repoburg 1.3.315 → 1.3.316
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 +779 -383
- package/agent-pane/backend/dist/server.js +781 -385
- package/agent-pane/frontend/dist/assets/{TerminalView-HheF07Iz.js → TerminalView-CKPhyFtE.js} +1 -1
- package/agent-pane/frontend/dist/assets/index-D315G0hv.js +851 -0
- package/agent-pane/frontend/dist/assets/{index-PWGU-lZn.css → index-nEHdBY3j.css} +1 -1
- package/agent-pane/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/tabtape/extension/dist/build-info.json +3 -3
- package/tabtape/extension/dist/manifest.json +1 -1
- package/tabtape/ui/dist/build-info.json +3 -3
- package/agent-pane/frontend/dist/assets/index-Do_-oQ87.js +0 -846
|
@@ -6128,8 +6128,8 @@ var require_req = __commonJS({
|
|
|
6128
6128
|
if (req.originalUrl) {
|
|
6129
6129
|
_req.url = req.originalUrl;
|
|
6130
6130
|
} else {
|
|
6131
|
-
const
|
|
6132
|
-
_req.url = typeof
|
|
6131
|
+
const path21 = req.path;
|
|
6132
|
+
_req.url = typeof path21 === "string" ? path21 : req.url ? req.url.path || req.url : void 0;
|
|
6133
6133
|
}
|
|
6134
6134
|
if (req.query) {
|
|
6135
6135
|
_req.query = req.query;
|
|
@@ -6294,14 +6294,14 @@ var require_redact = __commonJS({
|
|
|
6294
6294
|
}
|
|
6295
6295
|
return obj2;
|
|
6296
6296
|
}
|
|
6297
|
-
function parsePath(
|
|
6297
|
+
function parsePath(path21) {
|
|
6298
6298
|
const parts = [];
|
|
6299
6299
|
let current = "";
|
|
6300
6300
|
let inBrackets = false;
|
|
6301
6301
|
let inQuotes = false;
|
|
6302
6302
|
let quoteChar = "";
|
|
6303
|
-
for (let i = 0; i <
|
|
6304
|
-
const char =
|
|
6303
|
+
for (let i = 0; i < path21.length; i++) {
|
|
6304
|
+
const char = path21[i];
|
|
6305
6305
|
if (!inBrackets && char === ".") {
|
|
6306
6306
|
if (current) {
|
|
6307
6307
|
parts.push(current);
|
|
@@ -6432,10 +6432,10 @@ var require_redact = __commonJS({
|
|
|
6432
6432
|
return current;
|
|
6433
6433
|
}
|
|
6434
6434
|
function redactPaths(obj2, paths, censor, remove = false) {
|
|
6435
|
-
for (const
|
|
6436
|
-
const parts = parsePath(
|
|
6435
|
+
for (const path21 of paths) {
|
|
6436
|
+
const parts = parsePath(path21);
|
|
6437
6437
|
if (parts.includes("*")) {
|
|
6438
|
-
redactWildcardPath(obj2, parts, censor,
|
|
6438
|
+
redactWildcardPath(obj2, parts, censor, path21, remove);
|
|
6439
6439
|
} else {
|
|
6440
6440
|
if (remove) {
|
|
6441
6441
|
removeKey(obj2, parts);
|
|
@@ -6520,8 +6520,8 @@ var require_redact = __commonJS({
|
|
|
6520
6520
|
}
|
|
6521
6521
|
} else {
|
|
6522
6522
|
if (afterWildcard.includes("*")) {
|
|
6523
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
6524
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
6523
|
+
const wrappedCensor = typeof censor === "function" ? (value, path21) => {
|
|
6524
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path21];
|
|
6525
6525
|
return censor(value, fullPath);
|
|
6526
6526
|
} : censor;
|
|
6527
6527
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -6556,8 +6556,8 @@ var require_redact = __commonJS({
|
|
|
6556
6556
|
return null;
|
|
6557
6557
|
}
|
|
6558
6558
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
6559
|
-
for (const
|
|
6560
|
-
const parts = parsePath(
|
|
6559
|
+
for (const path21 of pathsToClone) {
|
|
6560
|
+
const parts = parsePath(path21);
|
|
6561
6561
|
let current = pathStructure;
|
|
6562
6562
|
for (let i = 0; i < parts.length; i++) {
|
|
6563
6563
|
const part = parts[i];
|
|
@@ -6609,24 +6609,24 @@ var require_redact = __commonJS({
|
|
|
6609
6609
|
}
|
|
6610
6610
|
return cloneSelectively(obj2, pathStructure);
|
|
6611
6611
|
}
|
|
6612
|
-
function validatePath(
|
|
6613
|
-
if (typeof
|
|
6612
|
+
function validatePath(path21) {
|
|
6613
|
+
if (typeof path21 !== "string") {
|
|
6614
6614
|
throw new Error("Paths must be (non-empty) strings");
|
|
6615
6615
|
}
|
|
6616
|
-
if (
|
|
6616
|
+
if (path21 === "") {
|
|
6617
6617
|
throw new Error("Invalid redaction path ()");
|
|
6618
6618
|
}
|
|
6619
|
-
if (
|
|
6620
|
-
throw new Error(`Invalid redaction path (${
|
|
6619
|
+
if (path21.includes("..")) {
|
|
6620
|
+
throw new Error(`Invalid redaction path (${path21})`);
|
|
6621
6621
|
}
|
|
6622
|
-
if (
|
|
6623
|
-
throw new Error(`Invalid redaction path (${
|
|
6622
|
+
if (path21.includes(",")) {
|
|
6623
|
+
throw new Error(`Invalid redaction path (${path21})`);
|
|
6624
6624
|
}
|
|
6625
6625
|
let bracketCount = 0;
|
|
6626
6626
|
let inQuotes = false;
|
|
6627
6627
|
let quoteChar = "";
|
|
6628
|
-
for (let i = 0; i <
|
|
6629
|
-
const char =
|
|
6628
|
+
for (let i = 0; i < path21.length; i++) {
|
|
6629
|
+
const char = path21[i];
|
|
6630
6630
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
6631
6631
|
if (!inQuotes) {
|
|
6632
6632
|
inQuotes = true;
|
|
@@ -6640,20 +6640,20 @@ var require_redact = __commonJS({
|
|
|
6640
6640
|
} else if (char === "]" && !inQuotes) {
|
|
6641
6641
|
bracketCount--;
|
|
6642
6642
|
if (bracketCount < 0) {
|
|
6643
|
-
throw new Error(`Invalid redaction path (${
|
|
6643
|
+
throw new Error(`Invalid redaction path (${path21})`);
|
|
6644
6644
|
}
|
|
6645
6645
|
}
|
|
6646
6646
|
}
|
|
6647
6647
|
if (bracketCount !== 0) {
|
|
6648
|
-
throw new Error(`Invalid redaction path (${
|
|
6648
|
+
throw new Error(`Invalid redaction path (${path21})`);
|
|
6649
6649
|
}
|
|
6650
6650
|
}
|
|
6651
6651
|
function validatePaths(paths) {
|
|
6652
6652
|
if (!Array.isArray(paths)) {
|
|
6653
6653
|
throw new TypeError("paths must be an array");
|
|
6654
6654
|
}
|
|
6655
|
-
for (const
|
|
6656
|
-
validatePath(
|
|
6655
|
+
for (const path21 of paths) {
|
|
6656
|
+
validatePath(path21);
|
|
6657
6657
|
}
|
|
6658
6658
|
}
|
|
6659
6659
|
function slowRedact(options = {}) {
|
|
@@ -6821,8 +6821,8 @@ var require_redaction = __commonJS({
|
|
|
6821
6821
|
if (shape[k] === null) {
|
|
6822
6822
|
o[k] = (value) => topCensor(value, [k]);
|
|
6823
6823
|
} else {
|
|
6824
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
6825
|
-
return censor(value, [k, ...
|
|
6824
|
+
const wrappedCensor = typeof censor === "function" ? (value, path21) => {
|
|
6825
|
+
return censor(value, [k, ...path21]);
|
|
6826
6826
|
} : censor;
|
|
6827
6827
|
o[k] = Redact({
|
|
6828
6828
|
paths: shape[k],
|
|
@@ -7040,10 +7040,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
7040
7040
|
var require_sonic_boom = __commonJS({
|
|
7041
7041
|
"node_modules/sonic-boom/index.js"(exports, module) {
|
|
7042
7042
|
"use strict";
|
|
7043
|
-
var
|
|
7043
|
+
var fs13 = __require("fs");
|
|
7044
7044
|
var EventEmitter5 = __require("events");
|
|
7045
7045
|
var inherits = __require("util").inherits;
|
|
7046
|
-
var
|
|
7046
|
+
var path21 = __require("path");
|
|
7047
7047
|
var sleep2 = require_atomic_sleep();
|
|
7048
7048
|
var assert2 = __require("assert");
|
|
7049
7049
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -7097,20 +7097,20 @@ var require_sonic_boom = __commonJS({
|
|
|
7097
7097
|
const mode = sonic.mode;
|
|
7098
7098
|
if (sonic.sync) {
|
|
7099
7099
|
try {
|
|
7100
|
-
if (sonic.mkdir)
|
|
7101
|
-
const fd =
|
|
7100
|
+
if (sonic.mkdir) fs13.mkdirSync(path21.dirname(file2), { recursive: true });
|
|
7101
|
+
const fd = fs13.openSync(file2, flags, mode);
|
|
7102
7102
|
fileOpened(null, fd);
|
|
7103
7103
|
} catch (err) {
|
|
7104
7104
|
fileOpened(err);
|
|
7105
7105
|
throw err;
|
|
7106
7106
|
}
|
|
7107
7107
|
} else if (sonic.mkdir) {
|
|
7108
|
-
|
|
7108
|
+
fs13.mkdir(path21.dirname(file2), { recursive: true }, (err) => {
|
|
7109
7109
|
if (err) return fileOpened(err);
|
|
7110
|
-
|
|
7110
|
+
fs13.open(file2, flags, mode, fileOpened);
|
|
7111
7111
|
});
|
|
7112
7112
|
} else {
|
|
7113
|
-
|
|
7113
|
+
fs13.open(file2, flags, mode, fileOpened);
|
|
7114
7114
|
}
|
|
7115
7115
|
}
|
|
7116
7116
|
function SonicBoom(opts) {
|
|
@@ -7151,8 +7151,8 @@ var require_sonic_boom = __commonJS({
|
|
|
7151
7151
|
this.flush = flushBuffer;
|
|
7152
7152
|
this.flushSync = flushBufferSync;
|
|
7153
7153
|
this._actualWrite = actualWriteBuffer;
|
|
7154
|
-
fsWriteSync = () =>
|
|
7155
|
-
fsWrite = () =>
|
|
7154
|
+
fsWriteSync = () => fs13.writeSync(this.fd, this._writingBuf);
|
|
7155
|
+
fsWrite = () => fs13.write(this.fd, this._writingBuf, this.release);
|
|
7156
7156
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
7157
7157
|
this._writingBuf = "";
|
|
7158
7158
|
this.write = write;
|
|
@@ -7161,15 +7161,15 @@ var require_sonic_boom = __commonJS({
|
|
|
7161
7161
|
this._actualWrite = actualWrite;
|
|
7162
7162
|
fsWriteSync = () => {
|
|
7163
7163
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
7164
|
-
return
|
|
7164
|
+
return fs13.writeSync(this.fd, this._writingBuf);
|
|
7165
7165
|
}
|
|
7166
|
-
return
|
|
7166
|
+
return fs13.writeSync(this.fd, this._writingBuf, "utf8");
|
|
7167
7167
|
};
|
|
7168
7168
|
fsWrite = () => {
|
|
7169
7169
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
7170
|
-
return
|
|
7170
|
+
return fs13.write(this.fd, this._writingBuf, this.release);
|
|
7171
7171
|
}
|
|
7172
|
-
return
|
|
7172
|
+
return fs13.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
7173
7173
|
};
|
|
7174
7174
|
} else {
|
|
7175
7175
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
@@ -7226,7 +7226,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7226
7226
|
}
|
|
7227
7227
|
}
|
|
7228
7228
|
if (this._fsync) {
|
|
7229
|
-
|
|
7229
|
+
fs13.fsyncSync(this.fd);
|
|
7230
7230
|
}
|
|
7231
7231
|
const len = this._len;
|
|
7232
7232
|
if (this._reopening) {
|
|
@@ -7340,7 +7340,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7340
7340
|
const onDrain = () => {
|
|
7341
7341
|
if (!this._fsync) {
|
|
7342
7342
|
try {
|
|
7343
|
-
|
|
7343
|
+
fs13.fsync(this.fd, (err) => {
|
|
7344
7344
|
this._flushPending = false;
|
|
7345
7345
|
cb(err);
|
|
7346
7346
|
});
|
|
@@ -7442,7 +7442,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7442
7442
|
const fd = this.fd;
|
|
7443
7443
|
this.once("ready", () => {
|
|
7444
7444
|
if (fd !== this.fd) {
|
|
7445
|
-
|
|
7445
|
+
fs13.close(fd, (err) => {
|
|
7446
7446
|
if (err) {
|
|
7447
7447
|
return this.emit("error", err);
|
|
7448
7448
|
}
|
|
@@ -7491,7 +7491,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7491
7491
|
buf = this._bufs[0];
|
|
7492
7492
|
}
|
|
7493
7493
|
try {
|
|
7494
|
-
const n = Buffer.isBuffer(buf) ?
|
|
7494
|
+
const n = Buffer.isBuffer(buf) ? fs13.writeSync(this.fd, buf) : fs13.writeSync(this.fd, buf, "utf8");
|
|
7495
7495
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n);
|
|
7496
7496
|
buf = releasedBufObj.writingBuf;
|
|
7497
7497
|
this._len = releasedBufObj.len;
|
|
@@ -7507,7 +7507,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7507
7507
|
}
|
|
7508
7508
|
}
|
|
7509
7509
|
try {
|
|
7510
|
-
|
|
7510
|
+
fs13.fsyncSync(this.fd);
|
|
7511
7511
|
} catch {
|
|
7512
7512
|
}
|
|
7513
7513
|
}
|
|
@@ -7528,7 +7528,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7528
7528
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
7529
7529
|
}
|
|
7530
7530
|
try {
|
|
7531
|
-
const n =
|
|
7531
|
+
const n = fs13.writeSync(this.fd, buf);
|
|
7532
7532
|
buf = buf.subarray(n);
|
|
7533
7533
|
this._len = Math.max(this._len - n, 0);
|
|
7534
7534
|
if (buf.length <= 0) {
|
|
@@ -7556,13 +7556,13 @@ var require_sonic_boom = __commonJS({
|
|
|
7556
7556
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
7557
7557
|
if (this.sync) {
|
|
7558
7558
|
try {
|
|
7559
|
-
const written = Buffer.isBuffer(this._writingBuf) ?
|
|
7559
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs13.writeSync(this.fd, this._writingBuf) : fs13.writeSync(this.fd, this._writingBuf, "utf8");
|
|
7560
7560
|
release(null, written);
|
|
7561
7561
|
} catch (err) {
|
|
7562
7562
|
release(err);
|
|
7563
7563
|
}
|
|
7564
7564
|
} else {
|
|
7565
|
-
|
|
7565
|
+
fs13.write(this.fd, this._writingBuf, release);
|
|
7566
7566
|
}
|
|
7567
7567
|
}
|
|
7568
7568
|
function actualWriteBuffer() {
|
|
@@ -7571,7 +7571,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7571
7571
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
7572
7572
|
if (this.sync) {
|
|
7573
7573
|
try {
|
|
7574
|
-
const written =
|
|
7574
|
+
const written = fs13.writeSync(this.fd, this._writingBuf);
|
|
7575
7575
|
release(null, written);
|
|
7576
7576
|
} catch (err) {
|
|
7577
7577
|
release(err);
|
|
@@ -7580,7 +7580,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7580
7580
|
if (kCopyBuffer) {
|
|
7581
7581
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
7582
7582
|
}
|
|
7583
|
-
|
|
7583
|
+
fs13.write(this.fd, this._writingBuf, release);
|
|
7584
7584
|
}
|
|
7585
7585
|
}
|
|
7586
7586
|
function actualClose(sonic) {
|
|
@@ -7596,12 +7596,12 @@ var require_sonic_boom = __commonJS({
|
|
|
7596
7596
|
sonic._lens = [];
|
|
7597
7597
|
assert2(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
7598
7598
|
try {
|
|
7599
|
-
|
|
7599
|
+
fs13.fsync(sonic.fd, closeWrapped);
|
|
7600
7600
|
} catch {
|
|
7601
7601
|
}
|
|
7602
7602
|
function closeWrapped() {
|
|
7603
7603
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
7604
|
-
|
|
7604
|
+
fs13.close(sonic.fd, done);
|
|
7605
7605
|
} else {
|
|
7606
7606
|
done();
|
|
7607
7607
|
}
|
|
@@ -8437,15 +8437,15 @@ var require_transport = __commonJS({
|
|
|
8437
8437
|
if (!unquoted) {
|
|
8438
8438
|
return false;
|
|
8439
8439
|
}
|
|
8440
|
-
let
|
|
8441
|
-
if (
|
|
8440
|
+
let path21 = unquoted;
|
|
8441
|
+
if (path21.startsWith("file://")) {
|
|
8442
8442
|
try {
|
|
8443
|
-
|
|
8443
|
+
path21 = fileURLToPath6(path21);
|
|
8444
8444
|
} catch {
|
|
8445
8445
|
return false;
|
|
8446
8446
|
}
|
|
8447
8447
|
}
|
|
8448
|
-
return isAbsolute(
|
|
8448
|
+
return isAbsolute(path21) && !existsSync3(path21);
|
|
8449
8449
|
}
|
|
8450
8450
|
function stripQuotes(value) {
|
|
8451
8451
|
const first = value[0];
|
|
@@ -17121,8 +17121,8 @@ var require_utils = __commonJS({
|
|
|
17121
17121
|
}
|
|
17122
17122
|
return ind;
|
|
17123
17123
|
}
|
|
17124
|
-
function removeDotSegments(
|
|
17125
|
-
let input =
|
|
17124
|
+
function removeDotSegments(path21) {
|
|
17125
|
+
let input = path21;
|
|
17126
17126
|
const output = [];
|
|
17127
17127
|
let nextSlash = -1;
|
|
17128
17128
|
let len = 0;
|
|
@@ -17374,8 +17374,8 @@ var require_schemes = __commonJS({
|
|
|
17374
17374
|
wsComponent.secure = void 0;
|
|
17375
17375
|
}
|
|
17376
17376
|
if (wsComponent.resourceName) {
|
|
17377
|
-
const [
|
|
17378
|
-
wsComponent.path =
|
|
17377
|
+
const [path21, query2] = wsComponent.resourceName.split("?");
|
|
17378
|
+
wsComponent.path = path21 && path21 !== "/" ? path21 : void 0;
|
|
17379
17379
|
wsComponent.query = query2;
|
|
17380
17380
|
wsComponent.resourceName = void 0;
|
|
17381
17381
|
}
|
|
@@ -22312,8 +22312,8 @@ var require_utils2 = __commonJS({
|
|
|
22312
22312
|
}
|
|
22313
22313
|
return ind;
|
|
22314
22314
|
}
|
|
22315
|
-
function removeDotSegments(
|
|
22316
|
-
let input =
|
|
22315
|
+
function removeDotSegments(path21) {
|
|
22316
|
+
let input = path21;
|
|
22317
22317
|
const output = [];
|
|
22318
22318
|
let nextSlash = -1;
|
|
22319
22319
|
let len = 0;
|
|
@@ -22658,8 +22658,8 @@ var require_schemes2 = __commonJS({
|
|
|
22658
22658
|
wsComponent.secure = void 0;
|
|
22659
22659
|
}
|
|
22660
22660
|
if (wsComponent.resourceName) {
|
|
22661
|
-
const [
|
|
22662
|
-
wsComponent.path =
|
|
22661
|
+
const [path21, query2] = wsComponent.resourceName.split("?");
|
|
22662
|
+
wsComponent.path = path21 && path21 !== "/" ? path21 : void 0;
|
|
22663
22663
|
wsComponent.query = query2;
|
|
22664
22664
|
wsComponent.resourceName = void 0;
|
|
22665
22665
|
}
|
|
@@ -23435,12 +23435,12 @@ var require_dist = __commonJS({
|
|
|
23435
23435
|
throw new Error(`Unknown format "${name}"`);
|
|
23436
23436
|
return f;
|
|
23437
23437
|
};
|
|
23438
|
-
function addFormats(ajv, list,
|
|
23438
|
+
function addFormats(ajv, list, fs13, exportName) {
|
|
23439
23439
|
var _a3;
|
|
23440
23440
|
var _b;
|
|
23441
23441
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
23442
23442
|
for (const f of list)
|
|
23443
|
-
ajv.addFormat(f,
|
|
23443
|
+
ajv.addFormat(f, fs13[f]);
|
|
23444
23444
|
}
|
|
23445
23445
|
module.exports = exports = formatsPlugin;
|
|
23446
23446
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -24143,8 +24143,8 @@ var require_utils3 = __commonJS({
|
|
|
24143
24143
|
}
|
|
24144
24144
|
return ind;
|
|
24145
24145
|
}
|
|
24146
|
-
function removeDotSegments(
|
|
24147
|
-
let input =
|
|
24146
|
+
function removeDotSegments(path21) {
|
|
24147
|
+
let input = path21;
|
|
24148
24148
|
const output = [];
|
|
24149
24149
|
let nextSlash = -1;
|
|
24150
24150
|
let len = 0;
|
|
@@ -24489,8 +24489,8 @@ var require_schemes3 = __commonJS({
|
|
|
24489
24489
|
wsComponent.secure = void 0;
|
|
24490
24490
|
}
|
|
24491
24491
|
if (wsComponent.resourceName) {
|
|
24492
|
-
const [
|
|
24493
|
-
wsComponent.path =
|
|
24492
|
+
const [path21, query2] = wsComponent.resourceName.split("?");
|
|
24493
|
+
wsComponent.path = path21 && path21 !== "/" ? path21 : void 0;
|
|
24494
24494
|
wsComponent.query = query2;
|
|
24495
24495
|
wsComponent.resourceName = void 0;
|
|
24496
24496
|
}
|
|
@@ -32007,13 +32007,13 @@ var require_node = __commonJS({
|
|
|
32007
32007
|
this.staticChildrenNodes[index] = node;
|
|
32008
32008
|
}
|
|
32009
32009
|
}
|
|
32010
|
-
findStaticMatchingChild(
|
|
32011
|
-
const charCode =
|
|
32010
|
+
findStaticMatchingChild(path21, pathIndex) {
|
|
32011
|
+
const charCode = path21.charCodeAt(pathIndex);
|
|
32012
32012
|
const charCodes = this.staticChildrenCharCodes;
|
|
32013
32013
|
for (let i = 0; i < charCodes.length; i++) {
|
|
32014
32014
|
if (charCodes[i] === charCode) {
|
|
32015
32015
|
const staticChild = this.staticChildrenNodes[i];
|
|
32016
|
-
if (staticChild.matchPrefix(
|
|
32016
|
+
if (staticChild.matchPrefix(path21, pathIndex)) {
|
|
32017
32017
|
return staticChild;
|
|
32018
32018
|
}
|
|
32019
32019
|
return null;
|
|
@@ -32021,34 +32021,34 @@ var require_node = __commonJS({
|
|
|
32021
32021
|
}
|
|
32022
32022
|
return null;
|
|
32023
32023
|
}
|
|
32024
|
-
getStaticChild(
|
|
32025
|
-
if (
|
|
32024
|
+
getStaticChild(path21, pathIndex = 0) {
|
|
32025
|
+
if (path21.length === pathIndex) {
|
|
32026
32026
|
return this;
|
|
32027
32027
|
}
|
|
32028
|
-
const staticChild = this.findStaticMatchingChild(
|
|
32028
|
+
const staticChild = this.findStaticMatchingChild(path21, pathIndex);
|
|
32029
32029
|
if (staticChild) {
|
|
32030
|
-
return staticChild.getStaticChild(
|
|
32030
|
+
return staticChild.getStaticChild(path21, pathIndex + staticChild.prefix.length);
|
|
32031
32031
|
}
|
|
32032
32032
|
return null;
|
|
32033
32033
|
}
|
|
32034
|
-
createStaticChild(
|
|
32035
|
-
if (
|
|
32034
|
+
createStaticChild(path21) {
|
|
32035
|
+
if (path21.length === 0) {
|
|
32036
32036
|
return this;
|
|
32037
32037
|
}
|
|
32038
|
-
const childIndex = this.staticChildrenCharCodes.indexOf(
|
|
32038
|
+
const childIndex = this.staticChildrenCharCodes.indexOf(path21.charCodeAt(0));
|
|
32039
32039
|
let staticChild = childIndex === -1 ? void 0 : this.staticChildrenNodes[childIndex];
|
|
32040
32040
|
if (staticChild) {
|
|
32041
32041
|
let i = 1;
|
|
32042
32042
|
for (; i < staticChild.prefix.length; i++) {
|
|
32043
|
-
if (
|
|
32043
|
+
if (path21.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) {
|
|
32044
32044
|
staticChild = staticChild.split(this, i);
|
|
32045
32045
|
break;
|
|
32046
32046
|
}
|
|
32047
32047
|
}
|
|
32048
|
-
return staticChild.createStaticChild(
|
|
32048
|
+
return staticChild.createStaticChild(path21.slice(i));
|
|
32049
32049
|
}
|
|
32050
|
-
const node = new StaticNode(
|
|
32051
|
-
this.setStaticChild(
|
|
32050
|
+
const node = new StaticNode(path21);
|
|
32051
|
+
this.setStaticChild(path21.charAt(0), node);
|
|
32052
32052
|
return node;
|
|
32053
32053
|
}
|
|
32054
32054
|
};
|
|
@@ -32108,8 +32108,8 @@ var require_node = __commonJS({
|
|
|
32108
32108
|
parentNode.setStaticChild(parentPrefix.charAt(0), staticNode);
|
|
32109
32109
|
return staticNode;
|
|
32110
32110
|
}
|
|
32111
|
-
getNextNode(
|
|
32112
|
-
let node = this.findStaticMatchingChild(
|
|
32111
|
+
getNextNode(path21, pathIndex, nodeStack, paramsCount) {
|
|
32112
|
+
let node = this.findStaticMatchingChild(path21, pathIndex);
|
|
32113
32113
|
let parametricBrotherNodeIndex = 0;
|
|
32114
32114
|
if (node === null) {
|
|
32115
32115
|
if (this.parametricChildren.length === 0) {
|
|
@@ -32156,8 +32156,8 @@ var require_node = __commonJS({
|
|
|
32156
32156
|
this.kind = NODE_TYPES.PARAMETRIC;
|
|
32157
32157
|
this.nodePaths = /* @__PURE__ */ new Set([nodePath2]);
|
|
32158
32158
|
}
|
|
32159
|
-
getNextNode(
|
|
32160
|
-
return this.findStaticMatchingChild(
|
|
32159
|
+
getNextNode(path21, pathIndex) {
|
|
32160
|
+
return this.findStaticMatchingChild(path21, pathIndex);
|
|
32161
32161
|
}
|
|
32162
32162
|
};
|
|
32163
32163
|
var WildcardNode = class extends Node {
|
|
@@ -32513,81 +32513,81 @@ var require_url_sanitizer = __commonJS({
|
|
|
32513
32513
|
return String.fromCharCode(charCode);
|
|
32514
32514
|
}
|
|
32515
32515
|
var MIN_NATIVE_SCAN_LENGTH = 12;
|
|
32516
|
-
function safeDecodeURI(
|
|
32517
|
-
if (
|
|
32518
|
-
return safeDecodeURINativeScan(
|
|
32516
|
+
function safeDecodeURI(path21, useSemicolonDelimiter) {
|
|
32517
|
+
if (path21.length >= MIN_NATIVE_SCAN_LENGTH) {
|
|
32518
|
+
return safeDecodeURINativeScan(path21, useSemicolonDelimiter);
|
|
32519
32519
|
}
|
|
32520
|
-
return safeDecodeURICharScan(
|
|
32520
|
+
return safeDecodeURICharScan(path21, useSemicolonDelimiter, 1);
|
|
32521
32521
|
}
|
|
32522
|
-
function safeDecodeURINativeScan(
|
|
32523
|
-
const percentIndex =
|
|
32524
|
-
let delimIndex =
|
|
32525
|
-
const hashIndex =
|
|
32522
|
+
function safeDecodeURINativeScan(path21, useSemicolonDelimiter) {
|
|
32523
|
+
const percentIndex = path21.indexOf("%", 1);
|
|
32524
|
+
let delimIndex = path21.indexOf("?", 1);
|
|
32525
|
+
const hashIndex = path21.indexOf("#", 1);
|
|
32526
32526
|
if (hashIndex !== -1 && (delimIndex === -1 || hashIndex < delimIndex)) {
|
|
32527
32527
|
delimIndex = hashIndex;
|
|
32528
32528
|
}
|
|
32529
32529
|
if (useSemicolonDelimiter) {
|
|
32530
|
-
const semicolonIndex =
|
|
32530
|
+
const semicolonIndex = path21.indexOf(";", 1);
|
|
32531
32531
|
if (semicolonIndex !== -1 && (delimIndex === -1 || semicolonIndex < delimIndex)) {
|
|
32532
32532
|
delimIndex = semicolonIndex;
|
|
32533
32533
|
}
|
|
32534
32534
|
}
|
|
32535
32535
|
if (percentIndex === -1 || delimIndex !== -1 && percentIndex > delimIndex) {
|
|
32536
32536
|
if (delimIndex === -1) {
|
|
32537
|
-
return { path:
|
|
32537
|
+
return { path: path21, querystring: "", shouldDecodeParam: false };
|
|
32538
32538
|
}
|
|
32539
32539
|
return {
|
|
32540
|
-
path:
|
|
32541
|
-
querystring:
|
|
32540
|
+
path: path21.slice(0, delimIndex),
|
|
32541
|
+
querystring: path21.slice(delimIndex + 1),
|
|
32542
32542
|
shouldDecodeParam: false
|
|
32543
32543
|
};
|
|
32544
32544
|
}
|
|
32545
|
-
return safeDecodeURIPercentScan(
|
|
32545
|
+
return safeDecodeURIPercentScan(path21, useSemicolonDelimiter, percentIndex);
|
|
32546
32546
|
}
|
|
32547
|
-
function safeDecodeURICharScan(
|
|
32548
|
-
for (let i = startIndex; i <
|
|
32549
|
-
const charCode =
|
|
32547
|
+
function safeDecodeURICharScan(path21, useSemicolonDelimiter, startIndex) {
|
|
32548
|
+
for (let i = startIndex; i < path21.length; i++) {
|
|
32549
|
+
const charCode = path21.charCodeAt(i);
|
|
32550
32550
|
if (charCode === 37) {
|
|
32551
|
-
return safeDecodeURIPercentScan(
|
|
32551
|
+
return safeDecodeURIPercentScan(path21, useSemicolonDelimiter, i);
|
|
32552
32552
|
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
32553
32553
|
return {
|
|
32554
|
-
path:
|
|
32555
|
-
querystring:
|
|
32554
|
+
path: path21.slice(0, i),
|
|
32555
|
+
querystring: path21.slice(i + 1),
|
|
32556
32556
|
shouldDecodeParam: false
|
|
32557
32557
|
};
|
|
32558
32558
|
}
|
|
32559
32559
|
}
|
|
32560
|
-
return { path:
|
|
32560
|
+
return { path: path21, querystring: "", shouldDecodeParam: false };
|
|
32561
32561
|
}
|
|
32562
|
-
function reencodePercentChar(
|
|
32563
|
-
return
|
|
32562
|
+
function reencodePercentChar(path21, index) {
|
|
32563
|
+
return path21.slice(0, index + 1) + "25" + path21.slice(index + 1);
|
|
32564
32564
|
}
|
|
32565
|
-
function safeDecodeURIPercentScan(
|
|
32565
|
+
function safeDecodeURIPercentScan(path21, useSemicolonDelimiter, startIndex) {
|
|
32566
32566
|
let shouldDecode = false;
|
|
32567
32567
|
let shouldDecodeParam = false;
|
|
32568
32568
|
let querystring = "";
|
|
32569
|
-
for (let i = startIndex; i <
|
|
32570
|
-
const charCode =
|
|
32569
|
+
for (let i = startIndex; i < path21.length; i++) {
|
|
32570
|
+
const charCode = path21.charCodeAt(i);
|
|
32571
32571
|
if (charCode === 37) {
|
|
32572
|
-
const componentCharCode = decodeComponentCharCode(
|
|
32572
|
+
const componentCharCode = decodeComponentCharCode(path21.charCodeAt(i + 1), path21.charCodeAt(i + 2));
|
|
32573
32573
|
if (componentCharCode === 0) {
|
|
32574
32574
|
shouldDecode = true;
|
|
32575
32575
|
} else {
|
|
32576
32576
|
shouldDecodeParam = true;
|
|
32577
32577
|
if (componentCharCode === 37) {
|
|
32578
32578
|
shouldDecode = true;
|
|
32579
|
-
|
|
32579
|
+
path21 = reencodePercentChar(path21, i);
|
|
32580
32580
|
i += 2;
|
|
32581
32581
|
}
|
|
32582
32582
|
i += 2;
|
|
32583
32583
|
}
|
|
32584
32584
|
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
32585
|
-
querystring =
|
|
32586
|
-
|
|
32585
|
+
querystring = path21.slice(i + 1);
|
|
32586
|
+
path21 = path21.slice(0, i);
|
|
32587
32587
|
break;
|
|
32588
32588
|
}
|
|
32589
32589
|
}
|
|
32590
|
-
const decodedPath = shouldDecode ? decodeURI(
|
|
32590
|
+
const decodedPath = shouldDecode ? decodeURI(path21) : path21;
|
|
32591
32591
|
return { path: decodedPath, querystring, shouldDecodeParam };
|
|
32592
32592
|
}
|
|
32593
32593
|
function safeDecodeURIComponent(uriComponent) {
|
|
@@ -32682,7 +32682,7 @@ var require_find_my_way = __commonJS({
|
|
|
32682
32682
|
this.trees = /* @__PURE__ */ Object.create(null);
|
|
32683
32683
|
this._treeGET = null;
|
|
32684
32684
|
}
|
|
32685
|
-
Router.prototype.on = function on(method,
|
|
32685
|
+
Router.prototype.on = function on(method, path21, opts, handler, store) {
|
|
32686
32686
|
if (typeof opts === "function") {
|
|
32687
32687
|
if (handler !== void 0) {
|
|
32688
32688
|
store = handler;
|
|
@@ -32690,34 +32690,34 @@ var require_find_my_way = __commonJS({
|
|
|
32690
32690
|
handler = opts;
|
|
32691
32691
|
opts = {};
|
|
32692
32692
|
}
|
|
32693
|
-
assert2(typeof
|
|
32694
|
-
assert2(
|
|
32695
|
-
assert2(
|
|
32693
|
+
assert2(typeof path21 === "string", "Path should be a string");
|
|
32694
|
+
assert2(path21.length > 0, "The path could not be empty");
|
|
32695
|
+
assert2(path21[0] === "/" || path21[0] === "*", "The first character of a path should be `/` or `*`");
|
|
32696
32696
|
assert2(typeof handler === "function", "Handler should be a function");
|
|
32697
|
-
const optionalParamMatch =
|
|
32697
|
+
const optionalParamMatch = path21.match(OPTIONAL_PARAM_REGEXP);
|
|
32698
32698
|
if (optionalParamMatch) {
|
|
32699
|
-
assert2(
|
|
32700
|
-
const pathFull =
|
|
32701
|
-
const pathOptional =
|
|
32699
|
+
assert2(path21.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
32700
|
+
const pathFull = path21.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
32701
|
+
const pathOptional = path21.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
|
|
32702
32702
|
this.on(method, pathFull, opts, handler, store);
|
|
32703
32703
|
this.on(method, pathOptional, opts, handler, store);
|
|
32704
32704
|
return;
|
|
32705
32705
|
}
|
|
32706
|
-
const route =
|
|
32706
|
+
const route = path21;
|
|
32707
32707
|
if (this.ignoreDuplicateSlashes) {
|
|
32708
|
-
|
|
32708
|
+
path21 = removeDuplicateSlashes(path21);
|
|
32709
32709
|
}
|
|
32710
32710
|
if (this.ignoreTrailingSlash) {
|
|
32711
|
-
|
|
32711
|
+
path21 = trimLastSlash(path21);
|
|
32712
32712
|
}
|
|
32713
32713
|
const methods = Array.isArray(method) ? method : [method];
|
|
32714
32714
|
for (const method2 of methods) {
|
|
32715
32715
|
assert2(typeof method2 === "string", "Method should be a string");
|
|
32716
32716
|
assert2(httpMethods.includes(method2), `Method '${method2}' is not an http method.`);
|
|
32717
|
-
this._on(method2,
|
|
32717
|
+
this._on(method2, path21, opts, handler, store, route);
|
|
32718
32718
|
}
|
|
32719
32719
|
};
|
|
32720
|
-
Router.prototype._on = function _on(method,
|
|
32720
|
+
Router.prototype._on = function _on(method, path21, opts, handler, store) {
|
|
32721
32721
|
let constraints = {};
|
|
32722
32722
|
if (opts.constraints !== void 0) {
|
|
32723
32723
|
assert2(typeof opts.constraints === "object" && opts.constraints !== null, "Constraints should be an object");
|
|
@@ -32730,7 +32730,7 @@ var require_find_my_way = __commonJS({
|
|
|
32730
32730
|
if (this.trees[method] === void 0) {
|
|
32731
32731
|
this.trees[method] = new StaticNode("/");
|
|
32732
32732
|
}
|
|
32733
|
-
let pattern =
|
|
32733
|
+
let pattern = path21;
|
|
32734
32734
|
if (pattern === "*" && this.trees[method].prefix.length !== 0) {
|
|
32735
32735
|
const currentRoot = this.trees[method];
|
|
32736
32736
|
this.trees[method] = new StaticNode("");
|
|
@@ -32838,19 +32838,19 @@ var require_find_my_way = __commonJS({
|
|
|
32838
32838
|
throw new Error(`Method '${method}' already declared for route '${pattern}' with constraints '${JSON.stringify(constraints)}'`);
|
|
32839
32839
|
}
|
|
32840
32840
|
}
|
|
32841
|
-
const route = { method, path:
|
|
32841
|
+
const route = { method, path: path21, pattern, params, opts, handler, store };
|
|
32842
32842
|
this.routes.push(route);
|
|
32843
32843
|
currentNode.addRoute(route, this.constrainer);
|
|
32844
32844
|
};
|
|
32845
|
-
Router.prototype.hasRoute = function hasRoute(method,
|
|
32846
|
-
const route = this.findRoute(method,
|
|
32845
|
+
Router.prototype.hasRoute = function hasRoute(method, path21, constraints) {
|
|
32846
|
+
const route = this.findRoute(method, path21, constraints);
|
|
32847
32847
|
return route !== null;
|
|
32848
32848
|
};
|
|
32849
|
-
Router.prototype.findRoute = function findNode(method,
|
|
32849
|
+
Router.prototype.findRoute = function findNode(method, path21, constraints = {}) {
|
|
32850
32850
|
if (this.trees[method] === void 0) {
|
|
32851
32851
|
return null;
|
|
32852
32852
|
}
|
|
32853
|
-
let pattern =
|
|
32853
|
+
let pattern = path21;
|
|
32854
32854
|
let currentNode = this.trees[method];
|
|
32855
32855
|
let parentNodePathIndex = currentNode.prefix.length;
|
|
32856
32856
|
const params = [];
|
|
@@ -32971,39 +32971,39 @@ var require_find_my_way = __commonJS({
|
|
|
32971
32971
|
this._treeGET = null;
|
|
32972
32972
|
this.routes = [];
|
|
32973
32973
|
};
|
|
32974
|
-
Router.prototype.off = function off(method,
|
|
32975
|
-
assert2(typeof
|
|
32976
|
-
assert2(
|
|
32977
|
-
assert2(
|
|
32974
|
+
Router.prototype.off = function off(method, path21, constraints) {
|
|
32975
|
+
assert2(typeof path21 === "string", "Path should be a string");
|
|
32976
|
+
assert2(path21.length > 0, "The path could not be empty");
|
|
32977
|
+
assert2(path21[0] === "/" || path21[0] === "*", "The first character of a path should be `/` or `*`");
|
|
32978
32978
|
assert2(
|
|
32979
32979
|
typeof constraints === "undefined" || typeof constraints === "object" && !Array.isArray(constraints) && constraints !== null,
|
|
32980
32980
|
"Constraints should be an object or undefined."
|
|
32981
32981
|
);
|
|
32982
|
-
const optionalParamMatch =
|
|
32982
|
+
const optionalParamMatch = path21.match(OPTIONAL_PARAM_REGEXP);
|
|
32983
32983
|
if (optionalParamMatch) {
|
|
32984
|
-
assert2(
|
|
32985
|
-
const pathFull =
|
|
32986
|
-
const pathOptional =
|
|
32984
|
+
assert2(path21.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
32985
|
+
const pathFull = path21.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
32986
|
+
const pathOptional = path21.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
|
|
32987
32987
|
this.off(method, pathFull, constraints);
|
|
32988
32988
|
this.off(method, pathOptional, constraints);
|
|
32989
32989
|
return;
|
|
32990
32990
|
}
|
|
32991
32991
|
if (this.ignoreDuplicateSlashes) {
|
|
32992
|
-
|
|
32992
|
+
path21 = removeDuplicateSlashes(path21);
|
|
32993
32993
|
}
|
|
32994
32994
|
if (this.ignoreTrailingSlash) {
|
|
32995
|
-
|
|
32995
|
+
path21 = trimLastSlash(path21);
|
|
32996
32996
|
}
|
|
32997
32997
|
const methods = Array.isArray(method) ? method : [method];
|
|
32998
32998
|
for (const method2 of methods) {
|
|
32999
|
-
this._off(method2,
|
|
32999
|
+
this._off(method2, path21, constraints);
|
|
33000
33000
|
}
|
|
33001
33001
|
};
|
|
33002
|
-
Router.prototype._off = function _off(method,
|
|
33002
|
+
Router.prototype._off = function _off(method, path21, constraints) {
|
|
33003
33003
|
assert2(typeof method === "string", "Method should be a string");
|
|
33004
33004
|
assert2(httpMethods.includes(method), `Method '${method}' is not an http method.`);
|
|
33005
33005
|
function matcherWithoutConstraints(route) {
|
|
33006
|
-
return method !== route.method ||
|
|
33006
|
+
return method !== route.method || path21 !== route.path;
|
|
33007
33007
|
}
|
|
33008
33008
|
function matcherWithConstraints(route) {
|
|
33009
33009
|
return matcherWithoutConstraints(route) || !deepEqual(constraints, route.opts.constraints || {});
|
|
@@ -33040,37 +33040,37 @@ var require_find_my_way = __commonJS({
|
|
|
33040
33040
|
if (handle === null) return this._defaultRoute(req, res, ctx);
|
|
33041
33041
|
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);
|
|
33042
33042
|
};
|
|
33043
|
-
Router.prototype.find = function find(method,
|
|
33043
|
+
Router.prototype.find = function find(method, path21, derivedConstraints) {
|
|
33044
33044
|
let currentNode = method === "GET" ? this._treeGET : this.trees[method];
|
|
33045
33045
|
if (currentNode == null) return null;
|
|
33046
|
-
if (
|
|
33047
|
-
|
|
33046
|
+
if (path21.charCodeAt(0) !== 47) {
|
|
33047
|
+
path21 = path21.replace(FULL_PATH_REGEXP, "/");
|
|
33048
33048
|
}
|
|
33049
33049
|
if (this.ignoreDuplicateSlashes) {
|
|
33050
|
-
|
|
33050
|
+
path21 = removeDuplicateSlashes(path21);
|
|
33051
33051
|
}
|
|
33052
33052
|
let sanitizedUrl;
|
|
33053
33053
|
let querystring2;
|
|
33054
33054
|
let shouldDecodeParam;
|
|
33055
33055
|
try {
|
|
33056
|
-
sanitizedUrl =
|
|
33057
|
-
|
|
33056
|
+
sanitizedUrl = path21.length >= MIN_NATIVE_SCAN_LENGTH ? safeDecodeURINativeScan(path21, this.useSemicolonDelimiter) : safeDecodeURICharScan(path21, this.useSemicolonDelimiter, 1);
|
|
33057
|
+
path21 = sanitizedUrl.path;
|
|
33058
33058
|
querystring2 = sanitizedUrl.querystring;
|
|
33059
33059
|
shouldDecodeParam = sanitizedUrl.shouldDecodeParam;
|
|
33060
33060
|
} catch (error51) {
|
|
33061
|
-
return this._onBadUrl(
|
|
33061
|
+
return this._onBadUrl(path21);
|
|
33062
33062
|
}
|
|
33063
33063
|
if (this.ignoreTrailingSlash) {
|
|
33064
|
-
|
|
33064
|
+
path21 = trimLastSlash(path21);
|
|
33065
33065
|
}
|
|
33066
|
-
const originPath =
|
|
33066
|
+
const originPath = path21;
|
|
33067
33067
|
if (this.caseSensitive === false) {
|
|
33068
|
-
|
|
33068
|
+
path21 = path21.toLowerCase();
|
|
33069
33069
|
}
|
|
33070
33070
|
const maxParamLength = this.maxParamLength;
|
|
33071
33071
|
let pathIndex = currentNode.prefix.length;
|
|
33072
33072
|
const params = [];
|
|
33073
|
-
const pathLen =
|
|
33073
|
+
const pathLen = path21.length;
|
|
33074
33074
|
const brothersNodesStack = [];
|
|
33075
33075
|
let maxParamLengthExceeded = false;
|
|
33076
33076
|
while (true) {
|
|
@@ -33085,7 +33085,7 @@ var require_find_my_way = __commonJS({
|
|
|
33085
33085
|
};
|
|
33086
33086
|
}
|
|
33087
33087
|
}
|
|
33088
|
-
let node = currentNode.getNextNode(
|
|
33088
|
+
let node = currentNode.getNextNode(path21, pathIndex, brothersNodesStack, params.length);
|
|
33089
33089
|
if (node === null) {
|
|
33090
33090
|
if (brothersNodesStack.length === 0) {
|
|
33091
33091
|
if (maxParamLengthExceeded && this.onMaxParamLength) {
|
|
@@ -33186,8 +33186,8 @@ var require_find_my_way = __commonJS({
|
|
|
33186
33186
|
Router.prototype._rebuild = function(routes) {
|
|
33187
33187
|
this.reset();
|
|
33188
33188
|
for (const route of routes) {
|
|
33189
|
-
const { method, path:
|
|
33190
|
-
this._on(method,
|
|
33189
|
+
const { method, path: path21, opts, handler, store } = route;
|
|
33190
|
+
this._on(method, path21, opts, handler, store);
|
|
33191
33191
|
}
|
|
33192
33192
|
};
|
|
33193
33193
|
Router.prototype._defaultRoute = function(req, res, ctx) {
|
|
@@ -33198,24 +33198,24 @@ var require_find_my_way = __commonJS({
|
|
|
33198
33198
|
res.end();
|
|
33199
33199
|
}
|
|
33200
33200
|
};
|
|
33201
|
-
Router.prototype._onBadUrl = function(
|
|
33201
|
+
Router.prototype._onBadUrl = function(path21) {
|
|
33202
33202
|
if (this.onBadUrl === null) {
|
|
33203
33203
|
return null;
|
|
33204
33204
|
}
|
|
33205
33205
|
const onBadUrl = this.onBadUrl;
|
|
33206
33206
|
return {
|
|
33207
|
-
handler: (req, res, ctx) => onBadUrl(
|
|
33207
|
+
handler: (req, res, ctx) => onBadUrl(path21, req, res),
|
|
33208
33208
|
params: {},
|
|
33209
33209
|
store: null
|
|
33210
33210
|
};
|
|
33211
33211
|
};
|
|
33212
|
-
Router.prototype._onMaxParamLength = function(
|
|
33212
|
+
Router.prototype._onMaxParamLength = function(path21) {
|
|
33213
33213
|
if (this.onMaxParamLength === null) {
|
|
33214
33214
|
return null;
|
|
33215
33215
|
}
|
|
33216
33216
|
const onMaxParamLength = this.onMaxParamLength;
|
|
33217
33217
|
return {
|
|
33218
|
-
handler: (req, res, ctx) => onMaxParamLength(
|
|
33218
|
+
handler: (req, res, ctx) => onMaxParamLength(path21, req, res),
|
|
33219
33219
|
params: {},
|
|
33220
33220
|
store: null
|
|
33221
33221
|
};
|
|
@@ -33247,12 +33247,12 @@ var require_find_my_way = __commonJS({
|
|
|
33247
33247
|
if (!httpMethods.hasOwnProperty(i)) continue;
|
|
33248
33248
|
const m = httpMethods[i];
|
|
33249
33249
|
const methodName = m.toLowerCase();
|
|
33250
|
-
Router.prototype[methodName] = function(
|
|
33251
|
-
return this.on(m,
|
|
33250
|
+
Router.prototype[methodName] = function(path21, handler, store) {
|
|
33251
|
+
return this.on(m, path21, handler, store);
|
|
33252
33252
|
};
|
|
33253
33253
|
}
|
|
33254
|
-
Router.prototype.all = function(
|
|
33255
|
-
this.on(httpMethods,
|
|
33254
|
+
Router.prototype.all = function(path21, handler, store) {
|
|
33255
|
+
this.on(httpMethods, path21, handler, store);
|
|
33256
33256
|
};
|
|
33257
33257
|
Router.sanitizeUrlPath = function sanitizeUrlPath(url2, useSemicolonDelimiter) {
|
|
33258
33258
|
const decoded = safeDecodeURI(url2, useSemicolonDelimiter);
|
|
@@ -33267,14 +33267,14 @@ var require_find_my_way = __commonJS({
|
|
|
33267
33267
|
function escapeRegExp(string4) {
|
|
33268
33268
|
return string4.replace(ESCAPE_REGEXP, "\\$&");
|
|
33269
33269
|
}
|
|
33270
|
-
function removeDuplicateSlashes(
|
|
33271
|
-
return
|
|
33270
|
+
function removeDuplicateSlashes(path21) {
|
|
33271
|
+
return path21.indexOf("//") !== -1 ? path21.replace(REMOVE_DUPLICATE_SLASHES_REGEXP, "/") : path21;
|
|
33272
33272
|
}
|
|
33273
|
-
function trimLastSlash(
|
|
33274
|
-
if (
|
|
33275
|
-
return
|
|
33273
|
+
function trimLastSlash(path21) {
|
|
33274
|
+
if (path21.length > 1 && path21.charCodeAt(path21.length - 1) === 47) {
|
|
33275
|
+
return path21.slice(0, -1);
|
|
33276
33276
|
}
|
|
33277
|
-
return
|
|
33277
|
+
return path21;
|
|
33278
33278
|
}
|
|
33279
33279
|
function trimRegExpStartAndEnd(regexString) {
|
|
33280
33280
|
if (regexString.charCodeAt(1) === 94) {
|
|
@@ -33285,22 +33285,22 @@ var require_find_my_way = __commonJS({
|
|
|
33285
33285
|
}
|
|
33286
33286
|
return regexString;
|
|
33287
33287
|
}
|
|
33288
|
-
function getClosingParenthensePosition(
|
|
33288
|
+
function getClosingParenthensePosition(path21, idx) {
|
|
33289
33289
|
let parentheses = 1;
|
|
33290
|
-
while (idx <
|
|
33290
|
+
while (idx < path21.length) {
|
|
33291
33291
|
idx++;
|
|
33292
|
-
if (
|
|
33292
|
+
if (path21.charCodeAt(idx) === 92) {
|
|
33293
33293
|
idx++;
|
|
33294
33294
|
continue;
|
|
33295
33295
|
}
|
|
33296
|
-
if (
|
|
33296
|
+
if (path21.charCodeAt(idx) === 41) {
|
|
33297
33297
|
parentheses--;
|
|
33298
|
-
} else if (
|
|
33298
|
+
} else if (path21.charCodeAt(idx) === 40) {
|
|
33299
33299
|
parentheses++;
|
|
33300
33300
|
}
|
|
33301
33301
|
if (!parentheses) return idx;
|
|
33302
33302
|
}
|
|
33303
|
-
throw new TypeError('Invalid regexp expression in "' +
|
|
33303
|
+
throw new TypeError('Invalid regexp expression in "' + path21 + '"');
|
|
33304
33304
|
}
|
|
33305
33305
|
function defaultBuildPrettyMeta(route) {
|
|
33306
33306
|
if (!route) return {};
|
|
@@ -33533,12 +33533,12 @@ var require_route = __commonJS({
|
|
|
33533
33533
|
function route({ options: options2, isFastify }) {
|
|
33534
33534
|
throwIfAlreadyStarted("Cannot add route!");
|
|
33535
33535
|
const opts = { ...options2 };
|
|
33536
|
-
const
|
|
33536
|
+
const path21 = opts.url || opts.path || "";
|
|
33537
33537
|
if (!opts.handler) {
|
|
33538
|
-
throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method,
|
|
33538
|
+
throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method, path21);
|
|
33539
33539
|
}
|
|
33540
33540
|
if (opts.errorHandler !== void 0 && typeof opts.errorHandler !== "function") {
|
|
33541
|
-
throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method,
|
|
33541
|
+
throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method, path21);
|
|
33542
33542
|
}
|
|
33543
33543
|
validateBodyLimitOption(opts.bodyLimit);
|
|
33544
33544
|
validateHandlerTimeoutOption(opts.handlerTimeout);
|
|
@@ -33548,22 +33548,22 @@ var require_route = __commonJS({
|
|
|
33548
33548
|
if (Array.isArray(opts.method)) {
|
|
33549
33549
|
for (let i = 0; i < opts.method.length; ++i) {
|
|
33550
33550
|
opts.method[i] = normalizeAndValidateMethod.call(this, opts.method[i]);
|
|
33551
|
-
validateSchemaBodyOption.call(this, opts.method[i],
|
|
33551
|
+
validateSchemaBodyOption.call(this, opts.method[i], path21, opts.schema);
|
|
33552
33552
|
isGetRoute = opts.method.includes("GET");
|
|
33553
33553
|
isHeadRoute = opts.method.includes("HEAD");
|
|
33554
33554
|
}
|
|
33555
33555
|
} else {
|
|
33556
33556
|
opts.method = normalizeAndValidateMethod.call(this, opts.method);
|
|
33557
|
-
validateSchemaBodyOption.call(this, opts.method,
|
|
33557
|
+
validateSchemaBodyOption.call(this, opts.method, path21, opts.schema);
|
|
33558
33558
|
isGetRoute = opts.method === "GET";
|
|
33559
33559
|
isHeadRoute = opts.method === "HEAD";
|
|
33560
33560
|
}
|
|
33561
33561
|
const headOpts = shouldExposeHead && isGetRoute ? { ...options2 } : null;
|
|
33562
33562
|
const prefix = this[kRoutePrefix];
|
|
33563
|
-
if (
|
|
33563
|
+
if (path21 === "/" && prefix.length > 0 && opts.method !== "HEAD") {
|
|
33564
33564
|
switch (opts.prefixTrailingSlash) {
|
|
33565
33565
|
case "slash":
|
|
33566
|
-
addNewRoute.call(this, { path:
|
|
33566
|
+
addNewRoute.call(this, { path: path21, isFastify });
|
|
33567
33567
|
break;
|
|
33568
33568
|
case "no-slash":
|
|
33569
33569
|
addNewRoute.call(this, { path: "", isFastify });
|
|
@@ -33572,20 +33572,20 @@ var require_route = __commonJS({
|
|
|
33572
33572
|
default:
|
|
33573
33573
|
addNewRoute.call(this, { path: "", isFastify });
|
|
33574
33574
|
if (ignoreTrailingSlash !== true && (ignoreDuplicateSlashes !== true || !prefix.endsWith("/"))) {
|
|
33575
|
-
addNewRoute.call(this, { path:
|
|
33575
|
+
addNewRoute.call(this, { path: path21, prefixing: true, isFastify });
|
|
33576
33576
|
}
|
|
33577
33577
|
}
|
|
33578
|
-
} else if (
|
|
33579
|
-
addNewRoute.call(this, { path:
|
|
33578
|
+
} else if (path21[0] === "/" && prefix.endsWith("/")) {
|
|
33579
|
+
addNewRoute.call(this, { path: path21.slice(1), isFastify });
|
|
33580
33580
|
} else {
|
|
33581
|
-
addNewRoute.call(this, { path:
|
|
33581
|
+
addNewRoute.call(this, { path: path21, isFastify });
|
|
33582
33582
|
}
|
|
33583
33583
|
return this;
|
|
33584
|
-
function addNewRoute({ path:
|
|
33585
|
-
const url2 = prefix +
|
|
33584
|
+
function addNewRoute({ path: path22, prefixing = false, isFastify: isFastify2 = false }) {
|
|
33585
|
+
const url2 = prefix + path22;
|
|
33586
33586
|
opts.url = url2;
|
|
33587
33587
|
opts.path = url2;
|
|
33588
|
-
opts.routePath =
|
|
33588
|
+
opts.routePath = path22;
|
|
33589
33589
|
opts.prefix = prefix;
|
|
33590
33590
|
opts.logLevel = opts.logLevel || this[kLogLevel];
|
|
33591
33591
|
validateLogLevelOption(opts.logLevel, opts.method, opts.url, logger);
|
|
@@ -33717,7 +33717,7 @@ var require_route = __commonJS({
|
|
|
33717
33717
|
});
|
|
33718
33718
|
if (shouldExposeHead && isGetRoute && !isHeadRoute && !hasHEADHandler) {
|
|
33719
33719
|
const onSendHandlers = parseHeadOnSendHandlers(headOpts.onSend);
|
|
33720
|
-
prepareRoute.call(this, { method: "HEAD", url:
|
|
33720
|
+
prepareRoute.call(this, { method: "HEAD", url: path22, options: { ...headOpts, onSend: onSendHandlers }, isFastify: true });
|
|
33721
33721
|
}
|
|
33722
33722
|
}
|
|
33723
33723
|
}
|
|
@@ -33841,9 +33841,9 @@ var require_route = __commonJS({
|
|
|
33841
33841
|
}
|
|
33842
33842
|
return method;
|
|
33843
33843
|
}
|
|
33844
|
-
function validateSchemaBodyOption(method,
|
|
33844
|
+
function validateSchemaBodyOption(method, path21, schema) {
|
|
33845
33845
|
if (this[kSupportedHTTPMethods].bodyless.has(method) && schema?.body) {
|
|
33846
|
-
throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method,
|
|
33846
|
+
throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method, path21);
|
|
33847
33847
|
}
|
|
33848
33848
|
}
|
|
33849
33849
|
function validateBodyLimitOption(bodyLimit) {
|
|
@@ -33858,11 +33858,11 @@ var require_route = __commonJS({
|
|
|
33858
33858
|
throw new FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT(handlerTimeout);
|
|
33859
33859
|
}
|
|
33860
33860
|
}
|
|
33861
|
-
function validateLogLevelOption(logLevel, method,
|
|
33861
|
+
function validateLogLevelOption(logLevel, method, path21, logger) {
|
|
33862
33862
|
if (logLevel == null || logLevel === "") return;
|
|
33863
33863
|
if (logger?.levels?.values == null) return;
|
|
33864
33864
|
if (typeof logLevel !== "string" || logger.levels.values[logLevel] === void 0) {
|
|
33865
|
-
throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method,
|
|
33865
|
+
throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method, path21, logLevel);
|
|
33866
33866
|
}
|
|
33867
33867
|
}
|
|
33868
33868
|
function runPreParsing(err, request, reply) {
|
|
@@ -33951,7 +33951,7 @@ var require_four_oh_four = __commonJS({
|
|
|
33951
33951
|
});
|
|
33952
33952
|
}
|
|
33953
33953
|
function createRouteEventHandler() {
|
|
33954
|
-
return function onRouteEvent(
|
|
33954
|
+
return function onRouteEvent(path21, req, res) {
|
|
33955
33955
|
const fourOhFourContext = this[kFourOhFourLevelInstance][kFourOhFourContext];
|
|
33956
33956
|
const id = getGenReqId(fourOhFourContext.server, req);
|
|
33957
33957
|
const childLogger = createChildLogger(fourOhFourContext, logger, req, id);
|
|
@@ -36622,19 +36622,19 @@ var require_fastify = __commonJS({
|
|
|
36622
36622
|
}
|
|
36623
36623
|
fourOhFour.router.lookup(req, res);
|
|
36624
36624
|
}
|
|
36625
|
-
function onBadUrl(
|
|
36625
|
+
function onBadUrl(path21, req, res) {
|
|
36626
36626
|
if (options.frameworkErrors) {
|
|
36627
36627
|
const id = getGenReqId(routeEventContext.server, req);
|
|
36628
36628
|
const childLogger = createChildLogger(routeEventContext, options.logger, req, id);
|
|
36629
36629
|
const request = new Request(id, null, req, null, childLogger, routeEventContext);
|
|
36630
36630
|
const reply = new Reply(res, request, childLogger);
|
|
36631
36631
|
routeEventContext.server[kLogController].incomingRequest(request, reply);
|
|
36632
|
-
return options.frameworkErrors(new FST_ERR_BAD_URL(
|
|
36632
|
+
return options.frameworkErrors(new FST_ERR_BAD_URL(path21), request, reply);
|
|
36633
36633
|
}
|
|
36634
36634
|
const body = JSON.stringify({
|
|
36635
36635
|
error: "Bad Request",
|
|
36636
36636
|
code: "FST_ERR_BAD_URL",
|
|
36637
|
-
message: `'${
|
|
36637
|
+
message: `'${path21}' is not a valid url component`,
|
|
36638
36638
|
statusCode: 400
|
|
36639
36639
|
});
|
|
36640
36640
|
res.writeHead(400, {
|
|
@@ -36643,19 +36643,19 @@ var require_fastify = __commonJS({
|
|
|
36643
36643
|
});
|
|
36644
36644
|
res.end(body);
|
|
36645
36645
|
}
|
|
36646
|
-
function onMaxParamLength(
|
|
36646
|
+
function onMaxParamLength(path21, req, res) {
|
|
36647
36647
|
if (options.frameworkErrors) {
|
|
36648
36648
|
const id = getGenReqId(routeEventContext.server, req);
|
|
36649
36649
|
const childLogger = createChildLogger(routeEventContext, options.logger, req, id);
|
|
36650
36650
|
const request = new Request(id, null, req, null, childLogger, routeEventContext);
|
|
36651
36651
|
const reply = new Reply(res, request, childLogger);
|
|
36652
36652
|
routeEventContext.server[kLogController].incomingRequest(request, reply);
|
|
36653
|
-
return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(
|
|
36653
|
+
return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(path21), request, reply);
|
|
36654
36654
|
}
|
|
36655
36655
|
const body = JSON.stringify({
|
|
36656
36656
|
error: "Bad Request",
|
|
36657
36657
|
code: "FST_ERR_MAX_PARAM_LENGTH",
|
|
36658
|
-
message: `'${
|
|
36658
|
+
message: `'${path21}' is exceeding the max param length`,
|
|
36659
36659
|
statusCode: 414
|
|
36660
36660
|
});
|
|
36661
36661
|
res.writeHead(414, {
|
|
@@ -37480,7 +37480,7 @@ var require_limiter = __commonJS({
|
|
|
37480
37480
|
var require_permessage_deflate = __commonJS({
|
|
37481
37481
|
"node_modules/ws/lib/permessage-deflate.js"(exports, module) {
|
|
37482
37482
|
"use strict";
|
|
37483
|
-
var
|
|
37483
|
+
var zlib2 = __require("zlib");
|
|
37484
37484
|
var bufferUtil = require_buffer_util();
|
|
37485
37485
|
var Limiter = require_limiter();
|
|
37486
37486
|
var { kStatusCode } = require_constants3();
|
|
@@ -37747,8 +37747,8 @@ var require_permessage_deflate = __commonJS({
|
|
|
37747
37747
|
const endpoint = this._isServer ? "client" : "server";
|
|
37748
37748
|
if (!this._inflate) {
|
|
37749
37749
|
const key = `${endpoint}_max_window_bits`;
|
|
37750
|
-
const windowBits = typeof this.params[key] !== "number" ?
|
|
37751
|
-
this._inflate =
|
|
37750
|
+
const windowBits = typeof this.params[key] !== "number" ? zlib2.Z_DEFAULT_WINDOWBITS : this.params[key];
|
|
37751
|
+
this._inflate = zlib2.createInflateRaw({
|
|
37752
37752
|
...this._options.zlibInflateOptions,
|
|
37753
37753
|
windowBits
|
|
37754
37754
|
});
|
|
@@ -37798,8 +37798,8 @@ var require_permessage_deflate = __commonJS({
|
|
|
37798
37798
|
const endpoint = this._isServer ? "server" : "client";
|
|
37799
37799
|
if (!this._deflate) {
|
|
37800
37800
|
const key = `${endpoint}_max_window_bits`;
|
|
37801
|
-
const windowBits = typeof this.params[key] !== "number" ?
|
|
37802
|
-
this._deflate =
|
|
37801
|
+
const windowBits = typeof this.params[key] !== "number" ? zlib2.Z_DEFAULT_WINDOWBITS : this.params[key];
|
|
37802
|
+
this._deflate = zlib2.createDeflateRaw({
|
|
37803
37803
|
...this._options.zlibDeflateOptions,
|
|
37804
37804
|
windowBits
|
|
37805
37805
|
});
|
|
@@ -37809,7 +37809,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
37809
37809
|
}
|
|
37810
37810
|
this._deflate[kCallback] = callback;
|
|
37811
37811
|
this._deflate.write(data);
|
|
37812
|
-
this._deflate.flush(
|
|
37812
|
+
this._deflate.flush(zlib2.Z_SYNC_FLUSH, () => {
|
|
37813
37813
|
if (!this._deflate) {
|
|
37814
37814
|
return;
|
|
37815
37815
|
}
|
|
@@ -41001,13 +41001,13 @@ var require_websocket_server = __commonJS({
|
|
|
41001
41001
|
// src/server.ts
|
|
41002
41002
|
var import_fastify = __toESM(require_fastify(), 1);
|
|
41003
41003
|
var import_cors = __toESM(require_cors(), 1);
|
|
41004
|
-
import
|
|
41004
|
+
import path20 from "node:path";
|
|
41005
41005
|
|
|
41006
41006
|
// src/db/index.ts
|
|
41007
41007
|
import Database from "better-sqlite3";
|
|
41008
41008
|
var db;
|
|
41009
|
-
function initDb(
|
|
41010
|
-
db = new Database(
|
|
41009
|
+
function initDb(path21 = "data.db") {
|
|
41010
|
+
db = new Database(path21);
|
|
41011
41011
|
db.pragma("journal_mode = WAL");
|
|
41012
41012
|
db.pragma("foreign_keys = ON");
|
|
41013
41013
|
createTables(db);
|
|
@@ -43477,9 +43477,9 @@ async function browseFolder(input, opts = {}) {
|
|
|
43477
43477
|
const atHome = dir === nodePath.resolve(home);
|
|
43478
43478
|
const folders = await Promise.all(
|
|
43479
43479
|
names.slice(0, limit).map(async (name) => {
|
|
43480
|
-
const
|
|
43480
|
+
const path21 = nodePath.join(dir, name);
|
|
43481
43481
|
const skipProbe = atHome && HOME_STANDARD_FOLDERS.has(name) || dir === "/Volumes";
|
|
43482
|
-
return { name, path:
|
|
43482
|
+
return { name, path: path21, git: !skipProbe && await exists(nodePath.join(path21, ".git")) };
|
|
43483
43483
|
})
|
|
43484
43484
|
);
|
|
43485
43485
|
const parent = nodePath.dirname(dir);
|
|
@@ -43517,11 +43517,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
43517
43517
|
}
|
|
43518
43518
|
}
|
|
43519
43519
|
}, async (request, reply) => {
|
|
43520
|
-
const { path:
|
|
43521
|
-
if (!
|
|
43520
|
+
const { path: path21, label = null } = request.body || {};
|
|
43521
|
+
if (!path21 || !path21.trim()) {
|
|
43522
43522
|
return reply.code(400).send({ error: "Path is required" });
|
|
43523
43523
|
}
|
|
43524
|
-
const resolved = await resolveWorkspacePath(
|
|
43524
|
+
const resolved = await resolveWorkspacePath(path21);
|
|
43525
43525
|
if ("error" in resolved) {
|
|
43526
43526
|
return reply.code(400).send({ error: resolved.error });
|
|
43527
43527
|
}
|
|
@@ -43563,8 +43563,8 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
43563
43563
|
"-e",
|
|
43564
43564
|
'POSIX path of (choose folder with prompt "Select a workspace directory")'
|
|
43565
43565
|
]);
|
|
43566
|
-
const
|
|
43567
|
-
return { path:
|
|
43566
|
+
const path21 = stdout.trim().replace(/\/$/, "");
|
|
43567
|
+
return { path: path21 };
|
|
43568
43568
|
} catch {
|
|
43569
43569
|
return reply.code(204).send({ cancelled: true });
|
|
43570
43570
|
}
|
|
@@ -43580,11 +43580,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
43580
43580
|
}
|
|
43581
43581
|
}
|
|
43582
43582
|
}, async (request, reply) => {
|
|
43583
|
-
const { path:
|
|
43584
|
-
if (!
|
|
43583
|
+
const { path: path21 } = request.body || {};
|
|
43584
|
+
if (!path21 || !path21.trim()) {
|
|
43585
43585
|
return reply.code(400).send({ error: "Path is required" });
|
|
43586
43586
|
}
|
|
43587
|
-
const trimmedPath =
|
|
43587
|
+
const trimmedPath = path21.trim();
|
|
43588
43588
|
const db2 = getDb();
|
|
43589
43589
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
43590
43590
|
if (existing) {
|
|
@@ -44318,17 +44318,17 @@ async function registerPerfLogRoutes(fastify) {
|
|
|
44318
44318
|
if (entries.length === 0) {
|
|
44319
44319
|
return reply.send({ written: 0 });
|
|
44320
44320
|
}
|
|
44321
|
-
const
|
|
44321
|
+
const path21 = perfLogPath();
|
|
44322
44322
|
try {
|
|
44323
|
-
mkdirSync2(dirname(
|
|
44323
|
+
mkdirSync2(dirname(path21), { recursive: true });
|
|
44324
44324
|
try {
|
|
44325
|
-
if (statSync(
|
|
44326
|
-
renameSync(
|
|
44325
|
+
if (statSync(path21).size > MAX_BYTES) {
|
|
44326
|
+
renameSync(path21, `${path21}.1`);
|
|
44327
44327
|
}
|
|
44328
44328
|
} catch {
|
|
44329
44329
|
}
|
|
44330
44330
|
const lines = entries.map((e) => `${new Date(e.t).toISOString()} [${oneLine(e.cat)}] ${oneLine(e.msg)}`).join("\n");
|
|
44331
|
-
appendFileSync(
|
|
44331
|
+
appendFileSync(path21, `${lines}
|
|
44332
44332
|
`, "utf-8");
|
|
44333
44333
|
return reply.send({ written: entries.length });
|
|
44334
44334
|
} catch (err) {
|
|
@@ -44952,8 +44952,8 @@ function proxyHandler(request, reply) {
|
|
|
44952
44952
|
}
|
|
44953
44953
|
|
|
44954
44954
|
// src/routes/apps.ts
|
|
44955
|
-
import
|
|
44956
|
-
import
|
|
44955
|
+
import fs7 from "node:fs";
|
|
44956
|
+
import path11 from "node:path";
|
|
44957
44957
|
|
|
44958
44958
|
// src/apps/instances.ts
|
|
44959
44959
|
import fs3 from "node:fs";
|
|
@@ -99609,6 +99609,21 @@ function resolveToolWorkspace(workspace) {
|
|
|
99609
99609
|
function deleteAppInstances(appId) {
|
|
99610
99610
|
getDb().prepare("DELETE FROM app_instances WHERE app_id = ?").run(appId);
|
|
99611
99611
|
}
|
|
99612
|
+
function listAppInstances(appId) {
|
|
99613
|
+
getInstanceState(appId, "");
|
|
99614
|
+
const rows = getDb().prepare("SELECT * FROM app_instances WHERE app_id = ? ORDER BY workspace_path").all(appId);
|
|
99615
|
+
return rows.map((row) => {
|
|
99616
|
+
const { pinned, data } = rowToState(row);
|
|
99617
|
+
return { workspace: row.workspace_path, pinned, data };
|
|
99618
|
+
});
|
|
99619
|
+
}
|
|
99620
|
+
function importAppInstances(appId, instances) {
|
|
99621
|
+
getDb().transaction(() => {
|
|
99622
|
+
for (const inst of instances) {
|
|
99623
|
+
writeRow(appId, inst.workspace, { pinned: inst.pinned, data: inst.data, version: inst.data ? 1 : 0 });
|
|
99624
|
+
}
|
|
99625
|
+
})();
|
|
99626
|
+
}
|
|
99612
99627
|
|
|
99613
99628
|
// src/apps/mcp-tools.ts
|
|
99614
99629
|
import fs5 from "node:fs";
|
|
@@ -99843,6 +99858,29 @@ function deleteAppFiles(appId) {
|
|
|
99843
99858
|
if (!APP_ID_RE.test(appId)) return;
|
|
99844
99859
|
fs4.rmSync(appFilesDir(appId), { recursive: true, force: true });
|
|
99845
99860
|
}
|
|
99861
|
+
function listAppFileIds(appId) {
|
|
99862
|
+
try {
|
|
99863
|
+
return fs4.readdirSync(appFilesDir(appId)).filter((name) => APP_FILE_ID_RE.test(name)).sort();
|
|
99864
|
+
} catch {
|
|
99865
|
+
return [];
|
|
99866
|
+
}
|
|
99867
|
+
}
|
|
99868
|
+
function checkImportedAppFile(fileId, bytes) {
|
|
99869
|
+
const type = sniffImageType(bytes);
|
|
99870
|
+
const expected = type ? `${crypto2.createHash("sha256").update(bytes).digest("hex")}.${APP_FILE_TYPES[type]}` : null;
|
|
99871
|
+
if (!APP_FILE_ID_RE.test(fileId) || fileId !== expected || bytes.length > APP_FILE_MAX_BYTES) {
|
|
99872
|
+
throw new AppFileError(`Stored file does not match its id: ${fileId}`, 400);
|
|
99873
|
+
}
|
|
99874
|
+
}
|
|
99875
|
+
function writeImportedAppFiles(appId, files) {
|
|
99876
|
+
if (files.size === 0) return;
|
|
99877
|
+
const dir = appFilesDir(appId);
|
|
99878
|
+
fs4.mkdirSync(dir, { recursive: true });
|
|
99879
|
+
for (const [fileId, bytes] of files) {
|
|
99880
|
+
const file2 = path7.join(dir, fileId);
|
|
99881
|
+
if (!fs4.existsSync(file2)) fs4.writeFileSync(file2, bytes);
|
|
99882
|
+
}
|
|
99883
|
+
}
|
|
99846
99884
|
|
|
99847
99885
|
// src/apps/app-sessions.ts
|
|
99848
99886
|
function text(value) {
|
|
@@ -100944,11 +100982,363 @@ function anyAppHasTools() {
|
|
|
100944
100982
|
return listAppTools().length > 0;
|
|
100945
100983
|
}
|
|
100946
100984
|
|
|
100985
|
+
// src/apps/app-zip.ts
|
|
100986
|
+
import fs6 from "node:fs";
|
|
100987
|
+
import path10 from "node:path";
|
|
100988
|
+
|
|
100989
|
+
// src/apps/zip.ts
|
|
100990
|
+
import zlib from "node:zlib";
|
|
100991
|
+
var ZipError = class extends Error {
|
|
100992
|
+
};
|
|
100993
|
+
var LOCAL_SIG = 67324752;
|
|
100994
|
+
var CENTRAL_SIG = 33639248;
|
|
100995
|
+
var EOCD_SIG = 101010256;
|
|
100996
|
+
var EOCD_MIN = 22;
|
|
100997
|
+
var FLAG_UTF8 = 2048;
|
|
100998
|
+
var FLAG_ENCRYPTED = 1;
|
|
100999
|
+
var METHOD_STORE = 0;
|
|
101000
|
+
var METHOD_DEFLATE = 8;
|
|
101001
|
+
var MADE_BY_UNIX = 3 << 8 | 20;
|
|
101002
|
+
var S_IFMT = 61440;
|
|
101003
|
+
var S_IFREG = 32768;
|
|
101004
|
+
var S_IFLNK = 40960;
|
|
101005
|
+
function dosDateTime(when) {
|
|
101006
|
+
const year = Math.max(1980, when.getFullYear());
|
|
101007
|
+
return {
|
|
101008
|
+
time: when.getHours() << 11 | when.getMinutes() << 5 | Math.floor(when.getSeconds() / 2),
|
|
101009
|
+
date: year - 1980 << 9 | when.getMonth() + 1 << 5 | when.getDate()
|
|
101010
|
+
};
|
|
101011
|
+
}
|
|
101012
|
+
function createZip(entries, when = /* @__PURE__ */ new Date()) {
|
|
101013
|
+
const { time: time3, date: date5 } = dosDateTime(when);
|
|
101014
|
+
const locals = [];
|
|
101015
|
+
const centrals = [];
|
|
101016
|
+
let offset = 0;
|
|
101017
|
+
for (const entry of entries) {
|
|
101018
|
+
const name = Buffer.from(entry.name, "utf-8");
|
|
101019
|
+
const crc = zlib.crc32(entry.data);
|
|
101020
|
+
const deflated = zlib.deflateRawSync(entry.data);
|
|
101021
|
+
const useDeflate = deflated.length < entry.data.length;
|
|
101022
|
+
const body = useDeflate ? deflated : entry.data;
|
|
101023
|
+
const method = useDeflate ? METHOD_DEFLATE : METHOD_STORE;
|
|
101024
|
+
const local = Buffer.alloc(30);
|
|
101025
|
+
local.writeUInt32LE(LOCAL_SIG, 0);
|
|
101026
|
+
local.writeUInt16LE(20, 4);
|
|
101027
|
+
local.writeUInt16LE(FLAG_UTF8, 6);
|
|
101028
|
+
local.writeUInt16LE(method, 8);
|
|
101029
|
+
local.writeUInt16LE(time3, 10);
|
|
101030
|
+
local.writeUInt16LE(date5, 12);
|
|
101031
|
+
local.writeUInt32LE(crc, 14);
|
|
101032
|
+
local.writeUInt32LE(body.length, 18);
|
|
101033
|
+
local.writeUInt32LE(entry.data.length, 22);
|
|
101034
|
+
local.writeUInt16LE(name.length, 26);
|
|
101035
|
+
local.writeUInt16LE(0, 28);
|
|
101036
|
+
locals.push(local, name, body);
|
|
101037
|
+
const central = Buffer.alloc(46);
|
|
101038
|
+
central.writeUInt32LE(CENTRAL_SIG, 0);
|
|
101039
|
+
central.writeUInt16LE(MADE_BY_UNIX, 4);
|
|
101040
|
+
central.writeUInt16LE(20, 6);
|
|
101041
|
+
central.writeUInt16LE(FLAG_UTF8, 8);
|
|
101042
|
+
central.writeUInt16LE(method, 10);
|
|
101043
|
+
central.writeUInt16LE(time3, 12);
|
|
101044
|
+
central.writeUInt16LE(date5, 14);
|
|
101045
|
+
central.writeUInt32LE(crc, 16);
|
|
101046
|
+
central.writeUInt32LE(body.length, 20);
|
|
101047
|
+
central.writeUInt32LE(entry.data.length, 24);
|
|
101048
|
+
central.writeUInt16LE(name.length, 28);
|
|
101049
|
+
central.writeUInt32LE((S_IFREG | 420) << 16 >>> 0, 38);
|
|
101050
|
+
central.writeUInt32LE(offset, 42);
|
|
101051
|
+
centrals.push(central, name);
|
|
101052
|
+
offset += local.length + name.length + body.length;
|
|
101053
|
+
}
|
|
101054
|
+
const centralDir = Buffer.concat(centrals);
|
|
101055
|
+
const eocd = Buffer.alloc(EOCD_MIN);
|
|
101056
|
+
eocd.writeUInt32LE(EOCD_SIG, 0);
|
|
101057
|
+
eocd.writeUInt16LE(entries.length, 8);
|
|
101058
|
+
eocd.writeUInt16LE(entries.length, 10);
|
|
101059
|
+
eocd.writeUInt32LE(centralDir.length, 12);
|
|
101060
|
+
eocd.writeUInt32LE(offset, 16);
|
|
101061
|
+
return Buffer.concat([...locals, centralDir, eocd]);
|
|
101062
|
+
}
|
|
101063
|
+
function readZip(buf, limits) {
|
|
101064
|
+
let eocd = -1;
|
|
101065
|
+
for (let i = buf.length - EOCD_MIN; i >= Math.max(0, buf.length - EOCD_MIN - 65535); i--) {
|
|
101066
|
+
if (buf.readUInt32LE(i) === EOCD_SIG) {
|
|
101067
|
+
eocd = i;
|
|
101068
|
+
break;
|
|
101069
|
+
}
|
|
101070
|
+
}
|
|
101071
|
+
if (eocd < 0) throw new ZipError("Not a zip file");
|
|
101072
|
+
const count2 = buf.readUInt16LE(eocd + 10);
|
|
101073
|
+
const cdSize = buf.readUInt32LE(eocd + 12);
|
|
101074
|
+
const cdOffset = buf.readUInt32LE(eocd + 16);
|
|
101075
|
+
if (count2 === 65535 || cdOffset === 4294967295) throw new ZipError("ZIP64 archives are not supported");
|
|
101076
|
+
if (cdOffset + cdSize > eocd) throw new ZipError("Corrupt zip: central directory out of range");
|
|
101077
|
+
const out = [];
|
|
101078
|
+
let total = 0;
|
|
101079
|
+
let p = cdOffset;
|
|
101080
|
+
for (let n = 0; n < count2; n++) {
|
|
101081
|
+
if (p + 46 > eocd || buf.readUInt32LE(p) !== CENTRAL_SIG) throw new ZipError("Corrupt zip: bad central directory");
|
|
101082
|
+
const flags = buf.readUInt16LE(p + 8);
|
|
101083
|
+
const method = buf.readUInt16LE(p + 10);
|
|
101084
|
+
const crc = buf.readUInt32LE(p + 16);
|
|
101085
|
+
const compSize = buf.readUInt32LE(p + 20);
|
|
101086
|
+
const size2 = buf.readUInt32LE(p + 24);
|
|
101087
|
+
const nameLen = buf.readUInt16LE(p + 28);
|
|
101088
|
+
const extraLen = buf.readUInt16LE(p + 30);
|
|
101089
|
+
const commentLen = buf.readUInt16LE(p + 32);
|
|
101090
|
+
const madeBy = buf.readUInt16LE(p + 4) >> 8;
|
|
101091
|
+
const mode = buf.readUInt32LE(p + 38) >>> 16;
|
|
101092
|
+
const localOffset = buf.readUInt32LE(p + 42);
|
|
101093
|
+
const name = buf.toString(flags & FLAG_UTF8 ? "utf-8" : "latin1", p + 46, p + 46 + nameLen);
|
|
101094
|
+
p += 46 + nameLen + extraLen + commentLen;
|
|
101095
|
+
if (name.endsWith("/")) continue;
|
|
101096
|
+
if (madeBy === 3 && (mode & S_IFMT) === S_IFLNK) continue;
|
|
101097
|
+
if (flags & FLAG_ENCRYPTED) throw new ZipError(`Encrypted entries are not supported: ${name}`);
|
|
101098
|
+
if (method !== METHOD_STORE && method !== METHOD_DEFLATE) {
|
|
101099
|
+
throw new ZipError(`Unsupported compression method ${method}: ${name}`);
|
|
101100
|
+
}
|
|
101101
|
+
if (compSize === 4294967295 || size2 === 4294967295) throw new ZipError("ZIP64 archives are not supported");
|
|
101102
|
+
if (out.length >= limits.maxEntries) throw new ZipError(`Too many files (max ${limits.maxEntries})`);
|
|
101103
|
+
if (size2 > limits.maxFileBytes) throw new ZipError(`File too large: ${name}`);
|
|
101104
|
+
total += size2;
|
|
101105
|
+
if (total > limits.maxTotalBytes) throw new ZipError("Archive too large when unpacked");
|
|
101106
|
+
if (localOffset + 30 > buf.length || buf.readUInt32LE(localOffset) !== LOCAL_SIG) {
|
|
101107
|
+
throw new ZipError(`Corrupt zip: bad local header for ${name}`);
|
|
101108
|
+
}
|
|
101109
|
+
const dataStart = localOffset + 30 + buf.readUInt16LE(localOffset + 26) + buf.readUInt16LE(localOffset + 28);
|
|
101110
|
+
if (dataStart + compSize > buf.length) throw new ZipError(`Corrupt zip: truncated ${name}`);
|
|
101111
|
+
const raw = buf.subarray(dataStart, dataStart + compSize);
|
|
101112
|
+
let data;
|
|
101113
|
+
if (method === METHOD_STORE) {
|
|
101114
|
+
data = Buffer.from(raw);
|
|
101115
|
+
} else {
|
|
101116
|
+
try {
|
|
101117
|
+
data = zlib.inflateRawSync(raw, { maxOutputLength: Math.max(1, size2) });
|
|
101118
|
+
} catch {
|
|
101119
|
+
throw new ZipError(`Corrupt zip: cannot inflate ${name}`);
|
|
101120
|
+
}
|
|
101121
|
+
}
|
|
101122
|
+
if (data.length !== size2 || zlib.crc32(data) !== crc) throw new ZipError(`Corrupt zip: checksum mismatch in ${name}`);
|
|
101123
|
+
out.push({ name, data });
|
|
101124
|
+
}
|
|
101125
|
+
return out;
|
|
101126
|
+
}
|
|
101127
|
+
|
|
101128
|
+
// src/apps/app-zip.ts
|
|
101129
|
+
var APP_ZIP_MAX_BYTES = 50 * 1024 * 1024;
|
|
101130
|
+
var APP_DATA_DIR = ".agentpane-data";
|
|
101131
|
+
var DATA_FORMAT = 1;
|
|
101132
|
+
var MAX_INSTANCES2 = 1e3;
|
|
101133
|
+
var IMPORT_LIMITS = {
|
|
101134
|
+
maxEntries: 5e3,
|
|
101135
|
+
maxFileBytes: 20 * 1024 * 1024,
|
|
101136
|
+
maxTotalBytes: 100 * 1024 * 1024
|
|
101137
|
+
};
|
|
101138
|
+
var AppZipError = class extends Error {
|
|
101139
|
+
constructor(message, status) {
|
|
101140
|
+
super(message);
|
|
101141
|
+
this.status = status;
|
|
101142
|
+
}
|
|
101143
|
+
};
|
|
101144
|
+
function isSkipped(segment) {
|
|
101145
|
+
return segment.startsWith(".") || segment === "node_modules" || segment === "__MACOSX";
|
|
101146
|
+
}
|
|
101147
|
+
function isSafeSegment(segment) {
|
|
101148
|
+
return segment.length > 0 && segment.length <= 255 && !/[\\/:*?"<>|]/.test(segment) && ![...segment].some((ch) => ch.charCodeAt(0) < 32);
|
|
101149
|
+
}
|
|
101150
|
+
function collectAppFiles(id) {
|
|
101151
|
+
const root = appDir(id);
|
|
101152
|
+
const out = [];
|
|
101153
|
+
const walk = (dir, rel) => {
|
|
101154
|
+
const entries = fs6.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
101155
|
+
for (const entry of entries) {
|
|
101156
|
+
if (isSkipped(entry.name)) continue;
|
|
101157
|
+
const relPath = rel ? `${rel}/${entry.name}` : entry.name;
|
|
101158
|
+
if (!rel && entry.name === "state.json") continue;
|
|
101159
|
+
const full = path10.join(dir, entry.name);
|
|
101160
|
+
if (entry.isDirectory()) walk(full, relPath);
|
|
101161
|
+
else if (entry.isFile()) out.push({ name: `${id}/${relPath}`, data: fs6.readFileSync(full) });
|
|
101162
|
+
}
|
|
101163
|
+
};
|
|
101164
|
+
walk(root, "");
|
|
101165
|
+
return out;
|
|
101166
|
+
}
|
|
101167
|
+
function collectAppData(id) {
|
|
101168
|
+
const dataJson = { format: DATA_FORMAT, app: id, filesDir: appFilesDir(id), instances: listAppInstances(id) };
|
|
101169
|
+
const out = [
|
|
101170
|
+
{ name: `${id}/${APP_DATA_DIR}/data.json`, data: Buffer.from(JSON.stringify(dataJson, null, 2)) }
|
|
101171
|
+
];
|
|
101172
|
+
for (const fileId of listAppFileIds(id)) {
|
|
101173
|
+
out.push({
|
|
101174
|
+
name: `${id}/${APP_DATA_DIR}/files/${fileId}`,
|
|
101175
|
+
data: fs6.readFileSync(path10.join(appFilesDir(id), fileId))
|
|
101176
|
+
});
|
|
101177
|
+
}
|
|
101178
|
+
return out;
|
|
101179
|
+
}
|
|
101180
|
+
function exportAppZip(id, opts = {}) {
|
|
101181
|
+
if (!readManifest(id)) throw new AppZipError("App not found", 404);
|
|
101182
|
+
return createZip([...collectAppFiles(id), ...opts.data ? collectAppData(id) : []]);
|
|
101183
|
+
}
|
|
101184
|
+
function parseAppData(entries) {
|
|
101185
|
+
const raw = entries.get("data.json");
|
|
101186
|
+
if (!raw) throw new AppZipError(`${APP_DATA_DIR}/data.json is missing`, 400);
|
|
101187
|
+
let parsed;
|
|
101188
|
+
try {
|
|
101189
|
+
parsed = JSON.parse(raw.toString("utf-8"));
|
|
101190
|
+
} catch {
|
|
101191
|
+
throw new AppZipError(`${APP_DATA_DIR}/data.json is not valid JSON`, 400);
|
|
101192
|
+
}
|
|
101193
|
+
const doc = parsed;
|
|
101194
|
+
if (!doc || typeof doc !== "object" || doc.format !== DATA_FORMAT || !Array.isArray(doc.instances)) {
|
|
101195
|
+
throw new AppZipError(`${APP_DATA_DIR}/data.json has an unknown format`, 400);
|
|
101196
|
+
}
|
|
101197
|
+
if (doc.instances.length > MAX_INSTANCES2) throw new AppZipError(`Too many instances (max ${MAX_INSTANCES2})`, 400);
|
|
101198
|
+
const seen = /* @__PURE__ */ new Set();
|
|
101199
|
+
const instances = doc.instances.map((item) => {
|
|
101200
|
+
const inst = item;
|
|
101201
|
+
const workspace = inst && typeof inst.workspace === "string" ? inst.workspace : null;
|
|
101202
|
+
const valid = workspace !== null && (workspace === "" || path10.isAbsolute(workspace)) && !seen.has(workspace) && (inst.data === null || typeof inst.data === "object" && !Array.isArray(inst.data));
|
|
101203
|
+
if (!valid) throw new AppZipError(`${APP_DATA_DIR}/data.json has an invalid instance`, 400);
|
|
101204
|
+
seen.add(workspace);
|
|
101205
|
+
return { workspace, pinned: inst.pinned === true, data: inst.data };
|
|
101206
|
+
});
|
|
101207
|
+
const files = /* @__PURE__ */ new Map();
|
|
101208
|
+
for (const [rel, bytes] of entries) {
|
|
101209
|
+
if (rel === "data.json") continue;
|
|
101210
|
+
const fileId = rel.startsWith("files/") ? rel.slice("files/".length) : rel;
|
|
101211
|
+
try {
|
|
101212
|
+
checkImportedAppFile(fileId, bytes);
|
|
101213
|
+
} catch (err) {
|
|
101214
|
+
if (err instanceof AppFileError) throw new AppZipError(`${APP_DATA_DIR}/${rel}: ${err.message}`, 400);
|
|
101215
|
+
throw err;
|
|
101216
|
+
}
|
|
101217
|
+
files.set(fileId, bytes);
|
|
101218
|
+
}
|
|
101219
|
+
return {
|
|
101220
|
+
app: typeof doc.app === "string" ? doc.app : "",
|
|
101221
|
+
filesDir: typeof doc.filesDir === "string" && doc.filesDir ? doc.filesDir : null,
|
|
101222
|
+
instances,
|
|
101223
|
+
files
|
|
101224
|
+
};
|
|
101225
|
+
}
|
|
101226
|
+
function readAppZip(buf) {
|
|
101227
|
+
let entries;
|
|
101228
|
+
try {
|
|
101229
|
+
entries = readZip(buf, IMPORT_LIMITS);
|
|
101230
|
+
} catch (err) {
|
|
101231
|
+
if (err instanceof ZipError) throw new AppZipError(err.message, 400);
|
|
101232
|
+
throw err;
|
|
101233
|
+
}
|
|
101234
|
+
const paths = [];
|
|
101235
|
+
const bytesOf = /* @__PURE__ */ new Map();
|
|
101236
|
+
for (const entry of entries) {
|
|
101237
|
+
const segments = entry.name.replace(/\\/g, "/").split("/");
|
|
101238
|
+
if (!segments.every(isSafeSegment) || segments.some((s) => s === "." || s === "..")) {
|
|
101239
|
+
throw new AppZipError(`Invalid file path in archive: ${entry.name}`, 400);
|
|
101240
|
+
}
|
|
101241
|
+
const dataAt = segments.indexOf(APP_DATA_DIR);
|
|
101242
|
+
const junk = segments.some((s, i) => isSkipped(s) && i !== dataAt) || dataAt > 1;
|
|
101243
|
+
if (junk) continue;
|
|
101244
|
+
paths.push(segments);
|
|
101245
|
+
bytesOf.set(segments, entry.data);
|
|
101246
|
+
}
|
|
101247
|
+
const first = paths[0]?.[0];
|
|
101248
|
+
const nested = paths.length > 0 && paths.every((p) => p.length > 1 && p[0] === first && p[0] !== APP_DATA_DIR);
|
|
101249
|
+
const files = /* @__PURE__ */ new Map();
|
|
101250
|
+
const dataEntries = /* @__PURE__ */ new Map();
|
|
101251
|
+
for (const p of paths) {
|
|
101252
|
+
const segs = nested ? p.slice(1) : p;
|
|
101253
|
+
const bytes = bytesOf.get(p);
|
|
101254
|
+
if (segs[0] === APP_DATA_DIR) {
|
|
101255
|
+
dataEntries.set(segs.slice(1).join("/"), bytes);
|
|
101256
|
+
continue;
|
|
101257
|
+
}
|
|
101258
|
+
if (segs.some(isSkipped)) continue;
|
|
101259
|
+
const rel = segs.join("/");
|
|
101260
|
+
if (files.has(rel)) throw new AppZipError(`Duplicate file in archive: ${rel}`, 400);
|
|
101261
|
+
files.set(rel, bytes);
|
|
101262
|
+
}
|
|
101263
|
+
if (files.size === 0) throw new AppZipError("The archive holds no app files", 400);
|
|
101264
|
+
for (const rel of files.keys()) {
|
|
101265
|
+
const parts = rel.split("/");
|
|
101266
|
+
for (let i = 1; i < parts.length; i++) {
|
|
101267
|
+
if (files.has(parts.slice(0, i).join("/"))) throw new AppZipError(`Conflicting paths in archive: ${rel}`, 400);
|
|
101268
|
+
}
|
|
101269
|
+
}
|
|
101270
|
+
return {
|
|
101271
|
+
files,
|
|
101272
|
+
folder: nested ? first : null,
|
|
101273
|
+
data: dataEntries.size > 0 ? parseAppData(dataEntries) : null
|
|
101274
|
+
};
|
|
101275
|
+
}
|
|
101276
|
+
function mapStrings(value, replace) {
|
|
101277
|
+
if (typeof value === "string") return replace(value);
|
|
101278
|
+
if (Array.isArray(value)) return value.map((v) => mapStrings(v, replace));
|
|
101279
|
+
if (value && typeof value === "object") {
|
|
101280
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, mapStrings(v, replace)]));
|
|
101281
|
+
}
|
|
101282
|
+
return value;
|
|
101283
|
+
}
|
|
101284
|
+
function rehomeInstances(data, id) {
|
|
101285
|
+
const swaps = [];
|
|
101286
|
+
const newUrl = `/api/apps/${id}/files/`;
|
|
101287
|
+
if (data.app && data.app !== id) swaps.push([`/api/apps/${data.app}/files/`, newUrl]);
|
|
101288
|
+
const newDir = appFilesDir(id);
|
|
101289
|
+
const oldDir = data.filesDir?.replace(/[\\/]+$/, "");
|
|
101290
|
+
if (oldDir && oldDir !== newDir) {
|
|
101291
|
+
swaps.push([`${oldDir}/`, `${newDir}${path10.sep}`], [`${oldDir}\\`, `${newDir}${path10.sep}`]);
|
|
101292
|
+
}
|
|
101293
|
+
if (swaps.length === 0) return data.instances;
|
|
101294
|
+
const replace = (s) => swaps.reduce((out, [from, to]) => out.split(from).join(to), s);
|
|
101295
|
+
return data.instances.map((inst) => ({
|
|
101296
|
+
...inst,
|
|
101297
|
+
data: inst.data ? mapStrings(inst.data, replace) : null
|
|
101298
|
+
}));
|
|
101299
|
+
}
|
|
101300
|
+
function importAppZip(id, buf, opts = {}) {
|
|
101301
|
+
const { files, data } = readAppZip(buf);
|
|
101302
|
+
if (readManifest(id) || fs6.existsSync(appDir(id))) throw new AppZipError("App already exists", 409);
|
|
101303
|
+
const withData = opts.data ? data : null;
|
|
101304
|
+
ensureAppsRoot();
|
|
101305
|
+
const tmp = path10.join(appsRoot(), `.import-${v4_default()}`);
|
|
101306
|
+
try {
|
|
101307
|
+
for (const [rel, bytes] of files) {
|
|
101308
|
+
const file2 = path10.join(tmp, ...rel.split("/"));
|
|
101309
|
+
fs6.mkdirSync(path10.dirname(file2), { recursive: true });
|
|
101310
|
+
fs6.writeFileSync(file2, bytes);
|
|
101311
|
+
}
|
|
101312
|
+
if (!files.has("manifest.json")) {
|
|
101313
|
+
fs6.writeFileSync(path10.join(tmp, "manifest.json"), JSON.stringify({ title: id }, null, 2));
|
|
101314
|
+
} else if (!readManifestIn(tmp)) {
|
|
101315
|
+
throw new AppZipError('manifest.json is invalid (it needs at least a "title" string)', 400);
|
|
101316
|
+
}
|
|
101317
|
+
if (fs6.existsSync(appDir(id))) throw new AppZipError("App already exists", 409);
|
|
101318
|
+
fs6.renameSync(tmp, appDir(id));
|
|
101319
|
+
} finally {
|
|
101320
|
+
fs6.rmSync(tmp, { recursive: true, force: true });
|
|
101321
|
+
}
|
|
101322
|
+
if (!withData) return { id, data: null };
|
|
101323
|
+
try {
|
|
101324
|
+
deleteAppFiles(id);
|
|
101325
|
+
deleteAppInstances(id);
|
|
101326
|
+
writeImportedAppFiles(id, withData.files);
|
|
101327
|
+
importAppInstances(id, rehomeInstances(withData, id));
|
|
101328
|
+
} catch (err) {
|
|
101329
|
+
fs6.rmSync(appDir(id), { recursive: true, force: true });
|
|
101330
|
+
deleteAppFiles(id);
|
|
101331
|
+
deleteAppInstances(id);
|
|
101332
|
+
throw err;
|
|
101333
|
+
}
|
|
101334
|
+
return { id, data: { instances: withData.instances.length, files: withData.files.size } };
|
|
101335
|
+
}
|
|
101336
|
+
|
|
100947
101337
|
// src/routes/apps.ts
|
|
100948
101338
|
var FILE_UPLOAD_BODY_LIMIT = Math.ceil(APP_FILE_MAX_BYTES * 4 / 3) + 64 * 1024;
|
|
100949
|
-
|
|
100950
|
-
|
|
100951
|
-
|
|
101339
|
+
function isTrueFlag(value) {
|
|
101340
|
+
return value === "1" || value === "true";
|
|
101341
|
+
}
|
|
100952
101342
|
var SKELETON_HTML = `<!DOCTYPE html>
|
|
100953
101343
|
<html>
|
|
100954
101344
|
<head>
|
|
@@ -101000,7 +101390,7 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101000
101390
|
fastify.get("/api/apps", async () => {
|
|
101001
101391
|
try {
|
|
101002
101392
|
ensureAppsRoot();
|
|
101003
|
-
const entries =
|
|
101393
|
+
const entries = fs7.readdirSync(appsRoot(), { withFileTypes: true });
|
|
101004
101394
|
const apps = [];
|
|
101005
101395
|
for (const entry of entries) {
|
|
101006
101396
|
if (!entry.isDirectory() || !APP_ID_RE.test(entry.name)) continue;
|
|
@@ -101030,9 +101420,9 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101030
101420
|
if (!exRoot) return [];
|
|
101031
101421
|
const out = [];
|
|
101032
101422
|
try {
|
|
101033
|
-
for (const entry of
|
|
101423
|
+
for (const entry of fs7.readdirSync(exRoot, { withFileTypes: true })) {
|
|
101034
101424
|
if (!entry.isDirectory() || !APP_ID_RE.test(entry.name)) continue;
|
|
101035
|
-
const manifest = readManifestIn(
|
|
101425
|
+
const manifest = readManifestIn(path11.join(exRoot, entry.name));
|
|
101036
101426
|
if (!manifest) continue;
|
|
101037
101427
|
out.push({
|
|
101038
101428
|
id: entry.name,
|
|
@@ -101053,11 +101443,11 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101053
101443
|
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
101054
101444
|
const exRoot = examplesRoot();
|
|
101055
101445
|
if (!exRoot) return reply.code(404).send({ error: "Examples catalog not available" });
|
|
101056
|
-
const src =
|
|
101446
|
+
const src = path11.join(exRoot, id);
|
|
101057
101447
|
if (!readManifestIn(src)) return reply.code(404).send({ error: "Example not found" });
|
|
101058
101448
|
if (readManifest(id)) return reply.code(409).send({ error: "App already installed" });
|
|
101059
101449
|
ensureAppsRoot();
|
|
101060
|
-
|
|
101450
|
+
fs7.cpSync(src, appDir(id), { recursive: true });
|
|
101061
101451
|
return { ok: true, id };
|
|
101062
101452
|
});
|
|
101063
101453
|
fastify.post(
|
|
@@ -101089,10 +101479,10 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101089
101479
|
if (readManifest(id)) return reply.code(409).send({ error: "App already exists" });
|
|
101090
101480
|
ensureAppsRoot();
|
|
101091
101481
|
const dir = appDir(id);
|
|
101092
|
-
|
|
101482
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
101093
101483
|
const cleanTitle2 = title.trim();
|
|
101094
|
-
|
|
101095
|
-
|
|
101484
|
+
fs7.writeFileSync(
|
|
101485
|
+
path11.join(dir, "manifest.json"),
|
|
101096
101486
|
JSON.stringify(
|
|
101097
101487
|
{
|
|
101098
101488
|
title: cleanTitle2,
|
|
@@ -101103,48 +101493,54 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101103
101493
|
2
|
|
101104
101494
|
)
|
|
101105
101495
|
);
|
|
101106
|
-
|
|
101107
|
-
|
|
101496
|
+
fs7.writeFileSync(path11.join(dir, "index.html"), SKELETON_HTML.replaceAll("__TITLE__", cleanTitle2));
|
|
101497
|
+
fs7.writeFileSync(path11.join(dir, "app.ts"), SKELETON_TS);
|
|
101108
101498
|
return { ok: true, id };
|
|
101109
101499
|
}
|
|
101110
101500
|
);
|
|
101111
|
-
fastify.
|
|
101112
|
-
|
|
101113
|
-
|
|
101114
|
-
|
|
101115
|
-
|
|
101116
|
-
|
|
101117
|
-
|
|
101118
|
-
|
|
101119
|
-
|
|
101120
|
-
|
|
101121
|
-
|
|
101501
|
+
await fastify.register(async (scope) => {
|
|
101502
|
+
scope.addContentTypeParser(
|
|
101503
|
+
["application/zip", "application/x-zip-compressed", "application/octet-stream"],
|
|
101504
|
+
{ parseAs: "buffer", bodyLimit: APP_ZIP_MAX_BYTES },
|
|
101505
|
+
(_req, body, done) => done(null, body)
|
|
101506
|
+
);
|
|
101507
|
+
scope.post(
|
|
101508
|
+
"/api/apps/import",
|
|
101509
|
+
{
|
|
101510
|
+
bodyLimit: APP_ZIP_MAX_BYTES,
|
|
101511
|
+
schema: {
|
|
101512
|
+
querystring: { type: "object", properties: { id: { type: "string" }, data: { type: "string" } } }
|
|
101122
101513
|
}
|
|
101123
|
-
}
|
|
101124
|
-
|
|
101125
|
-
|
|
101126
|
-
|
|
101127
|
-
|
|
101128
|
-
|
|
101129
|
-
|
|
101130
|
-
|
|
101131
|
-
|
|
101132
|
-
|
|
101133
|
-
|
|
101134
|
-
|
|
101135
|
-
|
|
101136
|
-
return reply.code(400).send({ error: `File too large: ${name}` });
|
|
101514
|
+
},
|
|
101515
|
+
async (request, reply) => {
|
|
101516
|
+
if (!Buffer.isBuffer(request.body) || request.body.length === 0) {
|
|
101517
|
+
return reply.code(400).send({ error: "Upload a .zip file (Content-Type: application/zip)" });
|
|
101518
|
+
}
|
|
101519
|
+
try {
|
|
101520
|
+
const id = request.query.id?.trim() || readAppZip(request.body).folder || "";
|
|
101521
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
101522
|
+
const result = importAppZip(id, request.body, { data: isTrueFlag(request.query.data) });
|
|
101523
|
+
return { ok: true, ...result };
|
|
101524
|
+
} catch (err) {
|
|
101525
|
+
if (err instanceof AppZipError) return reply.code(err.status).send({ error: err.message });
|
|
101526
|
+
throw err;
|
|
101137
101527
|
}
|
|
101138
101528
|
}
|
|
101139
|
-
|
|
101140
|
-
|
|
101141
|
-
|
|
101142
|
-
|
|
101143
|
-
|
|
101144
|
-
|
|
101529
|
+
);
|
|
101530
|
+
});
|
|
101531
|
+
fastify.get(
|
|
101532
|
+
"/api/apps/:id/export",
|
|
101533
|
+
{ schema: { querystring: { type: "object", properties: { data: { type: "string" } } } } },
|
|
101534
|
+
async (request, reply) => {
|
|
101535
|
+
const { id } = request.params;
|
|
101536
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
101537
|
+
try {
|
|
101538
|
+
const zip = exportAppZip(id, { data: isTrueFlag(request.query.data) });
|
|
101539
|
+
return reply.header("Content-Type", "application/zip").header("Content-Disposition", `attachment; filename="${id}.zip"`).header("Cache-Control", "no-store").send(zip);
|
|
101540
|
+
} catch (err) {
|
|
101541
|
+
if (err instanceof AppZipError) return reply.code(err.status).send({ error: err.message });
|
|
101542
|
+
throw err;
|
|
101145
101543
|
}
|
|
101146
|
-
for (const [name, content] of entries) fs6.writeFileSync(path10.join(dir, name), content);
|
|
101147
|
-
return { ok: true, id };
|
|
101148
101544
|
}
|
|
101149
101545
|
);
|
|
101150
101546
|
fastify.post(
|
|
@@ -101308,7 +101704,7 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101308
101704
|
const { id } = request.params;
|
|
101309
101705
|
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
101310
101706
|
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
101311
|
-
|
|
101707
|
+
fs7.rmSync(appDir(id), { recursive: true, force: true });
|
|
101312
101708
|
deleteAppFiles(id);
|
|
101313
101709
|
deleteAppInstances(id);
|
|
101314
101710
|
invalidateHeadlessRuntime(id);
|
|
@@ -102075,7 +102471,7 @@ async function registerUsageRoutes(fastify) {
|
|
|
102075
102471
|
|
|
102076
102472
|
// src/claude/session-import.ts
|
|
102077
102473
|
import { readFile as readFile2, realpath } from "node:fs/promises";
|
|
102078
|
-
import
|
|
102474
|
+
import path12 from "node:path";
|
|
102079
102475
|
import { getSessionInfo, listSessions } from "@anthropic-ai/claude-agent-sdk";
|
|
102080
102476
|
|
|
102081
102477
|
// src/claude/widget-tool.ts
|
|
@@ -102847,10 +103243,10 @@ function mergeDefs(...defs) {
|
|
|
102847
103243
|
function cloneDef(schema) {
|
|
102848
103244
|
return mergeDefs(schema._zod.def);
|
|
102849
103245
|
}
|
|
102850
|
-
function getElementAtPath(obj2,
|
|
102851
|
-
if (!
|
|
103246
|
+
function getElementAtPath(obj2, path21) {
|
|
103247
|
+
if (!path21)
|
|
102852
103248
|
return obj2;
|
|
102853
|
-
return
|
|
103249
|
+
return path21.reduce((acc, key) => acc?.[key], obj2);
|
|
102854
103250
|
}
|
|
102855
103251
|
function promiseAllObject(promisesObj) {
|
|
102856
103252
|
const keys = Object.keys(promisesObj);
|
|
@@ -103259,11 +103655,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
103259
103655
|
}
|
|
103260
103656
|
return false;
|
|
103261
103657
|
}
|
|
103262
|
-
function prefixIssues(
|
|
103658
|
+
function prefixIssues(path21, issues) {
|
|
103263
103659
|
return issues.map((iss) => {
|
|
103264
103660
|
var _a3;
|
|
103265
103661
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
103266
|
-
iss.path.unshift(
|
|
103662
|
+
iss.path.unshift(path21);
|
|
103267
103663
|
return iss;
|
|
103268
103664
|
});
|
|
103269
103665
|
}
|
|
@@ -103410,16 +103806,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
103410
103806
|
}
|
|
103411
103807
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
103412
103808
|
const fieldErrors = { _errors: [] };
|
|
103413
|
-
const processError = (error52,
|
|
103809
|
+
const processError = (error52, path21 = []) => {
|
|
103414
103810
|
for (const issue2 of error52.issues) {
|
|
103415
103811
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
103416
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
103812
|
+
issue2.errors.map((issues) => processError({ issues }, [...path21, ...issue2.path]));
|
|
103417
103813
|
} else if (issue2.code === "invalid_key") {
|
|
103418
|
-
processError({ issues: issue2.issues }, [...
|
|
103814
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
103419
103815
|
} else if (issue2.code === "invalid_element") {
|
|
103420
|
-
processError({ issues: issue2.issues }, [...
|
|
103816
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
103421
103817
|
} else {
|
|
103422
|
-
const fullpath = [...
|
|
103818
|
+
const fullpath = [...path21, ...issue2.path];
|
|
103423
103819
|
if (fullpath.length === 0) {
|
|
103424
103820
|
fieldErrors._errors.push(mapper(issue2));
|
|
103425
103821
|
} else {
|
|
@@ -103446,17 +103842,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
103446
103842
|
}
|
|
103447
103843
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
103448
103844
|
const result = { errors: [] };
|
|
103449
|
-
const processError = (error52,
|
|
103845
|
+
const processError = (error52, path21 = []) => {
|
|
103450
103846
|
var _a3, _b;
|
|
103451
103847
|
for (const issue2 of error52.issues) {
|
|
103452
103848
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
103453
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
103849
|
+
issue2.errors.map((issues) => processError({ issues }, [...path21, ...issue2.path]));
|
|
103454
103850
|
} else if (issue2.code === "invalid_key") {
|
|
103455
|
-
processError({ issues: issue2.issues }, [...
|
|
103851
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
103456
103852
|
} else if (issue2.code === "invalid_element") {
|
|
103457
|
-
processError({ issues: issue2.issues }, [...
|
|
103853
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
103458
103854
|
} else {
|
|
103459
|
-
const fullpath = [...
|
|
103855
|
+
const fullpath = [...path21, ...issue2.path];
|
|
103460
103856
|
if (fullpath.length === 0) {
|
|
103461
103857
|
result.errors.push(mapper(issue2));
|
|
103462
103858
|
continue;
|
|
@@ -103488,8 +103884,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
103488
103884
|
}
|
|
103489
103885
|
function toDotPath(_path) {
|
|
103490
103886
|
const segs = [];
|
|
103491
|
-
const
|
|
103492
|
-
for (const seg of
|
|
103887
|
+
const path21 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
103888
|
+
for (const seg of path21) {
|
|
103493
103889
|
if (typeof seg === "number")
|
|
103494
103890
|
segs.push(`[${seg}]`);
|
|
103495
103891
|
else if (typeof seg === "symbol")
|
|
@@ -116181,13 +116577,13 @@ function resolveRef(ref, ctx) {
|
|
|
116181
116577
|
if (!ref.startsWith("#")) {
|
|
116182
116578
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
116183
116579
|
}
|
|
116184
|
-
const
|
|
116185
|
-
if (
|
|
116580
|
+
const path21 = ref.slice(1).split("/").filter(Boolean);
|
|
116581
|
+
if (path21.length === 0) {
|
|
116186
116582
|
return ctx.rootSchema;
|
|
116187
116583
|
}
|
|
116188
116584
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
116189
|
-
if (
|
|
116190
|
-
const key =
|
|
116585
|
+
if (path21[0] === defsKey) {
|
|
116586
|
+
const key = path21[1];
|
|
116191
116587
|
if (!key || !ctx.defs[key]) {
|
|
116192
116588
|
throw new Error(`Reference not found: ${ref}`);
|
|
116193
116589
|
}
|
|
@@ -116712,9 +117108,9 @@ function mapToolUse(block) {
|
|
|
116712
117108
|
};
|
|
116713
117109
|
}
|
|
116714
117110
|
function deriveFileChangeData(input, toolName) {
|
|
116715
|
-
const
|
|
117111
|
+
const path21 = input.file_path ?? input.notebook_path ?? "";
|
|
116716
117112
|
const kind = toolName === "Write" ? "add" : "modify";
|
|
116717
|
-
return { changes: [{ path:
|
|
117113
|
+
return { changes: [{ path: path21, kind }], status: "in_progress" };
|
|
116718
117114
|
}
|
|
116719
117115
|
function extractToolResultText(content) {
|
|
116720
117116
|
if (!content) return "";
|
|
@@ -117120,7 +117516,7 @@ async function realDir(dir) {
|
|
|
117120
117516
|
}
|
|
117121
117517
|
}
|
|
117122
117518
|
async function sameDir(a, realB) {
|
|
117123
|
-
const realA = await realDir(a) ??
|
|
117519
|
+
const realA = await realDir(a) ?? path12.resolve(a);
|
|
117124
117520
|
return realA === realB;
|
|
117125
117521
|
}
|
|
117126
117522
|
function knownClaudeSessionIds(db2) {
|
|
@@ -117290,26 +117686,26 @@ async function registerClaudeSessionRoutes(fastify) {
|
|
|
117290
117686
|
|
|
117291
117687
|
// src/codex/session-import.ts
|
|
117292
117688
|
import { realpath as realpath2 } from "node:fs/promises";
|
|
117293
|
-
import
|
|
117689
|
+
import path14 from "node:path";
|
|
117294
117690
|
|
|
117295
117691
|
// src/apps/register-mcp.ts
|
|
117296
|
-
import
|
|
117297
|
-
import
|
|
117692
|
+
import fs8 from "node:fs";
|
|
117693
|
+
import path13 from "node:path";
|
|
117298
117694
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
117299
117695
|
var MCP_SERVER_NAME = "agentpane-miniapps";
|
|
117300
117696
|
function panePublicUrl() {
|
|
117301
117697
|
return (process.env.AGENT_PANE_PUBLIC_URL || process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
|
|
117302
117698
|
}
|
|
117303
117699
|
function stdioScriptPath() {
|
|
117304
|
-
const here =
|
|
117700
|
+
const here = path13.dirname(fileURLToPath2(import.meta.url));
|
|
117305
117701
|
const candidates = [
|
|
117306
|
-
|
|
117702
|
+
path13.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
|
|
117307
117703
|
// src/apps/ → backend/scripts
|
|
117308
|
-
|
|
117704
|
+
path13.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
|
|
117309
117705
|
// dist bundle → backend/scripts
|
|
117310
117706
|
];
|
|
117311
117707
|
for (const candidate of candidates) {
|
|
117312
|
-
if (
|
|
117708
|
+
if (fs8.existsSync(candidate)) return candidate;
|
|
117313
117709
|
}
|
|
117314
117710
|
return null;
|
|
117315
117711
|
}
|
|
@@ -117564,7 +117960,7 @@ async function realDir2(dir) {
|
|
|
117564
117960
|
async function workspaceDirs(workspacePath) {
|
|
117565
117961
|
const real = await realDir2(workspacePath);
|
|
117566
117962
|
if (!real) return null;
|
|
117567
|
-
const given =
|
|
117963
|
+
const given = path14.resolve(workspacePath);
|
|
117568
117964
|
return given === real ? [real] : [given, real];
|
|
117569
117965
|
}
|
|
117570
117966
|
function titleOf2(thread) {
|
|
@@ -117803,8 +118199,8 @@ async function registerCodexSessionRoutes(fastify) {
|
|
|
117803
118199
|
}
|
|
117804
118200
|
|
|
117805
118201
|
// src/session-host/flags.ts
|
|
117806
|
-
import
|
|
117807
|
-
import
|
|
118202
|
+
import fs9 from "node:fs";
|
|
118203
|
+
import path15 from "node:path";
|
|
117808
118204
|
var DEFAULT_FLAGS = {
|
|
117809
118205
|
claude: true,
|
|
117810
118206
|
codex: true,
|
|
@@ -117823,18 +118219,18 @@ function setPaneDataDir(dir) {
|
|
|
117823
118219
|
}
|
|
117824
118220
|
function sessionHostsRoot() {
|
|
117825
118221
|
const override = process.env.AGENT_PANE_SESSION_HOSTS_DIR;
|
|
117826
|
-
if (override) return
|
|
117827
|
-
return paneDataDir ?
|
|
118222
|
+
if (override) return path15.resolve(override);
|
|
118223
|
+
return paneDataDir ? path15.join(paneDataDir, "session-hosts") : null;
|
|
117828
118224
|
}
|
|
117829
118225
|
function flagsFilePath() {
|
|
117830
118226
|
const root = sessionHostsRoot();
|
|
117831
|
-
if (process.env.AGENT_PANE_SESSION_HOSTS_DIR) return
|
|
117832
|
-
return paneDataDir ?
|
|
118227
|
+
if (process.env.AGENT_PANE_SESSION_HOSTS_DIR) return path15.join(path15.dirname(root), "session-hosts.json");
|
|
118228
|
+
return paneDataDir ? path15.join(paneDataDir, "session-hosts.json") : null;
|
|
117833
118229
|
}
|
|
117834
118230
|
function readFlagFile(file2) {
|
|
117835
118231
|
if (!file2) return {};
|
|
117836
118232
|
try {
|
|
117837
|
-
const parsed = JSON.parse(
|
|
118233
|
+
const parsed = JSON.parse(fs9.readFileSync(file2, "utf8"));
|
|
117838
118234
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
|
|
117839
118235
|
console.warn(`[session-host] ${file2} is not a JSON object; using the defaults`);
|
|
117840
118236
|
} catch (err) {
|
|
@@ -117900,16 +118296,16 @@ var LOG_HEADER_LEN = LOG_HEADER_PREFIX.length + LOG_HEADER_DIGITS + 1;
|
|
|
117900
118296
|
|
|
117901
118297
|
// src/session-host/registry.ts
|
|
117902
118298
|
import { randomBytes, randomUUID as randomUUID2 } from "node:crypto";
|
|
117903
|
-
import
|
|
117904
|
-
import
|
|
118299
|
+
import fs11 from "node:fs";
|
|
118300
|
+
import path17 from "node:path";
|
|
117905
118301
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
117906
118302
|
|
|
117907
118303
|
// src/session-host/client.ts
|
|
117908
118304
|
import { execFile as execFile3, spawn as spawn4 } from "node:child_process";
|
|
117909
118305
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
117910
|
-
import
|
|
118306
|
+
import fs10 from "node:fs";
|
|
117911
118307
|
import net2 from "node:net";
|
|
117912
|
-
import
|
|
118308
|
+
import path16 from "node:path";
|
|
117913
118309
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
117914
118310
|
var HostRequestError = class extends Error {
|
|
117915
118311
|
reply;
|
|
@@ -117921,36 +118317,36 @@ var HostRequestError = class extends Error {
|
|
|
117921
118317
|
function hostScriptPath() {
|
|
117922
118318
|
const override = process.env.AGENT_PANE_SESSION_HOST_SCRIPT;
|
|
117923
118319
|
if (override) return override;
|
|
117924
|
-
const here =
|
|
118320
|
+
const here = path16.dirname(fileURLToPath3(import.meta.url));
|
|
117925
118321
|
const candidates = [
|
|
117926
|
-
|
|
118322
|
+
path16.resolve(here, "../../scripts/session-host.mjs"),
|
|
117927
118323
|
// src/session-host/ → backend/scripts
|
|
117928
|
-
|
|
118324
|
+
path16.resolve(here, "../scripts/session-host.mjs")
|
|
117929
118325
|
// dist bundle → backend/scripts
|
|
117930
118326
|
];
|
|
117931
118327
|
for (const candidate of candidates) {
|
|
117932
|
-
if (
|
|
118328
|
+
if (fs10.existsSync(candidate)) return candidate;
|
|
117933
118329
|
}
|
|
117934
118330
|
return null;
|
|
117935
118331
|
}
|
|
117936
118332
|
function hostSocketPath(dir) {
|
|
117937
|
-
const direct =
|
|
118333
|
+
const direct = path16.join(dir, "sock");
|
|
117938
118334
|
if (Buffer.byteLength(direct) < 100) return direct;
|
|
117939
118335
|
const uid = typeof process.getuid === "function" ? process.getuid() : 0;
|
|
117940
|
-
return
|
|
118336
|
+
return path16.join("/tmp", `rbsh-${uid}`, path16.basename(dir), "sock");
|
|
117941
118337
|
}
|
|
117942
118338
|
function readJson(file2) {
|
|
117943
118339
|
try {
|
|
117944
|
-
return JSON.parse(
|
|
118340
|
+
return JSON.parse(fs10.readFileSync(file2, "utf8"));
|
|
117945
118341
|
} catch {
|
|
117946
118342
|
return null;
|
|
117947
118343
|
}
|
|
117948
118344
|
}
|
|
117949
118345
|
function readHostExit(dir) {
|
|
117950
|
-
return readJson(
|
|
118346
|
+
return readJson(path16.join(dir, "exit.json"));
|
|
117951
118347
|
}
|
|
117952
118348
|
function readHostChild(dir) {
|
|
117953
|
-
return readJson(
|
|
118349
|
+
return readJson(path16.join(dir, "child.json"));
|
|
117954
118350
|
}
|
|
117955
118351
|
function isPidAlive(pid) {
|
|
117956
118352
|
if (!pid || pid <= 0) return false;
|
|
@@ -118105,8 +118501,8 @@ function attachHost(dir, after, timeoutMs = 5e3) {
|
|
|
118105
118501
|
function startHost(opts) {
|
|
118106
118502
|
const script = hostScriptPath();
|
|
118107
118503
|
if (!script) throw new Error("session host script not found");
|
|
118108
|
-
|
|
118109
|
-
|
|
118504
|
+
fs10.mkdirSync(opts.dir, { recursive: true, mode: 448 });
|
|
118505
|
+
fs10.chmodSync(opts.dir, 448);
|
|
118110
118506
|
const env = {};
|
|
118111
118507
|
for (const [k, v] of Object.entries(opts.env)) if (v !== void 0) env[k] = v;
|
|
118112
118508
|
const child = spawn4(opts.nodePath ?? process.execPath, [script, opts.dir, JSON.stringify(opts.config), opts.command, ...opts.args], {
|
|
@@ -118140,9 +118536,9 @@ async function waitForHost(dir, timeoutMs = 1e4) {
|
|
|
118140
118536
|
function readLogOldest(dir) {
|
|
118141
118537
|
let fd = null;
|
|
118142
118538
|
try {
|
|
118143
|
-
fd =
|
|
118539
|
+
fd = fs10.openSync(path16.join(dir, "out.log"), "r");
|
|
118144
118540
|
const buf = Buffer.alloc(LOG_HEADER_LEN);
|
|
118145
|
-
const n =
|
|
118541
|
+
const n = fs10.readSync(fd, buf, 0, LOG_HEADER_LEN, 0);
|
|
118146
118542
|
const text2 = buf.subarray(0, n).toString("utf8");
|
|
118147
118543
|
if (n < LOG_HEADER_LEN || !text2.startsWith(LOG_HEADER_PREFIX) || text2[LOG_HEADER_LEN - 1] !== "\n") return null;
|
|
118148
118544
|
const digits = text2.slice(LOG_HEADER_PREFIX.length, LOG_HEADER_PREFIX.length + LOG_HEADER_DIGITS);
|
|
@@ -118150,14 +118546,14 @@ function readLogOldest(dir) {
|
|
|
118150
118546
|
} catch {
|
|
118151
118547
|
return null;
|
|
118152
118548
|
} finally {
|
|
118153
|
-
if (fd !== null)
|
|
118549
|
+
if (fd !== null) fs10.closeSync(fd);
|
|
118154
118550
|
}
|
|
118155
118551
|
}
|
|
118156
118552
|
function readHostLog(dir, after) {
|
|
118157
118553
|
const oldest = readLogOldest(dir);
|
|
118158
118554
|
if (oldest === null || after < oldest) return null;
|
|
118159
118555
|
try {
|
|
118160
|
-
const all =
|
|
118556
|
+
const all = fs10.readFileSync(path16.join(dir, "out.log"));
|
|
118161
118557
|
const start = LOG_HEADER_LEN + (after - oldest);
|
|
118162
118558
|
if (start > all.length) return null;
|
|
118163
118559
|
return all.subarray(start);
|
|
@@ -118167,14 +118563,14 @@ function readHostLog(dir, after) {
|
|
|
118167
118563
|
}
|
|
118168
118564
|
function removeHostDir(dir) {
|
|
118169
118565
|
try {
|
|
118170
|
-
|
|
118566
|
+
fs10.rmSync(dir, { recursive: true, force: true });
|
|
118171
118567
|
} catch (err) {
|
|
118172
118568
|
console.error(`[session-host] could not remove ${dir}:`, err.message);
|
|
118173
118569
|
}
|
|
118174
|
-
const alias =
|
|
118570
|
+
const alias = path16.dirname(hostSocketPath(dir));
|
|
118175
118571
|
if (alias !== dir) {
|
|
118176
118572
|
try {
|
|
118177
|
-
|
|
118573
|
+
fs10.unlinkSync(alias);
|
|
118178
118574
|
} catch {
|
|
118179
118575
|
}
|
|
118180
118576
|
}
|
|
@@ -118234,16 +118630,16 @@ function newHostDir() {
|
|
|
118234
118630
|
const root = sessionHostsRoot();
|
|
118235
118631
|
if (!root) throw new Error("session hosts have no directory");
|
|
118236
118632
|
const id = randomBytes(8).toString("hex");
|
|
118237
|
-
return { id, dir:
|
|
118633
|
+
return { id, dir: path17.join(root, id) };
|
|
118238
118634
|
}
|
|
118239
118635
|
var cachedVersion;
|
|
118240
118636
|
function runtimeVersion() {
|
|
118241
118637
|
if (cachedVersion !== void 0) return cachedVersion;
|
|
118242
118638
|
cachedVersion = null;
|
|
118243
|
-
const here =
|
|
118639
|
+
const here = path17.dirname(fileURLToPath4(import.meta.url));
|
|
118244
118640
|
for (const rel of ["../../../../package.json", "../../../package.json"]) {
|
|
118245
118641
|
try {
|
|
118246
|
-
const pkg = JSON.parse(
|
|
118642
|
+
const pkg = JSON.parse(fs11.readFileSync(path17.resolve(here, rel), "utf8"));
|
|
118247
118643
|
if (pkg.name === "repoburg" && pkg.version) {
|
|
118248
118644
|
cachedVersion = pkg.version;
|
|
118249
118645
|
break;
|
|
@@ -118254,15 +118650,15 @@ function runtimeVersion() {
|
|
|
118254
118650
|
return cachedVersion;
|
|
118255
118651
|
}
|
|
118256
118652
|
function writeHostMeta(dir, meta3) {
|
|
118257
|
-
|
|
118258
|
-
|
|
118259
|
-
const tmp =
|
|
118260
|
-
|
|
118261
|
-
|
|
118653
|
+
fs11.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
118654
|
+
fs11.chmodSync(dir, 448);
|
|
118655
|
+
const tmp = path17.join(dir, "meta.json.tmp");
|
|
118656
|
+
fs11.writeFileSync(tmp, JSON.stringify(meta3, null, 2) + "\n", { mode: 384 });
|
|
118657
|
+
fs11.renameSync(tmp, path17.join(dir, "meta.json"));
|
|
118262
118658
|
}
|
|
118263
118659
|
function readHostMeta(dir) {
|
|
118264
118660
|
try {
|
|
118265
|
-
return JSON.parse(
|
|
118661
|
+
return JSON.parse(fs11.readFileSync(path17.join(dir, "meta.json"), "utf8"));
|
|
118266
118662
|
} catch {
|
|
118267
118663
|
return null;
|
|
118268
118664
|
}
|
|
@@ -118400,16 +118796,16 @@ async function runAdoption() {
|
|
|
118400
118796
|
async function adoptHosts(db2, root, adoption, result) {
|
|
118401
118797
|
let entries = [];
|
|
118402
118798
|
try {
|
|
118403
|
-
entries =
|
|
118799
|
+
entries = fs11.readdirSync(root);
|
|
118404
118800
|
} catch (err) {
|
|
118405
118801
|
if (err.code !== "ENOENT") console.error("[session-host] cannot read", root, err.message);
|
|
118406
118802
|
}
|
|
118407
118803
|
const seen = /* @__PURE__ */ new Set();
|
|
118408
118804
|
const queue = [];
|
|
118409
118805
|
for (const id of entries) {
|
|
118410
|
-
const dir =
|
|
118806
|
+
const dir = path17.join(root, id);
|
|
118411
118807
|
try {
|
|
118412
|
-
if (!
|
|
118808
|
+
if (!fs11.statSync(dir).isDirectory()) continue;
|
|
118413
118809
|
} catch {
|
|
118414
118810
|
continue;
|
|
118415
118811
|
}
|
|
@@ -118973,9 +119369,9 @@ function mapTokenUsage(data) {
|
|
|
118973
119369
|
|
|
118974
119370
|
// src/tabtape/browser-mcp.ts
|
|
118975
119371
|
import { spawn as spawn6 } from "node:child_process";
|
|
118976
|
-
import
|
|
119372
|
+
import fs12 from "node:fs";
|
|
118977
119373
|
import os6 from "node:os";
|
|
118978
|
-
import
|
|
119374
|
+
import path18 from "node:path";
|
|
118979
119375
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
118980
119376
|
var TABTAPE_MCP_NAME = "tabtape";
|
|
118981
119377
|
var PLAYWRIGHT_MCP_NAME = "playwright";
|
|
@@ -118989,15 +119385,15 @@ function disabled() {
|
|
|
118989
119385
|
function tabtapeBaseUrl() {
|
|
118990
119386
|
return (process.env.AGENT_PANE_TABTAPE_URL || `${sessionHostDaemonUrl()}/tabtape`).replace(/\/+$/, "");
|
|
118991
119387
|
}
|
|
118992
|
-
function playwrightMcpScript(from =
|
|
119388
|
+
function playwrightMcpScript(from = path18.dirname(fileURLToPath5(import.meta.url))) {
|
|
118993
119389
|
if (scriptOverride !== void 0) return scriptOverride;
|
|
118994
119390
|
let dir = from;
|
|
118995
119391
|
for (let i = 0; i < 6; i++) {
|
|
118996
|
-
const script =
|
|
118997
|
-
if (
|
|
119392
|
+
const script = path18.join(dir, "tabtape", "playwright", "mcp.mjs");
|
|
119393
|
+
if (fs12.existsSync(script) && fs12.existsSync(path18.join(dir, "tabtape", "extension", "dist", "manifest.json"))) {
|
|
118998
119394
|
return script;
|
|
118999
119395
|
}
|
|
119000
|
-
const parent =
|
|
119396
|
+
const parent = path18.dirname(dir);
|
|
119001
119397
|
if (parent === dir) break;
|
|
119002
119398
|
dir = parent;
|
|
119003
119399
|
}
|
|
@@ -119030,7 +119426,7 @@ async function browserMcp(taken) {
|
|
|
119030
119426
|
}
|
|
119031
119427
|
function jsonServerNames(file2, pick2) {
|
|
119032
119428
|
try {
|
|
119033
|
-
const json2 = JSON.parse(
|
|
119429
|
+
const json2 = JSON.parse(fs12.readFileSync(file2, "utf8"));
|
|
119034
119430
|
const servers = pick2(json2);
|
|
119035
119431
|
return servers && typeof servers === "object" ? Object.keys(servers) : [];
|
|
119036
119432
|
} catch {
|
|
@@ -119039,14 +119435,14 @@ function jsonServerNames(file2, pick2) {
|
|
|
119039
119435
|
}
|
|
119040
119436
|
function claudeConfigFile() {
|
|
119041
119437
|
if (process.env.AGENT_PANE_CLAUDE_CONFIG_FILE) return process.env.AGENT_PANE_CLAUDE_CONFIG_FILE;
|
|
119042
|
-
return
|
|
119438
|
+
return path18.join(process.env.CLAUDE_CONFIG_DIR || os6.homedir(), ".claude.json");
|
|
119043
119439
|
}
|
|
119044
119440
|
function claudeUserMcpNames(cwd) {
|
|
119045
119441
|
const file2 = claudeConfigFile();
|
|
119046
119442
|
return /* @__PURE__ */ new Set([
|
|
119047
119443
|
...jsonServerNames(file2, (json2) => json2.mcpServers),
|
|
119048
119444
|
...jsonServerNames(file2, (json2) => json2.projects?.[cwd]?.mcpServers),
|
|
119049
|
-
...jsonServerNames(
|
|
119445
|
+
...jsonServerNames(path18.join(cwd, ".mcp.json"), (json2) => json2.mcpServers)
|
|
119050
119446
|
]);
|
|
119051
119447
|
}
|
|
119052
119448
|
async function claudeBrowserMcpServers(cwd) {
|
|
@@ -119059,7 +119455,7 @@ async function claudeBrowserMcpServers(cwd) {
|
|
|
119059
119455
|
function tomlServerNames(file2) {
|
|
119060
119456
|
let text2;
|
|
119061
119457
|
try {
|
|
119062
|
-
text2 =
|
|
119458
|
+
text2 = fs12.readFileSync(file2, "utf8");
|
|
119063
119459
|
} catch {
|
|
119064
119460
|
return [];
|
|
119065
119461
|
}
|
|
@@ -119069,8 +119465,8 @@ function tomlServerNames(file2) {
|
|
|
119069
119465
|
return names;
|
|
119070
119466
|
}
|
|
119071
119467
|
function codexUserMcpNames(cwd) {
|
|
119072
|
-
const home = process.env.CODEX_HOME ||
|
|
119073
|
-
return /* @__PURE__ */ new Set([...tomlServerNames(
|
|
119468
|
+
const home = process.env.CODEX_HOME || path18.join(os6.homedir(), ".codex");
|
|
119469
|
+
return /* @__PURE__ */ new Set([...tomlServerNames(path18.join(home, "config.toml")), ...tomlServerNames(path18.join(cwd, ".codex", "config.toml"))]);
|
|
119074
119470
|
}
|
|
119075
119471
|
var CODEX_BROWSER_CHECK_INSTRUCTIONS = `Browser checks: when you check a change end-to-end in a browser, use the playwright MCP tools (a Chromium with the tabtape recorder) and record the check. Call the tabtape tool get_record_link (name: what you check, url: the first page), open its start link with browser_navigate, do the check, then open its stop link: that page shows the replay link, which you give the user. When a check fails, look into the recording with the tabtape tools before guessing. If recording does not work (the start page says "Nothing happened", or tabtape cannot be reached), carry on with the check and tell the user the recording failed.`;
|
|
119076
119472
|
async function codexBrowserMcp(cwd) {
|
|
@@ -119097,13 +119493,13 @@ async function codexBrowserMcp(cwd) {
|
|
|
119097
119493
|
}
|
|
119098
119494
|
var prepared = false;
|
|
119099
119495
|
function chromiumDownloadCommand(execPath = process.execPath) {
|
|
119100
|
-
const bin =
|
|
119101
|
-
const npx =
|
|
119102
|
-
if (!
|
|
119496
|
+
const bin = path18.dirname(execPath);
|
|
119497
|
+
const npx = path18.join(bin, process.platform === "win32" ? "npx.cmd" : "npx");
|
|
119498
|
+
if (!fs12.existsSync(npx)) return null;
|
|
119103
119499
|
return {
|
|
119104
119500
|
command: npx,
|
|
119105
119501
|
args: ["-y", "@playwright/mcp@latest", "install-browser", "chromium"],
|
|
119106
|
-
env: { ...process.env, PATH: [bin, process.env.PATH].filter(Boolean).join(
|
|
119502
|
+
env: { ...process.env, PATH: [bin, process.env.PATH].filter(Boolean).join(path18.delimiter) }
|
|
119107
119503
|
};
|
|
119108
119504
|
}
|
|
119109
119505
|
function prepareBrowserMcp() {
|
|
@@ -123104,8 +123500,8 @@ var RepoburgHttpClient = class {
|
|
|
123104
123500
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
123105
123501
|
}
|
|
123106
123502
|
/** Perform a JSON request. Throws a concise error on non-OK/non-JSON responses. */
|
|
123107
|
-
async request(method,
|
|
123108
|
-
const response = await fetch(`${this.baseUrl}${
|
|
123503
|
+
async request(method, path21, body) {
|
|
123504
|
+
const response = await fetch(`${this.baseUrl}${path21}`, {
|
|
123109
123505
|
method,
|
|
123110
123506
|
headers: { "Content-Type": "application/json" },
|
|
123111
123507
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
@@ -123114,17 +123510,17 @@ var RepoburgHttpClient = class {
|
|
|
123114
123510
|
if (!response.ok) {
|
|
123115
123511
|
if (isHtml(text2)) {
|
|
123116
123512
|
throw new Error(
|
|
123117
|
-
`${method} ${
|
|
123513
|
+
`${method} ${path21} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
123118
123514
|
);
|
|
123119
123515
|
}
|
|
123120
|
-
throw new Error(`${method} ${
|
|
123516
|
+
throw new Error(`${method} ${path21} failed: ${response.status} ${text2}`);
|
|
123121
123517
|
}
|
|
123122
123518
|
if (text2.length === 0) return void 0;
|
|
123123
123519
|
try {
|
|
123124
123520
|
return JSON.parse(text2);
|
|
123125
123521
|
} catch {
|
|
123126
123522
|
throw new Error(
|
|
123127
|
-
`${method} ${
|
|
123523
|
+
`${method} ${path21} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
123128
123524
|
);
|
|
123129
123525
|
}
|
|
123130
123526
|
}
|
|
@@ -123179,7 +123575,7 @@ var RepoburgHttpClient = class {
|
|
|
123179
123575
|
};
|
|
123180
123576
|
|
|
123181
123577
|
// src/repoburg/backend-resolver.ts
|
|
123182
|
-
import
|
|
123578
|
+
import path19 from "node:path";
|
|
123183
123579
|
var HEALTH_POLL_INTERVAL_MS = 1e3;
|
|
123184
123580
|
var HEALTH_TIMEOUT_MS = 3e4;
|
|
123185
123581
|
function daemonBaseUrl() {
|
|
@@ -123234,7 +123630,7 @@ async function backendHealthy(baseUrl, expectedPath) {
|
|
|
123234
123630
|
const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
|
|
123235
123631
|
if (health.status !== "ok") return false;
|
|
123236
123632
|
if (expectedPath && health.projectPath) {
|
|
123237
|
-
return
|
|
123633
|
+
return path19.resolve(health.projectPath) === path19.resolve(expectedPath);
|
|
123238
123634
|
}
|
|
123239
123635
|
return true;
|
|
123240
123636
|
} catch {
|
|
@@ -123255,7 +123651,7 @@ function serviceBaseUrl(service) {
|
|
|
123255
123651
|
return `http://localhost:${service.port}`;
|
|
123256
123652
|
}
|
|
123257
123653
|
function coveringService(services, absPath) {
|
|
123258
|
-
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path +
|
|
123654
|
+
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path19.sep)).sort((a, b) => b.path.length - a.path.length)[0];
|
|
123259
123655
|
}
|
|
123260
123656
|
async function restartService(daemon, name) {
|
|
123261
123657
|
try {
|
|
@@ -123291,7 +123687,7 @@ async function resolveBackendUrl(projectPath, opts = {}) {
|
|
|
123291
123687
|
if (envUrl) {
|
|
123292
123688
|
return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
|
|
123293
123689
|
}
|
|
123294
|
-
const absPath =
|
|
123690
|
+
const absPath = path19.resolve(projectPath);
|
|
123295
123691
|
const daemon = daemonBaseUrl();
|
|
123296
123692
|
const cached3 = resolvedCache.get(absPath);
|
|
123297
123693
|
if (cached3 && await backendHealthy(cached3.baseUrl, cached3.servesPath ?? absPath)) {
|
|
@@ -124972,7 +125368,7 @@ registerProvider("repoburg", repoburgProvider);
|
|
|
124972
125368
|
async function createAgentPaneApp(dbPath, opts = {}) {
|
|
124973
125369
|
const allowRequest = opts.allowRequest ?? isLocalRequest;
|
|
124974
125370
|
initDb(dbPath);
|
|
124975
|
-
setPaneDataDir(dbPath === ":memory:" ? null :
|
|
125371
|
+
setPaneDataDir(dbPath === ":memory:" ? null : path20.dirname(path20.resolve(dbPath)));
|
|
124976
125372
|
const fastify = (0, import_fastify.default)({ logger: true, bodyLimit: 50 * 1024 * 1024 });
|
|
124977
125373
|
fastify.addHook("onRequest", async (request, reply) => {
|
|
124978
125374
|
if (!allowRequest(request.headers.origin, request.headers.host)) {
|