repoburg 1.3.315 → 1.3.317
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 +832 -418
- package/agent-pane/backend/dist/server.js +834 -420
- package/agent-pane/frontend/dist/assets/{TerminalView-HheF07Iz.js → TerminalView-D3fkOngy.js} +1 -1
- package/agent-pane/frontend/dist/assets/index-Bb9z3drP.js +852 -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);
|
|
@@ -43460,9 +43460,9 @@ async function browseFolder(input, opts = {}) {
|
|
|
43460
43460
|
const atHome = dir === nodePath.resolve(home);
|
|
43461
43461
|
const folders = await Promise.all(
|
|
43462
43462
|
names.slice(0, limit).map(async (name) => {
|
|
43463
|
-
const
|
|
43463
|
+
const path21 = nodePath.join(dir, name);
|
|
43464
43464
|
const skipProbe = atHome && HOME_STANDARD_FOLDERS.has(name) || dir === "/Volumes";
|
|
43465
|
-
return { name, path:
|
|
43465
|
+
return { name, path: path21, git: !skipProbe && await exists(nodePath.join(path21, ".git")) };
|
|
43466
43466
|
})
|
|
43467
43467
|
);
|
|
43468
43468
|
const parent = nodePath.dirname(dir);
|
|
@@ -43500,11 +43500,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
43500
43500
|
}
|
|
43501
43501
|
}
|
|
43502
43502
|
}, async (request, reply) => {
|
|
43503
|
-
const { path:
|
|
43504
|
-
if (!
|
|
43503
|
+
const { path: path21, label = null } = request.body || {};
|
|
43504
|
+
if (!path21 || !path21.trim()) {
|
|
43505
43505
|
return reply.code(400).send({ error: "Path is required" });
|
|
43506
43506
|
}
|
|
43507
|
-
const resolved = await resolveWorkspacePath(
|
|
43507
|
+
const resolved = await resolveWorkspacePath(path21);
|
|
43508
43508
|
if ("error" in resolved) {
|
|
43509
43509
|
return reply.code(400).send({ error: resolved.error });
|
|
43510
43510
|
}
|
|
@@ -43546,8 +43546,8 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
43546
43546
|
"-e",
|
|
43547
43547
|
'POSIX path of (choose folder with prompt "Select a workspace directory")'
|
|
43548
43548
|
]);
|
|
43549
|
-
const
|
|
43550
|
-
return { path:
|
|
43549
|
+
const path21 = stdout.trim().replace(/\/$/, "");
|
|
43550
|
+
return { path: path21 };
|
|
43551
43551
|
} catch {
|
|
43552
43552
|
return reply.code(204).send({ cancelled: true });
|
|
43553
43553
|
}
|
|
@@ -43563,11 +43563,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
43563
43563
|
}
|
|
43564
43564
|
}
|
|
43565
43565
|
}, async (request, reply) => {
|
|
43566
|
-
const { path:
|
|
43567
|
-
if (!
|
|
43566
|
+
const { path: path21 } = request.body || {};
|
|
43567
|
+
if (!path21 || !path21.trim()) {
|
|
43568
43568
|
return reply.code(400).send({ error: "Path is required" });
|
|
43569
43569
|
}
|
|
43570
|
-
const trimmedPath =
|
|
43570
|
+
const trimmedPath = path21.trim();
|
|
43571
43571
|
const db2 = getDb();
|
|
43572
43572
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
43573
43573
|
if (existing) {
|
|
@@ -44301,17 +44301,17 @@ async function registerPerfLogRoutes(fastify) {
|
|
|
44301
44301
|
if (entries.length === 0) {
|
|
44302
44302
|
return reply.send({ written: 0 });
|
|
44303
44303
|
}
|
|
44304
|
-
const
|
|
44304
|
+
const path21 = perfLogPath();
|
|
44305
44305
|
try {
|
|
44306
|
-
mkdirSync2(dirname(
|
|
44306
|
+
mkdirSync2(dirname(path21), { recursive: true });
|
|
44307
44307
|
try {
|
|
44308
|
-
if (statSync(
|
|
44309
|
-
renameSync(
|
|
44308
|
+
if (statSync(path21).size > MAX_BYTES) {
|
|
44309
|
+
renameSync(path21, `${path21}.1`);
|
|
44310
44310
|
}
|
|
44311
44311
|
} catch {
|
|
44312
44312
|
}
|
|
44313
44313
|
const lines = entries.map((e) => `${new Date(e.t).toISOString()} [${oneLine(e.cat)}] ${oneLine(e.msg)}`).join("\n");
|
|
44314
|
-
appendFileSync(
|
|
44314
|
+
appendFileSync(path21, `${lines}
|
|
44315
44315
|
`, "utf-8");
|
|
44316
44316
|
return reply.send({ written: entries.length });
|
|
44317
44317
|
} catch (err) {
|
|
@@ -44935,8 +44935,8 @@ function proxyHandler(request, reply) {
|
|
|
44935
44935
|
}
|
|
44936
44936
|
|
|
44937
44937
|
// src/routes/apps.ts
|
|
44938
|
-
import
|
|
44939
|
-
import
|
|
44938
|
+
import fs7 from "node:fs";
|
|
44939
|
+
import path11 from "node:path";
|
|
44940
44940
|
|
|
44941
44941
|
// src/apps/instances.ts
|
|
44942
44942
|
import fs3 from "node:fs";
|
|
@@ -99592,6 +99592,21 @@ function resolveToolWorkspace(workspace) {
|
|
|
99592
99592
|
function deleteAppInstances(appId) {
|
|
99593
99593
|
getDb().prepare("DELETE FROM app_instances WHERE app_id = ?").run(appId);
|
|
99594
99594
|
}
|
|
99595
|
+
function listAppInstances(appId) {
|
|
99596
|
+
getInstanceState(appId, "");
|
|
99597
|
+
const rows = getDb().prepare("SELECT * FROM app_instances WHERE app_id = ? ORDER BY workspace_path").all(appId);
|
|
99598
|
+
return rows.map((row) => {
|
|
99599
|
+
const { pinned, data } = rowToState(row);
|
|
99600
|
+
return { workspace: row.workspace_path, pinned, data };
|
|
99601
|
+
});
|
|
99602
|
+
}
|
|
99603
|
+
function importAppInstances(appId, instances) {
|
|
99604
|
+
getDb().transaction(() => {
|
|
99605
|
+
for (const inst of instances) {
|
|
99606
|
+
writeRow(appId, inst.workspace, { pinned: inst.pinned, data: inst.data, version: inst.data ? 1 : 0 });
|
|
99607
|
+
}
|
|
99608
|
+
})();
|
|
99609
|
+
}
|
|
99595
99610
|
|
|
99596
99611
|
// src/apps/mcp-tools.ts
|
|
99597
99612
|
import fs5 from "node:fs";
|
|
@@ -99826,6 +99841,29 @@ function deleteAppFiles(appId) {
|
|
|
99826
99841
|
if (!APP_ID_RE.test(appId)) return;
|
|
99827
99842
|
fs4.rmSync(appFilesDir(appId), { recursive: true, force: true });
|
|
99828
99843
|
}
|
|
99844
|
+
function listAppFileIds(appId) {
|
|
99845
|
+
try {
|
|
99846
|
+
return fs4.readdirSync(appFilesDir(appId)).filter((name) => APP_FILE_ID_RE.test(name)).sort();
|
|
99847
|
+
} catch {
|
|
99848
|
+
return [];
|
|
99849
|
+
}
|
|
99850
|
+
}
|
|
99851
|
+
function checkImportedAppFile(fileId, bytes) {
|
|
99852
|
+
const type = sniffImageType(bytes);
|
|
99853
|
+
const expected = type ? `${crypto2.createHash("sha256").update(bytes).digest("hex")}.${APP_FILE_TYPES[type]}` : null;
|
|
99854
|
+
if (!APP_FILE_ID_RE.test(fileId) || fileId !== expected || bytes.length > APP_FILE_MAX_BYTES) {
|
|
99855
|
+
throw new AppFileError(`Stored file does not match its id: ${fileId}`, 400);
|
|
99856
|
+
}
|
|
99857
|
+
}
|
|
99858
|
+
function writeImportedAppFiles(appId, files) {
|
|
99859
|
+
if (files.size === 0) return;
|
|
99860
|
+
const dir = appFilesDir(appId);
|
|
99861
|
+
fs4.mkdirSync(dir, { recursive: true });
|
|
99862
|
+
for (const [fileId, bytes] of files) {
|
|
99863
|
+
const file2 = path7.join(dir, fileId);
|
|
99864
|
+
if (!fs4.existsSync(file2)) fs4.writeFileSync(file2, bytes);
|
|
99865
|
+
}
|
|
99866
|
+
}
|
|
99829
99867
|
|
|
99830
99868
|
// src/apps/app-sessions.ts
|
|
99831
99869
|
function text(value) {
|
|
@@ -100927,11 +100965,363 @@ function anyAppHasTools() {
|
|
|
100927
100965
|
return listAppTools().length > 0;
|
|
100928
100966
|
}
|
|
100929
100967
|
|
|
100968
|
+
// src/apps/app-zip.ts
|
|
100969
|
+
import fs6 from "node:fs";
|
|
100970
|
+
import path10 from "node:path";
|
|
100971
|
+
|
|
100972
|
+
// src/apps/zip.ts
|
|
100973
|
+
import zlib from "node:zlib";
|
|
100974
|
+
var ZipError = class extends Error {
|
|
100975
|
+
};
|
|
100976
|
+
var LOCAL_SIG = 67324752;
|
|
100977
|
+
var CENTRAL_SIG = 33639248;
|
|
100978
|
+
var EOCD_SIG = 101010256;
|
|
100979
|
+
var EOCD_MIN = 22;
|
|
100980
|
+
var FLAG_UTF8 = 2048;
|
|
100981
|
+
var FLAG_ENCRYPTED = 1;
|
|
100982
|
+
var METHOD_STORE = 0;
|
|
100983
|
+
var METHOD_DEFLATE = 8;
|
|
100984
|
+
var MADE_BY_UNIX = 3 << 8 | 20;
|
|
100985
|
+
var S_IFMT = 61440;
|
|
100986
|
+
var S_IFREG = 32768;
|
|
100987
|
+
var S_IFLNK = 40960;
|
|
100988
|
+
function dosDateTime(when) {
|
|
100989
|
+
const year = Math.max(1980, when.getFullYear());
|
|
100990
|
+
return {
|
|
100991
|
+
time: when.getHours() << 11 | when.getMinutes() << 5 | Math.floor(when.getSeconds() / 2),
|
|
100992
|
+
date: year - 1980 << 9 | when.getMonth() + 1 << 5 | when.getDate()
|
|
100993
|
+
};
|
|
100994
|
+
}
|
|
100995
|
+
function createZip(entries, when = /* @__PURE__ */ new Date()) {
|
|
100996
|
+
const { time: time3, date: date5 } = dosDateTime(when);
|
|
100997
|
+
const locals = [];
|
|
100998
|
+
const centrals = [];
|
|
100999
|
+
let offset = 0;
|
|
101000
|
+
for (const entry of entries) {
|
|
101001
|
+
const name = Buffer.from(entry.name, "utf-8");
|
|
101002
|
+
const crc = zlib.crc32(entry.data);
|
|
101003
|
+
const deflated = zlib.deflateRawSync(entry.data);
|
|
101004
|
+
const useDeflate = deflated.length < entry.data.length;
|
|
101005
|
+
const body = useDeflate ? deflated : entry.data;
|
|
101006
|
+
const method = useDeflate ? METHOD_DEFLATE : METHOD_STORE;
|
|
101007
|
+
const local = Buffer.alloc(30);
|
|
101008
|
+
local.writeUInt32LE(LOCAL_SIG, 0);
|
|
101009
|
+
local.writeUInt16LE(20, 4);
|
|
101010
|
+
local.writeUInt16LE(FLAG_UTF8, 6);
|
|
101011
|
+
local.writeUInt16LE(method, 8);
|
|
101012
|
+
local.writeUInt16LE(time3, 10);
|
|
101013
|
+
local.writeUInt16LE(date5, 12);
|
|
101014
|
+
local.writeUInt32LE(crc, 14);
|
|
101015
|
+
local.writeUInt32LE(body.length, 18);
|
|
101016
|
+
local.writeUInt32LE(entry.data.length, 22);
|
|
101017
|
+
local.writeUInt16LE(name.length, 26);
|
|
101018
|
+
local.writeUInt16LE(0, 28);
|
|
101019
|
+
locals.push(local, name, body);
|
|
101020
|
+
const central = Buffer.alloc(46);
|
|
101021
|
+
central.writeUInt32LE(CENTRAL_SIG, 0);
|
|
101022
|
+
central.writeUInt16LE(MADE_BY_UNIX, 4);
|
|
101023
|
+
central.writeUInt16LE(20, 6);
|
|
101024
|
+
central.writeUInt16LE(FLAG_UTF8, 8);
|
|
101025
|
+
central.writeUInt16LE(method, 10);
|
|
101026
|
+
central.writeUInt16LE(time3, 12);
|
|
101027
|
+
central.writeUInt16LE(date5, 14);
|
|
101028
|
+
central.writeUInt32LE(crc, 16);
|
|
101029
|
+
central.writeUInt32LE(body.length, 20);
|
|
101030
|
+
central.writeUInt32LE(entry.data.length, 24);
|
|
101031
|
+
central.writeUInt16LE(name.length, 28);
|
|
101032
|
+
central.writeUInt32LE((S_IFREG | 420) << 16 >>> 0, 38);
|
|
101033
|
+
central.writeUInt32LE(offset, 42);
|
|
101034
|
+
centrals.push(central, name);
|
|
101035
|
+
offset += local.length + name.length + body.length;
|
|
101036
|
+
}
|
|
101037
|
+
const centralDir = Buffer.concat(centrals);
|
|
101038
|
+
const eocd = Buffer.alloc(EOCD_MIN);
|
|
101039
|
+
eocd.writeUInt32LE(EOCD_SIG, 0);
|
|
101040
|
+
eocd.writeUInt16LE(entries.length, 8);
|
|
101041
|
+
eocd.writeUInt16LE(entries.length, 10);
|
|
101042
|
+
eocd.writeUInt32LE(centralDir.length, 12);
|
|
101043
|
+
eocd.writeUInt32LE(offset, 16);
|
|
101044
|
+
return Buffer.concat([...locals, centralDir, eocd]);
|
|
101045
|
+
}
|
|
101046
|
+
function readZip(buf, limits) {
|
|
101047
|
+
let eocd = -1;
|
|
101048
|
+
for (let i = buf.length - EOCD_MIN; i >= Math.max(0, buf.length - EOCD_MIN - 65535); i--) {
|
|
101049
|
+
if (buf.readUInt32LE(i) === EOCD_SIG) {
|
|
101050
|
+
eocd = i;
|
|
101051
|
+
break;
|
|
101052
|
+
}
|
|
101053
|
+
}
|
|
101054
|
+
if (eocd < 0) throw new ZipError("Not a zip file");
|
|
101055
|
+
const count2 = buf.readUInt16LE(eocd + 10);
|
|
101056
|
+
const cdSize = buf.readUInt32LE(eocd + 12);
|
|
101057
|
+
const cdOffset = buf.readUInt32LE(eocd + 16);
|
|
101058
|
+
if (count2 === 65535 || cdOffset === 4294967295) throw new ZipError("ZIP64 archives are not supported");
|
|
101059
|
+
if (cdOffset + cdSize > eocd) throw new ZipError("Corrupt zip: central directory out of range");
|
|
101060
|
+
const out = [];
|
|
101061
|
+
let total = 0;
|
|
101062
|
+
let p = cdOffset;
|
|
101063
|
+
for (let n = 0; n < count2; n++) {
|
|
101064
|
+
if (p + 46 > eocd || buf.readUInt32LE(p) !== CENTRAL_SIG) throw new ZipError("Corrupt zip: bad central directory");
|
|
101065
|
+
const flags = buf.readUInt16LE(p + 8);
|
|
101066
|
+
const method = buf.readUInt16LE(p + 10);
|
|
101067
|
+
const crc = buf.readUInt32LE(p + 16);
|
|
101068
|
+
const compSize = buf.readUInt32LE(p + 20);
|
|
101069
|
+
const size2 = buf.readUInt32LE(p + 24);
|
|
101070
|
+
const nameLen = buf.readUInt16LE(p + 28);
|
|
101071
|
+
const extraLen = buf.readUInt16LE(p + 30);
|
|
101072
|
+
const commentLen = buf.readUInt16LE(p + 32);
|
|
101073
|
+
const madeBy = buf.readUInt16LE(p + 4) >> 8;
|
|
101074
|
+
const mode = buf.readUInt32LE(p + 38) >>> 16;
|
|
101075
|
+
const localOffset = buf.readUInt32LE(p + 42);
|
|
101076
|
+
const name = buf.toString(flags & FLAG_UTF8 ? "utf-8" : "latin1", p + 46, p + 46 + nameLen);
|
|
101077
|
+
p += 46 + nameLen + extraLen + commentLen;
|
|
101078
|
+
if (name.endsWith("/")) continue;
|
|
101079
|
+
if (madeBy === 3 && (mode & S_IFMT) === S_IFLNK) continue;
|
|
101080
|
+
if (flags & FLAG_ENCRYPTED) throw new ZipError(`Encrypted entries are not supported: ${name}`);
|
|
101081
|
+
if (method !== METHOD_STORE && method !== METHOD_DEFLATE) {
|
|
101082
|
+
throw new ZipError(`Unsupported compression method ${method}: ${name}`);
|
|
101083
|
+
}
|
|
101084
|
+
if (compSize === 4294967295 || size2 === 4294967295) throw new ZipError("ZIP64 archives are not supported");
|
|
101085
|
+
if (out.length >= limits.maxEntries) throw new ZipError(`Too many files (max ${limits.maxEntries})`);
|
|
101086
|
+
if (size2 > limits.maxFileBytes) throw new ZipError(`File too large: ${name}`);
|
|
101087
|
+
total += size2;
|
|
101088
|
+
if (total > limits.maxTotalBytes) throw new ZipError("Archive too large when unpacked");
|
|
101089
|
+
if (localOffset + 30 > buf.length || buf.readUInt32LE(localOffset) !== LOCAL_SIG) {
|
|
101090
|
+
throw new ZipError(`Corrupt zip: bad local header for ${name}`);
|
|
101091
|
+
}
|
|
101092
|
+
const dataStart = localOffset + 30 + buf.readUInt16LE(localOffset + 26) + buf.readUInt16LE(localOffset + 28);
|
|
101093
|
+
if (dataStart + compSize > buf.length) throw new ZipError(`Corrupt zip: truncated ${name}`);
|
|
101094
|
+
const raw = buf.subarray(dataStart, dataStart + compSize);
|
|
101095
|
+
let data;
|
|
101096
|
+
if (method === METHOD_STORE) {
|
|
101097
|
+
data = Buffer.from(raw);
|
|
101098
|
+
} else {
|
|
101099
|
+
try {
|
|
101100
|
+
data = zlib.inflateRawSync(raw, { maxOutputLength: Math.max(1, size2) });
|
|
101101
|
+
} catch {
|
|
101102
|
+
throw new ZipError(`Corrupt zip: cannot inflate ${name}`);
|
|
101103
|
+
}
|
|
101104
|
+
}
|
|
101105
|
+
if (data.length !== size2 || zlib.crc32(data) !== crc) throw new ZipError(`Corrupt zip: checksum mismatch in ${name}`);
|
|
101106
|
+
out.push({ name, data });
|
|
101107
|
+
}
|
|
101108
|
+
return out;
|
|
101109
|
+
}
|
|
101110
|
+
|
|
101111
|
+
// src/apps/app-zip.ts
|
|
101112
|
+
var APP_ZIP_MAX_BYTES = 50 * 1024 * 1024;
|
|
101113
|
+
var APP_DATA_DIR = ".agentpane-data";
|
|
101114
|
+
var DATA_FORMAT = 1;
|
|
101115
|
+
var MAX_INSTANCES2 = 1e3;
|
|
101116
|
+
var IMPORT_LIMITS = {
|
|
101117
|
+
maxEntries: 5e3,
|
|
101118
|
+
maxFileBytes: 20 * 1024 * 1024,
|
|
101119
|
+
maxTotalBytes: 100 * 1024 * 1024
|
|
101120
|
+
};
|
|
101121
|
+
var AppZipError = class extends Error {
|
|
101122
|
+
constructor(message, status) {
|
|
101123
|
+
super(message);
|
|
101124
|
+
this.status = status;
|
|
101125
|
+
}
|
|
101126
|
+
};
|
|
101127
|
+
function isSkipped(segment) {
|
|
101128
|
+
return segment.startsWith(".") || segment === "node_modules" || segment === "__MACOSX";
|
|
101129
|
+
}
|
|
101130
|
+
function isSafeSegment(segment) {
|
|
101131
|
+
return segment.length > 0 && segment.length <= 255 && !/[\\/:*?"<>|]/.test(segment) && ![...segment].some((ch) => ch.charCodeAt(0) < 32);
|
|
101132
|
+
}
|
|
101133
|
+
function collectAppFiles(id) {
|
|
101134
|
+
const root = appDir(id);
|
|
101135
|
+
const out = [];
|
|
101136
|
+
const walk = (dir, rel) => {
|
|
101137
|
+
const entries = fs6.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
101138
|
+
for (const entry of entries) {
|
|
101139
|
+
if (isSkipped(entry.name)) continue;
|
|
101140
|
+
const relPath = rel ? `${rel}/${entry.name}` : entry.name;
|
|
101141
|
+
if (!rel && entry.name === "state.json") continue;
|
|
101142
|
+
const full = path10.join(dir, entry.name);
|
|
101143
|
+
if (entry.isDirectory()) walk(full, relPath);
|
|
101144
|
+
else if (entry.isFile()) out.push({ name: `${id}/${relPath}`, data: fs6.readFileSync(full) });
|
|
101145
|
+
}
|
|
101146
|
+
};
|
|
101147
|
+
walk(root, "");
|
|
101148
|
+
return out;
|
|
101149
|
+
}
|
|
101150
|
+
function collectAppData(id) {
|
|
101151
|
+
const dataJson = { format: DATA_FORMAT, app: id, filesDir: appFilesDir(id), instances: listAppInstances(id) };
|
|
101152
|
+
const out = [
|
|
101153
|
+
{ name: `${id}/${APP_DATA_DIR}/data.json`, data: Buffer.from(JSON.stringify(dataJson, null, 2)) }
|
|
101154
|
+
];
|
|
101155
|
+
for (const fileId of listAppFileIds(id)) {
|
|
101156
|
+
out.push({
|
|
101157
|
+
name: `${id}/${APP_DATA_DIR}/files/${fileId}`,
|
|
101158
|
+
data: fs6.readFileSync(path10.join(appFilesDir(id), fileId))
|
|
101159
|
+
});
|
|
101160
|
+
}
|
|
101161
|
+
return out;
|
|
101162
|
+
}
|
|
101163
|
+
function exportAppZip(id, opts = {}) {
|
|
101164
|
+
if (!readManifest(id)) throw new AppZipError("App not found", 404);
|
|
101165
|
+
return createZip([...collectAppFiles(id), ...opts.data ? collectAppData(id) : []]);
|
|
101166
|
+
}
|
|
101167
|
+
function parseAppData(entries) {
|
|
101168
|
+
const raw = entries.get("data.json");
|
|
101169
|
+
if (!raw) throw new AppZipError(`${APP_DATA_DIR}/data.json is missing`, 400);
|
|
101170
|
+
let parsed;
|
|
101171
|
+
try {
|
|
101172
|
+
parsed = JSON.parse(raw.toString("utf-8"));
|
|
101173
|
+
} catch {
|
|
101174
|
+
throw new AppZipError(`${APP_DATA_DIR}/data.json is not valid JSON`, 400);
|
|
101175
|
+
}
|
|
101176
|
+
const doc = parsed;
|
|
101177
|
+
if (!doc || typeof doc !== "object" || doc.format !== DATA_FORMAT || !Array.isArray(doc.instances)) {
|
|
101178
|
+
throw new AppZipError(`${APP_DATA_DIR}/data.json has an unknown format`, 400);
|
|
101179
|
+
}
|
|
101180
|
+
if (doc.instances.length > MAX_INSTANCES2) throw new AppZipError(`Too many instances (max ${MAX_INSTANCES2})`, 400);
|
|
101181
|
+
const seen = /* @__PURE__ */ new Set();
|
|
101182
|
+
const instances = doc.instances.map((item) => {
|
|
101183
|
+
const inst = item;
|
|
101184
|
+
const workspace = inst && typeof inst.workspace === "string" ? inst.workspace : null;
|
|
101185
|
+
const valid = workspace !== null && (workspace === "" || path10.isAbsolute(workspace)) && !seen.has(workspace) && (inst.data === null || typeof inst.data === "object" && !Array.isArray(inst.data));
|
|
101186
|
+
if (!valid) throw new AppZipError(`${APP_DATA_DIR}/data.json has an invalid instance`, 400);
|
|
101187
|
+
seen.add(workspace);
|
|
101188
|
+
return { workspace, pinned: inst.pinned === true, data: inst.data };
|
|
101189
|
+
});
|
|
101190
|
+
const files = /* @__PURE__ */ new Map();
|
|
101191
|
+
for (const [rel, bytes] of entries) {
|
|
101192
|
+
if (rel === "data.json") continue;
|
|
101193
|
+
const fileId = rel.startsWith("files/") ? rel.slice("files/".length) : rel;
|
|
101194
|
+
try {
|
|
101195
|
+
checkImportedAppFile(fileId, bytes);
|
|
101196
|
+
} catch (err) {
|
|
101197
|
+
if (err instanceof AppFileError) throw new AppZipError(`${APP_DATA_DIR}/${rel}: ${err.message}`, 400);
|
|
101198
|
+
throw err;
|
|
101199
|
+
}
|
|
101200
|
+
files.set(fileId, bytes);
|
|
101201
|
+
}
|
|
101202
|
+
return {
|
|
101203
|
+
app: typeof doc.app === "string" ? doc.app : "",
|
|
101204
|
+
filesDir: typeof doc.filesDir === "string" && doc.filesDir ? doc.filesDir : null,
|
|
101205
|
+
instances,
|
|
101206
|
+
files
|
|
101207
|
+
};
|
|
101208
|
+
}
|
|
101209
|
+
function readAppZip(buf) {
|
|
101210
|
+
let entries;
|
|
101211
|
+
try {
|
|
101212
|
+
entries = readZip(buf, IMPORT_LIMITS);
|
|
101213
|
+
} catch (err) {
|
|
101214
|
+
if (err instanceof ZipError) throw new AppZipError(err.message, 400);
|
|
101215
|
+
throw err;
|
|
101216
|
+
}
|
|
101217
|
+
const paths = [];
|
|
101218
|
+
const bytesOf = /* @__PURE__ */ new Map();
|
|
101219
|
+
for (const entry of entries) {
|
|
101220
|
+
const segments = entry.name.replace(/\\/g, "/").split("/");
|
|
101221
|
+
if (!segments.every(isSafeSegment) || segments.some((s) => s === "." || s === "..")) {
|
|
101222
|
+
throw new AppZipError(`Invalid file path in archive: ${entry.name}`, 400);
|
|
101223
|
+
}
|
|
101224
|
+
const dataAt = segments.indexOf(APP_DATA_DIR);
|
|
101225
|
+
const junk = segments.some((s, i) => isSkipped(s) && i !== dataAt) || dataAt > 1;
|
|
101226
|
+
if (junk) continue;
|
|
101227
|
+
paths.push(segments);
|
|
101228
|
+
bytesOf.set(segments, entry.data);
|
|
101229
|
+
}
|
|
101230
|
+
const first = paths[0]?.[0];
|
|
101231
|
+
const nested = paths.length > 0 && paths.every((p) => p.length > 1 && p[0] === first && p[0] !== APP_DATA_DIR);
|
|
101232
|
+
const files = /* @__PURE__ */ new Map();
|
|
101233
|
+
const dataEntries = /* @__PURE__ */ new Map();
|
|
101234
|
+
for (const p of paths) {
|
|
101235
|
+
const segs = nested ? p.slice(1) : p;
|
|
101236
|
+
const bytes = bytesOf.get(p);
|
|
101237
|
+
if (segs[0] === APP_DATA_DIR) {
|
|
101238
|
+
dataEntries.set(segs.slice(1).join("/"), bytes);
|
|
101239
|
+
continue;
|
|
101240
|
+
}
|
|
101241
|
+
if (segs.some(isSkipped)) continue;
|
|
101242
|
+
const rel = segs.join("/");
|
|
101243
|
+
if (files.has(rel)) throw new AppZipError(`Duplicate file in archive: ${rel}`, 400);
|
|
101244
|
+
files.set(rel, bytes);
|
|
101245
|
+
}
|
|
101246
|
+
if (files.size === 0) throw new AppZipError("The archive holds no app files", 400);
|
|
101247
|
+
for (const rel of files.keys()) {
|
|
101248
|
+
const parts = rel.split("/");
|
|
101249
|
+
for (let i = 1; i < parts.length; i++) {
|
|
101250
|
+
if (files.has(parts.slice(0, i).join("/"))) throw new AppZipError(`Conflicting paths in archive: ${rel}`, 400);
|
|
101251
|
+
}
|
|
101252
|
+
}
|
|
101253
|
+
return {
|
|
101254
|
+
files,
|
|
101255
|
+
folder: nested ? first : null,
|
|
101256
|
+
data: dataEntries.size > 0 ? parseAppData(dataEntries) : null
|
|
101257
|
+
};
|
|
101258
|
+
}
|
|
101259
|
+
function mapStrings(value, replace) {
|
|
101260
|
+
if (typeof value === "string") return replace(value);
|
|
101261
|
+
if (Array.isArray(value)) return value.map((v) => mapStrings(v, replace));
|
|
101262
|
+
if (value && typeof value === "object") {
|
|
101263
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, mapStrings(v, replace)]));
|
|
101264
|
+
}
|
|
101265
|
+
return value;
|
|
101266
|
+
}
|
|
101267
|
+
function rehomeInstances(data, id) {
|
|
101268
|
+
const swaps = [];
|
|
101269
|
+
const newUrl = `/api/apps/${id}/files/`;
|
|
101270
|
+
if (data.app && data.app !== id) swaps.push([`/api/apps/${data.app}/files/`, newUrl]);
|
|
101271
|
+
const newDir = appFilesDir(id);
|
|
101272
|
+
const oldDir = data.filesDir?.replace(/[\\/]+$/, "");
|
|
101273
|
+
if (oldDir && oldDir !== newDir) {
|
|
101274
|
+
swaps.push([`${oldDir}/`, `${newDir}${path10.sep}`], [`${oldDir}\\`, `${newDir}${path10.sep}`]);
|
|
101275
|
+
}
|
|
101276
|
+
if (swaps.length === 0) return data.instances;
|
|
101277
|
+
const replace = (s) => swaps.reduce((out, [from, to]) => out.split(from).join(to), s);
|
|
101278
|
+
return data.instances.map((inst) => ({
|
|
101279
|
+
...inst,
|
|
101280
|
+
data: inst.data ? mapStrings(inst.data, replace) : null
|
|
101281
|
+
}));
|
|
101282
|
+
}
|
|
101283
|
+
function importAppZip(id, buf, opts = {}) {
|
|
101284
|
+
const { files, data } = readAppZip(buf);
|
|
101285
|
+
if (readManifest(id) || fs6.existsSync(appDir(id))) throw new AppZipError("App already exists", 409);
|
|
101286
|
+
const withData = opts.data ? data : null;
|
|
101287
|
+
ensureAppsRoot();
|
|
101288
|
+
const tmp = path10.join(appsRoot(), `.import-${v4_default()}`);
|
|
101289
|
+
try {
|
|
101290
|
+
for (const [rel, bytes] of files) {
|
|
101291
|
+
const file2 = path10.join(tmp, ...rel.split("/"));
|
|
101292
|
+
fs6.mkdirSync(path10.dirname(file2), { recursive: true });
|
|
101293
|
+
fs6.writeFileSync(file2, bytes);
|
|
101294
|
+
}
|
|
101295
|
+
if (!files.has("manifest.json")) {
|
|
101296
|
+
fs6.writeFileSync(path10.join(tmp, "manifest.json"), JSON.stringify({ title: id }, null, 2));
|
|
101297
|
+
} else if (!readManifestIn(tmp)) {
|
|
101298
|
+
throw new AppZipError('manifest.json is invalid (it needs at least a "title" string)', 400);
|
|
101299
|
+
}
|
|
101300
|
+
if (fs6.existsSync(appDir(id))) throw new AppZipError("App already exists", 409);
|
|
101301
|
+
fs6.renameSync(tmp, appDir(id));
|
|
101302
|
+
} finally {
|
|
101303
|
+
fs6.rmSync(tmp, { recursive: true, force: true });
|
|
101304
|
+
}
|
|
101305
|
+
if (!withData) return { id, data: null };
|
|
101306
|
+
try {
|
|
101307
|
+
deleteAppFiles(id);
|
|
101308
|
+
deleteAppInstances(id);
|
|
101309
|
+
writeImportedAppFiles(id, withData.files);
|
|
101310
|
+
importAppInstances(id, rehomeInstances(withData, id));
|
|
101311
|
+
} catch (err) {
|
|
101312
|
+
fs6.rmSync(appDir(id), { recursive: true, force: true });
|
|
101313
|
+
deleteAppFiles(id);
|
|
101314
|
+
deleteAppInstances(id);
|
|
101315
|
+
throw err;
|
|
101316
|
+
}
|
|
101317
|
+
return { id, data: { instances: withData.instances.length, files: withData.files.size } };
|
|
101318
|
+
}
|
|
101319
|
+
|
|
100930
101320
|
// src/routes/apps.ts
|
|
100931
101321
|
var FILE_UPLOAD_BODY_LIMIT = Math.ceil(APP_FILE_MAX_BYTES * 4 / 3) + 64 * 1024;
|
|
100932
|
-
|
|
100933
|
-
|
|
100934
|
-
|
|
101322
|
+
function isTrueFlag(value) {
|
|
101323
|
+
return value === "1" || value === "true";
|
|
101324
|
+
}
|
|
100935
101325
|
var SKELETON_HTML = `<!DOCTYPE html>
|
|
100936
101326
|
<html>
|
|
100937
101327
|
<head>
|
|
@@ -100983,7 +101373,7 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
100983
101373
|
fastify.get("/api/apps", async () => {
|
|
100984
101374
|
try {
|
|
100985
101375
|
ensureAppsRoot();
|
|
100986
|
-
const entries =
|
|
101376
|
+
const entries = fs7.readdirSync(appsRoot(), { withFileTypes: true });
|
|
100987
101377
|
const apps = [];
|
|
100988
101378
|
for (const entry of entries) {
|
|
100989
101379
|
if (!entry.isDirectory() || !APP_ID_RE.test(entry.name)) continue;
|
|
@@ -101013,9 +101403,9 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101013
101403
|
if (!exRoot) return [];
|
|
101014
101404
|
const out = [];
|
|
101015
101405
|
try {
|
|
101016
|
-
for (const entry of
|
|
101406
|
+
for (const entry of fs7.readdirSync(exRoot, { withFileTypes: true })) {
|
|
101017
101407
|
if (!entry.isDirectory() || !APP_ID_RE.test(entry.name)) continue;
|
|
101018
|
-
const manifest = readManifestIn(
|
|
101408
|
+
const manifest = readManifestIn(path11.join(exRoot, entry.name));
|
|
101019
101409
|
if (!manifest) continue;
|
|
101020
101410
|
out.push({
|
|
101021
101411
|
id: entry.name,
|
|
@@ -101036,11 +101426,11 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101036
101426
|
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
101037
101427
|
const exRoot = examplesRoot();
|
|
101038
101428
|
if (!exRoot) return reply.code(404).send({ error: "Examples catalog not available" });
|
|
101039
|
-
const src =
|
|
101429
|
+
const src = path11.join(exRoot, id);
|
|
101040
101430
|
if (!readManifestIn(src)) return reply.code(404).send({ error: "Example not found" });
|
|
101041
101431
|
if (readManifest(id)) return reply.code(409).send({ error: "App already installed" });
|
|
101042
101432
|
ensureAppsRoot();
|
|
101043
|
-
|
|
101433
|
+
fs7.cpSync(src, appDir(id), { recursive: true });
|
|
101044
101434
|
return { ok: true, id };
|
|
101045
101435
|
});
|
|
101046
101436
|
fastify.post(
|
|
@@ -101072,10 +101462,10 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101072
101462
|
if (readManifest(id)) return reply.code(409).send({ error: "App already exists" });
|
|
101073
101463
|
ensureAppsRoot();
|
|
101074
101464
|
const dir = appDir(id);
|
|
101075
|
-
|
|
101465
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
101076
101466
|
const cleanTitle2 = title.trim();
|
|
101077
|
-
|
|
101078
|
-
|
|
101467
|
+
fs7.writeFileSync(
|
|
101468
|
+
path11.join(dir, "manifest.json"),
|
|
101079
101469
|
JSON.stringify(
|
|
101080
101470
|
{
|
|
101081
101471
|
title: cleanTitle2,
|
|
@@ -101086,48 +101476,54 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101086
101476
|
2
|
|
101087
101477
|
)
|
|
101088
101478
|
);
|
|
101089
|
-
|
|
101090
|
-
|
|
101479
|
+
fs7.writeFileSync(path11.join(dir, "index.html"), SKELETON_HTML.replaceAll("__TITLE__", cleanTitle2));
|
|
101480
|
+
fs7.writeFileSync(path11.join(dir, "app.ts"), SKELETON_TS);
|
|
101091
101481
|
return { ok: true, id };
|
|
101092
101482
|
}
|
|
101093
101483
|
);
|
|
101094
|
-
fastify.
|
|
101095
|
-
|
|
101096
|
-
|
|
101097
|
-
|
|
101098
|
-
|
|
101099
|
-
|
|
101100
|
-
|
|
101101
|
-
|
|
101102
|
-
|
|
101103
|
-
|
|
101104
|
-
|
|
101484
|
+
await fastify.register(async (scope) => {
|
|
101485
|
+
scope.addContentTypeParser(
|
|
101486
|
+
["application/zip", "application/x-zip-compressed", "application/octet-stream"],
|
|
101487
|
+
{ parseAs: "buffer", bodyLimit: APP_ZIP_MAX_BYTES },
|
|
101488
|
+
(_req, body, done) => done(null, body)
|
|
101489
|
+
);
|
|
101490
|
+
scope.post(
|
|
101491
|
+
"/api/apps/import",
|
|
101492
|
+
{
|
|
101493
|
+
bodyLimit: APP_ZIP_MAX_BYTES,
|
|
101494
|
+
schema: {
|
|
101495
|
+
querystring: { type: "object", properties: { id: { type: "string" }, data: { type: "string" } } }
|
|
101105
101496
|
}
|
|
101106
|
-
}
|
|
101107
|
-
|
|
101108
|
-
|
|
101109
|
-
|
|
101110
|
-
|
|
101111
|
-
|
|
101112
|
-
|
|
101113
|
-
|
|
101114
|
-
|
|
101115
|
-
|
|
101116
|
-
|
|
101117
|
-
|
|
101118
|
-
|
|
101119
|
-
return reply.code(400).send({ error: `File too large: ${name}` });
|
|
101497
|
+
},
|
|
101498
|
+
async (request, reply) => {
|
|
101499
|
+
if (!Buffer.isBuffer(request.body) || request.body.length === 0) {
|
|
101500
|
+
return reply.code(400).send({ error: "Upload a .zip file (Content-Type: application/zip)" });
|
|
101501
|
+
}
|
|
101502
|
+
try {
|
|
101503
|
+
const id = request.query.id?.trim() || readAppZip(request.body).folder || "";
|
|
101504
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
101505
|
+
const result = importAppZip(id, request.body, { data: isTrueFlag(request.query.data) });
|
|
101506
|
+
return { ok: true, ...result };
|
|
101507
|
+
} catch (err) {
|
|
101508
|
+
if (err instanceof AppZipError) return reply.code(err.status).send({ error: err.message });
|
|
101509
|
+
throw err;
|
|
101120
101510
|
}
|
|
101121
101511
|
}
|
|
101122
|
-
|
|
101123
|
-
|
|
101124
|
-
|
|
101125
|
-
|
|
101126
|
-
|
|
101127
|
-
|
|
101512
|
+
);
|
|
101513
|
+
});
|
|
101514
|
+
fastify.get(
|
|
101515
|
+
"/api/apps/:id/export",
|
|
101516
|
+
{ schema: { querystring: { type: "object", properties: { data: { type: "string" } } } } },
|
|
101517
|
+
async (request, reply) => {
|
|
101518
|
+
const { id } = request.params;
|
|
101519
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
101520
|
+
try {
|
|
101521
|
+
const zip = exportAppZip(id, { data: isTrueFlag(request.query.data) });
|
|
101522
|
+
return reply.header("Content-Type", "application/zip").header("Content-Disposition", `attachment; filename="${id}.zip"`).header("Cache-Control", "no-store").send(zip);
|
|
101523
|
+
} catch (err) {
|
|
101524
|
+
if (err instanceof AppZipError) return reply.code(err.status).send({ error: err.message });
|
|
101525
|
+
throw err;
|
|
101128
101526
|
}
|
|
101129
|
-
for (const [name, content] of entries) fs6.writeFileSync(path10.join(dir, name), content);
|
|
101130
|
-
return { ok: true, id };
|
|
101131
101527
|
}
|
|
101132
101528
|
);
|
|
101133
101529
|
fastify.post(
|
|
@@ -101291,7 +101687,7 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101291
101687
|
const { id } = request.params;
|
|
101292
101688
|
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
101293
101689
|
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
101294
|
-
|
|
101690
|
+
fs7.rmSync(appDir(id), { recursive: true, force: true });
|
|
101295
101691
|
deleteAppFiles(id);
|
|
101296
101692
|
deleteAppInstances(id);
|
|
101297
101693
|
invalidateHeadlessRuntime(id);
|
|
@@ -102058,7 +102454,7 @@ async function registerUsageRoutes(fastify) {
|
|
|
102058
102454
|
|
|
102059
102455
|
// src/claude/session-import.ts
|
|
102060
102456
|
import { readFile as readFile2, realpath } from "node:fs/promises";
|
|
102061
|
-
import
|
|
102457
|
+
import path12 from "node:path";
|
|
102062
102458
|
import { getSessionInfo, listSessions } from "@anthropic-ai/claude-agent-sdk";
|
|
102063
102459
|
|
|
102064
102460
|
// src/claude/widget-tool.ts
|
|
@@ -102830,10 +103226,10 @@ function mergeDefs(...defs) {
|
|
|
102830
103226
|
function cloneDef(schema) {
|
|
102831
103227
|
return mergeDefs(schema._zod.def);
|
|
102832
103228
|
}
|
|
102833
|
-
function getElementAtPath(obj2,
|
|
102834
|
-
if (!
|
|
103229
|
+
function getElementAtPath(obj2, path21) {
|
|
103230
|
+
if (!path21)
|
|
102835
103231
|
return obj2;
|
|
102836
|
-
return
|
|
103232
|
+
return path21.reduce((acc, key) => acc?.[key], obj2);
|
|
102837
103233
|
}
|
|
102838
103234
|
function promiseAllObject(promisesObj) {
|
|
102839
103235
|
const keys = Object.keys(promisesObj);
|
|
@@ -103242,11 +103638,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
103242
103638
|
}
|
|
103243
103639
|
return false;
|
|
103244
103640
|
}
|
|
103245
|
-
function prefixIssues(
|
|
103641
|
+
function prefixIssues(path21, issues) {
|
|
103246
103642
|
return issues.map((iss) => {
|
|
103247
103643
|
var _a3;
|
|
103248
103644
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
103249
|
-
iss.path.unshift(
|
|
103645
|
+
iss.path.unshift(path21);
|
|
103250
103646
|
return iss;
|
|
103251
103647
|
});
|
|
103252
103648
|
}
|
|
@@ -103393,16 +103789,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
103393
103789
|
}
|
|
103394
103790
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
103395
103791
|
const fieldErrors = { _errors: [] };
|
|
103396
|
-
const processError = (error52,
|
|
103792
|
+
const processError = (error52, path21 = []) => {
|
|
103397
103793
|
for (const issue2 of error52.issues) {
|
|
103398
103794
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
103399
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
103795
|
+
issue2.errors.map((issues) => processError({ issues }, [...path21, ...issue2.path]));
|
|
103400
103796
|
} else if (issue2.code === "invalid_key") {
|
|
103401
|
-
processError({ issues: issue2.issues }, [...
|
|
103797
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
103402
103798
|
} else if (issue2.code === "invalid_element") {
|
|
103403
|
-
processError({ issues: issue2.issues }, [...
|
|
103799
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
103404
103800
|
} else {
|
|
103405
|
-
const fullpath = [...
|
|
103801
|
+
const fullpath = [...path21, ...issue2.path];
|
|
103406
103802
|
if (fullpath.length === 0) {
|
|
103407
103803
|
fieldErrors._errors.push(mapper(issue2));
|
|
103408
103804
|
} else {
|
|
@@ -103429,17 +103825,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
103429
103825
|
}
|
|
103430
103826
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
103431
103827
|
const result = { errors: [] };
|
|
103432
|
-
const processError = (error52,
|
|
103828
|
+
const processError = (error52, path21 = []) => {
|
|
103433
103829
|
var _a3, _b;
|
|
103434
103830
|
for (const issue2 of error52.issues) {
|
|
103435
103831
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
103436
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
103832
|
+
issue2.errors.map((issues) => processError({ issues }, [...path21, ...issue2.path]));
|
|
103437
103833
|
} else if (issue2.code === "invalid_key") {
|
|
103438
|
-
processError({ issues: issue2.issues }, [...
|
|
103834
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
103439
103835
|
} else if (issue2.code === "invalid_element") {
|
|
103440
|
-
processError({ issues: issue2.issues }, [...
|
|
103836
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
103441
103837
|
} else {
|
|
103442
|
-
const fullpath = [...
|
|
103838
|
+
const fullpath = [...path21, ...issue2.path];
|
|
103443
103839
|
if (fullpath.length === 0) {
|
|
103444
103840
|
result.errors.push(mapper(issue2));
|
|
103445
103841
|
continue;
|
|
@@ -103471,8 +103867,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
103471
103867
|
}
|
|
103472
103868
|
function toDotPath(_path) {
|
|
103473
103869
|
const segs = [];
|
|
103474
|
-
const
|
|
103475
|
-
for (const seg of
|
|
103870
|
+
const path21 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
103871
|
+
for (const seg of path21) {
|
|
103476
103872
|
if (typeof seg === "number")
|
|
103477
103873
|
segs.push(`[${seg}]`);
|
|
103478
103874
|
else if (typeof seg === "symbol")
|
|
@@ -116164,13 +116560,13 @@ function resolveRef(ref, ctx) {
|
|
|
116164
116560
|
if (!ref.startsWith("#")) {
|
|
116165
116561
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
116166
116562
|
}
|
|
116167
|
-
const
|
|
116168
|
-
if (
|
|
116563
|
+
const path21 = ref.slice(1).split("/").filter(Boolean);
|
|
116564
|
+
if (path21.length === 0) {
|
|
116169
116565
|
return ctx.rootSchema;
|
|
116170
116566
|
}
|
|
116171
116567
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
116172
|
-
if (
|
|
116173
|
-
const key =
|
|
116568
|
+
if (path21[0] === defsKey) {
|
|
116569
|
+
const key = path21[1];
|
|
116174
116570
|
if (!key || !ctx.defs[key]) {
|
|
116175
116571
|
throw new Error(`Reference not found: ${ref}`);
|
|
116176
116572
|
}
|
|
@@ -116695,9 +117091,9 @@ function mapToolUse(block) {
|
|
|
116695
117091
|
};
|
|
116696
117092
|
}
|
|
116697
117093
|
function deriveFileChangeData(input, toolName) {
|
|
116698
|
-
const
|
|
117094
|
+
const path21 = input.file_path ?? input.notebook_path ?? "";
|
|
116699
117095
|
const kind = toolName === "Write" ? "add" : "modify";
|
|
116700
|
-
return { changes: [{ path:
|
|
117096
|
+
return { changes: [{ path: path21, kind }], status: "in_progress" };
|
|
116701
117097
|
}
|
|
116702
117098
|
function extractToolResultText(content) {
|
|
116703
117099
|
if (!content) return "";
|
|
@@ -117103,7 +117499,7 @@ async function realDir(dir) {
|
|
|
117103
117499
|
}
|
|
117104
117500
|
}
|
|
117105
117501
|
async function sameDir(a, realB) {
|
|
117106
|
-
const realA = await realDir(a) ??
|
|
117502
|
+
const realA = await realDir(a) ?? path12.resolve(a);
|
|
117107
117503
|
return realA === realB;
|
|
117108
117504
|
}
|
|
117109
117505
|
function knownClaudeSessionIds(db2) {
|
|
@@ -117273,26 +117669,26 @@ async function registerClaudeSessionRoutes(fastify) {
|
|
|
117273
117669
|
|
|
117274
117670
|
// src/codex/session-import.ts
|
|
117275
117671
|
import { realpath as realpath2 } from "node:fs/promises";
|
|
117276
|
-
import
|
|
117672
|
+
import path14 from "node:path";
|
|
117277
117673
|
|
|
117278
117674
|
// src/apps/register-mcp.ts
|
|
117279
|
-
import
|
|
117280
|
-
import
|
|
117675
|
+
import fs8 from "node:fs";
|
|
117676
|
+
import path13 from "node:path";
|
|
117281
117677
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
117282
117678
|
var MCP_SERVER_NAME = "agentpane-miniapps";
|
|
117283
117679
|
function panePublicUrl() {
|
|
117284
117680
|
return (process.env.AGENT_PANE_PUBLIC_URL || process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
|
|
117285
117681
|
}
|
|
117286
117682
|
function stdioScriptPath() {
|
|
117287
|
-
const here =
|
|
117683
|
+
const here = path13.dirname(fileURLToPath2(import.meta.url));
|
|
117288
117684
|
const candidates = [
|
|
117289
|
-
|
|
117685
|
+
path13.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
|
|
117290
117686
|
// src/apps/ → backend/scripts
|
|
117291
|
-
|
|
117687
|
+
path13.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
|
|
117292
117688
|
// dist bundle → backend/scripts
|
|
117293
117689
|
];
|
|
117294
117690
|
for (const candidate of candidates) {
|
|
117295
|
-
if (
|
|
117691
|
+
if (fs8.existsSync(candidate)) return candidate;
|
|
117296
117692
|
}
|
|
117297
117693
|
return null;
|
|
117298
117694
|
}
|
|
@@ -117547,7 +117943,7 @@ async function realDir2(dir) {
|
|
|
117547
117943
|
async function workspaceDirs(workspacePath) {
|
|
117548
117944
|
const real = await realDir2(workspacePath);
|
|
117549
117945
|
if (!real) return null;
|
|
117550
|
-
const given =
|
|
117946
|
+
const given = path14.resolve(workspacePath);
|
|
117551
117947
|
return given === real ? [real] : [given, real];
|
|
117552
117948
|
}
|
|
117553
117949
|
function titleOf2(thread) {
|
|
@@ -117786,8 +118182,8 @@ async function registerCodexSessionRoutes(fastify) {
|
|
|
117786
118182
|
}
|
|
117787
118183
|
|
|
117788
118184
|
// src/session-host/flags.ts
|
|
117789
|
-
import
|
|
117790
|
-
import
|
|
118185
|
+
import fs9 from "node:fs";
|
|
118186
|
+
import path15 from "node:path";
|
|
117791
118187
|
var DEFAULT_FLAGS = {
|
|
117792
118188
|
claude: true,
|
|
117793
118189
|
codex: true,
|
|
@@ -117806,18 +118202,18 @@ function setPaneDataDir(dir) {
|
|
|
117806
118202
|
}
|
|
117807
118203
|
function sessionHostsRoot() {
|
|
117808
118204
|
const override = process.env.AGENT_PANE_SESSION_HOSTS_DIR;
|
|
117809
|
-
if (override) return
|
|
117810
|
-
return paneDataDir ?
|
|
118205
|
+
if (override) return path15.resolve(override);
|
|
118206
|
+
return paneDataDir ? path15.join(paneDataDir, "session-hosts") : null;
|
|
117811
118207
|
}
|
|
117812
118208
|
function flagsFilePath() {
|
|
117813
118209
|
const root = sessionHostsRoot();
|
|
117814
|
-
if (process.env.AGENT_PANE_SESSION_HOSTS_DIR) return
|
|
117815
|
-
return paneDataDir ?
|
|
118210
|
+
if (process.env.AGENT_PANE_SESSION_HOSTS_DIR) return path15.join(path15.dirname(root), "session-hosts.json");
|
|
118211
|
+
return paneDataDir ? path15.join(paneDataDir, "session-hosts.json") : null;
|
|
117816
118212
|
}
|
|
117817
118213
|
function readFlagFile(file2) {
|
|
117818
118214
|
if (!file2) return {};
|
|
117819
118215
|
try {
|
|
117820
|
-
const parsed = JSON.parse(
|
|
118216
|
+
const parsed = JSON.parse(fs9.readFileSync(file2, "utf8"));
|
|
117821
118217
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
|
|
117822
118218
|
console.warn(`[session-host] ${file2} is not a JSON object; using the defaults`);
|
|
117823
118219
|
} catch (err) {
|
|
@@ -117883,16 +118279,16 @@ var LOG_HEADER_LEN = LOG_HEADER_PREFIX.length + LOG_HEADER_DIGITS + 1;
|
|
|
117883
118279
|
|
|
117884
118280
|
// src/session-host/registry.ts
|
|
117885
118281
|
import { randomBytes, randomUUID as randomUUID2 } from "node:crypto";
|
|
117886
|
-
import
|
|
117887
|
-
import
|
|
118282
|
+
import fs11 from "node:fs";
|
|
118283
|
+
import path17 from "node:path";
|
|
117888
118284
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
117889
118285
|
|
|
117890
118286
|
// src/session-host/client.ts
|
|
117891
118287
|
import { execFile as execFile3, spawn as spawn4 } from "node:child_process";
|
|
117892
118288
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
117893
|
-
import
|
|
118289
|
+
import fs10 from "node:fs";
|
|
117894
118290
|
import net2 from "node:net";
|
|
117895
|
-
import
|
|
118291
|
+
import path16 from "node:path";
|
|
117896
118292
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
117897
118293
|
var HostRequestError = class extends Error {
|
|
117898
118294
|
reply;
|
|
@@ -117904,36 +118300,36 @@ var HostRequestError = class extends Error {
|
|
|
117904
118300
|
function hostScriptPath() {
|
|
117905
118301
|
const override = process.env.AGENT_PANE_SESSION_HOST_SCRIPT;
|
|
117906
118302
|
if (override) return override;
|
|
117907
|
-
const here =
|
|
118303
|
+
const here = path16.dirname(fileURLToPath3(import.meta.url));
|
|
117908
118304
|
const candidates = [
|
|
117909
|
-
|
|
118305
|
+
path16.resolve(here, "../../scripts/session-host.mjs"),
|
|
117910
118306
|
// src/session-host/ → backend/scripts
|
|
117911
|
-
|
|
118307
|
+
path16.resolve(here, "../scripts/session-host.mjs")
|
|
117912
118308
|
// dist bundle → backend/scripts
|
|
117913
118309
|
];
|
|
117914
118310
|
for (const candidate of candidates) {
|
|
117915
|
-
if (
|
|
118311
|
+
if (fs10.existsSync(candidate)) return candidate;
|
|
117916
118312
|
}
|
|
117917
118313
|
return null;
|
|
117918
118314
|
}
|
|
117919
118315
|
function hostSocketPath(dir) {
|
|
117920
|
-
const direct =
|
|
118316
|
+
const direct = path16.join(dir, "sock");
|
|
117921
118317
|
if (Buffer.byteLength(direct) < 100) return direct;
|
|
117922
118318
|
const uid = typeof process.getuid === "function" ? process.getuid() : 0;
|
|
117923
|
-
return
|
|
118319
|
+
return path16.join("/tmp", `rbsh-${uid}`, path16.basename(dir), "sock");
|
|
117924
118320
|
}
|
|
117925
118321
|
function readJson(file2) {
|
|
117926
118322
|
try {
|
|
117927
|
-
return JSON.parse(
|
|
118323
|
+
return JSON.parse(fs10.readFileSync(file2, "utf8"));
|
|
117928
118324
|
} catch {
|
|
117929
118325
|
return null;
|
|
117930
118326
|
}
|
|
117931
118327
|
}
|
|
117932
118328
|
function readHostExit(dir) {
|
|
117933
|
-
return readJson(
|
|
118329
|
+
return readJson(path16.join(dir, "exit.json"));
|
|
117934
118330
|
}
|
|
117935
118331
|
function readHostChild(dir) {
|
|
117936
|
-
return readJson(
|
|
118332
|
+
return readJson(path16.join(dir, "child.json"));
|
|
117937
118333
|
}
|
|
117938
118334
|
function isPidAlive(pid) {
|
|
117939
118335
|
if (!pid || pid <= 0) return false;
|
|
@@ -118088,8 +118484,8 @@ function attachHost(dir, after, timeoutMs = 5e3) {
|
|
|
118088
118484
|
function startHost(opts) {
|
|
118089
118485
|
const script = hostScriptPath();
|
|
118090
118486
|
if (!script) throw new Error("session host script not found");
|
|
118091
|
-
|
|
118092
|
-
|
|
118487
|
+
fs10.mkdirSync(opts.dir, { recursive: true, mode: 448 });
|
|
118488
|
+
fs10.chmodSync(opts.dir, 448);
|
|
118093
118489
|
const env = {};
|
|
118094
118490
|
for (const [k, v] of Object.entries(opts.env)) if (v !== void 0) env[k] = v;
|
|
118095
118491
|
const child = spawn4(opts.nodePath ?? process.execPath, [script, opts.dir, JSON.stringify(opts.config), opts.command, ...opts.args], {
|
|
@@ -118123,9 +118519,9 @@ async function waitForHost(dir, timeoutMs = 1e4) {
|
|
|
118123
118519
|
function readLogOldest(dir) {
|
|
118124
118520
|
let fd = null;
|
|
118125
118521
|
try {
|
|
118126
|
-
fd =
|
|
118522
|
+
fd = fs10.openSync(path16.join(dir, "out.log"), "r");
|
|
118127
118523
|
const buf = Buffer.alloc(LOG_HEADER_LEN);
|
|
118128
|
-
const n =
|
|
118524
|
+
const n = fs10.readSync(fd, buf, 0, LOG_HEADER_LEN, 0);
|
|
118129
118525
|
const text2 = buf.subarray(0, n).toString("utf8");
|
|
118130
118526
|
if (n < LOG_HEADER_LEN || !text2.startsWith(LOG_HEADER_PREFIX) || text2[LOG_HEADER_LEN - 1] !== "\n") return null;
|
|
118131
118527
|
const digits = text2.slice(LOG_HEADER_PREFIX.length, LOG_HEADER_PREFIX.length + LOG_HEADER_DIGITS);
|
|
@@ -118133,14 +118529,14 @@ function readLogOldest(dir) {
|
|
|
118133
118529
|
} catch {
|
|
118134
118530
|
return null;
|
|
118135
118531
|
} finally {
|
|
118136
|
-
if (fd !== null)
|
|
118532
|
+
if (fd !== null) fs10.closeSync(fd);
|
|
118137
118533
|
}
|
|
118138
118534
|
}
|
|
118139
118535
|
function readHostLog(dir, after) {
|
|
118140
118536
|
const oldest = readLogOldest(dir);
|
|
118141
118537
|
if (oldest === null || after < oldest) return null;
|
|
118142
118538
|
try {
|
|
118143
|
-
const all =
|
|
118539
|
+
const all = fs10.readFileSync(path16.join(dir, "out.log"));
|
|
118144
118540
|
const start = LOG_HEADER_LEN + (after - oldest);
|
|
118145
118541
|
if (start > all.length) return null;
|
|
118146
118542
|
return all.subarray(start);
|
|
@@ -118150,14 +118546,14 @@ function readHostLog(dir, after) {
|
|
|
118150
118546
|
}
|
|
118151
118547
|
function removeHostDir(dir) {
|
|
118152
118548
|
try {
|
|
118153
|
-
|
|
118549
|
+
fs10.rmSync(dir, { recursive: true, force: true });
|
|
118154
118550
|
} catch (err) {
|
|
118155
118551
|
console.error(`[session-host] could not remove ${dir}:`, err.message);
|
|
118156
118552
|
}
|
|
118157
|
-
const alias =
|
|
118553
|
+
const alias = path16.dirname(hostSocketPath(dir));
|
|
118158
118554
|
if (alias !== dir) {
|
|
118159
118555
|
try {
|
|
118160
|
-
|
|
118556
|
+
fs10.unlinkSync(alias);
|
|
118161
118557
|
} catch {
|
|
118162
118558
|
}
|
|
118163
118559
|
}
|
|
@@ -118217,16 +118613,16 @@ function newHostDir() {
|
|
|
118217
118613
|
const root = sessionHostsRoot();
|
|
118218
118614
|
if (!root) throw new Error("session hosts have no directory");
|
|
118219
118615
|
const id = randomBytes(8).toString("hex");
|
|
118220
|
-
return { id, dir:
|
|
118616
|
+
return { id, dir: path17.join(root, id) };
|
|
118221
118617
|
}
|
|
118222
118618
|
var cachedVersion;
|
|
118223
118619
|
function runtimeVersion() {
|
|
118224
118620
|
if (cachedVersion !== void 0) return cachedVersion;
|
|
118225
118621
|
cachedVersion = null;
|
|
118226
|
-
const here =
|
|
118622
|
+
const here = path17.dirname(fileURLToPath4(import.meta.url));
|
|
118227
118623
|
for (const rel of ["../../../../package.json", "../../../package.json"]) {
|
|
118228
118624
|
try {
|
|
118229
|
-
const pkg = JSON.parse(
|
|
118625
|
+
const pkg = JSON.parse(fs11.readFileSync(path17.resolve(here, rel), "utf8"));
|
|
118230
118626
|
if (pkg.name === "repoburg" && pkg.version) {
|
|
118231
118627
|
cachedVersion = pkg.version;
|
|
118232
118628
|
break;
|
|
@@ -118237,15 +118633,15 @@ function runtimeVersion() {
|
|
|
118237
118633
|
return cachedVersion;
|
|
118238
118634
|
}
|
|
118239
118635
|
function writeHostMeta(dir, meta3) {
|
|
118240
|
-
|
|
118241
|
-
|
|
118242
|
-
const tmp =
|
|
118243
|
-
|
|
118244
|
-
|
|
118636
|
+
fs11.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
118637
|
+
fs11.chmodSync(dir, 448);
|
|
118638
|
+
const tmp = path17.join(dir, "meta.json.tmp");
|
|
118639
|
+
fs11.writeFileSync(tmp, JSON.stringify(meta3, null, 2) + "\n", { mode: 384 });
|
|
118640
|
+
fs11.renameSync(tmp, path17.join(dir, "meta.json"));
|
|
118245
118641
|
}
|
|
118246
118642
|
function readHostMeta(dir) {
|
|
118247
118643
|
try {
|
|
118248
|
-
return JSON.parse(
|
|
118644
|
+
return JSON.parse(fs11.readFileSync(path17.join(dir, "meta.json"), "utf8"));
|
|
118249
118645
|
} catch {
|
|
118250
118646
|
return null;
|
|
118251
118647
|
}
|
|
@@ -118383,16 +118779,16 @@ async function runAdoption() {
|
|
|
118383
118779
|
async function adoptHosts(db2, root, adoption, result) {
|
|
118384
118780
|
let entries = [];
|
|
118385
118781
|
try {
|
|
118386
|
-
entries =
|
|
118782
|
+
entries = fs11.readdirSync(root);
|
|
118387
118783
|
} catch (err) {
|
|
118388
118784
|
if (err.code !== "ENOENT") console.error("[session-host] cannot read", root, err.message);
|
|
118389
118785
|
}
|
|
118390
118786
|
const seen = /* @__PURE__ */ new Set();
|
|
118391
118787
|
const queue = [];
|
|
118392
118788
|
for (const id of entries) {
|
|
118393
|
-
const dir =
|
|
118789
|
+
const dir = path17.join(root, id);
|
|
118394
118790
|
try {
|
|
118395
|
-
if (!
|
|
118791
|
+
if (!fs11.statSync(dir).isDirectory()) continue;
|
|
118396
118792
|
} catch {
|
|
118397
118793
|
continue;
|
|
118398
118794
|
}
|
|
@@ -118504,7 +118900,7 @@ async function shutDownAllHosts() {
|
|
|
118504
118900
|
if (!root) return 0;
|
|
118505
118901
|
let entries = [];
|
|
118506
118902
|
try {
|
|
118507
|
-
entries =
|
|
118903
|
+
entries = fs11.readdirSync(root);
|
|
118508
118904
|
} catch {
|
|
118509
118905
|
return 0;
|
|
118510
118906
|
}
|
|
@@ -118517,7 +118913,7 @@ async function shutDownAllHosts() {
|
|
|
118517
118913
|
}
|
|
118518
118914
|
await Promise.all(
|
|
118519
118915
|
entries.map(async (id) => {
|
|
118520
|
-
const dir =
|
|
118916
|
+
const dir = path17.join(root, id);
|
|
118521
118917
|
const row = db2 ? getHostRow(db2, id) : void 0;
|
|
118522
118918
|
try {
|
|
118523
118919
|
await shutDownHost(dir, { eof: row?.runtime === "codex" });
|
|
@@ -118986,9 +119382,9 @@ function mapTokenUsage(data) {
|
|
|
118986
119382
|
|
|
118987
119383
|
// src/tabtape/browser-mcp.ts
|
|
118988
119384
|
import { spawn as spawn6 } from "node:child_process";
|
|
118989
|
-
import
|
|
119385
|
+
import fs12 from "node:fs";
|
|
118990
119386
|
import os6 from "node:os";
|
|
118991
|
-
import
|
|
119387
|
+
import path18 from "node:path";
|
|
118992
119388
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
118993
119389
|
var TABTAPE_MCP_NAME = "tabtape";
|
|
118994
119390
|
var PLAYWRIGHT_MCP_NAME = "playwright";
|
|
@@ -119002,15 +119398,15 @@ function disabled() {
|
|
|
119002
119398
|
function tabtapeBaseUrl() {
|
|
119003
119399
|
return (process.env.AGENT_PANE_TABTAPE_URL || `${sessionHostDaemonUrl()}/tabtape`).replace(/\/+$/, "");
|
|
119004
119400
|
}
|
|
119005
|
-
function playwrightMcpScript(from =
|
|
119401
|
+
function playwrightMcpScript(from = path18.dirname(fileURLToPath5(import.meta.url))) {
|
|
119006
119402
|
if (scriptOverride !== void 0) return scriptOverride;
|
|
119007
119403
|
let dir = from;
|
|
119008
119404
|
for (let i = 0; i < 6; i++) {
|
|
119009
|
-
const script =
|
|
119010
|
-
if (
|
|
119405
|
+
const script = path18.join(dir, "tabtape", "playwright", "mcp.mjs");
|
|
119406
|
+
if (fs12.existsSync(script) && fs12.existsSync(path18.join(dir, "tabtape", "extension", "dist", "manifest.json"))) {
|
|
119011
119407
|
return script;
|
|
119012
119408
|
}
|
|
119013
|
-
const parent =
|
|
119409
|
+
const parent = path18.dirname(dir);
|
|
119014
119410
|
if (parent === dir) break;
|
|
119015
119411
|
dir = parent;
|
|
119016
119412
|
}
|
|
@@ -119043,7 +119439,7 @@ async function browserMcp(taken) {
|
|
|
119043
119439
|
}
|
|
119044
119440
|
function jsonServerNames(file2, pick2) {
|
|
119045
119441
|
try {
|
|
119046
|
-
const json2 = JSON.parse(
|
|
119442
|
+
const json2 = JSON.parse(fs12.readFileSync(file2, "utf8"));
|
|
119047
119443
|
const servers = pick2(json2);
|
|
119048
119444
|
return servers && typeof servers === "object" ? Object.keys(servers) : [];
|
|
119049
119445
|
} catch {
|
|
@@ -119052,14 +119448,14 @@ function jsonServerNames(file2, pick2) {
|
|
|
119052
119448
|
}
|
|
119053
119449
|
function claudeConfigFile() {
|
|
119054
119450
|
if (process.env.AGENT_PANE_CLAUDE_CONFIG_FILE) return process.env.AGENT_PANE_CLAUDE_CONFIG_FILE;
|
|
119055
|
-
return
|
|
119451
|
+
return path18.join(process.env.CLAUDE_CONFIG_DIR || os6.homedir(), ".claude.json");
|
|
119056
119452
|
}
|
|
119057
119453
|
function claudeUserMcpNames(cwd) {
|
|
119058
119454
|
const file2 = claudeConfigFile();
|
|
119059
119455
|
return /* @__PURE__ */ new Set([
|
|
119060
119456
|
...jsonServerNames(file2, (json2) => json2.mcpServers),
|
|
119061
119457
|
...jsonServerNames(file2, (json2) => json2.projects?.[cwd]?.mcpServers),
|
|
119062
|
-
...jsonServerNames(
|
|
119458
|
+
...jsonServerNames(path18.join(cwd, ".mcp.json"), (json2) => json2.mcpServers)
|
|
119063
119459
|
]);
|
|
119064
119460
|
}
|
|
119065
119461
|
async function claudeBrowserMcpServers(cwd) {
|
|
@@ -119072,7 +119468,7 @@ async function claudeBrowserMcpServers(cwd) {
|
|
|
119072
119468
|
function tomlServerNames(file2) {
|
|
119073
119469
|
let text2;
|
|
119074
119470
|
try {
|
|
119075
|
-
text2 =
|
|
119471
|
+
text2 = fs12.readFileSync(file2, "utf8");
|
|
119076
119472
|
} catch {
|
|
119077
119473
|
return [];
|
|
119078
119474
|
}
|
|
@@ -119082,8 +119478,8 @@ function tomlServerNames(file2) {
|
|
|
119082
119478
|
return names;
|
|
119083
119479
|
}
|
|
119084
119480
|
function codexUserMcpNames(cwd) {
|
|
119085
|
-
const home = process.env.CODEX_HOME ||
|
|
119086
|
-
return /* @__PURE__ */ new Set([...tomlServerNames(
|
|
119481
|
+
const home = process.env.CODEX_HOME || path18.join(os6.homedir(), ".codex");
|
|
119482
|
+
return /* @__PURE__ */ new Set([...tomlServerNames(path18.join(home, "config.toml")), ...tomlServerNames(path18.join(cwd, ".codex", "config.toml"))]);
|
|
119087
119483
|
}
|
|
119088
119484
|
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.`;
|
|
119089
119485
|
async function codexBrowserMcp(cwd) {
|
|
@@ -119110,13 +119506,13 @@ async function codexBrowserMcp(cwd) {
|
|
|
119110
119506
|
}
|
|
119111
119507
|
var prepared = false;
|
|
119112
119508
|
function chromiumDownloadCommand(execPath = process.execPath) {
|
|
119113
|
-
const bin =
|
|
119114
|
-
const npx =
|
|
119115
|
-
if (!
|
|
119509
|
+
const bin = path18.dirname(execPath);
|
|
119510
|
+
const npx = path18.join(bin, process.platform === "win32" ? "npx.cmd" : "npx");
|
|
119511
|
+
if (!fs12.existsSync(npx)) return null;
|
|
119116
119512
|
return {
|
|
119117
119513
|
command: npx,
|
|
119118
119514
|
args: ["-y", "@playwright/mcp@latest", "install-browser", "chromium"],
|
|
119119
|
-
env: { ...process.env, PATH: [bin, process.env.PATH].filter(Boolean).join(
|
|
119515
|
+
env: { ...process.env, PATH: [bin, process.env.PATH].filter(Boolean).join(path18.delimiter) }
|
|
119120
119516
|
};
|
|
119121
119517
|
}
|
|
119122
119518
|
function prepareBrowserMcp() {
|
|
@@ -120283,10 +120679,19 @@ var EFFORT_LABELS = {
|
|
|
120283
120679
|
max: "Max",
|
|
120284
120680
|
ultra: "Ultra"
|
|
120285
120681
|
};
|
|
120682
|
+
var MODEL_LIST_MAX_PAGES = 20;
|
|
120286
120683
|
async function getModels() {
|
|
120287
120684
|
try {
|
|
120288
|
-
const
|
|
120289
|
-
|
|
120685
|
+
const server = getSharedAppServer();
|
|
120686
|
+
const listed = [];
|
|
120687
|
+
let cursor = null;
|
|
120688
|
+
for (let page = 0; page < MODEL_LIST_MAX_PAGES; page++) {
|
|
120689
|
+
const result = await server.request("model/list", cursor ? { cursor } : {});
|
|
120690
|
+
listed.push(...result.data ?? []);
|
|
120691
|
+
cursor = result.nextCursor ?? null;
|
|
120692
|
+
if (!cursor) break;
|
|
120693
|
+
}
|
|
120694
|
+
return listed.filter((m) => !m.hidden).map((m) => ({
|
|
120290
120695
|
slug: m.id,
|
|
120291
120696
|
displayName: m.displayName,
|
|
120292
120697
|
description: m.description,
|
|
@@ -121321,8 +121726,9 @@ var PromptQueue = class {
|
|
|
121321
121726
|
var CLI_OVERRIDE = process.env.CLAUDE_BIN ? { pathToClaudeCodeExecutable: process.env.CLAUDE_BIN } : {};
|
|
121322
121727
|
var sessionMap2 = /* @__PURE__ */ new Map();
|
|
121323
121728
|
var titleGenerating2 = /* @__PURE__ */ new Set();
|
|
121324
|
-
var
|
|
121325
|
-
var
|
|
121729
|
+
var MODELS_TTL_MS = 10 * 6e4;
|
|
121730
|
+
var catalog = null;
|
|
121731
|
+
var catalogLoad = null;
|
|
121326
121732
|
var thinkingAccumulator = /* @__PURE__ */ new Map();
|
|
121327
121733
|
var streamingMessageIds = /* @__PURE__ */ new Map();
|
|
121328
121734
|
var widgetStreams = /* @__PURE__ */ new WeakMap();
|
|
@@ -122644,40 +123050,48 @@ async function stopTask2(sessionId, taskId) {
|
|
|
122644
123050
|
if (!entry) return;
|
|
122645
123051
|
await entry.query.stopTask(taskId);
|
|
122646
123052
|
}
|
|
122647
|
-
|
|
122648
|
-
|
|
122649
|
-
|
|
122650
|
-
|
|
122651
|
-
|
|
122652
|
-
|
|
122653
|
-
|
|
122654
|
-
|
|
122655
|
-
|
|
122656
|
-
|
|
123053
|
+
function loadCatalog() {
|
|
123054
|
+
catalogLoad ??= (async () => {
|
|
123055
|
+
try {
|
|
123056
|
+
const q = query({
|
|
123057
|
+
prompt: "",
|
|
123058
|
+
options: {
|
|
123059
|
+
cwd: process.cwd(),
|
|
123060
|
+
permissionMode: "bypassPermissions",
|
|
123061
|
+
allowDangerouslySkipPermissions: true,
|
|
123062
|
+
...CLI_OVERRIDE
|
|
123063
|
+
}
|
|
123064
|
+
});
|
|
123065
|
+
const initResult = await q.initializationResult();
|
|
123066
|
+
q.close();
|
|
123067
|
+
const models = (initResult.models ?? []).map((m) => ({
|
|
123068
|
+
slug: m.value,
|
|
123069
|
+
displayName: m.displayName,
|
|
123070
|
+
description: m.description,
|
|
123071
|
+
defaultReasoning: m.supportedEffortLevels?.[0] ?? "medium",
|
|
123072
|
+
reasoningLevels: (m.supportedEffortLevels ?? []).map((e) => ({
|
|
123073
|
+
effort: e,
|
|
123074
|
+
label: EFFORT_LABELS2[e] ?? e
|
|
123075
|
+
}))
|
|
123076
|
+
}));
|
|
123077
|
+
if (models.length > 0) {
|
|
123078
|
+
catalog = { models, commands: mapSdkCommands(initResult.commands ?? []), at: Date.now() };
|
|
122657
123079
|
}
|
|
122658
|
-
}
|
|
122659
|
-
|
|
122660
|
-
|
|
122661
|
-
|
|
122662
|
-
|
|
122663
|
-
|
|
122664
|
-
|
|
122665
|
-
|
|
122666
|
-
|
|
122667
|
-
|
|
122668
|
-
|
|
122669
|
-
label: EFFORT_LABELS2[e] ?? e
|
|
122670
|
-
}))
|
|
122671
|
-
}));
|
|
122672
|
-
return cachedModels;
|
|
122673
|
-
} catch {
|
|
122674
|
-
return [];
|
|
122675
|
-
}
|
|
123080
|
+
} catch {
|
|
123081
|
+
} finally {
|
|
123082
|
+
catalogLoad = null;
|
|
123083
|
+
}
|
|
123084
|
+
})();
|
|
123085
|
+
return catalogLoad;
|
|
123086
|
+
}
|
|
123087
|
+
async function getModels2() {
|
|
123088
|
+
if (!catalog) await loadCatalog();
|
|
123089
|
+
else if (Date.now() - catalog.at > MODELS_TTL_MS) void loadCatalog();
|
|
123090
|
+
return catalog?.models ?? [];
|
|
122676
123091
|
}
|
|
122677
123092
|
async function getCommands2() {
|
|
122678
|
-
if (
|
|
122679
|
-
|
|
122680
|
-
return cachedCommands ?? [];
|
|
123093
|
+
if (!catalog) await loadCatalog();
|
|
123094
|
+
return catalog?.commands ?? [];
|
|
122681
123095
|
}
|
|
122682
123096
|
function mapSdkCommands(commands) {
|
|
122683
123097
|
return commands.map((c) => ({
|
|
@@ -123117,8 +123531,8 @@ var RepoburgHttpClient = class {
|
|
|
123117
123531
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
123118
123532
|
}
|
|
123119
123533
|
/** Perform a JSON request. Throws a concise error on non-OK/non-JSON responses. */
|
|
123120
|
-
async request(method,
|
|
123121
|
-
const response = await fetch(`${this.baseUrl}${
|
|
123534
|
+
async request(method, path21, body) {
|
|
123535
|
+
const response = await fetch(`${this.baseUrl}${path21}`, {
|
|
123122
123536
|
method,
|
|
123123
123537
|
headers: { "Content-Type": "application/json" },
|
|
123124
123538
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
@@ -123127,17 +123541,17 @@ var RepoburgHttpClient = class {
|
|
|
123127
123541
|
if (!response.ok) {
|
|
123128
123542
|
if (isHtml(text2)) {
|
|
123129
123543
|
throw new Error(
|
|
123130
|
-
`${method} ${
|
|
123544
|
+
`${method} ${path21} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
123131
123545
|
);
|
|
123132
123546
|
}
|
|
123133
|
-
throw new Error(`${method} ${
|
|
123547
|
+
throw new Error(`${method} ${path21} failed: ${response.status} ${text2}`);
|
|
123134
123548
|
}
|
|
123135
123549
|
if (text2.length === 0) return void 0;
|
|
123136
123550
|
try {
|
|
123137
123551
|
return JSON.parse(text2);
|
|
123138
123552
|
} catch {
|
|
123139
123553
|
throw new Error(
|
|
123140
|
-
`${method} ${
|
|
123554
|
+
`${method} ${path21} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
123141
123555
|
);
|
|
123142
123556
|
}
|
|
123143
123557
|
}
|
|
@@ -123192,7 +123606,7 @@ var RepoburgHttpClient = class {
|
|
|
123192
123606
|
};
|
|
123193
123607
|
|
|
123194
123608
|
// src/repoburg/backend-resolver.ts
|
|
123195
|
-
import
|
|
123609
|
+
import path19 from "node:path";
|
|
123196
123610
|
var HEALTH_POLL_INTERVAL_MS = 1e3;
|
|
123197
123611
|
var HEALTH_TIMEOUT_MS = 3e4;
|
|
123198
123612
|
function daemonBaseUrl() {
|
|
@@ -123247,7 +123661,7 @@ async function backendHealthy(baseUrl, expectedPath) {
|
|
|
123247
123661
|
const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
|
|
123248
123662
|
if (health.status !== "ok") return false;
|
|
123249
123663
|
if (expectedPath && health.projectPath) {
|
|
123250
|
-
return
|
|
123664
|
+
return path19.resolve(health.projectPath) === path19.resolve(expectedPath);
|
|
123251
123665
|
}
|
|
123252
123666
|
return true;
|
|
123253
123667
|
} catch {
|
|
@@ -123268,7 +123682,7 @@ function serviceBaseUrl(service) {
|
|
|
123268
123682
|
return `http://localhost:${service.port}`;
|
|
123269
123683
|
}
|
|
123270
123684
|
function coveringService(services, absPath) {
|
|
123271
|
-
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path +
|
|
123685
|
+
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path19.sep)).sort((a, b) => b.path.length - a.path.length)[0];
|
|
123272
123686
|
}
|
|
123273
123687
|
async function restartService(daemon, name) {
|
|
123274
123688
|
try {
|
|
@@ -123304,7 +123718,7 @@ async function resolveBackendUrl(projectPath, opts = {}) {
|
|
|
123304
123718
|
if (envUrl) {
|
|
123305
123719
|
return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
|
|
123306
123720
|
}
|
|
123307
|
-
const absPath =
|
|
123721
|
+
const absPath = path19.resolve(projectPath);
|
|
123308
123722
|
const daemon = daemonBaseUrl();
|
|
123309
123723
|
const cached3 = resolvedCache.get(absPath);
|
|
123310
123724
|
if (cached3 && await backendHealthy(cached3.baseUrl, cached3.servesPath ?? absPath)) {
|
|
@@ -124985,7 +125399,7 @@ registerProvider("repoburg", repoburgProvider);
|
|
|
124985
125399
|
async function createAgentPaneApp(dbPath, opts = {}) {
|
|
124986
125400
|
const allowRequest = opts.allowRequest ?? isLocalRequest;
|
|
124987
125401
|
initDb(dbPath);
|
|
124988
|
-
setPaneDataDir(dbPath === ":memory:" ? null :
|
|
125402
|
+
setPaneDataDir(dbPath === ":memory:" ? null : path20.dirname(path20.resolve(dbPath)));
|
|
124989
125403
|
const fastify = (0, import_fastify.default)({ logger: true, bodyLimit: 50 * 1024 * 1024 });
|
|
124990
125404
|
fastify.addHook("onRequest", async (request, reply) => {
|
|
124991
125405
|
if (!allowRequest(request.headers.origin, request.headers.host)) {
|