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.
@@ -147,16 +147,16 @@ function parseEnvContent(content) {
147
147
  }
148
148
  return result;
149
149
  }
150
- function loadEnv(path10, override = false) {
150
+ function loadEnv(path9, override = false) {
151
151
  const fromEnv = (process.env.TINA4_ENV_FILE ?? "").trim();
152
- if (path10 === void 0 && fromEnv.length > 0) {
152
+ if (path9 === void 0 && fromEnv.length > 0) {
153
153
  const named = resolve(fromEnv);
154
154
  return mergeFirstWins(
155
155
  loadEnvFile(join(dirname(named), ".env.local"), override),
156
156
  loadEnvFile(named, override)
157
157
  );
158
158
  }
159
- const target = resolve(path10 ?? ".");
159
+ const target = resolve(path9 ?? ".");
160
160
  if (existsSync(target) && statSync(target).isDirectory()) {
161
161
  return mergeFirstWins(
162
162
  loadEnvFile(join(target, ".env.local"), override),
@@ -393,12 +393,12 @@ function resolveCallerName() {
393
393
  return void 0;
394
394
  }
395
395
  }
396
- function targetIsFile(path10) {
396
+ function targetIsFile(path9) {
397
397
  try {
398
- if (existsSync2(path10) && statSync2(path10).isDirectory()) return false;
398
+ if (existsSync2(path9) && statSync2(path9).isDirectory()) return false;
399
399
  } catch {
400
400
  }
401
- const base = basename(path10);
401
+ const base = basename(path9);
402
402
  return base.includes(".") && !base.startsWith(".");
403
403
  }
404
404
  function resolveBool(explicit, envName, fallback) {
@@ -722,8 +722,8 @@ var init_logger = __esm({
722
722
  rotateSize;
723
723
  rotateKeep;
724
724
  lock;
725
- constructor(path10, rotateSize, rotateKeep, lockBuffer) {
726
- this.path = path10;
725
+ constructor(path9, rotateSize, rotateKeep, lockBuffer) {
726
+ this.path = path9;
727
727
  this.rotateSize = rotateSize;
728
728
  this.rotateKeep = rotateKeep;
729
729
  this.lock = new SinkLock(lockBuffer);
@@ -1244,8 +1244,8 @@ function hashPassword(password, salt, iterations = 26e4) {
1244
1244
  }
1245
1245
  function checkPassword(password, hash) {
1246
1246
  try {
1247
- const delimiter2 = hash.includes("$") ? "$" : ":";
1248
- const parts = hash.split(delimiter2);
1247
+ const delimiter3 = hash.includes("$") ? "$" : ":";
1248
+ const parts = hash.split(delimiter3);
1249
1249
  if (parts.length !== 4 || parts[0] !== "pbkdf2_sha256") return false;
1250
1250
  const iterations = parseInt(parts[1], 10);
1251
1251
  const salt = parts[2];
@@ -1721,8 +1721,8 @@ var init_modelCollection = __esm({
1721
1721
 
1722
1722
  // ../orm/src/databaseUrl.ts
1723
1723
  import { inspect } from "node:util";
1724
- function stripOneSlash(path10) {
1725
- return path10.startsWith("/") ? path10.slice(1) : path10;
1724
+ function stripOneSlash(path9) {
1725
+ return path9.startsWith("/") ? path9.slice(1) : path9;
1726
1726
  }
1727
1727
  function decode(value) {
1728
1728
  if (value === void 0 || value === "") return null;
@@ -3729,8 +3729,8 @@ function resolveSqlitePath(dbPath) {
3729
3729
  return dbPath;
3730
3730
  }
3731
3731
  const cwd = resolve2(process.cwd());
3732
- const path10 = join4(cwd, dbPath);
3733
- const parent = dirname3(path10);
3732
+ const path9 = join4(cwd, dbPath);
3733
+ const parent = dirname3(path9);
3734
3734
  const absParent = resolve2(parent);
3735
3735
  if (absParent !== cwd && !absParent.startsWith(cwd + sep)) {
3736
3736
  throw new Error(
@@ -3738,7 +3738,7 @@ function resolveSqlitePath(dbPath) {
3738
3738
  );
3739
3739
  }
3740
3740
  mkdirSync2(parent, { recursive: true, mode: 509 });
3741
- return path10;
3741
+ return path9;
3742
3742
  }
3743
3743
  function fieldTypeToSQLite(def) {
3744
3744
  switch (def.type) {
@@ -7617,9 +7617,9 @@ async function initDatabase(config) {
7617
7617
  const rawType = config?.type ?? "sqlite";
7618
7618
  const type2 = rawType === "sqlserver" ? "mssql" : rawType;
7619
7619
  if (config === void 0 && !process.env.TINA4_DATABASE_URL) {
7620
- const path10 = "./data/tina4.db";
7620
+ const path9 = "./data/tina4.db";
7621
7621
  console.warn(
7622
- `[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.)`
7622
+ `[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.)`
7623
7623
  );
7624
7624
  }
7625
7625
  const finished = (adapter) => {
@@ -8834,6 +8834,7 @@ var init_database = __esm({
8834
8834
  // ../orm/src/model.ts
8835
8835
  import { readdirSync, statSync as statSync3 } from "node:fs";
8836
8836
  import { join as join5, extname } from "node:path";
8837
+ import { pathToFileURL } from "node:url";
8837
8838
  async function discoverModels(modelsDir) {
8838
8839
  const models = [];
8839
8840
  let files;
@@ -8849,7 +8850,7 @@ async function discoverModels(modelsDir) {
8849
8850
  const ext = extname(file);
8850
8851
  if (ext !== ".ts" && ext !== ".js") continue;
8851
8852
  try {
8852
- const moduleUrl = `file://${filePath}?t=${Date.now()}`;
8853
+ const moduleUrl = `${pathToFileURL(filePath).href}?t=${Date.now()}`;
8853
8854
  const mod = await import(moduleUrl);
8854
8855
  const ModelClass = mod.default ?? mod;
8855
8856
  if (!ModelClass.tableName || !ModelClass.fields) {
@@ -9190,7 +9191,7 @@ async function removeMigrationRecord(name) {
9190
9191
  [name]
9191
9192
  );
9192
9193
  }
9193
- async function rollback(migrationsDir, delimiter2) {
9194
+ async function rollback(migrationsDir, delimiter3) {
9194
9195
  if (migrationsDir instanceof Map) {
9195
9196
  const downFunctions = migrationsDir;
9196
9197
  const migrations2 = await getLastBatchMigrations();
@@ -9209,7 +9210,7 @@ async function rollback(migrationsDir, delimiter2) {
9209
9210
  return rolledBack2;
9210
9211
  }
9211
9212
  const dir = resolve3(migrationsDir ?? "migrations");
9212
- const delim = delimiter2 ?? ";";
9213
+ const delim = delimiter3 ?? ";";
9213
9214
  const db = getAdapter();
9214
9215
  const migrations = await getLastBatchMigrations();
9215
9216
  const rolledBack = [];
@@ -9332,13 +9333,13 @@ function hasExecutableSql(sql) {
9332
9333
  function isUnappliedScaffold(sql) {
9333
9334
  return TINA4_EDIT_MARKER_RE.test(sql) && !hasExecutableSql(sql);
9334
9335
  }
9335
- function splitStatements(sql, delimiter2 = ";") {
9336
+ function splitStatements(sql, delimiter3 = ";") {
9336
9337
  const state = {
9337
9338
  sql: normalizeQuotes(sql),
9338
9339
  statements: [],
9339
9340
  current: "",
9340
- delimiter: delimiter2,
9341
- dlen: delimiter2.length,
9341
+ delimiter: delimiter3,
9342
+ dlen: delimiter3.length,
9342
9343
  i: 0,
9343
9344
  inDollarBlock: false,
9344
9345
  inSlashBlock: false
@@ -9465,18 +9466,18 @@ async function releaseMigrationLock(db, lock) {
9465
9466
  async function migrate(adapter, options) {
9466
9467
  const db = adapter ?? getAdapter();
9467
9468
  const dir = resolve3(options?.migrationsDir ?? "migrations");
9468
- const delimiter2 = options?.delimiter ?? ";";
9469
+ const delimiter3 = options?.delimiter ?? ";";
9469
9470
  if (!existsSync4(dir)) {
9470
9471
  return { applied: [], skipped: [], failed: [] };
9471
9472
  }
9472
9473
  const lock = await acquireMigrationLock(db, dir);
9473
9474
  try {
9474
- return await runPendingMigrations(db, dir, delimiter2);
9475
+ return await runPendingMigrations(db, dir, delimiter3);
9475
9476
  } finally {
9476
9477
  await releaseMigrationLock(db, lock);
9477
9478
  }
9478
9479
  }
9479
- async function runPendingMigrations(db, dir, delimiter2) {
9480
+ async function runPendingMigrations(db, dir, delimiter3) {
9480
9481
  const result = { applied: [], skipped: [], failed: [] };
9481
9482
  await ensureMigrationTableOn(db);
9482
9483
  const files = sortMigrationFiles(
@@ -9522,7 +9523,7 @@ async function runPendingMigrations(db, dir, delimiter2) {
9522
9523
  );
9523
9524
  continue;
9524
9525
  }
9525
- const statements = splitStatements(sqlContent, delimiter2);
9526
+ const statements = splitStatements(sqlContent, delimiter3);
9526
9527
  try {
9527
9528
  await adapterStartTransaction(db);
9528
9529
  for (const stmt of statements) {
@@ -10702,15 +10703,15 @@ function findOutsideQuotes(expr, needle) {
10702
10703
  }
10703
10704
  return -1;
10704
10705
  }
10705
- function splitOutsideQuotes(expr, sep9) {
10706
- if (!expr.includes(sep9)) return [expr];
10706
+ function splitOutsideQuotes(expr, sep10) {
10707
+ if (!expr.includes(sep10)) return [expr];
10707
10708
  const parts = [];
10708
10709
  let currentStart = 0;
10709
10710
  let inQuote = null;
10710
10711
  let depth = 0;
10711
10712
  let bracketDepth = 0;
10712
10713
  let i = 0;
10713
- const sepLen = sep9.length;
10714
+ const sepLen = sep10.length;
10714
10715
  const lastStart = expr.length - sepLen;
10715
10716
  while (i <= lastStart) {
10716
10717
  const ch = expr[i];
@@ -10731,7 +10732,7 @@ function splitOutsideQuotes(expr, sep9) {
10731
10732
  else if (ch === ")") depth--;
10732
10733
  else if (ch === "[") bracketDepth++;
10733
10734
  else if (ch === "]") bracketDepth--;
10734
- if (depth === 0 && bracketDepth === 0 && expr.startsWith(sep9, i)) {
10735
+ if (depth === 0 && bracketDepth === 0 && expr.startsWith(sep10, i)) {
10735
10736
  parts.push(expr.slice(currentStart, i));
10736
10737
  i += sepLen;
10737
10738
  currentStart = i;
@@ -11909,8 +11910,8 @@ var init_engine = __esm({
11909
11910
  },
11910
11911
  first: (v) => Array.isArray(v) ? v[0] ?? null : null,
11911
11912
  last: (v) => Array.isArray(v) ? v[v.length - 1] ?? null : null,
11912
- join: (v, sep9) => Array.isArray(v) ? v.map(String).join(sep9 !== void 0 ? String(sep9) : ", ") : String(v),
11913
- split: (v, sep9) => String(v).split(sep9 !== void 0 ? String(sep9) : " "),
11913
+ join: (v, sep10) => Array.isArray(v) ? v.map(String).join(sep10 !== void 0 ? String(sep10) : ", ") : String(v),
11914
+ split: (v, sep10) => String(v).split(sep10 !== void 0 ? String(sep10) : " "),
11914
11915
  replace: (v, from, to) => {
11915
11916
  const s = String(v);
11916
11917
  if (from !== void 0 && typeof from === "object" && from !== null && !Array.isArray(from)) {
@@ -16072,6 +16073,7 @@ var init_baseModel = __esm({
16072
16073
  import { randomInt, randomUUID } from "node:crypto";
16073
16074
  import { existsSync as existsSync7, readdirSync as readdirSync3 } from "node:fs";
16074
16075
  import { resolve as resolve5, join as join8 } from "node:path";
16076
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
16075
16077
  function mulberry32(seed) {
16076
16078
  let s = seed | 0;
16077
16079
  return () => {
@@ -16575,7 +16577,7 @@ var init_fakeData = __esm({
16575
16577
  for (const file of files) {
16576
16578
  const fullPath = join8(dir, file);
16577
16579
  try {
16578
- const mod = await import(fullPath);
16580
+ const mod = await import(pathToFileURL2(fullPath).href);
16579
16581
  if (typeof mod.default === "function") {
16580
16582
  await mod.default();
16581
16583
  }
@@ -17300,12 +17302,12 @@ function regexpFn(pattern, value) {
17300
17302
  }
17301
17303
  function resolveStorePath(dbPath) {
17302
17304
  if (dbPath === ":memory:") return dbPath;
17303
- let path10 = dbPath;
17304
- if (!isAbsolute4(path10)) {
17305
- path10 = join9(process.cwd(), path10);
17306
- mkdirSync4(dirname5(path10), { recursive: true });
17305
+ let path9 = dbPath;
17306
+ if (!isAbsolute4(path9)) {
17307
+ path9 = join9(process.cwd(), path9);
17308
+ mkdirSync4(dirname5(path9), { recursive: true });
17307
17309
  }
17308
- return path10;
17310
+ return path9;
17309
17311
  }
17310
17312
  function mongoUriSource() {
17311
17313
  return MONGO_URI_VARS.find((name) => (process.env[name] ?? "").trim() !== "") ?? "";
@@ -17684,8 +17686,8 @@ var init_docstore = __esm({
17684
17686
  path;
17685
17687
  conn;
17686
17688
  collections = /* @__PURE__ */ new Map();
17687
- constructor(path10) {
17688
- this.path = path10 || process.env.TINA4_DOC_STORE_PATH || "data/tina4_docstore.db";
17689
+ constructor(path9) {
17690
+ this.path = path9 || process.env.TINA4_DOC_STORE_PATH || "data/tina4_docstore.db";
17689
17691
  const resolved = resolveStorePath(this.path);
17690
17692
  this.conn = new DatabaseSync2(resolved);
17691
17693
  this.conn.function("regexp", regexpFn);
@@ -17774,8 +17776,8 @@ var init_graphUrl = __esm({
17774
17776
  this.engine = engine;
17775
17777
  this.host = parsed.hostname || "localhost";
17776
17778
  this.port = parsed.port ? parseInt(parsed.port, 10) : ENGINE_DEFAULT_PORT[engine];
17777
- const path10 = (parsed.pathname || "").replace(/^\//, "");
17778
- this.graph = path10 === "" ? null : path10;
17779
+ const path9 = (parsed.pathname || "").replace(/^\//, "");
17780
+ this.graph = path9 === "" ? null : path9;
17779
17781
  this.username = parsed.username ? decodeURIComponent(parsed.username) : null;
17780
17782
  this.password = parsed.password ? decodeURIComponent(parsed.password) : null;
17781
17783
  this.params = {};
@@ -20936,8 +20938,8 @@ function coerceParam(raw, type2) {
20936
20938
  return raw;
20937
20939
  }
20938
20940
  }
20939
- function joinGroupPath(prefix, path10) {
20940
- const full = `${prefix}/${path10.replace(/^\/+/, "")}`;
20941
+ function joinGroupPath(prefix, path9) {
20942
+ const full = `${prefix}/${path9.replace(/^\/+/, "")}`;
20941
20943
  const trimmed = `/${trimSlashes(full)}`;
20942
20944
  return trimmed.replace(/\/+/g, "/");
20943
20945
  }
@@ -20978,26 +20980,26 @@ async function runRouteMiddlewares(middlewares, req2, res) {
20978
20980
  }
20979
20981
  return true;
20980
20982
  }
20981
- function get(path10, handler, middlewares, meta) {
20982
- return defaultRouter.get(path10, handler, middlewares, meta);
20983
+ function get(path9, handler, middlewares, meta) {
20984
+ return defaultRouter.get(path9, handler, middlewares, meta);
20983
20985
  }
20984
- function post(path10, handler, middlewares, meta) {
20985
- return defaultRouter.post(path10, handler, middlewares, meta);
20986
+ function post(path9, handler, middlewares, meta) {
20987
+ return defaultRouter.post(path9, handler, middlewares, meta);
20986
20988
  }
20987
- function put(path10, handler, middlewares, meta) {
20988
- return defaultRouter.put(path10, handler, middlewares, meta);
20989
+ function put(path9, handler, middlewares, meta) {
20990
+ return defaultRouter.put(path9, handler, middlewares, meta);
20989
20991
  }
20990
- function patch(path10, handler, middlewares, meta) {
20991
- return defaultRouter.patch(path10, handler, middlewares, meta);
20992
+ function patch(path9, handler, middlewares, meta) {
20993
+ return defaultRouter.patch(path9, handler, middlewares, meta);
20992
20994
  }
20993
- function del(path10, handler, middlewares, meta) {
20994
- return defaultRouter.delete(path10, handler, middlewares, meta);
20995
+ function del(path9, handler, middlewares, meta) {
20996
+ return defaultRouter.delete(path9, handler, middlewares, meta);
20995
20997
  }
20996
- function any(path10, handler, middlewares, meta) {
20997
- return defaultRouter.any(path10, handler, middlewares, meta);
20998
+ function any(path9, handler, middlewares, meta) {
20999
+ return defaultRouter.any(path9, handler, middlewares, meta);
20998
21000
  }
20999
- function websocket(path10, handler, options) {
21000
- return defaultRouter.websocket(path10, handler, options);
21001
+ function websocket(path9, handler, options) {
21002
+ return defaultRouter.websocket(path9, handler, options);
21001
21003
  }
21002
21004
  var WsRouteRef, RouteRef, Router, RouteGroup, TINA4_DEFAULT_ROUTER, globalRouterHost, defaultRouter;
21003
21005
  var init_router = __esm({
@@ -21145,32 +21147,32 @@ var init_router = __esm({
21145
21147
  /**
21146
21148
  * Register a GET route programmatically.
21147
21149
  */
21148
- get(path10, handler, middlewares, meta) {
21149
- return this.addRoute({ method: "GET", pattern: path10, handler, middlewares, meta });
21150
+ get(path9, handler, middlewares, meta) {
21151
+ return this.addRoute({ method: "GET", pattern: path9, handler, middlewares, meta });
21150
21152
  }
21151
21153
  /**
21152
21154
  * Register a POST route programmatically.
21153
21155
  */
21154
- post(path10, handler, middlewares, meta) {
21155
- return this.addRoute({ method: "POST", pattern: path10, handler, middlewares, meta });
21156
+ post(path9, handler, middlewares, meta) {
21157
+ return this.addRoute({ method: "POST", pattern: path9, handler, middlewares, meta });
21156
21158
  }
21157
21159
  /**
21158
21160
  * Register a PUT route programmatically.
21159
21161
  */
21160
- put(path10, handler, middlewares, meta) {
21161
- return this.addRoute({ method: "PUT", pattern: path10, handler, middlewares, meta });
21162
+ put(path9, handler, middlewares, meta) {
21163
+ return this.addRoute({ method: "PUT", pattern: path9, handler, middlewares, meta });
21162
21164
  }
21163
21165
  /**
21164
21166
  * Register a PATCH route programmatically.
21165
21167
  */
21166
- patch(path10, handler, middlewares, meta) {
21167
- return this.addRoute({ method: "PATCH", pattern: path10, handler, middlewares, meta });
21168
+ patch(path9, handler, middlewares, meta) {
21169
+ return this.addRoute({ method: "PATCH", pattern: path9, handler, middlewares, meta });
21168
21170
  }
21169
21171
  /**
21170
21172
  * Register a DELETE route programmatically.
21171
21173
  */
21172
- delete(path10, handler, middlewares, meta) {
21173
- return this.addRoute({ method: "DELETE", pattern: path10, handler, middlewares, meta });
21174
+ delete(path9, handler, middlewares, meta) {
21175
+ return this.addRoute({ method: "DELETE", pattern: path9, handler, middlewares, meta });
21174
21176
  }
21175
21177
  /**
21176
21178
  * Register an explicit HEAD route. By default the framework auto-handles
@@ -21180,8 +21182,8 @@ var init_router = __esm({
21180
21182
  * logic, custom validator headers without the cost of building the body.
21181
21183
  * The framework still strips the response body for you on the way out.
21182
21184
  */
21183
- head(path10, handler, middlewares, meta) {
21184
- return this.addRoute({ method: "HEAD", pattern: path10, handler, middlewares, meta });
21185
+ head(path9, handler, middlewares, meta) {
21186
+ return this.addRoute({ method: "HEAD", pattern: path9, handler, middlewares, meta });
21185
21187
  }
21186
21188
  /**
21187
21189
  * Register an explicit OPTIONS route. By default the framework auto-
@@ -21189,16 +21191,16 @@ var init_router = __esm({
21189
21191
  * registered for the path and returning 204 (RFC 9110 §9.3.7). Use
21190
21192
  * this to take over that behaviour.
21191
21193
  */
21192
- options(path10, handler, middlewares, meta) {
21193
- return this.addRoute({ method: "OPTIONS", pattern: path10, handler, middlewares, meta });
21194
+ options(path9, handler, middlewares, meta) {
21195
+ return this.addRoute({ method: "OPTIONS", pattern: path9, handler, middlewares, meta });
21194
21196
  }
21195
21197
  /**
21196
21198
  * Register a route that matches ANY HTTP method.
21197
21199
  */
21198
- any(path10, handler, middlewares, meta) {
21200
+ any(path9, handler, middlewares, meta) {
21199
21201
  let lastRef;
21200
21202
  for (const method of ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]) {
21201
- lastRef = this.addRoute({ method, pattern: path10, handler, middlewares, meta });
21203
+ lastRef = this.addRoute({ method, pattern: path9, handler, middlewares, meta });
21202
21204
  }
21203
21205
  return lastRef;
21204
21206
  }
@@ -21217,14 +21219,14 @@ var init_router = __esm({
21217
21219
  * the trailing slash. Returning the de-slashed pattern lets callers issue
21218
21220
  * a 308 redirect instead of a hard 404 — Python parity.
21219
21221
  */
21220
- match(method, path10) {
21222
+ match(method, path9) {
21221
21223
  const upperMethod = method.toUpperCase();
21222
21224
  const routes = this.routes.get(upperMethod);
21223
21225
  if (routes) {
21224
- const direct = this.matchRoute(routes, path10);
21226
+ const direct = this.matchRoute(routes, path9);
21225
21227
  if (direct) return direct;
21226
- if (isTrailingSlashRedirectEnabled() && path10.length > 1 && path10.endsWith("/")) {
21227
- const stripped = rtrimSlashes(path10);
21228
+ if (isTrailingSlashRedirectEnabled() && path9.length > 1 && path9.endsWith("/")) {
21229
+ const stripped = rtrimSlashes(path9);
21228
21230
  if (stripped.length > 0) {
21229
21231
  const retry = this.matchRoute(routes, stripped);
21230
21232
  if (retry) return retry;
@@ -21234,7 +21236,7 @@ var init_router = __esm({
21234
21236
  if (upperMethod === "HEAD") {
21235
21237
  const getRoutes = this.routes.get("GET");
21236
21238
  if (getRoutes) {
21237
- return this.matchRoute(getRoutes, path10);
21239
+ return this.matchRoute(getRoutes, path9);
21238
21240
  }
21239
21241
  }
21240
21242
  return null;
@@ -21249,13 +21251,13 @@ var init_router = __esm({
21249
21251
  * OPTIONS is appended whenever any method exists for the path (the
21250
21252
  * framework auto-handles OPTIONS).
21251
21253
  */
21252
- methodsAllowedForPath(path10) {
21254
+ methodsAllowedForPath(path9) {
21253
21255
  const order = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
21254
21256
  const seen = /* @__PURE__ */ new Set();
21255
21257
  for (const m of order) {
21256
21258
  const routes = this.routes.get(m);
21257
21259
  if (!routes) continue;
21258
- if (this.matchRoute(routes, path10)) {
21260
+ if (this.matchRoute(routes, path9)) {
21259
21261
  seen.add(m);
21260
21262
  }
21261
21263
  }
@@ -21266,9 +21268,9 @@ var init_router = __esm({
21266
21268
  return order.filter((m) => seen.has(m));
21267
21269
  }
21268
21270
  /** Inner match against a list of compiled routes, no trailing-slash logic. */
21269
- matchRoute(routes, path10) {
21271
+ matchRoute(routes, path9) {
21270
21272
  for (const route of routes) {
21271
- const match = route.regex.exec(path10);
21273
+ const match = route.regex.exec(path9);
21272
21274
  if (match) {
21273
21275
  const params = {};
21274
21276
  for (let i = 0; i < route.paramNames.length; i++) {
@@ -21356,10 +21358,10 @@ var init_router = __esm({
21356
21358
  * When secured, the upgrade handshake requires a valid JWT (Authorization
21357
21359
  * header / `bearer` subprotocol / `?token=`) or the upgrade is rejected.
21358
21360
  */
21359
- websocket(path10, handler, options) {
21360
- this.wsRoutes = this.wsRoutes.filter((r) => r.pattern !== path10);
21361
+ websocket(path9, handler, options) {
21362
+ this.wsRoutes = this.wsRoutes.filter((r) => r.pattern !== path9);
21361
21363
  const route = {
21362
- pattern: path10,
21364
+ pattern: path9,
21363
21365
  handler,
21364
21366
  // Public unless explicitly secured via options OR a handler `_secured` flag.
21365
21367
  authRequired: Boolean(options?.secured ?? handler._secured ?? false)
@@ -21416,54 +21418,54 @@ var init_router = __esm({
21416
21418
  * Register a route for a specific HTTP method.
21417
21419
  * Core registration method — all convenience methods delegate here.
21418
21420
  */
21419
- static add(method, path10, handler, middleware, swaggerMeta, template) {
21421
+ static add(method, path9, handler, middleware, swaggerMeta, template) {
21420
21422
  const m = method.toUpperCase();
21421
21423
  if (m === "ANY") {
21422
- return defaultRouter.any(path10, handler, middleware, swaggerMeta);
21424
+ return defaultRouter.any(path9, handler, middleware, swaggerMeta);
21423
21425
  }
21424
- return defaultRouter.addRoute({ method: m, pattern: path10, handler, middlewares: middleware, meta: swaggerMeta, template });
21426
+ return defaultRouter.addRoute({ method: m, pattern: path9, handler, middlewares: middleware, meta: swaggerMeta, template });
21425
21427
  }
21426
21428
  /**
21427
21429
  * Register a GET route on the default global router.
21428
21430
  */
21429
- static get(path10, handler, middleware, swaggerMeta, template) {
21430
- return defaultRouter.get(path10, handler, middleware, swaggerMeta);
21431
+ static get(path9, handler, middleware, swaggerMeta, template) {
21432
+ return defaultRouter.get(path9, handler, middleware, swaggerMeta);
21431
21433
  }
21432
21434
  /**
21433
21435
  * Register a POST route on the default global router.
21434
21436
  */
21435
- static post(path10, handler, middleware, swaggerMeta, template) {
21436
- return defaultRouter.post(path10, handler, middleware, swaggerMeta);
21437
+ static post(path9, handler, middleware, swaggerMeta, template) {
21438
+ return defaultRouter.post(path9, handler, middleware, swaggerMeta);
21437
21439
  }
21438
21440
  /**
21439
21441
  * Register a PUT route on the default global router.
21440
21442
  */
21441
- static put(path10, handler, middleware, swaggerMeta, template) {
21442
- return defaultRouter.put(path10, handler, middleware, swaggerMeta);
21443
+ static put(path9, handler, middleware, swaggerMeta, template) {
21444
+ return defaultRouter.put(path9, handler, middleware, swaggerMeta);
21443
21445
  }
21444
21446
  /**
21445
21447
  * Register a PATCH route on the default global router.
21446
21448
  */
21447
- static patch(path10, handler, middleware, swaggerMeta, template) {
21448
- return defaultRouter.patch(path10, handler, middleware, swaggerMeta);
21449
+ static patch(path9, handler, middleware, swaggerMeta, template) {
21450
+ return defaultRouter.patch(path9, handler, middleware, swaggerMeta);
21449
21451
  }
21450
21452
  /**
21451
21453
  * Register a DELETE route on the default global router.
21452
21454
  */
21453
- static delete(path10, handler, middleware, swaggerMeta, template) {
21454
- return defaultRouter.delete(path10, handler, middleware, swaggerMeta);
21455
+ static delete(path9, handler, middleware, swaggerMeta, template) {
21456
+ return defaultRouter.delete(path9, handler, middleware, swaggerMeta);
21455
21457
  }
21456
21458
  /**
21457
21459
  * Register a route that matches ANY HTTP method on the default global router.
21458
21460
  */
21459
- static any(path10, handler, middleware, swaggerMeta, template) {
21460
- return defaultRouter.any(path10, handler, middleware, swaggerMeta);
21461
+ static any(path9, handler, middleware, swaggerMeta, template) {
21462
+ return defaultRouter.any(path9, handler, middleware, swaggerMeta);
21461
21463
  }
21462
21464
  /**
21463
21465
  * Register a WebSocket route on the default global router.
21464
21466
  */
21465
- static websocket(path10, handler, options) {
21466
- return defaultRouter.websocket(path10, handler, options);
21467
+ static websocket(path9, handler, options) {
21468
+ return defaultRouter.websocket(path9, handler, options);
21467
21469
  }
21468
21470
  /**
21469
21471
  * Match a WebSocket upgrade path against routes on the default global router.
@@ -21579,57 +21581,57 @@ var init_router = __esm({
21579
21581
  const merged = [...group, ...route];
21580
21582
  return merged.length > 0 ? merged : void 0;
21581
21583
  }
21582
- get(path10, handler, middlewares, meta) {
21584
+ get(path9, handler, middlewares, meta) {
21583
21585
  return this.router.addRoute({
21584
21586
  method: "GET",
21585
- pattern: joinGroupPath(this.prefix, path10),
21587
+ pattern: joinGroupPath(this.prefix, path9),
21586
21588
  handler,
21587
21589
  middlewares: this.mergeMiddlewares(middlewares),
21588
21590
  meta
21589
21591
  });
21590
21592
  }
21591
- post(path10, handler, middlewares, meta) {
21593
+ post(path9, handler, middlewares, meta) {
21592
21594
  return this.router.addRoute({
21593
21595
  method: "POST",
21594
- pattern: joinGroupPath(this.prefix, path10),
21596
+ pattern: joinGroupPath(this.prefix, path9),
21595
21597
  handler,
21596
21598
  middlewares: this.mergeMiddlewares(middlewares),
21597
21599
  meta
21598
21600
  });
21599
21601
  }
21600
- put(path10, handler, middlewares, meta) {
21602
+ put(path9, handler, middlewares, meta) {
21601
21603
  return this.router.addRoute({
21602
21604
  method: "PUT",
21603
- pattern: joinGroupPath(this.prefix, path10),
21605
+ pattern: joinGroupPath(this.prefix, path9),
21604
21606
  handler,
21605
21607
  middlewares: this.mergeMiddlewares(middlewares),
21606
21608
  meta
21607
21609
  });
21608
21610
  }
21609
- patch(path10, handler, middlewares, meta) {
21611
+ patch(path9, handler, middlewares, meta) {
21610
21612
  return this.router.addRoute({
21611
21613
  method: "PATCH",
21612
- pattern: joinGroupPath(this.prefix, path10),
21614
+ pattern: joinGroupPath(this.prefix, path9),
21613
21615
  handler,
21614
21616
  middlewares: this.mergeMiddlewares(middlewares),
21615
21617
  meta
21616
21618
  });
21617
21619
  }
21618
- delete(path10, handler, middlewares, meta) {
21620
+ delete(path9, handler, middlewares, meta) {
21619
21621
  return this.router.addRoute({
21620
21622
  method: "DELETE",
21621
- pattern: joinGroupPath(this.prefix, path10),
21623
+ pattern: joinGroupPath(this.prefix, path9),
21622
21624
  handler,
21623
21625
  middlewares: this.mergeMiddlewares(middlewares),
21624
21626
  meta
21625
21627
  });
21626
21628
  }
21627
- any(path10, handler, middlewares, meta) {
21629
+ any(path9, handler, middlewares, meta) {
21628
21630
  let lastRef;
21629
21631
  for (const method of ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]) {
21630
21632
  lastRef = this.router.addRoute({
21631
21633
  method,
21632
- pattern: joinGroupPath(this.prefix, path10),
21634
+ pattern: joinGroupPath(this.prefix, path9),
21633
21635
  handler,
21634
21636
  middlewares: this.mergeMiddlewares(middlewares),
21635
21637
  meta
@@ -21831,6 +21833,7 @@ var init_trustedProxy = __esm({
21831
21833
  // src/response.ts
21832
21834
  import fs2 from "node:fs";
21833
21835
  import nodePath from "node:path";
21836
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
21834
21837
  import { once } from "node:events";
21835
21838
  async function closeSource(source) {
21836
21839
  const s = source;
@@ -21873,7 +21876,7 @@ async function getFrond() {
21873
21876
  return engine;
21874
21877
  }
21875
21878
  async function getFrameworkFrond() {
21876
- const frameworkDir = nodePath.resolve(nodePath.dirname(import.meta.url.replace("file://", "")), "..", "templates");
21879
+ const frameworkDir = nodePath.resolve(nodePath.dirname(fileURLToPath2(import.meta.url)), "..", "templates");
21877
21880
  if (!_frameworkFrond && fs2.existsSync(frameworkDir)) {
21878
21881
  try {
21879
21882
  const { Frond: Frond2, setCspNonceProvider: setCspNonceProvider2 } = await Promise.resolve().then(() => (init_engine(), engine_exports));
@@ -22908,9 +22911,9 @@ var init_middleware = __esm({
22908
22911
  const duration = Date.now() - (req2.startTime ?? Date.now());
22909
22912
  const status2 = res.raw.statusCode;
22910
22913
  const method = req2.method ?? "?";
22911
- const path10 = logPath(req2);
22914
+ const path9 = logPath(req2);
22912
22915
  const color = status2 >= 400 ? "\x1B[31m" : status2 >= 300 ? "\x1B[33m" : "\x1B[32m";
22913
- console.log(` ${color}${status2}\x1B[0m ${method} ${path10} \x1B[90m${duration}ms\x1B[0m`);
22916
+ console.log(` ${color}${status2}\x1B[0m ${method} ${path9} \x1B[90m${duration}ms\x1B[0m`);
22914
22917
  return [req2, res];
22915
22918
  }
22916
22919
  };
@@ -23075,7 +23078,7 @@ function createRequest(req2) {
23075
23078
  const xfHost = trustedPeer ? req2.headers["x-forwarded-host"] : void 0;
23076
23079
  const host = (Array.isArray(xfHost) ? xfHost[0] : xfHost) ?? (req2.headers.host ?? "localhost");
23077
23080
  const query = {};
23078
- let path10;
23081
+ let path9;
23079
23082
  let queryString;
23080
23083
  let fullUrl;
23081
23084
  try {
@@ -23084,13 +23087,13 @@ function createRequest(req2) {
23084
23087
  if (isUnsafeFieldName(key)) continue;
23085
23088
  Reflect.set(query, key, value);
23086
23089
  }
23087
- path10 = url.pathname;
23090
+ path9 = url.pathname;
23088
23091
  queryString = url.search.replace(/^\?/, "");
23089
23092
  fullUrl = url.toString();
23090
23093
  } catch {
23091
23094
  const rawTarget = req2.url ?? "/";
23092
23095
  const questionIdx = rawTarget.indexOf("?");
23093
- path10 = questionIdx >= 0 ? rawTarget.slice(0, questionIdx) : rawTarget;
23096
+ path9 = questionIdx >= 0 ? rawTarget.slice(0, questionIdx) : rawTarget;
23094
23097
  queryString = questionIdx >= 0 ? rawTarget.slice(questionIdx + 1) : "";
23095
23098
  try {
23096
23099
  for (const [key, value] of new URLSearchParams(queryString)) {
@@ -23103,7 +23106,7 @@ function createRequest(req2) {
23103
23106
  }
23104
23107
  tReq.params = {};
23105
23108
  w.query = query;
23106
- w.path = path10;
23109
+ w.path = path9;
23107
23110
  w.queryString = queryString;
23108
23111
  w.url = fullUrl;
23109
23112
  tReq.body = void 0;
@@ -23218,14 +23221,14 @@ function extractBoundary(contentType) {
23218
23221
  function parseMultipart(body, boundary) {
23219
23222
  const pairs = [];
23220
23223
  const files = {};
23221
- const delimiter2 = Buffer.from(`--${boundary}`);
23224
+ const delimiter3 = Buffer.from(`--${boundary}`);
23222
23225
  const closeDelimiter = Buffer.from(`--${boundary}--`);
23223
23226
  const crlf = Buffer.from("\r\n");
23224
23227
  const doubleCrlf = Buffer.from("\r\n\r\n");
23225
23228
  let offset = 0;
23226
- const firstIdx = bufferIndexOf(body, delimiter2, offset);
23229
+ const firstIdx = bufferIndexOf(body, delimiter3, offset);
23227
23230
  if (firstIdx === -1) return { fields: {}, files };
23228
- offset = firstIdx + delimiter2.length;
23231
+ offset = firstIdx + delimiter3.length;
23229
23232
  if (body[offset] === 13 && body[offset + 1] === 10) {
23230
23233
  offset += 2;
23231
23234
  }
@@ -23234,7 +23237,7 @@ function parseMultipart(body, boundary) {
23234
23237
  if (headersEnd === -1) break;
23235
23238
  const headersStr = body.subarray(offset, headersEnd).toString("utf-8");
23236
23239
  offset = headersEnd + doubleCrlf.length;
23237
- const nextDelimIdx = bufferIndexOf(body, delimiter2, offset);
23240
+ const nextDelimIdx = bufferIndexOf(body, delimiter3, offset);
23238
23241
  if (nextDelimIdx === -1) break;
23239
23242
  const contentEnd = nextDelimIdx - crlf.length;
23240
23243
  const content = body.subarray(offset, contentEnd);
@@ -23258,7 +23261,7 @@ function parseMultipart(body, boundary) {
23258
23261
  } else if (disposition.name) {
23259
23262
  pairs.push([disposition.name, content.toString("utf-8")]);
23260
23263
  }
23261
- offset = nextDelimIdx + delimiter2.length;
23264
+ offset = nextDelimIdx + delimiter3.length;
23262
23265
  if (body[offset] === 45 && body[offset + 1] === 45) {
23263
23266
  break;
23264
23267
  }
@@ -23818,6 +23821,7 @@ __export(routeDiscovery_exports, {
23818
23821
  });
23819
23822
  import { readdirSync as readdirSync5, statSync as statSync7, mkdirSync as mkdirSync8, writeFileSync as writeFileSync5, existsSync as existsSync9 } from "node:fs";
23820
23823
  import { join as join12, relative, basename as basename2, extname as extname2 } from "node:path";
23824
+ import { pathToFileURL as pathToFileURL3 } from "node:url";
23821
23825
  function boolExport(value) {
23822
23826
  return typeof value === "boolean" ? value : void 0;
23823
23827
  }
@@ -23839,7 +23843,7 @@ async function discoverRoutes(routesDir) {
23839
23843
  const relativePath2 = relative(routesDir, filePath);
23840
23844
  const pattern = filePathToPattern(relativePath2);
23841
23845
  try {
23842
- const moduleUrl = `file://${filePath}?t=${currentMtime}`;
23846
+ const moduleUrl = `${pathToFileURL3(filePath).href}?t=${currentMtime}`;
23843
23847
  const mod = await import(moduleUrl);
23844
23848
  const handler = mod.default ?? mod.handler;
23845
23849
  if (typeof handler !== "function") {
@@ -23880,7 +23884,7 @@ function recordBrokenImport(filePath, error2) {
23880
23884
  try {
23881
23885
  const brokenDir = join12(process.cwd(), "data", ".broken");
23882
23886
  if (!existsSync9(brokenDir)) mkdirSync8(brokenDir, { recursive: true });
23883
- const slug = filePath.replace(/[/\\]/g, "_");
23887
+ const slug = filePath.replace(/[/\\:]/g, "_");
23884
23888
  const payload = JSON.stringify({
23885
23889
  type: "auto_discover_failure",
23886
23890
  file: filePath,
@@ -24020,17 +24024,17 @@ function sleepSync(ms) {
24020
24024
  if (ms <= 0) return;
24021
24025
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
24022
24026
  }
24023
- function bindable(host, port) {
24027
+ function probeBind(host, port, timeout = 5e3) {
24024
24028
  try {
24025
- execFileSync(process.execPath, ["-e", BIND_PROBE, host, String(port)], { stdio: "ignore", timeout: 5e3 });
24026
- return true;
24027
- } catch {
24028
- return false;
24029
+ execFileSync(process.execPath, ["-e", BIND_PROBE, host, String(port)], { stdio: "ignore", timeout });
24030
+ return "free";
24031
+ } catch (err) {
24032
+ return err.status === PROBE_HELD ? "held" : "unknown";
24029
24033
  }
24030
24034
  }
24031
24035
  function refusal(port, dev, noTakeover, host) {
24032
24036
  if (dev && !noTakeover) return null;
24033
- if (host !== void 0 && bindable(host, port)) {
24037
+ if (host !== void 0 && probeBind(host, port) !== "held") {
24034
24038
  return { status: TAKEOVER_NOTHING, port, killed: [], message: "" };
24035
24039
  }
24036
24040
  if (noTakeover) {
@@ -24078,7 +24082,7 @@ function takeOverPort(port, dev, noTakeover, baseDir, grace = 500, host) {
24078
24082
  `Reclaimed port ${port} from Tina4 dev server (PID: ${killed.join(", ")}).`
24079
24083
  );
24080
24084
  }
24081
- var TAKEOVER_NOTHING, TAKEOVER_KILLED, TAKEOVER_REFUSED_FOREIGN, TAKEOVER_REFUSED_OPTOUT, TAKEOVER_REFUSED_PROD, TAKEOVER_SKIPPED_CONTAINER, TAKEOVER_REFUSALS, BIND_PROBE;
24085
+ 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;
24082
24086
  var init_portTakeover = __esm({
24083
24087
  "src/portTakeover.ts"() {
24084
24088
  "use strict";
@@ -24093,7 +24097,9 @@ var init_portTakeover = __esm({
24093
24097
  TAKEOVER_REFUSED_OPTOUT,
24094
24098
  TAKEOVER_REFUSED_PROD
24095
24099
  ];
24096
- 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)));';
24100
+ PROBE_HELD = 3;
24101
+ PROBE_OTHER = 4;
24102
+ 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)));`;
24097
24103
  }
24098
24104
  });
24099
24105
 
@@ -25271,6 +25277,21 @@ var init_databaseHandler = __esm({
25271
25277
  }
25272
25278
  return this.sqliteHandle;
25273
25279
  }
25280
+ /**
25281
+ * Release the SQLite connection this handler opened, so its file (and the
25282
+ * WAL's -wal / -shm side files) is no longer held open: on Windows an open
25283
+ * file cannot be deleted or replaced. Idempotent, and the next read or write
25284
+ * reopens the connection. A server engine needs nothing here - each call goes
25285
+ * through the sync bridge, which holds no connection between calls.
25286
+ */
25287
+ close() {
25288
+ if (this.sqliteHandle === null) return;
25289
+ try {
25290
+ this.sqliteHandle.close();
25291
+ } finally {
25292
+ this.sqliteHandle = null;
25293
+ }
25294
+ }
25274
25295
  get engine() {
25275
25296
  return this.target === null ? "sqlite" : this.target.engine;
25276
25297
  }
@@ -26471,8 +26492,8 @@ function tryServeStatic(staticDir, req2, res) {
26471
26492
  }
26472
26493
  return false;
26473
26494
  }
26474
- function hasHiddenSegment(path10, separator = "/") {
26475
- return path10.split(separator).some((segment) => segment.length > 0 && segment.startsWith("."));
26495
+ function hasHiddenSegment(path9, separator = "/") {
26496
+ return path9.split(separator).some((segment) => segment.length > 0 && segment.startsWith("."));
26476
26497
  }
26477
26498
  function conditionalHeader(req2, name) {
26478
26499
  const headers = req2.headers;
@@ -26796,10 +26817,10 @@ function createHealthRoute(version = "3.0.0") {
26796
26817
  function createHealthRoutes(version = "3.0.0") {
26797
26818
  startTime = Date.now();
26798
26819
  const routes = [];
26799
- const path10 = healthPath();
26820
+ const path9 = healthPath();
26800
26821
  routes.push({
26801
26822
  method: "GET",
26802
- pattern: path10,
26823
+ pattern: path9,
26803
26824
  handler: buildHandler(version),
26804
26825
  meta: {
26805
26826
  summary: "Health check",
@@ -26807,7 +26828,7 @@ function createHealthRoutes(version = "3.0.0") {
26807
26828
  tags: ["System"]
26808
26829
  }
26809
26830
  });
26810
- if (path10 !== "/health") {
26831
+ if (path9 !== "/health") {
26811
26832
  routes.push({
26812
26833
  method: "GET",
26813
26834
  pattern: "/health",
@@ -26885,9 +26906,72 @@ var init_rateLimiter = __esm({
26885
26906
  }
26886
26907
  });
26887
26908
 
26909
+ // src/batchSpawn.ts
26910
+ import { spawnSync } from "node:child_process";
26911
+ import { existsSync as existsSync12, statSync as statSync10 } from "node:fs";
26912
+ import { delimiter, extname as extname4, join as join16 } from "node:path";
26913
+ function isBatchFile(file, platform = process.platform) {
26914
+ return platform === "win32" && /\.(cmd|bat)$/i.test(file);
26915
+ }
26916
+ function escapeBatchArgument(arg) {
26917
+ let quoted = String(arg).replace(/(\\*)"/g, '$1$1\\"').replace(/(\\*)$/, "$1$1");
26918
+ quoted = `"${quoted}"`;
26919
+ return quoted.replace(CMD_META, "^$1").replace(CMD_META, "^$1");
26920
+ }
26921
+ function escapeBatchCommand(file) {
26922
+ return file.replace(CMD_META, "^$1");
26923
+ }
26924
+ function findExecutable(name, platform = process.platform) {
26925
+ if (platform !== "win32" || /[\\/]/.test(name) || extname4(name) !== "") return name;
26926
+ const exts = (process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
26927
+ const dirs = (process.env.PATH || "").split(delimiter).filter(Boolean);
26928
+ const candidates = dirs.flatMap((dir) => exts.map((ext) => join16(dir, name + ext.toLowerCase())));
26929
+ return candidates.find(isRegularFile) ?? name;
26930
+ }
26931
+ function isRegularFile(path9) {
26932
+ try {
26933
+ return existsSync12(path9) && statSync10(path9).isFile();
26934
+ } catch {
26935
+ return false;
26936
+ }
26937
+ }
26938
+ function spawnSyncAllowingBatch(file, args, options = {}) {
26939
+ if (!isBatchFile(file)) return spawnSync(file, args, options);
26940
+ const line = [escapeBatchCommand(file), ...args.map(escapeBatchArgument)].join(" ");
26941
+ const shell = process.env.comspec || "cmd.exe";
26942
+ return spawnSync(shell, ["/d", "/s", "/c", `"${line}"`], {
26943
+ ...options,
26944
+ windowsVerbatimArguments: true
26945
+ });
26946
+ }
26947
+ function execFileSyncAllowingBatch(name, args, options = {}) {
26948
+ const result = spawnSyncAllowingBatch(findExecutable(name), args, { encoding: "utf-8", ...options });
26949
+ if (result.error) throw result.error;
26950
+ const stdout = String(result.stdout ?? "");
26951
+ const stderr = String(result.stderr ?? "");
26952
+ if (result.status !== 0) {
26953
+ const err = new Error(
26954
+ `Command failed: ${name} ${args.join(" ")} (exit ${result.status ?? result.signal})
26955
+ ${stderr}`.trim()
26956
+ );
26957
+ err.status = result.status;
26958
+ err.stdout = stdout;
26959
+ err.stderr = stderr;
26960
+ throw err;
26961
+ }
26962
+ return stdout;
26963
+ }
26964
+ var CMD_META;
26965
+ var init_batchSpawn = __esm({
26966
+ "src/batchSpawn.ts"() {
26967
+ "use strict";
26968
+ CMD_META = /([()\][%!^"`<>&|;, *?])/g;
26969
+ }
26970
+ });
26971
+
26888
26972
  // src/devMailbox.ts
26889
- import { mkdirSync as mkdirSync11, readdirSync as readdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync8, unlinkSync as unlinkSync7, existsSync as existsSync12 } from "node:fs";
26890
- import { join as join16 } from "node:path";
26973
+ import { mkdirSync as mkdirSync11, readdirSync as readdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync8, unlinkSync as unlinkSync7, existsSync as existsSync13 } from "node:fs";
26974
+ import { join as join17 } from "node:path";
26891
26975
  import { randomUUID as randomUUID2 } from "node:crypto";
26892
26976
  var DevMailbox;
26893
26977
  var init_devMailbox = __esm({
@@ -26902,7 +26986,7 @@ var init_devMailbox = __esm({
26902
26986
  * Ensure a folder directory exists.
26903
26987
  */
26904
26988
  ensureFolder(folder) {
26905
- const dir = join16(this.mailboxDir, folder);
26989
+ const dir = join17(this.mailboxDir, folder);
26906
26990
  mkdirSync11(dir, { recursive: true });
26907
26991
  return dir;
26908
26992
  }
@@ -26941,10 +27025,10 @@ var init_devMailbox = __esm({
26941
27025
  read: false
26942
27026
  };
26943
27027
  const outboxDir = this.ensureFolder("outbox");
26944
- writeFileSync8(join16(outboxDir, `${id}.json`), JSON.stringify(message, null, 2));
27028
+ writeFileSync8(join17(outboxDir, `${id}.json`), JSON.stringify(message, null, 2));
26945
27029
  const inboxDir = this.ensureFolder("inbox");
26946
27030
  const inboxMessage = { ...message, type: "inbox" };
26947
- writeFileSync8(join16(inboxDir, `${id}.json`), JSON.stringify(inboxMessage, null, 2));
27031
+ writeFileSync8(join17(inboxDir, `${id}.json`), JSON.stringify(inboxMessage, null, 2));
26948
27032
  return { success: true, message: "Email captured to dev mailbox", id };
26949
27033
  }
26950
27034
  /**
@@ -26962,7 +27046,7 @@ var init_devMailbox = __esm({
26962
27046
  const sliced = files.slice(offset, offset + limit);
26963
27047
  for (const file of sliced) {
26964
27048
  try {
26965
- const msg = JSON.parse(readFileSync11(join16(dir, file), "utf-8"));
27049
+ const msg = JSON.parse(readFileSync11(join17(dir, file), "utf-8"));
26966
27050
  results.push(msg);
26967
27051
  } catch {
26968
27052
  }
@@ -26975,8 +27059,8 @@ var init_devMailbox = __esm({
26975
27059
  read(msgId) {
26976
27060
  const folders = ["inbox", "outbox"];
26977
27061
  for (const folder of folders) {
26978
- const filePath = join16(this.mailboxDir, folder, `${msgId}.json`);
26979
- if (existsSync12(filePath)) {
27062
+ const filePath = join17(this.mailboxDir, folder, `${msgId}.json`);
27063
+ if (existsSync13(filePath)) {
26980
27064
  try {
26981
27065
  const msg = JSON.parse(readFileSync11(filePath, "utf-8"));
26982
27066
  msg.read = true;
@@ -26999,7 +27083,7 @@ var init_devMailbox = __esm({
26999
27083
  const files = readdirSync7(dir).filter((f) => f.endsWith(".json"));
27000
27084
  for (const file of files) {
27001
27085
  try {
27002
- const msg = JSON.parse(readFileSync11(join16(dir, file), "utf-8"));
27086
+ const msg = JSON.parse(readFileSync11(join17(dir, file), "utf-8"));
27003
27087
  if (!msg.read) count++;
27004
27088
  } catch {
27005
27089
  }
@@ -27015,8 +27099,8 @@ var init_devMailbox = __esm({
27015
27099
  let deleted = false;
27016
27100
  const folders = ["inbox", "outbox"];
27017
27101
  for (const folder of folders) {
27018
- const filePath = join16(this.mailboxDir, folder, `${msgId}.json`);
27019
- if (existsSync12(filePath)) {
27102
+ const filePath = join17(this.mailboxDir, folder, `${msgId}.json`);
27103
+ if (existsSync13(filePath)) {
27020
27104
  try {
27021
27105
  unlinkSync7(filePath);
27022
27106
  deleted = true;
@@ -27032,12 +27116,12 @@ var init_devMailbox = __esm({
27032
27116
  clear(folder) {
27033
27117
  const folders = folder ? [folder] : ["inbox", "outbox"];
27034
27118
  for (const f of folders) {
27035
- const dir = join16(this.mailboxDir, f);
27119
+ const dir = join17(this.mailboxDir, f);
27036
27120
  try {
27037
- if (existsSync12(dir)) {
27121
+ if (existsSync13(dir)) {
27038
27122
  const files = readdirSync7(dir).filter((file) => file.endsWith(".json"));
27039
27123
  for (const file of files) {
27040
- unlinkSync7(join16(dir, file));
27124
+ unlinkSync7(join17(dir, file));
27041
27125
  }
27042
27126
  }
27043
27127
  } catch {
@@ -27090,7 +27174,7 @@ Generated by DevMailbox.seed() for development purposes.`,
27090
27174
  // first two are unread
27091
27175
  };
27092
27176
  const dir = this.ensureFolder("inbox");
27093
- writeFileSync8(join16(dir, `${id}.json`), JSON.stringify(message, null, 2));
27177
+ writeFileSync8(join17(dir, `${id}.json`), JSON.stringify(message, null, 2));
27094
27178
  }
27095
27179
  }
27096
27180
  /**
@@ -27098,9 +27182,9 @@ Generated by DevMailbox.seed() for development purposes.`,
27098
27182
  */
27099
27183
  count(folder) {
27100
27184
  const countDir = (f) => {
27101
- const dir = join16(this.mailboxDir, f);
27185
+ const dir = join17(this.mailboxDir, f);
27102
27186
  try {
27103
- if (existsSync12(dir)) {
27187
+ if (existsSync13(dir)) {
27104
27188
  return readdirSync7(dir).filter((file) => file.endsWith(".json")).length;
27105
27189
  }
27106
27190
  } catch {
@@ -27141,8 +27225,8 @@ var init_upstreamResponse = __esm({
27141
27225
  // src/metrics.ts
27142
27226
  import * as fs3 from "node:fs";
27143
27227
  import * as path2 from "node:path";
27144
- import { spawnSync } from "node:child_process";
27145
- import { fileURLToPath as fileURLToPath2 } from "node:url";
27228
+ import { spawnSync as spawnSync2 } from "node:child_process";
27229
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
27146
27230
  function containsTypeScript(directory) {
27147
27231
  if (!fs3.existsSync(directory) || !fs3.statSync(directory).isDirectory()) return false;
27148
27232
  for (const entry of fs3.readdirSync(directory, { withFileTypes: true })) {
@@ -27153,7 +27237,7 @@ function containsTypeScript(directory) {
27153
27237
  return false;
27154
27238
  }
27155
27239
  function resolveTarget(root = "src") {
27156
- const resolved = containsTypeScript(root) ? path2.resolve(root) : path2.dirname(fileURLToPath2(import.meta.url));
27240
+ const resolved = containsTypeScript(root) ? path2.resolve(root) : path2.dirname(fileURLToPath3(import.meta.url));
27157
27241
  const mode = containsTypeScript(root) ? "project" : "framework";
27158
27242
  lastScanRoot = resolved;
27159
27243
  return [resolved, mode];
@@ -27181,7 +27265,7 @@ function enginePath() {
27181
27265
  function runEngine(target) {
27182
27266
  const binary = enginePath();
27183
27267
  if (!binary) throw new MetricsEngineError(`tina4 not found on PATH - ${INSTALL_HINT}`);
27184
- const processResult = spawnSync(binary, ["metrics", "--path", target, "--json", "--no-history"], {
27268
+ const processResult = spawnSync2(binary, ["metrics", "--path", target, "--json", "--no-history"], {
27185
27269
  encoding: "utf8",
27186
27270
  timeout: 6e4,
27187
27271
  maxBuffer: 64 * 1024 * 1024
@@ -27274,9 +27358,9 @@ var init_metrics = __esm({
27274
27358
  });
27275
27359
 
27276
27360
  // src/feedback.ts
27277
- import { readFileSync as readFileSync12, existsSync as existsSync14 } from "node:fs";
27278
- import { dirname as dirname8, join as join18, resolve as resolve9 } from "node:path";
27279
- import { fileURLToPath as fileURLToPath3 } from "node:url";
27361
+ import { readFileSync as readFileSync12, existsSync as existsSync15 } from "node:fs";
27362
+ import { dirname as dirname8, join as join19, resolve as resolve9 } from "node:path";
27363
+ import { fileURLToPath as fileURLToPath4 } from "node:url";
27280
27364
  function feedbackEnabled() {
27281
27365
  const raw = (process.env.TINA4_ENABLE_FEEDBACK ?? "").trim().toLowerCase();
27282
27366
  return raw === "1" || raw === "true" || raw === "yes" || raw === "on";
@@ -27325,8 +27409,8 @@ function feedbackRateLimitOk(user) {
27325
27409
  }
27326
27410
  function injectFeedbackWidget(request, html) {
27327
27411
  if (!html) return html;
27328
- const path10 = (request.path ?? "") || "";
27329
- if (path10.startsWith("/__dev") || path10.startsWith("/__feedback")) return html;
27412
+ const path9 = (request.path ?? "") || "";
27413
+ if (path9.startsWith("/__dev") || path9.startsWith("/__feedback")) return html;
27330
27414
  if (html.includes("data-tina4-feedback")) return html;
27331
27415
  const [allowed] = feedbackIsWhitelisted(request);
27332
27416
  if (!allowed) return html;
@@ -27402,11 +27486,11 @@ var init_feedback = __esm({
27402
27486
  clearTimeout(timer);
27403
27487
  await relayUpstreamResponse(res, upstream);
27404
27488
  };
27405
- __feedbackDirname = dirname8(fileURLToPath3(import.meta.url));
27489
+ __feedbackDirname = dirname8(fileURLToPath4(import.meta.url));
27406
27490
  WIDGET_BUNDLE_PATH = resolve9(__feedbackDirname, "__feedback", "widget.js");
27407
27491
  handleFeedbackWidgetJs = (_req, res) => {
27408
27492
  let body;
27409
- if (existsSync14(WIDGET_BUNDLE_PATH)) {
27493
+ if (existsSync15(WIDGET_BUNDLE_PATH)) {
27410
27494
  body = readFileSync12(WIDGET_BUNDLE_PATH);
27411
27495
  } else {
27412
27496
  body = "console.warn('tina4-feedback-widget bundle not built yet');";
@@ -27422,14 +27506,14 @@ var init_feedback = __esm({
27422
27506
  });
27423
27507
 
27424
27508
  // src/version.ts
27425
- import { existsSync as existsSync15, readFileSync as readFileSync13 } from "node:fs";
27426
- import { dirname as dirname9, join as join19 } from "node:path";
27427
- import { fileURLToPath as fileURLToPath4 } from "node:url";
27509
+ import { existsSync as existsSync16, readFileSync as readFileSync13 } from "node:fs";
27510
+ import { dirname as dirname9, join as join20 } from "node:path";
27511
+ import { fileURLToPath as fileURLToPath5 } from "node:url";
27428
27512
  function resolveFrameworkVersion() {
27429
- let dir = dirname9(fileURLToPath4(import.meta.url));
27513
+ let dir = dirname9(fileURLToPath5(import.meta.url));
27430
27514
  for (let i = 0; i < 6; i++) {
27431
- const pkgPath = join19(dir, "package.json");
27432
- if (existsSync15(pkgPath)) {
27515
+ const pkgPath = join20(dir, "package.json");
27516
+ if (existsSync16(pkgPath)) {
27433
27517
  try {
27434
27518
  const pkg = JSON.parse(readFileSync13(pkgPath, "utf-8"));
27435
27519
  if (typeof pkg.version === "string" && pkg.version) return pkg.version;
@@ -27511,27 +27595,27 @@ __export(generate_exports, {
27511
27595
  toSnake: () => toSnake,
27512
27596
  toTableName: () => toTableName
27513
27597
  });
27514
- import { existsSync as existsSync16, mkdirSync as mkdirSync12, writeFileSync as writeFileSync9, readdirSync as readdirSync9, copyFileSync } from "node:fs";
27515
- import { join as join20, relative as relative2, resolve as resolve10, sep as sep5, dirname as dirname10 } from "node:path";
27516
- import { fileURLToPath as fileURLToPath5 } from "node:url";
27598
+ import { existsSync as existsSync17, mkdirSync as mkdirSync12, writeFileSync as writeFileSync9, readdirSync as readdirSync9, copyFileSync } from "node:fs";
27599
+ import { join as join21, relative as relative2, resolve as resolve10, sep as sep5, dirname as dirname10 } from "node:path";
27600
+ import { fileURLToPath as fileURLToPath6 } from "node:url";
27517
27601
  function ensureDir(dir) {
27518
27602
  if (__resolution.dryRun) return;
27519
- if (!existsSync16(dir)) {
27603
+ if (!existsSync17(dir)) {
27520
27604
  mkdirSync12(dir, { recursive: true });
27521
27605
  }
27522
27606
  }
27523
- function writeFileSafe(path10, content) {
27524
- captureEditHints(path10, content);
27607
+ function writeFileSafe(path9, content) {
27608
+ captureEditHints(path9, content);
27525
27609
  if (__resolution.dryRun) {
27526
27610
  return;
27527
27611
  }
27528
- if (existsSync16(path10)) {
27529
- if (!__resolution.jsonMode) console.log(` File already exists: ${path10}`);
27612
+ if (existsSync17(path9)) {
27613
+ if (!__resolution.jsonMode) console.log(` File already exists: ${path9}`);
27530
27614
  return;
27531
27615
  }
27532
- writeFileSync9(path10, content, "utf-8");
27533
- __resolution.actionsTaken.push(`wrote ${path10}`);
27534
- if (!__resolution.jsonMode) console.log(` Created ${path10}`);
27616
+ writeFileSync9(path9, content, "utf-8");
27617
+ __resolution.actionsTaken.push(`wrote ${path9}`);
27618
+ if (!__resolution.jsonMode) console.log(` Created ${path9}`);
27535
27619
  }
27536
27620
  function toSnake(name) {
27537
27621
  return name.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
@@ -27623,9 +27707,9 @@ function pushRoute(routePattern) {
27623
27707
  if (!__resolution.body.routes) __resolution.body.routes = [];
27624
27708
  __resolution.body.routes.push(routePattern);
27625
27709
  }
27626
- function pushTestPath(path10) {
27710
+ function pushTestPath(path9) {
27627
27711
  if (!__resolution.body.test_paths) __resolution.body.test_paths = [];
27628
- __resolution.body.test_paths.push(path10);
27712
+ __resolution.body.test_paths.push(path9);
27629
27713
  }
27630
27714
  function pushEditHint(hint) {
27631
27715
  if (!__resolution.body.edit_hints) __resolution.body.edit_hints = [];
@@ -27856,7 +27940,7 @@ function generateModel(name, flags, emitTest = true) {
27856
27940
  const table2 = resolveTable(name, flags, { announce: true });
27857
27941
  const dir = resolve10("src/models");
27858
27942
  ensureDir(dir);
27859
- const path10 = join20(dir, `${name}.ts`);
27943
+ const path9 = join21(dir, `${name}.ts`);
27860
27944
  setResolutionField("class_name", name);
27861
27945
  setResolutionField("table_name", table2);
27862
27946
  setResolutionField("file_path", `src/models/${name}.ts`);
@@ -27879,7 +27963,7 @@ ${fieldLines.join("\n")}
27879
27963
  };
27880
27964
  }
27881
27965
  `;
27882
- writeFileSafe(path10, content);
27966
+ writeFileSafe(path9, content);
27883
27967
  if (!flags["no-migration"]) {
27884
27968
  generateMigration(`create_${table2}`, flags, fields, table2, false);
27885
27969
  }
@@ -27896,7 +27980,7 @@ function generateRoute(name, flags, emitTest = true) {
27896
27980
  const model = flags.model;
27897
27981
  const isPublic = Boolean(flags.public);
27898
27982
  const base = resolve10("src/routes/api", routePath);
27899
- const idDir = join20(base, "[id]");
27983
+ const idDir = join21(base, "[id]");
27900
27984
  ensureDir(base);
27901
27985
  ensureDir(idDir);
27902
27986
  pushRoute(`/api/${routePath}`);
@@ -27912,7 +27996,7 @@ function generateRoute(name, flags, emitTest = true) {
27912
27996
  const writeDoc = isPublic ? "Public (--public): no token required." : "Secure by default: requires a Bearer token (use --public to open).";
27913
27997
  if (model) {
27914
27998
  writeFileSafe(
27915
- join20(base, "get.ts"),
27999
+ join21(base, "get.ts"),
27916
28000
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
27917
28001
  ${modelImportBase}
27918
28002
  export const meta = { summary: "List all ${routePath}", tags: ["${routePath}"] };
@@ -27929,7 +28013,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
27929
28013
  );
27930
28014
  } else {
27931
28015
  writeFileSafe(
27932
- join20(base, "get.ts"),
28016
+ join21(base, "get.ts"),
27933
28017
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
27934
28018
 
27935
28019
  export const meta = { summary: "List all ${routePath}", tags: ["${routePath}"] };
@@ -27948,7 +28032,7 @@ ${aiFill(`list_${routePath}`, {
27948
28032
  }
27949
28033
  if (model) {
27950
28034
  writeFileSafe(
27951
- join20(base, "post.ts"),
28035
+ join21(base, "post.ts"),
27952
28036
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
27953
28037
  ${modelImportBase}${secureOptOut(isPublic)}export const meta = { summary: "Create a new ${singular}", tags: ["${routePath}"] };
27954
28038
 
@@ -27971,7 +28055,7 @@ ${extend(
27971
28055
  );
27972
28056
  } else {
27973
28057
  writeFileSafe(
27974
- join20(base, "post.ts"),
28058
+ join21(base, "post.ts"),
27975
28059
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
27976
28060
 
27977
28061
  ${secureOptOut(isPublic)}export const meta = { summary: "Create a new ${singular}", tags: ["${routePath}"] };
@@ -27992,7 +28076,7 @@ ${aiFill(`create_${singular}`, {
27992
28076
  }
27993
28077
  if (model) {
27994
28078
  writeFileSafe(
27995
- join20(idDir, "get.ts"),
28079
+ join21(idDir, "get.ts"),
27996
28080
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
27997
28081
  ${modelImportId}
27998
28082
  export const meta = { summary: "Get a ${singular} by ID", tags: ["${routePath}"] };
@@ -28010,7 +28094,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28010
28094
  );
28011
28095
  } else {
28012
28096
  writeFileSafe(
28013
- join20(idDir, "get.ts"),
28097
+ join21(idDir, "get.ts"),
28014
28098
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28015
28099
 
28016
28100
  export const meta = { summary: "Get a ${singular} by ID", tags: ["${routePath}"] };
@@ -28029,7 +28113,7 @@ ${aiFill(`get_${singular}`, {
28029
28113
  }
28030
28114
  if (model) {
28031
28115
  writeFileSafe(
28032
- join20(idDir, "put.ts"),
28116
+ join21(idDir, "put.ts"),
28033
28117
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28034
28118
  ${modelImportId}${secureOptOut(isPublic)}export const meta = { summary: "Update a ${singular} by ID", tags: ["${routePath}"] };
28035
28119
 
@@ -28058,7 +28142,7 @@ ${extend(
28058
28142
  );
28059
28143
  } else {
28060
28144
  writeFileSafe(
28061
- join20(idDir, "put.ts"),
28145
+ join21(idDir, "put.ts"),
28062
28146
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28063
28147
 
28064
28148
  ${secureOptOut(isPublic)}export const meta = { summary: "Update a ${singular} by ID", tags: ["${routePath}"] };
@@ -28079,7 +28163,7 @@ ${aiFill(`update_${singular}`, {
28079
28163
  }
28080
28164
  if (model) {
28081
28165
  writeFileSafe(
28082
- join20(idDir, "delete.ts"),
28166
+ join21(idDir, "delete.ts"),
28083
28167
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28084
28168
  ${modelImportId}${secureOptOut(isPublic)}export const meta = { summary: "Delete a ${singular} by ID", tags: ["${routePath}"] };
28085
28169
 
@@ -28098,7 +28182,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28098
28182
  );
28099
28183
  } else {
28100
28184
  writeFileSafe(
28101
- join20(idDir, "delete.ts"),
28185
+ join21(idDir, "delete.ts"),
28102
28186
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28103
28187
 
28104
28188
  ${secureOptOut(isPublic)}export const meta = { summary: "Delete a ${singular} by ID", tags: ["${routePath}"] };
@@ -28175,10 +28259,10 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28175
28259
  return res.html(await Crud.toCrud(req, { model: ${model}, title: "${model} Admin"${publicOpt} }));
28176
28260
  }
28177
28261
  `;
28178
- writeFileSafe(join20(dir, "get.ts"), content);
28262
+ writeFileSafe(join21(dir, "get.ts"), content);
28179
28263
  }
28180
28264
  function frameworkCrudTemplatesDir() {
28181
- const here = dirname10(fileURLToPath5(import.meta.url));
28265
+ const here = dirname10(fileURLToPath6(import.meta.url));
28182
28266
  const candidates = [
28183
28267
  resolve10(here, "../../../core/templates/crud"),
28184
28268
  // monorepo: packages/cli/src/commands -> packages/core/templates/crud
@@ -28187,7 +28271,7 @@ function frameworkCrudTemplatesDir() {
28187
28271
  resolve10(here, "../templates/crud")
28188
28272
  // flattened publish fallback
28189
28273
  ];
28190
- return candidates.find((c) => existsSync16(c)) ?? null;
28274
+ return candidates.find((c) => existsSync17(c)) ?? null;
28191
28275
  }
28192
28276
  function copyCrudTemplates() {
28193
28277
  const sourceDir = frameworkCrudTemplatesDir();
@@ -28198,13 +28282,13 @@ function copyCrudTemplates() {
28198
28282
  const targetDir = resolve10("src/templates/crud");
28199
28283
  ensureDir(targetDir);
28200
28284
  for (const file of readdirSync9(sourceDir).filter((f) => f.endsWith(".twig")).sort()) {
28201
- const dest = join20(targetDir, file);
28202
- if (existsSync16(dest)) {
28285
+ const dest = join21(targetDir, file);
28286
+ if (existsSync17(dest)) {
28203
28287
  if (!__resolution.jsonMode) console.log(` File already exists: ${dest}`);
28204
28288
  continue;
28205
28289
  }
28206
28290
  if (__resolution.dryRun) continue;
28207
- copyFileSync(join20(sourceDir, file), dest);
28291
+ copyFileSync(join21(sourceDir, file), dest);
28208
28292
  __resolution.actionsTaken.push(`wrote ${dest}`);
28209
28293
  if (!__resolution.jsonMode) console.log(` Created ${dest}`);
28210
28294
  }
@@ -28262,7 +28346,7 @@ ${writeCase}
28262
28346
  console.log(\`\\nResults: \${pass} passed, \${fail} failed\`);
28263
28347
  process.exit(fail > 0 ? 1 : 0);
28264
28348
  `;
28265
- writeFileSafe(join20(dir, `${table2}.test.ts`), content);
28349
+ writeFileSafe(join21(dir, `${table2}.test.ts`), content);
28266
28350
  }
28267
28351
  function generateMigration(name, flags, fieldsOverride, tableOverride, emitTest = true) {
28268
28352
  const ts = timestamp();
@@ -28282,7 +28366,7 @@ function generateMigration(name, flags, fieldsOverride, tableOverride, emitTest
28282
28366
  const isCreate = name.startsWith("create_") || fieldsOverride !== void 0;
28283
28367
  const isView = isCreate && fieldsOverride === void 0 && table2.endsWith("_view");
28284
28368
  const fileName = `${ts}_${name}.sql`;
28285
- const path10 = join20(dir, fileName);
28369
+ const path9 = join21(dir, fileName);
28286
28370
  setResolutionField("migration_path", `migrations/${fileName}`);
28287
28371
  if (__resolution.target === "migration") {
28288
28372
  setResolutionField("file_path", `migrations/${fileName}`);
@@ -28323,8 +28407,8 @@ DROP TABLE IF EXISTS ${table2};`;
28323
28407
  -- UP
28324
28408
  ${upSql}
28325
28409
  `;
28326
- writeFileSafe(path10, content);
28327
- const downPath = join20(dir, `${ts}_${name}.down.sql`);
28410
+ writeFileSafe(path9, content);
28411
+ const downPath = join21(dir, `${ts}_${name}.down.sql`);
28328
28412
  const downContent = `-- Rollback: ${name}
28329
28413
  -- Created: ${now}
28330
28414
 
@@ -28337,7 +28421,7 @@ function generateMiddleware(name, _flags) {
28337
28421
  const snake = toSnake(name);
28338
28422
  const dir = resolve10("src/middleware");
28339
28423
  ensureDir(dir);
28340
- const path10 = join20(dir, `${snake}.ts`);
28424
+ const path9 = join21(dir, `${snake}.ts`);
28341
28425
  if (__resolution.target === "middleware") {
28342
28426
  setResolutionField("class_name", name);
28343
28427
  setResolutionField("file_path", `src/middleware/${snake}.ts`);
@@ -28375,7 +28459,7 @@ export async function after${name}(
28375
28459
  await next();
28376
28460
  }
28377
28461
  `;
28378
- writeFileSafe(path10, content);
28462
+ writeFileSafe(path9, content);
28379
28463
  emitMiddlewareTest(name, snake);
28380
28464
  }
28381
28465
  function generateTest(name, flags) {
@@ -28384,7 +28468,7 @@ function generateTest(name, flags) {
28384
28468
  const model = flags.model;
28385
28469
  const dir = resolve10("tests");
28386
28470
  ensureDir(dir);
28387
- const path10 = join20(dir, `${snake}.test.ts`);
28471
+ const path9 = join21(dir, `${snake}.test.ts`);
28388
28472
  if (model && flags["secure-writes"]) {
28389
28473
  const isPublic = Boolean(flags.public);
28390
28474
  const posture = isPublic ? "open (--public)" : "gated";
@@ -28433,7 +28517,7 @@ ${writeCase}
28433
28517
  console.log(\`\\nResults: \${pass} passed, \${fail} failed\`);
28434
28518
  process.exit(fail > 0 ? 1 : 0);
28435
28519
  `;
28436
- writeFileSafe(path10, content2);
28520
+ writeFileSafe(path9, content2);
28437
28521
  return;
28438
28522
  }
28439
28523
  let content;
@@ -28499,7 +28583,7 @@ const test${titleName} = tests(
28499
28583
  void test${titleName};
28500
28584
  `;
28501
28585
  }
28502
- writeFileSafe(path10, content);
28586
+ writeFileSafe(path9, content);
28503
28587
  void singular;
28504
28588
  }
28505
28589
  function generateForm2(name, flags) {
@@ -28522,7 +28606,7 @@ function generateForm2(name, flags) {
28522
28606
  };
28523
28607
  const dir = resolve10("src/templates/forms");
28524
28608
  ensureDir(dir);
28525
- const path10 = join20(dir, `${table2}.twig`);
28609
+ const path9 = join21(dir, `${table2}.twig`);
28526
28610
  let fieldHtml = "";
28527
28611
  for (const [fname, ftype] of fields) {
28528
28612
  const itype = inputTypes[ftype] || "text";
@@ -28566,7 +28650,7 @@ function generateForm2(name, flags) {
28566
28650
  </div>
28567
28651
  {% endblock %}
28568
28652
  `;
28569
- writeFileSafe(path10, content);
28653
+ writeFileSafe(path9, content);
28570
28654
  }
28571
28655
  function generateView(name, flags) {
28572
28656
  const fields = fieldsOrDefault(flags.fields || "");
@@ -28575,7 +28659,7 @@ function generateView(name, flags) {
28575
28659
  const cols = fields.map(([f]) => f);
28576
28660
  const dir = resolve10("src/templates/pages");
28577
28661
  ensureDir(dir);
28578
- const listPath = join20(dir, `${routeName}.twig`);
28662
+ const listPath = join21(dir, `${routeName}.twig`);
28579
28663
  const th = cols.map((c) => ` <th>${c.replace(/_/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase())}</th>`).join("\n");
28580
28664
  const td = cols.map((c) => ` <td>{{ item.${c} }}</td>`).join("\n");
28581
28665
  const listContent = `{% extends "base.twig" %}
@@ -28612,7 +28696,7 @@ ${td}
28612
28696
  {% endblock %}
28613
28697
  `;
28614
28698
  writeFileSafe(listPath, listContent);
28615
- const detailPath = join20(dir, `${table2}.twig`);
28699
+ const detailPath = join21(dir, `${table2}.twig`);
28616
28700
  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");
28617
28701
  const detailContent = `{% extends "base.twig" %}
28618
28702
  {% block title %}${name} Detail{% endblock %}
@@ -28642,7 +28726,7 @@ function generateAuth(_flags) {
28642
28726
  ensureDir(loginDir);
28643
28727
  ensureDir(meDir);
28644
28728
  writeFileSafe(
28645
- join20(registerDir, "post.ts"),
28729
+ join21(registerDir, "post.ts"),
28646
28730
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28647
28731
  import { hashPassword } from "tina4-nodejs";
28648
28732
  import User from "../../../../models/User.js";
@@ -28674,7 +28758,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28674
28758
  `
28675
28759
  );
28676
28760
  writeFileSafe(
28677
- join20(loginDir, "post.ts"),
28761
+ join21(loginDir, "post.ts"),
28678
28762
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28679
28763
  import { checkPassword, getToken } from "tina4-nodejs";
28680
28764
  import User from "../../../../models/User.js";
@@ -28707,7 +28791,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28707
28791
  `
28708
28792
  );
28709
28793
  writeFileSafe(
28710
- join20(meDir, "get.ts"),
28794
+ join21(meDir, "get.ts"),
28711
28795
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28712
28796
  import { authenticateRequest } from "tina4-nodejs";
28713
28797
 
@@ -28726,7 +28810,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28726
28810
  const formsDir = resolve10("src/templates/forms");
28727
28811
  ensureDir(formsDir);
28728
28812
  writeFileSafe(
28729
- join20(formsDir, "login.twig"),
28813
+ join21(formsDir, "login.twig"),
28730
28814
  `{% extends "base.twig" %}
28731
28815
  {% block title %}Login{% endblock %}
28732
28816
  {% block content %}
@@ -28754,7 +28838,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28754
28838
  `
28755
28839
  );
28756
28840
  writeFileSafe(
28757
- join20(formsDir, "register.twig"),
28841
+ join21(formsDir, "register.twig"),
28758
28842
  `{% extends "base.twig" %}
28759
28843
  {% block title %}Register{% endblock %}
28760
28844
  {% block content %}
@@ -28793,7 +28877,7 @@ function generateService(name, flags) {
28793
28877
  const cron = flags.cron;
28794
28878
  const dir = resolve10("src/services");
28795
28879
  ensureDir(dir);
28796
- const path10 = join20(dir, `${snake}.ts`);
28880
+ const path9 = join21(dir, `${snake}.ts`);
28797
28881
  let scheduleField;
28798
28882
  let note;
28799
28883
  if (cron && cron !== true) {
@@ -28836,7 +28920,7 @@ export default {
28836
28920
  ${scheduleField}
28837
28921
  };
28838
28922
  `;
28839
- writeFileSafe(path10, content);
28923
+ writeFileSafe(path9, content);
28840
28924
  emitServiceTest(name, snake, camel);
28841
28925
  }
28842
28926
  function generateQueue(name, _flags) {
@@ -28845,7 +28929,7 @@ function generateQueue(name, _flags) {
28845
28929
  const pascal = toPascal(topic) || "Topic";
28846
28930
  const dir = resolve10("src/services");
28847
28931
  ensureDir(dir);
28848
- const path10 = join20(dir, `${slug}_consumer.ts`);
28932
+ const path9 = join21(dir, `${slug}_consumer.ts`);
28849
28933
  const body = aiFill(`handle${pascal}`, {
28850
28934
  intent: `process ONE ${topic} job payload`,
28851
28935
  given: "payload -> the produced job data (job.payload)",
@@ -28900,13 +28984,13 @@ export default {
28900
28984
  daemon: true,
28901
28985
  };
28902
28986
  `;
28903
- writeFileSafe(path10, content);
28987
+ writeFileSafe(path9, content);
28904
28988
  emitQueueTest(topic, slug, pascal);
28905
28989
  }
28906
28990
  function generateValidator(name, _flags) {
28907
28991
  const dir = resolve10("src/validators");
28908
28992
  ensureDir(dir);
28909
- const path10 = join20(dir, `${toSnake(name)}.ts`);
28993
+ const path9 = join21(dir, `${toSnake(name)}.ts`);
28910
28994
  const rules = extend(
28911
28995
  "add / adjust the validation rules for this payload",
28912
28996
  `e.g. .email("email").minLength("name", 2).integer("age"); ground: tina4_context("validate request body with Validator", "nodejs")`
@@ -28927,14 +29011,14 @@ ${rules} validator.required("name"); // starter rule (matches the model's def
28927
29011
  return validator;
28928
29012
  }
28929
29013
  `;
28930
- writeFileSafe(path10, content);
29014
+ writeFileSafe(path9, content);
28931
29015
  emitValidatorTest(name, toSnake(name), toPascal(name));
28932
29016
  }
28933
29017
  function generateSeeder(name, flags) {
28934
29018
  const table2 = resolveTable(name, flags, { announce: false });
28935
29019
  const dir = resolve10("src/seeds");
28936
29020
  ensureDir(dir);
28937
- const path10 = join20(dir, `${table2}_seeder.ts`);
29021
+ const path9 = join21(dir, `${table2}_seeder.ts`);
28938
29022
  const overrides = extend(
28939
29023
  "override fields that need a specific shape (seedOrm auto-fills the rest)",
28940
29024
  `e.g. return { email: (f) => f.email(), status: "active" }; ground: tina4_context("seed ORM model with FakeData", "nodejs")`
@@ -28968,7 +29052,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
28968
29052
  await run();
28969
29053
  }
28970
29054
  `;
28971
- writeFileSafe(path10, content);
29055
+ writeFileSafe(path9, content);
28972
29056
  emitSeederTest(name, table2);
28973
29057
  }
28974
29058
  function generateWebsocket(name, _flags) {
@@ -28979,7 +29063,7 @@ function generateWebsocket(name, _flags) {
28979
29063
  const handlerName = `${toCamel(toPascal(base))}Ws`;
28980
29064
  const dir = resolve10("src/routes");
28981
29065
  ensureDir(dir);
28982
- const path10 = join20(dir, `ws_${base}.ts`);
29066
+ const path9 = join21(dir, `ws_${base}.ts`);
28983
29067
  const body = aiFill(handlerName, {
28984
29068
  intent: `handle an inbound "message" frame on ${wsPath}`,
28985
29069
  given: "data -> the message payload (string); connection -> WebSocketConnection",
@@ -29021,7 +29105,7 @@ ${body}}
29021
29105
 
29022
29106
  websocket("${wsPath}", ${handlerName});
29023
29107
  `;
29024
- writeFileSafe(path10, content);
29108
+ writeFileSafe(path9, content);
29025
29109
  emitWebsocketTest(wsPath, base, handlerName);
29026
29110
  }
29027
29111
  function generateListener(name, _flags) {
@@ -29030,7 +29114,7 @@ function generateListener(name, _flags) {
29030
29114
  const handlerName = `on${toPascal(slug)}`;
29031
29115
  const dir = resolve10("src/listeners");
29032
29116
  ensureDir(dir);
29033
- const path10 = join20(dir, `${slug}.ts`);
29117
+ const path9 = join21(dir, `${slug}.ts`);
29034
29118
  const body = aiFill(handlerName, {
29035
29119
  intent: `react to the '${event}' event`,
29036
29120
  given: `args -> whatever Events.emit("${event}", ...args) passed`,
@@ -29056,13 +29140,13 @@ ${body}}
29056
29140
 
29057
29141
  Events.on("${event}", ${handlerName});
29058
29142
  `;
29059
- writeFileSafe(path10, content);
29143
+ writeFileSafe(path9, content);
29060
29144
  emitListenerTest(event, slug);
29061
29145
  }
29062
29146
  function writeTest(testName, content) {
29063
29147
  const dir = resolve10("tests");
29064
29148
  ensureDir(dir);
29065
- writeFileSafe(join20(dir, `${testName}.test.ts`), content);
29149
+ writeFileSafe(join21(dir, `${testName}.test.ts`), content);
29066
29150
  }
29067
29151
  function standaloneTest(doc, body) {
29068
29152
  return `${doc}
@@ -29728,7 +29812,6 @@ __export(mcp_exports, {
29728
29812
  import * as fs4 from "node:fs";
29729
29813
  import * as path3 from "node:path";
29730
29814
  import * as os from "node:os";
29731
- import { spawnSync as spawnSync2 } from "node:child_process";
29732
29815
  import { createRequire as createRequire7 } from "node:module";
29733
29816
  import { randomBytes as randomBytes7 } from "node:crypto";
29734
29817
  function reqSibling(pkg) {
@@ -30057,7 +30140,7 @@ function verifyNodeSyntax(absPath, relPath) {
30057
30140
  if (!target) return null;
30058
30141
  const { cmd, args } = syntaxCheckCommand(absPath, target.ext);
30059
30142
  try {
30060
- const proc = spawnSync2(cmd, args, {
30143
+ const proc = spawnSyncAllowingBatch(findExecutable(cmd), args, {
30061
30144
  encoding: "utf-8",
30062
30145
  timeout: 5e3,
30063
30146
  cwd: path3.dirname(path3.dirname(absPath))
@@ -30938,13 +31021,13 @@ function registerDevTools(server) {
30938
31021
  "git_status",
30939
31022
  () => {
30940
31023
  try {
30941
- const { execFileSync: execFileSync6 } = req("node:child_process");
31024
+ const { execFileSync: execFileSync5 } = req("node:child_process");
30942
31025
  const cwd = path3.resolve(process.cwd());
30943
31026
  const run = (args) => {
30944
- return execFileSync6("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
31027
+ return execFileSync5("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
30945
31028
  };
30946
31029
  try {
30947
- execFileSync6("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
31030
+ execFileSync5("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
30948
31031
  } catch {
30949
31032
  return { error: "Not a git repository" };
30950
31033
  }
@@ -31072,6 +31155,7 @@ var init_mcp = __esm({
31072
31155
  "src/mcp.ts"() {
31073
31156
  "use strict";
31074
31157
  init_slashTrim();
31158
+ init_batchSpawn();
31075
31159
  init_version();
31076
31160
  req = createRequire7(import.meta.url);
31077
31161
  PARSE_ERROR = -32700;
@@ -32533,7 +32617,7 @@ function pack(segments, maxLines) {
32533
32617
  }
32534
32618
  return chunks;
32535
32619
  }
32536
- function chunkCode(text, path10 = "", maxLines = 60) {
32620
+ function chunkCode(text, path9 = "", maxLines = 60) {
32537
32621
  const lines = splitLines(text);
32538
32622
  let bounds = [];
32539
32623
  for (let i = 0; i < lines.length; i++) {
@@ -32547,7 +32631,7 @@ function chunkCode(text, path10 = "", maxLines = 60) {
32547
32631
  for (let k = 0; k < bounds.length; k++) {
32548
32632
  segments.push(lines.slice(bounds[k], ends[k]));
32549
32633
  }
32550
- const header = path10 ? `# file: ${path10}` : null;
32634
+ const header = path9 ? `# file: ${path9}` : null;
32551
32635
  const packed = pack(segments, maxLines);
32552
32636
  const out = [];
32553
32637
  for (let i = 0; i < packed.length; i++) {
@@ -32598,8 +32682,8 @@ __export(context_exports, {
32598
32682
  fts5Supported: () => fts5Supported
32599
32683
  });
32600
32684
  import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
32601
- import { existsSync as existsSync18, mkdirSync as mkdirSync14, readFileSync as readFileSync15, readdirSync as readdirSync11, realpathSync as realpathSync5 } from "node:fs";
32602
- import { basename as basename4, dirname as dirname12, extname as extname5, isAbsolute as isAbsolute6, join as join22, relative as relative4, resolve as resolve12 } from "node:path";
32685
+ import { existsSync as existsSync19, mkdirSync as mkdirSync14, readFileSync as readFileSync15, readdirSync as readdirSync11, realpathSync as realpathSync5 } from "node:fs";
32686
+ import { basename as basename4, dirname as dirname12, extname as extname6, isAbsolute as isAbsolute6, join as join23, relative as relative4, resolve as resolve12 } from "node:path";
32603
32687
  function fts5Supported() {
32604
32688
  try {
32605
32689
  const conn = new DatabaseSync4(":memory:");
@@ -32622,13 +32706,13 @@ function realResolve(abs) {
32622
32706
  } catch {
32623
32707
  }
32624
32708
  try {
32625
- return join22(realpathSync5(dirname12(abs)), basename4(abs));
32709
+ return join23(realpathSync5(dirname12(abs)), basename4(abs));
32626
32710
  } catch {
32627
32711
  return abs;
32628
32712
  }
32629
32713
  }
32630
32714
  function dbKey(db) {
32631
- return resolve12(db ? String(db) : join22(process.cwd(), ".tina4", "context.db"));
32715
+ return resolve12(db ? String(db) : join23(process.cwd(), ".tina4", "context.db"));
32632
32716
  }
32633
32717
  function defaultContext(root, db) {
32634
32718
  const key = dbKey(db);
@@ -32734,7 +32818,7 @@ var init_context = __esm({
32734
32818
  }
32735
32819
  // ── indexing ───────────────────────────────────────────────
32736
32820
  static chunksFor(label, text) {
32737
- const ext = extname5(label).toLowerCase();
32821
+ const ext = extname6(label).toLowerCase();
32738
32822
  const special = SPECIAL_FILES.has(basename4(label).toLowerCase());
32739
32823
  if (CODE_EXTS.has(ext) || CONFIG_EXTS.has(ext) || special) {
32740
32824
  return chunkCode(text, label);
@@ -32773,7 +32857,7 @@ var init_context = __esm({
32773
32857
  static eligible(filename) {
32774
32858
  const fn = filename.toLowerCase();
32775
32859
  if (fn.endsWith(".min.js")) return false;
32776
- const ext = extname5(fn);
32860
+ const ext = extname6(fn);
32777
32861
  return CODE_EXTS.has(ext) || DOC_EXTS.has(ext) || CONFIG_EXTS.has(ext) || SPECIAL_FILES.has(fn);
32778
32862
  }
32779
32863
  /**
@@ -32801,11 +32885,11 @@ var init_context = __esm({
32801
32885
  files.sort();
32802
32886
  for (const fn of files) {
32803
32887
  if (!_Context.eligible(fn)) continue;
32804
- const full = join22(dir, fn);
32888
+ const full = join23(dir, fn);
32805
32889
  const rel = relative4(rootAbs, full);
32806
32890
  total += this.indexPath(full, rel);
32807
32891
  }
32808
- for (const d of subdirs) walk2(join22(dir, d));
32892
+ for (const d of subdirs) walk2(join23(dir, d));
32809
32893
  };
32810
32894
  walk2(rootAbs);
32811
32895
  return total;
@@ -32821,7 +32905,7 @@ var init_context = __esm({
32821
32905
  reindexFile(changedPath) {
32822
32906
  if (!this.available || this.root === null) return -1;
32823
32907
  const raw = String(changedPath);
32824
- const abs = isAbsolute6(raw) ? raw : join22(process.cwd(), raw);
32908
+ const abs = isAbsolute6(raw) ? raw : join23(process.cwd(), raw);
32825
32909
  const resolved = realResolve(resolve12(abs));
32826
32910
  const rel = relative4(this.root, resolved);
32827
32911
  if (rel === "" || rel.startsWith("..") || isAbsolute6(rel)) {
@@ -32834,7 +32918,7 @@ var init_context = __esm({
32834
32918
  }
32835
32919
  if (!_Context.eligible(basename4(rel))) return -1;
32836
32920
  const stored = rel;
32837
- if (!existsSync18(abs)) {
32921
+ if (!existsSync19(abs)) {
32838
32922
  this.conn.prepare("DELETE FROM chunks WHERE path = ?").run(stored);
32839
32923
  return 0;
32840
32924
  }
@@ -32852,8 +32936,8 @@ var init_context = __esm({
32852
32936
  const expr = [...toks].sort().map((t) => `"${t}"`).join(" OR ");
32853
32937
  return { expr, toks };
32854
32938
  }
32855
- static isTestlike(path10) {
32856
- const s = (path10 || "").toLowerCase();
32939
+ static isTestlike(path9) {
32940
+ const s = (path9 || "").toLowerCase();
32857
32941
  return ["/test", "test/", "test_", "_test.", ".test.", "/example", "example/"].some((p) => s.includes(p));
32858
32942
  }
32859
32943
  static defines(foldedBody, symbols) {
@@ -33317,7 +33401,7 @@ function parseFrame(data) {
33317
33401
  const payload = data.subarray(offset, offset + payloadLen);
33318
33402
  return { fin: !!fin, opcode, payload: Buffer.from(payload), bytesConsumed: offset + payloadLen };
33319
33403
  }
33320
- function createRouteConnection(socket, path10, headers, params, auth) {
33404
+ function createRouteConnection(socket, path9, headers, params, auth) {
33321
33405
  const id = randomUUID4().slice(0, 8);
33322
33406
  const send = (message) => {
33323
33407
  try {
@@ -33327,14 +33411,14 @@ function createRouteConnection(socket, path10, headers, params, auth) {
33327
33411
  };
33328
33412
  const conn = {
33329
33413
  id,
33330
- path: path10,
33414
+ path: path9,
33331
33415
  ip: socket.remoteAddress ?? "unknown",
33332
33416
  headers,
33333
33417
  params,
33334
33418
  auth,
33335
33419
  send,
33336
33420
  sendJson: (data) => send(JSON.stringify(data)),
33337
- broadcast: (message) => wsRouteManager.broadcastPath(path10, message),
33421
+ broadcast: (message) => wsRouteManager.broadcastPath(path9, message),
33338
33422
  broadcastToRoom: (room, message, excludeSelf = false) => wsRouteManager.broadcastToRoom(room, message, excludeSelf ? id : void 0),
33339
33423
  getRoomConnections: (room) => wsRouteManager.getRoomConnections(room),
33340
33424
  joinRoom: (room) => wsRouteManager.joinRoom(id, room),
@@ -33543,8 +33627,8 @@ var init_websocket = __esm({
33543
33627
  * to the Router's `(conn, event, data)` style and registers it via
33544
33628
  * `Router.websocket()`.
33545
33629
  */
33546
- route(path10, handler, options) {
33547
- this._routeHandlers.set(path10, handler);
33630
+ route(path9, handler, options) {
33631
+ this._routeHandlers.set(path9, handler);
33548
33632
  const adapter = async (conn, event, data) => {
33549
33633
  if (event === "open") {
33550
33634
  const result = handler(conn);
@@ -33567,7 +33651,7 @@ var init_websocket = __esm({
33567
33651
  }
33568
33652
  }
33569
33653
  };
33570
- Router.websocket(path10, adapter, options);
33654
+ Router.websocket(path9, adapter, options);
33571
33655
  }
33572
33656
  /**
33573
33657
  * Broadcast a message to all connected clients.
@@ -33577,18 +33661,18 @@ var init_websocket = __esm({
33577
33661
  * When `path` is omitted/undefined, all clients receive the message
33578
33662
  * (backward compatible).
33579
33663
  */
33580
- broadcast(message, excludeIds, path10) {
33664
+ broadcast(message, excludeIds, path9) {
33581
33665
  this.ensureBackplane();
33582
33666
  const exclude = new Set(excludeIds ?? []);
33583
33667
  for (const [id, client] of Array.from(this.clients)) {
33584
33668
  if (exclude.has(id)) continue;
33585
- if (path10 !== void 0 && client.path !== path10) continue;
33669
+ if (path9 !== void 0 && client.path !== path9) continue;
33586
33670
  this.safeSend(client, message);
33587
33671
  }
33588
33672
  this.backplane.publish(
33589
- path10 !== void 0 ? "path" : "all",
33673
+ path9 !== void 0 ? "path" : "all",
33590
33674
  message,
33591
- { path: path10 ?? null, exclude: excludeIds?.[0] ?? null },
33675
+ { path: path9 ?? null, exclude: excludeIds?.[0] ?? null },
33592
33676
  Log
33593
33677
  );
33594
33678
  }
@@ -34064,10 +34148,10 @@ var init_websocket = __esm({
34064
34148
  }
34065
34149
  }
34066
34150
  /** Broadcast a text frame to every connection on the same path. */
34067
- broadcastPath(path10, message) {
34151
+ broadcastPath(path9, message) {
34068
34152
  const frame = buildFrame(OP_TEXT, Buffer.from(message, "utf-8"));
34069
34153
  for (const state of this.connections.values()) {
34070
- if (state.path !== path10 || state.closed) continue;
34154
+ if (state.path !== path9 || state.closed) continue;
34071
34155
  try {
34072
34156
  state.socket.write(frame);
34073
34157
  } catch {
@@ -35680,8 +35764,8 @@ var init_job = __esm({
35680
35764
  });
35681
35765
 
35682
35766
  // src/queueBackends/liteBackend.ts
35683
- import { mkdirSync as mkdirSync15, readdirSync as readdirSync12, readFileSync as readFileSync16, writeFileSync as writeFileSync11, unlinkSync as unlinkSync8, existsSync as existsSync19 } from "node:fs";
35684
- import { join as join23 } from "node:path";
35767
+ import { mkdirSync as mkdirSync15, readdirSync as readdirSync12, readFileSync as readFileSync16, writeFileSync as writeFileSync11, unlinkSync as unlinkSync8, existsSync as existsSync20 } from "node:fs";
35768
+ import { join as join24 } from "node:path";
35685
35769
  import { randomUUID as randomUUID7 } from "node:crypto";
35686
35770
  var LiteBackend;
35687
35771
  var init_liteBackend = __esm({
@@ -35705,22 +35789,22 @@ var init_liteBackend = __esm({
35705
35789
  this.visibilityTimeout = visibilityTimeout;
35706
35790
  }
35707
35791
  ensureDir(queue) {
35708
- const dir = join23(this.basePath, queue);
35792
+ const dir = join24(this.basePath, queue);
35709
35793
  mkdirSync15(dir, { recursive: true });
35710
35794
  return dir;
35711
35795
  }
35712
35796
  ensureFailedDir(queue) {
35713
- const dir = join23(this.basePath, queue, "failed");
35797
+ const dir = join24(this.basePath, queue, "failed");
35714
35798
  mkdirSync15(dir, { recursive: true });
35715
35799
  return dir;
35716
35800
  }
35717
35801
  ensureReservedDir(queue) {
35718
- const dir = join23(this.basePath, queue, "reserved");
35802
+ const dir = join24(this.basePath, queue, "reserved");
35719
35803
  mkdirSync15(dir, { recursive: true });
35720
35804
  return dir;
35721
35805
  }
35722
35806
  reservedPath(queue, jobId) {
35723
- return join23(this.ensureReservedDir(queue), `${jobId}.queue-data`);
35807
+ return join24(this.ensureReservedDir(queue), `${jobId}.queue-data`);
35724
35808
  }
35725
35809
  nowIso() {
35726
35810
  return (/* @__PURE__ */ new Date()).toISOString();
@@ -35763,7 +35847,7 @@ var init_liteBackend = __esm({
35763
35847
  error: void 0
35764
35848
  };
35765
35849
  const prefix = this.nextPrefix();
35766
- writeFileSync11(join23(dir, `${prefix}_${id}.queue-data`), JSON.stringify(job, null, 2));
35850
+ writeFileSync11(join24(dir, `${prefix}_${id}.queue-data`), JSON.stringify(job, null, 2));
35767
35851
  return id;
35768
35852
  }
35769
35853
  /**
@@ -35782,7 +35866,7 @@ var init_liteBackend = __esm({
35782
35866
  }
35783
35867
  const candidates = [];
35784
35868
  for (const filename of filenames) {
35785
- const filePath = join23(dir, filename);
35869
+ const filePath = join24(dir, filename);
35786
35870
  let job;
35787
35871
  try {
35788
35872
  job = JSON.parse(readFileSync16(filePath, "utf-8"));
@@ -35846,7 +35930,7 @@ var init_liteBackend = __esm({
35846
35930
  return;
35847
35931
  }
35848
35932
  for (const filename of filenames) {
35849
- const filePath = join23(reservedDir, filename);
35933
+ const filePath = join24(reservedDir, filename);
35850
35934
  let record2;
35851
35935
  try {
35852
35936
  record2 = JSON.parse(readFileSync16(filePath, "utf-8"));
@@ -35884,7 +35968,7 @@ var init_liteBackend = __esm({
35884
35968
  this.reclaimExpired(queue, bridge.getMaxRetries(), this.nowIso());
35885
35969
  const now = this.nowIso();
35886
35970
  for (const [filename, job] of this.availableCandidates(queue, now)) {
35887
- const filePath = join23(dir, filename);
35971
+ const filePath = join24(dir, filename);
35888
35972
  job.topic = queue;
35889
35973
  job.priority = job.priority ?? 0;
35890
35974
  this.writeReserved(queue, job);
@@ -35909,7 +35993,7 @@ var init_liteBackend = __esm({
35909
35993
  const results = [];
35910
35994
  for (const [filename, job] of this.availableCandidates(queue, now)) {
35911
35995
  if (results.length >= count) break;
35912
- const filePath = join23(dir, filename);
35996
+ const filePath = join24(dir, filename);
35913
35997
  job.topic = queue;
35914
35998
  job.priority = job.priority ?? 0;
35915
35999
  this.writeReserved(queue, job);
@@ -35962,7 +36046,7 @@ var init_liteBackend = __esm({
35962
36046
  let count = 0;
35963
36047
  for (const file of files) {
35964
36048
  try {
35965
- const job = JSON.parse(readFileSync16(join23(scanDir, file), "utf-8"));
36049
+ const job = JSON.parse(readFileSync16(join24(scanDir, file), "utf-8"));
35966
36050
  if (job.status === status2) count++;
35967
36051
  } catch {
35968
36052
  }
@@ -35975,28 +36059,28 @@ var init_liteBackend = __esm({
35975
36059
  try {
35976
36060
  const files = readdirSync12(dir).filter((f) => f.endsWith(".queue-data"));
35977
36061
  for (const file of files) {
35978
- unlinkSync8(join23(dir, file));
36062
+ unlinkSync8(join24(dir, file));
35979
36063
  count++;
35980
36064
  }
35981
36065
  } catch {
35982
36066
  }
35983
- const failedDir = join23(dir, "failed");
36067
+ const failedDir = join24(dir, "failed");
35984
36068
  try {
35985
- if (existsSync19(failedDir)) {
36069
+ if (existsSync20(failedDir)) {
35986
36070
  const files = readdirSync12(failedDir).filter((f) => f.endsWith(".queue-data"));
35987
36071
  for (const file of files) {
35988
- unlinkSync8(join23(failedDir, file));
36072
+ unlinkSync8(join24(failedDir, file));
35989
36073
  count++;
35990
36074
  }
35991
36075
  }
35992
36076
  } catch {
35993
36077
  }
35994
- const reservedDir = join23(dir, "reserved");
36078
+ const reservedDir = join24(dir, "reserved");
35995
36079
  try {
35996
- if (existsSync19(reservedDir)) {
36080
+ if (existsSync20(reservedDir)) {
35997
36081
  const files = readdirSync12(reservedDir).filter((f) => f.endsWith(".queue-data"));
35998
36082
  for (const file of files) {
35999
- unlinkSync8(join23(reservedDir, file));
36083
+ unlinkSync8(join24(reservedDir, file));
36000
36084
  count++;
36001
36085
  }
36002
36086
  }
@@ -36019,7 +36103,7 @@ var init_liteBackend = __esm({
36019
36103
  const files = readdirSync12(dir).filter((f) => f.endsWith(".queue-data")).sort();
36020
36104
  for (const file of files) {
36021
36105
  try {
36022
- const job = JSON.parse(readFileSync16(join23(dir, file), "utf-8"));
36106
+ const job = JSON.parse(readFileSync16(join24(dir, file), "utf-8"));
36023
36107
  const attempts = job.attempts || 0;
36024
36108
  if (attempts > 0 && attempts < maxRetries) {
36025
36109
  results.push(job);
@@ -36042,9 +36126,9 @@ var init_liteBackend = __esm({
36042
36126
  try {
36043
36127
  const queues = readdirSync12(this.basePath);
36044
36128
  for (const q of queues) {
36045
- const failedDir = join23(this.basePath, q, "failed");
36046
- const filePath = join23(failedDir, `${jobId}.queue-data`);
36047
- if (existsSync19(filePath)) {
36129
+ const failedDir = join24(this.basePath, q, "failed");
36130
+ const filePath = join24(failedDir, `${jobId}.queue-data`);
36131
+ if (existsSync20(filePath)) {
36048
36132
  const job = JSON.parse(readFileSync16(filePath, "utf-8"));
36049
36133
  job.status = "pending";
36050
36134
  job.attempts = (job.attempts || 0) + 1;
@@ -36052,8 +36136,8 @@ var init_liteBackend = __esm({
36052
36136
  job.createdAt = (/* @__PURE__ */ new Date()).toISOString();
36053
36137
  job.delayUntil = delaySeconds ? new Date(Date.now() + delaySeconds * 1e3).toISOString() : null;
36054
36138
  const prefix = this.nextPrefix();
36055
- const queueDir = join23(this.basePath, q);
36056
- writeFileSync11(join23(queueDir, `${prefix}_${jobId}.queue-data`), JSON.stringify(job, null, 2));
36139
+ const queueDir = join24(this.basePath, q);
36140
+ writeFileSync11(join24(queueDir, `${prefix}_${jobId}.queue-data`), JSON.stringify(job, null, 2));
36057
36141
  unlinkSync8(filePath);
36058
36142
  return true;
36059
36143
  }
@@ -36069,7 +36153,7 @@ var init_liteBackend = __esm({
36069
36153
  const files = readdirSync12(failedDir).filter((f) => f.endsWith(".queue-data")).sort();
36070
36154
  for (const file of files) {
36071
36155
  try {
36072
- const job = JSON.parse(readFileSync16(join23(failedDir, file), "utf-8"));
36156
+ const job = JSON.parse(readFileSync16(join24(failedDir, file), "utf-8"));
36073
36157
  if ((job.attempts || 0) >= maxRetries) {
36074
36158
  job.status = "dead";
36075
36159
  results.push(job);
@@ -36090,7 +36174,7 @@ var init_liteBackend = __esm({
36090
36174
  const files = readdirSync12(failedDir).filter((f) => f.endsWith(".queue-data"));
36091
36175
  for (const file of files) {
36092
36176
  try {
36093
- unlinkSync8(join23(failedDir, file));
36177
+ unlinkSync8(join24(failedDir, file));
36094
36178
  count++;
36095
36179
  } catch {
36096
36180
  }
@@ -36103,9 +36187,9 @@ var init_liteBackend = __esm({
36103
36187
  const files = readdirSync12(dir).filter((f) => f.endsWith(".queue-data"));
36104
36188
  for (const file of files) {
36105
36189
  try {
36106
- const job = JSON.parse(readFileSync16(join23(dir, file), "utf-8"));
36190
+ const job = JSON.parse(readFileSync16(join24(dir, file), "utf-8"));
36107
36191
  if (job.status === status2) {
36108
- unlinkSync8(join23(dir, file));
36192
+ unlinkSync8(join24(dir, file));
36109
36193
  count++;
36110
36194
  }
36111
36195
  } catch {
@@ -36129,7 +36213,7 @@ var init_liteBackend = __esm({
36129
36213
  const files = readdirSync12(failedDir).filter((f) => f.endsWith(".queue-data"));
36130
36214
  for (const file of files) {
36131
36215
  try {
36132
- const filePath = join23(failedDir, file);
36216
+ const filePath = join24(failedDir, file);
36133
36217
  const job = JSON.parse(readFileSync16(filePath, "utf-8"));
36134
36218
  if ((job.attempts || 0) >= maxRetries) {
36135
36219
  continue;
@@ -36139,7 +36223,7 @@ var init_liteBackend = __esm({
36139
36223
  job.createdAt = (/* @__PURE__ */ new Date()).toISOString();
36140
36224
  job.delayUntil = null;
36141
36225
  const prefix = this.nextPrefix();
36142
- writeFileSync11(join23(queueDir, `${prefix}_${job.id}.queue-data`), JSON.stringify(job, null, 2));
36226
+ writeFileSync11(join24(queueDir, `${prefix}_${job.id}.queue-data`), JSON.stringify(job, null, 2));
36143
36227
  unlinkSync8(filePath);
36144
36228
  count++;
36145
36229
  } catch {
@@ -36159,7 +36243,7 @@ var init_liteBackend = __esm({
36159
36243
  }
36160
36244
  for (const file of files) {
36161
36245
  if (!file.includes(id)) continue;
36162
- const filePath = join23(dir, file);
36246
+ const filePath = join24(dir, file);
36163
36247
  let job;
36164
36248
  try {
36165
36249
  job = JSON.parse(readFileSync16(filePath, "utf-8"));
@@ -36207,7 +36291,7 @@ var init_liteBackend = __esm({
36207
36291
  error: error2
36208
36292
  };
36209
36293
  const prefix = this.nextPrefix();
36210
- writeFileSync11(join23(dir, `${prefix}_${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
36294
+ writeFileSync11(join24(dir, `${prefix}_${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
36211
36295
  }
36212
36296
  /**
36213
36297
  * Move the job to the dead-letter (failed/) directory. Terminal until a
@@ -36227,7 +36311,7 @@ var init_liteBackend = __esm({
36227
36311
  error: error2,
36228
36312
  failedAt: (/* @__PURE__ */ new Date()).toISOString()
36229
36313
  };
36230
- writeFileSync11(join23(failedDir, `${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
36314
+ writeFileSync11(join24(failedDir, `${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
36231
36315
  }
36232
36316
  /**
36233
36317
  * Record a failed attempt.
@@ -36277,7 +36361,7 @@ var init_liteBackend = __esm({
36277
36361
  retryJob(queue, job, delaySeconds) {
36278
36362
  this.clearReservation(queue, job.id);
36279
36363
  try {
36280
- unlinkSync8(join23(this.ensureFailedDir(queue), `${job.id}.queue-data`));
36364
+ unlinkSync8(join24(this.ensureFailedDir(queue), `${job.id}.queue-data`));
36281
36365
  } catch {
36282
36366
  }
36283
36367
  job.attempts = (job.attempts || 0) + 1;
@@ -37417,6 +37501,9 @@ var init_projectIndexExtractors = __esm({
37417
37501
  import * as fs6 from "node:fs";
37418
37502
  import * as path6 from "node:path";
37419
37503
  import * as crypto2 from "node:crypto";
37504
+ function indexKey(root, fullPath) {
37505
+ return path6.relative(root, fullPath).split(path6.sep).join("/");
37506
+ }
37420
37507
  function projectRoot2() {
37421
37508
  return path6.resolve(process.cwd());
37422
37509
  }
@@ -37451,7 +37538,7 @@ function extract2(fullPath) {
37451
37538
  return {};
37452
37539
  }
37453
37540
  const entry = {
37454
- path: path6.relative(projectRoot2(), fullPath),
37541
+ path: indexKey(projectRoot2(), fullPath),
37455
37542
  size: st.size,
37456
37543
  mtime: Math.floor(st.mtimeMs / 1e3),
37457
37544
  language: languageFor(fullPath)
@@ -37558,7 +37645,6 @@ var projectIndex_exports = {};
37558
37645
  __export(projectIndex_exports, {
37559
37646
  ProjectIndex: () => ProjectIndex
37560
37647
  });
37561
- import * as path7 from "node:path";
37562
37648
  import * as fs7 from "node:fs";
37563
37649
  function scoreSearchEntry(query, rel, entry) {
37564
37650
  let score = rel.toLowerCase().includes(query) ? 10 : 0;
@@ -37591,7 +37677,7 @@ var init_projectIndex = __esm({
37591
37677
  const found = [];
37592
37678
  walk(root, found);
37593
37679
  for (const fp of found) {
37594
- const rel = path7.relative(root, fp);
37680
+ const rel = indexKey(root, fp);
37595
37681
  seen.add(rel);
37596
37682
  let mtime;
37597
37683
  try {
@@ -37617,7 +37703,7 @@ var init_projectIndex = __esm({
37617
37703
  updated,
37618
37704
  removed: removed.length,
37619
37705
  total: Object.keys(files).length,
37620
- path: path7.relative(root, indexPath())
37706
+ path: indexKey(root, indexPath())
37621
37707
  };
37622
37708
  },
37623
37709
  search(query, limit = 20) {
@@ -38169,23 +38255,23 @@ __export(docs_exports, {
38169
38255
  returnFromSignature: () => returnFromSignature
38170
38256
  });
38171
38257
  import * as fs8 from "node:fs";
38172
- import * as path8 from "node:path";
38173
- import { fileURLToPath as fileURLToPath6 } from "node:url";
38258
+ import * as path7 from "node:path";
38259
+ import { fileURLToPath as fileURLToPath7 } from "node:url";
38174
38260
  function detectFrameworkRoots() {
38175
- const corePackageRoot = path8.resolve(__DIRNAME, "..");
38176
- const packagesRoot = path8.resolve(corePackageRoot, "..");
38261
+ const corePackageRoot = path7.resolve(__DIRNAME, "..");
38262
+ const packagesRoot = path7.resolve(corePackageRoot, "..");
38177
38263
  const roots = [];
38178
38264
  for (const pkg of ["core", "orm", "swagger", "frond"]) {
38179
- const dir = path8.join(packagesRoot, pkg, "src");
38265
+ const dir = path7.join(packagesRoot, pkg, "src");
38180
38266
  if (fs8.existsSync(dir)) roots.push(dir);
38181
38267
  }
38182
38268
  return roots;
38183
38269
  }
38184
38270
  function detectVersion(projectRoot3) {
38185
38271
  for (const candidate of [
38186
- path8.join(projectRoot3, "package.json"),
38187
- path8.resolve(__DIRNAME, "..", "..", "..", "package.json"),
38188
- path8.resolve(__DIRNAME, "..", "package.json")
38272
+ path7.join(projectRoot3, "package.json"),
38273
+ path7.resolve(__DIRNAME, "..", "..", "..", "package.json"),
38274
+ path7.resolve(__DIRNAME, "..", "package.json")
38189
38275
  ]) {
38190
38276
  try {
38191
38277
  const pkg = JSON.parse(fs8.readFileSync(candidate, "utf-8"));
@@ -38196,16 +38282,16 @@ function detectVersion(projectRoot3) {
38196
38282
  return "0.0.0";
38197
38283
  }
38198
38284
  function relativePath(absPath, projectRoot3, frameworkRoots) {
38199
- const norm = path8.resolve(absPath);
38285
+ const norm = path7.resolve(absPath);
38200
38286
  for (const fw of frameworkRoots) {
38201
- const parent = path8.dirname(fw);
38202
- if (norm.startsWith(parent + path8.sep)) {
38203
- const monorepo = path8.resolve(parent, "..", "..");
38204
- if (norm.startsWith(monorepo + path8.sep)) return path8.relative(monorepo, norm);
38205
- return path8.relative(parent, norm);
38287
+ const parent = path7.dirname(fw);
38288
+ if (norm.startsWith(parent + path7.sep)) {
38289
+ const monorepo = path7.resolve(parent, "..", "..");
38290
+ if (norm.startsWith(monorepo + path7.sep)) return path7.relative(monorepo, norm);
38291
+ return path7.relative(parent, norm);
38206
38292
  }
38207
38293
  }
38208
- if (norm.startsWith(projectRoot3 + path8.sep)) return path8.relative(projectRoot3, norm);
38294
+ if (norm.startsWith(projectRoot3 + path7.sep)) return path7.relative(projectRoot3, norm);
38209
38295
  return norm;
38210
38296
  }
38211
38297
  function tokenise(text) {
@@ -38245,12 +38331,12 @@ function walkTsFiles(root) {
38245
38331
  if (e.name.startsWith(".")) continue;
38246
38332
  if (e.isDirectory()) {
38247
38333
  if (e.name === "node_modules" || e.name === "tests" || e.name === "test" || e.name === "dist" || e.name === "build") continue;
38248
- visit(path8.join(dir, e.name));
38334
+ visit(path7.join(dir, e.name));
38249
38335
  } else if (e.isFile()) {
38250
38336
  if (!e.name.endsWith(".ts") && !e.name.endsWith(".js") && !e.name.endsWith(".mjs")) continue;
38251
38337
  if (e.name.endsWith(".test.ts") || e.name.endsWith(".test.js")) continue;
38252
38338
  if (e.name.endsWith(".d.ts")) continue;
38253
- found.push(path8.join(dir, e.name));
38339
+ found.push(path7.join(dir, e.name));
38254
38340
  }
38255
38341
  }
38256
38342
  }
@@ -38577,8 +38663,8 @@ var init_docs = __esm({
38577
38663
  "hash"
38578
38664
  ]);
38579
38665
  _DOCS_CACHE = /* @__PURE__ */ new Map();
38580
- __FILENAME = fileURLToPath6(import.meta.url);
38581
- __DIRNAME = path8.dirname(__FILENAME);
38666
+ __FILENAME = fileURLToPath7(import.meta.url);
38667
+ __DIRNAME = path7.dirname(__FILENAME);
38582
38668
  USER_DIRS = ["src/orm", "src/routes", "src/app", "src/services", "src/models"];
38583
38669
  FENCE_RE = new RegExp(
38584
38670
  String.fromCharCode(96, 96, 96) + "[a-zA-Z0-9_+-]*\\n([\\s\\S]*?)\\n" + String.fromCharCode(96, 96, 96),
@@ -38596,7 +38682,7 @@ var init_docs = __esm({
38596
38682
  userMtime = 0;
38597
38683
  frameworkMtime = 0;
38598
38684
  constructor(projectRoot3) {
38599
- this.projectRoot = path8.resolve(projectRoot3);
38685
+ this.projectRoot = path7.resolve(projectRoot3);
38600
38686
  this.frameworkRoots = detectFrameworkRoots();
38601
38687
  this.version = detectVersion(this.projectRoot);
38602
38688
  }
@@ -38788,7 +38874,7 @@ var init_docs = __esm({
38788
38874
  // ── Drift detector + sync ────────────────────────────────────────
38789
38875
  static checkDocs(mdPath, projectRoot3) {
38790
38876
  if (!fs8.existsSync(mdPath)) return { drift: [] };
38791
- const docs = _Docs.cached(projectRoot3 ?? path8.dirname(mdPath));
38877
+ const docs = _Docs.cached(projectRoot3 ?? path7.dirname(mdPath));
38792
38878
  const idx = docs.index();
38793
38879
  const known = /* @__PURE__ */ new Set();
38794
38880
  for (const e of idx) known.add(e.name.toLowerCase());
@@ -38815,7 +38901,7 @@ var init_docs = __esm({
38815
38901
  return { drift };
38816
38902
  }
38817
38903
  static syncDocs(mdPath, projectRoot3) {
38818
- const docs = _Docs.cached(projectRoot3 ?? (fs8.existsSync(mdPath) ? path8.dirname(mdPath) : process.cwd()));
38904
+ const docs = _Docs.cached(projectRoot3 ?? (fs8.existsSync(mdPath) ? path7.dirname(mdPath) : process.cwd()));
38819
38905
  const generated = docs.renderGeneratedBlock();
38820
38906
  const begin = "<!-- BEGIN GENERATED API -->";
38821
38907
  const end = "<!-- END GENERATED API -->";
@@ -38839,7 +38925,7 @@ ${end}
38839
38925
  }
38840
38926
  // ── Internals ────────────────────────────────────────────────────
38841
38927
  static cached(projectRoot3) {
38842
- const key = path8.resolve(projectRoot3 ?? process.cwd());
38928
+ const key = path7.resolve(projectRoot3 ?? process.cwd());
38843
38929
  let inst = _DOCS_CACHE.get(key);
38844
38930
  if (!inst) {
38845
38931
  inst = new _Docs(key);
@@ -38866,11 +38952,11 @@ ${end}
38866
38952
  this.frameworkMtime = shared.mtime;
38867
38953
  this.indexCache = null;
38868
38954
  }
38869
- const userMtime = this.maxMtime(USER_DIRS.map((d) => path8.join(this.projectRoot, d)));
38955
+ const userMtime = this.maxMtime(USER_DIRS.map((d) => path7.join(this.projectRoot, d)));
38870
38956
  if (this.indexCache === null || userMtime !== this.userMtime) {
38871
38957
  this.userEntries = /* @__PURE__ */ new Map();
38872
38958
  for (const sub of USER_DIRS) {
38873
- const dir = path8.join(this.projectRoot, sub);
38959
+ const dir = path7.join(this.projectRoot, sub);
38874
38960
  if (!fs8.existsSync(dir)) continue;
38875
38961
  for (const f of walkTsFiles(dir)) {
38876
38962
  buildEntriesForFile(f, "user", this.frameworkRoots, this.projectRoot, this.version, this.userEntries);
@@ -38953,9 +39039,9 @@ ${end}
38953
39039
 
38954
39040
  // src/devAdmin.ts
38955
39041
  import { cpus as osCpus } from "node:os";
38956
- import { readFileSync as readFileSync20, writeFileSync as writeFileSync15, existsSync as existsSync23, readdirSync as readdirSync16, mkdirSync as mkdirSync18, copyFileSync as copyFileSync2, statSync as statSync17, 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";
38957
- import { join as join27, dirname as dirname14, resolve as resolve16, relative as relative9, sep as sep8, basename as basename5 } from "node:path";
38958
- import { fileURLToPath as fileURLToPath7 } from "node:url";
39042
+ import { readFileSync as readFileSync20, writeFileSync as writeFileSync15, existsSync as existsSync24, readdirSync as readdirSync16, mkdirSync as mkdirSync18, copyFileSync as copyFileSync2, 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";
39043
+ import { join as join28, dirname as dirname14, resolve as resolve16, relative as relative8, sep as sep9, basename as basename5 } from "node:path";
39044
+ import { fileURLToPath as fileURLToPath8 } from "node:url";
38959
39045
  import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
38960
39046
  import net2 from "node:net";
38961
39047
  function escapeHtml2(value) {
@@ -39033,15 +39119,15 @@ function devToolbarAllowed(req2) {
39033
39119
  return devPeerAllowed(peer);
39034
39120
  }
39035
39121
  function devRequestDenial(req2) {
39036
- const path10 = (req2.path ?? "").replace(/\/+/g, "/");
39037
- const isMcp = DEV_MCP_PREFIXES.some((prefix) => path10 === prefix || path10.startsWith(prefix + "/"));
39122
+ const path9 = (req2.path ?? "").replace(/\/+/g, "/");
39123
+ const isMcp = DEV_MCP_PREFIXES.some((prefix) => path9 === prefix || path9.startsWith(prefix + "/"));
39038
39124
  if (!devHostAllowed(req2.header("host"))) {
39039
39125
  return { status: 403, error: "dev-admin: refused (host not allowed)" };
39040
39126
  }
39041
39127
  if (!devSameOriginOk(req2)) {
39042
39128
  return { status: 403, error: "dev-admin: refused (cross-origin request)" };
39043
39129
  }
39044
- if (DEV_PUBLIC_ASSETS.has(path10)) {
39130
+ if (DEV_PUBLIC_ASSETS.has(path9)) {
39045
39131
  return null;
39046
39132
  }
39047
39133
  if (!isMcp) {
@@ -39133,12 +39219,12 @@ function mapQueueJob(job, topic, status2) {
39133
39219
  };
39134
39220
  }
39135
39221
  function readQueueDir(dir, topic, status2) {
39136
- if (!existsSync23(dir)) return [];
39222
+ if (!existsSync24(dir)) return [];
39137
39223
  const jobs = [];
39138
39224
  for (const filename of readdirSync16(dir).sort()) {
39139
39225
  if (!filename.endsWith(".queue-data")) continue;
39140
39226
  try {
39141
- jobs.push(mapQueueJob(JSON.parse(readFileSync20(join27(dir, filename), "utf-8")), topic, status2));
39227
+ jobs.push(mapQueueJob(JSON.parse(readFileSync20(join28(dir, filename), "utf-8")), topic, status2));
39142
39228
  } catch {
39143
39229
  }
39144
39230
  }
@@ -39275,8 +39361,8 @@ async function proxyToSupervisor(req2, res, downstreamPath) {
39275
39361
  function resolveDevEnvVar(key) {
39276
39362
  const live = process.env[key];
39277
39363
  if (live !== void 0 && live !== "") return live;
39278
- const envPath = join27(process.cwd(), ".env");
39279
- if (!existsSync23(envPath)) return "";
39364
+ const envPath = join28(process.cwd(), ".env");
39365
+ if (!existsSync24(envPath)) return "";
39280
39366
  for (const line of readFileSync20(envPath, "utf-8").split("\n")) {
39281
39367
  const t = line.trim();
39282
39368
  if (!t || t.startsWith("#") || !t.includes("=")) continue;
@@ -39286,8 +39372,8 @@ function resolveDevEnvVar(key) {
39286
39372
  return "";
39287
39373
  }
39288
39374
  function upsertDevEnvVar(key, value) {
39289
- const envPath = join27(process.cwd(), ".env");
39290
- const lines = existsSync23(envPath) ? readFileSync20(envPath, "utf-8").split("\n") : [];
39375
+ const envPath = join28(process.cwd(), ".env");
39376
+ const lines = existsSync24(envPath) ? readFileSync20(envPath, "utf-8").split("\n") : [];
39291
39377
  let found = false;
39292
39378
  const out = [];
39293
39379
  for (const line of lines) {
@@ -39317,9 +39403,9 @@ function formatUptime(seconds) {
39317
39403
  return parts.join(" ");
39318
39404
  }
39319
39405
  function parseEnvFile() {
39320
- const envPath = join27(process.cwd(), ".env");
39406
+ const envPath = join28(process.cwd(), ".env");
39321
39407
  const result = {};
39322
- if (!existsSync23(envPath)) return result;
39408
+ if (!existsSync24(envPath)) return result;
39323
39409
  const lines = readFileSync20(envPath, "utf-8").split("\n");
39324
39410
  for (const line of lines) {
39325
39411
  const trimmed = line.trim();
@@ -39331,10 +39417,10 @@ function parseEnvFile() {
39331
39417
  }
39332
39418
  function walkDirRecursive(dir) {
39333
39419
  const results = [];
39334
- if (!existsSync23(dir)) return results;
39420
+ if (!existsSync24(dir)) return results;
39335
39421
  for (const entry of readdirSync16(dir)) {
39336
- const full = join27(dir, entry);
39337
- if (statSync17(full).isDirectory()) {
39422
+ const full = join28(dir, entry);
39423
+ if (statSync18(full).isDirectory()) {
39338
39424
  results.push(...walkDirRecursive(full));
39339
39425
  } else {
39340
39426
  results.push(full);
@@ -39351,8 +39437,8 @@ function handleGalleryDeploy(router) {
39351
39437
  return;
39352
39438
  }
39353
39439
  const galleryDir = resolve16(__devAdminDirname, "..", "gallery");
39354
- const gallerySrc = join27(galleryDir, name, "src");
39355
- if (!existsSync23(gallerySrc)) {
39440
+ const gallerySrc = join28(galleryDir, name, "src");
39441
+ if (!existsSync24(gallerySrc)) {
39356
39442
  res.json({ error: `Gallery item '${name}' not found` }, 404);
39357
39443
  return;
39358
39444
  }
@@ -39360,15 +39446,15 @@ function handleGalleryDeploy(router) {
39360
39446
  const copied = [];
39361
39447
  const allFiles = walkDirRecursive(gallerySrc);
39362
39448
  for (const srcFile of allFiles) {
39363
- const rel = relative9(gallerySrc, srcFile);
39364
- const dest = join27(projectSrc, rel);
39449
+ const rel = relative8(gallerySrc, srcFile);
39450
+ const dest = join28(projectSrc, rel);
39365
39451
  mkdirSync18(dirname14(dest), { recursive: true });
39366
39452
  copyFileSync2(srcFile, dest);
39367
39453
  copied.push(rel);
39368
39454
  }
39369
39455
  try {
39370
39456
  const routesDir = resolve16(process.cwd(), "src", "routes");
39371
- if (existsSync23(routesDir)) {
39457
+ if (existsSync24(routesDir)) {
39372
39458
  const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_routeDiscovery(), routeDiscovery_exports));
39373
39459
  const routes = await discoverRoutes2(routesDir);
39374
39460
  for (const route of routes) {
@@ -39397,7 +39483,7 @@ function realPathOf2(target) {
39397
39483
  tail.unshift(basename5(existing));
39398
39484
  existing = dirname14(existing);
39399
39485
  }
39400
- return join27(realpathSync6(existing), ...tail);
39486
+ return join28(realpathSync6(existing), ...tail);
39401
39487
  }
39402
39488
  function safeJoin(projectRoot3, rel, extraRoots = []) {
39403
39489
  try {
@@ -39405,14 +39491,14 @@ function safeJoin(projectRoot3, rel, extraRoots = []) {
39405
39491
  const resolved = realPathOf2(resolve16(root, rel));
39406
39492
  const roots = [root, ...extraRoots.filter(Boolean).map((r) => realPathOf2(resolve16(r)))];
39407
39493
  for (const r of roots) {
39408
- if (resolved === r || resolved.startsWith(r.endsWith(sep8) ? r : r + sep8)) return resolved;
39494
+ if (resolved === r || resolved.startsWith(r.endsWith(sep9) ? r : r + sep9)) return resolved;
39409
39495
  }
39410
39496
  } catch {
39411
39497
  }
39412
39498
  return null;
39413
39499
  }
39414
39500
  function resolvedRelative(projectRoot3, resolvedPath) {
39415
- return relative9(realPathOf2(resolve16(projectRoot3)), resolvedPath);
39501
+ return relative8(realPathOf2(resolve16(projectRoot3)), resolvedPath);
39416
39502
  }
39417
39503
  function devFilesHidden(name) {
39418
39504
  if (DEV_FILES_IGNORED.has(name)) return true;
@@ -39428,10 +39514,10 @@ function devGitStatusLabel(code) {
39428
39514
  async function devGitInfo(root) {
39429
39515
  const empty = { branch: "", gitRoot: null, status: /* @__PURE__ */ new Map() };
39430
39516
  try {
39431
- const { execFileSync: execFileSync6 } = await import("node:child_process");
39517
+ const { execFileSync: execFileSync5 } = await import("node:child_process");
39432
39518
  const git = (args) => {
39433
39519
  try {
39434
- return execFileSync6("git", args, { cwd: root, timeout: 3e3, encoding: "utf-8" }).toString();
39520
+ return execFileSync5("git", args, { cwd: root, timeout: 3e3, encoding: "utf-8" }).toString();
39435
39521
  } catch {
39436
39522
  return null;
39437
39523
  }
@@ -39483,7 +39569,7 @@ function buildFileEntry(name, full, entryRel, cwdInGit, gitStatus) {
39483
39569
  let isDir = false;
39484
39570
  let size = null;
39485
39571
  try {
39486
- const st = statSync17(full);
39572
+ const st = statSync18(full);
39487
39573
  isDir = st.isDirectory();
39488
39574
  if (!isDir) size = st.size;
39489
39575
  } catch {
@@ -39558,7 +39644,7 @@ function applyMcpOutcome(res, outcome) {
39558
39644
  function renderToolbarHtml(ctx) {
39559
39645
  const nodeVersion = process.version;
39560
39646
  const method = escapeHtml2(ctx.method);
39561
- const path10 = escapeHtml2(ctx.path);
39647
+ const path9 = escapeHtml2(ctx.path);
39562
39648
  const matchedPattern = escapeHtml2(ctx.matchedPattern);
39563
39649
  const reload = ctx.reload === false ? "0" : "1";
39564
39650
  return `<link rel="stylesheet" href="/__dev/toolbar.css">
@@ -39575,7 +39661,7 @@ function renderToolbarHtml(ctx) {
39575
39661
  </div>
39576
39662
  </div>
39577
39663
  <span class="t4-green">${method}</span>
39578
- <span>${path10}</span>
39664
+ <span>${path9}</span>
39579
39665
  <span class="t4-arrow">&rarr; ${matchedPattern}</span>
39580
39666
  <span class="t4-yellow">req:${ctx.requestId}</span>
39581
39667
  <span class="t4-blue">${ctx.routeCount} routes</span>
@@ -39750,6 +39836,7 @@ var init_devAdmin = __esm({
39750
39836
  "src/devAdmin.ts"() {
39751
39837
  "use strict";
39752
39838
  init_slashTrim();
39839
+ init_batchSpawn();
39753
39840
  init_devMailbox();
39754
39841
  init_upstreamResponse();
39755
39842
  init_dotenv();
@@ -39811,12 +39898,12 @@ var init_devAdmin = __esm({
39811
39898
  RequestInspector = class {
39812
39899
  static requests = [];
39813
39900
  static maxRequests = 200;
39814
- static capture(method, path10, status2, duration) {
39901
+ static capture(method, path9, status2, duration) {
39815
39902
  const entry = {
39816
39903
  id: `${Date.now()}_${this.requests.length}`,
39817
39904
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
39818
39905
  method,
39819
- path: path10,
39906
+ path: path9,
39820
39907
  status: status2,
39821
39908
  durationMs: Math.round(duration * 100) / 100
39822
39909
  };
@@ -40005,12 +40092,12 @@ var init_devAdmin = __esm({
40005
40092
  };
40006
40093
  WsTracker = class {
40007
40094
  static connections = [];
40008
- static add(remoteAddress, path10) {
40095
+ static add(remoteAddress, path9) {
40009
40096
  const conn = {
40010
40097
  id: `ws_${Date.now()}_${this.connections.length}`,
40011
40098
  connectedAt: (/* @__PURE__ */ new Date()).toISOString(),
40012
40099
  remoteAddress,
40013
- path: path10
40100
+ path: path9
40014
40101
  };
40015
40102
  this.connections.push(conn);
40016
40103
  return conn.id;
@@ -40120,7 +40207,7 @@ var init_devAdmin = __esm({
40120
40207
  const p = (url.searchParams.get("path") || "").toString();
40121
40208
  const scanRoot = metricsScanRoot();
40122
40209
  let target = p ? safeJoin(process.cwd(), p, [scanRoot]) : "";
40123
- if (target === null && scanRoot) target = safeJoin(process.cwd(), join27(scanRoot, p), [scanRoot]);
40210
+ if (target === null && scanRoot) target = safeJoin(process.cwd(), join28(scanRoot, p), [scanRoot]);
40124
40211
  if (target === null) {
40125
40212
  res.status(403).json({ error: "Path outside project" });
40126
40213
  return;
@@ -40441,16 +40528,16 @@ var init_devAdmin = __esm({
40441
40528
  failed: queue.size("failed"),
40442
40529
  reserved: queue.size("reserved")
40443
40530
  };
40444
- const topicDir = join27(queueBasePath2(), topic);
40531
+ const topicDir = join28(queueBasePath2(), topic);
40445
40532
  const jobs = [];
40446
40533
  if (!statusFilter || statusFilter === "pending") {
40447
40534
  jobs.push(...readQueueDir(topicDir, topic, "pending"));
40448
40535
  }
40449
40536
  if (!statusFilter || statusFilter === "reserved") {
40450
- jobs.push(...readQueueDir(join27(topicDir, "reserved"), topic, "reserved"));
40537
+ jobs.push(...readQueueDir(join28(topicDir, "reserved"), topic, "reserved"));
40451
40538
  }
40452
40539
  if (!statusFilter || statusFilter === "failed" || statusFilter === "dead") {
40453
- jobs.push(...readQueueDir(join27(topicDir, "failed"), topic, "dead_letter"));
40540
+ jobs.push(...readQueueDir(join28(topicDir, "failed"), topic, "dead_letter"));
40454
40541
  }
40455
40542
  res.json({ stats, jobs });
40456
40543
  } catch (e) {
@@ -40466,10 +40553,10 @@ var init_devAdmin = __esm({
40466
40553
  const { queueBasePath: queueBasePath2 } = await Promise.resolve().then(() => (init_queue(), queue_exports));
40467
40554
  const queueDir = queueBasePath2();
40468
40555
  let topics = [];
40469
- if (existsSync23(queueDir)) {
40556
+ if (existsSync24(queueDir)) {
40470
40557
  topics = readdirSync16(queueDir).filter((d) => {
40471
40558
  try {
40472
- return statSync17(join27(queueDir, d)).isDirectory();
40559
+ return statSync18(join28(queueDir, d)).isDirectory();
40473
40560
  } catch {
40474
40561
  return false;
40475
40562
  }
@@ -40754,7 +40841,7 @@ var init_devAdmin = __esm({
40754
40841
  const count = parseInt(String(body.count ?? "10"), 10) || 10;
40755
40842
  try {
40756
40843
  const orm = await Promise.resolve().then(() => (init_src(), src_exports));
40757
- const dirs = ["src/orm", "src/models"].map((d) => resolve16(process.cwd(), d)).filter((d) => existsSync23(d));
40844
+ const dirs = ["src/orm", "src/models"].map((d) => resolve16(process.cwd(), d)).filter((d) => existsSync24(d));
40758
40845
  const classes = [];
40759
40846
  for (const dir of dirs) {
40760
40847
  for (const m of await orm.discoverModels(dir)) classes.push(m.modelClass);
@@ -40895,7 +40982,7 @@ var init_devAdmin = __esm({
40895
40982
  return;
40896
40983
  }
40897
40984
  try {
40898
- const envPath = join27(process.cwd(), ".env");
40985
+ const envPath = join28(process.cwd(), ".env");
40899
40986
  const fd = openSync5(envPath, constants4.O_RDWR | constants4.O_APPEND | constants4.O_CREAT | (constants4.O_NOFOLLOW ?? 0) | (constants4.O_NONBLOCK ?? 0), 384);
40900
40987
  try {
40901
40988
  const info = fstatSync3(fd);
@@ -40939,29 +41026,29 @@ var init_devAdmin = __esm({
40939
41026
  res.json({ success: false, error: msg });
40940
41027
  }
40941
41028
  };
40942
- __devAdminFilename = fileURLToPath7(import.meta.url);
41029
+ __devAdminFilename = fileURLToPath8(import.meta.url);
40943
41030
  __devAdminDirname = dirname14(__devAdminFilename);
40944
41031
  handleGalleryList = (_req, res) => {
40945
41032
  const galleryDir = resolve16(__devAdminDirname, "..", "gallery");
40946
41033
  const items = [];
40947
- if (existsSync23(galleryDir)) {
41034
+ if (existsSync24(galleryDir)) {
40948
41035
  const entries = readdirSync16(galleryDir).sort();
40949
41036
  for (const entry of entries) {
40950
- const entryPath = join27(galleryDir, entry);
40951
- const metaFile = join27(entryPath, "meta.json");
40952
- if (statSync17(entryPath).isDirectory() && existsSync23(metaFile)) {
41037
+ const entryPath = join28(galleryDir, entry);
41038
+ const metaFile = join28(entryPath, "meta.json");
41039
+ if (statSync18(entryPath).isDirectory() && existsSync24(metaFile)) {
40953
41040
  try {
40954
41041
  const meta = JSON.parse(readFileSync20(metaFile, "utf-8"));
40955
41042
  meta.id = entry;
40956
- const srcDir = join27(entryPath, "src");
40957
- if (existsSync23(srcDir)) {
41043
+ const srcDir = join28(entryPath, "src");
41044
+ if (existsSync24(srcDir)) {
40958
41045
  const allFiles = walkDirRecursive(srcDir);
40959
- meta.files = allFiles.map((f) => relative9(srcDir, f));
41046
+ meta.files = allFiles.map((f) => relative8(srcDir, f));
40960
41047
  }
40961
41048
  const projectSrc = resolve16(process.cwd(), "src");
40962
- if (existsSync23(srcDir) && meta.files) {
41049
+ if (existsSync24(srcDir) && meta.files) {
40963
41050
  meta.deployed = meta.files.every(
40964
- (f) => existsSync23(join27(projectSrc, f))
41051
+ (f) => existsSync24(join28(projectSrc, f))
40965
41052
  );
40966
41053
  } else {
40967
41054
  meta.deployed = false;
@@ -41038,7 +41125,7 @@ var init_devAdmin = __esm({
41038
41125
  const root = resolve16(process.cwd());
41039
41126
  const target = safeJoin(root, rel);
41040
41127
  const { branch, gitRoot, status: gitStatus } = await devGitInfo(root);
41041
- if (!target || !existsSync23(target) || !statSync17(target).isDirectory()) {
41128
+ if (!target || !existsSync24(target) || !statSync18(target).isDirectory()) {
41042
41129
  res.json({ path: rel, branch, entries: [], error: "not a directory" });
41043
41130
  return;
41044
41131
  }
@@ -41051,12 +41138,12 @@ var init_devAdmin = __esm({
41051
41138
  const entries = [];
41052
41139
  for (const name of readdirSync16(target).sort()) {
41053
41140
  if (devFilesHidden(name)) continue;
41054
- const full = join27(target, name);
41055
- const entryRel = relative9(root, full).replace(/\\/g, "/");
41141
+ const full = join28(target, name);
41142
+ const entryRel = relative8(root, full).replace(/\\/g, "/");
41056
41143
  if (isSecretPath(entryRel)) continue;
41057
41144
  entries.push(buildFileEntry(name, full, entryRel, cwdInGit, gitStatus));
41058
41145
  }
41059
- res.json({ path: relative9(root, target).replace(/\\/g, "/") || ".", branch, entries });
41146
+ res.json({ path: relative8(root, target).replace(/\\/g, "/") || ".", branch, entries });
41060
41147
  };
41061
41148
  DEV_ADMIN_LANG_MAP = {
41062
41149
  ".py": "python",
@@ -41114,8 +41201,8 @@ var init_devAdmin = __esm({
41114
41201
  return;
41115
41202
  }
41116
41203
  const content = data.toString("utf-8");
41117
- const path10 = relative9(root, target);
41118
- res.json({ path: path10, content, language: devAdminLanguage(path10), bytes: Buffer.byteLength(content, "utf-8") });
41204
+ const path9 = relative8(root, target);
41205
+ res.json({ path: path9, content, language: devAdminLanguage(path9), bytes: Buffer.byteLength(content, "utf-8") });
41119
41206
  } catch (e) {
41120
41207
  res.json({ error: e.message }, 500);
41121
41208
  }
@@ -41132,14 +41219,14 @@ var init_devAdmin = __esm({
41132
41219
  }
41133
41220
  try {
41134
41221
  mkdirSync18(dirname14(target), { recursive: true });
41135
- const existed = existsSync23(target);
41222
+ const existed = existsSync24(target);
41136
41223
  writeFileSync15(target, content, "utf-8");
41137
41224
  try {
41138
41225
  const { Plan: Plan2 } = await Promise.resolve().then(() => (init_plan(), plan_exports));
41139
- Plan2.recordAction(existed ? "patched" : "created", relative9(root, target));
41226
+ Plan2.recordAction(existed ? "patched" : "created", relative8(root, target));
41140
41227
  } catch {
41141
41228
  }
41142
- res.json({ ok: true, path: relative9(root, target), bytes: Buffer.byteLength(content, "utf-8") });
41229
+ res.json({ ok: true, path: relative8(root, target), bytes: Buffer.byteLength(content, "utf-8") });
41143
41230
  } catch (e) {
41144
41231
  res.json({ error: e.message }, 500);
41145
41232
  }
@@ -41197,7 +41284,7 @@ var init_devAdmin = __esm({
41197
41284
  res.json({ error: "Invalid path" }, 400);
41198
41285
  return;
41199
41286
  }
41200
- if (!existsSync23(src)) {
41287
+ if (!existsSync24(src)) {
41201
41288
  res.json({ error: `Source not found: ${from}` }, 404);
41202
41289
  return;
41203
41290
  }
@@ -41205,7 +41292,7 @@ var init_devAdmin = __esm({
41205
41292
  const { renameSync: renameSync3 } = await import("node:fs");
41206
41293
  mkdirSync18(dirname14(dst), { recursive: true });
41207
41294
  renameSync3(src, dst);
41208
- res.json({ ok: true, from: relative9(root, src), to: relative9(root, dst) });
41295
+ res.json({ ok: true, from: relative8(root, src), to: relative8(root, dst) });
41209
41296
  } catch (e) {
41210
41297
  res.json({ error: e.message }, 500);
41211
41298
  }
@@ -41219,14 +41306,14 @@ var init_devAdmin = __esm({
41219
41306
  res.json({ error: "Invalid path" }, 400);
41220
41307
  return;
41221
41308
  }
41222
- if (!existsSync23(target)) {
41309
+ if (!existsSync24(target)) {
41223
41310
  res.json({ error: `Not found: ${rel}` }, 404);
41224
41311
  return;
41225
41312
  }
41226
41313
  try {
41227
41314
  const { rmSync: rmSync2 } = await import("node:fs");
41228
41315
  rmSync2(target, { recursive: true, force: true });
41229
- res.json({ ok: true, deleted: relative9(root, target) });
41316
+ res.json({ ok: true, deleted: relative8(root, target) });
41230
41317
  } catch (e) {
41231
41318
  res.json({ error: e.message }, 500);
41232
41319
  }
@@ -41261,13 +41348,11 @@ var init_devAdmin = __esm({
41261
41348
  return;
41262
41349
  }
41263
41350
  try {
41264
- const { execFileSync: execFileSync6 } = await import("node:child_process");
41265
41351
  const args = ["install", dev ? "--save-dev" : "--save", pkg];
41266
- const output = execFileSync6("npm", args, {
41352
+ const output = execFileSyncAllowingBatch("npm", args, {
41267
41353
  cwd: resolve16(process.cwd()),
41268
- timeout: 12e4,
41269
- encoding: "utf-8"
41270
- }).toString();
41354
+ timeout: 12e4
41355
+ });
41271
41356
  res.json({ ok: true, package: pkg, output });
41272
41357
  } catch (e) {
41273
41358
  res.json({ error: e.message }, 500);
@@ -41275,15 +41360,15 @@ var init_devAdmin = __esm({
41275
41360
  };
41276
41361
  handleGitStatus = async (_req, res) => {
41277
41362
  try {
41278
- const { execFileSync: execFileSync6 } = await import("node:child_process");
41363
+ const { execFileSync: execFileSync5 } = await import("node:child_process");
41279
41364
  const cwd = resolve16(process.cwd());
41280
41365
  try {
41281
- execFileSync6("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
41366
+ execFileSync5("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
41282
41367
  } catch {
41283
41368
  res.json({ error: "Not a git repository" }, 400);
41284
41369
  return;
41285
41370
  }
41286
- const run = (args) => execFileSync6("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
41371
+ const run = (args) => execFileSync5("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
41287
41372
  res.json({
41288
41373
  branch: run(["branch", "--show-current"]),
41289
41374
  status: run(["status", "--porcelain"]).split(/\r?\n/).filter((l) => l),
@@ -41413,12 +41498,10 @@ var init_devAdmin = __esm({
41413
41498
  return;
41414
41499
  }
41415
41500
  try {
41416
- const { execFileSync: execFileSync6 } = await import("node:child_process");
41417
- const output = execFileSync6("npx", ["tina4nodejs", "generate", kind, name], {
41501
+ const output = execFileSyncAllowingBatch("npx", ["tina4nodejs", "generate", kind, name], {
41418
41502
  cwd: resolve16(process.cwd()),
41419
- timeout: 3e4,
41420
- encoding: "utf-8"
41421
- }).toString();
41503
+ timeout: 3e4
41504
+ });
41422
41505
  res.json({ ok: true, kind, name, output });
41423
41506
  } catch (e) {
41424
41507
  res.json({ error: e.message }, 500);
@@ -41560,21 +41643,21 @@ var init_devAdmin = __esm({
41560
41643
  });
41561
41644
  };
41562
41645
  handleDevAdminJs = async (_req, res) => {
41563
- const { readFileSync: readFileSync27, existsSync: existsSync29 } = await import("node:fs");
41564
- const { dirname: dirname17, join: join33, resolve: resolve21 } = await import("node:path");
41565
- const { fileURLToPath: fileURLToPath10 } = await import("node:url");
41566
- const dir = dirname17(fileURLToPath10(import.meta.url));
41646
+ const { readFileSync: readFileSync27, existsSync: existsSync30 } = await import("node:fs");
41647
+ const { dirname: dirname17, join: join34, resolve: resolve21 } = await import("node:path");
41648
+ const { fileURLToPath: fileURLToPath11 } = await import("node:url");
41649
+ const dir = dirname17(fileURLToPath11(import.meta.url));
41567
41650
  const candidates = [
41568
- join33(dir, "..", "public", "js", "tina4-dev-admin.min.js"),
41651
+ join34(dir, "..", "public", "js", "tina4-dev-admin.min.js"),
41569
41652
  // src/../public/js/
41570
- join33(dir, "..", "..", "public", "js", "tina4-dev-admin.min.js"),
41653
+ join34(dir, "..", "..", "public", "js", "tina4-dev-admin.min.js"),
41571
41654
  // deeper nesting
41572
41655
  resolve21(process.cwd(), "node_modules", "tina4-nodejs", "packages", "core", "public", "js", "tina4-dev-admin.min.js"),
41573
41656
  resolve21(process.cwd(), "public", "js", "tina4-dev-admin.min.js")
41574
41657
  // project public/
41575
41658
  ];
41576
41659
  for (const jsPath of candidates) {
41577
- if (existsSync29(jsPath)) {
41660
+ if (existsSync30(jsPath)) {
41578
41661
  try {
41579
41662
  const content = readFileSync27(jsPath, "utf-8");
41580
41663
  res.raw.writeHead(200, { "Content-Type": "application/javascript; charset=utf-8", "Cache-Control": "no-cache" });
@@ -41588,20 +41671,20 @@ var init_devAdmin = __esm({
41588
41671
  res.raw.end("tina4-dev-admin.min.js not found");
41589
41672
  };
41590
41673
  handleDevAdminSplit = async (_req, res) => {
41591
- const { readFileSync: readFileSync27, existsSync: existsSync29 } = await import("node:fs");
41592
- const { dirname: dirname17, join: join33, resolve: resolve21 } = await import("node:path");
41593
- const { fileURLToPath: fileURLToPath10 } = await import("node:url");
41594
- const dir = dirname17(fileURLToPath10(import.meta.url));
41674
+ const { readFileSync: readFileSync27, existsSync: existsSync30 } = await import("node:fs");
41675
+ const { dirname: dirname17, join: join34, resolve: resolve21 } = await import("node:path");
41676
+ const { fileURLToPath: fileURLToPath11 } = await import("node:url");
41677
+ const dir = dirname17(fileURLToPath11(import.meta.url));
41595
41678
  const candidates = [
41596
- join33(dir, "..", "public", "js", "tina4-dev-admin-split.html"),
41597
- join33(dir, "..", "..", "public", "js", "tina4-dev-admin-split.html"),
41679
+ join34(dir, "..", "public", "js", "tina4-dev-admin-split.html"),
41680
+ join34(dir, "..", "..", "public", "js", "tina4-dev-admin-split.html"),
41598
41681
  resolve21(process.cwd(), "node_modules", "tina4-nodejs", "packages", "core", "public", "js", "tina4-dev-admin-split.html"),
41599
41682
  resolve21(process.cwd(), "public", "js", "tina4-dev-admin-split.html")
41600
41683
  ];
41601
- for (const path10 of candidates) {
41602
- if (existsSync29(path10)) {
41684
+ for (const path9 of candidates) {
41685
+ if (existsSync30(path9)) {
41603
41686
  try {
41604
- const content = readFileSync27(path10, "utf-8");
41687
+ const content = readFileSync27(path9, "utf-8");
41605
41688
  res.raw.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-cache" });
41606
41689
  res.raw.end(content);
41607
41690
  return;
@@ -41624,8 +41707,8 @@ var init_devAdmin = __esm({
41624
41707
  });
41625
41708
 
41626
41709
  // src/i18n.ts
41627
- import { readFileSync as readFileSync21, readdirSync as readdirSync17, existsSync as existsSync24 } from "node:fs";
41628
- import { join as join28, resolve as resolve17 } from "node:path";
41710
+ import { readFileSync as readFileSync21, readdirSync as readdirSync17, existsSync as existsSync25 } from "node:fs";
41711
+ import { join as join29, resolve as resolve17 } from "node:path";
41629
41712
  var I18n;
41630
41713
  var init_i18n = __esm({
41631
41714
  "src/i18n.ts"() {
@@ -41644,9 +41727,9 @@ var init_i18n = __esm({
41644
41727
  * Arg order is (locale, path) to match the Python master `I18n(locale, path)`
41645
41728
  * (BUG-7, BREAKING in 3.13.x — was previously (localeDir, defaultLocale)).
41646
41729
  */
41647
- constructor(locale, path10) {
41730
+ constructor(locale, path9) {
41648
41731
  this._localeDir = resolve17(
41649
- path10 ?? process.env.TINA4_LOCALE_DIR ?? "src/locales"
41732
+ path9 ?? process.env.TINA4_LOCALE_DIR ?? "src/locales"
41650
41733
  );
41651
41734
  this._defaultLocale = locale ?? process.env.TINA4_LOCALE ?? "en";
41652
41735
  this._currentLocale = this._defaultLocale;
@@ -41702,7 +41785,7 @@ var init_i18n = __esm({
41702
41785
  }
41703
41786
  /** List available locale codes based on JSON files in the locale directory. */
41704
41787
  availableLocales() {
41705
- if (!existsSync24(this._localeDir)) {
41788
+ if (!existsSync25(this._localeDir)) {
41706
41789
  return [this._defaultLocale];
41707
41790
  }
41708
41791
  try {
@@ -41718,8 +41801,8 @@ var init_i18n = __esm({
41718
41801
  if (this._translations.has(locale)) {
41719
41802
  return;
41720
41803
  }
41721
- const filePath = join28(this._localeDir, `${locale}.json`);
41722
- if (existsSync24(filePath)) {
41804
+ const filePath = join29(this._localeDir, `${locale}.json`);
41805
+ if (existsSync25(filePath)) {
41723
41806
  try {
41724
41807
  const raw = readFileSync21(filePath, "utf-8");
41725
41808
  const data = JSON.parse(raw);
@@ -41731,8 +41814,8 @@ var init_i18n = __esm({
41731
41814
  }
41732
41815
  }
41733
41816
  for (const ext of [".yml", ".yaml"]) {
41734
- const yamlPath = join28(this._localeDir, `${locale}${ext}`);
41735
- if (existsSync24(yamlPath)) {
41817
+ const yamlPath = join29(this._localeDir, `${locale}${ext}`);
41818
+ if (existsSync25(yamlPath)) {
41736
41819
  try {
41737
41820
  const raw = readFileSync21(yamlPath, "utf-8");
41738
41821
  const data = _I18n._parseSimpleYaml(raw);
@@ -43257,11 +43340,11 @@ __export(docsAutoDiscovery_exports, {
43257
43340
  writeMcpDiscovery: () => writeMcpDiscovery
43258
43341
  });
43259
43342
  import * as fs9 from "node:fs";
43260
- import * as path9 from "node:path";
43343
+ import * as path8 from "node:path";
43261
43344
  function writeMcpDiscovery(projectRoot3, port) {
43262
- const root = path9.resolve(projectRoot3);
43263
- const tinaDir = path9.join(root, TINA4_DIR);
43264
- const mcpPath = path9.join(tinaDir, MCP_FILE);
43345
+ const root = path8.resolve(projectRoot3);
43346
+ const tinaDir = path8.join(root, TINA4_DIR);
43347
+ const mcpPath = path8.join(tinaDir, MCP_FILE);
43265
43348
  const portStr = String(
43266
43349
  port || Number(process.env.TINA4_PORT) || Number(process.env.PORT) || 7148
43267
43350
  );
@@ -43288,9 +43371,9 @@ function writeMcpDiscovery(projectRoot3, port) {
43288
43371
  fs9.writeFileSync(mcpPath, desiredJson, "utf-8");
43289
43372
  wrote = true;
43290
43373
  }
43291
- const gitDir = path9.join(root, ".git");
43374
+ const gitDir = path8.join(root, ".git");
43292
43375
  if (fs9.existsSync(gitDir)) {
43293
- const gitignorePath = path9.join(root, ".gitignore");
43376
+ const gitignorePath = path8.join(root, ".gitignore");
43294
43377
  let contents = "";
43295
43378
  if (fs9.existsSync(gitignorePath)) {
43296
43379
  try {
@@ -43301,8 +43384,8 @@ function writeMcpDiscovery(projectRoot3, port) {
43301
43384
  const lines = contents.split(/\r?\n/);
43302
43385
  const already = lines.some((l) => l.trim() === GITIGNORE_LINE || l.trim() === ".tina4");
43303
43386
  if (!already) {
43304
- const sep9 = contents.endsWith("\n") || contents === "" ? "" : "\n";
43305
- fs9.writeFileSync(gitignorePath, `${contents}${sep9}${GITIGNORE_LINE}
43387
+ const sep10 = contents.endsWith("\n") || contents === "" ? "" : "\n";
43388
+ fs9.writeFileSync(gitignorePath, `${contents}${sep10}${GITIGNORE_LINE}
43306
43389
  `, "utf-8");
43307
43390
  }
43308
43391
  }
@@ -43320,11 +43403,11 @@ var init_docsAutoDiscovery = __esm({
43320
43403
 
43321
43404
  // src/server.ts
43322
43405
  import { randomBytes as randomBytes9 } from "node:crypto";
43323
- import { resolve as resolve19, dirname as dirname15, join as join30, relative as relative10 } from "node:path";
43324
- import { existsSync as existsSync26, readdirSync as readdirSync18, readFileSync as readFileSync23, statSync as statSync18 } from "node:fs";
43406
+ import { resolve as resolve19, dirname as dirname15, join as join31, relative as relative9 } from "node:path";
43407
+ import { existsSync as existsSync27, readdirSync as readdirSync18, readFileSync as readFileSync23, statSync as statSync19 } from "node:fs";
43325
43408
  import { isatty } from "node:tty";
43326
- import { fileURLToPath as fileURLToPath8 } from "node:url";
43327
- import { execFileSync as execFileSync3, execFile } from "node:child_process";
43409
+ import { fileURLToPath as fileURLToPath9 } from "node:url";
43410
+ import { execFile } from "node:child_process";
43328
43411
  import cluster from "node:cluster";
43329
43412
  import os2 from "node:os";
43330
43413
  function isSwaggerAssetPath(pathname) {
@@ -43386,7 +43469,7 @@ function reportOrmBootFailure(stage, err, dbConfig) {
43386
43469
  }
43387
43470
  async function autoMigrateOnStartup(migrationDir = "migrations", base = process.cwd()) {
43388
43471
  const dir = resolve19(base, migrationDir);
43389
- if (!existsSync26(dir)) return;
43472
+ if (!existsSync27(dir)) return;
43390
43473
  let hasSql = false;
43391
43474
  try {
43392
43475
  hasSql = readdirSync18(dir).some((f) => f.endsWith(".sql") && !f.endsWith(".down.sql"));
@@ -43476,17 +43559,8 @@ function killPort(port) {
43476
43559
  }
43477
43560
  }
43478
43561
  function findAvailablePort(start2) {
43479
- try {
43480
- execFileSync3(process.execPath, ["-e", `
43481
- const s = require("net").createServer();
43482
- s.listen(${start2}, "0.0.0.0", () => { s.close(); process.exit(0); });
43483
- s.on("error", () => process.exit(1));
43484
- `], { timeout: 1e3 });
43485
- return start2;
43486
- } catch {
43487
- killPort(start2);
43488
- return start2;
43489
- }
43562
+ if (probeBind("0.0.0.0", start2) === "held") killPort(start2);
43563
+ return start2;
43490
43564
  }
43491
43565
  function shouldOpenBrowser(isDevelopment, noBrowser = false) {
43492
43566
  if (!isDevelopment || isTruthy(process.env.TINA4_PRODUCTION) || cluster.isWorker) return false;
@@ -43548,12 +43622,12 @@ async function renderErrorPage(code, data, templatesDir) {
43548
43622
  }
43549
43623
  return instance;
43550
43624
  };
43551
- const userTemplatePath = join30(templatesDir, templateFile);
43552
- if (existsSync26(userTemplatePath)) {
43625
+ const userTemplatePath = join31(templatesDir, templateFile);
43626
+ if (existsSync27(userTemplatePath)) {
43553
43627
  return getCachedFrond(templatesDir).render(templateFile, data);
43554
43628
  }
43555
- const builtinTemplatePath = join30(BUILTIN_ERROR_TEMPLATES_DIR, templateFile);
43556
- if (existsSync26(builtinTemplatePath)) {
43629
+ const builtinTemplatePath = join31(BUILTIN_ERROR_TEMPLATES_DIR, templateFile);
43630
+ if (existsSync27(builtinTemplatePath)) {
43557
43631
  return getCachedFrond(BUILTIN_ERROR_TEMPLATES_DIR).render(templateFile, data);
43558
43632
  }
43559
43633
  return null;
@@ -43570,10 +43644,10 @@ function injectDevToolbar(html, ctx) {
43570
43644
  }
43571
43645
  function walkGalleryFiles(dir) {
43572
43646
  const results = [];
43573
- if (!existsSync26(dir)) return results;
43647
+ if (!existsSync27(dir)) return results;
43574
43648
  for (const f of readdirSync18(dir)) {
43575
- const full = join30(dir, f);
43576
- if (statSync18(full).isDirectory()) results.push(...walkGalleryFiles(full));
43649
+ const full = join31(dir, f);
43650
+ if (statSync19(full).isDirectory()) results.push(...walkGalleryFiles(full));
43577
43651
  else results.push(full);
43578
43652
  }
43579
43653
  return results;
@@ -43581,18 +43655,18 @@ function walkGalleryFiles(dir) {
43581
43655
  function getGalleryDeployedState() {
43582
43656
  const galleryDir = resolve19(__dirname, "..", "gallery");
43583
43657
  const state = {};
43584
- if (!existsSync26(galleryDir)) return state;
43658
+ if (!existsSync27(galleryDir)) return state;
43585
43659
  try {
43586
43660
  const entries = readdirSync18(galleryDir).sort();
43587
43661
  for (const entry of entries) {
43588
- const entryPath = join30(galleryDir, entry);
43589
- const metaFile = join30(entryPath, "meta.json");
43590
- if (statSync18(entryPath).isDirectory() && existsSync26(metaFile)) {
43591
- const srcDir = join30(entryPath, "src");
43592
- if (existsSync26(srcDir)) {
43662
+ const entryPath = join31(galleryDir, entry);
43663
+ const metaFile = join31(entryPath, "meta.json");
43664
+ if (statSync19(entryPath).isDirectory() && existsSync27(metaFile)) {
43665
+ const srcDir = join31(entryPath, "src");
43666
+ if (existsSync27(srcDir)) {
43593
43667
  const files = walkGalleryFiles(srcDir);
43594
43668
  const projectSrc = resolve19(process.cwd(), "src");
43595
- state[entry] = files.every((f) => existsSync26(join30(projectSrc, relative10(srcDir, f))));
43669
+ state[entry] = files.every((f) => existsSync27(join31(projectSrc, relative9(srcDir, f))));
43596
43670
  } else {
43597
43671
  state[entry] = false;
43598
43672
  }
@@ -43623,7 +43697,7 @@ function resolveTemplate(pathname, templatesDir) {
43623
43697
  if (cleanPath.includes("\\") || cleanPath.split("/").some((seg) => seg === "" || seg === "." || seg === "..")) return null;
43624
43698
  const pagesDir = resolve19(templatesDir, TEMPLATE_PAGES_DIR);
43625
43699
  for (const ext of [".twig", ".html"]) {
43626
- if (existsSync26(resolve19(pagesDir, cleanPath + ext))) {
43700
+ if (existsSync27(resolve19(pagesDir, cleanPath + ext))) {
43627
43701
  return `${TEMPLATE_PAGES_DIR}/${cleanPath}${ext}`;
43628
43702
  }
43629
43703
  }
@@ -43632,7 +43706,7 @@ function resolveTemplate(pathname, templatesDir) {
43632
43706
  if (!templateCache) {
43633
43707
  templateCache = /* @__PURE__ */ new Map();
43634
43708
  const pagesDir = resolve19(templatesDir, TEMPLATE_PAGES_DIR);
43635
- if (existsSync26(pagesDir)) {
43709
+ if (existsSync27(pagesDir)) {
43636
43710
  const scan = (dir, prefix) => {
43637
43711
  for (const entry of readdirSync18(dir, { withFileTypes: true })) {
43638
43712
  if (entry.name.startsWith("_")) continue;
@@ -44100,9 +44174,9 @@ function serveMethodNotAllowed(ctx) {
44100
44174
  }
44101
44175
  function serveStaticAsset(ctx) {
44102
44176
  const custom = process.env.TINA4_PUBLIC_DIR;
44103
- if (custom && existsSync26(custom) && tryServeStatic(custom, ctx.req, ctx.res)) return true;
44104
- if (existsSync26(ctx.staticDir) && tryServeStatic(ctx.staticDir, ctx.req, ctx.res)) return true;
44105
- if (existsSync26(ctx.srcPublicDir) && tryServeStatic(ctx.srcPublicDir, ctx.req, ctx.res)) return true;
44177
+ if (custom && existsSync27(custom) && tryServeStatic(custom, ctx.req, ctx.res)) return true;
44178
+ if (existsSync27(ctx.staticDir) && tryServeStatic(ctx.staticDir, ctx.req, ctx.res)) return true;
44179
+ if (existsSync27(ctx.srcPublicDir) && tryServeStatic(ctx.srcPublicDir, ctx.req, ctx.res)) return true;
44106
44180
  if (ctx.swaggerAssetsEnabled || !isSwaggerAssetPath(ctx.pathname)) {
44107
44181
  if (tryServeStatic(BUILTIN_PUBLIC_DIR, ctx.req, ctx.res)) return true;
44108
44182
  }
@@ -44316,6 +44390,9 @@ function startProductionCluster(port, host) {
44316
44390
  Debug: OFF (Log level: ${logLevel})
44317
44391
  ${reset2}`);
44318
44392
  }
44393
+ if (process.env.NODE_CLUSTER_SCHED_POLICY === void 0) {
44394
+ cluster.schedulingPolicy = cluster.SCHED_RR;
44395
+ }
44319
44396
  for (let i = 0; i < numCPUs; i++) cluster.fork();
44320
44397
  cluster.on("exit", (worker, code) => {
44321
44398
  if (code !== 0) {
@@ -44335,7 +44412,7 @@ ${reset2}`);
44335
44412
  function wireLocaleGlobal(frondEngine, base) {
44336
44413
  if (!frondEngine) return;
44337
44414
  const localeDir = resolve19(base, process.env.TINA4_LOCALE_DIR ?? "src/locales");
44338
- if (!existsSync26(localeDir)) return;
44415
+ if (!existsSync27(localeDir)) return;
44339
44416
  try {
44340
44417
  const localeFiles = readdirSync18(localeDir).filter((file) => file.endsWith(".json"));
44341
44418
  const FrondClass = frondEngine.constructor;
@@ -44408,7 +44485,7 @@ async function startServer(config) {
44408
44485
  middleware.use(requestLogger());
44409
44486
  middleware.use(rateLimiter());
44410
44487
  MiddlewareRunner.use(SecurityHeadersMiddleware);
44411
- if (existsSync26(routesDir)) {
44488
+ if (existsSync27(routesDir)) {
44412
44489
  const routes = await discoverRoutes(routesDir);
44413
44490
  for (const route of routes) {
44414
44491
  router.addRoute(route);
@@ -44671,8 +44748,8 @@ ${reset2}
44671
44748
  });
44672
44749
  }
44673
44750
  async function initializeOrm(config, router, base, ormDir, modelsDir) {
44674
- const hasOrmDir = existsSync26(ormDir);
44675
- const hasModelsDir = existsSync26(modelsDir);
44751
+ const hasOrmDir = existsSync27(ormDir);
44752
+ const hasModelsDir = existsSync27(modelsDir);
44676
44753
  if (hasOrmDir || hasModelsDir) {
44677
44754
  let ormStage = "import";
44678
44755
  const dbConfig = config?.database ?? {};
@@ -44735,7 +44812,7 @@ async function configureSwagger(router, ormDir, modelsDir) {
44735
44812
  let modelDefs = [];
44736
44813
  try {
44737
44814
  const orm = await Promise.resolve().then(() => (init_src(), src_exports));
44738
- const allModelDirs = [ormDir, modelsDir].filter((d) => existsSync26(d));
44815
+ const allModelDirs = [ormDir, modelsDir].filter((d) => existsSync27(d));
44739
44816
  const seenTables = /* @__PURE__ */ new Set();
44740
44817
  for (const dir of allModelDirs) {
44741
44818
  const discovered = await orm.discoverModels(dir);
@@ -44786,7 +44863,7 @@ var init_server = __esm({
44786
44863
  init_background();
44787
44864
  init_tcp();
44788
44865
  init_version();
44789
- __filename = fileURLToPath8(import.meta.url);
44866
+ __filename = fileURLToPath9(import.meta.url);
44790
44867
  __dirname = dirname15(__filename);
44791
44868
  BUILTIN_ERROR_TEMPLATES_DIR = resolve19(__dirname, "..", "templates");
44792
44869
  BUILTIN_PUBLIC_DIR = resolve19(__dirname, "..", "public");
@@ -45028,7 +45105,7 @@ var init_mqttMessage = __esm({
45028
45105
  import net3 from "node:net";
45029
45106
  import tls from "node:tls";
45030
45107
  import { randomBytes as randomBytes10 } from "node:crypto";
45031
- import { existsSync as existsSync27, readFileSync as readFileSync24 } from "node:fs";
45108
+ import { existsSync as existsSync28, readFileSync as readFileSync24 } from "node:fs";
45032
45109
  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;
45033
45110
  var init_mqtt = __esm({
45034
45111
  "src/mqtt.ts"() {
@@ -45231,7 +45308,7 @@ var init_mqtt = __esm({
45231
45308
  */
45232
45309
  async connect() {
45233
45310
  this.closeSocket();
45234
- if (this.secure && this.tlsVerify && this.caFile && !existsSync27(this.caFile)) {
45311
+ if (this.secure && this.tlsVerify && this.caFile && !existsSync28(this.caFile)) {
45235
45312
  throw new MqttError(
45236
45313
  `MQTT CA file not found: ${this.caFile} -- TINA4_MQTT_CA_FILE (or caFile) must point at the broker's CA certificate in PEM form`
45237
45314
  );
@@ -45713,9 +45790,9 @@ var init_mqtt = __esm({
45713
45790
  });
45714
45791
 
45715
45792
  // src/service.ts
45716
- import { readdirSync as readdirSync19, statSync as statSync19, watchFile, unwatchFile } from "node:fs";
45717
- import { join as join31, extname as extname8 } from "node:path";
45718
- import { pathToFileURL } from "node:url";
45793
+ import { readdirSync as readdirSync19, statSync as statSync20, watchFile, unwatchFile } from "node:fs";
45794
+ import { join as join32, extname as extname9 } from "node:path";
45795
+ import { pathToFileURL as pathToFileURL4 } from "node:url";
45719
45796
  function matchCronField(field, value) {
45720
45797
  if (field === "*") return true;
45721
45798
  if (field.includes("/")) {
@@ -45886,13 +45963,13 @@ var init_service = __esm({
45886
45963
  return discovered;
45887
45964
  }
45888
45965
  for (const entry of entries) {
45889
- const ext = extname8(entry);
45966
+ const ext = extname9(entry);
45890
45967
  if (ext !== ".ts" && ext !== ".js") continue;
45891
- const fullPath = join31(dir, entry);
45892
- const stat = statSync19(fullPath);
45968
+ const fullPath = join32(dir, entry);
45969
+ const stat = statSync20(fullPath);
45893
45970
  if (!stat.isFile()) continue;
45894
45971
  try {
45895
- const fileUrl = pathToFileURL(fullPath).href;
45972
+ const fileUrl = pathToFileURL4(fullPath).href;
45896
45973
  const mod = await import(fileUrl);
45897
45974
  const exp = mod.default ?? mod;
45898
45975
  if (exp.name && typeof exp.handler === "function") {
@@ -46013,13 +46090,13 @@ var init_service = __esm({
46013
46090
  return;
46014
46091
  }
46015
46092
  for (const entry of entries) {
46016
- const ext = extname8(entry);
46093
+ const ext = extname9(entry);
46017
46094
  if (ext !== ".ts" && ext !== ".js") continue;
46018
- const fullPath = join31(dir, entry);
46095
+ const fullPath = join32(dir, entry);
46019
46096
  if (watchedFiles.has(fullPath)) continue;
46020
46097
  watchedFiles.add(fullPath);
46021
46098
  watchFile(fullPath, { interval: 1e3 }, async () => {
46022
- const fileUrl = pathToFileURL(fullPath).href;
46099
+ const fileUrl = pathToFileURL4(fullPath).href;
46023
46100
  try {
46024
46101
  const mod = await import(fileUrl + "?t=" + Date.now());
46025
46102
  const exp = mod.default ?? mod;
@@ -46282,23 +46359,23 @@ function guessContentType(filename) {
46282
46359
  }
46283
46360
  function buildMultipartBody(boundary, fieldName, filename, fileContent, contentType, extraFields) {
46284
46361
  const crlf = "\r\n";
46285
- const delimiter2 = `--${boundary}`;
46362
+ const delimiter3 = `--${boundary}`;
46286
46363
  const parts = [];
46287
46364
  if (extraFields) {
46288
46365
  for (const [key, value] of Object.entries(extraFields)) {
46289
- parts.push(Buffer.from(delimiter2 + crlf, "utf-8"));
46366
+ parts.push(Buffer.from(delimiter3 + crlf, "utf-8"));
46290
46367
  parts.push(Buffer.from(`Content-Disposition: form-data; name="${key}"` + crlf + crlf, "utf-8"));
46291
46368
  parts.push(Buffer.from(String(value) + crlf, "utf-8"));
46292
46369
  }
46293
46370
  }
46294
- parts.push(Buffer.from(delimiter2 + crlf, "utf-8"));
46371
+ parts.push(Buffer.from(delimiter3 + crlf, "utf-8"));
46295
46372
  parts.push(
46296
46373
  Buffer.from(`Content-Disposition: form-data; name="${fieldName}"; filename="${filename}"` + crlf, "utf-8")
46297
46374
  );
46298
46375
  parts.push(Buffer.from(`Content-Type: ${contentType}` + crlf + crlf, "utf-8"));
46299
46376
  parts.push(fileContent);
46300
46377
  parts.push(Buffer.from(crlf, "utf-8"));
46301
- parts.push(Buffer.from(delimiter2 + "--" + crlf, "utf-8"));
46378
+ parts.push(Buffer.from(delimiter3 + "--" + crlf, "utf-8"));
46302
46379
  return Buffer.concat(parts);
46303
46380
  }
46304
46381
  async function* parseLineStream(chunks) {
@@ -46545,8 +46622,8 @@ var init_api = __esm({
46545
46622
  /**
46546
46623
  * HTTP GET request.
46547
46624
  */
46548
- async get(path10, params) {
46549
- let url = this.buildUrl(path10);
46625
+ async get(path9, params) {
46626
+ let url = this.buildUrl(path9);
46550
46627
  if (params && Object.keys(params).length > 0) {
46551
46628
  const qs = new URLSearchParams(params).toString();
46552
46629
  url += (url.includes("?") ? "&" : "?") + qs;
@@ -46556,32 +46633,32 @@ var init_api = __esm({
46556
46633
  /**
46557
46634
  * HTTP POST request.
46558
46635
  */
46559
- async post(path10, body, contentType = "application/json") {
46560
- return this.sendRequest("POST", path10, body, contentType);
46636
+ async post(path9, body, contentType = "application/json") {
46637
+ return this.sendRequest("POST", path9, body, contentType);
46561
46638
  }
46562
46639
  /**
46563
46640
  * HTTP PUT request.
46564
46641
  */
46565
- async put(path10, body, contentType = "application/json") {
46566
- return this.sendRequest("PUT", path10, body, contentType);
46642
+ async put(path9, body, contentType = "application/json") {
46643
+ return this.sendRequest("PUT", path9, body, contentType);
46567
46644
  }
46568
46645
  /**
46569
46646
  * HTTP PATCH request.
46570
46647
  */
46571
- async patch(path10, body, contentType = "application/json") {
46572
- return this.sendRequest("PATCH", path10, body, contentType);
46648
+ async patch(path9, body, contentType = "application/json") {
46649
+ return this.sendRequest("PATCH", path9, body, contentType);
46573
46650
  }
46574
46651
  /**
46575
46652
  * HTTP DELETE request.
46576
46653
  */
46577
- async delete(path10, body) {
46578
- return this.sendRequest("DELETE", path10, body);
46654
+ async delete(path9, body) {
46655
+ return this.sendRequest("DELETE", path9, body);
46579
46656
  }
46580
46657
  /**
46581
46658
  * Generic request method — public entry point for any HTTP method.
46582
46659
  */
46583
- async sendRequest(method, path10, body, contentType = "application/json") {
46584
- const url = this.buildUrl(path10);
46660
+ async sendRequest(method, path9, body, contentType = "application/json") {
46661
+ const url = this.buildUrl(path9);
46585
46662
  return this.execute(method.toUpperCase(), url, body, contentType);
46586
46663
  }
46587
46664
  /**
@@ -46605,7 +46682,7 @@ var init_api = __esm({
46605
46682
  * await api.upload("/avatars", { fileBytes: raw, filename: "me.png",
46606
46683
  * extraFields: { user_id: "42" } });
46607
46684
  */
46608
- async upload(path10, opts = {}) {
46685
+ async upload(path9, opts = {}) {
46609
46686
  const { filePath, fieldName = "file", extraFields, headers, fileBytes, filename } = opts;
46610
46687
  let content;
46611
46688
  let uploadName;
@@ -46640,7 +46717,7 @@ var init_api = __esm({
46640
46717
  const boundary = "----Tina4Boundary" + randomBytes11(16).toString("hex");
46641
46718
  const bodyBuffer = buildMultipartBody(boundary, fieldName, uploadName, content, partContentType, extraFields);
46642
46719
  const contentType = `multipart/form-data; boundary=${boundary}`;
46643
- return this.execute("POST", this.buildUrl(path10), bodyBuffer, contentType, headers);
46720
+ return this.execute("POST", this.buildUrl(path9), bodyBuffer, contentType, headers);
46644
46721
  }
46645
46722
  /**
46646
46723
  * Stream a GET response body to `destPath` in chunks.
@@ -46655,11 +46732,11 @@ var init_api = __esm({
46655
46732
  * dest, HTTP error status, or a transport failure); the destination file is
46656
46733
  * not written on error.
46657
46734
  */
46658
- async download(path10, destPath, params) {
46735
+ async download(path9, destPath, params) {
46659
46736
  if (!destPath) {
46660
46737
  return { http_code: null, headers: {}, error: "download requires destPath", path: null };
46661
46738
  }
46662
- let url = this.buildUrl(path10);
46739
+ let url = this.buildUrl(path9);
46663
46740
  if (params && Object.keys(params).length > 0) {
46664
46741
  const qs = new URLSearchParams(params).toString();
46665
46742
  url += (url.includes("?") ? "&" : "?") + qs;
@@ -46743,8 +46820,8 @@ var init_api = __esm({
46743
46820
  * bounds just the connect + headers phase (default
46744
46821
  * `TINA4_API_CONNECT_TIMEOUT` or 10s).
46745
46822
  */
46746
- async *streamBytes(path10, opts = {}) {
46747
- const url = this.buildUrl(path10);
46823
+ async *streamBytes(path9, opts = {}) {
46824
+ const url = this.buildUrl(path9);
46748
46825
  const method = (opts.method ?? "GET").toUpperCase();
46749
46826
  const contentType = opts.contentType ?? "application/json";
46750
46827
  const { headers, data } = this.buildRequest(method, contentType, opts.body, opts.headers, url);
@@ -46779,8 +46856,8 @@ var init_api = __esm({
46779
46856
  * yields a trailing line without a terminator on EOF. Built on
46780
46857
  * {@link streamBytes} plus the shared {@link parseLineStream}.
46781
46858
  */
46782
- async *streamLines(path10, opts = {}) {
46783
- yield* parseLineStream(this.streamBytes(path10, opts));
46859
+ async *streamLines(path9, opts = {}) {
46860
+ yield* parseLineStream(this.streamBytes(path9, opts));
46784
46861
  }
46785
46862
  /**
46786
46863
  * Stream the response as SSE (Server-Sent Events). Yields one
@@ -46789,8 +46866,8 @@ var init_api = __esm({
46789
46866
  * with `data === "[DONE]"` and the iterator ends on the next EOF.
46790
46867
  * Built on {@link streamLines} plus the shared {@link parseSseStream}.
46791
46868
  */
46792
- async *streamSse(path10, opts = {}) {
46793
- yield* parseSseStream(this.streamLines(path10, opts));
46869
+ async *streamSse(path9, opts = {}) {
46870
+ yield* parseSseStream(this.streamLines(path9, opts));
46794
46871
  }
46795
46872
  // ── Internal helpers ──────────────────────────────────────────────
46796
46873
  /**
@@ -46856,14 +46933,14 @@ var init_api = __esm({
46856
46933
  req2.end();
46857
46934
  });
46858
46935
  }
46859
- buildUrl(path10) {
46860
- if (path10.startsWith("http://") || path10.startsWith("https://")) {
46861
- return path10;
46936
+ buildUrl(path9) {
46937
+ if (path9.startsWith("http://") || path9.startsWith("https://")) {
46938
+ return path9;
46862
46939
  }
46863
- if (!path10) {
46940
+ if (!path9) {
46864
46941
  return this.baseUrl;
46865
46942
  }
46866
- return `${this.baseUrl}/${path10.replace(/^\/+/, "")}`;
46943
+ return `${this.baseUrl}/${path9.replace(/^\/+/, "")}`;
46867
46944
  }
46868
46945
  /**
46869
46946
  * The headers configured on the client, as they may go to `targetUrl`.
@@ -48803,15 +48880,15 @@ var init_htmlElement = __esm({
48803
48880
  });
48804
48881
 
48805
48882
  // src/ai.ts
48806
- import { existsSync as existsSync28, mkdirSync as mkdirSync21, writeFileSync as writeFileSync18, readFileSync as readFileSync26 } from "node:fs";
48883
+ import { existsSync as existsSync29, mkdirSync as mkdirSync21, writeFileSync as writeFileSync18, readFileSync as readFileSync26 } from "node:fs";
48807
48884
  import { homedir } from "node:os";
48808
- import { join as join32, resolve as resolve20, relative as relative11, dirname as dirname16 } from "node:path";
48809
- import { fileURLToPath as fileURLToPath9 } from "node:url";
48810
- import { execSync, execFileSync as execFileSync4 } from "node:child_process";
48885
+ import { join as join33, resolve as resolve20, relative as relative10, dirname as dirname16 } from "node:path";
48886
+ import { fileURLToPath as fileURLToPath10 } from "node:url";
48887
+ import { execSync, execFileSync as execFileSync3 } from "node:child_process";
48811
48888
  import { createInterface } from "node:readline";
48812
48889
  function readVersion() {
48813
48890
  try {
48814
- const thisDir = dirname16(fileURLToPath9(import.meta.url));
48891
+ const thisDir = dirname16(fileURLToPath10(import.meta.url));
48815
48892
  const rootPkg = resolve20(thisDir, "..", "..", "..", "package.json");
48816
48893
  const pkg = JSON.parse(readFileSync26(rootPkg, "utf-8"));
48817
48894
  return pkg.version ?? "0.0.0";
@@ -48863,7 +48940,7 @@ function downloadSkillsSync(jobs) {
48863
48940
  })();
48864
48941
  `;
48865
48942
  try {
48866
- const out = execFileSync4(process.execPath, ["-e", child, JSON.stringify(jobs)], {
48943
+ const out = execFileSync3(process.execPath, ["-e", child, JSON.stringify(jobs)], {
48867
48944
  encoding: "utf-8",
48868
48945
  timeout: 5e4,
48869
48946
  maxBuffer: 8 * 1024 * 1024
@@ -48876,8 +48953,8 @@ function downloadSkillsSync(jobs) {
48876
48953
  function installSkills(root = ".", targets) {
48877
48954
  const ref = skillsRef();
48878
48955
  const dests = targets ?? [
48879
- join32(resolve20(root), ".claude", "skills"),
48880
- join32(homedir(), ".claude", "skills")
48956
+ join33(resolve20(root), ".claude", "skills"),
48957
+ join33(homedir(), ".claude", "skills")
48881
48958
  ];
48882
48959
  const jobs = [];
48883
48960
  const index = /* @__PURE__ */ new Map();
@@ -48895,9 +48972,9 @@ function installSkills(root = ".", targets) {
48895
48972
  const base = `https://raw.githubusercontent.com/tina4stack/${spec.repo}/${ref}/.claude/skills/${skill}`;
48896
48973
  skillMdUrl[skill] = `${base}/SKILL.md`;
48897
48974
  for (const dest of dests) {
48898
- add(`${base}/SKILL.md`, join32(dest, skill, "SKILL.md"));
48975
+ add(`${base}/SKILL.md`, join33(dest, skill, "SKILL.md"));
48899
48976
  for (const r of spec.references) {
48900
- add(`${base}/references/${r}`, join32(dest, skill, "references", r));
48977
+ add(`${base}/references/${r}`, join33(dest, skill, "references", r));
48901
48978
  }
48902
48979
  }
48903
48980
  }
@@ -48909,7 +48986,7 @@ function installSkills(root = ".", targets) {
48909
48986
  return installed;
48910
48987
  }
48911
48988
  function isInstalled(root, tool) {
48912
- return existsSync28(join32(resolve20(root), tool.contextFile));
48989
+ return existsSync29(join33(resolve20(root), tool.contextFile));
48913
48990
  }
48914
48991
  function showMenu(root = ".") {
48915
48992
  const r = resolve20(root);
@@ -49032,7 +49109,7 @@ function looksLikeOldFrameworkInstall(existing) {
49032
49109
  function writeOrMerge(contextPath, contextFile, frameworkGuide) {
49033
49110
  const block = skillBlock(contextFile);
49034
49111
  const [start2, end] = markersFor(contextFile);
49035
- if (!existsSync28(contextPath)) {
49112
+ if (!existsSync29(contextPath)) {
49036
49113
  writeFileSync18(contextPath, frameworkGuide.replace(/\s+$/, "") + "\n\n" + block + "\n", "utf-8");
49037
49114
  return "Installed";
49038
49115
  }
@@ -49053,14 +49130,14 @@ function writeOrMerge(contextPath, contextFile, frameworkGuide) {
49053
49130
  }
49054
49131
  function installForTool(root, tool, context) {
49055
49132
  const created = [];
49056
- const contextPath = join32(root, tool.contextFile);
49133
+ const contextPath = join33(root, tool.contextFile);
49057
49134
  if (tool.configDir) {
49058
- mkdirSync21(join32(root, tool.configDir), { recursive: true });
49135
+ mkdirSync21(join33(root, tool.configDir), { recursive: true });
49059
49136
  }
49060
49137
  const parentDir = dirname16(contextPath);
49061
49138
  mkdirSync21(parentDir, { recursive: true });
49062
49139
  const action = writeOrMerge(contextPath, tool.contextFile, context);
49063
- const rel = relative11(root, contextPath);
49140
+ const rel = relative10(root, contextPath);
49064
49141
  created.push(rel);
49065
49142
  console.log(` ${GREEN2}\u2713${RESET2} ${action} ${rel}`);
49066
49143
  if (tool.name === "claude-code") {
@@ -49093,7 +49170,7 @@ function installTina4Ai() {
49093
49170
  function installClaudeSkills(root) {
49094
49171
  const created = [];
49095
49172
  for (const skill of installSkills(root)) {
49096
- created.push(join32(".claude", "skills", skill));
49173
+ created.push(join33(".claude", "skills", skill));
49097
49174
  console.log(` ${GREEN2}\u2713${RESET2} Installed .claude/skills/${skill} (project + global)`);
49098
49175
  }
49099
49176
  return created;
@@ -49434,10 +49511,10 @@ import { tests, assertEqual, runAll } from "tina4-nodejs";
49434
49511
  }
49435
49512
  function generateClaudeCodeContext() {
49436
49513
  try {
49437
- const thisDir = dirname16(fileURLToPath9(import.meta.url));
49514
+ const thisDir = dirname16(fileURLToPath10(import.meta.url));
49438
49515
  const repoRoot = resolve20(thisDir, "..", "..", "..");
49439
- const claudeMdPath = join32(repoRoot, "CLAUDE.md");
49440
- if (existsSync28(claudeMdPath)) {
49516
+ const claudeMdPath = join33(repoRoot, "CLAUDE.md");
49517
+ if (existsSync29(claudeMdPath)) {
49441
49518
  return readFileSync26(claudeMdPath, "utf-8");
49442
49519
  }
49443
49520
  } catch {
@@ -50098,10 +50175,10 @@ var init_aiClient = __esm({
50098
50175
  throw new AiConfigError("AI URL must be an http or https URL");
50099
50176
  }
50100
50177
  if (url.protocol !== "http:" && url.protocol !== "https:") throw new AiConfigError("AI URL must be an http or https URL");
50101
- const path10 = rtrimSlashes(url.pathname);
50102
- if (path10 === "" || path10 === "/v1" || path10 === "/api" || path10 === "/v1beta/openai") {
50178
+ const path9 = rtrimSlashes(url.pathname);
50179
+ if (path9 === "" || path9 === "/v1" || path9 === "/api" || path9 === "/v1beta/openai") {
50103
50180
  const suffix = provider === "anthropic" ? "/messages" : capability === "embed" ? "/embeddings" : "/chat/completions";
50104
- url.pathname = (path10 || "/v1") + suffix;
50181
+ url.pathname = (path9 || "/v1") + suffix;
50105
50182
  }
50106
50183
  return url.toString();
50107
50184
  }
@@ -50617,7 +50694,7 @@ var init_aiClient = __esm({
50617
50694
  });
50618
50695
 
50619
50696
  // src/queueBackends/rabbitmqBackend.ts
50620
- import { execFileSync as execFileSync5 } from "node:child_process";
50697
+ import { execFileSync as execFileSync4 } from "node:child_process";
50621
50698
  import { randomUUID as randomUUID9 } from "node:crypto";
50622
50699
  function parseAmqpUrl(url) {
50623
50700
  const config = {};
@@ -51038,7 +51115,7 @@ var init_rabbitmqBackend = __esm({
51038
51115
  setTimeout(() => { sock.destroy(); process.exit(1); }, 10000).unref();
51039
51116
  `;
51040
51117
  try {
51041
- const result = execFileSync5(process.execPath, ["-e", script], {
51118
+ const result = execFileSync4(process.execPath, ["-e", script], {
51042
51119
  encoding: "utf-8",
51043
51120
  timeout: 15e3,
51044
51121
  stdio: ["pipe", "pipe", "pipe"]
@@ -51414,27 +51491,27 @@ var init_testClient = __esm({
51414
51491
  return this.ctxPromise;
51415
51492
  }
51416
51493
  /** Send a GET request. */
51417
- async get(path10, options) {
51418
- return this._request("GET", path10, options);
51494
+ async get(path9, options) {
51495
+ return this._request("GET", path9, options);
51419
51496
  }
51420
51497
  /** Send a POST request. */
51421
- async post(path10, options) {
51422
- return this._request("POST", path10, options);
51498
+ async post(path9, options) {
51499
+ return this._request("POST", path9, options);
51423
51500
  }
51424
51501
  /** Send a PUT request. */
51425
- async put(path10, options) {
51426
- return this._request("PUT", path10, options);
51502
+ async put(path9, options) {
51503
+ return this._request("PUT", path9, options);
51427
51504
  }
51428
51505
  /** Send a PATCH request. */
51429
- async patch(path10, options) {
51430
- return this._request("PATCH", path10, options);
51506
+ async patch(path9, options) {
51507
+ return this._request("PATCH", path9, options);
51431
51508
  }
51432
51509
  /** Send a DELETE request. */
51433
- async delete(path10, options) {
51434
- return this._request("DELETE", path10, options);
51510
+ async delete(path9, options) {
51511
+ return this._request("DELETE", path9, options);
51435
51512
  }
51436
51513
  /** Build a mock request/response pair and dispatch it through the REAL pipeline (runDispatch). */
51437
- async _request(method, path10, options) {
51514
+ async _request(method, path9, options) {
51438
51515
  const { json, body, headers } = options ?? {};
51439
51516
  let rawBody = "";
51440
51517
  let contentType = "";
@@ -51460,7 +51537,7 @@ var init_testClient = __esm({
51460
51537
  Object.defineProperty(socket, "remoteAddress", { value: "127.0.0.1" });
51461
51538
  const rawReq = new IncomingMessage2(socket);
51462
51539
  rawReq.method = method.toUpperCase();
51463
- rawReq.url = path10;
51540
+ rawReq.url = path9;
51464
51541
  rawReq.headers = { ...reqHeaders, host: "localhost:7148" };
51465
51542
  if (rawBody) {
51466
51543
  rawReq.push(Buffer.from(rawBody));
@@ -51531,20 +51608,20 @@ var init_test = __esm({
51531
51608
  if (this._client === null) this._client = new TestClient();
51532
51609
  return this._client;
51533
51610
  }
51534
- async get(path10, options) {
51535
- return this.client.get(path10, options);
51611
+ async get(path9, options) {
51612
+ return this.client.get(path9, options);
51536
51613
  }
51537
- async post(path10, options) {
51538
- return this.client.post(path10, options);
51614
+ async post(path9, options) {
51615
+ return this.client.post(path9, options);
51539
51616
  }
51540
- async put(path10, options) {
51541
- return this.client.put(path10, options);
51617
+ async put(path9, options) {
51618
+ return this.client.put(path9, options);
51542
51619
  }
51543
- async patch(path10, options) {
51544
- return this.client.patch(path10, options);
51620
+ async patch(path9, options) {
51621
+ return this.client.patch(path9, options);
51545
51622
  }
51546
- async delete(path10, options) {
51547
- return this.client.delete(path10, options);
51623
+ async delete(path9, options) {
51624
+ return this.client.delete(path9, options);
51548
51625
  }
51549
51626
  // ── Positional assertions — (actual, expected, message) shape ────────
51550
51627
  assertEqual(actual, expected, message) {