meshy-node 0.3.1 → 0.3.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/README.md +1 -1
- package/dashboard/assets/DashboardPage-BMIVTxil.js +130 -0
- package/dashboard/assets/DashboardShared-BSmoDCJG.js +59 -0
- package/dashboard/assets/{DiffTab-DgOYOCn1.js → DiffTab-BLGTdyp_.js} +2 -2
- package/dashboard/assets/{FilesTab-Csi7UE5G.js → FilesTab-CSpNGxJl.js} +1 -1
- package/dashboard/assets/{PreviewTab-DT95fOD3.js → PreviewTab-CEFgpX6R.js} +4 -4
- package/dashboard/assets/SharedConversationPage-CgHzpTa0.js +12 -0
- package/dashboard/assets/{file-BUN3RpOS.js → file-DCzQQ4U3.js} +1 -1
- package/dashboard/assets/{folder-C28inzgP.js → folder-D2R8g5cx.js} +1 -1
- package/dashboard/assets/{index-COwXI8L0.js → index-CSVyG8lh.js} +6 -6
- package/dashboard/assets/index-CnhngBZ-.css +1 -0
- package/dashboard/index.html +2 -2
- package/main.cjs +1561 -619
- package/package.json +1 -1
- package/runtime-metadata.json +5 -5
- package/dashboard/assets/DashboardPage-ChA_y3oq.js +0 -120
- package/dashboard/assets/DashboardShared-B4AJ8Ukj.js +0 -59
- package/dashboard/assets/SharedConversationPage-D5DMTSIy.js +0 -7
- package/dashboard/assets/index-tpSDJYRT.css +0 -1
package/main.cjs
CHANGED
|
@@ -4301,7 +4301,7 @@ var require_has_flag = __commonJS({
|
|
|
4301
4301
|
var require_supports_color = __commonJS({
|
|
4302
4302
|
"../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports2, module2) {
|
|
4303
4303
|
"use strict";
|
|
4304
|
-
var
|
|
4304
|
+
var os7 = require("os");
|
|
4305
4305
|
var tty = require("tty");
|
|
4306
4306
|
var hasFlag2 = require_has_flag();
|
|
4307
4307
|
var { env } = process;
|
|
@@ -4349,7 +4349,7 @@ var require_supports_color = __commonJS({
|
|
|
4349
4349
|
return min;
|
|
4350
4350
|
}
|
|
4351
4351
|
if (process.platform === "win32") {
|
|
4352
|
-
const osRelease =
|
|
4352
|
+
const osRelease = os7.release().split(".");
|
|
4353
4353
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
4354
4354
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
4355
4355
|
}
|
|
@@ -6629,8 +6629,8 @@ var require_node2 = __commonJS({
|
|
|
6629
6629
|
}
|
|
6630
6630
|
break;
|
|
6631
6631
|
case "FILE":
|
|
6632
|
-
var
|
|
6633
|
-
stream2 = new
|
|
6632
|
+
var fs21 = require("fs");
|
|
6633
|
+
stream2 = new fs21.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(
|
|
19424
|
-
if (!
|
|
19423
|
+
function lookup(path22) {
|
|
19424
|
+
if (!path22 || typeof path22 !== "string") {
|
|
19425
19425
|
return false;
|
|
19426
19426
|
}
|
|
19427
|
-
var extension2 = extname3("x." +
|
|
19427
|
+
var extension2 = extname3("x." + path22).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(
|
|
22945
|
+
function pathToRegexp(path22, 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 (
|
|
22960
|
-
while (m = MATCHING_GROUP_REGEXP.exec(
|
|
22959
|
+
if (path22 instanceof RegExp) {
|
|
22960
|
+
while (m = MATCHING_GROUP_REGEXP.exec(path22.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
|
|
22968
|
+
return path22;
|
|
22969
22969
|
}
|
|
22970
|
-
if (Array.isArray(
|
|
22971
|
-
|
|
22970
|
+
if (Array.isArray(path22)) {
|
|
22971
|
+
path22 = path22.map(function(value) {
|
|
22972
22972
|
return pathToRegexp(value, keys, options).source;
|
|
22973
22973
|
});
|
|
22974
|
-
return new RegExp(
|
|
22974
|
+
return new RegExp(path22.join("|"), flags);
|
|
22975
22975
|
}
|
|
22976
|
-
if (typeof
|
|
22976
|
+
if (typeof path22 !== "string") {
|
|
22977
22977
|
throw new TypeError("path must be a string, array of strings, or regular expression");
|
|
22978
22978
|
}
|
|
22979
|
-
|
|
22979
|
+
path22 = path22.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 +=
|
|
22996
|
+
backtrack += path22.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(
|
|
23026
|
+
while (m = MATCHING_GROUP_REGEXP.exec(path22)) {
|
|
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
|
-
|
|
23038
|
+
path22 += strict ? "" : path22[path22.length - 1] === "/" ? "?" : "/?";
|
|
23039
23039
|
if (end) {
|
|
23040
|
-
|
|
23041
|
-
} else if (
|
|
23042
|
-
|
|
23040
|
+
path22 += "$";
|
|
23041
|
+
} else if (path22[path22.length - 1] !== "/") {
|
|
23042
|
+
path22 += lookahead ? "(?=/|$)" : "(?:/|$)";
|
|
23043
23043
|
}
|
|
23044
|
-
return new RegExp("^" +
|
|
23044
|
+
return new RegExp("^" + path22, 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(
|
|
23057
|
+
function Layer(path22, options, fn) {
|
|
23058
23058
|
if (!(this instanceof Layer)) {
|
|
23059
|
-
return new Layer(
|
|
23059
|
+
return new Layer(path22, options, fn);
|
|
23060
23060
|
}
|
|
23061
|
-
debug("new %o",
|
|
23061
|
+
debug("new %o", path22);
|
|
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(
|
|
23068
|
-
this.regexp.fast_star =
|
|
23069
|
-
this.regexp.fast_slash =
|
|
23067
|
+
this.regexp = pathRegexp(path22, this.keys = [], opts);
|
|
23068
|
+
this.regexp.fast_star = path22 === "*";
|
|
23069
|
+
this.regexp.fast_slash = path22 === "/" && 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(
|
|
23093
|
+
Layer.prototype.match = function match(path22) {
|
|
23094
23094
|
var match2;
|
|
23095
|
-
if (
|
|
23095
|
+
if (path22 != 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(
|
|
23103
|
-
this.path =
|
|
23102
|
+
this.params = { "0": decode_param(path22) };
|
|
23103
|
+
this.path = path22;
|
|
23104
23104
|
return true;
|
|
23105
23105
|
}
|
|
23106
|
-
match2 = this.regexp.exec(
|
|
23106
|
+
match2 = this.regexp.exec(path22);
|
|
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(
|
|
23200
|
-
this.path =
|
|
23199
|
+
function Route(path22) {
|
|
23200
|
+
this.path = path22;
|
|
23201
23201
|
this.stack = [];
|
|
23202
|
-
debug("new %o",
|
|
23202
|
+
debug("new %o", path22);
|
|
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
|
|
23416
|
-
if (
|
|
23415
|
+
var path22 = getPathname(req);
|
|
23416
|
+
if (path22 == 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,
|
|
23424
|
+
match = matchLayer(layer, path22);
|
|
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,
|
|
23462
|
+
trim_prefix(layer, layerError, layerPath, path22);
|
|
23463
23463
|
}
|
|
23464
23464
|
sync = 0;
|
|
23465
23465
|
});
|
|
23466
23466
|
}
|
|
23467
|
-
function trim_prefix(layer, layerError, layerPath,
|
|
23467
|
+
function trim_prefix(layer, layerError, layerPath, path22) {
|
|
23468
23468
|
if (layerPath.length !== 0) {
|
|
23469
|
-
if (layerPath !==
|
|
23469
|
+
if (layerPath !== path22.slice(0, layerPath.length)) {
|
|
23470
23470
|
next(layerError);
|
|
23471
23471
|
return;
|
|
23472
23472
|
}
|
|
23473
|
-
var c =
|
|
23473
|
+
var c = path22[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
|
|
23551
|
+
var path22 = "/";
|
|
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
|
-
|
|
23559
|
+
path22 = 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",
|
|
23572
|
-
var layer = new Layer(
|
|
23571
|
+
debug("use %o %s", path22, fn.name || "<anonymous>");
|
|
23572
|
+
var layer = new Layer(path22, {
|
|
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(
|
|
23583
|
-
var route2 = new Route(
|
|
23584
|
-
var layer = new Layer(
|
|
23582
|
+
proto.route = function route(path22) {
|
|
23583
|
+
var route2 = new Route(path22);
|
|
23584
|
+
var layer = new Layer(path22, {
|
|
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(
|
|
23595
|
-
var route = this.route(
|
|
23594
|
+
proto[method] = function(path22) {
|
|
23595
|
+
var route = this.route(path22);
|
|
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,
|
|
23631
|
+
function matchLayer(layer, path22) {
|
|
23632
23632
|
try {
|
|
23633
|
-
return layer.match(
|
|
23633
|
+
return layer.match(path22);
|
|
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
|
|
23752
|
-
var
|
|
23753
|
-
var dirname7 =
|
|
23754
|
-
var
|
|
23755
|
-
var extname3 =
|
|
23756
|
-
var
|
|
23757
|
-
var resolve14 =
|
|
23751
|
+
var path22 = require("path");
|
|
23752
|
+
var fs21 = require("fs");
|
|
23753
|
+
var dirname7 = path22.dirname;
|
|
23754
|
+
var basename4 = path22.basename;
|
|
23755
|
+
var extname3 = path22.extname;
|
|
23756
|
+
var join17 = path22.join;
|
|
23757
|
+
var resolve14 = path22.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
|
|
23786
|
+
var path23;
|
|
23787
23787
|
var roots = [].concat(this.root);
|
|
23788
23788
|
debug('lookup "%s"', name2);
|
|
23789
|
-
for (var i = 0; i < roots.length && !
|
|
23789
|
+
for (var i = 0; i < roots.length && !path23; i++) {
|
|
23790
23790
|
var root = roots[i];
|
|
23791
23791
|
var loc = resolve14(root, name2);
|
|
23792
23792
|
var dir = dirname7(loc);
|
|
23793
|
-
var file =
|
|
23794
|
-
|
|
23793
|
+
var file = basename4(loc);
|
|
23794
|
+
path23 = this.resolve(dir, file);
|
|
23795
23795
|
}
|
|
23796
|
-
return
|
|
23796
|
+
return path23;
|
|
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 resolve15(dir, file) {
|
|
23803
23803
|
var ext = this.ext;
|
|
23804
|
-
var
|
|
23805
|
-
var stat = tryStat(
|
|
23804
|
+
var path23 = join17(dir, file);
|
|
23805
|
+
var stat = tryStat(path23);
|
|
23806
23806
|
if (stat && stat.isFile()) {
|
|
23807
|
-
return
|
|
23807
|
+
return path23;
|
|
23808
23808
|
}
|
|
23809
|
-
|
|
23810
|
-
stat = tryStat(
|
|
23809
|
+
path23 = join17(dir, basename4(file, ext), "index" + ext);
|
|
23810
|
+
stat = tryStat(path23);
|
|
23811
23811
|
if (stat && stat.isFile()) {
|
|
23812
|
-
return
|
|
23812
|
+
return path23;
|
|
23813
23813
|
}
|
|
23814
23814
|
};
|
|
23815
|
-
function tryStat(
|
|
23816
|
-
debug('stat "%s"',
|
|
23815
|
+
function tryStat(path23) {
|
|
23816
|
+
debug('stat "%s"', path23);
|
|
23817
23817
|
try {
|
|
23818
|
-
return
|
|
23818
|
+
return fs21.statSync(path23);
|
|
23819
23819
|
} catch (e) {
|
|
23820
23820
|
return void 0;
|
|
23821
23821
|
}
|
|
@@ -23829,7 +23829,7 @@ var require_content_disposition = __commonJS({
|
|
|
23829
23829
|
"use strict";
|
|
23830
23830
|
module2.exports = contentDisposition;
|
|
23831
23831
|
module2.exports.parse = parse;
|
|
23832
|
-
var
|
|
23832
|
+
var basename4 = require("path").basename;
|
|
23833
23833
|
var Buffer2 = require_safe_buffer().Buffer;
|
|
23834
23834
|
var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;
|
|
23835
23835
|
var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
|
|
@@ -23865,9 +23865,9 @@ var require_content_disposition = __commonJS({
|
|
|
23865
23865
|
if (typeof fallback === "string" && NON_LATIN1_REGEXP.test(fallback)) {
|
|
23866
23866
|
throw new TypeError("fallback must be ISO-8859-1 string");
|
|
23867
23867
|
}
|
|
23868
|
-
var name2 =
|
|
23868
|
+
var name2 = basename4(filename);
|
|
23869
23869
|
var isQuotedString = TEXT_REGEXP.test(name2);
|
|
23870
|
-
var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name2) :
|
|
23870
|
+
var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name2) : basename4(fallback);
|
|
23871
23871
|
var hasFallback = typeof fallbackName === "string" && fallbackName !== name2;
|
|
23872
23872
|
if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name2)) {
|
|
23873
23873
|
params["filename*"] = name2;
|
|
@@ -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
|
|
24116
|
-
var
|
|
24115
|
+
var path22 = require("path");
|
|
24116
|
+
var fs21 = 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 =
|
|
24137
|
+
var map = {}, content = fs21.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(
|
|
24146
|
-
var ext =
|
|
24145
|
+
Mime.prototype.lookup = function(path23, fallback) {
|
|
24146
|
+
var ext = path23.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 escapeHtml = require_escape_html();
|
|
24257
24257
|
var etag = require_etag();
|
|
24258
24258
|
var fresh = require_fresh();
|
|
24259
|
-
var
|
|
24259
|
+
var fs21 = 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
|
|
24264
|
+
var path22 = require("path");
|
|
24265
24265
|
var statuses = require_statuses();
|
|
24266
24266
|
var Stream = require("stream");
|
|
24267
24267
|
var util3 = require("util");
|
|
24268
|
-
var extname3 =
|
|
24269
|
-
var
|
|
24270
|
-
var normalize =
|
|
24271
|
-
var resolve14 =
|
|
24272
|
-
var
|
|
24268
|
+
var extname3 = path22.extname;
|
|
24269
|
+
var join17 = path22.join;
|
|
24270
|
+
var normalize = path22.normalize;
|
|
24271
|
+
var resolve14 = path22.resolve;
|
|
24272
|
+
var sep4 = path22.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,
|
|
24279
|
-
return new SendStream(req,
|
|
24278
|
+
function send(req, path23, options) {
|
|
24279
|
+
return new SendStream(req, path23, options);
|
|
24280
24280
|
}
|
|
24281
|
-
function SendStream(req,
|
|
24281
|
+
function SendStream(req, path23, options) {
|
|
24282
24282
|
Stream.call(this);
|
|
24283
24283
|
var opts = options || {};
|
|
24284
24284
|
this.options = opts;
|
|
24285
|
-
this.path =
|
|
24285
|
+
this.path = path23;
|
|
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(
|
|
24332
|
-
this._root = resolve14(String(
|
|
24331
|
+
SendStream.prototype.root = function root(path23) {
|
|
24332
|
+
this._root = resolve14(String(path23));
|
|
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(
|
|
24445
|
+
SendStream.prototype.redirect = function redirect(path23) {
|
|
24446
24446
|
var res = this.res;
|
|
24447
24447
|
if (hasListeners(this, "directory")) {
|
|
24448
|
-
this.emit("directory", res,
|
|
24448
|
+
this.emit("directory", res, path23);
|
|
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
|
|
24469
|
-
if (
|
|
24468
|
+
var path23 = decode(this.path);
|
|
24469
|
+
if (path23 === -1) {
|
|
24470
24470
|
this.error(400);
|
|
24471
24471
|
return res;
|
|
24472
24472
|
}
|
|
24473
|
-
if (~
|
|
24473
|
+
if (~path23.indexOf("\0")) {
|
|
24474
24474
|
this.error(400);
|
|
24475
24475
|
return res;
|
|
24476
24476
|
}
|
|
24477
24477
|
var parts;
|
|
24478
24478
|
if (root !== null) {
|
|
24479
|
-
if (
|
|
24480
|
-
|
|
24479
|
+
if (path23) {
|
|
24480
|
+
path23 = normalize("." + sep4 + path23);
|
|
24481
24481
|
}
|
|
24482
|
-
if (UP_PATH_REGEXP.test(
|
|
24483
|
-
debug('malicious path "%s"',
|
|
24482
|
+
if (UP_PATH_REGEXP.test(path23)) {
|
|
24483
|
+
debug('malicious path "%s"', path23);
|
|
24484
24484
|
this.error(403);
|
|
24485
24485
|
return res;
|
|
24486
24486
|
}
|
|
24487
|
-
parts =
|
|
24488
|
-
|
|
24487
|
+
parts = path23.split(sep4);
|
|
24488
|
+
path23 = normalize(join17(root, path23));
|
|
24489
24489
|
} else {
|
|
24490
|
-
if (UP_PATH_REGEXP.test(
|
|
24491
|
-
debug('malicious path "%s"',
|
|
24490
|
+
if (UP_PATH_REGEXP.test(path23)) {
|
|
24491
|
+
debug('malicious path "%s"', path23);
|
|
24492
24492
|
this.error(403);
|
|
24493
24493
|
return res;
|
|
24494
24494
|
}
|
|
24495
|
-
parts = normalize(
|
|
24496
|
-
|
|
24495
|
+
parts = normalize(path23).split(sep4);
|
|
24496
|
+
path23 = resolve14(path23);
|
|
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,
|
|
24503
|
+
debug('%s dotfile "%s"', access, path23);
|
|
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(
|
|
24517
|
+
this.sendIndex(path23);
|
|
24518
24518
|
return res;
|
|
24519
24519
|
}
|
|
24520
|
-
this.sendFile(
|
|
24520
|
+
this.sendFile(path23);
|
|
24521
24521
|
return res;
|
|
24522
24522
|
};
|
|
24523
|
-
SendStream.prototype.send = function send2(
|
|
24523
|
+
SendStream.prototype.send = function send2(path23, 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"',
|
|
24536
|
-
this.setHeader(
|
|
24537
|
-
this.type(
|
|
24535
|
+
debug('pipe "%s"', path23);
|
|
24536
|
+
this.setHeader(path23, stat);
|
|
24537
|
+
this.type(path23);
|
|
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(
|
|
24586
|
+
this.stream(path23, opts);
|
|
24587
24587
|
};
|
|
24588
|
-
SendStream.prototype.sendFile = function sendFile(
|
|
24588
|
+
SendStream.prototype.sendFile = function sendFile(path23) {
|
|
24589
24589
|
var i = 0;
|
|
24590
24590
|
var self2 = this;
|
|
24591
|
-
debug('stat "%s"',
|
|
24592
|
-
|
|
24593
|
-
if (err && err.code === "ENOENT" && !extname3(
|
|
24591
|
+
debug('stat "%s"', path23);
|
|
24592
|
+
fs21.stat(path23, function onstat(err, stat) {
|
|
24593
|
+
if (err && err.code === "ENOENT" && !extname3(path23) && path23[path23.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(
|
|
24598
|
-
self2.emit("file",
|
|
24599
|
-
self2.send(
|
|
24597
|
+
if (stat.isDirectory()) return self2.redirect(path23);
|
|
24598
|
+
self2.emit("file", path23, stat);
|
|
24599
|
+
self2.send(path23, 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 =
|
|
24605
|
+
var p = path23 + "." + self2._extensions[i++];
|
|
24606
24606
|
debug('stat "%s"', p);
|
|
24607
|
-
|
|
24607
|
+
fs21.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(
|
|
24615
|
+
SendStream.prototype.sendIndex = function sendIndex(path23) {
|
|
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 =
|
|
24623
|
+
var p = join17(path23, self2._index[i]);
|
|
24624
24624
|
debug('stat "%s"', p);
|
|
24625
|
-
|
|
24625
|
+
fs21.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(
|
|
24634
|
+
SendStream.prototype.stream = function stream(path23, options) {
|
|
24635
24635
|
var self2 = this;
|
|
24636
24636
|
var res = this.res;
|
|
24637
|
-
var stream2 =
|
|
24637
|
+
var stream2 = fs21.createReadStream(path23, 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(
|
|
24652
|
+
SendStream.prototype.type = function type(path23) {
|
|
24653
24653
|
var res = this.res;
|
|
24654
24654
|
if (res.getHeader("Content-Type")) return;
|
|
24655
|
-
var type2 = mime.lookup(
|
|
24655
|
+
var type2 = mime.lookup(path23);
|
|
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(
|
|
24664
|
+
SendStream.prototype.setHeader = function setHeader(path23, stat) {
|
|
24665
24665
|
var res = this.res;
|
|
24666
|
-
this.emit("headers", res,
|
|
24666
|
+
this.emit("headers", res, path23, 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(
|
|
24725
|
+
function decode(path23) {
|
|
24726
24726
|
try {
|
|
24727
|
-
return decodeURIComponent(
|
|
24727
|
+
return decodeURIComponent(path23);
|
|
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(
|
|
25638
|
-
if ("/" ===
|
|
25639
|
-
if (":" ===
|
|
25640
|
-
if ("\\\\" ===
|
|
25637
|
+
exports2.isAbsolute = function(path22) {
|
|
25638
|
+
if ("/" === path22[0]) return true;
|
|
25639
|
+
if (":" === path22[1] && ("\\" === path22[2] || "/" === path22[2])) return true;
|
|
25640
|
+
if ("\\\\" === path22.substring(0, 2)) return true;
|
|
25641
25641
|
};
|
|
25642
25642
|
exports2.flatten = deprecate.function(
|
|
25643
25643
|
flatten,
|
|
@@ -25760,7 +25760,7 @@ var require_application = __commonJS({
|
|
|
25760
25760
|
"../../node_modules/.pnpm/express@4.22.1/node_modules/express/lib/application.js"(exports2, module2) {
|
|
25761
25761
|
"use strict";
|
|
25762
25762
|
var finalhandler = require_finalhandler();
|
|
25763
|
-
var
|
|
25763
|
+
var Router13 = require_router();
|
|
25764
25764
|
var methods = require_methods();
|
|
25765
25765
|
var middleware = require_init();
|
|
25766
25766
|
var query = require_query();
|
|
@@ -25825,7 +25825,7 @@ var require_application = __commonJS({
|
|
|
25825
25825
|
};
|
|
25826
25826
|
app.lazyrouter = function lazyrouter() {
|
|
25827
25827
|
if (!this._router) {
|
|
25828
|
-
this._router = new
|
|
25828
|
+
this._router = new Router13({
|
|
25829
25829
|
caseSensitive: this.enabled("case sensitive routing"),
|
|
25830
25830
|
strict: this.enabled("strict routing")
|
|
25831
25831
|
});
|
|
@@ -25848,7 +25848,7 @@ var require_application = __commonJS({
|
|
|
25848
25848
|
};
|
|
25849
25849
|
app.use = function use(fn) {
|
|
25850
25850
|
var offset = 0;
|
|
25851
|
-
var
|
|
25851
|
+
var path22 = "/";
|
|
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
|
-
|
|
25859
|
+
path22 = 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(
|
|
25870
|
+
return router.use(path22, fn2);
|
|
25871
25871
|
}
|
|
25872
|
-
debug(".use app under %s",
|
|
25873
|
-
fn2.mountpath =
|
|
25872
|
+
debug(".use app under %s", path22);
|
|
25873
|
+
fn2.mountpath = path22;
|
|
25874
25874
|
fn2.parent = this;
|
|
25875
|
-
router.use(
|
|
25875
|
+
router.use(path22, 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(
|
|
25887
|
+
app.route = function route(path22) {
|
|
25888
25888
|
this.lazyrouter();
|
|
25889
|
-
return this._router.route(
|
|
25889
|
+
return this._router.route(path22);
|
|
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
|
|
25940
|
+
app.path = function path22() {
|
|
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(
|
|
25956
|
+
app[method] = function(path22) {
|
|
25957
25957
|
if (method === "get" && arguments.length === 1) {
|
|
25958
|
-
return this.set(
|
|
25958
|
+
return this.set(path22);
|
|
25959
25959
|
}
|
|
25960
25960
|
this.lazyrouter();
|
|
25961
|
-
var route = this._router.route(
|
|
25961
|
+
var route = this._router.route(path22);
|
|
25962
25962
|
route[method].apply(route, slice.call(arguments, 1));
|
|
25963
25963
|
return this;
|
|
25964
25964
|
};
|
|
25965
25965
|
});
|
|
25966
|
-
app.all = function all(
|
|
25966
|
+
app.all = function all(path22) {
|
|
25967
25967
|
this.lazyrouter();
|
|
25968
|
-
var route = this._router.route(
|
|
25968
|
+
var route = this._router.route(path22);
|
|
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
|
|
26727
|
+
defineGetter(req, "path", function path22() {
|
|
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 isAbsolute4 = require_utils2().isAbsolute;
|
|
27049
27049
|
var onFinished = require_on_finished();
|
|
27050
|
-
var
|
|
27050
|
+
var path22 = 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 =
|
|
27059
|
+
var extname3 = path22.extname;
|
|
27060
27060
|
var mime = send.mime;
|
|
27061
|
-
var resolve14 =
|
|
27061
|
+
var resolve14 = path22.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(
|
|
27238
|
+
res.sendFile = function sendFile(path23, 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 (!
|
|
27244
|
+
if (!path23) {
|
|
27245
27245
|
throw new TypeError("path argument is required to res.sendFile");
|
|
27246
27246
|
}
|
|
27247
|
-
if (typeof
|
|
27247
|
+
if (typeof path23 !== "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 && !isAbsolute4(
|
|
27254
|
+
if (!opts.root && !isAbsolute4(path23)) {
|
|
27255
27255
|
throw new TypeError("path must be absolute or specify root to res.sendFile");
|
|
27256
27256
|
}
|
|
27257
|
-
var pathname = encodeURI(
|
|
27257
|
+
var pathname = encodeURI(path23);
|
|
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(
|
|
27267
|
+
res.sendfile = function(path23, 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,
|
|
27277
|
+
var file = send(req, path23, 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(
|
|
27290
|
+
res.download = function download(path23, 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 ||
|
|
27307
|
+
"Content-Disposition": contentDisposition(name2 || path23)
|
|
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 ? resolve14(
|
|
27320
|
+
var fullPath = !opts.root ? resolve14(path23) : path23;
|
|
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
|
|
27622
|
-
if (
|
|
27623
|
-
|
|
27621
|
+
var path22 = parseUrl(req).pathname;
|
|
27622
|
+
if (path22 === "/" && originalUrl.pathname.substr(-1) !== "/") {
|
|
27623
|
+
path22 = "";
|
|
27624
27624
|
}
|
|
27625
|
-
var stream = send(req,
|
|
27625
|
+
var stream = send(req, path22, opts);
|
|
27626
27626
|
stream.on("directory", onDirectory);
|
|
27627
27627
|
if (setHeaders) {
|
|
27628
27628
|
stream.on("headers", setHeaders);
|
|
@@ -27690,7 +27690,7 @@ var require_express = __commonJS({
|
|
|
27690
27690
|
var mixin = require_merge_descriptors();
|
|
27691
27691
|
var proto = require_application();
|
|
27692
27692
|
var Route = require_route();
|
|
27693
|
-
var
|
|
27693
|
+
var Router13 = require_router();
|
|
27694
27694
|
var req = require_request();
|
|
27695
27695
|
var res = require_response();
|
|
27696
27696
|
exports2 = module2.exports = createApplication;
|
|
@@ -27713,7 +27713,7 @@ var require_express = __commonJS({
|
|
|
27713
27713
|
exports2.request = req;
|
|
27714
27714
|
exports2.response = res;
|
|
27715
27715
|
exports2.Route = Route;
|
|
27716
|
-
exports2.Router =
|
|
27716
|
+
exports2.Router = Router13;
|
|
27717
27717
|
exports2.json = bodyParser.json;
|
|
27718
27718
|
exports2.query = require_query();
|
|
27719
27719
|
exports2.raw = bodyParser.raw;
|
|
@@ -32265,11 +32265,11 @@ function persistNodeStartupTransport(storagePath, transport) {
|
|
|
32265
32265
|
transport
|
|
32266
32266
|
});
|
|
32267
32267
|
}
|
|
32268
|
-
function persistNodeStartupJoin(storagePath,
|
|
32268
|
+
function persistNodeStartupJoin(storagePath, join17) {
|
|
32269
32269
|
const startup = resolveNodeStartupMetadata(storagePath);
|
|
32270
32270
|
persistNodeStartupMetadata(storagePath, {
|
|
32271
32271
|
...startup,
|
|
32272
|
-
join:
|
|
32272
|
+
join: join17
|
|
32273
32273
|
});
|
|
32274
32274
|
}
|
|
32275
32275
|
function resolvePersistedDevTunnelId(storagePath, kind) {
|
|
@@ -32612,6 +32612,10 @@ var TASK_PRIORITIES = /* @__PURE__ */ new Set([
|
|
|
32612
32612
|
"high",
|
|
32613
32613
|
"critical"
|
|
32614
32614
|
]);
|
|
32615
|
+
var TASK_CONVERSATION_KIND_SET = /* @__PURE__ */ new Set([
|
|
32616
|
+
"meshyChat",
|
|
32617
|
+
"nativeSession"
|
|
32618
|
+
]);
|
|
32615
32619
|
var NODE_ROLES = /* @__PURE__ */ new Set([
|
|
32616
32620
|
"leader",
|
|
32617
32621
|
"follower"
|
|
@@ -32627,6 +32631,9 @@ function isTaskStatus(value) {
|
|
|
32627
32631
|
function isTaskPriority(value) {
|
|
32628
32632
|
return typeof value === "string" && TASK_PRIORITIES.has(value);
|
|
32629
32633
|
}
|
|
32634
|
+
function isTaskConversationKind(value) {
|
|
32635
|
+
return typeof value === "string" && TASK_CONVERSATION_KIND_SET.has(value);
|
|
32636
|
+
}
|
|
32630
32637
|
function isNodeRole(value) {
|
|
32631
32638
|
return typeof value === "string" && NODE_ROLES.has(value);
|
|
32632
32639
|
}
|
|
@@ -33117,7 +33124,8 @@ function parseTask(value) {
|
|
|
33117
33124
|
}
|
|
33118
33125
|
const status = asTaskStatus(value.status);
|
|
33119
33126
|
const priority = asTaskPriority(value.priority);
|
|
33120
|
-
|
|
33127
|
+
const conversationKind = value.conversationKind === void 0 ? "meshyChat" : asTaskConversationKind(value.conversationKind);
|
|
33128
|
+
if (typeof value.id !== "string" || typeof value.title !== "string" || typeof value.description !== "string" || typeof value.agent !== "string" || value.project !== null && typeof value.project !== "string" || value.effectiveProjectPath !== null && value.effectiveProjectPath !== void 0 && typeof value.effectiveProjectPath !== "string" || value.branch !== null && value.branch !== void 0 && typeof value.branch !== "string" || conversationKind === null || !isPlainObject(value.payload) || status === null || priority === null || value.assignedTo !== null && typeof value.assignedTo !== "string" || value.assignedNodeName !== void 0 && value.assignedNodeName !== null && typeof value.assignedNodeName !== "string" || typeof value.createdBy !== "string" || value.result !== null && !isPlainObject(value.result) || value.error !== null && typeof value.error !== "string" || typeof value.retryCount !== "number" || !Number.isFinite(value.retryCount) || typeof value.maxRetries !== "number" || !Number.isFinite(value.maxRetries) || typeof value.createdAt !== "number" || !Number.isFinite(value.createdAt) || typeof value.updatedAt !== "number" || !Number.isFinite(value.updatedAt)) {
|
|
33121
33129
|
return null;
|
|
33122
33130
|
}
|
|
33123
33131
|
return {
|
|
@@ -33128,6 +33136,7 @@ function parseTask(value) {
|
|
|
33128
33136
|
project: value.project ?? null,
|
|
33129
33137
|
effectiveProjectPath: typeof value.effectiveProjectPath === "string" ? value.effectiveProjectPath : null,
|
|
33130
33138
|
branch: value.branch === void 0 ? void 0 : typeof value.branch === "string" ? value.branch : null,
|
|
33139
|
+
conversationKind,
|
|
33131
33140
|
payload: clone(value.payload),
|
|
33132
33141
|
status,
|
|
33133
33142
|
priority,
|
|
@@ -33177,6 +33186,9 @@ function asTaskStatus(value) {
|
|
|
33177
33186
|
function asTaskPriority(value) {
|
|
33178
33187
|
return isTaskPriority(value) ? value : null;
|
|
33179
33188
|
}
|
|
33189
|
+
function asTaskConversationKind(value) {
|
|
33190
|
+
return isTaskConversationKind(value) ? value : null;
|
|
33191
|
+
}
|
|
33180
33192
|
function sortEntries(input) {
|
|
33181
33193
|
return Array.from(input.entries()).sort(([left], [right]) => left.localeCompare(right));
|
|
33182
33194
|
}
|
|
@@ -33254,19 +33266,19 @@ async function fetchWithTimeout(url, init, timeoutMs = DEFAULT_NODE_REQUEST_TIME
|
|
|
33254
33266
|
cleanup();
|
|
33255
33267
|
}
|
|
33256
33268
|
}
|
|
33257
|
-
async function fetchNodeWithFallback(node,
|
|
33269
|
+
async function fetchNodeWithFallback(node, path22, init, timeoutMs = DEFAULT_NODE_REQUEST_TIMEOUT_MS, trace, options) {
|
|
33258
33270
|
let lastError;
|
|
33259
33271
|
const endpoints = getNodeRequestEndpoints(node, options);
|
|
33260
33272
|
for (const [index, endpoint] of endpoints.entries()) {
|
|
33261
33273
|
const attempt = index + 1;
|
|
33262
|
-
trace?.onAttempt?.({ attempt, endpoint, path:
|
|
33274
|
+
trace?.onAttempt?.({ attempt, endpoint, path: path22, timeoutMs, totalEndpoints: endpoints.length });
|
|
33263
33275
|
try {
|
|
33264
|
-
const response = await fetchWithTimeout(`${endpoint}${
|
|
33265
|
-
trace?.onResponse?.({ attempt, endpoint, path:
|
|
33276
|
+
const response = await fetchWithTimeout(`${endpoint}${path22}`, init, timeoutMs);
|
|
33277
|
+
trace?.onResponse?.({ attempt, endpoint, path: path22, response, timeoutMs, totalEndpoints: endpoints.length });
|
|
33266
33278
|
return { endpoint, response };
|
|
33267
33279
|
} catch (error) {
|
|
33268
33280
|
lastError = error;
|
|
33269
|
-
trace?.onError?.({ attempt, endpoint, error, path:
|
|
33281
|
+
trace?.onError?.({ attempt, endpoint, error, path: path22, timeoutMs, totalEndpoints: endpoints.length });
|
|
33270
33282
|
}
|
|
33271
33283
|
}
|
|
33272
33284
|
throw lastError instanceof Error ? lastError : new Error("No reachable node endpoint");
|
|
@@ -33852,6 +33864,7 @@ var TaskEngine = class {
|
|
|
33852
33864
|
project: input.project ?? null,
|
|
33853
33865
|
effectiveProjectPath: null,
|
|
33854
33866
|
branch: input.branch ?? null,
|
|
33867
|
+
conversationKind: input.conversationKind ?? "meshyChat",
|
|
33855
33868
|
payload: input.payload,
|
|
33856
33869
|
status: "pending",
|
|
33857
33870
|
priority: input.priority ?? "normal",
|
|
@@ -34540,8 +34553,10 @@ var NODE_KIND_BY_LEGACY = {
|
|
|
34540
34553
|
"node-workdir-tree": "node.workdir.tree",
|
|
34541
34554
|
"node-workdir-branch-info": "node.workdir.branch-info",
|
|
34542
34555
|
"node-workdir-branch-create": "node.workdir.branch-create",
|
|
34556
|
+
"node-sessions-list": "node.sessions.list",
|
|
34543
34557
|
devtunnel: "node.transport.set",
|
|
34544
34558
|
"task-cancel": "task.cancel",
|
|
34559
|
+
"task-logs": "task.logs",
|
|
34545
34560
|
"task-output-summary": "task.output.summary",
|
|
34546
34561
|
"task-output-tree": "task.output.tree",
|
|
34547
34562
|
"task-output-content": "task.output.content",
|
|
@@ -35305,9 +35320,9 @@ var DataRouter = class {
|
|
|
35305
35320
|
/**
|
|
35306
35321
|
* Returns true if the request should be proxied to the leader.
|
|
35307
35322
|
*/
|
|
35308
|
-
shouldProxy(method,
|
|
35323
|
+
shouldProxy(method, path22) {
|
|
35309
35324
|
if (this.election.isLeader()) return false;
|
|
35310
|
-
if (this.isExcludedPath(
|
|
35325
|
+
if (this.isExcludedPath(path22)) return false;
|
|
35311
35326
|
if (method.toUpperCase() === "GET") return false;
|
|
35312
35327
|
return WRITE_METHODS.has(method.toUpperCase());
|
|
35313
35328
|
}
|
|
@@ -35411,8 +35426,8 @@ var DataRouter = class {
|
|
|
35411
35426
|
};
|
|
35412
35427
|
}
|
|
35413
35428
|
// ── Helpers ───────────────────────────────────────────────────────────
|
|
35414
|
-
isExcludedPath(
|
|
35415
|
-
return EXCLUDED_PATH_PREFIXES.some((prefix) =>
|
|
35429
|
+
isExcludedPath(path22) {
|
|
35430
|
+
return EXCLUDED_PATH_PREFIXES.some((prefix) => path22.startsWith(prefix)) || EXCLUDED_PATH_SUFFIXES.some((suffix) => path22.endsWith(suffix));
|
|
35416
35431
|
}
|
|
35417
35432
|
};
|
|
35418
35433
|
|
|
@@ -35550,6 +35565,325 @@ var EngineRegistry = class {
|
|
|
35550
35565
|
}
|
|
35551
35566
|
};
|
|
35552
35567
|
|
|
35568
|
+
// ../../packages/core/src/agents/native-session-history.ts
|
|
35569
|
+
var fs7 = __toESM(require("fs"), 1);
|
|
35570
|
+
var os4 = __toESM(require("os"), 1);
|
|
35571
|
+
var path7 = __toESM(require("path"), 1);
|
|
35572
|
+
function isRecord2(value) {
|
|
35573
|
+
return typeof value === "object" && value !== null;
|
|
35574
|
+
}
|
|
35575
|
+
function readJsonLines(filePath) {
|
|
35576
|
+
if (!fs7.existsSync(filePath)) {
|
|
35577
|
+
return [];
|
|
35578
|
+
}
|
|
35579
|
+
const content = fs7.readFileSync(filePath, "utf8");
|
|
35580
|
+
if (!content.trim()) {
|
|
35581
|
+
return [];
|
|
35582
|
+
}
|
|
35583
|
+
return content.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).flatMap((line) => {
|
|
35584
|
+
try {
|
|
35585
|
+
const parsed = JSON.parse(line);
|
|
35586
|
+
return isRecord2(parsed) ? [parsed] : [];
|
|
35587
|
+
} catch {
|
|
35588
|
+
return [];
|
|
35589
|
+
}
|
|
35590
|
+
});
|
|
35591
|
+
}
|
|
35592
|
+
function readFileModifiedAt(filePath) {
|
|
35593
|
+
try {
|
|
35594
|
+
return fs7.statSync(filePath).mtime.toISOString();
|
|
35595
|
+
} catch {
|
|
35596
|
+
return null;
|
|
35597
|
+
}
|
|
35598
|
+
}
|
|
35599
|
+
function compareUpdatedSessions(left, right) {
|
|
35600
|
+
const leftTime = left.updatedAt ? Date.parse(left.updatedAt) : 0;
|
|
35601
|
+
const rightTime = right.updatedAt ? Date.parse(right.updatedAt) : 0;
|
|
35602
|
+
return rightTime - leftTime || left.sessionId.localeCompare(right.sessionId);
|
|
35603
|
+
}
|
|
35604
|
+
function findMatchingFiles(rootDir, predicate) {
|
|
35605
|
+
if (!fs7.existsSync(rootDir)) {
|
|
35606
|
+
return [];
|
|
35607
|
+
}
|
|
35608
|
+
const matches = [];
|
|
35609
|
+
const pendingDirs = [rootDir];
|
|
35610
|
+
while (pendingDirs.length > 0) {
|
|
35611
|
+
const currentDir = pendingDirs.shift();
|
|
35612
|
+
if (!currentDir) continue;
|
|
35613
|
+
const entries = fs7.readdirSync(currentDir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
|
|
35614
|
+
for (const entry of entries) {
|
|
35615
|
+
const entryPath = path7.join(currentDir, entry.name);
|
|
35616
|
+
if (entry.isDirectory()) {
|
|
35617
|
+
pendingDirs.push(entryPath);
|
|
35618
|
+
continue;
|
|
35619
|
+
}
|
|
35620
|
+
if (!entry.isFile() || !predicate(entryPath)) {
|
|
35621
|
+
continue;
|
|
35622
|
+
}
|
|
35623
|
+
let mtimeMs = 0;
|
|
35624
|
+
try {
|
|
35625
|
+
mtimeMs = fs7.statSync(entryPath).mtimeMs;
|
|
35626
|
+
} catch {
|
|
35627
|
+
mtimeMs = 0;
|
|
35628
|
+
}
|
|
35629
|
+
matches.push({ filePath: entryPath, mtimeMs });
|
|
35630
|
+
}
|
|
35631
|
+
}
|
|
35632
|
+
return matches.sort((left, right) => right.mtimeMs - left.mtimeMs || left.filePath.localeCompare(right.filePath)).map((entry) => entry.filePath);
|
|
35633
|
+
}
|
|
35634
|
+
function findFirstMatchingFile(rootDir, predicate) {
|
|
35635
|
+
if (!fs7.existsSync(rootDir)) {
|
|
35636
|
+
return null;
|
|
35637
|
+
}
|
|
35638
|
+
const pendingDirs = [rootDir];
|
|
35639
|
+
while (pendingDirs.length > 0) {
|
|
35640
|
+
const currentDir = pendingDirs.shift();
|
|
35641
|
+
if (!currentDir) continue;
|
|
35642
|
+
const entries = fs7.readdirSync(currentDir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
|
|
35643
|
+
for (const entry of entries) {
|
|
35644
|
+
const entryPath = path7.join(currentDir, entry.name);
|
|
35645
|
+
if (entry.isDirectory()) {
|
|
35646
|
+
pendingDirs.push(entryPath);
|
|
35647
|
+
continue;
|
|
35648
|
+
}
|
|
35649
|
+
if (entry.isFile() && predicate(entryPath)) {
|
|
35650
|
+
return entryPath;
|
|
35651
|
+
}
|
|
35652
|
+
}
|
|
35653
|
+
}
|
|
35654
|
+
return null;
|
|
35655
|
+
}
|
|
35656
|
+
function buildAssistantTextEvent(text, timestamp) {
|
|
35657
|
+
return {
|
|
35658
|
+
type: "assistant",
|
|
35659
|
+
message: {
|
|
35660
|
+
role: "assistant",
|
|
35661
|
+
content: [{ type: "text", text }]
|
|
35662
|
+
},
|
|
35663
|
+
...timestamp ? { timestamp } : {}
|
|
35664
|
+
};
|
|
35665
|
+
}
|
|
35666
|
+
function buildAssistantThinkingEvent(thinking, timestamp) {
|
|
35667
|
+
return {
|
|
35668
|
+
type: "assistant",
|
|
35669
|
+
message: {
|
|
35670
|
+
role: "assistant",
|
|
35671
|
+
content: [{ type: "thinking", thinking }]
|
|
35672
|
+
},
|
|
35673
|
+
...timestamp ? { timestamp } : {}
|
|
35674
|
+
};
|
|
35675
|
+
}
|
|
35676
|
+
function extractCodexReasoningText(item) {
|
|
35677
|
+
if (typeof item.text === "string") {
|
|
35678
|
+
return item.text.trim();
|
|
35679
|
+
}
|
|
35680
|
+
if (Array.isArray(item.summary)) {
|
|
35681
|
+
return item.summary.map((entry) => {
|
|
35682
|
+
if (typeof entry === "string") return entry.trim();
|
|
35683
|
+
if (isRecord2(entry) && typeof entry.text === "string") {
|
|
35684
|
+
return entry.text.trim();
|
|
35685
|
+
}
|
|
35686
|
+
return "";
|
|
35687
|
+
}).filter(Boolean).join("\n\n");
|
|
35688
|
+
}
|
|
35689
|
+
return "";
|
|
35690
|
+
}
|
|
35691
|
+
function truncateSummary(text, maxLength = 96) {
|
|
35692
|
+
const normalized = text.replace(/\s+/g, " ").trim();
|
|
35693
|
+
if (!normalized) {
|
|
35694
|
+
return "";
|
|
35695
|
+
}
|
|
35696
|
+
if (normalized.length <= maxLength) {
|
|
35697
|
+
return normalized;
|
|
35698
|
+
}
|
|
35699
|
+
return `${normalized.slice(0, maxLength - 1).trimEnd()}\u2026`;
|
|
35700
|
+
}
|
|
35701
|
+
function extractTextFromClaudeMessageContent(content) {
|
|
35702
|
+
if (typeof content === "string") {
|
|
35703
|
+
return truncateSummary(content);
|
|
35704
|
+
}
|
|
35705
|
+
if (!Array.isArray(content)) {
|
|
35706
|
+
return "";
|
|
35707
|
+
}
|
|
35708
|
+
for (const part of content) {
|
|
35709
|
+
if (!isRecord2(part)) continue;
|
|
35710
|
+
if (typeof part.text === "string" && part.text.trim()) {
|
|
35711
|
+
return truncateSummary(part.text);
|
|
35712
|
+
}
|
|
35713
|
+
if (part.type === "tool_result" && typeof part.content === "string" && part.content.trim()) {
|
|
35714
|
+
return truncateSummary(part.content);
|
|
35715
|
+
}
|
|
35716
|
+
}
|
|
35717
|
+
return "";
|
|
35718
|
+
}
|
|
35719
|
+
function findClaudeSessionSummary(entries, sessionId) {
|
|
35720
|
+
let cwd = "";
|
|
35721
|
+
let summary = "";
|
|
35722
|
+
let updatedAt = null;
|
|
35723
|
+
for (const entry of entries) {
|
|
35724
|
+
if (typeof entry.timestamp === "string") {
|
|
35725
|
+
updatedAt = entry.timestamp;
|
|
35726
|
+
}
|
|
35727
|
+
if (!cwd && typeof entry.cwd === "string" && entry.cwd.trim()) {
|
|
35728
|
+
cwd = entry.cwd.trim();
|
|
35729
|
+
}
|
|
35730
|
+
if (summary || entry.type !== "user" || !isRecord2(entry.message)) {
|
|
35731
|
+
continue;
|
|
35732
|
+
}
|
|
35733
|
+
const candidate = extractTextFromClaudeMessageContent(entry.message.content);
|
|
35734
|
+
if (candidate) {
|
|
35735
|
+
summary = candidate;
|
|
35736
|
+
}
|
|
35737
|
+
}
|
|
35738
|
+
if (!cwd) {
|
|
35739
|
+
return null;
|
|
35740
|
+
}
|
|
35741
|
+
return {
|
|
35742
|
+
agent: "claudecode",
|
|
35743
|
+
sessionId,
|
|
35744
|
+
cwd,
|
|
35745
|
+
summary: summary || `Claude Code session ${sessionId.slice(0, 12)}`,
|
|
35746
|
+
updatedAt
|
|
35747
|
+
};
|
|
35748
|
+
}
|
|
35749
|
+
function loadCodexSessionIndex() {
|
|
35750
|
+
const indexPath = path7.join(os4.homedir(), ".codex", "session_index.jsonl");
|
|
35751
|
+
const index = /* @__PURE__ */ new Map();
|
|
35752
|
+
for (const entry of readJsonLines(indexPath)) {
|
|
35753
|
+
if (typeof entry.id !== "string" || !entry.id.trim()) {
|
|
35754
|
+
continue;
|
|
35755
|
+
}
|
|
35756
|
+
index.set(entry.id, {
|
|
35757
|
+
...typeof entry.thread_name === "string" && entry.thread_name.trim() ? { threadName: truncateSummary(entry.thread_name) } : {},
|
|
35758
|
+
...typeof entry.updated_at === "string" && entry.updated_at.trim() ? { updatedAt: entry.updated_at } : {}
|
|
35759
|
+
});
|
|
35760
|
+
}
|
|
35761
|
+
return index;
|
|
35762
|
+
}
|
|
35763
|
+
function findCodexSessionSummary(entries, filePath, sessionIndex) {
|
|
35764
|
+
let sessionId = path7.basename(filePath, ".jsonl");
|
|
35765
|
+
let cwd = "";
|
|
35766
|
+
let summary = "";
|
|
35767
|
+
let updatedAt = null;
|
|
35768
|
+
for (const entry of entries) {
|
|
35769
|
+
if (typeof entry.timestamp === "string") {
|
|
35770
|
+
updatedAt = entry.timestamp;
|
|
35771
|
+
}
|
|
35772
|
+
if (entry.type === "session_meta" && isRecord2(entry.payload)) {
|
|
35773
|
+
if (typeof entry.payload.id === "string" && entry.payload.id.trim()) {
|
|
35774
|
+
sessionId = entry.payload.id.trim();
|
|
35775
|
+
}
|
|
35776
|
+
if (!cwd && typeof entry.payload.cwd === "string" && entry.payload.cwd.trim()) {
|
|
35777
|
+
cwd = entry.payload.cwd.trim();
|
|
35778
|
+
}
|
|
35779
|
+
continue;
|
|
35780
|
+
}
|
|
35781
|
+
if (!summary && entry.type === "event_msg" && isRecord2(entry.payload) && entry.payload.type === "user_message") {
|
|
35782
|
+
if (typeof entry.payload.message === "string" && entry.payload.message.trim()) {
|
|
35783
|
+
summary = truncateSummary(entry.payload.message);
|
|
35784
|
+
}
|
|
35785
|
+
}
|
|
35786
|
+
}
|
|
35787
|
+
if (!cwd || !sessionId) {
|
|
35788
|
+
return null;
|
|
35789
|
+
}
|
|
35790
|
+
const indexed = sessionIndex.get(sessionId);
|
|
35791
|
+
return {
|
|
35792
|
+
agent: "codex",
|
|
35793
|
+
sessionId,
|
|
35794
|
+
cwd,
|
|
35795
|
+
summary: indexed?.threadName || summary || `Codex session ${sessionId.slice(0, 12)}`,
|
|
35796
|
+
updatedAt: indexed?.updatedAt ?? updatedAt
|
|
35797
|
+
};
|
|
35798
|
+
}
|
|
35799
|
+
function loadClaudeSessionHistory(sessionId) {
|
|
35800
|
+
const projectsDir = path7.join(os4.homedir(), ".claude", "projects");
|
|
35801
|
+
const sessionFile = findFirstMatchingFile(projectsDir, (filePath) => {
|
|
35802
|
+
if (filePath.includes(`${path7.sep}subagents${path7.sep}`)) {
|
|
35803
|
+
return false;
|
|
35804
|
+
}
|
|
35805
|
+
return path7.basename(filePath).toLowerCase() === `${sessionId.toLowerCase()}.jsonl`;
|
|
35806
|
+
});
|
|
35807
|
+
if (!sessionFile) {
|
|
35808
|
+
return { logs: [], sourcePath: null };
|
|
35809
|
+
}
|
|
35810
|
+
const logs = readJsonLines(sessionFile).filter((entry) => {
|
|
35811
|
+
if (entry.type !== "user" && entry.type !== "assistant" || entry.isMeta === true || entry.isSidechain === true) {
|
|
35812
|
+
return false;
|
|
35813
|
+
}
|
|
35814
|
+
return isRecord2(entry.message);
|
|
35815
|
+
});
|
|
35816
|
+
return { logs, sourcePath: sessionFile };
|
|
35817
|
+
}
|
|
35818
|
+
function loadCodexSessionHistory(sessionId) {
|
|
35819
|
+
const sessionsDir = path7.join(os4.homedir(), ".codex", "sessions");
|
|
35820
|
+
const sessionFile = findFirstMatchingFile(sessionsDir, (filePath) => path7.basename(filePath).toLowerCase().includes(sessionId.toLowerCase()) && filePath.toLowerCase().endsWith(".jsonl"));
|
|
35821
|
+
if (!sessionFile) {
|
|
35822
|
+
return { logs: [], sourcePath: null };
|
|
35823
|
+
}
|
|
35824
|
+
const logs = readJsonLines(sessionFile).flatMap((entry) => {
|
|
35825
|
+
if (entry.type !== "event_msg" || !isRecord2(entry.payload)) {
|
|
35826
|
+
return [];
|
|
35827
|
+
}
|
|
35828
|
+
const timestamp = typeof entry.timestamp === "string" ? entry.timestamp : void 0;
|
|
35829
|
+
const payload = entry.payload;
|
|
35830
|
+
if (payload.type === "user_message" && typeof payload.message === "string" && payload.message.trim()) {
|
|
35831
|
+
return [buildTaskUserLogEvent([{ type: "text", text: payload.message.trim() }], timestamp)];
|
|
35832
|
+
}
|
|
35833
|
+
if (payload.type === "agent_message" && typeof payload.message === "string" && payload.message.trim()) {
|
|
35834
|
+
return [buildAssistantTextEvent(payload.message.trim(), timestamp)];
|
|
35835
|
+
}
|
|
35836
|
+
if (payload.type === "agent_reasoning") {
|
|
35837
|
+
const reasoning = extractCodexReasoningText(payload);
|
|
35838
|
+
if (reasoning) {
|
|
35839
|
+
return [buildAssistantThinkingEvent(reasoning, timestamp)];
|
|
35840
|
+
}
|
|
35841
|
+
}
|
|
35842
|
+
return [];
|
|
35843
|
+
});
|
|
35844
|
+
return { logs, sourcePath: sessionFile };
|
|
35845
|
+
}
|
|
35846
|
+
function loadNativeSessionHistory(input) {
|
|
35847
|
+
if (input.agent === "claudecode") {
|
|
35848
|
+
return loadClaudeSessionHistory(input.sessionId);
|
|
35849
|
+
}
|
|
35850
|
+
return loadCodexSessionHistory(input.sessionId);
|
|
35851
|
+
}
|
|
35852
|
+
function listNativeSessions(input) {
|
|
35853
|
+
const limit = Math.min(Math.max(1, input.limit ?? 50), 100);
|
|
35854
|
+
if (input.agent === "claudecode") {
|
|
35855
|
+
const projectsDir = path7.join(os4.homedir(), ".claude", "projects");
|
|
35856
|
+
return findMatchingFiles(projectsDir, (filePath) => {
|
|
35857
|
+
if (filePath.includes(`${path7.sep}subagents${path7.sep}`)) {
|
|
35858
|
+
return false;
|
|
35859
|
+
}
|
|
35860
|
+
return filePath.toLowerCase().endsWith(".jsonl");
|
|
35861
|
+
}).map((filePath) => {
|
|
35862
|
+
const sessionId = path7.basename(filePath, ".jsonl");
|
|
35863
|
+
const summary = findClaudeSessionSummary(readJsonLines(filePath), sessionId);
|
|
35864
|
+
if (!summary) {
|
|
35865
|
+
return null;
|
|
35866
|
+
}
|
|
35867
|
+
return {
|
|
35868
|
+
...summary,
|
|
35869
|
+
updatedAt: summary.updatedAt ?? readFileModifiedAt(filePath)
|
|
35870
|
+
};
|
|
35871
|
+
}).filter((session) => session !== null).sort(compareUpdatedSessions).slice(0, limit);
|
|
35872
|
+
}
|
|
35873
|
+
const sessionIndex = loadCodexSessionIndex();
|
|
35874
|
+
const sessionsDir = path7.join(os4.homedir(), ".codex", "sessions");
|
|
35875
|
+
return findMatchingFiles(sessionsDir, (filePath) => filePath.toLowerCase().endsWith(".jsonl")).map((filePath) => {
|
|
35876
|
+
const summary = findCodexSessionSummary(readJsonLines(filePath), filePath, sessionIndex);
|
|
35877
|
+
if (!summary) {
|
|
35878
|
+
return null;
|
|
35879
|
+
}
|
|
35880
|
+
return {
|
|
35881
|
+
...summary,
|
|
35882
|
+
updatedAt: summary.updatedAt ?? readFileModifiedAt(filePath)
|
|
35883
|
+
};
|
|
35884
|
+
}).filter((session) => session !== null).sort(compareUpdatedSessions).slice(0, limit);
|
|
35885
|
+
}
|
|
35886
|
+
|
|
35553
35887
|
// ../../packages/core/src/tasks/task-forwarding.ts
|
|
35554
35888
|
function getEventType(event) {
|
|
35555
35889
|
return typeof event.type === "string" ? event.type : void 0;
|
|
@@ -35857,18 +36191,18 @@ function getCurrentGitBranch(workDir) {
|
|
|
35857
36191
|
var import_node_child_process3 = require("child_process");
|
|
35858
36192
|
|
|
35859
36193
|
// ../../packages/core/src/agents/cli-invocations.ts
|
|
35860
|
-
var
|
|
35861
|
-
var
|
|
36194
|
+
var fs8 = __toESM(require("fs"), 1);
|
|
36195
|
+
var path8 = __toESM(require("path"), 1);
|
|
35862
36196
|
function resolveClaudeInvocation() {
|
|
35863
36197
|
if (process.platform !== "win32") {
|
|
35864
36198
|
return { command: "claude", argsPrefix: [] };
|
|
35865
36199
|
}
|
|
35866
|
-
const pathEntries = (process.env.PATH ?? "").split(
|
|
36200
|
+
const pathEntries = (process.env.PATH ?? "").split(path8.delimiter).filter(Boolean);
|
|
35867
36201
|
for (const entry of pathEntries) {
|
|
35868
|
-
const shimPath =
|
|
35869
|
-
if (!
|
|
35870
|
-
const cliPath =
|
|
35871
|
-
if (
|
|
36202
|
+
const shimPath = path8.join(entry, "claude.cmd");
|
|
36203
|
+
if (!fs8.existsSync(shimPath)) continue;
|
|
36204
|
+
const cliPath = path8.join(entry, "node_modules", "@anthropic-ai", "claude-code", "cli.js");
|
|
36205
|
+
if (fs8.existsSync(cliPath)) {
|
|
35872
36206
|
return {
|
|
35873
36207
|
command: process.execPath,
|
|
35874
36208
|
argsPrefix: [cliPath]
|
|
@@ -35881,12 +36215,12 @@ function resolveCodexInvocation() {
|
|
|
35881
36215
|
if (process.platform !== "win32") {
|
|
35882
36216
|
return { command: "codex", argsPrefix: [] };
|
|
35883
36217
|
}
|
|
35884
|
-
const pathEntries = (process.env.PATH ?? "").split(
|
|
36218
|
+
const pathEntries = (process.env.PATH ?? "").split(path8.delimiter).filter(Boolean);
|
|
35885
36219
|
for (const entry of pathEntries) {
|
|
35886
|
-
const shimPath =
|
|
35887
|
-
if (!
|
|
35888
|
-
const cliPath =
|
|
35889
|
-
if (
|
|
36220
|
+
const shimPath = path8.join(entry, "codex.cmd");
|
|
36221
|
+
if (!fs8.existsSync(shimPath)) continue;
|
|
36222
|
+
const cliPath = path8.join(entry, "node_modules", "@openai", "codex", "bin", "codex.js");
|
|
36223
|
+
if (fs8.existsSync(cliPath)) {
|
|
35890
36224
|
return {
|
|
35891
36225
|
command: process.execPath,
|
|
35892
36226
|
argsPrefix: [cliPath]
|
|
@@ -36039,8 +36373,8 @@ var CodexLiteAdapter = class {
|
|
|
36039
36373
|
};
|
|
36040
36374
|
|
|
36041
36375
|
// ../../packages/core/src/agents/engines/claude-code-engine.ts
|
|
36042
|
-
var
|
|
36043
|
-
var
|
|
36376
|
+
var fs9 = __toESM(require("fs"), 1);
|
|
36377
|
+
var path9 = __toESM(require("path"), 1);
|
|
36044
36378
|
var import_node_child_process4 = require("child_process");
|
|
36045
36379
|
var DEFAULT_CLAUDE_MODEL = "sonnet";
|
|
36046
36380
|
function buildClaudeModeArgs(mode) {
|
|
@@ -36077,7 +36411,7 @@ var ClaudeCodeEngine = class extends ExecutionEngine {
|
|
|
36077
36411
|
if (task.agent !== "claudecode") continue;
|
|
36078
36412
|
const sessionId = task.payload.sessionId;
|
|
36079
36413
|
if (!sessionId) continue;
|
|
36080
|
-
const cwd =
|
|
36414
|
+
const cwd = path9.resolve(
|
|
36081
36415
|
task.payload.sessionCwd ?? task.effectiveProjectPath ?? task.project ?? process.cwd()
|
|
36082
36416
|
);
|
|
36083
36417
|
this.sessions.set(task.id, { sessionId, cwd, title: task.title });
|
|
@@ -36204,6 +36538,13 @@ var ClaudeCodeEngine = class extends ExecutionEngine {
|
|
|
36204
36538
|
session = recovered;
|
|
36205
36539
|
}
|
|
36206
36540
|
}
|
|
36541
|
+
if (!session) {
|
|
36542
|
+
const persisted = this.recoverPersistedSession(taskId);
|
|
36543
|
+
if (persisted) {
|
|
36544
|
+
this.sessions.set(taskId, persisted);
|
|
36545
|
+
session = persisted;
|
|
36546
|
+
}
|
|
36547
|
+
}
|
|
36207
36548
|
if (!session) {
|
|
36208
36549
|
throw new MeshyError("TASK_NOT_FOUND", `No active session for task ${taskId}`, 404);
|
|
36209
36550
|
}
|
|
@@ -36337,8 +36678,8 @@ var ClaudeCodeEngine = class extends ExecutionEngine {
|
|
|
36337
36678
|
/** Recover a session by scanning the JSONL log file for the last system.init event. */
|
|
36338
36679
|
recoverSession(taskId) {
|
|
36339
36680
|
const logPath = this.getLogPath(taskId);
|
|
36340
|
-
if (!
|
|
36341
|
-
const content =
|
|
36681
|
+
if (!fs9.existsSync(logPath)) return null;
|
|
36682
|
+
const content = fs9.readFileSync(logPath, "utf-8").trim();
|
|
36342
36683
|
if (!content) return null;
|
|
36343
36684
|
const lines = content.split("\n");
|
|
36344
36685
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
@@ -36351,7 +36692,7 @@ var ClaudeCodeEngine = class extends ExecutionEngine {
|
|
|
36351
36692
|
const persistedCwd = typeof task?.payload.sessionCwd === "string" ? task.payload.sessionCwd : void 0;
|
|
36352
36693
|
return {
|
|
36353
36694
|
sessionId: event.session_id,
|
|
36354
|
-
cwd:
|
|
36695
|
+
cwd: path9.resolve(
|
|
36355
36696
|
(typeof event.cwd === "string" ? event.cwd : persistedCwd) ?? task?.effectiveProjectPath ?? task?.project ?? process.cwd()
|
|
36356
36697
|
),
|
|
36357
36698
|
title: task?.title ?? taskId
|
|
@@ -36362,11 +36703,25 @@ var ClaudeCodeEngine = class extends ExecutionEngine {
|
|
|
36362
36703
|
}
|
|
36363
36704
|
return null;
|
|
36364
36705
|
}
|
|
36706
|
+
recoverPersistedSession(taskId) {
|
|
36707
|
+
const task = this.taskEngine.getTask(taskId);
|
|
36708
|
+
const sessionId = typeof task?.payload.sessionId === "string" ? task.payload.sessionId : void 0;
|
|
36709
|
+
if (!sessionId) {
|
|
36710
|
+
return null;
|
|
36711
|
+
}
|
|
36712
|
+
return {
|
|
36713
|
+
sessionId,
|
|
36714
|
+
cwd: path9.resolve(
|
|
36715
|
+
(typeof task?.payload.sessionCwd === "string" ? task.payload.sessionCwd : void 0) ?? task?.effectiveProjectPath ?? task?.project ?? process.cwd()
|
|
36716
|
+
),
|
|
36717
|
+
title: task?.title ?? taskId
|
|
36718
|
+
};
|
|
36719
|
+
}
|
|
36365
36720
|
};
|
|
36366
36721
|
|
|
36367
36722
|
// ../../packages/core/src/agents/engines/codex-engine.ts
|
|
36368
|
-
var
|
|
36369
|
-
var
|
|
36723
|
+
var fs10 = __toESM(require("fs"), 1);
|
|
36724
|
+
var path10 = __toESM(require("path"), 1);
|
|
36370
36725
|
var import_node_child_process5 = require("child_process");
|
|
36371
36726
|
function buildAssistantEvent(text, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
36372
36727
|
return {
|
|
@@ -36378,7 +36733,7 @@ function buildAssistantEvent(text, timestamp = (/* @__PURE__ */ new Date()).toIS
|
|
|
36378
36733
|
timestamp
|
|
36379
36734
|
};
|
|
36380
36735
|
}
|
|
36381
|
-
function
|
|
36736
|
+
function buildAssistantThinkingEvent2(thinking, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
36382
36737
|
return {
|
|
36383
36738
|
type: "assistant",
|
|
36384
36739
|
message: {
|
|
@@ -36388,7 +36743,7 @@ function buildAssistantThinkingEvent(thinking, timestamp = (/* @__PURE__ */ new
|
|
|
36388
36743
|
timestamp
|
|
36389
36744
|
};
|
|
36390
36745
|
}
|
|
36391
|
-
function
|
|
36746
|
+
function extractCodexReasoningText2(item) {
|
|
36392
36747
|
if (typeof item.text === "string") {
|
|
36393
36748
|
return item.text.trim();
|
|
36394
36749
|
}
|
|
@@ -36446,7 +36801,7 @@ var CodexEngine = class extends ExecutionEngine {
|
|
|
36446
36801
|
if (task.agent !== "codex") continue;
|
|
36447
36802
|
const sessionId = task.payload.sessionId;
|
|
36448
36803
|
if (!sessionId) continue;
|
|
36449
|
-
const cwd =
|
|
36804
|
+
const cwd = path10.resolve(
|
|
36450
36805
|
task.payload.sessionCwd ?? task.effectiveProjectPath ?? task.project ?? process.cwd()
|
|
36451
36806
|
);
|
|
36452
36807
|
this.sessions.set(task.id, { sessionId, cwd, title: task.title });
|
|
@@ -36481,6 +36836,13 @@ var CodexEngine = class extends ExecutionEngine {
|
|
|
36481
36836
|
session = recovered;
|
|
36482
36837
|
}
|
|
36483
36838
|
}
|
|
36839
|
+
if (!session) {
|
|
36840
|
+
const persisted = this.recoverPersistedSession(taskId);
|
|
36841
|
+
if (persisted) {
|
|
36842
|
+
this.sessions.set(taskId, persisted);
|
|
36843
|
+
session = persisted;
|
|
36844
|
+
}
|
|
36845
|
+
}
|
|
36484
36846
|
if (!session) {
|
|
36485
36847
|
throw new MeshyError("TASK_NOT_FOUND", `No active session for task ${taskId}`, 404);
|
|
36486
36848
|
}
|
|
@@ -36626,9 +36988,9 @@ var CodexEngine = class extends ExecutionEngine {
|
|
|
36626
36988
|
return buildAssistantEvent(item.text);
|
|
36627
36989
|
}
|
|
36628
36990
|
if (item?.type === "reasoning" || item?.type === "agent_reasoning") {
|
|
36629
|
-
const reasoning =
|
|
36991
|
+
const reasoning = extractCodexReasoningText2(item);
|
|
36630
36992
|
if (reasoning) {
|
|
36631
|
-
return
|
|
36993
|
+
return buildAssistantThinkingEvent2(reasoning);
|
|
36632
36994
|
}
|
|
36633
36995
|
}
|
|
36634
36996
|
}
|
|
@@ -36640,13 +37002,13 @@ var CodexEngine = class extends ExecutionEngine {
|
|
|
36640
37002
|
if (images.length === 0) {
|
|
36641
37003
|
return { prompt, imagePaths: [] };
|
|
36642
37004
|
}
|
|
36643
|
-
const attachmentDir =
|
|
36644
|
-
|
|
37005
|
+
const attachmentDir = path10.join(this.logDir, "attachments", taskId);
|
|
37006
|
+
fs10.mkdirSync(attachmentDir, { recursive: true });
|
|
36645
37007
|
const imagePaths = images.map((image, index) => {
|
|
36646
37008
|
const fallbackName = `image-${Date.now()}-${index}.${inferExtension(image.mediaType)}`;
|
|
36647
37009
|
const filename = sanitizeFilename(image.filename ?? fallbackName);
|
|
36648
|
-
const filePath =
|
|
36649
|
-
|
|
37010
|
+
const filePath = path10.join(attachmentDir, filename);
|
|
37011
|
+
fs10.writeFileSync(filePath, Buffer.from(image.data, "base64"));
|
|
36650
37012
|
return filePath;
|
|
36651
37013
|
});
|
|
36652
37014
|
return { prompt, imagePaths };
|
|
@@ -36665,8 +37027,8 @@ var CodexEngine = class extends ExecutionEngine {
|
|
|
36665
37027
|
/** Recover a session by scanning the JSONL log for the thread.started event. */
|
|
36666
37028
|
recoverSession(taskId) {
|
|
36667
37029
|
const logPath = this.getLogPath(taskId);
|
|
36668
|
-
if (!
|
|
36669
|
-
const content =
|
|
37030
|
+
if (!fs10.existsSync(logPath)) return null;
|
|
37031
|
+
const content = fs10.readFileSync(logPath, "utf-8").trim();
|
|
36670
37032
|
if (!content) return null;
|
|
36671
37033
|
const lines = content.split("\n");
|
|
36672
37034
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
@@ -36679,7 +37041,7 @@ var CodexEngine = class extends ExecutionEngine {
|
|
|
36679
37041
|
const persistedCwd = typeof task?.payload.sessionCwd === "string" ? task.payload.sessionCwd : void 0;
|
|
36680
37042
|
return {
|
|
36681
37043
|
sessionId: event.thread_id,
|
|
36682
|
-
cwd:
|
|
37044
|
+
cwd: path10.resolve(persistedCwd ?? task?.effectiveProjectPath ?? task?.project ?? process.cwd()),
|
|
36683
37045
|
title: task?.title ?? taskId
|
|
36684
37046
|
};
|
|
36685
37047
|
}
|
|
@@ -36688,11 +37050,25 @@ var CodexEngine = class extends ExecutionEngine {
|
|
|
36688
37050
|
}
|
|
36689
37051
|
return null;
|
|
36690
37052
|
}
|
|
37053
|
+
recoverPersistedSession(taskId) {
|
|
37054
|
+
const task = this.taskEngine.getTask(taskId);
|
|
37055
|
+
const sessionId = typeof task?.payload.sessionId === "string" ? task.payload.sessionId : void 0;
|
|
37056
|
+
if (!sessionId) {
|
|
37057
|
+
return null;
|
|
37058
|
+
}
|
|
37059
|
+
return {
|
|
37060
|
+
sessionId,
|
|
37061
|
+
cwd: path10.resolve(
|
|
37062
|
+
(typeof task?.payload.sessionCwd === "string" ? task.payload.sessionCwd : void 0) ?? task?.effectiveProjectPath ?? task?.project ?? process.cwd()
|
|
37063
|
+
),
|
|
37064
|
+
title: task?.title ?? taskId
|
|
37065
|
+
};
|
|
37066
|
+
}
|
|
36691
37067
|
};
|
|
36692
37068
|
|
|
36693
37069
|
// ../../packages/core/src/storage/storage-paths.ts
|
|
36694
|
-
var
|
|
36695
|
-
var
|
|
37070
|
+
var os5 = __toESM(require("os"), 1);
|
|
37071
|
+
var path11 = __toESM(require("path"), 1);
|
|
36696
37072
|
function resolveDefaultStorageMode(options = {}) {
|
|
36697
37073
|
const envMode = options.env?.MESHY_STORAGE_MODE;
|
|
36698
37074
|
if (envMode === "cwd" || envMode === "home") {
|
|
@@ -36707,20 +37083,20 @@ function resolveDefaultStorageMode(options = {}) {
|
|
|
36707
37083
|
function resolveDefaultStoragePath(options = {}) {
|
|
36708
37084
|
const mode = resolveDefaultStorageMode(options);
|
|
36709
37085
|
const envBaseDir = options.env?.MESHY_STORAGE_BASE_DIR;
|
|
36710
|
-
const baseDir = mode === "cwd" ? envBaseDir ?? options.cwd ?? process.cwd() : options.homeDir ??
|
|
36711
|
-
return
|
|
37086
|
+
const baseDir = mode === "cwd" ? envBaseDir ?? options.cwd ?? process.cwd() : options.homeDir ?? os5.homedir();
|
|
37087
|
+
return path11.resolve(baseDir, ".meshy");
|
|
36712
37088
|
}
|
|
36713
37089
|
function toSafeNodeStorageName(nodeName) {
|
|
36714
37090
|
const safeName = nodeName.trim().replace(/[^a-zA-Z0-9_-]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
36715
37091
|
return safeName.length > 0 ? safeName : "node";
|
|
36716
37092
|
}
|
|
36717
37093
|
function resolveNodeScopedStoragePath(storageRoot, nodeName) {
|
|
36718
|
-
return
|
|
37094
|
+
return path11.resolve(storageRoot, toSafeNodeStorageName(nodeName));
|
|
36719
37095
|
}
|
|
36720
37096
|
|
|
36721
37097
|
// ../../packages/core/src/storage/storage-migration.ts
|
|
36722
|
-
var
|
|
36723
|
-
var
|
|
37098
|
+
var fs11 = __toESM(require("fs"), 1);
|
|
37099
|
+
var path12 = __toESM(require("path"), 1);
|
|
36724
37100
|
var LEGACY_FILES = [
|
|
36725
37101
|
"metadata.json",
|
|
36726
37102
|
"cluster.json",
|
|
@@ -36731,33 +37107,33 @@ var LEGACY_FILES = [
|
|
|
36731
37107
|
];
|
|
36732
37108
|
var LEGACY_DIRS = ["logs", "task-logs"];
|
|
36733
37109
|
function migrateLegacyNodeStorage(options) {
|
|
36734
|
-
const sourcePath =
|
|
37110
|
+
const sourcePath = path12.resolve(options.storageRoot);
|
|
36735
37111
|
if (normalizeString2(options.nodeName)) {
|
|
36736
37112
|
return migrateIntoRequestedNode({ ...options, storageRoot: sourcePath, nodeName: normalizeString2(options.nodeName) });
|
|
36737
37113
|
}
|
|
36738
37114
|
return migrateByDiscoveredNodes({ ...options, storageRoot: sourcePath });
|
|
36739
37115
|
}
|
|
36740
37116
|
function migrateIntoRequestedNode(options) {
|
|
36741
|
-
const sourcePath =
|
|
37117
|
+
const sourcePath = path12.resolve(options.storageRoot);
|
|
36742
37118
|
const targetPath = resolveNodeScopedStoragePath(sourcePath, options.nodeName);
|
|
36743
37119
|
const moved = [];
|
|
36744
37120
|
const skipped = [];
|
|
36745
37121
|
const entries = collectLegacyEntries(sourcePath, options.nodeName);
|
|
36746
37122
|
for (const entry of entries) {
|
|
36747
|
-
const source =
|
|
36748
|
-
const target =
|
|
36749
|
-
if (!
|
|
37123
|
+
const source = path12.join(sourcePath, entry.sourceName);
|
|
37124
|
+
const target = path12.join(targetPath, entry.targetName);
|
|
37125
|
+
if (!fs11.existsSync(source)) {
|
|
36750
37126
|
continue;
|
|
36751
37127
|
}
|
|
36752
|
-
if (
|
|
37128
|
+
if (fs11.existsSync(target) && options.overwrite !== true) {
|
|
36753
37129
|
skipped.push(entry.targetName);
|
|
36754
37130
|
continue;
|
|
36755
37131
|
}
|
|
36756
|
-
|
|
36757
|
-
if (
|
|
36758
|
-
|
|
37132
|
+
fs11.mkdirSync(path12.dirname(target), { recursive: true });
|
|
37133
|
+
if (fs11.existsSync(target)) {
|
|
37134
|
+
fs11.rmSync(target, { recursive: true, force: true });
|
|
36759
37135
|
}
|
|
36760
|
-
|
|
37136
|
+
fs11.renameSync(source, target);
|
|
36761
37137
|
moved.push(entry.targetName);
|
|
36762
37138
|
}
|
|
36763
37139
|
return {
|
|
@@ -36772,16 +37148,16 @@ function migrateIntoRequestedNode(options) {
|
|
|
36772
37148
|
};
|
|
36773
37149
|
}
|
|
36774
37150
|
function migrateByDiscoveredNodes(options) {
|
|
36775
|
-
const sourcePath =
|
|
37151
|
+
const sourcePath = path12.resolve(options.storageRoot);
|
|
36776
37152
|
const moved = [];
|
|
36777
37153
|
const skipped = [];
|
|
36778
37154
|
const dropped = [];
|
|
36779
37155
|
const targetNames = /* @__PURE__ */ new Set();
|
|
36780
37156
|
const nodeIdToName = /* @__PURE__ */ new Map();
|
|
36781
|
-
const nodes = readJsonRecord(
|
|
37157
|
+
const nodes = readJsonRecord(path12.join(sourcePath, "nodes.json"));
|
|
36782
37158
|
const nodesByName = /* @__PURE__ */ new Map();
|
|
36783
37159
|
for (const [key, value] of Object.entries(nodes)) {
|
|
36784
|
-
if (!
|
|
37160
|
+
if (!isRecord3(value)) {
|
|
36785
37161
|
dropped.push(`node:${key}`);
|
|
36786
37162
|
continue;
|
|
36787
37163
|
}
|
|
@@ -36795,7 +37171,7 @@ function migrateByDiscoveredNodes(options) {
|
|
|
36795
37171
|
nodeIdToName.set(nodeId, nodeName);
|
|
36796
37172
|
nodesByName.set(nodeName, { ...nodesByName.get(nodeName) ?? {}, [nodeId]: value });
|
|
36797
37173
|
}
|
|
36798
|
-
const metadata = readJsonRecord(
|
|
37174
|
+
const metadata = readJsonRecord(path12.join(sourcePath, "metadata.json"));
|
|
36799
37175
|
const metadataNodeName = normalizeString2(metadata.defaultNodeName);
|
|
36800
37176
|
if (metadataNodeName) {
|
|
36801
37177
|
targetNames.add(metadataNodeName);
|
|
@@ -36825,7 +37201,7 @@ function migrateByDiscoveredNodes(options) {
|
|
|
36825
37201
|
}
|
|
36826
37202
|
moveScopedPath(
|
|
36827
37203
|
identity.sourcePath,
|
|
36828
|
-
|
|
37204
|
+
path12.join(resolveNodeScopedStoragePath(sourcePath, identity.nodeName), "node-identity.json"),
|
|
36829
37205
|
`${identity.nodeName}/node-identity.json`,
|
|
36830
37206
|
options.overwrite === true,
|
|
36831
37207
|
moved,
|
|
@@ -36837,8 +37213,8 @@ function migrateByDiscoveredNodes(options) {
|
|
|
36837
37213
|
migrateNodeScopedOrDrop(sourcePath, resolveElectionNodeName(sourcePath, nodeIdToName) ?? inferredSingleNodeName, "election.json", options.overwrite === true, moved, skipped, dropped);
|
|
36838
37214
|
migrateNodeScopedOrDrop(sourcePath, inferredSingleNodeName, "cluster.json", options.overwrite === true, moved, skipped, dropped);
|
|
36839
37215
|
migrateNodeScopedOrDrop(sourcePath, inferredSingleNodeName, "logs", options.overwrite === true, moved, skipped, dropped);
|
|
36840
|
-
cleanupEmptyDir(
|
|
36841
|
-
const targetNodeNames = [...targetNames].filter((nodeName) =>
|
|
37216
|
+
cleanupEmptyDir(path12.join(sourcePath, "task-logs"));
|
|
37217
|
+
const targetNodeNames = [...targetNames].filter((nodeName) => fs11.existsSync(resolveNodeScopedStoragePath(sourcePath, nodeName))).sort();
|
|
36842
37218
|
const targetPaths = targetNodeNames.map((nodeName) => resolveNodeScopedStoragePath(sourcePath, nodeName));
|
|
36843
37219
|
return {
|
|
36844
37220
|
migrated: moved.length > 0 && skipped.length === 0,
|
|
@@ -36855,9 +37231,9 @@ function migrateTasksAndShares(sourcePath, nodeIdToName, targetNames, overwrite,
|
|
|
36855
37231
|
const taskNodeNames = /* @__PURE__ */ new Set();
|
|
36856
37232
|
const taskIdToNodeName = /* @__PURE__ */ new Map();
|
|
36857
37233
|
const tasksByName = /* @__PURE__ */ new Map();
|
|
36858
|
-
const tasks = readJsonRecord(
|
|
37234
|
+
const tasks = readJsonRecord(path12.join(sourcePath, "tasks.json"));
|
|
36859
37235
|
for (const [key, value] of Object.entries(tasks)) {
|
|
36860
|
-
if (!
|
|
37236
|
+
if (!isRecord3(value)) {
|
|
36861
37237
|
dropped.push(`task:${key}`);
|
|
36862
37238
|
continue;
|
|
36863
37239
|
}
|
|
@@ -36876,16 +37252,16 @@ function migrateTasksAndShares(sourcePath, nodeIdToName, targetNames, overwrite,
|
|
|
36876
37252
|
for (const [nodeName, taskGroup] of tasksByName) {
|
|
36877
37253
|
writeScopedJson(sourcePath, nodeName, "tasks.json", taskGroup, overwrite, moved, skipped);
|
|
36878
37254
|
}
|
|
36879
|
-
if (skipped.length === taskSkipStart &&
|
|
37255
|
+
if (skipped.length === taskSkipStart && fs11.existsSync(path12.join(sourcePath, "tasks.json"))) {
|
|
36880
37256
|
if (tasksByName.size === 0) {
|
|
36881
37257
|
dropped.push("tasks.json");
|
|
36882
37258
|
}
|
|
36883
|
-
|
|
37259
|
+
fs11.rmSync(path12.join(sourcePath, "tasks.json"), { force: true });
|
|
36884
37260
|
}
|
|
36885
37261
|
const sharesByName = /* @__PURE__ */ new Map();
|
|
36886
|
-
const shares = readJsonRecord(
|
|
37262
|
+
const shares = readJsonRecord(path12.join(sourcePath, "shares.json"));
|
|
36887
37263
|
for (const [key, value] of Object.entries(shares)) {
|
|
36888
|
-
if (!
|
|
37264
|
+
if (!isRecord3(value)) {
|
|
36889
37265
|
dropped.push(`share:${key}`);
|
|
36890
37266
|
continue;
|
|
36891
37267
|
}
|
|
@@ -36912,22 +37288,22 @@ function migrateTasksAndShares(sourcePath, nodeIdToName, targetNames, overwrite,
|
|
|
36912
37288
|
return taskNodeNames;
|
|
36913
37289
|
}
|
|
36914
37290
|
function migrateTaskLogs(sourcePath, taskIdToNodeName, overwrite, moved, skipped, dropped) {
|
|
36915
|
-
const sourceDir =
|
|
36916
|
-
if (!
|
|
36917
|
-
for (const fileName of
|
|
36918
|
-
const source =
|
|
36919
|
-
const stat =
|
|
37291
|
+
const sourceDir = path12.join(sourcePath, "task-logs");
|
|
37292
|
+
if (!fs11.existsSync(sourceDir)) return;
|
|
37293
|
+
for (const fileName of fs11.readdirSync(sourceDir)) {
|
|
37294
|
+
const source = path12.join(sourceDir, fileName);
|
|
37295
|
+
const stat = fs11.statSync(source);
|
|
36920
37296
|
if (!stat.isFile()) continue;
|
|
36921
37297
|
const taskId = fileName.endsWith(".jsonl") ? fileName.slice(0, -".jsonl".length) : fileName;
|
|
36922
37298
|
const nodeName = taskIdToNodeName.get(taskId);
|
|
36923
37299
|
if (!nodeName) {
|
|
36924
|
-
|
|
37300
|
+
fs11.rmSync(source, { force: true });
|
|
36925
37301
|
dropped.push(`task-log:${fileName}`);
|
|
36926
37302
|
continue;
|
|
36927
37303
|
}
|
|
36928
37304
|
moveScopedPath(
|
|
36929
37305
|
source,
|
|
36930
|
-
|
|
37306
|
+
path12.join(resolveNodeScopedStoragePath(sourcePath, nodeName), "task-logs", fileName),
|
|
36931
37307
|
`${nodeName}/task-logs/${fileName}`,
|
|
36932
37308
|
overwrite,
|
|
36933
37309
|
moved,
|
|
@@ -36936,8 +37312,8 @@ function migrateTaskLogs(sourcePath, taskIdToNodeName, overwrite, moved, skipped
|
|
|
36936
37312
|
}
|
|
36937
37313
|
}
|
|
36938
37314
|
function migrateNodeScopedOrDrop(sourcePath, nodeName, sourceName, overwrite, moved, skipped, dropped) {
|
|
36939
|
-
const source =
|
|
36940
|
-
if (!
|
|
37315
|
+
const source = path12.join(sourcePath, sourceName);
|
|
37316
|
+
if (!fs11.existsSync(source)) return;
|
|
36941
37317
|
if (!nodeName) {
|
|
36942
37318
|
removeLegacyPath(source);
|
|
36943
37319
|
dropped.push(sourceName);
|
|
@@ -36945,7 +37321,7 @@ function migrateNodeScopedOrDrop(sourcePath, nodeName, sourceName, overwrite, mo
|
|
|
36945
37321
|
}
|
|
36946
37322
|
moveScopedPath(
|
|
36947
37323
|
source,
|
|
36948
|
-
|
|
37324
|
+
path12.join(resolveNodeScopedStoragePath(sourcePath, nodeName), sourceName),
|
|
36949
37325
|
`${nodeName}/${sourceName}`,
|
|
36950
37326
|
overwrite,
|
|
36951
37327
|
moved,
|
|
@@ -36954,37 +37330,37 @@ function migrateNodeScopedOrDrop(sourcePath, nodeName, sourceName, overwrite, mo
|
|
|
36954
37330
|
}
|
|
36955
37331
|
function writeScopedJson(sourcePath, nodeName, fileName, value, overwrite, moved, skipped) {
|
|
36956
37332
|
if (Object.keys(value).length === 0) return;
|
|
36957
|
-
const target =
|
|
37333
|
+
const target = path12.join(resolveNodeScopedStoragePath(sourcePath, nodeName), fileName);
|
|
36958
37334
|
const label = `${nodeName}/${fileName}`;
|
|
36959
|
-
if (
|
|
37335
|
+
if (fs11.existsSync(target) && !overwrite) {
|
|
36960
37336
|
skipped.push(label);
|
|
36961
37337
|
return;
|
|
36962
37338
|
}
|
|
36963
|
-
|
|
36964
|
-
|
|
37339
|
+
fs11.mkdirSync(path12.dirname(target), { recursive: true });
|
|
37340
|
+
fs11.writeFileSync(target, JSON.stringify(value, null, 2) + "\n", "utf-8");
|
|
36965
37341
|
moved.push(label);
|
|
36966
37342
|
}
|
|
36967
37343
|
function moveScopedPath(source, target, label, overwrite, moved, skipped) {
|
|
36968
|
-
if (!
|
|
36969
|
-
if (
|
|
37344
|
+
if (!fs11.existsSync(source)) return;
|
|
37345
|
+
if (fs11.existsSync(target) && !overwrite) {
|
|
36970
37346
|
skipped.push(label);
|
|
36971
37347
|
return;
|
|
36972
37348
|
}
|
|
36973
|
-
|
|
36974
|
-
if (
|
|
36975
|
-
|
|
37349
|
+
fs11.mkdirSync(path12.dirname(target), { recursive: true });
|
|
37350
|
+
if (fs11.existsSync(target)) {
|
|
37351
|
+
fs11.rmSync(target, { recursive: true, force: true });
|
|
36976
37352
|
}
|
|
36977
|
-
|
|
37353
|
+
fs11.renameSync(source, target);
|
|
36978
37354
|
moved.push(label);
|
|
36979
37355
|
}
|
|
36980
37356
|
function collectIdentityEntries(storageRoot) {
|
|
36981
|
-
if (!
|
|
37357
|
+
if (!fs11.existsSync(storageRoot)) return [];
|
|
36982
37358
|
const entries = [];
|
|
36983
|
-
for (const sourceName of
|
|
37359
|
+
for (const sourceName of fs11.readdirSync(storageRoot)) {
|
|
36984
37360
|
const match = /^node-identity-(.+)\.json$/.exec(sourceName);
|
|
36985
37361
|
if (sourceName !== "node-identity.json" && !match) continue;
|
|
36986
|
-
const sourcePath =
|
|
36987
|
-
if (!
|
|
37362
|
+
const sourcePath = path12.join(storageRoot, sourceName);
|
|
37363
|
+
if (!fs11.statSync(sourcePath).isFile()) continue;
|
|
36988
37364
|
const identity = readJsonRecord(sourcePath);
|
|
36989
37365
|
const nodeName = normalizeString2(identity.name) ?? (match ? match[1] : void 0);
|
|
36990
37366
|
entries.push({ sourceName, sourcePath, nodeName });
|
|
@@ -36992,27 +37368,27 @@ function collectIdentityEntries(storageRoot) {
|
|
|
36992
37368
|
return entries;
|
|
36993
37369
|
}
|
|
36994
37370
|
function resolveElectionNodeName(sourcePath, nodeIdToName) {
|
|
36995
|
-
const election = readJsonRecord(
|
|
37371
|
+
const election = readJsonRecord(path12.join(sourcePath, "election.json"));
|
|
36996
37372
|
const leaderId = normalizeString2(election.leaderId);
|
|
36997
37373
|
return leaderId ? nodeIdToName.get(leaderId) : void 0;
|
|
36998
37374
|
}
|
|
36999
37375
|
function removeLegacyFile(sourcePath, fileName, dropped) {
|
|
37000
|
-
const target =
|
|
37001
|
-
if (!
|
|
37002
|
-
|
|
37376
|
+
const target = path12.join(sourcePath, fileName);
|
|
37377
|
+
if (!fs11.existsSync(target)) return;
|
|
37378
|
+
fs11.rmSync(target, { force: true });
|
|
37003
37379
|
if (fileName !== "nodes.json" && fileName !== "shares.json") {
|
|
37004
37380
|
dropped.push(fileName);
|
|
37005
37381
|
}
|
|
37006
37382
|
}
|
|
37007
37383
|
function cleanupEmptyDir(dirPath) {
|
|
37008
|
-
if (!
|
|
37009
|
-
if (
|
|
37010
|
-
|
|
37384
|
+
if (!fs11.existsSync(dirPath)) return;
|
|
37385
|
+
if (fs11.readdirSync(dirPath).length === 0) {
|
|
37386
|
+
fs11.rmSync(dirPath, { recursive: true, force: true });
|
|
37011
37387
|
}
|
|
37012
37388
|
}
|
|
37013
37389
|
function removeLegacyPath(targetPath) {
|
|
37014
|
-
if (
|
|
37015
|
-
|
|
37390
|
+
if (fs11.existsSync(targetPath)) {
|
|
37391
|
+
fs11.rmSync(targetPath, { recursive: true, force: true });
|
|
37016
37392
|
}
|
|
37017
37393
|
}
|
|
37018
37394
|
function collectLegacyEntries(storageRoot, nodeName) {
|
|
@@ -37026,16 +37402,16 @@ function collectLegacyEntries(storageRoot, nodeName) {
|
|
|
37026
37402
|
}
|
|
37027
37403
|
const exactIdentity = `node-identity-${safeName}.json`;
|
|
37028
37404
|
entries.push({ sourceName: exactIdentity, targetName: "node-identity.json" });
|
|
37029
|
-
const legacyIdentity =
|
|
37030
|
-
if (
|
|
37405
|
+
const legacyIdentity = path12.join(storageRoot, "node-identity.json");
|
|
37406
|
+
if (fs11.existsSync(legacyIdentity)) {
|
|
37031
37407
|
entries.push({ sourceName: "node-identity.json", targetName: "node-identity.json" });
|
|
37032
37408
|
}
|
|
37033
37409
|
return entries;
|
|
37034
37410
|
}
|
|
37035
37411
|
function readJsonRecord(filePath) {
|
|
37036
37412
|
try {
|
|
37037
|
-
const parsed = JSON.parse(
|
|
37038
|
-
return
|
|
37413
|
+
const parsed = JSON.parse(fs11.readFileSync(filePath, "utf-8"));
|
|
37414
|
+
return isRecord3(parsed) ? parsed : {};
|
|
37039
37415
|
} catch {
|
|
37040
37416
|
return {};
|
|
37041
37417
|
}
|
|
@@ -37045,12 +37421,12 @@ function normalizeString2(value) {
|
|
|
37045
37421
|
const trimmed = value.trim();
|
|
37046
37422
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
37047
37423
|
}
|
|
37048
|
-
function
|
|
37424
|
+
function isRecord3(value) {
|
|
37049
37425
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37050
37426
|
}
|
|
37051
37427
|
|
|
37052
37428
|
// ../../packages/core/src/node/node.ts
|
|
37053
|
-
var
|
|
37429
|
+
var path14 = __toESM(require("path"), 1);
|
|
37054
37430
|
|
|
37055
37431
|
// ../../packages/core/src/messaging/node-local-message-handler.ts
|
|
37056
37432
|
async function handleLocalNodeMessage(deps, message) {
|
|
@@ -37095,8 +37471,8 @@ async function handleLocalNodeMessage(deps, message) {
|
|
|
37095
37471
|
}
|
|
37096
37472
|
|
|
37097
37473
|
// ../../packages/core/src/node/node-identity.ts
|
|
37098
|
-
var
|
|
37099
|
-
var
|
|
37474
|
+
var fs12 = __toESM(require("fs"), 1);
|
|
37475
|
+
var path13 = __toESM(require("path"), 1);
|
|
37100
37476
|
|
|
37101
37477
|
// ../../node_modules/.pnpm/nanoid@5.1.7/node_modules/nanoid/index.js
|
|
37102
37478
|
var import_node_crypto6 = require("crypto");
|
|
@@ -37130,17 +37506,17 @@ function nanoid(size = 21) {
|
|
|
37130
37506
|
|
|
37131
37507
|
// ../../packages/core/src/node/node-identity.ts
|
|
37132
37508
|
function loadOrCreateNodeId(storagePath, nodeName) {
|
|
37133
|
-
const identityPath =
|
|
37509
|
+
const identityPath = path13.join(storagePath, "node-identity.json");
|
|
37134
37510
|
try {
|
|
37135
|
-
if (
|
|
37136
|
-
const raw = JSON.parse(
|
|
37511
|
+
if (fs12.existsSync(identityPath)) {
|
|
37512
|
+
const raw = JSON.parse(fs12.readFileSync(identityPath, "utf-8"));
|
|
37137
37513
|
if (typeof raw.id === "string" && raw.id.length > 0) return raw.id;
|
|
37138
37514
|
}
|
|
37139
37515
|
} catch {
|
|
37140
37516
|
}
|
|
37141
37517
|
const id = nanoid();
|
|
37142
|
-
|
|
37143
|
-
|
|
37518
|
+
fs12.mkdirSync(path13.dirname(identityPath), { recursive: true });
|
|
37519
|
+
fs12.writeFileSync(identityPath, JSON.stringify({ id, name: nodeName }, null, 2) + "\n", "utf-8");
|
|
37144
37520
|
return id;
|
|
37145
37521
|
}
|
|
37146
37522
|
|
|
@@ -37184,7 +37560,7 @@ var MeshyNode = class {
|
|
|
37184
37560
|
await this.transport.start(this.config.node.port);
|
|
37185
37561
|
const endpoint = await this.transport.getEndpoint();
|
|
37186
37562
|
const now = Date.now();
|
|
37187
|
-
const workDir =
|
|
37563
|
+
const workDir = path14.resolve(this.config.node.workDir ?? process.cwd());
|
|
37188
37564
|
this.selfInfo = {
|
|
37189
37565
|
id: nodeId,
|
|
37190
37566
|
name: this.config.node.name,
|
|
@@ -37214,7 +37590,7 @@ var MeshyNode = class {
|
|
|
37214
37590
|
this.logger,
|
|
37215
37591
|
this.getSettingsSnapshot
|
|
37216
37592
|
);
|
|
37217
|
-
const logDir =
|
|
37593
|
+
const logDir = path14.join(this.config.storage.path, "task-logs");
|
|
37218
37594
|
this.taskEngine = new TaskEngine(this.store, this.nodeRegistry, this.eventBus, logDir);
|
|
37219
37595
|
this.heartbeat.setGetAssignedTasks((nodeId2) => {
|
|
37220
37596
|
const result = this.taskEngine.listTasks({ assignedTo: nodeId2, status: "assigned" });
|
|
@@ -38282,7 +38658,7 @@ function formatBanner(info) {
|
|
|
38282
38658
|
}
|
|
38283
38659
|
|
|
38284
38660
|
// src/bootstrap/process.ts
|
|
38285
|
-
var
|
|
38661
|
+
var fs13 = __toESM(require("fs"), 1);
|
|
38286
38662
|
var nodePath = __toESM(require("path"), 1);
|
|
38287
38663
|
var startupFatalLogPath;
|
|
38288
38664
|
function getErrorMessage2(err) {
|
|
@@ -38307,8 +38683,8 @@ function writeStartupFatalError(err, logPath = startupFatalLogPath) {
|
|
|
38307
38683
|
if (!logPath) {
|
|
38308
38684
|
return void 0;
|
|
38309
38685
|
}
|
|
38310
|
-
|
|
38311
|
-
|
|
38686
|
+
fs13.mkdirSync(nodePath.dirname(logPath), { recursive: true });
|
|
38687
|
+
fs13.appendFileSync(logPath, formatFatalErrorForLog(err), "utf-8");
|
|
38312
38688
|
return logPath;
|
|
38313
38689
|
}
|
|
38314
38690
|
async function closeHttpServer(server, options = {}) {
|
|
@@ -38825,8 +39201,8 @@ function getErrorMap() {
|
|
|
38825
39201
|
|
|
38826
39202
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
38827
39203
|
var makeIssue = (params) => {
|
|
38828
|
-
const { data, path:
|
|
38829
|
-
const fullPath = [...
|
|
39204
|
+
const { data, path: path22, errorMaps, issueData } = params;
|
|
39205
|
+
const fullPath = [...path22, ...issueData.path || []];
|
|
38830
39206
|
const fullIssue = {
|
|
38831
39207
|
...issueData,
|
|
38832
39208
|
path: fullPath
|
|
@@ -38942,11 +39318,11 @@ var errorUtil;
|
|
|
38942
39318
|
|
|
38943
39319
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
38944
39320
|
var ParseInputLazyPath = class {
|
|
38945
|
-
constructor(parent, value,
|
|
39321
|
+
constructor(parent, value, path22, key) {
|
|
38946
39322
|
this._cachedPath = [];
|
|
38947
39323
|
this.parent = parent;
|
|
38948
39324
|
this.data = value;
|
|
38949
|
-
this._path =
|
|
39325
|
+
this._path = path22;
|
|
38950
39326
|
this._key = key;
|
|
38951
39327
|
}
|
|
38952
39328
|
get path() {
|
|
@@ -42513,6 +42889,7 @@ var JoinTaskSchema = external_exports.object({
|
|
|
42513
42889
|
agent: external_exports.string(),
|
|
42514
42890
|
project: external_exports.string().nullable(),
|
|
42515
42891
|
effectiveProjectPath: external_exports.string().nullable(),
|
|
42892
|
+
conversationKind: external_exports.enum(["meshyChat", "nativeSession"]).optional(),
|
|
42516
42893
|
payload: external_exports.record(external_exports.unknown()),
|
|
42517
42894
|
status: external_exports.enum(["pending", "assigned", "running", "completed", "failed", "cancelled", "archived"]),
|
|
42518
42895
|
priority: external_exports.enum(["low", "normal", "high", "critical"]),
|
|
@@ -42611,6 +42988,13 @@ var GitRemoteBranchOptionSchema = external_exports.object({
|
|
|
42611
42988
|
branch: external_exports.string(),
|
|
42612
42989
|
ref: external_exports.string()
|
|
42613
42990
|
});
|
|
42991
|
+
var NativeSessionSummarySchema = external_exports.object({
|
|
42992
|
+
agent: external_exports.enum(["codex", "claudecode"]),
|
|
42993
|
+
sessionId: external_exports.string(),
|
|
42994
|
+
cwd: external_exports.string(),
|
|
42995
|
+
summary: external_exports.string(),
|
|
42996
|
+
updatedAt: external_exports.string().nullable()
|
|
42997
|
+
});
|
|
42614
42998
|
var NodeListQuery = external_exports.object({
|
|
42615
42999
|
status: external_exports.enum(["online", "busy", "offline"]).optional(),
|
|
42616
43000
|
capability: external_exports.string().optional()
|
|
@@ -42640,6 +43024,10 @@ var NodeWorkDirBranchQuery = external_exports.object({
|
|
|
42640
43024
|
offset: external_exports.coerce.number().int().min(0).default(0),
|
|
42641
43025
|
allowAbsolute: QueryBoolean
|
|
42642
43026
|
});
|
|
43027
|
+
var NodeNativeSessionsQuery = external_exports.object({
|
|
43028
|
+
agent: external_exports.enum(["codex", "claudecode"]),
|
|
43029
|
+
limit: external_exports.coerce.number().int().min(1).max(100).default(50)
|
|
43030
|
+
});
|
|
42643
43031
|
var NodeWorkDirTreeResponse = external_exports.object({
|
|
42644
43032
|
nodeId: external_exports.string(),
|
|
42645
43033
|
rootPath: external_exports.string(),
|
|
@@ -42676,6 +43064,11 @@ var CreateNodeWorkDirBranchBody = external_exports.object({
|
|
|
42676
43064
|
var CreateNodeWorkDirBranchResponse = NodeWorkDirBranchResponse.extend({
|
|
42677
43065
|
createdBranch: external_exports.string()
|
|
42678
43066
|
});
|
|
43067
|
+
var NodeNativeSessionsResponse = external_exports.object({
|
|
43068
|
+
nodeId: external_exports.string(),
|
|
43069
|
+
agent: external_exports.enum(["codex", "claudecode"]),
|
|
43070
|
+
sessions: external_exports.array(NativeSessionSummarySchema)
|
|
43071
|
+
});
|
|
42679
43072
|
var UpdateNodeBody = external_exports.object({
|
|
42680
43073
|
name: external_exports.string().min(1).optional(),
|
|
42681
43074
|
capabilities: external_exports.array(external_exports.string()).optional()
|
|
@@ -42683,7 +43076,9 @@ var UpdateNodeBody = external_exports.object({
|
|
|
42683
43076
|
|
|
42684
43077
|
// ../../packages/api/src/schemas/tasks.ts
|
|
42685
43078
|
var AGENT_OPTIONS = ["mars", "codex", "claudecode", "eureka"];
|
|
43079
|
+
var NATIVE_SESSION_AGENT_OPTIONS = ["codex", "claudecode"];
|
|
42686
43080
|
var TASK_MODE_OPTIONS = ["bypass", "plan", "edit", "dangerous"];
|
|
43081
|
+
var TASK_CONVERSATION_KIND_OPTIONS = ["meshyChat", "nativeSession"];
|
|
42687
43082
|
var TaskPayload = external_exports.record(external_exports.unknown()).superRefine((payload, ctx) => {
|
|
42688
43083
|
const mode = payload.mode;
|
|
42689
43084
|
if (mode !== void 0 && !TASK_MODE_OPTIONS.includes(mode)) {
|
|
@@ -42720,6 +43115,7 @@ var TaskListResponse = external_exports.object({
|
|
|
42720
43115
|
project: external_exports.string().nullable(),
|
|
42721
43116
|
effectiveProjectPath: external_exports.string().nullable(),
|
|
42722
43117
|
branch: external_exports.string().nullable().optional(),
|
|
43118
|
+
conversationKind: external_exports.enum(TASK_CONVERSATION_KIND_OPTIONS).optional(),
|
|
42723
43119
|
payload: external_exports.record(external_exports.unknown()),
|
|
42724
43120
|
status: external_exports.enum(["pending", "assigned", "running", "completed", "failed", "cancelled", "archived"]),
|
|
42725
43121
|
priority: external_exports.enum(["low", "normal", "high", "critical"]),
|
|
@@ -42750,6 +43146,7 @@ var AssignTaskBody = external_exports.object({
|
|
|
42750
43146
|
nodeId: external_exports.string().min(1)
|
|
42751
43147
|
});
|
|
42752
43148
|
var TaskResponse = TaskListResponse.shape.tasks.element;
|
|
43149
|
+
var TaskLogEvent = external_exports.record(external_exports.unknown());
|
|
42753
43150
|
var TaskMessageTextPart = external_exports.object({
|
|
42754
43151
|
type: external_exports.literal("text"),
|
|
42755
43152
|
text: external_exports.string().trim().min(1)
|
|
@@ -42782,6 +43179,19 @@ var SendMessageBody = external_exports.union([
|
|
|
42782
43179
|
content: [{ type: "text", text: value.message }]
|
|
42783
43180
|
}))
|
|
42784
43181
|
]);
|
|
43182
|
+
var AttachNativeSessionBody = external_exports.object({
|
|
43183
|
+
title: external_exports.string().trim().min(1).max(120).optional(),
|
|
43184
|
+
agent: external_exports.enum(NATIVE_SESSION_AGENT_OPTIONS),
|
|
43185
|
+
sessionId: external_exports.string().trim().min(1),
|
|
43186
|
+
cwd: external_exports.string().trim().min(1),
|
|
43187
|
+
assignTo: external_exports.string().min(1).optional(),
|
|
43188
|
+
priority: external_exports.enum(["low", "normal", "high", "critical"]).default("normal"),
|
|
43189
|
+
mode: external_exports.enum(TASK_MODE_OPTIONS).optional()
|
|
43190
|
+
});
|
|
43191
|
+
var WorkerImportTaskBody = external_exports.object({
|
|
43192
|
+
task: TaskResponse,
|
|
43193
|
+
logs: external_exports.array(TaskLogEvent).default([])
|
|
43194
|
+
});
|
|
42785
43195
|
var TaskLogsQuery = external_exports.object({
|
|
42786
43196
|
after: external_exports.coerce.number().int().min(0).optional()
|
|
42787
43197
|
});
|
|
@@ -42804,9 +43214,9 @@ var BatchTaskIdsBody = external_exports.object({
|
|
|
42804
43214
|
});
|
|
42805
43215
|
|
|
42806
43216
|
// ../../packages/api/src/app/server.ts
|
|
42807
|
-
var
|
|
42808
|
-
var
|
|
42809
|
-
var
|
|
43217
|
+
var path19 = __toESM(require("path"), 1);
|
|
43218
|
+
var fs18 = __toESM(require("fs"), 1);
|
|
43219
|
+
var import_express13 = __toESM(require_express2(), 1);
|
|
42810
43220
|
|
|
42811
43221
|
// ../../packages/api/src/middleware/auth.ts
|
|
42812
43222
|
var SKIP_AUTH_PATHS = ["/api/system/health"];
|
|
@@ -43231,7 +43641,7 @@ function createClusterControlRoutes() {
|
|
|
43231
43641
|
}
|
|
43232
43642
|
|
|
43233
43643
|
// ../../packages/api/src/routes/nodes.ts
|
|
43234
|
-
var
|
|
43644
|
+
var import_express5 = __toESM(require_express2(), 1);
|
|
43235
43645
|
|
|
43236
43646
|
// ../../packages/api/src/node/devtunnel-guard.ts
|
|
43237
43647
|
var BLOCKING_TASK_STATUSES = /* @__PURE__ */ new Set(["assigned", "running"]);
|
|
@@ -43257,11 +43667,11 @@ function assertCanChangeNodeDevTunnel(taskEngine, nodeId) {
|
|
|
43257
43667
|
var import_express3 = __toESM(require_express2(), 1);
|
|
43258
43668
|
|
|
43259
43669
|
// ../../packages/api/src/node/node-workdir-service.ts
|
|
43260
|
-
var
|
|
43670
|
+
var path16 = __toESM(require("path"), 1);
|
|
43261
43671
|
|
|
43262
43672
|
// ../../packages/api/src/output/helpers.ts
|
|
43263
|
-
var
|
|
43264
|
-
var
|
|
43673
|
+
var fs14 = __toESM(require("fs"), 1);
|
|
43674
|
+
var path15 = __toESM(require("path"), 1);
|
|
43265
43675
|
var MAX_INLINE_SIZE = 512 * 1024;
|
|
43266
43676
|
var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
43267
43677
|
".txt",
|
|
@@ -43374,15 +43784,15 @@ function mimeForExt(ext) {
|
|
|
43374
43784
|
return MIME_MAP[ext] ?? "application/octet-stream";
|
|
43375
43785
|
}
|
|
43376
43786
|
function resolveOutputPath(root, relativePath) {
|
|
43377
|
-
const resolved =
|
|
43378
|
-
const normalizedRoot =
|
|
43379
|
-
if (!resolved.startsWith(normalizedRoot +
|
|
43787
|
+
const resolved = path15.resolve(root, relativePath);
|
|
43788
|
+
const normalizedRoot = path15.resolve(root);
|
|
43789
|
+
if (!resolved.startsWith(normalizedRoot + path15.sep) && resolved !== normalizedRoot) {
|
|
43380
43790
|
throw new Error("Path traversal detected");
|
|
43381
43791
|
}
|
|
43382
43792
|
return resolved;
|
|
43383
43793
|
}
|
|
43384
43794
|
function classifyFile(filePath) {
|
|
43385
|
-
const ext =
|
|
43795
|
+
const ext = path15.extname(filePath).toLowerCase();
|
|
43386
43796
|
if (ext === ".json" || ext === ".jsonl" || ext === ".ndjson") {
|
|
43387
43797
|
return { kind: "json", mimeType: "application/json" };
|
|
43388
43798
|
}
|
|
@@ -43412,21 +43822,21 @@ function listDirectory(root, relativePath, options = {}) {
|
|
|
43412
43822
|
return listResolvedDirectory(absPath, relativePath, options);
|
|
43413
43823
|
}
|
|
43414
43824
|
function listAbsoluteDirectory(absoluteDir, options = {}) {
|
|
43415
|
-
if (!
|
|
43825
|
+
if (!path15.isAbsolute(absoluteDir)) {
|
|
43416
43826
|
throw new Error("listAbsoluteDirectory requires an absolute path");
|
|
43417
43827
|
}
|
|
43418
43828
|
return listResolvedDirectory(absoluteDir, absoluteDir, { ...options, childPathStyle: "absolute" });
|
|
43419
43829
|
}
|
|
43420
43830
|
function listResolvedDirectory(absPath, relativeBase, options = {}) {
|
|
43421
|
-
if (!
|
|
43831
|
+
if (!fs14.existsSync(absPath) || !fs14.statSync(absPath).isDirectory()) {
|
|
43422
43832
|
return [];
|
|
43423
43833
|
}
|
|
43424
|
-
const entries =
|
|
43834
|
+
const entries = fs14.readdirSync(absPath, { withFileTypes: true });
|
|
43425
43835
|
const result = [];
|
|
43426
43836
|
const childPathStyle = options.childPathStyle ?? "relative";
|
|
43427
43837
|
for (const entry of entries) {
|
|
43428
43838
|
if (entry.name.startsWith(".")) continue;
|
|
43429
|
-
const entryRelPath = childPathStyle === "absolute" ?
|
|
43839
|
+
const entryRelPath = childPathStyle === "absolute" ? path15.join(absPath, entry.name) : path15.join(relativeBase || ".", entry.name).split(path15.sep).join("/");
|
|
43430
43840
|
if (entry.isDirectory()) {
|
|
43431
43841
|
result.push({
|
|
43432
43842
|
path: entryRelPath,
|
|
@@ -43436,8 +43846,8 @@ function listResolvedDirectory(absPath, relativeBase, options = {}) {
|
|
|
43436
43846
|
} else if (options.directoriesOnly) {
|
|
43437
43847
|
continue;
|
|
43438
43848
|
} else if (entry.isFile()) {
|
|
43439
|
-
const fullPath =
|
|
43440
|
-
const stat =
|
|
43849
|
+
const fullPath = path15.join(absPath, entry.name);
|
|
43850
|
+
const stat = fs14.statSync(fullPath);
|
|
43441
43851
|
const { kind, mimeType } = classifyFile(entry.name);
|
|
43442
43852
|
result.push({
|
|
43443
43853
|
path: entryRelPath,
|
|
@@ -43457,11 +43867,11 @@ function listResolvedDirectory(absPath, relativeBase, options = {}) {
|
|
|
43457
43867
|
}
|
|
43458
43868
|
function detectHtmlEntries(root) {
|
|
43459
43869
|
const entries = [];
|
|
43460
|
-
if (
|
|
43870
|
+
if (fs14.existsSync(path15.join(root, "index.html"))) {
|
|
43461
43871
|
entries.push({ path: "index.html", label: "index.html" });
|
|
43462
43872
|
}
|
|
43463
43873
|
try {
|
|
43464
|
-
const topLevel =
|
|
43874
|
+
const topLevel = fs14.readdirSync(root, { withFileTypes: true });
|
|
43465
43875
|
const htmlFiles = topLevel.filter(
|
|
43466
43876
|
(e) => e.isFile() && e.name.endsWith(".html") && !e.name.startsWith(".")
|
|
43467
43877
|
);
|
|
@@ -43472,8 +43882,8 @@ function detectHtmlEntries(root) {
|
|
|
43472
43882
|
}
|
|
43473
43883
|
const subdirs = topLevel.filter((e) => e.isDirectory() && !e.name.startsWith("."));
|
|
43474
43884
|
for (const dir of subdirs) {
|
|
43475
|
-
const subIndex =
|
|
43476
|
-
if (
|
|
43885
|
+
const subIndex = path15.join(root, dir.name, "index.html");
|
|
43886
|
+
if (fs14.existsSync(subIndex)) {
|
|
43477
43887
|
entries.push({
|
|
43478
43888
|
path: `${dir.name}/index.html`,
|
|
43479
43889
|
label: `${dir.name}/index.html`
|
|
@@ -43485,11 +43895,11 @@ function detectHtmlEntries(root) {
|
|
|
43485
43895
|
return entries;
|
|
43486
43896
|
}
|
|
43487
43897
|
function getOutputSummary(root) {
|
|
43488
|
-
const rootName =
|
|
43898
|
+
const rootName = path15.basename(root);
|
|
43489
43899
|
const htmlEntries = detectHtmlEntries(root);
|
|
43490
43900
|
let fileCount;
|
|
43491
43901
|
try {
|
|
43492
|
-
const entries =
|
|
43902
|
+
const entries = fs14.readdirSync(root, { withFileTypes: true });
|
|
43493
43903
|
fileCount = entries.filter((e) => !e.name.startsWith(".")).length;
|
|
43494
43904
|
} catch {
|
|
43495
43905
|
fileCount = void 0;
|
|
@@ -43505,14 +43915,14 @@ function getOutputSummary(root) {
|
|
|
43505
43915
|
}
|
|
43506
43916
|
function readFileContent(root, relativePath) {
|
|
43507
43917
|
const absPath = resolveOutputPath(root, relativePath);
|
|
43508
|
-
if (!
|
|
43918
|
+
if (!fs14.existsSync(absPath) || !fs14.statSync(absPath).isFile()) {
|
|
43509
43919
|
throw new Error("File not found");
|
|
43510
43920
|
}
|
|
43511
|
-
const stat =
|
|
43921
|
+
const stat = fs14.statSync(absPath);
|
|
43512
43922
|
const { kind, mimeType } = classifyFile(absPath);
|
|
43513
43923
|
if (kind === "image" || kind === "pdf" || kind === "binary") {
|
|
43514
43924
|
const truncated2 = stat.size > MAX_INLINE_SIZE;
|
|
43515
|
-
const buffer = truncated2 ? Buffer.alloc(0) :
|
|
43925
|
+
const buffer = truncated2 ? Buffer.alloc(0) : fs14.readFileSync(absPath);
|
|
43516
43926
|
return {
|
|
43517
43927
|
path: relativePath,
|
|
43518
43928
|
kind,
|
|
@@ -43523,7 +43933,7 @@ function readFileContent(root, relativePath) {
|
|
|
43523
43933
|
};
|
|
43524
43934
|
}
|
|
43525
43935
|
const truncated = stat.size > MAX_INLINE_SIZE;
|
|
43526
|
-
const content = truncated ?
|
|
43936
|
+
const content = truncated ? fs14.readFileSync(absPath, "utf-8").slice(0, MAX_INLINE_SIZE) : fs14.readFileSync(absPath, "utf-8");
|
|
43527
43937
|
return {
|
|
43528
43938
|
path: relativePath,
|
|
43529
43939
|
kind,
|
|
@@ -43768,14 +44178,14 @@ function getGitDiff(dirPath) {
|
|
|
43768
44178
|
|
|
43769
44179
|
// ../../packages/api/src/node/node-workdir-service.ts
|
|
43770
44180
|
function isAbsolutePath(p) {
|
|
43771
|
-
return
|
|
44181
|
+
return path16.isAbsolute(p) || /^[A-Za-z]:[\\/]/.test(p);
|
|
43772
44182
|
}
|
|
43773
44183
|
function resolveNodeWorkDirTarget(nodeId, rootPath, currentPath, allowAbsolute) {
|
|
43774
44184
|
if (!rootPath) {
|
|
43775
44185
|
throw new MeshyError("VALIDATION_ERROR", `Node ${nodeId} does not expose a working directory`, 400);
|
|
43776
44186
|
}
|
|
43777
44187
|
const useAbsolute = allowAbsolute && isAbsolutePath(currentPath);
|
|
43778
|
-
const resolvedPath = useAbsolute ?
|
|
44188
|
+
const resolvedPath = useAbsolute ? path16.resolve(currentPath) : currentPath;
|
|
43779
44189
|
return {
|
|
43780
44190
|
rootPath,
|
|
43781
44191
|
resolvedPath,
|
|
@@ -43860,13 +44270,13 @@ function createLocalNodeWorkDirBranch(nodeId, rootPath, currentPath, options) {
|
|
|
43860
44270
|
}
|
|
43861
44271
|
function computeParentPath(rootPath, currentPath, useAbsolute) {
|
|
43862
44272
|
if (useAbsolute) {
|
|
43863
|
-
const parent =
|
|
44273
|
+
const parent = path16.dirname(currentPath);
|
|
43864
44274
|
return parent === currentPath ? null : parent;
|
|
43865
44275
|
}
|
|
43866
44276
|
const normalized = currentPath.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
43867
44277
|
if (normalized === "" || normalized === ".") {
|
|
43868
|
-
const absParent =
|
|
43869
|
-
return absParent ===
|
|
44278
|
+
const absParent = path16.dirname(path16.resolve(rootPath));
|
|
44279
|
+
return absParent === path16.resolve(rootPath) ? null : absParent;
|
|
43870
44280
|
}
|
|
43871
44281
|
const segments = normalized.split("/").filter(Boolean);
|
|
43872
44282
|
segments.pop();
|
|
@@ -43966,7 +44376,43 @@ function sendLocalNodeWorkDirBranchCreate(req, res, nodeId, options = {}) {
|
|
|
43966
44376
|
}
|
|
43967
44377
|
|
|
43968
44378
|
// ../../packages/api/src/tasks/task-route-utils.ts
|
|
43969
|
-
var
|
|
44379
|
+
var fs15 = __toESM(require("fs"), 1);
|
|
44380
|
+
|
|
44381
|
+
// ../../packages/api/src/node/node-message-compat.ts
|
|
44382
|
+
var LEGACY_KIND_BY_NODE_MESSAGE = {
|
|
44383
|
+
"node.workdir.tree": "node-workdir-tree",
|
|
44384
|
+
"node.workdir.branch-info": "node-workdir-branch-info",
|
|
44385
|
+
"node.workdir.branch-create": "node-workdir-branch-create",
|
|
44386
|
+
"node.sessions.list": "node-sessions-list",
|
|
44387
|
+
"node.transport.set": "devtunnel",
|
|
44388
|
+
"task.cancel": "task-cancel",
|
|
44389
|
+
"task.logs": "task-logs",
|
|
44390
|
+
"task.output.summary": "task-output-summary",
|
|
44391
|
+
"task.output.tree": "task-output-tree",
|
|
44392
|
+
"task.output.content": "task-output-content",
|
|
44393
|
+
"task.output.download": "task-output-download",
|
|
44394
|
+
"task.output.diff": "task-output-diff",
|
|
44395
|
+
"task.preview.create": "task-preview-session"
|
|
44396
|
+
};
|
|
44397
|
+
function canRequestNodeMessage(heartbeat) {
|
|
44398
|
+
return !!(heartbeat?.requestNodeMessage || heartbeat?.requestWorkerControl);
|
|
44399
|
+
}
|
|
44400
|
+
function requestFallbackNodeMessage(heartbeat, nodeId, message) {
|
|
44401
|
+
if (heartbeat.requestNodeMessage) return heartbeat.requestNodeMessage(nodeId, message);
|
|
44402
|
+
if (heartbeat.requestWorkerControl) return heartbeat.requestWorkerControl(nodeId, toLegacyWorkerControl2(message));
|
|
44403
|
+
throw new Error("Node message fallback is not available");
|
|
44404
|
+
}
|
|
44405
|
+
function toLegacyWorkerControl2(message) {
|
|
44406
|
+
return {
|
|
44407
|
+
...typeof message.payload === "object" && message.payload !== null ? message.payload : {},
|
|
44408
|
+
kind: LEGACY_KIND_BY_NODE_MESSAGE[message.kind] ?? message.kind
|
|
44409
|
+
};
|
|
44410
|
+
}
|
|
44411
|
+
|
|
44412
|
+
// ../../packages/api/src/tasks/task-route-utils.ts
|
|
44413
|
+
function isRecord4(value) {
|
|
44414
|
+
return typeof value === "object" && value !== null;
|
|
44415
|
+
}
|
|
43970
44416
|
function restoreTaskState(taskEngine, task) {
|
|
43971
44417
|
taskEngine.updateTask(task.id, {
|
|
43972
44418
|
status: task.status,
|
|
@@ -43981,10 +44427,10 @@ function readLocalTaskLogs(engineRegistry, taskId, after, agent) {
|
|
|
43981
44427
|
throw new MeshyError("VALIDATION_ERROR", `Engine not registered for agent: ${agent}`, 400);
|
|
43982
44428
|
}
|
|
43983
44429
|
const logPath = engine.getLogPath(taskId);
|
|
43984
|
-
if (!
|
|
44430
|
+
if (!fs15.existsSync(logPath)) {
|
|
43985
44431
|
return { logs: [], total: 0 };
|
|
43986
44432
|
}
|
|
43987
|
-
const content =
|
|
44433
|
+
const content = fs15.readFileSync(logPath, "utf-8");
|
|
43988
44434
|
const allLines = content.trim().split("\n").filter(Boolean);
|
|
43989
44435
|
const logs = [];
|
|
43990
44436
|
for (let i = after; i < allLines.length; i++) {
|
|
@@ -43995,6 +44441,169 @@ function readLocalTaskLogs(engineRegistry, taskId, after, agent) {
|
|
|
43995
44441
|
}
|
|
43996
44442
|
return { logs, total: allLines.length };
|
|
43997
44443
|
}
|
|
44444
|
+
function recordLocalTaskLogs(engineRegistry, task, logs) {
|
|
44445
|
+
if (logs.length === 0) {
|
|
44446
|
+
return;
|
|
44447
|
+
}
|
|
44448
|
+
const engine = engineRegistry.get(task.agent);
|
|
44449
|
+
if (!engine) {
|
|
44450
|
+
throw new MeshyError("VALIDATION_ERROR", `Engine not registered for agent: ${task.agent}`, 400);
|
|
44451
|
+
}
|
|
44452
|
+
for (const event of logs) {
|
|
44453
|
+
engine.recordOutput(task.id, event);
|
|
44454
|
+
}
|
|
44455
|
+
}
|
|
44456
|
+
function parseEventTimestamp(event) {
|
|
44457
|
+
if (typeof event.timestamp !== "string") {
|
|
44458
|
+
return null;
|
|
44459
|
+
}
|
|
44460
|
+
const parsed = Date.parse(event.timestamp);
|
|
44461
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
44462
|
+
}
|
|
44463
|
+
function getTaskUserMessageSignature(value) {
|
|
44464
|
+
const content = normalizeTaskUserMessageContent(value);
|
|
44465
|
+
if (content.length === 0) {
|
|
44466
|
+
return null;
|
|
44467
|
+
}
|
|
44468
|
+
return content.map((part) => {
|
|
44469
|
+
if (part.type === "text") return `t:${part.text}`;
|
|
44470
|
+
if (part.type === "tool_result") return `r:${part.toolUseId}:${part.isError === true ? "1" : "0"}:${part.content}`;
|
|
44471
|
+
const dataStart = part.data.slice(0, 32);
|
|
44472
|
+
const dataEnd = part.data.slice(-32);
|
|
44473
|
+
return `i:${part.mediaType}:${part.data.length}:${dataStart}:${dataEnd}`;
|
|
44474
|
+
}).join("|");
|
|
44475
|
+
}
|
|
44476
|
+
function normalizeStructuredValue(value) {
|
|
44477
|
+
if (Array.isArray(value)) {
|
|
44478
|
+
return value.map((entry) => normalizeStructuredValue(entry));
|
|
44479
|
+
}
|
|
44480
|
+
if (!isRecord4(value)) {
|
|
44481
|
+
return value;
|
|
44482
|
+
}
|
|
44483
|
+
return Object.fromEntries(
|
|
44484
|
+
Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)).map(([key, entryValue]) => [key, normalizeStructuredValue(entryValue)])
|
|
44485
|
+
);
|
|
44486
|
+
}
|
|
44487
|
+
function getTranscriptEventSignature(event) {
|
|
44488
|
+
if (event.type === "user") {
|
|
44489
|
+
const signature = getTaskUserMessageSignature(isRecord4(event.message) ? event.message.content : event.message) ?? getTaskUserMessageSignature(event.content);
|
|
44490
|
+
return signature ? `user:${signature}` : null;
|
|
44491
|
+
}
|
|
44492
|
+
if (event.type === "assistant") {
|
|
44493
|
+
if (typeof event.message === "string") {
|
|
44494
|
+
return `assistant:${JSON.stringify(event.message)}`;
|
|
44495
|
+
}
|
|
44496
|
+
if (isRecord4(event.message) && "content" in event.message) {
|
|
44497
|
+
return `assistant:${JSON.stringify(normalizeStructuredValue(event.message.content))}`;
|
|
44498
|
+
}
|
|
44499
|
+
if (Array.isArray(event.content)) {
|
|
44500
|
+
return `assistant:${JSON.stringify(normalizeStructuredValue(event.content))}`;
|
|
44501
|
+
}
|
|
44502
|
+
if (isRecord4(event.message)) {
|
|
44503
|
+
return `assistant:${JSON.stringify(normalizeStructuredValue(event.message))}`;
|
|
44504
|
+
}
|
|
44505
|
+
}
|
|
44506
|
+
return null;
|
|
44507
|
+
}
|
|
44508
|
+
function sortLogsChronologically(events) {
|
|
44509
|
+
return events.map((event, index) => ({ event, index })).sort((left, right) => {
|
|
44510
|
+
const leftTimestamp = parseEventTimestamp(left.event);
|
|
44511
|
+
const rightTimestamp = parseEventTimestamp(right.event);
|
|
44512
|
+
if (leftTimestamp !== null && rightTimestamp !== null && leftTimestamp !== rightTimestamp) {
|
|
44513
|
+
return leftTimestamp - rightTimestamp;
|
|
44514
|
+
}
|
|
44515
|
+
return left.index - right.index;
|
|
44516
|
+
}).map((entry) => entry.event);
|
|
44517
|
+
}
|
|
44518
|
+
function timestampsMatch(left, right) {
|
|
44519
|
+
const leftTimestamp = parseEventTimestamp(left);
|
|
44520
|
+
const rightTimestamp = parseEventTimestamp(right);
|
|
44521
|
+
if (leftTimestamp === null || rightTimestamp === null) {
|
|
44522
|
+
return true;
|
|
44523
|
+
}
|
|
44524
|
+
return Math.abs(leftTimestamp - rightTimestamp) <= 6e4;
|
|
44525
|
+
}
|
|
44526
|
+
function transcriptEvents(events) {
|
|
44527
|
+
return events.flatMap((event, index) => {
|
|
44528
|
+
const signature = getTranscriptEventSignature(event);
|
|
44529
|
+
return signature ? [{ index, event, signature }] : [];
|
|
44530
|
+
});
|
|
44531
|
+
}
|
|
44532
|
+
function findLocalTranscriptDuplicates(nativeLogs, localLogs) {
|
|
44533
|
+
const nativeTranscript = transcriptEvents(nativeLogs);
|
|
44534
|
+
const localTranscript = transcriptEvents(localLogs);
|
|
44535
|
+
if (nativeTranscript.length === 0 || localTranscript.length === 0) {
|
|
44536
|
+
return /* @__PURE__ */ new Set();
|
|
44537
|
+
}
|
|
44538
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
44539
|
+
for (const localEvent of localTranscript) {
|
|
44540
|
+
if (nativeTranscript.some((nativeEvent) => nativeEvent.signature === localEvent.signature && timestampsMatch(nativeEvent.event, localEvent.event))) {
|
|
44541
|
+
duplicates.add(localEvent.index);
|
|
44542
|
+
}
|
|
44543
|
+
}
|
|
44544
|
+
return duplicates;
|
|
44545
|
+
}
|
|
44546
|
+
function mergeNativeSessionLogs(nativeLogs, localLogs) {
|
|
44547
|
+
if (localLogs.length === 0) {
|
|
44548
|
+
return nativeLogs;
|
|
44549
|
+
}
|
|
44550
|
+
const duplicateLocalIndexes = findLocalTranscriptDuplicates(nativeLogs, localLogs);
|
|
44551
|
+
const retainedLocalLogs = localLogs.filter((_, index) => !duplicateLocalIndexes.has(index));
|
|
44552
|
+
if (retainedLocalLogs.length === 0) {
|
|
44553
|
+
return nativeLogs;
|
|
44554
|
+
}
|
|
44555
|
+
return sortLogsChronologically([...nativeLogs, ...retainedLocalLogs]);
|
|
44556
|
+
}
|
|
44557
|
+
function readLocalTaskLogsWithNativeHistory(engineRegistry, task, taskId, after, agent) {
|
|
44558
|
+
const local = readLocalTaskLogs(engineRegistry, taskId, after, agent);
|
|
44559
|
+
const sessionId = typeof task?.payload?.sessionId === "string" ? task.payload.sessionId : "";
|
|
44560
|
+
if (after > 0 || task?.conversationKind !== "nativeSession" || !sessionId || task.agent !== "codex" && task.agent !== "claudecode") {
|
|
44561
|
+
return local;
|
|
44562
|
+
}
|
|
44563
|
+
const history = loadNativeSessionHistory({ agent: task.agent, sessionId });
|
|
44564
|
+
if (history.logs.length === 0) {
|
|
44565
|
+
return local;
|
|
44566
|
+
}
|
|
44567
|
+
if (local.total > 0) {
|
|
44568
|
+
const logs = mergeNativeSessionLogs(history.logs, local.logs);
|
|
44569
|
+
return { logs, total: logs.length };
|
|
44570
|
+
}
|
|
44571
|
+
recordLocalTaskLogs(engineRegistry, task, history.logs);
|
|
44572
|
+
return readLocalTaskLogs(engineRegistry, taskId, after, agent);
|
|
44573
|
+
}
|
|
44574
|
+
async function seedTaskSnapshotOnWorker(task, logs, node, log2, timeoutMs = 1e4) {
|
|
44575
|
+
const proxyPath = "/api/worker/import-task";
|
|
44576
|
+
const { endpoint, response } = await fetchNodeWithFallback(
|
|
44577
|
+
node,
|
|
44578
|
+
proxyPath,
|
|
44579
|
+
{
|
|
44580
|
+
method: "POST",
|
|
44581
|
+
headers: { "Content-Type": "application/json" },
|
|
44582
|
+
body: JSON.stringify({ task, logs })
|
|
44583
|
+
},
|
|
44584
|
+
timeoutMs,
|
|
44585
|
+
void 0,
|
|
44586
|
+
{ preferPublicEndpoint: true }
|
|
44587
|
+
);
|
|
44588
|
+
if (!response.ok) {
|
|
44589
|
+
const failure = await response.text().catch(() => "");
|
|
44590
|
+
throw new MeshyError("NODE_OFFLINE", failure || `Failed to seed task on ${node.name} (${response.status})`, 502);
|
|
44591
|
+
}
|
|
44592
|
+
const body = await response.json().catch(() => null);
|
|
44593
|
+
const seededLogs = Array.isArray(body?.logs) ? body.logs : logs;
|
|
44594
|
+
log2.info("seeded task snapshot on worker", {
|
|
44595
|
+
taskId: task.id,
|
|
44596
|
+
assignedTo: node.id,
|
|
44597
|
+
endpoint,
|
|
44598
|
+
importedLogCount: seededLogs.length
|
|
44599
|
+
});
|
|
44600
|
+
return seededLogs;
|
|
44601
|
+
}
|
|
44602
|
+
async function requestTaskLogsOverKeepalive(heartbeat, nodeId, task, after) {
|
|
44603
|
+
if (!canRequestNodeMessage(heartbeat)) return null;
|
|
44604
|
+
const message = createNodeMessage("task.logs", { taskId: task.id, after, task }, { expectsResponse: true });
|
|
44605
|
+
return requestFallbackNodeMessage(heartbeat, nodeId, message);
|
|
44606
|
+
}
|
|
43998
44607
|
async function sendProxyResponse(res, proxyRes) {
|
|
43999
44608
|
const contentType = proxyRes.headers.get("content-type");
|
|
44000
44609
|
const contentDisposition = proxyRes.headers.get("content-disposition");
|
|
@@ -44005,6 +44614,43 @@ async function sendProxyResponse(res, proxyRes) {
|
|
|
44005
44614
|
if (cacheControl) res.setHeader("Cache-Control", cacheControl);
|
|
44006
44615
|
res.status(proxyRes.status).send(body);
|
|
44007
44616
|
}
|
|
44617
|
+
async function maybeProxyReadToLeader(req, res, options = {}) {
|
|
44618
|
+
const { dataRouter, nodeRegistry, logger: rootLogger } = req.app.locals.deps;
|
|
44619
|
+
const methods = new Set((options.methods ?? ["GET"]).map((method) => method.toUpperCase()));
|
|
44620
|
+
if (!methods.has(req.method.toUpperCase()) || nodeRegistry?.isLeader?.() !== false || !dataRouter?.proxyToLeader) {
|
|
44621
|
+
return false;
|
|
44622
|
+
}
|
|
44623
|
+
const leaderEndpoint = dataRouter.getLeaderEndpoint?.();
|
|
44624
|
+
if (!leaderEndpoint) {
|
|
44625
|
+
return false;
|
|
44626
|
+
}
|
|
44627
|
+
try {
|
|
44628
|
+
const result = await dataRouter.proxyToLeader(req);
|
|
44629
|
+
for (const [key, value] of Object.entries(result.headers)) {
|
|
44630
|
+
if (key.toLowerCase() === "content-length" || key.toLowerCase() === "transfer-encoding") continue;
|
|
44631
|
+
res.setHeader(key, value);
|
|
44632
|
+
}
|
|
44633
|
+
res.status(result.status).json(result.body);
|
|
44634
|
+
return true;
|
|
44635
|
+
} catch (error) {
|
|
44636
|
+
const log2 = rootLogger?.child?.("tasks/leader-read-proxy") ?? rootLogger;
|
|
44637
|
+
log2?.warn?.("leader read proxy failed", {
|
|
44638
|
+
path: req.originalUrl ?? req.url,
|
|
44639
|
+
leaderEndpoint,
|
|
44640
|
+
error: error instanceof Error ? error.message : String(error)
|
|
44641
|
+
});
|
|
44642
|
+
throw error instanceof MeshyError ? error : new MeshyError("NODE_OFFLINE", "Leader unreachable", 502);
|
|
44643
|
+
}
|
|
44644
|
+
}
|
|
44645
|
+
|
|
44646
|
+
// ../../packages/api/src/node/node-native-session-service.ts
|
|
44647
|
+
function getLocalNodeNativeSessions(nodeId, agent, limit) {
|
|
44648
|
+
return {
|
|
44649
|
+
nodeId,
|
|
44650
|
+
agent,
|
|
44651
|
+
sessions: listNativeSessions({ agent, limit })
|
|
44652
|
+
};
|
|
44653
|
+
}
|
|
44008
44654
|
|
|
44009
44655
|
// ../../packages/api/src/tasks/task-cancellation.ts
|
|
44010
44656
|
var TERMINAL_STATUSES2 = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "archived"]);
|
|
@@ -44066,29 +44712,29 @@ function cancelTaskOnCurrentNode(deps, taskId, options = {}) {
|
|
|
44066
44712
|
}
|
|
44067
44713
|
|
|
44068
44714
|
// ../../packages/api/src/tasks/task-output-service.ts
|
|
44069
|
-
var
|
|
44070
|
-
var
|
|
44715
|
+
var fs17 = __toESM(require("fs"), 1);
|
|
44716
|
+
var path18 = __toESM(require("path"), 1);
|
|
44071
44717
|
|
|
44072
44718
|
// ../../packages/api/src/preview/preview-server.ts
|
|
44073
44719
|
var crypto3 = __toESM(require("crypto"), 1);
|
|
44074
|
-
var
|
|
44075
|
-
var
|
|
44720
|
+
var fs16 = __toESM(require("fs"), 1);
|
|
44721
|
+
var path17 = __toESM(require("path"), 1);
|
|
44076
44722
|
var http2 = __toESM(require("http"), 1);
|
|
44077
44723
|
function resolvePreviewPath(rootPath, relativePath) {
|
|
44078
44724
|
const sanitizedPath = relativePath.replace(/\\/g, "/");
|
|
44079
|
-
const resolvedPath =
|
|
44080
|
-
const normalizedRoot =
|
|
44081
|
-
if (!resolvedPath.startsWith(normalizedRoot +
|
|
44725
|
+
const resolvedPath = path17.resolve(rootPath, sanitizedPath);
|
|
44726
|
+
const normalizedRoot = path17.resolve(rootPath);
|
|
44727
|
+
if (!resolvedPath.startsWith(normalizedRoot + path17.sep) && resolvedPath !== normalizedRoot) {
|
|
44082
44728
|
throw new Error("Invalid preview path");
|
|
44083
44729
|
}
|
|
44084
44730
|
return {
|
|
44085
44731
|
absolutePath: resolvedPath,
|
|
44086
|
-
normalizedPath:
|
|
44732
|
+
normalizedPath: path17.relative(normalizedRoot, resolvedPath).split(path17.sep).join("/")
|
|
44087
44733
|
};
|
|
44088
44734
|
}
|
|
44089
44735
|
function resolvePreviewEntryPath(rootPath, entryPath) {
|
|
44090
44736
|
const { absolutePath, normalizedPath } = resolvePreviewPath(rootPath, entryPath ?? "index.html");
|
|
44091
|
-
if (!
|
|
44737
|
+
if (!fs16.existsSync(absolutePath) || !fs16.statSync(absolutePath).isFile()) {
|
|
44092
44738
|
throw new Error("Preview entry not found");
|
|
44093
44739
|
}
|
|
44094
44740
|
return normalizedPath;
|
|
@@ -44152,7 +44798,7 @@ var MIME_MAP2 = {
|
|
|
44152
44798
|
".pdf": "application/pdf"
|
|
44153
44799
|
};
|
|
44154
44800
|
function getMime(filePath) {
|
|
44155
|
-
return MIME_MAP2[
|
|
44801
|
+
return MIME_MAP2[path17.extname(filePath).toLowerCase()] ?? "application/octet-stream";
|
|
44156
44802
|
}
|
|
44157
44803
|
function sendPreviewAssetResponse(sessionManager, token, requestedPath, res) {
|
|
44158
44804
|
const session = sessionManager.get(token);
|
|
@@ -44170,13 +44816,13 @@ function sendPreviewAssetResponse(sessionManager, token, requestedPath, res) {
|
|
|
44170
44816
|
res.end("Invalid path");
|
|
44171
44817
|
return;
|
|
44172
44818
|
}
|
|
44173
|
-
if (!
|
|
44819
|
+
if (!fs16.existsSync(resolved) || !fs16.statSync(resolved).isFile()) {
|
|
44174
44820
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
44175
44821
|
res.end("File not found");
|
|
44176
44822
|
return;
|
|
44177
44823
|
}
|
|
44178
44824
|
const mime = getMime(resolved);
|
|
44179
|
-
const content =
|
|
44825
|
+
const content = fs16.readFileSync(resolved);
|
|
44180
44826
|
res.writeHead(200, {
|
|
44181
44827
|
"Content-Type": mime,
|
|
44182
44828
|
"Content-Length": content.length,
|
|
@@ -44449,13 +45095,13 @@ function getLocalTaskOutputDownload(taskEngine, taskId, filePath) {
|
|
|
44449
45095
|
const rootPath = getTaskOutputRoot(taskEngine, taskId);
|
|
44450
45096
|
try {
|
|
44451
45097
|
const absolutePath = resolveOutputPath(rootPath, filePath);
|
|
44452
|
-
if (!
|
|
45098
|
+
if (!fs17.existsSync(absolutePath) || !fs17.statSync(absolutePath).isFile()) {
|
|
44453
45099
|
throw new MeshyError("TASK_NOT_FOUND", `File not found: ${filePath}`, 404);
|
|
44454
45100
|
}
|
|
44455
45101
|
const { mimeType } = classifyFile(absolutePath);
|
|
44456
|
-
const fileName =
|
|
45102
|
+
const fileName = path18.basename(absolutePath).replace(/"/g, "");
|
|
44457
45103
|
return {
|
|
44458
|
-
content:
|
|
45104
|
+
content: fs17.readFileSync(absolutePath),
|
|
44459
45105
|
headers: {
|
|
44460
45106
|
"Content-Type": mimeType,
|
|
44461
45107
|
"Content-Disposition": `inline; filename="${fileName}"`,
|
|
@@ -44541,6 +45187,12 @@ function payloadValue(request, key, fallback) {
|
|
|
44541
45187
|
const value = request.payload[key];
|
|
44542
45188
|
return value === void 0 ? fallback : value;
|
|
44543
45189
|
}
|
|
45190
|
+
function maybeImportTaskSnapshot(deps, request) {
|
|
45191
|
+
if (!request.kind.startsWith("task.output.") && request.kind !== "task.preview.create" && request.kind !== "task.logs") return;
|
|
45192
|
+
const task = payloadValue(request, "task", null);
|
|
45193
|
+
if (!task || deps.taskEngine.getTask(task.id)) return;
|
|
45194
|
+
deps.taskEngine.importTasks([task]);
|
|
45195
|
+
}
|
|
44544
45196
|
async function executeWorkerControlRequest(deps, request) {
|
|
44545
45197
|
const startedAt = Date.now();
|
|
44546
45198
|
const log2 = deps.logger.child("worker-control");
|
|
@@ -44553,6 +45205,7 @@ async function executeWorkerControlRequest(deps, request) {
|
|
|
44553
45205
|
});
|
|
44554
45206
|
try {
|
|
44555
45207
|
let response;
|
|
45208
|
+
maybeImportTaskSnapshot(deps, request);
|
|
44556
45209
|
switch (request.kind) {
|
|
44557
45210
|
case "node.workdir.tree": {
|
|
44558
45211
|
const self2 = deps.nodeRegistry.getSelf();
|
|
@@ -44611,6 +45264,19 @@ async function executeWorkerControlRequest(deps, request) {
|
|
|
44611
45264
|
);
|
|
44612
45265
|
break;
|
|
44613
45266
|
}
|
|
45267
|
+
case "node.sessions.list": {
|
|
45268
|
+
const self2 = deps.nodeRegistry.getSelf();
|
|
45269
|
+
response = jsonResponse(
|
|
45270
|
+
request.id,
|
|
45271
|
+
200,
|
|
45272
|
+
getLocalNodeNativeSessions(
|
|
45273
|
+
self2.id,
|
|
45274
|
+
payloadValue(request, "agent", "codex"),
|
|
45275
|
+
payloadValue(request, "limit", 50)
|
|
45276
|
+
)
|
|
45277
|
+
);
|
|
45278
|
+
break;
|
|
45279
|
+
}
|
|
44614
45280
|
case "node.transport.set": {
|
|
44615
45281
|
assertCanChangeNodeDevTunnel(deps.taskEngine, deps.nodeRegistry.getSelf().id);
|
|
44616
45282
|
if (payloadValue(request, "enabled", false)) {
|
|
@@ -44657,6 +45323,16 @@ async function executeWorkerControlRequest(deps, request) {
|
|
|
44657
45323
|
});
|
|
44658
45324
|
break;
|
|
44659
45325
|
}
|
|
45326
|
+
case "task.logs": {
|
|
45327
|
+
const taskId = payloadValue(request, "taskId", "");
|
|
45328
|
+
const task = deps.taskEngine.getTask(taskId);
|
|
45329
|
+
response = jsonResponse(
|
|
45330
|
+
request.id,
|
|
45331
|
+
200,
|
|
45332
|
+
readLocalTaskLogsWithNativeHistory(deps.engineRegistry, task, taskId, payloadValue(request, "after", 0), task?.agent ?? "claudecode")
|
|
45333
|
+
);
|
|
45334
|
+
break;
|
|
45335
|
+
}
|
|
44660
45336
|
case "task.output.summary": {
|
|
44661
45337
|
response = jsonResponse(
|
|
44662
45338
|
request.id,
|
|
@@ -44758,38 +45434,22 @@ function sendWorkerControlResponse(res, response) {
|
|
|
44758
45434
|
res.status(response.statusCode).send(response.body);
|
|
44759
45435
|
}
|
|
44760
45436
|
|
|
44761
|
-
// ../../packages/api/src/
|
|
44762
|
-
var
|
|
44763
|
-
|
|
44764
|
-
|
|
44765
|
-
|
|
44766
|
-
|
|
44767
|
-
|
|
44768
|
-
|
|
44769
|
-
|
|
44770
|
-
|
|
44771
|
-
"task.output.download": "task-output-download",
|
|
44772
|
-
"task.output.diff": "task-output-diff",
|
|
44773
|
-
"task.preview.create": "task-preview-session"
|
|
44774
|
-
};
|
|
44775
|
-
function canRequestNodeMessage(heartbeat) {
|
|
44776
|
-
return !!(heartbeat?.requestNodeMessage || heartbeat?.requestWorkerControl);
|
|
44777
|
-
}
|
|
44778
|
-
function requestFallbackNodeMessage(heartbeat, nodeId, message) {
|
|
44779
|
-
if (heartbeat.requestNodeMessage) return heartbeat.requestNodeMessage(nodeId, message);
|
|
44780
|
-
if (heartbeat.requestWorkerControl) return heartbeat.requestWorkerControl(nodeId, toLegacyWorkerControl2(message));
|
|
44781
|
-
throw new Error("Node message fallback is not available");
|
|
44782
|
-
}
|
|
44783
|
-
function toLegacyWorkerControl2(message) {
|
|
44784
|
-
return {
|
|
44785
|
-
...typeof message.payload === "object" && message.payload !== null ? message.payload : {},
|
|
44786
|
-
kind: LEGACY_KIND_BY_NODE_MESSAGE[message.kind] ?? message.kind
|
|
44787
|
-
};
|
|
45437
|
+
// ../../packages/api/src/routes/node-native-sessions.ts
|
|
45438
|
+
var import_express4 = __toESM(require_express2(), 1);
|
|
45439
|
+
function sendLocalNodeNativeSessions(req, res, nodeId, options = {}) {
|
|
45440
|
+
const query = NodeNativeSessionsQuery.parse(req.query);
|
|
45441
|
+
const { nodeRegistry } = req.app.locals.deps;
|
|
45442
|
+
const self2 = nodeRegistry.getSelf();
|
|
45443
|
+
if (options.requireSelfNode && nodeId !== self2.id) {
|
|
45444
|
+
throw new MeshyError("NODE_NOT_FOUND", `Node ${nodeId} not found`, 404);
|
|
45445
|
+
}
|
|
45446
|
+
res.json(getLocalNodeNativeSessions(self2.id, query.agent, query.limit));
|
|
44788
45447
|
}
|
|
44789
45448
|
|
|
44790
45449
|
// ../../packages/api/src/routes/nodes.ts
|
|
44791
45450
|
var NODE_WORKDIR_PROXY_TIMEOUT_MS = 1e4;
|
|
44792
45451
|
var NODE_WORKDIR_BRANCH_PROXY_TIMEOUT_MS = 25e3;
|
|
45452
|
+
var NODE_NATIVE_SESSIONS_PROXY_TIMEOUT_MS = 1e4;
|
|
44793
45453
|
function describeProxyError2(error) {
|
|
44794
45454
|
if (error instanceof Error) {
|
|
44795
45455
|
const errorCategory = error.name === "AbortError" || /aborted/i.test(error.message) ? "abort" : /timeout/i.test(error.message) ? "timeout" : "network";
|
|
@@ -45053,8 +45713,73 @@ async function maybeHandleRemoteNodeWorkDirBranchCreateRequest(req, res, nodeId)
|
|
|
45053
45713
|
throw new MeshyError("NODE_OFFLINE", `Cannot reach node ${nodeId} to create a git branch`, 502);
|
|
45054
45714
|
}
|
|
45055
45715
|
}
|
|
45716
|
+
async function maybeHandleRemoteNodeNativeSessionsRequest(req, res, nodeId) {
|
|
45717
|
+
const query = NodeNativeSessionsQuery.parse(req.query);
|
|
45718
|
+
const { nodeRegistry, heartbeat, logger: rootLogger } = req.app.locals.deps;
|
|
45719
|
+
const selfId = nodeRegistry.getSelf().id;
|
|
45720
|
+
if (nodeId === selfId) {
|
|
45721
|
+
return false;
|
|
45722
|
+
}
|
|
45723
|
+
const node = nodeRegistry.getNode(nodeId);
|
|
45724
|
+
if (!node) {
|
|
45725
|
+
throw new MeshyError("NODE_NOT_FOUND", `Node ${nodeId} not found`, 404);
|
|
45726
|
+
}
|
|
45727
|
+
const log2 = rootLogger.child("nodes/native-sessions");
|
|
45728
|
+
const proxyPath = req.originalUrl ?? `/api/nodes/${nodeId}/native-sessions`;
|
|
45729
|
+
const fallbackRequest = createNodeMessage("node.sessions.list", {
|
|
45730
|
+
agent: query.agent,
|
|
45731
|
+
limit: query.limit
|
|
45732
|
+
}, { expectsResponse: true });
|
|
45733
|
+
const canPushToNode = heartbeat?.canPushToNode?.(nodeId) ?? true;
|
|
45734
|
+
if (!canPushToNode && canRequestNodeMessage(heartbeat)) {
|
|
45735
|
+
log2.warn("node native sessions request falling back to keepalive control", {
|
|
45736
|
+
nodeId,
|
|
45737
|
+
proxyPath
|
|
45738
|
+
});
|
|
45739
|
+
const controlResponse = await requestFallbackNodeMessage(heartbeat, nodeId, fallbackRequest);
|
|
45740
|
+
sendWorkerControlResponse(res, controlResponse);
|
|
45741
|
+
return true;
|
|
45742
|
+
}
|
|
45743
|
+
try {
|
|
45744
|
+
const { endpoint, response } = await fetchNodeWithFallback(
|
|
45745
|
+
node,
|
|
45746
|
+
proxyPath,
|
|
45747
|
+
void 0,
|
|
45748
|
+
NODE_NATIVE_SESSIONS_PROXY_TIMEOUT_MS,
|
|
45749
|
+
createNodeWorkdirProxyTrace(log2, nodeId, proxyPath),
|
|
45750
|
+
{ preferPublicEndpoint: true }
|
|
45751
|
+
);
|
|
45752
|
+
log2.debug("proxying node native sessions request", {
|
|
45753
|
+
nodeId,
|
|
45754
|
+
endpoint,
|
|
45755
|
+
proxyPath
|
|
45756
|
+
});
|
|
45757
|
+
await sendProxyResponse(res, response);
|
|
45758
|
+
return true;
|
|
45759
|
+
} catch (err) {
|
|
45760
|
+
const errorDetails = describeProxyError2(err);
|
|
45761
|
+
log2.warn("node native sessions proxy error", {
|
|
45762
|
+
nodeId,
|
|
45763
|
+
proxyPath,
|
|
45764
|
+
timeoutMs: NODE_NATIVE_SESSIONS_PROXY_TIMEOUT_MS,
|
|
45765
|
+
...errorDetails
|
|
45766
|
+
});
|
|
45767
|
+
if (canRequestNodeMessage(heartbeat)) {
|
|
45768
|
+
log2.warn("node native sessions proxy failed, falling back to keepalive control", {
|
|
45769
|
+
nodeId,
|
|
45770
|
+
proxyPath,
|
|
45771
|
+
timeoutMs: NODE_NATIVE_SESSIONS_PROXY_TIMEOUT_MS,
|
|
45772
|
+
...errorDetails
|
|
45773
|
+
});
|
|
45774
|
+
const controlResponse = await requestFallbackNodeMessage(heartbeat, nodeId, fallbackRequest);
|
|
45775
|
+
sendWorkerControlResponse(res, controlResponse);
|
|
45776
|
+
return true;
|
|
45777
|
+
}
|
|
45778
|
+
throw new MeshyError("NODE_OFFLINE", `Cannot reach node ${nodeId} to list its native sessions`, 502);
|
|
45779
|
+
}
|
|
45780
|
+
}
|
|
45056
45781
|
function createNodeRoutes() {
|
|
45057
|
-
const router = (0,
|
|
45782
|
+
const router = (0, import_express5.Router)();
|
|
45058
45783
|
router.get("/", asyncHandler3(async (req, res) => {
|
|
45059
45784
|
const { nodeRegistry } = req.app.locals.deps;
|
|
45060
45785
|
const query = NodeListQuery.parse(req.query);
|
|
@@ -45092,6 +45817,14 @@ function createNodeRoutes() {
|
|
|
45092
45817
|
}));
|
|
45093
45818
|
res.json({ node, tasks: taskSummary });
|
|
45094
45819
|
}));
|
|
45820
|
+
router.get("/:id/native-sessions", asyncHandler3(async (req, res) => {
|
|
45821
|
+
const nodeId = req.params.id;
|
|
45822
|
+
const handled = await maybeHandleRemoteNodeNativeSessionsRequest(req, res, nodeId);
|
|
45823
|
+
if (handled) {
|
|
45824
|
+
return;
|
|
45825
|
+
}
|
|
45826
|
+
sendLocalNodeNativeSessions(req, res, nodeId);
|
|
45827
|
+
}));
|
|
45095
45828
|
router.get("/:id/workdir/tree", asyncHandler3(async (req, res) => {
|
|
45096
45829
|
const nodeId = req.params.id;
|
|
45097
45830
|
const handled = await maybeHandleRemoteNodeWorkDirRequest(req, res, nodeId);
|
|
@@ -45249,12 +45982,12 @@ function createNodeRoutes() {
|
|
|
45249
45982
|
}
|
|
45250
45983
|
|
|
45251
45984
|
// ../../packages/api/src/routes/node-messages.ts
|
|
45252
|
-
var
|
|
45985
|
+
var import_express6 = __toESM(require_express2(), 1);
|
|
45253
45986
|
function asyncHandler4(fn) {
|
|
45254
45987
|
return (req, res, next) => fn(req, res, next).catch(next);
|
|
45255
45988
|
}
|
|
45256
45989
|
function createNodeMessageRoutes() {
|
|
45257
|
-
const router = (0,
|
|
45990
|
+
const router = (0, import_express6.Router)();
|
|
45258
45991
|
router.post("/messages", asyncHandler4(async (req, res) => {
|
|
45259
45992
|
const response = await handleNodeMessage(req.app.locals.deps, req.body);
|
|
45260
45993
|
if (response) {
|
|
@@ -45334,7 +46067,7 @@ async function handleTaskMessage(deps, message) {
|
|
|
45334
46067
|
}
|
|
45335
46068
|
|
|
45336
46069
|
// ../../packages/api/src/routes/tasks.ts
|
|
45337
|
-
var
|
|
46070
|
+
var import_express8 = __toESM(require_express2(), 1);
|
|
45338
46071
|
|
|
45339
46072
|
// ../../packages/api/src/tasks/task-remote-cancellation.ts
|
|
45340
46073
|
async function cancelRemoteTaskExecution(deps) {
|
|
@@ -45403,8 +46136,306 @@ function startLocalTaskFollowUp(deps, task, content, assignedTo, metadata) {
|
|
|
45403
46136
|
}
|
|
45404
46137
|
}
|
|
45405
46138
|
|
|
46139
|
+
// ../../packages/api/src/tasks/task-session-import.ts
|
|
46140
|
+
var TASK_IMPORT_PROXY_TIMEOUT_MS = 1e4;
|
|
46141
|
+
function buildImportedSessionTitle(agent, sessionId) {
|
|
46142
|
+
const label = agent === "codex" ? "Codex" : "Claude Code";
|
|
46143
|
+
const suffix = sessionId.trim().slice(0, 12);
|
|
46144
|
+
return `${label} session ${suffix || "attached"}`;
|
|
46145
|
+
}
|
|
46146
|
+
function resolveTargetImportNode(nodeRegistry, nodeId, agent) {
|
|
46147
|
+
const self2 = nodeRegistry.getSelf();
|
|
46148
|
+
const node = nodeRegistry.getNode(nodeId) ?? (self2?.id === nodeId ? self2 : null);
|
|
46149
|
+
if (!node) {
|
|
46150
|
+
throw new MeshyError("NODE_NOT_FOUND", `Node ${nodeId} not found`, 404);
|
|
46151
|
+
}
|
|
46152
|
+
if (node.status === "offline") {
|
|
46153
|
+
throw new MeshyError("NODE_OFFLINE", `Node ${node.name} is offline`, 400);
|
|
46154
|
+
}
|
|
46155
|
+
if (node.supportedAgents && node.supportedAgents.length > 0 && !node.supportedAgents.includes(agent)) {
|
|
46156
|
+
throw new MeshyError("VALIDATION_ERROR", `Node ${node.name} does not support agent ${agent}`, 400);
|
|
46157
|
+
}
|
|
46158
|
+
return node;
|
|
46159
|
+
}
|
|
46160
|
+
async function attachNativeSession(deps, body) {
|
|
46161
|
+
const log2 = deps.logger.child("tasks/import-session");
|
|
46162
|
+
const selfId = deps.nodeRegistry.getSelf()?.id;
|
|
46163
|
+
const targetNodeId = body.assignTo ?? selfId;
|
|
46164
|
+
if (!targetNodeId) {
|
|
46165
|
+
throw new MeshyError("VALIDATION_ERROR", "No target node is available for session import", 400);
|
|
46166
|
+
}
|
|
46167
|
+
const targetNode = resolveTargetImportNode(deps.nodeRegistry, targetNodeId, body.agent);
|
|
46168
|
+
const history = loadNativeSessionHistory({
|
|
46169
|
+
agent: body.agent,
|
|
46170
|
+
sessionId: body.sessionId
|
|
46171
|
+
});
|
|
46172
|
+
let importedLogs = history.logs;
|
|
46173
|
+
const task = deps.taskEngine.createTask({
|
|
46174
|
+
title: body.title?.trim() || buildImportedSessionTitle(body.agent, body.sessionId),
|
|
46175
|
+
description: `Attached native ${body.agent === "codex" ? "Codex" : "Claude Code"} session`,
|
|
46176
|
+
agent: body.agent,
|
|
46177
|
+
project: body.cwd,
|
|
46178
|
+
conversationKind: "nativeSession",
|
|
46179
|
+
payload: {
|
|
46180
|
+
sessionId: body.sessionId,
|
|
46181
|
+
sessionCwd: body.cwd,
|
|
46182
|
+
...body.mode ? { mode: body.mode } : {}
|
|
46183
|
+
},
|
|
46184
|
+
priority: body.priority,
|
|
46185
|
+
createdBy: "api"
|
|
46186
|
+
});
|
|
46187
|
+
const importedTask = deps.taskEngine.updateTask(task.id, {
|
|
46188
|
+
status: "completed",
|
|
46189
|
+
assignedTo: targetNode.id,
|
|
46190
|
+
assignedNodeName: targetNode.name,
|
|
46191
|
+
effectiveProjectPath: body.cwd
|
|
46192
|
+
});
|
|
46193
|
+
if (!importedTask) {
|
|
46194
|
+
deps.taskEngine.deleteTask(task.id);
|
|
46195
|
+
throw new MeshyError("TASK_NOT_FOUND", `Task ${task.id} not found after session import`, 500);
|
|
46196
|
+
}
|
|
46197
|
+
try {
|
|
46198
|
+
if (targetNode.id !== selfId) {
|
|
46199
|
+
importedLogs = await seedTaskSnapshotOnWorker(importedTask, importedLogs, targetNode, log2, TASK_IMPORT_PROXY_TIMEOUT_MS);
|
|
46200
|
+
}
|
|
46201
|
+
} catch (error) {
|
|
46202
|
+
deps.taskEngine.deleteTask(task.id);
|
|
46203
|
+
throw error;
|
|
46204
|
+
}
|
|
46205
|
+
if (importedLogs.length > 0) {
|
|
46206
|
+
try {
|
|
46207
|
+
recordLocalTaskLogs(deps.engineRegistry, importedTask, importedLogs);
|
|
46208
|
+
log2.info("imported native session history into local task logs", {
|
|
46209
|
+
taskId: importedTask.id,
|
|
46210
|
+
assignedTo: importedTask.assignedTo,
|
|
46211
|
+
importedLogCount: importedLogs.length,
|
|
46212
|
+
sourcePath: history.sourcePath
|
|
46213
|
+
});
|
|
46214
|
+
} catch (error) {
|
|
46215
|
+
log2.warn("failed to mirror imported native session history locally", {
|
|
46216
|
+
taskId: importedTask.id,
|
|
46217
|
+
assignedTo: importedTask.assignedTo,
|
|
46218
|
+
importedLogCount: importedLogs.length,
|
|
46219
|
+
sourcePath: history.sourcePath,
|
|
46220
|
+
error: error instanceof Error ? error.message : String(error)
|
|
46221
|
+
});
|
|
46222
|
+
}
|
|
46223
|
+
} else {
|
|
46224
|
+
log2.info("no native session history found to import", {
|
|
46225
|
+
taskId: importedTask.id,
|
|
46226
|
+
assignedTo: importedTask.assignedTo,
|
|
46227
|
+
sessionId: body.sessionId,
|
|
46228
|
+
sourcePath: history.sourcePath
|
|
46229
|
+
});
|
|
46230
|
+
}
|
|
46231
|
+
return importedTask;
|
|
46232
|
+
}
|
|
46233
|
+
|
|
46234
|
+
// ../../packages/api/src/tasks/task-log-proxy.ts
|
|
46235
|
+
var TASK_LOG_PROXY_PURPOSE_HEADER = "x-meshy-proxy-purpose";
|
|
46236
|
+
var TASK_LOG_PROXY_SOURCE_HEADER = "x-meshy-proxy-source-node";
|
|
46237
|
+
var TASK_LOG_PROXY_TASK_HEADER = "x-meshy-task-snapshot";
|
|
46238
|
+
var TASK_LOG_PROXY_PURPOSE = "task-logs";
|
|
46239
|
+
function encodeTaskSnapshot(task) {
|
|
46240
|
+
return Buffer.from(JSON.stringify(task), "utf8").toString("base64url");
|
|
46241
|
+
}
|
|
46242
|
+
function decodeTaskSnapshot(value) {
|
|
46243
|
+
if (!value) return void 0;
|
|
46244
|
+
try {
|
|
46245
|
+
const task = JSON.parse(Buffer.from(value, "base64url").toString("utf8"));
|
|
46246
|
+
return typeof task?.id === "string" ? task : void 0;
|
|
46247
|
+
} catch {
|
|
46248
|
+
return void 0;
|
|
46249
|
+
}
|
|
46250
|
+
}
|
|
46251
|
+
function createTaskLogsProxyHeaders(sourceNodeId, task) {
|
|
46252
|
+
return {
|
|
46253
|
+
[TASK_LOG_PROXY_PURPOSE_HEADER]: TASK_LOG_PROXY_PURPOSE,
|
|
46254
|
+
[TASK_LOG_PROXY_TASK_HEADER]: encodeTaskSnapshot(task),
|
|
46255
|
+
...sourceNodeId ? { [TASK_LOG_PROXY_SOURCE_HEADER]: sourceNodeId } : {}
|
|
46256
|
+
};
|
|
46257
|
+
}
|
|
46258
|
+
function getTaskLogsProxyRequestMetadata(req) {
|
|
46259
|
+
const purpose = req.get(TASK_LOG_PROXY_PURPOSE_HEADER);
|
|
46260
|
+
const sourceNodeId = req.get(TASK_LOG_PROXY_SOURCE_HEADER) ?? void 0;
|
|
46261
|
+
return { isProxy: purpose === TASK_LOG_PROXY_PURPOSE, sourceNodeId, task: decodeTaskSnapshot(req.get(TASK_LOG_PROXY_TASK_HEADER)) };
|
|
46262
|
+
}
|
|
46263
|
+
function describeProxyError3(error) {
|
|
46264
|
+
if (error instanceof Error) {
|
|
46265
|
+
const errorCategory = error.name === "AbortError" || /aborted/i.test(error.message) ? "abort" : /timeout/i.test(error.message) ? "timeout" : "network";
|
|
46266
|
+
return {
|
|
46267
|
+
errorName: error.name,
|
|
46268
|
+
errorMessage: error.message,
|
|
46269
|
+
errorCategory
|
|
46270
|
+
};
|
|
46271
|
+
}
|
|
46272
|
+
return {
|
|
46273
|
+
errorName: "UnknownError",
|
|
46274
|
+
errorMessage: String(error),
|
|
46275
|
+
errorCategory: "unknown"
|
|
46276
|
+
};
|
|
46277
|
+
}
|
|
46278
|
+
function createTaskLogsProxyTrace(log2, taskId, nodeId, proxyPath) {
|
|
46279
|
+
return {
|
|
46280
|
+
onAttempt: ({ attempt, endpoint, timeoutMs, totalEndpoints }) => {
|
|
46281
|
+
log2.debug("task logs proxy attempt", { taskId, nodeId, proxyPath, endpoint, attempt, totalEndpoints, timeoutMs });
|
|
46282
|
+
},
|
|
46283
|
+
onResponse: ({ attempt, endpoint, response, timeoutMs, totalEndpoints }) => {
|
|
46284
|
+
log2.info("task logs proxy response", {
|
|
46285
|
+
taskId,
|
|
46286
|
+
nodeId,
|
|
46287
|
+
proxyPath,
|
|
46288
|
+
endpoint,
|
|
46289
|
+
attempt,
|
|
46290
|
+
totalEndpoints,
|
|
46291
|
+
timeoutMs,
|
|
46292
|
+
ok: response.ok,
|
|
46293
|
+
statusCode: response.status
|
|
46294
|
+
});
|
|
46295
|
+
},
|
|
46296
|
+
onError: ({ attempt, endpoint, error, timeoutMs, totalEndpoints }) => {
|
|
46297
|
+
log2.warn("task logs proxy attempt failed", {
|
|
46298
|
+
taskId,
|
|
46299
|
+
nodeId,
|
|
46300
|
+
proxyPath,
|
|
46301
|
+
endpoint,
|
|
46302
|
+
attempt,
|
|
46303
|
+
totalEndpoints,
|
|
46304
|
+
timeoutMs,
|
|
46305
|
+
...describeProxyError3(error)
|
|
46306
|
+
});
|
|
46307
|
+
}
|
|
46308
|
+
};
|
|
46309
|
+
}
|
|
46310
|
+
|
|
46311
|
+
// ../../packages/api/src/tasks/task-log-response.ts
|
|
46312
|
+
var TASK_LOG_PROXY_TIMEOUT_MS = 1e4;
|
|
46313
|
+
async function sendTaskLogsResponse(req, res, taskId) {
|
|
46314
|
+
const { engineRegistry, taskEngine, nodeRegistry, heartbeat, logger: rootLogger } = req.app.locals.deps;
|
|
46315
|
+
const log2 = rootLogger.child("tasks/logs");
|
|
46316
|
+
const query = TaskLogsQuery.parse(req.query);
|
|
46317
|
+
const after = query.after ?? 0;
|
|
46318
|
+
const proxyRequest = getTaskLogsProxyRequestMetadata(req);
|
|
46319
|
+
let task = taskEngine.getTask(taskId);
|
|
46320
|
+
if (!task && proxyRequest.task?.id === taskId) {
|
|
46321
|
+
taskEngine.importTasks([proxyRequest.task]);
|
|
46322
|
+
task = taskEngine.getTask(taskId) ?? proxyRequest.task;
|
|
46323
|
+
log2.info("imported task snapshot from proxied task logs request", {
|
|
46324
|
+
taskId,
|
|
46325
|
+
assignedTo: task.assignedTo,
|
|
46326
|
+
sourceNodeId: proxyRequest.sourceNodeId
|
|
46327
|
+
});
|
|
46328
|
+
}
|
|
46329
|
+
if (!task && !proxyRequest.isProxy && await maybeProxyReadToLeader(req, res)) return;
|
|
46330
|
+
const selfId = nodeRegistry.getSelf()?.id;
|
|
46331
|
+
const isLeader = nodeRegistry.isLeader();
|
|
46332
|
+
const isFollowerRemoteTask = !isLeader && !!(task?.assignedTo && task.assignedTo !== selfId);
|
|
46333
|
+
const needsProxy = isLeader && !!(task?.assignedTo && task.assignedTo !== selfId);
|
|
46334
|
+
if (proxyRequest.isProxy) {
|
|
46335
|
+
log2.info("received proxied task logs request", {
|
|
46336
|
+
taskId,
|
|
46337
|
+
after,
|
|
46338
|
+
taskFound: !!task,
|
|
46339
|
+
assignedTo: task?.assignedTo,
|
|
46340
|
+
selfId,
|
|
46341
|
+
isLeader,
|
|
46342
|
+
sourceNodeId: proxyRequest.sourceNodeId,
|
|
46343
|
+
forwardedHost: req.get("x-forwarded-host"),
|
|
46344
|
+
forwardedFor: req.get("x-forwarded-for")
|
|
46345
|
+
});
|
|
46346
|
+
}
|
|
46347
|
+
if (!task) throw new MeshyError("TASK_NOT_FOUND", `Task ${taskId} not found`, 404);
|
|
46348
|
+
log2.debug("log request", {
|
|
46349
|
+
taskId,
|
|
46350
|
+
assignedTo: task?.assignedTo,
|
|
46351
|
+
selfId,
|
|
46352
|
+
isLeader,
|
|
46353
|
+
needsProxy
|
|
46354
|
+
});
|
|
46355
|
+
if (isLeader) {
|
|
46356
|
+
const local2 = readLocalTaskLogsWithNativeHistory(engineRegistry, task, taskId, after, task?.agent ?? "claudecode");
|
|
46357
|
+
if (local2.total > 0 || !needsProxy) {
|
|
46358
|
+
log2.debug("serving leader-local task logs", {
|
|
46359
|
+
taskId,
|
|
46360
|
+
assignedTo: task?.assignedTo,
|
|
46361
|
+
selfId,
|
|
46362
|
+
total: local2.total,
|
|
46363
|
+
after
|
|
46364
|
+
});
|
|
46365
|
+
res.json(local2);
|
|
46366
|
+
return;
|
|
46367
|
+
}
|
|
46368
|
+
log2.debug("leader-local task log missing, falling back to worker proxy", {
|
|
46369
|
+
taskId,
|
|
46370
|
+
assignedTo: task?.assignedTo,
|
|
46371
|
+
selfId
|
|
46372
|
+
});
|
|
46373
|
+
}
|
|
46374
|
+
if (needsProxy) {
|
|
46375
|
+
const node = nodeRegistry.getNode(task.assignedTo);
|
|
46376
|
+
log2.debug("proxy target", { nodeId: node?.id, endpoint: node?.endpoint, devtunnel: node?.devtunnelEndpoint, status: node?.status });
|
|
46377
|
+
if (node) {
|
|
46378
|
+
const seededLogs = await seedTaskSnapshotOnWorker(task, [], node, log2).catch((err) => {
|
|
46379
|
+
log2.warn("failed to seed task snapshot before task logs proxy", {
|
|
46380
|
+
taskId,
|
|
46381
|
+
assignedTo: task.assignedTo,
|
|
46382
|
+
...describeProxyError3(err)
|
|
46383
|
+
});
|
|
46384
|
+
return [];
|
|
46385
|
+
});
|
|
46386
|
+
if (seededLogs.length > 0) recordLocalTaskLogs(engineRegistry, task, seededLogs);
|
|
46387
|
+
const proxyPath = `/api/tasks/${taskId}/logs?after=${after}`;
|
|
46388
|
+
try {
|
|
46389
|
+
const { endpoint, response: proxyRes } = await fetchNodeWithFallback(
|
|
46390
|
+
node,
|
|
46391
|
+
proxyPath,
|
|
46392
|
+
{ headers: createTaskLogsProxyHeaders(selfId, task) },
|
|
46393
|
+
TASK_LOG_PROXY_TIMEOUT_MS,
|
|
46394
|
+
createTaskLogsProxyTrace(log2, taskId, node.id, proxyPath),
|
|
46395
|
+
{ preferPublicEndpoint: true }
|
|
46396
|
+
);
|
|
46397
|
+
const proxyUrl = `${endpoint}${proxyPath}`;
|
|
46398
|
+
log2.info("proxying task logs request", {
|
|
46399
|
+
taskId,
|
|
46400
|
+
assignedTo: task.assignedTo,
|
|
46401
|
+
endpoint,
|
|
46402
|
+
proxyPath,
|
|
46403
|
+
url: proxyUrl
|
|
46404
|
+
});
|
|
46405
|
+
if (!proxyRes.ok) throw new MeshyError("NODE_OFFLINE", `Worker log proxy failed (${proxyRes.status})`, 502);
|
|
46406
|
+
const data = await proxyRes.json();
|
|
46407
|
+
log2.debug("proxy returned", { logs: data?.logs?.length ?? 0, total: data?.total });
|
|
46408
|
+
res.json(data);
|
|
46409
|
+
return;
|
|
46410
|
+
} catch (err) {
|
|
46411
|
+
log2.warn("task logs proxy failed; falling back to keepalive control", {
|
|
46412
|
+
taskId,
|
|
46413
|
+
assignedTo: task.assignedTo,
|
|
46414
|
+
timeoutMs: TASK_LOG_PROXY_TIMEOUT_MS,
|
|
46415
|
+
...describeProxyError3(err)
|
|
46416
|
+
});
|
|
46417
|
+
const fallback = await requestTaskLogsOverKeepalive(heartbeat, task.assignedTo, task, after);
|
|
46418
|
+
if (fallback) {
|
|
46419
|
+
sendWorkerControlResponse(res, fallback);
|
|
46420
|
+
return;
|
|
46421
|
+
}
|
|
46422
|
+
}
|
|
46423
|
+
}
|
|
46424
|
+
}
|
|
46425
|
+
const local = readLocalTaskLogsWithNativeHistory(engineRegistry, task, taskId, after, task?.agent ?? "claudecode");
|
|
46426
|
+
if (!proxyRequest.isProxy && isFollowerRemoteTask && local.total === 0 && await maybeProxyReadToLeader(req, res)) return;
|
|
46427
|
+
log2.debug("serving local task logs after proxy miss", {
|
|
46428
|
+
taskId,
|
|
46429
|
+
assignedTo: task?.assignedTo,
|
|
46430
|
+
selfId,
|
|
46431
|
+
total: local.total,
|
|
46432
|
+
after
|
|
46433
|
+
});
|
|
46434
|
+
res.json(local);
|
|
46435
|
+
}
|
|
46436
|
+
|
|
45406
46437
|
// ../../packages/api/src/routes/task-output.ts
|
|
45407
|
-
var
|
|
46438
|
+
var import_express7 = __toESM(require_express2(), 1);
|
|
45408
46439
|
|
|
45409
46440
|
// ../../packages/api/src/app/request-origin.ts
|
|
45410
46441
|
function getFirstHeaderValue(value) {
|
|
@@ -45458,7 +46489,7 @@ function resolveRequestOrigin(req) {
|
|
|
45458
46489
|
|
|
45459
46490
|
// ../../packages/api/src/routes/task-output.ts
|
|
45460
46491
|
var TASK_OUTPUT_PROXY_TIMEOUT_MS = 1e4;
|
|
45461
|
-
function
|
|
46492
|
+
function describeProxyError4(error) {
|
|
45462
46493
|
if (error instanceof Error) {
|
|
45463
46494
|
const errorCategory = error.name === "AbortError" || /aborted/i.test(error.message) ? "abort" : /timeout/i.test(error.message) ? "timeout" : "network";
|
|
45464
46495
|
return {
|
|
@@ -45511,7 +46542,7 @@ function createTaskOutputProxyTrace(log2, taskId, assignedTo, kind, proxyPath) {
|
|
|
45511
46542
|
attempt,
|
|
45512
46543
|
totalEndpoints,
|
|
45513
46544
|
timeoutMs,
|
|
45514
|
-
...
|
|
46545
|
+
...describeProxyError4(error)
|
|
45515
46546
|
});
|
|
45516
46547
|
}
|
|
45517
46548
|
};
|
|
@@ -45529,11 +46560,26 @@ function rewritePreviewPayloadIfNeeded(req, nodeId, payload) {
|
|
|
45529
46560
|
}
|
|
45530
46561
|
return rewritePreviewSessionPayloadForProxy(previewProxyManager, payload, nodeId);
|
|
45531
46562
|
}
|
|
46563
|
+
function withTaskSnapshot(message, task) {
|
|
46564
|
+
if (!message || typeof message.payload !== "object" || message.payload === null) return message;
|
|
46565
|
+
return { ...message, payload: { ...message.payload, task } };
|
|
46566
|
+
}
|
|
46567
|
+
async function sendTaskOutputProxyResponse(req, res, nodeId, proxyRes, fallbackRequest) {
|
|
46568
|
+
if (fallbackRequest?.kind === "task.preview.create" && proxyRes.ok) {
|
|
46569
|
+
const body = await proxyRes.json().catch(() => null);
|
|
46570
|
+
if (isPreviewSessionPayload(body)) {
|
|
46571
|
+
res.status(proxyRes.status).json(rewritePreviewPayloadIfNeeded(req, nodeId, body));
|
|
46572
|
+
return;
|
|
46573
|
+
}
|
|
46574
|
+
}
|
|
46575
|
+
await sendProxyResponse(res, proxyRes);
|
|
46576
|
+
}
|
|
45532
46577
|
async function maybeHandleRemoteTaskOutputRequest(req, res, taskId, subPath, init, fallbackRequest) {
|
|
45533
46578
|
const { taskEngine, nodeRegistry, heartbeat, logger: rootLogger } = req.app.locals.deps;
|
|
45534
46579
|
const log2 = rootLogger.child("tasks/output");
|
|
45535
46580
|
const task = taskEngine.getTask(taskId);
|
|
45536
46581
|
if (!task) {
|
|
46582
|
+
if (await maybeProxyReadToLeader(req, res, { methods: ["GET", "POST"] })) return true;
|
|
45537
46583
|
throw new MeshyError("TASK_NOT_FOUND", `Task ${taskId} not found`, 404);
|
|
45538
46584
|
}
|
|
45539
46585
|
const selfId = nodeRegistry.getSelf()?.id;
|
|
@@ -45550,14 +46596,15 @@ async function maybeHandleRemoteTaskOutputRequest(req, res, taskId, subPath, ini
|
|
|
45550
46596
|
throw new MeshyError("NODE_NOT_FOUND", `Assigned node ${assignedNodeId} not found`, 404);
|
|
45551
46597
|
}
|
|
45552
46598
|
if (!node.endpoint && !node.devtunnelEndpoint) {
|
|
45553
|
-
|
|
46599
|
+
const hydratedFallbackRequest2 = withTaskSnapshot(fallbackRequest, task);
|
|
46600
|
+
if (hydratedFallbackRequest2 && canRequestNodeMessage(heartbeat)) {
|
|
45554
46601
|
log2.warn("worker output endpoint missing, falling back to keepalive control", {
|
|
45555
46602
|
taskId,
|
|
45556
46603
|
assignedTo: assignedNodeId,
|
|
45557
|
-
kind:
|
|
46604
|
+
kind: hydratedFallbackRequest2.kind
|
|
45558
46605
|
});
|
|
45559
|
-
const controlResponse = await requestFallbackNodeMessage(heartbeat, assignedNodeId,
|
|
45560
|
-
if (
|
|
46606
|
+
const controlResponse = await requestFallbackNodeMessage(heartbeat, assignedNodeId, hydratedFallbackRequest2);
|
|
46607
|
+
if (hydratedFallbackRequest2.kind === "task.preview.create" && controlResponse.bodyEncoding === "json" && isPreviewSessionPayload(controlResponse.body)) {
|
|
45561
46608
|
res.status(controlResponse.statusCode).json(
|
|
45562
46609
|
rewritePreviewPayloadIfNeeded(req, assignedNodeId, controlResponse.body)
|
|
45563
46610
|
);
|
|
@@ -45571,6 +46618,7 @@ async function maybeHandleRemoteTaskOutputRequest(req, res, taskId, subPath, ini
|
|
|
45571
46618
|
const qs = new URL(req.originalUrl ?? req.url, "http://localhost").search;
|
|
45572
46619
|
const proxyPath = `/api/tasks/${taskId}/output${subPath}${qs}`;
|
|
45573
46620
|
const messageKind = fallbackRequest?.kind ?? "task.output.proxy";
|
|
46621
|
+
const hydratedFallbackRequest = withTaskSnapshot(fallbackRequest, task);
|
|
45574
46622
|
try {
|
|
45575
46623
|
const { endpoint, response: proxyRes } = await fetchNodeWithFallback(
|
|
45576
46624
|
node,
|
|
@@ -45587,26 +46635,35 @@ async function maybeHandleRemoteTaskOutputRequest(req, res, taskId, subPath, ini
|
|
|
45587
46635
|
proxyPath,
|
|
45588
46636
|
outputEndpoint: endpoint
|
|
45589
46637
|
});
|
|
45590
|
-
if (
|
|
45591
|
-
const
|
|
45592
|
-
|
|
45593
|
-
|
|
46638
|
+
if (proxyRes.status === 404) {
|
|
46639
|
+
const seededLogs = await seedTaskSnapshotOnWorker(task, [], node, log2).catch((seedError) => {
|
|
46640
|
+
log2.warn("failed to seed task snapshot after worker output 404", {
|
|
46641
|
+
taskId,
|
|
46642
|
+
assignedTo: assignedNodeId,
|
|
46643
|
+
kind: messageKind,
|
|
46644
|
+
error: seedError instanceof Error ? seedError.message : String(seedError)
|
|
46645
|
+
});
|
|
46646
|
+
return null;
|
|
46647
|
+
});
|
|
46648
|
+
if (seededLogs !== null) {
|
|
46649
|
+
const retry = await fetchNodeWithFallback(node, proxyPath, init, TASK_OUTPUT_PROXY_TIMEOUT_MS);
|
|
46650
|
+
await sendTaskOutputProxyResponse(req, res, assignedNodeId, retry.response, fallbackRequest);
|
|
45594
46651
|
return true;
|
|
45595
46652
|
}
|
|
45596
46653
|
}
|
|
45597
|
-
await
|
|
46654
|
+
await sendTaskOutputProxyResponse(req, res, assignedNodeId, proxyRes, fallbackRequest);
|
|
45598
46655
|
return true;
|
|
45599
46656
|
} catch (err) {
|
|
45600
|
-
if (
|
|
46657
|
+
if (hydratedFallbackRequest && canRequestNodeMessage(heartbeat)) {
|
|
45601
46658
|
log2.warn("worker output proxy failed, falling back to keepalive control", {
|
|
45602
46659
|
taskId,
|
|
45603
46660
|
assignedTo: assignedNodeId,
|
|
45604
|
-
kind:
|
|
46661
|
+
kind: hydratedFallbackRequest.kind,
|
|
45605
46662
|
timeoutMs: TASK_OUTPUT_PROXY_TIMEOUT_MS,
|
|
45606
|
-
...
|
|
46663
|
+
...describeProxyError4(err)
|
|
45607
46664
|
});
|
|
45608
|
-
const controlResponse = await requestFallbackNodeMessage(heartbeat, assignedNodeId,
|
|
45609
|
-
if (
|
|
46665
|
+
const controlResponse = await requestFallbackNodeMessage(heartbeat, assignedNodeId, hydratedFallbackRequest);
|
|
46666
|
+
if (hydratedFallbackRequest.kind === "task.preview.create" && controlResponse.bodyEncoding === "json" && isPreviewSessionPayload(controlResponse.body)) {
|
|
45610
46667
|
res.status(controlResponse.statusCode).json(
|
|
45611
46668
|
rewritePreviewPayloadIfNeeded(req, assignedNodeId, controlResponse.body)
|
|
45612
46669
|
);
|
|
@@ -45620,13 +46677,13 @@ async function maybeHandleRemoteTaskOutputRequest(req, res, taskId, subPath, ini
|
|
|
45620
46677
|
assignedTo: assignedNodeId,
|
|
45621
46678
|
kind: messageKind,
|
|
45622
46679
|
timeoutMs: TASK_OUTPUT_PROXY_TIMEOUT_MS,
|
|
45623
|
-
...
|
|
46680
|
+
...describeProxyError4(err)
|
|
45624
46681
|
});
|
|
45625
46682
|
throw new MeshyError("NODE_OFFLINE", "Cannot reach worker for task output", 502);
|
|
45626
46683
|
}
|
|
45627
46684
|
}
|
|
45628
46685
|
function createTaskOutputRoutes(options = {}) {
|
|
45629
|
-
const router = (0,
|
|
46686
|
+
const router = (0, import_express7.Router)();
|
|
45630
46687
|
const allowRemoteProxy = options.allowRemoteProxy ?? true;
|
|
45631
46688
|
router.get("/:id/output", asyncHandler5(async (req, res) => {
|
|
45632
46689
|
const taskId = req.params.id;
|
|
@@ -45747,62 +46804,6 @@ function createTaskOutputRoutes(options = {}) {
|
|
|
45747
46804
|
var TERMINAL_STATUSES3 = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "archived"]);
|
|
45748
46805
|
var ARCHIVABLE_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "archived"]);
|
|
45749
46806
|
var ACTIVE_STATUSES = /* @__PURE__ */ new Set(["pending", "assigned", "running"]);
|
|
45750
|
-
var TASK_LOG_PROXY_TIMEOUT_MS = 1e4;
|
|
45751
|
-
function describeProxyError4(error) {
|
|
45752
|
-
if (error instanceof Error) {
|
|
45753
|
-
const errorCategory = error.name === "AbortError" || /aborted/i.test(error.message) ? "abort" : /timeout/i.test(error.message) ? "timeout" : "network";
|
|
45754
|
-
return {
|
|
45755
|
-
errorName: error.name,
|
|
45756
|
-
errorMessage: error.message,
|
|
45757
|
-
errorCategory
|
|
45758
|
-
};
|
|
45759
|
-
}
|
|
45760
|
-
return {
|
|
45761
|
-
errorName: "UnknownError",
|
|
45762
|
-
errorMessage: String(error),
|
|
45763
|
-
errorCategory: "unknown"
|
|
45764
|
-
};
|
|
45765
|
-
}
|
|
45766
|
-
function createTaskLogsProxyTrace(log2, taskId, nodeId, proxyPath) {
|
|
45767
|
-
return {
|
|
45768
|
-
onAttempt: ({ attempt, endpoint, timeoutMs, totalEndpoints }) => {
|
|
45769
|
-
log2.debug("task logs proxy attempt", {
|
|
45770
|
-
taskId,
|
|
45771
|
-
nodeId,
|
|
45772
|
-
proxyPath,
|
|
45773
|
-
endpoint,
|
|
45774
|
-
attempt,
|
|
45775
|
-
totalEndpoints,
|
|
45776
|
-
timeoutMs
|
|
45777
|
-
});
|
|
45778
|
-
},
|
|
45779
|
-
onResponse: ({ attempt, endpoint, response, timeoutMs, totalEndpoints }) => {
|
|
45780
|
-
log2.info("task logs proxy response", {
|
|
45781
|
-
taskId,
|
|
45782
|
-
nodeId,
|
|
45783
|
-
proxyPath,
|
|
45784
|
-
endpoint,
|
|
45785
|
-
attempt,
|
|
45786
|
-
totalEndpoints,
|
|
45787
|
-
timeoutMs,
|
|
45788
|
-
ok: response.ok,
|
|
45789
|
-
statusCode: response.status
|
|
45790
|
-
});
|
|
45791
|
-
},
|
|
45792
|
-
onError: ({ attempt, endpoint, error, timeoutMs, totalEndpoints }) => {
|
|
45793
|
-
log2.warn("task logs proxy attempt failed", {
|
|
45794
|
-
taskId,
|
|
45795
|
-
nodeId,
|
|
45796
|
-
proxyPath,
|
|
45797
|
-
endpoint,
|
|
45798
|
-
attempt,
|
|
45799
|
-
totalEndpoints,
|
|
45800
|
-
timeoutMs,
|
|
45801
|
-
...describeProxyError4(error)
|
|
45802
|
-
});
|
|
45803
|
-
}
|
|
45804
|
-
};
|
|
45805
|
-
}
|
|
45806
46807
|
function shouldGenerateTitle(task) {
|
|
45807
46808
|
return task.payload.titleSource === "derived";
|
|
45808
46809
|
}
|
|
@@ -45917,7 +46918,7 @@ function buildShareUrl(origin, shareId) {
|
|
|
45917
46918
|
return `${origin.replace(/\/+$/, "")}/shared/tasks/${encodeURIComponent(shareId)}`;
|
|
45918
46919
|
}
|
|
45919
46920
|
function createTaskRoutes() {
|
|
45920
|
-
const router = (0,
|
|
46921
|
+
const router = (0, import_express8.Router)();
|
|
45921
46922
|
router.post("/", asyncHandler6(async (req, res) => {
|
|
45922
46923
|
const { taskEngine, nodeRegistry, liteAgentRunner, logger: rootLogger, workDir } = req.app.locals.deps;
|
|
45923
46924
|
const body = CreateTaskBody.parse(req.body);
|
|
@@ -45940,6 +46941,17 @@ function createTaskRoutes() {
|
|
|
45940
46941
|
scheduleTitleGeneration({ taskEngine, liteAgentRunner, logger: rootLogger, workDir }, task);
|
|
45941
46942
|
res.status(201).json(withAssignedNodeMetadata(task, nodeRegistry));
|
|
45942
46943
|
}));
|
|
46944
|
+
router.post("/import-session", asyncHandler6(async (req, res) => {
|
|
46945
|
+
const { taskEngine, nodeRegistry, engineRegistry, logger: rootLogger, shareOrigin } = req.app.locals.deps;
|
|
46946
|
+
const body = AttachNativeSessionBody.parse(req.body);
|
|
46947
|
+
const importedTask = await attachNativeSession({
|
|
46948
|
+
taskEngine,
|
|
46949
|
+
nodeRegistry,
|
|
46950
|
+
engineRegistry,
|
|
46951
|
+
logger: rootLogger
|
|
46952
|
+
}, body);
|
|
46953
|
+
res.status(201).json(toTaskResponse(importedTask, nodeRegistry, taskEngine, shareOrigin));
|
|
46954
|
+
}));
|
|
45943
46955
|
router.get("/", asyncHandler6(async (req, res) => {
|
|
45944
46956
|
const { taskEngine, nodeRegistry, shareOrigin } = req.app.locals.deps;
|
|
45945
46957
|
const query = TaskListQuery.parse(req.query);
|
|
@@ -45991,6 +47003,7 @@ function createTaskRoutes() {
|
|
|
45991
47003
|
const taskId = req.params.id;
|
|
45992
47004
|
const task = taskEngine.getTask(taskId);
|
|
45993
47005
|
if (!task) {
|
|
47006
|
+
if (await maybeProxyReadToLeader(req, res)) return;
|
|
45994
47007
|
throw new MeshyError("TASK_NOT_FOUND", `Task ${taskId} not found`, 404);
|
|
45995
47008
|
}
|
|
45996
47009
|
res.json(toTaskResponse(task, nodeRegistry, taskEngine, shareOrigin));
|
|
@@ -46141,89 +47154,7 @@ function createTaskRoutes() {
|
|
|
46141
47154
|
res.json(withAssignedNodeMetadata(task, nodeRegistry));
|
|
46142
47155
|
}));
|
|
46143
47156
|
router.get("/:id/logs", asyncHandler6(async (req, res) => {
|
|
46144
|
-
|
|
46145
|
-
const log2 = rootLogger.child("tasks/logs");
|
|
46146
|
-
const query = TaskLogsQuery.parse(req.query);
|
|
46147
|
-
const after = query.after ?? 0;
|
|
46148
|
-
const taskId = req.params.id;
|
|
46149
|
-
const task = taskEngine.getTask(taskId);
|
|
46150
|
-
const selfId = nodeRegistry.getSelf()?.id;
|
|
46151
|
-
const isLeader = nodeRegistry.isLeader();
|
|
46152
|
-
const needsProxy = isLeader && !!(task?.assignedTo && task.assignedTo !== selfId);
|
|
46153
|
-
log2.debug("log request", {
|
|
46154
|
-
taskId,
|
|
46155
|
-
assignedTo: task?.assignedTo,
|
|
46156
|
-
selfId,
|
|
46157
|
-
isLeader,
|
|
46158
|
-
needsProxy
|
|
46159
|
-
});
|
|
46160
|
-
if (isLeader) {
|
|
46161
|
-
const local2 = readLocalTaskLogs(engineRegistry, taskId, after, task?.agent ?? "claudecode");
|
|
46162
|
-
if (local2.total > 0 || !needsProxy) {
|
|
46163
|
-
log2.debug("serving leader-local task logs", {
|
|
46164
|
-
taskId,
|
|
46165
|
-
assignedTo: task?.assignedTo,
|
|
46166
|
-
selfId,
|
|
46167
|
-
total: local2.total,
|
|
46168
|
-
after
|
|
46169
|
-
});
|
|
46170
|
-
res.json(local2);
|
|
46171
|
-
return;
|
|
46172
|
-
}
|
|
46173
|
-
log2.debug("leader-local task log missing, falling back to worker proxy", {
|
|
46174
|
-
taskId,
|
|
46175
|
-
assignedTo: task?.assignedTo,
|
|
46176
|
-
selfId
|
|
46177
|
-
});
|
|
46178
|
-
}
|
|
46179
|
-
if (needsProxy) {
|
|
46180
|
-
const node = nodeRegistry.getNode(task.assignedTo);
|
|
46181
|
-
log2.debug("proxy target", { nodeId: node?.id, endpoint: node?.endpoint, devtunnel: node?.devtunnelEndpoint, status: node?.status });
|
|
46182
|
-
if (node) {
|
|
46183
|
-
const proxyPath = `/api/tasks/${taskId}/logs?after=${after}`;
|
|
46184
|
-
try {
|
|
46185
|
-
const { endpoint, response: proxyRes } = await fetchNodeWithFallback(
|
|
46186
|
-
node,
|
|
46187
|
-
proxyPath,
|
|
46188
|
-
void 0,
|
|
46189
|
-
TASK_LOG_PROXY_TIMEOUT_MS,
|
|
46190
|
-
createTaskLogsProxyTrace(log2, taskId, node.id, proxyPath),
|
|
46191
|
-
{ preferPublicEndpoint: true }
|
|
46192
|
-
);
|
|
46193
|
-
const proxyUrl = `${endpoint}${proxyPath}`;
|
|
46194
|
-
log2.info("proxying task logs request", {
|
|
46195
|
-
taskId,
|
|
46196
|
-
assignedTo: task.assignedTo,
|
|
46197
|
-
endpoint,
|
|
46198
|
-
proxyPath,
|
|
46199
|
-
url: proxyUrl
|
|
46200
|
-
});
|
|
46201
|
-
log2.debug("proxy response", { status: proxyRes.status });
|
|
46202
|
-
if (proxyRes.ok) {
|
|
46203
|
-
const data = await proxyRes.json();
|
|
46204
|
-
log2.debug("proxy returned", { logs: data?.logs?.length ?? 0, total: data?.total });
|
|
46205
|
-
res.json(data);
|
|
46206
|
-
return;
|
|
46207
|
-
}
|
|
46208
|
-
} catch (err) {
|
|
46209
|
-
log2.warn("task logs proxy failed; serving local logs after proxy miss", {
|
|
46210
|
-
taskId,
|
|
46211
|
-
assignedTo: task.assignedTo,
|
|
46212
|
-
timeoutMs: TASK_LOG_PROXY_TIMEOUT_MS,
|
|
46213
|
-
...describeProxyError4(err)
|
|
46214
|
-
});
|
|
46215
|
-
}
|
|
46216
|
-
}
|
|
46217
|
-
}
|
|
46218
|
-
const local = readLocalTaskLogs(engineRegistry, taskId, after, task?.agent ?? "claudecode");
|
|
46219
|
-
log2.debug("serving local task logs after proxy miss", {
|
|
46220
|
-
taskId,
|
|
46221
|
-
assignedTo: task?.assignedTo,
|
|
46222
|
-
selfId,
|
|
46223
|
-
total: local.total,
|
|
46224
|
-
after
|
|
46225
|
-
});
|
|
46226
|
-
res.json(local);
|
|
47157
|
+
await sendTaskLogsResponse(req, res, req.params.id);
|
|
46227
47158
|
}));
|
|
46228
47159
|
router.post("/:id/message", asyncHandler6(async (req, res) => {
|
|
46229
47160
|
const { taskEngine, engineRegistry, nodeRegistry, heartbeat, logger: rootLogger } = req.app.locals.deps;
|
|
@@ -46287,7 +47218,7 @@ function createTaskRoutes() {
|
|
|
46287
47218
|
}
|
|
46288
47219
|
|
|
46289
47220
|
// ../../packages/api/src/routes/shared.ts
|
|
46290
|
-
var
|
|
47221
|
+
var import_express9 = __toESM(require_express2(), 1);
|
|
46291
47222
|
function asyncHandler7(fn) {
|
|
46292
47223
|
return (req, res, next) => fn(req, res, next).catch(next);
|
|
46293
47224
|
}
|
|
@@ -46315,6 +47246,7 @@ function toSharedConversation(share, task) {
|
|
|
46315
47246
|
title: task.title,
|
|
46316
47247
|
description: task.description,
|
|
46317
47248
|
agent: task.agent,
|
|
47249
|
+
conversationKind: task.conversationKind,
|
|
46318
47250
|
status: task.status,
|
|
46319
47251
|
priority: task.priority,
|
|
46320
47252
|
assignedNodeName: task.assignedNodeName ?? null,
|
|
@@ -46326,7 +47258,7 @@ function toSharedConversation(share, task) {
|
|
|
46326
47258
|
};
|
|
46327
47259
|
}
|
|
46328
47260
|
function createSharedRoutes() {
|
|
46329
|
-
const router = (0,
|
|
47261
|
+
const router = (0, import_express9.Router)();
|
|
46330
47262
|
router.get("/conversations/:shareId", asyncHandler7(async (req, res) => {
|
|
46331
47263
|
const { taskEngine } = req.app.locals.deps;
|
|
46332
47264
|
const shareId = req.params.shareId;
|
|
@@ -46338,15 +47270,10 @@ function createSharedRoutes() {
|
|
|
46338
47270
|
res.json(toSharedConversation(share, task));
|
|
46339
47271
|
}));
|
|
46340
47272
|
router.get("/conversations/:shareId/logs", asyncHandler7(async (req, res) => {
|
|
46341
|
-
const { taskEngine
|
|
46342
|
-
const query = TaskLogsQuery.parse(req.query);
|
|
47273
|
+
const { taskEngine } = req.app.locals.deps;
|
|
46343
47274
|
const shareId = req.params.shareId;
|
|
46344
47275
|
const share = assertActiveShare(taskEngine.getTaskShare(shareId));
|
|
46345
|
-
|
|
46346
|
-
if (!task) {
|
|
46347
|
-
throw new MeshyError("TASK_NOT_FOUND", "Shared conversation task not found", 404);
|
|
46348
|
-
}
|
|
46349
|
-
res.json(readLocalTaskLogs(engineRegistry, task.id, query.after ?? 0, task.agent));
|
|
47276
|
+
await sendTaskLogsResponse(req, res, share.taskId);
|
|
46350
47277
|
}));
|
|
46351
47278
|
router.get("/conversations/:shareId/output", asyncHandler7(async (req, res) => {
|
|
46352
47279
|
const { taskEngine } = req.app.locals.deps;
|
|
@@ -46441,7 +47368,7 @@ function createSharedRoutes() {
|
|
|
46441
47368
|
}
|
|
46442
47369
|
|
|
46443
47370
|
// ../../packages/api/src/routes/worker.ts
|
|
46444
|
-
var
|
|
47371
|
+
var import_express10 = __toESM(require_express2(), 1);
|
|
46445
47372
|
var WorkerMessageBody = external_exports.object({
|
|
46446
47373
|
taskId: external_exports.string().min(1)
|
|
46447
47374
|
}).and(SendMessageBody);
|
|
@@ -46452,7 +47379,7 @@ function asyncHandler8(fn) {
|
|
|
46452
47379
|
return (req, res, next) => fn(req, res, next).catch(next);
|
|
46453
47380
|
}
|
|
46454
47381
|
function createWorkerRoutes() {
|
|
46455
|
-
const router = (0,
|
|
47382
|
+
const router = (0, import_express10.Router)();
|
|
46456
47383
|
router.post("/execute", asyncHandler8(async (req, res) => {
|
|
46457
47384
|
const { taskEngine, engineRegistry, nodeRegistry, eventBus, logger: rootLogger, workDir } = req.app.locals.deps;
|
|
46458
47385
|
const log2 = rootLogger.child("worker/execute");
|
|
@@ -46470,6 +47397,21 @@ function createWorkerRoutes() {
|
|
|
46470
47397
|
});
|
|
46471
47398
|
res.json({ ok: true });
|
|
46472
47399
|
}));
|
|
47400
|
+
router.post("/import-task", asyncHandler8(async (req, res) => {
|
|
47401
|
+
const { taskEngine, engineRegistry } = req.app.locals.deps;
|
|
47402
|
+
const body = WorkerImportTaskBody.parse(req.body);
|
|
47403
|
+
const { task } = body;
|
|
47404
|
+
let { logs } = body;
|
|
47405
|
+
if (logs.length === 0 && task.conversationKind === "nativeSession") {
|
|
47406
|
+
const sessionId = typeof task.payload?.sessionId === "string" ? task.payload.sessionId : "";
|
|
47407
|
+
if (sessionId && (task.agent === "codex" || task.agent === "claudecode")) {
|
|
47408
|
+
logs = loadNativeSessionHistory({ agent: task.agent, sessionId }).logs;
|
|
47409
|
+
}
|
|
47410
|
+
}
|
|
47411
|
+
taskEngine.importTasks([task]);
|
|
47412
|
+
recordLocalTaskLogs(engineRegistry, task, logs);
|
|
47413
|
+
res.status(201).json({ ok: true, task, logs });
|
|
47414
|
+
}));
|
|
46473
47415
|
router.post("/message", asyncHandler8(async (req, res) => {
|
|
46474
47416
|
const { engineRegistry, taskEngine, nodeRegistry, eventBus, logger: rootLogger } = req.app.locals.deps;
|
|
46475
47417
|
const log2 = rootLogger.child("worker/message");
|
|
@@ -46651,10 +47593,10 @@ function normalizeNodeMessageResponse(value) {
|
|
|
46651
47593
|
}
|
|
46652
47594
|
|
|
46653
47595
|
// ../../packages/api/src/routes/system.ts
|
|
46654
|
-
var
|
|
47596
|
+
var import_express11 = __toESM(require_express2(), 1);
|
|
46655
47597
|
|
|
46656
47598
|
// ../../packages/api/src/app/system-info.ts
|
|
46657
|
-
var
|
|
47599
|
+
var os6 = __toESM(require("os"), 1);
|
|
46658
47600
|
var import_node_child_process8 = require("child_process");
|
|
46659
47601
|
var RUNTIME_TOOLS = [
|
|
46660
47602
|
{ id: "claude", label: "Claude Code", command: "claude" },
|
|
@@ -46721,16 +47663,16 @@ function inspectRuntimeTools() {
|
|
|
46721
47663
|
return RUNTIME_TOOLS.map(inspectTool);
|
|
46722
47664
|
}
|
|
46723
47665
|
function getOsSnapshot() {
|
|
46724
|
-
const cpus2 =
|
|
47666
|
+
const cpus2 = os6.cpus();
|
|
46725
47667
|
return {
|
|
46726
|
-
platform:
|
|
46727
|
-
release:
|
|
46728
|
-
arch:
|
|
46729
|
-
hostname:
|
|
47668
|
+
platform: os6.platform(),
|
|
47669
|
+
release: os6.release(),
|
|
47670
|
+
arch: os6.arch(),
|
|
47671
|
+
hostname: os6.hostname(),
|
|
46730
47672
|
cpuModel: cpus2[0]?.model ?? null,
|
|
46731
47673
|
cpuCount: cpus2.length,
|
|
46732
|
-
totalMemoryBytes:
|
|
46733
|
-
freeMemoryBytes:
|
|
47674
|
+
totalMemoryBytes: os6.totalmem(),
|
|
47675
|
+
freeMemoryBytes: os6.freemem()
|
|
46734
47676
|
};
|
|
46735
47677
|
}
|
|
46736
47678
|
function buildNodeSettingsSnapshot(options) {
|
|
@@ -46773,7 +47715,7 @@ function asyncHandler9(fn) {
|
|
|
46773
47715
|
return (req, res, next) => fn(req, res, next).catch(next);
|
|
46774
47716
|
}
|
|
46775
47717
|
function createSystemRoutes() {
|
|
46776
|
-
const router = (0,
|
|
47718
|
+
const router = (0, import_express11.Router)();
|
|
46777
47719
|
router.get("/health", asyncHandler9(async (req, res) => {
|
|
46778
47720
|
const { logger: rootLogger } = req.app.locals.deps;
|
|
46779
47721
|
rootLogger.child("system/health").info("received system health API call", {
|
|
@@ -46879,7 +47821,7 @@ function createSystemRoutes() {
|
|
|
46879
47821
|
}
|
|
46880
47822
|
|
|
46881
47823
|
// ../../packages/api/src/routes/events.ts
|
|
46882
|
-
var
|
|
47824
|
+
var import_express12 = __toESM(require_express2(), 1);
|
|
46883
47825
|
var HEARTBEAT_INTERVAL_MS = 15e3;
|
|
46884
47826
|
var CATEGORY_MAP = {
|
|
46885
47827
|
tasks: "task.",
|
|
@@ -46915,7 +47857,7 @@ function shouldIncludeEvent(eventName, categories) {
|
|
|
46915
47857
|
});
|
|
46916
47858
|
}
|
|
46917
47859
|
function createEventRoutes() {
|
|
46918
|
-
const router = (0,
|
|
47860
|
+
const router = (0, import_express12.Router)();
|
|
46919
47861
|
router.get("/", (req, res) => {
|
|
46920
47862
|
const { eventBus } = req.app.locals.deps;
|
|
46921
47863
|
const categories = parseFilter(req.query.filter);
|
|
@@ -47000,8 +47942,8 @@ function isAllowedSharePath(pathname) {
|
|
|
47000
47942
|
function resolveRuntimeBaseDir() {
|
|
47001
47943
|
const entryPath = process.argv[1];
|
|
47002
47944
|
if (typeof entryPath === "string" && entryPath.length > 0) {
|
|
47003
|
-
const resolved =
|
|
47004
|
-
return
|
|
47945
|
+
const resolved = fs18.realpathSync(path19.resolve(entryPath));
|
|
47946
|
+
return path19.dirname(resolved);
|
|
47005
47947
|
}
|
|
47006
47948
|
return process.cwd();
|
|
47007
47949
|
}
|
|
@@ -47009,25 +47951,25 @@ function resolveStaticDir(baseDir) {
|
|
|
47009
47951
|
const envStaticDir = process.env.MESHY_STATIC_DIR;
|
|
47010
47952
|
const candidateDirs = [
|
|
47011
47953
|
envStaticDir,
|
|
47012
|
-
|
|
47013
|
-
|
|
47014
|
-
|
|
47015
|
-
|
|
47016
|
-
|
|
47017
|
-
|
|
47018
|
-
|
|
47019
|
-
|
|
47020
|
-
|
|
47954
|
+
path19.resolve(baseDir, "dashboard"),
|
|
47955
|
+
path19.resolve(baseDir, "../dashboard"),
|
|
47956
|
+
path19.resolve(baseDir, "../../dashboard/dist"),
|
|
47957
|
+
path19.resolve(baseDir, "../../../packages/dashboard/dist"),
|
|
47958
|
+
path19.resolve(baseDir, "../public"),
|
|
47959
|
+
path19.resolve(baseDir, "../../packages/api/public"),
|
|
47960
|
+
path19.resolve(baseDir, "../../../packages/api/public"),
|
|
47961
|
+
path19.resolve(process.cwd(), "packages/dashboard/dist"),
|
|
47962
|
+
path19.resolve(process.cwd(), "packages/api/public")
|
|
47021
47963
|
].filter((value) => typeof value === "string" && value.length > 0);
|
|
47022
47964
|
for (const candidate of candidateDirs) {
|
|
47023
|
-
if (
|
|
47965
|
+
if (fs18.existsSync(candidate)) {
|
|
47024
47966
|
return candidate;
|
|
47025
47967
|
}
|
|
47026
47968
|
}
|
|
47027
47969
|
return null;
|
|
47028
47970
|
}
|
|
47029
47971
|
function createServer2(deps) {
|
|
47030
|
-
const app = (0,
|
|
47972
|
+
const app = (0, import_express13.default)();
|
|
47031
47973
|
app.locals.deps = deps;
|
|
47032
47974
|
if (typeof deps.heartbeat.setNodeMessageHandler === "function") {
|
|
47033
47975
|
deps.heartbeat.setNodeMessageHandler((message) => handleNodeMessage(deps, message));
|
|
@@ -47068,7 +48010,7 @@ function createServer2(deps) {
|
|
|
47068
48010
|
const runtimeBaseDir = resolveRuntimeBaseDir();
|
|
47069
48011
|
const staticDir = resolveStaticDir(runtimeBaseDir);
|
|
47070
48012
|
if (staticDir) {
|
|
47071
|
-
const staticMiddleware =
|
|
48013
|
+
const staticMiddleware = import_express13.default.static(staticDir);
|
|
47072
48014
|
app.use((req, res, next) => {
|
|
47073
48015
|
if (isApiRequest(req)) {
|
|
47074
48016
|
next();
|
|
@@ -47081,7 +48023,7 @@ function createServer2(deps) {
|
|
|
47081
48023
|
staticMiddleware(req, res, next);
|
|
47082
48024
|
});
|
|
47083
48025
|
}
|
|
47084
|
-
app.use(
|
|
48026
|
+
app.use(import_express13.default.json({ limit: JSON_BODY_LIMIT }));
|
|
47085
48027
|
app.use(createAuthMiddleware(authConfig));
|
|
47086
48028
|
app.use((req, res, next) => {
|
|
47087
48029
|
void (async () => {
|
|
@@ -47103,7 +48045,7 @@ function createServer2(deps) {
|
|
|
47103
48045
|
})().catch(next);
|
|
47104
48046
|
});
|
|
47105
48047
|
app.use(createRoutingMiddleware(deps.dataRouter));
|
|
47106
|
-
const largeBodyParser =
|
|
48048
|
+
const largeBodyParser = import_express13.default.json({ limit: JSON_BODY_LIMIT_LARGE });
|
|
47107
48049
|
app.use("/api/cluster", createClusterRoutes());
|
|
47108
48050
|
app.use("/api/cluster-control", createClusterControlRoutes());
|
|
47109
48051
|
app.use("/api/node", largeBodyParser, createNodeMessageRoutes());
|
|
@@ -47114,8 +48056,8 @@ function createServer2(deps) {
|
|
|
47114
48056
|
app.use("/api/system", createSystemRoutes());
|
|
47115
48057
|
app.use("/api/events", createEventRoutes());
|
|
47116
48058
|
if (staticDir) {
|
|
47117
|
-
const indexPath =
|
|
47118
|
-
if (
|
|
48059
|
+
const indexPath = path19.join(staticDir, "index.html");
|
|
48060
|
+
if (fs18.existsSync(indexPath)) {
|
|
47119
48061
|
app.get("*", (req, res, next) => {
|
|
47120
48062
|
if (isApiRequest(req)) {
|
|
47121
48063
|
next();
|
|
@@ -47485,8 +48427,8 @@ function createTransport(config) {
|
|
|
47485
48427
|
}
|
|
47486
48428
|
|
|
47487
48429
|
// src/startup.ts
|
|
47488
|
-
var
|
|
47489
|
-
var
|
|
48430
|
+
var fs19 = __toESM(require("fs"), 1);
|
|
48431
|
+
var path20 = __toESM(require("path"), 1);
|
|
47490
48432
|
var readline = __toESM(require("readline/promises"), 1);
|
|
47491
48433
|
var import_node_child_process10 = require("child_process");
|
|
47492
48434
|
function getDefaultNodeName() {
|
|
@@ -47549,19 +48491,19 @@ function createDefaultCommandRunner(platform2) {
|
|
|
47549
48491
|
};
|
|
47550
48492
|
}
|
|
47551
48493
|
function getNodeMetadataPath2(storagePath) {
|
|
47552
|
-
return
|
|
48494
|
+
return path20.join(storagePath, "metadata.json");
|
|
47553
48495
|
}
|
|
47554
48496
|
function readStartupMetadataFile(storagePath) {
|
|
47555
48497
|
try {
|
|
47556
|
-
const raw = JSON.parse(
|
|
48498
|
+
const raw = JSON.parse(fs19.readFileSync(getNodeMetadataPath2(storagePath), "utf-8"));
|
|
47557
48499
|
return typeof raw === "object" && raw !== null ? raw : {};
|
|
47558
48500
|
} catch {
|
|
47559
48501
|
return {};
|
|
47560
48502
|
}
|
|
47561
48503
|
}
|
|
47562
48504
|
function writeStartupMetadataFile(storagePath, metadata) {
|
|
47563
|
-
|
|
47564
|
-
|
|
48505
|
+
fs19.mkdirSync(storagePath, { recursive: true });
|
|
48506
|
+
fs19.writeFileSync(getNodeMetadataPath2(storagePath), JSON.stringify(metadata, null, 2) + "\n", "utf-8");
|
|
47565
48507
|
}
|
|
47566
48508
|
function formatLocalDate(now) {
|
|
47567
48509
|
const year = now.getFullYear();
|
|
@@ -47800,9 +48742,9 @@ async function ensureStartupRequirements(storagePath, options = {}) {
|
|
|
47800
48742
|
metadata
|
|
47801
48743
|
};
|
|
47802
48744
|
}
|
|
47803
|
-
function loadConfigFile(
|
|
48745
|
+
function loadConfigFile(path22) {
|
|
47804
48746
|
try {
|
|
47805
|
-
const raw =
|
|
48747
|
+
const raw = fs19.readFileSync(path22, "utf-8");
|
|
47806
48748
|
return JSON.parse(raw);
|
|
47807
48749
|
} catch {
|
|
47808
48750
|
return {};
|
|
@@ -47980,26 +48922,26 @@ function formatLoadedStartMetadata(info, authEnabled) {
|
|
|
47980
48922
|
}
|
|
47981
48923
|
|
|
47982
48924
|
// src/runtime-metadata.ts
|
|
47983
|
-
var
|
|
47984
|
-
var
|
|
48925
|
+
var fs20 = __toESM(require("fs"), 1);
|
|
48926
|
+
var path21 = __toESM(require("path"), 1);
|
|
47985
48927
|
var import_node_child_process11 = require("child_process");
|
|
47986
48928
|
var runtimeDir = resolveRuntimeDir();
|
|
47987
48929
|
var appRoot = resolveAppRoot(runtimeDir);
|
|
47988
|
-
var repoRoot =
|
|
48930
|
+
var repoRoot = path21.resolve(appRoot, "../..");
|
|
47989
48931
|
function resolveRuntimeDir() {
|
|
47990
48932
|
const entryPath = process.argv[1];
|
|
47991
48933
|
if (typeof entryPath === "string" && entryPath.length > 0) {
|
|
47992
48934
|
try {
|
|
47993
|
-
return
|
|
48935
|
+
return path21.dirname(fs20.realpathSync(path21.resolve(entryPath)));
|
|
47994
48936
|
} catch {
|
|
47995
|
-
return
|
|
48937
|
+
return path21.dirname(path21.resolve(entryPath));
|
|
47996
48938
|
}
|
|
47997
48939
|
}
|
|
47998
48940
|
return process.cwd();
|
|
47999
48941
|
}
|
|
48000
48942
|
function readJsonFile(filePath) {
|
|
48001
48943
|
try {
|
|
48002
|
-
return JSON.parse(
|
|
48944
|
+
return JSON.parse(fs20.readFileSync(filePath, "utf-8"));
|
|
48003
48945
|
} catch {
|
|
48004
48946
|
return null;
|
|
48005
48947
|
}
|
|
@@ -48009,9 +48951,9 @@ function readPackageManifest(filePath) {
|
|
|
48009
48951
|
}
|
|
48010
48952
|
function readEmbeddedRuntimeMetadata() {
|
|
48011
48953
|
const candidates = [
|
|
48012
|
-
|
|
48013
|
-
|
|
48014
|
-
|
|
48954
|
+
path21.join(appRoot, "runtime-metadata.json"),
|
|
48955
|
+
path21.join(runtimeDir, "runtime-metadata.json"),
|
|
48956
|
+
path21.resolve(process.cwd(), "apps/node/dist/runtime-metadata.json")
|
|
48015
48957
|
];
|
|
48016
48958
|
for (const candidate of candidates) {
|
|
48017
48959
|
const metadata = readJsonFile(candidate);
|
|
@@ -48024,23 +48966,23 @@ function readEmbeddedRuntimeMetadata() {
|
|
|
48024
48966
|
function resolveAppRoot(baseDir) {
|
|
48025
48967
|
const candidates = [
|
|
48026
48968
|
baseDir,
|
|
48027
|
-
|
|
48028
|
-
|
|
48029
|
-
|
|
48969
|
+
path21.resolve(baseDir, ".."),
|
|
48970
|
+
path21.resolve(process.cwd(), "apps/node/dist"),
|
|
48971
|
+
path21.resolve(process.cwd(), "apps/node"),
|
|
48030
48972
|
process.cwd()
|
|
48031
48973
|
];
|
|
48032
48974
|
for (const candidate of candidates) {
|
|
48033
|
-
const manifest = readPackageManifest(
|
|
48975
|
+
const manifest = readPackageManifest(path21.join(candidate, "package.json"));
|
|
48034
48976
|
if (manifest?.name === "@meshy/node" || manifest?.name === "meshy-node") {
|
|
48035
48977
|
return candidate;
|
|
48036
48978
|
}
|
|
48037
48979
|
}
|
|
48038
48980
|
for (const candidate of candidates) {
|
|
48039
|
-
if (
|
|
48981
|
+
if (fs20.existsSync(path21.join(candidate, "package.json"))) {
|
|
48040
48982
|
return candidate;
|
|
48041
48983
|
}
|
|
48042
48984
|
}
|
|
48043
|
-
return
|
|
48985
|
+
return path21.resolve(baseDir, "..");
|
|
48044
48986
|
}
|
|
48045
48987
|
function toPackageInfo(filePath) {
|
|
48046
48988
|
const manifest = readPackageManifest(filePath);
|
|
@@ -48100,8 +49042,8 @@ function buildRuntimeMetadata(storagePath) {
|
|
|
48100
49042
|
components: startupRequirements.components
|
|
48101
49043
|
};
|
|
48102
49044
|
}
|
|
48103
|
-
const appPackage = toPackageInfo(
|
|
48104
|
-
const workspaceManifest = readPackageManifest(
|
|
49045
|
+
const appPackage = toPackageInfo(path21.join(appRoot, "package.json"));
|
|
49046
|
+
const workspaceManifest = readPackageManifest(path21.join(repoRoot, "package.json"));
|
|
48105
49047
|
return {
|
|
48106
49048
|
packageName: appPackage?.name ?? "meshy",
|
|
48107
49049
|
packageVersion: appPackage?.version ?? "0.1.0",
|
|
@@ -48109,11 +49051,11 @@ function buildRuntimeMetadata(storagePath) {
|
|
|
48109
49051
|
startupRequirementsLastCheckedOn: startupRequirements.lastCheckedOn,
|
|
48110
49052
|
components: startupRequirements.components,
|
|
48111
49053
|
packages: {
|
|
48112
|
-
workspace: toPackageInfo(
|
|
49054
|
+
workspace: toPackageInfo(path21.join(repoRoot, "package.json")),
|
|
48113
49055
|
node: appPackage,
|
|
48114
|
-
core: toPackageInfo(
|
|
48115
|
-
dashboard: toPackageInfo(
|
|
48116
|
-
api: toPackageInfo(
|
|
49056
|
+
core: toPackageInfo(path21.join(repoRoot, "packages/core/package.json")),
|
|
49057
|
+
dashboard: toPackageInfo(path21.join(repoRoot, "packages/dashboard/package.json")),
|
|
49058
|
+
api: toPackageInfo(path21.join(repoRoot, "packages/api/package.json"))
|
|
48117
49059
|
},
|
|
48118
49060
|
repository: {
|
|
48119
49061
|
url: normalizeRepositoryUrl(readGitValue(["config", "--get", "remote.upstream.url"])) ?? normalizeRepositoryUrl(readGitValue(["config", "--get", "remote.origin.url"])) ?? readRepositoryUrlFromManifest(workspaceManifest),
|