repoburg 1.3.234 → 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 +3 -3
- 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-BGAclp9s.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");
|
|
@@ -41388,7 +41403,8 @@ async function registerSessionRoutes(fastify) {
|
|
|
41388
41403
|
model: { type: ["string", "null"] },
|
|
41389
41404
|
model_reasoning_effort: { type: ["string", "null"] },
|
|
41390
41405
|
cwd: { type: ["string", "null"] },
|
|
41391
|
-
runtime_config: { type: ["string", "null"] }
|
|
41406
|
+
runtime_config: { type: ["string", "null"] },
|
|
41407
|
+
origin_app_id: { type: ["string", "null"] }
|
|
41392
41408
|
}
|
|
41393
41409
|
}
|
|
41394
41410
|
}
|
|
@@ -41399,16 +41415,17 @@ async function registerSessionRoutes(fastify) {
|
|
|
41399
41415
|
model = null,
|
|
41400
41416
|
model_reasoning_effort = null,
|
|
41401
41417
|
cwd = null,
|
|
41402
|
-
runtime_config = null
|
|
41418
|
+
runtime_config = null,
|
|
41419
|
+
origin_app_id = null
|
|
41403
41420
|
} = request.body || {};
|
|
41404
41421
|
const id = v4_default();
|
|
41405
41422
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41406
41423
|
const db2 = getDb();
|
|
41407
41424
|
const maxOrder = db2.prepare("SELECT COALESCE(MAX(sort_order), 0) AS m FROM sessions WHERE cwd = ?").get(cwd ?? null);
|
|
41408
41425
|
db2.prepare(
|
|
41409
|
-
`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)
|
|
41410
|
-
VALUES (?, ?, ?, ?, ?, ?, NULL, 'active', 0, ?, ?, ?, ?)`
|
|
41411
|
-
).run(id, title, runtime_type, model, model_reasoning_effort, cwd, maxOrder.m + 1, now, now, runtime_config);
|
|
41426
|
+
`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)
|
|
41427
|
+
VALUES (?, ?, ?, ?, ?, ?, NULL, 'active', 0, ?, ?, ?, ?, ?)`
|
|
41428
|
+
).run(id, title, runtime_type, model, model_reasoning_effort, cwd, maxOrder.m + 1, now, now, runtime_config, origin_app_id);
|
|
41412
41429
|
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
41413
41430
|
return session;
|
|
41414
41431
|
});
|
|
@@ -42218,11 +42235,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42218
42235
|
}
|
|
42219
42236
|
}
|
|
42220
42237
|
}, async (request, reply) => {
|
|
42221
|
-
const { path:
|
|
42222
|
-
if (!
|
|
42238
|
+
const { path: path8, label = null } = request.body || {};
|
|
42239
|
+
if (!path8 || !path8.trim()) {
|
|
42223
42240
|
return reply.code(400).send({ error: "Path is required" });
|
|
42224
42241
|
}
|
|
42225
|
-
const trimmedPath =
|
|
42242
|
+
const trimmedPath = path8.trim();
|
|
42226
42243
|
const db2 = getDb();
|
|
42227
42244
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
42228
42245
|
if (existing) {
|
|
@@ -42250,8 +42267,8 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42250
42267
|
"-e",
|
|
42251
42268
|
'POSIX path of (choose folder with prompt "Select a workspace directory")'
|
|
42252
42269
|
]);
|
|
42253
|
-
const
|
|
42254
|
-
return { path:
|
|
42270
|
+
const path8 = stdout.trim().replace(/\/$/, "");
|
|
42271
|
+
return { path: path8 };
|
|
42255
42272
|
} catch {
|
|
42256
42273
|
return reply.code(204).send({ cancelled: true });
|
|
42257
42274
|
}
|
|
@@ -42267,11 +42284,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42267
42284
|
}
|
|
42268
42285
|
}
|
|
42269
42286
|
}, async (request, reply) => {
|
|
42270
|
-
const { path:
|
|
42271
|
-
if (!
|
|
42287
|
+
const { path: path8 } = request.body || {};
|
|
42288
|
+
if (!path8 || !path8.trim()) {
|
|
42272
42289
|
return reply.code(400).send({ error: "Path is required" });
|
|
42273
42290
|
}
|
|
42274
|
-
const trimmedPath =
|
|
42291
|
+
const trimmedPath = path8.trim();
|
|
42275
42292
|
const db2 = getDb();
|
|
42276
42293
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
42277
42294
|
if (existing) {
|
|
@@ -42536,6 +42553,8 @@ var AppServerClient = class {
|
|
|
42536
42553
|
buffer = "";
|
|
42537
42554
|
closed = false;
|
|
42538
42555
|
clientInfo;
|
|
42556
|
+
/** Bound stdout listener — removed in close() so stale data is not processed. */
|
|
42557
|
+
stdoutListener = (chunk) => this.onStdoutData(chunk);
|
|
42539
42558
|
events = new EventEmitter();
|
|
42540
42559
|
constructor(options) {
|
|
42541
42560
|
const binary = options.binaryPath ?? "codex";
|
|
@@ -42547,7 +42566,7 @@ var AppServerClient = class {
|
|
|
42547
42566
|
});
|
|
42548
42567
|
this.clientInfo = options.clientInfo ?? { name: "agentpane", title: "AgentPane", version: "1.0.0" };
|
|
42549
42568
|
this.proc.stdout?.setEncoding("utf-8");
|
|
42550
|
-
this.proc.stdout?.on("data",
|
|
42569
|
+
this.proc.stdout?.on("data", this.stdoutListener);
|
|
42551
42570
|
this.proc.stderr?.on("data", (chunk) => {
|
|
42552
42571
|
const text = chunk.toString().trim();
|
|
42553
42572
|
if (text) console.error("[app-server] stderr:", text);
|
|
@@ -42616,6 +42635,7 @@ var AppServerClient = class {
|
|
|
42616
42635
|
async close() {
|
|
42617
42636
|
if (this.closed) return;
|
|
42618
42637
|
this.closed = true;
|
|
42638
|
+
this.proc.stdout?.removeListener("data", this.stdoutListener);
|
|
42619
42639
|
for (const [id, entry] of this.pending) {
|
|
42620
42640
|
clearTimeout(entry.timer);
|
|
42621
42641
|
entry.reject(new Error("AppServerClient closed"));
|
|
@@ -42628,6 +42648,7 @@ var AppServerClient = class {
|
|
|
42628
42648
|
this.proc.stdin?.write(message);
|
|
42629
42649
|
}
|
|
42630
42650
|
onStdoutData(chunk) {
|
|
42651
|
+
if (this.closed) return;
|
|
42631
42652
|
this.buffer += chunk;
|
|
42632
42653
|
const lines = this.buffer.split("\n");
|
|
42633
42654
|
this.buffer = lines.pop() ?? "";
|
|
@@ -42644,11 +42665,18 @@ var AppServerClient = class {
|
|
|
42644
42665
|
} catch {
|
|
42645
42666
|
return;
|
|
42646
42667
|
}
|
|
42647
|
-
|
|
42648
|
-
|
|
42668
|
+
const hasId = "id" in msg && typeof msg.id === "number";
|
|
42669
|
+
const hasMethod = "method" in msg && typeof msg.method === "string";
|
|
42670
|
+
if (hasId && hasMethod) {
|
|
42671
|
+
this.handleServerRequest(msg.method, msg.id, msg.params);
|
|
42672
|
+
return;
|
|
42673
|
+
}
|
|
42674
|
+
if (hasId) {
|
|
42675
|
+
const id = msg.id;
|
|
42676
|
+
const pending = this.pending.get(id);
|
|
42649
42677
|
if (!pending) return;
|
|
42650
42678
|
clearTimeout(pending.timer);
|
|
42651
|
-
this.pending.delete(
|
|
42679
|
+
this.pending.delete(id);
|
|
42652
42680
|
if (msg.error) {
|
|
42653
42681
|
const err = msg.error;
|
|
42654
42682
|
pending.reject(new Error(`JSON-RPC error ${err.code}: ${err.message}`));
|
|
@@ -42657,17 +42685,35 @@ var AppServerClient = class {
|
|
|
42657
42685
|
}
|
|
42658
42686
|
return;
|
|
42659
42687
|
}
|
|
42660
|
-
if (
|
|
42661
|
-
const
|
|
42688
|
+
if (hasMethod) {
|
|
42689
|
+
const method = msg.method;
|
|
42690
|
+
const handlers = this.notificationHandlers.get(method);
|
|
42662
42691
|
if (handlers) {
|
|
42663
42692
|
for (const handler of handlers) {
|
|
42664
42693
|
handler(msg.params);
|
|
42665
42694
|
}
|
|
42666
42695
|
}
|
|
42667
|
-
this.events.emit("notification",
|
|
42696
|
+
this.events.emit("notification", method, msg.params);
|
|
42668
42697
|
return;
|
|
42669
42698
|
}
|
|
42670
42699
|
}
|
|
42700
|
+
/**
|
|
42701
|
+
* Handle a server→client JSON-RPC request. The last registered handler
|
|
42702
|
+
* runs and its result is sent back; unhandled requests are declined with
|
|
42703
|
+
* a -32601 error so the server never waits forever.
|
|
42704
|
+
*/
|
|
42705
|
+
handleServerRequest(method, id, params) {
|
|
42706
|
+
const respond = (payload) => {
|
|
42707
|
+
this.write(JSON.stringify({ jsonrpc: "2.0", id, ...payload }) + "\n");
|
|
42708
|
+
};
|
|
42709
|
+
const handlers = this.requestHandlers.get(method);
|
|
42710
|
+
if (!handlers || handlers.length === 0) {
|
|
42711
|
+
respond({ error: { code: -32601, message: `Method not found: ${method}` } });
|
|
42712
|
+
return;
|
|
42713
|
+
}
|
|
42714
|
+
const handler = handlers[handlers.length - 1];
|
|
42715
|
+
Promise.resolve(handler(params)).then((result) => respond({ result: result ?? {} })).catch((err) => respond({ error: { code: -32e3, message: err.message } }));
|
|
42716
|
+
}
|
|
42671
42717
|
onProcessExit(code, signal) {
|
|
42672
42718
|
if (this.closed) return;
|
|
42673
42719
|
this.closed = true;
|
|
@@ -42889,17 +42935,17 @@ async function registerPerfLogRoutes(fastify) {
|
|
|
42889
42935
|
if (entries.length === 0) {
|
|
42890
42936
|
return reply.send({ written: 0 });
|
|
42891
42937
|
}
|
|
42892
|
-
const
|
|
42938
|
+
const path8 = perfLogPath();
|
|
42893
42939
|
try {
|
|
42894
|
-
mkdirSync(dirname(
|
|
42940
|
+
mkdirSync(dirname(path8), { recursive: true });
|
|
42895
42941
|
try {
|
|
42896
|
-
if (statSync(
|
|
42897
|
-
renameSync(
|
|
42942
|
+
if (statSync(path8).size > MAX_BYTES) {
|
|
42943
|
+
renameSync(path8, `${path8}.1`);
|
|
42898
42944
|
}
|
|
42899
42945
|
} catch {
|
|
42900
42946
|
}
|
|
42901
42947
|
const lines = entries.map((e) => `${new Date(e.t).toISOString()} [${oneLine(e.cat)}] ${oneLine(e.msg)}`).join("\n");
|
|
42902
|
-
appendFileSync(
|
|
42948
|
+
appendFileSync(path8, `${lines}
|
|
42903
42949
|
`, "utf-8");
|
|
42904
42950
|
return reply.send({ written: entries.length });
|
|
42905
42951
|
} catch (err) {
|
|
@@ -43461,6 +43507,757 @@ function proxyHandler(request, reply) {
|
|
|
43461
43507
|
upstream.end();
|
|
43462
43508
|
}
|
|
43463
43509
|
|
|
43510
|
+
// src/routes/apps.ts
|
|
43511
|
+
import fs4 from "node:fs";
|
|
43512
|
+
import path5 from "node:path";
|
|
43513
|
+
|
|
43514
|
+
// src/apps/instances.ts
|
|
43515
|
+
import fs2 from "node:fs";
|
|
43516
|
+
import path4 from "node:path";
|
|
43517
|
+
|
|
43518
|
+
// src/apps/apps-registry.ts
|
|
43519
|
+
import fs from "node:fs";
|
|
43520
|
+
import path3 from "node:path";
|
|
43521
|
+
import os2 from "node:os";
|
|
43522
|
+
import { fileURLToPath } from "node:url";
|
|
43523
|
+
var APP_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
43524
|
+
var rootOverride = null;
|
|
43525
|
+
function setAppsRootOverride(root) {
|
|
43526
|
+
rootOverride = root;
|
|
43527
|
+
}
|
|
43528
|
+
function appsRoot() {
|
|
43529
|
+
return rootOverride ?? process.env.AGENT_PANE_APPS_DIR ?? path3.join(os2.homedir(), ".repoburg", "agent-pane", "apps");
|
|
43530
|
+
}
|
|
43531
|
+
function appDir(id) {
|
|
43532
|
+
return path3.join(appsRoot(), id);
|
|
43533
|
+
}
|
|
43534
|
+
var examplesRootOverride = null;
|
|
43535
|
+
function setExamplesRootOverride(root) {
|
|
43536
|
+
examplesRootOverride = root;
|
|
43537
|
+
}
|
|
43538
|
+
function examplesRoot() {
|
|
43539
|
+
if (examplesRootOverride) return examplesRootOverride;
|
|
43540
|
+
if (process.env.AGENT_PANE_EXAMPLES_DIR) return process.env.AGENT_PANE_EXAMPLES_DIR;
|
|
43541
|
+
const here = path3.dirname(fileURLToPath(import.meta.url));
|
|
43542
|
+
for (const candidate of [path3.resolve(here, "../../examples"), path3.resolve(here, "../../../examples")]) {
|
|
43543
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
43544
|
+
}
|
|
43545
|
+
return null;
|
|
43546
|
+
}
|
|
43547
|
+
function ensureAppsRoot() {
|
|
43548
|
+
const root = appsRoot();
|
|
43549
|
+
fs.mkdirSync(root, { recursive: true });
|
|
43550
|
+
for (const name of ["CLAUDE.md", "AGENTS.md"]) {
|
|
43551
|
+
const file = path3.join(root, name);
|
|
43552
|
+
if (!fs.existsSync(file)) fs.writeFileSync(file, APPS_MD_SKELETON);
|
|
43553
|
+
}
|
|
43554
|
+
}
|
|
43555
|
+
var APPS_MD_SKELETON = `# Mini Apps
|
|
43556
|
+
|
|
43557
|
+
Each subdirectory of this folder is one mini app:
|
|
43558
|
+
|
|
43559
|
+
<app-id>/
|
|
43560
|
+
manifest.json - { "title": string, "description"?: string, "icon"?: string,
|
|
43561
|
+
"tools"?: [{ "name", "description", "inputSchema" }] }
|
|
43562
|
+
index.html - markup only (full HTML document); do NOT reference app.js
|
|
43563
|
+
app.js - app logic; injected automatically into the page
|
|
43564
|
+
|
|
43565
|
+
App state does NOT live in this folder \u2014 it is stored in the pane database
|
|
43566
|
+
(app_instances table) and reached with getState()/setState().
|
|
43567
|
+
|
|
43568
|
+
## Bridge API (window.AgentPane)
|
|
43569
|
+
|
|
43570
|
+
- getApp() - app info (id, title)
|
|
43571
|
+
- getState() / setState(data) - persistent JSON state, survives page reload
|
|
43572
|
+
- createSession({ cwd, runtime_type, model, title }) - agent session owned by this app
|
|
43573
|
+
- submitTurn(sessionId, prompt) - send a prompt to a session
|
|
43574
|
+
- onTurnCompleted(callback) - callback(event, { turnId, response }) when a turn ends
|
|
43575
|
+
- 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)
|
|
43576
|
+
one of the manifest tools; answer with resolveToolCall(callId, result)
|
|
43577
|
+
|
|
43578
|
+
## Agent tool calls (manifest "tools")
|
|
43579
|
+
|
|
43580
|
+
Manifest tools are exposed to the agent as MCP tools named
|
|
43581
|
+
<app-id>__<tool.name>. The pane routes each call to the app's HEADLESS
|
|
43582
|
+
runtime \u2014 a backend sandbox running this same app.js. The open tab is a
|
|
43583
|
+
viewer; it refreshes via AgentPane.onStateChanged(cb).
|
|
43584
|
+
|
|
43585
|
+
Headless contract for apps that declare tools:
|
|
43586
|
+
- register AgentPane.onToolCall(handler) synchronously at startup
|
|
43587
|
+
- tool handlers must not depend on the DOM or the live UI
|
|
43588
|
+
- headless state is the GLOBAL instance (workspace ''), shared with the
|
|
43589
|
+
open tab via onStateChanged
|
|
43590
|
+
- createSession/submitTurn are not available in the headless runtime
|
|
43591
|
+
|
|
43592
|
+
If the app cannot load headless (broken app.js, no handler), the pane
|
|
43593
|
+
falls back to relaying calls into the OPEN app iframe \u2014 the app must be
|
|
43594
|
+
open in AgentPane for a tool call to succeed in that case.
|
|
43595
|
+
|
|
43596
|
+
## Result contract
|
|
43597
|
+
|
|
43598
|
+
To give the app a structured result, put this requirement in the job prompt:
|
|
43599
|
+
"End your answer with a single JSON code block matching this schema: ..."
|
|
43600
|
+
`;
|
|
43601
|
+
function readManifestIn(dir) {
|
|
43602
|
+
try {
|
|
43603
|
+
const raw = fs.readFileSync(path3.join(dir, "manifest.json"), "utf-8");
|
|
43604
|
+
const parsed = JSON.parse(raw);
|
|
43605
|
+
if (!parsed || typeof parsed.title !== "string") return null;
|
|
43606
|
+
return {
|
|
43607
|
+
title: parsed.title,
|
|
43608
|
+
description: typeof parsed.description === "string" ? parsed.description : void 0,
|
|
43609
|
+
icon: typeof parsed.icon === "string" ? parsed.icon : void 0,
|
|
43610
|
+
tools: Array.isArray(parsed.tools) ? parsed.tools.filter((t) => t && typeof t.name === "string" && typeof t.description === "string") : void 0
|
|
43611
|
+
};
|
|
43612
|
+
} catch {
|
|
43613
|
+
return null;
|
|
43614
|
+
}
|
|
43615
|
+
}
|
|
43616
|
+
function readManifest(id) {
|
|
43617
|
+
return readManifestIn(appDir(id));
|
|
43618
|
+
}
|
|
43619
|
+
function readAppFile(id, name) {
|
|
43620
|
+
try {
|
|
43621
|
+
return fs.readFileSync(path3.join(appDir(id), name), "utf-8");
|
|
43622
|
+
} catch {
|
|
43623
|
+
return "";
|
|
43624
|
+
}
|
|
43625
|
+
}
|
|
43626
|
+
function readState(id) {
|
|
43627
|
+
try {
|
|
43628
|
+
const parsed = JSON.parse(readAppFile(id, "state.json"));
|
|
43629
|
+
return {
|
|
43630
|
+
pinned: parsed?.pinned === true,
|
|
43631
|
+
data: parsed && typeof parsed.data === "object" && parsed.data !== null ? parsed.data : null
|
|
43632
|
+
};
|
|
43633
|
+
} catch {
|
|
43634
|
+
return { pinned: false, data: null };
|
|
43635
|
+
}
|
|
43636
|
+
}
|
|
43637
|
+
var watcher = null;
|
|
43638
|
+
var pendingChanges = /* @__PURE__ */ new Map();
|
|
43639
|
+
var HOT_RELOAD_DEBOUNCE_MS = 250;
|
|
43640
|
+
function startAppsWatch(onAppChange) {
|
|
43641
|
+
stopAppsWatch();
|
|
43642
|
+
const root = appsRoot();
|
|
43643
|
+
fs.mkdirSync(root, { recursive: true });
|
|
43644
|
+
try {
|
|
43645
|
+
watcher = fs.watch(root, { recursive: true }, (_event, filename) => {
|
|
43646
|
+
const rel = String(filename ?? "");
|
|
43647
|
+
const segs = rel.split(path3.sep);
|
|
43648
|
+
const appId = segs[0];
|
|
43649
|
+
const file = segs[segs.length - 1];
|
|
43650
|
+
if (!appId || appId === path3.basename(root) || !APP_ID_RE.test(appId) || file === "state.json") return;
|
|
43651
|
+
const timer = pendingChanges.get(appId);
|
|
43652
|
+
if (timer) clearTimeout(timer);
|
|
43653
|
+
pendingChanges.set(
|
|
43654
|
+
appId,
|
|
43655
|
+
setTimeout(() => {
|
|
43656
|
+
pendingChanges.delete(appId);
|
|
43657
|
+
onAppChange(appId);
|
|
43658
|
+
}, HOT_RELOAD_DEBOUNCE_MS)
|
|
43659
|
+
);
|
|
43660
|
+
});
|
|
43661
|
+
} catch {
|
|
43662
|
+
watcher = null;
|
|
43663
|
+
}
|
|
43664
|
+
}
|
|
43665
|
+
function stopAppsWatch() {
|
|
43666
|
+
if (watcher) {
|
|
43667
|
+
watcher.close();
|
|
43668
|
+
watcher = null;
|
|
43669
|
+
}
|
|
43670
|
+
for (const timer of pendingChanges.values()) clearTimeout(timer);
|
|
43671
|
+
pendingChanges.clear();
|
|
43672
|
+
}
|
|
43673
|
+
|
|
43674
|
+
// src/apps/instances.ts
|
|
43675
|
+
function rowToState(row) {
|
|
43676
|
+
let data = null;
|
|
43677
|
+
try {
|
|
43678
|
+
const parsed = JSON.parse(row.state ?? "null");
|
|
43679
|
+
if (parsed && typeof parsed === "object") data = parsed;
|
|
43680
|
+
} catch {
|
|
43681
|
+
}
|
|
43682
|
+
return { pinned: row.pinned === 1, data };
|
|
43683
|
+
}
|
|
43684
|
+
function writeRow(appId, workspace, state) {
|
|
43685
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
43686
|
+
getDb().prepare(
|
|
43687
|
+
`INSERT INTO app_instances (id, app_id, workspace_path, pinned, state, created_at, updated_at)
|
|
43688
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
43689
|
+
ON CONFLICT(app_id, workspace_path) DO UPDATE SET
|
|
43690
|
+
pinned = excluded.pinned, state = excluded.state, updated_at = excluded.updated_at`
|
|
43691
|
+
).run(v4_default(), appId, workspace, state.pinned ? 1 : 0, JSON.stringify(state.data ?? null), now, now);
|
|
43692
|
+
}
|
|
43693
|
+
function getInstanceState(appId, workspace = "") {
|
|
43694
|
+
const db2 = getDb();
|
|
43695
|
+
const row = db2.prepare("SELECT * FROM app_instances WHERE app_id = ? AND workspace_path = ?").get(appId, workspace);
|
|
43696
|
+
if (row) return rowToState(row);
|
|
43697
|
+
if (workspace === "") {
|
|
43698
|
+
const legacyFile = path4.join(appDir(appId), "state.json");
|
|
43699
|
+
if (fs2.existsSync(legacyFile)) {
|
|
43700
|
+
const imported = readState(appId);
|
|
43701
|
+
writeRow(appId, "", imported);
|
|
43702
|
+
fs2.rmSync(legacyFile, { force: true });
|
|
43703
|
+
return imported;
|
|
43704
|
+
}
|
|
43705
|
+
}
|
|
43706
|
+
return { pinned: false, data: null };
|
|
43707
|
+
}
|
|
43708
|
+
function updateInstanceState(appId, workspace, patch) {
|
|
43709
|
+
const current = getInstanceState(appId, workspace);
|
|
43710
|
+
const { pinned, data } = patch;
|
|
43711
|
+
const next = {
|
|
43712
|
+
pinned: typeof pinned === "boolean" ? pinned : current.pinned,
|
|
43713
|
+
data: data === void 0 ? current.data : data !== null && typeof data === "object" ? data : null
|
|
43714
|
+
};
|
|
43715
|
+
writeRow(appId, workspace, next);
|
|
43716
|
+
return next;
|
|
43717
|
+
}
|
|
43718
|
+
function deleteAppInstances(appId) {
|
|
43719
|
+
getDb().prepare("DELETE FROM app_instances WHERE app_id = ?").run(appId);
|
|
43720
|
+
}
|
|
43721
|
+
|
|
43722
|
+
// src/apps/mcp-tools.ts
|
|
43723
|
+
import fs3 from "node:fs";
|
|
43724
|
+
|
|
43725
|
+
// src/apps/headless-runtime.ts
|
|
43726
|
+
import vm from "node:vm";
|
|
43727
|
+
var HEADLESS_TOOL_TIMEOUT_MS = Number(process.env.AGENT_PANE_TOOL_TIMEOUT_MS ?? 3e4);
|
|
43728
|
+
function stub() {
|
|
43729
|
+
const fn = function stub2() {
|
|
43730
|
+
};
|
|
43731
|
+
return new Proxy(fn, {
|
|
43732
|
+
get: (_target, prop) => {
|
|
43733
|
+
if (prop === "then") return void 0;
|
|
43734
|
+
if (prop === Symbol.toPrimitive || prop === "toString" || prop === "valueOf") return () => "";
|
|
43735
|
+
if (prop === "length") return 0;
|
|
43736
|
+
if (prop === "value" || prop === "textContent" || prop === "innerText" || prop === "innerHTML") return "";
|
|
43737
|
+
return stub();
|
|
43738
|
+
},
|
|
43739
|
+
set: () => true,
|
|
43740
|
+
apply: () => stub(),
|
|
43741
|
+
construct: () => ({}),
|
|
43742
|
+
has: () => true
|
|
43743
|
+
});
|
|
43744
|
+
}
|
|
43745
|
+
var runtimes = /* @__PURE__ */ new Map();
|
|
43746
|
+
var pendingCalls = /* @__PURE__ */ new Map();
|
|
43747
|
+
function getHeadlessToolHandler(appId) {
|
|
43748
|
+
const cached = runtimes.get(appId);
|
|
43749
|
+
if (cached) return cached.handler;
|
|
43750
|
+
const js = readAppFile(appId, "app.js");
|
|
43751
|
+
if (!js.trim()) return null;
|
|
43752
|
+
const manifest = readManifest(appId);
|
|
43753
|
+
let handler = null;
|
|
43754
|
+
const bridge = {
|
|
43755
|
+
getApp: () => Promise.resolve({ id: appId, title: manifest?.title ?? appId }),
|
|
43756
|
+
// Headless state = the GLOBAL instance (workspace ''). Tool calls carry
|
|
43757
|
+
// no workspace context; the open tab keeps its own workspace-scoped view.
|
|
43758
|
+
getState: () => Promise.resolve(getInstanceState(appId, "")),
|
|
43759
|
+
setState: (data) => {
|
|
43760
|
+
const next = updateInstanceState(appId, "", { data });
|
|
43761
|
+
broadcast("app:state_changed", { appId });
|
|
43762
|
+
return Promise.resolve(next);
|
|
43763
|
+
},
|
|
43764
|
+
onToolCall: (cb) => {
|
|
43765
|
+
if (typeof cb === "function") handler = cb;
|
|
43766
|
+
},
|
|
43767
|
+
resolveToolCall: (callId, result) => {
|
|
43768
|
+
resolveHeadlessToolCall(String(callId), result);
|
|
43769
|
+
return Promise.resolve({ ok: true });
|
|
43770
|
+
},
|
|
43771
|
+
// UI-flow APIs are intentionally unavailable headless.
|
|
43772
|
+
createSession: () => Promise.reject(new Error("createSession is not available in the headless runtime")),
|
|
43773
|
+
submitTurn: () => Promise.reject(new Error("submitTurn is not available in the headless runtime")),
|
|
43774
|
+
onTurnCompleted: () => {
|
|
43775
|
+
},
|
|
43776
|
+
onTurnDelta: () => {
|
|
43777
|
+
}
|
|
43778
|
+
};
|
|
43779
|
+
const sandbox = {
|
|
43780
|
+
console: {
|
|
43781
|
+
log: (...a) => console.log(`[app:${appId}]`, ...a),
|
|
43782
|
+
warn: (...a) => console.warn(`[app:${appId}]`, ...a),
|
|
43783
|
+
error: (...a) => console.error(`[app:${appId}]`, ...a)
|
|
43784
|
+
},
|
|
43785
|
+
setTimeout,
|
|
43786
|
+
clearTimeout,
|
|
43787
|
+
document: stub(),
|
|
43788
|
+
navigator: stub(),
|
|
43789
|
+
AgentPane: bridge
|
|
43790
|
+
};
|
|
43791
|
+
const windowObj = {
|
|
43792
|
+
addEventListener: () => {
|
|
43793
|
+
},
|
|
43794
|
+
removeEventListener: () => {
|
|
43795
|
+
},
|
|
43796
|
+
document: sandbox.document,
|
|
43797
|
+
navigator: sandbox.navigator,
|
|
43798
|
+
setTimeout,
|
|
43799
|
+
clearTimeout,
|
|
43800
|
+
AgentPane: bridge
|
|
43801
|
+
};
|
|
43802
|
+
sandbox.window = windowObj;
|
|
43803
|
+
sandbox.self = windowObj;
|
|
43804
|
+
try {
|
|
43805
|
+
const context = vm.createContext(sandbox);
|
|
43806
|
+
vm.runInContext(js, context, { filename: `${appId}/app.js` });
|
|
43807
|
+
} catch (err) {
|
|
43808
|
+
console.warn(`[headless:${appId}] app.js load failed: ${err.message}`);
|
|
43809
|
+
return null;
|
|
43810
|
+
}
|
|
43811
|
+
if (!handler) return null;
|
|
43812
|
+
runtimes.set(appId, { handler });
|
|
43813
|
+
return handler;
|
|
43814
|
+
}
|
|
43815
|
+
function dispatchHeadlessToolCall(handler, tool, args) {
|
|
43816
|
+
const callId = v4_default();
|
|
43817
|
+
const result = new Promise((resolve, reject) => {
|
|
43818
|
+
const timer = setTimeout(() => {
|
|
43819
|
+
pendingCalls.delete(callId);
|
|
43820
|
+
reject(
|
|
43821
|
+
new Error(
|
|
43822
|
+
`Mini app did not answer tool '${tool}' within ${HEADLESS_TOOL_TIMEOUT_MS / 1e3}s (headless runtime) \u2014 check the app tool handler.`
|
|
43823
|
+
)
|
|
43824
|
+
);
|
|
43825
|
+
}, HEADLESS_TOOL_TIMEOUT_MS);
|
|
43826
|
+
pendingCalls.set(callId, { resolve, reject, timer });
|
|
43827
|
+
});
|
|
43828
|
+
try {
|
|
43829
|
+
handler("tool_call", { callId, tool, name: tool, args: args ?? {} });
|
|
43830
|
+
} catch (err) {
|
|
43831
|
+
const pending = pendingCalls.get(callId);
|
|
43832
|
+
if (pending) {
|
|
43833
|
+
pendingCalls.delete(callId);
|
|
43834
|
+
clearTimeout(pending.timer);
|
|
43835
|
+
pending.reject(new Error(`Headless tool handler crashed: ${err.message}`));
|
|
43836
|
+
}
|
|
43837
|
+
}
|
|
43838
|
+
return { callId, result };
|
|
43839
|
+
}
|
|
43840
|
+
function resolveHeadlessToolCall(callId, result) {
|
|
43841
|
+
const pending = pendingCalls.get(callId);
|
|
43842
|
+
if (!pending) return false;
|
|
43843
|
+
pendingCalls.delete(callId);
|
|
43844
|
+
clearTimeout(pending.timer);
|
|
43845
|
+
pending.resolve(result ?? null);
|
|
43846
|
+
return true;
|
|
43847
|
+
}
|
|
43848
|
+
function invalidateHeadlessRuntime(appId) {
|
|
43849
|
+
if (appId) runtimes.delete(appId);
|
|
43850
|
+
else runtimes.clear();
|
|
43851
|
+
}
|
|
43852
|
+
|
|
43853
|
+
// src/apps/mcp-tools.ts
|
|
43854
|
+
var TOOL_CALL_TIMEOUT_MS = Number(process.env.AGENT_PANE_TOOL_TIMEOUT_MS ?? 3e4);
|
|
43855
|
+
var TOOL_NS = "__";
|
|
43856
|
+
function listAppTools() {
|
|
43857
|
+
const tools = [];
|
|
43858
|
+
try {
|
|
43859
|
+
for (const entry of fs3.readdirSync(appsRoot(), { withFileTypes: true })) {
|
|
43860
|
+
if (!entry.isDirectory()) continue;
|
|
43861
|
+
const manifest = readManifest(entry.name);
|
|
43862
|
+
for (const tool of manifest?.tools ?? []) {
|
|
43863
|
+
if (!tool?.name || !tool?.description) continue;
|
|
43864
|
+
tools.push({
|
|
43865
|
+
name: `${entry.name}${TOOL_NS}${tool.name}`,
|
|
43866
|
+
description: `[${entry.name}] ${tool.description}`,
|
|
43867
|
+
inputSchema: tool.inputSchema
|
|
43868
|
+
});
|
|
43869
|
+
}
|
|
43870
|
+
}
|
|
43871
|
+
} catch {
|
|
43872
|
+
}
|
|
43873
|
+
return tools;
|
|
43874
|
+
}
|
|
43875
|
+
function splitToolName(name) {
|
|
43876
|
+
const idx = name.indexOf(TOOL_NS);
|
|
43877
|
+
if (idx <= 0 || idx === name.length - TOOL_NS.length) return null;
|
|
43878
|
+
return { appId: name.slice(0, idx), localName: name.slice(idx + TOOL_NS.length) };
|
|
43879
|
+
}
|
|
43880
|
+
var pendingCalls2 = /* @__PURE__ */ new Map();
|
|
43881
|
+
function dispatchAppTool(toolName, args) {
|
|
43882
|
+
const split = splitToolName(toolName);
|
|
43883
|
+
if (!split) {
|
|
43884
|
+
throw new Error(`Invalid tool name: ${toolName}`);
|
|
43885
|
+
}
|
|
43886
|
+
const { appId, localName } = split;
|
|
43887
|
+
const manifest = readManifest(appId);
|
|
43888
|
+
const tool = manifest?.tools?.find((t) => t.name === localName);
|
|
43889
|
+
if (!manifest || !tool) {
|
|
43890
|
+
throw new Error(`Unknown mini-app tool: ${toolName}`);
|
|
43891
|
+
}
|
|
43892
|
+
const headlessHandler = getHeadlessToolHandler(appId);
|
|
43893
|
+
if (headlessHandler) {
|
|
43894
|
+
return dispatchHeadlessToolCall(headlessHandler, localName, args);
|
|
43895
|
+
}
|
|
43896
|
+
const callId = v4_default();
|
|
43897
|
+
const result = new Promise((resolve, reject) => {
|
|
43898
|
+
const timer = setTimeout(() => {
|
|
43899
|
+
pendingCalls2.delete(callId);
|
|
43900
|
+
reject(
|
|
43901
|
+
new Error(
|
|
43902
|
+
`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.`
|
|
43903
|
+
)
|
|
43904
|
+
);
|
|
43905
|
+
}, TOOL_CALL_TIMEOUT_MS);
|
|
43906
|
+
pendingCalls2.set(callId, { resolve, reject, timer, appId });
|
|
43907
|
+
broadcast("app:tool_call", { appId, callId, tool: localName, args: args ?? {} });
|
|
43908
|
+
});
|
|
43909
|
+
return { callId, result };
|
|
43910
|
+
}
|
|
43911
|
+
async function callAppTool(toolName, args) {
|
|
43912
|
+
return dispatchAppTool(toolName, args).result;
|
|
43913
|
+
}
|
|
43914
|
+
function resolveAppToolCall(callId, result, error) {
|
|
43915
|
+
const pending = pendingCalls2.get(callId);
|
|
43916
|
+
if (!pending) return false;
|
|
43917
|
+
pendingCalls2.delete(callId);
|
|
43918
|
+
clearTimeout(pending.timer);
|
|
43919
|
+
if (error) pending.reject(new Error(error));
|
|
43920
|
+
else pending.resolve(result ?? null);
|
|
43921
|
+
return true;
|
|
43922
|
+
}
|
|
43923
|
+
function anyAppHasTools() {
|
|
43924
|
+
return listAppTools().length > 0;
|
|
43925
|
+
}
|
|
43926
|
+
|
|
43927
|
+
// src/routes/apps.ts
|
|
43928
|
+
var IMPORT_FILE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
43929
|
+
var IMPORT_MAX_FILES = 50;
|
|
43930
|
+
var IMPORT_MAX_FILE_BYTES = 512 * 1024;
|
|
43931
|
+
var SKELETON_HTML = `<!DOCTYPE html>
|
|
43932
|
+
<html>
|
|
43933
|
+
<head>
|
|
43934
|
+
<meta charset="utf-8">
|
|
43935
|
+
<title>__TITLE__</title>
|
|
43936
|
+
</head>
|
|
43937
|
+
<body>
|
|
43938
|
+
<h1>__TITLE__</h1>
|
|
43939
|
+
<p id="out">Skeleton app \u2014 develop it with Edit App.</p>
|
|
43940
|
+
</body>
|
|
43941
|
+
</html>
|
|
43942
|
+
`;
|
|
43943
|
+
var SKELETON_JS = `// Skeleton mini app. window.AgentPane is the pane bridge:
|
|
43944
|
+
// getState() / setState(data) persistent state (survives reloads)
|
|
43945
|
+
// createSession / submitTurn talk to an agent session
|
|
43946
|
+
// onTurnCompleted / onToolCall react to agent events
|
|
43947
|
+
var ui = { ready: false };
|
|
43948
|
+
|
|
43949
|
+
function render() {
|
|
43950
|
+
document.getElementById('out').textContent =
|
|
43951
|
+
ui.ready ? 'State: ' + JSON.stringify(ui.data) : 'Loading\u2026';
|
|
43952
|
+
}
|
|
43953
|
+
|
|
43954
|
+
(async function init() {
|
|
43955
|
+
var state = await AgentPane.getState();
|
|
43956
|
+
ui.data = (state && state.data) || {};
|
|
43957
|
+
ui.ready = true;
|
|
43958
|
+
render();
|
|
43959
|
+
})();
|
|
43960
|
+
`;
|
|
43961
|
+
async function registerAppRoutes(fastify, opts) {
|
|
43962
|
+
setAppsRootOverride(opts?.appsRoot ?? null);
|
|
43963
|
+
setExamplesRootOverride(opts?.examplesRoot ?? null);
|
|
43964
|
+
startAppsWatch((appId) => {
|
|
43965
|
+
invalidateHeadlessRuntime(appId);
|
|
43966
|
+
broadcast("app:source:updated", { appId });
|
|
43967
|
+
});
|
|
43968
|
+
fastify.addHook("onClose", async () => stopAppsWatch());
|
|
43969
|
+
fastify.get("/api/apps", async () => {
|
|
43970
|
+
try {
|
|
43971
|
+
ensureAppsRoot();
|
|
43972
|
+
const entries = fs4.readdirSync(appsRoot(), { withFileTypes: true });
|
|
43973
|
+
const apps = [];
|
|
43974
|
+
for (const entry of entries) {
|
|
43975
|
+
if (!entry.isDirectory() || !APP_ID_RE.test(entry.name)) continue;
|
|
43976
|
+
const manifest = readManifest(entry.name);
|
|
43977
|
+
if (!manifest) continue;
|
|
43978
|
+
apps.push({
|
|
43979
|
+
id: entry.name,
|
|
43980
|
+
title: manifest.title,
|
|
43981
|
+
description: manifest.description ?? null,
|
|
43982
|
+
icon: manifest.icon ?? null,
|
|
43983
|
+
pinned: getInstanceState(entry.name).pinned
|
|
43984
|
+
});
|
|
43985
|
+
}
|
|
43986
|
+
apps.sort((a, b) => Number(b.pinned) - Number(a.pinned) || a.title.localeCompare(b.title));
|
|
43987
|
+
return apps;
|
|
43988
|
+
} catch {
|
|
43989
|
+
return [];
|
|
43990
|
+
}
|
|
43991
|
+
});
|
|
43992
|
+
fastify.get("/api/apps/mcp/tools", async () => listAppTools());
|
|
43993
|
+
fastify.get("/api/apps/examples", async () => {
|
|
43994
|
+
const exRoot = examplesRoot();
|
|
43995
|
+
if (!exRoot) return [];
|
|
43996
|
+
const out = [];
|
|
43997
|
+
try {
|
|
43998
|
+
for (const entry of fs4.readdirSync(exRoot, { withFileTypes: true })) {
|
|
43999
|
+
if (!entry.isDirectory() || !APP_ID_RE.test(entry.name)) continue;
|
|
44000
|
+
const manifest = readManifestIn(path5.join(exRoot, entry.name));
|
|
44001
|
+
if (!manifest) continue;
|
|
44002
|
+
out.push({
|
|
44003
|
+
id: entry.name,
|
|
44004
|
+
title: manifest.title,
|
|
44005
|
+
description: manifest.description ?? null,
|
|
44006
|
+
icon: manifest.icon ?? null,
|
|
44007
|
+
pinned: false
|
|
44008
|
+
});
|
|
44009
|
+
}
|
|
44010
|
+
} catch {
|
|
44011
|
+
return [];
|
|
44012
|
+
}
|
|
44013
|
+
out.sort((a, b) => a.title.localeCompare(b.title));
|
|
44014
|
+
return out;
|
|
44015
|
+
});
|
|
44016
|
+
fastify.post("/api/apps/examples/:id/install", async (request, reply) => {
|
|
44017
|
+
const { id } = request.params;
|
|
44018
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44019
|
+
const exRoot = examplesRoot();
|
|
44020
|
+
if (!exRoot) return reply.code(404).send({ error: "Examples catalog not available" });
|
|
44021
|
+
const src = path5.join(exRoot, id);
|
|
44022
|
+
if (!readManifestIn(src)) return reply.code(404).send({ error: "Example not found" });
|
|
44023
|
+
if (readManifest(id)) return reply.code(409).send({ error: "App already installed" });
|
|
44024
|
+
ensureAppsRoot();
|
|
44025
|
+
fs4.cpSync(src, appDir(id), { recursive: true });
|
|
44026
|
+
return { ok: true, id };
|
|
44027
|
+
});
|
|
44028
|
+
fastify.post(
|
|
44029
|
+
"/api/apps",
|
|
44030
|
+
{
|
|
44031
|
+
schema: {
|
|
44032
|
+
body: {
|
|
44033
|
+
type: "object",
|
|
44034
|
+
required: ["id", "title"],
|
|
44035
|
+
properties: {
|
|
44036
|
+
id: { type: "string" },
|
|
44037
|
+
title: { type: "string" },
|
|
44038
|
+
description: { type: "string" },
|
|
44039
|
+
icon: { type: "string" }
|
|
44040
|
+
}
|
|
44041
|
+
}
|
|
44042
|
+
}
|
|
44043
|
+
},
|
|
44044
|
+
async (request, reply) => {
|
|
44045
|
+
const { id, title, description, icon } = request.body || {};
|
|
44046
|
+
if (!id || !APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44047
|
+
if (!title || !title.trim()) return reply.code(400).send({ error: "Title is required" });
|
|
44048
|
+
if (readManifest(id)) return reply.code(409).send({ error: "App already exists" });
|
|
44049
|
+
ensureAppsRoot();
|
|
44050
|
+
const dir = appDir(id);
|
|
44051
|
+
fs4.mkdirSync(dir, { recursive: true });
|
|
44052
|
+
const cleanTitle2 = title.trim();
|
|
44053
|
+
fs4.writeFileSync(
|
|
44054
|
+
path5.join(dir, "manifest.json"),
|
|
44055
|
+
JSON.stringify(
|
|
44056
|
+
{
|
|
44057
|
+
title: cleanTitle2,
|
|
44058
|
+
description: description?.trim() || void 0,
|
|
44059
|
+
icon: icon?.trim() || void 0
|
|
44060
|
+
},
|
|
44061
|
+
null,
|
|
44062
|
+
2
|
|
44063
|
+
)
|
|
44064
|
+
);
|
|
44065
|
+
fs4.writeFileSync(path5.join(dir, "index.html"), SKELETON_HTML.replaceAll("__TITLE__", cleanTitle2));
|
|
44066
|
+
fs4.writeFileSync(path5.join(dir, "app.js"), SKELETON_JS);
|
|
44067
|
+
return { ok: true, id };
|
|
44068
|
+
}
|
|
44069
|
+
);
|
|
44070
|
+
fastify.post(
|
|
44071
|
+
"/api/apps/import",
|
|
44072
|
+
{
|
|
44073
|
+
schema: {
|
|
44074
|
+
body: {
|
|
44075
|
+
type: "object",
|
|
44076
|
+
required: ["id", "files"],
|
|
44077
|
+
properties: {
|
|
44078
|
+
id: { type: "string" },
|
|
44079
|
+
files: { type: "object", additionalProperties: { type: "string" } }
|
|
44080
|
+
}
|
|
44081
|
+
}
|
|
44082
|
+
}
|
|
44083
|
+
},
|
|
44084
|
+
async (request, reply) => {
|
|
44085
|
+
const { id, files } = request.body || {};
|
|
44086
|
+
if (!id || !APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44087
|
+
const entries = Object.entries(files ?? {});
|
|
44088
|
+
if (entries.length === 0) return reply.code(400).send({ error: "No files uploaded" });
|
|
44089
|
+
if (entries.length > IMPORT_MAX_FILES) {
|
|
44090
|
+
return reply.code(400).send({ error: `Too many files (max ${IMPORT_MAX_FILES})` });
|
|
44091
|
+
}
|
|
44092
|
+
for (const [name, content] of entries) {
|
|
44093
|
+
if (!IMPORT_FILE_RE.test(name)) return reply.code(400).send({ error: `Invalid file name: ${name}` });
|
|
44094
|
+
if (typeof content !== "string" || content.length > IMPORT_MAX_FILE_BYTES) {
|
|
44095
|
+
return reply.code(400).send({ error: `File too large: ${name}` });
|
|
44096
|
+
}
|
|
44097
|
+
}
|
|
44098
|
+
if (readManifest(id)) return reply.code(409).send({ error: "App already exists" });
|
|
44099
|
+
ensureAppsRoot();
|
|
44100
|
+
const dir = appDir(id);
|
|
44101
|
+
fs4.mkdirSync(dir, { recursive: true });
|
|
44102
|
+
if (!Object.hasOwn(files ?? {}, "manifest.json")) {
|
|
44103
|
+
fs4.writeFileSync(path5.join(dir, "manifest.json"), JSON.stringify({ title: id }, null, 2));
|
|
44104
|
+
}
|
|
44105
|
+
for (const [name, content] of entries) fs4.writeFileSync(path5.join(dir, name), content);
|
|
44106
|
+
return { ok: true, id };
|
|
44107
|
+
}
|
|
44108
|
+
);
|
|
44109
|
+
fastify.post(
|
|
44110
|
+
"/api/apps/mcp/call",
|
|
44111
|
+
{
|
|
44112
|
+
schema: {
|
|
44113
|
+
body: {
|
|
44114
|
+
type: "object",
|
|
44115
|
+
required: ["tool"],
|
|
44116
|
+
properties: {
|
|
44117
|
+
tool: { type: "string" },
|
|
44118
|
+
args: { type: ["object", "null"] }
|
|
44119
|
+
}
|
|
44120
|
+
}
|
|
44121
|
+
}
|
|
44122
|
+
},
|
|
44123
|
+
async (request, reply) => {
|
|
44124
|
+
const { tool, args } = request.body || {};
|
|
44125
|
+
try {
|
|
44126
|
+
const result = await callAppTool(tool, args ?? {});
|
|
44127
|
+
return { ok: true, result };
|
|
44128
|
+
} catch (err) {
|
|
44129
|
+
return reply.code(200).send({ ok: false, error: err.message });
|
|
44130
|
+
}
|
|
44131
|
+
}
|
|
44132
|
+
);
|
|
44133
|
+
fastify.post(
|
|
44134
|
+
"/api/apps/mcp/calls/:callId/result",
|
|
44135
|
+
{
|
|
44136
|
+
schema: {
|
|
44137
|
+
body: {
|
|
44138
|
+
type: "object",
|
|
44139
|
+
properties: {
|
|
44140
|
+
result: {},
|
|
44141
|
+
error: { type: ["string", "null"] }
|
|
44142
|
+
}
|
|
44143
|
+
}
|
|
44144
|
+
}
|
|
44145
|
+
},
|
|
44146
|
+
async (request, reply) => {
|
|
44147
|
+
const { callId } = request.params;
|
|
44148
|
+
const { result, error } = request.body || {};
|
|
44149
|
+
const answered = resolveAppToolCall(callId, result, error ?? void 0);
|
|
44150
|
+
if (!answered) {
|
|
44151
|
+
return reply.code(404).send({ error: "Unknown or already-answered tool call" });
|
|
44152
|
+
}
|
|
44153
|
+
return { ok: true };
|
|
44154
|
+
}
|
|
44155
|
+
);
|
|
44156
|
+
fastify.get("/api/apps/:id/source", async (request, reply) => {
|
|
44157
|
+
const { id } = request.params;
|
|
44158
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44159
|
+
const manifest = readManifest(id);
|
|
44160
|
+
if (!manifest) return reply.code(404).send({ error: "App not found" });
|
|
44161
|
+
return {
|
|
44162
|
+
manifest,
|
|
44163
|
+
html: readAppFile(id, "index.html"),
|
|
44164
|
+
js: readAppFile(id, "app.js")
|
|
44165
|
+
};
|
|
44166
|
+
});
|
|
44167
|
+
fastify.get(
|
|
44168
|
+
"/api/apps/:id/state",
|
|
44169
|
+
{ schema: { querystring: { type: "object", properties: { workspace: { type: "string" } } } } },
|
|
44170
|
+
async (request, reply) => {
|
|
44171
|
+
const { id } = request.params;
|
|
44172
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44173
|
+
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
44174
|
+
return getInstanceState(id, request.query?.workspace ?? "");
|
|
44175
|
+
}
|
|
44176
|
+
);
|
|
44177
|
+
fastify.put(
|
|
44178
|
+
"/api/apps/:id/state",
|
|
44179
|
+
{
|
|
44180
|
+
schema: {
|
|
44181
|
+
querystring: { type: "object", properties: { workspace: { type: "string" } } },
|
|
44182
|
+
body: {
|
|
44183
|
+
type: "object",
|
|
44184
|
+
properties: {
|
|
44185
|
+
pinned: { type: "boolean" },
|
|
44186
|
+
data: { type: ["object", "null"] }
|
|
44187
|
+
}
|
|
44188
|
+
}
|
|
44189
|
+
}
|
|
44190
|
+
},
|
|
44191
|
+
async (request, reply) => {
|
|
44192
|
+
const { id } = request.params;
|
|
44193
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44194
|
+
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
44195
|
+
return updateInstanceState(id, request.query?.workspace ?? "", request.body || {});
|
|
44196
|
+
}
|
|
44197
|
+
);
|
|
44198
|
+
fastify.delete("/api/apps/:id", async (request, reply) => {
|
|
44199
|
+
const { id } = request.params;
|
|
44200
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44201
|
+
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
44202
|
+
fs4.rmSync(appDir(id), { recursive: true, force: true });
|
|
44203
|
+
deleteAppInstances(id);
|
|
44204
|
+
invalidateHeadlessRuntime(id);
|
|
44205
|
+
return { ok: true };
|
|
44206
|
+
});
|
|
44207
|
+
fastify.get("/api/apps/:id/sessions", async (request, reply) => {
|
|
44208
|
+
const { id } = request.params;
|
|
44209
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44210
|
+
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
44211
|
+
const rows = getDb().prepare("SELECT * FROM sessions WHERE origin_app_id = ? ORDER BY created_at DESC").all(id);
|
|
44212
|
+
return rows;
|
|
44213
|
+
});
|
|
44214
|
+
fastify.post(
|
|
44215
|
+
"/api/apps/:id/edit-session",
|
|
44216
|
+
{
|
|
44217
|
+
schema: {
|
|
44218
|
+
body: {
|
|
44219
|
+
type: "object",
|
|
44220
|
+
properties: {
|
|
44221
|
+
runtime_type: { type: "string" },
|
|
44222
|
+
model: { type: ["string", "null"] },
|
|
44223
|
+
model_reasoning_effort: { type: ["string", "null"] }
|
|
44224
|
+
}
|
|
44225
|
+
}
|
|
44226
|
+
}
|
|
44227
|
+
},
|
|
44228
|
+
async (request, reply) => {
|
|
44229
|
+
const { id } = request.params;
|
|
44230
|
+
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
44231
|
+
const manifest = readManifest(id);
|
|
44232
|
+
if (!manifest) return reply.code(404).send({ error: "App not found" });
|
|
44233
|
+
const dir = appDir(id);
|
|
44234
|
+
const db2 = getDb();
|
|
44235
|
+
const existing = db2.prepare("SELECT * FROM sessions WHERE origin_app_id = ? AND cwd = ? ORDER BY created_at DESC LIMIT 1").get(id, dir);
|
|
44236
|
+
if (existing) return existing;
|
|
44237
|
+
const { runtime_type = "claude", model = null, model_reasoning_effort = null } = request.body || {};
|
|
44238
|
+
const sessionId = v4_default();
|
|
44239
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
44240
|
+
const maxOrder = db2.prepare("SELECT COALESCE(MAX(sort_order), 0) AS m FROM sessions WHERE cwd = ?").get(dir);
|
|
44241
|
+
db2.prepare(
|
|
44242
|
+
`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)
|
|
44243
|
+
VALUES (?, ?, ?, ?, ?, ?, NULL, 'active', 0, ?, ?, ?, ?)`
|
|
44244
|
+
).run(
|
|
44245
|
+
sessionId,
|
|
44246
|
+
`Edit: ${manifest.title}`,
|
|
44247
|
+
runtime_type,
|
|
44248
|
+
model,
|
|
44249
|
+
model_reasoning_effort,
|
|
44250
|
+
dir,
|
|
44251
|
+
maxOrder.m + 1,
|
|
44252
|
+
now,
|
|
44253
|
+
now,
|
|
44254
|
+
id
|
|
44255
|
+
);
|
|
44256
|
+
return db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
|
|
44257
|
+
}
|
|
44258
|
+
);
|
|
44259
|
+
}
|
|
44260
|
+
|
|
43464
44261
|
// src/codex/item-mapper.ts
|
|
43465
44262
|
function mapItemData(item) {
|
|
43466
44263
|
switch (item.type) {
|
|
@@ -43529,6 +44326,99 @@ function mapTokenUsage(data) {
|
|
|
43529
44326
|
};
|
|
43530
44327
|
}
|
|
43531
44328
|
|
|
44329
|
+
// src/apps/register-mcp.ts
|
|
44330
|
+
import fs5 from "node:fs";
|
|
44331
|
+
import path6 from "node:path";
|
|
44332
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
44333
|
+
var MCP_SERVER_NAME = "agentpane-miniapps";
|
|
44334
|
+
function panePublicUrl() {
|
|
44335
|
+
return (process.env.AGENT_PANE_PUBLIC_URL || process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
|
|
44336
|
+
}
|
|
44337
|
+
function stdioScriptPath() {
|
|
44338
|
+
const here = path6.dirname(fileURLToPath2(import.meta.url));
|
|
44339
|
+
const candidates = [
|
|
44340
|
+
path6.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
|
|
44341
|
+
// src/apps/ → backend/scripts
|
|
44342
|
+
path6.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
|
|
44343
|
+
// dist bundle → backend/scripts
|
|
44344
|
+
];
|
|
44345
|
+
for (const candidate of candidates) {
|
|
44346
|
+
if (fs5.existsSync(candidate)) return candidate;
|
|
44347
|
+
}
|
|
44348
|
+
return null;
|
|
44349
|
+
}
|
|
44350
|
+
var registered = /* @__PURE__ */ new Set();
|
|
44351
|
+
async function registerMiniAppMcp(baseUrl) {
|
|
44352
|
+
if (registered.has(baseUrl)) return true;
|
|
44353
|
+
const script = stdioScriptPath();
|
|
44354
|
+
if (!script) {
|
|
44355
|
+
console.warn("[miniapp-mcp] stdio proxy script not found \u2014 registration skipped");
|
|
44356
|
+
return false;
|
|
44357
|
+
}
|
|
44358
|
+
if (!anyAppHasTools()) {
|
|
44359
|
+
return false;
|
|
44360
|
+
}
|
|
44361
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
44362
|
+
try {
|
|
44363
|
+
try {
|
|
44364
|
+
const res2 = await fetch(`${base}/mcp/servers`, { signal: AbortSignal.timeout(5e3) });
|
|
44365
|
+
if (res2.ok) {
|
|
44366
|
+
const servers = await res2.json();
|
|
44367
|
+
const names = servers.map((s) => s.server_name ?? s.name);
|
|
44368
|
+
if (names.includes(MCP_SERVER_NAME)) {
|
|
44369
|
+
registered.add(baseUrl);
|
|
44370
|
+
return true;
|
|
44371
|
+
}
|
|
44372
|
+
}
|
|
44373
|
+
} catch {
|
|
44374
|
+
}
|
|
44375
|
+
const body = {
|
|
44376
|
+
configJson: JSON.stringify({
|
|
44377
|
+
[MCP_SERVER_NAME]: {
|
|
44378
|
+
command: process.execPath,
|
|
44379
|
+
args: [script, panePublicUrl()],
|
|
44380
|
+
env: {}
|
|
44381
|
+
}
|
|
44382
|
+
})
|
|
44383
|
+
};
|
|
44384
|
+
const res = await fetch(`${base}/mcp/configs`, {
|
|
44385
|
+
method: "POST",
|
|
44386
|
+
headers: { "Content-Type": "application/json" },
|
|
44387
|
+
body: JSON.stringify(body),
|
|
44388
|
+
signal: AbortSignal.timeout(1e4)
|
|
44389
|
+
});
|
|
44390
|
+
if (res.status === 201) {
|
|
44391
|
+
console.log(`[miniapp-mcp] gateway registered in workspace backend ${base}`);
|
|
44392
|
+
registered.add(baseUrl);
|
|
44393
|
+
return true;
|
|
44394
|
+
}
|
|
44395
|
+
const text = await res.text();
|
|
44396
|
+
if (res.status === 400 && /already exists/i.test(text)) {
|
|
44397
|
+
registered.add(baseUrl);
|
|
44398
|
+
return true;
|
|
44399
|
+
}
|
|
44400
|
+
console.warn(`[miniapp-mcp] registration failed (${res.status}): ${text.slice(0, 200)}`);
|
|
44401
|
+
return false;
|
|
44402
|
+
} catch (err) {
|
|
44403
|
+
console.warn(`[miniapp-mcp] registration error: ${err.message}`);
|
|
44404
|
+
return false;
|
|
44405
|
+
}
|
|
44406
|
+
}
|
|
44407
|
+
function codexMiniAppLaunchArgs() {
|
|
44408
|
+
const script = stdioScriptPath();
|
|
44409
|
+
if (!script || !anyAppHasTools()) return null;
|
|
44410
|
+
return [
|
|
44411
|
+
// MCP tool calls must not ask for elicitation approval — nobody is
|
|
44412
|
+
// watching an agent-driven session to approve (feature is stable/on).
|
|
44413
|
+
"-c",
|
|
44414
|
+
"features.tool_call_mcp_elicitation=false",
|
|
44415
|
+
"-c",
|
|
44416
|
+
`mcp_servers.${MCP_SERVER_NAME}.command=${JSON.stringify(process.execPath)}`,
|
|
44417
|
+
"-c",
|
|
44418
|
+
`mcp_servers.${MCP_SERVER_NAME}.args=${JSON.stringify([script, panePublicUrl()])}`
|
|
44419
|
+
];
|
|
44420
|
+
}
|
|
44421
|
+
|
|
43532
44422
|
// src/codex/codex-provider.ts
|
|
43533
44423
|
var sessionMap = /* @__PURE__ */ new Map();
|
|
43534
44424
|
function setSessionStatus(db2, sessionId, isRunning, status, now, hasUnreviewed = false) {
|
|
@@ -43589,12 +44479,32 @@ function isEmptyReasoning(item) {
|
|
|
43589
44479
|
const text = item.text ?? "";
|
|
43590
44480
|
return summary.length === 0 && content.length === 0 && text.length === 0;
|
|
43591
44481
|
}
|
|
44482
|
+
function appServerClientOptions(_session, cwd) {
|
|
44483
|
+
const launchArgs = codexMiniAppLaunchArgs();
|
|
44484
|
+
return launchArgs ? { cwd, launchArgs } : { cwd, launchArgs: [] };
|
|
44485
|
+
}
|
|
44486
|
+
function autoApproveToolUserInput(client) {
|
|
44487
|
+
client.onRequest("item/tool/requestUserInput", async (params) => {
|
|
44488
|
+
const questions = params.questions ?? [];
|
|
44489
|
+
const answers = {};
|
|
44490
|
+
for (const question of questions) {
|
|
44491
|
+
if (!question.options?.some((option) => option.label === "Allow")) {
|
|
44492
|
+
throw new Error(`Unhandled app-server question (no Allow option): ${question.id}`);
|
|
44493
|
+
}
|
|
44494
|
+
answers[question.id] = { answers: ["Allow"] };
|
|
44495
|
+
}
|
|
44496
|
+
return { answers };
|
|
44497
|
+
});
|
|
44498
|
+
}
|
|
43592
44499
|
async function getOrCreateThread(session) {
|
|
43593
44500
|
const existing = sessionMap.get(session.id);
|
|
43594
44501
|
if (existing) return existing;
|
|
43595
44502
|
const cwd = session.cwd ?? process.cwd();
|
|
43596
|
-
const client = new AppServerClient(
|
|
44503
|
+
const client = new AppServerClient(appServerClientOptions(session, cwd));
|
|
43597
44504
|
await client.initialize();
|
|
44505
|
+
if (session.origin_app_id) {
|
|
44506
|
+
autoApproveToolUserInput(client);
|
|
44507
|
+
}
|
|
43598
44508
|
const config = parseRuntimeConfig(session);
|
|
43599
44509
|
const sandbox = sandboxType(config);
|
|
43600
44510
|
let threadId;
|
|
@@ -43680,6 +44590,18 @@ async function startTurn(session, turn) {
|
|
|
43680
44590
|
turnDone = true;
|
|
43681
44591
|
const db3 = getDb();
|
|
43682
44592
|
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
44593
|
+
if (p.turn?.status === "failed") {
|
|
44594
|
+
const errMsg = p.turn.error?.message ?? "Codex turn failed";
|
|
44595
|
+
db3.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
|
|
44596
|
+
"failed",
|
|
44597
|
+
errMsg,
|
|
44598
|
+
now2,
|
|
44599
|
+
turn.id
|
|
44600
|
+
);
|
|
44601
|
+
recomputeSessionRunning(db3, session.id, "failed");
|
|
44602
|
+
broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: errMsg });
|
|
44603
|
+
return;
|
|
44604
|
+
}
|
|
43683
44605
|
if (p.usage !== void 0) {
|
|
43684
44606
|
db3.prepare("UPDATE turns SET status = ?, token_usage = ?, updated_at = ? WHERE id = ?").run(
|
|
43685
44607
|
"completed",
|
|
@@ -44138,9 +45060,9 @@ function mapToolUse(block) {
|
|
|
44138
45060
|
};
|
|
44139
45061
|
}
|
|
44140
45062
|
function deriveFileChangeData(input, toolName) {
|
|
44141
|
-
const
|
|
45063
|
+
const path8 = input.file_path ?? input.notebook_path ?? "";
|
|
44142
45064
|
const kind = toolName === "Write" ? "add" : "modify";
|
|
44143
|
-
return { changes: [{ path:
|
|
45065
|
+
return { changes: [{ path: path8, kind }], status: "in_progress" };
|
|
44144
45066
|
}
|
|
44145
45067
|
function extractToolResultText(content) {
|
|
44146
45068
|
if (!content) return "";
|
|
@@ -45171,8 +46093,8 @@ var RepoburgHttpClient = class {
|
|
|
45171
46093
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
45172
46094
|
}
|
|
45173
46095
|
/** Perform a JSON request. Throws a concise error on non-OK/non-JSON responses. */
|
|
45174
|
-
async request(method,
|
|
45175
|
-
const response = await fetch(`${this.baseUrl}${
|
|
46096
|
+
async request(method, path8, body) {
|
|
46097
|
+
const response = await fetch(`${this.baseUrl}${path8}`, {
|
|
45176
46098
|
method,
|
|
45177
46099
|
headers: { "Content-Type": "application/json" },
|
|
45178
46100
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
@@ -45181,17 +46103,17 @@ var RepoburgHttpClient = class {
|
|
|
45181
46103
|
if (!response.ok) {
|
|
45182
46104
|
if (isHtml(text)) {
|
|
45183
46105
|
throw new Error(
|
|
45184
|
-
`${method} ${
|
|
46106
|
+
`${method} ${path8} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
45185
46107
|
);
|
|
45186
46108
|
}
|
|
45187
|
-
throw new Error(`${method} ${
|
|
46109
|
+
throw new Error(`${method} ${path8} failed: ${response.status} ${text}`);
|
|
45188
46110
|
}
|
|
45189
46111
|
if (text.length === 0) return void 0;
|
|
45190
46112
|
try {
|
|
45191
46113
|
return JSON.parse(text);
|
|
45192
46114
|
} catch {
|
|
45193
46115
|
throw new Error(
|
|
45194
|
-
`${method} ${
|
|
46116
|
+
`${method} ${path8} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
45195
46117
|
);
|
|
45196
46118
|
}
|
|
45197
46119
|
}
|
|
@@ -45246,7 +46168,7 @@ var RepoburgHttpClient = class {
|
|
|
45246
46168
|
};
|
|
45247
46169
|
|
|
45248
46170
|
// src/repoburg/backend-resolver.ts
|
|
45249
|
-
import
|
|
46171
|
+
import path7 from "node:path";
|
|
45250
46172
|
var HEALTH_POLL_INTERVAL_MS = 1e3;
|
|
45251
46173
|
var HEALTH_TIMEOUT_MS = 3e4;
|
|
45252
46174
|
function daemonBaseUrl() {
|
|
@@ -45301,7 +46223,7 @@ async function backendHealthy(baseUrl, expectedPath) {
|
|
|
45301
46223
|
const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
|
|
45302
46224
|
if (health.status !== "ok") return false;
|
|
45303
46225
|
if (expectedPath && health.projectPath) {
|
|
45304
|
-
return
|
|
46226
|
+
return path7.resolve(health.projectPath) === path7.resolve(expectedPath);
|
|
45305
46227
|
}
|
|
45306
46228
|
return true;
|
|
45307
46229
|
} catch {
|
|
@@ -45321,6 +46243,9 @@ async function waitForHealthy(baseUrl, name, expectedPath) {
|
|
|
45321
46243
|
function serviceBaseUrl(service) {
|
|
45322
46244
|
return `http://localhost:${service.port}`;
|
|
45323
46245
|
}
|
|
46246
|
+
function coveringService(services, absPath) {
|
|
46247
|
+
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path7.sep)).sort((a, b) => b.path.length - a.path.length)[0];
|
|
46248
|
+
}
|
|
45324
46249
|
async function restartService(daemon, name) {
|
|
45325
46250
|
try {
|
|
45326
46251
|
await fetchJson(`${daemon}/services/${name}/restart`, { method: "POST" });
|
|
@@ -45343,7 +46268,8 @@ function cache(absPath, service) {
|
|
|
45343
46268
|
const resolved = {
|
|
45344
46269
|
baseUrl: serviceBaseUrl(service),
|
|
45345
46270
|
port: service.port,
|
|
45346
|
-
name: service.name
|
|
46271
|
+
name: service.name,
|
|
46272
|
+
servesPath: service.path
|
|
45347
46273
|
};
|
|
45348
46274
|
resolvedCache.set(absPath, resolved);
|
|
45349
46275
|
return resolved;
|
|
@@ -45354,10 +46280,10 @@ async function resolveBackendUrl(projectPath, opts = {}) {
|
|
|
45354
46280
|
if (envUrl) {
|
|
45355
46281
|
return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
|
|
45356
46282
|
}
|
|
45357
|
-
const absPath =
|
|
46283
|
+
const absPath = path7.resolve(projectPath);
|
|
45358
46284
|
const daemon = daemonBaseUrl();
|
|
45359
46285
|
const cached = resolvedCache.get(absPath);
|
|
45360
|
-
if (cached && await backendHealthy(cached.baseUrl, absPath)) {
|
|
46286
|
+
if (cached && await backendHealthy(cached.baseUrl, cached.servesPath ?? absPath)) {
|
|
45361
46287
|
return cached;
|
|
45362
46288
|
}
|
|
45363
46289
|
try {
|
|
@@ -45368,20 +46294,20 @@ async function resolveBackendUrl(projectPath, opts = {}) {
|
|
|
45368
46294
|
);
|
|
45369
46295
|
}
|
|
45370
46296
|
const services = await fetchJson(`${daemon}/services`);
|
|
45371
|
-
const match = services
|
|
46297
|
+
const match = coveringService(services, absPath);
|
|
45372
46298
|
if (match && match.status === "running") {
|
|
45373
|
-
if (await backendHealthy(serviceBaseUrl(match),
|
|
46299
|
+
if (await backendHealthy(serviceBaseUrl(match), match.path)) {
|
|
45374
46300
|
return cache(absPath, match);
|
|
45375
46301
|
}
|
|
45376
46302
|
if (!autoStart) return null;
|
|
45377
46303
|
await restartService(daemon, match.name);
|
|
45378
|
-
await waitForHealthy(serviceBaseUrl(match), match.name,
|
|
46304
|
+
await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
|
|
45379
46305
|
return cache(absPath, match);
|
|
45380
46306
|
}
|
|
45381
46307
|
if (!autoStart) return null;
|
|
45382
46308
|
if (match) {
|
|
45383
46309
|
await restartService(daemon, match.name);
|
|
45384
|
-
await waitForHealthy(serviceBaseUrl(match), match.name,
|
|
46310
|
+
await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
|
|
45385
46311
|
return cache(absPath, match);
|
|
45386
46312
|
}
|
|
45387
46313
|
const service = await startService(daemon, absPath);
|
|
@@ -46529,6 +47455,7 @@ async function startTurn3(session, turn) {
|
|
|
46529
47455
|
`[repoburg] resolved backend ${baseUrl} differs from pinned ${pinned.baseUrl} for session ${session.id} \u2014 keeping the pinned entry.`
|
|
46530
47456
|
);
|
|
46531
47457
|
}
|
|
47458
|
+
void registerMiniAppMcp(baseUrl);
|
|
46532
47459
|
let entry;
|
|
46533
47460
|
try {
|
|
46534
47461
|
entry = turn.thread_id ? await ensureThreadSession(session, turn, client, baseUrl) : await ensureSession(session, client, baseUrl);
|
|
@@ -46753,7 +47680,7 @@ registerProvider("repoburg", repoburgProvider);
|
|
|
46753
47680
|
async function createAgentPaneApp(dbPath) {
|
|
46754
47681
|
initDb(dbPath);
|
|
46755
47682
|
const fastify = (0, import_fastify.default)({ logger: true, bodyLimit: 50 * 1024 * 1024 });
|
|
46756
|
-
await fastify.register(import_cors.default, { origin: true });
|
|
47683
|
+
await fastify.register(import_cors.default, { origin: true, methods: "GET,HEAD,PUT,PATCH,POST,DELETE" });
|
|
46757
47684
|
await registerSessionRoutes(fastify);
|
|
46758
47685
|
await registerTurnRoutes(fastify);
|
|
46759
47686
|
await registerThreadRoutes(fastify);
|
|
@@ -46768,6 +47695,7 @@ async function createAgentPaneApp(dbPath) {
|
|
|
46768
47695
|
await registerPerfLogRoutes(fastify);
|
|
46769
47696
|
await registerMaintenanceRoutes(fastify);
|
|
46770
47697
|
await registerVscodeWebRoutes(fastify);
|
|
47698
|
+
await registerAppRoutes(fastify);
|
|
46771
47699
|
const wss2 = initWs();
|
|
46772
47700
|
return { fastify, wss: wss2 };
|
|
46773
47701
|
}
|