@vibedeckx/darwin-arm64 0.3.43 → 0.3.44
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/dist/bin.js +1106 -218
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -13356,12 +13356,12 @@ var require_semver = __commonJS({
|
|
|
13356
13356
|
}
|
|
13357
13357
|
function replaceHyphen(comp, options) {
|
|
13358
13358
|
const r = HYPHENRANGE_REGEXP;
|
|
13359
|
-
return comp.replace(r, (_3, from, fM, fm,
|
|
13359
|
+
return comp.replace(r, (_3, from, fM, fm, fp38, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
13360
13360
|
if (isX(fM)) {
|
|
13361
13361
|
from = "";
|
|
13362
13362
|
} else if (isX(fm)) {
|
|
13363
13363
|
from = `>=${fM}.0.0${options?.includePrerelease ? "-0" : ""}`;
|
|
13364
|
-
} else if (isX(
|
|
13364
|
+
} else if (isX(fp38)) {
|
|
13365
13365
|
from = `>=${fM}.${fm}.0${options?.includePrerelease ? "-0" : ""}`;
|
|
13366
13366
|
} else if (fpr) {
|
|
13367
13367
|
from = `>=${from}`;
|
|
@@ -87525,12 +87525,12 @@ var require_range = __commonJS({
|
|
|
87525
87525
|
debug("replaceGTE0", comp, options);
|
|
87526
87526
|
return comp.trim().replace(re2[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
87527
87527
|
};
|
|
87528
|
-
var hyphenReplace = (incPr) => ($0, from, fM, fm,
|
|
87528
|
+
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp38, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
87529
87529
|
if (isX(fM)) {
|
|
87530
87530
|
from = "";
|
|
87531
87531
|
} else if (isX(fm)) {
|
|
87532
87532
|
from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
87533
|
-
} else if (isX(
|
|
87533
|
+
} else if (isX(fp38)) {
|
|
87534
87534
|
from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
87535
87535
|
} else if (fpr) {
|
|
87536
87536
|
from = `>=${from}`;
|
|
@@ -90111,8 +90111,8 @@ var require_pretty_print = __commonJS({
|
|
|
90111
90111
|
serializedRoute += serializeMetaData(route.metaData);
|
|
90112
90112
|
return serializedRoute;
|
|
90113
90113
|
}
|
|
90114
|
-
function mergeSimilarRoutes(
|
|
90115
|
-
return
|
|
90114
|
+
function mergeSimilarRoutes(routes37) {
|
|
90115
|
+
return routes37.reduce((mergedRoutes, route) => {
|
|
90116
90116
|
for (const nodeRoute of mergedRoutes) {
|
|
90117
90117
|
if (deepEqual(route.opts.constraints, nodeRoute.opts.constraints) && deepEqual(route.metaData, nodeRoute.metaData)) {
|
|
90118
90118
|
nodeRoute.method += ", " + route.method;
|
|
@@ -90124,18 +90124,18 @@ var require_pretty_print = __commonJS({
|
|
|
90124
90124
|
}, []);
|
|
90125
90125
|
}
|
|
90126
90126
|
function serializeNode(node, prefix, options) {
|
|
90127
|
-
let
|
|
90127
|
+
let routes37 = node.routes;
|
|
90128
90128
|
if (options.method === void 0) {
|
|
90129
|
-
|
|
90129
|
+
routes37 = routes37.map(normalizeRoute);
|
|
90130
90130
|
}
|
|
90131
|
-
|
|
90131
|
+
routes37 = routes37.map((route) => {
|
|
90132
90132
|
route.metaData = getRouteMetaData(route, options);
|
|
90133
90133
|
return route;
|
|
90134
90134
|
});
|
|
90135
90135
|
if (options.method === void 0) {
|
|
90136
|
-
|
|
90136
|
+
routes37 = mergeSimilarRoutes(routes37);
|
|
90137
90137
|
}
|
|
90138
|
-
return
|
|
90138
|
+
return routes37.map(serializeRoute).join(`
|
|
90139
90139
|
${prefix}`);
|
|
90140
90140
|
}
|
|
90141
90141
|
function buildObjectTree(node, tree, prefix, options) {
|
|
@@ -91402,9 +91402,9 @@ var require_find_my_way = __commonJS({
|
|
|
91402
91402
|
pathIndex = paramEndIndex;
|
|
91403
91403
|
}
|
|
91404
91404
|
};
|
|
91405
|
-
Router.prototype._rebuild = function(
|
|
91405
|
+
Router.prototype._rebuild = function(routes37) {
|
|
91406
91406
|
this.reset();
|
|
91407
|
-
for (const route of
|
|
91407
|
+
for (const route of routes37) {
|
|
91408
91408
|
const { method, path: path26, opts, handler, store } = route;
|
|
91409
91409
|
this._on(method, path26, opts, handler, store);
|
|
91410
91410
|
}
|
|
@@ -93806,7 +93806,7 @@ var require_form_data = __commonJS({
|
|
|
93806
93806
|
"../../node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/form-data.js"(exports, module) {
|
|
93807
93807
|
"use strict";
|
|
93808
93808
|
var { randomUUID: randomUUID31 } = __require("node:crypto");
|
|
93809
|
-
var { Readable:
|
|
93809
|
+
var { Readable: Readable5 } = __require("node:stream");
|
|
93810
93810
|
var textEncoder;
|
|
93811
93811
|
function isFormDataLike(payload) {
|
|
93812
93812
|
return payload && typeof payload === "object" && typeof payload.append === "function" && typeof payload.delete === "function" && typeof payload.get === "function" && typeof payload.getAll === "function" && typeof payload.has === "function" && typeof payload.set === "function" && payload[Symbol.toStringTag] === "FormData";
|
|
@@ -93845,7 +93845,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
93845
93845
|
}
|
|
93846
93846
|
yield textEncoder.encode(`--${boundary}--`);
|
|
93847
93847
|
}
|
|
93848
|
-
const stream =
|
|
93848
|
+
const stream = Readable5.from(asyncIterator());
|
|
93849
93849
|
return {
|
|
93850
93850
|
stream,
|
|
93851
93851
|
contentType: `multipart/form-data; boundary=${boundary}`
|
|
@@ -93860,7 +93860,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
93860
93860
|
var require_request2 = __commonJS({
|
|
93861
93861
|
"../../node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/request.js"(exports, module) {
|
|
93862
93862
|
"use strict";
|
|
93863
|
-
var { Readable:
|
|
93863
|
+
var { Readable: Readable5, addAbortSignal } = __require("node:stream");
|
|
93864
93864
|
var util2 = __require("node:util");
|
|
93865
93865
|
var cookie = require_dist5();
|
|
93866
93866
|
var assert2 = __require("node:assert");
|
|
@@ -93898,7 +93898,7 @@ var require_request2 = __commonJS({
|
|
|
93898
93898
|
}
|
|
93899
93899
|
}
|
|
93900
93900
|
function Request2(options) {
|
|
93901
|
-
|
|
93901
|
+
Readable5.call(this, {
|
|
93902
93902
|
autoDestroy: false
|
|
93903
93903
|
});
|
|
93904
93904
|
const parsedURL = parseURL(options.url || options.path, options.query);
|
|
@@ -94030,7 +94030,7 @@ var require_request2 = __commonJS({
|
|
|
94030
94030
|
}
|
|
94031
94031
|
});
|
|
94032
94032
|
}
|
|
94033
|
-
util2.inherits(Request2,
|
|
94033
|
+
util2.inherits(Request2, Readable5);
|
|
94034
94034
|
util2.inherits(CustomRequest, Request2);
|
|
94035
94035
|
Request2.prototype.destroy = function(error48) {
|
|
94036
94036
|
if (this.destroyed || this._lightMyRequest.isDone) return;
|
|
@@ -94235,14 +94235,14 @@ var require_response = __commonJS({
|
|
|
94235
94235
|
"../../node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/response.js"(exports, module) {
|
|
94236
94236
|
"use strict";
|
|
94237
94237
|
var http = __require("node:http");
|
|
94238
|
-
var { Writable: Writable2, Readable:
|
|
94238
|
+
var { Writable: Writable2, Readable: Readable5, addAbortSignal } = __require("node:stream");
|
|
94239
94239
|
var util2 = __require("node:util");
|
|
94240
94240
|
var setCookie = require_set_cookie();
|
|
94241
94241
|
function Response2(req, onEnd, reject) {
|
|
94242
94242
|
http.ServerResponse.call(this, req);
|
|
94243
94243
|
if (req._lightMyRequest?.payloadAsStream) {
|
|
94244
94244
|
const read = this.emit.bind(this, "drain");
|
|
94245
|
-
this._lightMyRequest = { headers: null, trailers: {}, stream: new
|
|
94245
|
+
this._lightMyRequest = { headers: null, trailers: {}, stream: new Readable5({ read }) };
|
|
94246
94246
|
const signal = req._lightMyRequest.signal;
|
|
94247
94247
|
if (signal) {
|
|
94248
94248
|
addAbortSignal(signal, this._lightMyRequest.stream);
|
|
@@ -94388,7 +94388,7 @@ var require_response = __commonJS({
|
|
|
94388
94388
|
if (response._lightMyRequest.stream) {
|
|
94389
94389
|
return response._lightMyRequest.stream;
|
|
94390
94390
|
}
|
|
94391
|
-
return
|
|
94391
|
+
return Readable5.from(response._lightMyRequest.payloadChunks);
|
|
94392
94392
|
};
|
|
94393
94393
|
return res;
|
|
94394
94394
|
}
|
|
@@ -100612,8 +100612,8 @@ var require_commonjs6 = __commonJS({
|
|
|
100612
100612
|
return this.#fullpath = this.name;
|
|
100613
100613
|
}
|
|
100614
100614
|
const pv = p2.fullpath();
|
|
100615
|
-
const
|
|
100616
|
-
return this.#fullpath =
|
|
100615
|
+
const fp38 = pv + (!p2.parent ? "" : this.sep) + name25;
|
|
100616
|
+
return this.#fullpath = fp38;
|
|
100617
100617
|
}
|
|
100618
100618
|
/**
|
|
100619
100619
|
* On platforms other than windows, this is identical to fullpath.
|
|
@@ -104310,7 +104310,7 @@ var require_send = __commonJS({
|
|
|
104310
104310
|
var normalize = path26.normalize;
|
|
104311
104311
|
var resolve3 = path26.resolve;
|
|
104312
104312
|
var sep2 = path26.sep;
|
|
104313
|
-
var
|
|
104313
|
+
var Readable5 = stream.Readable;
|
|
104314
104314
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
104315
104315
|
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
|
|
104316
104316
|
var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
|
|
@@ -104517,7 +104517,7 @@ var require_send = __commonJS({
|
|
|
104517
104517
|
return {
|
|
104518
104518
|
statusCode,
|
|
104519
104519
|
headers,
|
|
104520
|
-
stream:
|
|
104520
|
+
stream: Readable5.from(doc[0]),
|
|
104521
104521
|
// metadata
|
|
104522
104522
|
type: "error",
|
|
104523
104523
|
metadata: { error: createHttpError(statusCode, err) }
|
|
@@ -104543,7 +104543,7 @@ var require_send = __commonJS({
|
|
|
104543
104543
|
return {
|
|
104544
104544
|
statusCode: 304,
|
|
104545
104545
|
headers,
|
|
104546
|
-
stream:
|
|
104546
|
+
stream: Readable5.from(""),
|
|
104547
104547
|
// metadata
|
|
104548
104548
|
type: "file",
|
|
104549
104549
|
metadata: { path: path27, stat: stat3 }
|
|
@@ -104631,7 +104631,7 @@ var require_send = __commonJS({
|
|
|
104631
104631
|
return {
|
|
104632
104632
|
statusCode,
|
|
104633
104633
|
headers,
|
|
104634
|
-
stream:
|
|
104634
|
+
stream: Readable5.from(""),
|
|
104635
104635
|
// metadata
|
|
104636
104636
|
type: "file",
|
|
104637
104637
|
metadata: { path: path27, stat: stat3 }
|
|
@@ -104666,7 +104666,7 @@ var require_send = __commonJS({
|
|
|
104666
104666
|
return {
|
|
104667
104667
|
statusCode: 301,
|
|
104668
104668
|
headers,
|
|
104669
|
-
stream:
|
|
104669
|
+
stream: Readable5.from(doc[0]),
|
|
104670
104670
|
// metadata
|
|
104671
104671
|
type: "directory",
|
|
104672
104672
|
metadata: { requestPath: options.path, path: path27 }
|
|
@@ -105329,7 +105329,7 @@ var require_static = __commonJS({
|
|
|
105329
105329
|
var { fileURLToPath: fileURLToPath4 } = __require("node:url");
|
|
105330
105330
|
var { statSync: statSync3 } = __require("node:fs");
|
|
105331
105331
|
var { glob } = require_commonjs7();
|
|
105332
|
-
var
|
|
105332
|
+
var fp38 = require_plugin2();
|
|
105333
105333
|
var send = require_send2();
|
|
105334
105334
|
var encodingNegotiator = require_accept_negotiator();
|
|
105335
105335
|
var contentDisposition = require_content_disposition();
|
|
@@ -105433,7 +105433,7 @@ var require_static = __commonJS({
|
|
|
105433
105433
|
} else {
|
|
105434
105434
|
const indexes = new Set(opts.index === void 0 ? ["index.html"] : [].concat(opts.index));
|
|
105435
105435
|
const indexDirs = /* @__PURE__ */ new Map();
|
|
105436
|
-
const
|
|
105436
|
+
const routes37 = /* @__PURE__ */ new Set();
|
|
105437
105437
|
const roots = Array.isArray(sendOptions.root) ? sendOptions.root : [sendOptions.root];
|
|
105438
105438
|
for (let rootPath of roots) {
|
|
105439
105439
|
rootPath = rootPath.split(path26.win32.sep).join(path26.posix.sep);
|
|
@@ -105449,10 +105449,10 @@ var require_static = __commonJS({
|
|
|
105449
105449
|
for (let file2 of files) {
|
|
105450
105450
|
file2 = file2.split(path26.win32.sep).join(path26.posix.sep);
|
|
105451
105451
|
const route = prefix + file2;
|
|
105452
|
-
if (
|
|
105452
|
+
if (routes37.has(route)) {
|
|
105453
105453
|
continue;
|
|
105454
105454
|
}
|
|
105455
|
-
|
|
105455
|
+
routes37.add(route);
|
|
105456
105456
|
setUpHeadAndGet(routeOpts, route, `/${file2}`, rootPath);
|
|
105457
105457
|
const key2 = path26.posix.basename(route);
|
|
105458
105458
|
if (indexes.has(key2) && !indexDirs.has(key2)) {
|
|
@@ -105747,7 +105747,7 @@ var require_static = __commonJS({
|
|
|
105747
105747
|
throw err;
|
|
105748
105748
|
}
|
|
105749
105749
|
}
|
|
105750
|
-
module.exports =
|
|
105750
|
+
module.exports = fp38(fastifyStatic2, {
|
|
105751
105751
|
fastify: "5.x",
|
|
105752
105752
|
name: "@fastify/static"
|
|
105753
105753
|
});
|
|
@@ -107959,8 +107959,8 @@ var require_websocket = __commonJS({
|
|
|
107959
107959
|
var http = __require("http");
|
|
107960
107960
|
var net2 = __require("net");
|
|
107961
107961
|
var tls = __require("tls");
|
|
107962
|
-
var { randomBytes: randomBytes5, createHash:
|
|
107963
|
-
var { Duplex, Readable:
|
|
107962
|
+
var { randomBytes: randomBytes5, createHash: createHash12 } = __require("crypto");
|
|
107963
|
+
var { Duplex, Readable: Readable5 } = __require("stream");
|
|
107964
107964
|
var { URL: URL2 } = __require("url");
|
|
107965
107965
|
var PerMessageDeflate = require_permessage_deflate();
|
|
107966
107966
|
var Receiver2 = require_receiver();
|
|
@@ -108619,7 +108619,7 @@ var require_websocket = __commonJS({
|
|
|
108619
108619
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
108620
108620
|
return;
|
|
108621
108621
|
}
|
|
108622
|
-
const digest =
|
|
108622
|
+
const digest = createHash12("sha1").update(key2 + GUID).digest("base64");
|
|
108623
108623
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
108624
108624
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
108625
108625
|
return;
|
|
@@ -108986,7 +108986,7 @@ var require_websocket_server = __commonJS({
|
|
|
108986
108986
|
var EventEmitter3 = __require("events");
|
|
108987
108987
|
var http = __require("http");
|
|
108988
108988
|
var { Duplex } = __require("stream");
|
|
108989
|
-
var { createHash:
|
|
108989
|
+
var { createHash: createHash12 } = __require("crypto");
|
|
108990
108990
|
var extension = require_extension();
|
|
108991
108991
|
var PerMessageDeflate = require_permessage_deflate();
|
|
108992
108992
|
var subprotocol = require_subprotocol();
|
|
@@ -109287,7 +109287,7 @@ var require_websocket_server = __commonJS({
|
|
|
109287
109287
|
);
|
|
109288
109288
|
}
|
|
109289
109289
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
109290
|
-
const digest =
|
|
109290
|
+
const digest = createHash12("sha1").update(key2 + GUID).digest("base64");
|
|
109291
109291
|
const headers = [
|
|
109292
109292
|
"HTTP/1.1 101 Switching Protocols",
|
|
109293
109293
|
"Upgrade: websocket",
|
|
@@ -110338,9 +110338,9 @@ var require_stream_duplex = __commonJS({
|
|
|
110338
110338
|
return keys2;
|
|
110339
110339
|
};
|
|
110340
110340
|
module.exports = Duplex;
|
|
110341
|
-
var
|
|
110341
|
+
var Readable5 = require_stream_readable();
|
|
110342
110342
|
var Writable2 = require_stream_writable();
|
|
110343
|
-
require_inherits()(Duplex,
|
|
110343
|
+
require_inherits()(Duplex, Readable5);
|
|
110344
110344
|
{
|
|
110345
110345
|
keys = objectKeys(Writable2.prototype);
|
|
110346
110346
|
for (v2 = 0; v2 < keys.length; v2++) {
|
|
@@ -110353,7 +110353,7 @@ var require_stream_duplex = __commonJS({
|
|
|
110353
110353
|
var v2;
|
|
110354
110354
|
function Duplex(options) {
|
|
110355
110355
|
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
110356
|
-
|
|
110356
|
+
Readable5.call(this, options);
|
|
110357
110357
|
Writable2.call(this, options);
|
|
110358
110358
|
this.allowHalfOpen = true;
|
|
110359
110359
|
if (options) {
|
|
@@ -111009,14 +111009,14 @@ var require_from = __commonJS({
|
|
|
111009
111009
|
return (hint === "string" ? String : Number)(input);
|
|
111010
111010
|
}
|
|
111011
111011
|
var ERR_INVALID_ARG_TYPE = require_errors6().codes.ERR_INVALID_ARG_TYPE;
|
|
111012
|
-
function from(
|
|
111012
|
+
function from(Readable5, iterable, opts) {
|
|
111013
111013
|
var iterator;
|
|
111014
111014
|
if (iterable && typeof iterable.next === "function") {
|
|
111015
111015
|
iterator = iterable;
|
|
111016
111016
|
} else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();
|
|
111017
111017
|
else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();
|
|
111018
111018
|
else throw new ERR_INVALID_ARG_TYPE("iterable", ["Iterable"], iterable);
|
|
111019
|
-
var readable = new
|
|
111019
|
+
var readable = new Readable5(_objectSpread({
|
|
111020
111020
|
objectMode: true
|
|
111021
111021
|
}, opts));
|
|
111022
111022
|
var reading = false;
|
|
@@ -111056,9 +111056,9 @@ var require_from = __commonJS({
|
|
|
111056
111056
|
var require_stream_readable = __commonJS({
|
|
111057
111057
|
"../../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js"(exports, module) {
|
|
111058
111058
|
"use strict";
|
|
111059
|
-
module.exports =
|
|
111059
|
+
module.exports = Readable5;
|
|
111060
111060
|
var Duplex;
|
|
111061
|
-
|
|
111061
|
+
Readable5.ReadableState = ReadableState;
|
|
111062
111062
|
var EE = __require("events").EventEmitter;
|
|
111063
111063
|
var EElistenerCount = function EElistenerCount2(emitter, type) {
|
|
111064
111064
|
return emitter.listeners(type).length;
|
|
@@ -111093,7 +111093,7 @@ var require_stream_readable = __commonJS({
|
|
|
111093
111093
|
var StringDecoder;
|
|
111094
111094
|
var createReadableStreamAsyncIterator;
|
|
111095
111095
|
var from;
|
|
111096
|
-
require_inherits()(
|
|
111096
|
+
require_inherits()(Readable5, Stream);
|
|
111097
111097
|
var errorOrDestroy = destroyImpl.errorOrDestroy;
|
|
111098
111098
|
var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
|
|
111099
111099
|
function prependListener(emitter, event, fn) {
|
|
@@ -111137,9 +111137,9 @@ var require_stream_readable = __commonJS({
|
|
|
111137
111137
|
this.encoding = options.encoding;
|
|
111138
111138
|
}
|
|
111139
111139
|
}
|
|
111140
|
-
function
|
|
111140
|
+
function Readable5(options) {
|
|
111141
111141
|
Duplex = Duplex || require_stream_duplex();
|
|
111142
|
-
if (!(this instanceof
|
|
111142
|
+
if (!(this instanceof Readable5)) return new Readable5(options);
|
|
111143
111143
|
var isDuplex = this instanceof Duplex;
|
|
111144
111144
|
this._readableState = new ReadableState(options, this, isDuplex);
|
|
111145
111145
|
this.readable = true;
|
|
@@ -111149,7 +111149,7 @@ var require_stream_readable = __commonJS({
|
|
|
111149
111149
|
}
|
|
111150
111150
|
Stream.call(this);
|
|
111151
111151
|
}
|
|
111152
|
-
Object.defineProperty(
|
|
111152
|
+
Object.defineProperty(Readable5.prototype, "destroyed", {
|
|
111153
111153
|
// making it explicit this property is not enumerable
|
|
111154
111154
|
// because otherwise some prototype manipulation in
|
|
111155
111155
|
// userland will fail
|
|
@@ -111167,12 +111167,12 @@ var require_stream_readable = __commonJS({
|
|
|
111167
111167
|
this._readableState.destroyed = value;
|
|
111168
111168
|
}
|
|
111169
111169
|
});
|
|
111170
|
-
|
|
111171
|
-
|
|
111172
|
-
|
|
111170
|
+
Readable5.prototype.destroy = destroyImpl.destroy;
|
|
111171
|
+
Readable5.prototype._undestroy = destroyImpl.undestroy;
|
|
111172
|
+
Readable5.prototype._destroy = function(err, cb) {
|
|
111173
111173
|
cb(err);
|
|
111174
111174
|
};
|
|
111175
|
-
|
|
111175
|
+
Readable5.prototype.push = function(chunk2, encoding) {
|
|
111176
111176
|
var state = this._readableState;
|
|
111177
111177
|
var skipChunkCheck;
|
|
111178
111178
|
if (!state.objectMode) {
|
|
@@ -111189,7 +111189,7 @@ var require_stream_readable = __commonJS({
|
|
|
111189
111189
|
}
|
|
111190
111190
|
return readableAddChunk(this, chunk2, encoding, false, skipChunkCheck);
|
|
111191
111191
|
};
|
|
111192
|
-
|
|
111192
|
+
Readable5.prototype.unshift = function(chunk2) {
|
|
111193
111193
|
return readableAddChunk(this, chunk2, null, true, false);
|
|
111194
111194
|
};
|
|
111195
111195
|
function readableAddChunk(stream, chunk2, encoding, addToFront, skipChunkCheck) {
|
|
@@ -111250,10 +111250,10 @@ var require_stream_readable = __commonJS({
|
|
|
111250
111250
|
}
|
|
111251
111251
|
return er;
|
|
111252
111252
|
}
|
|
111253
|
-
|
|
111253
|
+
Readable5.prototype.isPaused = function() {
|
|
111254
111254
|
return this._readableState.flowing === false;
|
|
111255
111255
|
};
|
|
111256
|
-
|
|
111256
|
+
Readable5.prototype.setEncoding = function(enc) {
|
|
111257
111257
|
if (!StringDecoder) StringDecoder = require_string_decoder().StringDecoder;
|
|
111258
111258
|
var decoder = new StringDecoder(enc);
|
|
111259
111259
|
this._readableState.decoder = decoder;
|
|
@@ -111299,7 +111299,7 @@ var require_stream_readable = __commonJS({
|
|
|
111299
111299
|
}
|
|
111300
111300
|
return state.length;
|
|
111301
111301
|
}
|
|
111302
|
-
|
|
111302
|
+
Readable5.prototype.read = function(n) {
|
|
111303
111303
|
debug("read", n);
|
|
111304
111304
|
n = parseInt(n, 10);
|
|
111305
111305
|
var state = this._readableState;
|
|
@@ -111408,10 +111408,10 @@ var require_stream_readable = __commonJS({
|
|
|
111408
111408
|
}
|
|
111409
111409
|
state.readingMore = false;
|
|
111410
111410
|
}
|
|
111411
|
-
|
|
111411
|
+
Readable5.prototype._read = function(n) {
|
|
111412
111412
|
errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED("_read()"));
|
|
111413
111413
|
};
|
|
111414
|
-
|
|
111414
|
+
Readable5.prototype.pipe = function(dest, pipeOpts) {
|
|
111415
111415
|
var src = this;
|
|
111416
111416
|
var state = this._readableState;
|
|
111417
111417
|
switch (state.pipesCount) {
|
|
@@ -111514,7 +111514,7 @@ var require_stream_readable = __commonJS({
|
|
|
111514
111514
|
}
|
|
111515
111515
|
};
|
|
111516
111516
|
}
|
|
111517
|
-
|
|
111517
|
+
Readable5.prototype.unpipe = function(dest) {
|
|
111518
111518
|
var state = this._readableState;
|
|
111519
111519
|
var unpipeInfo = {
|
|
111520
111520
|
hasUnpiped: false
|
|
@@ -111548,7 +111548,7 @@ var require_stream_readable = __commonJS({
|
|
|
111548
111548
|
dest.emit("unpipe", this, unpipeInfo);
|
|
111549
111549
|
return this;
|
|
111550
111550
|
};
|
|
111551
|
-
|
|
111551
|
+
Readable5.prototype.on = function(ev, fn) {
|
|
111552
111552
|
var res = Stream.prototype.on.call(this, ev, fn);
|
|
111553
111553
|
var state = this._readableState;
|
|
111554
111554
|
if (ev === "data") {
|
|
@@ -111569,15 +111569,15 @@ var require_stream_readable = __commonJS({
|
|
|
111569
111569
|
}
|
|
111570
111570
|
return res;
|
|
111571
111571
|
};
|
|
111572
|
-
|
|
111573
|
-
|
|
111572
|
+
Readable5.prototype.addListener = Readable5.prototype.on;
|
|
111573
|
+
Readable5.prototype.removeListener = function(ev, fn) {
|
|
111574
111574
|
var res = Stream.prototype.removeListener.call(this, ev, fn);
|
|
111575
111575
|
if (ev === "readable") {
|
|
111576
111576
|
process.nextTick(updateReadableListening, this);
|
|
111577
111577
|
}
|
|
111578
111578
|
return res;
|
|
111579
111579
|
};
|
|
111580
|
-
|
|
111580
|
+
Readable5.prototype.removeAllListeners = function(ev) {
|
|
111581
111581
|
var res = Stream.prototype.removeAllListeners.apply(this, arguments);
|
|
111582
111582
|
if (ev === "readable" || ev === void 0) {
|
|
111583
111583
|
process.nextTick(updateReadableListening, this);
|
|
@@ -111597,7 +111597,7 @@ var require_stream_readable = __commonJS({
|
|
|
111597
111597
|
debug("readable nexttick read 0");
|
|
111598
111598
|
self2.read(0);
|
|
111599
111599
|
}
|
|
111600
|
-
|
|
111600
|
+
Readable5.prototype.resume = function() {
|
|
111601
111601
|
var state = this._readableState;
|
|
111602
111602
|
if (!state.flowing) {
|
|
111603
111603
|
debug("resume");
|
|
@@ -111623,7 +111623,7 @@ var require_stream_readable = __commonJS({
|
|
|
111623
111623
|
flow(stream);
|
|
111624
111624
|
if (state.flowing && !state.reading) stream.read(0);
|
|
111625
111625
|
}
|
|
111626
|
-
|
|
111626
|
+
Readable5.prototype.pause = function() {
|
|
111627
111627
|
debug("call pause flowing=%j", this._readableState.flowing);
|
|
111628
111628
|
if (this._readableState.flowing !== false) {
|
|
111629
111629
|
debug("pause");
|
|
@@ -111638,7 +111638,7 @@ var require_stream_readable = __commonJS({
|
|
|
111638
111638
|
debug("flow", state.flowing);
|
|
111639
111639
|
while (state.flowing && stream.read() !== null) ;
|
|
111640
111640
|
}
|
|
111641
|
-
|
|
111641
|
+
Readable5.prototype.wrap = function(stream) {
|
|
111642
111642
|
var _this = this;
|
|
111643
111643
|
var state = this._readableState;
|
|
111644
111644
|
var paused = false;
|
|
@@ -111683,14 +111683,14 @@ var require_stream_readable = __commonJS({
|
|
|
111683
111683
|
return this;
|
|
111684
111684
|
};
|
|
111685
111685
|
if (typeof Symbol === "function") {
|
|
111686
|
-
|
|
111686
|
+
Readable5.prototype[Symbol.asyncIterator] = function() {
|
|
111687
111687
|
if (createReadableStreamAsyncIterator === void 0) {
|
|
111688
111688
|
createReadableStreamAsyncIterator = require_async_iterator();
|
|
111689
111689
|
}
|
|
111690
111690
|
return createReadableStreamAsyncIterator(this);
|
|
111691
111691
|
};
|
|
111692
111692
|
}
|
|
111693
|
-
Object.defineProperty(
|
|
111693
|
+
Object.defineProperty(Readable5.prototype, "readableHighWaterMark", {
|
|
111694
111694
|
// making it explicit this property is not enumerable
|
|
111695
111695
|
// because otherwise some prototype manipulation in
|
|
111696
111696
|
// userland will fail
|
|
@@ -111699,7 +111699,7 @@ var require_stream_readable = __commonJS({
|
|
|
111699
111699
|
return this._readableState.highWaterMark;
|
|
111700
111700
|
}
|
|
111701
111701
|
});
|
|
111702
|
-
Object.defineProperty(
|
|
111702
|
+
Object.defineProperty(Readable5.prototype, "readableBuffer", {
|
|
111703
111703
|
// making it explicit this property is not enumerable
|
|
111704
111704
|
// because otherwise some prototype manipulation in
|
|
111705
111705
|
// userland will fail
|
|
@@ -111708,7 +111708,7 @@ var require_stream_readable = __commonJS({
|
|
|
111708
111708
|
return this._readableState && this._readableState.buffer;
|
|
111709
111709
|
}
|
|
111710
111710
|
});
|
|
111711
|
-
Object.defineProperty(
|
|
111711
|
+
Object.defineProperty(Readable5.prototype, "readableFlowing", {
|
|
111712
111712
|
// making it explicit this property is not enumerable
|
|
111713
111713
|
// because otherwise some prototype manipulation in
|
|
111714
111714
|
// userland will fail
|
|
@@ -111722,8 +111722,8 @@ var require_stream_readable = __commonJS({
|
|
|
111722
111722
|
}
|
|
111723
111723
|
}
|
|
111724
111724
|
});
|
|
111725
|
-
|
|
111726
|
-
Object.defineProperty(
|
|
111725
|
+
Readable5._fromList = fromList;
|
|
111726
|
+
Object.defineProperty(Readable5.prototype, "readableLength", {
|
|
111727
111727
|
// making it explicit this property is not enumerable
|
|
111728
111728
|
// because otherwise some prototype manipulation in
|
|
111729
111729
|
// userland will fail
|
|
@@ -111769,11 +111769,11 @@ var require_stream_readable = __commonJS({
|
|
|
111769
111769
|
}
|
|
111770
111770
|
}
|
|
111771
111771
|
if (typeof Symbol === "function") {
|
|
111772
|
-
|
|
111772
|
+
Readable5.from = function(iterable, opts) {
|
|
111773
111773
|
if (from === void 0) {
|
|
111774
111774
|
from = require_from();
|
|
111775
111775
|
}
|
|
111776
|
-
return from(
|
|
111776
|
+
return from(Readable5, iterable, opts);
|
|
111777
111777
|
};
|
|
111778
111778
|
}
|
|
111779
111779
|
function indexOf(xs, x2) {
|
|
@@ -112390,7 +112390,7 @@ var require_websocket2 = __commonJS({
|
|
|
112390
112390
|
var { ServerResponse } = __require("node:http");
|
|
112391
112391
|
var { PassThrough } = __require("node:stream");
|
|
112392
112392
|
var { randomBytes: randomBytes5 } = __require("node:crypto");
|
|
112393
|
-
var
|
|
112393
|
+
var fp38 = require_plugin2();
|
|
112394
112394
|
var WebSocket2 = require_ws();
|
|
112395
112395
|
var Duplexify = require_duplexify();
|
|
112396
112396
|
var kWs = /* @__PURE__ */ Symbol("ws-socket");
|
|
@@ -112576,7 +112576,7 @@ var require_websocket2 = __commonJS({
|
|
|
112576
112576
|
}
|
|
112577
112577
|
next();
|
|
112578
112578
|
}
|
|
112579
|
-
module.exports =
|
|
112579
|
+
module.exports = fp38(fastifyWebsocket2, {
|
|
112580
112580
|
fastify: "5.x",
|
|
112581
112581
|
name: "@fastify/websocket"
|
|
112582
112582
|
});
|
|
@@ -113826,7 +113826,7 @@ var require_basename = __commonJS({
|
|
|
113826
113826
|
var require_multipart = __commonJS({
|
|
113827
113827
|
"../../node_modules/.pnpm/@fastify+busboy@3.2.0/node_modules/@fastify/busboy/lib/types/multipart.js"(exports, module) {
|
|
113828
113828
|
"use strict";
|
|
113829
|
-
var { Readable:
|
|
113829
|
+
var { Readable: Readable5 } = __require("node:stream");
|
|
113830
113830
|
var { inherits } = __require("node:util");
|
|
113831
113831
|
var Dicer = require_Dicer();
|
|
113832
113832
|
var parseParams = require_parseParams();
|
|
@@ -114091,11 +114091,11 @@ var require_multipart = __commonJS({
|
|
|
114091
114091
|
part.resume();
|
|
114092
114092
|
}
|
|
114093
114093
|
function FileStream(opts) {
|
|
114094
|
-
|
|
114094
|
+
Readable5.call(this, opts);
|
|
114095
114095
|
this.bytesRead = 0;
|
|
114096
114096
|
this.truncated = false;
|
|
114097
114097
|
}
|
|
114098
|
-
inherits(FileStream,
|
|
114098
|
+
inherits(FileStream, Readable5);
|
|
114099
114099
|
FileStream.prototype._read = function(n) {
|
|
114100
114100
|
};
|
|
114101
114101
|
module.exports = Multipart;
|
|
@@ -115020,7 +115020,7 @@ var require_multipart2 = __commonJS({
|
|
|
115020
115020
|
"use strict";
|
|
115021
115021
|
var Busboy = require_main();
|
|
115022
115022
|
var os3 = __require("node:os");
|
|
115023
|
-
var
|
|
115023
|
+
var fp38 = require_plugin2();
|
|
115024
115024
|
var { createWriteStream: createWriteStream2 } = __require("node:fs");
|
|
115025
115025
|
var { unlink: unlink2 } = __require("node:fs/promises");
|
|
115026
115026
|
var path26 = __require("node:path");
|
|
@@ -115028,7 +115028,7 @@ var require_multipart2 = __commonJS({
|
|
|
115028
115028
|
var createError = require_error2();
|
|
115029
115029
|
var streamToNull = require_stream_consumer();
|
|
115030
115030
|
var deepmergeAll = require_deepmerge()({ all: true });
|
|
115031
|
-
var { PassThrough, Readable:
|
|
115031
|
+
var { PassThrough, Readable: Readable5 } = __require("node:stream");
|
|
115032
115032
|
var { pipeline: pump } = __require("node:stream/promises");
|
|
115033
115033
|
var secureJSON = require_secure_json_parse();
|
|
115034
115034
|
var kMultipart = /* @__PURE__ */ Symbol("multipart");
|
|
@@ -115407,7 +115407,7 @@ var require_multipart2 = __commonJS({
|
|
|
115407
115407
|
if (!field._buf) {
|
|
115408
115408
|
throw new FileBufferNotFoundError();
|
|
115409
115409
|
}
|
|
115410
|
-
field.file =
|
|
115410
|
+
field.file = Readable5.from(field._buf);
|
|
115411
115411
|
yield field;
|
|
115412
115412
|
}
|
|
115413
115413
|
} catch (err) {
|
|
@@ -115469,7 +115469,7 @@ var require_multipart2 = __commonJS({
|
|
|
115469
115469
|
}
|
|
115470
115470
|
});
|
|
115471
115471
|
}
|
|
115472
|
-
module.exports =
|
|
115472
|
+
module.exports = fp38(fastifyMultipart2, {
|
|
115473
115473
|
fastify: "5.x",
|
|
115474
115474
|
name: "@fastify/multipart"
|
|
115475
115475
|
});
|
|
@@ -126452,7 +126452,7 @@ var require_readable2 = __commonJS({
|
|
|
126452
126452
|
"../../node_modules/.pnpm/undici@7.22.0/node_modules/undici/lib/api/readable.js"(exports, module) {
|
|
126453
126453
|
"use strict";
|
|
126454
126454
|
var assert2 = __require("node:assert");
|
|
126455
|
-
var { Readable:
|
|
126455
|
+
var { Readable: Readable5 } = __require("node:stream");
|
|
126456
126456
|
var { RequestAbortedError, NotSupportedError, InvalidArgumentError: InvalidArgumentError4, AbortError } = require_errors7();
|
|
126457
126457
|
var util2 = require_util7();
|
|
126458
126458
|
var { ReadableStreamFrom } = require_util7();
|
|
@@ -126466,7 +126466,7 @@ var require_readable2 = __commonJS({
|
|
|
126466
126466
|
var kBytesRead = /* @__PURE__ */ Symbol("kBytesRead");
|
|
126467
126467
|
var noop4 = () => {
|
|
126468
126468
|
};
|
|
126469
|
-
var BodyReadable = class extends
|
|
126469
|
+
var BodyReadable = class extends Readable5 {
|
|
126470
126470
|
/**
|
|
126471
126471
|
* @param {object} opts
|
|
126472
126472
|
* @param {(this: Readable, size: number) => void} opts.resume
|
|
@@ -126855,7 +126855,7 @@ var require_api_request = __commonJS({
|
|
|
126855
126855
|
"use strict";
|
|
126856
126856
|
var assert2 = __require("node:assert");
|
|
126857
126857
|
var { AsyncResource } = __require("node:async_hooks");
|
|
126858
|
-
var { Readable:
|
|
126858
|
+
var { Readable: Readable5 } = require_readable2();
|
|
126859
126859
|
var { InvalidArgumentError: InvalidArgumentError4, RequestAbortedError } = require_errors7();
|
|
126860
126860
|
var util2 = require_util7();
|
|
126861
126861
|
function noop4() {
|
|
@@ -126936,7 +126936,7 @@ var require_api_request = __commonJS({
|
|
|
126936
126936
|
const parsedHeaders = responseHeaders === "raw" ? util2.parseHeaders(rawHeaders) : headers;
|
|
126937
126937
|
const contentType2 = parsedHeaders["content-type"];
|
|
126938
126938
|
const contentLength = parsedHeaders["content-length"];
|
|
126939
|
-
const res = new
|
|
126939
|
+
const res = new Readable5({
|
|
126940
126940
|
resume,
|
|
126941
126941
|
abort,
|
|
126942
126942
|
contentType: contentType2,
|
|
@@ -127245,7 +127245,7 @@ var require_api_pipeline = __commonJS({
|
|
|
127245
127245
|
"../../node_modules/.pnpm/undici@7.22.0/node_modules/undici/lib/api/api-pipeline.js"(exports, module) {
|
|
127246
127246
|
"use strict";
|
|
127247
127247
|
var {
|
|
127248
|
-
Readable:
|
|
127248
|
+
Readable: Readable5,
|
|
127249
127249
|
Duplex,
|
|
127250
127250
|
PassThrough
|
|
127251
127251
|
} = __require("node:stream");
|
|
@@ -127261,7 +127261,7 @@ var require_api_pipeline = __commonJS({
|
|
|
127261
127261
|
function noop4() {
|
|
127262
127262
|
}
|
|
127263
127263
|
var kResume = /* @__PURE__ */ Symbol("resume");
|
|
127264
|
-
var PipelineRequest = class extends
|
|
127264
|
+
var PipelineRequest = class extends Readable5 {
|
|
127265
127265
|
constructor() {
|
|
127266
127266
|
super({ autoDestroy: true });
|
|
127267
127267
|
this[kResume] = null;
|
|
@@ -127278,7 +127278,7 @@ var require_api_pipeline = __commonJS({
|
|
|
127278
127278
|
callback(err);
|
|
127279
127279
|
}
|
|
127280
127280
|
};
|
|
127281
|
-
var PipelineResponse = class extends
|
|
127281
|
+
var PipelineResponse = class extends Readable5 {
|
|
127282
127282
|
constructor(resume) {
|
|
127283
127283
|
super({ autoDestroy: true });
|
|
127284
127284
|
this[kResume] = resume;
|
|
@@ -131776,7 +131776,7 @@ var require_cache2 = __commonJS({
|
|
|
131776
131776
|
"../../node_modules/.pnpm/undici@7.22.0/node_modules/undici/lib/interceptor/cache.js"(exports, module) {
|
|
131777
131777
|
"use strict";
|
|
131778
131778
|
var assert2 = __require("node:assert");
|
|
131779
|
-
var { Readable:
|
|
131779
|
+
var { Readable: Readable5 } = __require("node:stream");
|
|
131780
131780
|
var util2 = require_util7();
|
|
131781
131781
|
var CacheHandler = require_cache_handler();
|
|
131782
131782
|
var MemoryCacheStore = require_memory_cache_store();
|
|
@@ -131865,7 +131865,7 @@ var require_cache2 = __commonJS({
|
|
|
131865
131865
|
return dispatch(opts, new CacheHandler(globalOpts, cacheKey2, handler));
|
|
131866
131866
|
}
|
|
131867
131867
|
function sendCachedValue(handler, opts, result, age, context2, isStale2) {
|
|
131868
|
-
const stream = util2.isStream(result.body) ? result.body :
|
|
131868
|
+
const stream = util2.isStream(result.body) ? result.body : Readable5.from(result.body ?? []);
|
|
131869
131869
|
assert2(!stream.destroyed, "stream should not be destroyed");
|
|
131870
131870
|
assert2(!stream.readableDidRead, "stream should not be readableDidRead");
|
|
131871
131871
|
const controller = {
|
|
@@ -134791,7 +134791,7 @@ var require_fetch2 = __commonJS({
|
|
|
134791
134791
|
subresourceSet
|
|
134792
134792
|
} = require_constants9();
|
|
134793
134793
|
var EE = __require("node:events");
|
|
134794
|
-
var { Readable:
|
|
134794
|
+
var { Readable: Readable5, pipeline, finished, isErrored, isReadable } = __require("node:stream");
|
|
134795
134795
|
var { addAbortListener, bufferToLowerCasedHeaderName } = require_util7();
|
|
134796
134796
|
var { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require_data_url();
|
|
134797
134797
|
var { getGlobalDispatcher } = require_global2();
|
|
@@ -135717,7 +135717,7 @@ var require_fetch2 = __commonJS({
|
|
|
135717
135717
|
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i]), rawHeaders[i + 1].toString("latin1"), true);
|
|
135718
135718
|
}
|
|
135719
135719
|
const location = headersList.get("location", true);
|
|
135720
|
-
this.body = new
|
|
135720
|
+
this.body = new Readable5({ read: resume });
|
|
135721
135721
|
const willFollow = location && request.redirect === "follow" && redirectStatusSet.has(status);
|
|
135722
135722
|
const decoders = [];
|
|
135723
135723
|
if (request.method !== "HEAD" && request.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) {
|
|
@@ -169126,11 +169126,11 @@ function buildCommand(builderArgs) {
|
|
|
169126
169126
|
}
|
|
169127
169127
|
};
|
|
169128
169128
|
}
|
|
169129
|
-
function* generateRouteMapHelpLines(
|
|
169129
|
+
function* generateRouteMapHelpLines(routes37, docs, args) {
|
|
169130
169130
|
const { brief, fullDescription, hideRoute } = docs;
|
|
169131
169131
|
const { headers } = args.text;
|
|
169132
169132
|
yield args.ansiColor ? `\x1B[1m${headers.usage}\x1B[22m` : headers.usage;
|
|
169133
|
-
for (const [name25, route] of Object.entries(
|
|
169133
|
+
for (const [name25, route] of Object.entries(routes37)) {
|
|
169134
169134
|
if (!hideRoute || !hideRoute[name25] || args.includeHidden) {
|
|
169135
169135
|
const externalRouteName = args.config.caseStyle === "convert-camel-to-kebab" ? convertCamelCaseToKebabCase(name25) : name25;
|
|
169136
169136
|
yield ` ${route.formatUsageLine({
|
|
@@ -169160,7 +169160,7 @@ function* generateRouteMapHelpLines(routes36, docs, args) {
|
|
|
169160
169160
|
}
|
|
169161
169161
|
yield "";
|
|
169162
169162
|
yield args.ansiColor ? `\x1B[1m${headers.commands}\x1B[22m` : headers.commands;
|
|
169163
|
-
const visibleRoutes = Object.entries(
|
|
169163
|
+
const visibleRoutes = Object.entries(routes37).filter(
|
|
169164
169164
|
([name25]) => !hideRoute || !hideRoute[name25] || args.includeHidden
|
|
169165
169165
|
);
|
|
169166
169166
|
const rows = visibleRoutes.map(([internalRouteName, route]) => {
|
|
@@ -169188,24 +169188,24 @@ function* generateRouteMapHelpLines(routes36, docs, args) {
|
|
|
169188
169188
|
}
|
|
169189
169189
|
}
|
|
169190
169190
|
function buildRouteMap({
|
|
169191
|
-
routes:
|
|
169191
|
+
routes: routes37,
|
|
169192
169192
|
defaultCommand: defaultCommandRoute,
|
|
169193
169193
|
docs,
|
|
169194
169194
|
aliases
|
|
169195
169195
|
}) {
|
|
169196
|
-
if (Object.entries(
|
|
169196
|
+
if (Object.entries(routes37).length === 0) {
|
|
169197
169197
|
throw new InternalError("Route map must contain at least one route");
|
|
169198
169198
|
}
|
|
169199
169199
|
const activeAliases = aliases ?? {};
|
|
169200
169200
|
const aliasesByRoute = /* @__PURE__ */ new Map();
|
|
169201
169201
|
for (const [alias, routeName] of Object.entries(activeAliases)) {
|
|
169202
|
-
if (alias in
|
|
169202
|
+
if (alias in routes37) {
|
|
169203
169203
|
throw new InternalError(`Cannot use "${alias}" as an alias when a route with that name already exists`);
|
|
169204
169204
|
}
|
|
169205
169205
|
const routeAliases = aliasesByRoute.get(routeName) ?? [];
|
|
169206
169206
|
aliasesByRoute.set(routeName, [...routeAliases, alias]);
|
|
169207
169207
|
}
|
|
169208
|
-
const defaultCommand = defaultCommandRoute ?
|
|
169208
|
+
const defaultCommand = defaultCommandRoute ? routes37[defaultCommandRoute] : void 0;
|
|
169209
169209
|
if (defaultCommand && defaultCommand.kind === RouteMapSymbol) {
|
|
169210
169210
|
throw new InternalError(
|
|
169211
169211
|
`Cannot use "${defaultCommandRoute}" as the default command because it is not a Command`
|
|
@@ -169214,7 +169214,7 @@ function buildRouteMap({
|
|
|
169214
169214
|
const resolveRouteName = (input) => {
|
|
169215
169215
|
if (input in activeAliases) {
|
|
169216
169216
|
return activeAliases[input];
|
|
169217
|
-
} else if (input in
|
|
169217
|
+
} else if (input in routes37) {
|
|
169218
169218
|
return input;
|
|
169219
169219
|
}
|
|
169220
169220
|
};
|
|
@@ -169232,7 +169232,7 @@ function buildRouteMap({
|
|
|
169232
169232
|
return `${args.prefix.join(" ")} ${routeNames.join("|")} ...`;
|
|
169233
169233
|
},
|
|
169234
169234
|
formatHelp: (config2) => {
|
|
169235
|
-
const lines = [...generateRouteMapHelpLines(
|
|
169235
|
+
const lines = [...generateRouteMapHelpLines(routes37, docs, config2)];
|
|
169236
169236
|
const text2 = lines.join("\n");
|
|
169237
169237
|
return text2 + "\n";
|
|
169238
169238
|
},
|
|
@@ -169275,11 +169275,11 @@ function buildRouteMap({
|
|
|
169275
169275
|
},
|
|
169276
169276
|
getRoutingTargetForInput: (input) => {
|
|
169277
169277
|
const routeName = input in activeAliases ? activeAliases[input] : input;
|
|
169278
|
-
return
|
|
169278
|
+
return routes37[routeName];
|
|
169279
169279
|
},
|
|
169280
169280
|
getAllEntries() {
|
|
169281
169281
|
const hiddenRoutes = docs.hideRoute;
|
|
169282
|
-
return Object.entries(
|
|
169282
|
+
return Object.entries(routes37).map(([originalRouteName, target]) => {
|
|
169283
169283
|
return {
|
|
169284
169284
|
name: {
|
|
169285
169285
|
original: originalRouteName,
|
|
@@ -186099,6 +186099,14 @@ var createScheduledRepos = (kdb, h) => ({
|
|
|
186099
186099
|
}
|
|
186100
186100
|
});
|
|
186101
186101
|
|
|
186102
|
+
// src/storage/repositories/session-side-rows.ts
|
|
186103
|
+
async function deleteSessionSideRows(trx, sessionIds) {
|
|
186104
|
+
if (sessionIds.length === 0) return;
|
|
186105
|
+
const ids = [...sessionIds];
|
|
186106
|
+
await trx.deleteFrom("agent_session_remote_grants").where("session_id", "in", ids).execute();
|
|
186107
|
+
await trx.deleteFrom("agent_session_remote_touches").where("session_id", "in", ids).execute();
|
|
186108
|
+
}
|
|
186109
|
+
|
|
186102
186110
|
// src/storage/repositories/core.ts
|
|
186103
186111
|
var mapProject = (row) => ({
|
|
186104
186112
|
id: row.id,
|
|
@@ -186180,7 +186188,12 @@ var createCoreRepos = (kdb, h) => ({
|
|
|
186180
186188
|
let scope = trx.selectFrom("projects").select("id").where("id", "=", id);
|
|
186181
186189
|
if (userId) scope = scope.where("user_id", "=", userId);
|
|
186182
186190
|
if (!await scope.executeTakeFirst()) return;
|
|
186183
|
-
const mappings = await trx.selectFrom("remote_session_mappings").select(["remote_server_id", "remote_session_id"]).where("project_id", "=", id).execute();
|
|
186191
|
+
const mappings = await trx.selectFrom("remote_session_mappings").select(["local_session_id", "remote_server_id", "remote_session_id"]).where("project_id", "=", id).execute();
|
|
186192
|
+
const localSessions = await trx.selectFrom("agent_sessions").select("id").where("project_id", "=", id).execute();
|
|
186193
|
+
await deleteSessionSideRows(trx, [
|
|
186194
|
+
...localSessions.map((row) => row.id),
|
|
186195
|
+
...mappings.map((row) => row.local_session_id)
|
|
186196
|
+
]);
|
|
186184
186197
|
for (const mapping of mappings) {
|
|
186185
186198
|
await trx.deleteFrom("notification_sync_cursors").where("remote_server_id", "=", mapping.remote_server_id).where("remote_session_id", "=", mapping.remote_session_id).execute();
|
|
186186
186199
|
}
|
|
@@ -187319,7 +187332,7 @@ var createAgentSessionRepos = (kdb, h) => ({
|
|
|
187319
187332
|
delete: async (id) => {
|
|
187320
187333
|
await kdb.transaction().execute(async (trx) => {
|
|
187321
187334
|
await trx.deleteFrom("agent_sessions").where("id", "=", id).execute();
|
|
187322
|
-
await trx
|
|
187335
|
+
await deleteSessionSideRows(trx, [id]);
|
|
187323
187336
|
});
|
|
187324
187337
|
},
|
|
187325
187338
|
// The original inline statement is `INSERT ... ON CONFLICT(session_id,
|
|
@@ -187375,19 +187388,25 @@ var createAgentSessionRepos = (kdb, h) => ({
|
|
|
187375
187388
|
return query.orderBy("activity_at", "asc").orderBy("id", "asc").limit(limit).execute();
|
|
187376
187389
|
},
|
|
187377
187390
|
deleteIfExpired: async (id, cutoff) => {
|
|
187378
|
-
|
|
187379
|
-
|
|
187391
|
+
return kdb.transaction().execute(async (trx) => {
|
|
187392
|
+
const result = await trx.deleteFrom("agent_sessions").where("id", "=", id).where(retentionPredicate(cutoff)).executeTakeFirst();
|
|
187393
|
+
const deleted = (result.numDeletedRows ?? 0n) > 0n;
|
|
187394
|
+
if (deleted) await deleteSessionSideRows(trx, [id]);
|
|
187395
|
+
return deleted;
|
|
187396
|
+
});
|
|
187380
187397
|
},
|
|
187381
187398
|
// Legacy compensation only ever targets rows the legacy `/new` path
|
|
187382
187399
|
// created, i.e. `active` ones. Pending identities and tombstones belong
|
|
187383
187400
|
// to the lifecycle service; deleting them here would break its replay.
|
|
187384
|
-
deleteIfEmpty: async (id) => {
|
|
187385
|
-
const result = await
|
|
187401
|
+
deleteIfEmpty: async (id) => kdb.transaction().execute(async (trx) => {
|
|
187402
|
+
const result = await trx.deleteFrom("agent_sessions").where("id", "=", id).where("lifecycle_state", "=", "active").where(sql`NOT EXISTS (
|
|
187386
187403
|
SELECT 1 FROM agent_session_entries entry
|
|
187387
187404
|
WHERE entry.session_id = agent_sessions.id
|
|
187388
187405
|
)`).executeTakeFirst();
|
|
187389
|
-
|
|
187390
|
-
|
|
187406
|
+
const deleted = (result.numDeletedRows ?? 0n) > 0n;
|
|
187407
|
+
if (deleted) await deleteSessionSideRows(trx, [id]);
|
|
187408
|
+
return deleted;
|
|
187409
|
+
}),
|
|
187391
187410
|
listIdsByProject: async (projectId) => {
|
|
187392
187411
|
const rows = await kdb.selectFrom("agent_sessions").select("id").where("project_id", "=", projectId).where(visibleLifecycle).orderBy("id", "asc").execute();
|
|
187393
187412
|
return rows.map((r) => r.id);
|
|
@@ -187556,8 +187575,11 @@ var createAgentSessionRepos = (kdb, h) => ({
|
|
|
187556
187575
|
deleteExpiredTombstones: async ({ cutoff, limit }) => {
|
|
187557
187576
|
const victims = await kdb.selectFrom("agent_sessions").select("id").where("lifecycle_state", "=", "expired").where("expired_at", "is not", null).where("expired_at", "<", cutoff).orderBy("expired_at", "asc").limit(limit).execute();
|
|
187558
187577
|
if (victims.length === 0) return 0;
|
|
187559
|
-
|
|
187560
|
-
|
|
187578
|
+
return kdb.transaction().execute(async (trx) => {
|
|
187579
|
+
const deleted = await trx.deleteFrom("agent_sessions").where("id", "in", victims.map((r) => r.id)).where("lifecycle_state", "=", "expired").where("expired_at", "<", cutoff).returning("id").execute();
|
|
187580
|
+
await deleteSessionSideRows(trx, deleted.map((r) => r.id));
|
|
187581
|
+
return deleted.length;
|
|
187582
|
+
});
|
|
187561
187583
|
},
|
|
187562
187584
|
clearActivationPayloads: async ({ cutoff, limit }) => {
|
|
187563
187585
|
const rows = await kdb.selectFrom("agent_sessions").select("id").where("lifecycle_state", "=", "active").where("activation_content_json", "is not", null).where("activated_at", "is not", null).where("activated_at", "<", cutoff).limit(limit).execute();
|
|
@@ -187748,7 +187770,7 @@ var createAgentSessionRepos = (kdb, h) => ({
|
|
|
187748
187770
|
if (row) {
|
|
187749
187771
|
await trx.deleteFrom("notification_sync_cursors").where("remote_server_id", "=", row.remote_server_id).where("remote_session_id", "=", row.remote_session_id).execute();
|
|
187750
187772
|
}
|
|
187751
|
-
await trx
|
|
187773
|
+
await deleteSessionSideRows(trx, [localSessionId]);
|
|
187752
187774
|
return (result.numDeletedRows ?? 0n) > 0n;
|
|
187753
187775
|
});
|
|
187754
187776
|
},
|
|
@@ -188167,15 +188189,18 @@ var createCrossRemoteAuditRepo = (kdb) => ({
|
|
|
188167
188189
|
insert: async (entry) => {
|
|
188168
188190
|
await kdb.insertInto("cross_remote_audit").values({ id: crypto3.randomUUID(), created_at: (/* @__PURE__ */ new Date()).toISOString(), ...entry }).execute();
|
|
188169
188191
|
},
|
|
188170
|
-
listSessionTargets: async (sessionId, userId, limit = 8) => {
|
|
188171
|
-
let query = kdb.selectFrom("cross_remote_audit").select(["target_remote_id"]).select((eb) => eb.fn.max("seq").as("last_seq")).where("session_id", "=", sessionId).where("status", "not in", ["denied", "offline"]);
|
|
188172
|
-
if (userId) query = query.where("user_id", "=", userId);
|
|
188173
|
-
const rows = await query.groupBy("target_remote_id").orderBy("last_seq", "desc").limit(limit).execute();
|
|
188174
|
-
return rows.map((row) => row.target_remote_id);
|
|
188175
|
-
},
|
|
188176
188192
|
listByTarget: async (targetRemoteId, limit = 100) => {
|
|
188177
188193
|
const rows = await kdb.selectFrom("cross_remote_audit").selectAll().where("target_remote_id", "=", targetRemoteId).orderBy("seq", "desc").limit(limit).execute();
|
|
188178
188194
|
return rows.map(mapRow);
|
|
188195
|
+
},
|
|
188196
|
+
pruneBefore: async (cutoff, limit) => {
|
|
188197
|
+
const firstKept = await kdb.selectFrom("cross_remote_audit").select("seq").where("created_at", ">=", cutoff.toISOString()).orderBy("seq", "asc").limit(1).executeTakeFirst();
|
|
188198
|
+
const result = await kdb.deleteFrom("cross_remote_audit").where("seq", "in", (eb) => {
|
|
188199
|
+
let batch = eb.selectFrom("cross_remote_audit").select("seq");
|
|
188200
|
+
if (firstKept) batch = batch.where("seq", "<", firstKept.seq);
|
|
188201
|
+
return batch.orderBy("seq", "asc").limit(limit);
|
|
188202
|
+
}).executeTakeFirst();
|
|
188203
|
+
return Number(result.numDeletedRows ?? 0n);
|
|
188179
188204
|
}
|
|
188180
188205
|
}
|
|
188181
188206
|
});
|
|
@@ -188207,6 +188232,22 @@ var createSessionRemoteGrantRepo = (kdb) => ({
|
|
|
188207
188232
|
}
|
|
188208
188233
|
});
|
|
188209
188234
|
|
|
188235
|
+
// src/storage/repositories/session-remote-touches.ts
|
|
188236
|
+
var createSessionRemoteTouchRepo = (kdb) => ({
|
|
188237
|
+
sessionRemoteTouches: {
|
|
188238
|
+
record: async (sessionId, userId, remoteServerId) => {
|
|
188239
|
+
const now3 = (/* @__PURE__ */ new Date()).toISOString();
|
|
188240
|
+
await kdb.insertInto("agent_session_remote_touches").values({ session_id: sessionId, remote_server_id: remoteServerId, user_id: userId, last_used_at: now3 }).onConflict((oc) => oc.columns(["session_id", "remote_server_id"]).doUpdateSet({ last_used_at: now3 })).execute();
|
|
188241
|
+
},
|
|
188242
|
+
list: async (sessionId, userId, limit = 8) => {
|
|
188243
|
+
let query = kdb.selectFrom("agent_session_remote_touches").select("remote_server_id").where("session_id", "=", sessionId);
|
|
188244
|
+
if (userId) query = query.where("user_id", "=", userId);
|
|
188245
|
+
const rows = await query.orderBy("last_used_at", "desc").orderBy("remote_server_id", "asc").limit(limit).execute();
|
|
188246
|
+
return rows.map((row) => row.remote_server_id);
|
|
188247
|
+
}
|
|
188248
|
+
}
|
|
188249
|
+
});
|
|
188250
|
+
|
|
188210
188251
|
// src/storage/repositories/merge-targets.ts
|
|
188211
188252
|
var createMergeTargetsRepo = (kdb) => ({
|
|
188212
188253
|
mergeTargets: {
|
|
@@ -188806,15 +188847,14 @@ var createSearchCacheRepos = (kdb, _h) => ({
|
|
|
188806
188847
|
favorited: false,
|
|
188807
188848
|
recency: 0
|
|
188808
188849
|
})), limitPerGroup);
|
|
188809
|
-
const wsRows = await kdb.selectFrom("workspace_search_cache as w").leftJoin("project_remotes as pr", (join2) => join2.onRef("pr.project_id", "=", "w.project_id").onRef("pr.remote_server_id", "=", "w.target_id")).select(["w.project_id", "w.
|
|
188850
|
+
const wsRows = await kdb.selectFrom("workspace_search_cache as w").leftJoin("project_remotes as pr", (join2) => join2.onRef("pr.project_id", "=", "w.project_id").onRef("pr.remote_server_id", "=", "w.target_id")).select(["w.project_id", "w.branch"]).where("w.project_id", "in", projectIds).where("w.deleted_at", "is", null).where((eb) => eb.or([
|
|
188810
188851
|
eb("w.target_id", "=", "local"),
|
|
188811
188852
|
eb("pr.id", "is not", null)
|
|
188812
|
-
])).execute();
|
|
188853
|
+
])).groupBy(["w.project_id", "w.branch"]).execute();
|
|
188813
188854
|
const workspaces = rankAndCap(wsRows.map((w2) => ({
|
|
188814
188855
|
item: {
|
|
188815
188856
|
projectId: w2.project_id,
|
|
188816
188857
|
projectName: nameById.get(w2.project_id) ?? "",
|
|
188817
|
-
targetId: w2.target_id,
|
|
188818
188858
|
branch: fromDbBranch(w2.branch)
|
|
188819
188859
|
},
|
|
188820
188860
|
tier: matchTier(fromDbBranch(w2.branch) ?? "main", q),
|
|
@@ -188883,6 +188923,10 @@ var createWorkflowRunRepos = (kdb) => ({
|
|
|
188883
188923
|
const row = await kdb.selectFrom("workflow_runs").selectAll().where("loop_id", "=", loopId).where("round", "=", round).orderBy("created_at", "desc").orderBy(sql`rowid`, "desc").executeTakeFirst();
|
|
188884
188924
|
return row ? asRun(row) : void 0;
|
|
188885
188925
|
},
|
|
188926
|
+
getLatestLoopRunByReviewer: async (reviewerSessionId) => {
|
|
188927
|
+
const row = await kdb.selectFrom("workflow_runs").selectAll().where("reviewer_session_id", "=", reviewerSessionId).where("loop_id", "is not", null).where("kind", "=", "review").orderBy("created_at", "desc").orderBy(sql`rowid`, "desc").executeTakeFirst();
|
|
188928
|
+
return row ? asRun(row) : void 0;
|
|
188929
|
+
},
|
|
188886
188930
|
listReviewedSourceSessions: async (projectId, branch) => {
|
|
188887
188931
|
const rows = await kdb.selectFrom("workflow_runs").select("source_session_id").distinct().where("project_id", "=", projectId).where("branch", "is", branch).where("status", "=", "completed").where("reviewer_session_id", "is not", null).execute();
|
|
188888
188932
|
return rows.map((r) => r.source_session_id);
|
|
@@ -188960,10 +189004,11 @@ var createWorkflowRunRepos = (kdb) => ({
|
|
|
188960
189004
|
await sql`
|
|
188961
189005
|
INSERT INTO workflow_runs
|
|
188962
189006
|
(id, project_id, branch, source_session_id, source_turn_end_index, reviewer_session_id,
|
|
188963
|
-
review_focus, review_target, review_span, status, loop_id, round, max_rounds)
|
|
189007
|
+
review_focus, review_target, review_span, status, loop_id, round, max_rounds, loop_manual)
|
|
188964
189008
|
SELECT ${nextRun.id}, ${nextRun.project_id}, ${nextRun.branch}, ${nextRun.source_session_id},
|
|
188965
189009
|
${nextRun.source_turn_end_index}, NULL, ${nextRun.review_focus}, ${nextRun.review_target},
|
|
188966
|
-
'this_turn', 'waiting_rereview', ${nextRun.loop_id}, ${nextRun.round}, ${nextRun.max_rounds}
|
|
189010
|
+
'this_turn', 'waiting_rereview', ${nextRun.loop_id}, ${nextRun.round}, ${nextRun.max_rounds},
|
|
189011
|
+
${nextRun.loop_manual}
|
|
188967
189012
|
WHERE NOT EXISTS (
|
|
188968
189013
|
SELECT 1 FROM workflow_runs
|
|
188969
189014
|
WHERE status IN (${sql.join(ACTIVE)})
|
|
@@ -203220,6 +203265,19 @@ function assertProjectChatMessageWithinByteLimit(type, content) {
|
|
|
203220
203265
|
|
|
203221
203266
|
// src/storage/repositories/project-chat.ts
|
|
203222
203267
|
var now = () => sql`strftime('%Y-%m-%d %H:%M:%f', 'now')`;
|
|
203268
|
+
async function backfillMissingThreadTitles(kdb, projectId, userId, threadId) {
|
|
203269
|
+
let query = kdb.updateTable("project_chat_threads").set({ title: sql`(
|
|
203270
|
+
select substr(trim(m.content), 1, 60)
|
|
203271
|
+
from project_chat_messages as m
|
|
203272
|
+
where m.thread_id = project_chat_threads.id and m.type = 'user'
|
|
203273
|
+
order by m.sequence asc limit 1
|
|
203274
|
+
)` }).where("project_id", "=", projectId).where("user_id", "=", userId).where("title", "is", null).where(sql`exists (
|
|
203275
|
+
select 1 from project_chat_messages as m
|
|
203276
|
+
where m.thread_id = project_chat_threads.id and m.type = 'user'
|
|
203277
|
+
)`);
|
|
203278
|
+
if (threadId) query = query.where("id", "=", threadId);
|
|
203279
|
+
await query.execute();
|
|
203280
|
+
}
|
|
203223
203281
|
var mapThread = (row) => {
|
|
203224
203282
|
const {
|
|
203225
203283
|
create_request_id: _requestId,
|
|
@@ -203407,12 +203465,14 @@ var createProjectChatRepos = (kdb) => ({
|
|
|
203407
203465
|
return { thread: mapThread(existing), created: false };
|
|
203408
203466
|
}),
|
|
203409
203467
|
listByProject: async (projectId, userId, limit, opts) => {
|
|
203468
|
+
await backfillMissingThreadTitles(kdb, projectId, userId);
|
|
203410
203469
|
let query = kdb.selectFrom("project_chat_threads").selectAll().where("project_id", "=", projectId).where("user_id", "=", userId);
|
|
203411
203470
|
if (!opts?.includeArchived) query = query.where("archived_at", "is", null);
|
|
203412
203471
|
const rows = await query.orderBy("updated_at", "desc").orderBy("id", "desc").limit(limit).execute();
|
|
203413
203472
|
return rows.map(mapThread);
|
|
203414
203473
|
},
|
|
203415
203474
|
listPageByProject: async (projectId, userId, limit, opts) => {
|
|
203475
|
+
await backfillMissingThreadTitles(kdb, projectId, userId);
|
|
203416
203476
|
let query = kdb.selectFrom("project_chat_threads").selectAll().where("project_id", "=", projectId).where("user_id", "=", userId);
|
|
203417
203477
|
if (!opts?.includeArchived) query = query.where("archived_at", "is", null);
|
|
203418
203478
|
if (opts?.query) {
|
|
@@ -203441,7 +203501,11 @@ var createProjectChatRepos = (kdb) => ({
|
|
|
203441
203501
|
},
|
|
203442
203502
|
getById: async (id, projectId, userId) => {
|
|
203443
203503
|
if (!userId) return void 0;
|
|
203444
|
-
|
|
203504
|
+
let row = await kdb.selectFrom("project_chat_threads").selectAll().where("id", "=", id).where("project_id", "=", projectId).where("user_id", "=", userId).executeTakeFirst();
|
|
203505
|
+
if (row?.title === null) {
|
|
203506
|
+
await backfillMissingThreadTitles(kdb, projectId, userId, id);
|
|
203507
|
+
row = await kdb.selectFrom("project_chat_threads").selectAll().where("id", "=", id).where("project_id", "=", projectId).where("user_id", "=", userId).executeTakeFirst();
|
|
203508
|
+
}
|
|
203445
203509
|
return row ? mapThread(row) : void 0;
|
|
203446
203510
|
},
|
|
203447
203511
|
update: async (id, projectId, userId, patch) => {
|
|
@@ -203457,6 +203521,14 @@ var createProjectChatRepos = (kdb) => ({
|
|
|
203457
203521
|
const row = await kdb.selectFrom("project_chat_threads").selectAll().where("id", "=", id).where("project_id", "=", projectId).where("user_id", "=", userId).executeTakeFirst();
|
|
203458
203522
|
return row ? mapThread(row) : void 0;
|
|
203459
203523
|
},
|
|
203524
|
+
setTitleIfMissing: async (id, projectId, userId, title) => {
|
|
203525
|
+
const row = await kdb.updateTable("project_chat_threads").set({ title }).where("id", "=", id).where("project_id", "=", projectId).where("user_id", "=", userId).where("title", "is", null).returningAll().executeTakeFirst();
|
|
203526
|
+
return row ? mapThread(row) : void 0;
|
|
203527
|
+
},
|
|
203528
|
+
replaceTitleIfCurrent: async (id, projectId, userId, currentTitle, title) => {
|
|
203529
|
+
const row = await kdb.updateTable("project_chat_threads").set({ title }).where("id", "=", id).where("project_id", "=", projectId).where("user_id", "=", userId).where("title", "=", currentTitle).returningAll().executeTakeFirst();
|
|
203530
|
+
return row ? mapThread(row) : void 0;
|
|
203531
|
+
},
|
|
203460
203532
|
archive: async (id, projectId, userId) => {
|
|
203461
203533
|
await kdb.updateTable("project_chat_threads").set({ archived_at: Date.now(), updated_at: now() }).where("id", "=", id).where("project_id", "=", projectId).where("user_id", "=", userId).execute();
|
|
203462
203534
|
const row = await kdb.selectFrom("project_chat_threads").selectAll().where("id", "=", id).where("project_id", "=", projectId).where("user_id", "=", userId).executeTakeFirst();
|
|
@@ -204831,11 +204903,27 @@ var initializeSchema = (db) => {
|
|
|
204831
204903
|
|
|
204832
204904
|
CREATE INDEX IF NOT EXISTS idx_cross_remote_audit_target ON cross_remote_audit(target_remote_id, seq);
|
|
204833
204905
|
|
|
204834
|
-
--
|
|
204835
|
-
--
|
|
204836
|
-
--
|
|
204837
|
-
|
|
204838
|
-
|
|
204906
|
+
-- Briefly served "which machines has this session touched?" before that
|
|
204907
|
+
-- moved to agent_session_remote_touches; the audit is time-pruned now and
|
|
204908
|
+
-- no longer read by session.
|
|
204909
|
+
DROP INDEX IF EXISTS idx_cross_remote_audit_session;
|
|
204910
|
+
|
|
204911
|
+
-- Which machines a session's calls actually ran on through the cross-remote
|
|
204912
|
+
-- gateway: one row per (session, machine), refreshed on every call. The
|
|
204913
|
+
-- grants table above says where the agent MAY go; this says where it WENT,
|
|
204914
|
+
-- which is where its artifacts (a screenshot in another box's /tmp) live \u2014
|
|
204915
|
+
-- artifact-read-targets.ts reads it on every artifact hover. Kept apart from
|
|
204916
|
+
-- cross_remote_audit because the lifetimes differ: the audit is pruned by
|
|
204917
|
+
-- age, while this lives exactly as long as its session (every session
|
|
204918
|
+
-- delete path calls deleteSessionSideRows). No FK on session_id, for the
|
|
204919
|
+
-- same reason as the grants table.
|
|
204920
|
+
CREATE TABLE IF NOT EXISTS agent_session_remote_touches (
|
|
204921
|
+
session_id TEXT NOT NULL,
|
|
204922
|
+
remote_server_id TEXT NOT NULL REFERENCES remote_servers(id) ON DELETE CASCADE,
|
|
204923
|
+
user_id TEXT NOT NULL,
|
|
204924
|
+
last_used_at TEXT NOT NULL,
|
|
204925
|
+
PRIMARY KEY (session_id, remote_server_id)
|
|
204926
|
+
);
|
|
204839
204927
|
`);
|
|
204840
204928
|
const workspaceCheckoutsTable = db.prepare(
|
|
204841
204929
|
"SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'workspace_checkouts'"
|
|
@@ -205870,6 +205958,7 @@ var initializeSchema = (db) => {
|
|
|
205870
205958
|
loop_id TEXT,
|
|
205871
205959
|
round INTEGER NOT NULL DEFAULT 1,
|
|
205872
205960
|
max_rounds INTEGER,
|
|
205961
|
+
loop_manual INTEGER NOT NULL DEFAULT 0,
|
|
205873
205962
|
verdict TEXT,
|
|
205874
205963
|
kind TEXT NOT NULL DEFAULT 'review',
|
|
205875
205964
|
params TEXT,
|
|
@@ -206063,7 +206152,9 @@ var initializeSchema = (db) => {
|
|
|
206063
206152
|
// Repeat-until-done loops: every earlier row is a review.
|
|
206064
206153
|
["kind", "kind TEXT NOT NULL DEFAULT 'review'"],
|
|
206065
206154
|
["params", "params TEXT"],
|
|
206066
|
-
["outcome_status", "outcome_status TEXT"]
|
|
206155
|
+
["outcome_status", "outcome_status TEXT"],
|
|
206156
|
+
// Unattended review loops: set once the user steps in.
|
|
206157
|
+
["loop_manual", "loop_manual INTEGER NOT NULL DEFAULT 0"]
|
|
206067
206158
|
]) {
|
|
206068
206159
|
if (!workflowRunsInfo.some((col) => col.name === name25)) {
|
|
206069
206160
|
db.exec(`ALTER TABLE workflow_runs ADD COLUMN ${ddl}`);
|
|
@@ -206213,6 +206304,7 @@ var createSqliteStorage = async (dbPath) => {
|
|
|
206213
206304
|
...createWorkspaceRepos(kdb, h),
|
|
206214
206305
|
...createCrossRemoteAuditRepo(kdb),
|
|
206215
206306
|
...createSessionRemoteGrantRepo(kdb),
|
|
206307
|
+
...createSessionRemoteTouchRepo(kdb),
|
|
206216
206308
|
...createMergeTargetsRepo(kdb),
|
|
206217
206309
|
...createSearchCacheRepos(kdb, h),
|
|
206218
206310
|
...createWorkflowRunRepos(kdb),
|
|
@@ -230302,7 +230394,7 @@ async function appendRemoteGrantContext(storage2, sessionId, userId, content) {
|
|
|
230302
230394
|
return appendContextBlock(content, await buildRemoteGrantContext(storage2, sessionId, userId));
|
|
230303
230395
|
}
|
|
230304
230396
|
|
|
230305
|
-
// src/utils/
|
|
230397
|
+
// src/utils/conversation-title.ts
|
|
230306
230398
|
var TITLE_MAX_CHARS = 60;
|
|
230307
230399
|
var AI_TIMEOUT_MS = 15e3;
|
|
230308
230400
|
var MAX_INPUT_CHARS = 2e3;
|
|
@@ -230338,14 +230430,14 @@ function sanitizeTitle(raw) {
|
|
|
230338
230430
|
}
|
|
230339
230431
|
return t;
|
|
230340
230432
|
}
|
|
230341
|
-
async function
|
|
230433
|
+
async function generateConversationTitleWithModel(model, userMessage, options = {}) {
|
|
230342
230434
|
if (userMessage.trim().length === 0) return null;
|
|
230343
230435
|
const telemetry = options.userId ? {
|
|
230344
230436
|
isEnabled: true,
|
|
230345
|
-
functionId: "
|
|
230437
|
+
functionId: "conversation-title",
|
|
230346
230438
|
metadata: {
|
|
230347
230439
|
userId: options.userId,
|
|
230348
|
-
tags: ["vibedeckx", "
|
|
230440
|
+
tags: ["vibedeckx", "conversation-title"]
|
|
230349
230441
|
}
|
|
230350
230442
|
} : void 0;
|
|
230351
230443
|
try {
|
|
@@ -230360,13 +230452,13 @@ async function generateSessionTitleWithModel(model, userMessage, options = {}) {
|
|
|
230360
230452
|
const sanitized = sanitizeTitle(text2);
|
|
230361
230453
|
return sanitized.length > 0 ? sanitized : null;
|
|
230362
230454
|
} catch (error48) {
|
|
230363
|
-
console.warn("[
|
|
230455
|
+
console.warn("[ConversationTitle] AI generation failed:", error48.message);
|
|
230364
230456
|
return null;
|
|
230365
230457
|
}
|
|
230366
230458
|
}
|
|
230367
|
-
async function
|
|
230459
|
+
async function generateConversationTitle(storage2, userMessage, userId) {
|
|
230368
230460
|
if (!await isChatModelConfigured(storage2, userId)) return null;
|
|
230369
|
-
return
|
|
230461
|
+
return generateConversationTitleWithModel(await resolveFastChatModel(storage2, userId), userMessage, { userId });
|
|
230370
230462
|
}
|
|
230371
230463
|
|
|
230372
230464
|
// src/utils/review-snapshot.ts
|
|
@@ -234214,7 +234306,7 @@ var AgentSessionManager = class {
|
|
|
234214
234306
|
const fallback = snippetTitle(userText);
|
|
234215
234307
|
let title = null;
|
|
234216
234308
|
try {
|
|
234217
|
-
title = await
|
|
234309
|
+
title = await generateConversationTitle(this.storage, userText, userId);
|
|
234218
234310
|
} catch (error48) {
|
|
234219
234311
|
console.warn(`[AgentSession] Title generation threw for ${session.id}:`, error48);
|
|
234220
234312
|
}
|
|
@@ -235869,7 +235961,7 @@ async function generateAndPushRemoteSessionTitle(deps, localSessionId, userText,
|
|
|
235869
235961
|
if (await deps.storage.remoteSessionMappings.isTitleResolved(localSessionId)) return;
|
|
235870
235962
|
let aiTitle = null;
|
|
235871
235963
|
try {
|
|
235872
|
-
aiTitle = await
|
|
235964
|
+
aiTitle = await generateConversationTitle(deps.storage, userText, userId);
|
|
235873
235965
|
} catch (error48) {
|
|
235874
235966
|
console.warn(
|
|
235875
235967
|
`[SessionTitle] AI title generation threw for ${localSessionId}:`,
|
|
@@ -239437,6 +239529,38 @@ async function createProjectChatTools(options) {
|
|
|
239437
239529
|
};
|
|
239438
239530
|
})
|
|
239439
239531
|
},
|
|
239532
|
+
list_starred_sessions: {
|
|
239533
|
+
description: "List sessions the user starred in this project, local and remote, newest star first. Use this instead of list_agent_sessions when looking for starred sessions: old starred sessions may be missing from the recent-activity list.",
|
|
239534
|
+
inputSchema: emptySchema,
|
|
239535
|
+
execute: readInScope(async () => {
|
|
239536
|
+
const [localRows, remoteRows] = await Promise.all([
|
|
239537
|
+
storage2.agentSessions.listFavoritedActivityByProject(projectId, LIST_LIMIT + 1, "project-chat"),
|
|
239538
|
+
remoteSessions ? storage2.searchCache.listRemoteSessionFavoritesByProject(projectId, LIST_LIMIT + 1, "project-chat") : Promise.resolve([])
|
|
239539
|
+
]);
|
|
239540
|
+
const byId = /* @__PURE__ */ new Map();
|
|
239541
|
+
for (const row of [...localRows, ...remoteRows]) {
|
|
239542
|
+
if (row.favoritedAt === null || row.projectId !== projectId || !isToolSelectorId(row.id)) continue;
|
|
239543
|
+
if (!byId.has(row.id)) byId.set(row.id, row);
|
|
239544
|
+
}
|
|
239545
|
+
const merged = [...byId.values()].sort((left, right) => (right.favoritedAt ?? 0) - (left.favoritedAt ?? 0) || left.id.localeCompare(right.id));
|
|
239546
|
+
const rows = merged.slice(0, LIST_LIMIT);
|
|
239547
|
+
await touchAll("agent_session", rows.map((row) => row.id));
|
|
239548
|
+
return {
|
|
239549
|
+
items: rows.map((row) => ({
|
|
239550
|
+
id: preview(row.id, ID_CHAR_LIMIT),
|
|
239551
|
+
projectId: preview(row.projectId, ID_CHAR_LIMIT),
|
|
239552
|
+
branch: nullablePreview(row.branch, LIST_BRANCH_CHAR_LIMIT),
|
|
239553
|
+
title: nullablePreview(row.title, LIST_NAME_CHAR_LIMIT),
|
|
239554
|
+
status: preview(row.status, ENUM_CHAR_LIMIT),
|
|
239555
|
+
target: preview(row.target, LIST_TARGET_CHAR_LIMIT),
|
|
239556
|
+
agentType: nullablePreview(row.agentType, ENUM_CHAR_LIMIT),
|
|
239557
|
+
model: nullablePreview(row.model, LIST_MODEL_CHAR_LIMIT),
|
|
239558
|
+
starredAt: new Date(row.favoritedAt ?? 0).toISOString()
|
|
239559
|
+
})),
|
|
239560
|
+
truncated: merged.length > LIST_LIMIT
|
|
239561
|
+
};
|
|
239562
|
+
})
|
|
239563
|
+
},
|
|
239440
239564
|
get_agent_session: {
|
|
239441
239565
|
description: "Return status and a server-bounded recent transcript for one project agent session.",
|
|
239442
239566
|
inputSchema: external_exports.object({ sessionId: external_exports.string().min(1).max(MAX_TOOL_SELECTOR_ID) }).strict(),
|
|
@@ -239587,7 +239711,9 @@ var PROJECT_CHAT_SYSTEM_PROMPT = [
|
|
|
239587
239711
|
"Project Chat does not belong to a branch or workspace; never assume one workspace is the whole project.",
|
|
239588
239712
|
"You may create a task, update a task, create an agent session in an explicitly selected existing workspace, select a requested workspace, send an agent instruction, and run an existing schedule now.",
|
|
239589
239713
|
"Use supplied tools for factual context and report mutations only from successful tool results.",
|
|
239590
|
-
"There is no delete capability, no worktree creation, no schedule configuration, no agent-session stop, and no Git capability."
|
|
239714
|
+
"There is no delete capability, no worktree creation, no schedule configuration, no agent-session stop, and no Git capability.",
|
|
239715
|
+
"When you mention a task, workspace, agent session, schedule, or schedule run whose id a tool returned, write it as a Markdown link so the user can click to open it: [label](#ref:<type>:<id>), where <type> is task, workspace, agent_session, schedule, or schedule_run and <id> is the exact id from the tool result (for example [Fix login bug](#ref:agent_session:abc123)).",
|
|
239716
|
+
"Never invent ids or link items no tool returned."
|
|
239591
239717
|
].join(" ");
|
|
239592
239718
|
var PROJECT_CHAT_TOOL_CALL_LIMIT = 8;
|
|
239593
239719
|
var PROJECT_CHAT_TOOL_RESULT_BYTE_LIMIT = 64 * 1024;
|
|
@@ -239790,6 +239916,7 @@ var ProjectChatManager = class {
|
|
|
239790
239916
|
constructor(storage2, runner, options = {}) {
|
|
239791
239917
|
this.storage = storage2;
|
|
239792
239918
|
this.runner = runner ?? new DefaultProjectChatModelRunner(storage2);
|
|
239919
|
+
this.titleGenerator = options.titleGenerator ?? generateConversationTitle;
|
|
239793
239920
|
this.drainTimeoutMs = options.drainTimeoutMs ?? 2e3;
|
|
239794
239921
|
this.idleEvictionMs = options.idleEvictionMs ?? 3e4;
|
|
239795
239922
|
this.terminalRetryDelayMs = options.terminalRetryDelayMs ?? 100;
|
|
@@ -239830,6 +239957,7 @@ var ProjectChatManager = class {
|
|
|
239830
239957
|
outstandingOperations = /* @__PURE__ */ new Set();
|
|
239831
239958
|
operationReconciliationFlights = /* @__PURE__ */ new Map();
|
|
239832
239959
|
runner;
|
|
239960
|
+
titleGenerator;
|
|
239833
239961
|
drainTimeoutMs;
|
|
239834
239962
|
idleEvictionMs;
|
|
239835
239963
|
terminalRetryDelayMs;
|
|
@@ -239994,12 +240122,69 @@ var ProjectChatManager = class {
|
|
|
239994
240122
|
content: trimmed
|
|
239995
240123
|
});
|
|
239996
240124
|
this.assertLifecycle(threadId, generation, true);
|
|
240125
|
+
if (live.thread.title === null) {
|
|
240126
|
+
try {
|
|
240127
|
+
const fallbackTitle = snippetTitle(trimmed);
|
|
240128
|
+
const written = await this.storage.projectChatThreads.setTitleIfMissing(
|
|
240129
|
+
threadId,
|
|
240130
|
+
live.thread.project_id,
|
|
240131
|
+
userId,
|
|
240132
|
+
fallbackTitle
|
|
240133
|
+
);
|
|
240134
|
+
const updated = written ?? await this.storage.projectChatThreads.getById(
|
|
240135
|
+
threadId,
|
|
240136
|
+
live.thread.project_id,
|
|
240137
|
+
userId
|
|
240138
|
+
);
|
|
240139
|
+
if (updated && updated.title !== live.thread.title) {
|
|
240140
|
+
live.thread = updated;
|
|
240141
|
+
this.broadcast(live, { JsonPatch: [{
|
|
240142
|
+
op: "replace",
|
|
240143
|
+
path: "/thread",
|
|
240144
|
+
value: { type: "THREAD", content: updated }
|
|
240145
|
+
}] });
|
|
240146
|
+
}
|
|
240147
|
+
if (updated?.title === fallbackTitle) {
|
|
240148
|
+
void this.generateTitle(threadId, userId, trimmed, fallbackTitle);
|
|
240149
|
+
}
|
|
240150
|
+
} catch (error48) {
|
|
240151
|
+
console.warn("[ProjectChat] Could not set conversation title:", error48);
|
|
240152
|
+
}
|
|
240153
|
+
}
|
|
239997
240154
|
if (accepted.acceptedMessage) this.publishMessage(live, accepted.acceptedMessage);
|
|
239998
240155
|
if (this.shuttingDown) return;
|
|
239999
240156
|
live.queue.push(accepted);
|
|
240000
240157
|
this.broadcastStatus(live);
|
|
240001
240158
|
this.pump(live);
|
|
240002
240159
|
}
|
|
240160
|
+
/** Best-effort AI refinement of the first-message fallback title. */
|
|
240161
|
+
async generateTitle(threadId, userId, firstMessage, fallbackTitle) {
|
|
240162
|
+
try {
|
|
240163
|
+
const generated = await this.titleGenerator(this.storage, firstMessage, userId);
|
|
240164
|
+
if (!generated || generated === fallbackTitle) return;
|
|
240165
|
+
const owned = await this.findAuthorized(threadId, userId);
|
|
240166
|
+
if (!owned) return;
|
|
240167
|
+
const updated = await this.storage.projectChatThreads.replaceTitleIfCurrent(
|
|
240168
|
+
threadId,
|
|
240169
|
+
owned.project_id,
|
|
240170
|
+
userId,
|
|
240171
|
+
fallbackTitle,
|
|
240172
|
+
generated
|
|
240173
|
+
);
|
|
240174
|
+
if (!updated) return;
|
|
240175
|
+
const live = this.liveThreads.get(threadId);
|
|
240176
|
+
if (live && live.thread.project_id === updated.project_id && live.thread.user_id === updated.user_id) {
|
|
240177
|
+
live.thread = updated;
|
|
240178
|
+
this.broadcast(live, { JsonPatch: [{
|
|
240179
|
+
op: "replace",
|
|
240180
|
+
path: "/thread",
|
|
240181
|
+
value: { type: "THREAD", content: updated }
|
|
240182
|
+
}] });
|
|
240183
|
+
}
|
|
240184
|
+
} catch (error48) {
|
|
240185
|
+
console.warn("[ProjectChat] Could not generate conversation title:", error48);
|
|
240186
|
+
}
|
|
240187
|
+
}
|
|
240003
240188
|
/** Authorization requires storage I/O, so stopping is deliberately async. */
|
|
240004
240189
|
async stopGeneration(threadId, userId, expectedActiveTurnId) {
|
|
240005
240190
|
const thread = await this.findAuthorized(threadId, userId);
|
|
@@ -241577,6 +241762,8 @@ var CHECK_OUTPUT_TAIL = 600;
|
|
|
241577
241762
|
var ABNORMAL_END_RECHECK_MS = 1500;
|
|
241578
241763
|
var STOP_NOTE = {
|
|
241579
241764
|
itemDone: "Loop: this iteration finished its item; the session was closed. The next item runs in a fresh session.",
|
|
241765
|
+
finished: "Loop finished: this session reported nothing left to process (Status: done). The loop is complete; no further sessions will start.",
|
|
241766
|
+
paused: "Loop paused after this item; the session was closed. The loop is waiting for you \u2014 resume or end it from the loop card.",
|
|
241580
241767
|
cancelled: "Loop ended; the session was closed.",
|
|
241581
241768
|
timeCap: "Loop: time cap reached; the session was stopped.",
|
|
241582
241769
|
resumed: "Loop resumed in a fresh session; this one was closed."
|
|
@@ -241878,7 +242065,10 @@ ${TASK_STATUS_INSTRUCTIONS}`;
|
|
|
241878
242065
|
this.host.emitRunUpdated(done);
|
|
241879
242066
|
if (outbox) this.host.milestoneCreated();
|
|
241880
242067
|
const keepSession = settlement.next === "gate" && (status === "blocked" || status === null || checkFailure !== null);
|
|
241881
|
-
if (!keepSession)
|
|
242068
|
+
if (!keepSession) {
|
|
242069
|
+
const note = settlement.next === "finished" ? STOP_NOTE.finished : settlement.next === "gate" ? STOP_NOTE.paused : STOP_NOTE.itemDone;
|
|
242070
|
+
await this.stop(run2.source_session_id, note);
|
|
242071
|
+
}
|
|
241882
242072
|
if (!insertRun) return;
|
|
241883
242073
|
const next = await this.storage.workflowRuns.getById(insertRun.id);
|
|
241884
242074
|
this.host.track(next);
|
|
@@ -242133,6 +242323,7 @@ var WorkflowError = class extends Error {
|
|
|
242133
242323
|
code;
|
|
242134
242324
|
};
|
|
242135
242325
|
var LOOP_DEADLINE_CHECK_MS = 6e4;
|
|
242326
|
+
var HANDED_OVER = "handed over to the user";
|
|
242136
242327
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "cancelled", "failed"]);
|
|
242137
242328
|
var DELIVERY_UNKNOWN_PREFIX = "\u6295\u9012\u7ED3\u679C\u672A\u77E5";
|
|
242138
242329
|
var REREVIEW_DELIVERY_UNKNOWN = `${DELIVERY_UNKNOWN_PREFIX}\uFF1A\u590D\u5BA1\u4EFB\u52A1\u53EF\u80FD\u5DF2\u9001\u8FBE reviewer\u3002\u82E5\u5176\u5B8C\u6210\uFF0C\u7ED3\u679C\u4F1A\u81EA\u52A8\u5F52\u5C5E\uFF1B\u5426\u5219\u8BF7\u7ED3\u675F\u672C\u6B21 review \u540E\u91CD\u65B0\u53D1\u8D77\u3002`;
|
|
@@ -242383,6 +242574,13 @@ var WorkflowEngine = class {
|
|
|
242383
242574
|
eventBus;
|
|
242384
242575
|
/** sessionId → participation in an active run (rebuilt on boot). */
|
|
242385
242576
|
participants = /* @__PURE__ */ new Map();
|
|
242577
|
+
/**
|
|
242578
|
+
* Source session → the loop run whose automatic next hop (relaying the
|
|
242579
|
+
* feedback, or starting the re-review) waits for the source to go idle. The
|
|
242580
|
+
* completion event fires before the source's status leaves `running`, so a
|
|
242581
|
+
* first attempt can land too early.
|
|
242582
|
+
*/
|
|
242583
|
+
autoWaiting = /* @__PURE__ */ new Map();
|
|
242386
242584
|
/** runId → prompt inputs captured at prepare time (see PendingActivation). */
|
|
242387
242585
|
pendingActivations = /* @__PURE__ */ new Map();
|
|
242388
242586
|
/** runId → armed preparation-timeout timer. */
|
|
@@ -242396,6 +242594,10 @@ var WorkflowEngine = class {
|
|
|
242396
242594
|
void this.handleTaskCompleted(event).catch(
|
|
242397
242595
|
(err) => console.error("[WorkflowEngine] handleTaskCompleted failed:", err)
|
|
242398
242596
|
);
|
|
242597
|
+
} else if (event.type === "session:status" && event.status !== "running" && this.autoWaiting.has(event.sessionId)) {
|
|
242598
|
+
const { runId, action } = this.autoWaiting.get(event.sessionId);
|
|
242599
|
+
this.autoWaiting.delete(event.sessionId);
|
|
242600
|
+
void (action === "relay" ? this.autoRelay(runId, true) : this.autoRereview(runId, true));
|
|
242399
242601
|
} else if (event.type === "session:status" && event.status !== "running" && this.participants.get(event.sessionId)?.role === "task") {
|
|
242400
242602
|
void this.repeat.onSessionIdle(event.sessionId).catch(
|
|
242401
242603
|
(err) => console.error("[WorkflowEngine] repeat-loop idle check failed:", err)
|
|
@@ -242467,6 +242669,8 @@ var WorkflowEngine = class {
|
|
|
242467
242669
|
error: "\u53D1\u9001\u72B6\u6001\u672A\u77E5\uFF1A\u670D\u52A1\u5728\u53D1\u9001\u53CD\u9988\u671F\u95F4\u91CD\u542F\u3002\u8BF7\u68C0\u67E5 source session \u662F\u5426\u5DF2\u6536\u5230\u53CD\u9988\uFF0C\u518D\u51B3\u5B9A\u91CD\u53D1\u6216\u7ED3\u675F\u3002"
|
|
242468
242670
|
});
|
|
242469
242671
|
run2.status = "waiting_feedback";
|
|
242672
|
+
} else if (run2.status === "waiting_feedback" && run2.loop_id) {
|
|
242673
|
+
await this.notifyFeedbackGate(run2);
|
|
242470
242674
|
} else if (run2.status === "waiting_reviewer") {
|
|
242471
242675
|
await this.storage.workflowRuns.update(run2.id, {
|
|
242472
242676
|
error: "\u670D\u52A1\u91CD\u542F\uFF0C\u53EF\u80FD\u9519\u8FC7 reviewer \u5B8C\u6210\u4E8B\u4EF6\u3002\u82E5 reviewer \u5DF2\u5B8C\u6210\uFF0C\u8BF7\u6253\u5F00\u5176\u7A97\u53E3\u67E5\u770B\uFF0C\u6216\u7ED3\u675F\u672C\u6B21 review\u3002"
|
|
@@ -242534,7 +242738,7 @@ var WorkflowEngine = class {
|
|
|
242534
242738
|
const outcome = turnEnd.outcome ?? "completed";
|
|
242535
242739
|
const completed = outcome === "completed" || outcome === "completed_with_pending_tasks";
|
|
242536
242740
|
if (completed && findTurnOpeningUserEntryIndex(entries, turnEndIndex) === entryIndex) {
|
|
242537
|
-
await this.claimStep(step, entries, turnEndIndex);
|
|
242741
|
+
await this.claimStep(step, entries, turnEndIndex, { live: false });
|
|
242538
242742
|
settled.add(run2.id);
|
|
242539
242743
|
continue;
|
|
242540
242744
|
}
|
|
@@ -242694,16 +242898,126 @@ var WorkflowEngine = class {
|
|
|
242694
242898
|
review_target: null,
|
|
242695
242899
|
loop_id: run2.loop_id,
|
|
242696
242900
|
round: run2.round + 1,
|
|
242697
|
-
max_rounds: run2.max_rounds
|
|
242901
|
+
max_rounds: run2.max_rounds,
|
|
242902
|
+
loop_manual: run2.loop_manual
|
|
242698
242903
|
};
|
|
242699
242904
|
}
|
|
242700
|
-
/**
|
|
242701
|
-
|
|
242905
|
+
/**
|
|
242906
|
+
* The insert is conditional (see claimStepAndTransition); read it back to know.
|
|
242907
|
+
* With `auto`, the next round starts by itself (see `autoRereview`).
|
|
242908
|
+
*/
|
|
242909
|
+
async announceNextRoundGate(nextRunId, auto = false) {
|
|
242702
242910
|
if (!nextRunId) return;
|
|
242703
242911
|
const gate = await this.storage.workflowRuns.getById(nextRunId);
|
|
242704
242912
|
if (!gate) return;
|
|
242705
242913
|
this.trackParticipants(gate);
|
|
242706
242914
|
this.emitRunUpdated(gate);
|
|
242915
|
+
if (auto) await this.autoRereview(gate.id);
|
|
242916
|
+
}
|
|
242917
|
+
// ---------- unattended review loops ----------
|
|
242918
|
+
//
|
|
242919
|
+
// Inside the round cap a loop runs by itself while the reviewer says a clear
|
|
242920
|
+
// `needs-changes`: its feedback goes to the source as-is, and the source's
|
|
242921
|
+
// fix is re-reviewed. The cap is the hand-over point — the LAST round's
|
|
242922
|
+
// feedback waits for the user, and so does every round past it. Anything
|
|
242923
|
+
// else stops at the gate it reached, which is exactly the manual path:
|
|
242924
|
+
// another verdict, a drift note, a claim found by restart reconciliation, a
|
|
242925
|
+
// failed attempt, or the user stepping in (`loop_manual`).
|
|
242926
|
+
/**
|
|
242927
|
+
* Whether a round's feedback goes out without the user. `live` = claimed
|
|
242928
|
+
* from a completion event, not by restart reconciliation.
|
|
242929
|
+
*/
|
|
242930
|
+
shouldAutoRelay(run2, verdict, driftNote, live) {
|
|
242931
|
+
return live && run2.loop_id !== null && !run2.loop_manual && verdict === "needs-changes" && driftNote === null && run2.max_rounds !== null && run2.round < run2.max_rounds;
|
|
242932
|
+
}
|
|
242933
|
+
/**
|
|
242934
|
+
* Park an automatic hop until `sessionId` goes idle. False when it already
|
|
242935
|
+
* is — the status event may have gone out before the entry was written — and
|
|
242936
|
+
* the caller should retry now.
|
|
242937
|
+
*/
|
|
242938
|
+
async waitForIdle(sessionId, runId, action) {
|
|
242939
|
+
this.autoWaiting.set(sessionId, { runId, action });
|
|
242940
|
+
const session = await this.storage.agentSessions.getById(sessionId);
|
|
242941
|
+
if (session?.status === "running") return true;
|
|
242942
|
+
if (this.autoWaiting.get(sessionId)?.runId !== runId) return true;
|
|
242943
|
+
this.autoWaiting.delete(sessionId);
|
|
242944
|
+
return false;
|
|
242945
|
+
}
|
|
242946
|
+
async isStillAutomatic(runId) {
|
|
242947
|
+
return !(await this.storage.workflowRuns.getById(runId))?.loop_manual;
|
|
242948
|
+
}
|
|
242949
|
+
/** `approveFeedback` with nobody to report to: a failure stays at the gate, and rings. */
|
|
242950
|
+
async autoRelay(runId, retried = false) {
|
|
242951
|
+
const run2 = await this.storage.workflowRuns.getById(runId);
|
|
242952
|
+
if (run2?.status !== "waiting_feedback") return;
|
|
242953
|
+
if (!run2.loop_manual) {
|
|
242954
|
+
try {
|
|
242955
|
+
await this.approveFeedback(runId, void 0, { auto: true });
|
|
242956
|
+
return;
|
|
242957
|
+
} catch (err) {
|
|
242958
|
+
const back = await this.storage.workflowRuns.getById(runId);
|
|
242959
|
+
if (back?.status !== "waiting_feedback") return;
|
|
242960
|
+
if (!retried && err instanceof WorkflowError && err.code === "session-busy") {
|
|
242961
|
+
if (await this.waitForIdle(back.source_session_id, runId, "relay")) return;
|
|
242962
|
+
return this.autoRelay(runId, true);
|
|
242963
|
+
}
|
|
242964
|
+
if (!back.error && !back.loop_manual) {
|
|
242965
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
242966
|
+
const noted = await this.storage.workflowRuns.update(runId, { error: `\u81EA\u52A8\u8F6C\u53D1\u672A\u80FD\u53D1\u51FA\uFF1A${reason}` });
|
|
242967
|
+
if (noted) this.emitRunUpdated(noted);
|
|
242968
|
+
}
|
|
242969
|
+
}
|
|
242970
|
+
}
|
|
242971
|
+
await this.notifyFeedbackGate(run2);
|
|
242972
|
+
}
|
|
242973
|
+
/**
|
|
242974
|
+
* The review_ready milestone an automatic relay skipped, for a gate that
|
|
242975
|
+
* ends up waiting for the user after all. Same deterministic id as the one
|
|
242976
|
+
* the claim would have written, so it rings at most once.
|
|
242977
|
+
*/
|
|
242978
|
+
async notifyFeedbackGate(run2) {
|
|
242979
|
+
const step = (await this.storage.workflowRunSteps.listByRun(run2.id)).filter((st) => st.role === "reviewer" && st.status === "claimed" && st.turn_end_index !== null).at(-1);
|
|
242980
|
+
if (!step) return;
|
|
242981
|
+
const { inserted } = await this.storage.notificationOutbox.insert(
|
|
242982
|
+
this.reviewReadyOutbox(run2, step.session_id, step.turn_end_index)
|
|
242983
|
+
);
|
|
242984
|
+
if (inserted) this.onMilestoneCreated?.();
|
|
242985
|
+
}
|
|
242986
|
+
/**
|
|
242987
|
+
* `approveRereview` with nobody to report to. Only a clear `needs-changes`
|
|
242988
|
+
* within the cap qualifies — the caller checks the verdict; failures land on
|
|
242989
|
+
* the gate and ring.
|
|
242990
|
+
*/
|
|
242991
|
+
async autoRereview(gateId, retried = false) {
|
|
242992
|
+
const gate = await this.storage.workflowRuns.getById(gateId);
|
|
242993
|
+
if (gate?.status !== "waiting_rereview" || gate.loop_manual) return;
|
|
242994
|
+
if (gate.max_rounds === null || gate.round > gate.max_rounds) return;
|
|
242995
|
+
try {
|
|
242996
|
+
await this.approveRereview(gateId, { auto: true });
|
|
242997
|
+
} catch (err) {
|
|
242998
|
+
const back = await this.storage.workflowRuns.getById(gateId);
|
|
242999
|
+
if (back?.status !== "waiting_rereview") return;
|
|
243000
|
+
if (!retried && err instanceof WorkflowError && err.code === "source-running") {
|
|
243001
|
+
if (await this.waitForIdle(back.source_session_id, gateId, "rereview")) return;
|
|
243002
|
+
return this.autoRereview(gateId, true);
|
|
243003
|
+
}
|
|
243004
|
+
if (back.loop_manual) return;
|
|
243005
|
+
if (!back.error) {
|
|
243006
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
243007
|
+
const noted = await this.storage.workflowRuns.update(gateId, { error: `\u81EA\u52A8\u590D\u5BA1\u672A\u80FD\u53D1\u8D77\uFF1A${reason}` });
|
|
243008
|
+
if (noted) this.emitRunUpdated(noted);
|
|
243009
|
+
}
|
|
243010
|
+
const { inserted } = await this.storage.notificationOutbox.insert({
|
|
243011
|
+
id: workflowFailedId(gateId, "auto-rereview"),
|
|
243012
|
+
kind: "workflow_failed",
|
|
243013
|
+
project_id: back.project_id,
|
|
243014
|
+
branch: back.branch,
|
|
243015
|
+
session_id: back.source_session_id,
|
|
243016
|
+
workflow_run_id: back.id,
|
|
243017
|
+
created_at: Date.now()
|
|
243018
|
+
});
|
|
243019
|
+
if (inserted) this.onMilestoneCreated?.();
|
|
243020
|
+
}
|
|
242707
243021
|
}
|
|
242708
243022
|
/** The reviewer the loop continues with: the previous round's. */
|
|
242709
243023
|
async loopReviewerSessionId(gate) {
|
|
@@ -242787,11 +243101,13 @@ var WorkflowEngine = class {
|
|
|
242787
243101
|
project: { id: project.id, path: project.path },
|
|
242788
243102
|
entries,
|
|
242789
243103
|
turnEndIndex,
|
|
242790
|
-
target
|
|
243104
|
+
target,
|
|
243105
|
+
stillAutomatic: opts.auto ? () => this.isStillAutomatic(gate.id) : void 0
|
|
242791
243106
|
});
|
|
242792
243107
|
if (outcome.kind === "mode-switch-failed" || outcome.kind === "no_side_effect") {
|
|
242793
243108
|
const busy = outcome.kind === "no_side_effect" && outcome.busy;
|
|
242794
|
-
const
|
|
243109
|
+
const handedOver = outcome.kind === "no_side_effect" && outcome.reason === HANDED_OVER;
|
|
243110
|
+
const reason = handedOver ? "\u4F60\u5DF2\u4ECB\u5165\u8FD9\u4E2A\u5FAA\u73AF\uFF0C\u590D\u5BA1\u6539\u4E3A\u7531\u4F60\u786E\u8BA4\u3002" : outcome.kind === "mode-switch-failed" ? "\u65E0\u6CD5\u5C06 reviewer \u6062\u590D\u4E3A\u53EA\u8BFB plan \u6A21\u5F0F\uFF0C\u590D\u5BA1\u672A\u53D1\u51FA\u3002\u53EF\u91CD\u8BD5\uFF0C\u6216\u7ED3\u675F\u5FAA\u73AF\u3002" : busy ? "reviewer \u6B63\u5728\u56DE\u590D\u4E2D\uFF0C\u590D\u5BA1\u672A\u53D1\u51FA\u3002\u8BF7\u7B49\u5F85\u5176\u5B8C\u6210\u540E\u91CD\u8BD5\u3002" : "\u590D\u5BA1\u4EFB\u52A1\u672A\u9001\u8FBE reviewer\uFF08\u5176 session \u53EF\u80FD\u672A\u8FD0\u884C\uFF09\u3002\u53EF\u91CD\u8BD5\uFF0C\u6216\u7ED3\u675F\u5FAA\u73AF\u3002";
|
|
242795
243111
|
const back = await this.storage.workflowRuns.transition(gate.id, "waiting_reviewer", "waiting_rereview", {
|
|
242796
243112
|
reviewer_session_id: null,
|
|
242797
243113
|
error: reason
|
|
@@ -242878,7 +243194,8 @@ var WorkflowEngine = class {
|
|
|
242878
243194
|
sessionId: opts.reviewerSession.id,
|
|
242879
243195
|
payload: prompt,
|
|
242880
243196
|
projectPath: opts.project.path,
|
|
242881
|
-
turn: REVIEWER_TURN
|
|
243197
|
+
turn: REVIEWER_TURN,
|
|
243198
|
+
stillAutomatic: opts.stillAutomatic
|
|
242882
243199
|
});
|
|
242883
243200
|
}
|
|
242884
243201
|
// ---------- dispatch identity (Phase 2 prerequisite design §2) ----------
|
|
@@ -242936,6 +243253,10 @@ var WorkflowEngine = class {
|
|
|
242936
243253
|
if (!reused) await steps.abandon(step.id, "target session busy");
|
|
242937
243254
|
return { kind: "no_side_effect", busy: true, reason: "target session is mid-turn" };
|
|
242938
243255
|
}
|
|
243256
|
+
if (opts.stillAutomatic && !await opts.stillAutomatic()) {
|
|
243257
|
+
if (!reused) await steps.abandon(step.id, "handed over to the user");
|
|
243258
|
+
return { kind: "no_side_effect", busy: false, reason: HANDED_OVER };
|
|
243259
|
+
}
|
|
242939
243260
|
let runtimeAccepted = false;
|
|
242940
243261
|
try {
|
|
242941
243262
|
const result = await deliverInstruction({
|
|
@@ -243436,7 +243757,7 @@ var WorkflowEngine = class {
|
|
|
243436
243757
|
* completion event and restart reconciliation, so a late claim goes through
|
|
243437
243758
|
* exactly the transaction a live one does.
|
|
243438
243759
|
*/
|
|
243439
|
-
async claimStep(step, entries, boundary) {
|
|
243760
|
+
async claimStep(step, entries, boundary, opts = { live: true }) {
|
|
243440
243761
|
const output = extractLastAssistantInTurn(entries, boundary);
|
|
243441
243762
|
if (step.kind === "task_prompt") {
|
|
243442
243763
|
await this.repeat.onTaskTurnCompleted(step, entries, boundary, output);
|
|
@@ -243445,6 +243766,7 @@ var WorkflowEngine = class {
|
|
|
243445
243766
|
if (step.kind === "feedback") {
|
|
243446
243767
|
const run3 = await this.storage.workflowRuns.getById(step.run_id);
|
|
243447
243768
|
const nextRun = run3 ? this.nextRoundGate(run3, boundary) : void 0;
|
|
243769
|
+
const auto = opts.live && run3?.verdict === "needs-changes" && !run3.loop_manual;
|
|
243448
243770
|
if (run3 && (run3.status === "sending_feedback" || run3.status === "waiting_feedback")) {
|
|
243449
243771
|
const completed = await this.storage.workflowRuns.claimStepAndTransition({
|
|
243450
243772
|
stepId: step.id,
|
|
@@ -243459,7 +243781,7 @@ var WorkflowEngine = class {
|
|
|
243459
243781
|
this.untrackRun(done);
|
|
243460
243782
|
this.emitRunUpdated(done);
|
|
243461
243783
|
}
|
|
243462
|
-
await this.announceNextRoundGate(nextRun?.id);
|
|
243784
|
+
await this.announceNextRoundGate(nextRun?.id, auto);
|
|
243463
243785
|
return;
|
|
243464
243786
|
}
|
|
243465
243787
|
}
|
|
@@ -243469,13 +243791,15 @@ var WorkflowEngine = class {
|
|
|
243469
243791
|
outputSnapshot: output,
|
|
243470
243792
|
nextRun
|
|
243471
243793
|
});
|
|
243472
|
-
if (claimed) await this.announceNextRoundGate(nextRun?.id);
|
|
243794
|
+
if (claimed) await this.announceNextRoundGate(nextRun?.id, auto);
|
|
243473
243795
|
return;
|
|
243474
243796
|
}
|
|
243475
243797
|
const run2 = await this.storage.workflowRuns.getById(step.run_id);
|
|
243476
243798
|
if (!run2 || run2.status !== "waiting_reviewer") return;
|
|
243477
243799
|
const feedback = output ?? "(reviewer \u6CA1\u6709\u8F93\u51FA\u53EF\u7528\u7684\u53CD\u9988\u6587\u672C)";
|
|
243478
243800
|
const driftNote = await this.computeDriftNote(run2);
|
|
243801
|
+
const verdict = parseVerdict(output);
|
|
243802
|
+
const relay = this.shouldAutoRelay(run2, verdict, driftNote, opts.live);
|
|
243479
243803
|
const ok = await this.storage.workflowRuns.claimStepAndTransition({
|
|
243480
243804
|
stepId: step.id,
|
|
243481
243805
|
turnEndIndex: boundary,
|
|
@@ -243487,14 +243811,15 @@ var WorkflowEngine = class {
|
|
|
243487
243811
|
// `error: null` also clears a "delivery outcome unknown" note: the
|
|
243488
243812
|
// completion just answered it.
|
|
243489
243813
|
// Parsed by exact match; null = unrecognised = the human decides.
|
|
243490
|
-
patch: { feedback_snapshot: feedback, error: driftNote, verdict
|
|
243491
|
-
outbox: this.reviewReadyOutbox(run2, step.session_id, boundary)
|
|
243814
|
+
patch: { feedback_snapshot: feedback, error: driftNote, verdict },
|
|
243815
|
+
outbox: relay ? void 0 : this.reviewReadyOutbox(run2, step.session_id, boundary)
|
|
243492
243816
|
}
|
|
243493
243817
|
});
|
|
243494
243818
|
if (!ok) return;
|
|
243495
|
-
this.onMilestoneCreated?.();
|
|
243819
|
+
if (!relay) this.onMilestoneCreated?.();
|
|
243496
243820
|
const updated = await this.storage.workflowRuns.getById(run2.id);
|
|
243497
243821
|
if (updated) this.emitRunUpdated(updated);
|
|
243822
|
+
if (relay) await this.autoRelay(run2.id);
|
|
243498
243823
|
}
|
|
243499
243824
|
async computeDriftNote(run2) {
|
|
243500
243825
|
try {
|
|
@@ -243552,7 +243877,7 @@ var WorkflowEngine = class {
|
|
|
243552
243877
|
const updated = await this.storage.workflowRuns.getById(run2.id);
|
|
243553
243878
|
if (updated) this.emitRunUpdated(updated);
|
|
243554
243879
|
}
|
|
243555
|
-
async approveFeedback(runId, editedPayload) {
|
|
243880
|
+
async approveFeedback(runId, editedPayload, opts = {}) {
|
|
243556
243881
|
const run2 = await this.storage.workflowRuns.getById(runId);
|
|
243557
243882
|
if (!run2 || run2.status !== "waiting_feedback") {
|
|
243558
243883
|
throw new WorkflowError("bad-state", "run \u4E0D\u5728\u7B49\u5F85\u53CD\u9988\u786E\u8BA4\u7684\u72B6\u6001");
|
|
@@ -243578,10 +243903,11 @@ var WorkflowEngine = class {
|
|
|
243578
243903
|
sessionId: run2.source_session_id,
|
|
243579
243904
|
payload,
|
|
243580
243905
|
projectPath: project?.path ?? void 0,
|
|
243581
|
-
turn: FEEDBACK_TURN
|
|
243906
|
+
turn: FEEDBACK_TURN,
|
|
243907
|
+
stillAutomatic: opts.auto ? () => this.isStillAutomatic(runId) : void 0
|
|
243582
243908
|
});
|
|
243583
243909
|
if (outcome.kind !== "accepted") {
|
|
243584
|
-
const error48 = outcome.kind === "unknown" ? `${DELIVERY_UNKNOWN_PREFIX}\uFF1A\u53CD\u9988\u53EF\u80FD\u5DF2\u9001\u8FBE source session\u3002\u8BF7\u68C0\u67E5\u5176\u7A97\u53E3\uFF1B\u518D\u6B21\u786E\u8BA4\u4F1A\u6309\u539F\u6587\u91CD\u8BD5\uFF08\u5DF2\u9001\u8FBE\u5219\u4E0D\u4F1A\u91CD\u590D\u53D1\u9001\uFF09\u3002` : outcome.busy ? "source session \u6B63\u5728\u8FD0\u884C\uFF0C\u8BF7\u7B49\u5F85\u5176\u5B8C\u6210\u540E\u518D\u53D1\u9001\u53CD\u9988\u3002" : "\u53D1\u9001\u5931\u8D25\uFF1A\u76EE\u6807 session \u53EF\u80FD\u672A\u8FD0\u884C\u3002\u8BF7\u5728\u5176\u7A97\u53E3\u4E2D\u5524\u9192\u540E\u91CD\u8BD5\uFF0C\u6216\u7ED3\u675F\u672C\u6B21 review\u3002";
|
|
243910
|
+
const error48 = outcome.kind === "unknown" ? `${DELIVERY_UNKNOWN_PREFIX}\uFF1A\u53CD\u9988\u53EF\u80FD\u5DF2\u9001\u8FBE source session\u3002\u8BF7\u68C0\u67E5\u5176\u7A97\u53E3\uFF1B\u518D\u6B21\u786E\u8BA4\u4F1A\u6309\u539F\u6587\u91CD\u8BD5\uFF08\u5DF2\u9001\u8FBE\u5219\u4E0D\u4F1A\u91CD\u590D\u53D1\u9001\uFF09\u3002` : outcome.reason === HANDED_OVER ? null : outcome.busy ? "source session \u6B63\u5728\u8FD0\u884C\uFF0C\u8BF7\u7B49\u5F85\u5176\u5B8C\u6210\u540E\u518D\u53D1\u9001\u53CD\u9988\u3002" : "\u53D1\u9001\u5931\u8D25\uFF1A\u76EE\u6807 session \u53EF\u80FD\u672A\u8FD0\u884C\u3002\u8BF7\u5728\u5176\u7A97\u53E3\u4E2D\u5524\u9192\u540E\u91CD\u8BD5\uFF0C\u6216\u7ED3\u675F\u672C\u6B21 review\u3002";
|
|
243585
243911
|
await this.storage.workflowRuns.transition(runId, "sending_feedback", "waiting_feedback", { error: error48 });
|
|
243586
243912
|
const rolled = await this.storage.workflowRuns.getById(runId);
|
|
243587
243913
|
if (rolled) this.emitRunUpdated(rolled);
|
|
@@ -243694,6 +244020,7 @@ var WorkflowEngine = class {
|
|
|
243694
244020
|
*/
|
|
243695
244021
|
async handleExternalUserMessage(sessionId) {
|
|
243696
244022
|
const p2 = this.participants.get(sessionId);
|
|
244023
|
+
await this.handOverLoop(sessionId, p2);
|
|
243697
244024
|
if (!p2) return;
|
|
243698
244025
|
if (p2.role === "reviewer") {
|
|
243699
244026
|
try {
|
|
@@ -243712,6 +244039,39 @@ var WorkflowEngine = class {
|
|
|
243712
244039
|
return;
|
|
243713
244040
|
}
|
|
243714
244041
|
}
|
|
244042
|
+
/**
|
|
244043
|
+
* Stepping into a review loop — to either side — hands the rest of it to the
|
|
244044
|
+
* user: every later gate waits for them. Besides the run holding the
|
|
244045
|
+
* session, that covers a source busy with feedback already sent: its round
|
|
244046
|
+
* has completed and holds nothing, but its open feedback step still names
|
|
244047
|
+
* the loop, and the next gate copies the flag from it. The reviewer is held
|
|
244048
|
+
* by nothing between rounds either: its last loop run finds the loop, and
|
|
244049
|
+
* both that run (the next gate copies from it) and the loop's active run, if
|
|
244050
|
+
* a gate already exists, are marked. Never throws (see
|
|
244051
|
+
* handleExternalUserMessage).
|
|
244052
|
+
*/
|
|
244053
|
+
async handOverLoop(sessionId, p2) {
|
|
244054
|
+
try {
|
|
244055
|
+
const runIds = new Set(p2 ? [p2.runId] : []);
|
|
244056
|
+
for (const step of await this.storage.workflowRunSteps.getOpenBySession(sessionId)) {
|
|
244057
|
+
if (step.kind === "feedback") runIds.add(step.run_id);
|
|
244058
|
+
}
|
|
244059
|
+
const reviewed = await this.storage.workflowRuns.getLatestLoopRunByReviewer(sessionId);
|
|
244060
|
+
if (reviewed?.loop_id) {
|
|
244061
|
+
runIds.add(reviewed.id);
|
|
244062
|
+
const active = await this.storage.workflowRuns.getActiveInLoop(reviewed.loop_id);
|
|
244063
|
+
if (active) runIds.add(active.id);
|
|
244064
|
+
}
|
|
244065
|
+
for (const runId of runIds) {
|
|
244066
|
+
const run2 = await this.storage.workflowRuns.getById(runId);
|
|
244067
|
+
if (run2?.kind !== "review" || !run2.loop_id || run2.loop_manual) continue;
|
|
244068
|
+
const updated = await this.storage.workflowRuns.update(run2.id, { loop_manual: 1 });
|
|
244069
|
+
if (updated && !(p2?.role === "reviewer" && p2.runId === run2.id)) this.emitRunUpdated(updated);
|
|
244070
|
+
}
|
|
244071
|
+
} catch (err) {
|
|
244072
|
+
console.error(`[WorkflowEngine] handleExternalUserMessage: failed handing loop over for ${sessionId}; swallowed`, err);
|
|
244073
|
+
}
|
|
244074
|
+
}
|
|
243715
244075
|
emitRunUpdated(run2) {
|
|
243716
244076
|
this.eventBus?.emit({ type: "workflow:run-updated", projectId: run2.project_id, branch: run2.branch, run: run2 });
|
|
243717
244077
|
const streams = /* @__PURE__ */ new Set([run2.source_session_id, run2.reviewer_session_id]);
|
|
@@ -245821,6 +246181,28 @@ var SessionRetentionSweeper = class {
|
|
|
245821
246181
|
}
|
|
245822
246182
|
};
|
|
245823
246183
|
|
|
246184
|
+
// src/cross-remote-retention.ts
|
|
246185
|
+
var CROSS_REMOTE_AUDIT_RETENTION_ENV = "VIBEDECKX_CROSS_REMOTE_AUDIT_RETENTION_DAYS";
|
|
246186
|
+
var DEFAULT_AUDIT_RETENTION_DAYS = 90;
|
|
246187
|
+
var AUDIT_PRUNE_BATCH = 1e3;
|
|
246188
|
+
function auditRetentionDays(raw = process.env[CROSS_REMOTE_AUDIT_RETENTION_ENV]) {
|
|
246189
|
+
return parseRetentionDays(raw) ?? DEFAULT_AUDIT_RETENTION_DAYS;
|
|
246190
|
+
}
|
|
246191
|
+
async function pruneCrossRemoteAudit(storage2, opts = {}) {
|
|
246192
|
+
const now3 = opts.now ?? Date.now();
|
|
246193
|
+
const cutoff = new Date(now3 - (opts.auditDays ?? auditRetentionDays()) * MS_PER_DAY);
|
|
246194
|
+
const batchSize = opts.batchSize ?? AUDIT_PRUNE_BATCH;
|
|
246195
|
+
let removed = 0;
|
|
246196
|
+
for (; ; ) {
|
|
246197
|
+
const deleted = await storage2.crossRemoteAudit.pruneBefore(cutoff, batchSize);
|
|
246198
|
+
removed += deleted;
|
|
246199
|
+
if (deleted < batchSize) break;
|
|
246200
|
+
await new Promise((resolve3) => setImmediate(resolve3));
|
|
246201
|
+
}
|
|
246202
|
+
if (removed > 0) console.log(`[CrossRemoteRetention] pruned ${removed} audit row(s)`);
|
|
246203
|
+
return removed;
|
|
246204
|
+
}
|
|
246205
|
+
|
|
245824
246206
|
// src/agent-session-lifecycle.ts
|
|
245825
246207
|
import { createHash as createHash6, randomUUID as randomUUID12 } from "node:crypto";
|
|
245826
246208
|
function lifecycleHttpStatus(kind) {
|
|
@@ -248520,6 +248902,9 @@ var sharedServices = async (fastify2, opts) => {
|
|
|
248520
248902
|
storage: opts.storage,
|
|
248521
248903
|
deleteIfExpired: (sessionId, cutoff) => agentSessionManager.deleteDormantSessionIfExpired(sessionId, cutoff),
|
|
248522
248904
|
maintenance: async () => {
|
|
248905
|
+
await pruneCrossRemoteAudit(opts.storage).catch((error48) => {
|
|
248906
|
+
console.error("[CrossRemoteRetention] prune failed:", error48);
|
|
248907
|
+
});
|
|
248523
248908
|
await agentSessionLifecycle.maintain();
|
|
248524
248909
|
await opts.storage.remoteSessionCreationIntents.discardStaleLifecycleIntents({
|
|
248525
248910
|
cutoff: Date.now() - 7 * 24 * 60 * 6e4,
|
|
@@ -251097,6 +251482,52 @@ import { readFileSync as readFileSync4 } from "fs";
|
|
|
251097
251482
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
251098
251483
|
|
|
251099
251484
|
// src/utils/diff-parser.ts
|
|
251485
|
+
var C_ESCAPES = {
|
|
251486
|
+
a: 7,
|
|
251487
|
+
b: 8,
|
|
251488
|
+
f: 12,
|
|
251489
|
+
n: 10,
|
|
251490
|
+
r: 13,
|
|
251491
|
+
t: 9,
|
|
251492
|
+
v: 11,
|
|
251493
|
+
"\\": 92,
|
|
251494
|
+
'"': 34
|
|
251495
|
+
};
|
|
251496
|
+
function unquoteGitPath(token) {
|
|
251497
|
+
if (token.length < 2 || !token.startsWith('"') || !token.endsWith('"')) return token;
|
|
251498
|
+
const body = token.slice(1, -1);
|
|
251499
|
+
const bytes = [];
|
|
251500
|
+
for (let i = 0; i < body.length; i++) {
|
|
251501
|
+
if (body[i] !== "\\") {
|
|
251502
|
+
bytes.push(...Buffer.from(body[i], "utf-8"));
|
|
251503
|
+
continue;
|
|
251504
|
+
}
|
|
251505
|
+
const next = body[i + 1];
|
|
251506
|
+
if (next === void 0) {
|
|
251507
|
+
bytes.push(92);
|
|
251508
|
+
continue;
|
|
251509
|
+
}
|
|
251510
|
+
if (next >= "0" && next <= "7") {
|
|
251511
|
+
const octal = body.slice(i + 1, i + 4).match(/^[0-7]{1,3}/)[0];
|
|
251512
|
+
bytes.push(parseInt(octal, 8) & 255);
|
|
251513
|
+
i += octal.length;
|
|
251514
|
+
continue;
|
|
251515
|
+
}
|
|
251516
|
+
const simple = C_ESCAPES[next];
|
|
251517
|
+
if (simple !== void 0) {
|
|
251518
|
+
bytes.push(simple);
|
|
251519
|
+
i += 1;
|
|
251520
|
+
continue;
|
|
251521
|
+
}
|
|
251522
|
+
bytes.push(92, ...Buffer.from(next, "utf-8"));
|
|
251523
|
+
i += 1;
|
|
251524
|
+
}
|
|
251525
|
+
return Buffer.from(bytes).toString("utf-8");
|
|
251526
|
+
}
|
|
251527
|
+
var DIFF_HEADER = /^("a\/(?:[^"\\]|\\.)*"|a\/.+?) ("b\/(?:[^"\\]|\\.)*"|b\/.+)$/;
|
|
251528
|
+
function headerPath(token) {
|
|
251529
|
+
return unquoteGitPath(token).slice(2);
|
|
251530
|
+
}
|
|
251100
251531
|
function parseDiffOutput(diffOutput) {
|
|
251101
251532
|
const files = [];
|
|
251102
251533
|
if (!diffOutput.trim()) {
|
|
@@ -251106,10 +251537,10 @@ function parseDiffOutput(diffOutput) {
|
|
|
251106
251537
|
for (const fileDiff of fileDiffs) {
|
|
251107
251538
|
const lines = fileDiff.split("\n");
|
|
251108
251539
|
if (lines.length === 0) continue;
|
|
251109
|
-
const headerMatch = lines[0].match(
|
|
251540
|
+
const headerMatch = lines[0].match(DIFF_HEADER);
|
|
251110
251541
|
if (!headerMatch) continue;
|
|
251111
|
-
const oldPath = headerMatch[1];
|
|
251112
|
-
const newPath = headerMatch[2];
|
|
251542
|
+
const oldPath = headerPath(headerMatch[1]);
|
|
251543
|
+
const newPath = headerPath(headerMatch[2]);
|
|
251113
251544
|
let status = "modified";
|
|
251114
251545
|
let finalPath = newPath;
|
|
251115
251546
|
let finalOldPath;
|
|
@@ -251356,21 +251787,21 @@ async function getUntrackedFiles(cwd) {
|
|
|
251356
251787
|
try {
|
|
251357
251788
|
const { execSync: execSync2 } = await import("child_process");
|
|
251358
251789
|
untrackedOutput = execSync2(
|
|
251359
|
-
"git ls-files --others --exclude-standard",
|
|
251790
|
+
"git ls-files --others --exclude-standard -z",
|
|
251360
251791
|
{ cwd, encoding: "utf-8", maxBuffer: 10 * 1024 * 1024 }
|
|
251361
|
-
)
|
|
251792
|
+
);
|
|
251362
251793
|
} catch {
|
|
251363
251794
|
return [];
|
|
251364
251795
|
}
|
|
251365
|
-
|
|
251366
|
-
|
|
251796
|
+
const untrackedPaths = untrackedOutput.split("\0").filter(Boolean);
|
|
251797
|
+
if (untrackedPaths.length === 0) return [];
|
|
251367
251798
|
const files = [];
|
|
251368
251799
|
for (const filePath of untrackedPaths) {
|
|
251369
251800
|
try {
|
|
251370
251801
|
const fullPath = path12.join(cwd, filePath);
|
|
251371
251802
|
const buffer = readFileSync4(fullPath);
|
|
251372
251803
|
if (buffer.includes(0)) {
|
|
251373
|
-
files.push({ path: filePath, status: "added", hunks: [] });
|
|
251804
|
+
files.push({ path: filePath, status: "added", hunks: [], binary: true });
|
|
251374
251805
|
continue;
|
|
251375
251806
|
}
|
|
251376
251807
|
const content = buffer.toString("utf-8");
|
|
@@ -251623,7 +252054,7 @@ async function resolveArtifactReadTargets(deps, opts) {
|
|
|
251623
252054
|
const sessionServerId = deps.remoteSessionMap.get(sessionId)?.remoteServerId;
|
|
251624
252055
|
if (sessionServerId) candidates.push(sessionServerId);
|
|
251625
252056
|
candidates.push(
|
|
251626
|
-
...await deps.storage.
|
|
252057
|
+
...await deps.storage.sessionRemoteTouches.list(sessionId, opts.userId)
|
|
251627
252058
|
);
|
|
251628
252059
|
}
|
|
251629
252060
|
const targets = [];
|
|
@@ -255942,7 +256373,7 @@ var routes16 = async (fastify2) => {
|
|
|
255942
256373
|
id: randomUUID21(),
|
|
255943
256374
|
project_id: projectId,
|
|
255944
256375
|
user_id: userId,
|
|
255945
|
-
title: null,
|
|
256376
|
+
title: body.message ? snippetTitle(body.message) : null,
|
|
255946
256377
|
create_request_id: createRequestId,
|
|
255947
256378
|
create_payload_hash: createPayloadHash,
|
|
255948
256379
|
...body.message !== void 0 ? { initialTurn: {
|
|
@@ -255964,6 +256395,12 @@ var routes16 = async (fastify2) => {
|
|
|
255964
256395
|
} catch (error48) {
|
|
255965
256396
|
req.log.warn({ err: error48, threadId: thread.id }, "Project Chat initial turn will resume later");
|
|
255966
256397
|
}
|
|
256398
|
+
void fastify2.projectChatManager.generateTitle(
|
|
256399
|
+
thread.id,
|
|
256400
|
+
userId,
|
|
256401
|
+
body.message,
|
|
256402
|
+
thread.title ?? snippetTitle(body.message)
|
|
256403
|
+
);
|
|
255967
256404
|
}
|
|
255968
256405
|
return reply.code(201).send({ thread });
|
|
255969
256406
|
});
|
|
@@ -257735,7 +258172,7 @@ var routes22 = async (fastify2) => {
|
|
|
257735
258172
|
for (const id of PROVIDER_IDS) masked[id] = maskApiKey(keys[id]);
|
|
257736
258173
|
return masked;
|
|
257737
258174
|
}
|
|
257738
|
-
function
|
|
258175
|
+
function serializeConfig2(config2) {
|
|
257739
258176
|
return {
|
|
257740
258177
|
apiKeys: maskApiKeys(config2.apiKeys),
|
|
257741
258178
|
main: config2.main,
|
|
@@ -257759,7 +258196,7 @@ var routes22 = async (fastify2) => {
|
|
|
257759
258196
|
const userId = requireSettingsUser(req, reply);
|
|
257760
258197
|
if (userId === null) return;
|
|
257761
258198
|
const config2 = await getChatProviderConfig(fastify2.storage, userId);
|
|
257762
|
-
return reply.code(200).send(
|
|
258199
|
+
return reply.code(200).send(serializeConfig2(config2));
|
|
257763
258200
|
});
|
|
257764
258201
|
fastify2.put("/api/settings/chat-provider", async (req, reply) => {
|
|
257765
258202
|
const userId = requireSettingsUser(req, reply);
|
|
@@ -257800,7 +258237,7 @@ var routes22 = async (fastify2) => {
|
|
|
257800
258237
|
console.log(
|
|
257801
258238
|
`[Settings] Chat provider updated: main=${updated.main.provider}/${updated.main.model}, fast=${updated.fast.provider}/${updated.fast.model}`
|
|
257802
258239
|
);
|
|
257803
|
-
return reply.code(200).send(
|
|
258240
|
+
return reply.code(200).send(serializeConfig2(updated));
|
|
257804
258241
|
});
|
|
257805
258242
|
fastify2.get("/api/settings/terminal", async (req, reply) => {
|
|
257806
258243
|
const userId = requireSettingsUser(req, reply);
|
|
@@ -257949,8 +258386,452 @@ ${text2}`,
|
|
|
257949
258386
|
};
|
|
257950
258387
|
var translate_routes_default = (0, import_fastify_plugin24.default)(routes23, { name: "translate-routes" });
|
|
257951
258388
|
|
|
257952
|
-
// src/routes/
|
|
258389
|
+
// src/routes/tts-routes.ts
|
|
257953
258390
|
var import_fastify_plugin25 = __toESM(require_plugin2(), 1);
|
|
258391
|
+
import { createHash as createHash10 } from "crypto";
|
|
258392
|
+
import { Readable as Readable2 } from "stream";
|
|
258393
|
+
|
|
258394
|
+
// src/tts/types.ts
|
|
258395
|
+
var TtsProviderError = class extends Error {
|
|
258396
|
+
constructor(kind, message) {
|
|
258397
|
+
super(message);
|
|
258398
|
+
this.kind = kind;
|
|
258399
|
+
this.name = "TtsProviderError";
|
|
258400
|
+
}
|
|
258401
|
+
kind;
|
|
258402
|
+
};
|
|
258403
|
+
|
|
258404
|
+
// src/tts/azure.ts
|
|
258405
|
+
var OUTPUT_FORMAT = "audio-24khz-48kbitrate-mono-mp3";
|
|
258406
|
+
var REGION_RE = /^[a-z0-9]+$/;
|
|
258407
|
+
var VOICE_RE = /^[A-Za-z]{2,3}-[A-Za-z0-9]{2,4}-[A-Za-z0-9_:-]+$/;
|
|
258408
|
+
function isHdVoice(voice) {
|
|
258409
|
+
return /:DragonHD/i.test(voice);
|
|
258410
|
+
}
|
|
258411
|
+
function escapeXml(text2) {
|
|
258412
|
+
return text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
258413
|
+
}
|
|
258414
|
+
function voiceLocale(voice) {
|
|
258415
|
+
const [lang, region] = voice.split("-");
|
|
258416
|
+
return lang && region ? `${lang}-${region}` : "en-US";
|
|
258417
|
+
}
|
|
258418
|
+
function buildSsml({ text: text2, voice }) {
|
|
258419
|
+
return `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="${voiceLocale(voice)}"><voice name="${escapeXml(voice)}">${escapeXml(text2)}</voice></speak>`;
|
|
258420
|
+
}
|
|
258421
|
+
function regionOf(creds) {
|
|
258422
|
+
const region = (creds.region ?? "").trim().toLowerCase();
|
|
258423
|
+
if (!REGION_RE.test(region)) throw new TtsProviderError("bad_request", "Invalid Azure region");
|
|
258424
|
+
return region;
|
|
258425
|
+
}
|
|
258426
|
+
function statusError(status, voice) {
|
|
258427
|
+
if (status === 401 || status === 403) return new TtsProviderError("auth", `Azure rejected the key (HTTP ${status})`);
|
|
258428
|
+
if (status === 429) return new TtsProviderError("quota", "Azure rate limit or quota exceeded");
|
|
258429
|
+
if (status === 400) {
|
|
258430
|
+
const hint = voice && isHdVoice(voice) ? " HD voices are only available in some Azure regions \u2014 check your resource's region, or pick a non-HD voice." : "";
|
|
258431
|
+
return new TtsProviderError("bad_request", `Azure rejected the request (HTTP 400).${hint}`);
|
|
258432
|
+
}
|
|
258433
|
+
return new TtsProviderError("upstream", `Azure returned HTTP ${status}`);
|
|
258434
|
+
}
|
|
258435
|
+
async function azureFetch(url2, init) {
|
|
258436
|
+
try {
|
|
258437
|
+
return await fetch(url2, init);
|
|
258438
|
+
} catch (err) {
|
|
258439
|
+
const name25 = err?.name;
|
|
258440
|
+
if (name25 === "AbortError" || name25 === "TimeoutError") throw err;
|
|
258441
|
+
throw new TtsProviderError("network", `Could not reach Azure: ${err?.message ?? err}`);
|
|
258442
|
+
}
|
|
258443
|
+
}
|
|
258444
|
+
var OMNI_GROUP = "HD Omni (recommended)";
|
|
258445
|
+
var MULTILINGUAL_GROUP = "Multilingual";
|
|
258446
|
+
function mapAzureVoices(rows) {
|
|
258447
|
+
const voices = [];
|
|
258448
|
+
for (const row of rows) {
|
|
258449
|
+
const id = row.ShortName;
|
|
258450
|
+
if (!id) continue;
|
|
258451
|
+
const omni = /:DragonHDOmni/i.test(id);
|
|
258452
|
+
const multilingual = !isHdVoice(id) && row.VoiceType === "Neural" && /Multilingual/i.test(id);
|
|
258453
|
+
if (!omni && !multilingual) continue;
|
|
258454
|
+
voices.push({
|
|
258455
|
+
id,
|
|
258456
|
+
label: `${row.LocalName || row.DisplayName || id} (${row.Locale ?? voiceLocale(id)})`,
|
|
258457
|
+
locale: row.Locale,
|
|
258458
|
+
multilingual: true,
|
|
258459
|
+
group: omni ? OMNI_GROUP : MULTILINGUAL_GROUP
|
|
258460
|
+
});
|
|
258461
|
+
}
|
|
258462
|
+
voices.sort((a, b2) => Number(b2.group === OMNI_GROUP) - Number(a.group === OMNI_GROUP) || a.id.localeCompare(b2.id));
|
|
258463
|
+
return voices;
|
|
258464
|
+
}
|
|
258465
|
+
var azureProvider = {
|
|
258466
|
+
id: "azure",
|
|
258467
|
+
label: "Azure Speech",
|
|
258468
|
+
credentialFields: [
|
|
258469
|
+
{ key: "apiKey", label: "API key", secret: true, envKey: "AZURE_SPEECH_KEY" },
|
|
258470
|
+
{ key: "region", label: "Region", secret: false, envKey: "AZURE_SPEECH_REGION", placeholder: "southeastasia" }
|
|
258471
|
+
],
|
|
258472
|
+
defaultVoice: "zh-CN-Xiaoxiao:DragonHDOmniLatestNeural",
|
|
258473
|
+
maxCharsPerRequest: 1500,
|
|
258474
|
+
isValidVoice: (voice) => VOICE_RE.test(voice),
|
|
258475
|
+
async listVoices(creds, { signal, dispatcher }) {
|
|
258476
|
+
const res = await azureFetch(
|
|
258477
|
+
`https://${regionOf(creds)}.tts.speech.microsoft.com/cognitiveservices/voices/list`,
|
|
258478
|
+
{ headers: { "Ocp-Apim-Subscription-Key": creds.apiKey ?? "" }, signal, dispatcher }
|
|
258479
|
+
);
|
|
258480
|
+
if (!res.ok) throw statusError(res.status);
|
|
258481
|
+
const rows = await res.json();
|
|
258482
|
+
return mapAzureVoices(Array.isArray(rows) ? rows : []);
|
|
258483
|
+
},
|
|
258484
|
+
async synthesize(creds, { text: text2, voice, signal, dispatcher }) {
|
|
258485
|
+
const res = await azureFetch(
|
|
258486
|
+
`https://${regionOf(creds)}.tts.speech.microsoft.com/cognitiveservices/v1`,
|
|
258487
|
+
{
|
|
258488
|
+
method: "POST",
|
|
258489
|
+
headers: {
|
|
258490
|
+
"Ocp-Apim-Subscription-Key": creds.apiKey ?? "",
|
|
258491
|
+
"Content-Type": "application/ssml+xml",
|
|
258492
|
+
"X-Microsoft-OutputFormat": OUTPUT_FORMAT,
|
|
258493
|
+
"User-Agent": "vibedeckx"
|
|
258494
|
+
},
|
|
258495
|
+
body: buildSsml({ text: text2, voice }),
|
|
258496
|
+
signal,
|
|
258497
|
+
dispatcher
|
|
258498
|
+
}
|
|
258499
|
+
);
|
|
258500
|
+
if (!res.ok || !res.body) {
|
|
258501
|
+
await res.body?.cancel().catch(() => {
|
|
258502
|
+
});
|
|
258503
|
+
throw statusError(res.ok ? 502 : res.status, voice);
|
|
258504
|
+
}
|
|
258505
|
+
return { audio: res.body, contentType: "audio/mpeg" };
|
|
258506
|
+
}
|
|
258507
|
+
};
|
|
258508
|
+
|
|
258509
|
+
// src/tts/providers.ts
|
|
258510
|
+
var TTS_PROVIDERS = {
|
|
258511
|
+
azure: azureProvider
|
|
258512
|
+
};
|
|
258513
|
+
var TTS_PROVIDER_IDS = Object.keys(TTS_PROVIDERS);
|
|
258514
|
+
var DEFAULT_TTS_PROVIDER = "azure";
|
|
258515
|
+
function isTtsProviderId(value) {
|
|
258516
|
+
return typeof value === "string" && Object.prototype.hasOwnProperty.call(TTS_PROVIDERS, value);
|
|
258517
|
+
}
|
|
258518
|
+
|
|
258519
|
+
// src/tts/config.ts
|
|
258520
|
+
var TTS_SETTING_KEY = "tts";
|
|
258521
|
+
var TTS_RATE_MIN = 0.5;
|
|
258522
|
+
var TTS_RATE_MAX = 2;
|
|
258523
|
+
function clampRate(value, fallback = 1) {
|
|
258524
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
|
|
258525
|
+
return Math.min(TTS_RATE_MAX, Math.max(TTS_RATE_MIN, Math.round(value * 100) / 100));
|
|
258526
|
+
}
|
|
258527
|
+
function normalizeVoice(provider, voice) {
|
|
258528
|
+
const def = TTS_PROVIDERS[provider];
|
|
258529
|
+
return typeof voice === "string" && def.isValidVoice(voice) ? voice : def.defaultVoice;
|
|
258530
|
+
}
|
|
258531
|
+
function normalizeCredentials(raw) {
|
|
258532
|
+
const out = {};
|
|
258533
|
+
if (!raw || typeof raw !== "object") return out;
|
|
258534
|
+
for (const id of TTS_PROVIDER_IDS) {
|
|
258535
|
+
const entry = raw[id];
|
|
258536
|
+
if (!entry || typeof entry !== "object") continue;
|
|
258537
|
+
const creds = {};
|
|
258538
|
+
for (const field of TTS_PROVIDERS[id].credentialFields) {
|
|
258539
|
+
const value = entry[field.key];
|
|
258540
|
+
if (typeof value === "string") creds[field.key] = value;
|
|
258541
|
+
}
|
|
258542
|
+
out[id] = creds;
|
|
258543
|
+
}
|
|
258544
|
+
return out;
|
|
258545
|
+
}
|
|
258546
|
+
function defaultTtsConfig() {
|
|
258547
|
+
return {
|
|
258548
|
+
provider: DEFAULT_TTS_PROVIDER,
|
|
258549
|
+
credentials: {},
|
|
258550
|
+
voice: TTS_PROVIDERS[DEFAULT_TTS_PROVIDER].defaultVoice,
|
|
258551
|
+
rate: 1
|
|
258552
|
+
};
|
|
258553
|
+
}
|
|
258554
|
+
function parseTtsConfig(raw) {
|
|
258555
|
+
if (!raw) return defaultTtsConfig();
|
|
258556
|
+
try {
|
|
258557
|
+
const parsed = JSON.parse(raw);
|
|
258558
|
+
if (!parsed || typeof parsed !== "object") return defaultTtsConfig();
|
|
258559
|
+
const provider = isTtsProviderId(parsed.provider) ? parsed.provider : DEFAULT_TTS_PROVIDER;
|
|
258560
|
+
return {
|
|
258561
|
+
provider,
|
|
258562
|
+
credentials: normalizeCredentials(parsed.credentials),
|
|
258563
|
+
voice: normalizeVoice(provider, parsed.voice),
|
|
258564
|
+
rate: clampRate(parsed.rate)
|
|
258565
|
+
};
|
|
258566
|
+
} catch {
|
|
258567
|
+
return defaultTtsConfig();
|
|
258568
|
+
}
|
|
258569
|
+
}
|
|
258570
|
+
async function getTtsConfig(storage2, userId) {
|
|
258571
|
+
return parseTtsConfig(await storage2.userSettings.get(userId, TTS_SETTING_KEY));
|
|
258572
|
+
}
|
|
258573
|
+
function resolveCredentials(config2, provider = config2.provider) {
|
|
258574
|
+
const stored = config2.credentials[provider] ?? {};
|
|
258575
|
+
const creds = {};
|
|
258576
|
+
for (const field of TTS_PROVIDERS[provider].credentialFields) {
|
|
258577
|
+
const value = stored[field.key]?.trim() || (field.envKey ? process.env[field.envKey]?.trim() : "") || "";
|
|
258578
|
+
creds[field.key] = value;
|
|
258579
|
+
}
|
|
258580
|
+
return creds;
|
|
258581
|
+
}
|
|
258582
|
+
function isTtsConfigured(config2, provider = config2.provider) {
|
|
258583
|
+
const creds = resolveCredentials(config2, provider);
|
|
258584
|
+
return TTS_PROVIDERS[provider].credentialFields.every((field) => creds[field.key].length > 0);
|
|
258585
|
+
}
|
|
258586
|
+
function maskSecret(value) {
|
|
258587
|
+
if (!value) return "";
|
|
258588
|
+
if (value.length <= 4) return "****";
|
|
258589
|
+
return "****" + value.slice(-4);
|
|
258590
|
+
}
|
|
258591
|
+
|
|
258592
|
+
// src/routes/tts-routes.ts
|
|
258593
|
+
var TtsValidationError = class extends Error {
|
|
258594
|
+
};
|
|
258595
|
+
var TTS_MAX_CONCURRENT_PER_USER = 2;
|
|
258596
|
+
var VOICE_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
258597
|
+
var VOICE_CACHE_MAX = 50;
|
|
258598
|
+
var SYNTHESIZE_TIMEOUT_MS = 6e4;
|
|
258599
|
+
function requireTtsUser(req, reply) {
|
|
258600
|
+
const auth2 = requireAuth(req, reply);
|
|
258601
|
+
if (auth2 === null) return null;
|
|
258602
|
+
return resolveUserId(auth2);
|
|
258603
|
+
}
|
|
258604
|
+
function serializeConfig(config2) {
|
|
258605
|
+
const credentials = {};
|
|
258606
|
+
for (const id of TTS_PROVIDER_IDS) {
|
|
258607
|
+
const stored = config2.credentials[id] ?? {};
|
|
258608
|
+
const out = {};
|
|
258609
|
+
for (const field of TTS_PROVIDERS[id].credentialFields) {
|
|
258610
|
+
const value = stored[field.key] ?? "";
|
|
258611
|
+
out[field.key] = field.secret ? maskSecret(value) : value;
|
|
258612
|
+
}
|
|
258613
|
+
credentials[id] = out;
|
|
258614
|
+
}
|
|
258615
|
+
return {
|
|
258616
|
+
provider: config2.provider,
|
|
258617
|
+
voice: config2.voice,
|
|
258618
|
+
rate: config2.rate,
|
|
258619
|
+
configured: isTtsConfigured(config2),
|
|
258620
|
+
credentials,
|
|
258621
|
+
rateRange: { min: TTS_RATE_MIN, max: TTS_RATE_MAX },
|
|
258622
|
+
providers: TTS_PROVIDER_IDS.map((id) => {
|
|
258623
|
+
const def = TTS_PROVIDERS[id];
|
|
258624
|
+
return {
|
|
258625
|
+
id,
|
|
258626
|
+
label: def.label,
|
|
258627
|
+
defaultVoice: def.defaultVoice,
|
|
258628
|
+
maxCharsPerRequest: def.maxCharsPerRequest,
|
|
258629
|
+
configured: isTtsConfigured(config2, id),
|
|
258630
|
+
credentialFields: def.credentialFields.map((field) => ({
|
|
258631
|
+
key: field.key,
|
|
258632
|
+
label: field.label,
|
|
258633
|
+
secret: field.secret,
|
|
258634
|
+
placeholder: field.placeholder,
|
|
258635
|
+
// Lets the UI say "using the server default" without revealing the value.
|
|
258636
|
+
fromEnv: Boolean(field.envKey && process.env[field.envKey]?.trim())
|
|
258637
|
+
}))
|
|
258638
|
+
};
|
|
258639
|
+
})
|
|
258640
|
+
};
|
|
258641
|
+
}
|
|
258642
|
+
function errorReply(reply, err) {
|
|
258643
|
+
switch (err.kind) {
|
|
258644
|
+
// Not 401: the client would read that as its own session having expired.
|
|
258645
|
+
case "auth":
|
|
258646
|
+
return reply.code(502).send({ code: "tts_auth_failed", error: err.message });
|
|
258647
|
+
case "quota":
|
|
258648
|
+
return reply.code(429).send({ code: "tts_quota", error: err.message });
|
|
258649
|
+
case "bad_request":
|
|
258650
|
+
return reply.code(400).send({ code: "tts_bad_request", error: err.message });
|
|
258651
|
+
default:
|
|
258652
|
+
return reply.code(502).send({ code: "tts_upstream", error: err.message });
|
|
258653
|
+
}
|
|
258654
|
+
}
|
|
258655
|
+
var routes24 = async (fastify2) => {
|
|
258656
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
258657
|
+
const voiceCache = /* @__PURE__ */ new Map();
|
|
258658
|
+
const dispatcher = () => fastify2.proxyManager?.getFetchDispatcher();
|
|
258659
|
+
fastify2.get("/api/settings/tts", async (req, reply) => {
|
|
258660
|
+
const userId = requireTtsUser(req, reply);
|
|
258661
|
+
if (userId === null) return;
|
|
258662
|
+
return reply.code(200).send(serializeConfig(await getTtsConfig(fastify2.storage, userId)));
|
|
258663
|
+
});
|
|
258664
|
+
fastify2.put("/api/settings/tts", async (req, reply) => {
|
|
258665
|
+
const userId = requireTtsUser(req, reply);
|
|
258666
|
+
if (userId === null) return;
|
|
258667
|
+
const body = req.body ?? {};
|
|
258668
|
+
let updated;
|
|
258669
|
+
try {
|
|
258670
|
+
await fastify2.storage.userSettings.update(userId, TTS_SETTING_KEY, (current) => {
|
|
258671
|
+
const existing = parseTtsConfig(current);
|
|
258672
|
+
let provider = existing.provider;
|
|
258673
|
+
if (body.provider !== void 0) {
|
|
258674
|
+
if (!isTtsProviderId(body.provider)) {
|
|
258675
|
+
throw new TtsValidationError(`provider must be one of: ${TTS_PROVIDER_IDS.join(", ")}`);
|
|
258676
|
+
}
|
|
258677
|
+
provider = body.provider;
|
|
258678
|
+
}
|
|
258679
|
+
const credentials = { ...existing.credentials };
|
|
258680
|
+
if (body.credentials !== void 0) {
|
|
258681
|
+
if (!body.credentials || typeof body.credentials !== "object") {
|
|
258682
|
+
throw new TtsValidationError("credentials must be an object");
|
|
258683
|
+
}
|
|
258684
|
+
for (const id of TTS_PROVIDER_IDS) {
|
|
258685
|
+
const incoming = body.credentials[id];
|
|
258686
|
+
if (incoming === void 0) continue;
|
|
258687
|
+
if (!incoming || typeof incoming !== "object") {
|
|
258688
|
+
throw new TtsValidationError(`credentials.${id} must be an object`);
|
|
258689
|
+
}
|
|
258690
|
+
const merged = { ...existing.credentials[id] ?? {} };
|
|
258691
|
+
for (const field of TTS_PROVIDERS[id].credentialFields) {
|
|
258692
|
+
const value = incoming[field.key];
|
|
258693
|
+
if (value === void 0) continue;
|
|
258694
|
+
if (typeof value !== "string") {
|
|
258695
|
+
throw new TtsValidationError(`credentials.${id}.${field.key} must be a string`);
|
|
258696
|
+
}
|
|
258697
|
+
if (field.secret && value !== "" && value === maskSecret(merged[field.key] ?? "")) continue;
|
|
258698
|
+
merged[field.key] = value.trim();
|
|
258699
|
+
}
|
|
258700
|
+
credentials[id] = merged;
|
|
258701
|
+
}
|
|
258702
|
+
}
|
|
258703
|
+
let voice;
|
|
258704
|
+
if (body.voice !== void 0) {
|
|
258705
|
+
if (typeof body.voice !== "string" || !TTS_PROVIDERS[provider].isValidVoice(body.voice)) {
|
|
258706
|
+
throw new TtsValidationError(`voice is not a valid ${TTS_PROVIDERS[provider].label} voice`);
|
|
258707
|
+
}
|
|
258708
|
+
voice = body.voice;
|
|
258709
|
+
} else {
|
|
258710
|
+
voice = normalizeVoice(provider, provider === existing.provider ? existing.voice : void 0);
|
|
258711
|
+
}
|
|
258712
|
+
let rate = existing.rate;
|
|
258713
|
+
if (body.rate !== void 0) {
|
|
258714
|
+
if (typeof body.rate !== "number" || !Number.isFinite(body.rate) || body.rate < TTS_RATE_MIN || body.rate > TTS_RATE_MAX) {
|
|
258715
|
+
throw new TtsValidationError(`rate must be a number between ${TTS_RATE_MIN} and ${TTS_RATE_MAX}`);
|
|
258716
|
+
}
|
|
258717
|
+
rate = clampRate(body.rate);
|
|
258718
|
+
}
|
|
258719
|
+
updated = { provider, credentials, voice, rate };
|
|
258720
|
+
return JSON.stringify(updated);
|
|
258721
|
+
});
|
|
258722
|
+
} catch (err) {
|
|
258723
|
+
if (err instanceof TtsValidationError) return reply.code(400).send({ error: err.message });
|
|
258724
|
+
throw err;
|
|
258725
|
+
}
|
|
258726
|
+
console.log(`[Settings] TTS updated: provider=${updated.provider}, voice=${updated.voice}, rate=${updated.rate}`);
|
|
258727
|
+
return reply.code(200).send(serializeConfig(updated));
|
|
258728
|
+
});
|
|
258729
|
+
fastify2.get("/api/tts/voices", async (req, reply) => {
|
|
258730
|
+
const userId = requireTtsUser(req, reply);
|
|
258731
|
+
if (userId === null) return;
|
|
258732
|
+
const config2 = await getTtsConfig(fastify2.storage, userId);
|
|
258733
|
+
const requested = req.query.provider;
|
|
258734
|
+
if (requested !== void 0 && !isTtsProviderId(requested)) {
|
|
258735
|
+
return reply.code(400).send({ error: `provider must be one of: ${TTS_PROVIDER_IDS.join(", ")}` });
|
|
258736
|
+
}
|
|
258737
|
+
const provider = requested ?? config2.provider;
|
|
258738
|
+
if (!isTtsConfigured(config2, provider)) {
|
|
258739
|
+
return reply.code(409).send({ code: "tts_not_configured", error: "Text-to-speech is not configured" });
|
|
258740
|
+
}
|
|
258741
|
+
const creds = resolveCredentials(config2, provider);
|
|
258742
|
+
const cacheKey2 = createHash10("sha256").update(provider).update("\0").update(JSON.stringify(creds)).digest("hex");
|
|
258743
|
+
const cached2 = voiceCache.get(cacheKey2);
|
|
258744
|
+
if (cached2 && Date.now() - cached2.at < VOICE_CACHE_TTL_MS) {
|
|
258745
|
+
return reply.code(200).send({ provider, voices: cached2.voices });
|
|
258746
|
+
}
|
|
258747
|
+
try {
|
|
258748
|
+
const voices = await TTS_PROVIDERS[provider].listVoices(creds, {
|
|
258749
|
+
signal: AbortSignal.timeout(15e3),
|
|
258750
|
+
dispatcher: dispatcher()
|
|
258751
|
+
});
|
|
258752
|
+
if (voiceCache.size >= VOICE_CACHE_MAX) voiceCache.delete(voiceCache.keys().next().value);
|
|
258753
|
+
voiceCache.set(cacheKey2, { at: Date.now(), voices });
|
|
258754
|
+
return reply.code(200).send({ provider, voices });
|
|
258755
|
+
} catch (err) {
|
|
258756
|
+
if (err instanceof TtsProviderError) return errorReply(reply, err);
|
|
258757
|
+
if (err?.name === "TimeoutError") {
|
|
258758
|
+
return reply.code(504).send({ code: "tts_upstream", error: "Voice list request timed out" });
|
|
258759
|
+
}
|
|
258760
|
+
throw err;
|
|
258761
|
+
}
|
|
258762
|
+
});
|
|
258763
|
+
fastify2.post(
|
|
258764
|
+
"/api/tts/synthesize",
|
|
258765
|
+
async (req, reply) => {
|
|
258766
|
+
const userId = requireTtsUser(req, reply);
|
|
258767
|
+
if (userId === null) return;
|
|
258768
|
+
const config2 = await getTtsConfig(fastify2.storage, userId);
|
|
258769
|
+
const def = TTS_PROVIDERS[config2.provider];
|
|
258770
|
+
const body = req.body ?? {};
|
|
258771
|
+
const text2 = typeof body.text === "string" ? body.text.trim() : "";
|
|
258772
|
+
if (!text2) return reply.code(400).send({ error: "text is required" });
|
|
258773
|
+
if (text2.length > def.maxCharsPerRequest) {
|
|
258774
|
+
return reply.code(400).send({ error: `text must be at most ${def.maxCharsPerRequest} characters` });
|
|
258775
|
+
}
|
|
258776
|
+
if (body.voice !== void 0 && (typeof body.voice !== "string" || !def.isValidVoice(body.voice))) {
|
|
258777
|
+
return reply.code(400).send({ error: "invalid voice" });
|
|
258778
|
+
}
|
|
258779
|
+
if (!isTtsConfigured(config2)) {
|
|
258780
|
+
return reply.code(409).send({ code: "tts_not_configured", error: "Text-to-speech is not configured" });
|
|
258781
|
+
}
|
|
258782
|
+
const active = inFlight.get(userId) ?? 0;
|
|
258783
|
+
if (active >= TTS_MAX_CONCURRENT_PER_USER) {
|
|
258784
|
+
return reply.code(429).send({ code: "tts_busy", error: "Too many concurrent speech requests" });
|
|
258785
|
+
}
|
|
258786
|
+
inFlight.set(userId, active + 1);
|
|
258787
|
+
let released = false;
|
|
258788
|
+
const release = () => {
|
|
258789
|
+
if (released) return;
|
|
258790
|
+
released = true;
|
|
258791
|
+
const n = (inFlight.get(userId) ?? 1) - 1;
|
|
258792
|
+
if (n <= 0) inFlight.delete(userId);
|
|
258793
|
+
else inFlight.set(userId, n);
|
|
258794
|
+
};
|
|
258795
|
+
const controller = new AbortController();
|
|
258796
|
+
reply.raw.once("close", () => {
|
|
258797
|
+
if (!reply.raw.writableFinished) controller.abort();
|
|
258798
|
+
release();
|
|
258799
|
+
});
|
|
258800
|
+
const startedAt = Date.now();
|
|
258801
|
+
let result;
|
|
258802
|
+
try {
|
|
258803
|
+
result = await def.synthesize(resolveCredentials(config2), {
|
|
258804
|
+
text: text2,
|
|
258805
|
+
voice: typeof body.voice === "string" ? body.voice : config2.voice,
|
|
258806
|
+
signal: AbortSignal.any([controller.signal, AbortSignal.timeout(SYNTHESIZE_TIMEOUT_MS)]),
|
|
258807
|
+
dispatcher: dispatcher()
|
|
258808
|
+
});
|
|
258809
|
+
} catch (err) {
|
|
258810
|
+
release();
|
|
258811
|
+
if (err instanceof TtsProviderError) {
|
|
258812
|
+
console.warn(`[tts] ${config2.provider} synthesize failed (${err.kind}): ${err.message}`);
|
|
258813
|
+
return errorReply(reply, err);
|
|
258814
|
+
}
|
|
258815
|
+
if (controller.signal.aborted) return reply.code(499).send();
|
|
258816
|
+
if (err?.name === "TimeoutError") {
|
|
258817
|
+
return reply.code(504).send({ code: "tts_upstream", error: "Speech synthesis timed out" });
|
|
258818
|
+
}
|
|
258819
|
+
throw err;
|
|
258820
|
+
}
|
|
258821
|
+
console.log(`[tts] ${config2.provider} chars=${text2.length} ttfb=${Date.now() - startedAt}ms`);
|
|
258822
|
+
const audio = Readable2.fromWeb(result.audio);
|
|
258823
|
+
audio.once("close", release);
|
|
258824
|
+
audio.once("error", (err) => {
|
|
258825
|
+
if (!controller.signal.aborted) console.warn(`[tts] audio stream error: ${err.message}`);
|
|
258826
|
+
});
|
|
258827
|
+
return reply.code(200).header("Content-Type", result.contentType).header("Cache-Control", "no-store").send(audio);
|
|
258828
|
+
}
|
|
258829
|
+
);
|
|
258830
|
+
};
|
|
258831
|
+
var tts_routes_default = (0, import_fastify_plugin25.default)(routes24, { name: "tts-routes" });
|
|
258832
|
+
|
|
258833
|
+
// src/routes/websocket-routes.ts
|
|
258834
|
+
var import_fastify_plugin26 = __toESM(require_plugin2(), 1);
|
|
257954
258835
|
|
|
257955
258836
|
// src/routes/executor-stream-handlers.ts
|
|
257956
258837
|
import { randomUUID as randomUUID26 } from "crypto";
|
|
@@ -258264,7 +259145,7 @@ function resolveRemoteReplayCursor(clientEpoch, cachedEpoch, afterEntryIndex) {
|
|
|
258264
259145
|
replayAfter: epochMatches ? afterEntryIndex ?? -1 : -1
|
|
258265
259146
|
};
|
|
258266
259147
|
}
|
|
258267
|
-
var
|
|
259148
|
+
var routes25 = async (fastify2) => {
|
|
258268
259149
|
fastify2.reverseConnectManager.setStatusChangeHandler((remoteServerId, status) => {
|
|
258269
259150
|
if (status !== "online") return;
|
|
258270
259151
|
const cache2 = fastify2.remotePatchCache;
|
|
@@ -258784,11 +259665,11 @@ var routes24 = async (fastify2) => {
|
|
|
258784
259665
|
);
|
|
258785
259666
|
});
|
|
258786
259667
|
};
|
|
258787
|
-
var websocket_routes_default = (0,
|
|
259668
|
+
var websocket_routes_default = (0, import_fastify_plugin26.default)(routes25, { name: "websocket-routes" });
|
|
258788
259669
|
|
|
258789
259670
|
// src/routes/reverse-connect-routes.ts
|
|
258790
|
-
var
|
|
258791
|
-
import { randomBytes as randomBytes4, createHash as
|
|
259671
|
+
var import_fastify_plugin27 = __toESM(require_plugin2(), 1);
|
|
259672
|
+
import { randomBytes as randomBytes4, createHash as createHash11, verify as cryptoVerify } from "crypto";
|
|
258792
259673
|
|
|
258793
259674
|
// src/utils/rate-limited-warn.ts
|
|
258794
259675
|
function createRateLimitedWarn(windowMs, maxKeys) {
|
|
@@ -258832,7 +259713,7 @@ function extractReportedVersion(frame) {
|
|
|
258832
259713
|
var MACHINE_HANDSHAKE_TIMEOUT_MS = 5e3;
|
|
258833
259714
|
var REJECT_LOG_WINDOW_MS = 3e4;
|
|
258834
259715
|
var REJECT_LOG_MAX_KEYS = 500;
|
|
258835
|
-
var
|
|
259716
|
+
var routes26 = async (fastify2) => {
|
|
258836
259717
|
const logRejectedUpgrade = createRateLimitedWarn(REJECT_LOG_WINDOW_MS, REJECT_LOG_MAX_KEYS);
|
|
258837
259718
|
fastify2.get("/api/reverse-connect/identity", async (req, reply) => {
|
|
258838
259719
|
const token = req.headers["x-vibedeckx-connect-token"];
|
|
@@ -258938,7 +259819,7 @@ var routes25 = async (fastify2) => {
|
|
|
258938
259819
|
socket.close(4003, "Bad machine signature");
|
|
258939
259820
|
return;
|
|
258940
259821
|
}
|
|
258941
|
-
const fingerprint =
|
|
259822
|
+
const fingerprint = createHash11("sha256").update(publicKey).digest("hex");
|
|
258942
259823
|
const { owned, created } = await fastify2.storage.machineIdentity.claimOrVerify(fingerprint, publicKey, ownerId);
|
|
258943
259824
|
if (!owned) {
|
|
258944
259825
|
console.warn(`[ReverseConnect] Machine ${fingerprint.slice(0, 12)} owner mismatch \u2014 rejecting ${serverId}`);
|
|
@@ -258966,10 +259847,10 @@ var routes25 = async (fastify2) => {
|
|
|
258966
259847
|
);
|
|
258967
259848
|
});
|
|
258968
259849
|
};
|
|
258969
|
-
var reverse_connect_routes_default = (0,
|
|
259850
|
+
var reverse_connect_routes_default = (0, import_fastify_plugin27.default)(routes26, { name: "reverse-connect-routes" });
|
|
258970
259851
|
|
|
258971
259852
|
// src/routes/event-routes.ts
|
|
258972
|
-
var
|
|
259853
|
+
var import_fastify_plugin28 = __toESM(require_plugin2(), 1);
|
|
258973
259854
|
function toWireEvent(event) {
|
|
258974
259855
|
if (event.type === "executor:stopped" && (event.tailOutput !== void 0 || event.finalResult !== void 0)) {
|
|
258975
259856
|
const { tailOutput: _tailOutput, finalResult: _finalResult, ...rest } = event;
|
|
@@ -258977,7 +259858,7 @@ function toWireEvent(event) {
|
|
|
258977
259858
|
}
|
|
258978
259859
|
return event;
|
|
258979
259860
|
}
|
|
258980
|
-
var
|
|
259861
|
+
var routes27 = async (fastify2) => {
|
|
258981
259862
|
fastify2.get("/api/events", async (req, reply) => {
|
|
258982
259863
|
let userId = null;
|
|
258983
259864
|
if (fastify2.authEnabled) {
|
|
@@ -259037,10 +259918,10 @@ var routes26 = async (fastify2) => {
|
|
|
259037
259918
|
await reply;
|
|
259038
259919
|
});
|
|
259039
259920
|
};
|
|
259040
|
-
var event_routes_default = (0,
|
|
259921
|
+
var event_routes_default = (0, import_fastify_plugin28.default)(routes27, { name: "event-routes" });
|
|
259041
259922
|
|
|
259042
259923
|
// src/routes/terminal-routes.ts
|
|
259043
|
-
var
|
|
259924
|
+
var import_fastify_plugin29 = __toESM(require_plugin2(), 1);
|
|
259044
259925
|
import path17 from "path";
|
|
259045
259926
|
async function getRemoteConfig5(fastify2, project, remoteServerId) {
|
|
259046
259927
|
const remotes = await fastify2.storage.projectRemotes.getByProject(project.id);
|
|
@@ -259051,7 +259932,7 @@ async function getRemoteConfig5(fastify2, project, remoteServerId) {
|
|
|
259051
259932
|
remotePath: target.remote_path
|
|
259052
259933
|
};
|
|
259053
259934
|
}
|
|
259054
|
-
var
|
|
259935
|
+
var routes28 = async (fastify2) => {
|
|
259055
259936
|
fastify2.post("/api/path/terminals", async (req, reply) => {
|
|
259056
259937
|
const { path: projectPath, branch } = req.body;
|
|
259057
259938
|
if (!projectPath) {
|
|
@@ -259226,11 +260107,11 @@ var routes27 = async (fastify2) => {
|
|
|
259226
260107
|
}
|
|
259227
260108
|
);
|
|
259228
260109
|
};
|
|
259229
|
-
var terminal_routes_default = (0,
|
|
260110
|
+
var terminal_routes_default = (0, import_fastify_plugin29.default)(routes28, { name: "terminal-routes" });
|
|
259230
260111
|
|
|
259231
260112
|
// src/routes/browser-routes.ts
|
|
259232
|
-
var
|
|
259233
|
-
var
|
|
260113
|
+
var import_fastify_plugin30 = __toESM(require_plugin2(), 1);
|
|
260114
|
+
var routes29 = async (fastify2) => {
|
|
259234
260115
|
const ensureProjectAccess = async (req, reply) => {
|
|
259235
260116
|
const userId = requireUserFacingUserId(req, reply);
|
|
259236
260117
|
if (userId === null) return null;
|
|
@@ -259301,10 +260182,10 @@ var routes28 = async (fastify2) => {
|
|
|
259301
260182
|
return reply.code(200).send({ ok: true });
|
|
259302
260183
|
});
|
|
259303
260184
|
};
|
|
259304
|
-
var browser_routes_default = (0,
|
|
260185
|
+
var browser_routes_default = (0, import_fastify_plugin30.default)(routes29, { name: "browser-routes" });
|
|
259305
260186
|
|
|
259306
260187
|
// src/routes/browser-proxy-routes.ts
|
|
259307
|
-
var
|
|
260188
|
+
var import_fastify_plugin31 = __toESM(require_plugin2(), 1);
|
|
259308
260189
|
import { randomUUID as randomUUID27 } from "crypto";
|
|
259309
260190
|
|
|
259310
260191
|
// src/utils/ssrf-guard.ts
|
|
@@ -259800,7 +260681,7 @@ function generateInjectedScript(projectId, targetOrigin, proxyWsPrefix) {
|
|
|
259800
260681
|
})();
|
|
259801
260682
|
</script>`;
|
|
259802
260683
|
}
|
|
259803
|
-
var
|
|
260684
|
+
var routes30 = async (fastify2) => {
|
|
259804
260685
|
fastify2.get("/api/projects/:id/browser/proxy/*", async (req, reply) => {
|
|
259805
260686
|
const userId = requireUserFacingOrTrustedProxyUserId(req, reply);
|
|
259806
260687
|
if (userId === null) return;
|
|
@@ -259972,10 +260853,10 @@ var routes29 = async (fastify2) => {
|
|
|
259972
260853
|
});
|
|
259973
260854
|
});
|
|
259974
260855
|
};
|
|
259975
|
-
var browser_proxy_routes_default = (0,
|
|
260856
|
+
var browser_proxy_routes_default = (0, import_fastify_plugin31.default)(routes30, { name: "browser-proxy-routes" });
|
|
259976
260857
|
|
|
259977
260858
|
// src/routes/cross-remote-target-routes.ts
|
|
259978
|
-
var
|
|
260859
|
+
var import_fastify_plugin32 = __toESM(require_plugin2(), 1);
|
|
259979
260860
|
import path19 from "path";
|
|
259980
260861
|
import { promises as fs4 } from "fs";
|
|
259981
260862
|
|
|
@@ -265222,7 +266103,7 @@ var clampTimeoutMs = (timeoutSec) => {
|
|
|
265222
266103
|
const requested = typeof timeoutSec === "number" && Number.isFinite(timeoutSec) && timeoutSec > 0 ? timeoutSec : DEFAULT_TIMEOUT_SEC;
|
|
265223
266104
|
return Math.min(requested, MAX_TIMEOUT_SEC) * 1e3;
|
|
265224
266105
|
};
|
|
265225
|
-
var
|
|
266106
|
+
var routes31 = async (fastify2) => {
|
|
265226
266107
|
const mcpSessions = new RemoteMcpSessionManager();
|
|
265227
266108
|
fastify2.decorate("remoteMcpSessionManager", mcpSessions);
|
|
265228
266109
|
fastify2.addHook("onClose", async () => mcpSessions.shutdown());
|
|
@@ -265386,10 +266267,10 @@ var routes30 = async (fastify2) => {
|
|
|
265386
266267
|
return reply.send({ closed: await mcpSessions.close(request.body?.workerHandle ?? "") });
|
|
265387
266268
|
});
|
|
265388
266269
|
};
|
|
265389
|
-
var cross_remote_target_routes_default = (0,
|
|
266270
|
+
var cross_remote_target_routes_default = (0, import_fastify_plugin32.default)(routes31, { name: "cross-remote-target-routes" });
|
|
265390
266271
|
|
|
265391
266272
|
// src/routes/cross-remote-mcp-routes.ts
|
|
265392
|
-
var
|
|
266273
|
+
var import_fastify_plugin33 = __toESM(require_plugin2(), 1);
|
|
265393
266274
|
var PROTOCOL_VERSION = "2024-11-05";
|
|
265394
266275
|
var AUDIT_ARGS_MAX = 1024;
|
|
265395
266276
|
var NOT_ACCESSIBLE = "remote not found or not accessible";
|
|
@@ -265613,7 +266494,7 @@ var textResult = (text2, isError = false) => ({
|
|
|
265613
266494
|
content: [{ type: "text", text: text2 }],
|
|
265614
266495
|
...isError ? { isError: true } : {}
|
|
265615
266496
|
});
|
|
265616
|
-
var
|
|
266497
|
+
var routes32 = async (fastify2) => {
|
|
265617
266498
|
const guard = new SessionConcurrencyGuard();
|
|
265618
266499
|
let cachedSecret;
|
|
265619
266500
|
const getSecret = () => {
|
|
@@ -265699,6 +266580,12 @@ var routes31 = async (fastify2) => {
|
|
|
265699
266580
|
} catch (err) {
|
|
265700
266581
|
console.error("[CrossRemoteMCP] Failed to write audit row:", err);
|
|
265701
266582
|
}
|
|
266583
|
+
if (status === "denied" || status === "offline") return;
|
|
266584
|
+
try {
|
|
266585
|
+
await fastify2.storage.sessionRemoteTouches.record(payload.sessionId, payload.userId, targetRemoteId);
|
|
266586
|
+
} catch (err) {
|
|
266587
|
+
console.error("[CrossRemoteMCP] Failed to record session touch:", err);
|
|
266588
|
+
}
|
|
265702
266589
|
};
|
|
265703
266590
|
const callTool = async (payload, toolName, args) => {
|
|
265704
266591
|
if (toolName === "list_accessible_remotes") {
|
|
@@ -265837,10 +266724,10 @@ var routes31 = async (fastify2) => {
|
|
|
265837
266724
|
}
|
|
265838
266725
|
});
|
|
265839
266726
|
};
|
|
265840
|
-
var cross_remote_mcp_routes_default = (0,
|
|
266727
|
+
var cross_remote_mcp_routes_default = (0, import_fastify_plugin33.default)(routes32, { name: "cross-remote-mcp-routes" });
|
|
265841
266728
|
|
|
265842
266729
|
// src/routes/session-mcp-routes.ts
|
|
265843
|
-
var
|
|
266730
|
+
var import_fastify_plugin34 = __toESM(require_plugin2(), 1);
|
|
265844
266731
|
var PROTOCOL_VERSION2 = "2024-11-05";
|
|
265845
266732
|
var TOOLS2 = [
|
|
265846
266733
|
{
|
|
@@ -265853,7 +266740,7 @@ var textResult2 = (text2, isError = false) => ({
|
|
|
265853
266740
|
content: [{ type: "text", text: text2 }],
|
|
265854
266741
|
...isError ? { isError: true } : {}
|
|
265855
266742
|
});
|
|
265856
|
-
var
|
|
266743
|
+
var routes33 = async (fastify2) => {
|
|
265857
266744
|
let cachedSecret;
|
|
265858
266745
|
const getSecret = () => {
|
|
265859
266746
|
if (!cachedSecret) cachedSecret = getSessionToolsSecret(fastify2.storage);
|
|
@@ -265913,10 +266800,10 @@ var routes32 = async (fastify2) => {
|
|
|
265913
266800
|
}
|
|
265914
266801
|
});
|
|
265915
266802
|
};
|
|
265916
|
-
var session_mcp_routes_default = (0,
|
|
266803
|
+
var session_mcp_routes_default = (0, import_fastify_plugin34.default)(routes33, { name: "session-mcp-routes" });
|
|
265917
266804
|
|
|
265918
266805
|
// src/routes/schedule-routes.ts
|
|
265919
|
-
var
|
|
266806
|
+
var import_fastify_plugin35 = __toESM(require_plugin2(), 1);
|
|
265920
266807
|
import { randomUUID as randomUUID29 } from "crypto";
|
|
265921
266808
|
import path20 from "path";
|
|
265922
266809
|
var RUN_TYPES = ["command", "prompt"];
|
|
@@ -265937,7 +266824,7 @@ function validateResolved(b2) {
|
|
|
265937
266824
|
if (cronError) return `Invalid cron expression: ${cronError}`;
|
|
265938
266825
|
return null;
|
|
265939
266826
|
}
|
|
265940
|
-
var
|
|
266827
|
+
var routes34 = async (fastify2) => {
|
|
265941
266828
|
const sendTerminalManualOutcome = (reply, request, replay) => {
|
|
265942
266829
|
if (!request.terminalStatus || request.terminalResponseStatus === null) return null;
|
|
265943
266830
|
const common = { runId: request.runId, status: request.terminalStatus, durable: true, replay };
|
|
@@ -266204,7 +267091,7 @@ var routes33 = async (fastify2) => {
|
|
|
266204
267091
|
}
|
|
266205
267092
|
);
|
|
266206
267093
|
};
|
|
266207
|
-
var schedule_routes_default = (0,
|
|
267094
|
+
var schedule_routes_default = (0, import_fastify_plugin35.default)(routes34, { name: "schedule-routes" });
|
|
266208
267095
|
|
|
266209
267096
|
// src/search/catalog.ts
|
|
266210
267097
|
var parseDbTimestamp5 = (ts) => {
|
|
@@ -266381,10 +267268,10 @@ var searchRoutes = async (fastify2) => {
|
|
|
266381
267268
|
var search_routes_default = searchRoutes;
|
|
266382
267269
|
|
|
266383
267270
|
// src/routes/notification-routes.ts
|
|
266384
|
-
var
|
|
267271
|
+
var import_fastify_plugin36 = __toESM(require_plugin2(), 1);
|
|
266385
267272
|
var MAX_LIMIT = 500;
|
|
266386
267273
|
var DEFAULT_LIMIT = 100;
|
|
266387
|
-
var
|
|
267274
|
+
var routes35 = async (fastify2) => {
|
|
266388
267275
|
fastify2.get(
|
|
266389
267276
|
"/api/notifications",
|
|
266390
267277
|
async (req, reply) => {
|
|
@@ -266416,10 +267303,10 @@ var routes34 = async (fastify2) => {
|
|
|
266416
267303
|
return reply.code(200).send({ ok: true });
|
|
266417
267304
|
});
|
|
266418
267305
|
};
|
|
266419
|
-
var notification_routes_default = (0,
|
|
267306
|
+
var notification_routes_default = (0, import_fastify_plugin36.default)(routes35, { name: "notification-routes" });
|
|
266420
267307
|
|
|
266421
267308
|
// ../../node_modules/.pnpm/@clerk+fastify@3.1.2_fastify@5.7.2_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@clerk/fastify/dist/chunk-RY4T2JMQ.mjs
|
|
266422
|
-
import { Readable as
|
|
267309
|
+
import { Readable as Readable3 } from "stream";
|
|
266423
267310
|
var fastifyRequestToRequest = (req) => {
|
|
266424
267311
|
const headers = new Headers(
|
|
266425
267312
|
Object.keys(req.headers).reduce((acc, key2) => {
|
|
@@ -266460,7 +267347,7 @@ var requestToProxyRequest = (req) => {
|
|
|
266460
267347
|
return new Request(url2.toString(), {
|
|
266461
267348
|
method: req.method,
|
|
266462
267349
|
headers,
|
|
266463
|
-
body: hasBody ?
|
|
267350
|
+
body: hasBody ? Readable3.toWeb(req.raw) : void 0,
|
|
266464
267351
|
// @ts-expect-error - duplex required for streaming bodies but not in all TS definitions
|
|
266465
267352
|
duplex: hasBody ? "half" : void 0
|
|
266466
267353
|
});
|
|
@@ -266468,7 +267355,7 @@ var requestToProxyRequest = (req) => {
|
|
|
266468
267355
|
|
|
266469
267356
|
// ../../node_modules/.pnpm/@clerk+fastify@3.1.2_fastify@5.7.2_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@clerk/fastify/dist/index.mjs
|
|
266470
267357
|
init_dist();
|
|
266471
|
-
var
|
|
267358
|
+
var import_fastify_plugin37 = __toESM(require_plugin2(), 1);
|
|
266472
267359
|
|
|
266473
267360
|
// ../../node_modules/.pnpm/@clerk+backend@3.2.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@clerk/backend/dist/internal.mjs
|
|
266474
267361
|
init_chunk_JW73PKED();
|
|
@@ -266641,7 +267528,7 @@ async function clerkFrontendApiProxy(request, options) {
|
|
|
266641
267528
|
|
|
266642
267529
|
// ../../node_modules/.pnpm/@clerk+fastify@3.1.2_fastify@5.7.2_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@clerk/fastify/dist/index.mjs
|
|
266643
267530
|
init_dist();
|
|
266644
|
-
import { Readable as
|
|
267531
|
+
import { Readable as Readable4 } from "stream";
|
|
266645
267532
|
|
|
266646
267533
|
// ../../node_modules/.pnpm/@clerk+shared@4.3.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@clerk/shared/dist/runtime/apiUrlFromPublishableKey.mjs
|
|
266647
267534
|
init_constants_Bta24VLk();
|
|
@@ -266706,7 +267593,7 @@ var withClerkMiddleware = (options) => {
|
|
|
266706
267593
|
});
|
|
266707
267594
|
if (proxyResponse.body) {
|
|
266708
267595
|
const reader = proxyResponse.body.getReader();
|
|
266709
|
-
const stream = new
|
|
267596
|
+
const stream = new Readable4({
|
|
266710
267597
|
async read() {
|
|
266711
267598
|
try {
|
|
266712
267599
|
const { done, value } = await reader.read();
|
|
@@ -266756,7 +267643,7 @@ var plugin = (instance, opts, done) => {
|
|
|
266756
267643
|
instance.addHook(hookName, withClerkMiddleware(opts));
|
|
266757
267644
|
done();
|
|
266758
267645
|
};
|
|
266759
|
-
var clerkPlugin = (0,
|
|
267646
|
+
var clerkPlugin = (0, import_fastify_plugin37.default)(plugin, {
|
|
266760
267647
|
name: "@clerk/fastify",
|
|
266761
267648
|
fastify: "5.x"
|
|
266762
267649
|
});
|
|
@@ -267020,6 +267907,7 @@ var createServer = async (opts) => {
|
|
|
267020
267907
|
server.register(workflow_run_routes_default);
|
|
267021
267908
|
server.register(settings_routes_default);
|
|
267022
267909
|
server.register(translate_routes_default);
|
|
267910
|
+
server.register(tts_routes_default);
|
|
267023
267911
|
server.register(event_routes_default);
|
|
267024
267912
|
server.register(notification_routes_default);
|
|
267025
267913
|
server.register(notification_outbox_routes_default);
|
|
@@ -269593,7 +270481,7 @@ var connectRoutes = buildRouteMap({
|
|
|
269593
270481
|
defaultCommand: "run",
|
|
269594
270482
|
docs: { brief: "Connect to a Vibedeckx server as an inbound node" }
|
|
269595
270483
|
});
|
|
269596
|
-
var
|
|
270484
|
+
var routes36 = buildRouteMap({
|
|
269597
270485
|
routes: {
|
|
269598
270486
|
start: startCommand,
|
|
269599
270487
|
connect: connectRoutes
|
|
@@ -269603,7 +270491,7 @@ var routes35 = buildRouteMap({
|
|
|
269603
270491
|
brief: "Vibedeckx - AI-powered app generator"
|
|
269604
270492
|
}
|
|
269605
270493
|
});
|
|
269606
|
-
var program = buildApplication(
|
|
270494
|
+
var program = buildApplication(routes36, {
|
|
269607
270495
|
name: "vibedeckx",
|
|
269608
270496
|
versionInfo: {
|
|
269609
270497
|
currentVersion: readPackageVersion()
|