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
|
@@ -9794,8 +9794,8 @@ var require_req = __commonJS({
|
|
|
9794
9794
|
if (req.originalUrl) {
|
|
9795
9795
|
_req.url = req.originalUrl;
|
|
9796
9796
|
} else {
|
|
9797
|
-
const
|
|
9798
|
-
_req.url = typeof
|
|
9797
|
+
const path11 = req.path;
|
|
9798
|
+
_req.url = typeof path11 === "string" ? path11 : req.url ? req.url.path || req.url : void 0;
|
|
9799
9799
|
}
|
|
9800
9800
|
if (req.query) {
|
|
9801
9801
|
_req.query = req.query;
|
|
@@ -9960,14 +9960,14 @@ var require_redact = __commonJS({
|
|
|
9960
9960
|
}
|
|
9961
9961
|
return obj;
|
|
9962
9962
|
}
|
|
9963
|
-
function parsePath(
|
|
9963
|
+
function parsePath(path11) {
|
|
9964
9964
|
const parts = [];
|
|
9965
9965
|
let current = "";
|
|
9966
9966
|
let inBrackets = false;
|
|
9967
9967
|
let inQuotes = false;
|
|
9968
9968
|
let quoteChar = "";
|
|
9969
|
-
for (let i = 0; i <
|
|
9970
|
-
const char =
|
|
9969
|
+
for (let i = 0; i < path11.length; i++) {
|
|
9970
|
+
const char = path11[i];
|
|
9971
9971
|
if (!inBrackets && char === ".") {
|
|
9972
9972
|
if (current) {
|
|
9973
9973
|
parts.push(current);
|
|
@@ -10098,10 +10098,10 @@ var require_redact = __commonJS({
|
|
|
10098
10098
|
return current;
|
|
10099
10099
|
}
|
|
10100
10100
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
10101
|
-
for (const
|
|
10102
|
-
const parts = parsePath(
|
|
10101
|
+
for (const path11 of paths) {
|
|
10102
|
+
const parts = parsePath(path11);
|
|
10103
10103
|
if (parts.includes("*")) {
|
|
10104
|
-
redactWildcardPath(obj, parts, censor,
|
|
10104
|
+
redactWildcardPath(obj, parts, censor, path11, remove);
|
|
10105
10105
|
} else {
|
|
10106
10106
|
if (remove) {
|
|
10107
10107
|
removeKey(obj, parts);
|
|
@@ -10186,8 +10186,8 @@ var require_redact = __commonJS({
|
|
|
10186
10186
|
}
|
|
10187
10187
|
} else {
|
|
10188
10188
|
if (afterWildcard.includes("*")) {
|
|
10189
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
10190
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
10189
|
+
const wrappedCensor = typeof censor === "function" ? (value, path11) => {
|
|
10190
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path11];
|
|
10191
10191
|
return censor(value, fullPath);
|
|
10192
10192
|
} : censor;
|
|
10193
10193
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -10222,8 +10222,8 @@ var require_redact = __commonJS({
|
|
|
10222
10222
|
return null;
|
|
10223
10223
|
}
|
|
10224
10224
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
10225
|
-
for (const
|
|
10226
|
-
const parts = parsePath(
|
|
10225
|
+
for (const path11 of pathsToClone) {
|
|
10226
|
+
const parts = parsePath(path11);
|
|
10227
10227
|
let current = pathStructure;
|
|
10228
10228
|
for (let i = 0; i < parts.length; i++) {
|
|
10229
10229
|
const part = parts[i];
|
|
@@ -10275,24 +10275,24 @@ var require_redact = __commonJS({
|
|
|
10275
10275
|
}
|
|
10276
10276
|
return cloneSelectively(obj, pathStructure);
|
|
10277
10277
|
}
|
|
10278
|
-
function validatePath(
|
|
10279
|
-
if (typeof
|
|
10278
|
+
function validatePath(path11) {
|
|
10279
|
+
if (typeof path11 !== "string") {
|
|
10280
10280
|
throw new Error("Paths must be (non-empty) strings");
|
|
10281
10281
|
}
|
|
10282
|
-
if (
|
|
10282
|
+
if (path11 === "") {
|
|
10283
10283
|
throw new Error("Invalid redaction path ()");
|
|
10284
10284
|
}
|
|
10285
|
-
if (
|
|
10286
|
-
throw new Error(`Invalid redaction path (${
|
|
10285
|
+
if (path11.includes("..")) {
|
|
10286
|
+
throw new Error(`Invalid redaction path (${path11})`);
|
|
10287
10287
|
}
|
|
10288
|
-
if (
|
|
10289
|
-
throw new Error(`Invalid redaction path (${
|
|
10288
|
+
if (path11.includes(",")) {
|
|
10289
|
+
throw new Error(`Invalid redaction path (${path11})`);
|
|
10290
10290
|
}
|
|
10291
10291
|
let bracketCount = 0;
|
|
10292
10292
|
let inQuotes = false;
|
|
10293
10293
|
let quoteChar = "";
|
|
10294
|
-
for (let i = 0; i <
|
|
10295
|
-
const char =
|
|
10294
|
+
for (let i = 0; i < path11.length; i++) {
|
|
10295
|
+
const char = path11[i];
|
|
10296
10296
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
10297
10297
|
if (!inQuotes) {
|
|
10298
10298
|
inQuotes = true;
|
|
@@ -10306,20 +10306,20 @@ var require_redact = __commonJS({
|
|
|
10306
10306
|
} else if (char === "]" && !inQuotes) {
|
|
10307
10307
|
bracketCount--;
|
|
10308
10308
|
if (bracketCount < 0) {
|
|
10309
|
-
throw new Error(`Invalid redaction path (${
|
|
10309
|
+
throw new Error(`Invalid redaction path (${path11})`);
|
|
10310
10310
|
}
|
|
10311
10311
|
}
|
|
10312
10312
|
}
|
|
10313
10313
|
if (bracketCount !== 0) {
|
|
10314
|
-
throw new Error(`Invalid redaction path (${
|
|
10314
|
+
throw new Error(`Invalid redaction path (${path11})`);
|
|
10315
10315
|
}
|
|
10316
10316
|
}
|
|
10317
10317
|
function validatePaths(paths) {
|
|
10318
10318
|
if (!Array.isArray(paths)) {
|
|
10319
10319
|
throw new TypeError("paths must be an array");
|
|
10320
10320
|
}
|
|
10321
|
-
for (const
|
|
10322
|
-
validatePath(
|
|
10321
|
+
for (const path11 of paths) {
|
|
10322
|
+
validatePath(path11);
|
|
10323
10323
|
}
|
|
10324
10324
|
}
|
|
10325
10325
|
function slowRedact(options = {}) {
|
|
@@ -10487,8 +10487,8 @@ var require_redaction = __commonJS({
|
|
|
10487
10487
|
if (shape[k] === null) {
|
|
10488
10488
|
o[k] = (value) => topCensor(value, [k]);
|
|
10489
10489
|
} else {
|
|
10490
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
10491
|
-
return censor(value, [k, ...
|
|
10490
|
+
const wrappedCensor = typeof censor === "function" ? (value, path11) => {
|
|
10491
|
+
return censor(value, [k, ...path11]);
|
|
10492
10492
|
} : censor;
|
|
10493
10493
|
o[k] = Redact({
|
|
10494
10494
|
paths: shape[k],
|
|
@@ -10709,7 +10709,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10709
10709
|
var fs7 = __require("fs");
|
|
10710
10710
|
var EventEmitter2 = __require("events");
|
|
10711
10711
|
var inherits = __require("util").inherits;
|
|
10712
|
-
var
|
|
10712
|
+
var path11 = __require("path");
|
|
10713
10713
|
var sleep = require_atomic_sleep();
|
|
10714
10714
|
var assert = __require("assert");
|
|
10715
10715
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -10763,7 +10763,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10763
10763
|
const mode = sonic.mode;
|
|
10764
10764
|
if (sonic.sync) {
|
|
10765
10765
|
try {
|
|
10766
|
-
if (sonic.mkdir) fs7.mkdirSync(
|
|
10766
|
+
if (sonic.mkdir) fs7.mkdirSync(path11.dirname(file), { recursive: true });
|
|
10767
10767
|
const fd = fs7.openSync(file, flags, mode);
|
|
10768
10768
|
fileOpened(null, fd);
|
|
10769
10769
|
} catch (err) {
|
|
@@ -10771,7 +10771,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10771
10771
|
throw err;
|
|
10772
10772
|
}
|
|
10773
10773
|
} else if (sonic.mkdir) {
|
|
10774
|
-
fs7.mkdir(
|
|
10774
|
+
fs7.mkdir(path11.dirname(file), { recursive: true }, (err) => {
|
|
10775
10775
|
if (err) return fileOpened(err);
|
|
10776
10776
|
fs7.open(file, flags, mode, fileOpened);
|
|
10777
10777
|
});
|
|
@@ -12103,15 +12103,15 @@ var require_transport = __commonJS({
|
|
|
12103
12103
|
if (!unquoted) {
|
|
12104
12104
|
return false;
|
|
12105
12105
|
}
|
|
12106
|
-
let
|
|
12107
|
-
if (
|
|
12106
|
+
let path11 = unquoted;
|
|
12107
|
+
if (path11.startsWith("file://")) {
|
|
12108
12108
|
try {
|
|
12109
|
-
|
|
12109
|
+
path11 = fileURLToPath3(path11);
|
|
12110
12110
|
} catch {
|
|
12111
12111
|
return false;
|
|
12112
12112
|
}
|
|
12113
12113
|
}
|
|
12114
|
-
return isAbsolute(
|
|
12114
|
+
return isAbsolute(path11) && !existsSync3(path11);
|
|
12115
12115
|
}
|
|
12116
12116
|
function stripQuotes(value) {
|
|
12117
12117
|
const first = value[0];
|
|
@@ -13852,7 +13852,7 @@ var require_pino = __commonJS({
|
|
|
13852
13852
|
} = symbols;
|
|
13853
13853
|
var { epochTime, nullTime } = time;
|
|
13854
13854
|
var { pid } = process;
|
|
13855
|
-
var
|
|
13855
|
+
var hostname2 = os4.hostname();
|
|
13856
13856
|
var defaultErrorSerializer = stdSerializers.err;
|
|
13857
13857
|
var defaultOptions = {
|
|
13858
13858
|
level: "info",
|
|
@@ -13862,7 +13862,7 @@ var require_pino = __commonJS({
|
|
|
13862
13862
|
errorKey: "err",
|
|
13863
13863
|
nestedKey: null,
|
|
13864
13864
|
enabled: true,
|
|
13865
|
-
base: { pid, hostname },
|
|
13865
|
+
base: { pid, hostname: hostname2 },
|
|
13866
13866
|
serializers: Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
13867
13867
|
err: defaultErrorSerializer
|
|
13868
13868
|
}),
|
|
@@ -20787,8 +20787,8 @@ var require_utils = __commonJS({
|
|
|
20787
20787
|
}
|
|
20788
20788
|
return ind;
|
|
20789
20789
|
}
|
|
20790
|
-
function removeDotSegments(
|
|
20791
|
-
let input =
|
|
20790
|
+
function removeDotSegments(path11) {
|
|
20791
|
+
let input = path11;
|
|
20792
20792
|
const output = [];
|
|
20793
20793
|
let nextSlash = -1;
|
|
20794
20794
|
let len = 0;
|
|
@@ -21040,8 +21040,8 @@ var require_schemes = __commonJS({
|
|
|
21040
21040
|
wsComponent.secure = void 0;
|
|
21041
21041
|
}
|
|
21042
21042
|
if (wsComponent.resourceName) {
|
|
21043
|
-
const [
|
|
21044
|
-
wsComponent.path =
|
|
21043
|
+
const [path11, query2] = wsComponent.resourceName.split("?");
|
|
21044
|
+
wsComponent.path = path11 && path11 !== "/" ? path11 : void 0;
|
|
21045
21045
|
wsComponent.query = query2;
|
|
21046
21046
|
wsComponent.resourceName = void 0;
|
|
21047
21047
|
}
|
|
@@ -23863,9 +23863,9 @@ var require_discriminator = __commonJS({
|
|
|
23863
23863
|
function validateMapping() {
|
|
23864
23864
|
const mapping = getMapping();
|
|
23865
23865
|
gen.if(false);
|
|
23866
|
-
for (const
|
|
23867
|
-
gen.elseIf((0, codegen_1._)`${tag} === ${
|
|
23868
|
-
gen.assign(valid, applyTagSchema(mapping[
|
|
23866
|
+
for (const tagValue2 in mapping) {
|
|
23867
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
|
|
23868
|
+
gen.assign(valid, applyTagSchema(mapping[tagValue2]));
|
|
23869
23869
|
}
|
|
23870
23870
|
gen.else();
|
|
23871
23871
|
cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag, tagName });
|
|
@@ -23909,18 +23909,18 @@ var require_discriminator = __commonJS({
|
|
|
23909
23909
|
if (sch.const) {
|
|
23910
23910
|
addMapping(sch.const, i);
|
|
23911
23911
|
} else if (sch.enum) {
|
|
23912
|
-
for (const
|
|
23913
|
-
addMapping(
|
|
23912
|
+
for (const tagValue2 of sch.enum) {
|
|
23913
|
+
addMapping(tagValue2, i);
|
|
23914
23914
|
}
|
|
23915
23915
|
} else {
|
|
23916
23916
|
throw new Error(`discriminator: "properties/${tagName}" must have "const" or "enum"`);
|
|
23917
23917
|
}
|
|
23918
23918
|
}
|
|
23919
|
-
function addMapping(
|
|
23920
|
-
if (typeof
|
|
23919
|
+
function addMapping(tagValue2, i) {
|
|
23920
|
+
if (typeof tagValue2 != "string" || tagValue2 in oneOfMapping) {
|
|
23921
23921
|
throw new Error(`discriminator: "${tagName}" values must be unique strings`);
|
|
23922
23922
|
}
|
|
23923
|
-
oneOfMapping[
|
|
23923
|
+
oneOfMapping[tagValue2] = i;
|
|
23924
23924
|
}
|
|
23925
23925
|
}
|
|
23926
23926
|
}
|
|
@@ -24698,9 +24698,9 @@ var require_discriminator2 = __commonJS({
|
|
|
24698
24698
|
}
|
|
24699
24699
|
function validateMapping(tag) {
|
|
24700
24700
|
gen.if(false);
|
|
24701
|
-
for (const
|
|
24702
|
-
gen.elseIf((0, codegen_1._)`${tag} === ${
|
|
24703
|
-
gen.assign(valid, applyTagSchema(
|
|
24701
|
+
for (const tagValue2 in parentSchema.mapping) {
|
|
24702
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
|
|
24703
|
+
gen.assign(valid, applyTagSchema(tagValue2));
|
|
24704
24704
|
}
|
|
24705
24705
|
gen.else();
|
|
24706
24706
|
cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag }, { instancePath: schema, schemaPath: "mapping", parentSchema: true });
|
|
@@ -25115,9 +25115,9 @@ var require_serialize = __commonJS({
|
|
|
25115
25115
|
const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(discriminator)}`);
|
|
25116
25116
|
serializeString({ ...cxt, data: tag });
|
|
25117
25117
|
gen.if(false);
|
|
25118
|
-
for (const
|
|
25119
|
-
gen.elseIf((0, codegen_1._)`${tag} === ${
|
|
25120
|
-
const sch = schema.mapping[
|
|
25118
|
+
for (const tagValue2 in schema.mapping) {
|
|
25119
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
|
|
25120
|
+
const sch = schema.mapping[tagValue2];
|
|
25121
25121
|
serializeSchemaProperties({ ...cxt, schema: sch }, discriminator);
|
|
25122
25122
|
}
|
|
25123
25123
|
gen.endIf();
|
|
@@ -25583,9 +25583,9 @@ var require_parse = __commonJS({
|
|
|
25583
25583
|
gen.assign(names_1.default.jsonPos, startPos);
|
|
25584
25584
|
gen.if((0, codegen_1._)`${tag} === undefined`);
|
|
25585
25585
|
parsingError(cxt, (0, codegen_1.str)`discriminator tag not found`);
|
|
25586
|
-
for (const
|
|
25587
|
-
gen.elseIf((0, codegen_1._)`${tag} === ${
|
|
25588
|
-
parseSchemaProperties({ ...cxt, schema: mapping[
|
|
25586
|
+
for (const tagValue2 in mapping) {
|
|
25587
|
+
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
|
|
25588
|
+
parseSchemaProperties({ ...cxt, schema: mapping[tagValue2] }, discriminator);
|
|
25589
25589
|
}
|
|
25590
25590
|
gen.else();
|
|
25591
25591
|
parsingError(cxt, (0, codegen_1.str)`discriminator value not in schema`);
|
|
@@ -25978,8 +25978,8 @@ var require_utils2 = __commonJS({
|
|
|
25978
25978
|
}
|
|
25979
25979
|
return ind;
|
|
25980
25980
|
}
|
|
25981
|
-
function removeDotSegments(
|
|
25982
|
-
let input =
|
|
25981
|
+
function removeDotSegments(path11) {
|
|
25982
|
+
let input = path11;
|
|
25983
25983
|
const output = [];
|
|
25984
25984
|
let nextSlash = -1;
|
|
25985
25985
|
let len = 0;
|
|
@@ -26324,8 +26324,8 @@ var require_schemes2 = __commonJS({
|
|
|
26324
26324
|
wsComponent.secure = void 0;
|
|
26325
26325
|
}
|
|
26326
26326
|
if (wsComponent.resourceName) {
|
|
26327
|
-
const [
|
|
26328
|
-
wsComponent.path =
|
|
26327
|
+
const [path11, query2] = wsComponent.resourceName.split("?");
|
|
26328
|
+
wsComponent.path = path11 && path11 !== "/" ? path11 : void 0;
|
|
26329
26329
|
wsComponent.query = query2;
|
|
26330
26330
|
wsComponent.resourceName = void 0;
|
|
26331
26331
|
}
|
|
@@ -27809,8 +27809,8 @@ var require_utils3 = __commonJS({
|
|
|
27809
27809
|
}
|
|
27810
27810
|
return ind;
|
|
27811
27811
|
}
|
|
27812
|
-
function removeDotSegments(
|
|
27813
|
-
let input =
|
|
27812
|
+
function removeDotSegments(path11) {
|
|
27813
|
+
let input = path11;
|
|
27814
27814
|
const output = [];
|
|
27815
27815
|
let nextSlash = -1;
|
|
27816
27816
|
let len = 0;
|
|
@@ -28155,8 +28155,8 @@ var require_schemes3 = __commonJS({
|
|
|
28155
28155
|
wsComponent.secure = void 0;
|
|
28156
28156
|
}
|
|
28157
28157
|
if (wsComponent.resourceName) {
|
|
28158
|
-
const [
|
|
28159
|
-
wsComponent.path =
|
|
28158
|
+
const [path11, query2] = wsComponent.resourceName.split("?");
|
|
28159
|
+
wsComponent.path = path11 && path11 !== "/" ? path11 : void 0;
|
|
28160
28160
|
wsComponent.query = query2;
|
|
28161
28161
|
wsComponent.resourceName = void 0;
|
|
28162
28162
|
}
|
|
@@ -35673,13 +35673,13 @@ var require_node = __commonJS({
|
|
|
35673
35673
|
this.staticChildrenNodes[index] = node;
|
|
35674
35674
|
}
|
|
35675
35675
|
}
|
|
35676
|
-
findStaticMatchingChild(
|
|
35677
|
-
const charCode =
|
|
35676
|
+
findStaticMatchingChild(path11, pathIndex) {
|
|
35677
|
+
const charCode = path11.charCodeAt(pathIndex);
|
|
35678
35678
|
const charCodes = this.staticChildrenCharCodes;
|
|
35679
35679
|
for (let i = 0; i < charCodes.length; i++) {
|
|
35680
35680
|
if (charCodes[i] === charCode) {
|
|
35681
35681
|
const staticChild = this.staticChildrenNodes[i];
|
|
35682
|
-
if (staticChild.matchPrefix(
|
|
35682
|
+
if (staticChild.matchPrefix(path11, pathIndex)) {
|
|
35683
35683
|
return staticChild;
|
|
35684
35684
|
}
|
|
35685
35685
|
return null;
|
|
@@ -35687,34 +35687,34 @@ var require_node = __commonJS({
|
|
|
35687
35687
|
}
|
|
35688
35688
|
return null;
|
|
35689
35689
|
}
|
|
35690
|
-
getStaticChild(
|
|
35691
|
-
if (
|
|
35690
|
+
getStaticChild(path11, pathIndex = 0) {
|
|
35691
|
+
if (path11.length === pathIndex) {
|
|
35692
35692
|
return this;
|
|
35693
35693
|
}
|
|
35694
|
-
const staticChild = this.findStaticMatchingChild(
|
|
35694
|
+
const staticChild = this.findStaticMatchingChild(path11, pathIndex);
|
|
35695
35695
|
if (staticChild) {
|
|
35696
|
-
return staticChild.getStaticChild(
|
|
35696
|
+
return staticChild.getStaticChild(path11, pathIndex + staticChild.prefix.length);
|
|
35697
35697
|
}
|
|
35698
35698
|
return null;
|
|
35699
35699
|
}
|
|
35700
|
-
createStaticChild(
|
|
35701
|
-
if (
|
|
35700
|
+
createStaticChild(path11) {
|
|
35701
|
+
if (path11.length === 0) {
|
|
35702
35702
|
return this;
|
|
35703
35703
|
}
|
|
35704
|
-
const childIndex = this.staticChildrenCharCodes.indexOf(
|
|
35704
|
+
const childIndex = this.staticChildrenCharCodes.indexOf(path11.charCodeAt(0));
|
|
35705
35705
|
let staticChild = childIndex === -1 ? void 0 : this.staticChildrenNodes[childIndex];
|
|
35706
35706
|
if (staticChild) {
|
|
35707
35707
|
let i = 1;
|
|
35708
35708
|
for (; i < staticChild.prefix.length; i++) {
|
|
35709
|
-
if (
|
|
35709
|
+
if (path11.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) {
|
|
35710
35710
|
staticChild = staticChild.split(this, i);
|
|
35711
35711
|
break;
|
|
35712
35712
|
}
|
|
35713
35713
|
}
|
|
35714
|
-
return staticChild.createStaticChild(
|
|
35714
|
+
return staticChild.createStaticChild(path11.slice(i));
|
|
35715
35715
|
}
|
|
35716
|
-
const node = new StaticNode(
|
|
35717
|
-
this.setStaticChild(
|
|
35716
|
+
const node = new StaticNode(path11);
|
|
35717
|
+
this.setStaticChild(path11.charAt(0), node);
|
|
35718
35718
|
return node;
|
|
35719
35719
|
}
|
|
35720
35720
|
};
|
|
@@ -35738,13 +35738,13 @@ var require_node = __commonJS({
|
|
|
35738
35738
|
}
|
|
35739
35739
|
return null;
|
|
35740
35740
|
}
|
|
35741
|
-
createParametricChild(regex, staticSuffix,
|
|
35741
|
+
createParametricChild(regex, staticSuffix, nodePath2) {
|
|
35742
35742
|
let parametricChild = this.getParametricChild(regex);
|
|
35743
35743
|
if (parametricChild) {
|
|
35744
|
-
parametricChild.nodePaths.add(
|
|
35744
|
+
parametricChild.nodePaths.add(nodePath2);
|
|
35745
35745
|
return parametricChild;
|
|
35746
35746
|
}
|
|
35747
|
-
parametricChild = new ParametricNode(regex, staticSuffix,
|
|
35747
|
+
parametricChild = new ParametricNode(regex, staticSuffix, nodePath2);
|
|
35748
35748
|
this.parametricChildren.push(parametricChild);
|
|
35749
35749
|
this.parametricChildren.sort((child1, child2) => {
|
|
35750
35750
|
if (!child1.isRegex) return 1;
|
|
@@ -35774,8 +35774,8 @@ var require_node = __commonJS({
|
|
|
35774
35774
|
parentNode.setStaticChild(parentPrefix.charAt(0), staticNode);
|
|
35775
35775
|
return staticNode;
|
|
35776
35776
|
}
|
|
35777
|
-
getNextNode(
|
|
35778
|
-
let node = this.findStaticMatchingChild(
|
|
35777
|
+
getNextNode(path11, pathIndex, nodeStack, paramsCount) {
|
|
35778
|
+
let node = this.findStaticMatchingChild(path11, pathIndex);
|
|
35779
35779
|
let parametricBrotherNodeIndex = 0;
|
|
35780
35780
|
if (node === null) {
|
|
35781
35781
|
if (this.parametricChildren.length === 0) {
|
|
@@ -35814,16 +35814,16 @@ var require_node = __commonJS({
|
|
|
35814
35814
|
}
|
|
35815
35815
|
};
|
|
35816
35816
|
var ParametricNode = class extends ParentNode {
|
|
35817
|
-
constructor(regex, staticSuffix,
|
|
35817
|
+
constructor(regex, staticSuffix, nodePath2) {
|
|
35818
35818
|
super();
|
|
35819
35819
|
this.isRegex = !!regex;
|
|
35820
35820
|
this.regex = regex || null;
|
|
35821
35821
|
this.staticSuffix = staticSuffix || null;
|
|
35822
35822
|
this.kind = NODE_TYPES.PARAMETRIC;
|
|
35823
|
-
this.nodePaths = /* @__PURE__ */ new Set([
|
|
35823
|
+
this.nodePaths = /* @__PURE__ */ new Set([nodePath2]);
|
|
35824
35824
|
}
|
|
35825
|
-
getNextNode(
|
|
35826
|
-
return this.findStaticMatchingChild(
|
|
35825
|
+
getNextNode(path11, pathIndex) {
|
|
35826
|
+
return this.findStaticMatchingChild(path11, pathIndex);
|
|
35827
35827
|
}
|
|
35828
35828
|
};
|
|
35829
35829
|
var WildcardNode = class extends Node {
|
|
@@ -36179,81 +36179,81 @@ var require_url_sanitizer = __commonJS({
|
|
|
36179
36179
|
return String.fromCharCode(charCode);
|
|
36180
36180
|
}
|
|
36181
36181
|
var MIN_NATIVE_SCAN_LENGTH = 12;
|
|
36182
|
-
function safeDecodeURI(
|
|
36183
|
-
if (
|
|
36184
|
-
return safeDecodeURINativeScan(
|
|
36182
|
+
function safeDecodeURI(path11, useSemicolonDelimiter) {
|
|
36183
|
+
if (path11.length >= MIN_NATIVE_SCAN_LENGTH) {
|
|
36184
|
+
return safeDecodeURINativeScan(path11, useSemicolonDelimiter);
|
|
36185
36185
|
}
|
|
36186
|
-
return safeDecodeURICharScan(
|
|
36186
|
+
return safeDecodeURICharScan(path11, useSemicolonDelimiter, 1);
|
|
36187
36187
|
}
|
|
36188
|
-
function safeDecodeURINativeScan(
|
|
36189
|
-
const percentIndex =
|
|
36190
|
-
let delimIndex =
|
|
36191
|
-
const hashIndex =
|
|
36188
|
+
function safeDecodeURINativeScan(path11, useSemicolonDelimiter) {
|
|
36189
|
+
const percentIndex = path11.indexOf("%", 1);
|
|
36190
|
+
let delimIndex = path11.indexOf("?", 1);
|
|
36191
|
+
const hashIndex = path11.indexOf("#", 1);
|
|
36192
36192
|
if (hashIndex !== -1 && (delimIndex === -1 || hashIndex < delimIndex)) {
|
|
36193
36193
|
delimIndex = hashIndex;
|
|
36194
36194
|
}
|
|
36195
36195
|
if (useSemicolonDelimiter) {
|
|
36196
|
-
const semicolonIndex =
|
|
36196
|
+
const semicolonIndex = path11.indexOf(";", 1);
|
|
36197
36197
|
if (semicolonIndex !== -1 && (delimIndex === -1 || semicolonIndex < delimIndex)) {
|
|
36198
36198
|
delimIndex = semicolonIndex;
|
|
36199
36199
|
}
|
|
36200
36200
|
}
|
|
36201
36201
|
if (percentIndex === -1 || delimIndex !== -1 && percentIndex > delimIndex) {
|
|
36202
36202
|
if (delimIndex === -1) {
|
|
36203
|
-
return { path:
|
|
36203
|
+
return { path: path11, querystring: "", shouldDecodeParam: false };
|
|
36204
36204
|
}
|
|
36205
36205
|
return {
|
|
36206
|
-
path:
|
|
36207
|
-
querystring:
|
|
36206
|
+
path: path11.slice(0, delimIndex),
|
|
36207
|
+
querystring: path11.slice(delimIndex + 1),
|
|
36208
36208
|
shouldDecodeParam: false
|
|
36209
36209
|
};
|
|
36210
36210
|
}
|
|
36211
|
-
return safeDecodeURIPercentScan(
|
|
36211
|
+
return safeDecodeURIPercentScan(path11, useSemicolonDelimiter, percentIndex);
|
|
36212
36212
|
}
|
|
36213
|
-
function safeDecodeURICharScan(
|
|
36214
|
-
for (let i = startIndex; i <
|
|
36215
|
-
const charCode =
|
|
36213
|
+
function safeDecodeURICharScan(path11, useSemicolonDelimiter, startIndex) {
|
|
36214
|
+
for (let i = startIndex; i < path11.length; i++) {
|
|
36215
|
+
const charCode = path11.charCodeAt(i);
|
|
36216
36216
|
if (charCode === 37) {
|
|
36217
|
-
return safeDecodeURIPercentScan(
|
|
36217
|
+
return safeDecodeURIPercentScan(path11, useSemicolonDelimiter, i);
|
|
36218
36218
|
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
36219
36219
|
return {
|
|
36220
|
-
path:
|
|
36221
|
-
querystring:
|
|
36220
|
+
path: path11.slice(0, i),
|
|
36221
|
+
querystring: path11.slice(i + 1),
|
|
36222
36222
|
shouldDecodeParam: false
|
|
36223
36223
|
};
|
|
36224
36224
|
}
|
|
36225
36225
|
}
|
|
36226
|
-
return { path:
|
|
36226
|
+
return { path: path11, querystring: "", shouldDecodeParam: false };
|
|
36227
36227
|
}
|
|
36228
|
-
function reencodePercentChar(
|
|
36229
|
-
return
|
|
36228
|
+
function reencodePercentChar(path11, index) {
|
|
36229
|
+
return path11.slice(0, index + 1) + "25" + path11.slice(index + 1);
|
|
36230
36230
|
}
|
|
36231
|
-
function safeDecodeURIPercentScan(
|
|
36231
|
+
function safeDecodeURIPercentScan(path11, useSemicolonDelimiter, startIndex) {
|
|
36232
36232
|
let shouldDecode = false;
|
|
36233
36233
|
let shouldDecodeParam = false;
|
|
36234
36234
|
let querystring = "";
|
|
36235
|
-
for (let i = startIndex; i <
|
|
36236
|
-
const charCode =
|
|
36235
|
+
for (let i = startIndex; i < path11.length; i++) {
|
|
36236
|
+
const charCode = path11.charCodeAt(i);
|
|
36237
36237
|
if (charCode === 37) {
|
|
36238
|
-
const componentCharCode = decodeComponentCharCode(
|
|
36238
|
+
const componentCharCode = decodeComponentCharCode(path11.charCodeAt(i + 1), path11.charCodeAt(i + 2));
|
|
36239
36239
|
if (componentCharCode === 0) {
|
|
36240
36240
|
shouldDecode = true;
|
|
36241
36241
|
} else {
|
|
36242
36242
|
shouldDecodeParam = true;
|
|
36243
36243
|
if (componentCharCode === 37) {
|
|
36244
36244
|
shouldDecode = true;
|
|
36245
|
-
|
|
36245
|
+
path11 = reencodePercentChar(path11, i);
|
|
36246
36246
|
i += 2;
|
|
36247
36247
|
}
|
|
36248
36248
|
i += 2;
|
|
36249
36249
|
}
|
|
36250
36250
|
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
36251
|
-
querystring =
|
|
36252
|
-
|
|
36251
|
+
querystring = path11.slice(i + 1);
|
|
36252
|
+
path11 = path11.slice(0, i);
|
|
36253
36253
|
break;
|
|
36254
36254
|
}
|
|
36255
36255
|
}
|
|
36256
|
-
const decodedPath = shouldDecode ? decodeURI(
|
|
36256
|
+
const decodedPath = shouldDecode ? decodeURI(path11) : path11;
|
|
36257
36257
|
return { path: decodedPath, querystring, shouldDecodeParam };
|
|
36258
36258
|
}
|
|
36259
36259
|
function safeDecodeURIComponent(uriComponent) {
|
|
@@ -36348,7 +36348,7 @@ var require_find_my_way = __commonJS({
|
|
|
36348
36348
|
this.trees = /* @__PURE__ */ Object.create(null);
|
|
36349
36349
|
this._treeGET = null;
|
|
36350
36350
|
}
|
|
36351
|
-
Router.prototype.on = function on(method,
|
|
36351
|
+
Router.prototype.on = function on(method, path11, opts, handler, store) {
|
|
36352
36352
|
if (typeof opts === "function") {
|
|
36353
36353
|
if (handler !== void 0) {
|
|
36354
36354
|
store = handler;
|
|
@@ -36356,34 +36356,34 @@ var require_find_my_way = __commonJS({
|
|
|
36356
36356
|
handler = opts;
|
|
36357
36357
|
opts = {};
|
|
36358
36358
|
}
|
|
36359
|
-
assert(typeof
|
|
36360
|
-
assert(
|
|
36361
|
-
assert(
|
|
36359
|
+
assert(typeof path11 === "string", "Path should be a string");
|
|
36360
|
+
assert(path11.length > 0, "The path could not be empty");
|
|
36361
|
+
assert(path11[0] === "/" || path11[0] === "*", "The first character of a path should be `/` or `*`");
|
|
36362
36362
|
assert(typeof handler === "function", "Handler should be a function");
|
|
36363
|
-
const optionalParamMatch =
|
|
36363
|
+
const optionalParamMatch = path11.match(OPTIONAL_PARAM_REGEXP);
|
|
36364
36364
|
if (optionalParamMatch) {
|
|
36365
|
-
assert(
|
|
36366
|
-
const pathFull =
|
|
36367
|
-
const pathOptional =
|
|
36365
|
+
assert(path11.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
36366
|
+
const pathFull = path11.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
36367
|
+
const pathOptional = path11.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
|
|
36368
36368
|
this.on(method, pathFull, opts, handler, store);
|
|
36369
36369
|
this.on(method, pathOptional, opts, handler, store);
|
|
36370
36370
|
return;
|
|
36371
36371
|
}
|
|
36372
|
-
const route =
|
|
36372
|
+
const route = path11;
|
|
36373
36373
|
if (this.ignoreDuplicateSlashes) {
|
|
36374
|
-
|
|
36374
|
+
path11 = removeDuplicateSlashes(path11);
|
|
36375
36375
|
}
|
|
36376
36376
|
if (this.ignoreTrailingSlash) {
|
|
36377
|
-
|
|
36377
|
+
path11 = trimLastSlash(path11);
|
|
36378
36378
|
}
|
|
36379
36379
|
const methods = Array.isArray(method) ? method : [method];
|
|
36380
36380
|
for (const method2 of methods) {
|
|
36381
36381
|
assert(typeof method2 === "string", "Method should be a string");
|
|
36382
36382
|
assert(httpMethods.includes(method2), `Method '${method2}' is not an http method.`);
|
|
36383
|
-
this._on(method2,
|
|
36383
|
+
this._on(method2, path11, opts, handler, store, route);
|
|
36384
36384
|
}
|
|
36385
36385
|
};
|
|
36386
|
-
Router.prototype._on = function _on(method,
|
|
36386
|
+
Router.prototype._on = function _on(method, path11, opts, handler, store) {
|
|
36387
36387
|
let constraints = {};
|
|
36388
36388
|
if (opts.constraints !== void 0) {
|
|
36389
36389
|
assert(typeof opts.constraints === "object" && opts.constraints !== null, "Constraints should be an object");
|
|
@@ -36396,7 +36396,7 @@ var require_find_my_way = __commonJS({
|
|
|
36396
36396
|
if (this.trees[method] === void 0) {
|
|
36397
36397
|
this.trees[method] = new StaticNode("/");
|
|
36398
36398
|
}
|
|
36399
|
-
let pattern =
|
|
36399
|
+
let pattern = path11;
|
|
36400
36400
|
if (pattern === "*" && this.trees[method].prefix.length !== 0) {
|
|
36401
36401
|
const currentRoot = this.trees[method];
|
|
36402
36402
|
this.trees[method] = new StaticNode("");
|
|
@@ -36473,11 +36473,11 @@ var require_find_my_way = __commonJS({
|
|
|
36473
36473
|
nodePatternParts += "()" + staticPart;
|
|
36474
36474
|
if (isEndOfNode || pattern.charCodeAt(j) === 47 || j === pattern.length) {
|
|
36475
36475
|
const nodePattern = isRegexNode ? nodePatternParts : staticPart;
|
|
36476
|
-
const
|
|
36476
|
+
const nodePath2 = pattern.slice(i, j);
|
|
36477
36477
|
pattern = pattern.slice(0, i + 1) + nodePattern + pattern.slice(j);
|
|
36478
36478
|
i += nodePattern.length;
|
|
36479
36479
|
const regex = isRegexNode ? new RegExp("^" + regexps.join("") + "$") : null;
|
|
36480
|
-
currentNode = currentNode.createParametricChild(regex, staticPart || null,
|
|
36480
|
+
currentNode = currentNode.createParametricChild(regex, staticPart || null, nodePath2);
|
|
36481
36481
|
parentNodePathIndex = i + 1;
|
|
36482
36482
|
break;
|
|
36483
36483
|
}
|
|
@@ -36504,19 +36504,19 @@ var require_find_my_way = __commonJS({
|
|
|
36504
36504
|
throw new Error(`Method '${method}' already declared for route '${pattern}' with constraints '${JSON.stringify(constraints)}'`);
|
|
36505
36505
|
}
|
|
36506
36506
|
}
|
|
36507
|
-
const route = { method, path:
|
|
36507
|
+
const route = { method, path: path11, pattern, params, opts, handler, store };
|
|
36508
36508
|
this.routes.push(route);
|
|
36509
36509
|
currentNode.addRoute(route, this.constrainer);
|
|
36510
36510
|
};
|
|
36511
|
-
Router.prototype.hasRoute = function hasRoute(method,
|
|
36512
|
-
const route = this.findRoute(method,
|
|
36511
|
+
Router.prototype.hasRoute = function hasRoute(method, path11, constraints) {
|
|
36512
|
+
const route = this.findRoute(method, path11, constraints);
|
|
36513
36513
|
return route !== null;
|
|
36514
36514
|
};
|
|
36515
|
-
Router.prototype.findRoute = function findNode(method,
|
|
36515
|
+
Router.prototype.findRoute = function findNode(method, path11, constraints = {}) {
|
|
36516
36516
|
if (this.trees[method] === void 0) {
|
|
36517
36517
|
return null;
|
|
36518
36518
|
}
|
|
36519
|
-
let pattern =
|
|
36519
|
+
let pattern = path11;
|
|
36520
36520
|
let currentNode = this.trees[method];
|
|
36521
36521
|
let parentNodePathIndex = currentNode.prefix.length;
|
|
36522
36522
|
const params = [];
|
|
@@ -36588,11 +36588,11 @@ var require_find_my_way = __commonJS({
|
|
|
36588
36588
|
nodePatternParts += "()" + staticPart;
|
|
36589
36589
|
if (isEndOfNode || pattern.charCodeAt(j) === 47 || j === pattern.length) {
|
|
36590
36590
|
const nodePattern = isRegexNode ? nodePatternParts : staticPart;
|
|
36591
|
-
const
|
|
36591
|
+
const nodePath2 = pattern.slice(i, j);
|
|
36592
36592
|
pattern = pattern.slice(0, i + 1) + nodePattern + pattern.slice(j);
|
|
36593
36593
|
i += nodePattern.length;
|
|
36594
36594
|
const regex = isRegexNode ? new RegExp("^" + regexps.join("") + "$") : null;
|
|
36595
|
-
currentNode = currentNode.getParametricChild(regex, staticPart || null,
|
|
36595
|
+
currentNode = currentNode.getParametricChild(regex, staticPart || null, nodePath2);
|
|
36596
36596
|
if (currentNode === null) {
|
|
36597
36597
|
return null;
|
|
36598
36598
|
}
|
|
@@ -36637,39 +36637,39 @@ var require_find_my_way = __commonJS({
|
|
|
36637
36637
|
this._treeGET = null;
|
|
36638
36638
|
this.routes = [];
|
|
36639
36639
|
};
|
|
36640
|
-
Router.prototype.off = function off(method,
|
|
36641
|
-
assert(typeof
|
|
36642
|
-
assert(
|
|
36643
|
-
assert(
|
|
36640
|
+
Router.prototype.off = function off(method, path11, constraints) {
|
|
36641
|
+
assert(typeof path11 === "string", "Path should be a string");
|
|
36642
|
+
assert(path11.length > 0, "The path could not be empty");
|
|
36643
|
+
assert(path11[0] === "/" || path11[0] === "*", "The first character of a path should be `/` or `*`");
|
|
36644
36644
|
assert(
|
|
36645
36645
|
typeof constraints === "undefined" || typeof constraints === "object" && !Array.isArray(constraints) && constraints !== null,
|
|
36646
36646
|
"Constraints should be an object or undefined."
|
|
36647
36647
|
);
|
|
36648
|
-
const optionalParamMatch =
|
|
36648
|
+
const optionalParamMatch = path11.match(OPTIONAL_PARAM_REGEXP);
|
|
36649
36649
|
if (optionalParamMatch) {
|
|
36650
|
-
assert(
|
|
36651
|
-
const pathFull =
|
|
36652
|
-
const pathOptional =
|
|
36650
|
+
assert(path11.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
36651
|
+
const pathFull = path11.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
36652
|
+
const pathOptional = path11.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
|
|
36653
36653
|
this.off(method, pathFull, constraints);
|
|
36654
36654
|
this.off(method, pathOptional, constraints);
|
|
36655
36655
|
return;
|
|
36656
36656
|
}
|
|
36657
36657
|
if (this.ignoreDuplicateSlashes) {
|
|
36658
|
-
|
|
36658
|
+
path11 = removeDuplicateSlashes(path11);
|
|
36659
36659
|
}
|
|
36660
36660
|
if (this.ignoreTrailingSlash) {
|
|
36661
|
-
|
|
36661
|
+
path11 = trimLastSlash(path11);
|
|
36662
36662
|
}
|
|
36663
36663
|
const methods = Array.isArray(method) ? method : [method];
|
|
36664
36664
|
for (const method2 of methods) {
|
|
36665
|
-
this._off(method2,
|
|
36665
|
+
this._off(method2, path11, constraints);
|
|
36666
36666
|
}
|
|
36667
36667
|
};
|
|
36668
|
-
Router.prototype._off = function _off(method,
|
|
36668
|
+
Router.prototype._off = function _off(method, path11, constraints) {
|
|
36669
36669
|
assert(typeof method === "string", "Method should be a string");
|
|
36670
36670
|
assert(httpMethods.includes(method), `Method '${method}' is not an http method.`);
|
|
36671
36671
|
function matcherWithoutConstraints(route) {
|
|
36672
|
-
return method !== route.method ||
|
|
36672
|
+
return method !== route.method || path11 !== route.path;
|
|
36673
36673
|
}
|
|
36674
36674
|
function matcherWithConstraints(route) {
|
|
36675
36675
|
return matcherWithoutConstraints(route) || !deepEqual(constraints, route.opts.constraints || {});
|
|
@@ -36706,37 +36706,37 @@ var require_find_my_way = __commonJS({
|
|
|
36706
36706
|
if (handle === null) return this._defaultRoute(req, res, ctx);
|
|
36707
36707
|
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);
|
|
36708
36708
|
};
|
|
36709
|
-
Router.prototype.find = function find(method,
|
|
36709
|
+
Router.prototype.find = function find(method, path11, derivedConstraints) {
|
|
36710
36710
|
let currentNode = method === "GET" ? this._treeGET : this.trees[method];
|
|
36711
36711
|
if (currentNode == null) return null;
|
|
36712
|
-
if (
|
|
36713
|
-
|
|
36712
|
+
if (path11.charCodeAt(0) !== 47) {
|
|
36713
|
+
path11 = path11.replace(FULL_PATH_REGEXP, "/");
|
|
36714
36714
|
}
|
|
36715
36715
|
if (this.ignoreDuplicateSlashes) {
|
|
36716
|
-
|
|
36716
|
+
path11 = removeDuplicateSlashes(path11);
|
|
36717
36717
|
}
|
|
36718
36718
|
let sanitizedUrl;
|
|
36719
36719
|
let querystring2;
|
|
36720
36720
|
let shouldDecodeParam;
|
|
36721
36721
|
try {
|
|
36722
|
-
sanitizedUrl =
|
|
36723
|
-
|
|
36722
|
+
sanitizedUrl = path11.length >= MIN_NATIVE_SCAN_LENGTH ? safeDecodeURINativeScan(path11, this.useSemicolonDelimiter) : safeDecodeURICharScan(path11, this.useSemicolonDelimiter, 1);
|
|
36723
|
+
path11 = sanitizedUrl.path;
|
|
36724
36724
|
querystring2 = sanitizedUrl.querystring;
|
|
36725
36725
|
shouldDecodeParam = sanitizedUrl.shouldDecodeParam;
|
|
36726
36726
|
} catch (error) {
|
|
36727
|
-
return this._onBadUrl(
|
|
36727
|
+
return this._onBadUrl(path11);
|
|
36728
36728
|
}
|
|
36729
36729
|
if (this.ignoreTrailingSlash) {
|
|
36730
|
-
|
|
36730
|
+
path11 = trimLastSlash(path11);
|
|
36731
36731
|
}
|
|
36732
|
-
const originPath =
|
|
36732
|
+
const originPath = path11;
|
|
36733
36733
|
if (this.caseSensitive === false) {
|
|
36734
|
-
|
|
36734
|
+
path11 = path11.toLowerCase();
|
|
36735
36735
|
}
|
|
36736
36736
|
const maxParamLength = this.maxParamLength;
|
|
36737
36737
|
let pathIndex = currentNode.prefix.length;
|
|
36738
36738
|
const params = [];
|
|
36739
|
-
const pathLen =
|
|
36739
|
+
const pathLen = path11.length;
|
|
36740
36740
|
const brothersNodesStack = [];
|
|
36741
36741
|
let maxParamLengthExceeded = false;
|
|
36742
36742
|
while (true) {
|
|
@@ -36751,7 +36751,7 @@ var require_find_my_way = __commonJS({
|
|
|
36751
36751
|
};
|
|
36752
36752
|
}
|
|
36753
36753
|
}
|
|
36754
|
-
let node = currentNode.getNextNode(
|
|
36754
|
+
let node = currentNode.getNextNode(path11, pathIndex, brothersNodesStack, params.length);
|
|
36755
36755
|
if (node === null) {
|
|
36756
36756
|
if (brothersNodesStack.length === 0) {
|
|
36757
36757
|
if (maxParamLengthExceeded && this.onMaxParamLength) {
|
|
@@ -36852,8 +36852,8 @@ var require_find_my_way = __commonJS({
|
|
|
36852
36852
|
Router.prototype._rebuild = function(routes) {
|
|
36853
36853
|
this.reset();
|
|
36854
36854
|
for (const route of routes) {
|
|
36855
|
-
const { method, path:
|
|
36856
|
-
this._on(method,
|
|
36855
|
+
const { method, path: path11, opts, handler, store } = route;
|
|
36856
|
+
this._on(method, path11, opts, handler, store);
|
|
36857
36857
|
}
|
|
36858
36858
|
};
|
|
36859
36859
|
Router.prototype._defaultRoute = function(req, res, ctx) {
|
|
@@ -36864,24 +36864,24 @@ var require_find_my_way = __commonJS({
|
|
|
36864
36864
|
res.end();
|
|
36865
36865
|
}
|
|
36866
36866
|
};
|
|
36867
|
-
Router.prototype._onBadUrl = function(
|
|
36867
|
+
Router.prototype._onBadUrl = function(path11) {
|
|
36868
36868
|
if (this.onBadUrl === null) {
|
|
36869
36869
|
return null;
|
|
36870
36870
|
}
|
|
36871
36871
|
const onBadUrl = this.onBadUrl;
|
|
36872
36872
|
return {
|
|
36873
|
-
handler: (req, res, ctx) => onBadUrl(
|
|
36873
|
+
handler: (req, res, ctx) => onBadUrl(path11, req, res),
|
|
36874
36874
|
params: {},
|
|
36875
36875
|
store: null
|
|
36876
36876
|
};
|
|
36877
36877
|
};
|
|
36878
|
-
Router.prototype._onMaxParamLength = function(
|
|
36878
|
+
Router.prototype._onMaxParamLength = function(path11) {
|
|
36879
36879
|
if (this.onMaxParamLength === null) {
|
|
36880
36880
|
return null;
|
|
36881
36881
|
}
|
|
36882
36882
|
const onMaxParamLength = this.onMaxParamLength;
|
|
36883
36883
|
return {
|
|
36884
|
-
handler: (req, res, ctx) => onMaxParamLength(
|
|
36884
|
+
handler: (req, res, ctx) => onMaxParamLength(path11, req, res),
|
|
36885
36885
|
params: {},
|
|
36886
36886
|
store: null
|
|
36887
36887
|
};
|
|
@@ -36913,12 +36913,12 @@ var require_find_my_way = __commonJS({
|
|
|
36913
36913
|
if (!httpMethods.hasOwnProperty(i)) continue;
|
|
36914
36914
|
const m = httpMethods[i];
|
|
36915
36915
|
const methodName = m.toLowerCase();
|
|
36916
|
-
Router.prototype[methodName] = function(
|
|
36917
|
-
return this.on(m,
|
|
36916
|
+
Router.prototype[methodName] = function(path11, handler, store) {
|
|
36917
|
+
return this.on(m, path11, handler, store);
|
|
36918
36918
|
};
|
|
36919
36919
|
}
|
|
36920
|
-
Router.prototype.all = function(
|
|
36921
|
-
this.on(httpMethods,
|
|
36920
|
+
Router.prototype.all = function(path11, handler, store) {
|
|
36921
|
+
this.on(httpMethods, path11, handler, store);
|
|
36922
36922
|
};
|
|
36923
36923
|
Router.sanitizeUrlPath = function sanitizeUrlPath(url, useSemicolonDelimiter) {
|
|
36924
36924
|
const decoded = safeDecodeURI(url, useSemicolonDelimiter);
|
|
@@ -36933,14 +36933,14 @@ var require_find_my_way = __commonJS({
|
|
|
36933
36933
|
function escapeRegExp(string) {
|
|
36934
36934
|
return string.replace(ESCAPE_REGEXP, "\\$&");
|
|
36935
36935
|
}
|
|
36936
|
-
function removeDuplicateSlashes(
|
|
36937
|
-
return
|
|
36936
|
+
function removeDuplicateSlashes(path11) {
|
|
36937
|
+
return path11.indexOf("//") !== -1 ? path11.replace(REMOVE_DUPLICATE_SLASHES_REGEXP, "/") : path11;
|
|
36938
36938
|
}
|
|
36939
|
-
function trimLastSlash(
|
|
36940
|
-
if (
|
|
36941
|
-
return
|
|
36939
|
+
function trimLastSlash(path11) {
|
|
36940
|
+
if (path11.length > 1 && path11.charCodeAt(path11.length - 1) === 47) {
|
|
36941
|
+
return path11.slice(0, -1);
|
|
36942
36942
|
}
|
|
36943
|
-
return
|
|
36943
|
+
return path11;
|
|
36944
36944
|
}
|
|
36945
36945
|
function trimRegExpStartAndEnd(regexString) {
|
|
36946
36946
|
if (regexString.charCodeAt(1) === 94) {
|
|
@@ -36951,22 +36951,22 @@ var require_find_my_way = __commonJS({
|
|
|
36951
36951
|
}
|
|
36952
36952
|
return regexString;
|
|
36953
36953
|
}
|
|
36954
|
-
function getClosingParenthensePosition(
|
|
36954
|
+
function getClosingParenthensePosition(path11, idx) {
|
|
36955
36955
|
let parentheses = 1;
|
|
36956
|
-
while (idx <
|
|
36956
|
+
while (idx < path11.length) {
|
|
36957
36957
|
idx++;
|
|
36958
|
-
if (
|
|
36958
|
+
if (path11.charCodeAt(idx) === 92) {
|
|
36959
36959
|
idx++;
|
|
36960
36960
|
continue;
|
|
36961
36961
|
}
|
|
36962
|
-
if (
|
|
36962
|
+
if (path11.charCodeAt(idx) === 41) {
|
|
36963
36963
|
parentheses--;
|
|
36964
|
-
} else if (
|
|
36964
|
+
} else if (path11.charCodeAt(idx) === 40) {
|
|
36965
36965
|
parentheses++;
|
|
36966
36966
|
}
|
|
36967
36967
|
if (!parentheses) return idx;
|
|
36968
36968
|
}
|
|
36969
|
-
throw new TypeError('Invalid regexp expression in "' +
|
|
36969
|
+
throw new TypeError('Invalid regexp expression in "' + path11 + '"');
|
|
36970
36970
|
}
|
|
36971
36971
|
function defaultBuildPrettyMeta(route) {
|
|
36972
36972
|
if (!route) return {};
|
|
@@ -37199,12 +37199,12 @@ var require_route = __commonJS({
|
|
|
37199
37199
|
function route({ options: options2, isFastify }) {
|
|
37200
37200
|
throwIfAlreadyStarted("Cannot add route!");
|
|
37201
37201
|
const opts = { ...options2 };
|
|
37202
|
-
const
|
|
37202
|
+
const path11 = opts.url || opts.path || "";
|
|
37203
37203
|
if (!opts.handler) {
|
|
37204
|
-
throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method,
|
|
37204
|
+
throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method, path11);
|
|
37205
37205
|
}
|
|
37206
37206
|
if (opts.errorHandler !== void 0 && typeof opts.errorHandler !== "function") {
|
|
37207
|
-
throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method,
|
|
37207
|
+
throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method, path11);
|
|
37208
37208
|
}
|
|
37209
37209
|
validateBodyLimitOption(opts.bodyLimit);
|
|
37210
37210
|
validateHandlerTimeoutOption(opts.handlerTimeout);
|
|
@@ -37214,22 +37214,22 @@ var require_route = __commonJS({
|
|
|
37214
37214
|
if (Array.isArray(opts.method)) {
|
|
37215
37215
|
for (let i = 0; i < opts.method.length; ++i) {
|
|
37216
37216
|
opts.method[i] = normalizeAndValidateMethod.call(this, opts.method[i]);
|
|
37217
|
-
validateSchemaBodyOption.call(this, opts.method[i],
|
|
37217
|
+
validateSchemaBodyOption.call(this, opts.method[i], path11, opts.schema);
|
|
37218
37218
|
isGetRoute = opts.method.includes("GET");
|
|
37219
37219
|
isHeadRoute = opts.method.includes("HEAD");
|
|
37220
37220
|
}
|
|
37221
37221
|
} else {
|
|
37222
37222
|
opts.method = normalizeAndValidateMethod.call(this, opts.method);
|
|
37223
|
-
validateSchemaBodyOption.call(this, opts.method,
|
|
37223
|
+
validateSchemaBodyOption.call(this, opts.method, path11, opts.schema);
|
|
37224
37224
|
isGetRoute = opts.method === "GET";
|
|
37225
37225
|
isHeadRoute = opts.method === "HEAD";
|
|
37226
37226
|
}
|
|
37227
37227
|
const headOpts = shouldExposeHead && isGetRoute ? { ...options2 } : null;
|
|
37228
37228
|
const prefix = this[kRoutePrefix];
|
|
37229
|
-
if (
|
|
37229
|
+
if (path11 === "/" && prefix.length > 0 && opts.method !== "HEAD") {
|
|
37230
37230
|
switch (opts.prefixTrailingSlash) {
|
|
37231
37231
|
case "slash":
|
|
37232
|
-
addNewRoute.call(this, { path:
|
|
37232
|
+
addNewRoute.call(this, { path: path11, isFastify });
|
|
37233
37233
|
break;
|
|
37234
37234
|
case "no-slash":
|
|
37235
37235
|
addNewRoute.call(this, { path: "", isFastify });
|
|
@@ -37238,20 +37238,20 @@ var require_route = __commonJS({
|
|
|
37238
37238
|
default:
|
|
37239
37239
|
addNewRoute.call(this, { path: "", isFastify });
|
|
37240
37240
|
if (ignoreTrailingSlash !== true && (ignoreDuplicateSlashes !== true || !prefix.endsWith("/"))) {
|
|
37241
|
-
addNewRoute.call(this, { path:
|
|
37241
|
+
addNewRoute.call(this, { path: path11, prefixing: true, isFastify });
|
|
37242
37242
|
}
|
|
37243
37243
|
}
|
|
37244
|
-
} else if (
|
|
37245
|
-
addNewRoute.call(this, { path:
|
|
37244
|
+
} else if (path11[0] === "/" && prefix.endsWith("/")) {
|
|
37245
|
+
addNewRoute.call(this, { path: path11.slice(1), isFastify });
|
|
37246
37246
|
} else {
|
|
37247
|
-
addNewRoute.call(this, { path:
|
|
37247
|
+
addNewRoute.call(this, { path: path11, isFastify });
|
|
37248
37248
|
}
|
|
37249
37249
|
return this;
|
|
37250
|
-
function addNewRoute({ path:
|
|
37251
|
-
const url = prefix +
|
|
37250
|
+
function addNewRoute({ path: path12, prefixing = false, isFastify: isFastify2 = false }) {
|
|
37251
|
+
const url = prefix + path12;
|
|
37252
37252
|
opts.url = url;
|
|
37253
37253
|
opts.path = url;
|
|
37254
|
-
opts.routePath =
|
|
37254
|
+
opts.routePath = path12;
|
|
37255
37255
|
opts.prefix = prefix;
|
|
37256
37256
|
opts.logLevel = opts.logLevel || this[kLogLevel];
|
|
37257
37257
|
validateLogLevelOption(opts.logLevel, opts.method, opts.url, logger);
|
|
@@ -37383,7 +37383,7 @@ var require_route = __commonJS({
|
|
|
37383
37383
|
});
|
|
37384
37384
|
if (shouldExposeHead && isGetRoute && !isHeadRoute && !hasHEADHandler) {
|
|
37385
37385
|
const onSendHandlers = parseHeadOnSendHandlers(headOpts.onSend);
|
|
37386
|
-
prepareRoute.call(this, { method: "HEAD", url:
|
|
37386
|
+
prepareRoute.call(this, { method: "HEAD", url: path12, options: { ...headOpts, onSend: onSendHandlers }, isFastify: true });
|
|
37387
37387
|
}
|
|
37388
37388
|
}
|
|
37389
37389
|
}
|
|
@@ -37507,9 +37507,9 @@ var require_route = __commonJS({
|
|
|
37507
37507
|
}
|
|
37508
37508
|
return method;
|
|
37509
37509
|
}
|
|
37510
|
-
function validateSchemaBodyOption(method,
|
|
37510
|
+
function validateSchemaBodyOption(method, path11, schema) {
|
|
37511
37511
|
if (this[kSupportedHTTPMethods].bodyless.has(method) && schema?.body) {
|
|
37512
|
-
throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method,
|
|
37512
|
+
throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method, path11);
|
|
37513
37513
|
}
|
|
37514
37514
|
}
|
|
37515
37515
|
function validateBodyLimitOption(bodyLimit) {
|
|
@@ -37524,11 +37524,11 @@ var require_route = __commonJS({
|
|
|
37524
37524
|
throw new FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT(handlerTimeout);
|
|
37525
37525
|
}
|
|
37526
37526
|
}
|
|
37527
|
-
function validateLogLevelOption(logLevel, method,
|
|
37527
|
+
function validateLogLevelOption(logLevel, method, path11, logger) {
|
|
37528
37528
|
if (logLevel == null || logLevel === "") return;
|
|
37529
37529
|
if (logger?.levels?.values == null) return;
|
|
37530
37530
|
if (typeof logLevel !== "string" || logger.levels.values[logLevel] === void 0) {
|
|
37531
|
-
throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method,
|
|
37531
|
+
throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method, path11, logLevel);
|
|
37532
37532
|
}
|
|
37533
37533
|
}
|
|
37534
37534
|
function runPreParsing(err, request, reply) {
|
|
@@ -37617,7 +37617,7 @@ var require_four_oh_four = __commonJS({
|
|
|
37617
37617
|
});
|
|
37618
37618
|
}
|
|
37619
37619
|
function createRouteEventHandler() {
|
|
37620
|
-
return function onRouteEvent(
|
|
37620
|
+
return function onRouteEvent(path11, req, res) {
|
|
37621
37621
|
const fourOhFourContext = this[kFourOhFourLevelInstance][kFourOhFourContext];
|
|
37622
37622
|
const id = getGenReqId(fourOhFourContext.server, req);
|
|
37623
37623
|
const childLogger = createChildLogger(fourOhFourContext, logger, req, id);
|
|
@@ -40288,19 +40288,19 @@ var require_fastify = __commonJS({
|
|
|
40288
40288
|
}
|
|
40289
40289
|
fourOhFour.router.lookup(req, res);
|
|
40290
40290
|
}
|
|
40291
|
-
function onBadUrl(
|
|
40291
|
+
function onBadUrl(path11, req, res) {
|
|
40292
40292
|
if (options.frameworkErrors) {
|
|
40293
40293
|
const id = getGenReqId(routeEventContext.server, req);
|
|
40294
40294
|
const childLogger = createChildLogger(routeEventContext, options.logger, req, id);
|
|
40295
40295
|
const request = new Request(id, null, req, null, childLogger, routeEventContext);
|
|
40296
40296
|
const reply = new Reply(res, request, childLogger);
|
|
40297
40297
|
routeEventContext.server[kLogController].incomingRequest(request, reply);
|
|
40298
|
-
return options.frameworkErrors(new FST_ERR_BAD_URL(
|
|
40298
|
+
return options.frameworkErrors(new FST_ERR_BAD_URL(path11), request, reply);
|
|
40299
40299
|
}
|
|
40300
40300
|
const body = JSON.stringify({
|
|
40301
40301
|
error: "Bad Request",
|
|
40302
40302
|
code: "FST_ERR_BAD_URL",
|
|
40303
|
-
message: `'${
|
|
40303
|
+
message: `'${path11}' is not a valid url component`,
|
|
40304
40304
|
statusCode: 400
|
|
40305
40305
|
});
|
|
40306
40306
|
res.writeHead(400, {
|
|
@@ -40309,19 +40309,19 @@ var require_fastify = __commonJS({
|
|
|
40309
40309
|
});
|
|
40310
40310
|
res.end(body);
|
|
40311
40311
|
}
|
|
40312
|
-
function onMaxParamLength(
|
|
40312
|
+
function onMaxParamLength(path11, req, res) {
|
|
40313
40313
|
if (options.frameworkErrors) {
|
|
40314
40314
|
const id = getGenReqId(routeEventContext.server, req);
|
|
40315
40315
|
const childLogger = createChildLogger(routeEventContext, options.logger, req, id);
|
|
40316
40316
|
const request = new Request(id, null, req, null, childLogger, routeEventContext);
|
|
40317
40317
|
const reply = new Reply(res, request, childLogger);
|
|
40318
40318
|
routeEventContext.server[kLogController].incomingRequest(request, reply);
|
|
40319
|
-
return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(
|
|
40319
|
+
return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(path11), request, reply);
|
|
40320
40320
|
}
|
|
40321
40321
|
const body = JSON.stringify({
|
|
40322
40322
|
error: "Bad Request",
|
|
40323
40323
|
code: "FST_ERR_MAX_PARAM_LENGTH",
|
|
40324
|
-
message: `'${
|
|
40324
|
+
message: `'${path11}' is exceeding the max param length`,
|
|
40325
40325
|
statusCode: 414
|
|
40326
40326
|
});
|
|
40327
40327
|
res.writeHead(414, {
|
|
@@ -41027,8 +41027,8 @@ async function shutdownAllProviders() {
|
|
|
41027
41027
|
// src/db/index.ts
|
|
41028
41028
|
import Database from "better-sqlite3";
|
|
41029
41029
|
var db;
|
|
41030
|
-
function initDb(
|
|
41031
|
-
db = new Database(
|
|
41030
|
+
function initDb(path11 = "data.db") {
|
|
41031
|
+
db = new Database(path11);
|
|
41032
41032
|
db.pragma("journal_mode = WAL");
|
|
41033
41033
|
db.pragma("foreign_keys = ON");
|
|
41034
41034
|
createTables(db);
|
|
@@ -41121,6 +41121,7 @@ function createTables(database) {
|
|
|
41121
41121
|
workspace_path TEXT NOT NULL DEFAULT '',
|
|
41122
41122
|
pinned INTEGER NOT NULL DEFAULT 0,
|
|
41123
41123
|
state TEXT,
|
|
41124
|
+
version INTEGER NOT NULL DEFAULT 0,
|
|
41124
41125
|
created_at TEXT NOT NULL,
|
|
41125
41126
|
updated_at TEXT NOT NULL,
|
|
41126
41127
|
UNIQUE(app_id, workspace_path)
|
|
@@ -41176,6 +41177,13 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
|
|
|
41176
41177
|
if (!sessColumns.some((c) => c.name === "user_touched")) {
|
|
41177
41178
|
database.exec("ALTER TABLE sessions ADD COLUMN user_touched INTEGER NOT NULL DEFAULT 0");
|
|
41178
41179
|
}
|
|
41180
|
+
if (!sessColumns.some((c) => c.name === "import_source_id")) {
|
|
41181
|
+
database.exec("ALTER TABLE sessions ADD COLUMN import_source_id TEXT");
|
|
41182
|
+
}
|
|
41183
|
+
const appInstanceColumns = database.prepare("PRAGMA table_info(app_instances)").all();
|
|
41184
|
+
if (!appInstanceColumns.some((c) => c.name === "version")) {
|
|
41185
|
+
database.exec("ALTER TABLE app_instances ADD COLUMN version INTEGER NOT NULL DEFAULT 0");
|
|
41186
|
+
}
|
|
41179
41187
|
const turnColumns = database.prepare("PRAGMA table_info(turns)").all();
|
|
41180
41188
|
if (!turnColumns.some((c) => c.name === "thread_id")) {
|
|
41181
41189
|
database.exec("ALTER TABLE turns ADD COLUMN thread_id TEXT");
|
|
@@ -42680,8 +42688,101 @@ Agent: ${agent}`;
|
|
|
42680
42688
|
|
|
42681
42689
|
// src/routes/workspaces.ts
|
|
42682
42690
|
import { execFile } from "node:child_process";
|
|
42691
|
+
import { readdir, stat } from "node:fs/promises";
|
|
42692
|
+
import { homedir, hostname } from "node:os";
|
|
42693
|
+
import nodePath from "node:path";
|
|
42683
42694
|
import { promisify } from "node:util";
|
|
42684
42695
|
var execFileAsync = promisify(execFile);
|
|
42696
|
+
async function resolveWorkspacePath(input) {
|
|
42697
|
+
let p = input.trim();
|
|
42698
|
+
if (p === "~" || p.startsWith("~/")) p = nodePath.join(homedir(), p.slice(1));
|
|
42699
|
+
if (!nodePath.isAbsolute(p)) {
|
|
42700
|
+
return { error: "Enter the full path of a folder, e.g. ~/projects/my-app" };
|
|
42701
|
+
}
|
|
42702
|
+
p = nodePath.resolve(p);
|
|
42703
|
+
try {
|
|
42704
|
+
if (!(await stat(p)).isDirectory()) return { error: `${p} is a file, not a folder` };
|
|
42705
|
+
} catch {
|
|
42706
|
+
return { error: `There is no folder at ${p}` };
|
|
42707
|
+
}
|
|
42708
|
+
return { path: p };
|
|
42709
|
+
}
|
|
42710
|
+
var BROWSE_LIMIT = 500;
|
|
42711
|
+
var HOME_STANDARD_FOLDERS = /* @__PURE__ */ new Set([
|
|
42712
|
+
"Applications",
|
|
42713
|
+
"Desktop",
|
|
42714
|
+
"Documents",
|
|
42715
|
+
"Downloads",
|
|
42716
|
+
"Library",
|
|
42717
|
+
"Movies",
|
|
42718
|
+
"Music",
|
|
42719
|
+
"Pictures",
|
|
42720
|
+
"Public"
|
|
42721
|
+
]);
|
|
42722
|
+
async function exists(p) {
|
|
42723
|
+
try {
|
|
42724
|
+
await stat(p);
|
|
42725
|
+
return true;
|
|
42726
|
+
} catch {
|
|
42727
|
+
return false;
|
|
42728
|
+
}
|
|
42729
|
+
}
|
|
42730
|
+
async function browseFolder(input, opts = {}) {
|
|
42731
|
+
const home = opts.home ?? homedir();
|
|
42732
|
+
let dir = input?.trim() || home;
|
|
42733
|
+
if (dir === "~" || dir.startsWith("~/")) dir = nodePath.join(home, dir.slice(1));
|
|
42734
|
+
if (!nodePath.isAbsolute(dir)) return { status: 400, error: `Not a full path: ${dir}` };
|
|
42735
|
+
dir = nodePath.resolve(dir);
|
|
42736
|
+
let entries;
|
|
42737
|
+
try {
|
|
42738
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
42739
|
+
} catch (err) {
|
|
42740
|
+
const code = err.code;
|
|
42741
|
+
if (code === "ENOENT") return { status: 404, error: `There is no folder at ${dir}` };
|
|
42742
|
+
if (code === "ENOTDIR") return { status: 400, error: `${dir} is a file, not a folder` };
|
|
42743
|
+
if (code === "EACCES" || code === "EPERM") return { status: 403, error: `No permission to open ${dir}` };
|
|
42744
|
+
throw err;
|
|
42745
|
+
}
|
|
42746
|
+
const names = [];
|
|
42747
|
+
for (const entry of entries) {
|
|
42748
|
+
if (entry.name.startsWith(".")) continue;
|
|
42749
|
+
if (entry.isDirectory()) {
|
|
42750
|
+
names.push(entry.name);
|
|
42751
|
+
} else if (entry.isSymbolicLink()) {
|
|
42752
|
+
try {
|
|
42753
|
+
if ((await stat(nodePath.join(dir, entry.name))).isDirectory()) names.push(entry.name);
|
|
42754
|
+
} catch {
|
|
42755
|
+
}
|
|
42756
|
+
}
|
|
42757
|
+
}
|
|
42758
|
+
names.sort((a, b) => a.localeCompare(b, void 0, { sensitivity: "base", numeric: true }));
|
|
42759
|
+
const limit = opts.limit ?? BROWSE_LIMIT;
|
|
42760
|
+
const atHome = dir === nodePath.resolve(home);
|
|
42761
|
+
const folders = await Promise.all(
|
|
42762
|
+
names.slice(0, limit).map(async (name) => {
|
|
42763
|
+
const path11 = nodePath.join(dir, name);
|
|
42764
|
+
const skipProbe = atHome && HOME_STANDARD_FOLDERS.has(name) || dir === "/Volumes";
|
|
42765
|
+
return { name, path: path11, git: !skipProbe && await exists(nodePath.join(path11, ".git")) };
|
|
42766
|
+
})
|
|
42767
|
+
);
|
|
42768
|
+
const parent = nodePath.dirname(dir);
|
|
42769
|
+
return {
|
|
42770
|
+
path: dir,
|
|
42771
|
+
parent: parent === dir ? null : parent,
|
|
42772
|
+
home,
|
|
42773
|
+
hostname: hostname(),
|
|
42774
|
+
folders,
|
|
42775
|
+
truncated: names.length > limit
|
|
42776
|
+
};
|
|
42777
|
+
}
|
|
42778
|
+
var LOOPBACK_HOST = /^(localhost|127(?:\.\d+){3}|\[::1\]|::1|0\.0\.0\.0)(:\d+)?$/i;
|
|
42779
|
+
function pickerAvailability(request, platform = process.platform) {
|
|
42780
|
+
const host = String(request.headers.host ?? "");
|
|
42781
|
+
const remote = Boolean(request.headers["cf-connecting-ip"]) || host !== "" && !LOOPBACK_HOST.test(host);
|
|
42782
|
+
if (remote) return { available: false, reason: "remote" };
|
|
42783
|
+
if (platform !== "darwin") return { available: false, reason: "unsupported" };
|
|
42784
|
+
return { available: true, reason: null };
|
|
42785
|
+
}
|
|
42685
42786
|
async function registerWorkspaceRoutes(fastify) {
|
|
42686
42787
|
fastify.get("/api/workspaces", async () => {
|
|
42687
42788
|
const rows = getDb().prepare("SELECT * FROM workspaces ORDER BY created_at ASC").all();
|
|
@@ -42699,11 +42800,15 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42699
42800
|
}
|
|
42700
42801
|
}
|
|
42701
42802
|
}, async (request, reply) => {
|
|
42702
|
-
const { path:
|
|
42703
|
-
if (!
|
|
42803
|
+
const { path: path11, label = null } = request.body || {};
|
|
42804
|
+
if (!path11 || !path11.trim()) {
|
|
42704
42805
|
return reply.code(400).send({ error: "Path is required" });
|
|
42705
42806
|
}
|
|
42706
|
-
const
|
|
42807
|
+
const resolved = await resolveWorkspacePath(path11);
|
|
42808
|
+
if ("error" in resolved) {
|
|
42809
|
+
return reply.code(400).send({ error: resolved.error });
|
|
42810
|
+
}
|
|
42811
|
+
const trimmedPath = resolved.path;
|
|
42707
42812
|
const db2 = getDb();
|
|
42708
42813
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
42709
42814
|
if (existing) {
|
|
@@ -42725,14 +42830,20 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42725
42830
|
const workspace = db2.prepare("SELECT * FROM workspaces WHERE id = ?").get(id);
|
|
42726
42831
|
return workspace;
|
|
42727
42832
|
});
|
|
42833
|
+
fastify.get("/api/workspaces/picker", async (request) => pickerAvailability(request));
|
|
42834
|
+
fastify.get("/api/workspaces/browse", async (request, reply) => {
|
|
42835
|
+
const result = await browseFolder(request.query.path);
|
|
42836
|
+
if ("error" in result) return reply.code(result.status).send({ error: result.error });
|
|
42837
|
+
return result;
|
|
42838
|
+
});
|
|
42728
42839
|
fastify.get("/api/pick-directory", async (_request, reply) => {
|
|
42729
42840
|
try {
|
|
42730
42841
|
const { stdout } = await execFileAsync("osascript", [
|
|
42731
42842
|
"-e",
|
|
42732
42843
|
'POSIX path of (choose folder with prompt "Select a workspace directory")'
|
|
42733
42844
|
]);
|
|
42734
|
-
const
|
|
42735
|
-
return { path:
|
|
42845
|
+
const path11 = stdout.trim().replace(/\/$/, "");
|
|
42846
|
+
return { path: path11 };
|
|
42736
42847
|
} catch {
|
|
42737
42848
|
return reply.code(204).send({ cancelled: true });
|
|
42738
42849
|
}
|
|
@@ -42748,11 +42859,11 @@ async function registerWorkspaceRoutes(fastify) {
|
|
|
42748
42859
|
}
|
|
42749
42860
|
}
|
|
42750
42861
|
}, async (request, reply) => {
|
|
42751
|
-
const { path:
|
|
42752
|
-
if (!
|
|
42862
|
+
const { path: path11 } = request.body || {};
|
|
42863
|
+
if (!path11 || !path11.trim()) {
|
|
42753
42864
|
return reply.code(400).send({ error: "Path is required" });
|
|
42754
42865
|
}
|
|
42755
|
-
const trimmedPath =
|
|
42866
|
+
const trimmedPath = path11.trim();
|
|
42756
42867
|
const db2 = getDb();
|
|
42757
42868
|
const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
|
|
42758
42869
|
if (existing) {
|
|
@@ -43357,12 +43468,12 @@ async function registerFileRoutes(fastify) {
|
|
|
43357
43468
|
|
|
43358
43469
|
// src/routes/perf-log.ts
|
|
43359
43470
|
import { appendFileSync, mkdirSync, renameSync, statSync } from "node:fs";
|
|
43360
|
-
import { homedir } from "node:os";
|
|
43471
|
+
import { homedir as homedir2 } from "node:os";
|
|
43361
43472
|
import { dirname, join } from "node:path";
|
|
43362
43473
|
var MAX_BYTES = 5 * 1024 * 1024;
|
|
43363
43474
|
var MAX_BATCH = 500;
|
|
43364
43475
|
function perfLogPath() {
|
|
43365
|
-
return process.env.AGENT_PANE_PERF_LOG ?? join(
|
|
43476
|
+
return process.env.AGENT_PANE_PERF_LOG ?? join(homedir2(), ".repoburg", "agent-pane", "perf.log");
|
|
43366
43477
|
}
|
|
43367
43478
|
function oneLine(s) {
|
|
43368
43479
|
return s.replace(/[\r\n\t]+/g, " ");
|
|
@@ -43399,17 +43510,17 @@ async function registerPerfLogRoutes(fastify) {
|
|
|
43399
43510
|
if (entries.length === 0) {
|
|
43400
43511
|
return reply.send({ written: 0 });
|
|
43401
43512
|
}
|
|
43402
|
-
const
|
|
43513
|
+
const path11 = perfLogPath();
|
|
43403
43514
|
try {
|
|
43404
|
-
mkdirSync(dirname(
|
|
43515
|
+
mkdirSync(dirname(path11), { recursive: true });
|
|
43405
43516
|
try {
|
|
43406
|
-
if (statSync(
|
|
43407
|
-
renameSync(
|
|
43517
|
+
if (statSync(path11).size > MAX_BYTES) {
|
|
43518
|
+
renameSync(path11, `${path11}.1`);
|
|
43408
43519
|
}
|
|
43409
43520
|
} catch {
|
|
43410
43521
|
}
|
|
43411
43522
|
const lines = entries.map((e) => `${new Date(e.t).toISOString()} [${oneLine(e.cat)}] ${oneLine(e.msg)}`).join("\n");
|
|
43412
|
-
appendFileSync(
|
|
43523
|
+
appendFileSync(path11, `${lines}
|
|
43413
43524
|
`, "utf-8");
|
|
43414
43525
|
return reply.send({ written: entries.length });
|
|
43415
43526
|
} catch (err) {
|
|
@@ -43487,7 +43598,7 @@ import net from "node:net";
|
|
|
43487
43598
|
import crypto from "node:crypto";
|
|
43488
43599
|
import os from "node:os";
|
|
43489
43600
|
import path2 from "node:path";
|
|
43490
|
-
import { mkdir, readdir, symlink, lstat, access, readFile, writeFile, unlink } from "node:fs/promises";
|
|
43601
|
+
import { mkdir, readdir as readdir2, symlink, lstat, access, readFile, writeFile, unlink } from "node:fs/promises";
|
|
43491
43602
|
var VSCODE_WEB_DATA_DIR = path2.join(os.homedir(), ".repoburg", "vscode-web");
|
|
43492
43603
|
function resolveDesktopUserDir() {
|
|
43493
43604
|
if (process.platform === "darwin") {
|
|
@@ -43520,7 +43631,7 @@ async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
|
|
|
43520
43631
|
const desktopExt = path2.join(os.homedir(), ".vscode", "extensions");
|
|
43521
43632
|
let entries;
|
|
43522
43633
|
try {
|
|
43523
|
-
entries = await
|
|
43634
|
+
entries = await readdir2(desktopExt, { withFileTypes: true });
|
|
43524
43635
|
} catch {
|
|
43525
43636
|
return;
|
|
43526
43637
|
}
|
|
@@ -98299,7 +98410,8 @@ Icons come from ONE library: Lucide (https://lucide.dev/icons, ISC).
|
|
|
98299
98410
|
## Bridge API (window.AgentPane)
|
|
98300
98411
|
|
|
98301
98412
|
- getApp() - app info (id, title)
|
|
98302
|
-
- getState() / setState(data) - persistent JSON state, survives page reload
|
|
98413
|
+
- getState() / setState(data, { ifVersion }?) - persistent JSON state, survives page reload; getState reads the stored copy on every call (see "Shared state" below)
|
|
98414
|
+
- onStateChanged(callback) - callback({ version }) when somebody else (an agent, another tab) wrote the state; not fired for this tab's own setState
|
|
98303
98415
|
- 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
|
|
98304
98416
|
- 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)
|
|
98305
98417
|
- onTurnCompleted(callback) - callback(event, { turnId, response }) when a turn ends
|
|
@@ -98311,6 +98423,23 @@ Icons come from ONE library: Lucide (https://lucide.dev/icons, ISC).
|
|
|
98311
98423
|
- getFile(ref) - metadata of a stored file ({ id, url, path, type, size }), null when ref (id or url) names no file of this app
|
|
98312
98424
|
- fileUrl(ref) - synchronous URL to load a stored file from in this pane; any other string comes back unchanged
|
|
98313
98425
|
|
|
98426
|
+
## Shared state
|
|
98427
|
+
|
|
98428
|
+
One state instance (app + workspace) has several writers: this tab, other
|
|
98429
|
+
tabs on the same workspace, the headless runtime (agent tool calls) and
|
|
98430
|
+
agents writing over REST.
|
|
98431
|
+
- on onStateChanged, re-read with getState() and re-render
|
|
98432
|
+
- read-modify-write: apply the change to the data of a fresh getState()
|
|
98433
|
+
and save with setState(data, { ifVersion: state.version }). When
|
|
98434
|
+
somebody wrote in between, nothing is written and the promise rejects
|
|
98435
|
+
with error.code === 'conflict' (error.state = the stored state now):
|
|
98436
|
+
apply the change to error.state.data and retry with its version
|
|
98437
|
+
- never write back an old in-memory copy without ifVersion: it silently
|
|
98438
|
+
replaces whatever an agent wrote since
|
|
98439
|
+
- agents writing over REST do the same: GET /api/apps/<id>/state?workspace=<key>,
|
|
98440
|
+
then PUT { "data": ..., "ifVersion": <version from the GET> };
|
|
98441
|
+
409 = re-read and retry
|
|
98442
|
+
|
|
98314
98443
|
## Files and images
|
|
98315
98444
|
|
|
98316
98445
|
uploadFile stores images (PNG, JPEG, GIF or WebP, max 5 MB) for the app,
|
|
@@ -98451,6 +98580,15 @@ function stopAppsWatch() {
|
|
|
98451
98580
|
}
|
|
98452
98581
|
|
|
98453
98582
|
// src/apps/instances.ts
|
|
98583
|
+
var StateConflictError = class extends Error {
|
|
98584
|
+
/** The stored state the write was checked against. */
|
|
98585
|
+
current;
|
|
98586
|
+
constructor(expected, current) {
|
|
98587
|
+
super(`App state changed: the write expected version ${expected}, the stored copy is at version ${current.version}`);
|
|
98588
|
+
this.name = "StateConflictError";
|
|
98589
|
+
this.current = current;
|
|
98590
|
+
}
|
|
98591
|
+
};
|
|
98454
98592
|
function rowToState(row) {
|
|
98455
98593
|
let data = null;
|
|
98456
98594
|
try {
|
|
@@ -98458,41 +98596,63 @@ function rowToState(row) {
|
|
|
98458
98596
|
if (parsed && typeof parsed === "object") data = parsed;
|
|
98459
98597
|
} catch {
|
|
98460
98598
|
}
|
|
98461
|
-
return { pinned: row.pinned === 1, data };
|
|
98599
|
+
return { pinned: row.pinned === 1, data, version: row.version ?? 0 };
|
|
98462
98600
|
}
|
|
98463
98601
|
function writeRow(appId, workspace, state) {
|
|
98464
98602
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
98465
98603
|
getDb().prepare(
|
|
98466
|
-
`INSERT INTO app_instances (id, app_id, workspace_path, pinned, state, created_at, updated_at)
|
|
98467
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
98604
|
+
`INSERT INTO app_instances (id, app_id, workspace_path, pinned, state, version, created_at, updated_at)
|
|
98605
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
98468
98606
|
ON CONFLICT(app_id, workspace_path) DO UPDATE SET
|
|
98469
|
-
pinned = excluded.pinned, state = excluded.state,
|
|
98470
|
-
|
|
98607
|
+
pinned = excluded.pinned, state = excluded.state, version = excluded.version,
|
|
98608
|
+
updated_at = excluded.updated_at`
|
|
98609
|
+
).run(
|
|
98610
|
+
v4_default(),
|
|
98611
|
+
appId,
|
|
98612
|
+
workspace,
|
|
98613
|
+
state.pinned ? 1 : 0,
|
|
98614
|
+
JSON.stringify(state.data ?? null),
|
|
98615
|
+
state.version,
|
|
98616
|
+
now,
|
|
98617
|
+
now
|
|
98618
|
+
);
|
|
98619
|
+
}
|
|
98620
|
+
var EMPTY_STATE = { pinned: false, data: null, version: 0 };
|
|
98621
|
+
function readRow(appId, workspace) {
|
|
98622
|
+
const row = getDb().prepare("SELECT * FROM app_instances WHERE app_id = ? AND workspace_path = ?").get(appId, workspace);
|
|
98623
|
+
return row ? rowToState(row) : null;
|
|
98471
98624
|
}
|
|
98472
98625
|
function getInstanceState(appId, workspace = "") {
|
|
98473
|
-
const
|
|
98474
|
-
|
|
98475
|
-
if (row) return rowToState(row);
|
|
98626
|
+
const stored = readRow(appId, workspace);
|
|
98627
|
+
if (stored) return stored;
|
|
98476
98628
|
if (workspace === "") {
|
|
98477
98629
|
const legacyFile = path4.join(appDir(appId), "state.json");
|
|
98478
98630
|
if (fs2.existsSync(legacyFile)) {
|
|
98479
|
-
const
|
|
98631
|
+
const legacy = readState(appId);
|
|
98632
|
+
const imported = { pinned: legacy.pinned, data: legacy.data, version: 1 };
|
|
98480
98633
|
writeRow(appId, "", imported);
|
|
98481
98634
|
fs2.rmSync(legacyFile, { force: true });
|
|
98482
98635
|
return imported;
|
|
98483
98636
|
}
|
|
98484
98637
|
}
|
|
98485
|
-
return {
|
|
98638
|
+
return { ...EMPTY_STATE };
|
|
98486
98639
|
}
|
|
98487
98640
|
function updateInstanceState(appId, workspace, patch) {
|
|
98488
|
-
|
|
98489
|
-
|
|
98490
|
-
|
|
98491
|
-
|
|
98492
|
-
|
|
98493
|
-
|
|
98494
|
-
|
|
98495
|
-
|
|
98641
|
+
getInstanceState(appId, workspace);
|
|
98642
|
+
return getDb().transaction(() => {
|
|
98643
|
+
const current = readRow(appId, workspace) ?? { ...EMPTY_STATE };
|
|
98644
|
+
const { pinned, data, ifVersion } = patch;
|
|
98645
|
+
if (typeof ifVersion === "number" && ifVersion !== current.version) {
|
|
98646
|
+
throw new StateConflictError(ifVersion, current);
|
|
98647
|
+
}
|
|
98648
|
+
const next = {
|
|
98649
|
+
pinned: typeof pinned === "boolean" ? pinned : current.pinned,
|
|
98650
|
+
data: data === void 0 ? current.data : data !== null && typeof data === "object" ? data : null,
|
|
98651
|
+
version: data === void 0 ? current.version : current.version + 1
|
|
98652
|
+
};
|
|
98653
|
+
writeRow(appId, workspace, next);
|
|
98654
|
+
return next;
|
|
98655
|
+
}).immediate();
|
|
98496
98656
|
}
|
|
98497
98657
|
function deleteAppInstances(appId) {
|
|
98498
98658
|
getDb().prepare("DELETE FROM app_instances WHERE app_id = ?").run(appId);
|
|
@@ -98573,7 +98733,27 @@ var APP_TS = "app.ts";
|
|
|
98573
98733
|
var BRIDGE_DTS_FILE = "agentpane.d.ts";
|
|
98574
98734
|
var BRIDGE_DTS = `/** AgentPane bridge \u2014 typed contract for mini apps (ambient, no import). */
|
|
98575
98735
|
interface AgentPaneAppInfo { id: string; title?: string }
|
|
98576
|
-
interface AgentPaneState {
|
|
98736
|
+
interface AgentPaneState {
|
|
98737
|
+
pinned: boolean;
|
|
98738
|
+
data: Record<string, unknown> | null;
|
|
98739
|
+
/** Data writes the instance has seen (0 = never written); pass it to
|
|
98740
|
+
* setState as ifVersion. Absent on panes without versioned state. */
|
|
98741
|
+
version?: number;
|
|
98742
|
+
}
|
|
98743
|
+
interface AgentPaneSetStateOptions {
|
|
98744
|
+
/** Write only while the stored copy is still at this version (from
|
|
98745
|
+
* getState/setState); otherwise setState rejects with an
|
|
98746
|
+
* AgentPaneStateConflict and nothing is written. */
|
|
98747
|
+
ifVersion?: number;
|
|
98748
|
+
}
|
|
98749
|
+
/** setState rejection when ifVersion no longer matches: re-read, re-apply, retry. */
|
|
98750
|
+
interface AgentPaneStateConflict extends Error {
|
|
98751
|
+
code: 'conflict';
|
|
98752
|
+
/** The stored state now. */
|
|
98753
|
+
state: AgentPaneState;
|
|
98754
|
+
}
|
|
98755
|
+
/** onStateChanged payload: somebody else (agent, another tab) wrote this instance. */
|
|
98756
|
+
interface AgentPaneStateChangedPayload { version?: number }
|
|
98577
98757
|
interface AgentPaneSessionInfo { id: string; title?: string | null }
|
|
98578
98758
|
interface AgentPaneCreateSessionOptions {
|
|
98579
98759
|
title?: string;
|
|
@@ -98620,15 +98800,21 @@ interface AgentPaneSubmitTurnOptions {
|
|
|
98620
98800
|
|
|
98621
98801
|
declare const AgentPane: {
|
|
98622
98802
|
getApp(): Promise<AgentPaneAppInfo>;
|
|
98803
|
+
/** The stored state, read fresh from the pane on every call. */
|
|
98623
98804
|
getState(): Promise<AgentPaneState>;
|
|
98624
|
-
|
|
98805
|
+
/** Replace the stored data. With opts.ifVersion it rejects with an
|
|
98806
|
+
* AgentPaneStateConflict (error.code === 'conflict') instead of
|
|
98807
|
+
* overwriting a newer copy. */
|
|
98808
|
+
setState(data: Record<string, unknown> | null, opts?: AgentPaneSetStateOptions): Promise<AgentPaneState>;
|
|
98625
98809
|
createSession(opts?: AgentPaneCreateSessionOptions): Promise<AgentPaneSessionInfo>;
|
|
98626
98810
|
/** Send a prompt to a session; opts.attachments go with it (the agent sees images). */
|
|
98627
98811
|
submitTurn(sessionId: string, prompt: string, opts?: AgentPaneSubmitTurnOptions): Promise<unknown>;
|
|
98628
98812
|
onTurnCompleted(cb: (event: 'turn:completed' | 'turn:failed', payload: AgentPaneTurnPayload | null) => void): void;
|
|
98629
98813
|
onTurnDelta(cb: (payload: AgentPaneDeltaPayload) => void): void;
|
|
98630
98814
|
onToolCall(cb: (payload: AgentPaneToolCallPayload) => void): void;
|
|
98631
|
-
|
|
98815
|
+
/** Somebody else wrote this instance (an agent, another tab); not fired
|
|
98816
|
+
* for this tab's own setState. Re-read with getState. */
|
|
98817
|
+
onStateChanged(cb: (payload: AgentPaneStateChangedPayload) => void): void;
|
|
98632
98818
|
/** Fires when the live background-task set of one of the app's sessions
|
|
98633
98819
|
* changes (also empty sets, when the last task ends). */
|
|
98634
98820
|
onBackgroundTasks(cb: (payload: AgentPaneBackgroundTasksPayload | null) => void): void;
|
|
@@ -98987,9 +99173,9 @@ function getAppFile(appId, ref) {
|
|
|
98987
99173
|
if (!fileId) return null;
|
|
98988
99174
|
const file = path6.join(appFilesDir(appId), fileId);
|
|
98989
99175
|
try {
|
|
98990
|
-
const
|
|
98991
|
-
if (!
|
|
98992
|
-
return { id: fileId, url: appFileUrl(appId, fileId), path: file, type: fileType(fileId), size:
|
|
99176
|
+
const stat2 = fs3.statSync(file);
|
|
99177
|
+
if (!stat2.isFile()) return null;
|
|
99178
|
+
return { id: fileId, url: appFileUrl(appId, fileId), path: file, type: fileType(fileId), size: stat2.size };
|
|
98993
99179
|
} catch {
|
|
98994
99180
|
return null;
|
|
98995
99181
|
}
|
|
@@ -99044,9 +99230,23 @@ function getHeadlessToolHandler(appId, workspace = "") {
|
|
|
99044
99230
|
// State is scoped to the calling session's workspace instance; '' = global
|
|
99045
99231
|
// (no known workspace). The open tab keeps its own workspace-scoped view.
|
|
99046
99232
|
getState: () => Promise.resolve(getInstanceState(appId, workspace)),
|
|
99047
|
-
|
|
99048
|
-
|
|
99049
|
-
|
|
99233
|
+
// opts.ifVersion: write only on top of that version — same contract as
|
|
99234
|
+
// the iframe bridge (rejects with code 'conflict' + the stored state).
|
|
99235
|
+
setState: (data, opts) => {
|
|
99236
|
+
const ifVersion = opts?.ifVersion;
|
|
99237
|
+
let next;
|
|
99238
|
+
try {
|
|
99239
|
+
next = updateInstanceState(appId, workspace, {
|
|
99240
|
+
data,
|
|
99241
|
+
ifVersion: typeof ifVersion === "number" ? ifVersion : void 0
|
|
99242
|
+
});
|
|
99243
|
+
} catch (err) {
|
|
99244
|
+
if (err instanceof StateConflictError) {
|
|
99245
|
+
return Promise.reject(Object.assign(new Error(err.message), { code: "conflict", state: err.current }));
|
|
99246
|
+
}
|
|
99247
|
+
return Promise.reject(err);
|
|
99248
|
+
}
|
|
99249
|
+
broadcast("app:state_changed", { appId, workspace, version: next.version });
|
|
99050
99250
|
return Promise.resolve(next);
|
|
99051
99251
|
},
|
|
99052
99252
|
onToolCall: (cb) => {
|
|
@@ -99522,7 +99722,9 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
99522
99722
|
type: "object",
|
|
99523
99723
|
properties: {
|
|
99524
99724
|
pinned: { type: "boolean" },
|
|
99525
|
-
data: { type: ["object", "null"] }
|
|
99725
|
+
data: { type: ["object", "null"] },
|
|
99726
|
+
ifVersion: { type: "integer", minimum: 0 },
|
|
99727
|
+
writer: { type: "string", maxLength: 200 }
|
|
99526
99728
|
}
|
|
99527
99729
|
}
|
|
99528
99730
|
}
|
|
@@ -99531,7 +99733,23 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
99531
99733
|
const { id } = request.params;
|
|
99532
99734
|
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
99533
99735
|
if (!readManifest(id)) return reply.code(404).send({ error: "App not found" });
|
|
99534
|
-
|
|
99736
|
+
const workspace = request.query?.workspace ?? "";
|
|
99737
|
+
const { pinned, data, ifVersion, writer } = request.body || {};
|
|
99738
|
+
let next;
|
|
99739
|
+
try {
|
|
99740
|
+
next = updateInstanceState(id, workspace, { pinned, data, ifVersion });
|
|
99741
|
+
} catch (err) {
|
|
99742
|
+
if (err instanceof StateConflictError) {
|
|
99743
|
+
return reply.code(409).send({ error: err.message, state: err.current });
|
|
99744
|
+
}
|
|
99745
|
+
throw err;
|
|
99746
|
+
}
|
|
99747
|
+
if (data !== void 0) {
|
|
99748
|
+
const change = { appId: id, workspace, version: next.version };
|
|
99749
|
+
if (writer) change.writer = writer;
|
|
99750
|
+
broadcast("app:state_changed", change);
|
|
99751
|
+
}
|
|
99752
|
+
return next;
|
|
99535
99753
|
}
|
|
99536
99754
|
);
|
|
99537
99755
|
fastify.post(
|
|
@@ -99642,13 +99860,13 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
99642
99860
|
|
|
99643
99861
|
// src/sidecar/transcript-locator.ts
|
|
99644
99862
|
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
99645
|
-
import { homedir as
|
|
99863
|
+
import { homedir as homedir3 } from "node:os";
|
|
99646
99864
|
import { join as join2 } from "node:path";
|
|
99647
99865
|
function claudeConfigDir() {
|
|
99648
|
-
return process.env.CLAUDE_CONFIG_DIR || join2(
|
|
99866
|
+
return process.env.CLAUDE_CONFIG_DIR || join2(homedir3(), ".claude");
|
|
99649
99867
|
}
|
|
99650
99868
|
function codexHome() {
|
|
99651
|
-
return process.env.CODEX_HOME || join2(
|
|
99869
|
+
return process.env.CODEX_HOME || join2(homedir3(), ".codex");
|
|
99652
99870
|
}
|
|
99653
99871
|
function encodeClaudeProjectDir(cwd) {
|
|
99654
99872
|
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
@@ -99771,7 +99989,7 @@ async function registerSidecarRoutes(fastify) {
|
|
|
99771
99989
|
|
|
99772
99990
|
// src/usage/usage-service.ts
|
|
99773
99991
|
import { readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
99774
|
-
import { homedir as
|
|
99992
|
+
import { homedir as homedir4 } from "node:os";
|
|
99775
99993
|
import { join as join3 } from "node:path";
|
|
99776
99994
|
|
|
99777
99995
|
// src/usage/usage-pricing.ts
|
|
@@ -99836,7 +100054,7 @@ function computeCost(modelId, usage, inputIncludesCached) {
|
|
|
99836
100054
|
|
|
99837
100055
|
// src/usage/usage-service.ts
|
|
99838
100056
|
function usageFilesDir() {
|
|
99839
|
-
return process.env.AGENT_PANE_USAGE_DIR ?? join3(
|
|
100057
|
+
return process.env.AGENT_PANE_USAGE_DIR ?? join3(homedir4(), ".repoburg", "usage");
|
|
99840
100058
|
}
|
|
99841
100059
|
function emptyBucket() {
|
|
99842
100060
|
return { calls: 0, errors: 0, input: 0, cached: 0, cacheWrite: 0, output: 0, cost: 0 };
|
|
@@ -100092,6 +100310,619 @@ async function registerUsageRoutes(fastify) {
|
|
|
100092
100310
|
);
|
|
100093
100311
|
}
|
|
100094
100312
|
|
|
100313
|
+
// src/claude/session-import.ts
|
|
100314
|
+
import { readFile as readFile2, realpath } from "node:fs/promises";
|
|
100315
|
+
import path8 from "node:path";
|
|
100316
|
+
import { getSessionInfo, listSessions } from "@anthropic-ai/claude-agent-sdk";
|
|
100317
|
+
|
|
100318
|
+
// src/claude/claude-message-mapper.ts
|
|
100319
|
+
function mapAssistantContent(content, messageId, thinkingTexts) {
|
|
100320
|
+
const descriptors = [];
|
|
100321
|
+
for (let i = 0; i < content.length; i++) {
|
|
100322
|
+
const block = content[i];
|
|
100323
|
+
switch (block.type) {
|
|
100324
|
+
case "text": {
|
|
100325
|
+
const tb = block;
|
|
100326
|
+
descriptors.push({
|
|
100327
|
+
type: "agent_message",
|
|
100328
|
+
data: { text: tb.text },
|
|
100329
|
+
externalId: messageId
|
|
100330
|
+
});
|
|
100331
|
+
break;
|
|
100332
|
+
}
|
|
100333
|
+
case "thinking": {
|
|
100334
|
+
const tb = block;
|
|
100335
|
+
let text = tb.thinking;
|
|
100336
|
+
if (!text && thinkingTexts) {
|
|
100337
|
+
text = thinkingTexts.get(i) ?? "";
|
|
100338
|
+
}
|
|
100339
|
+
descriptors.push({
|
|
100340
|
+
type: "reasoning",
|
|
100341
|
+
data: { text },
|
|
100342
|
+
externalId: messageId
|
|
100343
|
+
});
|
|
100344
|
+
break;
|
|
100345
|
+
}
|
|
100346
|
+
case "tool_use": {
|
|
100347
|
+
const tu = block;
|
|
100348
|
+
const desc = mapToolUse(tu);
|
|
100349
|
+
descriptors.push(desc);
|
|
100350
|
+
break;
|
|
100351
|
+
}
|
|
100352
|
+
case "redacted_thinking":
|
|
100353
|
+
break;
|
|
100354
|
+
default:
|
|
100355
|
+
break;
|
|
100356
|
+
}
|
|
100357
|
+
}
|
|
100358
|
+
return descriptors;
|
|
100359
|
+
}
|
|
100360
|
+
function mapToolUse(block) {
|
|
100361
|
+
const input = block.input;
|
|
100362
|
+
if (block.name === "Bash") {
|
|
100363
|
+
return {
|
|
100364
|
+
type: "command_execution",
|
|
100365
|
+
data: {
|
|
100366
|
+
command: input.command ?? "",
|
|
100367
|
+
aggregated_output: null,
|
|
100368
|
+
exit_code: null,
|
|
100369
|
+
status: "in_progress"
|
|
100370
|
+
},
|
|
100371
|
+
externalId: block.id
|
|
100372
|
+
};
|
|
100373
|
+
}
|
|
100374
|
+
if (block.name === "Edit" || block.name === "Write" || block.name === "MultiEdit" || block.name === "NotebookEdit") {
|
|
100375
|
+
return {
|
|
100376
|
+
type: "file_change",
|
|
100377
|
+
data: deriveFileChangeData(input, block.name),
|
|
100378
|
+
externalId: block.id
|
|
100379
|
+
};
|
|
100380
|
+
}
|
|
100381
|
+
return {
|
|
100382
|
+
type: "mcp_tool_call",
|
|
100383
|
+
data: {
|
|
100384
|
+
server: null,
|
|
100385
|
+
tool: block.name,
|
|
100386
|
+
arguments: input,
|
|
100387
|
+
result: null,
|
|
100388
|
+
error: null,
|
|
100389
|
+
status: "in_progress"
|
|
100390
|
+
},
|
|
100391
|
+
externalId: block.id
|
|
100392
|
+
};
|
|
100393
|
+
}
|
|
100394
|
+
function deriveFileChangeData(input, toolName) {
|
|
100395
|
+
const path11 = input.file_path ?? input.notebook_path ?? "";
|
|
100396
|
+
const kind = toolName === "Write" ? "add" : "modify";
|
|
100397
|
+
return { changes: [{ path: path11, kind }], status: "in_progress" };
|
|
100398
|
+
}
|
|
100399
|
+
function extractToolResultText(content) {
|
|
100400
|
+
if (!content) return "";
|
|
100401
|
+
if (typeof content === "string") return content;
|
|
100402
|
+
if (Array.isArray(content)) {
|
|
100403
|
+
return content.map((b) => {
|
|
100404
|
+
if (b && typeof b === "object" && b.type === "text") {
|
|
100405
|
+
return String(b.text ?? "");
|
|
100406
|
+
}
|
|
100407
|
+
return "";
|
|
100408
|
+
}).filter(Boolean).join("\n");
|
|
100409
|
+
}
|
|
100410
|
+
return "";
|
|
100411
|
+
}
|
|
100412
|
+
function applyToolResult(itemType, existingData, toolResult, toolUseResult, isError) {
|
|
100413
|
+
switch (itemType) {
|
|
100414
|
+
case "command_execution": {
|
|
100415
|
+
const text = extractToolResultText(toolResult?.content);
|
|
100416
|
+
const tur = toolUseResult && typeof toolUseResult === "object" ? toolUseResult : {};
|
|
100417
|
+
const stdout = typeof tur.stdout === "string" ? tur.stdout : "";
|
|
100418
|
+
const stderr = typeof tur.stderr === "string" ? tur.stderr : "";
|
|
100419
|
+
let aggregated = text || stdout;
|
|
100420
|
+
if (stderr) aggregated = aggregated ? `${aggregated}
|
|
100421
|
+
${stderr}` : stderr;
|
|
100422
|
+
return {
|
|
100423
|
+
...existingData,
|
|
100424
|
+
aggregated_output: aggregated,
|
|
100425
|
+
exit_code: isError ? 1 : 0,
|
|
100426
|
+
status: isError ? "failed" : "completed"
|
|
100427
|
+
};
|
|
100428
|
+
}
|
|
100429
|
+
case "mcp_tool_call": {
|
|
100430
|
+
const text = extractToolResultText(toolResult?.content);
|
|
100431
|
+
return {
|
|
100432
|
+
...existingData,
|
|
100433
|
+
result: text ? [{ type: "text", text }] : toolUseResult ?? null,
|
|
100434
|
+
error: isError ? text || "Tool error" : null,
|
|
100435
|
+
status: isError ? "failed" : "completed"
|
|
100436
|
+
};
|
|
100437
|
+
}
|
|
100438
|
+
case "file_change": {
|
|
100439
|
+
return { ...existingData, status: isError ? "failed" : "completed" };
|
|
100440
|
+
}
|
|
100441
|
+
default:
|
|
100442
|
+
return existingData;
|
|
100443
|
+
}
|
|
100444
|
+
}
|
|
100445
|
+
function mapPartialDelta(event) {
|
|
100446
|
+
const e = event;
|
|
100447
|
+
if (e.type !== "content_block_delta") return null;
|
|
100448
|
+
const delta = e.delta;
|
|
100449
|
+
if (delta.type === "text_delta") {
|
|
100450
|
+
return { kind: "text", text: delta.text, index: e.index };
|
|
100451
|
+
}
|
|
100452
|
+
if (delta.type === "thinking_delta") {
|
|
100453
|
+
return { kind: "thinking", text: delta.thinking, index: e.index };
|
|
100454
|
+
}
|
|
100455
|
+
return null;
|
|
100456
|
+
}
|
|
100457
|
+
function mapUsage(usage) {
|
|
100458
|
+
return {
|
|
100459
|
+
input_tokens: usage.input_tokens,
|
|
100460
|
+
cached_input_tokens: usage.cache_read_input_tokens ?? 0,
|
|
100461
|
+
cache_write_input_tokens: usage.cache_creation_input_tokens ?? 0,
|
|
100462
|
+
output_tokens: usage.output_tokens,
|
|
100463
|
+
reasoning_output_tokens: 0
|
|
100464
|
+
// Claude SDK does not provide this separately.
|
|
100465
|
+
};
|
|
100466
|
+
}
|
|
100467
|
+
|
|
100468
|
+
// src/claude/transcript-history.ts
|
|
100469
|
+
var MESSAGE_TYPES = /* @__PURE__ */ new Set(["user", "assistant"]);
|
|
100470
|
+
function parseTranscript(text) {
|
|
100471
|
+
const entries = [];
|
|
100472
|
+
for (const line of text.split("\n")) {
|
|
100473
|
+
if (!line.trim()) continue;
|
|
100474
|
+
let raw;
|
|
100475
|
+
try {
|
|
100476
|
+
raw = JSON.parse(line);
|
|
100477
|
+
} catch {
|
|
100478
|
+
continue;
|
|
100479
|
+
}
|
|
100480
|
+
if (typeof raw.uuid !== "string" || typeof raw.type !== "string") continue;
|
|
100481
|
+
const link = {
|
|
100482
|
+
type: raw.type,
|
|
100483
|
+
uuid: raw.uuid,
|
|
100484
|
+
parentUuid: typeof raw.parentUuid === "string" ? raw.parentUuid : null,
|
|
100485
|
+
logicalParentUuid: typeof raw.logicalParentUuid === "string" ? raw.logicalParentUuid : null,
|
|
100486
|
+
isSidechain: raw.isSidechain === true,
|
|
100487
|
+
timestamp: typeof raw.timestamp === "string" ? raw.timestamp : void 0
|
|
100488
|
+
};
|
|
100489
|
+
if (raw.type === "system") {
|
|
100490
|
+
link.subtype = typeof raw.subtype === "string" ? raw.subtype : void 0;
|
|
100491
|
+
if (link.subtype === "compact_boundary") {
|
|
100492
|
+
link.compactMetadata = raw.compactMetadata ?? null;
|
|
100493
|
+
}
|
|
100494
|
+
} else if (MESSAGE_TYPES.has(raw.type)) {
|
|
100495
|
+
link.isMeta = raw.isMeta === true;
|
|
100496
|
+
link.isCompactSummary = raw.isCompactSummary === true;
|
|
100497
|
+
link.isApiErrorMessage = raw.isApiErrorMessage === true;
|
|
100498
|
+
link.cwd = typeof raw.cwd === "string" ? raw.cwd : void 0;
|
|
100499
|
+
link.origin = raw.origin ?? null;
|
|
100500
|
+
link.message = raw.message ?? null;
|
|
100501
|
+
link.toolUseResult = raw.toolUseResult;
|
|
100502
|
+
}
|
|
100503
|
+
entries.push(link);
|
|
100504
|
+
}
|
|
100505
|
+
return entries;
|
|
100506
|
+
}
|
|
100507
|
+
function mainChain(entries) {
|
|
100508
|
+
const byUuid = /* @__PURE__ */ new Map();
|
|
100509
|
+
for (const entry of entries) byUuid.set(entry.uuid, entry);
|
|
100510
|
+
let leaf;
|
|
100511
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
100512
|
+
const entry = entries[i];
|
|
100513
|
+
if (MESSAGE_TYPES.has(entry.type) && !entry.isSidechain) {
|
|
100514
|
+
leaf = entry;
|
|
100515
|
+
break;
|
|
100516
|
+
}
|
|
100517
|
+
}
|
|
100518
|
+
const chain = [];
|
|
100519
|
+
const seen = /* @__PURE__ */ new Set();
|
|
100520
|
+
let current = leaf;
|
|
100521
|
+
while (current && !seen.has(current.uuid)) {
|
|
100522
|
+
seen.add(current.uuid);
|
|
100523
|
+
chain.push(current);
|
|
100524
|
+
const parent = current.parentUuid ?? current.logicalParentUuid ?? null;
|
|
100525
|
+
current = parent ? byUuid.get(parent) : void 0;
|
|
100526
|
+
}
|
|
100527
|
+
return chain.reverse();
|
|
100528
|
+
}
|
|
100529
|
+
var INJECTED_BLOCK = /^\s*<(system-reminder|ide_opened_file|ide_selection|ide_diagnostics)>/;
|
|
100530
|
+
function tagValue(text, tag) {
|
|
100531
|
+
const match = new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`).exec(text);
|
|
100532
|
+
return match ? match[1] : null;
|
|
100533
|
+
}
|
|
100534
|
+
function classifyUserInput(entry) {
|
|
100535
|
+
if (entry.origin?.kind && entry.origin.kind !== "human") return { kind: "ignore" };
|
|
100536
|
+
const content = entry.message?.content;
|
|
100537
|
+
let text = "";
|
|
100538
|
+
let images = 0;
|
|
100539
|
+
if (typeof content === "string") {
|
|
100540
|
+
text = content;
|
|
100541
|
+
} else if (Array.isArray(content)) {
|
|
100542
|
+
const parts = [];
|
|
100543
|
+
for (const block of content) {
|
|
100544
|
+
if (!block || typeof block !== "object") continue;
|
|
100545
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
100546
|
+
if (!INJECTED_BLOCK.test(block.text)) parts.push(block.text);
|
|
100547
|
+
} else if (block.type === "image") {
|
|
100548
|
+
images++;
|
|
100549
|
+
}
|
|
100550
|
+
}
|
|
100551
|
+
text = parts.join("\n");
|
|
100552
|
+
}
|
|
100553
|
+
const trimmed = text.trim();
|
|
100554
|
+
if (trimmed.startsWith("[Request interrupted by user")) return { kind: "interrupt" };
|
|
100555
|
+
const commandName = tagValue(trimmed, "command-name");
|
|
100556
|
+
if (commandName !== null) {
|
|
100557
|
+
const args = (tagValue(trimmed, "command-args") ?? "").trim();
|
|
100558
|
+
const name = commandName.trim();
|
|
100559
|
+
return { kind: "command", text: args ? `${name} ${args}` : name };
|
|
100560
|
+
}
|
|
100561
|
+
const bashInput = tagValue(trimmed, "bash-input");
|
|
100562
|
+
if (bashInput !== null) return { kind: "bash", command: bashInput };
|
|
100563
|
+
const stdout = tagValue(trimmed, "bash-stdout");
|
|
100564
|
+
const stderr = tagValue(trimmed, "bash-stderr");
|
|
100565
|
+
if (stdout !== null || stderr !== null) return { kind: "bash-output", stdout: stdout ?? "", stderr: stderr ?? "" };
|
|
100566
|
+
if (/^<(local-command-stdout|local-command-stderr|local-command-caveat|task-notification|system-reminder)>/.test(
|
|
100567
|
+
trimmed
|
|
100568
|
+
)) {
|
|
100569
|
+
return { kind: "ignore" };
|
|
100570
|
+
}
|
|
100571
|
+
if (!trimmed && images === 0) return { kind: "ignore" };
|
|
100572
|
+
const imageNote = images > 0 && !trimmed.includes("[Image") ? Array(images).fill("[Image]").join(" ") : "";
|
|
100573
|
+
return { kind: "prompt", text: [trimmed, imageNote].filter(Boolean).join("\n") };
|
|
100574
|
+
}
|
|
100575
|
+
var TOOL_ITEM_TYPES = /* @__PURE__ */ new Set(["command_execution", "file_change", "mcp_tool_call"]);
|
|
100576
|
+
function syntheticText(content) {
|
|
100577
|
+
if (typeof content === "string") return content;
|
|
100578
|
+
if (!Array.isArray(content)) return "";
|
|
100579
|
+
return content.map(
|
|
100580
|
+
(b) => b && typeof b === "object" && b.type === "text" ? String(b.text ?? "") : ""
|
|
100581
|
+
).join("").trim();
|
|
100582
|
+
}
|
|
100583
|
+
function buildTurns(chain) {
|
|
100584
|
+
const turns = [];
|
|
100585
|
+
let current = null;
|
|
100586
|
+
let lastMs = 0;
|
|
100587
|
+
const stamp = (entry) => {
|
|
100588
|
+
const parsed = entry.timestamp ? Date.parse(entry.timestamp) : NaN;
|
|
100589
|
+
lastMs = Number.isFinite(parsed) && parsed > lastMs ? parsed : lastMs + 1;
|
|
100590
|
+
return new Date(lastMs).toISOString();
|
|
100591
|
+
};
|
|
100592
|
+
const openTurn = (prompt, entry, fromCommand = false) => {
|
|
100593
|
+
const at = stamp(entry);
|
|
100594
|
+
const turn = {
|
|
100595
|
+
userPrompt: prompt,
|
|
100596
|
+
status: "completed",
|
|
100597
|
+
agentResponse: null,
|
|
100598
|
+
thoughts: null,
|
|
100599
|
+
externalTurnId: null,
|
|
100600
|
+
createdAt: at,
|
|
100601
|
+
updatedAt: at,
|
|
100602
|
+
items: [],
|
|
100603
|
+
fromCommand,
|
|
100604
|
+
toolItems: /* @__PURE__ */ new Map()
|
|
100605
|
+
};
|
|
100606
|
+
turns.push(turn);
|
|
100607
|
+
return turn;
|
|
100608
|
+
};
|
|
100609
|
+
const addItem = (turn, entry, item) => {
|
|
100610
|
+
const full = { ...item, createdAt: stamp(entry) };
|
|
100611
|
+
turn.items.push(full);
|
|
100612
|
+
turn.updatedAt = full.createdAt;
|
|
100613
|
+
return full;
|
|
100614
|
+
};
|
|
100615
|
+
for (const entry of chain) {
|
|
100616
|
+
if (entry.type === "system") {
|
|
100617
|
+
if (entry.subtype === "compact_boundary" && current) {
|
|
100618
|
+
const meta = entry.compactMetadata ?? {};
|
|
100619
|
+
addItem(current, entry, {
|
|
100620
|
+
type: "context_compaction",
|
|
100621
|
+
externalId: `compact-${entry.uuid}`,
|
|
100622
|
+
data: { trigger: meta.trigger ?? "auto", pre_tokens: meta.preTokens ?? 0, post_tokens: meta.postTokens ?? 0 },
|
|
100623
|
+
status: "completed"
|
|
100624
|
+
});
|
|
100625
|
+
}
|
|
100626
|
+
continue;
|
|
100627
|
+
}
|
|
100628
|
+
if (entry.type === "user") {
|
|
100629
|
+
if (entry.isMeta || entry.isCompactSummary) continue;
|
|
100630
|
+
const content = entry.message?.content;
|
|
100631
|
+
if (Array.isArray(content) && content.some((b) => b?.type === "tool_result")) {
|
|
100632
|
+
if (!current) continue;
|
|
100633
|
+
for (const block of content) {
|
|
100634
|
+
const b = block;
|
|
100635
|
+
if (b?.type !== "tool_result" || !b.tool_use_id) continue;
|
|
100636
|
+
const item = current.toolItems.get(b.tool_use_id);
|
|
100637
|
+
if (!item) continue;
|
|
100638
|
+
const isError = !!b.is_error;
|
|
100639
|
+
item.data = applyToolResult(item.type, item.data, b, entry.toolUseResult, isError);
|
|
100640
|
+
item.status = isError ? "failed" : "completed";
|
|
100641
|
+
}
|
|
100642
|
+
continue;
|
|
100643
|
+
}
|
|
100644
|
+
const input = classifyUserInput(entry);
|
|
100645
|
+
switch (input.kind) {
|
|
100646
|
+
case "prompt":
|
|
100647
|
+
current = openTurn(input.text, entry);
|
|
100648
|
+
break;
|
|
100649
|
+
case "command":
|
|
100650
|
+
current = openTurn(input.text, entry, true);
|
|
100651
|
+
break;
|
|
100652
|
+
case "bash": {
|
|
100653
|
+
const turn = openTurn(`! ${input.command}`, entry);
|
|
100654
|
+
current = turn;
|
|
100655
|
+
const item = addItem(turn, entry, {
|
|
100656
|
+
type: "command_execution",
|
|
100657
|
+
externalId: `bash-${entry.uuid}`,
|
|
100658
|
+
data: { command: input.command, aggregated_output: null, exit_code: null, status: "in_progress" },
|
|
100659
|
+
status: "in_progress"
|
|
100660
|
+
});
|
|
100661
|
+
turn.toolItems.set(item.externalId, item);
|
|
100662
|
+
break;
|
|
100663
|
+
}
|
|
100664
|
+
case "bash-output": {
|
|
100665
|
+
const item = current?.items.find(
|
|
100666
|
+
(i) => i.type === "command_execution" && i.status === "in_progress" && i.externalId.startsWith("bash-")
|
|
100667
|
+
);
|
|
100668
|
+
if (item) {
|
|
100669
|
+
const failed = !!input.stderr.trim() && !input.stdout.trim();
|
|
100670
|
+
const output = [input.stdout, input.stderr].filter((s) => s.trim()).join("\n");
|
|
100671
|
+
item.data = {
|
|
100672
|
+
...item.data,
|
|
100673
|
+
aggregated_output: output,
|
|
100674
|
+
exit_code: failed ? 1 : 0,
|
|
100675
|
+
status: failed ? "failed" : "completed"
|
|
100676
|
+
};
|
|
100677
|
+
item.status = failed ? "failed" : "completed";
|
|
100678
|
+
}
|
|
100679
|
+
break;
|
|
100680
|
+
}
|
|
100681
|
+
case "interrupt":
|
|
100682
|
+
if (current) current.status = "aborted";
|
|
100683
|
+
break;
|
|
100684
|
+
case "ignore":
|
|
100685
|
+
break;
|
|
100686
|
+
}
|
|
100687
|
+
continue;
|
|
100688
|
+
}
|
|
100689
|
+
if (entry.type === "assistant") {
|
|
100690
|
+
const message = entry.message;
|
|
100691
|
+
if (!message) continue;
|
|
100692
|
+
if (!current) current = openTurn("", entry);
|
|
100693
|
+
const turn = current;
|
|
100694
|
+
if (entry.isApiErrorMessage || message.model === "<synthetic>") {
|
|
100695
|
+
const text = syntheticText(message.content);
|
|
100696
|
+
if (entry.isApiErrorMessage && text) {
|
|
100697
|
+
addItem(turn, entry, {
|
|
100698
|
+
type: "error",
|
|
100699
|
+
externalId: `api-error-${entry.uuid}`,
|
|
100700
|
+
data: { message: text, error: "api_error" },
|
|
100701
|
+
status: "completed"
|
|
100702
|
+
});
|
|
100703
|
+
}
|
|
100704
|
+
continue;
|
|
100705
|
+
}
|
|
100706
|
+
const content = Array.isArray(message.content) ? message.content : [];
|
|
100707
|
+
for (const desc of mapAssistantContent(content, entry.uuid)) {
|
|
100708
|
+
if (desc.type === "reasoning" && !String(desc.data.text ?? "").trim()) continue;
|
|
100709
|
+
if (desc.type === "agent_message") desc.externalId = message.id ?? entry.uuid;
|
|
100710
|
+
const isTool = TOOL_ITEM_TYPES.has(desc.type);
|
|
100711
|
+
const item = addItem(turn, entry, {
|
|
100712
|
+
type: desc.type,
|
|
100713
|
+
externalId: desc.externalId,
|
|
100714
|
+
data: desc.data,
|
|
100715
|
+
status: isTool ? "in_progress" : "completed"
|
|
100716
|
+
});
|
|
100717
|
+
if (isTool) turn.toolItems.set(desc.externalId, item);
|
|
100718
|
+
if (desc.type === "agent_message") turn.agentResponse = String(desc.data.text ?? "");
|
|
100719
|
+
if (desc.type === "reasoning") turn.thoughts = String(desc.data.text ?? "");
|
|
100720
|
+
}
|
|
100721
|
+
turn.externalTurnId = entry.uuid;
|
|
100722
|
+
turn.updatedAt = stamp(entry);
|
|
100723
|
+
}
|
|
100724
|
+
}
|
|
100725
|
+
return turns.filter((turn) => !(turn.fromCommand && turn.items.length === 0)).map(({ fromCommand: _fromCommand, toolItems: _toolItems, ...turn }) => ({
|
|
100726
|
+
...turn,
|
|
100727
|
+
// A tool that never got its result (interrupted, crashed) did not finish.
|
|
100728
|
+
items: turn.items.map(
|
|
100729
|
+
(item) => item.status === "in_progress" ? { ...item, status: "failed", data: { ...item.data, status: "failed" } } : item
|
|
100730
|
+
)
|
|
100731
|
+
}));
|
|
100732
|
+
}
|
|
100733
|
+
function transcriptToTurns(text) {
|
|
100734
|
+
return buildTurns(mainChain(parseTranscript(text)));
|
|
100735
|
+
}
|
|
100736
|
+
|
|
100737
|
+
// src/claude/session-import.ts
|
|
100738
|
+
var ClaudeImportError = class extends Error {
|
|
100739
|
+
status;
|
|
100740
|
+
paneSessionId;
|
|
100741
|
+
constructor(status, message, paneSessionId = null) {
|
|
100742
|
+
super(message);
|
|
100743
|
+
this.name = "ClaudeImportError";
|
|
100744
|
+
this.status = status;
|
|
100745
|
+
this.paneSessionId = paneSessionId;
|
|
100746
|
+
}
|
|
100747
|
+
};
|
|
100748
|
+
var RECENT_MS = 10 * 6e4;
|
|
100749
|
+
var CHECK_EMPTY_BELOW_BYTES = 64 * 1024;
|
|
100750
|
+
var SESSION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
100751
|
+
var TITLE_MAX = 100;
|
|
100752
|
+
async function realDir(dir) {
|
|
100753
|
+
try {
|
|
100754
|
+
return await realpath(dir);
|
|
100755
|
+
} catch {
|
|
100756
|
+
return null;
|
|
100757
|
+
}
|
|
100758
|
+
}
|
|
100759
|
+
async function sameDir(a, realB) {
|
|
100760
|
+
const realA = await realDir(a) ?? path8.resolve(a);
|
|
100761
|
+
return realA === realB;
|
|
100762
|
+
}
|
|
100763
|
+
function knownClaudeSessionIds(db2) {
|
|
100764
|
+
const rows = db2.prepare(
|
|
100765
|
+
`SELECT external_thread_id AS id FROM sessions WHERE external_thread_id IS NOT NULL
|
|
100766
|
+
UNION SELECT pre_rewind_thread_id FROM sessions WHERE pre_rewind_thread_id IS NOT NULL
|
|
100767
|
+
UNION SELECT import_source_id FROM sessions WHERE import_source_id IS NOT NULL
|
|
100768
|
+
UNION SELECT external_thread_id FROM discussion_threads WHERE external_thread_id IS NOT NULL`
|
|
100769
|
+
).all();
|
|
100770
|
+
return new Set(rows.map((row) => row.id));
|
|
100771
|
+
}
|
|
100772
|
+
function paneSessionHolding(db2, claudeSessionId) {
|
|
100773
|
+
const row = db2.prepare(
|
|
100774
|
+
`SELECT id FROM sessions WHERE import_source_id = ? OR external_thread_id = ? OR pre_rewind_thread_id = ?
|
|
100775
|
+
UNION SELECT session_id FROM discussion_threads WHERE external_thread_id = ?
|
|
100776
|
+
LIMIT 1`
|
|
100777
|
+
).get(claudeSessionId, claudeSessionId, claudeSessionId, claudeSessionId);
|
|
100778
|
+
return row?.id ?? null;
|
|
100779
|
+
}
|
|
100780
|
+
function titleOf(info) {
|
|
100781
|
+
const raw = (info.customTitle || info.summary || info.firstPrompt || "").trim();
|
|
100782
|
+
const firstLine = raw.split("\n")[0].trim();
|
|
100783
|
+
return firstLine.length > TITLE_MAX ? `${firstLine.slice(0, TITLE_MAX - 1)}\u2026` : firstLine;
|
|
100784
|
+
}
|
|
100785
|
+
async function readTranscript(info) {
|
|
100786
|
+
const file = locateTranscript({ runtime_type: "claude", external_thread_id: info.sessionId, cwd: info.cwd ?? null });
|
|
100787
|
+
if (!file) return null;
|
|
100788
|
+
try {
|
|
100789
|
+
return await readFile2(file, "utf8");
|
|
100790
|
+
} catch {
|
|
100791
|
+
return null;
|
|
100792
|
+
}
|
|
100793
|
+
}
|
|
100794
|
+
async function listImportableClaudeSessions(db2, workspacePath, now = Date.now()) {
|
|
100795
|
+
const dir = await realDir(workspacePath);
|
|
100796
|
+
if (!dir) return [];
|
|
100797
|
+
const known = knownClaudeSessionIds(db2);
|
|
100798
|
+
const infos = await listSessions({ dir, includeProgrammatic: false, includeWorktrees: false });
|
|
100799
|
+
const sessions = [];
|
|
100800
|
+
for (const info of infos) {
|
|
100801
|
+
if (known.has(info.sessionId) || !info.cwd) continue;
|
|
100802
|
+
if (!await sameDir(info.cwd, dir)) continue;
|
|
100803
|
+
if ((info.fileSize ?? 0) < CHECK_EMPTY_BELOW_BYTES) {
|
|
100804
|
+
const text = await readTranscript(info);
|
|
100805
|
+
if (!text || transcriptToTurns(text).length === 0) continue;
|
|
100806
|
+
}
|
|
100807
|
+
sessions.push({
|
|
100808
|
+
session_id: info.sessionId,
|
|
100809
|
+
title: titleOf(info) || "Untitled session",
|
|
100810
|
+
cwd: info.cwd,
|
|
100811
|
+
git_branch: info.gitBranch ?? null,
|
|
100812
|
+
created_at: info.createdAt ? new Date(info.createdAt).toISOString() : null,
|
|
100813
|
+
last_modified: new Date(info.lastModified).toISOString(),
|
|
100814
|
+
recently_active: now - info.lastModified < RECENT_MS
|
|
100815
|
+
});
|
|
100816
|
+
}
|
|
100817
|
+
return sessions.sort((a, b) => a.last_modified < b.last_modified ? 1 : -1);
|
|
100818
|
+
}
|
|
100819
|
+
async function importClaudeSession(db2, claudeSessionId, workspacePath) {
|
|
100820
|
+
if (!SESSION_ID.test(claudeSessionId)) throw new ClaudeImportError(400, "Not a Claude Code session id");
|
|
100821
|
+
const holder = paneSessionHolding(db2, claudeSessionId);
|
|
100822
|
+
if (holder) throw new ClaudeImportError(409, "This session is already in the pane", holder);
|
|
100823
|
+
const dir = workspacePath ? await realDir(workspacePath) : null;
|
|
100824
|
+
const info = (dir ? await getSessionInfo(claudeSessionId, { dir }) : void 0) ?? await getSessionInfo(claudeSessionId);
|
|
100825
|
+
if (!info) throw new ClaudeImportError(404, "Claude Code session not found");
|
|
100826
|
+
const text = await readTranscript(info);
|
|
100827
|
+
if (text === null) throw new ClaudeImportError(404, "The session transcript could not be read");
|
|
100828
|
+
const turns = transcriptToTurns(text);
|
|
100829
|
+
if (turns.length === 0) throw new ClaudeImportError(422, "This session has no conversation to import");
|
|
100830
|
+
const cwd = workspacePath && dir && info.cwd && await sameDir(info.cwd, dir) ? workspacePath : info.cwd ?? null;
|
|
100831
|
+
const sessionId = v4_default();
|
|
100832
|
+
const createdAt = turns[0].createdAt;
|
|
100833
|
+
const updatedAt = turns[turns.length - 1].updatedAt;
|
|
100834
|
+
const insertSession = db2.prepare(
|
|
100835
|
+
`INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status,
|
|
100836
|
+
is_running, lifecycle, sort_order, user_touched, import_source_id, created_at, updated_at)
|
|
100837
|
+
VALUES (?, ?, 'claude', NULL, NULL, ?, ?, 'active', 0, 'working', ?, 1, ?, ?, ?)`
|
|
100838
|
+
);
|
|
100839
|
+
const insertTurn = db2.prepare(
|
|
100840
|
+
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status,
|
|
100841
|
+
error, created_at, updated_at)
|
|
100842
|
+
VALUES (?, ?, ?, ?, ?, NULL, ?, ?, NULL, ?, ?)`
|
|
100843
|
+
);
|
|
100844
|
+
const insertItem2 = db2.prepare(
|
|
100845
|
+
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
100846
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
|
|
100847
|
+
);
|
|
100848
|
+
db2.transaction(() => {
|
|
100849
|
+
const raced = paneSessionHolding(db2, claudeSessionId);
|
|
100850
|
+
if (raced) throw new ClaudeImportError(409, "This session is already in the pane", raced);
|
|
100851
|
+
const { m } = db2.prepare("SELECT COALESCE(MAX(sort_order), 0) AS m FROM sessions WHERE cwd = ?").get(cwd);
|
|
100852
|
+
insertSession.run(
|
|
100853
|
+
sessionId,
|
|
100854
|
+
titleOf(info) || null,
|
|
100855
|
+
cwd,
|
|
100856
|
+
claudeSessionId,
|
|
100857
|
+
m + 1,
|
|
100858
|
+
claudeSessionId,
|
|
100859
|
+
createdAt,
|
|
100860
|
+
updatedAt
|
|
100861
|
+
);
|
|
100862
|
+
for (const turn of turns) {
|
|
100863
|
+
const turnId = v4_default();
|
|
100864
|
+
insertTurn.run(
|
|
100865
|
+
turnId,
|
|
100866
|
+
sessionId,
|
|
100867
|
+
turn.userPrompt,
|
|
100868
|
+
turn.agentResponse,
|
|
100869
|
+
turn.thoughts,
|
|
100870
|
+
turn.externalTurnId,
|
|
100871
|
+
turn.status,
|
|
100872
|
+
turn.createdAt,
|
|
100873
|
+
turn.updatedAt
|
|
100874
|
+
);
|
|
100875
|
+
for (const item of turn.items) {
|
|
100876
|
+
insertItem2.run(
|
|
100877
|
+
v4_default(),
|
|
100878
|
+
turnId,
|
|
100879
|
+
item.externalId,
|
|
100880
|
+
item.type,
|
|
100881
|
+
JSON.stringify(trimItemData(item.data)),
|
|
100882
|
+
item.status,
|
|
100883
|
+
item.createdAt,
|
|
100884
|
+
item.createdAt
|
|
100885
|
+
);
|
|
100886
|
+
}
|
|
100887
|
+
}
|
|
100888
|
+
})();
|
|
100889
|
+
return db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
|
|
100890
|
+
}
|
|
100891
|
+
|
|
100892
|
+
// src/routes/claude-sessions.ts
|
|
100893
|
+
async function registerClaudeSessionRoutes(fastify) {
|
|
100894
|
+
fastify.get("/api/claude-sessions", async (request, reply) => {
|
|
100895
|
+
const workspace = request.query.workspace?.trim();
|
|
100896
|
+
if (!workspace) return reply.code(400).send({ error: "workspace is required" });
|
|
100897
|
+
try {
|
|
100898
|
+
return { sessions: await listImportableClaudeSessions(getDb(), workspace) };
|
|
100899
|
+
} catch (err) {
|
|
100900
|
+
return reply.code(500).send({ error: `Could not list Claude Code sessions: ${err.message}` });
|
|
100901
|
+
}
|
|
100902
|
+
});
|
|
100903
|
+
fastify.post(
|
|
100904
|
+
"/api/claude-sessions/:id/import",
|
|
100905
|
+
{
|
|
100906
|
+
schema: {
|
|
100907
|
+
body: {
|
|
100908
|
+
type: ["object", "null"],
|
|
100909
|
+
properties: { workspace: { type: ["string", "null"] } }
|
|
100910
|
+
}
|
|
100911
|
+
}
|
|
100912
|
+
},
|
|
100913
|
+
async (request, reply) => {
|
|
100914
|
+
try {
|
|
100915
|
+
return await importClaudeSession(getDb(), request.params.id, request.body?.workspace?.trim() || null);
|
|
100916
|
+
} catch (err) {
|
|
100917
|
+
if (err instanceof ClaudeImportError) {
|
|
100918
|
+
return reply.code(err.status).send({ error: err.message, session_id: err.paneSessionId });
|
|
100919
|
+
}
|
|
100920
|
+
return reply.code(500).send({ error: `Import failed: ${err.message}` });
|
|
100921
|
+
}
|
|
100922
|
+
}
|
|
100923
|
+
);
|
|
100924
|
+
}
|
|
100925
|
+
|
|
100095
100926
|
// src/codex/item-mapper.ts
|
|
100096
100927
|
function mapItemData(item) {
|
|
100097
100928
|
switch (item.type) {
|
|
@@ -100162,18 +100993,18 @@ function mapTokenUsage(data) {
|
|
|
100162
100993
|
|
|
100163
100994
|
// src/apps/register-mcp.ts
|
|
100164
100995
|
import fs6 from "node:fs";
|
|
100165
|
-
import
|
|
100996
|
+
import path9 from "node:path";
|
|
100166
100997
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
100167
100998
|
var MCP_SERVER_NAME = "agentpane-miniapps";
|
|
100168
100999
|
function panePublicUrl() {
|
|
100169
101000
|
return (process.env.AGENT_PANE_PUBLIC_URL || process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
|
|
100170
101001
|
}
|
|
100171
101002
|
function stdioScriptPath() {
|
|
100172
|
-
const here =
|
|
101003
|
+
const here = path9.dirname(fileURLToPath2(import.meta.url));
|
|
100173
101004
|
const candidates = [
|
|
100174
|
-
|
|
101005
|
+
path9.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
|
|
100175
101006
|
// src/apps/ → backend/scripts
|
|
100176
|
-
|
|
101007
|
+
path9.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
|
|
100177
101008
|
// dist bundle → backend/scripts
|
|
100178
101009
|
];
|
|
100179
101010
|
for (const candidate of candidates) {
|
|
@@ -100860,156 +101691,6 @@ import { readFileSync as readFileSync3 } from "fs";
|
|
|
100860
101691
|
import { tmpdir } from "os";
|
|
100861
101692
|
import { join as join4 } from "path";
|
|
100862
101693
|
|
|
100863
|
-
// src/claude/claude-message-mapper.ts
|
|
100864
|
-
function mapAssistantContent(content, messageId, thinkingTexts) {
|
|
100865
|
-
const descriptors = [];
|
|
100866
|
-
for (let i = 0; i < content.length; i++) {
|
|
100867
|
-
const block = content[i];
|
|
100868
|
-
switch (block.type) {
|
|
100869
|
-
case "text": {
|
|
100870
|
-
const tb = block;
|
|
100871
|
-
descriptors.push({
|
|
100872
|
-
type: "agent_message",
|
|
100873
|
-
data: { text: tb.text },
|
|
100874
|
-
externalId: messageId
|
|
100875
|
-
});
|
|
100876
|
-
break;
|
|
100877
|
-
}
|
|
100878
|
-
case "thinking": {
|
|
100879
|
-
const tb = block;
|
|
100880
|
-
let text = tb.thinking;
|
|
100881
|
-
if (!text && thinkingTexts) {
|
|
100882
|
-
text = thinkingTexts.get(i) ?? "";
|
|
100883
|
-
}
|
|
100884
|
-
descriptors.push({
|
|
100885
|
-
type: "reasoning",
|
|
100886
|
-
data: { text },
|
|
100887
|
-
externalId: messageId
|
|
100888
|
-
});
|
|
100889
|
-
break;
|
|
100890
|
-
}
|
|
100891
|
-
case "tool_use": {
|
|
100892
|
-
const tu = block;
|
|
100893
|
-
const desc = mapToolUse(tu);
|
|
100894
|
-
descriptors.push(desc);
|
|
100895
|
-
break;
|
|
100896
|
-
}
|
|
100897
|
-
case "redacted_thinking":
|
|
100898
|
-
break;
|
|
100899
|
-
default:
|
|
100900
|
-
break;
|
|
100901
|
-
}
|
|
100902
|
-
}
|
|
100903
|
-
return descriptors;
|
|
100904
|
-
}
|
|
100905
|
-
function mapToolUse(block) {
|
|
100906
|
-
const input = block.input;
|
|
100907
|
-
if (block.name === "Bash") {
|
|
100908
|
-
return {
|
|
100909
|
-
type: "command_execution",
|
|
100910
|
-
data: {
|
|
100911
|
-
command: input.command ?? "",
|
|
100912
|
-
aggregated_output: null,
|
|
100913
|
-
exit_code: null,
|
|
100914
|
-
status: "in_progress"
|
|
100915
|
-
},
|
|
100916
|
-
externalId: block.id
|
|
100917
|
-
};
|
|
100918
|
-
}
|
|
100919
|
-
if (block.name === "Edit" || block.name === "Write" || block.name === "MultiEdit" || block.name === "NotebookEdit") {
|
|
100920
|
-
return {
|
|
100921
|
-
type: "file_change",
|
|
100922
|
-
data: deriveFileChangeData(input, block.name),
|
|
100923
|
-
externalId: block.id
|
|
100924
|
-
};
|
|
100925
|
-
}
|
|
100926
|
-
return {
|
|
100927
|
-
type: "mcp_tool_call",
|
|
100928
|
-
data: {
|
|
100929
|
-
server: null,
|
|
100930
|
-
tool: block.name,
|
|
100931
|
-
arguments: input,
|
|
100932
|
-
result: null,
|
|
100933
|
-
error: null,
|
|
100934
|
-
status: "in_progress"
|
|
100935
|
-
},
|
|
100936
|
-
externalId: block.id
|
|
100937
|
-
};
|
|
100938
|
-
}
|
|
100939
|
-
function deriveFileChangeData(input, toolName) {
|
|
100940
|
-
const path10 = input.file_path ?? input.notebook_path ?? "";
|
|
100941
|
-
const kind = toolName === "Write" ? "add" : "modify";
|
|
100942
|
-
return { changes: [{ path: path10, kind }], status: "in_progress" };
|
|
100943
|
-
}
|
|
100944
|
-
function extractToolResultText(content) {
|
|
100945
|
-
if (!content) return "";
|
|
100946
|
-
if (typeof content === "string") return content;
|
|
100947
|
-
if (Array.isArray(content)) {
|
|
100948
|
-
return content.map((b) => {
|
|
100949
|
-
if (b && typeof b === "object" && b.type === "text") {
|
|
100950
|
-
return String(b.text ?? "");
|
|
100951
|
-
}
|
|
100952
|
-
return "";
|
|
100953
|
-
}).filter(Boolean).join("\n");
|
|
100954
|
-
}
|
|
100955
|
-
return "";
|
|
100956
|
-
}
|
|
100957
|
-
function applyToolResult(itemType, existingData, toolResult, toolUseResult, isError) {
|
|
100958
|
-
switch (itemType) {
|
|
100959
|
-
case "command_execution": {
|
|
100960
|
-
const text = extractToolResultText(toolResult?.content);
|
|
100961
|
-
const tur = toolUseResult && typeof toolUseResult === "object" ? toolUseResult : {};
|
|
100962
|
-
const stdout = typeof tur.stdout === "string" ? tur.stdout : "";
|
|
100963
|
-
const stderr = typeof tur.stderr === "string" ? tur.stderr : "";
|
|
100964
|
-
let aggregated = text || stdout;
|
|
100965
|
-
if (stderr) aggregated = aggregated ? `${aggregated}
|
|
100966
|
-
${stderr}` : stderr;
|
|
100967
|
-
return {
|
|
100968
|
-
...existingData,
|
|
100969
|
-
aggregated_output: aggregated,
|
|
100970
|
-
exit_code: isError ? 1 : 0,
|
|
100971
|
-
status: isError ? "failed" : "completed"
|
|
100972
|
-
};
|
|
100973
|
-
}
|
|
100974
|
-
case "mcp_tool_call": {
|
|
100975
|
-
const text = extractToolResultText(toolResult?.content);
|
|
100976
|
-
return {
|
|
100977
|
-
...existingData,
|
|
100978
|
-
result: text ? [{ type: "text", text }] : toolUseResult ?? null,
|
|
100979
|
-
error: isError ? text || "Tool error" : null,
|
|
100980
|
-
status: isError ? "failed" : "completed"
|
|
100981
|
-
};
|
|
100982
|
-
}
|
|
100983
|
-
case "file_change": {
|
|
100984
|
-
return { ...existingData, status: isError ? "failed" : "completed" };
|
|
100985
|
-
}
|
|
100986
|
-
default:
|
|
100987
|
-
return existingData;
|
|
100988
|
-
}
|
|
100989
|
-
}
|
|
100990
|
-
function mapPartialDelta(event) {
|
|
100991
|
-
const e = event;
|
|
100992
|
-
if (e.type !== "content_block_delta") return null;
|
|
100993
|
-
const delta = e.delta;
|
|
100994
|
-
if (delta.type === "text_delta") {
|
|
100995
|
-
return { kind: "text", text: delta.text, index: e.index };
|
|
100996
|
-
}
|
|
100997
|
-
if (delta.type === "thinking_delta") {
|
|
100998
|
-
return { kind: "thinking", text: delta.thinking, index: e.index };
|
|
100999
|
-
}
|
|
101000
|
-
return null;
|
|
101001
|
-
}
|
|
101002
|
-
function mapUsage(usage) {
|
|
101003
|
-
return {
|
|
101004
|
-
input_tokens: usage.input_tokens,
|
|
101005
|
-
cached_input_tokens: usage.cache_read_input_tokens ?? 0,
|
|
101006
|
-
cache_write_input_tokens: usage.cache_creation_input_tokens ?? 0,
|
|
101007
|
-
output_tokens: usage.output_tokens,
|
|
101008
|
-
reasoning_output_tokens: 0
|
|
101009
|
-
// Claude SDK does not provide this separately.
|
|
101010
|
-
};
|
|
101011
|
-
}
|
|
101012
|
-
|
|
101013
101694
|
// src/claude/claude-types.ts
|
|
101014
101695
|
var EFFORT_LABELS2 = {
|
|
101015
101696
|
low: "Low",
|
|
@@ -102367,8 +103048,8 @@ var RepoburgHttpClient = class {
|
|
|
102367
103048
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
102368
103049
|
}
|
|
102369
103050
|
/** Perform a JSON request. Throws a concise error on non-OK/non-JSON responses. */
|
|
102370
|
-
async request(method,
|
|
102371
|
-
const response = await fetch(`${this.baseUrl}${
|
|
103051
|
+
async request(method, path11, body) {
|
|
103052
|
+
const response = await fetch(`${this.baseUrl}${path11}`, {
|
|
102372
103053
|
method,
|
|
102373
103054
|
headers: { "Content-Type": "application/json" },
|
|
102374
103055
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
@@ -102377,17 +103058,17 @@ var RepoburgHttpClient = class {
|
|
|
102377
103058
|
if (!response.ok) {
|
|
102378
103059
|
if (isHtml(text)) {
|
|
102379
103060
|
throw new Error(
|
|
102380
|
-
`${method} ${
|
|
103061
|
+
`${method} ${path11} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
102381
103062
|
);
|
|
102382
103063
|
}
|
|
102383
|
-
throw new Error(`${method} ${
|
|
103064
|
+
throw new Error(`${method} ${path11} failed: ${response.status} ${text}`);
|
|
102384
103065
|
}
|
|
102385
103066
|
if (text.length === 0) return void 0;
|
|
102386
103067
|
try {
|
|
102387
103068
|
return JSON.parse(text);
|
|
102388
103069
|
} catch {
|
|
102389
103070
|
throw new Error(
|
|
102390
|
-
`${method} ${
|
|
103071
|
+
`${method} ${path11} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
102391
103072
|
);
|
|
102392
103073
|
}
|
|
102393
103074
|
}
|
|
@@ -102442,7 +103123,7 @@ var RepoburgHttpClient = class {
|
|
|
102442
103123
|
};
|
|
102443
103124
|
|
|
102444
103125
|
// src/repoburg/backend-resolver.ts
|
|
102445
|
-
import
|
|
103126
|
+
import path10 from "node:path";
|
|
102446
103127
|
var HEALTH_POLL_INTERVAL_MS = 1e3;
|
|
102447
103128
|
var HEALTH_TIMEOUT_MS = 3e4;
|
|
102448
103129
|
function daemonBaseUrl() {
|
|
@@ -102497,7 +103178,7 @@ async function backendHealthy(baseUrl, expectedPath) {
|
|
|
102497
103178
|
const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
|
|
102498
103179
|
if (health.status !== "ok") return false;
|
|
102499
103180
|
if (expectedPath && health.projectPath) {
|
|
102500
|
-
return
|
|
103181
|
+
return path10.resolve(health.projectPath) === path10.resolve(expectedPath);
|
|
102501
103182
|
}
|
|
102502
103183
|
return true;
|
|
102503
103184
|
} catch {
|
|
@@ -102518,7 +103199,7 @@ function serviceBaseUrl(service) {
|
|
|
102518
103199
|
return `http://localhost:${service.port}`;
|
|
102519
103200
|
}
|
|
102520
103201
|
function coveringService(services, absPath) {
|
|
102521
|
-
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path +
|
|
103202
|
+
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path10.sep)).sort((a, b) => b.path.length - a.path.length)[0];
|
|
102522
103203
|
}
|
|
102523
103204
|
async function restartService(daemon, name) {
|
|
102524
103205
|
try {
|
|
@@ -102554,7 +103235,7 @@ async function resolveBackendUrl(projectPath, opts = {}) {
|
|
|
102554
103235
|
if (envUrl) {
|
|
102555
103236
|
return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
|
|
102556
103237
|
}
|
|
102557
|
-
const absPath =
|
|
103238
|
+
const absPath = path10.resolve(projectPath);
|
|
102558
103239
|
const daemon = daemonBaseUrl();
|
|
102559
103240
|
const cached = resolvedCache.get(absPath);
|
|
102560
103241
|
if (cached && await backendHealthy(cached.baseUrl, cached.servesPath ?? absPath)) {
|
|
@@ -103983,6 +104664,7 @@ async function createAgentPaneApp(dbPath) {
|
|
|
103983
104664
|
await registerAppRoutes(fastify);
|
|
103984
104665
|
await registerSidecarRoutes(fastify);
|
|
103985
104666
|
await registerUsageRoutes(fastify);
|
|
104667
|
+
await registerClaudeSessionRoutes(fastify);
|
|
103986
104668
|
const wss2 = initWs();
|
|
103987
104669
|
wss2.on("connection", (ws) => {
|
|
103988
104670
|
ws.send(JSON.stringify({ event: "background_tasks:snapshot", data: { sessions: listAllBackgroundTasks() } }));
|