repoburg 1.3.231 → 1.3.234
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/agent-pane/backend/dist/index.js +1352 -501
- package/agent-pane/backend/dist/server.js +1349 -501
- package/agent-pane/frontend/dist/assets/index-B8tLcszC.css +1 -0
- package/agent-pane/frontend/dist/assets/index-BGAclp9s.js +424 -0
- package/agent-pane/frontend/dist/index.html +2 -2
- package/daemon/dist/agentPane.js +9 -0
- package/daemon/dist/agentPane.spec.js +22 -0
- package/daemon/dist/index.js +5 -0
- package/package.json +3 -2
- package/vscode-serve-web-test.png +0 -0
- package/agent-pane/frontend/dist/assets/index-BFzfnSZm.js +0 -418
- package/agent-pane/frontend/dist/assets/index-lc9eQnqi.css +0 -1
|
@@ -401,8 +401,8 @@ var require_error = __commonJS({
|
|
|
401
401
|
});
|
|
402
402
|
if (shouldCreateFastifyGenericError) {
|
|
403
403
|
Object.defineProperty(FastifyError, Symbol.hasInstance, {
|
|
404
|
-
value(
|
|
405
|
-
return
|
|
404
|
+
value(instance2) {
|
|
405
|
+
return instance2 && instance2[FastifyGenericErrorSymbol];
|
|
406
406
|
},
|
|
407
407
|
configurable: false,
|
|
408
408
|
writable: false,
|
|
@@ -410,8 +410,8 @@ var require_error = __commonJS({
|
|
|
410
410
|
});
|
|
411
411
|
} else {
|
|
412
412
|
Object.defineProperty(FastifyError, Symbol.hasInstance, {
|
|
413
|
-
value(
|
|
414
|
-
return
|
|
413
|
+
value(instance2) {
|
|
414
|
+
return instance2 && instance2[FastifySpecificErrorSymbol];
|
|
415
415
|
},
|
|
416
416
|
configurable: false,
|
|
417
417
|
writable: false,
|
|
@@ -1058,10 +1058,10 @@ var require_avvio = __commonJS({
|
|
|
1058
1058
|
this._closeQ.drain = noop;
|
|
1059
1059
|
};
|
|
1060
1060
|
this._doStart = null;
|
|
1061
|
-
const
|
|
1061
|
+
const instance2 = this;
|
|
1062
1062
|
this._root = new Plugin(fastq(this, this._loadPluginNextTick, 1), function root(server2, opts2, done2) {
|
|
1063
|
-
|
|
1064
|
-
opts2.autostart &&
|
|
1063
|
+
instance2._doStart = done2;
|
|
1064
|
+
opts2.autostart && instance2.start();
|
|
1065
1065
|
}, opts, false, 0);
|
|
1066
1066
|
this._trackPluginLoading(this._root);
|
|
1067
1067
|
this._loadPlugin(this._root, (err) => {
|
|
@@ -1147,8 +1147,8 @@ var require_avvio = __commonJS({
|
|
|
1147
1147
|
return plugin;
|
|
1148
1148
|
};
|
|
1149
1149
|
Boot.prototype._expose = function _expose() {
|
|
1150
|
-
const
|
|
1151
|
-
const server =
|
|
1150
|
+
const instance2 = this;
|
|
1151
|
+
const server = instance2._server;
|
|
1152
1152
|
const {
|
|
1153
1153
|
use: useKey = "use",
|
|
1154
1154
|
after: afterKey = "after",
|
|
@@ -1160,7 +1160,7 @@ var require_avvio = __commonJS({
|
|
|
1160
1160
|
throw new AVV_ERR_EXPOSE_ALREADY_DEFINED(useKey, "use");
|
|
1161
1161
|
}
|
|
1162
1162
|
server[useKey] = function(fn, opts) {
|
|
1163
|
-
|
|
1163
|
+
instance2.use(fn, opts);
|
|
1164
1164
|
return this;
|
|
1165
1165
|
};
|
|
1166
1166
|
if (server[afterKey]) {
|
|
@@ -1168,9 +1168,9 @@ var require_avvio = __commonJS({
|
|
|
1168
1168
|
}
|
|
1169
1169
|
server[afterKey] = function(func) {
|
|
1170
1170
|
if (typeof func !== "function") {
|
|
1171
|
-
return
|
|
1171
|
+
return instance2._loadRegistered();
|
|
1172
1172
|
}
|
|
1173
|
-
|
|
1173
|
+
instance2.after(encapsulateThreeParam(func, this));
|
|
1174
1174
|
return this;
|
|
1175
1175
|
};
|
|
1176
1176
|
if (server[readyKey]) {
|
|
@@ -1180,7 +1180,7 @@ var require_avvio = __commonJS({
|
|
|
1180
1180
|
if (func && typeof func !== "function") {
|
|
1181
1181
|
throw new AVV_ERR_CALLBACK_NOT_FN(readyKey, typeof func);
|
|
1182
1182
|
}
|
|
1183
|
-
return
|
|
1183
|
+
return instance2.ready(func ? encapsulateThreeParam(func, this) : void 0);
|
|
1184
1184
|
};
|
|
1185
1185
|
if (server[onCloseKey]) {
|
|
1186
1186
|
throw new AVV_ERR_EXPOSE_ALREADY_DEFINED(onCloseKey, "onClose");
|
|
@@ -1189,7 +1189,7 @@ var require_avvio = __commonJS({
|
|
|
1189
1189
|
if (typeof func !== "function") {
|
|
1190
1190
|
throw new AVV_ERR_CALLBACK_NOT_FN(onCloseKey, typeof func);
|
|
1191
1191
|
}
|
|
1192
|
-
|
|
1192
|
+
instance2.onClose(encapsulateTwoParam(func, this));
|
|
1193
1193
|
return this;
|
|
1194
1194
|
};
|
|
1195
1195
|
if (server[closeKey]) {
|
|
@@ -1200,15 +1200,15 @@ var require_avvio = __commonJS({
|
|
|
1200
1200
|
throw new AVV_ERR_CALLBACK_NOT_FN(closeKey, typeof func);
|
|
1201
1201
|
}
|
|
1202
1202
|
if (func) {
|
|
1203
|
-
|
|
1203
|
+
instance2.close(encapsulateThreeParam(func, this));
|
|
1204
1204
|
return this;
|
|
1205
1205
|
}
|
|
1206
|
-
return
|
|
1206
|
+
return instance2.close();
|
|
1207
1207
|
};
|
|
1208
1208
|
if (server.then) {
|
|
1209
1209
|
throw new AVV_ERR_ATTRIBUTE_ALREADY_DEFINED("then");
|
|
1210
1210
|
}
|
|
1211
|
-
Object.defineProperty(server, "then", { get: thenify.bind(
|
|
1211
|
+
Object.defineProperty(server, "then", { get: thenify.bind(instance2) });
|
|
1212
1212
|
server[kAvvio] = true;
|
|
1213
1213
|
};
|
|
1214
1214
|
Boot.prototype.after = function(func) {
|
|
@@ -1293,7 +1293,7 @@ var require_avvio = __commonJS({
|
|
|
1293
1293
|
return this.pluginTree.toJSON();
|
|
1294
1294
|
};
|
|
1295
1295
|
Boot.prototype._loadPlugin = function(plugin, callback) {
|
|
1296
|
-
const
|
|
1296
|
+
const instance2 = this;
|
|
1297
1297
|
if (isPromiseLike(plugin.func)) {
|
|
1298
1298
|
plugin.func.then((fn) => {
|
|
1299
1299
|
if (typeof fn.default === "function") {
|
|
@@ -1304,17 +1304,17 @@ var require_avvio = __commonJS({
|
|
|
1304
1304
|
}, callback);
|
|
1305
1305
|
return;
|
|
1306
1306
|
}
|
|
1307
|
-
const last =
|
|
1308
|
-
|
|
1309
|
-
if (
|
|
1307
|
+
const last = instance2._current[0];
|
|
1308
|
+
instance2._current.unshift(plugin);
|
|
1309
|
+
if (instance2._error && !plugin.isAfter) {
|
|
1310
1310
|
debug("skipping loading of plugin as instance errored and it is not an after", plugin.name);
|
|
1311
1311
|
process.nextTick(execCallback);
|
|
1312
1312
|
return;
|
|
1313
1313
|
}
|
|
1314
|
-
let server = last?.server ||
|
|
1314
|
+
let server = last?.server || instance2._server;
|
|
1315
1315
|
if (!plugin.isAfter) {
|
|
1316
1316
|
try {
|
|
1317
|
-
server =
|
|
1317
|
+
server = instance2.override(server, plugin.func, plugin.options);
|
|
1318
1318
|
} catch (overrideErr) {
|
|
1319
1319
|
debug("override errored", plugin.name);
|
|
1320
1320
|
return execCallback(overrideErr);
|
|
@@ -1323,7 +1323,7 @@ var require_avvio = __commonJS({
|
|
|
1323
1323
|
plugin.exec(server, execCallback);
|
|
1324
1324
|
function execCallback(err) {
|
|
1325
1325
|
plugin.finish(err, (err2) => {
|
|
1326
|
-
|
|
1326
|
+
instance2._current.shift();
|
|
1327
1327
|
callback(err2);
|
|
1328
1328
|
});
|
|
1329
1329
|
}
|
|
@@ -2672,11 +2672,11 @@ var require_promise = __commonJS({
|
|
|
2672
2672
|
var require_server = __commonJS({
|
|
2673
2673
|
"node_modules/fastify/lib/server.js"(exports, module) {
|
|
2674
2674
|
"use strict";
|
|
2675
|
-
var
|
|
2675
|
+
var http3 = __require("node:http");
|
|
2676
2676
|
var https = __require("node:https");
|
|
2677
|
-
var
|
|
2677
|
+
var http22 = __require("node:http2");
|
|
2678
2678
|
var dns = __require("node:dns");
|
|
2679
|
-
var
|
|
2679
|
+
var os2 = __require("node:os");
|
|
2680
2680
|
var { kState, kOptions, kServerBindings, kHttp2ServerSessions } = require_symbols2();
|
|
2681
2681
|
var { FSTWRN003 } = require_warnings();
|
|
2682
2682
|
var { onListenHookRunner } = require_hooks();
|
|
@@ -2917,7 +2917,7 @@ var require_server = __commonJS({
|
|
|
2917
2917
|
}
|
|
2918
2918
|
const httpsOptions = options.https === true ? {} : options.https;
|
|
2919
2919
|
if (options.http2) {
|
|
2920
|
-
const server2 = typeof httpsOptions === "object" ?
|
|
2920
|
+
const server2 = typeof httpsOptions === "object" ? http22.createSecureServer(httpsOptions, httpHandler) : http22.createServer(options.http, httpHandler);
|
|
2921
2921
|
server2.on("session", (session) => session.setTimeout(options.http2SessionTimeout, () => {
|
|
2922
2922
|
session.close();
|
|
2923
2923
|
}));
|
|
@@ -2927,7 +2927,7 @@ var require_server = __commonJS({
|
|
|
2927
2927
|
server2.setTimeout(options.connectionTimeout);
|
|
2928
2928
|
return server2;
|
|
2929
2929
|
}
|
|
2930
|
-
const server = httpsOptions ? https.createServer(httpsOptions, httpHandler) :
|
|
2930
|
+
const server = httpsOptions ? https.createServer(httpsOptions, httpHandler) : http3.createServer(options.http, httpHandler);
|
|
2931
2931
|
server.keepAliveTimeout = options.keepAliveTimeout;
|
|
2932
2932
|
server.requestTimeout = options.requestTimeout;
|
|
2933
2933
|
server.setTimeout(options.connectionTimeout);
|
|
@@ -2938,7 +2938,7 @@ var require_server = __commonJS({
|
|
|
2938
2938
|
}
|
|
2939
2939
|
function getAddresses(address) {
|
|
2940
2940
|
if (address.address === "0.0.0.0") {
|
|
2941
|
-
return Object.values(
|
|
2941
|
+
return Object.values(os2.networkInterfaces()).flatMap((iface) => {
|
|
2942
2942
|
return iface.filter((iface2) => iface2.family === "IPv4");
|
|
2943
2943
|
}).sort((iface) => {
|
|
2944
2944
|
return iface.internal ? -1 : 1;
|
|
@@ -6124,8 +6124,8 @@ var require_req = __commonJS({
|
|
|
6124
6124
|
if (req.originalUrl) {
|
|
6125
6125
|
_req.url = req.originalUrl;
|
|
6126
6126
|
} else {
|
|
6127
|
-
const
|
|
6128
|
-
_req.url = typeof
|
|
6127
|
+
const path4 = req.path;
|
|
6128
|
+
_req.url = typeof path4 === "string" ? path4 : req.url ? req.url.path || req.url : void 0;
|
|
6129
6129
|
}
|
|
6130
6130
|
if (req.query) {
|
|
6131
6131
|
_req.query = req.query;
|
|
@@ -6290,14 +6290,14 @@ var require_redact = __commonJS({
|
|
|
6290
6290
|
}
|
|
6291
6291
|
return obj;
|
|
6292
6292
|
}
|
|
6293
|
-
function parsePath(
|
|
6293
|
+
function parsePath(path4) {
|
|
6294
6294
|
const parts = [];
|
|
6295
6295
|
let current = "";
|
|
6296
6296
|
let inBrackets = false;
|
|
6297
6297
|
let inQuotes = false;
|
|
6298
6298
|
let quoteChar = "";
|
|
6299
|
-
for (let i = 0; i <
|
|
6300
|
-
const char =
|
|
6299
|
+
for (let i = 0; i < path4.length; i++) {
|
|
6300
|
+
const char = path4[i];
|
|
6301
6301
|
if (!inBrackets && char === ".") {
|
|
6302
6302
|
if (current) {
|
|
6303
6303
|
parts.push(current);
|
|
@@ -6428,10 +6428,10 @@ var require_redact = __commonJS({
|
|
|
6428
6428
|
return current;
|
|
6429
6429
|
}
|
|
6430
6430
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
6431
|
-
for (const
|
|
6432
|
-
const parts = parsePath(
|
|
6431
|
+
for (const path4 of paths) {
|
|
6432
|
+
const parts = parsePath(path4);
|
|
6433
6433
|
if (parts.includes("*")) {
|
|
6434
|
-
redactWildcardPath(obj, parts, censor,
|
|
6434
|
+
redactWildcardPath(obj, parts, censor, path4, remove);
|
|
6435
6435
|
} else {
|
|
6436
6436
|
if (remove) {
|
|
6437
6437
|
removeKey(obj, parts);
|
|
@@ -6516,8 +6516,8 @@ var require_redact = __commonJS({
|
|
|
6516
6516
|
}
|
|
6517
6517
|
} else {
|
|
6518
6518
|
if (afterWildcard.includes("*")) {
|
|
6519
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
6520
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
6519
|
+
const wrappedCensor = typeof censor === "function" ? (value, path4) => {
|
|
6520
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path4];
|
|
6521
6521
|
return censor(value, fullPath);
|
|
6522
6522
|
} : censor;
|
|
6523
6523
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -6552,8 +6552,8 @@ var require_redact = __commonJS({
|
|
|
6552
6552
|
return null;
|
|
6553
6553
|
}
|
|
6554
6554
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
6555
|
-
for (const
|
|
6556
|
-
const parts = parsePath(
|
|
6555
|
+
for (const path4 of pathsToClone) {
|
|
6556
|
+
const parts = parsePath(path4);
|
|
6557
6557
|
let current = pathStructure;
|
|
6558
6558
|
for (let i = 0; i < parts.length; i++) {
|
|
6559
6559
|
const part = parts[i];
|
|
@@ -6605,24 +6605,24 @@ var require_redact = __commonJS({
|
|
|
6605
6605
|
}
|
|
6606
6606
|
return cloneSelectively(obj, pathStructure);
|
|
6607
6607
|
}
|
|
6608
|
-
function validatePath(
|
|
6609
|
-
if (typeof
|
|
6608
|
+
function validatePath(path4) {
|
|
6609
|
+
if (typeof path4 !== "string") {
|
|
6610
6610
|
throw new Error("Paths must be (non-empty) strings");
|
|
6611
6611
|
}
|
|
6612
|
-
if (
|
|
6612
|
+
if (path4 === "") {
|
|
6613
6613
|
throw new Error("Invalid redaction path ()");
|
|
6614
6614
|
}
|
|
6615
|
-
if (
|
|
6616
|
-
throw new Error(`Invalid redaction path (${
|
|
6615
|
+
if (path4.includes("..")) {
|
|
6616
|
+
throw new Error(`Invalid redaction path (${path4})`);
|
|
6617
6617
|
}
|
|
6618
|
-
if (
|
|
6619
|
-
throw new Error(`Invalid redaction path (${
|
|
6618
|
+
if (path4.includes(",")) {
|
|
6619
|
+
throw new Error(`Invalid redaction path (${path4})`);
|
|
6620
6620
|
}
|
|
6621
6621
|
let bracketCount = 0;
|
|
6622
6622
|
let inQuotes = false;
|
|
6623
6623
|
let quoteChar = "";
|
|
6624
|
-
for (let i = 0; i <
|
|
6625
|
-
const char =
|
|
6624
|
+
for (let i = 0; i < path4.length; i++) {
|
|
6625
|
+
const char = path4[i];
|
|
6626
6626
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
6627
6627
|
if (!inQuotes) {
|
|
6628
6628
|
inQuotes = true;
|
|
@@ -6636,20 +6636,20 @@ var require_redact = __commonJS({
|
|
|
6636
6636
|
} else if (char === "]" && !inQuotes) {
|
|
6637
6637
|
bracketCount--;
|
|
6638
6638
|
if (bracketCount < 0) {
|
|
6639
|
-
throw new Error(`Invalid redaction path (${
|
|
6639
|
+
throw new Error(`Invalid redaction path (${path4})`);
|
|
6640
6640
|
}
|
|
6641
6641
|
}
|
|
6642
6642
|
}
|
|
6643
6643
|
if (bracketCount !== 0) {
|
|
6644
|
-
throw new Error(`Invalid redaction path (${
|
|
6644
|
+
throw new Error(`Invalid redaction path (${path4})`);
|
|
6645
6645
|
}
|
|
6646
6646
|
}
|
|
6647
6647
|
function validatePaths(paths) {
|
|
6648
6648
|
if (!Array.isArray(paths)) {
|
|
6649
6649
|
throw new TypeError("paths must be an array");
|
|
6650
6650
|
}
|
|
6651
|
-
for (const
|
|
6652
|
-
validatePath(
|
|
6651
|
+
for (const path4 of paths) {
|
|
6652
|
+
validatePath(path4);
|
|
6653
6653
|
}
|
|
6654
6654
|
}
|
|
6655
6655
|
function slowRedact(options = {}) {
|
|
@@ -6817,8 +6817,8 @@ var require_redaction = __commonJS({
|
|
|
6817
6817
|
if (shape[k] === null) {
|
|
6818
6818
|
o[k] = (value) => topCensor(value, [k]);
|
|
6819
6819
|
} else {
|
|
6820
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
6821
|
-
return censor(value, [k, ...
|
|
6820
|
+
const wrappedCensor = typeof censor === "function" ? (value, path4) => {
|
|
6821
|
+
return censor(value, [k, ...path4]);
|
|
6822
6822
|
} : censor;
|
|
6823
6823
|
o[k] = Redact({
|
|
6824
6824
|
paths: shape[k],
|
|
@@ -7039,7 +7039,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7039
7039
|
var fs = __require("fs");
|
|
7040
7040
|
var EventEmitter2 = __require("events");
|
|
7041
7041
|
var inherits = __require("util").inherits;
|
|
7042
|
-
var
|
|
7042
|
+
var path4 = __require("path");
|
|
7043
7043
|
var sleep = require_atomic_sleep();
|
|
7044
7044
|
var assert = __require("assert");
|
|
7045
7045
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -7093,7 +7093,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7093
7093
|
const mode = sonic.mode;
|
|
7094
7094
|
if (sonic.sync) {
|
|
7095
7095
|
try {
|
|
7096
|
-
if (sonic.mkdir) fs.mkdirSync(
|
|
7096
|
+
if (sonic.mkdir) fs.mkdirSync(path4.dirname(file), { recursive: true });
|
|
7097
7097
|
const fd = fs.openSync(file, flags, mode);
|
|
7098
7098
|
fileOpened(null, fd);
|
|
7099
7099
|
} catch (err) {
|
|
@@ -7101,7 +7101,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7101
7101
|
throw err;
|
|
7102
7102
|
}
|
|
7103
7103
|
} else if (sonic.mkdir) {
|
|
7104
|
-
fs.mkdir(
|
|
7104
|
+
fs.mkdir(path4.dirname(file), { recursive: true }, (err) => {
|
|
7105
7105
|
if (err) return fileOpened(err);
|
|
7106
7106
|
fs.open(file, flags, mode, fileOpened);
|
|
7107
7107
|
});
|
|
@@ -7113,7 +7113,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7113
7113
|
if (!(this instanceof SonicBoom)) {
|
|
7114
7114
|
return new SonicBoom(opts);
|
|
7115
7115
|
}
|
|
7116
|
-
let { fd, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {};
|
|
7116
|
+
let { fd, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir: mkdir2, retryEAGAIN, fsync, contentMode, mode } = opts || {};
|
|
7117
7117
|
fd = fd || dest;
|
|
7118
7118
|
this._len = 0;
|
|
7119
7119
|
this.fd = -1;
|
|
@@ -7138,7 +7138,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7138
7138
|
this.append = append || false;
|
|
7139
7139
|
this.mode = mode;
|
|
7140
7140
|
this.retryEAGAIN = retryEAGAIN || (() => true);
|
|
7141
|
-
this.mkdir =
|
|
7141
|
+
this.mkdir = mkdir2 || false;
|
|
7142
7142
|
let fsWriteSync;
|
|
7143
7143
|
let fsWrite;
|
|
7144
7144
|
if (contentMode === kContentModeBuffer) {
|
|
@@ -7850,7 +7850,7 @@ var require_thread_stream = __commonJS({
|
|
|
7850
7850
|
var { version } = require_package();
|
|
7851
7851
|
var { EventEmitter: EventEmitter2 } = __require("events");
|
|
7852
7852
|
var { Worker } = __require("worker_threads");
|
|
7853
|
-
var { join:
|
|
7853
|
+
var { join: join3 } = __require("path");
|
|
7854
7854
|
var { pathToFileURL } = __require("url");
|
|
7855
7855
|
var { wait } = require_wait();
|
|
7856
7856
|
var {
|
|
@@ -7901,7 +7901,7 @@ var require_thread_stream = __commonJS({
|
|
|
7901
7901
|
function createWorker(stream, opts) {
|
|
7902
7902
|
const { filename, workerData } = opts;
|
|
7903
7903
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
7904
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
7904
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join3(__dirname, "lib", "worker.js");
|
|
7905
7905
|
const worker = new Worker(toExecute, {
|
|
7906
7906
|
...opts.workerOpts,
|
|
7907
7907
|
name: opts.workerOpts?.name || "thread-stream",
|
|
@@ -8367,9 +8367,9 @@ var require_transport = __commonJS({
|
|
|
8367
8367
|
"node_modules/pino/lib/transport.js"(exports, module) {
|
|
8368
8368
|
"use strict";
|
|
8369
8369
|
var { createRequire } = __require("module");
|
|
8370
|
-
var { existsSync } = __require("node:fs");
|
|
8370
|
+
var { existsSync: existsSync2 } = __require("node:fs");
|
|
8371
8371
|
var getCallers = require_caller();
|
|
8372
|
-
var { join:
|
|
8372
|
+
var { join: join3, isAbsolute, sep } = __require("node:path");
|
|
8373
8373
|
var { fileURLToPath } = __require("node:url");
|
|
8374
8374
|
var sleep = require_atomic_sleep();
|
|
8375
8375
|
var onExit = require_on_exit_leak_free();
|
|
@@ -8433,15 +8433,15 @@ var require_transport = __commonJS({
|
|
|
8433
8433
|
if (!unquoted) {
|
|
8434
8434
|
return false;
|
|
8435
8435
|
}
|
|
8436
|
-
let
|
|
8437
|
-
if (
|
|
8436
|
+
let path4 = unquoted;
|
|
8437
|
+
if (path4.startsWith("file://")) {
|
|
8438
8438
|
try {
|
|
8439
|
-
|
|
8439
|
+
path4 = fileURLToPath(path4);
|
|
8440
8440
|
} catch {
|
|
8441
8441
|
return false;
|
|
8442
8442
|
}
|
|
8443
8443
|
}
|
|
8444
|
-
return isAbsolute(
|
|
8444
|
+
return isAbsolute(path4) && !existsSync2(path4);
|
|
8445
8445
|
}
|
|
8446
8446
|
function stripQuotes(value) {
|
|
8447
8447
|
const first = value[0];
|
|
@@ -8522,7 +8522,7 @@ var require_transport = __commonJS({
|
|
|
8522
8522
|
throw new Error("only one of target or targets can be specified");
|
|
8523
8523
|
}
|
|
8524
8524
|
if (targets) {
|
|
8525
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
8525
|
+
target = bundlerOverrides["pino-worker"] || join3(__dirname, "worker.js");
|
|
8526
8526
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
8527
8527
|
return {
|
|
8528
8528
|
...dest,
|
|
@@ -8540,7 +8540,7 @@ var require_transport = __commonJS({
|
|
|
8540
8540
|
});
|
|
8541
8541
|
});
|
|
8542
8542
|
} else if (pipeline) {
|
|
8543
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
8543
|
+
target = bundlerOverrides["pino-worker"] || join3(__dirname, "worker.js");
|
|
8544
8544
|
options.pipelines = [pipeline.map((dest) => {
|
|
8545
8545
|
return {
|
|
8546
8546
|
...dest,
|
|
@@ -8563,7 +8563,7 @@ var require_transport = __commonJS({
|
|
|
8563
8563
|
return origin;
|
|
8564
8564
|
}
|
|
8565
8565
|
if (origin === "pino/file") {
|
|
8566
|
-
return
|
|
8566
|
+
return join3(__dirname, "..", "file.js");
|
|
8567
8567
|
}
|
|
8568
8568
|
let fixTarget2;
|
|
8569
8569
|
for (const filePath of callers) {
|
|
@@ -8766,15 +8766,15 @@ var require_tools = __commonJS({
|
|
|
8766
8766
|
return data + propStr + msgStr + end;
|
|
8767
8767
|
}
|
|
8768
8768
|
}
|
|
8769
|
-
function asChindings(
|
|
8769
|
+
function asChindings(instance2, bindings) {
|
|
8770
8770
|
let value;
|
|
8771
|
-
let data =
|
|
8772
|
-
const stringify2 =
|
|
8773
|
-
const stringifySafe =
|
|
8774
|
-
const stringifiers =
|
|
8771
|
+
let data = instance2[chindingsSym];
|
|
8772
|
+
const stringify2 = instance2[stringifySym];
|
|
8773
|
+
const stringifySafe = instance2[stringifySafeSym];
|
|
8774
|
+
const stringifiers = instance2[stringifiersSym];
|
|
8775
8775
|
const wildcardStringifier = stringifiers[wildcardFirstSym];
|
|
8776
|
-
const serializers =
|
|
8777
|
-
const formatter =
|
|
8776
|
+
const serializers = instance2[serializersSym];
|
|
8777
|
+
const formatter = instance2[formattersSym].bindings;
|
|
8778
8778
|
bindings = formatter(bindings);
|
|
8779
8779
|
for (const key in bindings) {
|
|
8780
8780
|
value = bindings[key];
|
|
@@ -8827,7 +8827,7 @@ var require_tools = __commonJS({
|
|
|
8827
8827
|
}
|
|
8828
8828
|
}
|
|
8829
8829
|
function createArgsNormalizer(defaultOptions) {
|
|
8830
|
-
return function normalizeArgs(
|
|
8830
|
+
return function normalizeArgs(instance2, caller, opts = {}, stream) {
|
|
8831
8831
|
if (typeof opts === "string") {
|
|
8832
8832
|
stream = buildSafeSonicBoom({ dest: opts });
|
|
8833
8833
|
opts = {};
|
|
@@ -8979,16 +8979,16 @@ var require_levels = __commonJS({
|
|
|
8979
8979
|
o[k] = '{"level":' + Number(k);
|
|
8980
8980
|
return o;
|
|
8981
8981
|
}, {});
|
|
8982
|
-
function genLsCache(
|
|
8983
|
-
const formatter =
|
|
8984
|
-
const { labels } =
|
|
8982
|
+
function genLsCache(instance2) {
|
|
8983
|
+
const formatter = instance2[formattersSym].level;
|
|
8984
|
+
const { labels } = instance2.levels;
|
|
8985
8985
|
const cache2 = {};
|
|
8986
8986
|
for (const label in labels) {
|
|
8987
8987
|
const level = formatter(labels[label], Number(label));
|
|
8988
8988
|
cache2[label] = JSON.stringify(level).slice(0, -1);
|
|
8989
8989
|
}
|
|
8990
|
-
|
|
8991
|
-
return
|
|
8990
|
+
instance2[lsCacheSym] = cache2;
|
|
8991
|
+
return instance2;
|
|
8992
8992
|
}
|
|
8993
8993
|
function isStandardLevel(level, useOnlyCustomLevels) {
|
|
8994
8994
|
if (useOnlyCustomLevels) {
|
|
@@ -9233,49 +9233,49 @@ var require_proto = __commonJS({
|
|
|
9233
9233
|
}
|
|
9234
9234
|
const serializers = this[serializersSym];
|
|
9235
9235
|
const formatters = this[formattersSym];
|
|
9236
|
-
const
|
|
9236
|
+
const instance2 = Object.create(this);
|
|
9237
9237
|
if (options == null) {
|
|
9238
|
-
if (
|
|
9239
|
-
|
|
9238
|
+
if (instance2[formattersSym].bindings !== resetChildingsFormatter) {
|
|
9239
|
+
instance2[formattersSym] = buildFormatters(
|
|
9240
9240
|
formatters.level,
|
|
9241
9241
|
resetChildingsFormatter,
|
|
9242
9242
|
formatters.log
|
|
9243
9243
|
);
|
|
9244
9244
|
}
|
|
9245
|
-
|
|
9245
|
+
instance2[chindingsSym] = asChindings(instance2, bindings2);
|
|
9246
9246
|
if (this.onChild !== noop) {
|
|
9247
|
-
this.onChild(
|
|
9247
|
+
this.onChild(instance2);
|
|
9248
9248
|
}
|
|
9249
|
-
return
|
|
9249
|
+
return instance2;
|
|
9250
9250
|
}
|
|
9251
9251
|
if (options.hasOwnProperty("serializers") === true) {
|
|
9252
|
-
|
|
9252
|
+
instance2[serializersSym] = /* @__PURE__ */ Object.create(null);
|
|
9253
9253
|
for (const k in serializers) {
|
|
9254
|
-
|
|
9254
|
+
instance2[serializersSym][k] = serializers[k];
|
|
9255
9255
|
}
|
|
9256
9256
|
const parentSymbols = Object.getOwnPropertySymbols(serializers);
|
|
9257
9257
|
for (var i = 0; i < parentSymbols.length; i++) {
|
|
9258
9258
|
const ks = parentSymbols[i];
|
|
9259
|
-
|
|
9259
|
+
instance2[serializersSym][ks] = serializers[ks];
|
|
9260
9260
|
}
|
|
9261
9261
|
for (const bk in options.serializers) {
|
|
9262
|
-
|
|
9262
|
+
instance2[serializersSym][bk] = options.serializers[bk];
|
|
9263
9263
|
}
|
|
9264
9264
|
const bindingsSymbols = Object.getOwnPropertySymbols(options.serializers);
|
|
9265
9265
|
for (var bi = 0; bi < bindingsSymbols.length; bi++) {
|
|
9266
9266
|
const bks = bindingsSymbols[bi];
|
|
9267
|
-
|
|
9267
|
+
instance2[serializersSym][bks] = options.serializers[bks];
|
|
9268
9268
|
}
|
|
9269
|
-
} else
|
|
9269
|
+
} else instance2[serializersSym] = serializers;
|
|
9270
9270
|
if (options.hasOwnProperty("formatters")) {
|
|
9271
9271
|
const { level, bindings: chindings, log } = options.formatters;
|
|
9272
|
-
|
|
9272
|
+
instance2[formattersSym] = buildFormatters(
|
|
9273
9273
|
level || formatters.level,
|
|
9274
9274
|
chindings || resetChildingsFormatter,
|
|
9275
9275
|
log || formatters.log
|
|
9276
9276
|
);
|
|
9277
9277
|
} else {
|
|
9278
|
-
|
|
9278
|
+
instance2[formattersSym] = buildFormatters(
|
|
9279
9279
|
formatters.level,
|
|
9280
9280
|
resetChildingsFormatter,
|
|
9281
9281
|
formatters.log
|
|
@@ -9283,27 +9283,27 @@ var require_proto = __commonJS({
|
|
|
9283
9283
|
}
|
|
9284
9284
|
if (options.hasOwnProperty("customLevels") === true) {
|
|
9285
9285
|
assertNoLevelCollisions(this.levels, options.customLevels);
|
|
9286
|
-
|
|
9287
|
-
genLsCache(
|
|
9286
|
+
instance2.levels = mappings(options.customLevels, instance2[useOnlyCustomLevelsSym]);
|
|
9287
|
+
genLsCache(instance2);
|
|
9288
9288
|
}
|
|
9289
9289
|
if (typeof options.redact === "object" && options.redact !== null || Array.isArray(options.redact)) {
|
|
9290
|
-
|
|
9291
|
-
const stringifiers = redaction(
|
|
9290
|
+
instance2.redact = options.redact;
|
|
9291
|
+
const stringifiers = redaction(instance2.redact, stringify);
|
|
9292
9292
|
const formatOpts = { stringify: stringifiers[redactFmtSym] };
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
|
|
9293
|
+
instance2[stringifySym] = stringify;
|
|
9294
|
+
instance2[stringifiersSym] = stringifiers;
|
|
9295
|
+
instance2[formatOptsSym] = formatOpts;
|
|
9296
9296
|
}
|
|
9297
9297
|
if (typeof options.msgPrefix === "string") {
|
|
9298
|
-
|
|
9298
|
+
instance2[msgPrefixSym] = (this[msgPrefixSym] || "") + options.msgPrefix;
|
|
9299
9299
|
}
|
|
9300
|
-
|
|
9300
|
+
instance2[chindingsSym] = asChindings(instance2, bindings2);
|
|
9301
9301
|
if (options.level !== void 0 && options.level !== this.level || options.hasOwnProperty("customLevels")) {
|
|
9302
9302
|
const childLevel = options.level || this.level;
|
|
9303
|
-
|
|
9303
|
+
instance2[setLevelSym](childLevel);
|
|
9304
9304
|
}
|
|
9305
|
-
this.onChild(
|
|
9306
|
-
return
|
|
9305
|
+
this.onChild(instance2);
|
|
9306
|
+
return instance2;
|
|
9307
9307
|
}
|
|
9308
9308
|
function bindings() {
|
|
9309
9309
|
const chindings = this[chindingsSym];
|
|
@@ -9543,7 +9543,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
9543
9543
|
return circularValue;
|
|
9544
9544
|
}
|
|
9545
9545
|
let res = "";
|
|
9546
|
-
let
|
|
9546
|
+
let join3 = ",";
|
|
9547
9547
|
const originalIndentation = indentation;
|
|
9548
9548
|
if (Array.isArray(value)) {
|
|
9549
9549
|
if (value.length === 0) {
|
|
@@ -9557,7 +9557,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
9557
9557
|
indentation += spacer;
|
|
9558
9558
|
res += `
|
|
9559
9559
|
${indentation}`;
|
|
9560
|
-
|
|
9560
|
+
join3 = `,
|
|
9561
9561
|
${indentation}`;
|
|
9562
9562
|
}
|
|
9563
9563
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -9565,13 +9565,13 @@ ${indentation}`;
|
|
|
9565
9565
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
9566
9566
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
9567
9567
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
9568
|
-
res +=
|
|
9568
|
+
res += join3;
|
|
9569
9569
|
}
|
|
9570
9570
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
9571
9571
|
res += tmp !== void 0 ? tmp : "null";
|
|
9572
9572
|
if (value.length - 1 > maximumBreadth) {
|
|
9573
9573
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
9574
|
-
res += `${
|
|
9574
|
+
res += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
9575
9575
|
}
|
|
9576
9576
|
if (spacer !== "") {
|
|
9577
9577
|
res += `
|
|
@@ -9592,7 +9592,7 @@ ${originalIndentation}`;
|
|
|
9592
9592
|
let separator = "";
|
|
9593
9593
|
if (spacer !== "") {
|
|
9594
9594
|
indentation += spacer;
|
|
9595
|
-
|
|
9595
|
+
join3 = `,
|
|
9596
9596
|
${indentation}`;
|
|
9597
9597
|
whitespace = " ";
|
|
9598
9598
|
}
|
|
@@ -9606,13 +9606,13 @@ ${indentation}`;
|
|
|
9606
9606
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
9607
9607
|
if (tmp !== void 0) {
|
|
9608
9608
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
9609
|
-
separator =
|
|
9609
|
+
separator = join3;
|
|
9610
9610
|
}
|
|
9611
9611
|
}
|
|
9612
9612
|
if (keyLength > maximumBreadth) {
|
|
9613
9613
|
const removedKeys = keyLength - maximumBreadth;
|
|
9614
9614
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
9615
|
-
separator =
|
|
9615
|
+
separator = join3;
|
|
9616
9616
|
}
|
|
9617
9617
|
if (spacer !== "" && separator.length > 1) {
|
|
9618
9618
|
res = `
|
|
@@ -9653,7 +9653,7 @@ ${originalIndentation}`;
|
|
|
9653
9653
|
}
|
|
9654
9654
|
const originalIndentation = indentation;
|
|
9655
9655
|
let res = "";
|
|
9656
|
-
let
|
|
9656
|
+
let join3 = ",";
|
|
9657
9657
|
if (Array.isArray(value)) {
|
|
9658
9658
|
if (value.length === 0) {
|
|
9659
9659
|
return "[]";
|
|
@@ -9666,7 +9666,7 @@ ${originalIndentation}`;
|
|
|
9666
9666
|
indentation += spacer;
|
|
9667
9667
|
res += `
|
|
9668
9668
|
${indentation}`;
|
|
9669
|
-
|
|
9669
|
+
join3 = `,
|
|
9670
9670
|
${indentation}`;
|
|
9671
9671
|
}
|
|
9672
9672
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -9674,13 +9674,13 @@ ${indentation}`;
|
|
|
9674
9674
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
9675
9675
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
9676
9676
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
9677
|
-
res +=
|
|
9677
|
+
res += join3;
|
|
9678
9678
|
}
|
|
9679
9679
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
9680
9680
|
res += tmp !== void 0 ? tmp : "null";
|
|
9681
9681
|
if (value.length - 1 > maximumBreadth) {
|
|
9682
9682
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
9683
|
-
res += `${
|
|
9683
|
+
res += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
9684
9684
|
}
|
|
9685
9685
|
if (spacer !== "") {
|
|
9686
9686
|
res += `
|
|
@@ -9693,7 +9693,7 @@ ${originalIndentation}`;
|
|
|
9693
9693
|
let whitespace = "";
|
|
9694
9694
|
if (spacer !== "") {
|
|
9695
9695
|
indentation += spacer;
|
|
9696
|
-
|
|
9696
|
+
join3 = `,
|
|
9697
9697
|
${indentation}`;
|
|
9698
9698
|
whitespace = " ";
|
|
9699
9699
|
}
|
|
@@ -9702,7 +9702,7 @@ ${indentation}`;
|
|
|
9702
9702
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
9703
9703
|
if (tmp !== void 0) {
|
|
9704
9704
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
9705
|
-
separator =
|
|
9705
|
+
separator = join3;
|
|
9706
9706
|
}
|
|
9707
9707
|
}
|
|
9708
9708
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -9760,20 +9760,20 @@ ${originalIndentation}`;
|
|
|
9760
9760
|
indentation += spacer;
|
|
9761
9761
|
let res2 = `
|
|
9762
9762
|
${indentation}`;
|
|
9763
|
-
const
|
|
9763
|
+
const join4 = `,
|
|
9764
9764
|
${indentation}`;
|
|
9765
9765
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
9766
9766
|
let i = 0;
|
|
9767
9767
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
9768
9768
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
9769
9769
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
9770
|
-
res2 +=
|
|
9770
|
+
res2 += join4;
|
|
9771
9771
|
}
|
|
9772
9772
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
9773
9773
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
9774
9774
|
if (value.length - 1 > maximumBreadth) {
|
|
9775
9775
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
9776
|
-
res2 += `${
|
|
9776
|
+
res2 += `${join4}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
9777
9777
|
}
|
|
9778
9778
|
res2 += `
|
|
9779
9779
|
${originalIndentation}`;
|
|
@@ -9789,16 +9789,16 @@ ${originalIndentation}`;
|
|
|
9789
9789
|
return '"[Object]"';
|
|
9790
9790
|
}
|
|
9791
9791
|
indentation += spacer;
|
|
9792
|
-
const
|
|
9792
|
+
const join3 = `,
|
|
9793
9793
|
${indentation}`;
|
|
9794
9794
|
let res = "";
|
|
9795
9795
|
let separator = "";
|
|
9796
9796
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
9797
9797
|
if (isTypedArrayWithEntries(value)) {
|
|
9798
|
-
res += stringifyTypedArray(value,
|
|
9798
|
+
res += stringifyTypedArray(value, join3, maximumBreadth);
|
|
9799
9799
|
keys = keys.slice(value.length);
|
|
9800
9800
|
maximumPropertiesToStringify -= value.length;
|
|
9801
|
-
separator =
|
|
9801
|
+
separator = join3;
|
|
9802
9802
|
}
|
|
9803
9803
|
if (deterministic) {
|
|
9804
9804
|
keys = sort(keys, comparator);
|
|
@@ -9809,13 +9809,13 @@ ${indentation}`;
|
|
|
9809
9809
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
9810
9810
|
if (tmp !== void 0) {
|
|
9811
9811
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
9812
|
-
separator =
|
|
9812
|
+
separator = join3;
|
|
9813
9813
|
}
|
|
9814
9814
|
}
|
|
9815
9815
|
if (keyLength > maximumBreadth) {
|
|
9816
9816
|
const removedKeys = keyLength - maximumBreadth;
|
|
9817
9817
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
9818
|
-
separator =
|
|
9818
|
+
separator = join3;
|
|
9819
9819
|
}
|
|
9820
9820
|
if (separator !== "") {
|
|
9821
9821
|
res = `
|
|
@@ -10135,7 +10135,7 @@ var require_multistream = __commonJS({
|
|
|
10135
10135
|
var require_pino = __commonJS({
|
|
10136
10136
|
"node_modules/pino/pino.js"(exports, module) {
|
|
10137
10137
|
"use strict";
|
|
10138
|
-
var
|
|
10138
|
+
var os2 = __require("node:os");
|
|
10139
10139
|
var stdSerializers = require_pino_std_serializers();
|
|
10140
10140
|
var caller = require_caller();
|
|
10141
10141
|
var redaction = require_redaction();
|
|
@@ -10182,7 +10182,7 @@ var require_pino = __commonJS({
|
|
|
10182
10182
|
} = symbols;
|
|
10183
10183
|
var { epochTime, nullTime } = time;
|
|
10184
10184
|
var { pid } = process;
|
|
10185
|
-
var hostname =
|
|
10185
|
+
var hostname = os2.hostname();
|
|
10186
10186
|
var defaultErrorSerializer = stdSerializers.err;
|
|
10187
10187
|
var defaultOptions = {
|
|
10188
10188
|
level: "info",
|
|
@@ -10219,8 +10219,8 @@ var require_pino = __commonJS({
|
|
|
10219
10219
|
var normalize = createArgsNormalizer(defaultOptions);
|
|
10220
10220
|
var serializers = Object.assign(/* @__PURE__ */ Object.create(null), stdSerializers);
|
|
10221
10221
|
function pino(...args) {
|
|
10222
|
-
const
|
|
10223
|
-
const { opts, stream } = normalize(
|
|
10222
|
+
const instance2 = {};
|
|
10223
|
+
const { opts, stream } = normalize(instance2, caller(), ...args);
|
|
10224
10224
|
if (opts.level && typeof opts.level === "string" && DEFAULT_LEVELS[opts.level.toLowerCase()] !== void 0) opts.level = opts.level.toLowerCase();
|
|
10225
10225
|
const {
|
|
10226
10226
|
redact,
|
|
@@ -10288,7 +10288,7 @@ var require_pino = __commonJS({
|
|
|
10288
10288
|
}
|
|
10289
10289
|
assertLevelComparison(levelComparison);
|
|
10290
10290
|
const levelCompFunc = genLevelComparison(levelComparison);
|
|
10291
|
-
Object.assign(
|
|
10291
|
+
Object.assign(instance2, {
|
|
10292
10292
|
levels,
|
|
10293
10293
|
[levelCompSym]: levelCompFunc,
|
|
10294
10294
|
[useOnlyCustomLevelsSym]: useOnlyCustomLevels,
|
|
@@ -10315,10 +10315,10 @@ var require_pino = __commonJS({
|
|
|
10315
10315
|
onChild,
|
|
10316
10316
|
[msgPrefixSym]: msgPrefix
|
|
10317
10317
|
});
|
|
10318
|
-
Object.setPrototypeOf(
|
|
10319
|
-
genLsCache(
|
|
10320
|
-
|
|
10321
|
-
return
|
|
10318
|
+
Object.setPrototypeOf(instance2, proto());
|
|
10319
|
+
genLsCache(instance2);
|
|
10320
|
+
instance2[setLevelSym](level);
|
|
10321
|
+
return instance2;
|
|
10322
10322
|
}
|
|
10323
10323
|
module.exports = pino;
|
|
10324
10324
|
module.exports.destination = (dest = process.stdout.fd) => {
|
|
@@ -11048,18 +11048,18 @@ var require_decorate = __commonJS({
|
|
|
11048
11048
|
FST_ERR_DEC_DEPENDENCY_INVALID_TYPE,
|
|
11049
11049
|
FST_ERR_DEC_UNDECLARED
|
|
11050
11050
|
} = require_errors2();
|
|
11051
|
-
function decorate(
|
|
11052
|
-
if (Object.hasOwn(
|
|
11051
|
+
function decorate(instance2, name, fn, dependencies) {
|
|
11052
|
+
if (Object.hasOwn(instance2, name)) {
|
|
11053
11053
|
throw new FST_ERR_DEC_ALREADY_PRESENT(name);
|
|
11054
11054
|
}
|
|
11055
|
-
checkDependencies(
|
|
11055
|
+
checkDependencies(instance2, name, dependencies);
|
|
11056
11056
|
if (fn && (typeof fn.getter === "function" || typeof fn.setter === "function")) {
|
|
11057
|
-
Object.defineProperty(
|
|
11057
|
+
Object.defineProperty(instance2, name, {
|
|
11058
11058
|
get: fn.getter,
|
|
11059
11059
|
set: fn.setter
|
|
11060
11060
|
});
|
|
11061
11061
|
} else {
|
|
11062
|
-
|
|
11062
|
+
instance2[name] = fn;
|
|
11063
11063
|
}
|
|
11064
11064
|
}
|
|
11065
11065
|
function getInstanceDecorator(name) {
|
|
@@ -11072,19 +11072,19 @@ var require_decorate = __commonJS({
|
|
|
11072
11072
|
return this[name];
|
|
11073
11073
|
}
|
|
11074
11074
|
function decorateConstructor(konstructor, name, fn, dependencies) {
|
|
11075
|
-
const
|
|
11076
|
-
if (Object.hasOwn(
|
|
11075
|
+
const instance2 = konstructor.prototype;
|
|
11076
|
+
if (Object.hasOwn(instance2, name) || hasKey(konstructor, name) || hasInstanceProperty(konstructor, name)) {
|
|
11077
11077
|
throw new FST_ERR_DEC_ALREADY_PRESENT(name);
|
|
11078
11078
|
}
|
|
11079
11079
|
konstructor[kHasBeenDecorated] = true;
|
|
11080
11080
|
checkDependencies(konstructor, name, dependencies);
|
|
11081
11081
|
if (fn && (typeof fn.getter === "function" || typeof fn.setter === "function")) {
|
|
11082
|
-
Object.defineProperty(
|
|
11082
|
+
Object.defineProperty(instance2, name, {
|
|
11083
11083
|
get: fn.getter,
|
|
11084
11084
|
set: fn.setter
|
|
11085
11085
|
});
|
|
11086
11086
|
} else if (typeof fn === "function") {
|
|
11087
|
-
|
|
11087
|
+
instance2[name] = fn;
|
|
11088
11088
|
} else {
|
|
11089
11089
|
konstructor.props.push({ key: name, value: fn });
|
|
11090
11090
|
}
|
|
@@ -11099,11 +11099,11 @@ var require_decorate = __commonJS({
|
|
|
11099
11099
|
decorate(this, name, fn, dependencies);
|
|
11100
11100
|
return this;
|
|
11101
11101
|
}
|
|
11102
|
-
function checkExistence(
|
|
11102
|
+
function checkExistence(instance2, name) {
|
|
11103
11103
|
if (name) {
|
|
11104
|
-
return name in
|
|
11104
|
+
return name in instance2 || instance2.prototype && name in instance2.prototype || hasKey(instance2, name);
|
|
11105
11105
|
}
|
|
11106
|
-
return
|
|
11106
|
+
return instance2 in this;
|
|
11107
11107
|
}
|
|
11108
11108
|
function hasKey(fn, name) {
|
|
11109
11109
|
return fn.props ? fn.props.some((p) => p.key === name) : false;
|
|
@@ -11126,7 +11126,7 @@ var require_decorate = __commonJS({
|
|
|
11126
11126
|
if (name && hasInstanceProperty(this[kReply], name)) return true;
|
|
11127
11127
|
return checkExistence(this[kReply].prototype, name);
|
|
11128
11128
|
}
|
|
11129
|
-
function checkDependencies(
|
|
11129
|
+
function checkDependencies(instance2, name, deps) {
|
|
11130
11130
|
if (deps === void 0 || deps === null) {
|
|
11131
11131
|
return;
|
|
11132
11132
|
}
|
|
@@ -11134,7 +11134,7 @@ var require_decorate = __commonJS({
|
|
|
11134
11134
|
throw new FST_ERR_DEC_DEPENDENCY_INVALID_TYPE(name);
|
|
11135
11135
|
}
|
|
11136
11136
|
for (let i = 0; i !== deps.length; ++i) {
|
|
11137
|
-
if (!checkExistence(
|
|
11137
|
+
if (!checkExistence(instance2, deps[i]) && !hasInstanceProperty(instance2, deps[i])) {
|
|
11138
11138
|
throw new FST_ERR_DEC_MISSING_DEPENDENCY(deps[i]);
|
|
11139
11139
|
}
|
|
11140
11140
|
}
|
|
@@ -11151,8 +11151,8 @@ var require_decorate = __commonJS({
|
|
|
11151
11151
|
decorateConstructor(this[kRequest], name, fn, dependencies);
|
|
11152
11152
|
return this;
|
|
11153
11153
|
}
|
|
11154
|
-
function assertNotStarted(
|
|
11155
|
-
if (
|
|
11154
|
+
function assertNotStarted(instance2, name) {
|
|
11155
|
+
if (instance2[kState].started) {
|
|
11156
11156
|
throw new FST_ERR_DEC_AFTER_START(name);
|
|
11157
11157
|
}
|
|
11158
11158
|
}
|
|
@@ -17117,8 +17117,8 @@ var require_utils = __commonJS({
|
|
|
17117
17117
|
}
|
|
17118
17118
|
return ind;
|
|
17119
17119
|
}
|
|
17120
|
-
function removeDotSegments(
|
|
17121
|
-
let input =
|
|
17120
|
+
function removeDotSegments(path4) {
|
|
17121
|
+
let input = path4;
|
|
17122
17122
|
const output = [];
|
|
17123
17123
|
let nextSlash = -1;
|
|
17124
17124
|
let len = 0;
|
|
@@ -17370,8 +17370,8 @@ var require_schemes = __commonJS({
|
|
|
17370
17370
|
wsComponent.secure = void 0;
|
|
17371
17371
|
}
|
|
17372
17372
|
if (wsComponent.resourceName) {
|
|
17373
|
-
const [
|
|
17374
|
-
wsComponent.path =
|
|
17373
|
+
const [path4, query2] = wsComponent.resourceName.split("?");
|
|
17374
|
+
wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
|
|
17375
17375
|
wsComponent.query = query2;
|
|
17376
17376
|
wsComponent.resourceName = void 0;
|
|
17377
17377
|
}
|
|
@@ -17430,7 +17430,7 @@ var require_schemes = __commonJS({
|
|
|
17430
17430
|
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
17431
17431
|
return urnComponent;
|
|
17432
17432
|
}
|
|
17433
|
-
var
|
|
17433
|
+
var http3 = (
|
|
17434
17434
|
/** @type {SchemeHandler} */
|
|
17435
17435
|
{
|
|
17436
17436
|
scheme: "http",
|
|
@@ -17443,7 +17443,7 @@ var require_schemes = __commonJS({
|
|
|
17443
17443
|
/** @type {SchemeHandler} */
|
|
17444
17444
|
{
|
|
17445
17445
|
scheme: "https",
|
|
17446
|
-
domainHost:
|
|
17446
|
+
domainHost: http3.domainHost,
|
|
17447
17447
|
parse: httpParse,
|
|
17448
17448
|
serialize: httpSerialize
|
|
17449
17449
|
}
|
|
@@ -17487,7 +17487,7 @@ var require_schemes = __commonJS({
|
|
|
17487
17487
|
var SCHEMES = (
|
|
17488
17488
|
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
17489
17489
|
{
|
|
17490
|
-
http,
|
|
17490
|
+
http: http3,
|
|
17491
17491
|
https,
|
|
17492
17492
|
ws,
|
|
17493
17493
|
wss: wss2,
|
|
@@ -22308,8 +22308,8 @@ var require_utils2 = __commonJS({
|
|
|
22308
22308
|
}
|
|
22309
22309
|
return ind;
|
|
22310
22310
|
}
|
|
22311
|
-
function removeDotSegments(
|
|
22312
|
-
let input =
|
|
22311
|
+
function removeDotSegments(path4) {
|
|
22312
|
+
let input = path4;
|
|
22313
22313
|
const output = [];
|
|
22314
22314
|
let nextSlash = -1;
|
|
22315
22315
|
let len = 0;
|
|
@@ -22654,8 +22654,8 @@ var require_schemes2 = __commonJS({
|
|
|
22654
22654
|
wsComponent.secure = void 0;
|
|
22655
22655
|
}
|
|
22656
22656
|
if (wsComponent.resourceName) {
|
|
22657
|
-
const [
|
|
22658
|
-
wsComponent.path =
|
|
22657
|
+
const [path4, query2] = wsComponent.resourceName.split("?");
|
|
22658
|
+
wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
|
|
22659
22659
|
wsComponent.query = query2;
|
|
22660
22660
|
wsComponent.resourceName = void 0;
|
|
22661
22661
|
}
|
|
@@ -22714,7 +22714,7 @@ var require_schemes2 = __commonJS({
|
|
|
22714
22714
|
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
22715
22715
|
return urnComponent;
|
|
22716
22716
|
}
|
|
22717
|
-
var
|
|
22717
|
+
var http3 = (
|
|
22718
22718
|
/** @type {SchemeHandler} */
|
|
22719
22719
|
{
|
|
22720
22720
|
scheme: "http",
|
|
@@ -22727,7 +22727,7 @@ var require_schemes2 = __commonJS({
|
|
|
22727
22727
|
/** @type {SchemeHandler} */
|
|
22728
22728
|
{
|
|
22729
22729
|
scheme: "https",
|
|
22730
|
-
domainHost:
|
|
22730
|
+
domainHost: http3.domainHost,
|
|
22731
22731
|
parse: httpParse,
|
|
22732
22732
|
serialize: httpSerialize
|
|
22733
22733
|
}
|
|
@@ -22771,7 +22771,7 @@ var require_schemes2 = __commonJS({
|
|
|
22771
22771
|
var SCHEMES = (
|
|
22772
22772
|
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
22773
22773
|
{
|
|
22774
|
-
http,
|
|
22774
|
+
http: http3,
|
|
22775
22775
|
https,
|
|
22776
22776
|
ws,
|
|
22777
22777
|
wss: wss2,
|
|
@@ -24139,8 +24139,8 @@ var require_utils3 = __commonJS({
|
|
|
24139
24139
|
}
|
|
24140
24140
|
return ind;
|
|
24141
24141
|
}
|
|
24142
|
-
function removeDotSegments(
|
|
24143
|
-
let input =
|
|
24142
|
+
function removeDotSegments(path4) {
|
|
24143
|
+
let input = path4;
|
|
24144
24144
|
const output = [];
|
|
24145
24145
|
let nextSlash = -1;
|
|
24146
24146
|
let len = 0;
|
|
@@ -24485,8 +24485,8 @@ var require_schemes3 = __commonJS({
|
|
|
24485
24485
|
wsComponent.secure = void 0;
|
|
24486
24486
|
}
|
|
24487
24487
|
if (wsComponent.resourceName) {
|
|
24488
|
-
const [
|
|
24489
|
-
wsComponent.path =
|
|
24488
|
+
const [path4, query2] = wsComponent.resourceName.split("?");
|
|
24489
|
+
wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
|
|
24490
24490
|
wsComponent.query = query2;
|
|
24491
24491
|
wsComponent.resourceName = void 0;
|
|
24492
24492
|
}
|
|
@@ -24545,7 +24545,7 @@ var require_schemes3 = __commonJS({
|
|
|
24545
24545
|
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
24546
24546
|
return urnComponent;
|
|
24547
24547
|
}
|
|
24548
|
-
var
|
|
24548
|
+
var http3 = (
|
|
24549
24549
|
/** @type {SchemeHandler} */
|
|
24550
24550
|
{
|
|
24551
24551
|
scheme: "http",
|
|
@@ -24558,7 +24558,7 @@ var require_schemes3 = __commonJS({
|
|
|
24558
24558
|
/** @type {SchemeHandler} */
|
|
24559
24559
|
{
|
|
24560
24560
|
scheme: "https",
|
|
24561
|
-
domainHost:
|
|
24561
|
+
domainHost: http3.domainHost,
|
|
24562
24562
|
parse: httpParse,
|
|
24563
24563
|
serialize: httpSerialize
|
|
24564
24564
|
}
|
|
@@ -24602,7 +24602,7 @@ var require_schemes3 = __commonJS({
|
|
|
24602
24602
|
var SCHEMES = (
|
|
24603
24603
|
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
24604
24604
|
{
|
|
24605
|
-
http,
|
|
24605
|
+
http: http3,
|
|
24606
24606
|
https,
|
|
24607
24607
|
ws,
|
|
24608
24608
|
wss: wss2,
|
|
@@ -29958,12 +29958,12 @@ var require_plugin_utils = __commonJS({
|
|
|
29958
29958
|
Request: existRequest,
|
|
29959
29959
|
Reply: existReply
|
|
29960
29960
|
};
|
|
29961
|
-
function _checkDecorators(that,
|
|
29961
|
+
function _checkDecorators(that, instance2, decorators, name) {
|
|
29962
29962
|
assert(Array.isArray(decorators), "The decorators should be an array of strings");
|
|
29963
29963
|
decorators.forEach((decorator) => {
|
|
29964
29964
|
const withPluginName = typeof name === "string" ? ` required by '${name}'` : "";
|
|
29965
|
-
if (!checks[
|
|
29966
|
-
throw new FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE(decorator, withPluginName,
|
|
29965
|
+
if (!checks[instance2].call(that, decorator)) {
|
|
29966
|
+
throw new FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE(decorator, withPluginName, instance2);
|
|
29967
29967
|
}
|
|
29968
29968
|
});
|
|
29969
29969
|
}
|
|
@@ -32003,13 +32003,13 @@ var require_node = __commonJS({
|
|
|
32003
32003
|
this.staticChildrenNodes[index] = node;
|
|
32004
32004
|
}
|
|
32005
32005
|
}
|
|
32006
|
-
findStaticMatchingChild(
|
|
32007
|
-
const charCode =
|
|
32006
|
+
findStaticMatchingChild(path4, pathIndex) {
|
|
32007
|
+
const charCode = path4.charCodeAt(pathIndex);
|
|
32008
32008
|
const charCodes = this.staticChildrenCharCodes;
|
|
32009
32009
|
for (let i = 0; i < charCodes.length; i++) {
|
|
32010
32010
|
if (charCodes[i] === charCode) {
|
|
32011
32011
|
const staticChild = this.staticChildrenNodes[i];
|
|
32012
|
-
if (staticChild.matchPrefix(
|
|
32012
|
+
if (staticChild.matchPrefix(path4, pathIndex)) {
|
|
32013
32013
|
return staticChild;
|
|
32014
32014
|
}
|
|
32015
32015
|
return null;
|
|
@@ -32017,34 +32017,34 @@ var require_node = __commonJS({
|
|
|
32017
32017
|
}
|
|
32018
32018
|
return null;
|
|
32019
32019
|
}
|
|
32020
|
-
getStaticChild(
|
|
32021
|
-
if (
|
|
32020
|
+
getStaticChild(path4, pathIndex = 0) {
|
|
32021
|
+
if (path4.length === pathIndex) {
|
|
32022
32022
|
return this;
|
|
32023
32023
|
}
|
|
32024
|
-
const staticChild = this.findStaticMatchingChild(
|
|
32024
|
+
const staticChild = this.findStaticMatchingChild(path4, pathIndex);
|
|
32025
32025
|
if (staticChild) {
|
|
32026
|
-
return staticChild.getStaticChild(
|
|
32026
|
+
return staticChild.getStaticChild(path4, pathIndex + staticChild.prefix.length);
|
|
32027
32027
|
}
|
|
32028
32028
|
return null;
|
|
32029
32029
|
}
|
|
32030
|
-
createStaticChild(
|
|
32031
|
-
if (
|
|
32030
|
+
createStaticChild(path4) {
|
|
32031
|
+
if (path4.length === 0) {
|
|
32032
32032
|
return this;
|
|
32033
32033
|
}
|
|
32034
|
-
const childIndex = this.staticChildrenCharCodes.indexOf(
|
|
32034
|
+
const childIndex = this.staticChildrenCharCodes.indexOf(path4.charCodeAt(0));
|
|
32035
32035
|
let staticChild = childIndex === -1 ? void 0 : this.staticChildrenNodes[childIndex];
|
|
32036
32036
|
if (staticChild) {
|
|
32037
32037
|
let i = 1;
|
|
32038
32038
|
for (; i < staticChild.prefix.length; i++) {
|
|
32039
|
-
if (
|
|
32039
|
+
if (path4.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) {
|
|
32040
32040
|
staticChild = staticChild.split(this, i);
|
|
32041
32041
|
break;
|
|
32042
32042
|
}
|
|
32043
32043
|
}
|
|
32044
|
-
return staticChild.createStaticChild(
|
|
32044
|
+
return staticChild.createStaticChild(path4.slice(i));
|
|
32045
32045
|
}
|
|
32046
|
-
const node = new StaticNode(
|
|
32047
|
-
this.setStaticChild(
|
|
32046
|
+
const node = new StaticNode(path4);
|
|
32047
|
+
this.setStaticChild(path4.charAt(0), node);
|
|
32048
32048
|
return node;
|
|
32049
32049
|
}
|
|
32050
32050
|
};
|
|
@@ -32104,8 +32104,8 @@ var require_node = __commonJS({
|
|
|
32104
32104
|
parentNode.setStaticChild(parentPrefix.charAt(0), staticNode);
|
|
32105
32105
|
return staticNode;
|
|
32106
32106
|
}
|
|
32107
|
-
getNextNode(
|
|
32108
|
-
let node = this.findStaticMatchingChild(
|
|
32107
|
+
getNextNode(path4, pathIndex, nodeStack, paramsCount) {
|
|
32108
|
+
let node = this.findStaticMatchingChild(path4, pathIndex);
|
|
32109
32109
|
let parametricBrotherNodeIndex = 0;
|
|
32110
32110
|
if (node === null) {
|
|
32111
32111
|
if (this.parametricChildren.length === 0) {
|
|
@@ -32152,8 +32152,8 @@ var require_node = __commonJS({
|
|
|
32152
32152
|
this.kind = NODE_TYPES.PARAMETRIC;
|
|
32153
32153
|
this.nodePaths = /* @__PURE__ */ new Set([nodePath]);
|
|
32154
32154
|
}
|
|
32155
|
-
getNextNode(
|
|
32156
|
-
return this.findStaticMatchingChild(
|
|
32155
|
+
getNextNode(path4, pathIndex) {
|
|
32156
|
+
return this.findStaticMatchingChild(path4, pathIndex);
|
|
32157
32157
|
}
|
|
32158
32158
|
};
|
|
32159
32159
|
var WildcardNode = class extends Node {
|
|
@@ -32509,81 +32509,81 @@ var require_url_sanitizer = __commonJS({
|
|
|
32509
32509
|
return String.fromCharCode(charCode);
|
|
32510
32510
|
}
|
|
32511
32511
|
var MIN_NATIVE_SCAN_LENGTH = 12;
|
|
32512
|
-
function safeDecodeURI(
|
|
32513
|
-
if (
|
|
32514
|
-
return safeDecodeURINativeScan(
|
|
32512
|
+
function safeDecodeURI(path4, useSemicolonDelimiter) {
|
|
32513
|
+
if (path4.length >= MIN_NATIVE_SCAN_LENGTH) {
|
|
32514
|
+
return safeDecodeURINativeScan(path4, useSemicolonDelimiter);
|
|
32515
32515
|
}
|
|
32516
|
-
return safeDecodeURICharScan(
|
|
32516
|
+
return safeDecodeURICharScan(path4, useSemicolonDelimiter, 1);
|
|
32517
32517
|
}
|
|
32518
|
-
function safeDecodeURINativeScan(
|
|
32519
|
-
const percentIndex =
|
|
32520
|
-
let delimIndex =
|
|
32521
|
-
const hashIndex =
|
|
32518
|
+
function safeDecodeURINativeScan(path4, useSemicolonDelimiter) {
|
|
32519
|
+
const percentIndex = path4.indexOf("%", 1);
|
|
32520
|
+
let delimIndex = path4.indexOf("?", 1);
|
|
32521
|
+
const hashIndex = path4.indexOf("#", 1);
|
|
32522
32522
|
if (hashIndex !== -1 && (delimIndex === -1 || hashIndex < delimIndex)) {
|
|
32523
32523
|
delimIndex = hashIndex;
|
|
32524
32524
|
}
|
|
32525
32525
|
if (useSemicolonDelimiter) {
|
|
32526
|
-
const semicolonIndex =
|
|
32526
|
+
const semicolonIndex = path4.indexOf(";", 1);
|
|
32527
32527
|
if (semicolonIndex !== -1 && (delimIndex === -1 || semicolonIndex < delimIndex)) {
|
|
32528
32528
|
delimIndex = semicolonIndex;
|
|
32529
32529
|
}
|
|
32530
32530
|
}
|
|
32531
32531
|
if (percentIndex === -1 || delimIndex !== -1 && percentIndex > delimIndex) {
|
|
32532
32532
|
if (delimIndex === -1) {
|
|
32533
|
-
return { path:
|
|
32533
|
+
return { path: path4, querystring: "", shouldDecodeParam: false };
|
|
32534
32534
|
}
|
|
32535
32535
|
return {
|
|
32536
|
-
path:
|
|
32537
|
-
querystring:
|
|
32536
|
+
path: path4.slice(0, delimIndex),
|
|
32537
|
+
querystring: path4.slice(delimIndex + 1),
|
|
32538
32538
|
shouldDecodeParam: false
|
|
32539
32539
|
};
|
|
32540
32540
|
}
|
|
32541
|
-
return safeDecodeURIPercentScan(
|
|
32541
|
+
return safeDecodeURIPercentScan(path4, useSemicolonDelimiter, percentIndex);
|
|
32542
32542
|
}
|
|
32543
|
-
function safeDecodeURICharScan(
|
|
32544
|
-
for (let i = startIndex; i <
|
|
32545
|
-
const charCode =
|
|
32543
|
+
function safeDecodeURICharScan(path4, useSemicolonDelimiter, startIndex) {
|
|
32544
|
+
for (let i = startIndex; i < path4.length; i++) {
|
|
32545
|
+
const charCode = path4.charCodeAt(i);
|
|
32546
32546
|
if (charCode === 37) {
|
|
32547
|
-
return safeDecodeURIPercentScan(
|
|
32547
|
+
return safeDecodeURIPercentScan(path4, useSemicolonDelimiter, i);
|
|
32548
32548
|
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
32549
32549
|
return {
|
|
32550
|
-
path:
|
|
32551
|
-
querystring:
|
|
32550
|
+
path: path4.slice(0, i),
|
|
32551
|
+
querystring: path4.slice(i + 1),
|
|
32552
32552
|
shouldDecodeParam: false
|
|
32553
32553
|
};
|
|
32554
32554
|
}
|
|
32555
32555
|
}
|
|
32556
|
-
return { path:
|
|
32556
|
+
return { path: path4, querystring: "", shouldDecodeParam: false };
|
|
32557
32557
|
}
|
|
32558
|
-
function reencodePercentChar(
|
|
32559
|
-
return
|
|
32558
|
+
function reencodePercentChar(path4, index) {
|
|
32559
|
+
return path4.slice(0, index + 1) + "25" + path4.slice(index + 1);
|
|
32560
32560
|
}
|
|
32561
|
-
function safeDecodeURIPercentScan(
|
|
32561
|
+
function safeDecodeURIPercentScan(path4, useSemicolonDelimiter, startIndex) {
|
|
32562
32562
|
let shouldDecode = false;
|
|
32563
32563
|
let shouldDecodeParam = false;
|
|
32564
32564
|
let querystring = "";
|
|
32565
|
-
for (let i = startIndex; i <
|
|
32566
|
-
const charCode =
|
|
32565
|
+
for (let i = startIndex; i < path4.length; i++) {
|
|
32566
|
+
const charCode = path4.charCodeAt(i);
|
|
32567
32567
|
if (charCode === 37) {
|
|
32568
|
-
const componentCharCode = decodeComponentCharCode(
|
|
32568
|
+
const componentCharCode = decodeComponentCharCode(path4.charCodeAt(i + 1), path4.charCodeAt(i + 2));
|
|
32569
32569
|
if (componentCharCode === 0) {
|
|
32570
32570
|
shouldDecode = true;
|
|
32571
32571
|
} else {
|
|
32572
32572
|
shouldDecodeParam = true;
|
|
32573
32573
|
if (componentCharCode === 37) {
|
|
32574
32574
|
shouldDecode = true;
|
|
32575
|
-
|
|
32575
|
+
path4 = reencodePercentChar(path4, i);
|
|
32576
32576
|
i += 2;
|
|
32577
32577
|
}
|
|
32578
32578
|
i += 2;
|
|
32579
32579
|
}
|
|
32580
32580
|
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
32581
|
-
querystring =
|
|
32582
|
-
|
|
32581
|
+
querystring = path4.slice(i + 1);
|
|
32582
|
+
path4 = path4.slice(0, i);
|
|
32583
32583
|
break;
|
|
32584
32584
|
}
|
|
32585
32585
|
}
|
|
32586
|
-
const decodedPath = shouldDecode ? decodeURI(
|
|
32586
|
+
const decodedPath = shouldDecode ? decodeURI(path4) : path4;
|
|
32587
32587
|
return { path: decodedPath, querystring, shouldDecodeParam };
|
|
32588
32588
|
}
|
|
32589
32589
|
function safeDecodeURIComponent(uriComponent) {
|
|
@@ -32678,7 +32678,7 @@ var require_find_my_way = __commonJS({
|
|
|
32678
32678
|
this.trees = /* @__PURE__ */ Object.create(null);
|
|
32679
32679
|
this._treeGET = null;
|
|
32680
32680
|
}
|
|
32681
|
-
Router.prototype.on = function on(method,
|
|
32681
|
+
Router.prototype.on = function on(method, path4, opts, handler, store) {
|
|
32682
32682
|
if (typeof opts === "function") {
|
|
32683
32683
|
if (handler !== void 0) {
|
|
32684
32684
|
store = handler;
|
|
@@ -32686,34 +32686,34 @@ var require_find_my_way = __commonJS({
|
|
|
32686
32686
|
handler = opts;
|
|
32687
32687
|
opts = {};
|
|
32688
32688
|
}
|
|
32689
|
-
assert(typeof
|
|
32690
|
-
assert(
|
|
32691
|
-
assert(
|
|
32689
|
+
assert(typeof path4 === "string", "Path should be a string");
|
|
32690
|
+
assert(path4.length > 0, "The path could not be empty");
|
|
32691
|
+
assert(path4[0] === "/" || path4[0] === "*", "The first character of a path should be `/` or `*`");
|
|
32692
32692
|
assert(typeof handler === "function", "Handler should be a function");
|
|
32693
|
-
const optionalParamMatch =
|
|
32693
|
+
const optionalParamMatch = path4.match(OPTIONAL_PARAM_REGEXP);
|
|
32694
32694
|
if (optionalParamMatch) {
|
|
32695
|
-
assert(
|
|
32696
|
-
const pathFull =
|
|
32697
|
-
const pathOptional =
|
|
32695
|
+
assert(path4.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
32696
|
+
const pathFull = path4.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
32697
|
+
const pathOptional = path4.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
|
|
32698
32698
|
this.on(method, pathFull, opts, handler, store);
|
|
32699
32699
|
this.on(method, pathOptional, opts, handler, store);
|
|
32700
32700
|
return;
|
|
32701
32701
|
}
|
|
32702
|
-
const route =
|
|
32702
|
+
const route = path4;
|
|
32703
32703
|
if (this.ignoreDuplicateSlashes) {
|
|
32704
|
-
|
|
32704
|
+
path4 = removeDuplicateSlashes(path4);
|
|
32705
32705
|
}
|
|
32706
32706
|
if (this.ignoreTrailingSlash) {
|
|
32707
|
-
|
|
32707
|
+
path4 = trimLastSlash(path4);
|
|
32708
32708
|
}
|
|
32709
32709
|
const methods = Array.isArray(method) ? method : [method];
|
|
32710
32710
|
for (const method2 of methods) {
|
|
32711
32711
|
assert(typeof method2 === "string", "Method should be a string");
|
|
32712
32712
|
assert(httpMethods.includes(method2), `Method '${method2}' is not an http method.`);
|
|
32713
|
-
this._on(method2,
|
|
32713
|
+
this._on(method2, path4, opts, handler, store, route);
|
|
32714
32714
|
}
|
|
32715
32715
|
};
|
|
32716
|
-
Router.prototype._on = function _on(method,
|
|
32716
|
+
Router.prototype._on = function _on(method, path4, opts, handler, store) {
|
|
32717
32717
|
let constraints = {};
|
|
32718
32718
|
if (opts.constraints !== void 0) {
|
|
32719
32719
|
assert(typeof opts.constraints === "object" && opts.constraints !== null, "Constraints should be an object");
|
|
@@ -32726,7 +32726,7 @@ var require_find_my_way = __commonJS({
|
|
|
32726
32726
|
if (this.trees[method] === void 0) {
|
|
32727
32727
|
this.trees[method] = new StaticNode("/");
|
|
32728
32728
|
}
|
|
32729
|
-
let pattern =
|
|
32729
|
+
let pattern = path4;
|
|
32730
32730
|
if (pattern === "*" && this.trees[method].prefix.length !== 0) {
|
|
32731
32731
|
const currentRoot = this.trees[method];
|
|
32732
32732
|
this.trees[method] = new StaticNode("");
|
|
@@ -32834,19 +32834,19 @@ var require_find_my_way = __commonJS({
|
|
|
32834
32834
|
throw new Error(`Method '${method}' already declared for route '${pattern}' with constraints '${JSON.stringify(constraints)}'`);
|
|
32835
32835
|
}
|
|
32836
32836
|
}
|
|
32837
|
-
const route = { method, path:
|
|
32837
|
+
const route = { method, path: path4, pattern, params, opts, handler, store };
|
|
32838
32838
|
this.routes.push(route);
|
|
32839
32839
|
currentNode.addRoute(route, this.constrainer);
|
|
32840
32840
|
};
|
|
32841
|
-
Router.prototype.hasRoute = function hasRoute(method,
|
|
32842
|
-
const route = this.findRoute(method,
|
|
32841
|
+
Router.prototype.hasRoute = function hasRoute(method, path4, constraints) {
|
|
32842
|
+
const route = this.findRoute(method, path4, constraints);
|
|
32843
32843
|
return route !== null;
|
|
32844
32844
|
};
|
|
32845
|
-
Router.prototype.findRoute = function findNode(method,
|
|
32845
|
+
Router.prototype.findRoute = function findNode(method, path4, constraints = {}) {
|
|
32846
32846
|
if (this.trees[method] === void 0) {
|
|
32847
32847
|
return null;
|
|
32848
32848
|
}
|
|
32849
|
-
let pattern =
|
|
32849
|
+
let pattern = path4;
|
|
32850
32850
|
let currentNode = this.trees[method];
|
|
32851
32851
|
let parentNodePathIndex = currentNode.prefix.length;
|
|
32852
32852
|
const params = [];
|
|
@@ -32967,39 +32967,39 @@ var require_find_my_way = __commonJS({
|
|
|
32967
32967
|
this._treeGET = null;
|
|
32968
32968
|
this.routes = [];
|
|
32969
32969
|
};
|
|
32970
|
-
Router.prototype.off = function off(method,
|
|
32971
|
-
assert(typeof
|
|
32972
|
-
assert(
|
|
32973
|
-
assert(
|
|
32970
|
+
Router.prototype.off = function off(method, path4, constraints) {
|
|
32971
|
+
assert(typeof path4 === "string", "Path should be a string");
|
|
32972
|
+
assert(path4.length > 0, "The path could not be empty");
|
|
32973
|
+
assert(path4[0] === "/" || path4[0] === "*", "The first character of a path should be `/` or `*`");
|
|
32974
32974
|
assert(
|
|
32975
32975
|
typeof constraints === "undefined" || typeof constraints === "object" && !Array.isArray(constraints) && constraints !== null,
|
|
32976
32976
|
"Constraints should be an object or undefined."
|
|
32977
32977
|
);
|
|
32978
|
-
const optionalParamMatch =
|
|
32978
|
+
const optionalParamMatch = path4.match(OPTIONAL_PARAM_REGEXP);
|
|
32979
32979
|
if (optionalParamMatch) {
|
|
32980
|
-
assert(
|
|
32981
|
-
const pathFull =
|
|
32982
|
-
const pathOptional =
|
|
32980
|
+
assert(path4.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
32981
|
+
const pathFull = path4.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
32982
|
+
const pathOptional = path4.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
|
|
32983
32983
|
this.off(method, pathFull, constraints);
|
|
32984
32984
|
this.off(method, pathOptional, constraints);
|
|
32985
32985
|
return;
|
|
32986
32986
|
}
|
|
32987
32987
|
if (this.ignoreDuplicateSlashes) {
|
|
32988
|
-
|
|
32988
|
+
path4 = removeDuplicateSlashes(path4);
|
|
32989
32989
|
}
|
|
32990
32990
|
if (this.ignoreTrailingSlash) {
|
|
32991
|
-
|
|
32991
|
+
path4 = trimLastSlash(path4);
|
|
32992
32992
|
}
|
|
32993
32993
|
const methods = Array.isArray(method) ? method : [method];
|
|
32994
32994
|
for (const method2 of methods) {
|
|
32995
|
-
this._off(method2,
|
|
32995
|
+
this._off(method2, path4, constraints);
|
|
32996
32996
|
}
|
|
32997
32997
|
};
|
|
32998
|
-
Router.prototype._off = function _off(method,
|
|
32998
|
+
Router.prototype._off = function _off(method, path4, constraints) {
|
|
32999
32999
|
assert(typeof method === "string", "Method should be a string");
|
|
33000
33000
|
assert(httpMethods.includes(method), `Method '${method}' is not an http method.`);
|
|
33001
33001
|
function matcherWithoutConstraints(route) {
|
|
33002
|
-
return method !== route.method ||
|
|
33002
|
+
return method !== route.method || path4 !== route.path;
|
|
33003
33003
|
}
|
|
33004
33004
|
function matcherWithConstraints(route) {
|
|
33005
33005
|
return matcherWithoutConstraints(route) || !deepEqual(constraints, route.opts.constraints || {});
|
|
@@ -33036,37 +33036,37 @@ var require_find_my_way = __commonJS({
|
|
|
33036
33036
|
if (handle === null) return this._defaultRoute(req, res, ctx);
|
|
33037
33037
|
return ctx === void 0 ? handle.handler(req, res, handle.params, handle.store, handle.searchParams) : handle.handler.call(ctx, req, res, handle.params, handle.store, handle.searchParams);
|
|
33038
33038
|
};
|
|
33039
|
-
Router.prototype.find = function find(method,
|
|
33039
|
+
Router.prototype.find = function find(method, path4, derivedConstraints) {
|
|
33040
33040
|
let currentNode = method === "GET" ? this._treeGET : this.trees[method];
|
|
33041
33041
|
if (currentNode == null) return null;
|
|
33042
|
-
if (
|
|
33043
|
-
|
|
33042
|
+
if (path4.charCodeAt(0) !== 47) {
|
|
33043
|
+
path4 = path4.replace(FULL_PATH_REGEXP, "/");
|
|
33044
33044
|
}
|
|
33045
33045
|
if (this.ignoreDuplicateSlashes) {
|
|
33046
|
-
|
|
33046
|
+
path4 = removeDuplicateSlashes(path4);
|
|
33047
33047
|
}
|
|
33048
33048
|
let sanitizedUrl;
|
|
33049
33049
|
let querystring2;
|
|
33050
33050
|
let shouldDecodeParam;
|
|
33051
33051
|
try {
|
|
33052
|
-
sanitizedUrl =
|
|
33053
|
-
|
|
33052
|
+
sanitizedUrl = path4.length >= MIN_NATIVE_SCAN_LENGTH ? safeDecodeURINativeScan(path4, this.useSemicolonDelimiter) : safeDecodeURICharScan(path4, this.useSemicolonDelimiter, 1);
|
|
33053
|
+
path4 = sanitizedUrl.path;
|
|
33054
33054
|
querystring2 = sanitizedUrl.querystring;
|
|
33055
33055
|
shouldDecodeParam = sanitizedUrl.shouldDecodeParam;
|
|
33056
33056
|
} catch (error) {
|
|
33057
|
-
return this._onBadUrl(
|
|
33057
|
+
return this._onBadUrl(path4);
|
|
33058
33058
|
}
|
|
33059
33059
|
if (this.ignoreTrailingSlash) {
|
|
33060
|
-
|
|
33060
|
+
path4 = trimLastSlash(path4);
|
|
33061
33061
|
}
|
|
33062
|
-
const originPath =
|
|
33062
|
+
const originPath = path4;
|
|
33063
33063
|
if (this.caseSensitive === false) {
|
|
33064
|
-
|
|
33064
|
+
path4 = path4.toLowerCase();
|
|
33065
33065
|
}
|
|
33066
33066
|
const maxParamLength = this.maxParamLength;
|
|
33067
33067
|
let pathIndex = currentNode.prefix.length;
|
|
33068
33068
|
const params = [];
|
|
33069
|
-
const pathLen =
|
|
33069
|
+
const pathLen = path4.length;
|
|
33070
33070
|
const brothersNodesStack = [];
|
|
33071
33071
|
let maxParamLengthExceeded = false;
|
|
33072
33072
|
while (true) {
|
|
@@ -33081,7 +33081,7 @@ var require_find_my_way = __commonJS({
|
|
|
33081
33081
|
};
|
|
33082
33082
|
}
|
|
33083
33083
|
}
|
|
33084
|
-
let node = currentNode.getNextNode(
|
|
33084
|
+
let node = currentNode.getNextNode(path4, pathIndex, brothersNodesStack, params.length);
|
|
33085
33085
|
if (node === null) {
|
|
33086
33086
|
if (brothersNodesStack.length === 0) {
|
|
33087
33087
|
if (maxParamLengthExceeded && this.onMaxParamLength) {
|
|
@@ -33182,8 +33182,8 @@ var require_find_my_way = __commonJS({
|
|
|
33182
33182
|
Router.prototype._rebuild = function(routes) {
|
|
33183
33183
|
this.reset();
|
|
33184
33184
|
for (const route of routes) {
|
|
33185
|
-
const { method, path:
|
|
33186
|
-
this._on(method,
|
|
33185
|
+
const { method, path: path4, opts, handler, store } = route;
|
|
33186
|
+
this._on(method, path4, opts, handler, store);
|
|
33187
33187
|
}
|
|
33188
33188
|
};
|
|
33189
33189
|
Router.prototype._defaultRoute = function(req, res, ctx) {
|
|
@@ -33194,24 +33194,24 @@ var require_find_my_way = __commonJS({
|
|
|
33194
33194
|
res.end();
|
|
33195
33195
|
}
|
|
33196
33196
|
};
|
|
33197
|
-
Router.prototype._onBadUrl = function(
|
|
33197
|
+
Router.prototype._onBadUrl = function(path4) {
|
|
33198
33198
|
if (this.onBadUrl === null) {
|
|
33199
33199
|
return null;
|
|
33200
33200
|
}
|
|
33201
33201
|
const onBadUrl = this.onBadUrl;
|
|
33202
33202
|
return {
|
|
33203
|
-
handler: (req, res, ctx) => onBadUrl(
|
|
33203
|
+
handler: (req, res, ctx) => onBadUrl(path4, req, res),
|
|
33204
33204
|
params: {},
|
|
33205
33205
|
store: null
|
|
33206
33206
|
};
|
|
33207
33207
|
};
|
|
33208
|
-
Router.prototype._onMaxParamLength = function(
|
|
33208
|
+
Router.prototype._onMaxParamLength = function(path4) {
|
|
33209
33209
|
if (this.onMaxParamLength === null) {
|
|
33210
33210
|
return null;
|
|
33211
33211
|
}
|
|
33212
33212
|
const onMaxParamLength = this.onMaxParamLength;
|
|
33213
33213
|
return {
|
|
33214
|
-
handler: (req, res, ctx) => onMaxParamLength(
|
|
33214
|
+
handler: (req, res, ctx) => onMaxParamLength(path4, req, res),
|
|
33215
33215
|
params: {},
|
|
33216
33216
|
store: null
|
|
33217
33217
|
};
|
|
@@ -33243,12 +33243,12 @@ var require_find_my_way = __commonJS({
|
|
|
33243
33243
|
if (!httpMethods.hasOwnProperty(i)) continue;
|
|
33244
33244
|
const m = httpMethods[i];
|
|
33245
33245
|
const methodName = m.toLowerCase();
|
|
33246
|
-
Router.prototype[methodName] = function(
|
|
33247
|
-
return this.on(m,
|
|
33246
|
+
Router.prototype[methodName] = function(path4, handler, store) {
|
|
33247
|
+
return this.on(m, path4, handler, store);
|
|
33248
33248
|
};
|
|
33249
33249
|
}
|
|
33250
|
-
Router.prototype.all = function(
|
|
33251
|
-
this.on(httpMethods,
|
|
33250
|
+
Router.prototype.all = function(path4, handler, store) {
|
|
33251
|
+
this.on(httpMethods, path4, handler, store);
|
|
33252
33252
|
};
|
|
33253
33253
|
Router.sanitizeUrlPath = function sanitizeUrlPath(url, useSemicolonDelimiter) {
|
|
33254
33254
|
const decoded = safeDecodeURI(url, useSemicolonDelimiter);
|
|
@@ -33263,14 +33263,14 @@ var require_find_my_way = __commonJS({
|
|
|
33263
33263
|
function escapeRegExp(string) {
|
|
33264
33264
|
return string.replace(ESCAPE_REGEXP, "\\$&");
|
|
33265
33265
|
}
|
|
33266
|
-
function removeDuplicateSlashes(
|
|
33267
|
-
return
|
|
33266
|
+
function removeDuplicateSlashes(path4) {
|
|
33267
|
+
return path4.indexOf("//") !== -1 ? path4.replace(REMOVE_DUPLICATE_SLASHES_REGEXP, "/") : path4;
|
|
33268
33268
|
}
|
|
33269
|
-
function trimLastSlash(
|
|
33270
|
-
if (
|
|
33271
|
-
return
|
|
33269
|
+
function trimLastSlash(path4) {
|
|
33270
|
+
if (path4.length > 1 && path4.charCodeAt(path4.length - 1) === 47) {
|
|
33271
|
+
return path4.slice(0, -1);
|
|
33272
33272
|
}
|
|
33273
|
-
return
|
|
33273
|
+
return path4;
|
|
33274
33274
|
}
|
|
33275
33275
|
function trimRegExpStartAndEnd(regexString) {
|
|
33276
33276
|
if (regexString.charCodeAt(1) === 94) {
|
|
@@ -33281,22 +33281,22 @@ var require_find_my_way = __commonJS({
|
|
|
33281
33281
|
}
|
|
33282
33282
|
return regexString;
|
|
33283
33283
|
}
|
|
33284
|
-
function getClosingParenthensePosition(
|
|
33284
|
+
function getClosingParenthensePosition(path4, idx) {
|
|
33285
33285
|
let parentheses = 1;
|
|
33286
|
-
while (idx <
|
|
33286
|
+
while (idx < path4.length) {
|
|
33287
33287
|
idx++;
|
|
33288
|
-
if (
|
|
33288
|
+
if (path4.charCodeAt(idx) === 92) {
|
|
33289
33289
|
idx++;
|
|
33290
33290
|
continue;
|
|
33291
33291
|
}
|
|
33292
|
-
if (
|
|
33292
|
+
if (path4.charCodeAt(idx) === 41) {
|
|
33293
33293
|
parentheses--;
|
|
33294
|
-
} else if (
|
|
33294
|
+
} else if (path4.charCodeAt(idx) === 40) {
|
|
33295
33295
|
parentheses++;
|
|
33296
33296
|
}
|
|
33297
33297
|
if (!parentheses) return idx;
|
|
33298
33298
|
}
|
|
33299
|
-
throw new TypeError('Invalid regexp expression in "' +
|
|
33299
|
+
throw new TypeError('Invalid regexp expression in "' + path4 + '"');
|
|
33300
33300
|
}
|
|
33301
33301
|
function defaultBuildPrettyMeta(route) {
|
|
33302
33302
|
if (!route) return {};
|
|
@@ -33529,12 +33529,12 @@ var require_route = __commonJS({
|
|
|
33529
33529
|
function route({ options: options2, isFastify }) {
|
|
33530
33530
|
throwIfAlreadyStarted("Cannot add route!");
|
|
33531
33531
|
const opts = { ...options2 };
|
|
33532
|
-
const
|
|
33532
|
+
const path4 = opts.url || opts.path || "";
|
|
33533
33533
|
if (!opts.handler) {
|
|
33534
|
-
throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method,
|
|
33534
|
+
throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method, path4);
|
|
33535
33535
|
}
|
|
33536
33536
|
if (opts.errorHandler !== void 0 && typeof opts.errorHandler !== "function") {
|
|
33537
|
-
throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method,
|
|
33537
|
+
throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method, path4);
|
|
33538
33538
|
}
|
|
33539
33539
|
validateBodyLimitOption(opts.bodyLimit);
|
|
33540
33540
|
validateHandlerTimeoutOption(opts.handlerTimeout);
|
|
@@ -33544,22 +33544,22 @@ var require_route = __commonJS({
|
|
|
33544
33544
|
if (Array.isArray(opts.method)) {
|
|
33545
33545
|
for (let i = 0; i < opts.method.length; ++i) {
|
|
33546
33546
|
opts.method[i] = normalizeAndValidateMethod.call(this, opts.method[i]);
|
|
33547
|
-
validateSchemaBodyOption.call(this, opts.method[i],
|
|
33547
|
+
validateSchemaBodyOption.call(this, opts.method[i], path4, opts.schema);
|
|
33548
33548
|
isGetRoute = opts.method.includes("GET");
|
|
33549
33549
|
isHeadRoute = opts.method.includes("HEAD");
|
|
33550
33550
|
}
|
|
33551
33551
|
} else {
|
|
33552
33552
|
opts.method = normalizeAndValidateMethod.call(this, opts.method);
|
|
33553
|
-
validateSchemaBodyOption.call(this, opts.method,
|
|
33553
|
+
validateSchemaBodyOption.call(this, opts.method, path4, opts.schema);
|
|
33554
33554
|
isGetRoute = opts.method === "GET";
|
|
33555
33555
|
isHeadRoute = opts.method === "HEAD";
|
|
33556
33556
|
}
|
|
33557
33557
|
const headOpts = shouldExposeHead && isGetRoute ? { ...options2 } : null;
|
|
33558
33558
|
const prefix = this[kRoutePrefix];
|
|
33559
|
-
if (
|
|
33559
|
+
if (path4 === "/" && prefix.length > 0 && opts.method !== "HEAD") {
|
|
33560
33560
|
switch (opts.prefixTrailingSlash) {
|
|
33561
33561
|
case "slash":
|
|
33562
|
-
addNewRoute.call(this, { path:
|
|
33562
|
+
addNewRoute.call(this, { path: path4, isFastify });
|
|
33563
33563
|
break;
|
|
33564
33564
|
case "no-slash":
|
|
33565
33565
|
addNewRoute.call(this, { path: "", isFastify });
|
|
@@ -33568,20 +33568,20 @@ var require_route = __commonJS({
|
|
|
33568
33568
|
default:
|
|
33569
33569
|
addNewRoute.call(this, { path: "", isFastify });
|
|
33570
33570
|
if (ignoreTrailingSlash !== true && (ignoreDuplicateSlashes !== true || !prefix.endsWith("/"))) {
|
|
33571
|
-
addNewRoute.call(this, { path:
|
|
33571
|
+
addNewRoute.call(this, { path: path4, prefixing: true, isFastify });
|
|
33572
33572
|
}
|
|
33573
33573
|
}
|
|
33574
|
-
} else if (
|
|
33575
|
-
addNewRoute.call(this, { path:
|
|
33574
|
+
} else if (path4[0] === "/" && prefix.endsWith("/")) {
|
|
33575
|
+
addNewRoute.call(this, { path: path4.slice(1), isFastify });
|
|
33576
33576
|
} else {
|
|
33577
|
-
addNewRoute.call(this, { path:
|
|
33577
|
+
addNewRoute.call(this, { path: path4, isFastify });
|
|
33578
33578
|
}
|
|
33579
33579
|
return this;
|
|
33580
|
-
function addNewRoute({ path:
|
|
33581
|
-
const url = prefix +
|
|
33580
|
+
function addNewRoute({ path: path5, prefixing = false, isFastify: isFastify2 = false }) {
|
|
33581
|
+
const url = prefix + path5;
|
|
33582
33582
|
opts.url = url;
|
|
33583
33583
|
opts.path = url;
|
|
33584
|
-
opts.routePath =
|
|
33584
|
+
opts.routePath = path5;
|
|
33585
33585
|
opts.prefix = prefix;
|
|
33586
33586
|
opts.logLevel = opts.logLevel || this[kLogLevel];
|
|
33587
33587
|
validateLogLevelOption(opts.logLevel, opts.method, opts.url, logger);
|
|
@@ -33713,7 +33713,7 @@ var require_route = __commonJS({
|
|
|
33713
33713
|
});
|
|
33714
33714
|
if (shouldExposeHead && isGetRoute && !isHeadRoute && !hasHEADHandler) {
|
|
33715
33715
|
const onSendHandlers = parseHeadOnSendHandlers(headOpts.onSend);
|
|
33716
|
-
prepareRoute.call(this, { method: "HEAD", url:
|
|
33716
|
+
prepareRoute.call(this, { method: "HEAD", url: path5, options: { ...headOpts, onSend: onSendHandlers }, isFastify: true });
|
|
33717
33717
|
}
|
|
33718
33718
|
}
|
|
33719
33719
|
}
|
|
@@ -33837,9 +33837,9 @@ var require_route = __commonJS({
|
|
|
33837
33837
|
}
|
|
33838
33838
|
return method;
|
|
33839
33839
|
}
|
|
33840
|
-
function validateSchemaBodyOption(method,
|
|
33840
|
+
function validateSchemaBodyOption(method, path4, schema) {
|
|
33841
33841
|
if (this[kSupportedHTTPMethods].bodyless.has(method) && schema?.body) {
|
|
33842
|
-
throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method,
|
|
33842
|
+
throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method, path4);
|
|
33843
33843
|
}
|
|
33844
33844
|
}
|
|
33845
33845
|
function validateBodyLimitOption(bodyLimit) {
|
|
@@ -33854,11 +33854,11 @@ var require_route = __commonJS({
|
|
|
33854
33854
|
throw new FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT(handlerTimeout);
|
|
33855
33855
|
}
|
|
33856
33856
|
}
|
|
33857
|
-
function validateLogLevelOption(logLevel, method,
|
|
33857
|
+
function validateLogLevelOption(logLevel, method, path4, logger) {
|
|
33858
33858
|
if (logLevel == null || logLevel === "") return;
|
|
33859
33859
|
if (logger?.levels?.values == null) return;
|
|
33860
33860
|
if (typeof logLevel !== "string" || logger.levels.values[logLevel] === void 0) {
|
|
33861
|
-
throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method,
|
|
33861
|
+
throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method, path4, logLevel);
|
|
33862
33862
|
}
|
|
33863
33863
|
}
|
|
33864
33864
|
function runPreParsing(err, request, reply) {
|
|
@@ -33930,12 +33930,12 @@ var require_four_oh_four = __commonJS({
|
|
|
33930
33930
|
});
|
|
33931
33931
|
let _routeEventHandler = null;
|
|
33932
33932
|
return { router, setNotFoundHandler, setContext, arrange404 };
|
|
33933
|
-
function arrange404(
|
|
33934
|
-
|
|
33935
|
-
|
|
33936
|
-
router.onBadUrl = router.onBadUrl.bind(
|
|
33937
|
-
router.onMaxParamLength = router.onMaxParamLength.bind(
|
|
33938
|
-
router.defaultRoute = router.defaultRoute.bind(
|
|
33933
|
+
function arrange404(instance2) {
|
|
33934
|
+
instance2[kFourOhFourLevelInstance] = instance2;
|
|
33935
|
+
instance2[kCanSetNotFoundHandler] = true;
|
|
33936
|
+
router.onBadUrl = router.onBadUrl.bind(instance2);
|
|
33937
|
+
router.onMaxParamLength = router.onMaxParamLength.bind(instance2);
|
|
33938
|
+
router.defaultRoute = router.defaultRoute.bind(instance2);
|
|
33939
33939
|
}
|
|
33940
33940
|
function basic404(request, reply) {
|
|
33941
33941
|
request.server[kLogController].routeNotFound(request, reply);
|
|
@@ -33947,7 +33947,7 @@ var require_four_oh_four = __commonJS({
|
|
|
33947
33947
|
});
|
|
33948
33948
|
}
|
|
33949
33949
|
function createRouteEventHandler() {
|
|
33950
|
-
return function onRouteEvent(
|
|
33950
|
+
return function onRouteEvent(path4, req, res) {
|
|
33951
33951
|
const fourOhFourContext = this[kFourOhFourLevelInstance][kFourOhFourContext];
|
|
33952
33952
|
const id = getGenReqId(fourOhFourContext.server, req);
|
|
33953
33953
|
const childLogger = createChildLogger(fourOhFourContext, logger, req, id);
|
|
@@ -33956,8 +33956,8 @@ var require_four_oh_four = __commonJS({
|
|
|
33956
33956
|
_routeEventHandler(request, reply);
|
|
33957
33957
|
};
|
|
33958
33958
|
}
|
|
33959
|
-
function setContext(
|
|
33960
|
-
const _404Context = Object.assign({},
|
|
33959
|
+
function setContext(instance2, context) {
|
|
33960
|
+
const _404Context = Object.assign({}, instance2[kFourOhFourContext]);
|
|
33961
33961
|
_404Context.onSend = context.onSend;
|
|
33962
33962
|
context[kFourOhFourContext] = _404Context;
|
|
33963
33963
|
}
|
|
@@ -34078,30 +34078,30 @@ var require_plugin_override = __commonJS({
|
|
|
34078
34078
|
old[kPluginNameChain].push(fnName);
|
|
34079
34079
|
return old;
|
|
34080
34080
|
}
|
|
34081
|
-
const
|
|
34082
|
-
old[kChildren].push(
|
|
34083
|
-
|
|
34084
|
-
|
|
34085
|
-
|
|
34086
|
-
|
|
34087
|
-
|
|
34088
|
-
|
|
34089
|
-
|
|
34090
|
-
|
|
34091
|
-
|
|
34092
|
-
|
|
34093
|
-
|
|
34094
|
-
|
|
34095
|
-
|
|
34096
|
-
|
|
34097
|
-
if (
|
|
34098
|
-
|
|
34081
|
+
const instance2 = Object.create(old);
|
|
34082
|
+
old[kChildren].push(instance2);
|
|
34083
|
+
instance2.ready = old[kAvvioBoot].bind(instance2);
|
|
34084
|
+
instance2[kChildren] = [];
|
|
34085
|
+
instance2[kReply] = Reply.buildReply(instance2[kReply]);
|
|
34086
|
+
instance2[kRequest] = Request.buildRequest(instance2[kRequest]);
|
|
34087
|
+
instance2[kContentTypeParser] = ContentTypeParser.helpers.buildContentTypeParser(instance2[kContentTypeParser]);
|
|
34088
|
+
instance2[kHooks] = buildHooks(instance2[kHooks]);
|
|
34089
|
+
instance2[kRoutePrefix] = buildRoutePrefix(instance2[kRoutePrefix], opts.prefix);
|
|
34090
|
+
instance2[kLogLevel] = opts.logLevel || instance2[kLogLevel];
|
|
34091
|
+
instance2[kSchemaController] = SchemaController.buildSchemaController(old[kSchemaController]);
|
|
34092
|
+
instance2.getSchema = instance2[kSchemaController].getSchema.bind(instance2[kSchemaController]);
|
|
34093
|
+
instance2.getSchemas = instance2[kSchemaController].getSchemas.bind(instance2[kSchemaController]);
|
|
34094
|
+
instance2[pluginUtils.kRegisteredPlugins] = Object.create(instance2[pluginUtils.kRegisteredPlugins]);
|
|
34095
|
+
instance2[kPluginNameChain] = [fnName];
|
|
34096
|
+
instance2[kErrorHandlerAlreadySet] = false;
|
|
34097
|
+
if (instance2[kLogSerializers] || opts.logSerializers) {
|
|
34098
|
+
instance2[kLogSerializers] = Object.assign(Object.create(instance2[kLogSerializers]), opts.logSerializers);
|
|
34099
34099
|
}
|
|
34100
34100
|
if (opts.prefix) {
|
|
34101
|
-
|
|
34101
|
+
instance2[kFourOhFour].arrange404(instance2);
|
|
34102
34102
|
}
|
|
34103
|
-
for (const hook of
|
|
34104
|
-
return
|
|
34103
|
+
for (const hook of instance2[kHooks].onRegister) hook.call(old, instance2, opts);
|
|
34104
|
+
return instance2;
|
|
34105
34105
|
};
|
|
34106
34106
|
function buildRoutePrefix(instancePrefix, pluginPrefix) {
|
|
34107
34107
|
if (!pluginPrefix) {
|
|
@@ -34895,12 +34895,12 @@ var require_set_cookie = __commonJS({
|
|
|
34895
34895
|
var require_response = __commonJS({
|
|
34896
34896
|
"node_modules/light-my-request/lib/response.js"(exports, module) {
|
|
34897
34897
|
"use strict";
|
|
34898
|
-
var
|
|
34898
|
+
var http3 = __require("node:http");
|
|
34899
34899
|
var { Writable, Readable, addAbortSignal } = __require("node:stream");
|
|
34900
34900
|
var util = __require("node:util");
|
|
34901
34901
|
var setCookie = require_set_cookie();
|
|
34902
34902
|
function Response(req, onEnd, reject) {
|
|
34903
|
-
|
|
34903
|
+
http3.ServerResponse.call(this, req);
|
|
34904
34904
|
if (req._lightMyRequest?.payloadAsStream) {
|
|
34905
34905
|
const read = this.emit.bind(this, "drain");
|
|
34906
34906
|
this._lightMyRequest = { headers: null, trailers: {}, stream: new Readable({ read }) };
|
|
@@ -34965,7 +34965,7 @@ var require_response = __commonJS({
|
|
|
34965
34965
|
this.once("error", onEndFailure);
|
|
34966
34966
|
this.once("close", onEndFailure);
|
|
34967
34967
|
}
|
|
34968
|
-
util.inherits(Response,
|
|
34968
|
+
util.inherits(Response, http3.ServerResponse);
|
|
34969
34969
|
Response.prototype.setTimeout = function(msecs, callback) {
|
|
34970
34970
|
this.timeoutHandle = setTimeout(() => {
|
|
34971
34971
|
this.emit("timeout");
|
|
@@ -34974,7 +34974,7 @@ var require_response = __commonJS({
|
|
|
34974
34974
|
return this;
|
|
34975
34975
|
};
|
|
34976
34976
|
Response.prototype.writeHead = function() {
|
|
34977
|
-
const result =
|
|
34977
|
+
const result = http3.ServerResponse.prototype.writeHead.apply(this, arguments);
|
|
34978
34978
|
copyHeaders(this);
|
|
34979
34979
|
if (this._lightMyRequest.stream) {
|
|
34980
34980
|
this._lightMyRequest.onEndSuccess(generatePayload(this));
|
|
@@ -34985,7 +34985,7 @@ var require_response = __commonJS({
|
|
|
34985
34985
|
if (this.timeoutHandle) {
|
|
34986
34986
|
clearTimeout(this.timeoutHandle);
|
|
34987
34987
|
}
|
|
34988
|
-
|
|
34988
|
+
http3.ServerResponse.prototype.write.call(this, data, encoding, callback);
|
|
34989
34989
|
if (this._lightMyRequest.stream) {
|
|
34990
34990
|
return this._lightMyRequest.stream.push(Buffer.from(data, encoding));
|
|
34991
34991
|
} else {
|
|
@@ -34997,7 +34997,7 @@ var require_response = __commonJS({
|
|
|
34997
34997
|
if (data) {
|
|
34998
34998
|
this.write(data, encoding);
|
|
34999
34999
|
}
|
|
35000
|
-
|
|
35000
|
+
http3.ServerResponse.prototype.end.call(this, callback);
|
|
35001
35001
|
this.emit("finish");
|
|
35002
35002
|
this.destroy();
|
|
35003
35003
|
};
|
|
@@ -36078,7 +36078,7 @@ var require_fastify = __commonJS({
|
|
|
36078
36078
|
"use strict";
|
|
36079
36079
|
var VERSION = "5.12.0";
|
|
36080
36080
|
var Avvio = require_avvio();
|
|
36081
|
-
var
|
|
36081
|
+
var http3 = __require("node:http");
|
|
36082
36082
|
var diagnostics = __require("node:diagnostics_channel");
|
|
36083
36083
|
var lightMyRequest;
|
|
36084
36084
|
var {
|
|
@@ -36430,15 +36430,15 @@ var require_fastify = __commonJS({
|
|
|
36430
36430
|
fastify2.ready = ready;
|
|
36431
36431
|
fastify2.printPlugins = avvio.prettyPrint.bind(avvio);
|
|
36432
36432
|
avvio.once("preReady", () => {
|
|
36433
|
-
fastify2.onClose((
|
|
36433
|
+
fastify2.onClose((instance2, done) => {
|
|
36434
36434
|
fastify2[kState].closing = true;
|
|
36435
36435
|
router.closeRoutes();
|
|
36436
36436
|
hookRunnerApplication("preClose", fastify2[kAvvioBoot], fastify2, function() {
|
|
36437
36437
|
if (fastify2[kState].listening) {
|
|
36438
36438
|
if (forceCloseConnections === "idle" && options.serverFactory) {
|
|
36439
|
-
|
|
36439
|
+
instance2.server.closeIdleConnections();
|
|
36440
36440
|
} else if (serverHasCloseAllConnections && forceCloseConnections === true) {
|
|
36441
|
-
|
|
36441
|
+
instance2.server.closeAllConnections();
|
|
36442
36442
|
} else if (forceCloseConnections === true) {
|
|
36443
36443
|
for (const conn of fastify2[kKeepAliveConnections]) {
|
|
36444
36444
|
conn.destroy();
|
|
@@ -36447,10 +36447,10 @@ var require_fastify = __commonJS({
|
|
|
36447
36447
|
}
|
|
36448
36448
|
}
|
|
36449
36449
|
if (serverHasCloseHttp2Sessions) {
|
|
36450
|
-
|
|
36450
|
+
instance2.server.closeHttp2Sessions();
|
|
36451
36451
|
}
|
|
36452
36452
|
if (!options.serverFactory || fastify2[kState].listening) {
|
|
36453
|
-
|
|
36453
|
+
instance2.server.close(function(err) {
|
|
36454
36454
|
if (err && err.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
36455
36455
|
done(null);
|
|
36456
36456
|
} else {
|
|
@@ -36618,19 +36618,19 @@ var require_fastify = __commonJS({
|
|
|
36618
36618
|
}
|
|
36619
36619
|
fourOhFour.router.lookup(req, res);
|
|
36620
36620
|
}
|
|
36621
|
-
function onBadUrl(
|
|
36621
|
+
function onBadUrl(path4, req, res) {
|
|
36622
36622
|
if (options.frameworkErrors) {
|
|
36623
36623
|
const id = getGenReqId(routeEventContext.server, req);
|
|
36624
36624
|
const childLogger = createChildLogger(routeEventContext, options.logger, req, id);
|
|
36625
36625
|
const request = new Request(id, null, req, null, childLogger, routeEventContext);
|
|
36626
36626
|
const reply = new Reply(res, request, childLogger);
|
|
36627
36627
|
routeEventContext.server[kLogController].incomingRequest(request, reply);
|
|
36628
|
-
return options.frameworkErrors(new FST_ERR_BAD_URL(
|
|
36628
|
+
return options.frameworkErrors(new FST_ERR_BAD_URL(path4), request, reply);
|
|
36629
36629
|
}
|
|
36630
36630
|
const body = JSON.stringify({
|
|
36631
36631
|
error: "Bad Request",
|
|
36632
36632
|
code: "FST_ERR_BAD_URL",
|
|
36633
|
-
message: `'${
|
|
36633
|
+
message: `'${path4}' is not a valid url component`,
|
|
36634
36634
|
statusCode: 400
|
|
36635
36635
|
});
|
|
36636
36636
|
res.writeHead(400, {
|
|
@@ -36639,19 +36639,19 @@ var require_fastify = __commonJS({
|
|
|
36639
36639
|
});
|
|
36640
36640
|
res.end(body);
|
|
36641
36641
|
}
|
|
36642
|
-
function onMaxParamLength(
|
|
36642
|
+
function onMaxParamLength(path4, req, res) {
|
|
36643
36643
|
if (options.frameworkErrors) {
|
|
36644
36644
|
const id = getGenReqId(routeEventContext.server, req);
|
|
36645
36645
|
const childLogger = createChildLogger(routeEventContext, options.logger, req, id);
|
|
36646
36646
|
const request = new Request(id, null, req, null, childLogger, routeEventContext);
|
|
36647
36647
|
const reply = new Reply(res, request, childLogger);
|
|
36648
36648
|
routeEventContext.server[kLogController].incomingRequest(request, reply);
|
|
36649
|
-
return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(
|
|
36649
|
+
return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(path4), request, reply);
|
|
36650
36650
|
}
|
|
36651
36651
|
const body = JSON.stringify({
|
|
36652
36652
|
error: "Bad Request",
|
|
36653
36653
|
code: "FST_ERR_MAX_PARAM_LENGTH",
|
|
36654
|
-
message: `'${
|
|
36654
|
+
message: `'${path4}' is exceeding the max param length`,
|
|
36655
36655
|
statusCode: 414
|
|
36656
36656
|
});
|
|
36657
36657
|
res.writeHead(414, {
|
|
@@ -36765,7 +36765,7 @@ var require_fastify = __commonJS({
|
|
|
36765
36765
|
return this;
|
|
36766
36766
|
}
|
|
36767
36767
|
function addHttpMethod(method, { hasBody = false, overrideExisting = false } = {}) {
|
|
36768
|
-
if (typeof method !== "string" ||
|
|
36768
|
+
if (typeof method !== "string" || http3.METHODS.indexOf(method) === -1) {
|
|
36769
36769
|
throw new FST_ERR_ROUTE_METHOD_INVALID();
|
|
36770
36770
|
}
|
|
36771
36771
|
const alreadyExists = this[kSupportedHTTPMethods].bodyless.has(method) || this[kSupportedHTTPMethods].bodywith.has(method);
|
|
@@ -36868,17 +36868,17 @@ var require_fastify = __commonJS({
|
|
|
36868
36868
|
let body, errorCode, errorStatus, errorLabel;
|
|
36869
36869
|
if (err.code === "ERR_HTTP_REQUEST_TIMEOUT") {
|
|
36870
36870
|
errorCode = "408";
|
|
36871
|
-
errorStatus =
|
|
36871
|
+
errorStatus = http3.STATUS_CODES[errorCode];
|
|
36872
36872
|
body = `{"error":"${errorStatus}","message":"Client Timeout","statusCode":408}`;
|
|
36873
36873
|
errorLabel = "timeout";
|
|
36874
36874
|
} else if (err.code === "HPE_HEADER_OVERFLOW") {
|
|
36875
36875
|
errorCode = "431";
|
|
36876
|
-
errorStatus =
|
|
36876
|
+
errorStatus = http3.STATUS_CODES[errorCode];
|
|
36877
36877
|
body = `{"error":"${errorStatus}","message":"Exceeded maximum allowed HTTP header size","statusCode":431}`;
|
|
36878
36878
|
errorLabel = "header_overflow";
|
|
36879
36879
|
} else {
|
|
36880
36880
|
errorCode = "400";
|
|
36881
|
-
errorStatus =
|
|
36881
|
+
errorStatus = http3.STATUS_CODES[errorCode];
|
|
36882
36882
|
body = `{"error":"${errorStatus}","message":"Client Error","statusCode":400}`;
|
|
36883
36883
|
errorLabel = "error";
|
|
36884
36884
|
}
|
|
@@ -39560,8 +39560,8 @@ var require_websocket = __commonJS({
|
|
|
39560
39560
|
"use strict";
|
|
39561
39561
|
var EventEmitter2 = __require("events");
|
|
39562
39562
|
var https = __require("https");
|
|
39563
|
-
var
|
|
39564
|
-
var
|
|
39563
|
+
var http3 = __require("http");
|
|
39564
|
+
var net2 = __require("net");
|
|
39565
39565
|
var tls = __require("tls");
|
|
39566
39566
|
var { randomBytes, createHash } = __require("crypto");
|
|
39567
39567
|
var { Duplex, Readable } = __require("stream");
|
|
@@ -40102,7 +40102,7 @@ var require_websocket = __commonJS({
|
|
|
40102
40102
|
}
|
|
40103
40103
|
const defaultPort = isSecure ? 443 : 80;
|
|
40104
40104
|
const key = randomBytes(16).toString("base64");
|
|
40105
|
-
const request = isSecure ? https.request :
|
|
40105
|
+
const request = isSecure ? https.request : http3.request;
|
|
40106
40106
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
40107
40107
|
let perMessageDeflate;
|
|
40108
40108
|
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
@@ -40305,12 +40305,12 @@ var require_websocket = __commonJS({
|
|
|
40305
40305
|
}
|
|
40306
40306
|
function netConnect(options) {
|
|
40307
40307
|
options.path = options.socketPath;
|
|
40308
|
-
return
|
|
40308
|
+
return net2.connect(options);
|
|
40309
40309
|
}
|
|
40310
40310
|
function tlsConnect(options) {
|
|
40311
40311
|
options.path = void 0;
|
|
40312
40312
|
if (!options.servername && options.servername !== "") {
|
|
40313
|
-
options.servername =
|
|
40313
|
+
options.servername = net2.isIP(options.host) ? "" : options.host;
|
|
40314
40314
|
}
|
|
40315
40315
|
return tls.connect(options);
|
|
40316
40316
|
}
|
|
@@ -40598,7 +40598,7 @@ var require_websocket_server = __commonJS({
|
|
|
40598
40598
|
"node_modules/ws/lib/websocket-server.js"(exports, module) {
|
|
40599
40599
|
"use strict";
|
|
40600
40600
|
var EventEmitter2 = __require("events");
|
|
40601
|
-
var
|
|
40601
|
+
var http3 = __require("http");
|
|
40602
40602
|
var { Duplex } = __require("stream");
|
|
40603
40603
|
var { createHash } = __require("crypto");
|
|
40604
40604
|
var extension2 = require_extension();
|
|
@@ -40679,8 +40679,8 @@ var require_websocket_server = __commonJS({
|
|
|
40679
40679
|
);
|
|
40680
40680
|
}
|
|
40681
40681
|
if (options.port != null) {
|
|
40682
|
-
this._server =
|
|
40683
|
-
const body =
|
|
40682
|
+
this._server = http3.createServer((req, res) => {
|
|
40683
|
+
const body = http3.STATUS_CODES[426];
|
|
40684
40684
|
res.writeHead(426, {
|
|
40685
40685
|
"Content-Length": body.length,
|
|
40686
40686
|
"Content-Type": "text/plain"
|
|
@@ -40969,7 +40969,7 @@ var require_websocket_server = __commonJS({
|
|
|
40969
40969
|
this.destroy();
|
|
40970
40970
|
}
|
|
40971
40971
|
function abortHandshake(socket, code, message, headers) {
|
|
40972
|
-
message = message ||
|
|
40972
|
+
message = message || http3.STATUS_CODES[code];
|
|
40973
40973
|
headers = {
|
|
40974
40974
|
Connection: "close",
|
|
40975
40975
|
"Content-Type": "text/html",
|
|
@@ -40978,7 +40978,7 @@ var require_websocket_server = __commonJS({
|
|
|
40978
40978
|
};
|
|
40979
40979
|
socket.once("finish", socket.destroy);
|
|
40980
40980
|
socket.end(
|
|
40981
|
-
`HTTP/1.1 ${code} ${
|
|
40981
|
+
`HTTP/1.1 ${code} ${http3.STATUS_CODES[code]}\r
|
|
40982
40982
|
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
|
|
40983
40983
|
);
|
|
40984
40984
|
}
|
|
@@ -41001,8 +41001,8 @@ var import_cors = __toESM(require_cors(), 1);
|
|
|
41001
41001
|
// src/db/index.ts
|
|
41002
41002
|
import Database from "better-sqlite3";
|
|
41003
41003
|
var db;
|
|
41004
|
-
function initDb(
|
|
41005
|
-
db = new Database(
|
|
41004
|
+
function initDb(path4 = "data.db") {
|
|
41005
|
+
db = new Database(path4);
|
|
41006
41006
|
db.pragma("journal_mode = WAL");
|
|
41007
41007
|
db.pragma("foreign_keys = ON");
|
|
41008
41008
|
createTables(db);
|
|
@@ -41087,13 +41087,14 @@ function createTables(database) {
|
|
|
41087
41087
|
CREATE TABLE IF NOT EXISTS discussion_threads (
|
|
41088
41088
|
id TEXT PRIMARY KEY,
|
|
41089
41089
|
session_id TEXT NOT NULL,
|
|
41090
|
-
item_id TEXT
|
|
41091
|
-
turn_id TEXT
|
|
41092
|
-
start_offset INTEGER
|
|
41093
|
-
end_offset INTEGER
|
|
41094
|
-
selected_text TEXT
|
|
41090
|
+
item_id TEXT,
|
|
41091
|
+
turn_id TEXT,
|
|
41092
|
+
start_offset INTEGER,
|
|
41093
|
+
end_offset INTEGER,
|
|
41094
|
+
selected_text TEXT,
|
|
41095
41095
|
status TEXT NOT NULL DEFAULT 'open',
|
|
41096
41096
|
resolved_at TEXT,
|
|
41097
|
+
external_thread_id TEXT,
|
|
41097
41098
|
created_at TEXT NOT NULL,
|
|
41098
41099
|
updated_at TEXT NOT NULL,
|
|
41099
41100
|
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
@@ -41164,13 +41165,14 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
|
|
|
41164
41165
|
CREATE TABLE IF NOT EXISTS discussion_threads (
|
|
41165
41166
|
id TEXT PRIMARY KEY,
|
|
41166
41167
|
session_id TEXT NOT NULL,
|
|
41167
|
-
item_id TEXT
|
|
41168
|
-
turn_id TEXT
|
|
41169
|
-
start_offset INTEGER
|
|
41170
|
-
end_offset INTEGER
|
|
41171
|
-
selected_text TEXT
|
|
41168
|
+
item_id TEXT,
|
|
41169
|
+
turn_id TEXT,
|
|
41170
|
+
start_offset INTEGER,
|
|
41171
|
+
end_offset INTEGER,
|
|
41172
|
+
selected_text TEXT,
|
|
41172
41173
|
status TEXT NOT NULL DEFAULT 'open',
|
|
41173
41174
|
resolved_at TEXT,
|
|
41175
|
+
external_thread_id TEXT,
|
|
41174
41176
|
created_at TEXT NOT NULL,
|
|
41175
41177
|
updated_at TEXT NOT NULL,
|
|
41176
41178
|
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
@@ -41179,6 +41181,37 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
|
|
|
41179
41181
|
CREATE INDEX IF NOT EXISTS idx_discussion_threads_item_id ON discussion_threads(item_id);
|
|
41180
41182
|
`);
|
|
41181
41183
|
}
|
|
41184
|
+
const threadAnchorCols = database.prepare("PRAGMA table_info(discussion_threads)").all();
|
|
41185
|
+
const anchorCol = threadAnchorCols.find((c) => c.name === "item_id");
|
|
41186
|
+
if (anchorCol && anchorCol.notnull === 1) {
|
|
41187
|
+
database.exec(`
|
|
41188
|
+
CREATE TABLE discussion_threads_new (
|
|
41189
|
+
id TEXT PRIMARY KEY,
|
|
41190
|
+
session_id TEXT NOT NULL,
|
|
41191
|
+
item_id TEXT,
|
|
41192
|
+
turn_id TEXT,
|
|
41193
|
+
start_offset INTEGER,
|
|
41194
|
+
end_offset INTEGER,
|
|
41195
|
+
selected_text TEXT,
|
|
41196
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
41197
|
+
resolved_at TEXT,
|
|
41198
|
+
external_thread_id TEXT,
|
|
41199
|
+
created_at TEXT NOT NULL,
|
|
41200
|
+
updated_at TEXT NOT NULL,
|
|
41201
|
+
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
41202
|
+
);
|
|
41203
|
+
INSERT INTO discussion_threads_new
|
|
41204
|
+
(id, session_id, item_id, turn_id, start_offset, end_offset, selected_text,
|
|
41205
|
+
status, resolved_at, external_thread_id, created_at, updated_at)
|
|
41206
|
+
SELECT id, session_id, item_id, turn_id, start_offset, end_offset, selected_text,
|
|
41207
|
+
status, resolved_at, external_thread_id, created_at, updated_at
|
|
41208
|
+
FROM discussion_threads;
|
|
41209
|
+
DROP TABLE discussion_threads;
|
|
41210
|
+
ALTER TABLE discussion_threads_new RENAME TO discussion_threads;
|
|
41211
|
+
CREATE INDEX IF NOT EXISTS idx_discussion_threads_session_id ON discussion_threads(session_id);
|
|
41212
|
+
CREATE INDEX IF NOT EXISTS idx_discussion_threads_item_id ON discussion_threads(item_id);
|
|
41213
|
+
`);
|
|
41214
|
+
}
|
|
41182
41215
|
}
|
|
41183
41216
|
|
|
41184
41217
|
// node_modules/ws/wrapper.mjs
|
|
@@ -41710,6 +41743,50 @@ async function registerSessionRoutes(fastify) {
|
|
|
41710
41743
|
);
|
|
41711
41744
|
}
|
|
41712
41745
|
|
|
41746
|
+
// src/routes/session-guard.ts
|
|
41747
|
+
var LIVE_TURN_SQL = `SELECT id FROM turns WHERE session_id = ? AND status IN ('pending', 'running') LIMIT 1`;
|
|
41748
|
+
var LIVE_MAIN_TURN_SQL = `SELECT id FROM turns WHERE session_id = ? AND status IN ('pending', 'running') AND thread_id IS NULL LIMIT 1`;
|
|
41749
|
+
var LIVE_THREAD_TURN_SQL = `SELECT id FROM turns WHERE thread_id = ? AND status IN ('pending', 'running') LIMIT 1`;
|
|
41750
|
+
function isSessionBusy(db2, session, opts) {
|
|
41751
|
+
if (opts?.threadId) {
|
|
41752
|
+
return !!db2.prepare(LIVE_THREAD_TURN_SQL).get(opts.threadId);
|
|
41753
|
+
}
|
|
41754
|
+
if (opts?.mainOnly) {
|
|
41755
|
+
if (db2.prepare(LIVE_MAIN_TURN_SQL).get(session.id)) return true;
|
|
41756
|
+
if (db2.prepare(LIVE_TURN_SQL).get(session.id)) return false;
|
|
41757
|
+
} else {
|
|
41758
|
+
if (db2.prepare(LIVE_TURN_SQL).get(session.id)) return true;
|
|
41759
|
+
}
|
|
41760
|
+
if (!session.is_running) return false;
|
|
41761
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41762
|
+
db2.prepare("UPDATE sessions SET is_running = 0, status = ?, updated_at = ? WHERE id = ?").run(
|
|
41763
|
+
"active",
|
|
41764
|
+
now,
|
|
41765
|
+
session.id
|
|
41766
|
+
);
|
|
41767
|
+
return false;
|
|
41768
|
+
}
|
|
41769
|
+
function recomputeSessionRunning(db2, sessionId, idleStatus = "active", hasUnreviewed = false) {
|
|
41770
|
+
const live = db2.prepare(`SELECT COUNT(*) AS c FROM turns WHERE session_id = ? AND status IN ('pending', 'running')`).get(sessionId);
|
|
41771
|
+
const isRunning = live.c > 0 ? 1 : 0;
|
|
41772
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41773
|
+
if (hasUnreviewed && isRunning === 0) {
|
|
41774
|
+
db2.prepare("UPDATE sessions SET is_running = ?, status = ?, has_unreviewed = 1, updated_at = ? WHERE id = ?").run(
|
|
41775
|
+
isRunning,
|
|
41776
|
+
idleStatus,
|
|
41777
|
+
now,
|
|
41778
|
+
sessionId
|
|
41779
|
+
);
|
|
41780
|
+
} else {
|
|
41781
|
+
db2.prepare("UPDATE sessions SET is_running = ?, status = ?, updated_at = ? WHERE id = ?").run(
|
|
41782
|
+
isRunning,
|
|
41783
|
+
isRunning ? "running" : idleStatus,
|
|
41784
|
+
now,
|
|
41785
|
+
sessionId
|
|
41786
|
+
);
|
|
41787
|
+
}
|
|
41788
|
+
}
|
|
41789
|
+
|
|
41713
41790
|
// src/routes/turns.ts
|
|
41714
41791
|
async function registerTurnRoutes(fastify) {
|
|
41715
41792
|
fastify.post(
|
|
@@ -41748,7 +41825,7 @@ async function registerTurnRoutes(fastify) {
|
|
|
41748
41825
|
if (!session) {
|
|
41749
41826
|
return reply.code(404).send({ error: "Session not found" });
|
|
41750
41827
|
}
|
|
41751
|
-
if (session
|
|
41828
|
+
if (isSessionBusy(db2, session, { mainOnly: true })) {
|
|
41752
41829
|
return reply.code(409).send({ error: "A turn is already running for this session" });
|
|
41753
41830
|
}
|
|
41754
41831
|
const turnId = v4_default();
|
|
@@ -41770,14 +41847,37 @@ async function registerTurnRoutes(fastify) {
|
|
|
41770
41847
|
return parsedTurn;
|
|
41771
41848
|
}
|
|
41772
41849
|
);
|
|
41850
|
+
fastify.get(
|
|
41851
|
+
"/api/sessions/:id/turns/:turnId",
|
|
41852
|
+
async (request, reply) => {
|
|
41853
|
+
const { id, turnId } = request.params;
|
|
41854
|
+
const db2 = getDb();
|
|
41855
|
+
const session = db2.prepare("SELECT id FROM sessions WHERE id = ?").get(id);
|
|
41856
|
+
if (!session) {
|
|
41857
|
+
return reply.code(404).send({ error: "Session not found" });
|
|
41858
|
+
}
|
|
41859
|
+
const raw = db2.prepare("SELECT * FROM turns WHERE id = ? AND session_id = ?").get(turnId, id);
|
|
41860
|
+
if (!raw) {
|
|
41861
|
+
return reply.code(404).send({ error: "Turn not found" });
|
|
41862
|
+
}
|
|
41863
|
+
const itemRows = db2.prepare("SELECT * FROM items WHERE turn_id = ? ORDER BY created_at ASC").all(turnId);
|
|
41864
|
+
return {
|
|
41865
|
+
...raw,
|
|
41866
|
+
token_usage: raw.token_usage ? JSON.parse(raw.token_usage) : null,
|
|
41867
|
+
attachments: raw.attachments ? JSON.parse(raw.attachments) : null,
|
|
41868
|
+
items: itemRows.map((it) => ({ ...it, data: it.data ? JSON.parse(it.data) : null }))
|
|
41869
|
+
};
|
|
41870
|
+
}
|
|
41871
|
+
);
|
|
41773
41872
|
fastify.post("/api/sessions/:id/cancel", async (request, reply) => {
|
|
41774
41873
|
const { id } = request.params;
|
|
41874
|
+
const { threadId } = request.query ?? {};
|
|
41775
41875
|
const db2 = getDb();
|
|
41776
41876
|
const session = db2.prepare("SELECT runtime_type FROM sessions WHERE id = ?").get(id);
|
|
41777
41877
|
if (!session) {
|
|
41778
41878
|
return reply.code(404).send({ error: "Session not found" });
|
|
41779
41879
|
}
|
|
41780
|
-
const cancelled = await getProvider(session.runtime_type).interruptTurn(id);
|
|
41880
|
+
const cancelled = await getProvider(session.runtime_type).interruptTurn(id, threadId);
|
|
41781
41881
|
if (!cancelled) {
|
|
41782
41882
|
return reply.code(409).send({ error: "No running turn to cancel" });
|
|
41783
41883
|
}
|
|
@@ -41786,6 +41886,14 @@ async function registerTurnRoutes(fastify) {
|
|
|
41786
41886
|
}
|
|
41787
41887
|
|
|
41788
41888
|
// src/routes/threads.ts
|
|
41889
|
+
function parseTurnRow(row, items = []) {
|
|
41890
|
+
return {
|
|
41891
|
+
...row,
|
|
41892
|
+
token_usage: row.token_usage ? JSON.parse(row.token_usage) : null,
|
|
41893
|
+
attachments: row.attachments ? JSON.parse(row.attachments) : null,
|
|
41894
|
+
items
|
|
41895
|
+
};
|
|
41896
|
+
}
|
|
41789
41897
|
async function registerThreadRoutes(fastify) {
|
|
41790
41898
|
fastify.post(
|
|
41791
41899
|
"/api/sessions/:sessionId/threads",
|
|
@@ -41793,75 +41901,109 @@ async function registerThreadRoutes(fastify) {
|
|
|
41793
41901
|
schema: {
|
|
41794
41902
|
body: {
|
|
41795
41903
|
type: "object",
|
|
41796
|
-
required: ["
|
|
41904
|
+
required: ["message"],
|
|
41797
41905
|
properties: {
|
|
41798
41906
|
itemId: { type: "string" },
|
|
41799
41907
|
turnId: { type: "string" },
|
|
41800
41908
|
startOffset: { type: "number" },
|
|
41801
41909
|
endOffset: { type: "number" },
|
|
41802
41910
|
selectedText: { type: "string" },
|
|
41803
|
-
message: { type: "string", minLength: 1 }
|
|
41911
|
+
message: { type: "string", minLength: 1 },
|
|
41912
|
+
attachments: {
|
|
41913
|
+
type: "array",
|
|
41914
|
+
items: {
|
|
41915
|
+
type: "object",
|
|
41916
|
+
required: ["name", "media_type", "data"],
|
|
41917
|
+
properties: {
|
|
41918
|
+
name: { type: "string" },
|
|
41919
|
+
media_type: { type: "string" },
|
|
41920
|
+
data: { type: "string" }
|
|
41921
|
+
}
|
|
41922
|
+
}
|
|
41923
|
+
}
|
|
41804
41924
|
}
|
|
41805
41925
|
}
|
|
41806
41926
|
}
|
|
41807
41927
|
},
|
|
41808
41928
|
async (request, reply) => {
|
|
41809
41929
|
const { sessionId } = request.params;
|
|
41810
|
-
const { itemId, turnId, startOffset, endOffset, selectedText, message } = request.body || {};
|
|
41930
|
+
const { itemId, turnId, startOffset, endOffset, selectedText, message, attachments } = request.body || {};
|
|
41811
41931
|
const db2 = getDb();
|
|
41812
41932
|
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
|
|
41813
41933
|
if (!session) {
|
|
41814
41934
|
return reply.code(404).send({ error: "Session not found" });
|
|
41815
41935
|
}
|
|
41816
|
-
if (session
|
|
41936
|
+
if (isSessionBusy(db2, session)) {
|
|
41817
41937
|
return reply.code(409).send({ error: "A turn is already running for this session" });
|
|
41818
41938
|
}
|
|
41939
|
+
const isAnchored = Boolean(itemId && turnId && selectedText);
|
|
41819
41940
|
const threadId = v4_default();
|
|
41820
41941
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41821
41942
|
db2.prepare(
|
|
41822
41943
|
`INSERT INTO discussion_threads (id, session_id, item_id, turn_id, start_offset, end_offset, selected_text, status, created_at, updated_at)
|
|
41823
41944
|
VALUES (?, ?, ?, ?, ?, ?, ?, 'open', ?, ?)`
|
|
41824
|
-
).run(
|
|
41945
|
+
).run(
|
|
41946
|
+
threadId,
|
|
41947
|
+
sessionId,
|
|
41948
|
+
itemId ?? null,
|
|
41949
|
+
turnId ?? null,
|
|
41950
|
+
startOffset ?? null,
|
|
41951
|
+
endOffset ?? null,
|
|
41952
|
+
selectedText ?? null,
|
|
41953
|
+
now,
|
|
41954
|
+
now
|
|
41955
|
+
);
|
|
41825
41956
|
const provider = getProvider(session.runtime_type);
|
|
41826
41957
|
if (provider.forkSession) {
|
|
41827
41958
|
try {
|
|
41828
41959
|
if (!session.external_thread_id) {
|
|
41829
|
-
console.warn(
|
|
41960
|
+
console.warn(
|
|
41961
|
+
`[threads] cannot fork for thread ${threadId}: session ${sessionId} has no external_thread_id \u2014 thread will start a fresh isolated session`
|
|
41962
|
+
);
|
|
41830
41963
|
} else {
|
|
41831
|
-
const anchorTurn = db2.prepare("SELECT * FROM turns WHERE id = ?").get(turnId)
|
|
41964
|
+
const anchorTurn = isAnchored ? db2.prepare("SELECT * FROM turns WHERE id = ?").get(turnId) : db2.prepare(
|
|
41965
|
+
"SELECT * FROM turns WHERE session_id = ? AND thread_id IS NULL ORDER BY created_at DESC LIMIT 1"
|
|
41966
|
+
).get(sessionId);
|
|
41832
41967
|
if (anchorTurn) {
|
|
41833
41968
|
const forkedSessionId = await provider.forkSession(session, anchorTurn);
|
|
41834
41969
|
if (forkedSessionId) {
|
|
41835
|
-
db2.prepare("UPDATE discussion_threads SET external_thread_id = ? WHERE id = ?").run(
|
|
41970
|
+
db2.prepare("UPDATE discussion_threads SET external_thread_id = ? WHERE id = ?").run(
|
|
41971
|
+
forkedSessionId,
|
|
41972
|
+
threadId
|
|
41973
|
+
);
|
|
41836
41974
|
console.log(`[threads] forked to ${forkedSessionId} for thread ${threadId} (session ${sessionId})`);
|
|
41837
41975
|
} else {
|
|
41838
|
-
console.warn(
|
|
41976
|
+
console.warn(
|
|
41977
|
+
`[threads] forkSession returned null for thread ${threadId} (external_thread_id=${session.external_thread_id}) \u2014 thread will start a fresh isolated session`
|
|
41978
|
+
);
|
|
41839
41979
|
}
|
|
41840
41980
|
} else {
|
|
41841
|
-
console.warn(`[threads] anchor turn
|
|
41981
|
+
console.warn(`[threads] no anchor turn found for thread ${threadId} \u2014 cannot fork`);
|
|
41842
41982
|
}
|
|
41843
41983
|
}
|
|
41844
41984
|
} catch (err) {
|
|
41845
41985
|
console.error(`[threads] forkSession failed for thread ${threadId}:`, err);
|
|
41846
41986
|
}
|
|
41847
41987
|
}
|
|
41848
|
-
const formattedPrompt = `[Quoting from your previous response]:
|
|
41988
|
+
const formattedPrompt = isAnchored ? `[Quoting from your previous response]:
|
|
41849
41989
|
> ${selectedText}
|
|
41850
41990
|
|
|
41851
|
-
${message}
|
|
41991
|
+
${message}` : message;
|
|
41852
41992
|
const newTurnId = v4_default();
|
|
41993
|
+
const attachmentsJson = attachments && attachments.length > 0 ? JSON.stringify(attachments) : null;
|
|
41853
41994
|
db2.prepare(
|
|
41854
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, created_at, updated_at)
|
|
41855
|
-
VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'pending', NULL, ?, ?, ?)`
|
|
41856
|
-
).run(newTurnId, sessionId, formattedPrompt, threadId, now, now);
|
|
41857
|
-
const
|
|
41858
|
-
provider.startTurn(session,
|
|
41995
|
+
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, attachments, created_at, updated_at)
|
|
41996
|
+
VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'pending', NULL, ?, ?, ?, ?)`
|
|
41997
|
+
).run(newTurnId, sessionId, formattedPrompt, threadId, attachmentsJson, now, now);
|
|
41998
|
+
const rawTurn = db2.prepare("SELECT * FROM turns WHERE id = ?").get(newTurnId);
|
|
41999
|
+
provider.startTurn(session, rawTurn).catch((err) => {
|
|
41859
42000
|
console.error(`[threads] Unhandled error for session ${sessionId}:`, err);
|
|
41860
42001
|
});
|
|
41861
42002
|
const threadRow = db2.prepare("SELECT * FROM discussion_threads WHERE id = ?").get(threadId);
|
|
42003
|
+
const turn = parseTurnRow(rawTurn);
|
|
41862
42004
|
const thread = {
|
|
41863
42005
|
...threadRow,
|
|
41864
|
-
turns: [
|
|
42006
|
+
turns: [turn]
|
|
41865
42007
|
};
|
|
41866
42008
|
broadcast("thread:created", { sessionId, thread, turn });
|
|
41867
42009
|
return { thread, turn };
|
|
@@ -41875,21 +42017,34 @@ ${message}`;
|
|
|
41875
42017
|
type: "object",
|
|
41876
42018
|
required: ["message"],
|
|
41877
42019
|
properties: {
|
|
41878
|
-
message: { type: "string", minLength: 1 }
|
|
42020
|
+
message: { type: "string", minLength: 1 },
|
|
42021
|
+
attachments: {
|
|
42022
|
+
type: "array",
|
|
42023
|
+
items: {
|
|
42024
|
+
type: "object",
|
|
42025
|
+
required: ["name", "media_type", "data"],
|
|
42026
|
+
properties: {
|
|
42027
|
+
name: { type: "string" },
|
|
42028
|
+
media_type: { type: "string" },
|
|
42029
|
+
data: { type: "string" }
|
|
42030
|
+
}
|
|
42031
|
+
}
|
|
42032
|
+
}
|
|
41879
42033
|
}
|
|
41880
42034
|
}
|
|
41881
42035
|
}
|
|
41882
42036
|
},
|
|
41883
42037
|
async (request, reply) => {
|
|
41884
42038
|
const { sessionId, threadId } = request.params;
|
|
41885
|
-
const { message } = request.body || {};
|
|
42039
|
+
const { message, attachments } = request.body || {};
|
|
41886
42040
|
const db2 = getDb();
|
|
41887
42041
|
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
|
|
41888
42042
|
if (!session) {
|
|
41889
42043
|
return reply.code(404).send({ error: "Session not found" });
|
|
41890
42044
|
}
|
|
41891
|
-
|
|
41892
|
-
|
|
42045
|
+
isSessionBusy(db2, session);
|
|
42046
|
+
if (isSessionBusy(db2, session, { threadId })) {
|
|
42047
|
+
return reply.code(409).send({ error: "A turn is still running in this thread" });
|
|
41893
42048
|
}
|
|
41894
42049
|
const thread = db2.prepare("SELECT * FROM discussion_threads WHERE id = ? AND session_id = ?").get(threadId, sessionId);
|
|
41895
42050
|
if (!thread) {
|
|
@@ -41900,14 +42055,16 @@ ${message}`;
|
|
|
41900
42055
|
}
|
|
41901
42056
|
const newTurnId = v4_default();
|
|
41902
42057
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42058
|
+
const attachmentsJson = attachments && attachments.length > 0 ? JSON.stringify(attachments) : null;
|
|
41903
42059
|
db2.prepare(
|
|
41904
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, created_at, updated_at)
|
|
41905
|
-
VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'pending', NULL, ?, ?, ?)`
|
|
41906
|
-
).run(newTurnId, sessionId, message, threadId, now, now);
|
|
41907
|
-
const
|
|
41908
|
-
getProvider(session.runtime_type).startTurn(session,
|
|
42060
|
+
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, attachments, created_at, updated_at)
|
|
42061
|
+
VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'pending', NULL, ?, ?, ?, ?)`
|
|
42062
|
+
).run(newTurnId, sessionId, message, threadId, attachmentsJson, now, now);
|
|
42063
|
+
const rawTurn = db2.prepare("SELECT * FROM turns WHERE id = ?").get(newTurnId);
|
|
42064
|
+
getProvider(session.runtime_type).startTurn(session, rawTurn).catch((err) => {
|
|
41909
42065
|
console.error(`[threads] followup error for session ${sessionId}:`, err);
|
|
41910
42066
|
});
|
|
42067
|
+
const turn = parseTurnRow(rawTurn);
|
|
41911
42068
|
broadcast("thread:followup", { sessionId, threadId, turn });
|
|
41912
42069
|
return { turn };
|
|
41913
42070
|
}
|
|
@@ -41959,9 +42116,12 @@ Agent: ${agent}`;
|
|
|
41959
42116
|
return reply.code(500).send({ error: "Summarization failed \u2014 thread was not resolved. Try again or resolve without sharing." });
|
|
41960
42117
|
}
|
|
41961
42118
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41962
|
-
db2.prepare(
|
|
41963
|
-
"
|
|
41964
|
-
|
|
42119
|
+
db2.prepare("UPDATE discussion_threads SET status = ?, resolved_at = ?, updated_at = ? WHERE id = ?").run(
|
|
42120
|
+
"resolved",
|
|
42121
|
+
now,
|
|
42122
|
+
now,
|
|
42123
|
+
threadId
|
|
42124
|
+
);
|
|
41965
42125
|
broadcast("thread:resolved", { sessionId, threadId, status: "resolved" });
|
|
41966
42126
|
return { summary, resolved: true };
|
|
41967
42127
|
}
|
|
@@ -41989,9 +42149,12 @@ Agent: ${agent}`;
|
|
|
41989
42149
|
}
|
|
41990
42150
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41991
42151
|
const resolvedAt = status === "resolved" ? now : null;
|
|
41992
|
-
db2.prepare(
|
|
41993
|
-
|
|
41994
|
-
|
|
42152
|
+
db2.prepare("UPDATE discussion_threads SET status = ?, resolved_at = ?, updated_at = ? WHERE id = ?").run(
|
|
42153
|
+
status,
|
|
42154
|
+
resolvedAt,
|
|
42155
|
+
now,
|
|
42156
|
+
threadId
|
|
42157
|
+
);
|
|
41995
42158
|
broadcast("thread:resolved", { sessionId, threadId, status });
|
|
41996
42159
|
return { id: threadId, status, resolved_at: resolvedAt };
|
|
41997
42160
|
}
|
|
@@ -42010,9 +42173,7 @@ Agent: ${agent}`;
|
|
|
42010
42173
|
const provider = getProvider(session.runtime_type);
|
|
42011
42174
|
provider.clearThreadBranch?.(sessionId, threadId);
|
|
42012
42175
|
}
|
|
42013
|
-
db2.prepare(
|
|
42014
|
-
"DELETE FROM items WHERE turn_id IN (SELECT id FROM turns WHERE thread_id = ?)"
|
|
42015
|
-
).run(threadId);
|
|
42176
|
+
db2.prepare("DELETE FROM items WHERE turn_id IN (SELECT id FROM turns WHERE thread_id = ?)").run(threadId);
|
|
42016
42177
|
db2.prepare("DELETE FROM turns WHERE thread_id = ?").run(threadId);
|
|
42017
42178
|
db2.prepare("DELETE FROM discussion_threads WHERE id = ?").run(threadId);
|
|
42018
42179
|
broadcast("thread:deleted", { sessionId, threadId });
|
|
@@ -42042,11 +42203,7 @@ Agent: ${agent}`;
|
|
|
42042
42203
|
}
|
|
42043
42204
|
result.push({
|
|
42044
42205
|
...tr,
|
|
42045
|
-
turns: turnRows.map((row) => (
|
|
42046
|
-
...row,
|
|
42047
|
-
token_usage: row.token_usage ? JSON.parse(row.token_usage) : null,
|
|
42048
|
-
items: itemsByTurn.get(row.id) ?? []
|
|
42049
|
-
}))
|
|
42206
|
+
turns: turnRows.map((row) => parseTurnRow(row, itemsByTurn.get(row.id) ?? []))
|
|
42050
42207
|
});
|
|
42051
42208
|
}
|
|
42052
42209
|
return result;
|
|
@@ -42074,11 +42231,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42074
42231
|
}
|
|
42075
42232
|
}
|
|
42076
42233
|
}, async (request, reply) => {
|
|
42077
|
-
const { path:
|
|
42078
|
-
if (!
|
|
42234
|
+
const { path: path4, label = null } = request.body || {};
|
|
42235
|
+
if (!path4 || !path4.trim()) {
|
|
42079
42236
|
return reply.code(400).send({ error: "Path is required" });
|
|
42080
42237
|
}
|
|
42081
|
-
const trimmedPath =
|
|
42238
|
+
const trimmedPath = path4.trim();
|
|
42082
42239
|
const db2 = getDb();
|
|
42083
42240
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
42084
42241
|
if (existing) {
|
|
@@ -42106,8 +42263,8 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42106
42263
|
"-e",
|
|
42107
42264
|
'POSIX path of (choose folder with prompt "Select a workspace directory")'
|
|
42108
42265
|
]);
|
|
42109
|
-
const
|
|
42110
|
-
return { path:
|
|
42266
|
+
const path4 = stdout.trim().replace(/\/$/, "");
|
|
42267
|
+
return { path: path4 };
|
|
42111
42268
|
} catch {
|
|
42112
42269
|
return reply.code(204).send({ cancelled: true });
|
|
42113
42270
|
}
|
|
@@ -42123,11 +42280,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42123
42280
|
}
|
|
42124
42281
|
}
|
|
42125
42282
|
}, async (request, reply) => {
|
|
42126
|
-
const { path:
|
|
42127
|
-
if (!
|
|
42283
|
+
const { path: path4 } = request.body || {};
|
|
42284
|
+
if (!path4 || !path4.trim()) {
|
|
42128
42285
|
return reply.code(400).send({ error: "Path is required" });
|
|
42129
42286
|
}
|
|
42130
|
-
const trimmedPath =
|
|
42287
|
+
const trimmedPath = path4.trim();
|
|
42131
42288
|
const db2 = getDb();
|
|
42132
42289
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
42133
42290
|
if (existing) {
|
|
@@ -42701,6 +42858,622 @@ async function registerFileRoutes(fastify) {
|
|
|
42701
42858
|
});
|
|
42702
42859
|
}
|
|
42703
42860
|
|
|
42861
|
+
// src/routes/perf-log.ts
|
|
42862
|
+
import { appendFileSync, mkdirSync, renameSync, statSync } from "node:fs";
|
|
42863
|
+
import { homedir } from "node:os";
|
|
42864
|
+
import { dirname, join } from "node:path";
|
|
42865
|
+
var MAX_BYTES = 5 * 1024 * 1024;
|
|
42866
|
+
var MAX_BATCH = 500;
|
|
42867
|
+
function perfLogPath() {
|
|
42868
|
+
return process.env.AGENT_PANE_PERF_LOG ?? join(homedir(), ".repoburg", "agent-pane", "perf.log");
|
|
42869
|
+
}
|
|
42870
|
+
function oneLine(s) {
|
|
42871
|
+
return s.replace(/[\r\n\t]+/g, " ");
|
|
42872
|
+
}
|
|
42873
|
+
async function registerPerfLogRoutes(fastify) {
|
|
42874
|
+
fastify.post(
|
|
42875
|
+
"/api/perf-log",
|
|
42876
|
+
{
|
|
42877
|
+
schema: {
|
|
42878
|
+
body: {
|
|
42879
|
+
type: "object",
|
|
42880
|
+
required: ["entries"],
|
|
42881
|
+
properties: {
|
|
42882
|
+
entries: {
|
|
42883
|
+
type: "array",
|
|
42884
|
+
maxItems: MAX_BATCH,
|
|
42885
|
+
items: {
|
|
42886
|
+
type: "object",
|
|
42887
|
+
required: ["t", "cat", "msg"],
|
|
42888
|
+
properties: {
|
|
42889
|
+
t: { type: "number" },
|
|
42890
|
+
cat: { type: "string", maxLength: 16 },
|
|
42891
|
+
msg: { type: "string", maxLength: 4e3 },
|
|
42892
|
+
ms: { type: "number" }
|
|
42893
|
+
}
|
|
42894
|
+
}
|
|
42895
|
+
}
|
|
42896
|
+
}
|
|
42897
|
+
}
|
|
42898
|
+
}
|
|
42899
|
+
},
|
|
42900
|
+
async (request, reply) => {
|
|
42901
|
+
const entries = (request.body?.entries ?? []).slice(0, MAX_BATCH);
|
|
42902
|
+
if (entries.length === 0) {
|
|
42903
|
+
return reply.send({ written: 0 });
|
|
42904
|
+
}
|
|
42905
|
+
const path4 = perfLogPath();
|
|
42906
|
+
try {
|
|
42907
|
+
mkdirSync(dirname(path4), { recursive: true });
|
|
42908
|
+
try {
|
|
42909
|
+
if (statSync(path4).size > MAX_BYTES) {
|
|
42910
|
+
renameSync(path4, `${path4}.1`);
|
|
42911
|
+
}
|
|
42912
|
+
} catch {
|
|
42913
|
+
}
|
|
42914
|
+
const lines = entries.map((e) => `${new Date(e.t).toISOString()} [${oneLine(e.cat)}] ${oneLine(e.msg)}`).join("\n");
|
|
42915
|
+
appendFileSync(path4, `${lines}
|
|
42916
|
+
`, "utf-8");
|
|
42917
|
+
return reply.send({ written: entries.length });
|
|
42918
|
+
} catch (err) {
|
|
42919
|
+
request.log.warn(`perf-log write failed: ${err.message}`);
|
|
42920
|
+
return reply.send({ written: 0 });
|
|
42921
|
+
}
|
|
42922
|
+
}
|
|
42923
|
+
);
|
|
42924
|
+
}
|
|
42925
|
+
|
|
42926
|
+
// src/routes/maintenance.ts
|
|
42927
|
+
var TRIMMABLE_KEYS = ["aggregated_output", "output"];
|
|
42928
|
+
async function registerMaintenanceRoutes(fastify) {
|
|
42929
|
+
fastify.post(
|
|
42930
|
+
"/api/maintenance/prune-items",
|
|
42931
|
+
{
|
|
42932
|
+
schema: {
|
|
42933
|
+
body: {
|
|
42934
|
+
type: "object",
|
|
42935
|
+
properties: {
|
|
42936
|
+
maxBytes: { type: "number" },
|
|
42937
|
+
vacuum: { type: "boolean" }
|
|
42938
|
+
},
|
|
42939
|
+
additionalProperties: false
|
|
42940
|
+
}
|
|
42941
|
+
}
|
|
42942
|
+
},
|
|
42943
|
+
async (request) => {
|
|
42944
|
+
const maxBytes = Math.max(1024, Math.min(1e6, request.body?.maxBytes ?? 5e4));
|
|
42945
|
+
const vacuum = request.body?.vacuum === true;
|
|
42946
|
+
const db2 = getDb();
|
|
42947
|
+
let bytesBefore = 0;
|
|
42948
|
+
let bytesAfter = 0;
|
|
42949
|
+
let pruned = 0;
|
|
42950
|
+
const rows = db2.prepare("SELECT id, data FROM items WHERE LENGTH(data) > ?").all(maxBytes);
|
|
42951
|
+
const update = db2.prepare("UPDATE items SET data = ? WHERE id = ?");
|
|
42952
|
+
for (const row of rows) {
|
|
42953
|
+
if (!row.data) continue;
|
|
42954
|
+
let data;
|
|
42955
|
+
try {
|
|
42956
|
+
data = JSON.parse(row.data);
|
|
42957
|
+
} catch {
|
|
42958
|
+
continue;
|
|
42959
|
+
}
|
|
42960
|
+
let changed = false;
|
|
42961
|
+
for (const key of TRIMMABLE_KEYS) {
|
|
42962
|
+
const v = data[key];
|
|
42963
|
+
if (typeof v === "string" && v.length > maxBytes) {
|
|
42964
|
+
data[key] = `\u2026 [pruned: kept newest ${maxBytes} bytes]
|
|
42965
|
+
` + v.slice(-maxBytes);
|
|
42966
|
+
changed = true;
|
|
42967
|
+
}
|
|
42968
|
+
}
|
|
42969
|
+
if (!changed) continue;
|
|
42970
|
+
const next = JSON.stringify(data);
|
|
42971
|
+
bytesBefore += row.data.length;
|
|
42972
|
+
bytesAfter += next.length;
|
|
42973
|
+
pruned++;
|
|
42974
|
+
update.run(next, row.id);
|
|
42975
|
+
}
|
|
42976
|
+
if (vacuum) {
|
|
42977
|
+
db2.exec("VACUUM");
|
|
42978
|
+
}
|
|
42979
|
+
return {
|
|
42980
|
+
pruned_items: pruned,
|
|
42981
|
+
bytes_before: bytesBefore,
|
|
42982
|
+
bytes_after: bytesAfter,
|
|
42983
|
+
bytes_freed: bytesBefore - bytesAfter,
|
|
42984
|
+
max_bytes: maxBytes,
|
|
42985
|
+
vacuum
|
|
42986
|
+
};
|
|
42987
|
+
}
|
|
42988
|
+
);
|
|
42989
|
+
}
|
|
42990
|
+
|
|
42991
|
+
// src/routes/vscode-web.ts
|
|
42992
|
+
import http2 from "node:http";
|
|
42993
|
+
|
|
42994
|
+
// src/vscode-web/manager.ts
|
|
42995
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
42996
|
+
import { existsSync } from "node:fs";
|
|
42997
|
+
import http from "node:http";
|
|
42998
|
+
import net from "node:net";
|
|
42999
|
+
import crypto from "node:crypto";
|
|
43000
|
+
import os from "node:os";
|
|
43001
|
+
import path2 from "node:path";
|
|
43002
|
+
import { mkdir, readdir, symlink, lstat, access, readFile, writeFile, unlink } from "node:fs/promises";
|
|
43003
|
+
var VSCODE_WEB_DATA_DIR = path2.join(os.homedir(), ".repoburg", "vscode-web");
|
|
43004
|
+
function resolveDesktopUserDir() {
|
|
43005
|
+
if (process.platform === "darwin") {
|
|
43006
|
+
return path2.join(os.homedir(), "Library", "Application Support", "Code", "User");
|
|
43007
|
+
}
|
|
43008
|
+
if (process.platform === "win32" && process.env.APPDATA) {
|
|
43009
|
+
return path2.join(process.env.APPDATA, "Code", "User");
|
|
43010
|
+
}
|
|
43011
|
+
if (process.platform === "linux") {
|
|
43012
|
+
return path2.join(os.homedir(), ".config", "Code", "User");
|
|
43013
|
+
}
|
|
43014
|
+
return null;
|
|
43015
|
+
}
|
|
43016
|
+
async function linkUnlessExists(src, dst) {
|
|
43017
|
+
await mkdir(path2.dirname(dst), { recursive: true });
|
|
43018
|
+
try {
|
|
43019
|
+
await lstat(dst);
|
|
43020
|
+
return false;
|
|
43021
|
+
} catch {
|
|
43022
|
+
await symlink(src, dst);
|
|
43023
|
+
return true;
|
|
43024
|
+
}
|
|
43025
|
+
}
|
|
43026
|
+
function fileRegistryUri(dir) {
|
|
43027
|
+
const external = `file://${dir}`;
|
|
43028
|
+
return { $mid: 1, fsPath: dir, external, path: dir, scheme: "file" };
|
|
43029
|
+
}
|
|
43030
|
+
async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
|
|
43031
|
+
try {
|
|
43032
|
+
const desktopExt = path2.join(os.homedir(), ".vscode", "extensions");
|
|
43033
|
+
let entries;
|
|
43034
|
+
try {
|
|
43035
|
+
entries = await readdir(desktopExt, { withFileTypes: true });
|
|
43036
|
+
} catch {
|
|
43037
|
+
return;
|
|
43038
|
+
}
|
|
43039
|
+
const serverExt = path2.join(dataDir, "extensions");
|
|
43040
|
+
const linkedFolders = [];
|
|
43041
|
+
for (const entry of entries) {
|
|
43042
|
+
if (!entry.isDirectory()) continue;
|
|
43043
|
+
const target = path2.join(serverExt, entry.name);
|
|
43044
|
+
await linkUnlessExists(path2.join(desktopExt, entry.name), target);
|
|
43045
|
+
const st = await lstat(target).catch(() => null);
|
|
43046
|
+
if (st?.isSymbolicLink()) linkedFolders.push(entry.name);
|
|
43047
|
+
}
|
|
43048
|
+
await mergeExtensionRegistry(desktopExt, serverExt, linkedFolders);
|
|
43049
|
+
await pruneObsolete(serverExt, linkedFolders);
|
|
43050
|
+
const desktopUser = resolveDesktopUserDir();
|
|
43051
|
+
if (!desktopUser) return;
|
|
43052
|
+
const serverUser = path2.join(dataDir, "data", "User");
|
|
43053
|
+
for (const item of ["settings.json", "keybindings.json", "snippets"]) {
|
|
43054
|
+
const src = path2.join(desktopUser, item);
|
|
43055
|
+
try {
|
|
43056
|
+
await access(src);
|
|
43057
|
+
} catch {
|
|
43058
|
+
continue;
|
|
43059
|
+
}
|
|
43060
|
+
await linkUnlessExists(src, path2.join(serverUser, item));
|
|
43061
|
+
}
|
|
43062
|
+
} catch {
|
|
43063
|
+
}
|
|
43064
|
+
}
|
|
43065
|
+
async function mergeExtensionRegistry(desktopExt, serverExt, linkedFolders) {
|
|
43066
|
+
let desktopEntries = [];
|
|
43067
|
+
try {
|
|
43068
|
+
desktopEntries = JSON.parse(await readFile(path2.join(desktopExt, "extensions.json"), "utf8"));
|
|
43069
|
+
} catch {
|
|
43070
|
+
return;
|
|
43071
|
+
}
|
|
43072
|
+
const linked = new Set(linkedFolders);
|
|
43073
|
+
const toAdd = desktopEntries.filter((e) => e.identifier?.id && linked.has(e.relativeLocation));
|
|
43074
|
+
const serverRegistryPath = path2.join(serverExt, "extensions.json");
|
|
43075
|
+
let serverEntries = [];
|
|
43076
|
+
try {
|
|
43077
|
+
serverEntries = JSON.parse(await readFile(serverRegistryPath, "utf8"));
|
|
43078
|
+
} catch {
|
|
43079
|
+
}
|
|
43080
|
+
const known = new Set(serverEntries.map((e) => `${e.identifier.id.toLowerCase()}@${e.version}`));
|
|
43081
|
+
const additions = toAdd.filter((e) => !known.has(`${e.identifier.id.toLowerCase()}@${e.version}`));
|
|
43082
|
+
if (additions.length === 0) return;
|
|
43083
|
+
for (const entry of additions) {
|
|
43084
|
+
const dir = path2.join(serverExt, entry.relativeLocation);
|
|
43085
|
+
serverEntries.push({ ...entry, location: fileRegistryUri(dir) });
|
|
43086
|
+
}
|
|
43087
|
+
await writeFile(serverRegistryPath, JSON.stringify(serverEntries));
|
|
43088
|
+
}
|
|
43089
|
+
async function pruneObsolete(serverExt, linkedFolders) {
|
|
43090
|
+
const obsoletePath = path2.join(serverExt, ".obsolete");
|
|
43091
|
+
let obsolete;
|
|
43092
|
+
try {
|
|
43093
|
+
obsolete = JSON.parse(await readFile(obsoletePath, "utf8"));
|
|
43094
|
+
} catch {
|
|
43095
|
+
return;
|
|
43096
|
+
}
|
|
43097
|
+
const linked = new Set(linkedFolders);
|
|
43098
|
+
const next = Object.fromEntries(Object.entries(obsolete).filter(([name]) => !linked.has(name)));
|
|
43099
|
+
if (Object.keys(next).length === Object.keys(obsolete).length) return;
|
|
43100
|
+
if (Object.keys(next).length === 0) {
|
|
43101
|
+
try {
|
|
43102
|
+
await unlink(obsoletePath);
|
|
43103
|
+
} catch {
|
|
43104
|
+
}
|
|
43105
|
+
} else {
|
|
43106
|
+
await writeFile(obsoletePath, JSON.stringify(next));
|
|
43107
|
+
}
|
|
43108
|
+
}
|
|
43109
|
+
var IDLE_STOP_MS = 15 * 60 * 1e3;
|
|
43110
|
+
var MAX_INSTANCES = 2;
|
|
43111
|
+
var IDLE_CHECK_MS = 3e4;
|
|
43112
|
+
var STARTUP_TIMEOUT_MS = 9e4;
|
|
43113
|
+
var PROBE_INTERVAL_MS = 500;
|
|
43114
|
+
var SIGKILL_GRACE_MS = 5e3;
|
|
43115
|
+
function resolveCodeCli() {
|
|
43116
|
+
const override = process.env.AGENTPANE_VSCODE_CLI;
|
|
43117
|
+
if (override) return override;
|
|
43118
|
+
if (process.platform === "darwin") {
|
|
43119
|
+
const bundled = "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";
|
|
43120
|
+
if (existsSync(bundled)) return bundled;
|
|
43121
|
+
}
|
|
43122
|
+
return "code";
|
|
43123
|
+
}
|
|
43124
|
+
function defaultSpawnServeWeb(port, token, folder, id) {
|
|
43125
|
+
const args = [
|
|
43126
|
+
"serve-web",
|
|
43127
|
+
"--host",
|
|
43128
|
+
"127.0.0.1",
|
|
43129
|
+
"--port",
|
|
43130
|
+
String(port),
|
|
43131
|
+
"--connection-token",
|
|
43132
|
+
token,
|
|
43133
|
+
// Instance-scoped base path: the proxy routes /vscode/<id>/* to this port.
|
|
43134
|
+
"--server-base-path",
|
|
43135
|
+
`/vscode/${id}`,
|
|
43136
|
+
"--server-data-dir",
|
|
43137
|
+
VSCODE_WEB_DATA_DIR,
|
|
43138
|
+
"--accept-server-license-terms",
|
|
43139
|
+
"--disable-telemetry"
|
|
43140
|
+
];
|
|
43141
|
+
if (folder) args.push("--default-folder", folder);
|
|
43142
|
+
return spawn2(resolveCodeCli(), args, { stdio: ["ignore", "pipe", "pipe"], detached: true });
|
|
43143
|
+
}
|
|
43144
|
+
function defaultProbe(port, token) {
|
|
43145
|
+
return new Promise((resolve, reject) => {
|
|
43146
|
+
const req = http.get(`http://127.0.0.1:${port}/vscode/?tkn=${token}`, (res) => {
|
|
43147
|
+
res.resume();
|
|
43148
|
+
resolve();
|
|
43149
|
+
});
|
|
43150
|
+
req.on("error", reject);
|
|
43151
|
+
req.setTimeout(2e3, () => {
|
|
43152
|
+
req.destroy(new Error("probe timeout"));
|
|
43153
|
+
});
|
|
43154
|
+
});
|
|
43155
|
+
}
|
|
43156
|
+
function findFreePort() {
|
|
43157
|
+
return new Promise((resolve, reject) => {
|
|
43158
|
+
const server = net.createServer();
|
|
43159
|
+
server.listen(0, "127.0.0.1", () => {
|
|
43160
|
+
const { port } = server.address();
|
|
43161
|
+
server.close(() => resolve(port));
|
|
43162
|
+
});
|
|
43163
|
+
server.on("error", reject);
|
|
43164
|
+
});
|
|
43165
|
+
}
|
|
43166
|
+
function idOfFolder(folder) {
|
|
43167
|
+
if (!folder) return "default";
|
|
43168
|
+
return crypto.createHash("sha256").update(folder).digest("hex").slice(0, 8);
|
|
43169
|
+
}
|
|
43170
|
+
function statusOf(inst) {
|
|
43171
|
+
return { id: inst.id, state: inst.state, port: inst.port, token: inst.token, error: inst.error, folder: inst.folder };
|
|
43172
|
+
}
|
|
43173
|
+
function stoppedStatus() {
|
|
43174
|
+
return { id: null, state: "stopped", port: null, token: null, error: null, folder: null };
|
|
43175
|
+
}
|
|
43176
|
+
var VscodeWebManager = class {
|
|
43177
|
+
constructor(deps) {
|
|
43178
|
+
this.deps = deps;
|
|
43179
|
+
}
|
|
43180
|
+
instances = /* @__PURE__ */ new Map();
|
|
43181
|
+
checkTimer = null;
|
|
43182
|
+
/** Instance by id (proxy + WS upgrade lookup). */
|
|
43183
|
+
getInstance(id) {
|
|
43184
|
+
return this.instances.get(id) ?? null;
|
|
43185
|
+
}
|
|
43186
|
+
status(id) {
|
|
43187
|
+
const inst = this.instances.get(id);
|
|
43188
|
+
return inst ? statusOf(inst) : stoppedStatus();
|
|
43189
|
+
}
|
|
43190
|
+
/** Reset the idle clock — called on every proxied request/WS frame/heartbeat. */
|
|
43191
|
+
markAccessed(id) {
|
|
43192
|
+
const inst = this.instances.get(id);
|
|
43193
|
+
if (inst) inst.lastAccessedAt = this.deps.now();
|
|
43194
|
+
}
|
|
43195
|
+
/**
|
|
43196
|
+
* Start (or reuse) the instance serving `folder`. Returns 'starting'
|
|
43197
|
+
* immediately; readiness is reached in the background — poll `status()`.
|
|
43198
|
+
*/
|
|
43199
|
+
async start(folder) {
|
|
43200
|
+
const id = idOfFolder(folder);
|
|
43201
|
+
const existing = this.instances.get(id);
|
|
43202
|
+
if (existing && (existing.state === "running" || existing.state === "starting")) {
|
|
43203
|
+
this.markAccessed(id);
|
|
43204
|
+
return statusOf(existing);
|
|
43205
|
+
}
|
|
43206
|
+
await this.evictIfNeeded();
|
|
43207
|
+
await this.spawnInstance(id, folder);
|
|
43208
|
+
this.startIdleCheck();
|
|
43209
|
+
return this.status(id);
|
|
43210
|
+
}
|
|
43211
|
+
/** Enforce the cap: stop the least-recently-accessed active instance. */
|
|
43212
|
+
async evictIfNeeded() {
|
|
43213
|
+
const active = [...this.instances.values()].filter((i) => i.state === "running" || i.state === "starting");
|
|
43214
|
+
for (let i = active.length; i >= MAX_INSTANCES; i--) {
|
|
43215
|
+
let oldest = null;
|
|
43216
|
+
for (const inst of active) {
|
|
43217
|
+
if (!oldest || inst.lastAccessedAt < oldest.lastAccessedAt) oldest = inst;
|
|
43218
|
+
}
|
|
43219
|
+
if (!oldest) return;
|
|
43220
|
+
active.splice(active.indexOf(oldest), 1);
|
|
43221
|
+
await this.stop(oldest.id);
|
|
43222
|
+
}
|
|
43223
|
+
}
|
|
43224
|
+
async spawnInstance(id, folder) {
|
|
43225
|
+
await this.deps.syncProfile(VSCODE_WEB_DATA_DIR);
|
|
43226
|
+
const token = crypto.randomBytes(24).toString("hex");
|
|
43227
|
+
const port = await findFreePort();
|
|
43228
|
+
const child = this.deps.spawnServeWeb(port, token, folder, id);
|
|
43229
|
+
const inst = {
|
|
43230
|
+
id,
|
|
43231
|
+
folder,
|
|
43232
|
+
port,
|
|
43233
|
+
token,
|
|
43234
|
+
state: "starting",
|
|
43235
|
+
error: null,
|
|
43236
|
+
child,
|
|
43237
|
+
lastAccessedAt: this.deps.now(),
|
|
43238
|
+
stopping: false
|
|
43239
|
+
};
|
|
43240
|
+
this.instances.set(id, inst);
|
|
43241
|
+
child.on("error", (err) => {
|
|
43242
|
+
if (inst.stopping) return;
|
|
43243
|
+
inst.child = null;
|
|
43244
|
+
inst.state = "error";
|
|
43245
|
+
inst.error = String(err);
|
|
43246
|
+
});
|
|
43247
|
+
child.on("exit", (code) => {
|
|
43248
|
+
inst.child = null;
|
|
43249
|
+
if (inst.stopping) {
|
|
43250
|
+
inst.stopping = false;
|
|
43251
|
+
} else if (inst.state === "starting") {
|
|
43252
|
+
inst.state = "error";
|
|
43253
|
+
inst.error = `serve-web exited during startup (code ${code})`;
|
|
43254
|
+
} else {
|
|
43255
|
+
inst.state = "stopped";
|
|
43256
|
+
}
|
|
43257
|
+
});
|
|
43258
|
+
void this.waitForReady(inst);
|
|
43259
|
+
}
|
|
43260
|
+
/** Poll the port until serve-web answers, or fail after the startup timeout. */
|
|
43261
|
+
waitForReady(inst) {
|
|
43262
|
+
const deadline = this.deps.now() + STARTUP_TIMEOUT_MS;
|
|
43263
|
+
return new Promise((resolve) => {
|
|
43264
|
+
const timer = setInterval(async () => {
|
|
43265
|
+
if (inst.state !== "starting") {
|
|
43266
|
+
clearInterval(timer);
|
|
43267
|
+
resolve();
|
|
43268
|
+
return;
|
|
43269
|
+
}
|
|
43270
|
+
if (this.deps.now() > deadline) {
|
|
43271
|
+
clearInterval(timer);
|
|
43272
|
+
inst.state = "error";
|
|
43273
|
+
inst.error = `serve-web did not become ready within ${STARTUP_TIMEOUT_MS / 1e3}s`;
|
|
43274
|
+
inst.stopping = true;
|
|
43275
|
+
const child = inst.child;
|
|
43276
|
+
inst.child = null;
|
|
43277
|
+
this.killChild(child, inst.id);
|
|
43278
|
+
resolve();
|
|
43279
|
+
return;
|
|
43280
|
+
}
|
|
43281
|
+
try {
|
|
43282
|
+
await this.deps.probe(inst.port, inst.token);
|
|
43283
|
+
clearInterval(timer);
|
|
43284
|
+
if (inst.state === "starting") {
|
|
43285
|
+
inst.state = "running";
|
|
43286
|
+
this.markAccessed(inst.id);
|
|
43287
|
+
}
|
|
43288
|
+
resolve();
|
|
43289
|
+
} catch {
|
|
43290
|
+
}
|
|
43291
|
+
}, PROBE_INTERVAL_MS);
|
|
43292
|
+
});
|
|
43293
|
+
}
|
|
43294
|
+
/** Stop the child process and drop the instance entry (SIGTERM → SIGKILL). */
|
|
43295
|
+
async stop(id) {
|
|
43296
|
+
const inst = this.instances.get(id);
|
|
43297
|
+
if (!inst) return stoppedStatus();
|
|
43298
|
+
inst.stopping = true;
|
|
43299
|
+
const child = inst.child;
|
|
43300
|
+
inst.child = null;
|
|
43301
|
+
this.instances.delete(id);
|
|
43302
|
+
this.killChild(child, id);
|
|
43303
|
+
return { ...statusOf(inst), state: "stopped" };
|
|
43304
|
+
}
|
|
43305
|
+
/** Kill the instance's whole process tree (SIGTERM → SIGKILL after grace).
|
|
43306
|
+
* The group kill misses the code-server node child (it re-sessions itself),
|
|
43307
|
+
* so also sweep by the instance-unique --server-base-path argument. */
|
|
43308
|
+
killChild(child, id) {
|
|
43309
|
+
if (child?.pid) {
|
|
43310
|
+
try {
|
|
43311
|
+
process.kill(-child.pid, "SIGTERM");
|
|
43312
|
+
} catch {
|
|
43313
|
+
child.kill("SIGTERM");
|
|
43314
|
+
}
|
|
43315
|
+
}
|
|
43316
|
+
this.sweepTree(id, "SIGTERM");
|
|
43317
|
+
setTimeout(() => this.sweepTree(id, "SIGKILL"), SIGKILL_GRACE_MS).unref();
|
|
43318
|
+
}
|
|
43319
|
+
/** Signal every process whose command line carries this instance's base path. */
|
|
43320
|
+
sweepTree(id, signal) {
|
|
43321
|
+
try {
|
|
43322
|
+
spawn2("pkill", [signal === "SIGKILL" ? "-9" : "-TERM", "-f", `server-base-path /vscode/${id}`], {
|
|
43323
|
+
stdio: "ignore"
|
|
43324
|
+
});
|
|
43325
|
+
} catch {
|
|
43326
|
+
}
|
|
43327
|
+
}
|
|
43328
|
+
/** Periodic idle check — stops instances silent past the 15-minute window. */
|
|
43329
|
+
startIdleCheck() {
|
|
43330
|
+
if (this.checkTimer) return;
|
|
43331
|
+
this.checkTimer = setInterval(() => {
|
|
43332
|
+
const now = this.deps.now();
|
|
43333
|
+
for (const inst of [...this.instances.values()]) {
|
|
43334
|
+
if (inst.state === "running" || inst.state === "starting") {
|
|
43335
|
+
if (now - inst.lastAccessedAt > IDLE_STOP_MS) void this.stop(inst.id);
|
|
43336
|
+
}
|
|
43337
|
+
}
|
|
43338
|
+
}, IDLE_CHECK_MS);
|
|
43339
|
+
this.checkTimer.unref?.();
|
|
43340
|
+
}
|
|
43341
|
+
};
|
|
43342
|
+
var instance = null;
|
|
43343
|
+
function getVscodeWebManager() {
|
|
43344
|
+
if (!instance) {
|
|
43345
|
+
instance = new VscodeWebManager({
|
|
43346
|
+
spawnServeWeb: defaultSpawnServeWeb,
|
|
43347
|
+
probe: defaultProbe,
|
|
43348
|
+
now: () => Date.now(),
|
|
43349
|
+
syncProfile
|
|
43350
|
+
});
|
|
43351
|
+
}
|
|
43352
|
+
return instance;
|
|
43353
|
+
}
|
|
43354
|
+
function handleVscodeWebUpgrade(request, socket, head) {
|
|
43355
|
+
const manager = getVscodeWebManager();
|
|
43356
|
+
const match = /^\/vscode\/([^/?]+)/.exec(request.url || "");
|
|
43357
|
+
const id = match?.[1] ?? "";
|
|
43358
|
+
const inst = manager.getInstance(id);
|
|
43359
|
+
if (!inst || inst.state !== "running") {
|
|
43360
|
+
socket.write("HTTP/1.1 503 Service Unavailable\r\nConnection: close\r\n\r\n");
|
|
43361
|
+
socket.destroy();
|
|
43362
|
+
return;
|
|
43363
|
+
}
|
|
43364
|
+
const upstream = http.request({
|
|
43365
|
+
host: "127.0.0.1",
|
|
43366
|
+
port: inst.port,
|
|
43367
|
+
method: "GET",
|
|
43368
|
+
path: request.url,
|
|
43369
|
+
headers: request.headers
|
|
43370
|
+
});
|
|
43371
|
+
upstream.on("upgrade", (res, upSocket, upHead) => {
|
|
43372
|
+
manager.markAccessed(id);
|
|
43373
|
+
let header = "HTTP/1.1 101 Switching Protocols\r\n";
|
|
43374
|
+
for (const [name, value] of Object.entries(res.headers)) {
|
|
43375
|
+
if (value === void 0) continue;
|
|
43376
|
+
if (Array.isArray(value)) for (const v of value) header += `${name}: ${v}\r
|
|
43377
|
+
`;
|
|
43378
|
+
else header += `${name}: ${value}\r
|
|
43379
|
+
`;
|
|
43380
|
+
}
|
|
43381
|
+
header += "\r\n";
|
|
43382
|
+
socket.write(header);
|
|
43383
|
+
if (head.length) upSocket.write(head);
|
|
43384
|
+
if (upHead.length) socket.write(upHead);
|
|
43385
|
+
socket.pipe(upSocket);
|
|
43386
|
+
upSocket.pipe(socket);
|
|
43387
|
+
socket.on("data", () => manager.markAccessed(id));
|
|
43388
|
+
socket.on("error", () => upSocket.destroy());
|
|
43389
|
+
upSocket.on("error", () => socket.destroy());
|
|
43390
|
+
socket.on("close", () => upSocket.destroy());
|
|
43391
|
+
upSocket.on("close", () => socket.destroy());
|
|
43392
|
+
});
|
|
43393
|
+
upstream.on("response", () => {
|
|
43394
|
+
socket.write("HTTP/1.1 502 Bad Gateway\r\nConnection: close\r\n\r\n");
|
|
43395
|
+
socket.destroy();
|
|
43396
|
+
});
|
|
43397
|
+
upstream.on("error", () => socket.destroy());
|
|
43398
|
+
upstream.end();
|
|
43399
|
+
}
|
|
43400
|
+
|
|
43401
|
+
// src/routes/vscode-web.ts
|
|
43402
|
+
var PROXY_METHODS = ["GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"];
|
|
43403
|
+
async function registerVscodeWebRoutes(fastify) {
|
|
43404
|
+
fastify.get(
|
|
43405
|
+
"/api/vscode-web/status",
|
|
43406
|
+
async (request) => getVscodeWebManager().status(request.query.id ?? idOfFolder(request.query.folder ?? null))
|
|
43407
|
+
);
|
|
43408
|
+
fastify.post(
|
|
43409
|
+
"/api/vscode-web/start",
|
|
43410
|
+
async (request) => getVscodeWebManager().start(request.body?.folder ?? null)
|
|
43411
|
+
);
|
|
43412
|
+
fastify.post(
|
|
43413
|
+
"/api/vscode-web/stop",
|
|
43414
|
+
async (request) => getVscodeWebManager().stop(request.body?.id ?? idOfFolder(request.body?.folder ?? null))
|
|
43415
|
+
);
|
|
43416
|
+
fastify.post(
|
|
43417
|
+
"/api/vscode-web/heartbeat",
|
|
43418
|
+
async (request) => {
|
|
43419
|
+
const manager = getVscodeWebManager();
|
|
43420
|
+
if (request.body?.id) manager.markAccessed(request.body.id);
|
|
43421
|
+
return manager.status(request.body?.id ?? "");
|
|
43422
|
+
}
|
|
43423
|
+
);
|
|
43424
|
+
await fastify.register(async (scope) => {
|
|
43425
|
+
scope.addContentTypeParser("*", { parseAs: "buffer" }, (_req, body, done) => done(null, body));
|
|
43426
|
+
scope.route({
|
|
43427
|
+
method: [...PROXY_METHODS],
|
|
43428
|
+
url: "/vscode/:id",
|
|
43429
|
+
handler: proxyHandler
|
|
43430
|
+
});
|
|
43431
|
+
scope.route({
|
|
43432
|
+
method: [...PROXY_METHODS],
|
|
43433
|
+
url: "/vscode/:id/*",
|
|
43434
|
+
handler: proxyHandler
|
|
43435
|
+
});
|
|
43436
|
+
});
|
|
43437
|
+
}
|
|
43438
|
+
function proxyHandler(request, reply) {
|
|
43439
|
+
const manager = getVscodeWebManager();
|
|
43440
|
+
const inst = manager.getInstance(String(request.params.id));
|
|
43441
|
+
if (!inst || inst.state !== "running") {
|
|
43442
|
+
reply.code(503);
|
|
43443
|
+
void reply.send({ error: "VS Code web server is not running" });
|
|
43444
|
+
return;
|
|
43445
|
+
}
|
|
43446
|
+
manager.markAccessed(inst.id);
|
|
43447
|
+
const upstream = http2.request(
|
|
43448
|
+
{
|
|
43449
|
+
host: "127.0.0.1",
|
|
43450
|
+
port: inst.port,
|
|
43451
|
+
method: request.method,
|
|
43452
|
+
path: request.raw.url,
|
|
43453
|
+
headers: request.raw.headers
|
|
43454
|
+
},
|
|
43455
|
+
(res) => {
|
|
43456
|
+
reply.hijack();
|
|
43457
|
+
reply.raw.writeHead(res.statusCode ?? 502, res.headers);
|
|
43458
|
+
res.pipe(reply.raw);
|
|
43459
|
+
}
|
|
43460
|
+
);
|
|
43461
|
+
upstream.on("error", () => {
|
|
43462
|
+
if (reply.raw.headersSent) {
|
|
43463
|
+
reply.raw.destroy();
|
|
43464
|
+
return;
|
|
43465
|
+
}
|
|
43466
|
+
reply.hijack();
|
|
43467
|
+
reply.raw.writeHead(502, { "content-type": "application/json" });
|
|
43468
|
+
reply.raw.end('{"error":"vscode serve-web unreachable"}');
|
|
43469
|
+
});
|
|
43470
|
+
const body = request.body;
|
|
43471
|
+
if (body && body.length > 0 && request.method !== "GET" && request.method !== "HEAD") {
|
|
43472
|
+
upstream.write(body);
|
|
43473
|
+
}
|
|
43474
|
+
upstream.end();
|
|
43475
|
+
}
|
|
43476
|
+
|
|
42704
43477
|
// src/codex/item-mapper.ts
|
|
42705
43478
|
function mapItemData(item) {
|
|
42706
43479
|
switch (item.type) {
|
|
@@ -42881,7 +43654,7 @@ async function startTurn(session, turn) {
|
|
|
42881
43654
|
now2,
|
|
42882
43655
|
turn.id
|
|
42883
43656
|
);
|
|
42884
|
-
|
|
43657
|
+
recomputeSessionRunning(db2, session.id, "failed");
|
|
42885
43658
|
broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: errMsg });
|
|
42886
43659
|
return;
|
|
42887
43660
|
}
|
|
@@ -42932,7 +43705,7 @@ async function startTurn(session, turn) {
|
|
|
42932
43705
|
db3.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("completed", now2, turn.id);
|
|
42933
43706
|
broadcast("turn:completed", { sessionId: session.id, turnId: turn.id, hasUnreviewed: true });
|
|
42934
43707
|
}
|
|
42935
|
-
|
|
43708
|
+
recomputeSessionRunning(db3, session.id, "active", true);
|
|
42936
43709
|
syncThreadTitle(session.id);
|
|
42937
43710
|
};
|
|
42938
43711
|
const handleTurnFailed = (params) => {
|
|
@@ -42948,7 +43721,7 @@ async function startTurn(session, turn) {
|
|
|
42948
43721
|
now2,
|
|
42949
43722
|
turn.id
|
|
42950
43723
|
);
|
|
42951
|
-
|
|
43724
|
+
recomputeSessionRunning(db3, session.id, "failed");
|
|
42952
43725
|
broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: p.error.message });
|
|
42953
43726
|
};
|
|
42954
43727
|
const handleAgentMessageDelta = (params) => {
|
|
@@ -43002,7 +43775,7 @@ async function startTurn(session, turn) {
|
|
|
43002
43775
|
now2,
|
|
43003
43776
|
turn.id
|
|
43004
43777
|
);
|
|
43005
|
-
|
|
43778
|
+
recomputeSessionRunning(db3, session.id, "failed");
|
|
43006
43779
|
broadcast("turn:failed", {
|
|
43007
43780
|
sessionId: session.id,
|
|
43008
43781
|
turnId: turn.id,
|
|
@@ -43019,7 +43792,7 @@ async function startTurn(session, turn) {
|
|
|
43019
43792
|
now2,
|
|
43020
43793
|
turn.id
|
|
43021
43794
|
);
|
|
43022
|
-
|
|
43795
|
+
recomputeSessionRunning(db2, session.id, "failed");
|
|
43023
43796
|
broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: errMsg });
|
|
43024
43797
|
turnDone = true;
|
|
43025
43798
|
}
|
|
@@ -43070,7 +43843,7 @@ function handleItemEvent(params, sessionId, turnId, status, broadcastEvent) {
|
|
|
43070
43843
|
};
|
|
43071
43844
|
broadcast(broadcastEvent, { sessionId, turnId, item: wsItem });
|
|
43072
43845
|
}
|
|
43073
|
-
async function interruptTurn(sessionId) {
|
|
43846
|
+
async function interruptTurn(sessionId, _threadId) {
|
|
43074
43847
|
const entry = sessionMap.get(sessionId);
|
|
43075
43848
|
if (!entry || !entry.turnId) return false;
|
|
43076
43849
|
try {
|
|
@@ -43081,7 +43854,7 @@ async function interruptTurn(sessionId) {
|
|
|
43081
43854
|
const db2 = getDb();
|
|
43082
43855
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
43083
43856
|
db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("aborted", now, entry.turnId);
|
|
43084
|
-
|
|
43857
|
+
recomputeSessionRunning(db2, sessionId);
|
|
43085
43858
|
broadcast("turn:cancelled", { sessionId, turnId: entry.turnId });
|
|
43086
43859
|
entry.turnId = null;
|
|
43087
43860
|
return true;
|
|
@@ -43299,7 +44072,7 @@ var codexProvider = {
|
|
|
43299
44072
|
import { query, forkSession as sdkForkSession } from "@anthropic-ai/claude-agent-sdk";
|
|
43300
44073
|
import { readFileSync as readFileSync2 } from "fs";
|
|
43301
44074
|
import { tmpdir } from "os";
|
|
43302
|
-
import { join } from "path";
|
|
44075
|
+
import { join as join2 } from "path";
|
|
43303
44076
|
|
|
43304
44077
|
// src/claude/claude-message-mapper.ts
|
|
43305
44078
|
function mapAssistantContent(content, messageId, thinkingTexts) {
|
|
@@ -43378,9 +44151,9 @@ function mapToolUse(block) {
|
|
|
43378
44151
|
};
|
|
43379
44152
|
}
|
|
43380
44153
|
function deriveFileChangeData(input, toolName) {
|
|
43381
|
-
const
|
|
44154
|
+
const path4 = input.file_path ?? input.notebook_path ?? "";
|
|
43382
44155
|
const kind = toolName === "Write" ? "add" : "modify";
|
|
43383
|
-
return { changes: [{ path:
|
|
44156
|
+
return { changes: [{ path: path4, kind }], status: "in_progress" };
|
|
43384
44157
|
}
|
|
43385
44158
|
function extractToolResultText(content) {
|
|
43386
44159
|
if (!content) return "";
|
|
@@ -43571,8 +44344,13 @@ async function ensureSessionStarted(session, mapKey, resumeSessionId) {
|
|
|
43571
44344
|
const staleItems = db2.prepare(
|
|
43572
44345
|
"UPDATE items SET status = 'failed', updated_at = ? WHERE status = 'in_progress' AND turn_id IN (SELECT id FROM turns WHERE session_id = ?)"
|
|
43573
44346
|
).run(now, session.id);
|
|
43574
|
-
db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
|
|
43575
|
-
|
|
44347
|
+
db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
|
|
44348
|
+
"failed",
|
|
44349
|
+
errMsg,
|
|
44350
|
+
now,
|
|
44351
|
+
entry.turnId
|
|
44352
|
+
);
|
|
44353
|
+
recomputeSessionRunning(db2, session.id, "failed");
|
|
43576
44354
|
broadcast("turn:failed", { sessionId: session.id, turnId: entry.turnId, error: errMsg });
|
|
43577
44355
|
if (staleItems.changes > 0) {
|
|
43578
44356
|
const staleRows = db2.prepare(
|
|
@@ -43621,8 +44399,13 @@ async function startTurn2(session, turn) {
|
|
|
43621
44399
|
} catch (err) {
|
|
43622
44400
|
const errMsg = `Failed to start Claude query: ${err.message}`;
|
|
43623
44401
|
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
43624
|
-
db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
|
|
43625
|
-
|
|
44402
|
+
db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
|
|
44403
|
+
"failed",
|
|
44404
|
+
errMsg,
|
|
44405
|
+
now2,
|
|
44406
|
+
turn.id
|
|
44407
|
+
);
|
|
44408
|
+
recomputeSessionRunning(db2, session.id, "failed");
|
|
43626
44409
|
broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: errMsg });
|
|
43627
44410
|
return;
|
|
43628
44411
|
}
|
|
@@ -43657,7 +44440,11 @@ async function startTurn2(session, turn) {
|
|
|
43657
44440
|
if (att.media_type.startsWith("image/")) {
|
|
43658
44441
|
blocks.push({
|
|
43659
44442
|
type: "image",
|
|
43660
|
-
source: {
|
|
44443
|
+
source: {
|
|
44444
|
+
type: "base64",
|
|
44445
|
+
media_type: att.media_type,
|
|
44446
|
+
data: att.data
|
|
44447
|
+
}
|
|
43661
44448
|
});
|
|
43662
44449
|
} else if (att.media_type === "application/pdf") {
|
|
43663
44450
|
blocks.push({
|
|
@@ -43698,17 +44485,43 @@ async function handleMessage(message, sessionId, turnId, entry, db2) {
|
|
|
43698
44485
|
);
|
|
43699
44486
|
}
|
|
43700
44487
|
} else if (sub === "compact_boundary") {
|
|
43701
|
-
handleCompactBoundary(
|
|
44488
|
+
handleCompactBoundary(
|
|
44489
|
+
message,
|
|
44490
|
+
sessionId,
|
|
44491
|
+
turnId,
|
|
44492
|
+
db2
|
|
44493
|
+
);
|
|
43702
44494
|
} else if (sub === "task_started") {
|
|
43703
|
-
handleTaskStarted(
|
|
44495
|
+
handleTaskStarted(
|
|
44496
|
+
message,
|
|
44497
|
+
sessionId,
|
|
44498
|
+
turnId,
|
|
44499
|
+
entry,
|
|
44500
|
+
db2
|
|
44501
|
+
);
|
|
43704
44502
|
} else if (sub === "task_progress") {
|
|
43705
|
-
handleTaskProgress(
|
|
44503
|
+
handleTaskProgress(
|
|
44504
|
+
message,
|
|
44505
|
+
sessionId,
|
|
44506
|
+
turnId,
|
|
44507
|
+
entry,
|
|
44508
|
+
db2
|
|
44509
|
+
);
|
|
43706
44510
|
} else if (sub === "task_updated") {
|
|
43707
44511
|
handleTaskUpdated(message, sessionId, turnId, db2);
|
|
43708
44512
|
} else if (sub === "task_notification") {
|
|
43709
|
-
handleTaskNotification(
|
|
44513
|
+
handleTaskNotification(
|
|
44514
|
+
message,
|
|
44515
|
+
sessionId,
|
|
44516
|
+
turnId,
|
|
44517
|
+
entry,
|
|
44518
|
+
db2
|
|
44519
|
+
);
|
|
43710
44520
|
} else if (sub === "background_tasks_changed") {
|
|
43711
|
-
handleBackgroundTasksChanged(
|
|
44521
|
+
handleBackgroundTasksChanged(
|
|
44522
|
+
message,
|
|
44523
|
+
sessionId
|
|
44524
|
+
);
|
|
43712
44525
|
}
|
|
43713
44526
|
}
|
|
43714
44527
|
break;
|
|
@@ -43852,7 +44665,7 @@ function constructMonitorOutputPath(entry, taskId) {
|
|
|
43852
44665
|
if (!entry.sessionId) return "";
|
|
43853
44666
|
const uid = typeof process.getuid === "function" ? process.getuid() : 0;
|
|
43854
44667
|
const encodedCwd = entry.cwd.replace(/\//g, "-");
|
|
43855
|
-
return
|
|
44668
|
+
return join2(tmpdir(), `claude-${uid}`, encodedCwd, entry.sessionId, "tasks", `${taskId}.output`);
|
|
43856
44669
|
}
|
|
43857
44670
|
function handleTaskStarted(message, sessionId, turnId, entry, db2) {
|
|
43858
44671
|
const m = message;
|
|
@@ -43982,11 +44795,7 @@ async function handleResultMessage(message, sessionId, turnId, entry, db2) {
|
|
|
43982
44795
|
if (message.subtype === "success") {
|
|
43983
44796
|
const usage = mapUsage(message.usage);
|
|
43984
44797
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
43985
|
-
db2.prepare("UPDATE turns SET token_usage = ?, updated_at = ? WHERE id = ?").run(
|
|
43986
|
-
JSON.stringify(usage),
|
|
43987
|
-
now,
|
|
43988
|
-
turnId
|
|
43989
|
-
);
|
|
44798
|
+
db2.prepare("UPDATE turns SET token_usage = ?, updated_at = ? WHERE id = ?").run(JSON.stringify(usage), now, turnId);
|
|
43990
44799
|
broadcast("turn:tokenUsage", { sessionId, turnId, usage });
|
|
43991
44800
|
try {
|
|
43992
44801
|
const ctx = await entry.query.getContextUsage();
|
|
@@ -44010,8 +44819,13 @@ async function handleResultMessage(message, sessionId, turnId, entry, db2) {
|
|
|
44010
44819
|
} else {
|
|
44011
44820
|
const errorMsg = message.errors?.join("; ") ?? "Claude turn failed";
|
|
44012
44821
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
44013
|
-
db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
|
|
44014
|
-
|
|
44822
|
+
db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
|
|
44823
|
+
"failed",
|
|
44824
|
+
errorMsg,
|
|
44825
|
+
now,
|
|
44826
|
+
turnId
|
|
44827
|
+
);
|
|
44828
|
+
recomputeSessionRunning(db2, sessionId, "failed");
|
|
44015
44829
|
broadcast("turn:failed", { sessionId, turnId, error: errorMsg });
|
|
44016
44830
|
}
|
|
44017
44831
|
}
|
|
@@ -44029,7 +44843,7 @@ function completeTurn(db2, sessionId, turnId, usage) {
|
|
|
44029
44843
|
db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("completed", now, turnId);
|
|
44030
44844
|
broadcast("turn:completed", { sessionId, turnId, hasUnreviewed: true });
|
|
44031
44845
|
}
|
|
44032
|
-
|
|
44846
|
+
recomputeSessionRunning(db2, sessionId, "active", true);
|
|
44033
44847
|
syncThreadTitle2(sessionId);
|
|
44034
44848
|
}
|
|
44035
44849
|
function upsertItem(db2, desc, sessionId, turnId, status, broadcastEvent) {
|
|
@@ -44060,26 +44874,56 @@ function upsertItem(db2, desc, sessionId, turnId, status, broadcastEvent) {
|
|
|
44060
44874
|
};
|
|
44061
44875
|
broadcast(broadcastEvent, { sessionId, turnId, item: wsItem });
|
|
44062
44876
|
}
|
|
44063
|
-
async function interruptTurn2(sessionId) {
|
|
44064
|
-
let entry
|
|
44065
|
-
|
|
44066
|
-
|
|
44067
|
-
|
|
44068
|
-
|
|
44069
|
-
|
|
44877
|
+
async function interruptTurn2(sessionId, threadId) {
|
|
44878
|
+
let entry;
|
|
44879
|
+
let entryKey = null;
|
|
44880
|
+
if (threadId) {
|
|
44881
|
+
entryKey = `${sessionId}:thread:${threadId}`;
|
|
44882
|
+
entry = sessionMap2.get(entryKey);
|
|
44883
|
+
} else {
|
|
44884
|
+
entry = sessionMap2.get(sessionId);
|
|
44885
|
+
entryKey = sessionId;
|
|
44886
|
+
if (!entry || !entry.turnId) {
|
|
44887
|
+
entryKey = null;
|
|
44888
|
+
for (const [key, threadEntry] of sessionMap2) {
|
|
44889
|
+
if (key.startsWith(`${sessionId}:thread:`) && threadEntry.turnId) {
|
|
44890
|
+
entry = threadEntry;
|
|
44891
|
+
entryKey = key;
|
|
44892
|
+
break;
|
|
44893
|
+
}
|
|
44070
44894
|
}
|
|
44071
44895
|
}
|
|
44072
44896
|
}
|
|
44073
|
-
if (
|
|
44897
|
+
if (entry && entry.turnId && entryKey) {
|
|
44898
|
+
const turnId = entry.turnId;
|
|
44899
|
+
try {
|
|
44900
|
+
await entry.query.interrupt();
|
|
44901
|
+
const db2 = getDb();
|
|
44902
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
44903
|
+
db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("aborted", now, turnId);
|
|
44904
|
+
recomputeSessionRunning(db2, sessionId);
|
|
44905
|
+
broadcast("turn:cancelled", { sessionId, turnId });
|
|
44906
|
+
streamingMessageIds.delete(turnId);
|
|
44907
|
+
entry.turnId = null;
|
|
44908
|
+
return true;
|
|
44909
|
+
} catch {
|
|
44910
|
+
entry.promptQueue.close();
|
|
44911
|
+
entry.query.close();
|
|
44912
|
+
streamingMessageIds.delete(turnId);
|
|
44913
|
+
sessionMap2.delete(entryKey);
|
|
44914
|
+
}
|
|
44915
|
+
}
|
|
44074
44916
|
try {
|
|
44075
|
-
await entry.query.interrupt();
|
|
44076
44917
|
const db2 = getDb();
|
|
44918
|
+
const orphan = db2.prepare(
|
|
44919
|
+
`SELECT id FROM turns WHERE session_id = ? ${threadId ? "AND thread_id = ?" : ""} AND status IN ('pending', 'running') ORDER BY created_at DESC LIMIT 1`
|
|
44920
|
+
).get(...threadId ? [sessionId, threadId] : [sessionId]);
|
|
44921
|
+
if (!orphan) return false;
|
|
44077
44922
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
44078
|
-
db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("aborted", now,
|
|
44079
|
-
|
|
44080
|
-
broadcast("turn:cancelled", { sessionId, turnId:
|
|
44081
|
-
streamingMessageIds.delete(
|
|
44082
|
-
entry.turnId = null;
|
|
44923
|
+
db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("aborted", now, orphan.id);
|
|
44924
|
+
recomputeSessionRunning(db2, sessionId);
|
|
44925
|
+
broadcast("turn:cancelled", { sessionId, turnId: orphan.id });
|
|
44926
|
+
streamingMessageIds.delete(orphan.id);
|
|
44083
44927
|
return true;
|
|
44084
44928
|
} catch {
|
|
44085
44929
|
return false;
|
|
@@ -44340,8 +45184,8 @@ var RepoburgHttpClient = class {
|
|
|
44340
45184
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
44341
45185
|
}
|
|
44342
45186
|
/** Perform a JSON request. Throws a concise error on non-OK/non-JSON responses. */
|
|
44343
|
-
async request(method,
|
|
44344
|
-
const response = await fetch(`${this.baseUrl}${
|
|
45187
|
+
async request(method, path4, body) {
|
|
45188
|
+
const response = await fetch(`${this.baseUrl}${path4}`, {
|
|
44345
45189
|
method,
|
|
44346
45190
|
headers: { "Content-Type": "application/json" },
|
|
44347
45191
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
@@ -44350,17 +45194,17 @@ var RepoburgHttpClient = class {
|
|
|
44350
45194
|
if (!response.ok) {
|
|
44351
45195
|
if (isHtml(text)) {
|
|
44352
45196
|
throw new Error(
|
|
44353
|
-
`${method} ${
|
|
45197
|
+
`${method} ${path4} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
44354
45198
|
);
|
|
44355
45199
|
}
|
|
44356
|
-
throw new Error(`${method} ${
|
|
45200
|
+
throw new Error(`${method} ${path4} failed: ${response.status} ${text}`);
|
|
44357
45201
|
}
|
|
44358
45202
|
if (text.length === 0) return void 0;
|
|
44359
45203
|
try {
|
|
44360
45204
|
return JSON.parse(text);
|
|
44361
45205
|
} catch {
|
|
44362
45206
|
throw new Error(
|
|
44363
|
-
`${method} ${
|
|
45207
|
+
`${method} ${path4} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
44364
45208
|
);
|
|
44365
45209
|
}
|
|
44366
45210
|
}
|
|
@@ -44415,7 +45259,7 @@ var RepoburgHttpClient = class {
|
|
|
44415
45259
|
};
|
|
44416
45260
|
|
|
44417
45261
|
// src/repoburg/backend-resolver.ts
|
|
44418
|
-
import
|
|
45262
|
+
import path3 from "node:path";
|
|
44419
45263
|
var HEALTH_POLL_INTERVAL_MS = 1e3;
|
|
44420
45264
|
var HEALTH_TIMEOUT_MS = 3e4;
|
|
44421
45265
|
function daemonBaseUrl() {
|
|
@@ -44470,7 +45314,7 @@ async function backendHealthy(baseUrl, expectedPath) {
|
|
|
44470
45314
|
const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
|
|
44471
45315
|
if (health.status !== "ok") return false;
|
|
44472
45316
|
if (expectedPath && health.projectPath) {
|
|
44473
|
-
return
|
|
45317
|
+
return path3.resolve(health.projectPath) === path3.resolve(expectedPath);
|
|
44474
45318
|
}
|
|
44475
45319
|
return true;
|
|
44476
45320
|
} catch {
|
|
@@ -44523,7 +45367,7 @@ async function resolveBackendUrl(projectPath, opts = {}) {
|
|
|
44523
45367
|
if (envUrl) {
|
|
44524
45368
|
return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
|
|
44525
45369
|
}
|
|
44526
|
-
const absPath =
|
|
45370
|
+
const absPath = path3.resolve(projectPath);
|
|
44527
45371
|
const daemon = daemonBaseUrl();
|
|
44528
45372
|
const cached = resolvedCache.get(absPath);
|
|
44529
45373
|
if (cached && await backendHealthy(cached.baseUrl, absPath)) {
|
|
@@ -45163,7 +46007,7 @@ var TurnProjector = class {
|
|
|
45163
46007
|
db2.prepare(
|
|
45164
46008
|
"UPDATE turns SET status = ?, agent_response = ?, token_usage = ?, updated_at = ? WHERE id = ?"
|
|
45165
46009
|
).run("completed", responseText || null, usage ? JSON.stringify(usage) : null, now, this.deps.turnId);
|
|
45166
|
-
|
|
46010
|
+
recomputeSessionRunning(db2, this.deps.agentPaneSessionId, "active", true);
|
|
45167
46011
|
broadcast("turn:completed", {
|
|
45168
46012
|
sessionId: this.deps.agentPaneSessionId,
|
|
45169
46013
|
turnId: this.deps.turnId,
|
|
@@ -45300,7 +46144,7 @@ var TurnProjector = class {
|
|
|
45300
46144
|
now,
|
|
45301
46145
|
this.deps.turnId
|
|
45302
46146
|
);
|
|
45303
|
-
|
|
46147
|
+
recomputeSessionRunning(db2, this.deps.agentPaneSessionId, "failed");
|
|
45304
46148
|
broadcast("turn:failed", {
|
|
45305
46149
|
sessionId: this.deps.agentPaneSessionId,
|
|
45306
46150
|
turnId: this.deps.turnId,
|
|
@@ -45317,7 +46161,7 @@ var TurnProjector = class {
|
|
|
45317
46161
|
now,
|
|
45318
46162
|
this.deps.turnId
|
|
45319
46163
|
);
|
|
45320
|
-
|
|
46164
|
+
recomputeSessionRunning(db2, this.deps.agentPaneSessionId);
|
|
45321
46165
|
broadcast("turn:cancelled", {
|
|
45322
46166
|
sessionId: this.deps.agentPaneSessionId,
|
|
45323
46167
|
turnId: this.deps.turnId
|
|
@@ -45386,7 +46230,7 @@ var TurnProjector = class {
|
|
|
45386
46230
|
db2.prepare(
|
|
45387
46231
|
"UPDATE turns SET status = ?, agent_response = ?, token_usage = ?, updated_at = ? WHERE id = ?"
|
|
45388
46232
|
).run("completed", responseText || null, usage ? JSON.stringify(usage) : null, now, this.deps.turnId);
|
|
45389
|
-
|
|
46233
|
+
recomputeSessionRunning(db2, this.deps.agentPaneSessionId, "active", true);
|
|
45390
46234
|
broadcast("turn:completed", {
|
|
45391
46235
|
sessionId: this.deps.agentPaneSessionId,
|
|
45392
46236
|
turnId: this.deps.turnId,
|
|
@@ -45612,7 +46456,7 @@ function failTurnBeforeStart(db2, sessionId, turnId, error) {
|
|
|
45612
46456
|
now,
|
|
45613
46457
|
turnId
|
|
45614
46458
|
);
|
|
45615
|
-
|
|
46459
|
+
recomputeSessionRunning(db2, sessionId, "failed");
|
|
45616
46460
|
broadcast("turn:failed", { sessionId, turnId, error });
|
|
45617
46461
|
}
|
|
45618
46462
|
function failTurn(entry, error) {
|
|
@@ -45635,7 +46479,7 @@ function failTurn(entry, error) {
|
|
|
45635
46479
|
active.turnId,
|
|
45636
46480
|
"in_progress"
|
|
45637
46481
|
);
|
|
45638
|
-
|
|
46482
|
+
recomputeSessionRunning(db2, entry.agentPaneSessionId, "failed");
|
|
45639
46483
|
broadcast("turn:failed", { sessionId: entry.agentPaneSessionId, turnId: active.turnId, error });
|
|
45640
46484
|
}
|
|
45641
46485
|
async function runStreamLoop(entry, projector) {
|
|
@@ -45752,9 +46596,9 @@ async function startTurn3(session, turn) {
|
|
|
45752
46596
|
failTurn(entry, err.message);
|
|
45753
46597
|
}
|
|
45754
46598
|
}
|
|
45755
|
-
async function interruptTurn3(sessionId) {
|
|
45756
|
-
let entry = sessionMap3.get(sessionId);
|
|
45757
|
-
if (!entry?.activeTurn) {
|
|
46599
|
+
async function interruptTurn3(sessionId, threadId) {
|
|
46600
|
+
let entry = threadId ? sessionMap3.get(`${sessionId}:thread:${threadId}`) : sessionMap3.get(sessionId);
|
|
46601
|
+
if (!threadId && !entry?.activeTurn) {
|
|
45758
46602
|
for (const [key, threadEntry] of sessionMap3) {
|
|
45759
46603
|
if (key.startsWith(`${sessionId}:thread:`) && threadEntry.activeTurn) {
|
|
45760
46604
|
entry = threadEntry;
|
|
@@ -45778,7 +46622,7 @@ async function interruptTurn3(sessionId) {
|
|
|
45778
46622
|
active.turnId,
|
|
45779
46623
|
"in_progress"
|
|
45780
46624
|
);
|
|
45781
|
-
|
|
46625
|
+
recomputeSessionRunning(db2, sessionId);
|
|
45782
46626
|
broadcast("turn:cancelled", { sessionId, turnId: active.turnId });
|
|
45783
46627
|
return true;
|
|
45784
46628
|
}
|
|
@@ -45934,6 +46778,9 @@ async function createAgentPaneApp(dbPath) {
|
|
|
45934
46778
|
await registerPluginRoutes(fastify);
|
|
45935
46779
|
await registerMcpRoutes(fastify);
|
|
45936
46780
|
await registerFileRoutes(fastify);
|
|
46781
|
+
await registerPerfLogRoutes(fastify);
|
|
46782
|
+
await registerMaintenanceRoutes(fastify);
|
|
46783
|
+
await registerVscodeWebRoutes(fastify);
|
|
45937
46784
|
const wss2 = initWs();
|
|
45938
46785
|
return { fastify, wss: wss2 };
|
|
45939
46786
|
}
|
|
@@ -45943,6 +46790,10 @@ var PORT = Number(process.env.AGENT_PANE_PORT ?? 3003);
|
|
|
45943
46790
|
async function main() {
|
|
45944
46791
|
const { fastify, wss: wss2 } = await createAgentPaneApp("data.db");
|
|
45945
46792
|
fastify.server.on("upgrade", (req, socket, head) => {
|
|
46793
|
+
if ((req.url || "").startsWith("/vscode")) {
|
|
46794
|
+
handleVscodeWebUpgrade(req, socket, head);
|
|
46795
|
+
return;
|
|
46796
|
+
}
|
|
45946
46797
|
const wsServer = getWss();
|
|
45947
46798
|
if (wsServer) {
|
|
45948
46799
|
handleUpgrade(wsServer, req, socket, head);
|