@floless/app 0.119.0 → 0.120.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -294,41 +294,41 @@ var require_queue = __commonJS({
294
294
  queue2.drained = drained;
295
295
  return queue2;
296
296
  function push(value) {
297
- var p = new Promise(function(resolve11, reject) {
297
+ var p = new Promise(function(resolve12, reject) {
298
298
  pushCb(value, function(err2, result) {
299
299
  if (err2) {
300
300
  reject(err2);
301
301
  return;
302
302
  }
303
- resolve11(result);
303
+ resolve12(result);
304
304
  });
305
305
  });
306
306
  p.catch(noop);
307
307
  return p;
308
308
  }
309
309
  function unshift(value) {
310
- var p = new Promise(function(resolve11, reject) {
310
+ var p = new Promise(function(resolve12, reject) {
311
311
  unshiftCb(value, function(err2, result) {
312
312
  if (err2) {
313
313
  reject(err2);
314
314
  return;
315
315
  }
316
- resolve11(result);
316
+ resolve12(result);
317
317
  });
318
318
  });
319
319
  p.catch(noop);
320
320
  return p;
321
321
  }
322
322
  function drained() {
323
- var p = new Promise(function(resolve11) {
323
+ var p = new Promise(function(resolve12) {
324
324
  process.nextTick(function() {
325
325
  if (queue2.idle()) {
326
- resolve11();
326
+ resolve12();
327
327
  } else {
328
328
  var previousDrain = queue2.drain;
329
329
  queue2.drain = function() {
330
330
  if (typeof previousDrain === "function") previousDrain();
331
- resolve11();
331
+ resolve12();
332
332
  queue2.drain = previousDrain;
333
333
  };
334
334
  }
@@ -671,8 +671,8 @@ var require_create_promise = __commonJS({
671
671
  reject: null,
672
672
  promise: null
673
673
  };
674
- obj2.promise = new Promise((resolve11, reject) => {
675
- obj2.resolve = resolve11;
674
+ obj2.promise = new Promise((resolve12, reject) => {
675
+ obj2.resolve = resolve12;
676
676
  obj2.reject = reject;
677
677
  });
678
678
  return obj2;
@@ -941,11 +941,11 @@ var require_thenify = __commonJS({
941
941
  return;
942
942
  }
943
943
  debug("thenify");
944
- return (resolve11, reject) => {
944
+ return (resolve12, reject) => {
945
945
  const p = this._loadRegistered();
946
946
  return p.then(() => {
947
947
  this[kThenifyDoNotWrap] = true;
948
- return resolve11(this._server);
948
+ return resolve12(this._server);
949
949
  }, reject);
950
950
  };
951
951
  }
@@ -1082,12 +1082,12 @@ var require_boot = __commonJS({
1082
1082
  inherits(Boot, EE);
1083
1083
  if ("asyncDispose" in Symbol) {
1084
1084
  Boot.prototype[Symbol.asyncDispose] = function() {
1085
- return new Promise((resolve11, reject) => {
1085
+ return new Promise((resolve12, reject) => {
1086
1086
  this.close((err2) => {
1087
1087
  if (err2) {
1088
1088
  return reject(err2);
1089
1089
  }
1090
- resolve11();
1090
+ resolve12();
1091
1091
  });
1092
1092
  });
1093
1093
  };
@@ -1234,12 +1234,12 @@ var require_boot = __commonJS({
1234
1234
  throw new AVV_ERR_CALLBACK_NOT_FN("close", typeof func);
1235
1235
  }
1236
1236
  } else {
1237
- promise = new Promise(function(resolve11, reject) {
1237
+ promise = new Promise(function(resolve12, reject) {
1238
1238
  func = function(err2) {
1239
1239
  if (err2) {
1240
1240
  return reject(err2);
1241
1241
  }
1242
- resolve11();
1242
+ resolve12();
1243
1243
  };
1244
1244
  });
1245
1245
  }
@@ -1259,7 +1259,7 @@ var require_boot = __commonJS({
1259
1259
  queueMicrotask(this.start.bind(this));
1260
1260
  return;
1261
1261
  }
1262
- return new Promise((resolve11, reject) => {
1262
+ return new Promise((resolve12, reject) => {
1263
1263
  this._readyQ.push(readyPromiseCB);
1264
1264
  this.start();
1265
1265
  const relativeContext = this._current[0].server;
@@ -1267,7 +1267,7 @@ var require_boot = __commonJS({
1267
1267
  if (err2) {
1268
1268
  reject(err2);
1269
1269
  } else {
1270
- resolve11(relativeContext);
1270
+ resolve12(relativeContext);
1271
1271
  }
1272
1272
  process.nextTick(done);
1273
1273
  }
@@ -2542,8 +2542,8 @@ var require_promise = __commonJS({
2542
2542
  var { kTestInternals } = require_symbols2();
2543
2543
  function withResolvers() {
2544
2544
  let res, rej;
2545
- const promise = new Promise((resolve11, reject) => {
2546
- res = resolve11;
2545
+ const promise = new Promise((resolve12, reject) => {
2546
+ res = resolve12;
2547
2547
  rej = reject;
2548
2548
  });
2549
2549
  return { promise, resolve: res, reject: rej };
@@ -2642,15 +2642,15 @@ var require_server = __commonJS({
2642
2642
  if (cb === void 0) {
2643
2643
  const listening = listenPromise.call(this, server, listenOptions);
2644
2644
  return listening.then((address) => {
2645
- const { promise, resolve: resolve11 } = PonyPromise.withResolvers();
2645
+ const { promise, resolve: resolve12 } = PonyPromise.withResolvers();
2646
2646
  if (host === "localhost") {
2647
2647
  multipleBindings.call(this, server, httpHandler, options, listenOptions, () => {
2648
2648
  this[kState].listening = true;
2649
- resolve11(address);
2649
+ resolve12(address);
2650
2650
  onListenHookRunner(this);
2651
2651
  });
2652
2652
  } else {
2653
- resolve11(address);
2653
+ resolve12(address);
2654
2654
  onListenHookRunner(this);
2655
2655
  }
2656
2656
  return promise;
@@ -2777,7 +2777,7 @@ var require_server = __commonJS({
2777
2777
  }
2778
2778
  return this.ready().then(() => {
2779
2779
  if (this[kState].aborted) return;
2780
- const { promise, resolve: resolve11, reject } = PonyPromise.withResolvers();
2780
+ const { promise, resolve: resolve12, reject } = PonyPromise.withResolvers();
2781
2781
  const errEventHandler = (err2) => {
2782
2782
  cleanup();
2783
2783
  this[kState].listening = false;
@@ -2786,7 +2786,7 @@ var require_server = __commonJS({
2786
2786
  const listeningEventHandler = () => {
2787
2787
  cleanup();
2788
2788
  this[kState].listening = true;
2789
- resolve11(logServerAddress.call(
2789
+ resolve12(logServerAddress.call(
2790
2790
  this,
2791
2791
  server,
2792
2792
  listenOptions.listenTextResolver || defaultResolveServerListeningText
@@ -4085,7 +4085,7 @@ var require_redact = __commonJS({
4085
4085
  }
4086
4086
  }
4087
4087
  }
4088
- function redactWildcardPath(obj2, parts, censor, originalPath, remove = false) {
4088
+ function redactWildcardPath(obj2, parts, censor, originalPath2, remove = false) {
4089
4089
  const wildcardIndex = parts.indexOf("*");
4090
4090
  if (wildcardIndex === parts.length - 1) {
4091
4091
  const parentParts = parts.slice(0, -1);
@@ -4127,10 +4127,10 @@ var require_redact = __commonJS({
4127
4127
  }
4128
4128
  }
4129
4129
  } else {
4130
- redactIntermediateWildcard(obj2, parts, censor, wildcardIndex, originalPath, remove);
4130
+ redactIntermediateWildcard(obj2, parts, censor, wildcardIndex, originalPath2, remove);
4131
4131
  }
4132
4132
  }
4133
- function redactIntermediateWildcard(obj2, parts, censor, wildcardIndex, originalPath, remove = false) {
4133
+ function redactIntermediateWildcard(obj2, parts, censor, wildcardIndex, originalPath2, remove = false) {
4134
4134
  const beforeWildcard = parts.slice(0, wildcardIndex);
4135
4135
  const afterWildcard = parts.slice(wildcardIndex + 1);
4136
4136
  const pathArray = [];
@@ -4159,7 +4159,7 @@ var require_redact = __commonJS({
4159
4159
  const fullPath = [...pathArray.slice(0, pathLength), ...path];
4160
4160
  return censor(value, fullPath);
4161
4161
  } : censor;
4162
- redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
4162
+ redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath2, remove);
4163
4163
  } else {
4164
4164
  if (remove) {
4165
4165
  removeKey(current, afterWildcard);
@@ -5489,7 +5489,7 @@ var require_thread_stream = __commonJS({
5489
5489
  var { version } = require_package();
5490
5490
  var { EventEmitter: EventEmitter2 } = require("events");
5491
5491
  var { Worker: Worker2 } = require("worker_threads");
5492
- var { join: join46 } = require("path");
5492
+ var { join: join48 } = require("path");
5493
5493
  var { pathToFileURL } = require("url");
5494
5494
  var { wait } = require_wait();
5495
5495
  var {
@@ -5540,7 +5540,7 @@ var require_thread_stream = __commonJS({
5540
5540
  function createWorker(stream, opts) {
5541
5541
  const { filename, workerData } = opts;
5542
5542
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
5543
- const toExecute = bundlerOverrides["thread-stream-worker"] || join46(__dirname, "lib", "worker.js");
5543
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join48(__dirname, "lib", "worker.js");
5544
5544
  const worker = new Worker2(toExecute, {
5545
5545
  ...opts.workerOpts,
5546
5546
  name: opts.workerOpts?.name || "thread-stream",
@@ -6006,9 +6006,9 @@ var require_transport = __commonJS({
6006
6006
  "node_modules/pino/lib/transport.js"(exports2, module2) {
6007
6007
  "use strict";
6008
6008
  var { createRequire: createRequire5 } = require("module");
6009
- var { existsSync: existsSync41 } = require("node:fs");
6009
+ var { existsSync: existsSync42 } = require("node:fs");
6010
6010
  var getCallers = require_caller();
6011
- var { join: join46, isAbsolute: isAbsolute3, sep: sep6 } = require("node:path");
6011
+ var { join: join48, isAbsolute: isAbsolute3, sep: sep7 } = require("node:path");
6012
6012
  var { fileURLToPath: fileURLToPath6 } = require("node:url");
6013
6013
  var sleep2 = require_atomic_sleep();
6014
6014
  var onExit = require_on_exit_leak_free();
@@ -6080,7 +6080,7 @@ var require_transport = __commonJS({
6080
6080
  return false;
6081
6081
  }
6082
6082
  }
6083
- return isAbsolute3(path) && !existsSync41(path);
6083
+ return isAbsolute3(path) && !existsSync42(path);
6084
6084
  }
6085
6085
  function stripQuotes(value) {
6086
6086
  const first = value[0];
@@ -6150,7 +6150,7 @@ var require_transport = __commonJS({
6150
6150
  stream.flushSync();
6151
6151
  }
6152
6152
  function transport(fullOptions) {
6153
- const { pipeline: pipeline2, targets, levels, dedupe, worker = {}, caller = getCallers(), sync = false } = fullOptions;
6153
+ const { pipeline: pipeline3, targets, levels, dedupe, worker = {}, caller = getCallers(), sync = false } = fullOptions;
6154
6154
  const options = {
6155
6155
  ...fullOptions.options
6156
6156
  };
@@ -6161,7 +6161,7 @@ var require_transport = __commonJS({
6161
6161
  throw new Error("only one of target or targets can be specified");
6162
6162
  }
6163
6163
  if (targets) {
6164
- target = bundlerOverrides["pino-worker"] || join46(__dirname, "worker.js");
6164
+ target = bundlerOverrides["pino-worker"] || join48(__dirname, "worker.js");
6165
6165
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
6166
6166
  return {
6167
6167
  ...dest,
@@ -6178,9 +6178,9 @@ var require_transport = __commonJS({
6178
6178
  };
6179
6179
  });
6180
6180
  });
6181
- } else if (pipeline2) {
6182
- target = bundlerOverrides["pino-worker"] || join46(__dirname, "worker.js");
6183
- options.pipelines = [pipeline2.map((dest) => {
6181
+ } else if (pipeline3) {
6182
+ target = bundlerOverrides["pino-worker"] || join48(__dirname, "worker.js");
6183
+ options.pipelines = [pipeline3.map((dest) => {
6184
6184
  return {
6185
6185
  ...dest,
6186
6186
  target: fixTarget(dest.target)
@@ -6194,7 +6194,7 @@ var require_transport = __commonJS({
6194
6194
  options.dedupe = dedupe;
6195
6195
  }
6196
6196
  options.pinoWillSendConfig = true;
6197
- const name = targets || pipeline2 ? "pino.transport" : target;
6197
+ const name = targets || pipeline3 ? "pino.transport" : target;
6198
6198
  return buildStream(fixTarget(target), options, worker, sync, name);
6199
6199
  function fixTarget(origin) {
6200
6200
  origin = bundlerOverrides[origin] || origin;
@@ -6202,12 +6202,12 @@ var require_transport = __commonJS({
6202
6202
  return origin;
6203
6203
  }
6204
6204
  if (origin === "pino/file") {
6205
- return join46(__dirname, "..", "file.js");
6205
+ return join48(__dirname, "..", "file.js");
6206
6206
  }
6207
6207
  let fixTarget2;
6208
6208
  for (const filePath of callers) {
6209
6209
  try {
6210
- const context = filePath === "node:repl" ? process.cwd() + sep6 : filePath;
6210
+ const context = filePath === "node:repl" ? process.cwd() + sep7 : filePath;
6211
6211
  fixTarget2 = createRequire5(context).resolve(origin);
6212
6212
  break;
6213
6213
  } catch (err2) {
@@ -7182,7 +7182,7 @@ var require_safe_stable_stringify = __commonJS({
7182
7182
  return circularValue;
7183
7183
  }
7184
7184
  let res = "";
7185
- let join46 = ",";
7185
+ let join48 = ",";
7186
7186
  const originalIndentation = indentation;
7187
7187
  if (Array.isArray(value)) {
7188
7188
  if (value.length === 0) {
@@ -7196,7 +7196,7 @@ var require_safe_stable_stringify = __commonJS({
7196
7196
  indentation += spacer;
7197
7197
  res += `
7198
7198
  ${indentation}`;
7199
- join46 = `,
7199
+ join48 = `,
7200
7200
  ${indentation}`;
7201
7201
  }
7202
7202
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -7204,13 +7204,13 @@ ${indentation}`;
7204
7204
  for (; i < maximumValuesToStringify - 1; i++) {
7205
7205
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
7206
7206
  res += tmp2 !== void 0 ? tmp2 : "null";
7207
- res += join46;
7207
+ res += join48;
7208
7208
  }
7209
7209
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
7210
7210
  res += tmp !== void 0 ? tmp : "null";
7211
7211
  if (value.length - 1 > maximumBreadth) {
7212
7212
  const removedKeys = value.length - maximumBreadth - 1;
7213
- res += `${join46}"... ${getItemCount(removedKeys)} not stringified"`;
7213
+ res += `${join48}"... ${getItemCount(removedKeys)} not stringified"`;
7214
7214
  }
7215
7215
  if (spacer !== "") {
7216
7216
  res += `
@@ -7231,7 +7231,7 @@ ${originalIndentation}`;
7231
7231
  let separator = "";
7232
7232
  if (spacer !== "") {
7233
7233
  indentation += spacer;
7234
- join46 = `,
7234
+ join48 = `,
7235
7235
  ${indentation}`;
7236
7236
  whitespace = " ";
7237
7237
  }
@@ -7245,13 +7245,13 @@ ${indentation}`;
7245
7245
  const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
7246
7246
  if (tmp !== void 0) {
7247
7247
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
7248
- separator = join46;
7248
+ separator = join48;
7249
7249
  }
7250
7250
  }
7251
7251
  if (keyLength > maximumBreadth) {
7252
7252
  const removedKeys = keyLength - maximumBreadth;
7253
7253
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
7254
- separator = join46;
7254
+ separator = join48;
7255
7255
  }
7256
7256
  if (spacer !== "" && separator.length > 1) {
7257
7257
  res = `
@@ -7292,7 +7292,7 @@ ${originalIndentation}`;
7292
7292
  }
7293
7293
  const originalIndentation = indentation;
7294
7294
  let res = "";
7295
- let join46 = ",";
7295
+ let join48 = ",";
7296
7296
  if (Array.isArray(value)) {
7297
7297
  if (value.length === 0) {
7298
7298
  return "[]";
@@ -7305,7 +7305,7 @@ ${originalIndentation}`;
7305
7305
  indentation += spacer;
7306
7306
  res += `
7307
7307
  ${indentation}`;
7308
- join46 = `,
7308
+ join48 = `,
7309
7309
  ${indentation}`;
7310
7310
  }
7311
7311
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -7313,13 +7313,13 @@ ${indentation}`;
7313
7313
  for (; i < maximumValuesToStringify - 1; i++) {
7314
7314
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
7315
7315
  res += tmp2 !== void 0 ? tmp2 : "null";
7316
- res += join46;
7316
+ res += join48;
7317
7317
  }
7318
7318
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
7319
7319
  res += tmp !== void 0 ? tmp : "null";
7320
7320
  if (value.length - 1 > maximumBreadth) {
7321
7321
  const removedKeys = value.length - maximumBreadth - 1;
7322
- res += `${join46}"... ${getItemCount(removedKeys)} not stringified"`;
7322
+ res += `${join48}"... ${getItemCount(removedKeys)} not stringified"`;
7323
7323
  }
7324
7324
  if (spacer !== "") {
7325
7325
  res += `
@@ -7332,7 +7332,7 @@ ${originalIndentation}`;
7332
7332
  let whitespace = "";
7333
7333
  if (spacer !== "") {
7334
7334
  indentation += spacer;
7335
- join46 = `,
7335
+ join48 = `,
7336
7336
  ${indentation}`;
7337
7337
  whitespace = " ";
7338
7338
  }
@@ -7341,7 +7341,7 @@ ${indentation}`;
7341
7341
  const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
7342
7342
  if (tmp !== void 0) {
7343
7343
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
7344
- separator = join46;
7344
+ separator = join48;
7345
7345
  }
7346
7346
  }
7347
7347
  if (spacer !== "" && separator.length > 1) {
@@ -7399,20 +7399,20 @@ ${originalIndentation}`;
7399
7399
  indentation += spacer;
7400
7400
  let res2 = `
7401
7401
  ${indentation}`;
7402
- const join47 = `,
7402
+ const join49 = `,
7403
7403
  ${indentation}`;
7404
7404
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
7405
7405
  let i = 0;
7406
7406
  for (; i < maximumValuesToStringify - 1; i++) {
7407
7407
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
7408
7408
  res2 += tmp2 !== void 0 ? tmp2 : "null";
7409
- res2 += join47;
7409
+ res2 += join49;
7410
7410
  }
7411
7411
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
7412
7412
  res2 += tmp !== void 0 ? tmp : "null";
7413
7413
  if (value.length - 1 > maximumBreadth) {
7414
7414
  const removedKeys = value.length - maximumBreadth - 1;
7415
- res2 += `${join47}"... ${getItemCount(removedKeys)} not stringified"`;
7415
+ res2 += `${join49}"... ${getItemCount(removedKeys)} not stringified"`;
7416
7416
  }
7417
7417
  res2 += `
7418
7418
  ${originalIndentation}`;
@@ -7428,16 +7428,16 @@ ${originalIndentation}`;
7428
7428
  return '"[Object]"';
7429
7429
  }
7430
7430
  indentation += spacer;
7431
- const join46 = `,
7431
+ const join48 = `,
7432
7432
  ${indentation}`;
7433
7433
  let res = "";
7434
7434
  let separator = "";
7435
7435
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
7436
7436
  if (isTypedArrayWithEntries(value)) {
7437
- res += stringifyTypedArray(value, join46, maximumBreadth);
7437
+ res += stringifyTypedArray(value, join48, maximumBreadth);
7438
7438
  keys = keys.slice(value.length);
7439
7439
  maximumPropertiesToStringify -= value.length;
7440
- separator = join46;
7440
+ separator = join48;
7441
7441
  }
7442
7442
  if (deterministic) {
7443
7443
  keys = sort(keys, comparator);
@@ -7448,13 +7448,13 @@ ${indentation}`;
7448
7448
  const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
7449
7449
  if (tmp !== void 0) {
7450
7450
  res += `${separator}${strEscape(key3)}: ${tmp}`;
7451
- separator = join46;
7451
+ separator = join48;
7452
7452
  }
7453
7453
  }
7454
7454
  if (keyLength > maximumBreadth) {
7455
7455
  const removedKeys = keyLength - maximumBreadth;
7456
7456
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
7457
- separator = join46;
7457
+ separator = join48;
7458
7458
  }
7459
7459
  if (separator !== "") {
7460
7460
  res = `
@@ -15309,7 +15309,7 @@ var require_compile = __commonJS({
15309
15309
  const schOrFunc = root4.refs[ref];
15310
15310
  if (schOrFunc)
15311
15311
  return schOrFunc;
15312
- let _sch = resolve11.call(this, root4, ref);
15312
+ let _sch = resolve12.call(this, root4, ref);
15313
15313
  if (_sch === void 0) {
15314
15314
  const schema = (_a2 = root4.localRefs) === null || _a2 === void 0 ? void 0 : _a2[ref];
15315
15315
  const { schemaId } = this.opts;
@@ -15336,7 +15336,7 @@ var require_compile = __commonJS({
15336
15336
  function sameSchemaEnv(s1, s2) {
15337
15337
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
15338
15338
  }
15339
- function resolve11(root4, ref) {
15339
+ function resolve12(root4, ref) {
15340
15340
  let sch;
15341
15341
  while (typeof (sch = this.refs[ref]) == "string")
15342
15342
  ref = sch;
@@ -15967,7 +15967,7 @@ var require_fast_uri = __commonJS({
15967
15967
  }
15968
15968
  return uri;
15969
15969
  }
15970
- function resolve11(baseURI, relativeURI, options) {
15970
+ function resolve12(baseURI, relativeURI, options) {
15971
15971
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
15972
15972
  const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
15973
15973
  schemelessOptions.skipEscape = true;
@@ -16225,7 +16225,7 @@ var require_fast_uri = __commonJS({
16225
16225
  var fastUri = {
16226
16226
  SCHEMES,
16227
16227
  normalize: normalize2,
16228
- resolve: resolve11,
16228
+ resolve: resolve12,
16229
16229
  resolveComponent,
16230
16230
  equal,
16231
16231
  serialize,
@@ -32061,7 +32061,7 @@ var require_parse_url = __commonJS({
32061
32061
  var require_form_data = __commonJS({
32062
32062
  "node_modules/light-my-request/lib/form-data.js"(exports2, module2) {
32063
32063
  "use strict";
32064
- var { randomUUID: randomUUID16 } = require("node:crypto");
32064
+ var { randomUUID: randomUUID17 } = require("node:crypto");
32065
32065
  var { Readable: Readable3 } = require("node:stream");
32066
32066
  var textEncoder;
32067
32067
  function isFormDataLike(payload) {
@@ -32069,7 +32069,7 @@ var require_form_data = __commonJS({
32069
32069
  }
32070
32070
  function formDataToStream(formdata) {
32071
32071
  textEncoder = textEncoder ?? new TextEncoder();
32072
- const boundary = `----formdata-${randomUUID16()}`;
32072
+ const boundary = `----formdata-${randomUUID17()}`;
32073
32073
  const prefix = `--${boundary}\r
32074
32074
  Content-Disposition: form-data`;
32075
32075
  const escape2 = (str5) => str5.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
@@ -33572,9 +33572,9 @@ var require_light_my_request = __commonJS({
33572
33572
  const res = new Response(req, callback);
33573
33573
  return makeRequest(dispatchFunc, server, req, res);
33574
33574
  } else {
33575
- return new Promise((resolve11, reject) => {
33575
+ return new Promise((resolve12, reject) => {
33576
33576
  const req = new RequestConstructor(options);
33577
- const res = new Response(req, resolve11, reject);
33577
+ const res = new Response(req, resolve12, reject);
33578
33578
  makeRequest(dispatchFunc, server, req, res);
33579
33579
  });
33580
33580
  }
@@ -34478,14 +34478,14 @@ var require_commonjs = __commonJS({
34478
34478
  exports2.range = exports2.balanced = void 0;
34479
34479
  var balanced = (a, b, str5) => {
34480
34480
  const ma = a instanceof RegExp ? maybeMatch(a, str5) : a;
34481
- const mb = b instanceof RegExp ? maybeMatch(b, str5) : b;
34482
- const r = ma !== null && mb != null && (0, exports2.range)(ma, mb, str5);
34481
+ const mb3 = b instanceof RegExp ? maybeMatch(b, str5) : b;
34482
+ const r = ma !== null && mb3 != null && (0, exports2.range)(ma, mb3, str5);
34483
34483
  return r && {
34484
34484
  start: r[0],
34485
34485
  end: r[1],
34486
34486
  pre: str5.slice(0, r[0]),
34487
34487
  body: str5.slice(r[0] + ma.length, r[1]),
34488
- post: str5.slice(r[1] + mb.length)
34488
+ post: str5.slice(r[1] + mb3.length)
34489
34489
  };
34490
34490
  };
34491
34491
  exports2.balanced = balanced;
@@ -37706,10 +37706,10 @@ var require_commonjs4 = __commonJS({
37706
37706
  * Return a void Promise that resolves once the stream ends.
37707
37707
  */
37708
37708
  async promise() {
37709
- return new Promise((resolve11, reject) => {
37709
+ return new Promise((resolve12, reject) => {
37710
37710
  this.on(DESTROYED, () => reject(new Error("stream destroyed")));
37711
37711
  this.on("error", (er) => reject(er));
37712
- this.on("end", () => resolve11());
37712
+ this.on("end", () => resolve12());
37713
37713
  });
37714
37714
  }
37715
37715
  /**
@@ -37733,7 +37733,7 @@ var require_commonjs4 = __commonJS({
37733
37733
  return Promise.resolve({ done: false, value: res });
37734
37734
  if (this[EOF])
37735
37735
  return stop();
37736
- let resolve11;
37736
+ let resolve12;
37737
37737
  let reject;
37738
37738
  const onerr = (er) => {
37739
37739
  this.off("data", ondata);
@@ -37747,19 +37747,19 @@ var require_commonjs4 = __commonJS({
37747
37747
  this.off("end", onend);
37748
37748
  this.off(DESTROYED, ondestroy);
37749
37749
  this.pause();
37750
- resolve11({ value, done: !!this[EOF] });
37750
+ resolve12({ value, done: !!this[EOF] });
37751
37751
  };
37752
37752
  const onend = () => {
37753
37753
  this.off("error", onerr);
37754
37754
  this.off("data", ondata);
37755
37755
  this.off(DESTROYED, ondestroy);
37756
37756
  stop();
37757
- resolve11({ done: true, value: void 0 });
37757
+ resolve12({ done: true, value: void 0 });
37758
37758
  };
37759
37759
  const ondestroy = () => onerr(new Error("stream destroyed"));
37760
37760
  return new Promise((res2, rej) => {
37761
37761
  reject = rej;
37762
- resolve11 = res2;
37762
+ resolve12 = res2;
37763
37763
  this.once(DESTROYED, ondestroy);
37764
37764
  this.once("error", onerr);
37765
37765
  this.once("end", onend);
@@ -37900,7 +37900,7 @@ var require_commonjs5 = __commonJS({
37900
37900
  var node_url_1 = require("node:url");
37901
37901
  var fs_1 = require("fs");
37902
37902
  var actualFS = __importStar(require("node:fs"));
37903
- var realpathSync3 = fs_1.realpathSync.native;
37903
+ var realpathSync4 = fs_1.realpathSync.native;
37904
37904
  var promises_1 = require("node:fs/promises");
37905
37905
  var minipass_1 = require_commonjs4();
37906
37906
  var defaultFS = {
@@ -37908,7 +37908,7 @@ var require_commonjs5 = __commonJS({
37908
37908
  readdir: fs_1.readdir,
37909
37909
  readdirSync: fs_1.readdirSync,
37910
37910
  readlinkSync: fs_1.readlinkSync,
37911
- realpathSync: realpathSync3,
37911
+ realpathSync: realpathSync4,
37912
37912
  promises: {
37913
37913
  lstat: promises_1.lstat,
37914
37914
  readdir: promises_1.readdir,
@@ -38779,9 +38779,9 @@ var require_commonjs5 = __commonJS({
38779
38779
  if (this.#asyncReaddirInFlight) {
38780
38780
  await this.#asyncReaddirInFlight;
38781
38781
  } else {
38782
- let resolve11 = () => {
38782
+ let resolve12 = () => {
38783
38783
  };
38784
- this.#asyncReaddirInFlight = new Promise((res) => resolve11 = res);
38784
+ this.#asyncReaddirInFlight = new Promise((res) => resolve12 = res);
38785
38785
  try {
38786
38786
  for (const e of await this.#fs.promises.readdir(fullpath, {
38787
38787
  withFileTypes: true
@@ -38794,7 +38794,7 @@ var require_commonjs5 = __commonJS({
38794
38794
  children.provisional = 0;
38795
38795
  }
38796
38796
  this.#asyncReaddirInFlight = void 0;
38797
- resolve11();
38797
+ resolve12();
38798
38798
  }
38799
38799
  return children.slice(0, children.provisional);
38800
38800
  }
@@ -39027,7 +39027,7 @@ var require_commonjs5 = __commonJS({
39027
39027
  *
39028
39028
  * @internal
39029
39029
  */
39030
- constructor(cwd = process.cwd(), pathImpl, sep6, { nocase, childrenCacheSize = 16 * 1024, fs: fs2 = defaultFS } = {}) {
39030
+ constructor(cwd = process.cwd(), pathImpl, sep7, { nocase, childrenCacheSize = 16 * 1024, fs: fs2 = defaultFS } = {}) {
39031
39031
  this.#fs = fsFromOption(fs2);
39032
39032
  if (cwd instanceof URL || cwd.startsWith("file://")) {
39033
39033
  cwd = (0, node_url_1.fileURLToPath)(cwd);
@@ -39038,7 +39038,7 @@ var require_commonjs5 = __commonJS({
39038
39038
  this.#resolveCache = new ResolveCache();
39039
39039
  this.#resolvePosixCache = new ResolveCache();
39040
39040
  this.#children = new ChildrenCache(childrenCacheSize);
39041
- const split = cwdPath.substring(this.rootPath.length).split(sep6);
39041
+ const split = cwdPath.substring(this.rootPath.length).split(sep7);
39042
39042
  if (split.length === 1 && !split[0]) {
39043
39043
  split.pop();
39044
39044
  }
@@ -41991,10 +41991,10 @@ var require_send = __commonJS({
41991
41991
  var { parseTokenList } = require_parseTokenList();
41992
41992
  var { createHttpError } = require_createHttpError();
41993
41993
  var extname4 = path.extname;
41994
- var join46 = path.join;
41994
+ var join48 = path.join;
41995
41995
  var normalize2 = path.normalize;
41996
- var resolve11 = path.resolve;
41997
- var sep6 = path.sep;
41996
+ var resolve12 = path.resolve;
41997
+ var sep7 = path.sep;
41998
41998
  var Readable3 = stream.Readable;
41999
41999
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
42000
42000
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
@@ -42040,7 +42040,7 @@ var require_send = __commonJS({
42040
42040
  const lastModified = options.lastModified !== void 0 ? Boolean(options.lastModified) : true;
42041
42041
  const maxage = normalizeMaxAge(options.maxAge ?? options.maxage);
42042
42042
  const maxContentRangeChunkSize = options.maxContentRangeChunkSize !== void 0 ? Number(options.maxContentRangeChunkSize) : null;
42043
- const root4 = options.root ? resolve11(options.root) : null;
42043
+ const root4 = options.root ? resolve12(options.root) : null;
42044
42044
  const highWaterMark = Number.isSafeInteger(options.highWaterMark) && options.highWaterMark > 0 ? options.highWaterMark : null;
42045
42045
  return {
42046
42046
  acceptRanges,
@@ -42071,21 +42071,21 @@ var require_send = __commonJS({
42071
42071
  let parts;
42072
42072
  if (root4 !== null) {
42073
42073
  if (path2) {
42074
- path2 = normalize2("." + sep6 + path2);
42074
+ path2 = normalize2("." + sep7 + path2);
42075
42075
  }
42076
42076
  if (UP_PATH_REGEXP.test(path2)) {
42077
42077
  debug('malicious path "%s"', path2);
42078
42078
  return { statusCode: 403 };
42079
42079
  }
42080
- parts = path2.split(sep6);
42081
- path2 = normalize2(join46(root4, path2));
42080
+ parts = path2.split(sep7);
42081
+ path2 = normalize2(join48(root4, path2));
42082
42082
  } else {
42083
42083
  if (UP_PATH_REGEXP.test(path2)) {
42084
42084
  debug('malicious path "%s"', path2);
42085
42085
  return { statusCode: 403 };
42086
42086
  }
42087
- parts = normalize2(path2).split(sep6);
42088
- path2 = resolve11(path2);
42087
+ parts = normalize2(path2).split(sep7);
42088
+ path2 = resolve12(path2);
42089
42089
  }
42090
42090
  return { path: path2, parts };
42091
42091
  }
@@ -42181,9 +42181,9 @@ var require_send = __commonJS({
42181
42181
  );
42182
42182
  }
42183
42183
  function tryStat(path2) {
42184
- return new Promise((resolve12) => {
42184
+ return new Promise((resolve13) => {
42185
42185
  fs2.stat(path2, function onstat(error, stat4) {
42186
- resolve12({ error, stat: stat4 });
42186
+ resolve13({ error, stat: stat4 });
42187
42187
  });
42188
42188
  });
42189
42189
  }
@@ -42361,7 +42361,7 @@ var require_send = __commonJS({
42361
42361
  let err2;
42362
42362
  for (let i = 0; i < options.index.length; i++) {
42363
42363
  const index = options.index[i];
42364
- const p = join46(path2, index);
42364
+ const p = join48(path2, index);
42365
42365
  const { error, stat: stat4 } = await tryStat(p);
42366
42366
  if (error) {
42367
42367
  err2 = error;
@@ -42377,7 +42377,7 @@ var require_send = __commonJS({
42377
42377
  }
42378
42378
  async function sendFile(request, path2, options) {
42379
42379
  const { error, stat: stat4 } = await tryStat(path2);
42380
- if (error && error.code === "ENOENT" && !extname4(path2) && path2[path2.length - 1] !== sep6) {
42380
+ if (error && error.code === "ENOENT" && !extname4(path2) && path2[path2.length - 1] !== sep7) {
42381
42381
  let err2 = error;
42382
42382
  for (let i = 0; i < options.extensions.length; i++) {
42383
42383
  const extension = options.extensions[i];
@@ -43145,8 +43145,8 @@ var require_static = __commonJS({
43145
43145
  }
43146
43146
  }
43147
43147
  }
43148
- for (const [dirname22, rootPath] of indexDirs.entries()) {
43149
- const pathname = dirname22 + (dirname22.endsWith("/") ? "" : "/");
43148
+ for (const [dirname23, rootPath] of indexDirs.entries()) {
43149
+ const pathname = dirname23 + (dirname23.endsWith("/") ? "" : "/");
43150
43150
  const file = "/" + pathname.replace(prefix, "");
43151
43151
  setUpHeadAndGet(routeOpts, pathname, file, rootPath);
43152
43152
  if (opts.redirect === true) {
@@ -47402,10 +47402,10 @@ var require_resolve_block_map = __commonJS({
47402
47402
  let offset = bm.offset;
47403
47403
  let commentEnd = null;
47404
47404
  for (const collItem of bm.items) {
47405
- const { start, key, sep: sep6, value } = collItem;
47405
+ const { start, key, sep: sep7, value } = collItem;
47406
47406
  const keyProps = resolveProps.resolveProps(start, {
47407
47407
  indicator: "explicit-key-ind",
47408
- next: key ?? sep6?.[0],
47408
+ next: key ?? sep7?.[0],
47409
47409
  offset,
47410
47410
  onError,
47411
47411
  parentIndent: bm.indent,
@@ -47419,7 +47419,7 @@ var require_resolve_block_map = __commonJS({
47419
47419
  else if ("indent" in key && key.indent !== bm.indent)
47420
47420
  onError(offset, "BAD_INDENT", startColMsg);
47421
47421
  }
47422
- if (!keyProps.anchor && !keyProps.tag && !sep6) {
47422
+ if (!keyProps.anchor && !keyProps.tag && !sep7) {
47423
47423
  commentEnd = keyProps.end;
47424
47424
  if (keyProps.comment) {
47425
47425
  if (map.comment)
@@ -47443,7 +47443,7 @@ var require_resolve_block_map = __commonJS({
47443
47443
  ctx.atKey = false;
47444
47444
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
47445
47445
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
47446
- const valueProps = resolveProps.resolveProps(sep6 ?? [], {
47446
+ const valueProps = resolveProps.resolveProps(sep7 ?? [], {
47447
47447
  indicator: "map-value-ind",
47448
47448
  next: value,
47449
47449
  offset: keyNode.range[2],
@@ -47459,7 +47459,7 @@ var require_resolve_block_map = __commonJS({
47459
47459
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
47460
47460
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
47461
47461
  }
47462
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep6, null, valueProps, onError);
47462
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep7, null, valueProps, onError);
47463
47463
  if (ctx.schema.compat)
47464
47464
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
47465
47465
  offset = valueNode.range[2];
@@ -47550,7 +47550,7 @@ var require_resolve_end = __commonJS({
47550
47550
  let comment = "";
47551
47551
  if (end) {
47552
47552
  let hasSpace = false;
47553
- let sep6 = "";
47553
+ let sep7 = "";
47554
47554
  for (const token of end) {
47555
47555
  const { source, type } = token;
47556
47556
  switch (type) {
@@ -47564,13 +47564,13 @@ var require_resolve_end = __commonJS({
47564
47564
  if (!comment)
47565
47565
  comment = cb;
47566
47566
  else
47567
- comment += sep6 + cb;
47568
- sep6 = "";
47567
+ comment += sep7 + cb;
47568
+ sep7 = "";
47569
47569
  break;
47570
47570
  }
47571
47571
  case "newline":
47572
47572
  if (comment)
47573
- sep6 += source;
47573
+ sep7 += source;
47574
47574
  hasSpace = true;
47575
47575
  break;
47576
47576
  default:
@@ -47613,18 +47613,18 @@ var require_resolve_flow_collection = __commonJS({
47613
47613
  let offset = fc.offset + fc.start.source.length;
47614
47614
  for (let i = 0; i < fc.items.length; ++i) {
47615
47615
  const collItem = fc.items[i];
47616
- const { start, key, sep: sep6, value } = collItem;
47616
+ const { start, key, sep: sep7, value } = collItem;
47617
47617
  const props = resolveProps.resolveProps(start, {
47618
47618
  flow: fcName,
47619
47619
  indicator: "explicit-key-ind",
47620
- next: key ?? sep6?.[0],
47620
+ next: key ?? sep7?.[0],
47621
47621
  offset,
47622
47622
  onError,
47623
47623
  parentIndent: fc.indent,
47624
47624
  startOnNewline: false
47625
47625
  });
47626
47626
  if (!props.found) {
47627
- if (!props.anchor && !props.tag && !sep6 && !value) {
47627
+ if (!props.anchor && !props.tag && !sep7 && !value) {
47628
47628
  if (i === 0 && props.comma)
47629
47629
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
47630
47630
  else if (i < fc.items.length - 1)
@@ -47678,8 +47678,8 @@ var require_resolve_flow_collection = __commonJS({
47678
47678
  }
47679
47679
  }
47680
47680
  }
47681
- if (!isMap3 && !sep6 && !props.found) {
47682
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep6, null, props, onError);
47681
+ if (!isMap3 && !sep7 && !props.found) {
47682
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep7, null, props, onError);
47683
47683
  coll.items.push(valueNode);
47684
47684
  offset = valueNode.range[2];
47685
47685
  if (isBlock(value))
@@ -47691,7 +47691,7 @@ var require_resolve_flow_collection = __commonJS({
47691
47691
  if (isBlock(key))
47692
47692
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
47693
47693
  ctx.atKey = false;
47694
- const valueProps = resolveProps.resolveProps(sep6 ?? [], {
47694
+ const valueProps = resolveProps.resolveProps(sep7 ?? [], {
47695
47695
  flow: fcName,
47696
47696
  indicator: "map-value-ind",
47697
47697
  next: value,
@@ -47702,8 +47702,8 @@ var require_resolve_flow_collection = __commonJS({
47702
47702
  });
47703
47703
  if (valueProps.found) {
47704
47704
  if (!isMap3 && !props.found && ctx.options.strict) {
47705
- if (sep6)
47706
- for (const st of sep6) {
47705
+ if (sep7)
47706
+ for (const st of sep7) {
47707
47707
  if (st === valueProps.found)
47708
47708
  break;
47709
47709
  if (st.type === "newline") {
@@ -47720,7 +47720,7 @@ var require_resolve_flow_collection = __commonJS({
47720
47720
  else
47721
47721
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
47722
47722
  }
47723
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep6, null, valueProps, onError) : null;
47723
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep7, null, valueProps, onError) : null;
47724
47724
  if (valueNode) {
47725
47725
  if (isBlock(value))
47726
47726
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -47900,7 +47900,7 @@ var require_resolve_block_scalar = __commonJS({
47900
47900
  chompStart = i + 1;
47901
47901
  }
47902
47902
  let value = "";
47903
- let sep6 = "";
47903
+ let sep7 = "";
47904
47904
  let prevMoreIndented = false;
47905
47905
  for (let i = 0; i < contentStart; ++i)
47906
47906
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -47917,24 +47917,24 @@ var require_resolve_block_scalar = __commonJS({
47917
47917
  indent = "";
47918
47918
  }
47919
47919
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
47920
- value += sep6 + indent.slice(trimIndent) + content;
47921
- sep6 = "\n";
47920
+ value += sep7 + indent.slice(trimIndent) + content;
47921
+ sep7 = "\n";
47922
47922
  } else if (indent.length > trimIndent || content[0] === " ") {
47923
- if (sep6 === " ")
47924
- sep6 = "\n";
47925
- else if (!prevMoreIndented && sep6 === "\n")
47926
- sep6 = "\n\n";
47927
- value += sep6 + indent.slice(trimIndent) + content;
47928
- sep6 = "\n";
47923
+ if (sep7 === " ")
47924
+ sep7 = "\n";
47925
+ else if (!prevMoreIndented && sep7 === "\n")
47926
+ sep7 = "\n\n";
47927
+ value += sep7 + indent.slice(trimIndent) + content;
47928
+ sep7 = "\n";
47929
47929
  prevMoreIndented = true;
47930
47930
  } else if (content === "") {
47931
- if (sep6 === "\n")
47931
+ if (sep7 === "\n")
47932
47932
  value += "\n";
47933
47933
  else
47934
- sep6 = "\n";
47934
+ sep7 = "\n";
47935
47935
  } else {
47936
- value += sep6 + content;
47937
- sep6 = " ";
47936
+ value += sep7 + content;
47937
+ sep7 = " ";
47938
47938
  prevMoreIndented = false;
47939
47939
  }
47940
47940
  }
@@ -48116,25 +48116,25 @@ var require_resolve_flow_scalar = __commonJS({
48116
48116
  if (!match)
48117
48117
  return source;
48118
48118
  let res = match[1];
48119
- let sep6 = " ";
48119
+ let sep7 = " ";
48120
48120
  let pos2 = first.lastIndex;
48121
48121
  line.lastIndex = pos2;
48122
48122
  while (match = line.exec(source)) {
48123
48123
  if (match[1] === "") {
48124
- if (sep6 === "\n")
48125
- res += sep6;
48124
+ if (sep7 === "\n")
48125
+ res += sep7;
48126
48126
  else
48127
- sep6 = "\n";
48127
+ sep7 = "\n";
48128
48128
  } else {
48129
- res += sep6 + match[1];
48130
- sep6 = " ";
48129
+ res += sep7 + match[1];
48130
+ sep7 = " ";
48131
48131
  }
48132
48132
  pos2 = line.lastIndex;
48133
48133
  }
48134
48134
  const last = /[ \t]*(.*)/sy;
48135
48135
  last.lastIndex = pos2;
48136
48136
  match = last.exec(source);
48137
- return res + sep6 + (match?.[1] ?? "");
48137
+ return res + sep7 + (match?.[1] ?? "");
48138
48138
  }
48139
48139
  function doubleQuotedValue(source, onError) {
48140
48140
  let res = "";
@@ -48944,14 +48944,14 @@ var require_cst_stringify = __commonJS({
48944
48944
  }
48945
48945
  }
48946
48946
  }
48947
- function stringifyItem({ start, key, sep: sep6, value }) {
48947
+ function stringifyItem({ start, key, sep: sep7, value }) {
48948
48948
  let res = "";
48949
48949
  for (const st of start)
48950
48950
  res += st.source;
48951
48951
  if (key)
48952
48952
  res += stringifyToken(key);
48953
- if (sep6)
48954
- for (const st of sep6)
48953
+ if (sep7)
48954
+ for (const st of sep7)
48955
48955
  res += st.source;
48956
48956
  if (value)
48957
48957
  res += stringifyToken(value);
@@ -50118,18 +50118,18 @@ var require_parser = __commonJS({
50118
50118
  if (this.type === "map-value-ind") {
50119
50119
  const prev = getPrevProps(this.peek(2));
50120
50120
  const start = getFirstKeyStartProps(prev);
50121
- let sep6;
50121
+ let sep7;
50122
50122
  if (scalar.end) {
50123
- sep6 = scalar.end;
50124
- sep6.push(this.sourceToken);
50123
+ sep7 = scalar.end;
50124
+ sep7.push(this.sourceToken);
50125
50125
  delete scalar.end;
50126
50126
  } else
50127
- sep6 = [this.sourceToken];
50127
+ sep7 = [this.sourceToken];
50128
50128
  const map = {
50129
50129
  type: "block-map",
50130
50130
  offset: scalar.offset,
50131
50131
  indent: scalar.indent,
50132
- items: [{ start, key: scalar, sep: sep6 }]
50132
+ items: [{ start, key: scalar, sep: sep7 }]
50133
50133
  };
50134
50134
  this.onKeyLine = true;
50135
50135
  this.stack[this.stack.length - 1] = map;
@@ -50282,15 +50282,15 @@ var require_parser = __commonJS({
50282
50282
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
50283
50283
  const start2 = getFirstKeyStartProps(it.start);
50284
50284
  const key = it.key;
50285
- const sep6 = it.sep;
50286
- sep6.push(this.sourceToken);
50285
+ const sep7 = it.sep;
50286
+ sep7.push(this.sourceToken);
50287
50287
  delete it.key;
50288
50288
  delete it.sep;
50289
50289
  this.stack.push({
50290
50290
  type: "block-map",
50291
50291
  offset: this.offset,
50292
50292
  indent: this.indent,
50293
- items: [{ start: start2, key, sep: sep6 }]
50293
+ items: [{ start: start2, key, sep: sep7 }]
50294
50294
  });
50295
50295
  } else if (start.length > 0) {
50296
50296
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -50484,13 +50484,13 @@ var require_parser = __commonJS({
50484
50484
  const prev = getPrevProps(parent);
50485
50485
  const start = getFirstKeyStartProps(prev);
50486
50486
  fixFlowSeqItems(fc);
50487
- const sep6 = fc.end.splice(1, fc.end.length);
50488
- sep6.push(this.sourceToken);
50487
+ const sep7 = fc.end.splice(1, fc.end.length);
50488
+ sep7.push(this.sourceToken);
50489
50489
  const map = {
50490
50490
  type: "block-map",
50491
50491
  offset: fc.offset,
50492
50492
  indent: fc.indent,
50493
- items: [{ start, key: fc, sep: sep6 }]
50493
+ items: [{ start, key: fc, sep: sep7 }]
50494
50494
  };
50495
50495
  this.onKeyLine = true;
50496
50496
  this.stack[this.stack.length - 1] = map;
@@ -50827,10 +50827,11 @@ var import_node_readline2 = require("node:readline");
50827
50827
 
50828
50828
  // index.ts
50829
50829
  var import_node_url5 = require("node:url");
50830
- var import_node_path48 = require("node:path");
50830
+ var import_node_path50 = require("node:path");
50831
50831
  var import_node_os27 = require("node:os");
50832
- var import_node_fs50 = require("node:fs");
50832
+ var import_node_fs52 = require("node:fs");
50833
50833
  var import_node_child_process11 = require("node:child_process");
50834
+ var import_node_util4 = require("node:util");
50834
50835
 
50835
50836
  // log.mjs
50836
50837
  var import_node_path = require("node:path");
@@ -50951,6 +50952,7 @@ function storeVisualInput(appId, dataUrl) {
50951
50952
  return { path, ext, bytes: (0, import_node_fs3.statSync)(path).size, sha256: sha2563 };
50952
50953
  }
50953
50954
  var MAX_IFC_BYTES = 64 * 1024 * 1024;
50955
+ var mb = (bytes) => `${Math.round(bytes / (1024 * 1024))} MB`;
50954
50956
  function sniffIfc(buf) {
50955
50957
  let off = 0;
50956
50958
  if (buf.length >= 3 && buf[0] === 239 && buf[1] === 187 && buf[2] === 191) off = 3;
@@ -50958,13 +50960,13 @@ function sniffIfc(buf) {
50958
50960
  if (buf.length >= 4 && buf[0] === 80 && buf[1] === 75 && (buf[2] === 3 || buf[2] === 5 || buf[2] === 7)) return "ifczip";
50959
50961
  return null;
50960
50962
  }
50961
- function storeIfcInput(appId, dataUrl) {
50963
+ function storeIfcInput(appId, dataUrl, maxBytes = MAX_IFC_BYTES) {
50962
50964
  if (!safeSegment(appId)) throw new VisualInputError("invalid app id");
50963
50965
  const m = /^data:([\w/+.-]*);base64,(.*)$/s.exec(dataUrl || "");
50964
50966
  if (!m) throw new VisualInputError("IFC must be a base64 data URL");
50965
50967
  const buf = Buffer.from(m[2] ?? "", "base64");
50966
50968
  if (buf.length === 0) throw new VisualInputError("empty IFC file");
50967
- if (buf.length > MAX_IFC_BYTES) throw new VisualInputError("IFC file too large (max 64 MB)");
50969
+ if (buf.length > maxBytes) throw new VisualInputError(`IFC file too large (max ${mb(maxBytes)})`);
50968
50970
  const ext = sniffIfc(buf);
50969
50971
  if (!ext) throw new VisualInputError("that file is not an IFC (.ifc / .ifczip)");
50970
50972
  const sha2563 = (0, import_node_crypto.createHash)("sha256").update(buf).digest("hex");
@@ -51138,7 +51140,7 @@ function localBusyError(kind, key, at, blocker, now) {
51138
51140
  });
51139
51141
  }
51140
51142
  function waitForTurn(previous, budget, onExpiry) {
51141
- return new Promise((resolve11, reject) => {
51143
+ return new Promise((resolve12, reject) => {
51142
51144
  let settled = false;
51143
51145
  const timer = setTimeout(() => {
51144
51146
  if (settled) return;
@@ -51150,7 +51152,7 @@ function waitForTurn(previous, budget, onExpiry) {
51150
51152
  if (settled) return;
51151
51153
  settled = true;
51152
51154
  clearTimeout(timer);
51153
- resolve11();
51155
+ resolve12();
51154
51156
  });
51155
51157
  });
51156
51158
  }
@@ -51159,7 +51161,7 @@ var STALE_MS = 3e4;
51159
51161
  var WAIT_MS = 50;
51160
51162
  var TIMEOUT_MS = 6e4;
51161
51163
  var processStarts = /* @__PURE__ */ new Map();
51162
- var sleep = (ms) => new Promise((resolve11) => setTimeout(resolve11, ms));
51164
+ var sleep = (ms) => new Promise((resolve12) => setTimeout(resolve12, ms));
51163
51165
  function root() {
51164
51166
  return (0, import_node_path3.join)(process.env.FLOLESS_HOME ?? (0, import_node_path3.join)((0, import_node_os3.homedir)(), ".floless"), ".locks");
51165
51167
  }
@@ -51388,8 +51390,8 @@ async function withLifecycleLock(kind, key, fn, options = {}) {
51388
51390
  const intent = registerIntent(token, options);
51389
51391
  const previous = localTails.get(token) ?? Promise.resolve();
51390
51392
  let releaseLocal;
51391
- const mine = new Promise((resolve11) => {
51392
- releaseLocal = resolve11;
51393
+ const mine = new Promise((resolve12) => {
51394
+ releaseLocal = resolve12;
51393
51395
  });
51394
51396
  const tail = previous.catch(() => {
51395
51397
  }).then(() => mine);
@@ -52481,8 +52483,8 @@ var AwareLifecycleGate = class {
52481
52483
  this.#writerDepth = 1;
52482
52484
  return Promise.resolve(this.#writerLease(leaseOwner));
52483
52485
  }
52484
- return new Promise((resolve11, reject) => {
52485
- const waiter = { mode, owner: leaseOwner, resolve: resolve11, reject, ...signal ? { signal } : {} };
52486
+ return new Promise((resolve12, reject) => {
52487
+ const waiter = { mode, owner: leaseOwner, resolve: resolve12, reject, ...signal ? { signal } : {} };
52486
52488
  if (signal) {
52487
52489
  waiter.onAbort = () => {
52488
52490
  const index = this.#queue.indexOf(waiter);
@@ -52657,7 +52659,7 @@ function runRawUnlocked(args, onSpawn, envOverride, timeoutMs) {
52657
52659
  if (!Number.isFinite(limit) || limit <= 0) {
52658
52660
  throw new AwareError(`invalid aware timeout: ${limit}`);
52659
52661
  }
52660
- return new Promise((resolve11, reject) => {
52662
+ return new Promise((resolve12, reject) => {
52661
52663
  const child = (0, import_node_child_process2.spawn)(bin, argv, {
52662
52664
  shell: invoker.shell,
52663
52665
  windowsHide: true,
@@ -52684,7 +52686,7 @@ function runRawUnlocked(args, onSpawn, envOverride, timeoutMs) {
52684
52686
  reject(terminalError);
52685
52687
  return;
52686
52688
  }
52687
- resolve11({ code: code ?? -1, stdout, stderr });
52689
+ resolve12({ code: code ?? -1, stdout, stderr });
52688
52690
  });
52689
52691
  });
52690
52692
  }
@@ -52701,7 +52703,7 @@ function runRawWithEnvUnlocked(args, env2, timeoutMs, onSpawn, signal) {
52701
52703
  }
52702
52704
  const argv = [...preArgs, ...args];
52703
52705
  const limit = timeoutMs ?? RUN_TIMEOUT_MS;
52704
- return new Promise((resolve11, reject) => {
52706
+ return new Promise((resolve12, reject) => {
52705
52707
  const child = (0, import_node_child_process2.spawn)(bin, argv, { shell: invoker.shell, windowsHide: true, env: env2 ?? process.env });
52706
52708
  let stdout = "";
52707
52709
  let stderr = "";
@@ -52738,7 +52740,7 @@ function runRawWithEnvUnlocked(args, env2, timeoutMs, onSpawn, signal) {
52738
52740
  reject(terminalError);
52739
52741
  return;
52740
52742
  }
52741
- resolve11({ code: code ?? -1, stdout, stderr });
52743
+ resolve12({ code: code ?? -1, stdout, stderr });
52742
52744
  });
52743
52745
  });
52744
52746
  }
@@ -52807,7 +52809,7 @@ function standardUserTempDir() {
52807
52809
  async function hostInstancesUnlocked(host) {
52808
52810
  const bin = resolveHostBridge(host);
52809
52811
  if (!bin) return { ok: false, instances: [], probeFailed: true, error: `aware-${host} bridge not found (run \`aware sidecar install ${host}\`)` };
52810
- const probe = (env3) => new Promise((resolve11) => {
52812
+ const probe = (env3) => new Promise((resolve12) => {
52811
52813
  const child = (0, import_node_child_process2.spawn)(bin, ["list-instances"], { windowsHide: true, env: env3 ? { ...process.env, ...env3 } : process.env });
52812
52814
  let stdout = "";
52813
52815
  let stderr = "";
@@ -52816,11 +52818,11 @@ async function hostInstancesUnlocked(host) {
52816
52818
  child.stderr.on("data", (d) => stderr += d.toString());
52817
52819
  child.on("error", () => {
52818
52820
  clearTimeout(timer);
52819
- resolve11({ code: -1, stdout: "", stderr: "spawn failed" });
52821
+ resolve12({ code: -1, stdout: "", stderr: "spawn failed" });
52820
52822
  });
52821
52823
  child.on("close", (code) => {
52822
52824
  clearTimeout(timer);
52823
- resolve11({ code, stdout, stderr });
52825
+ resolve12({ code, stdout, stderr });
52824
52826
  });
52825
52827
  });
52826
52828
  let out = await probe();
@@ -52900,7 +52902,7 @@ async function execTeklaUnlocked(code, opts = {}) {
52900
52902
  args: opts.args ?? {}
52901
52903
  });
52902
52904
  const timeoutMs = opts.debug ? 15 * 6e4 : RUN_TIMEOUT_MS;
52903
- return new Promise((resolve11, reject) => {
52905
+ return new Promise((resolve12, reject) => {
52904
52906
  const child = (0, import_node_child_process2.spawn)(bin, ["exec", "--version", version, "--json-stdin"], { windowsHide: true });
52905
52907
  let stdout = "";
52906
52908
  let stderr = "";
@@ -52933,7 +52935,7 @@ async function execTeklaUnlocked(code, opts = {}) {
52933
52935
  })
52934
52936
  );
52935
52937
  }
52936
- resolve11(parsed);
52938
+ resolve12(parsed);
52937
52939
  });
52938
52940
  child.stdin.write(payload);
52939
52941
  child.stdin.end();
@@ -53074,8 +53076,8 @@ function startTriggerWithLease(id, args, lease) {
53074
53076
  let stopped = false;
53075
53077
  let stopPromise = null;
53076
53078
  let settleClosed;
53077
- const closed = new Promise((resolve11) => {
53078
- settleClosed = resolve11;
53079
+ const closed = new Promise((resolve12) => {
53080
+ settleClosed = resolve12;
53079
53081
  });
53080
53082
  const child = (0, import_node_child_process2.spawn)(bin, [...preArgs, ...args], { shell: invoker.shell, windowsHide: true });
53081
53083
  const readAndEmit = () => {
@@ -53282,7 +53284,7 @@ function connectDeviceCodeWithLease(id, onEvent, lease) {
53282
53284
  if (!bin) throw new AwareError("aware CLI invoker not resolved");
53283
53285
  inFlightConnects.get(id)?.();
53284
53286
  const argv = [...preArgs, "connect", id, "--device-code", "--json"];
53285
- return new Promise((resolve11, reject) => {
53287
+ return new Promise((resolve12, reject) => {
53286
53288
  const child = (0, import_node_child_process2.spawn)(bin, argv, { shell: invoker.shell, windowsHide: true });
53287
53289
  let buf = "";
53288
53290
  let gotPrompt = false;
@@ -53308,7 +53310,7 @@ function connectDeviceCodeWithLease(id, onEvent, lease) {
53308
53310
  }
53309
53311
  if (!gotPrompt && obj2.phase === "prompt" && typeof obj2.user_code === "string") {
53310
53312
  gotPrompt = true;
53311
- resolve11({ prompt: obj2, cancel });
53313
+ resolve12({ prompt: obj2, cancel });
53312
53314
  } else {
53313
53315
  onEvent(obj2);
53314
53316
  }
@@ -53940,18 +53942,57 @@ function cmpVersions(a, b) {
53940
53942
  }
53941
53943
  return 0;
53942
53944
  }
53945
+ function classifyProbeFailure(err2) {
53946
+ const e = err2;
53947
+ if (!e || e.killed === true) return "unknown";
53948
+ return e.code === 1 ? "absent" : "unknown";
53949
+ }
53950
+ function probeTimeoutMs(attempt) {
53951
+ return 5e3 * (attempt + 1);
53952
+ }
53953
+ async function probeCommand(lookup, opts = {}) {
53954
+ const attempts = Number.isFinite(opts.attempts) ? Math.max(1, opts.attempts) : 3;
53955
+ const delay = opts.delay ?? ((ms) => new Promise((r) => {
53956
+ setTimeout(r, ms);
53957
+ }));
53958
+ for (let attempt = 0; attempt < attempts; attempt++) {
53959
+ try {
53960
+ await lookup(attempt);
53961
+ return "present";
53962
+ } catch (err2) {
53963
+ const outcome = classifyProbeFailure(err2);
53964
+ opts.onFailure?.({ attempt, outcome, err: err2 });
53965
+ if (outcome === "absent") return "absent";
53966
+ if (attempt < attempts - 1) await delay(250 * (attempt + 1));
53967
+ }
53968
+ }
53969
+ return "unknown";
53970
+ }
53971
+ function toolchainLookup(run, opts) {
53972
+ return (cmd) => probeCommand(
53973
+ (attempt) => run(opts.isWin ? "where" : "which", [cmd], { windowsHide: true, timeout: probeTimeoutMs(attempt) }),
53974
+ { onFailure: (info) => opts.onFailure?.({ ...info, cmd }) }
53975
+ );
53976
+ }
53943
53977
  function decideBootstrap(input) {
53944
53978
  const { toolchain, aware: aware2, floor, skip } = input;
53945
- if (!toolchain.hasNode) return { kind: "fail", reason: "no-node" };
53979
+ if (toolchain.node === "absent") return { kind: "fail", reason: "no-node" };
53980
+ if (toolchain.node === "unknown") return { kind: "fail", reason: "toolchain-unverified" };
53946
53981
  if (skip) return aware2.installed ? { kind: "ready" } : { kind: "fail", reason: "absent-and-skipped" };
53947
53982
  if (aware2.installed && isValidVersion(aware2.version) && cmpVersions(aware2.version, floor) >= 0) return { kind: "ready" };
53948
- if (!toolchain.hasNpm) return aware2.installed ? { kind: "ready" } : { kind: "fail", reason: "no-npm" };
53983
+ if (toolchain.npm !== "present") {
53984
+ if (aware2.installed) return { kind: "ready" };
53985
+ return { kind: "fail", reason: toolchain.npm === "absent" ? "no-npm" : "toolchain-unverified" };
53986
+ }
53949
53987
  return { kind: "install", version: "latest" };
53950
53988
  }
53951
53989
  var REMEDIATION = {
53952
53990
  "no-node": "AWARE needs Node.js 20+. Install it from https://nodejs.org and relaunch floless.app.",
53953
53991
  "no-npm": "npm was not found. Install Node.js 20+ (which includes npm) from https://nodejs.org, then relaunch.",
53954
53992
  "absent-and-skipped": "AWARE_SKIP_BOOTSTRAP is set but AWARE is not installed. Run: npm i -g @aware-aeco/cli",
53993
+ // Supplementary to the UI's own copy (which the overlay shows above it), so it says
53994
+ // what was actually attempted rather than paraphrasing "we couldn't check".
53995
+ "toolchain-unverified": "The PATH lookup for Node.js/npm did not complete \u2014 it timed out or could not be spawned, so nothing was proven missing. Usually a busy machine rather than a broken install: use Try again, and relaunch FloLess if it persists.",
53955
53996
  "eacces": "The global install was denied (permission). Run in an elevated terminal, or set an npm user prefix, then relaunch: npm i -g @aware-aeco/cli",
53956
53997
  "offline": "Could not reach the npm registry. Check your connection and relaunch.",
53957
53998
  "install-failed": "Installing AWARE failed. Try manually: npm i -g @aware-aeco/cli",
@@ -53993,7 +54034,16 @@ function runBootstrap(deps) {
53993
54034
  set(deps, { status: "probing", awareReady: false, awareVersion: null, reason: null, remediation: null });
53994
54035
  const aware0 = deps.getAware();
53995
54036
  version = aware0.version;
53996
- const decision = decideBootstrap({ toolchain: deps.probeToolchain(), aware: aware0, floor: deps.floor, skip: deps.skip });
54037
+ let toolchain;
54038
+ try {
54039
+ toolchain = await deps.probeToolchain();
54040
+ } catch (err2) {
54041
+ deps.logWarn?.("toolchain probe threw \u2014 treating as unverified", {
54042
+ err: err2 instanceof Error ? err2.stack ?? err2.message : String(err2)
54043
+ });
54044
+ return fail(deps, "toolchain-unverified", version);
54045
+ }
54046
+ const decision = decideBootstrap({ toolchain, aware: aware0, floor: deps.floor, skip: deps.skip });
53997
54047
  if (decision.kind === "fail") return fail(deps, decision.reason, version);
53998
54048
  if (decision.kind === "install") {
53999
54049
  set(deps, { status: "installing", awareReady: false, awareVersion: version, reason: null, remediation: null });
@@ -54469,7 +54519,7 @@ function appVersion() {
54469
54519
  return resolveVersion({
54470
54520
  isSea: isSea2(),
54471
54521
  sqVersionXml: readSqVersionXml(),
54472
- define: true ? "0.119.0" : void 0,
54522
+ define: true ? "0.120.0" : void 0,
54473
54523
  pkgVersion: readPkgVersion()
54474
54524
  });
54475
54525
  }
@@ -54485,7 +54535,7 @@ function resolveChannel(s) {
54485
54535
  function appChannel() {
54486
54536
  return resolveChannel({
54487
54537
  isSea: isSea2(),
54488
- define: true ? "0.119.0" : void 0,
54538
+ define: true ? "0.120.0" : void 0,
54489
54539
  // argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
54490
54540
  // carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
54491
54541
  modulePath: process.argv[1]
@@ -54660,10 +54710,10 @@ function ensureManagedProfile(id) {
54660
54710
  return "written";
54661
54711
  }
54662
54712
  function isPortBindable(port, host = "127.0.0.1") {
54663
- return new Promise((resolve11) => {
54713
+ return new Promise((resolve12) => {
54664
54714
  const srv = import_node_net.default.createServer();
54665
- srv.once("error", () => resolve11(false));
54666
- srv.listen(port, host, () => srv.close(() => resolve11(true)));
54715
+ srv.once("error", () => resolve12(false));
54716
+ srv.listen(port, host, () => srv.close(() => resolve12(true)));
54667
54717
  });
54668
54718
  }
54669
54719
 
@@ -55974,26 +56024,26 @@ for (i = 0; i < 32768; ++i) {
55974
56024
  }
55975
56025
  var x;
55976
56026
  var i;
55977
- var hMap = (function(cd, mb, r) {
56027
+ var hMap = (function(cd, mb3, r) {
55978
56028
  var s = cd.length;
55979
56029
  var i = 0;
55980
- var l = new u16(mb);
56030
+ var l = new u16(mb3);
55981
56031
  for (; i < s; ++i) {
55982
56032
  if (cd[i])
55983
56033
  ++l[cd[i] - 1];
55984
56034
  }
55985
- var le = new u16(mb);
55986
- for (i = 1; i < mb; ++i) {
56035
+ var le = new u16(mb3);
56036
+ for (i = 1; i < mb3; ++i) {
55987
56037
  le[i] = le[i - 1] + l[i - 1] << 1;
55988
56038
  }
55989
56039
  var co;
55990
56040
  if (r) {
55991
- co = new u16(1 << mb);
55992
- var rvb = 15 - mb;
56041
+ co = new u16(1 << mb3);
56042
+ var rvb = 15 - mb3;
55993
56043
  for (i = 0; i < s; ++i) {
55994
56044
  if (cd[i]) {
55995
56045
  var sv = i << 4 | cd[i];
55996
- var r_1 = mb - cd[i];
56046
+ var r_1 = mb3 - cd[i];
55997
56047
  var v = le[cd[i] - 1]++ << r_1;
55998
56048
  for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
55999
56049
  co[rev[v] >> rvb] = sv;
@@ -56238,7 +56288,7 @@ var wbits16 = function(d, p, v) {
56238
56288
  d[o + 1] |= v >> 8;
56239
56289
  d[o + 2] |= v >> 16;
56240
56290
  };
56241
- var hTree = function(d, mb) {
56291
+ var hTree = function(d, mb3) {
56242
56292
  var t = [];
56243
56293
  for (var i = 0; i < d.length; ++i) {
56244
56294
  if (d[i])
@@ -56271,36 +56321,36 @@ var hTree = function(d, mb) {
56271
56321
  }
56272
56322
  var tr = new u16(maxSym + 1);
56273
56323
  var mbt = ln(t[i1 - 1], tr, 0);
56274
- if (mbt > mb) {
56324
+ if (mbt > mb3) {
56275
56325
  var i = 0, dt = 0;
56276
- var lft = mbt - mb, cst = 1 << lft;
56326
+ var lft = mbt - mb3, cst = 1 << lft;
56277
56327
  t2.sort(function(a, b) {
56278
56328
  return tr[b.s] - tr[a.s] || a.f - b.f;
56279
56329
  });
56280
56330
  for (; i < s; ++i) {
56281
56331
  var i2_1 = t2[i].s;
56282
- if (tr[i2_1] > mb) {
56332
+ if (tr[i2_1] > mb3) {
56283
56333
  dt += cst - (1 << mbt - tr[i2_1]);
56284
- tr[i2_1] = mb;
56334
+ tr[i2_1] = mb3;
56285
56335
  } else
56286
56336
  break;
56287
56337
  }
56288
56338
  dt >>= lft;
56289
56339
  while (dt > 0) {
56290
56340
  var i2_2 = t2[i].s;
56291
- if (tr[i2_2] < mb)
56292
- dt -= 1 << mb - tr[i2_2]++ - 1;
56341
+ if (tr[i2_2] < mb3)
56342
+ dt -= 1 << mb3 - tr[i2_2]++ - 1;
56293
56343
  else
56294
56344
  ++i;
56295
56345
  }
56296
56346
  for (; i >= 0 && dt; --i) {
56297
56347
  var i2_3 = t2[i].s;
56298
- if (tr[i2_3] == mb) {
56348
+ if (tr[i2_3] == mb3) {
56299
56349
  --tr[i2_3];
56300
56350
  ++dt;
56301
56351
  }
56302
56352
  }
56303
- mbt = mb;
56353
+ mbt = mb3;
56304
56354
  }
56305
56355
  return { t: new u8(tr), l: mbt };
56306
56356
  };
@@ -57268,7 +57318,7 @@ function projectsRoot() {
57268
57318
  function archiveRoot() {
57269
57319
  return (0, import_node_path16.join)(projectsRoot(), ".archive");
57270
57320
  }
57271
- var RESERVED_PROJECT_INTERNAL = /(^|[\\/])\.floless-(?:txn|cleanup|tmp|backup|activation)-/i;
57321
+ var RESERVED_PROJECT_INTERNAL = /(^|[\\/])\.floless-(?:txn|cleanup|tmp|backup|activation|refcache)-/i;
57272
57322
  function isReservedProjectInternalPath(path) {
57273
57323
  return RESERVED_PROJECT_INTERNAL.test(path);
57274
57324
  }
@@ -57836,7 +57886,7 @@ function bearingFaces(x, uOnN, vOnN, requestedSide) {
57836
57886
  }
57837
57887
 
57838
57888
  // index.ts
57839
- var import_node_crypto24 = require("node:crypto");
57889
+ var import_node_crypto26 = require("node:crypto");
57840
57890
 
57841
57891
  // ifc-guid.ts
57842
57892
  var import_node_crypto10 = require("node:crypto");
@@ -61556,12 +61606,12 @@ function resolveAppContract(appId, operation, readAppFn) {
61556
61606
  }
61557
61607
  return { kind: "contract", doc };
61558
61608
  }
61559
- function appContractState(appId, app, resolve11 = (id, op, readAppFn) => resolveAppContract(id, op, readAppFn)) {
61609
+ function appContractState(appId, app, resolve12 = (id, op, readAppFn) => resolveAppContract(id, op, readAppFn)) {
61560
61610
  try {
61561
61611
  const baked = bakedContractNode(app);
61562
61612
  if (!baked) return null;
61563
61613
  if (declaredTypeOf(baked.config["takeoff"]) !== STEEL_V2) return null;
61564
- return resolve11(appId, "read", () => app).kind === "project-publication" ? "project-publication" : null;
61614
+ return resolve12(appId, "read", () => app).kind === "project-publication" ? "project-publication" : null;
61565
61615
  } catch (e) {
61566
61616
  if (e instanceof ContractPolicyError) {
61567
61617
  console.warn(`appContractState: "${appId}" has baked contract bytes the policy refuses (${e.code}) \u2014 its card cannot explain the actions that will fail`, e.message);
@@ -62944,6 +62994,7 @@ var REGISTRY = /* @__PURE__ */ new Map([
62944
62994
  ["$.member_styles", { disposition: "issue", note: "line styles are chosen in the editor" }],
62945
62995
  ["$.member_types", { disposition: "issue", note: "the member-type registry is authored in the editor" }],
62946
62996
  ["$.views", { disposition: "issue", note: "saved views are the user's own camera bookmarks" }],
62997
+ ["$.reference_models", { disposition: "issue", note: "a reference model is a file a human chose to overlay, and where they chose to put it \u2014 a read of the drawing can know neither" }],
62947
62998
  ["$.dims3d", { disposition: "issue", note: "3D dimensions are drawn by the user" }],
62948
62999
  ["$.dim_overlays", { disposition: "issue", note: "dimension overlay toggles are editor state" }],
62949
63000
  ["$.dim_style", { disposition: "issue", note: "dimension styling is editor state" }],
@@ -67676,12 +67727,558 @@ function registerSteelPrepassRoute(app, deps) {
67676
67727
  );
67677
67728
  }
67678
67729
 
67730
+ // reference-routes.ts
67731
+ var import_node_crypto20 = require("node:crypto");
67732
+
67733
+ // reference-import.ts
67734
+ var import_node_fs31 = require("node:fs");
67735
+ var import_node_path27 = require("node:path");
67736
+ var AGENT2 = "ifc-reference-reader";
67737
+ var WARN_BYTES = 50 * 1024 * 1024;
67738
+ var MAX_BYTES5 = 150 * 1024 * 1024;
67739
+ var MAX_VERTICES2 = 8e6;
67740
+ var ReferenceImportError = class extends Error {
67741
+ };
67742
+ var mb2 = (bytes) => `${Math.round(bytes / (1024 * 1024))} MB`;
67743
+ function dataUrlBytes(dataUrl) {
67744
+ const marker = ";base64,";
67745
+ const at = String(dataUrl ?? "").indexOf(marker);
67746
+ if (at < 0) return 0;
67747
+ const b64 = String(dataUrl).slice(at + marker.length);
67748
+ if (!b64) return 0;
67749
+ const pad = b64.endsWith("==") ? 2 : b64.endsWith("=") ? 1 : 0;
67750
+ return Math.max(0, Math.floor(b64.length * 3 / 4) - pad);
67751
+ }
67752
+ function assertAcceptable(bytes, name) {
67753
+ if (!Number.isFinite(bytes) || bytes <= 0) {
67754
+ throw new ReferenceImportError(`"${name}" is empty, so there is nothing to load`);
67755
+ }
67756
+ if (bytes > MAX_BYTES5) {
67757
+ throw new ReferenceImportError(
67758
+ `"${name}" is ${mb2(bytes)}; the limit for a reference model is ${mb2(MAX_BYTES5)}. Try exporting just the part of the model you need to see.`
67759
+ );
67760
+ }
67761
+ return { warn: bytes >= WARN_BYTES, bytes };
67762
+ }
67763
+ var OFFSCREEN_SPANS = 1.5;
67764
+ function isOffscreen(refCenter, nativeSpan, nativeCenter = [0, 0, 0]) {
67765
+ if (!refCenter || !(nativeSpan > 0)) return false;
67766
+ return Math.hypot(refCenter[0] - nativeCenter[0], refCenter[1] - nativeCenter[1], refCenter[2] - nativeCenter[2]) > nativeSpan * OFFSCREEN_SPANS;
67767
+ }
67768
+ function renderable(o) {
67769
+ const q = o;
67770
+ return !!q && Array.isArray(q.positions) && Array.isArray(q.indices) && q.positions.length >= 9 && q.indices.length >= 3 && q.positions.length % 3 === 0;
67771
+ }
67772
+ function toReferenceObjects(raw) {
67773
+ if (!raw || !Array.isArray(raw.objects)) {
67774
+ throw new ReferenceImportError("the reference reader returned no objects");
67775
+ }
67776
+ const all = raw.objects;
67777
+ const objects = all.filter(renderable).map((o) => ({
67778
+ id: typeof o.id === "string" ? o.id : "",
67779
+ name: typeof o.name === "string" ? o.name : null,
67780
+ ifcType: typeof o.ifcType === "string" ? o.ifcType : null,
67781
+ storey: typeof o.storey === "string" ? o.storey : null,
67782
+ profile: typeof o.profile === "string" ? o.profile : null,
67783
+ material: typeof o.material === "string" ? o.material : null,
67784
+ positions: o.positions.slice(),
67785
+ indices: o.indices.slice()
67786
+ }));
67787
+ return { objects, dropped: all.length - objects.length };
67788
+ }
67789
+ var REFERENCE_DIR = "references";
67790
+ var SAFE_NAME = /[^A-Za-z0-9._-]+/g;
67791
+ function projectRelativeReferencePath(fileName, taken = /* @__PURE__ */ new Set()) {
67792
+ const raw = String(fileName ?? "").trim();
67793
+ if (!raw) throw new ReferenceImportError("that file has no name");
67794
+ if (/[\\/]/.test(raw) || /^[A-Za-z]:/.test(raw) || raw.includes("..")) {
67795
+ throw new ReferenceImportError("a reference file name may not contain a path");
67796
+ }
67797
+ const safe2 = raw.replace(SAFE_NAME, "_");
67798
+ const dot = safe2.lastIndexOf(".");
67799
+ const stem = dot > 0 ? safe2.slice(0, dot) : safe2;
67800
+ const ext = dot > 0 ? safe2.slice(dot) : "";
67801
+ let candidate = `${REFERENCE_DIR}/${stem}${ext}`;
67802
+ for (let n = 2; taken.has(candidate); n++) candidate = `${REFERENCE_DIR}/${stem}-${n}${ext}`;
67803
+ return candidate;
67804
+ }
67805
+ var readerChain2 = Promise.resolve();
67806
+ function writeReaderApp2(companionId, command, ifcPath) {
67807
+ const dir = appPath(companionId);
67808
+ (0, import_node_fs31.mkdirSync)(dir, { recursive: true });
67809
+ const flo = (0, import_node_path27.join)(dir, `${companionId}.flo`);
67810
+ const lines = [
67811
+ `app: ${companionId}`,
67812
+ "version: 0.1.0",
67813
+ `display-name: ${JSON.stringify(`Reference reader (${command})`)}`,
67814
+ `description: ${JSON.stringify(command === "probe" ? "Check what an IFC file says about itself \u2014 its units, schema, element count and rough extent \u2014 without reading its geometry, so an oversized file can be refused before it is loaded." : "Read a whole IFC file as reference geometry \u2014 every element as a mesh, with the name, type, storey, profile and material the file records for it.")}`,
67815
+ "exposes-as-agent: false",
67816
+ "requires:",
67817
+ ` - ${AGENT2}@0.1.x`,
67818
+ "layout: linear",
67819
+ "nodes:",
67820
+ ` - id: ${command}`,
67821
+ ` agent: ${AGENT2}`,
67822
+ ` command: ${command}`,
67823
+ " config:",
67824
+ ` ifc-path: ${JSON.stringify(ifcPath)}`
67825
+ ];
67826
+ if (command === "read-model") lines.push(` max-vertices: ${MAX_VERTICES2}`);
67827
+ lines.push("");
67828
+ (0, import_node_fs31.writeFileSync)(flo, lines.join("\n"));
67829
+ return flo;
67830
+ }
67831
+ function nodeOutput2(traceText, node) {
67832
+ const events = traceText ? parseTrace(traceText) : [];
67833
+ const ev = [...events].reverse().find((e) => e.kind === "node-output" && e.node === node);
67834
+ const data = ev ? ev.data : null;
67835
+ return data && typeof data === "object" ? data : null;
67836
+ }
67837
+ async function ensureReferenceReader() {
67838
+ try {
67839
+ await aware.ensureAgentInstalled(AGENT2);
67840
+ await aware.ensureConnectionReaderBridge();
67841
+ } catch (e) {
67842
+ throw new ReferenceImportError(
67843
+ `could not set up the reference reader \u2014 check your network and try again${e instanceof Error && e.message ? ` (${e.message})` : ""}`
67844
+ );
67845
+ }
67846
+ }
67847
+ async function runReader2(companionId, command, ifcPath) {
67848
+ const prev = readerChain2;
67849
+ let release;
67850
+ readerChain2 = new Promise((r) => release = r);
67851
+ await prev.catch(() => {
67852
+ });
67853
+ try {
67854
+ const flo = writeReaderApp2(companionId, command, ifcPath);
67855
+ try {
67856
+ await aware.compile(flo);
67857
+ } catch (e) {
67858
+ throw new ReferenceImportError(`could not compile the reference reader: ${e instanceof Error ? e.message : "compile error"}`);
67859
+ }
67860
+ let traceText;
67861
+ try {
67862
+ ({ traceText } = await aware.run(companionId, {}));
67863
+ } catch (e) {
67864
+ const reason = e instanceof AwareError ? String(e.detail?.stderr ?? "").trim() : "";
67865
+ throw new ReferenceImportError(reason || (e instanceof Error ? e.message : "the reference reader failed"));
67866
+ }
67867
+ const out = nodeOutput2(traceText, command);
67868
+ if (!out) throw new ReferenceImportError("the reference reader returned no result");
67869
+ return out;
67870
+ } finally {
67871
+ release();
67872
+ }
67873
+ }
67874
+ async function probeReference(companionId, ifcPath) {
67875
+ await ensureReferenceReader();
67876
+ const out = await runReader2(companionId, "probe", ifcPath);
67877
+ const units = out.units ?? {};
67878
+ const bbox = out.bbox;
67879
+ return {
67880
+ schema: typeof out.schema === "string" ? out.schema : null,
67881
+ units: { declared: typeof units.declared === "string" ? units.declared : null },
67882
+ elements: typeof out.elements === "number" ? out.elements : 0,
67883
+ // null is meaningful here and must survive: it means the reader could not establish an extent, and
67884
+ // a consumer that treated it as a zero box would read "a point at the origin" as fact.
67885
+ bbox: bbox && Array.isArray(bbox.min) && Array.isArray(bbox.max) ? bbox : null
67886
+ };
67887
+ }
67888
+ async function readReferenceModel(companionId, ifcPath) {
67889
+ await ensureReferenceReader();
67890
+ const out = await runReader2(companionId, "read-model", ifcPath);
67891
+ return toReferenceObjects(out);
67892
+ }
67893
+
67894
+ // reference-store.ts
67895
+ var import_node_crypto19 = require("node:crypto");
67896
+ var import_node_fs32 = require("node:fs");
67897
+ var import_promises3 = require("node:stream/promises");
67898
+ var import_node_path28 = require("node:path");
67899
+ function insideProject(projectId, relPath) {
67900
+ const raw = String(relPath ?? "");
67901
+ const m = raw.match(/^references\/([^/\\]+)$/);
67902
+ const name = m ? m[1] : "";
67903
+ if (!name || name === "." || name === "..") {
67904
+ throw new ReferenceImportError("that reference does not name one of its own files, so it cannot be read or removed");
67905
+ }
67906
+ const root4 = realish(projectDir(projectId));
67907
+ const abs = (0, import_node_path28.resolve)(root4, REFERENCE_DIR, name);
67908
+ if (realish((0, import_node_path28.join)(root4, REFERENCE_DIR)) !== (0, import_node_path28.resolve)(root4, REFERENCE_DIR)) {
67909
+ throw new ReferenceImportError("this project\u2019s references folder is a link to somewhere else, so it will not be written to");
67910
+ }
67911
+ if (!abs.startsWith(root4 + import_node_path28.sep)) {
67912
+ throw new ReferenceImportError("that reference points outside its project, so it cannot be read or removed");
67913
+ }
67914
+ return abs;
67915
+ }
67916
+ function realish(p) {
67917
+ try {
67918
+ return import_node_fs32.realpathSync.native((0, import_node_path28.resolve)(p));
67919
+ } catch {
67920
+ return (0, import_node_path28.resolve)(p);
67921
+ }
67922
+ }
67923
+ var cachePath2 = (projectId, refId2) => (0, import_node_path28.join)(projectDir(projectId), `.floless-refcache-${safeId2(refId2)}.json`);
67924
+ function safeId2(refId2) {
67925
+ const s = String(refId2 ?? "").replace(/[^A-Za-z0-9._-]+/g, "_");
67926
+ if (!s || s === "." || s === "..") throw new ReferenceImportError("that reference has an unusable id");
67927
+ return s;
67928
+ }
67929
+ async function hashFile(path) {
67930
+ const h = (0, import_node_crypto19.createHash)("sha256");
67931
+ await (0, import_promises3.pipeline)((0, import_node_fs32.createReadStream)(path), h);
67932
+ return h.digest("hex");
67933
+ }
67934
+ function copyOriginal(projectId, relPath, sourceAbs, tag) {
67935
+ const abs = insideProject(projectId, relPath);
67936
+ (0, import_node_fs32.mkdirSync)((0, import_node_path28.dirname)(abs), { recursive: true });
67937
+ const tmp = `${abs}.${safeId2(tag)}.part`;
67938
+ (0, import_node_fs32.copyFileSync)(sourceAbs, tmp);
67939
+ (0, import_node_fs32.renameSync)(tmp, abs);
67940
+ return abs;
67941
+ }
67942
+ function referenceFilesOnDisk(projectId) {
67943
+ try {
67944
+ return (0, import_node_fs32.readdirSync)((0, import_node_path28.join)(projectDir(projectId), REFERENCE_DIR)).map((f) => `${REFERENCE_DIR}/${f}`);
67945
+ } catch (e) {
67946
+ if (e.code === "ENOENT") return [];
67947
+ throw new ReferenceImportError(
67948
+ "could not check which reference files this project already holds, so a new one cannot safely be named \u2014 check the project folder is readable"
67949
+ );
67950
+ }
67951
+ }
67952
+ function originalPath(projectId, relPath) {
67953
+ const abs = insideProject(projectId, relPath);
67954
+ return (0, import_node_fs32.existsSync)(abs) ? abs : null;
67955
+ }
67956
+ function writeCache2(projectId, refId2, cache2) {
67957
+ const p = cachePath2(projectId, refId2);
67958
+ const tmp = `${p}.part`;
67959
+ (0, import_node_fs32.writeFileSync)(tmp, JSON.stringify(cache2));
67960
+ (0, import_node_fs32.renameSync)(tmp, p);
67961
+ }
67962
+ function cachedGeometry(projectId, refId2, expectHash) {
67963
+ const p = cachePath2(projectId, refId2);
67964
+ if (!(0, import_node_fs32.existsSync)(p)) return null;
67965
+ try {
67966
+ const parsed = JSON.parse((0, import_node_fs32.readFileSync)(p, "utf8"));
67967
+ if (!parsed || parsed.v !== 1 || !Array.isArray(parsed.objects)) return null;
67968
+ if (parsed.sourceHash !== expectHash) return null;
67969
+ return parsed;
67970
+ } catch {
67971
+ return null;
67972
+ }
67973
+ }
67974
+ function dropCache(projectId, refId2) {
67975
+ (0, import_node_fs32.rmSync)(cachePath2(projectId, refId2), { force: true });
67976
+ }
67977
+ function removeReference(projectId, refId2, relPath) {
67978
+ dropCache(projectId, refId2);
67979
+ if (relPath) (0, import_node_fs32.rmSync)(insideProject(projectId, relPath), { force: true });
67980
+ }
67981
+ function takenReferencePaths(refs) {
67982
+ return new Set((refs ?? []).map((r) => r.file).filter((f) => typeof f === "string"));
67983
+ }
67984
+
67985
+ // reference-routes.ts
67986
+ var APPID = /^[a-z0-9][a-z0-9._-]*$/i;
67987
+ var REFERENCE_BODY_LIMIT = 210 * 1024 * 1024;
67988
+ var companion = (appId) => `${appId}-refimport`;
67989
+ var ReferenceLockedError = class extends Error {
67990
+ constructor(refName2) {
67991
+ super(`"${refName2}" is locked \u2014 unlock it in the Reference models panel to remove it`);
67992
+ this.refName = refName2;
67993
+ }
67994
+ refName;
67995
+ };
67996
+ function gate2(deps, appId, project) {
67997
+ const refuse2 = (status, error, code) => ({ ok: false, refusal: { status, body: { ok: false, error, ...code ? { code } : {} } } });
67998
+ if (!appId || !APPID.test(appId)) return refuse2(400, "a valid appId is required");
67999
+ if (!project) return refuse2(400, "reference models are project-scoped, so a project is required");
68000
+ const p = deps.getProject(project);
68001
+ if (!p) return refuse2(404, `unknown project: ${project}`);
68002
+ if (p.app !== appId) return refuse2(404, `project "${project}" belongs to app "${p.app}", not "${appId}"`);
68003
+ const doc = readAcceptedForRequest(appId, project);
68004
+ if (doc == null) return refuse2(404, "this project has no model yet, so there is nothing to reference against");
68005
+ if (declaredTypeOf(doc) !== STEEL_V2) {
68006
+ return refuse2(
68007
+ 409,
68008
+ "reference models need the model-level contract. Migrate this project first (Model \u25B8 Migrate to the model-level contract), then insert the reference.",
68009
+ "reference-requires-v2"
68010
+ );
68011
+ }
68012
+ return { ok: true, appId, project, doc };
68013
+ }
68014
+ function verdictFor(probe, nativeSpan, nativeCenter) {
68015
+ if (typeof nativeSpan !== "number" || !Number.isFinite(nativeSpan) || nativeSpan <= 0) return null;
68016
+ if (!probe.bbox) return null;
68017
+ const { min, max: max2 } = probe.bbox;
68018
+ const refCenter = [(min[0] + max2[0]) / 2, (min[1] + max2[1]) / 2, (min[2] + max2[2]) / 2];
68019
+ const centre = Array.isArray(nativeCenter) && nativeCenter.length === 3 && nativeCenter.every((n) => typeof n === "number" && Number.isFinite(n)) ? nativeCenter : void 0;
68020
+ return { factor: null, offscreen: isOffscreen(refCenter, nativeSpan, centre) };
68021
+ }
68022
+ function spanOf(objects) {
68023
+ let lo = [Infinity, Infinity, Infinity];
68024
+ let hi = [-Infinity, -Infinity, -Infinity];
68025
+ for (const o of objects) {
68026
+ const p = o.positions;
68027
+ for (let i = 0; i + 2 < p.length; i += 3) {
68028
+ for (let a = 0; a < 3; a++) {
68029
+ const v = p[i + a];
68030
+ if (!Number.isFinite(v)) continue;
68031
+ if (v < lo[a]) lo[a] = v;
68032
+ if (v > hi[a]) hi[a] = v;
68033
+ }
68034
+ }
68035
+ }
68036
+ const span = Math.max(hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]);
68037
+ return Number.isFinite(span) && span > 0 ? span : 0;
68038
+ }
68039
+ function referencesOf(doc) {
68040
+ const refs = doc.reference_models;
68041
+ return Array.isArray(refs) ? refs : [];
68042
+ }
68043
+ function importRefusal(e) {
68044
+ if (e instanceof ReferenceImportError || e instanceof VisualInputError) {
68045
+ return { status: 400, body: { ok: false, error: e.message } };
68046
+ }
68047
+ return null;
68048
+ }
68049
+ function registerReferenceRoutes(app, deps) {
68050
+ app.post(
68051
+ "/api/steel/:appId/reference/probe",
68052
+ { bodyLimit: REFERENCE_BODY_LIMIT },
68053
+ async (req, reply) => {
68054
+ const g = gate2(deps, req.params.appId, req.query.project);
68055
+ if (!g.ok) return reply.status(g.refusal.status).send(g.refusal.body);
68056
+ const { dataUrl, name } = req.body ?? {};
68057
+ if (!dataUrl) return reply.status(400).send({ ok: false, error: "an IFC file is required" });
68058
+ const displayName = String(name || "model.ifc");
68059
+ let stored;
68060
+ let warn = false;
68061
+ try {
68062
+ ({ warn } = assertAcceptable(dataUrlBytes(dataUrl), displayName));
68063
+ stored = storeIfcInput(g.appId, dataUrl, MAX_BYTES5);
68064
+ } catch (e) {
68065
+ const r = importRefusal(e);
68066
+ if (r) return reply.status(r.status).send(r.body);
68067
+ throw e;
68068
+ }
68069
+ let done = false;
68070
+ req.raw.on("close", () => {
68071
+ if (!done && deps.runControl.isRunActive()) deps.runControl.cancelActiveRun();
68072
+ });
68073
+ try {
68074
+ const probe = await deps.reader.probe(companion(g.appId), stored.path);
68075
+ return { ok: true, sha: stored.sha256, bytes: stored.bytes, warn, probe, verdict: verdictFor(probe, req.body?.nativeSpan, req.body?.nativeCenter) };
68076
+ } catch (e) {
68077
+ const r = importRefusal(e);
68078
+ if (r) return reply.status(r.status).send(r.body);
68079
+ app.log.error({ appId: g.appId, err: e instanceof Error ? e.message : e }, "reference probe failed");
68080
+ return reply.status(500).send({ ok: false, error: "could not read that IFC file" });
68081
+ } finally {
68082
+ done = true;
68083
+ }
68084
+ }
68085
+ );
68086
+ app.post(
68087
+ "/api/steel/:appId/reference",
68088
+ async (req, reply) => {
68089
+ const g = gate2(deps, req.params.appId, req.query.project);
68090
+ if (!g.ok) return reply.status(g.refusal.status).send(g.refusal.body);
68091
+ const { sha, name, placement } = req.body ?? {};
68092
+ if (!sha) return reply.status(400).send({ ok: false, error: "probe the file first \u2014 its sha is required" });
68093
+ const source = ifcInputPath(g.appId, sha);
68094
+ if (!source) {
68095
+ return reply.status(404).send({ ok: false, error: "the uploaded IFC is no longer available \u2014 drop the file again" });
68096
+ }
68097
+ const displayName = String(name || "model.ifc");
68098
+ const id = (0, import_node_crypto20.randomUUID)();
68099
+ let rel;
68100
+ try {
68101
+ rel = await withLifecycleLock("project", g.project, () => {
68102
+ const doc = readAcceptedForRequest(g.appId, g.project);
68103
+ const taken = takenReferencePaths(referencesOf(doc ?? {}));
68104
+ for (const f of referenceFilesOnDisk(g.project)) taken.add(f);
68105
+ const claimed2 = projectRelativeReferencePath(displayName, taken);
68106
+ copyOriginal(g.project, claimed2, source, id);
68107
+ return claimed2;
68108
+ });
68109
+ } catch (e) {
68110
+ const r = importRefusal(e);
68111
+ if (r) return reply.status(r.status).send(r.body);
68112
+ throw e;
68113
+ }
68114
+ let committed = false;
68115
+ const rollback = () => {
68116
+ if (committed) return;
68117
+ try {
68118
+ removeReference(g.project, id, rel);
68119
+ } catch (e) {
68120
+ app.log.error({ project: g.project, id, rel, err: e instanceof Error ? e.message : e }, "reference rollback failed \u2014 an orphaned original is left on disk");
68121
+ }
68122
+ };
68123
+ let done = false;
68124
+ req.raw.on("close", () => {
68125
+ if (!done && deps.runControl.isRunActive()) deps.runControl.cancelActiveRun();
68126
+ });
68127
+ try {
68128
+ const abs = originalPath(g.project, rel);
68129
+ if (!abs) throw new ReferenceImportError("the copied file vanished before it could be read");
68130
+ const probe = await deps.reader.probe(companion(g.appId), abs);
68131
+ const sourceHash = await hashFile(abs);
68132
+ const geometry = await deps.reader.readModel(companion(g.appId), abs);
68133
+ if (!geometry.objects.length) {
68134
+ rollback();
68135
+ return reply.status(400).send({ ok: false, error: `"${displayName}" has no geometry we can draw` });
68136
+ }
68137
+ writeCache2(g.project, id, { v: 1, sourceHash, dropped: geometry.dropped, objects: geometry.objects });
68138
+ const entry2 = {
68139
+ id,
68140
+ file: rel,
68141
+ name: displayName,
68142
+ ...placement ? { placement } : {},
68143
+ units: { declared: probe.units.declared, override: null },
68144
+ // Half-opacity by default, because a reference that arrives looking like our own steel is the
68145
+ // one mistake this feature must never make.
68146
+ display: { visible: true, opacity: 0.5, locked: false, snap: true }
68147
+ };
68148
+ const etag = await withLifecycleLock("project", g.project, async () => {
68149
+ const current = readAcceptedForRequest(g.appId, g.project);
68150
+ if (current == null) throw new ReferenceImportError("this project has no model to attach a reference to");
68151
+ const next = { ...current, reference_models: [...referencesOf(current), entry2] };
68152
+ const written = await writeContractChecked(g.appId, next, g.project, {
68153
+ origin: "internal",
68154
+ why: "inserting a reference model appends one entry under a fresh id, so it depends on no version the caller read"
68155
+ });
68156
+ return written.etag;
68157
+ });
68158
+ committed = true;
68159
+ deps.broadcast(contractChangedEvent(g.appId, g.project, etag, req.headers["x-floless-mutation-id"]));
68160
+ return { ok: true, etag, reference: entry2, objects: geometry.objects, dropped: geometry.dropped, spanMm: spanOf(geometry.objects) };
68161
+ } catch (e) {
68162
+ rollback();
68163
+ const r = importRefusal(e);
68164
+ if (r) return reply.status(r.status).send(r.body);
68165
+ if (e instanceof ContractError) {
68166
+ return reply.status(400).send({ ok: false, error: e.message, ...e.code ? { code: e.code } : {} });
68167
+ }
68168
+ app.log.error({ appId: g.appId, err: e instanceof Error ? e.message : e }, "reference insert failed");
68169
+ return reply.status(500).send({ ok: false, error: "could not load that reference model" });
68170
+ } finally {
68171
+ done = true;
68172
+ }
68173
+ }
68174
+ );
68175
+ app.get(
68176
+ "/api/steel/:appId/reference/:id/geometry",
68177
+ async (req, reply) => {
68178
+ const g = gate2(deps, req.params.appId, req.query.project);
68179
+ if (!g.ok) return reply.status(g.refusal.status).send(g.refusal.body);
68180
+ const entry2 = referencesOf(g.doc).find((r) => r.id === req.params.id);
68181
+ if (!entry2) return reply.status(404).send({ ok: false, error: "no such reference model" });
68182
+ const abs = entry2.file ? originalPath(g.project, entry2.file) : null;
68183
+ if (!abs) {
68184
+ return reply.status(409).send({
68185
+ ok: false,
68186
+ code: "reference-unresolved",
68187
+ error: `"${entry2.name}" is missing from this project \u2014 relink it to the file on your disk and its position is restored`
68188
+ });
68189
+ }
68190
+ let sourceHash;
68191
+ try {
68192
+ sourceHash = await hashFile(abs);
68193
+ } catch {
68194
+ return reply.status(409).send({ ok: false, code: "reference-unresolved", error: `"${entry2.name}" could not be read` });
68195
+ }
68196
+ const hit = cachedGeometry(g.project, entry2.id, sourceHash);
68197
+ if (hit) return { ok: true, cached: true, objects: hit.objects, dropped: hit.dropped, spanMm: spanOf(hit.objects) };
68198
+ let done = false;
68199
+ req.raw.on("close", () => {
68200
+ if (!done && deps.runControl.isRunActive()) deps.runControl.cancelActiveRun();
68201
+ });
68202
+ try {
68203
+ const geometry = await deps.reader.readModel(companion(g.appId), abs);
68204
+ if (!geometry.objects.length) {
68205
+ return reply.status(409).send({
68206
+ ok: false,
68207
+ code: "reference-empty",
68208
+ error: `"${entry2.name}" was read, but produced nothing we can draw` + (geometry.dropped ? ` (${geometry.dropped} object${geometry.dropped === 1 ? "" : "s"} had no usable mesh)` : "") + ". The file may be a newer IFC flavour than the reader handles."
68209
+ });
68210
+ }
68211
+ writeCache2(g.project, entry2.id, { v: 1, sourceHash, dropped: geometry.dropped, objects: geometry.objects });
68212
+ return { ok: true, cached: false, objects: geometry.objects, dropped: geometry.dropped, spanMm: spanOf(geometry.objects) };
68213
+ } catch (e) {
68214
+ const r = importRefusal(e);
68215
+ if (r) return reply.status(r.status).send(r.body);
68216
+ app.log.error({ appId: g.appId, id: entry2.id, err: e instanceof Error ? e.message : e }, "reference rebuild failed");
68217
+ return reply.status(500).send({ ok: false, error: `could not re-read "${entry2.name}"` });
68218
+ } finally {
68219
+ done = true;
68220
+ }
68221
+ }
68222
+ );
68223
+ app.delete(
68224
+ "/api/steel/:appId/reference/:id",
68225
+ async (req, reply) => {
68226
+ const g = gate2(deps, req.params.appId, req.query.project);
68227
+ if (!g.ok) return reply.status(g.refusal.status).send(g.refusal.body);
68228
+ const entry2 = referencesOf(g.doc).find((r) => r.id === req.params.id);
68229
+ if (!entry2) return reply.status(404).send({ ok: false, error: "no such reference model" });
68230
+ if (entry2.display?.locked) {
68231
+ return reply.status(409).send({
68232
+ ok: false,
68233
+ code: "reference-locked",
68234
+ error: `"${entry2.name}" is locked \u2014 unlock it in the Reference models panel to remove it`
68235
+ });
68236
+ }
68237
+ try {
68238
+ const etag = await withLifecycleLock("project", g.project, async () => {
68239
+ const current = readAcceptedForRequest(g.appId, g.project);
68240
+ if (current == null) throw new ReferenceImportError("this project has no model");
68241
+ const now = referencesOf(current).find((r) => r.id === entry2.id);
68242
+ if (now?.display?.locked) throw new ReferenceLockedError(now.name || entry2.name);
68243
+ const kept = referencesOf(current).filter((r) => r.id !== entry2.id);
68244
+ const next = { ...current, reference_models: kept };
68245
+ const written = await writeContractChecked(g.appId, next, g.project, {
68246
+ origin: "internal",
68247
+ why: "removing a reference model drops one entry by id, so it depends on no version the caller read"
68248
+ });
68249
+ return written.etag;
68250
+ });
68251
+ try {
68252
+ removeReference(g.project, entry2.id, entry2.file ?? null);
68253
+ } catch (e) {
68254
+ app.log.error(
68255
+ { project: g.project, id: entry2.id, file: entry2.file, err: e instanceof Error ? e.message : e },
68256
+ "reference removed from the contract, but its bytes could not be deleted \u2014 an orphan is left on disk"
68257
+ );
68258
+ }
68259
+ deps.broadcast(contractChangedEvent(g.appId, g.project, etag, req.headers["x-floless-mutation-id"]));
68260
+ return { ok: true, etag };
68261
+ } catch (e) {
68262
+ if (e instanceof ReferenceLockedError) {
68263
+ return reply.status(409).send({ ok: false, code: "reference-locked", error: e.message });
68264
+ }
68265
+ const r = importRefusal(e);
68266
+ if (r) return reply.status(r.status).send(r.body);
68267
+ if (e instanceof ContractError) {
68268
+ return reply.status(400).send({ ok: false, error: e.message, ...e.code ? { code: e.code } : {} });
68269
+ }
68270
+ throw e;
68271
+ }
68272
+ }
68273
+ );
68274
+ }
68275
+
67679
68276
  // bom-export.ts
67680
68277
  var import_node_os17 = require("node:os");
67681
- var import_node_path27 = require("node:path");
68278
+ var import_node_path29 = require("node:path");
67682
68279
 
67683
68280
  // node_modules/write-excel-file/modules/export/writeXlsxFileNode.js
67684
- var import_node_fs31 = __toESM(require("node:fs"), 1);
68281
+ var import_node_fs33 = __toESM(require("node:fs"), 1);
67685
68282
 
67686
68283
  // node_modules/write-excel-file/modules/xlsx/helpers/features/getAdditionalContent.js
67687
68284
  function _createForOfIteratorHelperLoose(r, e) {
@@ -70686,13 +71283,13 @@ function convertFileContentToUint8Array(fileContent) {
70686
71283
  throw new Error("Unsupported file content type. Expected a `Stream`, a `Blob` or a `Buffer`");
70687
71284
  }
70688
71285
  function streamToUint8Array(stream) {
70689
- return new Promise(function(resolve11, reject) {
71286
+ return new Promise(function(resolve12, reject) {
70690
71287
  var chunks = [];
70691
71288
  stream.on("data", function(chunk) {
70692
71289
  chunks.push(chunk);
70693
71290
  });
70694
71291
  stream.on("end", function() {
70695
- resolve11(import_node_buffer.Buffer.concat(chunks));
71292
+ resolve12(import_node_buffer.Buffer.concat(chunks));
70696
71293
  });
70697
71294
  stream.on("error", reject);
70698
71295
  });
@@ -70781,26 +71378,26 @@ function writeXlsxFile(arg1, arg2, arg3) {
70781
71378
  },
70782
71379
  toFile: function toFile(filePath) {
70783
71380
  return createReadableStream().then(function(readableStream) {
70784
- return pipe(readableStream, import_node_fs31.default.createWriteStream(filePath));
71381
+ return pipe(readableStream, import_node_fs33.default.createWriteStream(filePath));
70785
71382
  });
70786
71383
  }
70787
71384
  };
70788
71385
  }
70789
71386
  function convertStreamToBuffer(stream) {
70790
- return new Promise(function(resolve11, reject) {
71387
+ return new Promise(function(resolve12, reject) {
70791
71388
  var chunks = [];
70792
71389
  stream.on("data", function(chunk) {
70793
71390
  chunks.push(chunk);
70794
71391
  });
70795
71392
  stream.on("end", function() {
70796
- resolve11(Buffer.concat(chunks));
71393
+ resolve12(Buffer.concat(chunks));
70797
71394
  });
70798
71395
  stream.on("error", reject);
70799
71396
  });
70800
71397
  }
70801
71398
  function pipe(readableStream, writableStream) {
70802
- return new Promise(function(resolve11, reject) {
70803
- readableStream.pipe(writableStream).on("finish", resolve11).on("error", reject);
71399
+ return new Promise(function(resolve12, reject) {
71400
+ readableStream.pipe(writableStream).on("finish", resolve12).on("error", reject);
70804
71401
  });
70805
71402
  }
70806
71403
 
@@ -71078,8 +71675,8 @@ var BOM_EXPORT_KIND = {
71078
71675
  html: "bom-html"
71079
71676
  };
71080
71677
  function bomExportPath(appId, format) {
71081
- const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path27.join)((0, import_node_os17.homedir)(), ".floless");
71082
- return (0, import_node_path27.join)(root4, "exports", appId, `${appId}-bom.${format}`);
71678
+ const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path29.join)((0, import_node_os17.homedir)(), ".floless");
71679
+ return (0, import_node_path29.join)(root4, "exports", appId, `${appId}-bom.${format}`);
71083
71680
  }
71084
71681
  function csvField(v) {
71085
71682
  let s = String(v);
@@ -71168,9 +71765,9 @@ function appExportSource(deps, resolved, appId, action, reply) {
71168
71765
  }
71169
71766
  }
71170
71767
  async function projectExportSource(deps, appId, project, reply) {
71171
- const gate2 = deps.projectExportGate(appId, project);
71172
- if (gate2) {
71173
- reply.status(gate2.status).send({ ok: false, error: gate2.error });
71768
+ const gate3 = deps.projectExportGate(appId, project);
71769
+ if (gate3) {
71770
+ reply.status(gate3.status).send({ ok: false, error: gate3.error });
71174
71771
  return null;
71175
71772
  }
71176
71773
  let snapshot;
@@ -71257,8 +71854,8 @@ function registerContractAccessRoutes(app, deps) {
71257
71854
  return deps.withLifecycleLock(project ? "project" : "app", project || appId, async () => {
71258
71855
  let input;
71259
71856
  if (project) {
71260
- const gate2 = deps.projectExportGate(appId, project);
71261
- if (gate2) return reply.status(gate2.status).send({ ok: false, error: gate2.error });
71857
+ const gate3 = deps.projectExportGate(appId, project);
71858
+ if (gate3) return reply.status(gate3.status).send({ ok: false, error: gate3.error });
71262
71859
  let snapshot;
71263
71860
  try {
71264
71861
  snapshot = deps.currentApprovedSnapshot(project);
@@ -71288,8 +71885,8 @@ function registerContractAccessRoutes(app, deps) {
71288
71885
  return reply.status(400).send({ ok: false, error: `invalid appId: ${appId}` });
71289
71886
  }
71290
71887
  if (project) {
71291
- const gate2 = deps.projectExportGate(appId, project);
71292
- if (gate2) return reply.status(gate2.status).send({ ok: false, error: gate2.error });
71888
+ const gate3 = deps.projectExportGate(appId, project);
71889
+ if (gate3) return reply.status(gate3.status).send({ ok: false, error: gate3.error });
71293
71890
  let snapshot;
71294
71891
  try {
71295
71892
  snapshot = deps.currentApprovedSnapshot(project);
@@ -71437,8 +72034,8 @@ function replyLifecycleLockBusyError(error, logger, reply) {
71437
72034
  }
71438
72035
 
71439
72036
  // project-export-files.ts
71440
- var import_node_fs32 = require("node:fs");
71441
- var import_node_path28 = require("node:path");
72037
+ var import_node_fs34 = require("node:fs");
72038
+ var import_node_path30 = require("node:path");
71442
72039
  function projectExportFiles(appId, kindOf2 = appId) {
71443
72040
  if (kindOf2 === "vectorize") {
71444
72041
  return [{ kind: "svg", filename: `${appId}.svg` }];
@@ -71467,26 +72064,26 @@ function exportFileBase(projectId, appId, now = /* @__PURE__ */ new Date()) {
71467
72064
  }
71468
72065
  function uniqueProjectExportFilename(projectId, preferred) {
71469
72066
  const dir = projectExportsDir(projectId);
71470
- if (!(0, import_node_fs32.existsSync)((0, import_node_path28.join)(dir, preferred))) return preferred;
71471
- const extension = (0, import_node_path28.extname)(preferred);
72067
+ if (!(0, import_node_fs34.existsSync)((0, import_node_path30.join)(dir, preferred))) return preferred;
72068
+ const extension = (0, import_node_path30.extname)(preferred);
71472
72069
  const stem = preferred.slice(0, preferred.length - extension.length);
71473
72070
  for (let suffix = 2; suffix <= 9999; suffix += 1) {
71474
72071
  const candidate = `${stem}-${suffix}${extension}`;
71475
- if (!(0, import_node_fs32.existsSync)((0, import_node_path28.join)(dir, candidate))) return candidate;
72072
+ if (!(0, import_node_fs34.existsSync)((0, import_node_path30.join)(dir, candidate))) return candidate;
71476
72073
  }
71477
72074
  throw new Error("could not allocate a unique project export filename");
71478
72075
  }
71479
72076
 
71480
72077
  // project-export-receipts.ts
71481
- var import_node_crypto19 = require("node:crypto");
71482
- var import_node_fs33 = require("node:fs");
71483
- var import_node_path30 = require("node:path");
72078
+ var import_node_crypto21 = require("node:crypto");
72079
+ var import_node_fs35 = require("node:fs");
72080
+ var import_node_path32 = require("node:path");
71484
72081
 
71485
72082
  // safe-filename.ts
71486
- var import_node_path29 = require("node:path");
72083
+ var import_node_path31 = require("node:path");
71487
72084
  var WINDOWS_DEVICE = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i;
71488
72085
  function isPortablePlainFilename(name) {
71489
- return !!name && (0, import_node_path29.basename)(name) === name && name !== "." && name !== ".." && !/[\\/\u0000-\u001f\u007f<>:"|?*]/.test(name) && !/[. ]$/.test(name) && !WINDOWS_DEVICE.test(name) && Buffer.byteLength(name, "utf8") <= 255;
72086
+ return !!name && (0, import_node_path31.basename)(name) === name && name !== "." && name !== ".." && !/[\\/\u0000-\u001f\u007f<>:"|?*]/.test(name) && !/[. ]$/.test(name) && !WINDOWS_DEVICE.test(name) && Buffer.byteLength(name, "utf8") <= 255;
71490
72087
  }
71491
72088
 
71492
72089
  // project-export-receipts.ts
@@ -71506,21 +72103,21 @@ var EXTENSIONS = {
71506
72103
  "render-mp4": ".mp4"
71507
72104
  };
71508
72105
  var RESERVED2 = /^\.floless-(?:txn|cleanup|tmp|backup)-/i;
71509
- var projectExportIndexPath = (projectId) => (0, import_node_path30.join)(projectExportsDir(projectId), "index.json");
72106
+ var projectExportIndexPath = (projectId) => (0, import_node_path32.join)(projectExportsDir(projectId), "index.json");
71510
72107
  function hash(bytes) {
71511
- return (0, import_node_crypto19.createHash)("sha256").update(bytes).digest("hex");
72108
+ return (0, import_node_crypto21.createHash)("sha256").update(bytes).digest("hex");
71512
72109
  }
71513
72110
  function proof(bytes) {
71514
72111
  return bytes ? { exists: true, bytes: bytes.length, sha256: hash(bytes) } : { exists: false, bytes: 0, sha256: null };
71515
72112
  }
71516
72113
  function readFileProof(path) {
71517
- return (0, import_node_fs33.existsSync)(path) ? proof((0, import_node_fs33.readFileSync)(path)) : proof(null);
72114
+ return (0, import_node_fs35.existsSync)(path) ? proof((0, import_node_fs35.readFileSync)(path)) : proof(null);
71518
72115
  }
71519
72116
  function fileProofEquals(a, b) {
71520
72117
  return a.exists === b.exists && a.bytes === b.bytes && a.sha256 === b.sha256;
71521
72118
  }
71522
72119
  function validReceiptFilename(kind, filename) {
71523
- if (!isPortablePlainFilename(filename) || filename === "index.json" || RESERVED2.test(filename) || (0, import_node_path30.basename)(filename) !== filename) return false;
72120
+ if (!isPortablePlainFilename(filename) || filename === "index.json" || RESERVED2.test(filename) || (0, import_node_path32.basename)(filename) !== filename) return false;
71524
72121
  return filename.toLowerCase().endsWith(EXTENSIONS[kind]);
71525
72122
  }
71526
72123
  function isExportKind(v) {
@@ -71613,45 +72210,45 @@ function indexBytes(body) {
71613
72210
  `, "utf8");
71614
72211
  }
71615
72212
  function syncFile(path) {
71616
- const fd2 = (0, import_node_fs33.openSync)(path, "r+");
72213
+ const fd2 = (0, import_node_fs35.openSync)(path, "r+");
71617
72214
  try {
71618
- (0, import_node_fs33.fsyncSync)(fd2);
72215
+ (0, import_node_fs35.fsyncSync)(fd2);
71619
72216
  } finally {
71620
- (0, import_node_fs33.closeSync)(fd2);
72217
+ (0, import_node_fs35.closeSync)(fd2);
71621
72218
  }
71622
72219
  }
71623
72220
  function syncDirectory(path) {
71624
72221
  try {
71625
- const fd2 = (0, import_node_fs33.openSync)(path, "r");
72222
+ const fd2 = (0, import_node_fs35.openSync)(path, "r");
71626
72223
  try {
71627
- (0, import_node_fs33.fsyncSync)(fd2);
72224
+ (0, import_node_fs35.fsyncSync)(fd2);
71628
72225
  } finally {
71629
- (0, import_node_fs33.closeSync)(fd2);
72226
+ (0, import_node_fs35.closeSync)(fd2);
71630
72227
  }
71631
72228
  } catch {
71632
72229
  }
71633
72230
  }
71634
72231
  function durableReplace(path, bytes) {
71635
- const dir = (0, import_node_path30.dirname)(path);
71636
- (0, import_node_fs33.mkdirSync)(dir, { recursive: true });
71637
- const tmp = (0, import_node_path30.join)(dir, `.floless-tmp-receipt-${(0, import_node_crypto19.randomUUID)()}`);
72232
+ const dir = (0, import_node_path32.dirname)(path);
72233
+ (0, import_node_fs35.mkdirSync)(dir, { recursive: true });
72234
+ const tmp = (0, import_node_path32.join)(dir, `.floless-tmp-receipt-${(0, import_node_crypto21.randomUUID)()}`);
71638
72235
  try {
71639
- (0, import_node_fs33.writeFileSync)(tmp, bytes, { flag: "wx" });
72236
+ (0, import_node_fs35.writeFileSync)(tmp, bytes, { flag: "wx" });
71640
72237
  syncFile(tmp);
71641
- (0, import_node_fs33.renameSync)(tmp, path);
72238
+ (0, import_node_fs35.renameSync)(tmp, path);
71642
72239
  syncFile(path);
71643
72240
  syncDirectory(dir);
71644
72241
  } finally {
71645
72242
  try {
71646
- (0, import_node_fs33.rmSync)(tmp, { force: true });
72243
+ (0, import_node_fs35.rmSync)(tmp, { force: true });
71647
72244
  } catch {
71648
72245
  }
71649
72246
  }
71650
72247
  }
71651
72248
  function strictCurrent(projectId) {
71652
72249
  const path = projectExportIndexPath(projectId);
71653
- if (!(0, import_node_fs33.existsSync)(path)) return { bytes: null, body: { exports: [], opaque: [] } };
71654
- const bytes = (0, import_node_fs33.readFileSync)(path);
72250
+ if (!(0, import_node_fs35.existsSync)(path)) return { bytes: null, body: { exports: [], opaque: [] } };
72251
+ const bytes = (0, import_node_fs35.readFileSync)(path);
71655
72252
  return { bytes, body: parseIndexBytes(bytes) };
71656
72253
  }
71657
72254
  function listProjectExportReceipts(projectId) {
@@ -71663,14 +72260,14 @@ function listProjectExportReceipts(projectId) {
71663
72260
  }
71664
72261
  function resolveProjectExportReceiptPath(projectId, receipt) {
71665
72262
  if (!validReceiptFilename(receipt.kind, receipt.filename)) return null;
71666
- const dir = (0, import_node_path30.resolve)(projectExportsDir(projectId));
71667
- const path = (0, import_node_path30.resolve)(dir, receipt.filename);
71668
- return (0, import_node_path30.dirname)(path) === dir ? path : null;
72263
+ const dir = (0, import_node_path32.resolve)(projectExportsDir(projectId));
72264
+ const path = (0, import_node_path32.resolve)(dir, receipt.filename);
72265
+ return (0, import_node_path32.dirname)(path) === dir ? path : null;
71669
72266
  }
71670
72267
  function prepareProjectExport(projectId, receipt) {
71671
72268
  validateInput(receipt);
71672
72269
  const dir = projectExportsDir(projectId);
71673
- (0, import_node_fs33.mkdirSync)(dir, { recursive: true });
72270
+ (0, import_node_fs35.mkdirSync)(dir, { recursive: true });
71674
72271
  const current = strictCurrent(projectId);
71675
72272
  const key = receiptKey(receipt.kind, receipt.variant);
71676
72273
  const prior = current.body.exports.find((row) => receiptKey(row.kind, row.variant) === key) ?? null;
@@ -71739,8 +72336,8 @@ function restoreProjectExportTransition(transition) {
71739
72336
  }
71740
72337
  durableReplace(transition.indexPath, Buffer.from(transition.beforeBytesBase64, "base64"));
71741
72338
  } else {
71742
- (0, import_node_fs33.rmSync)(transition.indexPath, { force: true });
71743
- syncDirectory((0, import_node_path30.dirname)(transition.indexPath));
72339
+ (0, import_node_fs35.rmSync)(transition.indexPath, { force: true });
72340
+ syncDirectory((0, import_node_path32.dirname)(transition.indexPath));
71744
72341
  }
71745
72342
  if (!currentMatches(transition.indexPath, transition.before)) {
71746
72343
  throw new ProjectExportReceiptError("project export index did not match the restored proof.");
@@ -71762,8 +72359,8 @@ function cleanupSupersededProjectExport(transition) {
71762
72359
  const path = resolveProjectExportReceiptPath(transition.projectId, superseded);
71763
72360
  if (!path) return;
71764
72361
  try {
71765
- (0, import_node_fs33.rmSync)(path, { force: true });
71766
- syncDirectory((0, import_node_path30.dirname)(path));
72362
+ (0, import_node_fs35.rmSync)(path, { force: true });
72363
+ syncDirectory((0, import_node_path32.dirname)(path));
71767
72364
  } catch {
71768
72365
  }
71769
72366
  }
@@ -71776,7 +72373,7 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
71776
72373
  if (!path) throw new ProjectExportReceiptError("project export artifact path is unsafe.");
71777
72374
  let wroteArtifact = false;
71778
72375
  try {
71779
- (0, import_node_fs33.writeFileSync)(path, bytes, { flag: "wx" });
72376
+ (0, import_node_fs35.writeFileSync)(path, bytes, { flag: "wx" });
71780
72377
  wroteArtifact = true;
71781
72378
  syncFile(path);
71782
72379
  commitProjectExportTransition(transition);
@@ -71791,8 +72388,8 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
71791
72388
  }
71792
72389
  if (!restoreError && wroteArtifact) {
71793
72390
  try {
71794
- (0, import_node_fs33.rmSync)(path, { force: true });
71795
- syncDirectory((0, import_node_path30.dirname)(path));
72391
+ (0, import_node_fs35.rmSync)(path, { force: true });
72392
+ syncDirectory((0, import_node_path32.dirname)(path));
71796
72393
  } catch {
71797
72394
  }
71798
72395
  }
@@ -71806,7 +72403,7 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
71806
72403
  }
71807
72404
  function receiptHasFile(projectId, receipt) {
71808
72405
  const path = resolveProjectExportReceiptPath(projectId, receipt);
71809
- return path !== null && (0, import_node_fs33.existsSync)(path);
72406
+ return path !== null && (0, import_node_fs35.existsSync)(path);
71810
72407
  }
71811
72408
  function matchingProjectExportReceipts(projectId, version, contractHash2, kinds) {
71812
72409
  const wanted = kinds ? new Set(kinds) : null;
@@ -71853,7 +72450,7 @@ function currentApprovedSnapshot(projectId, version) {
71853
72450
  }
71854
72451
 
71855
72452
  // workspace-data.ts
71856
- var import_node_fs34 = require("node:fs");
72453
+ var import_node_fs36 = require("node:fs");
71857
72454
  var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
71858
72455
  var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
71859
72456
  "bom-csv",
@@ -71886,7 +72483,7 @@ function parseBool(v, fallback) {
71886
72483
  if (v === false || v === "false" || v === "0") return false;
71887
72484
  return null;
71888
72485
  }
71889
- function parseIntParam(v, name) {
72486
+ function parseIntParam(v) {
71890
72487
  if (v === void 0) return void 0;
71891
72488
  if (Array.isArray(v)) return null;
71892
72489
  const raw = typeof v === "number" ? String(v) : typeof v === "string" ? v : "";
@@ -71914,15 +72511,15 @@ function exportBody(projectId, receipt, opts) {
71914
72511
  };
71915
72512
  if (opts.includePaths) body.path = path;
71916
72513
  if (opts.exportContents) {
71917
- const st = (0, import_node_fs34.statSync)(path);
72514
+ const st = (0, import_node_fs36.statSync)(path);
71918
72515
  if (st.size > opts.maxBytes) {
71919
72516
  body.contentOmitted = true;
71920
72517
  body.omittedReason = `export is ${st.size} bytes, over max-bytes ${opts.maxBytes}`;
71921
72518
  } else if (receipt.encoding === "base64") {
71922
- body.content = (0, import_node_fs34.readFileSync)(path).toString("base64");
72519
+ body.content = (0, import_node_fs36.readFileSync)(path).toString("base64");
71923
72520
  } else {
71924
72521
  body.encoding = receipt.encoding ?? "utf8";
71925
- body.content = (0, import_node_fs34.readFileSync)(path, "utf8");
72522
+ body.content = (0, import_node_fs36.readFileSync)(path, "utf8");
71926
72523
  }
71927
72524
  }
71928
72525
  return body;
@@ -71951,7 +72548,7 @@ function registerWorkspaceDataRoutes(app) {
71951
72548
  });
71952
72549
  app.get("/api/workspace-projects/:projectId/approved", async (req, reply) => {
71953
72550
  const appGuard = optionalString(req.query.app);
71954
- const version = parseIntParam(req.query.version, "version");
72551
+ const version = parseIntParam(req.query.version);
71955
72552
  if (version === null) return sendError(reply, 400, "invalid version");
71956
72553
  const includeValues = values(req.query.include);
71957
72554
  const includes = includeValues.length ? includeValues : ["contract"];
@@ -71969,8 +72566,9 @@ function registerWorkspaceDataRoutes(app) {
71969
72566
  if (exportContents === null) return sendError(reply, 400, "invalid export-contents");
71970
72567
  const includePaths = parseBool(req.query["include-paths"], false);
71971
72568
  if (includePaths === null) return sendError(reply, 400, "invalid include-paths");
71972
- const maxBytes = parseIntParam(req.query["max-bytes"], "max-bytes") ?? DEFAULT_MAX_BYTES;
71973
- if (maxBytes === null) return sendError(reply, 400, "invalid max-bytes");
72569
+ const maxBytesParam = parseIntParam(req.query["max-bytes"]);
72570
+ if (maxBytesParam === null) return sendError(reply, 400, "invalid max-bytes");
72571
+ const maxBytes = maxBytesParam ?? DEFAULT_MAX_BYTES;
71974
72572
  let snap;
71975
72573
  try {
71976
72574
  snap = currentApprovedSnapshot(req.params.projectId, version);
@@ -72031,7 +72629,7 @@ function registerWorkspaceDataRoutes(app) {
72031
72629
  if (appGuard && !sameAppLineage(appGuard, project.app)) {
72032
72630
  return sendError(reply, 404, `project "${project.id}" belongs to app "${project.app}", not "${appGuard}"`);
72033
72631
  }
72034
- const limit = parseIntParam(req.query.limit, "limit");
72632
+ const limit = parseIntParam(req.query.limit);
72035
72633
  if (limit === null) return sendError(reply, 400, "invalid limit");
72036
72634
  const q = optionalString(req.query.q);
72037
72635
  const wikiDir = currentGenerationWikiDir(project.id);
@@ -72200,18 +72798,18 @@ function registerMigrationCommitRoute(app, deps) {
72200
72798
  }
72201
72799
 
72202
72800
  // workspace-agent-manifest.ts
72203
- var import_node_fs35 = require("node:fs");
72801
+ var import_node_fs37 = require("node:fs");
72204
72802
  var import_node_os18 = require("node:os");
72205
- var import_node_path31 = require("node:path");
72803
+ var import_node_path33 = require("node:path");
72206
72804
  function awareHome() {
72207
- return process.env.AWARE_HOME || (0, import_node_path31.join)((0, import_node_os18.homedir)(), ".aware");
72805
+ return process.env.AWARE_HOME || (0, import_node_path33.join)((0, import_node_os18.homedir)(), ".aware");
72208
72806
  }
72209
72807
  function workspaceAgentDir() {
72210
- return (0, import_node_path31.join)(awareHome(), "agents", "floless-workspace");
72808
+ return (0, import_node_path33.join)(awareHome(), "agents", "floless-workspace");
72211
72809
  }
72212
72810
  function syncWorkspaceAgentManifest(port) {
72213
72811
  const dir = workspaceAgentDir();
72214
- (0, import_node_fs35.mkdirSync)(dir, { recursive: true });
72812
+ (0, import_node_fs37.mkdirSync)(dir, { recursive: true });
72215
72813
  const manifest = `agent: floless-workspace
72216
72814
  version: 0.2.0
72217
72815
  sdk-target: 2.4.0
@@ -72341,8 +72939,8 @@ commands:
72341
72939
  headers: object
72342
72940
  body: object
72343
72941
  `;
72344
- const path = (0, import_node_path31.join)(dir, "manifest.yaml");
72345
- if (!(0, import_node_fs35.existsSync)(path) || manifest !== "") (0, import_node_fs35.writeFileSync)(path, manifest, "utf8");
72942
+ const path = (0, import_node_path33.join)(dir, "manifest.yaml");
72943
+ if (!(0, import_node_fs37.existsSync)(path) || manifest !== "") (0, import_node_fs37.writeFileSync)(path, manifest, "utf8");
72346
72944
  return path;
72347
72945
  }
72348
72946
 
@@ -72736,7 +73334,7 @@ function diffCrossVersion(from, to, view, v2Side, ctx, tonnage) {
72736
73334
  const v1 = collect(v1Doc);
72737
73335
  const migration = view.doc.migration;
72738
73336
  const out = baseDiff(tonnage, { geometryNotCompared: true });
72739
- const verdict = migration ? mappingApplies(v1Doc, v1.byKey, migration, view) : { applies: false, uncorroborated: /* @__PURE__ */ new Set() };
73337
+ const verdict = migration ? mappingApplies(v1.byKey, migration, view) : { applies: false, uncorroborated: /* @__PURE__ */ new Set() };
72740
73338
  if (!verdict.applies || ctx && !ctx.lineageResolved) {
72741
73339
  out.warnings.mappingIncomplete = true;
72742
73340
  out.comparison = "suppressed";
@@ -72860,7 +73458,7 @@ function diffCrossVersion(from, to, view, v2Side, ctx, tonnage) {
72860
73458
  applyIdentityHeuristic(out, groups.size, v2ByKey.size, [...groups.keys()].filter((k) => v2ByKey.has(k)).length);
72861
73459
  return out;
72862
73460
  }
72863
- function mappingApplies(v1Doc, v1Keys, migration, view) {
73461
+ function mappingApplies(v1Keys, migration, view) {
72864
73462
  const no = { applies: false, uncorroborated: /* @__PURE__ */ new Set() };
72865
73463
  const mapped = /* @__PURE__ */ new Set();
72866
73464
  for (const row of asArray(migration.members)) mapped.add(str4(row?.sheet) + NUL + str4(row?.id));
@@ -73337,7 +73935,7 @@ async function summarizeVersionChangesAsync(id, versions, bases) {
73337
73935
  const fromVersion = baseForVersion(n, bases);
73338
73936
  const fromSkel = fromVersion != null ? await readVersionSkeletonAsync(id, fromVersion) : void 0;
73339
73937
  if (fromVersion != null && fromSkel == null) continue;
73340
- await new Promise((resolve11) => setImmediate(resolve11));
73938
+ await new Promise((resolve12) => setImmediate(resolve12));
73341
73939
  const to = await loadDiffDocumentAsync(id, n, toSkel);
73342
73940
  if (to.kind !== "eligible") continue;
73343
73941
  const from = fromVersion != null ? await loadDiffDocumentAsync(id, fromVersion, fromSkel) : void 0;
@@ -73437,7 +74035,7 @@ function computeVersionDiff(id, n, base) {
73437
74035
  }
73438
74036
 
73439
74037
  // contract-bake.ts
73440
- var import_node_fs36 = require("node:fs");
74038
+ var import_node_fs38 = require("node:fs");
73441
74039
  var import_yaml7 = __toESM(require_dist6(), 1);
73442
74040
  function isSteelType(t) {
73443
74041
  return t === STEEL_V1 || t === STEEL_V2;
@@ -73449,6 +74047,7 @@ function bakedV2(contract) {
73449
74047
  delete baked.prop_labels;
73450
74048
  delete baked.member_styles;
73451
74049
  delete baked.views;
74050
+ delete baked.reference_models;
73452
74051
  if (Array.isArray(baked.plans)) {
73453
74052
  baked.plans = baked.plans.map((p) => {
73454
74053
  if (!p || typeof p !== "object") return p;
@@ -73460,7 +74059,7 @@ function bakedV2(contract) {
73460
74059
  return stripConfidentialImages(baked);
73461
74060
  }
73462
74061
  function bakeContractIntoApp(sourcePath, contract) {
73463
- const doc = (0, import_yaml7.parseDocument)((0, import_node_fs36.readFileSync)(sourcePath, "utf8"));
74062
+ const doc = (0, import_yaml7.parseDocument)((0, import_node_fs38.readFileSync)(sourcePath, "utf8"));
73464
74063
  if (doc.errors.length > 0) {
73465
74064
  throw new Error(`contract bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
73466
74065
  }
@@ -73484,7 +74083,7 @@ function bakeContractIntoApp(sourcePath, contract) {
73484
74083
  throw new InvalidModelV2Error(`refusing to bake: contract declares steel.model/v2 but is not valid v2: ${issues[0] ?? "unknown"}`, issues);
73485
74084
  }
73486
74085
  doc.setIn(["nodes", idx, "config", "takeoff"], bakedV2(contract));
73487
- (0, import_node_fs36.writeFileSync)(sourcePath, doc.toString());
74086
+ (0, import_node_fs38.writeFileSync)(sourcePath, doc.toString());
73488
74087
  return;
73489
74088
  }
73490
74089
  const baked = { ...contract };
@@ -73529,7 +74128,7 @@ function bakeContractIntoApp(sourcePath, contract) {
73529
74128
  );
73530
74129
  }
73531
74130
  doc.setIn(["nodes", idx, "config", "takeoff"], baked);
73532
- (0, import_node_fs36.writeFileSync)(sourcePath, doc.toString());
74131
+ (0, import_node_fs38.writeFileSync)(sourcePath, doc.toString());
73533
74132
  }
73534
74133
 
73535
74134
  // vectorize.ts
@@ -73951,11 +74550,11 @@ function awareFailureMessage(e, fallback) {
73951
74550
  }
73952
74551
 
73953
74552
  // scene-bake.ts
73954
- var import_node_fs37 = require("node:fs");
73955
- var import_node_path32 = require("node:path");
74553
+ var import_node_fs39 = require("node:fs");
74554
+ var import_node_path34 = require("node:path");
73956
74555
  var import_yaml8 = __toESM(require_dist6(), 1);
73957
74556
  function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
73958
- const doc = (0, import_yaml8.parseDocument)((0, import_node_fs37.readFileSync)(sourcePath, "utf8"));
74557
+ const doc = (0, import_yaml8.parseDocument)((0, import_node_fs39.readFileSync)(sourcePath, "utf8"));
73959
74558
  if (doc.errors.length > 0) {
73960
74559
  throw new Error(`scene bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
73961
74560
  }
@@ -73964,10 +74563,10 @@ function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
73964
74563
  const idx = items.findIndex((it) => ((0, import_yaml8.isMap)(it) ? it.toJSON() : null)?.agent === agent);
73965
74564
  if (idx < 0) throw new Error(`no ${agent} render node to bake the scene into`);
73966
74565
  doc.setIn(["nodes", idx, "config", "scene"], scene);
73967
- (0, import_node_fs37.writeFileSync)(sourcePath, doc.toString());
74566
+ (0, import_node_fs39.writeFileSync)(sourcePath, doc.toString());
73968
74567
  }
73969
74568
  function bakeNodeConfigById(sourcePath, nodeId, patch2) {
73970
- const doc = (0, import_yaml8.parseDocument)((0, import_node_fs37.readFileSync)(sourcePath, "utf8"));
74569
+ const doc = (0, import_yaml8.parseDocument)((0, import_node_fs39.readFileSync)(sourcePath, "utf8"));
73971
74570
  if (doc.errors.length > 0) {
73972
74571
  throw new Error(`node bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
73973
74572
  }
@@ -73976,12 +74575,12 @@ function bakeNodeConfigById(sourcePath, nodeId, patch2) {
73976
74575
  const idx = items.findIndex((it) => ((0, import_yaml8.isMap)(it) ? it.toJSON() : null)?.id === nodeId);
73977
74576
  if (idx < 0) throw new Error(`no node with id "${nodeId}"`);
73978
74577
  for (const [key, value] of Object.entries(patch2)) doc.setIn(["nodes", idx, "config", key], value);
73979
- (0, import_node_fs37.writeFileSync)(sourcePath, doc.toString());
74578
+ (0, import_node_fs39.writeFileSync)(sourcePath, doc.toString());
73980
74579
  }
73981
74580
  function writeViewer3dApp(dir, appId, scene) {
73982
- (0, import_node_fs37.mkdirSync)(dir, { recursive: true });
73983
- const flo = (0, import_node_path32.join)(dir, `${appId}.flo`);
73984
- (0, import_node_fs37.writeFileSync)(flo, [
74581
+ (0, import_node_fs39.mkdirSync)(dir, { recursive: true });
74582
+ const flo = (0, import_node_path34.join)(dir, `${appId}.flo`);
74583
+ (0, import_node_fs39.writeFileSync)(flo, [
73985
74584
  `app: ${appId}`,
73986
74585
  "version: 0.1.0",
73987
74586
  "display-name: Steel 3D",
@@ -74004,18 +74603,18 @@ function writeViewer3dApp(dir, appId, scene) {
74004
74603
  var COMPANION_MARKER = "# floless-companion: generated by FloLess \u2014 overwritten on every export";
74005
74604
  function isCompanionApp(flo) {
74006
74605
  try {
74007
- return (0, import_node_fs37.readFileSync)(flo, "utf8").split(/\r?\n/, 1)[0]?.trim() === COMPANION_MARKER;
74606
+ return (0, import_node_fs39.readFileSync)(flo, "utf8").split(/\r?\n/, 1)[0]?.trim() === COMPANION_MARKER;
74008
74607
  } catch (e) {
74009
74608
  return e?.code === "ENOENT";
74010
74609
  }
74011
74610
  }
74012
74611
  function writeBomReportApp(dir, appId, table) {
74013
- (0, import_node_fs37.mkdirSync)(dir, { recursive: true });
74014
- const flo = (0, import_node_path32.join)(dir, `${appId}.flo`);
74612
+ (0, import_node_fs39.mkdirSync)(dir, { recursive: true });
74613
+ const flo = (0, import_node_path34.join)(dir, `${appId}.flo`);
74015
74614
  if (!isCompanionApp(flo)) {
74016
74615
  throw new Error(`refusing to overwrite "${appId}": an app of that name exists and FloLess did not write it`);
74017
74616
  }
74018
- (0, import_node_fs37.writeFileSync)(flo, [
74617
+ (0, import_node_fs39.writeFileSync)(flo, [
74019
74618
  COMPANION_MARKER,
74020
74619
  `app: ${appId}`,
74021
74620
  "version: 0.1.0",
@@ -74042,9 +74641,9 @@ function writeBomReportApp(dir, appId, table) {
74042
74641
  return flo;
74043
74642
  }
74044
74643
  function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
74045
- (0, import_node_fs37.mkdirSync)(dir, { recursive: true });
74046
- const flo = (0, import_node_path32.join)(dir, `${appId}.flo`);
74047
- (0, import_node_fs37.writeFileSync)(flo, [
74644
+ (0, import_node_fs39.mkdirSync)(dir, { recursive: true });
74645
+ const flo = (0, import_node_path34.join)(dir, `${appId}.flo`);
74646
+ (0, import_node_fs39.writeFileSync)(flo, [
74048
74647
  `app: ${appId}`,
74049
74648
  "version: 0.1.0",
74050
74649
  "display-name: Steel to Revit",
@@ -74078,9 +74677,9 @@ function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
74078
74677
  return flo;
74079
74678
  }
74080
74679
  function writeSketchupApp(dir, appId, scene) {
74081
- (0, import_node_fs37.mkdirSync)(dir, { recursive: true });
74082
- const flo = (0, import_node_path32.join)(dir, `${appId}.flo`);
74083
- (0, import_node_fs37.writeFileSync)(flo, [
74680
+ (0, import_node_fs39.mkdirSync)(dir, { recursive: true });
74681
+ const flo = (0, import_node_path34.join)(dir, `${appId}.flo`);
74682
+ (0, import_node_fs39.writeFileSync)(flo, [
74084
74683
  `app: ${appId}`,
74085
74684
  "version: 0.1.0",
74086
74685
  "display-name: Steel to SketchUp",
@@ -74107,10 +74706,10 @@ function writeSketchupApp(dir, appId, scene) {
74107
74706
  return flo;
74108
74707
  }
74109
74708
  function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
74110
- (0, import_node_fs37.mkdirSync)(dir, { recursive: true });
74111
- const flo = (0, import_node_path32.join)(dir, `${appId}.flo`);
74709
+ (0, import_node_fs39.mkdirSync)(dir, { recursive: true });
74710
+ const flo = (0, import_node_path34.join)(dir, `${appId}.flo`);
74112
74711
  const exactRhinoId = typeof rhinoId === "string" && rhinoId.trim() ? rhinoId.trim() : null;
74113
- (0, import_node_fs37.writeFileSync)(flo, [
74712
+ (0, import_node_fs39.writeFileSync)(flo, [
74114
74713
  `app: ${appId}`,
74115
74714
  "version: 0.1.0",
74116
74715
  "display-name: Steel to Rhino",
@@ -74137,9 +74736,9 @@ function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
74137
74736
  return flo;
74138
74737
  }
74139
74738
  function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
74140
- (0, import_node_fs37.mkdirSync)(dir, { recursive: true });
74141
- const flo = (0, import_node_path32.join)(dir, `${appId}.flo`);
74142
- (0, import_node_fs37.writeFileSync)(flo, [
74739
+ (0, import_node_fs39.mkdirSync)(dir, { recursive: true });
74740
+ const flo = (0, import_node_path34.join)(dir, `${appId}.flo`);
74741
+ (0, import_node_fs39.writeFileSync)(flo, [
74143
74742
  `app: ${appId}`,
74144
74743
  "version: 0.1.0",
74145
74744
  "display-name: Steel to Tekla",
@@ -74302,10 +74901,10 @@ async function teklaVersionToBake() {
74302
74901
  }
74303
74902
 
74304
74903
  // ifc-publication.ts
74305
- var import_node_crypto20 = require("node:crypto");
74306
- var import_node_fs38 = require("node:fs");
74904
+ var import_node_crypto22 = require("node:crypto");
74905
+ var import_node_fs40 = require("node:fs");
74307
74906
  var import_node_os19 = require("node:os");
74308
- var import_node_path33 = require("node:path");
74907
+ var import_node_path35 = require("node:path");
74309
74908
  var IfcPublicationError = class extends Error {
74310
74909
  constructor(message) {
74311
74910
  super(message);
@@ -74328,7 +74927,7 @@ var MAX_TRANSACTIONS = 256;
74328
74927
  var MAX_PHASE_BYTES = 1024 * 1024;
74329
74928
  var MAX_INDEX_SNAPSHOT_BYTES = 512 * 1024;
74330
74929
  function sha2562(bytes) {
74331
- return (0, import_node_crypto20.createHash)("sha256").update(bytes).digest("hex");
74930
+ return (0, import_node_crypto22.createHash)("sha256").update(bytes).digest("hex");
74332
74931
  }
74333
74932
  function proof2(bytes) {
74334
74933
  return { exists: true, bytes: bytes.length, sha256: sha2562(bytes) };
@@ -74337,37 +74936,37 @@ function sameProof(path, expected) {
74337
74936
  return fileProofEquals(readFileProof(path), expected);
74338
74937
  }
74339
74938
  function syncFile2(path) {
74340
- const fd2 = (0, import_node_fs38.openSync)(path, "r+");
74939
+ const fd2 = (0, import_node_fs40.openSync)(path, "r+");
74341
74940
  try {
74342
- (0, import_node_fs38.fsyncSync)(fd2);
74941
+ (0, import_node_fs40.fsyncSync)(fd2);
74343
74942
  } finally {
74344
- (0, import_node_fs38.closeSync)(fd2);
74943
+ (0, import_node_fs40.closeSync)(fd2);
74345
74944
  }
74346
74945
  }
74347
74946
  function syncDirectory2(path) {
74348
74947
  try {
74349
- const fd2 = (0, import_node_fs38.openSync)(path, "r");
74948
+ const fd2 = (0, import_node_fs40.openSync)(path, "r");
74350
74949
  try {
74351
- (0, import_node_fs38.fsyncSync)(fd2);
74950
+ (0, import_node_fs40.fsyncSync)(fd2);
74352
74951
  } finally {
74353
- (0, import_node_fs38.closeSync)(fd2);
74952
+ (0, import_node_fs40.closeSync)(fd2);
74354
74953
  }
74355
74954
  } catch {
74356
74955
  }
74357
74956
  }
74358
74957
  function durableReplace2(path, bytes) {
74359
- const dir = (0, import_node_path33.dirname)(path);
74360
- (0, import_node_fs38.mkdirSync)(dir, { recursive: true });
74361
- const tmp = (0, import_node_path33.join)(dir, `.floless-tmp-recovery-${(0, import_node_crypto20.randomUUID)()}`);
74958
+ const dir = (0, import_node_path35.dirname)(path);
74959
+ (0, import_node_fs40.mkdirSync)(dir, { recursive: true });
74960
+ const tmp = (0, import_node_path35.join)(dir, `.floless-tmp-recovery-${(0, import_node_crypto22.randomUUID)()}`);
74362
74961
  try {
74363
- (0, import_node_fs38.writeFileSync)(tmp, bytes, { flag: "wx" });
74962
+ (0, import_node_fs40.writeFileSync)(tmp, bytes, { flag: "wx" });
74364
74963
  syncFile2(tmp);
74365
- (0, import_node_fs38.renameSync)(tmp, path);
74964
+ (0, import_node_fs40.renameSync)(tmp, path);
74366
74965
  syncFile2(path);
74367
74966
  syncDirectory2(dir);
74368
74967
  } finally {
74369
74968
  try {
74370
- (0, import_node_fs38.rmSync)(tmp, { force: true });
74969
+ (0, import_node_fs40.rmSync)(tmp, { force: true });
74371
74970
  } catch {
74372
74971
  }
74373
74972
  }
@@ -74379,26 +74978,26 @@ function plainIfcFilename(name) {
74379
74978
  return isPortablePlainFilename(name) && name.toLowerCase().endsWith(".ifc") && !name.toLowerCase().startsWith(".floless-");
74380
74979
  }
74381
74980
  function canonicalPath(path) {
74382
- return (0, import_node_path33.resolve)(path);
74981
+ return (0, import_node_path35.resolve)(path);
74383
74982
  }
74384
74983
  function validateRequestPaths(tempPath, finalPath) {
74385
74984
  const final = canonicalPath(finalPath);
74386
74985
  const temp = canonicalPath(tempPath);
74387
- const dir = (0, import_node_path33.dirname)(final);
74388
- if ((0, import_node_path33.dirname)(temp) !== dir) throw new IfcPublicationError("IFC temp and final paths must share one directory.");
74389
- if (!plainIfcFilename((0, import_node_path33.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
74390
- if (!TEMP_RE.test((0, import_node_path33.basename)(temp))) throw new IfcPublicationError("IFC temp filename is not request-scoped.");
74986
+ const dir = (0, import_node_path35.dirname)(final);
74987
+ if ((0, import_node_path35.dirname)(temp) !== dir) throw new IfcPublicationError("IFC temp and final paths must share one directory.");
74988
+ if (!plainIfcFilename((0, import_node_path35.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
74989
+ if (!TEMP_RE.test((0, import_node_path35.basename)(temp))) throw new IfcPublicationError("IFC temp filename is not request-scoped.");
74391
74990
  return { dir, temp, final };
74392
74991
  }
74393
74992
  function requestIfcTempPath(finalPath) {
74394
74993
  const final = canonicalPath(finalPath);
74395
- if (!plainIfcFilename((0, import_node_path33.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
74396
- (0, import_node_fs38.mkdirSync)((0, import_node_path33.dirname)(final), { recursive: true });
74397
- return (0, import_node_path33.join)((0, import_node_path33.dirname)(final), `.floless-tmp-ifc-${(0, import_node_crypto20.randomUUID)()}.ifc`);
74994
+ if (!plainIfcFilename((0, import_node_path35.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
74995
+ (0, import_node_fs40.mkdirSync)((0, import_node_path35.dirname)(final), { recursive: true });
74996
+ return (0, import_node_path35.join)((0, import_node_path35.dirname)(final), `.floless-tmp-ifc-${(0, import_node_crypto22.randomUUID)()}.ifc`);
74398
74997
  }
74399
74998
  function validateIfc(path) {
74400
- if (!(0, import_node_fs38.existsSync)(path) || (0, import_node_fs38.statSync)(path).size === 0) throw new IfcPublicationError("the IFC export produced no file");
74401
- const bytes = (0, import_node_fs38.readFileSync)(path);
74999
+ if (!(0, import_node_fs40.existsSync)(path) || (0, import_node_fs40.statSync)(path).size === 0) throw new IfcPublicationError("the IFC export produced no file");
75000
+ const bytes = (0, import_node_fs40.readFileSync)(path);
74402
75001
  const prefix = bytes.subarray(0, Math.min(bytes.length, 128)).toString("utf8");
74403
75002
  if (!prefix.includes("ISO-10303-21")) throw new IfcPublicationError("the IFC export did not produce a valid STEP envelope");
74404
75003
  return { bytes, proof: proof2(bytes) };
@@ -74411,21 +75010,21 @@ function metadataEqual(a, b) {
74411
75010
  function writePhase2(txnDir2, journal) {
74412
75011
  const index = PHASES2.indexOf(journal.phase);
74413
75012
  if (index < 0) throw new IfcPublicationError(`unknown IFC publication phase "${journal.phase}".`);
74414
- const destination = (0, import_node_path33.join)(txnDir2, `${String(index).padStart(3, "0")}-${journal.phase}.json`);
74415
- if ((0, import_node_fs38.existsSync)(destination)) throw new IfcPublicationError(`IFC publication phase "${journal.phase}" already exists.`);
74416
- const temp = (0, import_node_path33.join)(txnDir2, `.phase-${(0, import_node_crypto20.randomUUID)()}.tmp`);
75013
+ const destination = (0, import_node_path35.join)(txnDir2, `${String(index).padStart(3, "0")}-${journal.phase}.json`);
75014
+ if ((0, import_node_fs40.existsSync)(destination)) throw new IfcPublicationError(`IFC publication phase "${journal.phase}" already exists.`);
75015
+ const temp = (0, import_node_path35.join)(txnDir2, `.phase-${(0, import_node_crypto22.randomUUID)()}.tmp`);
74417
75016
  const bytes = Buffer.from(`${JSON.stringify(journal, null, 2)}
74418
75017
  `, "utf8");
74419
75018
  try {
74420
- (0, import_node_fs38.writeFileSync)(temp, bytes, { flag: "wx" });
75019
+ (0, import_node_fs40.writeFileSync)(temp, bytes, { flag: "wx" });
74421
75020
  syncFile2(temp);
74422
- (0, import_node_fs38.renameSync)(temp, destination);
75021
+ (0, import_node_fs40.renameSync)(temp, destination);
74423
75022
  syncFile2(destination);
74424
75023
  syncDirectory2(txnDir2);
74425
- syncDirectory2((0, import_node_path33.dirname)(txnDir2));
75024
+ syncDirectory2((0, import_node_path35.dirname)(txnDir2));
74426
75025
  } finally {
74427
75026
  try {
74428
- (0, import_node_fs38.rmSync)(temp, { force: true });
75027
+ (0, import_node_fs40.rmSync)(temp, { force: true });
74429
75028
  } catch {
74430
75029
  }
74431
75030
  }
@@ -74445,12 +75044,12 @@ function validateJournal(raw, txnDir2, expectedTxnId) {
74445
75044
  const resource = j.resource;
74446
75045
  if (!validResource(resource)) throw new IfcPublicationError("IFC journal resource is invalid.");
74447
75046
  const exportDir = canonicalPath(String(j.exportDir));
74448
- const actualDir = canonicalPath((0, import_node_path33.dirname)(txnDir2));
75047
+ const actualDir = canonicalPath((0, import_node_path35.dirname)(txnDir2));
74449
75048
  if (exportDir !== actualDir) throw new IfcPublicationError("IFC journal export directory is not canonical.");
74450
75049
  const finalPath = canonicalPath(String(j.finalPath));
74451
75050
  const tempPath = canonicalPath(String(j.tempPath));
74452
75051
  const backupPath = canonicalPath(String(j.backupPath));
74453
- if ((0, import_node_path33.dirname)(finalPath) !== exportDir || (0, import_node_path33.dirname)(tempPath) !== exportDir || (0, import_node_path33.dirname)(backupPath) !== exportDir || !plainIfcFilename((0, import_node_path33.basename)(finalPath)) || !TEMP_RE.test((0, import_node_path33.basename)(tempPath)) || !BACKUP_RE.test((0, import_node_path33.basename)(backupPath))) throw new IfcPublicationError("IFC journal contains an unsafe artifact path.");
75052
+ if ((0, import_node_path35.dirname)(finalPath) !== exportDir || (0, import_node_path35.dirname)(tempPath) !== exportDir || (0, import_node_path35.dirname)(backupPath) !== exportDir || !plainIfcFilename((0, import_node_path35.basename)(finalPath)) || !TEMP_RE.test((0, import_node_path35.basename)(tempPath)) || !BACKUP_RE.test((0, import_node_path35.basename)(backupPath))) throw new IfcPublicationError("IFC journal contains an unsafe artifact path.");
74454
75053
  const journal = {
74455
75054
  version: 1,
74456
75055
  txnId: expectedTxnId,
@@ -74470,7 +75069,7 @@ function validateJournal(raw, txnDir2, expectedTxnId) {
74470
75069
  }
74471
75070
  if (journal.mode === "artifact-with-receipt") {
74472
75071
  const indexPath = canonicalPath(String(j.indexPath));
74473
- if ((0, import_node_path33.dirname)(indexPath) !== exportDir || (0, import_node_path33.basename)(indexPath) !== "index.json") {
75072
+ if ((0, import_node_path35.dirname)(indexPath) !== exportDir || (0, import_node_path35.basename)(indexPath) !== "index.json") {
74474
75073
  throw new IfcPublicationError("IFC journal receipt index path is unsafe.");
74475
75074
  }
74476
75075
  journal.indexPath = indexPath;
@@ -74488,10 +75087,10 @@ function validateJournal(raw, txnDir2, expectedTxnId) {
74488
75087
  return journal;
74489
75088
  }
74490
75089
  function loadJournal(txnDir2) {
74491
- const match = (0, import_node_path33.basename)(txnDir2).match(ACTIVE_RE);
74492
- if (!match) throw new IfcPublicationError(`unsafe IFC transaction directory "${(0, import_node_path33.basename)(txnDir2)}".`);
75090
+ const match = (0, import_node_path35.basename)(txnDir2).match(ACTIVE_RE);
75091
+ if (!match) throw new IfcPublicationError(`unsafe IFC transaction directory "${(0, import_node_path35.basename)(txnDir2)}".`);
74493
75092
  const txnId = match[1];
74494
- const entries2 = (0, import_node_fs38.readdirSync)(txnDir2, { withFileTypes: true });
75093
+ const entries2 = (0, import_node_fs40.readdirSync)(txnDir2, { withFileTypes: true });
74495
75094
  if (!entries2.length) return null;
74496
75095
  const phaseFiles = entries2.filter((entry2) => entry2.isFile() && PHASE_RE.test(entry2.name)).sort((a, b) => a.name.localeCompare(b.name));
74497
75096
  const unknown = entries2.filter((entry2) => !(entry2.isFile() && (PHASE_RE.test(entry2.name) || /^\.phase-[a-f0-9-]+\.tmp$/i.test(entry2.name))));
@@ -74505,11 +75104,11 @@ function loadJournal(txnDir2) {
74505
75104
  const declaredIndex = Number(phaseMatch[1]);
74506
75105
  const declaredPhase = phaseMatch[2];
74507
75106
  if (declaredIndex !== index || PHASES2[index] !== declaredPhase) break;
74508
- const path = (0, import_node_path33.join)(txnDir2, entry2.name);
74509
- if ((0, import_node_fs38.statSync)(path).size > MAX_PHASE_BYTES) break;
75107
+ const path = (0, import_node_path35.join)(txnDir2, entry2.name);
75108
+ if ((0, import_node_fs40.statSync)(path).size > MAX_PHASE_BYTES) break;
74510
75109
  let parsed;
74511
75110
  try {
74512
- parsed = JSON.parse((0, import_node_fs38.readFileSync)(path, "utf8"));
75111
+ parsed = JSON.parse((0, import_node_fs40.readFileSync)(path, "utf8"));
74513
75112
  } catch {
74514
75113
  break;
74515
75114
  }
@@ -74536,8 +75135,8 @@ function restoreIndex(journal) {
74536
75135
  if (journal.priorIndex.exists) {
74537
75136
  durableReplace2(indexPath, Buffer.from(journal.priorIndexBase64, "base64"));
74538
75137
  } else {
74539
- (0, import_node_fs38.rmSync)(indexPath, { force: true });
74540
- syncDirectory2((0, import_node_path33.dirname)(indexPath));
75138
+ (0, import_node_fs40.rmSync)(indexPath, { force: true });
75139
+ syncDirectory2((0, import_node_path35.dirname)(indexPath));
74541
75140
  }
74542
75141
  if (!sameProof(indexPath, journal.priorIndex)) {
74543
75142
  throw new IfcPublicationError("receipt index restore did not match its recorded proof.");
@@ -74552,14 +75151,14 @@ function restoreArtifact(journal) {
74552
75151
  if (!fileProofEquals(backup, journal.priorArtifact)) {
74553
75152
  throw new IfcPublicationError("IFC backup does not match the recorded prior artifact.");
74554
75153
  }
74555
- (0, import_node_fs38.rmSync)(journal.backupPath, { force: true });
75154
+ (0, import_node_fs40.rmSync)(journal.backupPath, { force: true });
74556
75155
  }
74557
75156
  } else if (!final.exists || fileProofEquals(final, journal.newArtifact)) {
74558
75157
  if (!fileProofEquals(backup, journal.priorArtifact)) {
74559
75158
  throw new IfcPublicationError("IFC prior artifact cannot be proven for rollback.");
74560
75159
  }
74561
- if (final.exists) (0, import_node_fs38.rmSync)(journal.finalPath, { force: true });
74562
- (0, import_node_fs38.renameSync)(journal.backupPath, journal.finalPath);
75160
+ if (final.exists) (0, import_node_fs40.rmSync)(journal.finalPath, { force: true });
75161
+ (0, import_node_fs40.renameSync)(journal.backupPath, journal.finalPath);
74563
75162
  syncFile2(journal.finalPath);
74564
75163
  } else {
74565
75164
  throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
@@ -74572,25 +75171,25 @@ function restoreArtifact(journal) {
74572
75171
  if (!fileProofEquals(final, journal.newArtifact)) {
74573
75172
  throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
74574
75173
  }
74575
- (0, import_node_fs38.rmSync)(journal.finalPath, { force: true });
75174
+ (0, import_node_fs40.rmSync)(journal.finalPath, { force: true });
74576
75175
  }
74577
75176
  if (backup.exists) throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
74578
75177
  }
74579
- if ((0, import_node_fs38.existsSync)(journal.tempPath)) {
75178
+ if ((0, import_node_fs40.existsSync)(journal.tempPath)) {
74580
75179
  if (!sameProof(journal.tempPath, journal.newArtifact)) {
74581
75180
  throw new IfcPublicationError("IFC temp artifact does not match its recorded proof.");
74582
75181
  }
74583
- (0, import_node_fs38.rmSync)(journal.tempPath, { force: true });
75182
+ (0, import_node_fs40.rmSync)(journal.tempPath, { force: true });
74584
75183
  }
74585
75184
  syncDirectory2(journal.exportDir);
74586
75185
  }
74587
75186
  function retireTransaction(txnDir2) {
74588
- const match = (0, import_node_path33.basename)(txnDir2).match(ACTIVE_RE);
75187
+ const match = (0, import_node_path35.basename)(txnDir2).match(ACTIVE_RE);
74589
75188
  if (!match) throw new IfcPublicationError("cannot retire an unsafe IFC transaction directory.");
74590
- const cleanupDir = (0, import_node_path33.join)((0, import_node_path33.dirname)(txnDir2), `.floless-cleanup-ifc-${match[1]}`);
74591
- if ((0, import_node_fs38.existsSync)(cleanupDir)) throw new IfcPublicationError("IFC cleanup directory already exists.");
74592
- (0, import_node_fs38.renameSync)(txnDir2, cleanupDir);
74593
- syncDirectory2((0, import_node_path33.dirname)(txnDir2));
75189
+ const cleanupDir = (0, import_node_path35.join)((0, import_node_path35.dirname)(txnDir2), `.floless-cleanup-ifc-${match[1]}`);
75190
+ if ((0, import_node_fs40.existsSync)(cleanupDir)) throw new IfcPublicationError("IFC cleanup directory already exists.");
75191
+ (0, import_node_fs40.renameSync)(txnDir2, cleanupDir);
75192
+ syncDirectory2((0, import_node_path35.dirname)(txnDir2));
74594
75193
  return cleanupDir;
74595
75194
  }
74596
75195
  function finishCommitted(txnDir2, journal, allowMissingBackup) {
@@ -74606,7 +75205,7 @@ function finishCommitted(txnDir2, journal, allowMissingBackup) {
74606
75205
  if (!fileProofEquals(backup, journal.priorArtifact)) {
74607
75206
  throw new IfcPublicationError("committed IFC backup does not match the recorded prior artifact.");
74608
75207
  }
74609
- (0, import_node_fs38.rmSync)(journal.backupPath, { force: true });
75208
+ (0, import_node_fs40.rmSync)(journal.backupPath, { force: true });
74610
75209
  syncDirectory2(journal.exportDir);
74611
75210
  } else if (!allowMissingBackup) {
74612
75211
  throw new IfcPublicationError("committed IFC backup disappeared before verified cleanup.");
@@ -74615,18 +75214,18 @@ function finishCommitted(txnDir2, journal, allowMissingBackup) {
74615
75214
  throw new IfcPublicationError("unexpected committed IFC backup exists for a no-prior transaction.");
74616
75215
  }
74617
75216
  const cleanupDir = retireTransaction(txnDir2);
74618
- (0, import_node_fs38.rmSync)(cleanupDir, { recursive: true, force: true });
75217
+ (0, import_node_fs40.rmSync)(cleanupDir, { recursive: true, force: true });
74619
75218
  syncDirectory2(journal.exportDir);
74620
75219
  }
74621
75220
  function rollbackTransaction(txnDir2, journal) {
74622
75221
  restoreArtifact(journal);
74623
75222
  restoreIndex(journal);
74624
75223
  const cleanupDir = retireTransaction(txnDir2);
74625
- (0, import_node_fs38.rmSync)(cleanupDir, { recursive: true, force: true });
75224
+ (0, import_node_fs40.rmSync)(cleanupDir, { recursive: true, force: true });
74626
75225
  syncDirectory2(journal.exportDir);
74627
75226
  }
74628
75227
  function safeTransactionDirectory(path) {
74629
- const st = (0, import_node_fs38.lstatSync)(path);
75228
+ const st = (0, import_node_fs40.lstatSync)(path);
74630
75229
  if (!st.isDirectory() || st.isSymbolicLink()) {
74631
75230
  throw new IfcPublicationError(`IFC transaction path is not a plain directory: ${path}`);
74632
75231
  }
@@ -74636,7 +75235,7 @@ async function recoverActive(txnDir2, expected) {
74636
75235
  const journal = loadJournal(txnDir2);
74637
75236
  if (!journal) {
74638
75237
  const cleanupDir = retireTransaction(txnDir2);
74639
- (0, import_node_fs38.rmSync)(cleanupDir, { recursive: true, force: true });
75238
+ (0, import_node_fs40.rmSync)(cleanupDir, { recursive: true, force: true });
74640
75239
  return;
74641
75240
  }
74642
75241
  if (expected && (journal.resource.kind !== expected.kind || journal.resource.key !== expected.key)) {
@@ -74649,18 +75248,18 @@ async function recoverActive(txnDir2, expected) {
74649
75248
  }
74650
75249
  async function recoverIfcPublicationsInDirectory(exportDir, expected) {
74651
75250
  const dir = canonicalPath(exportDir);
74652
- if (!(0, import_node_fs38.existsSync)(dir)) return [];
75251
+ if (!(0, import_node_fs40.existsSync)(dir)) return [];
74653
75252
  safeTransactionDirectory(dir);
74654
- const entries2 = (0, import_node_fs38.readdirSync)(dir, { withFileTypes: true }).filter((entry2) => ACTIVE_RE.test(entry2.name) || CLEANUP_RE.test(entry2.name));
75253
+ const entries2 = (0, import_node_fs40.readdirSync)(dir, { withFileTypes: true }).filter((entry2) => ACTIVE_RE.test(entry2.name) || CLEANUP_RE.test(entry2.name));
74655
75254
  if (entries2.length > MAX_TRANSACTIONS) {
74656
75255
  throw new IfcPublicationError(`IFC recovery refused ${entries2.length} transaction directories (limit ${MAX_TRANSACTIONS}).`);
74657
75256
  }
74658
75257
  const recovered = [];
74659
75258
  for (const entry2 of entries2) {
74660
- const path = (0, import_node_path33.join)(dir, entry2.name);
75259
+ const path = (0, import_node_path35.join)(dir, entry2.name);
74661
75260
  safeTransactionDirectory(path);
74662
75261
  if (CLEANUP_RE.test(entry2.name)) {
74663
- (0, import_node_fs38.rmSync)(path, { recursive: true, force: true });
75262
+ (0, import_node_fs40.rmSync)(path, { recursive: true, force: true });
74664
75263
  syncDirectory2(dir);
74665
75264
  recovered.push(entry2.name);
74666
75265
  continue;
@@ -74672,32 +75271,32 @@ async function recoverIfcPublicationsInDirectory(exportDir, expected) {
74672
75271
  }
74673
75272
  async function recoverAllIfcPublications() {
74674
75273
  const recovered = [];
74675
- const rootHome = process.env.FLOLESS_HOME ?? (0, import_node_path33.join)((0, import_node_os19.homedir)(), ".floless");
74676
- const projectsRoot2 = (0, import_node_path33.join)(rootHome, "projects");
74677
- if ((0, import_node_fs38.existsSync)(projectsRoot2)) {
75274
+ const rootHome = process.env.FLOLESS_HOME ?? (0, import_node_path35.join)((0, import_node_os19.homedir)(), ".floless");
75275
+ const projectsRoot2 = (0, import_node_path35.join)(rootHome, "projects");
75276
+ if ((0, import_node_fs40.existsSync)(projectsRoot2)) {
74678
75277
  safeTransactionDirectory(projectsRoot2);
74679
- for (const entry2 of (0, import_node_fs38.readdirSync)(projectsRoot2, { withFileTypes: true })) {
75278
+ for (const entry2 of (0, import_node_fs40.readdirSync)(projectsRoot2, { withFileTypes: true })) {
74680
75279
  if (entry2.name.startsWith(".")) continue;
74681
75280
  if (entry2.isSymbolicLink()) throw new IfcPublicationError(`project recovery root is a link: ${entry2.name}`);
74682
75281
  if (!entry2.isDirectory() || !/^[a-z0-9][a-z0-9-]*$/.test(entry2.name)) continue;
74683
- const projectPath = (0, import_node_path33.join)(projectsRoot2, entry2.name);
75282
+ const projectPath = (0, import_node_path35.join)(projectsRoot2, entry2.name);
74684
75283
  safeTransactionDirectory(projectPath);
74685
75284
  const dir = projectExportsDir(entry2.name);
74686
75285
  const names = await recoverIfcPublicationsInDirectory(dir, { kind: "project", key: entry2.name });
74687
75286
  recovered.push(...names.map((name) => `${entry2.name}/${name}`));
74688
75287
  }
74689
75288
  }
74690
- const root4 = (0, import_node_path33.join)(rootHome, "exports");
74691
- if ((0, import_node_fs38.existsSync)(root4)) {
75289
+ const root4 = (0, import_node_path35.join)(rootHome, "exports");
75290
+ if ((0, import_node_fs40.existsSync)(root4)) {
74692
75291
  safeTransactionDirectory(root4);
74693
- for (const entry2 of (0, import_node_fs38.readdirSync)(root4, { withFileTypes: true })) {
75292
+ for (const entry2 of (0, import_node_fs40.readdirSync)(root4, { withFileTypes: true })) {
74694
75293
  if (entry2.name.startsWith(".")) continue;
74695
75294
  if (entry2.isSymbolicLink()) throw new IfcPublicationError(`workflow recovery root is a link: ${entry2.name}`);
74696
75295
  if (!entry2.isDirectory()) continue;
74697
75296
  if (!/^[A-Za-z0-9._-]+$/.test(entry2.name)) continue;
74698
- safeTransactionDirectory((0, import_node_path33.join)(root4, entry2.name));
75297
+ safeTransactionDirectory((0, import_node_path35.join)(root4, entry2.name));
74699
75298
  const names = await recoverIfcPublicationsInDirectory(
74700
- (0, import_node_path33.join)(root4, entry2.name),
75299
+ (0, import_node_path35.join)(root4, entry2.name),
74701
75300
  { kind: "app", key: entry2.name }
74702
75301
  );
74703
75302
  recovered.push(...names.map((name) => `${entry2.name}/${name}`));
@@ -74707,8 +75306,8 @@ async function recoverAllIfcPublications() {
74707
75306
  }
74708
75307
  function assertReceiptOptions(receipt, resource, exportDir, finalPath, artifact) {
74709
75308
  const transition = receipt.transition;
74710
- if (resource.kind !== "project" || transition.projectId !== resource.key || transition.next.kind !== "ifc" || transition.next.filename !== (0, import_node_path33.basename)(finalPath) || transition.next.bytes !== artifact.bytes || canonicalPath(transition.indexPath) !== canonicalPath(projectExportIndexPath(transition.projectId))) throw new IfcPublicationError("project receipt transition does not match the IFC publication target.");
74711
- if ((0, import_node_path33.dirname)(canonicalPath(transition.indexPath)) !== exportDir || (0, import_node_path33.basename)(transition.indexPath) !== "index.json") throw new IfcPublicationError("project receipt index is outside the IFC export directory.");
75309
+ if (resource.kind !== "project" || transition.projectId !== resource.key || transition.next.kind !== "ifc" || transition.next.filename !== (0, import_node_path35.basename)(finalPath) || transition.next.bytes !== artifact.bytes || canonicalPath(transition.indexPath) !== canonicalPath(projectExportIndexPath(transition.projectId))) throw new IfcPublicationError("project receipt transition does not match the IFC publication target.");
75310
+ if ((0, import_node_path35.dirname)(canonicalPath(transition.indexPath)) !== exportDir || (0, import_node_path35.basename)(transition.indexPath) !== "index.json") throw new IfcPublicationError("project receipt index is outside the IFC export directory.");
74712
75311
  const beforeSnapshot = transition.beforeBytesBase64 === null ? null : Buffer.from(transition.beforeBytesBase64, "base64");
74713
75312
  if (beforeSnapshot && beforeSnapshot.length > MAX_INDEX_SNAPSHOT_BYTES || transition.before.exists !== (beforeSnapshot !== null) || beforeSnapshot !== null && !fileProofEquals(proof2(beforeSnapshot), transition.before) || !fileProofEquals(proof2(Buffer.from(transition.afterBytesBase64, "base64")), transition.after)) throw new IfcPublicationError("project receipt transition proofs are inconsistent.");
74714
75313
  if (!fileProofEquals(readFileProof(transition.indexPath), transition.before)) {
@@ -74721,7 +75320,7 @@ function promiseLike(value) {
74721
75320
  async function publishIfcAtomically(tempPath, finalPath, options) {
74722
75321
  if (!options || !validResource(options.resource)) throw new IfcPublicationError("IFC publication resource is invalid.");
74723
75322
  const paths = validateRequestPaths(tempPath, finalPath);
74724
- const tempStat = (0, import_node_fs38.lstatSync)(paths.temp);
75323
+ const tempStat = (0, import_node_fs40.lstatSync)(paths.temp);
74725
75324
  if (!tempStat.isFile()) throw new IfcPublicationError("the IFC to publish is not a regular file.");
74726
75325
  const validated = validateIfc(paths.temp);
74727
75326
  if (options.expectedContentSha256 !== void 0 && validated.proof.sha256 !== options.expectedContentSha256) {
@@ -74733,9 +75332,9 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
74733
75332
  }
74734
75333
  return withLifecycleLock(options.resource.kind, options.resource.key, async () => {
74735
75334
  await recoverIfcPublicationsInDirectory(paths.dir, options.resource);
74736
- const txnId = (0, import_node_crypto20.randomUUID)();
74737
- const txnDir2 = (0, import_node_path33.join)(paths.dir, `.floless-txn-ifc-${txnId}`);
74738
- const backupPath = (0, import_node_path33.join)(paths.dir, `.floless-backup-ifc-${txnId}.ifc`);
75335
+ const txnId = (0, import_node_crypto22.randomUUID)();
75336
+ const txnDir2 = (0, import_node_path35.join)(paths.dir, `.floless-txn-ifc-${txnId}`);
75337
+ const backupPath = (0, import_node_path35.join)(paths.dir, `.floless-backup-ifc-${txnId}.ifc`);
74739
75338
  const priorArtifact = readFileProof(paths.final);
74740
75339
  const transition = options.receipt?.transition;
74741
75340
  const base = {
@@ -74759,7 +75358,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
74759
75358
  };
74760
75359
  let journal = { ...base, phase: "prepared" };
74761
75360
  let committed = false;
74762
- (0, import_node_fs38.mkdirSync)(txnDir2);
75361
+ (0, import_node_fs40.mkdirSync)(txnDir2);
74763
75362
  syncDirectory2(paths.dir);
74764
75363
  const hit = (point) => {
74765
75364
  options.fault?.(point);
@@ -74775,11 +75374,11 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
74775
75374
  phase("prepared");
74776
75375
  phase("backing-up");
74777
75376
  if (priorArtifact.exists) {
74778
- (0, import_node_fs38.renameSync)(paths.final, backupPath);
75377
+ (0, import_node_fs40.renameSync)(paths.final, backupPath);
74779
75378
  syncDirectory2(paths.dir);
74780
75379
  }
74781
75380
  phase("promoting");
74782
- (0, import_node_fs38.renameSync)(paths.temp, paths.final);
75381
+ (0, import_node_fs40.renameSync)(paths.temp, paths.final);
74783
75382
  syncFile2(paths.final);
74784
75383
  syncDirectory2(paths.dir);
74785
75384
  if (!sameProof(paths.final, validated.proof)) {
@@ -74808,7 +75407,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
74808
75407
  if (!fileProofEquals(backup, priorArtifact)) {
74809
75408
  throw new IfcPublicationError("IFC backup did not match the recorded prior artifact before cleanup.");
74810
75409
  }
74811
- (0, import_node_fs38.rmSync)(backupPath, { force: true });
75410
+ (0, import_node_fs40.rmSync)(backupPath, { force: true });
74812
75411
  syncDirectory2(paths.dir);
74813
75412
  } else if (backup.exists) {
74814
75413
  throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
@@ -74818,7 +75417,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
74818
75417
  const cleanupDir = retireTransaction(txnDir2);
74819
75418
  hit("after-retire");
74820
75419
  hit("before-cleanup-remove");
74821
- (0, import_node_fs38.rmSync)(cleanupDir, { recursive: true, force: true });
75420
+ (0, import_node_fs40.rmSync)(cleanupDir, { recursive: true, force: true });
74822
75421
  syncDirectory2(paths.dir);
74823
75422
  return { bytes: validated.bytes, cleanupPending: false };
74824
75423
  } catch (error) {
@@ -74861,14 +75460,14 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
74861
75460
  });
74862
75461
  }
74863
75462
  function cleanupIfcTemp(path) {
74864
- if (!TEMP_RE.test((0, import_node_path33.basename)(path))) return;
75463
+ if (!TEMP_RE.test((0, import_node_path35.basename)(path))) return;
74865
75464
  const canonical = canonicalPath(path);
74866
- const dir = (0, import_node_path33.dirname)(canonical);
74867
- if ((0, import_node_fs38.existsSync)(dir)) {
74868
- for (const entry2 of (0, import_node_fs38.readdirSync)(dir, { withFileTypes: true })) {
75465
+ const dir = (0, import_node_path35.dirname)(canonical);
75466
+ if ((0, import_node_fs40.existsSync)(dir)) {
75467
+ for (const entry2 of (0, import_node_fs40.readdirSync)(dir, { withFileTypes: true })) {
74869
75468
  if (!entry2.isDirectory() || !ACTIVE_RE.test(entry2.name)) continue;
74870
75469
  try {
74871
- const journal = loadJournal((0, import_node_path33.join)(dir, entry2.name));
75470
+ const journal = loadJournal((0, import_node_path35.join)(dir, entry2.name));
74872
75471
  if (!journal || journal.tempPath === canonical) return;
74873
75472
  } catch {
74874
75473
  return;
@@ -74876,15 +75475,15 @@ function cleanupIfcTemp(path) {
74876
75475
  }
74877
75476
  }
74878
75477
  try {
74879
- (0, import_node_fs38.rmSync)(path, { force: true });
75478
+ (0, import_node_fs40.rmSync)(path, { force: true });
74880
75479
  } catch {
74881
75480
  }
74882
75481
  }
74883
75482
 
74884
75483
  // export-companion.ts
74885
- var import_node_crypto21 = require("node:crypto");
74886
- var import_node_fs39 = require("node:fs");
74887
- var import_node_path34 = require("node:path");
75484
+ var import_node_crypto23 = require("node:crypto");
75485
+ var import_node_fs41 = require("node:fs");
75486
+ var import_node_path36 = require("node:path");
74888
75487
  var PREFIX = "floless-export-tmp-";
74889
75488
  var LEASE = ".floless-export-lease.json";
74890
75489
  var STALE_MS2 = 30 * 6e4;
@@ -74898,34 +75497,34 @@ function processAlive2(pid) {
74898
75497
  }
74899
75498
  }
74900
75499
  function defaultAppsRoot() {
74901
- return (0, import_node_path34.dirname)(appPath("placeholder"));
75500
+ return (0, import_node_path36.dirname)(appPath("placeholder"));
74902
75501
  }
74903
75502
  function assertScratchPath(path, appsRoot) {
74904
- const root4 = (0, import_node_path34.resolve)(appsRoot);
74905
- const target = (0, import_node_path34.resolve)(path);
74906
- if ((0, import_node_path34.dirname)(target) !== root4 || !(0, import_node_path34.basename)(target).startsWith(PREFIX)) {
75503
+ const root4 = (0, import_node_path36.resolve)(appsRoot);
75504
+ const target = (0, import_node_path36.resolve)(path);
75505
+ if ((0, import_node_path36.dirname)(target) !== root4 || !(0, import_node_path36.basename)(target).startsWith(PREFIX)) {
74907
75506
  throw new Error(`refusing to remove a non-export companion path: ${target}`);
74908
75507
  }
74909
75508
  }
74910
75509
  function removeScratch(path, appsRoot) {
74911
75510
  assertScratchPath(path, appsRoot);
74912
- (0, import_node_fs39.rmSync)(path, { recursive: true, force: true });
75511
+ (0, import_node_fs41.rmSync)(path, { recursive: true, force: true });
74913
75512
  }
74914
75513
  function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
74915
75514
  const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
74916
- const token = (0, import_node_crypto21.randomUUID)();
75515
+ const token = (0, import_node_crypto23.randomUUID)();
74917
75516
  const id = `${PREFIX}${safeOwner}-${sink}-${token}`;
74918
- const root4 = (0, import_node_path34.resolve)(appsRoot);
74919
- const path = (0, import_node_path34.resolve)(root4, id);
75517
+ const root4 = (0, import_node_path36.resolve)(appsRoot);
75518
+ const path = (0, import_node_path36.resolve)(root4, id);
74920
75519
  return {
74921
75520
  id,
74922
75521
  path,
74923
75522
  token,
74924
75523
  cleanup: () => {
74925
- if (!(0, import_node_fs39.existsSync)(path)) return;
75524
+ if (!(0, import_node_fs41.existsSync)(path)) return;
74926
75525
  let current = null;
74927
75526
  try {
74928
- current = JSON.parse((0, import_node_fs39.readFileSync)((0, import_node_path34.resolve)(path, LEASE), "utf8"));
75527
+ current = JSON.parse((0, import_node_fs41.readFileSync)((0, import_node_path36.resolve)(path, LEASE), "utf8"));
74929
75528
  } catch {
74930
75529
  }
74931
75530
  if (current && current.token !== token) throw new Error(`export companion lease changed for ${id}`);
@@ -74933,28 +75532,28 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
74933
75532
  }
74934
75533
  };
74935
75534
  }
74936
- function stampExportCompanionLease(companion) {
74937
- (0, import_node_fs39.writeFileSync)((0, import_node_path34.resolve)(companion.path, LEASE), JSON.stringify({
75535
+ function stampExportCompanionLease(companion2) {
75536
+ (0, import_node_fs41.writeFileSync)((0, import_node_path36.resolve)(companion2.path, LEASE), JSON.stringify({
74938
75537
  pid: process.pid,
74939
- token: companion.token,
75538
+ token: companion2.token,
74940
75539
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
74941
75540
  }));
74942
75541
  }
74943
75542
  function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
74944
- const root4 = (0, import_node_path34.resolve)(appsRoot);
74945
- if (!(0, import_node_fs39.existsSync)(root4)) return [];
75543
+ const root4 = (0, import_node_path36.resolve)(appsRoot);
75544
+ if (!(0, import_node_fs41.existsSync)(root4)) return [];
74946
75545
  const removed = [];
74947
- for (const entry2 of (0, import_node_fs39.readdirSync)(root4, { withFileTypes: true })) {
75546
+ for (const entry2 of (0, import_node_fs41.readdirSync)(root4, { withFileTypes: true })) {
74948
75547
  if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX)) continue;
74949
- const path = (0, import_node_path34.resolve)(root4, entry2.name);
75548
+ const path = (0, import_node_path36.resolve)(root4, entry2.name);
74950
75549
  let lease = null;
74951
75550
  try {
74952
- lease = JSON.parse((0, import_node_fs39.readFileSync)((0, import_node_path34.resolve)(path, LEASE), "utf8"));
75551
+ lease = JSON.parse((0, import_node_fs41.readFileSync)((0, import_node_path36.resolve)(path, LEASE), "utf8"));
74953
75552
  } catch {
74954
75553
  }
74955
75554
  let created;
74956
75555
  try {
74957
- created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs39.statSync)(path).mtimeMs;
75556
+ created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs41.statSync)(path).mtimeMs;
74958
75557
  } catch {
74959
75558
  continue;
74960
75559
  }
@@ -75078,12 +75677,12 @@ var HOST_PROCESS_NAMES = {
75078
75677
  rhino: "rhino"
75079
75678
  };
75080
75679
  var DEFAULT_DEPS2 = {
75081
- runPowerShell: (script) => new Promise((resolve11, reject) => {
75680
+ runPowerShell: (script) => new Promise((resolve12, reject) => {
75082
75681
  (0, import_node_child_process6.execFile)(
75083
75682
  "powershell.exe",
75084
75683
  ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", script],
75085
75684
  { encoding: "utf8", windowsHide: true, timeout: 5e3, maxBuffer: 1 << 20 },
75086
- (error, stdout) => error ? reject(error) : resolve11(stdout)
75685
+ (error, stdout) => error ? reject(error) : resolve12(stdout)
75087
75686
  );
75088
75687
  }),
75089
75688
  platform: process.platform
@@ -75528,14 +76127,14 @@ function looksLikeHostUnavailable(host, ...messages) {
75528
76127
  }
75529
76128
 
75530
76129
  // render-readiness.ts
75531
- var import_node_fs40 = require("node:fs");
75532
- var import_node_path35 = require("node:path");
76130
+ var import_node_fs42 = require("node:fs");
76131
+ var import_node_path37 = require("node:path");
75533
76132
  var import_node_os20 = require("node:os");
75534
76133
  var RENDER_AWARE_FLOOR = "0.103.0";
75535
76134
  var RENDER_AGENT_ID = "blender";
75536
76135
  function isFile(path) {
75537
76136
  try {
75538
- return (0, import_node_fs40.existsSync)(path) && (0, import_node_fs40.statSync)(path).isFile();
76137
+ return (0, import_node_fs42.existsSync)(path) && (0, import_node_fs42.statSync)(path).isFile();
75539
76138
  } catch {
75540
76139
  return false;
75541
76140
  }
@@ -75543,9 +76142,9 @@ function isFile(path) {
75543
76142
  function lookupOnPath(command, env2) {
75544
76143
  const path = env2.PATH ?? env2.Path;
75545
76144
  if (!path) return null;
75546
- for (const dir of path.split(import_node_path35.delimiter)) {
76145
+ for (const dir of path.split(import_node_path37.delimiter)) {
75547
76146
  if (!dir) continue;
75548
- const candidate = (0, import_node_path35.join)(dir, command);
76147
+ const candidate = (0, import_node_path37.join)(dir, command);
75549
76148
  if (isFile(candidate)) return candidate;
75550
76149
  }
75551
76150
  return null;
@@ -75562,21 +76161,21 @@ function windowsCandidates(env2) {
75562
76161
  for (const variable of ["ProgramFiles", "ProgramW6432", "ProgramFiles(x86)"]) {
75563
76162
  const value = env2[variable];
75564
76163
  if (!value) continue;
75565
- const root4 = (0, import_node_path35.join)(value, "Blender Foundation");
76164
+ const root4 = (0, import_node_path37.join)(value, "Blender Foundation");
75566
76165
  if (!roots.includes(root4)) roots.push(root4);
75567
76166
  }
75568
76167
  const found = [];
75569
76168
  for (const root4 of roots) {
75570
76169
  let entries2;
75571
76170
  try {
75572
- entries2 = (0, import_node_fs40.readdirSync)(root4);
76171
+ entries2 = (0, import_node_fs42.readdirSync)(root4);
75573
76172
  } catch {
75574
76173
  continue;
75575
76174
  }
75576
76175
  for (const name of entries2) {
75577
76176
  const match = /^Blender\s+(\d+(?:\.\d+)*)$/i.exec(name);
75578
76177
  if (!match) continue;
75579
- const binary = (0, import_node_path35.join)(root4, name, "blender.exe");
76178
+ const binary = (0, import_node_path37.join)(root4, name, "blender.exe");
75580
76179
  if (isFile(binary)) {
75581
76180
  found.push({ version: match[1].split(".").map(Number), name, binary });
75582
76181
  }
@@ -75590,7 +76189,7 @@ function platformDefaults(env2, isWin3) {
75590
76189
  if (process.platform === "darwin") {
75591
76190
  return [
75592
76191
  "/Applications/Blender.app/Contents/MacOS/Blender",
75593
- (0, import_node_path35.join)((0, import_node_os20.homedir)(), "Applications/Blender.app/Contents/MacOS/Blender")
76192
+ (0, import_node_path37.join)((0, import_node_os20.homedir)(), "Applications/Blender.app/Contents/MacOS/Blender")
75594
76193
  ];
75595
76194
  }
75596
76195
  return ["/usr/bin/blender", "/usr/local/bin/blender", "/snap/bin/blender"];
@@ -75753,20 +76352,20 @@ function nothingToApprove(contract) {
75753
76352
  }
75754
76353
 
75755
76354
  // app-lifecycle.ts
75756
- var import_node_fs43 = require("node:fs");
76355
+ var import_node_fs45 = require("node:fs");
75757
76356
  var import_node_os22 = require("node:os");
75758
- var import_node_path38 = require("node:path");
76357
+ var import_node_path40 = require("node:path");
75759
76358
 
75760
76359
  // routines.ts
75761
- var import_node_fs42 = require("node:fs");
75762
- var import_node_path37 = require("node:path");
76360
+ var import_node_fs44 = require("node:fs");
76361
+ var import_node_path39 = require("node:path");
75763
76362
 
75764
76363
  // trigger-sessions.ts
75765
- var import_node_fs41 = require("node:fs");
76364
+ var import_node_fs43 = require("node:fs");
75766
76365
  var import_node_os21 = require("node:os");
75767
- var import_node_path36 = require("node:path");
76366
+ var import_node_path38 = require("node:path");
75768
76367
  var import_yaml9 = __toESM(require_dist6(), 1);
75769
- var AGENTS_DIR2 = process.env.AWARE_HOME ? (0, import_node_path36.join)(process.env.AWARE_HOME, "agents") : (0, import_node_path36.join)((0, import_node_os21.homedir)(), ".aware", "agents");
76368
+ var AGENTS_DIR2 = process.env.AWARE_HOME ? (0, import_node_path38.join)(process.env.AWARE_HOME, "agents") : (0, import_node_path38.join)((0, import_node_os21.homedir)(), ".aware", "agents");
75770
76369
  function summarizeFire(data) {
75771
76370
  if (!data) return "event";
75772
76371
  const type = typeof data.type === "string" ? data.type : "";
@@ -75783,10 +76382,10 @@ function mapTriggerState(phase) {
75783
76382
  function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
75784
76383
  const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
75785
76384
  if (!safe2(agent)) return false;
75786
- const manifestPath2 = (0, import_node_path36.join)(agentsDir, agent, "manifest.yaml");
75787
- if (!(0, import_node_fs41.existsSync)(manifestPath2)) return false;
76385
+ const manifestPath2 = (0, import_node_path38.join)(agentsDir, agent, "manifest.yaml");
76386
+ if (!(0, import_node_fs43.existsSync)(manifestPath2)) return false;
75788
76387
  try {
75789
- const doc = (0, import_yaml9.parse)((0, import_node_fs41.readFileSync)(manifestPath2, "utf8"));
76388
+ const doc = (0, import_yaml9.parse)((0, import_node_fs43.readFileSync)(manifestPath2, "utf8"));
75790
76389
  const transport = doc?.transport;
75791
76390
  return !!(transport && typeof transport === "object" && "cli" in transport);
75792
76391
  } catch {
@@ -76094,7 +76693,7 @@ var RoutineError = class extends Error {
76094
76693
  }
76095
76694
  status;
76096
76695
  };
76097
- var ROUTINES_FILE = (0, import_node_path37.join)(flolessRoot, "routines.json");
76696
+ var ROUTINES_FILE = (0, import_node_path39.join)(flolessRoot, "routines.json");
76098
76697
  var routines = [];
76099
76698
  var loaded = false;
76100
76699
  function ensureLoaded() {
@@ -76130,10 +76729,10 @@ function sanitizeRoutine(raw) {
76130
76729
  };
76131
76730
  }
76132
76731
  function loadFromDisk() {
76133
- if (!(0, import_node_fs42.existsSync)(ROUTINES_FILE)) return [];
76732
+ if (!(0, import_node_fs44.existsSync)(ROUTINES_FILE)) return [];
76134
76733
  let text3;
76135
76734
  try {
76136
- text3 = (0, import_node_fs42.readFileSync)(ROUTINES_FILE, "utf8");
76735
+ text3 = (0, import_node_fs44.readFileSync)(ROUTINES_FILE, "utf8");
76137
76736
  } catch {
76138
76737
  return [];
76139
76738
  }
@@ -76142,17 +76741,17 @@ function loadFromDisk() {
76142
76741
  return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
76143
76742
  } catch {
76144
76743
  try {
76145
- (0, import_node_fs42.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
76744
+ (0, import_node_fs44.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
76146
76745
  } catch {
76147
76746
  }
76148
76747
  return [];
76149
76748
  }
76150
76749
  }
76151
76750
  function saveRoutines() {
76152
- if (!(0, import_node_fs42.existsSync)(flolessRoot)) (0, import_node_fs42.mkdirSync)(flolessRoot, { recursive: true });
76751
+ if (!(0, import_node_fs44.existsSync)(flolessRoot)) (0, import_node_fs44.mkdirSync)(flolessRoot, { recursive: true });
76153
76752
  const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
76154
- (0, import_node_fs42.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
76155
- (0, import_node_fs42.renameSync)(tmp, ROUTINES_FILE);
76753
+ (0, import_node_fs44.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
76754
+ (0, import_node_fs44.renameSync)(tmp, ROUTINES_FILE);
76156
76755
  }
76157
76756
  function listRoutines() {
76158
76757
  ensureLoaded();
@@ -76572,13 +77171,13 @@ var AppLifecycleError = class extends Error {
76572
77171
  }
76573
77172
  };
76574
77173
  function appsDir() {
76575
- return process.env.AWARE_HOME ? (0, import_node_path38.join)(process.env.AWARE_HOME, "apps") : (0, import_node_path38.join)((0, import_node_os22.homedir)(), ".aware", "apps");
77174
+ return process.env.AWARE_HOME ? (0, import_node_path40.join)(process.env.AWARE_HOME, "apps") : (0, import_node_path40.join)((0, import_node_os22.homedir)(), ".aware", "apps");
76576
77175
  }
76577
77176
  function appDirPath(id) {
76578
- return (0, import_node_path38.join)(appsDir(), id);
77177
+ return (0, import_node_path40.join)(appsDir(), id);
76579
77178
  }
76580
77179
  function appInstalled(id) {
76581
- return APP_ID4.test(id) && (0, import_node_fs43.existsSync)(appDirPath(id));
77180
+ return APP_ID4.test(id) && (0, import_node_fs45.existsSync)(appDirPath(id));
76582
77181
  }
76583
77182
  function logCascade(what, e) {
76584
77183
  console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
@@ -76816,9 +77415,9 @@ function isGatedAwareRoute(url, method) {
76816
77415
 
76817
77416
  // autostart.mjs
76818
77417
  var import_node_child_process7 = require("node:child_process");
76819
- var import_node_fs44 = require("node:fs");
77418
+ var import_node_fs46 = require("node:fs");
76820
77419
  var import_node_os23 = require("node:os");
76821
- var import_node_path39 = require("node:path");
77420
+ var import_node_path41 = require("node:path");
76822
77421
 
76823
77422
  // teardown.mjs
76824
77423
  var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
@@ -76930,8 +77529,8 @@ function removeLegacyRunKey() {
76930
77529
  }
76931
77530
  function logLine(msg) {
76932
77531
  try {
76933
- (0, import_node_fs44.mkdirSync)(logDir(), { recursive: true });
76934
- (0, import_node_fs44.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
77532
+ (0, import_node_fs46.mkdirSync)(logDir(), { recursive: true });
77533
+ (0, import_node_fs46.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
76935
77534
  `);
76936
77535
  } catch {
76937
77536
  }
@@ -76939,8 +77538,8 @@ function logLine(msg) {
76939
77538
  function registerAutostart(exePath) {
76940
77539
  if (!isWin) return;
76941
77540
  const xml = buildAutostartTaskXml(exePath, currentUserId());
76942
- const tmp = (0, import_node_path39.join)((0, import_node_os23.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
76943
- (0, import_node_fs44.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
77541
+ const tmp = (0, import_node_path41.join)((0, import_node_os23.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
77542
+ (0, import_node_fs46.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
76944
77543
  try {
76945
77544
  (0, import_node_child_process7.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
76946
77545
  stdio: ["ignore", "ignore", "ignore"],
@@ -76951,7 +77550,7 @@ function registerAutostart(exePath) {
76951
77550
  throw err2;
76952
77551
  } finally {
76953
77552
  try {
76954
- (0, import_node_fs44.rmSync)(tmp, { force: true });
77553
+ (0, import_node_fs46.rmSync)(tmp, { force: true });
76955
77554
  } catch {
76956
77555
  }
76957
77556
  }
@@ -76985,27 +77584,27 @@ function unregisterAutostart() {
76985
77584
 
76986
77585
  // updater.ts
76987
77586
  var import_node_child_process8 = require("node:child_process");
76988
- var import_node_crypto22 = require("node:crypto");
76989
- var import_node_fs46 = require("node:fs");
77587
+ var import_node_crypto24 = require("node:crypto");
77588
+ var import_node_fs48 = require("node:fs");
76990
77589
  var import_node_stream3 = require("node:stream");
76991
- var import_promises3 = require("node:stream/promises");
76992
- var import_node_path41 = require("node:path");
77590
+ var import_promises4 = require("node:stream/promises");
77591
+ var import_node_path43 = require("node:path");
76993
77592
 
76994
77593
  // post-update-marker.mjs
76995
- var import_node_fs45 = require("node:fs");
77594
+ var import_node_fs47 = require("node:fs");
76996
77595
  var import_node_os24 = require("node:os");
76997
- var import_node_path40 = require("node:path");
77596
+ var import_node_path42 = require("node:path");
76998
77597
  var FRESH_MS = 12e4;
76999
77598
  function markerPath() {
77000
77599
  const override = (process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim();
77001
77600
  if (override) return override;
77002
- const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path40.join)((0, import_node_os24.homedir)(), ".floless");
77003
- return (0, import_node_path40.join)(root4, ".post-update");
77601
+ const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path42.join)((0, import_node_os24.homedir)(), ".floless");
77602
+ return (0, import_node_path42.join)(root4, ".post-update");
77004
77603
  }
77005
77604
  function legacyMarkerPath() {
77006
77605
  if ((process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim()) return null;
77007
77606
  try {
77008
- return (0, import_node_path40.join)((0, import_node_path40.dirname)((0, import_node_path40.dirname)(process.execPath)), ".floless-post-update");
77607
+ return (0, import_node_path42.join)((0, import_node_path42.dirname)((0, import_node_path42.dirname)(process.execPath)), ".floless-post-update");
77009
77608
  } catch {
77010
77609
  return null;
77011
77610
  }
@@ -77015,7 +77614,7 @@ function writePostUpdateMarker() {
77015
77614
  for (const p of [markerPath(), legacyMarkerPath()]) {
77016
77615
  if (!p) continue;
77017
77616
  try {
77018
- (0, import_node_fs45.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
77617
+ (0, import_node_fs47.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
77019
77618
  wrote = true;
77020
77619
  } catch {
77021
77620
  }
@@ -77027,9 +77626,9 @@ function consumePostUpdateMarker() {
77027
77626
  for (const p of [markerPath(), legacyMarkerPath()]) {
77028
77627
  if (!p) continue;
77029
77628
  try {
77030
- if (!(0, import_node_fs45.existsSync)(p)) continue;
77031
- const ageMs = Date.now() - (0, import_node_fs45.statSync)(p).mtimeMs;
77032
- (0, import_node_fs45.rmSync)(p, { force: true });
77629
+ if (!(0, import_node_fs47.existsSync)(p)) continue;
77630
+ const ageMs = Date.now() - (0, import_node_fs47.statSync)(p).mtimeMs;
77631
+ (0, import_node_fs47.rmSync)(p, { force: true });
77033
77632
  if (ageMs < FRESH_MS) fresh = true;
77034
77633
  } catch {
77035
77634
  }
@@ -77046,13 +77645,13 @@ function currentVersion() {
77046
77645
  return appVersion();
77047
77646
  }
77048
77647
  function installRoot() {
77049
- return (0, import_node_path41.dirname)((0, import_node_path41.dirname)(process.execPath));
77648
+ return (0, import_node_path43.dirname)((0, import_node_path43.dirname)(process.execPath));
77050
77649
  }
77051
77650
  function updateExePath() {
77052
- return (0, import_node_path41.join)(installRoot(), "Update.exe");
77651
+ return (0, import_node_path43.join)(installRoot(), "Update.exe");
77053
77652
  }
77054
77653
  function packagesDir() {
77055
- return (0, import_node_path41.join)(installRoot(), "packages");
77654
+ return (0, import_node_path43.join)(installRoot(), "packages");
77056
77655
  }
77057
77656
  function feedUrl() {
77058
77657
  const env2 = (process.env.FLOLESS_UPDATE_URL ?? "").trim().replace(/\/+$/, "");
@@ -77151,23 +77750,23 @@ async function checkForUpdate() {
77151
77750
  return { supported: true, currentVersion: cur, updateAvailable: true, targetVersion: latest.Version, asset: latest };
77152
77751
  }
77153
77752
  async function sha1OfFile(path) {
77154
- const hash2 = (0, import_node_crypto22.createHash)("sha1");
77155
- await (0, import_promises3.pipeline)((0, import_node_fs46.createReadStream)(path), hash2);
77753
+ const hash2 = (0, import_node_crypto24.createHash)("sha1");
77754
+ await (0, import_promises4.pipeline)((0, import_node_fs48.createReadStream)(path), hash2);
77156
77755
  return hash2.digest("hex").toUpperCase();
77157
77756
  }
77158
77757
  async function downloadPackage(asset) {
77159
77758
  if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
77160
77759
  const want = asset.SHA1.toUpperCase();
77161
77760
  const dir = packagesDir();
77162
- (0, import_node_fs46.mkdirSync)(dir, { recursive: true });
77163
- const dest = (0, import_node_path41.join)(dir, asset.FileName);
77164
- if ((0, import_node_fs46.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
77761
+ (0, import_node_fs48.mkdirSync)(dir, { recursive: true });
77762
+ const dest = (0, import_node_path43.join)(dir, asset.FileName);
77763
+ if ((0, import_node_fs48.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
77165
77764
  const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
77166
77765
  redirect: "follow",
77167
77766
  signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
77168
77767
  });
77169
77768
  if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
77170
- await (0, import_promises3.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs46.createWriteStream)(dest));
77769
+ await (0, import_promises4.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs48.createWriteStream)(dest));
77171
77770
  const got = await sha1OfFile(dest);
77172
77771
  if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
77173
77772
  return dest;
@@ -77176,12 +77775,12 @@ async function applyUpdate(check, opts) {
77176
77775
  if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
77177
77776
  if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
77178
77777
  const exe = updateExePath();
77179
- if (!(0, import_node_fs46.existsSync)(exe)) {
77778
+ if (!(0, import_node_fs48.existsSync)(exe)) {
77180
77779
  return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
77181
77780
  }
77182
77781
  const pkg = await downloadPackage(check.asset);
77183
77782
  if (opts?.onBeforeApply) await opts.onBeforeApply();
77184
- await new Promise((resolve11, reject) => {
77783
+ await new Promise((resolve12, reject) => {
77185
77784
  const child = (0, import_node_child_process8.spawn)(exe, ["apply", "--package", pkg, "--waitPid", String(process.pid)], {
77186
77785
  cwd: installRoot(),
77187
77786
  detached: true,
@@ -77191,7 +77790,7 @@ async function applyUpdate(check, opts) {
77191
77790
  child.once("error", reject);
77192
77791
  child.once("spawn", () => {
77193
77792
  child.unref();
77194
- resolve11();
77793
+ resolve12();
77195
77794
  });
77196
77795
  });
77197
77796
  writePostUpdateMarker();
@@ -77416,12 +78015,12 @@ function isTraceCorrupt(events) {
77416
78015
 
77417
78016
  // launch.mjs
77418
78017
  var import_node_child_process9 = require("node:child_process");
77419
- var import_node_path42 = require("node:path");
78018
+ var import_node_path44 = require("node:path");
77420
78019
  var import_node_url3 = require("node:url");
77421
- var import_node_fs47 = require("node:fs");
78020
+ var import_node_fs49 = require("node:fs");
77422
78021
  var import_node_http = __toESM(require("node:http"), 1);
77423
78022
  var import_node_readline = require("node:readline");
77424
- var __dirname2 = (0, import_node_path42.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
78023
+ var __dirname2 = (0, import_node_path44.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
77425
78024
  var PORT = Number(process.env.PORT ?? 4317);
77426
78025
  var HEALTH_URL = `http://127.0.0.1:${PORT}/api/health`;
77427
78026
  var BROWSER_URL = `http://floless.localhost:${PORT}`;
@@ -77434,20 +78033,20 @@ var log = (m) => {
77434
78033
  }
77435
78034
  };
77436
78035
  function ping() {
77437
- return new Promise((resolve11) => {
78036
+ return new Promise((resolve12) => {
77438
78037
  const req = import_node_http.default.get(HEALTH_URL, { timeout: 1500 }, (res) => {
77439
78038
  res.resume();
77440
- resolve11(res.statusCode === 200);
78039
+ resolve12(res.statusCode === 200);
77441
78040
  });
77442
- req.on("error", () => resolve11(false));
78041
+ req.on("error", () => resolve12(false));
77443
78042
  req.on("timeout", () => {
77444
78043
  req.destroy();
77445
- resolve11(false);
78044
+ resolve12(false);
77446
78045
  });
77447
78046
  });
77448
78047
  }
77449
78048
  function probeRunning() {
77450
- return new Promise((resolve11) => {
78049
+ return new Promise((resolve12) => {
77451
78050
  const req = import_node_http.default.get(HEALTH_URL, { timeout: 1500 }, (res) => {
77452
78051
  let body = "";
77453
78052
  res.on("data", (c) => {
@@ -77456,16 +78055,16 @@ function probeRunning() {
77456
78055
  res.on("end", () => {
77457
78056
  try {
77458
78057
  const j = JSON.parse(body);
77459
- resolve11({ version: j.appVersion || null, channel: j.appChannel || null });
78058
+ resolve12({ version: j.appVersion || null, channel: j.appChannel || null });
77460
78059
  } catch {
77461
- resolve11({ version: null, channel: null });
78060
+ resolve12({ version: null, channel: null });
77462
78061
  }
77463
78062
  });
77464
78063
  });
77465
- req.on("error", () => resolve11({ version: null, channel: null }));
78064
+ req.on("error", () => resolve12({ version: null, channel: null }));
77466
78065
  req.on("timeout", () => {
77467
78066
  req.destroy();
77468
- resolve11({ version: null, channel: null });
78067
+ resolve12({ version: null, channel: null });
77469
78068
  });
77470
78069
  });
77471
78070
  }
@@ -77499,8 +78098,8 @@ async function waitHealthy(timeoutMs = 3e4) {
77499
78098
  function resolveServerStart() {
77500
78099
  const packaged = /flolessapp\.exe$/i.test(process.execPath);
77501
78100
  if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
77502
- const bundle = (0, import_node_path42.join)(__dirname2, "dist", "floless-server.cjs");
77503
- if ((0, import_node_fs47.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
78101
+ const bundle = (0, import_node_path44.join)(__dirname2, "dist", "floless-server.cjs");
78102
+ if ((0, import_node_fs49.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
77504
78103
  return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
77505
78104
  }
77506
78105
  function startServerDetached() {
@@ -77653,8 +78252,8 @@ function taskkillArgs(pid, { tree = true } = {}) {
77653
78252
  }
77654
78253
  function killSupervisor({ tree = true } = {}) {
77655
78254
  if (!isWin2) return;
77656
- const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path42.basename)(process.execPath));
77657
- const scriptMatch = isNpmChannel ? (0, import_node_path42.basename)((0, import_node_url3.fileURLToPath)(__import_meta_url)) : void 0;
78255
+ const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path44.basename)(process.execPath));
78256
+ const scriptMatch = isNpmChannel ? (0, import_node_path44.basename)((0, import_node_url3.fileURLToPath)(__import_meta_url)) : void 0;
77658
78257
  const realExe = resolveRealInstallExe(process.execPath);
77659
78258
  const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
77660
78259
  const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
@@ -77687,15 +78286,15 @@ async function cmdRestart() {
77687
78286
  await cmdOpen();
77688
78287
  }
77689
78288
  function apiJson(path, method = "GET") {
77690
- return new Promise((resolve11, reject) => {
78289
+ return new Promise((resolve12, reject) => {
77691
78290
  const req = import_node_http.default.request(`http://127.0.0.1:${PORT}${path}`, { method, timeout: 5e3 }, (res) => {
77692
78291
  let body = "";
77693
78292
  res.on("data", (c) => body += c);
77694
78293
  res.on("end", () => {
77695
78294
  try {
77696
- resolve11(JSON.parse(body || "{}"));
78295
+ resolve12(JSON.parse(body || "{}"));
77697
78296
  } catch {
77698
- resolve11({});
78297
+ resolve12({});
77699
78298
  }
77700
78299
  });
77701
78300
  });
@@ -77766,11 +78365,11 @@ function removeRegistryFootprint() {
77766
78365
  }
77767
78366
  }
77768
78367
  function promptYesNo(question) {
77769
- return new Promise((resolve11) => {
78368
+ return new Promise((resolve12) => {
77770
78369
  const rl = (0, import_node_readline.createInterface)({ input: process.stdin, output: process.stdout });
77771
78370
  rl.question(`${question} `, (answer) => {
77772
78371
  rl.close();
77773
- resolve11(/^y(es)?$/i.test((answer ?? "").trim()));
78372
+ resolve12(/^y(es)?$/i.test((answer ?? "").trim()));
77774
78373
  });
77775
78374
  });
77776
78375
  }
@@ -77825,7 +78424,7 @@ async function runAction(arg, flagArgv = [], selfVersion = null, selfChannel = n
77825
78424
  }
77826
78425
  await action(parseTeardownFlags(flagArgv));
77827
78426
  }
77828
- var entry = (0, import_node_path42.basename)(process.argv[1] ?? "").toLowerCase();
78427
+ var entry = (0, import_node_path44.basename)(process.argv[1] ?? "").toLowerCase();
77829
78428
  if (entry === "launch.mjs") {
77830
78429
  runAction(process.argv[2], process.argv.slice(3)).catch((e) => {
77831
78430
  log(`error: ${e?.message ?? e}`);
@@ -77834,9 +78433,9 @@ if (entry === "launch.mjs") {
77834
78433
  }
77835
78434
 
77836
78435
  // aware-update.ts
77837
- var import_promises4 = require("node:fs/promises");
77838
- var import_node_crypto23 = require("node:crypto");
77839
- var import_node_path43 = require("node:path");
78436
+ var import_promises5 = require("node:fs/promises");
78437
+ var import_node_crypto25 = require("node:crypto");
78438
+ var import_node_path45 = require("node:path");
77840
78439
  var REGISTRY_LATEST = "https://registry.npmjs.org/@aware-aeco/cli/latest";
77841
78440
  var FEED_TIMEOUT_MS2 = 15e3;
77842
78441
  var VERSION_TTL_MS = 5e3;
@@ -77848,12 +78447,12 @@ function requireExactAwareTarget(value) {
77848
78447
  if (!isExactAwareTarget(value)) throw new Error("The AWARE registry returned an invalid update version.");
77849
78448
  return value;
77850
78449
  }
77851
- var nodeBridgeIo = { readdir: import_promises4.readdir, lstat: import_promises4.lstat, realpath: import_promises4.realpath };
77852
- var nodeBridgeVersionIo = { ...nodeBridgeIo, readFile: import_promises4.readFile };
78450
+ var nodeBridgeIo = { readdir: import_promises5.readdir, lstat: import_promises5.lstat, realpath: import_promises5.realpath };
78451
+ var nodeBridgeVersionIo = { ...nodeBridgeIo, readFile: import_promises5.readFile };
77853
78452
  var BRIDGE_VERSION_MAX_BYTES = 128;
77854
78453
  function pathInside(root4, candidate) {
77855
- const rel = (0, import_node_path43.relative)(root4, candidate);
77856
- return rel === "" || !rel.startsWith("..") && !(0, import_node_path43.isAbsolute)(rel);
78454
+ const rel = (0, import_node_path45.relative)(root4, candidate);
78455
+ return rel === "" || !rel.startsWith("..") && !(0, import_node_path45.isAbsolute)(rel);
77857
78456
  }
77858
78457
  async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
77859
78458
  let names;
@@ -77877,7 +78476,7 @@ async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
77877
78476
  for (const host of AWARE_BRIDGE_HOSTS) {
77878
78477
  const fileName = `aware-${host}.exe`;
77879
78478
  if (!names.includes(fileName)) continue;
77880
- const candidate = (0, import_node_path43.join)(bridgeDirectory, fileName);
78479
+ const candidate = (0, import_node_path45.join)(bridgeDirectory, fileName);
77881
78480
  try {
77882
78481
  const stat4 = await io.lstat(candidate);
77883
78482
  const canonical = await io.realpath(candidate);
@@ -77921,8 +78520,8 @@ async function persistentBridgeVersion(bridgeDirectory, host, io = nodeBridgeVer
77921
78520
  throw error;
77922
78521
  }
77923
78522
  };
77924
- const executable = (0, import_node_path43.join)(bridgeDirectory, `aware-${host}.exe`);
77925
- const marker = (0, import_node_path43.join)(bridgeDirectory, `aware-${host}.version`);
78523
+ const executable = (0, import_node_path45.join)(bridgeDirectory, `aware-${host}.exe`);
78524
+ const marker = (0, import_node_path45.join)(bridgeDirectory, `aware-${host}.version`);
77926
78525
  try {
77927
78526
  if (!await validateFile(executable) || !await validateFile(marker)) return null;
77928
78527
  const bytes = await io.readFile(marker, "utf8");
@@ -77934,7 +78533,7 @@ async function persistentBridgeVersion(bridgeDirectory, host, io = nodeBridgeVer
77934
78533
  throw new Error(`Could not safely verify the installed ${host} bridge.`, { cause: error });
77935
78534
  }
77936
78535
  }
77937
- var nodeMarkerIo = { mkdir: import_promises4.mkdir, readFile: import_promises4.readFile, writeFile: import_promises4.writeFile, rename: import_promises4.rename, chmod: import_promises4.chmod, rm: import_promises4.rm };
78536
+ var nodeMarkerIo = { mkdir: import_promises5.mkdir, readFile: import_promises5.readFile, writeFile: import_promises5.writeFile, rename: import_promises5.rename, chmod: import_promises5.chmod, rm: import_promises5.rm };
77938
78537
  var MARKER_MAX_BYTES = 4096;
77939
78538
  var TOKEN = /^[A-Za-z0-9._-]{1,128}$/;
77940
78539
  var PROCESS_IDENTITY = /^[A-Za-z0-9._:-]{1,192}$/;
@@ -77950,7 +78549,7 @@ function validateMarker(value) {
77950
78549
  if (v.host != null && !isBridgeHost(v.host)) return null;
77951
78550
  if (v.child != null) {
77952
78551
  const child = v.child;
77953
- if (!Number.isSafeInteger(child.pid) || child.pid <= 0 || !PROCESS_IDENTITY.test(child.startIdentity) || !PROCESS_IDENTITY.test(child.executableIdentity) || (0, import_node_path43.basename)(child.executableIdentity) !== child.executableIdentity) return null;
78552
+ if (!Number.isSafeInteger(child.pid) || child.pid <= 0 || !PROCESS_IDENTITY.test(child.startIdentity) || !PROCESS_IDENTITY.test(child.executableIdentity) || (0, import_node_path45.basename)(child.executableIdentity) !== child.executableIdentity) return null;
77954
78553
  }
77955
78554
  return {
77956
78555
  schema: 1,
@@ -77965,8 +78564,8 @@ function validateMarker(value) {
77965
78564
  function createMaintenanceMarkerStore(markerPath2, options = {}) {
77966
78565
  const io = options.io ?? nodeMarkerIo;
77967
78566
  const maxBytes = Math.min(options.maxBytes ?? MARKER_MAX_BYTES, MARKER_MAX_BYTES);
77968
- const randomId = options.randomId ?? import_node_crypto23.randomUUID;
77969
- const directory = (0, import_node_path43.dirname)(markerPath2);
78567
+ const randomId = options.randomId ?? import_node_crypto25.randomUUID;
78568
+ const directory = (0, import_node_path45.dirname)(markerPath2);
77970
78569
  return {
77971
78570
  async read() {
77972
78571
  let bytes;
@@ -77990,7 +78589,7 @@ function createMaintenanceMarkerStore(markerPath2, options = {}) {
77990
78589
  const bytes = JSON.stringify(valid);
77991
78590
  if (Buffer.byteLength(bytes) > maxBytes) throw new Error("Refused to write an oversized AWARE maintenance marker.");
77992
78591
  await io.mkdir(directory, { recursive: true, mode: 448 });
77993
- const temp = (0, import_node_path43.join)(directory, `.${(0, import_node_path43.basename)(markerPath2)}.${randomId()}.tmp`);
78592
+ const temp = (0, import_node_path45.join)(directory, `.${(0, import_node_path45.basename)(markerPath2)}.${randomId()}.tmp`);
77994
78593
  try {
77995
78594
  await io.writeFile(temp, bytes, { encoding: "utf8", flag: "wx", mode: 384 });
77996
78595
  await io.rename(temp, markerPath2);
@@ -78102,8 +78701,8 @@ async function checkAwareUpdate(bridgeDirectory) {
78102
78701
 
78103
78702
  // aware-install-process.ts
78104
78703
  var import_node_child_process10 = require("node:child_process");
78105
- var import_promises5 = require("node:fs/promises");
78106
- var import_node_path44 = require("node:path");
78704
+ var import_promises6 = require("node:fs/promises");
78705
+ var import_node_path46 = require("node:path");
78107
78706
  var import_node_util3 = require("node:util");
78108
78707
  var execFileAsync = (0, import_node_util3.promisify)(import_node_child_process10.execFile);
78109
78708
  var DEFAULT_INSTALL_TIMEOUT_MS = 10 * 6e4;
@@ -78131,7 +78730,7 @@ function killTree2(child) {
78131
78730
  }
78132
78731
  }
78133
78732
  function safeExecutableIdentity(value) {
78134
- const name = (0, import_node_path44.basename)(value.trim()).replace(/[^A-Za-z0-9._-]/g, "").slice(0, 128);
78733
+ const name = (0, import_node_path46.basename)(value.trim()).replace(/[^A-Za-z0-9._-]/g, "").slice(0, 128);
78135
78734
  return name || "unknown";
78136
78735
  }
78137
78736
  async function maintenanceChildIdentity(pid) {
@@ -78195,8 +78794,8 @@ async function maintenanceChildIdentity(pid) {
78195
78794
  }
78196
78795
  if (process.platform === "linux") {
78197
78796
  const [stat4, exe] = await Promise.all([
78198
- (0, import_promises5.readFile)(`/proc/${pid}/stat`, "utf8"),
78199
- (0, import_promises5.readlink)(`/proc/${pid}/exe`)
78797
+ (0, import_promises6.readFile)(`/proc/${pid}/stat`, "utf8"),
78798
+ (0, import_promises6.readlink)(`/proc/${pid}/exe`)
78200
78799
  ]);
78201
78800
  const close = stat4.lastIndexOf(")");
78202
78801
  const fields = stat4.slice(close + 2).split(/\s+/);
@@ -78229,7 +78828,7 @@ function installAwareGlobal(spec, onLine = () => {
78229
78828
  const signal = externalSignal ?? ownController.signal;
78230
78829
  const timeout = ownController ? setTimeout(() => ownController.abort(), DEFAULT_INSTALL_TIMEOUT_MS) : null;
78231
78830
  timeout?.unref?.();
78232
- return new Promise((resolve11, reject) => {
78831
+ return new Promise((resolve12, reject) => {
78233
78832
  const child = (0, import_node_child_process10.spawn)("npm", ["i", "-g", `@aware-aeco/cli@${spec}`], {
78234
78833
  shell: process.platform === "win32",
78235
78834
  windowsHide: true
@@ -78247,7 +78846,7 @@ function installAwareGlobal(spec, onLine = () => {
78247
78846
  if (timeout) clearTimeout(timeout);
78248
78847
  signal.removeEventListener("abort", onAbort);
78249
78848
  if (error) reject(error);
78250
- else resolve11();
78849
+ else resolve12();
78251
78850
  };
78252
78851
  const onAbort = () => {
78253
78852
  aborted = true;
@@ -78441,8 +79040,8 @@ var AwareUpdateJobManager = class {
78441
79040
  }
78442
79041
  let resolveReserved;
78443
79042
  let rejectReserved;
78444
- const reserved = new Promise((resolve11, reject) => {
78445
- resolveReserved = resolve11;
79043
+ const reserved = new Promise((resolve12, reject) => {
79044
+ resolveReserved = resolve12;
78446
79045
  rejectReserved = reject;
78447
79046
  });
78448
79047
  record2.retry = { host, reserved };
@@ -78866,9 +79465,9 @@ function registerAwareUpdateRoutes(app, manager) {
78866
79465
  }
78867
79466
 
78868
79467
  // skill-sync.ts
78869
- var import_node_fs48 = require("node:fs");
79468
+ var import_node_fs50 = require("node:fs");
78870
79469
  var import_node_os25 = require("node:os");
78871
- var import_node_path45 = require("node:path");
79470
+ var import_node_path47 = require("node:path");
78872
79471
  var import_node_url4 = require("node:url");
78873
79472
  var import_yaml10 = __toESM(require_dist6(), 1);
78874
79473
 
@@ -78913,14 +79512,14 @@ function selectShippedSkillNames(names) {
78913
79512
  }
78914
79513
 
78915
79514
  // skill-sync.ts
78916
- var __dirname3 = (0, import_node_path45.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
79515
+ var __dirname3 = (0, import_node_path47.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
78917
79516
  function bundledSkillsRoot() {
78918
79517
  const candidates = [
78919
- (0, import_node_path45.join)(__dirname3, "skills"),
78920
- (0, import_node_path45.join)((0, import_node_path45.dirname)(process.execPath), "skills"),
78921
- (0, import_node_path45.join)(__dirname3, "..", ".claude", "skills")
79518
+ (0, import_node_path47.join)(__dirname3, "skills"),
79519
+ (0, import_node_path47.join)((0, import_node_path47.dirname)(process.execPath), "skills"),
79520
+ (0, import_node_path47.join)(__dirname3, "..", ".claude", "skills")
78922
79521
  ];
78923
- return candidates.find((p) => (0, import_node_fs48.existsSync)(p)) ?? null;
79522
+ return candidates.find((p) => (0, import_node_fs50.existsSync)(p)) ?? null;
78924
79523
  }
78925
79524
  function targetConfigDirs() {
78926
79525
  const override = process.env.FLOLESS_SKILL_TARGETS;
@@ -78929,14 +79528,14 @@ function targetConfigDirs() {
78929
79528
  }
78930
79529
  const home = (0, import_node_os25.homedir)();
78931
79530
  return [
78932
- { runtime: "claude", dir: (0, import_node_path45.join)(home, ".claude") },
78933
- { runtime: "codex", dir: (0, import_node_path45.join)(home, ".codex") },
78934
- { runtime: "opencode", dir: (0, import_node_path45.join)(home, ".opencode") }
79531
+ { runtime: "claude", dir: (0, import_node_path47.join)(home, ".claude") },
79532
+ { runtime: "codex", dir: (0, import_node_path47.join)(home, ".codex") },
79533
+ { runtime: "opencode", dir: (0, import_node_path47.join)(home, ".opencode") }
78935
79534
  ];
78936
79535
  }
78937
79536
  function skillVersion(skillMdPath) {
78938
79537
  try {
78939
- const text3 = (0, import_node_fs48.readFileSync)(skillMdPath, "utf8");
79538
+ const text3 = (0, import_node_fs50.readFileSync)(skillMdPath, "utf8");
78940
79539
  const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text3);
78941
79540
  if (!m || m[1] === void 0) return null;
78942
79541
  const fm = (0, import_yaml10.parse)(m[1]);
@@ -78976,21 +79575,21 @@ function decideAction(installed, bundled) {
78976
79575
  function bundledSkills(root4) {
78977
79576
  let entries2 = [];
78978
79577
  try {
78979
- entries2 = selectShippedSkillNames((0, import_node_fs48.readdirSync)(root4));
79578
+ entries2 = selectShippedSkillNames((0, import_node_fs50.readdirSync)(root4));
78980
79579
  } catch {
78981
79580
  return [];
78982
79581
  }
78983
79582
  const out = [];
78984
79583
  for (const name of entries2) {
78985
- const dir = (0, import_node_path45.join)(root4, name);
79584
+ const dir = (0, import_node_path47.join)(root4, name);
78986
79585
  let isDir = false;
78987
79586
  try {
78988
- isDir = (0, import_node_fs48.statSync)(dir).isDirectory();
79587
+ isDir = (0, import_node_fs50.statSync)(dir).isDirectory();
78989
79588
  } catch {
78990
79589
  isDir = false;
78991
79590
  }
78992
79591
  if (!isDir) continue;
78993
- const v = skillVersion((0, import_node_path45.join)(dir, "SKILL.md"));
79592
+ const v = skillVersion((0, import_node_path47.join)(dir, "SKILL.md"));
78994
79593
  if (!v) continue;
78995
79594
  out.push({ name, dir, version: v });
78996
79595
  }
@@ -79003,17 +79602,17 @@ function syncSkills() {
79003
79602
  const skills = bundledSkills(root4);
79004
79603
  if (!skills.length) return results;
79005
79604
  for (const { runtime, dir: cfg } of targetConfigDirs()) {
79006
- if (!(0, import_node_fs48.existsSync)(cfg)) continue;
79007
- const skillsDir = (0, import_node_path45.join)(cfg, "skills");
79605
+ if (!(0, import_node_fs50.existsSync)(cfg)) continue;
79606
+ const skillsDir = (0, import_node_path47.join)(cfg, "skills");
79008
79607
  for (const s of skills) {
79009
- const dest = (0, import_node_path45.join)(skillsDir, s.name);
79010
- const installedMd = (0, import_node_path45.join)(dest, "SKILL.md");
79011
- const installed = (0, import_node_fs48.existsSync)(installedMd) ? skillVersion(installedMd) : null;
79608
+ const dest = (0, import_node_path47.join)(skillsDir, s.name);
79609
+ const installedMd = (0, import_node_path47.join)(dest, "SKILL.md");
79610
+ const installed = (0, import_node_fs50.existsSync)(installedMd) ? skillVersion(installedMd) : null;
79012
79611
  const action = decideAction(installed, s.version);
79013
79612
  if (action === "installed" || action === "updated") {
79014
79613
  try {
79015
- if (action === "updated") (0, import_node_fs48.rmSync)(dest, { recursive: true, force: true });
79016
- (0, import_node_fs48.cpSync)(s.dir, dest, { recursive: true });
79614
+ if (action === "updated") (0, import_node_fs50.rmSync)(dest, { recursive: true, force: true });
79615
+ (0, import_node_fs50.cpSync)(s.dir, dest, { recursive: true });
79017
79616
  results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
79018
79617
  } catch {
79019
79618
  }
@@ -79027,19 +79626,19 @@ function syncSkills() {
79027
79626
 
79028
79627
  // watch.ts
79029
79628
  var import_node_os26 = require("node:os");
79030
- var import_node_path47 = require("node:path");
79031
- var import_node_fs49 = require("node:fs");
79629
+ var import_node_path49 = require("node:path");
79630
+ var import_node_fs51 = require("node:fs");
79032
79631
 
79033
79632
  // node_modules/chokidar/esm/index.js
79034
79633
  var import_fs2 = require("fs");
79035
- var import_promises8 = require("fs/promises");
79634
+ var import_promises9 = require("fs/promises");
79036
79635
  var import_events = require("events");
79037
79636
  var sysPath2 = __toESM(require("path"), 1);
79038
79637
 
79039
79638
  // node_modules/readdirp/esm/index.js
79040
- var import_promises6 = require("node:fs/promises");
79639
+ var import_promises7 = require("node:fs/promises");
79041
79640
  var import_node_stream4 = require("node:stream");
79042
- var import_node_path46 = require("node:path");
79641
+ var import_node_path48 = require("node:path");
79043
79642
  var EntryTypes = {
79044
79643
  FILE_TYPE: "files",
79045
79644
  DIR_TYPE: "directories",
@@ -79104,7 +79703,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
79104
79703
  const { root: root4, type } = opts;
79105
79704
  this._fileFilter = normalizeFilter(opts.fileFilter);
79106
79705
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
79107
- const statMethod = opts.lstat ? import_promises6.lstat : import_promises6.stat;
79706
+ const statMethod = opts.lstat ? import_promises7.lstat : import_promises7.stat;
79108
79707
  if (wantBigintFsStats) {
79109
79708
  this._stat = (path) => statMethod(path, { bigint: true });
79110
79709
  } else {
@@ -79114,7 +79713,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
79114
79713
  this._wantsDir = type ? DIR_TYPES.has(type) : false;
79115
79714
  this._wantsFile = type ? FILE_TYPES.has(type) : false;
79116
79715
  this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
79117
- this._root = (0, import_node_path46.resolve)(root4);
79716
+ this._root = (0, import_node_path48.resolve)(root4);
79118
79717
  this._isDirent = !opts.alwaysStat;
79119
79718
  this._statsProp = this._isDirent ? "dirent" : "stats";
79120
79719
  this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
@@ -79175,7 +79774,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
79175
79774
  async _exploreDir(path, depth) {
79176
79775
  let files2;
79177
79776
  try {
79178
- files2 = await (0, import_promises6.readdir)(path, this._rdOptions);
79777
+ files2 = await (0, import_promises7.readdir)(path, this._rdOptions);
79179
79778
  } catch (error) {
79180
79779
  this._onError(error);
79181
79780
  }
@@ -79185,8 +79784,8 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
79185
79784
  let entry2;
79186
79785
  const basename11 = this._isDirent ? dirent.name : dirent;
79187
79786
  try {
79188
- const fullPath = (0, import_node_path46.resolve)((0, import_node_path46.join)(path, basename11));
79189
- entry2 = { path: (0, import_node_path46.relative)(this._root, fullPath), fullPath, basename: basename11 };
79787
+ const fullPath = (0, import_node_path48.resolve)((0, import_node_path48.join)(path, basename11));
79788
+ entry2 = { path: (0, import_node_path48.relative)(this._root, fullPath), fullPath, basename: basename11 };
79190
79789
  entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
79191
79790
  } catch (err2) {
79192
79791
  this._onError(err2);
@@ -79213,14 +79812,14 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
79213
79812
  if (stats && stats.isSymbolicLink()) {
79214
79813
  const full = entry2.fullPath;
79215
79814
  try {
79216
- const entryRealPath = await (0, import_promises6.realpath)(full);
79217
- const entryRealPathStats = await (0, import_promises6.lstat)(entryRealPath);
79815
+ const entryRealPath = await (0, import_promises7.realpath)(full);
79816
+ const entryRealPathStats = await (0, import_promises7.lstat)(entryRealPath);
79218
79817
  if (entryRealPathStats.isFile()) {
79219
79818
  return "file";
79220
79819
  }
79221
79820
  if (entryRealPathStats.isDirectory()) {
79222
79821
  const len = entryRealPath.length;
79223
- if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path46.sep) {
79822
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path48.sep) {
79224
79823
  const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
79225
79824
  recursiveError.code = RECURSIVE_ERROR_CODE;
79226
79825
  return this._onError(recursiveError);
@@ -79257,7 +79856,7 @@ function readdirp(root4, options = {}) {
79257
79856
 
79258
79857
  // node_modules/chokidar/esm/handler.js
79259
79858
  var import_fs = require("fs");
79260
- var import_promises7 = require("fs/promises");
79859
+ var import_promises8 = require("fs/promises");
79261
79860
  var sysPath = __toESM(require("path"), 1);
79262
79861
  var import_os = require("os");
79263
79862
  var STR_DATA = "data";
@@ -79284,7 +79883,7 @@ var EVENTS = {
79284
79883
  };
79285
79884
  var EV = EVENTS;
79286
79885
  var THROTTLE_MODE_WATCH = "watch";
79287
- var statMethods = { lstat: import_promises7.lstat, stat: import_promises7.stat };
79886
+ var statMethods = { lstat: import_promises8.lstat, stat: import_promises8.stat };
79288
79887
  var KEY_LISTENERS = "listeners";
79289
79888
  var KEY_ERR = "errHandlers";
79290
79889
  var KEY_RAW = "rawEmitters";
@@ -79641,7 +80240,7 @@ var setFsWatchListener = (path, fullPath, options, handlers) => {
79641
80240
  cont.watcherUnusable = true;
79642
80241
  if (isWindows && error.code === "EPERM") {
79643
80242
  try {
79644
- const fd2 = await (0, import_promises7.open)(path, "r");
80243
+ const fd2 = await (0, import_promises8.open)(path, "r");
79645
80244
  await fd2.close();
79646
80245
  broadcastErr(error);
79647
80246
  } catch (err2) {
@@ -79759,9 +80358,9 @@ var NodeFsHandler = class {
79759
80358
  if (this.fsw.closed) {
79760
80359
  return;
79761
80360
  }
79762
- const dirname22 = sysPath.dirname(file);
80361
+ const dirname23 = sysPath.dirname(file);
79763
80362
  const basename11 = sysPath.basename(file);
79764
- const parent = this.fsw._getWatchedDir(dirname22);
80363
+ const parent = this.fsw._getWatchedDir(dirname23);
79765
80364
  let prevStats = stats;
79766
80365
  if (parent.has(basename11))
79767
80366
  return;
@@ -79770,7 +80369,7 @@ var NodeFsHandler = class {
79770
80369
  return;
79771
80370
  if (!newStats || newStats.mtimeMs === 0) {
79772
80371
  try {
79773
- const newStats2 = await (0, import_promises7.stat)(file);
80372
+ const newStats2 = await (0, import_promises8.stat)(file);
79774
80373
  if (this.fsw.closed)
79775
80374
  return;
79776
80375
  const at = newStats2.atimeMs;
@@ -79788,7 +80387,7 @@ var NodeFsHandler = class {
79788
80387
  prevStats = newStats2;
79789
80388
  }
79790
80389
  } catch (error) {
79791
- this.fsw._remove(dirname22, basename11);
80390
+ this.fsw._remove(dirname23, basename11);
79792
80391
  }
79793
80392
  } else if (parent.has(basename11)) {
79794
80393
  const at = newStats.atimeMs;
@@ -79825,7 +80424,7 @@ var NodeFsHandler = class {
79825
80424
  this.fsw._incrReadyCount();
79826
80425
  let linkPath;
79827
80426
  try {
79828
- linkPath = await (0, import_promises7.realpath)(path);
80427
+ linkPath = await (0, import_promises8.realpath)(path);
79829
80428
  } catch (e) {
79830
80429
  this.fsw._emitReady();
79831
80430
  return true;
@@ -79884,7 +80483,7 @@ var NodeFsHandler = class {
79884
80483
  this._addToNodeFs(path, initialAdd, wh, depth + 1);
79885
80484
  }
79886
80485
  }).on(EV.ERROR, this._boundHandleError);
79887
- return new Promise((resolve11, reject) => {
80486
+ return new Promise((resolve12, reject) => {
79888
80487
  if (!stream)
79889
80488
  return reject();
79890
80489
  stream.once(STR_END, () => {
@@ -79893,7 +80492,7 @@ var NodeFsHandler = class {
79893
80492
  return;
79894
80493
  }
79895
80494
  const wasThrottled = throttler ? throttler.clear() : false;
79896
- resolve11(void 0);
80495
+ resolve12(void 0);
79897
80496
  previous.getChildren().filter((item) => {
79898
80497
  return item !== directory && !current.has(item);
79899
80498
  }).forEach((item) => {
@@ -79973,7 +80572,7 @@ var NodeFsHandler = class {
79973
80572
  let closer;
79974
80573
  if (stats.isDirectory()) {
79975
80574
  const absPath = sysPath.resolve(path);
79976
- const targetPath = follow ? await (0, import_promises7.realpath)(path) : path;
80575
+ const targetPath = follow ? await (0, import_promises8.realpath)(path) : path;
79977
80576
  if (this.fsw.closed)
79978
80577
  return;
79979
80578
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -79983,7 +80582,7 @@ var NodeFsHandler = class {
79983
80582
  this.fsw._symlinkPaths.set(absPath, targetPath);
79984
80583
  }
79985
80584
  } else if (stats.isSymbolicLink()) {
79986
- const targetPath = follow ? await (0, import_promises7.realpath)(path) : path;
80585
+ const targetPath = follow ? await (0, import_promises8.realpath)(path) : path;
79987
80586
  if (this.fsw.closed)
79988
80587
  return;
79989
80588
  const parent = sysPath.dirname(wh.watchPath);
@@ -80144,7 +80743,7 @@ var DirEntry = class {
80144
80743
  return;
80145
80744
  const dir = this.path;
80146
80745
  try {
80147
- await (0, import_promises8.readdir)(dir);
80746
+ await (0, import_promises9.readdir)(dir);
80148
80747
  } catch (err2) {
80149
80748
  if (this._removeWatcher) {
80150
80749
  this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
@@ -80469,7 +81068,7 @@ var FSWatcher = class extends import_events.EventEmitter {
80469
81068
  const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path) : path;
80470
81069
  let stats2;
80471
81070
  try {
80472
- stats2 = await (0, import_promises8.stat)(fullPath);
81071
+ stats2 = await (0, import_promises9.stat)(fullPath);
80473
81072
  } catch (err2) {
80474
81073
  }
80475
81074
  if (!stats2 || this.closed)
@@ -80728,33 +81327,33 @@ function appIdFromLogPath(path) {
80728
81327
  return i >= 0 && parts[i + 1] ? parts[i + 1] : null;
80729
81328
  }
80730
81329
  function samePath(a, b) {
80731
- const ra = (0, import_node_path47.resolve)(a);
80732
- const rb = (0, import_node_path47.resolve)(b);
81330
+ const ra = (0, import_node_path49.resolve)(a);
81331
+ const rb = (0, import_node_path49.resolve)(b);
80733
81332
  return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
80734
81333
  }
80735
81334
  function underDir(path, dir) {
80736
- const rp = (0, import_node_path47.resolve)(path);
80737
- const rd = (0, import_node_path47.resolve)(dir);
81335
+ const rp = (0, import_node_path49.resolve)(path);
81336
+ const rd = (0, import_node_path49.resolve)(dir);
80738
81337
  const [p, d] = process.platform === "win32" ? [rp.toLowerCase(), rd.toLowerCase()] : [rp, rd];
80739
- return p === d || p.startsWith(d + import_node_path47.sep);
81338
+ return p === d || p.startsWith(d + import_node_path49.sep);
80740
81339
  }
80741
81340
  function startWatcher() {
80742
- const awareDir = process.env.AWARE_HOME ?? (0, import_node_path47.join)((0, import_node_os26.homedir)(), ".aware");
80743
- const credentialsDir = (0, import_node_path47.join)(awareDir, "credentials");
80744
- if (!(0, import_node_fs49.existsSync)(credentialsDir)) {
81341
+ const awareDir = process.env.AWARE_HOME ?? (0, import_node_path49.join)((0, import_node_os26.homedir)(), ".aware");
81342
+ const credentialsDir = (0, import_node_path49.join)(awareDir, "credentials");
81343
+ if (!(0, import_node_fs51.existsSync)(credentialsDir)) {
80745
81344
  try {
80746
- (0, import_node_fs49.mkdirSync)(credentialsDir, { recursive: true });
81345
+ (0, import_node_fs51.mkdirSync)(credentialsDir, { recursive: true });
80747
81346
  } catch {
80748
81347
  }
80749
81348
  }
80750
- if (!(0, import_node_fs49.existsSync)(uiDir)) {
81349
+ if (!(0, import_node_fs51.existsSync)(uiDir)) {
80751
81350
  try {
80752
- (0, import_node_fs49.mkdirSync)(uiDir, { recursive: true });
81351
+ (0, import_node_fs51.mkdirSync)(uiDir, { recursive: true });
80753
81352
  } catch {
80754
81353
  }
80755
81354
  }
80756
- const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path47.join)(awareDir, d)).filter((p) => (0, import_node_fs49.existsSync)(p));
80757
- if ((0, import_node_fs49.existsSync)(uiDir)) targets.push(uiDir);
81355
+ const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path49.join)(awareDir, d)).filter((p) => (0, import_node_fs51.existsSync)(p));
81356
+ if ((0, import_node_fs51.existsSync)(uiDir)) targets.push(uiDir);
80758
81357
  if (targets.length === 0) {
80759
81358
  return null;
80760
81359
  }
@@ -80783,11 +81382,11 @@ function startWatcher() {
80783
81382
  const isCredential = path.split(/[\\/]/).includes("credentials");
80784
81383
  const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
80785
81384
  broadcast({ type: "fs-change", kind, event, path });
80786
- if (kind === "trace" && event !== "unlink" && (0, import_node_fs49.existsSync)(path)) {
81385
+ if (kind === "trace" && event !== "unlink" && (0, import_node_fs51.existsSync)(path)) {
80787
81386
  const id = appIdFromLogPath(path);
80788
81387
  if (!id) return;
80789
81388
  try {
80790
- broadcast({ type: "trace-file", id, runId: path.split(import_node_path47.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs49.readFileSync)(path, "utf8")) });
81389
+ broadcast({ type: "trace-file", id, runId: path.split(import_node_path49.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs51.readFileSync)(path, "utf8")) });
80791
81390
  } catch {
80792
81391
  }
80793
81392
  }
@@ -80796,10 +81395,10 @@ function startWatcher() {
80796
81395
  }
80797
81396
 
80798
81397
  // index.ts
80799
- var __dirname4 = (0, import_node_path48.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
80800
- var WEB_ROOT = [(0, import_node_path48.join)(__dirname4, "web"), (0, import_node_path48.join)((0, import_node_path48.dirname)(process.execPath), "web"), (0, import_node_path48.join)(__dirname4, "..", "web")].find(
80801
- (p) => (0, import_node_fs50.existsSync)(p)
80802
- ) ?? (0, import_node_path48.join)(__dirname4, "..", "web");
81398
+ var __dirname4 = (0, import_node_path50.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
81399
+ var WEB_ROOT = [(0, import_node_path50.join)(__dirname4, "web"), (0, import_node_path50.join)((0, import_node_path50.dirname)(process.execPath), "web"), (0, import_node_path50.join)(__dirname4, "..", "web")].find(
81400
+ (p) => (0, import_node_fs52.existsSync)(p)
81401
+ ) ?? (0, import_node_path50.join)(__dirname4, "..", "web");
80803
81402
  var PORT2 = Number(process.env.PORT ?? 4317);
80804
81403
  var HOST = "127.0.0.1";
80805
81404
  var crashHandlersInstalled = false;
@@ -80815,7 +81414,7 @@ function installCrashHandlers() {
80815
81414
  ${stack}
80816
81415
  `;
80817
81416
  try {
80818
- (0, import_node_fs50.appendFileSync)(logFilePath(), line);
81417
+ (0, import_node_fs52.appendFileSync)(logFilePath(), line);
80819
81418
  } catch {
80820
81419
  }
80821
81420
  if (process.stderr.isTTY) process.stderr.write(line);
@@ -80879,16 +81478,25 @@ async function startServer() {
80879
81478
  const MIN_AWARE = TEKLA_AWARE_FLOOR;
80880
81479
  const SHARE_3D_AWARE_FLOOR = "0.96.0";
80881
81480
  const isWin3 = process.platform === "win32";
80882
- const has = (cmd) => {
80883
- try {
80884
- (0, import_node_child_process11.execFileSync)(isWin3 ? "where" : "which", [cmd], { stdio: "ignore", windowsHide: true, timeout: 5e3 });
80885
- return true;
80886
- } catch {
80887
- return false;
81481
+ const execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process11.execFile);
81482
+ const lookUpOnPath = toolchainLookup(execFileAsync2, {
81483
+ isWin: isWin3,
81484
+ onFailure: ({ cmd, attempt, outcome, err: err2 }) => {
81485
+ const e = err2;
81486
+ app.log.warn(
81487
+ { cmd, attempt, outcome, code: e?.code, killed: e?.killed, signal: e?.signal },
81488
+ "PATH lookup did not complete"
81489
+ );
80888
81490
  }
80889
- };
81491
+ });
80890
81492
  const bootstrapDeps = {
80891
- probeToolchain: () => ({ hasNode: has("node"), hasNpm: has("npm") }),
81493
+ // Concurrent, not sequential: these are independent, and serialising them doubled
81494
+ // the worst case to ~62 s of "Checking for AWARE…" while holding the AWARE
81495
+ // exclusive lock — on precisely the saturated machine this fix exists to serve.
81496
+ probeToolchain: async () => {
81497
+ const [node, npm] = await Promise.all([lookUpOnPath("node"), lookUpOnPath("npm")]);
81498
+ return { node, npm };
81499
+ },
80892
81500
  getAware: () => {
80893
81501
  const v = aware.npmVersion();
80894
81502
  return { installed: v !== null, version: v };
@@ -80898,11 +81506,12 @@ async function startServer() {
80898
81506
  refreshInvoker,
80899
81507
  emit: broadcast,
80900
81508
  floor: MIN_AWARE,
80901
- skip: process.env.AWARE_SKIP_BOOTSTRAP === "1"
81509
+ skip: process.env.AWARE_SKIP_BOOTSTRAP === "1",
81510
+ logWarn: (msg, fields) => app.log.warn(fields, msg)
80902
81511
  };
80903
- const AWARE_BRIDGE_DIRECTORY = (0, import_node_path48.join)((0, import_node_os27.homedir)(), ".aware", "bridges");
81512
+ const AWARE_BRIDGE_DIRECTORY = (0, import_node_path50.join)((0, import_node_os27.homedir)(), ".aware", "bridges");
80904
81513
  const awareMaintenance = createMaintenanceMarkerStore(
80905
- (0, import_node_path48.join)((0, import_node_os27.homedir)(), ".floless", "aware-maintenance.json")
81514
+ (0, import_node_path50.join)((0, import_node_os27.homedir)(), ".floless", "aware-maintenance.json")
80906
81515
  );
80907
81516
  function upgradeOwner() {
80908
81517
  const owner2 = currentAwareOwner();
@@ -80992,7 +81601,7 @@ async function startServer() {
80992
81601
  let snapshot = marker?.snapshot ?? await snapshotPersistentBridges(AWARE_BRIDGE_DIRECTORY);
80993
81602
  let recoveryMarker = {
80994
81603
  schema: 1,
80995
- transaction: marker?.transaction ?? (0, import_node_crypto24.randomUUID)(),
81604
+ transaction: marker?.transaction ?? (0, import_node_crypto26.randomUUID)(),
80996
81605
  stage: "recovery",
80997
81606
  target,
80998
81607
  snapshot
@@ -81264,7 +81873,7 @@ async function startServer() {
81264
81873
  app.post("/api/bootstrap/retry", async () => {
81265
81874
  const st = getBootstrapState().status;
81266
81875
  if (st === "failed" || st === "idle") {
81267
- void startAwareBootstrap();
81876
+ void startAwareBootstrap().catch((err2) => app.log.error({ err: err2 instanceof Error ? err2.stack ?? err2.message : String(err2) }, "bootstrap retry failed"));
81268
81877
  }
81269
81878
  return { ok: true, bootstrap: getBootstrapState().status };
81270
81879
  });
@@ -81351,10 +81960,10 @@ async function startServer() {
81351
81960
  const bdir = backupDir(id, fromVersion, Date.now());
81352
81961
  let backedUp = false;
81353
81962
  try {
81354
- (0, import_node_fs50.mkdirSync)((0, import_node_path48.dirname)(bdir), { recursive: true });
81355
- (0, import_node_fs50.cpSync)(appDirPath2, bdir, { recursive: true });
81963
+ (0, import_node_fs52.mkdirSync)((0, import_node_path50.dirname)(bdir), { recursive: true });
81964
+ (0, import_node_fs52.cpSync)(appDirPath2, bdir, { recursive: true });
81356
81965
  backedUp = true;
81357
- (0, import_node_fs50.cpSync)(templatePath, srcPath);
81966
+ (0, import_node_fs52.cpSync)(templatePath, srcPath);
81358
81967
  if (id !== templateId) stampSourceAppId(srcPath, id);
81359
81968
  if (contract != null) {
81360
81969
  bakeContractIntoApp(srcPath, contract);
@@ -81368,8 +81977,8 @@ async function startServer() {
81368
81977
  throw new TemplateSwapError(`${verb} failed before any change was made (${msg}) \u2014 the workflow is untouched`, `${verb}-not-started`);
81369
81978
  }
81370
81979
  try {
81371
- (0, import_node_fs50.rmSync)(appDirPath2, { recursive: true, force: true });
81372
- (0, import_node_fs50.cpSync)(bdir, appDirPath2, { recursive: true });
81980
+ (0, import_node_fs52.rmSync)(appDirPath2, { recursive: true, force: true });
81981
+ (0, import_node_fs52.cpSync)(bdir, appDirPath2, { recursive: true });
81373
81982
  } catch (re) {
81374
81983
  const rmsg = re instanceof Error ? re.message : String(re);
81375
81984
  throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
@@ -81381,7 +81990,7 @@ async function startServer() {
81381
81990
  function readSwapContract(id, verb) {
81382
81991
  const gerund = verb === "update" ? "updating" : "restoring";
81383
81992
  const contract = readAcceptedForRequest(id, void 0);
81384
- if (contract == null && (0, import_node_fs50.existsSync)(contractPath(id))) {
81993
+ if (contract == null && (0, import_node_fs52.existsSync)(contractPath(id))) {
81385
81994
  return { ok: false, body: { ok: false, error: `"${id}"'s saved data is unreadable \u2014 open it in the editor and re-save before ${gerund}`, code: "contract-corrupt" } };
81386
81995
  }
81387
81996
  if (contract != null && !validateContract(contract).valid) {
@@ -81678,7 +82287,7 @@ async function startServer() {
81678
82287
  }
81679
82288
  let data;
81680
82289
  try {
81681
- data = (0, import_node_fs50.readFileSync)(thumb.path);
82290
+ data = (0, import_node_fs52.readFileSync)(thumb.path);
81682
82291
  } catch {
81683
82292
  return reply.status(404).send({ ok: false, error: "no thumbnail" });
81684
82293
  }
@@ -81936,9 +82545,9 @@ async function startServer() {
81936
82545
  const bad = projectAppMismatch(req.params.appId, project);
81937
82546
  if (bad) return reply.status(404).send({ ok: false, error: bad });
81938
82547
  const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
81939
- const file = (0, import_node_path48.join)((0, import_node_path48.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
81940
- if (!(0, import_node_fs50.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
81941
- return reply.type("image/svg+xml").send((0, import_node_fs50.readFileSync)(file, "utf8"));
82548
+ const file = (0, import_node_path50.join)((0, import_node_path50.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
82549
+ if (!(0, import_node_fs52.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
82550
+ return reply.type("image/svg+xml").send((0, import_node_fs52.readFileSync)(file, "utf8"));
81942
82551
  }
81943
82552
  );
81944
82553
  app.put(
@@ -82037,17 +82646,29 @@ async function startServer() {
82037
82646
  { bodyLimit: 25 * 1024 * 1024 },
82038
82647
  // contracts embed rasters (matches /scene + PUT) — the editor/host-AI POSTs the live contract to score
82039
82648
  async (req, reply) => {
82040
- const candidate = req.body && "contract" in req.body ? req.body.contract : readAcceptedForRequest(req.params.appId, void 0);
82041
- if (candidate == null) return reply.status(404).send({ ok: false, error: "no contract to score" });
82649
+ const project = req.query.project || void 0;
82650
+ if (project) {
82651
+ const bad = projectAppMismatch(req.params.appId, project);
82652
+ if (bad) return reply.status(404).send({ ok: false, error: bad });
82653
+ }
82654
+ const candidate = req.body && "contract" in req.body ? req.body.contract : readAcceptedForRequest(req.params.appId, project);
82655
+ if (candidate == null) {
82656
+ return reply.status(404).send({
82657
+ ok: false,
82658
+ error: project ? `no contract for project ${project} to score` : "no contract to score"
82659
+ });
82660
+ }
82042
82661
  const steel = acceptSteelForRoute(candidate, { appId: req.params.appId }, "request-body", "v1-only");
82043
82662
  if (!steel.accepted) return reply.status(400).send(steel.refusal);
82044
82663
  const doc = steel.doc;
82045
82664
  const docTarget = doc && typeof doc === "object" ? doc.target_confidence : void 0;
82046
82665
  let appDefault = 70;
82047
- try {
82048
- const inp = readApp(req.params.appId).inputs.find((i) => i.name === "target_confidence");
82049
- if (typeof inp?.default === "number") appDefault = inp.default;
82050
- } catch {
82666
+ if (!project) {
82667
+ try {
82668
+ const inp = readApp(req.params.appId).inputs.find((i) => i.name === "target_confidence");
82669
+ if (typeof inp?.default === "number") appDefault = inp.default;
82670
+ } catch {
82671
+ }
82051
82672
  }
82052
82673
  const target = typeof req.body?.target === "number" ? req.body.target : typeof docTarget === "number" ? docTarget : appDefault;
82053
82674
  const result = scoreContract2(doc);
@@ -82103,7 +82724,7 @@ async function startServer() {
82103
82724
  }
82104
82725
  const statedAt = (filename) => {
82105
82726
  try {
82106
- const st = (0, import_node_fs50.statSync)((0, import_node_path48.join)(dir, filename));
82727
+ const st = (0, import_node_fs52.statSync)((0, import_node_path50.join)(dir, filename));
82107
82728
  return st.isFile() ? st.mtime.toISOString() : null;
82108
82729
  } catch {
82109
82730
  return null;
@@ -82113,14 +82734,14 @@ async function startServer() {
82113
82734
  const rows2 = (byKind.get(kind) ?? []).map((receipt) => ({
82114
82735
  variant: receipt.variant ?? null,
82115
82736
  filename: receipt.filename,
82116
- path: (0, import_node_path48.join)(dir, receipt.filename),
82737
+ path: (0, import_node_path50.join)(dir, receipt.filename),
82117
82738
  exportedAt: statedAt(receipt.filename)
82118
82739
  })).sort((a, b) => String(b.exportedAt ?? "").localeCompare(String(a.exportedAt ?? "")));
82119
82740
  const headline = rows2[0];
82120
82741
  return {
82121
82742
  kind,
82122
82743
  filename: headline?.filename ?? legacy,
82123
- path: headline?.path ?? (0, import_node_path48.join)(dir, legacy),
82744
+ path: headline?.path ?? (0, import_node_path50.join)(dir, legacy),
82124
82745
  exportedAt: headline?.exportedAt ?? null,
82125
82746
  ...rows2.length ? { variants: rows2 } : {}
82126
82747
  };
@@ -82147,8 +82768,8 @@ async function startServer() {
82147
82768
  async () => withLifecycleLock("app", `${appId}-3d`, async () => {
82148
82769
  let projectSnapshot;
82149
82770
  if (project) {
82150
- const gate2 = projectExportGate(appId, project);
82151
- if (gate2) return reply.status(gate2.status).send({ ok: false, error: gate2.error });
82771
+ const gate3 = projectExportGate(appId, project);
82772
+ if (gate3) return reply.status(gate3.status).send({ ok: false, error: gate3.error });
82152
82773
  try {
82153
82774
  projectSnapshot = currentApprovedSnapshot(project);
82154
82775
  } catch (error) {
@@ -82219,7 +82840,7 @@ async function startServer() {
82219
82840
  }
82220
82841
  async function dropExportSourceId(appId, project) {
82221
82842
  const ownerId = project ? await getOrCreateProjectExportSourceId(project) : await getOrCreateWorkflowExportSourceId(appId);
82222
- return deriveDropExportSourceId(project ? "project" : "workflow", ownerId, (0, import_node_crypto24.randomUUID)());
82843
+ return deriveDropExportSourceId(project ? "project" : "workflow", ownerId, (0, import_node_crypto26.randomUUID)());
82223
82844
  }
82224
82845
  async function continueIfcExport(input, reply) {
82225
82846
  const appId = input.appId;
@@ -82260,7 +82881,7 @@ async function startServer() {
82260
82881
  }
82261
82882
  if (!hasExportableSceneRecords(scene)) return reply.status(422).send({ ok: false, error: emptyError, skipped });
82262
82883
  const filename = `${exportFileBase(project, appId)}.ifc`;
82263
- const finalPath = (0, import_node_path48.join)(project ? projectExportsDir(project) : (0, import_node_path48.dirname)(bomExportPath(appId, "csv")), filename);
82884
+ const finalPath = (0, import_node_path50.join)(project ? projectExportsDir(project) : (0, import_node_path50.dirname)(bomExportPath(appId, "csv")), filename);
82264
82885
  const priorProjectIfc = project ? listProjectExportReceipts(project).find((row) => row.kind === "ifc") : void 0;
82265
82886
  const tempPath = requestIfcTempPath(finalPath);
82266
82887
  try {
@@ -82268,15 +82889,15 @@ async function startServer() {
82268
82889
  scene,
82269
82890
  "output-path": tempPath
82270
82891
  });
82271
- if (!(0, import_node_fs50.existsSync)(tempPath) || (0, import_node_fs50.statSync)(tempPath).size === 0) {
82892
+ if (!(0, import_node_fs52.existsSync)(tempPath) || (0, import_node_fs52.statSync)(tempPath).size === 0) {
82272
82893
  throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
82273
82894
  }
82274
- const artifactBytes = (0, import_node_fs50.readFileSync)(tempPath);
82895
+ const artifactBytes = (0, import_node_fs52.readFileSync)(tempPath);
82275
82896
  const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
82276
82897
  index: parseStepData(artifactBytes),
82277
82898
  bytes: artifactBytes
82278
82899
  });
82279
- const expectedContentSha256 = (0, import_node_crypto24.createHash)("sha256").update(artifactBytes).digest("hex");
82900
+ const expectedContentSha256 = (0, import_node_crypto26.createHash)("sha256").update(artifactBytes).digest("hex");
82280
82901
  const transition = project && projectSnapshot ? prepareProjectExport(project, {
82281
82902
  kind: "ifc",
82282
82903
  filename,
@@ -82326,7 +82947,7 @@ async function startServer() {
82326
82947
  ok: false,
82327
82948
  error: awareFailureMessage(error, "IFC export failed"),
82328
82949
  ...reason ? { reason } : {},
82329
- preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs50.existsSync)(finalPath)
82950
+ preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs52.existsSync)(finalPath)
82330
82951
  });
82331
82952
  } finally {
82332
82953
  cleanupIfcTemp(tempPath);
@@ -82370,10 +82991,10 @@ async function startServer() {
82370
82991
  const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
82371
82992
  if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
82372
82993
  const path = resolveProjectExportReceiptPath(project, receipt);
82373
- if (!path || !(0, import_node_fs50.existsSync)(path)) {
82994
+ if (!path || !(0, import_node_fs52.existsSync)(path)) {
82374
82995
  return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
82375
82996
  }
82376
- return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs50.readFileSync)(path));
82997
+ return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs52.readFileSync)(path));
82377
82998
  });
82378
82999
  const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
82379
83000
  app.post("/api/contract/:appId/render", async (req, reply) => {
@@ -82405,8 +83026,8 @@ async function startServer() {
82405
83026
  return reply.status(409).send({ ok: false, error: readiness.message, readiness });
82406
83027
  }
82407
83028
  return withLifecycleLock("project", project, async () => {
82408
- const gate2 = projectExportGate(appId, project);
82409
- if (gate2) return reply.status(gate2.status).send({ ok: false, error: gate2.error });
83029
+ const gate3 = projectExportGate(appId, project);
83030
+ if (gate3) return reply.status(gate3.status).send({ ok: false, error: gate3.error });
82410
83031
  let projectSnapshot;
82411
83032
  try {
82412
83033
  projectSnapshot = currentApprovedSnapshot(project);
@@ -82430,8 +83051,8 @@ async function startServer() {
82430
83051
  }
82431
83052
  const kind = output === "turntable" ? "render-mp4" : "render-png";
82432
83053
  const extension = output === "turntable" ? ".mp4" : ".png";
82433
- const scratch = (0, import_node_fs50.mkdtempSync)((0, import_node_path48.join)((0, import_node_os27.tmpdir)(), "floless-render-"));
82434
- const ifcPath = (0, import_node_path48.join)(scratch, "model.ifc");
83054
+ const scratch = (0, import_node_fs52.mkdtempSync)((0, import_node_path50.join)((0, import_node_os27.tmpdir)(), "floless-render-"));
83055
+ const ifcPath = (0, import_node_path50.join)(scratch, "model.ifc");
82435
83056
  const rendered = [];
82436
83057
  const progress = (stage, extra = {}) => {
82437
83058
  try {
@@ -82442,13 +83063,13 @@ async function startServer() {
82442
83063
  try {
82443
83064
  progress("preparing");
82444
83065
  await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
82445
- if (!(0, import_node_fs50.existsSync)(ifcPath) || (0, import_node_fs50.statSync)(ifcPath).size === 0) {
83066
+ if (!(0, import_node_fs52.existsSync)(ifcPath) || (0, import_node_fs52.statSync)(ifcPath).size === 0) {
82446
83067
  throw new Error("AWARE reported a successful IFC write but produced no file to render");
82447
83068
  }
82448
83069
  const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
82449
83070
  for (const [i, viewpoint] of viewpoints.entries()) {
82450
83071
  progress("rendering", { viewpoint, index: i + 1, output });
82451
- const artifactPath = (0, import_node_path48.join)(scratch, `render-${viewpoint}${extension}`);
83072
+ const artifactPath = (0, import_node_path50.join)(scratch, `render-${viewpoint}${extension}`);
82452
83073
  const receipt = await aware.agentInvoke(RENDER_AGENT_ID, output === "turntable" ? "render.turntable" : "render.still", {
82453
83074
  "ifc-path": ifcPath,
82454
83075
  "output-path": artifactPath,
@@ -82460,10 +83081,10 @@ async function startServer() {
82460
83081
  environment: "studio",
82461
83082
  ...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
82462
83083
  }, { timeoutMs: renderBudgetMs });
82463
- if (!(0, import_node_fs50.existsSync)(artifactPath) || (0, import_node_fs50.statSync)(artifactPath).size === 0) {
83084
+ if (!(0, import_node_fs52.existsSync)(artifactPath) || (0, import_node_fs52.statSync)(artifactPath).size === 0) {
82464
83085
  throw new Error(`the ${viewpoint} render reported success but produced no image`);
82465
83086
  }
82466
- const bytes = (0, import_node_fs50.readFileSync)(artifactPath);
83087
+ const bytes = (0, import_node_fs52.readFileSync)(artifactPath);
82467
83088
  const preferred = `${exportFileBase(project, appId)}-${viewpoint}${extension}`;
82468
83089
  const filename = uniqueProjectExportFilename(project, preferred);
82469
83090
  publishProjectExportArtifact(project, {
@@ -82499,7 +83120,7 @@ async function startServer() {
82499
83120
  // Kept for a single-viewpoint caller so the existing shape still reads naturally.
82500
83121
  filename: rendered[0]?.filename,
82501
83122
  viewpoint: rendered[0]?.viewpoint,
82502
- savedTo: rendered[0] ? (0, import_node_path48.join)(projectExportsDir(project), rendered[0].filename) : void 0
83123
+ savedTo: rendered[0] ? (0, import_node_path50.join)(projectExportsDir(project), rendered[0].filename) : void 0
82503
83124
  };
82504
83125
  } catch (error) {
82505
83126
  const reason = awareStderr(error);
@@ -82517,7 +83138,7 @@ async function startServer() {
82517
83138
  rendered
82518
83139
  });
82519
83140
  } finally {
82520
- (0, import_node_fs50.rmSync)(scratch, { recursive: true, force: true });
83141
+ (0, import_node_fs52.rmSync)(scratch, { recursive: true, force: true });
82521
83142
  }
82522
83143
  }, {
82523
83144
  // What anyone blocked on this project is told, and for how long to expect it. Erring long
@@ -82557,18 +83178,18 @@ async function startServer() {
82557
83178
  skipped: built.skipped
82558
83179
  });
82559
83180
  }
82560
- const companion = createExportCompanion(appId, "tekla");
83181
+ const companion2 = createExportCompanion(appId, "tekla");
82561
83182
  try {
82562
- const flo = writeTeklaApp(companion.path, companion.id, built.scene, readiness.host.version || await teklaVersionToBake());
82563
- stampExportCompanionLease(companion);
83183
+ const flo = writeTeklaApp(companion2.path, companion2.id, built.scene, readiness.host.version || await teklaVersionToBake());
83184
+ stampExportCompanionLease(companion2);
82564
83185
  await aware.compile(flo);
82565
83186
  let runResult;
82566
83187
  try {
82567
- runResult = await aware.run(companion.id, {});
83188
+ runResult = await aware.run(companion2.id, {});
82568
83189
  } catch (error) {
82569
83190
  const recoverable = error instanceof AwareError && /timeout|timed out|lost response|connection reset/i.test(`${error.message} ${awareStderr(error) || ""}`);
82570
83191
  if (!recoverable) throw error;
82571
- runResult = await aware.run(companion.id, {});
83192
+ runResult = await aware.run(companion2.id, {});
82572
83193
  }
82573
83194
  const events = runResult.traceText ? parseTrace(runResult.traceText) : [];
82574
83195
  const output = [...events].reverse().find((event) => event.kind === "node-output" && event.node === "bake-tekla");
@@ -82597,9 +83218,9 @@ async function startServer() {
82597
83218
  });
82598
83219
  } finally {
82599
83220
  try {
82600
- companion.cleanup();
83221
+ companion2.cleanup();
82601
83222
  } catch (error) {
82602
- app.log.error({ companionId: companion.id, error: error instanceof Error ? error.message : error }, "could not remove Tekla export companion");
83223
+ app.log.error({ companionId: companion2.id, error: error instanceof Error ? error.message : error }, "could not remove Tekla export companion");
82603
83224
  }
82604
83225
  }
82605
83226
  }
@@ -82637,27 +83258,27 @@ async function startServer() {
82637
83258
  skipped: built.skipped
82638
83259
  });
82639
83260
  }
82640
- const companion = createExportCompanion(appId, target.host);
83261
+ const companion2 = createExportCompanion(appId, target.host);
82641
83262
  try {
82642
83263
  const flo = target.writeApp(
82643
- companion.path,
82644
- companion.id,
83264
+ companion2.path,
83265
+ companion2.id,
82645
83266
  built.scene,
82646
83267
  genericBakeTarget(hostPid, readiness.session)
82647
83268
  );
82648
- stampExportCompanionLease(companion);
83269
+ stampExportCompanionLease(companion2);
82649
83270
  await aware.compile(flo);
82650
83271
  const env2 = readiness.bakeEnv;
82651
83272
  const runOpts = target.host === "rhino" ? { env: env2, timeoutMs: RHINO_BAKE_RUN_TIMEOUT_MS } : { env: env2 };
82652
83273
  let runResult;
82653
83274
  try {
82654
- runResult = await aware.run(companion.id, runOpts);
83275
+ runResult = await aware.run(companion2.id, runOpts);
82655
83276
  } catch (error) {
82656
83277
  const failureText = error instanceof Error ? `${error.message} ${error instanceof AwareError ? awareStderr(error) || "" : ""}` : String(error);
82657
83278
  const uncertainRhinoCompletion = target.host === "rhino" && /timeout|timed out|lost response|connection reset|commit[-_ ]state|still (?:be )?applying|uncertain/i.test(failureText);
82658
83279
  const recoverable = !uncertainRhinoCompletion && error instanceof AwareError && /timeout|timed out|lost response|connection reset/i.test(failureText);
82659
83280
  if (!recoverable) throw error;
82660
- runResult = await aware.run(companion.id, runOpts);
83281
+ runResult = await aware.run(companion2.id, runOpts);
82661
83282
  }
82662
83283
  const events = runResult.traceText ? parseTrace(runResult.traceText) : [];
82663
83284
  const output = [...events].reverse().find((event) => event.kind === "node-output" && event.node === target.nodeId);
@@ -82689,9 +83310,9 @@ async function startServer() {
82689
83310
  });
82690
83311
  } finally {
82691
83312
  try {
82692
- companion.cleanup();
83313
+ companion2.cleanup();
82693
83314
  } catch (error) {
82694
- app.log.error({ companionId: companion.id, error: error instanceof Error ? error.message : error }, "could not remove host export companion");
83315
+ app.log.error({ companionId: companion2.id, error: error instanceof Error ? error.message : error }, "could not remove host export companion");
82695
83316
  }
82696
83317
  }
82697
83318
  }
@@ -82755,10 +83376,10 @@ async function startServer() {
82755
83376
  }
82756
83377
  const preferredFilename = `${exportFileBase(project, appId)}-bom.${format}`;
82757
83378
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
82758
- const outPath = project ? (0, import_node_path48.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
82759
- const dir = (0, import_node_path48.dirname)(outPath);
83379
+ const outPath = project ? (0, import_node_path50.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
83380
+ const dir = (0, import_node_path50.dirname)(outPath);
82760
83381
  try {
82761
- (0, import_node_fs50.mkdirSync)(dir, { recursive: true });
83382
+ (0, import_node_fs52.mkdirSync)(dir, { recursive: true });
82762
83383
  const kind = BOM_EXPORT_KIND[format];
82763
83384
  let text3 = null;
82764
83385
  let buf;
@@ -82785,8 +83406,8 @@ async function startServer() {
82785
83406
  version: projectSnapshot.version.n,
82786
83407
  contractHash: projectSnapshot.contractHash
82787
83408
  }, buf);
82788
- } else if (text3 != null) (0, import_node_fs50.writeFileSync)(outPath, text3, "utf8");
82789
- else (0, import_node_fs50.writeFileSync)(outPath, buf);
83409
+ } else if (text3 != null) (0, import_node_fs52.writeFileSync)(outPath, text3, "utf8");
83410
+ else (0, import_node_fs52.writeFileSync)(outPath, buf);
82790
83411
  return {
82791
83412
  ok: true,
82792
83413
  payload: text3 != null ? { filename, encoding: "utf8", content: text3, bytes: buf.length, savedTo: outPath } : { filename, encoding: "base64", content: buf.toString("base64"), bytes: buf.length, savedTo: outPath }
@@ -82824,9 +83445,9 @@ async function startServer() {
82824
83445
  const svg = contractToSvg(cleaned);
82825
83446
  const preferredFilename = `${exportFileBase(project, appId)}.svg`;
82826
83447
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
82827
- const outPath = project ? (0, import_node_path48.join)(projectExportsDir(project), filename) : (0, import_node_path48.join)(appPath(appId), filename);
83448
+ const outPath = project ? (0, import_node_path50.join)(projectExportsDir(project), filename) : (0, import_node_path50.join)(appPath(appId), filename);
82828
83449
  try {
82829
- (0, import_node_fs50.mkdirSync)((0, import_node_path48.dirname)(outPath), { recursive: true });
83450
+ (0, import_node_fs52.mkdirSync)((0, import_node_path50.dirname)(outPath), { recursive: true });
82830
83451
  if (project && projectSnapshot) {
82831
83452
  publishProjectExportArtifact(project, {
82832
83453
  kind: "svg",
@@ -82836,7 +83457,7 @@ async function startServer() {
82836
83457
  version: projectSnapshot.version.n,
82837
83458
  contractHash: projectSnapshot.contractHash
82838
83459
  }, Buffer.from(svg, "utf8"));
82839
- } else (0, import_node_fs50.writeFileSync)(outPath, svg, "utf8");
83460
+ } else (0, import_node_fs52.writeFileSync)(outPath, svg, "utf8");
82840
83461
  return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
82841
83462
  } catch (e) {
82842
83463
  app.log.error({ appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
@@ -82996,11 +83617,11 @@ async function startServer() {
82996
83617
  return reply.status(409).send({ ok: false, error: `a workflow named "${id}" is already installed \u2014 remove it first, or rename the file's app: id`, code: "exists", id });
82997
83618
  }
82998
83619
  await deleteOrigin(id);
82999
- const stageRoot = (0, import_node_fs50.mkdtempSync)((0, import_node_path48.join)((0, import_node_os27.tmpdir)(), "floless-import-"));
83620
+ const stageRoot = (0, import_node_fs52.mkdtempSync)((0, import_node_path50.join)((0, import_node_os27.tmpdir)(), "floless-import-"));
83000
83621
  try {
83001
- const stageDir = (0, import_node_path48.join)(stageRoot, id);
83002
- (0, import_node_fs50.mkdirSync)(stageDir);
83003
- (0, import_node_fs50.writeFileSync)((0, import_node_path48.join)(stageDir, `${id}.flo`), content);
83622
+ const stageDir = (0, import_node_path50.join)(stageRoot, id);
83623
+ (0, import_node_fs52.mkdirSync)(stageDir);
83624
+ (0, import_node_fs52.writeFileSync)((0, import_node_path50.join)(stageDir, `${id}.flo`), content);
83004
83625
  await aware.install(stageDir);
83005
83626
  } catch (err2) {
83006
83627
  try {
@@ -83011,7 +83632,7 @@ async function startServer() {
83011
83632
  const reason = awareStderr(err2);
83012
83633
  return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
83013
83634
  } finally {
83014
- (0, import_node_fs50.rmSync)(stageRoot, { recursive: true, force: true });
83635
+ (0, import_node_fs52.rmSync)(stageRoot, { recursive: true, force: true });
83015
83636
  }
83016
83637
  broadcast({ type: "apps-changed", id });
83017
83638
  return { ok: true, id };
@@ -83026,13 +83647,13 @@ async function startServer() {
83026
83647
  }
83027
83648
  const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
83028
83649
  const baked = bakeFloSource(appData.source.text, inputs);
83029
- const tmpRoot = (0, import_node_fs50.mkdtempSync)((0, import_node_path48.join)((0, import_node_os27.tmpdir)(), "floless-bake-"));
83030
- const backupDir2 = (0, import_node_path48.join)(tmpRoot, `${id}-backup`);
83031
- const bakeDir = (0, import_node_path48.join)(tmpRoot, id);
83032
- (0, import_node_fs50.cpSync)(appDir(id), backupDir2, { recursive: true });
83033
- (0, import_node_fs50.cpSync)(appDir(id), bakeDir, { recursive: true });
83650
+ const tmpRoot = (0, import_node_fs52.mkdtempSync)((0, import_node_path50.join)((0, import_node_os27.tmpdir)(), "floless-bake-"));
83651
+ const backupDir2 = (0, import_node_path50.join)(tmpRoot, `${id}-backup`);
83652
+ const bakeDir = (0, import_node_path50.join)(tmpRoot, id);
83653
+ (0, import_node_fs52.cpSync)(appDir(id), backupDir2, { recursive: true });
83654
+ (0, import_node_fs52.cpSync)(appDir(id), bakeDir, { recursive: true });
83034
83655
  const floName = appData.source.path.split(/[\\/]/).pop();
83035
- (0, import_node_fs50.writeFileSync)((0, import_node_path48.join)(bakeDir, floName), baked);
83656
+ (0, import_node_fs52.writeFileSync)((0, import_node_path50.join)(bakeDir, floName), baked);
83036
83657
  let appInstalled2 = true;
83037
83658
  try {
83038
83659
  await aware.uninstall(id);
@@ -83054,17 +83675,17 @@ async function startServer() {
83054
83675
  throw installErr;
83055
83676
  }
83056
83677
  try {
83057
- await aware.compile((0, import_node_path48.join)(appDir(id), floName));
83678
+ await aware.compile((0, import_node_path50.join)(appDir(id), floName));
83058
83679
  } catch (compileErr) {
83059
83680
  app.log.warn({ id, compileErr: String(compileErr) }, "bake: post-install recompile failed (app baked but may need a manual Compile)");
83060
83681
  }
83061
83682
  broadcast({ type: "baked", id });
83062
83683
  return { ok: true, id, agent: id, inputs };
83063
83684
  } finally {
83064
- if (appInstalled2) (0, import_node_fs50.rmSync)(tmpRoot, { recursive: true, force: true });
83685
+ if (appInstalled2) (0, import_node_fs52.rmSync)(tmpRoot, { recursive: true, force: true });
83065
83686
  }
83066
83687
  });
83067
- const graftAgentsDir = () => (0, import_node_path48.join)((0, import_node_os27.homedir)(), ".aware", "agents");
83688
+ const graftAgentsDir = () => (0, import_node_path50.join)((0, import_node_os27.homedir)(), ".aware", "agents");
83068
83689
  app.post("/api/graft/match", async (req, reply) => {
83069
83690
  const { glob } = req.body ?? {};
83070
83691
  if (!glob) return reply.status(400).send({ ok: false, error: "glob required" });
@@ -83081,7 +83702,7 @@ async function startServer() {
83081
83702
  if (!sourceKind || !sourceRef) {
83082
83703
  return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
83083
83704
  }
83084
- const tempHome = (0, import_node_fs50.mkdtempSync)((0, import_node_path48.join)((0, import_node_os27.tmpdir)(), "floless-graft-"));
83705
+ const tempHome = (0, import_node_fs52.mkdtempSync)((0, import_node_path50.join)((0, import_node_os27.tmpdir)(), "floless-graft-"));
83085
83706
  let result;
83086
83707
  try {
83087
83708
  result = await aware.build({
@@ -83094,19 +83715,19 @@ async function startServer() {
83094
83715
  awareHome: tempHome
83095
83716
  });
83096
83717
  } catch (err2) {
83097
- (0, import_node_fs50.rmSync)(tempHome, { recursive: true, force: true });
83718
+ (0, import_node_fs52.rmSync)(tempHome, { recursive: true, force: true });
83098
83719
  const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
83099
83720
  return reply.status(422).send({ ok: false, error: msg });
83100
83721
  }
83101
83722
  const manifest = readStagedManifest(result.agentDir);
83102
83723
  if (!manifest) {
83103
- (0, import_node_fs50.rmSync)(tempHome, { recursive: true, force: true });
83724
+ (0, import_node_fs52.rmSync)(tempHome, { recursive: true, force: true });
83104
83725
  return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
83105
83726
  }
83106
- const token = (0, import_node_crypto24.randomUUID)();
83727
+ const token = (0, import_node_crypto26.randomUUID)();
83107
83728
  registerStage(token, tempHome, result.agentId);
83108
83729
  const preview2 = buildPreview(manifest, sourceKind, sourceRef, token);
83109
- if ((0, import_node_fs50.existsSync)((0, import_node_path48.join)(graftAgentsDir(), result.agentId))) {
83730
+ if ((0, import_node_fs52.existsSync)((0, import_node_path50.join)(graftAgentsDir(), result.agentId))) {
83110
83731
  preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
83111
83732
  }
83112
83733
  return { ok: true, preview: preview2 };
@@ -83125,7 +83746,7 @@ async function startServer() {
83125
83746
  registerStage(stagedRef, stage.tempDir, stage.agentId);
83126
83747
  return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
83127
83748
  }
83128
- (0, import_node_fs50.rmSync)(stage.tempDir, { recursive: true, force: true });
83749
+ (0, import_node_fs52.rmSync)(stage.tempDir, { recursive: true, force: true });
83129
83750
  throw err2;
83130
83751
  }
83131
83752
  broadcast({ type: "grafted", id: stage.agentId });
@@ -83443,11 +84064,11 @@ async function startServer() {
83443
84064
  app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
83444
84065
  const n = Number.parseInt(req.params.n, 10);
83445
84066
  const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
83446
- if (!p || !(0, import_node_fs50.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
84067
+ if (!p || !(0, import_node_fs52.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
83447
84068
  const ext = p.split(".").pop().toLowerCase();
83448
84069
  reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
83449
84070
  reply.header("Cache-Control", "no-store");
83450
- return (0, import_node_fs50.readFileSync)(p);
84071
+ return (0, import_node_fs52.readFileSync)(p);
83451
84072
  });
83452
84073
  app.post(
83453
84074
  "/api/tweak",
@@ -83530,6 +84151,12 @@ async function startServer() {
83530
84151
  }
83531
84152
  }
83532
84153
  );
84154
+ registerReferenceRoutes(app, {
84155
+ getProject,
84156
+ broadcast,
84157
+ reader: { probe: probeReference, readModel: readReferenceModel },
84158
+ runControl: { isRunActive, cancelActiveRun }
84159
+ });
83533
84160
  const CONN_APPID = /^[a-z0-9][a-z0-9._-]*$/i;
83534
84161
  app.post(
83535
84162
  "/api/import-connection/list",
@@ -83643,10 +84270,10 @@ async function startServer() {
83643
84270
  const EXT_TRACE_MAX_BYTES = 5 * 1024 * 1024;
83644
84271
  function resolveExtensionSource(source, warn = () => {
83645
84272
  }) {
83646
- const sep6 = source.indexOf(":");
83647
- if (sep6 <= 0) return void 0;
83648
- const kind = source.slice(0, sep6);
83649
- const ref = source.slice(sep6 + 1);
84273
+ const sep7 = source.indexOf(":");
84274
+ if (sep7 <= 0) return void 0;
84275
+ const kind = source.slice(0, sep7);
84276
+ const ref = source.slice(sep7 + 1);
83650
84277
  if (!EXT_SOURCE_REF.test(ref)) return void 0;
83651
84278
  if (kind === "last-run-output") {
83652
84279
  const latest = readLatestTrace(ref, void 0, EXT_TRACE_MAX_BYTES);
@@ -83674,7 +84301,7 @@ async function startServer() {
83674
84301
  warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
83675
84302
  let finishedAt2 = null;
83676
84303
  try {
83677
- finishedAt2 = (0, import_node_fs50.statSync)(latest.path).mtime.toISOString();
84304
+ finishedAt2 = (0, import_node_fs52.statSync)(latest.path).mtime.toISOString();
83678
84305
  } catch {
83679
84306
  finishedAt2 = null;
83680
84307
  }
@@ -83684,7 +84311,7 @@ async function startServer() {
83684
84311
  let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
83685
84312
  if (!finishedAt) {
83686
84313
  try {
83687
- finishedAt = (0, import_node_fs50.statSync)(latest.path).mtime.toISOString();
84314
+ finishedAt = (0, import_node_fs52.statSync)(latest.path).mtime.toISOString();
83688
84315
  } catch {
83689
84316
  finishedAt = null;
83690
84317
  }
@@ -83851,11 +84478,11 @@ function unregisterProtocol() {
83851
84478
 
83852
84479
  // main.ts
83853
84480
  function promptYesNo2(question) {
83854
- return new Promise((resolve11) => {
84481
+ return new Promise((resolve12) => {
83855
84482
  const rl = (0, import_node_readline2.createInterface)({ input: process.stdin, output: process.stdout });
83856
84483
  rl.question(`${question} `, (answer) => {
83857
84484
  rl.close();
83858
- resolve11(/^y(es)?$/i.test((answer ?? "").trim()));
84485
+ resolve12(/^y(es)?$/i.test((answer ?? "").trim()));
83859
84486
  });
83860
84487
  });
83861
84488
  }