repoburg 1.3.235 → 1.3.236
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 +1188 -260
- package/agent-pane/backend/dist/server.js +1188 -260
- package/agent-pane/frontend/dist/assets/index-BKidPoB0.js +475 -0
- package/agent-pane/frontend/dist/assets/{index-B8tLcszC.css → index-qS_kafxG.css} +1 -1
- package/agent-pane/frontend/dist/index.html +2 -2
- package/daemon/dist/instance-entry.spec.js +57 -0
- package/daemon/dist/instanceEntry.js +19 -0
- package/daemon/dist/serviceManager.js +32 -16
- package/daemon/dist/serviceManager.spec.js +22 -4
- package/daemon/instance-entry-keys.js +22 -0
- package/daemon/instance-entry.js +28 -0
- package/miniapp-catalog-modal.png +0 -0
- package/miniapp-daemon-e2e-green.png +0 -0
- package/miniapp-faz31-codex-green.png +0 -0
- package/miniapp-pr-review-green.png +0 -0
- package/miniapp-workspace-scoped.png +0 -0
- package/package.json +1 -1
- package/agent-pane/frontend/dist/assets/index-CpjdL6KA.js +0 -424
|
@@ -2676,7 +2676,7 @@ var require_server = __commonJS({
|
|
|
2676
2676
|
var https = __require("node:https");
|
|
2677
2677
|
var http22 = __require("node:http2");
|
|
2678
2678
|
var dns = __require("node:dns");
|
|
2679
|
-
var
|
|
2679
|
+
var os3 = __require("node:os");
|
|
2680
2680
|
var { kState, kOptions, kServerBindings, kHttp2ServerSessions } = require_symbols2();
|
|
2681
2681
|
var { FSTWRN003 } = require_warnings();
|
|
2682
2682
|
var { onListenHookRunner } = require_hooks();
|
|
@@ -2938,7 +2938,7 @@ var require_server = __commonJS({
|
|
|
2938
2938
|
}
|
|
2939
2939
|
function getAddresses(address) {
|
|
2940
2940
|
if (address.address === "0.0.0.0") {
|
|
2941
|
-
return Object.values(
|
|
2941
|
+
return Object.values(os3.networkInterfaces()).flatMap((iface) => {
|
|
2942
2942
|
return iface.filter((iface2) => iface2.family === "IPv4");
|
|
2943
2943
|
}).sort((iface) => {
|
|
2944
2944
|
return iface.internal ? -1 : 1;
|
|
@@ -6124,8 +6124,8 @@ var require_req = __commonJS({
|
|
|
6124
6124
|
if (req.originalUrl) {
|
|
6125
6125
|
_req.url = req.originalUrl;
|
|
6126
6126
|
} else {
|
|
6127
|
-
const
|
|
6128
|
-
_req.url = typeof
|
|
6127
|
+
const path8 = req.path;
|
|
6128
|
+
_req.url = typeof path8 === "string" ? path8 : req.url ? req.url.path || req.url : void 0;
|
|
6129
6129
|
}
|
|
6130
6130
|
if (req.query) {
|
|
6131
6131
|
_req.query = req.query;
|
|
@@ -6290,14 +6290,14 @@ var require_redact = __commonJS({
|
|
|
6290
6290
|
}
|
|
6291
6291
|
return obj;
|
|
6292
6292
|
}
|
|
6293
|
-
function parsePath(
|
|
6293
|
+
function parsePath(path8) {
|
|
6294
6294
|
const parts = [];
|
|
6295
6295
|
let current = "";
|
|
6296
6296
|
let inBrackets = false;
|
|
6297
6297
|
let inQuotes = false;
|
|
6298
6298
|
let quoteChar = "";
|
|
6299
|
-
for (let i = 0; i <
|
|
6300
|
-
const char =
|
|
6299
|
+
for (let i = 0; i < path8.length; i++) {
|
|
6300
|
+
const char = path8[i];
|
|
6301
6301
|
if (!inBrackets && char === ".") {
|
|
6302
6302
|
if (current) {
|
|
6303
6303
|
parts.push(current);
|
|
@@ -6428,10 +6428,10 @@ var require_redact = __commonJS({
|
|
|
6428
6428
|
return current;
|
|
6429
6429
|
}
|
|
6430
6430
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
6431
|
-
for (const
|
|
6432
|
-
const parts = parsePath(
|
|
6431
|
+
for (const path8 of paths) {
|
|
6432
|
+
const parts = parsePath(path8);
|
|
6433
6433
|
if (parts.includes("*")) {
|
|
6434
|
-
redactWildcardPath(obj, parts, censor,
|
|
6434
|
+
redactWildcardPath(obj, parts, censor, path8, remove);
|
|
6435
6435
|
} else {
|
|
6436
6436
|
if (remove) {
|
|
6437
6437
|
removeKey(obj, parts);
|
|
@@ -6516,8 +6516,8 @@ var require_redact = __commonJS({
|
|
|
6516
6516
|
}
|
|
6517
6517
|
} else {
|
|
6518
6518
|
if (afterWildcard.includes("*")) {
|
|
6519
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
6520
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
6519
|
+
const wrappedCensor = typeof censor === "function" ? (value, path8) => {
|
|
6520
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path8];
|
|
6521
6521
|
return censor(value, fullPath);
|
|
6522
6522
|
} : censor;
|
|
6523
6523
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -6552,8 +6552,8 @@ var require_redact = __commonJS({
|
|
|
6552
6552
|
return null;
|
|
6553
6553
|
}
|
|
6554
6554
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
6555
|
-
for (const
|
|
6556
|
-
const parts = parsePath(
|
|
6555
|
+
for (const path8 of pathsToClone) {
|
|
6556
|
+
const parts = parsePath(path8);
|
|
6557
6557
|
let current = pathStructure;
|
|
6558
6558
|
for (let i = 0; i < parts.length; i++) {
|
|
6559
6559
|
const part = parts[i];
|
|
@@ -6605,24 +6605,24 @@ var require_redact = __commonJS({
|
|
|
6605
6605
|
}
|
|
6606
6606
|
return cloneSelectively(obj, pathStructure);
|
|
6607
6607
|
}
|
|
6608
|
-
function validatePath(
|
|
6609
|
-
if (typeof
|
|
6608
|
+
function validatePath(path8) {
|
|
6609
|
+
if (typeof path8 !== "string") {
|
|
6610
6610
|
throw new Error("Paths must be (non-empty) strings");
|
|
6611
6611
|
}
|
|
6612
|
-
if (
|
|
6612
|
+
if (path8 === "") {
|
|
6613
6613
|
throw new Error("Invalid redaction path ()");
|
|
6614
6614
|
}
|
|
6615
|
-
if (
|
|
6616
|
-
throw new Error(`Invalid redaction path (${
|
|
6615
|
+
if (path8.includes("..")) {
|
|
6616
|
+
throw new Error(`Invalid redaction path (${path8})`);
|
|
6617
6617
|
}
|
|
6618
|
-
if (
|
|
6619
|
-
throw new Error(`Invalid redaction path (${
|
|
6618
|
+
if (path8.includes(",")) {
|
|
6619
|
+
throw new Error(`Invalid redaction path (${path8})`);
|
|
6620
6620
|
}
|
|
6621
6621
|
let bracketCount = 0;
|
|
6622
6622
|
let inQuotes = false;
|
|
6623
6623
|
let quoteChar = "";
|
|
6624
|
-
for (let i = 0; i <
|
|
6625
|
-
const char =
|
|
6624
|
+
for (let i = 0; i < path8.length; i++) {
|
|
6625
|
+
const char = path8[i];
|
|
6626
6626
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
6627
6627
|
if (!inQuotes) {
|
|
6628
6628
|
inQuotes = true;
|
|
@@ -6636,20 +6636,20 @@ var require_redact = __commonJS({
|
|
|
6636
6636
|
} else if (char === "]" && !inQuotes) {
|
|
6637
6637
|
bracketCount--;
|
|
6638
6638
|
if (bracketCount < 0) {
|
|
6639
|
-
throw new Error(`Invalid redaction path (${
|
|
6639
|
+
throw new Error(`Invalid redaction path (${path8})`);
|
|
6640
6640
|
}
|
|
6641
6641
|
}
|
|
6642
6642
|
}
|
|
6643
6643
|
if (bracketCount !== 0) {
|
|
6644
|
-
throw new Error(`Invalid redaction path (${
|
|
6644
|
+
throw new Error(`Invalid redaction path (${path8})`);
|
|
6645
6645
|
}
|
|
6646
6646
|
}
|
|
6647
6647
|
function validatePaths(paths) {
|
|
6648
6648
|
if (!Array.isArray(paths)) {
|
|
6649
6649
|
throw new TypeError("paths must be an array");
|
|
6650
6650
|
}
|
|
6651
|
-
for (const
|
|
6652
|
-
validatePath(
|
|
6651
|
+
for (const path8 of paths) {
|
|
6652
|
+
validatePath(path8);
|
|
6653
6653
|
}
|
|
6654
6654
|
}
|
|
6655
6655
|
function slowRedact(options = {}) {
|
|
@@ -6817,8 +6817,8 @@ var require_redaction = __commonJS({
|
|
|
6817
6817
|
if (shape[k] === null) {
|
|
6818
6818
|
o[k] = (value) => topCensor(value, [k]);
|
|
6819
6819
|
} else {
|
|
6820
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
6821
|
-
return censor(value, [k, ...
|
|
6820
|
+
const wrappedCensor = typeof censor === "function" ? (value, path8) => {
|
|
6821
|
+
return censor(value, [k, ...path8]);
|
|
6822
6822
|
} : censor;
|
|
6823
6823
|
o[k] = Redact({
|
|
6824
6824
|
paths: shape[k],
|
|
@@ -7036,10 +7036,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
7036
7036
|
var require_sonic_boom = __commonJS({
|
|
7037
7037
|
"node_modules/sonic-boom/index.js"(exports, module) {
|
|
7038
7038
|
"use strict";
|
|
7039
|
-
var
|
|
7039
|
+
var fs6 = __require("fs");
|
|
7040
7040
|
var EventEmitter2 = __require("events");
|
|
7041
7041
|
var inherits = __require("util").inherits;
|
|
7042
|
-
var
|
|
7042
|
+
var path8 = __require("path");
|
|
7043
7043
|
var sleep = require_atomic_sleep();
|
|
7044
7044
|
var assert = __require("assert");
|
|
7045
7045
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -7093,20 +7093,20 @@ var require_sonic_boom = __commonJS({
|
|
|
7093
7093
|
const mode = sonic.mode;
|
|
7094
7094
|
if (sonic.sync) {
|
|
7095
7095
|
try {
|
|
7096
|
-
if (sonic.mkdir)
|
|
7097
|
-
const fd =
|
|
7096
|
+
if (sonic.mkdir) fs6.mkdirSync(path8.dirname(file), { recursive: true });
|
|
7097
|
+
const fd = fs6.openSync(file, flags, mode);
|
|
7098
7098
|
fileOpened(null, fd);
|
|
7099
7099
|
} catch (err) {
|
|
7100
7100
|
fileOpened(err);
|
|
7101
7101
|
throw err;
|
|
7102
7102
|
}
|
|
7103
7103
|
} else if (sonic.mkdir) {
|
|
7104
|
-
|
|
7104
|
+
fs6.mkdir(path8.dirname(file), { recursive: true }, (err) => {
|
|
7105
7105
|
if (err) return fileOpened(err);
|
|
7106
|
-
|
|
7106
|
+
fs6.open(file, flags, mode, fileOpened);
|
|
7107
7107
|
});
|
|
7108
7108
|
} else {
|
|
7109
|
-
|
|
7109
|
+
fs6.open(file, flags, mode, fileOpened);
|
|
7110
7110
|
}
|
|
7111
7111
|
}
|
|
7112
7112
|
function SonicBoom(opts) {
|
|
@@ -7147,8 +7147,8 @@ var require_sonic_boom = __commonJS({
|
|
|
7147
7147
|
this.flush = flushBuffer;
|
|
7148
7148
|
this.flushSync = flushBufferSync;
|
|
7149
7149
|
this._actualWrite = actualWriteBuffer;
|
|
7150
|
-
fsWriteSync = () =>
|
|
7151
|
-
fsWrite = () =>
|
|
7150
|
+
fsWriteSync = () => fs6.writeSync(this.fd, this._writingBuf);
|
|
7151
|
+
fsWrite = () => fs6.write(this.fd, this._writingBuf, this.release);
|
|
7152
7152
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
7153
7153
|
this._writingBuf = "";
|
|
7154
7154
|
this.write = write;
|
|
@@ -7157,15 +7157,15 @@ var require_sonic_boom = __commonJS({
|
|
|
7157
7157
|
this._actualWrite = actualWrite;
|
|
7158
7158
|
fsWriteSync = () => {
|
|
7159
7159
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
7160
|
-
return
|
|
7160
|
+
return fs6.writeSync(this.fd, this._writingBuf);
|
|
7161
7161
|
}
|
|
7162
|
-
return
|
|
7162
|
+
return fs6.writeSync(this.fd, this._writingBuf, "utf8");
|
|
7163
7163
|
};
|
|
7164
7164
|
fsWrite = () => {
|
|
7165
7165
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
7166
|
-
return
|
|
7166
|
+
return fs6.write(this.fd, this._writingBuf, this.release);
|
|
7167
7167
|
}
|
|
7168
|
-
return
|
|
7168
|
+
return fs6.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
7169
7169
|
};
|
|
7170
7170
|
} else {
|
|
7171
7171
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
@@ -7222,7 +7222,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7222
7222
|
}
|
|
7223
7223
|
}
|
|
7224
7224
|
if (this._fsync) {
|
|
7225
|
-
|
|
7225
|
+
fs6.fsyncSync(this.fd);
|
|
7226
7226
|
}
|
|
7227
7227
|
const len = this._len;
|
|
7228
7228
|
if (this._reopening) {
|
|
@@ -7336,7 +7336,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7336
7336
|
const onDrain = () => {
|
|
7337
7337
|
if (!this._fsync) {
|
|
7338
7338
|
try {
|
|
7339
|
-
|
|
7339
|
+
fs6.fsync(this.fd, (err) => {
|
|
7340
7340
|
this._flushPending = false;
|
|
7341
7341
|
cb(err);
|
|
7342
7342
|
});
|
|
@@ -7438,7 +7438,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7438
7438
|
const fd = this.fd;
|
|
7439
7439
|
this.once("ready", () => {
|
|
7440
7440
|
if (fd !== this.fd) {
|
|
7441
|
-
|
|
7441
|
+
fs6.close(fd, (err) => {
|
|
7442
7442
|
if (err) {
|
|
7443
7443
|
return this.emit("error", err);
|
|
7444
7444
|
}
|
|
@@ -7487,7 +7487,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7487
7487
|
buf = this._bufs[0];
|
|
7488
7488
|
}
|
|
7489
7489
|
try {
|
|
7490
|
-
const n = Buffer.isBuffer(buf) ?
|
|
7490
|
+
const n = Buffer.isBuffer(buf) ? fs6.writeSync(this.fd, buf) : fs6.writeSync(this.fd, buf, "utf8");
|
|
7491
7491
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n);
|
|
7492
7492
|
buf = releasedBufObj.writingBuf;
|
|
7493
7493
|
this._len = releasedBufObj.len;
|
|
@@ -7503,7 +7503,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7503
7503
|
}
|
|
7504
7504
|
}
|
|
7505
7505
|
try {
|
|
7506
|
-
|
|
7506
|
+
fs6.fsyncSync(this.fd);
|
|
7507
7507
|
} catch {
|
|
7508
7508
|
}
|
|
7509
7509
|
}
|
|
@@ -7524,7 +7524,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7524
7524
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
7525
7525
|
}
|
|
7526
7526
|
try {
|
|
7527
|
-
const n =
|
|
7527
|
+
const n = fs6.writeSync(this.fd, buf);
|
|
7528
7528
|
buf = buf.subarray(n);
|
|
7529
7529
|
this._len = Math.max(this._len - n, 0);
|
|
7530
7530
|
if (buf.length <= 0) {
|
|
@@ -7552,13 +7552,13 @@ var require_sonic_boom = __commonJS({
|
|
|
7552
7552
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
7553
7553
|
if (this.sync) {
|
|
7554
7554
|
try {
|
|
7555
|
-
const written = Buffer.isBuffer(this._writingBuf) ?
|
|
7555
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs6.writeSync(this.fd, this._writingBuf) : fs6.writeSync(this.fd, this._writingBuf, "utf8");
|
|
7556
7556
|
release(null, written);
|
|
7557
7557
|
} catch (err) {
|
|
7558
7558
|
release(err);
|
|
7559
7559
|
}
|
|
7560
7560
|
} else {
|
|
7561
|
-
|
|
7561
|
+
fs6.write(this.fd, this._writingBuf, release);
|
|
7562
7562
|
}
|
|
7563
7563
|
}
|
|
7564
7564
|
function actualWriteBuffer() {
|
|
@@ -7567,7 +7567,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7567
7567
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
7568
7568
|
if (this.sync) {
|
|
7569
7569
|
try {
|
|
7570
|
-
const written =
|
|
7570
|
+
const written = fs6.writeSync(this.fd, this._writingBuf);
|
|
7571
7571
|
release(null, written);
|
|
7572
7572
|
} catch (err) {
|
|
7573
7573
|
release(err);
|
|
@@ -7576,7 +7576,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7576
7576
|
if (kCopyBuffer) {
|
|
7577
7577
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
7578
7578
|
}
|
|
7579
|
-
|
|
7579
|
+
fs6.write(this.fd, this._writingBuf, release);
|
|
7580
7580
|
}
|
|
7581
7581
|
}
|
|
7582
7582
|
function actualClose(sonic) {
|
|
@@ -7592,12 +7592,12 @@ var require_sonic_boom = __commonJS({
|
|
|
7592
7592
|
sonic._lens = [];
|
|
7593
7593
|
assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
7594
7594
|
try {
|
|
7595
|
-
|
|
7595
|
+
fs6.fsync(sonic.fd, closeWrapped);
|
|
7596
7596
|
} catch {
|
|
7597
7597
|
}
|
|
7598
7598
|
function closeWrapped() {
|
|
7599
7599
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
7600
|
-
|
|
7600
|
+
fs6.close(sonic.fd, done);
|
|
7601
7601
|
} else {
|
|
7602
7602
|
done();
|
|
7603
7603
|
}
|
|
@@ -8370,7 +8370,7 @@ var require_transport = __commonJS({
|
|
|
8370
8370
|
var { existsSync: existsSync2 } = __require("node:fs");
|
|
8371
8371
|
var getCallers = require_caller();
|
|
8372
8372
|
var { join: join3, isAbsolute, sep } = __require("node:path");
|
|
8373
|
-
var { fileURLToPath } = __require("node:url");
|
|
8373
|
+
var { fileURLToPath: fileURLToPath3 } = __require("node:url");
|
|
8374
8374
|
var sleep = require_atomic_sleep();
|
|
8375
8375
|
var onExit = require_on_exit_leak_free();
|
|
8376
8376
|
var ThreadStream = require_thread_stream();
|
|
@@ -8433,15 +8433,15 @@ var require_transport = __commonJS({
|
|
|
8433
8433
|
if (!unquoted) {
|
|
8434
8434
|
return false;
|
|
8435
8435
|
}
|
|
8436
|
-
let
|
|
8437
|
-
if (
|
|
8436
|
+
let path8 = unquoted;
|
|
8437
|
+
if (path8.startsWith("file://")) {
|
|
8438
8438
|
try {
|
|
8439
|
-
|
|
8439
|
+
path8 = fileURLToPath3(path8);
|
|
8440
8440
|
} catch {
|
|
8441
8441
|
return false;
|
|
8442
8442
|
}
|
|
8443
8443
|
}
|
|
8444
|
-
return isAbsolute(
|
|
8444
|
+
return isAbsolute(path8) && !existsSync2(path8);
|
|
8445
8445
|
}
|
|
8446
8446
|
function stripQuotes(value) {
|
|
8447
8447
|
const first = value[0];
|
|
@@ -10135,7 +10135,7 @@ var require_multistream = __commonJS({
|
|
|
10135
10135
|
var require_pino = __commonJS({
|
|
10136
10136
|
"node_modules/pino/pino.js"(exports, module) {
|
|
10137
10137
|
"use strict";
|
|
10138
|
-
var
|
|
10138
|
+
var os3 = __require("node:os");
|
|
10139
10139
|
var stdSerializers = require_pino_std_serializers();
|
|
10140
10140
|
var caller = require_caller();
|
|
10141
10141
|
var redaction = require_redaction();
|
|
@@ -10182,7 +10182,7 @@ var require_pino = __commonJS({
|
|
|
10182
10182
|
} = symbols;
|
|
10183
10183
|
var { epochTime, nullTime } = time;
|
|
10184
10184
|
var { pid } = process;
|
|
10185
|
-
var hostname =
|
|
10185
|
+
var hostname = os3.hostname();
|
|
10186
10186
|
var defaultErrorSerializer = stdSerializers.err;
|
|
10187
10187
|
var defaultOptions = {
|
|
10188
10188
|
level: "info",
|
|
@@ -17117,8 +17117,8 @@ var require_utils = __commonJS({
|
|
|
17117
17117
|
}
|
|
17118
17118
|
return ind;
|
|
17119
17119
|
}
|
|
17120
|
-
function removeDotSegments(
|
|
17121
|
-
let input =
|
|
17120
|
+
function removeDotSegments(path8) {
|
|
17121
|
+
let input = path8;
|
|
17122
17122
|
const output = [];
|
|
17123
17123
|
let nextSlash = -1;
|
|
17124
17124
|
let len = 0;
|
|
@@ -17370,8 +17370,8 @@ var require_schemes = __commonJS({
|
|
|
17370
17370
|
wsComponent.secure = void 0;
|
|
17371
17371
|
}
|
|
17372
17372
|
if (wsComponent.resourceName) {
|
|
17373
|
-
const [
|
|
17374
|
-
wsComponent.path =
|
|
17373
|
+
const [path8, query2] = wsComponent.resourceName.split("?");
|
|
17374
|
+
wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
|
|
17375
17375
|
wsComponent.query = query2;
|
|
17376
17376
|
wsComponent.resourceName = void 0;
|
|
17377
17377
|
}
|
|
@@ -22308,8 +22308,8 @@ var require_utils2 = __commonJS({
|
|
|
22308
22308
|
}
|
|
22309
22309
|
return ind;
|
|
22310
22310
|
}
|
|
22311
|
-
function removeDotSegments(
|
|
22312
|
-
let input =
|
|
22311
|
+
function removeDotSegments(path8) {
|
|
22312
|
+
let input = path8;
|
|
22313
22313
|
const output = [];
|
|
22314
22314
|
let nextSlash = -1;
|
|
22315
22315
|
let len = 0;
|
|
@@ -22654,8 +22654,8 @@ var require_schemes2 = __commonJS({
|
|
|
22654
22654
|
wsComponent.secure = void 0;
|
|
22655
22655
|
}
|
|
22656
22656
|
if (wsComponent.resourceName) {
|
|
22657
|
-
const [
|
|
22658
|
-
wsComponent.path =
|
|
22657
|
+
const [path8, query2] = wsComponent.resourceName.split("?");
|
|
22658
|
+
wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
|
|
22659
22659
|
wsComponent.query = query2;
|
|
22660
22660
|
wsComponent.resourceName = void 0;
|
|
22661
22661
|
}
|
|
@@ -23431,12 +23431,12 @@ var require_dist = __commonJS({
|
|
|
23431
23431
|
throw new Error(`Unknown format "${name}"`);
|
|
23432
23432
|
return f;
|
|
23433
23433
|
};
|
|
23434
|
-
function addFormats(ajv, list,
|
|
23434
|
+
function addFormats(ajv, list, fs6, exportName) {
|
|
23435
23435
|
var _a;
|
|
23436
23436
|
var _b;
|
|
23437
23437
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
23438
23438
|
for (const f of list)
|
|
23439
|
-
ajv.addFormat(f,
|
|
23439
|
+
ajv.addFormat(f, fs6[f]);
|
|
23440
23440
|
}
|
|
23441
23441
|
module.exports = exports = formatsPlugin;
|
|
23442
23442
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -24139,8 +24139,8 @@ var require_utils3 = __commonJS({
|
|
|
24139
24139
|
}
|
|
24140
24140
|
return ind;
|
|
24141
24141
|
}
|
|
24142
|
-
function removeDotSegments(
|
|
24143
|
-
let input =
|
|
24142
|
+
function removeDotSegments(path8) {
|
|
24143
|
+
let input = path8;
|
|
24144
24144
|
const output = [];
|
|
24145
24145
|
let nextSlash = -1;
|
|
24146
24146
|
let len = 0;
|
|
@@ -24485,8 +24485,8 @@ var require_schemes3 = __commonJS({
|
|
|
24485
24485
|
wsComponent.secure = void 0;
|
|
24486
24486
|
}
|
|
24487
24487
|
if (wsComponent.resourceName) {
|
|
24488
|
-
const [
|
|
24489
|
-
wsComponent.path =
|
|
24488
|
+
const [path8, query2] = wsComponent.resourceName.split("?");
|
|
24489
|
+
wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
|
|
24490
24490
|
wsComponent.query = query2;
|
|
24491
24491
|
wsComponent.resourceName = void 0;
|
|
24492
24492
|
}
|
|
@@ -32003,13 +32003,13 @@ var require_node = __commonJS({
|
|
|
32003
32003
|
this.staticChildrenNodes[index] = node;
|
|
32004
32004
|
}
|
|
32005
32005
|
}
|
|
32006
|
-
findStaticMatchingChild(
|
|
32007
|
-
const charCode =
|
|
32006
|
+
findStaticMatchingChild(path8, pathIndex) {
|
|
32007
|
+
const charCode = path8.charCodeAt(pathIndex);
|
|
32008
32008
|
const charCodes = this.staticChildrenCharCodes;
|
|
32009
32009
|
for (let i = 0; i < charCodes.length; i++) {
|
|
32010
32010
|
if (charCodes[i] === charCode) {
|
|
32011
32011
|
const staticChild = this.staticChildrenNodes[i];
|
|
32012
|
-
if (staticChild.matchPrefix(
|
|
32012
|
+
if (staticChild.matchPrefix(path8, pathIndex)) {
|
|
32013
32013
|
return staticChild;
|
|
32014
32014
|
}
|
|
32015
32015
|
return null;
|
|
@@ -32017,34 +32017,34 @@ var require_node = __commonJS({
|
|
|
32017
32017
|
}
|
|
32018
32018
|
return null;
|
|
32019
32019
|
}
|
|
32020
|
-
getStaticChild(
|
|
32021
|
-
if (
|
|
32020
|
+
getStaticChild(path8, pathIndex = 0) {
|
|
32021
|
+
if (path8.length === pathIndex) {
|
|
32022
32022
|
return this;
|
|
32023
32023
|
}
|
|
32024
|
-
const staticChild = this.findStaticMatchingChild(
|
|
32024
|
+
const staticChild = this.findStaticMatchingChild(path8, pathIndex);
|
|
32025
32025
|
if (staticChild) {
|
|
32026
|
-
return staticChild.getStaticChild(
|
|
32026
|
+
return staticChild.getStaticChild(path8, pathIndex + staticChild.prefix.length);
|
|
32027
32027
|
}
|
|
32028
32028
|
return null;
|
|
32029
32029
|
}
|
|
32030
|
-
createStaticChild(
|
|
32031
|
-
if (
|
|
32030
|
+
createStaticChild(path8) {
|
|
32031
|
+
if (path8.length === 0) {
|
|
32032
32032
|
return this;
|
|
32033
32033
|
}
|
|
32034
|
-
const childIndex = this.staticChildrenCharCodes.indexOf(
|
|
32034
|
+
const childIndex = this.staticChildrenCharCodes.indexOf(path8.charCodeAt(0));
|
|
32035
32035
|
let staticChild = childIndex === -1 ? void 0 : this.staticChildrenNodes[childIndex];
|
|
32036
32036
|
if (staticChild) {
|
|
32037
32037
|
let i = 1;
|
|
32038
32038
|
for (; i < staticChild.prefix.length; i++) {
|
|
32039
|
-
if (
|
|
32039
|
+
if (path8.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) {
|
|
32040
32040
|
staticChild = staticChild.split(this, i);
|
|
32041
32041
|
break;
|
|
32042
32042
|
}
|
|
32043
32043
|
}
|
|
32044
|
-
return staticChild.createStaticChild(
|
|
32044
|
+
return staticChild.createStaticChild(path8.slice(i));
|
|
32045
32045
|
}
|
|
32046
|
-
const node = new StaticNode(
|
|
32047
|
-
this.setStaticChild(
|
|
32046
|
+
const node = new StaticNode(path8);
|
|
32047
|
+
this.setStaticChild(path8.charAt(0), node);
|
|
32048
32048
|
return node;
|
|
32049
32049
|
}
|
|
32050
32050
|
};
|
|
@@ -32104,8 +32104,8 @@ var require_node = __commonJS({
|
|
|
32104
32104
|
parentNode.setStaticChild(parentPrefix.charAt(0), staticNode);
|
|
32105
32105
|
return staticNode;
|
|
32106
32106
|
}
|
|
32107
|
-
getNextNode(
|
|
32108
|
-
let node = this.findStaticMatchingChild(
|
|
32107
|
+
getNextNode(path8, pathIndex, nodeStack, paramsCount) {
|
|
32108
|
+
let node = this.findStaticMatchingChild(path8, pathIndex);
|
|
32109
32109
|
let parametricBrotherNodeIndex = 0;
|
|
32110
32110
|
if (node === null) {
|
|
32111
32111
|
if (this.parametricChildren.length === 0) {
|
|
@@ -32152,8 +32152,8 @@ var require_node = __commonJS({
|
|
|
32152
32152
|
this.kind = NODE_TYPES.PARAMETRIC;
|
|
32153
32153
|
this.nodePaths = /* @__PURE__ */ new Set([nodePath]);
|
|
32154
32154
|
}
|
|
32155
|
-
getNextNode(
|
|
32156
|
-
return this.findStaticMatchingChild(
|
|
32155
|
+
getNextNode(path8, pathIndex) {
|
|
32156
|
+
return this.findStaticMatchingChild(path8, pathIndex);
|
|
32157
32157
|
}
|
|
32158
32158
|
};
|
|
32159
32159
|
var WildcardNode = class extends Node {
|
|
@@ -32509,81 +32509,81 @@ var require_url_sanitizer = __commonJS({
|
|
|
32509
32509
|
return String.fromCharCode(charCode);
|
|
32510
32510
|
}
|
|
32511
32511
|
var MIN_NATIVE_SCAN_LENGTH = 12;
|
|
32512
|
-
function safeDecodeURI(
|
|
32513
|
-
if (
|
|
32514
|
-
return safeDecodeURINativeScan(
|
|
32512
|
+
function safeDecodeURI(path8, useSemicolonDelimiter) {
|
|
32513
|
+
if (path8.length >= MIN_NATIVE_SCAN_LENGTH) {
|
|
32514
|
+
return safeDecodeURINativeScan(path8, useSemicolonDelimiter);
|
|
32515
32515
|
}
|
|
32516
|
-
return safeDecodeURICharScan(
|
|
32516
|
+
return safeDecodeURICharScan(path8, useSemicolonDelimiter, 1);
|
|
32517
32517
|
}
|
|
32518
|
-
function safeDecodeURINativeScan(
|
|
32519
|
-
const percentIndex =
|
|
32520
|
-
let delimIndex =
|
|
32521
|
-
const hashIndex =
|
|
32518
|
+
function safeDecodeURINativeScan(path8, useSemicolonDelimiter) {
|
|
32519
|
+
const percentIndex = path8.indexOf("%", 1);
|
|
32520
|
+
let delimIndex = path8.indexOf("?", 1);
|
|
32521
|
+
const hashIndex = path8.indexOf("#", 1);
|
|
32522
32522
|
if (hashIndex !== -1 && (delimIndex === -1 || hashIndex < delimIndex)) {
|
|
32523
32523
|
delimIndex = hashIndex;
|
|
32524
32524
|
}
|
|
32525
32525
|
if (useSemicolonDelimiter) {
|
|
32526
|
-
const semicolonIndex =
|
|
32526
|
+
const semicolonIndex = path8.indexOf(";", 1);
|
|
32527
32527
|
if (semicolonIndex !== -1 && (delimIndex === -1 || semicolonIndex < delimIndex)) {
|
|
32528
32528
|
delimIndex = semicolonIndex;
|
|
32529
32529
|
}
|
|
32530
32530
|
}
|
|
32531
32531
|
if (percentIndex === -1 || delimIndex !== -1 && percentIndex > delimIndex) {
|
|
32532
32532
|
if (delimIndex === -1) {
|
|
32533
|
-
return { path:
|
|
32533
|
+
return { path: path8, querystring: "", shouldDecodeParam: false };
|
|
32534
32534
|
}
|
|
32535
32535
|
return {
|
|
32536
|
-
path:
|
|
32537
|
-
querystring:
|
|
32536
|
+
path: path8.slice(0, delimIndex),
|
|
32537
|
+
querystring: path8.slice(delimIndex + 1),
|
|
32538
32538
|
shouldDecodeParam: false
|
|
32539
32539
|
};
|
|
32540
32540
|
}
|
|
32541
|
-
return safeDecodeURIPercentScan(
|
|
32541
|
+
return safeDecodeURIPercentScan(path8, useSemicolonDelimiter, percentIndex);
|
|
32542
32542
|
}
|
|
32543
|
-
function safeDecodeURICharScan(
|
|
32544
|
-
for (let i = startIndex; i <
|
|
32545
|
-
const charCode =
|
|
32543
|
+
function safeDecodeURICharScan(path8, useSemicolonDelimiter, startIndex) {
|
|
32544
|
+
for (let i = startIndex; i < path8.length; i++) {
|
|
32545
|
+
const charCode = path8.charCodeAt(i);
|
|
32546
32546
|
if (charCode === 37) {
|
|
32547
|
-
return safeDecodeURIPercentScan(
|
|
32547
|
+
return safeDecodeURIPercentScan(path8, useSemicolonDelimiter, i);
|
|
32548
32548
|
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
32549
32549
|
return {
|
|
32550
|
-
path:
|
|
32551
|
-
querystring:
|
|
32550
|
+
path: path8.slice(0, i),
|
|
32551
|
+
querystring: path8.slice(i + 1),
|
|
32552
32552
|
shouldDecodeParam: false
|
|
32553
32553
|
};
|
|
32554
32554
|
}
|
|
32555
32555
|
}
|
|
32556
|
-
return { path:
|
|
32556
|
+
return { path: path8, querystring: "", shouldDecodeParam: false };
|
|
32557
32557
|
}
|
|
32558
|
-
function reencodePercentChar(
|
|
32559
|
-
return
|
|
32558
|
+
function reencodePercentChar(path8, index) {
|
|
32559
|
+
return path8.slice(0, index + 1) + "25" + path8.slice(index + 1);
|
|
32560
32560
|
}
|
|
32561
|
-
function safeDecodeURIPercentScan(
|
|
32561
|
+
function safeDecodeURIPercentScan(path8, useSemicolonDelimiter, startIndex) {
|
|
32562
32562
|
let shouldDecode = false;
|
|
32563
32563
|
let shouldDecodeParam = false;
|
|
32564
32564
|
let querystring = "";
|
|
32565
|
-
for (let i = startIndex; i <
|
|
32566
|
-
const charCode =
|
|
32565
|
+
for (let i = startIndex; i < path8.length; i++) {
|
|
32566
|
+
const charCode = path8.charCodeAt(i);
|
|
32567
32567
|
if (charCode === 37) {
|
|
32568
|
-
const componentCharCode = decodeComponentCharCode(
|
|
32568
|
+
const componentCharCode = decodeComponentCharCode(path8.charCodeAt(i + 1), path8.charCodeAt(i + 2));
|
|
32569
32569
|
if (componentCharCode === 0) {
|
|
32570
32570
|
shouldDecode = true;
|
|
32571
32571
|
} else {
|
|
32572
32572
|
shouldDecodeParam = true;
|
|
32573
32573
|
if (componentCharCode === 37) {
|
|
32574
32574
|
shouldDecode = true;
|
|
32575
|
-
|
|
32575
|
+
path8 = reencodePercentChar(path8, i);
|
|
32576
32576
|
i += 2;
|
|
32577
32577
|
}
|
|
32578
32578
|
i += 2;
|
|
32579
32579
|
}
|
|
32580
32580
|
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
32581
|
-
querystring =
|
|
32582
|
-
|
|
32581
|
+
querystring = path8.slice(i + 1);
|
|
32582
|
+
path8 = path8.slice(0, i);
|
|
32583
32583
|
break;
|
|
32584
32584
|
}
|
|
32585
32585
|
}
|
|
32586
|
-
const decodedPath = shouldDecode ? decodeURI(
|
|
32586
|
+
const decodedPath = shouldDecode ? decodeURI(path8) : path8;
|
|
32587
32587
|
return { path: decodedPath, querystring, shouldDecodeParam };
|
|
32588
32588
|
}
|
|
32589
32589
|
function safeDecodeURIComponent(uriComponent) {
|
|
@@ -32678,7 +32678,7 @@ var require_find_my_way = __commonJS({
|
|
|
32678
32678
|
this.trees = /* @__PURE__ */ Object.create(null);
|
|
32679
32679
|
this._treeGET = null;
|
|
32680
32680
|
}
|
|
32681
|
-
Router.prototype.on = function on(method,
|
|
32681
|
+
Router.prototype.on = function on(method, path8, opts, handler, store) {
|
|
32682
32682
|
if (typeof opts === "function") {
|
|
32683
32683
|
if (handler !== void 0) {
|
|
32684
32684
|
store = handler;
|
|
@@ -32686,34 +32686,34 @@ var require_find_my_way = __commonJS({
|
|
|
32686
32686
|
handler = opts;
|
|
32687
32687
|
opts = {};
|
|
32688
32688
|
}
|
|
32689
|
-
assert(typeof
|
|
32690
|
-
assert(
|
|
32691
|
-
assert(
|
|
32689
|
+
assert(typeof path8 === "string", "Path should be a string");
|
|
32690
|
+
assert(path8.length > 0, "The path could not be empty");
|
|
32691
|
+
assert(path8[0] === "/" || path8[0] === "*", "The first character of a path should be `/` or `*`");
|
|
32692
32692
|
assert(typeof handler === "function", "Handler should be a function");
|
|
32693
|
-
const optionalParamMatch =
|
|
32693
|
+
const optionalParamMatch = path8.match(OPTIONAL_PARAM_REGEXP);
|
|
32694
32694
|
if (optionalParamMatch) {
|
|
32695
|
-
assert(
|
|
32696
|
-
const pathFull =
|
|
32697
|
-
const pathOptional =
|
|
32695
|
+
assert(path8.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
32696
|
+
const pathFull = path8.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
32697
|
+
const pathOptional = path8.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
|
|
32698
32698
|
this.on(method, pathFull, opts, handler, store);
|
|
32699
32699
|
this.on(method, pathOptional, opts, handler, store);
|
|
32700
32700
|
return;
|
|
32701
32701
|
}
|
|
32702
|
-
const route =
|
|
32702
|
+
const route = path8;
|
|
32703
32703
|
if (this.ignoreDuplicateSlashes) {
|
|
32704
|
-
|
|
32704
|
+
path8 = removeDuplicateSlashes(path8);
|
|
32705
32705
|
}
|
|
32706
32706
|
if (this.ignoreTrailingSlash) {
|
|
32707
|
-
|
|
32707
|
+
path8 = trimLastSlash(path8);
|
|
32708
32708
|
}
|
|
32709
32709
|
const methods = Array.isArray(method) ? method : [method];
|
|
32710
32710
|
for (const method2 of methods) {
|
|
32711
32711
|
assert(typeof method2 === "string", "Method should be a string");
|
|
32712
32712
|
assert(httpMethods.includes(method2), `Method '${method2}' is not an http method.`);
|
|
32713
|
-
this._on(method2,
|
|
32713
|
+
this._on(method2, path8, opts, handler, store, route);
|
|
32714
32714
|
}
|
|
32715
32715
|
};
|
|
32716
|
-
Router.prototype._on = function _on(method,
|
|
32716
|
+
Router.prototype._on = function _on(method, path8, opts, handler, store) {
|
|
32717
32717
|
let constraints = {};
|
|
32718
32718
|
if (opts.constraints !== void 0) {
|
|
32719
32719
|
assert(typeof opts.constraints === "object" && opts.constraints !== null, "Constraints should be an object");
|
|
@@ -32726,7 +32726,7 @@ var require_find_my_way = __commonJS({
|
|
|
32726
32726
|
if (this.trees[method] === void 0) {
|
|
32727
32727
|
this.trees[method] = new StaticNode("/");
|
|
32728
32728
|
}
|
|
32729
|
-
let pattern =
|
|
32729
|
+
let pattern = path8;
|
|
32730
32730
|
if (pattern === "*" && this.trees[method].prefix.length !== 0) {
|
|
32731
32731
|
const currentRoot = this.trees[method];
|
|
32732
32732
|
this.trees[method] = new StaticNode("");
|
|
@@ -32834,19 +32834,19 @@ var require_find_my_way = __commonJS({
|
|
|
32834
32834
|
throw new Error(`Method '${method}' already declared for route '${pattern}' with constraints '${JSON.stringify(constraints)}'`);
|
|
32835
32835
|
}
|
|
32836
32836
|
}
|
|
32837
|
-
const route = { method, path:
|
|
32837
|
+
const route = { method, path: path8, pattern, params, opts, handler, store };
|
|
32838
32838
|
this.routes.push(route);
|
|
32839
32839
|
currentNode.addRoute(route, this.constrainer);
|
|
32840
32840
|
};
|
|
32841
|
-
Router.prototype.hasRoute = function hasRoute(method,
|
|
32842
|
-
const route = this.findRoute(method,
|
|
32841
|
+
Router.prototype.hasRoute = function hasRoute(method, path8, constraints) {
|
|
32842
|
+
const route = this.findRoute(method, path8, constraints);
|
|
32843
32843
|
return route !== null;
|
|
32844
32844
|
};
|
|
32845
|
-
Router.prototype.findRoute = function findNode(method,
|
|
32845
|
+
Router.prototype.findRoute = function findNode(method, path8, constraints = {}) {
|
|
32846
32846
|
if (this.trees[method] === void 0) {
|
|
32847
32847
|
return null;
|
|
32848
32848
|
}
|
|
32849
|
-
let pattern =
|
|
32849
|
+
let pattern = path8;
|
|
32850
32850
|
let currentNode = this.trees[method];
|
|
32851
32851
|
let parentNodePathIndex = currentNode.prefix.length;
|
|
32852
32852
|
const params = [];
|
|
@@ -32967,39 +32967,39 @@ var require_find_my_way = __commonJS({
|
|
|
32967
32967
|
this._treeGET = null;
|
|
32968
32968
|
this.routes = [];
|
|
32969
32969
|
};
|
|
32970
|
-
Router.prototype.off = function off(method,
|
|
32971
|
-
assert(typeof
|
|
32972
|
-
assert(
|
|
32973
|
-
assert(
|
|
32970
|
+
Router.prototype.off = function off(method, path8, constraints) {
|
|
32971
|
+
assert(typeof path8 === "string", "Path should be a string");
|
|
32972
|
+
assert(path8.length > 0, "The path could not be empty");
|
|
32973
|
+
assert(path8[0] === "/" || path8[0] === "*", "The first character of a path should be `/` or `*`");
|
|
32974
32974
|
assert(
|
|
32975
32975
|
typeof constraints === "undefined" || typeof constraints === "object" && !Array.isArray(constraints) && constraints !== null,
|
|
32976
32976
|
"Constraints should be an object or undefined."
|
|
32977
32977
|
);
|
|
32978
|
-
const optionalParamMatch =
|
|
32978
|
+
const optionalParamMatch = path8.match(OPTIONAL_PARAM_REGEXP);
|
|
32979
32979
|
if (optionalParamMatch) {
|
|
32980
|
-
assert(
|
|
32981
|
-
const pathFull =
|
|
32982
|
-
const pathOptional =
|
|
32980
|
+
assert(path8.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
32981
|
+
const pathFull = path8.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
32982
|
+
const pathOptional = path8.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
|
|
32983
32983
|
this.off(method, pathFull, constraints);
|
|
32984
32984
|
this.off(method, pathOptional, constraints);
|
|
32985
32985
|
return;
|
|
32986
32986
|
}
|
|
32987
32987
|
if (this.ignoreDuplicateSlashes) {
|
|
32988
|
-
|
|
32988
|
+
path8 = removeDuplicateSlashes(path8);
|
|
32989
32989
|
}
|
|
32990
32990
|
if (this.ignoreTrailingSlash) {
|
|
32991
|
-
|
|
32991
|
+
path8 = trimLastSlash(path8);
|
|
32992
32992
|
}
|
|
32993
32993
|
const methods = Array.isArray(method) ? method : [method];
|
|
32994
32994
|
for (const method2 of methods) {
|
|
32995
|
-
this._off(method2,
|
|
32995
|
+
this._off(method2, path8, constraints);
|
|
32996
32996
|
}
|
|
32997
32997
|
};
|
|
32998
|
-
Router.prototype._off = function _off(method,
|
|
32998
|
+
Router.prototype._off = function _off(method, path8, constraints) {
|
|
32999
32999
|
assert(typeof method === "string", "Method should be a string");
|
|
33000
33000
|
assert(httpMethods.includes(method), `Method '${method}' is not an http method.`);
|
|
33001
33001
|
function matcherWithoutConstraints(route) {
|
|
33002
|
-
return method !== route.method ||
|
|
33002
|
+
return method !== route.method || path8 !== route.path;
|
|
33003
33003
|
}
|
|
33004
33004
|
function matcherWithConstraints(route) {
|
|
33005
33005
|
return matcherWithoutConstraints(route) || !deepEqual(constraints, route.opts.constraints || {});
|
|
@@ -33036,37 +33036,37 @@ var require_find_my_way = __commonJS({
|
|
|
33036
33036
|
if (handle === null) return this._defaultRoute(req, res, ctx);
|
|
33037
33037
|
return ctx === void 0 ? handle.handler(req, res, handle.params, handle.store, handle.searchParams) : handle.handler.call(ctx, req, res, handle.params, handle.store, handle.searchParams);
|
|
33038
33038
|
};
|
|
33039
|
-
Router.prototype.find = function find(method,
|
|
33039
|
+
Router.prototype.find = function find(method, path8, derivedConstraints) {
|
|
33040
33040
|
let currentNode = method === "GET" ? this._treeGET : this.trees[method];
|
|
33041
33041
|
if (currentNode == null) return null;
|
|
33042
|
-
if (
|
|
33043
|
-
|
|
33042
|
+
if (path8.charCodeAt(0) !== 47) {
|
|
33043
|
+
path8 = path8.replace(FULL_PATH_REGEXP, "/");
|
|
33044
33044
|
}
|
|
33045
33045
|
if (this.ignoreDuplicateSlashes) {
|
|
33046
|
-
|
|
33046
|
+
path8 = removeDuplicateSlashes(path8);
|
|
33047
33047
|
}
|
|
33048
33048
|
let sanitizedUrl;
|
|
33049
33049
|
let querystring2;
|
|
33050
33050
|
let shouldDecodeParam;
|
|
33051
33051
|
try {
|
|
33052
|
-
sanitizedUrl =
|
|
33053
|
-
|
|
33052
|
+
sanitizedUrl = path8.length >= MIN_NATIVE_SCAN_LENGTH ? safeDecodeURINativeScan(path8, this.useSemicolonDelimiter) : safeDecodeURICharScan(path8, this.useSemicolonDelimiter, 1);
|
|
33053
|
+
path8 = sanitizedUrl.path;
|
|
33054
33054
|
querystring2 = sanitizedUrl.querystring;
|
|
33055
33055
|
shouldDecodeParam = sanitizedUrl.shouldDecodeParam;
|
|
33056
33056
|
} catch (error) {
|
|
33057
|
-
return this._onBadUrl(
|
|
33057
|
+
return this._onBadUrl(path8);
|
|
33058
33058
|
}
|
|
33059
33059
|
if (this.ignoreTrailingSlash) {
|
|
33060
|
-
|
|
33060
|
+
path8 = trimLastSlash(path8);
|
|
33061
33061
|
}
|
|
33062
|
-
const originPath =
|
|
33062
|
+
const originPath = path8;
|
|
33063
33063
|
if (this.caseSensitive === false) {
|
|
33064
|
-
|
|
33064
|
+
path8 = path8.toLowerCase();
|
|
33065
33065
|
}
|
|
33066
33066
|
const maxParamLength = this.maxParamLength;
|
|
33067
33067
|
let pathIndex = currentNode.prefix.length;
|
|
33068
33068
|
const params = [];
|
|
33069
|
-
const pathLen =
|
|
33069
|
+
const pathLen = path8.length;
|
|
33070
33070
|
const brothersNodesStack = [];
|
|
33071
33071
|
let maxParamLengthExceeded = false;
|
|
33072
33072
|
while (true) {
|
|
@@ -33081,7 +33081,7 @@ var require_find_my_way = __commonJS({
|
|
|
33081
33081
|
};
|
|
33082
33082
|
}
|
|
33083
33083
|
}
|
|
33084
|
-
let node = currentNode.getNextNode(
|
|
33084
|
+
let node = currentNode.getNextNode(path8, pathIndex, brothersNodesStack, params.length);
|
|
33085
33085
|
if (node === null) {
|
|
33086
33086
|
if (brothersNodesStack.length === 0) {
|
|
33087
33087
|
if (maxParamLengthExceeded && this.onMaxParamLength) {
|
|
@@ -33182,8 +33182,8 @@ var require_find_my_way = __commonJS({
|
|
|
33182
33182
|
Router.prototype._rebuild = function(routes) {
|
|
33183
33183
|
this.reset();
|
|
33184
33184
|
for (const route of routes) {
|
|
33185
|
-
const { method, path:
|
|
33186
|
-
this._on(method,
|
|
33185
|
+
const { method, path: path8, opts, handler, store } = route;
|
|
33186
|
+
this._on(method, path8, opts, handler, store);
|
|
33187
33187
|
}
|
|
33188
33188
|
};
|
|
33189
33189
|
Router.prototype._defaultRoute = function(req, res, ctx) {
|
|
@@ -33194,24 +33194,24 @@ var require_find_my_way = __commonJS({
|
|
|
33194
33194
|
res.end();
|
|
33195
33195
|
}
|
|
33196
33196
|
};
|
|
33197
|
-
Router.prototype._onBadUrl = function(
|
|
33197
|
+
Router.prototype._onBadUrl = function(path8) {
|
|
33198
33198
|
if (this.onBadUrl === null) {
|
|
33199
33199
|
return null;
|
|
33200
33200
|
}
|
|
33201
33201
|
const onBadUrl = this.onBadUrl;
|
|
33202
33202
|
return {
|
|
33203
|
-
handler: (req, res, ctx) => onBadUrl(
|
|
33203
|
+
handler: (req, res, ctx) => onBadUrl(path8, req, res),
|
|
33204
33204
|
params: {},
|
|
33205
33205
|
store: null
|
|
33206
33206
|
};
|
|
33207
33207
|
};
|
|
33208
|
-
Router.prototype._onMaxParamLength = function(
|
|
33208
|
+
Router.prototype._onMaxParamLength = function(path8) {
|
|
33209
33209
|
if (this.onMaxParamLength === null) {
|
|
33210
33210
|
return null;
|
|
33211
33211
|
}
|
|
33212
33212
|
const onMaxParamLength = this.onMaxParamLength;
|
|
33213
33213
|
return {
|
|
33214
|
-
handler: (req, res, ctx) => onMaxParamLength(
|
|
33214
|
+
handler: (req, res, ctx) => onMaxParamLength(path8, req, res),
|
|
33215
33215
|
params: {},
|
|
33216
33216
|
store: null
|
|
33217
33217
|
};
|
|
@@ -33243,12 +33243,12 @@ var require_find_my_way = __commonJS({
|
|
|
33243
33243
|
if (!httpMethods.hasOwnProperty(i)) continue;
|
|
33244
33244
|
const m = httpMethods[i];
|
|
33245
33245
|
const methodName = m.toLowerCase();
|
|
33246
|
-
Router.prototype[methodName] = function(
|
|
33247
|
-
return this.on(m,
|
|
33246
|
+
Router.prototype[methodName] = function(path8, handler, store) {
|
|
33247
|
+
return this.on(m, path8, handler, store);
|
|
33248
33248
|
};
|
|
33249
33249
|
}
|
|
33250
|
-
Router.prototype.all = function(
|
|
33251
|
-
this.on(httpMethods,
|
|
33250
|
+
Router.prototype.all = function(path8, handler, store) {
|
|
33251
|
+
this.on(httpMethods, path8, handler, store);
|
|
33252
33252
|
};
|
|
33253
33253
|
Router.sanitizeUrlPath = function sanitizeUrlPath(url, useSemicolonDelimiter) {
|
|
33254
33254
|
const decoded = safeDecodeURI(url, useSemicolonDelimiter);
|
|
@@ -33263,14 +33263,14 @@ var require_find_my_way = __commonJS({
|
|
|
33263
33263
|
function escapeRegExp(string) {
|
|
33264
33264
|
return string.replace(ESCAPE_REGEXP, "\\$&");
|
|
33265
33265
|
}
|
|
33266
|
-
function removeDuplicateSlashes(
|
|
33267
|
-
return
|
|
33266
|
+
function removeDuplicateSlashes(path8) {
|
|
33267
|
+
return path8.indexOf("//") !== -1 ? path8.replace(REMOVE_DUPLICATE_SLASHES_REGEXP, "/") : path8;
|
|
33268
33268
|
}
|
|
33269
|
-
function trimLastSlash(
|
|
33270
|
-
if (
|
|
33271
|
-
return
|
|
33269
|
+
function trimLastSlash(path8) {
|
|
33270
|
+
if (path8.length > 1 && path8.charCodeAt(path8.length - 1) === 47) {
|
|
33271
|
+
return path8.slice(0, -1);
|
|
33272
33272
|
}
|
|
33273
|
-
return
|
|
33273
|
+
return path8;
|
|
33274
33274
|
}
|
|
33275
33275
|
function trimRegExpStartAndEnd(regexString) {
|
|
33276
33276
|
if (regexString.charCodeAt(1) === 94) {
|
|
@@ -33281,22 +33281,22 @@ var require_find_my_way = __commonJS({
|
|
|
33281
33281
|
}
|
|
33282
33282
|
return regexString;
|
|
33283
33283
|
}
|
|
33284
|
-
function getClosingParenthensePosition(
|
|
33284
|
+
function getClosingParenthensePosition(path8, idx) {
|
|
33285
33285
|
let parentheses = 1;
|
|
33286
|
-
while (idx <
|
|
33286
|
+
while (idx < path8.length) {
|
|
33287
33287
|
idx++;
|
|
33288
|
-
if (
|
|
33288
|
+
if (path8.charCodeAt(idx) === 92) {
|
|
33289
33289
|
idx++;
|
|
33290
33290
|
continue;
|
|
33291
33291
|
}
|
|
33292
|
-
if (
|
|
33292
|
+
if (path8.charCodeAt(idx) === 41) {
|
|
33293
33293
|
parentheses--;
|
|
33294
|
-
} else if (
|
|
33294
|
+
} else if (path8.charCodeAt(idx) === 40) {
|
|
33295
33295
|
parentheses++;
|
|
33296
33296
|
}
|
|
33297
33297
|
if (!parentheses) return idx;
|
|
33298
33298
|
}
|
|
33299
|
-
throw new TypeError('Invalid regexp expression in "' +
|
|
33299
|
+
throw new TypeError('Invalid regexp expression in "' + path8 + '"');
|
|
33300
33300
|
}
|
|
33301
33301
|
function defaultBuildPrettyMeta(route) {
|
|
33302
33302
|
if (!route) return {};
|
|
@@ -33529,12 +33529,12 @@ var require_route = __commonJS({
|
|
|
33529
33529
|
function route({ options: options2, isFastify }) {
|
|
33530
33530
|
throwIfAlreadyStarted("Cannot add route!");
|
|
33531
33531
|
const opts = { ...options2 };
|
|
33532
|
-
const
|
|
33532
|
+
const path8 = opts.url || opts.path || "";
|
|
33533
33533
|
if (!opts.handler) {
|
|
33534
|
-
throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method,
|
|
33534
|
+
throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method, path8);
|
|
33535
33535
|
}
|
|
33536
33536
|
if (opts.errorHandler !== void 0 && typeof opts.errorHandler !== "function") {
|
|
33537
|
-
throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method,
|
|
33537
|
+
throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method, path8);
|
|
33538
33538
|
}
|
|
33539
33539
|
validateBodyLimitOption(opts.bodyLimit);
|
|
33540
33540
|
validateHandlerTimeoutOption(opts.handlerTimeout);
|
|
@@ -33544,22 +33544,22 @@ var require_route = __commonJS({
|
|
|
33544
33544
|
if (Array.isArray(opts.method)) {
|
|
33545
33545
|
for (let i = 0; i < opts.method.length; ++i) {
|
|
33546
33546
|
opts.method[i] = normalizeAndValidateMethod.call(this, opts.method[i]);
|
|
33547
|
-
validateSchemaBodyOption.call(this, opts.method[i],
|
|
33547
|
+
validateSchemaBodyOption.call(this, opts.method[i], path8, opts.schema);
|
|
33548
33548
|
isGetRoute = opts.method.includes("GET");
|
|
33549
33549
|
isHeadRoute = opts.method.includes("HEAD");
|
|
33550
33550
|
}
|
|
33551
33551
|
} else {
|
|
33552
33552
|
opts.method = normalizeAndValidateMethod.call(this, opts.method);
|
|
33553
|
-
validateSchemaBodyOption.call(this, opts.method,
|
|
33553
|
+
validateSchemaBodyOption.call(this, opts.method, path8, opts.schema);
|
|
33554
33554
|
isGetRoute = opts.method === "GET";
|
|
33555
33555
|
isHeadRoute = opts.method === "HEAD";
|
|
33556
33556
|
}
|
|
33557
33557
|
const headOpts = shouldExposeHead && isGetRoute ? { ...options2 } : null;
|
|
33558
33558
|
const prefix = this[kRoutePrefix];
|
|
33559
|
-
if (
|
|
33559
|
+
if (path8 === "/" && prefix.length > 0 && opts.method !== "HEAD") {
|
|
33560
33560
|
switch (opts.prefixTrailingSlash) {
|
|
33561
33561
|
case "slash":
|
|
33562
|
-
addNewRoute.call(this, { path:
|
|
33562
|
+
addNewRoute.call(this, { path: path8, isFastify });
|
|
33563
33563
|
break;
|
|
33564
33564
|
case "no-slash":
|
|
33565
33565
|
addNewRoute.call(this, { path: "", isFastify });
|
|
@@ -33568,20 +33568,20 @@ var require_route = __commonJS({
|
|
|
33568
33568
|
default:
|
|
33569
33569
|
addNewRoute.call(this, { path: "", isFastify });
|
|
33570
33570
|
if (ignoreTrailingSlash !== true && (ignoreDuplicateSlashes !== true || !prefix.endsWith("/"))) {
|
|
33571
|
-
addNewRoute.call(this, { path:
|
|
33571
|
+
addNewRoute.call(this, { path: path8, prefixing: true, isFastify });
|
|
33572
33572
|
}
|
|
33573
33573
|
}
|
|
33574
|
-
} else if (
|
|
33575
|
-
addNewRoute.call(this, { path:
|
|
33574
|
+
} else if (path8[0] === "/" && prefix.endsWith("/")) {
|
|
33575
|
+
addNewRoute.call(this, { path: path8.slice(1), isFastify });
|
|
33576
33576
|
} else {
|
|
33577
|
-
addNewRoute.call(this, { path:
|
|
33577
|
+
addNewRoute.call(this, { path: path8, isFastify });
|
|
33578
33578
|
}
|
|
33579
33579
|
return this;
|
|
33580
|
-
function addNewRoute({ path:
|
|
33581
|
-
const url = prefix +
|
|
33580
|
+
function addNewRoute({ path: path9, prefixing = false, isFastify: isFastify2 = false }) {
|
|
33581
|
+
const url = prefix + path9;
|
|
33582
33582
|
opts.url = url;
|
|
33583
33583
|
opts.path = url;
|
|
33584
|
-
opts.routePath =
|
|
33584
|
+
opts.routePath = path9;
|
|
33585
33585
|
opts.prefix = prefix;
|
|
33586
33586
|
opts.logLevel = opts.logLevel || this[kLogLevel];
|
|
33587
33587
|
validateLogLevelOption(opts.logLevel, opts.method, opts.url, logger);
|
|
@@ -33713,7 +33713,7 @@ var require_route = __commonJS({
|
|
|
33713
33713
|
});
|
|
33714
33714
|
if (shouldExposeHead && isGetRoute && !isHeadRoute && !hasHEADHandler) {
|
|
33715
33715
|
const onSendHandlers = parseHeadOnSendHandlers(headOpts.onSend);
|
|
33716
|
-
prepareRoute.call(this, { method: "HEAD", url:
|
|
33716
|
+
prepareRoute.call(this, { method: "HEAD", url: path9, options: { ...headOpts, onSend: onSendHandlers }, isFastify: true });
|
|
33717
33717
|
}
|
|
33718
33718
|
}
|
|
33719
33719
|
}
|
|
@@ -33837,9 +33837,9 @@ var require_route = __commonJS({
|
|
|
33837
33837
|
}
|
|
33838
33838
|
return method;
|
|
33839
33839
|
}
|
|
33840
|
-
function validateSchemaBodyOption(method,
|
|
33840
|
+
function validateSchemaBodyOption(method, path8, schema) {
|
|
33841
33841
|
if (this[kSupportedHTTPMethods].bodyless.has(method) && schema?.body) {
|
|
33842
|
-
throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method,
|
|
33842
|
+
throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method, path8);
|
|
33843
33843
|
}
|
|
33844
33844
|
}
|
|
33845
33845
|
function validateBodyLimitOption(bodyLimit) {
|
|
@@ -33854,11 +33854,11 @@ var require_route = __commonJS({
|
|
|
33854
33854
|
throw new FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT(handlerTimeout);
|
|
33855
33855
|
}
|
|
33856
33856
|
}
|
|
33857
|
-
function validateLogLevelOption(logLevel, method,
|
|
33857
|
+
function validateLogLevelOption(logLevel, method, path8, logger) {
|
|
33858
33858
|
if (logLevel == null || logLevel === "") return;
|
|
33859
33859
|
if (logger?.levels?.values == null) return;
|
|
33860
33860
|
if (typeof logLevel !== "string" || logger.levels.values[logLevel] === void 0) {
|
|
33861
|
-
throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method,
|
|
33861
|
+
throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method, path8, logLevel);
|
|
33862
33862
|
}
|
|
33863
33863
|
}
|
|
33864
33864
|
function runPreParsing(err, request, reply) {
|
|
@@ -33947,7 +33947,7 @@ var require_four_oh_four = __commonJS({
|
|
|
33947
33947
|
});
|
|
33948
33948
|
}
|
|
33949
33949
|
function createRouteEventHandler() {
|
|
33950
|
-
return function onRouteEvent(
|
|
33950
|
+
return function onRouteEvent(path8, req, res) {
|
|
33951
33951
|
const fourOhFourContext = this[kFourOhFourLevelInstance][kFourOhFourContext];
|
|
33952
33952
|
const id = getGenReqId(fourOhFourContext.server, req);
|
|
33953
33953
|
const childLogger = createChildLogger(fourOhFourContext, logger, req, id);
|
|
@@ -36618,19 +36618,19 @@ var require_fastify = __commonJS({
|
|
|
36618
36618
|
}
|
|
36619
36619
|
fourOhFour.router.lookup(req, res);
|
|
36620
36620
|
}
|
|
36621
|
-
function onBadUrl(
|
|
36621
|
+
function onBadUrl(path8, req, res) {
|
|
36622
36622
|
if (options.frameworkErrors) {
|
|
36623
36623
|
const id = getGenReqId(routeEventContext.server, req);
|
|
36624
36624
|
const childLogger = createChildLogger(routeEventContext, options.logger, req, id);
|
|
36625
36625
|
const request = new Request(id, null, req, null, childLogger, routeEventContext);
|
|
36626
36626
|
const reply = new Reply(res, request, childLogger);
|
|
36627
36627
|
routeEventContext.server[kLogController].incomingRequest(request, reply);
|
|
36628
|
-
return options.frameworkErrors(new FST_ERR_BAD_URL(
|
|
36628
|
+
return options.frameworkErrors(new FST_ERR_BAD_URL(path8), request, reply);
|
|
36629
36629
|
}
|
|
36630
36630
|
const body = JSON.stringify({
|
|
36631
36631
|
error: "Bad Request",
|
|
36632
36632
|
code: "FST_ERR_BAD_URL",
|
|
36633
|
-
message: `'${
|
|
36633
|
+
message: `'${path8}' is not a valid url component`,
|
|
36634
36634
|
statusCode: 400
|
|
36635
36635
|
});
|
|
36636
36636
|
res.writeHead(400, {
|
|
@@ -36639,19 +36639,19 @@ var require_fastify = __commonJS({
|
|
|
36639
36639
|
});
|
|
36640
36640
|
res.end(body);
|
|
36641
36641
|
}
|
|
36642
|
-
function onMaxParamLength(
|
|
36642
|
+
function onMaxParamLength(path8, req, res) {
|
|
36643
36643
|
if (options.frameworkErrors) {
|
|
36644
36644
|
const id = getGenReqId(routeEventContext.server, req);
|
|
36645
36645
|
const childLogger = createChildLogger(routeEventContext, options.logger, req, id);
|
|
36646
36646
|
const request = new Request(id, null, req, null, childLogger, routeEventContext);
|
|
36647
36647
|
const reply = new Reply(res, request, childLogger);
|
|
36648
36648
|
routeEventContext.server[kLogController].incomingRequest(request, reply);
|
|
36649
|
-
return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(
|
|
36649
|
+
return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(path8), request, reply);
|
|
36650
36650
|
}
|
|
36651
36651
|
const body = JSON.stringify({
|
|
36652
36652
|
error: "Bad Request",
|
|
36653
36653
|
code: "FST_ERR_MAX_PARAM_LENGTH",
|
|
36654
|
-
message: `'${
|
|
36654
|
+
message: `'${path8}' is exceeding the max param length`,
|
|
36655
36655
|
statusCode: 414
|
|
36656
36656
|
});
|
|
36657
36657
|
res.writeHead(414, {
|
|
@@ -41001,8 +41001,8 @@ var import_cors = __toESM(require_cors(), 1);
|
|
|
41001
41001
|
// src/db/index.ts
|
|
41002
41002
|
import Database from "better-sqlite3";
|
|
41003
41003
|
var db;
|
|
41004
|
-
function initDb(
|
|
41005
|
-
db = new Database(
|
|
41004
|
+
function initDb(path8 = "data.db") {
|
|
41005
|
+
db = new Database(path8);
|
|
41006
41006
|
db.pragma("journal_mode = WAL");
|
|
41007
41007
|
db.pragma("foreign_keys = ON");
|
|
41008
41008
|
createTables(db);
|
|
@@ -41100,6 +41100,17 @@ function createTables(database) {
|
|
|
41100
41100
|
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
41101
41101
|
);
|
|
41102
41102
|
|
|
41103
|
+
CREATE TABLE IF NOT EXISTS app_instances (
|
|
41104
|
+
id TEXT PRIMARY KEY,
|
|
41105
|
+
app_id TEXT NOT NULL,
|
|
41106
|
+
workspace_path TEXT NOT NULL DEFAULT '',
|
|
41107
|
+
pinned INTEGER NOT NULL DEFAULT 0,
|
|
41108
|
+
state TEXT,
|
|
41109
|
+
created_at TEXT NOT NULL,
|
|
41110
|
+
updated_at TEXT NOT NULL,
|
|
41111
|
+
UNIQUE(app_id, workspace_path)
|
|
41112
|
+
);
|
|
41113
|
+
|
|
41103
41114
|
CREATE INDEX IF NOT EXISTS idx_turns_session_id ON turns(session_id);
|
|
41104
41115
|
CREATE INDEX IF NOT EXISTS idx_items_turn_id ON items(turn_id);
|
|
41105
41116
|
CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
|
|
@@ -41107,6 +41118,7 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
|
|
|
41107
41118
|
CREATE INDEX IF NOT EXISTS idx_sidebar_folders_workspace_path ON sidebar_folders(workspace_path);
|
|
41108
41119
|
CREATE INDEX IF NOT EXISTS idx_discussion_threads_session_id ON discussion_threads(session_id);
|
|
41109
41120
|
CREATE INDEX IF NOT EXISTS idx_discussion_threads_item_id ON discussion_threads(item_id);
|
|
41121
|
+
CREATE INDEX IF NOT EXISTS idx_app_instances_app_id ON app_instances(app_id);
|
|
41110
41122
|
`);
|
|
41111
41123
|
const wsColumns = database.prepare("PRAGMA table_info(workspaces)").all();
|
|
41112
41124
|
if (!wsColumns.some((c) => c.name === "deleted")) {
|
|
@@ -41143,6 +41155,9 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
|
|
|
41143
41155
|
if (!sessColumns.some((c) => c.name === "starred")) {
|
|
41144
41156
|
database.exec("ALTER TABLE sessions ADD COLUMN starred INTEGER NOT NULL DEFAULT 0");
|
|
41145
41157
|
}
|
|
41158
|
+
if (!sessColumns.some((c) => c.name === "origin_app_id")) {
|
|
41159
|
+
database.exec("ALTER TABLE sessions ADD COLUMN origin_app_id TEXT");
|
|
41160
|
+
}
|
|
41146
41161
|
const turnColumns = database.prepare("PRAGMA table_info(turns)").all();
|
|
41147
41162
|
if (!turnColumns.some((c) => c.name === "thread_id")) {
|
|
41148
41163
|
database.exec("ALTER TABLE turns ADD COLUMN thread_id TEXT");
|
|
@@ -41401,7 +41416,8 @@ async function registerSessionRoutes(fastify) {
|
|
|
41401
41416
|
model: { type: ["string", "null"] },
|
|
41402
41417
|
model_reasoning_effort: { type: ["string", "null"] },
|
|
41403
41418
|
cwd: { type: ["string", "null"] },
|
|
41404
|
-
runtime_config: { type: ["string", "null"] }
|
|
41419
|
+
runtime_config: { type: ["string", "null"] },
|
|
41420
|
+
origin_app_id: { type: ["string", "null"] }
|
|
41405
41421
|
}
|
|
41406
41422
|
}
|
|
41407
41423
|
}
|
|
@@ -41412,16 +41428,17 @@ async function registerSessionRoutes(fastify) {
|
|
|
41412
41428
|
model = null,
|
|
41413
41429
|
model_reasoning_effort = null,
|
|
41414
41430
|
cwd = null,
|
|
41415
|
-
runtime_config = null
|
|
41431
|
+
runtime_config = null,
|
|
41432
|
+
origin_app_id = null
|
|
41416
41433
|
} = request.body || {};
|
|
41417
41434
|
const id = v4_default();
|
|
41418
41435
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41419
41436
|
const db2 = getDb();
|
|
41420
41437
|
const maxOrder = db2.prepare("SELECT COALESCE(MAX(sort_order), 0) AS m FROM sessions WHERE cwd = ?").get(cwd ?? null);
|
|
41421
41438
|
db2.prepare(
|
|
41422
|
-
`INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status, is_running, sort_order, created_at, updated_at, runtime_config)
|
|
41423
|
-
VALUES (?, ?, ?, ?, ?, ?, NULL, 'active', 0, ?, ?, ?, ?)`
|
|
41424
|
-
).run(id, title, runtime_type, model, model_reasoning_effort, cwd, maxOrder.m + 1, now, now, runtime_config);
|
|
41439
|
+
`INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status, is_running, sort_order, created_at, updated_at, runtime_config, origin_app_id)
|
|
41440
|
+
VALUES (?, ?, ?, ?, ?, ?, NULL, 'active', 0, ?, ?, ?, ?, ?)`
|
|
41441
|
+
).run(id, title, runtime_type, model, model_reasoning_effort, cwd, maxOrder.m + 1, now, now, runtime_config, origin_app_id);
|
|
41425
41442
|
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
41426
41443
|
return session;
|
|
41427
41444
|
});
|
|
@@ -42231,11 +42248,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42231
42248
|
}
|
|
42232
42249
|
}
|
|
42233
42250
|
}, async (request, reply) => {
|
|
42234
|
-
const { path:
|
|
42235
|
-
if (!
|
|
42251
|
+
const { path: path8, label = null } = request.body || {};
|
|
42252
|
+
if (!path8 || !path8.trim()) {
|
|
42236
42253
|
return reply.code(400).send({ error: "Path is required" });
|
|
42237
42254
|
}
|
|
42238
|
-
const trimmedPath =
|
|
42255
|
+
const trimmedPath = path8.trim();
|
|
42239
42256
|
const db2 = getDb();
|
|
42240
42257
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
42241
42258
|
if (existing) {
|
|
@@ -42263,8 +42280,8 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42263
42280
|
"-e",
|
|
42264
42281
|
'POSIX path of (choose folder with prompt "Select a workspace directory")'
|
|
42265
42282
|
]);
|
|
42266
|
-
const
|
|
42267
|
-
return { path:
|
|
42283
|
+
const path8 = stdout.trim().replace(/\/$/, "");
|
|
42284
|
+
return { path: path8 };
|
|
42268
42285
|
} catch {
|
|
42269
42286
|
return reply.code(204).send({ cancelled: true });
|
|
42270
42287
|
}
|
|
@@ -42280,11 +42297,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42280
42297
|
}
|
|
42281
42298
|
}
|
|
42282
42299
|
}, async (request, reply) => {
|
|
42283
|
-
const { path:
|
|
42284
|
-
if (!
|
|
42300
|
+
const { path: path8 } = request.body || {};
|
|
42301
|
+
if (!path8 || !path8.trim()) {
|
|
42285
42302
|
return reply.code(400).send({ error: "Path is required" });
|
|
42286
42303
|
}
|
|
42287
|
-
const trimmedPath =
|
|
42304
|
+
const trimmedPath = path8.trim();
|
|
42288
42305
|
const db2 = getDb();
|
|
42289
42306
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
42290
42307
|
if (existing) {
|
|
@@ -42549,6 +42566,8 @@ var AppServerClient = class {
|
|
|
42549
42566
|
buffer = "";
|
|
42550
42567
|
closed = false;
|
|
42551
42568
|
clientInfo;
|
|
42569
|
+
/** Bound stdout listener — removed in close() so stale data is not processed. */
|
|
42570
|
+
stdoutListener = (chunk) => this.onStdoutData(chunk);
|
|
42552
42571
|
events = new EventEmitter();
|
|
42553
42572
|
constructor(options) {
|
|
42554
42573
|
const binary = options.binaryPath ?? "codex";
|
|
@@ -42560,7 +42579,7 @@ var AppServerClient = class {
|
|
|
42560
42579
|
});
|
|
42561
42580
|
this.clientInfo = options.clientInfo ?? { name: "agentpane", title: "AgentPane", version: "1.0.0" };
|
|
42562
42581
|
this.proc.stdout?.setEncoding("utf-8");
|
|
42563
|
-
this.proc.stdout?.on("data",
|
|
42582
|
+
this.proc.stdout?.on("data", this.stdoutListener);
|
|
42564
42583
|
this.proc.stderr?.on("data", (chunk) => {
|
|
42565
42584
|
const text = chunk.toString().trim();
|
|
42566
42585
|
if (text) console.error("[app-server] stderr:", text);
|
|
@@ -42629,6 +42648,7 @@ var AppServerClient = class {
|
|
|
42629
42648
|
async close() {
|
|
42630
42649
|
if (this.closed) return;
|
|
42631
42650
|
this.closed = true;
|
|
42651
|
+
this.proc.stdout?.removeListener("data", this.stdoutListener);
|
|
42632
42652
|
for (const [id, entry] of this.pending) {
|
|
42633
42653
|
clearTimeout(entry.timer);
|
|
42634
42654
|
entry.reject(new Error("AppServerClient closed"));
|
|
@@ -42641,6 +42661,7 @@ var AppServerClient = class {
|
|
|
42641
42661
|
this.proc.stdin?.write(message);
|
|
42642
42662
|
}
|
|
42643
42663
|
onStdoutData(chunk) {
|
|
42664
|
+
if (this.closed) return;
|
|
42644
42665
|
this.buffer += chunk;
|
|
42645
42666
|
const lines = this.buffer.split("\n");
|
|
42646
42667
|
this.buffer = lines.pop() ?? "";
|
|
@@ -42657,11 +42678,18 @@ var AppServerClient = class {
|
|
|
42657
42678
|
} catch {
|
|
42658
42679
|
return;
|
|
42659
42680
|
}
|
|
42660
|
-
|
|
42661
|
-
|
|
42681
|
+
const hasId = "id" in msg && typeof msg.id === "number";
|
|
42682
|
+
const hasMethod = "method" in msg && typeof msg.method === "string";
|
|
42683
|
+
if (hasId && hasMethod) {
|
|
42684
|
+
this.handleServerRequest(msg.method, msg.id, msg.params);
|
|
42685
|
+
return;
|
|
42686
|
+
}
|
|
42687
|
+
if (hasId) {
|
|
42688
|
+
const id = msg.id;
|
|
42689
|
+
const pending = this.pending.get(id);
|
|
42662
42690
|
if (!pending) return;
|
|
42663
42691
|
clearTimeout(pending.timer);
|
|
42664
|
-
this.pending.delete(
|
|
42692
|
+
this.pending.delete(id);
|
|
42665
42693
|
if (msg.error) {
|
|
42666
42694
|
const err = msg.error;
|
|
42667
42695
|
pending.reject(new Error(`JSON-RPC error ${err.code}: ${err.message}`));
|
|
@@ -42670,17 +42698,35 @@ var AppServerClient = class {
|
|
|
42670
42698
|
}
|
|
42671
42699
|
return;
|
|
42672
42700
|
}
|
|
42673
|
-
if (
|
|
42674
|
-
const
|
|
42701
|
+
if (hasMethod) {
|
|
42702
|
+
const method = msg.method;
|
|
42703
|
+
const handlers = this.notificationHandlers.get(method);
|
|
42675
42704
|
if (handlers) {
|
|
42676
42705
|
for (const handler of handlers) {
|
|
42677
42706
|
handler(msg.params);
|
|
42678
42707
|
}
|
|
42679
42708
|
}
|
|
42680
|
-
this.events.emit("notification",
|
|
42709
|
+
this.events.emit("notification", method, msg.params);
|
|
42681
42710
|
return;
|
|
42682
42711
|
}
|
|
42683
42712
|
}
|
|
42713
|
+
/**
|
|
42714
|
+
* Handle a server→client JSON-RPC request. The last registered handler
|
|
42715
|
+
* runs and its result is sent back; unhandled requests are declined with
|
|
42716
|
+
* a -32601 error so the server never waits forever.
|
|
42717
|
+
*/
|
|
42718
|
+
handleServerRequest(method, id, params) {
|
|
42719
|
+
const respond = (payload) => {
|
|
42720
|
+
this.write(JSON.stringify({ jsonrpc: "2.0", id, ...payload }) + "\n");
|
|
42721
|
+
};
|
|
42722
|
+
const handlers = this.requestHandlers.get(method);
|
|
42723
|
+
if (!handlers || handlers.length === 0) {
|
|
42724
|
+
respond({ error: { code: -32601, message: `Method not found: ${method}` } });
|
|
42725
|
+
return;
|
|
42726
|
+
}
|
|
42727
|
+
const handler = handlers[handlers.length - 1];
|
|
42728
|
+
Promise.resolve(handler(params)).then((result) => respond({ result: result ?? {} })).catch((err) => respond({ error: { code: -32e3, message: err.message } }));
|
|
42729
|
+
}
|
|
42684
42730
|
onProcessExit(code, signal) {
|
|
42685
42731
|
if (this.closed) return;
|
|
42686
42732
|
this.closed = true;
|
|
@@ -42902,17 +42948,17 @@ async function registerPerfLogRoutes(fastify) {
|
|
|
42902
42948
|
if (entries.length === 0) {
|
|
42903
42949
|
return reply.send({ written: 0 });
|
|
42904
42950
|
}
|
|
42905
|
-
const
|
|
42951
|
+
const path8 = perfLogPath();
|
|
42906
42952
|
try {
|
|
42907
|
-
mkdirSync(dirname(
|
|
42953
|
+
mkdirSync(dirname(path8), { recursive: true });
|
|
42908
42954
|
try {
|
|
42909
|
-
if (statSync(
|
|
42910
|
-
renameSync(
|
|
42955
|
+
if (statSync(path8).size > MAX_BYTES) {
|
|
42956
|
+
renameSync(path8, `${path8}.1`);
|
|
42911
42957
|
}
|
|
42912
42958
|
} catch {
|
|
42913
42959
|
}
|
|
42914
42960
|
const lines = entries.map((e) => `${new Date(e.t).toISOString()} [${oneLine(e.cat)}] ${oneLine(e.msg)}`).join("\n");
|
|
42915
|
-
appendFileSync(
|
|
42961
|
+
appendFileSync(path8, `${lines}
|
|
42916
42962
|
`, "utf-8");
|
|
42917
42963
|
return reply.send({ written: entries.length });
|
|
42918
42964
|
} catch (err) {
|
|
@@ -43474,6 +43520,757 @@ function proxyHandler(request, reply) {
|
|
|
43474
43520
|
upstream.end();
|
|
43475
43521
|
}
|
|
43476
43522
|
|
|
43523
|
+
// src/routes/apps.ts
|
|
43524
|
+
import fs4 from "node:fs";
|
|
43525
|
+
import path5 from "node:path";
|
|
43526
|
+
|
|
43527
|
+
// src/apps/instances.ts
|
|
43528
|
+
import fs2 from "node:fs";
|
|
43529
|
+
import path4 from "node:path";
|
|
43530
|
+
|
|
43531
|
+
// src/apps/apps-registry.ts
|
|
43532
|
+
import fs from "node:fs";
|
|
43533
|
+
import path3 from "node:path";
|
|
43534
|
+
import os2 from "node:os";
|
|
43535
|
+
import { fileURLToPath } from "node:url";
|
|
43536
|
+
var APP_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
43537
|
+
var rootOverride = null;
|
|
43538
|
+
function setAppsRootOverride(root) {
|
|
43539
|
+
rootOverride = root;
|
|
43540
|
+
}
|
|
43541
|
+
function appsRoot() {
|
|
43542
|
+
return rootOverride ?? process.env.AGENT_PANE_APPS_DIR ?? path3.join(os2.homedir(), ".repoburg", "agent-pane", "apps");
|
|
43543
|
+
}
|
|
43544
|
+
function appDir(id) {
|
|
43545
|
+
return path3.join(appsRoot(), id);
|
|
43546
|
+
}
|
|
43547
|
+
var examplesRootOverride = null;
|
|
43548
|
+
function setExamplesRootOverride(root) {
|
|
43549
|
+
examplesRootOverride = root;
|
|
43550
|
+
}
|
|
43551
|
+
function examplesRoot() {
|
|
43552
|
+
if (examplesRootOverride) return examplesRootOverride;
|
|
43553
|
+
if (process.env.AGENT_PANE_EXAMPLES_DIR) return process.env.AGENT_PANE_EXAMPLES_DIR;
|
|
43554
|
+
const here = path3.dirname(fileURLToPath(import.meta.url));
|
|
43555
|
+
for (const candidate of [path3.resolve(here, "../../examples"), path3.resolve(here, "../../../examples")]) {
|
|
43556
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
43557
|
+
}
|
|
43558
|
+
return null;
|
|
43559
|
+
}
|
|
43560
|
+
function ensureAppsRoot() {
|
|
43561
|
+
const root = appsRoot();
|
|
43562
|
+
fs.mkdirSync(root, { recursive: true });
|
|
43563
|
+
for (const name of ["CLAUDE.md", "AGENTS.md"]) {
|
|
43564
|
+
const file = path3.join(root, name);
|
|
43565
|
+
if (!fs.existsSync(file)) fs.writeFileSync(file, APPS_MD_SKELETON);
|
|
43566
|
+
}
|
|
43567
|
+
}
|
|
43568
|
+
var APPS_MD_SKELETON = `# Mini Apps
|
|
43569
|
+
|
|
43570
|
+
Each subdirectory of this folder is one mini app:
|
|
43571
|
+
|
|
43572
|
+
<app-id>/
|
|
43573
|
+
manifest.json - { "title": string, "description"?: string, "icon"?: string,
|
|
43574
|
+
"tools"?: [{ "name", "description", "inputSchema" }] }
|
|
43575
|
+
index.html - markup only (full HTML document); do NOT reference app.js
|
|
43576
|
+
app.js - app logic; injected automatically into the page
|
|
43577
|
+
|
|
43578
|
+
App state does NOT live in this folder \u2014 it is stored in the pane database
|
|
43579
|
+
(app_instances table) and reached with getState()/setState().
|
|
43580
|
+
|
|
43581
|
+
## Bridge API (window.AgentPane)
|
|
43582
|
+
|
|
43583
|
+
- getApp() - app info (id, title)
|
|
43584
|
+
- getState() / setState(data) - persistent JSON state, survives page reload
|
|
43585
|
+
- createSession({ cwd, runtime_type, model, title }) - agent session owned by this app
|
|
43586
|
+
- submitTurn(sessionId, prompt) - send a prompt to a session
|
|
43587
|
+
- onTurnCompleted(callback) - callback(event, { turnId, response }) when a turn ends
|
|
43588
|
+
- onToolCall(callback) - callback({ callId, name, tool, args }) when the AGENT calls one of the manifest tools (name and tool carry the same tool name); answer with resolveToolCall(callId, result)
|
|
43589
|
+
one of the manifest tools; answer with resolveToolCall(callId, result)
|
|
43590
|
+
|
|
43591
|
+
## Agent tool calls (manifest "tools")
|
|
43592
|
+
|
|
43593
|
+
Manifest tools are exposed to the agent as MCP tools named
|
|
43594
|
+
<app-id>__<tool.name>. The pane routes each call to the app's HEADLESS
|
|
43595
|
+
runtime \u2014 a backend sandbox running this same app.js. The open tab is a
|
|
43596
|
+
viewer; it refreshes via AgentPane.onStateChanged(cb).
|
|
43597
|
+
|
|
43598
|
+
Headless contract for apps that declare tools:
|
|
43599
|
+
- register AgentPane.onToolCall(handler) synchronously at startup
|
|
43600
|
+
- tool handlers must not depend on the DOM or the live UI
|
|
43601
|
+
- headless state is the GLOBAL instance (workspace ''), shared with the
|
|
43602
|
+
open tab via onStateChanged
|
|
43603
|
+
- createSession/submitTurn are not available in the headless runtime
|
|
43604
|
+
|
|
43605
|
+
If the app cannot load headless (broken app.js, no handler), the pane
|
|
43606
|
+
falls back to relaying calls into the OPEN app iframe \u2014 the app must be
|
|
43607
|
+
open in AgentPane for a tool call to succeed in that case.
|
|
43608
|
+
|
|
43609
|
+
## Result contract
|
|
43610
|
+
|
|
43611
|
+
To give the app a structured result, put this requirement in the job prompt:
|
|
43612
|
+
"End your answer with a single JSON code block matching this schema: ..."
|
|
43613
|
+
`;
|
|
43614
|
+
function readManifestIn(dir) {
|
|
43615
|
+
try {
|
|
43616
|
+
const raw = fs.readFileSync(path3.join(dir, "manifest.json"), "utf-8");
|
|
43617
|
+
const parsed = JSON.parse(raw);
|
|
43618
|
+
if (!parsed || typeof parsed.title !== "string") return null;
|
|
43619
|
+
return {
|
|
43620
|
+
title: parsed.title,
|
|
43621
|
+
description: typeof parsed.description === "string" ? parsed.description : void 0,
|
|
43622
|
+
icon: typeof parsed.icon === "string" ? parsed.icon : void 0,
|
|
43623
|
+
tools: Array.isArray(parsed.tools) ? parsed.tools.filter((t) => t && typeof t.name === "string" && typeof t.description === "string") : void 0
|
|
43624
|
+
};
|
|
43625
|
+
} catch {
|
|
43626
|
+
return null;
|
|
43627
|
+
}
|
|
43628
|
+
}
|
|
43629
|
+
function readManifest(id) {
|
|
43630
|
+
return readManifestIn(appDir(id));
|
|
43631
|
+
}
|
|
43632
|
+
function readAppFile(id, name) {
|
|
43633
|
+
try {
|
|
43634
|
+
return fs.readFileSync(path3.join(appDir(id), name), "utf-8");
|
|
43635
|
+
} catch {
|
|
43636
|
+
return "";
|
|
43637
|
+
}
|
|
43638
|
+
}
|
|
43639
|
+
function readState(id) {
|
|
43640
|
+
try {
|
|
43641
|
+
const parsed = JSON.parse(readAppFile(id, "state.json"));
|
|
43642
|
+
return {
|
|
43643
|
+
pinned: parsed?.pinned === true,
|
|
43644
|
+
data: parsed && typeof parsed.data === "object" && parsed.data !== null ? parsed.data : null
|
|
43645
|
+
};
|
|
43646
|
+
} catch {
|
|
43647
|
+
return { pinned: false, data: null };
|
|
43648
|
+
}
|
|
43649
|
+
}
|
|
43650
|
+
var watcher = null;
|
|
43651
|
+
var pendingChanges = /* @__PURE__ */ new Map();
|
|
43652
|
+
var HOT_RELOAD_DEBOUNCE_MS = 250;
|
|
43653
|
+
function startAppsWatch(onAppChange) {
|
|
43654
|
+
stopAppsWatch();
|
|
43655
|
+
const root = appsRoot();
|
|
43656
|
+
fs.mkdirSync(root, { recursive: true });
|
|
43657
|
+
try {
|
|
43658
|
+
watcher = fs.watch(root, { recursive: true }, (_event, filename) => {
|
|
43659
|
+
const rel = String(filename ?? "");
|
|
43660
|
+
const segs = rel.split(path3.sep);
|
|
43661
|
+
const appId = segs[0];
|
|
43662
|
+
const file = segs[segs.length - 1];
|
|
43663
|
+
if (!appId || appId === path3.basename(root) || !APP_ID_RE.test(appId) || file === "state.json") return;
|
|
43664
|
+
const timer = pendingChanges.get(appId);
|
|
43665
|
+
if (timer) clearTimeout(timer);
|
|
43666
|
+
pendingChanges.set(
|
|
43667
|
+
appId,
|
|
43668
|
+
setTimeout(() => {
|
|
43669
|
+
pendingChanges.delete(appId);
|
|
43670
|
+
onAppChange(appId);
|
|
43671
|
+
}, HOT_RELOAD_DEBOUNCE_MS)
|
|
43672
|
+
);
|
|
43673
|
+
});
|
|
43674
|
+
} catch {
|
|
43675
|
+
watcher = null;
|
|
43676
|
+
}
|
|
43677
|
+
}
|
|
43678
|
+
function stopAppsWatch() {
|
|
43679
|
+
if (watcher) {
|
|
43680
|
+
watcher.close();
|
|
43681
|
+
watcher = null;
|
|
43682
|
+
}
|
|
43683
|
+
for (const timer of pendingChanges.values()) clearTimeout(timer);
|
|
43684
|
+
pendingChanges.clear();
|
|
43685
|
+
}
|
|
43686
|
+
|
|
43687
|
+
// src/apps/instances.ts
|
|
43688
|
+
function rowToState(row) {
|
|
43689
|
+
let data = null;
|
|
43690
|
+
try {
|
|
43691
|
+
const parsed = JSON.parse(row.state ?? "null");
|
|
43692
|
+
if (parsed && typeof parsed === "object") data = parsed;
|
|
43693
|
+
} catch {
|
|
43694
|
+
}
|
|
43695
|
+
return { pinned: row.pinned === 1, data };
|
|
43696
|
+
}
|
|
43697
|
+
function writeRow(appId, workspace, state) {
|
|
43698
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
43699
|
+
getDb().prepare(
|
|
43700
|
+
`INSERT INTO app_instances (id, app_id, workspace_path, pinned, state, created_at, updated_at)
|
|
43701
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
43702
|
+
ON CONFLICT(app_id, workspace_path) DO UPDATE SET
|
|
43703
|
+
pinned = excluded.pinned, state = excluded.state, updated_at = excluded.updated_at`
|
|
43704
|
+
).run(v4_default(), appId, workspace, state.pinned ? 1 : 0, JSON.stringify(state.data ?? null), now, now);
|
|
43705
|
+
}
|
|
43706
|
+
function getInstanceState(appId, workspace = "") {
|
|
43707
|
+
const db2 = getDb();
|
|
43708
|
+
const row = db2.prepare("SELECT * FROM app_instances WHERE app_id = ? AND workspace_path = ?").get(appId, workspace);
|
|
43709
|
+
if (row) return rowToState(row);
|
|
43710
|
+
if (workspace === "") {
|
|
43711
|
+
const legacyFile = path4.join(appDir(appId), "state.json");
|
|
43712
|
+
if (fs2.existsSync(legacyFile)) {
|
|
43713
|
+
const imported = readState(appId);
|
|
43714
|
+
writeRow(appId, "", imported);
|
|
43715
|
+
fs2.rmSync(legacyFile, { force: true });
|
|
43716
|
+
return imported;
|
|
43717
|
+
}
|
|
43718
|
+
}
|
|
43719
|
+
return { pinned: false, data: null };
|
|
43720
|
+
}
|
|
43721
|
+
function updateInstanceState(appId, workspace, patch) {
|
|
43722
|
+
const current = getInstanceState(appId, workspace);
|
|
43723
|
+
const { pinned, data } = patch;
|
|
43724
|
+
const next = {
|
|
43725
|
+
pinned: typeof pinned === "boolean" ? pinned : current.pinned,
|
|
43726
|
+
data: data === void 0 ? current.data : data !== null && typeof data === "object" ? data : null
|
|
43727
|
+
};
|
|
43728
|
+
writeRow(appId, workspace, next);
|
|
43729
|
+
return next;
|
|
43730
|
+
}
|
|
43731
|
+
function deleteAppInstances(appId) {
|
|
43732
|
+
getDb().prepare("DELETE FROM app_instances WHERE app_id = ?").run(appId);
|
|
43733
|
+
}
|
|
43734
|
+
|
|
43735
|
+
// src/apps/mcp-tools.ts
|
|
43736
|
+
import fs3 from "node:fs";
|
|
43737
|
+
|
|
43738
|
+
// src/apps/headless-runtime.ts
|
|
43739
|
+
import vm from "node:vm";
|
|
43740
|
+
var HEADLESS_TOOL_TIMEOUT_MS = Number(process.env.AGENT_PANE_TOOL_TIMEOUT_MS ?? 3e4);
|
|
43741
|
+
function stub() {
|
|
43742
|
+
const fn = function stub2() {
|
|
43743
|
+
};
|
|
43744
|
+
return new Proxy(fn, {
|
|
43745
|
+
get: (_target, prop) => {
|
|
43746
|
+
if (prop === "then") return void 0;
|
|
43747
|
+
if (prop === Symbol.toPrimitive || prop === "toString" || prop === "valueOf") return () => "";
|
|
43748
|
+
if (prop === "length") return 0;
|
|
43749
|
+
if (prop === "value" || prop === "textContent" || prop === "innerText" || prop === "innerHTML") return "";
|
|
43750
|
+
return stub();
|
|
43751
|
+
},
|
|
43752
|
+
set: () => true,
|
|
43753
|
+
apply: () => stub(),
|
|
43754
|
+
construct: () => ({}),
|
|
43755
|
+
has: () => true
|
|
43756
|
+
});
|
|
43757
|
+
}
|
|
43758
|
+
var runtimes = /* @__PURE__ */ new Map();
|
|
43759
|
+
var pendingCalls = /* @__PURE__ */ new Map();
|
|
43760
|
+
function getHeadlessToolHandler(appId) {
|
|
43761
|
+
const cached = runtimes.get(appId);
|
|
43762
|
+
if (cached) return cached.handler;
|
|
43763
|
+
const js = readAppFile(appId, "app.js");
|
|
43764
|
+
if (!js.trim()) return null;
|
|
43765
|
+
const manifest = readManifest(appId);
|
|
43766
|
+
let handler = null;
|
|
43767
|
+
const bridge = {
|
|
43768
|
+
getApp: () => Promise.resolve({ id: appId, title: manifest?.title ?? appId }),
|
|
43769
|
+
// Headless state = the GLOBAL instance (workspace ''). Tool calls carry
|
|
43770
|
+
// no workspace context; the open tab keeps its own workspace-scoped view.
|
|
43771
|
+
getState: () => Promise.resolve(getInstanceState(appId, "")),
|
|
43772
|
+
setState: (data) => {
|
|
43773
|
+
const next = updateInstanceState(appId, "", { data });
|
|
43774
|
+
broadcast("app:state_changed", { appId });
|
|
43775
|
+
return Promise.resolve(next);
|
|
43776
|
+
},
|
|
43777
|
+
onToolCall: (cb) => {
|
|
43778
|
+
if (typeof cb === "function") handler = cb;
|
|
43779
|
+
},
|
|
43780
|
+
resolveToolCall: (callId, result) => {
|
|
43781
|
+
resolveHeadlessToolCall(String(callId), result);
|
|
43782
|
+
return Promise.resolve({ ok: true });
|
|
43783
|
+
},
|
|
43784
|
+
// UI-flow APIs are intentionally unavailable headless.
|
|
43785
|
+
createSession: () => Promise.reject(new Error("createSession is not available in the headless runtime")),
|
|
43786
|
+
submitTurn: () => Promise.reject(new Error("submitTurn is not available in the headless runtime")),
|
|
43787
|
+
onTurnCompleted: () => {
|
|
43788
|
+
},
|
|
43789
|
+
onTurnDelta: () => {
|
|
43790
|
+
}
|
|
43791
|
+
};
|
|
43792
|
+
const sandbox = {
|
|
43793
|
+
console: {
|
|
43794
|
+
log: (...a) => console.log(`[app:${appId}]`, ...a),
|
|
43795
|
+
warn: (...a) => console.warn(`[app:${appId}]`, ...a),
|
|
43796
|
+
error: (...a) => console.error(`[app:${appId}]`, ...a)
|
|
43797
|
+
},
|
|
43798
|
+
setTimeout,
|
|
43799
|
+
clearTimeout,
|
|
43800
|
+
document: stub(),
|
|
43801
|
+
navigator: stub(),
|
|
43802
|
+
AgentPane: bridge
|
|
43803
|
+
};
|
|
43804
|
+
const windowObj = {
|
|
43805
|
+
addEventListener: () => {
|
|
43806
|
+
},
|
|
43807
|
+
removeEventListener: () => {
|
|
43808
|
+
},
|
|
43809
|
+
document: sandbox.document,
|
|
43810
|
+
navigator: sandbox.navigator,
|
|
43811
|
+
setTimeout,
|
|
43812
|
+
clearTimeout,
|
|
43813
|
+
AgentPane: bridge
|
|
43814
|
+
};
|
|
43815
|
+
sandbox.window = windowObj;
|
|
43816
|
+
sandbox.self = windowObj;
|
|
43817
|
+
try {
|
|
43818
|
+
const context = vm.createContext(sandbox);
|
|
43819
|
+
vm.runInContext(js, context, { filename: `${appId}/app.js` });
|
|
43820
|
+
} catch (err) {
|
|
43821
|
+
console.warn(`[headless:${appId}] app.js load failed: ${err.message}`);
|
|
43822
|
+
return null;
|
|
43823
|
+
}
|
|
43824
|
+
if (!handler) return null;
|
|
43825
|
+
runtimes.set(appId, { handler });
|
|
43826
|
+
return handler;
|
|
43827
|
+
}
|
|
43828
|
+
function dispatchHeadlessToolCall(handler, tool, args) {
|
|
43829
|
+
const callId = v4_default();
|
|
43830
|
+
const result = new Promise((resolve, reject) => {
|
|
43831
|
+
const timer = setTimeout(() => {
|
|
43832
|
+
pendingCalls.delete(callId);
|
|
43833
|
+
reject(
|
|
43834
|
+
new Error(
|
|
43835
|
+
`Mini app did not answer tool '${tool}' within ${HEADLESS_TOOL_TIMEOUT_MS / 1e3}s (headless runtime) \u2014 check the app tool handler.`
|
|
43836
|
+
)
|
|
43837
|
+
);
|
|
43838
|
+
}, HEADLESS_TOOL_TIMEOUT_MS);
|
|
43839
|
+
pendingCalls.set(callId, { resolve, reject, timer });
|
|
43840
|
+
});
|
|
43841
|
+
try {
|
|
43842
|
+
handler("tool_call", { callId, tool, name: tool, args: args ?? {} });
|
|
43843
|
+
} catch (err) {
|
|
43844
|
+
const pending = pendingCalls.get(callId);
|
|
43845
|
+
if (pending) {
|
|
43846
|
+
pendingCalls.delete(callId);
|
|
43847
|
+
clearTimeout(pending.timer);
|
|
43848
|
+
pending.reject(new Error(`Headless tool handler crashed: ${err.message}`));
|
|
43849
|
+
}
|
|
43850
|
+
}
|
|
43851
|
+
return { callId, result };
|
|
43852
|
+
}
|
|
43853
|
+
function resolveHeadlessToolCall(callId, result) {
|
|
43854
|
+
const pending = pendingCalls.get(callId);
|
|
43855
|
+
if (!pending) return false;
|
|
43856
|
+
pendingCalls.delete(callId);
|
|
43857
|
+
clearTimeout(pending.timer);
|
|
43858
|
+
pending.resolve(result ?? null);
|
|
43859
|
+
return true;
|
|
43860
|
+
}
|
|
43861
|
+
function invalidateHeadlessRuntime(appId) {
|
|
43862
|
+
if (appId) runtimes.delete(appId);
|
|
43863
|
+
else runtimes.clear();
|
|
43864
|
+
}
|
|
43865
|
+
|
|
43866
|
+
// src/apps/mcp-tools.ts
|
|
43867
|
+
var TOOL_CALL_TIMEOUT_MS = Number(process.env.AGENT_PANE_TOOL_TIMEOUT_MS ?? 3e4);
|
|
43868
|
+
var TOOL_NS = "__";
|
|
43869
|
+
function listAppTools() {
|
|
43870
|
+
const tools = [];
|
|
43871
|
+
try {
|
|
43872
|
+
for (const entry of fs3.readdirSync(appsRoot(), { withFileTypes: true })) {
|
|
43873
|
+
if (!entry.isDirectory()) continue;
|
|
43874
|
+
const manifest = readManifest(entry.name);
|
|
43875
|
+
for (const tool of manifest?.tools ?? []) {
|
|
43876
|
+
if (!tool?.name || !tool?.description) continue;
|
|
43877
|
+
tools.push({
|
|
43878
|
+
name: `${entry.name}${TOOL_NS}${tool.name}`,
|
|
43879
|
+
description: `[${entry.name}] ${tool.description}`,
|
|
43880
|
+
inputSchema: tool.inputSchema
|
|
43881
|
+
});
|
|
43882
|
+
}
|
|
43883
|
+
}
|
|
43884
|
+
} catch {
|
|
43885
|
+
}
|
|
43886
|
+
return tools;
|
|
43887
|
+
}
|
|
43888
|
+
function splitToolName(name) {
|
|
43889
|
+
const idx = name.indexOf(TOOL_NS);
|
|
43890
|
+
if (idx <= 0 || idx === name.length - TOOL_NS.length) return null;
|
|
43891
|
+
return { appId: name.slice(0, idx), localName: name.slice(idx + TOOL_NS.length) };
|
|
43892
|
+
}
|
|
43893
|
+
var pendingCalls2 = /* @__PURE__ */ new Map();
|
|
43894
|
+
function dispatchAppTool(toolName, args) {
|
|
43895
|
+
const split = splitToolName(toolName);
|
|
43896
|
+
if (!split) {
|
|
43897
|
+
throw new Error(`Invalid tool name: ${toolName}`);
|
|
43898
|
+
}
|
|
43899
|
+
const { appId, localName } = split;
|
|
43900
|
+
const manifest = readManifest(appId);
|
|
43901
|
+
const tool = manifest?.tools?.find((t) => t.name === localName);
|
|
43902
|
+
if (!manifest || !tool) {
|
|
43903
|
+
throw new Error(`Unknown mini-app tool: ${toolName}`);
|
|
43904
|
+
}
|
|
43905
|
+
const headlessHandler = getHeadlessToolHandler(appId);
|
|
43906
|
+
if (headlessHandler) {
|
|
43907
|
+
return dispatchHeadlessToolCall(headlessHandler, localName, args);
|
|
43908
|
+
}
|
|
43909
|
+
const callId = v4_default();
|
|
43910
|
+
const result = new Promise((resolve, reject) => {
|
|
43911
|
+
const timer = setTimeout(() => {
|
|
43912
|
+
pendingCalls2.delete(callId);
|
|
43913
|
+
reject(
|
|
43914
|
+
new Error(
|
|
43915
|
+
`Mini app '${appId}' did not answer tool '${localName}' within ${TOOL_CALL_TIMEOUT_MS / 1e3}s \u2014 open the app in AgentPane or fix its headless load.`
|
|
43916
|
+
)
|
|
43917
|
+
);
|
|
43918
|
+
}, TOOL_CALL_TIMEOUT_MS);
|
|
43919
|
+
pendingCalls2.set(callId, { resolve, reject, timer, appId });
|
|
43920
|
+
broadcast("app:tool_call", { appId, callId, tool: localName, args: args ?? {} });
|
|
43921
|
+
});
|
|
43922
|
+
return { callId, result };
|
|
43923
|
+
}
|
|
43924
|
+
async function callAppTool(toolName, args) {
|
|
43925
|
+
return dispatchAppTool(toolName, args).result;
|
|
43926
|
+
}
|
|
43927
|
+
function resolveAppToolCall(callId, result, error) {
|
|
43928
|
+
const pending = pendingCalls2.get(callId);
|
|
43929
|
+
if (!pending) return false;
|
|
43930
|
+
pendingCalls2.delete(callId);
|
|
43931
|
+
clearTimeout(pending.timer);
|
|
43932
|
+
if (error) pending.reject(new Error(error));
|
|
43933
|
+
else pending.resolve(result ?? null);
|
|
43934
|
+
return true;
|
|
43935
|
+
}
|
|
43936
|
+
function anyAppHasTools() {
|
|
43937
|
+
return listAppTools().length > 0;
|
|
43938
|
+
}
|
|
43939
|
+
|
|
43940
|
+
// src/routes/apps.ts
|
|
43941
|
+
var IMPORT_FILE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
43942
|
+
var IMPORT_MAX_FILES = 50;
|
|
43943
|
+
var IMPORT_MAX_FILE_BYTES = 512 * 1024;
|
|
43944
|
+
var SKELETON_HTML = `<!DOCTYPE html>
|
|
43945
|
+
<html>
|
|
43946
|
+
<head>
|
|
43947
|
+
<meta charset="utf-8">
|
|
43948
|
+
<title>__TITLE__</title>
|
|
43949
|
+
</head>
|
|
43950
|
+
<body>
|
|
43951
|
+
<h1>__TITLE__</h1>
|
|
43952
|
+
<p id="out">Skeleton app \u2014 develop it with Edit App.</p>
|
|
43953
|
+
</body>
|
|
43954
|
+
</html>
|
|
43955
|
+
`;
|
|
43956
|
+
var SKELETON_JS = `// Skeleton mini app. window.AgentPane is the pane bridge:
|
|
43957
|
+
// getState() / setState(data) persistent state (survives reloads)
|
|
43958
|
+
// createSession / submitTurn talk to an agent session
|
|
43959
|
+
// onTurnCompleted / onToolCall react to agent events
|
|
43960
|
+
var ui = { ready: false };
|
|
43961
|
+
|
|
43962
|
+
function render() {
|
|
43963
|
+
document.getElementById('out').textContent =
|
|
43964
|
+
ui.ready ? 'State: ' + JSON.stringify(ui.data) : 'Loading\u2026';
|
|
43965
|
+
}
|
|
43966
|
+
|
|
43967
|
+
(async function init() {
|
|
43968
|
+
var state = await AgentPane.getState();
|
|
43969
|
+
ui.data = (state && state.data) || {};
|
|
43970
|
+
ui.ready = true;
|
|
43971
|
+
render();
|
|
43972
|
+
})();
|
|
43973
|
+
`;
|
|
43974
|
+
async function registerAppRoutes(fastify, opts) {
|
|
43975
|
+
setAppsRootOverride(opts?.appsRoot ?? null);
|
|
43976
|
+
setExamplesRootOverride(opts?.examplesRoot ?? null);
|
|
43977
|
+
startAppsWatch((appId) => {
|
|
43978
|
+
invalidateHeadlessRuntime(appId);
|
|
43979
|
+
broadcast("app:source:updated", { appId });
|
|
43980
|
+
});
|
|
43981
|
+
fastify.addHook("onClose", async () => stopAppsWatch());
|
|
43982
|
+
fastify.get("/api/apps", async () => {
|
|
43983
|
+
try {
|
|
43984
|
+
ensureAppsRoot();
|
|
43985
|
+
const entries = fs4.readdirSync(appsRoot(), { withFileTypes: true });
|
|
43986
|
+
const apps = [];
|
|
43987
|
+
for (const entry of entries) {
|
|
43988
|
+
if (!entry.isDirectory() || !APP_ID_RE.test(entry.name)) continue;
|
|
43989
|
+
const manifest = readManifest(entry.name);
|
|
43990
|
+
if (!manifest) continue;
|
|
43991
|
+
apps.push({
|
|
43992
|
+
id: entry.name,
|
|
43993
|
+
title: manifest.title,
|
|
43994
|
+
description: manifest.description ?? null,
|
|
43995
|
+
icon: manifest.icon ?? null,
|
|
43996
|
+
pinned: getInstanceState(entry.name).pinned
|
|
43997
|
+
});
|
|
43998
|
+
}
|
|
43999
|
+
apps.sort((a, b) => Number(b.pinned) - Number(a.pinned) || a.title.localeCompare(b.title));
|
|
44000
|
+
return apps;
|
|
44001
|
+
} catch {
|
|
44002
|
+
return [];
|
|
44003
|
+
}
|
|
44004
|
+
});
|
|
44005
|
+
fastify.get("/api/apps/mcp/tools", async () => listAppTools());
|
|
44006
|
+
fastify.get("/api/apps/examples", async () => {
|
|
44007
|
+
const exRoot = examplesRoot();
|
|
44008
|
+
if (!exRoot) return [];
|
|
44009
|
+
const out = [];
|
|
44010
|
+
try {
|
|
44011
|
+
for (const entry of fs4.readdirSync(exRoot, { withFileTypes: true })) {
|
|
44012
|
+
if (!entry.isDirectory() || !APP_ID_RE.test(entry.name)) continue;
|
|
44013
|
+
const manifest = readManifestIn(path5.join(exRoot, entry.name));
|
|
44014
|
+
if (!manifest) continue;
|
|
44015
|
+
out.push({
|
|
44016
|
+
id: entry.name,
|
|
44017
|
+
title: manifest.title,
|
|
44018
|
+
description: manifest.description ?? null,
|
|
44019
|
+
icon: manifest.icon ?? null,
|
|
44020
|
+
pinned: false
|
|
44021
|
+
});
|
|
44022
|
+
}
|
|
44023
|
+
} catch {
|
|
44024
|
+
return [];
|
|
44025
|
+
}
|
|
44026
|
+
out.sort((a, b) => a.title.localeCompare(b.title));
|
|
44027
|
+
return out;
|
|
44028
|
+
});
|
|
44029
|
+
fastify.post("/api/apps/examples/:id/install", async (request, reply) => {
|
|
44030
|
+
const { id } = request.params;
|
|
44031
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44032
|
+
const exRoot = examplesRoot();
|
|
44033
|
+
if (!exRoot) return reply.code(404).send({ error: "Examples catalog not available" });
|
|
44034
|
+
const src = path5.join(exRoot, id);
|
|
44035
|
+
if (!readManifestIn(src)) return reply.code(404).send({ error: "Example not found" });
|
|
44036
|
+
if (readManifest(id)) return reply.code(409).send({ error: "App already installed" });
|
|
44037
|
+
ensureAppsRoot();
|
|
44038
|
+
fs4.cpSync(src, appDir(id), { recursive: true });
|
|
44039
|
+
return { ok: true, id };
|
|
44040
|
+
});
|
|
44041
|
+
fastify.post(
|
|
44042
|
+
"/api/apps",
|
|
44043
|
+
{
|
|
44044
|
+
schema: {
|
|
44045
|
+
body: {
|
|
44046
|
+
type: "object",
|
|
44047
|
+
required: ["id", "title"],
|
|
44048
|
+
properties: {
|
|
44049
|
+
id: { type: "string" },
|
|
44050
|
+
title: { type: "string" },
|
|
44051
|
+
description: { type: "string" },
|
|
44052
|
+
icon: { type: "string" }
|
|
44053
|
+
}
|
|
44054
|
+
}
|
|
44055
|
+
}
|
|
44056
|
+
},
|
|
44057
|
+
async (request, reply) => {
|
|
44058
|
+
const { id, title, description, icon } = request.body || {};
|
|
44059
|
+
if (!id || !APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44060
|
+
if (!title || !title.trim()) return reply.code(400).send({ error: "Title is required" });
|
|
44061
|
+
if (readManifest(id)) return reply.code(409).send({ error: "App already exists" });
|
|
44062
|
+
ensureAppsRoot();
|
|
44063
|
+
const dir = appDir(id);
|
|
44064
|
+
fs4.mkdirSync(dir, { recursive: true });
|
|
44065
|
+
const cleanTitle2 = title.trim();
|
|
44066
|
+
fs4.writeFileSync(
|
|
44067
|
+
path5.join(dir, "manifest.json"),
|
|
44068
|
+
JSON.stringify(
|
|
44069
|
+
{
|
|
44070
|
+
title: cleanTitle2,
|
|
44071
|
+
description: description?.trim() || void 0,
|
|
44072
|
+
icon: icon?.trim() || void 0
|
|
44073
|
+
},
|
|
44074
|
+
null,
|
|
44075
|
+
2
|
|
44076
|
+
)
|
|
44077
|
+
);
|
|
44078
|
+
fs4.writeFileSync(path5.join(dir, "index.html"), SKELETON_HTML.replaceAll("__TITLE__", cleanTitle2));
|
|
44079
|
+
fs4.writeFileSync(path5.join(dir, "app.js"), SKELETON_JS);
|
|
44080
|
+
return { ok: true, id };
|
|
44081
|
+
}
|
|
44082
|
+
);
|
|
44083
|
+
fastify.post(
|
|
44084
|
+
"/api/apps/import",
|
|
44085
|
+
{
|
|
44086
|
+
schema: {
|
|
44087
|
+
body: {
|
|
44088
|
+
type: "object",
|
|
44089
|
+
required: ["id", "files"],
|
|
44090
|
+
properties: {
|
|
44091
|
+
id: { type: "string" },
|
|
44092
|
+
files: { type: "object", additionalProperties: { type: "string" } }
|
|
44093
|
+
}
|
|
44094
|
+
}
|
|
44095
|
+
}
|
|
44096
|
+
},
|
|
44097
|
+
async (request, reply) => {
|
|
44098
|
+
const { id, files } = request.body || {};
|
|
44099
|
+
if (!id || !APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44100
|
+
const entries = Object.entries(files ?? {});
|
|
44101
|
+
if (entries.length === 0) return reply.code(400).send({ error: "No files uploaded" });
|
|
44102
|
+
if (entries.length > IMPORT_MAX_FILES) {
|
|
44103
|
+
return reply.code(400).send({ error: `Too many files (max ${IMPORT_MAX_FILES})` });
|
|
44104
|
+
}
|
|
44105
|
+
for (const [name, content] of entries) {
|
|
44106
|
+
if (!IMPORT_FILE_RE.test(name)) return reply.code(400).send({ error: `Invalid file name: ${name}` });
|
|
44107
|
+
if (typeof content !== "string" || content.length > IMPORT_MAX_FILE_BYTES) {
|
|
44108
|
+
return reply.code(400).send({ error: `File too large: ${name}` });
|
|
44109
|
+
}
|
|
44110
|
+
}
|
|
44111
|
+
if (readManifest(id)) return reply.code(409).send({ error: "App already exists" });
|
|
44112
|
+
ensureAppsRoot();
|
|
44113
|
+
const dir = appDir(id);
|
|
44114
|
+
fs4.mkdirSync(dir, { recursive: true });
|
|
44115
|
+
if (!Object.hasOwn(files ?? {}, "manifest.json")) {
|
|
44116
|
+
fs4.writeFileSync(path5.join(dir, "manifest.json"), JSON.stringify({ title: id }, null, 2));
|
|
44117
|
+
}
|
|
44118
|
+
for (const [name, content] of entries) fs4.writeFileSync(path5.join(dir, name), content);
|
|
44119
|
+
return { ok: true, id };
|
|
44120
|
+
}
|
|
44121
|
+
);
|
|
44122
|
+
fastify.post(
|
|
44123
|
+
"/api/apps/mcp/call",
|
|
44124
|
+
{
|
|
44125
|
+
schema: {
|
|
44126
|
+
body: {
|
|
44127
|
+
type: "object",
|
|
44128
|
+
required: ["tool"],
|
|
44129
|
+
properties: {
|
|
44130
|
+
tool: { type: "string" },
|
|
44131
|
+
args: { type: ["object", "null"] }
|
|
44132
|
+
}
|
|
44133
|
+
}
|
|
44134
|
+
}
|
|
44135
|
+
},
|
|
44136
|
+
async (request, reply) => {
|
|
44137
|
+
const { tool, args } = request.body || {};
|
|
44138
|
+
try {
|
|
44139
|
+
const result = await callAppTool(tool, args ?? {});
|
|
44140
|
+
return { ok: true, result };
|
|
44141
|
+
} catch (err) {
|
|
44142
|
+
return reply.code(200).send({ ok: false, error: err.message });
|
|
44143
|
+
}
|
|
44144
|
+
}
|
|
44145
|
+
);
|
|
44146
|
+
fastify.post(
|
|
44147
|
+
"/api/apps/mcp/calls/:callId/result",
|
|
44148
|
+
{
|
|
44149
|
+
schema: {
|
|
44150
|
+
body: {
|
|
44151
|
+
type: "object",
|
|
44152
|
+
properties: {
|
|
44153
|
+
result: {},
|
|
44154
|
+
error: { type: ["string", "null"] }
|
|
44155
|
+
}
|
|
44156
|
+
}
|
|
44157
|
+
}
|
|
44158
|
+
},
|
|
44159
|
+
async (request, reply) => {
|
|
44160
|
+
const { callId } = request.params;
|
|
44161
|
+
const { result, error } = request.body || {};
|
|
44162
|
+
const answered = resolveAppToolCall(callId, result, error ?? void 0);
|
|
44163
|
+
if (!answered) {
|
|
44164
|
+
return reply.code(404).send({ error: "Unknown or already-answered tool call" });
|
|
44165
|
+
}
|
|
44166
|
+
return { ok: true };
|
|
44167
|
+
}
|
|
44168
|
+
);
|
|
44169
|
+
fastify.get("/api/apps/:id/source", async (request, reply) => {
|
|
44170
|
+
const { id } = request.params;
|
|
44171
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44172
|
+
const manifest = readManifest(id);
|
|
44173
|
+
if (!manifest) return reply.code(404).send({ error: "App not found" });
|
|
44174
|
+
return {
|
|
44175
|
+
manifest,
|
|
44176
|
+
html: readAppFile(id, "index.html"),
|
|
44177
|
+
js: readAppFile(id, "app.js")
|
|
44178
|
+
};
|
|
44179
|
+
});
|
|
44180
|
+
fastify.get(
|
|
44181
|
+
"/api/apps/:id/state",
|
|
44182
|
+
{ schema: { querystring: { type: "object", properties: { workspace: { type: "string" } } } } },
|
|
44183
|
+
async (request, reply) => {
|
|
44184
|
+
const { id } = request.params;
|
|
44185
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44186
|
+
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
44187
|
+
return getInstanceState(id, request.query?.workspace ?? "");
|
|
44188
|
+
}
|
|
44189
|
+
);
|
|
44190
|
+
fastify.put(
|
|
44191
|
+
"/api/apps/:id/state",
|
|
44192
|
+
{
|
|
44193
|
+
schema: {
|
|
44194
|
+
querystring: { type: "object", properties: { workspace: { type: "string" } } },
|
|
44195
|
+
body: {
|
|
44196
|
+
type: "object",
|
|
44197
|
+
properties: {
|
|
44198
|
+
pinned: { type: "boolean" },
|
|
44199
|
+
data: { type: ["object", "null"] }
|
|
44200
|
+
}
|
|
44201
|
+
}
|
|
44202
|
+
}
|
|
44203
|
+
},
|
|
44204
|
+
async (request, reply) => {
|
|
44205
|
+
const { id } = request.params;
|
|
44206
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44207
|
+
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
44208
|
+
return updateInstanceState(id, request.query?.workspace ?? "", request.body || {});
|
|
44209
|
+
}
|
|
44210
|
+
);
|
|
44211
|
+
fastify.delete("/api/apps/:id", async (request, reply) => {
|
|
44212
|
+
const { id } = request.params;
|
|
44213
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44214
|
+
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
44215
|
+
fs4.rmSync(appDir(id), { recursive: true, force: true });
|
|
44216
|
+
deleteAppInstances(id);
|
|
44217
|
+
invalidateHeadlessRuntime(id);
|
|
44218
|
+
return { ok: true };
|
|
44219
|
+
});
|
|
44220
|
+
fastify.get("/api/apps/:id/sessions", async (request, reply) => {
|
|
44221
|
+
const { id } = request.params;
|
|
44222
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44223
|
+
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
44224
|
+
const rows = getDb().prepare("SELECT * FROM sessions WHERE origin_app_id = ? ORDER BY created_at DESC").all(id);
|
|
44225
|
+
return rows;
|
|
44226
|
+
});
|
|
44227
|
+
fastify.post(
|
|
44228
|
+
"/api/apps/:id/edit-session",
|
|
44229
|
+
{
|
|
44230
|
+
schema: {
|
|
44231
|
+
body: {
|
|
44232
|
+
type: "object",
|
|
44233
|
+
properties: {
|
|
44234
|
+
runtime_type: { type: "string" },
|
|
44235
|
+
model: { type: ["string", "null"] },
|
|
44236
|
+
model_reasoning_effort: { type: ["string", "null"] }
|
|
44237
|
+
}
|
|
44238
|
+
}
|
|
44239
|
+
}
|
|
44240
|
+
},
|
|
44241
|
+
async (request, reply) => {
|
|
44242
|
+
const { id } = request.params;
|
|
44243
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44244
|
+
const manifest = readManifest(id);
|
|
44245
|
+
if (!manifest) return reply.code(404).send({ error: "App not found" });
|
|
44246
|
+
const dir = appDir(id);
|
|
44247
|
+
const db2 = getDb();
|
|
44248
|
+
const existing = db2.prepare("SELECT * FROM sessions WHERE origin_app_id = ? AND cwd = ? ORDER BY created_at DESC LIMIT 1").get(id, dir);
|
|
44249
|
+
if (existing) return existing;
|
|
44250
|
+
const { runtime_type = "claude", model = null, model_reasoning_effort = null } = request.body || {};
|
|
44251
|
+
const sessionId = v4_default();
|
|
44252
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
44253
|
+
const maxOrder = db2.prepare("SELECT COALESCE(MAX(sort_order), 0) AS m FROM sessions WHERE cwd = ?").get(dir);
|
|
44254
|
+
db2.prepare(
|
|
44255
|
+
`INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status, is_running, sort_order, created_at, updated_at, origin_app_id)
|
|
44256
|
+
VALUES (?, ?, ?, ?, ?, ?, NULL, 'active', 0, ?, ?, ?, ?)`
|
|
44257
|
+
).run(
|
|
44258
|
+
sessionId,
|
|
44259
|
+
`Edit: ${manifest.title}`,
|
|
44260
|
+
runtime_type,
|
|
44261
|
+
model,
|
|
44262
|
+
model_reasoning_effort,
|
|
44263
|
+
dir,
|
|
44264
|
+
maxOrder.m + 1,
|
|
44265
|
+
now,
|
|
44266
|
+
now,
|
|
44267
|
+
id
|
|
44268
|
+
);
|
|
44269
|
+
return db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
|
|
44270
|
+
}
|
|
44271
|
+
);
|
|
44272
|
+
}
|
|
44273
|
+
|
|
43477
44274
|
// src/codex/item-mapper.ts
|
|
43478
44275
|
function mapItemData(item) {
|
|
43479
44276
|
switch (item.type) {
|
|
@@ -43542,6 +44339,99 @@ function mapTokenUsage(data) {
|
|
|
43542
44339
|
};
|
|
43543
44340
|
}
|
|
43544
44341
|
|
|
44342
|
+
// src/apps/register-mcp.ts
|
|
44343
|
+
import fs5 from "node:fs";
|
|
44344
|
+
import path6 from "node:path";
|
|
44345
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
44346
|
+
var MCP_SERVER_NAME = "agentpane-miniapps";
|
|
44347
|
+
function panePublicUrl() {
|
|
44348
|
+
return (process.env.AGENT_PANE_PUBLIC_URL || process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
|
|
44349
|
+
}
|
|
44350
|
+
function stdioScriptPath() {
|
|
44351
|
+
const here = path6.dirname(fileURLToPath2(import.meta.url));
|
|
44352
|
+
const candidates = [
|
|
44353
|
+
path6.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
|
|
44354
|
+
// src/apps/ → backend/scripts
|
|
44355
|
+
path6.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
|
|
44356
|
+
// dist bundle → backend/scripts
|
|
44357
|
+
];
|
|
44358
|
+
for (const candidate of candidates) {
|
|
44359
|
+
if (fs5.existsSync(candidate)) return candidate;
|
|
44360
|
+
}
|
|
44361
|
+
return null;
|
|
44362
|
+
}
|
|
44363
|
+
var registered = /* @__PURE__ */ new Set();
|
|
44364
|
+
async function registerMiniAppMcp(baseUrl) {
|
|
44365
|
+
if (registered.has(baseUrl)) return true;
|
|
44366
|
+
const script = stdioScriptPath();
|
|
44367
|
+
if (!script) {
|
|
44368
|
+
console.warn("[miniapp-mcp] stdio proxy script not found \u2014 registration skipped");
|
|
44369
|
+
return false;
|
|
44370
|
+
}
|
|
44371
|
+
if (!anyAppHasTools()) {
|
|
44372
|
+
return false;
|
|
44373
|
+
}
|
|
44374
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
44375
|
+
try {
|
|
44376
|
+
try {
|
|
44377
|
+
const res2 = await fetch(`${base}/mcp/servers`, { signal: AbortSignal.timeout(5e3) });
|
|
44378
|
+
if (res2.ok) {
|
|
44379
|
+
const servers = await res2.json();
|
|
44380
|
+
const names = servers.map((s) => s.server_name ?? s.name);
|
|
44381
|
+
if (names.includes(MCP_SERVER_NAME)) {
|
|
44382
|
+
registered.add(baseUrl);
|
|
44383
|
+
return true;
|
|
44384
|
+
}
|
|
44385
|
+
}
|
|
44386
|
+
} catch {
|
|
44387
|
+
}
|
|
44388
|
+
const body = {
|
|
44389
|
+
configJson: JSON.stringify({
|
|
44390
|
+
[MCP_SERVER_NAME]: {
|
|
44391
|
+
command: process.execPath,
|
|
44392
|
+
args: [script, panePublicUrl()],
|
|
44393
|
+
env: {}
|
|
44394
|
+
}
|
|
44395
|
+
})
|
|
44396
|
+
};
|
|
44397
|
+
const res = await fetch(`${base}/mcp/configs`, {
|
|
44398
|
+
method: "POST",
|
|
44399
|
+
headers: { "Content-Type": "application/json" },
|
|
44400
|
+
body: JSON.stringify(body),
|
|
44401
|
+
signal: AbortSignal.timeout(1e4)
|
|
44402
|
+
});
|
|
44403
|
+
if (res.status === 201) {
|
|
44404
|
+
console.log(`[miniapp-mcp] gateway registered in workspace backend ${base}`);
|
|
44405
|
+
registered.add(baseUrl);
|
|
44406
|
+
return true;
|
|
44407
|
+
}
|
|
44408
|
+
const text = await res.text();
|
|
44409
|
+
if (res.status === 400 && /already exists/i.test(text)) {
|
|
44410
|
+
registered.add(baseUrl);
|
|
44411
|
+
return true;
|
|
44412
|
+
}
|
|
44413
|
+
console.warn(`[miniapp-mcp] registration failed (${res.status}): ${text.slice(0, 200)}`);
|
|
44414
|
+
return false;
|
|
44415
|
+
} catch (err) {
|
|
44416
|
+
console.warn(`[miniapp-mcp] registration error: ${err.message}`);
|
|
44417
|
+
return false;
|
|
44418
|
+
}
|
|
44419
|
+
}
|
|
44420
|
+
function codexMiniAppLaunchArgs() {
|
|
44421
|
+
const script = stdioScriptPath();
|
|
44422
|
+
if (!script || !anyAppHasTools()) return null;
|
|
44423
|
+
return [
|
|
44424
|
+
// MCP tool calls must not ask for elicitation approval — nobody is
|
|
44425
|
+
// watching an agent-driven session to approve (feature is stable/on).
|
|
44426
|
+
"-c",
|
|
44427
|
+
"features.tool_call_mcp_elicitation=false",
|
|
44428
|
+
"-c",
|
|
44429
|
+
`mcp_servers.${MCP_SERVER_NAME}.command=${JSON.stringify(process.execPath)}`,
|
|
44430
|
+
"-c",
|
|
44431
|
+
`mcp_servers.${MCP_SERVER_NAME}.args=${JSON.stringify([script, panePublicUrl()])}`
|
|
44432
|
+
];
|
|
44433
|
+
}
|
|
44434
|
+
|
|
43545
44435
|
// src/codex/codex-provider.ts
|
|
43546
44436
|
var sessionMap = /* @__PURE__ */ new Map();
|
|
43547
44437
|
function setSessionStatus(db2, sessionId, isRunning, status, now, hasUnreviewed = false) {
|
|
@@ -43602,12 +44492,32 @@ function isEmptyReasoning(item) {
|
|
|
43602
44492
|
const text = item.text ?? "";
|
|
43603
44493
|
return summary.length === 0 && content.length === 0 && text.length === 0;
|
|
43604
44494
|
}
|
|
44495
|
+
function appServerClientOptions(_session, cwd) {
|
|
44496
|
+
const launchArgs = codexMiniAppLaunchArgs();
|
|
44497
|
+
return launchArgs ? { cwd, launchArgs } : { cwd, launchArgs: [] };
|
|
44498
|
+
}
|
|
44499
|
+
function autoApproveToolUserInput(client) {
|
|
44500
|
+
client.onRequest("item/tool/requestUserInput", async (params) => {
|
|
44501
|
+
const questions = params.questions ?? [];
|
|
44502
|
+
const answers = {};
|
|
44503
|
+
for (const question of questions) {
|
|
44504
|
+
if (!question.options?.some((option) => option.label === "Allow")) {
|
|
44505
|
+
throw new Error(`Unhandled app-server question (no Allow option): ${question.id}`);
|
|
44506
|
+
}
|
|
44507
|
+
answers[question.id] = { answers: ["Allow"] };
|
|
44508
|
+
}
|
|
44509
|
+
return { answers };
|
|
44510
|
+
});
|
|
44511
|
+
}
|
|
43605
44512
|
async function getOrCreateThread(session) {
|
|
43606
44513
|
const existing = sessionMap.get(session.id);
|
|
43607
44514
|
if (existing) return existing;
|
|
43608
44515
|
const cwd = session.cwd ?? process.cwd();
|
|
43609
|
-
const client = new AppServerClient(
|
|
44516
|
+
const client = new AppServerClient(appServerClientOptions(session, cwd));
|
|
43610
44517
|
await client.initialize();
|
|
44518
|
+
if (session.origin_app_id) {
|
|
44519
|
+
autoApproveToolUserInput(client);
|
|
44520
|
+
}
|
|
43611
44521
|
const config = parseRuntimeConfig(session);
|
|
43612
44522
|
const sandbox = sandboxType(config);
|
|
43613
44523
|
let threadId;
|
|
@@ -43693,6 +44603,18 @@ async function startTurn(session, turn) {
|
|
|
43693
44603
|
turnDone = true;
|
|
43694
44604
|
const db3 = getDb();
|
|
43695
44605
|
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
44606
|
+
if (p.turn?.status === "failed") {
|
|
44607
|
+
const errMsg = p.turn.error?.message ?? "Codex turn failed";
|
|
44608
|
+
db3.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
|
|
44609
|
+
"failed",
|
|
44610
|
+
errMsg,
|
|
44611
|
+
now2,
|
|
44612
|
+
turn.id
|
|
44613
|
+
);
|
|
44614
|
+
recomputeSessionRunning(db3, session.id, "failed");
|
|
44615
|
+
broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: errMsg });
|
|
44616
|
+
return;
|
|
44617
|
+
}
|
|
43696
44618
|
if (p.usage !== void 0) {
|
|
43697
44619
|
db3.prepare("UPDATE turns SET status = ?, token_usage = ?, updated_at = ? WHERE id = ?").run(
|
|
43698
44620
|
"completed",
|
|
@@ -44151,9 +45073,9 @@ function mapToolUse(block) {
|
|
|
44151
45073
|
};
|
|
44152
45074
|
}
|
|
44153
45075
|
function deriveFileChangeData(input, toolName) {
|
|
44154
|
-
const
|
|
45076
|
+
const path8 = input.file_path ?? input.notebook_path ?? "";
|
|
44155
45077
|
const kind = toolName === "Write" ? "add" : "modify";
|
|
44156
|
-
return { changes: [{ path:
|
|
45078
|
+
return { changes: [{ path: path8, kind }], status: "in_progress" };
|
|
44157
45079
|
}
|
|
44158
45080
|
function extractToolResultText(content) {
|
|
44159
45081
|
if (!content) return "";
|
|
@@ -45184,8 +46106,8 @@ var RepoburgHttpClient = class {
|
|
|
45184
46106
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
45185
46107
|
}
|
|
45186
46108
|
/** Perform a JSON request. Throws a concise error on non-OK/non-JSON responses. */
|
|
45187
|
-
async request(method,
|
|
45188
|
-
const response = await fetch(`${this.baseUrl}${
|
|
46109
|
+
async request(method, path8, body) {
|
|
46110
|
+
const response = await fetch(`${this.baseUrl}${path8}`, {
|
|
45189
46111
|
method,
|
|
45190
46112
|
headers: { "Content-Type": "application/json" },
|
|
45191
46113
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
@@ -45194,17 +46116,17 @@ var RepoburgHttpClient = class {
|
|
|
45194
46116
|
if (!response.ok) {
|
|
45195
46117
|
if (isHtml(text)) {
|
|
45196
46118
|
throw new Error(
|
|
45197
|
-
`${method} ${
|
|
46119
|
+
`${method} ${path8} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
45198
46120
|
);
|
|
45199
46121
|
}
|
|
45200
|
-
throw new Error(`${method} ${
|
|
46122
|
+
throw new Error(`${method} ${path8} failed: ${response.status} ${text}`);
|
|
45201
46123
|
}
|
|
45202
46124
|
if (text.length === 0) return void 0;
|
|
45203
46125
|
try {
|
|
45204
46126
|
return JSON.parse(text);
|
|
45205
46127
|
} catch {
|
|
45206
46128
|
throw new Error(
|
|
45207
|
-
`${method} ${
|
|
46129
|
+
`${method} ${path8} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
45208
46130
|
);
|
|
45209
46131
|
}
|
|
45210
46132
|
}
|
|
@@ -45259,7 +46181,7 @@ var RepoburgHttpClient = class {
|
|
|
45259
46181
|
};
|
|
45260
46182
|
|
|
45261
46183
|
// src/repoburg/backend-resolver.ts
|
|
45262
|
-
import
|
|
46184
|
+
import path7 from "node:path";
|
|
45263
46185
|
var HEALTH_POLL_INTERVAL_MS = 1e3;
|
|
45264
46186
|
var HEALTH_TIMEOUT_MS = 3e4;
|
|
45265
46187
|
function daemonBaseUrl() {
|
|
@@ -45314,7 +46236,7 @@ async function backendHealthy(baseUrl, expectedPath) {
|
|
|
45314
46236
|
const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
|
|
45315
46237
|
if (health.status !== "ok") return false;
|
|
45316
46238
|
if (expectedPath && health.projectPath) {
|
|
45317
|
-
return
|
|
46239
|
+
return path7.resolve(health.projectPath) === path7.resolve(expectedPath);
|
|
45318
46240
|
}
|
|
45319
46241
|
return true;
|
|
45320
46242
|
} catch {
|
|
@@ -45334,6 +46256,9 @@ async function waitForHealthy(baseUrl, name, expectedPath) {
|
|
|
45334
46256
|
function serviceBaseUrl(service) {
|
|
45335
46257
|
return `http://localhost:${service.port}`;
|
|
45336
46258
|
}
|
|
46259
|
+
function coveringService(services, absPath) {
|
|
46260
|
+
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path7.sep)).sort((a, b) => b.path.length - a.path.length)[0];
|
|
46261
|
+
}
|
|
45337
46262
|
async function restartService(daemon, name) {
|
|
45338
46263
|
try {
|
|
45339
46264
|
await fetchJson(`${daemon}/services/${name}/restart`, { method: "POST" });
|
|
@@ -45356,7 +46281,8 @@ function cache(absPath, service) {
|
|
|
45356
46281
|
const resolved = {
|
|
45357
46282
|
baseUrl: serviceBaseUrl(service),
|
|
45358
46283
|
port: service.port,
|
|
45359
|
-
name: service.name
|
|
46284
|
+
name: service.name,
|
|
46285
|
+
servesPath: service.path
|
|
45360
46286
|
};
|
|
45361
46287
|
resolvedCache.set(absPath, resolved);
|
|
45362
46288
|
return resolved;
|
|
@@ -45367,10 +46293,10 @@ async function resolveBackendUrl(projectPath, opts = {}) {
|
|
|
45367
46293
|
if (envUrl) {
|
|
45368
46294
|
return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
|
|
45369
46295
|
}
|
|
45370
|
-
const absPath =
|
|
46296
|
+
const absPath = path7.resolve(projectPath);
|
|
45371
46297
|
const daemon = daemonBaseUrl();
|
|
45372
46298
|
const cached = resolvedCache.get(absPath);
|
|
45373
|
-
if (cached && await backendHealthy(cached.baseUrl, absPath)) {
|
|
46299
|
+
if (cached && await backendHealthy(cached.baseUrl, cached.servesPath ?? absPath)) {
|
|
45374
46300
|
return cached;
|
|
45375
46301
|
}
|
|
45376
46302
|
try {
|
|
@@ -45381,20 +46307,20 @@ async function resolveBackendUrl(projectPath, opts = {}) {
|
|
|
45381
46307
|
);
|
|
45382
46308
|
}
|
|
45383
46309
|
const services = await fetchJson(`${daemon}/services`);
|
|
45384
|
-
const match = services
|
|
46310
|
+
const match = coveringService(services, absPath);
|
|
45385
46311
|
if (match && match.status === "running") {
|
|
45386
|
-
if (await backendHealthy(serviceBaseUrl(match),
|
|
46312
|
+
if (await backendHealthy(serviceBaseUrl(match), match.path)) {
|
|
45387
46313
|
return cache(absPath, match);
|
|
45388
46314
|
}
|
|
45389
46315
|
if (!autoStart) return null;
|
|
45390
46316
|
await restartService(daemon, match.name);
|
|
45391
|
-
await waitForHealthy(serviceBaseUrl(match), match.name,
|
|
46317
|
+
await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
|
|
45392
46318
|
return cache(absPath, match);
|
|
45393
46319
|
}
|
|
45394
46320
|
if (!autoStart) return null;
|
|
45395
46321
|
if (match) {
|
|
45396
46322
|
await restartService(daemon, match.name);
|
|
45397
|
-
await waitForHealthy(serviceBaseUrl(match), match.name,
|
|
46323
|
+
await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
|
|
45398
46324
|
return cache(absPath, match);
|
|
45399
46325
|
}
|
|
45400
46326
|
const service = await startService(daemon, absPath);
|
|
@@ -46542,6 +47468,7 @@ async function startTurn3(session, turn) {
|
|
|
46542
47468
|
`[repoburg] resolved backend ${baseUrl} differs from pinned ${pinned.baseUrl} for session ${session.id} \u2014 keeping the pinned entry.`
|
|
46543
47469
|
);
|
|
46544
47470
|
}
|
|
47471
|
+
void registerMiniAppMcp(baseUrl);
|
|
46545
47472
|
let entry;
|
|
46546
47473
|
try {
|
|
46547
47474
|
entry = turn.thread_id ? await ensureThreadSession(session, turn, client, baseUrl) : await ensureSession(session, client, baseUrl);
|
|
@@ -46766,7 +47693,7 @@ registerProvider("repoburg", repoburgProvider);
|
|
|
46766
47693
|
async function createAgentPaneApp(dbPath) {
|
|
46767
47694
|
initDb(dbPath);
|
|
46768
47695
|
const fastify = (0, import_fastify.default)({ logger: true, bodyLimit: 50 * 1024 * 1024 });
|
|
46769
|
-
await fastify.register(import_cors.default, { origin: true });
|
|
47696
|
+
await fastify.register(import_cors.default, { origin: true, methods: "GET,HEAD,PUT,PATCH,POST,DELETE" });
|
|
46770
47697
|
await registerSessionRoutes(fastify);
|
|
46771
47698
|
await registerTurnRoutes(fastify);
|
|
46772
47699
|
await registerThreadRoutes(fastify);
|
|
@@ -46781,6 +47708,7 @@ async function createAgentPaneApp(dbPath) {
|
|
|
46781
47708
|
await registerPerfLogRoutes(fastify);
|
|
46782
47709
|
await registerMaintenanceRoutes(fastify);
|
|
46783
47710
|
await registerVscodeWebRoutes(fastify);
|
|
47711
|
+
await registerAppRoutes(fastify);
|
|
46784
47712
|
const wss2 = initWs();
|
|
46785
47713
|
return { fastify, wss: wss2 };
|
|
46786
47714
|
}
|