@floless/app 0.130.0 → 0.130.1

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.
@@ -11213,13 +11213,13 @@ var require_context = __commonJS({
11213
11213
  this.server = server;
11214
11214
  }
11215
11215
  function defaultSchemaErrorFormatter(errors, dataVar) {
11216
- let text4 = "";
11216
+ let text5 = "";
11217
11217
  const separator = ", ";
11218
11218
  for (let i = 0; i !== errors.length; ++i) {
11219
11219
  const e = errors[i];
11220
- text4 += dataVar + (e.instancePath || "") + " " + e.message + separator;
11220
+ text5 += dataVar + (e.instancePath || "") + " " + e.message + separator;
11221
11221
  }
11222
- return new Error(text4.slice(0, -separator.length));
11222
+ return new Error(text5.slice(0, -separator.length));
11223
11223
  }
11224
11224
  module2.exports = Context;
11225
11225
  }
@@ -11915,20 +11915,20 @@ var require_secure_json_parse = __commonJS({
11915
11915
  var hasBuffer = typeof Buffer !== "undefined";
11916
11916
  var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
11917
11917
  var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
11918
- function _parse(text4, reviver, options) {
11918
+ function _parse(text5, reviver, options) {
11919
11919
  if (options == null) {
11920
11920
  if (reviver !== null && typeof reviver === "object") {
11921
11921
  options = reviver;
11922
11922
  reviver = void 0;
11923
11923
  }
11924
11924
  }
11925
- if (hasBuffer && Buffer.isBuffer(text4)) {
11926
- text4 = text4.toString();
11925
+ if (hasBuffer && Buffer.isBuffer(text5)) {
11926
+ text5 = text5.toString();
11927
11927
  }
11928
- if (text4 && text4.charCodeAt(0) === 65279) {
11929
- text4 = text4.slice(1);
11928
+ if (text5 && text5.charCodeAt(0) === 65279) {
11929
+ text5 = text5.slice(1);
11930
11930
  }
11931
- const obj3 = JSON.parse(text4, reviver);
11931
+ const obj3 = JSON.parse(text5, reviver);
11932
11932
  if (obj3 === null || typeof obj3 !== "object") {
11933
11933
  return obj3;
11934
11934
  }
@@ -11938,15 +11938,15 @@ var require_secure_json_parse = __commonJS({
11938
11938
  return obj3;
11939
11939
  }
11940
11940
  if (protoAction !== "ignore" && constructorAction !== "ignore") {
11941
- if (suspectProtoRx.test(text4) === false && suspectConstructorRx.test(text4) === false) {
11941
+ if (suspectProtoRx.test(text5) === false && suspectConstructorRx.test(text5) === false) {
11942
11942
  return obj3;
11943
11943
  }
11944
11944
  } else if (protoAction !== "ignore" && constructorAction === "ignore") {
11945
- if (suspectProtoRx.test(text4) === false) {
11945
+ if (suspectProtoRx.test(text5) === false) {
11946
11946
  return obj3;
11947
11947
  }
11948
11948
  } else {
11949
- if (suspectConstructorRx.test(text4) === false) {
11949
+ if (suspectConstructorRx.test(text5) === false) {
11950
11950
  return obj3;
11951
11951
  }
11952
11952
  }
@@ -11984,20 +11984,20 @@ var require_secure_json_parse = __commonJS({
11984
11984
  }
11985
11985
  return obj3;
11986
11986
  }
11987
- function parse2(text4, reviver, options) {
11987
+ function parse2(text5, reviver, options) {
11988
11988
  const { stackTraceLimit } = Error;
11989
11989
  Error.stackTraceLimit = 0;
11990
11990
  try {
11991
- return _parse(text4, reviver, options);
11991
+ return _parse(text5, reviver, options);
11992
11992
  } finally {
11993
11993
  Error.stackTraceLimit = stackTraceLimit;
11994
11994
  }
11995
11995
  }
11996
- function safeParse(text4, reviver) {
11996
+ function safeParse(text5, reviver) {
11997
11997
  const { stackTraceLimit } = Error;
11998
11998
  Error.stackTraceLimit = 0;
11999
11999
  try {
12000
- return _parse(text4, reviver, { safe: true });
12000
+ return _parse(text5, reviver, { safe: true });
12001
12001
  } catch {
12002
12002
  return void 0;
12003
12003
  } finally {
@@ -12406,10 +12406,10 @@ var require_code = __commonJS({
12406
12406
  }
12407
12407
  get names() {
12408
12408
  var _a2;
12409
- return (_a2 = this._names) !== null && _a2 !== void 0 ? _a2 : this._names = this._items.reduce((names, c) => {
12409
+ return (_a2 = this._names) !== null && _a2 !== void 0 ? _a2 : this._names = this._items.reduce((names2, c) => {
12410
12410
  if (c instanceof Name)
12411
- names[c.str] = (names[c.str] || 0) + 1;
12412
- return names;
12411
+ names2[c.str] = (names2[c.str] || 0) + 1;
12412
+ return names2;
12413
12413
  }, {});
12414
12414
  }
12415
12415
  };
@@ -12735,11 +12735,11 @@ var require_codegen = __commonJS({
12735
12735
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
12736
12736
  return `${varKind} ${this.name}${rhs};` + _n;
12737
12737
  }
12738
- optimizeNames(names, constants2) {
12739
- if (!names[this.name.str])
12738
+ optimizeNames(names2, constants2) {
12739
+ if (!names2[this.name.str])
12740
12740
  return;
12741
12741
  if (this.rhs)
12742
- this.rhs = optimizeExpr(this.rhs, names, constants2);
12742
+ this.rhs = optimizeExpr(this.rhs, names2, constants2);
12743
12743
  return this;
12744
12744
  }
12745
12745
  get names() {
@@ -12756,15 +12756,15 @@ var require_codegen = __commonJS({
12756
12756
  render({ _n }) {
12757
12757
  return `${this.lhs} = ${this.rhs};` + _n;
12758
12758
  }
12759
- optimizeNames(names, constants2) {
12760
- if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
12759
+ optimizeNames(names2, constants2) {
12760
+ if (this.lhs instanceof code_1.Name && !names2[this.lhs.str] && !this.sideEffects)
12761
12761
  return;
12762
- this.rhs = optimizeExpr(this.rhs, names, constants2);
12762
+ this.rhs = optimizeExpr(this.rhs, names2, constants2);
12763
12763
  return this;
12764
12764
  }
12765
12765
  get names() {
12766
- const names = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
12767
- return addExprNames(names, this.rhs);
12766
+ const names2 = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
12767
+ return addExprNames(names2, this.rhs);
12768
12768
  }
12769
12769
  };
12770
12770
  var AssignOp = class extends Assign {
@@ -12820,8 +12820,8 @@ var require_codegen = __commonJS({
12820
12820
  optimizeNodes() {
12821
12821
  return `${this.code}` ? this : void 0;
12822
12822
  }
12823
- optimizeNames(names, constants2) {
12824
- this.code = optimizeExpr(this.code, names, constants2);
12823
+ optimizeNames(names2, constants2) {
12824
+ this.code = optimizeExpr(this.code, names2, constants2);
12825
12825
  return this;
12826
12826
  }
12827
12827
  get names() {
@@ -12850,20 +12850,20 @@ var require_codegen = __commonJS({
12850
12850
  }
12851
12851
  return nodes.length > 0 ? this : void 0;
12852
12852
  }
12853
- optimizeNames(names, constants2) {
12853
+ optimizeNames(names2, constants2) {
12854
12854
  const { nodes } = this;
12855
12855
  let i = nodes.length;
12856
12856
  while (i--) {
12857
12857
  const n = nodes[i];
12858
- if (n.optimizeNames(names, constants2))
12858
+ if (n.optimizeNames(names2, constants2))
12859
12859
  continue;
12860
- subtractNames(names, n.names);
12860
+ subtractNames(names2, n.names);
12861
12861
  nodes.splice(i, 1);
12862
12862
  }
12863
12863
  return nodes.length > 0 ? this : void 0;
12864
12864
  }
12865
12865
  get names() {
12866
- return this.nodes.reduce((names, n) => addNames(names, n.names), {});
12866
+ return this.nodes.reduce((names2, n) => addNames(names2, n.names), {});
12867
12867
  }
12868
12868
  };
12869
12869
  var BlockNode = class extends ParentNode {
@@ -12908,20 +12908,20 @@ var require_codegen = __commonJS({
12908
12908
  return void 0;
12909
12909
  return this;
12910
12910
  }
12911
- optimizeNames(names, constants2) {
12911
+ optimizeNames(names2, constants2) {
12912
12912
  var _a2;
12913
- this.else = (_a2 = this.else) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names, constants2);
12914
- if (!(super.optimizeNames(names, constants2) || this.else))
12913
+ this.else = (_a2 = this.else) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names2, constants2);
12914
+ if (!(super.optimizeNames(names2, constants2) || this.else))
12915
12915
  return;
12916
- this.condition = optimizeExpr(this.condition, names, constants2);
12916
+ this.condition = optimizeExpr(this.condition, names2, constants2);
12917
12917
  return this;
12918
12918
  }
12919
12919
  get names() {
12920
- const names = super.names;
12921
- addExprNames(names, this.condition);
12920
+ const names2 = super.names;
12921
+ addExprNames(names2, this.condition);
12922
12922
  if (this.else)
12923
- addNames(names, this.else.names);
12924
- return names;
12923
+ addNames(names2, this.else.names);
12924
+ return names2;
12925
12925
  }
12926
12926
  };
12927
12927
  If.kind = "if";
@@ -12936,10 +12936,10 @@ var require_codegen = __commonJS({
12936
12936
  render(opts) {
12937
12937
  return `for(${this.iteration})` + super.render(opts);
12938
12938
  }
12939
- optimizeNames(names, constants2) {
12940
- if (!super.optimizeNames(names, constants2))
12939
+ optimizeNames(names2, constants2) {
12940
+ if (!super.optimizeNames(names2, constants2))
12941
12941
  return;
12942
- this.iteration = optimizeExpr(this.iteration, names, constants2);
12942
+ this.iteration = optimizeExpr(this.iteration, names2, constants2);
12943
12943
  return this;
12944
12944
  }
12945
12945
  get names() {
@@ -12960,8 +12960,8 @@ var require_codegen = __commonJS({
12960
12960
  return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
12961
12961
  }
12962
12962
  get names() {
12963
- const names = addExprNames(super.names, this.from);
12964
- return addExprNames(names, this.to);
12963
+ const names2 = addExprNames(super.names, this.from);
12964
+ return addExprNames(names2, this.to);
12965
12965
  }
12966
12966
  };
12967
12967
  var ForIter = class extends For {
@@ -12975,10 +12975,10 @@ var require_codegen = __commonJS({
12975
12975
  render(opts) {
12976
12976
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
12977
12977
  }
12978
- optimizeNames(names, constants2) {
12979
- if (!super.optimizeNames(names, constants2))
12978
+ optimizeNames(names2, constants2) {
12979
+ if (!super.optimizeNames(names2, constants2))
12980
12980
  return;
12981
- this.iterable = optimizeExpr(this.iterable, names, constants2);
12981
+ this.iterable = optimizeExpr(this.iterable, names2, constants2);
12982
12982
  return this;
12983
12983
  }
12984
12984
  get names() {
@@ -13020,20 +13020,20 @@ var require_codegen = __commonJS({
13020
13020
  (_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNodes();
13021
13021
  return this;
13022
13022
  }
13023
- optimizeNames(names, constants2) {
13023
+ optimizeNames(names2, constants2) {
13024
13024
  var _a2, _b2;
13025
- super.optimizeNames(names, constants2);
13026
- (_a2 = this.catch) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names, constants2);
13027
- (_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNames(names, constants2);
13025
+ super.optimizeNames(names2, constants2);
13026
+ (_a2 = this.catch) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names2, constants2);
13027
+ (_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNames(names2, constants2);
13028
13028
  return this;
13029
13029
  }
13030
13030
  get names() {
13031
- const names = super.names;
13031
+ const names2 = super.names;
13032
13032
  if (this.catch)
13033
- addNames(names, this.catch.names);
13033
+ addNames(names2, this.catch.names);
13034
13034
  if (this.finally)
13035
- addNames(names, this.finally.names);
13036
- return names;
13035
+ addNames(names2, this.finally.names);
13036
+ return names2;
13037
13037
  }
13038
13038
  };
13039
13039
  var Catch = class extends BlockNode {
@@ -13317,15 +13317,15 @@ var require_codegen = __commonJS({
13317
13317
  }
13318
13318
  };
13319
13319
  exports2.CodeGen = CodeGen;
13320
- function addNames(names, from) {
13320
+ function addNames(names2, from) {
13321
13321
  for (const n in from)
13322
- names[n] = (names[n] || 0) + (from[n] || 0);
13323
- return names;
13322
+ names2[n] = (names2[n] || 0) + (from[n] || 0);
13323
+ return names2;
13324
13324
  }
13325
- function addExprNames(names, from) {
13326
- return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
13325
+ function addExprNames(names2, from) {
13326
+ return from instanceof code_1._CodeOrName ? addNames(names2, from.names) : names2;
13327
13327
  }
13328
- function optimizeExpr(expr, names, constants2) {
13328
+ function optimizeExpr(expr, names2, constants2) {
13329
13329
  if (expr instanceof code_1.Name)
13330
13330
  return replaceName(expr);
13331
13331
  if (!canOptimize(expr))
@@ -13341,18 +13341,18 @@ var require_codegen = __commonJS({
13341
13341
  }, []));
13342
13342
  function replaceName(n) {
13343
13343
  const c = constants2[n.str];
13344
- if (c === void 0 || names[n.str] !== 1)
13344
+ if (c === void 0 || names2[n.str] !== 1)
13345
13345
  return n;
13346
- delete names[n.str];
13346
+ delete names2[n.str];
13347
13347
  return c;
13348
13348
  }
13349
13349
  function canOptimize(e) {
13350
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants2[c.str] !== void 0);
13350
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names2[c.str] === 1 && constants2[c.str] !== void 0);
13351
13351
  }
13352
13352
  }
13353
- function subtractNames(names, from) {
13353
+ function subtractNames(names2, from) {
13354
13354
  for (const n in from)
13355
- names[n] = (names[n] || 0) - (from[n] || 0);
13355
+ names2[n] = (names2[n] || 0) - (from[n] || 0);
13356
13356
  }
13357
13357
  function not(x) {
13358
13358
  return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._)`!${par(x)}`;
@@ -13550,7 +13550,7 @@ var require_names = __commonJS({
13550
13550
  "use strict";
13551
13551
  Object.defineProperty(exports2, "__esModule", { value: true });
13552
13552
  var codegen_1 = require_codegen();
13553
- var names = {
13553
+ var names2 = {
13554
13554
  // validation function arguments
13555
13555
  data: new codegen_1.Name("data"),
13556
13556
  // data passed to validation function
@@ -13579,7 +13579,7 @@ var require_names = __commonJS({
13579
13579
  jsonLen: new codegen_1.Name("jsonLen"),
13580
13580
  jsonPart: new codegen_1.Name("jsonPart")
13581
13581
  };
13582
- exports2.default = names;
13582
+ exports2.default = names2;
13583
13583
  }
13584
13584
  });
13585
13585
 
@@ -14545,20 +14545,20 @@ var require_resolve = __commonJS({
14545
14545
  return false;
14546
14546
  }
14547
14547
  function countKeys(schema) {
14548
- let count = 0;
14548
+ let count2 = 0;
14549
14549
  for (const key in schema) {
14550
14550
  if (key === "$ref")
14551
14551
  return Infinity;
14552
- count++;
14552
+ count2++;
14553
14553
  if (SIMPLE_INLINED.has(key))
14554
14554
  continue;
14555
14555
  if (typeof schema[key] == "object") {
14556
- (0, util_1.eachItem)(schema[key], (sch) => count += countKeys(sch));
14556
+ (0, util_1.eachItem)(schema[key], (sch) => count2 += countKeys(sch));
14557
14557
  }
14558
- if (count === Infinity)
14558
+ if (count2 === Infinity)
14559
14559
  return Infinity;
14560
14560
  }
14561
- return count;
14561
+ return count2;
14562
14562
  }
14563
14563
  function getFullPath(resolver, id = "", normalize2) {
14564
14564
  if (normalize2 !== false)
@@ -16640,7 +16640,7 @@ var require_core = __commonJS({
16640
16640
  errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
16641
16641
  if (!errors || errors.length === 0)
16642
16642
  return "No errors";
16643
- return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text4, msg) => text4 + separator + msg);
16643
+ return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text5, msg) => text5 + separator + msg);
16644
16644
  }
16645
16645
  $dataMetaSchema(metaSchema, keywordsJsonPointers) {
16646
16646
  const rules = this.RULES.all;
@@ -17730,8 +17730,8 @@ var require_contains = __commonJS({
17730
17730
  cxt.result(valid, () => cxt.reset());
17731
17731
  function validateItemsWithCount() {
17732
17732
  const schValid = gen.name("_valid");
17733
- const count = gen.let("count", 0);
17734
- validateItems(schValid, () => gen.if(schValid, () => checkLimits(count)));
17733
+ const count2 = gen.let("count", 0);
17734
+ validateItems(schValid, () => gen.if(schValid, () => checkLimits(count2)));
17735
17735
  }
17736
17736
  function validateItems(_valid, block) {
17737
17737
  gen.forRange("i", 0, len, (i) => {
@@ -17744,16 +17744,16 @@ var require_contains = __commonJS({
17744
17744
  block();
17745
17745
  });
17746
17746
  }
17747
- function checkLimits(count) {
17748
- gen.code((0, codegen_1._)`${count}++`);
17747
+ function checkLimits(count2) {
17748
+ gen.code((0, codegen_1._)`${count2}++`);
17749
17749
  if (max2 === void 0) {
17750
- gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid, true).break());
17750
+ gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid, true).break());
17751
17751
  } else {
17752
- gen.if((0, codegen_1._)`${count} > ${max2}`, () => gen.assign(valid, false).break());
17752
+ gen.if((0, codegen_1._)`${count2} > ${max2}`, () => gen.assign(valid, false).break());
17753
17753
  if (min === 1)
17754
17754
  gen.assign(valid, true);
17755
17755
  else
17756
- gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid, true));
17756
+ gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid, true));
17757
17757
  }
17758
17758
  }
17759
17759
  }
@@ -20100,9 +20100,9 @@ var require_parseJson = __commonJS({
20100
20100
  pos2++;
20101
20101
  } else if (c === "u") {
20102
20102
  pos2++;
20103
- let count = 4;
20103
+ let count2 = 4;
20104
20104
  let code = 0;
20105
- while (count--) {
20105
+ while (count2--) {
20106
20106
  code <<= 4;
20107
20107
  c = s[pos2];
20108
20108
  if (c === void 0) {
@@ -21076,8 +21076,8 @@ var require_standalone = __commonJS({
21076
21076
  }
21077
21077
  function setUsedState(name, state2) {
21078
21078
  const { prefix } = name;
21079
- const names = usedValues[prefix] = usedValues[prefix] || /* @__PURE__ */ new Map();
21080
- names.set(name, state2);
21079
+ const names2 = usedValues[prefix] = usedValues[prefix] || /* @__PURE__ */ new Map();
21080
+ names2.set(name, state2);
21081
21081
  }
21082
21082
  }
21083
21083
  }
@@ -40846,7 +40846,7 @@ var require_plugin2 = __commonJS({
40846
40846
  "use strict";
40847
40847
  var getPluginName = require_getPluginName();
40848
40848
  var toCamelCase = require_toCamelCase();
40849
- var count = 0;
40849
+ var count2 = 0;
40850
40850
  function plugin(fn, options = {}) {
40851
40851
  let autoName = false;
40852
40852
  if (fn.default !== void 0) {
@@ -40870,7 +40870,7 @@ var require_plugin2 = __commonJS({
40870
40870
  }
40871
40871
  if (!options.name) {
40872
40872
  autoName = true;
40873
- options.name = getPluginName(fn) + "-auto-" + count++;
40873
+ options.name = getPluginName(fn) + "-auto-" + count2++;
40874
40874
  }
40875
40875
  fn[/* @__PURE__ */ Symbol.for("skip-override")] = options.encapsulate !== true;
40876
40876
  fn[/* @__PURE__ */ Symbol.for("fastify.display-name")] = options.name;
@@ -41333,8 +41333,8 @@ var require_depd = __commonJS({
41333
41333
  return deprecate;
41334
41334
  }
41335
41335
  function eehaslisteners(emitter, type) {
41336
- var count = typeof emitter.listenerCount !== "function" ? emitter.listeners(type).length : emitter.listenerCount(type);
41337
- return count > 0;
41336
+ var count2 = typeof emitter.listenerCount !== "function" ? emitter.listeners(type).length : emitter.listenerCount(type);
41337
+ return count2 > 0;
41338
41338
  }
41339
41339
  function isignored(namespace) {
41340
41340
  if (process.noDeprecation) {
@@ -42758,7 +42758,7 @@ var require_content_disposition = __commonJS({
42758
42758
  var index = match[0].length;
42759
42759
  var type = match[1].toLowerCase();
42760
42760
  var key;
42761
- var names = [];
42761
+ var names2 = [];
42762
42762
  var params = {};
42763
42763
  var value;
42764
42764
  index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === ";" ? index - 1 : index;
@@ -42769,10 +42769,10 @@ var require_content_disposition = __commonJS({
42769
42769
  index += match[0].length;
42770
42770
  key = match[1].toLowerCase();
42771
42771
  value = match[2];
42772
- if (names.indexOf(key) !== -1) {
42772
+ if (names2.indexOf(key) !== -1) {
42773
42773
  throw new TypeError("invalid duplicate parameter");
42774
42774
  }
42775
- names.push(key);
42775
+ names2.push(key);
42776
42776
  if (key.indexOf("*") + 1 === key.length) {
42777
42777
  key = key.slice(0, -1);
42778
42778
  value = decodefield(value);
@@ -43012,7 +43012,7 @@ var require_static = __commonJS({
43012
43012
  "use strict";
43013
43013
  var path = require("node:path");
43014
43014
  var { fileURLToPath: fileURLToPath6 } = require("node:url");
43015
- var { statSync: statSync30 } = require("node:fs");
43015
+ var { statSync: statSync31 } = require("node:fs");
43016
43016
  var { glob } = require_commonjs6();
43017
43017
  var fp = require_plugin2();
43018
43018
  var send = require_send2();
@@ -43375,7 +43375,7 @@ var require_static = __commonJS({
43375
43375
  }
43376
43376
  let pathStat;
43377
43377
  try {
43378
- pathStat = statSync30(rootPath);
43378
+ pathStat = statSync31(rootPath);
43379
43379
  } catch (e) {
43380
43380
  if (e.code === "ENOENT") {
43381
43381
  fastify.log.warn(`"root" path "${rootPath}" must exist`);
@@ -43399,7 +43399,7 @@ var require_static = __commonJS({
43399
43399
  return indexFiles.find((filename) => {
43400
43400
  const p = path.join(root6, pathname, filename);
43401
43401
  try {
43402
- const stats = statSync30(p);
43402
+ const stats = statSync31(p);
43403
43403
  return !stats.isDirectory();
43404
43404
  } catch {
43405
43405
  return false;
@@ -44009,8 +44009,8 @@ var require_Node = __commonJS({
44009
44009
  };
44010
44010
  const res = toJS.toJS(this, "", ctx);
44011
44011
  if (typeof onAnchor === "function")
44012
- for (const { count, res: res2 } of ctx.anchors.values())
44013
- onAnchor(res2, count);
44012
+ for (const { count: count2, res: res2 } of ctx.anchors.values())
44013
+ onAnchor(res2, count2);
44014
44014
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
44015
44015
  }
44016
44016
  };
@@ -44116,13 +44116,13 @@ var require_Alias = __commonJS({
44116
44116
  const anchor = anchors2 && source && anchors2.get(source);
44117
44117
  return anchor ? anchor.count * anchor.aliasCount : 0;
44118
44118
  } else if (identity.isCollection(node)) {
44119
- let count = 0;
44119
+ let count2 = 0;
44120
44120
  for (const item of node.items) {
44121
44121
  const c = getAliasCount(doc, item, anchors2);
44122
- if (c > count)
44123
- count = c;
44122
+ if (c > count2)
44123
+ count2 = c;
44124
44124
  }
44125
- return count;
44125
+ return count2;
44126
44126
  } else if (identity.isPair(node)) {
44127
44127
  const kc = getAliasCount(doc, node.key, anchors2);
44128
44128
  const vc = getAliasCount(doc, node.value, anchors2);
@@ -44406,14 +44406,14 @@ var require_foldFlowLines = __commonJS({
44406
44406
  var FOLD_FLOW = "flow";
44407
44407
  var FOLD_BLOCK = "block";
44408
44408
  var FOLD_QUOTED = "quoted";
44409
- function foldFlowLines(text4, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
44409
+ function foldFlowLines(text5, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
44410
44410
  if (!lineWidth || lineWidth < 0)
44411
- return text4;
44411
+ return text5;
44412
44412
  if (lineWidth < minContentWidth)
44413
44413
  minContentWidth = 0;
44414
44414
  const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
44415
- if (text4.length <= endStep)
44416
- return text4;
44415
+ if (text5.length <= endStep)
44416
+ return text5;
44417
44417
  const folds = [];
44418
44418
  const escapedFolds = {};
44419
44419
  let end = lineWidth - indent.length;
@@ -44430,14 +44430,14 @@ var require_foldFlowLines = __commonJS({
44430
44430
  let escStart = -1;
44431
44431
  let escEnd = -1;
44432
44432
  if (mode === FOLD_BLOCK) {
44433
- i = consumeMoreIndentedLines(text4, i, indent.length);
44433
+ i = consumeMoreIndentedLines(text5, i, indent.length);
44434
44434
  if (i !== -1)
44435
44435
  end = i + endStep;
44436
44436
  }
44437
- for (let ch2; ch2 = text4[i += 1]; ) {
44437
+ for (let ch2; ch2 = text5[i += 1]; ) {
44438
44438
  if (mode === FOLD_QUOTED && ch2 === "\\") {
44439
44439
  escStart = i;
44440
- switch (text4[i + 1]) {
44440
+ switch (text5[i + 1]) {
44441
44441
  case "x":
44442
44442
  i += 3;
44443
44443
  break;
@@ -44454,12 +44454,12 @@ var require_foldFlowLines = __commonJS({
44454
44454
  }
44455
44455
  if (ch2 === "\n") {
44456
44456
  if (mode === FOLD_BLOCK)
44457
- i = consumeMoreIndentedLines(text4, i, indent.length);
44457
+ i = consumeMoreIndentedLines(text5, i, indent.length);
44458
44458
  end = i + indent.length + endStep;
44459
44459
  split = void 0;
44460
44460
  } else {
44461
44461
  if (ch2 === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
44462
- const next = text4[i + 1];
44462
+ const next = text5[i + 1];
44463
44463
  if (next && next !== " " && next !== "\n" && next !== " ")
44464
44464
  split = i;
44465
44465
  }
@@ -44471,12 +44471,12 @@ var require_foldFlowLines = __commonJS({
44471
44471
  } else if (mode === FOLD_QUOTED) {
44472
44472
  while (prev === " " || prev === " ") {
44473
44473
  prev = ch2;
44474
- ch2 = text4[i += 1];
44474
+ ch2 = text5[i += 1];
44475
44475
  overflow = true;
44476
44476
  }
44477
44477
  const j = i > escEnd + 1 ? i - 2 : escStart - 1;
44478
44478
  if (escapedFolds[j])
44479
- return text4;
44479
+ return text5;
44480
44480
  folds.push(j);
44481
44481
  escapedFolds[j] = true;
44482
44482
  end = j + endStep;
@@ -44491,39 +44491,39 @@ var require_foldFlowLines = __commonJS({
44491
44491
  if (overflow && onOverflow)
44492
44492
  onOverflow();
44493
44493
  if (folds.length === 0)
44494
- return text4;
44494
+ return text5;
44495
44495
  if (onFold)
44496
44496
  onFold();
44497
- let res = text4.slice(0, folds[0]);
44497
+ let res = text5.slice(0, folds[0]);
44498
44498
  for (let i2 = 0; i2 < folds.length; ++i2) {
44499
44499
  const fold = folds[i2];
44500
- const end2 = folds[i2 + 1] || text4.length;
44500
+ const end2 = folds[i2 + 1] || text5.length;
44501
44501
  if (fold === 0)
44502
44502
  res = `
44503
- ${indent}${text4.slice(0, end2)}`;
44503
+ ${indent}${text5.slice(0, end2)}`;
44504
44504
  else {
44505
44505
  if (mode === FOLD_QUOTED && escapedFolds[fold])
44506
- res += `${text4[fold]}\\`;
44506
+ res += `${text5[fold]}\\`;
44507
44507
  res += `
44508
- ${indent}${text4.slice(fold + 1, end2)}`;
44508
+ ${indent}${text5.slice(fold + 1, end2)}`;
44509
44509
  }
44510
44510
  }
44511
44511
  return res;
44512
44512
  }
44513
- function consumeMoreIndentedLines(text4, i, indent) {
44513
+ function consumeMoreIndentedLines(text5, i, indent) {
44514
44514
  let end = i;
44515
44515
  let start2 = i + 1;
44516
- let ch2 = text4[start2];
44516
+ let ch2 = text5[start2];
44517
44517
  while (ch2 === " " || ch2 === " ") {
44518
44518
  if (i < start2 + indent) {
44519
- ch2 = text4[++i];
44519
+ ch2 = text5[++i];
44520
44520
  } else {
44521
44521
  do {
44522
- ch2 = text4[++i];
44522
+ ch2 = text5[++i];
44523
44523
  } while (ch2 && ch2 !== "\n");
44524
44524
  end = i;
44525
44525
  start2 = i + 1;
44526
- ch2 = text4[start2];
44526
+ ch2 = text5[start2];
44527
44527
  }
44528
44528
  }
44529
44529
  return end;
@@ -47075,8 +47075,8 @@ var require_Document = __commonJS({
47075
47075
  };
47076
47076
  const res = toJS.toJS(this.contents, jsonArg ?? "", ctx);
47077
47077
  if (typeof onAnchor === "function")
47078
- for (const { count, res: res2 } of ctx.anchors.values())
47079
- onAnchor(res2, count);
47078
+ for (const { count: count2, res: res2 } of ctx.anchors.values())
47079
+ onAnchor(res2, count2);
47080
47080
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
47081
47081
  }
47082
47082
  /**
@@ -47153,12 +47153,12 @@ var require_errors5 = __commonJS({
47153
47153
  lineStr = prev + lineStr;
47154
47154
  }
47155
47155
  if (/[^ ]/.test(lineStr)) {
47156
- let count = 1;
47156
+ let count2 = 1;
47157
47157
  const end = error.linePos[1];
47158
47158
  if (end?.line === line && end.col > col) {
47159
- count = Math.max(1, Math.min(end.col - col, 80 - ci));
47159
+ count2 = Math.max(1, Math.min(end.col - col, 80 - ci));
47160
47160
  }
47161
- const pointer = " ".repeat(ci) + "^".repeat(count);
47161
+ const pointer = " ".repeat(ci) + "^".repeat(count2);
47162
47162
  error.message += `:
47163
47163
 
47164
47164
  ${lineStr}
@@ -50770,7 +50770,7 @@ var require_dist6 = __commonJS({
50770
50770
 
50771
50771
  // install-path.mjs
50772
50772
  var import_node_fs = require("node:fs");
50773
- function resolveRealInstallExePure(execPath, localAppData, exists, readdir5, realpath3) {
50773
+ function resolveRealInstallExePure(execPath, localAppData, exists, readdir6, realpath3) {
50774
50774
  if (!execPath) return execPath;
50775
50775
  let resolved = execPath;
50776
50776
  try {
@@ -50789,7 +50789,7 @@ function resolveRealInstallExePure(execPath, localAppData, exists, readdir5, rea
50789
50789
  const packagesDir2 = `${laRoot}\\Packages`;
50790
50790
  let packages;
50791
50791
  try {
50792
- packages = readdir5(packagesDir2);
50792
+ packages = readdir6(packagesDir2);
50793
50793
  } catch {
50794
50794
  return execPath;
50795
50795
  }
@@ -50822,16 +50822,16 @@ function deriveSandboxLicenseDir() {
50822
50822
  deriveSandboxLicenseDir();
50823
50823
 
50824
50824
  // main.ts
50825
- var import_node_child_process18 = require("node:child_process");
50825
+ var import_node_child_process19 = require("node:child_process");
50826
50826
  var import_node_readline2 = require("node:readline");
50827
50827
 
50828
50828
  // index.ts
50829
50829
  var import_node_url5 = require("node:url");
50830
50830
  var import_node_path70 = require("node:path");
50831
50831
  var import_node_os38 = require("node:os");
50832
- var import_node_fs73 = require("node:fs");
50833
- var import_node_child_process16 = require("node:child_process");
50834
- var import_node_util6 = require("node:util");
50832
+ var import_node_fs74 = require("node:fs");
50833
+ var import_node_child_process17 = require("node:child_process");
50834
+ var import_node_util7 = require("node:util");
50835
50835
 
50836
50836
  // log.mjs
50837
50837
  var import_node_path = require("node:path");
@@ -51667,16 +51667,16 @@ function cancelJournalState(journal, all) {
51667
51667
  function pendingRenameJournals() {
51668
51668
  const dir = renameJournalDir();
51669
51669
  if (!(0, import_node_fs7.existsSync)(dir)) return [];
51670
- const names = (0, import_node_fs7.readdirSync)(dir).filter((name) => name.endsWith(".json"));
51671
- if (names.length > 256) throw new Error(`app-origin rename recovery refused ${names.length} journals`);
51672
- return names.map((name) => readRenameJournal(name.slice(0, -".json".length)));
51670
+ const names2 = (0, import_node_fs7.readdirSync)(dir).filter((name) => name.endsWith(".json"));
51671
+ if (names2.length > 256) throw new Error(`app-origin rename recovery refused ${names2.length} journals`);
51672
+ return names2.map((name) => readRenameJournal(name.slice(0, -".json".length)));
51673
51673
  }
51674
51674
  function pendingDuplicateJournals() {
51675
51675
  const dir = duplicateJournalDir();
51676
51676
  if (!(0, import_node_fs7.existsSync)(dir)) return [];
51677
- const names = (0, import_node_fs7.readdirSync)(dir).filter((name) => name.endsWith(".json"));
51678
- if (names.length > 256) throw new Error(`app-origin duplicate recovery refused ${names.length} journals`);
51679
- return names.map((name) => readDuplicateJournal(name.slice(0, -".json".length)));
51677
+ const names2 = (0, import_node_fs7.readdirSync)(dir).filter((name) => name.endsWith(".json"));
51678
+ if (names2.length > 256) throw new Error(`app-origin duplicate recovery refused ${names2.length} journals`);
51679
+ return names2.map((name) => readDuplicateJournal(name.slice(0, -".json".length)));
51680
51680
  }
51681
51681
  function assertNoPendingOriginOperation(...ids) {
51682
51682
  const pending = pendingRenameJournals().find((journal) => ids.includes(journal.oldId) || ids.includes(journal.newId));
@@ -51987,13 +51987,13 @@ var APPS_DIR = process.env.AWARE_HOME ? (0, import_node_path6.join)(process.env.
51987
51987
  function normalizeNote(n) {
51988
51988
  if (n && typeof n === "object") {
51989
51989
  const o = n;
51990
- const text5 = typeof o.text === "string" ? o.text : String(o.text ?? "");
51990
+ const text6 = typeof o.text === "string" ? o.text : String(o.text ?? "");
51991
51991
  const kind2 = o.kind === "warn" || o.kind === "error" ? o.kind : "info";
51992
- return { kind: kind2, text: text5 };
51992
+ return { kind: kind2, text: text6 };
51993
51993
  }
51994
- const text4 = String(n);
51995
- const kind = /defaulting to write-mode|not installed/i.test(text4) ? "warn" : "info";
51996
- return { kind, text: text4 };
51994
+ const text5 = String(n);
51995
+ const kind = /defaulting to write-mode|not installed/i.test(text5) ? "warn" : "info";
51996
+ return { kind, text: text5 };
51997
51997
  }
51998
51998
  function isVisualInput(i) {
51999
51999
  return i.widget === "file" || i.type === "image" || i.type === "file";
@@ -52037,8 +52037,8 @@ function firstWithExt(dir, ext) {
52037
52037
  const hit = (0, import_node_fs8.readdirSync)(dir).find((f) => f.toLowerCase().endsWith(ext));
52038
52038
  return hit ? (0, import_node_path6.join)(dir, hit) : null;
52039
52039
  }
52040
- function sha256(text4) {
52041
- return (0, import_node_crypto4.createHash)("sha256").update(text4).digest("hex");
52040
+ function sha256(text5) {
52041
+ return (0, import_node_crypto4.createHash)("sha256").update(text5).digest("hex");
52042
52042
  }
52043
52043
  function asRecord(v) {
52044
52044
  return v && typeof v === "object" && !Array.isArray(v) ? v : {};
@@ -52055,7 +52055,7 @@ function appMeta(id, bypassCache = false) {
52055
52055
  const hit = bypassCache ? void 0 : metaCache.get(sourcePath2);
52056
52056
  if (hit && hit.mtimeMs === st.mtimeMs && hit.size === st.size && hit.ino === st.ino) return hit.meta;
52057
52057
  sourceParses++;
52058
- const text4 = (0, import_node_fs8.readFileSync)(sourcePath2, "utf8");
52058
+ const text5 = (0, import_node_fs8.readFileSync)(sourcePath2, "utf8");
52059
52059
  const after = (0, import_node_fs8.statSync)(sourcePath2);
52060
52060
  const settled2 = after.mtimeMs === st.mtimeMs && after.size === st.size && after.ino === st.ino;
52061
52061
  const remember = (meta2) => {
@@ -52064,7 +52064,7 @@ function appMeta(id, bypassCache = false) {
52064
52064
  };
52065
52065
  let src;
52066
52066
  try {
52067
- src = asRecord((0, import_yaml.parse)(text4));
52067
+ src = asRecord((0, import_yaml.parse)(text5));
52068
52068
  } catch {
52069
52069
  return remember(META_DEFAULT);
52070
52070
  }
@@ -52385,8 +52385,8 @@ function mergeConnectables(base, live, displayName) {
52385
52385
  }
52386
52386
  return [...base, ...extra].sort((a, b) => a.name.localeCompare(b.name));
52387
52387
  }
52388
- function parseTrace(text4) {
52389
- return text4.split(/\r?\n/).filter((l) => l.trim()).map((l) => {
52388
+ function parseTrace(text5) {
52389
+ return text5.split(/\r?\n/).filter((l) => l.trim()).map((l) => {
52390
52390
  try {
52391
52391
  return JSON.parse(l);
52392
52392
  } catch {
@@ -53385,7 +53385,7 @@ function watchRunProgress(id, onProgress) {
53385
53385
  }
53386
53386
  if (size < offset) offset = 0;
53387
53387
  if (size <= offset) return;
53388
- let text4;
53388
+ let text5;
53389
53389
  let fd2 = -1;
53390
53390
  try {
53391
53391
  fd2 = (0, import_node_fs9.openSync)(tracePath, "r");
@@ -53393,7 +53393,7 @@ function watchRunProgress(id, onProgress) {
53393
53393
  const read2 = (0, import_node_fs9.readSync)(fd2, buf, 0, buf.length, offset);
53394
53394
  const nl = buf.lastIndexOf(10, read2 - 1);
53395
53395
  if (nl < 0) return;
53396
- text4 = buf.subarray(0, nl + 1).toString("utf8");
53396
+ text5 = buf.subarray(0, nl + 1).toString("utf8");
53397
53397
  offset += nl + 1;
53398
53398
  } catch {
53399
53399
  return;
@@ -53405,7 +53405,7 @@ function watchRunProgress(id, onProgress) {
53405
53405
  }
53406
53406
  }
53407
53407
  }
53408
- for (const line of text4.split(/\r?\n/)) {
53408
+ for (const line of text5.split(/\r?\n/)) {
53409
53409
  if (!line.trim()) continue;
53410
53410
  let ev;
53411
53411
  try {
@@ -53636,8 +53636,8 @@ function agentInvokeArgv(agent, command, inputsRef) {
53636
53636
  function isInvokeUnsupported(detail) {
53637
53637
  if (!detail || typeof detail !== "object") return false;
53638
53638
  const d = detail;
53639
- const text4 = [d.stdout, d.stderr].filter((s) => typeof s === "string").join("\n");
53640
- return /unrecognized subcommand|unknown subcommand/i.test(text4);
53639
+ const text5 = [d.stdout, d.stderr].filter((s) => typeof s === "string").join("\n");
53640
+ return /unrecognized subcommand|unknown subcommand/i.test(text5);
53641
53641
  }
53642
53642
  var inFlightConnects = /* @__PURE__ */ new Map();
53643
53643
  function cancelAllConnects() {
@@ -54216,10 +54216,10 @@ function readExtensionsText() {
54216
54216
  }
54217
54217
  }
54218
54218
  function readExtensions() {
54219
- const text4 = readExtensionsText();
54220
- if (text4 === null) return null;
54219
+ const text5 = readExtensionsText();
54220
+ if (text5 === null) return null;
54221
54221
  try {
54222
- const parsed = JSON.parse(text4);
54222
+ const parsed = JSON.parse(text5);
54223
54223
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
54224
54224
  } catch {
54225
54225
  return null;
@@ -54229,24 +54229,24 @@ function descriptorPanels(d) {
54229
54229
  if (!d || !Array.isArray(d.panels)) return [];
54230
54230
  return d.panels.filter((p) => !!p && typeof p === "object" && !Array.isArray(p));
54231
54231
  }
54232
- function panelsCountOf(text4) {
54233
- if (text4 === null) return 0;
54232
+ function panelsCountOf(text5) {
54233
+ if (text5 === null) return 0;
54234
54234
  try {
54235
- const parsed = JSON.parse(text4);
54235
+ const parsed = JSON.parse(text5);
54236
54236
  return parsed && typeof parsed === "object" && Array.isArray(parsed.panels) ? parsed.panels.length : 0;
54237
54237
  } catch {
54238
54238
  return 0;
54239
54239
  }
54240
54240
  }
54241
54241
  function loadTimeline() {
54242
- let text4;
54242
+ let text5;
54243
54243
  try {
54244
- text4 = (0, import_node_fs10.readFileSync)(TIMELINE_FILE, "utf8");
54244
+ text5 = (0, import_node_fs10.readFileSync)(TIMELINE_FILE, "utf8");
54245
54245
  } catch {
54246
54246
  return { cursor: -1, entries: [] };
54247
54247
  }
54248
54248
  try {
54249
- const parsed = JSON.parse(text4);
54249
+ const parsed = JSON.parse(text5);
54250
54250
  if (!parsed || typeof parsed !== "object") return { cursor: -1, entries: [] };
54251
54251
  const p = parsed;
54252
54252
  const rawEntries = Array.isArray(p.entries) ? p.entries : [];
@@ -54268,10 +54268,10 @@ function saveTimeline(t) {
54268
54268
  (0, import_node_fs10.writeFileSync)(tmp, JSON.stringify(t, null, 2));
54269
54269
  (0, import_node_fs10.renameSync)(tmp, TIMELINE_FILE);
54270
54270
  }
54271
- function writeExtensionsText(text4) {
54271
+ function writeExtensionsText(text5) {
54272
54272
  ensureUiDir();
54273
54273
  const tmp = `${extensionsFile}.${process.pid}.tmp`;
54274
- (0, import_node_fs10.writeFileSync)(tmp, text4);
54274
+ (0, import_node_fs10.writeFileSync)(tmp, text5);
54275
54275
  (0, import_node_fs10.renameSync)(tmp, extensionsFile);
54276
54276
  }
54277
54277
  function applyState(entry2) {
@@ -54292,15 +54292,15 @@ function seedTimeline() {
54292
54292
  if (t.entries.length > 0) return;
54293
54293
  saveTimeline({ cursor: 0, entries: [{ content: readExtensionsText(), ts: (/* @__PURE__ */ new Date()).toISOString() }] });
54294
54294
  }
54295
- function recordChange(text4) {
54295
+ function recordChange(text5) {
54296
54296
  const t = loadTimeline();
54297
54297
  if (t.entries.length === 0) {
54298
- saveTimeline({ cursor: 0, entries: [{ content: text4, ts: (/* @__PURE__ */ new Date()).toISOString() }] });
54298
+ saveTimeline({ cursor: 0, entries: [{ content: text5, ts: (/* @__PURE__ */ new Date()).toISOString() }] });
54299
54299
  return { recorded: true };
54300
54300
  }
54301
- if (text4 === currentContent(t)) return { recorded: false };
54301
+ if (text5 === currentContent(t)) return { recorded: false };
54302
54302
  const entries = t.entries.slice(0, t.cursor + 1);
54303
- entries.push({ content: text4, ts: (/* @__PURE__ */ new Date()).toISOString() });
54303
+ entries.push({ content: text5, ts: (/* @__PURE__ */ new Date()).toISOString() });
54304
54304
  let cursor = entries.length - 1;
54305
54305
  while (entries.length > HISTORY_KEEP) {
54306
54306
  entries.shift();
@@ -54372,8 +54372,8 @@ function isUiAgentMissing(err2) {
54372
54372
  const detail = err2.detail ?? {};
54373
54373
  const stdout = typeof detail.stdout === "string" ? detail.stdout : "";
54374
54374
  const stderr = typeof detail.stderr === "string" ? detail.stderr : "";
54375
- const text4 = `${err2.message} ${stdout} ${stderr}`;
54376
- return /not installed/i.test(text4);
54375
+ const text5 = `${err2.message} ${stdout} ${stderr}`;
54376
+ return /not installed/i.test(text5);
54377
54377
  }
54378
54378
  function classifyValidateError(err2) {
54379
54379
  if (err2 instanceof AwareUnsupportedError) {
@@ -54980,7 +54980,7 @@ function appVersion() {
54980
54980
  return resolveVersion({
54981
54981
  isSea: isSea2(),
54982
54982
  sqVersionXml: readSqVersionXml(),
54983
- define: true ? "0.130.0" : void 0,
54983
+ define: true ? "0.130.1" : void 0,
54984
54984
  pkgVersion: readPkgVersion()
54985
54985
  });
54986
54986
  }
@@ -54996,7 +54996,7 @@ function resolveChannel(s) {
54996
54996
  function appChannel() {
54997
54997
  return resolveChannel({
54998
54998
  isSea: isSea2(),
54999
- define: true ? "0.130.0" : void 0,
54999
+ define: true ? "0.130.1" : void 0,
55000
55000
  // argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
55001
55001
  // carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
55002
55002
  modulePath: process.argv[1]
@@ -55660,9 +55660,9 @@ function checkModelReferences(doc) {
55660
55660
  if (has("control2_at") && !has("control2_ref")) {
55661
55661
  add(`$.plans[${pi}]`, "control-pair-incomplete", `sheet "${sheet ?? pi}" has control2_at with no control2_ref; a second control is never the model origin, so the intersection it names must be stated`);
55662
55662
  }
55663
- for (const side of ["datum", "control2"]) {
55664
- if (has(`${side}_ref`) && !has(`${side}_at`)) {
55665
- add(`$.plans[${pi}]`, "control-pair-incomplete", `sheet "${sheet ?? pi}" has ${side}_ref with no ${side}_at; naming an intersection without its point on the sheet registers nothing`);
55663
+ for (const side2 of ["datum", "control2"]) {
55664
+ if (has(`${side2}_ref`) && !has(`${side2}_at`)) {
55665
+ add(`$.plans[${pi}]`, "control-pair-incomplete", `sheet "${sheet ?? pi}" has ${side2}_ref with no ${side2}_at; naming an intersection without its point on the sheet registers nothing`);
55666
55666
  }
55667
55667
  }
55668
55668
  });
@@ -55790,12 +55790,12 @@ function checkModelReferences(doc) {
55790
55790
  if (declared !== parsedCount) add("$.grid.axes", "grid-axis-count", `${dir} has ${parsedCount} parsed entries but ${declared} declared axes`);
55791
55791
  };
55792
55792
  for (const dir of ["x", "y"]) {
55793
- const text4 = str(grid[dir]);
55794
- if (text4 === null) {
55793
+ const text5 = str(grid[dir]);
55794
+ if (text5 === null) {
55795
55795
  compare(dir, 0);
55796
55796
  continue;
55797
55797
  }
55798
- const parsed = parseSpacings(text4);
55798
+ const parsed = parseSpacings(text5);
55799
55799
  if (parsed.err) add(`$.grid.${dir}`, "grid-spacing-invalid", `${dir} grid string is unparseable: ${parsed.err}`);
55800
55800
  else compare(dir, parsed.offsets.length);
55801
55801
  }
@@ -58282,10 +58282,10 @@ var IMPORT_MAX_UNCOMPRESSED = 2 * 1024 * 1024 * 1024;
58282
58282
  function importProjectZip(data) {
58283
58283
  let entries;
58284
58284
  try {
58285
- let count = 0, uncompressed = 0;
58285
+ let count2 = 0, uncompressed = 0;
58286
58286
  entries = unzipSync(data, {
58287
58287
  filter: (f) => {
58288
- if (++count > IMPORT_MAX_FILES) throw new ProjectError("archive has too many entries");
58288
+ if (++count2 > IMPORT_MAX_FILES) throw new ProjectError("archive has too many entries");
58289
58289
  uncompressed += f.originalSize;
58290
58290
  if (uncompressed > IMPORT_MAX_UNCOMPRESSED) throw new ProjectError("archive is too large uncompressed");
58291
58291
  return true;
@@ -59170,8 +59170,8 @@ async function recoverAllIfcPublications() {
59170
59170
  const projectPath = (0, import_node_path20.join)(projectsRoot2, entry2.name);
59171
59171
  safeTransactionDirectory(projectPath);
59172
59172
  const dir = projectExportsDir(entry2.name);
59173
- const names = await recoverIfcPublicationsInDirectory(dir, { kind: "project", key: entry2.name });
59174
- recovered.push(...names.map((name) => `${entry2.name}/${name}`));
59173
+ const names2 = await recoverIfcPublicationsInDirectory(dir, { kind: "project", key: entry2.name });
59174
+ recovered.push(...names2.map((name) => `${entry2.name}/${name}`));
59175
59175
  }
59176
59176
  }
59177
59177
  const root6 = (0, import_node_path20.join)(rootHome, "exports");
@@ -59183,11 +59183,11 @@ async function recoverAllIfcPublications() {
59183
59183
  if (!entry2.isDirectory()) continue;
59184
59184
  if (!/^[A-Za-z0-9._-]+$/.test(entry2.name)) continue;
59185
59185
  safeTransactionDirectory((0, import_node_path20.join)(root6, entry2.name));
59186
- const names = await recoverIfcPublicationsInDirectory(
59186
+ const names2 = await recoverIfcPublicationsInDirectory(
59187
59187
  (0, import_node_path20.join)(root6, entry2.name),
59188
59188
  { kind: "app", key: entry2.name }
59189
59189
  );
59190
- recovered.push(...names.map((name) => `${entry2.name}/${name}`));
59190
+ recovered.push(...names2.map((name) => `${entry2.name}/${name}`));
59191
59191
  }
59192
59192
  }
59193
59193
  return recovered;
@@ -59555,7 +59555,7 @@ function plyFitsSection(t, half) {
59555
59555
  return t > 0 && t < 2 * half;
59556
59556
  }
59557
59557
  function bearingFaces(x, uOnN, vOnN, requestedSide) {
59558
- const side = requestedSide >= 0 ? 1 : -1;
59558
+ const side2 = requestedSide >= 0 ? 1 : -1;
59559
59559
  const onU = Math.abs(Math.abs(uOnN) - 1) < 1e-9;
59560
59560
  const onV = Math.abs(Math.abs(vOnN) - 1) < 1e-9;
59561
59561
  if (!onU && !onV) return null;
@@ -59565,7 +59565,7 @@ function bearingFaces(x, uOnN, vOnN, requestedSide) {
59565
59565
  case "i": {
59566
59566
  if (!onU) return null;
59567
59567
  if (!plyFitsSection(x.tw, x.bf / 2)) return null;
59568
- return { lapN: side * x.tw / 2, sideDir: side, plyFarN: -side * x.tw / 2, ply: x.tw, derived: false };
59568
+ return { lapN: side2 * x.tw / 2, sideDir: side2, plyFarN: -side2 * x.tw / 2, ply: x.tw, derived: false };
59569
59569
  }
59570
59570
  case "channel": {
59571
59571
  if (!onU) return null;
@@ -59900,8 +59900,8 @@ function parseStepData(input) {
59900
59900
  if (input.length > MAX_BYTES3) throw new StepParseError("IFC is larger than the supported maximum.");
59901
59901
  assertAscii((i) => input[i], input.length);
59902
59902
  }
59903
- const text4 = typeof input === "string" ? input : input.toString("utf8");
59904
- const sc = new Scanner(text4);
59903
+ const text5 = typeof input === "string" ? input : input.toString("utf8");
59904
+ const sc = new Scanner(text5);
59905
59905
  sc.expectWord("ISO-10303-21");
59906
59906
  sc.expect(";");
59907
59907
  sc.expectWord("HEADER");
@@ -60611,12 +60611,12 @@ function validateCompletion(value) {
60611
60611
  if (outcome !== "applied" && outcome !== "needs-you" && outcome !== "refused") {
60612
60612
  return { kind: "violation", why: `unrecognised outcome ${JSON.stringify(outcome)}` };
60613
60613
  }
60614
- const text4 = typeof question === "string" ? question.trim().slice(0, MAX_QUESTION) : "";
60615
- if (outcome === "needs-you" && !text4) {
60614
+ const text5 = typeof question === "string" ? question.trim().slice(0, MAX_QUESTION) : "";
60615
+ if (outcome === "needs-you" && !text5) {
60616
60616
  return { kind: "violation", why: "outcome needs-you carried no question" };
60617
60617
  }
60618
- if (outcome === "needs-you") return { kind: "needs-you", question: text4 };
60619
- if (outcome === "refused") return { kind: "refused", question: text4 };
60618
+ if (outcome === "needs-you") return { kind: "needs-you", question: text5 };
60619
+ if (outcome === "refused") return { kind: "refused", question: text5 };
60620
60620
  return { kind: "applied" };
60621
60621
  }
60622
60622
  function readCompletion(terminal) {
@@ -60678,12 +60678,12 @@ function codexCompletion(stdout) {
60678
60678
  return validateCompletion(value);
60679
60679
  }
60680
60680
  function eventDetail(value) {
60681
- let text4 = "";
60682
- if (typeof value === "string") text4 = value;
60681
+ let text5 = "";
60682
+ if (typeof value === "string") text5 = value;
60683
60683
  else if (value && typeof value === "object" && typeof value.message === "string") {
60684
- text4 = String(value.message);
60684
+ text5 = String(value.message);
60685
60685
  }
60686
- return text4.trim() ? `: ${text4.trim().slice(0, 200)}` : "";
60686
+ return text5.trim() ? `: ${text5.trim().slice(0, 200)}` : "";
60687
60687
  }
60688
60688
  function terminalEvent(stdout) {
60689
60689
  const trimmed = stdout.trim();
@@ -60888,9 +60888,9 @@ function durableWrite2(path, bytes) {
60888
60888
  (0, import_node_fs27.chmodSync)(path, 384);
60889
60889
  syncDirectoryBestEffort((0, import_node_path25.dirname)(path));
60890
60890
  }
60891
- function durableReplace3(path, text4) {
60891
+ function durableReplace3(path, text5) {
60892
60892
  const tmp = `${path}.${process.pid}.${(0, import_node_crypto15.randomUUID)()}.tmp`;
60893
- durableWrite2(tmp, text4);
60893
+ durableWrite2(tmp, text5);
60894
60894
  (0, import_node_fs27.renameSync)(tmp, path);
60895
60895
  const fd2 = (0, import_node_fs27.openSync)(path, "r+");
60896
60896
  try {
@@ -61485,8 +61485,8 @@ function mcpConfigFor(token2, origin) {
61485
61485
  function jsonRpc(id, result) {
61486
61486
  return { jsonrpc: "2.0", id, result };
61487
61487
  }
61488
- function toolRefusal(text4) {
61489
- return { content: [{ type: "text", text: text4 }], isError: true };
61488
+ function toolRefusal(text5) {
61489
+ return { content: [{ type: "text", text: text5 }], isError: true };
61490
61490
  }
61491
61491
  function sameBody(want, got) {
61492
61492
  if (want === void 0 && got !== null && typeof got === "object" && Object.keys(got).length === 0) return true;
@@ -61604,9 +61604,9 @@ function registerRunRelay(app, deps, origin) {
61604
61604
  }
61605
61605
  try {
61606
61606
  const result = await callCodexTool(deps, lease, params?.name, params?.arguments ?? {});
61607
- const text4 = boundedJson(result);
61607
+ const text5 = boundedJson(result);
61608
61608
  recordCodexTool(lease, params?.name, "allowed");
61609
- return reply.send(jsonRpc(msg.id, { content: [{ type: "text", text: text4 }] }));
61609
+ return reply.send(jsonRpc(msg.id, { content: [{ type: "text", text: text5 }] }));
61610
61610
  } catch (err2) {
61611
61611
  recordCodexTool(lease, params?.name, "denied");
61612
61612
  const message = String(err2?.message ?? err2).slice(0, 1e3);
@@ -61785,9 +61785,9 @@ async function callCodexTool(deps, lease, name, args) {
61785
61785
  throw new Error(`no such tool: ${String(name)}`);
61786
61786
  }
61787
61787
  function boundedJson(value) {
61788
- const text4 = JSON.stringify(value);
61789
- if (text4.length > 16 * 1024 * 1024) throw new Error("tool result exceeded the bounded relay response");
61790
- return text4;
61788
+ const text5 = JSON.stringify(value);
61789
+ if (text5.length > 16 * 1024 * 1024) throw new Error("tool result exceeded the bounded relay response");
61790
+ return text5;
61791
61791
  }
61792
61792
  function onlyThisRequest(body, requestId) {
61793
61793
  const b = body;
@@ -62509,14 +62509,14 @@ async function ensureManagedSidecarsForUserAction(deps = liveDeps) {
62509
62509
  if (needsRepair(initial) === 0) return { supported: true, repaired: 0 };
62510
62510
  return deps.withExclusive(async () => {
62511
62511
  const before = await deps.inventory();
62512
- const count = needsRepair(before);
62513
- if (count === 0) return { supported: true, repaired: 0 };
62512
+ const count2 = needsRepair(before);
62513
+ if (count2 === 0) return { supported: true, repaired: 0 };
62514
62514
  const after = await deps.repair();
62515
62515
  const remaining2 = needsRepair(after);
62516
62516
  if (remaining2 > 0) {
62517
62517
  throw new AwareError(`AWARE left ${remaining2} managed runtime tool(s) needing repair.`);
62518
62518
  }
62519
- return { supported: true, repaired: count };
62519
+ return { supported: true, repaired: count2 };
62520
62520
  });
62521
62521
  }
62522
62522
 
@@ -62716,9 +62716,9 @@ var NEUTRAL_TEXT_PARAMS = {
62716
62716
  };
62717
62717
  function boundedNeutralText(value) {
62718
62718
  if (typeof value !== "string") return null;
62719
- const text4 = value.trim();
62720
- if (!text4 || Buffer.byteLength(text4, "utf8") > 64 || /[\u0000-\u001f\u007f]/.test(text4)) return null;
62721
- return text4;
62719
+ const text5 = value.trim();
62720
+ if (!text5 || Buffer.byteLength(text5, "utf8") > 64 || /[\u0000-\u001f\u007f]/.test(text5)) return null;
62721
+ return text5;
62722
62722
  }
62723
62723
  var gridCountsInteger = (p) => (!("boltCols" in p) || Number.isInteger(p.boltCols)) && (!("boltRows" in p) || Number.isInteger(p.boltRows));
62724
62724
  function sanitizeRecipe(raw) {
@@ -62730,8 +62730,8 @@ function sanitizeRecipe(raw) {
62730
62730
  for (const [k, v] of Object.entries(r.params)) {
62731
62731
  if (typeof v === "number" && isFinite(v)) num4[k] = v;
62732
62732
  if (NEUTRAL_TEXT_PARAMS[r.kind]?.has(k)) {
62733
- const text4 = boundedNeutralText(v);
62734
- if (text4) neutral[k] = text4;
62733
+ const text5 = boundedNeutralText(v);
62734
+ if (text5) neutral[k] = text5;
62735
62735
  else if (v != null) return void 0;
62736
62736
  }
62737
62737
  }
@@ -62903,9 +62903,9 @@ var LOG_CLAIM_TOKEN = (0, import_node_crypto19.randomUUID)();
62903
62903
  var versionsDir = (id) => (0, import_node_path34.join)(projectDir(id), "versions");
62904
62904
  var objectsDir = (id) => (0, import_node_path34.join)(projectDir(id), "objects");
62905
62905
  var logPath = (id) => (0, import_node_path34.join)(versionsDir(id), "log.json");
62906
- function writeAtomic(path, text4) {
62906
+ function writeAtomic(path, text5) {
62907
62907
  const tmp = `${path}.${process.pid}.tmp`;
62908
- (0, import_node_fs34.writeFileSync)(tmp, text4);
62908
+ (0, import_node_fs34.writeFileSync)(tmp, text5);
62909
62909
  (0, import_node_fs34.renameSync)(tmp, path);
62910
62910
  }
62911
62911
  function isVersionMeta(v) {
@@ -63106,9 +63106,9 @@ function createVersion(id, contract, meta) {
63106
63106
  (0, import_node_fs34.mkdirSync)(objectsDir(id), { recursive: true });
63107
63107
  const blobs = /* @__PURE__ */ new Map();
63108
63108
  const skeleton = dehydrate(contract, blobs);
63109
- for (const [hash3, text4] of blobs) {
63109
+ for (const [hash3, text5] of blobs) {
63110
63110
  const p = (0, import_node_path34.join)(objectsDir(id), hash3);
63111
- if (!(0, import_node_fs34.existsSync)(p)) writeAtomic(p, text4);
63111
+ if (!(0, import_node_fs34.existsSync)(p)) writeAtomic(p, text5);
63112
63112
  }
63113
63113
  const log2 = loadLog(id);
63114
63114
  const n = claimVersionNumber(id, (log2.versions.at(-1)?.n ?? 0) + 1);
@@ -63967,12 +63967,12 @@ function expandShearPlate(joint, beam, support, nativeSupport) {
63967
63967
  const cope = beamCopes(beam, support, joint.at ?? "end0", p);
63968
63968
  const copeRadius = pos(p, "copeRadius", 12.7);
63969
63969
  const MIN_COPE = 1;
63970
- const pushCope = (side, dec) => {
63970
+ const pushCope = (side2, dec) => {
63971
63971
  if (!(dec.depth > MIN_COPE)) return;
63972
63972
  const lenU = dec.length + clearance;
63973
- const vC = side === "top" ? beam.dims.d / 2 - dec.depth / 2 : -beam.dims.d / 2 + dec.depth / 2;
63973
+ const vC = side2 === "top" ? beam.dims.d / 2 - dec.depth / 2 : -beam.dims.d / 2 + dec.depth / 2;
63974
63974
  parts.push({
63975
- id: `${joint.id}:cope-${side}`,
63975
+ id: `${joint.id}:cope-${side2}`,
63976
63976
  group: "cope",
63977
63977
  kind: "cut",
63978
63978
  member: beam.id,
@@ -63983,9 +63983,9 @@ function expandShearPlate(joint, beam, support, nativeSupport) {
63983
63983
  depth: dec.depth,
63984
63984
  thickness: beam.dims.w + 2,
63985
63985
  radius: copeRadius,
63986
- reentrantV: side === "top" ? -1 : 1,
63986
+ reentrantV: side2 === "top" ? -1 : 1,
63987
63987
  // web side = toward the beam centroid (top cope below, bottom above)
63988
- meta: { label: `${side === "top" ? "Top" : "Bottom"} cope ${Math.round(dec.length)}\xD7${Math.round(dec.depth)}` }
63988
+ meta: { label: `${side2 === "top" ? "Top" : "Bottom"} cope ${Math.round(dec.length)}\xD7${Math.round(dec.depth)}` }
63989
63989
  });
63990
63990
  };
63991
63991
  if (cope.top) pushCope("top", cope.top);
@@ -64224,7 +64224,7 @@ function expandBraceGusset(joint, brace, support, nativeSupport) {
64224
64224
  k++;
64225
64225
  }
64226
64226
  }
64227
- const mkPlate = (suffix, uStart, mid, holes, side) => ({
64227
+ const mkPlate = (suffix, uStart, mid, holes, side2) => ({
64228
64228
  id: `${joint.id}:${suffix}`,
64229
64229
  group: "gusset-plate",
64230
64230
  kind: "plate",
@@ -64236,7 +64236,7 @@ function expandBraceGusset(joint, brace, support, nativeSupport) {
64236
64236
  thickness,
64237
64237
  holes,
64238
64238
  material: plateMaterial,
64239
- meta: { label: `Gusset plate ${Math.round(width)}\xD7${Math.round(height)}\xD7${Math.round(thickness)}${side}`, setbackMm: trimMm }
64239
+ meta: { label: `Gusset plate ${Math.round(width)}\xD7${Math.round(height)}\xD7${Math.round(thickness)}${side2}`, setbackMm: trimMm }
64240
64240
  });
64241
64241
  const plateA = mkPlate("plateA", uA, aMid, holesA, plateCount === 2 ? " (near)" : "");
64242
64242
  const parts = [plateA];
@@ -65444,8 +65444,8 @@ function checkSpatialStructure(index, manifest) {
65444
65444
  }
65445
65445
  const aggregates = index.byType("IFCRELAGGREGATES");
65446
65446
  if (aggregates.length !== 3) fail2(`the IFC has ${aggregates.length} spatial aggregations, expected 3.`);
65447
- const chain = [["IFCPROJECT", "IFCSITE"], ["IFCSITE", "IFCBUILDING"], ["IFCBUILDING", "IFCBUILDINGSTOREY"]];
65448
- for (const [parentType, childType] of chain) {
65447
+ const chain2 = [["IFCPROJECT", "IFCSITE"], ["IFCSITE", "IFCBUILDING"], ["IFCBUILDING", "IFCBUILDINGSTOREY"]];
65448
+ for (const [parentType, childType] of chain2) {
65449
65449
  const match = aggregates.find((rel) => {
65450
65450
  const parent = index.byId.get(refId(argAt(rel, 4)) ?? -1);
65451
65451
  const children = listItems(argAt(rel, 5)) ?? [];
@@ -70914,10 +70914,10 @@ function registerSteelPrepassRoute(app, deps) {
70914
70914
  }
70915
70915
  let doc = structuredClone(current);
70916
70916
  const plans = Array.isArray(doc.plans) ? doc.plans.filter(isObj5) : [];
70917
- const names = plans.map((plan) => String(plan.sheet ?? ""));
70918
- const missing = Object.keys(sheets).filter((sheet) => !names.includes(sheet));
70917
+ const names2 = plans.map((plan) => String(plan.sheet ?? ""));
70918
+ const missing = Object.keys(sheets).filter((sheet) => !names2.includes(sheet));
70919
70919
  if (missing.length) return reply.status(400).send({ ok: false, code: "prepass-unknown-sheet", error: `unknown sheet: ${missing.join(", ")}` });
70920
- const duplicates = Object.keys(sheets).filter((sheet) => names.filter((name) => name === sheet).length > 1);
70920
+ const duplicates = Object.keys(sheets).filter((sheet) => names2.filter((name) => name === sheet).length > 1);
70921
70921
  if (duplicates.length) return reply.status(400).send({ ok: false, code: "prepass-duplicate-sheet", error: `duplicate sheet: ${duplicates.join(", ")}` });
70922
70922
  let applied = false;
70923
70923
  if (body.filter !== void 0) {
@@ -70962,7 +70962,7 @@ function registerSteelPrepassRoute(app, deps) {
70962
70962
  }
70963
70963
  }
70964
70964
  const filterSheets = filterSheetsOf(doc);
70965
- const unregistered = filterSheets.map((sheet) => typeof sheet.sheet === "string" ? sheet.sheet.trim() : "").filter((sheet) => sheet && !names.includes(sheet));
70965
+ const unregistered = filterSheets.map((sheet) => typeof sheet.sheet === "string" ? sheet.sheet.trim() : "").filter((sheet) => sheet && !names2.includes(sheet));
70966
70966
  if (unregistered.length) {
70967
70967
  return reply.status(400).send({
70968
70968
  ok: false,
@@ -71011,6 +71011,7 @@ function registerSteelPrepassRoute(app, deps) {
71011
71011
 
71012
71012
  // reference-routes.ts
71013
71013
  var import_node_crypto29 = require("node:crypto");
71014
+ var import_node_fs44 = require("node:fs");
71014
71015
 
71015
71016
  // reference-import.ts
71016
71017
  var import_node_fs42 = require("node:fs");
@@ -71036,8 +71037,14 @@ var ReferenceImportError = class extends Error {
71036
71037
  * refusals it recognises — threw the user's whole selection away on the one refusal whose remedy is
71037
71038
  * to try again.
71038
71039
  */
71039
- constructor(message, code) {
71040
- super(message);
71040
+ /**
71041
+ * `options` carries a `cause`, which matters wherever a message is REPLACED rather than passed on.
71042
+ * `compareReferences` rewrites the bridge's "unknown command" stderr into "update FloLess"; without a
71043
+ * cause, a wrong command name emitted by US would tell every user to update, forever, with the real
71044
+ * reason unrecoverable from the logs.
71045
+ */
71046
+ constructor(message, code, options) {
71047
+ super(message, options);
71041
71048
  this.code = code;
71042
71049
  }
71043
71050
  code;
@@ -71081,12 +71088,12 @@ function toColorRuns(raw, indexCount) {
71081
71088
  if (!q || !Array.isArray(q.rgba) || q.rgba.length !== 4) return void 0;
71082
71089
  if (!q.rgba.every((v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1)) return void 0;
71083
71090
  if (!Number.isInteger(q.start) || !Number.isInteger(q.count)) return void 0;
71084
- const start2 = q.start, count = q.count;
71085
- if (start2 !== at || count <= 0) return void 0;
71086
- if (start2 % 3 !== 0 || count % 3 !== 0) return void 0;
71087
- at += count;
71091
+ const start2 = q.start, count2 = q.count;
71092
+ if (start2 !== at || count2 <= 0) return void 0;
71093
+ if (start2 % 3 !== 0 || count2 % 3 !== 0) return void 0;
71094
+ at += count2;
71088
71095
  if (at > indexCount) return void 0;
71089
- runs.push({ rgba: [q.rgba[0], q.rgba[1], q.rgba[2], q.rgba[3]], start: start2, count });
71096
+ runs.push({ rgba: [q.rgba[0], q.rgba[1], q.rgba[2], q.rgba[3]], start: start2, count: count2 });
71090
71097
  }
71091
71098
  return at === indexCount ? runs : void 0;
71092
71099
  }
@@ -71172,10 +71179,10 @@ function toSelection(raw) {
71172
71179
  if (!q || typeof q !== "object" || Array.isArray(q)) return null;
71173
71180
  if (!Number.isInteger(q.candidates) || q.candidates < 0) return null;
71174
71181
  if (!Array.isArray(q.unmatched)) return null;
71175
- const names = (v) => Array.isArray(v) && v.every((s) => typeof s === "string") ? v : void 0;
71176
- const storeys = names(q.storeys);
71177
- const ifcTypes = names(q.ifcTypes);
71178
- const ids = names(q.ids);
71182
+ const names2 = (v) => Array.isArray(v) && v.every((s) => typeof s === "string") ? v : void 0;
71183
+ const storeys = names2(q.storeys);
71184
+ const ifcTypes = names2(q.ifcTypes);
71185
+ const ids = names2(q.ids);
71179
71186
  return {
71180
71187
  ...storeys ? { storeys } : {},
71181
71188
  ...ifcTypes ? { ifcTypes } : {},
@@ -71197,6 +71204,11 @@ function toReferenceObjects(raw) {
71197
71204
  const all = raw.objects;
71198
71205
  const objects = all.filter(renderable).map((o) => ({
71199
71206
  id: typeof o.id === "string" ? o.id : "",
71207
+ // MAPPED EXPLICITLY, because this function maps a FIXED FIELD LIST — a field the reader adds and
71208
+ // this list does not name is silently dropped at the door, which is exactly how `globalId` would
71209
+ // have gone missing. `null` when the reader gave us nothing usable, so "the file has no id for
71210
+ // this" survives as a first-class answer instead of decaying into the expressID `id` holds.
71211
+ globalId: typeof o.globalId === "string" && o.globalId ? o.globalId : null,
71200
71212
  name: typeof o.name === "string" ? o.name : null,
71201
71213
  ifcType: typeof o.ifcType === "string" ? o.ifcType : null,
71202
71214
  storey: typeof o.storey === "string" ? o.storey : null,
@@ -71302,9 +71314,9 @@ function createSegmentPump(companionId, sink) {
71302
71314
  active2++;
71303
71315
  void (async () => {
71304
71316
  try {
71305
- const text4 = await aware.readRunArtifact(companionId, job.id, job.runId, { signal: controller.signal });
71317
+ const text5 = await aware.readRunArtifact(companionId, job.id, job.runId, { signal: controller.signal });
71306
71318
  if (stopped) return;
71307
- const objects = toPreviewObjects(JSON.parse(text4));
71319
+ const objects = toPreviewObjects(JSON.parse(text5));
71308
71320
  if (!objects.length) return;
71309
71321
  if (painted + objects.length > PREVIEW_MAX_OBJECTS) {
71310
71322
  stop("cap");
@@ -71370,15 +71382,15 @@ var readerChain2 = Promise.resolve();
71370
71382
  function wantsSegments(command, filter) {
71371
71383
  return command === "read-model" && !emittedFilter(filter);
71372
71384
  }
71373
- function writeReaderApp2(companionId, command, ifcPath, filter, progressive = false) {
71385
+ function writeReaderAppFor(companionId, invocation) {
71374
71386
  const dir = appPath(companionId);
71375
71387
  (0, import_node_fs42.mkdirSync)(dir, { recursive: true });
71376
71388
  const flo = (0, import_node_path39.join)(dir, `${companionId}.flo`);
71377
71389
  const lines = [
71378
71390
  `app: ${companionId}`,
71379
71391
  "version: 0.1.0",
71380
- `display-name: ${JSON.stringify(`Reference reader (${command})`)}`,
71381
- `description: ${JSON.stringify(command === "probe" ? "Check what an IFC file says about itself \u2014 its units, schema, element count and rough extent \u2014 without reading its geometry, so an oversized file can be refused before it is loaded." : "Read a whole IFC file as reference geometry \u2014 every element as a mesh, with the name, type, storey, profile and material the file records for it.")}`,
71392
+ `display-name: ${JSON.stringify(`Reference reader (${invocation.command})`)}`,
71393
+ `description: ${JSON.stringify(invocation.description)}`,
71382
71394
  "exposes-as-agent: false",
71383
71395
  "requires:",
71384
71396
  // UNPINNED, DELIBERATELY — and this is not laziness, it is the only true statement
@@ -71400,23 +71412,34 @@ function writeReaderApp2(companionId, command, ifcPath, filter, progressive = fa
71400
71412
  ` - ${AGENT2}`,
71401
71413
  "layout: linear",
71402
71414
  "nodes:",
71403
- ` - id: ${command}`,
71415
+ ` - id: ${invocation.command}`,
71404
71416
  ` agent: ${AGENT2}`,
71405
- ` command: ${command}`,
71406
- " config:",
71407
- ` ifc-path: ${JSON.stringify(ifcPath)}`
71417
+ ` command: ${invocation.command}`,
71418
+ " config:"
71408
71419
  ];
71409
- if (command === "read-model") {
71410
- lines.push(` max-vertices: ${MAX_VERTICES2}`);
71411
- const emit = emittedFilter(filter);
71412
- if (emit?.storeys) lines.push(` storeys: ${JSON.stringify(emit.storeys)}`);
71413
- if (emit?.ifcTypes) lines.push(` ifc-types: ${JSON.stringify(emit.ifcTypes)}`);
71414
- if (progressive && wantsSegments(command, filter)) lines.push(` batch-size: ${PREVIEW_BATCH_SIZE}`);
71420
+ for (const [key, value] of Object.entries(invocation.config)) {
71421
+ if (value === void 0) continue;
71422
+ lines.push(` ${key}: ${JSON.stringify(value)}`);
71415
71423
  }
71416
71424
  lines.push("");
71417
71425
  (0, import_node_fs42.writeFileSync)(flo, lines.join("\n"));
71418
71426
  return flo;
71419
71427
  }
71428
+ var READER_DESCRIPTION = {
71429
+ probe: "Check what an IFC file says about itself \u2014 its units, schema, element count and rough extent \u2014 without reading its geometry, so an oversized file can be refused before it is loaded.",
71430
+ "read-model": "Read a whole IFC file as reference geometry \u2014 every element as a mesh, with the name, type, storey, profile and material the file records for it."
71431
+ };
71432
+ function readerInvocation(command, ifcPath, filter, progressive = false) {
71433
+ const config = { "ifc-path": ifcPath };
71434
+ if (command === "read-model") {
71435
+ config["max-vertices"] = MAX_VERTICES2;
71436
+ const emit = emittedFilter(filter);
71437
+ if (emit?.storeys) config.storeys = emit.storeys;
71438
+ if (emit?.ifcTypes) config["ifc-types"] = emit.ifcTypes;
71439
+ if (progressive && wantsSegments(command, filter)) config["batch-size"] = PREVIEW_BATCH_SIZE;
71440
+ }
71441
+ return { command, description: READER_DESCRIPTION[command], config };
71442
+ }
71420
71443
  async function ensureReferenceReader() {
71421
71444
  try {
71422
71445
  await ensureManagedSidecarsForUserAction();
@@ -71429,7 +71452,9 @@ async function ensureReferenceReader() {
71429
71452
  }
71430
71453
  }
71431
71454
  function readerRunTimeout(command) {
71432
- return command === "read-model" ? READER_RUN_TIMEOUT_MS : void 0;
71455
+ if (command === "probe") return void 0;
71456
+ if (command === "compare") return READER_RUN_TIMEOUT_MS * 2;
71457
+ return READER_RUN_TIMEOUT_MS;
71433
71458
  }
71434
71459
  function readerArtifactId(output) {
71435
71460
  if (!Object.hasOwn(output, "$aware-artifact")) return null;
@@ -71443,7 +71468,8 @@ function readerArtifactId(output) {
71443
71468
  }
71444
71469
  return id;
71445
71470
  }
71446
- async function runReader2(companionId, command, ifcPath, opts = {}) {
71471
+ async function runReader2(companionId, invocation, opts = {}) {
71472
+ const command = invocation.command;
71447
71473
  const prev = readerChain2;
71448
71474
  let release;
71449
71475
  readerChain2 = new Promise((r) => release = r);
@@ -71451,7 +71477,7 @@ async function runReader2(companionId, command, ifcPath, opts = {}) {
71451
71477
  });
71452
71478
  const pump = opts.preview && wantsSegments(command, opts.filter) ? createSegmentPump(companionId, opts.preview) : null;
71453
71479
  try {
71454
- const flo = writeReaderApp2(companionId, command, ifcPath, opts.filter, !!pump);
71480
+ const flo = writeReaderAppFor(companionId, pump ? { ...invocation, config: { ...invocation.config, "batch-size": PREVIEW_BATCH_SIZE } } : invocation);
71455
71481
  try {
71456
71482
  await aware.compile(flo);
71457
71483
  } catch (e) {
@@ -71499,9 +71525,12 @@ async function runReader2(companionId, command, ifcPath, opts = {}) {
71499
71525
  release();
71500
71526
  }
71501
71527
  }
71502
- async function probeReference(companionId, ifcPath, opts = {}) {
71528
+ async function runReaderCommand(companionId, invocation, opts = {}) {
71503
71529
  await ensureReferenceReader();
71504
- const out = await runReader2(companionId, "probe", ifcPath, opts);
71530
+ return runReader2(companionId, invocation, opts);
71531
+ }
71532
+ async function probeReference(companionId, ifcPath, opts = {}) {
71533
+ const out = await runReaderCommand(companionId, readerInvocation("probe", ifcPath), opts);
71505
71534
  const units = out.units ?? {};
71506
71535
  const bbox = out.bbox;
71507
71536
  return {
@@ -71518,8 +71547,7 @@ async function probeReference(companionId, ifcPath, opts = {}) {
71518
71547
  };
71519
71548
  }
71520
71549
  async function readReferenceModel(companionId, ifcPath, opts = {}) {
71521
- await ensureReferenceReader();
71522
- const out = await runReader2(companionId, "read-model", ifcPath, opts);
71550
+ const out = await runReaderCommand(companionId, readerInvocation("read-model", ifcPath, opts.filter), opts);
71523
71551
  const read2 = toReferenceObjects(out);
71524
71552
  assertSelectionConfirmed(read2.selected, opts.filter);
71525
71553
  return read2;
@@ -71672,7 +71700,7 @@ function realish(p) {
71672
71700
  return (0, import_node_path40.resolve)(p);
71673
71701
  }
71674
71702
  }
71675
- var REFERENCE_CACHE_VERSION = 5;
71703
+ var REFERENCE_CACHE_VERSION = 6;
71676
71704
  var cachePath2 = (projectId, refId2) => (0, import_node_path40.join)(projectDir(projectId), `.floless-refcache-${safeId2(refId2)}.json`);
71677
71705
  function safeId2(refId2) {
71678
71706
  const s = String(refId2 ?? "").replace(/[^A-Za-z0-9._-]+/g, "_");
@@ -71738,10 +71766,290 @@ function removeReference(projectId, refId2, relPath) {
71738
71766
  dropCache(projectId, refId2);
71739
71767
  if (relPath) (0, import_node_fs43.rmSync)(insideProject(projectId, relPath), { force: true });
71740
71768
  }
71769
+ function removeReferenceFile(projectId, relPath) {
71770
+ (0, import_node_fs43.rmSync)(insideProject(projectId, relPath), { force: true });
71771
+ }
71741
71772
  function takenReferencePaths(refs) {
71742
71773
  return new Set((refs ?? []).map((r) => r.file).filter((f) => typeof f === "string"));
71743
71774
  }
71744
71775
 
71776
+ // reference-compare.ts
71777
+ var POSITION_TOLERANCE_MM = 1;
71778
+ var CompareRefusedError = class extends Error {
71779
+ reason;
71780
+ baseObjects;
71781
+ revisedObjects;
71782
+ /** Undrawable products per side. An "empty" side that is empty by skip is repairable; an empty file is not. */
71783
+ skipped;
71784
+ uncomparable;
71785
+ constructor(detail) {
71786
+ super(detail.reason);
71787
+ this.name = "CompareRefusedError";
71788
+ this.reason = detail.reason;
71789
+ this.baseObjects = detail.baseObjects;
71790
+ this.revisedObjects = detail.revisedObjects;
71791
+ this.skipped = detail.skipped;
71792
+ this.uncomparable = detail.uncomparable;
71793
+ }
71794
+ };
71795
+ var isRecord2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
71796
+ var isCount = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0;
71797
+ var count = (v) => isCount(v) ? Math.floor(v) : 0;
71798
+ var tally = (v) => {
71799
+ if (!isRecord2(v)) return {};
71800
+ const out = {};
71801
+ for (const [k, n] of Object.entries(v)) if (typeof n === "number" && Number.isFinite(n)) out[k] = n;
71802
+ return out;
71803
+ };
71804
+ var side = (v) => {
71805
+ const s = isRecord2(v) ? v : {};
71806
+ const u = isRecord2(s.uncomparable) ? s.uncomparable : {};
71807
+ return {
71808
+ objects: count(s.objects),
71809
+ usableIds: count(s.usableIds),
71810
+ skipped: count(s.skipped),
71811
+ uncomparable: { count: count(u.count), blank: count(u.blank), duplicated: count(u.duplicated), byType: tally(u.byType), byStorey: tally(u.byStorey) }
71812
+ };
71813
+ };
71814
+ var STATUSES = /* @__PURE__ */ new Set(["added", "removed", "changed", "unchanged"]);
71815
+ var triple = (v) => Array.isArray(v) && v.length === 3 && v.every((n) => typeof n === "number" && Number.isFinite(n)) ? [v[0], v[1], v[2]] : null;
71816
+ var text4 = (v) => typeof v === "string" ? v : null;
71817
+ function toChange(raw, index) {
71818
+ if (!isRecord2(raw)) throw new ReferenceImportError(`the comparison returned a change row that is not an object (row ${index + 1})`);
71819
+ const status = raw.status;
71820
+ if (typeof status !== "string" || !STATUSES.has(status)) {
71821
+ throw new ReferenceImportError(`the comparison returned a change row with an unknown status "${String(status)}" (row ${index + 1})`);
71822
+ }
71823
+ const id = raw.id;
71824
+ if (typeof id !== "string" || !id) {
71825
+ throw new ReferenceImportError(`the comparison returned a change row with no id (row ${index + 1})`);
71826
+ }
71827
+ const out = {
71828
+ status,
71829
+ id,
71830
+ name: text4(raw.name),
71831
+ ifcType: text4(raw.ifcType),
71832
+ storey: text4(raw.storey),
71833
+ profile: text4(raw.profile),
71834
+ material: text4(raw.material),
71835
+ centroid: triple(raw.centroid)
71836
+ };
71837
+ if (Array.isArray(raw.changedBy)) out.changedBy = raw.changedBy.filter((c) => typeof c === "string");
71838
+ if (out.status === "changed" && !out.changedBy?.length) {
71839
+ throw new ReferenceImportError(`the comparison marked an object changed without saying what changed about it (row ${index + 1})`);
71840
+ }
71841
+ const delta = triple(raw.delta);
71842
+ if (delta) out.delta = delta;
71843
+ if (typeof raw.distance === "number" && Number.isFinite(raw.distance)) out.distance = raw.distance;
71844
+ if (Array.isArray(raw.fields)) {
71845
+ out.fields = raw.fields.filter(isRecord2).map((f) => ({ name: String(f.name ?? ""), from: f.from ?? null, to: f.to ?? null }));
71846
+ }
71847
+ return out;
71848
+ }
71849
+ function toSummary(raw) {
71850
+ const keys = ["added", "removed", "changed", "unchanged", "uncomparable"];
71851
+ if (!isRecord2(raw)) throw new ReferenceImportError("the comparison returned no summary, so its counts cannot be shown");
71852
+ for (const k of keys) {
71853
+ if (!isCount(raw[k]) || !Number.isInteger(raw[k])) {
71854
+ throw new ReferenceImportError(`the comparison returned a summary with no usable "${k}" count`);
71855
+ }
71856
+ }
71857
+ return { added: raw.added, removed: raw.removed, changed: raw.changed, unchanged: raw.unchanged, uncomparable: raw.uncomparable };
71858
+ }
71859
+ function parseCompareResult(raw) {
71860
+ if (!isRecord2(raw)) throw new ReferenceImportError("the comparison returned nothing we can read");
71861
+ if (raw.frame !== FILE_Z_UP) {
71862
+ throw new ReferenceImportError(
71863
+ `the comparison came back in the "${String(raw.frame ?? "unstated")}" frame rather than "${FILE_Z_UP}" \u2014 your IFC reader is out of date, so update FloLess and try again`
71864
+ );
71865
+ }
71866
+ if (!Array.isArray(raw.criteria)) {
71867
+ throw new ReferenceImportError("the comparison did not say which criteria it applied, so its result cannot be trusted or stored");
71868
+ }
71869
+ if (!raw.criteria.every((c) => typeof c === "string")) {
71870
+ throw new ReferenceImportError("the comparison listed a criterion FloLess cannot read, so its result cannot be trusted or stored");
71871
+ }
71872
+ const criteria = raw.criteria;
71873
+ const identity = isRecord2(raw.identity) ? raw.identity : null;
71874
+ if (!identity) {
71875
+ throw new ReferenceImportError("the comparison did not report what it matched, so its result cannot be shown");
71876
+ }
71877
+ const refused2 = isRecord2(identity.refused) ? identity.refused : null;
71878
+ if (refused2) {
71879
+ if (!isCount(refused2.baseObjects) || !isCount(refused2.revisedObjects)) {
71880
+ throw new ReferenceImportError("the comparison refused, but did not say how many objects it saw in either file, so there is nothing honest to report");
71881
+ }
71882
+ const skipped = isRecord2(refused2.skipped) ? refused2.skipped : {};
71883
+ throw new CompareRefusedError({
71884
+ reason: typeof refused2.reason === "string" && refused2.reason ? refused2.reason : "these two files could not be compared",
71885
+ baseObjects: count(refused2.baseObjects),
71886
+ revisedObjects: count(refused2.revisedObjects),
71887
+ // `skipped` and `uncomparable` DO default, and the asymmetry is deliberate: they qualify the
71888
+ // refusal ("…and everything in one file was undrawable") where the object counts ARE the
71889
+ // refusal. Absent means the bridge reported none, which is what zero says.
71890
+ skipped: { base: count(skipped.base), revised: count(skipped.revised) },
71891
+ uncomparable: count(refused2.uncomparable)
71892
+ });
71893
+ }
71894
+ if (!criteria.length) {
71895
+ throw new ReferenceImportError("the comparison reported no criteria, so there is no statement of what it compared");
71896
+ }
71897
+ if (!Array.isArray(raw.changes)) {
71898
+ throw new ReferenceImportError("the comparison returned no changes list and no refusal, so it cannot be shown either way");
71899
+ }
71900
+ const changes = raw.changes.map(toChange);
71901
+ const summary2 = toSummary(raw.summary);
71902
+ const matched = {
71903
+ paired: count(identity.paired),
71904
+ added: count(identity.added),
71905
+ removed: count(identity.removed),
71906
+ base: side(identity.base),
71907
+ revised: side(identity.revised)
71908
+ };
71909
+ reconcile(summary2, changes, matched);
71910
+ const sel = isRecord2(raw.selected) ? raw.selected : null;
71911
+ return {
71912
+ frame: FILE_Z_UP,
71913
+ identity: matched,
71914
+ changes,
71915
+ criteria,
71916
+ summary: summary2,
71917
+ selected: sel ? { base: toSelection(sel.base), revised: toSelection(sel.revised) } : null
71918
+ };
71919
+ }
71920
+ function reconcile(summary2, changes, identity) {
71921
+ for (const status of ["added", "removed", "changed"]) {
71922
+ const rows2 = changes.filter((c) => c.status === status).length;
71923
+ if (summary2[status] !== rows2) {
71924
+ throw new ReferenceImportError(
71925
+ `the comparison's summary disagrees with its own change list \u2014 it reports ${summary2[status]} ${status}, but lists ${rows2}`
71926
+ );
71927
+ }
71928
+ }
71929
+ if (identity.added !== summary2.added || identity.removed !== summary2.removed) {
71930
+ throw new ReferenceImportError(
71931
+ `the comparison's matching counts disagree with its summary \u2014 ${identity.added}/${identity.removed} added/removed against ${summary2.added}/${summary2.removed}`
71932
+ );
71933
+ }
71934
+ const perSide = identity.base.uncomparable.count + identity.revised.uncomparable.count;
71935
+ if (summary2.uncomparable !== perSide) {
71936
+ throw new ReferenceImportError(
71937
+ `the comparison reports ${summary2.uncomparable} objects it could not compare, but accounts for ${perSide}`
71938
+ );
71939
+ }
71940
+ }
71941
+ var names = (v) => {
71942
+ const list = Array.isArray(v) ? v.filter((s) => typeof s === "string" && !!s.trim()) : [];
71943
+ return list.length ? list : void 0;
71944
+ };
71945
+ function sidesDiffer(base, revised) {
71946
+ const key = (s) => JSON.stringify([[...s.storeys ?? []].sort(), [...s.ifcTypes ?? []].sort()]);
71947
+ return key(base) !== key(revised);
71948
+ }
71949
+ var statedBaseSide = (opts) => Object.hasOwn(opts, "baseFilter");
71950
+ function compareInvocation(basePath, revisedPath, opts = {}) {
71951
+ const config = {
71952
+ "base-ifc-path": basePath,
71953
+ "revised-ifc-path": revisedPath
71954
+ };
71955
+ const revised = { storeys: names(opts.filter?.storeys), ifcTypes: names(opts.filter?.ifcTypes) };
71956
+ const base = { storeys: names(opts.baseFilter?.storeys), ifcTypes: names(opts.baseFilter?.ifcTypes) };
71957
+ if (!statedBaseSide(opts) || !sidesDiffer(base, revised)) {
71958
+ if (revised.storeys) config.storeys = revised.storeys;
71959
+ if (revised.ifcTypes) config["ifc-types"] = revised.ifcTypes;
71960
+ } else {
71961
+ if (base.storeys) config["base-storeys"] = base.storeys;
71962
+ if (base.ifcTypes) config["base-ifc-types"] = base.ifcTypes;
71963
+ if (revised.storeys) config["revised-storeys"] = revised.storeys;
71964
+ if (revised.ifcTypes) config["revised-ifc-types"] = revised.ifcTypes;
71965
+ }
71966
+ config["position-tolerance-mm"] = typeof opts.toleranceMm === "number" && Number.isFinite(opts.toleranceMm) && opts.toleranceMm > 0 ? opts.toleranceMm : POSITION_TOLERANCE_MM;
71967
+ return {
71968
+ command: "compare",
71969
+ // Plain English, per CLAUDE.md's standing rule: this becomes the node's Inspect ▸ Description, and
71970
+ // it is written for somebody who does not read code.
71971
+ description: "Compare two versions of one IFC file and say what was added, removed and changed \u2014 matching each object by the identity the file itself gives it, and refusing to guess when the two files share no identities at all.",
71972
+ config
71973
+ };
71974
+ }
71975
+ async function compareReferences(companionId, basePath, revisedPath, opts = {}) {
71976
+ let out;
71977
+ try {
71978
+ out = await runReaderCommand(companionId, compareInvocation(basePath, revisedPath, opts), { ticket: opts.ticket });
71979
+ } catch (e) {
71980
+ if (e instanceof ReferenceImportError && /unknown command/i.test(e.message)) {
71981
+ throw new ReferenceImportError(
71982
+ "your IFC reader is too old to compare two versions of a file \u2014 update FloLess and try again",
71983
+ "reference-reader-too-old",
71984
+ { cause: e }
71985
+ );
71986
+ }
71987
+ throw e;
71988
+ }
71989
+ const result = parseCompareResult(out);
71990
+ const baseAsked = statedBaseSide(opts) ? opts.baseFilter : opts.filter;
71991
+ if (emittedFilter(baseAsked)) assertSelectionConfirmed(result.selected?.base ?? null, baseAsked);
71992
+ if (emittedFilter(opts.filter)) assertSelectionConfirmed(result.selected?.revised ?? null, opts.filter);
71993
+ return result;
71994
+ }
71995
+
71996
+ // reference-versions.ts
71997
+ var chain = (e) => e.versions ?? [];
71998
+ var currentVersion = (e) => chain(e).at(-1) ?? null;
71999
+ var currentVersionId = (e) => currentVersion(e)?.id ?? null;
72000
+ function versionIdsAreUnique(e) {
72001
+ const v = chain(e);
72002
+ return new Set(v.map((x) => x.id)).size === v.length;
72003
+ }
72004
+ var normalizeFilter2 = (f) => {
72005
+ const part = (v) => v?.length ? [...v].sort() : [];
72006
+ const s = part(f?.storeys);
72007
+ const t = part(f?.ifcTypes);
72008
+ return s.length || t.length ? JSON.stringify([s, t]) : null;
72009
+ };
72010
+ var sameFilter = (a, b) => normalizeFilter2(a) === normalizeFilter2(b);
72011
+ function mirrorIsIntact(e) {
72012
+ const last = currentVersion(e);
72013
+ if (!last) return true;
72014
+ return e.file === last.file && e.name === last.name && sameFilter(e.filter, last.filter);
72015
+ }
72016
+ function withMirror(e, last, versions) {
72017
+ const out = { ...e, file: last.file, name: last.name, versions };
72018
+ if (last.filter === void 0) delete out.filter;
72019
+ else out.filter = last.filter;
72020
+ return out;
72021
+ }
72022
+ var refuseCollision = (versions, id) => {
72023
+ if (versions.some((v) => v.id === id)) throw new Error(`version id '${id}' already exists in this reference's chain`);
72024
+ };
72025
+ function adoptChain(e, opts) {
72026
+ if (chain(e).length) return e;
72027
+ const id = opts.mintId?.() ?? cryptoId();
72028
+ refuseCollision(chain(e), id);
72029
+ const v1 = {
72030
+ id,
72031
+ file: e.file,
72032
+ name: e.name,
72033
+ // The bytes are not knowable from the entry alone; the route hashes the retained original and
72034
+ // passes it. A zero-filled placeholder would satisfy the schema pattern and lie, so absence is
72035
+ // filled by the caller rather than invented here.
72036
+ sha256: opts.sha256 ?? "0".repeat(64),
72037
+ importedAt: opts.at,
72038
+ adopted: true,
72039
+ ...e.filter === void 0 ? {} : { filter: e.filter }
72040
+ };
72041
+ return { ...e, versions: [v1] };
72042
+ }
72043
+ function appendVersion(e, version, opts = {}) {
72044
+ const base = adoptChain(e, { mintId: opts.mintId, at: opts.at ?? version.importedAt });
72045
+ const versions = chain(base);
72046
+ refuseCollision(versions, version.id);
72047
+ const next = [...versions, version];
72048
+ return withMirror(base, version, next);
72049
+ }
72050
+ var newVersionId = () => `v-${globalThis.crypto.randomUUID()}`;
72051
+ var cryptoId = newVersionId;
72052
+
71745
72053
  // disconnect-guard.ts
71746
72054
  function watchDisconnect(reply, onGone) {
71747
72055
  let done = false;
@@ -71863,6 +72171,74 @@ function unmatchedMessage(name, missed, remedy) {
71863
72171
  const what = missed.length ? `has nothing under ${missed.map((m) => `"${m}"`).join(", ")}` : "has nothing under the storeys or types it was loaded with";
71864
72172
  return `"${name}" ${what}. The file may have been re-exported with different names \u2014 ${remedy}`;
71865
72173
  }
72174
+ var PreconditionError = class extends Error {
72175
+ constructor(status, body) {
72176
+ super(body.error);
72177
+ this.status = status;
72178
+ this.body = body;
72179
+ }
72180
+ status;
72181
+ body;
72182
+ };
72183
+ function precondition(entry2, body, expect) {
72184
+ const refuse = (status, error, code, extra = {}) => ({ status, body: { ok: false, error, code, ...extra } });
72185
+ if (entry2.display?.locked) {
72186
+ return refuse(409, `"${entry2.name}" is locked \u2014 unlock it in the Reference models panel to load a new version of it`, "reference-locked");
72187
+ }
72188
+ if (!mirrorIsIntact(entry2)) {
72189
+ return refuse(409, `"${entry2.name}" records a version history that disagrees with the file it currently points at, so a new version cannot safely be added to it`, "reference-mirror-diverged");
72190
+ }
72191
+ if (!versionIdsAreUnique(entry2)) {
72192
+ return refuse(409, `"${entry2.name}" records two versions under the same id, so a new version cannot safely be added to it`, "reference-versions-ambiguous");
72193
+ }
72194
+ if (!("expectedVersionId" in body)) {
72195
+ return refuse(400, "a new version must say which version it believes is current", "reference-version-expected-missing");
72196
+ }
72197
+ const expected = body.expectedVersionId ?? null;
72198
+ if (expected !== null && typeof expected !== "string") {
72199
+ return refuse(400, "a new version must say which version it believes is current", "reference-version-expected-missing");
72200
+ }
72201
+ const actual = currentVersionId(entry2);
72202
+ if (expected !== actual) {
72203
+ return refuse(
72204
+ 409,
72205
+ actual === null ? `"${entry2.name}" has no version history yet, but this upload expected one \u2014 reload the project and try again` : `"${entry2.name}" moved on to another version while this one was being prepared \u2014 reload the project and try again`,
72206
+ "reference-version-stale",
72207
+ { currentVersionId: actual }
72208
+ );
72209
+ }
72210
+ if (expect && (entry2.file !== expect.file || !sameEmittedFilter(entry2.filter, expect.filter))) {
72211
+ return refuse(
72212
+ 409,
72213
+ `"${entry2.name}" now points at a different file or a different part of it than the one this version was compared against \u2014 reload the project and try again`,
72214
+ "reference-version-stale",
72215
+ { currentVersionId: actual }
72216
+ );
72217
+ }
72218
+ return null;
72219
+ }
72220
+ function sameEmittedFilter(a, b) {
72221
+ const key = (f) => {
72222
+ const e = emittedFilter(f);
72223
+ return e ? JSON.stringify([[...e.storeys ?? []].sort(), [...e.ifcTypes ?? []].sort()]) : null;
72224
+ };
72225
+ return key(a) === key(b);
72226
+ }
72227
+ function storeysMissingFrom(probe, filter) {
72228
+ if (!probe.storeys || !filter?.storeys?.length) return [];
72229
+ const have = new Set(probe.storeys.map((r) => r.name).filter((n) => typeof n === "string").map((n) => n.toLowerCase()));
72230
+ return filter.storeys.filter((s) => !have.has(s.toLowerCase()));
72231
+ }
72232
+ function filterUnmatchedBody(refName2, fileName, missed, probe) {
72233
+ const what = missed.length ? `has nothing under ${missed.map((m) => `"${m}"`).join(", ")}` : "has nothing under the storeys or types this reference was loaded with";
72234
+ return {
72235
+ ok: false,
72236
+ code: "reference-filter-unmatched",
72237
+ error: `"${fileName}" ${what}, which is what "${refName2}" is currently read under. It may have been re-exported with different names \u2014 load the new version unfiltered, pick a new filter, or cancel.`,
72238
+ unmatched: missed,
72239
+ probe
72240
+ };
72241
+ }
71866
72242
  function referencesOf(doc) {
71867
72243
  const refs = doc.reference_models;
71868
72244
  return Array.isArray(refs) ? refs : [];
@@ -71985,8 +72361,8 @@ function registerReferenceRoutes(app, deps) {
71985
72361
  const { sha, name, placement, progressId: sessionId } = req.body ?? {};
71986
72362
  if (!sha) return reply.status(400).send({ ok: false, error: "probe the file first \u2014 its sha is required" });
71987
72363
  const asked = req.body?.filter;
71988
- const names = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string" && !!s.trim()) : [];
71989
- const filter = emittedFilter({ storeys: names(asked?.storeys), ifcTypes: names(asked?.ifcTypes) }) ?? void 0;
72364
+ const names2 = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string" && !!s.trim()) : [];
72365
+ const filter = emittedFilter({ storeys: names2(asked?.storeys), ifcTypes: names2(asked?.ifcTypes) }) ?? void 0;
71990
72366
  if (asked !== void 0 && !filter) {
71991
72367
  return reply.status(400).send({
71992
72368
  ok: false,
@@ -72078,7 +72454,20 @@ function registerReferenceRoutes(app, deps) {
72078
72454
  units: { declared: probe.units.declared, override: null },
72079
72455
  // Half-opacity by default, because a reference that arrives looking like our own steel is the
72080
72456
  // one mistake this feature must never make.
72081
- display: { visible: true, opacity: 0.5, locked: false, snap: true }
72457
+ display: { visible: true, opacity: 0.5, locked: false, snap: true },
72458
+ // BORN WITH A CHAIN, from this feature onward (#734). Without it every reference inserted
72459
+ // after ship is born chainless and immediately needs the legacy `expectedVersionId: null`
72460
+ // path — which would keep that path load-bearing forever instead of leaving it as the
72461
+ // migration it is meant to be. No `adopted` flag: this row's `importedAt` is a real import
72462
+ // date, which is precisely what an adopted row cannot claim.
72463
+ versions: [{
72464
+ id: newVersionId(),
72465
+ file: rel,
72466
+ name: displayName,
72467
+ sha256: sourceHash,
72468
+ importedAt: (/* @__PURE__ */ new Date()).toISOString(),
72469
+ ...filter ? { filter } : {}
72470
+ }]
72082
72471
  };
72083
72472
  const etag = await withLifecycleLock("project", g.project, async () => {
72084
72473
  if (scope.gone()) throw new ReferenceImportError("cancelled");
@@ -72189,6 +72578,234 @@ function registerReferenceRoutes(app, deps) {
72189
72578
  }
72190
72579
  }
72191
72580
  );
72581
+ app.post(
72582
+ "/api/steel/:appId/reference/:id/version",
72583
+ async (req, reply) => {
72584
+ const scope = runScope(deps, reply, { detachOnDisconnect: true });
72585
+ const g = gate2(deps, req.params.appId, req.query.project);
72586
+ if (!g.ok) return reply.status(g.refusal.status).send(g.refusal.body);
72587
+ const entry2 = referencesOf(g.doc).find((r) => r.id === req.params.id);
72588
+ if (!entry2) return reply.status(404).send({ ok: false, error: "no such reference model" });
72589
+ const pre = precondition(entry2, req.body ?? {});
72590
+ if (pre) return reply.status(pre.status).send(pre.body);
72591
+ const { sha, name, progressId: sessionId } = req.body ?? {};
72592
+ if (!sha) return reply.status(400).send({ ok: false, error: "probe the file first \u2014 its sha is required" });
72593
+ const displayName = String(name || entry2.name || "model.ifc");
72594
+ if (entry2.filter && !emittedFilter(entry2.filter)) {
72595
+ return reply.status(409).send({
72596
+ ok: false,
72597
+ code: "reference-filter-unreadable",
72598
+ error: `"${entry2.name}" records which part of the file to load, but not in a form FloLess can read. Remove the reference and add it again to choose the storeys afresh.`
72599
+ });
72600
+ }
72601
+ let filter;
72602
+ if (req.body?.filter === void 0) {
72603
+ filter = entry2.filter;
72604
+ } else if (req.body.filter === null) {
72605
+ filter = void 0;
72606
+ } else {
72607
+ const asked = req.body.filter;
72608
+ const names2 = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string" && !!s.trim()) : [];
72609
+ filter = emittedFilter({ storeys: names2(asked.storeys), ifcTypes: names2(asked.ifcTypes) }) ?? void 0;
72610
+ if (!filter) {
72611
+ return reply.status(400).send({
72612
+ ok: false,
72613
+ code: "reference-empty-filter",
72614
+ error: "choose at least one storey or type to load, or clear the selection to load the whole file"
72615
+ });
72616
+ }
72617
+ }
72618
+ const source = ifcInputPath(g.appId, String(sha));
72619
+ if (!source) {
72620
+ return reply.status(404).send({ ok: false, error: "the uploaded IFC is no longer available \u2014 drop the file again" });
72621
+ }
72622
+ const basePath = entry2.file ? originalPath(g.project, entry2.file) : null;
72623
+ if (!basePath) {
72624
+ return reply.status(409).send({
72625
+ ok: false,
72626
+ code: "reference-unresolved",
72627
+ error: `"${entry2.name}" is missing from this project, so there is no version to compare the new file against \u2014 relink it first`
72628
+ });
72629
+ }
72630
+ const versionId = newVersionId();
72631
+ let rel = null;
72632
+ let committed = false;
72633
+ let preview2 = null;
72634
+ const rollback = () => {
72635
+ if (committed || !rel) return;
72636
+ try {
72637
+ removeReferenceFile(g.project, rel);
72638
+ } catch (e) {
72639
+ app.log.error({ project: g.project, id: entry2.id, rel, err: e }, "reference version rollback failed \u2014 an orphaned original is left on disk");
72640
+ }
72641
+ };
72642
+ try {
72643
+ try {
72644
+ assertAcceptable((0, import_node_fs44.statSync)(source).size, displayName);
72645
+ } catch (e) {
72646
+ const r = importRefusal(e);
72647
+ if (r) return reply.status(r.status).send(r.body);
72648
+ throw e;
72649
+ }
72650
+ const probe = await deps.reader.probe(companion(g.appId), source, { ticket: scope.ticket() });
72651
+ const estimate = selectedPopulation(probe, filter);
72652
+ if (estimate !== null && objectVerdict(estimate) === "refuse") {
72653
+ return reply.status(400).send({
72654
+ ok: false,
72655
+ code: "reference-too-many-objects",
72656
+ error: tooMany(`"${displayName}" would load about ${estimate.toLocaleString("en-US")} objects`, probe)
72657
+ });
72658
+ }
72659
+ const missedInProbe = storeysMissingFrom(probe, filter);
72660
+ if (missedInProbe.length) {
72661
+ return reply.status(409).send(filterUnmatchedBody(entry2.name, displayName, missedInProbe, probe));
72662
+ }
72663
+ let comparison;
72664
+ try {
72665
+ comparison = await deps.reader.compare(companion(g.appId), basePath, source, {
72666
+ ticket: scope.ticket(),
72667
+ filter,
72668
+ // THE BASE SIDE KEEPS THE FILTER IT WAS READ UNDER. Identical on the ordinary path (where
72669
+ // `sidesDiffer` collapses it back to one shared filter), and load-bearing on §6.3's
72670
+ // remedy: applying a newly-chosen filter to the OLD file asks it for a storey it has never
72671
+ // had, resolves nothing there, and reports every object in the new file as `added`.
72672
+ baseFilter: entry2.filter
72673
+ });
72674
+ } catch (e) {
72675
+ if (e instanceof CompareRefusedError) {
72676
+ return reply.status(409).send({
72677
+ ok: false,
72678
+ code: "reference-compare-refused",
72679
+ error: e.reason,
72680
+ refused: {
72681
+ reason: e.reason,
72682
+ baseObjects: e.baseObjects,
72683
+ revisedObjects: e.revisedObjects,
72684
+ skipped: e.skipped,
72685
+ uncomparable: e.uncomparable,
72686
+ baseName: entry2.name,
72687
+ revisedName: displayName
72688
+ }
72689
+ });
72690
+ }
72691
+ throw e;
72692
+ }
72693
+ const missed = unmatchedNames(comparison.selected?.revised ?? null);
72694
+ if (hasUnmatched(comparison.selected?.revised ?? null)) {
72695
+ return reply.status(409).send(filterUnmatchedBody(entry2.name, displayName, missed, probe));
72696
+ }
72697
+ if (hasUnmatched(comparison.selected?.base ?? null)) {
72698
+ const baseMissed = unmatchedNames(comparison.selected?.base ?? null);
72699
+ return reply.status(409).send({
72700
+ ok: false,
72701
+ code: "reference-compare-base-unmatched",
72702
+ error: `The version of "${entry2.name}" you already have has nothing under ${baseMissed.map((m) => `"${m}"`).join(", ") || "the storeys or types it was loaded with"}, so there is nothing to compare the new file against. Load it as a separate reference instead.`,
72703
+ unmatched: baseMissed
72704
+ });
72705
+ }
72706
+ rel = await withLifecycleLock("project", g.project, () => {
72707
+ const doc = readAcceptedForRequest(g.appId, g.project);
72708
+ const taken = takenReferencePaths(referencesOf(doc ?? {}));
72709
+ for (const f of referenceFilesOnDisk(g.project)) taken.add(f);
72710
+ const claimed2 = projectRelativeReferencePath(displayName, taken);
72711
+ copyOriginal(g.project, claimed2, source, versionId);
72712
+ return claimed2;
72713
+ });
72714
+ const abs = originalPath(g.project, rel);
72715
+ if (!abs) throw new ReferenceImportError("the copied file vanished before it could be read");
72716
+ const sourceHash = await hashFile(abs);
72717
+ const adoptedSha = currentVersionId(entry2) === null ? await hashFile(basePath) : null;
72718
+ preview2 = previewFor(sessionId, g.appId, g.project);
72719
+ const geometry = await deps.reader.readModel(companion(g.appId), abs, {
72720
+ ticket: scope.ticket(),
72721
+ filter,
72722
+ ...preview2 ? { preview: preview2.sink } : {}
72723
+ });
72724
+ if (scope.gone()) throw new ReferenceImportError("cancelled");
72725
+ if (!geometry.objects.length && hasUnmatched(geometry.selected)) {
72726
+ rollback();
72727
+ return reply.status(409).send(filterUnmatchedBody(entry2.name, displayName, unmatchedNames(geometry.selected), probe));
72728
+ }
72729
+ if (!geometry.objects.length) {
72730
+ rollback();
72731
+ return reply.status(400).send({ ok: false, error: `"${displayName}" has no geometry we can draw` });
72732
+ }
72733
+ if (objectVerdict(geometry.objects.length) === "refuse") {
72734
+ rollback();
72735
+ return reply.status(400).send({
72736
+ ok: false,
72737
+ code: "reference-too-many-objects",
72738
+ error: tooMany(`"${displayName}" read ${geometry.objects.length.toLocaleString("en-US")} objects`, probe)
72739
+ });
72740
+ }
72741
+ writeCache2(g.project, entry2.id, { v: REFERENCE_CACHE_VERSION, sourceHash, dropped: geometry.dropped, colorsAvailable: geometry.colorsAvailable, colorsDropped: geometry.colorsDropped, propertySetsAvailable: geometry.propertySetsAvailable, ...filter ? { filter } : {}, objects: geometry.objects });
72742
+ const version = {
72743
+ id: versionId,
72744
+ file: rel,
72745
+ name: displayName,
72746
+ sha256: sourceHash,
72747
+ importedAt: (/* @__PURE__ */ new Date()).toISOString(),
72748
+ ...filter ? { filter } : {}
72749
+ };
72750
+ let next;
72751
+ const etag = await withLifecycleLock("project", g.project, async () => {
72752
+ if (scope.gone()) throw new ReferenceImportError("cancelled");
72753
+ const current = readAcceptedForRequest(g.appId, g.project);
72754
+ if (current == null) throw new ReferenceImportError("this project has no model to attach a reference to");
72755
+ const now = referencesOf(current).find((r) => r.id === entry2.id);
72756
+ if (!now) throw new ReferenceImportError(`"${entry2.name}" was removed while its new version was being read`);
72757
+ const late = precondition(now, req.body ?? {}, { file: entry2.file, filter: entry2.filter });
72758
+ if (late) throw new PreconditionError(late.status, late.body);
72759
+ const adopted = adoptChain(now, {
72760
+ at: version.importedAt,
72761
+ ...adoptedSha ? { sha256: adoptedSha } : {}
72762
+ });
72763
+ next = appendVersion(adopted, version);
72764
+ const written = await writeContractChecked(g.appId, {
72765
+ ...current,
72766
+ reference_models: referencesOf(current).map((r) => r.id === entry2.id ? next : r)
72767
+ }, g.project, {
72768
+ origin: "internal",
72769
+ why: "appending a reference version rewrites one entry by id under a precondition the route re-checks inside this lock"
72770
+ });
72771
+ return written.etag;
72772
+ });
72773
+ committed = true;
72774
+ deps.broadcast(contractChangedEvent(g.appId, g.project, etag, req.headers["x-floless-mutation-id"]));
72775
+ return {
72776
+ ok: true,
72777
+ etag,
72778
+ reference: next,
72779
+ version,
72780
+ versions: next.versions ?? [version],
72781
+ // THE COMPARISON RIDES THE SUCCESS. It was computed before the copy and is the answer the
72782
+ // user asked for; recomputing it from a second request would compare the new version against
72783
+ // itself.
72784
+ comparison,
72785
+ objects: geometry.objects,
72786
+ dropped: geometry.dropped,
72787
+ colorsAvailable: geometry.colorsAvailable,
72788
+ colorsDropped: geometry.colorsDropped,
72789
+ propertySetsAvailable: geometry.propertySetsAvailable,
72790
+ spanMm: spanOf(geometry.objects),
72791
+ ...hasUnmatched(geometry.selected) ? { unmatched: unmatchedNames(geometry.selected) } : {}
72792
+ };
72793
+ } catch (e) {
72794
+ rollback();
72795
+ if (e instanceof PreconditionError) return reply.status(e.status).send(e.body);
72796
+ const r = importRefusal(e);
72797
+ if (r) return reply.status(r.status).send(r.body);
72798
+ if (e instanceof ContractError) {
72799
+ return reply.status(400).send({ ok: false, error: e.message, ...e.code ? { code: e.code } : {} });
72800
+ }
72801
+ app.log.error({ appId: g.appId, id: entry2.id, versionId, rel, expectedVersionId: req.body?.expectedVersionId, err: e }, "reference version upload failed");
72802
+ return reply.status(500).send({ ok: false, error: `could not load a new version of "${entry2.name}"` });
72803
+ } finally {
72804
+ if (preview2) closeProgressSession(preview2.id, "done");
72805
+ scope.finish();
72806
+ }
72807
+ }
72808
+ );
72192
72809
  app.delete(
72193
72810
  "/api/steel/:appId/reference/:id",
72194
72811
  async (req, reply) => {
@@ -72203,6 +72820,7 @@ function registerReferenceRoutes(app, deps) {
72203
72820
  error: `"${entry2.name}" is locked \u2014 unlock it in the Reference models panel to remove it`
72204
72821
  });
72205
72822
  }
72823
+ let stillReferenced = [];
72206
72824
  try {
72207
72825
  const etag = await withLifecycleLock("project", g.project, async () => {
72208
72826
  const current = readAcceptedForRequest(g.appId, g.project);
@@ -72210,6 +72828,7 @@ function registerReferenceRoutes(app, deps) {
72210
72828
  const now = referencesOf(current).find((r) => r.id === entry2.id);
72211
72829
  if (now?.display?.locked) throw new ReferenceLockedError(now.name || entry2.name);
72212
72830
  const kept = referencesOf(current).filter((r) => r.id !== entry2.id);
72831
+ stillReferenced = kept;
72213
72832
  const next = { ...current, reference_models: kept };
72214
72833
  const written = await writeContractChecked(g.appId, next, g.project, {
72215
72834
  origin: "internal",
@@ -72217,13 +72836,33 @@ function registerReferenceRoutes(app, deps) {
72217
72836
  });
72218
72837
  return written.etag;
72219
72838
  });
72839
+ const owned = /* @__PURE__ */ new Set([...(entry2.versions ?? []).map((v) => v.file), ...entry2.file ? [entry2.file] : []]);
72840
+ const stillUsed = /* @__PURE__ */ new Set();
72841
+ for (const other of stillReferenced) {
72842
+ if (other.file) stillUsed.add(other.file);
72843
+ for (const v of other.versions ?? []) stillUsed.add(v.file);
72844
+ }
72220
72845
  try {
72221
- removeReference(g.project, entry2.id, entry2.file ?? null);
72846
+ dropCache(g.project, entry2.id);
72222
72847
  } catch (e) {
72223
- app.log.error(
72224
- { project: g.project, id: entry2.id, file: entry2.file, err: e instanceof Error ? e.message : e },
72225
- "reference removed from the contract, but its bytes could not be deleted \u2014 an orphan is left on disk"
72226
- );
72848
+ app.log.error({ project: g.project, id: entry2.id, err: e }, "a removed reference left its geometry cache behind");
72849
+ }
72850
+ for (const file of owned) {
72851
+ if (stillUsed.has(file)) {
72852
+ app.log.warn(
72853
+ { project: g.project, id: entry2.id, file },
72854
+ "a removed reference shared a file with another reference \u2014 the file is kept, so the survivor still resolves"
72855
+ );
72856
+ continue;
72857
+ }
72858
+ try {
72859
+ removeReferenceFile(g.project, file);
72860
+ } catch (e) {
72861
+ app.log.error(
72862
+ { project: g.project, id: entry2.id, file, err: e instanceof Error ? e.message : e },
72863
+ "a removed reference kept one of its originals \u2014 an orphan is left on disk"
72864
+ );
72865
+ }
72227
72866
  }
72228
72867
  deps.broadcast(contractChangedEvent(g.appId, g.project, etag, req.headers["x-floless-mutation-id"]));
72229
72868
  return { ok: true, etag };
@@ -72247,7 +72886,7 @@ var import_node_os25 = require("node:os");
72247
72886
  var import_node_path41 = require("node:path");
72248
72887
 
72249
72888
  // node_modules/write-excel-file/modules/export/writeXlsxFileNode.js
72250
- var import_node_fs44 = __toESM(require("node:fs"), 1);
72889
+ var import_node_fs45 = __toESM(require("node:fs"), 1);
72251
72890
 
72252
72891
  // node_modules/write-excel-file/modules/xlsx/helpers/features/getAdditionalContent.js
72253
72892
  function _createForOfIteratorHelperLoose(r, e) {
@@ -73373,13 +74012,13 @@ function getBorderXml(_ref) {
73373
74012
  xml += "</border>";
73374
74013
  return xml;
73375
74014
  }
73376
- function getSideBorderXml(side, _ref2) {
74015
+ function getSideBorderXml(side2, _ref2) {
73377
74016
  var style = _ref2.style, color = _ref2.color;
73378
74017
  if (color && !style) {
73379
74018
  style = "thin";
73380
74019
  }
73381
74020
  var hasChildren = Boolean(color);
73382
- return "<".concat(side) + (style ? ' style="'.concat(sanitizeAttributeValue(style), '"') : "") + (hasChildren ? ">" : "/>") + (color ? '<color rgb="'.concat(sanitizeAttributeValue(getXlsxColorForHexColor(color)), '"/>') : "") + (hasChildren ? "</".concat(side, ">") : "");
74021
+ return "<".concat(side2) + (style ? ' style="'.concat(sanitizeAttributeValue(style), '"') : "") + (hasChildren ? ">" : "/>") + (color ? '<color rgb="'.concat(sanitizeAttributeValue(getXlsxColorForHexColor(color)), '"/>') : "") + (hasChildren ? "</".concat(side2, ">") : "");
73383
74022
  }
73384
74023
 
73385
74024
  // node_modules/write-excel-file/modules/xlsx/helpers/getFontXml.js
@@ -75041,7 +75680,7 @@ function generateXlsxFileContents(arg1, arg2, arg3) {
75041
75680
  sheetsOptions = setConditionalFormattingRulesGlobalIndexes(sheetsOptions);
75042
75681
  var features = getFeatures(options.features);
75043
75682
  var files2 = {};
75044
- var readFile5 = function readFile6(path) {
75683
+ var readFile6 = function readFile7(path) {
75045
75684
  return files2[path];
75046
75685
  };
75047
75686
  var writeFiles = function writeFiles2(filesToWrite) {
@@ -75108,7 +75747,7 @@ function generateXlsxFileContents(arg1, arg2, arg3) {
75108
75747
  sheetIndex++;
75109
75748
  }
75110
75749
  writeFiles(getWrittenFiles(features, sheetsOptions, {
75111
- read: readFile5
75750
+ read: readFile6
75112
75751
  }));
75113
75752
  files2["xl/styles.xml"] = generateStylesXml(getCellStyles(), sheetsOptions, features);
75114
75753
  files2["xl/sharedStrings.xml"] = generateSharedStringsXml(getSharedStrings());
@@ -75347,7 +75986,7 @@ function writeXlsxFile(arg1, arg2, arg3) {
75347
75986
  },
75348
75987
  toFile: function toFile(filePath) {
75349
75988
  return createReadableStream().then(function(readableStream) {
75350
- return pipe(readableStream, import_node_fs44.default.createWriteStream(filePath));
75989
+ return pipe(readableStream, import_node_fs45.default.createWriteStream(filePath));
75351
75990
  });
75352
75991
  }
75353
75992
  };
@@ -75983,7 +76622,7 @@ function workspaceContractLifecycle(contract, hasHistory = false) {
75983
76622
  }
75984
76623
 
75985
76624
  // project-export-files.ts
75986
- var import_node_fs45 = require("node:fs");
76625
+ var import_node_fs46 = require("node:fs");
75987
76626
  var import_node_path42 = require("node:path");
75988
76627
  function projectExportFiles(appId, kindOf2 = appId) {
75989
76628
  if (kindOf2 === "vectorize") {
@@ -76013,12 +76652,12 @@ function exportFileBase(projectId, appId, now = /* @__PURE__ */ new Date()) {
76013
76652
  }
76014
76653
  function uniqueProjectExportFilename(projectId, preferred) {
76015
76654
  const dir = projectExportsDir(projectId);
76016
- if (!(0, import_node_fs45.existsSync)((0, import_node_path42.join)(dir, preferred))) return preferred;
76655
+ if (!(0, import_node_fs46.existsSync)((0, import_node_path42.join)(dir, preferred))) return preferred;
76017
76656
  const extension = (0, import_node_path42.extname)(preferred);
76018
76657
  const stem = preferred.slice(0, preferred.length - extension.length);
76019
76658
  for (let suffix = 2; suffix <= 9999; suffix += 1) {
76020
76659
  const candidate = `${stem}-${suffix}${extension}`;
76021
- if (!(0, import_node_fs45.existsSync)((0, import_node_path42.join)(dir, candidate))) return candidate;
76660
+ if (!(0, import_node_fs46.existsSync)((0, import_node_path42.join)(dir, candidate))) return candidate;
76022
76661
  }
76023
76662
  throw new Error("could not allocate a unique project export filename");
76024
76663
  }
@@ -76219,8 +76858,8 @@ var arr4 = (v) => Array.isArray(v) ? v : [];
76219
76858
  var eq = (a, b) => canonicalJson(a) === canonicalJson(b);
76220
76859
  var own = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
76221
76860
  function displayValue(value) {
76222
- const text4 = canonicalJson(value);
76223
- return text4.length <= 240 ? value : { summary: `Large value (${text4.length} characters)`, sha256: hashOf(value) };
76861
+ const text5 = canonicalJson(value);
76862
+ return text5.length <= 240 ? value : { summary: `Large value (${text5.length} characters)`, sha256: hashOf(value) };
76224
76863
  }
76225
76864
  function groupOf(opts) {
76226
76865
  const keys = changedKeys(opts.before, opts.after);
@@ -76641,10 +77280,10 @@ function freezeApprovalReviewId(review) {
76641
77280
  moveForward: review.moveForward ?? null
76642
77281
  });
76643
77282
  }
76644
- function summary(count, selective) {
76645
- if (count === 0) return "No changes need approval.";
77283
+ function summary(count2, selective) {
77284
+ if (count2 === 0) return "No changes need approval.";
76646
77285
  if (!selective) return "Review the model as one complete change.";
76647
- return `${count} ${count === 1 ? "change needs" : "changes need"} review.`;
77286
+ return `${count2} ${count2 === 1 ? "change needs" : "changes need"} review.`;
76648
77287
  }
76649
77288
  function buildApprovalReview(input) {
76650
77289
  let partition = partitionContract(input.baseContract, input.draft);
@@ -76699,7 +77338,7 @@ function buildApprovalReview(input) {
76699
77338
 
76700
77339
  // working-revision-manifest.ts
76701
77340
  var import_node_crypto30 = require("node:crypto");
76702
- var import_node_fs46 = require("node:fs");
77341
+ var import_node_fs47 = require("node:fs");
76703
77342
  var import_node_path43 = require("node:path");
76704
77343
  var pathOf = (projectId) => (0, import_node_path43.join)(projectDir(projectId), ".floless-working-revision-state-v1.json");
76705
77344
  var checksumOf = (body) => hashOf(body);
@@ -76714,7 +77353,7 @@ function assertProject(project) {
76714
77353
  function readWorkingRevisionManifest(project) {
76715
77354
  const uuid = assertProject(project);
76716
77355
  try {
76717
- const value = JSON.parse((0, import_node_fs46.readFileSync)(pathOf(project.id), "utf8"));
77356
+ const value = JSON.parse((0, import_node_fs47.readFileSync)(pathOf(project.id), "utf8"));
76718
77357
  if (value?.schema !== 1 || value.projectUuid !== uuid || !Number.isInteger(value.epoch) || value.epoch < 0) return null;
76719
77358
  return checksumOf(bodyOf(value)) === value.checksum ? value : null;
76720
77359
  } catch {
@@ -76736,8 +77375,8 @@ function ensureWorkingRevisionManifest(input) {
76736
77375
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
76737
77376
  };
76738
77377
  const value = { ...body, checksum: checksumOf(body) };
76739
- (0, import_node_fs46.mkdirSync)(projectDir(input.project.id), { recursive: true });
76740
- if (!(0, import_node_fs46.existsSync)(pathOf(input.project.id))) writeJsonAtomic(pathOf(input.project.id), value);
77378
+ (0, import_node_fs47.mkdirSync)(projectDir(input.project.id), { recursive: true });
77379
+ if (!(0, import_node_fs47.existsSync)(pathOf(input.project.id))) writeJsonAtomic(pathOf(input.project.id), value);
76741
77380
  return readWorkingRevisionManifest(input.project) ?? value;
76742
77381
  }
76743
77382
  function advanceWorkingRevisionManifest(input) {
@@ -76983,8 +77622,8 @@ function applyApprovalDiscard(review, partition, changes, validateCandidate) {
76983
77622
  const chosen = new Set(discardedIds);
76984
77623
  for (const group of review.groups) {
76985
77624
  const component = review.groups.filter((candidate) => candidate.dependencyGroup === group.dependencyGroup);
76986
- const count = component.filter((candidate) => chosen.has(candidate.id)).length;
76987
- if (count && count !== component.length) {
77625
+ const count2 = component.filter((candidate) => chosen.has(candidate.id)).length;
77626
+ if (count2 && count2 !== component.length) {
76988
77627
  throw new ApprovalSelectionError("invalid-dependency", `discard all dependent changes together: ${component.map((candidate) => candidate.id).join(", ")}`);
76989
77628
  }
76990
77629
  }
@@ -77008,7 +77647,7 @@ function projectApprovalCandidateAccepted(appId, projectId, candidate) {
77008
77647
 
77009
77648
  // project-checkpoints-store.ts
77010
77649
  var import_node_crypto31 = require("node:crypto");
77011
- var import_node_fs47 = require("node:fs");
77650
+ var import_node_fs48 = require("node:fs");
77012
77651
  var import_node_path44 = require("node:path");
77013
77652
  var HASH_RE3 = /^[0-9a-f]{64}$/;
77014
77653
  function root5(projectId) {
@@ -77018,7 +77657,7 @@ var objectsDir2 = (projectId) => (0, import_node_path44.join)(root5(projectId),
77018
77657
  var eventsPath = (projectId) => (0, import_node_path44.join)(root5(projectId), "events.json");
77019
77658
  function readEvents(projectId) {
77020
77659
  try {
77021
- const parsed = JSON.parse((0, import_node_fs47.readFileSync)(eventsPath(projectId), "utf8"));
77660
+ const parsed = JSON.parse((0, import_node_fs48.readFileSync)(eventsPath(projectId), "utf8"));
77022
77661
  if (parsed?.schema !== 1 || !Array.isArray(parsed.events)) return { schema: 1, events: [] };
77023
77662
  return { schema: 1, events: parsed.events.filter(validEvent) };
77024
77663
  } catch {
@@ -77033,7 +77672,7 @@ function validEvent(value) {
77033
77672
  function readContent(projectId, id) {
77034
77673
  if (!HASH_RE3.test(id)) return null;
77035
77674
  try {
77036
- const value = JSON.parse((0, import_node_fs47.readFileSync)((0, import_node_path44.join)(objectsDir2(projectId), `${id}.json`), "utf8"));
77675
+ const value = JSON.parse((0, import_node_fs48.readFileSync)((0, import_node_path44.join)(objectsDir2(projectId), `${id}.json`), "utf8"));
77037
77676
  if (value?.schema !== 1 || value.id !== id || hashCheckpoint(value) !== id) return null;
77038
77677
  return value;
77039
77678
  } catch {
@@ -77049,7 +77688,7 @@ function requireIdentity(project) {
77049
77688
  return project.uuid;
77050
77689
  }
77051
77690
  function appendEvent(projectId, event) {
77052
- (0, import_node_fs47.mkdirSync)(root5(projectId), { recursive: true });
77691
+ (0, import_node_fs48.mkdirSync)(root5(projectId), { recursive: true });
77053
77692
  const log2 = readEvents(projectId);
77054
77693
  const row = { ...event, eventId: (0, import_node_crypto31.randomUUID)(), at: (/* @__PURE__ */ new Date()).toISOString() };
77055
77694
  log2.events.push(row);
@@ -77067,9 +77706,9 @@ function captureProjectCheckpoint(input) {
77067
77706
  contract: input.contract
77068
77707
  };
77069
77708
  const id = hashCheckpoint(withoutId);
77070
- (0, import_node_fs47.mkdirSync)(objectsDir2(input.project.id), { recursive: true });
77709
+ (0, import_node_fs48.mkdirSync)(objectsDir2(input.project.id), { recursive: true });
77071
77710
  const path = (0, import_node_path44.join)(objectsDir2(input.project.id), `${id}.json`);
77072
- if (!(0, import_node_fs47.existsSync)(path)) writeJsonAtomic(path, { ...withoutId, id });
77711
+ if (!(0, import_node_fs48.existsSync)(path)) writeJsonAtomic(path, { ...withoutId, id });
77073
77712
  const event = appendEvent(input.project.id, {
77074
77713
  checkpointId: id,
77075
77714
  kind: "captured",
@@ -77112,7 +77751,7 @@ function markProjectCheckpoint(project, checkpointId, kind, expectedEventId) {
77112
77751
 
77113
77752
  // export-source.ts
77114
77753
  var import_node_crypto32 = require("node:crypto");
77115
- var import_node_fs48 = require("node:fs");
77754
+ var import_node_fs49 = require("node:fs");
77116
77755
  var import_node_os26 = require("node:os");
77117
77756
  var import_node_path45 = require("node:path");
77118
77757
  var HANDLE_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -77135,7 +77774,7 @@ function validId(id) {
77135
77774
  function readExportHandle(handleId) {
77136
77775
  if (!validId(handleId)) return null;
77137
77776
  try {
77138
- const value = JSON.parse((0, import_node_fs48.readFileSync)(handlePath(handleId), "utf8"));
77777
+ const value = JSON.parse((0, import_node_fs49.readFileSync)(handlePath(handleId), "utf8"));
77139
77778
  if (value?.schema !== 1 || value.handleId !== handleId || value.checksum !== hashOf(withoutChecksum(value))) return null;
77140
77779
  return value;
77141
77780
  } catch {
@@ -77144,7 +77783,7 @@ function readExportHandle(handleId) {
77144
77783
  }
77145
77784
  function captureExportSource(projectId, selector = { kind: "latest-approved" }, isDerivedEligible) {
77146
77785
  collectExpiredExportHandles();
77147
- if ((0, import_node_fs48.existsSync)(storeRoot()) && (0, import_node_fs48.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length >= MAX_STORED_HANDLES) {
77786
+ if ((0, import_node_fs49.existsSync)(storeRoot()) && (0, import_node_fs49.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length >= MAX_STORED_HANDLES) {
77148
77787
  throw new Error("too many frozen export sources are waiting; finish or retry older exports first");
77149
77788
  }
77150
77789
  const project = getProject(projectId);
@@ -77222,7 +77861,7 @@ function captureExportSource(projectId, selector = { kind: "latest-approved" },
77222
77861
  expiresAt: new Date(Date.now() + HANDLE_TTL_MS).toISOString(),
77223
77862
  resultRefs: []
77224
77863
  };
77225
- (0, import_node_fs48.mkdirSync)(storeRoot(), { recursive: true });
77864
+ (0, import_node_fs49.mkdirSync)(storeRoot(), { recursive: true });
77226
77865
  writeJsonAtomic(handlePath(handleId), stored(body));
77227
77866
  const { contract: _contract, lease: _lease, expiresAt: _expiresAt, resultRefs: _refs, checksum: _checksum, ...resolved } = readExportHandle(handleId);
77228
77867
  return resolved;
@@ -77234,7 +77873,7 @@ function cloneExportHandle(handleId, copies) {
77234
77873
  if (!original || original.lease !== "active" || Date.parse(original.expiresAt) <= Date.now()) {
77235
77874
  throw new Error("export source handle is unavailable");
77236
77875
  }
77237
- const storedCount = (0, import_node_fs48.existsSync)(storeRoot()) ? (0, import_node_fs48.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length : 0;
77876
+ const storedCount = (0, import_node_fs49.existsSync)(storeRoot()) ? (0, import_node_fs49.readdirSync)(storeRoot()).filter((name) => name.endsWith(".json")).length : 0;
77238
77877
  if (storedCount + copies - 1 > MAX_STORED_HANDLES) throw new Error("too many frozen export sources are waiting");
77239
77878
  const results = [];
77240
77879
  const created = [];
@@ -77249,7 +77888,7 @@ function cloneExportHandle(handleId, copies) {
77249
77888
  results.push(resolved);
77250
77889
  }
77251
77890
  } catch (error) {
77252
- for (const id of created) (0, import_node_fs48.rmSync)(handlePath(id), { force: true });
77891
+ for (const id of created) (0, import_node_fs49.rmSync)(handlePath(id), { force: true });
77253
77892
  throw error;
77254
77893
  }
77255
77894
  return results;
@@ -77289,21 +77928,21 @@ function releaseUnusedExportHandle(handleId, projectId, projectUuid) {
77289
77928
  }
77290
77929
  function projectIdHasActiveExportLeases(projectId) {
77291
77930
  collectExpiredExportHandles();
77292
- if (!(0, import_node_fs48.existsSync)(storeRoot())) return false;
77293
- return (0, import_node_fs48.readdirSync)(storeRoot()).some((name) => {
77931
+ if (!(0, import_node_fs49.existsSync)(storeRoot())) return false;
77932
+ return (0, import_node_fs49.readdirSync)(storeRoot()).some((name) => {
77294
77933
  const handle = name.endsWith(".json") ? readExportHandle(name.slice(0, -5)) : null;
77295
77934
  return handle?.projectId === projectId && handle.lease === "active" && Date.parse(handle.expiresAt) > Date.now();
77296
77935
  });
77297
77936
  }
77298
77937
  function collectExpiredExportHandles(now = Date.now()) {
77299
- if (!(0, import_node_fs48.existsSync)(storeRoot())) return 0;
77938
+ if (!(0, import_node_fs49.existsSync)(storeRoot())) return 0;
77300
77939
  let removed = 0;
77301
- for (const name of (0, import_node_fs48.readdirSync)(storeRoot())) {
77940
+ for (const name of (0, import_node_fs49.readdirSync)(storeRoot())) {
77302
77941
  if (!name.endsWith(".json")) continue;
77303
77942
  const id = name.slice(0, -5);
77304
77943
  const handle = readExportHandle(id);
77305
77944
  if (!handle || Date.parse(handle.expiresAt) <= now && handle.resultRefs.length === 0) {
77306
- (0, import_node_fs48.rmSync)(handlePath(id), { force: true });
77945
+ (0, import_node_fs49.rmSync)(handlePath(id), { force: true });
77307
77946
  removed++;
77308
77947
  }
77309
77948
  }
@@ -77312,7 +77951,7 @@ function collectExpiredExportHandles(now = Date.now()) {
77312
77951
 
77313
77952
  // file-publication.ts
77314
77953
  var import_node_crypto33 = require("node:crypto");
77315
- var import_node_fs49 = require("node:fs");
77954
+ var import_node_fs50 = require("node:fs");
77316
77955
  var import_node_path46 = require("node:path");
77317
77956
  var FilePublicationError = class extends Error {
77318
77957
  constructor(message, code, paths = []) {
@@ -77330,7 +77969,7 @@ var proofOfBytes = (bytes) => ({
77330
77969
  });
77331
77970
  function readFileProof2(path) {
77332
77971
  try {
77333
- return proofOfBytes((0, import_node_fs49.readFileSync)(path));
77972
+ return proofOfBytes((0, import_node_fs50.readFileSync)(path));
77334
77973
  } catch (error) {
77335
77974
  if (error.code === "ENOENT") return null;
77336
77975
  throw error;
@@ -77341,18 +77980,18 @@ function fileProofEquals2(a, b) {
77341
77980
  }
77342
77981
  function durableCanonicalJson(path, value) {
77343
77982
  const dir = (0, import_node_path46.dirname)(path);
77344
- (0, import_node_fs49.mkdirSync)(dir, { recursive: true });
77983
+ (0, import_node_fs50.mkdirSync)(dir, { recursive: true });
77345
77984
  const temp = (0, import_node_path46.join)(dir, `.${(0, import_node_path46.basename)(path)}.${process.pid}.${(0, import_node_crypto33.randomUUID)()}.tmp`);
77346
77985
  try {
77347
- (0, import_node_fs49.writeFileSync)(temp, `${canonicalJson(value)}
77986
+ (0, import_node_fs50.writeFileSync)(temp, `${canonicalJson(value)}
77348
77987
  `, { encoding: "utf8", flag: "wx" });
77349
77988
  syncFile(temp);
77350
- (0, import_node_fs49.renameSync)(temp, path);
77989
+ (0, import_node_fs50.renameSync)(temp, path);
77351
77990
  syncFile(path);
77352
77991
  syncDirectoryBestEffort(dir);
77353
77992
  } finally {
77354
77993
  try {
77355
- (0, import_node_fs49.rmSync)(temp, { force: true });
77994
+ (0, import_node_fs50.rmSync)(temp, { force: true });
77356
77995
  } catch {
77357
77996
  }
77358
77997
  }
@@ -77371,7 +78010,7 @@ function mappedError(error, paths) {
77371
78010
  }
77372
78011
  function linkExclusive(source, destination) {
77373
78012
  try {
77374
- (0, import_node_fs49.linkSync)(source, destination);
78013
+ (0, import_node_fs50.linkSync)(source, destination);
77375
78014
  } catch (error) {
77376
78015
  throw mappedError(error, [source, destination]);
77377
78016
  }
@@ -77380,27 +78019,27 @@ function assertSameVolume(a, b) {
77380
78019
  let aDev;
77381
78020
  let bDev;
77382
78021
  try {
77383
- aDev = (0, import_node_fs49.statSync)(a, { bigint: true }).dev;
77384
- bDev = (0, import_node_fs49.statSync)(b, { bigint: true }).dev;
78022
+ aDev = (0, import_node_fs50.statSync)(a, { bigint: true }).dev;
78023
+ bDev = (0, import_node_fs50.statSync)(b, { bigint: true }).dev;
77385
78024
  } catch (error) {
77386
78025
  throw mappedError(error, [a, b]);
77387
78026
  }
77388
78027
  if (aDev !== bDev) throw new FilePublicationError("publication paths are not on the same volume", "different-volume", [a, b]);
77389
78028
  }
77390
78029
  function uniqueArtifact(dir, label2, livePath) {
77391
- (0, import_node_fs49.mkdirSync)(dir, { recursive: true });
78030
+ (0, import_node_fs50.mkdirSync)(dir, { recursive: true });
77392
78031
  return (0, import_node_path46.join)(dir, `.floless-${label2}-${(0, import_node_crypto33.randomUUID)()}-${(0, import_node_path46.basename)(livePath)}`);
77393
78032
  }
77394
78033
  function publishFileExclusive(input) {
77395
78034
  const { livePath, stagedPath, expectedLive, artifactDir } = input;
77396
- assertSameVolume(stagedPath, (0, import_node_fs49.existsSync)(livePath) ? livePath : (0, import_node_path46.dirname)(livePath));
78035
+ assertSameVolume(stagedPath, (0, import_node_fs50.existsSync)(livePath) ? livePath : (0, import_node_path46.dirname)(livePath));
77397
78036
  const stagedProof = readFileProof2(stagedPath);
77398
78037
  if (!stagedProof) throw new FilePublicationError("staged publication file is missing", "io-failure", [stagedPath]);
77399
78038
  let beforeImage = null;
77400
78039
  if (expectedLive) {
77401
78040
  beforeImage = uniqueArtifact(artifactDir, "before", livePath);
77402
78041
  try {
77403
- (0, import_node_fs49.renameSync)(livePath, beforeImage);
78042
+ (0, import_node_fs50.renameSync)(livePath, beforeImage);
77404
78043
  } catch (error) {
77405
78044
  throw mappedError(error, [livePath, beforeImage]);
77406
78045
  }
@@ -77412,19 +78051,19 @@ function publishFileExclusive(input) {
77412
78051
  }
77413
78052
  throw new FilePublicationError("the live file changed before publication", "live-changed", [livePath, beforeImage]);
77414
78053
  }
77415
- } else if ((0, import_node_fs49.existsSync)(livePath)) {
78054
+ } else if ((0, import_node_fs50.existsSync)(livePath)) {
77416
78055
  throw new FilePublicationError("the live destination appeared before publication", "destination-exists", [livePath]);
77417
78056
  }
77418
78057
  try {
77419
78058
  input.onFaultPoint?.("after-live-move", { livePath, stagedPath, beforeImage });
77420
78059
  linkExclusive(stagedPath, livePath);
77421
78060
  input.onFaultPoint?.("after-live-link", { livePath, stagedPath, beforeImage });
77422
- (0, import_node_fs49.unlinkSync)(stagedPath);
78061
+ (0, import_node_fs50.unlinkSync)(stagedPath);
77423
78062
  input.onFaultPoint?.("after-staged-unlink", { livePath, stagedPath, beforeImage });
77424
78063
  syncFile(livePath);
77425
78064
  syncDirectoryBestEffort((0, import_node_path46.dirname)(livePath));
77426
78065
  } catch (error) {
77427
- if (beforeImage && !(0, import_node_fs49.existsSync)(livePath)) {
78066
+ if (beforeImage && !(0, import_node_fs50.existsSync)(livePath)) {
77428
78067
  try {
77429
78068
  linkExclusive(beforeImage, livePath);
77430
78069
  } catch {
@@ -77447,7 +78086,7 @@ function publishFileExclusive(input) {
77447
78086
  var import_node_path48 = require("node:path");
77448
78087
 
77449
78088
  // app-source-lock.ts
77450
- var import_node_fs50 = require("node:fs");
78089
+ var import_node_fs51 = require("node:fs");
77451
78090
  var import_node_os27 = require("node:os");
77452
78091
  var import_node_path47 = require("node:path");
77453
78092
  var AppSourcePublicationBusyError = class extends Error {
@@ -77460,9 +78099,9 @@ var AppSourcePublicationBusyError = class extends Error {
77460
78099
  function activeApprovalTransaction(appId) {
77461
78100
  const home = process.env.AWARE_HOME || (0, import_node_path47.join)((0, import_node_os27.homedir)(), ".aware");
77462
78101
  const path = (0, import_node_path47.join)(home, "apps", appId, ".floless-approval-publication-journal-v1.json");
77463
- if (!(0, import_node_fs50.existsSync)(path)) return null;
78102
+ if (!(0, import_node_fs51.existsSync)(path)) return null;
77464
78103
  try {
77465
- const stored2 = JSON.parse((0, import_node_fs50.readFileSync)(path, "utf8"));
78104
+ const stored2 = JSON.parse((0, import_node_fs51.readFileSync)(path, "utf8"));
77466
78105
  return typeof stored2?.journal?.id === "string" && stored2.journal.id ? stored2.journal.id : "__invalid__";
77467
78106
  } catch {
77468
78107
  return "__invalid__";
@@ -77471,7 +78110,7 @@ function activeApprovalTransaction(appId) {
77471
78110
  function activeCodexJournal(appId) {
77472
78111
  const root6 = (0, import_node_path47.join)(process.env.FLOLESS_HOME ?? (0, import_node_path47.join)((0, import_node_os27.homedir)(), ".floless"), "run-journals");
77473
78112
  for (const lease of listLeases()) {
77474
- if (lease.runtime === "codex" && lease.appId === appId && (0, import_node_fs50.existsSync)((0, import_node_path47.join)(root6, lease.leaseId, "journal.json"))) return lease.leaseId;
78113
+ if (lease.runtime === "codex" && lease.appId === appId && (0, import_node_fs51.existsSync)((0, import_node_path47.join)(root6, lease.leaseId, "journal.json"))) return lease.leaseId;
77475
78114
  }
77476
78115
  return null;
77477
78116
  }
@@ -77489,7 +78128,7 @@ function withAppSourceLock(appId, label2, fn, options = {}) {
77489
78128
 
77490
78129
  // app-publication-manifest.ts
77491
78130
  var import_node_crypto34 = require("node:crypto");
77492
- var import_node_fs51 = require("node:fs");
78131
+ var import_node_fs52 = require("node:fs");
77493
78132
  var import_yaml7 = __toESM(require_dist6(), 1);
77494
78133
  var APP_PUBLICATION_MANIFEST_SCHEMA = 1;
77495
78134
  var AppPublicationManifestError = class extends Error {
@@ -77506,7 +78145,7 @@ function observeAppPublication(sourcePath2, lockPath2) {
77506
78145
  let lockSourceHash = null;
77507
78146
  if (lock) {
77508
78147
  try {
77509
- const parsed = (0, import_yaml7.parse)((0, import_node_fs51.readFileSync)(lockPath2, "utf8"));
78148
+ const parsed = (0, import_yaml7.parse)((0, import_node_fs52.readFileSync)(lockPath2, "utf8"));
77510
78149
  lockSourceHash = typeof parsed?.["source-hash"] === "string" ? parsed["source-hash"] : null;
77511
78150
  } catch {
77512
78151
  }
@@ -77531,10 +78170,10 @@ function validManifest2(value) {
77531
78170
  return m.schema === APP_PUBLICATION_MANIFEST_SCHEMA && typeof m.publicationId === "string" && !!m.publicationId && typeof m.appId === "string" && !!m.appId && Number.isSafeInteger(m.generation) && (m.generation ?? -1) >= 0 && (m.state === "ready-clean" || m.state === "ready-dirty" || m.state === "recovering") && validProof(m.source) && validProof(m.lock) && (m.lockSourceHash === null || typeof m.lockSourceHash === "string") && validTxn && typeof m.updatedAt === "string" && (m.state === "recovering" ? m.transaction !== null : m.transaction === null);
77532
78171
  }
77533
78172
  function readAppPublicationManifest(path) {
77534
- if (!(0, import_node_fs51.existsSync)(path)) return null;
78173
+ if (!(0, import_node_fs52.existsSync)(path)) return null;
77535
78174
  let stored2;
77536
78175
  try {
77537
- stored2 = JSON.parse((0, import_node_fs51.readFileSync)(path, "utf8"));
78176
+ stored2 = JSON.parse((0, import_node_fs52.readFileSync)(path, "utf8"));
77538
78177
  } catch {
77539
78178
  throw new AppPublicationManifestError(`app publication manifest is unreadable: ${path}`, "corrupt");
77540
78179
  }
@@ -77730,7 +78369,7 @@ function withAppPublicationWhileProjectLocked(input) {
77730
78369
 
77731
78370
  // approval-app-publication.ts
77732
78371
  var import_node_crypto35 = require("node:crypto");
77733
- var import_node_fs52 = require("node:fs");
78372
+ var import_node_fs53 = require("node:fs");
77734
78373
  var import_node_path49 = require("node:path");
77735
78374
  var JOURNAL = ".floless-approval-publication-journal-v1.json";
77736
78375
  var MANIFEST = ".floless-app-publication-state-v1.json";
@@ -77757,7 +78396,7 @@ function storeJournal(journal) {
77757
78396
  }
77758
78397
  function readApprovalPublicationJournal(sourcePath2) {
77759
78398
  try {
77760
- const stored2 = JSON.parse((0, import_node_fs52.readFileSync)(approvalPublicationJournalPath(sourcePath2), "utf8"));
78399
+ const stored2 = JSON.parse((0, import_node_fs53.readFileSync)(approvalPublicationJournalPath(sourcePath2), "utf8"));
77761
78400
  const value = stored2?.journal;
77762
78401
  const expectedLiveLock = sourcePath2.replace(/\.[^.]+$/, ".lock");
77763
78402
  const expectedStageDir = (0, import_node_path49.join)(stagingRoot2(sourcePath2), `${value?.appId ?? ""}-${value?.id ?? ""}`);
@@ -77783,8 +78422,8 @@ async function stageApprovalPublication(input) {
77783
78422
  const beforeSource = readFileProof2(input.sourcePath);
77784
78423
  const beforeLock = readFileProof2(input.liveLockPath);
77785
78424
  try {
77786
- (0, import_node_fs52.mkdirSync)(stageDir, { recursive: true });
77787
- (0, import_node_fs52.cpSync)(appRoot, stagedAppRoot, {
78425
+ (0, import_node_fs53.mkdirSync)(stageDir, { recursive: true });
78426
+ (0, import_node_fs53.cpSync)(appRoot, stagedAppRoot, {
77788
78427
  recursive: true,
77789
78428
  filter: (path) => ![JOURNAL, MANIFEST].includes((0, import_node_path49.basename)(path))
77790
78429
  });
@@ -77797,7 +78436,7 @@ async function stageApprovalPublication(input) {
77797
78436
  throw new Error("live workflow changed while the approval was being staged");
77798
78437
  }
77799
78438
  } catch (error) {
77800
- (0, import_node_fs52.rmSync)(stageDir, { recursive: true, force: true });
78439
+ (0, import_node_fs53.rmSync)(stageDir, { recursive: true, force: true });
77801
78440
  throw error;
77802
78441
  }
77803
78442
  const journal = {
@@ -77830,12 +78469,12 @@ function publishOne(livePath, stagedPath, before, staged, artifactDir) {
77830
78469
  const live = readFileProof2(livePath);
77831
78470
  if (fileProofEquals2(live, staged)) return;
77832
78471
  if (!fileProofEquals2(live, before)) throw new Error(`live publication changed outside the approval transaction: ${livePath}`);
77833
- if (!(0, import_node_fs52.existsSync)(stagedPath)) throw new Error(`staged publication bytes are unavailable: ${stagedPath}`);
78472
+ if (!(0, import_node_fs53.existsSync)(stagedPath)) throw new Error(`staged publication bytes are unavailable: ${stagedPath}`);
77834
78473
  publishFileExclusive({ livePath, stagedPath, expectedLive: before, artifactDir });
77835
78474
  }
77836
78475
  function completeApprovalPublication(journal) {
77837
78476
  if (journal.phase !== "authorized" && journal.phase !== "published") throw new Error("approval publication is not authorized");
77838
- (0, import_node_fs52.mkdirSync)(journal.artifactDir, { recursive: true });
78477
+ (0, import_node_fs53.mkdirSync)(journal.artifactDir, { recursive: true });
77839
78478
  publishOne(journal.liveSourcePath, journal.stagedSourcePath, journal.beforeSource, journal.stagedSource, journal.artifactDir);
77840
78479
  publishOne(journal.liveLockPath, journal.stagedLockPath, journal.beforeLock, journal.stagedLock, journal.artifactDir);
77841
78480
  if (!fileProofEquals2(readFileProof2(journal.liveSourcePath), journal.stagedSource) || !fileProofEquals2(readFileProof2(journal.liveLockPath), journal.stagedLock)) {
@@ -77848,17 +78487,17 @@ function finalizeApprovalPublication(journal) {
77848
78487
  if (!current || current.id !== journal.id || current.phase !== "published") {
77849
78488
  throw new Error("published approval recovery authority is unavailable");
77850
78489
  }
77851
- (0, import_node_fs52.rmSync)(journal.stageDir, { recursive: true, force: true });
77852
- (0, import_node_fs52.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
78490
+ (0, import_node_fs53.rmSync)(journal.stageDir, { recursive: true, force: true });
78491
+ (0, import_node_fs53.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
77853
78492
  }
77854
78493
  function abandonApprovalPublication(journal) {
77855
78494
  if (journal.phase !== "staged") throw new Error("an authorized approval publication must be completed, not abandoned");
77856
- (0, import_node_fs52.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
77857
- (0, import_node_fs52.rmSync)(journal.stageDir, { recursive: true, force: true });
78495
+ (0, import_node_fs53.rmSync)(approvalPublicationJournalPath(journal.liveSourcePath), { force: true });
78496
+ (0, import_node_fs53.rmSync)(journal.stageDir, { recursive: true, force: true });
77858
78497
  }
77859
78498
 
77860
78499
  // workspace-data.ts
77861
- var import_node_fs53 = require("node:fs");
78500
+ var import_node_fs54 = require("node:fs");
77862
78501
  var VALID_INCLUDES = /* @__PURE__ */ new Set(["contract", "exports"]);
77863
78502
  var VALID_EXPORT_KINDS = /* @__PURE__ */ new Set([
77864
78503
  "bom-csv",
@@ -77916,15 +78555,15 @@ function exportBody(projectId, receipt, opts) {
77916
78555
  };
77917
78556
  if (opts.includePaths) body.path = path;
77918
78557
  if (opts.exportContents) {
77919
- const st = (0, import_node_fs53.statSync)(path);
78558
+ const st = (0, import_node_fs54.statSync)(path);
77920
78559
  if (st.size > opts.maxBytes) {
77921
78560
  body.contentOmitted = true;
77922
78561
  body.omittedReason = `export is ${st.size} bytes, over max-bytes ${opts.maxBytes}`;
77923
78562
  } else if (receipt.encoding === "base64") {
77924
- body.content = (0, import_node_fs53.readFileSync)(path).toString("base64");
78563
+ body.content = (0, import_node_fs54.readFileSync)(path).toString("base64");
77925
78564
  } else {
77926
78565
  body.encoding = receipt.encoding ?? "utf8";
77927
- body.content = (0, import_node_fs53.readFileSync)(path, "utf8");
78566
+ body.content = (0, import_node_fs54.readFileSync)(path, "utf8");
77928
78567
  }
77929
78568
  }
77930
78569
  return body;
@@ -78062,7 +78701,7 @@ function registerWorkspaceDataRoutes(app) {
78062
78701
  const generation = readCurrentGeneration(project.id);
78063
78702
  if (!generation) return { ok: true, generation: null, pages: [], total: 0, truncated: false };
78064
78703
  const wikiDir = generationWikiDir(project.id, generation.generationId);
78065
- if (!(0, import_node_fs53.existsSync)(wikiDir)) return { ok: true, generation: null, pages: [], total: 0, truncated: false };
78704
+ if (!(0, import_node_fs54.existsSync)(wikiDir)) return { ok: true, generation: null, pages: [], total: 0, truncated: false };
78066
78705
  try {
78067
78706
  const feed = readKnowledgeSummaries(wikiDir, { q, limit: limit ?? void 0 });
78068
78707
  return { ok: true, generation, ...feed };
@@ -78135,7 +78774,7 @@ function readProjectPublicationState(appId, readLiveProjects, reportError) {
78135
78774
  }
78136
78775
 
78137
78776
  // workspace-agent-manifest.ts
78138
- var import_node_fs54 = require("node:fs");
78777
+ var import_node_fs55 = require("node:fs");
78139
78778
  var import_node_os28 = require("node:os");
78140
78779
  var import_node_path50 = require("node:path");
78141
78780
  var WORKSPACE_MANIFEST_VERSION = "0.2.1";
@@ -78151,7 +78790,7 @@ function ownerPath2(dir) {
78151
78790
  }
78152
78791
  function readOwner2(path) {
78153
78792
  try {
78154
- const parsed = JSON.parse((0, import_node_fs54.readFileSync)(path, "utf8"));
78793
+ const parsed = JSON.parse((0, import_node_fs55.readFileSync)(path, "utf8"));
78155
78794
  if (Number.isSafeInteger(parsed.pid) && parsed.pid > 0 && Number.isSafeInteger(parsed.port) && parsed.port > 0 && parsed.port <= 65535 && typeof parsed.manifestVersion === "string" && parsed.manifestVersion.length > 0) return {
78156
78795
  pid: parsed.pid,
78157
78796
  port: parsed.port,
@@ -78171,7 +78810,7 @@ function processIsAlive(pid) {
78171
78810
  }
78172
78811
  function syncWorkspaceAgentManifest(port, deps = {}) {
78173
78812
  const dir = workspaceAgentDir();
78174
- (0, import_node_fs54.mkdirSync)(dir, { recursive: true });
78813
+ (0, import_node_fs55.mkdirSync)(dir, { recursive: true });
78175
78814
  const ownPath = ownerPath2(dir);
78176
78815
  const pid = deps.pid ?? process.pid;
78177
78816
  const isAlive = deps.isProcessAlive ?? processIsAlive;
@@ -78187,15 +78826,15 @@ function syncWorkspaceAgentManifest(port, deps = {}) {
78187
78826
  break;
78188
78827
  }
78189
78828
  previousOwner = current;
78190
- if ((0, import_node_fs54.existsSync)(ownPath)) {
78829
+ if ((0, import_node_fs55.existsSync)(ownPath)) {
78191
78830
  try {
78192
- (0, import_node_fs54.unlinkSync)(ownPath);
78831
+ (0, import_node_fs55.unlinkSync)(ownPath);
78193
78832
  } catch {
78194
78833
  continue;
78195
78834
  }
78196
78835
  }
78197
78836
  try {
78198
- (0, import_node_fs54.writeFileSync)(ownPath, `${JSON.stringify(mine)}
78837
+ (0, import_node_fs55.writeFileSync)(ownPath, `${JSON.stringify(mine)}
78199
78838
  `, { encoding: "utf8", flag: "wx" });
78200
78839
  break;
78201
78840
  } catch (err2) {
@@ -78354,12 +78993,12 @@ commands:
78354
78993
  `;
78355
78994
  const path = (0, import_node_path50.join)(dir, "manifest.yaml");
78356
78995
  try {
78357
- (0, import_node_fs54.writeFileSync)(path, manifest, "utf8");
78996
+ (0, import_node_fs55.writeFileSync)(path, manifest, "utf8");
78358
78997
  } catch (err2) {
78359
78998
  const current = readOwner2(ownPath);
78360
78999
  if (current?.pid === mine.pid && current.port === mine.port) {
78361
79000
  try {
78362
- (0, import_node_fs54.unlinkSync)(ownPath);
79001
+ (0, import_node_fs55.unlinkSync)(ownPath);
78363
79002
  } catch {
78364
79003
  }
78365
79004
  }
@@ -78575,16 +79214,16 @@ function diffContracts(from, to, ctx) {
78575
79214
  }
78576
79215
 
78577
79216
  // version-diff.ts
78578
- var isRecord2 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
79217
+ var isRecord3 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
78579
79218
  function loadDiffDocument(id, n, skeleton) {
78580
- if (!isRecord2(skeleton)) return { kind: "unsupported", reason: "not-record" };
79219
+ if (!isRecord3(skeleton)) return { kind: "unsupported", reason: "not-record" };
78581
79220
  if (!isModelV2(skeleton)) return { kind: "unsupported", reason: "unsupported-type" };
78582
79221
  const doc = readVersion(id, n);
78583
79222
  if (doc == null) return { kind: "unreadable", reason: "missing-v2-blob" };
78584
79223
  return readModel(doc) ? { kind: "eligible", doc } : { kind: "unsupported", reason: "invalid-v2" };
78585
79224
  }
78586
79225
  async function loadDiffDocumentAsync(id, n, skeleton) {
78587
- if (!isRecord2(skeleton)) return { kind: "unsupported", reason: "not-record" };
79226
+ if (!isRecord3(skeleton)) return { kind: "unsupported", reason: "not-record" };
78588
79227
  if (!isModelV2(skeleton)) return { kind: "unsupported", reason: "unsupported-type" };
78589
79228
  const doc = await readVersionAsync(id, n);
78590
79229
  if (doc == null) return { kind: "unreadable", reason: "missing-v2-blob" };
@@ -78669,20 +79308,20 @@ var cautionsForWarnings = (warnings) => {
78669
79308
  }
78670
79309
  return cautions;
78671
79310
  };
78672
- var unavailableSummary = (from, side) => ({
79311
+ var unavailableSummary = (from, side2) => ({
78673
79312
  from,
78674
79313
  headline: "Comparison unavailable",
78675
79314
  detailCount: 0,
78676
- bullets: [side === "from" ? "The earlier version could not be compared because its saved model is not readable." : side === "to" ? "This version could not be compared because its saved model is not readable." : "Neither version could be compared because their saved models are not readable."],
79315
+ bullets: [side2 === "from" ? "The earlier version could not be compared because its saved model is not readable." : side2 === "to" ? "This version could not be compared because its saved model is not readable." : "Neither version could be compared because their saved models are not readable."],
78677
79316
  cautions: []
78678
79317
  });
78679
79318
  function summarizeContractDiff(diff) {
78680
79319
  const bullets = [];
78681
79320
  let detailCount = 0;
78682
- const add = (count, text4) => {
78683
- if (!count) return;
78684
- detailCount += count;
78685
- bullets.push(text4);
79321
+ const add = (count2, text5) => {
79322
+ if (!count2) return;
79323
+ detailCount += count2;
79324
+ bullets.push(text5);
78686
79325
  };
78687
79326
  add(diff.added.length, `Added ${countWord(diff.added.length, "member")}: ${preview(diff.added.map(refName))}.`);
78688
79327
  add(diff.removed.length, `Removed ${countWord(diff.removed.length, "member")}: ${preview(diff.removed.map(refName))}.`);
@@ -78877,7 +79516,7 @@ function computeVersionDiff(id, n, base) {
78877
79516
  }
78878
79517
 
78879
79518
  // contract-bake.ts
78880
- var import_node_fs55 = require("node:fs");
79519
+ var import_node_fs56 = require("node:fs");
78881
79520
  var import_yaml8 = __toESM(require_dist6(), 1);
78882
79521
 
78883
79522
  // confidential-images.ts
@@ -78921,7 +79560,7 @@ function bakedV2(contract) {
78921
79560
  return stripConfidentialImages(baked);
78922
79561
  }
78923
79562
  function bakeContractIntoApp(sourcePath2, contract) {
78924
- const doc = (0, import_yaml8.parseDocument)((0, import_node_fs55.readFileSync)(sourcePath2, "utf8"));
79563
+ const doc = (0, import_yaml8.parseDocument)((0, import_node_fs56.readFileSync)(sourcePath2, "utf8"));
78925
79564
  if (doc.errors.length > 0) {
78926
79565
  throw new Error(`contract bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
78927
79566
  }
@@ -78945,7 +79584,7 @@ function bakeContractIntoApp(sourcePath2, contract) {
78945
79584
  throw new InvalidModelV2Error(`refusing to bake: contract declares steel.model/v2 but is not valid v2: ${issues[0] ?? "unknown"}`, issues);
78946
79585
  }
78947
79586
  doc.setIn(["nodes", idx, "config", "takeoff"], bakedV2(contract));
78948
- (0, import_node_fs55.writeFileSync)(sourcePath2, doc.toString());
79587
+ (0, import_node_fs56.writeFileSync)(sourcePath2, doc.toString());
78949
79588
  return;
78950
79589
  }
78951
79590
  const baked = { ...contract };
@@ -78990,7 +79629,7 @@ function bakeContractIntoApp(sourcePath2, contract) {
78990
79629
  );
78991
79630
  }
78992
79631
  doc.setIn(["nodes", idx, "config", "takeoff"], baked);
78993
- (0, import_node_fs55.writeFileSync)(sourcePath2, doc.toString());
79632
+ (0, import_node_fs56.writeFileSync)(sourcePath2, doc.toString());
78994
79633
  }
78995
79634
 
78996
79635
  // vectorize.ts
@@ -79086,7 +79725,7 @@ function deriveLayers(elements, existing) {
79086
79725
  if (!el.layer) continue;
79087
79726
  counts.set(el.layer, (counts.get(el.layer) ?? 0) + 1);
79088
79727
  }
79089
- return [...counts.entries()].map(([name, count]) => onByName.has(name) ? { name, count, on: onByName.get(name) } : { name, count }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
79728
+ return [...counts.entries()].map(([name, count2]) => onByName.has(name) ? { name, count: count2, on: onByName.get(name) } : { name, count: count2 }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
79090
79729
  }
79091
79730
  function pickSheet(contract, sheetId) {
79092
79731
  const sheets = contract.sheets ?? [];
@@ -79420,11 +80059,11 @@ function agentUpdateFailureMessage(e, id) {
79420
80059
  }
79421
80060
 
79422
80061
  // scene-bake.ts
79423
- var import_node_fs56 = require("node:fs");
80062
+ var import_node_fs57 = require("node:fs");
79424
80063
  var import_node_path51 = require("node:path");
79425
80064
  var import_yaml9 = __toESM(require_dist6(), 1);
79426
80065
  function bakeSceneIntoApp(sourcePath2, scene, agent = "viewer-3d") {
79427
- const doc = (0, import_yaml9.parseDocument)((0, import_node_fs56.readFileSync)(sourcePath2, "utf8"));
80066
+ const doc = (0, import_yaml9.parseDocument)((0, import_node_fs57.readFileSync)(sourcePath2, "utf8"));
79428
80067
  if (doc.errors.length > 0) {
79429
80068
  throw new Error(`scene bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
79430
80069
  }
@@ -79433,10 +80072,10 @@ function bakeSceneIntoApp(sourcePath2, scene, agent = "viewer-3d") {
79433
80072
  const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.agent === agent);
79434
80073
  if (idx < 0) throw new Error(`no ${agent} render node to bake the scene into`);
79435
80074
  doc.setIn(["nodes", idx, "config", "scene"], scene);
79436
- (0, import_node_fs56.writeFileSync)(sourcePath2, doc.toString());
80075
+ (0, import_node_fs57.writeFileSync)(sourcePath2, doc.toString());
79437
80076
  }
79438
80077
  function bakeNodeConfigById(sourcePath2, nodeId, patch2) {
79439
- const doc = (0, import_yaml9.parseDocument)((0, import_node_fs56.readFileSync)(sourcePath2, "utf8"));
80078
+ const doc = (0, import_yaml9.parseDocument)((0, import_node_fs57.readFileSync)(sourcePath2, "utf8"));
79440
80079
  if (doc.errors.length > 0) {
79441
80080
  throw new Error(`node bake: source is not valid YAML: ${doc.errors[0]?.message ?? "parse error"}`);
79442
80081
  }
@@ -79445,12 +80084,12 @@ function bakeNodeConfigById(sourcePath2, nodeId, patch2) {
79445
80084
  const idx = items.findIndex((it) => ((0, import_yaml9.isMap)(it) ? it.toJSON() : null)?.id === nodeId);
79446
80085
  if (idx < 0) throw new Error(`no node with id "${nodeId}"`);
79447
80086
  for (const [key, value] of Object.entries(patch2)) doc.setIn(["nodes", idx, "config", key], value);
79448
- (0, import_node_fs56.writeFileSync)(sourcePath2, doc.toString());
80087
+ (0, import_node_fs57.writeFileSync)(sourcePath2, doc.toString());
79449
80088
  }
79450
80089
  function writeViewer3dApp(dir, appId, scene) {
79451
- (0, import_node_fs56.mkdirSync)(dir, { recursive: true });
80090
+ (0, import_node_fs57.mkdirSync)(dir, { recursive: true });
79452
80091
  const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
79453
- (0, import_node_fs56.writeFileSync)(flo, [
80092
+ (0, import_node_fs57.writeFileSync)(flo, [
79454
80093
  `app: ${appId}`,
79455
80094
  "version: 0.1.0",
79456
80095
  "display-name: Steel 3D",
@@ -79473,18 +80112,18 @@ function writeViewer3dApp(dir, appId, scene) {
79473
80112
  var COMPANION_MARKER = "# floless-companion: generated by FloLess \u2014 overwritten on every export";
79474
80113
  function isCompanionApp(flo) {
79475
80114
  try {
79476
- return (0, import_node_fs56.readFileSync)(flo, "utf8").split(/\r?\n/, 1)[0]?.trim() === COMPANION_MARKER;
80115
+ return (0, import_node_fs57.readFileSync)(flo, "utf8").split(/\r?\n/, 1)[0]?.trim() === COMPANION_MARKER;
79477
80116
  } catch (e) {
79478
80117
  return e?.code === "ENOENT";
79479
80118
  }
79480
80119
  }
79481
80120
  function writeBomReportApp(dir, appId, table) {
79482
- (0, import_node_fs56.mkdirSync)(dir, { recursive: true });
80121
+ (0, import_node_fs57.mkdirSync)(dir, { recursive: true });
79483
80122
  const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
79484
80123
  if (!isCompanionApp(flo)) {
79485
80124
  throw new Error(`refusing to overwrite "${appId}": an app of that name exists and FloLess did not write it`);
79486
80125
  }
79487
- (0, import_node_fs56.writeFileSync)(flo, [
80126
+ (0, import_node_fs57.writeFileSync)(flo, [
79488
80127
  COMPANION_MARKER,
79489
80128
  `app: ${appId}`,
79490
80129
  "version: 0.1.0",
@@ -79511,9 +80150,9 @@ function writeBomReportApp(dir, appId, table) {
79511
80150
  return flo;
79512
80151
  }
79513
80152
  function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
79514
- (0, import_node_fs56.mkdirSync)(dir, { recursive: true });
80153
+ (0, import_node_fs57.mkdirSync)(dir, { recursive: true });
79515
80154
  const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
79516
- (0, import_node_fs56.writeFileSync)(flo, [
80155
+ (0, import_node_fs57.writeFileSync)(flo, [
79517
80156
  `app: ${appId}`,
79518
80157
  "version: 0.1.0",
79519
80158
  "display-name: Steel to Revit",
@@ -79547,9 +80186,9 @@ function writeRevitApp(dir, appId, scene, hostPid, revitVersion = "2026") {
79547
80186
  return flo;
79548
80187
  }
79549
80188
  function writeSketchupApp(dir, appId, scene) {
79550
- (0, import_node_fs56.mkdirSync)(dir, { recursive: true });
80189
+ (0, import_node_fs57.mkdirSync)(dir, { recursive: true });
79551
80190
  const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
79552
- (0, import_node_fs56.writeFileSync)(flo, [
80191
+ (0, import_node_fs57.writeFileSync)(flo, [
79553
80192
  `app: ${appId}`,
79554
80193
  "version: 0.1.0",
79555
80194
  "display-name: Steel to SketchUp",
@@ -79576,10 +80215,10 @@ function writeSketchupApp(dir, appId, scene) {
79576
80215
  return flo;
79577
80216
  }
79578
80217
  function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
79579
- (0, import_node_fs56.mkdirSync)(dir, { recursive: true });
80218
+ (0, import_node_fs57.mkdirSync)(dir, { recursive: true });
79580
80219
  const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
79581
80220
  const exactRhinoId = typeof rhinoId === "string" && rhinoId.trim() ? rhinoId.trim() : null;
79582
- (0, import_node_fs56.writeFileSync)(flo, [
80221
+ (0, import_node_fs57.writeFileSync)(flo, [
79583
80222
  `app: ${appId}`,
79584
80223
  "version: 0.1.0",
79585
80224
  "display-name: Steel to Rhino",
@@ -79606,9 +80245,9 @@ function writeRhinoApp(dir, appId, scene, rhinoId, hostPid) {
79606
80245
  return flo;
79607
80246
  }
79608
80247
  function writeTeklaApp(dir, appId, scene, teklaVersion = "2026.0") {
79609
- (0, import_node_fs56.mkdirSync)(dir, { recursive: true });
80248
+ (0, import_node_fs57.mkdirSync)(dir, { recursive: true });
79610
80249
  const flo = (0, import_node_path51.join)(dir, `${appId}.flo`);
79611
- (0, import_node_fs56.writeFileSync)(flo, [
80250
+ (0, import_node_fs57.writeFileSync)(flo, [
79612
80251
  `app: ${appId}`,
79613
80252
  "version: 0.1.0",
79614
80253
  "display-name: Steel to Tekla",
@@ -79772,7 +80411,7 @@ async function teklaVersionToBake() {
79772
80411
 
79773
80412
  // export-companion.ts
79774
80413
  var import_node_crypto36 = require("node:crypto");
79775
- var import_node_fs57 = require("node:fs");
80414
+ var import_node_fs58 = require("node:fs");
79776
80415
  var import_node_path52 = require("node:path");
79777
80416
  var PREFIX2 = "floless-export-tmp-";
79778
80417
  var LEASE = ".floless-export-lease.json";
@@ -79798,7 +80437,7 @@ function assertScratchPath(path, appsRoot) {
79798
80437
  }
79799
80438
  function removeScratch(path, appsRoot) {
79800
80439
  assertScratchPath(path, appsRoot);
79801
- (0, import_node_fs57.rmSync)(path, { recursive: true, force: true });
80440
+ (0, import_node_fs58.rmSync)(path, { recursive: true, force: true });
79802
80441
  }
79803
80442
  function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
79804
80443
  const safeOwner = ownerId.replace(/[^a-z0-9._-]/gi, "-").slice(0, 80) || "app";
@@ -79811,10 +80450,10 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
79811
80450
  path,
79812
80451
  token: token2,
79813
80452
  cleanup: () => {
79814
- if (!(0, import_node_fs57.existsSync)(path)) return;
80453
+ if (!(0, import_node_fs58.existsSync)(path)) return;
79815
80454
  let current = null;
79816
80455
  try {
79817
- current = JSON.parse((0, import_node_fs57.readFileSync)((0, import_node_path52.resolve)(path, LEASE), "utf8"));
80456
+ current = JSON.parse((0, import_node_fs58.readFileSync)((0, import_node_path52.resolve)(path, LEASE), "utf8"));
79818
80457
  } catch {
79819
80458
  }
79820
80459
  if (current && current.token !== token2) throw new Error(`export companion lease changed for ${id}`);
@@ -79823,7 +80462,7 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
79823
80462
  };
79824
80463
  }
79825
80464
  function stampExportCompanionLease(companion2) {
79826
- (0, import_node_fs57.writeFileSync)((0, import_node_path52.resolve)(companion2.path, LEASE), JSON.stringify({
80465
+ (0, import_node_fs58.writeFileSync)((0, import_node_path52.resolve)(companion2.path, LEASE), JSON.stringify({
79827
80466
  pid: process.pid,
79828
80467
  token: companion2.token,
79829
80468
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -79831,19 +80470,19 @@ function stampExportCompanionLease(companion2) {
79831
80470
  }
79832
80471
  function sweepStaleExportCompanions(now = Date.now(), appsRoot = defaultAppsRoot()) {
79833
80472
  const root6 = (0, import_node_path52.resolve)(appsRoot);
79834
- if (!(0, import_node_fs57.existsSync)(root6)) return [];
80473
+ if (!(0, import_node_fs58.existsSync)(root6)) return [];
79835
80474
  const removed = [];
79836
- for (const entry2 of (0, import_node_fs57.readdirSync)(root6, { withFileTypes: true })) {
80475
+ for (const entry2 of (0, import_node_fs58.readdirSync)(root6, { withFileTypes: true })) {
79837
80476
  if (!entry2.isDirectory() || !entry2.name.startsWith(PREFIX2)) continue;
79838
80477
  const path = (0, import_node_path52.resolve)(root6, entry2.name);
79839
80478
  let lease = null;
79840
80479
  try {
79841
- lease = JSON.parse((0, import_node_fs57.readFileSync)((0, import_node_path52.resolve)(path, LEASE), "utf8"));
80480
+ lease = JSON.parse((0, import_node_fs58.readFileSync)((0, import_node_path52.resolve)(path, LEASE), "utf8"));
79842
80481
  } catch {
79843
80482
  }
79844
80483
  let created;
79845
80484
  try {
79846
- created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs57.statSync)(path).mtimeMs;
80485
+ created = lease ? Date.parse(lease.createdAt) : (0, import_node_fs58.statSync)(path).mtimeMs;
79847
80486
  } catch {
79848
80487
  continue;
79849
80488
  }
@@ -80141,9 +80780,9 @@ async function scanRunningKnownHosts(deps = DEFAULT_DEPS2) {
80141
80780
  if (!envelope || typeof envelope !== "object" || envelope.ok !== true) {
80142
80781
  return { scanned: false, hosts: [] };
80143
80782
  }
80144
- const names = envelope.names;
80145
- if (!Array.isArray(names) && typeof names !== "string") return { scanned: false, hosts: [] };
80146
- const list = Array.isArray(names) ? names : [names];
80783
+ const names2 = envelope.names;
80784
+ if (!Array.isArray(names2) && typeof names2 !== "string") return { scanned: false, hosts: [] };
80785
+ const list = Array.isArray(names2) ? names2 : [names2];
80147
80786
  const found = /* @__PURE__ */ new Set();
80148
80787
  for (const raw of list) {
80149
80788
  const host = hostForProcessName(typeof raw === "string" ? raw : null);
@@ -80417,14 +81056,14 @@ function looksLikeHostUnavailable(host, ...messages) {
80417
81056
  }
80418
81057
 
80419
81058
  // render-readiness.ts
80420
- var import_node_fs58 = require("node:fs");
81059
+ var import_node_fs59 = require("node:fs");
80421
81060
  var import_node_path53 = require("node:path");
80422
81061
  var import_node_os29 = require("node:os");
80423
81062
  var RENDER_AWARE_FLOOR = "0.103.0";
80424
81063
  var RENDER_AGENT_ID = "blender";
80425
81064
  function isFile(path) {
80426
81065
  try {
80427
- return (0, import_node_fs58.existsSync)(path) && (0, import_node_fs58.statSync)(path).isFile();
81066
+ return (0, import_node_fs59.existsSync)(path) && (0, import_node_fs59.statSync)(path).isFile();
80428
81067
  } catch {
80429
81068
  return false;
80430
81069
  }
@@ -80458,7 +81097,7 @@ function windowsCandidates(env2) {
80458
81097
  for (const root6 of roots) {
80459
81098
  let entries;
80460
81099
  try {
80461
- entries = (0, import_node_fs58.readdirSync)(root6);
81100
+ entries = (0, import_node_fs59.readdirSync)(root6);
80462
81101
  } catch {
80463
81102
  continue;
80464
81103
  }
@@ -80781,16 +81420,16 @@ function rollUpModel(view) {
80781
81420
  }
80782
81421
 
80783
81422
  // app-lifecycle.ts
80784
- var import_node_fs62 = require("node:fs");
81423
+ var import_node_fs63 = require("node:fs");
80785
81424
  var import_node_os32 = require("node:os");
80786
81425
  var import_node_path57 = require("node:path");
80787
81426
 
80788
81427
  // routines.ts
80789
- var import_node_fs60 = require("node:fs");
81428
+ var import_node_fs61 = require("node:fs");
80790
81429
  var import_node_path55 = require("node:path");
80791
81430
 
80792
81431
  // trigger-sessions.ts
80793
- var import_node_fs59 = require("node:fs");
81432
+ var import_node_fs60 = require("node:fs");
80794
81433
  var import_node_os30 = require("node:os");
80795
81434
  var import_node_path54 = require("node:path");
80796
81435
  var import_yaml10 = __toESM(require_dist6(), 1);
@@ -80812,9 +81451,9 @@ function isHostBacked(agent, agentsDir = AGENTS_DIR2) {
80812
81451
  const safe2 = (n) => !n.includes("/") && !n.includes("\\") && !n.includes("..");
80813
81452
  if (!safe2(agent)) return false;
80814
81453
  const manifestPath2 = (0, import_node_path54.join)(agentsDir, agent, "manifest.yaml");
80815
- if (!(0, import_node_fs59.existsSync)(manifestPath2)) return false;
81454
+ if (!(0, import_node_fs60.existsSync)(manifestPath2)) return false;
80816
81455
  try {
80817
- const doc = (0, import_yaml10.parse)((0, import_node_fs59.readFileSync)(manifestPath2, "utf8"));
81456
+ const doc = (0, import_yaml10.parse)((0, import_node_fs60.readFileSync)(manifestPath2, "utf8"));
80818
81457
  const transport = doc?.transport;
80819
81458
  return !!(transport && typeof transport === "object" && "cli" in transport);
80820
81459
  } catch {
@@ -81158,29 +81797,29 @@ function sanitizeRoutine(raw) {
81158
81797
  };
81159
81798
  }
81160
81799
  function loadFromDisk() {
81161
- if (!(0, import_node_fs60.existsSync)(ROUTINES_FILE)) return [];
81162
- let text4;
81800
+ if (!(0, import_node_fs61.existsSync)(ROUTINES_FILE)) return [];
81801
+ let text5;
81163
81802
  try {
81164
- text4 = (0, import_node_fs60.readFileSync)(ROUTINES_FILE, "utf8");
81803
+ text5 = (0, import_node_fs61.readFileSync)(ROUTINES_FILE, "utf8");
81165
81804
  } catch {
81166
81805
  return [];
81167
81806
  }
81168
81807
  try {
81169
- const parsed = JSON.parse(text4);
81808
+ const parsed = JSON.parse(text5);
81170
81809
  return Array.isArray(parsed) ? parsed.map(sanitizeRoutine).filter((r) => r !== null) : [];
81171
81810
  } catch {
81172
81811
  try {
81173
- (0, import_node_fs60.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
81812
+ (0, import_node_fs61.renameSync)(ROUTINES_FILE, `${ROUTINES_FILE}.corrupt-${Date.now()}`);
81174
81813
  } catch {
81175
81814
  }
81176
81815
  return [];
81177
81816
  }
81178
81817
  }
81179
81818
  function saveRoutines() {
81180
- if (!(0, import_node_fs60.existsSync)(flolessRoot)) (0, import_node_fs60.mkdirSync)(flolessRoot, { recursive: true });
81819
+ if (!(0, import_node_fs61.existsSync)(flolessRoot)) (0, import_node_fs61.mkdirSync)(flolessRoot, { recursive: true });
81181
81820
  const tmp = `${ROUTINES_FILE}.${process.pid}.tmp`;
81182
- (0, import_node_fs60.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
81183
- (0, import_node_fs60.renameSync)(tmp, ROUTINES_FILE);
81821
+ (0, import_node_fs61.writeFileSync)(tmp, JSON.stringify(routines, null, 2));
81822
+ (0, import_node_fs61.renameSync)(tmp, ROUTINES_FILE);
81184
81823
  }
81185
81824
  function listRoutines() {
81186
81825
  ensureLoaded();
@@ -81590,7 +82229,7 @@ async function stopScheduler() {
81590
82229
  }
81591
82230
 
81592
82231
  // kb-pin-store.ts
81593
- var import_node_fs61 = require("node:fs");
82232
+ var import_node_fs62 = require("node:fs");
81594
82233
  var import_node_path56 = require("node:path");
81595
82234
  var import_node_os31 = require("node:os");
81596
82235
  var KbPinError = class extends Error {
@@ -81658,9 +82297,9 @@ function normalizePages(pages) {
81658
82297
  }
81659
82298
  function readPinUnlocked(appId) {
81660
82299
  const p = pinPath(appId);
81661
- if (!(0, import_node_fs61.existsSync)(p)) return null;
82300
+ if (!(0, import_node_fs62.existsSync)(p)) return null;
81662
82301
  try {
81663
- const parsed = JSON.parse((0, import_node_fs61.readFileSync)(p, "utf8"));
82302
+ const parsed = JSON.parse((0, import_node_fs62.readFileSync)(p, "utf8"));
81664
82303
  if (!parsed || typeof parsed !== "object") {
81665
82304
  console.warn(`kb-pin-store: ignoring schema-invalid pin at ${p} (not an object)`);
81666
82305
  return null;
@@ -81699,7 +82338,7 @@ function writePinUnlocked(appId, pin) {
81699
82338
  pinnedAt: (/* @__PURE__ */ new Date()).toISOString(),
81700
82339
  pages: normalizePages(pin.pages)
81701
82340
  };
81702
- (0, import_node_fs61.mkdirSync)((0, import_node_path56.dirname)(p), { recursive: true });
82341
+ (0, import_node_fs62.mkdirSync)((0, import_node_path56.dirname)(p), { recursive: true });
81703
82342
  writeJsonAtomic(p, doc);
81704
82343
  return doc;
81705
82344
  }
@@ -81709,9 +82348,9 @@ function writePin(appId, pin) {
81709
82348
  function movePinBytesUnlocked(fromAppId, toAppId) {
81710
82349
  const from = pinPath(fromAppId);
81711
82350
  const to = pinPath(toAppId);
81712
- if (from === to || !(0, import_node_fs61.existsSync)(from)) return false;
81713
- (0, import_node_fs61.mkdirSync)((0, import_node_path56.dirname)(to), { recursive: true });
81714
- (0, import_node_fs61.renameSync)(from, to);
82351
+ if (from === to || !(0, import_node_fs62.existsSync)(from)) return false;
82352
+ (0, import_node_fs62.mkdirSync)((0, import_node_path56.dirname)(to), { recursive: true });
82353
+ (0, import_node_fs62.renameSync)(from, to);
81715
82354
  return true;
81716
82355
  }
81717
82356
  function movePinBytes(fromAppId, toAppId) {
@@ -81719,8 +82358,8 @@ function movePinBytes(fromAppId, toAppId) {
81719
82358
  }
81720
82359
  function dropPinBytesUnlocked(appId) {
81721
82360
  const p = pinPath(appId);
81722
- if (!(0, import_node_fs61.existsSync)(p)) return false;
81723
- (0, import_node_fs61.rmSync)(p, { force: true });
82361
+ if (!(0, import_node_fs62.existsSync)(p)) return false;
82362
+ (0, import_node_fs62.rmSync)(p, { force: true });
81724
82363
  return true;
81725
82364
  }
81726
82365
  function dropPinBytes(appId) {
@@ -81730,9 +82369,9 @@ function repointProjectPinsUnlocked(fromProjectId, toProjectId) {
81730
82369
  if (!isProjectId2(fromProjectId) || !isProjectId2(toProjectId)) {
81731
82370
  throw new KbPinError("invalid project id for pin repoint", "invalid-project");
81732
82371
  }
81733
- if (fromProjectId === toProjectId || !(0, import_node_fs61.existsSync)(pinsDir())) return 0;
82372
+ if (fromProjectId === toProjectId || !(0, import_node_fs62.existsSync)(pinsDir())) return 0;
81734
82373
  const targets = [];
81735
- for (const entry2 of (0, import_node_fs61.readdirSync)(pinsDir(), { withFileTypes: true })) {
82374
+ for (const entry2 of (0, import_node_fs62.readdirSync)(pinsDir(), { withFileTypes: true })) {
81736
82375
  if (!entry2.isFile() || !entry2.name.endsWith(".json")) continue;
81737
82376
  const appId = (0, import_node_path56.basename)(entry2.name, ".json");
81738
82377
  let pin;
@@ -81782,7 +82421,7 @@ function appDirPath(id) {
81782
82421
  return (0, import_node_path57.join)(appsDir(), id);
81783
82422
  }
81784
82423
  function appInstalled(id) {
81785
- return APP_ID5.test(id) && (0, import_node_fs62.existsSync)(appDirPath(id));
82424
+ return APP_ID5.test(id) && (0, import_node_fs63.existsSync)(appDirPath(id));
81786
82425
  }
81787
82426
  function logCascade(what, e) {
81788
82427
  console.error(`[app-lifecycle] cascade step failed (${what}):`, e instanceof Error ? e.message : e);
@@ -81991,11 +82630,11 @@ async function deleteApp(id, deps = defaultDeps2) {
81991
82630
  }
81992
82631
 
81993
82632
  // kb-pin-routes.ts
81994
- var import_node_fs63 = require("node:fs");
82633
+ var import_node_fs64 = require("node:fs");
81995
82634
  function driftOf(pin) {
81996
82635
  const cur = readCurrentGeneration(pin.projectId);
81997
82636
  if (cur === null) return true;
81998
- if (!(0, import_node_fs63.existsSync)(generationWikiDir(pin.projectId, cur.generationId))) return true;
82637
+ if (!(0, import_node_fs64.existsSync)(generationWikiDir(pin.projectId, cur.generationId))) return true;
81999
82638
  return cur.generationId !== pin.generationId;
82000
82639
  }
82001
82640
  function registerKbPinRoutes(app, deps) {
@@ -82111,7 +82750,7 @@ function isGatedAwareRoute(url, method) {
82111
82750
 
82112
82751
  // autostart.mjs
82113
82752
  var import_node_child_process10 = require("node:child_process");
82114
- var import_node_fs64 = require("node:fs");
82753
+ var import_node_fs65 = require("node:fs");
82115
82754
  var import_node_os33 = require("node:os");
82116
82755
  var import_node_path58 = require("node:path");
82117
82756
 
@@ -82225,8 +82864,8 @@ function removeLegacyRunKey() {
82225
82864
  }
82226
82865
  function logLine(msg) {
82227
82866
  try {
82228
- (0, import_node_fs64.mkdirSync)(logDir(), { recursive: true });
82229
- (0, import_node_fs64.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
82867
+ (0, import_node_fs65.mkdirSync)(logDir(), { recursive: true });
82868
+ (0, import_node_fs65.appendFileSync)(logFilePath(), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
82230
82869
  `);
82231
82870
  } catch {
82232
82871
  }
@@ -82235,7 +82874,7 @@ function registerAutostart(exePath) {
82235
82874
  if (!isWin) return;
82236
82875
  const xml = buildAutostartTaskXml(exePath, currentUserId());
82237
82876
  const tmp = (0, import_node_path58.join)((0, import_node_os33.tmpdir)(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
82238
- (0, import_node_fs64.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
82877
+ (0, import_node_fs65.writeFileSync)(tmp, "\uFEFF" + xml, { encoding: "utf16le" });
82239
82878
  try {
82240
82879
  (0, import_node_child_process10.execFileSync)("schtasks", ["/Create", "/TN", TASK_NAME, "/XML", tmp, "/F"], {
82241
82880
  stdio: ["ignore", "ignore", "ignore"],
@@ -82246,7 +82885,7 @@ function registerAutostart(exePath) {
82246
82885
  throw err2;
82247
82886
  } finally {
82248
82887
  try {
82249
- (0, import_node_fs64.rmSync)(tmp, { force: true });
82888
+ (0, import_node_fs65.rmSync)(tmp, { force: true });
82250
82889
  } catch {
82251
82890
  }
82252
82891
  }
@@ -82281,13 +82920,13 @@ function unregisterAutostart() {
82281
82920
  // updater.ts
82282
82921
  var import_node_child_process11 = require("node:child_process");
82283
82922
  var import_node_crypto37 = require("node:crypto");
82284
- var import_node_fs66 = require("node:fs");
82923
+ var import_node_fs67 = require("node:fs");
82285
82924
  var import_node_stream3 = require("node:stream");
82286
82925
  var import_promises5 = require("node:stream/promises");
82287
82926
  var import_node_path60 = require("node:path");
82288
82927
 
82289
82928
  // post-update-marker.mjs
82290
- var import_node_fs65 = require("node:fs");
82929
+ var import_node_fs66 = require("node:fs");
82291
82930
  var import_node_os34 = require("node:os");
82292
82931
  var import_node_path59 = require("node:path");
82293
82932
  var FRESH_MS = 12e4;
@@ -82310,7 +82949,7 @@ function writePostUpdateMarker() {
82310
82949
  for (const p of [markerPath(), legacyMarkerPath()]) {
82311
82950
  if (!p) continue;
82312
82951
  try {
82313
- (0, import_node_fs65.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
82952
+ (0, import_node_fs66.writeFileSync)(p, (/* @__PURE__ */ new Date()).toISOString());
82314
82953
  wrote = true;
82315
82954
  } catch {
82316
82955
  }
@@ -82322,9 +82961,9 @@ function consumePostUpdateMarker() {
82322
82961
  for (const p of [markerPath(), legacyMarkerPath()]) {
82323
82962
  if (!p) continue;
82324
82963
  try {
82325
- if (!(0, import_node_fs65.existsSync)(p)) continue;
82326
- const ageMs = Date.now() - (0, import_node_fs65.statSync)(p).mtimeMs;
82327
- (0, import_node_fs65.rmSync)(p, { force: true });
82964
+ if (!(0, import_node_fs66.existsSync)(p)) continue;
82965
+ const ageMs = Date.now() - (0, import_node_fs66.statSync)(p).mtimeMs;
82966
+ (0, import_node_fs66.rmSync)(p, { force: true });
82328
82967
  if (ageMs < FRESH_MS) fresh = true;
82329
82968
  } catch {
82330
82969
  }
@@ -82337,7 +82976,7 @@ var CHANNEL = "win";
82337
82976
  var FEED_TIMEOUT_MS = 15e3;
82338
82977
  var DOWNLOAD_TIMEOUT_MS = 3e5;
82339
82978
  var NUPKG_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*\.nupkg$/;
82340
- function currentVersion() {
82979
+ function currentVersion2() {
82341
82980
  return appVersion();
82342
82981
  }
82343
82982
  function installRoot() {
@@ -82390,7 +83029,7 @@ async function checkNpmUpdate(cur, channel = "npm") {
82390
83029
  }
82391
83030
  }
82392
83031
  async function checkForUpdate() {
82393
- const cur = currentVersion();
83032
+ const cur = currentVersion2();
82394
83033
  const channel = appChannel();
82395
83034
  if (channel === "npm" || channel === "npx") return checkNpmUpdate(cur, channel);
82396
83035
  if (channel !== "desktop") {
@@ -82438,22 +83077,22 @@ async function checkForUpdate() {
82438
83077
  }
82439
83078
  async function sha1OfFile(path) {
82440
83079
  const hash3 = (0, import_node_crypto37.createHash)("sha1");
82441
- await (0, import_promises5.pipeline)((0, import_node_fs66.createReadStream)(path), hash3);
83080
+ await (0, import_promises5.pipeline)((0, import_node_fs67.createReadStream)(path), hash3);
82442
83081
  return hash3.digest("hex").toUpperCase();
82443
83082
  }
82444
83083
  async function downloadPackage(asset) {
82445
83084
  if (!NUPKG_NAME.test(asset.FileName)) throw new Error(`refusing suspicious package name: ${asset.FileName}`);
82446
83085
  const want = asset.SHA1.toUpperCase();
82447
83086
  const dir = packagesDir();
82448
- (0, import_node_fs66.mkdirSync)(dir, { recursive: true });
83087
+ (0, import_node_fs67.mkdirSync)(dir, { recursive: true });
82449
83088
  const dest = (0, import_node_path60.join)(dir, asset.FileName);
82450
- if ((0, import_node_fs66.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
83089
+ if ((0, import_node_fs67.existsSync)(dest) && await sha1OfFile(dest) === want) return dest;
82451
83090
  const res = await authedFetch(`${feedUrl()}/${encodeURIComponent(asset.FileName)}`, {
82452
83091
  redirect: "follow",
82453
83092
  signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS)
82454
83093
  });
82455
83094
  if (!res.ok || !res.body) throw new Error(`download failed: HTTP ${res.status} for ${asset.FileName}`);
82456
- await (0, import_promises5.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs66.createWriteStream)(dest));
83095
+ await (0, import_promises5.pipeline)(import_node_stream3.Readable.fromWeb(res.body), (0, import_node_fs67.createWriteStream)(dest));
82457
83096
  const got = await sha1OfFile(dest);
82458
83097
  if (got !== want) throw new Error(`SHA1 mismatch for ${asset.FileName}: feed=${want} got=${got}`);
82459
83098
  return dest;
@@ -82462,7 +83101,7 @@ async function applyUpdate(check, opts) {
82462
83101
  if (!check.supported) return { applied: false, message: check.reason ?? "auto-update not supported in this runtime" };
82463
83102
  if (!check.updateAvailable || !check.asset) return { applied: false, message: check.reason ?? "no update available" };
82464
83103
  const exe2 = updateExePath();
82465
- if (!(0, import_node_fs66.existsSync)(exe2)) {
83104
+ if (!(0, import_node_fs67.existsSync)(exe2)) {
82466
83105
  return { applied: false, message: `Update.exe not found at ${exe2} \u2014 is this a Velopack install?` };
82467
83106
  }
82468
83107
  const pkg = await downloadPackage(check.asset);
@@ -82579,15 +83218,15 @@ function ccType(prefix) {
82579
83218
  }
82580
83219
  }
82581
83220
  function parseBulletChanges(body) {
82582
- const text4 = body.replace(/\r\n?/g, "\n");
83221
+ const text5 = body.replace(/\r\n?/g, "\n");
82583
83222
  const styled = [];
82584
83223
  let m;
82585
83224
  STYLED_CHANGE_RE.lastIndex = 0;
82586
- while ((m = STYLED_CHANGE_RE.exec(text4)) !== null) styled.push({ type: m[1].toLowerCase(), description: m[2].trim() });
83225
+ while ((m = STYLED_CHANGE_RE.exec(text5)) !== null) styled.push({ type: m[1].toLowerCase(), description: m[2].trim() });
82587
83226
  if (styled.length) return styled;
82588
83227
  const out = [];
82589
83228
  COMMIT_BULLET_RE.lastIndex = 0;
82590
- while ((m = COMMIT_BULLET_RE.exec(text4)) !== null) {
83229
+ while ((m = COMMIT_BULLET_RE.exec(text5)) !== null) {
82591
83230
  const raw = m[1].replace(GH_CREDIT_RE, "").trim();
82592
83231
  if (!raw) continue;
82593
83232
  if (raw.startsWith("@")) continue;
@@ -82704,7 +83343,7 @@ function isTraceCorrupt(events) {
82704
83343
  var import_node_child_process12 = require("node:child_process");
82705
83344
  var import_node_path61 = require("node:path");
82706
83345
  var import_node_url3 = require("node:url");
82707
- var import_node_fs67 = require("node:fs");
83346
+ var import_node_fs68 = require("node:fs");
82708
83347
  var import_node_http = __toESM(require("node:http"), 1);
82709
83348
  var import_node_readline = require("node:readline");
82710
83349
  var __dirname2 = (0, import_node_path61.dirname)((0, import_node_url3.fileURLToPath)(__import_meta_url));
@@ -82786,7 +83425,7 @@ function resolveServerStart() {
82786
83425
  const packaged = /flolessapp\.exe$/i.test(process.execPath);
82787
83426
  if (packaged) return { cmd: process.execPath, args: ["--serve"], shell: false };
82788
83427
  const bundle = (0, import_node_path61.join)(__dirname2, "dist", "floless-server.cjs");
82789
- if ((0, import_node_fs67.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
83428
+ if ((0, import_node_fs68.existsSync)(bundle)) return { cmd: process.execPath, args: [bundle, "--serve"], shell: false };
82790
83429
  return { cmd: "npm", args: ["run", "start"], shell: isWin2 };
82791
83430
  }
82792
83431
  function startServerDetached() {
@@ -83142,13 +83781,13 @@ function pathInside(root6, candidate) {
83142
83781
  return rel === "" || !rel.startsWith("..") && !(0, import_node_path62.isAbsolute)(rel);
83143
83782
  }
83144
83783
  async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
83145
- let names;
83784
+ let names2;
83146
83785
  try {
83147
83786
  const directory = await io.lstat(bridgeDirectory);
83148
83787
  if (!directory.isDirectory() || directory.isSymbolicLink()) {
83149
83788
  throw new Error("persistent bridge directory is not a regular directory");
83150
83789
  }
83151
- names = await io.readdir(bridgeDirectory);
83790
+ names2 = await io.readdir(bridgeDirectory);
83152
83791
  } catch (error) {
83153
83792
  if (error.code === "ENOENT") return Object.freeze([]);
83154
83793
  throw new Error("Could not safely inspect installed AWARE bridges.", { cause: error });
@@ -83162,7 +83801,7 @@ async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
83162
83801
  const installed = [];
83163
83802
  for (const host of AWARE_BRIDGE_HOSTS) {
83164
83803
  const fileName = `aware-${host}.exe`;
83165
- if (!names.includes(fileName)) continue;
83804
+ if (!names2.includes(fileName)) continue;
83166
83805
  const candidate = (0, import_node_path62.join)(bridgeDirectory, fileName);
83167
83806
  try {
83168
83807
  const stat4 = await io.lstat(candidate);
@@ -83617,17 +84256,17 @@ function installAwareGlobal(spec, onLine = () => {
83617
84256
  signal.addEventListener("abort", onAbort, { once: true });
83618
84257
  if (signal.aborted) onAbort();
83619
84258
  child.stdout?.on("data", (data) => {
83620
- const text4 = data.toString();
83621
- combinedTail = tail2(combinedTail, text4);
83622
- onLine(text4.trimEnd());
83623
- options.onLine?.(text4.trimEnd());
84259
+ const text5 = data.toString();
84260
+ combinedTail = tail2(combinedTail, text5);
84261
+ onLine(text5.trimEnd());
84262
+ options.onLine?.(text5.trimEnd());
83624
84263
  });
83625
84264
  child.stderr?.on("data", (data) => {
83626
- const text4 = data.toString();
83627
- stderrTail = tail2(stderrTail, text4);
83628
- combinedTail = tail2(combinedTail, text4);
83629
- onLine(text4.trimEnd());
83630
- options.onLine?.(text4.trimEnd());
84265
+ const text5 = data.toString();
84266
+ stderrTail = tail2(stderrTail, text5);
84267
+ combinedTail = tail2(combinedTail, text5);
84268
+ onLine(text5.trimEnd());
84269
+ options.onLine?.(text5.trimEnd());
83631
84270
  });
83632
84271
  child.on("spawn", () => {
83633
84272
  if (!child.pid || !options.onChild) return;
@@ -83648,6 +84287,90 @@ function installAwareGlobal(spec, onLine = () => {
83648
84287
  });
83649
84288
  }
83650
84289
 
84290
+ // installer-tree-probe.ts
84291
+ var import_node_child_process14 = require("node:child_process");
84292
+ var import_promises8 = require("node:fs/promises");
84293
+ var import_node_util6 = require("node:util");
84294
+ var execFileAsync3 = (0, import_node_util6.promisify)(import_node_child_process14.execFile);
84295
+ var INSTALLER_COMMAND_LINE_PATTERN = "@aware-aeco/cli@|\\baware(?:\\.cmd|\\.js)?\\W?\\s+sidecar\\s+install";
84296
+ var INSTALLER_RE = new RegExp(INSTALLER_COMMAND_LINE_PATTERN);
84297
+ function matchesInstallerCommandLine(commandLine) {
84298
+ return INSTALLER_RE.test(commandLine);
84299
+ }
84300
+ function procCmdlineToString(raw) {
84301
+ return raw.replace(/\0+$/, "").split("\0").join(" ");
84302
+ }
84303
+ function psOutputHasInstaller(stdout, selfPid) {
84304
+ for (const line of stdout.split("\n")) {
84305
+ const match = /^\s*(\d+)\s+(.*)$/.exec(line);
84306
+ if (!match) continue;
84307
+ if (Number(match[1]) === selfPid) continue;
84308
+ if (matchesInstallerCommandLine(match[2])) return true;
84309
+ }
84310
+ return false;
84311
+ }
84312
+ function isVanishedProcessError(err2) {
84313
+ const code = err2?.code;
84314
+ return code === "ENOENT" || code === "ESRCH";
84315
+ }
84316
+ function windowsProbe() {
84317
+ const script = [
84318
+ "$p=Get-CimInstance Win32_Process -ErrorAction Stop",
84319
+ `$m=$p|Where-Object {$_.ProcessId -ne $PID -and $_.CommandLine -match '${INSTALLER_COMMAND_LINE_PATTERN}'}`,
84320
+ "if($m){Write-Output true}else{Write-Output false}"
84321
+ ].join(";");
84322
+ return (0, import_node_child_process14.execFileSync)("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
84323
+ encoding: "utf8",
84324
+ windowsHide: true,
84325
+ timeout: 5e3
84326
+ }).trim();
84327
+ }
84328
+ async function runPsDefault() {
84329
+ const { stdout } = await execFileAsync3("ps", ["-Awwo", "pid=,command="], {
84330
+ encoding: "utf8",
84331
+ timeout: 5e3,
84332
+ maxBuffer: 8 * 1024 * 1024
84333
+ });
84334
+ return stdout;
84335
+ }
84336
+ async function anyAwareInstallerTreeAlive(deps = {}) {
84337
+ const platform = deps.platform ?? process.platform;
84338
+ const selfPid = deps.selfPid ?? process.pid;
84339
+ if (platform === "win32") {
84340
+ try {
84341
+ return (deps.runWindowsProbe ?? windowsProbe)().toLowerCase() === "true";
84342
+ } catch {
84343
+ return true;
84344
+ }
84345
+ }
84346
+ if (platform === "linux") {
84347
+ let entries;
84348
+ try {
84349
+ entries = await (deps.listProcDir ?? (() => (0, import_promises8.readdir)("/proc")))();
84350
+ } catch {
84351
+ return true;
84352
+ }
84353
+ const read2 = deps.readProcCmdline ?? ((pid) => (0, import_promises8.readFile)(`/proc/${pid}/cmdline`, "utf8"));
84354
+ for (const entry2 of entries) {
84355
+ if (!/^\d+$/.test(entry2) || Number(entry2) === selfPid) continue;
84356
+ let raw;
84357
+ try {
84358
+ raw = await read2(entry2);
84359
+ } catch (err2) {
84360
+ if (isVanishedProcessError(err2)) continue;
84361
+ return true;
84362
+ }
84363
+ if (matchesInstallerCommandLine(procCmdlineToString(raw))) return true;
84364
+ }
84365
+ return false;
84366
+ }
84367
+ try {
84368
+ return psOutputHasInstaller(await (deps.runPs ?? runPsDefault)(), selfPid);
84369
+ } catch {
84370
+ return true;
84371
+ }
84372
+ }
84373
+
83651
84374
  // aware-update-jobs.ts
83652
84375
  var AwareUpdateConflictError = class extends Error {
83653
84376
  status = 409;
@@ -84442,16 +85165,16 @@ function registerDebugNodeRoute(app, deps) {
84442
85165
  }
84443
85166
 
84444
85167
  // terminal-run.ts
84445
- var import_node_child_process14 = require("node:child_process");
84446
85168
  var import_node_child_process15 = require("node:child_process");
84447
- var import_node_fs71 = require("node:fs");
85169
+ var import_node_child_process16 = require("node:child_process");
85170
+ var import_node_fs72 = require("node:fs");
84448
85171
  var import_node_crypto40 = require("node:crypto");
84449
85172
  var import_node_os36 = require("node:os");
84450
85173
  var import_node_path67 = require("node:path");
84451
85174
 
84452
85175
  // run-file-relay.ts
84453
85176
  var import_node_crypto39 = require("node:crypto");
84454
- var import_node_fs68 = require("node:fs");
85177
+ var import_node_fs69 = require("node:fs");
84455
85178
  var import_node_path64 = require("node:path");
84456
85179
  var import_yaml11 = __toESM(require_dist6(), 1);
84457
85180
  var SAFE_APP_ID2 = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
@@ -84492,21 +85215,21 @@ function createRunFileRelay(options) {
84492
85215
  const validateRoot = (0, import_node_path64.join)(options.journalRoot, `.validate-${safeLease2(options.leaseId)}-${(0, import_node_crypto39.randomUUID)()}`);
84493
85216
  const validateAppDir = (0, import_node_path64.join)(validateRoot, options.appId);
84494
85217
  const validateSourcePath = (0, import_node_path64.join)(validateAppDir, `${options.appId}.flo`);
84495
- (0, import_node_fs68.mkdirSync)(validateAppDir, { recursive: true, mode: 448 });
85218
+ (0, import_node_fs69.mkdirSync)(validateAppDir, { recursive: true, mode: 448 });
84496
85219
  try {
84497
- (0, import_node_fs68.writeFileSync)(validateSourcePath, candidate, { encoding: "utf8", mode: 384, flag: "wx" });
85220
+ (0, import_node_fs69.writeFileSync)(validateSourcePath, candidate, { encoding: "utf8", mode: 384, flag: "wx" });
84498
85221
  await options.validateCandidate({ appDir: validateAppDir, sourcePath: validateSourcePath });
84499
85222
  } finally {
84500
- (0, import_node_fs68.rmSync)(validateRoot, { recursive: true, force: true });
85223
+ (0, import_node_fs69.rmSync)(validateRoot, { recursive: true, force: true });
84501
85224
  }
84502
85225
  const afterValidation = readSnapshot(options);
84503
85226
  if (afterValidation.sha256 !== before.sha256 || !sameIdentity(afterValidation.identity, before.identity)) {
84504
85227
  throw new RunFileRelayError("the workflow changed while the proposal was being validated; read it again");
84505
85228
  }
84506
- (0, import_node_fs68.mkdirSync)(options.journalRoot, { recursive: true, mode: 448 });
85229
+ (0, import_node_fs69.mkdirSync)(options.journalRoot, { recursive: true, mode: 448 });
84507
85230
  const journalDir = (0, import_node_path64.join)(options.journalRoot, safeLease2(options.leaseId));
84508
85231
  try {
84509
- (0, import_node_fs68.mkdirSync)(journalDir, { mode: 448 });
85232
+ (0, import_node_fs69.mkdirSync)(journalDir, { mode: 448 });
84510
85233
  } catch (err2) {
84511
85234
  if (err2.code === "EEXIST") {
84512
85235
  throw new RunFileRelayError("this run already has a staged candidate");
@@ -84544,7 +85267,7 @@ function createRunFileRelay(options) {
84544
85267
  syncDirectoryBestEffort(options.journalRoot);
84545
85268
  drainAuditOutbox(options, (0, import_node_path64.join)(journalDir, "journal.json"));
84546
85269
  } catch (err2) {
84547
- (0, import_node_fs68.rmSync)(journalDir, { recursive: true, force: true });
85270
+ (0, import_node_fs69.rmSync)(journalDir, { recursive: true, force: true });
84548
85271
  throw err2;
84549
85272
  }
84550
85273
  return { baseSha256: before.sha256, candidateSha256, journalDir };
@@ -84576,7 +85299,7 @@ function createRunFileRelay(options) {
84576
85299
  if (journal.value.state !== "final-ok") throw new RunFileRelayError("the staged candidate has no durable final-ok result");
84577
85300
  const candidatePath = (0, import_node_path64.join)(journal.dir, "candidate.flo");
84578
85301
  rejectLink2(candidatePath, "staged candidate");
84579
- const candidateBytes = (0, import_node_fs68.readFileSync)(candidatePath);
85302
+ const candidateBytes = (0, import_node_fs69.readFileSync)(candidatePath);
84580
85303
  if (candidateBytes.length > MAX_SOURCE_BYTES) throw new RunFileRelayError("the staged candidate is too large");
84581
85304
  new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(candidateBytes);
84582
85305
  const candidateSha256 = hash2(candidateBytes);
@@ -84587,7 +85310,7 @@ function createRunFileRelay(options) {
84587
85310
  }
84588
85311
  const lockPath2 = live.sourcePath.replace(/\.(flo|app|flow|aware)$/i, ".lock");
84589
85312
  const sourceBefore = Buffer.from(live.source, "utf8");
84590
- const lockBefore = (0, import_node_fs68.existsSync)(lockPath2) ? readRegularFile(lockPath2, MAX_SOURCE_BYTES, "workflow lock") : null;
85313
+ const lockBefore = (0, import_node_fs69.existsSync)(lockPath2) ? readRegularFile(lockPath2, MAX_SOURCE_BYTES, "workflow lock") : null;
84591
85314
  let mutated = false;
84592
85315
  try {
84593
85316
  durableWrite3((0, import_node_path64.join)(journal.dir, "source.before"), sourceBefore);
@@ -84608,12 +85331,12 @@ function createRunFileRelay(options) {
84608
85331
  }, "source-written", { oldHash: journal.value.baseSha256, newHash: candidateSha256 }));
84609
85332
  drainAuditOutbox(options, journal.path);
84610
85333
  const compiled = await deps.compile(live.sourcePath);
84611
- if (hash2((0, import_node_fs68.readFileSync)(live.sourcePath)) !== candidateSha256) {
85334
+ if (hash2((0, import_node_fs69.readFileSync)(live.sourcePath)) !== candidateSha256) {
84612
85335
  throw new RunFileRelayError("the compiler did not compile the exact staged source bytes");
84613
85336
  }
84614
85337
  const producedLock = compiled.lockPath ?? lockPath2;
84615
85338
  rejectLink2(producedLock, "compiled workflow lock");
84616
- const realLock = import_node_fs68.realpathSync.native(producedLock);
85339
+ const realLock = import_node_fs69.realpathSync.native(producedLock);
84617
85340
  const expectedLock = (0, import_node_path64.resolve)(lockPath2);
84618
85341
  const norm2 = (value) => process.platform === "win32" ? value.toLowerCase() : value;
84619
85342
  if (norm2(realLock) !== norm2(expectedLock)) throw new RunFileRelayError("the compiler wrote an unexpected lock path");
@@ -84670,7 +85393,7 @@ function createRunFileRelay(options) {
84670
85393
  try {
84671
85394
  live = readSnapshot(options);
84672
85395
  const lockPath2 = live.sourcePath.replace(/\.(flo|app|flow|aware)$/i, ".lock");
84673
- currentLock = (0, import_node_fs68.existsSync)(lockPath2) ? readRegularFile(lockPath2, MAX_SOURCE_BYTES, "workflow lock") : null;
85396
+ currentLock = (0, import_node_fs69.existsSync)(lockPath2) ? readRegularFile(lockPath2, MAX_SOURCE_BYTES, "workflow lock") : null;
84674
85397
  } catch (error) {
84675
85398
  throw new RunFileRelayError(
84676
85399
  `the live workflow generation cannot be verified; automatic recovery refused: ${String(error?.message ?? error)}`,
@@ -84687,7 +85410,7 @@ function createRunFileRelay(options) {
84687
85410
  }
84688
85411
  if (journal.value.state === "compiled") {
84689
85412
  const receiptPath = (0, import_node_path64.join)(journal.dir, "receipt.json");
84690
- if ((0, import_node_fs68.existsSync)(receiptPath)) verifyReceipt(options, journal.dir, journal.value);
85413
+ if ((0, import_node_fs69.existsSync)(receiptPath)) verifyReceipt(options, journal.dir, journal.value);
84691
85414
  else writeReceipt(options, journal.dir, journal.value);
84692
85415
  writeJournal(journal.path, withAudit(options, {
84693
85416
  ...readJournal(options).value,
@@ -84703,7 +85426,7 @@ function createRunFileRelay(options) {
84703
85426
  };
84704
85427
  const discardStage = () => {
84705
85428
  const dir = (0, import_node_path64.join)(options.journalRoot, safeLease2(options.leaseId));
84706
- if (!(0, import_node_fs68.existsSync)(dir)) return;
85429
+ if (!(0, import_node_fs69.existsSync)(dir)) return;
84707
85430
  const journal = readJournal(options);
84708
85431
  if (!["staged", "final-ok", "rolled-back"].includes(journal.value.state)) {
84709
85432
  throw new RunFileRelayError(
@@ -84725,7 +85448,7 @@ function createRunFileRelay(options) {
84725
85448
  }
84726
85449
  drainAuditOutbox(options, journal.path);
84727
85450
  if (readJournal(options).value.auditOutbox.length) return;
84728
- (0, import_node_fs68.rmSync)(dir, { recursive: true, force: true });
85451
+ (0, import_node_fs69.rmSync)(dir, { recursive: true, force: true });
84729
85452
  };
84730
85453
  const cleanupCompleted = () => {
84731
85454
  const journal = readJournal(options);
@@ -84736,7 +85459,7 @@ function createRunFileRelay(options) {
84736
85459
  const drained = readJournal(options);
84737
85460
  if (drained.value.auditOutbox.length) throw new RunFileRelayError("run audit outbox is not drained");
84738
85461
  verifyReceipt(options, drained.dir, drained.value);
84739
- (0, import_node_fs68.rmSync)(drained.dir, { recursive: true, force: true });
85462
+ (0, import_node_fs69.rmSync)(drained.dir, { recursive: true, force: true });
84740
85463
  syncDirectoryBestEffort(options.journalRoot);
84741
85464
  };
84742
85465
  const recordPublicationCommitted = () => {
@@ -84765,7 +85488,7 @@ function createRunFileRelay(options) {
84765
85488
  }
84766
85489
  function readRunFileJournalIdentity(journalRoot, leaseId) {
84767
85490
  const dir = (0, import_node_path64.join)(journalRoot, safeLease2(leaseId));
84768
- if (!(0, import_node_fs68.existsSync)(dir)) return null;
85491
+ if (!(0, import_node_fs69.existsSync)(dir)) return null;
84769
85492
  rejectLink2(dir, "run journal");
84770
85493
  const path = (0, import_node_path64.join)(dir, "journal.json");
84771
85494
  rejectLink2(path, "run journal record");
@@ -84787,7 +85510,7 @@ function readJournal(options) {
84787
85510
  rejectLink2(path, "run journal record");
84788
85511
  let value;
84789
85512
  try {
84790
- value = JSON.parse((0, import_node_fs68.readFileSync)(path, "utf8"));
85513
+ value = JSON.parse((0, import_node_fs69.readFileSync)(path, "utf8"));
84791
85514
  } catch {
84792
85515
  throw new RunFileRelayError("run journal is missing or malformed");
84793
85516
  }
@@ -84849,7 +85572,7 @@ function verifyReceipt(options, dir, journal) {
84849
85572
  rejectLink2(path, "run settlement receipt");
84850
85573
  let value;
84851
85574
  try {
84852
- value = JSON.parse((0, import_node_fs68.readFileSync)(path, "utf8"));
85575
+ value = JSON.parse((0, import_node_fs69.readFileSync)(path, "utf8"));
84853
85576
  } catch {
84854
85577
  throw new RunFileRelayError("run settlement receipt is malformed");
84855
85578
  }
@@ -84874,8 +85597,8 @@ function restoreBefore(options, journal) {
84874
85597
  const lockPath2 = live.sourcePath.replace(/\.(flo|app|flow|aware)$/i, ".lock");
84875
85598
  const beforeLock = (0, import_node_path64.join)(journal.dir, "lock.before");
84876
85599
  const absent = (0, import_node_path64.join)(journal.dir, "lock.absent");
84877
- const beforeLockBytes = (0, import_node_fs68.existsSync)(beforeLock) ? readRegularFile(beforeLock, MAX_SOURCE_BYTES, "lock snapshot") : null;
84878
- if (!beforeLockBytes && !(0, import_node_fs68.existsSync)(absent)) throw new RunFileRelayError("run journal has no prior lock snapshot");
85600
+ const beforeLockBytes = (0, import_node_fs69.existsSync)(beforeLock) ? readRegularFile(beforeLock, MAX_SOURCE_BYTES, "lock snapshot") : null;
85601
+ if (!beforeLockBytes && !(0, import_node_fs69.existsSync)(absent)) throw new RunFileRelayError("run journal has no prior lock snapshot");
84879
85602
  const ownedSourceHashes = /* @__PURE__ */ new Set([journal.value.baseSha256, journal.value.candidateSha256]);
84880
85603
  if (typeof journal.value.sourceSha256 === "string") ownedSourceHashes.add(journal.value.sourceSha256);
84881
85604
  if (!ownedSourceHashes.has(live.sha256)) {
@@ -84883,7 +85606,7 @@ function restoreBefore(options, journal) {
84883
85606
  }
84884
85607
  let currentLock = null;
84885
85608
  try {
84886
- currentLock = (0, import_node_fs68.existsSync)(lockPath2) ? readRegularFile(lockPath2, MAX_SOURCE_BYTES, "workflow lock") : null;
85609
+ currentLock = (0, import_node_fs69.existsSync)(lockPath2) ? readRegularFile(lockPath2, MAX_SOURCE_BYTES, "workflow lock") : null;
84887
85610
  } catch (error) {
84888
85611
  throw new RunFileRelayError(
84889
85612
  `the live workflow lock cannot be attributed to this transaction; automatic rollback refused: ${String(error?.message ?? error)}`,
@@ -84899,11 +85622,11 @@ function restoreBefore(options, journal) {
84899
85622
  }
84900
85623
  durableReplace4(live.sourcePath, sourceBefore);
84901
85624
  if (beforeLockBytes) durableReplace4(lockPath2, beforeLockBytes);
84902
- else if ((0, import_node_fs68.existsSync)(absent)) {
84903
- if ((0, import_node_fs68.existsSync)(lockPath2)) (0, import_node_fs68.rmSync)(lockPath2, { force: true });
85625
+ else if ((0, import_node_fs69.existsSync)(absent)) {
85626
+ if ((0, import_node_fs69.existsSync)(lockPath2)) (0, import_node_fs69.rmSync)(lockPath2, { force: true });
84904
85627
  }
84905
85628
  try {
84906
- (0, import_node_fs68.rmSync)((0, import_node_path64.join)(journal.dir, "receipt.json"), { force: true });
85629
+ (0, import_node_fs69.rmSync)((0, import_node_path64.join)(journal.dir, "receipt.json"), { force: true });
84907
85630
  } catch {
84908
85631
  }
84909
85632
  writeJournal(journal.path, withAudit(options, {
@@ -84916,21 +85639,21 @@ function restoreBefore(options, journal) {
84916
85639
  function readSnapshot(options) {
84917
85640
  assertIdentifiers(options);
84918
85641
  const appsRootInput = (0, import_node_path64.resolve)(options.appsRoot);
84919
- if (!(0, import_node_fs68.existsSync)(appsRootInput)) throw new RunFileRelayError("the AWARE apps root does not exist");
85642
+ if (!(0, import_node_fs69.existsSync)(appsRootInput)) throw new RunFileRelayError("the AWARE apps root does not exist");
84920
85643
  rejectLink2(appsRootInput, "AWARE apps root");
84921
- const appsRoot = import_node_fs68.realpathSync.native(appsRootInput);
85644
+ const appsRoot = import_node_fs69.realpathSync.native(appsRootInput);
84922
85645
  const appDirInput = (0, import_node_path64.join)(appsRoot, options.appId);
84923
85646
  rejectLink2(appDirInput, "app directory");
84924
- const appDir2 = import_node_fs68.realpathSync.native(appDirInput);
85647
+ const appDir2 = import_node_fs69.realpathSync.native(appDirInput);
84925
85648
  if (!isInside(appsRoot, appDir2)) throw new RunFileRelayError("the app directory escapes the AWARE apps root");
84926
85649
  const sourceInput = (0, import_node_path64.join)(appDir2, `${options.appId}.flo`);
84927
85650
  rejectLink2(sourceInput, "workflow source");
84928
- const sourcePath2 = import_node_fs68.realpathSync.native(sourceInput);
85651
+ const sourcePath2 = import_node_fs69.realpathSync.native(sourceInput);
84929
85652
  if (!isInside(appDir2, sourcePath2)) throw new RunFileRelayError("the workflow source escapes its app directory");
84930
- const st = (0, import_node_fs68.statSync)(sourcePath2);
85653
+ const st = (0, import_node_fs69.statSync)(sourcePath2);
84931
85654
  if (!st.isFile()) throw new RunFileRelayError("the workflow source is not a regular file");
84932
85655
  if (st.size > MAX_SOURCE_BYTES) throw new RunFileRelayError("the workflow source is too large");
84933
- const bytes = (0, import_node_fs68.readFileSync)(sourcePath2);
85656
+ const bytes = (0, import_node_fs69.readFileSync)(sourcePath2);
84934
85657
  let source;
84935
85658
  try {
84936
85659
  source = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
@@ -85019,7 +85742,7 @@ function safeLease2(value) {
85019
85742
  function rejectLink2(path, label2) {
85020
85743
  let st;
85021
85744
  try {
85022
- st = (0, import_node_fs68.lstatSync)(path);
85745
+ st = (0, import_node_fs69.lstatSync)(path);
85023
85746
  } catch {
85024
85747
  throw new RunFileRelayError(`${label2} does not exist`);
85025
85748
  }
@@ -85040,40 +85763,40 @@ function hash2(value) {
85040
85763
  }
85041
85764
  function readRegularFile(path, maxBytes, label2) {
85042
85765
  rejectLink2(path, label2);
85043
- const st = (0, import_node_fs68.statSync)(path);
85766
+ const st = (0, import_node_fs69.statSync)(path);
85044
85767
  if (!st.isFile()) throw new RunFileRelayError(`${label2} is not a regular file`);
85045
85768
  if (st.size > maxBytes) throw new RunFileRelayError(`${label2} is too large`);
85046
- return (0, import_node_fs68.readFileSync)(path);
85769
+ return (0, import_node_fs69.readFileSync)(path);
85047
85770
  }
85048
85771
  function durableWrite3(path, value) {
85049
85772
  const tmp = `${path}.${process.pid}.${(0, import_node_crypto39.randomUUID)()}.tmp`;
85050
- const fd2 = (0, import_node_fs68.openSync)(tmp, "wx", 384);
85773
+ const fd2 = (0, import_node_fs69.openSync)(tmp, "wx", 384);
85051
85774
  try {
85052
- (0, import_node_fs68.writeFileSync)(fd2, value);
85053
- (0, import_node_fs68.fsyncSync)(fd2);
85775
+ (0, import_node_fs69.writeFileSync)(fd2, value);
85776
+ (0, import_node_fs69.fsyncSync)(fd2);
85054
85777
  } finally {
85055
- (0, import_node_fs68.closeSync)(fd2);
85778
+ (0, import_node_fs69.closeSync)(fd2);
85056
85779
  }
85057
- (0, import_node_fs68.renameSync)(tmp, path);
85780
+ (0, import_node_fs69.renameSync)(tmp, path);
85058
85781
  syncFile(path);
85059
85782
  syncDirectoryBestEffort((0, import_node_path64.dirname)(path));
85060
85783
  }
85061
85784
  function durableReplace4(path, value) {
85062
85785
  const tmp = `${path}.${process.pid}.${(0, import_node_crypto39.randomUUID)()}.tmp`;
85063
- const fd2 = (0, import_node_fs68.openSync)(tmp, "wx", 384);
85786
+ const fd2 = (0, import_node_fs69.openSync)(tmp, "wx", 384);
85064
85787
  try {
85065
- (0, import_node_fs68.writeFileSync)(fd2, value);
85066
- (0, import_node_fs68.fsyncSync)(fd2);
85788
+ (0, import_node_fs69.writeFileSync)(fd2, value);
85789
+ (0, import_node_fs69.fsyncSync)(fd2);
85067
85790
  } finally {
85068
- (0, import_node_fs68.closeSync)(fd2);
85791
+ (0, import_node_fs69.closeSync)(fd2);
85069
85792
  }
85070
- (0, import_node_fs68.renameSync)(tmp, path);
85793
+ (0, import_node_fs69.renameSync)(tmp, path);
85071
85794
  syncFile(path);
85072
85795
  syncDirectoryBestEffort((0, import_node_path64.dirname)(path));
85073
85796
  }
85074
85797
 
85075
85798
  // skill-sync.ts
85076
- var import_node_fs69 = require("node:fs");
85799
+ var import_node_fs70 = require("node:fs");
85077
85800
  var import_node_os35 = require("node:os");
85078
85801
  var import_node_path65 = require("node:path");
85079
85802
  var import_node_url4 = require("node:url");
@@ -85116,8 +85839,8 @@ var PRODUCT_SKILLS = [
85116
85839
  "steel-drawing-abbreviations"
85117
85840
  // default US/AISC abbreviations+shapes legend (non-namespace) the steel reader falls back to when a set omits its own legend sheet
85118
85841
  ];
85119
- function selectShippedSkillNames(names) {
85120
- const present = new Set(names);
85842
+ function selectShippedSkillNames(names2) {
85843
+ const present = new Set(names2);
85121
85844
  return PRODUCT_SKILLS.filter((name) => present.has(name));
85122
85845
  }
85123
85846
 
@@ -85129,7 +85852,7 @@ function bundledSkillsRoot() {
85129
85852
  (0, import_node_path65.join)((0, import_node_path65.dirname)(process.execPath), "skills"),
85130
85853
  (0, import_node_path65.join)(__dirname3, "..", ".claude", "skills")
85131
85854
  ];
85132
- return candidates.find((p) => (0, import_node_fs69.existsSync)(p)) ?? null;
85855
+ return candidates.find((p) => (0, import_node_fs70.existsSync)(p)) ?? null;
85133
85856
  }
85134
85857
  function targetConfigDirs() {
85135
85858
  const override = process.env.FLOLESS_SKILL_TARGETS;
@@ -85145,8 +85868,8 @@ function targetConfigDirs() {
85145
85868
  }
85146
85869
  function skillVersion(skillMdPath) {
85147
85870
  try {
85148
- const text4 = (0, import_node_fs69.readFileSync)(skillMdPath, "utf8");
85149
- const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text4);
85871
+ const text5 = (0, import_node_fs70.readFileSync)(skillMdPath, "utf8");
85872
+ const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text5);
85150
85873
  if (!m || m[1] === void 0) return null;
85151
85874
  const fm = (0, import_yaml12.parse)(m[1]);
85152
85875
  const meta = fm?.metadata;
@@ -85185,7 +85908,7 @@ function decideAction(installed, bundled) {
85185
85908
  function bundledSkills(root6) {
85186
85909
  let entries = [];
85187
85910
  try {
85188
- entries = selectShippedSkillNames((0, import_node_fs69.readdirSync)(root6));
85911
+ entries = selectShippedSkillNames((0, import_node_fs70.readdirSync)(root6));
85189
85912
  } catch {
85190
85913
  return [];
85191
85914
  }
@@ -85194,7 +85917,7 @@ function bundledSkills(root6) {
85194
85917
  const dir = (0, import_node_path65.join)(root6, name);
85195
85918
  let isDir = false;
85196
85919
  try {
85197
- isDir = (0, import_node_fs69.statSync)(dir).isDirectory();
85920
+ isDir = (0, import_node_fs70.statSync)(dir).isDirectory();
85198
85921
  } catch {
85199
85922
  isDir = false;
85200
85923
  }
@@ -85212,17 +85935,17 @@ function syncSkills() {
85212
85935
  const skills = bundledSkills(root6);
85213
85936
  if (!skills.length) return results;
85214
85937
  for (const { runtime, dir: cfg } of targetConfigDirs()) {
85215
- if (!(0, import_node_fs69.existsSync)(cfg)) continue;
85938
+ if (!(0, import_node_fs70.existsSync)(cfg)) continue;
85216
85939
  const skillsDir = (0, import_node_path65.join)(cfg, "skills");
85217
85940
  for (const s of skills) {
85218
85941
  const dest = (0, import_node_path65.join)(skillsDir, s.name);
85219
85942
  const installedMd = (0, import_node_path65.join)(dest, "SKILL.md");
85220
- const installed = (0, import_node_fs69.existsSync)(installedMd) ? skillVersion(installedMd) : null;
85943
+ const installed = (0, import_node_fs70.existsSync)(installedMd) ? skillVersion(installedMd) : null;
85221
85944
  const action = decideAction(installed, s.version);
85222
85945
  if (action === "installed" || action === "updated") {
85223
85946
  try {
85224
- if (action === "updated") (0, import_node_fs69.rmSync)(dest, { recursive: true, force: true });
85225
- (0, import_node_fs69.cpSync)(s.dir, dest, { recursive: true });
85947
+ if (action === "updated") (0, import_node_fs70.rmSync)(dest, { recursive: true, force: true });
85948
+ (0, import_node_fs70.cpSync)(s.dir, dest, { recursive: true });
85226
85949
  results.push({ runtime, skill: s.name, action, from: installed, to: s.version });
85227
85950
  } catch {
85228
85951
  }
@@ -85235,7 +85958,7 @@ function syncSkills() {
85235
85958
  }
85236
85959
 
85237
85960
  // run-skill-relay.ts
85238
- var import_node_fs70 = require("node:fs");
85961
+ var import_node_fs71 = require("node:fs");
85239
85962
  var import_node_path66 = require("node:path");
85240
85963
  var MAX_RESOURCE_BYTES = 256 * 1024;
85241
85964
  var SAFE_SKILL = /^floless-app-[a-z0-9][a-z0-9-]*$/;
@@ -85272,15 +85995,15 @@ function createRunSkillReader(options) {
85272
85995
  const candidate = (0, import_node_path66.resolve)(skillRoot, ...segments);
85273
85996
  let real;
85274
85997
  try {
85275
- real = import_node_fs70.realpathSync.native(candidate);
85998
+ real = import_node_fs71.realpathSync.native(candidate);
85276
85999
  } catch {
85277
86000
  throw new RunSkillRelayError("skill resource not found");
85278
86001
  }
85279
86002
  if (!isInside(skillRoot, real)) throw new RunSkillRelayError("resource escapes the selected skill");
85280
- const st = (0, import_node_fs70.statSync)(real);
86003
+ const st = (0, import_node_fs71.statSync)(real);
85281
86004
  if (!st.isFile()) throw new RunSkillRelayError("skill resource is not a regular file");
85282
86005
  if (st.size > MAX_RESOURCE_BYTES) throw new RunSkillRelayError("skill resource is too large");
85283
- const bytes = (0, import_node_fs70.readFileSync)(real);
86006
+ const bytes = (0, import_node_fs71.readFileSync)(real);
85284
86007
  try {
85285
86008
  return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
85286
86009
  } catch {
@@ -85293,17 +86016,17 @@ function checkedDirectory(path, label2) {
85293
86016
  rejectLink3(path, label2);
85294
86017
  let real;
85295
86018
  try {
85296
- real = import_node_fs70.realpathSync.native(path);
86019
+ real = import_node_fs71.realpathSync.native(path);
85297
86020
  } catch {
85298
86021
  throw new RunSkillRelayError(`${label2} not found`);
85299
86022
  }
85300
- if (!(0, import_node_fs70.statSync)(real).isDirectory()) throw new RunSkillRelayError(`${label2} is not a directory`);
86023
+ if (!(0, import_node_fs71.statSync)(real).isDirectory()) throw new RunSkillRelayError(`${label2} is not a directory`);
85301
86024
  return real;
85302
86025
  }
85303
86026
  function rejectLink3(path, label2) {
85304
86027
  let st;
85305
86028
  try {
85306
- st = (0, import_node_fs70.lstatSync)(path);
86029
+ st = (0, import_node_fs71.lstatSync)(path);
85307
86030
  } catch {
85308
86031
  throw new RunSkillRelayError(`${label2} not found`);
85309
86032
  }
@@ -85354,7 +86077,7 @@ async function killTreeAndVerify(pid, procStartedAt) {
85354
86077
  }
85355
86078
  if (WIN3) {
85356
86079
  try {
85357
- (0, import_node_child_process15.execFileSync)("taskkill", ["/pid", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true, timeout: 1e4 });
86080
+ (0, import_node_child_process16.execFileSync)("taskkill", ["/pid", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true, timeout: 1e4 });
85358
86081
  } catch {
85359
86082
  }
85360
86083
  } else {
@@ -85521,14 +86244,14 @@ async function finish(deps, lease, patch2, options = {}) {
85521
86244
  var mcpDir = () => (0, import_node_path67.join)(process.env.FLOLESS_HOME ?? (0, import_node_path67.join)((0, import_node_os36.homedir)(), ".floless"), "run-mcp");
85522
86245
  var mcpPath = (leaseId) => (0, import_node_path67.join)(mcpDir(), `${leaseId}.json`);
85523
86246
  function writeMcpConfig(lease) {
85524
- (0, import_node_fs71.mkdirSync)(mcpDir(), { recursive: true });
86247
+ (0, import_node_fs72.mkdirSync)(mcpDir(), { recursive: true });
85525
86248
  const p = mcpPath(lease.leaseId);
85526
- (0, import_node_fs71.writeFileSync)(p, JSON.stringify(mcpConfigFor(lease.token, selfOrigin()), null, 2), { mode: 384 });
86249
+ (0, import_node_fs72.writeFileSync)(p, JSON.stringify(mcpConfigFor(lease.token, selfOrigin()), null, 2), { mode: 384 });
85527
86250
  return p;
85528
86251
  }
85529
86252
  function cleanupMcpConfig(leaseId) {
85530
86253
  try {
85531
- (0, import_node_fs71.rmSync)(mcpPath(leaseId));
86254
+ (0, import_node_fs72.rmSync)(mcpPath(leaseId));
85532
86255
  } catch {
85533
86256
  }
85534
86257
  }
@@ -85599,8 +86322,8 @@ function verifyRevisionSources(deps, lease) {
85599
86322
  req.sourceRefs.forEach((ref, index) => {
85600
86323
  const path = (deps.sourcePathFor ?? snapshotPathFor)(req.id, index);
85601
86324
  if (!path || ref.ext.toLowerCase() !== "pdf") throw new Error("the queued revision PDF set no longer matches this run");
85602
- const data = (0, import_node_fs71.readFileSync)(path);
85603
- if (data.length !== ref.bytes || (0, import_node_fs71.statSync)(path).size !== ref.bytes || (0, import_node_crypto40.createHash)("sha256").update(data).digest("hex") !== ref.sha256) {
86325
+ const data = (0, import_node_fs72.readFileSync)(path);
86326
+ if (data.length !== ref.bytes || (0, import_node_fs72.statSync)(path).size !== ref.bytes || (0, import_node_crypto40.createHash)("sha256").update(data).digest("hex") !== ref.sha256) {
85604
86327
  throw new Error("the queued PDF source changed after this run was claimed");
85605
86328
  }
85606
86329
  });
@@ -86120,7 +86843,7 @@ function start(deps, lease, plan) {
86120
86843
  function defaultSpawn(file, args, cwd, env2) {
86121
86844
  const batch = WIN3 && /\.(cmd|bat)$/i.test(file);
86122
86845
  const [exe2, argv] = batch ? ["cmd.exe", ["/c", file, ...args]] : [file, [...args]];
86123
- return (0, import_node_child_process14.spawn)(exe2, argv, {
86846
+ return (0, import_node_child_process15.spawn)(exe2, argv, {
86124
86847
  cwd,
86125
86848
  // `windowsHide` for the same reason `aware-adapter.ts` carries it: no console window flashes on
86126
86849
  // the user's desktop. Its cost is F4's — a login prompt would be drawn on a window that does not
@@ -86137,7 +86860,7 @@ function defaultRuntimeVersion(file, args) {
86137
86860
  const batch = WIN3 && /\.(cmd|bat)$/i.test(file);
86138
86861
  const exe2 = batch ? "cmd.exe" : file;
86139
86862
  const argv = batch ? ["/d", "/s", "/c", file, ...args] : [...args];
86140
- return (0, import_node_child_process15.execFileSync)(exe2, argv, { encoding: "utf8", windowsHide: true, timeout: 1e4 }).trim();
86863
+ return (0, import_node_child_process16.execFileSync)(exe2, argv, { encoding: "utf8", windowsHide: true, timeout: 1e4 }).trim();
86141
86864
  }
86142
86865
  var tail = (s) => (s.length > MAX_TAIL ? s.slice(-MAX_TAIL) : s).trim();
86143
86866
  async function settle(deps, lease, code, out, err2, sessionCaptureError = null) {
@@ -86474,16 +87197,16 @@ async function stopAllRuns(deps) {
86474
87197
  // watch.ts
86475
87198
  var import_node_os37 = require("node:os");
86476
87199
  var import_node_path69 = require("node:path");
86477
- var import_node_fs72 = require("node:fs");
87200
+ var import_node_fs73 = require("node:fs");
86478
87201
 
86479
87202
  // node_modules/chokidar/esm/index.js
86480
87203
  var import_fs2 = require("fs");
86481
- var import_promises10 = require("fs/promises");
87204
+ var import_promises11 = require("fs/promises");
86482
87205
  var import_events = require("events");
86483
87206
  var sysPath2 = __toESM(require("path"), 1);
86484
87207
 
86485
87208
  // node_modules/readdirp/esm/index.js
86486
- var import_promises8 = require("node:fs/promises");
87209
+ var import_promises9 = require("node:fs/promises");
86487
87210
  var import_node_stream4 = require("node:stream");
86488
87211
  var import_node_path68 = require("node:path");
86489
87212
  var EntryTypes = {
@@ -86524,7 +87247,7 @@ var FILE_TYPES = /* @__PURE__ */ new Set([
86524
87247
  var isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
86525
87248
  var wantBigintFsStats = process.platform === "win32";
86526
87249
  var emptyFn = (_entryInfo) => true;
86527
- var normalizeFilter2 = (filter) => {
87250
+ var normalizeFilter3 = (filter) => {
86528
87251
  if (filter === void 0)
86529
87252
  return emptyFn;
86530
87253
  if (typeof filter === "function")
@@ -86548,9 +87271,9 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
86548
87271
  });
86549
87272
  const opts = { ...defaultOptions, ...options };
86550
87273
  const { root: root6, type } = opts;
86551
- this._fileFilter = normalizeFilter2(opts.fileFilter);
86552
- this._directoryFilter = normalizeFilter2(opts.directoryFilter);
86553
- const statMethod = opts.lstat ? import_promises8.lstat : import_promises8.stat;
87274
+ this._fileFilter = normalizeFilter3(opts.fileFilter);
87275
+ this._directoryFilter = normalizeFilter3(opts.directoryFilter);
87276
+ const statMethod = opts.lstat ? import_promises9.lstat : import_promises9.stat;
86554
87277
  if (wantBigintFsStats) {
86555
87278
  this._stat = (path) => statMethod(path, { bigint: true });
86556
87279
  } else {
@@ -86621,7 +87344,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
86621
87344
  async _exploreDir(path, depth) {
86622
87345
  let files2;
86623
87346
  try {
86624
- files2 = await (0, import_promises8.readdir)(path, this._rdOptions);
87347
+ files2 = await (0, import_promises9.readdir)(path, this._rdOptions);
86625
87348
  } catch (error) {
86626
87349
  this._onError(error);
86627
87350
  }
@@ -86659,8 +87382,8 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
86659
87382
  if (stats && stats.isSymbolicLink()) {
86660
87383
  const full = entry2.fullPath;
86661
87384
  try {
86662
- const entryRealPath = await (0, import_promises8.realpath)(full);
86663
- const entryRealPathStats = await (0, import_promises8.lstat)(entryRealPath);
87385
+ const entryRealPath = await (0, import_promises9.realpath)(full);
87386
+ const entryRealPathStats = await (0, import_promises9.lstat)(entryRealPath);
86664
87387
  if (entryRealPathStats.isFile()) {
86665
87388
  return "file";
86666
87389
  }
@@ -86703,7 +87426,7 @@ function readdirp(root6, options = {}) {
86703
87426
 
86704
87427
  // node_modules/chokidar/esm/handler.js
86705
87428
  var import_fs = require("fs");
86706
- var import_promises9 = require("fs/promises");
87429
+ var import_promises10 = require("fs/promises");
86707
87430
  var sysPath = __toESM(require("path"), 1);
86708
87431
  var import_os = require("os");
86709
87432
  var STR_DATA = "data";
@@ -86730,7 +87453,7 @@ var EVENTS = {
86730
87453
  };
86731
87454
  var EV = EVENTS;
86732
87455
  var THROTTLE_MODE_WATCH = "watch";
86733
- var statMethods = { lstat: import_promises9.lstat, stat: import_promises9.stat };
87456
+ var statMethods = { lstat: import_promises10.lstat, stat: import_promises10.stat };
86734
87457
  var KEY_LISTENERS = "listeners";
86735
87458
  var KEY_ERR = "errHandlers";
86736
87459
  var KEY_RAW = "rawEmitters";
@@ -87087,7 +87810,7 @@ var setFsWatchListener = (path, fullPath, options, handlers) => {
87087
87810
  cont.watcherUnusable = true;
87088
87811
  if (isWindows && error.code === "EPERM") {
87089
87812
  try {
87090
- const fd2 = await (0, import_promises9.open)(path, "r");
87813
+ const fd2 = await (0, import_promises10.open)(path, "r");
87091
87814
  await fd2.close();
87092
87815
  broadcastErr(error);
87093
87816
  } catch (err2) {
@@ -87216,7 +87939,7 @@ var NodeFsHandler = class {
87216
87939
  return;
87217
87940
  if (!newStats || newStats.mtimeMs === 0) {
87218
87941
  try {
87219
- const newStats2 = await (0, import_promises9.stat)(file);
87942
+ const newStats2 = await (0, import_promises10.stat)(file);
87220
87943
  if (this.fsw.closed)
87221
87944
  return;
87222
87945
  const at = newStats2.atimeMs;
@@ -87271,7 +87994,7 @@ var NodeFsHandler = class {
87271
87994
  this.fsw._incrReadyCount();
87272
87995
  let linkPath;
87273
87996
  try {
87274
- linkPath = await (0, import_promises9.realpath)(path);
87997
+ linkPath = await (0, import_promises10.realpath)(path);
87275
87998
  } catch (e) {
87276
87999
  this.fsw._emitReady();
87277
88000
  return true;
@@ -87419,7 +88142,7 @@ var NodeFsHandler = class {
87419
88142
  let closer;
87420
88143
  if (stats.isDirectory()) {
87421
88144
  const absPath = sysPath.resolve(path);
87422
- const targetPath = follow ? await (0, import_promises9.realpath)(path) : path;
88145
+ const targetPath = follow ? await (0, import_promises10.realpath)(path) : path;
87423
88146
  if (this.fsw.closed)
87424
88147
  return;
87425
88148
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -87429,7 +88152,7 @@ var NodeFsHandler = class {
87429
88152
  this.fsw._symlinkPaths.set(absPath, targetPath);
87430
88153
  }
87431
88154
  } else if (stats.isSymbolicLink()) {
87432
- const targetPath = follow ? await (0, import_promises9.realpath)(path) : path;
88155
+ const targetPath = follow ? await (0, import_promises10.realpath)(path) : path;
87433
88156
  if (this.fsw.closed)
87434
88157
  return;
87435
88158
  const parent = sysPath.dirname(wh.watchPath);
@@ -87590,7 +88313,7 @@ var DirEntry = class {
87590
88313
  return;
87591
88314
  const dir = this.path;
87592
88315
  try {
87593
- await (0, import_promises10.readdir)(dir);
88316
+ await (0, import_promises11.readdir)(dir);
87594
88317
  } catch (err2) {
87595
88318
  if (this._removeWatcher) {
87596
88319
  this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
@@ -87915,7 +88638,7 @@ var FSWatcher = class extends import_events.EventEmitter {
87915
88638
  const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path) : path;
87916
88639
  let stats2;
87917
88640
  try {
87918
- stats2 = await (0, import_promises10.stat)(fullPath);
88641
+ stats2 = await (0, import_promises11.stat)(fullPath);
87919
88642
  } catch (err2) {
87920
88643
  }
87921
88644
  if (!stats2 || this.closed)
@@ -87958,12 +88681,12 @@ var FSWatcher = class extends import_events.EventEmitter {
87958
88681
  let timeoutObject;
87959
88682
  const clear = () => {
87960
88683
  const item = action.get(path);
87961
- const count = item ? item.count : 0;
88684
+ const count2 = item ? item.count : 0;
87962
88685
  action.delete(path);
87963
88686
  clearTimeout(timeoutObject);
87964
88687
  if (item)
87965
88688
  clearTimeout(item.timeoutObject);
87966
- return count;
88689
+ return count2;
87967
88690
  };
87968
88691
  timeoutObject = setTimeout(clear, timeout);
87969
88692
  const thr = { timeoutObject, clear, count: 0 };
@@ -88187,20 +88910,20 @@ function underDir(path, dir) {
88187
88910
  function startWatcher() {
88188
88911
  const awareDir = process.env.AWARE_HOME ?? (0, import_node_path69.join)((0, import_node_os37.homedir)(), ".aware");
88189
88912
  const credentialsDir = (0, import_node_path69.join)(awareDir, "credentials");
88190
- if (!(0, import_node_fs72.existsSync)(credentialsDir)) {
88913
+ if (!(0, import_node_fs73.existsSync)(credentialsDir)) {
88191
88914
  try {
88192
- (0, import_node_fs72.mkdirSync)(credentialsDir, { recursive: true });
88915
+ (0, import_node_fs73.mkdirSync)(credentialsDir, { recursive: true });
88193
88916
  } catch {
88194
88917
  }
88195
88918
  }
88196
- if (!(0, import_node_fs72.existsSync)(uiDir)) {
88919
+ if (!(0, import_node_fs73.existsSync)(uiDir)) {
88197
88920
  try {
88198
- (0, import_node_fs72.mkdirSync)(uiDir, { recursive: true });
88921
+ (0, import_node_fs73.mkdirSync)(uiDir, { recursive: true });
88199
88922
  } catch {
88200
88923
  }
88201
88924
  }
88202
- const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path69.join)(awareDir, d)).filter((p) => (0, import_node_fs72.existsSync)(p));
88203
- if ((0, import_node_fs72.existsSync)(uiDir)) targets.push(uiDir);
88925
+ const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path69.join)(awareDir, d)).filter((p) => (0, import_node_fs73.existsSync)(p));
88926
+ if ((0, import_node_fs73.existsSync)(uiDir)) targets.push(uiDir);
88204
88927
  if (targets.length === 0) {
88205
88928
  return null;
88206
88929
  }
@@ -88229,11 +88952,11 @@ function startWatcher() {
88229
88952
  const isCredential = path.split(/[\\/]/).includes("credentials");
88230
88953
  const kind = isCredential ? "credential" : path.endsWith(".jsonl") ? "trace" : path.endsWith(".lock") ? "lock" : path.endsWith(".flo") || path.endsWith(".app") ? "source" : "file";
88231
88954
  broadcast({ type: "fs-change", kind, event, path });
88232
- if (kind === "trace" && event !== "unlink" && (0, import_node_fs72.existsSync)(path)) {
88955
+ if (kind === "trace" && event !== "unlink" && (0, import_node_fs73.existsSync)(path)) {
88233
88956
  const id = appIdFromLogPath(path);
88234
88957
  if (!id) return;
88235
88958
  try {
88236
- broadcast({ type: "trace-file", id, runId: path.split(import_node_path69.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs72.readFileSync)(path, "utf8")) });
88959
+ broadcast({ type: "trace-file", id, runId: path.split(import_node_path69.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs73.readFileSync)(path, "utf8")) });
88237
88960
  } catch {
88238
88961
  }
88239
88962
  }
@@ -88244,7 +88967,7 @@ function startWatcher() {
88244
88967
  // index.ts
88245
88968
  var __dirname4 = (0, import_node_path70.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
88246
88969
  var WEB_ROOT = [(0, import_node_path70.join)(__dirname4, "web"), (0, import_node_path70.join)((0, import_node_path70.dirname)(process.execPath), "web"), (0, import_node_path70.join)(__dirname4, "..", "web")].find(
88247
- (p) => (0, import_node_fs73.existsSync)(p)
88970
+ (p) => (0, import_node_fs74.existsSync)(p)
88248
88971
  ) ?? (0, import_node_path70.join)(__dirname4, "..", "web");
88249
88972
  var PORT2 = Number(process.env.PORT ?? 4317);
88250
88973
  var HOST = "127.0.0.1";
@@ -88261,7 +88984,7 @@ function installCrashHandlers() {
88261
88984
  ${stack}
88262
88985
  `;
88263
88986
  try {
88264
- (0, import_node_fs73.appendFileSync)(logFilePath(), line);
88987
+ (0, import_node_fs74.appendFileSync)(logFilePath(), line);
88265
88988
  } catch {
88266
88989
  }
88267
88990
  if (process.stderr.isTTY) process.stderr.write(line);
@@ -88325,8 +89048,8 @@ async function startServer() {
88325
89048
  const MIN_AWARE = TEKLA_AWARE_FLOOR;
88326
89049
  const SHARE_3D_AWARE_FLOOR = "0.96.0";
88327
89050
  const isWin3 = process.platform === "win32";
88328
- const execFileAsync3 = (0, import_node_util6.promisify)(import_node_child_process16.execFile);
88329
- const lookUpOnPath = toolchainLookup(execFileAsync3, {
89051
+ const execFileAsync4 = (0, import_node_util7.promisify)(import_node_child_process17.execFile);
89052
+ const lookUpOnPath = toolchainLookup(execFileAsync4, {
88330
89053
  isWin: isWin3,
88331
89054
  onFailure: ({ cmd, attempt, outcome, err: err2 }) => {
88332
89055
  const e = err2;
@@ -88379,23 +89102,6 @@ async function startServer() {
88379
89102
  if (!child.pid) throw new Error("AWARE sidecar installer did not expose a child PID");
88380
89103
  await context.childStarted(await maintenanceChildIdentity(child.pid));
88381
89104
  }
88382
- function anyAwareInstallerTreeAlive() {
88383
- if (process.platform !== "win32") return false;
88384
- try {
88385
- const script = [
88386
- "$p=Get-CimInstance Win32_Process -ErrorAction Stop",
88387
- "$m=$p|Where-Object {$_.ProcessId -ne $PID -and $_.CommandLine -match '@aware-aeco/cli@|aware(?:\\.cmd)?\\s+sidecar\\s+install'}",
88388
- "if($m){Write-Output true}else{Write-Output false}"
88389
- ].join(";");
88390
- return (0, import_node_child_process16.execFileSync)("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
88391
- encoding: "utf8",
88392
- windowsHide: true,
88393
- timeout: 5e3
88394
- }).trim().toLowerCase() === "true";
88395
- } catch {
88396
- return true;
88397
- }
88398
- }
88399
89105
  const awareUpdateJobs = new AwareUpdateJobManager({
88400
89106
  resolveCurrentTarget: async () => {
88401
89107
  const marker = await awareMaintenance.read();
@@ -88534,7 +89240,7 @@ async function startServer() {
88534
89240
  maintenance: awareMaintenance,
88535
89241
  withRecoveryExclusive: (work) => withAwareExclusive(() => work(upgradeOwner())),
88536
89242
  matchingChildAlive: async (marker) => marker.child ? maintenanceChildMatches(marker.child) : false,
88537
- anyInstallerTreeAlive: async () => anyAwareInstallerTreeAlive(),
89243
+ anyInstallerTreeAlive: () => anyAwareInstallerTreeAlive(),
88538
89244
  repairAndVerify: repairInterruptedAwareMaintenance
88539
89245
  });
88540
89246
  }
@@ -88953,10 +89659,10 @@ async function startServer() {
88953
89659
  const bdir = backupDir(id, fromVersion, Date.now());
88954
89660
  let backedUp = false;
88955
89661
  try {
88956
- (0, import_node_fs73.mkdirSync)((0, import_node_path70.dirname)(bdir), { recursive: true });
88957
- (0, import_node_fs73.cpSync)(appDirPath2, bdir, { recursive: true });
89662
+ (0, import_node_fs74.mkdirSync)((0, import_node_path70.dirname)(bdir), { recursive: true });
89663
+ (0, import_node_fs74.cpSync)(appDirPath2, bdir, { recursive: true });
88958
89664
  backedUp = true;
88959
- (0, import_node_fs73.cpSync)(templatePath, srcPath);
89665
+ (0, import_node_fs74.cpSync)(templatePath, srcPath);
88960
89666
  if (id !== templateId) stampSourceAppId(srcPath, id);
88961
89667
  if (contract != null) {
88962
89668
  bakeContractIntoApp(srcPath, contract);
@@ -88971,8 +89677,8 @@ async function startServer() {
88971
89677
  throw new TemplateSwapError(`${verb} failed before any change was made (${msg}) \u2014 the workflow is untouched`, `${verb}-not-started`);
88972
89678
  }
88973
89679
  try {
88974
- (0, import_node_fs73.rmSync)(appDirPath2, { recursive: true, force: true });
88975
- (0, import_node_fs73.cpSync)(bdir, appDirPath2, { recursive: true });
89680
+ (0, import_node_fs74.rmSync)(appDirPath2, { recursive: true, force: true });
89681
+ (0, import_node_fs74.cpSync)(bdir, appDirPath2, { recursive: true });
88976
89682
  } catch (re) {
88977
89683
  const rmsg = re instanceof Error ? re.message : String(re);
88978
89684
  throw new TemplateSwapError(`${verb} failed (${msg}) AND rollback failed (${rmsg}) \u2014 restore manually from ${bdir}`, "rollback-failed", bdir);
@@ -88984,7 +89690,7 @@ async function startServer() {
88984
89690
  function readSwapContract(id, verb) {
88985
89691
  const gerund = verb === "update" ? "updating" : "restoring";
88986
89692
  const contract = readAcceptedForRequest(id, void 0);
88987
- if (contract == null && (0, import_node_fs73.existsSync)(contractPath(id))) {
89693
+ if (contract == null && (0, import_node_fs74.existsSync)(contractPath(id))) {
88988
89694
  return { ok: false, body: { ok: false, error: `"${id}"'s saved data is unreadable \u2014 open it in the editor and re-save before ${gerund}`, code: "contract-corrupt" } };
88989
89695
  }
88990
89696
  if (contract != null && !validateContract(contract).valid) {
@@ -89342,7 +90048,7 @@ async function startServer() {
89342
90048
  }
89343
90049
  let data;
89344
90050
  try {
89345
- data = (0, import_node_fs73.readFileSync)(thumb.path);
90051
+ data = (0, import_node_fs74.readFileSync)(thumb.path);
89346
90052
  } catch {
89347
90053
  return reply.status(404).send({ ok: false, error: "no thumbnail" });
89348
90054
  }
@@ -89869,8 +90575,8 @@ async function startServer() {
89869
90575
  if (bad) return reply.status(404).send({ ok: false, error: bad });
89870
90576
  const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
89871
90577
  const file = (0, import_node_path70.join)((0, import_node_path70.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
89872
- if (!(0, import_node_fs73.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
89873
- return reply.type("image/svg+xml").send((0, import_node_fs73.readFileSync)(file, "utf8"));
90578
+ if (!(0, import_node_fs74.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
90579
+ return reply.type("image/svg+xml").send((0, import_node_fs74.readFileSync)(file, "utf8"));
89874
90580
  }
89875
90581
  );
89876
90582
  app.put(
@@ -90411,7 +91117,7 @@ async function startServer() {
90411
91117
  }
90412
91118
  const statedAt = (filename) => {
90413
91119
  try {
90414
- const st = (0, import_node_fs73.statSync)((0, import_node_path70.join)(dir, filename));
91120
+ const st = (0, import_node_fs74.statSync)((0, import_node_path70.join)(dir, filename));
90415
91121
  return st.isFile() ? st.mtime.toISOString() : null;
90416
91122
  } catch {
90417
91123
  return null;
@@ -90584,10 +91290,10 @@ async function startServer() {
90584
91290
  scene,
90585
91291
  "output-path": tempPath
90586
91292
  });
90587
- if (!(0, import_node_fs73.existsSync)(tempPath) || (0, import_node_fs73.statSync)(tempPath).size === 0) {
91293
+ if (!(0, import_node_fs74.existsSync)(tempPath) || (0, import_node_fs74.statSync)(tempPath).size === 0) {
90588
91294
  throw new ReceiptReconciliationError("AWARE reported a successful export but wrote no IFC file.");
90589
91295
  }
90590
- const artifactBytes = (0, import_node_fs73.readFileSync)(tempPath);
91296
+ const artifactBytes = (0, import_node_fs74.readFileSync)(tempPath);
90591
91297
  const receipt = reconcileIfcExportReceipt(scene, rawReceipt, producerUnsupported, {
90592
91298
  index: parseStepData(artifactBytes),
90593
91299
  bytes: artifactBytes
@@ -90643,7 +91349,7 @@ async function startServer() {
90643
91349
  ok: false,
90644
91350
  error: awareFailureMessage(error, "IFC export failed"),
90645
91351
  ...reason ? { reason } : {},
90646
- preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs73.existsSync)(finalPath)
91352
+ preservedPrevious: project && priorProjectIfc ? receiptHasFile(project, priorProjectIfc) : (0, import_node_fs74.existsSync)(finalPath)
90647
91353
  });
90648
91354
  } finally {
90649
91355
  cleanupIfcTemp(tempPath);
@@ -90690,10 +91396,10 @@ async function startServer() {
90690
91396
  const receipt = wanted ? stills.find((row) => row.variant === wanted) : [...stills].sort((a, b) => b.exportedAt.localeCompare(a.exportedAt))[0];
90691
91397
  if (!receipt) return reply.status(404).send({ ok: false, error: "nothing rendered yet" });
90692
91398
  const path = resolveProjectExportReceiptPath(project, receipt);
90693
- if (!path || !(0, import_node_fs73.existsSync)(path)) {
91399
+ if (!path || !(0, import_node_fs74.existsSync)(path)) {
90694
91400
  return reply.status(404).send({ ok: false, error: "the rendered image is no longer on disk" });
90695
91401
  }
90696
- return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs73.readFileSync)(path));
91402
+ return reply.header("content-type", "image/png").header("cache-control", "private, max-age=31536000, immutable").send((0, import_node_fs74.readFileSync)(path));
90697
91403
  });
90698
91404
  const RENDER_VIEWPOINTS = /* @__PURE__ */ new Set(["hero", "iso", "front", "back", "left", "right", "top"]);
90699
91405
  app.post("/api/contract/:appId/render", async (req, reply) => {
@@ -90754,7 +91460,7 @@ async function startServer() {
90754
91460
  }
90755
91461
  const kind = output === "turntable" ? "render-mp4" : "render-png";
90756
91462
  const extension = output === "turntable" ? ".mp4" : ".png";
90757
- const scratch = (0, import_node_fs73.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-render-"));
91463
+ const scratch = (0, import_node_fs74.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-render-"));
90758
91464
  const ifcPath = (0, import_node_path70.join)(scratch, "model.ifc");
90759
91465
  const rendered = [];
90760
91466
  const progress = (stage, extra = {}) => {
@@ -90766,7 +91472,7 @@ async function startServer() {
90766
91472
  try {
90767
91473
  progress("preparing");
90768
91474
  await aware.agentInvoke("ifc", "write", { scene: built.scene, "output-path": ifcPath });
90769
- if (!(0, import_node_fs73.existsSync)(ifcPath) || (0, import_node_fs73.statSync)(ifcPath).size === 0) {
91475
+ if (!(0, import_node_fs74.existsSync)(ifcPath) || (0, import_node_fs74.statSync)(ifcPath).size === 0) {
90770
91476
  throw new Error("AWARE reported a successful IFC write but produced no file to render");
90771
91477
  }
90772
91478
  const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
@@ -90784,10 +91490,10 @@ async function startServer() {
90784
91490
  environment: "studio",
90785
91491
  ...output === "turntable" ? { "duration-seconds": 12, fps: 24, "width-pixels": 1280, "height-pixels": 720 } : { quality, "width-pixels": 1920, "height-pixels": 1080 }
90786
91492
  }, { timeoutMs: renderBudgetMs });
90787
- if (!(0, import_node_fs73.existsSync)(artifactPath) || (0, import_node_fs73.statSync)(artifactPath).size === 0) {
91493
+ if (!(0, import_node_fs74.existsSync)(artifactPath) || (0, import_node_fs74.statSync)(artifactPath).size === 0) {
90788
91494
  throw new Error(`the ${viewpoint} render reported success but produced no image`);
90789
91495
  }
90790
- const bytes = (0, import_node_fs73.readFileSync)(artifactPath);
91496
+ const bytes = (0, import_node_fs74.readFileSync)(artifactPath);
90791
91497
  const sourceSuffix = "source" in projectSnapshot && projectSnapshot.source ? `-${projectSnapshot.source.filenameLabel.replace(/[^A-Za-z0-9._-]+/g, "-")}` : "";
90792
91498
  const preferred = `${exportFileBase(project, appId)}-${viewpoint}${sourceSuffix}${extension}`;
90793
91499
  const filename = uniqueProjectExportFilename(project, preferred);
@@ -90843,7 +91549,7 @@ async function startServer() {
90843
91549
  rendered
90844
91550
  });
90845
91551
  } finally {
90846
- (0, import_node_fs73.rmSync)(scratch, { recursive: true, force: true });
91552
+ (0, import_node_fs74.rmSync)(scratch, { recursive: true, force: true });
90847
91553
  }
90848
91554
  }, {
90849
91555
  // What anyone blocked on this project is told, and for how long to expect it. Erring long
@@ -91084,14 +91790,14 @@ async function startServer() {
91084
91790
  const outPath = project ? (0, import_node_path70.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
91085
91791
  const dir = (0, import_node_path70.dirname)(outPath);
91086
91792
  try {
91087
- (0, import_node_fs73.mkdirSync)(dir, { recursive: true });
91793
+ (0, import_node_fs74.mkdirSync)(dir, { recursive: true });
91088
91794
  const kind = BOM_EXPORT_KIND[format];
91089
- let text4 = null;
91795
+ let text5 = null;
91090
91796
  let buf;
91091
91797
  if (format === "xlsx") {
91092
91798
  buf = await bomToXlsx(bom, columns);
91093
91799
  } else {
91094
- text4 = format === "csv" ? bomToCsv(bom, columns) : await withLifecycleLock(
91800
+ text5 = format === "csv" ? bomToCsv(bom, columns) : await withLifecycleLock(
91095
91801
  "app",
91096
91802
  bomReportCompanionId(appId),
91097
91803
  () => renderBomReport(appId, {
@@ -91100,23 +91806,23 @@ async function startServer() {
91100
91806
  }),
91101
91807
  { label: "rendering the bill of materials report" }
91102
91808
  );
91103
- buf = Buffer.from(text4, "utf8");
91809
+ buf = Buffer.from(text5, "utf8");
91104
91810
  }
91105
91811
  if (project && projectSnapshot) {
91106
91812
  publishProjectExportArtifact(project, {
91107
91813
  kind,
91108
91814
  filename,
91109
- encoding: text4 != null ? "utf8" : "base64",
91815
+ encoding: text5 != null ? "utf8" : "base64",
91110
91816
  bytes: buf.length,
91111
91817
  version: projectSnapshot.version.n,
91112
91818
  sourceKind: projectSnapshot.source?.kind ?? "approved",
91113
91819
  contractHash: projectSnapshot.contractHash
91114
91820
  }, buf);
91115
- } else if (text4 != null) (0, import_node_fs73.writeFileSync)(outPath, text4, "utf8");
91116
- else (0, import_node_fs73.writeFileSync)(outPath, buf);
91821
+ } else if (text5 != null) (0, import_node_fs74.writeFileSync)(outPath, text5, "utf8");
91822
+ else (0, import_node_fs74.writeFileSync)(outPath, buf);
91117
91823
  return {
91118
91824
  ok: true,
91119
- payload: text4 != null ? { filename, encoding: "utf8", content: text4, bytes: buf.length, savedTo: outPath } : { filename, encoding: "base64", content: buf.toString("base64"), bytes: buf.length, savedTo: outPath }
91825
+ payload: text5 != null ? { filename, encoding: "utf8", content: text5, bytes: buf.length, savedTo: outPath } : { filename, encoding: "base64", content: buf.toString("base64"), bytes: buf.length, savedTo: outPath }
91120
91826
  };
91121
91827
  } catch (e) {
91122
91828
  if (e instanceof BomReportError) {
@@ -91153,7 +91859,7 @@ async function startServer() {
91153
91859
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
91154
91860
  const outPath = project ? (0, import_node_path70.join)(projectExportsDir(project), filename) : (0, import_node_path70.join)(appPath(appId), filename);
91155
91861
  try {
91156
- (0, import_node_fs73.mkdirSync)((0, import_node_path70.dirname)(outPath), { recursive: true });
91862
+ (0, import_node_fs74.mkdirSync)((0, import_node_path70.dirname)(outPath), { recursive: true });
91157
91863
  if (project && projectSnapshot) {
91158
91864
  publishProjectExportArtifact(project, {
91159
91865
  kind: "svg",
@@ -91164,7 +91870,7 @@ async function startServer() {
91164
91870
  sourceKind: projectSnapshot.source?.kind ?? "approved",
91165
91871
  contractHash: projectSnapshot.contractHash
91166
91872
  }, Buffer.from(svg, "utf8"));
91167
- } else (0, import_node_fs73.writeFileSync)(outPath, svg, "utf8");
91873
+ } else (0, import_node_fs74.writeFileSync)(outPath, svg, "utf8");
91168
91874
  return { ok: true, filename, encoding: "utf8", content: svg, bytes: Buffer.byteLength(svg), savedTo: outPath };
91169
91875
  } catch (e) {
91170
91876
  app.log.error({ appId, err: e instanceof Error ? e.message : e }, "export-svg: write failed");
@@ -91357,11 +92063,11 @@ async function startServer() {
91357
92063
  id
91358
92064
  });
91359
92065
  }
91360
- const stageRoot = (0, import_node_fs73.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-import-"));
92066
+ const stageRoot = (0, import_node_fs74.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-import-"));
91361
92067
  try {
91362
92068
  const stageDir = (0, import_node_path70.join)(stageRoot, id);
91363
- (0, import_node_fs73.mkdirSync)(stageDir);
91364
- (0, import_node_fs73.writeFileSync)((0, import_node_path70.join)(stageDir, `${id}.flo`), content);
92069
+ (0, import_node_fs74.mkdirSync)(stageDir);
92070
+ (0, import_node_fs74.writeFileSync)((0, import_node_path70.join)(stageDir, `${id}.flo`), content);
91365
92071
  await aware.install(stageDir);
91366
92072
  } catch (err2) {
91367
92073
  try {
@@ -91372,7 +92078,7 @@ async function startServer() {
91372
92078
  const reason = awareStderr(err2);
91373
92079
  return reply.status(502).send({ ok: false, error: `import failed: ${msg}`, code: "install-failed", reason, agentsUnavailable: unavailableAgents(reason) });
91374
92080
  } finally {
91375
- (0, import_node_fs73.rmSync)(stageRoot, { recursive: true, force: true });
92081
+ (0, import_node_fs74.rmSync)(stageRoot, { recursive: true, force: true });
91376
92082
  }
91377
92083
  broadcast({ type: "apps-changed", id });
91378
92084
  return { ok: true, id };
@@ -91388,13 +92094,13 @@ async function startServer() {
91388
92094
  }
91389
92095
  const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
91390
92096
  const baked = bakeFloSource(appData.source.text, inputs);
91391
- const tmpRoot = (0, import_node_fs73.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-bake-"));
92097
+ const tmpRoot = (0, import_node_fs74.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-bake-"));
91392
92098
  const backupDir2 = (0, import_node_path70.join)(tmpRoot, `${id}-backup`);
91393
92099
  const bakeDir = (0, import_node_path70.join)(tmpRoot, id);
91394
- (0, import_node_fs73.cpSync)(appDir(id), backupDir2, { recursive: true });
91395
- (0, import_node_fs73.cpSync)(appDir(id), bakeDir, { recursive: true });
92100
+ (0, import_node_fs74.cpSync)(appDir(id), backupDir2, { recursive: true });
92101
+ (0, import_node_fs74.cpSync)(appDir(id), bakeDir, { recursive: true });
91396
92102
  const floName = appData.source.path.split(/[\\/]/).pop();
91397
- (0, import_node_fs73.writeFileSync)((0, import_node_path70.join)(bakeDir, floName), baked);
92103
+ (0, import_node_fs74.writeFileSync)((0, import_node_path70.join)(bakeDir, floName), baked);
91398
92104
  let appInstalled2 = true;
91399
92105
  try {
91400
92106
  await aware.uninstall(id);
@@ -91423,7 +92129,7 @@ async function startServer() {
91423
92129
  broadcast({ type: "baked", id });
91424
92130
  return { ok: true, id, agent: id, inputs };
91425
92131
  } finally {
91426
- if (appInstalled2) (0, import_node_fs73.rmSync)(tmpRoot, { recursive: true, force: true });
92132
+ if (appInstalled2) (0, import_node_fs74.rmSync)(tmpRoot, { recursive: true, force: true });
91427
92133
  }
91428
92134
  });
91429
92135
  });
@@ -91444,7 +92150,7 @@ async function startServer() {
91444
92150
  if (!sourceKind || !sourceRef) {
91445
92151
  return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
91446
92152
  }
91447
- const tempHome = (0, import_node_fs73.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-graft-"));
92153
+ const tempHome = (0, import_node_fs74.mkdtempSync)((0, import_node_path70.join)((0, import_node_os38.tmpdir)(), "floless-graft-"));
91448
92154
  let result;
91449
92155
  try {
91450
92156
  result = await aware.build({
@@ -91457,19 +92163,19 @@ async function startServer() {
91457
92163
  awareHome: tempHome
91458
92164
  });
91459
92165
  } catch (err2) {
91460
- (0, import_node_fs73.rmSync)(tempHome, { recursive: true, force: true });
92166
+ (0, import_node_fs74.rmSync)(tempHome, { recursive: true, force: true });
91461
92167
  const msg = err2 instanceof AwareError ? err2.message : String(err2?.message ?? err2);
91462
92168
  return reply.status(422).send({ ok: false, error: msg });
91463
92169
  }
91464
92170
  const manifest = readStagedManifest(result.agentDir);
91465
92171
  if (!manifest) {
91466
- (0, import_node_fs73.rmSync)(tempHome, { recursive: true, force: true });
92172
+ (0, import_node_fs74.rmSync)(tempHome, { recursive: true, force: true });
91467
92173
  return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
91468
92174
  }
91469
92175
  const token2 = (0, import_node_crypto41.randomUUID)();
91470
92176
  registerStage(token2, tempHome, result.agentId);
91471
92177
  const preview2 = buildPreview(manifest, sourceKind, sourceRef, token2);
91472
- if ((0, import_node_fs73.existsSync)((0, import_node_path70.join)(graftAgentsDir(), result.agentId))) {
92178
+ if ((0, import_node_fs74.existsSync)((0, import_node_path70.join)(graftAgentsDir(), result.agentId))) {
91473
92179
  preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
91474
92180
  }
91475
92181
  return { ok: true, preview: preview2 };
@@ -91488,7 +92194,7 @@ async function startServer() {
91488
92194
  registerStage(stagedRef, stage.tempDir, stage.agentId);
91489
92195
  return reply.status(409).send({ ok: false, error: err2.message, agentId: stage.agentId, collision: true });
91490
92196
  }
91491
- (0, import_node_fs73.rmSync)(stage.tempDir, { recursive: true, force: true });
92197
+ (0, import_node_fs74.rmSync)(stage.tempDir, { recursive: true, force: true });
91492
92198
  throw err2;
91493
92199
  }
91494
92200
  broadcast({ type: "grafted", id: stage.agentId });
@@ -91784,11 +92490,11 @@ async function startServer() {
91784
92490
  app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
91785
92491
  const n = Number.parseInt(req.params.n, 10);
91786
92492
  const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
91787
- if (!p || !(0, import_node_fs73.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
92493
+ if (!p || !(0, import_node_fs74.existsSync)(p)) return reply.status(404).send({ ok: false, error: "snapshot not found" });
91788
92494
  const ext = p.split(".").pop().toLowerCase();
91789
92495
  reply.header("Content-Type", ext === "png" ? "image/png" : ext === "webp" ? "image/webp" : ext === "pdf" ? "application/pdf" : "image/jpeg");
91790
92496
  reply.header("Cache-Control", "no-store");
91791
- return (0, import_node_fs73.readFileSync)(p);
92497
+ return (0, import_node_fs74.readFileSync)(p);
91792
92498
  });
91793
92499
  app.post(
91794
92500
  "/api/tweak",
@@ -91853,7 +92559,7 @@ async function startServer() {
91853
92559
  registerReferenceRoutes(app, {
91854
92560
  getProject,
91855
92561
  broadcast,
91856
- reader: { probe: probeReference, readModel: readReferenceModel },
92562
+ reader: { probe: probeReference, readModel: readReferenceModel, compare: compareReferences },
91857
92563
  runControl: { newTicket: newRunTicket, cancel: cancelRun }
91858
92564
  });
91859
92565
  const CONN_APPID = /^[a-z0-9][a-z0-9._-]*$/i;
@@ -92049,7 +92755,7 @@ ${v.prompt}` : "";
92049
92755
  warn(`last-run-status:${ref} \u2014 trace exists but couldn't be parsed (corrupt/truncated)`);
92050
92756
  let finishedAt2 = null;
92051
92757
  try {
92052
- finishedAt2 = (0, import_node_fs73.statSync)(latest.path).mtime.toISOString();
92758
+ finishedAt2 = (0, import_node_fs74.statSync)(latest.path).mtime.toISOString();
92053
92759
  } catch {
92054
92760
  finishedAt2 = null;
92055
92761
  }
@@ -92059,7 +92765,7 @@ ${v.prompt}` : "";
92059
92765
  let finishedAt = typeof runEnd?.ts === "string" ? runEnd.ts : null;
92060
92766
  if (!finishedAt) {
92061
92767
  try {
92062
- finishedAt = (0, import_node_fs73.statSync)(latest.path).mtime.toISOString();
92768
+ finishedAt = (0, import_node_fs74.statSync)(latest.path).mtime.toISOString();
92063
92769
  } catch {
92064
92770
  finishedAt = null;
92065
92771
  }
@@ -92222,10 +92928,10 @@ ${v.prompt}` : "";
92222
92928
  }
92223
92929
 
92224
92930
  // protocol.ts
92225
- var import_node_child_process17 = require("node:child_process");
92931
+ var import_node_child_process18 = require("node:child_process");
92226
92932
  var BASE = PROTOCOL_KEY;
92227
92933
  function reg(args) {
92228
- (0, import_node_child_process17.execFileSync)("reg", args, { stdio: "ignore", windowsHide: true });
92934
+ (0, import_node_child_process18.execFileSync)("reg", args, { stdio: "ignore", windowsHide: true });
92229
92935
  }
92230
92936
  function registerProtocol(exePath) {
92231
92937
  if (process.platform !== "win32") return;
@@ -92265,13 +92971,13 @@ async function removeAwarePerDecision(removeAwareFlag, prompt) {
92265
92971
  );
92266
92972
  const shell = process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : "/bin/sh";
92267
92973
  try {
92268
- (0, import_node_child_process18.execSync)("npm uninstall -g @aware-aeco/cli", { stdio: "inherit", shell });
92974
+ (0, import_node_child_process19.execSync)("npm uninstall -g @aware-aeco/cli", { stdio: "inherit", shell });
92269
92975
  } catch {
92270
92976
  process.stdout.write('floless: warning: "npm uninstall -g @aware-aeco/cli" failed \u2014 see the output above.\n');
92271
92977
  }
92272
92978
  let lsJson = "";
92273
92979
  try {
92274
- lsJson = (0, import_node_child_process18.execSync)("npm ls -g @aware-aeco/cli --depth=0 --json", {
92980
+ lsJson = (0, import_node_child_process19.execSync)("npm ls -g @aware-aeco/cli --depth=0 --json", {
92275
92981
  encoding: "utf8",
92276
92982
  stdio: ["ignore", "pipe", "ignore"],
92277
92983
  shell