repoburg 1.3.276 → 1.3.278
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 +1113 -431
- package/agent-pane/backend/dist/server.js +1113 -431
- package/agent-pane/frontend/dist/assets/index-BD6rEkyH.css +1 -0
- package/agent-pane/frontend/dist/assets/index-DMFO29nN.js +639 -0
- package/agent-pane/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/tabtape/extension/dist/build-info.json +3 -3
- package/tabtape/extension/dist/manifest.json +1 -1
- package/tabtape/ui/dist/build-info.json +3 -3
- package/agent-pane/frontend/dist/assets/index-CZYdmbey.js +0 -612
- package/agent-pane/frontend/dist/assets/index-l4iJLb5_.css +0 -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 path11 = req.path;
|
|
6128
|
+
_req.url = typeof path11 === "string" ? path11 : 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(path11) {
|
|
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 < path11.length; i++) {
|
|
6300
|
+
const char = path11[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 path11 of paths) {
|
|
6432
|
+
const parts = parsePath(path11);
|
|
6433
6433
|
if (parts.includes("*")) {
|
|
6434
|
-
redactWildcardPath(obj, parts, censor,
|
|
6434
|
+
redactWildcardPath(obj, parts, censor, path11, 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, path11) => {
|
|
6520
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path11];
|
|
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 path11 of pathsToClone) {
|
|
6556
|
+
const parts = parsePath(path11);
|
|
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(path11) {
|
|
6609
|
+
if (typeof path11 !== "string") {
|
|
6610
6610
|
throw new Error("Paths must be (non-empty) strings");
|
|
6611
6611
|
}
|
|
6612
|
-
if (
|
|
6612
|
+
if (path11 === "") {
|
|
6613
6613
|
throw new Error("Invalid redaction path ()");
|
|
6614
6614
|
}
|
|
6615
|
-
if (
|
|
6616
|
-
throw new Error(`Invalid redaction path (${
|
|
6615
|
+
if (path11.includes("..")) {
|
|
6616
|
+
throw new Error(`Invalid redaction path (${path11})`);
|
|
6617
6617
|
}
|
|
6618
|
-
if (
|
|
6619
|
-
throw new Error(`Invalid redaction path (${
|
|
6618
|
+
if (path11.includes(",")) {
|
|
6619
|
+
throw new Error(`Invalid redaction path (${path11})`);
|
|
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 < path11.length; i++) {
|
|
6625
|
+
const char = path11[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 (${path11})`);
|
|
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 (${path11})`);
|
|
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 path11 of paths) {
|
|
6652
|
+
validatePath(path11);
|
|
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, path11) => {
|
|
6821
|
+
return censor(value, [k, ...path11]);
|
|
6822
6822
|
} : censor;
|
|
6823
6823
|
o[k] = Redact({
|
|
6824
6824
|
paths: shape[k],
|
|
@@ -7039,7 +7039,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7039
7039
|
var fs7 = __require("fs");
|
|
7040
7040
|
var EventEmitter2 = __require("events");
|
|
7041
7041
|
var inherits = __require("util").inherits;
|
|
7042
|
-
var
|
|
7042
|
+
var path11 = __require("path");
|
|
7043
7043
|
var sleep = require_atomic_sleep();
|
|
7044
7044
|
var assert = __require("assert");
|
|
7045
7045
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -7093,7 +7093,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7093
7093
|
const mode = sonic.mode;
|
|
7094
7094
|
if (sonic.sync) {
|
|
7095
7095
|
try {
|
|
7096
|
-
if (sonic.mkdir) fs7.mkdirSync(
|
|
7096
|
+
if (sonic.mkdir) fs7.mkdirSync(path11.dirname(file), { recursive: true });
|
|
7097
7097
|
const fd = fs7.openSync(file, flags, mode);
|
|
7098
7098
|
fileOpened(null, fd);
|
|
7099
7099
|
} catch (err) {
|
|
@@ -7101,7 +7101,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7101
7101
|
throw err;
|
|
7102
7102
|
}
|
|
7103
7103
|
} else if (sonic.mkdir) {
|
|
7104
|
-
fs7.mkdir(
|
|
7104
|
+
fs7.mkdir(path11.dirname(file), { recursive: true }, (err) => {
|
|
7105
7105
|
if (err) return fileOpened(err);
|
|
7106
7106
|
fs7.open(file, flags, mode, fileOpened);
|
|
7107
7107
|
});
|
|
@@ -8433,15 +8433,15 @@ var require_transport = __commonJS({
|
|
|
8433
8433
|
if (!unquoted) {
|
|
8434
8434
|
return false;
|
|
8435
8435
|
}
|
|
8436
|
-
let
|
|
8437
|
-
if (
|
|
8436
|
+
let path11 = unquoted;
|
|
8437
|
+
if (path11.startsWith("file://")) {
|
|
8438
8438
|
try {
|
|
8439
|
-
|
|
8439
|
+
path11 = fileURLToPath3(path11);
|
|
8440
8440
|
} catch {
|
|
8441
8441
|
return false;
|
|
8442
8442
|
}
|
|
8443
8443
|
}
|
|
8444
|
-
return isAbsolute(
|
|
8444
|
+
return isAbsolute(path11) && !existsSync3(path11);
|
|
8445
8445
|
}
|
|
8446
8446
|
function stripQuotes(value) {
|
|
8447
8447
|
const first = value[0];
|
|
@@ -10182,7 +10182,7 @@ var require_pino = __commonJS({
|
|
|
10182
10182
|
} = symbols;
|
|
10183
10183
|
var { epochTime, nullTime } = time;
|
|
10184
10184
|
var { pid } = process;
|
|
10185
|
-
var
|
|
10185
|
+
var hostname2 = os4.hostname();
|
|
10186
10186
|
var defaultErrorSerializer = stdSerializers.err;
|
|
10187
10187
|
var defaultOptions = {
|
|
10188
10188
|
level: "info",
|
|
@@ -10192,7 +10192,7 @@ var require_pino = __commonJS({
|
|
|
10192
10192
|
errorKey: "err",
|
|
10193
10193
|
nestedKey: null,
|
|
10194
10194
|
enabled: true,
|
|
10195
|
-
base: { pid, hostname },
|
|
10195
|
+
base: { pid, hostname: hostname2 },
|
|
10196
10196
|
serializers: Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
10197
10197
|
err: defaultErrorSerializer
|
|
10198
10198
|
}),
|
|
@@ -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(path11) {
|
|
17121
|
+
let input = path11;
|
|
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 [path11, query2] = wsComponent.resourceName.split("?");
|
|
17374
|
+
wsComponent.path = path11 && path11 !== "/" ? path11 : void 0;
|
|
17375
17375
|
wsComponent.query = query2;
|
|
17376
17376
|
wsComponent.resourceName = void 0;
|
|
17377
17377
|
}
|
|
@@ -20193,9 +20193,9 @@ var require_discriminator = __commonJS({
|
|
|
20193
20193
|
function validateMapping() {
|
|
20194
20194
|
const mapping = getMapping();
|
|
20195
20195
|
gen.if(false);
|
|
20196
|
-
for (const
|
|
20197
|
-
gen.elseIf((0, codegen_1._)`${tag} === ${
|
|
20198
|
-
gen.assign(valid, applyTagSchema(mapping[
|
|
20196
|
+
for (const tagValue2 in mapping) {
|
|
20197
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
|
|
20198
|
+
gen.assign(valid, applyTagSchema(mapping[tagValue2]));
|
|
20199
20199
|
}
|
|
20200
20200
|
gen.else();
|
|
20201
20201
|
cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag, tagName });
|
|
@@ -20239,18 +20239,18 @@ var require_discriminator = __commonJS({
|
|
|
20239
20239
|
if (sch.const) {
|
|
20240
20240
|
addMapping(sch.const, i);
|
|
20241
20241
|
} else if (sch.enum) {
|
|
20242
|
-
for (const
|
|
20243
|
-
addMapping(
|
|
20242
|
+
for (const tagValue2 of sch.enum) {
|
|
20243
|
+
addMapping(tagValue2, i);
|
|
20244
20244
|
}
|
|
20245
20245
|
} else {
|
|
20246
20246
|
throw new Error(`discriminator: "properties/${tagName}" must have "const" or "enum"`);
|
|
20247
20247
|
}
|
|
20248
20248
|
}
|
|
20249
|
-
function addMapping(
|
|
20250
|
-
if (typeof
|
|
20249
|
+
function addMapping(tagValue2, i) {
|
|
20250
|
+
if (typeof tagValue2 != "string" || tagValue2 in oneOfMapping) {
|
|
20251
20251
|
throw new Error(`discriminator: "${tagName}" values must be unique strings`);
|
|
20252
20252
|
}
|
|
20253
|
-
oneOfMapping[
|
|
20253
|
+
oneOfMapping[tagValue2] = i;
|
|
20254
20254
|
}
|
|
20255
20255
|
}
|
|
20256
20256
|
}
|
|
@@ -21028,9 +21028,9 @@ var require_discriminator2 = __commonJS({
|
|
|
21028
21028
|
}
|
|
21029
21029
|
function validateMapping(tag) {
|
|
21030
21030
|
gen.if(false);
|
|
21031
|
-
for (const
|
|
21032
|
-
gen.elseIf((0, codegen_1._)`${tag} === ${
|
|
21033
|
-
gen.assign(valid, applyTagSchema(
|
|
21031
|
+
for (const tagValue2 in parentSchema.mapping) {
|
|
21032
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
|
|
21033
|
+
gen.assign(valid, applyTagSchema(tagValue2));
|
|
21034
21034
|
}
|
|
21035
21035
|
gen.else();
|
|
21036
21036
|
cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag }, { instancePath: schema, schemaPath: "mapping", parentSchema: true });
|
|
@@ -21445,9 +21445,9 @@ var require_serialize = __commonJS({
|
|
|
21445
21445
|
const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(discriminator)}`);
|
|
21446
21446
|
serializeString({ ...cxt, data: tag });
|
|
21447
21447
|
gen.if(false);
|
|
21448
|
-
for (const
|
|
21449
|
-
gen.elseIf((0, codegen_1._)`${tag} === ${
|
|
21450
|
-
const sch = schema.mapping[
|
|
21448
|
+
for (const tagValue2 in schema.mapping) {
|
|
21449
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
|
|
21450
|
+
const sch = schema.mapping[tagValue2];
|
|
21451
21451
|
serializeSchemaProperties({ ...cxt, schema: sch }, discriminator);
|
|
21452
21452
|
}
|
|
21453
21453
|
gen.endIf();
|
|
@@ -21913,9 +21913,9 @@ var require_parse = __commonJS({
|
|
|
21913
21913
|
gen.assign(names_1.default.jsonPos, startPos);
|
|
21914
21914
|
gen.if((0, codegen_1._)`${tag} === undefined`);
|
|
21915
21915
|
parsingError(cxt, (0, codegen_1.str)`discriminator tag not found`);
|
|
21916
|
-
for (const
|
|
21917
|
-
gen.elseIf((0, codegen_1._)`${tag} === ${
|
|
21918
|
-
parseSchemaProperties({ ...cxt, schema: mapping[
|
|
21916
|
+
for (const tagValue2 in mapping) {
|
|
21917
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
|
|
21918
|
+
parseSchemaProperties({ ...cxt, schema: mapping[tagValue2] }, discriminator);
|
|
21919
21919
|
}
|
|
21920
21920
|
gen.else();
|
|
21921
21921
|
parsingError(cxt, (0, codegen_1.str)`discriminator value not in schema`);
|
|
@@ -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(path11) {
|
|
22312
|
+
let input = path11;
|
|
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 [path11, query2] = wsComponent.resourceName.split("?");
|
|
22658
|
+
wsComponent.path = path11 && path11 !== "/" ? path11 : void 0;
|
|
22659
22659
|
wsComponent.query = query2;
|
|
22660
22660
|
wsComponent.resourceName = void 0;
|
|
22661
22661
|
}
|
|
@@ -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(path11) {
|
|
24143
|
+
let input = path11;
|
|
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 [path11, query2] = wsComponent.resourceName.split("?");
|
|
24489
|
+
wsComponent.path = path11 && path11 !== "/" ? path11 : 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(path11, pathIndex) {
|
|
32007
|
+
const charCode = path11.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(path11, 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(path11, pathIndex = 0) {
|
|
32021
|
+
if (path11.length === pathIndex) {
|
|
32022
32022
|
return this;
|
|
32023
32023
|
}
|
|
32024
|
-
const staticChild = this.findStaticMatchingChild(
|
|
32024
|
+
const staticChild = this.findStaticMatchingChild(path11, pathIndex);
|
|
32025
32025
|
if (staticChild) {
|
|
32026
|
-
return staticChild.getStaticChild(
|
|
32026
|
+
return staticChild.getStaticChild(path11, pathIndex + staticChild.prefix.length);
|
|
32027
32027
|
}
|
|
32028
32028
|
return null;
|
|
32029
32029
|
}
|
|
32030
|
-
createStaticChild(
|
|
32031
|
-
if (
|
|
32030
|
+
createStaticChild(path11) {
|
|
32031
|
+
if (path11.length === 0) {
|
|
32032
32032
|
return this;
|
|
32033
32033
|
}
|
|
32034
|
-
const childIndex = this.staticChildrenCharCodes.indexOf(
|
|
32034
|
+
const childIndex = this.staticChildrenCharCodes.indexOf(path11.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 (path11.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(path11.slice(i));
|
|
32045
32045
|
}
|
|
32046
|
-
const node = new StaticNode(
|
|
32047
|
-
this.setStaticChild(
|
|
32046
|
+
const node = new StaticNode(path11);
|
|
32047
|
+
this.setStaticChild(path11.charAt(0), node);
|
|
32048
32048
|
return node;
|
|
32049
32049
|
}
|
|
32050
32050
|
};
|
|
@@ -32068,13 +32068,13 @@ var require_node = __commonJS({
|
|
|
32068
32068
|
}
|
|
32069
32069
|
return null;
|
|
32070
32070
|
}
|
|
32071
|
-
createParametricChild(regex, staticSuffix,
|
|
32071
|
+
createParametricChild(regex, staticSuffix, nodePath2) {
|
|
32072
32072
|
let parametricChild = this.getParametricChild(regex);
|
|
32073
32073
|
if (parametricChild) {
|
|
32074
|
-
parametricChild.nodePaths.add(
|
|
32074
|
+
parametricChild.nodePaths.add(nodePath2);
|
|
32075
32075
|
return parametricChild;
|
|
32076
32076
|
}
|
|
32077
|
-
parametricChild = new ParametricNode(regex, staticSuffix,
|
|
32077
|
+
parametricChild = new ParametricNode(regex, staticSuffix, nodePath2);
|
|
32078
32078
|
this.parametricChildren.push(parametricChild);
|
|
32079
32079
|
this.parametricChildren.sort((child1, child2) => {
|
|
32080
32080
|
if (!child1.isRegex) return 1;
|
|
@@ -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(path11, pathIndex, nodeStack, paramsCount) {
|
|
32108
|
+
let node = this.findStaticMatchingChild(path11, pathIndex);
|
|
32109
32109
|
let parametricBrotherNodeIndex = 0;
|
|
32110
32110
|
if (node === null) {
|
|
32111
32111
|
if (this.parametricChildren.length === 0) {
|
|
@@ -32144,16 +32144,16 @@ var require_node = __commonJS({
|
|
|
32144
32144
|
}
|
|
32145
32145
|
};
|
|
32146
32146
|
var ParametricNode = class extends ParentNode {
|
|
32147
|
-
constructor(regex, staticSuffix,
|
|
32147
|
+
constructor(regex, staticSuffix, nodePath2) {
|
|
32148
32148
|
super();
|
|
32149
32149
|
this.isRegex = !!regex;
|
|
32150
32150
|
this.regex = regex || null;
|
|
32151
32151
|
this.staticSuffix = staticSuffix || null;
|
|
32152
32152
|
this.kind = NODE_TYPES.PARAMETRIC;
|
|
32153
|
-
this.nodePaths = /* @__PURE__ */ new Set([
|
|
32153
|
+
this.nodePaths = /* @__PURE__ */ new Set([nodePath2]);
|
|
32154
32154
|
}
|
|
32155
|
-
getNextNode(
|
|
32156
|
-
return this.findStaticMatchingChild(
|
|
32155
|
+
getNextNode(path11, pathIndex) {
|
|
32156
|
+
return this.findStaticMatchingChild(path11, 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(path11, useSemicolonDelimiter) {
|
|
32513
|
+
if (path11.length >= MIN_NATIVE_SCAN_LENGTH) {
|
|
32514
|
+
return safeDecodeURINativeScan(path11, useSemicolonDelimiter);
|
|
32515
32515
|
}
|
|
32516
|
-
return safeDecodeURICharScan(
|
|
32516
|
+
return safeDecodeURICharScan(path11, useSemicolonDelimiter, 1);
|
|
32517
32517
|
}
|
|
32518
|
-
function safeDecodeURINativeScan(
|
|
32519
|
-
const percentIndex =
|
|
32520
|
-
let delimIndex =
|
|
32521
|
-
const hashIndex =
|
|
32518
|
+
function safeDecodeURINativeScan(path11, useSemicolonDelimiter) {
|
|
32519
|
+
const percentIndex = path11.indexOf("%", 1);
|
|
32520
|
+
let delimIndex = path11.indexOf("?", 1);
|
|
32521
|
+
const hashIndex = path11.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 = path11.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: path11, querystring: "", shouldDecodeParam: false };
|
|
32534
32534
|
}
|
|
32535
32535
|
return {
|
|
32536
|
-
path:
|
|
32537
|
-
querystring:
|
|
32536
|
+
path: path11.slice(0, delimIndex),
|
|
32537
|
+
querystring: path11.slice(delimIndex + 1),
|
|
32538
32538
|
shouldDecodeParam: false
|
|
32539
32539
|
};
|
|
32540
32540
|
}
|
|
32541
|
-
return safeDecodeURIPercentScan(
|
|
32541
|
+
return safeDecodeURIPercentScan(path11, useSemicolonDelimiter, percentIndex);
|
|
32542
32542
|
}
|
|
32543
|
-
function safeDecodeURICharScan(
|
|
32544
|
-
for (let i = startIndex; i <
|
|
32545
|
-
const charCode =
|
|
32543
|
+
function safeDecodeURICharScan(path11, useSemicolonDelimiter, startIndex) {
|
|
32544
|
+
for (let i = startIndex; i < path11.length; i++) {
|
|
32545
|
+
const charCode = path11.charCodeAt(i);
|
|
32546
32546
|
if (charCode === 37) {
|
|
32547
|
-
return safeDecodeURIPercentScan(
|
|
32547
|
+
return safeDecodeURIPercentScan(path11, useSemicolonDelimiter, i);
|
|
32548
32548
|
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
32549
32549
|
return {
|
|
32550
|
-
path:
|
|
32551
|
-
querystring:
|
|
32550
|
+
path: path11.slice(0, i),
|
|
32551
|
+
querystring: path11.slice(i + 1),
|
|
32552
32552
|
shouldDecodeParam: false
|
|
32553
32553
|
};
|
|
32554
32554
|
}
|
|
32555
32555
|
}
|
|
32556
|
-
return { path:
|
|
32556
|
+
return { path: path11, querystring: "", shouldDecodeParam: false };
|
|
32557
32557
|
}
|
|
32558
|
-
function reencodePercentChar(
|
|
32559
|
-
return
|
|
32558
|
+
function reencodePercentChar(path11, index) {
|
|
32559
|
+
return path11.slice(0, index + 1) + "25" + path11.slice(index + 1);
|
|
32560
32560
|
}
|
|
32561
|
-
function safeDecodeURIPercentScan(
|
|
32561
|
+
function safeDecodeURIPercentScan(path11, 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 < path11.length; i++) {
|
|
32566
|
+
const charCode = path11.charCodeAt(i);
|
|
32567
32567
|
if (charCode === 37) {
|
|
32568
|
-
const componentCharCode = decodeComponentCharCode(
|
|
32568
|
+
const componentCharCode = decodeComponentCharCode(path11.charCodeAt(i + 1), path11.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
|
+
path11 = reencodePercentChar(path11, 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 = path11.slice(i + 1);
|
|
32582
|
+
path11 = path11.slice(0, i);
|
|
32583
32583
|
break;
|
|
32584
32584
|
}
|
|
32585
32585
|
}
|
|
32586
|
-
const decodedPath = shouldDecode ? decodeURI(
|
|
32586
|
+
const decodedPath = shouldDecode ? decodeURI(path11) : path11;
|
|
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, path11, 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 path11 === "string", "Path should be a string");
|
|
32690
|
+
assert(path11.length > 0, "The path could not be empty");
|
|
32691
|
+
assert(path11[0] === "/" || path11[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 = path11.match(OPTIONAL_PARAM_REGEXP);
|
|
32694
32694
|
if (optionalParamMatch) {
|
|
32695
|
-
assert(
|
|
32696
|
-
const pathFull =
|
|
32697
|
-
const pathOptional =
|
|
32695
|
+
assert(path11.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
32696
|
+
const pathFull = path11.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
32697
|
+
const pathOptional = path11.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 = path11;
|
|
32703
32703
|
if (this.ignoreDuplicateSlashes) {
|
|
32704
|
-
|
|
32704
|
+
path11 = removeDuplicateSlashes(path11);
|
|
32705
32705
|
}
|
|
32706
32706
|
if (this.ignoreTrailingSlash) {
|
|
32707
|
-
|
|
32707
|
+
path11 = trimLastSlash(path11);
|
|
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, path11, opts, handler, store, route);
|
|
32714
32714
|
}
|
|
32715
32715
|
};
|
|
32716
|
-
Router.prototype._on = function _on(method,
|
|
32716
|
+
Router.prototype._on = function _on(method, path11, 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 = path11;
|
|
32730
32730
|
if (pattern === "*" && this.trees[method].prefix.length !== 0) {
|
|
32731
32731
|
const currentRoot = this.trees[method];
|
|
32732
32732
|
this.trees[method] = new StaticNode("");
|
|
@@ -32803,11 +32803,11 @@ var require_find_my_way = __commonJS({
|
|
|
32803
32803
|
nodePatternParts += "()" + staticPart;
|
|
32804
32804
|
if (isEndOfNode || pattern.charCodeAt(j) === 47 || j === pattern.length) {
|
|
32805
32805
|
const nodePattern = isRegexNode ? nodePatternParts : staticPart;
|
|
32806
|
-
const
|
|
32806
|
+
const nodePath2 = pattern.slice(i, j);
|
|
32807
32807
|
pattern = pattern.slice(0, i + 1) + nodePattern + pattern.slice(j);
|
|
32808
32808
|
i += nodePattern.length;
|
|
32809
32809
|
const regex = isRegexNode ? new RegExp("^" + regexps.join("") + "$") : null;
|
|
32810
|
-
currentNode = currentNode.createParametricChild(regex, staticPart || null,
|
|
32810
|
+
currentNode = currentNode.createParametricChild(regex, staticPart || null, nodePath2);
|
|
32811
32811
|
parentNodePathIndex = i + 1;
|
|
32812
32812
|
break;
|
|
32813
32813
|
}
|
|
@@ -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: path11, 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, path11, constraints) {
|
|
32842
|
+
const route = this.findRoute(method, path11, constraints);
|
|
32843
32843
|
return route !== null;
|
|
32844
32844
|
};
|
|
32845
|
-
Router.prototype.findRoute = function findNode(method,
|
|
32845
|
+
Router.prototype.findRoute = function findNode(method, path11, constraints = {}) {
|
|
32846
32846
|
if (this.trees[method] === void 0) {
|
|
32847
32847
|
return null;
|
|
32848
32848
|
}
|
|
32849
|
-
let pattern =
|
|
32849
|
+
let pattern = path11;
|
|
32850
32850
|
let currentNode = this.trees[method];
|
|
32851
32851
|
let parentNodePathIndex = currentNode.prefix.length;
|
|
32852
32852
|
const params = [];
|
|
@@ -32918,11 +32918,11 @@ var require_find_my_way = __commonJS({
|
|
|
32918
32918
|
nodePatternParts += "()" + staticPart;
|
|
32919
32919
|
if (isEndOfNode || pattern.charCodeAt(j) === 47 || j === pattern.length) {
|
|
32920
32920
|
const nodePattern = isRegexNode ? nodePatternParts : staticPart;
|
|
32921
|
-
const
|
|
32921
|
+
const nodePath2 = pattern.slice(i, j);
|
|
32922
32922
|
pattern = pattern.slice(0, i + 1) + nodePattern + pattern.slice(j);
|
|
32923
32923
|
i += nodePattern.length;
|
|
32924
32924
|
const regex = isRegexNode ? new RegExp("^" + regexps.join("") + "$") : null;
|
|
32925
|
-
currentNode = currentNode.getParametricChild(regex, staticPart || null,
|
|
32925
|
+
currentNode = currentNode.getParametricChild(regex, staticPart || null, nodePath2);
|
|
32926
32926
|
if (currentNode === null) {
|
|
32927
32927
|
return null;
|
|
32928
32928
|
}
|
|
@@ -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, path11, constraints) {
|
|
32971
|
+
assert(typeof path11 === "string", "Path should be a string");
|
|
32972
|
+
assert(path11.length > 0, "The path could not be empty");
|
|
32973
|
+
assert(path11[0] === "/" || path11[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 = path11.match(OPTIONAL_PARAM_REGEXP);
|
|
32979
32979
|
if (optionalParamMatch) {
|
|
32980
|
-
assert(
|
|
32981
|
-
const pathFull =
|
|
32982
|
-
const pathOptional =
|
|
32980
|
+
assert(path11.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
32981
|
+
const pathFull = path11.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
32982
|
+
const pathOptional = path11.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
|
+
path11 = removeDuplicateSlashes(path11);
|
|
32989
32989
|
}
|
|
32990
32990
|
if (this.ignoreTrailingSlash) {
|
|
32991
|
-
|
|
32991
|
+
path11 = trimLastSlash(path11);
|
|
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, path11, constraints);
|
|
32996
32996
|
}
|
|
32997
32997
|
};
|
|
32998
|
-
Router.prototype._off = function _off(method,
|
|
32998
|
+
Router.prototype._off = function _off(method, path11, 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 || path11 !== 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, path11, derivedConstraints) {
|
|
33040
33040
|
let currentNode = method === "GET" ? this._treeGET : this.trees[method];
|
|
33041
33041
|
if (currentNode == null) return null;
|
|
33042
|
-
if (
|
|
33043
|
-
|
|
33042
|
+
if (path11.charCodeAt(0) !== 47) {
|
|
33043
|
+
path11 = path11.replace(FULL_PATH_REGEXP, "/");
|
|
33044
33044
|
}
|
|
33045
33045
|
if (this.ignoreDuplicateSlashes) {
|
|
33046
|
-
|
|
33046
|
+
path11 = removeDuplicateSlashes(path11);
|
|
33047
33047
|
}
|
|
33048
33048
|
let sanitizedUrl;
|
|
33049
33049
|
let querystring2;
|
|
33050
33050
|
let shouldDecodeParam;
|
|
33051
33051
|
try {
|
|
33052
|
-
sanitizedUrl =
|
|
33053
|
-
|
|
33052
|
+
sanitizedUrl = path11.length >= MIN_NATIVE_SCAN_LENGTH ? safeDecodeURINativeScan(path11, this.useSemicolonDelimiter) : safeDecodeURICharScan(path11, this.useSemicolonDelimiter, 1);
|
|
33053
|
+
path11 = sanitizedUrl.path;
|
|
33054
33054
|
querystring2 = sanitizedUrl.querystring;
|
|
33055
33055
|
shouldDecodeParam = sanitizedUrl.shouldDecodeParam;
|
|
33056
33056
|
} catch (error) {
|
|
33057
|
-
return this._onBadUrl(
|
|
33057
|
+
return this._onBadUrl(path11);
|
|
33058
33058
|
}
|
|
33059
33059
|
if (this.ignoreTrailingSlash) {
|
|
33060
|
-
|
|
33060
|
+
path11 = trimLastSlash(path11);
|
|
33061
33061
|
}
|
|
33062
|
-
const originPath =
|
|
33062
|
+
const originPath = path11;
|
|
33063
33063
|
if (this.caseSensitive === false) {
|
|
33064
|
-
|
|
33064
|
+
path11 = path11.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 = path11.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(path11, 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: path11, opts, handler, store } = route;
|
|
33186
|
+
this._on(method, path11, 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(path11) {
|
|
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(path11, req, res),
|
|
33204
33204
|
params: {},
|
|
33205
33205
|
store: null
|
|
33206
33206
|
};
|
|
33207
33207
|
};
|
|
33208
|
-
Router.prototype._onMaxParamLength = function(
|
|
33208
|
+
Router.prototype._onMaxParamLength = function(path11) {
|
|
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(path11, 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(path11, handler, store) {
|
|
33247
|
+
return this.on(m, path11, handler, store);
|
|
33248
33248
|
};
|
|
33249
33249
|
}
|
|
33250
|
-
Router.prototype.all = function(
|
|
33251
|
-
this.on(httpMethods,
|
|
33250
|
+
Router.prototype.all = function(path11, handler, store) {
|
|
33251
|
+
this.on(httpMethods, path11, 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(path11) {
|
|
33267
|
+
return path11.indexOf("//") !== -1 ? path11.replace(REMOVE_DUPLICATE_SLASHES_REGEXP, "/") : path11;
|
|
33268
33268
|
}
|
|
33269
|
-
function trimLastSlash(
|
|
33270
|
-
if (
|
|
33271
|
-
return
|
|
33269
|
+
function trimLastSlash(path11) {
|
|
33270
|
+
if (path11.length > 1 && path11.charCodeAt(path11.length - 1) === 47) {
|
|
33271
|
+
return path11.slice(0, -1);
|
|
33272
33272
|
}
|
|
33273
|
-
return
|
|
33273
|
+
return path11;
|
|
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(path11, idx) {
|
|
33285
33285
|
let parentheses = 1;
|
|
33286
|
-
while (idx <
|
|
33286
|
+
while (idx < path11.length) {
|
|
33287
33287
|
idx++;
|
|
33288
|
-
if (
|
|
33288
|
+
if (path11.charCodeAt(idx) === 92) {
|
|
33289
33289
|
idx++;
|
|
33290
33290
|
continue;
|
|
33291
33291
|
}
|
|
33292
|
-
if (
|
|
33292
|
+
if (path11.charCodeAt(idx) === 41) {
|
|
33293
33293
|
parentheses--;
|
|
33294
|
-
} else if (
|
|
33294
|
+
} else if (path11.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 "' + path11 + '"');
|
|
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 path11 = 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, path11);
|
|
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, path11);
|
|
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], path11, 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, path11, 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 (path11 === "/" && 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: path11, 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: path11, prefixing: true, isFastify });
|
|
33572
33572
|
}
|
|
33573
33573
|
}
|
|
33574
|
-
} else if (
|
|
33575
|
-
addNewRoute.call(this, { path:
|
|
33574
|
+
} else if (path11[0] === "/" && prefix.endsWith("/")) {
|
|
33575
|
+
addNewRoute.call(this, { path: path11.slice(1), isFastify });
|
|
33576
33576
|
} else {
|
|
33577
|
-
addNewRoute.call(this, { path:
|
|
33577
|
+
addNewRoute.call(this, { path: path11, isFastify });
|
|
33578
33578
|
}
|
|
33579
33579
|
return this;
|
|
33580
|
-
function addNewRoute({ path:
|
|
33581
|
-
const url = prefix +
|
|
33580
|
+
function addNewRoute({ path: path12, prefixing = false, isFastify: isFastify2 = false }) {
|
|
33581
|
+
const url = prefix + path12;
|
|
33582
33582
|
opts.url = url;
|
|
33583
33583
|
opts.path = url;
|
|
33584
|
-
opts.routePath =
|
|
33584
|
+
opts.routePath = path12;
|
|
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: path12, 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, path11, 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, path11);
|
|
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, path11, 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, path11, 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(path11, 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(path11, 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(path11), 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: `'${path11}' 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(path11, 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(path11), 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: `'${path11}' 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(path11 = "data.db") {
|
|
41005
|
+
db = new Database(path11);
|
|
41006
41006
|
db.pragma("journal_mode = WAL");
|
|
41007
41007
|
db.pragma("foreign_keys = ON");
|
|
41008
41008
|
createTables(db);
|
|
@@ -41095,6 +41095,7 @@ function createTables(database) {
|
|
|
41095
41095
|
workspace_path TEXT NOT NULL DEFAULT '',
|
|
41096
41096
|
pinned INTEGER NOT NULL DEFAULT 0,
|
|
41097
41097
|
state TEXT,
|
|
41098
|
+
version INTEGER NOT NULL DEFAULT 0,
|
|
41098
41099
|
created_at TEXT NOT NULL,
|
|
41099
41100
|
updated_at TEXT NOT NULL,
|
|
41100
41101
|
UNIQUE(app_id, workspace_path)
|
|
@@ -41150,6 +41151,13 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
|
|
|
41150
41151
|
if (!sessColumns.some((c) => c.name === "user_touched")) {
|
|
41151
41152
|
database.exec("ALTER TABLE sessions ADD COLUMN user_touched INTEGER NOT NULL DEFAULT 0");
|
|
41152
41153
|
}
|
|
41154
|
+
if (!sessColumns.some((c) => c.name === "import_source_id")) {
|
|
41155
|
+
database.exec("ALTER TABLE sessions ADD COLUMN import_source_id TEXT");
|
|
41156
|
+
}
|
|
41157
|
+
const appInstanceColumns = database.prepare("PRAGMA table_info(app_instances)").all();
|
|
41158
|
+
if (!appInstanceColumns.some((c) => c.name === "version")) {
|
|
41159
|
+
database.exec("ALTER TABLE app_instances ADD COLUMN version INTEGER NOT NULL DEFAULT 0");
|
|
41160
|
+
}
|
|
41153
41161
|
const turnColumns = database.prepare("PRAGMA table_info(turns)").all();
|
|
41154
41162
|
if (!turnColumns.some((c) => c.name === "thread_id")) {
|
|
41155
41163
|
database.exec("ALTER TABLE turns ADD COLUMN thread_id TEXT");
|
|
@@ -42693,8 +42701,101 @@ Agent: ${agent}`;
|
|
|
42693
42701
|
|
|
42694
42702
|
// src/routes/workspaces.ts
|
|
42695
42703
|
import { execFile } from "node:child_process";
|
|
42704
|
+
import { readdir, stat } from "node:fs/promises";
|
|
42705
|
+
import { homedir, hostname } from "node:os";
|
|
42706
|
+
import nodePath from "node:path";
|
|
42696
42707
|
import { promisify } from "node:util";
|
|
42697
42708
|
var execFileAsync = promisify(execFile);
|
|
42709
|
+
async function resolveWorkspacePath(input) {
|
|
42710
|
+
let p = input.trim();
|
|
42711
|
+
if (p === "~" || p.startsWith("~/")) p = nodePath.join(homedir(), p.slice(1));
|
|
42712
|
+
if (!nodePath.isAbsolute(p)) {
|
|
42713
|
+
return { error: "Enter the full path of a folder, e.g. ~/projects/my-app" };
|
|
42714
|
+
}
|
|
42715
|
+
p = nodePath.resolve(p);
|
|
42716
|
+
try {
|
|
42717
|
+
if (!(await stat(p)).isDirectory()) return { error: `${p} is a file, not a folder` };
|
|
42718
|
+
} catch {
|
|
42719
|
+
return { error: `There is no folder at ${p}` };
|
|
42720
|
+
}
|
|
42721
|
+
return { path: p };
|
|
42722
|
+
}
|
|
42723
|
+
var BROWSE_LIMIT = 500;
|
|
42724
|
+
var HOME_STANDARD_FOLDERS = /* @__PURE__ */ new Set([
|
|
42725
|
+
"Applications",
|
|
42726
|
+
"Desktop",
|
|
42727
|
+
"Documents",
|
|
42728
|
+
"Downloads",
|
|
42729
|
+
"Library",
|
|
42730
|
+
"Movies",
|
|
42731
|
+
"Music",
|
|
42732
|
+
"Pictures",
|
|
42733
|
+
"Public"
|
|
42734
|
+
]);
|
|
42735
|
+
async function exists(p) {
|
|
42736
|
+
try {
|
|
42737
|
+
await stat(p);
|
|
42738
|
+
return true;
|
|
42739
|
+
} catch {
|
|
42740
|
+
return false;
|
|
42741
|
+
}
|
|
42742
|
+
}
|
|
42743
|
+
async function browseFolder(input, opts = {}) {
|
|
42744
|
+
const home = opts.home ?? homedir();
|
|
42745
|
+
let dir = input?.trim() || home;
|
|
42746
|
+
if (dir === "~" || dir.startsWith("~/")) dir = nodePath.join(home, dir.slice(1));
|
|
42747
|
+
if (!nodePath.isAbsolute(dir)) return { status: 400, error: `Not a full path: ${dir}` };
|
|
42748
|
+
dir = nodePath.resolve(dir);
|
|
42749
|
+
let entries;
|
|
42750
|
+
try {
|
|
42751
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
42752
|
+
} catch (err) {
|
|
42753
|
+
const code = err.code;
|
|
42754
|
+
if (code === "ENOENT") return { status: 404, error: `There is no folder at ${dir}` };
|
|
42755
|
+
if (code === "ENOTDIR") return { status: 400, error: `${dir} is a file, not a folder` };
|
|
42756
|
+
if (code === "EACCES" || code === "EPERM") return { status: 403, error: `No permission to open ${dir}` };
|
|
42757
|
+
throw err;
|
|
42758
|
+
}
|
|
42759
|
+
const names = [];
|
|
42760
|
+
for (const entry of entries) {
|
|
42761
|
+
if (entry.name.startsWith(".")) continue;
|
|
42762
|
+
if (entry.isDirectory()) {
|
|
42763
|
+
names.push(entry.name);
|
|
42764
|
+
} else if (entry.isSymbolicLink()) {
|
|
42765
|
+
try {
|
|
42766
|
+
if ((await stat(nodePath.join(dir, entry.name))).isDirectory()) names.push(entry.name);
|
|
42767
|
+
} catch {
|
|
42768
|
+
}
|
|
42769
|
+
}
|
|
42770
|
+
}
|
|
42771
|
+
names.sort((a, b) => a.localeCompare(b, void 0, { sensitivity: "base", numeric: true }));
|
|
42772
|
+
const limit = opts.limit ?? BROWSE_LIMIT;
|
|
42773
|
+
const atHome = dir === nodePath.resolve(home);
|
|
42774
|
+
const folders = await Promise.all(
|
|
42775
|
+
names.slice(0, limit).map(async (name) => {
|
|
42776
|
+
const path11 = nodePath.join(dir, name);
|
|
42777
|
+
const skipProbe = atHome && HOME_STANDARD_FOLDERS.has(name) || dir === "/Volumes";
|
|
42778
|
+
return { name, path: path11, git: !skipProbe && await exists(nodePath.join(path11, ".git")) };
|
|
42779
|
+
})
|
|
42780
|
+
);
|
|
42781
|
+
const parent = nodePath.dirname(dir);
|
|
42782
|
+
return {
|
|
42783
|
+
path: dir,
|
|
42784
|
+
parent: parent === dir ? null : parent,
|
|
42785
|
+
home,
|
|
42786
|
+
hostname: hostname(),
|
|
42787
|
+
folders,
|
|
42788
|
+
truncated: names.length > limit
|
|
42789
|
+
};
|
|
42790
|
+
}
|
|
42791
|
+
var LOOPBACK_HOST = /^(localhost|127(?:\.\d+){3}|\[::1\]|::1|0\.0\.0\.0)(:\d+)?$/i;
|
|
42792
|
+
function pickerAvailability(request, platform = process.platform) {
|
|
42793
|
+
const host = String(request.headers.host ?? "");
|
|
42794
|
+
const remote = Boolean(request.headers["cf-connecting-ip"]) || host !== "" && !LOOPBACK_HOST.test(host);
|
|
42795
|
+
if (remote) return { available: false, reason: "remote" };
|
|
42796
|
+
if (platform !== "darwin") return { available: false, reason: "unsupported" };
|
|
42797
|
+
return { available: true, reason: null };
|
|
42798
|
+
}
|
|
42698
42799
|
async function registerWorkspaceRoutes(fastify) {
|
|
42699
42800
|
fastify.get("/api/workspaces", async () => {
|
|
42700
42801
|
const rows = getDb().prepare("SELECT * FROM workspaces ORDER BY created_at ASC").all();
|
|
@@ -42712,11 +42813,15 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42712
42813
|
}
|
|
42713
42814
|
}
|
|
42714
42815
|
}, async (request, reply) => {
|
|
42715
|
-
const { path:
|
|
42716
|
-
if (!
|
|
42816
|
+
const { path: path11, label = null } = request.body || {};
|
|
42817
|
+
if (!path11 || !path11.trim()) {
|
|
42717
42818
|
return reply.code(400).send({ error: "Path is required" });
|
|
42718
42819
|
}
|
|
42719
|
-
const
|
|
42820
|
+
const resolved = await resolveWorkspacePath(path11);
|
|
42821
|
+
if ("error" in resolved) {
|
|
42822
|
+
return reply.code(400).send({ error: resolved.error });
|
|
42823
|
+
}
|
|
42824
|
+
const trimmedPath = resolved.path;
|
|
42720
42825
|
const db2 = getDb();
|
|
42721
42826
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
42722
42827
|
if (existing) {
|
|
@@ -42738,14 +42843,20 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42738
42843
|
const workspace = db2.prepare("SELECT * FROM workspaces WHERE id = ?").get(id);
|
|
42739
42844
|
return workspace;
|
|
42740
42845
|
});
|
|
42846
|
+
fastify.get("/api/workspaces/picker", async (request) => pickerAvailability(request));
|
|
42847
|
+
fastify.get("/api/workspaces/browse", async (request, reply) => {
|
|
42848
|
+
const result = await browseFolder(request.query.path);
|
|
42849
|
+
if ("error" in result) return reply.code(result.status).send({ error: result.error });
|
|
42850
|
+
return result;
|
|
42851
|
+
});
|
|
42741
42852
|
fastify.get("/api/pick-directory", async (_request, reply) => {
|
|
42742
42853
|
try {
|
|
42743
42854
|
const { stdout } = await execFileAsync("osascript", [
|
|
42744
42855
|
"-e",
|
|
42745
42856
|
'POSIX path of (choose folder with prompt "Select a workspace directory")'
|
|
42746
42857
|
]);
|
|
42747
|
-
const
|
|
42748
|
-
return { path:
|
|
42858
|
+
const path11 = stdout.trim().replace(/\/$/, "");
|
|
42859
|
+
return { path: path11 };
|
|
42749
42860
|
} catch {
|
|
42750
42861
|
return reply.code(204).send({ cancelled: true });
|
|
42751
42862
|
}
|
|
@@ -42761,11 +42872,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42761
42872
|
}
|
|
42762
42873
|
}
|
|
42763
42874
|
}, async (request, reply) => {
|
|
42764
|
-
const { path:
|
|
42765
|
-
if (!
|
|
42875
|
+
const { path: path11 } = request.body || {};
|
|
42876
|
+
if (!path11 || !path11.trim()) {
|
|
42766
42877
|
return reply.code(400).send({ error: "Path is required" });
|
|
42767
42878
|
}
|
|
42768
|
-
const trimmedPath =
|
|
42879
|
+
const trimmedPath = path11.trim();
|
|
42769
42880
|
const db2 = getDb();
|
|
42770
42881
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
42771
42882
|
if (existing) {
|
|
@@ -43370,12 +43481,12 @@ async function registerFileRoutes(fastify) {
|
|
|
43370
43481
|
|
|
43371
43482
|
// src/routes/perf-log.ts
|
|
43372
43483
|
import { appendFileSync, mkdirSync, renameSync, statSync } from "node:fs";
|
|
43373
|
-
import { homedir } from "node:os";
|
|
43484
|
+
import { homedir as homedir2 } from "node:os";
|
|
43374
43485
|
import { dirname, join } from "node:path";
|
|
43375
43486
|
var MAX_BYTES = 5 * 1024 * 1024;
|
|
43376
43487
|
var MAX_BATCH = 500;
|
|
43377
43488
|
function perfLogPath() {
|
|
43378
|
-
return process.env.AGENT_PANE_PERF_LOG ?? join(
|
|
43489
|
+
return process.env.AGENT_PANE_PERF_LOG ?? join(homedir2(), ".repoburg", "agent-pane", "perf.log");
|
|
43379
43490
|
}
|
|
43380
43491
|
function oneLine(s) {
|
|
43381
43492
|
return s.replace(/[\r\n\t]+/g, " ");
|
|
@@ -43412,17 +43523,17 @@ async function registerPerfLogRoutes(fastify) {
|
|
|
43412
43523
|
if (entries.length === 0) {
|
|
43413
43524
|
return reply.send({ written: 0 });
|
|
43414
43525
|
}
|
|
43415
|
-
const
|
|
43526
|
+
const path11 = perfLogPath();
|
|
43416
43527
|
try {
|
|
43417
|
-
mkdirSync(dirname(
|
|
43528
|
+
mkdirSync(dirname(path11), { recursive: true });
|
|
43418
43529
|
try {
|
|
43419
|
-
if (statSync(
|
|
43420
|
-
renameSync(
|
|
43530
|
+
if (statSync(path11).size > MAX_BYTES) {
|
|
43531
|
+
renameSync(path11, `${path11}.1`);
|
|
43421
43532
|
}
|
|
43422
43533
|
} catch {
|
|
43423
43534
|
}
|
|
43424
43535
|
const lines = entries.map((e) => `${new Date(e.t).toISOString()} [${oneLine(e.cat)}] ${oneLine(e.msg)}`).join("\n");
|
|
43425
|
-
appendFileSync(
|
|
43536
|
+
appendFileSync(path11, `${lines}
|
|
43426
43537
|
`, "utf-8");
|
|
43427
43538
|
return reply.send({ written: entries.length });
|
|
43428
43539
|
} catch (err) {
|
|
@@ -43500,7 +43611,7 @@ import net from "node:net";
|
|
|
43500
43611
|
import crypto from "node:crypto";
|
|
43501
43612
|
import os from "node:os";
|
|
43502
43613
|
import path2 from "node:path";
|
|
43503
|
-
import { mkdir, readdir, symlink, lstat, access, readFile, writeFile, unlink } from "node:fs/promises";
|
|
43614
|
+
import { mkdir, readdir as readdir2, symlink, lstat, access, readFile, writeFile, unlink } from "node:fs/promises";
|
|
43504
43615
|
var VSCODE_WEB_DATA_DIR = path2.join(os.homedir(), ".repoburg", "vscode-web");
|
|
43505
43616
|
function resolveDesktopUserDir() {
|
|
43506
43617
|
if (process.platform === "darwin") {
|
|
@@ -43533,7 +43644,7 @@ async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
|
|
|
43533
43644
|
const desktopExt = path2.join(os.homedir(), ".vscode", "extensions");
|
|
43534
43645
|
let entries;
|
|
43535
43646
|
try {
|
|
43536
|
-
entries = await
|
|
43647
|
+
entries = await readdir2(desktopExt, { withFileTypes: true });
|
|
43537
43648
|
} catch {
|
|
43538
43649
|
return;
|
|
43539
43650
|
}
|
|
@@ -98312,7 +98423,8 @@ Icons come from ONE library: Lucide (https://lucide.dev/icons, ISC).
|
|
|
98312
98423
|
## Bridge API (window.AgentPane)
|
|
98313
98424
|
|
|
98314
98425
|
- getApp() - app info (id, title)
|
|
98315
|
-
- getState() / setState(data) - persistent JSON state, survives page reload
|
|
98426
|
+
- getState() / setState(data, { ifVersion }?) - persistent JSON state, survives page reload; getState reads the stored copy on every call (see "Shared state" below)
|
|
98427
|
+
- onStateChanged(callback) - callback({ version }) when somebody else (an agent, another tab) wrote the state; not fired for this tab's own setState
|
|
98316
98428
|
- createSession({ cwd, runtime_type, model, model_reasoning_effort, title }) - agent session owned by this app; model_reasoning_effort is the effort for its turns ("low" | "medium" | "high" | "xhigh" | "max" | "ultra", the levels the model supports), omitted = the runtime's default
|
|
98317
98429
|
- submitTurn(sessionId, prompt, { attachments }?) - send a prompt to a session; attachments (optional) are stored files (id, url or the uploadFile result) or inline Blobs / { name, type, data } sent with that turn only; the agent sees attached images (Claude and Codex)
|
|
98318
98430
|
- onTurnCompleted(callback) - callback(event, { turnId, response }) when a turn ends
|
|
@@ -98324,6 +98436,23 @@ Icons come from ONE library: Lucide (https://lucide.dev/icons, ISC).
|
|
|
98324
98436
|
- getFile(ref) - metadata of a stored file ({ id, url, path, type, size }), null when ref (id or url) names no file of this app
|
|
98325
98437
|
- fileUrl(ref) - synchronous URL to load a stored file from in this pane; any other string comes back unchanged
|
|
98326
98438
|
|
|
98439
|
+
## Shared state
|
|
98440
|
+
|
|
98441
|
+
One state instance (app + workspace) has several writers: this tab, other
|
|
98442
|
+
tabs on the same workspace, the headless runtime (agent tool calls) and
|
|
98443
|
+
agents writing over REST.
|
|
98444
|
+
- on onStateChanged, re-read with getState() and re-render
|
|
98445
|
+
- read-modify-write: apply the change to the data of a fresh getState()
|
|
98446
|
+
and save with setState(data, { ifVersion: state.version }). When
|
|
98447
|
+
somebody wrote in between, nothing is written and the promise rejects
|
|
98448
|
+
with error.code === 'conflict' (error.state = the stored state now):
|
|
98449
|
+
apply the change to error.state.data and retry with its version
|
|
98450
|
+
- never write back an old in-memory copy without ifVersion: it silently
|
|
98451
|
+
replaces whatever an agent wrote since
|
|
98452
|
+
- agents writing over REST do the same: GET /api/apps/<id>/state?workspace=<key>,
|
|
98453
|
+
then PUT { "data": ..., "ifVersion": <version from the GET> };
|
|
98454
|
+
409 = re-read and retry
|
|
98455
|
+
|
|
98327
98456
|
## Files and images
|
|
98328
98457
|
|
|
98329
98458
|
uploadFile stores images (PNG, JPEG, GIF or WebP, max 5 MB) for the app,
|
|
@@ -98464,6 +98593,15 @@ function stopAppsWatch() {
|
|
|
98464
98593
|
}
|
|
98465
98594
|
|
|
98466
98595
|
// src/apps/instances.ts
|
|
98596
|
+
var StateConflictError = class extends Error {
|
|
98597
|
+
/** The stored state the write was checked against. */
|
|
98598
|
+
current;
|
|
98599
|
+
constructor(expected, current) {
|
|
98600
|
+
super(`App state changed: the write expected version ${expected}, the stored copy is at version ${current.version}`);
|
|
98601
|
+
this.name = "StateConflictError";
|
|
98602
|
+
this.current = current;
|
|
98603
|
+
}
|
|
98604
|
+
};
|
|
98467
98605
|
function rowToState(row) {
|
|
98468
98606
|
let data = null;
|
|
98469
98607
|
try {
|
|
@@ -98471,41 +98609,63 @@ function rowToState(row) {
|
|
|
98471
98609
|
if (parsed && typeof parsed === "object") data = parsed;
|
|
98472
98610
|
} catch {
|
|
98473
98611
|
}
|
|
98474
|
-
return { pinned: row.pinned === 1, data };
|
|
98612
|
+
return { pinned: row.pinned === 1, data, version: row.version ?? 0 };
|
|
98475
98613
|
}
|
|
98476
98614
|
function writeRow(appId, workspace, state) {
|
|
98477
98615
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
98478
98616
|
getDb().prepare(
|
|
98479
|
-
`INSERT INTO app_instances (id, app_id, workspace_path, pinned, state, created_at, updated_at)
|
|
98480
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
98617
|
+
`INSERT INTO app_instances (id, app_id, workspace_path, pinned, state, version, created_at, updated_at)
|
|
98618
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
98481
98619
|
ON CONFLICT(app_id, workspace_path) DO UPDATE SET
|
|
98482
|
-
pinned = excluded.pinned, state = excluded.state,
|
|
98483
|
-
|
|
98620
|
+
pinned = excluded.pinned, state = excluded.state, version = excluded.version,
|
|
98621
|
+
updated_at = excluded.updated_at`
|
|
98622
|
+
).run(
|
|
98623
|
+
v4_default(),
|
|
98624
|
+
appId,
|
|
98625
|
+
workspace,
|
|
98626
|
+
state.pinned ? 1 : 0,
|
|
98627
|
+
JSON.stringify(state.data ?? null),
|
|
98628
|
+
state.version,
|
|
98629
|
+
now,
|
|
98630
|
+
now
|
|
98631
|
+
);
|
|
98632
|
+
}
|
|
98633
|
+
var EMPTY_STATE = { pinned: false, data: null, version: 0 };
|
|
98634
|
+
function readRow(appId, workspace) {
|
|
98635
|
+
const row = getDb().prepare("SELECT * FROM app_instances WHERE app_id = ? AND workspace_path = ?").get(appId, workspace);
|
|
98636
|
+
return row ? rowToState(row) : null;
|
|
98484
98637
|
}
|
|
98485
98638
|
function getInstanceState(appId, workspace = "") {
|
|
98486
|
-
const
|
|
98487
|
-
|
|
98488
|
-
if (row) return rowToState(row);
|
|
98639
|
+
const stored = readRow(appId, workspace);
|
|
98640
|
+
if (stored) return stored;
|
|
98489
98641
|
if (workspace === "") {
|
|
98490
98642
|
const legacyFile = path4.join(appDir(appId), "state.json");
|
|
98491
98643
|
if (fs2.existsSync(legacyFile)) {
|
|
98492
|
-
const
|
|
98644
|
+
const legacy = readState(appId);
|
|
98645
|
+
const imported = { pinned: legacy.pinned, data: legacy.data, version: 1 };
|
|
98493
98646
|
writeRow(appId, "", imported);
|
|
98494
98647
|
fs2.rmSync(legacyFile, { force: true });
|
|
98495
98648
|
return imported;
|
|
98496
98649
|
}
|
|
98497
98650
|
}
|
|
98498
|
-
return {
|
|
98651
|
+
return { ...EMPTY_STATE };
|
|
98499
98652
|
}
|
|
98500
98653
|
function updateInstanceState(appId, workspace, patch) {
|
|
98501
|
-
|
|
98502
|
-
|
|
98503
|
-
|
|
98504
|
-
|
|
98505
|
-
|
|
98506
|
-
|
|
98507
|
-
|
|
98508
|
-
|
|
98654
|
+
getInstanceState(appId, workspace);
|
|
98655
|
+
return getDb().transaction(() => {
|
|
98656
|
+
const current = readRow(appId, workspace) ?? { ...EMPTY_STATE };
|
|
98657
|
+
const { pinned, data, ifVersion } = patch;
|
|
98658
|
+
if (typeof ifVersion === "number" && ifVersion !== current.version) {
|
|
98659
|
+
throw new StateConflictError(ifVersion, current);
|
|
98660
|
+
}
|
|
98661
|
+
const next = {
|
|
98662
|
+
pinned: typeof pinned === "boolean" ? pinned : current.pinned,
|
|
98663
|
+
data: data === void 0 ? current.data : data !== null && typeof data === "object" ? data : null,
|
|
98664
|
+
version: data === void 0 ? current.version : current.version + 1
|
|
98665
|
+
};
|
|
98666
|
+
writeRow(appId, workspace, next);
|
|
98667
|
+
return next;
|
|
98668
|
+
}).immediate();
|
|
98509
98669
|
}
|
|
98510
98670
|
function deleteAppInstances(appId) {
|
|
98511
98671
|
getDb().prepare("DELETE FROM app_instances WHERE app_id = ?").run(appId);
|
|
@@ -98586,7 +98746,27 @@ var APP_TS = "app.ts";
|
|
|
98586
98746
|
var BRIDGE_DTS_FILE = "agentpane.d.ts";
|
|
98587
98747
|
var BRIDGE_DTS = `/** AgentPane bridge \u2014 typed contract for mini apps (ambient, no import). */
|
|
98588
98748
|
interface AgentPaneAppInfo { id: string; title?: string }
|
|
98589
|
-
interface AgentPaneState {
|
|
98749
|
+
interface AgentPaneState {
|
|
98750
|
+
pinned: boolean;
|
|
98751
|
+
data: Record<string, unknown> | null;
|
|
98752
|
+
/** Data writes the instance has seen (0 = never written); pass it to
|
|
98753
|
+
* setState as ifVersion. Absent on panes without versioned state. */
|
|
98754
|
+
version?: number;
|
|
98755
|
+
}
|
|
98756
|
+
interface AgentPaneSetStateOptions {
|
|
98757
|
+
/** Write only while the stored copy is still at this version (from
|
|
98758
|
+
* getState/setState); otherwise setState rejects with an
|
|
98759
|
+
* AgentPaneStateConflict and nothing is written. */
|
|
98760
|
+
ifVersion?: number;
|
|
98761
|
+
}
|
|
98762
|
+
/** setState rejection when ifVersion no longer matches: re-read, re-apply, retry. */
|
|
98763
|
+
interface AgentPaneStateConflict extends Error {
|
|
98764
|
+
code: 'conflict';
|
|
98765
|
+
/** The stored state now. */
|
|
98766
|
+
state: AgentPaneState;
|
|
98767
|
+
}
|
|
98768
|
+
/** onStateChanged payload: somebody else (agent, another tab) wrote this instance. */
|
|
98769
|
+
interface AgentPaneStateChangedPayload { version?: number }
|
|
98590
98770
|
interface AgentPaneSessionInfo { id: string; title?: string | null }
|
|
98591
98771
|
interface AgentPaneCreateSessionOptions {
|
|
98592
98772
|
title?: string;
|
|
@@ -98633,15 +98813,21 @@ interface AgentPaneSubmitTurnOptions {
|
|
|
98633
98813
|
|
|
98634
98814
|
declare const AgentPane: {
|
|
98635
98815
|
getApp(): Promise<AgentPaneAppInfo>;
|
|
98816
|
+
/** The stored state, read fresh from the pane on every call. */
|
|
98636
98817
|
getState(): Promise<AgentPaneState>;
|
|
98637
|
-
|
|
98818
|
+
/** Replace the stored data. With opts.ifVersion it rejects with an
|
|
98819
|
+
* AgentPaneStateConflict (error.code === 'conflict') instead of
|
|
98820
|
+
* overwriting a newer copy. */
|
|
98821
|
+
setState(data: Record<string, unknown> | null, opts?: AgentPaneSetStateOptions): Promise<AgentPaneState>;
|
|
98638
98822
|
createSession(opts?: AgentPaneCreateSessionOptions): Promise<AgentPaneSessionInfo>;
|
|
98639
98823
|
/** Send a prompt to a session; opts.attachments go with it (the agent sees images). */
|
|
98640
98824
|
submitTurn(sessionId: string, prompt: string, opts?: AgentPaneSubmitTurnOptions): Promise<unknown>;
|
|
98641
98825
|
onTurnCompleted(cb: (event: 'turn:completed' | 'turn:failed', payload: AgentPaneTurnPayload | null) => void): void;
|
|
98642
98826
|
onTurnDelta(cb: (payload: AgentPaneDeltaPayload) => void): void;
|
|
98643
98827
|
onToolCall(cb: (payload: AgentPaneToolCallPayload) => void): void;
|
|
98644
|
-
|
|
98828
|
+
/** Somebody else wrote this instance (an agent, another tab); not fired
|
|
98829
|
+
* for this tab's own setState. Re-read with getState. */
|
|
98830
|
+
onStateChanged(cb: (payload: AgentPaneStateChangedPayload) => void): void;
|
|
98645
98831
|
/** Fires when the live background-task set of one of the app's sessions
|
|
98646
98832
|
* changes (also empty sets, when the last task ends). */
|
|
98647
98833
|
onBackgroundTasks(cb: (payload: AgentPaneBackgroundTasksPayload | null) => void): void;
|
|
@@ -99000,9 +99186,9 @@ function getAppFile(appId, ref) {
|
|
|
99000
99186
|
if (!fileId) return null;
|
|
99001
99187
|
const file = path6.join(appFilesDir(appId), fileId);
|
|
99002
99188
|
try {
|
|
99003
|
-
const
|
|
99004
|
-
if (!
|
|
99005
|
-
return { id: fileId, url: appFileUrl(appId, fileId), path: file, type: fileType(fileId), size:
|
|
99189
|
+
const stat2 = fs3.statSync(file);
|
|
99190
|
+
if (!stat2.isFile()) return null;
|
|
99191
|
+
return { id: fileId, url: appFileUrl(appId, fileId), path: file, type: fileType(fileId), size: stat2.size };
|
|
99006
99192
|
} catch {
|
|
99007
99193
|
return null;
|
|
99008
99194
|
}
|
|
@@ -99057,9 +99243,23 @@ function getHeadlessToolHandler(appId, workspace = "") {
|
|
|
99057
99243
|
// State is scoped to the calling session's workspace instance; '' = global
|
|
99058
99244
|
// (no known workspace). The open tab keeps its own workspace-scoped view.
|
|
99059
99245
|
getState: () => Promise.resolve(getInstanceState(appId, workspace)),
|
|
99060
|
-
|
|
99061
|
-
|
|
99062
|
-
|
|
99246
|
+
// opts.ifVersion: write only on top of that version — same contract as
|
|
99247
|
+
// the iframe bridge (rejects with code 'conflict' + the stored state).
|
|
99248
|
+
setState: (data, opts) => {
|
|
99249
|
+
const ifVersion = opts?.ifVersion;
|
|
99250
|
+
let next;
|
|
99251
|
+
try {
|
|
99252
|
+
next = updateInstanceState(appId, workspace, {
|
|
99253
|
+
data,
|
|
99254
|
+
ifVersion: typeof ifVersion === "number" ? ifVersion : void 0
|
|
99255
|
+
});
|
|
99256
|
+
} catch (err) {
|
|
99257
|
+
if (err instanceof StateConflictError) {
|
|
99258
|
+
return Promise.reject(Object.assign(new Error(err.message), { code: "conflict", state: err.current }));
|
|
99259
|
+
}
|
|
99260
|
+
return Promise.reject(err);
|
|
99261
|
+
}
|
|
99262
|
+
broadcast("app:state_changed", { appId, workspace, version: next.version });
|
|
99063
99263
|
return Promise.resolve(next);
|
|
99064
99264
|
},
|
|
99065
99265
|
onToolCall: (cb) => {
|
|
@@ -99535,7 +99735,9 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
99535
99735
|
type: "object",
|
|
99536
99736
|
properties: {
|
|
99537
99737
|
pinned: { type: "boolean" },
|
|
99538
|
-
data: { type: ["object", "null"] }
|
|
99738
|
+
data: { type: ["object", "null"] },
|
|
99739
|
+
ifVersion: { type: "integer", minimum: 0 },
|
|
99740
|
+
writer: { type: "string", maxLength: 200 }
|
|
99539
99741
|
}
|
|
99540
99742
|
}
|
|
99541
99743
|
}
|
|
@@ -99544,7 +99746,23 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
99544
99746
|
const { id } = request.params;
|
|
99545
99747
|
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
99546
99748
|
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
99547
|
-
|
|
99749
|
+
const workspace = request.query?.workspace ?? "";
|
|
99750
|
+
const { pinned, data, ifVersion, writer } = request.body || {};
|
|
99751
|
+
let next;
|
|
99752
|
+
try {
|
|
99753
|
+
next = updateInstanceState(id, workspace, { pinned, data, ifVersion });
|
|
99754
|
+
} catch (err) {
|
|
99755
|
+
if (err instanceof StateConflictError) {
|
|
99756
|
+
return reply.code(409).send({ error: err.message, state: err.current });
|
|
99757
|
+
}
|
|
99758
|
+
throw err;
|
|
99759
|
+
}
|
|
99760
|
+
if (data !== void 0) {
|
|
99761
|
+
const change = { appId: id, workspace, version: next.version };
|
|
99762
|
+
if (writer) change.writer = writer;
|
|
99763
|
+
broadcast("app:state_changed", change);
|
|
99764
|
+
}
|
|
99765
|
+
return next;
|
|
99548
99766
|
}
|
|
99549
99767
|
);
|
|
99550
99768
|
fastify.post(
|
|
@@ -99655,13 +99873,13 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
99655
99873
|
|
|
99656
99874
|
// src/sidecar/transcript-locator.ts
|
|
99657
99875
|
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
99658
|
-
import { homedir as
|
|
99876
|
+
import { homedir as homedir3 } from "node:os";
|
|
99659
99877
|
import { join as join2 } from "node:path";
|
|
99660
99878
|
function claudeConfigDir() {
|
|
99661
|
-
return process.env.CLAUDE_CONFIG_DIR || join2(
|
|
99879
|
+
return process.env.CLAUDE_CONFIG_DIR || join2(homedir3(), ".claude");
|
|
99662
99880
|
}
|
|
99663
99881
|
function codexHome() {
|
|
99664
|
-
return process.env.CODEX_HOME || join2(
|
|
99882
|
+
return process.env.CODEX_HOME || join2(homedir3(), ".codex");
|
|
99665
99883
|
}
|
|
99666
99884
|
function encodeClaudeProjectDir(cwd) {
|
|
99667
99885
|
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
@@ -99784,7 +100002,7 @@ async function registerSidecarRoutes(fastify) {
|
|
|
99784
100002
|
|
|
99785
100003
|
// src/usage/usage-service.ts
|
|
99786
100004
|
import { readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
99787
|
-
import { homedir as
|
|
100005
|
+
import { homedir as homedir4 } from "node:os";
|
|
99788
100006
|
import { join as join3 } from "node:path";
|
|
99789
100007
|
|
|
99790
100008
|
// src/usage/usage-pricing.ts
|
|
@@ -99849,7 +100067,7 @@ function computeCost(modelId, usage, inputIncludesCached) {
|
|
|
99849
100067
|
|
|
99850
100068
|
// src/usage/usage-service.ts
|
|
99851
100069
|
function usageFilesDir() {
|
|
99852
|
-
return process.env.AGENT_PANE_USAGE_DIR ?? join3(
|
|
100070
|
+
return process.env.AGENT_PANE_USAGE_DIR ?? join3(homedir4(), ".repoburg", "usage");
|
|
99853
100071
|
}
|
|
99854
100072
|
function emptyBucket() {
|
|
99855
100073
|
return { calls: 0, errors: 0, input: 0, cached: 0, cacheWrite: 0, output: 0, cost: 0 };
|
|
@@ -100105,6 +100323,619 @@ async function registerUsageRoutes(fastify) {
|
|
|
100105
100323
|
);
|
|
100106
100324
|
}
|
|
100107
100325
|
|
|
100326
|
+
// src/claude/session-import.ts
|
|
100327
|
+
import { readFile as readFile2, realpath } from "node:fs/promises";
|
|
100328
|
+
import path8 from "node:path";
|
|
100329
|
+
import { getSessionInfo, listSessions } from "@anthropic-ai/claude-agent-sdk";
|
|
100330
|
+
|
|
100331
|
+
// src/claude/claude-message-mapper.ts
|
|
100332
|
+
function mapAssistantContent(content, messageId, thinkingTexts) {
|
|
100333
|
+
const descriptors = [];
|
|
100334
|
+
for (let i = 0; i < content.length; i++) {
|
|
100335
|
+
const block = content[i];
|
|
100336
|
+
switch (block.type) {
|
|
100337
|
+
case "text": {
|
|
100338
|
+
const tb = block;
|
|
100339
|
+
descriptors.push({
|
|
100340
|
+
type: "agent_message",
|
|
100341
|
+
data: { text: tb.text },
|
|
100342
|
+
externalId: messageId
|
|
100343
|
+
});
|
|
100344
|
+
break;
|
|
100345
|
+
}
|
|
100346
|
+
case "thinking": {
|
|
100347
|
+
const tb = block;
|
|
100348
|
+
let text = tb.thinking;
|
|
100349
|
+
if (!text && thinkingTexts) {
|
|
100350
|
+
text = thinkingTexts.get(i) ?? "";
|
|
100351
|
+
}
|
|
100352
|
+
descriptors.push({
|
|
100353
|
+
type: "reasoning",
|
|
100354
|
+
data: { text },
|
|
100355
|
+
externalId: messageId
|
|
100356
|
+
});
|
|
100357
|
+
break;
|
|
100358
|
+
}
|
|
100359
|
+
case "tool_use": {
|
|
100360
|
+
const tu = block;
|
|
100361
|
+
const desc = mapToolUse(tu);
|
|
100362
|
+
descriptors.push(desc);
|
|
100363
|
+
break;
|
|
100364
|
+
}
|
|
100365
|
+
case "redacted_thinking":
|
|
100366
|
+
break;
|
|
100367
|
+
default:
|
|
100368
|
+
break;
|
|
100369
|
+
}
|
|
100370
|
+
}
|
|
100371
|
+
return descriptors;
|
|
100372
|
+
}
|
|
100373
|
+
function mapToolUse(block) {
|
|
100374
|
+
const input = block.input;
|
|
100375
|
+
if (block.name === "Bash") {
|
|
100376
|
+
return {
|
|
100377
|
+
type: "command_execution",
|
|
100378
|
+
data: {
|
|
100379
|
+
command: input.command ?? "",
|
|
100380
|
+
aggregated_output: null,
|
|
100381
|
+
exit_code: null,
|
|
100382
|
+
status: "in_progress"
|
|
100383
|
+
},
|
|
100384
|
+
externalId: block.id
|
|
100385
|
+
};
|
|
100386
|
+
}
|
|
100387
|
+
if (block.name === "Edit" || block.name === "Write" || block.name === "MultiEdit" || block.name === "NotebookEdit") {
|
|
100388
|
+
return {
|
|
100389
|
+
type: "file_change",
|
|
100390
|
+
data: deriveFileChangeData(input, block.name),
|
|
100391
|
+
externalId: block.id
|
|
100392
|
+
};
|
|
100393
|
+
}
|
|
100394
|
+
return {
|
|
100395
|
+
type: "mcp_tool_call",
|
|
100396
|
+
data: {
|
|
100397
|
+
server: null,
|
|
100398
|
+
tool: block.name,
|
|
100399
|
+
arguments: input,
|
|
100400
|
+
result: null,
|
|
100401
|
+
error: null,
|
|
100402
|
+
status: "in_progress"
|
|
100403
|
+
},
|
|
100404
|
+
externalId: block.id
|
|
100405
|
+
};
|
|
100406
|
+
}
|
|
100407
|
+
function deriveFileChangeData(input, toolName) {
|
|
100408
|
+
const path11 = input.file_path ?? input.notebook_path ?? "";
|
|
100409
|
+
const kind = toolName === "Write" ? "add" : "modify";
|
|
100410
|
+
return { changes: [{ path: path11, kind }], status: "in_progress" };
|
|
100411
|
+
}
|
|
100412
|
+
function extractToolResultText(content) {
|
|
100413
|
+
if (!content) return "";
|
|
100414
|
+
if (typeof content === "string") return content;
|
|
100415
|
+
if (Array.isArray(content)) {
|
|
100416
|
+
return content.map((b) => {
|
|
100417
|
+
if (b && typeof b === "object" && b.type === "text") {
|
|
100418
|
+
return String(b.text ?? "");
|
|
100419
|
+
}
|
|
100420
|
+
return "";
|
|
100421
|
+
}).filter(Boolean).join("\n");
|
|
100422
|
+
}
|
|
100423
|
+
return "";
|
|
100424
|
+
}
|
|
100425
|
+
function applyToolResult(itemType, existingData, toolResult, toolUseResult, isError) {
|
|
100426
|
+
switch (itemType) {
|
|
100427
|
+
case "command_execution": {
|
|
100428
|
+
const text = extractToolResultText(toolResult?.content);
|
|
100429
|
+
const tur = toolUseResult && typeof toolUseResult === "object" ? toolUseResult : {};
|
|
100430
|
+
const stdout = typeof tur.stdout === "string" ? tur.stdout : "";
|
|
100431
|
+
const stderr = typeof tur.stderr === "string" ? tur.stderr : "";
|
|
100432
|
+
let aggregated = text || stdout;
|
|
100433
|
+
if (stderr) aggregated = aggregated ? `${aggregated}
|
|
100434
|
+
${stderr}` : stderr;
|
|
100435
|
+
return {
|
|
100436
|
+
...existingData,
|
|
100437
|
+
aggregated_output: aggregated,
|
|
100438
|
+
exit_code: isError ? 1 : 0,
|
|
100439
|
+
status: isError ? "failed" : "completed"
|
|
100440
|
+
};
|
|
100441
|
+
}
|
|
100442
|
+
case "mcp_tool_call": {
|
|
100443
|
+
const text = extractToolResultText(toolResult?.content);
|
|
100444
|
+
return {
|
|
100445
|
+
...existingData,
|
|
100446
|
+
result: text ? [{ type: "text", text }] : toolUseResult ?? null,
|
|
100447
|
+
error: isError ? text || "Tool error" : null,
|
|
100448
|
+
status: isError ? "failed" : "completed"
|
|
100449
|
+
};
|
|
100450
|
+
}
|
|
100451
|
+
case "file_change": {
|
|
100452
|
+
return { ...existingData, status: isError ? "failed" : "completed" };
|
|
100453
|
+
}
|
|
100454
|
+
default:
|
|
100455
|
+
return existingData;
|
|
100456
|
+
}
|
|
100457
|
+
}
|
|
100458
|
+
function mapPartialDelta(event) {
|
|
100459
|
+
const e = event;
|
|
100460
|
+
if (e.type !== "content_block_delta") return null;
|
|
100461
|
+
const delta = e.delta;
|
|
100462
|
+
if (delta.type === "text_delta") {
|
|
100463
|
+
return { kind: "text", text: delta.text, index: e.index };
|
|
100464
|
+
}
|
|
100465
|
+
if (delta.type === "thinking_delta") {
|
|
100466
|
+
return { kind: "thinking", text: delta.thinking, index: e.index };
|
|
100467
|
+
}
|
|
100468
|
+
return null;
|
|
100469
|
+
}
|
|
100470
|
+
function mapUsage(usage) {
|
|
100471
|
+
return {
|
|
100472
|
+
input_tokens: usage.input_tokens,
|
|
100473
|
+
cached_input_tokens: usage.cache_read_input_tokens ?? 0,
|
|
100474
|
+
cache_write_input_tokens: usage.cache_creation_input_tokens ?? 0,
|
|
100475
|
+
output_tokens: usage.output_tokens,
|
|
100476
|
+
reasoning_output_tokens: 0
|
|
100477
|
+
// Claude SDK does not provide this separately.
|
|
100478
|
+
};
|
|
100479
|
+
}
|
|
100480
|
+
|
|
100481
|
+
// src/claude/transcript-history.ts
|
|
100482
|
+
var MESSAGE_TYPES = /* @__PURE__ */ new Set(["user", "assistant"]);
|
|
100483
|
+
function parseTranscript(text) {
|
|
100484
|
+
const entries = [];
|
|
100485
|
+
for (const line of text.split("\n")) {
|
|
100486
|
+
if (!line.trim()) continue;
|
|
100487
|
+
let raw;
|
|
100488
|
+
try {
|
|
100489
|
+
raw = JSON.parse(line);
|
|
100490
|
+
} catch {
|
|
100491
|
+
continue;
|
|
100492
|
+
}
|
|
100493
|
+
if (typeof raw.uuid !== "string" || typeof raw.type !== "string") continue;
|
|
100494
|
+
const link = {
|
|
100495
|
+
type: raw.type,
|
|
100496
|
+
uuid: raw.uuid,
|
|
100497
|
+
parentUuid: typeof raw.parentUuid === "string" ? raw.parentUuid : null,
|
|
100498
|
+
logicalParentUuid: typeof raw.logicalParentUuid === "string" ? raw.logicalParentUuid : null,
|
|
100499
|
+
isSidechain: raw.isSidechain === true,
|
|
100500
|
+
timestamp: typeof raw.timestamp === "string" ? raw.timestamp : void 0
|
|
100501
|
+
};
|
|
100502
|
+
if (raw.type === "system") {
|
|
100503
|
+
link.subtype = typeof raw.subtype === "string" ? raw.subtype : void 0;
|
|
100504
|
+
if (link.subtype === "compact_boundary") {
|
|
100505
|
+
link.compactMetadata = raw.compactMetadata ?? null;
|
|
100506
|
+
}
|
|
100507
|
+
} else if (MESSAGE_TYPES.has(raw.type)) {
|
|
100508
|
+
link.isMeta = raw.isMeta === true;
|
|
100509
|
+
link.isCompactSummary = raw.isCompactSummary === true;
|
|
100510
|
+
link.isApiErrorMessage = raw.isApiErrorMessage === true;
|
|
100511
|
+
link.cwd = typeof raw.cwd === "string" ? raw.cwd : void 0;
|
|
100512
|
+
link.origin = raw.origin ?? null;
|
|
100513
|
+
link.message = raw.message ?? null;
|
|
100514
|
+
link.toolUseResult = raw.toolUseResult;
|
|
100515
|
+
}
|
|
100516
|
+
entries.push(link);
|
|
100517
|
+
}
|
|
100518
|
+
return entries;
|
|
100519
|
+
}
|
|
100520
|
+
function mainChain(entries) {
|
|
100521
|
+
const byUuid = /* @__PURE__ */ new Map();
|
|
100522
|
+
for (const entry of entries) byUuid.set(entry.uuid, entry);
|
|
100523
|
+
let leaf;
|
|
100524
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
100525
|
+
const entry = entries[i];
|
|
100526
|
+
if (MESSAGE_TYPES.has(entry.type) && !entry.isSidechain) {
|
|
100527
|
+
leaf = entry;
|
|
100528
|
+
break;
|
|
100529
|
+
}
|
|
100530
|
+
}
|
|
100531
|
+
const chain = [];
|
|
100532
|
+
const seen = /* @__PURE__ */ new Set();
|
|
100533
|
+
let current = leaf;
|
|
100534
|
+
while (current && !seen.has(current.uuid)) {
|
|
100535
|
+
seen.add(current.uuid);
|
|
100536
|
+
chain.push(current);
|
|
100537
|
+
const parent = current.parentUuid ?? current.logicalParentUuid ?? null;
|
|
100538
|
+
current = parent ? byUuid.get(parent) : void 0;
|
|
100539
|
+
}
|
|
100540
|
+
return chain.reverse();
|
|
100541
|
+
}
|
|
100542
|
+
var INJECTED_BLOCK = /^\s*<(system-reminder|ide_opened_file|ide_selection|ide_diagnostics)>/;
|
|
100543
|
+
function tagValue(text, tag) {
|
|
100544
|
+
const match = new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`).exec(text);
|
|
100545
|
+
return match ? match[1] : null;
|
|
100546
|
+
}
|
|
100547
|
+
function classifyUserInput(entry) {
|
|
100548
|
+
if (entry.origin?.kind && entry.origin.kind !== "human") return { kind: "ignore" };
|
|
100549
|
+
const content = entry.message?.content;
|
|
100550
|
+
let text = "";
|
|
100551
|
+
let images = 0;
|
|
100552
|
+
if (typeof content === "string") {
|
|
100553
|
+
text = content;
|
|
100554
|
+
} else if (Array.isArray(content)) {
|
|
100555
|
+
const parts = [];
|
|
100556
|
+
for (const block of content) {
|
|
100557
|
+
if (!block || typeof block !== "object") continue;
|
|
100558
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
100559
|
+
if (!INJECTED_BLOCK.test(block.text)) parts.push(block.text);
|
|
100560
|
+
} else if (block.type === "image") {
|
|
100561
|
+
images++;
|
|
100562
|
+
}
|
|
100563
|
+
}
|
|
100564
|
+
text = parts.join("\n");
|
|
100565
|
+
}
|
|
100566
|
+
const trimmed = text.trim();
|
|
100567
|
+
if (trimmed.startsWith("[Request interrupted by user")) return { kind: "interrupt" };
|
|
100568
|
+
const commandName = tagValue(trimmed, "command-name");
|
|
100569
|
+
if (commandName !== null) {
|
|
100570
|
+
const args = (tagValue(trimmed, "command-args") ?? "").trim();
|
|
100571
|
+
const name = commandName.trim();
|
|
100572
|
+
return { kind: "command", text: args ? `${name} ${args}` : name };
|
|
100573
|
+
}
|
|
100574
|
+
const bashInput = tagValue(trimmed, "bash-input");
|
|
100575
|
+
if (bashInput !== null) return { kind: "bash", command: bashInput };
|
|
100576
|
+
const stdout = tagValue(trimmed, "bash-stdout");
|
|
100577
|
+
const stderr = tagValue(trimmed, "bash-stderr");
|
|
100578
|
+
if (stdout !== null || stderr !== null) return { kind: "bash-output", stdout: stdout ?? "", stderr: stderr ?? "" };
|
|
100579
|
+
if (/^<(local-command-stdout|local-command-stderr|local-command-caveat|task-notification|system-reminder)>/.test(
|
|
100580
|
+
trimmed
|
|
100581
|
+
)) {
|
|
100582
|
+
return { kind: "ignore" };
|
|
100583
|
+
}
|
|
100584
|
+
if (!trimmed && images === 0) return { kind: "ignore" };
|
|
100585
|
+
const imageNote = images > 0 && !trimmed.includes("[Image") ? Array(images).fill("[Image]").join(" ") : "";
|
|
100586
|
+
return { kind: "prompt", text: [trimmed, imageNote].filter(Boolean).join("\n") };
|
|
100587
|
+
}
|
|
100588
|
+
var TOOL_ITEM_TYPES = /* @__PURE__ */ new Set(["command_execution", "file_change", "mcp_tool_call"]);
|
|
100589
|
+
function syntheticText(content) {
|
|
100590
|
+
if (typeof content === "string") return content;
|
|
100591
|
+
if (!Array.isArray(content)) return "";
|
|
100592
|
+
return content.map(
|
|
100593
|
+
(b) => b && typeof b === "object" && b.type === "text" ? String(b.text ?? "") : ""
|
|
100594
|
+
).join("").trim();
|
|
100595
|
+
}
|
|
100596
|
+
function buildTurns(chain) {
|
|
100597
|
+
const turns = [];
|
|
100598
|
+
let current = null;
|
|
100599
|
+
let lastMs = 0;
|
|
100600
|
+
const stamp = (entry) => {
|
|
100601
|
+
const parsed = entry.timestamp ? Date.parse(entry.timestamp) : NaN;
|
|
100602
|
+
lastMs = Number.isFinite(parsed) && parsed > lastMs ? parsed : lastMs + 1;
|
|
100603
|
+
return new Date(lastMs).toISOString();
|
|
100604
|
+
};
|
|
100605
|
+
const openTurn = (prompt, entry, fromCommand = false) => {
|
|
100606
|
+
const at = stamp(entry);
|
|
100607
|
+
const turn = {
|
|
100608
|
+
userPrompt: prompt,
|
|
100609
|
+
status: "completed",
|
|
100610
|
+
agentResponse: null,
|
|
100611
|
+
thoughts: null,
|
|
100612
|
+
externalTurnId: null,
|
|
100613
|
+
createdAt: at,
|
|
100614
|
+
updatedAt: at,
|
|
100615
|
+
items: [],
|
|
100616
|
+
fromCommand,
|
|
100617
|
+
toolItems: /* @__PURE__ */ new Map()
|
|
100618
|
+
};
|
|
100619
|
+
turns.push(turn);
|
|
100620
|
+
return turn;
|
|
100621
|
+
};
|
|
100622
|
+
const addItem = (turn, entry, item) => {
|
|
100623
|
+
const full = { ...item, createdAt: stamp(entry) };
|
|
100624
|
+
turn.items.push(full);
|
|
100625
|
+
turn.updatedAt = full.createdAt;
|
|
100626
|
+
return full;
|
|
100627
|
+
};
|
|
100628
|
+
for (const entry of chain) {
|
|
100629
|
+
if (entry.type === "system") {
|
|
100630
|
+
if (entry.subtype === "compact_boundary" && current) {
|
|
100631
|
+
const meta = entry.compactMetadata ?? {};
|
|
100632
|
+
addItem(current, entry, {
|
|
100633
|
+
type: "context_compaction",
|
|
100634
|
+
externalId: `compact-${entry.uuid}`,
|
|
100635
|
+
data: { trigger: meta.trigger ?? "auto", pre_tokens: meta.preTokens ?? 0, post_tokens: meta.postTokens ?? 0 },
|
|
100636
|
+
status: "completed"
|
|
100637
|
+
});
|
|
100638
|
+
}
|
|
100639
|
+
continue;
|
|
100640
|
+
}
|
|
100641
|
+
if (entry.type === "user") {
|
|
100642
|
+
if (entry.isMeta || entry.isCompactSummary) continue;
|
|
100643
|
+
const content = entry.message?.content;
|
|
100644
|
+
if (Array.isArray(content) && content.some((b) => b?.type === "tool_result")) {
|
|
100645
|
+
if (!current) continue;
|
|
100646
|
+
for (const block of content) {
|
|
100647
|
+
const b = block;
|
|
100648
|
+
if (b?.type !== "tool_result" || !b.tool_use_id) continue;
|
|
100649
|
+
const item = current.toolItems.get(b.tool_use_id);
|
|
100650
|
+
if (!item) continue;
|
|
100651
|
+
const isError = !!b.is_error;
|
|
100652
|
+
item.data = applyToolResult(item.type, item.data, b, entry.toolUseResult, isError);
|
|
100653
|
+
item.status = isError ? "failed" : "completed";
|
|
100654
|
+
}
|
|
100655
|
+
continue;
|
|
100656
|
+
}
|
|
100657
|
+
const input = classifyUserInput(entry);
|
|
100658
|
+
switch (input.kind) {
|
|
100659
|
+
case "prompt":
|
|
100660
|
+
current = openTurn(input.text, entry);
|
|
100661
|
+
break;
|
|
100662
|
+
case "command":
|
|
100663
|
+
current = openTurn(input.text, entry, true);
|
|
100664
|
+
break;
|
|
100665
|
+
case "bash": {
|
|
100666
|
+
const turn = openTurn(`! ${input.command}`, entry);
|
|
100667
|
+
current = turn;
|
|
100668
|
+
const item = addItem(turn, entry, {
|
|
100669
|
+
type: "command_execution",
|
|
100670
|
+
externalId: `bash-${entry.uuid}`,
|
|
100671
|
+
data: { command: input.command, aggregated_output: null, exit_code: null, status: "in_progress" },
|
|
100672
|
+
status: "in_progress"
|
|
100673
|
+
});
|
|
100674
|
+
turn.toolItems.set(item.externalId, item);
|
|
100675
|
+
break;
|
|
100676
|
+
}
|
|
100677
|
+
case "bash-output": {
|
|
100678
|
+
const item = current?.items.find(
|
|
100679
|
+
(i) => i.type === "command_execution" && i.status === "in_progress" && i.externalId.startsWith("bash-")
|
|
100680
|
+
);
|
|
100681
|
+
if (item) {
|
|
100682
|
+
const failed = !!input.stderr.trim() && !input.stdout.trim();
|
|
100683
|
+
const output = [input.stdout, input.stderr].filter((s) => s.trim()).join("\n");
|
|
100684
|
+
item.data = {
|
|
100685
|
+
...item.data,
|
|
100686
|
+
aggregated_output: output,
|
|
100687
|
+
exit_code: failed ? 1 : 0,
|
|
100688
|
+
status: failed ? "failed" : "completed"
|
|
100689
|
+
};
|
|
100690
|
+
item.status = failed ? "failed" : "completed";
|
|
100691
|
+
}
|
|
100692
|
+
break;
|
|
100693
|
+
}
|
|
100694
|
+
case "interrupt":
|
|
100695
|
+
if (current) current.status = "aborted";
|
|
100696
|
+
break;
|
|
100697
|
+
case "ignore":
|
|
100698
|
+
break;
|
|
100699
|
+
}
|
|
100700
|
+
continue;
|
|
100701
|
+
}
|
|
100702
|
+
if (entry.type === "assistant") {
|
|
100703
|
+
const message = entry.message;
|
|
100704
|
+
if (!message) continue;
|
|
100705
|
+
if (!current) current = openTurn("", entry);
|
|
100706
|
+
const turn = current;
|
|
100707
|
+
if (entry.isApiErrorMessage || message.model === "<synthetic>") {
|
|
100708
|
+
const text = syntheticText(message.content);
|
|
100709
|
+
if (entry.isApiErrorMessage && text) {
|
|
100710
|
+
addItem(turn, entry, {
|
|
100711
|
+
type: "error",
|
|
100712
|
+
externalId: `api-error-${entry.uuid}`,
|
|
100713
|
+
data: { message: text, error: "api_error" },
|
|
100714
|
+
status: "completed"
|
|
100715
|
+
});
|
|
100716
|
+
}
|
|
100717
|
+
continue;
|
|
100718
|
+
}
|
|
100719
|
+
const content = Array.isArray(message.content) ? message.content : [];
|
|
100720
|
+
for (const desc of mapAssistantContent(content, entry.uuid)) {
|
|
100721
|
+
if (desc.type === "reasoning" && !String(desc.data.text ?? "").trim()) continue;
|
|
100722
|
+
if (desc.type === "agent_message") desc.externalId = message.id ?? entry.uuid;
|
|
100723
|
+
const isTool = TOOL_ITEM_TYPES.has(desc.type);
|
|
100724
|
+
const item = addItem(turn, entry, {
|
|
100725
|
+
type: desc.type,
|
|
100726
|
+
externalId: desc.externalId,
|
|
100727
|
+
data: desc.data,
|
|
100728
|
+
status: isTool ? "in_progress" : "completed"
|
|
100729
|
+
});
|
|
100730
|
+
if (isTool) turn.toolItems.set(desc.externalId, item);
|
|
100731
|
+
if (desc.type === "agent_message") turn.agentResponse = String(desc.data.text ?? "");
|
|
100732
|
+
if (desc.type === "reasoning") turn.thoughts = String(desc.data.text ?? "");
|
|
100733
|
+
}
|
|
100734
|
+
turn.externalTurnId = entry.uuid;
|
|
100735
|
+
turn.updatedAt = stamp(entry);
|
|
100736
|
+
}
|
|
100737
|
+
}
|
|
100738
|
+
return turns.filter((turn) => !(turn.fromCommand && turn.items.length === 0)).map(({ fromCommand: _fromCommand, toolItems: _toolItems, ...turn }) => ({
|
|
100739
|
+
...turn,
|
|
100740
|
+
// A tool that never got its result (interrupted, crashed) did not finish.
|
|
100741
|
+
items: turn.items.map(
|
|
100742
|
+
(item) => item.status === "in_progress" ? { ...item, status: "failed", data: { ...item.data, status: "failed" } } : item
|
|
100743
|
+
)
|
|
100744
|
+
}));
|
|
100745
|
+
}
|
|
100746
|
+
function transcriptToTurns(text) {
|
|
100747
|
+
return buildTurns(mainChain(parseTranscript(text)));
|
|
100748
|
+
}
|
|
100749
|
+
|
|
100750
|
+
// src/claude/session-import.ts
|
|
100751
|
+
var ClaudeImportError = class extends Error {
|
|
100752
|
+
status;
|
|
100753
|
+
paneSessionId;
|
|
100754
|
+
constructor(status, message, paneSessionId = null) {
|
|
100755
|
+
super(message);
|
|
100756
|
+
this.name = "ClaudeImportError";
|
|
100757
|
+
this.status = status;
|
|
100758
|
+
this.paneSessionId = paneSessionId;
|
|
100759
|
+
}
|
|
100760
|
+
};
|
|
100761
|
+
var RECENT_MS = 10 * 6e4;
|
|
100762
|
+
var CHECK_EMPTY_BELOW_BYTES = 64 * 1024;
|
|
100763
|
+
var SESSION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
100764
|
+
var TITLE_MAX = 100;
|
|
100765
|
+
async function realDir(dir) {
|
|
100766
|
+
try {
|
|
100767
|
+
return await realpath(dir);
|
|
100768
|
+
} catch {
|
|
100769
|
+
return null;
|
|
100770
|
+
}
|
|
100771
|
+
}
|
|
100772
|
+
async function sameDir(a, realB) {
|
|
100773
|
+
const realA = await realDir(a) ?? path8.resolve(a);
|
|
100774
|
+
return realA === realB;
|
|
100775
|
+
}
|
|
100776
|
+
function knownClaudeSessionIds(db2) {
|
|
100777
|
+
const rows = db2.prepare(
|
|
100778
|
+
`SELECT external_thread_id AS id FROM sessions WHERE external_thread_id IS NOT NULL
|
|
100779
|
+
UNION SELECT pre_rewind_thread_id FROM sessions WHERE pre_rewind_thread_id IS NOT NULL
|
|
100780
|
+
UNION SELECT import_source_id FROM sessions WHERE import_source_id IS NOT NULL
|
|
100781
|
+
UNION SELECT external_thread_id FROM discussion_threads WHERE external_thread_id IS NOT NULL`
|
|
100782
|
+
).all();
|
|
100783
|
+
return new Set(rows.map((row) => row.id));
|
|
100784
|
+
}
|
|
100785
|
+
function paneSessionHolding(db2, claudeSessionId) {
|
|
100786
|
+
const row = db2.prepare(
|
|
100787
|
+
`SELECT id FROM sessions WHERE import_source_id = ? OR external_thread_id = ? OR pre_rewind_thread_id = ?
|
|
100788
|
+
UNION SELECT session_id FROM discussion_threads WHERE external_thread_id = ?
|
|
100789
|
+
LIMIT 1`
|
|
100790
|
+
).get(claudeSessionId, claudeSessionId, claudeSessionId, claudeSessionId);
|
|
100791
|
+
return row?.id ?? null;
|
|
100792
|
+
}
|
|
100793
|
+
function titleOf(info) {
|
|
100794
|
+
const raw = (info.customTitle || info.summary || info.firstPrompt || "").trim();
|
|
100795
|
+
const firstLine = raw.split("\n")[0].trim();
|
|
100796
|
+
return firstLine.length > TITLE_MAX ? `${firstLine.slice(0, TITLE_MAX - 1)}\u2026` : firstLine;
|
|
100797
|
+
}
|
|
100798
|
+
async function readTranscript(info) {
|
|
100799
|
+
const file = locateTranscript({ runtime_type: "claude", external_thread_id: info.sessionId, cwd: info.cwd ?? null });
|
|
100800
|
+
if (!file) return null;
|
|
100801
|
+
try {
|
|
100802
|
+
return await readFile2(file, "utf8");
|
|
100803
|
+
} catch {
|
|
100804
|
+
return null;
|
|
100805
|
+
}
|
|
100806
|
+
}
|
|
100807
|
+
async function listImportableClaudeSessions(db2, workspacePath, now = Date.now()) {
|
|
100808
|
+
const dir = await realDir(workspacePath);
|
|
100809
|
+
if (!dir) return [];
|
|
100810
|
+
const known = knownClaudeSessionIds(db2);
|
|
100811
|
+
const infos = await listSessions({ dir, includeProgrammatic: false, includeWorktrees: false });
|
|
100812
|
+
const sessions = [];
|
|
100813
|
+
for (const info of infos) {
|
|
100814
|
+
if (known.has(info.sessionId) || !info.cwd) continue;
|
|
100815
|
+
if (!await sameDir(info.cwd, dir)) continue;
|
|
100816
|
+
if ((info.fileSize ?? 0) < CHECK_EMPTY_BELOW_BYTES) {
|
|
100817
|
+
const text = await readTranscript(info);
|
|
100818
|
+
if (!text || transcriptToTurns(text).length === 0) continue;
|
|
100819
|
+
}
|
|
100820
|
+
sessions.push({
|
|
100821
|
+
session_id: info.sessionId,
|
|
100822
|
+
title: titleOf(info) || "Untitled session",
|
|
100823
|
+
cwd: info.cwd,
|
|
100824
|
+
git_branch: info.gitBranch ?? null,
|
|
100825
|
+
created_at: info.createdAt ? new Date(info.createdAt).toISOString() : null,
|
|
100826
|
+
last_modified: new Date(info.lastModified).toISOString(),
|
|
100827
|
+
recently_active: now - info.lastModified < RECENT_MS
|
|
100828
|
+
});
|
|
100829
|
+
}
|
|
100830
|
+
return sessions.sort((a, b) => a.last_modified < b.last_modified ? 1 : -1);
|
|
100831
|
+
}
|
|
100832
|
+
async function importClaudeSession(db2, claudeSessionId, workspacePath) {
|
|
100833
|
+
if (!SESSION_ID.test(claudeSessionId)) throw new ClaudeImportError(400, "Not a Claude Code session id");
|
|
100834
|
+
const holder = paneSessionHolding(db2, claudeSessionId);
|
|
100835
|
+
if (holder) throw new ClaudeImportError(409, "This session is already in the pane", holder);
|
|
100836
|
+
const dir = workspacePath ? await realDir(workspacePath) : null;
|
|
100837
|
+
const info = (dir ? await getSessionInfo(claudeSessionId, { dir }) : void 0) ?? await getSessionInfo(claudeSessionId);
|
|
100838
|
+
if (!info) throw new ClaudeImportError(404, "Claude Code session not found");
|
|
100839
|
+
const text = await readTranscript(info);
|
|
100840
|
+
if (text === null) throw new ClaudeImportError(404, "The session transcript could not be read");
|
|
100841
|
+
const turns = transcriptToTurns(text);
|
|
100842
|
+
if (turns.length === 0) throw new ClaudeImportError(422, "This session has no conversation to import");
|
|
100843
|
+
const cwd = workspacePath && dir && info.cwd && await sameDir(info.cwd, dir) ? workspacePath : info.cwd ?? null;
|
|
100844
|
+
const sessionId = v4_default();
|
|
100845
|
+
const createdAt = turns[0].createdAt;
|
|
100846
|
+
const updatedAt = turns[turns.length - 1].updatedAt;
|
|
100847
|
+
const insertSession = db2.prepare(
|
|
100848
|
+
`INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status,
|
|
100849
|
+
is_running, lifecycle, sort_order, user_touched, import_source_id, created_at, updated_at)
|
|
100850
|
+
VALUES (?, ?, 'claude', NULL, NULL, ?, ?, 'active', 0, 'working', ?, 1, ?, ?, ?)`
|
|
100851
|
+
);
|
|
100852
|
+
const insertTurn = db2.prepare(
|
|
100853
|
+
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status,
|
|
100854
|
+
error, created_at, updated_at)
|
|
100855
|
+
VALUES (?, ?, ?, ?, ?, NULL, ?, ?, NULL, ?, ?)`
|
|
100856
|
+
);
|
|
100857
|
+
const insertItem2 = db2.prepare(
|
|
100858
|
+
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
100859
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
|
|
100860
|
+
);
|
|
100861
|
+
db2.transaction(() => {
|
|
100862
|
+
const raced = paneSessionHolding(db2, claudeSessionId);
|
|
100863
|
+
if (raced) throw new ClaudeImportError(409, "This session is already in the pane", raced);
|
|
100864
|
+
const { m } = db2.prepare("SELECT COALESCE(MAX(sort_order), 0) AS m FROM sessions WHERE cwd = ?").get(cwd);
|
|
100865
|
+
insertSession.run(
|
|
100866
|
+
sessionId,
|
|
100867
|
+
titleOf(info) || null,
|
|
100868
|
+
cwd,
|
|
100869
|
+
claudeSessionId,
|
|
100870
|
+
m + 1,
|
|
100871
|
+
claudeSessionId,
|
|
100872
|
+
createdAt,
|
|
100873
|
+
updatedAt
|
|
100874
|
+
);
|
|
100875
|
+
for (const turn of turns) {
|
|
100876
|
+
const turnId = v4_default();
|
|
100877
|
+
insertTurn.run(
|
|
100878
|
+
turnId,
|
|
100879
|
+
sessionId,
|
|
100880
|
+
turn.userPrompt,
|
|
100881
|
+
turn.agentResponse,
|
|
100882
|
+
turn.thoughts,
|
|
100883
|
+
turn.externalTurnId,
|
|
100884
|
+
turn.status,
|
|
100885
|
+
turn.createdAt,
|
|
100886
|
+
turn.updatedAt
|
|
100887
|
+
);
|
|
100888
|
+
for (const item of turn.items) {
|
|
100889
|
+
insertItem2.run(
|
|
100890
|
+
v4_default(),
|
|
100891
|
+
turnId,
|
|
100892
|
+
item.externalId,
|
|
100893
|
+
item.type,
|
|
100894
|
+
JSON.stringify(trimItemData(item.data)),
|
|
100895
|
+
item.status,
|
|
100896
|
+
item.createdAt,
|
|
100897
|
+
item.createdAt
|
|
100898
|
+
);
|
|
100899
|
+
}
|
|
100900
|
+
}
|
|
100901
|
+
})();
|
|
100902
|
+
return db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
|
|
100903
|
+
}
|
|
100904
|
+
|
|
100905
|
+
// src/routes/claude-sessions.ts
|
|
100906
|
+
async function registerClaudeSessionRoutes(fastify) {
|
|
100907
|
+
fastify.get("/api/claude-sessions", async (request, reply) => {
|
|
100908
|
+
const workspace = request.query.workspace?.trim();
|
|
100909
|
+
if (!workspace) return reply.code(400).send({ error: "workspace is required" });
|
|
100910
|
+
try {
|
|
100911
|
+
return { sessions: await listImportableClaudeSessions(getDb(), workspace) };
|
|
100912
|
+
} catch (err) {
|
|
100913
|
+
return reply.code(500).send({ error: `Could not list Claude Code sessions: ${err.message}` });
|
|
100914
|
+
}
|
|
100915
|
+
});
|
|
100916
|
+
fastify.post(
|
|
100917
|
+
"/api/claude-sessions/:id/import",
|
|
100918
|
+
{
|
|
100919
|
+
schema: {
|
|
100920
|
+
body: {
|
|
100921
|
+
type: ["object", "null"],
|
|
100922
|
+
properties: { workspace: { type: ["string", "null"] } }
|
|
100923
|
+
}
|
|
100924
|
+
}
|
|
100925
|
+
},
|
|
100926
|
+
async (request, reply) => {
|
|
100927
|
+
try {
|
|
100928
|
+
return await importClaudeSession(getDb(), request.params.id, request.body?.workspace?.trim() || null);
|
|
100929
|
+
} catch (err) {
|
|
100930
|
+
if (err instanceof ClaudeImportError) {
|
|
100931
|
+
return reply.code(err.status).send({ error: err.message, session_id: err.paneSessionId });
|
|
100932
|
+
}
|
|
100933
|
+
return reply.code(500).send({ error: `Import failed: ${err.message}` });
|
|
100934
|
+
}
|
|
100935
|
+
}
|
|
100936
|
+
);
|
|
100937
|
+
}
|
|
100938
|
+
|
|
100108
100939
|
// src/codex/item-mapper.ts
|
|
100109
100940
|
function mapItemData(item) {
|
|
100110
100941
|
switch (item.type) {
|
|
@@ -100175,18 +101006,18 @@ function mapTokenUsage(data) {
|
|
|
100175
101006
|
|
|
100176
101007
|
// src/apps/register-mcp.ts
|
|
100177
101008
|
import fs6 from "node:fs";
|
|
100178
|
-
import
|
|
101009
|
+
import path9 from "node:path";
|
|
100179
101010
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
100180
101011
|
var MCP_SERVER_NAME = "agentpane-miniapps";
|
|
100181
101012
|
function panePublicUrl() {
|
|
100182
101013
|
return (process.env.AGENT_PANE_PUBLIC_URL || process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
|
|
100183
101014
|
}
|
|
100184
101015
|
function stdioScriptPath() {
|
|
100185
|
-
const here =
|
|
101016
|
+
const here = path9.dirname(fileURLToPath2(import.meta.url));
|
|
100186
101017
|
const candidates = [
|
|
100187
|
-
|
|
101018
|
+
path9.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
|
|
100188
101019
|
// src/apps/ → backend/scripts
|
|
100189
|
-
|
|
101020
|
+
path9.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
|
|
100190
101021
|
// dist bundle → backend/scripts
|
|
100191
101022
|
];
|
|
100192
101023
|
for (const candidate of candidates) {
|
|
@@ -100873,156 +101704,6 @@ import { readFileSync as readFileSync3 } from "fs";
|
|
|
100873
101704
|
import { tmpdir } from "os";
|
|
100874
101705
|
import { join as join4 } from "path";
|
|
100875
101706
|
|
|
100876
|
-
// src/claude/claude-message-mapper.ts
|
|
100877
|
-
function mapAssistantContent(content, messageId, thinkingTexts) {
|
|
100878
|
-
const descriptors = [];
|
|
100879
|
-
for (let i = 0; i < content.length; i++) {
|
|
100880
|
-
const block = content[i];
|
|
100881
|
-
switch (block.type) {
|
|
100882
|
-
case "text": {
|
|
100883
|
-
const tb = block;
|
|
100884
|
-
descriptors.push({
|
|
100885
|
-
type: "agent_message",
|
|
100886
|
-
data: { text: tb.text },
|
|
100887
|
-
externalId: messageId
|
|
100888
|
-
});
|
|
100889
|
-
break;
|
|
100890
|
-
}
|
|
100891
|
-
case "thinking": {
|
|
100892
|
-
const tb = block;
|
|
100893
|
-
let text = tb.thinking;
|
|
100894
|
-
if (!text && thinkingTexts) {
|
|
100895
|
-
text = thinkingTexts.get(i) ?? "";
|
|
100896
|
-
}
|
|
100897
|
-
descriptors.push({
|
|
100898
|
-
type: "reasoning",
|
|
100899
|
-
data: { text },
|
|
100900
|
-
externalId: messageId
|
|
100901
|
-
});
|
|
100902
|
-
break;
|
|
100903
|
-
}
|
|
100904
|
-
case "tool_use": {
|
|
100905
|
-
const tu = block;
|
|
100906
|
-
const desc = mapToolUse(tu);
|
|
100907
|
-
descriptors.push(desc);
|
|
100908
|
-
break;
|
|
100909
|
-
}
|
|
100910
|
-
case "redacted_thinking":
|
|
100911
|
-
break;
|
|
100912
|
-
default:
|
|
100913
|
-
break;
|
|
100914
|
-
}
|
|
100915
|
-
}
|
|
100916
|
-
return descriptors;
|
|
100917
|
-
}
|
|
100918
|
-
function mapToolUse(block) {
|
|
100919
|
-
const input = block.input;
|
|
100920
|
-
if (block.name === "Bash") {
|
|
100921
|
-
return {
|
|
100922
|
-
type: "command_execution",
|
|
100923
|
-
data: {
|
|
100924
|
-
command: input.command ?? "",
|
|
100925
|
-
aggregated_output: null,
|
|
100926
|
-
exit_code: null,
|
|
100927
|
-
status: "in_progress"
|
|
100928
|
-
},
|
|
100929
|
-
externalId: block.id
|
|
100930
|
-
};
|
|
100931
|
-
}
|
|
100932
|
-
if (block.name === "Edit" || block.name === "Write" || block.name === "MultiEdit" || block.name === "NotebookEdit") {
|
|
100933
|
-
return {
|
|
100934
|
-
type: "file_change",
|
|
100935
|
-
data: deriveFileChangeData(input, block.name),
|
|
100936
|
-
externalId: block.id
|
|
100937
|
-
};
|
|
100938
|
-
}
|
|
100939
|
-
return {
|
|
100940
|
-
type: "mcp_tool_call",
|
|
100941
|
-
data: {
|
|
100942
|
-
server: null,
|
|
100943
|
-
tool: block.name,
|
|
100944
|
-
arguments: input,
|
|
100945
|
-
result: null,
|
|
100946
|
-
error: null,
|
|
100947
|
-
status: "in_progress"
|
|
100948
|
-
},
|
|
100949
|
-
externalId: block.id
|
|
100950
|
-
};
|
|
100951
|
-
}
|
|
100952
|
-
function deriveFileChangeData(input, toolName) {
|
|
100953
|
-
const path10 = input.file_path ?? input.notebook_path ?? "";
|
|
100954
|
-
const kind = toolName === "Write" ? "add" : "modify";
|
|
100955
|
-
return { changes: [{ path: path10, kind }], status: "in_progress" };
|
|
100956
|
-
}
|
|
100957
|
-
function extractToolResultText(content) {
|
|
100958
|
-
if (!content) return "";
|
|
100959
|
-
if (typeof content === "string") return content;
|
|
100960
|
-
if (Array.isArray(content)) {
|
|
100961
|
-
return content.map((b) => {
|
|
100962
|
-
if (b && typeof b === "object" && b.type === "text") {
|
|
100963
|
-
return String(b.text ?? "");
|
|
100964
|
-
}
|
|
100965
|
-
return "";
|
|
100966
|
-
}).filter(Boolean).join("\n");
|
|
100967
|
-
}
|
|
100968
|
-
return "";
|
|
100969
|
-
}
|
|
100970
|
-
function applyToolResult(itemType, existingData, toolResult, toolUseResult, isError) {
|
|
100971
|
-
switch (itemType) {
|
|
100972
|
-
case "command_execution": {
|
|
100973
|
-
const text = extractToolResultText(toolResult?.content);
|
|
100974
|
-
const tur = toolUseResult && typeof toolUseResult === "object" ? toolUseResult : {};
|
|
100975
|
-
const stdout = typeof tur.stdout === "string" ? tur.stdout : "";
|
|
100976
|
-
const stderr = typeof tur.stderr === "string" ? tur.stderr : "";
|
|
100977
|
-
let aggregated = text || stdout;
|
|
100978
|
-
if (stderr) aggregated = aggregated ? `${aggregated}
|
|
100979
|
-
${stderr}` : stderr;
|
|
100980
|
-
return {
|
|
100981
|
-
...existingData,
|
|
100982
|
-
aggregated_output: aggregated,
|
|
100983
|
-
exit_code: isError ? 1 : 0,
|
|
100984
|
-
status: isError ? "failed" : "completed"
|
|
100985
|
-
};
|
|
100986
|
-
}
|
|
100987
|
-
case "mcp_tool_call": {
|
|
100988
|
-
const text = extractToolResultText(toolResult?.content);
|
|
100989
|
-
return {
|
|
100990
|
-
...existingData,
|
|
100991
|
-
result: text ? [{ type: "text", text }] : toolUseResult ?? null,
|
|
100992
|
-
error: isError ? text || "Tool error" : null,
|
|
100993
|
-
status: isError ? "failed" : "completed"
|
|
100994
|
-
};
|
|
100995
|
-
}
|
|
100996
|
-
case "file_change": {
|
|
100997
|
-
return { ...existingData, status: isError ? "failed" : "completed" };
|
|
100998
|
-
}
|
|
100999
|
-
default:
|
|
101000
|
-
return existingData;
|
|
101001
|
-
}
|
|
101002
|
-
}
|
|
101003
|
-
function mapPartialDelta(event) {
|
|
101004
|
-
const e = event;
|
|
101005
|
-
if (e.type !== "content_block_delta") return null;
|
|
101006
|
-
const delta = e.delta;
|
|
101007
|
-
if (delta.type === "text_delta") {
|
|
101008
|
-
return { kind: "text", text: delta.text, index: e.index };
|
|
101009
|
-
}
|
|
101010
|
-
if (delta.type === "thinking_delta") {
|
|
101011
|
-
return { kind: "thinking", text: delta.thinking, index: e.index };
|
|
101012
|
-
}
|
|
101013
|
-
return null;
|
|
101014
|
-
}
|
|
101015
|
-
function mapUsage(usage) {
|
|
101016
|
-
return {
|
|
101017
|
-
input_tokens: usage.input_tokens,
|
|
101018
|
-
cached_input_tokens: usage.cache_read_input_tokens ?? 0,
|
|
101019
|
-
cache_write_input_tokens: usage.cache_creation_input_tokens ?? 0,
|
|
101020
|
-
output_tokens: usage.output_tokens,
|
|
101021
|
-
reasoning_output_tokens: 0
|
|
101022
|
-
// Claude SDK does not provide this separately.
|
|
101023
|
-
};
|
|
101024
|
-
}
|
|
101025
|
-
|
|
101026
101707
|
// src/claude/claude-types.ts
|
|
101027
101708
|
var EFFORT_LABELS2 = {
|
|
101028
101709
|
low: "Low",
|
|
@@ -102380,8 +103061,8 @@ var RepoburgHttpClient = class {
|
|
|
102380
103061
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
102381
103062
|
}
|
|
102382
103063
|
/** Perform a JSON request. Throws a concise error on non-OK/non-JSON responses. */
|
|
102383
|
-
async request(method,
|
|
102384
|
-
const response = await fetch(`${this.baseUrl}${
|
|
103064
|
+
async request(method, path11, body) {
|
|
103065
|
+
const response = await fetch(`${this.baseUrl}${path11}`, {
|
|
102385
103066
|
method,
|
|
102386
103067
|
headers: { "Content-Type": "application/json" },
|
|
102387
103068
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
@@ -102390,17 +103071,17 @@ var RepoburgHttpClient = class {
|
|
|
102390
103071
|
if (!response.ok) {
|
|
102391
103072
|
if (isHtml(text)) {
|
|
102392
103073
|
throw new Error(
|
|
102393
|
-
`${method} ${
|
|
103074
|
+
`${method} ${path11} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
102394
103075
|
);
|
|
102395
103076
|
}
|
|
102396
|
-
throw new Error(`${method} ${
|
|
103077
|
+
throw new Error(`${method} ${path11} failed: ${response.status} ${text}`);
|
|
102397
103078
|
}
|
|
102398
103079
|
if (text.length === 0) return void 0;
|
|
102399
103080
|
try {
|
|
102400
103081
|
return JSON.parse(text);
|
|
102401
103082
|
} catch {
|
|
102402
103083
|
throw new Error(
|
|
102403
|
-
`${method} ${
|
|
103084
|
+
`${method} ${path11} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
102404
103085
|
);
|
|
102405
103086
|
}
|
|
102406
103087
|
}
|
|
@@ -102455,7 +103136,7 @@ var RepoburgHttpClient = class {
|
|
|
102455
103136
|
};
|
|
102456
103137
|
|
|
102457
103138
|
// src/repoburg/backend-resolver.ts
|
|
102458
|
-
import
|
|
103139
|
+
import path10 from "node:path";
|
|
102459
103140
|
var HEALTH_POLL_INTERVAL_MS = 1e3;
|
|
102460
103141
|
var HEALTH_TIMEOUT_MS = 3e4;
|
|
102461
103142
|
function daemonBaseUrl() {
|
|
@@ -102510,7 +103191,7 @@ async function backendHealthy(baseUrl, expectedPath) {
|
|
|
102510
103191
|
const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
|
|
102511
103192
|
if (health.status !== "ok") return false;
|
|
102512
103193
|
if (expectedPath && health.projectPath) {
|
|
102513
|
-
return
|
|
103194
|
+
return path10.resolve(health.projectPath) === path10.resolve(expectedPath);
|
|
102514
103195
|
}
|
|
102515
103196
|
return true;
|
|
102516
103197
|
} catch {
|
|
@@ -102531,7 +103212,7 @@ function serviceBaseUrl(service) {
|
|
|
102531
103212
|
return `http://localhost:${service.port}`;
|
|
102532
103213
|
}
|
|
102533
103214
|
function coveringService(services, absPath) {
|
|
102534
|
-
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path +
|
|
103215
|
+
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path10.sep)).sort((a, b) => b.path.length - a.path.length)[0];
|
|
102535
103216
|
}
|
|
102536
103217
|
async function restartService(daemon, name) {
|
|
102537
103218
|
try {
|
|
@@ -102567,7 +103248,7 @@ async function resolveBackendUrl(projectPath, opts = {}) {
|
|
|
102567
103248
|
if (envUrl) {
|
|
102568
103249
|
return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
|
|
102569
103250
|
}
|
|
102570
|
-
const absPath =
|
|
103251
|
+
const absPath = path10.resolve(projectPath);
|
|
102571
103252
|
const daemon = daemonBaseUrl();
|
|
102572
103253
|
const cached = resolvedCache.get(absPath);
|
|
102573
103254
|
if (cached && await backendHealthy(cached.baseUrl, cached.servesPath ?? absPath)) {
|
|
@@ -103996,6 +104677,7 @@ async function createAgentPaneApp(dbPath) {
|
|
|
103996
104677
|
await registerAppRoutes(fastify);
|
|
103997
104678
|
await registerSidecarRoutes(fastify);
|
|
103998
104679
|
await registerUsageRoutes(fastify);
|
|
104680
|
+
await registerClaudeSessionRoutes(fastify);
|
|
103999
104681
|
const wss2 = initWs();
|
|
104000
104682
|
wss2.on("connection", (ws) => {
|
|
104001
104683
|
ws.send(JSON.stringify({ event: "background_tasks:snapshot", data: { sessions: listAllBackgroundTasks() } }));
|