@floless/app 0.113.2 → 0.113.4

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.
@@ -4752,7 +4752,7 @@ var require_sonic_boom = __commonJS({
4752
4752
  if (!(this instanceof SonicBoom)) {
4753
4753
  return new SonicBoom(opts);
4754
4754
  }
4755
- let { fd: fd2, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {};
4755
+ let { fd: fd2, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir: mkdir2, retryEAGAIN, fsync, contentMode, mode } = opts || {};
4756
4756
  fd2 = fd2 || dest;
4757
4757
  this._len = 0;
4758
4758
  this.fd = -1;
@@ -4777,7 +4777,7 @@ var require_sonic_boom = __commonJS({
4777
4777
  this.append = append || false;
4778
4778
  this.mode = mode;
4779
4779
  this.retryEAGAIN = retryEAGAIN || (() => true);
4780
- this.mkdir = mkdir || false;
4780
+ this.mkdir = mkdir2 || false;
4781
4781
  let fsWriteSync;
4782
4782
  let fsWrite;
4783
4783
  if (contentMode === kContentModeBuffer) {
@@ -5425,8 +5425,8 @@ var require_wait = __commonJS({
5425
5425
  done(null, "timed-out");
5426
5426
  return;
5427
5427
  }
5428
- const remaining = max2 === Infinity ? WAIT_MS2 : Math.min(WAIT_MS2, Math.max(1, max2 - Date.now()));
5429
- const result = Atomics.waitAsync(state2, index, current, remaining);
5428
+ const remaining2 = max2 === Infinity ? WAIT_MS2 : Math.min(WAIT_MS2, Math.max(1, max2 - Date.now()));
5429
+ const result = Atomics.waitAsync(state2, index, current, remaining2);
5430
5430
  if (result.async) {
5431
5431
  result.value.then(check);
5432
5432
  } else {
@@ -5447,8 +5447,8 @@ var require_wait = __commonJS({
5447
5447
  done(null, "timed-out");
5448
5448
  return;
5449
5449
  }
5450
- const remaining = max2 === Infinity ? WAIT_MS2 : Math.min(WAIT_MS2, Math.max(1, max2 - Date.now()));
5451
- const result = Atomics.waitAsync(state2, index, expected, remaining);
5450
+ const remaining2 = max2 === Infinity ? WAIT_MS2 : Math.min(WAIT_MS2, Math.max(1, max2 - Date.now()));
5451
+ const result = Atomics.waitAsync(state2, index, expected, remaining2);
5452
5452
  if (result.async) {
5453
5453
  result.value.then((res) => {
5454
5454
  if (res === "ok") {
@@ -5489,7 +5489,7 @@ var require_thread_stream = __commonJS({
5489
5489
  var { version } = require_package();
5490
5490
  var { EventEmitter: EventEmitter2 } = require("events");
5491
5491
  var { Worker: Worker2 } = require("worker_threads");
5492
- var { join: join45 } = require("path");
5492
+ var { join: join46 } = require("path");
5493
5493
  var { pathToFileURL } = require("url");
5494
5494
  var { wait } = require_wait();
5495
5495
  var {
@@ -5540,7 +5540,7 @@ var require_thread_stream = __commonJS({
5540
5540
  function createWorker(stream, opts) {
5541
5541
  const { filename, workerData } = opts;
5542
5542
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
5543
- const toExecute = bundlerOverrides["thread-stream-worker"] || join45(__dirname, "lib", "worker.js");
5543
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join46(__dirname, "lib", "worker.js");
5544
5544
  const worker = new Worker2(toExecute, {
5545
5545
  ...opts.workerOpts,
5546
5546
  name: opts.workerOpts?.name || "thread-stream",
@@ -5891,14 +5891,14 @@ var require_thread_stream = __commonJS({
5891
5891
  function write(stream, maxBytes, cb) {
5892
5892
  const current = Atomics.load(stream[kImpl].state, WRITE_INDEX);
5893
5893
  let offset = current;
5894
- let remaining = maxBytes;
5895
- while (remaining > 0 && stream[kImpl].bufLen !== 0) {
5894
+ let remaining2 = maxBytes;
5895
+ while (remaining2 > 0 && stream[kImpl].bufLen !== 0) {
5896
5896
  const head = stream[kImpl].bufHead;
5897
5897
  const buf = stream[kImpl].buf[head];
5898
- if (buf.length <= remaining) {
5898
+ if (buf.length <= remaining2) {
5899
5899
  buf.copy(stream[kImpl].data, offset);
5900
5900
  offset += buf.length;
5901
- remaining -= buf.length;
5901
+ remaining2 -= buf.length;
5902
5902
  stream[kImpl].bufLen -= buf.length;
5903
5903
  stream[kImpl].bufHead = head + 1;
5904
5904
  if (stream[kImpl].bufHead === stream[kImpl].buf.length) {
@@ -5910,11 +5910,11 @@ var require_thread_stream = __commonJS({
5910
5910
  }
5911
5911
  continue;
5912
5912
  }
5913
- buf.copy(stream[kImpl].data, offset, 0, remaining);
5914
- stream[kImpl].buf[head] = buf.subarray(remaining);
5915
- stream[kImpl].bufLen -= remaining;
5916
- offset += remaining;
5917
- remaining = 0;
5913
+ buf.copy(stream[kImpl].data, offset, 0, remaining2);
5914
+ stream[kImpl].buf[head] = buf.subarray(remaining2);
5915
+ stream[kImpl].bufLen -= remaining2;
5916
+ offset += remaining2;
5917
+ remaining2 = 0;
5918
5918
  }
5919
5919
  updateState(stream, () => {
5920
5920
  Atomics.store(stream[kImpl].state, WRITE_INDEX, offset);
@@ -6008,7 +6008,7 @@ var require_transport = __commonJS({
6008
6008
  var { createRequire: createRequire5 } = require("module");
6009
6009
  var { existsSync: existsSync41 } = require("node:fs");
6010
6010
  var getCallers = require_caller();
6011
- var { join: join45, isAbsolute: isAbsolute2, sep: sep6 } = require("node:path");
6011
+ var { join: join46, isAbsolute: isAbsolute3, sep: sep6 } = require("node:path");
6012
6012
  var { fileURLToPath: fileURLToPath6 } = require("node:url");
6013
6013
  var sleep2 = require_atomic_sleep();
6014
6014
  var onExit = require_on_exit_leak_free();
@@ -6080,7 +6080,7 @@ var require_transport = __commonJS({
6080
6080
  return false;
6081
6081
  }
6082
6082
  }
6083
- return isAbsolute2(path) && !existsSync41(path);
6083
+ return isAbsolute3(path) && !existsSync41(path);
6084
6084
  }
6085
6085
  function stripQuotes(value) {
6086
6086
  const first = value[0];
@@ -6161,7 +6161,7 @@ var require_transport = __commonJS({
6161
6161
  throw new Error("only one of target or targets can be specified");
6162
6162
  }
6163
6163
  if (targets) {
6164
- target = bundlerOverrides["pino-worker"] || join45(__dirname, "worker.js");
6164
+ target = bundlerOverrides["pino-worker"] || join46(__dirname, "worker.js");
6165
6165
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
6166
6166
  return {
6167
6167
  ...dest,
@@ -6179,7 +6179,7 @@ var require_transport = __commonJS({
6179
6179
  });
6180
6180
  });
6181
6181
  } else if (pipeline2) {
6182
- target = bundlerOverrides["pino-worker"] || join45(__dirname, "worker.js");
6182
+ target = bundlerOverrides["pino-worker"] || join46(__dirname, "worker.js");
6183
6183
  options.pipelines = [pipeline2.map((dest) => {
6184
6184
  return {
6185
6185
  ...dest,
@@ -6198,11 +6198,11 @@ var require_transport = __commonJS({
6198
6198
  return buildStream(fixTarget(target), options, worker, sync, name);
6199
6199
  function fixTarget(origin) {
6200
6200
  origin = bundlerOverrides[origin] || origin;
6201
- if (isAbsolute2(origin) || origin.indexOf("file://") === 0) {
6201
+ if (isAbsolute3(origin) || origin.indexOf("file://") === 0) {
6202
6202
  return origin;
6203
6203
  }
6204
6204
  if (origin === "pino/file") {
6205
- return join45(__dirname, "..", "file.js");
6205
+ return join46(__dirname, "..", "file.js");
6206
6206
  }
6207
6207
  let fixTarget2;
6208
6208
  for (const filePath of callers) {
@@ -7182,7 +7182,7 @@ var require_safe_stable_stringify = __commonJS({
7182
7182
  return circularValue;
7183
7183
  }
7184
7184
  let res = "";
7185
- let join45 = ",";
7185
+ let join46 = ",";
7186
7186
  const originalIndentation = indentation;
7187
7187
  if (Array.isArray(value)) {
7188
7188
  if (value.length === 0) {
@@ -7196,7 +7196,7 @@ var require_safe_stable_stringify = __commonJS({
7196
7196
  indentation += spacer;
7197
7197
  res += `
7198
7198
  ${indentation}`;
7199
- join45 = `,
7199
+ join46 = `,
7200
7200
  ${indentation}`;
7201
7201
  }
7202
7202
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -7204,13 +7204,13 @@ ${indentation}`;
7204
7204
  for (; i < maximumValuesToStringify - 1; i++) {
7205
7205
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
7206
7206
  res += tmp2 !== void 0 ? tmp2 : "null";
7207
- res += join45;
7207
+ res += join46;
7208
7208
  }
7209
7209
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
7210
7210
  res += tmp !== void 0 ? tmp : "null";
7211
7211
  if (value.length - 1 > maximumBreadth) {
7212
7212
  const removedKeys = value.length - maximumBreadth - 1;
7213
- res += `${join45}"... ${getItemCount(removedKeys)} not stringified"`;
7213
+ res += `${join46}"... ${getItemCount(removedKeys)} not stringified"`;
7214
7214
  }
7215
7215
  if (spacer !== "") {
7216
7216
  res += `
@@ -7231,7 +7231,7 @@ ${originalIndentation}`;
7231
7231
  let separator = "";
7232
7232
  if (spacer !== "") {
7233
7233
  indentation += spacer;
7234
- join45 = `,
7234
+ join46 = `,
7235
7235
  ${indentation}`;
7236
7236
  whitespace = " ";
7237
7237
  }
@@ -7245,13 +7245,13 @@ ${indentation}`;
7245
7245
  const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
7246
7246
  if (tmp !== void 0) {
7247
7247
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
7248
- separator = join45;
7248
+ separator = join46;
7249
7249
  }
7250
7250
  }
7251
7251
  if (keyLength > maximumBreadth) {
7252
7252
  const removedKeys = keyLength - maximumBreadth;
7253
7253
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
7254
- separator = join45;
7254
+ separator = join46;
7255
7255
  }
7256
7256
  if (spacer !== "" && separator.length > 1) {
7257
7257
  res = `
@@ -7292,7 +7292,7 @@ ${originalIndentation}`;
7292
7292
  }
7293
7293
  const originalIndentation = indentation;
7294
7294
  let res = "";
7295
- let join45 = ",";
7295
+ let join46 = ",";
7296
7296
  if (Array.isArray(value)) {
7297
7297
  if (value.length === 0) {
7298
7298
  return "[]";
@@ -7305,7 +7305,7 @@ ${originalIndentation}`;
7305
7305
  indentation += spacer;
7306
7306
  res += `
7307
7307
  ${indentation}`;
7308
- join45 = `,
7308
+ join46 = `,
7309
7309
  ${indentation}`;
7310
7310
  }
7311
7311
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -7313,13 +7313,13 @@ ${indentation}`;
7313
7313
  for (; i < maximumValuesToStringify - 1; i++) {
7314
7314
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
7315
7315
  res += tmp2 !== void 0 ? tmp2 : "null";
7316
- res += join45;
7316
+ res += join46;
7317
7317
  }
7318
7318
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
7319
7319
  res += tmp !== void 0 ? tmp : "null";
7320
7320
  if (value.length - 1 > maximumBreadth) {
7321
7321
  const removedKeys = value.length - maximumBreadth - 1;
7322
- res += `${join45}"... ${getItemCount(removedKeys)} not stringified"`;
7322
+ res += `${join46}"... ${getItemCount(removedKeys)} not stringified"`;
7323
7323
  }
7324
7324
  if (spacer !== "") {
7325
7325
  res += `
@@ -7332,7 +7332,7 @@ ${originalIndentation}`;
7332
7332
  let whitespace = "";
7333
7333
  if (spacer !== "") {
7334
7334
  indentation += spacer;
7335
- join45 = `,
7335
+ join46 = `,
7336
7336
  ${indentation}`;
7337
7337
  whitespace = " ";
7338
7338
  }
@@ -7341,7 +7341,7 @@ ${indentation}`;
7341
7341
  const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
7342
7342
  if (tmp !== void 0) {
7343
7343
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
7344
- separator = join45;
7344
+ separator = join46;
7345
7345
  }
7346
7346
  }
7347
7347
  if (spacer !== "" && separator.length > 1) {
@@ -7399,20 +7399,20 @@ ${originalIndentation}`;
7399
7399
  indentation += spacer;
7400
7400
  let res2 = `
7401
7401
  ${indentation}`;
7402
- const join46 = `,
7402
+ const join47 = `,
7403
7403
  ${indentation}`;
7404
7404
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
7405
7405
  let i = 0;
7406
7406
  for (; i < maximumValuesToStringify - 1; i++) {
7407
7407
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
7408
7408
  res2 += tmp2 !== void 0 ? tmp2 : "null";
7409
- res2 += join46;
7409
+ res2 += join47;
7410
7410
  }
7411
7411
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
7412
7412
  res2 += tmp !== void 0 ? tmp : "null";
7413
7413
  if (value.length - 1 > maximumBreadth) {
7414
7414
  const removedKeys = value.length - maximumBreadth - 1;
7415
- res2 += `${join46}"... ${getItemCount(removedKeys)} not stringified"`;
7415
+ res2 += `${join47}"... ${getItemCount(removedKeys)} not stringified"`;
7416
7416
  }
7417
7417
  res2 += `
7418
7418
  ${originalIndentation}`;
@@ -7428,16 +7428,16 @@ ${originalIndentation}`;
7428
7428
  return '"[Object]"';
7429
7429
  }
7430
7430
  indentation += spacer;
7431
- const join45 = `,
7431
+ const join46 = `,
7432
7432
  ${indentation}`;
7433
7433
  let res = "";
7434
7434
  let separator = "";
7435
7435
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
7436
7436
  if (isTypedArrayWithEntries(value)) {
7437
- res += stringifyTypedArray(value, join45, maximumBreadth);
7437
+ res += stringifyTypedArray(value, join46, maximumBreadth);
7438
7438
  keys = keys.slice(value.length);
7439
7439
  maximumPropertiesToStringify -= value.length;
7440
- separator = join45;
7440
+ separator = join46;
7441
7441
  }
7442
7442
  if (deterministic) {
7443
7443
  keys = sort(keys, comparator);
@@ -7448,13 +7448,13 @@ ${indentation}`;
7448
7448
  const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
7449
7449
  if (tmp !== void 0) {
7450
7450
  res += `${separator}${strEscape(key3)}: ${tmp}`;
7451
- separator = join45;
7451
+ separator = join46;
7452
7452
  }
7453
7453
  }
7454
7454
  if (keyLength > maximumBreadth) {
7455
7455
  const removedKeys = keyLength - maximumBreadth;
7456
7456
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
7457
- separator = join45;
7457
+ separator = join46;
7458
7458
  }
7459
7459
  if (separator !== "") {
7460
7460
  res = `
@@ -15973,49 +15973,49 @@ var require_fast_uri = __commonJS({
15973
15973
  schemelessOptions.skipEscape = true;
15974
15974
  return serialize(resolved, schemelessOptions);
15975
15975
  }
15976
- function resolveComponent(base, relative3, options, skipNormalization) {
15976
+ function resolveComponent(base, relative4, options, skipNormalization) {
15977
15977
  const target = {};
15978
15978
  if (!skipNormalization) {
15979
15979
  base = parse(serialize(base, options), options);
15980
- relative3 = parse(serialize(relative3, options), options);
15980
+ relative4 = parse(serialize(relative4, options), options);
15981
15981
  }
15982
15982
  options = options || {};
15983
- if (!options.tolerant && relative3.scheme) {
15984
- target.scheme = relative3.scheme;
15985
- target.userinfo = relative3.userinfo;
15986
- target.host = relative3.host;
15987
- target.port = relative3.port;
15988
- target.path = removeDotSegments(relative3.path || "");
15989
- target.query = relative3.query;
15983
+ if (!options.tolerant && relative4.scheme) {
15984
+ target.scheme = relative4.scheme;
15985
+ target.userinfo = relative4.userinfo;
15986
+ target.host = relative4.host;
15987
+ target.port = relative4.port;
15988
+ target.path = removeDotSegments(relative4.path || "");
15989
+ target.query = relative4.query;
15990
15990
  } else {
15991
- if (relative3.userinfo !== void 0 || relative3.host !== void 0 || relative3.port !== void 0) {
15992
- target.userinfo = relative3.userinfo;
15993
- target.host = relative3.host;
15994
- target.port = relative3.port;
15995
- target.path = removeDotSegments(relative3.path || "");
15996
- target.query = relative3.query;
15991
+ if (relative4.userinfo !== void 0 || relative4.host !== void 0 || relative4.port !== void 0) {
15992
+ target.userinfo = relative4.userinfo;
15993
+ target.host = relative4.host;
15994
+ target.port = relative4.port;
15995
+ target.path = removeDotSegments(relative4.path || "");
15996
+ target.query = relative4.query;
15997
15997
  } else {
15998
- if (!relative3.path) {
15998
+ if (!relative4.path) {
15999
15999
  target.path = base.path;
16000
- if (relative3.query !== void 0) {
16001
- target.query = relative3.query;
16000
+ if (relative4.query !== void 0) {
16001
+ target.query = relative4.query;
16002
16002
  } else {
16003
16003
  target.query = base.query;
16004
16004
  }
16005
16005
  } else {
16006
- if (relative3.path[0] === "/") {
16007
- target.path = removeDotSegments(relative3.path);
16006
+ if (relative4.path[0] === "/") {
16007
+ target.path = removeDotSegments(relative4.path);
16008
16008
  } else {
16009
16009
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
16010
- target.path = "/" + relative3.path;
16010
+ target.path = "/" + relative4.path;
16011
16011
  } else if (!base.path) {
16012
- target.path = relative3.path;
16012
+ target.path = relative4.path;
16013
16013
  } else {
16014
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative3.path;
16014
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative4.path;
16015
16015
  }
16016
16016
  target.path = removeDotSegments(target.path);
16017
16017
  }
16018
- target.query = relative3.query;
16018
+ target.query = relative4.query;
16019
16019
  }
16020
16020
  target.userinfo = base.userinfo;
16021
16021
  target.host = base.host;
@@ -16023,7 +16023,7 @@ var require_fast_uri = __commonJS({
16023
16023
  }
16024
16024
  target.scheme = base.scheme;
16025
16025
  }
16026
- target.fragment = relative3.fragment;
16026
+ target.fragment = relative4.fragment;
16027
16027
  return target;
16028
16028
  }
16029
16029
  function equal(uriA, uriB, options) {
@@ -32061,7 +32061,7 @@ var require_parse_url = __commonJS({
32061
32061
  var require_form_data = __commonJS({
32062
32062
  "node_modules/light-my-request/lib/form-data.js"(exports2, module2) {
32063
32063
  "use strict";
32064
- var { randomUUID: randomUUID15 } = require("node:crypto");
32064
+ var { randomUUID: randomUUID16 } = require("node:crypto");
32065
32065
  var { Readable: Readable3 } = require("node:stream");
32066
32066
  var textEncoder;
32067
32067
  function isFormDataLike(payload) {
@@ -32069,7 +32069,7 @@ var require_form_data = __commonJS({
32069
32069
  }
32070
32070
  function formDataToStream(formdata) {
32071
32071
  textEncoder = textEncoder ?? new TextEncoder();
32072
- const boundary = `----formdata-${randomUUID15()}`;
32072
+ const boundary = `----formdata-${randomUUID16()}`;
32073
32073
  const prefix = `--${boundary}\r
32074
32074
  Content-Disposition: form-data`;
32075
32075
  const escape2 = (str5) => str5.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
@@ -39881,10 +39881,10 @@ var require_ignore = __commonJS({
39881
39881
  ignored(p) {
39882
39882
  const fullpath = p.fullpath();
39883
39883
  const fullpaths = `${fullpath}/`;
39884
- const relative3 = p.relative() || ".";
39885
- const relatives = `${relative3}/`;
39884
+ const relative4 = p.relative() || ".";
39885
+ const relatives = `${relative4}/`;
39886
39886
  for (const m of this.relative) {
39887
- if (m.match(relative3) || m.match(relatives))
39887
+ if (m.match(relative4) || m.match(relatives))
39888
39888
  return true;
39889
39889
  }
39890
39890
  for (const m of this.absolute) {
@@ -39895,9 +39895,9 @@ var require_ignore = __commonJS({
39895
39895
  }
39896
39896
  childrenIgnored(p) {
39897
39897
  const fullpath = p.fullpath() + "/";
39898
- const relative3 = (p.relative() || ".") + "/";
39898
+ const relative4 = (p.relative() || ".") + "/";
39899
39899
  for (const m of this.relativeChildren) {
39900
- if (m.match(relative3))
39900
+ if (m.match(relative4))
39901
39901
  return true;
39902
39902
  }
39903
39903
  for (const m of this.absoluteChildren) {
@@ -41266,7 +41266,7 @@ var require_parseTokenList = __commonJS({
41266
41266
  // node_modules/depd/index.js
41267
41267
  var require_depd = __commonJS({
41268
41268
  "node_modules/depd/index.js"(exports2, module2) {
41269
- var relative3 = require("path").relative;
41269
+ var relative4 = require("path").relative;
41270
41270
  module2.exports = depd;
41271
41271
  var basePath = process.cwd();
41272
41272
  function containsNamespace(str5, namespace) {
@@ -41458,7 +41458,7 @@ var require_depd = __commonJS({
41458
41458
  return formatted;
41459
41459
  }
41460
41460
  function formatLocation(callSite) {
41461
- return relative3(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
41461
+ return relative4(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
41462
41462
  }
41463
41463
  function getStack() {
41464
41464
  var limit = Error.stackTraceLimit;
@@ -41991,7 +41991,7 @@ var require_send = __commonJS({
41991
41991
  var { parseTokenList } = require_parseTokenList();
41992
41992
  var { createHttpError } = require_createHttpError();
41993
41993
  var extname4 = path.extname;
41994
- var join45 = path.join;
41994
+ var join46 = path.join;
41995
41995
  var normalize2 = path.normalize;
41996
41996
  var resolve11 = path.resolve;
41997
41997
  var sep6 = path.sep;
@@ -42078,7 +42078,7 @@ var require_send = __commonJS({
42078
42078
  return { statusCode: 403 };
42079
42079
  }
42080
42080
  parts = path2.split(sep6);
42081
- path2 = normalize2(join45(root4, path2));
42081
+ path2 = normalize2(join46(root4, path2));
42082
42082
  } else {
42083
42083
  if (UP_PATH_REGEXP.test(path2)) {
42084
42084
  debug('malicious path "%s"', path2);
@@ -42361,7 +42361,7 @@ var require_send = __commonJS({
42361
42361
  let err2;
42362
42362
  for (let i = 0; i < options.index.length; i++) {
42363
42363
  const index = options.index[i];
42364
- const p = join45(path2, index);
42364
+ const p = join46(path2, index);
42365
42365
  const { error, stat: stat4 } = await tryStat(p);
42366
42366
  if (error) {
42367
42367
  err2 = error;
@@ -42517,7 +42517,7 @@ var require_accept_negotiator = __commonJS({
42517
42517
  return preferredEncoding;
42518
42518
  }
42519
42519
  var BEGIN = 0;
42520
- var TOKEN = 1;
42520
+ var TOKEN2 = 1;
42521
42521
  var QUALITY = 2;
42522
42522
  var END = 3;
42523
42523
  function parse(header, processMatch) {
@@ -42529,13 +42529,13 @@ var require_accept_negotiator = __commonJS({
42529
42529
  if (char === " " || char === " ") {
42530
42530
  continue;
42531
42531
  } else if (char === ";") {
42532
- if (state2 === TOKEN) {
42532
+ if (state2 === TOKEN2) {
42533
42533
  state2 = QUALITY;
42534
42534
  quality = "";
42535
42535
  }
42536
42536
  continue;
42537
42537
  } else if (char === ",") {
42538
- if (state2 === TOKEN) {
42538
+ if (state2 === TOKEN2) {
42539
42539
  if (processMatch(str5, 1)) {
42540
42540
  state2 = END;
42541
42541
  break;
@@ -42560,11 +42560,11 @@ var require_accept_negotiator = __commonJS({
42560
42560
  continue;
42561
42561
  }
42562
42562
  } else if (state2 === BEGIN) {
42563
- state2 = TOKEN;
42563
+ state2 = TOKEN2;
42564
42564
  str5 += char;
42565
42565
  continue;
42566
42566
  }
42567
- if (state2 === TOKEN) {
42567
+ if (state2 === TOKEN2) {
42568
42568
  const prevChar = header[i - 1];
42569
42569
  if (prevChar === " " || prevChar === " ") {
42570
42570
  str5 = "";
@@ -42580,7 +42580,7 @@ var require_accept_negotiator = __commonJS({
42580
42580
  str5 = char;
42581
42581
  quality = "";
42582
42582
  }
42583
- if (state2 === TOKEN) {
42583
+ if (state2 === TOKEN2) {
42584
42584
  processMatch(str5, 1);
42585
42585
  } else if (state2 === QUALITY) {
42586
42586
  processMatch(str5, parseFloat(quality) || 0);
@@ -42657,7 +42657,7 @@ var require_content_disposition = __commonJS({
42657
42657
  "use strict";
42658
42658
  module2.exports = contentDisposition;
42659
42659
  module2.exports.parse = parse;
42660
- var basename9 = require("path").basename;
42660
+ var basename11 = require("path").basename;
42661
42661
  var Buffer4 = require_safe_buffer().Buffer;
42662
42662
  var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;
42663
42663
  var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
@@ -42693,9 +42693,9 @@ var require_content_disposition = __commonJS({
42693
42693
  if (typeof fallback === "string" && NON_LATIN1_REGEXP.test(fallback)) {
42694
42694
  throw new TypeError("fallback must be ISO-8859-1 string");
42695
42695
  }
42696
- var name = basename9(filename);
42696
+ var name = basename11(filename);
42697
42697
  var isQuotedString = TEXT_REGEXP.test(name);
42698
- var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name) : basename9(fallback);
42698
+ var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name) : basename11(fallback);
42699
42699
  var hasFallback = typeof fallbackName === "string" && fallbackName !== name;
42700
42700
  if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {
42701
42701
  params["filename*"] = name;
@@ -43145,8 +43145,8 @@ var require_static = __commonJS({
43145
43145
  }
43146
43146
  }
43147
43147
  }
43148
- for (const [dirname21, rootPath] of indexDirs.entries()) {
43149
- const pathname = dirname21 + (dirname21.endsWith("/") ? "" : "/");
43148
+ for (const [dirname22, rootPath] of indexDirs.entries()) {
43149
+ const pathname = dirname22 + (dirname22.endsWith("/") ? "" : "/");
43150
43150
  const file = "/" + pathname.replace(prefix, "");
43151
43151
  setUpHeadAndGet(routeOpts, pathname, file, rootPath);
43152
43152
  if (opts.redirect === true) {
@@ -50770,11 +50770,11 @@ 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, readdir4, realpath2) {
50773
+ function resolveRealInstallExePure(execPath, localAppData, exists, readdir5, realpath3) {
50774
50774
  if (!execPath) return execPath;
50775
50775
  let resolved = execPath;
50776
50776
  try {
50777
- resolved = realpath2(execPath);
50777
+ resolved = realpath3(execPath);
50778
50778
  } catch {
50779
50779
  resolved = execPath;
50780
50780
  }
@@ -50789,7 +50789,7 @@ function resolveRealInstallExePure(execPath, localAppData, exists, readdir4, rea
50789
50789
  const packagesDir2 = `${laRoot}\\Packages`;
50790
50790
  let packages;
50791
50791
  try {
50792
- packages = readdir4(packagesDir2);
50792
+ packages = readdir5(packagesDir2);
50793
50793
  } catch {
50794
50794
  return execPath;
50795
50795
  }
@@ -50822,15 +50822,15 @@ function deriveSandboxLicenseDir() {
50822
50822
  deriveSandboxLicenseDir();
50823
50823
 
50824
50824
  // main.ts
50825
- var import_node_child_process12 = require("node:child_process");
50825
+ var import_node_child_process13 = 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
- var import_node_path46 = require("node:path");
50830
+ var import_node_path48 = require("node:path");
50831
50831
  var import_node_os27 = require("node:os");
50832
50832
  var import_node_fs50 = require("node:fs");
50833
- var import_node_child_process10 = require("node:child_process");
50833
+ var import_node_child_process11 = require("node:child_process");
50834
50834
 
50835
50835
  // log.mjs
50836
50836
  var import_node_path = require("node:path");
@@ -51023,9 +51023,9 @@ var import_node_crypto2 = require("node:crypto");
51023
51023
  var import_node_perf_hooks = require("node:perf_hooks");
51024
51024
  var MAX_EXPECTED_MS = 2 * 60 * 6e4;
51025
51025
  var MAX_LABEL_LENGTH = 60;
51026
- function busyMeta(owner) {
51027
- const label2 = typeof owner.label === "string" && owner.label.trim() && owner.label.length <= MAX_LABEL_LENGTH ? owner.label.trim() : null;
51028
- const expectedMs = typeof owner.expectedMs === "number" && Number.isFinite(owner.expectedMs) && owner.expectedMs > 0 && owner.expectedMs <= MAX_EXPECTED_MS ? owner.expectedMs : null;
51026
+ function busyMeta(owner2) {
51027
+ const label2 = typeof owner2.label === "string" && owner2.label.trim() && owner2.label.length <= MAX_LABEL_LENGTH ? owner2.label.trim() : null;
51028
+ const expectedMs = typeof owner2.expectedMs === "number" && Number.isFinite(owner2.expectedMs) && owner2.expectedMs > 0 && owner2.expectedMs <= MAX_EXPECTED_MS ? owner2.expectedMs : null;
51029
51029
  return { label: label2, expectedMs };
51030
51030
  }
51031
51031
  var LifecycleLockBusyError = class extends Error {
@@ -51047,24 +51047,24 @@ function remainingPhrase(remainingMs) {
51047
51047
  const minutes = Math.round(remainingMs / 6e4);
51048
51048
  return `about ${minutes} minute${minutes === 1 ? "" : "s"} left`;
51049
51049
  }
51050
- function busyDetail(kind, key, owner) {
51051
- const { label: label2, expectedMs } = busyMeta(owner);
51052
- const startedMs = Date.parse(owner.acquiredAt);
51050
+ function busyDetail(kind, key, owner2) {
51051
+ const { label: label2, expectedMs } = busyMeta(owner2);
51052
+ const startedMs = Date.parse(owner2.acquiredAt);
51053
51053
  const elapsedMs = Number.isFinite(startedMs) ? Math.max(0, Date.now() - startedMs) : 0;
51054
51054
  const usableEta = expectedMs != null && Number.isFinite(startedMs) ? expectedMs : null;
51055
- const remaining = usableEta == null ? null : usableEta - elapsedMs;
51055
+ const remaining2 = usableEta == null ? null : usableEta - elapsedMs;
51056
51056
  return {
51057
51057
  kind,
51058
51058
  key,
51059
51059
  label: label2,
51060
- startedAt: owner.acquiredAt,
51060
+ startedAt: owner2.acquiredAt,
51061
51061
  expectedMs: usableEta,
51062
51062
  elapsedMs,
51063
- remainingMs: remaining != null && remaining > 0 ? remaining : null
51063
+ remainingMs: remaining2 != null && remaining2 > 0 ? remaining2 : null
51064
51064
  };
51065
51065
  }
51066
- function busyError(kind, key, owner) {
51067
- const detail = owner ? busyDetail(kind, key, owner) : {
51066
+ function busyError(kind, key, owner2) {
51067
+ const detail = owner2 ? busyDetail(kind, key, owner2) : {
51068
51068
  kind,
51069
51069
  key,
51070
51070
  label: null,
@@ -51210,8 +51210,8 @@ function sameProcessStart(expected, actual) {
51210
51210
  }
51211
51211
  return false;
51212
51212
  }
51213
- function processAlive(owner) {
51214
- const { pid } = owner;
51213
+ function processAlive(owner2) {
51214
+ const { pid } = owner2;
51215
51215
  if (!Number.isInteger(pid) || pid <= 0) return false;
51216
51216
  try {
51217
51217
  process.kill(pid, 0);
@@ -51226,11 +51226,11 @@ function processAlive(owner) {
51226
51226
  } catch {
51227
51227
  }
51228
51228
  }
51229
- if (!owner.started) return true;
51229
+ if (!owner2.started) return true;
51230
51230
  const currentStart = processStartIdentity(pid);
51231
- if (currentStart == null || sameProcessStart(owner.started, currentStart)) return true;
51231
+ if (currentStart == null || sameProcessStart(owner2.started, currentStart)) return true;
51232
51232
  const confirmedStart = processStartIdentity(pid, true);
51233
- return confirmedStart == null || sameProcessStart(owner.started, confirmedStart);
51233
+ return confirmedStart == null || sameProcessStart(owner2.started, confirmedStart);
51234
51234
  }
51235
51235
  function readOwnerFile(file) {
51236
51236
  try {
@@ -51263,11 +51263,11 @@ function publishExclusive(file, bytes) {
51263
51263
  }
51264
51264
  }
51265
51265
  function staleGeneration(path, now = Date.now()) {
51266
- const owner = readOwner(path);
51267
- if (owner) {
51268
- const age = now - Date.parse(owner.acquiredAt);
51269
- if (!Number.isFinite(age) || age <= STALE_MS || processAlive(owner)) return null;
51270
- return (0, import_node_crypto2.createHash)("sha256").update(JSON.stringify(owner)).digest("hex").slice(0, 24);
51266
+ const owner2 = readOwner(path);
51267
+ if (owner2) {
51268
+ const age = now - Date.parse(owner2.acquiredAt);
51269
+ if (!Number.isFinite(age) || age <= STALE_MS || processAlive(owner2)) return null;
51270
+ return (0, import_node_crypto2.createHash)("sha256").update(JSON.stringify(owner2)).digest("hex").slice(0, 24);
51271
51271
  }
51272
51272
  try {
51273
51273
  const stat4 = (0, import_node_fs4.statSync)(path);
@@ -51341,7 +51341,7 @@ async function acquire(path, kind, key, options) {
51341
51341
  while (true) {
51342
51342
  try {
51343
51343
  (0, import_node_fs4.mkdirSync)(path);
51344
- const owner = {
51344
+ const owner2 = {
51345
51345
  pid: process.pid,
51346
51346
  token: PROCESS_TOKEN,
51347
51347
  acquiredAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -51351,9 +51351,9 @@ async function acquire(path, kind, key, options) {
51351
51351
  ...options.label ? { label: options.label } : {},
51352
51352
  ...options.expectedMs != null ? { expectedMs: options.expectedMs } : {}
51353
51353
  };
51354
- if (publishExclusive(ownerPath(path), JSON.stringify(owner))) {
51354
+ if (publishExclusive(ownerPath(path), JSON.stringify(owner2))) {
51355
51355
  const canonical = readOwner(path);
51356
- if (canonical?.pid === owner.pid && canonical.token === owner.token && canonical.acquiredAt === owner.acquiredAt) {
51356
+ if (canonical?.pid === owner2.pid && canonical.token === owner2.token && canonical.acquiredAt === owner2.acquiredAt) {
51357
51357
  return;
51358
51358
  }
51359
51359
  }
@@ -51363,11 +51363,11 @@ async function acquire(path, kind, key, options) {
51363
51363
  if (generation) {
51364
51364
  if (retireStaleLock(path, generation)) continue;
51365
51365
  } else {
51366
- const owner = readOwner(path);
51367
- const startedMs = owner ? Date.parse(owner.acquiredAt) : NaN;
51368
- const expected = owner ? busyMeta(owner).expectedMs : null;
51369
- if (owner && expected != null && startedMs + expected > deadline) {
51370
- throw busyError(kind, key, owner);
51366
+ const owner2 = readOwner(path);
51367
+ const startedMs = owner2 ? Date.parse(owner2.acquiredAt) : NaN;
51368
+ const expected = owner2 ? busyMeta(owner2).expectedMs : null;
51369
+ if (owner2 && expected != null && startedMs + expected > deadline) {
51370
+ throw busyError(kind, key, owner2);
51371
51371
  }
51372
51372
  }
51373
51373
  if (Date.now() >= deadline) throw busyError(kind, key, readOwner(path));
@@ -51408,8 +51408,8 @@ async function withLifecycleLock(kind, key, fn, options = {}) {
51408
51408
  return await held.run(next, fn);
51409
51409
  } finally {
51410
51410
  if ((0, import_node_fs4.existsSync)(path)) {
51411
- const owner = readOwner(path);
51412
- if (owner?.pid === process.pid && owner.token === PROCESS_TOKEN) {
51411
+ const owner2 = readOwner(path);
51412
+ if (owner2?.pid === process.pid && owner2.token === PROCESS_TOKEN) {
51413
51413
  try {
51414
51414
  (0, import_node_fs4.rmSync)(path, { recursive: true, force: true });
51415
51415
  } catch (e) {
@@ -52395,6 +52395,191 @@ function parseTrace(text3) {
52395
52395
  });
52396
52396
  }
52397
52397
 
52398
+ // aware-lifecycle-gate.ts
52399
+ var import_node_async_hooks2 = require("node:async_hooks");
52400
+ var OWNER_BRAND = /* @__PURE__ */ Symbol("aware-lifecycle-owner");
52401
+ function owner() {
52402
+ return Object.freeze({ [OWNER_BRAND]: true, id: /* @__PURE__ */ Symbol("aware-owner") });
52403
+ }
52404
+ function abortError() {
52405
+ const error = new Error("AWARE lifecycle lease acquisition was aborted");
52406
+ error.name = "AbortError";
52407
+ return error;
52408
+ }
52409
+ var AwareLifecycleGate = class {
52410
+ #owners = new import_node_async_hooks2.AsyncLocalStorage();
52411
+ #readerDepth = /* @__PURE__ */ new Map();
52412
+ #queue = [];
52413
+ #readerCount = 0;
52414
+ #writer = null;
52415
+ #writerDepth = 0;
52416
+ currentOwner() {
52417
+ return this.#owners.getStore() ?? null;
52418
+ }
52419
+ snapshot() {
52420
+ return {
52421
+ readers: this.#readerCount,
52422
+ writer: this.#writer !== null,
52423
+ queuedReaders: this.#queue.filter((w) => w.mode === "shared").length,
52424
+ queuedWriters: this.#queue.filter((w) => w.mode === "exclusive").length
52425
+ };
52426
+ }
52427
+ runAs(leaseOwner, fn) {
52428
+ return this.#owners.run(leaseOwner, fn);
52429
+ }
52430
+ enterAs(leaseOwner) {
52431
+ this.#owners.enterWith(leaseOwner);
52432
+ }
52433
+ acquireShared(signal) {
52434
+ return this.#acquire("shared", signal);
52435
+ }
52436
+ acquireExclusive(signal) {
52437
+ return this.#acquire("exclusive", signal);
52438
+ }
52439
+ async withShared(fn, signal) {
52440
+ const lease = await this.acquireShared(signal);
52441
+ try {
52442
+ return await this.runAs(lease.owner, fn);
52443
+ } finally {
52444
+ lease.release();
52445
+ }
52446
+ }
52447
+ async withExclusive(fn, signal) {
52448
+ const lease = await this.acquireExclusive(signal);
52449
+ try {
52450
+ return await this.runAs(lease.owner, fn);
52451
+ } finally {
52452
+ lease.release();
52453
+ }
52454
+ }
52455
+ #acquire(mode, signal) {
52456
+ if (signal?.aborted) return Promise.reject(abortError());
52457
+ const leaseOwner = this.currentOwner() ?? owner();
52458
+ if (this.#writer === leaseOwner) {
52459
+ this.#writerDepth++;
52460
+ return Promise.resolve(this.#lease(leaseOwner, mode, () => {
52461
+ this.#writerDepth--;
52462
+ if (this.#writerDepth === 0) {
52463
+ this.#writer = null;
52464
+ this.#drain();
52465
+ }
52466
+ }));
52467
+ }
52468
+ const existingReaderDepth = this.#readerDepth.get(leaseOwner) ?? 0;
52469
+ if (mode === "shared" && existingReaderDepth > 0) {
52470
+ this.#readerDepth.set(leaseOwner, existingReaderDepth + 1);
52471
+ this.#readerCount++;
52472
+ return Promise.resolve(this.#readerLease(leaseOwner));
52473
+ }
52474
+ if (mode === "exclusive" && existingReaderDepth > 0) {
52475
+ return Promise.reject(new Error("cannot upgrade an AWARE shared lease to exclusive"));
52476
+ }
52477
+ const writerQueued = this.#queue.some((w) => w.mode === "exclusive");
52478
+ if (mode === "shared" && this.#writer === null && !writerQueued) {
52479
+ this.#grantReader(leaseOwner);
52480
+ return Promise.resolve(this.#readerLease(leaseOwner));
52481
+ }
52482
+ if (mode === "exclusive" && this.#writer === null && this.#readerCount === 0) {
52483
+ this.#writer = leaseOwner;
52484
+ this.#writerDepth = 1;
52485
+ return Promise.resolve(this.#writerLease(leaseOwner));
52486
+ }
52487
+ return new Promise((resolve11, reject) => {
52488
+ const waiter = { mode, owner: leaseOwner, resolve: resolve11, reject, ...signal ? { signal } : {} };
52489
+ if (signal) {
52490
+ waiter.onAbort = () => {
52491
+ const index = this.#queue.indexOf(waiter);
52492
+ if (index >= 0) this.#queue.splice(index, 1);
52493
+ reject(abortError());
52494
+ this.#drain();
52495
+ };
52496
+ signal.addEventListener("abort", waiter.onAbort, { once: true });
52497
+ }
52498
+ this.#queue.push(waiter);
52499
+ });
52500
+ }
52501
+ #lease(leaseOwner, mode, onRelease) {
52502
+ let released = false;
52503
+ return {
52504
+ owner: leaseOwner,
52505
+ mode,
52506
+ release: () => {
52507
+ if (released) return;
52508
+ released = true;
52509
+ onRelease();
52510
+ }
52511
+ };
52512
+ }
52513
+ #grantReader(leaseOwner) {
52514
+ this.#readerDepth.set(leaseOwner, (this.#readerDepth.get(leaseOwner) ?? 0) + 1);
52515
+ this.#readerCount++;
52516
+ }
52517
+ #readerLease(leaseOwner) {
52518
+ return this.#lease(leaseOwner, "shared", () => {
52519
+ const depth = this.#readerDepth.get(leaseOwner) ?? 0;
52520
+ if (depth <= 1) this.#readerDepth.delete(leaseOwner);
52521
+ else this.#readerDepth.set(leaseOwner, depth - 1);
52522
+ this.#readerCount--;
52523
+ this.#drain();
52524
+ });
52525
+ }
52526
+ #writerLease(leaseOwner) {
52527
+ return this.#lease(leaseOwner, "exclusive", () => {
52528
+ this.#writerDepth--;
52529
+ if (this.#writerDepth === 0) {
52530
+ this.#writer = null;
52531
+ this.#drain();
52532
+ }
52533
+ });
52534
+ }
52535
+ #take(waiter) {
52536
+ if (waiter.signal && waiter.onAbort) {
52537
+ waiter.signal.removeEventListener("abort", waiter.onAbort);
52538
+ }
52539
+ }
52540
+ #drain() {
52541
+ if (this.#writer !== null || this.#readerCount > 0 || this.#queue.length === 0) return;
52542
+ const writerIndex = this.#queue.findIndex((w) => w.mode === "exclusive");
52543
+ if (writerIndex >= 0) {
52544
+ const [waiter] = this.#queue.splice(writerIndex, 1);
52545
+ if (!waiter) return;
52546
+ this.#take(waiter);
52547
+ this.#writer = waiter.owner;
52548
+ this.#writerDepth = 1;
52549
+ waiter.resolve(this.#writerLease(waiter.owner));
52550
+ return;
52551
+ }
52552
+ const readers = this.#queue.splice(0);
52553
+ for (const waiter of readers) {
52554
+ this.#take(waiter);
52555
+ this.#grantReader(waiter.owner);
52556
+ waiter.resolve(this.#readerLease(waiter.owner));
52557
+ }
52558
+ }
52559
+ };
52560
+ var awareLifecycleGate = new AwareLifecycleGate();
52561
+ var withAwareShared = (fn, signal) => awareLifecycleGate.withShared(fn, signal);
52562
+ var withAwareExclusive = (fn, signal) => awareLifecycleGate.withExclusive(fn, signal);
52563
+ var acquireAwareShared = (signal) => awareLifecycleGate.acquireShared(signal);
52564
+ var runAsAwareOwner = (leaseOwner, fn) => awareLifecycleGate.runAs(leaseOwner, fn);
52565
+ var currentAwareOwner = () => awareLifecycleGate.currentOwner();
52566
+
52567
+ // aware-sidecar-gate.ts
52568
+ var gate = new AwareLifecycleGate();
52569
+ function assertLifecycleOwned() {
52570
+ if (!currentAwareOwner()) {
52571
+ throw new Error("sidecar gate requires an AWARE lifecycle lease");
52572
+ }
52573
+ }
52574
+ async function withSidecarRead(fn, signal) {
52575
+ assertLifecycleOwned();
52576
+ return gate.withShared(fn, signal);
52577
+ }
52578
+ async function withSidecarWrite(fn, signal) {
52579
+ assertLifecycleOwned();
52580
+ return gate.withExclusive(fn, signal);
52581
+ }
52582
+
52398
52583
  // aware-adapter.ts
52399
52584
  var _nodeExe;
52400
52585
  function nodeExe() {
@@ -52462,7 +52647,7 @@ function awareNpmVersion() {
52462
52647
  }
52463
52648
  }
52464
52649
  var SHELL_META = /[&|;<>^"'`$()%\r\n\0]/;
52465
- function runRaw(args, onSpawn, envOverride, timeoutMs) {
52650
+ function runRawUnlocked(args, onSpawn, envOverride, timeoutMs) {
52466
52651
  const invoker = currentInvoker();
52467
52652
  const [bin, ...preArgs] = invoker.head;
52468
52653
  if (!bin) throw new AwareError("aware CLI invoker not resolved");
@@ -52484,12 +52669,13 @@ function runRaw(args, onSpawn, envOverride, timeoutMs) {
52484
52669
  onSpawn?.(child);
52485
52670
  let stdout = "";
52486
52671
  let stderr = "";
52672
+ let terminalError = null;
52487
52673
  const cap = (buf, chunk) => buf.length >= OUTPUT_CAP_BYTES ? buf : buf + chunk.toString();
52488
52674
  child.stdout.on("data", (d) => stdout = cap(stdout, d));
52489
52675
  child.stderr.on("data", (d) => stderr = cap(stderr, d));
52490
52676
  const timer = setTimeout(() => {
52677
+ terminalError = new AwareError(`aware ${args.join(" ")} timed out after ${limit}ms`);
52491
52678
  killTree(child);
52492
- reject(new AwareError(`aware ${args.join(" ")} timed out after ${limit}ms`));
52493
52679
  }, limit);
52494
52680
  child.on("error", (err2) => {
52495
52681
  clearTimeout(timer);
@@ -52497,11 +52683,18 @@ function runRaw(args, onSpawn, envOverride, timeoutMs) {
52497
52683
  });
52498
52684
  child.on("close", (code) => {
52499
52685
  clearTimeout(timer);
52686
+ if (terminalError) {
52687
+ reject(terminalError);
52688
+ return;
52689
+ }
52500
52690
  resolve11({ code: code ?? -1, stdout, stderr });
52501
52691
  });
52502
52692
  });
52503
52693
  }
52504
- function runRawWithEnv(args, env2, timeoutMs) {
52694
+ function runRaw(args, onSpawn, envOverride, timeoutMs) {
52695
+ return withAwareShared(() => runRawUnlocked(args, onSpawn, envOverride, timeoutMs));
52696
+ }
52697
+ function runRawWithEnvUnlocked(args, env2, timeoutMs, onSpawn, signal) {
52505
52698
  const invoker = currentInvoker();
52506
52699
  const [bin, ...preArgs] = invoker.head;
52507
52700
  if (!bin) throw new AwareError("aware CLI invoker not resolved");
@@ -52515,23 +52708,46 @@ function runRawWithEnv(args, env2, timeoutMs) {
52515
52708
  const child = (0, import_node_child_process2.spawn)(bin, argv, { shell: invoker.shell, windowsHide: true, env: env2 ?? process.env });
52516
52709
  let stdout = "";
52517
52710
  let stderr = "";
52711
+ let terminalError = null;
52712
+ try {
52713
+ onSpawn?.(child);
52714
+ } catch {
52715
+ terminalError = new AwareError("aware child identity hook failed");
52716
+ killTree(child);
52717
+ }
52518
52718
  const cap = (buf, chunk) => buf.length >= OUTPUT_CAP_BYTES ? buf : buf + chunk.toString();
52519
52719
  child.stdout.on("data", (d) => stdout = cap(stdout, d));
52520
52720
  child.stderr.on("data", (d) => stderr = cap(stderr, d));
52521
52721
  const timer = setTimeout(() => {
52722
+ terminalError = new AwareError(`aware ${args.join(" ")} timed out after ${limit}ms`);
52522
52723
  killTree(child);
52523
- reject(new AwareError(`aware ${args.join(" ")} timed out after ${limit}ms`));
52524
52724
  }, limit);
52725
+ const onAbort = () => {
52726
+ terminalError = new AwareError(`aware ${args.join(" ")} was aborted`);
52727
+ terminalError.name = "AbortError";
52728
+ killTree(child);
52729
+ };
52730
+ if (signal?.aborted) onAbort();
52731
+ else signal?.addEventListener("abort", onAbort, { once: true });
52525
52732
  child.on("error", (err2) => {
52526
52733
  clearTimeout(timer);
52734
+ signal?.removeEventListener("abort", onAbort);
52527
52735
  reject(new AwareError(`failed to spawn aware: ${err2.message}`, err2));
52528
52736
  });
52529
52737
  child.on("close", (code) => {
52530
52738
  clearTimeout(timer);
52739
+ signal?.removeEventListener("abort", onAbort);
52740
+ if (terminalError) {
52741
+ reject(terminalError);
52742
+ return;
52743
+ }
52531
52744
  resolve11({ code: code ?? -1, stdout, stderr });
52532
52745
  });
52533
52746
  });
52534
52747
  }
52748
+ function runRawWithEnv(args, env2, timeoutMs, onSpawn, signal) {
52749
+ return withAwareShared(() => runRawWithEnvUnlocked(args, env2, timeoutMs, onSpawn, signal), signal);
52750
+ }
52535
52751
  async function runJson(args, timeoutMs) {
52536
52752
  const { code, stdout, stderr } = await runRawWithEnv([...args, "--json"], void 0, timeoutMs);
52537
52753
  let env2;
@@ -52591,7 +52807,7 @@ function hostBridgeStatus(host) {
52591
52807
  function standardUserTempDir() {
52592
52808
  return process.env.LOCALAPPDATA ? (0, import_node_path7.join)(process.env.LOCALAPPDATA, "Temp") : (0, import_node_path7.join)((0, import_node_os7.homedir)(), "AppData", "Local", "Temp");
52593
52809
  }
52594
- async function hostInstances(host) {
52810
+ async function hostInstancesUnlocked(host) {
52595
52811
  const bin = resolveHostBridge(host);
52596
52812
  if (!bin) return { ok: false, instances: [], probeFailed: true, error: `aware-${host} bridge not found (run \`aware sidecar install ${host}\`)` };
52597
52813
  const probe = (env3) => new Promise((resolve11) => {
@@ -52631,6 +52847,9 @@ async function hostInstances(host) {
52631
52847
  }
52632
52848
  return { ok: true, instances, env: env2 };
52633
52849
  }
52850
+ async function hostInstances(host) {
52851
+ return withAwareShared(() => withSidecarRead(() => hostInstancesUnlocked(host)));
52852
+ }
52634
52853
  function parseHostInstances(stdout) {
52635
52854
  try {
52636
52855
  const body = JSON.parse(stdout.trim());
@@ -52674,7 +52893,7 @@ function injectDebugger(code) {
52674
52893
  else lines.unshift(inject);
52675
52894
  return lines.join("\n");
52676
52895
  }
52677
- async function execTekla(code, opts = {}) {
52896
+ async function execTeklaUnlocked(code, opts = {}) {
52678
52897
  const bin = resolveTeklaBridge();
52679
52898
  if (!bin) throw new AwareError("aware-tekla bridge not found (run `aware sidecar install tekla`)");
52680
52899
  const version = opts.version ?? "2025.0";
@@ -52688,12 +52907,13 @@ async function execTekla(code, opts = {}) {
52688
52907
  const child = (0, import_node_child_process2.spawn)(bin, ["exec", "--version", version, "--json-stdin"], { windowsHide: true });
52689
52908
  let stdout = "";
52690
52909
  let stderr = "";
52910
+ let terminalError = null;
52691
52911
  const cap = (buf, chunk) => buf.length >= OUTPUT_CAP_BYTES ? buf : buf + chunk.toString();
52692
52912
  child.stdout.on("data", (d) => stdout = cap(stdout, d));
52693
52913
  child.stderr.on("data", (d) => stderr = cap(stderr, d));
52694
52914
  const timer = setTimeout(() => {
52695
- child.kill();
52696
- reject(new AwareError(`aware-tekla exec timed out after ${timeoutMs}ms`));
52915
+ terminalError = new AwareError(`aware-tekla exec timed out after ${timeoutMs}ms`);
52916
+ killTree(child);
52697
52917
  }, timeoutMs);
52698
52918
  child.on("error", (err2) => {
52699
52919
  clearTimeout(timer);
@@ -52701,6 +52921,10 @@ async function execTekla(code, opts = {}) {
52701
52921
  });
52702
52922
  child.on("close", (exitCode) => {
52703
52923
  clearTimeout(timer);
52924
+ if (terminalError) {
52925
+ reject(terminalError);
52926
+ return;
52927
+ }
52704
52928
  let parsed;
52705
52929
  try {
52706
52930
  parsed = JSON.parse(stdout);
@@ -52718,6 +52942,9 @@ async function execTekla(code, opts = {}) {
52718
52942
  child.stdin.end();
52719
52943
  });
52720
52944
  }
52945
+ async function execTekla(code, opts = {}) {
52946
+ return withAwareShared(() => withSidecarRead(() => execTeklaUnlocked(code, opts)));
52947
+ }
52721
52948
  var activeRun = null;
52722
52949
  var runChain = Promise.resolve();
52723
52950
  function killTree(child) {
@@ -52809,11 +53036,8 @@ function readLatestTrace(id, logsRoot = LOGS_DIR, maxBytes) {
52809
53036
  const runId = p.split(/[\\/]/).pop()?.replace(/\.jsonl$/, "") ?? "";
52810
53037
  return { runId, path: p, text: read.text, truncated: read.truncated };
52811
53038
  }
52812
- function startTrigger(id, opts = {}) {
53039
+ async function startTrigger(id, opts = {}) {
52813
53040
  assertId(id);
52814
- const invoker = currentInvoker();
52815
- const [bin, ...preArgs] = invoker.head;
52816
- if (!bin) throw new AwareError("aware CLI invoker not resolved");
52817
53041
  const args = ["app", "run", id];
52818
53042
  if (opts.inputs) {
52819
53043
  for (const [k, v] of Object.entries(opts.inputs)) {
@@ -52821,9 +53045,27 @@ function startTrigger(id, opts = {}) {
52821
53045
  args.push("--input", `${k}=${String(v)}`);
52822
53046
  }
52823
53047
  }
53048
+ const lease = await acquireAwareShared();
53049
+ try {
53050
+ return runAsAwareOwner(lease.owner, () => startTriggerWithLease(id, args, lease));
53051
+ } catch (error) {
53052
+ lease.release();
53053
+ throw error;
53054
+ }
53055
+ }
53056
+ function startTriggerWithLease(id, args, lease) {
53057
+ const invoker = currentInvoker();
53058
+ const [bin, ...preArgs] = invoker.head;
53059
+ if (!bin) {
53060
+ lease.release();
53061
+ throw new AwareError("aware CLI invoker not resolved");
53062
+ }
52824
53063
  if (invoker.shell) {
52825
53064
  const bad = args.find((a) => SHELL_META.test(a));
52826
- if (bad !== void 0) throw new AwareError(`refusing to pass unsafe argument to shell: ${bad}`);
53065
+ if (bad !== void 0) {
53066
+ lease.release();
53067
+ throw new AwareError(`refusing to pass unsafe argument to shell: ${bad}`);
53068
+ }
52827
53069
  }
52828
53070
  let traceCb = null;
52829
53071
  let errorCb = null;
@@ -52833,6 +53075,11 @@ function startTrigger(id, opts = {}) {
52833
53075
  let stderrTail = "";
52834
53076
  let lastLen = -1;
52835
53077
  let stopped = false;
53078
+ let stopPromise = null;
53079
+ let settleClosed;
53080
+ const closed = new Promise((resolve11) => {
53081
+ settleClosed = resolve11;
53082
+ });
52836
53083
  const child = (0, import_node_child_process2.spawn)(bin, [...preArgs, ...args], { shell: invoker.shell, windowsHide: true });
52837
53084
  const readAndEmit = () => {
52838
53085
  if (!tracePath || !traceCb) return;
@@ -52858,22 +53105,31 @@ function startTrigger(id, opts = {}) {
52858
53105
  child.on("error", (err2) => {
52859
53106
  clearInterval(poll);
52860
53107
  errorCb?.(`failed to spawn aware: ${err2.message}`);
53108
+ settleClosed();
53109
+ lease.release();
52861
53110
  });
52862
53111
  child.on("close", (code) => {
52863
53112
  clearInterval(poll);
52864
53113
  readAndEmit();
52865
53114
  if (!stopped && code !== 0 && code !== null) errorCb?.(stderrTail.trim() || `aware app run exited ${code}`);
52866
53115
  exitCb?.(code);
53116
+ settleClosed();
53117
+ lease.release();
52867
53118
  });
52868
53119
  return {
52869
- async stop() {
52870
- stopped = true;
52871
- clearInterval(poll);
52872
- try {
52873
- await runRaw(["app", "stop", id]);
52874
- } catch {
52875
- }
52876
- killTree(child);
53120
+ stop() {
53121
+ if (stopPromise) return stopPromise;
53122
+ stopPromise = runAsAwareOwner(lease.owner, async () => {
53123
+ stopped = true;
53124
+ clearInterval(poll);
53125
+ try {
53126
+ await runRaw(["app", "stop", id]);
53127
+ } catch {
53128
+ }
53129
+ killTree(child);
53130
+ await closed;
53131
+ }).finally(() => lease.release());
53132
+ return stopPromise;
52877
53133
  },
52878
53134
  onTrace(cb) {
52879
53135
  traceCb = cb;
@@ -53013,8 +53269,17 @@ function cancelAllConnects() {
53013
53269
  for (const cancel of inFlightConnects.values()) cancel();
53014
53270
  inFlightConnects.clear();
53015
53271
  }
53016
- function connectDeviceCode(id, onEvent) {
53272
+ async function connectDeviceCode(id, onEvent) {
53017
53273
  assertId(id);
53274
+ const lease = await acquireAwareShared();
53275
+ try {
53276
+ return await runAsAwareOwner(lease.owner, () => connectDeviceCodeWithLease(id, onEvent, lease));
53277
+ } catch (error) {
53278
+ lease.release();
53279
+ throw error;
53280
+ }
53281
+ }
53282
+ function connectDeviceCodeWithLease(id, onEvent, lease) {
53018
53283
  const invoker = currentInvoker();
53019
53284
  const [bin, ...preArgs] = invoker.head;
53020
53285
  if (!bin) throw new AwareError("aware CLI invoker not resolved");
@@ -53057,16 +53322,27 @@ function connectDeviceCode(id, onEvent) {
53057
53322
  };
53058
53323
  child.on("error", (err2) => {
53059
53324
  cleanup();
53325
+ lease.release();
53060
53326
  if (!gotPrompt) reject(new AwareError(`failed to start aware connect: ${err2.message}`, err2));
53061
53327
  });
53062
53328
  child.on("close", () => {
53063
53329
  cleanup();
53330
+ lease.release();
53064
53331
  if (!gotPrompt) reject(new AwareError("aware connect ended before issuing a device code"));
53065
53332
  });
53066
53333
  });
53067
53334
  }
53068
- function connectOAuth(id, onResult) {
53335
+ async function connectOAuth(id, onResult) {
53069
53336
  assertId(id);
53337
+ const lease = await acquireAwareShared();
53338
+ try {
53339
+ return runAsAwareOwner(lease.owner, () => connectOAuthWithLease(id, onResult, lease));
53340
+ } catch (error) {
53341
+ lease.release();
53342
+ throw error;
53343
+ }
53344
+ }
53345
+ function connectOAuthWithLease(id, onResult, lease) {
53070
53346
  const invoker = currentInvoker();
53071
53347
  const [bin, ...preArgs] = invoker.head;
53072
53348
  if (!bin) throw new AwareError("aware CLI invoker not resolved");
@@ -53089,6 +53365,7 @@ function connectOAuth(id, onResult) {
53089
53365
  if (wasActive) inFlightConnects.delete(id);
53090
53366
  if (finished) return;
53091
53367
  finished = true;
53368
+ lease.release();
53092
53369
  if (wasActive) onResult({ status, code });
53093
53370
  };
53094
53371
  child.on("error", () => finish("failed", -1));
@@ -53103,7 +53380,7 @@ async function connectList() {
53103
53380
  const parsed = JSON.parse(stdout.slice(start));
53104
53381
  return Array.isArray(parsed) ? parsed : [];
53105
53382
  }
53106
- var aware = {
53383
+ var awareImpl = {
53107
53384
  npmVersion: awareNpmVersion,
53108
53385
  /** Cheap readiness probe — true if `aware app list --json` returns ok. */
53109
53386
  async smoke() {
@@ -53343,10 +53620,18 @@ var aware = {
53343
53620
  * over runRaw's 60s default — so use the generous timeout. NOT idempotent-safe to assume: prefer
53344
53621
  * ensureConnectionReaderBridge for the reader (checks the bridge is on disk first).
53345
53622
  */
53346
- async sidecarInstall(host) {
53347
- const { code, stdout, stderr } = await runRawWithEnv(sidecarInstallArgv(host), void 0, 6e5);
53348
- if (code !== 0) throw new AwareError(`aware sidecar install ${host} failed (exit ${code})`, { stdout, stderr });
53349
- return { output: stdout.trim() };
53623
+ async sidecarInstall(host, opts = {}) {
53624
+ return withAwareShared(() => withSidecarWrite(async () => {
53625
+ const { code, stdout, stderr } = await runRawWithEnv(
53626
+ sidecarInstallArgv(host),
53627
+ void 0,
53628
+ opts.timeoutMs ?? 6e5,
53629
+ opts.onSpawn,
53630
+ opts.signal
53631
+ );
53632
+ if (code !== 0) throw new AwareError(`aware sidecar install ${host} failed (exit ${code})`, { stdout, stderr });
53633
+ return { output: stdout.trim() };
53634
+ }, opts.signal), opts.signal);
53350
53635
  },
53351
53636
  /**
53352
53637
  * Ensure the connection-reader bridge (the web-ifc Node SEA) is present, idempotently: if it's
@@ -53355,9 +53640,11 @@ var aware = {
53355
53640
  * Rust) — the reader agent's manifest alone isn't enough.
53356
53641
  */
53357
53642
  async ensureConnectionReaderBridge() {
53358
- if (resolveConnectionReaderBridge()) return { present: true, output: "already installed" };
53359
- const r = await this.sidecarInstall("connection-reader");
53360
- return { present: !!resolveConnectionReaderBridge(), output: r.output };
53643
+ return withAwareShared(() => withSidecarWrite(async () => {
53644
+ if (resolveConnectionReaderBridge()) return { present: true, output: "already installed" };
53645
+ const r = await this.sidecarInstall("connection-reader");
53646
+ return { present: !!resolveConnectionReaderBridge(), output: r.output };
53647
+ }));
53361
53648
  },
53362
53649
  /**
53363
53650
  * Update an installed agent to the latest registry version (`aware agent update
@@ -53435,6 +53722,19 @@ var aware = {
53435
53722
  /** GET /api/integrations — authoritative keyring+file credential status. */
53436
53723
  connectList
53437
53724
  };
53725
+ var sharedMethodWrappers = /* @__PURE__ */ new Map();
53726
+ var aware = new Proxy(awareImpl, {
53727
+ get(target, property, receiver) {
53728
+ const value = Reflect.get(target, property, receiver);
53729
+ if (typeof value !== "function" || value.constructor.name !== "AsyncFunction") return value;
53730
+ let wrapped = sharedMethodWrappers.get(property);
53731
+ if (!wrapped) {
53732
+ wrapped = (...args) => withAwareShared(() => Reflect.apply(value, receiver, args));
53733
+ sharedMethodWrappers.set(property, wrapped);
53734
+ }
53735
+ return wrapped;
53736
+ }
53737
+ });
53438
53738
 
53439
53739
  // extensions-store.ts
53440
53740
  var import_node_fs9 = require("node:fs");
@@ -53658,7 +53958,8 @@ var REMEDIATION = {
53658
53958
  "eacces": "The global install was denied (permission). Run in an elevated terminal, or set an npm user prefix, then relaunch: npm i -g @aware-aeco/cli",
53659
53959
  "offline": "Could not reach the npm registry. Check your connection and relaunch.",
53660
53960
  "install-failed": "Installing AWARE failed. Try manually: npm i -g @aware-aeco/cli",
53661
- "smoke-failed": "AWARE installed but did not run correctly. Try reinstalling: npm i -g @aware-aeco/cli"
53961
+ "smoke-failed": "AWARE installed but did not run correctly. Try reinstalling: npm i -g @aware-aeco/cli",
53962
+ "maintenance-recovery-failed": "An interrupted AWARE update could not be recovered safely. Close any npm/AWARE installers, then use Try again. If it persists, reinstall @aware-aeco/cli and relaunch FloLess."
53662
53963
  };
53663
53964
  var state = { status: "idle", awareReady: false, awareVersion: null, reason: null, remediation: null };
53664
53965
  var inflight = null;
@@ -53673,6 +53974,14 @@ function set(deps, next) {
53673
53974
  function fail(deps, reason, awareVersion) {
53674
53975
  return set(deps, { status: "failed", awareReady: false, awareVersion, reason, remediation: reason ? REMEDIATION[reason] ?? null : null });
53675
53976
  }
53977
+ function failBootstrapMaintenanceRecovery(deps) {
53978
+ let version = null;
53979
+ try {
53980
+ version = deps.getAware().version;
53981
+ } catch {
53982
+ }
53983
+ return fail(deps, "maintenance-recovery-failed", version);
53984
+ }
53676
53985
  function classifyInstallError(err2) {
53677
53986
  const msg = String(err2?.message ?? err2);
53678
53987
  if (/EACCES|EPERM|permission denied/i.test(msg)) return "eacces";
@@ -54163,7 +54472,7 @@ function appVersion() {
54163
54472
  return resolveVersion({
54164
54473
  isSea: isSea2(),
54165
54474
  sqVersionXml: readSqVersionXml(),
54166
- define: true ? "0.113.2" : void 0,
54475
+ define: true ? "0.113.4" : void 0,
54167
54476
  pkgVersion: readPkgVersion()
54168
54477
  });
54169
54478
  }
@@ -54179,7 +54488,7 @@ function resolveChannel(s) {
54179
54488
  function appChannel() {
54180
54489
  return resolveChannel({
54181
54490
  isSea: isSea2(),
54182
- define: true ? "0.113.2" : void 0,
54491
+ define: true ? "0.113.4" : void 0,
54183
54492
  // argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
54184
54493
  // carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
54185
54494
  modulePath: process.argv[1]
@@ -57456,7 +57765,7 @@ function bearingFaces(x, uOnN, vOnN, requestedSide) {
57456
57765
  }
57457
57766
 
57458
57767
  // index.ts
57459
- var import_node_crypto23 = require("node:crypto");
57768
+ var import_node_crypto24 = require("node:crypto");
57460
57769
 
57461
57770
  // ifc-guid.ts
57462
57771
  var import_node_crypto10 = require("node:crypto");
@@ -64578,9 +64887,9 @@ function checkPlacement(index, entity, product) {
64578
64887
  if (placement.type !== "IFCLOCALPLACEMENT") {
64579
64888
  fail2(`${product.role} "${product.sceneId}" is placed by a ${placement.type}, expected IfcLocalPlacement.`);
64580
64889
  }
64581
- const relative3 = deref(index, argAt(placement, 1), `${product.role} "${product.sceneId}" relative placement`);
64582
- if (relative3.type !== "IFCAXIS2PLACEMENT3D") {
64583
- fail2(`${product.role} "${product.sceneId}" has a ${relative3.type} relative placement, expected IfcAxis2Placement3D.`);
64890
+ const relative4 = deref(index, argAt(placement, 1), `${product.role} "${product.sceneId}" relative placement`);
64891
+ if (relative4.type !== "IFCAXIS2PLACEMENT3D") {
64892
+ fail2(`${product.role} "${product.sceneId}" has a ${relative4.type} relative placement, expected IfcAxis2Placement3D.`);
64584
64893
  }
64585
64894
  const seen = /* @__PURE__ */ new Set([placement.id]);
64586
64895
  let parent = argAt(placement, 0);
@@ -64717,20 +65026,20 @@ function checkGridPlacement(index, entity, grid) {
64717
65026
  const what = `grid "${grid.sceneId}"`;
64718
65027
  const placement = deref(index, argAt(entity, 5), `${what} placement`);
64719
65028
  if (placement.type !== "IFCLOCALPLACEMENT") fail2(`${what} placement is a ${placement.type}, expected IfcLocalPlacement.`);
64720
- const relative3 = deref(index, argAt(placement, 1), `${what} relative placement`);
64721
- if (relative3.type !== "IFCAXIS2PLACEMENT3D") {
64722
- fail2(`${what} relative placement is a ${relative3.type}, expected IfcAxis2Placement3D.`);
65029
+ const relative4 = deref(index, argAt(placement, 1), `${what} relative placement`);
65030
+ if (relative4.type !== "IFCAXIS2PLACEMENT3D") {
65031
+ fail2(`${what} relative placement is a ${relative4.type}, expected IfcAxis2Placement3D.`);
64723
65032
  }
64724
- const origin = pointCoords(index, argAt(relative3, 0), `${what} origin`);
65033
+ const origin = pointCoords(index, argAt(relative4, 0), `${what} origin`);
64725
65034
  if (origin.length !== 3) fail2(`${what} origin has ${origin.length} coordinates, expected a 3D point.`);
64726
65035
  if (!nearVector(origin, grid.origin, AXIS_TOL_MM)) {
64727
65036
  fail2(`${what} origin is ${JSON.stringify(origin)}, expected ${JSON.stringify(grid.origin)} mm.`);
64728
65037
  }
64729
- const axis = directionCoords(index, argAt(relative3, 1), `${what} axis direction`);
65038
+ const axis = directionCoords(index, argAt(relative4, 1), `${what} axis direction`);
64730
65039
  if (!nearVector(axis, [0, 0, 1], 1e-9)) {
64731
65040
  fail2(`${what} axis direction is ${JSON.stringify(axis)}, expected the identity direction [0,0,1].`);
64732
65041
  }
64733
- const refDirection = directionCoords(index, argAt(relative3, 2), `${what} reference direction`);
65042
+ const refDirection = directionCoords(index, argAt(relative4, 2), `${what} reference direction`);
64734
65043
  if (!nearVector(refDirection, [1, 0, 0], 1e-9)) {
64735
65044
  fail2(`${what} reference direction is ${JSON.stringify(refDirection)}, expected the identity direction [1,0,0].`);
64736
65045
  }
@@ -65157,7 +65466,7 @@ function validateTeklaNativeIdentity(emitted, relationships) {
65157
65466
  }
65158
65467
  const boltParent = relationships.boltParentById.get(row.id);
65159
65468
  const gridParent = relationships.gridParentById.get(row.id);
65160
- let owner = row.id;
65469
+ let owner2 = row.id;
65161
65470
  if (boltParent) {
65162
65471
  if (row.realizedBy !== boltParent) {
65163
65472
  throw new ReceiptReconciliationError(
@@ -65170,7 +65479,7 @@ function validateTeklaNativeIdentity(emitted, relationships) {
65170
65479
  `Tekla row "${row.id}" must share nativeGuid with bolt array "${boltParent}".`
65171
65480
  );
65172
65481
  }
65173
- owner = boltParent;
65482
+ owner2 = boltParent;
65174
65483
  } else if (gridParent) {
65175
65484
  if (row.realizedBy !== void 0 && row.realizedBy !== gridParent) {
65176
65485
  throw new ReceiptReconciliationError(
@@ -65183,15 +65492,15 @@ function validateTeklaNativeIdentity(emitted, relationships) {
65183
65492
  `Tekla grid child "${row.id}" must share nativeGuid with grid "${gridParent}".`
65184
65493
  );
65185
65494
  }
65186
- owner = gridParent;
65495
+ owner2 = gridParent;
65187
65496
  }
65188
65497
  const priorOwner = ownerByGuid.get(row.nativeGuid);
65189
- if (priorOwner && priorOwner !== owner) {
65498
+ if (priorOwner && priorOwner !== owner2) {
65190
65499
  throw new ReceiptReconciliationError(
65191
- `Tekla nativeGuid "${row.nativeGuid}" is shared by independent records "${priorOwner}" and "${owner}".`
65500
+ `Tekla nativeGuid "${row.nativeGuid}" is shared by independent records "${priorOwner}" and "${owner2}".`
65192
65501
  );
65193
65502
  }
65194
- ownerByGuid.set(row.nativeGuid, owner);
65503
+ ownerByGuid.set(row.nativeGuid, owner2);
65195
65504
  }
65196
65505
  }
65197
65506
  function reconcileReceipt(sceneInput, rawReceipt, producerUnsupported = [], sink) {
@@ -67119,9 +67428,9 @@ function appExportSource(deps, resolved, appId, action, reply) {
67119
67428
  }
67120
67429
  }
67121
67430
  async function projectExportSource(deps, appId, project, reply) {
67122
- const gate = deps.projectExportGate(appId, project);
67123
- if (gate) {
67124
- reply.status(gate.status).send({ ok: false, error: gate.error });
67431
+ const gate2 = deps.projectExportGate(appId, project);
67432
+ if (gate2) {
67433
+ reply.status(gate2.status).send({ ok: false, error: gate2.error });
67125
67434
  return null;
67126
67435
  }
67127
67436
  let snapshot;
@@ -67200,8 +67509,8 @@ function registerContractAccessRoutes(app, deps) {
67200
67509
  return deps.withLifecycleLock(project ? "project" : "app", project || appId, async () => {
67201
67510
  let input;
67202
67511
  if (project) {
67203
- const gate = deps.projectExportGate(appId, project);
67204
- if (gate) return reply.status(gate.status).send({ ok: false, error: gate.error });
67512
+ const gate2 = deps.projectExportGate(appId, project);
67513
+ if (gate2) return reply.status(gate2.status).send({ ok: false, error: gate2.error });
67205
67514
  let snapshot;
67206
67515
  try {
67207
67516
  snapshot = deps.currentApprovedSnapshot(project);
@@ -67231,8 +67540,8 @@ function registerContractAccessRoutes(app, deps) {
67231
67540
  return reply.status(400).send({ ok: false, error: `invalid appId: ${appId}` });
67232
67541
  }
67233
67542
  if (project) {
67234
- const gate = deps.projectExportGate(appId, project);
67235
- if (gate) return reply.status(gate.status).send({ ok: false, error: gate.error });
67543
+ const gate2 = deps.projectExportGate(appId, project);
67544
+ if (gate2) return reply.status(gate2.status).send({ ok: false, error: gate2.error });
67236
67545
  let snapshot;
67237
67546
  try {
67238
67547
  snapshot = deps.currentApprovedSnapshot(project);
@@ -72765,7 +73074,7 @@ function generateXlsxFileContents(arg1, arg2, arg3) {
72765
73074
  sheetsOptions = setConditionalFormattingRulesGlobalIndexes(sheetsOptions);
72766
73075
  var features = getFeatures(options.features);
72767
73076
  var files2 = {};
72768
- var readFile3 = function readFile4(path) {
73077
+ var readFile5 = function readFile6(path) {
72769
73078
  return files2[path];
72770
73079
  };
72771
73080
  var writeFiles = function writeFiles2(filesToWrite) {
@@ -72832,7 +73141,7 @@ function generateXlsxFileContents(arg1, arg2, arg3) {
72832
73141
  sheetIndex++;
72833
73142
  }
72834
73143
  writeFiles(getWrittenFiles(features, sheetsOptions, {
72835
- read: readFile3
73144
+ read: readFile5
72836
73145
  }));
72837
73146
  files2["xl/styles.xml"] = generateStylesXml(getCellStyles(), sheetsOptions, features);
72838
73147
  files2["xl/sharedStrings.xml"] = generateSharedStringsXml(getSharedStrings());
@@ -74070,6 +74379,9 @@ var DEFAULT_DEPS = {
74070
74379
  probe: (code, opts) => aware.execTekla(code, opts)
74071
74380
  };
74072
74381
  async function teklaReadiness(deps = DEFAULT_DEPS) {
74382
+ return withAwareShared(() => withSidecarRead(() => teklaReadinessUnlocked(deps)));
74383
+ }
74384
+ async function teklaReadinessUnlocked(deps) {
74073
74385
  const awareVersion = deps.npmVersion();
74074
74386
  const awareCurrent = !!awareVersion && compareSemver(awareVersion, TEKLA_AWARE_FLOOR) >= 0;
74075
74387
  const bridge = deps.bridgeStatus();
@@ -74377,6 +74689,9 @@ var DEFAULT_DEPS3 = {
74377
74689
  runningHosts: () => runningKnownHosts()
74378
74690
  };
74379
74691
  async function hostReadiness(host, deps = DEFAULT_DEPS3, targetPid) {
74692
+ return withAwareShared(() => withSidecarRead(() => hostReadinessUnlocked(host, deps, targetPid)));
74693
+ }
74694
+ async function hostReadinessUnlocked(host, deps, targetPid) {
74380
74695
  const label2 = HOST_LABELS[host];
74381
74696
  const floor = HOST_BAKE_AWARE_FLOORS[host];
74382
74697
  const awareVersion = deps.npmVersion();
@@ -74692,6 +75007,9 @@ var DEFAULT_DEPS4 = {
74692
75007
  locateBlender: () => findBlender()
74693
75008
  };
74694
75009
  async function renderReadiness(deps = DEFAULT_DEPS4) {
75010
+ return withAwareShared(() => renderReadinessUnlocked(deps));
75011
+ }
75012
+ async function renderReadinessUnlocked(deps) {
74695
75013
  try {
74696
75014
  const version = deps.npmVersion();
74697
75015
  const current = !!version && compareSemver(version, RENDER_AWARE_FLOOR) >= 0;
@@ -74890,6 +75208,20 @@ var defaultDeps = {
74890
75208
  onReport: (id, workflow, report) => broadcast({ type: "trigger-report", id, workflow, nodeId: report.nodeId, html: report.html })
74891
75209
  };
74892
75210
  var sessions = /* @__PURE__ */ new Map();
75211
+ var sessionOperations = /* @__PURE__ */ new Map();
75212
+ function serializeSession(id, operation) {
75213
+ const prior = sessionOperations.get(id) ?? Promise.resolve();
75214
+ const result = prior.catch(() => {
75215
+ }).then(operation);
75216
+ const tail = result.then(() => {
75217
+ }, () => {
75218
+ });
75219
+ sessionOperations.set(id, tail);
75220
+ void tail.finally(() => {
75221
+ if (sessionOperations.get(id) === tail) sessionOperations.delete(id);
75222
+ });
75223
+ return result;
75224
+ }
74893
75225
  function isLive(s) {
74894
75226
  return s.handle !== null && s.snapshot.state === "listening";
74895
75227
  }
@@ -74908,11 +75240,14 @@ function foregroundSessionId(appId) {
74908
75240
  return `__run__:${appId}`;
74909
75241
  }
74910
75242
  function startSession(spec, deps = defaultDeps) {
75243
+ return serializeSession(spec.id, () => startSessionUnlocked(spec, deps));
75244
+ }
75245
+ async function startSessionUnlocked(spec, deps) {
74911
75246
  if (spec.hostBacked && hostWatcherActive(spec.id)) {
74912
75247
  return { ok: false, reason: "another host watcher is live \u2014 stop it first (one live model = one watcher)" };
74913
75248
  }
74914
75249
  const prior = sessions.get(spec.id);
74915
- if (prior?.handle) void prior.handle.stop();
75250
+ if (prior?.handle) await prior.handle.stop();
74916
75251
  const session = {
74917
75252
  spec,
74918
75253
  handle: null,
@@ -74924,7 +75259,7 @@ function startSession(spec, deps = defaultDeps) {
74924
75259
  if (current()) deps.onChange(spec.id, session.snapshot);
74925
75260
  };
74926
75261
  let lastReportCount = 0;
74927
- const handle = deps.start(spec.workflow, { inputs: spec.inputs });
75262
+ const handle = await deps.start(spec.workflow, { inputs: spec.inputs });
74928
75263
  session.handle = handle;
74929
75264
  handle.onTrace((events) => {
74930
75265
  if (!current()) return;
@@ -74960,6 +75295,9 @@ function startSession(spec, deps = defaultDeps) {
74960
75295
  return { ok: true };
74961
75296
  }
74962
75297
  async function stopSession(id) {
75298
+ await serializeSession(id, () => stopSessionUnlocked(id));
75299
+ }
75300
+ async function stopSessionUnlocked(id) {
74963
75301
  const s = sessions.get(id);
74964
75302
  if (!s) return;
74965
75303
  const handle = s.handle;
@@ -74972,6 +75310,9 @@ function getSnapshot(id) {
74972
75310
  return sessions.get(id)?.snapshot ?? null;
74973
75311
  }
74974
75312
  async function stopAllSessions() {
75313
+ while (sessionOperations.size > 0) {
75314
+ await Promise.allSettled([...sessionOperations.values()]);
75315
+ }
74975
75316
  await Promise.all([...sessions.keys()].map((id) => stopSession(id)));
74976
75317
  sessions.clear();
74977
75318
  }
@@ -75283,10 +75624,10 @@ function computeNextFire(r, from = /* @__PURE__ */ new Date()) {
75283
75624
  const nf = nextFireAt(r.schedule, from);
75284
75625
  return nf ? nf.toISOString() : null;
75285
75626
  }
75286
- function syncTriggerSession(r) {
75627
+ async function syncTriggerSession(r) {
75287
75628
  if (r.kind !== "trigger") return;
75288
75629
  if (!r.enabled) {
75289
- void stopSession(r.id);
75630
+ await stopSession(r.id);
75290
75631
  return;
75291
75632
  }
75292
75633
  let app;
@@ -75294,23 +75635,23 @@ function syncTriggerSession(r) {
75294
75635
  app = readApp(r.workflow);
75295
75636
  } catch {
75296
75637
  r.broken = { reason: "workflow not installed" };
75297
- void stopSession(r.id);
75638
+ await stopSession(r.id);
75298
75639
  return;
75299
75640
  }
75300
75641
  if (!app.triggerSource) {
75301
75642
  r.broken = { reason: "workflow is not trigger-eligible (no streaming source)" };
75302
- void stopSession(r.id);
75643
+ await stopSession(r.id);
75303
75644
  return;
75304
75645
  }
75305
75646
  if (!app.runnable) {
75306
75647
  r.broken = {
75307
75648
  reason: app.runState === "uncompiled" ? "needs Compile (no lock yet)" : "workflow changed \u2014 needs Compile"
75308
75649
  };
75309
- void stopSession(r.id);
75650
+ await stopSession(r.id);
75310
75651
  return;
75311
75652
  }
75312
75653
  delete r.broken;
75313
- const res = startSession({
75654
+ const res = await startSession({
75314
75655
  id: r.id,
75315
75656
  workflow: r.workflow,
75316
75657
  sourceNodeId: app.triggerSource.nodeId,
@@ -75319,6 +75660,16 @@ function syncTriggerSession(r) {
75319
75660
  });
75320
75661
  if (!res.ok) r.broken = { reason: res.reason };
75321
75662
  }
75663
+ function requestTriggerSync(r) {
75664
+ void syncTriggerSession(r).then(() => {
75665
+ saveRoutines();
75666
+ broadcast({ type: "routine-changed", id: r.id });
75667
+ }, (error) => {
75668
+ r.broken = { reason: error instanceof Error ? error.message : "could not start trigger session" };
75669
+ saveRoutines();
75670
+ broadcast({ type: "routine-changed", id: r.id });
75671
+ });
75672
+ }
75322
75673
  function createRoutine(input) {
75323
75674
  ensureLoaded();
75324
75675
  if (routines.length >= MAX_ROUTINES) {
@@ -75357,7 +75708,7 @@ function createRoutine(input) {
75357
75708
  r.nextFireAt = computeNextFire(r, now);
75358
75709
  routines.push(r);
75359
75710
  saveRoutines();
75360
- if (kind === "trigger") syncTriggerSession(r);
75711
+ if (kind === "trigger") requestTriggerSync(r);
75361
75712
  broadcast({ type: "routine-changed", id: r.id });
75362
75713
  return r;
75363
75714
  }
@@ -75385,7 +75736,7 @@ function updateRoutine(id, patch2) {
75385
75736
  r.nextFireAt = computeNextFire(r);
75386
75737
  saveRoutines();
75387
75738
  if (r.kind === "trigger" && (patch2.enabled !== void 0 || patch2.inputs !== void 0)) {
75388
- syncTriggerSession(r);
75739
+ requestTriggerSync(r);
75389
75740
  }
75390
75741
  broadcast({ type: "routine-changed", id: r.id });
75391
75742
  return r;
@@ -75396,7 +75747,9 @@ function deleteRoutine(id) {
75396
75747
  const before = routines.length;
75397
75748
  routines = routines.filter((r) => r.id !== id);
75398
75749
  if (routines.length === before) return false;
75399
- if (target?.kind === "trigger") void stopSession(id);
75750
+ if (target?.kind === "trigger") {
75751
+ void stopSession(id).catch((error) => console.warn(`[floless] trigger routine "${id}" teardown failed:`, error instanceof Error ? error.message : error));
75752
+ }
75400
75753
  saveRoutines();
75401
75754
  broadcast({ type: "routine-changed", id });
75402
75755
  return true;
@@ -75412,7 +75765,7 @@ function repointRoutines(oldId, newId) {
75412
75765
  }
75413
75766
  saveRoutines();
75414
75767
  for (const r of changed) {
75415
- if (r.kind === "trigger") syncTriggerSession(r);
75768
+ if (r.kind === "trigger") requestTriggerSync(r);
75416
75769
  broadcast({ type: "routine-changed", id: r.id });
75417
75770
  }
75418
75771
  return changed.length;
@@ -75591,7 +75944,7 @@ function startScheduler() {
75591
75944
  r.nextFireAt = computeNextFire(r, now);
75592
75945
  }
75593
75946
  saveRoutines();
75594
- for (const r of routines) if (r.kind === "trigger") syncTriggerSession(r);
75947
+ for (const r of routines) if (r.kind === "trigger") requestTriggerSync(r);
75595
75948
  scheduler = setInterval(tick, TICK_MS);
75596
75949
  scheduler.unref?.();
75597
75950
  }
@@ -76868,9 +77221,192 @@ if (entry === "launch.mjs") {
76868
77221
  }
76869
77222
 
76870
77223
  // aware-update.ts
77224
+ var import_promises4 = require("node:fs/promises");
77225
+ var import_node_crypto23 = require("node:crypto");
77226
+ var import_node_path43 = require("node:path");
76871
77227
  var REGISTRY_LATEST = "https://registry.npmjs.org/@aware-aeco/cli/latest";
76872
77228
  var FEED_TIMEOUT_MS2 = 15e3;
76873
77229
  var VERSION_TTL_MS = 5e3;
77230
+ var AWARE_BRIDGE_HOSTS = ["tekla", "revit", "sketchup", "rhino"];
77231
+ function isExactAwareTarget(value) {
77232
+ return typeof value === "string" && /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(value);
77233
+ }
77234
+ function requireExactAwareTarget(value) {
77235
+ if (!isExactAwareTarget(value)) throw new Error("The AWARE registry returned an invalid update version.");
77236
+ return value;
77237
+ }
77238
+ var nodeBridgeIo = { readdir: import_promises4.readdir, lstat: import_promises4.lstat, realpath: import_promises4.realpath };
77239
+ var nodeBridgeVersionIo = { ...nodeBridgeIo, readFile: import_promises4.readFile };
77240
+ var BRIDGE_VERSION_MAX_BYTES = 128;
77241
+ function pathInside(root4, candidate) {
77242
+ const rel = (0, import_node_path43.relative)(root4, candidate);
77243
+ return rel === "" || !rel.startsWith("..") && !(0, import_node_path43.isAbsolute)(rel);
77244
+ }
77245
+ async function snapshotPersistentBridges(bridgeDirectory, io = nodeBridgeIo) {
77246
+ let names;
77247
+ try {
77248
+ const directory = await io.lstat(bridgeDirectory);
77249
+ if (!directory.isDirectory() || directory.isSymbolicLink()) {
77250
+ throw new Error("persistent bridge directory is not a regular directory");
77251
+ }
77252
+ names = await io.readdir(bridgeDirectory);
77253
+ } catch (error) {
77254
+ if (error.code === "ENOENT") return Object.freeze([]);
77255
+ throw new Error("Could not safely inspect installed AWARE bridges.", { cause: error });
77256
+ }
77257
+ let canonicalRoot;
77258
+ try {
77259
+ canonicalRoot = await io.realpath(bridgeDirectory);
77260
+ } catch (error) {
77261
+ throw new Error("Could not safely inspect installed AWARE bridges.", { cause: error });
77262
+ }
77263
+ const installed = [];
77264
+ for (const host of AWARE_BRIDGE_HOSTS) {
77265
+ const fileName = `aware-${host}.exe`;
77266
+ if (!names.includes(fileName)) continue;
77267
+ const candidate = (0, import_node_path43.join)(bridgeDirectory, fileName);
77268
+ try {
77269
+ const stat4 = await io.lstat(candidate);
77270
+ const canonical = await io.realpath(candidate);
77271
+ if (!stat4.isFile() || stat4.isSymbolicLink() || !pathInside(canonicalRoot, canonical)) {
77272
+ throw new Error(`${fileName} is not a validated persistent executable`);
77273
+ }
77274
+ installed.push(host);
77275
+ } catch (error) {
77276
+ throw new Error(`Could not safely inspect the installed ${host} bridge.`, { cause: error });
77277
+ }
77278
+ }
77279
+ return Object.freeze(installed);
77280
+ }
77281
+ async function persistentBridgeVersion(bridgeDirectory, host, io = nodeBridgeVersionIo) {
77282
+ if (!isBridgeHost(host)) throw new Error("Unknown AWARE bridge host.");
77283
+ try {
77284
+ const directory = await io.lstat(bridgeDirectory);
77285
+ if (!directory.isDirectory() || directory.isSymbolicLink()) {
77286
+ throw new Error("persistent bridge directory is not a regular directory");
77287
+ }
77288
+ } catch (error) {
77289
+ if (error.code === "ENOENT") return null;
77290
+ throw new Error(`Could not safely verify the installed ${host} bridge.`, { cause: error });
77291
+ }
77292
+ let canonicalRoot;
77293
+ try {
77294
+ canonicalRoot = await io.realpath(bridgeDirectory);
77295
+ } catch (error) {
77296
+ throw new Error(`Could not safely verify the installed ${host} bridge.`, { cause: error });
77297
+ }
77298
+ const validateFile = async (path) => {
77299
+ try {
77300
+ const stat4 = await io.lstat(path);
77301
+ const canonical = await io.realpath(path);
77302
+ if (!stat4.isFile() || stat4.isSymbolicLink() || !pathInside(canonicalRoot, canonical)) {
77303
+ throw new Error("persistent bridge entry is not a validated regular file");
77304
+ }
77305
+ return true;
77306
+ } catch (error) {
77307
+ if (error.code === "ENOENT") return false;
77308
+ throw error;
77309
+ }
77310
+ };
77311
+ const executable = (0, import_node_path43.join)(bridgeDirectory, `aware-${host}.exe`);
77312
+ const marker = (0, import_node_path43.join)(bridgeDirectory, `aware-${host}.version`);
77313
+ try {
77314
+ if (!await validateFile(executable) || !await validateFile(marker)) return null;
77315
+ const bytes = await io.readFile(marker, "utf8");
77316
+ if (Buffer.byteLength(bytes) > BRIDGE_VERSION_MAX_BYTES) {
77317
+ throw new Error("persistent bridge version marker is oversized");
77318
+ }
77319
+ return bytes.trim() || null;
77320
+ } catch (error) {
77321
+ throw new Error(`Could not safely verify the installed ${host} bridge.`, { cause: error });
77322
+ }
77323
+ }
77324
+ var nodeMarkerIo = { mkdir: import_promises4.mkdir, readFile: import_promises4.readFile, writeFile: import_promises4.writeFile, rename: import_promises4.rename, chmod: import_promises4.chmod, rm: import_promises4.rm };
77325
+ var MARKER_MAX_BYTES = 4096;
77326
+ var TOKEN = /^[A-Za-z0-9._-]{1,128}$/;
77327
+ var PROCESS_IDENTITY = /^[A-Za-z0-9._:-]{1,192}$/;
77328
+ function isBridgeHost(value) {
77329
+ return typeof value === "string" && AWARE_BRIDGE_HOSTS.includes(value);
77330
+ }
77331
+ function validateMarker(value) {
77332
+ if (!value || typeof value !== "object") return null;
77333
+ const v = value;
77334
+ if (v.schema !== 1 || !TOKEN.test(v.transaction ?? "") || !isExactAwareTarget(v.target)) return null;
77335
+ if (!["runtime-install", "runtime-verify", "bridge-install", "bridge-verify", "retry-install", "retry-verify", "recovery"].includes(v.stage ?? "")) return null;
77336
+ if (!Array.isArray(v.snapshot) || v.snapshot.some((host) => !isBridgeHost(host)) || new Set(v.snapshot).size !== v.snapshot.length) return null;
77337
+ if (v.host != null && !isBridgeHost(v.host)) return null;
77338
+ if (v.child != null) {
77339
+ const child = v.child;
77340
+ if (!Number.isSafeInteger(child.pid) || child.pid <= 0 || !PROCESS_IDENTITY.test(child.startIdentity) || !PROCESS_IDENTITY.test(child.executableIdentity) || (0, import_node_path43.basename)(child.executableIdentity) !== child.executableIdentity) return null;
77341
+ }
77342
+ return {
77343
+ schema: 1,
77344
+ transaction: v.transaction,
77345
+ stage: v.stage,
77346
+ target: v.target,
77347
+ ...v.host ? { host: v.host } : {},
77348
+ snapshot: Object.freeze([...v.snapshot]),
77349
+ ...v.child ? { child: { ...v.child } } : {}
77350
+ };
77351
+ }
77352
+ function createMaintenanceMarkerStore(markerPath2, options = {}) {
77353
+ const io = options.io ?? nodeMarkerIo;
77354
+ const maxBytes = Math.min(options.maxBytes ?? MARKER_MAX_BYTES, MARKER_MAX_BYTES);
77355
+ const randomId = options.randomId ?? import_node_crypto23.randomUUID;
77356
+ const directory = (0, import_node_path43.dirname)(markerPath2);
77357
+ return {
77358
+ async read() {
77359
+ let bytes;
77360
+ try {
77361
+ bytes = await io.readFile(markerPath2, "utf8");
77362
+ } catch (error) {
77363
+ if (error.code === "ENOENT") return { kind: "absent" };
77364
+ return { kind: "corrupt", diagnostic: sanitizeAwareError(error).message };
77365
+ }
77366
+ if (Buffer.byteLength(bytes) > maxBytes) return { kind: "corrupt", diagnostic: "maintenance marker is oversized" };
77367
+ try {
77368
+ const marker = validateMarker(JSON.parse(bytes));
77369
+ return marker ? { kind: "valid", marker } : { kind: "corrupt", diagnostic: "maintenance marker has an invalid schema" };
77370
+ } catch {
77371
+ return { kind: "corrupt", diagnostic: "maintenance marker is not valid JSON" };
77372
+ }
77373
+ },
77374
+ async write(marker) {
77375
+ const valid = validateMarker(marker);
77376
+ if (!valid) throw new Error("Refused to write an invalid AWARE maintenance marker.");
77377
+ const bytes = JSON.stringify(valid);
77378
+ if (Buffer.byteLength(bytes) > maxBytes) throw new Error("Refused to write an oversized AWARE maintenance marker.");
77379
+ await io.mkdir(directory, { recursive: true, mode: 448 });
77380
+ const temp = (0, import_node_path43.join)(directory, `.${(0, import_node_path43.basename)(markerPath2)}.${randomId()}.tmp`);
77381
+ try {
77382
+ await io.writeFile(temp, bytes, { encoding: "utf8", flag: "wx", mode: 384 });
77383
+ await io.rename(temp, markerPath2);
77384
+ await io.chmod(markerPath2, 384);
77385
+ } finally {
77386
+ await io.rm(temp, { force: true }).catch(() => {
77387
+ });
77388
+ }
77389
+ },
77390
+ async clear() {
77391
+ await io.rm(markerPath2, { force: true });
77392
+ },
77393
+ async quarantine() {
77394
+ const quarantinePath = `${markerPath2}.corrupt`;
77395
+ await io.rm(quarantinePath, { force: true });
77396
+ await io.rename(markerPath2, quarantinePath);
77397
+ await io.chmod(quarantinePath, 384);
77398
+ }
77399
+ };
77400
+ }
77401
+ function sanitizeAwareError(error, fallbackCode = "operation-failed") {
77402
+ const raw = error instanceof Error ? error.message : String(error);
77403
+ const code = typeof error?.code === "string" ? error.code.toLowerCase().replace(/[^a-z0-9_-]/g, "").slice(0, 48) : fallbackCode;
77404
+ const message = raw.replace(/https?:\/\/[^\s]+/gi, "[url removed]").replace(/(?:token|password|secret|authorization)\s*[:=]\s*\S+/gi, "$1=[redacted]").replace(/[A-Za-z]:\\(?:[^\\\s]+\\)*[^\\\s]*/g, "[path removed]").replace(/\/(?:Users|home)\/[^\s]+/g, "[path removed]").replace(/\s+/g, " ").trim().slice(0, 240);
77405
+ return {
77406
+ code: code || fallbackCode,
77407
+ message: message || "The AWARE operation failed."
77408
+ };
77409
+ }
76874
77410
  var _v = null;
76875
77411
  function awareInstalledVersion(probe = aware.npmVersion) {
76876
77412
  const now = Date.now();
@@ -76891,12 +77427,44 @@ function versionGt2(a, b) {
76891
77427
  return false;
76892
77428
  }
76893
77429
  function decideAwareUpdate(cur, latest) {
76894
- const base = { supported: true, currentVersion: cur };
77430
+ const base = {
77431
+ supported: true,
77432
+ currentVersion: cur,
77433
+ operation: "none",
77434
+ bridges: Object.freeze([])
77435
+ };
76895
77436
  if (!latest) return { ...base, updateAvailable: false, reason: "could not read the npm registry latest" };
76896
77437
  if (!cur) return { ...base, updateAvailable: false, targetVersion: latest, reason: "AWARE not installed yet" };
76897
- if (versionGt2(latest, cur)) return { ...base, updateAvailable: true, targetVersion: latest };
77438
+ if (versionGt2(latest, cur)) return { ...base, updateAvailable: true, targetVersion: latest, operation: "runtime-update" };
76898
77439
  return { ...base, updateAvailable: false, targetVersion: latest, reason: `already up to date (v${cur})` };
76899
77440
  }
77441
+ async function inspectPersistentBridgeInventory(bridgeDirectory, target) {
77442
+ const installed = await snapshotPersistentBridges(bridgeDirectory);
77443
+ const inventory = [];
77444
+ for (const host of installed) {
77445
+ const version = await persistentBridgeVersion(bridgeDirectory, host);
77446
+ inventory.push(Object.freeze({
77447
+ host,
77448
+ version,
77449
+ status: version == null ? "unverifiable" : version === target ? "current" : "stale"
77450
+ }));
77451
+ }
77452
+ return Object.freeze(inventory);
77453
+ }
77454
+ function applyBridgeInventory(decision, inventory) {
77455
+ const bridges = Object.freeze([...inventory]);
77456
+ if (decision.operation === "runtime-update") return { ...decision, bridges };
77457
+ const stale = bridges.filter((bridge) => bridge.status !== "current");
77458
+ if (!stale.length || !decision.currentVersion) return { ...decision, bridges };
77459
+ return {
77460
+ ...decision,
77461
+ updateAvailable: true,
77462
+ targetVersion: decision.currentVersion,
77463
+ operation: "bridge-repair",
77464
+ bridges,
77465
+ reason: `${stale.length} installed bridge${stale.length === 1 ? "" : "s"} need repair`
77466
+ };
77467
+ }
76900
77468
  async function fetchAwareLatest() {
76901
77469
  try {
76902
77470
  const res = await fetch(REGISTRY_LATEST, { redirect: "follow", signal: AbortSignal.timeout(FEED_TIMEOUT_MS2) });
@@ -76907,35 +77475,750 @@ async function fetchAwareLatest() {
76907
77475
  return null;
76908
77476
  }
76909
77477
  }
76910
- async function checkAwareUpdate() {
77478
+ async function checkAwareUpdate(bridgeDirectory) {
76911
77479
  const cur = awareInstalledVersion();
76912
77480
  const latest = await fetchAwareLatest();
76913
- return decideAwareUpdate(cur, latest);
77481
+ const decision = decideAwareUpdate(cur, latest);
77482
+ if (!bridgeDirectory || !cur || !isExactAwareTarget(cur)) return decision;
77483
+ try {
77484
+ return applyBridgeInventory(decision, await inspectPersistentBridgeInventory(bridgeDirectory, cur));
77485
+ } catch {
77486
+ return { ...decision, reason: "could not safely inspect installed AWARE bridges" };
77487
+ }
76914
77488
  }
76915
- async function applyAwareUpdate(deps) {
77489
+
77490
+ // aware-install-process.ts
77491
+ var import_node_child_process10 = require("node:child_process");
77492
+ var import_promises5 = require("node:fs/promises");
77493
+ var import_node_path44 = require("node:path");
77494
+ var import_node_util3 = require("node:util");
77495
+ var execFileAsync = (0, import_node_util3.promisify)(import_node_child_process10.execFile);
77496
+ var DEFAULT_INSTALL_TIMEOUT_MS = 10 * 6e4;
77497
+ var TAIL_BYTES = 4e3;
77498
+ function abortError2() {
77499
+ const error = new Error("AWARE install was cancelled or timed out");
77500
+ error.name = "AbortError";
77501
+ return error;
77502
+ }
77503
+ function killTree2(child) {
77504
+ if (process.platform === "win32" && child.pid) {
77505
+ try {
77506
+ (0, import_node_child_process10.execFileSync)("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
77507
+ stdio: "ignore",
77508
+ windowsHide: true,
77509
+ timeout: 1e4
77510
+ });
77511
+ return;
77512
+ } catch {
77513
+ }
77514
+ }
76916
77515
  try {
76917
- await deps.install("latest");
76918
- deps.refresh();
76919
- invalidateAwareVersion();
76920
- return { ok: true, version: deps.probe() };
76921
- } catch (err2) {
76922
- return { ok: false, error: err2 instanceof Error ? err2.message : String(err2) };
77516
+ child.kill("SIGKILL");
77517
+ } catch {
76923
77518
  }
76924
77519
  }
76925
- function awareApplyDeps(install) {
76926
- return { install, refresh: refreshInvoker, probe: aware.npmVersion };
77520
+ function safeExecutableIdentity(value) {
77521
+ const name = (0, import_node_path44.basename)(value.trim()).replace(/[^A-Za-z0-9._-]/g, "").slice(0, 128);
77522
+ return name || "unknown";
76927
77523
  }
76928
- function awareUpgradeBlockReason(s) {
76929
- if (s.bootstrapInstalling || s.installInFlight) return "an AWARE install is already in progress \u2014 try again in a moment";
76930
- if (s.runActive) return "a workflow run is in progress \u2014 wait for it to finish before upgrading AWARE";
76931
- if (s.hostWatcherActive) return "a live trigger/watch session is using the host \u2014 stop it before upgrading AWARE";
76932
- return null;
77524
+ async function maintenanceChildIdentity(pid) {
77525
+ if (!Number.isSafeInteger(pid) || pid <= 0) throw new Error("installer child PID is invalid");
77526
+ if (process.platform === "win32") {
77527
+ const script = [
77528
+ `$p=Get-Process -Id ${pid} -ErrorAction Stop`,
77529
+ '[pscustomobject]@{start=("win:"+$p.StartTime.ToUniversalTime().Ticks);exe=[IO.Path]::GetFileName($p.Path)}|ConvertTo-Json -Compress'
77530
+ ].join(";");
77531
+ const { stdout } = await execFileAsync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
77532
+ windowsHide: true,
77533
+ timeout: 5e3,
77534
+ maxBuffer: 16384
77535
+ });
77536
+ const parsed = JSON.parse(stdout);
77537
+ if (typeof parsed.start !== "string" || typeof parsed.exe !== "string") {
77538
+ throw new Error("could not read installer child identity");
77539
+ }
77540
+ return {
77541
+ pid,
77542
+ startIdentity: parsed.start,
77543
+ executableIdentity: safeExecutableIdentity(parsed.exe)
77544
+ };
77545
+ }
77546
+ if (process.platform === "linux") {
77547
+ const [stat4, exe] = await Promise.all([
77548
+ (0, import_promises5.readFile)(`/proc/${pid}/stat`, "utf8"),
77549
+ (0, import_promises5.readlink)(`/proc/${pid}/exe`)
77550
+ ]);
77551
+ const close = stat4.lastIndexOf(")");
77552
+ const fields = stat4.slice(close + 2).split(/\s+/);
77553
+ const startTicks = fields[19];
77554
+ if (!startTicks || !/^\d+$/.test(startTicks)) throw new Error("could not read installer start ticks");
77555
+ return {
77556
+ pid,
77557
+ startIdentity: `linux:${startTicks}`,
77558
+ executableIdentity: safeExecutableIdentity(exe)
77559
+ };
77560
+ }
77561
+ throw new Error(`durable installer identity is unsupported on ${process.platform}`);
77562
+ }
77563
+ async function maintenanceChildMatches(identity) {
77564
+ try {
77565
+ const current = await maintenanceChildIdentity(identity.pid);
77566
+ return current.startIdentity === identity.startIdentity && current.executableIdentity.toLowerCase() === identity.executableIdentity.toLowerCase();
77567
+ } catch {
77568
+ return false;
77569
+ }
77570
+ }
77571
+ function installAwareGlobal(spec, onLine = () => {
77572
+ }, options = {}) {
77573
+ if (!/^(?:latest|(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))$/.test(spec)) {
77574
+ return Promise.reject(new Error("Refused an invalid AWARE install target."));
77575
+ }
77576
+ const externalSignal = options.signal;
77577
+ if (externalSignal?.aborted) return Promise.reject(abortError2());
77578
+ const ownController = externalSignal ? null : new AbortController();
77579
+ const signal = externalSignal ?? ownController.signal;
77580
+ const timeout = ownController ? setTimeout(() => ownController.abort(), DEFAULT_INSTALL_TIMEOUT_MS) : null;
77581
+ timeout?.unref?.();
77582
+ return new Promise((resolve11, reject) => {
77583
+ const child = (0, import_node_child_process10.spawn)("npm", ["i", "-g", `@aware-aeco/cli@${spec}`], {
77584
+ shell: process.platform === "win32",
77585
+ windowsHide: true
77586
+ });
77587
+ let stderrTail = "";
77588
+ let combinedTail = "";
77589
+ let aborted = signal.aborted;
77590
+ let settled = false;
77591
+ let identityFailed = null;
77592
+ let identityRecorded = Promise.resolve();
77593
+ const tail = (buffer, chunk) => (buffer + chunk).slice(-TAIL_BYTES);
77594
+ const finish = (error) => {
77595
+ if (settled) return;
77596
+ settled = true;
77597
+ if (timeout) clearTimeout(timeout);
77598
+ signal.removeEventListener("abort", onAbort);
77599
+ if (error) reject(error);
77600
+ else resolve11();
77601
+ };
77602
+ const onAbort = () => {
77603
+ aborted = true;
77604
+ killTree2(child);
77605
+ };
77606
+ signal.addEventListener("abort", onAbort, { once: true });
77607
+ if (signal.aborted) onAbort();
77608
+ child.stdout?.on("data", (data) => {
77609
+ const text3 = data.toString();
77610
+ combinedTail = tail(combinedTail, text3);
77611
+ onLine(text3.trimEnd());
77612
+ options.onLine?.(text3.trimEnd());
77613
+ });
77614
+ child.stderr?.on("data", (data) => {
77615
+ const text3 = data.toString();
77616
+ stderrTail = tail(stderrTail, text3);
77617
+ combinedTail = tail(combinedTail, text3);
77618
+ onLine(text3.trimEnd());
77619
+ options.onLine?.(text3.trimEnd());
77620
+ });
77621
+ child.on("spawn", () => {
77622
+ if (!child.pid || !options.onChild) return;
77623
+ identityRecorded = maintenanceChildIdentity(child.pid).then((identity) => options.onChild?.(identity)).then(() => {
77624
+ }).catch((error) => {
77625
+ identityFailed = error;
77626
+ killTree2(child);
77627
+ });
77628
+ });
77629
+ child.on("error", (error) => finish(error));
77630
+ child.on("close", async (code) => {
77631
+ await identityRecorded;
77632
+ if (identityFailed) return finish(identityFailed);
77633
+ if (aborted) return finish(abortError2());
77634
+ if (code === 0) return finish();
77635
+ return finish(new Error(`npm exited ${code}: ${stderrTail || combinedTail}`));
77636
+ });
77637
+ });
77638
+ }
77639
+
77640
+ // aware-update-jobs.ts
77641
+ var AwareUpdateConflictError = class extends Error {
77642
+ status = 409;
77643
+ };
77644
+ var AwareUpdateNotFoundError = class extends Error {
77645
+ status = 404;
77646
+ };
77647
+ var AwareUpdateGoneError = class extends Error {
77648
+ status = 410;
77649
+ };
77650
+ var DEFAULT_OPERATION_TIMEOUT = 10 * 6e4;
77651
+ var DEFAULT_JOB_TIMEOUT = 30 * 6e4;
77652
+ var DEFAULT_RETENTION_TTL = 30 * 6e4;
77653
+ var DEFAULT_MAX_RETAINED = 24;
77654
+ function frozenHosts(hosts) {
77655
+ return Object.freeze([...hosts]);
77656
+ }
77657
+ function frozenFailures(failures) {
77658
+ return Object.freeze([...failures].map((failure) => Object.freeze({ ...failure })));
77659
+ }
77660
+ function isTerminal(status) {
77661
+ return status.state === "success" || status.state === "partial" || status.state === "runtime-failed";
77662
+ }
77663
+ function timeoutFailure(host) {
77664
+ return { host, code: "timed-out", message: `Refreshing the ${host} bridge timed out.` };
77665
+ }
77666
+ function notAttemptedFailure(host) {
77667
+ return { host, code: "not-attempted", message: `The ${host} bridge was not attempted before the update deadline.` };
77668
+ }
77669
+ function cloneStatus(status) {
77670
+ if (status.state === "runtime-failed") return { ...status };
77671
+ if (status.state === "running") return { ...status, updated: frozenHosts(status.updated) };
77672
+ if (status.state === "success") return { ...status, updated: frozenHosts(status.updated) };
77673
+ return {
77674
+ ...status,
77675
+ updated: frozenHosts(status.updated),
77676
+ failed: frozenFailures(status.failed)
77677
+ };
77678
+ }
77679
+ var DeadlineError = class extends Error {
77680
+ code = "timed-out";
77681
+ constructor(message = "The AWARE update timed out.") {
77682
+ super(message);
77683
+ }
77684
+ };
77685
+ function remaining(deadline, now) {
77686
+ return Math.max(0, deadline - now());
77687
+ }
77688
+ async function bounded(operation, budgetMs, parentSignal) {
77689
+ if (budgetMs <= 0) throw new DeadlineError();
77690
+ const controller = new AbortController();
77691
+ let timedOut = false;
77692
+ const signal = parentSignal ? AbortSignal.any([controller.signal, parentSignal]) : controller.signal;
77693
+ const timer = setTimeout(() => {
77694
+ timedOut = true;
77695
+ controller.abort(new DeadlineError());
77696
+ }, budgetMs);
77697
+ timer.unref?.();
77698
+ try {
77699
+ const result = await operation(signal);
77700
+ if (timedOut || parentSignal?.aborted) throw new DeadlineError();
77701
+ return result;
77702
+ } catch (error) {
77703
+ if (timedOut || signal.aborted) throw new DeadlineError();
77704
+ throw error;
77705
+ } finally {
77706
+ clearTimeout(timer);
77707
+ }
77708
+ }
77709
+ var AwareUpdateJobManager = class {
77710
+ #jobs = /* @__PURE__ */ new Map();
77711
+ #gone = /* @__PURE__ */ new Map();
77712
+ #deps;
77713
+ #active = null;
77714
+ #starting = null;
77715
+ #retrying = null;
77716
+ #requestStarts = /* @__PURE__ */ new Map();
77717
+ #requestTransactions = /* @__PURE__ */ new Map();
77718
+ constructor(deps) {
77719
+ this.#deps = deps;
77720
+ }
77721
+ async start(requestId) {
77722
+ this.#purge();
77723
+ if (requestId) {
77724
+ const transaction = this.#requestTransactions.get(requestId);
77725
+ if (transaction) return this.get(transaction);
77726
+ const existing = this.#requestStarts.get(requestId);
77727
+ if (existing) return cloneStatus(await existing);
77728
+ }
77729
+ if (this.#active || this.#starting || this.#retrying) throw new AwareUpdateConflictError("An AWARE update is already in progress.");
77730
+ const starting = this.#begin();
77731
+ this.#starting = starting;
77732
+ if (requestId) this.#requestStarts.set(requestId, starting);
77733
+ try {
77734
+ const status = await starting;
77735
+ if (requestId) this.#requestTransactions.set(requestId, status.transaction);
77736
+ return status;
77737
+ } finally {
77738
+ if (this.#starting === starting) this.#starting = null;
77739
+ if (requestId && this.#requestStarts.get(requestId) === starting) this.#requestStarts.delete(requestId);
77740
+ }
77741
+ }
77742
+ async #begin() {
77743
+ const target = requireExactAwareTarget(await this.#deps.resolveCurrentTarget());
77744
+ if (this.#active || this.#retrying) throw new AwareUpdateConflictError("An AWARE update is already in progress.");
77745
+ const transaction = (this.#deps.randomId ?? cryptoRandomId)();
77746
+ const status = {
77747
+ state: "running",
77748
+ transaction,
77749
+ stage: "queued",
77750
+ target,
77751
+ completed: 0,
77752
+ total: 0,
77753
+ updated: frozenHosts([])
77754
+ };
77755
+ const startedAt = this.#now();
77756
+ this.#jobs.set(transaction, { status, snapshot: frozenHosts([]), startedAt, touchedAt: startedAt });
77757
+ this.#active = transaction;
77758
+ void this.#execute(transaction).catch((error) => this.#unexpectedFailure(transaction, error));
77759
+ return cloneStatus(status);
77760
+ }
77761
+ get(transaction) {
77762
+ this.#purge();
77763
+ const record2 = this.#jobs.get(transaction);
77764
+ if (record2) {
77765
+ record2.touchedAt = this.#now();
77766
+ return cloneStatus(record2.status);
77767
+ }
77768
+ if (this.#gone.has(transaction)) throw new AwareUpdateGoneError("This AWARE update result has expired.");
77769
+ throw new AwareUpdateNotFoundError("AWARE update transaction not found.");
77770
+ }
77771
+ async retry(transaction, hostValue) {
77772
+ this.#purge();
77773
+ if (!AWARE_BRIDGE_HOSTS.includes(hostValue)) {
77774
+ throw new AwareUpdateNotFoundError("AWARE bridge host not found.");
77775
+ }
77776
+ const host = hostValue;
77777
+ const record2 = this.#jobs.get(transaction);
77778
+ if (!record2) {
77779
+ if (this.#gone.has(transaction)) throw new AwareUpdateGoneError("This AWARE update result has expired.");
77780
+ throw new AwareUpdateNotFoundError("AWARE update transaction not found.");
77781
+ }
77782
+ if (record2.retry) {
77783
+ if (record2.retry.host !== host) throw new AwareUpdateConflictError("Another bridge retry is already in progress.");
77784
+ return cloneStatus(await record2.retry.reserved);
77785
+ }
77786
+ if (this.#active || this.#starting || this.#retrying) {
77787
+ throw new AwareUpdateConflictError("An AWARE update is already in progress.");
77788
+ }
77789
+ if (record2.status.state !== "partial" || !record2.snapshot.includes(host) || !record2.status.failed.some((failure) => failure.host === host)) {
77790
+ throw new AwareUpdateConflictError("That bridge is not retryable for this update transaction.");
77791
+ }
77792
+ let resolveReserved;
77793
+ let rejectReserved;
77794
+ const reserved = new Promise((resolve11, reject) => {
77795
+ resolveReserved = resolve11;
77796
+ rejectReserved = reject;
77797
+ });
77798
+ record2.retry = { host, reserved };
77799
+ this.#retrying = transaction;
77800
+ void this.#executeRetry(record2, host, resolveReserved, rejectReserved).catch(() => {
77801
+ });
77802
+ return cloneStatus(await reserved);
77803
+ }
77804
+ async #execute(transaction) {
77805
+ const record2 = this.#jobs.get(transaction);
77806
+ if (!record2 || record2.status.state !== "running") return;
77807
+ const started = this.#now();
77808
+ const jobBudget = this.#deps.jobTimeoutMs ?? DEFAULT_JOB_TIMEOUT;
77809
+ const deadline = started + jobBudget;
77810
+ const jobController = new AbortController();
77811
+ const jobTimer = setTimeout(() => jobController.abort(new DeadlineError()), jobBudget);
77812
+ jobTimer.unref?.();
77813
+ try {
77814
+ await this.#deps.withExclusive(async (owner2) => this.#deps.withMutationContainment(transaction, owner2, async () => {
77815
+ this.#running(record2, "snapshot", 0, 0, []);
77816
+ const snapshot = await this.#deps.snapshotPersistentBridges(owner2, record2.status.target);
77817
+ this.#assertSnapshot(snapshot);
77818
+ record2.snapshot = frozenHosts(snapshot);
77819
+ this.#running(record2, "runtime-install", 0, snapshot.length, []);
77820
+ let marker = {
77821
+ schema: 1,
77822
+ transaction,
77823
+ stage: "runtime-install",
77824
+ target: record2.status.target,
77825
+ snapshot: record2.snapshot
77826
+ };
77827
+ await this.#deps.maintenance.write(marker);
77828
+ let observed = null;
77829
+ let runtimeVerified = false;
77830
+ try {
77831
+ const installedBefore = await this.#deps.probeRuntime(owner2);
77832
+ if (installedBefore !== record2.status.target) {
77833
+ await bounded(
77834
+ (signal) => this.#deps.installRuntime(record2.status.target, {
77835
+ owner: owner2,
77836
+ signal,
77837
+ childStarted: async (child) => {
77838
+ marker = { ...marker, child };
77839
+ await this.#deps.maintenance.write(marker);
77840
+ }
77841
+ }),
77842
+ Math.min(this.#operationBudget(), remaining(deadline, () => this.#now())),
77843
+ jobController.signal
77844
+ );
77845
+ }
77846
+ this.#running(record2, "runtime-verify", 0, snapshot.length, []);
77847
+ marker = { ...marker, stage: "runtime-verify", child: void 0 };
77848
+ await this.#deps.maintenance.write(marker);
77849
+ await this.#deps.refreshRuntime(owner2);
77850
+ this.#deps.invalidateVersion();
77851
+ observed = await this.#deps.probeRuntime(owner2);
77852
+ if (observed !== record2.status.target) {
77853
+ throw Object.assign(new Error("The installed AWARE version did not match the confirmed update target."), { code: "version-mismatch" });
77854
+ }
77855
+ const smoke = await bounded(
77856
+ (signal) => this.#deps.smokeRuntime(owner2, signal),
77857
+ Math.min(this.#operationBudget(), remaining(deadline, () => this.#now())),
77858
+ jobController.signal
77859
+ );
77860
+ if (!smoke) throw Object.assign(new Error("AWARE installed but did not pass its readiness check."), { code: "smoke-failed" });
77861
+ runtimeVerified = true;
77862
+ const updated = [];
77863
+ const failed = [];
77864
+ for (let index = 0; index < snapshot.length; index++) {
77865
+ const host = snapshot[index];
77866
+ if (remaining(deadline, () => this.#now()) <= 0) {
77867
+ failed.push(notAttemptedFailure(host));
77868
+ for (const rest of snapshot.slice(index + 1)) failed.push(notAttemptedFailure(rest));
77869
+ break;
77870
+ }
77871
+ this.#running(record2, "bridge-install", index, snapshot.length, updated);
77872
+ marker = { ...marker, stage: "bridge-install", host, child: void 0 };
77873
+ await this.#deps.maintenance.write(marker);
77874
+ try {
77875
+ await this.#deps.withSidecarMutation(owner2, async () => {
77876
+ await bounded(
77877
+ (signal) => this.#deps.installBridge(host, record2.status.target, {
77878
+ owner: owner2,
77879
+ signal,
77880
+ childStarted: async (child) => {
77881
+ marker = { ...marker, child };
77882
+ await this.#deps.maintenance.write(marker);
77883
+ }
77884
+ }),
77885
+ Math.min(this.#operationBudget(), remaining(deadline, () => this.#now())),
77886
+ jobController.signal
77887
+ );
77888
+ this.#running(record2, "bridge-verify", index, snapshot.length, updated);
77889
+ marker = { ...marker, stage: "bridge-verify", child: void 0 };
77890
+ await this.#deps.maintenance.write(marker);
77891
+ const verified = await bounded(
77892
+ (signal) => this.#deps.verifyBridge(host, record2.status.target, owner2, signal),
77893
+ Math.min(this.#operationBudget(), remaining(deadline, () => this.#now())),
77894
+ jobController.signal
77895
+ );
77896
+ if (!verified) throw Object.assign(new Error(`The ${host} bridge version could not be verified.`), { code: "bridge-version-mismatch" });
77897
+ });
77898
+ updated.push(host);
77899
+ } catch (error) {
77900
+ const failure = error instanceof DeadlineError ? timeoutFailure(host) : { host, ...sanitizeAwareError(error, "bridge-update-failed") };
77901
+ failed.push(failure);
77902
+ this.#log(record2, "bridge-update", failure, host);
77903
+ if (error instanceof DeadlineError) {
77904
+ for (const rest of snapshot.slice(index + 1)) failed.push(notAttemptedFailure(rest));
77905
+ break;
77906
+ }
77907
+ }
77908
+ }
77909
+ this.#finishBridges(record2, observed, updated, failed);
77910
+ } catch (error) {
77911
+ await Promise.resolve(this.#deps.refreshRuntime(owner2)).catch(() => {
77912
+ });
77913
+ this.#deps.invalidateVersion();
77914
+ observed = await Promise.resolve(this.#deps.probeRuntime(owner2)).catch(() => observed);
77915
+ const safe2 = sanitizeAwareError(error, error instanceof DeadlineError ? "timed-out" : "runtime-update-failed");
77916
+ this.#log(record2, "runtime-update", safe2);
77917
+ this.#setTerminal(record2, {
77918
+ state: "runtime-failed",
77919
+ transaction,
77920
+ target: record2.status.target,
77921
+ ...observed ? { observedVersion: observed } : {},
77922
+ ...safe2
77923
+ });
77924
+ } finally {
77925
+ if (runtimeVerified) {
77926
+ await this.#deps.maintenance.clear().catch((error) => {
77927
+ this.#log(record2, "marker-clear", sanitizeAwareError(error, "marker-clear-failed"));
77928
+ });
77929
+ }
77930
+ }
77931
+ }), { signal: jobController.signal });
77932
+ } finally {
77933
+ clearTimeout(jobTimer);
77934
+ if (this.#active === transaction) this.#active = null;
77935
+ this.#purge();
77936
+ }
77937
+ }
77938
+ async #executeRetry(record2, host, resolveReserved, rejectReserved) {
77939
+ let reserved = false;
77940
+ const retryController = new AbortController();
77941
+ const retryTimer = setTimeout(
77942
+ () => retryController.abort(new DeadlineError("The AWARE bridge retry timed out.")),
77943
+ this.#operationBudget()
77944
+ );
77945
+ retryTimer.unref?.();
77946
+ try {
77947
+ await this.#deps.withExclusive(async (owner2) => {
77948
+ await this.#deps.withMutationContainment(record2.status.transaction, owner2, async () => {
77949
+ await this.#deps.withSidecarMutation(owner2, async () => {
77950
+ const status = record2.status;
77951
+ if (status.state !== "partial" || !status.failed.some((failure) => failure.host === host)) {
77952
+ throw new AwareUpdateConflictError("That bridge is no longer retryable.");
77953
+ }
77954
+ const current = await this.#deps.probeRuntime(owner2);
77955
+ const healthy = current === status.target && await bounded((signal) => this.#deps.smokeRuntime(owner2, signal), this.#operationBudget(), retryController.signal);
77956
+ if (!healthy || current !== status.observedVersion) {
77957
+ throw new AwareUpdateConflictError("This update was superseded by the currently installed AWARE runtime.");
77958
+ }
77959
+ const otherFailures = status.failed.filter((failure) => failure.host !== host);
77960
+ record2.status = {
77961
+ state: "retrying",
77962
+ transaction: status.transaction,
77963
+ target: status.target,
77964
+ host,
77965
+ completed: status.updated.length,
77966
+ total: record2.snapshot.length,
77967
+ updated: status.updated,
77968
+ failed: frozenFailures(otherFailures)
77969
+ };
77970
+ reserved = true;
77971
+ resolveReserved(cloneStatus(record2.status));
77972
+ let marker = {
77973
+ schema: 1,
77974
+ transaction: status.transaction,
77975
+ stage: "retry-install",
77976
+ target: status.target,
77977
+ host,
77978
+ snapshot: record2.snapshot
77979
+ };
77980
+ try {
77981
+ await this.#deps.maintenance.write(marker);
77982
+ await bounded(
77983
+ (signal) => this.#deps.installBridge(host, status.target, {
77984
+ owner: owner2,
77985
+ signal,
77986
+ childStarted: async (child) => {
77987
+ marker = { ...marker, child };
77988
+ await this.#deps.maintenance.write(marker);
77989
+ }
77990
+ }),
77991
+ this.#operationBudget(),
77992
+ retryController.signal
77993
+ );
77994
+ marker = { ...marker, stage: "retry-verify", child: void 0 };
77995
+ await this.#deps.maintenance.write(marker);
77996
+ const verified = await bounded(
77997
+ (signal) => this.#deps.verifyBridge(host, status.target, owner2, signal),
77998
+ this.#operationBudget(),
77999
+ retryController.signal
78000
+ );
78001
+ if (!verified) throw Object.assign(new Error(`The ${host} bridge version could not be verified.`), { code: "bridge-version-mismatch" });
78002
+ const updatedSet = /* @__PURE__ */ new Set([...status.updated, host]);
78003
+ const updated = frozenHosts(record2.snapshot.filter((candidate) => updatedSet.has(candidate)));
78004
+ if (otherFailures.length) {
78005
+ this.#setTerminal(record2, {
78006
+ state: "partial",
78007
+ transaction: status.transaction,
78008
+ target: status.target,
78009
+ observedVersion: status.observedVersion,
78010
+ updated,
78011
+ failed: frozenFailures(otherFailures)
78012
+ });
78013
+ } else {
78014
+ this.#setTerminal(record2, {
78015
+ state: "success",
78016
+ transaction: status.transaction,
78017
+ target: status.target,
78018
+ observedVersion: status.observedVersion,
78019
+ updated
78020
+ });
78021
+ }
78022
+ } catch (error) {
78023
+ const failure = error instanceof DeadlineError ? timeoutFailure(host) : { host, ...sanitizeAwareError(error, "bridge-update-failed") };
78024
+ this.#log(record2, "bridge-retry", failure, host);
78025
+ this.#setTerminal(record2, {
78026
+ state: "partial",
78027
+ transaction: status.transaction,
78028
+ target: status.target,
78029
+ observedVersion: status.observedVersion,
78030
+ updated: status.updated,
78031
+ failed: frozenFailures([...otherFailures, failure])
78032
+ });
78033
+ } finally {
78034
+ await this.#deps.maintenance.clear().catch((error) => {
78035
+ this.#log(record2, "marker-clear", sanitizeAwareError(error, "marker-clear-failed"));
78036
+ });
78037
+ }
78038
+ });
78039
+ });
78040
+ }, { signal: retryController.signal });
78041
+ } catch (error) {
78042
+ if (!reserved) rejectReserved(error);
78043
+ } finally {
78044
+ clearTimeout(retryTimer);
78045
+ record2.retry = void 0;
78046
+ if (this.#retrying === record2.status.transaction) this.#retrying = null;
78047
+ }
78048
+ }
78049
+ #finishBridges(record2, observedVersion, updated, failed) {
78050
+ if (updated.length + failed.length !== record2.snapshot.length) {
78051
+ throw new Error("AWARE bridge update did not partition its immutable snapshot.");
78052
+ }
78053
+ if (failed.length) {
78054
+ this.#setTerminal(record2, {
78055
+ state: "partial",
78056
+ transaction: record2.status.transaction,
78057
+ target: record2.status.target,
78058
+ observedVersion,
78059
+ updated: frozenHosts(updated),
78060
+ failed: frozenFailures(failed)
78061
+ });
78062
+ } else {
78063
+ this.#setTerminal(record2, {
78064
+ state: "success",
78065
+ transaction: record2.status.transaction,
78066
+ target: record2.status.target,
78067
+ observedVersion,
78068
+ updated: frozenHosts(updated)
78069
+ });
78070
+ }
78071
+ }
78072
+ #running(record2, stage, completed, total, updated) {
78073
+ record2.status = {
78074
+ state: "running",
78075
+ transaction: record2.status.transaction,
78076
+ target: record2.status.target,
78077
+ stage,
78078
+ completed,
78079
+ total,
78080
+ updated: frozenHosts(updated)
78081
+ };
78082
+ record2.touchedAt = this.#now();
78083
+ }
78084
+ #setTerminal(record2, status) {
78085
+ record2.status = { ...status, durationMs: Math.max(0, this.#now() - record2.startedAt) };
78086
+ record2.terminalAt = this.#now();
78087
+ record2.touchedAt = record2.terminalAt;
78088
+ }
78089
+ #unexpectedFailure(transaction, error) {
78090
+ const record2 = this.#jobs.get(transaction);
78091
+ if (!record2 || isTerminal(record2.status)) return;
78092
+ this.#setTerminal(record2, {
78093
+ state: "runtime-failed",
78094
+ transaction,
78095
+ target: record2.status.target,
78096
+ ...sanitizeAwareError(error, "internal-update-failed")
78097
+ });
78098
+ if (this.#active === transaction) this.#active = null;
78099
+ }
78100
+ #assertSnapshot(snapshot) {
78101
+ if (new Set(snapshot).size !== snapshot.length || snapshot.some((host) => !AWARE_BRIDGE_HOSTS.includes(host))) {
78102
+ throw new Error("The persistent bridge snapshot was invalid.");
78103
+ }
78104
+ }
78105
+ #operationBudget() {
78106
+ return this.#deps.operationTimeoutMs ?? DEFAULT_OPERATION_TIMEOUT;
78107
+ }
78108
+ #now() {
78109
+ return (this.#deps.now ?? Date.now)();
78110
+ }
78111
+ #log(record2, stage, error, host) {
78112
+ try {
78113
+ this.#deps.log?.({
78114
+ transaction: record2.status.transaction,
78115
+ stage,
78116
+ ...host ? { host } : {},
78117
+ ...error
78118
+ });
78119
+ } catch {
78120
+ }
78121
+ }
78122
+ #purge() {
78123
+ const now = this.#now();
78124
+ const ttl = this.#deps.retentionTtlMs ?? DEFAULT_RETENTION_TTL;
78125
+ const max2 = Math.max(1, this.#deps.maxRetainedJobs ?? DEFAULT_MAX_RETAINED);
78126
+ const terminal = [...this.#jobs.entries()].filter(([, record2]) => isTerminal(record2.status) && !record2.retry).sort((a, b) => a[1].touchedAt - b[1].touchedAt);
78127
+ for (const [id, record2] of terminal) {
78128
+ if ((record2.terminalAt ?? record2.touchedAt) + ttl <= now) this.#expire(id, now + ttl);
78129
+ }
78130
+ const survivors = [...this.#jobs.entries()].filter(([, record2]) => isTerminal(record2.status) && !record2.retry).sort((a, b) => a[1].touchedAt - b[1].touchedAt);
78131
+ while (survivors.length > max2) {
78132
+ const oldest = survivors.shift();
78133
+ if (oldest) this.#expire(oldest[0], now + ttl);
78134
+ }
78135
+ for (const [id, expires] of this.#gone) if (expires <= now) this.#gone.delete(id);
78136
+ while (this.#gone.size > max2) this.#gone.delete(this.#gone.keys().next().value);
78137
+ for (const [requestId, transaction] of this.#requestTransactions) {
78138
+ if (!this.#jobs.has(transaction) && !this.#gone.has(transaction)) this.#requestTransactions.delete(requestId);
78139
+ }
78140
+ }
78141
+ #expire(transaction, goneUntil) {
78142
+ if (transaction === this.#active) return;
78143
+ this.#jobs.delete(transaction);
78144
+ this.#gone.delete(transaction);
78145
+ this.#gone.set(transaction, goneUntil);
78146
+ }
78147
+ };
78148
+ function cryptoRandomId() {
78149
+ return globalThis.crypto.randomUUID();
78150
+ }
78151
+ async function recoverInterruptedAwareMaintenance(deps) {
78152
+ const read = await deps.maintenance.read();
78153
+ if (read.kind === "absent") return "clean";
78154
+ return deps.withRecoveryExclusive(async (owner2) => {
78155
+ if (read.kind === "corrupt") {
78156
+ if (await deps.anyInstallerTreeAlive()) {
78157
+ throw new Error("AWARE maintenance state is corrupt and an installer tree may still be running.");
78158
+ }
78159
+ await deps.maintenance.quarantine();
78160
+ if (!await deps.repairAndVerify(null, owner2)) {
78161
+ throw new Error("AWARE maintenance recovery could not verify a usable runtime and bridges.");
78162
+ }
78163
+ await deps.maintenance.clear();
78164
+ return "recovered";
78165
+ }
78166
+ if (await deps.matchingChildAlive(read.marker)) {
78167
+ throw new Error("An interrupted AWARE installer is still running.");
78168
+ }
78169
+ if (await deps.anyInstallerTreeAlive()) {
78170
+ throw new Error("An interrupted AWARE installer tree may still be running.");
78171
+ }
78172
+ if (!await deps.repairAndVerify({ ...read.marker, stage: "recovery", child: void 0 }, owner2)) {
78173
+ throw new Error("AWARE maintenance recovery could not verify a usable runtime and bridges.");
78174
+ }
78175
+ await deps.maintenance.clear();
78176
+ return "recovered";
78177
+ });
78178
+ }
78179
+
78180
+ // aware-update-routes.ts
78181
+ function sendRouteError(reply, error) {
78182
+ if (error instanceof AwareUpdateConflictError || error instanceof AwareUpdateGoneError || error instanceof AwareUpdateNotFoundError) {
78183
+ return reply.status(error.status).send({ ok: false, error: error.message });
78184
+ }
78185
+ return reply.status(400).send({ ok: false, error: sanitizeAwareError(error, "invalid-update-request").message });
78186
+ }
78187
+ function registerAwareUpdateRoutes(app, manager) {
78188
+ app.post("/api/aware/update/apply", async (request, reply) => {
78189
+ try {
78190
+ const value = request.headers["x-floless-request-id"];
78191
+ const requestId = typeof value === "string" && /^[a-zA-Z0-9-]{1,128}$/.test(value) ? value : void 0;
78192
+ const status = await manager.start(requestId);
78193
+ return reply.status(202).send({ ok: true, ...status });
78194
+ } catch (error) {
78195
+ return sendRouteError(reply, error);
78196
+ }
78197
+ });
78198
+ app.get("/api/aware/update/status/:transaction", async (request, reply) => {
78199
+ try {
78200
+ return reply.send({ ok: true, ...manager.get(request.params.transaction) });
78201
+ } catch (error) {
78202
+ return sendRouteError(reply, error);
78203
+ }
78204
+ });
78205
+ app.post(
78206
+ "/api/aware/update/status/:transaction/bridges/:host/retry",
78207
+ async (request, reply) => {
78208
+ try {
78209
+ const status = await manager.retry(request.params.transaction, request.params.host);
78210
+ return reply.status(202).send({ ok: true, ...status });
78211
+ } catch (error) {
78212
+ return sendRouteError(reply, error);
78213
+ }
78214
+ }
78215
+ );
76933
78216
  }
76934
78217
 
76935
78218
  // skill-sync.ts
76936
78219
  var import_node_fs48 = require("node:fs");
76937
78220
  var import_node_os25 = require("node:os");
76938
- var import_node_path43 = require("node:path");
78221
+ var import_node_path45 = require("node:path");
76939
78222
  var import_node_url4 = require("node:url");
76940
78223
  var import_yaml10 = __toESM(require_dist6(), 1);
76941
78224
 
@@ -76980,12 +78263,12 @@ function selectShippedSkillNames(names) {
76980
78263
  }
76981
78264
 
76982
78265
  // skill-sync.ts
76983
- var __dirname3 = (0, import_node_path43.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
78266
+ var __dirname3 = (0, import_node_path45.dirname)((0, import_node_url4.fileURLToPath)(__import_meta_url));
76984
78267
  function bundledSkillsRoot() {
76985
78268
  const candidates = [
76986
- (0, import_node_path43.join)(__dirname3, "skills"),
76987
- (0, import_node_path43.join)((0, import_node_path43.dirname)(process.execPath), "skills"),
76988
- (0, import_node_path43.join)(__dirname3, "..", ".claude", "skills")
78269
+ (0, import_node_path45.join)(__dirname3, "skills"),
78270
+ (0, import_node_path45.join)((0, import_node_path45.dirname)(process.execPath), "skills"),
78271
+ (0, import_node_path45.join)(__dirname3, "..", ".claude", "skills")
76989
78272
  ];
76990
78273
  return candidates.find((p) => (0, import_node_fs48.existsSync)(p)) ?? null;
76991
78274
  }
@@ -76996,9 +78279,9 @@ function targetConfigDirs() {
76996
78279
  }
76997
78280
  const home = (0, import_node_os25.homedir)();
76998
78281
  return [
76999
- { runtime: "claude", dir: (0, import_node_path43.join)(home, ".claude") },
77000
- { runtime: "codex", dir: (0, import_node_path43.join)(home, ".codex") },
77001
- { runtime: "opencode", dir: (0, import_node_path43.join)(home, ".opencode") }
78282
+ { runtime: "claude", dir: (0, import_node_path45.join)(home, ".claude") },
78283
+ { runtime: "codex", dir: (0, import_node_path45.join)(home, ".codex") },
78284
+ { runtime: "opencode", dir: (0, import_node_path45.join)(home, ".opencode") }
77002
78285
  ];
77003
78286
  }
77004
78287
  function skillVersion(skillMdPath) {
@@ -77049,7 +78332,7 @@ function bundledSkills(root4) {
77049
78332
  }
77050
78333
  const out = [];
77051
78334
  for (const name of entries2) {
77052
- const dir = (0, import_node_path43.join)(root4, name);
78335
+ const dir = (0, import_node_path45.join)(root4, name);
77053
78336
  let isDir = false;
77054
78337
  try {
77055
78338
  isDir = (0, import_node_fs48.statSync)(dir).isDirectory();
@@ -77057,7 +78340,7 @@ function bundledSkills(root4) {
77057
78340
  isDir = false;
77058
78341
  }
77059
78342
  if (!isDir) continue;
77060
- const v = skillVersion((0, import_node_path43.join)(dir, "SKILL.md"));
78343
+ const v = skillVersion((0, import_node_path45.join)(dir, "SKILL.md"));
77061
78344
  if (!v) continue;
77062
78345
  out.push({ name, dir, version: v });
77063
78346
  }
@@ -77071,10 +78354,10 @@ function syncSkills() {
77071
78354
  if (!skills.length) return results;
77072
78355
  for (const { runtime, dir: cfg } of targetConfigDirs()) {
77073
78356
  if (!(0, import_node_fs48.existsSync)(cfg)) continue;
77074
- const skillsDir = (0, import_node_path43.join)(cfg, "skills");
78357
+ const skillsDir = (0, import_node_path45.join)(cfg, "skills");
77075
78358
  for (const s of skills) {
77076
- const dest = (0, import_node_path43.join)(skillsDir, s.name);
77077
- const installedMd = (0, import_node_path43.join)(dest, "SKILL.md");
78359
+ const dest = (0, import_node_path45.join)(skillsDir, s.name);
78360
+ const installedMd = (0, import_node_path45.join)(dest, "SKILL.md");
77078
78361
  const installed = (0, import_node_fs48.existsSync)(installedMd) ? skillVersion(installedMd) : null;
77079
78362
  const action = decideAction(installed, s.version);
77080
78363
  if (action === "installed" || action === "updated") {
@@ -77094,19 +78377,19 @@ function syncSkills() {
77094
78377
 
77095
78378
  // watch.ts
77096
78379
  var import_node_os26 = require("node:os");
77097
- var import_node_path45 = require("node:path");
78380
+ var import_node_path47 = require("node:path");
77098
78381
  var import_node_fs49 = require("node:fs");
77099
78382
 
77100
78383
  // node_modules/chokidar/esm/index.js
77101
78384
  var import_fs2 = require("fs");
77102
- var import_promises6 = require("fs/promises");
78385
+ var import_promises8 = require("fs/promises");
77103
78386
  var import_events = require("events");
77104
78387
  var sysPath2 = __toESM(require("path"), 1);
77105
78388
 
77106
78389
  // node_modules/readdirp/esm/index.js
77107
- var import_promises4 = require("node:fs/promises");
78390
+ var import_promises6 = require("node:fs/promises");
77108
78391
  var import_node_stream4 = require("node:stream");
77109
- var import_node_path44 = require("node:path");
78392
+ var import_node_path46 = require("node:path");
77110
78393
  var EntryTypes = {
77111
78394
  FILE_TYPE: "files",
77112
78395
  DIR_TYPE: "directories",
@@ -77171,7 +78454,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
77171
78454
  const { root: root4, type } = opts;
77172
78455
  this._fileFilter = normalizeFilter(opts.fileFilter);
77173
78456
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
77174
- const statMethod = opts.lstat ? import_promises4.lstat : import_promises4.stat;
78457
+ const statMethod = opts.lstat ? import_promises6.lstat : import_promises6.stat;
77175
78458
  if (wantBigintFsStats) {
77176
78459
  this._stat = (path) => statMethod(path, { bigint: true });
77177
78460
  } else {
@@ -77181,7 +78464,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
77181
78464
  this._wantsDir = type ? DIR_TYPES.has(type) : false;
77182
78465
  this._wantsFile = type ? FILE_TYPES.has(type) : false;
77183
78466
  this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
77184
- this._root = (0, import_node_path44.resolve)(root4);
78467
+ this._root = (0, import_node_path46.resolve)(root4);
77185
78468
  this._isDirent = !opts.alwaysStat;
77186
78469
  this._statsProp = this._isDirent ? "dirent" : "stats";
77187
78470
  this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
@@ -77242,7 +78525,7 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
77242
78525
  async _exploreDir(path, depth) {
77243
78526
  let files2;
77244
78527
  try {
77245
- files2 = await (0, import_promises4.readdir)(path, this._rdOptions);
78528
+ files2 = await (0, import_promises6.readdir)(path, this._rdOptions);
77246
78529
  } catch (error) {
77247
78530
  this._onError(error);
77248
78531
  }
@@ -77250,10 +78533,10 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
77250
78533
  }
77251
78534
  async _formatEntry(dirent, path) {
77252
78535
  let entry2;
77253
- const basename9 = this._isDirent ? dirent.name : dirent;
78536
+ const basename11 = this._isDirent ? dirent.name : dirent;
77254
78537
  try {
77255
- const fullPath = (0, import_node_path44.resolve)((0, import_node_path44.join)(path, basename9));
77256
- entry2 = { path: (0, import_node_path44.relative)(this._root, fullPath), fullPath, basename: basename9 };
78538
+ const fullPath = (0, import_node_path46.resolve)((0, import_node_path46.join)(path, basename11));
78539
+ entry2 = { path: (0, import_node_path46.relative)(this._root, fullPath), fullPath, basename: basename11 };
77257
78540
  entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
77258
78541
  } catch (err2) {
77259
78542
  this._onError(err2);
@@ -77280,14 +78563,14 @@ var ReaddirpStream = class extends import_node_stream4.Readable {
77280
78563
  if (stats && stats.isSymbolicLink()) {
77281
78564
  const full = entry2.fullPath;
77282
78565
  try {
77283
- const entryRealPath = await (0, import_promises4.realpath)(full);
77284
- const entryRealPathStats = await (0, import_promises4.lstat)(entryRealPath);
78566
+ const entryRealPath = await (0, import_promises6.realpath)(full);
78567
+ const entryRealPathStats = await (0, import_promises6.lstat)(entryRealPath);
77285
78568
  if (entryRealPathStats.isFile()) {
77286
78569
  return "file";
77287
78570
  }
77288
78571
  if (entryRealPathStats.isDirectory()) {
77289
78572
  const len = entryRealPath.length;
77290
- if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path44.sep) {
78573
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path46.sep) {
77291
78574
  const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
77292
78575
  recursiveError.code = RECURSIVE_ERROR_CODE;
77293
78576
  return this._onError(recursiveError);
@@ -77324,7 +78607,7 @@ function readdirp(root4, options = {}) {
77324
78607
 
77325
78608
  // node_modules/chokidar/esm/handler.js
77326
78609
  var import_fs = require("fs");
77327
- var import_promises5 = require("fs/promises");
78610
+ var import_promises7 = require("fs/promises");
77328
78611
  var sysPath = __toESM(require("path"), 1);
77329
78612
  var import_os = require("os");
77330
78613
  var STR_DATA = "data";
@@ -77351,7 +78634,7 @@ var EVENTS = {
77351
78634
  };
77352
78635
  var EV = EVENTS;
77353
78636
  var THROTTLE_MODE_WATCH = "watch";
77354
- var statMethods = { lstat: import_promises5.lstat, stat: import_promises5.stat };
78637
+ var statMethods = { lstat: import_promises7.lstat, stat: import_promises7.stat };
77355
78638
  var KEY_LISTENERS = "listeners";
77356
78639
  var KEY_ERR = "errHandlers";
77357
78640
  var KEY_RAW = "rawEmitters";
@@ -77708,7 +78991,7 @@ var setFsWatchListener = (path, fullPath, options, handlers) => {
77708
78991
  cont.watcherUnusable = true;
77709
78992
  if (isWindows && error.code === "EPERM") {
77710
78993
  try {
77711
- const fd2 = await (0, import_promises5.open)(path, "r");
78994
+ const fd2 = await (0, import_promises7.open)(path, "r");
77712
78995
  await fd2.close();
77713
78996
  broadcastErr(error);
77714
78997
  } catch (err2) {
@@ -77792,9 +79075,9 @@ var NodeFsHandler = class {
77792
79075
  _watchWithNodeFs(path, listener) {
77793
79076
  const opts = this.fsw.options;
77794
79077
  const directory = sysPath.dirname(path);
77795
- const basename9 = sysPath.basename(path);
79078
+ const basename11 = sysPath.basename(path);
77796
79079
  const parent = this.fsw._getWatchedDir(directory);
77797
- parent.add(basename9);
79080
+ parent.add(basename11);
77798
79081
  const absolutePath = sysPath.resolve(path);
77799
79082
  const options = {
77800
79083
  persistent: opts.persistent
@@ -77804,7 +79087,7 @@ var NodeFsHandler = class {
77804
79087
  let closer;
77805
79088
  if (opts.usePolling) {
77806
79089
  const enableBin = opts.interval !== opts.binaryInterval;
77807
- options.interval = enableBin && isBinaryPath(basename9) ? opts.binaryInterval : opts.interval;
79090
+ options.interval = enableBin && isBinaryPath(basename11) ? opts.binaryInterval : opts.interval;
77808
79091
  closer = setFsWatchFileListener(path, absolutePath, options, {
77809
79092
  listener,
77810
79093
  rawEmitter: this.fsw._emitRaw
@@ -77826,18 +79109,18 @@ var NodeFsHandler = class {
77826
79109
  if (this.fsw.closed) {
77827
79110
  return;
77828
79111
  }
77829
- const dirname21 = sysPath.dirname(file);
77830
- const basename9 = sysPath.basename(file);
77831
- const parent = this.fsw._getWatchedDir(dirname21);
79112
+ const dirname22 = sysPath.dirname(file);
79113
+ const basename11 = sysPath.basename(file);
79114
+ const parent = this.fsw._getWatchedDir(dirname22);
77832
79115
  let prevStats = stats;
77833
- if (parent.has(basename9))
79116
+ if (parent.has(basename11))
77834
79117
  return;
77835
79118
  const listener = async (path, newStats) => {
77836
79119
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
77837
79120
  return;
77838
79121
  if (!newStats || newStats.mtimeMs === 0) {
77839
79122
  try {
77840
- const newStats2 = await (0, import_promises5.stat)(file);
79123
+ const newStats2 = await (0, import_promises7.stat)(file);
77841
79124
  if (this.fsw.closed)
77842
79125
  return;
77843
79126
  const at = newStats2.atimeMs;
@@ -77855,9 +79138,9 @@ var NodeFsHandler = class {
77855
79138
  prevStats = newStats2;
77856
79139
  }
77857
79140
  } catch (error) {
77858
- this.fsw._remove(dirname21, basename9);
79141
+ this.fsw._remove(dirname22, basename11);
77859
79142
  }
77860
- } else if (parent.has(basename9)) {
79143
+ } else if (parent.has(basename11)) {
77861
79144
  const at = newStats.atimeMs;
77862
79145
  const mt = newStats.mtimeMs;
77863
79146
  if (!at || at <= mt || mt !== prevStats.mtimeMs) {
@@ -77892,7 +79175,7 @@ var NodeFsHandler = class {
77892
79175
  this.fsw._incrReadyCount();
77893
79176
  let linkPath;
77894
79177
  try {
77895
- linkPath = await (0, import_promises5.realpath)(path);
79178
+ linkPath = await (0, import_promises7.realpath)(path);
77896
79179
  } catch (e) {
77897
79180
  this.fsw._emitReady();
77898
79181
  return true;
@@ -77983,7 +79266,7 @@ var NodeFsHandler = class {
77983
79266
  * @param realpath
77984
79267
  * @returns closer for the watcher instance.
77985
79268
  */
77986
- async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
79269
+ async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath3) {
77987
79270
  const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
77988
79271
  const tracked = parentDir.has(sysPath.basename(dir));
77989
79272
  if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
@@ -77994,7 +79277,7 @@ var NodeFsHandler = class {
77994
79277
  let throttler;
77995
79278
  let closer;
77996
79279
  const oDepth = this.fsw.options.depth;
77997
- if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath2)) {
79280
+ if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath3)) {
77998
79281
  if (!target) {
77999
79282
  await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
78000
79283
  if (this.fsw.closed)
@@ -78040,7 +79323,7 @@ var NodeFsHandler = class {
78040
79323
  let closer;
78041
79324
  if (stats.isDirectory()) {
78042
79325
  const absPath = sysPath.resolve(path);
78043
- const targetPath = follow ? await (0, import_promises5.realpath)(path) : path;
79326
+ const targetPath = follow ? await (0, import_promises7.realpath)(path) : path;
78044
79327
  if (this.fsw.closed)
78045
79328
  return;
78046
79329
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -78050,7 +79333,7 @@ var NodeFsHandler = class {
78050
79333
  this.fsw._symlinkPaths.set(absPath, targetPath);
78051
79334
  }
78052
79335
  } else if (stats.isSymbolicLink()) {
78053
- const targetPath = follow ? await (0, import_promises5.realpath)(path) : path;
79336
+ const targetPath = follow ? await (0, import_promises7.realpath)(path) : path;
78054
79337
  if (this.fsw.closed)
78055
79338
  return;
78056
79339
  const parent = sysPath.dirname(wh.watchPath);
@@ -78104,11 +79387,11 @@ function createPattern(matcher) {
78104
79387
  if (matcher.path === string)
78105
79388
  return true;
78106
79389
  if (matcher.recursive) {
78107
- const relative3 = sysPath2.relative(matcher.path, string);
78108
- if (!relative3) {
79390
+ const relative4 = sysPath2.relative(matcher.path, string);
79391
+ if (!relative4) {
78109
79392
  return false;
78110
79393
  }
78111
- return !relative3.startsWith("..") && !sysPath2.isAbsolute(relative3);
79394
+ return !relative4.startsWith("..") && !sysPath2.isAbsolute(relative4);
78112
79395
  }
78113
79396
  return false;
78114
79397
  };
@@ -78211,7 +79494,7 @@ var DirEntry = class {
78211
79494
  return;
78212
79495
  const dir = this.path;
78213
79496
  try {
78214
- await (0, import_promises6.readdir)(dir);
79497
+ await (0, import_promises8.readdir)(dir);
78215
79498
  } catch (err2) {
78216
79499
  if (this._removeWatcher) {
78217
79500
  this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
@@ -78536,7 +79819,7 @@ var FSWatcher = class extends import_events.EventEmitter {
78536
79819
  const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path) : path;
78537
79820
  let stats2;
78538
79821
  try {
78539
- stats2 = await (0, import_promises6.stat)(fullPath);
79822
+ stats2 = await (0, import_promises8.stat)(fullPath);
78540
79823
  } catch (err2) {
78541
79824
  }
78542
79825
  if (!stats2 || this.closed)
@@ -78795,19 +80078,19 @@ function appIdFromLogPath(path) {
78795
80078
  return i >= 0 && parts[i + 1] ? parts[i + 1] : null;
78796
80079
  }
78797
80080
  function samePath(a, b) {
78798
- const ra = (0, import_node_path45.resolve)(a);
78799
- const rb = (0, import_node_path45.resolve)(b);
80081
+ const ra = (0, import_node_path47.resolve)(a);
80082
+ const rb = (0, import_node_path47.resolve)(b);
78800
80083
  return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
78801
80084
  }
78802
80085
  function underDir(path, dir) {
78803
- const rp = (0, import_node_path45.resolve)(path);
78804
- const rd = (0, import_node_path45.resolve)(dir);
80086
+ const rp = (0, import_node_path47.resolve)(path);
80087
+ const rd = (0, import_node_path47.resolve)(dir);
78805
80088
  const [p, d] = process.platform === "win32" ? [rp.toLowerCase(), rd.toLowerCase()] : [rp, rd];
78806
- return p === d || p.startsWith(d + import_node_path45.sep);
80089
+ return p === d || p.startsWith(d + import_node_path47.sep);
78807
80090
  }
78808
80091
  function startWatcher() {
78809
- const awareDir = process.env.AWARE_HOME ?? (0, import_node_path45.join)((0, import_node_os26.homedir)(), ".aware");
78810
- const credentialsDir = (0, import_node_path45.join)(awareDir, "credentials");
80092
+ const awareDir = process.env.AWARE_HOME ?? (0, import_node_path47.join)((0, import_node_os26.homedir)(), ".aware");
80093
+ const credentialsDir = (0, import_node_path47.join)(awareDir, "credentials");
78811
80094
  if (!(0, import_node_fs49.existsSync)(credentialsDir)) {
78812
80095
  try {
78813
80096
  (0, import_node_fs49.mkdirSync)(credentialsDir, { recursive: true });
@@ -78820,7 +80103,7 @@ function startWatcher() {
78820
80103
  } catch {
78821
80104
  }
78822
80105
  }
78823
- const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path45.join)(awareDir, d)).filter((p) => (0, import_node_fs49.existsSync)(p));
80106
+ const targets = ["apps", "logs", "credentials"].map((d) => (0, import_node_path47.join)(awareDir, d)).filter((p) => (0, import_node_fs49.existsSync)(p));
78824
80107
  if ((0, import_node_fs49.existsSync)(uiDir)) targets.push(uiDir);
78825
80108
  if (targets.length === 0) {
78826
80109
  return null;
@@ -78854,7 +80137,7 @@ function startWatcher() {
78854
80137
  const id = appIdFromLogPath(path);
78855
80138
  if (!id) return;
78856
80139
  try {
78857
- broadcast({ type: "trace-file", id, runId: path.split(import_node_path45.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs49.readFileSync)(path, "utf8")) });
80140
+ broadcast({ type: "trace-file", id, runId: path.split(import_node_path47.sep).pop()?.replace(/\.jsonl$/, "") ?? null, events: parseTrace((0, import_node_fs49.readFileSync)(path, "utf8")) });
78858
80141
  } catch {
78859
80142
  }
78860
80143
  }
@@ -78863,10 +80146,10 @@ function startWatcher() {
78863
80146
  }
78864
80147
 
78865
80148
  // index.ts
78866
- var __dirname4 = (0, import_node_path46.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
78867
- var WEB_ROOT = [(0, import_node_path46.join)(__dirname4, "web"), (0, import_node_path46.join)((0, import_node_path46.dirname)(process.execPath), "web"), (0, import_node_path46.join)(__dirname4, "..", "web")].find(
80149
+ var __dirname4 = (0, import_node_path48.dirname)((0, import_node_url5.fileURLToPath)(__import_meta_url));
80150
+ var WEB_ROOT = [(0, import_node_path48.join)(__dirname4, "web"), (0, import_node_path48.join)((0, import_node_path48.dirname)(process.execPath), "web"), (0, import_node_path48.join)(__dirname4, "..", "web")].find(
78868
80151
  (p) => (0, import_node_fs50.existsSync)(p)
78869
- ) ?? (0, import_node_path46.join)(__dirname4, "..", "web");
80152
+ ) ?? (0, import_node_path48.join)(__dirname4, "..", "web");
78870
80153
  var PORT2 = Number(process.env.PORT ?? 4317);
78871
80154
  var HOST = "127.0.0.1";
78872
80155
  var crashHandlersInstalled = false;
@@ -78906,8 +80189,8 @@ async function startServer() {
78906
80189
  "lifecycle lock release FAILED \u2014 this resource will report busy until the app restarts"
78907
80190
  );
78908
80191
  });
78909
- for (const rename of await recoverPendingOriginRenames()) {
78910
- app.log.info({ rename }, "recovered interrupted workflow ownership rename");
80192
+ for (const rename2 of await recoverPendingOriginRenames()) {
80193
+ app.log.info({ rename: rename2 }, "recovered interrupted workflow ownership rename");
78911
80194
  }
78912
80195
  for (const duplicate of await recoverPendingOriginDuplicates()) {
78913
80196
  app.log.info({ duplicate }, "recovered interrupted workflow ownership duplicate");
@@ -78943,34 +80226,12 @@ async function startServer() {
78943
80226
  const isWin3 = process.platform === "win32";
78944
80227
  const has = (cmd) => {
78945
80228
  try {
78946
- (0, import_node_child_process10.execFileSync)(isWin3 ? "where" : "which", [cmd], { stdio: "ignore", windowsHide: true, timeout: 5e3 });
80229
+ (0, import_node_child_process11.execFileSync)(isWin3 ? "where" : "which", [cmd], { stdio: "ignore", windowsHide: true, timeout: 5e3 });
78947
80230
  return true;
78948
80231
  } catch {
78949
80232
  return false;
78950
80233
  }
78951
80234
  };
78952
- function installAwareGlobal(spec, onLine = () => {
78953
- }) {
78954
- return new Promise((resolve11, reject) => {
78955
- const child = (0, import_node_child_process10.spawn)("npm", ["i", "-g", `@aware-aeco/cli@${spec}`], { shell: isWin3, windowsHide: true });
78956
- let stderrTail = "";
78957
- let combinedTail = "";
78958
- const tail = (buf, s) => (buf + s).slice(-4e3);
78959
- child.stdout.on("data", (d) => {
78960
- const s = d.toString();
78961
- combinedTail = tail(combinedTail, s);
78962
- onLine(s.trimEnd());
78963
- });
78964
- child.stderr.on("data", (d) => {
78965
- const s = d.toString();
78966
- stderrTail = tail(stderrTail, s);
78967
- combinedTail = tail(combinedTail, s);
78968
- onLine(s.trimEnd());
78969
- });
78970
- child.on("error", (e) => reject(e));
78971
- child.on("close", (code) => code === 0 ? resolve11() : reject(new Error(`npm exited ${code}: ${stderrTail || combinedTail}`)));
78972
- });
78973
- }
78974
80235
  const bootstrapDeps = {
78975
80236
  probeToolchain: () => ({ hasNode: has("node"), hasNpm: has("npm") }),
78976
80237
  getAware: () => {
@@ -78984,6 +80245,153 @@ async function startServer() {
78984
80245
  floor: MIN_AWARE,
78985
80246
  skip: process.env.AWARE_SKIP_BOOTSTRAP === "1"
78986
80247
  };
80248
+ const AWARE_BRIDGE_DIRECTORY = (0, import_node_path48.join)((0, import_node_os27.homedir)(), ".aware", "bridges");
80249
+ const awareMaintenance = createMaintenanceMarkerStore(
80250
+ (0, import_node_path48.join)((0, import_node_os27.homedir)(), ".floless", "aware-maintenance.json")
80251
+ );
80252
+ function upgradeOwner() {
80253
+ const owner2 = currentAwareOwner();
80254
+ if (!owner2) throw new Error("AWARE updater is outside its exclusive lifecycle owner");
80255
+ return owner2;
80256
+ }
80257
+ async function recordSidecarChild(context, child) {
80258
+ if (!child.pid) throw new Error("AWARE sidecar installer did not expose a child PID");
80259
+ await context.childStarted(await maintenanceChildIdentity(child.pid));
80260
+ }
80261
+ function anyAwareInstallerTreeAlive() {
80262
+ if (process.platform !== "win32") return false;
80263
+ try {
80264
+ const script = [
80265
+ "$p=Get-CimInstance Win32_Process -ErrorAction Stop",
80266
+ "$m=$p|Where-Object {$_.ProcessId -ne $PID -and $_.CommandLine -match '@aware-aeco/cli@|aware(?:\\.cmd)?\\s+sidecar\\s+install'}",
80267
+ "if($m){Write-Output true}else{Write-Output false}"
80268
+ ].join(";");
80269
+ return (0, import_node_child_process11.execFileSync)("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
80270
+ encoding: "utf8",
80271
+ windowsHide: true,
80272
+ timeout: 5e3
80273
+ }).trim().toLowerCase() === "true";
80274
+ } catch {
80275
+ return true;
80276
+ }
80277
+ }
80278
+ const awareUpdateJobs = new AwareUpdateJobManager({
80279
+ resolveCurrentTarget: async () => {
80280
+ const marker = await awareMaintenance.read();
80281
+ if (marker.kind !== "absent") {
80282
+ throw Object.assign(new Error("An interrupted AWARE update must be recovered before starting another."), { code: "maintenance-pending" });
80283
+ }
80284
+ const check = await checkAwareUpdate(AWARE_BRIDGE_DIRECTORY);
80285
+ return check.updateAvailable ? check.targetVersion ?? null : null;
80286
+ },
80287
+ snapshotPersistentBridges: async (_owner, target) => {
80288
+ const inventory = await inspectPersistentBridgeInventory(AWARE_BRIDGE_DIRECTORY, target);
80289
+ return inventory.filter((bridge) => bridge.status !== "current").map((bridge) => bridge.host);
80290
+ },
80291
+ withExclusive: (work, options) => withAwareExclusive(
80292
+ () => work(upgradeOwner()),
80293
+ options?.signal
80294
+ ),
80295
+ // Dependency-free Node/SEA has no Windows Job Object API. Every spawned npm/
80296
+ // sidecar process is still abort/tree-kill/close awaited, while the durable
80297
+ // maintenance marker blocks startup recovery after an abrupt parent crash.
80298
+ withMutationContainment: async (_transaction, owner2, work) => {
80299
+ if (owner2 !== upgradeOwner()) throw new Error("AWARE mutation owner mismatch");
80300
+ return work();
80301
+ },
80302
+ withSidecarMutation: async (owner2, work) => {
80303
+ if (owner2 !== upgradeOwner()) throw new Error("AWARE sidecar owner mismatch");
80304
+ return withSidecarWrite(work);
80305
+ },
80306
+ installRuntime: (target, context) => installAwareGlobal(target, () => {
80307
+ }, {
80308
+ signal: context.signal,
80309
+ onChild: context.childStarted
80310
+ }),
80311
+ refreshRuntime: () => refreshInvoker(),
80312
+ invalidateVersion: invalidateAwareVersion,
80313
+ probeRuntime: () => aware.npmVersion(),
80314
+ smokeRuntime: async () => aware.smoke(),
80315
+ installBridge: async (host, _target, context) => {
80316
+ let identityRecorded = Promise.resolve();
80317
+ await aware.sidecarInstall(host, {
80318
+ signal: context.signal,
80319
+ onSpawn: (child) => {
80320
+ identityRecorded = recordSidecarChild(context, child);
80321
+ }
80322
+ });
80323
+ await identityRecorded;
80324
+ },
80325
+ verifyBridge: async (host, target) => await persistentBridgeVersion(AWARE_BRIDGE_DIRECTORY, host) === target,
80326
+ maintenance: awareMaintenance,
80327
+ log: (event) => app.log.info(event, "AWARE update transaction")
80328
+ });
80329
+ async function repairInterruptedAwareMaintenance(marker, owner2) {
80330
+ if (owner2 !== upgradeOwner()) return false;
80331
+ refreshInvoker();
80332
+ invalidateAwareVersion();
80333
+ let target = marker?.target ?? aware.npmVersion();
80334
+ if (!target || !/^\d+\.\d+\.\d+$/.test(target)) return false;
80335
+ let snapshot = marker?.snapshot ?? await snapshotPersistentBridges(AWARE_BRIDGE_DIRECTORY);
80336
+ let recoveryMarker = {
80337
+ schema: 1,
80338
+ transaction: marker?.transaction ?? (0, import_node_crypto24.randomUUID)(),
80339
+ stage: "recovery",
80340
+ target,
80341
+ snapshot
80342
+ };
80343
+ await awareMaintenance.write(recoveryMarker);
80344
+ if (aware.npmVersion() !== target) {
80345
+ await installAwareGlobal(target, () => {
80346
+ }, {
80347
+ onChild: async (child) => {
80348
+ recoveryMarker = { ...recoveryMarker, child };
80349
+ await awareMaintenance.write(recoveryMarker);
80350
+ }
80351
+ });
80352
+ refreshInvoker();
80353
+ invalidateAwareVersion();
80354
+ }
80355
+ if (aware.npmVersion() !== target || !await aware.smoke()) return false;
80356
+ for (const host of snapshot) {
80357
+ if (await persistentBridgeVersion(AWARE_BRIDGE_DIRECTORY, host) === target) continue;
80358
+ await withSidecarWrite(async () => {
80359
+ let childRecorded = Promise.resolve();
80360
+ await aware.sidecarInstall(host, {
80361
+ onSpawn: (child) => {
80362
+ if (!child.pid) throw new Error(`The ${host} bridge installer did not expose a child PID`);
80363
+ childRecorded = maintenanceChildIdentity(child.pid).then(async (identity) => {
80364
+ recoveryMarker = { ...recoveryMarker, host, child: identity };
80365
+ await awareMaintenance.write(recoveryMarker);
80366
+ });
80367
+ }
80368
+ });
80369
+ await childRecorded;
80370
+ if (await persistentBridgeVersion(AWARE_BRIDGE_DIRECTORY, host) !== target) {
80371
+ throw new Error(`The recovered ${host} bridge did not match AWARE ${target}`);
80372
+ }
80373
+ });
80374
+ }
80375
+ return true;
80376
+ }
80377
+ async function recoverAwareMaintenance() {
80378
+ return recoverInterruptedAwareMaintenance({
80379
+ maintenance: awareMaintenance,
80380
+ withRecoveryExclusive: (work) => withAwareExclusive(() => work(upgradeOwner())),
80381
+ matchingChildAlive: async (marker) => marker.child ? maintenanceChildMatches(marker.child) : false,
80382
+ anyInstallerTreeAlive: async () => anyAwareInstallerTreeAlive(),
80383
+ repairAndVerify: repairInterruptedAwareMaintenance
80384
+ });
80385
+ }
80386
+ async function startAwareBootstrap() {
80387
+ try {
80388
+ await recoverAwareMaintenance();
80389
+ } catch (error) {
80390
+ app.log.error({ err: error instanceof Error ? error.message : String(error) }, "AWARE maintenance recovery failed");
80391
+ return failBootstrapMaintenanceRecovery(bootstrapDeps);
80392
+ }
80393
+ return withAwareExclusive(() => runBootstrap(bootstrapDeps));
80394
+ }
78987
80395
  app.setErrorHandler((err2, req, reply) => {
78988
80396
  if (err2 instanceof AppNotFoundError) {
78989
80397
  return reply.status(404).send({ ok: false, error: err2.message });
@@ -79048,12 +80456,31 @@ async function startServer() {
79048
80456
  return reply.status(402).send({ ok: false, error: "subscription required", state: state2, reason, signInUrl: signInUrl2 });
79049
80457
  }
79050
80458
  });
79051
- app.addHook("onRequest", async (req, reply) => {
79052
- if (!isGatedAwareRoute(req.url, req.method)) return;
80459
+ app.addHook("onRequest", (req, reply, done) => {
80460
+ if (!isGatedAwareRoute(req.url, req.method)) {
80461
+ done();
80462
+ return;
80463
+ }
79053
80464
  const st = getBootstrapState();
79054
- if (st.status === "ready") return;
79055
- if (st.status === "failed") return reply.status(503).send({ ok: false, error: "AWARE unavailable", bootstrap: st.status, reason: st.reason, remediation: st.remediation });
79056
- return reply.status(409).send({ ok: false, error: "AWARE is still setting up", bootstrap: st.status });
80465
+ if (st.status === "ready") {
80466
+ void acquireAwareShared().then((lease) => {
80467
+ let released = false;
80468
+ const release = () => {
80469
+ if (released) return;
80470
+ released = true;
80471
+ lease.release();
80472
+ };
80473
+ reply.raw.once("finish", release);
80474
+ reply.raw.once("close", release);
80475
+ runAsAwareOwner(lease.owner, done);
80476
+ }, done);
80477
+ return;
80478
+ }
80479
+ if (st.status === "failed") {
80480
+ void reply.status(503).send({ ok: false, error: "AWARE unavailable", bootstrap: st.status, reason: st.reason, remediation: st.remediation });
80481
+ return;
80482
+ }
80483
+ void reply.status(409).send({ ok: false, error: "AWARE is still setting up", bootstrap: st.status });
79057
80484
  });
79058
80485
  app.get("/api/health", async () => {
79059
80486
  const bs = getBootstrapState();
@@ -79164,26 +80591,9 @@ async function startServer() {
79164
80591
  setTimeout(() => process.exit(0), 250);
79165
80592
  });
79166
80593
  app.get("/api/aware/update", async () => {
79167
- return { ok: true, ...await checkAwareUpdate() };
79168
- });
79169
- let awareInstallInFlight = false;
79170
- app.post("/api/aware/update/apply", async (_req, reply) => {
79171
- const block = awareUpgradeBlockReason({
79172
- bootstrapInstalling: getBootstrapState().status === "installing",
79173
- installInFlight: awareInstallInFlight,
79174
- runActive: isRunActive(),
79175
- hostWatcherActive: hostWatcherActive()
79176
- });
79177
- if (block) return reply.status(409).send({ ok: false, error: block });
79178
- awareInstallInFlight = true;
79179
- try {
79180
- const res = await applyAwareUpdate(awareApplyDeps(installAwareGlobal));
79181
- if (!res.ok) return reply.status(409).send({ ok: false, error: res.error ?? "aware upgrade failed" });
79182
- return { ok: true, version: res.version };
79183
- } finally {
79184
- awareInstallInFlight = false;
79185
- }
80594
+ return withAwareShared(async () => ({ ok: true, ...await checkAwareUpdate(AWARE_BRIDGE_DIRECTORY) }));
79186
80595
  });
80596
+ registerAwareUpdateRoutes(app, awareUpdateJobs);
79187
80597
  app.get("/api/release-notes", async (req, reply) => {
79188
80598
  const component = req.query.component === "aware" ? "aware" : "app";
79189
80599
  const version = typeof req.query.version === "string" ? req.query.version.trim().replace(/^v/, "") : "";
@@ -79194,7 +80604,7 @@ async function startServer() {
79194
80604
  app.post("/api/bootstrap/retry", async () => {
79195
80605
  const st = getBootstrapState().status;
79196
80606
  if (st === "failed" || st === "idle") {
79197
- void runBootstrap(bootstrapDeps);
80607
+ void startAwareBootstrap();
79198
80608
  }
79199
80609
  return { ok: true, bootstrap: getBootstrapState().status };
79200
80610
  });
@@ -79258,7 +80668,7 @@ async function startServer() {
79258
80668
  const bdir = backupDir(id, fromVersion, Date.now());
79259
80669
  let backedUp = false;
79260
80670
  try {
79261
- (0, import_node_fs50.mkdirSync)((0, import_node_path46.dirname)(bdir), { recursive: true });
80671
+ (0, import_node_fs50.mkdirSync)((0, import_node_path48.dirname)(bdir), { recursive: true });
79262
80672
  (0, import_node_fs50.cpSync)(appDirPath2, bdir, { recursive: true });
79263
80673
  backedUp = true;
79264
80674
  (0, import_node_fs50.cpSync)(templatePath, srcPath);
@@ -79429,7 +80839,7 @@ async function startServer() {
79429
80839
  });
79430
80840
  return { ok: true, id, flow, started: false };
79431
80841
  }
79432
- aware.connectOAuth(id, (result) => {
80842
+ await aware.connectOAuth(id, (result) => {
79433
80843
  const ok = result.status === "connected";
79434
80844
  broadcast({
79435
80845
  type: "connect-result",
@@ -79776,7 +81186,7 @@ async function startServer() {
79776
81186
  const bad = projectAppMismatch(req.params.appId, project);
79777
81187
  if (bad) return reply.status(404).send({ ok: false, error: bad });
79778
81188
  const safe2 = req.params.sheet.replace(/[^A-Za-z0-9._-]/g, "");
79779
- const file = (0, import_node_path46.join)((0, import_node_path46.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
81189
+ const file = (0, import_node_path48.join)((0, import_node_path48.dirname)(contractPath(req.params.appId, project)), "details", `${safe2}.svg`);
79780
81190
  if (!(0, import_node_fs50.existsSync)(file)) return reply.status(404).send({ ok: false, error: "no vector for this sheet" });
79781
81191
  return reply.type("image/svg+xml").send((0, import_node_fs50.readFileSync)(file, "utf8"));
79782
81192
  }
@@ -79943,7 +81353,7 @@ async function startServer() {
79943
81353
  }
79944
81354
  const statedAt = (filename) => {
79945
81355
  try {
79946
- const st = (0, import_node_fs50.statSync)((0, import_node_path46.join)(dir, filename));
81356
+ const st = (0, import_node_fs50.statSync)((0, import_node_path48.join)(dir, filename));
79947
81357
  return st.isFile() ? st.mtime.toISOString() : null;
79948
81358
  } catch {
79949
81359
  return null;
@@ -79953,14 +81363,14 @@ async function startServer() {
79953
81363
  const rows2 = (byKind.get(kind) ?? []).map((receipt) => ({
79954
81364
  variant: receipt.variant ?? null,
79955
81365
  filename: receipt.filename,
79956
- path: (0, import_node_path46.join)(dir, receipt.filename),
81366
+ path: (0, import_node_path48.join)(dir, receipt.filename),
79957
81367
  exportedAt: statedAt(receipt.filename)
79958
81368
  })).sort((a, b) => String(b.exportedAt ?? "").localeCompare(String(a.exportedAt ?? "")));
79959
81369
  const headline = rows2[0];
79960
81370
  return {
79961
81371
  kind,
79962
81372
  filename: headline?.filename ?? legacy,
79963
- path: headline?.path ?? (0, import_node_path46.join)(dir, legacy),
81373
+ path: headline?.path ?? (0, import_node_path48.join)(dir, legacy),
79964
81374
  exportedAt: headline?.exportedAt ?? null,
79965
81375
  ...rows2.length ? { variants: rows2 } : {}
79966
81376
  };
@@ -79987,8 +81397,8 @@ async function startServer() {
79987
81397
  async () => withLifecycleLock("app", `${appId}-3d`, async () => {
79988
81398
  let projectSnapshot;
79989
81399
  if (project) {
79990
- const gate = projectExportGate(appId, project);
79991
- if (gate) return reply.status(gate.status).send({ ok: false, error: gate.error });
81400
+ const gate2 = projectExportGate(appId, project);
81401
+ if (gate2) return reply.status(gate2.status).send({ ok: false, error: gate2.error });
79992
81402
  try {
79993
81403
  projectSnapshot = currentApprovedSnapshot(project);
79994
81404
  } catch (error) {
@@ -80059,7 +81469,7 @@ async function startServer() {
80059
81469
  }
80060
81470
  async function dropExportSourceId(appId, project) {
80061
81471
  const ownerId = project ? await getOrCreateProjectExportSourceId(project) : await getOrCreateWorkflowExportSourceId(appId);
80062
- return deriveDropExportSourceId(project ? "project" : "workflow", ownerId, (0, import_node_crypto23.randomUUID)());
81472
+ return deriveDropExportSourceId(project ? "project" : "workflow", ownerId, (0, import_node_crypto24.randomUUID)());
80063
81473
  }
80064
81474
  async function continueIfcExport(input, reply) {
80065
81475
  const appId = input.appId;
@@ -80100,7 +81510,7 @@ async function startServer() {
80100
81510
  }
80101
81511
  if (!hasExportableSceneRecords(scene)) return reply.status(422).send({ ok: false, error: emptyError, skipped });
80102
81512
  const filename = `${exportFileBase(project, appId)}.ifc`;
80103
- const finalPath = (0, import_node_path46.join)(project ? projectExportsDir(project) : (0, import_node_path46.dirname)(bomExportPath(appId, "csv")), filename);
81513
+ const finalPath = (0, import_node_path48.join)(project ? projectExportsDir(project) : (0, import_node_path48.dirname)(bomExportPath(appId, "csv")), filename);
80104
81514
  const priorProjectIfc = project ? listProjectExportReceipts(project).find((row) => row.kind === "ifc") : void 0;
80105
81515
  const tempPath = requestIfcTempPath(finalPath);
80106
81516
  try {
@@ -80116,7 +81526,7 @@ async function startServer() {
80116
81526
  index: parseStepData(artifactBytes),
80117
81527
  bytes: artifactBytes
80118
81528
  });
80119
- const expectedContentSha256 = (0, import_node_crypto23.createHash)("sha256").update(artifactBytes).digest("hex");
81529
+ const expectedContentSha256 = (0, import_node_crypto24.createHash)("sha256").update(artifactBytes).digest("hex");
80120
81530
  const transition = project && projectSnapshot ? prepareProjectExport(project, {
80121
81531
  kind: "ifc",
80122
81532
  filename,
@@ -80187,8 +81597,8 @@ async function startServer() {
80187
81597
  app.get("/api/contract/:appId/render-preview", async (req, reply) => {
80188
81598
  const project = req.query.project;
80189
81599
  if (!project) return reply.status(400).send({ ok: false, error: "project is required" });
80190
- const owner = getProject(project);
80191
- if (!owner || owner.app !== req.params.appId) {
81600
+ const owner2 = getProject(project);
81601
+ if (!owner2 || owner2.app !== req.params.appId) {
80192
81602
  return reply.status(404).send({ ok: false, error: "unknown project" });
80193
81603
  }
80194
81604
  let snapshot;
@@ -80245,8 +81655,8 @@ async function startServer() {
80245
81655
  return reply.status(409).send({ ok: false, error: readiness.message, readiness });
80246
81656
  }
80247
81657
  return withLifecycleLock("project", project, async () => {
80248
- const gate = projectExportGate(appId, project);
80249
- if (gate) return reply.status(gate.status).send({ ok: false, error: gate.error });
81658
+ const gate2 = projectExportGate(appId, project);
81659
+ if (gate2) return reply.status(gate2.status).send({ ok: false, error: gate2.error });
80250
81660
  let projectSnapshot;
80251
81661
  try {
80252
81662
  projectSnapshot = currentApprovedSnapshot(project);
@@ -80270,8 +81680,8 @@ async function startServer() {
80270
81680
  }
80271
81681
  const kind = output === "turntable" ? "render-mp4" : "render-png";
80272
81682
  const extension = output === "turntable" ? ".mp4" : ".png";
80273
- const scratch = (0, import_node_fs50.mkdtempSync)((0, import_node_path46.join)((0, import_node_os27.tmpdir)(), "floless-render-"));
80274
- const ifcPath = (0, import_node_path46.join)(scratch, "model.ifc");
81683
+ const scratch = (0, import_node_fs50.mkdtempSync)((0, import_node_path48.join)((0, import_node_os27.tmpdir)(), "floless-render-"));
81684
+ const ifcPath = (0, import_node_path48.join)(scratch, "model.ifc");
80275
81685
  const rendered = [];
80276
81686
  const progress = (stage, extra = {}) => {
80277
81687
  try {
@@ -80288,7 +81698,7 @@ async function startServer() {
80288
81698
  const renderBudgetMs = output === "turntable" ? 30 * 6e4 : 10 * 6e4;
80289
81699
  for (const [i, viewpoint] of viewpoints.entries()) {
80290
81700
  progress("rendering", { viewpoint, index: i + 1, output });
80291
- const artifactPath = (0, import_node_path46.join)(scratch, `render-${viewpoint}${extension}`);
81701
+ const artifactPath = (0, import_node_path48.join)(scratch, `render-${viewpoint}${extension}`);
80292
81702
  const receipt = await aware.agentInvoke(RENDER_AGENT_ID, output === "turntable" ? "render.turntable" : "render.still", {
80293
81703
  "ifc-path": ifcPath,
80294
81704
  "output-path": artifactPath,
@@ -80339,7 +81749,7 @@ async function startServer() {
80339
81749
  // Kept for a single-viewpoint caller so the existing shape still reads naturally.
80340
81750
  filename: rendered[0]?.filename,
80341
81751
  viewpoint: rendered[0]?.viewpoint,
80342
- savedTo: rendered[0] ? (0, import_node_path46.join)(projectExportsDir(project), rendered[0].filename) : void 0
81752
+ savedTo: rendered[0] ? (0, import_node_path48.join)(projectExportsDir(project), rendered[0].filename) : void 0
80343
81753
  };
80344
81754
  } catch (error) {
80345
81755
  const reason = awareStderr(error);
@@ -80571,8 +81981,8 @@ async function startServer() {
80571
81981
  }
80572
81982
  const preferredFilename = `${exportFileBase(project, appId)}-bom.${format}`;
80573
81983
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
80574
- const outPath = project ? (0, import_node_path46.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
80575
- const dir = (0, import_node_path46.dirname)(outPath);
81984
+ const outPath = project ? (0, import_node_path48.join)(projectExportsDir(project), filename) : bomExportPath(appId, format);
81985
+ const dir = (0, import_node_path48.dirname)(outPath);
80576
81986
  try {
80577
81987
  (0, import_node_fs50.mkdirSync)(dir, { recursive: true });
80578
81988
  if (format === "csv") {
@@ -80623,9 +82033,9 @@ async function startServer() {
80623
82033
  const svg = contractToSvg(cleaned);
80624
82034
  const preferredFilename = `${exportFileBase(project, appId)}.svg`;
80625
82035
  const filename = project ? uniqueProjectExportFilename(project, preferredFilename) : preferredFilename;
80626
- const outPath = project ? (0, import_node_path46.join)(projectExportsDir(project), filename) : (0, import_node_path46.join)(appPath(appId), filename);
82036
+ const outPath = project ? (0, import_node_path48.join)(projectExportsDir(project), filename) : (0, import_node_path48.join)(appPath(appId), filename);
80627
82037
  try {
80628
- (0, import_node_fs50.mkdirSync)((0, import_node_path46.dirname)(outPath), { recursive: true });
82038
+ (0, import_node_fs50.mkdirSync)((0, import_node_path48.dirname)(outPath), { recursive: true });
80629
82039
  if (project && projectSnapshot) {
80630
82040
  publishProjectExportArtifact(project, {
80631
82041
  kind: "svg",
@@ -80795,11 +82205,11 @@ async function startServer() {
80795
82205
  return reply.status(409).send({ ok: false, error: `a workflow named "${id}" is already installed \u2014 remove it first, or rename the file's app: id`, code: "exists", id });
80796
82206
  }
80797
82207
  await deleteOrigin(id);
80798
- const stageRoot = (0, import_node_fs50.mkdtempSync)((0, import_node_path46.join)((0, import_node_os27.tmpdir)(), "floless-import-"));
82208
+ const stageRoot = (0, import_node_fs50.mkdtempSync)((0, import_node_path48.join)((0, import_node_os27.tmpdir)(), "floless-import-"));
80799
82209
  try {
80800
- const stageDir = (0, import_node_path46.join)(stageRoot, id);
82210
+ const stageDir = (0, import_node_path48.join)(stageRoot, id);
80801
82211
  (0, import_node_fs50.mkdirSync)(stageDir);
80802
- (0, import_node_fs50.writeFileSync)((0, import_node_path46.join)(stageDir, `${id}.flo`), content);
82212
+ (0, import_node_fs50.writeFileSync)((0, import_node_path48.join)(stageDir, `${id}.flo`), content);
80803
82213
  await aware.install(stageDir);
80804
82214
  } catch (err2) {
80805
82215
  try {
@@ -80825,13 +82235,13 @@ async function startServer() {
80825
82235
  }
80826
82236
  const inputs = appData.inputs.map((i) => ({ name: i.name, type: i.type }));
80827
82237
  const baked = bakeFloSource(appData.source.text, inputs);
80828
- const tmpRoot = (0, import_node_fs50.mkdtempSync)((0, import_node_path46.join)((0, import_node_os27.tmpdir)(), "floless-bake-"));
80829
- const backupDir2 = (0, import_node_path46.join)(tmpRoot, `${id}-backup`);
80830
- const bakeDir = (0, import_node_path46.join)(tmpRoot, id);
82238
+ const tmpRoot = (0, import_node_fs50.mkdtempSync)((0, import_node_path48.join)((0, import_node_os27.tmpdir)(), "floless-bake-"));
82239
+ const backupDir2 = (0, import_node_path48.join)(tmpRoot, `${id}-backup`);
82240
+ const bakeDir = (0, import_node_path48.join)(tmpRoot, id);
80831
82241
  (0, import_node_fs50.cpSync)(appDir(id), backupDir2, { recursive: true });
80832
82242
  (0, import_node_fs50.cpSync)(appDir(id), bakeDir, { recursive: true });
80833
82243
  const floName = appData.source.path.split(/[\\/]/).pop();
80834
- (0, import_node_fs50.writeFileSync)((0, import_node_path46.join)(bakeDir, floName), baked);
82244
+ (0, import_node_fs50.writeFileSync)((0, import_node_path48.join)(bakeDir, floName), baked);
80835
82245
  let appInstalled2 = true;
80836
82246
  try {
80837
82247
  await aware.uninstall(id);
@@ -80853,7 +82263,7 @@ async function startServer() {
80853
82263
  throw installErr;
80854
82264
  }
80855
82265
  try {
80856
- await aware.compile((0, import_node_path46.join)(appDir(id), floName));
82266
+ await aware.compile((0, import_node_path48.join)(appDir(id), floName));
80857
82267
  } catch (compileErr) {
80858
82268
  app.log.warn({ id, compileErr: String(compileErr) }, "bake: post-install recompile failed (app baked but may need a manual Compile)");
80859
82269
  }
@@ -80863,7 +82273,7 @@ async function startServer() {
80863
82273
  if (appInstalled2) (0, import_node_fs50.rmSync)(tmpRoot, { recursive: true, force: true });
80864
82274
  }
80865
82275
  });
80866
- const graftAgentsDir = () => (0, import_node_path46.join)((0, import_node_os27.homedir)(), ".aware", "agents");
82276
+ const graftAgentsDir = () => (0, import_node_path48.join)((0, import_node_os27.homedir)(), ".aware", "agents");
80867
82277
  app.post("/api/graft/match", async (req, reply) => {
80868
82278
  const { glob } = req.body ?? {};
80869
82279
  if (!glob) return reply.status(400).send({ ok: false, error: "glob required" });
@@ -80880,7 +82290,7 @@ async function startServer() {
80880
82290
  if (!sourceKind || !sourceRef) {
80881
82291
  return reply.status(400).send({ ok: false, error: "sourceKind and sourceRef required" });
80882
82292
  }
80883
- const tempHome = (0, import_node_fs50.mkdtempSync)((0, import_node_path46.join)((0, import_node_os27.tmpdir)(), "floless-graft-"));
82293
+ const tempHome = (0, import_node_fs50.mkdtempSync)((0, import_node_path48.join)((0, import_node_os27.tmpdir)(), "floless-graft-"));
80884
82294
  let result;
80885
82295
  try {
80886
82296
  result = await aware.build({
@@ -80902,10 +82312,10 @@ async function startServer() {
80902
82312
  (0, import_node_fs50.rmSync)(tempHome, { recursive: true, force: true });
80903
82313
  return reply.status(502).send({ ok: false, error: `build produced output at ${result.agentDir} but no manifest.yaml` });
80904
82314
  }
80905
- const token = (0, import_node_crypto23.randomUUID)();
82315
+ const token = (0, import_node_crypto24.randomUUID)();
80906
82316
  registerStage(token, tempHome, result.agentId);
80907
82317
  const preview2 = buildPreview(manifest, sourceKind, sourceRef, token);
80908
- if ((0, import_node_fs50.existsSync)((0, import_node_path46.join)(graftAgentsDir(), result.agentId))) {
82318
+ if ((0, import_node_fs50.existsSync)((0, import_node_path48.join)(graftAgentsDir(), result.agentId))) {
80909
82319
  preview2.warnings.unshift(`An agent named "${result.agentId}" is already installed \u2014 creating it will overwrite it.`);
80910
82320
  }
80911
82321
  return { ok: true, preview: preview2 };
@@ -81060,7 +82470,7 @@ async function startServer() {
81060
82470
  return reply.send({ ok: false, error: "needs Compile \u2014 Run is gated on a fresh lock", blocked: true });
81061
82471
  }
81062
82472
  const sessionId = foregroundSessionId(id);
81063
- const res = startSession({
82473
+ const res = await startSession({
81064
82474
  id: sessionId,
81065
82475
  workflow: id,
81066
82476
  sourceNodeId: appSpec.triggerSource.nodeId,
@@ -81589,7 +82999,7 @@ async function startServer() {
81589
82999
  addClient(reply);
81590
83000
  });
81591
83001
  const watcher = startWatcher();
81592
- runBootstrap(bootstrapDeps).then((st) => {
83002
+ startAwareBootstrap().then((st) => {
81593
83003
  if (st.status === "ready") startScheduler();
81594
83004
  else app.log.warn({ reason: st.reason }, "AWARE bootstrap not ready; scheduler deferred");
81595
83005
  }).catch((err2) => app.log.error({ err: String(err2) }, "bootstrap continuation failed"));
@@ -81628,10 +83038,10 @@ async function startServer() {
81628
83038
  }
81629
83039
 
81630
83040
  // protocol.ts
81631
- var import_node_child_process11 = require("node:child_process");
83041
+ var import_node_child_process12 = require("node:child_process");
81632
83042
  var BASE = PROTOCOL_KEY;
81633
83043
  function reg(args) {
81634
- (0, import_node_child_process11.execFileSync)("reg", args, { stdio: "ignore", windowsHide: true });
83044
+ (0, import_node_child_process12.execFileSync)("reg", args, { stdio: "ignore", windowsHide: true });
81635
83045
  }
81636
83046
  function registerProtocol(exePath) {
81637
83047
  if (process.platform !== "win32") return;
@@ -81671,13 +83081,13 @@ async function removeAwarePerDecision(removeAwareFlag, prompt) {
81671
83081
  );
81672
83082
  const shell = process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : "/bin/sh";
81673
83083
  try {
81674
- (0, import_node_child_process12.execSync)("npm uninstall -g @aware-aeco/cli", { stdio: "inherit", shell });
83084
+ (0, import_node_child_process13.execSync)("npm uninstall -g @aware-aeco/cli", { stdio: "inherit", shell });
81675
83085
  } catch {
81676
83086
  process.stdout.write('floless: warning: "npm uninstall -g @aware-aeco/cli" failed \u2014 see the output above.\n');
81677
83087
  }
81678
83088
  let lsJson = "";
81679
83089
  try {
81680
- lsJson = (0, import_node_child_process12.execSync)("npm ls -g @aware-aeco/cli --depth=0 --json", {
83090
+ lsJson = (0, import_node_child_process13.execSync)("npm ls -g @aware-aeco/cli --depth=0 --json", {
81681
83091
  encoding: "utf8",
81682
83092
  stdio: ["ignore", "pipe", "ignore"],
81683
83093
  shell