meshy-node 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main.cjs CHANGED
@@ -6629,8 +6629,8 @@ var require_node2 = __commonJS({
6629
6629
  }
6630
6630
  break;
6631
6631
  case "FILE":
6632
- var fs23 = require("fs");
6633
- stream2 = new fs23.SyncWriteStream(fd2, { autoClose: false });
6632
+ var fs22 = require("fs");
6633
+ stream2 = new fs22.SyncWriteStream(fd2, { autoClose: false });
6634
6634
  stream2._type = "fs";
6635
6635
  break;
6636
6636
  case "PIPE":
@@ -19420,11 +19420,11 @@ var require_mime_types = __commonJS({
19420
19420
  }
19421
19421
  return exts[0];
19422
19422
  }
19423
- function lookup(path24) {
19424
- if (!path24 || typeof path24 !== "string") {
19423
+ function lookup(path23) {
19424
+ if (!path23 || typeof path23 !== "string") {
19425
19425
  return false;
19426
19426
  }
19427
- var extension2 = extname3("x." + path24).toLowerCase().substr(1);
19427
+ var extension2 = extname3("x." + path23).toLowerCase().substr(1);
19428
19428
  if (!extension2) {
19429
19429
  return false;
19430
19430
  }
@@ -22942,7 +22942,7 @@ var require_path_to_regexp = __commonJS({
22942
22942
  "use strict";
22943
22943
  module2.exports = pathToRegexp;
22944
22944
  var MATCHING_GROUP_REGEXP = /\\.|\((?:\?<(.*?)>)?(?!\?)/g;
22945
- function pathToRegexp(path24, keys, options) {
22945
+ function pathToRegexp(path23, keys, options) {
22946
22946
  options = options || {};
22947
22947
  keys = keys || [];
22948
22948
  var strict = options.strict;
@@ -22956,8 +22956,8 @@ var require_path_to_regexp = __commonJS({
22956
22956
  var pos = 0;
22957
22957
  var backtrack = "";
22958
22958
  var m;
22959
- if (path24 instanceof RegExp) {
22960
- while (m = MATCHING_GROUP_REGEXP.exec(path24.source)) {
22959
+ if (path23 instanceof RegExp) {
22960
+ while (m = MATCHING_GROUP_REGEXP.exec(path23.source)) {
22961
22961
  if (m[0][0] === "\\") continue;
22962
22962
  keys.push({
22963
22963
  name: m[1] || name2++,
@@ -22965,18 +22965,18 @@ var require_path_to_regexp = __commonJS({
22965
22965
  offset: m.index
22966
22966
  });
22967
22967
  }
22968
- return path24;
22968
+ return path23;
22969
22969
  }
22970
- if (Array.isArray(path24)) {
22971
- path24 = path24.map(function(value) {
22970
+ if (Array.isArray(path23)) {
22971
+ path23 = path23.map(function(value) {
22972
22972
  return pathToRegexp(value, keys, options).source;
22973
22973
  });
22974
- return new RegExp(path24.join("|"), flags);
22974
+ return new RegExp(path23.join("|"), flags);
22975
22975
  }
22976
- if (typeof path24 !== "string") {
22976
+ if (typeof path23 !== "string") {
22977
22977
  throw new TypeError("path must be a string, array of strings, or regular expression");
22978
22978
  }
22979
- path24 = path24.replace(
22979
+ path23 = path23.replace(
22980
22980
  /\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g,
22981
22981
  function(match, slash, format, key, capture, star, optional, offset) {
22982
22982
  if (match[0] === "\\") {
@@ -22993,7 +22993,7 @@ var require_path_to_regexp = __commonJS({
22993
22993
  if (slash || format) {
22994
22994
  backtrack = "";
22995
22995
  } else {
22996
- backtrack += path24.slice(pos, offset);
22996
+ backtrack += path23.slice(pos, offset);
22997
22997
  }
22998
22998
  pos = offset + match.length;
22999
22999
  if (match === "*") {
@@ -23023,7 +23023,7 @@ var require_path_to_regexp = __commonJS({
23023
23023
  return result;
23024
23024
  }
23025
23025
  );
23026
- while (m = MATCHING_GROUP_REGEXP.exec(path24)) {
23026
+ while (m = MATCHING_GROUP_REGEXP.exec(path23)) {
23027
23027
  if (m[0][0] === "\\") continue;
23028
23028
  if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
23029
23029
  keys.splice(keysOffset + i, 0, {
@@ -23035,13 +23035,13 @@ var require_path_to_regexp = __commonJS({
23035
23035
  }
23036
23036
  i++;
23037
23037
  }
23038
- path24 += strict ? "" : path24[path24.length - 1] === "/" ? "?" : "/?";
23038
+ path23 += strict ? "" : path23[path23.length - 1] === "/" ? "?" : "/?";
23039
23039
  if (end) {
23040
- path24 += "$";
23041
- } else if (path24[path24.length - 1] !== "/") {
23042
- path24 += lookahead ? "(?=/|$)" : "(?:/|$)";
23040
+ path23 += "$";
23041
+ } else if (path23[path23.length - 1] !== "/") {
23042
+ path23 += lookahead ? "(?=/|$)" : "(?:/|$)";
23043
23043
  }
23044
- return new RegExp("^" + path24, flags);
23044
+ return new RegExp("^" + path23, flags);
23045
23045
  }
23046
23046
  }
23047
23047
  });
@@ -23054,19 +23054,19 @@ var require_layer = __commonJS({
23054
23054
  var debug = require_src2()("express:router:layer");
23055
23055
  var hasOwnProperty = Object.prototype.hasOwnProperty;
23056
23056
  module2.exports = Layer;
23057
- function Layer(path24, options, fn) {
23057
+ function Layer(path23, options, fn) {
23058
23058
  if (!(this instanceof Layer)) {
23059
- return new Layer(path24, options, fn);
23059
+ return new Layer(path23, options, fn);
23060
23060
  }
23061
- debug("new %o", path24);
23061
+ debug("new %o", path23);
23062
23062
  var opts = options || {};
23063
23063
  this.handle = fn;
23064
23064
  this.name = fn.name || "<anonymous>";
23065
23065
  this.params = void 0;
23066
23066
  this.path = void 0;
23067
- this.regexp = pathRegexp(path24, this.keys = [], opts);
23068
- this.regexp.fast_star = path24 === "*";
23069
- this.regexp.fast_slash = path24 === "/" && opts.end === false;
23067
+ this.regexp = pathRegexp(path23, this.keys = [], opts);
23068
+ this.regexp.fast_star = path23 === "*";
23069
+ this.regexp.fast_slash = path23 === "/" && opts.end === false;
23070
23070
  }
23071
23071
  Layer.prototype.handle_error = function handle_error(error, req, res, next) {
23072
23072
  var fn = this.handle;
@@ -23090,20 +23090,20 @@ var require_layer = __commonJS({
23090
23090
  next(err);
23091
23091
  }
23092
23092
  };
23093
- Layer.prototype.match = function match(path24) {
23093
+ Layer.prototype.match = function match(path23) {
23094
23094
  var match2;
23095
- if (path24 != null) {
23095
+ if (path23 != null) {
23096
23096
  if (this.regexp.fast_slash) {
23097
23097
  this.params = {};
23098
23098
  this.path = "";
23099
23099
  return true;
23100
23100
  }
23101
23101
  if (this.regexp.fast_star) {
23102
- this.params = { "0": decode_param(path24) };
23103
- this.path = path24;
23102
+ this.params = { "0": decode_param(path23) };
23103
+ this.path = path23;
23104
23104
  return true;
23105
23105
  }
23106
- match2 = this.regexp.exec(path24);
23106
+ match2 = this.regexp.exec(path23);
23107
23107
  }
23108
23108
  if (!match2) {
23109
23109
  this.params = void 0;
@@ -23196,10 +23196,10 @@ var require_route = __commonJS({
23196
23196
  var slice = Array.prototype.slice;
23197
23197
  var toString = Object.prototype.toString;
23198
23198
  module2.exports = Route;
23199
- function Route(path24) {
23200
- this.path = path24;
23199
+ function Route(path23) {
23200
+ this.path = path23;
23201
23201
  this.stack = [];
23202
- debug("new %o", path24);
23202
+ debug("new %o", path23);
23203
23203
  this.methods = {};
23204
23204
  }
23205
23205
  Route.prototype._handles_method = function _handles_method(method) {
@@ -23412,8 +23412,8 @@ var require_router = __commonJS({
23412
23412
  if (++sync > 100) {
23413
23413
  return setImmediate(next, err);
23414
23414
  }
23415
- var path24 = getPathname(req);
23416
- if (path24 == null) {
23415
+ var path23 = getPathname(req);
23416
+ if (path23 == null) {
23417
23417
  return done(layerError);
23418
23418
  }
23419
23419
  var layer;
@@ -23421,7 +23421,7 @@ var require_router = __commonJS({
23421
23421
  var route;
23422
23422
  while (match !== true && idx < stack.length) {
23423
23423
  layer = stack[idx++];
23424
- match = matchLayer(layer, path24);
23424
+ match = matchLayer(layer, path23);
23425
23425
  route = layer.route;
23426
23426
  if (typeof match !== "boolean") {
23427
23427
  layerError = layerError || match;
@@ -23459,18 +23459,18 @@ var require_router = __commonJS({
23459
23459
  } else if (route) {
23460
23460
  layer.handle_request(req, res, next);
23461
23461
  } else {
23462
- trim_prefix(layer, layerError, layerPath, path24);
23462
+ trim_prefix(layer, layerError, layerPath, path23);
23463
23463
  }
23464
23464
  sync = 0;
23465
23465
  });
23466
23466
  }
23467
- function trim_prefix(layer, layerError, layerPath, path24) {
23467
+ function trim_prefix(layer, layerError, layerPath, path23) {
23468
23468
  if (layerPath.length !== 0) {
23469
- if (layerPath !== path24.slice(0, layerPath.length)) {
23469
+ if (layerPath !== path23.slice(0, layerPath.length)) {
23470
23470
  next(layerError);
23471
23471
  return;
23472
23472
  }
23473
- var c = path24[layerPath.length];
23473
+ var c = path23[layerPath.length];
23474
23474
  if (c && c !== "/" && c !== ".") return next(layerError);
23475
23475
  debug("trim prefix (%s) from url %s", layerPath, req.url);
23476
23476
  removed = layerPath;
@@ -23548,7 +23548,7 @@ var require_router = __commonJS({
23548
23548
  };
23549
23549
  proto.use = function use(fn) {
23550
23550
  var offset = 0;
23551
- var path24 = "/";
23551
+ var path23 = "/";
23552
23552
  if (typeof fn !== "function") {
23553
23553
  var arg = fn;
23554
23554
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -23556,7 +23556,7 @@ var require_router = __commonJS({
23556
23556
  }
23557
23557
  if (typeof arg !== "function") {
23558
23558
  offset = 1;
23559
- path24 = fn;
23559
+ path23 = fn;
23560
23560
  }
23561
23561
  }
23562
23562
  var callbacks = flatten(slice.call(arguments, offset));
@@ -23568,8 +23568,8 @@ var require_router = __commonJS({
23568
23568
  if (typeof fn !== "function") {
23569
23569
  throw new TypeError("Router.use() requires a middleware function but got a " + gettype(fn));
23570
23570
  }
23571
- debug("use %o %s", path24, fn.name || "<anonymous>");
23572
- var layer = new Layer(path24, {
23571
+ debug("use %o %s", path23, fn.name || "<anonymous>");
23572
+ var layer = new Layer(path23, {
23573
23573
  sensitive: this.caseSensitive,
23574
23574
  strict: false,
23575
23575
  end: false
@@ -23579,9 +23579,9 @@ var require_router = __commonJS({
23579
23579
  }
23580
23580
  return this;
23581
23581
  };
23582
- proto.route = function route(path24) {
23583
- var route2 = new Route(path24);
23584
- var layer = new Layer(path24, {
23582
+ proto.route = function route(path23) {
23583
+ var route2 = new Route(path23);
23584
+ var layer = new Layer(path23, {
23585
23585
  sensitive: this.caseSensitive,
23586
23586
  strict: this.strict,
23587
23587
  end: true
@@ -23591,8 +23591,8 @@ var require_router = __commonJS({
23591
23591
  return route2;
23592
23592
  };
23593
23593
  methods.concat("all").forEach(function(method) {
23594
- proto[method] = function(path24) {
23595
- var route = this.route(path24);
23594
+ proto[method] = function(path23) {
23595
+ var route = this.route(path23);
23596
23596
  route[method].apply(route, slice.call(arguments, 1));
23597
23597
  return this;
23598
23598
  };
@@ -23628,9 +23628,9 @@ var require_router = __commonJS({
23628
23628
  }
23629
23629
  return toString.call(obj).replace(objectRegExp, "$1");
23630
23630
  }
23631
- function matchLayer(layer, path24) {
23631
+ function matchLayer(layer, path23) {
23632
23632
  try {
23633
- return layer.match(path24);
23633
+ return layer.match(path23);
23634
23634
  } catch (err) {
23635
23635
  return err;
23636
23636
  }
@@ -23748,13 +23748,13 @@ var require_view = __commonJS({
23748
23748
  "../../node_modules/.pnpm/express@4.22.1/node_modules/express/lib/view.js"(exports2, module2) {
23749
23749
  "use strict";
23750
23750
  var debug = require_src2()("express:view");
23751
- var path24 = require("path");
23752
- var fs23 = require("fs");
23753
- var dirname7 = path24.dirname;
23754
- var basename5 = path24.basename;
23755
- var extname3 = path24.extname;
23756
- var join18 = path24.join;
23757
- var resolve15 = path24.resolve;
23751
+ var path23 = require("path");
23752
+ var fs22 = require("fs");
23753
+ var dirname7 = path23.dirname;
23754
+ var basename5 = path23.basename;
23755
+ var extname3 = path23.extname;
23756
+ var join17 = path23.join;
23757
+ var resolve15 = path23.resolve;
23758
23758
  module2.exports = View;
23759
23759
  function View(name2, options) {
23760
23760
  var opts = options || {};
@@ -23783,17 +23783,17 @@ var require_view = __commonJS({
23783
23783
  this.path = this.lookup(fileName);
23784
23784
  }
23785
23785
  View.prototype.lookup = function lookup(name2) {
23786
- var path25;
23786
+ var path24;
23787
23787
  var roots = [].concat(this.root);
23788
23788
  debug('lookup "%s"', name2);
23789
- for (var i = 0; i < roots.length && !path25; i++) {
23789
+ for (var i = 0; i < roots.length && !path24; i++) {
23790
23790
  var root = roots[i];
23791
23791
  var loc = resolve15(root, name2);
23792
23792
  var dir = dirname7(loc);
23793
23793
  var file = basename5(loc);
23794
- path25 = this.resolve(dir, file);
23794
+ path24 = this.resolve(dir, file);
23795
23795
  }
23796
- return path25;
23796
+ return path24;
23797
23797
  };
23798
23798
  View.prototype.render = function render(options, callback) {
23799
23799
  debug('render "%s"', this.path);
@@ -23801,21 +23801,21 @@ var require_view = __commonJS({
23801
23801
  };
23802
23802
  View.prototype.resolve = function resolve16(dir, file) {
23803
23803
  var ext = this.ext;
23804
- var path25 = join18(dir, file);
23805
- var stat = tryStat(path25);
23804
+ var path24 = join17(dir, file);
23805
+ var stat = tryStat(path24);
23806
23806
  if (stat && stat.isFile()) {
23807
- return path25;
23807
+ return path24;
23808
23808
  }
23809
- path25 = join18(dir, basename5(file, ext), "index" + ext);
23810
- stat = tryStat(path25);
23809
+ path24 = join17(dir, basename5(file, ext), "index" + ext);
23810
+ stat = tryStat(path24);
23811
23811
  if (stat && stat.isFile()) {
23812
- return path25;
23812
+ return path24;
23813
23813
  }
23814
23814
  };
23815
- function tryStat(path25) {
23816
- debug('stat "%s"', path25);
23815
+ function tryStat(path24) {
23816
+ debug('stat "%s"', path24);
23817
23817
  try {
23818
- return fs23.statSync(path25);
23818
+ return fs22.statSync(path24);
23819
23819
  } catch (e) {
23820
23820
  return void 0;
23821
23821
  }
@@ -24112,8 +24112,8 @@ var require_types = __commonJS({
24112
24112
  var require_mime = __commonJS({
24113
24113
  "../../node_modules/.pnpm/mime@1.6.0/node_modules/mime/mime.js"(exports2, module2) {
24114
24114
  "use strict";
24115
- var path24 = require("path");
24116
- var fs23 = require("fs");
24115
+ var path23 = require("path");
24116
+ var fs22 = require("fs");
24117
24117
  function Mime() {
24118
24118
  this.types = /* @__PURE__ */ Object.create(null);
24119
24119
  this.extensions = /* @__PURE__ */ Object.create(null);
@@ -24134,7 +24134,7 @@ var require_mime = __commonJS({
24134
24134
  };
24135
24135
  Mime.prototype.load = function(file) {
24136
24136
  this._loading = file;
24137
- var map = {}, content = fs23.readFileSync(file, "ascii"), lines = content.split(/[\r\n]+/);
24137
+ var map = {}, content = fs22.readFileSync(file, "ascii"), lines = content.split(/[\r\n]+/);
24138
24138
  lines.forEach(function(line) {
24139
24139
  var fields = line.replace(/\s*#.*|^\s*|\s*$/g, "").split(/\s+/);
24140
24140
  map[fields.shift()] = fields;
@@ -24142,8 +24142,8 @@ var require_mime = __commonJS({
24142
24142
  this.define(map);
24143
24143
  this._loading = null;
24144
24144
  };
24145
- Mime.prototype.lookup = function(path25, fallback) {
24146
- var ext = path25.replace(/^.*[\.\/\\]/, "").toLowerCase();
24145
+ Mime.prototype.lookup = function(path24, fallback) {
24146
+ var ext = path24.replace(/^.*[\.\/\\]/, "").toLowerCase();
24147
24147
  return this.types[ext] || fallback || this.default_type;
24148
24148
  };
24149
24149
  Mime.prototype.extension = function(mimeType) {
@@ -24256,33 +24256,33 @@ var require_send = __commonJS({
24256
24256
  var escapeHtml2 = require_escape_html();
24257
24257
  var etag = require_etag();
24258
24258
  var fresh = require_fresh();
24259
- var fs23 = require("fs");
24259
+ var fs22 = require("fs");
24260
24260
  var mime = require_mime();
24261
24261
  var ms = require_ms();
24262
24262
  var onFinished = require_on_finished();
24263
24263
  var parseRange = require_range_parser();
24264
- var path24 = require("path");
24264
+ var path23 = require("path");
24265
24265
  var statuses = require_statuses();
24266
24266
  var Stream = require("stream");
24267
24267
  var util3 = require("util");
24268
- var extname3 = path24.extname;
24269
- var join18 = path24.join;
24270
- var normalize = path24.normalize;
24271
- var resolve15 = path24.resolve;
24272
- var sep4 = path24.sep;
24268
+ var extname3 = path23.extname;
24269
+ var join17 = path23.join;
24270
+ var normalize = path23.normalize;
24271
+ var resolve15 = path23.resolve;
24272
+ var sep4 = path23.sep;
24273
24273
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
24274
24274
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
24275
24275
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
24276
24276
  module2.exports = send;
24277
24277
  module2.exports.mime = mime;
24278
- function send(req, path25, options) {
24279
- return new SendStream(req, path25, options);
24278
+ function send(req, path24, options) {
24279
+ return new SendStream(req, path24, options);
24280
24280
  }
24281
- function SendStream(req, path25, options) {
24281
+ function SendStream(req, path24, options) {
24282
24282
  Stream.call(this);
24283
24283
  var opts = options || {};
24284
24284
  this.options = opts;
24285
- this.path = path25;
24285
+ this.path = path24;
24286
24286
  this.req = req;
24287
24287
  this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
24288
24288
  this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
@@ -24328,8 +24328,8 @@ var require_send = __commonJS({
24328
24328
  this._index = index2;
24329
24329
  return this;
24330
24330
  }, "send.index: pass index as option");
24331
- SendStream.prototype.root = function root(path25) {
24332
- this._root = resolve15(String(path25));
24331
+ SendStream.prototype.root = function root(path24) {
24332
+ this._root = resolve15(String(path24));
24333
24333
  debug("root %s", this._root);
24334
24334
  return this;
24335
24335
  };
@@ -24442,10 +24442,10 @@ var require_send = __commonJS({
24442
24442
  var lastModified = this.res.getHeader("Last-Modified");
24443
24443
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
24444
24444
  };
24445
- SendStream.prototype.redirect = function redirect(path25) {
24445
+ SendStream.prototype.redirect = function redirect(path24) {
24446
24446
  var res = this.res;
24447
24447
  if (hasListeners(this, "directory")) {
24448
- this.emit("directory", res, path25);
24448
+ this.emit("directory", res, path24);
24449
24449
  return;
24450
24450
  }
24451
24451
  if (this.hasTrailingSlash()) {
@@ -24465,42 +24465,42 @@ var require_send = __commonJS({
24465
24465
  SendStream.prototype.pipe = function pipe(res) {
24466
24466
  var root = this._root;
24467
24467
  this.res = res;
24468
- var path25 = decode(this.path);
24469
- if (path25 === -1) {
24468
+ var path24 = decode(this.path);
24469
+ if (path24 === -1) {
24470
24470
  this.error(400);
24471
24471
  return res;
24472
24472
  }
24473
- if (~path25.indexOf("\0")) {
24473
+ if (~path24.indexOf("\0")) {
24474
24474
  this.error(400);
24475
24475
  return res;
24476
24476
  }
24477
24477
  var parts;
24478
24478
  if (root !== null) {
24479
- if (path25) {
24480
- path25 = normalize("." + sep4 + path25);
24479
+ if (path24) {
24480
+ path24 = normalize("." + sep4 + path24);
24481
24481
  }
24482
- if (UP_PATH_REGEXP.test(path25)) {
24483
- debug('malicious path "%s"', path25);
24482
+ if (UP_PATH_REGEXP.test(path24)) {
24483
+ debug('malicious path "%s"', path24);
24484
24484
  this.error(403);
24485
24485
  return res;
24486
24486
  }
24487
- parts = path25.split(sep4);
24488
- path25 = normalize(join18(root, path25));
24487
+ parts = path24.split(sep4);
24488
+ path24 = normalize(join17(root, path24));
24489
24489
  } else {
24490
- if (UP_PATH_REGEXP.test(path25)) {
24491
- debug('malicious path "%s"', path25);
24490
+ if (UP_PATH_REGEXP.test(path24)) {
24491
+ debug('malicious path "%s"', path24);
24492
24492
  this.error(403);
24493
24493
  return res;
24494
24494
  }
24495
- parts = normalize(path25).split(sep4);
24496
- path25 = resolve15(path25);
24495
+ parts = normalize(path24).split(sep4);
24496
+ path24 = resolve15(path24);
24497
24497
  }
24498
24498
  if (containsDotFile(parts)) {
24499
24499
  var access = this._dotfiles;
24500
24500
  if (access === void 0) {
24501
24501
  access = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow";
24502
24502
  }
24503
- debug('%s dotfile "%s"', access, path25);
24503
+ debug('%s dotfile "%s"', access, path24);
24504
24504
  switch (access) {
24505
24505
  case "allow":
24506
24506
  break;
@@ -24514,13 +24514,13 @@ var require_send = __commonJS({
24514
24514
  }
24515
24515
  }
24516
24516
  if (this._index.length && this.hasTrailingSlash()) {
24517
- this.sendIndex(path25);
24517
+ this.sendIndex(path24);
24518
24518
  return res;
24519
24519
  }
24520
- this.sendFile(path25);
24520
+ this.sendFile(path24);
24521
24521
  return res;
24522
24522
  };
24523
- SendStream.prototype.send = function send2(path25, stat) {
24523
+ SendStream.prototype.send = function send2(path24, stat) {
24524
24524
  var len = stat.size;
24525
24525
  var options = this.options;
24526
24526
  var opts = {};
@@ -24532,9 +24532,9 @@ var require_send = __commonJS({
24532
24532
  this.headersAlreadySent();
24533
24533
  return;
24534
24534
  }
24535
- debug('pipe "%s"', path25);
24536
- this.setHeader(path25, stat);
24537
- this.type(path25);
24535
+ debug('pipe "%s"', path24);
24536
+ this.setHeader(path24, stat);
24537
+ this.type(path24);
24538
24538
  if (this.isConditionalGET()) {
24539
24539
  if (this.isPreconditionFailure()) {
24540
24540
  this.error(412);
@@ -24583,28 +24583,28 @@ var require_send = __commonJS({
24583
24583
  res.end();
24584
24584
  return;
24585
24585
  }
24586
- this.stream(path25, opts);
24586
+ this.stream(path24, opts);
24587
24587
  };
24588
- SendStream.prototype.sendFile = function sendFile(path25) {
24588
+ SendStream.prototype.sendFile = function sendFile(path24) {
24589
24589
  var i = 0;
24590
24590
  var self2 = this;
24591
- debug('stat "%s"', path25);
24592
- fs23.stat(path25, function onstat(err, stat) {
24593
- if (err && err.code === "ENOENT" && !extname3(path25) && path25[path25.length - 1] !== sep4) {
24591
+ debug('stat "%s"', path24);
24592
+ fs22.stat(path24, function onstat(err, stat) {
24593
+ if (err && err.code === "ENOENT" && !extname3(path24) && path24[path24.length - 1] !== sep4) {
24594
24594
  return next(err);
24595
24595
  }
24596
24596
  if (err) return self2.onStatError(err);
24597
- if (stat.isDirectory()) return self2.redirect(path25);
24598
- self2.emit("file", path25, stat);
24599
- self2.send(path25, stat);
24597
+ if (stat.isDirectory()) return self2.redirect(path24);
24598
+ self2.emit("file", path24, stat);
24599
+ self2.send(path24, stat);
24600
24600
  });
24601
24601
  function next(err) {
24602
24602
  if (self2._extensions.length <= i) {
24603
24603
  return err ? self2.onStatError(err) : self2.error(404);
24604
24604
  }
24605
- var p = path25 + "." + self2._extensions[i++];
24605
+ var p = path24 + "." + self2._extensions[i++];
24606
24606
  debug('stat "%s"', p);
24607
- fs23.stat(p, function(err2, stat) {
24607
+ fs22.stat(p, function(err2, stat) {
24608
24608
  if (err2) return next(err2);
24609
24609
  if (stat.isDirectory()) return next();
24610
24610
  self2.emit("file", p, stat);
@@ -24612,7 +24612,7 @@ var require_send = __commonJS({
24612
24612
  });
24613
24613
  }
24614
24614
  };
24615
- SendStream.prototype.sendIndex = function sendIndex(path25) {
24615
+ SendStream.prototype.sendIndex = function sendIndex(path24) {
24616
24616
  var i = -1;
24617
24617
  var self2 = this;
24618
24618
  function next(err) {
@@ -24620,9 +24620,9 @@ var require_send = __commonJS({
24620
24620
  if (err) return self2.onStatError(err);
24621
24621
  return self2.error(404);
24622
24622
  }
24623
- var p = join18(path25, self2._index[i]);
24623
+ var p = join17(path24, self2._index[i]);
24624
24624
  debug('stat "%s"', p);
24625
- fs23.stat(p, function(err2, stat) {
24625
+ fs22.stat(p, function(err2, stat) {
24626
24626
  if (err2) return next(err2);
24627
24627
  if (stat.isDirectory()) return next();
24628
24628
  self2.emit("file", p, stat);
@@ -24631,10 +24631,10 @@ var require_send = __commonJS({
24631
24631
  }
24632
24632
  next();
24633
24633
  };
24634
- SendStream.prototype.stream = function stream(path25, options) {
24634
+ SendStream.prototype.stream = function stream(path24, options) {
24635
24635
  var self2 = this;
24636
24636
  var res = this.res;
24637
- var stream2 = fs23.createReadStream(path25, options);
24637
+ var stream2 = fs22.createReadStream(path24, options);
24638
24638
  this.emit("stream", stream2);
24639
24639
  stream2.pipe(res);
24640
24640
  function cleanup() {
@@ -24649,10 +24649,10 @@ var require_send = __commonJS({
24649
24649
  self2.emit("end");
24650
24650
  });
24651
24651
  };
24652
- SendStream.prototype.type = function type(path25) {
24652
+ SendStream.prototype.type = function type(path24) {
24653
24653
  var res = this.res;
24654
24654
  if (res.getHeader("Content-Type")) return;
24655
- var type2 = mime.lookup(path25);
24655
+ var type2 = mime.lookup(path24);
24656
24656
  if (!type2) {
24657
24657
  debug("no content-type");
24658
24658
  return;
@@ -24661,9 +24661,9 @@ var require_send = __commonJS({
24661
24661
  debug("content-type %s", type2);
24662
24662
  res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
24663
24663
  };
24664
- SendStream.prototype.setHeader = function setHeader(path25, stat) {
24664
+ SendStream.prototype.setHeader = function setHeader(path24, stat) {
24665
24665
  var res = this.res;
24666
- this.emit("headers", res, path25, stat);
24666
+ this.emit("headers", res, path24, stat);
24667
24667
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
24668
24668
  debug("accept ranges");
24669
24669
  res.setHeader("Accept-Ranges", "bytes");
@@ -24722,9 +24722,9 @@ var require_send = __commonJS({
24722
24722
  }
24723
24723
  return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
24724
24724
  }
24725
- function decode(path25) {
24725
+ function decode(path24) {
24726
24726
  try {
24727
- return decodeURIComponent(path25);
24727
+ return decodeURIComponent(path24);
24728
24728
  } catch (err) {
24729
24729
  return -1;
24730
24730
  }
@@ -25634,10 +25634,10 @@ var require_utils2 = __commonJS({
25634
25634
  var querystring = require("querystring");
25635
25635
  exports2.etag = createETagGenerator({ weak: false });
25636
25636
  exports2.wetag = createETagGenerator({ weak: true });
25637
- exports2.isAbsolute = function(path24) {
25638
- if ("/" === path24[0]) return true;
25639
- if (":" === path24[1] && ("\\" === path24[2] || "/" === path24[2])) return true;
25640
- if ("\\\\" === path24.substring(0, 2)) return true;
25637
+ exports2.isAbsolute = function(path23) {
25638
+ if ("/" === path23[0]) return true;
25639
+ if (":" === path23[1] && ("\\" === path23[2] || "/" === path23[2])) return true;
25640
+ if ("\\\\" === path23.substring(0, 2)) return true;
25641
25641
  };
25642
25642
  exports2.flatten = deprecate.function(
25643
25643
  flatten,
@@ -25848,7 +25848,7 @@ var require_application = __commonJS({
25848
25848
  };
25849
25849
  app.use = function use(fn) {
25850
25850
  var offset = 0;
25851
- var path24 = "/";
25851
+ var path23 = "/";
25852
25852
  if (typeof fn !== "function") {
25853
25853
  var arg = fn;
25854
25854
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -25856,7 +25856,7 @@ var require_application = __commonJS({
25856
25856
  }
25857
25857
  if (typeof arg !== "function") {
25858
25858
  offset = 1;
25859
- path24 = fn;
25859
+ path23 = fn;
25860
25860
  }
25861
25861
  }
25862
25862
  var fns = flatten(slice.call(arguments, offset));
@@ -25867,12 +25867,12 @@ var require_application = __commonJS({
25867
25867
  var router = this._router;
25868
25868
  fns.forEach(function(fn2) {
25869
25869
  if (!fn2 || !fn2.handle || !fn2.set) {
25870
- return router.use(path24, fn2);
25870
+ return router.use(path23, fn2);
25871
25871
  }
25872
- debug(".use app under %s", path24);
25873
- fn2.mountpath = path24;
25872
+ debug(".use app under %s", path23);
25873
+ fn2.mountpath = path23;
25874
25874
  fn2.parent = this;
25875
- router.use(path24, function mounted_app(req, res, next) {
25875
+ router.use(path23, function mounted_app(req, res, next) {
25876
25876
  var orig = req.app;
25877
25877
  fn2.handle(req, res, function(err) {
25878
25878
  setPrototypeOf(req, orig.request);
@@ -25884,9 +25884,9 @@ var require_application = __commonJS({
25884
25884
  }, this);
25885
25885
  return this;
25886
25886
  };
25887
- app.route = function route(path24) {
25887
+ app.route = function route(path23) {
25888
25888
  this.lazyrouter();
25889
- return this._router.route(path24);
25889
+ return this._router.route(path23);
25890
25890
  };
25891
25891
  app.engine = function engine(ext, fn) {
25892
25892
  if (typeof fn !== "function") {
@@ -25937,7 +25937,7 @@ var require_application = __commonJS({
25937
25937
  }
25938
25938
  return this;
25939
25939
  };
25940
- app.path = function path24() {
25940
+ app.path = function path23() {
25941
25941
  return this.parent ? this.parent.path() + this.mountpath : "";
25942
25942
  };
25943
25943
  app.enabled = function enabled2(setting) {
@@ -25953,19 +25953,19 @@ var require_application = __commonJS({
25953
25953
  return this.set(setting, false);
25954
25954
  };
25955
25955
  methods.forEach(function(method) {
25956
- app[method] = function(path24) {
25956
+ app[method] = function(path23) {
25957
25957
  if (method === "get" && arguments.length === 1) {
25958
- return this.set(path24);
25958
+ return this.set(path23);
25959
25959
  }
25960
25960
  this.lazyrouter();
25961
- var route = this._router.route(path24);
25961
+ var route = this._router.route(path23);
25962
25962
  route[method].apply(route, slice.call(arguments, 1));
25963
25963
  return this;
25964
25964
  };
25965
25965
  });
25966
- app.all = function all(path24) {
25966
+ app.all = function all(path23) {
25967
25967
  this.lazyrouter();
25968
- var route = this._router.route(path24);
25968
+ var route = this._router.route(path23);
25969
25969
  var args = slice.call(arguments, 1);
25970
25970
  for (var i = 0; i < methods.length; i++) {
25971
25971
  route[methods[i]].apply(route, args);
@@ -26724,7 +26724,7 @@ var require_request = __commonJS({
26724
26724
  var subdomains2 = !isIP(hostname3) ? hostname3.split(".").reverse() : [hostname3];
26725
26725
  return subdomains2.slice(offset);
26726
26726
  });
26727
- defineGetter(req, "path", function path24() {
26727
+ defineGetter(req, "path", function path23() {
26728
26728
  return parse(this).pathname;
26729
26729
  });
26730
26730
  defineGetter(req, "hostname", function hostname3() {
@@ -27047,7 +27047,7 @@ var require_response = __commonJS({
27047
27047
  var http3 = require("http");
27048
27048
  var isAbsolute5 = require_utils2().isAbsolute;
27049
27049
  var onFinished = require_on_finished();
27050
- var path24 = require("path");
27050
+ var path23 = require("path");
27051
27051
  var statuses = require_statuses();
27052
27052
  var merge = require_utils_merge();
27053
27053
  var sign = require_cookie_signature().sign;
@@ -27056,9 +27056,9 @@ var require_response = __commonJS({
27056
27056
  var setCharset = require_utils2().setCharset;
27057
27057
  var cookie = require_cookie();
27058
27058
  var send = require_send();
27059
- var extname3 = path24.extname;
27059
+ var extname3 = path23.extname;
27060
27060
  var mime = send.mime;
27061
- var resolve15 = path24.resolve;
27061
+ var resolve15 = path23.resolve;
27062
27062
  var vary = require_vary();
27063
27063
  var res = Object.create(http3.ServerResponse.prototype);
27064
27064
  module2.exports = res;
@@ -27235,26 +27235,26 @@ var require_response = __commonJS({
27235
27235
  this.type("txt");
27236
27236
  return this.send(body);
27237
27237
  };
27238
- res.sendFile = function sendFile(path25, options, callback) {
27238
+ res.sendFile = function sendFile(path24, options, callback) {
27239
27239
  var done = callback;
27240
27240
  var req = this.req;
27241
27241
  var res2 = this;
27242
27242
  var next = req.next;
27243
27243
  var opts = options || {};
27244
- if (!path25) {
27244
+ if (!path24) {
27245
27245
  throw new TypeError("path argument is required to res.sendFile");
27246
27246
  }
27247
- if (typeof path25 !== "string") {
27247
+ if (typeof path24 !== "string") {
27248
27248
  throw new TypeError("path must be a string to res.sendFile");
27249
27249
  }
27250
27250
  if (typeof options === "function") {
27251
27251
  done = options;
27252
27252
  opts = {};
27253
27253
  }
27254
- if (!opts.root && !isAbsolute5(path25)) {
27254
+ if (!opts.root && !isAbsolute5(path24)) {
27255
27255
  throw new TypeError("path must be absolute or specify root to res.sendFile");
27256
27256
  }
27257
- var pathname = encodeURI(path25);
27257
+ var pathname = encodeURI(path24);
27258
27258
  var file = send(req, pathname, opts);
27259
27259
  sendfile(res2, file, opts, function(err) {
27260
27260
  if (done) return done(err);
@@ -27264,7 +27264,7 @@ var require_response = __commonJS({
27264
27264
  }
27265
27265
  });
27266
27266
  };
27267
- res.sendfile = function(path25, options, callback) {
27267
+ res.sendfile = function(path24, options, callback) {
27268
27268
  var done = callback;
27269
27269
  var req = this.req;
27270
27270
  var res2 = this;
@@ -27274,7 +27274,7 @@ var require_response = __commonJS({
27274
27274
  done = options;
27275
27275
  opts = {};
27276
27276
  }
27277
- var file = send(req, path25, opts);
27277
+ var file = send(req, path24, opts);
27278
27278
  sendfile(res2, file, opts, function(err) {
27279
27279
  if (done) return done(err);
27280
27280
  if (err && err.code === "EISDIR") return next();
@@ -27287,7 +27287,7 @@ var require_response = __commonJS({
27287
27287
  res.sendfile,
27288
27288
  "res.sendfile: Use res.sendFile instead"
27289
27289
  );
27290
- res.download = function download(path25, filename, options, callback) {
27290
+ res.download = function download(path24, filename, options, callback) {
27291
27291
  var done = callback;
27292
27292
  var name2 = filename;
27293
27293
  var opts = options || null;
@@ -27304,7 +27304,7 @@ var require_response = __commonJS({
27304
27304
  opts = filename;
27305
27305
  }
27306
27306
  var headers = {
27307
- "Content-Disposition": contentDisposition(name2 || path25)
27307
+ "Content-Disposition": contentDisposition(name2 || path24)
27308
27308
  };
27309
27309
  if (opts && opts.headers) {
27310
27310
  var keys = Object.keys(opts.headers);
@@ -27317,7 +27317,7 @@ var require_response = __commonJS({
27317
27317
  }
27318
27318
  opts = Object.create(opts);
27319
27319
  opts.headers = headers;
27320
- var fullPath = !opts.root ? resolve15(path25) : path25;
27320
+ var fullPath = !opts.root ? resolve15(path24) : path24;
27321
27321
  return this.sendFile(fullPath, opts, done);
27322
27322
  };
27323
27323
  res.contentType = res.type = function contentType(type) {
@@ -27618,11 +27618,11 @@ var require_serve_static = __commonJS({
27618
27618
  }
27619
27619
  var forwardError = !fallthrough;
27620
27620
  var originalUrl = parseUrl.original(req);
27621
- var path24 = parseUrl(req).pathname;
27622
- if (path24 === "/" && originalUrl.pathname.substr(-1) !== "/") {
27623
- path24 = "";
27621
+ var path23 = parseUrl(req).pathname;
27622
+ if (path23 === "/" && originalUrl.pathname.substr(-1) !== "/") {
27623
+ path23 = "";
27624
27624
  }
27625
- var stream = send(req, path24, opts);
27625
+ var stream = send(req, path23, opts);
27626
27626
  stream.on("directory", onDirectory);
27627
27627
  if (setHeaders) {
27628
27628
  stream.on("headers", setHeaders);
@@ -32265,11 +32265,11 @@ function persistNodeStartupTransport(storagePath, transport) {
32265
32265
  transport
32266
32266
  });
32267
32267
  }
32268
- function persistNodeStartupJoin(storagePath, join18) {
32268
+ function persistNodeStartupJoin(storagePath, join17) {
32269
32269
  const startup = resolveNodeStartupMetadata(storagePath);
32270
32270
  persistNodeStartupMetadata(storagePath, {
32271
32271
  ...startup,
32272
- join: join18
32272
+ join: join17
32273
32273
  });
32274
32274
  }
32275
32275
  function resolvePersistedDevTunnelId(storagePath, kind) {
@@ -33089,6 +33089,22 @@ function parseNodeSettingsSnapshot(value) {
33089
33089
  }
33090
33090
  return clone(value);
33091
33091
  }
33092
+ function parseDevTunnelHealth(value) {
33093
+ if (!isPlainObject(value)) {
33094
+ return void 0;
33095
+ }
33096
+ if (value.status !== "healthy" && value.status !== "failed" || typeof value.checkedAt !== "number" || !Number.isFinite(value.checkedAt)) {
33097
+ return void 0;
33098
+ }
33099
+ return {
33100
+ status: value.status,
33101
+ checkedAt: value.checkedAt,
33102
+ endpoint: typeof value.endpoint === "string" ? value.endpoint : void 0,
33103
+ reason: typeof value.reason === "string" ? value.reason : void 0,
33104
+ statusCode: typeof value.statusCode === "number" && Number.isFinite(value.statusCode) ? value.statusCode : void 0,
33105
+ consecutiveFailures: typeof value.consecutiveFailures === "number" && Number.isFinite(value.consecutiveFailures) ? value.consecutiveFailures : void 0
33106
+ };
33107
+ }
33092
33108
  function isClusterInfo(value) {
33093
33109
  return isPlainObject(value) && typeof value.clusterId === "string" && typeof value.createdAt === "number" && Number.isFinite(value.createdAt);
33094
33110
  }
@@ -33112,6 +33128,7 @@ function parseNodeInfo(value) {
33112
33128
  lastHeartbeat: value.lastHeartbeat,
33113
33129
  transportType: typeof value.transportType === "string" ? value.transportType : void 0,
33114
33130
  devtunnelEndpoint: typeof value.devtunnelEndpoint === "string" ? value.devtunnelEndpoint : void 0,
33131
+ devtunnelHealth: parseDevTunnelHealth(value.devtunnelHealth),
33115
33132
  dashboardOrigin: typeof value.dashboardOrigin === "string" ? value.dashboardOrigin : void 0,
33116
33133
  workDir: typeof value.workDir === "string" ? value.workDir : void 0,
33117
33134
  workDirFolders: parseStringArray(value.workDirFolders),
@@ -33266,19 +33283,19 @@ async function fetchWithTimeout(url, init, timeoutMs = DEFAULT_NODE_REQUEST_TIME
33266
33283
  cleanup();
33267
33284
  }
33268
33285
  }
33269
- async function fetchNodeWithFallback(node, path24, init, timeoutMs = DEFAULT_NODE_REQUEST_TIMEOUT_MS, trace, options) {
33286
+ async function fetchNodeWithFallback(node, path23, init, timeoutMs = DEFAULT_NODE_REQUEST_TIMEOUT_MS, trace, options) {
33270
33287
  let lastError;
33271
33288
  const endpoints = getNodeRequestEndpoints(node, options);
33272
33289
  for (const [index, endpoint] of endpoints.entries()) {
33273
33290
  const attempt = index + 1;
33274
- trace?.onAttempt?.({ attempt, endpoint, path: path24, timeoutMs, totalEndpoints: endpoints.length });
33291
+ trace?.onAttempt?.({ attempt, endpoint, path: path23, timeoutMs, totalEndpoints: endpoints.length });
33275
33292
  try {
33276
- const response = await fetchWithTimeout(`${endpoint}${path24}`, init, timeoutMs);
33277
- trace?.onResponse?.({ attempt, endpoint, path: path24, response, timeoutMs, totalEndpoints: endpoints.length });
33293
+ const response = await fetchWithTimeout(`${endpoint}${path23}`, init, timeoutMs);
33294
+ trace?.onResponse?.({ attempt, endpoint, path: path23, response, timeoutMs, totalEndpoints: endpoints.length });
33278
33295
  return { endpoint, response };
33279
33296
  } catch (error) {
33280
33297
  lastError = error;
33281
- trace?.onError?.({ attempt, endpoint, error, path: path24, timeoutMs, totalEndpoints: endpoints.length });
33298
+ trace?.onError?.({ attempt, endpoint, error, path: path23, timeoutMs, totalEndpoints: endpoints.length });
33282
33299
  }
33283
33300
  }
33284
33301
  throw lastError instanceof Error ? lastError : new Error("No reachable node endpoint");
@@ -33515,6 +33532,24 @@ var NodeRegistry = class {
33515
33532
  }
33516
33533
  }
33517
33534
  }
33535
+ updateDevTunnelHealth(id, devtunnelHealth) {
33536
+ const node = this.nodes.get(id);
33537
+ if (node) {
33538
+ if (devtunnelHealth) {
33539
+ node.devtunnelHealth = { ...devtunnelHealth };
33540
+ } else {
33541
+ delete node.devtunnelHealth;
33542
+ }
33543
+ this.store.upsertNode(node);
33544
+ }
33545
+ if (this.selfNode && this.selfNode.id === id) {
33546
+ if (devtunnelHealth) {
33547
+ this.selfNode.devtunnelHealth = { ...devtunnelHealth };
33548
+ } else {
33549
+ delete this.selfNode.devtunnelHealth;
33550
+ }
33551
+ }
33552
+ }
33518
33553
  updateDashboardOrigin(id, dashboardOrigin) {
33519
33554
  const node = this.nodes.get(id);
33520
33555
  if (node) {
@@ -34689,17 +34724,9 @@ var HeartbeatMonitor = class {
34689
34724
  running = false;
34690
34725
  followerMissedMap = /* @__PURE__ */ new Map();
34691
34726
  followerPushReachableMap = /* @__PURE__ */ new Map();
34692
- /**
34693
- * Tracks whether a push-heartbeat has EVER succeeded for a follower.
34694
- * If push has never worked, the follower is on an unreachable network
34695
- * and should not be marked offline based on push failures alone.
34696
- */
34727
+ // Tracks whether push-heartbeat has ever succeeded for a follower.
34697
34728
  followerEverReachedMap = /* @__PURE__ */ new Map();
34698
- /**
34699
- * Last known leader endpoint — preserved across clearLeader() so
34700
- * follower keepalives can still attempt to reach the leader even
34701
- * after the follower timer fires.
34702
- */
34729
+ // Preserved across clearLeader() so follower keepalives can still reach the leader.
34703
34730
  lastKnownLeaderEndpoint = null;
34704
34731
  getQueuedMessages;
34705
34732
  messageQueue;
@@ -34922,6 +34949,7 @@ var HeartbeatMonitor = class {
34922
34949
  supportedAgents: self2.supportedAgents,
34923
34950
  devtunnelEnabled: self2.devtunnelEndpoint !== void 0,
34924
34951
  devtunnelEndpoint: self2.devtunnelEndpoint,
34952
+ devtunnelHealth: self2.devtunnelHealth,
34925
34953
  dashboardOrigin: self2.dashboardOrigin,
34926
34954
  workDirFolders: self2.workDir ? listWorkDirFolders(self2.workDir) : void 0,
34927
34955
  settingsSnapshot: this.resolveCurrentSettingsSnapshot()
@@ -34942,6 +34970,7 @@ var HeartbeatMonitor = class {
34942
34970
  workDir,
34943
34971
  devtunnelEnabled,
34944
34972
  devtunnelEndpoint,
34973
+ devtunnelHealth,
34945
34974
  dashboardOrigin,
34946
34975
  workDirFolders,
34947
34976
  settingsSnapshot
@@ -34969,6 +34998,7 @@ var HeartbeatMonitor = class {
34969
34998
  ...transportType ? { transportType } : {},
34970
34999
  ...workDir ? { workDir } : {},
34971
35000
  ...devtunnelEnabled && devtunnelEndpoint ? { devtunnelEndpoint } : {},
35001
+ ...devtunnelHealth ? { devtunnelHealth } : {},
34972
35002
  ...dashboardOrigin ? { dashboardOrigin } : {},
34973
35003
  ...workDirFolders ? { workDirFolders } : {},
34974
35004
  ...settingsSnapshot ? { settingsSnapshot } : {}
@@ -35004,6 +35034,7 @@ var HeartbeatMonitor = class {
35004
35034
  }
35005
35035
  this.nodeRegistry.updateLoad(nodeId, load);
35006
35036
  this.applyReportedDevTunnelState(nodeId, devtunnelEnabled, devtunnelEndpoint);
35037
+ this.nodeRegistry.updateDevTunnelHealth(nodeId, devtunnelEnabled === false ? void 0 : devtunnelHealth);
35007
35038
  this.nodeRegistry.updateDashboardOrigin(nodeId, dashboardOrigin);
35008
35039
  if (workDirFolders) {
35009
35040
  this.nodeRegistry.updateFolders(nodeId, workDirFolders);
@@ -35053,6 +35084,7 @@ var HeartbeatMonitor = class {
35053
35084
  workDir: self2.workDir,
35054
35085
  devtunnelEnabled: self2.devtunnelEndpoint !== void 0,
35055
35086
  devtunnelEndpoint: self2.devtunnelEndpoint,
35087
+ devtunnelHealth: self2.devtunnelHealth,
35056
35088
  dashboardOrigin: self2.dashboardOrigin,
35057
35089
  workDirFolders: self2.workDir ? listWorkDirFolders(self2.workDir) : void 0,
35058
35090
  settingsSnapshot
@@ -35341,9 +35373,9 @@ var DataRouter = class {
35341
35373
  /**
35342
35374
  * Returns true if the request should be proxied to the leader.
35343
35375
  */
35344
- shouldProxy(method, path24) {
35376
+ shouldProxy(method, path23) {
35345
35377
  if (this.election.isLeader()) return false;
35346
- if (this.isExcludedPath(path24)) return false;
35378
+ if (this.isExcludedPath(path23)) return false;
35347
35379
  if (method.toUpperCase() === "GET") return false;
35348
35380
  return WRITE_METHODS.has(method.toUpperCase());
35349
35381
  }
@@ -35447,8 +35479,8 @@ var DataRouter = class {
35447
35479
  };
35448
35480
  }
35449
35481
  // ── Helpers ───────────────────────────────────────────────────────────
35450
- isExcludedPath(path24) {
35451
- return EXCLUDED_PATH_PREFIXES.some((prefix) => path24.startsWith(prefix)) || EXCLUDED_PATH_SUFFIXES.some((suffix) => path24.endsWith(suffix));
35482
+ isExcludedPath(path23) {
35483
+ return EXCLUDED_PATH_PREFIXES.some((prefix) => path23.startsWith(prefix)) || EXCLUDED_PATH_SUFFIXES.some((suffix) => path23.endsWith(suffix));
35452
35484
  }
35453
35485
  };
35454
35486
 
@@ -37171,7 +37203,6 @@ var LEGACY_FILES = [
37171
37203
  "nodes.json",
37172
37204
  "tasks.json",
37173
37205
  "shares.json",
37174
- "node-operations.json",
37175
37206
  "election.json"
37176
37207
  ];
37177
37208
  var LEGACY_DIRS = ["logs", "task-logs"];
@@ -37761,6 +37792,9 @@ ${joinErrors.map((e) => ` - ${e}`).join("\n")}`
37761
37792
  if (self2.devtunnelEndpoint) {
37762
37793
  joinBody.devtunnelEndpoint = self2.devtunnelEndpoint;
37763
37794
  }
37795
+ if (self2.devtunnelHealth) {
37796
+ joinBody.devtunnelHealth = self2.devtunnelHealth;
37797
+ }
37764
37798
  if (self2.dashboardOrigin) {
37765
37799
  joinBody.dashboardOrigin = self2.dashboardOrigin;
37766
37800
  }
@@ -38094,6 +38128,7 @@ ${joinErrors.map((e) => ` - ${e}`).join("\n")}`
38094
38128
  workDir: currentSelf.workDir,
38095
38129
  workDirFolders: listWorkDirFolders(this.getWorkDir()),
38096
38130
  ...currentSelf.devtunnelEndpoint ? { devtunnelEndpoint: currentSelf.devtunnelEndpoint } : {},
38131
+ ...currentSelf.devtunnelHealth ? { devtunnelHealth: currentSelf.devtunnelHealth } : {},
38097
38132
  ...currentSelf.dashboardOrigin ? { dashboardOrigin: currentSelf.dashboardOrigin } : {},
38098
38133
  ...currentSelf.settingsSnapshot ? { settingsSnapshot: currentSelf.settingsSnapshot } : {}
38099
38134
  };
@@ -39276,8 +39311,8 @@ function getErrorMap() {
39276
39311
 
39277
39312
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
39278
39313
  var makeIssue = (params) => {
39279
- const { data, path: path24, errorMaps, issueData } = params;
39280
- const fullPath = [...path24, ...issueData.path || []];
39314
+ const { data, path: path23, errorMaps, issueData } = params;
39315
+ const fullPath = [...path23, ...issueData.path || []];
39281
39316
  const fullIssue = {
39282
39317
  ...issueData,
39283
39318
  path: fullPath
@@ -39393,11 +39428,11 @@ var errorUtil;
39393
39428
 
39394
39429
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
39395
39430
  var ParseInputLazyPath = class {
39396
- constructor(parent, value, path24, key) {
39431
+ constructor(parent, value, path23, key) {
39397
39432
  this._cachedPath = [];
39398
39433
  this.parent = parent;
39399
39434
  this.data = value;
39400
- this._path = path24;
39435
+ this._path = path23;
39401
39436
  this._key = key;
39402
39437
  }
39403
39438
  get path() {
@@ -42946,6 +42981,14 @@ var NodeSettingsSnapshotSchema = external_exports.object({
42946
42981
  api: SystemPackageInfoSchema.optional()
42947
42982
  }).optional()
42948
42983
  });
42984
+ var DevTunnelHealthSchema = external_exports.object({
42985
+ status: external_exports.enum(["healthy", "failed"]),
42986
+ checkedAt: external_exports.number(),
42987
+ endpoint: external_exports.string().optional(),
42988
+ reason: external_exports.string().optional(),
42989
+ statusCode: external_exports.number().optional(),
42990
+ consecutiveFailures: external_exports.number().optional()
42991
+ });
42949
42992
 
42950
42993
  // ../../packages/api/src/schemas/cluster.ts
42951
42994
  var NodeInfoSchema = external_exports.object({
@@ -42960,6 +43003,7 @@ var NodeInfoSchema = external_exports.object({
42960
43003
  lastHeartbeat: external_exports.number(),
42961
43004
  transportType: external_exports.string().optional(),
42962
43005
  devtunnelEndpoint: external_exports.string().optional(),
43006
+ devtunnelHealth: DevTunnelHealthSchema.optional(),
42963
43007
  dashboardOrigin: external_exports.string().optional(),
42964
43008
  workDir: external_exports.string().optional(),
42965
43009
  workDirFolders: external_exports.array(external_exports.string()).optional(),
@@ -42996,6 +43040,7 @@ var JoinClusterBody = external_exports.object({
42996
43040
  workDir: external_exports.string().optional(),
42997
43041
  workDirFolders: external_exports.array(external_exports.string()).optional(),
42998
43042
  devtunnelEndpoint: external_exports.string().url().optional(),
43043
+ devtunnelHealth: DevTunnelHealthSchema.optional(),
42999
43044
  dashboardOrigin: external_exports.string().url().optional(),
43000
43045
  settingsSnapshot: NodeSettingsSnapshotSchema.optional(),
43001
43046
  tasks: external_exports.array(JoinTaskSchema).default([])
@@ -43040,6 +43085,7 @@ var NodeInfoSchema2 = external_exports.object({
43040
43085
  lastHeartbeat: external_exports.number(),
43041
43086
  transportType: external_exports.string().optional(),
43042
43087
  devtunnelEndpoint: external_exports.string().optional(),
43088
+ devtunnelHealth: DevTunnelHealthSchema.optional(),
43043
43089
  dashboardOrigin: external_exports.string().optional(),
43044
43090
  workDir: external_exports.string().optional(),
43045
43091
  workDirFolders: external_exports.array(external_exports.string()).optional(),
@@ -43325,8 +43371,8 @@ var BatchTaskIdsBody = external_exports.object({
43325
43371
  });
43326
43372
 
43327
43373
  // ../../packages/api/src/app/server.ts
43328
- var path21 = __toESM(require("path"), 1);
43329
- var fs20 = __toESM(require("fs"), 1);
43374
+ var path20 = __toESM(require("path"), 1);
43375
+ var fs19 = __toESM(require("fs"), 1);
43330
43376
  var import_express14 = __toESM(require_express2(), 1);
43331
43377
 
43332
43378
  // ../../packages/api/src/middleware/auth.ts
@@ -43463,8 +43509,8 @@ function decodePathSegment(value) {
43463
43509
  return value;
43464
43510
  }
43465
43511
  }
43466
- function getSingleTaskDeleteId(path24) {
43467
- const match = /^\/api\/tasks\/([^/]+)$/.exec(path24);
43512
+ function getSingleTaskDeleteId(path23) {
43513
+ const match = /^\/api\/tasks\/([^/]+)$/.exec(path23);
43468
43514
  return match ? decodePathSegment(match[1]) : null;
43469
43515
  }
43470
43516
  function getSuccessfulBatchDeleteIds(body) {
@@ -44503,8 +44549,6 @@ function computeParentPath(rootPath, currentPath, useAbsolute) {
44503
44549
  }
44504
44550
 
44505
44551
  // ../../packages/api/src/node/node-operation-service.ts
44506
- var fs15 = __toESM(require("fs"), 1);
44507
- var path17 = __toESM(require("path"), 1);
44508
44552
  var import_node_crypto7 = require("crypto");
44509
44553
 
44510
44554
  // ../../packages/api/src/node/agent-upgrade-service.ts
@@ -44791,6 +44835,7 @@ function upgradeRuntimeAgentForDeps(deps, agent) {
44791
44835
  }
44792
44836
 
44793
44837
  // ../../packages/api/src/node/node-operation-service.ts
44838
+ var LEADER_REPORT_RETRY_MS = 5e3;
44794
44839
  var NodeOperationFailure = class extends Error {
44795
44840
  constructor(message, result) {
44796
44841
  super(message);
@@ -44819,60 +44864,6 @@ var InMemoryNodeOperationStore = class {
44819
44864
  return clone2(next);
44820
44865
  }
44821
44866
  };
44822
- var FileNodeOperationStore = class {
44823
- constructor(storagePath) {
44824
- this.storagePath = storagePath;
44825
- }
44826
- operations = /* @__PURE__ */ new Map();
44827
- loaded = false;
44828
- get(id) {
44829
- this.load();
44830
- const operation = this.operations.get(id);
44831
- return operation ? clone2(operation) : null;
44832
- }
44833
- list(filter = {}) {
44834
- this.load();
44835
- return Array.from(this.operations.values()).filter((operation) => matchesFilter(operation, filter)).sort((a, b) => b.createdAt - a.createdAt).map((operation) => clone2(operation));
44836
- }
44837
- upsert(operation) {
44838
- this.load();
44839
- const copy = clone2(operation);
44840
- this.operations.set(copy.id, copy);
44841
- this.persist();
44842
- return clone2(copy);
44843
- }
44844
- update(id, updates) {
44845
- this.load();
44846
- const current = this.operations.get(id);
44847
- if (!current) return null;
44848
- const next = { ...current, ...clone2(updates), id, createdAt: current.createdAt };
44849
- this.operations.set(id, next);
44850
- this.persist();
44851
- return clone2(next);
44852
- }
44853
- load() {
44854
- if (this.loaded) return;
44855
- this.loaded = true;
44856
- if (!fs15.existsSync(this.filePath)) return;
44857
- const raw = JSON.parse(fs15.readFileSync(this.filePath, "utf-8"));
44858
- const entries = Array.isArray(raw) ? raw : Object.values(raw);
44859
- for (const entry of entries) {
44860
- if (isNodeOperation(entry)) {
44861
- this.operations.set(entry.id, clone2(entry));
44862
- }
44863
- }
44864
- }
44865
- persist() {
44866
- fs15.mkdirSync(this.storagePath, { recursive: true });
44867
- const body = JSON.stringify(Object.fromEntries(this.operations), null, 2);
44868
- const tmpPath = `${this.filePath}.tmp`;
44869
- fs15.writeFileSync(tmpPath, body, "utf-8");
44870
- fs15.renameSync(tmpPath, this.filePath);
44871
- }
44872
- get filePath() {
44873
- return path17.join(this.storagePath, "node-operations.json");
44874
- }
44875
- };
44876
44867
  var NodeOperationService = class {
44877
44868
  constructor(deps, store) {
44878
44869
  this.deps = deps;
@@ -44881,6 +44872,7 @@ var NodeOperationService = class {
44881
44872
  this.registerHandler("workdir.branch-create", runWorkDirBranchCreateOperation);
44882
44873
  }
44883
44874
  handlers = /* @__PURE__ */ new Map();
44875
+ leaderReportRetryTimers = /* @__PURE__ */ new Map();
44884
44876
  registerHandler(kind, handler) {
44885
44877
  this.handlers.set(kind, handler);
44886
44878
  }
@@ -44976,25 +44968,46 @@ var NodeOperationService = class {
44976
44968
  async reportToLeader(operation) {
44977
44969
  if (this.deps.nodeRegistry.isLeader()) return;
44978
44970
  const leaderEndpoint = this.deps.nodeRegistry.getLeaderEndpoint?.();
44979
- if (!leaderEndpoint) return;
44971
+ if (!leaderEndpoint) {
44972
+ this.scheduleLeaderReportRetry(operation);
44973
+ return;
44974
+ }
44980
44975
  try {
44981
- await fetch(`${leaderEndpoint}/api/worker/node-operations/${operation.id}`, applyRequestAuthHeaders({
44976
+ const response = await fetch(`${leaderEndpoint}/api/worker/node-operations/${operation.id}`, applyRequestAuthHeaders({
44982
44977
  method: "POST",
44983
44978
  headers: { "Content-Type": "application/json" },
44984
44979
  body: JSON.stringify(operation)
44985
44980
  }));
44981
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
44982
+ this.clearLeaderReportRetry(operation.id);
44986
44983
  } catch (err) {
44987
44984
  this.deps.logger.child("node-operation").warn("failed to report node operation update to leader", {
44988
44985
  operationId: operation.id,
44989
44986
  kind: operation.kind,
44987
+ status: operation.status,
44990
44988
  error: err instanceof Error ? err.message : String(err)
44991
44989
  });
44990
+ this.scheduleLeaderReportRetry(operation);
44992
44991
  }
44993
44992
  }
44993
+ scheduleLeaderReportRetry(operation) {
44994
+ if (!isTerminalStatus(operation.status) || this.leaderReportRetryTimers.has(operation.id)) return;
44995
+ const timer = setTimeout(() => {
44996
+ this.leaderReportRetryTimers.delete(operation.id);
44997
+ void this.reportToLeader(operation);
44998
+ }, LEADER_REPORT_RETRY_MS);
44999
+ this.leaderReportRetryTimers.set(operation.id, timer);
45000
+ }
45001
+ clearLeaderReportRetry(id) {
45002
+ const timer = this.leaderReportRetryTimers.get(id);
45003
+ if (!timer) return;
45004
+ clearTimeout(timer);
45005
+ this.leaderReportRetryTimers.delete(id);
45006
+ }
44994
45007
  };
44995
45008
  function getNodeOperationService(deps) {
44996
45009
  if (deps.nodeOperationService) return deps.nodeOperationService;
44997
- const store = deps.nodeOperationStore ?? (deps.storagePath ? new FileNodeOperationStore(deps.storagePath) : new InMemoryNodeOperationStore());
45010
+ const store = deps.nodeOperationStore ?? new InMemoryNodeOperationStore();
44998
45011
  const service = new NodeOperationService(deps, store);
44999
45012
  deps.nodeOperationStore = store;
45000
45013
  deps.nodeOperationService = service;
@@ -45064,10 +45077,8 @@ function readSettingsSnapshot(value) {
45064
45077
  function matchesFilter(operation, filter) {
45065
45078
  return (!filter.nodeId || operation.nodeId === filter.nodeId) && (!filter.status || operation.status === filter.status) && (!filter.kind || operation.kind === filter.kind);
45066
45079
  }
45067
- function isNodeOperation(value) {
45068
- if (!value || typeof value !== "object") return false;
45069
- const record = value;
45070
- return typeof record.id === "string" && typeof record.kind === "string" && typeof record.nodeId === "string" && typeof record.status === "string" && typeof record.createdAt === "number" && typeof record.updatedAt === "number";
45080
+ function isTerminalStatus(status) {
45081
+ return status === "succeeded" || status === "failed";
45071
45082
  }
45072
45083
  function clone2(value) {
45073
45084
  return JSON.parse(JSON.stringify(value));
@@ -45180,7 +45191,7 @@ async function sendNodeWorkDirBranchCreateOperation(req, res, nodeId) {
45180
45191
  }
45181
45192
 
45182
45193
  // ../../packages/api/src/tasks/task-route-utils.ts
45183
- var fs16 = __toESM(require("fs"), 1);
45194
+ var fs15 = __toESM(require("fs"), 1);
45184
45195
  var import_node_stream2 = require("stream");
45185
45196
  var import_promises5 = require("stream/promises");
45186
45197
 
@@ -45242,10 +45253,10 @@ function readLocalTaskLogs(engineRegistry, taskId, after, agent) {
45242
45253
  throw new MeshyError("VALIDATION_ERROR", `Engine not registered for agent: ${agent}`, 400);
45243
45254
  }
45244
45255
  const logPath = engine.getLogPath(taskId);
45245
- if (!fs16.existsSync(logPath)) {
45256
+ if (!fs15.existsSync(logPath)) {
45246
45257
  return { logs: [], total: 0 };
45247
45258
  }
45248
- const content = fs16.readFileSync(logPath, "utf-8");
45259
+ const content = fs15.readFileSync(logPath, "utf-8");
45249
45260
  const allLines = content.trim().split("\n").filter(Boolean);
45250
45261
  const logs = [];
45251
45262
  for (let i = after; i < allLines.length; i++) {
@@ -45480,19 +45491,19 @@ var import_node_child_process10 = require("child_process");
45480
45491
  var import_node_crypto8 = require("crypto");
45481
45492
 
45482
45493
  // ../../packages/api/src/node/node-terminal-service.ts
45483
- var fs17 = __toESM(require("fs"), 1);
45484
- var path18 = __toESM(require("path"), 1);
45494
+ var fs16 = __toESM(require("fs"), 1);
45495
+ var path17 = __toESM(require("path"), 1);
45485
45496
  var DEFAULT_OUTPUT_LIMIT_BYTES = 64 * 1024;
45486
45497
  function isAbsolutePath2(value) {
45487
- return path18.isAbsolute(value) || /^[A-Za-z]:[\/]/.test(value);
45498
+ return path17.isAbsolute(value) || /^[A-Za-z]:[\/]/.test(value);
45488
45499
  }
45489
45500
  function resolveNodeTerminalCwd(nodeId, rootPath, cwd) {
45490
45501
  if (!rootPath) {
45491
45502
  throw new MeshyError("VALIDATION_ERROR", `Node ${nodeId} does not expose a working directory`, 400);
45492
45503
  }
45493
45504
  const requestedCwd = cwd?.trim() || ".";
45494
- const resolved = isAbsolutePath2(requestedCwd) ? path18.resolve(requestedCwd) : path18.resolve(rootPath, requestedCwd);
45495
- if (!fs17.existsSync(resolved) || !fs17.statSync(resolved).isDirectory()) {
45505
+ const resolved = isAbsolutePath2(requestedCwd) ? path17.resolve(requestedCwd) : path17.resolve(rootPath, requestedCwd);
45506
+ if (!fs16.existsSync(resolved) || !fs16.statSync(resolved).isDirectory()) {
45496
45507
  throw new MeshyError("VALIDATION_ERROR", `Working directory does not exist: ${resolved}`, 400);
45497
45508
  }
45498
45509
  return resolved;
@@ -45731,13 +45742,13 @@ function cancelTaskOnCurrentNode(deps, taskId, options = {}) {
45731
45742
  }
45732
45743
 
45733
45744
  // ../../packages/api/src/tasks/task-output-service.ts
45734
- var fs19 = __toESM(require("fs"), 1);
45735
- var path20 = __toESM(require("path"), 1);
45745
+ var fs18 = __toESM(require("fs"), 1);
45746
+ var path19 = __toESM(require("path"), 1);
45736
45747
 
45737
45748
  // ../../packages/api/src/preview/preview-server.ts
45738
45749
  var crypto3 = __toESM(require("crypto"), 1);
45739
- var fs18 = __toESM(require("fs"), 1);
45740
- var path19 = __toESM(require("path"), 1);
45750
+ var fs17 = __toESM(require("fs"), 1);
45751
+ var path18 = __toESM(require("path"), 1);
45741
45752
  var http2 = __toESM(require("http"), 1);
45742
45753
  var import_node_stream3 = require("stream");
45743
45754
  var import_promises6 = require("stream/promises");
@@ -45849,19 +45860,19 @@ function buildPreviewWorkerProxyHeaders(req) {
45849
45860
  // ../../packages/api/src/preview/preview-server.ts
45850
45861
  function resolvePreviewPath(rootPath, relativePath) {
45851
45862
  const sanitizedPath = relativePath.replace(/\\/g, "/");
45852
- const resolvedPath = path19.resolve(rootPath, sanitizedPath);
45853
- const normalizedRoot = path19.resolve(rootPath);
45854
- if (!resolvedPath.startsWith(normalizedRoot + path19.sep) && resolvedPath !== normalizedRoot) {
45863
+ const resolvedPath = path18.resolve(rootPath, sanitizedPath);
45864
+ const normalizedRoot = path18.resolve(rootPath);
45865
+ if (!resolvedPath.startsWith(normalizedRoot + path18.sep) && resolvedPath !== normalizedRoot) {
45855
45866
  throw new Error("Invalid preview path");
45856
45867
  }
45857
45868
  return {
45858
45869
  absolutePath: resolvedPath,
45859
- normalizedPath: path19.relative(normalizedRoot, resolvedPath).split(path19.sep).join("/")
45870
+ normalizedPath: path18.relative(normalizedRoot, resolvedPath).split(path18.sep).join("/")
45860
45871
  };
45861
45872
  }
45862
45873
  function resolvePreviewEntryPath(rootPath, entryPath) {
45863
45874
  const { absolutePath, normalizedPath } = resolvePreviewPath(rootPath, entryPath ?? "index.html");
45864
- if (!fs18.existsSync(absolutePath) || !fs18.statSync(absolutePath).isFile()) {
45875
+ if (!fs17.existsSync(absolutePath) || !fs17.statSync(absolutePath).isFile()) {
45865
45876
  throw new Error("Preview entry not found");
45866
45877
  }
45867
45878
  return normalizedPath;
@@ -45963,7 +45974,7 @@ var MIME_MAP2 = {
45963
45974
  ".mdx": "text/markdown"
45964
45975
  };
45965
45976
  function getMime(filePath) {
45966
- return MIME_MAP2[path19.extname(filePath).toLowerCase()] ?? "application/octet-stream";
45977
+ return MIME_MAP2[path18.extname(filePath).toLowerCase()] ?? "application/octet-stream";
45967
45978
  }
45968
45979
  function escapeHtml(value) {
45969
45980
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
@@ -46317,14 +46328,14 @@ async function sendPreviewAssetResponse(sessionManager, token, requestedPath, re
46317
46328
  res.end("Invalid path");
46318
46329
  return;
46319
46330
  }
46320
- if (!fs18.existsSync(resolved) || !fs18.statSync(resolved).isFile()) {
46331
+ if (!fs17.existsSync(resolved) || !fs17.statSync(resolved).isFile()) {
46321
46332
  res.writeHead(404, { "Content-Type": "text/plain" });
46322
46333
  res.end("File not found");
46323
46334
  return;
46324
46335
  }
46325
- const ext = path19.extname(resolved).toLowerCase();
46336
+ const ext = path18.extname(resolved).toLowerCase();
46326
46337
  const mime = ext === ".md" || ext === ".mdx" ? "text/html" : getMime(resolved);
46327
- const content = ext === ".md" || ext === ".mdx" ? renderMarkdownDocument(fs18.readFileSync(resolved, "utf8"), path19.basename(resolved)) : fs18.readFileSync(resolved);
46338
+ const content = ext === ".md" || ext === ".mdx" ? renderMarkdownDocument(fs17.readFileSync(resolved, "utf8"), path18.basename(resolved)) : fs17.readFileSync(resolved);
46328
46339
  res.writeHead(200, {
46329
46340
  "Content-Type": mime,
46330
46341
  "Content-Length": content.length,
@@ -46646,13 +46657,13 @@ function getLocalTaskOutputDownload(taskEngine, taskId, filePath) {
46646
46657
  const rootPath = getTaskOutputRoot(taskEngine, taskId);
46647
46658
  try {
46648
46659
  const absolutePath = resolveOutputPath(rootPath, filePath);
46649
- if (!fs19.existsSync(absolutePath) || !fs19.statSync(absolutePath).isFile()) {
46660
+ if (!fs18.existsSync(absolutePath) || !fs18.statSync(absolutePath).isFile()) {
46650
46661
  throw new MeshyError("TASK_NOT_FOUND", `File not found: ${filePath}`, 404);
46651
46662
  }
46652
46663
  const { mimeType } = classifyFile(absolutePath);
46653
- const fileName = path20.basename(absolutePath).replace(/"/g, "");
46664
+ const fileName = path19.basename(absolutePath).replace(/"/g, "");
46654
46665
  return {
46655
- content: fs19.readFileSync(absolutePath),
46666
+ content: fs18.readFileSync(absolutePath),
46656
46667
  headers: {
46657
46668
  "Content-Type": mimeType,
46658
46669
  "Content-Disposition": `inline; filename="${fileName}"`,
@@ -49609,8 +49620,8 @@ function hasAuthorizationHeader(req) {
49609
49620
  function resolveRuntimeBaseDir() {
49610
49621
  const entryPath = process.argv[1];
49611
49622
  if (typeof entryPath === "string" && entryPath.length > 0) {
49612
- const resolved = fs20.realpathSync(path21.resolve(entryPath));
49613
- return path21.dirname(resolved);
49623
+ const resolved = fs19.realpathSync(path20.resolve(entryPath));
49624
+ return path20.dirname(resolved);
49614
49625
  }
49615
49626
  return process.cwd();
49616
49627
  }
@@ -49618,18 +49629,18 @@ function resolveStaticDir(baseDir) {
49618
49629
  const envStaticDir = process.env.MESHY_STATIC_DIR;
49619
49630
  const candidateDirs = [
49620
49631
  envStaticDir,
49621
- path21.resolve(baseDir, "dashboard"),
49622
- path21.resolve(baseDir, "../dashboard"),
49623
- path21.resolve(baseDir, "../../dashboard/dist"),
49624
- path21.resolve(baseDir, "../../../packages/dashboard/dist"),
49625
- path21.resolve(baseDir, "../public"),
49626
- path21.resolve(baseDir, "../../packages/api/public"),
49627
- path21.resolve(baseDir, "../../../packages/api/public"),
49628
- path21.resolve(process.cwd(), "packages/dashboard/dist"),
49629
- path21.resolve(process.cwd(), "packages/api/public")
49632
+ path20.resolve(baseDir, "dashboard"),
49633
+ path20.resolve(baseDir, "../dashboard"),
49634
+ path20.resolve(baseDir, "../../dashboard/dist"),
49635
+ path20.resolve(baseDir, "../../../packages/dashboard/dist"),
49636
+ path20.resolve(baseDir, "../public"),
49637
+ path20.resolve(baseDir, "../../packages/api/public"),
49638
+ path20.resolve(baseDir, "../../../packages/api/public"),
49639
+ path20.resolve(process.cwd(), "packages/dashboard/dist"),
49640
+ path20.resolve(process.cwd(), "packages/api/public")
49630
49641
  ].filter((value) => typeof value === "string" && value.length > 0);
49631
49642
  for (const candidate of candidateDirs) {
49632
- if (fs20.existsSync(candidate)) {
49643
+ if (fs19.existsSync(candidate)) {
49633
49644
  return candidate;
49634
49645
  }
49635
49646
  }
@@ -49730,8 +49741,8 @@ function createServer2(deps) {
49730
49741
  app.use("/api/node-operations", createNodeOperationRoutes());
49731
49742
  app.use("/api/events", createEventRoutes());
49732
49743
  if (staticDir) {
49733
- const indexPath = path21.join(staticDir, "index.html");
49734
- if (fs20.existsSync(indexPath)) {
49744
+ const indexPath = path20.join(staticDir, "index.html");
49745
+ if (fs19.existsSync(indexPath)) {
49735
49746
  app.get("*", (req, res, next) => {
49736
49747
  if (isApiRequest(req)) {
49737
49748
  next();
@@ -50127,8 +50138,8 @@ var terminalWriter = {
50127
50138
  };
50128
50139
 
50129
50140
  // src/startup.ts
50130
- var fs21 = __toESM(require("fs"), 1);
50131
- var path22 = __toESM(require("path"), 1);
50141
+ var fs20 = __toESM(require("fs"), 1);
50142
+ var path21 = __toESM(require("path"), 1);
50132
50143
  var readline = __toESM(require("readline/promises"), 1);
50133
50144
  var import_node_child_process12 = require("child_process");
50134
50145
  function getDefaultNodeName() {
@@ -50191,19 +50202,19 @@ function createDefaultCommandRunner(platform2) {
50191
50202
  };
50192
50203
  }
50193
50204
  function getNodeMetadataPath2(storagePath) {
50194
- return path22.join(storagePath, "metadata.json");
50205
+ return path21.join(storagePath, "metadata.json");
50195
50206
  }
50196
50207
  function readStartupMetadataFile(storagePath) {
50197
50208
  try {
50198
- const raw = JSON.parse(fs21.readFileSync(getNodeMetadataPath2(storagePath), "utf-8"));
50209
+ const raw = JSON.parse(fs20.readFileSync(getNodeMetadataPath2(storagePath), "utf-8"));
50199
50210
  return typeof raw === "object" && raw !== null ? raw : {};
50200
50211
  } catch {
50201
50212
  return {};
50202
50213
  }
50203
50214
  }
50204
50215
  function writeStartupMetadataFile(storagePath, metadata) {
50205
- fs21.mkdirSync(storagePath, { recursive: true });
50206
- fs21.writeFileSync(getNodeMetadataPath2(storagePath), JSON.stringify(metadata, null, 2) + "\n", "utf-8");
50216
+ fs20.mkdirSync(storagePath, { recursive: true });
50217
+ fs20.writeFileSync(getNodeMetadataPath2(storagePath), JSON.stringify(metadata, null, 2) + "\n", "utf-8");
50207
50218
  }
50208
50219
  function formatLocalDate2(now) {
50209
50220
  const year = now.getFullYear();
@@ -50442,9 +50453,9 @@ async function ensureStartupRequirements(storagePath, options = {}) {
50442
50453
  metadata
50443
50454
  };
50444
50455
  }
50445
- function loadConfigFile(path24) {
50456
+ function loadConfigFile(path23) {
50446
50457
  try {
50447
- const raw = fs21.readFileSync(path24, "utf-8");
50458
+ const raw = fs20.readFileSync(path23, "utf-8");
50448
50459
  return JSON.parse(raw);
50449
50460
  } catch {
50450
50461
  return {};
@@ -50622,26 +50633,26 @@ function formatLoadedStartMetadata(info, authEnabled) {
50622
50633
  }
50623
50634
 
50624
50635
  // src/runtime-metadata.ts
50625
- var fs22 = __toESM(require("fs"), 1);
50626
- var path23 = __toESM(require("path"), 1);
50636
+ var fs21 = __toESM(require("fs"), 1);
50637
+ var path22 = __toESM(require("path"), 1);
50627
50638
  var import_node_child_process13 = require("child_process");
50628
50639
  var runtimeDir = resolveRuntimeDir();
50629
50640
  var appRoot = resolveAppRoot(runtimeDir);
50630
- var repoRoot = path23.resolve(appRoot, "../..");
50641
+ var repoRoot = path22.resolve(appRoot, "../..");
50631
50642
  function resolveRuntimeDir() {
50632
50643
  const entryPath = process.argv[1];
50633
50644
  if (typeof entryPath === "string" && entryPath.length > 0) {
50634
50645
  try {
50635
- return path23.dirname(fs22.realpathSync(path23.resolve(entryPath)));
50646
+ return path22.dirname(fs21.realpathSync(path22.resolve(entryPath)));
50636
50647
  } catch {
50637
- return path23.dirname(path23.resolve(entryPath));
50648
+ return path22.dirname(path22.resolve(entryPath));
50638
50649
  }
50639
50650
  }
50640
50651
  return process.cwd();
50641
50652
  }
50642
50653
  function readJsonFile(filePath) {
50643
50654
  try {
50644
- return JSON.parse(fs22.readFileSync(filePath, "utf-8"));
50655
+ return JSON.parse(fs21.readFileSync(filePath, "utf-8"));
50645
50656
  } catch {
50646
50657
  return null;
50647
50658
  }
@@ -50651,9 +50662,9 @@ function readPackageManifest(filePath) {
50651
50662
  }
50652
50663
  function readEmbeddedRuntimeMetadata() {
50653
50664
  const candidates = [
50654
- path23.join(appRoot, "runtime-metadata.json"),
50655
- path23.join(runtimeDir, "runtime-metadata.json"),
50656
- path23.resolve(process.cwd(), "apps/node/dist/runtime-metadata.json")
50665
+ path22.join(appRoot, "runtime-metadata.json"),
50666
+ path22.join(runtimeDir, "runtime-metadata.json"),
50667
+ path22.resolve(process.cwd(), "apps/node/dist/runtime-metadata.json")
50657
50668
  ];
50658
50669
  for (const candidate of candidates) {
50659
50670
  const metadata = readJsonFile(candidate);
@@ -50666,23 +50677,23 @@ function readEmbeddedRuntimeMetadata() {
50666
50677
  function resolveAppRoot(baseDir) {
50667
50678
  const candidates = [
50668
50679
  baseDir,
50669
- path23.resolve(baseDir, ".."),
50670
- path23.resolve(process.cwd(), "apps/node/dist"),
50671
- path23.resolve(process.cwd(), "apps/node"),
50680
+ path22.resolve(baseDir, ".."),
50681
+ path22.resolve(process.cwd(), "apps/node/dist"),
50682
+ path22.resolve(process.cwd(), "apps/node"),
50672
50683
  process.cwd()
50673
50684
  ];
50674
50685
  for (const candidate of candidates) {
50675
- const manifest = readPackageManifest(path23.join(candidate, "package.json"));
50686
+ const manifest = readPackageManifest(path22.join(candidate, "package.json"));
50676
50687
  if (manifest?.name === "@meshy/node" || manifest?.name === "meshy-node") {
50677
50688
  return candidate;
50678
50689
  }
50679
50690
  }
50680
50691
  for (const candidate of candidates) {
50681
- if (fs22.existsSync(path23.join(candidate, "package.json"))) {
50692
+ if (fs21.existsSync(path22.join(candidate, "package.json"))) {
50682
50693
  return candidate;
50683
50694
  }
50684
50695
  }
50685
- return path23.resolve(baseDir, "..");
50696
+ return path22.resolve(baseDir, "..");
50686
50697
  }
50687
50698
  function toPackageInfo(filePath) {
50688
50699
  const manifest = readPackageManifest(filePath);
@@ -50742,8 +50753,8 @@ function buildRuntimeMetadata(storagePath) {
50742
50753
  components: startupRequirements.components
50743
50754
  };
50744
50755
  }
50745
- const appPackage = toPackageInfo(path23.join(appRoot, "package.json"));
50746
- const workspaceManifest = readPackageManifest(path23.join(repoRoot, "package.json"));
50756
+ const appPackage = toPackageInfo(path22.join(appRoot, "package.json"));
50757
+ const workspaceManifest = readPackageManifest(path22.join(repoRoot, "package.json"));
50747
50758
  return {
50748
50759
  packageName: appPackage?.name ?? "meshy",
50749
50760
  packageVersion: appPackage?.version ?? "0.1.0",
@@ -50751,11 +50762,11 @@ function buildRuntimeMetadata(storagePath) {
50751
50762
  startupRequirementsLastCheckedOn: startupRequirements.lastCheckedOn,
50752
50763
  components: startupRequirements.components,
50753
50764
  packages: {
50754
- workspace: toPackageInfo(path23.join(repoRoot, "package.json")),
50765
+ workspace: toPackageInfo(path22.join(repoRoot, "package.json")),
50755
50766
  node: appPackage,
50756
- core: toPackageInfo(path23.join(repoRoot, "packages/core/package.json")),
50757
- dashboard: toPackageInfo(path23.join(repoRoot, "packages/dashboard/package.json")),
50758
- api: toPackageInfo(path23.join(repoRoot, "packages/api/package.json"))
50767
+ core: toPackageInfo(path22.join(repoRoot, "packages/core/package.json")),
50768
+ dashboard: toPackageInfo(path22.join(repoRoot, "packages/dashboard/package.json")),
50769
+ api: toPackageInfo(path22.join(repoRoot, "packages/api/package.json"))
50759
50770
  },
50760
50771
  repository: {
50761
50772
  url: normalizeRepositoryUrl(readGitValue(["config", "--get", "remote.upstream.url"])) ?? normalizeRepositoryUrl(readGitValue(["config", "--get", "remote.origin.url"])) ?? readRepositoryUrlFromManifest(workspaceManifest),
@@ -50765,6 +50776,82 @@ function buildRuntimeMetadata(storagePath) {
50765
50776
  };
50766
50777
  }
50767
50778
 
50779
+ // src/bootstrap/tunnel-health.ts
50780
+ var DEFAULT_TUNNEL_REACHABILITY_INTERVAL_MS = 6e4;
50781
+ var DEFAULT_TUNNEL_REACHABILITY_TIMEOUT_MS = 5e3;
50782
+ var DEFAULT_TUNNEL_RESTART_FAILURE_THRESHOLD = 2;
50783
+ function createTunnelReachabilityMonitor(options = {}) {
50784
+ const failureThreshold = options.failureThreshold ?? DEFAULT_TUNNEL_RESTART_FAILURE_THRESHOLD;
50785
+ const fetchImpl = options.fetchImpl ?? fetch;
50786
+ const healthPath = options.healthPath ?? "/api/system/health";
50787
+ const intervalMs = options.intervalMs ?? DEFAULT_TUNNEL_REACHABILITY_INTERVAL_MS;
50788
+ const now = options.now ?? (() => Date.now());
50789
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TUNNEL_REACHABILITY_TIMEOUT_MS;
50790
+ let consecutiveFailures = 0;
50791
+ let lastCheckedAt = null;
50792
+ function recordFailure(reason, statusCode) {
50793
+ consecutiveFailures += 1;
50794
+ return {
50795
+ available: false,
50796
+ checked: true,
50797
+ consecutiveFailures,
50798
+ reason,
50799
+ shouldRestart: consecutiveFailures >= failureThreshold,
50800
+ ...statusCode !== void 0 ? { statusCode } : {}
50801
+ };
50802
+ }
50803
+ return {
50804
+ async check(endpoint) {
50805
+ const currentTime = now();
50806
+ if (lastCheckedAt !== null && currentTime - lastCheckedAt < intervalMs) {
50807
+ return {
50808
+ available: true,
50809
+ checked: false,
50810
+ consecutiveFailures,
50811
+ shouldRestart: false
50812
+ };
50813
+ }
50814
+ lastCheckedAt = currentTime;
50815
+ if (!endpoint) {
50816
+ return recordFailure("missing endpoint");
50817
+ }
50818
+ try {
50819
+ const response = await fetchWithTimeout2(fetchImpl, buildHealthUrl(endpoint, healthPath), timeoutMs);
50820
+ if (!response.ok) {
50821
+ return recordFailure(`health check returned ${response.status}`, response.status);
50822
+ }
50823
+ consecutiveFailures = 0;
50824
+ return {
50825
+ available: true,
50826
+ checked: true,
50827
+ consecutiveFailures,
50828
+ shouldRestart: false,
50829
+ statusCode: response.status
50830
+ };
50831
+ } catch (err) {
50832
+ return recordFailure(err instanceof Error ? err.message : String(err));
50833
+ }
50834
+ },
50835
+ reset() {
50836
+ consecutiveFailures = 0;
50837
+ lastCheckedAt = null;
50838
+ }
50839
+ };
50840
+ }
50841
+ function buildHealthUrl(endpoint, healthPath) {
50842
+ return new URL(healthPath, endpoint).toString();
50843
+ }
50844
+ async function fetchWithTimeout2(fetchImpl, url, timeoutMs) {
50845
+ const controller = new AbortController();
50846
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
50847
+ timer.unref?.();
50848
+ try {
50849
+ return await fetchImpl(url, { method: "GET", signal: controller.signal });
50850
+ } finally {
50851
+ clearTimeout(timer);
50852
+ }
50853
+ }
50854
+
50768
50855
  // src/bootstrap/start-node.ts
50769
50856
  function createSettingsSnapshotProvider(options) {
50770
50857
  let cachedSnapshot = null;
@@ -50854,6 +50941,9 @@ function createTunnelManager(options) {
50854
50941
  let shareTransport = null;
50855
50942
  let dashboardHealthTimer = null;
50856
50943
  let nodeTunnelHealthTimer = null;
50944
+ let dashboardHealthCheckRunning = false;
50945
+ let nodeTunnelHealthCheckRunning = false;
50946
+ const nodeTunnelReachability = createTunnelReachabilityMonitor();
50857
50947
  function createDashboardTransportConfig() {
50858
50948
  return {
50859
50949
  type: "devtunnel",
@@ -50893,6 +50983,28 @@ function createTunnelManager(options) {
50893
50983
  function shouldPublishDashboardTunnel() {
50894
50984
  return authMetadata.enabled && (meshyNode.getTransportType() === "devtunnel" || meshyNode.isDevTunnelEnabled());
50895
50985
  }
50986
+ function getPublishedNodeTunnelEndpoint() {
50987
+ const self2 = meshyNode.getNodeRegistry().getSelf();
50988
+ return meshyNode.getTransportType() === "devtunnel" ? self2.endpoint : self2.devtunnelEndpoint;
50989
+ }
50990
+ function setPublishedNodeTunnelHealth(health) {
50991
+ const selfId = meshyNode.getNodeRegistry().getSelf().id;
50992
+ meshyNode.getNodeRegistry().updateDevTunnelHealth(selfId, health);
50993
+ }
50994
+ function markPublishedNodeTunnelHealthy(endpoint) {
50995
+ setPublishedNodeTunnelHealth({
50996
+ status: "healthy",
50997
+ checkedAt: Date.now(),
50998
+ ...endpoint ? { endpoint } : {}
50999
+ });
51000
+ }
51001
+ function markPublishedNodeTunnelFailed(details) {
51002
+ setPublishedNodeTunnelHealth({
51003
+ status: "failed",
51004
+ checkedAt: Date.now(),
51005
+ ...details
51006
+ });
51007
+ }
50896
51008
  async function stopDashboardTransport(reason) {
50897
51009
  if (!dashboardTransport) {
50898
51010
  if (dashboardOrigin) {
@@ -50996,31 +51108,100 @@ function createTunnelManager(options) {
50996
51108
  if (!nodeTunnelHealthTimer) {
50997
51109
  nodeTunnelHealthTimer = setInterval(() => {
50998
51110
  void (async () => {
50999
- if (!meshyNode.hasPublishedNodeTunnel()) {
51000
- return;
51001
- }
51002
- const healthy = await meshyNode.isPublishedNodeTunnelHealthy().catch(() => false);
51003
- if (healthy) {
51111
+ if (nodeTunnelHealthCheckRunning) {
51004
51112
  return;
51005
51113
  }
51006
- meshyNode.getLogger().warn("published node tunnel became unhealthy; restarting with stable id", {
51007
- mainTransportType: meshyNode.getTransportType(),
51008
- sidecarEnabled: meshyNode.isDevTunnelEnabled()
51009
- });
51114
+ nodeTunnelHealthCheckRunning = true;
51010
51115
  try {
51011
- const endpoint = await meshyNode.restartPublishedNodeTunnel();
51012
- meshyNode.getLogger().info("restarted published node tunnel", {
51013
- endpoint,
51014
- stableUrl: true,
51015
- mainTransportType: meshyNode.getTransportType(),
51016
- sidecarEnabled: meshyNode.isDevTunnelEnabled()
51116
+ if (!meshyNode.hasPublishedNodeTunnel()) {
51117
+ nodeTunnelReachability.reset();
51118
+ setPublishedNodeTunnelHealth(void 0);
51119
+ return;
51120
+ }
51121
+ const publishedEndpoint = getPublishedNodeTunnelEndpoint();
51122
+ const healthy = await meshyNode.isPublishedNodeTunnelHealthy().catch(() => false);
51123
+ if (!healthy) {
51124
+ markPublishedNodeTunnelFailed({
51125
+ endpoint: publishedEndpoint,
51126
+ reason: "devtunnel process is not running"
51127
+ });
51128
+ meshyNode.getLogger().warn("published node tunnel process became unhealthy; restarting with stable id", {
51129
+ mainTransportType: meshyNode.getTransportType(),
51130
+ sidecarEnabled: meshyNode.isDevTunnelEnabled()
51131
+ });
51132
+ try {
51133
+ const endpoint = await meshyNode.restartPublishedNodeTunnel();
51134
+ nodeTunnelReachability.reset();
51135
+ markPublishedNodeTunnelHealthy(endpoint);
51136
+ meshyNode.getLogger().info("restarted published node tunnel", {
51137
+ endpoint,
51138
+ stableUrl: true,
51139
+ mainTransportType: meshyNode.getTransportType(),
51140
+ sidecarEnabled: meshyNode.isDevTunnelEnabled()
51141
+ });
51142
+ } catch (err) {
51143
+ markPublishedNodeTunnelFailed({
51144
+ endpoint: publishedEndpoint,
51145
+ reason: err instanceof Error ? err.message : String(err)
51146
+ });
51147
+ meshyNode.getLogger().warn("failed to restart published node tunnel", {
51148
+ error: err instanceof Error ? err.message : String(err),
51149
+ mainTransportType: meshyNode.getTransportType(),
51150
+ sidecarEnabled: meshyNode.isDevTunnelEnabled()
51151
+ });
51152
+ }
51153
+ return;
51154
+ }
51155
+ const reachability = await nodeTunnelReachability.check(publishedEndpoint);
51156
+ if (!reachability.checked) {
51157
+ return;
51158
+ }
51159
+ if (reachability.available) {
51160
+ markPublishedNodeTunnelHealthy(publishedEndpoint);
51161
+ return;
51162
+ }
51163
+ markPublishedNodeTunnelFailed({
51164
+ consecutiveFailures: reachability.consecutiveFailures,
51165
+ endpoint: publishedEndpoint,
51166
+ reason: reachability.reason,
51167
+ statusCode: reachability.statusCode
51017
51168
  });
51018
- } catch (err) {
51019
- meshyNode.getLogger().warn("failed to restart published node tunnel", {
51020
- error: err instanceof Error ? err.message : String(err),
51169
+ meshyNode.getLogger().warn("published node tunnel endpoint health check failed", {
51170
+ consecutiveFailures: reachability.consecutiveFailures,
51171
+ failureThresholdReached: reachability.shouldRestart,
51021
51172
  mainTransportType: meshyNode.getTransportType(),
51022
- sidecarEnabled: meshyNode.isDevTunnelEnabled()
51173
+ reason: reachability.reason,
51174
+ sidecarEnabled: meshyNode.isDevTunnelEnabled(),
51175
+ statusCode: reachability.statusCode
51023
51176
  });
51177
+ if (!reachability.shouldRestart) {
51178
+ return;
51179
+ }
51180
+ try {
51181
+ const endpoint = await meshyNode.restartPublishedNodeTunnel();
51182
+ nodeTunnelReachability.reset();
51183
+ markPublishedNodeTunnelHealthy(endpoint);
51184
+ meshyNode.getLogger().info("restarted published node tunnel", {
51185
+ endpoint,
51186
+ stableUrl: true,
51187
+ mainTransportType: meshyNode.getTransportType(),
51188
+ sidecarEnabled: meshyNode.isDevTunnelEnabled()
51189
+ });
51190
+ } catch (err) {
51191
+ markPublishedNodeTunnelFailed({
51192
+ consecutiveFailures: reachability.consecutiveFailures,
51193
+ endpoint: publishedEndpoint,
51194
+ reason: err instanceof Error ? err.message : String(err),
51195
+ statusCode: reachability.statusCode
51196
+ });
51197
+ meshyNode.getLogger().warn("failed to restart published node tunnel", {
51198
+ error: err instanceof Error ? err.message : String(err),
51199
+ mainTransportType: meshyNode.getTransportType(),
51200
+ sidecarEnabled: meshyNode.isDevTunnelEnabled()
51201
+ });
51202
+ }
51203
+ } finally {
51204
+ nodeTunnelHealthCheckRunning = false;
51024
51205
  }
51025
51206
  })();
51026
51207
  }, config.cluster.heartbeatInterval);
@@ -51028,17 +51209,24 @@ function createTunnelManager(options) {
51028
51209
  if (!dashboardHealthTimer) {
51029
51210
  dashboardHealthTimer = setInterval(() => {
51030
51211
  void (async () => {
51031
- if (!dashboardTransport) {
51212
+ if (dashboardHealthCheckRunning) {
51032
51213
  return;
51033
51214
  }
51034
- const healthy = await dashboardTransport.isHealthy().catch(() => false);
51035
- if (healthy) {
51036
- return;
51215
+ dashboardHealthCheckRunning = true;
51216
+ try {
51217
+ if (!dashboardTransport) {
51218
+ return;
51219
+ }
51220
+ const healthy = await dashboardTransport.isHealthy().catch(() => false);
51221
+ if (!healthy) {
51222
+ meshyNode.getLogger().warn("dashboard tunnel process became unhealthy; restarting with stable id", {
51223
+ port: config.node.port
51224
+ });
51225
+ await restartDashboardTransport("healthcheck");
51226
+ }
51227
+ } finally {
51228
+ dashboardHealthCheckRunning = false;
51037
51229
  }
51038
- meshyNode.getLogger().warn("dashboard tunnel became unhealthy; restarting with stable id", {
51039
- port: config.node.port
51040
- });
51041
- await restartDashboardTransport("healthcheck");
51042
51230
  })();
51043
51231
  }, config.cluster.heartbeatInterval);
51044
51232
  }
@@ -51052,6 +51240,7 @@ function createTunnelManager(options) {
51052
51240
  clearInterval(nodeTunnelHealthTimer);
51053
51241
  nodeTunnelHealthTimer = null;
51054
51242
  }
51243
+ nodeTunnelReachability.reset();
51055
51244
  }
51056
51245
  async function stop() {
51057
51246
  stopHealthChecks();
@@ -51204,6 +51393,9 @@ async function startNode(args) {
51204
51393
  switchTransport: async (type) => {
51205
51394
  const endpoint = await meshyNode.switchTransport(type);
51206
51395
  persistNodeStartupTransport(config.storage.path, type);
51396
+ if (type !== "devtunnel" && !meshyNode.isDevTunnelEnabled()) {
51397
+ meshyNode.getNodeRegistry().updateDevTunnelHealth(meshyNode.getNodeRegistry().getSelf().id, void 0);
51398
+ }
51207
51399
  await tunnelManager.syncDashboardTransport(`switchTransport:${type}`);
51208
51400
  return endpoint;
51209
51401
  },
@@ -51216,6 +51408,9 @@ async function startNode(args) {
51216
51408
  },
51217
51409
  disableDevTunnel: async () => {
51218
51410
  await meshyNode.disableDevTunnel();
51411
+ if (meshyNode.getTransportType() !== "devtunnel") {
51412
+ meshyNode.getNodeRegistry().updateDevTunnelHealth(meshyNode.getNodeRegistry().getSelf().id, void 0);
51413
+ }
51219
51414
  persistNodeStartupTransport(
51220
51415
  config.storage.path,
51221
51416
  meshyNode.getTransportType()