@floless/app 0.109.1 → 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);
@@ -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
  }
@@ -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;
@@ -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;
@@ -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
@@ -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);
@@ -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;
@@ -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);
@@ -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 {
@@ -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 {
@@ -53792,7 +53792,7 @@ function appVersion() {
53792
53792
  return resolveVersion({
53793
53793
  isSea: isSea2(),
53794
53794
  sqVersionXml: readSqVersionXml(),
53795
- define: true ? "0.109.1" : 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.1" : 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) {
@@ -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);
@@ -57871,7 +57896,7 @@ async function exportProjectZip(id) {
57871
57896
  const walk2 = async (abs, rel) => {
57872
57897
  const entries2 = await (0, import_promises.readdir)(abs, { withFileTypes: true });
57873
57898
  await Promise.all(entries2.map(async (e) => {
57874
- const childAbs = (0, import_node_path19.join)(abs, e.name);
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);
@@ -57922,7 +57947,7 @@ 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
57952
  const contractEntries = Object.keys(entries2).filter((p) => relOf(p) === "contract.json");
57928
57953
  if (contractEntries.length > 1) {
@@ -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
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");
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");
57987
58012
  function writeAtomic(path, text3) {
57988
58013
  const tmp = `${path}.${process.pid}.tmp`;
57989
- (0, import_node_fs22.writeFileSync)(tmp, text3);
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
58101
  for (const [hash2, text3] of blobs) {
58077
- const p = (0, import_node_path20.join)(objectsDir(id), hash2);
58078
- if (!(0, import_node_fs22.existsSync)(p)) writeAtomic(p, text3);
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 -->";
@@ -58668,14 +58693,14 @@ function eachPage(wikiDir, io, onPage) {
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 entries2 = (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);
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);
59053
59078
  const keep = new Set(entries2.slice(0, GEN_KEEP).map((e) => e.name));
59054
59079
  keep.add(currentGenerationId);
59055
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",
@@ -62619,8 +62644,8 @@ function registerRevisionRoutes(app) {
62619
62644
  }
62620
62645
 
62621
62646
  // project-export-files.ts
62622
- var import_node_fs26 = require("node:fs");
62623
- var import_node_path23 = require("node:path");
62647
+ var import_node_fs27 = require("node:fs");
62648
+ var import_node_path24 = require("node:path");
62624
62649
  function projectExportFiles(appId, kindOf2 = appId) {
62625
62650
  if (kindOf2 === "vectorize") {
62626
62651
  return [{ kind: "svg", filename: `${appId}.svg` }];
@@ -62648,26 +62673,26 @@ function exportFileBase(projectId, appId, now = /* @__PURE__ */ new Date()) {
62648
62673
  }
62649
62674
  function uniqueProjectExportFilename(projectId, preferred) {
62650
62675
  const dir = projectExportsDir(projectId);
62651
- if (!(0, import_node_fs26.existsSync)((0, import_node_path23.join)(dir, preferred))) return preferred;
62652
- 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);
62653
62678
  const stem = preferred.slice(0, preferred.length - extension.length);
62654
62679
  for (let suffix = 2; suffix <= 9999; suffix += 1) {
62655
62680
  const candidate = `${stem}-${suffix}${extension}`;
62656
- 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;
62657
62682
  }
62658
62683
  throw new Error("could not allocate a unique project export filename");
62659
62684
  }
62660
62685
 
62661
62686
  // project-export-receipts.ts
62662
62687
  var import_node_crypto15 = require("node:crypto");
62663
- var import_node_fs27 = require("node:fs");
62664
- var import_node_path25 = require("node:path");
62688
+ var import_node_fs28 = require("node:fs");
62689
+ var import_node_path26 = require("node:path");
62665
62690
 
62666
62691
  // safe-filename.ts
62667
- var import_node_path24 = require("node:path");
62692
+ var import_node_path25 = require("node:path");
62668
62693
  var WINDOWS_DEVICE = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i;
62669
62694
  function isPortablePlainFilename(name) {
62670
- 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;
62671
62696
  }
62672
62697
 
62673
62698
  // project-export-receipts.ts
@@ -62686,7 +62711,7 @@ var EXTENSIONS = {
62686
62711
  "render-mp4": ".mp4"
62687
62712
  };
62688
62713
  var RESERVED2 = /^\.floless-(?:txn|cleanup|tmp|backup)-/i;
62689
- 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");
62690
62715
  function hash(bytes) {
62691
62716
  return (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex");
62692
62717
  }
@@ -62694,13 +62719,13 @@ function proof(bytes) {
62694
62719
  return bytes ? { exists: true, bytes: bytes.length, sha256: hash(bytes) } : { exists: false, bytes: 0, sha256: null };
62695
62720
  }
62696
62721
  function readFileProof(path) {
62697
- 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);
62698
62723
  }
62699
62724
  function fileProofEquals(a, b) {
62700
62725
  return a.exists === b.exists && a.bytes === b.bytes && a.sha256 === b.sha256;
62701
62726
  }
62702
62727
  function validReceiptFilename(kind, filename) {
62703
- 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;
62704
62729
  return filename.toLowerCase().endsWith(EXTENSIONS[kind]);
62705
62730
  }
62706
62731
  function isExportKind(v) {
@@ -62793,45 +62818,45 @@ function indexBytes(body) {
62793
62818
  `, "utf8");
62794
62819
  }
62795
62820
  function syncFile(path) {
62796
- const fd2 = (0, import_node_fs27.openSync)(path, "r+");
62821
+ const fd2 = (0, import_node_fs28.openSync)(path, "r+");
62797
62822
  try {
62798
- (0, import_node_fs27.fsyncSync)(fd2);
62823
+ (0, import_node_fs28.fsyncSync)(fd2);
62799
62824
  } finally {
62800
- (0, import_node_fs27.closeSync)(fd2);
62825
+ (0, import_node_fs28.closeSync)(fd2);
62801
62826
  }
62802
62827
  }
62803
62828
  function syncDirectory(path) {
62804
62829
  try {
62805
- const fd2 = (0, import_node_fs27.openSync)(path, "r");
62830
+ const fd2 = (0, import_node_fs28.openSync)(path, "r");
62806
62831
  try {
62807
- (0, import_node_fs27.fsyncSync)(fd2);
62832
+ (0, import_node_fs28.fsyncSync)(fd2);
62808
62833
  } finally {
62809
- (0, import_node_fs27.closeSync)(fd2);
62834
+ (0, import_node_fs28.closeSync)(fd2);
62810
62835
  }
62811
62836
  } catch {
62812
62837
  }
62813
62838
  }
62814
62839
  function durableReplace(path, bytes) {
62815
- const dir = (0, import_node_path25.dirname)(path);
62816
- (0, import_node_fs27.mkdirSync)(dir, { recursive: true });
62817
- 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)()}`);
62818
62843
  try {
62819
- (0, import_node_fs27.writeFileSync)(tmp, bytes, { flag: "wx" });
62844
+ (0, import_node_fs28.writeFileSync)(tmp, bytes, { flag: "wx" });
62820
62845
  syncFile(tmp);
62821
- (0, import_node_fs27.renameSync)(tmp, path);
62846
+ (0, import_node_fs28.renameSync)(tmp, path);
62822
62847
  syncFile(path);
62823
62848
  syncDirectory(dir);
62824
62849
  } finally {
62825
62850
  try {
62826
- (0, import_node_fs27.rmSync)(tmp, { force: true });
62851
+ (0, import_node_fs28.rmSync)(tmp, { force: true });
62827
62852
  } catch {
62828
62853
  }
62829
62854
  }
62830
62855
  }
62831
62856
  function strictCurrent(projectId) {
62832
62857
  const path = projectExportIndexPath(projectId);
62833
- if (!(0, import_node_fs27.existsSync)(path)) return { bytes: null, body: { exports: [], opaque: [] } };
62834
- 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);
62835
62860
  return { bytes, body: parseIndexBytes(bytes) };
62836
62861
  }
62837
62862
  function listProjectExportReceipts(projectId) {
@@ -62843,14 +62868,14 @@ function listProjectExportReceipts(projectId) {
62843
62868
  }
62844
62869
  function resolveProjectExportReceiptPath(projectId, receipt) {
62845
62870
  if (!validReceiptFilename(receipt.kind, receipt.filename)) return null;
62846
- const dir = (0, import_node_path25.resolve)(projectExportsDir(projectId));
62847
- const path = (0, import_node_path25.resolve)(dir, receipt.filename);
62848
- 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;
62849
62874
  }
62850
62875
  function prepareProjectExport(projectId, receipt) {
62851
62876
  validateInput(receipt);
62852
62877
  const dir = projectExportsDir(projectId);
62853
- (0, import_node_fs27.mkdirSync)(dir, { recursive: true });
62878
+ (0, import_node_fs28.mkdirSync)(dir, { recursive: true });
62854
62879
  const current = strictCurrent(projectId);
62855
62880
  const key = receiptKey(receipt.kind, receipt.variant);
62856
62881
  const prior = current.body.exports.find((row) => receiptKey(row.kind, row.variant) === key) ?? null;
@@ -62919,8 +62944,8 @@ function restoreProjectExportTransition(transition) {
62919
62944
  }
62920
62945
  durableReplace(transition.indexPath, Buffer.from(transition.beforeBytesBase64, "base64"));
62921
62946
  } else {
62922
- (0, import_node_fs27.rmSync)(transition.indexPath, { force: true });
62923
- 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));
62924
62949
  }
62925
62950
  if (!currentMatches(transition.indexPath, transition.before)) {
62926
62951
  throw new ProjectExportReceiptError("project export index did not match the restored proof.");
@@ -62942,8 +62967,8 @@ function cleanupSupersededProjectExport(transition) {
62942
62967
  const path = resolveProjectExportReceiptPath(transition.projectId, superseded);
62943
62968
  if (!path) return;
62944
62969
  try {
62945
- (0, import_node_fs27.rmSync)(path, { force: true });
62946
- syncDirectory((0, import_node_path25.dirname)(path));
62970
+ (0, import_node_fs28.rmSync)(path, { force: true });
62971
+ syncDirectory((0, import_node_path26.dirname)(path));
62947
62972
  } catch {
62948
62973
  }
62949
62974
  }
@@ -62956,7 +62981,7 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
62956
62981
  if (!path) throw new ProjectExportReceiptError("project export artifact path is unsafe.");
62957
62982
  let wroteArtifact = false;
62958
62983
  try {
62959
- (0, import_node_fs27.writeFileSync)(path, bytes, { flag: "wx" });
62984
+ (0, import_node_fs28.writeFileSync)(path, bytes, { flag: "wx" });
62960
62985
  wroteArtifact = true;
62961
62986
  syncFile(path);
62962
62987
  commitProjectExportTransition(transition);
@@ -62971,8 +62996,8 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
62971
62996
  }
62972
62997
  if (!restoreError && wroteArtifact) {
62973
62998
  try {
62974
- (0, import_node_fs27.rmSync)(path, { force: true });
62975
- syncDirectory((0, import_node_path25.dirname)(path));
62999
+ (0, import_node_fs28.rmSync)(path, { force: true });
63000
+ syncDirectory((0, import_node_path26.dirname)(path));
62976
63001
  } catch {
62977
63002
  }
62978
63003
  }
@@ -62986,7 +63011,7 @@ function publishProjectExportArtifact(projectId, receipt, bytes) {
62986
63011
  }
62987
63012
  function receiptHasFile(projectId, receipt) {
62988
63013
  const path = resolveProjectExportReceiptPath(projectId, receipt);
62989
- return path !== null && (0, import_node_fs27.existsSync)(path);
63014
+ return path !== null && (0, import_node_fs28.existsSync)(path);
62990
63015
  }
62991
63016
  function matchingProjectExportReceipts(projectId, version, contractHash2, kinds) {
62992
63017
  const wanted = kinds ? new Set(kinds) : null;
@@ -63033,7 +63058,7 @@ function currentApprovedSnapshot(projectId, version) {
63033
63058
  }
63034
63059
 
63035
63060
  // workspace-data.ts
63036
- var import_node_fs28 = require("node:fs");
63061
+ var import_node_fs29 = require("node:fs");
63037
63062
  var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
63038
63063
  var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
63039
63064
  "bom-csv",
@@ -63093,15 +63118,15 @@ function exportBody(projectId, receipt, opts) {
63093
63118
  };
63094
63119
  if (opts.includePaths) body.path = path;
63095
63120
  if (opts.exportContents) {
63096
- const st = (0, import_node_fs28.statSync)(path);
63121
+ const st = (0, import_node_fs29.statSync)(path);
63097
63122
  if (st.size > opts.maxBytes) {
63098
63123
  body.contentOmitted = true;
63099
63124
  body.omittedReason = `export is ${st.size} bytes, over max-bytes ${opts.maxBytes}`;
63100
63125
  } else if (receipt.encoding === "base64") {
63101
- body.content = (0, import_node_fs28.readFileSync)(path).toString("base64");
63126
+ body.content = (0, import_node_fs29.readFileSync)(path).toString("base64");
63102
63127
  } else {
63103
63128
  body.encoding = receipt.encoding ?? "utf8";
63104
- body.content = (0, import_node_fs28.readFileSync)(path, "utf8");
63129
+ body.content = (0, import_node_fs29.readFileSync)(path, "utf8");
63105
63130
  }
63106
63131
  }
63107
63132
  return body;
@@ -64517,18 +64542,18 @@ function registerMigrationPreviewRoute(app, deps) {
64517
64542
  }
64518
64543
 
64519
64544
  // workspace-agent-manifest.ts
64520
- var import_node_fs29 = require("node:fs");
64521
- var import_node_os15 = require("node:os");
64522
- 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");
64523
64548
  function awareHome() {
64524
- 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");
64525
64550
  }
64526
64551
  function workspaceAgentDir() {
64527
- return (0, import_node_path26.join)(awareHome(), "agents", "floless-workspace");
64552
+ return (0, import_node_path27.join)(awareHome(), "agents", "floless-workspace");
64528
64553
  }
64529
64554
  function syncWorkspaceAgentManifest(port) {
64530
64555
  const dir = workspaceAgentDir();
64531
- (0, import_node_fs29.mkdirSync)(dir, { recursive: true });
64556
+ (0, import_node_fs30.mkdirSync)(dir, { recursive: true });
64532
64557
  const manifest = `agent: floless-workspace
64533
64558
  version: 0.2.0
64534
64559
  sdk-target: 2.4.0
@@ -64658,8 +64683,8 @@ commands:
64658
64683
  headers: object
64659
64684
  body: object
64660
64685
  `;
64661
- const path = (0, import_node_path26.join)(dir, "manifest.yaml");
64662
- 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");
64663
64688
  return path;
64664
64689
  }
64665
64690
 
@@ -65652,7 +65677,7 @@ function computeVersionDiff(id, n, base) {
65652
65677
  }
65653
65678
 
65654
65679
  // contract-bake.ts
65655
- var import_node_fs30 = require("node:fs");
65680
+ var import_node_fs31 = require("node:fs");
65656
65681
  var import_yaml7 = __toESM(require_dist6(), 1);
65657
65682
  function bakedV2(contract) {
65658
65683
  const baked = { ...contract };
@@ -65672,7 +65697,7 @@ function bakedV2(contract) {
65672
65697
  return stripConfidentialImages(baked);
65673
65698
  }
65674
65699
  function bakeContractIntoApp(sourcePath, contract) {
65675
- 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"));
65676
65701
  if (doc.errors.length > 0) {
65677
65702
  throw new Error(`contract bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
65678
65703
  }
@@ -65689,7 +65714,7 @@ function bakeContractIntoApp(sourcePath, contract) {
65689
65714
  throw new InvalidModelV2Error(`refusing to bake: contract declares steel.model/v2 but is not valid v2: ${issues[0] ?? "unknown"}`, issues);
65690
65715
  }
65691
65716
  doc.setIn(["nodes", idx, "config", "takeoff"], bakedV2(contract));
65692
- (0, import_node_fs30.writeFileSync)(sourcePath, doc.toString());
65717
+ (0, import_node_fs31.writeFileSync)(sourcePath, doc.toString());
65693
65718
  return;
65694
65719
  }
65695
65720
  const baked = { ...contract };
@@ -65734,7 +65759,7 @@ function bakeContractIntoApp(sourcePath, contract) {
65734
65759
  );
65735
65760
  }
65736
65761
  doc.setIn(["nodes", idx, "config", "takeoff"], baked);
65737
- (0, import_node_fs30.writeFileSync)(sourcePath, doc.toString());
65762
+ (0, import_node_fs31.writeFileSync)(sourcePath, doc.toString());
65738
65763
  }
65739
65764
 
65740
65765
  // vectorize.ts
@@ -66091,11 +66116,11 @@ function viewsToScene(contractInput) {
66091
66116
  }
66092
66117
 
66093
66118
  // bom-export.ts
66094
- var import_node_os16 = require("node:os");
66095
- var import_node_path27 = require("node:path");
66119
+ var import_node_os17 = require("node:os");
66120
+ var import_node_path28 = require("node:path");
66096
66121
 
66097
66122
  // node_modules/write-excel-file/modules/export/writeXlsxFileNode.js
66098
- var import_node_fs31 = __toESM(require("node:fs"), 1);
66123
+ var import_node_fs32 = __toESM(require("node:fs"), 1);
66099
66124
 
66100
66125
  // node_modules/write-excel-file/modules/xlsx/helpers/features/getAdditionalContent.js
66101
66126
  function _createForOfIteratorHelperLoose(r, e) {
@@ -69195,7 +69220,7 @@ function writeXlsxFile(arg1, arg2, arg3) {
69195
69220
  },
69196
69221
  toFile: function toFile(filePath) {
69197
69222
  return createReadableStream().then(function(readableStream) {
69198
- return pipe(readableStream, import_node_fs31.default.createWriteStream(filePath));
69223
+ return pipe(readableStream, import_node_fs32.default.createWriteStream(filePath));
69199
69224
  });
69200
69225
  }
69201
69226
  };
@@ -69220,8 +69245,8 @@ function pipe(readableStream, writableStream) {
69220
69245
 
69221
69246
  // bom-export.ts
69222
69247
  function bomExportPath(appId, format) {
69223
- const root3 = process.env.FLOLESS_HOME ?? (0, import_node_path27.join)((0, import_node_os16.homedir)(), ".floless");
69224
- 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}`);
69225
69250
  }
69226
69251
  function csvField(v) {
69227
69252
  let s = String(v);
@@ -69266,11 +69291,11 @@ async function bomToXlsx(bom) {
69266
69291
  }
69267
69292
 
69268
69293
  // scene-bake.ts
69269
- var import_node_fs32 = require("node:fs");
69270
- var import_node_path28 = require("node:path");
69294
+ var import_node_fs33 = require("node:fs");
69295
+ var import_node_path29 = require("node:path");
69271
69296
  var import_yaml8 = __toESM(require_dist6(), 1);
69272
69297
  function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
69273
- 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"));
69274
69299
  if (doc.errors.length > 0) {
69275
69300
  throw new Error(`scene bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
69276
69301
  }
@@ -69279,10 +69304,10 @@ function bakeSceneIntoApp(sourcePath, scene, agent = "viewer-3d") {
69279
69304
  const idx = items.findIndex((it) => ((0, import_yaml8.isMap)(it) ? it.toJSON() : null)?.agent === agent);
69280
69305
  if (idx < 0) throw new Error(`no ${agent} render node to bake the scene into`);
69281
69306
  doc.setIn(["nodes", idx, "config", "scene"], scene);
69282
- (0, import_node_fs32.writeFileSync)(sourcePath, doc.toString());
69307
+ (0, import_node_fs33.writeFileSync)(sourcePath, doc.toString());
69283
69308
  }
69284
69309
  function bakeNodeConfigById(sourcePath, nodeId, patch2) {
69285
- 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"));
69286
69311
  if (doc.errors.length > 0) {
69287
69312
  throw new Error(`node bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
69288
69313
  }
@@ -69291,12 +69316,12 @@ function bakeNodeConfigById(sourcePath, nodeId, patch2) {
69291
69316
  const idx = items.findIndex((it) => ((0, import_yaml8.isMap)(it) ? it.toJSON() : null)?.id === nodeId);
69292
69317
  if (idx < 0) throw new Error(`no node with id "${nodeId}"`);
69293
69318
  for (const [key, value] of Object.entries(patch2)) doc.setIn(["nodes", idx, "config", key], value);
69294
- (0, import_node_fs32.writeFileSync)(sourcePath, doc.toString());
69319
+ (0, import_node_fs33.writeFileSync)(sourcePath, doc.toString());
69295
69320
  }
69296
69321
  function writeViewer3dApp(dir, appId, scene) {
69297
- (0, import_node_fs32.mkdirSync)(dir, { recursive: true });
69298
- const flo = (0, import_node_path28.join)(dir, `${appId}.flo`);
69299
- (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, [
69300
69325
  `app: ${appId}`,
69301
69326
  "version: 0.1.0",
69302
69327
  "display-name: Steel 3D",
@@ -69317,9 +69342,9 @@ function writeViewer3dApp(dir, appId, scene) {
69317
69342
  return flo;
69318
69343
  }
69319
69344
  function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
69320
- (0, import_node_fs32.mkdirSync)(dir, { recursive: true });
69321
- const flo = (0, import_node_path28.join)(dir, `${appId}.flo`);
69322
- (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, [
69323
69348
  `app: ${appId}`,
69324
69349
  "version: 0.1.0",
69325
69350
  "display-name: Steel to Tekla",
@@ -69423,9 +69448,9 @@ async function teklaVersionToBake() {
69423
69448
 
69424
69449
  // ifc-publication.ts
69425
69450
  var import_node_crypto17 = require("node:crypto");
69426
- var import_node_fs33 = require("node:fs");
69427
- var import_node_os17 = require("node:os");
69428
- 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");
69429
69454
  var IfcPublicationError = class extends Error {
69430
69455
  constructor(message) {
69431
69456
  super(message);
@@ -69457,37 +69482,37 @@ function sameProof(path, expected) {
69457
69482
  return fileProofEquals(readFileProof(path), expected);
69458
69483
  }
69459
69484
  function syncFile2(path) {
69460
- const fd2 = (0, import_node_fs33.openSync)(path, "r+");
69485
+ const fd2 = (0, import_node_fs34.openSync)(path, "r+");
69461
69486
  try {
69462
- (0, import_node_fs33.fsyncSync)(fd2);
69487
+ (0, import_node_fs34.fsyncSync)(fd2);
69463
69488
  } finally {
69464
- (0, import_node_fs33.closeSync)(fd2);
69489
+ (0, import_node_fs34.closeSync)(fd2);
69465
69490
  }
69466
69491
  }
69467
69492
  function syncDirectory2(path) {
69468
69493
  try {
69469
- const fd2 = (0, import_node_fs33.openSync)(path, "r");
69494
+ const fd2 = (0, import_node_fs34.openSync)(path, "r");
69470
69495
  try {
69471
- (0, import_node_fs33.fsyncSync)(fd2);
69496
+ (0, import_node_fs34.fsyncSync)(fd2);
69472
69497
  } finally {
69473
- (0, import_node_fs33.closeSync)(fd2);
69498
+ (0, import_node_fs34.closeSync)(fd2);
69474
69499
  }
69475
69500
  } catch {
69476
69501
  }
69477
69502
  }
69478
69503
  function durableReplace2(path, bytes) {
69479
- const dir = (0, import_node_path29.dirname)(path);
69480
- (0, import_node_fs33.mkdirSync)(dir, { recursive: true });
69481
- 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)()}`);
69482
69507
  try {
69483
- (0, import_node_fs33.writeFileSync)(tmp, bytes, { flag: "wx" });
69508
+ (0, import_node_fs34.writeFileSync)(tmp, bytes, { flag: "wx" });
69484
69509
  syncFile2(tmp);
69485
- (0, import_node_fs33.renameSync)(tmp, path);
69510
+ (0, import_node_fs34.renameSync)(tmp, path);
69486
69511
  syncFile2(path);
69487
69512
  syncDirectory2(dir);
69488
69513
  } finally {
69489
69514
  try {
69490
- (0, import_node_fs33.rmSync)(tmp, { force: true });
69515
+ (0, import_node_fs34.rmSync)(tmp, { force: true });
69491
69516
  } catch {
69492
69517
  }
69493
69518
  }
@@ -69499,26 +69524,26 @@ function plainIfcFilename(name) {
69499
69524
  return isPortablePlainFilename(name) && name.toLowerCase().endsWith(".ifc") && !name.toLowerCase().startsWith(".floless-");
69500
69525
  }
69501
69526
  function canonicalPath(path) {
69502
- return (0, import_node_path29.resolve)(path);
69527
+ return (0, import_node_path30.resolve)(path);
69503
69528
  }
69504
69529
  function validateRequestPaths(tempPath, finalPath) {
69505
69530
  const final = canonicalPath(finalPath);
69506
69531
  const temp = canonicalPath(tempPath);
69507
- const dir = (0, import_node_path29.dirname)(final);
69508
- if ((0, import_node_path29.dirname)(temp) !== dir) throw new IfcPublicationError("IFC temp and final paths must share one directory.");
69509
- if (!plainIfcFilename((0, import_node_path29.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
69510
- 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.");
69511
69536
  return { dir, temp, final };
69512
69537
  }
69513
69538
  function requestIfcTempPath(finalPath) {
69514
69539
  const final = canonicalPath(finalPath);
69515
- if (!plainIfcFilename((0, import_node_path29.basename)(final))) throw new IfcPublicationError("IFC final filename is unsafe.");
69516
- (0, import_node_fs33.mkdirSync)((0, import_node_path29.dirname)(final), { recursive: true });
69517
- 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`);
69518
69543
  }
69519
69544
  function validateIfc(path) {
69520
- if (!(0, import_node_fs33.existsSync)(path) || (0, import_node_fs33.statSync)(path).size === 0) throw new IfcPublicationError("the IFC export produced no file");
69521
- 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);
69522
69547
  const prefix = bytes.subarray(0, Math.min(bytes.length, 128)).toString("utf8");
69523
69548
  if (!prefix.includes("ISO-10303-21")) throw new IfcPublicationError("the IFC export did not produce a valid STEP envelope");
69524
69549
  return { bytes, proof: proof2(bytes) };
@@ -69531,21 +69556,21 @@ function metadataEqual(a, b) {
69531
69556
  function writePhase(txnDir, journal) {
69532
69557
  const index = PHASES.indexOf(journal.phase);
69533
69558
  if (index < 0) throw new IfcPublicationError(`unknown IFC publication phase "${journal.phase}".`);
69534
- const destination = (0, import_node_path29.join)(txnDir, `${String(index).padStart(3, "0")}-${journal.phase}.json`);
69535
- if ((0, import_node_fs33.existsSync)(destination)) throw new IfcPublicationError(`IFC publication phase "${journal.phase}" already exists.`);
69536
- 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`);
69537
69562
  const bytes = Buffer.from(`${JSON.stringify(journal, null, 2)}
69538
69563
  `, "utf8");
69539
69564
  try {
69540
- (0, import_node_fs33.writeFileSync)(temp, bytes, { flag: "wx" });
69565
+ (0, import_node_fs34.writeFileSync)(temp, bytes, { flag: "wx" });
69541
69566
  syncFile2(temp);
69542
- (0, import_node_fs33.renameSync)(temp, destination);
69567
+ (0, import_node_fs34.renameSync)(temp, destination);
69543
69568
  syncFile2(destination);
69544
69569
  syncDirectory2(txnDir);
69545
- syncDirectory2((0, import_node_path29.dirname)(txnDir));
69570
+ syncDirectory2((0, import_node_path30.dirname)(txnDir));
69546
69571
  } finally {
69547
69572
  try {
69548
- (0, import_node_fs33.rmSync)(temp, { force: true });
69573
+ (0, import_node_fs34.rmSync)(temp, { force: true });
69549
69574
  } catch {
69550
69575
  }
69551
69576
  }
@@ -69565,12 +69590,12 @@ function validateJournal(raw, txnDir, expectedTxnId) {
69565
69590
  const resource = j.resource;
69566
69591
  if (!validResource(resource)) throw new IfcPublicationError("IFC journal resource is invalid.");
69567
69592
  const exportDir = canonicalPath(String(j.exportDir));
69568
- const actualDir = canonicalPath((0, import_node_path29.dirname)(txnDir));
69593
+ const actualDir = canonicalPath((0, import_node_path30.dirname)(txnDir));
69569
69594
  if (exportDir !== actualDir) throw new IfcPublicationError("IFC journal export directory is not canonical.");
69570
69595
  const finalPath = canonicalPath(String(j.finalPath));
69571
69596
  const tempPath = canonicalPath(String(j.tempPath));
69572
69597
  const backupPath = canonicalPath(String(j.backupPath));
69573
- 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.");
69574
69599
  const journal = {
69575
69600
  version: 1,
69576
69601
  txnId: expectedTxnId,
@@ -69590,7 +69615,7 @@ function validateJournal(raw, txnDir, expectedTxnId) {
69590
69615
  }
69591
69616
  if (journal.mode === "artifact-with-receipt") {
69592
69617
  const indexPath = canonicalPath(String(j.indexPath));
69593
- 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") {
69594
69619
  throw new IfcPublicationError("IFC journal receipt index path is unsafe.");
69595
69620
  }
69596
69621
  journal.indexPath = indexPath;
@@ -69608,10 +69633,10 @@ function validateJournal(raw, txnDir, expectedTxnId) {
69608
69633
  return journal;
69609
69634
  }
69610
69635
  function loadJournal(txnDir) {
69611
- const match = (0, import_node_path29.basename)(txnDir).match(ACTIVE_RE);
69612
- 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)}".`);
69613
69638
  const txnId = match[1];
69614
- const entries2 = (0, import_node_fs33.readdirSync)(txnDir, { withFileTypes: true });
69639
+ const entries2 = (0, import_node_fs34.readdirSync)(txnDir, { withFileTypes: true });
69615
69640
  if (!entries2.length) return null;
69616
69641
  const phaseFiles = entries2.filter((entry2) => entry2.isFile() && PHASE_RE.test(entry2.name)).sort((a, b) => a.name.localeCompare(b.name));
69617
69642
  const unknown = entries2.filter((entry2) => !(entry2.isFile() && (PHASE_RE.test(entry2.name) || /^\.phase-[a-f0-9-]+\.tmp$/i.test(entry2.name))));
@@ -69625,11 +69650,11 @@ function loadJournal(txnDir) {
69625
69650
  const declaredIndex = Number(phaseMatch[1]);
69626
69651
  const declaredPhase = phaseMatch[2];
69627
69652
  if (declaredIndex !== index || PHASES[index] !== declaredPhase) break;
69628
- const path = (0, import_node_path29.join)(txnDir, entry2.name);
69629
- 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;
69630
69655
  let parsed;
69631
69656
  try {
69632
- parsed = JSON.parse((0, import_node_fs33.readFileSync)(path, "utf8"));
69657
+ parsed = JSON.parse((0, import_node_fs34.readFileSync)(path, "utf8"));
69633
69658
  } catch {
69634
69659
  break;
69635
69660
  }
@@ -69656,8 +69681,8 @@ function restoreIndex(journal) {
69656
69681
  if (journal.priorIndex.exists) {
69657
69682
  durableReplace2(indexPath, Buffer.from(journal.priorIndexBase64, "base64"));
69658
69683
  } else {
69659
- (0, import_node_fs33.rmSync)(indexPath, { force: true });
69660
- syncDirectory2((0, import_node_path29.dirname)(indexPath));
69684
+ (0, import_node_fs34.rmSync)(indexPath, { force: true });
69685
+ syncDirectory2((0, import_node_path30.dirname)(indexPath));
69661
69686
  }
69662
69687
  if (!sameProof(indexPath, journal.priorIndex)) {
69663
69688
  throw new IfcPublicationError("receipt index restore did not match its recorded proof.");
@@ -69672,14 +69697,14 @@ function restoreArtifact(journal) {
69672
69697
  if (!fileProofEquals(backup, journal.priorArtifact)) {
69673
69698
  throw new IfcPublicationError("IFC backup does not match the recorded prior artifact.");
69674
69699
  }
69675
- (0, import_node_fs33.rmSync)(journal.backupPath, { force: true });
69700
+ (0, import_node_fs34.rmSync)(journal.backupPath, { force: true });
69676
69701
  }
69677
69702
  } else if (!final.exists || fileProofEquals(final, journal.newArtifact)) {
69678
69703
  if (!fileProofEquals(backup, journal.priorArtifact)) {
69679
69704
  throw new IfcPublicationError("IFC prior artifact cannot be proven for rollback.");
69680
69705
  }
69681
- if (final.exists) (0, import_node_fs33.rmSync)(journal.finalPath, { force: true });
69682
- (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);
69683
69708
  syncFile2(journal.finalPath);
69684
69709
  } else {
69685
69710
  throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
@@ -69692,25 +69717,25 @@ function restoreArtifact(journal) {
69692
69717
  if (!fileProofEquals(final, journal.newArtifact)) {
69693
69718
  throw new IfcPublicationError("IFC final artifact is in an unknown state; recovery retained evidence.");
69694
69719
  }
69695
- (0, import_node_fs33.rmSync)(journal.finalPath, { force: true });
69720
+ (0, import_node_fs34.rmSync)(journal.finalPath, { force: true });
69696
69721
  }
69697
69722
  if (backup.exists) throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
69698
69723
  }
69699
- if ((0, import_node_fs33.existsSync)(journal.tempPath)) {
69724
+ if ((0, import_node_fs34.existsSync)(journal.tempPath)) {
69700
69725
  if (!sameProof(journal.tempPath, journal.newArtifact)) {
69701
69726
  throw new IfcPublicationError("IFC temp artifact does not match its recorded proof.");
69702
69727
  }
69703
- (0, import_node_fs33.rmSync)(journal.tempPath, { force: true });
69728
+ (0, import_node_fs34.rmSync)(journal.tempPath, { force: true });
69704
69729
  }
69705
69730
  syncDirectory2(journal.exportDir);
69706
69731
  }
69707
69732
  function retireTransaction(txnDir) {
69708
- const match = (0, import_node_path29.basename)(txnDir).match(ACTIVE_RE);
69733
+ const match = (0, import_node_path30.basename)(txnDir).match(ACTIVE_RE);
69709
69734
  if (!match) throw new IfcPublicationError("cannot retire an unsafe IFC transaction directory.");
69710
- const cleanupDir = (0, import_node_path29.join)((0, import_node_path29.dirname)(txnDir), `.floless-cleanup-ifc-${match[1]}`);
69711
- if ((0, import_node_fs33.existsSync)(cleanupDir)) throw new IfcPublicationError("IFC cleanup directory already exists.");
69712
- (0, import_node_fs33.renameSync)(txnDir, cleanupDir);
69713
- 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));
69714
69739
  return cleanupDir;
69715
69740
  }
69716
69741
  function finishCommitted(txnDir, journal, allowMissingBackup) {
@@ -69726,7 +69751,7 @@ function finishCommitted(txnDir, journal, allowMissingBackup) {
69726
69751
  if (!fileProofEquals(backup, journal.priorArtifact)) {
69727
69752
  throw new IfcPublicationError("committed IFC backup does not match the recorded prior artifact.");
69728
69753
  }
69729
- (0, import_node_fs33.rmSync)(journal.backupPath, { force: true });
69754
+ (0, import_node_fs34.rmSync)(journal.backupPath, { force: true });
69730
69755
  syncDirectory2(journal.exportDir);
69731
69756
  } else if (!allowMissingBackup) {
69732
69757
  throw new IfcPublicationError("committed IFC backup disappeared before verified cleanup.");
@@ -69735,18 +69760,18 @@ function finishCommitted(txnDir, journal, allowMissingBackup) {
69735
69760
  throw new IfcPublicationError("unexpected committed IFC backup exists for a no-prior transaction.");
69736
69761
  }
69737
69762
  const cleanupDir = retireTransaction(txnDir);
69738
- (0, import_node_fs33.rmSync)(cleanupDir, { recursive: true, force: true });
69763
+ (0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
69739
69764
  syncDirectory2(journal.exportDir);
69740
69765
  }
69741
69766
  function rollbackTransaction(txnDir, journal) {
69742
69767
  restoreArtifact(journal);
69743
69768
  restoreIndex(journal);
69744
69769
  const cleanupDir = retireTransaction(txnDir);
69745
- (0, import_node_fs33.rmSync)(cleanupDir, { recursive: true, force: true });
69770
+ (0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
69746
69771
  syncDirectory2(journal.exportDir);
69747
69772
  }
69748
69773
  function safeTransactionDirectory(path) {
69749
- const st = (0, import_node_fs33.lstatSync)(path);
69774
+ const st = (0, import_node_fs34.lstatSync)(path);
69750
69775
  if (!st.isDirectory() || st.isSymbolicLink()) {
69751
69776
  throw new IfcPublicationError(`IFC transaction path is not a plain directory: ${path}`);
69752
69777
  }
@@ -69756,7 +69781,7 @@ async function recoverActive(txnDir, expected) {
69756
69781
  const journal = loadJournal(txnDir);
69757
69782
  if (!journal) {
69758
69783
  const cleanupDir = retireTransaction(txnDir);
69759
- (0, import_node_fs33.rmSync)(cleanupDir, { recursive: true, force: true });
69784
+ (0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
69760
69785
  return;
69761
69786
  }
69762
69787
  if (expected && (journal.resource.kind !== expected.kind || journal.resource.key !== expected.key)) {
@@ -69769,18 +69794,18 @@ async function recoverActive(txnDir, expected) {
69769
69794
  }
69770
69795
  async function recoverIfcPublicationsInDirectory(exportDir, expected) {
69771
69796
  const dir = canonicalPath(exportDir);
69772
- if (!(0, import_node_fs33.existsSync)(dir)) return [];
69797
+ if (!(0, import_node_fs34.existsSync)(dir)) return [];
69773
69798
  safeTransactionDirectory(dir);
69774
- const entries2 = (0, import_node_fs33.readdirSync)(dir, { withFileTypes: true }).filter((entry2) => ACTIVE_RE.test(entry2.name) || CLEANUP_RE.test(entry2.name));
69799
+ const entries2 = (0, import_node_fs34.readdirSync)(dir, { withFileTypes: true }).filter((entry2) => ACTIVE_RE.test(entry2.name) || CLEANUP_RE.test(entry2.name));
69775
69800
  if (entries2.length > MAX_TRANSACTIONS) {
69776
69801
  throw new IfcPublicationError(`IFC recovery refused ${entries2.length} transaction directories (limit ${MAX_TRANSACTIONS}).`);
69777
69802
  }
69778
69803
  const recovered = [];
69779
69804
  for (const entry2 of entries2) {
69780
- const path = (0, import_node_path29.join)(dir, entry2.name);
69805
+ const path = (0, import_node_path30.join)(dir, entry2.name);
69781
69806
  safeTransactionDirectory(path);
69782
69807
  if (CLEANUP_RE.test(entry2.name)) {
69783
- (0, import_node_fs33.rmSync)(path, { recursive: true, force: true });
69808
+ (0, import_node_fs34.rmSync)(path, { recursive: true, force: true });
69784
69809
  syncDirectory2(dir);
69785
69810
  recovered.push(entry2.name);
69786
69811
  continue;
@@ -69792,32 +69817,32 @@ async function recoverIfcPublicationsInDirectory(exportDir, expected) {
69792
69817
  }
69793
69818
  async function recoverAllIfcPublications() {
69794
69819
  const recovered = [];
69795
- const rootHome = process.env.FLOLESS_HOME ?? (0, import_node_path29.join)((0, import_node_os17.homedir)(), ".floless");
69796
- const projectsRoot2 = (0, import_node_path29.join)(rootHome, "projects");
69797
- 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)) {
69798
69823
  safeTransactionDirectory(projectsRoot2);
69799
- 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 })) {
69800
69825
  if (entry2.name.startsWith(".")) continue;
69801
69826
  if (entry2.isSymbolicLink()) throw new IfcPublicationError(`project recovery root is a link: ${entry2.name}`);
69802
69827
  if (!entry2.isDirectory() || !/^[a-z0-9][a-z0-9-]*$/.test(entry2.name)) continue;
69803
- const projectPath = (0, import_node_path29.join)(projectsRoot2, entry2.name);
69828
+ const projectPath = (0, import_node_path30.join)(projectsRoot2, entry2.name);
69804
69829
  safeTransactionDirectory(projectPath);
69805
69830
  const dir = projectExportsDir(entry2.name);
69806
69831
  const names = await recoverIfcPublicationsInDirectory(dir, { kind: "project", key: entry2.name });
69807
69832
  recovered.push(...names.map((name) => `${entry2.name}/${name}`));
69808
69833
  }
69809
69834
  }
69810
- const root3 = (0, import_node_path29.join)(rootHome, "exports");
69811
- if ((0, import_node_fs33.existsSync)(root3)) {
69812
- safeTransactionDirectory(root3);
69813
- 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 })) {
69814
69839
  if (entry2.name.startsWith(".")) continue;
69815
69840
  if (entry2.isSymbolicLink()) throw new IfcPublicationError(`workflow recovery root is a link: ${entry2.name}`);
69816
69841
  if (!entry2.isDirectory()) continue;
69817
69842
  if (!/^[A-Za-z0-9._-]+$/.test(entry2.name)) continue;
69818
- safeTransactionDirectory((0, import_node_path29.join)(root3, entry2.name));
69843
+ safeTransactionDirectory((0, import_node_path30.join)(root4, entry2.name));
69819
69844
  const names = await recoverIfcPublicationsInDirectory(
69820
- (0, import_node_path29.join)(root3, entry2.name),
69845
+ (0, import_node_path30.join)(root4, entry2.name),
69821
69846
  { kind: "app", key: entry2.name }
69822
69847
  );
69823
69848
  recovered.push(...names.map((name) => `${entry2.name}/${name}`));
@@ -69827,8 +69852,8 @@ async function recoverAllIfcPublications() {
69827
69852
  }
69828
69853
  function assertReceiptOptions(receipt, resource, exportDir, finalPath, artifact) {
69829
69854
  const transition = receipt.transition;
69830
- 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.");
69831
- 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.");
69832
69857
  const beforeSnapshot = transition.beforeBytesBase64 === null ? null : Buffer.from(transition.beforeBytesBase64, "base64");
69833
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.");
69834
69859
  if (!fileProofEquals(readFileProof(transition.indexPath), transition.before)) {
@@ -69841,7 +69866,7 @@ function promiseLike(value) {
69841
69866
  async function publishIfcAtomically(tempPath, finalPath, options) {
69842
69867
  if (!options || !validResource(options.resource)) throw new IfcPublicationError("IFC publication resource is invalid.");
69843
69868
  const paths = validateRequestPaths(tempPath, finalPath);
69844
- const tempStat = (0, import_node_fs33.lstatSync)(paths.temp);
69869
+ const tempStat = (0, import_node_fs34.lstatSync)(paths.temp);
69845
69870
  if (!tempStat.isFile()) throw new IfcPublicationError("the IFC to publish is not a regular file.");
69846
69871
  const validated = validateIfc(paths.temp);
69847
69872
  if (options.expectedContentSha256 !== void 0 && validated.proof.sha256 !== options.expectedContentSha256) {
@@ -69854,8 +69879,8 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69854
69879
  return withLifecycleLock(options.resource.kind, options.resource.key, async () => {
69855
69880
  await recoverIfcPublicationsInDirectory(paths.dir, options.resource);
69856
69881
  const txnId = (0, import_node_crypto17.randomUUID)();
69857
- const txnDir = (0, import_node_path29.join)(paths.dir, `.floless-txn-ifc-${txnId}`);
69858
- 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`);
69859
69884
  const priorArtifact = readFileProof(paths.final);
69860
69885
  const transition = options.receipt?.transition;
69861
69886
  const base = {
@@ -69879,7 +69904,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69879
69904
  };
69880
69905
  let journal = { ...base, phase: "prepared" };
69881
69906
  let committed = false;
69882
- (0, import_node_fs33.mkdirSync)(txnDir);
69907
+ (0, import_node_fs34.mkdirSync)(txnDir);
69883
69908
  syncDirectory2(paths.dir);
69884
69909
  const hit = (point) => {
69885
69910
  options.fault?.(point);
@@ -69895,11 +69920,11 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69895
69920
  phase("prepared");
69896
69921
  phase("backing-up");
69897
69922
  if (priorArtifact.exists) {
69898
- (0, import_node_fs33.renameSync)(paths.final, backupPath);
69923
+ (0, import_node_fs34.renameSync)(paths.final, backupPath);
69899
69924
  syncDirectory2(paths.dir);
69900
69925
  }
69901
69926
  phase("promoting");
69902
- (0, import_node_fs33.renameSync)(paths.temp, paths.final);
69927
+ (0, import_node_fs34.renameSync)(paths.temp, paths.final);
69903
69928
  syncFile2(paths.final);
69904
69929
  syncDirectory2(paths.dir);
69905
69930
  if (!sameProof(paths.final, validated.proof)) {
@@ -69928,7 +69953,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69928
69953
  if (!fileProofEquals(backup, priorArtifact)) {
69929
69954
  throw new IfcPublicationError("IFC backup did not match the recorded prior artifact before cleanup.");
69930
69955
  }
69931
- (0, import_node_fs33.rmSync)(backupPath, { force: true });
69956
+ (0, import_node_fs34.rmSync)(backupPath, { force: true });
69932
69957
  syncDirectory2(paths.dir);
69933
69958
  } else if (backup.exists) {
69934
69959
  throw new IfcPublicationError("unexpected IFC backup exists for a no-prior transaction.");
@@ -69938,7 +69963,7 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69938
69963
  const cleanupDir = retireTransaction(txnDir);
69939
69964
  hit("after-retire");
69940
69965
  hit("before-cleanup-remove");
69941
- (0, import_node_fs33.rmSync)(cleanupDir, { recursive: true, force: true });
69966
+ (0, import_node_fs34.rmSync)(cleanupDir, { recursive: true, force: true });
69942
69967
  syncDirectory2(paths.dir);
69943
69968
  return { bytes: validated.bytes, cleanupPending: false };
69944
69969
  } catch (error) {
@@ -69981,14 +70006,14 @@ async function publishIfcAtomically(tempPath, finalPath, options) {
69981
70006
  });
69982
70007
  }
69983
70008
  function cleanupIfcTemp(path) {
69984
- if (!TEMP_RE.test((0, import_node_path29.basename)(path))) return;
70009
+ if (!TEMP_RE.test((0, import_node_path30.basename)(path))) return;
69985
70010
  const canonical = canonicalPath(path);
69986
- const dir = (0, import_node_path29.dirname)(canonical);
69987
- if ((0, import_node_fs33.existsSync)(dir)) {
69988
- 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 })) {
69989
70014
  if (!entry2.isDirectory() || !ACTIVE_RE.test(entry2.name)) continue;
69990
70015
  try {
69991
- const journal = loadJournal((0, import_node_path29.join)(dir, entry2.name));
70016
+ const journal = loadJournal((0, import_node_path30.join)(dir, entry2.name));
69992
70017
  if (!journal || journal.tempPath === canonical) return;
69993
70018
  } catch {
69994
70019
  return;
@@ -69996,15 +70021,15 @@ function cleanupIfcTemp(path) {
69996
70021
  }
69997
70022
  }
69998
70023
  try {
69999
- (0, import_node_fs33.rmSync)(path, { force: true });
70024
+ (0, import_node_fs34.rmSync)(path, { force: true });
70000
70025
  } catch {
70001
70026
  }
70002
70027
  }
70003
70028
 
70004
70029
  // export-companion.ts
70005
70030
  var import_node_crypto18 = require("node:crypto");
70006
- var import_node_fs34 = require("node:fs");
70007
- var import_node_path30 = require("node:path");
70031
+ var import_node_fs35 = require("node:fs");
70032
+ var import_node_path31 = require("node:path");
70008
70033
  var PREFIX = "floless-export-tmp-";
70009
70034
  var LEASE = ".floless-export-lease.json";
70010
70035
  var STALE_MS2 = 30 * 6e4;
@@ -70018,70 +70043,70 @@ function processAlive2(pid) {
70018
70043
  }
70019
70044
  }
70020
70045
  function defaultAppsRoot() {
70021
- return (0, import_node_path30.dirname)(appPath("placeholder"));
70046
+ return (0, import_node_path31.dirname)(appPath("placeholder"));
70022
70047
  }
70023
70048
  function assertScratchPath(path, appsRoot) {
70024
- const root3 = (0, import_node_path30.resolve)(appsRoot);
70025
- const target = (0, import_node_path30.resolve)(path);
70026
- 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)) {
70027
70052
  throw new Error(`refusing to remove a non-export companion path: ${target}`);
70028
70053
  }
70029
70054
  }
70030
70055
  function removeScratch(path, appsRoot) {
70031
70056
  assertScratchPath(path, appsRoot);
70032
- (0, import_node_fs34.rmSync)(path, { recursive: true, force: true });
70057
+ (0, import_node_fs35.rmSync)(path, { recursive: true, force: true });
70033
70058
  }
70034
70059
  function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
70035
70060
  const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
70036
70061
  const token = (0, import_node_crypto18.randomUUID)();
70037
70062
  const id = `${PREFIX}${safeOwner}-${sink}-${token}`;
70038
- const root3 = (0, import_node_path30.resolve)(appsRoot);
70039
- 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);
70040
70065
  const lease = { pid: process.pid, token, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
70041
70066
  return {
70042
70067
  id,
70043
70068
  path,
70044
70069
  token,
70045
70070
  cleanup: () => {
70046
- if (!(0, import_node_fs34.existsSync)(path)) return;
70071
+ if (!(0, import_node_fs35.existsSync)(path)) return;
70047
70072
  let current = null;
70048
70073
  try {
70049
- 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"));
70050
70075
  } catch {
70051
70076
  }
70052
70077
  if (current && current.token !== token) throw new Error(`export companion lease changed for ${id}`);
70053
- removeScratch(path, root3);
70078
+ removeScratch(path, root4);
70054
70079
  }
70055
70080
  };
70056
70081
  }
70057
70082
  function stampExportCompanionLease(companion) {
70058
- (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({
70059
70084
  pid: process.pid,
70060
70085
  token: companion.token,
70061
70086
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
70062
70087
  }));
70063
70088
  }
70064
70089
  function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
70065
- const root3 = (0, import_node_path30.resolve)(appsRoot);
70066
- 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 [];
70067
70092
  const removed = [];
70068
- 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 })) {
70069
70094
  if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX)) continue;
70070
- const path = (0, import_node_path30.resolve)(root3, entry2.name);
70095
+ const path = (0, import_node_path31.resolve)(root4, entry2.name);
70071
70096
  let lease = null;
70072
70097
  try {
70073
- 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"));
70074
70099
  } catch {
70075
70100
  }
70076
70101
  let created;
70077
70102
  try {
70078
- 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;
70079
70104
  } catch {
70080
70105
  continue;
70081
70106
  }
70082
70107
  if (Number.isFinite(created) && now - created < STALE_MS2) continue;
70083
70108
  if (lease && processAlive2(lease.pid)) continue;
70084
- removeScratch(path, root3);
70109
+ removeScratch(path, root4);
70085
70110
  removed.push(entry2.name);
70086
70111
  }
70087
70112
  return removed;
@@ -70188,14 +70213,14 @@ async function teklaReadiness(deps = DEFAULT_DEPS) {
70188
70213
  }
70189
70214
 
70190
70215
  // render-readiness.ts
70191
- var import_node_fs35 = require("node:fs");
70192
- var import_node_path31 = require("node:path");
70193
- 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");
70194
70219
  var RENDER_AWARE_FLOOR = "0.103.0";
70195
70220
  var RENDER_AGENT_ID = "blender";
70196
70221
  function isFile(path) {
70197
70222
  try {
70198
- 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();
70199
70224
  } catch {
70200
70225
  return false;
70201
70226
  }
@@ -70203,9 +70228,9 @@ function isFile(path) {
70203
70228
  function lookupOnPath(command, env2) {
70204
70229
  const path = env2.PATH ?? env2.Path;
70205
70230
  if (!path) return null;
70206
- for (const dir of path.split(import_node_path31.delimiter)) {
70231
+ for (const dir of path.split(import_node_path32.delimiter)) {
70207
70232
  if (!dir) continue;
70208
- const candidate = (0, import_node_path31.join)(dir, command);
70233
+ const candidate = (0, import_node_path32.join)(dir, command);
70209
70234
  if (isFile(candidate)) return candidate;
70210
70235
  }
70211
70236
  return null;
@@ -70222,21 +70247,21 @@ function windowsCandidates(env2) {
70222
70247
  for (const variable of ["ProgramFiles", "ProgramW6432", "ProgramFiles(x86)"]) {
70223
70248
  const value = env2[variable];
70224
70249
  if (!value) continue;
70225
- const root3 = (0, import_node_path31.join)(value, "Blender Foundation");
70226
- 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);
70227
70252
  }
70228
70253
  const found = [];
70229
- for (const root3 of roots) {
70254
+ for (const root4 of roots) {
70230
70255
  let entries2;
70231
70256
  try {
70232
- entries2 = (0, import_node_fs35.readdirSync)(root3);
70257
+ entries2 = (0, import_node_fs36.readdirSync)(root4);
70233
70258
  } catch {
70234
70259
  continue;
70235
70260
  }
70236
70261
  for (const name of entries2) {
70237
70262
  const match = /^Blender\s+(\d+(?:\.\d+)*)$/i.exec(name);
70238
70263
  if (!match) continue;
70239
- const binary = (0, import_node_path31.join)(root3, name, "blender.exe");
70264
+ const binary = (0, import_node_path32.join)(root4, name, "blender.exe");
70240
70265
  if (isFile(binary)) {
70241
70266
  found.push({ version: match[1].split(".").map(Number), name, binary });
70242
70267
  }
@@ -70250,7 +70275,7 @@ function platformDefaults(env2, isWin3) {
70250
70275
  if (process.platform === "darwin") {
70251
70276
  return [
70252
70277
  "/Applications/Blender.app/Contents/MacOS/Blender",
70253
- (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")
70254
70279
  ];
70255
70280
  }
70256
70281
  return ["/usr/bin/blender", "/usr/local/bin/blender", "/snap/bin/blender"];
@@ -70370,20 +70395,20 @@ async function bakeDownstream(sourcePath, appId, contract) {
70370
70395
  }
70371
70396
 
70372
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
70373
70403
  var import_node_fs38 = require("node:fs");
70374
- var import_node_os20 = require("node:os");
70375
70404
  var import_node_path34 = require("node:path");
70376
70405
 
70377
- // routines.ts
70406
+ // trigger-sessions.ts
70378
70407
  var import_node_fs37 = require("node:fs");
70408
+ var import_node_os20 = require("node:os");
70379
70409
  var import_node_path33 = require("node:path");
70380
-
70381
- // trigger-sessions.ts
70382
- var import_node_fs36 = require("node:fs");
70383
- var import_node_os19 = require("node:os");
70384
- var import_node_path32 = require("node:path");
70385
70410
  var import_yaml9 = __toESM(require_dist6(), 1);
70386
- 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");
70387
70412
  function summarizeFire(data) {
70388
70413
  if (!data) return "event";
70389
70414
  const type = typeof data.type === "string" ? data.type : "";
@@ -70400,10 +70425,10 @@ function mapTriggerState(phase) {
70400
70425
  function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
70401
70426
  const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
70402
70427
  if (!safe2(agent)) return false;
70403
- const manifestPath2 = (0, import_node_path32.join)(agentsDir, agent, "manifest.yaml");
70404
- 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;
70405
70430
  try {
70406
- 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"));
70407
70432
  const transport = doc?.transport;
70408
70433
  return !!(transport && typeof transport === "object" && "cli" in transport);
70409
70434
  } catch {
@@ -70688,7 +70713,7 @@ var RoutineError = class extends Error {
70688
70713
  }
70689
70714
  status;
70690
70715
  };
70691
- var ROUTINES_FILE = (0, import_node_path33.join)(flolessRoot, "routines.json");
70716
+ var ROUTINES_FILE = (0, import_node_path34.join)(flolessRoot, "routines.json");
70692
70717
  var routines = [];
70693
70718
  var loaded = false;
70694
70719
  function ensureLoaded() {
@@ -70724,10 +70749,10 @@ function sanitizeRoutine(raw) {
70724
70749
  };
70725
70750
  }
70726
70751
  function loadFromDisk() {
70727
- if (!(0, import_node_fs37.existsSync)(ROUTINES_FILE)) return [];
70752
+ if (!(0, import_node_fs38.existsSync)(ROUTINES_FILE)) return [];
70728
70753
  let text3;
70729
70754
  try {
70730
- text3 = (0, import_node_fs37.readFileSync)(ROUTINES_FILE, "utf8");
70755
+ text3 = (0, import_node_fs38.readFileSync)(ROUTINES_FILE, "utf8");
70731
70756
  } catch {
70732
70757
  return [];
70733
70758
  }
@@ -70736,17 +70761,17 @@ function loadFromDisk() {
70736
70761
  return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
70737
70762
  } catch {
70738
70763
  try {
70739
- (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()}`);
70740
70765
  } catch {
70741
70766
  }
70742
70767
  return [];
70743
70768
  }
70744
70769
  }
70745
70770
  function saveRoutines() {
70746
- 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 });
70747
70772
  const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
70748
- (0, import_node_fs37.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
70749
- (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);
70750
70775
  }
70751
70776
  function listRoutines() {
70752
70777
  ensureLoaded();
@@ -71154,13 +71179,13 @@ var AppLifecycleError = class extends Error {
71154
71179
  }
71155
71180
  };
71156
71181
  function appsDir() {
71157
- 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");
71158
71183
  }
71159
71184
  function appDirPath(id) {
71160
- return (0, import_node_path34.join)(appsDir(), id);
71185
+ return (0, import_node_path35.join)(appsDir(), id);
71161
71186
  }
71162
71187
  function appInstalled(id) {
71163
- 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));
71164
71189
  }
71165
71190
  function logCascade(what, e) {
71166
71191
  console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
@@ -71339,9 +71364,9 @@ function isGatedAwareRoute(url, method) {
71339
71364
 
71340
71365
  // autostart.mjs
71341
71366
  var import_node_child_process6 = require("node:child_process");
71342
- var import_node_fs39 = require("node:fs");
71343
- var import_node_os21 = require("node:os");
71344
- 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");
71345
71370
 
71346
71371
  // teardown.mjs
71347
71372
  var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
@@ -71453,8 +71478,8 @@ function removeLegacyRunKey() {
71453
71478
  }
71454
71479
  function logLine(msg) {
71455
71480
  try {
71456
- (0, import_node_fs39.mkdirSync)(logDir(), { recursive: true });
71457
- (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}
71458
71483
  `);
71459
71484
  } catch {
71460
71485
  }
@@ -71462,8 +71487,8 @@ function logLine(msg) {
71462
71487
  function registerAutostart(exePath) {
71463
71488
  if (!isWin) return;
71464
71489
  const xml = buildAutostartTaskXml(exePath, currentUserId());
71465
- const tmp = (0, import_node_path35.join)((0, import_node_os21.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
71466
- (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" });
71467
71492
  try {
71468
71493
  (0, import_node_child_process6.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
71469
71494
  stdio: ["ignore", "ignore", "ignore"],
@@ -71474,7 +71499,7 @@ function registerAutostart(exePath) {
71474
71499
  throw err2;
71475
71500
  } finally {
71476
71501
  try {
71477
- (0, import_node_fs39.rmSync)(tmp, { force: true });
71502
+ (0, import_node_fs40.rmSync)(tmp, { force: true });
71478
71503
  } catch {
71479
71504
  }
71480
71505
  }
@@ -71509,26 +71534,26 @@ function unregisterAutostart() {
71509
71534
  // updater.ts
71510
71535
  var import_node_child_process7 = require("node:child_process");
71511
71536
  var import_node_crypto19 = require("node:crypto");
71512
- var import_node_fs41 = require("node:fs");
71537
+ var import_node_fs42 = require("node:fs");
71513
71538
  var import_node_stream3 = require("node:stream");
71514
71539
  var import_promises3 = require("node:stream/promises");
71515
- var import_node_path37 = require("node:path");
71540
+ var import_node_path38 = require("node:path");
71516
71541
 
71517
71542
  // post-update-marker.mjs
71518
- var import_node_fs40 = require("node:fs");
71519
- var import_node_os22 = require("node:os");
71520
- 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");
71521
71546
  var FRESH_MS = 12e4;
71522
71547
  function markerPath() {
71523
71548
  const override = (process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim();
71524
71549
  if (override) return override;
71525
- const root3 = process.env.FLOLESS_HOME ?? (0, import_node_path36.join)((0, import_node_os22.homedir)(), ".floless");
71526
- 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");
71527
71552
  }
71528
71553
  function legacyMarkerPath() {
71529
71554
  if ((process.env.FLOLESS_POST_UPDATE_MARKER ?? "").trim()) return null;
71530
71555
  try {
71531
- 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");
71532
71557
  } catch {
71533
71558
  return null;
71534
71559
  }
@@ -71538,7 +71563,7 @@ function writePostUpdateMarker() {
71538
71563
  for (const p of [markerPath(), legacyMarkerPath()]) {
71539
71564
  if (!p) continue;
71540
71565
  try {
71541
- (0, import_node_fs40.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
71566
+ (0, import_node_fs41.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
71542
71567
  wrote = true;
71543
71568
  } catch {
71544
71569
  }
@@ -71550,9 +71575,9 @@ function consumePostUpdateMarker() {
71550
71575
  for (const p of [markerPath(), legacyMarkerPath()]) {
71551
71576
  if (!p) continue;
71552
71577
  try {
71553
- if (!(0, import_node_fs40.existsSync)(p)) continue;
71554
- const ageMs = Date.now() - (0, import_node_fs40.statSync)(p).mtimeMs;
71555
- (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 });
71556
71581
  if (ageMs < FRESH_MS) fresh = true;
71557
71582
  } catch {
71558
71583
  }
@@ -71569,13 +71594,13 @@ function currentVersion() {
71569
71594
  return appVersion();
71570
71595
  }
71571
71596
  function installRoot() {
71572
- 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));
71573
71598
  }
71574
71599
  function updateExePath() {
71575
- return (0, import_node_path37.join)(installRoot(), "Update.exe");
71600
+ return (0, import_node_path38.join)(installRoot(), "Update.exe");
71576
71601
  }
71577
71602
  function packagesDir() {
71578
- return (0, import_node_path37.join)(installRoot(), "packages");
71603
+ return (0, import_node_path38.join)(installRoot(), "packages");
71579
71604
  }
71580
71605
  function feedUrl() {
71581
71606
  const env2 = (process.env.FLOLESS_UPDATE_URL ?? "").trim().replace(/\/+$/, "");
@@ -71668,22 +71693,22 @@ async function checkForUpdate() {
71668
71693
  }
71669
71694
  async function sha1OfFile(path) {
71670
71695
  const hash2 = (0, import_node_crypto19.createHash)("sha1");
71671
- 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);
71672
71697
  return hash2.digest("hex").toUpperCase();
71673
71698
  }
71674
71699
  async function downloadPackage(asset) {
71675
71700
  if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
71676
71701
  const want = asset.SHA1.toUpperCase();
71677
71702
  const dir = packagesDir();
71678
- (0, import_node_fs41.mkdirSync)(dir, { recursive: true });
71679
- const dest = (0, import_node_path37.join)(dir, asset.FileName);
71680
- 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;
71681
71706
  const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
71682
71707
  redirect: "follow",
71683
71708
  signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
71684
71709
  });
71685
71710
  if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
71686
- 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));
71687
71712
  const got = await sha1OfFile(dest);
71688
71713
  if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
71689
71714
  return dest;
@@ -71692,7 +71717,7 @@ async function applyUpdate(check, opts) {
71692
71717
  if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
71693
71718
  if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
71694
71719
  const exe = updateExePath();
71695
- if (!(0, import_node_fs41.existsSync)(exe)) {
71720
+ if (!(0, import_node_fs42.existsSync)(exe)) {
71696
71721
  return { applied: false, message: `Update.exe not found at ${exe} \u2014 is this a Velopack install?` };
71697
71722
  }
71698
71723
  const pkg = await downloadPackage(check.asset);
@@ -71932,12 +71957,12 @@ function isTraceCorrupt(events) {
71932
71957
 
71933
71958
  // launch.mjs
71934
71959
  var import_node_child_process8 = require("node:child_process");
71935
- var import_node_path38 = require("node:path");
71960
+ var import_node_path39 = require("node:path");
71936
71961
  var import_node_url3 = require("node:url");
71937
- var import_node_fs42 = require("node:fs");
71962
+ var import_node_fs43 = require("node:fs");
71938
71963
  var import_node_http = __toESM(require("node:http"), 1);
71939
71964
  var import_node_readline = require("node:readline");
71940
- 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));
71941
71966
  var PORT = Number(process.env.PORT ?? 4317);
71942
71967
  var HEALTH_URL = `http://127.0.0.1:${PORT}/api/health`;
71943
71968
  var BROWSER_URL = `http://floless.localhost:${PORT}`;
@@ -72009,8 +72034,8 @@ async function waitHealthy(timeoutMs = 3e4) {
72009
72034
  function resolveServerStart() {
72010
72035
  const packaged = /flolessapp\.exe$/i.test(process.execPath);
72011
72036
  if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
72012
- const bundle = (0, import_node_path38.join)(__dirname2, "dist", "floless-server.cjs");
72013
- 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 };
72014
72039
  return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
72015
72040
  }
72016
72041
  function startServerDetached() {
@@ -72163,8 +72188,8 @@ function taskkillArgs(pid, { tree = true } = {}) {
72163
72188
  }
72164
72189
  function killSupervisor({ tree = true } = {}) {
72165
72190
  if (!isWin2) return;
72166
- const isNpmChannel = /^node(\.exe)?$/i.test((0, import_node_path38.basename)(process.execPath));
72167
- 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;
72168
72193
  const realExe = resolveRealInstallExe(process.execPath);
72169
72194
  const exeMatch = realExe === process.execPath ? process.execPath : [process.execPath, realExe];
72170
72195
  const pids = supervisorPidsToKill(enumerateProcesses(), process.pid, exeMatch, scriptMatch);
@@ -72329,7 +72354,7 @@ async function runAction(arg, flagArgv = [], selfVersion = null) {
72329
72354
  }
72330
72355
  await action(parseTeardownFlags(flagArgv));
72331
72356
  }
72332
- var entry = (0, import_node_path38.basename)(process.argv[1] ?? "").toLowerCase();
72357
+ var entry = (0, import_node_path39.basename)(process.argv[1] ?? "").toLowerCase();
72333
72358
  if (entry === "launch.mjs") {
72334
72359
  runAction(process.argv[2], process.argv.slice(3)).catch((e) => {
72335
72360
  log(`error: ${e?.message ?? e}`);
@@ -72403,9 +72428,9 @@ function awareUpgradeBlockReason(s) {
72403
72428
  }
72404
72429
 
72405
72430
  // skill-sync.ts
72406
- var import_node_fs43 = require("node:fs");
72407
- var import_node_os23 = require("node:os");
72408
- 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");
72409
72434
  var import_node_url4 = require("node:url");
72410
72435
  var import_yaml10 = __toESM(require_dist6(), 1);
72411
72436
 
@@ -72450,30 +72475,30 @@ function selectShippedSkillNames(names) {
72450
72475
  }
72451
72476
 
72452
72477
  // skill-sync.ts
72453
- 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));
72454
72479
  function bundledSkillsRoot() {
72455
72480
  const candidates = [
72456
- (0, import_node_path39.join)(__dirname3, "skills"),
72457
- (0, import_node_path39.join)((0, import_node_path39.dirname)(process.execPath), "skills"),
72458
- (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")
72459
72484
  ];
72460
- return candidates.find((p) => (0, import_node_fs43.existsSync)(p)) ?? null;
72485
+ return candidates.find((p) => (0, import_node_fs44.existsSync)(p)) ?? null;
72461
72486
  }
72462
72487
  function targetConfigDirs() {
72463
72488
  const override = process.env.FLOLESS_SKILL_TARGETS;
72464
72489
  if (override) {
72465
72490
  return override.split(";").map((d) => d.trim()).filter(Boolean).map((dir) => ({ runtime: "custom", dir }));
72466
72491
  }
72467
- const home = (0, import_node_os23.homedir)();
72492
+ const home = (0, import_node_os24.homedir)();
72468
72493
  return [
72469
- { runtime: "claude", dir: (0, import_node_path39.join)(home, ".claude") },
72470
- { runtime: "codex", dir: (0, import_node_path39.join)(home, ".codex") },
72471
- { 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") }
72472
72497
  ];
72473
72498
  }
72474
72499
  function skillVersion(skillMdPath) {
72475
72500
  try {
72476
- const text3 = (0, import_node_fs43.readFileSync)(skillMdPath, "utf8");
72501
+ const text3 = (0, import_node_fs44.readFileSync)(skillMdPath, "utf8");
72477
72502
  const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text3);
72478
72503
  if (!m || m[1] === void 0) return null;
72479
72504
  const fm = (0, import_yaml10.parse)(m[1]);
@@ -72510,24 +72535,24 @@ function decideAction(installed, bundled) {
72510
72535
  if (c === 0) return "skipped-current";
72511
72536
  return "skipped-newer";
72512
72537
  }
72513
- function bundledSkills(root3) {
72538
+ function bundledSkills(root4) {
72514
72539
  let entries2 = [];
72515
72540
  try {
72516
- entries2 = selectShippedSkillNames((0, import_node_fs43.readdirSync)(root3));
72541
+ entries2 = selectShippedSkillNames((0, import_node_fs44.readdirSync)(root4));
72517
72542
  } catch {
72518
72543
  return [];
72519
72544
  }
72520
72545
  const out = [];
72521
72546
  for (const name of entries2) {
72522
- const dir = (0, import_node_path39.join)(root3, name);
72547
+ const dir = (0, import_node_path40.join)(root4, name);
72523
72548
  let isDir = false;
72524
72549
  try {
72525
- isDir = (0, import_node_fs43.statSync)(dir).isDirectory();
72550
+ isDir = (0, import_node_fs44.statSync)(dir).isDirectory();
72526
72551
  } catch {
72527
72552
  isDir = false;
72528
72553
  }
72529
72554
  if (!isDir) continue;
72530
- const v = skillVersion((0, import_node_path39.join)(dir, "SKILL.md"));
72555
+ const v = skillVersion((0, import_node_path40.join)(dir, "SKILL.md"));
72531
72556
  if (!v) continue;
72532
72557
  out.push({ name, dir, version: v });
72533
72558
  }
@@ -72535,22 +72560,22 @@ function bundledSkills(root3) {
72535
72560
  }
72536
72561
  function syncSkills() {
72537
72562
  const results = [];
72538
- const root3 = bundledSkillsRoot();
72539
- if (!root3) return results;
72540
- const skills = bundledSkills(root3);
72563
+ const root4 = bundledSkillsRoot();
72564
+ if (!root4) return results;
72565
+ const skills = bundledSkills(root4);
72541
72566
  if (!skills.length) return results;
72542
72567
  for (const { runtime, dir: cfg } of targetConfigDirs()) {
72543
- if (!(0, import_node_fs43.existsSync)(cfg)) continue;
72544
- 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");
72545
72570
  for (const s of skills) {
72546
- const dest = (0, import_node_path39.join)(skillsDir, s.name);
72547
- const installedMd = (0, import_node_path39.join)(dest, "SKILL.md");
72548
- 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;
72549
72574
  const action = decideAction(installed, s.version);
72550
72575
  if (action === "installed" || action === "updated") {
72551
72576
  try {
72552
- if (action === "updated") (0, import_node_fs43.rmSync)(dest, { recursive: true, force: true });
72553
- (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 });
72554
72579
  results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
72555
72580
  } catch {
72556
72581
  }
@@ -72574,9 +72599,9 @@ function contractChangedEvent(appId, project, etag, rawMutationId) {
72574
72599
  }
72575
72600
 
72576
72601
  // watch.ts
72577
- var import_node_os24 = require("node:os");
72578
- var import_node_path41 = require("node:path");
72579
- 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");
72580
72605
 
72581
72606
  // node_modules/chokidar/esm/index.js
72582
72607
  var import_fs2 = require("fs");
@@ -72587,7 +72612,7 @@ var sysPath2 = __toESM(require("path"), 1);
72587
72612
  // node_modules/readdirp/esm/index.js
72588
72613
  var import_promises4 = require("node:fs/promises");
72589
72614
  var import_node_stream4 = require("node:stream");
72590
- var import_node_path40 = require("node:path");
72615
+ var import_node_path41 = require("node:path");
72591
72616
  var EntryTypes = {
72592
72617
  FILE_TYPE: "files",
72593
72618
  DIR_TYPE: "directories",
@@ -72649,7 +72674,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72649
72674
  highWaterMark: options.highWaterMark
72650
72675
  });
72651
72676
  const opts = { ...defaultOptions, ...options };
72652
- const { root: root3, type } = opts;
72677
+ const { root: root4, type } = opts;
72653
72678
  this._fileFilter = normalizeFilter(opts.fileFilter);
72654
72679
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
72655
72680
  const statMethod = opts.lstat ? import_promises4.lstat : import_promises4.stat;
@@ -72662,11 +72687,11 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72662
72687
  this._wantsDir = type ? DIR_TYPES.has(type) : false;
72663
72688
  this._wantsFile = type ? FILE_TYPES.has(type) : false;
72664
72689
  this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
72665
- this._root = (0, import_node_path40.resolve)(root3);
72690
+ this._root = (0, import_node_path41.resolve)(root4);
72666
72691
  this._isDirent = !opts.alwaysStat;
72667
72692
  this._statsProp = this._isDirent ? "dirent" : "stats";
72668
72693
  this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
72669
- this.parents = [this._exploreDir(root3, 1)];
72694
+ this.parents = [this._exploreDir(root4, 1)];
72670
72695
  this.reading = false;
72671
72696
  this.parent = void 0;
72672
72697
  }
@@ -72733,8 +72758,8 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72733
72758
  let entry2;
72734
72759
  const basename9 = this._isDirent ? dirent.name : dirent;
72735
72760
  try {
72736
- const fullPath = (0, import_node_path40.resolve)((0, import_node_path40.join)(path, basename9));
72737
- 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 };
72738
72763
  entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
72739
72764
  } catch (err2) {
72740
72765
  this._onError(err2);
@@ -72768,7 +72793,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72768
72793
  }
72769
72794
  if (entryRealPathStats.isDirectory()) {
72770
72795
  const len = entryRealPath.length;
72771
- 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) {
72772
72797
  const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
72773
72798
  recursiveError.code = RECURSIVE_ERROR_CODE;
72774
72799
  return this._onError(recursiveError);
@@ -72786,20 +72811,20 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
72786
72811
  return stats && this._wantsEverything && !stats.isDirectory();
72787
72812
  }
72788
72813
  };
72789
- function readdirp(root3, options = {}) {
72814
+ function readdirp(root4, options = {}) {
72790
72815
  let type = options.entryType || options.type;
72791
72816
  if (type === "both")
72792
72817
  type = EntryTypes.FILE_DIR_TYPE;
72793
72818
  if (type)
72794
72819
  options.type = type;
72795
- if (!root3) {
72820
+ if (!root4) {
72796
72821
  throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
72797
- } else if (typeof root3 !== "string") {
72822
+ } else if (typeof root4 !== "string") {
72798
72823
  throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
72799
72824
  } else if (type && !ALL_TYPES.includes(type)) {
72800
72825
  throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
72801
72826
  }
72802
- options.root = root3;
72827
+ options.root = root4;
72803
72828
  return new ReaddirpStream(options);
72804
72829
  }
72805
72830
 
@@ -74244,11 +74269,11 @@ var FSWatcher = class extends import_events.EventEmitter {
74244
74269
  }
74245
74270
  list.push(closer);
74246
74271
  }
74247
- _readdirp(root3, opts) {
74272
+ _readdirp(root4, opts) {
74248
74273
  if (this.closed)
74249
74274
  return;
74250
74275
  const options = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
74251
- let stream = readdirp(root3, options);
74276
+ let stream = readdirp(root4, options);
74252
74277
  this._streams.add(stream);
74253
74278
  stream.once(STR_CLOSE, () => {
74254
74279
  stream = void 0;
@@ -74276,33 +74301,33 @@ function appIdFromLogPath(path) {
74276
74301
  return i >= 0 && parts[i + 1] ? parts[i + 1] : null;
74277
74302
  }
74278
74303
  function samePath(a, b) {
74279
- const ra = (0, import_node_path41.resolve)(a);
74280
- 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);
74281
74306
  return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
74282
74307
  }
74283
74308
  function underDir(path, dir) {
74284
- const rp = (0, import_node_path41.resolve)(path);
74285
- 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);
74286
74311
  const [p, d] = process.platform === "win32" ? [rp.toLowerCase(), rd.toLowerCase()] : [rp, rd];
74287
- return p === d || p.startsWith(d + import_node_path41.sep);
74312
+ return p === d || p.startsWith(d + import_node_path42.sep);
74288
74313
  }
74289
74314
  function startWatcher() {
74290
- const awareDir = process.env.AWARE_HOME ?? (0, import_node_path41.join)((0, import_node_os24.homedir)(), ".aware");
74291
- const credentialsDir = (0, import_node_path41.join)(awareDir, "credentials");
74292
- 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)) {
74293
74318
  try {
74294
- (0, import_node_fs44.mkdirSync)(credentialsDir, { recursive: true });
74319
+ (0, import_node_fs45.mkdirSync)(credentialsDir, { recursive: true });
74295
74320
  } catch {
74296
74321
  }
74297
74322
  }
74298
- if (!(0, import_node_fs44.existsSync)(uiDir)) {
74323
+ if (!(0, import_node_fs45.existsSync)(uiDir)) {
74299
74324
  try {
74300
- (0, import_node_fs44.mkdirSync)(uiDir, { recursive: true });
74325
+ (0, import_node_fs45.mkdirSync)(uiDir, { recursive: true });
74301
74326
  } catch {
74302
74327
  }
74303
74328
  }
74304
- const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path41.join)(awareDir, d)).filter((p) => (0, import_node_fs44.existsSync)(p));
74305
- 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);
74306
74331
  if (targets.length === 0) {
74307
74332
  return null;
74308
74333
  }
@@ -74331,11 +74356,11 @@ function startWatcher() {
74331
74356
  const isCredential = path.split(/[\\/]/).includes("credentials");
74332
74357
  const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
74333
74358
  broadcast({ type: "fs-change", kind, event, path });
74334
- if (kind === "trace" && event !== "unlink" && (0, import_node_fs44.existsSync)(path)) {
74359
+ if (kind === "trace" && event !== "unlink" && (0, import_node_fs45.existsSync)(path)) {
74335
74360
  const id = appIdFromLogPath(path);
74336
74361
  if (!id) return;
74337
74362
  try {
74338
- 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")) });
74339
74364
  } catch {
74340
74365
  }
74341
74366
  }
@@ -74344,10 +74369,10 @@ function startWatcher() {
74344
74369
  }
74345
74370
 
74346
74371
  // index.ts
74347
- var __dirname4 = (0, import_node_path42.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
74348
- 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(
74349
- (p) => (0, import_node_fs45.existsSync)(p)
74350
- ) ?? (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");
74351
74376
  var PORT2 = Number(process.env.PORT ?? 4317);
74352
74377
  var HOST = "127.0.0.1";
74353
74378
  var crashHandlersInstalled = false;
@@ -74363,7 +74388,7 @@ function installCrashHandlers() {
74363
74388
  ${stack}
74364
74389
  `;
74365
74390
  try {
74366
- (0, import_node_fs45.appendFileSync)(logFilePath(), line);
74391
+ (0, import_node_fs46.appendFileSync)(logFilePath(), line);
74367
74392
  } catch {
74368
74393
  }
74369
74394
  if (process.stderr.isTTY) process.stderr.write(line);
@@ -74719,9 +74744,9 @@ async function startServer() {
74719
74744
  const { id, templateId, templatePath, srcPath, appDirPath: appDirPath2, fromVersion, contract, verb } = opts;
74720
74745
  const bdir = backupDir(id, fromVersion, Date.now());
74721
74746
  try {
74722
- (0, import_node_fs45.mkdirSync)((0, import_node_path42.dirname)(bdir), { recursive: true });
74723
- (0, import_node_fs45.cpSync)(appDirPath2, bdir, { recursive: true });
74724
- (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);
74725
74750
  if (id !== templateId) stampSourceAppId(srcPath, id);
74726
74751
  if (contract != null) {
74727
74752
  bakeContractIntoApp(srcPath, contract);
@@ -74732,8 +74757,8 @@ async function startServer() {
74732
74757
  } catch (e) {
74733
74758
  const msg = e instanceof Error ? e.message : String(e);
74734
74759
  try {
74735
- (0, import_node_fs45.rmSync)(appDirPath2, { recursive: true, force: true });
74736
- (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 });
74737
74762
  } catch (re) {
74738
74763
  const rmsg = re instanceof Error ? re.message : String(re);
74739
74764
  throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
@@ -74765,7 +74790,7 @@ async function startServer() {
74765
74790
  return reply.status(409).send({ ok: false, error: `"${id}" is already at ${fromVersion}`, code: "up-to-date" });
74766
74791
  }
74767
74792
  const contract = readAcceptedForRequest(id, void 0);
74768
- if (contract == null && (0, import_node_fs45.existsSync)(contractPath(id))) {
74793
+ if (contract == null && (0, import_node_fs46.existsSync)(contractPath(id))) {
74769
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" });
74770
74795
  }
74771
74796
  if (contract != null) {
@@ -74899,16 +74924,16 @@ async function startServer() {
74899
74924
  app.get("/api/app/:id", async (req) => {
74900
74925
  return { ok: true, app: readApp(req.params.id) };
74901
74926
  });
74902
- const withTemplateId = (p, root3) => ({ ...p, templateId: root3(p.app) });
74927
+ const withTemplateId = (p, root4) => ({ ...p, templateId: root4(p.app) });
74903
74928
  const projectView = (p) => withTemplateId(p, resolveTemplateId);
74904
74929
  const projectViews = (list) => {
74905
- const root3 = templateIdResolver();
74906
- return list.map((p) => withTemplateId(p, root3));
74930
+ const root4 = templateIdResolver();
74931
+ return list.map((p) => withTemplateId(p, root4));
74907
74932
  };
74908
74933
  const requestView2 = (r) => r === null ? null : { ...r, appTemplateId: r.appId ? resolveTemplateId(r.appId) : void 0 };
74909
74934
  const requestViews = (list) => {
74910
- const root3 = templateIdResolver();
74911
- 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 }));
74912
74937
  };
74913
74938
  app.get("/api/projects", async () => ({ ok: true, projects: projectViews(listProjects()) }));
74914
74939
  app.post(
@@ -75145,9 +75170,9 @@ async function startServer() {
75145
75170
  const bad = projectAppMismatch(req.params.appId, project);
75146
75171
  if (bad) return reply.status(404).send({ ok: false, error: bad });
75147
75172
  const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
75148
- const file = (0, import_node_path42.join)((0, import_node_path42.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
75149
- if (!(0, import_node_fs45.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
75150
- 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"));
75151
75176
  }
75152
75177
  );
75153
75178
  app.put(
@@ -75305,7 +75330,7 @@ async function startServer() {
75305
75330
  }
75306
75331
  const statedAt = (filename) => {
75307
75332
  try {
75308
- 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));
75309
75334
  return st.isFile() ? st.mtime.toISOString() : null;
75310
75335
  } catch {
75311
75336
  return null;
@@ -75315,14 +75340,14 @@ async function startServer() {
75315
75340
  const rows2 = (byKind.get(kind) ?? []).map((receipt) => ({
75316
75341
  variant: receipt.variant ?? null,
75317
75342
  filename: receipt.filename,
75318
- path: (0, import_node_path42.join)(dir, receipt.filename),
75343
+ path: (0, import_node_path43.join)(dir, receipt.filename),
75319
75344
  exportedAt: statedAt(receipt.filename)
75320
75345
  })).sort((a, b) => String(b.exportedAt ?? "").localeCompare(String(a.exportedAt ?? "")));
75321
75346
  const headline = rows2[0];
75322
75347
  return {
75323
75348
  kind,
75324
75349
  filename: headline?.filename ?? legacy,
75325
- path: headline?.path ?? (0, import_node_path42.join)(dir, legacy),
75350
+ path: headline?.path ?? (0, import_node_path43.join)(dir, legacy),
75326
75351
  exportedAt: headline?.exportedAt ?? null,
75327
75352
  ...rows2.length ? { variants: rows2 } : {}
75328
75353
  };
@@ -75461,7 +75486,7 @@ async function startServer() {
75461
75486
  }
75462
75487
  if (!hasExportableSceneRecords(scene)) return reply.status(422).send({ ok: false, error: emptyError, skipped });
75463
75488
  const filename = `${exportFileBase(project, appId)}.ifc`;
75464
- 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);
75465
75490
  const priorProjectIfc = project ? listProjectExportReceipts(project).find((row) => row.kind === "ifc") : void 0;
75466
75491
  const tempPath = requestIfcTempPath(finalPath);
75467
75492
  try {
@@ -75469,10 +75494,10 @@ async function startServer() {
75469
75494
  scene,
75470
75495
  "output-path": tempPath
75471
75496
  });
75472
- 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) {
75473
75498
  throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
75474
75499
  }
75475
- const artifactBytes = (0, import_node_fs45.readFileSync)(tempPath);
75500
+ const artifactBytes = (0, import_node_fs46.readFileSync)(tempPath);
75476
75501
  const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
75477
75502
  index: parseStepData(artifactBytes),
75478
75503
  bytes: artifactBytes
@@ -75525,7 +75550,7 @@ async function startServer() {
75525
75550
  return reply.status(status).send({
75526
75551
  ok: false,
75527
75552
  error: error instanceof Error ? error.message : "IFC export failed",
75528
- 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)
75529
75554
  });
75530
75555
  } finally {
75531
75556
  cleanupIfcTemp(tempPath);
@@ -75570,10 +75595,10 @@ async function startServer() {
75570
75595
  const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
75571
75596
  if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
75572
75597
  const path = resolveProjectExportReceiptPath(project, receipt);
75573
- if (!path || !(0, import_node_fs45.existsSync)(path)) {
75598
+ if (!path || !(0, import_node_fs46.existsSync)(path)) {
75574
75599
  return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
75575
75600
  }
75576
- 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));
75577
75602
  });
75578
75603
  const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
75579
75604
  app.post("/api/contract/:appId/render", async (req, reply) => {
@@ -75630,8 +75655,8 @@ async function startServer() {
75630
75655
  }
75631
75656
  const kind = output === "turntable" ? "render-mp4" : "render-png";
75632
75657
  const extension = output === "turntable" ? ".mp4" : ".png";
75633
- const scratch = (0, import_node_fs45.mkdtempSync)((0, import_node_path42.join)((0, import_node_os25.tmpdir)(), "floless-render-"));
75634
- 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");
75635
75660
  const rendered = [];
75636
75661
  const progress = (stage, extra = {}) => {
75637
75662
  try {
@@ -75642,13 +75667,13 @@ async function startServer() {
75642
75667
  try {
75643
75668
  progress("preparing");
75644
75669
  await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
75645
- 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) {
75646
75671
  throw new Error("AWARE reported a successful IFC write but produced no file to render");
75647
75672
  }
75648
75673
  const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
75649
75674
  for (const [i, viewpoint] of viewpoints.entries()) {
75650
75675
  progress("rendering", { viewpoint, index: i + 1, output });
75651
- const artifactPath = (0, import_node_path42.join)(scratch, `render-${viewpoint}${extension}`);
75676
+ const artifactPath = (0, import_node_path43.join)(scratch, `render-${viewpoint}${extension}`);
75652
75677
  const receipt = await aware.agentInvoke(RENDER_AGENT_ID, output === "turntable" ? "render.turntable" : "render.still", {
75653
75678
  "ifc-path": ifcPath,
75654
75679
  "output-path": artifactPath,
@@ -75660,10 +75685,10 @@ async function startServer() {
75660
75685
  environment: "studio",
75661
75686
  ...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
75662
75687
  }, { timeoutMs: renderBudgetMs });
75663
- 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) {
75664
75689
  throw new Error(`the ${viewpoint} render reported success but produced no image`);
75665
75690
  }
75666
- const bytes = (0, import_node_fs45.readFileSync)(artifactPath);
75691
+ const bytes = (0, import_node_fs46.readFileSync)(artifactPath);
75667
75692
  const preferred = `${exportFileBase(project, appId)}-${viewpoint}${extension}`;
75668
75693
  const filename = uniqueProjectExportFilename(project, preferred);
75669
75694
  publishProjectExportArtifact(project, {
@@ -75699,7 +75724,7 @@ async function startServer() {
75699
75724
  // Kept for a single-viewpoint caller so the existing shape still reads naturally.
75700
75725
  filename: rendered[0]?.filename,
75701
75726
  viewpoint: rendered[0]?.viewpoint,
75702
- 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
75703
75728
  };
75704
75729
  } catch (error) {
75705
75730
  app.log.warn(
@@ -75715,7 +75740,7 @@ async function startServer() {
75715
75740
  rendered
75716
75741
  });
75717
75742
  } finally {
75718
- (0, import_node_fs45.rmSync)(scratch, { recursive: true, force: true });
75743
+ (0, import_node_fs46.rmSync)(scratch, { recursive: true, force: true });
75719
75744
  }
75720
75745
  }, {
75721
75746
  // What anyone blocked on this project is told, and for how long to expect it. Erring long
@@ -75857,10 +75882,10 @@ async function startServer() {
75857
75882
  }
75858
75883
  const preferredFilename = `${exportFileBase(project, appId)}-bom.${format}`;
75859
75884
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
75860
- const outPath = project ? (0, import_node_path42.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
75861
- 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);
75862
75887
  try {
75863
- (0, import_node_fs45.mkdirSync)(dir, { recursive: true });
75888
+ (0, import_node_fs46.mkdirSync)(dir, { recursive: true });
75864
75889
  if (format === "csv") {
75865
75890
  const text3 = bomToCsv(bom);
75866
75891
  if (project && projectSnapshot) {
@@ -75872,7 +75897,7 @@ async function startServer() {
75872
75897
  version: projectSnapshot.version.n,
75873
75898
  contractHash: projectSnapshot.contractHash
75874
75899
  }, Buffer.from(text3, "utf8"));
75875
- } else (0, import_node_fs45.writeFileSync)(outPath, text3, "utf8");
75900
+ } else (0, import_node_fs46.writeFileSync)(outPath, text3, "utf8");
75876
75901
  return { ok: true, filename, encoding: "utf8", content: text3, bytes: Buffer.byteLength(text3), savedTo: outPath };
75877
75902
  }
75878
75903
  const buf = await bomToXlsx(bom);
@@ -75885,7 +75910,7 @@ async function startServer() {
75885
75910
  version: projectSnapshot.version.n,
75886
75911
  contractHash: projectSnapshot.contractHash
75887
75912
  }, buf);
75888
- } else (0, import_node_fs45.writeFileSync)(outPath, buf);
75913
+ } else (0, import_node_fs46.writeFileSync)(outPath, buf);
75889
75914
  return { ok: true, filename, encoding: "base64", content: buf.toString("base64"), bytes: buf.length, savedTo: outPath };
75890
75915
  } catch (e) {
75891
75916
  app.log.error({ appId, format, err: e instanceof Error ? e.message : e }, "export-bom: generation failed");
@@ -75923,9 +75948,9 @@ async function startServer() {
75923
75948
  const svg = contractToSvg(cleaned);
75924
75949
  const preferredFilename = `${exportFileBase(project, req.params.appId)}.svg`;
75925
75950
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
75926
- 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);
75927
75952
  try {
75928
- (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 });
75929
75954
  if (project && projectSnapshot) {
75930
75955
  publishProjectExportArtifact(project, {
75931
75956
  kind: "svg",
@@ -75935,7 +75960,7 @@ async function startServer() {
75935
75960
  version: projectSnapshot.version.n,
75936
75961
  contractHash: projectSnapshot.contractHash
75937
75962
  }, Buffer.from(svg, "utf8"));
75938
- } else (0, import_node_fs45.writeFileSync)(outPath, svg, "utf8");
75963
+ } else (0, import_node_fs46.writeFileSync)(outPath, svg, "utf8");
75939
75964
  return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
75940
75965
  } catch (e) {
75941
75966
  app.log.error({ appId: req.params.appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
@@ -76018,7 +76043,7 @@ async function startServer() {
76018
76043
  return reply.status(404).send({ ok: false, error: `"${id}" is not installed`, code: "not-installed" });
76019
76044
  }
76020
76045
  const contract = readAcceptedForRequest(id, void 0);
76021
- if (contract == null && (0, import_node_fs45.existsSync)(contractPath(id))) {
76046
+ if (contract == null && (0, import_node_fs46.existsSync)(contractPath(id))) {
76022
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" });
76023
76048
  }
76024
76049
  if (contract != null) {
@@ -76099,11 +76124,11 @@ async function startServer() {
76099
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 });
76100
76125
  }
76101
76126
  await deleteOrigin(id);
76102
- 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-"));
76103
76128
  try {
76104
- const stageDir = (0, import_node_path42.join)(stageRoot, id);
76105
- (0, import_node_fs45.mkdirSync)(stageDir);
76106
- (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);
76107
76132
  await aware.install(stageDir);
76108
76133
  } catch (err2) {
76109
76134
  try {
@@ -76114,7 +76139,7 @@ async function startServer() {
76114
76139
  const reason = awareStderr(err2);
76115
76140
  return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
76116
76141
  } finally {
76117
- (0, import_node_fs45.rmSync)(stageRoot, { recursive: true, force: true });
76142
+ (0, import_node_fs46.rmSync)(stageRoot, { recursive: true, force: true });
76118
76143
  }
76119
76144
  broadcast({ type: "apps-changed", id });
76120
76145
  return { ok: true, id };
@@ -76129,13 +76154,13 @@ async function startServer() {
76129
76154
  }
76130
76155
  const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
76131
76156
  const baked = bakeFloSource(appData.source.text, inputs);
76132
- const tmpRoot = (0, import_node_fs45.mkdtempSync)((0, import_node_path42.join)((0, import_node_os25.tmpdir)(), "floless-bake-"));
76133
- const backupDir2 = (0, import_node_path42.join)(tmpRoot, `${id}-backup`);
76134
- const bakeDir = (0, import_node_path42.join)(tmpRoot, id);
76135
- (0, import_node_fs45.cpSync)(appDir(id), backupDir2, { recursive: true });
76136
- (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 });
76137
76162
  const floName = appData.source.path.split(/[\\/]/).pop();
76138
- (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);
76139
76164
  let appInstalled2 = true;
76140
76165
  try {
76141
76166
  await aware.uninstall(id);
@@ -76157,17 +76182,17 @@ async function startServer() {
76157
76182
  throw installErr;
76158
76183
  }
76159
76184
  try {
76160
- await aware.compile((0, import_node_path42.join)(appDir(id), floName));
76185
+ await aware.compile((0, import_node_path43.join)(appDir(id), floName));
76161
76186
  } catch (compileErr) {
76162
76187
  app.log.warn({ id, compileErr: String(compileErr) }, "bake: post-install recompile failed (app baked but may need a manual Compile)");
76163
76188
  }
76164
76189
  broadcast({ type: "baked", id });
76165
76190
  return { ok: true, id, agent: id, inputs };
76166
76191
  } finally {
76167
- 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 });
76168
76193
  }
76169
76194
  });
76170
- 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");
76171
76196
  app.post("/api/graft/match", async (req, reply) => {
76172
76197
  const { glob } = req.body ?? {};
76173
76198
  if (!glob) return reply.status(400).send({ ok: false, error: "glob required" });
@@ -76184,7 +76209,7 @@ async function startServer() {
76184
76209
  if (!sourceKind || !sourceRef) {
76185
76210
  return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
76186
76211
  }
76187
- 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-"));
76188
76213
  let result;
76189
76214
  try {
76190
76215
  result = await aware.build({
@@ -76197,19 +76222,19 @@ async function startServer() {
76197
76222
  awareHome: tempHome
76198
76223
  });
76199
76224
  } catch (err2) {
76200
- (0, import_node_fs45.rmSync)(tempHome, { recursive: true, force: true });
76225
+ (0, import_node_fs46.rmSync)(tempHome, { recursive: true, force: true });
76201
76226
  const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
76202
76227
  return reply.status(422).send({ ok: false, error: msg });
76203
76228
  }
76204
76229
  const manifest = readStagedManifest(result.agentDir);
76205
76230
  if (!manifest) {
76206
- (0, import_node_fs45.rmSync)(tempHome, { recursive: true, force: true });
76231
+ (0, import_node_fs46.rmSync)(tempHome, { recursive: true, force: true });
76207
76232
  return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
76208
76233
  }
76209
76234
  const token = (0, import_node_crypto20.randomUUID)();
76210
76235
  registerStage(token, tempHome, result.agentId);
76211
76236
  const preview2 = buildPreview(manifest, sourceKind, sourceRef, token);
76212
- 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))) {
76213
76238
  preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
76214
76239
  }
76215
76240
  return { ok: true, preview: preview2 };
@@ -76228,7 +76253,7 @@ async function startServer() {
76228
76253
  registerStage(stagedRef, stage.tempDir, stage.agentId);
76229
76254
  return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
76230
76255
  }
76231
- (0, import_node_fs45.rmSync)(stage.tempDir, { recursive: true, force: true });
76256
+ (0, import_node_fs46.rmSync)(stage.tempDir, { recursive: true, force: true });
76232
76257
  throw err2;
76233
76258
  }
76234
76259
  broadcast({ type: "grafted", id: stage.agentId });
@@ -76545,11 +76570,11 @@ async function startServer() {
76545
76570
  app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
76546
76571
  const n = Number.parseInt(req.params.n, 10);
76547
76572
  const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
76548
- 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" });
76549
76574
  const ext = p.split(".").pop().toLowerCase();
76550
76575
  reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
76551
76576
  reply.header("Cache-Control", "no-store");
76552
- return (0, import_node_fs45.readFileSync)(p);
76577
+ return (0, import_node_fs46.readFileSync)(p);
76553
76578
  });
76554
76579
  app.post(
76555
76580
  "/api/tweak",
@@ -76776,7 +76801,7 @@ async function startServer() {
76776
76801
  warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
76777
76802
  let finishedAt2 = null;
76778
76803
  try {
76779
- finishedAt2 = (0, import_node_fs45.statSync)(latest.path).mtime.toISOString();
76804
+ finishedAt2 = (0, import_node_fs46.statSync)(latest.path).mtime.toISOString();
76780
76805
  } catch {
76781
76806
  finishedAt2 = null;
76782
76807
  }
@@ -76786,7 +76811,7 @@ async function startServer() {
76786
76811
  let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
76787
76812
  if (!finishedAt) {
76788
76813
  try {
76789
- finishedAt = (0, import_node_fs45.statSync)(latest.path).mtime.toISOString();
76814
+ finishedAt = (0, import_node_fs46.statSync)(latest.path).mtime.toISOString();
76790
76815
  } catch {
76791
76816
  finishedAt = null;
76792
76817
  }