@floless/app 0.109.0 → 0.109.2

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.
@@ -1055,7 +1055,7 @@ var require_boot = __commonJS({
1055
1055
  };
1056
1056
  this._doStart = null;
1057
1057
  const instance = this;
1058
- this._root = new Plugin(fastq(this, this._loadPluginNextTick, 1), function root3(server2, opts2, done2) {
1058
+ this._root = new Plugin(fastq(this, this._loadPluginNextTick, 1), function root4(server2, opts2, done2) {
1059
1059
  instance._doStart = done2;
1060
1060
  opts2.autostart && instance.start();
1061
1061
  }, opts, false, 0);
@@ -3887,9 +3887,9 @@ var require_caller = __commonJS({
3887
3887
  if (!Array.isArray(stack)) {
3888
3888
  return void 0;
3889
3889
  }
3890
- const entries = stack.slice(2);
3890
+ const entries2 = stack.slice(2);
3891
3891
  const fileNames = [];
3892
- for (const entry2 of entries) {
3892
+ for (const entry2 of entries2) {
3893
3893
  if (!entry2) {
3894
3894
  continue;
3895
3895
  }
@@ -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: join41 } = require("path");
5492
+ var { join: join42 } = 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"] || join41(__dirname, "lib", "worker.js");
5543
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join42(__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: existsSync37 } = require("node:fs");
6009
+ var { existsSync: existsSync38 } = require("node:fs");
6010
6010
  var getCallers = require_caller();
6011
- var { join: join41, isAbsolute: isAbsolute2, sep: sep6 } = require("node:path");
6011
+ var { join: join42, isAbsolute: isAbsolute2, sep: sep6 } = 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 isAbsolute2(path) && !existsSync37(path);
6083
+ return isAbsolute2(path) && !existsSync38(path);
6084
6084
  }
6085
6085
  function stripQuotes(value) {
6086
6086
  const first = value[0];
@@ -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"] || join41(__dirname, "worker.js");
6164
+ target = bundlerOverrides["pino-worker"] || join42(__dirname, "worker.js");
6165
6165
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
6166
6166
  return {
6167
6167
  ...dest,
@@ -6179,7 +6179,7 @@ var require_transport = __commonJS({
6179
6179
  });
6180
6180
  });
6181
6181
  } else if (pipeline2) {
6182
- target = bundlerOverrides["pino-worker"] || join41(__dirname, "worker.js");
6182
+ target = bundlerOverrides["pino-worker"] || join42(__dirname, "worker.js");
6183
6183
  options.pipelines = [pipeline2.map((dest) => {
6184
6184
  return {
6185
6185
  ...dest,
@@ -6202,7 +6202,7 @@ var require_transport = __commonJS({
6202
6202
  return origin;
6203
6203
  }
6204
6204
  if (origin === "pino/file") {
6205
- return join41(__dirname, "..", "file.js");
6205
+ return join42(__dirname, "..", "file.js");
6206
6206
  }
6207
6207
  let fixTarget2;
6208
6208
  for (const filePath of callers) {
@@ -7182,7 +7182,7 @@ var require_safe_stable_stringify = __commonJS({
7182
7182
  return circularValue;
7183
7183
  }
7184
7184
  let res = "";
7185
- let join41 = ",";
7185
+ let join42 = ",";
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
- join41 = `,
7199
+ join42 = `,
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 += join41;
7207
+ res += join42;
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 += `${join41}"... ${getItemCount(removedKeys)} not stringified"`;
7213
+ res += `${join42}"... ${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
- join41 = `,
7234
+ join42 = `,
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 = join41;
7248
+ separator = join42;
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 = join41;
7254
+ separator = join42;
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 join41 = ",";
7295
+ let join42 = ",";
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
- join41 = `,
7308
+ join42 = `,
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 += join41;
7316
+ res += join42;
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 += `${join41}"... ${getItemCount(removedKeys)} not stringified"`;
7322
+ res += `${join42}"... ${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
- join41 = `,
7335
+ join42 = `,
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 = join41;
7344
+ separator = join42;
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 join42 = `,
7402
+ const join43 = `,
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 += join42;
7409
+ res2 += join43;
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 += `${join42}"... ${getItemCount(removedKeys)} not stringified"`;
7415
+ res2 += `${join43}"... ${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 join41 = `,
7431
+ const join42 = `,
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, join41, maximumBreadth);
7437
+ res += stringifyTypedArray(value, join42, maximumBreadth);
7438
7438
  keys = keys.slice(value.length);
7439
7439
  maximumPropertiesToStringify -= value.length;
7440
- separator = join41;
7440
+ separator = join42;
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 = join41;
7451
+ separator = join42;
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 = join41;
7457
+ separator = join42;
7458
7458
  }
7459
7459
  if (separator !== "") {
7460
7460
  res = `
@@ -9843,7 +9843,7 @@ var require_forwarded = __commonJS({
9843
9843
  // node_modules/ipaddr.js/lib/ipaddr.js
9844
9844
  var require_ipaddr = __commonJS({
9845
9845
  "node_modules/ipaddr.js/lib/ipaddr.js"(exports2, module2) {
9846
- (function(root3) {
9846
+ (function(root4) {
9847
9847
  "use strict";
9848
9848
  const ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
9849
9849
  const ipv4Regexes = {
@@ -10637,7 +10637,7 @@ var require_ipaddr = __commonJS({
10637
10637
  if (typeof module2 !== "undefined" && module2.exports) {
10638
10638
  module2.exports = ipaddr;
10639
10639
  } else {
10640
- root3.ipaddr = ipaddr;
10640
+ root4.ipaddr = ipaddr;
10641
10641
  }
10642
10642
  })(exports2);
10643
10643
  }
@@ -11213,13 +11213,13 @@ var require_context = __commonJS({
11213
11213
  this.server = server;
11214
11214
  }
11215
11215
  function defaultSchemaErrorFormatter(errors, dataVar) {
11216
- let text2 = "";
11216
+ let text3 = "";
11217
11217
  const separator = ", ";
11218
11218
  for (let i = 0; i !== errors.length; ++i) {
11219
11219
  const e = errors[i];
11220
- text2 += dataVar + (e.instancePath || "") + " " + e.message + separator;
11220
+ text3 += dataVar + (e.instancePath || "") + " " + e.message + separator;
11221
11221
  }
11222
- return new Error(text2.slice(0, -separator.length));
11222
+ return new Error(text3.slice(0, -separator.length));
11223
11223
  }
11224
11224
  module2.exports = Context;
11225
11225
  }
@@ -11915,20 +11915,20 @@ var require_secure_json_parse = __commonJS({
11915
11915
  var hasBuffer = typeof Buffer !== "undefined";
11916
11916
  var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
11917
11917
  var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
11918
- function _parse(text2, reviver, options) {
11918
+ function _parse(text3, reviver, options) {
11919
11919
  if (options == null) {
11920
11920
  if (reviver !== null && typeof reviver === "object") {
11921
11921
  options = reviver;
11922
11922
  reviver = void 0;
11923
11923
  }
11924
11924
  }
11925
- if (hasBuffer && Buffer.isBuffer(text2)) {
11926
- text2 = text2.toString();
11925
+ if (hasBuffer && Buffer.isBuffer(text3)) {
11926
+ text3 = text3.toString();
11927
11927
  }
11928
- if (text2 && text2.charCodeAt(0) === 65279) {
11929
- text2 = text2.slice(1);
11928
+ if (text3 && text3.charCodeAt(0) === 65279) {
11929
+ text3 = text3.slice(1);
11930
11930
  }
11931
- const obj2 = JSON.parse(text2, reviver);
11931
+ const obj2 = JSON.parse(text3, reviver);
11932
11932
  if (obj2 === null || typeof obj2 !== "object") {
11933
11933
  return obj2;
11934
11934
  }
@@ -11938,15 +11938,15 @@ var require_secure_json_parse = __commonJS({
11938
11938
  return obj2;
11939
11939
  }
11940
11940
  if (protoAction !== "ignore" && constructorAction !== "ignore") {
11941
- if (suspectProtoRx.test(text2) === false && suspectConstructorRx.test(text2) === false) {
11941
+ if (suspectProtoRx.test(text3) === false && suspectConstructorRx.test(text3) === false) {
11942
11942
  return obj2;
11943
11943
  }
11944
11944
  } else if (protoAction !== "ignore" && constructorAction === "ignore") {
11945
- if (suspectProtoRx.test(text2) === false) {
11945
+ if (suspectProtoRx.test(text3) === false) {
11946
11946
  return obj2;
11947
11947
  }
11948
11948
  } else {
11949
- if (suspectConstructorRx.test(text2) === false) {
11949
+ if (suspectConstructorRx.test(text3) === false) {
11950
11950
  return obj2;
11951
11951
  }
11952
11952
  }
@@ -11984,20 +11984,20 @@ var require_secure_json_parse = __commonJS({
11984
11984
  }
11985
11985
  return obj2;
11986
11986
  }
11987
- function parse(text2, reviver, options) {
11987
+ function parse(text3, reviver, options) {
11988
11988
  const { stackTraceLimit } = Error;
11989
11989
  Error.stackTraceLimit = 0;
11990
11990
  try {
11991
- return _parse(text2, reviver, options);
11991
+ return _parse(text3, reviver, options);
11992
11992
  } finally {
11993
11993
  Error.stackTraceLimit = stackTraceLimit;
11994
11994
  }
11995
11995
  }
11996
- function safeParse(text2, reviver) {
11996
+ function safeParse(text3, reviver) {
11997
11997
  const { stackTraceLimit } = Error;
11998
11998
  Error.stackTraceLimit = 0;
11999
11999
  try {
12000
- return _parse(text2, reviver, { safe: true });
12000
+ return _parse(text3, reviver, { safe: true });
12001
12001
  } catch {
12002
12002
  return void 0;
12003
12003
  } finally {
@@ -15303,22 +15303,22 @@ var require_compile = __commonJS({
15303
15303
  }
15304
15304
  }
15305
15305
  exports2.compileSchema = compileSchema;
15306
- function resolveRef2(root3, baseId, ref) {
15306
+ function resolveRef2(root4, baseId, ref) {
15307
15307
  var _a2;
15308
15308
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
15309
- const schOrFunc = root3.refs[ref];
15309
+ const schOrFunc = root4.refs[ref];
15310
15310
  if (schOrFunc)
15311
15311
  return schOrFunc;
15312
- let _sch = resolve11.call(this, root3, ref);
15312
+ let _sch = resolve11.call(this, root4, ref);
15313
15313
  if (_sch === void 0) {
15314
- const schema = (_a2 = root3.localRefs) === null || _a2 === void 0 ? void 0 : _a2[ref];
15314
+ const schema = (_a2 = root4.localRefs) === null || _a2 === void 0 ? void 0 : _a2[ref];
15315
15315
  const { schemaId } = this.opts;
15316
15316
  if (schema)
15317
- _sch = new SchemaEnv({ schema, schemaId, root: root3, baseId });
15317
+ _sch = new SchemaEnv({ schema, schemaId, root: root4, baseId });
15318
15318
  }
15319
15319
  if (_sch === void 0)
15320
15320
  return;
15321
- return root3.refs[ref] = inlineOrCompile.call(this, _sch);
15321
+ return root4.refs[ref] = inlineOrCompile.call(this, _sch);
15322
15322
  }
15323
15323
  exports2.resolveRef = resolveRef2;
15324
15324
  function inlineOrCompile(sch) {
@@ -15336,23 +15336,23 @@ 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(root3, ref) {
15339
+ function resolve11(root4, ref) {
15340
15340
  let sch;
15341
15341
  while (typeof (sch = this.refs[ref]) == "string")
15342
15342
  ref = sch;
15343
- return sch || this.schemas[ref] || resolveSchema.call(this, root3, ref);
15343
+ return sch || this.schemas[ref] || resolveSchema.call(this, root4, ref);
15344
15344
  }
15345
- function resolveSchema(root3, ref) {
15345
+ function resolveSchema(root4, ref) {
15346
15346
  const p = this.opts.uriResolver.parse(ref);
15347
15347
  const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p);
15348
- let baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver, root3.baseId, void 0);
15349
- if (Object.keys(root3.schema).length > 0 && refPath === baseId) {
15350
- return getJsonPointer.call(this, p, root3);
15348
+ let baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver, root4.baseId, void 0);
15349
+ if (Object.keys(root4.schema).length > 0 && refPath === baseId) {
15350
+ return getJsonPointer.call(this, p, root4);
15351
15351
  }
15352
15352
  const id = (0, resolve_1.normalizeId)(refPath);
15353
15353
  const schOrRef = this.refs[id] || this.schemas[id];
15354
15354
  if (typeof schOrRef == "string") {
15355
- const sch = resolveSchema.call(this, root3, schOrRef);
15355
+ const sch = resolveSchema.call(this, root4, schOrRef);
15356
15356
  if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object")
15357
15357
  return;
15358
15358
  return getJsonPointer.call(this, p, sch);
@@ -15367,7 +15367,7 @@ var require_compile = __commonJS({
15367
15367
  const schId = schema[schemaId];
15368
15368
  if (schId)
15369
15369
  baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
15370
- return new SchemaEnv({ schema, schemaId, root: root3, baseId });
15370
+ return new SchemaEnv({ schema, schemaId, root: root4, baseId });
15371
15371
  }
15372
15372
  return getJsonPointer.call(this, p, schOrRef);
15373
15373
  }
@@ -15379,7 +15379,7 @@ var require_compile = __commonJS({
15379
15379
  "dependencies",
15380
15380
  "definitions"
15381
15381
  ]);
15382
- function getJsonPointer(parsedRef, { baseId, schema, root: root3 }) {
15382
+ function getJsonPointer(parsedRef, { baseId, schema, root: root4 }) {
15383
15383
  var _a2;
15384
15384
  if (((_a2 = parsedRef.fragment) === null || _a2 === void 0 ? void 0 : _a2[0]) !== "/")
15385
15385
  return;
@@ -15398,10 +15398,10 @@ var require_compile = __commonJS({
15398
15398
  let env2;
15399
15399
  if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) {
15400
15400
  const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
15401
- env2 = resolveSchema.call(this, root3, $ref);
15401
+ env2 = resolveSchema.call(this, root4, $ref);
15402
15402
  }
15403
15403
  const { schemaId } = this.opts;
15404
- env2 = env2 || new SchemaEnv({ schema, schemaId, root: root3, baseId });
15404
+ env2 = env2 || new SchemaEnv({ schema, schemaId, root: root4, baseId });
15405
15405
  if (env2.schema !== env2.root.schema)
15406
15406
  return env2;
15407
15407
  return void 0;
@@ -16530,8 +16530,8 @@ var require_core = __commonJS({
16530
16530
  keyRef = sch;
16531
16531
  if (sch === void 0) {
16532
16532
  const { schemaId } = this.opts;
16533
- const root3 = new compile_1.SchemaEnv({ schema: {}, schemaId });
16534
- sch = compile_1.resolveSchema.call(this, root3, keyRef);
16533
+ const root4 = new compile_1.SchemaEnv({ schema: {}, schemaId });
16534
+ sch = compile_1.resolveSchema.call(this, root4, keyRef);
16535
16535
  if (!sch)
16536
16536
  return;
16537
16537
  this.refs[keyRef] = sch;
@@ -16640,7 +16640,7 @@ var require_core = __commonJS({
16640
16640
  errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
16641
16641
  if (!errors || errors.length === 0)
16642
16642
  return "No errors";
16643
- return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text2, msg) => text2 + separator + msg);
16643
+ return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text3, msg) => text3 + separator + msg);
16644
16644
  }
16645
16645
  $dataMetaSchema(metaSchema, keywordsJsonPointers) {
16646
16646
  const rules = this.RULES.all;
@@ -16892,20 +16892,20 @@ var require_ref = __commonJS({
16892
16892
  code(cxt) {
16893
16893
  const { gen, schema: $ref, it } = cxt;
16894
16894
  const { baseId, schemaEnv: env2, validateName, opts, self } = it;
16895
- const { root: root3 } = env2;
16896
- if (($ref === "#" || $ref === "#/") && baseId === root3.baseId)
16895
+ const { root: root4 } = env2;
16896
+ if (($ref === "#" || $ref === "#/") && baseId === root4.baseId)
16897
16897
  return callRootRef();
16898
- const schOrEnv = compile_1.resolveRef.call(self, root3, baseId, $ref);
16898
+ const schOrEnv = compile_1.resolveRef.call(self, root4, baseId, $ref);
16899
16899
  if (schOrEnv === void 0)
16900
16900
  throw new ref_error_1.default(it.opts.uriResolver, baseId, $ref);
16901
16901
  if (schOrEnv instanceof compile_1.SchemaEnv)
16902
16902
  return callValidate(schOrEnv);
16903
16903
  return inlineRefSchema(schOrEnv);
16904
16904
  function callRootRef() {
16905
- if (env2 === root3)
16905
+ if (env2 === root4)
16906
16906
  return callRef(cxt, validateName, env2, env2.$async);
16907
- const rootName = gen.scopeValue("root", { ref: root3 });
16908
- return callRef(cxt, (0, codegen_1._)`${rootName}.validate`, root3, root3.$async);
16907
+ const rootName = gen.scopeValue("root", { ref: root4 });
16908
+ return callRef(cxt, (0, codegen_1._)`${rootName}.validate`, root4, root4.$async);
16909
16909
  }
16910
16910
  function callValidate(sch) {
16911
16911
  const v = getValidate(cxt, sch);
@@ -18945,7 +18945,7 @@ var require_ref2 = __commonJS({
18945
18945
  code(cxt) {
18946
18946
  (0, metadata_1.checkMetadata)(cxt);
18947
18947
  const { gen, data, schema: ref, parentSchema, it } = cxt;
18948
- const { schemaEnv: { root: root3 } } = it;
18948
+ const { schemaEnv: { root: root4 } } = it;
18949
18949
  const valid = gen.name("valid");
18950
18950
  if (parentSchema.nullable) {
18951
18951
  gen.var(valid, (0, codegen_1._)`${data} === null`);
@@ -18957,7 +18957,7 @@ var require_ref2 = __commonJS({
18957
18957
  cxt.ok(valid);
18958
18958
  function validateJtdRef() {
18959
18959
  var _a2;
18960
- const refSchema = (_a2 = root3.schema.definitions) === null || _a2 === void 0 ? void 0 : _a2[ref];
18960
+ const refSchema = (_a2 = root4.schema.definitions) === null || _a2 === void 0 ? void 0 : _a2[ref];
18961
18961
  if (!refSchema) {
18962
18962
  throw new ref_error_1.default(it.opts.uriResolver, "", ref, `No definition ${ref}`);
18963
18963
  }
@@ -18967,7 +18967,7 @@ var require_ref2 = __commonJS({
18967
18967
  inlineRefSchema(refSchema);
18968
18968
  }
18969
18969
  function callValidate(schema) {
18970
- const sch = compile_1.compileSchema.call(it.self, new compile_1.SchemaEnv({ schema, root: root3, schemaPath: `/definitions/${ref}` }));
18970
+ const sch = compile_1.compileSchema.call(it.self, new compile_1.SchemaEnv({ schema, root: root4, schemaPath: `/definitions/${ref}` }));
18971
18971
  const v = (0, ref_1.getValidate)(cxt, sch);
18972
18972
  const errsCount = gen.const("_errs", names_1.default.errors);
18973
18973
  (0, ref_1.callRef)(cxt, v, sch, sch.$async);
@@ -19573,7 +19573,7 @@ var require_jtd_schema = __commonJS({
19573
19573
  "node_modules/ajv/dist/refs/jtd-schema.js"(exports2) {
19574
19574
  "use strict";
19575
19575
  Object.defineProperty(exports2, "__esModule", { value: true });
19576
- var shared = (root3) => {
19576
+ var shared = (root4) => {
19577
19577
  const sch = {
19578
19578
  nullable: { type: "boolean" },
19579
19579
  metadata: {
@@ -19583,20 +19583,20 @@ var require_jtd_schema = __commonJS({
19583
19583
  additionalProperties: true
19584
19584
  }
19585
19585
  };
19586
- if (root3)
19586
+ if (root4)
19587
19587
  sch.definitions = { values: { ref: "schema" } };
19588
19588
  return sch;
19589
19589
  };
19590
- var emptyForm = (root3) => ({
19591
- optionalProperties: shared(root3)
19590
+ var emptyForm = (root4) => ({
19591
+ optionalProperties: shared(root4)
19592
19592
  });
19593
- var refForm = (root3) => ({
19593
+ var refForm = (root4) => ({
19594
19594
  properties: {
19595
19595
  ref: { type: "string" }
19596
19596
  },
19597
- optionalProperties: shared(root3)
19597
+ optionalProperties: shared(root4)
19598
19598
  });
19599
- var typeForm = (root3) => ({
19599
+ var typeForm = (root4) => ({
19600
19600
  properties: {
19601
19601
  type: {
19602
19602
  enum: [
@@ -19614,40 +19614,40 @@ var require_jtd_schema = __commonJS({
19614
19614
  ]
19615
19615
  }
19616
19616
  },
19617
- optionalProperties: shared(root3)
19617
+ optionalProperties: shared(root4)
19618
19618
  });
19619
- var enumForm = (root3) => ({
19619
+ var enumForm = (root4) => ({
19620
19620
  properties: {
19621
19621
  enum: { elements: { type: "string" } }
19622
19622
  },
19623
- optionalProperties: shared(root3)
19623
+ optionalProperties: shared(root4)
19624
19624
  });
19625
- var elementsForm = (root3) => ({
19625
+ var elementsForm = (root4) => ({
19626
19626
  properties: {
19627
19627
  elements: { ref: "schema" }
19628
19628
  },
19629
- optionalProperties: shared(root3)
19629
+ optionalProperties: shared(root4)
19630
19630
  });
19631
- var propertiesForm = (root3) => ({
19631
+ var propertiesForm = (root4) => ({
19632
19632
  properties: {
19633
19633
  properties: { values: { ref: "schema" } }
19634
19634
  },
19635
19635
  optionalProperties: {
19636
19636
  optionalProperties: { values: { ref: "schema" } },
19637
19637
  additionalProperties: { type: "boolean" },
19638
- ...shared(root3)
19638
+ ...shared(root4)
19639
19639
  }
19640
19640
  });
19641
- var optionalPropertiesForm = (root3) => ({
19641
+ var optionalPropertiesForm = (root4) => ({
19642
19642
  properties: {
19643
19643
  optionalProperties: { values: { ref: "schema" } }
19644
19644
  },
19645
19645
  optionalProperties: {
19646
19646
  additionalProperties: { type: "boolean" },
19647
- ...shared(root3)
19647
+ ...shared(root4)
19648
19648
  }
19649
19649
  });
19650
- var discriminatorForm = (root3) => ({
19650
+ var discriminatorForm = (root4) => ({
19651
19651
  properties: {
19652
19652
  discriminator: { type: "string" },
19653
19653
  mapping: {
@@ -19658,15 +19658,15 @@ var require_jtd_schema = __commonJS({
19658
19658
  }
19659
19659
  }
19660
19660
  },
19661
- optionalProperties: shared(root3)
19661
+ optionalProperties: shared(root4)
19662
19662
  });
19663
- var valuesForm = (root3) => ({
19663
+ var valuesForm = (root4) => ({
19664
19664
  properties: {
19665
19665
  values: { ref: "schema" }
19666
19666
  },
19667
- optionalProperties: shared(root3)
19667
+ optionalProperties: shared(root4)
19668
19668
  });
19669
- var schema = (root3) => ({
19669
+ var schema = (root4) => ({
19670
19670
  metadata: {
19671
19671
  union: [
19672
19672
  emptyForm,
@@ -19678,7 +19678,7 @@ var require_jtd_schema = __commonJS({
19678
19678
  optionalPropertiesForm,
19679
19679
  discriminatorForm,
19680
19680
  valuesForm
19681
- ].map((s) => s(root3))
19681
+ ].map((s) => s(root4))
19682
19682
  }
19683
19683
  });
19684
19684
  var jtdMetaSchema = {
@@ -19954,8 +19954,8 @@ var require_serialize = __commonJS({
19954
19954
  throw new ref_error_1.default(self.opts.uriResolver, "", ref, `No definition ${ref}`);
19955
19955
  if (!(0, ref_1.hasRef)(refSchema))
19956
19956
  return serializeCode({ ...cxt, schema: refSchema });
19957
- const { root: root3 } = schemaEnv;
19958
- const sch = compileSerializer.call(self, new __1.SchemaEnv({ schema: refSchema, root: root3 }), definitions);
19957
+ const { root: root4 } = schemaEnv;
19958
+ const sch = compileSerializer.call(self, new __1.SchemaEnv({ schema: refSchema, root: root4 }), definitions);
19959
19959
  gen.add(names_1.default.json, (0, codegen_1._)`${getSerialize(gen, sch)}(${data})`);
19960
19960
  }
19961
19961
  function getSerialize(gen, sch) {
@@ -20452,8 +20452,8 @@ var require_parse = __commonJS({
20452
20452
  throw new ref_error_1.default(self.opts.uriResolver, "", ref, `No definition ${ref}`);
20453
20453
  if (!(0, ref_1.hasRef)(refSchema))
20454
20454
  return parseCode({ ...cxt, schema: refSchema });
20455
- const { root: root3 } = schemaEnv;
20456
- const sch = compileParser.call(self, new __1.SchemaEnv({ schema: refSchema, root: root3 }), definitions);
20455
+ const { root: root4 } = schemaEnv;
20456
+ const sch = compileParser.call(self, new __1.SchemaEnv({ schema: refSchema, root: root4 }), definitions);
20457
20457
  partialParse(cxt, getParser(gen, sch), true);
20458
20458
  }
20459
20459
  function getParser(gen, sch) {
@@ -28323,9 +28323,9 @@ ${prefix}`);
28323
28323
  buildObjectTree(node.wildcardChild, tree, "*", options);
28324
28324
  }
28325
28325
  }
28326
- function prettyPrintTree(root3, options) {
28326
+ function prettyPrintTree(root4, options) {
28327
28327
  const objectTree = {};
28328
- buildObjectTree(root3, objectTree, root3.prefix, options);
28328
+ buildObjectTree(root4, objectTree, root4.prefix, options);
28329
28329
  return printObjectTree(objectTree);
28330
28330
  }
28331
28331
  module2.exports = { prettyPrintTree };
@@ -38131,13 +38131,13 @@ var require_commonjs5 = __commonJS({
38131
38131
  *
38132
38132
  * @internal
38133
38133
  */
38134
- constructor(name, type = UNKNOWN, root3, roots, nocase, children, opts) {
38134
+ constructor(name, type = UNKNOWN, root4, roots, nocase, children, opts) {
38135
38135
  this.name = name;
38136
38136
  this.#matchName = nocase ? normalizeNocase(name) : normalize2(name);
38137
38137
  this.#type = type & TYPEMASK;
38138
38138
  this.nocase = nocase;
38139
38139
  this.roots = roots;
38140
- this.root = root3 || this;
38140
+ this.root = root4 || this;
38141
38141
  this.#children = children;
38142
38142
  this.#fullpath = opts.fullpath;
38143
38143
  this.#relative = opts.relative;
@@ -38743,12 +38743,12 @@ var require_commonjs5 = __commonJS({
38743
38743
  }
38744
38744
  this.#readdirCBInFlight = true;
38745
38745
  const fullpath = this.fullpath();
38746
- this.#fs.readdir(fullpath, { withFileTypes: true }, (er, entries) => {
38746
+ this.#fs.readdir(fullpath, { withFileTypes: true }, (er, entries2) => {
38747
38747
  if (er) {
38748
38748
  this.#readdirFail(er.code);
38749
38749
  children.provisional = 0;
38750
38750
  } else {
38751
- for (const e of entries) {
38751
+ for (const e of entries2) {
38752
38752
  this.#readdirAddChild(e, children);
38753
38753
  }
38754
38754
  this.#readdirSuccess(children);
@@ -38916,8 +38916,8 @@ var require_commonjs5 = __commonJS({
38916
38916
  *
38917
38917
  * @internal
38918
38918
  */
38919
- constructor(name, type = UNKNOWN, root3, roots, nocase, children, opts) {
38920
- super(name, type, root3, roots, nocase, children, opts);
38919
+ constructor(name, type = UNKNOWN, root4, roots, nocase, children, opts) {
38920
+ super(name, type, root4, roots, nocase, children, opts);
38921
38921
  }
38922
38922
  /**
38923
38923
  * @internal
@@ -38939,9 +38939,9 @@ var require_commonjs5 = __commonJS({
38939
38939
  if (rootPath === this.root.name) {
38940
38940
  return this.root;
38941
38941
  }
38942
- for (const [compare, root3] of Object.entries(this.roots)) {
38942
+ for (const [compare, root4] of Object.entries(this.roots)) {
38943
38943
  if (this.sameRoot(rootPath, compare)) {
38944
- return this.roots[rootPath] = root3;
38944
+ return this.roots[rootPath] = root4;
38945
38945
  }
38946
38946
  }
38947
38947
  return this.roots[rootPath] = new PathScurryWin32(rootPath, this).root;
@@ -38970,8 +38970,8 @@ var require_commonjs5 = __commonJS({
38970
38970
  *
38971
38971
  * @internal
38972
38972
  */
38973
- constructor(name, type = UNKNOWN, root3, roots, nocase, children, opts) {
38974
- super(name, type, root3, roots, nocase, children, opts);
38973
+ constructor(name, type = UNKNOWN, root4, roots, nocase, children, opts) {
38974
+ super(name, type, root4, roots, nocase, children, opts);
38975
38975
  }
38976
38976
  /**
38977
38977
  * @internal
@@ -39305,11 +39305,11 @@ var require_commonjs5 = __commonJS({
39305
39305
  const dirs = /* @__PURE__ */ new Set();
39306
39306
  const walk2 = (dir, cb) => {
39307
39307
  dirs.add(dir);
39308
- dir.readdirCB((er, entries) => {
39308
+ dir.readdirCB((er, entries2) => {
39309
39309
  if (er) {
39310
39310
  return cb(er);
39311
39311
  }
39312
- let len = entries.length;
39312
+ let len = entries2.length;
39313
39313
  if (!len)
39314
39314
  return cb();
39315
39315
  const next = () => {
@@ -39317,7 +39317,7 @@ var require_commonjs5 = __commonJS({
39317
39317
  cb();
39318
39318
  }
39319
39319
  };
39320
- for (const e of entries) {
39320
+ for (const e of entries2) {
39321
39321
  if (!filter || filter(e)) {
39322
39322
  results.push(withFileTypes ? e : e.fullpath());
39323
39323
  }
@@ -39356,8 +39356,8 @@ var require_commonjs5 = __commonJS({
39356
39356
  }
39357
39357
  const dirs = /* @__PURE__ */ new Set([entry2]);
39358
39358
  for (const dir of dirs) {
39359
- const entries = dir.readdirSync();
39360
- for (const e of entries) {
39359
+ const entries2 = dir.readdirSync();
39360
+ for (const e of entries2) {
39361
39361
  if (!filter || filter(e)) {
39362
39362
  results.push(withFileTypes ? e : e.fullpath());
39363
39363
  }
@@ -39417,8 +39417,8 @@ var require_commonjs5 = __commonJS({
39417
39417
  }
39418
39418
  const dirs = /* @__PURE__ */ new Set([entry2]);
39419
39419
  for (const dir of dirs) {
39420
- const entries = dir.readdirSync();
39421
- for (const e of entries) {
39420
+ const entries2 = dir.readdirSync();
39421
+ for (const e of entries2) {
39422
39422
  if (!filter || filter(e)) {
39423
39423
  yield withFileTypes ? e : e.fullpath();
39424
39424
  }
@@ -39461,22 +39461,22 @@ var require_commonjs5 = __commonJS({
39461
39461
  }
39462
39462
  processing++;
39463
39463
  dirs.add(dir);
39464
- const onReaddir = (er, entries, didRealpaths = false) => {
39464
+ const onReaddir = (er, entries2, didRealpaths = false) => {
39465
39465
  if (er)
39466
39466
  return results.emit("error", er);
39467
39467
  if (follow && !didRealpaths) {
39468
39468
  const promises = [];
39469
- for (const e of entries) {
39469
+ for (const e of entries2) {
39470
39470
  if (e.isSymbolicLink()) {
39471
39471
  promises.push(e.realpath().then((r) => r?.isUnknown() ? r.lstat() : r));
39472
39472
  }
39473
39473
  }
39474
39474
  if (promises.length) {
39475
- Promise.all(promises).then(() => onReaddir(null, entries, true));
39475
+ Promise.all(promises).then(() => onReaddir(null, entries2, true));
39476
39476
  return;
39477
39477
  }
39478
39478
  }
39479
- for (const e of entries) {
39479
+ for (const e of entries2) {
39480
39480
  if (e && (!filter || filter(e))) {
39481
39481
  if (!results.write(withFileTypes ? e : e.fullpath())) {
39482
39482
  paused = true;
@@ -39484,7 +39484,7 @@ var require_commonjs5 = __commonJS({
39484
39484
  }
39485
39485
  }
39486
39486
  processing--;
39487
- for (const e of entries) {
39487
+ for (const e of entries2) {
39488
39488
  const r = e.realpathCached() || e;
39489
39489
  if (r.shouldWalk(dirs, walkFilter)) {
39490
39490
  queue2.push(r);
@@ -39530,8 +39530,8 @@ var require_commonjs5 = __commonJS({
39530
39530
  }
39531
39531
  processing++;
39532
39532
  dirs.add(dir);
39533
- const entries = dir.readdirSync();
39534
- for (const e of entries) {
39533
+ const entries2 = dir.readdirSync();
39534
+ for (const e of entries2) {
39535
39535
  if (!filter || filter(e)) {
39536
39536
  if (!results.write(withFileTypes ? e : e.fullpath())) {
39537
39537
  paused = true;
@@ -39539,7 +39539,7 @@ var require_commonjs5 = __commonJS({
39539
39539
  }
39540
39540
  }
39541
39541
  processing--;
39542
- for (const e of entries) {
39542
+ for (const e of entries2) {
39543
39543
  let r = e;
39544
39544
  if (e.isSymbolicLink()) {
39545
39545
  if (!(follow && (r = e.realpathSync())))
@@ -40004,10 +40004,10 @@ var require_processor = __commonJS({
40004
40004
  const processingSet = patterns.map((p) => [target, p]);
40005
40005
  for (let [t, pattern] of processingSet) {
40006
40006
  this.hasWalkedCache.storeWalked(t, pattern);
40007
- const root3 = pattern.root();
40007
+ const root4 = pattern.root();
40008
40008
  const absolute = pattern.isAbsolute() && this.opts.absolute !== false;
40009
- if (root3) {
40010
- t = t.resolve(root3 === "/" && this.opts.root !== void 0 ? this.opts.root : root3);
40009
+ if (root4) {
40010
+ t = t.resolve(root4 === "/" && this.opts.root !== void 0 ? this.opts.root : root4);
40011
40011
  const rest2 = pattern.rest();
40012
40012
  if (!rest2) {
40013
40013
  this.matches.add(t, true, false);
@@ -40072,10 +40072,10 @@ var require_processor = __commonJS({
40072
40072
  // child entry, and a set of matches, and
40073
40073
  // a hasWalkedCache that's a copy of this one
40074
40074
  // then we're going to call
40075
- filterEntries(parent, entries) {
40075
+ filterEntries(parent, entries2) {
40076
40076
  const patterns = this.subwalks.get(parent);
40077
40077
  const results = this.child();
40078
- for (const e of entries) {
40078
+ for (const e of entries2) {
40079
40079
  for (const pattern of patterns) {
40080
40080
  const absolute = pattern.isAbsolute();
40081
40081
  const p = pattern.pattern();
@@ -40327,13 +40327,13 @@ var require_walker = __commonJS({
40327
40327
  if (t.calledReaddir())
40328
40328
  this.walkCB3(t, childrenCached, processor, next);
40329
40329
  else {
40330
- t.readdirCB((_, entries) => this.walkCB3(t, entries, processor, next), true);
40330
+ t.readdirCB((_, entries2) => this.walkCB3(t, entries2, processor, next), true);
40331
40331
  }
40332
40332
  }
40333
40333
  next();
40334
40334
  }
40335
- walkCB3(target, entries, processor, cb) {
40336
- processor = processor.filterEntries(target, entries);
40335
+ walkCB3(target, entries2, processor, cb) {
40336
+ processor = processor.filterEntries(target, entries2);
40337
40337
  let tasks = 1;
40338
40338
  const next = () => {
40339
40339
  if (--tasks === 0)
@@ -40386,8 +40386,8 @@ var require_walker = __commonJS({
40386
40386
  }
40387
40387
  next();
40388
40388
  }
40389
- walkCB3Sync(target, entries, processor, cb) {
40390
- processor = processor.filterEntries(target, entries);
40389
+ walkCB3Sync(target, entries2, processor, cb) {
40390
+ processor = processor.filterEntries(target, entries2);
40391
40391
  let tasks = 1;
40392
40392
  const next = () => {
40393
40393
  if (--tasks === 0)
@@ -41991,7 +41991,7 @@ var require_send = __commonJS({
41991
41991
  var { parseTokenList } = require_parseTokenList();
41992
41992
  var { createHttpError } = require_createHttpError();
41993
41993
  var extname4 = path.extname;
41994
- var join41 = path.join;
41994
+ var join42 = path.join;
41995
41995
  var normalize2 = path.normalize;
41996
41996
  var resolve11 = path.resolve;
41997
41997
  var sep6 = path.sep;
@@ -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 root3 = options.root ? resolve11(options.root) : null;
42043
+ const root4 = options.root ? resolve11(options.root) : null;
42044
42044
  const highWaterMark = Number.isSafeInteger(options.highWaterMark) && options.highWaterMark > 0 ? options.highWaterMark : null;
42045
42045
  return {
42046
42046
  acceptRanges,
@@ -42054,13 +42054,13 @@ var require_send = __commonJS({
42054
42054
  lastModified,
42055
42055
  maxage,
42056
42056
  maxContentRangeChunkSize,
42057
- root: root3,
42057
+ root: root4,
42058
42058
  highWaterMark,
42059
42059
  start: options.start,
42060
42060
  end: options.end
42061
42061
  };
42062
42062
  }
42063
- function normalizePath2(_path, root3) {
42063
+ function normalizePath2(_path, root4) {
42064
42064
  let path2 = decode(_path);
42065
42065
  if (path2 == null) {
42066
42066
  return { statusCode: 400 };
@@ -42069,7 +42069,7 @@ var require_send = __commonJS({
42069
42069
  return { statusCode: 400 };
42070
42070
  }
42071
42071
  let parts;
42072
- if (root3 !== null) {
42072
+ if (root4 !== null) {
42073
42073
  if (path2) {
42074
42074
  path2 = normalize2("." + sep6 + path2);
42075
42075
  }
@@ -42078,7 +42078,7 @@ var require_send = __commonJS({
42078
42078
  return { statusCode: 403 };
42079
42079
  }
42080
42080
  parts = path2.split(sep6);
42081
- path2 = normalize2(join41(root3, path2));
42081
+ path2 = normalize2(join42(root4, path2));
42082
42082
  } else {
42083
42083
  if (UP_PATH_REGEXP.test(path2)) {
42084
42084
  debug('malicious path "%s"', path2);
@@ -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 = join41(path2, index);
42364
+ const p = join42(path2, index);
42365
42365
  const { error, stat: stat4 } = await tryStat(p);
42366
42366
  if (error) {
42367
42367
  err2 = error;
@@ -42874,13 +42874,13 @@ var require_dirList = __commonJS({
42874
42874
  * note: can't use glob because don't get error on non existing dir
42875
42875
  */
42876
42876
  list: async function(dir, options, dotfiles) {
42877
- const entries = { dirs: [], files: [] };
42877
+ const entries2 = { dirs: [], files: [] };
42878
42878
  let files2 = await fs2.readdir(dir);
42879
42879
  if (dotfiles === "deny" || dotfiles === "ignore") {
42880
42880
  files2 = files2.filter((file) => file.charAt(0) !== ".");
42881
42881
  }
42882
42882
  if (files2.length < 1) {
42883
- return entries;
42883
+ return entries2;
42884
42884
  }
42885
42885
  const worker = async (filename) => {
42886
42886
  let stats;
@@ -42894,16 +42894,16 @@ var require_dirList = __commonJS({
42894
42894
  if (options.extendedFolderInfo) {
42895
42895
  entry2.extendedInfo = await dirList.getExtendedInfo(path.join(dir, filename));
42896
42896
  }
42897
- entries.dirs.push(entry2);
42897
+ entries2.dirs.push(entry2);
42898
42898
  } else {
42899
- entries.files.push(entry2);
42899
+ entries2.files.push(entry2);
42900
42900
  }
42901
42901
  };
42902
42902
  const queue2 = fastq.promise(worker, fastqConcurrency);
42903
42903
  await Promise.all(files2.map((filename) => queue2.push(filename)));
42904
- entries.dirs.sort((a, b) => a.name.localeCompare(b.name));
42905
- entries.files.sort((a, b) => a.name.localeCompare(b.name));
42906
- return entries;
42904
+ entries2.dirs.sort((a, b) => a.name.localeCompare(b.name));
42905
+ entries2.files.sort((a, b) => a.name.localeCompare(b.name));
42906
+ return entries2;
42907
42907
  },
42908
42908
  /**
42909
42909
  * send dir list content, or 404 on error
@@ -42917,9 +42917,9 @@ var require_dirList = __commonJS({
42917
42917
  if (reply.request.query.format === "html" && typeof options.render !== "function") {
42918
42918
  throw new TypeError("The `list.render` option must be a function and is required with the URL parameter `format=html`");
42919
42919
  }
42920
- let entries;
42920
+ let entries2;
42921
42921
  try {
42922
- entries = await dirList.list(dir, options, dotfiles);
42922
+ entries2 = await dirList.list(dir, options, dotfiles);
42923
42923
  } catch {
42924
42924
  return reply.callNotFound();
42925
42925
  }
@@ -42927,17 +42927,17 @@ var require_dirList = __commonJS({
42927
42927
  if (format !== "html") {
42928
42928
  if (options.jsonFormat !== "extended") {
42929
42929
  const nameEntries = { dirs: [], files: [] };
42930
- entries.dirs.forEach((entry2) => nameEntries.dirs.push(entry2.name));
42931
- entries.files.forEach((entry2) => nameEntries.files.push(entry2.name));
42930
+ entries2.dirs.forEach((entry2) => nameEntries.dirs.push(entry2.name));
42931
+ entries2.files.forEach((entry2) => nameEntries.files.push(entry2.name));
42932
42932
  await reply.send(nameEntries);
42933
42933
  } else {
42934
- await reply.send(entries);
42934
+ await reply.send(entries2);
42935
42935
  }
42936
42936
  return;
42937
42937
  }
42938
42938
  const html = options.render(
42939
- entries.dirs.map((entry2) => dirList.htmlInfo(entry2, route, prefix, options)),
42940
- entries.files.map((entry2) => dirList.htmlInfo(entry2, route, prefix, options))
42939
+ entries2.dirs.map((entry2) => dirList.htmlInfo(entry2, route, prefix, options)),
42940
+ entries2.files.map((entry2) => dirList.htmlInfo(entry2, route, prefix, options))
42941
42941
  );
42942
42942
  await reply.type("text/html").send(html);
42943
42943
  },
@@ -42973,9 +42973,9 @@ var require_dirList = __commonJS({
42973
42973
  * @param {string} root fs root path
42974
42974
  * @param {string} route request route
42975
42975
  */
42976
- path: function(root3, route) {
42976
+ path: function(root4, route) {
42977
42977
  const _route = route[route.length - 1] === "/" ? route + "none" : route;
42978
- return path.dirname(path.join(root3, _route));
42978
+ return path.dirname(path.join(root4, _route));
42979
42979
  },
42980
42980
  /**
42981
42981
  * validate options
@@ -43075,12 +43075,12 @@ var require_static = __commonJS({
43075
43075
  if (opts.decorateReply !== false) {
43076
43076
  fastify.decorateReply("sendFile", function(filePath, rootPath, options) {
43077
43077
  const opts2 = typeof rootPath === "object" ? rootPath : options;
43078
- const root3 = typeof rootPath === "string" ? rootPath : opts2?.root;
43078
+ const root4 = typeof rootPath === "string" ? rootPath : opts2?.root;
43079
43079
  pumpSendToReply(
43080
43080
  this.request,
43081
43081
  this,
43082
43082
  filePath,
43083
- root3 || sendOptions.root,
43083
+ root4 || sendOptions.root,
43084
43084
  0,
43085
43085
  opts2
43086
43086
  );
@@ -43089,10 +43089,10 @@ var require_static = __commonJS({
43089
43089
  fastify.decorateReply(
43090
43090
  "download",
43091
43091
  function(filePath, fileName, options = {}) {
43092
- const { root: root3, ...opts2 } = typeof fileName === "object" ? fileName : options;
43092
+ const { root: root4, ...opts2 } = typeof fileName === "object" ? fileName : options;
43093
43093
  fileName = typeof fileName === "string" ? fileName : filePath;
43094
43094
  this.header("content-disposition", contentDisposition(fileName));
43095
- pumpSendToReply(this.request, this, filePath, root3, 0, opts2);
43095
+ pumpSendToReply(this.request, this, filePath, root4, 0, opts2);
43096
43096
  return this;
43097
43097
  }
43098
43098
  );
@@ -43325,25 +43325,25 @@ var require_static = __commonJS({
43325
43325
  return pumpSendToReply(req, reply, routeConfig.file, routeConfig.rootPath);
43326
43326
  }
43327
43327
  }
43328
- function normalizeRoot(root3) {
43329
- if (root3 === void 0) {
43330
- return root3;
43328
+ function normalizeRoot(root4) {
43329
+ if (root4 === void 0) {
43330
+ return root4;
43331
43331
  }
43332
- if (root3 instanceof URL && root3.protocol === "file:") {
43333
- return fileURLToPath6(root3);
43332
+ if (root4 instanceof URL && root4.protocol === "file:") {
43333
+ return fileURLToPath6(root4);
43334
43334
  }
43335
- if (Array.isArray(root3)) {
43335
+ if (Array.isArray(root4)) {
43336
43336
  const result = [];
43337
- for (let i = 0, il = root3.length; i < il; ++i) {
43338
- if (root3[i] instanceof URL && root3[i].protocol === "file:") {
43339
- result.push(fileURLToPath6(root3[i]));
43337
+ for (let i = 0, il = root4.length; i < il; ++i) {
43338
+ if (root4[i] instanceof URL && root4[i].protocol === "file:") {
43339
+ result.push(fileURLToPath6(root4[i]));
43340
43340
  } else {
43341
- result.push(root3[i]);
43341
+ result.push(root4[i]);
43342
43342
  }
43343
43343
  }
43344
43344
  return result;
43345
43345
  }
43346
- return root3;
43346
+ return root4;
43347
43347
  }
43348
43348
  function checkRootPathForErrors(fastify, rootPath) {
43349
43349
  if (rootPath === void 0) {
@@ -43394,10 +43394,10 @@ var require_static = __commonJS({
43394
43394
  }
43395
43395
  return `${type}; charset=utf-8`;
43396
43396
  }
43397
- function findIndexFile(pathname, root3, indexFiles = ["index.html"]) {
43397
+ function findIndexFile(pathname, root4, indexFiles = ["index.html"]) {
43398
43398
  if (Array.isArray(indexFiles)) {
43399
43399
  return indexFiles.find((filename) => {
43400
- const p = path.join(root3, pathname, filename);
43400
+ const p = path.join(root4, pathname, filename);
43401
43401
  try {
43402
43402
  const stats = statSync17(p);
43403
43403
  return !stats.isDirectory();
@@ -43841,9 +43841,9 @@ var require_anchors = __commonJS({
43841
43841
  }
43842
43842
  return true;
43843
43843
  }
43844
- function anchorNames(root3) {
43844
+ function anchorNames(root4) {
43845
43845
  const anchors = /* @__PURE__ */ new Set();
43846
- visit.visit(root3, {
43846
+ visit.visit(root4, {
43847
43847
  Value(_key, node) {
43848
43848
  if (node.anchor)
43849
43849
  anchors.add(node.anchor);
@@ -44406,14 +44406,14 @@ var require_foldFlowLines = __commonJS({
44406
44406
  var FOLD_FLOW = "flow";
44407
44407
  var FOLD_BLOCK = "block";
44408
44408
  var FOLD_QUOTED = "quoted";
44409
- function foldFlowLines(text2, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
44409
+ function foldFlowLines(text3, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
44410
44410
  if (!lineWidth || lineWidth < 0)
44411
- return text2;
44411
+ return text3;
44412
44412
  if (lineWidth < minContentWidth)
44413
44413
  minContentWidth = 0;
44414
44414
  const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
44415
- if (text2.length <= endStep)
44416
- return text2;
44415
+ if (text3.length <= endStep)
44416
+ return text3;
44417
44417
  const folds = [];
44418
44418
  const escapedFolds = {};
44419
44419
  let end = lineWidth - indent.length;
@@ -44430,14 +44430,14 @@ var require_foldFlowLines = __commonJS({
44430
44430
  let escStart = -1;
44431
44431
  let escEnd = -1;
44432
44432
  if (mode === FOLD_BLOCK) {
44433
- i = consumeMoreIndentedLines(text2, i, indent.length);
44433
+ i = consumeMoreIndentedLines(text3, i, indent.length);
44434
44434
  if (i !== -1)
44435
44435
  end = i + endStep;
44436
44436
  }
44437
- for (let ch2; ch2 = text2[i += 1]; ) {
44437
+ for (let ch2; ch2 = text3[i += 1]; ) {
44438
44438
  if (mode === FOLD_QUOTED && ch2 === "\\") {
44439
44439
  escStart = i;
44440
- switch (text2[i + 1]) {
44440
+ switch (text3[i + 1]) {
44441
44441
  case "x":
44442
44442
  i += 3;
44443
44443
  break;
@@ -44454,12 +44454,12 @@ var require_foldFlowLines = __commonJS({
44454
44454
  }
44455
44455
  if (ch2 === "\n") {
44456
44456
  if (mode === FOLD_BLOCK)
44457
- i = consumeMoreIndentedLines(text2, i, indent.length);
44457
+ i = consumeMoreIndentedLines(text3, i, indent.length);
44458
44458
  end = i + indent.length + endStep;
44459
44459
  split = void 0;
44460
44460
  } else {
44461
44461
  if (ch2 === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
44462
- const next = text2[i + 1];
44462
+ const next = text3[i + 1];
44463
44463
  if (next && next !== " " && next !== "\n" && next !== " ")
44464
44464
  split = i;
44465
44465
  }
@@ -44471,12 +44471,12 @@ var require_foldFlowLines = __commonJS({
44471
44471
  } else if (mode === FOLD_QUOTED) {
44472
44472
  while (prev === " " || prev === " ") {
44473
44473
  prev = ch2;
44474
- ch2 = text2[i += 1];
44474
+ ch2 = text3[i += 1];
44475
44475
  overflow = true;
44476
44476
  }
44477
44477
  const j = i > escEnd + 1 ? i - 2 : escStart - 1;
44478
44478
  if (escapedFolds[j])
44479
- return text2;
44479
+ return text3;
44480
44480
  folds.push(j);
44481
44481
  escapedFolds[j] = true;
44482
44482
  end = j + endStep;
@@ -44491,39 +44491,39 @@ var require_foldFlowLines = __commonJS({
44491
44491
  if (overflow && onOverflow)
44492
44492
  onOverflow();
44493
44493
  if (folds.length === 0)
44494
- return text2;
44494
+ return text3;
44495
44495
  if (onFold)
44496
44496
  onFold();
44497
- let res = text2.slice(0, folds[0]);
44497
+ let res = text3.slice(0, folds[0]);
44498
44498
  for (let i2 = 0; i2 < folds.length; ++i2) {
44499
44499
  const fold = folds[i2];
44500
- const end2 = folds[i2 + 1] || text2.length;
44500
+ const end2 = folds[i2 + 1] || text3.length;
44501
44501
  if (fold === 0)
44502
44502
  res = `
44503
- ${indent}${text2.slice(0, end2)}`;
44503
+ ${indent}${text3.slice(0, end2)}`;
44504
44504
  else {
44505
44505
  if (mode === FOLD_QUOTED && escapedFolds[fold])
44506
- res += `${text2[fold]}\\`;
44506
+ res += `${text3[fold]}\\`;
44507
44507
  res += `
44508
- ${indent}${text2.slice(fold + 1, end2)}`;
44508
+ ${indent}${text3.slice(fold + 1, end2)}`;
44509
44509
  }
44510
44510
  }
44511
44511
  return res;
44512
44512
  }
44513
- function consumeMoreIndentedLines(text2, i, indent) {
44513
+ function consumeMoreIndentedLines(text3, i, indent) {
44514
44514
  let end = i;
44515
44515
  let start = i + 1;
44516
- let ch2 = text2[start];
44516
+ let ch2 = text3[start];
44517
44517
  while (ch2 === " " || ch2 === " ") {
44518
44518
  if (i < start + indent) {
44519
- ch2 = text2[++i];
44519
+ ch2 = text3[++i];
44520
44520
  } else {
44521
44521
  do {
44522
- ch2 = text2[++i];
44522
+ ch2 = text3[++i];
44523
44523
  } while (ch2 && ch2 !== "\n");
44524
44524
  end = i;
44525
44525
  start = i + 1;
44526
- ch2 = text2[start];
44526
+ ch2 = text3[start];
44527
44527
  }
44528
44528
  }
44529
44529
  return end;
@@ -50827,9 +50827,9 @@ 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_path42 = require("node:path");
50831
- var import_node_os25 = require("node:os");
50832
- var import_node_fs45 = require("node:fs");
50830
+ var import_node_path43 = require("node:path");
50831
+ var import_node_os26 = require("node:os");
50832
+ var import_node_fs46 = require("node:fs");
50833
50833
  var import_node_child_process9 = require("node:child_process");
50834
50834
 
50835
50835
  // log.mjs
@@ -50904,8 +50904,8 @@ var MAX_BYTES2 = 100 * 1024 * 1024;
50904
50904
  var VisualInputError = class extends Error {
50905
50905
  };
50906
50906
  function inputsDir() {
50907
- const root3 = process.env.FLOLESS_HOME ?? (0, import_node_path2.join)((0, import_node_os2.homedir)(), ".floless");
50908
- return (0, import_node_path2.join)(root3, "inputs");
50907
+ const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path2.join)((0, import_node_os2.homedir)(), ".floless");
50908
+ return (0, import_node_path2.join)(root4, "inputs");
50909
50909
  }
50910
50910
  function sniffExt(buf) {
50911
50911
  if (buf.length >= 8 && buf[0] === 137 && buf[1] === 80 && buf[2] === 78 && buf[3] === 71) return "png";
@@ -50937,9 +50937,9 @@ function storeVisualInput(appId, dataUrl) {
50937
50937
  const sha2563 = (0, import_node_crypto.createHash)("sha256").update(buf).digest("hex");
50938
50938
  const dir = (0, import_node_path2.join)(inputsDir(), appId);
50939
50939
  const path = (0, import_node_path2.join)(dir, `${sha2563}.${ext}`);
50940
- const root3 = (0, import_node_path2.resolve)(inputsDir());
50940
+ const root4 = (0, import_node_path2.resolve)(inputsDir());
50941
50941
  const target = (0, import_node_path2.resolve)(path);
50942
- if (target !== root3 && !target.startsWith(root3 + import_node_path2.sep)) {
50942
+ if (target !== root4 && !target.startsWith(root4 + import_node_path2.sep)) {
50943
50943
  throw new VisualInputError("refusing to write outside the inputs root");
50944
50944
  }
50945
50945
  (0, import_node_fs3.mkdirSync)(dir, { recursive: true });
@@ -50970,9 +50970,9 @@ function storeIfcInput(appId, dataUrl) {
50970
50970
  const sha2563 = (0, import_node_crypto.createHash)("sha256").update(buf).digest("hex");
50971
50971
  const dir = (0, import_node_path2.join)(inputsDir(), appId);
50972
50972
  const path = (0, import_node_path2.join)(dir, `${sha2563}.${ext}`);
50973
- const root3 = (0, import_node_path2.resolve)(inputsDir());
50973
+ const root4 = (0, import_node_path2.resolve)(inputsDir());
50974
50974
  const target = (0, import_node_path2.resolve)(path);
50975
- if (target !== root3 && !target.startsWith(root3 + import_node_path2.sep)) {
50975
+ if (target !== root4 && !target.startsWith(root4 + import_node_path2.sep)) {
50976
50976
  throw new VisualInputError("refusing to write outside the inputs root");
50977
50977
  }
50978
50978
  (0, import_node_fs3.mkdirSync)(dir, { recursive: true });
@@ -50985,10 +50985,10 @@ function storeIfcInput(appId, dataUrl) {
50985
50985
  }
50986
50986
  function ifcInputPath(appId, sha2563) {
50987
50987
  if (!safeSegment(appId) || !safeSegment(sha2563) || !/^[a-f0-9]{64}$/i.test(sha2563)) return null;
50988
- const root3 = (0, import_node_path2.resolve)(inputsDir());
50988
+ const root4 = (0, import_node_path2.resolve)(inputsDir());
50989
50989
  for (const ext of ["ifc", "ifczip"]) {
50990
50990
  const path = (0, import_node_path2.resolve)((0, import_node_path2.join)(inputsDir(), appId, `${sha2563}.${ext}`));
50991
- if ((path === root3 || path.startsWith(root3 + import_node_path2.sep)) && (0, import_node_fs3.existsSync)(path)) return path;
50991
+ if ((path === root4 || path.startsWith(root4 + import_node_path2.sep)) && (0, import_node_fs3.existsSync)(path)) return path;
50992
50992
  }
50993
50993
  return null;
50994
50994
  }
@@ -51414,12 +51414,12 @@ async function withLifecycleLock(kind, key, fn, options = {}) {
51414
51414
 
51415
51415
  // app-origin-store.ts
51416
51416
  function storeFile() {
51417
- const root3 = process.env.FLOLESS_HOME ?? (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".floless");
51418
- return (0, import_node_path4.join)(root3, "app-origin.json");
51417
+ const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".floless");
51418
+ return (0, import_node_path4.join)(root4, "app-origin.json");
51419
51419
  }
51420
51420
  function renameJournalDir() {
51421
- const root3 = process.env.FLOLESS_HOME ?? (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".floless");
51422
- return (0, import_node_path4.join)(root3, "app-origin-renames");
51421
+ const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".floless");
51422
+ return (0, import_node_path4.join)(root4, "app-origin-renames");
51423
51423
  }
51424
51424
  function syncDirectoryBestEffort(dir) {
51425
51425
  try {
@@ -51716,13 +51716,13 @@ var APPS_DIR = process.env.AWARE_HOME ? (0, import_node_path5.join)(process.env.
51716
51716
  function normalizeNote(n) {
51717
51717
  if (n && typeof n === "object") {
51718
51718
  const o = n;
51719
- const text3 = typeof o.text === "string" ? o.text : String(o.text ?? "");
51719
+ const text4 = typeof o.text === "string" ? o.text : String(o.text ?? "");
51720
51720
  const kind2 = o.kind === "warn" || o.kind === "error" ? o.kind : "info";
51721
- return { kind: kind2, text: text3 };
51721
+ return { kind: kind2, text: text4 };
51722
51722
  }
51723
- const text2 = String(n);
51724
- const kind = /defaulting to write-mode|not installed/i.test(text2) ? "warn" : "info";
51725
- return { kind, text: text2 };
51723
+ const text3 = String(n);
51724
+ const kind = /defaulting to write-mode|not installed/i.test(text3) ? "warn" : "info";
51725
+ return { kind, text: text3 };
51726
51726
  }
51727
51727
  function isVisualInput(i) {
51728
51728
  return i.widget === "file" || i.type === "image" || i.type === "file";
@@ -51766,8 +51766,8 @@ function firstWithExt(dir, ext) {
51766
51766
  const hit = (0, import_node_fs6.readdirSync)(dir).find((f) => f.toLowerCase().endsWith(ext));
51767
51767
  return hit ? (0, import_node_path5.join)(dir, hit) : null;
51768
51768
  }
51769
- function sha256(text2) {
51770
- return (0, import_node_crypto4.createHash)("sha256").update(text2).digest("hex");
51769
+ function sha256(text3) {
51770
+ return (0, import_node_crypto4.createHash)("sha256").update(text3).digest("hex");
51771
51771
  }
51772
51772
  function asRecord(v) {
51773
51773
  return v && typeof v === "object" && !Array.isArray(v) ? v : {};
@@ -51784,7 +51784,7 @@ function appMeta(id, bypassCache = false) {
51784
51784
  const hit = bypassCache ? void 0 : metaCache.get(sourcePath);
51785
51785
  if (hit && hit.mtimeMs === st.mtimeMs && hit.size === st.size && hit.ino === st.ino) return hit.meta;
51786
51786
  sourceParses++;
51787
- const text2 = (0, import_node_fs6.readFileSync)(sourcePath, "utf8");
51787
+ const text3 = (0, import_node_fs6.readFileSync)(sourcePath, "utf8");
51788
51788
  const after = (0, import_node_fs6.statSync)(sourcePath);
51789
51789
  const settled = after.mtimeMs === st.mtimeMs && after.size === st.size && after.ino === st.ino;
51790
51790
  const remember = (meta2) => {
@@ -51793,7 +51793,7 @@ function appMeta(id, bypassCache = false) {
51793
51793
  };
51794
51794
  let src;
51795
51795
  try {
51796
- src = asRecord((0, import_yaml.parse)(text2));
51796
+ src = asRecord((0, import_yaml.parse)(text3));
51797
51797
  } catch {
51798
51798
  return remember(META_DEFAULT);
51799
51799
  }
@@ -52114,8 +52114,8 @@ function mergeConnectables(base, live, displayName) {
52114
52114
  }
52115
52115
  return [...base, ...extra].sort((a, b) => a.name.localeCompare(b.name));
52116
52116
  }
52117
- function parseTrace(text2) {
52118
- return text2.split(/\r?\n/).filter((l) => l.trim()).map((l) => {
52117
+ function parseTrace(text3) {
52118
+ return text3.split(/\r?\n/).filter((l) => l.trim()).map((l) => {
52119
52119
  try {
52120
52120
  return JSON.parse(l);
52121
52121
  } catch {
@@ -52164,8 +52164,8 @@ function resolveInvoker() {
52164
52164
  return { head: [nodeExe(), (0, import_node_path6.join)(envDir, "scripts/bin/aware.js")], shell: false, pkgDir: envDir };
52165
52165
  }
52166
52166
  try {
52167
- const root3 = (0, import_node_child_process2.execFileSync)("npm", ["root", "-g"], { encoding: "utf8", shell: process.platform === "win32", windowsHide: true, timeout: 1e4 }).trim();
52168
- const pkgDir = (0, import_node_path6.join)(root3, "@aware-aeco", "cli");
52167
+ const root4 = (0, import_node_child_process2.execFileSync)("npm", ["root", "-g"], { encoding: "utf8", shell: process.platform === "win32", windowsHide: true, timeout: 1e4 }).trim();
52168
+ const pkgDir = (0, import_node_path6.join)(root4, "@aware-aeco", "cli");
52169
52169
  const bin = (0, import_node_path6.join)(pkgDir, "scripts/bin/aware.js");
52170
52170
  if ((0, import_node_fs7.existsSync)(bin)) return { head: [nodeExe(), bin], shell: false, pkgDir };
52171
52171
  } catch {
@@ -52395,14 +52395,14 @@ function latestTracePath(id, logsRoot = LOGS_DIR) {
52395
52395
  }
52396
52396
  for (const instance of instances) {
52397
52397
  const instDir = (0, import_node_path6.join)(appDir2, instance);
52398
- let entries;
52398
+ let entries2;
52399
52399
  try {
52400
52400
  if (!(0, import_node_fs7.statSync)(instDir).isDirectory()) continue;
52401
- entries = (0, import_node_fs7.readdirSync)(instDir);
52401
+ entries2 = (0, import_node_fs7.readdirSync)(instDir);
52402
52402
  } catch {
52403
52403
  continue;
52404
52404
  }
52405
- for (const f of entries) {
52405
+ for (const f of entries2) {
52406
52406
  if (!f.endsWith(".jsonl")) continue;
52407
52407
  const p = (0, import_node_path6.join)(instDir, f);
52408
52408
  try {
@@ -52636,8 +52636,8 @@ function agentInvokeArgv(agent, command, inputsRef) {
52636
52636
  function isInvokeUnsupported(detail) {
52637
52637
  if (!detail || typeof detail !== "object") return false;
52638
52638
  const d = detail;
52639
- const text2 = [d.stdout, d.stderr].filter((s) => typeof s === "string").join("\n");
52640
- return /unrecognized subcommand|unknown subcommand/i.test(text2);
52639
+ const text3 = [d.stdout, d.stderr].filter((s) => typeof s === "string").join("\n");
52640
+ return /unrecognized subcommand|unknown subcommand/i.test(text3);
52641
52641
  }
52642
52642
  var inFlightConnects = /* @__PURE__ */ new Map();
52643
52643
  function cancelAllConnects() {
@@ -53085,10 +53085,10 @@ function readExtensionsText() {
53085
53085
  }
53086
53086
  }
53087
53087
  function readExtensions() {
53088
- const text2 = readExtensionsText();
53089
- if (text2 === null) return null;
53088
+ const text3 = readExtensionsText();
53089
+ if (text3 === null) return null;
53090
53090
  try {
53091
- const parsed = JSON.parse(text2);
53091
+ const parsed = JSON.parse(text3);
53092
53092
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
53093
53093
  } catch {
53094
53094
  return null;
@@ -53098,35 +53098,35 @@ function descriptorPanels(d) {
53098
53098
  if (!d || !Array.isArray(d.panels)) return [];
53099
53099
  return d.panels.filter((p) => !!p && typeof p === "object" && !Array.isArray(p));
53100
53100
  }
53101
- function panelsCountOf(text2) {
53102
- if (text2 === null) return 0;
53101
+ function panelsCountOf(text3) {
53102
+ if (text3 === null) return 0;
53103
53103
  try {
53104
- const parsed = JSON.parse(text2);
53104
+ const parsed = JSON.parse(text3);
53105
53105
  return parsed && typeof parsed === "object" && Array.isArray(parsed.panels) ? parsed.panels.length : 0;
53106
53106
  } catch {
53107
53107
  return 0;
53108
53108
  }
53109
53109
  }
53110
53110
  function loadTimeline() {
53111
- let text2;
53111
+ let text3;
53112
53112
  try {
53113
- text2 = (0, import_node_fs8.readFileSync)(TIMELINE_FILE, "utf8");
53113
+ text3 = (0, import_node_fs8.readFileSync)(TIMELINE_FILE, "utf8");
53114
53114
  } catch {
53115
53115
  return { cursor: -1, entries: [] };
53116
53116
  }
53117
53117
  try {
53118
- const parsed = JSON.parse(text2);
53118
+ const parsed = JSON.parse(text3);
53119
53119
  if (!parsed || typeof parsed !== "object") return { cursor: -1, entries: [] };
53120
53120
  const p = parsed;
53121
53121
  const rawEntries = Array.isArray(p.entries) ? p.entries : [];
53122
- const entries = rawEntries.filter((e) => !!e && typeof e === "object").map((e) => ({
53122
+ const entries2 = rawEntries.filter((e) => !!e && typeof e === "object").map((e) => ({
53123
53123
  content: typeof e.content === "string" ? e.content : null,
53124
53124
  ts: typeof e.ts === "string" ? e.ts : ""
53125
53125
  }));
53126
- let cursor = typeof p.cursor === "number" && Number.isInteger(p.cursor) ? p.cursor : entries.length - 1;
53127
- if (entries.length === 0) cursor = -1;
53128
- else cursor = Math.max(0, Math.min(cursor, entries.length - 1));
53129
- return { cursor, entries };
53126
+ let cursor = typeof p.cursor === "number" && Number.isInteger(p.cursor) ? p.cursor : entries2.length - 1;
53127
+ if (entries2.length === 0) cursor = -1;
53128
+ else cursor = Math.max(0, Math.min(cursor, entries2.length - 1));
53129
+ return { cursor, entries: entries2 };
53130
53130
  } catch {
53131
53131
  return { cursor: -1, entries: [] };
53132
53132
  }
@@ -53137,10 +53137,10 @@ function saveTimeline(t) {
53137
53137
  (0, import_node_fs8.writeFileSync)(tmp, JSON.stringify(t, null, 2));
53138
53138
  (0, import_node_fs8.renameSync)(tmp, TIMELINE_FILE);
53139
53139
  }
53140
- function writeExtensionsText(text2) {
53140
+ function writeExtensionsText(text3) {
53141
53141
  ensureUiDir();
53142
53142
  const tmp = `${extensionsFile}.${process.pid}.tmp`;
53143
- (0, import_node_fs8.writeFileSync)(tmp, text2);
53143
+ (0, import_node_fs8.writeFileSync)(tmp, text3);
53144
53144
  (0, import_node_fs8.renameSync)(tmp, extensionsFile);
53145
53145
  }
53146
53146
  function applyState(entry2) {
@@ -53161,21 +53161,21 @@ function seedTimeline() {
53161
53161
  if (t.entries.length > 0) return;
53162
53162
  saveTimeline({ cursor: 0, entries: [{ content: readExtensionsText(), ts: (/* @__PURE__ */ new Date()).toISOString() }] });
53163
53163
  }
53164
- function recordChange(text2) {
53164
+ function recordChange(text3) {
53165
53165
  const t = loadTimeline();
53166
53166
  if (t.entries.length === 0) {
53167
- saveTimeline({ cursor: 0, entries: [{ content: text2, ts: (/* @__PURE__ */ new Date()).toISOString() }] });
53167
+ saveTimeline({ cursor: 0, entries: [{ content: text3, ts: (/* @__PURE__ */ new Date()).toISOString() }] });
53168
53168
  return { recorded: true };
53169
53169
  }
53170
- if (text2 === currentContent(t)) return { recorded: false };
53171
- const entries = t.entries.slice(0, t.cursor + 1);
53172
- entries.push({ content: text2, ts: (/* @__PURE__ */ new Date()).toISOString() });
53173
- let cursor = entries.length - 1;
53174
- while (entries.length > HISTORY_KEEP) {
53175
- entries.shift();
53170
+ if (text3 === currentContent(t)) return { recorded: false };
53171
+ const entries2 = t.entries.slice(0, t.cursor + 1);
53172
+ entries2.push({ content: text3, ts: (/* @__PURE__ */ new Date()).toISOString() });
53173
+ let cursor = entries2.length - 1;
53174
+ while (entries2.length > HISTORY_KEEP) {
53175
+ entries2.shift();
53176
53176
  cursor--;
53177
53177
  }
53178
- saveTimeline({ cursor, entries });
53178
+ saveTimeline({ cursor, entries: entries2 });
53179
53179
  return { recorded: true };
53180
53180
  }
53181
53181
  function historyState() {
@@ -53223,15 +53223,15 @@ function resetExtensions() {
53223
53223
  t.entries.push({ content: readExtensionsText(), ts: (/* @__PURE__ */ new Date()).toISOString() });
53224
53224
  t.cursor = 0;
53225
53225
  }
53226
- const entries = t.entries.slice(0, t.cursor + 1);
53227
- entries.push({ content: null, ts: (/* @__PURE__ */ new Date()).toISOString() });
53228
- let cursor = entries.length - 1;
53229
- while (entries.length > HISTORY_KEEP) {
53230
- entries.shift();
53226
+ const entries2 = t.entries.slice(0, t.cursor + 1);
53227
+ entries2.push({ content: null, ts: (/* @__PURE__ */ new Date()).toISOString() });
53228
+ let cursor = entries2.length - 1;
53229
+ while (entries2.length > HISTORY_KEEP) {
53230
+ entries2.shift();
53231
53231
  cursor--;
53232
53232
  }
53233
- saveTimeline({ cursor, entries });
53234
- applyState(entries[cursor]);
53233
+ saveTimeline({ cursor, entries: entries2 });
53234
+ applyState(entries2[cursor]);
53235
53235
  return { reset: true, canUndo: cursor > 0, canRedo: false };
53236
53236
  }
53237
53237
 
@@ -53241,8 +53241,8 @@ function isUiAgentMissing(err2) {
53241
53241
  const detail = err2.detail ?? {};
53242
53242
  const stdout = typeof detail.stdout === "string" ? detail.stdout : "";
53243
53243
  const stderr = typeof detail.stderr === "string" ? detail.stderr : "";
53244
- const text2 = `${err2.message} ${stdout} ${stderr}`;
53245
- return /not installed/i.test(text2);
53244
+ const text3 = `${err2.message} ${stdout} ${stderr}`;
53245
+ return /not installed/i.test(text3);
53246
53246
  }
53247
53247
  function classifyValidateError(err2) {
53248
53248
  if (err2 instanceof AwareUnsupportedError) {
@@ -53792,7 +53792,7 @@ function appVersion() {
53792
53792
  return resolveVersion({
53793
53793
  isSea: isSea2(),
53794
53794
  sqVersionXml: readSqVersionXml(),
53795
- define: true ? "0.109.0" : void 0,
53795
+ define: true ? "0.109.2" : void 0,
53796
53796
  pkgVersion: readPkgVersion()
53797
53797
  });
53798
53798
  }
@@ -53802,7 +53802,7 @@ function resolveChannel(s) {
53802
53802
  return "dev";
53803
53803
  }
53804
53804
  function appChannel() {
53805
- return resolveChannel({ isSea: isSea2(), define: true ? "0.109.0" : void 0 });
53805
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.109.2" : void 0 });
53806
53806
  }
53807
53807
 
53808
53808
  // workflow-update.ts
@@ -53905,12 +53905,12 @@ function loadTemplates(roots) {
53905
53905
  return out;
53906
53906
  }
53907
53907
  function backupDir(id, version, ts) {
53908
- const root3 = process.env.FLOLESS_HOME ?? (0, import_node_path10.join)((0, import_node_os10.homedir)(), ".floless");
53908
+ const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path10.join)((0, import_node_os10.homedir)(), ".floless");
53909
53909
  const safe2 = (s) => {
53910
53910
  const c = String(s).replace(/[^0-9A-Za-z._-]/g, "_");
53911
53911
  return /^\.+$/.test(c) ? "_" : c || "_";
53912
53912
  };
53913
- return (0, import_node_path10.join)(root3, "app-backups", safe2(id), `${safe2(version)}-${ts}`);
53913
+ return (0, import_node_path10.join)(root4, "app-backups", safe2(id), `${safe2(version)}-${ts}`);
53914
53914
  }
53915
53915
 
53916
53916
  // oauth-presets.ts
@@ -54022,10 +54022,10 @@ function validate(doc, schema) {
54022
54022
  function isPlainObject(v) {
54023
54023
  return typeof v === "object" && v !== null && !Array.isArray(v);
54024
54024
  }
54025
- function resolveRef(root3, ref) {
54025
+ function resolveRef(root4, ref) {
54026
54026
  const m = /^#\/\$defs\/(.+)$/.exec(ref);
54027
54027
  if (!m) return null;
54028
- return root3.$defs?.[m[1]] ?? null;
54028
+ return root4.$defs?.[m[1]] ?? null;
54029
54029
  }
54030
54030
  function typeMatches(value, t) {
54031
54031
  switch (t) {
@@ -54061,14 +54061,14 @@ function deepEqual(a, b) {
54061
54061
  }
54062
54062
  return false;
54063
54063
  }
54064
- function walk(value, node, root3, path, errors) {
54064
+ function walk(value, node, root4, path, errors) {
54065
54065
  if (node.$ref) {
54066
- const target = resolveRef(root3, node.$ref);
54066
+ const target = resolveRef(root4, node.$ref);
54067
54067
  if (!target) {
54068
54068
  errors.push({ path, message: `unresolved $ref ${node.$ref}` });
54069
54069
  return;
54070
54070
  }
54071
- walk(value, target, root3, path, errors);
54071
+ walk(value, target, root4, path, errors);
54072
54072
  return;
54073
54073
  }
54074
54074
  if (node.oneOf) {
@@ -54076,7 +54076,7 @@ function walk(value, node, root3, path, errors) {
54076
54076
  let closest = null;
54077
54077
  for (const candidate of node.oneOf) {
54078
54078
  const candidateErrors = [];
54079
- walk(value, candidate, root3, path, candidateErrors);
54079
+ walk(value, candidate, root4, path, candidateErrors);
54080
54080
  if (candidateErrors.length === 0) matches++;
54081
54081
  else if (!closest || candidateErrors.length < closest.length) closest = candidateErrors;
54082
54082
  }
@@ -54117,11 +54117,11 @@ function walk(value, node, root3, path, errors) {
54117
54117
  const ap = node.additionalProperties;
54118
54118
  for (const key of Object.keys(value)) {
54119
54119
  if (Object.hasOwn(props, key)) {
54120
- walk(value[key], props[key], root3, `${path}.${key}`, errors);
54120
+ walk(value[key], props[key], root4, `${path}.${key}`, errors);
54121
54121
  } else if (ap === false) {
54122
54122
  errors.push({ path: `${path}.${key}`, message: "additional property not allowed" });
54123
54123
  } else if (ap && typeof ap === "object") {
54124
- walk(value[key], ap, root3, `${path}.${key}`, errors);
54124
+ walk(value[key], ap, root4, `${path}.${key}`, errors);
54125
54125
  }
54126
54126
  }
54127
54127
  }
@@ -54133,7 +54133,7 @@ function walk(value, node, root3, path, errors) {
54133
54133
  errors.push({ path, message: `expected at most ${node.maxItems} items, got ${value.length}` });
54134
54134
  }
54135
54135
  if (node.items) {
54136
- value.forEach((el, i) => walk(el, node.items, root3, `${path}[${i}]`, errors));
54136
+ value.forEach((el, i) => walk(el, node.items, root4, `${path}[${i}]`, errors));
54137
54137
  }
54138
54138
  }
54139
54139
  }
@@ -54343,9 +54343,9 @@ function gridLines(g) {
54343
54343
  for (let i = 0; i < g.lines.length; i++) {
54344
54344
  const l = g.lines[i] || {}, a = pt2(l.a), b = pt2(l.b);
54345
54345
  if (!a || !b || Math.hypot(b[0] - a[0], b[1] - a[1]) < 1e-6) continue;
54346
- const root3 = String(l.id || "line-" + (i + 1));
54347
- let id = root3, suffix = 2;
54348
- while (used.has(id)) id = root3 + "-" + suffix++;
54346
+ const root4 = String(l.id || "line-" + (i + 1));
54347
+ let id = root4, suffix = 2;
54348
+ while (used.has(id)) id = root4 + "-" + suffix++;
54349
54349
  used.add(id);
54350
54350
  out.push({ id, label: String(l.label || i + 1), a, b });
54351
54351
  }
@@ -54523,10 +54523,10 @@ function checkModelReferences(doc) {
54523
54523
  const evidence = entry2 && isObj(entry2.obs.evidence) ? entry2.obs.evidence : null;
54524
54524
  return arr(evidence?.supersedes).map(str).filter((e) => e !== null && e !== id && obsById.has(e));
54525
54525
  };
54526
- for (const root3 of obsById.keys()) {
54527
- if ((colour.get(root3) ?? WHITE) !== WHITE) continue;
54528
- colour.set(root3, GREY);
54529
- const stack = [{ id: root3, edges: edgesOf(root3), i: 0 }];
54526
+ for (const root4 of obsById.keys()) {
54527
+ if ((colour.get(root4) ?? WHITE) !== WHITE) continue;
54528
+ colour.set(root4, GREY);
54529
+ const stack = [{ id: root4, edges: edgesOf(root4), i: 0 }];
54530
54530
  while (stack.length) {
54531
54531
  const top = stack[stack.length - 1];
54532
54532
  if (top.i >= top.edges.length) {
@@ -54586,12 +54586,12 @@ function checkModelReferences(doc) {
54586
54586
  if (declared !== parsedCount) add("$.grid.axes", "grid-axis-count", `${dir} has ${parsedCount} parsed entries but ${declared} declared axes`);
54587
54587
  };
54588
54588
  for (const dir of ["x", "y"]) {
54589
- const text2 = str(grid[dir]);
54590
- if (text2 === null) {
54589
+ const text3 = str(grid[dir]);
54590
+ if (text3 === null) {
54591
54591
  compare(dir, 0);
54592
54592
  continue;
54593
54593
  }
54594
- const parsed = parseSpacings(text2);
54594
+ const parsed = parseSpacings(text3);
54595
54595
  if (parsed.err) add(`$.grid.${dir}`, "grid-spacing-invalid", `${dir} grid string is unparseable: ${parsed.err}`);
54596
54596
  else compare(dir, parsed.offsets.length);
54597
54597
  }
@@ -54671,8 +54671,8 @@ function checkModelReferences(doc) {
54671
54671
  }
54672
54672
  const clips = isObj(v.clips) ? v.clips : null;
54673
54673
  if (clips) {
54674
- const entries = arr(clips.clips);
54675
- const clipCounts = idIndex(entries.map((c) => isObj(c) ? str(c.id) : null));
54674
+ const entries2 = arr(clips.clips);
54675
+ const clipCounts = idIndex(entries2.map((c) => isObj(c) ? str(c.id) : null));
54676
54676
  for (const [id, n] of clipCounts) if (n > 1) add(`$.views[${vi}].clips.clips`, "clip-id-duplicate", `clip id "${id}" occurs ${n} times`);
54677
54677
  arr(clips.selected).forEach((s, i) => {
54678
54678
  const id = str(s);
@@ -55433,8 +55433,8 @@ function parseStepData(input) {
55433
55433
  if (input.length > MAX_BYTES3) throw new StepParseError("IFC is larger than the supported maximum.");
55434
55434
  assertAscii((i) => input[i], input.length);
55435
55435
  }
55436
- const text2 = typeof input === "string" ? input : input.toString("utf8");
55437
- const sc = new Scanner(text2);
55436
+ const text3 = typeof input === "string" ? input : input.toString("utf8");
55437
+ const sc = new Scanner(text3);
55438
55438
  sc.expectWord("ISO-10303-21");
55439
55439
  sc.expect(";");
55440
55440
  sc.expectWord("HEADER");
@@ -56103,9 +56103,9 @@ var NEUTRAL_TEXT_PARAMS = {
56103
56103
  };
56104
56104
  function boundedNeutralText(value) {
56105
56105
  if (typeof value !== "string") return null;
56106
- const text2 = value.trim();
56107
- if (!text2 || Buffer.byteLength(text2, "utf8") > 64 || /[\u0000-\u001f\u007f]/.test(text2)) return null;
56108
- return text2;
56106
+ const text3 = value.trim();
56107
+ if (!text3 || Buffer.byteLength(text3, "utf8") > 64 || /[\u0000-\u001f\u007f]/.test(text3)) return null;
56108
+ return text3;
56109
56109
  }
56110
56110
  var gridCountsInteger = (p) => (!("boltCols" in p) || Number.isInteger(p.boltCols)) && (!("boltRows" in p) || Number.isInteger(p.boltRows));
56111
56111
  function sanitizeRecipe(raw) {
@@ -56117,8 +56117,8 @@ function sanitizeRecipe(raw) {
56117
56117
  for (const [k, v] of Object.entries(r.params)) {
56118
56118
  if (typeof v === "number" && isFinite(v)) num6[k] = v;
56119
56119
  if (NEUTRAL_TEXT_PARAMS[r.kind]?.has(k)) {
56120
- const text2 = boundedNeutralText(v);
56121
- if (text2) neutral[k] = text2;
56120
+ const text3 = boundedNeutralText(v);
56121
+ if (text3) neutral[k] = text3;
56122
56122
  else if (v != null) return void 0;
56123
56123
  }
56124
56124
  }
@@ -56261,15 +56261,15 @@ function readContractForApp(appId, readAppFn = readApp) {
56261
56261
 
56262
56262
  // project-versions-store.ts
56263
56263
  var import_node_crypto10 = require("node:crypto");
56264
- var import_node_fs22 = require("node:fs");
56264
+ var import_node_fs23 = require("node:fs");
56265
56265
  var import_promises2 = require("node:fs/promises");
56266
- var import_node_path20 = require("node:path");
56266
+ var import_node_path21 = require("node:path");
56267
56267
 
56268
56268
  // projects-store.ts
56269
- var import_node_fs21 = require("node:fs");
56269
+ var import_node_fs22 = require("node:fs");
56270
56270
  var import_promises = require("node:fs/promises");
56271
- var import_node_path19 = require("node:path");
56272
- var import_node_os14 = require("node:os");
56271
+ var import_node_path20 = require("node:path");
56272
+ var import_node_os15 = require("node:os");
56273
56273
  var import_node_crypto9 = require("node:crypto");
56274
56274
 
56275
56275
  // node_modules/fflate/esm/index.mjs
@@ -57614,17 +57614,40 @@ function unzipSync(data, opts) {
57614
57614
  return files2;
57615
57615
  }
57616
57616
 
57617
+ // revision-staging-store.ts
57618
+ var import_node_fs21 = require("node:fs");
57619
+ var import_node_os14 = require("node:os");
57620
+ var import_node_path19 = require("node:path");
57621
+ function root2() {
57622
+ return process.env.FLOLESS_HOME ?? (0, import_node_path19.join)((0, import_node_os14.homedir)(), ".floless");
57623
+ }
57624
+ function stagingRoot() {
57625
+ return (0, import_node_path19.join)(root2(), ".staged-revisions");
57626
+ }
57627
+ var STAGING_KEY = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
57628
+ var safeStagingKey = (v) => {
57629
+ if (!STAGING_KEY.test(v)) throw new Error(`invalid project staging key: ${v}`);
57630
+ return v;
57631
+ };
57632
+ var stagingDir = (key) => (0, import_node_path19.join)(stagingRoot(), safeStagingKey(key));
57633
+ function dropStagingFor(stagingKey) {
57634
+ try {
57635
+ (0, import_node_fs21.rmSync)(stagingDir(stagingKey), { recursive: true, force: true });
57636
+ } catch {
57637
+ }
57638
+ }
57639
+
57617
57640
  // projects-store.ts
57618
57641
  var ProjectError = class extends Error {
57619
57642
  };
57620
- function root2() {
57621
- return process.env.FLOLESS_HOME ?? (0, import_node_path19.join)((0, import_node_os14.homedir)(), ".floless");
57643
+ function root3() {
57644
+ return process.env.FLOLESS_HOME ?? (0, import_node_path20.join)((0, import_node_os15.homedir)(), ".floless");
57622
57645
  }
57623
57646
  function projectsRoot() {
57624
- return (0, import_node_path19.join)(root2(), "projects");
57647
+ return (0, import_node_path20.join)(root3(), "projects");
57625
57648
  }
57626
57649
  function archiveRoot() {
57627
- return (0, import_node_path19.join)(projectsRoot(), ".archive");
57650
+ return (0, import_node_path20.join)(projectsRoot(), ".archive");
57628
57651
  }
57629
57652
  var RESERVED_PROJECT_INTERNAL = /(^|[\\/])\.floless-(?:txn|cleanup|tmp|backup)-/i;
57630
57653
  function isReservedProjectInternalPath(path) {
@@ -57645,22 +57668,22 @@ function slugify(name) {
57645
57668
  return s || "project";
57646
57669
  }
57647
57670
  function projectDir(id) {
57648
- return (0, import_node_path19.join)(projectsRoot(), safeProjectId(id));
57671
+ return (0, import_node_path20.join)(projectsRoot(), safeProjectId(id));
57649
57672
  }
57650
57673
  function archiveDir(id) {
57651
- return (0, import_node_path19.join)(archiveRoot(), safeProjectId(id));
57674
+ return (0, import_node_path20.join)(archiveRoot(), safeProjectId(id));
57652
57675
  }
57653
57676
  function projectExportsDir(id) {
57654
- return (0, import_node_path19.join)(projectDir(id), "exports");
57677
+ return (0, import_node_path20.join)(projectDir(id), "exports");
57655
57678
  }
57656
57679
  function projectKnowledgeDir(id) {
57657
- return (0, import_node_path19.join)(projectDir(id), "knowledge");
57680
+ return (0, import_node_path20.join)(projectDir(id), "knowledge");
57658
57681
  }
57659
- var metaPath = (id) => (0, import_node_path19.join)(projectDir(id), "project.json");
57682
+ var metaPath = (id) => (0, import_node_path20.join)(projectDir(id), "project.json");
57660
57683
  function readMetaFile(jsonPath, id) {
57661
- if (!(0, import_node_fs21.existsSync)(jsonPath)) return null;
57684
+ if (!(0, import_node_fs22.existsSync)(jsonPath)) return null;
57662
57685
  try {
57663
- const meta = JSON.parse((0, import_node_fs21.readFileSync)(jsonPath, "utf8"));
57686
+ const meta = JSON.parse((0, import_node_fs22.readFileSync)(jsonPath, "utf8"));
57664
57687
  if (meta && meta.id === id) return meta;
57665
57688
  console.warn(`projects-store: ignoring ${jsonPath} \u2014 its id "${String(meta?.id)}" does not match the folder "${id}"`);
57666
57689
  return null;
@@ -57673,16 +57696,16 @@ function readMeta(id) {
57673
57696
  return readMetaFile(metaPath(id), id);
57674
57697
  }
57675
57698
  function writeMetaTo(dir, meta) {
57676
- const path = (0, import_node_path19.join)(dir, "project.json");
57699
+ const path = (0, import_node_path20.join)(dir, "project.json");
57677
57700
  const tmp = `${path}.${process.pid}.${(0, import_node_crypto9.randomUUID)()}.tmp`;
57678
- (0, import_node_fs21.writeFileSync)(tmp, JSON.stringify(meta, null, 2));
57679
- (0, import_node_fs21.renameSync)(tmp, path);
57701
+ (0, import_node_fs22.writeFileSync)(tmp, JSON.stringify(meta, null, 2));
57702
+ (0, import_node_fs22.renameSync)(tmp, path);
57680
57703
  }
57681
57704
  var writeMeta = (meta) => writeMetaTo(projectDir(meta.id), meta);
57682
57705
  function listProjects() {
57683
- if (!(0, import_node_fs21.existsSync)(projectsRoot())) return [];
57706
+ if (!(0, import_node_fs22.existsSync)(projectsRoot())) return [];
57684
57707
  const out = [];
57685
- for (const entry2 of (0, import_node_fs21.readdirSync)(projectsRoot(), { withFileTypes: true })) {
57708
+ for (const entry2 of (0, import_node_fs22.readdirSync)(projectsRoot(), { withFileTypes: true })) {
57686
57709
  if (!isProjectDir(entry2)) continue;
57687
57710
  const meta = readMeta(entry2.name);
57688
57711
  if (meta) out.push(meta);
@@ -57708,8 +57731,8 @@ function createProject(input) {
57708
57731
  if (!name) throw new ProjectError("project name required");
57709
57732
  if (!/^[a-z0-9][a-z0-9._-]*$/i.test(app)) throw new ProjectError(`invalid app id: ${app || "(empty)"}`);
57710
57733
  let id = `${slugify(name)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
57711
- while ((0, import_node_fs21.existsSync)(projectDir(id))) id = `${slugify(name)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
57712
- (0, import_node_fs21.mkdirSync)(projectDir(id), { recursive: true });
57734
+ while ((0, import_node_fs22.existsSync)(projectDir(id))) id = `${slugify(name)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
57735
+ (0, import_node_fs22.mkdirSync)(projectDir(id), { recursive: true });
57713
57736
  const now = (/* @__PURE__ */ new Date()).toISOString();
57714
57737
  const meta = { id, uuid: (0, import_node_crypto9.randomUUID)(), name, app, createdAt: now, updatedAt: now };
57715
57738
  writeMeta(meta);
@@ -57722,10 +57745,10 @@ function renameProject(id, name) {
57722
57745
  const nextName = name.trim();
57723
57746
  if (nextName === meta.name) return meta;
57724
57747
  let newId = `${slugify(nextName)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
57725
- while ((0, import_node_fs21.existsSync)(projectDir(newId)) || (0, import_node_fs21.existsSync)((0, import_node_path19.join)(archiveRoot(), newId))) newId = `${slugify(nextName)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
57748
+ while ((0, import_node_fs22.existsSync)(projectDir(newId)) || (0, import_node_fs22.existsSync)((0, import_node_path20.join)(archiveRoot(), newId))) newId = `${slugify(nextName)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
57726
57749
  const from = projectDir(id), to = projectDir(newId);
57727
57750
  try {
57728
- (0, import_node_fs21.renameSync)(from, to);
57751
+ (0, import_node_fs22.renameSync)(from, to);
57729
57752
  } catch {
57730
57753
  throw new ProjectError("couldn\u2019t rename the project folder \u2014 it may be open or in use. Close the project and try again.");
57731
57754
  }
@@ -57735,7 +57758,7 @@ function renameProject(id, name) {
57735
57758
  return next;
57736
57759
  } catch (e) {
57737
57760
  try {
57738
- (0, import_node_fs21.renameSync)(to, from);
57761
+ (0, import_node_fs22.renameSync)(to, from);
57739
57762
  } catch {
57740
57763
  }
57741
57764
  throw e;
@@ -57762,7 +57785,7 @@ function duplicateProject(id, name) {
57762
57785
  name: typeof name === "string" && name.trim() ? name.trim() : `${src.name} (copy)`,
57763
57786
  app: src.app
57764
57787
  });
57765
- (0, import_node_fs21.cpSync)(projectDir(src.id), projectDir(copy.id), {
57788
+ (0, import_node_fs22.cpSync)(projectDir(src.id), projectDir(copy.id), {
57766
57789
  recursive: true,
57767
57790
  filter: (p) => !p.endsWith("project.json") && !isReservedProjectInternalPath(p)
57768
57791
  });
@@ -57781,56 +57804,58 @@ function repointProjects(oldId, newId) {
57781
57804
  console.warn(`repointProjects: leaving project ${meta.id} on "${oldId}" \u2014 ${e instanceof Error ? e.message : e}`);
57782
57805
  }
57783
57806
  };
57784
- if ((0, import_node_fs21.existsSync)(projectsRoot())) {
57785
- for (const entry2 of (0, import_node_fs21.readdirSync)(projectsRoot(), { withFileTypes: true })) {
57807
+ if ((0, import_node_fs22.existsSync)(projectsRoot())) {
57808
+ for (const entry2 of (0, import_node_fs22.readdirSync)(projectsRoot(), { withFileTypes: true })) {
57786
57809
  if (!isProjectDir(entry2)) continue;
57787
57810
  const meta = readMeta(entry2.name);
57788
57811
  if (meta && meta.app === oldId) repoint(meta, () => projectDir(meta.id));
57789
57812
  }
57790
57813
  }
57791
- if ((0, import_node_fs21.existsSync)(archiveRoot())) {
57792
- for (const entry2 of (0, import_node_fs21.readdirSync)(archiveRoot(), { withFileTypes: true })) {
57814
+ if ((0, import_node_fs22.existsSync)(archiveRoot())) {
57815
+ for (const entry2 of (0, import_node_fs22.readdirSync)(archiveRoot(), { withFileTypes: true })) {
57793
57816
  if (!isProjectDir(entry2)) continue;
57794
- const meta = readMetaFile((0, import_node_path19.join)(archiveRoot(), entry2.name, "project.json"), entry2.name);
57795
- if (meta && meta.app === oldId) repoint(meta, () => (0, import_node_path19.join)(archiveRoot(), safeProjectId(meta.id)));
57817
+ const meta = readMetaFile((0, import_node_path20.join)(archiveRoot(), entry2.name, "project.json"), entry2.name);
57818
+ if (meta && meta.app === oldId) repoint(meta, () => (0, import_node_path20.join)(archiveRoot(), safeProjectId(meta.id)));
57796
57819
  }
57797
57820
  }
57798
57821
  return { changed, skipped };
57799
57822
  }
57800
57823
  function archiveProject(id) {
57801
57824
  const dir = projectDir(id);
57802
- if (!(0, import_node_fs21.existsSync)(dir)) throw new ProjectError(`unknown project: ${id}`);
57803
- (0, import_node_fs21.mkdirSync)(archiveRoot(), { recursive: true });
57804
- const dest = (0, import_node_path19.join)(archiveRoot(), id);
57805
- if ((0, import_node_fs21.existsSync)(dest)) throw new ProjectError(`already archived: ${id}`);
57825
+ if (!(0, import_node_fs22.existsSync)(dir)) throw new ProjectError(`unknown project: ${id}`);
57826
+ (0, import_node_fs22.mkdirSync)(archiveRoot(), { recursive: true });
57827
+ const dest = (0, import_node_path20.join)(archiveRoot(), id);
57828
+ if ((0, import_node_fs22.existsSync)(dest)) throw new ProjectError(`already archived: ${id}`);
57806
57829
  const meta = readMeta(id);
57807
57830
  if (meta) writeMeta({ ...meta, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
57808
- (0, import_node_fs21.renameSync)(dir, dest);
57831
+ (0, import_node_fs22.renameSync)(dir, dest);
57809
57832
  }
57810
57833
  function listArchivedProjects() {
57811
- if (!(0, import_node_fs21.existsSync)(archiveRoot())) return [];
57834
+ if (!(0, import_node_fs22.existsSync)(archiveRoot())) return [];
57812
57835
  const out = [];
57813
- for (const entry2 of (0, import_node_fs21.readdirSync)(archiveRoot(), { withFileTypes: true })) {
57836
+ for (const entry2 of (0, import_node_fs22.readdirSync)(archiveRoot(), { withFileTypes: true })) {
57814
57837
  if (!isProjectDir(entry2)) continue;
57815
- const meta = readMetaFile((0, import_node_path19.join)(archiveRoot(), entry2.name, "project.json"), entry2.name);
57838
+ const meta = readMetaFile((0, import_node_path20.join)(archiveRoot(), entry2.name, "project.json"), entry2.name);
57816
57839
  if (meta) out.push(meta);
57817
57840
  }
57818
57841
  return out.sort((a, b) => a.updatedAt < b.updatedAt ? 1 : -1);
57819
57842
  }
57820
57843
  function unarchiveProject(id) {
57821
57844
  const src = archiveDir(id);
57822
- if (!(0, import_node_fs21.existsSync)(src)) throw new ProjectError(`not archived: ${id}`);
57823
- const meta = readMetaFile((0, import_node_path19.join)(src, "project.json"), id);
57845
+ if (!(0, import_node_fs22.existsSync)(src)) throw new ProjectError(`not archived: ${id}`);
57846
+ const meta = readMetaFile((0, import_node_path20.join)(src, "project.json"), id);
57824
57847
  if (!meta) throw new ProjectError(`archived project has missing or unreadable metadata: ${id}`);
57825
57848
  const dest = projectDir(id);
57826
- if ((0, import_node_fs21.existsSync)(dest)) throw new ProjectError(`a live project with that id already exists: ${id}`);
57827
- (0, import_node_fs21.renameSync)(src, dest);
57849
+ if ((0, import_node_fs22.existsSync)(dest)) throw new ProjectError(`a live project with that id already exists: ${id}`);
57850
+ (0, import_node_fs22.renameSync)(src, dest);
57828
57851
  return meta;
57829
57852
  }
57830
57853
  function deleteArchivedProject(id) {
57831
57854
  const dir = archiveDir(id);
57832
- if (!(0, import_node_fs21.existsSync)(dir)) throw new ProjectError(`not archived: ${id}`);
57833
- (0, import_node_fs21.rmSync)(dir, { recursive: true, force: true });
57855
+ if (!(0, import_node_fs22.existsSync)(dir)) throw new ProjectError(`not archived: ${id}`);
57856
+ const stagingId = readMetaFile((0, import_node_path20.join)(dir, "project.json"), id)?.stagingId;
57857
+ (0, import_node_fs22.rmSync)(dir, { recursive: true, force: true });
57858
+ if (stagingId) dropStagingFor(stagingId);
57834
57859
  }
57835
57860
  function exportFilename(name) {
57836
57861
  const clean = name.replace(/[^a-z0-9\-_. ]+/gi, " ").replace(/\s+/g, " ").trim().slice(0, 60);
@@ -57869,9 +57894,9 @@ async function exportProjectZip(id) {
57869
57894
  const projectRootDir = projectDir(id);
57870
57895
  const files2 = {};
57871
57896
  const walk2 = async (abs, rel) => {
57872
- const entries = await (0, import_promises.readdir)(abs, { withFileTypes: true });
57873
- await Promise.all(entries.map(async (e) => {
57874
- const childAbs = (0, import_node_path19.join)(abs, e.name);
57897
+ const entries2 = await (0, import_promises.readdir)(abs, { withFileTypes: true });
57898
+ await Promise.all(entries2.map(async (e) => {
57899
+ const childAbs = (0, import_node_path20.join)(abs, e.name);
57875
57900
  const childRel = rel ? `${rel}/${e.name}` : e.name;
57876
57901
  if (e.isDirectory()) await walk2(childAbs, childRel);
57877
57902
  else if (e.isFile() && !isReservedProjectInternalPath(childRel)) files2[`${id}/${childRel}`] = await (0, import_promises.readFile)(childAbs);
@@ -57884,10 +57909,10 @@ async function exportProjectZip(id) {
57884
57909
  var IMPORT_MAX_FILES = 1e4;
57885
57910
  var IMPORT_MAX_UNCOMPRESSED = 2 * 1024 * 1024 * 1024;
57886
57911
  function importProjectZip(data) {
57887
- let entries;
57912
+ let entries2;
57888
57913
  try {
57889
57914
  let count = 0, uncompressed = 0;
57890
- entries = unzipSync(data, {
57915
+ entries2 = unzipSync(data, {
57891
57916
  filter: (f) => {
57892
57917
  if (++count > IMPORT_MAX_FILES) throw new ProjectError("archive has too many entries");
57893
57918
  uncompressed += f.originalSize;
@@ -57899,17 +57924,17 @@ function importProjectZip(data) {
57899
57924
  if (e instanceof ProjectError) throw e;
57900
57925
  throw new ProjectError(`not a valid project archive: ${e instanceof Error ? e.message : String(e)}`);
57901
57926
  }
57902
- entries = Object.fromEntries(Object.entries(entries).map(([k, v]) => [k.replace(/\\/g, "/"), v]));
57903
- const reservedEntry = Object.keys(entries).find(isReservedProjectInternalPath);
57927
+ entries2 = Object.fromEntries(Object.entries(entries2).map(([k, v]) => [k.replace(/\\/g, "/"), v]));
57928
+ const reservedEntry = Object.keys(entries2).find(isReservedProjectInternalPath);
57904
57929
  if (reservedEntry) {
57905
57930
  throw new ProjectError(`archive contains reserved transaction state: ${reservedEntry}`);
57906
57931
  }
57907
- const metaEntry = Object.keys(entries).find((p) => /(^|\/)project\.json$/.test(p) && p.split("/").length <= 2);
57932
+ const metaEntry = Object.keys(entries2).find((p) => /(^|\/)project\.json$/.test(p) && p.split("/").length <= 2);
57908
57933
  if (!metaEntry) throw new ProjectError("archive has no project.json \u2014 not a project export");
57909
57934
  const rootPrefix = metaEntry.includes("/") ? metaEntry.slice(0, metaEntry.indexOf("/") + 1) : "";
57910
57935
  let srcMeta;
57911
57936
  try {
57912
- const parsed = JSON.parse(new TextDecoder().decode(entries[metaEntry]));
57937
+ const parsed = JSON.parse(new TextDecoder().decode(entries2[metaEntry]));
57913
57938
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("not an object");
57914
57939
  srcMeta = parsed;
57915
57940
  } catch {
@@ -57922,16 +57947,16 @@ function importProjectZip(data) {
57922
57947
  const app = typeof srcMeta.app === "string" ? srcMeta.app.trim() : "";
57923
57948
  if (!/^[a-z0-9][a-z0-9._-]*$/i.test(app)) throw new ProjectError(`archive names an invalid app id: ${app || "(empty)"}`);
57924
57949
  let id = `${slugify(name)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
57925
- while ((0, import_node_fs21.existsSync)(projectDir(id)) || (0, import_node_fs21.existsSync)((0, import_node_path19.join)(archiveRoot(), id))) id = `${slugify(name)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
57950
+ while ((0, import_node_fs22.existsSync)(projectDir(id)) || (0, import_node_fs22.existsSync)((0, import_node_path20.join)(archiveRoot(), id))) id = `${slugify(name)}-${(0, import_node_crypto9.randomBytes)(3).toString("hex")}`;
57926
57951
  const relOf = (entryPath) => rootPrefix && entryPath.startsWith(rootPrefix) ? entryPath.slice(rootPrefix.length) : entryPath;
57927
- const contractEntries = Object.keys(entries).filter((p) => relOf(p) === "contract.json");
57952
+ const contractEntries = Object.keys(entries2).filter((p) => relOf(p) === "contract.json");
57928
57953
  if (contractEntries.length > 1) {
57929
57954
  throw new ProjectError("archive contains more than one contract.json for the same project");
57930
57955
  }
57931
57956
  for (const entry2 of contractEntries) {
57932
57957
  let parsed;
57933
57958
  try {
57934
- parsed = JSON.parse(new TextDecoder().decode(entries[entry2]));
57959
+ parsed = JSON.parse(new TextDecoder().decode(entries2[entry2]));
57935
57960
  } catch {
57936
57961
  throw new ProjectError("archive contract.json is unreadable");
57937
57962
  }
@@ -57945,19 +57970,19 @@ function importProjectZip(data) {
57945
57970
  }
57946
57971
  }
57947
57972
  const dest = projectDir(id);
57948
- const destResolved = (0, import_node_path19.resolve)(dest);
57949
- (0, import_node_fs21.mkdirSync)(dest, { recursive: true });
57973
+ const destResolved = (0, import_node_path20.resolve)(dest);
57974
+ (0, import_node_fs22.mkdirSync)(dest, { recursive: true });
57950
57975
  try {
57951
- for (const [entryPath, bytes] of Object.entries(entries)) {
57976
+ for (const [entryPath, bytes] of Object.entries(entries2)) {
57952
57977
  if (entryPath === metaEntry) continue;
57953
57978
  const rel = rootPrefix && entryPath.startsWith(rootPrefix) ? entryPath.slice(rootPrefix.length) : entryPath;
57954
57979
  if (!rel || rel.endsWith("/")) continue;
57955
- const target = (0, import_node_path19.resolve)(dest, rel);
57956
- if (target !== destResolved && !target.startsWith(destResolved + import_node_path19.sep)) {
57980
+ const target = (0, import_node_path20.resolve)(dest, rel);
57981
+ if (target !== destResolved && !target.startsWith(destResolved + import_node_path20.sep)) {
57957
57982
  throw new ProjectError(`archive entry escapes the project dir: ${entryPath}`);
57958
57983
  }
57959
- (0, import_node_fs21.mkdirSync)((0, import_node_path19.dirname)(target), { recursive: true });
57960
- (0, import_node_fs21.writeFileSync)(target, bytes);
57984
+ (0, import_node_fs22.mkdirSync)((0, import_node_path20.dirname)(target), { recursive: true });
57985
+ (0, import_node_fs22.writeFileSync)(target, bytes);
57961
57986
  }
57962
57987
  const now = (/* @__PURE__ */ new Date()).toISOString();
57963
57988
  const meta = {
@@ -57972,7 +57997,7 @@ function importProjectZip(data) {
57972
57997
  writeMeta(meta);
57973
57998
  return meta;
57974
57999
  } catch (e) {
57975
- (0, import_node_fs21.rmSync)(dest, { recursive: true, force: true });
58000
+ (0, import_node_fs22.rmSync)(dest, { recursive: true, force: true });
57976
58001
  throw e;
57977
58002
  }
57978
58003
  }
@@ -57981,13 +58006,13 @@ function importProjectZip(data) {
57981
58006
  var BLOB_MIN = 8192;
57982
58007
  var BLOB_KEY = "__blobRef__";
57983
58008
  var HASH_RE = /^[0-9a-f]{64}$/;
57984
- var versionsDir = (id) => (0, import_node_path20.join)(projectDir(id), "versions");
57985
- var objectsDir = (id) => (0, import_node_path20.join)(projectDir(id), "objects");
57986
- var logPath = (id) => (0, import_node_path20.join)(versionsDir(id), "log.json");
57987
- function writeAtomic(path, text2) {
58009
+ var versionsDir = (id) => (0, import_node_path21.join)(projectDir(id), "versions");
58010
+ var objectsDir = (id) => (0, import_node_path21.join)(projectDir(id), "objects");
58011
+ var logPath = (id) => (0, import_node_path21.join)(versionsDir(id), "log.json");
58012
+ function writeAtomic(path, text3) {
57988
58013
  const tmp = `${path}.${process.pid}.tmp`;
57989
- (0, import_node_fs22.writeFileSync)(tmp, text2);
57990
- (0, import_node_fs22.renameSync)(tmp, path);
58014
+ (0, import_node_fs23.writeFileSync)(tmp, text3);
58015
+ (0, import_node_fs23.renameSync)(tmp, path);
57991
58016
  }
57992
58017
  function isVersionMeta(v) {
57993
58018
  if (!v || typeof v !== "object") return false;
@@ -58002,7 +58027,7 @@ function isValidSource(s) {
58002
58027
  }
58003
58028
  function loadLog(id) {
58004
58029
  try {
58005
- const parsed = JSON.parse((0, import_node_fs22.readFileSync)(logPath(id), "utf8"));
58030
+ const parsed = JSON.parse((0, import_node_fs23.readFileSync)(logPath(id), "utf8"));
58006
58031
  const raw = parsed && typeof parsed === "object" && Array.isArray(parsed.versions) ? parsed.versions : [];
58007
58032
  return { versions: raw.filter(isVersionMeta) };
58008
58033
  } catch {
@@ -58037,7 +58062,7 @@ function rehydrate(node, id) {
58037
58062
  if (Array.isArray(node)) return node.map((x) => rehydrate(x, id));
58038
58063
  if (node && typeof node === "object") {
58039
58064
  const hash2 = blobHashOf(node);
58040
- if (hash2 !== null) return (0, import_node_fs22.readFileSync)((0, import_node_path20.join)(objectsDir(id), hash2), "utf8");
58065
+ if (hash2 !== null) return (0, import_node_fs23.readFileSync)((0, import_node_path21.join)(objectsDir(id), hash2), "utf8");
58041
58066
  const out = {};
58042
58067
  for (const [k, v] of Object.entries(node)) out[k] = rehydrate(v, id);
58043
58068
  return out;
@@ -58069,13 +58094,13 @@ function rehydrateFrom(node, blobs) {
58069
58094
  return node;
58070
58095
  }
58071
58096
  function createVersion(id, contract, meta) {
58072
- (0, import_node_fs22.mkdirSync)(versionsDir(id), { recursive: true });
58073
- (0, import_node_fs22.mkdirSync)(objectsDir(id), { recursive: true });
58097
+ (0, import_node_fs23.mkdirSync)(versionsDir(id), { recursive: true });
58098
+ (0, import_node_fs23.mkdirSync)(objectsDir(id), { recursive: true });
58074
58099
  const blobs = /* @__PURE__ */ new Map();
58075
58100
  const skeleton = dehydrate(contract, blobs);
58076
- for (const [hash2, text2] of blobs) {
58077
- const p = (0, import_node_path20.join)(objectsDir(id), hash2);
58078
- if (!(0, import_node_fs22.existsSync)(p)) writeAtomic(p, text2);
58101
+ for (const [hash2, text3] of blobs) {
58102
+ const p = (0, import_node_path21.join)(objectsDir(id), hash2);
58103
+ if (!(0, import_node_fs23.existsSync)(p)) writeAtomic(p, text3);
58079
58104
  }
58080
58105
  const log2 = loadLog(id);
58081
58106
  const n = (log2.versions.at(-1)?.n ?? 0) + 1;
@@ -58089,7 +58114,7 @@ function createVersion(id, contract, meta) {
58089
58114
  ...meta.source ? { source: meta.source } : {}
58090
58115
  // revision-read provenance (small metadata; not dehydrated)
58091
58116
  };
58092
- writeAtomic((0, import_node_path20.join)(versionsDir(id), `${n}.json`), JSON.stringify({ meta: row, contract: skeleton }, null, 2));
58117
+ writeAtomic((0, import_node_path21.join)(versionsDir(id), `${n}.json`), JSON.stringify({ meta: row, contract: skeleton }, null, 2));
58093
58118
  log2.versions.push(row);
58094
58119
  writeAtomic(logPath(id), JSON.stringify(log2, null, 2));
58095
58120
  return row;
@@ -58101,7 +58126,7 @@ function listVersions(id) {
58101
58126
  }
58102
58127
  function readVersion(id, n) {
58103
58128
  try {
58104
- const snap = JSON.parse((0, import_node_fs22.readFileSync)((0, import_node_path20.join)(versionsDir(id), `${n}.json`), "utf8"));
58129
+ const snap = JSON.parse((0, import_node_fs23.readFileSync)((0, import_node_path21.join)(versionsDir(id), `${n}.json`), "utf8"));
58105
58130
  return rehydrate(snap.contract, id);
58106
58131
  } catch {
58107
58132
  return null;
@@ -58109,13 +58134,13 @@ function readVersion(id, n) {
58109
58134
  }
58110
58135
  async function readVersionAsync(id, n) {
58111
58136
  try {
58112
- const snap = JSON.parse(await (0, import_promises2.readFile)((0, import_node_path20.join)(versionsDir(id), `${n}.json`), "utf8"));
58137
+ const snap = JSON.parse(await (0, import_promises2.readFile)((0, import_node_path21.join)(versionsDir(id), `${n}.json`), "utf8"));
58113
58138
  const refs = /* @__PURE__ */ new Set();
58114
58139
  collectBlobRefs(snap.contract, refs);
58115
58140
  if (refs.size === 0) return snap.contract;
58116
58141
  const blobs = /* @__PURE__ */ new Map();
58117
58142
  await Promise.all([...refs].map(async (hash2) => {
58118
- blobs.set(hash2, await (0, import_promises2.readFile)((0, import_node_path20.join)(objectsDir(id), hash2), "utf8"));
58143
+ blobs.set(hash2, await (0, import_promises2.readFile)((0, import_node_path21.join)(objectsDir(id), hash2), "utf8"));
58119
58144
  }));
58120
58145
  return rehydrateFrom(snap.contract, blobs);
58121
58146
  } catch {
@@ -58124,7 +58149,7 @@ async function readVersionAsync(id, n) {
58124
58149
  }
58125
58150
  function readVersionSkeleton(id, n) {
58126
58151
  try {
58127
- const snap = JSON.parse((0, import_node_fs22.readFileSync)((0, import_node_path20.join)(versionsDir(id), `${n}.json`), "utf8"));
58152
+ const snap = JSON.parse((0, import_node_fs23.readFileSync)((0, import_node_path21.join)(versionsDir(id), `${n}.json`), "utf8"));
58128
58153
  return snap.contract;
58129
58154
  } catch {
58130
58155
  return null;
@@ -58132,7 +58157,7 @@ function readVersionSkeleton(id, n) {
58132
58157
  }
58133
58158
  async function readVersionSkeletonAsync(id, n) {
58134
58159
  try {
58135
- const snap = JSON.parse(await (0, import_promises2.readFile)((0, import_node_path20.join)(versionsDir(id), `${n}.json`), "utf8"));
58160
+ const snap = JSON.parse(await (0, import_promises2.readFile)((0, import_node_path21.join)(versionsDir(id), `${n}.json`), "utf8"));
58136
58161
  return snap.contract;
58137
58162
  } catch {
58138
58163
  return null;
@@ -58300,7 +58325,7 @@ function acceptSteelForRoute(doc, ctx, from) {
58300
58325
  }
58301
58326
 
58302
58327
  // knowledge-routes.ts
58303
- var import_node_fs24 = require("node:fs");
58328
+ var import_node_fs25 = require("node:fs");
58304
58329
 
58305
58330
  // sse.ts
58306
58331
  var clients = /* @__PURE__ */ new Set();
@@ -58338,8 +58363,8 @@ function clientCount() {
58338
58363
 
58339
58364
  // knowledge-store.ts
58340
58365
  var import_node_crypto12 = require("node:crypto");
58341
- var import_node_fs23 = require("node:fs");
58342
- var import_node_path21 = require("node:path");
58366
+ var import_node_fs24 = require("node:fs");
58367
+ var import_node_path22 = require("node:path");
58343
58368
  var import_yaml6 = __toESM(require_dist6(), 1);
58344
58369
  var KnowledgeError = class extends Error {
58345
58370
  code;
@@ -58349,8 +58374,8 @@ var KnowledgeError = class extends Error {
58349
58374
  }
58350
58375
  };
58351
58376
  var EMPTY_MANIFEST = { revision: 0, currentGeneration: null, sources: [] };
58352
- var manifestPath = (id) => (0, import_node_path21.join)(projectKnowledgeDir(id), "manifest.json");
58353
- var blobsDir = (id) => (0, import_node_path21.join)(projectKnowledgeDir(id), "blobs");
58377
+ var manifestPath = (id) => (0, import_node_path22.join)(projectKnowledgeDir(id), "manifest.json");
58378
+ var blobsDir = (id) => (0, import_node_path22.join)(projectKnowledgeDir(id), "blobs");
58354
58379
  var BLOB_SHA256_RE = /^[0-9a-f]{64}$/;
58355
58380
  function isSourceRow(row) {
58356
58381
  if (!row || typeof row !== "object") return false;
@@ -58359,9 +58384,9 @@ function isSourceRow(row) {
58359
58384
  }
58360
58385
  function readManifest(id) {
58361
58386
  const p = manifestPath(id);
58362
- if (!(0, import_node_fs23.existsSync)(p)) return { ...EMPTY_MANIFEST, sources: [] };
58387
+ if (!(0, import_node_fs24.existsSync)(p)) return { ...EMPTY_MANIFEST, sources: [] };
58363
58388
  try {
58364
- const parsed = JSON.parse((0, import_node_fs23.readFileSync)(p, "utf8"));
58389
+ const parsed = JSON.parse((0, import_node_fs24.readFileSync)(p, "utf8"));
58365
58390
  if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.sources)) {
58366
58391
  console.warn(`knowledge-store: ignoring schema-invalid manifest.json at ${p} (missing/invalid sources array)`);
58367
58392
  return { ...EMPTY_MANIFEST, sources: [] };
@@ -58385,11 +58410,11 @@ function readManifest(id) {
58385
58410
  }
58386
58411
  function writeManifest(id, manifest) {
58387
58412
  const dir = projectKnowledgeDir(id);
58388
- (0, import_node_fs23.mkdirSync)(dir, { recursive: true });
58413
+ (0, import_node_fs24.mkdirSync)(dir, { recursive: true });
58389
58414
  const dest = manifestPath(id);
58390
- const tmp = (0, import_node_path21.join)(dir, `.manifest.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
58391
- (0, import_node_fs23.writeFileSync)(tmp, JSON.stringify(manifest, null, 2));
58392
- (0, import_node_fs23.renameSync)(tmp, dest);
58415
+ const tmp = (0, import_node_path22.join)(dir, `.manifest.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
58416
+ (0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(manifest, null, 2));
58417
+ (0, import_node_fs24.renameSync)(tmp, dest);
58393
58418
  }
58394
58419
  var MAX_FILES = 50;
58395
58420
  var MAX_FILE_BYTES = 100 * 1024 * 1024;
@@ -58408,9 +58433,9 @@ function blobPathFor(id, blobSha256) {
58408
58433
  if (typeof blobSha256 !== "string" || !BLOB_SHA256_RE.test(blobSha256)) {
58409
58434
  throw new KnowledgeError(`invalid blob address: ${blobSha256}`);
58410
58435
  }
58411
- const full = (0, import_node_path21.resolve)((0, import_node_path21.join)(dir, blobSha256));
58412
- const root3 = (0, import_node_path21.resolve)(dir);
58413
- if (full !== (0, import_node_path21.join)(root3, blobSha256) || !full.startsWith(root3 + import_node_path21.sep)) {
58436
+ const full = (0, import_node_path22.resolve)((0, import_node_path22.join)(dir, blobSha256));
58437
+ const root4 = (0, import_node_path22.resolve)(dir);
58438
+ if (full !== (0, import_node_path22.join)(root4, blobSha256) || !full.startsWith(root4 + import_node_path22.sep)) {
58414
58439
  throw new KnowledgeError(`blob path escapes the blobs directory: ${blobSha256}`);
58415
58440
  }
58416
58441
  return full;
@@ -58466,12 +58491,12 @@ function addSource(id, input) {
58466
58491
  const { buf, mime, filename } = input;
58467
58492
  const sha2563 = (0, import_node_crypto12.createHash)("sha256").update(buf).digest("hex");
58468
58493
  const dir = blobsDir(id);
58469
- (0, import_node_fs23.mkdirSync)(dir, { recursive: true });
58494
+ (0, import_node_fs24.mkdirSync)(dir, { recursive: true });
58470
58495
  const blobPath = blobPathFor(id, sha2563);
58471
- if (!(0, import_node_fs23.existsSync)(blobPath)) {
58496
+ if (!(0, import_node_fs24.existsSync)(blobPath)) {
58472
58497
  const tmp = `${blobPath}.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`;
58473
- (0, import_node_fs23.writeFileSync)(tmp, buf);
58474
- (0, import_node_fs23.renameSync)(tmp, blobPath);
58498
+ (0, import_node_fs24.writeFileSync)(tmp, buf);
58499
+ (0, import_node_fs24.renameSync)(tmp, blobPath);
58475
58500
  }
58476
58501
  const manifest = readManifest(id);
58477
58502
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -58514,27 +58539,27 @@ function removeSource(id, sourceId) {
58514
58539
  if (!stillReferenced) {
58515
58540
  const blobPath = blobPathFor(id, removed.blobSha256);
58516
58541
  try {
58517
- if ((0, import_node_fs23.existsSync)(blobPath)) (0, import_node_fs23.unlinkSync)(blobPath);
58542
+ if ((0, import_node_fs24.existsSync)(blobPath)) (0, import_node_fs24.unlinkSync)(blobPath);
58518
58543
  } catch (e) {
58519
58544
  console.warn(`knowledge-store: could not GC blob ${removed.blobSha256} for ${id}: ${e instanceof Error ? e.message : e}`);
58520
58545
  }
58521
58546
  }
58522
58547
  }
58523
58548
  var LOCK_STALE_MS = 10 * 60 * 1e3;
58524
- var lockPath = (id) => (0, import_node_path21.join)(projectKnowledgeDir(id), "lock.json");
58549
+ var lockPath = (id) => (0, import_node_path22.join)(projectKnowledgeDir(id), "lock.json");
58525
58550
  function writeLockFile(id, lock) {
58526
58551
  const dir = projectKnowledgeDir(id);
58527
- (0, import_node_fs23.mkdirSync)(dir, { recursive: true });
58552
+ (0, import_node_fs24.mkdirSync)(dir, { recursive: true });
58528
58553
  const dest = lockPath(id);
58529
- const tmp = (0, import_node_path21.join)(dir, `.lock.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
58530
- (0, import_node_fs23.writeFileSync)(tmp, JSON.stringify(lock, null, 2));
58531
- (0, import_node_fs23.renameSync)(tmp, dest);
58554
+ const tmp = (0, import_node_path22.join)(dir, `.lock.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
58555
+ (0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(lock, null, 2));
58556
+ (0, import_node_fs24.renameSync)(tmp, dest);
58532
58557
  }
58533
58558
  function readLock(id) {
58534
58559
  const p = lockPath(id);
58535
- if (!(0, import_node_fs23.existsSync)(p)) return null;
58560
+ if (!(0, import_node_fs24.existsSync)(p)) return null;
58536
58561
  try {
58537
- const parsed = JSON.parse((0, import_node_fs23.readFileSync)(p, "utf8"));
58562
+ const parsed = JSON.parse((0, import_node_fs24.readFileSync)(p, "utf8"));
58538
58563
  if (!parsed || typeof parsed !== "object" || typeof parsed.requestId !== "string" || typeof parsed.createdAt !== "number" || !Number.isFinite(parsed.createdAt)) {
58539
58564
  console.warn(`knowledge-store: ignoring schema-invalid lock.json at ${p}`);
58540
58565
  return null;
@@ -58570,7 +58595,7 @@ function releaseLock(id, requestId) {
58570
58595
  if (existing.requestId !== requestId) return false;
58571
58596
  const p = lockPath(id);
58572
58597
  try {
58573
- if ((0, import_node_fs23.existsSync)(p)) (0, import_node_fs23.unlinkSync)(p);
58598
+ if ((0, import_node_fs24.existsSync)(p)) (0, import_node_fs24.unlinkSync)(p);
58574
58599
  } catch (e) {
58575
58600
  console.warn(`knowledge-store: could not release lock.json at ${p}: ${e instanceof Error ? e.message : e}`);
58576
58601
  }
@@ -58578,9 +58603,9 @@ function releaseLock(id, requestId) {
58578
58603
  }
58579
58604
  var GENERATION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
58580
58605
  var GEN_KEEP = 3;
58581
- var vaultDir = (id) => (0, import_node_path21.join)(projectKnowledgeDir(id), "vault");
58582
- var generationsDir = (id) => (0, import_node_path21.join)(vaultDir(id), "generations");
58583
- var currentGenerationPath = (id) => (0, import_node_path21.join)(vaultDir(id), "current-generation.json");
58606
+ var vaultDir = (id) => (0, import_node_path22.join)(projectKnowledgeDir(id), "vault");
58607
+ var generationsDir = (id) => (0, import_node_path22.join)(vaultDir(id), "generations");
58608
+ var currentGenerationPath = (id) => (0, import_node_path22.join)(vaultDir(id), "current-generation.json");
58584
58609
  function assertGenerationId(generationId) {
58585
58610
  if (typeof generationId !== "string" || !GENERATION_ID_RE.test(generationId)) {
58586
58611
  throw new KnowledgeError("invalid generation id");
@@ -58591,18 +58616,18 @@ function mintGenerationId() {
58591
58616
  }
58592
58617
  function generationWikiDir(id, generationId) {
58593
58618
  assertGenerationId(generationId);
58594
- return (0, import_node_path21.join)(generationsDir(id), generationId, "wiki");
58619
+ return (0, import_node_path22.join)(generationsDir(id), generationId, "wiki");
58595
58620
  }
58596
58621
  function publishGeneration(id, generationId) {
58597
58622
  assertGenerationId(generationId);
58598
- if (!(0, import_node_fs23.existsSync)(generationWikiDir(id, generationId))) throw new KnowledgeError("generation not found");
58623
+ if (!(0, import_node_fs24.existsSync)(generationWikiDir(id, generationId))) throw new KnowledgeError("generation not found");
58599
58624
  const pointer = { generationId, publishedAt: (/* @__PURE__ */ new Date()).toISOString() };
58600
58625
  const dir = vaultDir(id);
58601
- (0, import_node_fs23.mkdirSync)(dir, { recursive: true });
58626
+ (0, import_node_fs24.mkdirSync)(dir, { recursive: true });
58602
58627
  const dest = currentGenerationPath(id);
58603
- const tmp = (0, import_node_path21.join)(dir, `.current-generation.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
58604
- (0, import_node_fs23.writeFileSync)(tmp, JSON.stringify(pointer, null, 2));
58605
- (0, import_node_fs23.renameSync)(tmp, dest);
58628
+ const tmp = (0, import_node_path22.join)(dir, `.current-generation.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
58629
+ (0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(pointer, null, 2));
58630
+ (0, import_node_fs24.renameSync)(tmp, dest);
58606
58631
  const manifest = readManifest(id);
58607
58632
  manifest.currentGeneration = generationId;
58608
58633
  writeManifest(id, manifest);
@@ -58611,9 +58636,9 @@ function publishGeneration(id, generationId) {
58611
58636
  }
58612
58637
  function readCurrentGeneration(id) {
58613
58638
  const p = currentGenerationPath(id);
58614
- if (!(0, import_node_fs23.existsSync)(p)) return null;
58639
+ if (!(0, import_node_fs24.existsSync)(p)) return null;
58615
58640
  try {
58616
- const parsed = JSON.parse((0, import_node_fs23.readFileSync)(p, "utf8"));
58641
+ const parsed = JSON.parse((0, import_node_fs24.readFileSync)(p, "utf8"));
58617
58642
  if (typeof parsed?.generationId !== "string" || !GENERATION_ID_RE.test(parsed.generationId) || typeof parsed.publishedAt !== "string") {
58618
58643
  console.warn(`knowledge-store: ignoring schema-invalid current-generation.json at ${p}`);
58619
58644
  return null;
@@ -58628,7 +58653,7 @@ function currentGenerationWikiDir(id) {
58628
58653
  const current = readCurrentGeneration(id);
58629
58654
  if (!current) return null;
58630
58655
  const dir = generationWikiDir(id, current.generationId);
58631
- return (0, import_node_fs23.existsSync)(dir) ? dir : null;
58656
+ return (0, import_node_fs24.existsSync)(dir) ? dir : null;
58632
58657
  }
58633
58658
  var WIKI_SLUG_RE = /^[a-z0-9][a-z0-9._-]*$/;
58634
58659
  var KB_MAX_NODES = 300;
@@ -58636,9 +58661,9 @@ var KB_MAX_TOTAL_BYTES = 8 * 1024 * 1024;
58636
58661
  var KB_MAX_VISITS = 5e3;
58637
58662
  var KB_MAX_PAGE_BYTES = 512 * 1024;
58638
58663
  var REAL_IO = {
58639
- readdir: (dir) => (0, import_node_fs23.readdirSync)(dir, { withFileTypes: true }),
58640
- readFile: (path) => (0, import_node_fs23.readFileSync)(path, "utf8"),
58641
- statSize: (path) => (0, import_node_fs23.statSync)(path).size
58664
+ readdir: (dir) => (0, import_node_fs24.readdirSync)(dir, { withFileTypes: true }),
58665
+ readFile: (path) => (0, import_node_fs24.readFileSync)(path, "utf8"),
58666
+ statSize: (path) => (0, import_node_fs24.statSync)(path).size
58642
58667
  };
58643
58668
  var VAULT_START = "<!-- vault:generated:start -->";
58644
58669
  var VAULT_END = "<!-- vault:generated:end -->";
@@ -58653,29 +58678,29 @@ function eachPage(wikiDir, io, onPage) {
58653
58678
  let limitHit = false;
58654
58679
  let found = false;
58655
58680
  const walk2 = (dir) => {
58656
- let entries;
58681
+ let entries2;
58657
58682
  try {
58658
- entries = io.readdir(dir);
58683
+ entries2 = io.readdir(dir);
58659
58684
  } catch (e) {
58660
58685
  console.warn(`knowledge-store: cannot read wiki dir ${dir}: ${e instanceof Error ? e.message : e}`);
58661
58686
  ioError = true;
58662
58687
  return "go";
58663
58688
  }
58664
- for (const ent of [...entries].sort((x, y) => x.name.localeCompare(y.name))) {
58689
+ for (const ent of [...entries2].sort((x, y) => x.name.localeCompare(y.name))) {
58665
58690
  if (++visits > KB_MAX_VISITS) {
58666
58691
  console.warn(`knowledge-store: wiki exceeds KB_MAX_VISITS=${KB_MAX_VISITS}, truncating`);
58667
58692
  limitHit = true;
58668
58693
  return "stop";
58669
58694
  }
58670
58695
  if (ent.isDirectory()) {
58671
- if (walk2((0, import_node_path21.join)(dir, ent.name)) === "stop") return "stop";
58696
+ if (walk2((0, import_node_path22.join)(dir, ent.name)) === "stop") return "stop";
58672
58697
  } else if (ent.isFile() && ent.name.endsWith(".md")) {
58673
58698
  const slug = ent.name.slice(0, -3);
58674
58699
  if (!WIKI_SLUG_RE.test(slug)) {
58675
- console.warn(`knowledge-store: skipping non-canonical wiki basename "${slug}" (${(0, import_node_path21.join)(dir, ent.name)})`);
58700
+ console.warn(`knowledge-store: skipping non-canonical wiki basename "${slug}" (${(0, import_node_path22.join)(dir, ent.name)})`);
58676
58701
  continue;
58677
58702
  }
58678
- if (onPage(slug, (0, import_node_path21.join)(dir, ent.name))) {
58703
+ if (onPage(slug, (0, import_node_path22.join)(dir, ent.name))) {
58679
58704
  found = true;
58680
58705
  return "stop";
58681
58706
  }
@@ -58852,8 +58877,8 @@ function readPage(wikiDir, slug, io = REAL_IO) {
58852
58877
  if (status === "io-error") throw new KnowledgeError("failed to read the knowledge base", "io-error");
58853
58878
  return null;
58854
58879
  }
58855
- const full = (0, import_node_path21.resolve)(found), root3 = (0, import_node_path21.resolve)(wikiDir);
58856
- if (full !== root3 && !full.startsWith(root3 + import_node_path21.sep)) return null;
58880
+ const full = (0, import_node_path22.resolve)(found), root4 = (0, import_node_path22.resolve)(wikiDir);
58881
+ if (full !== root4 && !full.startsWith(root4 + import_node_path22.sep)) return null;
58857
58882
  const pp = splitPage(full, io);
58858
58883
  if (!pp.ok) {
58859
58884
  if (pp.reason === "oversize") throw new KnowledgeError("knowledge page too large to serve", "too-large");
@@ -58935,20 +58960,20 @@ function readKnowledgeSummaries(wikiDir, opts = {}, io = REAL_IO) {
58935
58960
  truncated
58936
58961
  };
58937
58962
  }
58938
- var organizePath = (id) => (0, import_node_path21.join)(projectKnowledgeDir(id), "organize.json");
58963
+ var organizePath = (id) => (0, import_node_path22.join)(projectKnowledgeDir(id), "organize.json");
58939
58964
  function writeOrganizeFile(id, org) {
58940
58965
  const dir = projectKnowledgeDir(id);
58941
- (0, import_node_fs23.mkdirSync)(dir, { recursive: true });
58966
+ (0, import_node_fs24.mkdirSync)(dir, { recursive: true });
58942
58967
  const dest = organizePath(id);
58943
- const tmp = (0, import_node_path21.join)(dir, `.organize.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
58944
- (0, import_node_fs23.writeFileSync)(tmp, JSON.stringify(org, null, 2));
58945
- (0, import_node_fs23.renameSync)(tmp, dest);
58968
+ const tmp = (0, import_node_path22.join)(dir, `.organize.json.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`);
58969
+ (0, import_node_fs24.writeFileSync)(tmp, JSON.stringify(org, null, 2));
58970
+ (0, import_node_fs24.renameSync)(tmp, dest);
58946
58971
  }
58947
58972
  function readOrganize(id) {
58948
58973
  const p = organizePath(id);
58949
- if (!(0, import_node_fs23.existsSync)(p)) return null;
58974
+ if (!(0, import_node_fs24.existsSync)(p)) return null;
58950
58975
  try {
58951
- const parsed = JSON.parse((0, import_node_fs23.readFileSync)(p, "utf8"));
58976
+ const parsed = JSON.parse((0, import_node_fs24.readFileSync)(p, "utf8"));
58952
58977
  if (!parsed || typeof parsed !== "object" || typeof parsed.requestId !== "string" || typeof parsed.generationId !== "string" || !GENERATION_ID_RE.test(parsed.generationId) || typeof parsed.baseRevision !== "number" || !Number.isFinite(parsed.baseRevision)) {
58953
58978
  console.warn(`knowledge-store: ignoring schema-invalid organize.json at ${p}`);
58954
58979
  return null;
@@ -58967,7 +58992,7 @@ function readOrganize(id) {
58967
58992
  function deleteOrganizeFile(id) {
58968
58993
  const p = organizePath(id);
58969
58994
  try {
58970
- if ((0, import_node_fs23.existsSync)(p)) (0, import_node_fs23.unlinkSync)(p);
58995
+ if ((0, import_node_fs24.existsSync)(p)) (0, import_node_fs24.unlinkSync)(p);
58971
58996
  } catch (e) {
58972
58997
  console.warn(`knowledge-store: could not delete organize.json at ${p}: ${e instanceof Error ? e.message : e}`);
58973
58998
  }
@@ -58985,7 +59010,7 @@ function startOrganize(id, requestId) {
58985
59010
  const generationId = mintGenerationId();
58986
59011
  const manifest = readManifest(id);
58987
59012
  const baseRevision = manifest.revision;
58988
- (0, import_node_fs23.mkdirSync)(generationWikiDir(id, generationId), { recursive: true });
59013
+ (0, import_node_fs24.mkdirSync)(generationWikiDir(id, generationId), { recursive: true });
58989
59014
  const now = (/* @__PURE__ */ new Date()).toISOString();
58990
59015
  for (const row of manifest.sources) {
58991
59016
  if (row.useAsKb) {
@@ -59006,8 +59031,8 @@ function finishOrganize(id, requestId, opts) {
59006
59031
  throw new KnowledgeError("generation id mismatch");
59007
59032
  }
59008
59033
  const wikiDir = generationWikiDir(id, org.generationId);
59009
- if (!(0, import_node_fs23.existsSync)(wikiDir)) throw new KnowledgeError("generation not found");
59010
- if ((0, import_node_fs23.readdirSync)(wikiDir).length === 0) {
59034
+ if (!(0, import_node_fs24.existsSync)(wikiDir)) throw new KnowledgeError("generation not found");
59035
+ if ((0, import_node_fs24.readdirSync)(wikiDir).length === 0) {
59011
59036
  throw new KnowledgeError("nothing to publish \u2014 generation is empty");
59012
59037
  }
59013
59038
  publishGeneration(id, org.generationId);
@@ -59048,14 +59073,14 @@ function failOrganize(id, requestId, opts) {
59048
59073
  }
59049
59074
  function gcOldGenerations(id, currentGenerationId) {
59050
59075
  const dir = generationsDir(id);
59051
- if (!(0, import_node_fs23.existsSync)(dir)) return;
59052
- const entries = (0, import_node_fs23.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ name: e.name, mtimeMs: (0, import_node_fs23.statSync)((0, import_node_path21.join)(dir, e.name)).mtimeMs })).sort((a, b) => b.mtimeMs - a.mtimeMs);
59053
- const keep = new Set(entries.slice(0, GEN_KEEP).map((e) => e.name));
59076
+ if (!(0, import_node_fs24.existsSync)(dir)) return;
59077
+ const entries2 = (0, import_node_fs24.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ name: e.name, mtimeMs: (0, import_node_fs24.statSync)((0, import_node_path22.join)(dir, e.name)).mtimeMs })).sort((a, b) => b.mtimeMs - a.mtimeMs);
59078
+ const keep = new Set(entries2.slice(0, GEN_KEEP).map((e) => e.name));
59054
59079
  keep.add(currentGenerationId);
59055
- for (const e of entries) {
59080
+ for (const e of entries2) {
59056
59081
  if (keep.has(e.name)) continue;
59057
59082
  try {
59058
- (0, import_node_fs23.rmSync)((0, import_node_path21.join)(dir, e.name), { recursive: true, force: true });
59083
+ (0, import_node_fs24.rmSync)((0, import_node_path22.join)(dir, e.name), { recursive: true, force: true });
59059
59084
  } catch (err2) {
59060
59085
  console.warn(`knowledge-store: could not GC stale generation dir ${e.name}: ${err2 instanceof Error ? err2.message : err2}`);
59061
59086
  }
@@ -59171,7 +59196,7 @@ function registerKnowledgeRoutes(app) {
59171
59196
  const blobPath = blobPathFor(project.id, row.blobSha256);
59172
59197
  let fd2;
59173
59198
  try {
59174
- fd2 = (0, import_node_fs24.openSync)(blobPath, "r");
59199
+ fd2 = (0, import_node_fs25.openSync)(blobPath, "r");
59175
59200
  } catch (e) {
59176
59201
  const code = e.code;
59177
59202
  if (code === "ENOENT" || code === "ENOTDIR") {
@@ -59181,17 +59206,17 @@ function registerKnowledgeRoutes(app) {
59181
59206
  }
59182
59207
  let streamOwnsFd = false;
59183
59208
  try {
59184
- const st = (0, import_node_fs24.fstatSync)(fd2);
59209
+ const st = (0, import_node_fs25.fstatSync)(fd2);
59185
59210
  if (!st.isFile()) {
59186
59211
  return reply.status(404).send({ ok: false, error: "source bytes are missing" });
59187
59212
  }
59188
59213
  reply.header("Content-Type", row.mime).header("Content-Length", String(st.size)).header("X-Content-Type-Options", "nosniff").header("Content-Disposition", "inline").header("Cache-Control", "private, no-store").header("Content-Security-Policy", "default-src 'none'; sandbox; frame-ancestors 'self'").header("Cross-Origin-Resource-Policy", "same-origin");
59189
59214
  if (req.method === "HEAD") return reply.send();
59190
- const stream = (0, import_node_fs24.createReadStream)(blobPath, { fd: fd2, autoClose: true });
59215
+ const stream = (0, import_node_fs25.createReadStream)(blobPath, { fd: fd2, autoClose: true });
59191
59216
  streamOwnsFd = true;
59192
59217
  return reply.send(stream);
59193
59218
  } finally {
59194
- if (!streamOwnsFd) (0, import_node_fs24.closeSync)(fd2);
59219
+ if (!streamOwnsFd) (0, import_node_fs25.closeSync)(fd2);
59195
59220
  }
59196
59221
  } catch (e) {
59197
59222
  if (e instanceof ProjectError) return reply.status(400).send({ ok: false, error: e.message });
@@ -59354,21 +59379,21 @@ function registerKnowledgeRoutes(app) {
59354
59379
 
59355
59380
  // project-sources-store.ts
59356
59381
  var import_node_crypto13 = require("node:crypto");
59357
- var import_node_fs25 = require("node:fs");
59358
- var import_node_path22 = require("node:path");
59359
- var sourcesDir = (id) => (0, import_node_path22.join)(projectDir(id), "sources");
59382
+ var import_node_fs26 = require("node:fs");
59383
+ var import_node_path23 = require("node:path");
59384
+ var sourcesDir = (id) => (0, import_node_path23.join)(projectDir(id), "sources");
59360
59385
  var safeExt = (ext) => typeof ext === "string" && /^[a-z0-9]{1,8}$/i.test(ext) ? ext.toLowerCase() : "bin";
59361
59386
  function writeAtomic2(path, buf) {
59362
59387
  const tmp = `${path}.${process.pid}.tmp`;
59363
- (0, import_node_fs25.writeFileSync)(tmp, buf);
59364
- (0, import_node_fs25.renameSync)(tmp, path);
59388
+ (0, import_node_fs26.writeFileSync)(tmp, buf);
59389
+ (0, import_node_fs26.renameSync)(tmp, path);
59365
59390
  }
59366
59391
  function saveSource(id, file) {
59367
- (0, import_node_fs25.mkdirSync)(sourcesDir(id), { recursive: true });
59392
+ (0, import_node_fs26.mkdirSync)(sourcesDir(id), { recursive: true });
59368
59393
  const sha2563 = (0, import_node_crypto13.createHash)("sha256").update(file.buf).digest("hex");
59369
59394
  const ext = safeExt(file.ext);
59370
- const p = (0, import_node_path22.join)(sourcesDir(id), `${sha2563}.${ext}`);
59371
- if (!(0, import_node_fs25.existsSync)(p)) writeAtomic2(p, file.buf);
59395
+ const p = (0, import_node_path23.join)(sourcesDir(id), `${sha2563}.${ext}`);
59396
+ if (!(0, import_node_fs26.existsSync)(p)) writeAtomic2(p, file.buf);
59372
59397
  return { name: String(file.name), sha256: sha2563, ext, bytes: file.buf.length };
59373
59398
  }
59374
59399
 
@@ -61582,7 +61607,7 @@ function structuralGridRecords(contract) {
61582
61607
  if (!Array.isArray(grid.origin) || grid.origin.length < 2 || !grid.origin.every((n) => typeof n === "number" && isFinite(n))) {
61583
61608
  throw new SceneContractError(`Grid on ${where} has an invalid origin.`);
61584
61609
  }
61585
- const root3 = `grid:${planIndex + 1}:${String(plan.sheet || plan.title || "main").trim().replace(/\s+/g, "-")}`;
61610
+ const root4 = `grid:${planIndex + 1}:${String(plan.sheet || plan.title || "main").trim().replace(/\s+/g, "-")}`;
61586
61611
  const k = mmPerPx(ptPerFt);
61587
61612
  const [ox, oy] = grid.origin;
61588
61613
  const toX = (x) => (x - ox) * k;
@@ -61599,7 +61624,7 @@ function structuralGridRecords(contract) {
61599
61624
  const start = Math.min(toY(axis.lo), toY(axis.hi));
61600
61625
  const end = Math.max(toY(axis.lo), toY(axis.hi));
61601
61626
  axes.push({
61602
- id: `${root3}:x:${index + 1}`,
61627
+ id: `${root4}:x:${index + 1}`,
61603
61628
  direction: "x",
61604
61629
  offsetMm: toX(axis.x),
61605
61630
  label: String(axis.label).trim(),
@@ -61612,7 +61637,7 @@ function structuralGridRecords(contract) {
61612
61637
  const start = Math.min(toX(axis.lo), toX(axis.hi));
61613
61638
  const end = Math.max(toX(axis.lo), toX(axis.hi));
61614
61639
  axes.push({
61615
- id: `${root3}:y:${index + 1}`,
61640
+ id: `${root4}:y:${index + 1}`,
61616
61641
  direction: "y",
61617
61642
  offsetMm: toY(axis.y),
61618
61643
  label: String(axis.label).trim(),
@@ -61622,10 +61647,10 @@ function structuralGridRecords(contract) {
61622
61647
  });
61623
61648
  const levels = geometry.zs.map((level, index) => {
61624
61649
  if (!String(level.label || "").trim()) throw new SceneContractError(`Grid on ${where} has a blank elevation label.`);
61625
- return { id: `${root3}:level:${level.sourceIndex ?? index}`, elevationMm: level.mm, label: String(level.label).trim() };
61650
+ return { id: `${root4}:level:${level.sourceIndex ?? index}`, elevationMm: level.mm, label: String(level.label).trim() };
61626
61651
  });
61627
61652
  const record2 = {
61628
- id: root3,
61653
+ id: root4,
61629
61654
  kind: "structural-grid",
61630
61655
  name: String(plan.title || plan.sheet || `Grid ${planIndex + 1}`).trim(),
61631
61656
  origin: [ox * k, -oy * k, 0],
@@ -61643,7 +61668,7 @@ function structuralGridRecords(contract) {
61643
61668
  referenceSystems.push(record2);
61644
61669
  }
61645
61670
  geometry.lines.forEach((line) => unsupported.push({
61646
- id: `${root3}:free:${line.id}`,
61671
+ id: `${root4}:free:${line.id}`,
61647
61672
  kind: "grid-axis",
61648
61673
  status: "unsupported",
61649
61674
  code: "free-angle-grid-axis-unrepresentable",
@@ -61901,7 +61926,7 @@ function modelGridRecords(grid) {
61901
61926
  zip("X", xAxes, X.offsets.length);
61902
61927
  zip("Y", yAxes, Y.offsets.length);
61903
61928
  zip("Z", zAxes, Z.levels.length);
61904
- const root3 = "grid:model";
61929
+ const root4 = "grid:model";
61905
61930
  const labelX = labelsFor(grid.labels_x, "num", X.offsets.length);
61906
61931
  const labelY = labelsFor(grid.labels_y, "alpha", Y.offsets.length);
61907
61932
  const ends = grid.ends ?? {};
@@ -61914,7 +61939,7 @@ function modelGridRecords(grid) {
61914
61939
  const start = span ? Math.min(span[0], span[1]) - oy : bounds.minY;
61915
61940
  const end = span ? Math.max(span[0], span[1]) - oy : bounds.maxY;
61916
61941
  axes.push({
61917
- id: `${root3}:${axis.id}`,
61942
+ id: `${root4}:${axis.id}`,
61918
61943
  direction: "x",
61919
61944
  offsetMm,
61920
61945
  label,
@@ -61930,7 +61955,7 @@ function modelGridRecords(grid) {
61930
61955
  const start = span ? Math.min(span[0], span[1]) - ox : bounds.minX;
61931
61956
  const end = span ? Math.max(span[0], span[1]) - ox : bounds.maxX;
61932
61957
  axes.push({
61933
- id: `${root3}:${axis.id}`,
61958
+ id: `${root4}:${axis.id}`,
61934
61959
  direction: "y",
61935
61960
  offsetMm,
61936
61961
  label,
@@ -61945,10 +61970,10 @@ function modelGridRecords(grid) {
61945
61970
  const axis = axisBySourceIndex.get(level.sourceIndex);
61946
61971
  const label = (axis.label ?? "").trim() || level.label;
61947
61972
  if (!label) throw new SceneContractError("The model grid has a blank elevation label.");
61948
- return { id: `${root3}:${axis.id}`, elevationMm: level.mm, label };
61973
+ return { id: `${root4}:${axis.id}`, elevationMm: level.mm, label };
61949
61974
  });
61950
61975
  const record2 = {
61951
- id: root3,
61976
+ id: root4,
61952
61977
  kind: "structural-grid",
61953
61978
  name: "Model Grid",
61954
61979
  origin: [ox, oy, 0],
@@ -61957,7 +61982,7 @@ function modelGridRecords(grid) {
61957
61982
  bounds
61958
61983
  };
61959
61984
  const unsupported = lines.map((line) => ({
61960
- id: `${root3}:free:${line.id}`,
61985
+ id: `${root4}:free:${line.id}`,
61961
61986
  kind: "grid-axis",
61962
61987
  status: "unsupported",
61963
61988
  code: "free-angle-grid-axis-unrepresentable",
@@ -62004,6 +62029,41 @@ function awareSceneFromModel(contractInput, sourceId) {
62004
62029
  return { scene, skipped: legacy.skipped, producerUnsupported };
62005
62030
  }
62006
62031
 
62032
+ // ../web/steel-detail-refs.js
62033
+ var text2 = (v) => String(v == null ? "" : v).trim();
62034
+ function calloutRefText(callout) {
62035
+ if (!callout || typeof callout !== "object") return null;
62036
+ const printed = text2(callout.text);
62037
+ if (printed) return printed;
62038
+ const target = callout.target;
62039
+ if (!target || typeof target !== "object") return null;
62040
+ const number = text2(target.number), sheet = text2(target.sheet);
62041
+ return number && sheet ? number + "-" + sheet : null;
62042
+ }
62043
+ function entries(plan) {
62044
+ if (!plan || typeof plan !== "object") return [];
62045
+ const out = [];
62046
+ for (const list of [plan.details, plan.callouts]) if (Array.isArray(list)) out.push(...list);
62047
+ return out;
62048
+ }
62049
+ var NON_DETAIL_KINDS = ["section", "elevation"];
62050
+ function planScoredDetails(plan) {
62051
+ const skip = new Set(NON_DETAIL_KINDS);
62052
+ const seen = /* @__PURE__ */ new Set(), out = [];
62053
+ for (const entry2 of entries(plan)) {
62054
+ if (!entry2 || typeof entry2 !== "object") continue;
62055
+ if (skip.has(text2(entry2.kind).toLowerCase())) continue;
62056
+ const name = calloutRefText(entry2) || "";
62057
+ const t = entry2.target;
62058
+ const targetSheet = t && typeof t === "object" && text2(t.sheet) || "";
62059
+ const key = name + "\0" + targetSheet;
62060
+ if (seen.has(key)) continue;
62061
+ seen.add(key);
62062
+ out.push({ text: name, targetSheet: targetSheet || null, kind: text2(entry2.kind) || "detail" });
62063
+ }
62064
+ return out;
62065
+ }
62066
+
62007
62067
  // steel-confidence.ts
62008
62068
  var BAND_WEIGHT = { verified: 1, high: 0.9, med: 0.65, low: 0.35, rfi: 0 };
62009
62069
  var isBraceMember = (m) => typeof m.memberType === "string" && m.memberType.trim().toLowerCase() === "brace";
@@ -62209,12 +62269,12 @@ function scoreContract(contractInput) {
62209
62269
  factors
62210
62270
  });
62211
62271
  }
62212
- for (const d of plan.details ?? []) {
62213
- const text2 = d.text ?? "";
62214
- const sheet = detailSheet(text2);
62272
+ for (const d of planScoredDetails(plan)) {
62273
+ const text3 = d.text;
62274
+ const sheet = detailSheet(text3) ?? d.targetSheet;
62215
62275
  const resolved = sheet != null && knownSheets.has(sheet.toUpperCase());
62216
62276
  byDetail.push({
62217
- text: text2,
62277
+ text: text3,
62218
62278
  planIdx,
62219
62279
  sheet: plan.sheet ?? "",
62220
62280
  band: resolved ? "high" : "low",
@@ -62250,8 +62310,8 @@ function scoreContract(contractInput) {
62250
62310
  }
62251
62311
  };
62252
62312
  }
62253
- function detailSheet(text2) {
62254
- const m = text2.toUpperCase().match(/S-?\s?\d{2,3}/);
62313
+ function detailSheet(text3) {
62314
+ const m = text3.toUpperCase().match(/S-?\s?\d{2,3}/);
62255
62315
  return m ? m[0].replace(/\s/g, "") : null;
62256
62316
  }
62257
62317
  function rollupDetails(details) {
@@ -62584,8 +62644,8 @@ function registerRevisionRoutes(app) {
62584
62644
  }
62585
62645
 
62586
62646
  // project-export-files.ts
62587
- var import_node_fs26 = require("node:fs");
62588
- var import_node_path23 = require("node:path");
62647
+ var import_node_fs27 = require("node:fs");
62648
+ var import_node_path24 = require("node:path");
62589
62649
  function projectExportFiles(appId, kindOf2 = appId) {
62590
62650
  if (kindOf2 === "vectorize") {
62591
62651
  return [{ kind: "svg", filename: `${appId}.svg` }];
@@ -62613,26 +62673,26 @@ function exportFileBase(projectId, appId, now = /* @__PURE__ */ new Date()) {
62613
62673
  }
62614
62674
  function uniqueProjectExportFilename(projectId, preferred) {
62615
62675
  const dir = projectExportsDir(projectId);
62616
- if (!(0, import_node_fs26.existsSync)((0, import_node_path23.join)(dir, preferred))) return preferred;
62617
- const extension = (0, import_node_path23.extname)(preferred);
62676
+ if (!(0, import_node_fs27.existsSync)((0, import_node_path24.join)(dir, preferred))) return preferred;
62677
+ const extension = (0, import_node_path24.extname)(preferred);
62618
62678
  const stem = preferred.slice(0, preferred.length - extension.length);
62619
62679
  for (let suffix = 2; suffix <= 9999; suffix += 1) {
62620
62680
  const candidate = `${stem}-${suffix}${extension}`;
62621
- if (!(0, import_node_fs26.existsSync)((0, import_node_path23.join)(dir, candidate))) return candidate;
62681
+ if (!(0, import_node_fs27.existsSync)((0, import_node_path24.join)(dir, candidate))) return candidate;
62622
62682
  }
62623
62683
  throw new Error("could not allocate a unique project export filename");
62624
62684
  }
62625
62685
 
62626
62686
  // project-export-receipts.ts
62627
62687
  var import_node_crypto15 = require("node:crypto");
62628
- var import_node_fs27 = require("node:fs");
62629
- var import_node_path25 = require("node:path");
62688
+ var import_node_fs28 = require("node:fs");
62689
+ var import_node_path26 = require("node:path");
62630
62690
 
62631
62691
  // safe-filename.ts
62632
- var import_node_path24 = require("node:path");
62692
+ var import_node_path25 = require("node:path");
62633
62693
  var WINDOWS_DEVICE = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i;
62634
62694
  function isPortablePlainFilename(name) {
62635
- return !!name && (0, import_node_path24.basename)(name) === name && name !== "." && name !== ".." && !/[\\/\u0000-\u001f\u007f<>:"|?*]/.test(name) && !/[. ]$/.test(name) && !WINDOWS_DEVICE.test(name) && Buffer.byteLength(name, "utf8") <= 255;
62695
+ return !!name && (0, import_node_path25.basename)(name) === name && name !== "." && name !== ".." && !/[\\/\u0000-\u001f\u007f<>:"|?*]/.test(name) && !/[. ]$/.test(name) && !WINDOWS_DEVICE.test(name) && Buffer.byteLength(name, "utf8") <= 255;
62636
62696
  }
62637
62697
 
62638
62698
  // project-export-receipts.ts
@@ -62651,7 +62711,7 @@ var EXTENSIONS = {
62651
62711
  "render-mp4": ".mp4"
62652
62712
  };
62653
62713
  var RESERVED2 = /^\.floless-(?:txn|cleanup|tmp|backup)-/i;
62654
- var projectExportIndexPath = (projectId) => (0, import_node_path25.join)(projectExportsDir(projectId), "index.json");
62714
+ var projectExportIndexPath = (projectId) => (0, import_node_path26.join)(projectExportsDir(projectId), "index.json");
62655
62715
  function hash(bytes) {
62656
62716
  return (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex");
62657
62717
  }
@@ -62659,13 +62719,13 @@ function proof(bytes) {
62659
62719
  return bytes ? { exists: true, bytes: bytes.length, sha256: hash(bytes) } : { exists: false, bytes: 0, sha256: null };
62660
62720
  }
62661
62721
  function readFileProof(path) {
62662
- return (0, import_node_fs27.existsSync)(path) ? proof((0, import_node_fs27.readFileSync)(path)) : proof(null);
62722
+ return (0, import_node_fs28.existsSync)(path) ? proof((0, import_node_fs28.readFileSync)(path)) : proof(null);
62663
62723
  }
62664
62724
  function fileProofEquals(a, b) {
62665
62725
  return a.exists === b.exists && a.bytes === b.bytes && a.sha256 === b.sha256;
62666
62726
  }
62667
62727
  function validReceiptFilename(kind, filename) {
62668
- if (!isPortablePlainFilename(filename) || filename === "index.json" || RESERVED2.test(filename) || (0, import_node_path25.basename)(filename) !== filename) return false;
62728
+ if (!isPortablePlainFilename(filename) || filename === "index.json" || RESERVED2.test(filename) || (0, import_node_path26.basename)(filename) !== filename) return false;
62669
62729
  return filename.toLowerCase().endsWith(EXTENSIONS[kind]);
62670
62730
  }
62671
62731
  function isExportKind(v) {
@@ -62758,45 +62818,45 @@ function indexBytes(body) {
62758
62818
  `, "utf8");
62759
62819
  }
62760
62820
  function syncFile(path) {
62761
- const fd2 = (0, import_node_fs27.openSync)(path, "r+");
62821
+ const fd2 = (0, import_node_fs28.openSync)(path, "r+");
62762
62822
  try {
62763
- (0, import_node_fs27.fsyncSync)(fd2);
62823
+ (0, import_node_fs28.fsyncSync)(fd2);
62764
62824
  } finally {
62765
- (0, import_node_fs27.closeSync)(fd2);
62825
+ (0, import_node_fs28.closeSync)(fd2);
62766
62826
  }
62767
62827
  }
62768
62828
  function syncDirectory(path) {
62769
62829
  try {
62770
- const fd2 = (0, import_node_fs27.openSync)(path, "r");
62830
+ const fd2 = (0, import_node_fs28.openSync)(path, "r");
62771
62831
  try {
62772
- (0, import_node_fs27.fsyncSync)(fd2);
62832
+ (0, import_node_fs28.fsyncSync)(fd2);
62773
62833
  } finally {
62774
- (0, import_node_fs27.closeSync)(fd2);
62834
+ (0, import_node_fs28.closeSync)(fd2);
62775
62835
  }
62776
62836
  } catch {
62777
62837
  }
62778
62838
  }
62779
62839
  function durableReplace(path, bytes) {
62780
- const dir = (0, import_node_path25.dirname)(path);
62781
- (0, import_node_fs27.mkdirSync)(dir, { recursive: true });
62782
- const tmp = (0, import_node_path25.join)(dir, `.floless-tmp-receipt-${(0, import_node_crypto15.randomUUID)()}`);
62840
+ const dir = (0, import_node_path26.dirname)(path);
62841
+ (0, import_node_fs28.mkdirSync)(dir, { recursive: true });
62842
+ const tmp = (0, import_node_path26.join)(dir, `.floless-tmp-receipt-${(0, import_node_crypto15.randomUUID)()}`);
62783
62843
  try {
62784
- (0, import_node_fs27.writeFileSync)(tmp, bytes, { flag: "wx" });
62844
+ (0, import_node_fs28.writeFileSync)(tmp, bytes, { flag: "wx" });
62785
62845
  syncFile(tmp);
62786
- (0, import_node_fs27.renameSync)(tmp, path);
62846
+ (0, import_node_fs28.renameSync)(tmp, path);
62787
62847
  syncFile(path);
62788
62848
  syncDirectory(dir);
62789
62849
  } finally {
62790
62850
  try {
62791
- (0, import_node_fs27.rmSync)(tmp, { force: true });
62851
+ (0, import_node_fs28.rmSync)(tmp, { force: true });
62792
62852
  } catch {
62793
62853
  }
62794
62854
  }
62795
62855
  }
62796
62856
  function strictCurrent(projectId) {
62797
62857
  const path = projectExportIndexPath(projectId);
62798
- if (!(0, import_node_fs27.existsSync)(path)) return { bytes: null, body: { exports: [], opaque: [] } };
62799
- const bytes = (0, import_node_fs27.readFileSync)(path);
62858
+ if (!(0, import_node_fs28.existsSync)(path)) return { bytes: null, body: { exports: [], opaque: [] } };
62859
+ const bytes = (0, import_node_fs28.readFileSync)(path);
62800
62860
  return { bytes, body: parseIndexBytes(bytes) };
62801
62861
  }
62802
62862
  function listProjectExportReceipts(projectId) {
@@ -62808,14 +62868,14 @@ function listProjectExportReceipts(projectId) {
62808
62868
  }
62809
62869
  function resolveProjectExportReceiptPath(projectId, receipt) {
62810
62870
  if (!validReceiptFilename(receipt.kind, receipt.filename)) return null;
62811
- const dir = (0, import_node_path25.resolve)(projectExportsDir(projectId));
62812
- const path = (0, import_node_path25.resolve)(dir, receipt.filename);
62813
- return (0, import_node_path25.dirname)(path) === dir ? path : null;
62871
+ const dir = (0, import_node_path26.resolve)(projectExportsDir(projectId));
62872
+ const path = (0, import_node_path26.resolve)(dir, receipt.filename);
62873
+ return (0, import_node_path26.dirname)(path) === dir ? path : null;
62814
62874
  }
62815
62875
  function prepareProjectExport(projectId, receipt) {
62816
62876
  validateInput(receipt);
62817
62877
  const dir = projectExportsDir(projectId);
62818
- (0, import_node_fs27.mkdirSync)(dir, { recursive: true });
62878
+ (0, import_node_fs28.mkdirSync)(dir, { recursive: true });
62819
62879
  const current = strictCurrent(projectId);
62820
62880
  const key = receiptKey(receipt.kind, receipt.variant);
62821
62881
  const prior = current.body.exports.find((row) => receiptKey(row.kind, row.variant) === key) ?? null;
@@ -62884,8 +62944,8 @@ function restoreProjectExportTransition(transition) {
62884
62944
  }
62885
62945
  durableReplace(transition.indexPath, Buffer.from(transition.beforeBytesBase64, "base64"));
62886
62946
  } else {
62887
- (0, import_node_fs27.rmSync)(transition.indexPath, { force: true });
62888
- syncDirectory((0, import_node_path25.dirname)(transition.indexPath));
62947
+ (0, import_node_fs28.rmSync)(transition.indexPath, { force: true });
62948
+ syncDirectory((0, import_node_path26.dirname)(transition.indexPath));
62889
62949
  }
62890
62950
  if (!currentMatches(transition.indexPath, transition.before)) {
62891
62951
  throw new ProjectExportReceiptError("project export index did not match the restored proof.");
@@ -62907,8 +62967,8 @@ function cleanupSupersededProjectExport(transition) {
62907
62967
  const path = resolveProjectExportReceiptPath(transition.projectId, superseded);
62908
62968
  if (!path) return;
62909
62969
  try {
62910
- (0, import_node_fs27.rmSync)(path, { force: true });
62911
- syncDirectory((0, import_node_path25.dirname)(path));
62970
+ (0, import_node_fs28.rmSync)(path, { force: true });
62971
+ syncDirectory((0, import_node_path26.dirname)(path));
62912
62972
  } catch {
62913
62973
  }
62914
62974
  }
@@ -62921,7 +62981,7 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
62921
62981
  if (!path) throw new ProjectExportReceiptError("project export artifact path is unsafe.");
62922
62982
  let wroteArtifact = false;
62923
62983
  try {
62924
- (0, import_node_fs27.writeFileSync)(path, bytes, { flag: "wx" });
62984
+ (0, import_node_fs28.writeFileSync)(path, bytes, { flag: "wx" });
62925
62985
  wroteArtifact = true;
62926
62986
  syncFile(path);
62927
62987
  commitProjectExportTransition(transition);
@@ -62936,8 +62996,8 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
62936
62996
  }
62937
62997
  if (!restoreError && wroteArtifact) {
62938
62998
  try {
62939
- (0, import_node_fs27.rmSync)(path, { force: true });
62940
- syncDirectory((0, import_node_path25.dirname)(path));
62999
+ (0, import_node_fs28.rmSync)(path, { force: true });
63000
+ syncDirectory((0, import_node_path26.dirname)(path));
62941
63001
  } catch {
62942
63002
  }
62943
63003
  }
@@ -62951,7 +63011,7 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
62951
63011
  }
62952
63012
  function receiptHasFile(projectId, receipt) {
62953
63013
  const path = resolveProjectExportReceiptPath(projectId, receipt);
62954
- return path !== null && (0, import_node_fs27.existsSync)(path);
63014
+ return path !== null && (0, import_node_fs28.existsSync)(path);
62955
63015
  }
62956
63016
  function matchingProjectExportReceipts(projectId, version, contractHash2, kinds) {
62957
63017
  const wanted = kinds ? new Set(kinds) : null;
@@ -62998,7 +63058,7 @@ function currentApprovedSnapshot(projectId, version) {
62998
63058
  }
62999
63059
 
63000
63060
  // workspace-data.ts
63001
- var import_node_fs28 = require("node:fs");
63061
+ var import_node_fs29 = require("node:fs");
63002
63062
  var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
63003
63063
  var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
63004
63064
  "bom-csv",
@@ -63058,15 +63118,15 @@ function exportBody(projectId, receipt, opts) {
63058
63118
  };
63059
63119
  if (opts.includePaths) body.path = path;
63060
63120
  if (opts.exportContents) {
63061
- const st = (0, import_node_fs28.statSync)(path);
63121
+ const st = (0, import_node_fs29.statSync)(path);
63062
63122
  if (st.size > opts.maxBytes) {
63063
63123
  body.contentOmitted = true;
63064
63124
  body.omittedReason = `export is ${st.size} bytes, over max-bytes ${opts.maxBytes}`;
63065
63125
  } else if (receipt.encoding === "base64") {
63066
- body.content = (0, import_node_fs28.readFileSync)(path).toString("base64");
63126
+ body.content = (0, import_node_fs29.readFileSync)(path).toString("base64");
63067
63127
  } else {
63068
63128
  body.encoding = receipt.encoding ?? "utf8";
63069
- body.content = (0, import_node_fs28.readFileSync)(path, "utf8");
63129
+ body.content = (0, import_node_fs29.readFileSync)(path, "utf8");
63070
63130
  }
63071
63131
  }
63072
63132
  return body;
@@ -63477,9 +63537,9 @@ function remapDetailPlacements(v1) {
63477
63537
  }
63478
63538
  function remapDims3d(v1) {
63479
63539
  const issues = [];
63480
- const entries = isObj3(v1) ? arr3(v1.dims3d).filter(isObj3) : [];
63481
- if (entries.length) {
63482
- issues.push({ code: "dims3d-ownerless", severity: "block", message: `${entries.length} 3D dimension(s) carry world coordinates in the OLD scene frame and have no owner to recompute from; assign a frame, confirm keep-as-world, or discard them before migrating (epic \xA710)` });
63540
+ const entries2 = isObj3(v1) ? arr3(v1.dims3d).filter(isObj3) : [];
63541
+ if (entries2.length) {
63542
+ issues.push({ code: "dims3d-ownerless", severity: "block", message: `${entries2.length} 3D dimension(s) carry world coordinates in the OLD scene frame and have no owner to recompute from; assign a frame, confirm keep-as-world, or discard them before migrating (epic \xA710)` });
63483
63543
  }
63484
63544
  return { dims3d: [], issues };
63485
63545
  }
@@ -64482,18 +64542,18 @@ function registerMigrationPreviewRoute(app, deps) {
64482
64542
  }
64483
64543
 
64484
64544
  // workspace-agent-manifest.ts
64485
- var import_node_fs29 = require("node:fs");
64486
- var import_node_os15 = require("node:os");
64487
- var import_node_path26 = require("node:path");
64545
+ var import_node_fs30 = require("node:fs");
64546
+ var import_node_os16 = require("node:os");
64547
+ var import_node_path27 = require("node:path");
64488
64548
  function awareHome() {
64489
- return process.env.AWARE_HOME || (0, import_node_path26.join)((0, import_node_os15.homedir)(), ".aware");
64549
+ return process.env.AWARE_HOME || (0, import_node_path27.join)((0, import_node_os16.homedir)(), ".aware");
64490
64550
  }
64491
64551
  function workspaceAgentDir() {
64492
- return (0, import_node_path26.join)(awareHome(), "agents", "floless-workspace");
64552
+ return (0, import_node_path27.join)(awareHome(), "agents", "floless-workspace");
64493
64553
  }
64494
64554
  function syncWorkspaceAgentManifest(port) {
64495
64555
  const dir = workspaceAgentDir();
64496
- (0, import_node_fs29.mkdirSync)(dir, { recursive: true });
64556
+ (0, import_node_fs30.mkdirSync)(dir, { recursive: true });
64497
64557
  const manifest = `agent: floless-workspace
64498
64558
  version: 0.2.0
64499
64559
  sdk-target: 2.4.0
@@ -64623,8 +64683,8 @@ commands:
64623
64683
  headers: object
64624
64684
  body: object
64625
64685
  `;
64626
- const path = (0, import_node_path26.join)(dir, "manifest.yaml");
64627
- if (!(0, import_node_fs29.existsSync)(path) || manifest !== "") (0, import_node_fs29.writeFileSync)(path, manifest, "utf8");
64686
+ const path = (0, import_node_path27.join)(dir, "manifest.yaml");
64687
+ if (!(0, import_node_fs30.existsSync)(path) || manifest !== "") (0, import_node_fs30.writeFileSync)(path, manifest, "utf8");
64628
64688
  return path;
64629
64689
  }
64630
64690
 
@@ -65428,10 +65488,10 @@ var unavailableSummary = (from, side) => ({
65428
65488
  function summarizeContractDiff(diff) {
65429
65489
  const bullets = [];
65430
65490
  let detailCount = 0;
65431
- const add = (count, text2) => {
65491
+ const add = (count, text3) => {
65432
65492
  if (!count) return;
65433
65493
  detailCount += count;
65434
- bullets.push(text2);
65494
+ bullets.push(text3);
65435
65495
  };
65436
65496
  add(diff.added.length, `Added ${countWord(diff.added.length, "member")}: ${preview(diff.added.map(refName))}.`);
65437
65497
  add(diff.removed.length, `Removed ${countWord(diff.removed.length, "member")}: ${preview(diff.removed.map(refName))}.`);
@@ -65617,7 +65677,7 @@ function computeVersionDiff(id, n, base) {
65617
65677
  }
65618
65678
 
65619
65679
  // contract-bake.ts
65620
- var import_node_fs30 = require("node:fs");
65680
+ var import_node_fs31 = require("node:fs");
65621
65681
  var import_yaml7 = __toESM(require_dist6(), 1);
65622
65682
  function bakedV2(contract) {
65623
65683
  const baked = { ...contract };
@@ -65637,7 +65697,7 @@ function bakedV2(contract) {
65637
65697
  return stripConfidentialImages(baked);
65638
65698
  }
65639
65699
  function bakeContractIntoApp(sourcePath, contract) {
65640
- const doc = (0, import_yaml7.parseDocument)((0, import_node_fs30.readFileSync)(sourcePath, "utf8"));
65700
+ const doc = (0, import_yaml7.parseDocument)((0, import_node_fs31.readFileSync)(sourcePath, "utf8"));
65641
65701
  if (doc.errors.length > 0) {
65642
65702
  throw new Error(`contract bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
65643
65703
  }
@@ -65654,7 +65714,7 @@ function bakeContractIntoApp(sourcePath, contract) {
65654
65714
  throw new InvalidModelV2Error(`refusing to bake: contract declares steel.model/v2 but is not valid v2: ${issues[0] ?? "unknown"}`, issues);
65655
65715
  }
65656
65716
  doc.setIn(["nodes", idx, "config", "takeoff"], bakedV2(contract));
65657
- (0, import_node_fs30.writeFileSync)(sourcePath, doc.toString());
65717
+ (0, import_node_fs31.writeFileSync)(sourcePath, doc.toString());
65658
65718
  return;
65659
65719
  }
65660
65720
  const baked = { ...contract };
@@ -65699,7 +65759,7 @@ function bakeContractIntoApp(sourcePath, contract) {
65699
65759
  );
65700
65760
  }
65701
65761
  doc.setIn(["nodes", idx, "config", "takeoff"], baked);
65702
- (0, import_node_fs30.writeFileSync)(sourcePath, doc.toString());
65762
+ (0, import_node_fs31.writeFileSync)(sourcePath, doc.toString());
65703
65763
  }
65704
65764
 
65705
65765
  // vectorize.ts
@@ -66056,11 +66116,11 @@ function viewsToScene(contractInput) {
66056
66116
  }
66057
66117
 
66058
66118
  // bom-export.ts
66059
- var import_node_os16 = require("node:os");
66060
- var import_node_path27 = require("node:path");
66119
+ var import_node_os17 = require("node:os");
66120
+ var import_node_path28 = require("node:path");
66061
66121
 
66062
66122
  // node_modules/write-excel-file/modules/export/writeXlsxFileNode.js
66063
- var import_node_fs31 = __toESM(require("node:fs"), 1);
66123
+ var import_node_fs32 = __toESM(require("node:fs"), 1);
66064
66124
 
66065
66125
  // node_modules/write-excel-file/modules/xlsx/helpers/features/getAdditionalContent.js
66066
66126
  function _createForOfIteratorHelperLoose(r, e) {
@@ -69160,7 +69220,7 @@ function writeXlsxFile(arg1, arg2, arg3) {
69160
69220
  },
69161
69221
  toFile: function toFile(filePath) {
69162
69222
  return createReadableStream().then(function(readableStream) {
69163
- return pipe(readableStream, import_node_fs31.default.createWriteStream(filePath));
69223
+ return pipe(readableStream, import_node_fs32.default.createWriteStream(filePath));
69164
69224
  });
69165
69225
  }
69166
69226
  };
@@ -69185,8 +69245,8 @@ function pipe(readableStream, writableStream) {
69185
69245
 
69186
69246
  // bom-export.ts
69187
69247
  function bomExportPath(appId, format) {
69188
- const root3 = process.env.FLOLESS_HOME ?? (0, import_node_path27.join)((0, import_node_os16.homedir)(), ".floless");
69189
- return (0, import_node_path27.join)(root3, "exports", appId, `${appId}-bom.${format}`);
69248
+ const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path28.join)((0, import_node_os17.homedir)(), ".floless");
69249
+ return (0, import_node_path28.join)(root4, "exports", appId, `${appId}-bom.${format}`);
69190
69250
  }
69191
69251
  function csvField(v) {
69192
69252
  let s = String(v);
@@ -69231,11 +69291,11 @@ async function bomToXlsx(bom) {
69231
69291
  }
69232
69292
 
69233
69293
  // scene-bake.ts
69234
- var import_node_fs32 = require("node:fs");
69235
- var import_node_path28 = require("node:path");
69294
+ var import_node_fs33 = require("node:fs");
69295
+ var import_node_path29 = require("node:path");
69236
69296
  var import_yaml8 = __toESM(require_dist6(), 1);
69237
69297
  function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
69238
- const doc = (0, import_yaml8.parseDocument)((0, import_node_fs32.readFileSync)(sourcePath, "utf8"));
69298
+ const doc = (0, import_yaml8.parseDocument)((0, import_node_fs33.readFileSync)(sourcePath, "utf8"));
69239
69299
  if (doc.errors.length > 0) {
69240
69300
  throw new Error(`scene bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
69241
69301
  }
@@ -69244,10 +69304,10 @@ function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
69244
69304
  const idx = items.findIndex((it) => ((0, import_yaml8.isMap)(it) ? it.toJSON() : null)?.agent === agent);
69245
69305
  if (idx < 0) throw new Error(`no ${agent} render node to bake the scene into`);
69246
69306
  doc.setIn(["nodes", idx, "config", "scene"], scene);
69247
- (0, import_node_fs32.writeFileSync)(sourcePath, doc.toString());
69307
+ (0, import_node_fs33.writeFileSync)(sourcePath, doc.toString());
69248
69308
  }
69249
69309
  function bakeNodeConfigById(sourcePath, nodeId, patch2) {
69250
- const doc = (0, import_yaml8.parseDocument)((0, import_node_fs32.readFileSync)(sourcePath, "utf8"));
69310
+ const doc = (0, import_yaml8.parseDocument)((0, import_node_fs33.readFileSync)(sourcePath, "utf8"));
69251
69311
  if (doc.errors.length > 0) {
69252
69312
  throw new Error(`node bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
69253
69313
  }
@@ -69256,12 +69316,12 @@ function bakeNodeConfigById(sourcePath, nodeId, patch2) {
69256
69316
  const idx = items.findIndex((it) => ((0, import_yaml8.isMap)(it) ? it.toJSON() : null)?.id === nodeId);
69257
69317
  if (idx < 0) throw new Error(`no node with id "${nodeId}"`);
69258
69318
  for (const [key, value] of Object.entries(patch2)) doc.setIn(["nodes", idx, "config", key], value);
69259
- (0, import_node_fs32.writeFileSync)(sourcePath, doc.toString());
69319
+ (0, import_node_fs33.writeFileSync)(sourcePath, doc.toString());
69260
69320
  }
69261
69321
  function writeViewer3dApp(dir, appId, scene) {
69262
- (0, import_node_fs32.mkdirSync)(dir, { recursive: true });
69263
- const flo = (0, import_node_path28.join)(dir, `${appId}.flo`);
69264
- (0, import_node_fs32.writeFileSync)(flo, [
69322
+ (0, import_node_fs33.mkdirSync)(dir, { recursive: true });
69323
+ const flo = (0, import_node_path29.join)(dir, `${appId}.flo`);
69324
+ (0, import_node_fs33.writeFileSync)(flo, [
69265
69325
  `app: ${appId}`,
69266
69326
  "version: 0.1.0",
69267
69327
  "display-name: Steel 3D",
@@ -69282,9 +69342,9 @@ function writeViewer3dApp(dir, appId, scene) {
69282
69342
  return flo;
69283
69343
  }
69284
69344
  function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
69285
- (0, import_node_fs32.mkdirSync)(dir, { recursive: true });
69286
- const flo = (0, import_node_path28.join)(dir, `${appId}.flo`);
69287
- (0, import_node_fs32.writeFileSync)(flo, [
69345
+ (0, import_node_fs33.mkdirSync)(dir, { recursive: true });
69346
+ const flo = (0, import_node_path29.join)(dir, `${appId}.flo`);
69347
+ (0, import_node_fs33.writeFileSync)(flo, [
69288
69348
  `app: ${appId}`,
69289
69349
  "version: 0.1.0",
69290
69350
  "display-name: Steel to Tekla",
@@ -69388,9 +69448,9 @@ async function teklaVersionToBake() {
69388
69448
 
69389
69449
  // ifc-publication.ts
69390
69450
  var import_node_crypto17 = require("node:crypto");
69391
- var import_node_fs33 = require("node:fs");
69392
- var import_node_os17 = require("node:os");
69393
- var import_node_path29 = require("node:path");
69451
+ var import_node_fs34 = require("node:fs");
69452
+ var import_node_os18 = require("node:os");
69453
+ var import_node_path30 = require("node:path");
69394
69454
  var IfcPublicationError = class extends Error {
69395
69455
  constructor(message) {
69396
69456
  super(message);
@@ -69422,37 +69482,37 @@ function sameProof(path, expected) {
69422
69482
  return fileProofEquals(readFileProof(path), expected);
69423
69483
  }
69424
69484
  function syncFile2(path) {
69425
- const fd2 = (0, import_node_fs33.openSync)(path, "r+");
69485
+ const fd2 = (0, import_node_fs34.openSync)(path, "r+");
69426
69486
  try {
69427
- (0, import_node_fs33.fsyncSync)(fd2);
69487
+ (0, import_node_fs34.fsyncSync)(fd2);
69428
69488
  } finally {
69429
- (0, import_node_fs33.closeSync)(fd2);
69489
+ (0, import_node_fs34.closeSync)(fd2);
69430
69490
  }
69431
69491
  }
69432
69492
  function syncDirectory2(path) {
69433
69493
  try {
69434
- const fd2 = (0, import_node_fs33.openSync)(path, "r");
69494
+ const fd2 = (0, import_node_fs34.openSync)(path, "r");
69435
69495
  try {
69436
- (0, import_node_fs33.fsyncSync)(fd2);
69496
+ (0, import_node_fs34.fsyncSync)(fd2);
69437
69497
  } finally {
69438
- (0, import_node_fs33.closeSync)(fd2);
69498
+ (0, import_node_fs34.closeSync)(fd2);
69439
69499
  }
69440
69500
  } catch {
69441
69501
  }
69442
69502
  }
69443
69503
  function durableReplace2(path, bytes) {
69444
- const dir = (0, import_node_path29.dirname)(path);
69445
- (0, import_node_fs33.mkdirSync)(dir, { recursive: true });
69446
- const tmp = (0, import_node_path29.join)(dir, `.floless-tmp-recovery-${(0, import_node_crypto17.randomUUID)()}`);
69504
+ const dir = (0, import_node_path30.dirname)(path);
69505
+ (0, import_node_fs34.mkdirSync)(dir, { recursive: true });
69506
+ const tmp = (0, import_node_path30.join)(dir, `.floless-tmp-recovery-${(0, import_node_crypto17.randomUUID)()}`);
69447
69507
  try {
69448
- (0, import_node_fs33.writeFileSync)(tmp, bytes, { flag: "wx" });
69508
+ (0, import_node_fs34.writeFileSync)(tmp, bytes, { flag: "wx" });
69449
69509
  syncFile2(tmp);
69450
- (0, import_node_fs33.renameSync)(tmp, path);
69510
+ (0, import_node_fs34.renameSync)(tmp, path);
69451
69511
  syncFile2(path);
69452
69512
  syncDirectory2(dir);
69453
69513
  } finally {
69454
69514
  try {
69455
- (0, import_node_fs33.rmSync)(tmp, { force: true });
69515
+ (0, import_node_fs34.rmSync)(tmp, { force: true });
69456
69516
  } catch {
69457
69517
  }
69458
69518
  }
@@ -69464,26 +69524,26 @@ function plainIfcFilename(name) {
69464
69524
  return isPortablePlainFilename(name) && name.toLowerCase().endsWith(".ifc") && !name.toLowerCase().startsWith(".floless-");
69465
69525
  }
69466
69526
  function canonicalPath(path) {
69467
- return (0, import_node_path29.resolve)(path);
69527
+ return (0, import_node_path30.resolve)(path);
69468
69528
  }
69469
69529
  function validateRequestPaths(tempPath, finalPath) {
69470
69530
  const final = canonicalPath(finalPath);
69471
69531
  const temp = canonicalPath(tempPath);
69472
- const dir = (0, import_node_path29.dirname)(final);
69473
- if ((0, import_node_path29.dirname)(temp) !== dir) throw new IfcPublicationError("IFC temp and final paths must share one directory.");
69474
- if (!plainIfcFilename((0, import_node_path29.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
69475
- if (!TEMP_RE.test((0, import_node_path29.basename)(temp))) throw new IfcPublicationError("IFC temp filename is not request-scoped.");
69532
+ const dir = (0, import_node_path30.dirname)(final);
69533
+ if ((0, import_node_path30.dirname)(temp) !== dir) throw new IfcPublicationError("IFC temp and final paths must share one directory.");
69534
+ if (!plainIfcFilename((0, import_node_path30.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
69535
+ if (!TEMP_RE.test((0, import_node_path30.basename)(temp))) throw new IfcPublicationError("IFC temp filename is not request-scoped.");
69476
69536
  return { dir, temp, final };
69477
69537
  }
69478
69538
  function requestIfcTempPath(finalPath) {
69479
69539
  const final = canonicalPath(finalPath);
69480
- if (!plainIfcFilename((0, import_node_path29.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
69481
- (0, import_node_fs33.mkdirSync)((0, import_node_path29.dirname)(final), { recursive: true });
69482
- return (0, import_node_path29.join)((0, import_node_path29.dirname)(final), `.floless-tmp-ifc-${(0, import_node_crypto17.randomUUID)()}.ifc`);
69540
+ if (!plainIfcFilename((0, import_node_path30.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
69541
+ (0, import_node_fs34.mkdirSync)((0, import_node_path30.dirname)(final), { recursive: true });
69542
+ return (0, import_node_path30.join)((0, import_node_path30.dirname)(final), `.floless-tmp-ifc-${(0, import_node_crypto17.randomUUID)()}.ifc`);
69483
69543
  }
69484
69544
  function validateIfc(path) {
69485
- if (!(0, import_node_fs33.existsSync)(path) || (0, import_node_fs33.statSync)(path).size === 0) throw new IfcPublicationError("the IFC export produced no file");
69486
- const bytes = (0, import_node_fs33.readFileSync)(path);
69545
+ if (!(0, import_node_fs34.existsSync)(path) || (0, import_node_fs34.statSync)(path).size === 0) throw new IfcPublicationError("the IFC export produced no file");
69546
+ const bytes = (0, import_node_fs34.readFileSync)(path);
69487
69547
  const prefix = bytes.subarray(0, Math.min(bytes.length, 128)).toString("utf8");
69488
69548
  if (!prefix.includes("ISO-10303-21")) throw new IfcPublicationError("the IFC export did not produce a valid STEP envelope");
69489
69549
  return { bytes, proof: proof2(bytes) };
@@ -69496,21 +69556,21 @@ function metadataEqual(a, b) {
69496
69556
  function writePhase(txnDir, journal) {
69497
69557
  const index = PHASES.indexOf(journal.phase);
69498
69558
  if (index < 0) throw new IfcPublicationError(`unknown IFC publication phase "${journal.phase}".`);
69499
- const destination = (0, import_node_path29.join)(txnDir, `${String(index).padStart(3, "0")}-${journal.phase}.json`);
69500
- if ((0, import_node_fs33.existsSync)(destination)) throw new IfcPublicationError(`IFC publication phase "${journal.phase}" already exists.`);
69501
- const temp = (0, import_node_path29.join)(txnDir, `.phase-${(0, import_node_crypto17.randomUUID)()}.tmp`);
69559
+ const destination = (0, import_node_path30.join)(txnDir, `${String(index).padStart(3, "0")}-${journal.phase}.json`);
69560
+ if ((0, import_node_fs34.existsSync)(destination)) throw new IfcPublicationError(`IFC publication phase "${journal.phase}" already exists.`);
69561
+ const temp = (0, import_node_path30.join)(txnDir, `.phase-${(0, import_node_crypto17.randomUUID)()}.tmp`);
69502
69562
  const bytes = Buffer.from(`${JSON.stringify(journal, null, 2)}
69503
69563
  `, "utf8");
69504
69564
  try {
69505
- (0, import_node_fs33.writeFileSync)(temp, bytes, { flag: "wx" });
69565
+ (0, import_node_fs34.writeFileSync)(temp, bytes, { flag: "wx" });
69506
69566
  syncFile2(temp);
69507
- (0, import_node_fs33.renameSync)(temp, destination);
69567
+ (0, import_node_fs34.renameSync)(temp, destination);
69508
69568
  syncFile2(destination);
69509
69569
  syncDirectory2(txnDir);
69510
- syncDirectory2((0, import_node_path29.dirname)(txnDir));
69570
+ syncDirectory2((0, import_node_path30.dirname)(txnDir));
69511
69571
  } finally {
69512
69572
  try {
69513
- (0, import_node_fs33.rmSync)(temp, { force: true });
69573
+ (0, import_node_fs34.rmSync)(temp, { force: true });
69514
69574
  } catch {
69515
69575
  }
69516
69576
  }
@@ -69530,12 +69590,12 @@ function validateJournal(raw, txnDir, expectedTxnId) {
69530
69590
  const resource = j.resource;
69531
69591
  if (!validResource(resource)) throw new IfcPublicationError("IFC journal resource is invalid.");
69532
69592
  const exportDir = canonicalPath(String(j.exportDir));
69533
- const actualDir = canonicalPath((0, import_node_path29.dirname)(txnDir));
69593
+ const actualDir = canonicalPath((0, import_node_path30.dirname)(txnDir));
69534
69594
  if (exportDir !== actualDir) throw new IfcPublicationError("IFC journal export directory is not canonical.");
69535
69595
  const finalPath = canonicalPath(String(j.finalPath));
69536
69596
  const tempPath = canonicalPath(String(j.tempPath));
69537
69597
  const backupPath = canonicalPath(String(j.backupPath));
69538
- if ((0, import_node_path29.dirname)(finalPath) !== exportDir || (0, import_node_path29.dirname)(tempPath) !== exportDir || (0, import_node_path29.dirname)(backupPath) !== exportDir || !plainIfcFilename((0, import_node_path29.basename)(finalPath)) || !TEMP_RE.test((0, import_node_path29.basename)(tempPath)) || !BACKUP_RE.test((0, import_node_path29.basename)(backupPath))) throw new IfcPublicationError("IFC journal contains an unsafe artifact path.");
69598
+ if ((0, import_node_path30.dirname)(finalPath) !== exportDir || (0, import_node_path30.dirname)(tempPath) !== exportDir || (0, import_node_path30.dirname)(backupPath) !== exportDir || !plainIfcFilename((0, import_node_path30.basename)(finalPath)) || !TEMP_RE.test((0, import_node_path30.basename)(tempPath)) || !BACKUP_RE.test((0, import_node_path30.basename)(backupPath))) throw new IfcPublicationError("IFC journal contains an unsafe artifact path.");
69539
69599
  const journal = {
69540
69600
  version: 1,
69541
69601
  txnId: expectedTxnId,
@@ -69555,7 +69615,7 @@ function validateJournal(raw, txnDir, expectedTxnId) {
69555
69615
  }
69556
69616
  if (journal.mode === "artifact-with-receipt") {
69557
69617
  const indexPath = canonicalPath(String(j.indexPath));
69558
- if ((0, import_node_path29.dirname)(indexPath) !== exportDir || (0, import_node_path29.basename)(indexPath) !== "index.json") {
69618
+ if ((0, import_node_path30.dirname)(indexPath) !== exportDir || (0, import_node_path30.basename)(indexPath) !== "index.json") {
69559
69619
  throw new IfcPublicationError("IFC journal receipt index path is unsafe.");
69560
69620
  }
69561
69621
  journal.indexPath = indexPath;
@@ -69573,13 +69633,13 @@ function validateJournal(raw, txnDir, expectedTxnId) {
69573
69633
  return journal;
69574
69634
  }
69575
69635
  function loadJournal(txnDir) {
69576
- const match = (0, import_node_path29.basename)(txnDir).match(ACTIVE_RE);
69577
- if (!match) throw new IfcPublicationError(`unsafe IFC transaction directory "${(0, import_node_path29.basename)(txnDir)}".`);
69636
+ const match = (0, import_node_path30.basename)(txnDir).match(ACTIVE_RE);
69637
+ if (!match) throw new IfcPublicationError(`unsafe IFC transaction directory "${(0, import_node_path30.basename)(txnDir)}".`);
69578
69638
  const txnId = match[1];
69579
- const entries = (0, import_node_fs33.readdirSync)(txnDir, { withFileTypes: true });
69580
- if (!entries.length) return null;
69581
- const phaseFiles = entries.filter((entry2) => entry2.isFile() && PHASE_RE.test(entry2.name)).sort((a, b) => a.name.localeCompare(b.name));
69582
- const unknown = entries.filter((entry2) => !(entry2.isFile() && (PHASE_RE.test(entry2.name) || /^\.phase-[a-f0-9-]+\.tmp$/i.test(entry2.name))));
69639
+ const entries2 = (0, import_node_fs34.readdirSync)(txnDir, { withFileTypes: true });
69640
+ if (!entries2.length) return null;
69641
+ const phaseFiles = entries2.filter((entry2) => entry2.isFile() && PHASE_RE.test(entry2.name)).sort((a, b) => a.name.localeCompare(b.name));
69642
+ const unknown = entries2.filter((entry2) => !(entry2.isFile() && (PHASE_RE.test(entry2.name) || /^\.phase-[a-f0-9-]+\.tmp$/i.test(entry2.name))));
69583
69643
  if (unknown.length) throw new IfcPublicationError("IFC transaction directory contains unexpected entries.");
69584
69644
  if (!phaseFiles.length) return null;
69585
69645
  let first = null;
@@ -69590,11 +69650,11 @@ function loadJournal(txnDir) {
69590
69650
  const declaredIndex = Number(phaseMatch[1]);
69591
69651
  const declaredPhase = phaseMatch[2];
69592
69652
  if (declaredIndex !== index || PHASES[index] !== declaredPhase) break;
69593
- const path = (0, import_node_path29.join)(txnDir, entry2.name);
69594
- if ((0, import_node_fs33.statSync)(path).size > MAX_PHASE_BYTES) break;
69653
+ const path = (0, import_node_path30.join)(txnDir, entry2.name);
69654
+ if ((0, import_node_fs34.statSync)(path).size > MAX_PHASE_BYTES) break;
69595
69655
  let parsed;
69596
69656
  try {
69597
- parsed = JSON.parse((0, import_node_fs33.readFileSync)(path, "utf8"));
69657
+ parsed = JSON.parse((0, import_node_fs34.readFileSync)(path, "utf8"));
69598
69658
  } catch {
69599
69659
  break;
69600
69660
  }
@@ -69621,8 +69681,8 @@ function restoreIndex(journal) {
69621
69681
  if (journal.priorIndex.exists) {
69622
69682
  durableReplace2(indexPath, Buffer.from(journal.priorIndexBase64, "base64"));
69623
69683
  } else {
69624
- (0, import_node_fs33.rmSync)(indexPath, { force: true });
69625
- syncDirectory2((0, import_node_path29.dirname)(indexPath));
69684
+ (0, import_node_fs34.rmSync)(indexPath, { force: true });
69685
+ syncDirectory2((0, import_node_path30.dirname)(indexPath));
69626
69686
  }
69627
69687
  if (!sameProof(indexPath, journal.priorIndex)) {
69628
69688
  throw new IfcPublicationError("receipt index restore did not match its recorded proof.");
@@ -69637,14 +69697,14 @@ function restoreArtifact(journal) {
69637
69697
  if (!fileProofEquals(backup, journal.priorArtifact)) {
69638
69698
  throw new IfcPublicationError("IFC backup does not match the recorded prior artifact.");
69639
69699
  }
69640
- (0, import_node_fs33.rmSync)(journal.backupPath, { force: true });
69700
+ (0, import_node_fs34.rmSync)(journal.backupPath, { force: true });
69641
69701
  }
69642
69702
  } else if (!final.exists || fileProofEquals(final, journal.newArtifact)) {
69643
69703
  if (!fileProofEquals(backup, journal.priorArtifact)) {
69644
69704
  throw new IfcPublicationError("IFC prior artifact cannot be proven for rollback.");
69645
69705
  }
69646
- if (final.exists) (0, import_node_fs33.rmSync)(journal.finalPath, { force: true });
69647
- (0, import_node_fs33.renameSync)(journal.backupPath, journal.finalPath);
69706
+ if (final.exists) (0, import_node_fs34.rmSync)(journal.finalPath, { force: true });
69707
+ (0, import_node_fs34.renameSync)(journal.backupPath, journal.finalPath);
69648
69708
  syncFile2(journal.finalPath);
69649
69709
  } else {
69650
69710
  throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
@@ -69657,25 +69717,25 @@ function restoreArtifact(journal) {
69657
69717
  if (!fileProofEquals(final, journal.newArtifact)) {
69658
69718
  throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
69659
69719
  }
69660
- (0, import_node_fs33.rmSync)(journal.finalPath, { force: true });
69720
+ (0, import_node_fs34.rmSync)(journal.finalPath, { force: true });
69661
69721
  }
69662
69722
  if (backup.exists) throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
69663
69723
  }
69664
- if ((0, import_node_fs33.existsSync)(journal.tempPath)) {
69724
+ if ((0, import_node_fs34.existsSync)(journal.tempPath)) {
69665
69725
  if (!sameProof(journal.tempPath, journal.newArtifact)) {
69666
69726
  throw new IfcPublicationError("IFC temp artifact does not match its recorded proof.");
69667
69727
  }
69668
- (0, import_node_fs33.rmSync)(journal.tempPath, { force: true });
69728
+ (0, import_node_fs34.rmSync)(journal.tempPath, { force: true });
69669
69729
  }
69670
69730
  syncDirectory2(journal.exportDir);
69671
69731
  }
69672
69732
  function retireTransaction(txnDir) {
69673
- const match = (0, import_node_path29.basename)(txnDir).match(ACTIVE_RE);
69733
+ const match = (0, import_node_path30.basename)(txnDir).match(ACTIVE_RE);
69674
69734
  if (!match) throw new IfcPublicationError("cannot retire an unsafe IFC transaction directory.");
69675
- const cleanupDir = (0, import_node_path29.join)((0, import_node_path29.dirname)(txnDir), `.floless-cleanup-ifc-${match[1]}`);
69676
- if ((0, import_node_fs33.existsSync)(cleanupDir)) throw new IfcPublicationError("IFC cleanup directory already exists.");
69677
- (0, import_node_fs33.renameSync)(txnDir, cleanupDir);
69678
- syncDirectory2((0, import_node_path29.dirname)(txnDir));
69735
+ const cleanupDir = (0, import_node_path30.join)((0, import_node_path30.dirname)(txnDir), `.floless-cleanup-ifc-${match[1]}`);
69736
+ if ((0, import_node_fs34.existsSync)(cleanupDir)) throw new IfcPublicationError("IFC cleanup directory already exists.");
69737
+ (0, import_node_fs34.renameSync)(txnDir, cleanupDir);
69738
+ syncDirectory2((0, import_node_path30.dirname)(txnDir));
69679
69739
  return cleanupDir;
69680
69740
  }
69681
69741
  function finishCommitted(txnDir, journal, allowMissingBackup) {
@@ -69691,7 +69751,7 @@ function finishCommitted(txnDir, journal, allowMissingBackup) {
69691
69751
  if (!fileProofEquals(backup, journal.priorArtifact)) {
69692
69752
  throw new IfcPublicationError("committed IFC backup does not match the recorded prior artifact.");
69693
69753
  }
69694
- (0, import_node_fs33.rmSync)(journal.backupPath, { force: true });
69754
+ (0, import_node_fs34.rmSync)(journal.backupPath, { force: true });
69695
69755
  syncDirectory2(journal.exportDir);
69696
69756
  } else if (!allowMissingBackup) {
69697
69757
  throw new IfcPublicationError("committed IFC backup disappeared before verified cleanup.");
@@ -69700,18 +69760,18 @@ function finishCommitted(txnDir, journal, allowMissingBackup) {
69700
69760
  throw new IfcPublicationError("unexpected committed IFC backup exists for a no-prior transaction.");
69701
69761
  }
69702
69762
  const cleanupDir = retireTransaction(txnDir);
69703
- (0, import_node_fs33.rmSync)(cleanupDir, { recursive: true, force: true });
69763
+ (0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
69704
69764
  syncDirectory2(journal.exportDir);
69705
69765
  }
69706
69766
  function rollbackTransaction(txnDir, journal) {
69707
69767
  restoreArtifact(journal);
69708
69768
  restoreIndex(journal);
69709
69769
  const cleanupDir = retireTransaction(txnDir);
69710
- (0, import_node_fs33.rmSync)(cleanupDir, { recursive: true, force: true });
69770
+ (0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
69711
69771
  syncDirectory2(journal.exportDir);
69712
69772
  }
69713
69773
  function safeTransactionDirectory(path) {
69714
- const st = (0, import_node_fs33.lstatSync)(path);
69774
+ const st = (0, import_node_fs34.lstatSync)(path);
69715
69775
  if (!st.isDirectory() || st.isSymbolicLink()) {
69716
69776
  throw new IfcPublicationError(`IFC transaction path is not a plain directory: ${path}`);
69717
69777
  }
@@ -69721,7 +69781,7 @@ async function recoverActive(txnDir, expected) {
69721
69781
  const journal = loadJournal(txnDir);
69722
69782
  if (!journal) {
69723
69783
  const cleanupDir = retireTransaction(txnDir);
69724
- (0, import_node_fs33.rmSync)(cleanupDir, { recursive: true, force: true });
69784
+ (0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
69725
69785
  return;
69726
69786
  }
69727
69787
  if (expected && (journal.resource.kind !== expected.kind || journal.resource.key !== expected.key)) {
@@ -69734,18 +69794,18 @@ async function recoverActive(txnDir, expected) {
69734
69794
  }
69735
69795
  async function recoverIfcPublicationsInDirectory(exportDir, expected) {
69736
69796
  const dir = canonicalPath(exportDir);
69737
- if (!(0, import_node_fs33.existsSync)(dir)) return [];
69797
+ if (!(0, import_node_fs34.existsSync)(dir)) return [];
69738
69798
  safeTransactionDirectory(dir);
69739
- const entries = (0, import_node_fs33.readdirSync)(dir, { withFileTypes: true }).filter((entry2) => ACTIVE_RE.test(entry2.name) || CLEANUP_RE.test(entry2.name));
69740
- if (entries.length > MAX_TRANSACTIONS) {
69741
- throw new IfcPublicationError(`IFC recovery refused ${entries.length} transaction directories (limit ${MAX_TRANSACTIONS}).`);
69799
+ const entries2 = (0, import_node_fs34.readdirSync)(dir, { withFileTypes: true }).filter((entry2) => ACTIVE_RE.test(entry2.name) || CLEANUP_RE.test(entry2.name));
69800
+ if (entries2.length > MAX_TRANSACTIONS) {
69801
+ throw new IfcPublicationError(`IFC recovery refused ${entries2.length} transaction directories (limit ${MAX_TRANSACTIONS}).`);
69742
69802
  }
69743
69803
  const recovered = [];
69744
- for (const entry2 of entries) {
69745
- const path = (0, import_node_path29.join)(dir, entry2.name);
69804
+ for (const entry2 of entries2) {
69805
+ const path = (0, import_node_path30.join)(dir, entry2.name);
69746
69806
  safeTransactionDirectory(path);
69747
69807
  if (CLEANUP_RE.test(entry2.name)) {
69748
- (0, import_node_fs33.rmSync)(path, { recursive: true, force: true });
69808
+ (0, import_node_fs34.rmSync)(path, { recursive: true, force: true });
69749
69809
  syncDirectory2(dir);
69750
69810
  recovered.push(entry2.name);
69751
69811
  continue;
@@ -69757,32 +69817,32 @@ async function recoverIfcPublicationsInDirectory(exportDir, expected) {
69757
69817
  }
69758
69818
  async function recoverAllIfcPublications() {
69759
69819
  const recovered = [];
69760
- const rootHome = process.env.FLOLESS_HOME ?? (0, import_node_path29.join)((0, import_node_os17.homedir)(), ".floless");
69761
- const projectsRoot2 = (0, import_node_path29.join)(rootHome, "projects");
69762
- if ((0, import_node_fs33.existsSync)(projectsRoot2)) {
69820
+ const rootHome = process.env.FLOLESS_HOME ?? (0, import_node_path30.join)((0, import_node_os18.homedir)(), ".floless");
69821
+ const projectsRoot2 = (0, import_node_path30.join)(rootHome, "projects");
69822
+ if ((0, import_node_fs34.existsSync)(projectsRoot2)) {
69763
69823
  safeTransactionDirectory(projectsRoot2);
69764
- for (const entry2 of (0, import_node_fs33.readdirSync)(projectsRoot2, { withFileTypes: true })) {
69824
+ for (const entry2 of (0, import_node_fs34.readdirSync)(projectsRoot2, { withFileTypes: true })) {
69765
69825
  if (entry2.name.startsWith(".")) continue;
69766
69826
  if (entry2.isSymbolicLink()) throw new IfcPublicationError(`project recovery root is a link: ${entry2.name}`);
69767
69827
  if (!entry2.isDirectory() || !/^[a-z0-9][a-z0-9-]*$/.test(entry2.name)) continue;
69768
- const projectPath = (0, import_node_path29.join)(projectsRoot2, entry2.name);
69828
+ const projectPath = (0, import_node_path30.join)(projectsRoot2, entry2.name);
69769
69829
  safeTransactionDirectory(projectPath);
69770
69830
  const dir = projectExportsDir(entry2.name);
69771
69831
  const names = await recoverIfcPublicationsInDirectory(dir, { kind: "project", key: entry2.name });
69772
69832
  recovered.push(...names.map((name) => `${entry2.name}/${name}`));
69773
69833
  }
69774
69834
  }
69775
- const root3 = (0, import_node_path29.join)(rootHome, "exports");
69776
- if ((0, import_node_fs33.existsSync)(root3)) {
69777
- safeTransactionDirectory(root3);
69778
- for (const entry2 of (0, import_node_fs33.readdirSync)(root3, { withFileTypes: true })) {
69835
+ const root4 = (0, import_node_path30.join)(rootHome, "exports");
69836
+ if ((0, import_node_fs34.existsSync)(root4)) {
69837
+ safeTransactionDirectory(root4);
69838
+ for (const entry2 of (0, import_node_fs34.readdirSync)(root4, { withFileTypes: true })) {
69779
69839
  if (entry2.name.startsWith(".")) continue;
69780
69840
  if (entry2.isSymbolicLink()) throw new IfcPublicationError(`workflow recovery root is a link: ${entry2.name}`);
69781
69841
  if (!entry2.isDirectory()) continue;
69782
69842
  if (!/^[A-Za-z0-9._-]+$/.test(entry2.name)) continue;
69783
- safeTransactionDirectory((0, import_node_path29.join)(root3, entry2.name));
69843
+ safeTransactionDirectory((0, import_node_path30.join)(root4, entry2.name));
69784
69844
  const names = await recoverIfcPublicationsInDirectory(
69785
- (0, import_node_path29.join)(root3, entry2.name),
69845
+ (0, import_node_path30.join)(root4, entry2.name),
69786
69846
  { kind: "app", key: entry2.name }
69787
69847
  );
69788
69848
  recovered.push(...names.map((name) => `${entry2.name}/${name}`));
@@ -69792,8 +69852,8 @@ async function recoverAllIfcPublications() {
69792
69852
  }
69793
69853
  function assertReceiptOptions(receipt, resource, exportDir, finalPath, artifact) {
69794
69854
  const transition = receipt.transition;
69795
- if (resource.kind !== "project" || transition.projectId !== resource.key || transition.next.kind !== "ifc" || transition.next.filename !== (0, import_node_path29.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.");
69796
- if ((0, import_node_path29.dirname)(canonicalPath(transition.indexPath)) !== exportDir || (0, import_node_path29.basename)(transition.indexPath) !== "index.json") throw new IfcPublicationError("project receipt index is outside the IFC export directory.");
69855
+ if (resource.kind !== "project" || transition.projectId !== resource.key || transition.next.kind !== "ifc" || transition.next.filename !== (0, import_node_path30.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.");
69856
+ if ((0, import_node_path30.dirname)(canonicalPath(transition.indexPath)) !== exportDir || (0, import_node_path30.basename)(transition.indexPath) !== "index.json") throw new IfcPublicationError("project receipt index is outside the IFC export directory.");
69797
69857
  const beforeSnapshot = transition.beforeBytesBase64 === null ? null : Buffer.from(transition.beforeBytesBase64, "base64");
69798
69858
  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.");
69799
69859
  if (!fileProofEquals(readFileProof(transition.indexPath), transition.before)) {
@@ -69806,7 +69866,7 @@ function promiseLike(value) {
69806
69866
  async function publishIfcAtomically(tempPath, finalPath, options) {
69807
69867
  if (!options || !validResource(options.resource)) throw new IfcPublicationError("IFC publication resource is invalid.");
69808
69868
  const paths = validateRequestPaths(tempPath, finalPath);
69809
- const tempStat = (0, import_node_fs33.lstatSync)(paths.temp);
69869
+ const tempStat = (0, import_node_fs34.lstatSync)(paths.temp);
69810
69870
  if (!tempStat.isFile()) throw new IfcPublicationError("the IFC to publish is not a regular file.");
69811
69871
  const validated = validateIfc(paths.temp);
69812
69872
  if (options.expectedContentSha256 !== void 0 && validated.proof.sha256 !== options.expectedContentSha256) {
@@ -69819,8 +69879,8 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69819
69879
  return withLifecycleLock(options.resource.kind, options.resource.key, async () => {
69820
69880
  await recoverIfcPublicationsInDirectory(paths.dir, options.resource);
69821
69881
  const txnId = (0, import_node_crypto17.randomUUID)();
69822
- const txnDir = (0, import_node_path29.join)(paths.dir, `.floless-txn-ifc-${txnId}`);
69823
- const backupPath = (0, import_node_path29.join)(paths.dir, `.floless-backup-ifc-${txnId}.ifc`);
69882
+ const txnDir = (0, import_node_path30.join)(paths.dir, `.floless-txn-ifc-${txnId}`);
69883
+ const backupPath = (0, import_node_path30.join)(paths.dir, `.floless-backup-ifc-${txnId}.ifc`);
69824
69884
  const priorArtifact = readFileProof(paths.final);
69825
69885
  const transition = options.receipt?.transition;
69826
69886
  const base = {
@@ -69844,7 +69904,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69844
69904
  };
69845
69905
  let journal = { ...base, phase: "prepared" };
69846
69906
  let committed = false;
69847
- (0, import_node_fs33.mkdirSync)(txnDir);
69907
+ (0, import_node_fs34.mkdirSync)(txnDir);
69848
69908
  syncDirectory2(paths.dir);
69849
69909
  const hit = (point) => {
69850
69910
  options.fault?.(point);
@@ -69860,11 +69920,11 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69860
69920
  phase("prepared");
69861
69921
  phase("backing-up");
69862
69922
  if (priorArtifact.exists) {
69863
- (0, import_node_fs33.renameSync)(paths.final, backupPath);
69923
+ (0, import_node_fs34.renameSync)(paths.final, backupPath);
69864
69924
  syncDirectory2(paths.dir);
69865
69925
  }
69866
69926
  phase("promoting");
69867
- (0, import_node_fs33.renameSync)(paths.temp, paths.final);
69927
+ (0, import_node_fs34.renameSync)(paths.temp, paths.final);
69868
69928
  syncFile2(paths.final);
69869
69929
  syncDirectory2(paths.dir);
69870
69930
  if (!sameProof(paths.final, validated.proof)) {
@@ -69893,7 +69953,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69893
69953
  if (!fileProofEquals(backup, priorArtifact)) {
69894
69954
  throw new IfcPublicationError("IFC backup did not match the recorded prior artifact before cleanup.");
69895
69955
  }
69896
- (0, import_node_fs33.rmSync)(backupPath, { force: true });
69956
+ (0, import_node_fs34.rmSync)(backupPath, { force: true });
69897
69957
  syncDirectory2(paths.dir);
69898
69958
  } else if (backup.exists) {
69899
69959
  throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
@@ -69903,7 +69963,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69903
69963
  const cleanupDir = retireTransaction(txnDir);
69904
69964
  hit("after-retire");
69905
69965
  hit("before-cleanup-remove");
69906
- (0, import_node_fs33.rmSync)(cleanupDir, { recursive: true, force: true });
69966
+ (0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
69907
69967
  syncDirectory2(paths.dir);
69908
69968
  return { bytes: validated.bytes, cleanupPending: false };
69909
69969
  } catch (error) {
@@ -69946,14 +70006,14 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69946
70006
  });
69947
70007
  }
69948
70008
  function cleanupIfcTemp(path) {
69949
- if (!TEMP_RE.test((0, import_node_path29.basename)(path))) return;
70009
+ if (!TEMP_RE.test((0, import_node_path30.basename)(path))) return;
69950
70010
  const canonical = canonicalPath(path);
69951
- const dir = (0, import_node_path29.dirname)(canonical);
69952
- if ((0, import_node_fs33.existsSync)(dir)) {
69953
- for (const entry2 of (0, import_node_fs33.readdirSync)(dir, { withFileTypes: true })) {
70011
+ const dir = (0, import_node_path30.dirname)(canonical);
70012
+ if ((0, import_node_fs34.existsSync)(dir)) {
70013
+ for (const entry2 of (0, import_node_fs34.readdirSync)(dir, { withFileTypes: true })) {
69954
70014
  if (!entry2.isDirectory() || !ACTIVE_RE.test(entry2.name)) continue;
69955
70015
  try {
69956
- const journal = loadJournal((0, import_node_path29.join)(dir, entry2.name));
70016
+ const journal = loadJournal((0, import_node_path30.join)(dir, entry2.name));
69957
70017
  if (!journal || journal.tempPath === canonical) return;
69958
70018
  } catch {
69959
70019
  return;
@@ -69961,15 +70021,15 @@ function cleanupIfcTemp(path) {
69961
70021
  }
69962
70022
  }
69963
70023
  try {
69964
- (0, import_node_fs33.rmSync)(path, { force: true });
70024
+ (0, import_node_fs34.rmSync)(path, { force: true });
69965
70025
  } catch {
69966
70026
  }
69967
70027
  }
69968
70028
 
69969
70029
  // export-companion.ts
69970
70030
  var import_node_crypto18 = require("node:crypto");
69971
- var import_node_fs34 = require("node:fs");
69972
- var import_node_path30 = require("node:path");
70031
+ var import_node_fs35 = require("node:fs");
70032
+ var import_node_path31 = require("node:path");
69973
70033
  var PREFIX = "floless-export-tmp-";
69974
70034
  var LEASE = ".floless-export-lease.json";
69975
70035
  var STALE_MS2 = 30 * 6e4;
@@ -69983,70 +70043,70 @@ function processAlive2(pid) {
69983
70043
  }
69984
70044
  }
69985
70045
  function defaultAppsRoot() {
69986
- return (0, import_node_path30.dirname)(appPath("placeholder"));
70046
+ return (0, import_node_path31.dirname)(appPath("placeholder"));
69987
70047
  }
69988
70048
  function assertScratchPath(path, appsRoot) {
69989
- const root3 = (0, import_node_path30.resolve)(appsRoot);
69990
- const target = (0, import_node_path30.resolve)(path);
69991
- if ((0, import_node_path30.dirname)(target) !== root3 || !(0, import_node_path30.basename)(target).startsWith(PREFIX)) {
70049
+ const root4 = (0, import_node_path31.resolve)(appsRoot);
70050
+ const target = (0, import_node_path31.resolve)(path);
70051
+ if ((0, import_node_path31.dirname)(target) !== root4 || !(0, import_node_path31.basename)(target).startsWith(PREFIX)) {
69992
70052
  throw new Error(`refusing to remove a non-export companion path: ${target}`);
69993
70053
  }
69994
70054
  }
69995
70055
  function removeScratch(path, appsRoot) {
69996
70056
  assertScratchPath(path, appsRoot);
69997
- (0, import_node_fs34.rmSync)(path, { recursive: true, force: true });
70057
+ (0, import_node_fs35.rmSync)(path, { recursive: true, force: true });
69998
70058
  }
69999
70059
  function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
70000
70060
  const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
70001
70061
  const token = (0, import_node_crypto18.randomUUID)();
70002
70062
  const id = `${PREFIX}${safeOwner}-${sink}-${token}`;
70003
- const root3 = (0, import_node_path30.resolve)(appsRoot);
70004
- const path = (0, import_node_path30.resolve)(root3, id);
70063
+ const root4 = (0, import_node_path31.resolve)(appsRoot);
70064
+ const path = (0, import_node_path31.resolve)(root4, id);
70005
70065
  const lease = { pid: process.pid, token, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
70006
70066
  return {
70007
70067
  id,
70008
70068
  path,
70009
70069
  token,
70010
70070
  cleanup: () => {
70011
- if (!(0, import_node_fs34.existsSync)(path)) return;
70071
+ if (!(0, import_node_fs35.existsSync)(path)) return;
70012
70072
  let current = null;
70013
70073
  try {
70014
- current = JSON.parse((0, import_node_fs34.readFileSync)((0, import_node_path30.resolve)(path, LEASE), "utf8"));
70074
+ current = JSON.parse((0, import_node_fs35.readFileSync)((0, import_node_path31.resolve)(path, LEASE), "utf8"));
70015
70075
  } catch {
70016
70076
  }
70017
70077
  if (current && current.token !== token) throw new Error(`export companion lease changed for ${id}`);
70018
- removeScratch(path, root3);
70078
+ removeScratch(path, root4);
70019
70079
  }
70020
70080
  };
70021
70081
  }
70022
70082
  function stampExportCompanionLease(companion) {
70023
- (0, import_node_fs34.writeFileSync)((0, import_node_path30.resolve)(companion.path, LEASE), JSON.stringify({
70083
+ (0, import_node_fs35.writeFileSync)((0, import_node_path31.resolve)(companion.path, LEASE), JSON.stringify({
70024
70084
  pid: process.pid,
70025
70085
  token: companion.token,
70026
70086
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
70027
70087
  }));
70028
70088
  }
70029
70089
  function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
70030
- const root3 = (0, import_node_path30.resolve)(appsRoot);
70031
- if (!(0, import_node_fs34.existsSync)(root3)) return [];
70090
+ const root4 = (0, import_node_path31.resolve)(appsRoot);
70091
+ if (!(0, import_node_fs35.existsSync)(root4)) return [];
70032
70092
  const removed = [];
70033
- for (const entry2 of (0, import_node_fs34.readdirSync)(root3, { withFileTypes: true })) {
70093
+ for (const entry2 of (0, import_node_fs35.readdirSync)(root4, { withFileTypes: true })) {
70034
70094
  if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX)) continue;
70035
- const path = (0, import_node_path30.resolve)(root3, entry2.name);
70095
+ const path = (0, import_node_path31.resolve)(root4, entry2.name);
70036
70096
  let lease = null;
70037
70097
  try {
70038
- lease = JSON.parse((0, import_node_fs34.readFileSync)((0, import_node_path30.resolve)(path, LEASE), "utf8"));
70098
+ lease = JSON.parse((0, import_node_fs35.readFileSync)((0, import_node_path31.resolve)(path, LEASE), "utf8"));
70039
70099
  } catch {
70040
70100
  }
70041
70101
  let created;
70042
70102
  try {
70043
- created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs34.statSync)(path).mtimeMs;
70103
+ created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs35.statSync)(path).mtimeMs;
70044
70104
  } catch {
70045
70105
  continue;
70046
70106
  }
70047
70107
  if (Number.isFinite(created) && now - created < STALE_MS2) continue;
70048
70108
  if (lease && processAlive2(lease.pid)) continue;
70049
- removeScratch(path, root3);
70109
+ removeScratch(path, root4);
70050
70110
  removed.push(entry2.name);
70051
70111
  }
70052
70112
  return removed;
@@ -70153,14 +70213,14 @@ async function teklaReadiness(deps = DEFAULT_DEPS) {
70153
70213
  }
70154
70214
 
70155
70215
  // render-readiness.ts
70156
- var import_node_fs35 = require("node:fs");
70157
- var import_node_path31 = require("node:path");
70158
- var import_node_os18 = require("node:os");
70216
+ var import_node_fs36 = require("node:fs");
70217
+ var import_node_path32 = require("node:path");
70218
+ var import_node_os19 = require("node:os");
70159
70219
  var RENDER_AWARE_FLOOR = "0.103.0";
70160
70220
  var RENDER_AGENT_ID = "blender";
70161
70221
  function isFile(path) {
70162
70222
  try {
70163
- return (0, import_node_fs35.existsSync)(path) && (0, import_node_fs35.statSync)(path).isFile();
70223
+ return (0, import_node_fs36.existsSync)(path) && (0, import_node_fs36.statSync)(path).isFile();
70164
70224
  } catch {
70165
70225
  return false;
70166
70226
  }
@@ -70168,9 +70228,9 @@ function isFile(path) {
70168
70228
  function lookupOnPath(command, env2) {
70169
70229
  const path = env2.PATH ?? env2.Path;
70170
70230
  if (!path) return null;
70171
- for (const dir of path.split(import_node_path31.delimiter)) {
70231
+ for (const dir of path.split(import_node_path32.delimiter)) {
70172
70232
  if (!dir) continue;
70173
- const candidate = (0, import_node_path31.join)(dir, command);
70233
+ const candidate = (0, import_node_path32.join)(dir, command);
70174
70234
  if (isFile(candidate)) return candidate;
70175
70235
  }
70176
70236
  return null;
@@ -70187,21 +70247,21 @@ function windowsCandidates(env2) {
70187
70247
  for (const variable of ["ProgramFiles", "ProgramW6432", "ProgramFiles(x86)"]) {
70188
70248
  const value = env2[variable];
70189
70249
  if (!value) continue;
70190
- const root3 = (0, import_node_path31.join)(value, "Blender Foundation");
70191
- if (!roots.includes(root3)) roots.push(root3);
70250
+ const root4 = (0, import_node_path32.join)(value, "Blender Foundation");
70251
+ if (!roots.includes(root4)) roots.push(root4);
70192
70252
  }
70193
70253
  const found = [];
70194
- for (const root3 of roots) {
70195
- let entries;
70254
+ for (const root4 of roots) {
70255
+ let entries2;
70196
70256
  try {
70197
- entries = (0, import_node_fs35.readdirSync)(root3);
70257
+ entries2 = (0, import_node_fs36.readdirSync)(root4);
70198
70258
  } catch {
70199
70259
  continue;
70200
70260
  }
70201
- for (const name of entries) {
70261
+ for (const name of entries2) {
70202
70262
  const match = /^Blender\s+(\d+(?:\.\d+)*)$/i.exec(name);
70203
70263
  if (!match) continue;
70204
- const binary = (0, import_node_path31.join)(root3, name, "blender.exe");
70264
+ const binary = (0, import_node_path32.join)(root4, name, "blender.exe");
70205
70265
  if (isFile(binary)) {
70206
70266
  found.push({ version: match[1].split(".").map(Number), name, binary });
70207
70267
  }
@@ -70215,7 +70275,7 @@ function platformDefaults(env2, isWin3) {
70215
70275
  if (process.platform === "darwin") {
70216
70276
  return [
70217
70277
  "/Applications/Blender.app/Contents/MacOS/Blender",
70218
- (0, import_node_path31.join)((0, import_node_os18.homedir)(), "Applications/Blender.app/Contents/MacOS/Blender")
70278
+ (0, import_node_path32.join)((0, import_node_os19.homedir)(), "Applications/Blender.app/Contents/MacOS/Blender")
70219
70279
  ];
70220
70280
  }
70221
70281
  return ["/usr/bin/blender", "/usr/local/bin/blender", "/snap/bin/blender"];
@@ -70335,20 +70395,20 @@ async function bakeDownstream(sourcePath, appId, contract) {
70335
70395
  }
70336
70396
 
70337
70397
  // app-lifecycle.ts
70398
+ var import_node_fs39 = require("node:fs");
70399
+ var import_node_os21 = require("node:os");
70400
+ var import_node_path35 = require("node:path");
70401
+
70402
+ // routines.ts
70338
70403
  var import_node_fs38 = require("node:fs");
70339
- var import_node_os20 = require("node:os");
70340
70404
  var import_node_path34 = require("node:path");
70341
70405
 
70342
- // routines.ts
70406
+ // trigger-sessions.ts
70343
70407
  var import_node_fs37 = require("node:fs");
70408
+ var import_node_os20 = require("node:os");
70344
70409
  var import_node_path33 = require("node:path");
70345
-
70346
- // trigger-sessions.ts
70347
- var import_node_fs36 = require("node:fs");
70348
- var import_node_os19 = require("node:os");
70349
- var import_node_path32 = require("node:path");
70350
70410
  var import_yaml9 = __toESM(require_dist6(), 1);
70351
- var AGENTS_DIR2 = process.env.AWARE_HOME ? (0, import_node_path32.join)(process.env.AWARE_HOME, "agents") : (0, import_node_path32.join)((0, import_node_os19.homedir)(), ".aware", "agents");
70411
+ var AGENTS_DIR2 = process.env.AWARE_HOME ? (0, import_node_path33.join)(process.env.AWARE_HOME, "agents") : (0, import_node_path33.join)((0, import_node_os20.homedir)(), ".aware", "agents");
70352
70412
  function summarizeFire(data) {
70353
70413
  if (!data) return "event";
70354
70414
  const type = typeof data.type === "string" ? data.type : "";
@@ -70365,10 +70425,10 @@ function mapTriggerState(phase) {
70365
70425
  function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
70366
70426
  const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
70367
70427
  if (!safe2(agent)) return false;
70368
- const manifestPath2 = (0, import_node_path32.join)(agentsDir, agent, "manifest.yaml");
70369
- if (!(0, import_node_fs36.existsSync)(manifestPath2)) return false;
70428
+ const manifestPath2 = (0, import_node_path33.join)(agentsDir, agent, "manifest.yaml");
70429
+ if (!(0, import_node_fs37.existsSync)(manifestPath2)) return false;
70370
70430
  try {
70371
- const doc = (0, import_yaml9.parse)((0, import_node_fs36.readFileSync)(manifestPath2, "utf8"));
70431
+ const doc = (0, import_yaml9.parse)((0, import_node_fs37.readFileSync)(manifestPath2, "utf8"));
70372
70432
  const transport = doc?.transport;
70373
70433
  return !!(transport && typeof transport === "object" && "cli" in transport);
70374
70434
  } catch {
@@ -70653,7 +70713,7 @@ var RoutineError = class extends Error {
70653
70713
  }
70654
70714
  status;
70655
70715
  };
70656
- var ROUTINES_FILE = (0, import_node_path33.join)(flolessRoot, "routines.json");
70716
+ var ROUTINES_FILE = (0, import_node_path34.join)(flolessRoot, "routines.json");
70657
70717
  var routines = [];
70658
70718
  var loaded = false;
70659
70719
  function ensureLoaded() {
@@ -70689,29 +70749,29 @@ function sanitizeRoutine(raw) {
70689
70749
  };
70690
70750
  }
70691
70751
  function loadFromDisk() {
70692
- if (!(0, import_node_fs37.existsSync)(ROUTINES_FILE)) return [];
70693
- let text2;
70752
+ if (!(0, import_node_fs38.existsSync)(ROUTINES_FILE)) return [];
70753
+ let text3;
70694
70754
  try {
70695
- text2 = (0, import_node_fs37.readFileSync)(ROUTINES_FILE, "utf8");
70755
+ text3 = (0, import_node_fs38.readFileSync)(ROUTINES_FILE, "utf8");
70696
70756
  } catch {
70697
70757
  return [];
70698
70758
  }
70699
70759
  try {
70700
- const parsed = JSON.parse(text2);
70760
+ const parsed = JSON.parse(text3);
70701
70761
  return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
70702
70762
  } catch {
70703
70763
  try {
70704
- (0, import_node_fs37.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
70764
+ (0, import_node_fs38.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
70705
70765
  } catch {
70706
70766
  }
70707
70767
  return [];
70708
70768
  }
70709
70769
  }
70710
70770
  function saveRoutines() {
70711
- if (!(0, import_node_fs37.existsSync)(flolessRoot)) (0, import_node_fs37.mkdirSync)(flolessRoot, { recursive: true });
70771
+ if (!(0, import_node_fs38.existsSync)(flolessRoot)) (0, import_node_fs38.mkdirSync)(flolessRoot, { recursive: true });
70712
70772
  const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
70713
- (0, import_node_fs37.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
70714
- (0, import_node_fs37.renameSync)(tmp, ROUTINES_FILE);
70773
+ (0, import_node_fs38.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
70774
+ (0, import_node_fs38.renameSync)(tmp, ROUTINES_FILE);
70715
70775
  }
70716
70776
  function listRoutines() {
70717
70777
  ensureLoaded();
@@ -71119,13 +71179,13 @@ var AppLifecycleError = class extends Error {
71119
71179
  }
71120
71180
  };
71121
71181
  function appsDir() {
71122
- return process.env.AWARE_HOME ? (0, import_node_path34.join)(process.env.AWARE_HOME, "apps") : (0, import_node_path34.join)((0, import_node_os20.homedir)(), ".aware", "apps");
71182
+ return process.env.AWARE_HOME ? (0, import_node_path35.join)(process.env.AWARE_HOME, "apps") : (0, import_node_path35.join)((0, import_node_os21.homedir)(), ".aware", "apps");
71123
71183
  }
71124
71184
  function appDirPath(id) {
71125
- return (0, import_node_path34.join)(appsDir(), id);
71185
+ return (0, import_node_path35.join)(appsDir(), id);
71126
71186
  }
71127
71187
  function appInstalled(id) {
71128
- return APP_ID3.test(id) && (0, import_node_fs38.existsSync)(appDirPath(id));
71188
+ return APP_ID3.test(id) && (0, import_node_fs39.existsSync)(appDirPath(id));
71129
71189
  }
71130
71190
  function logCascade(what, e) {
71131
71191
  console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
@@ -71304,9 +71364,9 @@ function isGatedAwareRoute(url, method) {
71304
71364
 
71305
71365
  // autostart.mjs
71306
71366
  var import_node_child_process6 = require("node:child_process");
71307
- var import_node_fs39 = require("node:fs");
71308
- var import_node_os21 = require("node:os");
71309
- var import_node_path35 = require("node:path");
71367
+ var import_node_fs40 = require("node:fs");
71368
+ var import_node_os22 = require("node:os");
71369
+ var import_node_path36 = require("node:path");
71310
71370
 
71311
71371
  // teardown.mjs
71312
71372
  var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
@@ -71418,8 +71478,8 @@ function removeLegacyRunKey() {
71418
71478
  }
71419
71479
  function logLine(msg) {
71420
71480
  try {
71421
- (0, import_node_fs39.mkdirSync)(logDir(), { recursive: true });
71422
- (0, import_node_fs39.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
71481
+ (0, import_node_fs40.mkdirSync)(logDir(), { recursive: true });
71482
+ (0, import_node_fs40.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
71423
71483
  `);
71424
71484
  } catch {
71425
71485
  }
@@ -71427,8 +71487,8 @@ function logLine(msg) {
71427
71487
  function registerAutostart(exePath) {
71428
71488
  if (!isWin) return;
71429
71489
  const xml = buildAutostartTaskXml(exePath, currentUserId());
71430
- const tmp = (0, import_node_path35.join)((0, import_node_os21.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
71431
- (0, import_node_fs39.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
71490
+ const tmp = (0, import_node_path36.join)((0, import_node_os22.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
71491
+ (0, import_node_fs40.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
71432
71492
  try {
71433
71493
  (0, import_node_child_process6.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
71434
71494
  stdio: ["ignore", "ignore", "ignore"],
@@ -71439,7 +71499,7 @@ function registerAutostart(exePath) {
71439
71499
  throw err2;
71440
71500
  } finally {
71441
71501
  try {
71442
- (0, import_node_fs39.rmSync)(tmp, { force: true });
71502
+ (0, import_node_fs40.rmSync)(tmp, { force: true });
71443
71503
  } catch {
71444
71504
  }
71445
71505
  }
@@ -71474,26 +71534,26 @@ function unregisterAutostart() {
71474
71534
  // updater.ts
71475
71535
  var import_node_child_process7 = require("node:child_process");
71476
71536
  var import_node_crypto19 = require("node:crypto");
71477
- var import_node_fs41 = require("node:fs");
71537
+ var import_node_fs42 = require("node:fs");
71478
71538
  var import_node_stream3 = require("node:stream");
71479
71539
  var import_promises3 = require("node:stream/promises");
71480
- var import_node_path37 = require("node:path");
71540
+ var import_node_path38 = require("node:path");
71481
71541
 
71482
71542
  // post-update-marker.mjs
71483
- var import_node_fs40 = require("node:fs");
71484
- var import_node_os22 = require("node:os");
71485
- var import_node_path36 = require("node:path");
71543
+ var import_node_fs41 = require("node:fs");
71544
+ var import_node_os23 = require("node:os");
71545
+ var import_node_path37 = require("node:path");
71486
71546
  var FRESH_MS = 12e4;
71487
71547
  function markerPath() {
71488
71548
  const override = (process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim();
71489
71549
  if (override) return override;
71490
- const root3 = process.env.FLOLESS_HOME ?? (0, import_node_path36.join)((0, import_node_os22.homedir)(), ".floless");
71491
- return (0, import_node_path36.join)(root3, ".post-update");
71550
+ const root4 = process.env.FLOLESS_HOME ?? (0, import_node_path37.join)((0, import_node_os23.homedir)(), ".floless");
71551
+ return (0, import_node_path37.join)(root4, ".post-update");
71492
71552
  }
71493
71553
  function legacyMarkerPath() {
71494
71554
  if ((process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim()) return null;
71495
71555
  try {
71496
- return (0, import_node_path36.join)((0, import_node_path36.dirname)((0, import_node_path36.dirname)(process.execPath)), ".floless-post-update");
71556
+ return (0, import_node_path37.join)((0, import_node_path37.dirname)((0, import_node_path37.dirname)(process.execPath)), ".floless-post-update");
71497
71557
  } catch {
71498
71558
  return null;
71499
71559
  }
@@ -71503,7 +71563,7 @@ function writePostUpdateMarker() {
71503
71563
  for (const p of [markerPath(), legacyMarkerPath()]) {
71504
71564
  if (!p) continue;
71505
71565
  try {
71506
- (0, import_node_fs40.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
71566
+ (0, import_node_fs41.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
71507
71567
  wrote = true;
71508
71568
  } catch {
71509
71569
  }
@@ -71515,9 +71575,9 @@ function consumePostUpdateMarker() {
71515
71575
  for (const p of [markerPath(), legacyMarkerPath()]) {
71516
71576
  if (!p) continue;
71517
71577
  try {
71518
- if (!(0, import_node_fs40.existsSync)(p)) continue;
71519
- const ageMs = Date.now() - (0, import_node_fs40.statSync)(p).mtimeMs;
71520
- (0, import_node_fs40.rmSync)(p, { force: true });
71578
+ if (!(0, import_node_fs41.existsSync)(p)) continue;
71579
+ const ageMs = Date.now() - (0, import_node_fs41.statSync)(p).mtimeMs;
71580
+ (0, import_node_fs41.rmSync)(p, { force: true });
71521
71581
  if (ageMs < FRESH_MS) fresh = true;
71522
71582
  } catch {
71523
71583
  }
@@ -71534,13 +71594,13 @@ function currentVersion() {
71534
71594
  return appVersion();
71535
71595
  }
71536
71596
  function installRoot() {
71537
- return (0, import_node_path37.dirname)((0, import_node_path37.dirname)(process.execPath));
71597
+ return (0, import_node_path38.dirname)((0, import_node_path38.dirname)(process.execPath));
71538
71598
  }
71539
71599
  function updateExePath() {
71540
- return (0, import_node_path37.join)(installRoot(), "Update.exe");
71600
+ return (0, import_node_path38.join)(installRoot(), "Update.exe");
71541
71601
  }
71542
71602
  function packagesDir() {
71543
- return (0, import_node_path37.join)(installRoot(), "packages");
71603
+ return (0, import_node_path38.join)(installRoot(), "packages");
71544
71604
  }
71545
71605
  function feedUrl() {
71546
71606
  const env2 = (process.env.FLOLESS_UPDATE_URL ?? "").trim().replace(/\/+$/, "");
@@ -71633,22 +71693,22 @@ async function checkForUpdate() {
71633
71693
  }
71634
71694
  async function sha1OfFile(path) {
71635
71695
  const hash2 = (0, import_node_crypto19.createHash)("sha1");
71636
- await (0, import_promises3.pipeline)((0, import_node_fs41.createReadStream)(path), hash2);
71696
+ await (0, import_promises3.pipeline)((0, import_node_fs42.createReadStream)(path), hash2);
71637
71697
  return hash2.digest("hex").toUpperCase();
71638
71698
  }
71639
71699
  async function downloadPackage(asset) {
71640
71700
  if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
71641
71701
  const want = asset.SHA1.toUpperCase();
71642
71702
  const dir = packagesDir();
71643
- (0, import_node_fs41.mkdirSync)(dir, { recursive: true });
71644
- const dest = (0, import_node_path37.join)(dir, asset.FileName);
71645
- if ((0, import_node_fs41.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
71703
+ (0, import_node_fs42.mkdirSync)(dir, { recursive: true });
71704
+ const dest = (0, import_node_path38.join)(dir, asset.FileName);
71705
+ if ((0, import_node_fs42.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
71646
71706
  const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
71647
71707
  redirect: "follow",
71648
71708
  signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
71649
71709
  });
71650
71710
  if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
71651
- await (0, import_promises3.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs41.createWriteStream)(dest));
71711
+ await (0, import_promises3.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs42.createWriteStream)(dest));
71652
71712
  const got = await sha1OfFile(dest);
71653
71713
  if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
71654
71714
  return dest;
@@ -71657,7 +71717,7 @@ async function applyUpdate(check, opts) {
71657
71717
  if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
71658
71718
  if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
71659
71719
  const exe = updateExePath();
71660
- if (!(0, import_node_fs41.existsSync)(exe)) {
71720
+ if (!(0, import_node_fs42.existsSync)(exe)) {
71661
71721
  return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
71662
71722
  }
71663
71723
  const pkg = await downloadPackage(check.asset);
@@ -71774,15 +71834,15 @@ function ccType(prefix) {
71774
71834
  }
71775
71835
  }
71776
71836
  function parseBulletChanges(body) {
71777
- const text2 = body.replace(/\r\n?/g, "\n");
71837
+ const text3 = body.replace(/\r\n?/g, "\n");
71778
71838
  const styled = [];
71779
71839
  let m;
71780
71840
  STYLED_CHANGE_RE.lastIndex = 0;
71781
- while ((m = STYLED_CHANGE_RE.exec(text2)) !== null) styled.push({ type: m[1].toLowerCase(), description: m[2].trim() });
71841
+ while ((m = STYLED_CHANGE_RE.exec(text3)) !== null) styled.push({ type: m[1].toLowerCase(), description: m[2].trim() });
71782
71842
  if (styled.length) return styled;
71783
71843
  const out = [];
71784
71844
  COMMIT_BULLET_RE.lastIndex = 0;
71785
- while ((m = COMMIT_BULLET_RE.exec(text2)) !== null) {
71845
+ while ((m = COMMIT_BULLET_RE.exec(text3)) !== null) {
71786
71846
  const raw = m[1].replace(GH_CREDIT_RE, "").trim();
71787
71847
  if (!raw) continue;
71788
71848
  if (raw.startsWith("@")) continue;
@@ -71897,12 +71957,12 @@ function isTraceCorrupt(events) {
71897
71957
 
71898
71958
  // launch.mjs
71899
71959
  var import_node_child_process8 = require("node:child_process");
71900
- var import_node_path38 = require("node:path");
71960
+ var import_node_path39 = require("node:path");
71901
71961
  var import_node_url3 = require("node:url");
71902
- var import_node_fs42 = require("node:fs");
71962
+ var import_node_fs43 = require("node:fs");
71903
71963
  var import_node_http = __toESM(require("node:http"), 1);
71904
71964
  var import_node_readline = require("node:readline");
71905
- var __dirname2 = (0, import_node_path38.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
71965
+ var __dirname2 = (0, import_node_path39.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
71906
71966
  var PORT = Number(process.env.PORT ?? 4317);
71907
71967
  var HEALTH_URL = `http://127.0.0.1:${PORT}/api/health`;
71908
71968
  var BROWSER_URL = `http://floless.localhost:${PORT}`;
@@ -71974,8 +72034,8 @@ async function waitHealthy(timeoutMs = 3e4) {
71974
72034
  function resolveServerStart() {
71975
72035
  const packaged = /flolessapp\.exe$/i.test(process.execPath);
71976
72036
  if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
71977
- const bundle = (0, import_node_path38.join)(__dirname2, "dist", "floless-server.cjs");
71978
- if ((0, import_node_fs42.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
72037
+ const bundle = (0, import_node_path39.join)(__dirname2, "dist", "floless-server.cjs");
72038
+ if ((0, import_node_fs43.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
71979
72039
  return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
71980
72040
  }
71981
72041
  function startServerDetached() {
@@ -72128,8 +72188,8 @@ function taskkillArgs(pid, { tree = true } = {}) {
72128
72188
  }
72129
72189
  function killSupervisor({ tree = true } = {}) {
72130
72190
  if (!isWin2) return;
72131
- const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path38.basename)(process.execPath));
72132
- const scriptMatch = isNpmChannel ? (0, import_node_path38.basename)((0, import_node_url3.fileURLToPath)(__import_meta_url)) : void 0;
72191
+ const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path39.basename)(process.execPath));
72192
+ const scriptMatch = isNpmChannel ? (0, import_node_path39.basename)((0, import_node_url3.fileURLToPath)(__import_meta_url)) : void 0;
72133
72193
  const realExe = resolveRealInstallExe(process.execPath);
72134
72194
  const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
72135
72195
  const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
@@ -72294,7 +72354,7 @@ async function runAction(arg, flagArgv = [], selfVersion = null) {
72294
72354
  }
72295
72355
  await action(parseTeardownFlags(flagArgv));
72296
72356
  }
72297
- var entry = (0, import_node_path38.basename)(process.argv[1] ?? "").toLowerCase();
72357
+ var entry = (0, import_node_path39.basename)(process.argv[1] ?? "").toLowerCase();
72298
72358
  if (entry === "launch.mjs") {
72299
72359
  runAction(process.argv[2], process.argv.slice(3)).catch((e) => {
72300
72360
  log(`error: ${e?.message ?? e}`);
@@ -72368,9 +72428,9 @@ function awareUpgradeBlockReason(s) {
72368
72428
  }
72369
72429
 
72370
72430
  // skill-sync.ts
72371
- var import_node_fs43 = require("node:fs");
72372
- var import_node_os23 = require("node:os");
72373
- var import_node_path39 = require("node:path");
72431
+ var import_node_fs44 = require("node:fs");
72432
+ var import_node_os24 = require("node:os");
72433
+ var import_node_path40 = require("node:path");
72374
72434
  var import_node_url4 = require("node:url");
72375
72435
  var import_yaml10 = __toESM(require_dist6(), 1);
72376
72436
 
@@ -72415,31 +72475,31 @@ function selectShippedSkillNames(names) {
72415
72475
  }
72416
72476
 
72417
72477
  // skill-sync.ts
72418
- var __dirname3 = (0, import_node_path39.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
72478
+ var __dirname3 = (0, import_node_path40.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
72419
72479
  function bundledSkillsRoot() {
72420
72480
  const candidates = [
72421
- (0, import_node_path39.join)(__dirname3, "skills"),
72422
- (0, import_node_path39.join)((0, import_node_path39.dirname)(process.execPath), "skills"),
72423
- (0, import_node_path39.join)(__dirname3, "..", ".claude", "skills")
72481
+ (0, import_node_path40.join)(__dirname3, "skills"),
72482
+ (0, import_node_path40.join)((0, import_node_path40.dirname)(process.execPath), "skills"),
72483
+ (0, import_node_path40.join)(__dirname3, "..", ".claude", "skills")
72424
72484
  ];
72425
- return candidates.find((p) => (0, import_node_fs43.existsSync)(p)) ?? null;
72485
+ return candidates.find((p) => (0, import_node_fs44.existsSync)(p)) ?? null;
72426
72486
  }
72427
72487
  function targetConfigDirs() {
72428
72488
  const override = process.env.FLOLESS_SKILL_TARGETS;
72429
72489
  if (override) {
72430
72490
  return override.split(";").map((d) => d.trim()).filter(Boolean).map((dir) => ({ runtime: "custom", dir }));
72431
72491
  }
72432
- const home = (0, import_node_os23.homedir)();
72492
+ const home = (0, import_node_os24.homedir)();
72433
72493
  return [
72434
- { runtime: "claude", dir: (0, import_node_path39.join)(home, ".claude") },
72435
- { runtime: "codex", dir: (0, import_node_path39.join)(home, ".codex") },
72436
- { runtime: "opencode", dir: (0, import_node_path39.join)(home, ".opencode") }
72494
+ { runtime: "claude", dir: (0, import_node_path40.join)(home, ".claude") },
72495
+ { runtime: "codex", dir: (0, import_node_path40.join)(home, ".codex") },
72496
+ { runtime: "opencode", dir: (0, import_node_path40.join)(home, ".opencode") }
72437
72497
  ];
72438
72498
  }
72439
72499
  function skillVersion(skillMdPath) {
72440
72500
  try {
72441
- const text2 = (0, import_node_fs43.readFileSync)(skillMdPath, "utf8");
72442
- const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text2);
72501
+ const text3 = (0, import_node_fs44.readFileSync)(skillMdPath, "utf8");
72502
+ const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text3);
72443
72503
  if (!m || m[1] === void 0) return null;
72444
72504
  const fm = (0, import_yaml10.parse)(m[1]);
72445
72505
  const meta = fm?.metadata;
@@ -72475,24 +72535,24 @@ function decideAction(installed, bundled) {
72475
72535
  if (c === 0) return "skipped-current";
72476
72536
  return "skipped-newer";
72477
72537
  }
72478
- function bundledSkills(root3) {
72479
- let entries = [];
72538
+ function bundledSkills(root4) {
72539
+ let entries2 = [];
72480
72540
  try {
72481
- entries = selectShippedSkillNames((0, import_node_fs43.readdirSync)(root3));
72541
+ entries2 = selectShippedSkillNames((0, import_node_fs44.readdirSync)(root4));
72482
72542
  } catch {
72483
72543
  return [];
72484
72544
  }
72485
72545
  const out = [];
72486
- for (const name of entries) {
72487
- const dir = (0, import_node_path39.join)(root3, name);
72546
+ for (const name of entries2) {
72547
+ const dir = (0, import_node_path40.join)(root4, name);
72488
72548
  let isDir = false;
72489
72549
  try {
72490
- isDir = (0, import_node_fs43.statSync)(dir).isDirectory();
72550
+ isDir = (0, import_node_fs44.statSync)(dir).isDirectory();
72491
72551
  } catch {
72492
72552
  isDir = false;
72493
72553
  }
72494
72554
  if (!isDir) continue;
72495
- const v = skillVersion((0, import_node_path39.join)(dir, "SKILL.md"));
72555
+ const v = skillVersion((0, import_node_path40.join)(dir, "SKILL.md"));
72496
72556
  if (!v) continue;
72497
72557
  out.push({ name, dir, version: v });
72498
72558
  }
@@ -72500,22 +72560,22 @@ function bundledSkills(root3) {
72500
72560
  }
72501
72561
  function syncSkills() {
72502
72562
  const results = [];
72503
- const root3 = bundledSkillsRoot();
72504
- if (!root3) return results;
72505
- const skills = bundledSkills(root3);
72563
+ const root4 = bundledSkillsRoot();
72564
+ if (!root4) return results;
72565
+ const skills = bundledSkills(root4);
72506
72566
  if (!skills.length) return results;
72507
72567
  for (const { runtime, dir: cfg } of targetConfigDirs()) {
72508
- if (!(0, import_node_fs43.existsSync)(cfg)) continue;
72509
- const skillsDir = (0, import_node_path39.join)(cfg, "skills");
72568
+ if (!(0, import_node_fs44.existsSync)(cfg)) continue;
72569
+ const skillsDir = (0, import_node_path40.join)(cfg, "skills");
72510
72570
  for (const s of skills) {
72511
- const dest = (0, import_node_path39.join)(skillsDir, s.name);
72512
- const installedMd = (0, import_node_path39.join)(dest, "SKILL.md");
72513
- const installed = (0, import_node_fs43.existsSync)(installedMd) ? skillVersion(installedMd) : null;
72571
+ const dest = (0, import_node_path40.join)(skillsDir, s.name);
72572
+ const installedMd = (0, import_node_path40.join)(dest, "SKILL.md");
72573
+ const installed = (0, import_node_fs44.existsSync)(installedMd) ? skillVersion(installedMd) : null;
72514
72574
  const action = decideAction(installed, s.version);
72515
72575
  if (action === "installed" || action === "updated") {
72516
72576
  try {
72517
- if (action === "updated") (0, import_node_fs43.rmSync)(dest, { recursive: true, force: true });
72518
- (0, import_node_fs43.cpSync)(s.dir, dest, { recursive: true });
72577
+ if (action === "updated") (0, import_node_fs44.rmSync)(dest, { recursive: true, force: true });
72578
+ (0, import_node_fs44.cpSync)(s.dir, dest, { recursive: true });
72519
72579
  results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
72520
72580
  } catch {
72521
72581
  }
@@ -72539,9 +72599,9 @@ function contractChangedEvent(appId, project, etag, rawMutationId) {
72539
72599
  }
72540
72600
 
72541
72601
  // watch.ts
72542
- var import_node_os24 = require("node:os");
72543
- var import_node_path41 = require("node:path");
72544
- var import_node_fs44 = require("node:fs");
72602
+ var import_node_os25 = require("node:os");
72603
+ var import_node_path42 = require("node:path");
72604
+ var import_node_fs45 = require("node:fs");
72545
72605
 
72546
72606
  // node_modules/chokidar/esm/index.js
72547
72607
  var import_fs2 = require("fs");
@@ -72552,7 +72612,7 @@ var sysPath2 = __toESM(require("path"), 1);
72552
72612
  // node_modules/readdirp/esm/index.js
72553
72613
  var import_promises4 = require("node:fs/promises");
72554
72614
  var import_node_stream4 = require("node:stream");
72555
- var import_node_path40 = require("node:path");
72615
+ var import_node_path41 = require("node:path");
72556
72616
  var EntryTypes = {
72557
72617
  FILE_TYPE: "files",
72558
72618
  DIR_TYPE: "directories",
@@ -72614,7 +72674,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72614
72674
  highWaterMark: options.highWaterMark
72615
72675
  });
72616
72676
  const opts = { ...defaultOptions, ...options };
72617
- const { root: root3, type } = opts;
72677
+ const { root: root4, type } = opts;
72618
72678
  this._fileFilter = normalizeFilter(opts.fileFilter);
72619
72679
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
72620
72680
  const statMethod = opts.lstat ? import_promises4.lstat : import_promises4.stat;
@@ -72627,11 +72687,11 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72627
72687
  this._wantsDir = type ? DIR_TYPES.has(type) : false;
72628
72688
  this._wantsFile = type ? FILE_TYPES.has(type) : false;
72629
72689
  this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
72630
- this._root = (0, import_node_path40.resolve)(root3);
72690
+ this._root = (0, import_node_path41.resolve)(root4);
72631
72691
  this._isDirent = !opts.alwaysStat;
72632
72692
  this._statsProp = this._isDirent ? "dirent" : "stats";
72633
72693
  this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
72634
- this.parents = [this._exploreDir(root3, 1)];
72694
+ this.parents = [this._exploreDir(root4, 1)];
72635
72695
  this.reading = false;
72636
72696
  this.parent = void 0;
72637
72697
  }
@@ -72698,8 +72758,8 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72698
72758
  let entry2;
72699
72759
  const basename9 = this._isDirent ? dirent.name : dirent;
72700
72760
  try {
72701
- const fullPath = (0, import_node_path40.resolve)((0, import_node_path40.join)(path, basename9));
72702
- entry2 = { path: (0, import_node_path40.relative)(this._root, fullPath), fullPath, basename: basename9 };
72761
+ const fullPath = (0, import_node_path41.resolve)((0, import_node_path41.join)(path, basename9));
72762
+ entry2 = { path: (0, import_node_path41.relative)(this._root, fullPath), fullPath, basename: basename9 };
72703
72763
  entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
72704
72764
  } catch (err2) {
72705
72765
  this._onError(err2);
@@ -72733,7 +72793,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72733
72793
  }
72734
72794
  if (entryRealPathStats.isDirectory()) {
72735
72795
  const len = entryRealPath.length;
72736
- if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path40.sep) {
72796
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path41.sep) {
72737
72797
  const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
72738
72798
  recursiveError.code = RECURSIVE_ERROR_CODE;
72739
72799
  return this._onError(recursiveError);
@@ -72751,20 +72811,20 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72751
72811
  return stats && this._wantsEverything && !stats.isDirectory();
72752
72812
  }
72753
72813
  };
72754
- function readdirp(root3, options = {}) {
72814
+ function readdirp(root4, options = {}) {
72755
72815
  let type = options.entryType || options.type;
72756
72816
  if (type === "both")
72757
72817
  type = EntryTypes.FILE_DIR_TYPE;
72758
72818
  if (type)
72759
72819
  options.type = type;
72760
- if (!root3) {
72820
+ if (!root4) {
72761
72821
  throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
72762
- } else if (typeof root3 !== "string") {
72822
+ } else if (typeof root4 !== "string") {
72763
72823
  throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
72764
72824
  } else if (type && !ALL_TYPES.includes(type)) {
72765
72825
  throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
72766
72826
  }
72767
- options.root = root3;
72827
+ options.root = root4;
72768
72828
  return new ReaddirpStream(options);
72769
72829
  }
72770
72830
 
@@ -74209,11 +74269,11 @@ var FSWatcher = class extends import_events.EventEmitter {
74209
74269
  }
74210
74270
  list.push(closer);
74211
74271
  }
74212
- _readdirp(root3, opts) {
74272
+ _readdirp(root4, opts) {
74213
74273
  if (this.closed)
74214
74274
  return;
74215
74275
  const options = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
74216
- let stream = readdirp(root3, options);
74276
+ let stream = readdirp(root4, options);
74217
74277
  this._streams.add(stream);
74218
74278
  stream.once(STR_CLOSE, () => {
74219
74279
  stream = void 0;
@@ -74241,33 +74301,33 @@ function appIdFromLogPath(path) {
74241
74301
  return i >= 0 && parts[i + 1] ? parts[i + 1] : null;
74242
74302
  }
74243
74303
  function samePath(a, b) {
74244
- const ra = (0, import_node_path41.resolve)(a);
74245
- const rb = (0, import_node_path41.resolve)(b);
74304
+ const ra = (0, import_node_path42.resolve)(a);
74305
+ const rb = (0, import_node_path42.resolve)(b);
74246
74306
  return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
74247
74307
  }
74248
74308
  function underDir(path, dir) {
74249
- const rp = (0, import_node_path41.resolve)(path);
74250
- const rd = (0, import_node_path41.resolve)(dir);
74309
+ const rp = (0, import_node_path42.resolve)(path);
74310
+ const rd = (0, import_node_path42.resolve)(dir);
74251
74311
  const [p, d] = process.platform === "win32" ? [rp.toLowerCase(), rd.toLowerCase()] : [rp, rd];
74252
- return p === d || p.startsWith(d + import_node_path41.sep);
74312
+ return p === d || p.startsWith(d + import_node_path42.sep);
74253
74313
  }
74254
74314
  function startWatcher() {
74255
- const awareDir = process.env.AWARE_HOME ?? (0, import_node_path41.join)((0, import_node_os24.homedir)(), ".aware");
74256
- const credentialsDir = (0, import_node_path41.join)(awareDir, "credentials");
74257
- if (!(0, import_node_fs44.existsSync)(credentialsDir)) {
74315
+ const awareDir = process.env.AWARE_HOME ?? (0, import_node_path42.join)((0, import_node_os25.homedir)(), ".aware");
74316
+ const credentialsDir = (0, import_node_path42.join)(awareDir, "credentials");
74317
+ if (!(0, import_node_fs45.existsSync)(credentialsDir)) {
74258
74318
  try {
74259
- (0, import_node_fs44.mkdirSync)(credentialsDir, { recursive: true });
74319
+ (0, import_node_fs45.mkdirSync)(credentialsDir, { recursive: true });
74260
74320
  } catch {
74261
74321
  }
74262
74322
  }
74263
- if (!(0, import_node_fs44.existsSync)(uiDir)) {
74323
+ if (!(0, import_node_fs45.existsSync)(uiDir)) {
74264
74324
  try {
74265
- (0, import_node_fs44.mkdirSync)(uiDir, { recursive: true });
74325
+ (0, import_node_fs45.mkdirSync)(uiDir, { recursive: true });
74266
74326
  } catch {
74267
74327
  }
74268
74328
  }
74269
- const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path41.join)(awareDir, d)).filter((p) => (0, import_node_fs44.existsSync)(p));
74270
- if ((0, import_node_fs44.existsSync)(uiDir)) targets.push(uiDir);
74329
+ const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path42.join)(awareDir, d)).filter((p) => (0, import_node_fs45.existsSync)(p));
74330
+ if ((0, import_node_fs45.existsSync)(uiDir)) targets.push(uiDir);
74271
74331
  if (targets.length === 0) {
74272
74332
  return null;
74273
74333
  }
@@ -74296,11 +74356,11 @@ function startWatcher() {
74296
74356
  const isCredential = path.split(/[\\/]/).includes("credentials");
74297
74357
  const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
74298
74358
  broadcast({ type: "fs-change", kind, event, path });
74299
- if (kind === "trace" && event !== "unlink" && (0, import_node_fs44.existsSync)(path)) {
74359
+ if (kind === "trace" && event !== "unlink" && (0, import_node_fs45.existsSync)(path)) {
74300
74360
  const id = appIdFromLogPath(path);
74301
74361
  if (!id) return;
74302
74362
  try {
74303
- broadcast({ type: "trace-file", id, runId: path.split(import_node_path41.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs44.readFileSync)(path, "utf8")) });
74363
+ broadcast({ type: "trace-file", id, runId: path.split(import_node_path42.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs45.readFileSync)(path, "utf8")) });
74304
74364
  } catch {
74305
74365
  }
74306
74366
  }
@@ -74309,10 +74369,10 @@ function startWatcher() {
74309
74369
  }
74310
74370
 
74311
74371
  // index.ts
74312
- var __dirname4 = (0, import_node_path42.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
74313
- var WEB_ROOT = [(0, import_node_path42.join)(__dirname4, "web"), (0, import_node_path42.join)((0, import_node_path42.dirname)(process.execPath), "web"), (0, import_node_path42.join)(__dirname4, "..", "web")].find(
74314
- (p) => (0, import_node_fs45.existsSync)(p)
74315
- ) ?? (0, import_node_path42.join)(__dirname4, "..", "web");
74372
+ var __dirname4 = (0, import_node_path43.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
74373
+ var WEB_ROOT = [(0, import_node_path43.join)(__dirname4, "web"), (0, import_node_path43.join)((0, import_node_path43.dirname)(process.execPath), "web"), (0, import_node_path43.join)(__dirname4, "..", "web")].find(
74374
+ (p) => (0, import_node_fs46.existsSync)(p)
74375
+ ) ?? (0, import_node_path43.join)(__dirname4, "..", "web");
74316
74376
  var PORT2 = Number(process.env.PORT ?? 4317);
74317
74377
  var HOST = "127.0.0.1";
74318
74378
  var crashHandlersInstalled = false;
@@ -74328,7 +74388,7 @@ function installCrashHandlers() {
74328
74388
  ${stack}
74329
74389
  `;
74330
74390
  try {
74331
- (0, import_node_fs45.appendFileSync)(logFilePath(), line);
74391
+ (0, import_node_fs46.appendFileSync)(logFilePath(), line);
74332
74392
  } catch {
74333
74393
  }
74334
74394
  if (process.stderr.isTTY) process.stderr.write(line);
@@ -74684,9 +74744,9 @@ async function startServer() {
74684
74744
  const { id, templateId, templatePath, srcPath, appDirPath: appDirPath2, fromVersion, contract, verb } = opts;
74685
74745
  const bdir = backupDir(id, fromVersion, Date.now());
74686
74746
  try {
74687
- (0, import_node_fs45.mkdirSync)((0, import_node_path42.dirname)(bdir), { recursive: true });
74688
- (0, import_node_fs45.cpSync)(appDirPath2, bdir, { recursive: true });
74689
- (0, import_node_fs45.cpSync)(templatePath, srcPath);
74747
+ (0, import_node_fs46.mkdirSync)((0, import_node_path43.dirname)(bdir), { recursive: true });
74748
+ (0, import_node_fs46.cpSync)(appDirPath2, bdir, { recursive: true });
74749
+ (0, import_node_fs46.cpSync)(templatePath, srcPath);
74690
74750
  if (id !== templateId) stampSourceAppId(srcPath, id);
74691
74751
  if (contract != null) {
74692
74752
  bakeContractIntoApp(srcPath, contract);
@@ -74697,8 +74757,8 @@ async function startServer() {
74697
74757
  } catch (e) {
74698
74758
  const msg = e instanceof Error ? e.message : String(e);
74699
74759
  try {
74700
- (0, import_node_fs45.rmSync)(appDirPath2, { recursive: true, force: true });
74701
- (0, import_node_fs45.cpSync)(bdir, appDirPath2, { recursive: true });
74760
+ (0, import_node_fs46.rmSync)(appDirPath2, { recursive: true, force: true });
74761
+ (0, import_node_fs46.cpSync)(bdir, appDirPath2, { recursive: true });
74702
74762
  } catch (re) {
74703
74763
  const rmsg = re instanceof Error ? re.message : String(re);
74704
74764
  throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
@@ -74730,7 +74790,7 @@ async function startServer() {
74730
74790
  return reply.status(409).send({ ok: false, error: `"${id}" is already at ${fromVersion}`, code: "up-to-date" });
74731
74791
  }
74732
74792
  const contract = readAcceptedForRequest(id, void 0);
74733
- if (contract == null && (0, import_node_fs45.existsSync)(contractPath(id))) {
74793
+ if (contract == null && (0, import_node_fs46.existsSync)(contractPath(id))) {
74734
74794
  return reply.status(409).send({ ok: false, error: `"${id}"'s saved data is unreadable \u2014 open it in the editor and re-save before updating`, code: "contract-corrupt" });
74735
74795
  }
74736
74796
  if (contract != null) {
@@ -74864,16 +74924,16 @@ async function startServer() {
74864
74924
  app.get("/api/app/:id", async (req) => {
74865
74925
  return { ok: true, app: readApp(req.params.id) };
74866
74926
  });
74867
- const withTemplateId = (p, root3) => ({ ...p, templateId: root3(p.app) });
74927
+ const withTemplateId = (p, root4) => ({ ...p, templateId: root4(p.app) });
74868
74928
  const projectView = (p) => withTemplateId(p, resolveTemplateId);
74869
74929
  const projectViews = (list) => {
74870
- const root3 = templateIdResolver();
74871
- return list.map((p) => withTemplateId(p, root3));
74930
+ const root4 = templateIdResolver();
74931
+ return list.map((p) => withTemplateId(p, root4));
74872
74932
  };
74873
74933
  const requestView2 = (r) => r === null ? null : { ...r, appTemplateId: r.appId ? resolveTemplateId(r.appId) : void 0 };
74874
74934
  const requestViews = (list) => {
74875
- const root3 = templateIdResolver();
74876
- return list.map((r) => ({ ...r, appTemplateId: r.appId ? root3(r.appId) : void 0 }));
74935
+ const root4 = templateIdResolver();
74936
+ return list.map((r) => ({ ...r, appTemplateId: r.appId ? root4(r.appId) : void 0 }));
74877
74937
  };
74878
74938
  app.get("/api/projects", async () => ({ ok: true, projects: projectViews(listProjects()) }));
74879
74939
  app.post(
@@ -75110,9 +75170,9 @@ async function startServer() {
75110
75170
  const bad = projectAppMismatch(req.params.appId, project);
75111
75171
  if (bad) return reply.status(404).send({ ok: false, error: bad });
75112
75172
  const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
75113
- const file = (0, import_node_path42.join)((0, import_node_path42.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
75114
- if (!(0, import_node_fs45.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
75115
- return reply.type("image/svg+xml").send((0, import_node_fs45.readFileSync)(file, "utf8"));
75173
+ const file = (0, import_node_path43.join)((0, import_node_path43.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
75174
+ if (!(0, import_node_fs46.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
75175
+ return reply.type("image/svg+xml").send((0, import_node_fs46.readFileSync)(file, "utf8"));
75116
75176
  }
75117
75177
  );
75118
75178
  app.put(
@@ -75270,7 +75330,7 @@ async function startServer() {
75270
75330
  }
75271
75331
  const statedAt = (filename) => {
75272
75332
  try {
75273
- const st = (0, import_node_fs45.statSync)((0, import_node_path42.join)(dir, filename));
75333
+ const st = (0, import_node_fs46.statSync)((0, import_node_path43.join)(dir, filename));
75274
75334
  return st.isFile() ? st.mtime.toISOString() : null;
75275
75335
  } catch {
75276
75336
  return null;
@@ -75280,14 +75340,14 @@ async function startServer() {
75280
75340
  const rows2 = (byKind.get(kind) ?? []).map((receipt) => ({
75281
75341
  variant: receipt.variant ?? null,
75282
75342
  filename: receipt.filename,
75283
- path: (0, import_node_path42.join)(dir, receipt.filename),
75343
+ path: (0, import_node_path43.join)(dir, receipt.filename),
75284
75344
  exportedAt: statedAt(receipt.filename)
75285
75345
  })).sort((a, b) => String(b.exportedAt ?? "").localeCompare(String(a.exportedAt ?? "")));
75286
75346
  const headline = rows2[0];
75287
75347
  return {
75288
75348
  kind,
75289
75349
  filename: headline?.filename ?? legacy,
75290
- path: headline?.path ?? (0, import_node_path42.join)(dir, legacy),
75350
+ path: headline?.path ?? (0, import_node_path43.join)(dir, legacy),
75291
75351
  exportedAt: headline?.exportedAt ?? null,
75292
75352
  ...rows2.length ? { variants: rows2 } : {}
75293
75353
  };
@@ -75426,7 +75486,7 @@ async function startServer() {
75426
75486
  }
75427
75487
  if (!hasExportableSceneRecords(scene)) return reply.status(422).send({ ok: false, error: emptyError, skipped });
75428
75488
  const filename = `${exportFileBase(project, appId)}.ifc`;
75429
- const finalPath = (0, import_node_path42.join)(project ? projectExportsDir(project) : (0, import_node_path42.dirname)(bomExportPath(appId, "csv")), filename);
75489
+ const finalPath = (0, import_node_path43.join)(project ? projectExportsDir(project) : (0, import_node_path43.dirname)(bomExportPath(appId, "csv")), filename);
75430
75490
  const priorProjectIfc = project ? listProjectExportReceipts(project).find((row) => row.kind === "ifc") : void 0;
75431
75491
  const tempPath = requestIfcTempPath(finalPath);
75432
75492
  try {
@@ -75434,10 +75494,10 @@ async function startServer() {
75434
75494
  scene,
75435
75495
  "output-path": tempPath
75436
75496
  });
75437
- if (!(0, import_node_fs45.existsSync)(tempPath) || (0, import_node_fs45.statSync)(tempPath).size === 0) {
75497
+ if (!(0, import_node_fs46.existsSync)(tempPath) || (0, import_node_fs46.statSync)(tempPath).size === 0) {
75438
75498
  throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
75439
75499
  }
75440
- const artifactBytes = (0, import_node_fs45.readFileSync)(tempPath);
75500
+ const artifactBytes = (0, import_node_fs46.readFileSync)(tempPath);
75441
75501
  const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
75442
75502
  index: parseStepData(artifactBytes),
75443
75503
  bytes: artifactBytes
@@ -75490,7 +75550,7 @@ async function startServer() {
75490
75550
  return reply.status(status).send({
75491
75551
  ok: false,
75492
75552
  error: error instanceof Error ? error.message : "IFC export failed",
75493
- preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs45.existsSync)(finalPath)
75553
+ preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs46.existsSync)(finalPath)
75494
75554
  });
75495
75555
  } finally {
75496
75556
  cleanupIfcTemp(tempPath);
@@ -75535,10 +75595,10 @@ async function startServer() {
75535
75595
  const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
75536
75596
  if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
75537
75597
  const path = resolveProjectExportReceiptPath(project, receipt);
75538
- if (!path || !(0, import_node_fs45.existsSync)(path)) {
75598
+ if (!path || !(0, import_node_fs46.existsSync)(path)) {
75539
75599
  return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
75540
75600
  }
75541
- return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs45.readFileSync)(path));
75601
+ return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs46.readFileSync)(path));
75542
75602
  });
75543
75603
  const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
75544
75604
  app.post("/api/contract/:appId/render", async (req, reply) => {
@@ -75595,8 +75655,8 @@ async function startServer() {
75595
75655
  }
75596
75656
  const kind = output === "turntable" ? "render-mp4" : "render-png";
75597
75657
  const extension = output === "turntable" ? ".mp4" : ".png";
75598
- const scratch = (0, import_node_fs45.mkdtempSync)((0, import_node_path42.join)((0, import_node_os25.tmpdir)(), "floless-render-"));
75599
- const ifcPath = (0, import_node_path42.join)(scratch, "model.ifc");
75658
+ const scratch = (0, import_node_fs46.mkdtempSync)((0, import_node_path43.join)((0, import_node_os26.tmpdir)(), "floless-render-"));
75659
+ const ifcPath = (0, import_node_path43.join)(scratch, "model.ifc");
75600
75660
  const rendered = [];
75601
75661
  const progress = (stage, extra = {}) => {
75602
75662
  try {
@@ -75607,13 +75667,13 @@ async function startServer() {
75607
75667
  try {
75608
75668
  progress("preparing");
75609
75669
  await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
75610
- if (!(0, import_node_fs45.existsSync)(ifcPath) || (0, import_node_fs45.statSync)(ifcPath).size === 0) {
75670
+ if (!(0, import_node_fs46.existsSync)(ifcPath) || (0, import_node_fs46.statSync)(ifcPath).size === 0) {
75611
75671
  throw new Error("AWARE reported a successful IFC write but produced no file to render");
75612
75672
  }
75613
75673
  const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
75614
75674
  for (const [i, viewpoint] of viewpoints.entries()) {
75615
75675
  progress("rendering", { viewpoint, index: i + 1, output });
75616
- const artifactPath = (0, import_node_path42.join)(scratch, `render-${viewpoint}${extension}`);
75676
+ const artifactPath = (0, import_node_path43.join)(scratch, `render-${viewpoint}${extension}`);
75617
75677
  const receipt = await aware.agentInvoke(RENDER_AGENT_ID, output === "turntable" ? "render.turntable" : "render.still", {
75618
75678
  "ifc-path": ifcPath,
75619
75679
  "output-path": artifactPath,
@@ -75625,10 +75685,10 @@ async function startServer() {
75625
75685
  environment: "studio",
75626
75686
  ...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
75627
75687
  }, { timeoutMs: renderBudgetMs });
75628
- if (!(0, import_node_fs45.existsSync)(artifactPath) || (0, import_node_fs45.statSync)(artifactPath).size === 0) {
75688
+ if (!(0, import_node_fs46.existsSync)(artifactPath) || (0, import_node_fs46.statSync)(artifactPath).size === 0) {
75629
75689
  throw new Error(`the ${viewpoint} render reported success but produced no image`);
75630
75690
  }
75631
- const bytes = (0, import_node_fs45.readFileSync)(artifactPath);
75691
+ const bytes = (0, import_node_fs46.readFileSync)(artifactPath);
75632
75692
  const preferred = `${exportFileBase(project, appId)}-${viewpoint}${extension}`;
75633
75693
  const filename = uniqueProjectExportFilename(project, preferred);
75634
75694
  publishProjectExportArtifact(project, {
@@ -75664,7 +75724,7 @@ async function startServer() {
75664
75724
  // Kept for a single-viewpoint caller so the existing shape still reads naturally.
75665
75725
  filename: rendered[0]?.filename,
75666
75726
  viewpoint: rendered[0]?.viewpoint,
75667
- savedTo: rendered[0] ? (0, import_node_path42.join)(projectExportsDir(project), rendered[0].filename) : void 0
75727
+ savedTo: rendered[0] ? (0, import_node_path43.join)(projectExportsDir(project), rendered[0].filename) : void 0
75668
75728
  };
75669
75729
  } catch (error) {
75670
75730
  app.log.warn(
@@ -75680,7 +75740,7 @@ async function startServer() {
75680
75740
  rendered
75681
75741
  });
75682
75742
  } finally {
75683
- (0, import_node_fs45.rmSync)(scratch, { recursive: true, force: true });
75743
+ (0, import_node_fs46.rmSync)(scratch, { recursive: true, force: true });
75684
75744
  }
75685
75745
  }, {
75686
75746
  // What anyone blocked on this project is told, and for how long to expect it. Erring long
@@ -75822,23 +75882,23 @@ async function startServer() {
75822
75882
  }
75823
75883
  const preferredFilename = `${exportFileBase(project, appId)}-bom.${format}`;
75824
75884
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
75825
- const outPath = project ? (0, import_node_path42.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
75826
- const dir = (0, import_node_path42.dirname)(outPath);
75885
+ const outPath = project ? (0, import_node_path43.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
75886
+ const dir = (0, import_node_path43.dirname)(outPath);
75827
75887
  try {
75828
- (0, import_node_fs45.mkdirSync)(dir, { recursive: true });
75888
+ (0, import_node_fs46.mkdirSync)(dir, { recursive: true });
75829
75889
  if (format === "csv") {
75830
- const text2 = bomToCsv(bom);
75890
+ const text3 = bomToCsv(bom);
75831
75891
  if (project && projectSnapshot) {
75832
75892
  publishProjectExportArtifact(project, {
75833
75893
  kind: "bom-csv",
75834
75894
  filename,
75835
75895
  encoding: "utf8",
75836
- bytes: Buffer.byteLength(text2),
75896
+ bytes: Buffer.byteLength(text3),
75837
75897
  version: projectSnapshot.version.n,
75838
75898
  contractHash: projectSnapshot.contractHash
75839
- }, Buffer.from(text2, "utf8"));
75840
- } else (0, import_node_fs45.writeFileSync)(outPath, text2, "utf8");
75841
- return { ok: true, filename, encoding: "utf8", content: text2, bytes: Buffer.byteLength(text2), savedTo: outPath };
75899
+ }, Buffer.from(text3, "utf8"));
75900
+ } else (0, import_node_fs46.writeFileSync)(outPath, text3, "utf8");
75901
+ return { ok: true, filename, encoding: "utf8", content: text3, bytes: Buffer.byteLength(text3), savedTo: outPath };
75842
75902
  }
75843
75903
  const buf = await bomToXlsx(bom);
75844
75904
  if (project && projectSnapshot) {
@@ -75850,7 +75910,7 @@ async function startServer() {
75850
75910
  version: projectSnapshot.version.n,
75851
75911
  contractHash: projectSnapshot.contractHash
75852
75912
  }, buf);
75853
- } else (0, import_node_fs45.writeFileSync)(outPath, buf);
75913
+ } else (0, import_node_fs46.writeFileSync)(outPath, buf);
75854
75914
  return { ok: true, filename, encoding: "base64", content: buf.toString("base64"), bytes: buf.length, savedTo: outPath };
75855
75915
  } catch (e) {
75856
75916
  app.log.error({ appId, format, err: e instanceof Error ? e.message : e }, "export-bom: generation failed");
@@ -75888,9 +75948,9 @@ async function startServer() {
75888
75948
  const svg = contractToSvg(cleaned);
75889
75949
  const preferredFilename = `${exportFileBase(project, req.params.appId)}.svg`;
75890
75950
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
75891
- const outPath = project ? (0, import_node_path42.join)(projectExportsDir(project), filename) : (0, import_node_path42.join)(appPath(req.params.appId), filename);
75951
+ const outPath = project ? (0, import_node_path43.join)(projectExportsDir(project), filename) : (0, import_node_path43.join)(appPath(req.params.appId), filename);
75892
75952
  try {
75893
- (0, import_node_fs45.mkdirSync)((0, import_node_path42.dirname)(outPath), { recursive: true });
75953
+ (0, import_node_fs46.mkdirSync)((0, import_node_path43.dirname)(outPath), { recursive: true });
75894
75954
  if (project && projectSnapshot) {
75895
75955
  publishProjectExportArtifact(project, {
75896
75956
  kind: "svg",
@@ -75900,7 +75960,7 @@ async function startServer() {
75900
75960
  version: projectSnapshot.version.n,
75901
75961
  contractHash: projectSnapshot.contractHash
75902
75962
  }, Buffer.from(svg, "utf8"));
75903
- } else (0, import_node_fs45.writeFileSync)(outPath, svg, "utf8");
75963
+ } else (0, import_node_fs46.writeFileSync)(outPath, svg, "utf8");
75904
75964
  return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
75905
75965
  } catch (e) {
75906
75966
  app.log.error({ appId: req.params.appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
@@ -75983,7 +76043,7 @@ async function startServer() {
75983
76043
  return reply.status(404).send({ ok: false, error: `"${id}" is not installed`, code: "not-installed" });
75984
76044
  }
75985
76045
  const contract = readAcceptedForRequest(id, void 0);
75986
- if (contract == null && (0, import_node_fs45.existsSync)(contractPath(id))) {
76046
+ if (contract == null && (0, import_node_fs46.existsSync)(contractPath(id))) {
75987
76047
  return reply.status(409).send({ ok: false, error: `"${id}"'s saved data is unreadable \u2014 open it in the editor and re-save before restoring`, code: "contract-corrupt" });
75988
76048
  }
75989
76049
  if (contract != null) {
@@ -76064,11 +76124,11 @@ async function startServer() {
76064
76124
  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 });
76065
76125
  }
76066
76126
  await deleteOrigin(id);
76067
- const stageRoot = (0, import_node_fs45.mkdtempSync)((0, import_node_path42.join)((0, import_node_os25.tmpdir)(), "floless-import-"));
76127
+ const stageRoot = (0, import_node_fs46.mkdtempSync)((0, import_node_path43.join)((0, import_node_os26.tmpdir)(), "floless-import-"));
76068
76128
  try {
76069
- const stageDir = (0, import_node_path42.join)(stageRoot, id);
76070
- (0, import_node_fs45.mkdirSync)(stageDir);
76071
- (0, import_node_fs45.writeFileSync)((0, import_node_path42.join)(stageDir, `${id}.flo`), content);
76129
+ const stageDir = (0, import_node_path43.join)(stageRoot, id);
76130
+ (0, import_node_fs46.mkdirSync)(stageDir);
76131
+ (0, import_node_fs46.writeFileSync)((0, import_node_path43.join)(stageDir, `${id}.flo`), content);
76072
76132
  await aware.install(stageDir);
76073
76133
  } catch (err2) {
76074
76134
  try {
@@ -76079,7 +76139,7 @@ async function startServer() {
76079
76139
  const reason = awareStderr(err2);
76080
76140
  return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
76081
76141
  } finally {
76082
- (0, import_node_fs45.rmSync)(stageRoot, { recursive: true, force: true });
76142
+ (0, import_node_fs46.rmSync)(stageRoot, { recursive: true, force: true });
76083
76143
  }
76084
76144
  broadcast({ type: "apps-changed", id });
76085
76145
  return { ok: true, id };
@@ -76094,13 +76154,13 @@ async function startServer() {
76094
76154
  }
76095
76155
  const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
76096
76156
  const baked = bakeFloSource(appData.source.text, inputs);
76097
- const tmpRoot = (0, import_node_fs45.mkdtempSync)((0, import_node_path42.join)((0, import_node_os25.tmpdir)(), "floless-bake-"));
76098
- const backupDir2 = (0, import_node_path42.join)(tmpRoot, `${id}-backup`);
76099
- const bakeDir = (0, import_node_path42.join)(tmpRoot, id);
76100
- (0, import_node_fs45.cpSync)(appDir(id), backupDir2, { recursive: true });
76101
- (0, import_node_fs45.cpSync)(appDir(id), bakeDir, { recursive: true });
76157
+ const tmpRoot = (0, import_node_fs46.mkdtempSync)((0, import_node_path43.join)((0, import_node_os26.tmpdir)(), "floless-bake-"));
76158
+ const backupDir2 = (0, import_node_path43.join)(tmpRoot, `${id}-backup`);
76159
+ const bakeDir = (0, import_node_path43.join)(tmpRoot, id);
76160
+ (0, import_node_fs46.cpSync)(appDir(id), backupDir2, { recursive: true });
76161
+ (0, import_node_fs46.cpSync)(appDir(id), bakeDir, { recursive: true });
76102
76162
  const floName = appData.source.path.split(/[\\/]/).pop();
76103
- (0, import_node_fs45.writeFileSync)((0, import_node_path42.join)(bakeDir, floName), baked);
76163
+ (0, import_node_fs46.writeFileSync)((0, import_node_path43.join)(bakeDir, floName), baked);
76104
76164
  let appInstalled2 = true;
76105
76165
  try {
76106
76166
  await aware.uninstall(id);
@@ -76122,17 +76182,17 @@ async function startServer() {
76122
76182
  throw installErr;
76123
76183
  }
76124
76184
  try {
76125
- await aware.compile((0, import_node_path42.join)(appDir(id), floName));
76185
+ await aware.compile((0, import_node_path43.join)(appDir(id), floName));
76126
76186
  } catch (compileErr) {
76127
76187
  app.log.warn({ id, compileErr: String(compileErr) }, "bake: post-install recompile failed (app baked but may need a manual Compile)");
76128
76188
  }
76129
76189
  broadcast({ type: "baked", id });
76130
76190
  return { ok: true, id, agent: id, inputs };
76131
76191
  } finally {
76132
- if (appInstalled2) (0, import_node_fs45.rmSync)(tmpRoot, { recursive: true, force: true });
76192
+ if (appInstalled2) (0, import_node_fs46.rmSync)(tmpRoot, { recursive: true, force: true });
76133
76193
  }
76134
76194
  });
76135
- const graftAgentsDir = () => (0, import_node_path42.join)((0, import_node_os25.homedir)(), ".aware", "agents");
76195
+ const graftAgentsDir = () => (0, import_node_path43.join)((0, import_node_os26.homedir)(), ".aware", "agents");
76136
76196
  app.post("/api/graft/match", async (req, reply) => {
76137
76197
  const { glob } = req.body ?? {};
76138
76198
  if (!glob) return reply.status(400).send({ ok: false, error: "glob required" });
@@ -76149,7 +76209,7 @@ async function startServer() {
76149
76209
  if (!sourceKind || !sourceRef) {
76150
76210
  return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
76151
76211
  }
76152
- const tempHome = (0, import_node_fs45.mkdtempSync)((0, import_node_path42.join)((0, import_node_os25.tmpdir)(), "floless-graft-"));
76212
+ const tempHome = (0, import_node_fs46.mkdtempSync)((0, import_node_path43.join)((0, import_node_os26.tmpdir)(), "floless-graft-"));
76153
76213
  let result;
76154
76214
  try {
76155
76215
  result = await aware.build({
@@ -76162,19 +76222,19 @@ async function startServer() {
76162
76222
  awareHome: tempHome
76163
76223
  });
76164
76224
  } catch (err2) {
76165
- (0, import_node_fs45.rmSync)(tempHome, { recursive: true, force: true });
76225
+ (0, import_node_fs46.rmSync)(tempHome, { recursive: true, force: true });
76166
76226
  const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
76167
76227
  return reply.status(422).send({ ok: false, error: msg });
76168
76228
  }
76169
76229
  const manifest = readStagedManifest(result.agentDir);
76170
76230
  if (!manifest) {
76171
- (0, import_node_fs45.rmSync)(tempHome, { recursive: true, force: true });
76231
+ (0, import_node_fs46.rmSync)(tempHome, { recursive: true, force: true });
76172
76232
  return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
76173
76233
  }
76174
76234
  const token = (0, import_node_crypto20.randomUUID)();
76175
76235
  registerStage(token, tempHome, result.agentId);
76176
76236
  const preview2 = buildPreview(manifest, sourceKind, sourceRef, token);
76177
- if ((0, import_node_fs45.existsSync)((0, import_node_path42.join)(graftAgentsDir(), result.agentId))) {
76237
+ if ((0, import_node_fs46.existsSync)((0, import_node_path43.join)(graftAgentsDir(), result.agentId))) {
76178
76238
  preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
76179
76239
  }
76180
76240
  return { ok: true, preview: preview2 };
@@ -76193,7 +76253,7 @@ async function startServer() {
76193
76253
  registerStage(stagedRef, stage.tempDir, stage.agentId);
76194
76254
  return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
76195
76255
  }
76196
- (0, import_node_fs45.rmSync)(stage.tempDir, { recursive: true, force: true });
76256
+ (0, import_node_fs46.rmSync)(stage.tempDir, { recursive: true, force: true });
76197
76257
  throw err2;
76198
76258
  }
76199
76259
  broadcast({ type: "grafted", id: stage.agentId });
@@ -76510,11 +76570,11 @@ async function startServer() {
76510
76570
  app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
76511
76571
  const n = Number.parseInt(req.params.n, 10);
76512
76572
  const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
76513
- if (!p || !(0, import_node_fs45.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
76573
+ if (!p || !(0, import_node_fs46.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
76514
76574
  const ext = p.split(".").pop().toLowerCase();
76515
76575
  reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
76516
76576
  reply.header("Cache-Control", "no-store");
76517
- return (0, import_node_fs45.readFileSync)(p);
76577
+ return (0, import_node_fs46.readFileSync)(p);
76518
76578
  });
76519
76579
  app.post(
76520
76580
  "/api/tweak",
@@ -76741,7 +76801,7 @@ async function startServer() {
76741
76801
  warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
76742
76802
  let finishedAt2 = null;
76743
76803
  try {
76744
- finishedAt2 = (0, import_node_fs45.statSync)(latest.path).mtime.toISOString();
76804
+ finishedAt2 = (0, import_node_fs46.statSync)(latest.path).mtime.toISOString();
76745
76805
  } catch {
76746
76806
  finishedAt2 = null;
76747
76807
  }
@@ -76751,7 +76811,7 @@ async function startServer() {
76751
76811
  let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
76752
76812
  if (!finishedAt) {
76753
76813
  try {
76754
- finishedAt = (0, import_node_fs45.statSync)(latest.path).mtime.toISOString();
76814
+ finishedAt = (0, import_node_fs46.statSync)(latest.path).mtime.toISOString();
76755
76815
  } catch {
76756
76816
  finishedAt = null;
76757
76817
  }