@chosengeneration/light-code 0.187.0 → 0.189.0
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/cli.cjs +1144 -720
- package/dist/server.cjs +1105 -681
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -494,14 +494,14 @@ var require_util = __commonJS({
|
|
|
494
494
|
}
|
|
495
495
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
496
496
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol}//${url2.hostname}:${port}`;
|
|
497
|
-
let
|
|
497
|
+
let path68 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
498
498
|
if (origin.endsWith("/")) {
|
|
499
499
|
origin = origin.substring(0, origin.length - 1);
|
|
500
500
|
}
|
|
501
|
-
if (
|
|
502
|
-
|
|
501
|
+
if (path68 && !path68.startsWith("/")) {
|
|
502
|
+
path68 = `/${path68}`;
|
|
503
503
|
}
|
|
504
|
-
url2 = new URL(origin +
|
|
504
|
+
url2 = new URL(origin + path68);
|
|
505
505
|
}
|
|
506
506
|
return url2;
|
|
507
507
|
}
|
|
@@ -2115,20 +2115,20 @@ var require_parseParams = __commonJS({
|
|
|
2115
2115
|
var require_basename = __commonJS({
|
|
2116
2116
|
"../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/basename.js"(exports2, module2) {
|
|
2117
2117
|
"use strict";
|
|
2118
|
-
module2.exports = function basename(
|
|
2119
|
-
if (typeof
|
|
2118
|
+
module2.exports = function basename(path68) {
|
|
2119
|
+
if (typeof path68 !== "string") {
|
|
2120
2120
|
return "";
|
|
2121
2121
|
}
|
|
2122
|
-
for (var i =
|
|
2123
|
-
switch (
|
|
2122
|
+
for (var i = path68.length - 1; i >= 0; --i) {
|
|
2123
|
+
switch (path68.charCodeAt(i)) {
|
|
2124
2124
|
case 47:
|
|
2125
2125
|
// '/'
|
|
2126
2126
|
case 92:
|
|
2127
|
-
|
|
2128
|
-
return
|
|
2127
|
+
path68 = path68.slice(i + 1);
|
|
2128
|
+
return path68 === ".." || path68 === "." ? "" : path68;
|
|
2129
2129
|
}
|
|
2130
2130
|
}
|
|
2131
|
-
return
|
|
2131
|
+
return path68 === ".." || path68 === "." ? "" : path68;
|
|
2132
2132
|
};
|
|
2133
2133
|
}
|
|
2134
2134
|
});
|
|
@@ -5158,7 +5158,7 @@ var require_request = __commonJS({
|
|
|
5158
5158
|
}
|
|
5159
5159
|
var Request = class _Request {
|
|
5160
5160
|
constructor(origin, {
|
|
5161
|
-
path:
|
|
5161
|
+
path: path68,
|
|
5162
5162
|
method,
|
|
5163
5163
|
body,
|
|
5164
5164
|
headers,
|
|
@@ -5172,11 +5172,11 @@ var require_request = __commonJS({
|
|
|
5172
5172
|
throwOnError,
|
|
5173
5173
|
expectContinue
|
|
5174
5174
|
}, handler) {
|
|
5175
|
-
if (typeof
|
|
5175
|
+
if (typeof path68 !== "string") {
|
|
5176
5176
|
throw new InvalidArgumentError("path must be a string");
|
|
5177
|
-
} else if (
|
|
5177
|
+
} else if (path68[0] !== "/" && !(path68.startsWith("http://") || path68.startsWith("https://")) && method !== "CONNECT") {
|
|
5178
5178
|
throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
|
|
5179
|
-
} else if (invalidPathRegex.exec(
|
|
5179
|
+
} else if (invalidPathRegex.exec(path68) !== null) {
|
|
5180
5180
|
throw new InvalidArgumentError("invalid request path");
|
|
5181
5181
|
}
|
|
5182
5182
|
if (typeof method !== "string") {
|
|
@@ -5239,7 +5239,7 @@ var require_request = __commonJS({
|
|
|
5239
5239
|
this.completed = false;
|
|
5240
5240
|
this.aborted = false;
|
|
5241
5241
|
this.upgrade = upgrade || null;
|
|
5242
|
-
this.path = query ? util.buildURL(
|
|
5242
|
+
this.path = query ? util.buildURL(path68, query) : path68;
|
|
5243
5243
|
this.origin = origin;
|
|
5244
5244
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
5245
5245
|
this.blocking = blocking == null ? false : blocking;
|
|
@@ -6247,9 +6247,9 @@ var require_RedirectHandler = __commonJS({
|
|
|
6247
6247
|
return this.handler.onHeaders(statusCode, headers, resume, statusText);
|
|
6248
6248
|
}
|
|
6249
6249
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
6250
|
-
const
|
|
6250
|
+
const path68 = search ? `${pathname}${search}` : pathname;
|
|
6251
6251
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
6252
|
-
this.opts.path =
|
|
6252
|
+
this.opts.path = path68;
|
|
6253
6253
|
this.opts.origin = origin;
|
|
6254
6254
|
this.opts.maxRedirections = 0;
|
|
6255
6255
|
this.opts.query = null;
|
|
@@ -7489,7 +7489,7 @@ var require_client = __commonJS({
|
|
|
7489
7489
|
writeH2(client, client[kHTTP2Session], request2);
|
|
7490
7490
|
return;
|
|
7491
7491
|
}
|
|
7492
|
-
const { body, method, path:
|
|
7492
|
+
const { body, method, path: path68, host, upgrade, headers, blocking, reset } = request2;
|
|
7493
7493
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
7494
7494
|
if (body && typeof body.read === "function") {
|
|
7495
7495
|
body.read(0);
|
|
@@ -7539,7 +7539,7 @@ var require_client = __commonJS({
|
|
|
7539
7539
|
if (blocking) {
|
|
7540
7540
|
socket[kBlocking] = true;
|
|
7541
7541
|
}
|
|
7542
|
-
let header2 = `${method} ${
|
|
7542
|
+
let header2 = `${method} ${path68} HTTP/1.1\r
|
|
7543
7543
|
`;
|
|
7544
7544
|
if (typeof host === "string") {
|
|
7545
7545
|
header2 += `host: ${host}\r
|
|
@@ -7602,7 +7602,7 @@ upgrade: ${upgrade}\r
|
|
|
7602
7602
|
return true;
|
|
7603
7603
|
}
|
|
7604
7604
|
function writeH2(client, session, request2) {
|
|
7605
|
-
const { body, method, path:
|
|
7605
|
+
const { body, method, path: path68, host, upgrade, expectContinue, signal, headers: reqHeaders } = request2;
|
|
7606
7606
|
let headers;
|
|
7607
7607
|
if (typeof reqHeaders === "string") headers = Request[kHTTP2CopyHeaders](reqHeaders.trim());
|
|
7608
7608
|
else headers = reqHeaders;
|
|
@@ -7645,7 +7645,7 @@ upgrade: ${upgrade}\r
|
|
|
7645
7645
|
});
|
|
7646
7646
|
return true;
|
|
7647
7647
|
}
|
|
7648
|
-
headers[HTTP2_HEADER_PATH] =
|
|
7648
|
+
headers[HTTP2_HEADER_PATH] = path68;
|
|
7649
7649
|
headers[HTTP2_HEADER_SCHEME] = "https";
|
|
7650
7650
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
7651
7651
|
if (body && typeof body.read === "function") {
|
|
@@ -9885,20 +9885,20 @@ var require_mock_utils = __commonJS({
|
|
|
9885
9885
|
}
|
|
9886
9886
|
return true;
|
|
9887
9887
|
}
|
|
9888
|
-
function safeUrl(
|
|
9889
|
-
if (typeof
|
|
9890
|
-
return
|
|
9888
|
+
function safeUrl(path68) {
|
|
9889
|
+
if (typeof path68 !== "string") {
|
|
9890
|
+
return path68;
|
|
9891
9891
|
}
|
|
9892
|
-
const pathSegments =
|
|
9892
|
+
const pathSegments = path68.split("?");
|
|
9893
9893
|
if (pathSegments.length !== 2) {
|
|
9894
|
-
return
|
|
9894
|
+
return path68;
|
|
9895
9895
|
}
|
|
9896
9896
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
9897
9897
|
qp.sort();
|
|
9898
9898
|
return [...pathSegments, qp.toString()].join("?");
|
|
9899
9899
|
}
|
|
9900
|
-
function matchKey(mockDispatch2, { path:
|
|
9901
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
9900
|
+
function matchKey(mockDispatch2, { path: path68, method, body, headers }) {
|
|
9901
|
+
const pathMatch = matchValue(mockDispatch2.path, path68);
|
|
9902
9902
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
9903
9903
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
9904
9904
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -9916,7 +9916,7 @@ var require_mock_utils = __commonJS({
|
|
|
9916
9916
|
function getMockDispatch(mockDispatches, key3) {
|
|
9917
9917
|
const basePath = key3.query ? buildURL(key3.path, key3.query) : key3.path;
|
|
9918
9918
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
9919
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
9919
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path68 }) => matchValue(safeUrl(path68), resolvedPath));
|
|
9920
9920
|
if (matchedMockDispatches.length === 0) {
|
|
9921
9921
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
9922
9922
|
}
|
|
@@ -9953,9 +9953,9 @@ var require_mock_utils = __commonJS({
|
|
|
9953
9953
|
}
|
|
9954
9954
|
}
|
|
9955
9955
|
function buildKey(opts) {
|
|
9956
|
-
const { path:
|
|
9956
|
+
const { path: path68, method, body, headers, query } = opts;
|
|
9957
9957
|
return {
|
|
9958
|
-
path:
|
|
9958
|
+
path: path68,
|
|
9959
9959
|
method,
|
|
9960
9960
|
body,
|
|
9961
9961
|
headers,
|
|
@@ -10404,10 +10404,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
10404
10404
|
}
|
|
10405
10405
|
format(pendingInterceptors) {
|
|
10406
10406
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
10407
|
-
({ method, path:
|
|
10407
|
+
({ method, path: path68, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
10408
10408
|
Method: method,
|
|
10409
10409
|
Origin: origin,
|
|
10410
|
-
Path:
|
|
10410
|
+
Path: path68,
|
|
10411
10411
|
"Status code": statusCode,
|
|
10412
10412
|
Persistent: persist ? "\u2705" : "\u274C",
|
|
10413
10413
|
Invocations: timesInvoked,
|
|
@@ -15027,8 +15027,8 @@ var require_util6 = __commonJS({
|
|
|
15027
15027
|
}
|
|
15028
15028
|
}
|
|
15029
15029
|
}
|
|
15030
|
-
function validateCookiePath(
|
|
15031
|
-
for (const char of
|
|
15030
|
+
function validateCookiePath(path68) {
|
|
15031
|
+
for (const char of path68) {
|
|
15032
15032
|
const code = char.charCodeAt(0);
|
|
15033
15033
|
if (code < 33 || char === ";") {
|
|
15034
15034
|
throw new Error("Invalid cookie path");
|
|
@@ -16708,11 +16708,11 @@ var require_undici = __commonJS({
|
|
|
16708
16708
|
if (typeof opts.path !== "string") {
|
|
16709
16709
|
throw new InvalidArgumentError("invalid opts.path");
|
|
16710
16710
|
}
|
|
16711
|
-
let
|
|
16711
|
+
let path68 = opts.path;
|
|
16712
16712
|
if (!opts.path.startsWith("/")) {
|
|
16713
|
-
|
|
16713
|
+
path68 = `/${path68}`;
|
|
16714
16714
|
}
|
|
16715
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
16715
|
+
url2 = new URL(util.parseOrigin(url2).origin + path68);
|
|
16716
16716
|
} else {
|
|
16717
16717
|
if (!opts) {
|
|
16718
16718
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -19983,8 +19983,8 @@ var require_utils2 = __commonJS({
|
|
|
19983
19983
|
}
|
|
19984
19984
|
return ind;
|
|
19985
19985
|
}
|
|
19986
|
-
function removeDotSegments(
|
|
19987
|
-
let input =
|
|
19986
|
+
function removeDotSegments(path68) {
|
|
19987
|
+
let input = path68;
|
|
19988
19988
|
const output = [];
|
|
19989
19989
|
let nextSlash = -1;
|
|
19990
19990
|
let len = 0;
|
|
@@ -20236,8 +20236,8 @@ var require_schemes = __commonJS({
|
|
|
20236
20236
|
wsComponent.secure = void 0;
|
|
20237
20237
|
}
|
|
20238
20238
|
if (wsComponent.resourceName) {
|
|
20239
|
-
const [
|
|
20240
|
-
wsComponent.path =
|
|
20239
|
+
const [path68, query] = wsComponent.resourceName.split("?");
|
|
20240
|
+
wsComponent.path = path68 && path68 !== "/" ? path68 : void 0;
|
|
20241
20241
|
wsComponent.query = query;
|
|
20242
20242
|
wsComponent.resourceName = void 0;
|
|
20243
20243
|
}
|
|
@@ -20392,21 +20392,21 @@ var require_fast_uri = __commonJS({
|
|
|
20392
20392
|
normalizeString(uri, options);
|
|
20393
20393
|
} else if (typeof uri === "object") {
|
|
20394
20394
|
uri = /** @type {T} */
|
|
20395
|
-
|
|
20395
|
+
parse4(serialize(uri, options), options);
|
|
20396
20396
|
}
|
|
20397
20397
|
return uri;
|
|
20398
20398
|
}
|
|
20399
20399
|
function resolve(baseURI, relativeURI, options) {
|
|
20400
20400
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
20401
|
-
const resolved = resolveComponent(
|
|
20401
|
+
const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
20402
20402
|
schemelessOptions.skipEscape = true;
|
|
20403
20403
|
return serialize(resolved, schemelessOptions);
|
|
20404
20404
|
}
|
|
20405
20405
|
function resolveComponent(base, relative, options, skipNormalization) {
|
|
20406
20406
|
const target = {};
|
|
20407
20407
|
if (!skipNormalization) {
|
|
20408
|
-
base =
|
|
20409
|
-
relative =
|
|
20408
|
+
base = parse4(serialize(base, options), options);
|
|
20409
|
+
relative = parse4(serialize(relative, options), options);
|
|
20410
20410
|
}
|
|
20411
20411
|
options = options || {};
|
|
20412
20412
|
if (!options.tolerant && relative.scheme) {
|
|
@@ -20635,7 +20635,7 @@ var require_fast_uri = __commonJS({
|
|
|
20635
20635
|
}
|
|
20636
20636
|
return { parsed, malformedAuthorityOrPort };
|
|
20637
20637
|
}
|
|
20638
|
-
function
|
|
20638
|
+
function parse4(uri, opts) {
|
|
20639
20639
|
return parseWithStatus(uri, opts).parsed;
|
|
20640
20640
|
}
|
|
20641
20641
|
function normalizeString(uri, opts) {
|
|
@@ -20664,7 +20664,7 @@ var require_fast_uri = __commonJS({
|
|
|
20664
20664
|
resolveComponent,
|
|
20665
20665
|
equal,
|
|
20666
20666
|
serialize,
|
|
20667
|
-
parse:
|
|
20667
|
+
parse: parse4
|
|
20668
20668
|
};
|
|
20669
20669
|
module2.exports = fastUri;
|
|
20670
20670
|
module2.exports.default = fastUri;
|
|
@@ -23636,12 +23636,12 @@ var require_dist = __commonJS({
|
|
|
23636
23636
|
throw new Error(`Unknown format "${name}"`);
|
|
23637
23637
|
return f;
|
|
23638
23638
|
};
|
|
23639
|
-
function addFormats(ajv, list2,
|
|
23639
|
+
function addFormats(ajv, list2, fs48, exportName) {
|
|
23640
23640
|
var _a3;
|
|
23641
23641
|
var _b;
|
|
23642
23642
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
23643
23643
|
for (const f of list2)
|
|
23644
|
-
ajv.addFormat(f,
|
|
23644
|
+
ajv.addFormat(f, fs48[f]);
|
|
23645
23645
|
}
|
|
23646
23646
|
module2.exports = exports2 = formatsPlugin;
|
|
23647
23647
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -23654,8 +23654,8 @@ var require_windows = __commonJS({
|
|
|
23654
23654
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports2, module2) {
|
|
23655
23655
|
module2.exports = isexe;
|
|
23656
23656
|
isexe.sync = sync;
|
|
23657
|
-
var
|
|
23658
|
-
function checkPathExt(
|
|
23657
|
+
var fs48 = require("fs");
|
|
23658
|
+
function checkPathExt(path68, options) {
|
|
23659
23659
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
23660
23660
|
if (!pathext) {
|
|
23661
23661
|
return true;
|
|
@@ -23666,25 +23666,25 @@ var require_windows = __commonJS({
|
|
|
23666
23666
|
}
|
|
23667
23667
|
for (var i = 0; i < pathext.length; i++) {
|
|
23668
23668
|
var p = pathext[i].toLowerCase();
|
|
23669
|
-
if (p &&
|
|
23669
|
+
if (p && path68.substr(-p.length).toLowerCase() === p) {
|
|
23670
23670
|
return true;
|
|
23671
23671
|
}
|
|
23672
23672
|
}
|
|
23673
23673
|
return false;
|
|
23674
23674
|
}
|
|
23675
|
-
function checkStat(stat,
|
|
23675
|
+
function checkStat(stat, path68, options) {
|
|
23676
23676
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
23677
23677
|
return false;
|
|
23678
23678
|
}
|
|
23679
|
-
return checkPathExt(
|
|
23679
|
+
return checkPathExt(path68, options);
|
|
23680
23680
|
}
|
|
23681
|
-
function isexe(
|
|
23682
|
-
|
|
23683
|
-
cb(er, er ? false : checkStat(stat,
|
|
23681
|
+
function isexe(path68, options, cb) {
|
|
23682
|
+
fs48.stat(path68, function(er, stat) {
|
|
23683
|
+
cb(er, er ? false : checkStat(stat, path68, options));
|
|
23684
23684
|
});
|
|
23685
23685
|
}
|
|
23686
|
-
function sync(
|
|
23687
|
-
return checkStat(
|
|
23686
|
+
function sync(path68, options) {
|
|
23687
|
+
return checkStat(fs48.statSync(path68), path68, options);
|
|
23688
23688
|
}
|
|
23689
23689
|
}
|
|
23690
23690
|
});
|
|
@@ -23694,14 +23694,14 @@ var require_mode = __commonJS({
|
|
|
23694
23694
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports2, module2) {
|
|
23695
23695
|
module2.exports = isexe;
|
|
23696
23696
|
isexe.sync = sync;
|
|
23697
|
-
var
|
|
23698
|
-
function isexe(
|
|
23699
|
-
|
|
23697
|
+
var fs48 = require("fs");
|
|
23698
|
+
function isexe(path68, options, cb) {
|
|
23699
|
+
fs48.stat(path68, function(er, stat) {
|
|
23700
23700
|
cb(er, er ? false : checkStat(stat, options));
|
|
23701
23701
|
});
|
|
23702
23702
|
}
|
|
23703
|
-
function sync(
|
|
23704
|
-
return checkStat(
|
|
23703
|
+
function sync(path68, options) {
|
|
23704
|
+
return checkStat(fs48.statSync(path68), options);
|
|
23705
23705
|
}
|
|
23706
23706
|
function checkStat(stat, options) {
|
|
23707
23707
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -23725,7 +23725,7 @@ var require_mode = __commonJS({
|
|
|
23725
23725
|
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
23726
23726
|
var require_isexe = __commonJS({
|
|
23727
23727
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports2, module2) {
|
|
23728
|
-
var
|
|
23728
|
+
var fs48 = require("fs");
|
|
23729
23729
|
var core;
|
|
23730
23730
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
23731
23731
|
core = require_windows();
|
|
@@ -23734,7 +23734,7 @@ var require_isexe = __commonJS({
|
|
|
23734
23734
|
}
|
|
23735
23735
|
module2.exports = isexe;
|
|
23736
23736
|
isexe.sync = sync;
|
|
23737
|
-
function isexe(
|
|
23737
|
+
function isexe(path68, options, cb) {
|
|
23738
23738
|
if (typeof options === "function") {
|
|
23739
23739
|
cb = options;
|
|
23740
23740
|
options = {};
|
|
@@ -23744,7 +23744,7 @@ var require_isexe = __commonJS({
|
|
|
23744
23744
|
throw new TypeError("callback not provided");
|
|
23745
23745
|
}
|
|
23746
23746
|
return new Promise(function(resolve, reject2) {
|
|
23747
|
-
isexe(
|
|
23747
|
+
isexe(path68, options || {}, function(er, is) {
|
|
23748
23748
|
if (er) {
|
|
23749
23749
|
reject2(er);
|
|
23750
23750
|
} else {
|
|
@@ -23753,7 +23753,7 @@ var require_isexe = __commonJS({
|
|
|
23753
23753
|
});
|
|
23754
23754
|
});
|
|
23755
23755
|
}
|
|
23756
|
-
core(
|
|
23756
|
+
core(path68, options || {}, function(er, is) {
|
|
23757
23757
|
if (er) {
|
|
23758
23758
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
23759
23759
|
er = null;
|
|
@@ -23763,9 +23763,9 @@ var require_isexe = __commonJS({
|
|
|
23763
23763
|
cb(er, is);
|
|
23764
23764
|
});
|
|
23765
23765
|
}
|
|
23766
|
-
function sync(
|
|
23766
|
+
function sync(path68, options) {
|
|
23767
23767
|
try {
|
|
23768
|
-
return core.sync(
|
|
23768
|
+
return core.sync(path68, options || {});
|
|
23769
23769
|
} catch (er) {
|
|
23770
23770
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
23771
23771
|
return false;
|
|
@@ -23781,7 +23781,7 @@ var require_isexe = __commonJS({
|
|
|
23781
23781
|
var require_which = __commonJS({
|
|
23782
23782
|
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports2, module2) {
|
|
23783
23783
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
23784
|
-
var
|
|
23784
|
+
var path68 = require("path");
|
|
23785
23785
|
var COLON = isWindows ? ";" : ":";
|
|
23786
23786
|
var isexe = require_isexe();
|
|
23787
23787
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -23819,7 +23819,7 @@ var require_which = __commonJS({
|
|
|
23819
23819
|
return opt.all && found2.length ? resolve(found2) : reject2(getNotFoundError(cmd));
|
|
23820
23820
|
const ppRaw = pathEnv[i];
|
|
23821
23821
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
23822
|
-
const pCmd =
|
|
23822
|
+
const pCmd = path68.join(pathPart, cmd);
|
|
23823
23823
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
23824
23824
|
resolve(subStep(p, i, 0));
|
|
23825
23825
|
});
|
|
@@ -23846,7 +23846,7 @@ var require_which = __commonJS({
|
|
|
23846
23846
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
23847
23847
|
const ppRaw = pathEnv[i];
|
|
23848
23848
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
23849
|
-
const pCmd =
|
|
23849
|
+
const pCmd = path68.join(pathPart, cmd);
|
|
23850
23850
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
23851
23851
|
for (let j = 0; j < pathExt.length; j++) {
|
|
23852
23852
|
const cur = p + pathExt[j];
|
|
@@ -23894,7 +23894,7 @@ var require_path_key = __commonJS({
|
|
|
23894
23894
|
var require_resolveCommand = __commonJS({
|
|
23895
23895
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
|
|
23896
23896
|
"use strict";
|
|
23897
|
-
var
|
|
23897
|
+
var path68 = require("path");
|
|
23898
23898
|
var which = require_which();
|
|
23899
23899
|
var getPathKey = require_path_key();
|
|
23900
23900
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -23912,7 +23912,7 @@ var require_resolveCommand = __commonJS({
|
|
|
23912
23912
|
try {
|
|
23913
23913
|
resolved = which.sync(parsed.command, {
|
|
23914
23914
|
path: env2[getPathKey({ env: env2 })],
|
|
23915
|
-
pathExt: withoutPathExt ?
|
|
23915
|
+
pathExt: withoutPathExt ? path68.delimiter : void 0
|
|
23916
23916
|
});
|
|
23917
23917
|
} catch (e) {
|
|
23918
23918
|
} finally {
|
|
@@ -23921,7 +23921,7 @@ var require_resolveCommand = __commonJS({
|
|
|
23921
23921
|
}
|
|
23922
23922
|
}
|
|
23923
23923
|
if (resolved) {
|
|
23924
|
-
resolved =
|
|
23924
|
+
resolved = path68.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
23925
23925
|
}
|
|
23926
23926
|
return resolved;
|
|
23927
23927
|
}
|
|
@@ -23975,8 +23975,8 @@ var require_shebang_command = __commonJS({
|
|
|
23975
23975
|
if (!match) {
|
|
23976
23976
|
return null;
|
|
23977
23977
|
}
|
|
23978
|
-
const [
|
|
23979
|
-
const binary =
|
|
23978
|
+
const [path68, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
23979
|
+
const binary = path68.split("/").pop();
|
|
23980
23980
|
if (binary === "env") {
|
|
23981
23981
|
return argument;
|
|
23982
23982
|
}
|
|
@@ -23989,16 +23989,16 @@ var require_shebang_command = __commonJS({
|
|
|
23989
23989
|
var require_readShebang = __commonJS({
|
|
23990
23990
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
|
|
23991
23991
|
"use strict";
|
|
23992
|
-
var
|
|
23992
|
+
var fs48 = require("fs");
|
|
23993
23993
|
var shebangCommand = require_shebang_command();
|
|
23994
23994
|
function readShebang(command) {
|
|
23995
23995
|
const size = 150;
|
|
23996
23996
|
const buffer = Buffer.alloc(size);
|
|
23997
23997
|
let fd;
|
|
23998
23998
|
try {
|
|
23999
|
-
fd =
|
|
24000
|
-
|
|
24001
|
-
|
|
23999
|
+
fd = fs48.openSync(command, "r");
|
|
24000
|
+
fs48.readSync(fd, buffer, 0, size, 0);
|
|
24001
|
+
fs48.closeSync(fd);
|
|
24002
24002
|
} catch (e) {
|
|
24003
24003
|
}
|
|
24004
24004
|
return shebangCommand(buffer.toString());
|
|
@@ -24011,7 +24011,7 @@ var require_readShebang = __commonJS({
|
|
|
24011
24011
|
var require_parse2 = __commonJS({
|
|
24012
24012
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
|
|
24013
24013
|
"use strict";
|
|
24014
|
-
var
|
|
24014
|
+
var path68 = require("path");
|
|
24015
24015
|
var resolveCommand = require_resolveCommand();
|
|
24016
24016
|
var escape4 = require_escape();
|
|
24017
24017
|
var readShebang = require_readShebang();
|
|
@@ -24036,7 +24036,7 @@ var require_parse2 = __commonJS({
|
|
|
24036
24036
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
24037
24037
|
if (parsed.options.forceShell || needsShell) {
|
|
24038
24038
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
24039
|
-
parsed.command =
|
|
24039
|
+
parsed.command = path68.normalize(parsed.command);
|
|
24040
24040
|
parsed.command = escape4.command(parsed.command);
|
|
24041
24041
|
parsed.args = parsed.args.map((arg) => escape4.argument(arg, needsDoubleEscapeMetaChars));
|
|
24042
24042
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -24046,7 +24046,7 @@ var require_parse2 = __commonJS({
|
|
|
24046
24046
|
}
|
|
24047
24047
|
return parsed;
|
|
24048
24048
|
}
|
|
24049
|
-
function
|
|
24049
|
+
function parse4(command, args, options) {
|
|
24050
24050
|
if (args && !Array.isArray(args)) {
|
|
24051
24051
|
options = args;
|
|
24052
24052
|
args = null;
|
|
@@ -24065,7 +24065,7 @@ var require_parse2 = __commonJS({
|
|
|
24065
24065
|
};
|
|
24066
24066
|
return options.shell ? parsed : parseNonShell(parsed);
|
|
24067
24067
|
}
|
|
24068
|
-
module2.exports =
|
|
24068
|
+
module2.exports = parse4;
|
|
24069
24069
|
}
|
|
24070
24070
|
});
|
|
24071
24071
|
|
|
@@ -24124,16 +24124,16 @@ var require_cross_spawn = __commonJS({
|
|
|
24124
24124
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports2, module2) {
|
|
24125
24125
|
"use strict";
|
|
24126
24126
|
var cp = require("child_process");
|
|
24127
|
-
var
|
|
24127
|
+
var parse4 = require_parse2();
|
|
24128
24128
|
var enoent = require_enoent();
|
|
24129
24129
|
function spawn16(command, args, options) {
|
|
24130
|
-
const parsed =
|
|
24130
|
+
const parsed = parse4(command, args, options);
|
|
24131
24131
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
24132
24132
|
enoent.hookChildProcess(spawned, parsed);
|
|
24133
24133
|
return spawned;
|
|
24134
24134
|
}
|
|
24135
24135
|
function spawnSync(command, args, options) {
|
|
24136
|
-
const parsed =
|
|
24136
|
+
const parsed = parse4(command, args, options);
|
|
24137
24137
|
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
24138
24138
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
24139
24139
|
return result;
|
|
@@ -24141,7 +24141,7 @@ var require_cross_spawn = __commonJS({
|
|
|
24141
24141
|
module2.exports = spawn16;
|
|
24142
24142
|
module2.exports.spawn = spawn16;
|
|
24143
24143
|
module2.exports.sync = spawnSync;
|
|
24144
|
-
module2.exports._parse =
|
|
24144
|
+
module2.exports._parse = parse4;
|
|
24145
24145
|
module2.exports._enoent = enoent;
|
|
24146
24146
|
}
|
|
24147
24147
|
});
|
|
@@ -24157,7 +24157,7 @@ var require_content_type = __commonJS({
|
|
|
24157
24157
|
var QUOTE_REGEXP = /([\\"])/g;
|
|
24158
24158
|
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
24159
24159
|
exports2.format = format;
|
|
24160
|
-
exports2.parse =
|
|
24160
|
+
exports2.parse = parse4;
|
|
24161
24161
|
function format(obj) {
|
|
24162
24162
|
if (!obj || typeof obj !== "object") {
|
|
24163
24163
|
throw new TypeError("argument obj is required");
|
|
@@ -24181,7 +24181,7 @@ var require_content_type = __commonJS({
|
|
|
24181
24181
|
}
|
|
24182
24182
|
return string4;
|
|
24183
24183
|
}
|
|
24184
|
-
function
|
|
24184
|
+
function parse4(string4) {
|
|
24185
24185
|
if (!string4) {
|
|
24186
24186
|
throw new TypeError("argument string is required");
|
|
24187
24187
|
}
|
|
@@ -24258,9 +24258,9 @@ __export(server_exports, {
|
|
|
24258
24258
|
});
|
|
24259
24259
|
module.exports = __toCommonJS(server_exports);
|
|
24260
24260
|
var import_promises38 = __toESM(require("node:fs/promises"), 1);
|
|
24261
|
-
var
|
|
24261
|
+
var import_node_fs19 = require("node:fs");
|
|
24262
24262
|
var import_node_http = require("node:http");
|
|
24263
|
-
var
|
|
24263
|
+
var import_node_path68 = __toESM(require("node:path"), 1);
|
|
24264
24264
|
|
|
24265
24265
|
// ../../packages/core/dist/platform/http.js
|
|
24266
24266
|
var import_node_crypto = require("node:crypto");
|
|
@@ -25428,10 +25428,10 @@ function mergeDefs(...defs) {
|
|
|
25428
25428
|
function cloneDef(schema12) {
|
|
25429
25429
|
return mergeDefs(schema12._zod.def);
|
|
25430
25430
|
}
|
|
25431
|
-
function getElementAtPath(obj,
|
|
25432
|
-
if (!
|
|
25431
|
+
function getElementAtPath(obj, path68) {
|
|
25432
|
+
if (!path68)
|
|
25433
25433
|
return obj;
|
|
25434
|
-
return
|
|
25434
|
+
return path68.reduce((acc, key3) => acc?.[key3], obj);
|
|
25435
25435
|
}
|
|
25436
25436
|
function promiseAllObject(promisesObj) {
|
|
25437
25437
|
const keys = Object.keys(promisesObj);
|
|
@@ -25840,11 +25840,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
25840
25840
|
}
|
|
25841
25841
|
return false;
|
|
25842
25842
|
}
|
|
25843
|
-
function prefixIssues(
|
|
25843
|
+
function prefixIssues(path68, issues) {
|
|
25844
25844
|
return issues.map((iss) => {
|
|
25845
25845
|
var _a3;
|
|
25846
25846
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
25847
|
-
iss.path.unshift(
|
|
25847
|
+
iss.path.unshift(path68);
|
|
25848
25848
|
return iss;
|
|
25849
25849
|
});
|
|
25850
25850
|
}
|
|
@@ -25991,16 +25991,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
25991
25991
|
}
|
|
25992
25992
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
25993
25993
|
const fieldErrors = { _errors: [] };
|
|
25994
|
-
const processError = (error52,
|
|
25994
|
+
const processError = (error52, path68 = []) => {
|
|
25995
25995
|
for (const issue2 of error52.issues) {
|
|
25996
25996
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
25997
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
25997
|
+
issue2.errors.map((issues) => processError({ issues }, [...path68, ...issue2.path]));
|
|
25998
25998
|
} else if (issue2.code === "invalid_key") {
|
|
25999
|
-
processError({ issues: issue2.issues }, [...
|
|
25999
|
+
processError({ issues: issue2.issues }, [...path68, ...issue2.path]);
|
|
26000
26000
|
} else if (issue2.code === "invalid_element") {
|
|
26001
|
-
processError({ issues: issue2.issues }, [...
|
|
26001
|
+
processError({ issues: issue2.issues }, [...path68, ...issue2.path]);
|
|
26002
26002
|
} else {
|
|
26003
|
-
const fullpath = [...
|
|
26003
|
+
const fullpath = [...path68, ...issue2.path];
|
|
26004
26004
|
if (fullpath.length === 0) {
|
|
26005
26005
|
fieldErrors._errors.push(mapper(issue2));
|
|
26006
26006
|
} else {
|
|
@@ -26027,17 +26027,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26027
26027
|
}
|
|
26028
26028
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
26029
26029
|
const result = { errors: [] };
|
|
26030
|
-
const processError = (error52,
|
|
26030
|
+
const processError = (error52, path68 = []) => {
|
|
26031
26031
|
var _a3, _b;
|
|
26032
26032
|
for (const issue2 of error52.issues) {
|
|
26033
26033
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
26034
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
26034
|
+
issue2.errors.map((issues) => processError({ issues }, [...path68, ...issue2.path]));
|
|
26035
26035
|
} else if (issue2.code === "invalid_key") {
|
|
26036
|
-
processError({ issues: issue2.issues }, [...
|
|
26036
|
+
processError({ issues: issue2.issues }, [...path68, ...issue2.path]);
|
|
26037
26037
|
} else if (issue2.code === "invalid_element") {
|
|
26038
|
-
processError({ issues: issue2.issues }, [...
|
|
26038
|
+
processError({ issues: issue2.issues }, [...path68, ...issue2.path]);
|
|
26039
26039
|
} else {
|
|
26040
|
-
const fullpath = [...
|
|
26040
|
+
const fullpath = [...path68, ...issue2.path];
|
|
26041
26041
|
if (fullpath.length === 0) {
|
|
26042
26042
|
result.errors.push(mapper(issue2));
|
|
26043
26043
|
continue;
|
|
@@ -26069,8 +26069,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26069
26069
|
}
|
|
26070
26070
|
function toDotPath(_path) {
|
|
26071
26071
|
const segs = [];
|
|
26072
|
-
const
|
|
26073
|
-
for (const seg of
|
|
26072
|
+
const path68 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
26073
|
+
for (const seg of path68) {
|
|
26074
26074
|
if (typeof seg === "number")
|
|
26075
26075
|
segs.push(`[${seg}]`);
|
|
26076
26076
|
else if (typeof seg === "symbol")
|
|
@@ -38762,13 +38762,13 @@ function resolveRef(ref, ctx) {
|
|
|
38762
38762
|
if (!ref.startsWith("#")) {
|
|
38763
38763
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
38764
38764
|
}
|
|
38765
|
-
const
|
|
38766
|
-
if (
|
|
38765
|
+
const path68 = ref.slice(1).split("/").filter(Boolean);
|
|
38766
|
+
if (path68.length === 0) {
|
|
38767
38767
|
return ctx.rootSchema;
|
|
38768
38768
|
}
|
|
38769
38769
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
38770
|
-
if (
|
|
38771
|
-
const key3 =
|
|
38770
|
+
if (path68[0] === defsKey) {
|
|
38771
|
+
const key3 = path68[1];
|
|
38772
38772
|
if (!key3 || !ctx.defs[key3]) {
|
|
38773
38773
|
throw new Error(`Reference not found: ${ref}`);
|
|
38774
38774
|
}
|
|
@@ -39365,6 +39365,7 @@ var strategyNodeSchema = external_exports.object({
|
|
|
39365
39365
|
var strategyGroupSchema = external_exports.object({
|
|
39366
39366
|
id: external_exports.string().min(1).max(40),
|
|
39367
39367
|
label: external_exports.string().max(80).optional(),
|
|
39368
|
+
kind: external_exports.enum(["parallel", "together"]).optional(),
|
|
39368
39369
|
x: external_exports.number().finite(),
|
|
39369
39370
|
y: external_exports.number().finite(),
|
|
39370
39371
|
w: external_exports.number().finite().min(60),
|
|
@@ -39372,7 +39373,9 @@ var strategyGroupSchema = external_exports.object({
|
|
|
39372
39373
|
});
|
|
39373
39374
|
var strategyEdgeSchema = external_exports.object({
|
|
39374
39375
|
id: external_exports.string().min(1).max(40),
|
|
39376
|
+
/** A step's id, or a box's (`StrategyGroup.id`): from a box means "once every step inside has answered". */
|
|
39375
39377
|
from: external_exports.string().min(1).max(40),
|
|
39378
|
+
/** A step's id, or a box's: to a box means every step inside starts from what arrives. */
|
|
39376
39379
|
to: external_exports.string().min(1).max(40),
|
|
39377
39380
|
/** Back and forth between the two: `from` works, `to` checks, and back to `from` until `until` or `maxRounds`. */
|
|
39378
39381
|
twoWay: external_exports.boolean().optional(),
|
|
@@ -39407,6 +39410,21 @@ var DEFAULT_LOOP_ROUNDS = 10;
|
|
|
39407
39410
|
function roundsOf(edge) {
|
|
39408
39411
|
return edge.maxRounds ?? DEFAULT_LOOP_ROUNDS;
|
|
39409
39412
|
}
|
|
39413
|
+
function groupKind(group) {
|
|
39414
|
+
return group.kind ?? "parallel";
|
|
39415
|
+
}
|
|
39416
|
+
function groupName(group) {
|
|
39417
|
+
return group.label?.trim() || (groupKind(group) === "parallel" ? "Parallel box" : "Box");
|
|
39418
|
+
}
|
|
39419
|
+
function groupMembers(strategy, groupId) {
|
|
39420
|
+
return strategy.nodes.filter((node) => node.group === groupId);
|
|
39421
|
+
}
|
|
39422
|
+
function endpointNodes(strategy, id) {
|
|
39423
|
+
const node = strategy.nodes.find((n) => n.id === id);
|
|
39424
|
+
if (node !== void 0)
|
|
39425
|
+
return [node];
|
|
39426
|
+
return (strategy.groups ?? []).some((group) => group.id === id) ? groupMembers(strategy, id) : [];
|
|
39427
|
+
}
|
|
39410
39428
|
function strategyProblems(strategy, knownRoles2, assigned) {
|
|
39411
39429
|
const problems = [];
|
|
39412
39430
|
if (strategy.nodes.length === 0)
|
|
@@ -39421,12 +39439,21 @@ function strategyProblems(strategy, knownRoles2, assigned) {
|
|
|
39421
39439
|
else if (!assigned.has(node.role))
|
|
39422
39440
|
problems.push(`Nobody is assigned to ${node.role}: give it a model in Settings \u2192 Agents.`);
|
|
39423
39441
|
}
|
|
39442
|
+
const groups = new Map((strategy.groups ?? []).map((group) => [group.id, group]));
|
|
39424
39443
|
const pairs = /* @__PURE__ */ new Set();
|
|
39425
39444
|
for (const edge of strategy.edges) {
|
|
39426
|
-
if (!ids.has(edge.from) || !ids.has(edge.to))
|
|
39445
|
+
if (!ids.has(edge.from) && !groups.has(edge.from) || !ids.has(edge.to) && !groups.has(edge.to))
|
|
39427
39446
|
problems.push("A connector points at a step that is not there.");
|
|
39428
39447
|
if (edge.from === edge.to)
|
|
39429
39448
|
problems.push("A connector goes from a step to itself.");
|
|
39449
|
+
if (edge.twoWay === true && (groups.has(edge.from) || groups.has(edge.to))) {
|
|
39450
|
+
problems.push("A back-and-forth joins two steps, not a box: connect it to one step inside the box.");
|
|
39451
|
+
}
|
|
39452
|
+
const fromNode = strategy.nodes.find((n) => n.id === edge.from);
|
|
39453
|
+
const toNode = strategy.nodes.find((n) => n.id === edge.to);
|
|
39454
|
+
if (groups.has(edge.to) && fromNode?.group === edge.to || groups.has(edge.from) && toNode?.group === edge.from) {
|
|
39455
|
+
problems.push("A connector joins a box to a step inside it; connect the steps inside to each other instead.");
|
|
39456
|
+
}
|
|
39430
39457
|
const pair = [edge.from, edge.to].sort().join("|");
|
|
39431
39458
|
if (edge.twoWay === true && pairs.has(pair))
|
|
39432
39459
|
problems.push("Two back-and-forth connectors join the same two steps.");
|
|
@@ -39434,34 +39461,74 @@ function strategyProblems(strategy, knownRoles2, assigned) {
|
|
|
39434
39461
|
pairs.add(pair);
|
|
39435
39462
|
}
|
|
39436
39463
|
for (const group of strategy.groups ?? []) {
|
|
39437
|
-
const inside = strategy
|
|
39464
|
+
const inside = groupMembers(strategy, group.id);
|
|
39465
|
+
if (inside.length === 0 && strategy.edges.some((edge) => edge.from === group.id || edge.to === group.id)) {
|
|
39466
|
+
problems.push(`${groupName(group)} is connected but has no steps inside.`);
|
|
39467
|
+
}
|
|
39468
|
+
if (groupKind(group) !== "parallel")
|
|
39469
|
+
continue;
|
|
39438
39470
|
const roles = inside.map((node) => node.role);
|
|
39439
39471
|
if (new Set(roles).size !== roles.length)
|
|
39440
|
-
problems.push(`${group
|
|
39472
|
+
problems.push(`${groupName(group)} holds one role twice; one specialist answers one question at a time, so they would not run in parallel.`);
|
|
39441
39473
|
}
|
|
39442
39474
|
return [...new Set(problems)];
|
|
39443
39475
|
}
|
|
39444
39476
|
function strategyOrder(strategy) {
|
|
39445
|
-
const
|
|
39446
|
-
const
|
|
39447
|
-
|
|
39448
|
-
|
|
39477
|
+
const groups = new Set((strategy.groups ?? []).map((group) => group.id));
|
|
39478
|
+
const unitOf = (id) => {
|
|
39479
|
+
if (groups.has(id))
|
|
39480
|
+
return id;
|
|
39481
|
+
const node = strategy.nodes.find((n) => n.id === id);
|
|
39482
|
+
return node?.group !== void 0 && groups.has(node.group) ? node.group : id;
|
|
39483
|
+
};
|
|
39484
|
+
const position = (unit) => {
|
|
39485
|
+
const group = strategy.groups?.find((g) => g.id === unit);
|
|
39486
|
+
if (group !== void 0)
|
|
39487
|
+
return group;
|
|
39488
|
+
return strategy.nodes.find((n) => n.id === unit) ?? { x: 0, y: 0 };
|
|
39489
|
+
};
|
|
39490
|
+
const canvasUnits = (a, b) => position(a).x - position(b).x || position(a).y - position(b).y;
|
|
39491
|
+
const units = [...new Set(strategy.nodes.map((node) => unitOf(node.id)))];
|
|
39492
|
+
const between = strategy.edges.map((edge) => ({ from: unitOf(edge.from), to: unitOf(edge.to) })).filter((edge) => edge.from !== edge.to);
|
|
39493
|
+
const order2 = orderBy(units, between, canvasUnits);
|
|
39449
39494
|
const canvas = (a, b) => a.x - b.x || a.y - b.y;
|
|
39450
|
-
const
|
|
39495
|
+
const out = [];
|
|
39496
|
+
for (const unit of order2) {
|
|
39497
|
+
if (!groups.has(unit)) {
|
|
39498
|
+
const node = strategy.nodes.find((n) => n.id === unit);
|
|
39499
|
+
if (node !== void 0)
|
|
39500
|
+
out.push(node);
|
|
39501
|
+
continue;
|
|
39502
|
+
}
|
|
39503
|
+
const inside = groupMembers(strategy, unit);
|
|
39504
|
+
const ids = new Set(inside.map((node) => node.id));
|
|
39505
|
+
const inner = strategy.edges.filter((edge) => ids.has(edge.from) && ids.has(edge.to));
|
|
39506
|
+
const byId = new Map(inside.map((node) => [node.id, node]));
|
|
39507
|
+
for (const id of orderBy(inside.map((node) => node.id), inner, (a, b) => canvas(byId.get(a), byId.get(b))))
|
|
39508
|
+
out.push(byId.get(id));
|
|
39509
|
+
}
|
|
39510
|
+
return out;
|
|
39511
|
+
}
|
|
39512
|
+
function orderBy(items, edges, compare) {
|
|
39513
|
+
const incoming = new Map(items.map((item2) => [item2, 0]));
|
|
39514
|
+
for (const edge of edges)
|
|
39515
|
+
if (incoming.has(edge.to) && incoming.has(edge.from))
|
|
39516
|
+
incoming.set(edge.to, (incoming.get(edge.to) ?? 0) + 1);
|
|
39517
|
+
const queue = items.filter((item2) => (incoming.get(item2) ?? 0) === 0).sort(compare);
|
|
39451
39518
|
const seen = /* @__PURE__ */ new Set();
|
|
39452
39519
|
const out = [];
|
|
39453
39520
|
while (queue.length > 0) {
|
|
39454
|
-
const
|
|
39455
|
-
if (seen.has(
|
|
39521
|
+
const item2 = queue.shift();
|
|
39522
|
+
if (seen.has(item2))
|
|
39456
39523
|
continue;
|
|
39457
|
-
seen.add(
|
|
39458
|
-
out.push(
|
|
39459
|
-
const next =
|
|
39524
|
+
seen.add(item2);
|
|
39525
|
+
out.push(item2);
|
|
39526
|
+
const next = [...new Set(edges.filter((edge) => edge.from === item2 && incoming.has(edge.to) && !seen.has(edge.to)).map((edge) => edge.to))].sort(compare);
|
|
39460
39527
|
queue.push(...next);
|
|
39461
39528
|
}
|
|
39462
|
-
for (const
|
|
39463
|
-
if (!seen.has(
|
|
39464
|
-
out.push(
|
|
39529
|
+
for (const item2 of [...items].sort(compare))
|
|
39530
|
+
if (!seen.has(item2))
|
|
39531
|
+
out.push(item2);
|
|
39465
39532
|
return out;
|
|
39466
39533
|
}
|
|
39467
39534
|
function firstLine(text2) {
|
|
@@ -39471,14 +39538,38 @@ function firstLine(text2) {
|
|
|
39471
39538
|
function describeStrategy(strategy, roleName) {
|
|
39472
39539
|
const order2 = strategyOrder(strategy);
|
|
39473
39540
|
const number5 = new Map(order2.map((node, i) => [node.id, i + 1]));
|
|
39541
|
+
const groups = strategy.groups ?? [];
|
|
39474
39542
|
const label = (id) => {
|
|
39475
39543
|
const node = strategy.nodes.find((n) => n.id === id);
|
|
39476
|
-
|
|
39477
|
-
|
|
39544
|
+
if (node !== void 0)
|
|
39545
|
+
return `${roleName(node.role)} (step ${String(number5.get(id) ?? "?")})`;
|
|
39546
|
+
const group = groups.find((g) => g.id === id);
|
|
39547
|
+
if (group === void 0)
|
|
39548
|
+
return id;
|
|
39549
|
+
const inside = groupMembers(strategy, id).map((member) => number5.get(member.id)).filter((n) => n !== void 0).sort((a, b) => a - b);
|
|
39550
|
+
return `the box "${groupName(group)}" (step${inside.length === 1 ? "" : "s"} ${inside.join(", ")})`;
|
|
39551
|
+
};
|
|
39552
|
+
const onward = (edge) => `${label(edge.to)}${edge.contract !== void 0 && edge.contract.trim().length > 0 ? ` (passing on: ${firstLine(edge.contract)})` : ""}${requiredOf(edge).length > 0 && !groups.some((g) => g.id === edge.from) ? ` [required: ${requiredOf(edge).join(", ")}]` : ""}`;
|
|
39478
39553
|
const lines2 = [`## Strategy: ${strategy.name}`, "", "The user drew how this work must be done. Steps, each done by consulting that role with ask_agent:"];
|
|
39554
|
+
const announced = /* @__PURE__ */ new Set();
|
|
39479
39555
|
for (const node of order2) {
|
|
39480
|
-
const
|
|
39481
|
-
|
|
39556
|
+
const group = node.group === void 0 ? void 0 : groups.find((g) => g.id === node.group);
|
|
39557
|
+
if (group !== void 0 && !announced.has(group.id)) {
|
|
39558
|
+
announced.add(group.id);
|
|
39559
|
+
const into = strategy.edges.filter((edge) => edge.to === group.id).map((edge) => label(edge.from));
|
|
39560
|
+
lines2.push(`${label(group.id)[0].toUpperCase()}${label(group.id).slice(1)} - ${groupKind(group) === "parallel" ? "consulted together, in ONE ask_agents call" : "done as a group, in the order below"}${into.length > 0 ? `, after ${into.join(" and ")}` : ""}:`);
|
|
39561
|
+
}
|
|
39562
|
+
const next = strategy.edges.filter((edge) => edge.from === node.id && edge.twoWay !== true).map(onward);
|
|
39563
|
+
lines2.push(`${group !== void 0 ? " " : ""}${String(number5.get(node.id))}. ${roleName(node.role)}${node.readOnly === true ? " - read-only: may not change anything" : ""}${node.instructions !== void 0 && node.instructions.trim().length > 0 ? ` - the user's instructions for it: "${firstLine(node.instructions)}"` : " - what it does here is yours to plan"}` + (next.length > 0 ? `; then ${next.join(" and ")}` : ""));
|
|
39564
|
+
if (group !== void 0) {
|
|
39565
|
+
const members = groupMembers(strategy, group.id);
|
|
39566
|
+
const last = order2.filter((n) => members.some((m) => m.id === n.id)).at(-1);
|
|
39567
|
+
if (last?.id === node.id) {
|
|
39568
|
+
const after = strategy.edges.filter((edge) => edge.from === group.id).map(onward);
|
|
39569
|
+
if (after.length > 0)
|
|
39570
|
+
lines2.push(` When every step in ${label(group.id)} has answered: then ${after.join(" and ")}.`);
|
|
39571
|
+
}
|
|
39572
|
+
}
|
|
39482
39573
|
}
|
|
39483
39574
|
const loops = strategy.edges.filter((edge) => edge.twoWay === true);
|
|
39484
39575
|
if (loops.length > 0) {
|
|
@@ -39488,13 +39579,17 @@ function describeStrategy(strategy, roleName) {
|
|
|
39488
39579
|
lines2.push(`- ${label(edge.from)} and ${judge}: after ${label(edge.from)}, ${judge} checks; if not done, back to ${label(edge.from)}. ` + (edge.until !== void 0 && edge.until.trim().length > 0 ? `Repeat until: "${edge.until.trim()}" (judged by ${judge}), ` : "Repeat ") + `at most ${String(roundsOf(edge))} round${roundsOf(edge) === 1 ? "" : "s"}.${edge.label !== void 0 ? ` (${edge.label})` : ""}` + (edge.contract !== void 0 && edge.contract.trim().length > 0 ? ` Each round ${label(edge.from)} passes on: ${firstLine(edge.contract)}.` : "") + (requiredOf(edge).length > 0 ? ` Required in every hand-over: ${requiredOf(edge).join(", ")}.` : ""));
|
|
39489
39580
|
}
|
|
39490
39581
|
}
|
|
39491
|
-
const boxes =
|
|
39492
|
-
|
|
39582
|
+
const boxes = groups.map((group) => ({ group, inside: order2.filter((node) => node.group === group.id) })).filter((box) => box.inside.length > 1);
|
|
39583
|
+
const parallel = boxes.filter((box) => groupKind(box.group) === "parallel");
|
|
39584
|
+
if (parallel.length > 0) {
|
|
39493
39585
|
lines2.push("", "In parallel (consult these together in ONE ask_agents call, and continue when all have answered):");
|
|
39494
|
-
for (const box of
|
|
39495
|
-
lines2.push(`- ${box.group
|
|
39586
|
+
for (const box of parallel)
|
|
39587
|
+
lines2.push(`- ${groupName(box.group)}: ${box.inside.map((node) => label(node.id)).join(", ")}`);
|
|
39588
|
+
}
|
|
39589
|
+
if (boxes.length > 0) {
|
|
39590
|
+
lines2.push("", "A connector leaving a box is followed only once every step inside it has answered. A connector into a box gives every step inside what arrives along it.");
|
|
39496
39591
|
}
|
|
39497
|
-
lines2.push("", "How to follow it:", "- Before doing anything else
|
|
39592
|
+
lines2.push("", "How to follow it:", "- This strategy applies to every piece of work asked for in this chat, not only the first. Before doing anything else for a request - including a new topic after an earlier one is finished - propose a plan with update_plan that carries out every step above in order for that request, naming the role for each step and writing each back-and-forth as one step with its condition and its maximum rounds. Then follow the plan. A new plan for a new topic starts the loops afresh; do not reuse an earlier topic's plan or skip the specialists because they were consulted before.", "- Give each specialist what it needs from the earlier steps: it does not see this conversation, only what you send it. A step's own instructions from the user reach it with every question; plan the steps that have none.", "- Connectors with no contract: before starting, propose what should pass along them with set_strategy_contracts (the user approves it). Light Code checks every required item after each answer, asks the specialist again for what is missing, and tells you if it is still missing - pass on what arrived, and say what did not.", "- In a back-and-forth, Light Code counts the rounds and tells you after each answer where the loop stands; it refuses a round past the maximum. If the maximum is reached without the condition, stop and tell the user what is still open rather than working around it.", "- A question from the user that is not part of the strategy is answered normally.");
|
|
39498
39593
|
return lines2.join("\n");
|
|
39499
39594
|
}
|
|
39500
39595
|
function readVerdict(answer) {
|
|
@@ -39532,24 +39627,27 @@ function beforeConsult(strategy, progress, lastRole, role, roleName) {
|
|
|
39532
39627
|
for (const edge of strategy.edges) {
|
|
39533
39628
|
const items = requiredOf(edge);
|
|
39534
39629
|
const from = strategy.nodes.find((n) => n.id === edge.from);
|
|
39535
|
-
|
|
39536
|
-
if (items.length === 0 || from === void 0 || to === void 0 || role !== from.role)
|
|
39630
|
+
if (items.length === 0 || from === void 0 || endpointNodes(strategy, edge.to).length === 0 || role !== from.role)
|
|
39537
39631
|
continue;
|
|
39538
|
-
notes.push(`Required in your answer for ${
|
|
39632
|
+
notes.push(`Required in your answer for ${targetName(strategy, edge.to, roleName)}, each on a line of its own starting with its name and a colon:
|
|
39539
39633
|
` + items.map((item2) => `${item2}: ...`).join("\n") + "\nLight Code checks these and will ask you again for any that are missing.");
|
|
39540
39634
|
}
|
|
39635
|
+
const endName = (id) => targetName(strategy, id, roleName);
|
|
39541
39636
|
for (const edge of strategy.edges) {
|
|
39542
|
-
const
|
|
39637
|
+
const fromBox = strategy.groups?.some((g) => g.id === edge.from) === true;
|
|
39638
|
+
const items = fromBox ? requiredOf(edge) : [];
|
|
39639
|
+
const contract = [edge.contract?.trim() ?? "", items.length > 0 ? `each of ${items.join(", ")}` : ""].filter((part) => part.length > 0).join("; ");
|
|
39543
39640
|
if (contract.length === 0)
|
|
39544
39641
|
continue;
|
|
39545
|
-
const from = strategy
|
|
39546
|
-
const to = strategy
|
|
39547
|
-
if (from ===
|
|
39642
|
+
const from = endpointNodes(strategy, edge.from);
|
|
39643
|
+
const to = endpointNodes(strategy, edge.to);
|
|
39644
|
+
if (from.length === 0 || to.length === 0)
|
|
39548
39645
|
continue;
|
|
39549
|
-
if (role ===
|
|
39550
|
-
notes.push(`Your answer is passed on to ${
|
|
39551
|
-
|
|
39552
|
-
|
|
39646
|
+
if (from.some((n) => n.role === role)) {
|
|
39647
|
+
notes.push(fromBox ? `Your answer, with the others from ${endName(edge.from)}, is passed on to ${endName(edge.to)}. As agreed, together they must contain: ${contract}. Give your part of it.` : `Your answer is passed on to ${endName(edge.to)}. As agreed, it must contain: ${contract}`);
|
|
39648
|
+
}
|
|
39649
|
+
if (to.some((n) => n.role === role))
|
|
39650
|
+
notes.push(`From ${endName(edge.from)} you are given, as agreed: ${contract}. If any of it is missing from the question, say exactly what is missing.`);
|
|
39553
39651
|
}
|
|
39554
39652
|
const instructed = nodes.map((node) => node.instructions?.trim() ?? "").filter((text2) => text2.length > 0);
|
|
39555
39653
|
if (instructed.length > 0)
|
|
@@ -39627,13 +39725,25 @@ function contractCheck(strategy, role, answer) {
|
|
|
39627
39725
|
for (const edge of strategy.edges) {
|
|
39628
39726
|
const items = requiredOf(edge);
|
|
39629
39727
|
const from = strategy.nodes.find((n) => n.id === edge.from);
|
|
39630
|
-
|
|
39631
|
-
if (items.length === 0 || from === void 0 || to === void 0 || from.role !== role)
|
|
39728
|
+
if (items.length === 0 || from === void 0 || from.role !== role)
|
|
39632
39729
|
continue;
|
|
39633
|
-
|
|
39730
|
+
const toNode = strategy.nodes.find((n) => n.id === edge.to);
|
|
39731
|
+
const toGroup = strategy.groups?.find((g) => g.id === edge.to);
|
|
39732
|
+
if (toNode === void 0 && toGroup === void 0)
|
|
39733
|
+
continue;
|
|
39734
|
+
out.push({ edgeId: edge.id, to: toNode?.role ?? groupName(toGroup), required: items, missing: missingItems(answer, items) });
|
|
39634
39735
|
}
|
|
39635
39736
|
return out;
|
|
39636
39737
|
}
|
|
39738
|
+
function targetName(strategy, id, roleName) {
|
|
39739
|
+
const node = strategy.nodes.find((n) => n.id === id);
|
|
39740
|
+
if (node !== void 0)
|
|
39741
|
+
return roleName(node.role);
|
|
39742
|
+
const group = strategy.groups?.find((g) => g.id === id);
|
|
39743
|
+
if (group === void 0)
|
|
39744
|
+
return id;
|
|
39745
|
+
return `the box "${groupName(group)}" (${groupMembers(strategy, id).map((n) => roleName(n.role)).join(", ")})`;
|
|
39746
|
+
}
|
|
39637
39747
|
function askForMissing(missing, previous) {
|
|
39638
39748
|
return [
|
|
39639
39749
|
`Your answer is missing what the strategy requires: ${missing.join(", ")}.`,
|
|
@@ -43502,8 +43612,8 @@ function restoreArguments(argumentsJson, reshaped) {
|
|
|
43502
43612
|
restoreAt(args, entry.path, entry.kind);
|
|
43503
43613
|
return JSON.stringify(args);
|
|
43504
43614
|
}
|
|
43505
|
-
function restoreAt(value,
|
|
43506
|
-
if (
|
|
43615
|
+
function restoreAt(value, path68, kind) {
|
|
43616
|
+
if (path68.length === 0) {
|
|
43507
43617
|
if (typeof value !== "string")
|
|
43508
43618
|
return value;
|
|
43509
43619
|
if (kind === "number") {
|
|
@@ -43516,7 +43626,7 @@ function restoreAt(value, path66, kind) {
|
|
|
43516
43626
|
return value;
|
|
43517
43627
|
}
|
|
43518
43628
|
}
|
|
43519
|
-
const [head, ...rest] =
|
|
43629
|
+
const [head, ...rest] = path68;
|
|
43520
43630
|
if (head === "[]") {
|
|
43521
43631
|
if (Array.isArray(value))
|
|
43522
43632
|
for (let i = 0; i < value.length; i += 1)
|
|
@@ -43529,16 +43639,16 @@ function restoreAt(value, path66, kind) {
|
|
|
43529
43639
|
}
|
|
43530
43640
|
var SCALARS = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean"]);
|
|
43531
43641
|
var MAX_DEPTH = 12;
|
|
43532
|
-
function convert(schema12, root,
|
|
43642
|
+
function convert(schema12, root, path68, found2, depth, isRoot = false) {
|
|
43533
43643
|
if (!isRecord2(schema12))
|
|
43534
43644
|
return { type: "string" };
|
|
43535
43645
|
if (depth > MAX_DEPTH)
|
|
43536
|
-
return asJsonString(schema12,
|
|
43646
|
+
return asJsonString(schema12, path68, found2, "nested too deeply to describe here");
|
|
43537
43647
|
let node = { ...schema12 };
|
|
43538
43648
|
if (typeof node.$ref === "string") {
|
|
43539
43649
|
const target = resolveRef2(node.$ref, root);
|
|
43540
43650
|
if (target === void 0)
|
|
43541
|
-
return asJsonString(node,
|
|
43651
|
+
return asJsonString(node, path68, found2, "a structured value");
|
|
43542
43652
|
const { $ref: _ref, ...siblings } = node;
|
|
43543
43653
|
void _ref;
|
|
43544
43654
|
node = { ...target, ...siblings };
|
|
@@ -43554,7 +43664,7 @@ function convert(schema12, root, path66, found2, depth, isRoot = false) {
|
|
|
43554
43664
|
const merged = { ...branches[0] };
|
|
43555
43665
|
if (describedBase !== void 0 && merged.description === void 0)
|
|
43556
43666
|
merged.description = describedBase;
|
|
43557
|
-
const converted = convert(merged, root,
|
|
43667
|
+
const converted = convert(merged, root, path68, found2, depth + 1);
|
|
43558
43668
|
if (nullable2)
|
|
43559
43669
|
converted.nullable = true;
|
|
43560
43670
|
return converted;
|
|
@@ -43562,16 +43672,16 @@ function convert(schema12, root, path66, found2, depth, isRoot = false) {
|
|
|
43562
43672
|
const allEnums = branches.every((branch) => Array.isArray(branch.enum) || branch.const !== void 0);
|
|
43563
43673
|
if (allEnums) {
|
|
43564
43674
|
const values = branches.flatMap((branch) => Array.isArray(branch.enum) ? branch.enum : [branch.const]);
|
|
43565
|
-
return convert({ ...withoutUnion(node), enum: values, ...nullable2 ? { nullable: true } : {} }, root,
|
|
43675
|
+
return convert({ ...withoutUnion(node), enum: values, ...nullable2 ? { nullable: true } : {} }, root, path68, found2, depth + 1);
|
|
43566
43676
|
}
|
|
43567
43677
|
const allScalars = branches.every((branch) => typeof branch.type === "string" && SCALARS.has(branch.type));
|
|
43568
43678
|
if (allScalars) {
|
|
43569
43679
|
const types = branches.map((branch) => branch.type);
|
|
43570
43680
|
const chosen = types.includes("string") ? "string" : types[0];
|
|
43571
43681
|
const note = `Accepts ${types.join(" or ")}.`;
|
|
43572
|
-
return convert({ ...withoutUnion(node), type: chosen, description: join(baseDescription(node), note), ...nullable2 ? { nullable: true } : {} }, root,
|
|
43682
|
+
return convert({ ...withoutUnion(node), type: chosen, description: join(baseDescription(node), note), ...nullable2 ? { nullable: true } : {} }, root, path68, found2, depth + 1);
|
|
43573
43683
|
}
|
|
43574
|
-
return asJsonString(node,
|
|
43684
|
+
return asJsonString(node, path68, found2, describeUnion(branches));
|
|
43575
43685
|
}
|
|
43576
43686
|
const type = node.type;
|
|
43577
43687
|
const notes = describeDropped(node);
|
|
@@ -43583,10 +43693,10 @@ function convert(schema12, root, path66, found2, depth, isRoot = false) {
|
|
|
43583
43693
|
const properties = isRecord2(node.properties) ? node.properties : {};
|
|
43584
43694
|
const names = Object.keys(properties);
|
|
43585
43695
|
if (names.length === 0 && !isRoot)
|
|
43586
|
-
return asJsonString(node,
|
|
43696
|
+
return asJsonString(node, path68, found2, "an object with any keys");
|
|
43587
43697
|
const converted = {};
|
|
43588
43698
|
for (const name of names)
|
|
43589
|
-
converted[name] = convert(properties[name], root, [...
|
|
43699
|
+
converted[name] = convert(properties[name], root, [...path68, name], found2, depth + 1);
|
|
43590
43700
|
out.properties = converted;
|
|
43591
43701
|
if (Array.isArray(node.required)) {
|
|
43592
43702
|
const required2 = node.required.filter((name) => typeof name === "string" && name in converted);
|
|
@@ -43594,9 +43704,9 @@ function convert(schema12, root, path66, found2, depth, isRoot = false) {
|
|
|
43594
43704
|
out.required = required2;
|
|
43595
43705
|
}
|
|
43596
43706
|
} else if (type === "array") {
|
|
43597
|
-
out.items = node.items === void 0 ? { type: "string" } : convert(node.items, root, [...
|
|
43707
|
+
out.items = node.items === void 0 ? { type: "string" } : convert(node.items, root, [...path68, "[]"], found2, depth + 1);
|
|
43598
43708
|
} else if (type === void 0 && node.enum === void 0) {
|
|
43599
|
-
return asJsonString(node,
|
|
43709
|
+
return asJsonString(node, path68, found2, "any JSON value");
|
|
43600
43710
|
}
|
|
43601
43711
|
if (Array.isArray(node.enum)) {
|
|
43602
43712
|
const values = node.enum.filter((value) => value !== null);
|
|
@@ -43606,7 +43716,7 @@ function convert(schema12, root, path66, found2, depth, isRoot = false) {
|
|
|
43606
43716
|
} else if (values.every((value) => typeof value === "number")) {
|
|
43607
43717
|
out.type = "string";
|
|
43608
43718
|
out.enum = values.map(String);
|
|
43609
|
-
found2.push({ path:
|
|
43719
|
+
found2.push({ path: path68, kind: "number" });
|
|
43610
43720
|
} else {
|
|
43611
43721
|
notes.push(`One of: ${values.map((value) => JSON.stringify(value)).join(", ")}.`);
|
|
43612
43722
|
}
|
|
@@ -43620,8 +43730,8 @@ function convert(schema12, root, path66, found2, depth, isRoot = false) {
|
|
|
43620
43730
|
out.description = description;
|
|
43621
43731
|
return out;
|
|
43622
43732
|
}
|
|
43623
|
-
function asJsonString(node,
|
|
43624
|
-
found2.push({ path:
|
|
43733
|
+
function asJsonString(node, path68, found2, what) {
|
|
43734
|
+
found2.push({ path: path68, kind: "json" });
|
|
43625
43735
|
const example = exampleFor(node);
|
|
43626
43736
|
return {
|
|
43627
43737
|
type: "string",
|
|
@@ -45000,8 +45110,8 @@ var SUPERSEDED_MARKER = "[Superseded: this file was read again later in the conv
|
|
|
45000
45110
|
function readFilePath(argumentsJson) {
|
|
45001
45111
|
try {
|
|
45002
45112
|
const parsed = JSON.parse(argumentsJson.length > 0 ? argumentsJson : "{}");
|
|
45003
|
-
const
|
|
45004
|
-
return typeof
|
|
45113
|
+
const path68 = parsed.path;
|
|
45114
|
+
return typeof path68 === "string" && path68.length > 0 ? path68 : void 0;
|
|
45005
45115
|
} catch {
|
|
45006
45116
|
return void 0;
|
|
45007
45117
|
}
|
|
@@ -45014,8 +45124,8 @@ function dropSupersededReads(messages) {
|
|
|
45014
45124
|
for (const toolCall of message6.toolCalls ?? []) {
|
|
45015
45125
|
if (toolCall.name !== "read_file")
|
|
45016
45126
|
continue;
|
|
45017
|
-
const
|
|
45018
|
-
if (
|
|
45127
|
+
const path68 = readFilePath(toolCall.arguments);
|
|
45128
|
+
if (path68 === void 0)
|
|
45019
45129
|
continue;
|
|
45020
45130
|
keyByCallId.set(toolCall.id, toolCall.arguments);
|
|
45021
45131
|
}
|
|
@@ -46023,6 +46133,18 @@ function pruneProgress(plan3, progress) {
|
|
|
46023
46133
|
kept[id] = entry;
|
|
46024
46134
|
return kept;
|
|
46025
46135
|
}
|
|
46136
|
+
function startsNewWork(previousPlan, previousProgress, nextPlan) {
|
|
46137
|
+
const before = parseCheckpoints(previousPlan);
|
|
46138
|
+
const after = parseCheckpoints(nextPlan);
|
|
46139
|
+
if (after.length === 0)
|
|
46140
|
+
return false;
|
|
46141
|
+
if (before.length === 0)
|
|
46142
|
+
return true;
|
|
46143
|
+
if (before.every((step) => previousProgress?.[step.id]?.status === "done"))
|
|
46144
|
+
return true;
|
|
46145
|
+
const kept = new Set(before.map((step) => step.id));
|
|
46146
|
+
return !after.some((step) => kept.has(step.id));
|
|
46147
|
+
}
|
|
46026
46148
|
function markCheckpoint(plan3, progress, index, status2) {
|
|
46027
46149
|
const checkpoint = parseCheckpoints(plan3).find((candidate) => candidate.index === index);
|
|
46028
46150
|
if (checkpoint === void 0)
|
|
@@ -48124,13 +48246,13 @@ var OpenSearchClient = class {
|
|
|
48124
48246
|
* `_bulk`, `_delete_by_query`, index creation — is refused here rather than merely
|
|
48125
48247
|
* unused, so no future edit or crafted argument can turn a read client into a writer.
|
|
48126
48248
|
*/
|
|
48127
|
-
async request(
|
|
48249
|
+
async request(path68, options = {}) {
|
|
48128
48250
|
const method = options.method ?? "GET";
|
|
48129
|
-
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(
|
|
48251
|
+
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(path68);
|
|
48130
48252
|
if (method !== "GET" && !isSearchPost) {
|
|
48131
|
-
throw new OpenSearchError(`Refusing ${method} ${
|
|
48253
|
+
throw new OpenSearchError(`Refusing ${method} ${path68}: this client is read-only. Indexing goes through the indexer, which the user starts from Settings.`);
|
|
48132
48254
|
}
|
|
48133
|
-
const url2 = `${this.base}${
|
|
48255
|
+
const url2 = `${this.base}${path68}`;
|
|
48134
48256
|
const request2 = {
|
|
48135
48257
|
method,
|
|
48136
48258
|
headers: this.headers()
|
|
@@ -48297,11 +48419,11 @@ function collectFields(properties, prefix, out) {
|
|
|
48297
48419
|
return;
|
|
48298
48420
|
for (const [name, raw] of Object.entries(properties)) {
|
|
48299
48421
|
const field2 = raw;
|
|
48300
|
-
const
|
|
48422
|
+
const path68 = prefix.length > 0 ? `${prefix}.${name}` : name;
|
|
48301
48423
|
if (typeof field2.type === "string")
|
|
48302
|
-
out[
|
|
48424
|
+
out[path68] = field2.type;
|
|
48303
48425
|
if (field2.properties !== void 0)
|
|
48304
|
-
collectFields(field2.properties,
|
|
48426
|
+
collectFields(field2.properties, path68, out);
|
|
48305
48427
|
}
|
|
48306
48428
|
}
|
|
48307
48429
|
function describeStatus(status2, url2, body) {
|
|
@@ -48320,23 +48442,23 @@ function describeStatus(status2, url2, body) {
|
|
|
48320
48442
|
var TEXT_TYPES = /* @__PURE__ */ new Set(["text", "match_only_text", "search_as_you_type", "wildcard"]);
|
|
48321
48443
|
var KEYWORD_TYPES = /* @__PURE__ */ new Set(["keyword", "constant_keyword"]);
|
|
48322
48444
|
var NOISE_FIELDS = /* @__PURE__ */ new Set(["@version", "ecs", "tags", "stream", "input", "agent", "host", "event"]);
|
|
48323
|
-
function leafName(
|
|
48324
|
-
const parts =
|
|
48325
|
-
return parts[parts.length - 1] ??
|
|
48445
|
+
function leafName(path68) {
|
|
48446
|
+
const parts = path68.split(".");
|
|
48447
|
+
return parts[parts.length - 1] ?? path68;
|
|
48326
48448
|
}
|
|
48327
48449
|
function selectQueryFields(mapping, limit = 25) {
|
|
48328
48450
|
const text2 = [];
|
|
48329
48451
|
const keyword = [];
|
|
48330
|
-
for (const [
|
|
48331
|
-
if (NOISE_FIELDS.has(leafName(
|
|
48452
|
+
for (const [path68, type] of Object.entries(mapping)) {
|
|
48453
|
+
if (NOISE_FIELDS.has(leafName(path68)) || NOISE_FIELDS.has(path68.split(".")[0] ?? ""))
|
|
48332
48454
|
continue;
|
|
48333
48455
|
if (TEXT_TYPES.has(type)) {
|
|
48334
|
-
text2.push(
|
|
48456
|
+
text2.push(path68);
|
|
48335
48457
|
} else if (KEYWORD_TYPES.has(type)) {
|
|
48336
|
-
const parent =
|
|
48337
|
-
if (
|
|
48458
|
+
const parent = path68.replace(/\.keyword$/, "");
|
|
48459
|
+
if (path68.endsWith(".keyword") && TEXT_TYPES.has(mapping[parent] ?? ""))
|
|
48338
48460
|
continue;
|
|
48339
|
-
keyword.push(
|
|
48461
|
+
keyword.push(path68);
|
|
48340
48462
|
}
|
|
48341
48463
|
}
|
|
48342
48464
|
const byDepth = (a, b) => a.split(".").length - b.split(".").length || a.localeCompare(b);
|
|
@@ -48478,8 +48600,8 @@ var OpenSearchIndexWriter = class {
|
|
|
48478
48600
|
}
|
|
48479
48601
|
return headers;
|
|
48480
48602
|
}
|
|
48481
|
-
async request(
|
|
48482
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
48603
|
+
async request(path68, method, body, signal) {
|
|
48604
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path68}`;
|
|
48483
48605
|
const request2 = { method, headers: this.headers() };
|
|
48484
48606
|
if (body !== void 0) {
|
|
48485
48607
|
if (typeof body === "string") {
|
|
@@ -48693,13 +48815,13 @@ var OpenSearchIndexWriter = class {
|
|
|
48693
48815
|
for (const hit of hits) {
|
|
48694
48816
|
const source = hit._source ?? {};
|
|
48695
48817
|
const vector = source.vector;
|
|
48696
|
-
const
|
|
48697
|
-
if (typeof
|
|
48818
|
+
const path68 = source.path;
|
|
48819
|
+
if (typeof path68 !== "string" || !Array.isArray(vector))
|
|
48698
48820
|
continue;
|
|
48699
48821
|
documents.push({
|
|
48700
48822
|
id: hit._id ?? "",
|
|
48701
48823
|
text: typeof source.text === "string" ? source.text : "",
|
|
48702
|
-
path:
|
|
48824
|
+
path: path68,
|
|
48703
48825
|
startLine: typeof source.startLine === "number" ? source.startLine : 1,
|
|
48704
48826
|
endLine: typeof source.endLine === "number" ? source.endLine : 1,
|
|
48705
48827
|
vector
|
|
@@ -48775,8 +48897,8 @@ var RestTransport = class {
|
|
|
48775
48897
|
* threw would push every caller into catching and re-inspecting an error to find out
|
|
48776
48898
|
* whether it was really an error. `expectOk` is there for the cases that are.
|
|
48777
48899
|
*/
|
|
48778
|
-
async send(
|
|
48779
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
48900
|
+
async send(path68, method, body, signal) {
|
|
48901
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path68}`;
|
|
48780
48902
|
const request2 = { method, headers: this.headers() };
|
|
48781
48903
|
if (body !== void 0)
|
|
48782
48904
|
request2.body = JSON.stringify(body);
|
|
@@ -48802,11 +48924,11 @@ var RestTransport = class {
|
|
|
48802
48924
|
return { status: response.status, body: parsed };
|
|
48803
48925
|
}
|
|
48804
48926
|
/** Sends, and throws unless the status is 2xx. */
|
|
48805
|
-
async expectOk(
|
|
48806
|
-
const result = await this.send(
|
|
48927
|
+
async expectOk(path68, method, body, signal) {
|
|
48928
|
+
const result = await this.send(path68, method, body, signal);
|
|
48807
48929
|
if (result.status < 200 || result.status >= 300) {
|
|
48808
48930
|
const detail = typeof result.body === "string" ? result.body : JSON.stringify(result.body ?? "");
|
|
48809
|
-
throw new VectorStoreError(`${method} ${
|
|
48931
|
+
throw new VectorStoreError(`${method} ${path68} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}` + this.explain(result.body), result.status);
|
|
48810
48932
|
}
|
|
48811
48933
|
return result.body;
|
|
48812
48934
|
}
|
|
@@ -48992,10 +49114,10 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
48992
49114
|
const matches = [];
|
|
48993
49115
|
for (let index = 0; index < ids.length; index++) {
|
|
48994
49116
|
const metadata = metadatas[index] ?? {};
|
|
48995
|
-
const
|
|
48996
|
-
if (
|
|
49117
|
+
const path68 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
49118
|
+
if (path68 === void 0)
|
|
48997
49119
|
continue;
|
|
48998
|
-
if (prefix !== void 0 && prefix.length > 0 && !
|
|
49120
|
+
if (prefix !== void 0 && prefix.length > 0 && !path68.startsWith(prefix))
|
|
48999
49121
|
continue;
|
|
49000
49122
|
if (projectHere && typeof metadata.project === "string" && !options.project?.names.includes(metadata.project))
|
|
49001
49123
|
continue;
|
|
@@ -49009,7 +49131,7 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
49009
49131
|
*/
|
|
49010
49132
|
score: typeof distance === "number" ? 1 / (1 + Math.max(0, distance)) : 0,
|
|
49011
49133
|
text: documents[index] ?? (typeof metadata.text === "string" ? metadata.text : ""),
|
|
49012
|
-
path:
|
|
49134
|
+
path: path68
|
|
49013
49135
|
};
|
|
49014
49136
|
if (typeof metadata.startLine === "number")
|
|
49015
49137
|
match.startLine = metadata.startLine;
|
|
@@ -49120,13 +49242,13 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
49120
49242
|
for (let index = 0; index < ids.length; index++) {
|
|
49121
49243
|
const metadata = result.metadatas?.[index] ?? {};
|
|
49122
49244
|
const vector = result.embeddings?.[index];
|
|
49123
|
-
const
|
|
49124
|
-
if (
|
|
49245
|
+
const path68 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
49246
|
+
if (path68 === void 0 || !Array.isArray(vector))
|
|
49125
49247
|
continue;
|
|
49126
49248
|
documents.push({
|
|
49127
49249
|
id: ids[index] ?? "",
|
|
49128
49250
|
text: result.documents?.[index] ?? "",
|
|
49129
|
-
path:
|
|
49251
|
+
path: path68,
|
|
49130
49252
|
startLine: typeof metadata.startLine === "number" ? metadata.startLine : 1,
|
|
49131
49253
|
endLine: typeof metadata.endLine === "number" ? metadata.endLine : 1,
|
|
49132
49254
|
vector
|
|
@@ -49143,9 +49265,9 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
49143
49265
|
const result = await this.rest.expectOk(`${this.base}/collections/${found2.id}/get`, "POST", { include: ["metadatas"], limit }, options.signal);
|
|
49144
49266
|
const paths = /* @__PURE__ */ new Set();
|
|
49145
49267
|
for (const metadata of result.metadatas ?? []) {
|
|
49146
|
-
const
|
|
49147
|
-
if (typeof
|
|
49148
|
-
paths.add(
|
|
49268
|
+
const path68 = metadata?.path;
|
|
49269
|
+
if (typeof path68 === "string")
|
|
49270
|
+
paths.add(path68);
|
|
49149
49271
|
}
|
|
49150
49272
|
return [...paths];
|
|
49151
49273
|
}
|
|
@@ -49172,14 +49294,14 @@ var MARKER_ID = "5f6d2a41-0000-5000-8000-6c69676874c0";
|
|
|
49172
49294
|
var MARKER_MARK = "light-code";
|
|
49173
49295
|
function toMatch(point) {
|
|
49174
49296
|
const payload = point.payload ?? {};
|
|
49175
|
-
const
|
|
49176
|
-
if (
|
|
49297
|
+
const path68 = typeof payload.path === "string" ? payload.path : void 0;
|
|
49298
|
+
if (path68 === void 0)
|
|
49177
49299
|
return void 0;
|
|
49178
49300
|
const match = {
|
|
49179
49301
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
49180
49302
|
score: typeof point.score === "number" ? point.score : 0,
|
|
49181
49303
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
49182
|
-
path:
|
|
49304
|
+
path: path68
|
|
49183
49305
|
};
|
|
49184
49306
|
if (typeof payload.startLine === "number")
|
|
49185
49307
|
match.startLine = payload.startLine;
|
|
@@ -49373,13 +49495,13 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
49373
49495
|
const documents = [];
|
|
49374
49496
|
for (const point of result.body.result?.points ?? []) {
|
|
49375
49497
|
const payload = point.payload ?? {};
|
|
49376
|
-
const
|
|
49377
|
-
if (
|
|
49498
|
+
const path68 = typeof payload.path === "string" ? payload.path : void 0;
|
|
49499
|
+
if (path68 === void 0 || !Array.isArray(point.vector))
|
|
49378
49500
|
continue;
|
|
49379
49501
|
documents.push({
|
|
49380
49502
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
49381
49503
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
49382
|
-
path:
|
|
49504
|
+
path: path68,
|
|
49383
49505
|
startLine: typeof payload.startLine === "number" ? payload.startLine : 1,
|
|
49384
49506
|
endLine: typeof payload.endLine === "number" ? payload.endLine : 1,
|
|
49385
49507
|
vector: point.vector
|
|
@@ -49406,9 +49528,9 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
49406
49528
|
throw new VectorStoreError(`Could not list "${collection}" (HTTP ${String(result.status)}).` + wrongServerHint("qdrant", result.body, this.rest.label), result.status);
|
|
49407
49529
|
}
|
|
49408
49530
|
for (const point of result.body.result?.points ?? []) {
|
|
49409
|
-
const
|
|
49410
|
-
if (typeof
|
|
49411
|
-
paths.add(
|
|
49531
|
+
const path68 = point.payload?.path;
|
|
49532
|
+
if (typeof path68 === "string")
|
|
49533
|
+
paths.add(path68);
|
|
49412
49534
|
}
|
|
49413
49535
|
offset = result.body.result?.next_page_offset;
|
|
49414
49536
|
if (offset === void 0 || offset === null)
|
|
@@ -49942,8 +50064,8 @@ function teamSkillDocument(skill, body, vector, attribution) {
|
|
|
49942
50064
|
vector
|
|
49943
50065
|
};
|
|
49944
50066
|
}
|
|
49945
|
-
function nameFromPath(
|
|
49946
|
-
return
|
|
50067
|
+
function nameFromPath(path68) {
|
|
50068
|
+
return path68.startsWith("skill:") ? path68.slice("skill:".length) : path68;
|
|
49947
50069
|
}
|
|
49948
50070
|
function toHit(match, self) {
|
|
49949
50071
|
return {
|
|
@@ -53029,8 +53151,8 @@ function createMailCoverageTool(options) {
|
|
|
53029
53151
|
}
|
|
53030
53152
|
};
|
|
53031
53153
|
}
|
|
53032
|
-
function normaliseFolder(
|
|
53033
|
-
return
|
|
53154
|
+
function normaliseFolder(path68) {
|
|
53155
|
+
return path68.toLowerCase().replace(/[\\/]+/g, "\\");
|
|
53034
53156
|
}
|
|
53035
53157
|
function haystackOf(record2) {
|
|
53036
53158
|
return `${record2.subject}
|
|
@@ -53526,7 +53648,7 @@ async function refreshMail(options) {
|
|
|
53526
53648
|
const limit = options.batchLimit ?? 2e3;
|
|
53527
53649
|
const previewChars = options.previewChars ?? 400;
|
|
53528
53650
|
const sinceMs = Date.now() - options.days * 24 * 60 * 60 * 1e3;
|
|
53529
|
-
const harvested = await options.harvest(options.folders.map((
|
|
53651
|
+
const harvested = await options.harvest(options.folders.map((path68) => ({ path: path68, sinceMs })), { limit, previewChars });
|
|
53530
53652
|
const fetched = harvested.messages.map(toRecord);
|
|
53531
53653
|
if (fetched.length === 0) {
|
|
53532
53654
|
return { added: 0, more: false, total: known.length, embedded: 0, backfilled: 0, complete: [] };
|
|
@@ -53567,9 +53689,9 @@ async function syncMail(options) {
|
|
|
53567
53689
|
const backfillDone = await options.store.loadBackfillState();
|
|
53568
53690
|
const limit = options.batchLimit ?? 500;
|
|
53569
53691
|
const previewChars = options.previewChars ?? 400;
|
|
53570
|
-
const forwardRequests = options.folders.map((
|
|
53571
|
-
const mark = marks.get(
|
|
53572
|
-
return mark === void 0 ? { path:
|
|
53692
|
+
const forwardRequests = options.folders.map((path68) => {
|
|
53693
|
+
const mark = marks.get(path68);
|
|
53694
|
+
return mark === void 0 ? { path: path68 } : { path: path68, sinceMs: mark.newest - 1e3 };
|
|
53573
53695
|
});
|
|
53574
53696
|
const forward = await options.harvest(forwardRequests, { limit, previewChars });
|
|
53575
53697
|
let candidates = forward.messages.map(toRecord);
|
|
@@ -53578,15 +53700,15 @@ async function syncMail(options) {
|
|
|
53578
53700
|
let more = forward.truncated;
|
|
53579
53701
|
const remaining = limit - candidates.length;
|
|
53580
53702
|
const floor = options.retentionMonths === void 0 ? void 0 : monthsBefore(options.now ?? Date.now(), options.retentionMonths);
|
|
53581
|
-
const outstanding = options.folders.filter((
|
|
53582
|
-
const atFloor = floor === void 0 ? [] : outstanding.filter((
|
|
53583
|
-
const behind = outstanding.filter((
|
|
53703
|
+
const outstanding = options.folders.filter((path68) => marks.has(path68) && backfillDone[path68] !== true);
|
|
53704
|
+
const atFloor = floor === void 0 ? [] : outstanding.filter((path68) => marks.get(path68).oldest <= floor);
|
|
53705
|
+
const behind = outstanding.filter((path68) => !atFloor.includes(path68));
|
|
53584
53706
|
completed.push(...atFloor);
|
|
53585
53707
|
if (remaining > 0 && behind.length > 0 && options.signal?.aborted !== true) {
|
|
53586
|
-
const backRequests = behind.map((
|
|
53587
|
-
path:
|
|
53708
|
+
const backRequests = behind.map((path68) => ({
|
|
53709
|
+
path: path68,
|
|
53588
53710
|
// Strictly older, so the oldest held message is not fetched again every pass.
|
|
53589
|
-
beforeMs: marks.get(
|
|
53711
|
+
beforeMs: marks.get(path68).oldest,
|
|
53590
53712
|
// And no older than retention wants. The harvest ANDs the two into one window.
|
|
53591
53713
|
...floor === void 0 ? {} : { sinceMs: floor }
|
|
53592
53714
|
}));
|
|
@@ -53594,9 +53716,9 @@ async function syncMail(options) {
|
|
|
53594
53716
|
backfilled = backward.messages.length;
|
|
53595
53717
|
candidates = [...candidates, ...backward.messages.map(toRecord)];
|
|
53596
53718
|
const returnedFor = new Set(backward.messages.map((message6) => message6.folder));
|
|
53597
|
-
for (const
|
|
53598
|
-
if (!returnedFor.has(
|
|
53599
|
-
completed.push(
|
|
53719
|
+
for (const path68 of behind) {
|
|
53720
|
+
if (!returnedFor.has(path68))
|
|
53721
|
+
completed.push(path68);
|
|
53600
53722
|
}
|
|
53601
53723
|
if (backward.truncated || backfilled > 0)
|
|
53602
53724
|
more = true;
|
|
@@ -53604,7 +53726,7 @@ async function syncMail(options) {
|
|
|
53604
53726
|
if (completed.length > 0) {
|
|
53605
53727
|
await options.store.saveBackfillState({
|
|
53606
53728
|
...backfillDone,
|
|
53607
|
-
...Object.fromEntries(completed.map((
|
|
53729
|
+
...Object.fromEntries(completed.map((path68) => [path68, true]))
|
|
53608
53730
|
});
|
|
53609
53731
|
}
|
|
53610
53732
|
const fresh = withoutKnown(candidates, known);
|
|
@@ -53951,14 +54073,14 @@ function formatBytes(size) {
|
|
|
53951
54073
|
return `${(size / (1 << 10)).toFixed(1)}KB`;
|
|
53952
54074
|
return `${String(size)}B`;
|
|
53953
54075
|
}
|
|
53954
|
-
async function readTail(
|
|
54076
|
+
async function readTail(fs48, path68, size, count3) {
|
|
53955
54077
|
let span = Math.min(size, CHUNK);
|
|
53956
54078
|
let text2;
|
|
53957
54079
|
let start;
|
|
53958
54080
|
for (; ; ) {
|
|
53959
54081
|
start = Math.max(0, size - span);
|
|
53960
54082
|
const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
|
|
53961
|
-
text2 = decoder2.write(await
|
|
54083
|
+
text2 = decoder2.write(await fs48.readBytesSlice(path68, start, size)) + decoder2.end();
|
|
53962
54084
|
const enough = text2.split("\n").length > count3;
|
|
53963
54085
|
if (enough || start === 0 || span >= size)
|
|
53964
54086
|
break;
|
|
@@ -53976,7 +54098,7 @@ async function readTail(fs46, path66, size, count3) {
|
|
|
53976
54098
|
hasMoreAfter: false
|
|
53977
54099
|
};
|
|
53978
54100
|
}
|
|
53979
|
-
async function readLineWindow(
|
|
54101
|
+
async function readLineWindow(fs48, path68, size, from, count3) {
|
|
53980
54102
|
const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
|
|
53981
54103
|
const lines2 = [];
|
|
53982
54104
|
let pending = "";
|
|
@@ -53991,7 +54113,7 @@ async function readLineWindow(fs46, path66, size, from, count3) {
|
|
|
53991
54113
|
};
|
|
53992
54114
|
scan: while (position < size) {
|
|
53993
54115
|
const end = Math.min(size, position + CHUNK);
|
|
53994
|
-
pending += decoder2.write(await
|
|
54116
|
+
pending += decoder2.write(await fs48.readBytesSlice(path68, position, end));
|
|
53995
54117
|
position = end;
|
|
53996
54118
|
const parts = pending.split(/\r\n|\r|\n/);
|
|
53997
54119
|
pending = parts.pop() ?? "";
|
|
@@ -54014,13 +54136,13 @@ async function readLineWindow(fs46, path66, size, from, count3) {
|
|
|
54014
54136
|
hasMoreAfter: !reachedEnd || lineNumber > from + lines2.length
|
|
54015
54137
|
};
|
|
54016
54138
|
}
|
|
54017
|
-
async function countLines(
|
|
54139
|
+
async function countLines(fs48, path68, size) {
|
|
54018
54140
|
let newlines = 0;
|
|
54019
54141
|
let position = 0;
|
|
54020
54142
|
let lastByte = -1;
|
|
54021
54143
|
while (position < size) {
|
|
54022
54144
|
const end = Math.min(size, position + CHUNK);
|
|
54023
|
-
const buffer = await
|
|
54145
|
+
const buffer = await fs48.readBytesSlice(path68, position, end);
|
|
54024
54146
|
for (const byte of buffer)
|
|
54025
54147
|
if (byte === 10)
|
|
54026
54148
|
newlines += 1;
|
|
@@ -60388,6 +60510,7 @@ var McpRegistry = class {
|
|
|
60388
60510
|
getAlwaysAllowed;
|
|
60389
60511
|
defaultTimeout;
|
|
60390
60512
|
isRepositoryServer;
|
|
60513
|
+
toolCache;
|
|
60391
60514
|
connections = /* @__PURE__ */ new Map();
|
|
60392
60515
|
statuses = /* @__PURE__ */ new Map();
|
|
60393
60516
|
errors = /* @__PURE__ */ new Map();
|
|
@@ -60396,13 +60519,90 @@ var McpRegistry = class {
|
|
|
60396
60519
|
panelTools = /* @__PURE__ */ new Map();
|
|
60397
60520
|
logs = /* @__PURE__ */ new Map();
|
|
60398
60521
|
servers = {};
|
|
60399
|
-
constructor(secrets, events, logger, getAlwaysAllowed = () => [], defaultTimeout = void 0, isRepositoryServer = async () => false) {
|
|
60522
|
+
constructor(secrets, events, logger, getAlwaysAllowed = () => [], defaultTimeout = void 0, isRepositoryServer = async () => false, toolCache = void 0) {
|
|
60400
60523
|
this.secrets = secrets;
|
|
60401
60524
|
this.events = events;
|
|
60402
60525
|
this.logger = logger;
|
|
60403
60526
|
this.getAlwaysAllowed = getAlwaysAllowed;
|
|
60404
60527
|
this.defaultTimeout = defaultTimeout;
|
|
60405
60528
|
this.isRepositoryServer = isRepositoryServer;
|
|
60529
|
+
this.toolCache = toolCache;
|
|
60530
|
+
}
|
|
60531
|
+
/** Connections being opened, so two callers asking at once share one start rather than spawning two servers. */
|
|
60532
|
+
connecting = /* @__PURE__ */ new Map();
|
|
60533
|
+
/** Servers whose tools are, for now, the remembered list rather than one the server gave this session. */
|
|
60534
|
+
fromCache = /* @__PURE__ */ new Set();
|
|
60535
|
+
/**
|
|
60536
|
+
* Offers the remembered tools of every enabled server that has not listed its own yet in this session,
|
|
60537
|
+
* when its connection settings are the ones the list was read under. A call to one waits for the server.
|
|
60538
|
+
*/
|
|
60539
|
+
async primeFromCache() {
|
|
60540
|
+
if (this.toolCache === void 0)
|
|
60541
|
+
return;
|
|
60542
|
+
let cached2;
|
|
60543
|
+
try {
|
|
60544
|
+
cached2 = await this.toolCache.read();
|
|
60545
|
+
} catch {
|
|
60546
|
+
return;
|
|
60547
|
+
}
|
|
60548
|
+
for (const [name, config2] of Object.entries(this.servers)) {
|
|
60549
|
+
if (config2.disabled === true || this.toolsByServer.has(name))
|
|
60550
|
+
continue;
|
|
60551
|
+
const entry = cached2[name];
|
|
60552
|
+
if (entry === void 0 || entry.signature !== connectionSignature(config2))
|
|
60553
|
+
continue;
|
|
60554
|
+
this.setTools(name, entry.tools, async () => this.liveConnection(name));
|
|
60555
|
+
this.fromCache.add(name);
|
|
60556
|
+
}
|
|
60557
|
+
}
|
|
60558
|
+
/** The server's connection, started (or waited for) when it is not open yet. Throws with the reason it failed. */
|
|
60559
|
+
async liveConnection(name) {
|
|
60560
|
+
const open = this.connections.get(name);
|
|
60561
|
+
if (open !== void 0)
|
|
60562
|
+
return open;
|
|
60563
|
+
await this.connectServer(name);
|
|
60564
|
+
const connection = this.connections.get(name);
|
|
60565
|
+
if (connection === void 0)
|
|
60566
|
+
throw new Error(`the server did not start${this.errors.has(name) ? `: ${this.errors.get(name) ?? ""}` : ""}`);
|
|
60567
|
+
return connection;
|
|
60568
|
+
}
|
|
60569
|
+
/** Records a server's tools - live or remembered - as tools the loop can call. */
|
|
60570
|
+
setTools(name, listed, connectionFor) {
|
|
60571
|
+
this.panelTools.set(name, new Set(listed.filter((descriptor) => descriptor.panelOnly === true).map((descriptor) => descriptor.name)));
|
|
60572
|
+
const descriptors = listed.filter((descriptor) => descriptor.panelOnly !== true);
|
|
60573
|
+
this.toolsByServer.set(name, descriptors.map((descriptor) => ({
|
|
60574
|
+
descriptor,
|
|
60575
|
+
tool: adaptTool(name, descriptor.name, descriptor.description, descriptor.inputSchema, async (args) => {
|
|
60576
|
+
const decision = denyCheck(descriptor.name, args, this.servers[name]?.deny);
|
|
60577
|
+
if (decision.denied) {
|
|
60578
|
+
this.appendLog(name, decision.message ?? "Refused by a deny rule.");
|
|
60579
|
+
throw new Error(decision.message ?? "Refused by a deny rule.");
|
|
60580
|
+
}
|
|
60581
|
+
return (await connectionFor()).callTool(descriptor.name, args);
|
|
60582
|
+
})
|
|
60583
|
+
})));
|
|
60584
|
+
}
|
|
60585
|
+
/**
|
|
60586
|
+
* Starts every enabled server that is not connected yet and waits only for those this session has no
|
|
60587
|
+
* tools for: a server whose remembered list is offered keeps starting in the background, and a call to it
|
|
60588
|
+
* waits for it then. Waits at most `maxWaitMs` even for the others, so one server that never answers
|
|
60589
|
+
* cannot hold a reply - its tools join the turn after it does. Returns the servers still starting.
|
|
60590
|
+
*/
|
|
60591
|
+
async ensureReady(maxWaitMs = 45e3) {
|
|
60592
|
+
const starting = Object.entries(this.servers).filter(([name, config2]) => config2.disabled !== true && !this.connections.has(name)).map(([name]) => ({ name, done: this.connectServer(name).catch(() => void 0) }));
|
|
60593
|
+
const needed = starting.filter((entry) => !this.toolsByServer.has(entry.name));
|
|
60594
|
+
if (needed.length > 0) {
|
|
60595
|
+
let timer;
|
|
60596
|
+
await Promise.race([
|
|
60597
|
+
Promise.all(needed.map((entry) => entry.done)),
|
|
60598
|
+
new Promise((resolve) => {
|
|
60599
|
+
timer = setTimeout(resolve, maxWaitMs);
|
|
60600
|
+
})
|
|
60601
|
+
]);
|
|
60602
|
+
if (timer !== void 0)
|
|
60603
|
+
clearTimeout(timer);
|
|
60604
|
+
}
|
|
60605
|
+
return starting.filter((entry) => this.statuses.get(entry.name) === "connecting").map((entry) => entry.name);
|
|
60406
60606
|
}
|
|
60407
60607
|
/** Replaces the configured server set, closing any that disappeared or changed. */
|
|
60408
60608
|
async configure(servers) {
|
|
@@ -60420,6 +60620,7 @@ var McpRegistry = class {
|
|
|
60420
60620
|
if (config2.disabled === true) {
|
|
60421
60621
|
this.statuses.set(name, "disabled");
|
|
60422
60622
|
this.toolsByServer.delete(name);
|
|
60623
|
+
this.fromCache.delete(name);
|
|
60423
60624
|
await this.disconnect(name, { silent: true });
|
|
60424
60625
|
} else if (!this.statuses.has(name) || this.statuses.get(name) === "disabled") {
|
|
60425
60626
|
this.statuses.set(name, "idle");
|
|
@@ -60430,15 +60631,17 @@ var McpRegistry = class {
|
|
|
60430
60631
|
this.statuses.delete(name);
|
|
60431
60632
|
this.errors.delete(name);
|
|
60432
60633
|
this.toolsByServer.delete(name);
|
|
60634
|
+
this.fromCache.delete(name);
|
|
60433
60635
|
}
|
|
60434
60636
|
}
|
|
60435
60637
|
for (const name of reconnect) {
|
|
60436
60638
|
const config2 = servers[name];
|
|
60437
60639
|
if (config2 !== void 0 && config2.disabled !== true) {
|
|
60438
|
-
void this.
|
|
60640
|
+
void this.connectServer(name).catch(() => {
|
|
60439
60641
|
});
|
|
60440
60642
|
}
|
|
60441
60643
|
}
|
|
60644
|
+
await this.primeFromCache();
|
|
60442
60645
|
this.events.onStateChanged();
|
|
60443
60646
|
}
|
|
60444
60647
|
/** Warnings the UI should surface before a server is started, e.g. package runners. */
|
|
@@ -60461,14 +60664,22 @@ var McpRegistry = class {
|
|
|
60461
60664
|
async connectServer(name) {
|
|
60462
60665
|
if (this.connections.has(name))
|
|
60463
60666
|
return;
|
|
60667
|
+
const already = this.connecting.get(name);
|
|
60668
|
+
if (already !== void 0)
|
|
60669
|
+
return already;
|
|
60464
60670
|
const config2 = this.servers[name];
|
|
60465
60671
|
if (config2 === void 0 || config2.disabled === true)
|
|
60466
60672
|
return;
|
|
60467
|
-
|
|
60673
|
+
const started = this.connect(name, config2).finally(() => {
|
|
60674
|
+
if (this.connecting.get(name) === started)
|
|
60675
|
+
this.connecting.delete(name);
|
|
60676
|
+
});
|
|
60677
|
+
this.connecting.set(name, started);
|
|
60678
|
+
return started;
|
|
60468
60679
|
}
|
|
60469
60680
|
/** Connects every enabled server that is not connected yet. Failures are per-server. */
|
|
60470
60681
|
async ensureConnected() {
|
|
60471
|
-
await Promise.all(Object.entries(this.servers).filter(([name, config2]) => config2.disabled !== true && !this.connections.has(name)).map(([name
|
|
60682
|
+
await Promise.all(Object.entries(this.servers).filter(([name, config2]) => config2.disabled !== true && !this.connections.has(name)).map(([name]) => this.connectServer(name)));
|
|
60472
60683
|
}
|
|
60473
60684
|
/** Bounded so a chatty server cannot grow this without limit over a long session. */
|
|
60474
60685
|
appendLog(name, line) {
|
|
@@ -60499,14 +60710,20 @@ var McpRegistry = class {
|
|
|
60499
60710
|
this.defaultTimeout,
|
|
60500
60711
|
{ repositoryDefined: await this.isRepositoryServer(name) }
|
|
60501
60712
|
);
|
|
60713
|
+
const startedAt = Date.now();
|
|
60502
60714
|
try {
|
|
60503
60715
|
await connection.connect();
|
|
60504
60716
|
this.connections.set(name, connection);
|
|
60505
60717
|
this.appendLog(name, "Connected.");
|
|
60506
60718
|
await this.refreshTools(name);
|
|
60719
|
+
const seconds = (Date.now() - startedAt) / 1e3;
|
|
60720
|
+
if (seconds >= 2)
|
|
60721
|
+
this.logger?.info(`[startup] MCP server "${name}" took ${seconds.toFixed(1)}s to start and list its tools`);
|
|
60507
60722
|
} catch (error51) {
|
|
60508
60723
|
const message6 = error51 instanceof Error ? error51.message : String(error51);
|
|
60509
|
-
this.
|
|
60724
|
+
if (this.fromCache.delete(name))
|
|
60725
|
+
this.toolsByServer.delete(name);
|
|
60726
|
+
this.logger?.warn(`MCP server "${name}" failed to connect after ${((Date.now() - startedAt) / 1e3).toFixed(1)}s: ${message6}`);
|
|
60510
60727
|
this.statuses.set(name, "failed");
|
|
60511
60728
|
this.errors.set(name, message6);
|
|
60512
60729
|
this.appendLog(name, `Failed: ${message6}`);
|
|
@@ -60519,22 +60736,15 @@ var McpRegistry = class {
|
|
|
60519
60736
|
return;
|
|
60520
60737
|
try {
|
|
60521
60738
|
const listed = await connection.listTools();
|
|
60522
|
-
this.
|
|
60523
|
-
|
|
60524
|
-
this.
|
|
60525
|
-
|
|
60526
|
-
|
|
60527
|
-
|
|
60528
|
-
if (decision.denied) {
|
|
60529
|
-
this.appendLog(name, decision.message ?? "Refused by a deny rule.");
|
|
60530
|
-
throw new Error(decision.message ?? "Refused by a deny rule.");
|
|
60531
|
-
}
|
|
60532
|
-
return connection.callTool(descriptor.name, args);
|
|
60533
|
-
})
|
|
60534
|
-
})));
|
|
60739
|
+
this.setTools(name, listed, async () => connection);
|
|
60740
|
+
this.fromCache.delete(name);
|
|
60741
|
+
const config2 = this.servers[name];
|
|
60742
|
+
if (config2 !== void 0 && this.toolCache !== void 0) {
|
|
60743
|
+
void this.toolCache.write(name, { signature: connectionSignature(config2), tools: listed, at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
60744
|
+
}
|
|
60535
60745
|
this.statuses.set(name, "ready");
|
|
60536
60746
|
this.errors.delete(name);
|
|
60537
|
-
this.appendLog(name, `Discovered ${
|
|
60747
|
+
this.appendLog(name, `Discovered ${listed.filter((descriptor) => descriptor.panelOnly !== true).length} tool(s).`);
|
|
60538
60748
|
} catch (error51) {
|
|
60539
60749
|
this.statuses.set(name, "failed");
|
|
60540
60750
|
this.errors.set(name, error51 instanceof Error ? error51.message : String(error51));
|
|
@@ -60545,6 +60755,7 @@ var McpRegistry = class {
|
|
|
60545
60755
|
await this.connections.get(name)?.close();
|
|
60546
60756
|
this.connections.delete(name);
|
|
60547
60757
|
this.toolsByServer.delete(name);
|
|
60758
|
+
this.fromCache.delete(name);
|
|
60548
60759
|
if (this.servers[name] !== void 0 && this.servers[name]?.disabled !== true) {
|
|
60549
60760
|
this.statuses.set(name, "idle");
|
|
60550
60761
|
}
|
|
@@ -61391,13 +61602,13 @@ function appendSkillImages(body, images) {
|
|
|
61391
61602
|
const trimmed = body.replace(/\s+$/, "");
|
|
61392
61603
|
return [trimmed, "", "## Images", "", ...missing.map(renderSkillImage)].join("\n");
|
|
61393
61604
|
}
|
|
61394
|
-
async function listSkillImages(skillFilePath,
|
|
61605
|
+
async function listSkillImages(skillFilePath, fs48) {
|
|
61395
61606
|
const asPosix = skillFilePath.split(String.fromCharCode(92)).join("/");
|
|
61396
61607
|
if (!asPosix.toLowerCase().endsWith("/skill.md"))
|
|
61397
61608
|
return [];
|
|
61398
61609
|
const dir = `${skillFilePath.slice(0, skillFilePath.length - "SKILL.md".length)}${SKILL_IMAGE_DIR}`;
|
|
61399
61610
|
try {
|
|
61400
|
-
const entries = await
|
|
61611
|
+
const entries = await fs48.readdir(dir);
|
|
61401
61612
|
return entries.filter((entry) => !entry.isDirectory && skillImageType(entry.name) !== void 0).map((entry) => entry.name).sort();
|
|
61402
61613
|
} catch {
|
|
61403
61614
|
return [];
|
|
@@ -61447,12 +61658,12 @@ function skillFilesDir(skillFilePath) {
|
|
|
61447
61658
|
return void 0;
|
|
61448
61659
|
return `${skillFilePath.slice(0, skillFilePath.length - "SKILL.md".length)}${SKILL_FILE_DIR}`;
|
|
61449
61660
|
}
|
|
61450
|
-
async function listSkillFiles(skillFilePath,
|
|
61661
|
+
async function listSkillFiles(skillFilePath, fs48) {
|
|
61451
61662
|
const dir = skillFilesDir(skillFilePath);
|
|
61452
61663
|
if (dir === void 0)
|
|
61453
61664
|
return [];
|
|
61454
61665
|
try {
|
|
61455
|
-
const entries = await
|
|
61666
|
+
const entries = await fs48.readdir(dir);
|
|
61456
61667
|
return entries.filter((entry) => !entry.isDirectory).map((entry) => entry.name).sort();
|
|
61457
61668
|
} catch {
|
|
61458
61669
|
return [];
|
|
@@ -62107,9 +62318,9 @@ function secretRefsFor(section, config2) {
|
|
|
62107
62318
|
}
|
|
62108
62319
|
return refs;
|
|
62109
62320
|
}
|
|
62110
|
-
function getPath2(source,
|
|
62321
|
+
function getPath2(source, path68) {
|
|
62111
62322
|
let value = source;
|
|
62112
|
-
for (const part of
|
|
62323
|
+
for (const part of path68.split(".")) {
|
|
62113
62324
|
if (typeof value !== "object" || value === null)
|
|
62114
62325
|
return void 0;
|
|
62115
62326
|
value = value[part];
|
|
@@ -62123,8 +62334,8 @@ function hasValue(value) {
|
|
|
62123
62334
|
return Object.keys(value).length > 0;
|
|
62124
62335
|
return true;
|
|
62125
62336
|
}
|
|
62126
|
-
function setPath(target,
|
|
62127
|
-
const [head, ...rest] =
|
|
62337
|
+
function setPath(target, path68, value) {
|
|
62338
|
+
const [head, ...rest] = path68.split(".");
|
|
62128
62339
|
if (head === void 0)
|
|
62129
62340
|
return;
|
|
62130
62341
|
if (rest.length === 0) {
|
|
@@ -62144,8 +62355,8 @@ function setPath(target, path66, value) {
|
|
|
62144
62355
|
var NESTED_PATHS = SHARE_SECTIONS.flatMap((section) => section.nested ?? []);
|
|
62145
62356
|
function withoutNested(config2) {
|
|
62146
62357
|
const copy = { ...config2 };
|
|
62147
|
-
for (const
|
|
62148
|
-
setPath(copy,
|
|
62358
|
+
for (const path68 of NESTED_PATHS)
|
|
62359
|
+
setPath(copy, path68, void 0);
|
|
62149
62360
|
return copy;
|
|
62150
62361
|
}
|
|
62151
62362
|
function describeSections(config2) {
|
|
@@ -62154,7 +62365,7 @@ function describeSections(config2) {
|
|
|
62154
62365
|
id: section.id,
|
|
62155
62366
|
label: section.label,
|
|
62156
62367
|
description: section.description,
|
|
62157
|
-
present: section.keys.some((key3) => has(owned, key3)) || (section.nested ?? []).some((
|
|
62368
|
+
present: section.keys.some((key3) => has(owned, key3)) || (section.nested ?? []).some((path68) => hasValue(getPath2(config2, path68))),
|
|
62158
62369
|
detail: detailFor(section, config2),
|
|
62159
62370
|
secretRefs: secretRefsFor(section, config2),
|
|
62160
62371
|
...section.machineSpecific === true ? { machineSpecific: true } : {},
|
|
@@ -62175,18 +62386,18 @@ function buildExport(config2, selected) {
|
|
|
62175
62386
|
if (has(config2, key3))
|
|
62176
62387
|
exported[key3] = config2[key3];
|
|
62177
62388
|
}
|
|
62178
|
-
for (const
|
|
62179
|
-
const value = getPath2(config2,
|
|
62389
|
+
for (const path68 of section.nested ?? []) {
|
|
62390
|
+
const value = getPath2(config2, path68);
|
|
62180
62391
|
if (hasValue(value))
|
|
62181
|
-
setPath(exported,
|
|
62392
|
+
setPath(exported, path68, value);
|
|
62182
62393
|
}
|
|
62183
|
-
for (const
|
|
62184
|
-
stripPath(exported,
|
|
62394
|
+
for (const path68 of section.strip ?? [])
|
|
62395
|
+
stripPath(exported, path68);
|
|
62185
62396
|
}
|
|
62186
62397
|
return exported;
|
|
62187
62398
|
}
|
|
62188
|
-
function stripPath(target,
|
|
62189
|
-
const [head, ...rest] =
|
|
62399
|
+
function stripPath(target, path68) {
|
|
62400
|
+
const [head, ...rest] = path68.split(".");
|
|
62190
62401
|
if (head === void 0)
|
|
62191
62402
|
return;
|
|
62192
62403
|
const value = target[head];
|
|
@@ -62214,22 +62425,22 @@ function applyImport(existing, imported, selected) {
|
|
|
62214
62425
|
else
|
|
62215
62426
|
delete merged[key3];
|
|
62216
62427
|
}
|
|
62217
|
-
for (const
|
|
62218
|
-
carryPath(existing, merged,
|
|
62428
|
+
for (const path68 of section.strip ?? []) {
|
|
62429
|
+
carryPath(existing, merged, path68);
|
|
62219
62430
|
}
|
|
62220
62431
|
}
|
|
62221
62432
|
for (const section of SHARE_SECTIONS) {
|
|
62222
62433
|
if (!chosen.has(section.id))
|
|
62223
62434
|
continue;
|
|
62224
|
-
for (const
|
|
62225
|
-
const value = getPath2(imported,
|
|
62226
|
-
setPath(merged,
|
|
62435
|
+
for (const path68 of section.nested ?? []) {
|
|
62436
|
+
const value = getPath2(imported, path68);
|
|
62437
|
+
setPath(merged, path68, hasValue(value) ? value : void 0);
|
|
62227
62438
|
}
|
|
62228
62439
|
}
|
|
62229
62440
|
return merged;
|
|
62230
62441
|
}
|
|
62231
|
-
function carryPath(from, to,
|
|
62232
|
-
const [head, ...rest] =
|
|
62442
|
+
function carryPath(from, to, path68) {
|
|
62443
|
+
const [head, ...rest] = path68.split(".");
|
|
62233
62444
|
if (head === void 0)
|
|
62234
62445
|
return;
|
|
62235
62446
|
const source = from[head];
|
|
@@ -64682,7 +64893,7 @@ The conversation is longer than this model accepts, and it could not be shortene
|
|
|
64682
64893
|
}
|
|
64683
64894
|
|
|
64684
64895
|
// ../../packages/core/dist/host/bridge.js
|
|
64685
|
-
var
|
|
64896
|
+
var import_node_crypto21 = require("node:crypto");
|
|
64686
64897
|
|
|
64687
64898
|
// ../../packages/core/dist/atlassian/autosysGateway.js
|
|
64688
64899
|
function withBasicCredentials(auth2, headerName, username, password) {
|
|
@@ -64807,7 +65018,7 @@ function gatewayFromSettings(input, stored) {
|
|
|
64807
65018
|
}
|
|
64808
65019
|
|
|
64809
65020
|
// ../../packages/core/dist/host/bridge.js
|
|
64810
|
-
var
|
|
65021
|
+
var import_node_fs14 = require("node:fs");
|
|
64811
65022
|
var import_node_child_process19 = require("node:child_process");
|
|
64812
65023
|
var import_promises31 = __toESM(require("node:fs/promises"), 1);
|
|
64813
65024
|
|
|
@@ -65591,7 +65802,7 @@ function ignoreDecision(rules, relative, isDirectory2, initial) {
|
|
|
65591
65802
|
}
|
|
65592
65803
|
return ignored;
|
|
65593
65804
|
}
|
|
65594
|
-
async function repositoryWideRules(
|
|
65805
|
+
async function repositoryWideRules(fs48, root, globalIgnoreFile) {
|
|
65595
65806
|
const sources = [
|
|
65596
65807
|
globalIgnoreFile ?? import_node_path29.default.join(process.env["XDG_CONFIG_HOME"] ?? import_node_path29.default.join(import_node_os4.default.homedir(), ".config"), "git", "ignore"),
|
|
65597
65808
|
import_node_path29.default.join(root, ".git", "info", "exclude")
|
|
@@ -65599,16 +65810,16 @@ async function repositoryWideRules(fs46, root, globalIgnoreFile) {
|
|
|
65599
65810
|
const rules = [];
|
|
65600
65811
|
for (const source of sources) {
|
|
65601
65812
|
try {
|
|
65602
|
-
rules.push(...parseIgnoreFile(await
|
|
65813
|
+
rules.push(...parseIgnoreFile(await fs48.readFile(source), ""));
|
|
65603
65814
|
} catch {
|
|
65604
65815
|
}
|
|
65605
65816
|
}
|
|
65606
65817
|
return rules;
|
|
65607
65818
|
}
|
|
65608
|
-
async function walkFiles(
|
|
65819
|
+
async function walkFiles(fs48, root, options) {
|
|
65609
65820
|
const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
|
|
65610
65821
|
const files = [];
|
|
65611
|
-
const baseRules = options.includeIgnored ? [] : await repositoryWideRules(
|
|
65822
|
+
const baseRules = options.includeIgnored ? [] : await repositoryWideRules(fs48, root, options.globalIgnoreFile);
|
|
65612
65823
|
const pending = [{ relative: "", rules: baseRules }];
|
|
65613
65824
|
while (pending.length > 0) {
|
|
65614
65825
|
if (options.signal?.aborted === true)
|
|
@@ -65617,14 +65828,14 @@ async function walkFiles(fs46, root, options) {
|
|
|
65617
65828
|
const absolute = relative.length > 0 ? import_node_path29.default.join(root, ...relative.split("/")) : root;
|
|
65618
65829
|
let entries;
|
|
65619
65830
|
try {
|
|
65620
|
-
entries = await
|
|
65831
|
+
entries = await fs48.readdir(absolute);
|
|
65621
65832
|
} catch {
|
|
65622
65833
|
continue;
|
|
65623
65834
|
}
|
|
65624
65835
|
let rules = inherited;
|
|
65625
65836
|
if (!options.includeIgnored && entries.some((entry) => entry.name === ".gitignore" && !entry.isDirectory)) {
|
|
65626
65837
|
try {
|
|
65627
|
-
const text2 = await
|
|
65838
|
+
const text2 = await fs48.readFile(import_node_path29.default.join(absolute, ".gitignore"));
|
|
65628
65839
|
rules = [...inherited, ...parseIgnoreFile(text2, relative)];
|
|
65629
65840
|
} catch {
|
|
65630
65841
|
}
|
|
@@ -65686,12 +65897,12 @@ function fileFilter(filePattern) {
|
|
|
65686
65897
|
const regex = globToRegExp(glob.startsWith("/") ? glob.slice(1) : glob, anchored);
|
|
65687
65898
|
return (relative) => regex.test(relative) !== exclude;
|
|
65688
65899
|
}
|
|
65689
|
-
async function searchFiles(
|
|
65900
|
+
async function searchFiles(fs48, root, options) {
|
|
65690
65901
|
const regex = compilePattern(options.pattern);
|
|
65691
65902
|
const admits = fileFilter(options.filePattern);
|
|
65692
65903
|
const context = options.contextLines ?? 2;
|
|
65693
65904
|
const maxOutput = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT;
|
|
65694
|
-
const { files, truncated: walkTruncated } = await walkFiles(
|
|
65905
|
+
const { files, truncated: walkTruncated } = await walkFiles(fs48, root, options);
|
|
65695
65906
|
const separator = process.platform === "win32" ? "\\" : "/";
|
|
65696
65907
|
const chunks = [];
|
|
65697
65908
|
let size = 0;
|
|
@@ -65704,10 +65915,10 @@ async function searchFiles(fs46, root, options) {
|
|
|
65704
65915
|
const absolute = import_node_path29.default.join(root, ...relative.split("/"));
|
|
65705
65916
|
let bytes;
|
|
65706
65917
|
try {
|
|
65707
|
-
const stat = await
|
|
65918
|
+
const stat = await fs48.stat(absolute);
|
|
65708
65919
|
if (stat.size > MAX_FILE_BYTES)
|
|
65709
65920
|
continue;
|
|
65710
|
-
bytes = await
|
|
65921
|
+
bytes = await fs48.readBytes(absolute);
|
|
65711
65922
|
} catch {
|
|
65712
65923
|
continue;
|
|
65713
65924
|
}
|
|
@@ -67737,8 +67948,8 @@ function pick2(hubs, name) {
|
|
|
67737
67948
|
|
|
67738
67949
|
// ../../packages/core/dist/host/bridge.js
|
|
67739
67950
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
67740
|
-
var
|
|
67741
|
-
var
|
|
67951
|
+
var import_node_fs15 = require("node:fs");
|
|
67952
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
67742
67953
|
|
|
67743
67954
|
// ../../packages/core/dist/modes/autoGuidance.js
|
|
67744
67955
|
function idiomsFor(environment) {
|
|
@@ -69897,8 +70108,8 @@ var ChangeLedger = class {
|
|
|
69897
70108
|
this.chat = chat;
|
|
69898
70109
|
}
|
|
69899
70110
|
/** Best effort: a ledger that cannot be written must never fail an edit that happened. */
|
|
69900
|
-
record(
|
|
69901
|
-
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(
|
|
70111
|
+
record(path68) {
|
|
70112
|
+
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(path68), at: Date.now() });
|
|
69902
70113
|
void (0, import_promises24.appendFile)(this.file, `${line}
|
|
69903
70114
|
`).catch(() => void 0);
|
|
69904
70115
|
}
|
|
@@ -74905,10 +75116,10 @@ function isSafeSegment(value) {
|
|
|
74905
75116
|
function isSafeTagName(name) {
|
|
74906
75117
|
return /^[A-Za-z0-9._/-]+$/.test(name) && !name.startsWith("-") && !name.startsWith("/") && !name.endsWith("/") && !name.endsWith(".") && !name.endsWith(".lock") && !name.includes("..") && !name.includes("//") && !name.split("/").some((part) => part.startsWith("."));
|
|
74907
75118
|
}
|
|
74908
|
-
function encodeRepoPath(
|
|
74909
|
-
const segments =
|
|
75119
|
+
function encodeRepoPath(path68) {
|
|
75120
|
+
const segments = path68.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0);
|
|
74910
75121
|
if (segments.length === 0 || segments.some((segment) => segment === ".." || segment === ".")) {
|
|
74911
|
-
throw new AtlassianError(`"${
|
|
75122
|
+
throw new AtlassianError(`"${path68}" is not a file path inside the repository.`);
|
|
74912
75123
|
}
|
|
74913
75124
|
return segments.map(encodeURIComponent).join("/");
|
|
74914
75125
|
}
|
|
@@ -74993,24 +75204,24 @@ var BitbucketClient = class {
|
|
|
74993
75204
|
* redirect was followed, the login page came back, and the file "could not be read" although
|
|
74994
75205
|
* pull requests on the same repository could. `browse` is REST, so it authenticates like those.
|
|
74995
75206
|
*/
|
|
74996
|
-
async file(repo,
|
|
74997
|
-
const target = encodeRepoPath(
|
|
75207
|
+
async file(repo, path68, ref, signal) {
|
|
75208
|
+
const target = encodeRepoPath(path68);
|
|
74998
75209
|
const lines2 = [];
|
|
74999
75210
|
let start = 0;
|
|
75000
75211
|
for (let page = 0; page < MAX_FILE_PAGES; page += 1) {
|
|
75001
75212
|
const query = new URLSearchParams({ start: String(start), limit: String(FILE_PAGE_LINES) });
|
|
75002
75213
|
if (ref !== void 0 && ref.length > 0)
|
|
75003
75214
|
query.set("at", ref);
|
|
75004
|
-
const body = await this.rest.json(`reading ${
|
|
75215
|
+
const body = await this.rest.json(`reading ${path68}`, `${this.repoPath(repo)}/browse/${target}?${query.toString()}`, { method: "GET" }, signal);
|
|
75005
75216
|
if (body.children !== void 0) {
|
|
75006
75217
|
const names = (body.children.values ?? []).map((child) => {
|
|
75007
75218
|
const name = child.path?.toString ?? child.path?.name ?? "?";
|
|
75008
75219
|
return child.type === "DIRECTORY" ? `${name}/` : name;
|
|
75009
75220
|
});
|
|
75010
|
-
throw new AtlassianError(`${
|
|
75221
|
+
throw new AtlassianError(`${path68} is a folder, not a file. It holds: ${names.join(", ") || "nothing"}.`);
|
|
75011
75222
|
}
|
|
75012
75223
|
if (body.binary === true)
|
|
75013
|
-
throw new AtlassianError(`${
|
|
75224
|
+
throw new AtlassianError(`${path68} is a binary file, so there is no text to read.`);
|
|
75014
75225
|
for (const line of body.lines ?? [])
|
|
75015
75226
|
lines2.push(line.text ?? "");
|
|
75016
75227
|
if (body.isLastPage !== false || body.nextPageStart === void 0 || body.nextPageStart <= start)
|
|
@@ -75121,9 +75332,9 @@ var BitbucketClient = class {
|
|
|
75121
75332
|
return out;
|
|
75122
75333
|
}
|
|
75123
75334
|
/** A file's bytes at `at`, or undefined when it is not there. */
|
|
75124
|
-
async readBytes(repo,
|
|
75335
|
+
async readBytes(repo, path68, at, signal) {
|
|
75125
75336
|
try {
|
|
75126
|
-
return await this.rest.bytes(`reading ${
|
|
75337
|
+
return await this.rest.bytes(`reading ${path68}`, `${this.repoPath(repo)}/raw/${encodeRepoPath(path68)}?${new URLSearchParams({ at }).toString()}`, signal);
|
|
75127
75338
|
} catch (error51) {
|
|
75128
75339
|
if (error51 instanceof AtlassianError && error51.status === 404)
|
|
75129
75340
|
return void 0;
|
|
@@ -75947,8 +76158,8 @@ ${text2.slice(-2e4)}`);
|
|
|
75947
76158
|
}
|
|
75948
76159
|
/** Queues a build, then follows the queue item briefly to learn its number. */
|
|
75949
76160
|
async startBuild(job, parameters, signal) {
|
|
75950
|
-
const
|
|
75951
|
-
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${
|
|
76161
|
+
const path68 = jobPath(job, this.base);
|
|
76162
|
+
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${path68}/buildWithParameters` : `${path68}/build`, parameters ?? {}, signal);
|
|
75952
76163
|
const location = response.headers["location"];
|
|
75953
76164
|
const queueId = location === void 0 ? void 0 : /\/queue\/item\/(\d+)/.exec(location)?.[1];
|
|
75954
76165
|
if (queueId === void 0)
|
|
@@ -75985,10 +76196,10 @@ ${text2.slice(-2e4)}`);
|
|
|
75985
76196
|
}
|
|
75986
76197
|
/** Creates a job from a whole config.xml, in the folder its name gives (`folder/sub/new-job`). */
|
|
75987
76198
|
async createJob(job, xml, signal) {
|
|
75988
|
-
const
|
|
75989
|
-
const cut =
|
|
75990
|
-
const parent =
|
|
75991
|
-
const name = decodeURIComponent(
|
|
76199
|
+
const path68 = jobPath(job, this.base);
|
|
76200
|
+
const cut = path68.lastIndexOf("/job/");
|
|
76201
|
+
const parent = path68.slice(0, cut);
|
|
76202
|
+
const name = decodeURIComponent(path68.slice(cut + "/job/".length));
|
|
75992
76203
|
await this.postBody(`creating ${job}`, `${parent}/createItem?${new URLSearchParams({ name }).toString()}`, xml, "application/xml", signal);
|
|
75993
76204
|
}
|
|
75994
76205
|
/** Replaces a job's config.xml. */
|
|
@@ -76301,14 +76512,14 @@ ${client.base}${jobPath(job, client.base)}/${buildRef(params3.build)}/`
|
|
|
76301
76512
|
};
|
|
76302
76513
|
return tool;
|
|
76303
76514
|
}
|
|
76304
|
-
async function readJenkinsfile(
|
|
76305
|
-
const resolved = await resolveToolPath(context,
|
|
76515
|
+
async function readJenkinsfile(path68, context) {
|
|
76516
|
+
const resolved = await resolveToolPath(context, path68);
|
|
76306
76517
|
if (!resolved.ok)
|
|
76307
76518
|
return { ok: false, message: resolved.message };
|
|
76308
76519
|
try {
|
|
76309
76520
|
return { ok: true, text: await context.fs.readFile(resolved.realPath), realPath: resolved.realPath };
|
|
76310
76521
|
} catch (error51) {
|
|
76311
|
-
return { ok: false, message: `Could not read ${
|
|
76522
|
+
return { ok: false, message: `Could not read ${path68}: ${error51 instanceof Error ? error51.message : String(error51)}` };
|
|
76312
76523
|
}
|
|
76313
76524
|
}
|
|
76314
76525
|
var checkSchema = external_exports.object({
|
|
@@ -77084,9 +77295,9 @@ var AutosysClient = class _AutosysClient {
|
|
|
77084
77295
|
* Something this server may not offer at the documented address: undefined for a 404, so a tool can
|
|
77085
77296
|
* say which setting (`autosys.paths`) points elsewhere, rather than reporting "found nothing".
|
|
77086
77297
|
*/
|
|
77087
|
-
async optional(doing,
|
|
77298
|
+
async optional(doing, path68, signal) {
|
|
77088
77299
|
try {
|
|
77089
|
-
return asList(await this.rest.json(doing,
|
|
77300
|
+
return asList(await this.rest.json(doing, path68, { method: "GET" }, signal));
|
|
77090
77301
|
} catch (error51) {
|
|
77091
77302
|
if (error51 instanceof AtlassianError && error51.status === 404)
|
|
77092
77303
|
return void 0;
|
|
@@ -78389,13 +78600,13 @@ var MonitorHistoryStore = class {
|
|
|
78389
78600
|
if (!isSafeIndexName(index))
|
|
78390
78601
|
throw new MonitorHistoryError(`"${index}" is not a usable index name (lowercase letters, digits, - and _).`);
|
|
78391
78602
|
}
|
|
78392
|
-
async send(method,
|
|
78603
|
+
async send(method, path68, body) {
|
|
78393
78604
|
const headers = { "Content-Type": "application/json" };
|
|
78394
78605
|
const { username, password } = this.connection;
|
|
78395
78606
|
if (username !== void 0 && username.length > 0) {
|
|
78396
78607
|
headers.Authorization = `Basic ${Buffer.from(`${username}:${password ?? ""}`).toString("base64")}`;
|
|
78397
78608
|
}
|
|
78398
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${
|
|
78609
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${path68}`;
|
|
78399
78610
|
const request2 = { method, headers };
|
|
78400
78611
|
if (body !== void 0)
|
|
78401
78612
|
request2.body = JSON.stringify(body);
|
|
@@ -82034,7 +82245,7 @@ function message4(error51) {
|
|
|
82034
82245
|
}
|
|
82035
82246
|
function filesIn(params3) {
|
|
82036
82247
|
return [
|
|
82037
|
-
...(params3.attachments ?? []).map((
|
|
82248
|
+
...(params3.attachments ?? []).map((path68) => ({ path: path68, inline: false })),
|
|
82038
82249
|
...(params3.inlineImages ?? []).map((image) => ({ path: image.path, inline: true }))
|
|
82039
82250
|
];
|
|
82040
82251
|
}
|
|
@@ -82682,6 +82893,110 @@ function isTranscriptMessage(type) {
|
|
|
82682
82893
|
return TRANSCRIPT_MESSAGES.has(type);
|
|
82683
82894
|
}
|
|
82684
82895
|
|
|
82896
|
+
// ../../packages/core/dist/mcp/toolCache.js
|
|
82897
|
+
var import_node_fs8 = require("node:fs");
|
|
82898
|
+
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
82899
|
+
var MAX_SERVERS = 200;
|
|
82900
|
+
function parse3(text2) {
|
|
82901
|
+
const out = {};
|
|
82902
|
+
let raw;
|
|
82903
|
+
try {
|
|
82904
|
+
raw = JSON.parse(text2);
|
|
82905
|
+
} catch {
|
|
82906
|
+
return out;
|
|
82907
|
+
}
|
|
82908
|
+
if (raw === null || typeof raw !== "object")
|
|
82909
|
+
return out;
|
|
82910
|
+
const servers = raw.servers;
|
|
82911
|
+
if (servers === null || typeof servers !== "object")
|
|
82912
|
+
return out;
|
|
82913
|
+
for (const [name, value] of Object.entries(servers)) {
|
|
82914
|
+
if (value === null || typeof value !== "object")
|
|
82915
|
+
continue;
|
|
82916
|
+
const entry = value;
|
|
82917
|
+
if (typeof entry.signature !== "string" || !Array.isArray(entry.tools))
|
|
82918
|
+
continue;
|
|
82919
|
+
const tools = entry.tools.filter((tool) => tool !== null && typeof tool === "object" && typeof tool.name === "string" && typeof tool.description === "string");
|
|
82920
|
+
out[name] = { signature: entry.signature, tools, at: typeof entry.at === "string" ? entry.at : "" };
|
|
82921
|
+
}
|
|
82922
|
+
return out;
|
|
82923
|
+
}
|
|
82924
|
+
function fileMcpToolCache(file2) {
|
|
82925
|
+
let writing = Promise.resolve();
|
|
82926
|
+
const read = async () => {
|
|
82927
|
+
try {
|
|
82928
|
+
return parse3(await import_node_fs8.promises.readFile(file2, "utf8"));
|
|
82929
|
+
} catch {
|
|
82930
|
+
return {};
|
|
82931
|
+
}
|
|
82932
|
+
};
|
|
82933
|
+
return {
|
|
82934
|
+
read,
|
|
82935
|
+
write(server, entry) {
|
|
82936
|
+
writing = writing.then(async () => {
|
|
82937
|
+
const servers = await read();
|
|
82938
|
+
servers[server] = entry;
|
|
82939
|
+
const names = Object.keys(servers);
|
|
82940
|
+
if (names.length > MAX_SERVERS) {
|
|
82941
|
+
names.sort((a, b) => (servers[a]?.at ?? "").localeCompare(servers[b]?.at ?? ""));
|
|
82942
|
+
for (const name of names.slice(0, names.length - MAX_SERVERS))
|
|
82943
|
+
delete servers[name];
|
|
82944
|
+
}
|
|
82945
|
+
await writeFileAtomically(file2, JSON.stringify({ version: 1, servers }));
|
|
82946
|
+
}).catch(() => void 0);
|
|
82947
|
+
return writing;
|
|
82948
|
+
}
|
|
82949
|
+
};
|
|
82950
|
+
}
|
|
82951
|
+
var MCP_TOOL_CACHE_FILE = "mcp-tools.json";
|
|
82952
|
+
function mcpToolCacheFile(dir) {
|
|
82953
|
+
return import_node_path49.default.join(dir, MCP_TOOL_CACHE_FILE);
|
|
82954
|
+
}
|
|
82955
|
+
|
|
82956
|
+
// ../../packages/core/dist/agent/chatSteering.js
|
|
82957
|
+
var import_node_crypto17 = require("node:crypto");
|
|
82958
|
+
var import_node_fs9 = require("node:fs");
|
|
82959
|
+
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
82960
|
+
function pendingSteeringFile(storageDir, workspaceRoot) {
|
|
82961
|
+
const key3 = (0, import_node_crypto17.createHash)("sha256").update(process.platform === "win32" ? import_node_path50.default.resolve(workspaceRoot).toLowerCase() : import_node_path50.default.resolve(workspaceRoot)).digest("hex").slice(0, 16);
|
|
82962
|
+
return import_node_path50.default.join(storageDir, "pending-chat", `${key3}.json`);
|
|
82963
|
+
}
|
|
82964
|
+
async function writePendingSteering(file2, steering) {
|
|
82965
|
+
if (steering.plan === void 0 && steering.strategy === void 0) {
|
|
82966
|
+
await clearPendingSteering(file2);
|
|
82967
|
+
return;
|
|
82968
|
+
}
|
|
82969
|
+
await writeFileAtomically(file2, JSON.stringify({ version: 1, ...steering }));
|
|
82970
|
+
}
|
|
82971
|
+
async function clearPendingSteering(file2) {
|
|
82972
|
+
await import_node_fs9.promises.rm(file2, { force: true }).catch(() => void 0);
|
|
82973
|
+
}
|
|
82974
|
+
async function readPendingSteering(file2) {
|
|
82975
|
+
let raw;
|
|
82976
|
+
try {
|
|
82977
|
+
raw = JSON.parse(await import_node_fs9.promises.readFile(file2, "utf8"));
|
|
82978
|
+
} catch {
|
|
82979
|
+
return void 0;
|
|
82980
|
+
}
|
|
82981
|
+
if (raw === null || typeof raw !== "object")
|
|
82982
|
+
return void 0;
|
|
82983
|
+
const value = raw;
|
|
82984
|
+
const out = {};
|
|
82985
|
+
if (typeof value["plan"] === "string" && value["plan"].trim().length > 0)
|
|
82986
|
+
out.plan = value["plan"];
|
|
82987
|
+
if (value["planProgress"] !== null && typeof value["planProgress"] === "object")
|
|
82988
|
+
out.planProgress = value["planProgress"];
|
|
82989
|
+
const strategy = strategySchema.safeParse(value["strategy"]);
|
|
82990
|
+
if (strategy.success) {
|
|
82991
|
+
out.strategy = strategy.data;
|
|
82992
|
+
if (value["strategyProgress"] !== null && typeof value["strategyProgress"] === "object")
|
|
82993
|
+
out.strategyProgress = value["strategyProgress"];
|
|
82994
|
+
if (Array.isArray(value["strategyExchanges"]))
|
|
82995
|
+
out.strategyExchanges = value["strategyExchanges"];
|
|
82996
|
+
}
|
|
82997
|
+
return out.plan === void 0 && out.strategy === void 0 ? void 0 : out;
|
|
82998
|
+
}
|
|
82999
|
+
|
|
82685
83000
|
// ../../packages/core/dist/host/approvalGate.js
|
|
82686
83001
|
var WebviewApprovalGate = class {
|
|
82687
83002
|
post;
|
|
@@ -82732,17 +83047,17 @@ var WebviewApprovalGate = class {
|
|
|
82732
83047
|
// ../../packages/core/dist/platform/node/filesystem.js
|
|
82733
83048
|
var import_promises29 = __toESM(require("node:fs/promises"), 1);
|
|
82734
83049
|
var NodeFileSystem = class {
|
|
82735
|
-
async readFile(
|
|
82736
|
-
return import_promises29.default.readFile(
|
|
83050
|
+
async readFile(path68) {
|
|
83051
|
+
return import_promises29.default.readFile(path68, "utf8");
|
|
82737
83052
|
}
|
|
82738
|
-
async readBytes(
|
|
82739
|
-
return import_promises29.default.readFile(
|
|
83053
|
+
async readBytes(path68) {
|
|
83054
|
+
return import_promises29.default.readFile(path68);
|
|
82740
83055
|
}
|
|
82741
|
-
async readBytesSlice(
|
|
83056
|
+
async readBytesSlice(path68, start, end) {
|
|
82742
83057
|
const length = Math.max(0, end - start);
|
|
82743
83058
|
if (length === 0)
|
|
82744
83059
|
return Buffer.alloc(0);
|
|
82745
|
-
const handle = await import_promises29.default.open(
|
|
83060
|
+
const handle = await import_promises29.default.open(path68, "r");
|
|
82746
83061
|
try {
|
|
82747
83062
|
const buffer = Buffer.alloc(length);
|
|
82748
83063
|
const { bytesRead } = await handle.read(buffer, 0, length, start);
|
|
@@ -82751,18 +83066,18 @@ var NodeFileSystem = class {
|
|
|
82751
83066
|
await handle.close();
|
|
82752
83067
|
}
|
|
82753
83068
|
}
|
|
82754
|
-
async writeFile(
|
|
82755
|
-
await import_promises29.default.writeFile(
|
|
83069
|
+
async writeFile(path68, contents) {
|
|
83070
|
+
await import_promises29.default.writeFile(path68, contents, "utf8");
|
|
82756
83071
|
}
|
|
82757
83072
|
/** The counterpart of `readBytes`, and deliberately as bare as `writeFile` beside it. */
|
|
82758
|
-
async writeBytes(
|
|
82759
|
-
await import_promises29.default.writeFile(
|
|
83073
|
+
async writeBytes(path68, contents) {
|
|
83074
|
+
await import_promises29.default.writeFile(path68, contents);
|
|
82760
83075
|
}
|
|
82761
83076
|
async rename(from, to) {
|
|
82762
83077
|
await replaceFile(from, to);
|
|
82763
83078
|
}
|
|
82764
|
-
async stat(
|
|
82765
|
-
const stat = await import_promises29.default.lstat(
|
|
83079
|
+
async stat(path68) {
|
|
83080
|
+
const stat = await import_promises29.default.lstat(path68);
|
|
82766
83081
|
return {
|
|
82767
83082
|
size: stat.size,
|
|
82768
83083
|
mtimeMs: stat.mtimeMs,
|
|
@@ -82771,8 +83086,8 @@ var NodeFileSystem = class {
|
|
|
82771
83086
|
isSymbolicLink: stat.isSymbolicLink()
|
|
82772
83087
|
};
|
|
82773
83088
|
}
|
|
82774
|
-
async readdir(
|
|
82775
|
-
const entries = await import_promises29.default.readdir(
|
|
83089
|
+
async readdir(path68) {
|
|
83090
|
+
const entries = await import_promises29.default.readdir(path68, { withFileTypes: true });
|
|
82776
83091
|
return entries.map((entry) => ({
|
|
82777
83092
|
name: entry.name,
|
|
82778
83093
|
isFile: entry.isFile(),
|
|
@@ -82780,21 +83095,21 @@ var NodeFileSystem = class {
|
|
|
82780
83095
|
isSymbolicLink: entry.isSymbolicLink()
|
|
82781
83096
|
}));
|
|
82782
83097
|
}
|
|
82783
|
-
async exists(
|
|
83098
|
+
async exists(path68) {
|
|
82784
83099
|
try {
|
|
82785
|
-
await import_promises29.default.access(
|
|
83100
|
+
await import_promises29.default.access(path68);
|
|
82786
83101
|
return true;
|
|
82787
83102
|
} catch {
|
|
82788
83103
|
return false;
|
|
82789
83104
|
}
|
|
82790
83105
|
}
|
|
82791
|
-
async mkdir(
|
|
82792
|
-
await import_promises29.default.mkdir(
|
|
83106
|
+
async mkdir(path68) {
|
|
83107
|
+
await import_promises29.default.mkdir(path68, { recursive: true });
|
|
82793
83108
|
}
|
|
82794
83109
|
};
|
|
82795
83110
|
|
|
82796
83111
|
// ../../packages/core/dist/config/project.js
|
|
82797
|
-
var
|
|
83112
|
+
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
82798
83113
|
function configuredProjectName(config2) {
|
|
82799
83114
|
const name = config2?.project?.name?.trim();
|
|
82800
83115
|
return name !== void 0 && name.length > 0 ? name : void 0;
|
|
@@ -82803,7 +83118,7 @@ function projectName(config2, workspaceRoot) {
|
|
|
82803
83118
|
const configured = configuredProjectName(config2);
|
|
82804
83119
|
if (configured !== void 0)
|
|
82805
83120
|
return configured;
|
|
82806
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
83121
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path51.default.basename(import_node_path51.default.resolve(workspaceRoot));
|
|
82807
83122
|
}
|
|
82808
83123
|
function projectSlug(name) {
|
|
82809
83124
|
if (name === void 0)
|
|
@@ -82813,8 +83128,8 @@ function projectSlug(name) {
|
|
|
82813
83128
|
}
|
|
82814
83129
|
|
|
82815
83130
|
// ../../packages/core/dist/rag/renameIndexes.js
|
|
82816
|
-
var
|
|
82817
|
-
var
|
|
83131
|
+
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
83132
|
+
var import_node_fs10 = require("node:fs");
|
|
82818
83133
|
function planIndexRenames(names) {
|
|
82819
83134
|
const plans = [];
|
|
82820
83135
|
for (const kind of ["codebase", "docs", "skills"]) {
|
|
@@ -82866,7 +83181,7 @@ async function copyIndex(options) {
|
|
|
82866
83181
|
async function copyBookkeeping(directory, from, to, storeId) {
|
|
82867
83182
|
let entries;
|
|
82868
83183
|
try {
|
|
82869
|
-
entries = await
|
|
83184
|
+
entries = await import_node_fs10.promises.readdir(directory);
|
|
82870
83185
|
} catch {
|
|
82871
83186
|
return [];
|
|
82872
83187
|
}
|
|
@@ -82877,7 +83192,7 @@ async function copyBookkeeping(directory, from, to, storeId) {
|
|
|
82877
83192
|
continue;
|
|
82878
83193
|
const target = `${to}@${storeId}.${entry.slice(prefix.length)}`;
|
|
82879
83194
|
try {
|
|
82880
|
-
await
|
|
83195
|
+
await import_node_fs10.promises.copyFile(import_node_path52.default.join(directory, entry), import_node_path52.default.join(directory, target), import_node_fs10.constants.COPYFILE_EXCL);
|
|
82881
83196
|
copied.push(target);
|
|
82882
83197
|
} catch {
|
|
82883
83198
|
}
|
|
@@ -82966,7 +83281,7 @@ var NodeTerminal = class {
|
|
|
82966
83281
|
|
|
82967
83282
|
// ../../packages/core/dist/platform/node/taskStore.js
|
|
82968
83283
|
var import_promises30 = __toESM(require("node:fs/promises"), 1);
|
|
82969
|
-
var
|
|
83284
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
82970
83285
|
|
|
82971
83286
|
// ../../packages/core/dist/history/types.js
|
|
82972
83287
|
function taskSummary(task) {
|
|
@@ -82989,7 +83304,7 @@ var JsonTaskStore = class {
|
|
|
82989
83304
|
constructor(globalStoragePath, truncationStore, logger) {
|
|
82990
83305
|
this.truncationStore = truncationStore;
|
|
82991
83306
|
this.logger = logger;
|
|
82992
|
-
this.directory =
|
|
83307
|
+
this.directory = import_node_path53.default.join(globalStoragePath, "tasks");
|
|
82993
83308
|
}
|
|
82994
83309
|
async list(workspaceRoot) {
|
|
82995
83310
|
const index = await this.readIndex();
|
|
@@ -83038,11 +83353,11 @@ var JsonTaskStore = class {
|
|
|
83038
83353
|
await this.writeIndex(index.filter((entry) => entry.id !== id));
|
|
83039
83354
|
}
|
|
83040
83355
|
fileFor(id) {
|
|
83041
|
-
return
|
|
83356
|
+
return import_node_path53.default.join(this.directory, `${id}.json`);
|
|
83042
83357
|
}
|
|
83043
83358
|
async readIndex() {
|
|
83044
83359
|
try {
|
|
83045
|
-
const raw = await import_promises30.default.readFile(
|
|
83360
|
+
const raw = await import_promises30.default.readFile(import_node_path53.default.join(this.directory, INDEX_FILE), "utf8");
|
|
83046
83361
|
const parsed = JSON.parse(raw);
|
|
83047
83362
|
if (Array.isArray(parsed))
|
|
83048
83363
|
return parsed.filter(isIndexEntry);
|
|
@@ -83077,7 +83392,7 @@ var JsonTaskStore = class {
|
|
|
83077
83392
|
}
|
|
83078
83393
|
async writeIndex(entries) {
|
|
83079
83394
|
await import_promises30.default.mkdir(this.directory, { recursive: true });
|
|
83080
|
-
const target =
|
|
83395
|
+
const target = import_node_path53.default.join(this.directory, INDEX_FILE);
|
|
83081
83396
|
const temporary = `${target}.tmp`;
|
|
83082
83397
|
await import_promises30.default.writeFile(temporary, JSON.stringify(entries, null, 2), "utf8");
|
|
83083
83398
|
await replaceFile(temporary, target);
|
|
@@ -83121,8 +83436,8 @@ function isRecord3(value) {
|
|
|
83121
83436
|
}
|
|
83122
83437
|
|
|
83123
83438
|
// ../../packages/core/dist/usage/store.js
|
|
83124
|
-
var
|
|
83125
|
-
var
|
|
83439
|
+
var import_node_fs11 = require("node:fs");
|
|
83440
|
+
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
83126
83441
|
|
|
83127
83442
|
// ../../packages/core/dist/s3/keys.js
|
|
83128
83443
|
function normalisePrefix(prefix) {
|
|
@@ -83255,7 +83570,7 @@ var FolderShardStore = class {
|
|
|
83255
83570
|
await this.ask({ action: "write", user: shardSegment(shard.user), day: shard.day, instance: shard.instance, events });
|
|
83256
83571
|
return;
|
|
83257
83572
|
}
|
|
83258
|
-
await this.writeAtomically(
|
|
83573
|
+
await this.writeAtomically(import_node_path54.default.join(this.root, shardSegment(shard.user), `${shard.day}__${shard.instance}.jsonl`), shardText(events));
|
|
83259
83574
|
}
|
|
83260
83575
|
async read(fromDay, toDay) {
|
|
83261
83576
|
this.lastProblems = [];
|
|
@@ -83275,8 +83590,8 @@ var FolderShardStore = class {
|
|
|
83275
83590
|
}
|
|
83276
83591
|
const files = await this.listFiles();
|
|
83277
83592
|
const wanted = selectShards(files, fromDay, toDay);
|
|
83278
|
-
const texts = await pooled(wanted, 8, (file2) =>
|
|
83279
|
-
this.lastProblems.push(`${
|
|
83593
|
+
const texts = await pooled(wanted, 8, (file2) => import_node_fs11.promises.readFile(import_node_path54.default.join(this.root, file2.user, file2.name), "utf8").catch((error51) => {
|
|
83594
|
+
this.lastProblems.push(`${import_node_path54.default.join(this.root, file2.user, file2.name)}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
83280
83595
|
return "";
|
|
83281
83596
|
}));
|
|
83282
83597
|
return texts.flatMap(parseUsageLines);
|
|
@@ -83285,7 +83600,7 @@ var FolderShardStore = class {
|
|
|
83285
83600
|
async listFiles() {
|
|
83286
83601
|
let users;
|
|
83287
83602
|
try {
|
|
83288
|
-
users = (await
|
|
83603
|
+
users = (await import_node_fs11.promises.readdir(this.root, { withFileTypes: true })).filter((entry) => entry.isDirectory() && entry.name !== "_profiles").map((entry) => entry.name);
|
|
83289
83604
|
} catch (error51) {
|
|
83290
83605
|
if (error51.code === "ENOENT")
|
|
83291
83606
|
return [];
|
|
@@ -83293,10 +83608,10 @@ var FolderShardStore = class {
|
|
|
83293
83608
|
}
|
|
83294
83609
|
const files = [];
|
|
83295
83610
|
for (const user of users) {
|
|
83296
|
-
const folder =
|
|
83611
|
+
const folder = import_node_path54.default.join(this.root, user);
|
|
83297
83612
|
let names;
|
|
83298
83613
|
try {
|
|
83299
|
-
names = await
|
|
83614
|
+
names = await import_node_fs11.promises.readdir(folder);
|
|
83300
83615
|
} catch (error51) {
|
|
83301
83616
|
names = [];
|
|
83302
83617
|
this.lastProblems.push(`${folder}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -83312,7 +83627,7 @@ var FolderShardStore = class {
|
|
|
83312
83627
|
}
|
|
83313
83628
|
async readShard(shard) {
|
|
83314
83629
|
try {
|
|
83315
|
-
return parseUsageLines(await
|
|
83630
|
+
return parseUsageLines(await import_node_fs11.promises.readFile(import_node_path54.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), "utf8"));
|
|
83316
83631
|
} catch (error51) {
|
|
83317
83632
|
if (error51.code === "ENOENT")
|
|
83318
83633
|
return void 0;
|
|
@@ -83320,10 +83635,10 @@ var FolderShardStore = class {
|
|
|
83320
83635
|
}
|
|
83321
83636
|
}
|
|
83322
83637
|
async putMonth(shard, events) {
|
|
83323
|
-
await this.writeAtomically(
|
|
83638
|
+
await this.writeAtomically(import_node_path54.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), shardText(events));
|
|
83324
83639
|
}
|
|
83325
83640
|
async removeShard(shard) {
|
|
83326
|
-
await
|
|
83641
|
+
await import_node_fs11.promises.rm(import_node_path54.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), { force: true });
|
|
83327
83642
|
}
|
|
83328
83643
|
async putProfile(user, profile) {
|
|
83329
83644
|
this.profilesFromRead = void 0;
|
|
@@ -83331,7 +83646,7 @@ var FolderShardStore = class {
|
|
|
83331
83646
|
await this.ask({ action: "writeProfile", user: shardSegment(user), profile: cleanProfile(profile) });
|
|
83332
83647
|
return;
|
|
83333
83648
|
}
|
|
83334
|
-
await this.writeAtomically(
|
|
83649
|
+
await this.writeAtomically(import_node_path54.default.join(this.root, "_profiles", `${shardSegment(user)}.json`), JSON.stringify(cleanProfile(profile)));
|
|
83335
83650
|
}
|
|
83336
83651
|
async readProfiles() {
|
|
83337
83652
|
if (this.profilesFromRead !== void 0)
|
|
@@ -83340,13 +83655,13 @@ var FolderShardStore = class {
|
|
|
83340
83655
|
await this.read("9999-12-31", "9999-12-31");
|
|
83341
83656
|
return this.profilesFromRead ?? {};
|
|
83342
83657
|
}
|
|
83343
|
-
const folder =
|
|
83658
|
+
const folder = import_node_path54.default.join(this.root, "_profiles");
|
|
83344
83659
|
const profiles = {};
|
|
83345
|
-
for (const name of await
|
|
83660
|
+
for (const name of await import_node_fs11.promises.readdir(folder).catch(() => [])) {
|
|
83346
83661
|
if (!name.endsWith(".json"))
|
|
83347
83662
|
continue;
|
|
83348
83663
|
try {
|
|
83349
|
-
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await
|
|
83664
|
+
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs11.promises.readFile(import_node_path54.default.join(folder, name), "utf8")));
|
|
83350
83665
|
} catch {
|
|
83351
83666
|
}
|
|
83352
83667
|
}
|
|
@@ -84161,8 +84476,8 @@ function usageCollectionOn(config2, choice) {
|
|
|
84161
84476
|
}
|
|
84162
84477
|
|
|
84163
84478
|
// ../../packages/core/dist/usage/backfill.js
|
|
84164
|
-
var
|
|
84165
|
-
var
|
|
84479
|
+
var import_node_fs12 = require("node:fs");
|
|
84480
|
+
var import_node_path55 = __toESM(require("node:path"), 1);
|
|
84166
84481
|
function comparablePath(value) {
|
|
84167
84482
|
return value.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
84168
84483
|
}
|
|
@@ -84172,7 +84487,7 @@ function eventsFromTask(task, context) {
|
|
|
84172
84487
|
return [];
|
|
84173
84488
|
const created = typeof task.createdAt === "number" && task.createdAt <= updated ? task.createdAt : updated;
|
|
84174
84489
|
const root = typeof task.workspaceRoot === "string" ? task.workspaceRoot : void 0;
|
|
84175
|
-
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ?
|
|
84490
|
+
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ? import_node_path55.default.basename(root.replace(/\\/g, "/")) : void 0;
|
|
84176
84491
|
const skillsByPath = new Map(context.skills.map((skill) => [comparablePath(skill.filePath), skill]));
|
|
84177
84492
|
const skip = new Set(context.skip);
|
|
84178
84493
|
const calls = [];
|
|
@@ -84209,7 +84524,7 @@ function eventsFromTask(task, context) {
|
|
|
84209
84524
|
let skill;
|
|
84210
84525
|
if (call.name === "read_file" && typeof call.args["path"] === "string") {
|
|
84211
84526
|
const requested2 = call.args["path"];
|
|
84212
|
-
const absolute =
|
|
84527
|
+
const absolute = import_node_path55.default.isAbsolute(requested2) || /^[A-Za-z]:[\\/]/.test(requested2) || root === void 0 ? requested2 : import_node_path55.default.join(root, requested2);
|
|
84213
84528
|
skill = skillsByPath.get(comparablePath(absolute));
|
|
84214
84529
|
}
|
|
84215
84530
|
if (call.name === "use_skill_file" && typeof call.args["skill"] === "string") {
|
|
@@ -84246,7 +84561,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
84246
84561
|
}
|
|
84247
84562
|
let names;
|
|
84248
84563
|
try {
|
|
84249
|
-
names = (await
|
|
84564
|
+
names = (await import_node_fs12.promises.readdir(tasksDir)).filter((name) => name.endsWith(".json") && name !== "index.json");
|
|
84250
84565
|
} catch {
|
|
84251
84566
|
return { events: [], tasks: 0, unreadable: 0, via: "node" };
|
|
84252
84567
|
}
|
|
@@ -84254,7 +84569,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
84254
84569
|
let unreadable = 0;
|
|
84255
84570
|
for (const name of names) {
|
|
84256
84571
|
try {
|
|
84257
|
-
events.push(...eventsFromTask(JSON.parse(await
|
|
84572
|
+
events.push(...eventsFromTask(JSON.parse(await import_node_fs12.promises.readFile(import_node_path55.default.join(tasksDir, name), "utf8")), context));
|
|
84258
84573
|
} catch {
|
|
84259
84574
|
unreadable++;
|
|
84260
84575
|
}
|
|
@@ -84262,24 +84577,24 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
84262
84577
|
return { events, tasks: names.length, unreadable, via: "node" };
|
|
84263
84578
|
}
|
|
84264
84579
|
async function backfillOnce(options) {
|
|
84265
|
-
const doneFile =
|
|
84580
|
+
const doneFile = import_node_path55.default.join(options.usageDir, "backfill.json");
|
|
84266
84581
|
for (const file2 of [doneFile, ...options.legacyDoneFile !== void 0 ? [options.legacyDoneFile] : []]) {
|
|
84267
|
-
if (await
|
|
84582
|
+
if (await import_node_fs12.promises.stat(file2).then(() => true, () => false))
|
|
84268
84583
|
return { ran: false };
|
|
84269
84584
|
}
|
|
84270
|
-
await
|
|
84271
|
-
const startFile =
|
|
84585
|
+
await import_node_fs12.promises.mkdir(options.usageDir, { recursive: true });
|
|
84586
|
+
const startFile = import_node_path55.default.join(options.usageDir, "backfill-start.json");
|
|
84272
84587
|
let before;
|
|
84273
84588
|
try {
|
|
84274
84589
|
before = (options.now ?? Date.now)();
|
|
84275
|
-
await
|
|
84590
|
+
await import_node_fs12.promises.writeFile(startFile, JSON.stringify({ before }), { encoding: "utf8", flag: "wx" });
|
|
84276
84591
|
} catch (error51) {
|
|
84277
84592
|
if (error51.code !== "EEXIST")
|
|
84278
84593
|
throw error51;
|
|
84279
84594
|
let claimed;
|
|
84280
84595
|
for (let attempt = 0; attempt < 40 && claimed === void 0; attempt++) {
|
|
84281
84596
|
try {
|
|
84282
|
-
const parsed = JSON.parse(await
|
|
84597
|
+
const parsed = JSON.parse(await import_node_fs12.promises.readFile(startFile, "utf8"));
|
|
84283
84598
|
if (typeof parsed.before === "number")
|
|
84284
84599
|
claimed = parsed.before;
|
|
84285
84600
|
} catch {
|
|
@@ -84316,12 +84631,12 @@ var params = external_exports.object({
|
|
|
84316
84631
|
limit: external_exports.number().int().min(1).max(2e5).optional().describe("events: at most this many rows, newest first (default 20000).")
|
|
84317
84632
|
});
|
|
84318
84633
|
function statsRange(input, now = Date.now()) {
|
|
84319
|
-
const
|
|
84320
|
-
const to = input.to !== void 0 ?
|
|
84634
|
+
const parse4 = (value, endOfDay) => Date.parse(`${value}T${endOfDay ? "23:59:59.999" : "00:00:00"}Z`);
|
|
84635
|
+
const to = input.to !== void 0 ? parse4(input.to, true) : now;
|
|
84321
84636
|
if (!Number.isFinite(to))
|
|
84322
84637
|
return { problem: `"${String(input.to)}" is not a date. Use YYYY-MM-DD.` };
|
|
84323
84638
|
if (input.from !== void 0) {
|
|
84324
|
-
const from =
|
|
84639
|
+
const from = parse4(input.from, false);
|
|
84325
84640
|
if (!Number.isFinite(from))
|
|
84326
84641
|
return { problem: `"${input.from}" is not a date. Use YYYY-MM-DD.` };
|
|
84327
84642
|
if (from > to)
|
|
@@ -84574,7 +84889,7 @@ async function lookupDirectory(names, options = {}) {
|
|
|
84574
84889
|
}
|
|
84575
84890
|
|
|
84576
84891
|
// ../../packages/core/dist/observers/auditIndex.js
|
|
84577
|
-
var
|
|
84892
|
+
var import_node_crypto18 = require("node:crypto");
|
|
84578
84893
|
var MAPPING2 = {
|
|
84579
84894
|
mappings: {
|
|
84580
84895
|
dynamic: false,
|
|
@@ -84622,7 +84937,7 @@ function recordText(record2) {
|
|
|
84622
84937
|
return parts.join("\n").slice(0, 2e4);
|
|
84623
84938
|
}
|
|
84624
84939
|
function recordId(record2) {
|
|
84625
|
-
return (0,
|
|
84940
|
+
return (0, import_node_crypto18.createHash)("sha256").update(JSON.stringify(record2)).digest("hex").slice(0, 32);
|
|
84626
84941
|
}
|
|
84627
84942
|
var AuditIndex = class {
|
|
84628
84943
|
http;
|
|
@@ -84636,13 +84951,13 @@ var AuditIndex = class {
|
|
|
84636
84951
|
if (!isSafeIndexName(index))
|
|
84637
84952
|
throw new Error(`"${index}" is not a usable index name (lowercase letters, digits, - and _).`);
|
|
84638
84953
|
}
|
|
84639
|
-
async send(method,
|
|
84954
|
+
async send(method, path68, body, contentType2 = "application/json") {
|
|
84640
84955
|
const headers = { "Content-Type": contentType2 };
|
|
84641
84956
|
const { username, password } = this.connection;
|
|
84642
84957
|
if (username !== void 0 && username.length > 0) {
|
|
84643
84958
|
headers.Authorization = `Basic ${Buffer.from(`${username}:${password ?? ""}`).toString("base64")}`;
|
|
84644
84959
|
}
|
|
84645
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${
|
|
84960
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${path68}`;
|
|
84646
84961
|
const request2 = { method, headers };
|
|
84647
84962
|
if (body !== void 0)
|
|
84648
84963
|
request2.body = body;
|
|
@@ -84736,20 +85051,20 @@ var AuditIndex = class {
|
|
|
84736
85051
|
};
|
|
84737
85052
|
|
|
84738
85053
|
// ../../packages/core/dist/observers/journal.js
|
|
84739
|
-
var
|
|
84740
|
-
var
|
|
84741
|
-
var
|
|
85054
|
+
var import_node_crypto19 = require("node:crypto");
|
|
85055
|
+
var import_node_fs13 = require("node:fs");
|
|
85056
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
84742
85057
|
function auditRoot(storageDir) {
|
|
84743
|
-
return
|
|
85058
|
+
return import_node_path56.default.join(storageDir, "audit");
|
|
84744
85059
|
}
|
|
84745
85060
|
function workspaceAuditFolder(workspace) {
|
|
84746
|
-
const resolved =
|
|
85061
|
+
const resolved = import_node_path56.default.resolve(workspace);
|
|
84747
85062
|
const key3 = process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
84748
|
-
const base =
|
|
84749
|
-
return `${base}-${(0,
|
|
85063
|
+
const base = import_node_path56.default.basename(key3).replace(/[^A-Za-z0-9._-]+/g, "-").slice(0, 40) || "workspace";
|
|
85064
|
+
return `${base}-${(0, import_node_crypto19.createHash)("sha256").update(key3).digest("hex").slice(0, 10)}`;
|
|
84750
85065
|
}
|
|
84751
85066
|
function newSessionId() {
|
|
84752
|
-
return `${Date.now().toString(36)}-${(0,
|
|
85067
|
+
return `${Date.now().toString(36)}-${(0, import_node_crypto19.randomBytes)(4).toString("hex")}`;
|
|
84753
85068
|
}
|
|
84754
85069
|
function day(at) {
|
|
84755
85070
|
const d = new Date(at);
|
|
@@ -84761,17 +85076,17 @@ var AuditJournal = class {
|
|
|
84761
85076
|
folder;
|
|
84762
85077
|
constructor(storageDir, workspace, session) {
|
|
84763
85078
|
this.session = session;
|
|
84764
|
-
this.folder =
|
|
85079
|
+
this.folder = import_node_path56.default.join(auditRoot(storageDir), workspaceAuditFolder(workspace));
|
|
84765
85080
|
}
|
|
84766
85081
|
/** Appends in order; a failure is reported to `onError` and never blocks the next record. */
|
|
84767
85082
|
append(record2, onError) {
|
|
84768
85083
|
const line = `${JSON.stringify(record2)}
|
|
84769
85084
|
`;
|
|
84770
|
-
const file2 =
|
|
85085
|
+
const file2 = import_node_path56.default.join(this.folder, `${day(record2.at)}__${this.session}.jsonl`);
|
|
84771
85086
|
this.chain = this.chain.then(async () => {
|
|
84772
85087
|
try {
|
|
84773
|
-
await
|
|
84774
|
-
await
|
|
85088
|
+
await import_node_fs13.promises.mkdir(this.folder, { recursive: true });
|
|
85089
|
+
await import_node_fs13.promises.appendFile(file2, line, "utf8");
|
|
84775
85090
|
} catch (error51) {
|
|
84776
85091
|
onError(error51);
|
|
84777
85092
|
}
|
|
@@ -84787,11 +85102,11 @@ async function pruneAudit(storageDir, days, now = Date.now()) {
|
|
|
84787
85102
|
const cutoff = day(now - days * 864e5);
|
|
84788
85103
|
let removed = 0;
|
|
84789
85104
|
const root = auditRoot(storageDir);
|
|
84790
|
-
for (const folder of await
|
|
84791
|
-
for (const name of await
|
|
85105
|
+
for (const folder of await import_node_fs13.promises.readdir(root).catch(() => [])) {
|
|
85106
|
+
for (const name of await import_node_fs13.promises.readdir(import_node_path56.default.join(root, folder)).catch(() => [])) {
|
|
84792
85107
|
const fileDay = /^(\d{4}-\d{2}-\d{2})__/.exec(name)?.[1];
|
|
84793
85108
|
if (fileDay !== void 0 && fileDay < cutoff) {
|
|
84794
|
-
await
|
|
85109
|
+
await import_node_fs13.promises.rm(import_node_path56.default.join(root, folder, name), { force: true }).then(() => removed += 1, () => void 0);
|
|
84795
85110
|
}
|
|
84796
85111
|
}
|
|
84797
85112
|
}
|
|
@@ -84799,12 +85114,12 @@ async function pruneAudit(storageDir, days, now = Date.now()) {
|
|
|
84799
85114
|
}
|
|
84800
85115
|
async function readAudit(storageDir, workspace, query) {
|
|
84801
85116
|
const root = auditRoot(storageDir);
|
|
84802
|
-
const folders = query.allWorkspaces === true || workspace === void 0 ? await
|
|
85117
|
+
const folders = query.allWorkspaces === true || workspace === void 0 ? await import_node_fs13.promises.readdir(root).catch(() => []) : [workspaceAuditFolder(workspace)];
|
|
84803
85118
|
const fromDay = query.from !== void 0 ? day(query.from) : void 0;
|
|
84804
85119
|
const untilDay = query.until !== void 0 ? day(query.until) : void 0;
|
|
84805
85120
|
const files = [];
|
|
84806
85121
|
for (const folder of folders) {
|
|
84807
|
-
for (const name of await
|
|
85122
|
+
for (const name of await import_node_fs13.promises.readdir(import_node_path56.default.join(root, folder)).catch(() => [])) {
|
|
84808
85123
|
const fileDay = /^(\d{4}-\d{2}-\d{2})__(.+)\.jsonl$/.exec(name);
|
|
84809
85124
|
if (fileDay === null)
|
|
84810
85125
|
continue;
|
|
@@ -84814,7 +85129,7 @@ async function readAudit(storageDir, workspace, query) {
|
|
|
84814
85129
|
continue;
|
|
84815
85130
|
if (query.session !== void 0 && fileDay[2] !== query.session)
|
|
84816
85131
|
continue;
|
|
84817
|
-
files.push(
|
|
85132
|
+
files.push(import_node_path56.default.join(root, folder, name));
|
|
84818
85133
|
}
|
|
84819
85134
|
}
|
|
84820
85135
|
const needle = query.contains?.toLowerCase();
|
|
@@ -84824,7 +85139,7 @@ async function readAudit(storageDir, workspace, query) {
|
|
|
84824
85139
|
for (const file2 of files) {
|
|
84825
85140
|
let text2;
|
|
84826
85141
|
try {
|
|
84827
|
-
text2 = await
|
|
85142
|
+
text2 = await import_node_fs13.promises.readFile(file2, "utf8");
|
|
84828
85143
|
} catch (error51) {
|
|
84829
85144
|
unreadable.push(`${file2}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
84830
85145
|
continue;
|
|
@@ -85762,8 +86077,8 @@ function createStrategyHistoryTool(deps) {
|
|
|
85762
86077
|
|
|
85763
86078
|
// ../../packages/core/dist/strategy/contractsTool.js
|
|
85764
86079
|
var item = external_exports.object({
|
|
85765
|
-
from: external_exports.string().min(1).describe(
|
|
85766
|
-
to: external_exports.string().min(1).describe(
|
|
86080
|
+
from: external_exports.string().min(1).describe(`The role that hands over, e.g. "programmer" - or a box's name, as the strategy text quotes it.`),
|
|
86081
|
+
to: external_exports.string().min(1).describe(`The role that receives it, e.g. "tester" - or a box's name, as the strategy text quotes it.`),
|
|
85767
86082
|
contract: external_exports.string().max(1e3).optional().describe("What passes along this connector, in a sentence."),
|
|
85768
86083
|
requires: external_exports.array(external_exports.string().trim().min(1).max(80)).max(10).optional().describe('The items the hand-over must contain, each a short name ("Changed files", "Tests run"). Light Code checks every one.')
|
|
85769
86084
|
});
|
|
@@ -85771,7 +86086,10 @@ var schema8 = external_exports.object({
|
|
|
85771
86086
|
contracts: external_exports.array(item).min(1).max(20).describe("One entry per connector to set. A connector is named by the two roles it joins.")
|
|
85772
86087
|
});
|
|
85773
86088
|
function findEdge(strategy, from, to) {
|
|
85774
|
-
const roleOf = (id) => strategy.nodes.find((n) => n.id === id)?.role
|
|
86089
|
+
const roleOf = (id) => strategy.nodes.find((n) => n.id === id)?.role ?? (() => {
|
|
86090
|
+
const group = strategy.groups?.find((g) => g.id === id);
|
|
86091
|
+
return group === void 0 ? void 0 : groupName(group).toLowerCase();
|
|
86092
|
+
})();
|
|
85775
86093
|
return strategy.edges.find((e) => roleOf(e.from) === from && roleOf(e.to) === to) ?? strategy.edges.find((e) => e.twoWay === true && roleOf(e.from) === to && roleOf(e.to) === from);
|
|
85776
86094
|
}
|
|
85777
86095
|
function applyContracts(strategy, params3, roleName) {
|
|
@@ -85837,7 +86155,7 @@ Not in the strategy, so left alone: ${unknown2.join(", ")}` : "")
|
|
|
85837
86155
|
}
|
|
85838
86156
|
|
|
85839
86157
|
// ../../packages/core/dist/team/admins.js
|
|
85840
|
-
var
|
|
86158
|
+
var import_node_crypto20 = require("node:crypto");
|
|
85841
86159
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
85842
86160
|
function windowsUserId() {
|
|
85843
86161
|
return normaliseUserId(import_node_os6.default.userInfo().username);
|
|
@@ -85907,13 +86225,13 @@ var TeamStore = class {
|
|
|
85907
86225
|
if (!isSafeIndexName(index))
|
|
85908
86226
|
throw new TeamStoreError(`"${index}" is not a usable index name (lowercase letters, digits, - and _).`);
|
|
85909
86227
|
}
|
|
85910
|
-
async send(method,
|
|
86228
|
+
async send(method, path68, body) {
|
|
85911
86229
|
const headers = { "Content-Type": "application/json" };
|
|
85912
86230
|
const { username, password } = this.connection;
|
|
85913
86231
|
if (username !== void 0 && username.length > 0) {
|
|
85914
86232
|
headers.Authorization = `Basic ${Buffer.from(`${username}:${password ?? ""}`).toString("base64")}`;
|
|
85915
86233
|
}
|
|
85916
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${
|
|
86234
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${path68}`;
|
|
85917
86235
|
const request2 = { method, headers };
|
|
85918
86236
|
if (body !== void 0)
|
|
85919
86237
|
request2.body = JSON.stringify(body);
|
|
@@ -86017,7 +86335,7 @@ var TeamStore = class {
|
|
|
86017
86335
|
}
|
|
86018
86336
|
async submit(review) {
|
|
86019
86337
|
await this.ensureIndex();
|
|
86020
|
-
const id = `review:${(0,
|
|
86338
|
+
const id = `review:${(0, import_node_crypto20.randomUUID)()}`;
|
|
86021
86339
|
const { status: status2, json: json2 } = await this.send("PUT", `/_create/${encodeURIComponent(id)}?refresh=true`, {
|
|
86022
86340
|
type: "review",
|
|
86023
86341
|
kind: review.kind,
|
|
@@ -86190,8 +86508,8 @@ function wireChatBridge(services) {
|
|
|
86190
86508
|
const workspaceBranch = workspaceRoot !== void 0 ? currentBranchOf(workspaceRoot) : void 0;
|
|
86191
86509
|
const machineApprovals = services.machineApprovalsFile !== void 0 ? new FileMachineApprovals(services.machineApprovalsFile) : void 0;
|
|
86192
86510
|
const mirrorRoot = services.mirrorRoot ?? storageDir;
|
|
86193
|
-
const personalSkillsDir = services.personalDir !== void 0 ?
|
|
86194
|
-
const personalToolsDir = services.personalDir !== void 0 ?
|
|
86511
|
+
const personalSkillsDir = services.personalDir !== void 0 ? import_node_path57.default.join(services.personalDir, "skills") : void 0;
|
|
86512
|
+
const personalToolsDir = services.personalDir !== void 0 ? import_node_path57.default.join(services.personalDir, "tools") : void 0;
|
|
86195
86513
|
const logger = new Logger({ level: "debug", sink: services.logSink });
|
|
86196
86514
|
let fastFsOps;
|
|
86197
86515
|
const fastFsAnswered = services.fastFs === void 0 ? Promise.resolve(void 0) : fastFsCapabilities(services.fastFs).then((answer) => {
|
|
@@ -86213,14 +86531,14 @@ function wireChatBridge(services) {
|
|
|
86213
86531
|
let cachedSecretValues = [];
|
|
86214
86532
|
const droppedFilesRoot2 = droppedFilesRoot();
|
|
86215
86533
|
const mailAttachmentsRoot2 = mailAttachmentsRoot();
|
|
86216
|
-
const droppedFilesDir =
|
|
86217
|
-
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(
|
|
86534
|
+
const droppedFilesDir = import_node_path57.default.join(droppedFilesRoot2, (0, import_node_crypto21.randomUUID)().slice(0, 8));
|
|
86535
|
+
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(import_node_path57.default.join(storageDir, "tool-results"), () => cachedSecretValues));
|
|
86218
86536
|
const taskStore = new JsonTaskStore(storageDir, truncationStore, logger);
|
|
86219
86537
|
const manifestsRoot = services.codebaseDir ?? storageDir;
|
|
86220
86538
|
const codebaseInstructionsFile = codebaseInstructionsPath({ codebaseDir: services.codebaseDir, storageDir, workspaceRoot: projectRoot });
|
|
86221
86539
|
if (services.codebaseDir !== void 0) {
|
|
86222
|
-
const shared =
|
|
86223
|
-
void import_promises31.default.access(shared).catch(() => import_promises31.default.cp(
|
|
86540
|
+
const shared = import_node_path57.default.join(services.codebaseDir, "index-manifests");
|
|
86541
|
+
void import_promises31.default.access(shared).catch(() => import_promises31.default.cp(import_node_path57.default.join(storageDir, "index-manifests"), shared, { recursive: true, errorOnExist: false, force: false })).catch(() => void 0);
|
|
86224
86542
|
}
|
|
86225
86543
|
const python = new PythonManager({
|
|
86226
86544
|
workspaceRoot,
|
|
@@ -86398,7 +86716,7 @@ ${preview.text}` } : {}
|
|
|
86398
86716
|
}
|
|
86399
86717
|
return gitCheck.answer;
|
|
86400
86718
|
}
|
|
86401
|
-
const defaultSkillsDir = workspaceRoot !== void 0 ?
|
|
86719
|
+
const defaultSkillsDir = workspaceRoot !== void 0 ? import_node_path57.default.join(workspaceRoot, ".lightcode", "skills") : void 0;
|
|
86402
86720
|
let skillsDir = defaultSkillsDir;
|
|
86403
86721
|
let localSkillsDir = defaultSkillsDir;
|
|
86404
86722
|
let extraSkillDirs = [];
|
|
@@ -86421,9 +86739,9 @@ ${preview.text}` } : {}
|
|
|
86421
86739
|
const trimmed = entry.trim();
|
|
86422
86740
|
if (trimmed.length === 0)
|
|
86423
86741
|
return void 0;
|
|
86424
|
-
if (
|
|
86425
|
-
return
|
|
86426
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
86742
|
+
if (import_node_path57.default.isAbsolute(trimmed))
|
|
86743
|
+
return import_node_path57.default.resolve(trimmed);
|
|
86744
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path57.default.resolve(workspaceRoot, trimmed);
|
|
86427
86745
|
}
|
|
86428
86746
|
function skillSearchPath() {
|
|
86429
86747
|
return [skillsDir, ...extraSkillDirs].filter((dir) => dir !== void 0);
|
|
@@ -86460,12 +86778,12 @@ ${preview.text}` } : {}
|
|
|
86460
86778
|
function watchSkillFolders() {
|
|
86461
86779
|
stopWatchingSkills();
|
|
86462
86780
|
const dirs = skillSearchPath();
|
|
86463
|
-
for (const dir of [...dirs, ...dirs.map((entry) =>
|
|
86781
|
+
for (const dir of [...dirs, ...dirs.map((entry) => import_node_path57.default.dirname(entry))]) {
|
|
86464
86782
|
try {
|
|
86465
86783
|
skillWatchers.push(
|
|
86466
86784
|
// Recursive, because a skill may be a folder with SKILL.md inside — a non-recursive
|
|
86467
86785
|
// watch sees the folder appear and then never hears about the file written into it.
|
|
86468
|
-
(0,
|
|
86786
|
+
(0, import_node_fs14.watch)(dir, { recursive: true }, () => {
|
|
86469
86787
|
if (skillWatchTimer !== void 0)
|
|
86470
86788
|
clearTimeout(skillWatchTimer);
|
|
86471
86789
|
skillWatchTimer = setTimeout(() => {
|
|
@@ -86537,7 +86855,7 @@ ${preview.text}` } : {}
|
|
|
86537
86855
|
await openInPanelEditor(filePath);
|
|
86538
86856
|
return;
|
|
86539
86857
|
}
|
|
86540
|
-
const real = await confineToAny(
|
|
86858
|
+
const real = await confineToAny(import_node_path57.default.resolve(filePath), roots);
|
|
86541
86859
|
await ui.openFile?.(real);
|
|
86542
86860
|
} catch (error51) {
|
|
86543
86861
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -86548,9 +86866,9 @@ ${preview.text}` } : {}
|
|
|
86548
86866
|
python.toolsDirectory(),
|
|
86549
86867
|
...skillsDir === void 0 ? [] : [skillsDir],
|
|
86550
86868
|
...extraSkillDirs.filter((dir) => dir !== void 0),
|
|
86551
|
-
|
|
86869
|
+
import_node_path57.default.join(storageDir, "reports"),
|
|
86552
86870
|
// Its own folder: nothing else lives there.
|
|
86553
|
-
...codebaseInstructionsFile === void 0 ? [] : [
|
|
86871
|
+
...codebaseInstructionsFile === void 0 ? [] : [import_node_path57.default.dirname(codebaseInstructionsFile)]
|
|
86554
86872
|
].filter((dir) => dir.length > 0);
|
|
86555
86873
|
}
|
|
86556
86874
|
function mostlyCrlf(text2) {
|
|
@@ -86559,17 +86877,17 @@ ${preview.text}` } : {}
|
|
|
86559
86877
|
}
|
|
86560
86878
|
const EDITOR_MAX_BYTES = 2 * 1024 * 1024;
|
|
86561
86879
|
async function openInPanelEditor(filePath) {
|
|
86562
|
-
const real = await confineToAny(
|
|
86880
|
+
const real = await confineToAny(import_node_path57.default.resolve(filePath), managedRoots());
|
|
86563
86881
|
const stat = await import_promises31.default.stat(real);
|
|
86564
86882
|
if (stat.size > EDITOR_MAX_BYTES)
|
|
86565
|
-
throw new Error(`${
|
|
86883
|
+
throw new Error(`${import_node_path57.default.basename(real)} is too large to edit here (${String(Math.round(stat.size / 1024))} KB).`);
|
|
86566
86884
|
const raw = await import_promises31.default.readFile(real, "utf8");
|
|
86567
86885
|
const crlf = mostlyCrlf(raw);
|
|
86568
|
-
post({ type: "editorFile", path: real, name:
|
|
86886
|
+
post({ type: "editorFile", path: real, name: import_node_path57.default.basename(real), content: raw.split("\r\n").join("\n"), mtimeMs: stat.mtimeMs, eol: crlf ? "crlf" : "lf" });
|
|
86569
86887
|
}
|
|
86570
86888
|
async function handleSaveEditorFile(filePath, content, mtimeMs) {
|
|
86571
86889
|
try {
|
|
86572
|
-
const real = await confineToAny(
|
|
86890
|
+
const real = await confineToAny(import_node_path57.default.resolve(filePath), managedRoots());
|
|
86573
86891
|
const current = await import_promises31.default.stat(real).catch(() => void 0);
|
|
86574
86892
|
if (current !== void 0 && Math.abs(current.mtimeMs - mtimeMs) > 1) {
|
|
86575
86893
|
post({
|
|
@@ -86577,7 +86895,7 @@ ${preview.text}` } : {}
|
|
|
86577
86895
|
path: real,
|
|
86578
86896
|
ok: false,
|
|
86579
86897
|
conflict: true,
|
|
86580
|
-
message: `${
|
|
86898
|
+
message: `${import_node_path57.default.basename(real)} was changed on disk after you opened it. Copy your text, close the editor, and open it again to see the new version.`
|
|
86581
86899
|
});
|
|
86582
86900
|
return;
|
|
86583
86901
|
}
|
|
@@ -86601,7 +86919,7 @@ ${preview.text}` } : {}
|
|
|
86601
86919
|
await handleOpenManagedFile(existing.filePath);
|
|
86602
86920
|
return;
|
|
86603
86921
|
}
|
|
86604
|
-
const target =
|
|
86922
|
+
const target = import_node_path57.default.join(skillsDir, "standing-instructions.md");
|
|
86605
86923
|
try {
|
|
86606
86924
|
await import_promises31.default.mkdir(skillsDir, { recursive: true });
|
|
86607
86925
|
await import_promises31.default.writeFile(target, STANDING_SKILL_TEMPLATE, { encoding: "utf8", flag: "wx" });
|
|
@@ -86621,7 +86939,7 @@ ${preview.text}` } : {}
|
|
|
86621
86939
|
return;
|
|
86622
86940
|
}
|
|
86623
86941
|
try {
|
|
86624
|
-
await import_promises31.default.mkdir(
|
|
86942
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(codebaseInstructionsFile), { recursive: true });
|
|
86625
86943
|
await import_promises31.default.writeFile(codebaseInstructionsFile, "", { encoding: "utf8", flag: "wx" });
|
|
86626
86944
|
} catch (error51) {
|
|
86627
86945
|
if (error51.code !== "EEXIST") {
|
|
@@ -86638,11 +86956,11 @@ ${preview.text}` } : {}
|
|
|
86638
86956
|
return;
|
|
86639
86957
|
if (!isValidToolName(name))
|
|
86640
86958
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
86641
|
-
const ownCopy =
|
|
86959
|
+
const ownCopy = import_node_path57.default.join(dir, toolFileName(name));
|
|
86642
86960
|
if (filePath !== void 0) {
|
|
86643
|
-
const same2 = (a, b) => normalizeForComparison(
|
|
86961
|
+
const same2 = (a, b) => normalizeForComparison(import_node_path57.default.resolve(a)) === normalizeForComparison(import_node_path57.default.resolve(b));
|
|
86644
86962
|
if (!same2(filePath, ownCopy)) {
|
|
86645
|
-
const fromBucket = mirroredToolsDirs.some((mirror) => same2(
|
|
86963
|
+
const fromBucket = mirroredToolsDirs.some((mirror) => same2(import_node_path57.default.dirname(filePath), mirror));
|
|
86646
86964
|
throw new Error(fromBucket ? `"${name}" at ${filePath} comes from a bucket folder, so deleting it here would be undone by the next sync. Decline it to hide this version, or remove it from the bucket to remove it for everyone.` : `${filePath} is not in the tools folder this machine writes to (${dir}), so it was not deleted.`);
|
|
86647
86965
|
}
|
|
86648
86966
|
}
|
|
@@ -86668,7 +86986,7 @@ ${preview.text}` } : {}
|
|
|
86668
86986
|
let dir;
|
|
86669
86987
|
let filePath = "";
|
|
86670
86988
|
for (const candidate of python.toolDirectories()) {
|
|
86671
|
-
const attempt =
|
|
86989
|
+
const attempt = import_node_path57.default.join(candidate, toolFileName(name));
|
|
86672
86990
|
if (await onDisk(attempt)) {
|
|
86673
86991
|
dir = candidate;
|
|
86674
86992
|
filePath = attempt;
|
|
@@ -86699,7 +87017,7 @@ ${preview.text}` } : {}
|
|
|
86699
87017
|
function samePath(a, b) {
|
|
86700
87018
|
if (a === void 0 || b === void 0)
|
|
86701
87019
|
return false;
|
|
86702
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
87020
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path57.default.resolve(value).toLowerCase() : import_node_path57.default.resolve(value);
|
|
86703
87021
|
return norm2(a) === norm2(b);
|
|
86704
87022
|
}
|
|
86705
87023
|
function publishFolder(kind, mirrors) {
|
|
@@ -86808,7 +87126,7 @@ ${preview.text}` } : {}
|
|
|
86808
87126
|
target,
|
|
86809
87127
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
|
|
86810
87128
|
relative: entry,
|
|
86811
|
-
contents: await import_promises31.default.readFile(
|
|
87129
|
+
contents: await import_promises31.default.readFile(import_node_path57.default.join(dir, entry))
|
|
86812
87130
|
});
|
|
86813
87131
|
uploaded += 1;
|
|
86814
87132
|
} catch (error51) {
|
|
@@ -86830,7 +87148,7 @@ ${preview.text}` } : {}
|
|
|
86830
87148
|
if (!isValidToolName(name))
|
|
86831
87149
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
86832
87150
|
for (const candidate of python.toolDirectories()) {
|
|
86833
|
-
const attempt =
|
|
87151
|
+
const attempt = import_node_path57.default.join(candidate, toolFileName(name));
|
|
86834
87152
|
try {
|
|
86835
87153
|
post({ type: "pythonToolSource", name, source: await import_promises31.default.readFile(attempt, "utf8") });
|
|
86836
87154
|
return;
|
|
@@ -86883,7 +87201,7 @@ ${preview.text}` } : {}
|
|
|
86883
87201
|
continue;
|
|
86884
87202
|
for (const candidate of python.toolDirectories()) {
|
|
86885
87203
|
try {
|
|
86886
|
-
const source = await import_promises31.default.readFile(
|
|
87204
|
+
const source = await import_promises31.default.readFile(import_node_path57.default.join(candidate, toolFileName(name)), "utf8");
|
|
86887
87205
|
declined[name] = hashSource(source);
|
|
86888
87206
|
recorded += 1;
|
|
86889
87207
|
break;
|
|
@@ -86941,7 +87259,7 @@ ${preview.text}` } : {}
|
|
|
86941
87259
|
let dir;
|
|
86942
87260
|
let filePath = "";
|
|
86943
87261
|
for (const candidate of python.toolDirectories()) {
|
|
86944
|
-
const attempt =
|
|
87262
|
+
const attempt = import_node_path57.default.join(candidate, toolFileName(name));
|
|
86945
87263
|
if (await onDisk(attempt)) {
|
|
86946
87264
|
dir = candidate;
|
|
86947
87265
|
filePath = attempt;
|
|
@@ -86967,7 +87285,7 @@ ${preview.text}` } : {}
|
|
|
86967
87285
|
function mirrorForDir(sourceDir) {
|
|
86968
87286
|
if (sourceDir === void 0)
|
|
86969
87287
|
return void 0;
|
|
86970
|
-
const wanted =
|
|
87288
|
+
const wanted = import_node_path57.default.resolve(sourceDir).toLowerCase();
|
|
86971
87289
|
for (const mirror of cachedSkillMirrors) {
|
|
86972
87290
|
if (mirror.enabled !== true)
|
|
86973
87291
|
continue;
|
|
@@ -86977,7 +87295,7 @@ ${preview.text}` } : {}
|
|
|
86977
87295
|
kind: "skills",
|
|
86978
87296
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
86979
87297
|
});
|
|
86980
|
-
if (
|
|
87298
|
+
if (import_node_path57.default.resolve(localDir).toLowerCase() === wanted)
|
|
86981
87299
|
return { mirror, localDir };
|
|
86982
87300
|
}
|
|
86983
87301
|
return void 0;
|
|
@@ -87042,8 +87360,8 @@ ${preview.text}` } : {}
|
|
|
87042
87360
|
});
|
|
87043
87361
|
let localProblem;
|
|
87044
87362
|
try {
|
|
87045
|
-
await import_promises31.default.rm(
|
|
87046
|
-
await import_promises31.default.rm(
|
|
87363
|
+
await import_promises31.default.rm(import_node_path57.default.join(found2.localDir, `${name}.md`), { force: true });
|
|
87364
|
+
await import_promises31.default.rm(import_node_path57.default.join(found2.localDir, name), { recursive: true, force: true });
|
|
87047
87365
|
} catch (error51) {
|
|
87048
87366
|
localProblem = error51 instanceof Error ? error51.message : String(error51);
|
|
87049
87367
|
}
|
|
@@ -87078,7 +87396,7 @@ ${preview.text}` } : {}
|
|
|
87078
87396
|
throw new Error(`"${name}" lives in ${existing.sourceDir}, which is a read-only skills folder. Delete the file there, or remove the folder in Settings.`);
|
|
87079
87397
|
}
|
|
87080
87398
|
const from = existing?.sourceDir !== void 0 && samePath(existing.sourceDir, personalSkillsDir) ? existing.sourceDir : skillsDir;
|
|
87081
|
-
await import_promises31.default.rm(
|
|
87399
|
+
await import_promises31.default.rm(import_node_path57.default.join(from, skillFileName(name)), { force: true });
|
|
87082
87400
|
await postSkills();
|
|
87083
87401
|
} catch (error51) {
|
|
87084
87402
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -87154,7 +87472,13 @@ ${preview.text}` } : {}
|
|
|
87154
87472
|
}
|
|
87155
87473
|
async function applyPlan(next) {
|
|
87156
87474
|
const trimmed = next?.slice(0, PLAN_LIMIT).trim();
|
|
87157
|
-
|
|
87475
|
+
const nextPlan = trimmed !== void 0 && trimmed.length > 0 ? trimmed : void 0;
|
|
87476
|
+
if (activeStrategy !== void 0 && startsNewWork(activePlan, activePlanProgress, nextPlan)) {
|
|
87477
|
+
strategyProgress = {};
|
|
87478
|
+
strategyLastRole = void 0;
|
|
87479
|
+
void postStrategies();
|
|
87480
|
+
}
|
|
87481
|
+
activePlan = nextPlan;
|
|
87158
87482
|
activePlanProgress = pruneProgress(activePlan, activePlanProgress);
|
|
87159
87483
|
await persistActiveTask();
|
|
87160
87484
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
@@ -87263,7 +87587,7 @@ ${preview.text}` } : {}
|
|
|
87263
87587
|
let scheduleToolAccess;
|
|
87264
87588
|
const approvalsKey = projectRoot ?? "__no_workspace__";
|
|
87265
87589
|
function comparableApprovalsKey(key3) {
|
|
87266
|
-
return key3 === "__no_workspace__" ? key3 : normalizeForComparison(
|
|
87590
|
+
return key3 === "__no_workspace__" ? key3 : normalizeForComparison(import_node_path57.default.resolve(key3));
|
|
87267
87591
|
}
|
|
87268
87592
|
function approvalsFrom(stored) {
|
|
87269
87593
|
if (stored === void 0)
|
|
@@ -87477,7 +87801,7 @@ ${preview.text}` } : {}
|
|
|
87477
87801
|
...taskExpertEstimate === void 0 ? {} : { estimate: taskExpertEstimate }
|
|
87478
87802
|
});
|
|
87479
87803
|
}
|
|
87480
|
-
const expertEventsPath =
|
|
87804
|
+
const expertEventsPath = import_node_path57.default.join(storageDir, "expert-events.jsonl");
|
|
87481
87805
|
let expertEvents;
|
|
87482
87806
|
let juniorTurnWithoutExpert = false;
|
|
87483
87807
|
async function loadExpertEvents() {
|
|
@@ -87505,7 +87829,7 @@ ${preview.text}` } : {}
|
|
|
87505
87829
|
try {
|
|
87506
87830
|
const events = await loadExpertEvents();
|
|
87507
87831
|
events.push(event);
|
|
87508
|
-
await import_promises31.default.mkdir(
|
|
87832
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(expertEventsPath), { recursive: true });
|
|
87509
87833
|
await import_promises31.default.appendFile(expertEventsPath, `${JSON.stringify(event)}
|
|
87510
87834
|
`, "utf8");
|
|
87511
87835
|
} catch (error51) {
|
|
@@ -87793,15 +88117,15 @@ ${preview.text}` } : {}
|
|
|
87793
88117
|
function contextMentionPath(file2) {
|
|
87794
88118
|
if (workspaceRoot === void 0)
|
|
87795
88119
|
return file2;
|
|
87796
|
-
const relative =
|
|
87797
|
-
return relative.length > 0 && !relative.startsWith("..") && !
|
|
88120
|
+
const relative = import_node_path57.default.relative(workspaceRoot, file2);
|
|
88121
|
+
return relative.length > 0 && !relative.startsWith("..") && !import_node_path57.default.isAbsolute(relative) ? relative.split(import_node_path57.default.sep).join("/") : file2;
|
|
87798
88122
|
}
|
|
87799
88123
|
function hostCapabilities() {
|
|
87800
88124
|
return {
|
|
87801
88125
|
// The branch this window or tab works on, shown under the chat's name; and the repository, when this
|
|
87802
88126
|
// folder is one of its branch folders (git/worktrees.ts).
|
|
87803
88127
|
...workspaceBranch !== void 0 ? { workspaceBranch } : {},
|
|
87804
|
-
...projectRoot !== void 0 && workspaceRoot !== void 0 && projectRoot !== workspaceRoot ? { branchFolderOf:
|
|
88128
|
+
...projectRoot !== void 0 && workspaceRoot !== void 0 && projectRoot !== workspaceRoot ? { branchFolderOf: import_node_path57.default.basename(projectRoot) } : {},
|
|
87805
88129
|
// The GitHub Copilot preset, offered only where VS Code's models can be reached.
|
|
87806
88130
|
hostModels: services.languageModels !== void 0,
|
|
87807
88131
|
nativeGuide: ui.openWalkthrough !== void 0,
|
|
@@ -87881,7 +88205,10 @@ ${preview.text}` } : {}
|
|
|
87881
88205
|
} catch {
|
|
87882
88206
|
return true;
|
|
87883
88207
|
}
|
|
87884
|
-
}
|
|
88208
|
+
},
|
|
88209
|
+
// Shared by every chat of a codebase in Fire Code (`codebaseDir`), so a chat starting after a crash or a
|
|
88210
|
+
// sleep offers the servers' tools at once instead of waiting for each to start (`mcp/toolCache.ts`).
|
|
88211
|
+
fileMcpToolCache(mcpToolCacheFile(services.codebaseDir ?? storageDir))
|
|
87885
88212
|
);
|
|
87886
88213
|
function postMcp() {
|
|
87887
88214
|
const servers = mcp.states_();
|
|
@@ -88364,14 +88691,14 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88364
88691
|
}
|
|
88365
88692
|
function readUserNpmrc() {
|
|
88366
88693
|
try {
|
|
88367
|
-
return (0,
|
|
88694
|
+
return (0, import_node_fs15.readFileSync)(process.env["NPM_CONFIG_USERCONFIG"] ?? import_node_path57.default.join(import_node_os7.default.homedir(), ".npmrc"), "utf8");
|
|
88368
88695
|
} catch {
|
|
88369
88696
|
return void 0;
|
|
88370
88697
|
}
|
|
88371
88698
|
}
|
|
88372
88699
|
function addonFolders(config2) {
|
|
88373
88700
|
return {
|
|
88374
|
-
configured: (config2.addons?.folders ?? []).map((folder) =>
|
|
88701
|
+
configured: (config2.addons?.folders ?? []).map((folder) => import_node_path57.default.resolve(folder)),
|
|
88375
88702
|
defaults: defaultAddonFolders(process.env, process.execPath, process.platform, readUserNpmrc())
|
|
88376
88703
|
};
|
|
88377
88704
|
}
|
|
@@ -88483,7 +88810,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88483
88810
|
if (id === void 0) {
|
|
88484
88811
|
if (records.length >= (spec.max ?? 500))
|
|
88485
88812
|
return postAddonPage(message6.package, { error: `No more than ${String(spec.max ?? 500)} ${spec.noun}s.` });
|
|
88486
|
-
id = (0,
|
|
88813
|
+
id = (0, import_node_crypto21.randomBytes)(6).toString("hex");
|
|
88487
88814
|
records.push({ id, values: cleaned.values });
|
|
88488
88815
|
} else {
|
|
88489
88816
|
const at = records.findIndex((record2) => record2.id === id);
|
|
@@ -88652,7 +88979,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88652
88979
|
}
|
|
88653
88980
|
async function handleSaveAddonFolders(folders) {
|
|
88654
88981
|
const cleaned = [...new Set(folders.map((folder) => folder.trim()).filter((folder) => folder.length > 0))];
|
|
88655
|
-
const relative = cleaned.find((folder) => !
|
|
88982
|
+
const relative = cleaned.find((folder) => !import_node_path57.default.isAbsolute(folder));
|
|
88656
88983
|
if (relative !== void 0) {
|
|
88657
88984
|
await postAddons(`"${relative}" is not a full path. Add-on folders are full paths, such as C:\\addons.`);
|
|
88658
88985
|
return;
|
|
@@ -88663,7 +88990,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88663
88990
|
postMcp();
|
|
88664
88991
|
await postAddons();
|
|
88665
88992
|
}
|
|
88666
|
-
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot,
|
|
88993
|
+
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot, import_node_path57.default.join(storageDir, "checkpoints", "shadow.git"), services.codebaseDir !== void 0 ? import_node_path57.default.join(services.codebaseDir, "checkpoint-objects") : void 0) : void 0;
|
|
88667
88994
|
async function postProfiles() {
|
|
88668
88995
|
const { config: config2 } = await configManager.load();
|
|
88669
88996
|
const profiles = await Promise.all((config2.profiles ?? []).map((profile) => toSummary(profile, secrets)));
|
|
@@ -88701,7 +89028,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88701
89028
|
let warning;
|
|
88702
89029
|
if (tls2.cert !== void 0 && tls2.key !== void 0) {
|
|
88703
89030
|
out.cert = tls2.cert.toString("utf8");
|
|
88704
|
-
const key3 = (0,
|
|
89031
|
+
const key3 = (0, import_node_crypto21.createPrivateKey)(tls2.passphrase !== void 0 ? { key: tls2.key, passphrase: tls2.passphrase } : { key: tls2.key });
|
|
88705
89032
|
out.key = key3.export({ type: "pkcs8", format: "pem" }).toString();
|
|
88706
89033
|
} else if (tls2.pfx !== void 0) {
|
|
88707
89034
|
warning = "The client certificate is a .pfx, which the observer process cannot present; it connects without one. If the gateway requires it, use a PEM certificate and key.";
|
|
@@ -88832,7 +89159,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88832
89159
|
await observerHub.configure(settings);
|
|
88833
89160
|
if (restart)
|
|
88834
89161
|
await observerHub.restart();
|
|
88835
|
-
auditRecordExists = settings.auditor.enabled || (0,
|
|
89162
|
+
auditRecordExists = settings.auditor.enabled || (0, import_node_fs15.existsSync)(observerHub.journalFolder);
|
|
88836
89163
|
if (settings.auditor.enabled && !auditPruned) {
|
|
88837
89164
|
auditPruned = true;
|
|
88838
89165
|
void pruneAudit(storageDir, o.auditor?.retentionDays ?? 90).then((n) => {
|
|
@@ -88877,7 +89204,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88877
89204
|
return;
|
|
88878
89205
|
}
|
|
88879
89206
|
if (ui.openFile !== void 0)
|
|
88880
|
-
await ui.openFile(
|
|
89207
|
+
await ui.openFile(import_node_path57.default.join(folder, newest));
|
|
88881
89208
|
else
|
|
88882
89209
|
ui.showInfo(`The audit journal is in ${folder} (newest: ${newest}).`);
|
|
88883
89210
|
}
|
|
@@ -88915,7 +89242,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88915
89242
|
async function handleOpenArtifact(relative, how) {
|
|
88916
89243
|
if (workspaceRoot === void 0)
|
|
88917
89244
|
return;
|
|
88918
|
-
const absolute = await confine(
|
|
89245
|
+
const absolute = await confine(import_node_path57.default.resolve(workspaceRoot, relative), workspaceRoot);
|
|
88919
89246
|
if (await denylist.isDenied(absolute)) {
|
|
88920
89247
|
ui.showWarning(`${relative} is on the deny list, so it is not opened.`);
|
|
88921
89248
|
return;
|
|
@@ -89028,7 +89355,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89028
89355
|
return { ok: true, message: `Saved in ${file2}; it reaches colleagues through this project's own sharing.` };
|
|
89029
89356
|
}
|
|
89030
89357
|
const enabled = cachedToolMirrors.filter((each) => each.enabled === true);
|
|
89031
|
-
const index = mirroredToolsDirs.findIndex((dir) => samePath(
|
|
89358
|
+
const index = mirroredToolsDirs.findIndex((dir) => samePath(import_node_path57.default.dirname(file2), dir));
|
|
89032
89359
|
try {
|
|
89033
89360
|
await writeFileAtomically(file2, review.content);
|
|
89034
89361
|
const mirror = index >= 0 ? enabled[index] : void 0;
|
|
@@ -89036,7 +89363,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89036
89363
|
const target = targetById(cachedS3, mirror.connectionId);
|
|
89037
89364
|
if (target === void 0 || target.readOnly === true)
|
|
89038
89365
|
return { ok: false, message: `${target?.label ?? mirror.connectionId} is read-only here, so the approved tool cannot be published from this computer.` };
|
|
89039
|
-
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative:
|
|
89366
|
+
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: import_node_path57.default.basename(file2), contents: Buffer.from(review.content, "utf8") });
|
|
89040
89367
|
return { ok: true, message: `Uploaded to the bucket ${target.label}; colleagues get it at their next sync and approve its code once, as for any tool.` };
|
|
89041
89368
|
}
|
|
89042
89369
|
scheduleTeamRepoPush();
|
|
@@ -89168,7 +89495,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89168
89495
|
const roleProcesses = /* @__PURE__ */ new Map();
|
|
89169
89496
|
async function roleProcessFor(agent, profile, config2, exe, system, tools) {
|
|
89170
89497
|
const definitions = toToolDefinitions([...tools]);
|
|
89171
|
-
const key3 = JSON.stringify([profile.id, profile.baseUrl, profile.model, profile.maxTokens ?? null, (0,
|
|
89498
|
+
const key3 = JSON.stringify([profile.id, profile.baseUrl, profile.model, profile.maxTokens ?? null, (0, import_node_crypto21.createHash)("sha256").update(system).digest("hex"), definitions.map((d) => d.name)]);
|
|
89172
89499
|
const existing = roleProcesses.get(agent.role);
|
|
89173
89500
|
if (existing !== void 0 && existing.key === key3)
|
|
89174
89501
|
return existing.process;
|
|
@@ -89317,8 +89644,8 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89317
89644
|
persistTimer.unref?.();
|
|
89318
89645
|
}
|
|
89319
89646
|
function composerDraftFile() {
|
|
89320
|
-
const id = (0,
|
|
89321
|
-
return
|
|
89647
|
+
const id = (0, import_node_crypto21.createHash)("sha256").update((workspaceRoot ?? "").toLowerCase()).digest("hex").slice(0, 16);
|
|
89648
|
+
return import_node_path57.default.join(storageDir, "drafts", `${id}.txt`);
|
|
89322
89649
|
}
|
|
89323
89650
|
let draftWrites = Promise.resolve();
|
|
89324
89651
|
function saveComposerDraft(text2) {
|
|
@@ -89331,10 +89658,20 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89331
89658
|
return import_promises31.default.readFile(composerDraftFile(), "utf8").catch(() => "");
|
|
89332
89659
|
}
|
|
89333
89660
|
async function persistActiveTask() {
|
|
89334
|
-
if (workspaceRoot === void 0
|
|
89661
|
+
if (workspaceRoot === void 0)
|
|
89662
|
+
return;
|
|
89663
|
+
const pending = pendingSteeringPath();
|
|
89664
|
+
if (conversation.isEmpty()) {
|
|
89665
|
+
if (pending !== void 0 && backgroundRun !== true) {
|
|
89666
|
+
await writePendingSteering(pending, {
|
|
89667
|
+
...activePlan !== void 0 ? { plan: activePlan, planProgress: activePlanProgress } : {},
|
|
89668
|
+
...activeStrategy !== void 0 ? { strategy: activeStrategy, strategyProgress, strategyExchanges } : {}
|
|
89669
|
+
}).catch((error51) => logger.warn(`Could not keep this chat's plan and strategy: ${describeFailure2(error51, true)}`));
|
|
89670
|
+
}
|
|
89335
89671
|
return;
|
|
89672
|
+
}
|
|
89336
89673
|
if (activeTaskId === void 0) {
|
|
89337
|
-
await setActiveTaskId((0,
|
|
89674
|
+
await setActiveTaskId((0, import_node_crypto21.randomUUID)());
|
|
89338
89675
|
activeTaskCreatedAt = Date.now();
|
|
89339
89676
|
truncationStore.startTask();
|
|
89340
89677
|
}
|
|
@@ -89356,6 +89693,8 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89356
89693
|
};
|
|
89357
89694
|
try {
|
|
89358
89695
|
await taskStore.save(redactTask(task, await knownSecretValues()));
|
|
89696
|
+
if (pending !== void 0 && backgroundRun !== true)
|
|
89697
|
+
await clearPendingSteering(pending);
|
|
89359
89698
|
} catch (error51) {
|
|
89360
89699
|
logger.warn("could not save task history", String(error51));
|
|
89361
89700
|
}
|
|
@@ -89391,20 +89730,27 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89391
89730
|
void _resumes;
|
|
89392
89731
|
void taskStore.save(settled).catch(() => void 0);
|
|
89393
89732
|
}
|
|
89394
|
-
|
|
89395
|
-
activePlanProgress = pruneProgress(activePlan, task.planProgress);
|
|
89396
|
-
activeStrategy = task.strategy;
|
|
89397
|
-
strategyProgress = task.strategyProgress ?? {};
|
|
89398
|
-
strategyExchanges = task.strategyExchanges ?? [];
|
|
89399
|
-
strategyLastRole = void 0;
|
|
89400
|
-
stopRoleProcesses();
|
|
89733
|
+
adoptSteering(task);
|
|
89401
89734
|
await setActiveTaskId(task.id);
|
|
89402
89735
|
post({ type: "taskRestored", taskId: task.id, entries: toTranscript(task.messages) });
|
|
89736
|
+
postSteering();
|
|
89737
|
+
await postTasks();
|
|
89738
|
+
}
|
|
89739
|
+
function adoptSteering(source) {
|
|
89740
|
+
activePlan = source.plan;
|
|
89741
|
+
activePlanProgress = pruneProgress(activePlan, source.planProgress);
|
|
89742
|
+
activeStrategy = source.strategy;
|
|
89743
|
+
strategyProgress = source.strategyProgress ?? {};
|
|
89744
|
+
strategyExchanges = source.strategyExchanges ?? [];
|
|
89745
|
+
strategyLastRole = void 0;
|
|
89746
|
+
stopRoleProcesses();
|
|
89747
|
+
}
|
|
89748
|
+
function postSteering() {
|
|
89403
89749
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
89404
89750
|
postPlanProgress();
|
|
89405
89751
|
void postStrategies();
|
|
89406
|
-
await postTasks();
|
|
89407
89752
|
}
|
|
89753
|
+
const pendingSteeringPath = () => workspaceRoot === void 0 ? void 0 : pendingSteeringFile(storageDir, workspaceRoot);
|
|
89408
89754
|
async function startNewTask() {
|
|
89409
89755
|
conversation.reset();
|
|
89410
89756
|
crashResumes = 0;
|
|
@@ -89425,6 +89771,9 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89425
89771
|
strategyLastRole = void 0;
|
|
89426
89772
|
stopRoleProcesses();
|
|
89427
89773
|
await setActiveTaskId(void 0);
|
|
89774
|
+
const pending = pendingSteeringPath();
|
|
89775
|
+
if (pending !== void 0 && backgroundRun !== true)
|
|
89776
|
+
await clearPendingSteering(pending);
|
|
89428
89777
|
post({ type: "taskRestored", taskId: void 0, entries: [] });
|
|
89429
89778
|
post({ type: "plan", plan: "" });
|
|
89430
89779
|
postPlanProgress();
|
|
@@ -89558,14 +89907,23 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89558
89907
|
await postTasks();
|
|
89559
89908
|
}
|
|
89560
89909
|
async function restoreActiveTaskOnLoad() {
|
|
89561
|
-
|
|
89910
|
+
const restoreEmptyChat = async () => {
|
|
89562
89911
|
post({ type: "taskRestored", taskId: void 0, entries: [] });
|
|
89912
|
+
const pending = pendingSteeringPath();
|
|
89913
|
+
const steering = pending === void 0 ? void 0 : await readPendingSteering(pending);
|
|
89914
|
+
if (steering === void 0 || !conversation.isEmpty() || activeTaskId !== void 0 || activeStrategy !== void 0 || activePlan !== void 0)
|
|
89915
|
+
return;
|
|
89916
|
+
adoptSteering(steering);
|
|
89917
|
+
postSteering();
|
|
89918
|
+
};
|
|
89919
|
+
if (activeTaskId === void 0) {
|
|
89920
|
+
await restoreEmptyChat();
|
|
89563
89921
|
return;
|
|
89564
89922
|
}
|
|
89565
89923
|
const task = await taskStore.load(activeTaskId);
|
|
89566
89924
|
if (task === void 0 || task.workspaceRoot !== workspaceRoot) {
|
|
89567
89925
|
await setActiveTaskId(void 0);
|
|
89568
|
-
|
|
89926
|
+
await restoreEmptyChat();
|
|
89569
89927
|
return;
|
|
89570
89928
|
}
|
|
89571
89929
|
conversation.restore(task.messages);
|
|
@@ -89573,7 +89931,9 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89573
89931
|
truncationStore.startTask(task.resultHandles);
|
|
89574
89932
|
restoredInterruptedTurn = task.turnRunning === true;
|
|
89575
89933
|
crashResumes = typeof task.crashResumes === "number" ? task.crashResumes : 0;
|
|
89934
|
+
adoptSteering(task);
|
|
89576
89935
|
post({ type: "taskRestored", taskId: task.id, entries: toTranscript(task.messages) });
|
|
89936
|
+
postSteering();
|
|
89577
89937
|
}
|
|
89578
89938
|
async function resumeInterruptedTurn() {
|
|
89579
89939
|
const decision = resumeDecision({ asked: services.resumeInterrupted === true, turnWasRunning: restoredInterruptedTurn, resumesSoFar: crashResumes });
|
|
@@ -89617,7 +89977,9 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89617
89977
|
const instructionsReady = early(readCodebaseInstructions(codebaseInstructionsFile));
|
|
89618
89978
|
const toolsReady = early((async () => {
|
|
89619
89979
|
await syncMcpFromConfig(config2);
|
|
89620
|
-
await mcp.
|
|
89980
|
+
const still = await mcp.ensureReady();
|
|
89981
|
+
if (still.length > 0)
|
|
89982
|
+
logger.info(`[startup] replying without waiting longer for MCP server(s) still starting: ${still.join(", ")}`);
|
|
89621
89983
|
await configurePython(config2);
|
|
89622
89984
|
})());
|
|
89623
89985
|
const capabilities = withReportedWindow(resolveModelCapabilities(profile.model, profile.modelCapabilities), await windowReady, profile.modelCapabilities);
|
|
@@ -89813,7 +90175,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89813
90175
|
...schedule === void 0 ? { requestForm } : {},
|
|
89814
90176
|
// A skill read with the user's defaults for its placeholders carries them (`skills/defaults.ts`).
|
|
89815
90177
|
annotateRead: (realPath) => {
|
|
89816
|
-
const fold = (value) => process.platform === "win32" ?
|
|
90178
|
+
const fold = (value) => process.platform === "win32" ? import_node_path57.default.resolve(value).toLowerCase() : import_node_path57.default.resolve(value);
|
|
89817
90179
|
const skill = skills.find((each) => fold(each.filePath) === fold(realPath));
|
|
89818
90180
|
return skill === void 0 ? void 0 : skillDefaultsReadNote(skill.name, config2.skillDefaults?.[skill.name]);
|
|
89819
90181
|
},
|
|
@@ -90272,7 +90634,7 @@ ${direction}` : attachMentions(text2, mentions);
|
|
|
90272
90634
|
try {
|
|
90273
90635
|
const { config: config2 } = await configManager.load();
|
|
90274
90636
|
const profiles = config2.profiles ?? [];
|
|
90275
|
-
const id = input.id ?? (0,
|
|
90637
|
+
const id = input.id ?? (0, import_node_crypto21.randomUUID)();
|
|
90276
90638
|
const existing = profiles.find((p) => p.id === id);
|
|
90277
90639
|
const auth2 = await buildAuthFromInput(input, id);
|
|
90278
90640
|
const saved = {
|
|
@@ -90310,7 +90672,7 @@ ${direction}` : attachMentions(text2, mentions);
|
|
|
90310
90672
|
post({ type: "error", message: `Profile "${id}" no longer exists.` });
|
|
90311
90673
|
return;
|
|
90312
90674
|
}
|
|
90313
|
-
const newId = (0,
|
|
90675
|
+
const newId = (0, import_node_crypto21.randomUUID)();
|
|
90314
90676
|
async function copySecret(fromRef, toRef) {
|
|
90315
90677
|
if (fromRef === void 0)
|
|
90316
90678
|
return false;
|
|
@@ -91121,7 +91483,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91121
91483
|
return { mode: cachedSearchScope, author: cachedAttribution.author };
|
|
91122
91484
|
}
|
|
91123
91485
|
function currentProjectNames() {
|
|
91124
|
-
const names = [cachedAttribution.project, workspaceRoot !== void 0 ?
|
|
91486
|
+
const names = [cachedAttribution.project, workspaceRoot !== void 0 ? import_node_path57.default.basename(workspaceRoot) : void 0];
|
|
91125
91487
|
return names.filter((name) => name !== void 0 && name.length > 0);
|
|
91126
91488
|
}
|
|
91127
91489
|
function indexProject(config2) {
|
|
@@ -91224,8 +91586,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91224
91586
|
limit: limits.limit,
|
|
91225
91587
|
previewChars: limits.previewChars
|
|
91226
91588
|
});
|
|
91227
|
-
for (const
|
|
91228
|
-
skipped2.add(
|
|
91589
|
+
for (const path68 of answer.skipped ?? [])
|
|
91590
|
+
skipped2.add(path68);
|
|
91229
91591
|
return { messages: answer.messages, truncated: answer.truncated };
|
|
91230
91592
|
},
|
|
91231
91593
|
...embedder !== void 0 && search !== void 0 && collection !== void 0 ? {
|
|
@@ -91524,9 +91886,9 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91524
91886
|
});
|
|
91525
91887
|
const all = result.folders.map((entry) => entry.path);
|
|
91526
91888
|
const wanted = new Set(chosen);
|
|
91527
|
-
for (const
|
|
91528
|
-
if (chosen.some((root) =>
|
|
91529
|
-
wanted.add(
|
|
91889
|
+
for (const path68 of all) {
|
|
91890
|
+
if (chosen.some((root) => path68 === root || path68.startsWith(`${root}\\`)))
|
|
91891
|
+
wanted.add(path68);
|
|
91530
91892
|
}
|
|
91531
91893
|
return [...wanted];
|
|
91532
91894
|
} catch {
|
|
@@ -91534,7 +91896,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91534
91896
|
}
|
|
91535
91897
|
}
|
|
91536
91898
|
async function handleRequestOutlookFolders(depth, force = false) {
|
|
91537
|
-
const cachePath =
|
|
91899
|
+
const cachePath = import_node_path57.default.join(storageDir, "outlook-folders.json");
|
|
91538
91900
|
let served = false;
|
|
91539
91901
|
try {
|
|
91540
91902
|
const cached2 = JSON.parse(await import_promises31.default.readFile(cachePath, "utf8"));
|
|
@@ -91554,7 +91916,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91554
91916
|
const scannedAt = Date.now();
|
|
91555
91917
|
post({ type: "outlookFolders", folders: result.folders, scannedAt });
|
|
91556
91918
|
try {
|
|
91557
|
-
await import_promises31.default.mkdir(
|
|
91919
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(cachePath), { recursive: true });
|
|
91558
91920
|
await import_promises31.default.writeFile(cachePath, JSON.stringify({ scannedAt, folders: result.folders }), "utf8");
|
|
91559
91921
|
} catch {
|
|
91560
91922
|
}
|
|
@@ -91799,7 +92161,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91799
92161
|
if (auth2.clientId === void 0 || auth2.clientSecretRef === void 0) {
|
|
91800
92162
|
throw new AtlassianError("AutoSys uses the API gateway but the client id or secret is missing. Settings \u2192 DevOps \u2192 AutoSys \u2192 API gateway: enter both and save.");
|
|
91801
92163
|
}
|
|
91802
|
-
const key3 = JSON.stringify({ auth: auth2, baseUrl: config2.autosys?.baseUrl, tls: tls2 === void 0 ? 0 : (0,
|
|
92164
|
+
const key3 = JSON.stringify({ auth: auth2, baseUrl: config2.autosys?.baseUrl, tls: tls2 === void 0 ? 0 : (0, import_node_crypto21.createHash)("sha256").update(JSON.stringify(tls2)).digest("hex") });
|
|
91803
92165
|
const testing = http !== httpClient;
|
|
91804
92166
|
if (!testing && autosysGateway?.key === key3)
|
|
91805
92167
|
return autosysGateway.strategy;
|
|
@@ -92471,13 +92833,13 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92471
92833
|
return { reason: "Off." };
|
|
92472
92834
|
if (!isSafeSegment(settings.project) || !isSafeSegment(settings.repo))
|
|
92473
92835
|
return { reason: "Enter the project key and repository slug." };
|
|
92474
|
-
const digest = (0,
|
|
92475
|
-
const root =
|
|
92836
|
+
const digest = (0, import_node_crypto21.createHash)("sha256").update(JSON.stringify([bitbucket.baseUrl, settings.project, settings.repo, settings.branch, settings.folder]).toLowerCase()).digest("hex").slice(0, 12);
|
|
92837
|
+
const root = import_node_path57.default.join(mirrorRoot, "teamrepo", `${settings.project}-${settings.repo}-${digest}`.toLowerCase());
|
|
92476
92838
|
return {
|
|
92477
|
-
dirs: { skills:
|
|
92839
|
+
dirs: { skills: import_node_path57.default.join(root, "skills"), tools: import_node_path57.default.join(root, "tools") },
|
|
92478
92840
|
// Where new skills and tools are saved while the repository is on - see loadSettings and pythonFolders.
|
|
92479
|
-
own: { skills:
|
|
92480
|
-
stateFile:
|
|
92841
|
+
own: { skills: import_node_path57.default.join(root, "saved-here", "skills"), tools: import_node_path57.default.join(root, "saved-here", "tools") },
|
|
92842
|
+
stateFile: import_node_path57.default.join(root, TEAM_REPO_STATE_FILE),
|
|
92481
92843
|
settings
|
|
92482
92844
|
};
|
|
92483
92845
|
}
|
|
@@ -92520,14 +92882,14 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92520
92882
|
const config2 = await loadSettings();
|
|
92521
92883
|
const plan3 = teamRepoPlan(config2);
|
|
92522
92884
|
if (!("reason" in plan3)) {
|
|
92523
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
92885
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path57.default.resolve(value).toLowerCase() : import_node_path57.default.resolve(value);
|
|
92524
92886
|
const folders = [
|
|
92525
92887
|
...[plan3.dirs.skills, plan3.own.skills, ...skillSearchPath()].map((dir) => [dir, "skills"]),
|
|
92526
92888
|
...[plan3.dirs.tools, plan3.own.tools, ...python.toolDirectories()].map((dir) => [dir, "tools"])
|
|
92527
92889
|
];
|
|
92528
|
-
const holder = folders.find(([dir]) => norm2(file2).startsWith(norm2(dir) +
|
|
92890
|
+
const holder = folders.find(([dir]) => norm2(file2).startsWith(norm2(dir) + import_node_path57.default.sep));
|
|
92529
92891
|
if (holder !== void 0) {
|
|
92530
|
-
const relative =
|
|
92892
|
+
const relative = import_node_path57.default.relative(import_node_path57.default.resolve(holder[0]), import_node_path57.default.resolve(file2)).split(import_node_path57.default.sep).join("/");
|
|
92531
92893
|
const where = repoPathFor(plan3.settings.folder, holder[1], relative);
|
|
92532
92894
|
try {
|
|
92533
92895
|
const client = await bitbucketClient();
|
|
@@ -92559,21 +92921,21 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92559
92921
|
const has2 = async (target) => import_promises31.default.stat(target).then(() => true, () => false);
|
|
92560
92922
|
if (kind === "skill") {
|
|
92561
92923
|
for (const dir of unique([skillsDir, localSkillsDir, personalSkillsDir, ...mirroredSkillsDirs])) {
|
|
92562
|
-
if (await has2(
|
|
92563
|
-
plan3.local.push(
|
|
92564
|
-
if (await has2(
|
|
92565
|
-
plan3.local.push(
|
|
92924
|
+
if (await has2(import_node_path57.default.join(dir, skillFileName(name))))
|
|
92925
|
+
plan3.local.push(import_node_path57.default.join(dir, skillFileName(name)));
|
|
92926
|
+
if (await has2(import_node_path57.default.join(dir, name, "SKILL.md")))
|
|
92927
|
+
plan3.local.push(import_node_path57.default.join(dir, name));
|
|
92566
92928
|
}
|
|
92567
92929
|
for (const extra of config2.skills?.paths ?? []) {
|
|
92568
92930
|
const dir = resolveSkillDir(extra);
|
|
92569
|
-
if (dir !== void 0 && (await has2(
|
|
92931
|
+
if (dir !== void 0 && (await has2(import_node_path57.default.join(dir, skillFileName(name))) || await has2(import_node_path57.default.join(dir, name, "SKILL.md")))) {
|
|
92570
92932
|
plan3.notes.push(`Also in ${dir}, a folder you added in Settings -> Skills - not removed; delete it there.`);
|
|
92571
92933
|
}
|
|
92572
92934
|
}
|
|
92573
92935
|
} else {
|
|
92574
92936
|
for (const dir of unique([pythonFolders(config2).toolsDir, localToolsDir(config2), personalToolsDir, ...mirroredToolsDirs])) {
|
|
92575
|
-
if (await has2(
|
|
92576
|
-
plan3.local.push(
|
|
92937
|
+
if (await has2(import_node_path57.default.join(dir, toolFileName(name))))
|
|
92938
|
+
plan3.local.push(import_node_path57.default.join(dir, toolFileName(name)));
|
|
92577
92939
|
}
|
|
92578
92940
|
}
|
|
92579
92941
|
const mirrors = (kind === "skill" ? cachedSkillMirrors : cachedToolMirrors).filter((mirror) => mirror.enabled === true);
|
|
@@ -92671,7 +93033,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92671
93033
|
try {
|
|
92672
93034
|
await import_promises31.default.rm(entry, { recursive: true, force: true });
|
|
92673
93035
|
if (kind === "tool")
|
|
92674
|
-
await forgetTool(
|
|
93036
|
+
await forgetTool(import_node_path57.default.dirname(entry), name).catch(() => void 0);
|
|
92675
93037
|
} catch (error51) {
|
|
92676
93038
|
localProblems.push(`${entry} (${error51 instanceof Error ? error51.message : String(error51)})`);
|
|
92677
93039
|
}
|
|
@@ -92697,24 +93059,24 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92697
93059
|
}
|
|
92698
93060
|
async function writeTeamMonitorSkill(file2, content) {
|
|
92699
93061
|
const config2 = await loadSettings();
|
|
92700
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
93062
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path57.default.resolve(value).toLowerCase() : import_node_path57.default.resolve(value);
|
|
92701
93063
|
const inside = (dir) => {
|
|
92702
93064
|
const target = norm2(file2);
|
|
92703
93065
|
const root = norm2(dir);
|
|
92704
|
-
return target.startsWith(root +
|
|
93066
|
+
return target.startsWith(root + import_node_path57.default.sep) ? import_node_path57.default.relative(import_node_path57.default.resolve(dir), import_node_path57.default.resolve(file2)) : void 0;
|
|
92705
93067
|
};
|
|
92706
93068
|
const saveIn = async (dir, relative) => {
|
|
92707
|
-
const destination =
|
|
93069
|
+
const destination = import_node_path57.default.join(dir, relative);
|
|
92708
93070
|
const enabled = cachedSkillMirrors.filter((each) => each.enabled === true);
|
|
92709
93071
|
const mirror = enabled.find((_, i) => samePath(mirroredSkillsDirs[i], dir));
|
|
92710
93072
|
const target = mirror !== void 0 ? targetById(cachedS3, mirror.connectionId) : void 0;
|
|
92711
93073
|
if (mirror !== void 0 && (target === void 0 || target.readOnly === true)) {
|
|
92712
93074
|
throw new Error(`${target?.label ?? mirror.connectionId} is read-only here, so this team monitor cannot be changed from this computer - ask whoever owns that bucket.`);
|
|
92713
93075
|
}
|
|
92714
|
-
await import_promises31.default.mkdir(
|
|
93076
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(destination), { recursive: true });
|
|
92715
93077
|
await writeFileAtomically(destination, content);
|
|
92716
93078
|
if (mirror !== void 0 && target !== void 0) {
|
|
92717
|
-
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: relative.split(
|
|
93079
|
+
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: relative.split(import_node_path57.default.sep).join("/"), contents: Buffer.from(content, "utf8") });
|
|
92718
93080
|
return `uploaded to the bucket ${target.label}`;
|
|
92719
93081
|
}
|
|
92720
93082
|
return `saved in ${dir}`;
|
|
@@ -92736,7 +93098,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92736
93098
|
throw new Error("There is no folder to save skills in, so the change cannot reach the team repository.");
|
|
92737
93099
|
const where = await saveIn(skillsDir, relative);
|
|
92738
93100
|
await handleTeamRepoSync("a monitor changed on the dashboard");
|
|
92739
|
-
const problem = teamRepoStatus?.error ?? teamRepoStatus?.conflicts.find((c2) => c2.path.endsWith(relative.split(
|
|
93101
|
+
const problem = teamRepoStatus?.error ?? teamRepoStatus?.conflicts.find((c2) => c2.path.endsWith(relative.split(import_node_path57.default.sep).join("/")))?.reason;
|
|
92740
93102
|
if (problem !== void 0) {
|
|
92741
93103
|
return { ok: false, message: `Saved here (${where}), but not committed to the team repository: ${problem}. Nothing was overwritten - see Settings \u2192 DevOps \u2192 Team repository.` };
|
|
92742
93104
|
}
|
|
@@ -92766,8 +93128,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92766
93128
|
function isPersonalSkill(skill) {
|
|
92767
93129
|
if (personalSkillsDir === void 0)
|
|
92768
93130
|
return false;
|
|
92769
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
92770
|
-
return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) +
|
|
93131
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path57.default.resolve(value).toLowerCase() : import_node_path57.default.resolve(value);
|
|
93132
|
+
return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) + import_node_path57.default.sep);
|
|
92771
93133
|
}
|
|
92772
93134
|
function bucketFolderLabels(config2) {
|
|
92773
93135
|
const label = (kind, mirror) => {
|
|
@@ -93015,7 +93377,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
93015
93377
|
}
|
|
93016
93378
|
const command = config2.branches?.setupCommand?.trim();
|
|
93017
93379
|
if (command !== void 0 && command.length > 0) {
|
|
93018
|
-
const label = workspaceBranch ??
|
|
93380
|
+
const label = workspaceBranch ?? import_node_path57.default.basename(workspaceRoot);
|
|
93019
93381
|
if (ui.runInTerminal !== void 0) {
|
|
93020
93382
|
ui.runInTerminal({ name: `Set up ${label}`, command, cwd: workspaceRoot, env: branchEnv });
|
|
93021
93383
|
parts.push(`running "${command}" in a terminal`);
|
|
@@ -93089,7 +93451,7 @@ ${last}` : ""}`);
|
|
|
93089
93451
|
approvalStamps.set("machine", stamp2);
|
|
93090
93452
|
}
|
|
93091
93453
|
for (const dir of python.toolDirectories()) {
|
|
93092
|
-
const file2 =
|
|
93454
|
+
const file2 = import_node_path57.default.join(dir, REGISTRY_FILE);
|
|
93093
93455
|
const stamp2 = await import_promises31.default.stat(file2).then((stat) => stat.mtimeMs, () => 0);
|
|
93094
93456
|
if (approvalStamps.has(file2) && approvalStamps.get(file2) !== stamp2)
|
|
93095
93457
|
changed = true;
|
|
@@ -93191,7 +93553,7 @@ ${last}` : ""}`);
|
|
|
93191
93553
|
return;
|
|
93192
93554
|
}
|
|
93193
93555
|
const folder = skill.filePath.slice(0, skill.filePath.length - "SKILL.md".length);
|
|
93194
|
-
const bytes = await import_promises31.default.readFile(
|
|
93556
|
+
const bytes = await import_promises31.default.readFile(import_node_path57.default.join(folder, SKILL_IMAGE_DIR, image));
|
|
93195
93557
|
const dataUri = skillImageDataUri(image, bytes);
|
|
93196
93558
|
post({
|
|
93197
93559
|
type: "skillImage",
|
|
@@ -93557,13 +93919,13 @@ ${last}` : ""}`);
|
|
|
93557
93919
|
}
|
|
93558
93920
|
function docsFingerprintPath(index, storeId, kind) {
|
|
93559
93921
|
const suffix = kind === void 0 ? "docs" : `docs.${kind}`;
|
|
93560
|
-
return
|
|
93922
|
+
return import_node_path57.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.${suffix}.json`);
|
|
93561
93923
|
}
|
|
93562
93924
|
function manifestKey(index, storeId) {
|
|
93563
93925
|
return `${index}@${storeId}`;
|
|
93564
93926
|
}
|
|
93565
93927
|
function manifestPath(index, storeId) {
|
|
93566
|
-
return
|
|
93928
|
+
return import_node_path57.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.json`);
|
|
93567
93929
|
}
|
|
93568
93930
|
async function readDocsFingerprint(index, storeId, kind) {
|
|
93569
93931
|
try {
|
|
@@ -93593,7 +93955,7 @@ ${last}` : ""}`);
|
|
|
93593
93955
|
});
|
|
93594
93956
|
const wanted = options.kind;
|
|
93595
93957
|
const entries = wanted === void 0 ? all : all.filter((entry) => entry.kind === wanted);
|
|
93596
|
-
const fingerprint = (0,
|
|
93958
|
+
const fingerprint = (0, import_node_crypto21.createHash)("sha256").update(`${wanted ?? "all"}:${embedder.model}:${String(embedder.dimensions)}`).update(entries.map((entry) => `${entry.id}\0${entry.text}`).join("")).digest("hex");
|
|
93597
93959
|
if (!options.force && fingerprint === await readDocsFingerprint(index, search.id, wanted)) {
|
|
93598
93960
|
return { unchanged: true, index, indexed: entries.length };
|
|
93599
93961
|
}
|
|
@@ -93627,7 +93989,7 @@ ${last}` : ""}`);
|
|
|
93627
93989
|
}
|
|
93628
93990
|
options.report?.("Writing", { done: 0, total: documents.length });
|
|
93629
93991
|
await writer.upsert(index, documents);
|
|
93630
|
-
await import_promises31.default.mkdir(
|
|
93992
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(docsFingerprintPath(index, search.id, wanted)), {
|
|
93631
93993
|
recursive: true
|
|
93632
93994
|
});
|
|
93633
93995
|
await import_promises31.default.writeFile(docsFingerprintPath(index, search.id, wanted), JSON.stringify({ fingerprint, indexedAt: Date.now(), count: documents.length }), "utf8");
|
|
@@ -93817,7 +94179,7 @@ ${last}` : ""}`);
|
|
|
93817
94179
|
});
|
|
93818
94180
|
if (manifest !== void 0) {
|
|
93819
94181
|
const targetPath = manifestPath(index, target.id);
|
|
93820
|
-
await import_promises31.default.mkdir(
|
|
94182
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(targetPath), { recursive: true });
|
|
93821
94183
|
await import_promises31.default.writeFile(targetPath, JSON.stringify(manifest), "utf8");
|
|
93822
94184
|
}
|
|
93823
94185
|
post({ type: "storeSync", running: false, copied: result.copied, fromLabel: source.label });
|
|
@@ -93866,7 +94228,7 @@ ${last}` : ""}`);
|
|
|
93866
94228
|
type: "project",
|
|
93867
94229
|
hasWorkspace: workspaceRoot !== void 0,
|
|
93868
94230
|
...configured !== void 0 ? { configured } : {},
|
|
93869
|
-
...workspaceRoot !== void 0 ? { folder:
|
|
94231
|
+
...workspaceRoot !== void 0 ? { folder: import_node_path57.default.basename(workspaceRoot) } : {},
|
|
93870
94232
|
...author !== void 0 ? { author } : {},
|
|
93871
94233
|
...index !== void 0 ? { indexName: index } : {},
|
|
93872
94234
|
...ownerConfigured !== void 0 && ownerConfigured.length > 0 ? { ownerConfigured } : {},
|
|
@@ -94006,8 +94368,8 @@ ${last}` : ""}`);
|
|
|
94006
94368
|
if (workspaceRoot === void 0)
|
|
94007
94369
|
return found2;
|
|
94008
94370
|
const root = workspaceRoot;
|
|
94009
|
-
const relative =
|
|
94010
|
-
if (relative.startsWith("..") ||
|
|
94371
|
+
const relative = import_node_path57.default.relative(root, folder);
|
|
94372
|
+
if (relative.startsWith("..") || import_node_path57.default.isAbsolute(relative))
|
|
94011
94373
|
return found2;
|
|
94012
94374
|
const output = await new Promise((resolve) => {
|
|
94013
94375
|
const child = (0, import_node_child_process19.spawn)("git", ["-c", "core.quotePath=false", "log", "--diff-filter=A", "--relative", "--format=@@%an", "--name-only", "--", relative.length > 0 ? relative : "."], {
|
|
@@ -94024,7 +94386,7 @@ ${last}` : ""}`);
|
|
|
94024
94386
|
if (line.startsWith("@@"))
|
|
94025
94387
|
author = line.slice(2).trim();
|
|
94026
94388
|
else if (line.trim().length > 0 && author !== void 0 && author.length > 0) {
|
|
94027
|
-
found2.set(normalizeForComparison(
|
|
94389
|
+
found2.set(normalizeForComparison(import_node_path57.default.resolve(root, line.trim())), author);
|
|
94028
94390
|
}
|
|
94029
94391
|
}
|
|
94030
94392
|
return found2;
|
|
@@ -94068,7 +94430,7 @@ ${last}` : ""}`);
|
|
|
94068
94430
|
},
|
|
94069
94431
|
source,
|
|
94070
94432
|
folder,
|
|
94071
|
-
relative:
|
|
94433
|
+
relative: import_node_path57.default.relative(folder, filePath).split(import_node_path57.default.sep).join("/")
|
|
94072
94434
|
});
|
|
94073
94435
|
};
|
|
94074
94436
|
for (const folder of skillFolders) {
|
|
@@ -94086,7 +94448,7 @@ ${last}` : ""}`);
|
|
|
94086
94448
|
const name = entry.slice(0, -3);
|
|
94087
94449
|
if (!isValidToolName(name))
|
|
94088
94450
|
continue;
|
|
94089
|
-
await consider("tool", name,
|
|
94451
|
+
await consider("tool", name, import_node_path57.default.join(folder, entry), folder, location);
|
|
94090
94452
|
}
|
|
94091
94453
|
}
|
|
94092
94454
|
const readOnly = skills.filter((skill) => skill.sourceDir !== void 0 && !skillFolders.some((folder) => samePath(folder, skill.sourceDir))).length;
|
|
@@ -94118,7 +94480,7 @@ ${last}` : ""}`);
|
|
|
94118
94480
|
} catch {
|
|
94119
94481
|
}
|
|
94120
94482
|
}
|
|
94121
|
-
const gitAuthor = gitAuthors.get(normalizeForComparison(
|
|
94483
|
+
const gitAuthor = gitAuthors.get(normalizeForComparison(import_node_path57.default.resolve(candidate.entry.filePath)));
|
|
94122
94484
|
if (gitAuthor !== void 0) {
|
|
94123
94485
|
candidate.entry.suggestion = { author: gitAuthor, source: "git: the commit that added this file" };
|
|
94124
94486
|
}
|
|
@@ -94227,7 +94589,7 @@ ${last}` : ""}`);
|
|
|
94227
94589
|
aliases: plan3.kind === "codebase" ? codebaseAliases(config2) : plan3.kind === "skills" ? skillAliases(config2) : [],
|
|
94228
94590
|
onProgress: (count3) => post({ type: "indexRenames", running: true, plans, store, current: plan3.to, copied: count3 })
|
|
94229
94591
|
});
|
|
94230
|
-
await copyBookkeeping(
|
|
94592
|
+
await copyBookkeeping(import_node_path57.default.join(manifestsRoot, "index-manifests"), plan3.from, plan3.to, search.id);
|
|
94231
94593
|
done.push({ ...plan3, copied });
|
|
94232
94594
|
}
|
|
94233
94595
|
post({ type: "indexRenames", running: false, plans: [], store, done });
|
|
@@ -94257,7 +94619,7 @@ ${last}` : ""}`);
|
|
|
94257
94619
|
project: projectName(config2, workspaceRoot),
|
|
94258
94620
|
aliases: codebaseAliases(config2)
|
|
94259
94621
|
});
|
|
94260
|
-
await copyBookkeeping(
|
|
94622
|
+
await copyBookkeeping(import_node_path57.default.join(manifestsRoot, "index-manifests"), legacy, current, search.id);
|
|
94261
94623
|
post({ type: "indexRenames", running: false, plans: [], done: [{ kind: "codebase", from: legacy, to: current, copied }] });
|
|
94262
94624
|
logger.info(`copied ${String(copied)} chunks from ${legacy} to ${current} rather than re-embedding them`);
|
|
94263
94625
|
}
|
|
@@ -94423,7 +94785,7 @@ ${last}` : ""}`);
|
|
|
94423
94785
|
denylist,
|
|
94424
94786
|
manifest,
|
|
94425
94787
|
saveManifest: async (next) => {
|
|
94426
|
-
await import_promises31.default.mkdir(
|
|
94788
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(manifestFile), { recursive: true });
|
|
94427
94789
|
await import_promises31.default.writeFile(manifestFile, JSON.stringify(next), "utf8");
|
|
94428
94790
|
},
|
|
94429
94791
|
...isIgnored2 !== void 0 ? { isIgnored: isIgnored2 } : {},
|
|
@@ -94509,9 +94871,9 @@ ${last}` : ""}`);
|
|
|
94509
94871
|
}
|
|
94510
94872
|
const usageLog = new UsageLog(storageDir);
|
|
94511
94873
|
const usageInstance = usageInstanceId(storageDir);
|
|
94512
|
-
const usageProfileFile =
|
|
94513
|
-
const legacyBackfillFile =
|
|
94514
|
-
const usageDir =
|
|
94874
|
+
const usageProfileFile = import_node_path57.default.join(storageDir, "usage-profile.json");
|
|
94875
|
+
const legacyBackfillFile = import_node_path57.default.join(storageDir, "usage-backfill.json");
|
|
94876
|
+
const usageDir = import_node_path57.default.join(storageDir, "usage");
|
|
94515
94877
|
const toolStartedAt = /* @__PURE__ */ new Map();
|
|
94516
94878
|
let usagePushTimer;
|
|
94517
94879
|
let usagePushing;
|
|
@@ -94529,7 +94891,7 @@ ${last}` : ""}`);
|
|
|
94529
94891
|
return (request2) => runFastFs(exe, request2);
|
|
94530
94892
|
}
|
|
94531
94893
|
function skillAtPath(requested2) {
|
|
94532
|
-
const absolute =
|
|
94894
|
+
const absolute = import_node_path57.default.isAbsolute(requested2) ? requested2 : workspaceRoot === void 0 ? void 0 : import_node_path57.default.resolve(workspaceRoot, requested2);
|
|
94533
94895
|
if (absolute === void 0)
|
|
94534
94896
|
return void 0;
|
|
94535
94897
|
return skills.find((skill) => samePath(skill.filePath, absolute));
|
|
@@ -94619,7 +94981,7 @@ ${last}` : ""}`);
|
|
|
94619
94981
|
const folder = chosen.path?.trim();
|
|
94620
94982
|
if (folder === void 0 || folder.length === 0)
|
|
94621
94983
|
return { problem: "The shared folder has no path." };
|
|
94622
|
-
if (!
|
|
94984
|
+
if (!import_node_path57.default.isAbsolute(folder))
|
|
94623
94985
|
return { problem: `"${folder}" is not an absolute path. Use the full path of a folder everybody can reach, such as a network share.` };
|
|
94624
94986
|
const helper = usageHelper();
|
|
94625
94987
|
return { store: new FolderShardStore(folder, ...helper !== void 0 ? [helper] : []), target };
|
|
@@ -94648,7 +95010,7 @@ ${last}` : ""}`);
|
|
|
94648
95010
|
}
|
|
94649
95011
|
async function readUsageBackfill() {
|
|
94650
95012
|
try {
|
|
94651
|
-
const text2 = await import_promises31.default.readFile(
|
|
95013
|
+
const text2 = await import_promises31.default.readFile(import_node_path57.default.join(usageDir, "backfill.json"), "utf8").catch(() => import_promises31.default.readFile(legacyBackfillFile, "utf8"));
|
|
94652
95014
|
const saved = JSON.parse(text2);
|
|
94653
95015
|
if (typeof saved.at !== "number")
|
|
94654
95016
|
return void 0;
|
|
@@ -94664,7 +95026,7 @@ ${last}` : ""}`);
|
|
|
94664
95026
|
legacyDoneFile: legacyBackfillFile,
|
|
94665
95027
|
run: async (before) => {
|
|
94666
95028
|
const status2 = python.status();
|
|
94667
|
-
return backfillFromTasks(
|
|
95029
|
+
return backfillFromTasks(import_node_path57.default.join(storageDir, "tasks"), {
|
|
94668
95030
|
user: cachedAttribution.author ?? "unknown",
|
|
94669
95031
|
project: cachedAttribution.project,
|
|
94670
95032
|
workspaceRoot,
|
|
@@ -94762,7 +95124,7 @@ ${last}` : ""}`);
|
|
|
94762
95124
|
try {
|
|
94763
95125
|
const text2 = (await import_promises31.default.readFile(file2, "utf8")).replace(/\r\n/g, "\n");
|
|
94764
95126
|
const meaningful = text2.split("\n").filter((line) => !/^(author|project|version|updated)\s*:/i.test(line) && !/^__(author|project|version|updated)__\s*=/.test(line)).join("\n").trim();
|
|
94765
|
-
return (0,
|
|
95127
|
+
return (0, import_node_crypto21.createHash)("sha256").update(meaningful).digest("hex").slice(0, 16);
|
|
94766
95128
|
} catch {
|
|
94767
95129
|
return void 0;
|
|
94768
95130
|
}
|
|
@@ -94837,14 +95199,14 @@ ${last}` : ""}`);
|
|
|
94837
95199
|
kind: "tool",
|
|
94838
95200
|
name: issue2.name,
|
|
94839
95201
|
filePath: issue2.filePath,
|
|
94840
|
-
deletable: samePath(
|
|
94841
|
-
location: where(
|
|
95202
|
+
deletable: samePath(import_node_path57.default.dirname(issue2.filePath), status2.toolsDir),
|
|
95203
|
+
location: where(import_node_path57.default.dirname(issue2.filePath), status2.toolsDir),
|
|
94842
95204
|
issue: issue2.kind === "unapproved" ? "waiting for approval" : issue2.kind === "hash-mismatch" ? "changed since approval" : issue2.detail.split("\n")[0] ?? "not loaded"
|
|
94843
95205
|
});
|
|
94844
95206
|
}
|
|
94845
95207
|
return items;
|
|
94846
95208
|
}
|
|
94847
|
-
const usageDirectoryFile =
|
|
95209
|
+
const usageDirectoryFile = import_node_path57.default.join(storageDir, "usage-directory.json");
|
|
94848
95210
|
let directoryRunning;
|
|
94849
95211
|
async function readDirectoryCache() {
|
|
94850
95212
|
try {
|
|
@@ -95179,7 +95541,7 @@ ${last}` : ""}`);
|
|
|
95179
95541
|
let indexedFiles = 0;
|
|
95180
95542
|
if (index !== void 0) {
|
|
95181
95543
|
try {
|
|
95182
|
-
const manifest = JSON.parse(await import_promises31.default.readFile(
|
|
95544
|
+
const manifest = JSON.parse(await import_promises31.default.readFile(import_node_path57.default.join(manifestsRoot, "index-manifests", `${index}.json`), "utf8"));
|
|
95183
95545
|
indexedFiles = Object.keys(manifest.files ?? {}).length;
|
|
95184
95546
|
} catch {
|
|
95185
95547
|
}
|
|
@@ -95455,7 +95817,7 @@ ${last}` : ""}`);
|
|
|
95455
95817
|
return;
|
|
95456
95818
|
}
|
|
95457
95819
|
const { config: config2 } = await configManager.load();
|
|
95458
|
-
const id = input.id ?? (0,
|
|
95820
|
+
const id = input.id ?? (0, import_node_crypto21.randomUUID)();
|
|
95459
95821
|
if (input.username !== void 0 && input.username.length > 0)
|
|
95460
95822
|
await secrets.set(searchUserRefFor(id), input.username);
|
|
95461
95823
|
if (input.password !== void 0 && input.password.length > 0)
|
|
@@ -95659,11 +96021,11 @@ ${last}` : ""}`);
|
|
|
95659
96021
|
answer({ error: bytes.length === 0 ? "There was nothing to save." : "That file is too large to save from here." });
|
|
95660
96022
|
return;
|
|
95661
96023
|
}
|
|
95662
|
-
const safeName = [...
|
|
95663
|
-
const extension =
|
|
96024
|
+
const safeName = [...import_node_path57.default.basename(name)].map((c2) => c2.charCodeAt(0) < 32 || '<>:"/\\|?*'.includes(c2) ? "-" : c2).join("") || "file";
|
|
96025
|
+
const extension = import_node_path57.default.extname(safeName).slice(1);
|
|
95664
96026
|
try {
|
|
95665
96027
|
const target = await ui.showSaveDialog({
|
|
95666
|
-
defaultName: workspaceRoot !== void 0 ?
|
|
96028
|
+
defaultName: workspaceRoot !== void 0 ? import_node_path57.default.join(workspaceRoot, safeName) : safeName,
|
|
95667
96029
|
...extension.length > 0 ? { extensions: [extension] } : {}
|
|
95668
96030
|
});
|
|
95669
96031
|
if (target === void 0) {
|
|
@@ -95744,8 +96106,8 @@ ${last}` : ""}`);
|
|
|
95744
96106
|
continue;
|
|
95745
96107
|
for (const key3 of section.keys)
|
|
95746
96108
|
patch[key3] = key3 === "profiles" && merged.profiles !== void 0 ? reconciled : merged[key3];
|
|
95747
|
-
for (const
|
|
95748
|
-
const head =
|
|
96109
|
+
for (const path68 of section.nested ?? []) {
|
|
96110
|
+
const head = path68.split(".")[0];
|
|
95749
96111
|
patch[head] = merged[head];
|
|
95750
96112
|
}
|
|
95751
96113
|
}
|
|
@@ -95789,7 +96151,7 @@ ${last}` : ""}`);
|
|
|
95789
96151
|
if (changeLedger !== void 0) {
|
|
95790
96152
|
const shared = await changeLedger.othersSince(targets, taskCheckpoint.createdAt);
|
|
95791
96153
|
if (shared.size > 0) {
|
|
95792
|
-
const shown2 = (file2) =>
|
|
96154
|
+
const shown2 = (file2) => import_node_path57.default.relative(workspaceRoot ?? "", file2).split(import_node_path57.default.sep).join("/");
|
|
95793
96155
|
const detail = [...shared].map(([file2, chats]) => `${shown2(file2)} (${chats.join(", ")})`).join("; ");
|
|
95794
96156
|
const all = await ui.showActionMessage(`Another chat also changed ${String(shared.size)} of these files after this chat started: ${detail}. Rolling them back would undo that chat's changes too.`, "Roll those back too", "warning");
|
|
95795
96157
|
if (!all) {
|
|
@@ -95827,9 +96189,15 @@ ${last}` : ""}`);
|
|
|
95827
96189
|
recordExchange({ at: Date.now(), role: agent.role, question: request2.question.slice(0, 4e3), answer: "", refused: planned.refuse });
|
|
95828
96190
|
throw new Error(planned.refuse);
|
|
95829
96191
|
}
|
|
95830
|
-
|
|
96192
|
+
let stepNotes = planned.addToPrompt;
|
|
96193
|
+
if (stepNotes.includes("@") && workspaceRoot !== void 0) {
|
|
96194
|
+
const mentioned = await resolveMentions(stepNotes, { fs: new NodeFileSystem(), workspaceRoot, denylist, siblings: mentionCodebases() }).catch(() => []);
|
|
96195
|
+
if (mentioned.length > 0)
|
|
96196
|
+
stepNotes = attachMentions(stepNotes, mentioned);
|
|
96197
|
+
}
|
|
96198
|
+
const question = stepNotes.length > 0 ? `${request2.question}
|
|
95831
96199
|
|
|
95832
|
-
${
|
|
96200
|
+
${stepNotes}` : request2.question;
|
|
95833
96201
|
strategyRunning.add(agent.role);
|
|
95834
96202
|
strategyLastRole = agent.role;
|
|
95835
96203
|
void postStrategies();
|
|
@@ -96073,7 +96441,7 @@ ${notes.join("\n")}` } : answer;
|
|
|
96073
96441
|
const pathRequest = pendingPathApprovals.get(id);
|
|
96074
96442
|
userGate.resolve(id, "approve");
|
|
96075
96443
|
if (pathRequest !== void 0) {
|
|
96076
|
-
const folder =
|
|
96444
|
+
const folder = import_node_path57.default.dirname(pathRequest);
|
|
96077
96445
|
sessionPathGrants.add(normalizeForComparison(pathRequest));
|
|
96078
96446
|
if (scope === "folder" && !cachedReadRoots.includes(folder)) {
|
|
96079
96447
|
const { config: config2 } = await configManager.load();
|
|
@@ -96313,10 +96681,10 @@ ${notes.join("\n")}` } : answer;
|
|
|
96313
96681
|
});
|
|
96314
96682
|
return;
|
|
96315
96683
|
}
|
|
96316
|
-
let dir =
|
|
96684
|
+
let dir = import_node_path57.default.dirname(import_node_path57.default.resolve(scriptPath));
|
|
96317
96685
|
for (let depth = 0; depth < 3; depth++) {
|
|
96318
96686
|
for (const name of VENV_DIR_NAMES) {
|
|
96319
|
-
const candidate =
|
|
96687
|
+
const candidate = import_node_path57.default.join(dir, name);
|
|
96320
96688
|
const found2 = await search(candidate);
|
|
96321
96689
|
if (found2 !== void 0) {
|
|
96322
96690
|
post({
|
|
@@ -96328,7 +96696,7 @@ ${notes.join("\n")}` } : answer;
|
|
|
96328
96696
|
return;
|
|
96329
96697
|
}
|
|
96330
96698
|
}
|
|
96331
|
-
const parent =
|
|
96699
|
+
const parent = import_node_path57.default.dirname(dir);
|
|
96332
96700
|
if (parent === dir)
|
|
96333
96701
|
break;
|
|
96334
96702
|
dir = parent;
|
|
@@ -97140,7 +97508,7 @@ ${notes.join("\n")}` } : answer;
|
|
|
97140
97508
|
try {
|
|
97141
97509
|
const { config: config2 } = await configManager.load();
|
|
97142
97510
|
await syncMcpFromConfig(config2);
|
|
97143
|
-
await mcp.
|
|
97511
|
+
await mcp.ensureReady();
|
|
97144
97512
|
mcpStartProblem = void 0;
|
|
97145
97513
|
} catch (error51) {
|
|
97146
97514
|
logger.warn(`Could not start MCP servers: ${describeFailure2(error51, true)}`);
|
|
@@ -97151,14 +97519,27 @@ ${notes.join("\n")}` } : answer;
|
|
|
97151
97519
|
void (async () => {
|
|
97152
97520
|
try {
|
|
97153
97521
|
const config2 = await loadSettings();
|
|
97154
|
-
const
|
|
97522
|
+
const startedAt = Date.now();
|
|
97523
|
+
const timed = (label, work) => work.finally(() => {
|
|
97524
|
+
const seconds = (Date.now() - startedAt) / 1e3;
|
|
97525
|
+
if (seconds >= 2)
|
|
97526
|
+
logger.info(`[startup] ${label} ready after ${seconds.toFixed(1)}s`);
|
|
97527
|
+
});
|
|
97528
|
+
const parts = [
|
|
97529
|
+
timed("secrets", knownSecretValues()),
|
|
97530
|
+
timed("skills", refreshSkills()),
|
|
97531
|
+
timed("Python tools", configurePython(config2)),
|
|
97532
|
+
timed("git check", gitAvailable()),
|
|
97533
|
+
timed("expert", resolveExpert(config2)),
|
|
97534
|
+
timed("MCP tools", mcpStarted)
|
|
97535
|
+
];
|
|
97155
97536
|
if ((config2.profiles ?? []).length > 0) {
|
|
97156
97537
|
const profile = resolveActiveProfile(config2);
|
|
97157
|
-
parts.push((async () => {
|
|
97538
|
+
parts.push(timed("model gateway (sign-in and context window)", (async () => {
|
|
97158
97539
|
if (profile.wireFormat !== "vscode-lm")
|
|
97159
97540
|
await authStrategyFor(config2, profile).resolveHeaders();
|
|
97160
97541
|
await reportedWindowFor(config2, profile);
|
|
97161
|
-
})());
|
|
97542
|
+
})()));
|
|
97162
97543
|
}
|
|
97163
97544
|
const results = await Promise.allSettled(parts);
|
|
97164
97545
|
for (const result of results) {
|
|
@@ -97261,11 +97642,11 @@ ${entry.content}`);
|
|
|
97261
97642
|
let lastReportPath;
|
|
97262
97643
|
async function saveReport(title, contents) {
|
|
97263
97644
|
try {
|
|
97264
|
-
const directory =
|
|
97645
|
+
const directory = import_node_path57.default.join(storageDir, "reports");
|
|
97265
97646
|
await import_promises31.default.mkdir(directory, { recursive: true });
|
|
97266
97647
|
const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
97267
97648
|
const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
97268
|
-
const target =
|
|
97649
|
+
const target = import_node_path57.default.join(directory, `${stamp2}${slug.length > 0 ? `-${slug}` : ""}.md`);
|
|
97269
97650
|
await import_promises31.default.writeFile(target, `# ${title}
|
|
97270
97651
|
|
|
97271
97652
|
${contents}
|
|
@@ -97281,7 +97662,7 @@ ${contents}
|
|
|
97281
97662
|
const keep = 100;
|
|
97282
97663
|
const entries = (await import_promises31.default.readdir(directory)).filter((name) => name.endsWith(".md")).sort();
|
|
97283
97664
|
for (const name of entries.slice(0, Math.max(0, entries.length - keep))) {
|
|
97284
|
-
await import_promises31.default.rm(
|
|
97665
|
+
await import_promises31.default.rm(import_node_path57.default.join(directory, name), { force: true });
|
|
97285
97666
|
}
|
|
97286
97667
|
}
|
|
97287
97668
|
let scheduleTimer;
|
|
@@ -97354,7 +97735,7 @@ ${contents}
|
|
|
97354
97735
|
async function handleSaveSchedule(schedule) {
|
|
97355
97736
|
try {
|
|
97356
97737
|
const schedules = await loadSchedules();
|
|
97357
|
-
const id = schedule.id.length > 0 ? schedule.id : (0,
|
|
97738
|
+
const id = schedule.id.length > 0 ? schedule.id : (0, import_node_crypto21.createHash)("sha256").update(`${schedule.name}:${String(Date.now())}`).digest("hex").slice(0, 12);
|
|
97358
97739
|
const armed = { ...schedule, id, nextRunAt: nextFireTime(schedule, Date.now()) };
|
|
97359
97740
|
await saveSchedules({ ...schedules, [id]: armed });
|
|
97360
97741
|
} catch (error51) {
|
|
@@ -97363,7 +97744,7 @@ ${contents}
|
|
|
97363
97744
|
}
|
|
97364
97745
|
async function createScheduleFromProposal(proposal) {
|
|
97365
97746
|
const schedules = await loadSchedules();
|
|
97366
|
-
const id = (0,
|
|
97747
|
+
const id = (0, import_node_crypto21.createHash)("sha256").update(`${proposal.name}:${String(Date.now())}`).digest("hex").slice(0, 12);
|
|
97367
97748
|
const schedule = {
|
|
97368
97749
|
id,
|
|
97369
97750
|
name: proposal.name,
|
|
@@ -97394,10 +97775,10 @@ ${contents}
|
|
|
97394
97775
|
}
|
|
97395
97776
|
const CLAIM_STALE_MS = 60 * 60 * 1e3;
|
|
97396
97777
|
async function claimSchedule(id) {
|
|
97397
|
-
const claimPath =
|
|
97778
|
+
const claimPath = import_node_path57.default.join(storageDir, "schedule-claims", `${id}.json`);
|
|
97398
97779
|
const mine = JSON.stringify({ pid: process.pid, at: Date.now() });
|
|
97399
97780
|
try {
|
|
97400
|
-
await import_promises31.default.mkdir(
|
|
97781
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(claimPath), { recursive: true });
|
|
97401
97782
|
await import_promises31.default.writeFile(claimPath, mine, { encoding: "utf8", flag: "wx" });
|
|
97402
97783
|
return true;
|
|
97403
97784
|
} catch (error51) {
|
|
@@ -97422,7 +97803,7 @@ ${contents}
|
|
|
97422
97803
|
}
|
|
97423
97804
|
}
|
|
97424
97805
|
async function releaseSchedule(id) {
|
|
97425
|
-
await import_promises31.default.rm(
|
|
97806
|
+
await import_promises31.default.rm(import_node_path57.default.join(storageDir, "schedule-claims", `${id}.json`), { force: true }).catch(() => void 0);
|
|
97426
97807
|
}
|
|
97427
97808
|
async function runSchedule(id, reason) {
|
|
97428
97809
|
if (reason === "due" && !await claimSchedule(id))
|
|
@@ -98117,11 +98498,11 @@ function createShowDiagramTool() {
|
|
|
98117
98498
|
|
|
98118
98499
|
// ../../packages/core/dist/lsp/manager.js
|
|
98119
98500
|
var import_promises32 = __toESM(require("node:fs/promises"), 1);
|
|
98120
|
-
var
|
|
98501
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
98121
98502
|
|
|
98122
98503
|
// ../../packages/core/dist/lsp/catalog.js
|
|
98123
|
-
var
|
|
98124
|
-
var
|
|
98504
|
+
var import_node_fs16 = require("node:fs");
|
|
98505
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
98125
98506
|
var c = (command, ...args) => ({ command, args });
|
|
98126
98507
|
var LSP_LANGUAGES = [
|
|
98127
98508
|
{ id: "python", label: "Python", extensions: ["py", "pyi"], candidates: [c("pyright-langserver", "--stdio"), c("basedpyright-langserver", "--stdio"), c("pylsp"), c("jedi-language-server")] },
|
|
@@ -98169,17 +98550,17 @@ var LSP_LANGUAGES = [
|
|
|
98169
98550
|
{ id: "sql", label: "SQL", extensions: ["sql"], candidates: [c("sql-language-server", "up", "--method", "stdio")] }
|
|
98170
98551
|
];
|
|
98171
98552
|
function languageFor(file2) {
|
|
98172
|
-
const ext =
|
|
98553
|
+
const ext = import_node_path58.default.extname(file2).slice(1).toLowerCase();
|
|
98173
98554
|
return LSP_LANGUAGES.find((l) => l.extensions.includes(ext));
|
|
98174
98555
|
}
|
|
98175
98556
|
function languageIdFor(language, file2) {
|
|
98176
|
-
const ext =
|
|
98557
|
+
const ext = import_node_path58.default.extname(file2).slice(1).toLowerCase();
|
|
98177
98558
|
return language.languageIdFor?.(ext) ?? language.id;
|
|
98178
98559
|
}
|
|
98179
98560
|
var found = /* @__PURE__ */ new Map();
|
|
98180
98561
|
function findOnPath(command, env2 = process.env) {
|
|
98181
|
-
if (
|
|
98182
|
-
return (0,
|
|
98562
|
+
if (import_node_path58.default.isAbsolute(command))
|
|
98563
|
+
return (0, import_node_fs16.existsSync)(command) ? command : void 0;
|
|
98183
98564
|
if (env2 !== process.env)
|
|
98184
98565
|
return searchPath(command, env2);
|
|
98185
98566
|
const hit = found.get(command);
|
|
@@ -98190,12 +98571,12 @@ function findOnPath(command, env2 = process.env) {
|
|
|
98190
98571
|
return value;
|
|
98191
98572
|
}
|
|
98192
98573
|
function searchPath(command, env2) {
|
|
98193
|
-
const dirs = (env2.PATH ?? env2.Path ?? "").split(
|
|
98574
|
+
const dirs = (env2.PATH ?? env2.Path ?? "").split(import_node_path58.default.delimiter).filter((d) => d.length > 0);
|
|
98194
98575
|
const exts = process.platform === "win32" ? ["", ...(env2.PATHEXT ?? ".EXE;.CMD;.BAT").toLowerCase().split(";")] : [""];
|
|
98195
98576
|
for (const dir of dirs) {
|
|
98196
98577
|
for (const ext of exts) {
|
|
98197
|
-
const candidate =
|
|
98198
|
-
if ((0,
|
|
98578
|
+
const candidate = import_node_path58.default.join(dir, command + ext);
|
|
98579
|
+
if ((0, import_node_fs16.existsSync)(candidate) && (process.platform !== "win32" || ext !== "" || /\.(exe|cmd|bat)$/i.test(candidate)))
|
|
98199
98580
|
return candidate;
|
|
98200
98581
|
}
|
|
98201
98582
|
}
|
|
@@ -98427,7 +98808,7 @@ var LspManager = class {
|
|
|
98427
98808
|
return void 0;
|
|
98428
98809
|
const args = [...found2.candidate.args];
|
|
98429
98810
|
if (language.id === "java" && !args.includes("-data"))
|
|
98430
|
-
args.push("-data",
|
|
98811
|
+
args.push("-data", import_node_path59.default.join(this.storageDir, "jdtls-workspace"));
|
|
98431
98812
|
try {
|
|
98432
98813
|
client = new LspClient(found2.executable, args, this.root, this.log);
|
|
98433
98814
|
this.clients.set(language.id, client);
|
|
@@ -98448,7 +98829,7 @@ var LspManager = class {
|
|
|
98448
98829
|
this.failed.set(language.id, client.lastError ?? "stopped");
|
|
98449
98830
|
return void 0;
|
|
98450
98831
|
}
|
|
98451
|
-
return { server:
|
|
98832
|
+
return { server: import_node_path59.default.basename(client.executable).replace(/\.(exe|cmd|bat)$/i, ""), diagnostics: diagnostics ?? [] };
|
|
98452
98833
|
} catch (error51) {
|
|
98453
98834
|
this.failed.set(language.id, error51 instanceof Error ? error51.message : String(error51));
|
|
98454
98835
|
client.dispose();
|
|
@@ -101089,7 +101470,8 @@ reported for these codebases. Commands run with execute_command run on this comp
|
|
|
101089
101470
|
|
|
101090
101471
|
**Git runs on the hub too**: the repository, its remote and its credentials are there, not in the
|
|
101091
101472
|
copy. Fire Code's sidebar counts and its Commit and push / Pull buttons work for a hub codebase while
|
|
101092
|
-
|
|
101473
|
+
any chat of it can run - whichever chat is loaded answers, an unloaded chat page is loaded again, and a
|
|
101474
|
+
sleeping codebase is woken for a Commit or Pull - local edits are saved to the hub first, then git commits and pushes there
|
|
101093
101475
|
(fast-forward-only pulls, fetched here afterwards); "Write with agent" describes the hub's diff. The
|
|
101094
101476
|
agent runs any other git command with \`hub_run\` shell, approved like any command.
|
|
101095
101477
|
**Outside the added folders**: \`hub_browse\` lists folders, finds files by name and reads text files
|
|
@@ -101702,6 +102084,14 @@ the idle time set there. The chats of one codebase **share** its checkpoint stor
|
|
|
101702
102084
|
and its index bookkeeping, so a new chat no longer adds another copy of the codebase's snapshots.
|
|
101703
102085
|
WebView2's cache is capped at 32 MB.
|
|
101704
102086
|
|
|
102087
|
+
**Starting a chat quickly.** MCP servers are processes of each chat's own agent, so they cannot be shared
|
|
102088
|
+
between chats - but what they offer can. Every chat of a codebase remembers each server's tool list in
|
|
102089
|
+
one shared file, so a chat started after a crash or a sleep offers those tools at once and replies
|
|
102090
|
+
without waiting for the servers; a server keeps starting in the background, and a call to one of its
|
|
102091
|
+
tools waits for it. A server with no remembered list is waited for at most 45 seconds, after which the
|
|
102092
|
+
reply goes ahead and its tools join the next message. When starting is still slow, the agent log
|
|
102093
|
+
(\`host.log\`) names each slow part with a \`[startup]\` line - the server, Python, skills or the gateway.
|
|
102094
|
+
|
|
101705
102095
|
**Not in Fire Code**: editor file pickers \u2014 paths are typed. Fire Code's
|
|
101706
102096
|
Settings \u2192 Export source code saves the whole repository as a zip that builds offline.
|
|
101707
102097
|
`
|
|
@@ -101988,6 +102378,19 @@ morning, by which time a toast is long gone. The run log keeps a Report button.
|
|
|
101988
102378
|
"parallel",
|
|
101989
102379
|
"parallel box",
|
|
101990
102380
|
"contract",
|
|
102381
|
+
"strategy per chat",
|
|
102382
|
+
"different strategy",
|
|
102383
|
+
"strategy lost",
|
|
102384
|
+
"keep the strategy",
|
|
102385
|
+
"new topic",
|
|
102386
|
+
"strategy after restart",
|
|
102387
|
+
"connect a box",
|
|
102388
|
+
"box to an agent",
|
|
102389
|
+
"group of agents",
|
|
102390
|
+
"box of agents",
|
|
102391
|
+
"when they all complete",
|
|
102392
|
+
"instructions for each agent",
|
|
102393
|
+
"reference files in instructions",
|
|
101991
102394
|
"read-only role",
|
|
101992
102395
|
"instructions for a role",
|
|
101993
102396
|
"what passed between",
|
|
@@ -102047,12 +102450,33 @@ refuses a round past the maximum - the agent then stops and tells you what is st
|
|
|
102047
102450
|
|
|
102048
102451
|
**A parallel box.** Press **Add a parallel box** on the left and drop steps into it: they are consulted at the same
|
|
102049
102452
|
time, each specialist in its own process, and the strategy carries on when all have answered (the agent uses one
|
|
102050
|
-
ask_agents call). Drag the box to move it with its steps, its corner to resize it. One role belongs in a box
|
|
102051
|
-
If several of them need your approval at once, the prompts come one at a time.
|
|
102052
|
-
|
|
102053
|
-
**
|
|
102054
|
-
|
|
102055
|
-
|
|
102453
|
+
ask_agents call). Drag the box to move it with its steps, its corner to resize it. One role belongs in a parallel box
|
|
102454
|
+
once. If several of them need your approval at once, the prompts come one at a time.
|
|
102455
|
+
|
|
102456
|
+
**A box (a group of steps).** Press **Add a box** for steps done as a group, one after another - in the order of the
|
|
102457
|
+
connectors between them, else as drawn. A box of either kind can be switched on the right ("Run at the same time" or
|
|
102458
|
+
"Run as a group").
|
|
102459
|
+
|
|
102460
|
+
**A strategy belongs to its chat.** Each chat keeps its own strategy, or none: choosing one with **Save and use in
|
|
102461
|
+
this chat** sets it for that chat only, and a new chat starts with none until you pick one. It is saved with the chat
|
|
102462
|
+
and comes back whenever the chat does - reopened from History, after the window reloads, when a Fire Code chat wakes
|
|
102463
|
+
from sleep or restarts after a crash - and it is kept even if you chose it before sending anything. **New chat with a
|
|
102464
|
+
handoff** carries it into the new chat. **Stop using** in the Strategy window takes it off the chat. Every request in
|
|
102465
|
+
the chat follows it, not only the first: for a new topic the agent proposes a new plan that goes through the strategy
|
|
102466
|
+
again, and the back-and-forth loops start afresh for it, with their full number of rounds.
|
|
102467
|
+
|
|
102468
|
+
**Connecting a box.** A box is one step of the flow: connect it like a step, from its own dot on the right edge or with
|
|
102469
|
+
**Connect to...** when it is selected, to a step or to another box - and connect a step or a box into it. A connector
|
|
102470
|
+
out of a box is followed only once every step inside has answered; a connector into a box gives every step inside what
|
|
102471
|
+
arrives along it. A back-and-forth joins two steps, never a box, and a box is not connected to a step inside it -
|
|
102472
|
+
connect the steps inside to each other instead. A contract on a connector out of a box is told to every step inside;
|
|
102473
|
+
its required items are part of that contract rather than checked, since no single answer holds all of them.
|
|
102474
|
+
|
|
102475
|
+
**Each step:** the \u270E on a step opens **Instructions for this specialist** - what is expected of it in this strategy -
|
|
102476
|
+
sent to it with every question it is asked under this strategy. Type **@** in it to name a workspace file or folder,
|
|
102477
|
+
as in the message box: its contents are attached each time the specialist is asked, with the same confinement and
|
|
102478
|
+
deny list as @ in the chat. Leave it empty and the main agent decides what to ask it, from its plan. **Read-only** means
|
|
102479
|
+
it cannot change anything: it gets no tool that edits or runs commands, and recommends instead.
|
|
102056
102480
|
|
|
102057
102481
|
**A contract on a connector** ("What passes along here"): what one step hands to the next, such as "the failing
|
|
102058
102482
|
tests, each with file:line". The first is told its answer must contain it, the second that it will be given it and to
|
|
@@ -103049,7 +103473,7 @@ function createLightCodeHelpTool() {
|
|
|
103049
103473
|
|
|
103050
103474
|
// ../../packages/core/dist/tools/listFiles.js
|
|
103051
103475
|
var import_node_child_process21 = require("node:child_process");
|
|
103052
|
-
var
|
|
103476
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
103053
103477
|
|
|
103054
103478
|
// ../../packages/core/dist/tools/ripgrepError.js
|
|
103055
103479
|
function ripgrepDidNotStart(error51) {
|
|
@@ -103130,7 +103554,7 @@ var listFilesTool = {
|
|
|
103130
103554
|
});
|
|
103131
103555
|
if (files.length === 0)
|
|
103132
103556
|
return noFiles;
|
|
103133
|
-
const listed = files.map((file2) => file2.split("/").join(
|
|
103557
|
+
const listed = files.map((file2) => file2.split("/").join(import_node_path60.default.sep)).join("\n");
|
|
103134
103558
|
return { content: truncated ? `${listed}
|
|
103135
103559
|
(listing cut short \u2014 list a narrower folder)` : listed };
|
|
103136
103560
|
}
|
|
@@ -103198,10 +103622,10 @@ function readSmall(raw, params3) {
|
|
|
103198
103622
|
const end = params3.limit !== void 0 ? start + params3.limit : lines2.length;
|
|
103199
103623
|
return number4(lines2.slice(start, end), start + 1);
|
|
103200
103624
|
}
|
|
103201
|
-
async function readLarge(
|
|
103625
|
+
async function readLarge(fs48, realPath, params3, size) {
|
|
103202
103626
|
const human = formatBytes(size);
|
|
103203
103627
|
if (params3.tail !== void 0) {
|
|
103204
|
-
const part = await readTail(
|
|
103628
|
+
const part = await readTail(fs48, realPath, size, params3.tail);
|
|
103205
103629
|
return [
|
|
103206
103630
|
`${human} file \u2014 last ${String(part.lines.length)} lines.`,
|
|
103207
103631
|
/*
|
|
@@ -103216,7 +103640,7 @@ async function readLarge(fs46, realPath, params3, size) {
|
|
|
103216
103640
|
}
|
|
103217
103641
|
if (params3.offset !== void 0) {
|
|
103218
103642
|
const limit = params3.limit ?? DEFAULT_LARGE_LIMIT;
|
|
103219
|
-
const part = await readLineWindow(
|
|
103643
|
+
const part = await readLineWindow(fs48, realPath, size, params3.offset, limit);
|
|
103220
103644
|
const shown2 = part.lines.length;
|
|
103221
103645
|
return [
|
|
103222
103646
|
`${human} file \u2014 lines ${String(params3.offset)}\u2013${String(params3.offset + shown2 - 1)}${part.hasMoreAfter ? ", more follows" : " (end of file)"}.`,
|
|
@@ -103224,7 +103648,7 @@ async function readLarge(fs46, realPath, params3, size) {
|
|
|
103224
103648
|
number4(part.lines, params3.offset)
|
|
103225
103649
|
].join("\n");
|
|
103226
103650
|
}
|
|
103227
|
-
const total = await countLines(
|
|
103651
|
+
const total = await countLines(fs48, realPath, size);
|
|
103228
103652
|
return [
|
|
103229
103653
|
`${realPathName(realPath)} is ${human} (${total.toLocaleString()} lines) \u2014 too large to read at once.`,
|
|
103230
103654
|
"",
|
|
@@ -103359,7 +103783,7 @@ var searchFilesTool = {
|
|
|
103359
103783
|
};
|
|
103360
103784
|
|
|
103361
103785
|
// ../../packages/core/dist/tools/writeToFile.js
|
|
103362
|
-
var
|
|
103786
|
+
var import_node_path61 = __toESM(require("node:path"), 1);
|
|
103363
103787
|
var paramsSchema23 = external_exports.object({
|
|
103364
103788
|
path: external_exports.string().min(1).describe("Path to the file, relative to the workspace root."),
|
|
103365
103789
|
content: external_exports.string().describe("Full file content to write.")
|
|
@@ -103387,7 +103811,7 @@ var writeToFileTool = {
|
|
|
103387
103811
|
return { content: changed, isError: true, path: params3.path };
|
|
103388
103812
|
}
|
|
103389
103813
|
if (!exists2) {
|
|
103390
|
-
await context.fs.mkdir(
|
|
103814
|
+
await context.fs.mkdir(import_node_path61.default.dirname(resolved.realPath));
|
|
103391
103815
|
}
|
|
103392
103816
|
await context.fs.writeFile(resolved.realPath, params3.content);
|
|
103393
103817
|
await recordWrite(context, resolved.realPath);
|
|
@@ -103489,14 +103913,14 @@ function createDefaultToolRegistry() {
|
|
|
103489
103913
|
|
|
103490
103914
|
// ../../packages/core/dist/dataset/store.js
|
|
103491
103915
|
var import_promises33 = __toESM(require("node:fs/promises"), 1);
|
|
103492
|
-
var
|
|
103916
|
+
var import_node_path62 = __toESM(require("node:path"), 1);
|
|
103493
103917
|
var DatasetStore = class {
|
|
103494
103918
|
filePath;
|
|
103495
103919
|
statePath;
|
|
103496
103920
|
constructor(storageDir, datasetId) {
|
|
103497
103921
|
const safe = datasetId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
103498
|
-
this.filePath =
|
|
103499
|
-
this.statePath =
|
|
103922
|
+
this.filePath = import_node_path62.default.join(storageDir, "datasets", `${safe}.jsonl`);
|
|
103923
|
+
this.statePath = import_node_path62.default.join(storageDir, "datasets", `${safe}.state.json`);
|
|
103500
103924
|
}
|
|
103501
103925
|
/** Every record. A malformed line is skipped — one bad line costs one record, not the corpus. */
|
|
103502
103926
|
async load() {
|
|
@@ -103524,7 +103948,7 @@ var DatasetStore = class {
|
|
|
103524
103948
|
async append(records) {
|
|
103525
103949
|
if (records.length === 0)
|
|
103526
103950
|
return;
|
|
103527
|
-
await import_promises33.default.mkdir(
|
|
103951
|
+
await import_promises33.default.mkdir(import_node_path62.default.dirname(this.filePath), { recursive: true });
|
|
103528
103952
|
await import_promises33.default.writeFile(this.filePath, "", { flag: "a" });
|
|
103529
103953
|
const lines2 = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
103530
103954
|
await import_promises33.default.appendFile(this.filePath, `${lines2}
|
|
@@ -103532,7 +103956,7 @@ var DatasetStore = class {
|
|
|
103532
103956
|
}
|
|
103533
103957
|
/** Rewrites with exactly these. Temp-and-rename, so an interrupted prune leaves the old file. */
|
|
103534
103958
|
async replace(records) {
|
|
103535
|
-
await import_promises33.default.mkdir(
|
|
103959
|
+
await import_promises33.default.mkdir(import_node_path62.default.dirname(this.filePath), { recursive: true });
|
|
103536
103960
|
const temporary = `${this.filePath}.tmp`;
|
|
103537
103961
|
const body = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
103538
103962
|
await import_promises33.default.writeFile(temporary, records.length === 0 ? "" : `${body}
|
|
@@ -103586,7 +104010,7 @@ var DatasetStore = class {
|
|
|
103586
104010
|
}
|
|
103587
104011
|
}
|
|
103588
104012
|
async recordSync(at) {
|
|
103589
|
-
await import_promises33.default.mkdir(
|
|
104013
|
+
await import_promises33.default.mkdir(import_node_path62.default.dirname(this.statePath), { recursive: true });
|
|
103590
104014
|
const temporary = `${this.statePath}.tmp`;
|
|
103591
104015
|
await import_promises33.default.writeFile(temporary, JSON.stringify({ lastSyncedAt: at }), "utf8");
|
|
103592
104016
|
await replaceFile(temporary, this.statePath);
|
|
@@ -103925,8 +104349,8 @@ That is a fault in the tool itself, or the source is unreachable from here. Fix
|
|
|
103925
104349
|
}
|
|
103926
104350
|
|
|
103927
104351
|
// ../../packages/core/dist/s3/sigv4.js
|
|
103928
|
-
var
|
|
103929
|
-
var EMPTY_PAYLOAD_SHA256 = (0,
|
|
104352
|
+
var import_node_crypto22 = require("node:crypto");
|
|
104353
|
+
var EMPTY_PAYLOAD_SHA256 = (0, import_node_crypto22.createHash)("sha256").update("").digest("hex");
|
|
103930
104354
|
function encodeSegment(segment) {
|
|
103931
104355
|
return encodeURIComponent(segment).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
103932
104356
|
}
|
|
@@ -103950,10 +104374,10 @@ function amzDate(now) {
|
|
|
103950
104374
|
return `${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z`;
|
|
103951
104375
|
}
|
|
103952
104376
|
function signingKey(secretAccessKey, date5, region, service) {
|
|
103953
|
-
const dateKey = (0,
|
|
103954
|
-
const regionKey = (0,
|
|
103955
|
-
const serviceKey = (0,
|
|
103956
|
-
return (0,
|
|
104377
|
+
const dateKey = (0, import_node_crypto22.createHmac)("sha256", `AWS4${secretAccessKey}`).update(date5).digest();
|
|
104378
|
+
const regionKey = (0, import_node_crypto22.createHmac)("sha256", dateKey).update(region).digest();
|
|
104379
|
+
const serviceKey = (0, import_node_crypto22.createHmac)("sha256", regionKey).update(service).digest();
|
|
104380
|
+
return (0, import_node_crypto22.createHmac)("sha256", serviceKey).update("aws4_request").digest();
|
|
103957
104381
|
}
|
|
103958
104382
|
function signRequest(input) {
|
|
103959
104383
|
const service = input.service ?? "s3";
|
|
@@ -103962,7 +104386,7 @@ function signRequest(input) {
|
|
|
103962
104386
|
const date5 = timestamp.slice(0, 8);
|
|
103963
104387
|
const url2 = new URL(input.url);
|
|
103964
104388
|
const body = input.body ?? Buffer.alloc(0);
|
|
103965
|
-
const payloadHash = (0,
|
|
104389
|
+
const payloadHash = (0, import_node_crypto22.createHash)("sha256").update(body).digest("hex");
|
|
103966
104390
|
const headers = {
|
|
103967
104391
|
...input.headers,
|
|
103968
104392
|
host: url2.host,
|
|
@@ -103986,9 +104410,9 @@ function signRequest(input) {
|
|
|
103986
104410
|
"AWS4-HMAC-SHA256",
|
|
103987
104411
|
timestamp,
|
|
103988
104412
|
scope,
|
|
103989
|
-
(0,
|
|
104413
|
+
(0, import_node_crypto22.createHash)("sha256").update(canonicalRequest).digest("hex")
|
|
103990
104414
|
].join("\n");
|
|
103991
|
-
const signature = (0,
|
|
104415
|
+
const signature = (0, import_node_crypto22.createHmac)("sha256", signingKey(input.secretAccessKey, date5, input.region, service)).update(stringToSign).digest("hex");
|
|
103992
104416
|
return {
|
|
103993
104417
|
headers: {
|
|
103994
104418
|
...headers,
|
|
@@ -104018,8 +104442,8 @@ var S3Client = class {
|
|
|
104018
104442
|
const host = inPath ? origin.host : `${bucket}.${origin.host}`;
|
|
104019
104443
|
const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
|
|
104020
104444
|
const prefix = inPath ? `${mount}/${bucket}` : mount;
|
|
104021
|
-
const
|
|
104022
|
-
const url2 = new URL(`${origin.protocol}//${host}${prefix}${
|
|
104445
|
+
const path68 = key3 === "" ? "" : `/${key3.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
|
|
104446
|
+
const url2 = new URL(`${origin.protocol}//${host}${prefix}${path68}`);
|
|
104023
104447
|
for (const [name, value] of Object.entries(call.query ?? {}))
|
|
104024
104448
|
url2.searchParams.set(name, value);
|
|
104025
104449
|
return url2.toString();
|
|
@@ -104286,9 +104710,9 @@ async function syncFromS3(options) {
|
|
|
104286
104710
|
return result;
|
|
104287
104711
|
}
|
|
104288
104712
|
var MANIFEST_NAME = ".lightcode-sync.json";
|
|
104289
|
-
async function readManifest(
|
|
104713
|
+
async function readManifest(fs48, manifestPath) {
|
|
104290
104714
|
try {
|
|
104291
|
-
const parsed = JSON.parse((await
|
|
104715
|
+
const parsed = JSON.parse((await fs48.readBytes(manifestPath)).toString("utf8"));
|
|
104292
104716
|
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
104293
104717
|
} catch {
|
|
104294
104718
|
return {};
|
|
@@ -104306,14 +104730,14 @@ function join2(dir, relative) {
|
|
|
104306
104730
|
const left = dir.replace(/[\\/]+$/, "");
|
|
104307
104731
|
return `${left}/${relative}`;
|
|
104308
104732
|
}
|
|
104309
|
-
async function writeWhole3(
|
|
104310
|
-
if (
|
|
104311
|
-
await
|
|
104733
|
+
async function writeWhole3(fs48, target, bytes) {
|
|
104734
|
+
if (fs48.rename === void 0) {
|
|
104735
|
+
await fs48.writeBytes(target, bytes);
|
|
104312
104736
|
return;
|
|
104313
104737
|
}
|
|
104314
104738
|
const temporary = `${target}.${String(process.pid)}.${String(Date.now())}.part`;
|
|
104315
|
-
await
|
|
104316
|
-
await
|
|
104739
|
+
await fs48.writeBytes(temporary, bytes);
|
|
104740
|
+
await fs48.rename(temporary, target);
|
|
104317
104741
|
}
|
|
104318
104742
|
function dirname(filePath) {
|
|
104319
104743
|
const cut = filePath.lastIndexOf("/");
|
|
@@ -104509,15 +104933,15 @@ function createS3Tools(targets) {
|
|
|
104509
104933
|
}
|
|
104510
104934
|
|
|
104511
104935
|
// ../../packages/core/dist/s3/localFolder.js
|
|
104512
|
-
var
|
|
104936
|
+
var import_node_crypto23 = require("node:crypto");
|
|
104513
104937
|
function mirrorFolder(options) {
|
|
104514
104938
|
const connection = safeSegment(options.connectionId);
|
|
104515
|
-
const digest = (0,
|
|
104939
|
+
const digest = (0, import_node_crypto23.createHash)("sha256").update((options.prefix ?? "").trim().toLowerCase()).digest("hex").slice(0, 8);
|
|
104516
104940
|
return join3(options.storageDir, "s3", connection, `${options.kind}-${digest}`);
|
|
104517
104941
|
}
|
|
104518
104942
|
function safeSegment(id) {
|
|
104519
104943
|
const cleaned = id.replace(/[^a-zA-Z0-9._-]/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 40);
|
|
104520
|
-
const suffix = (0,
|
|
104944
|
+
const suffix = (0, import_node_crypto23.createHash)("sha256").update(id).digest("hex").slice(0, 6);
|
|
104521
104945
|
return `${cleaned === "" ? "connection" : cleaned}-${suffix}`;
|
|
104522
104946
|
}
|
|
104523
104947
|
function join3(...parts) {
|
|
@@ -104634,13 +105058,13 @@ function reachableOrigins(hosts, extra = []) {
|
|
|
104634
105058
|
}
|
|
104635
105059
|
|
|
104636
105060
|
// src/identity.ts
|
|
104637
|
-
var
|
|
105061
|
+
var import_node_crypto24 = __toESM(require("node:crypto"), 1);
|
|
104638
105062
|
var SingleUserIdentity = class _SingleUserIdentity {
|
|
104639
105063
|
describe;
|
|
104640
105064
|
static PRINCIPAL = { id: "local", displayName: "Local user" };
|
|
104641
105065
|
principal;
|
|
104642
105066
|
/** Long-lived, minted per server run, only ever sent in an `Authorization` header. */
|
|
104643
|
-
sessionToken =
|
|
105067
|
+
sessionToken = import_node_crypto24.default.randomBytes(32).toString("base64url");
|
|
104644
105068
|
/**
|
|
104645
105069
|
* Single-use and short-lived, because it travels in the launch URL's fragment where it
|
|
104646
105070
|
* can end up in shell history or a terminal scrollback (§14).
|
|
@@ -104650,7 +105074,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
104650
105074
|
* raises it, and what that costs is stated where it is set: a longer window is a longer time in
|
|
104651
105075
|
* which somebody reading that scrollback can use it before you do.
|
|
104652
105076
|
*/
|
|
104653
|
-
handoffToken =
|
|
105077
|
+
handoffToken = import_node_crypto24.default.randomBytes(32).toString("base64url");
|
|
104654
105078
|
handoffExpiresAt;
|
|
104655
105079
|
handoffSeconds;
|
|
104656
105080
|
/**
|
|
@@ -104684,7 +105108,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
104684
105108
|
* which is the same person it was printed to in the first place.
|
|
104685
105109
|
*/
|
|
104686
105110
|
remintHandoff() {
|
|
104687
|
-
this.handoffToken =
|
|
105111
|
+
this.handoffToken = import_node_crypto24.default.randomBytes(32).toString("base64url");
|
|
104688
105112
|
this.handoffExpiresAt = Date.now() + this.handoffSeconds * 1e3;
|
|
104689
105113
|
return this.handoffToken;
|
|
104690
105114
|
}
|
|
@@ -104723,10 +105147,10 @@ function timingSafeEquals(a, b) {
|
|
|
104723
105147
|
const left = Buffer.from(a);
|
|
104724
105148
|
const right = Buffer.from(b);
|
|
104725
105149
|
if (left.length !== right.length) return false;
|
|
104726
|
-
return
|
|
105150
|
+
return import_node_crypto24.default.timingSafeEqual(left, right);
|
|
104727
105151
|
}
|
|
104728
105152
|
function storageKeyFor(principal) {
|
|
104729
|
-
return
|
|
105153
|
+
return import_node_crypto24.default.createHash("sha256").update(principal.id).digest("hex").slice(0, 32);
|
|
104730
105154
|
}
|
|
104731
105155
|
var OpenIdentity = class _OpenIdentity {
|
|
104732
105156
|
describe = "single user, no token (--no-token)";
|
|
@@ -104997,22 +105421,22 @@ async function readJsonBody(request2, maxBytes = 32 * 1024 * 1024) {
|
|
|
104997
105421
|
|
|
104998
105422
|
// src/fileSecretStore.ts
|
|
104999
105423
|
var import_promises34 = __toESM(require("node:fs/promises"), 1);
|
|
105000
|
-
var
|
|
105424
|
+
var import_node_path63 = __toESM(require("node:path"), 1);
|
|
105001
105425
|
|
|
105002
105426
|
// src/vaultCrypto.ts
|
|
105003
|
-
var
|
|
105427
|
+
var import_node_crypto25 = require("node:crypto");
|
|
105004
105428
|
function isVaultEnvelope(value) {
|
|
105005
105429
|
const v = value;
|
|
105006
105430
|
return typeof v === "object" && v !== null && v.sunVault === 1 && typeof v.iv === "string" && typeof v.tag === "string" && typeof v.data === "string";
|
|
105007
105431
|
}
|
|
105008
105432
|
function sealSecrets(secrets, key3) {
|
|
105009
|
-
const iv = (0,
|
|
105010
|
-
const cipher = (0,
|
|
105433
|
+
const iv = (0, import_node_crypto25.randomBytes)(12);
|
|
105434
|
+
const cipher = (0, import_node_crypto25.createCipheriv)("aes-256-gcm", key3, iv);
|
|
105011
105435
|
const data = Buffer.concat([cipher.update(JSON.stringify(secrets), "utf8"), cipher.final()]);
|
|
105012
105436
|
return { sunVault: 1, iv: iv.toString("base64"), tag: cipher.getAuthTag().toString("base64"), data: data.toString("base64") };
|
|
105013
105437
|
}
|
|
105014
105438
|
function openSecrets(envelope, key3) {
|
|
105015
|
-
const decipher = (0,
|
|
105439
|
+
const decipher = (0, import_node_crypto25.createDecipheriv)("aes-256-gcm", key3, Buffer.from(envelope.iv, "base64"));
|
|
105016
105440
|
decipher.setAuthTag(Buffer.from(envelope.tag, "base64"));
|
|
105017
105441
|
const plain = Buffer.concat([decipher.update(Buffer.from(envelope.data, "base64")), decipher.final()]);
|
|
105018
105442
|
const parsed = JSON.parse(plain.toString("utf8"));
|
|
@@ -105095,7 +105519,7 @@ var FileSecretStore = class {
|
|
|
105095
105519
|
);
|
|
105096
105520
|
}
|
|
105097
105521
|
mutate(secrets);
|
|
105098
|
-
await import_promises34.default.mkdir(
|
|
105522
|
+
await import_promises34.default.mkdir(import_node_path63.default.dirname(this.filePath), { recursive: true });
|
|
105099
105523
|
const temp = `${this.filePath}.${process.pid}.tmp`;
|
|
105100
105524
|
const body = this.key === void 0 ? secrets : sealSecrets(secrets, this.key);
|
|
105101
105525
|
await import_promises34.default.writeFile(temp, JSON.stringify(body, null, 2), { encoding: "utf8", mode: 384 });
|
|
@@ -105130,9 +105554,9 @@ var FileSecretStore = class {
|
|
|
105130
105554
|
};
|
|
105131
105555
|
|
|
105132
105556
|
// src/reviewQueue.ts
|
|
105133
|
-
var
|
|
105557
|
+
var import_node_crypto26 = __toESM(require("node:crypto"), 1);
|
|
105134
105558
|
var import_promises35 = __toESM(require("node:fs/promises"), 1);
|
|
105135
|
-
var
|
|
105559
|
+
var import_node_path64 = __toESM(require("node:path"), 1);
|
|
105136
105560
|
var ReviewQueue = class {
|
|
105137
105561
|
constructor(filePath) {
|
|
105138
105562
|
this.filePath = filePath;
|
|
@@ -105151,7 +105575,7 @@ var ReviewQueue = class {
|
|
|
105151
105575
|
}
|
|
105152
105576
|
async persist(items) {
|
|
105153
105577
|
this.cache = items;
|
|
105154
|
-
await import_promises35.default.mkdir(
|
|
105578
|
+
await import_promises35.default.mkdir(import_node_path64.default.dirname(this.filePath), { recursive: true });
|
|
105155
105579
|
const temporary = `${this.filePath}.tmp`;
|
|
105156
105580
|
await import_promises35.default.writeFile(temporary, JSON.stringify(items, null, 2), { encoding: "utf8", mode: 384 });
|
|
105157
105581
|
await replaceFile(temporary, this.filePath);
|
|
@@ -105169,7 +105593,7 @@ var ReviewQueue = class {
|
|
|
105169
105593
|
);
|
|
105170
105594
|
const queued = {
|
|
105171
105595
|
...request2,
|
|
105172
|
-
id:
|
|
105596
|
+
id: import_node_crypto26.default.randomUUID(),
|
|
105173
105597
|
submittedAt: Date.now(),
|
|
105174
105598
|
status: "pending"
|
|
105175
105599
|
};
|
|
@@ -105392,8 +105816,8 @@ var RoutedSecretStore = class {
|
|
|
105392
105816
|
|
|
105393
105817
|
// src/userVariables.ts
|
|
105394
105818
|
var import_promises36 = __toESM(require("node:fs/promises"), 1);
|
|
105395
|
-
var
|
|
105396
|
-
var
|
|
105819
|
+
var import_node_fs17 = require("node:fs");
|
|
105820
|
+
var import_node_path65 = __toESM(require("node:path"), 1);
|
|
105397
105821
|
var UserVariableStore = class {
|
|
105398
105822
|
constructor(filePath) {
|
|
105399
105823
|
this.filePath = filePath;
|
|
@@ -105408,7 +105832,7 @@ var UserVariableStore = class {
|
|
|
105408
105832
|
}
|
|
105409
105833
|
async save(variables) {
|
|
105410
105834
|
const parsed = sessionVariablesSchema.parse(variables);
|
|
105411
|
-
await import_promises36.default.mkdir(
|
|
105835
|
+
await import_promises36.default.mkdir(import_node_path65.default.dirname(this.filePath), { recursive: true });
|
|
105412
105836
|
const temporary = `${this.filePath}.tmp`;
|
|
105413
105837
|
await import_promises36.default.writeFile(temporary, JSON.stringify({ variables: parsed }, null, 2), {
|
|
105414
105838
|
encoding: "utf8",
|
|
@@ -105419,14 +105843,14 @@ var UserVariableStore = class {
|
|
|
105419
105843
|
}
|
|
105420
105844
|
};
|
|
105421
105845
|
function userVariableStoreFor(dataDir, principal) {
|
|
105422
|
-
return new UserVariableStore(userVariablesPath(
|
|
105846
|
+
return new UserVariableStore(userVariablesPath(import_node_path65.default.join(dataDir, "users", storageKeyFor(principal))));
|
|
105423
105847
|
}
|
|
105424
105848
|
function userVariablesPath(userDir) {
|
|
105425
|
-
return
|
|
105849
|
+
return import_node_path65.default.join(userDir, "variables.json");
|
|
105426
105850
|
}
|
|
105427
105851
|
function readVariablesFile(filePath) {
|
|
105428
105852
|
try {
|
|
105429
|
-
const raw = JSON.parse((0,
|
|
105853
|
+
const raw = JSON.parse((0, import_node_fs17.readFileSync)(filePath, "utf8"));
|
|
105430
105854
|
const parsed = sessionVariablesSchema.safeParse(raw["variables"]);
|
|
105431
105855
|
return parsed.success ? parsed.data : [];
|
|
105432
105856
|
} catch {
|
|
@@ -105450,13 +105874,13 @@ function hostedUser(env2 = process.env) {
|
|
|
105450
105874
|
}
|
|
105451
105875
|
|
|
105452
105876
|
// src/session.ts
|
|
105453
|
-
var
|
|
105877
|
+
var import_node_fs18 = require("node:fs");
|
|
105454
105878
|
var import_promises37 = __toESM(require("node:fs/promises"), 1);
|
|
105455
|
-
var
|
|
105879
|
+
var import_node_path67 = __toESM(require("node:path"), 1);
|
|
105456
105880
|
|
|
105457
105881
|
// src/credentialTool.ts
|
|
105458
105882
|
var import_node_child_process23 = require("node:child_process");
|
|
105459
|
-
var
|
|
105883
|
+
var import_node_path66 = __toESM(require("node:path"), 1);
|
|
105460
105884
|
var CREDENTIAL_PREFIX2 = "tool:";
|
|
105461
105885
|
var WRAPPER = [
|
|
105462
105886
|
"import importlib.util, json, sys",
|
|
@@ -105476,7 +105900,7 @@ async function fetchCredential(options, reference) {
|
|
|
105476
105900
|
if (name.length === 0) return { problem: "A credential reference needs a name: tool:<name>." };
|
|
105477
105901
|
const budget = options.timeoutMs ?? 3e4;
|
|
105478
105902
|
const run3 = await new Promise((resolve) => {
|
|
105479
|
-
const child = (0, import_node_child_process23.spawn)(options.interpreter, ["-c", WRAPPER,
|
|
105903
|
+
const child = (0, import_node_child_process23.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path66.default.resolve(options.file), name], {
|
|
105480
105904
|
windowsHide: true,
|
|
105481
105905
|
// The environment this was started in, as with the identity function: the libraries that
|
|
105482
105906
|
// hold credentials are configured through it, and nothing here is model-authored.
|
|
@@ -105672,7 +106096,7 @@ var FileConfigStore = class {
|
|
|
105672
106096
|
const filePath = this.pathFor(scope);
|
|
105673
106097
|
if (filePath === void 0)
|
|
105674
106098
|
throw new Error(`Cannot write ${scope} config: no workspace is open`);
|
|
105675
|
-
await import_promises37.default.mkdir(
|
|
106099
|
+
await import_promises37.default.mkdir(import_node_path67.default.dirname(filePath), { recursive: true });
|
|
105676
106100
|
const temporary = `${filePath}.${process.pid.toString(36)}.tmp`;
|
|
105677
106101
|
await import_promises37.default.writeFile(temporary, contents, { encoding: "utf8", mode: 384 });
|
|
105678
106102
|
await replaceFile(temporary, filePath);
|
|
@@ -105709,8 +106133,8 @@ var FileConfigStore = class {
|
|
|
105709
106133
|
};
|
|
105710
106134
|
let watcher;
|
|
105711
106135
|
try {
|
|
105712
|
-
watcher = (0,
|
|
105713
|
-
if (filename ===
|
|
106136
|
+
watcher = (0, import_node_fs18.watch)(import_node_path67.default.dirname(filePath), (_event, filename) => {
|
|
106137
|
+
if (filename === import_node_path67.default.basename(filePath)) onChange();
|
|
105714
106138
|
});
|
|
105715
106139
|
} catch {
|
|
105716
106140
|
}
|
|
@@ -105738,7 +106162,7 @@ var FileWorkspaceState = class {
|
|
|
105738
106162
|
async set(key3, value) {
|
|
105739
106163
|
if (value === void 0) delete this.values[key3];
|
|
105740
106164
|
else this.values[key3] = value;
|
|
105741
|
-
await import_promises37.default.mkdir(
|
|
106165
|
+
await import_promises37.default.mkdir(import_node_path67.default.dirname(this.filePath), { recursive: true });
|
|
105742
106166
|
await import_promises37.default.writeFile(this.filePath, JSON.stringify(this.values, null, 2), {
|
|
105743
106167
|
encoding: "utf8",
|
|
105744
106168
|
mode: 384
|
|
@@ -105788,7 +106212,7 @@ function createBrowserUi(workspaceRoot, post, fastFs, shared) {
|
|
|
105788
106212
|
openFile: async (filePath) => {
|
|
105789
106213
|
try {
|
|
105790
106214
|
post(
|
|
105791
|
-
[`[info] ${
|
|
106215
|
+
[`[info] ${import_node_path67.default.basename(filePath)}`, "", await import_promises37.default.readFile(filePath, "utf8")].join("\n")
|
|
105792
106216
|
);
|
|
105793
106217
|
} catch (error51) {
|
|
105794
106218
|
post(`[warning] Could not read ${filePath}: ${String(error51)}`);
|
|
@@ -105832,7 +106256,7 @@ function createBrowserUi(workspaceRoot, post, fastFs, shared) {
|
|
|
105832
106256
|
for (const entry of entries) {
|
|
105833
106257
|
if (found2.length >= limit) return;
|
|
105834
106258
|
if (entry.name.startsWith(".") && entry.name !== ".env") continue;
|
|
105835
|
-
const full =
|
|
106259
|
+
const full = import_node_path67.default.join(dir, entry.name);
|
|
105836
106260
|
if (entry.isDirectory()) {
|
|
105837
106261
|
if (skip.has(entry.name)) continue;
|
|
105838
106262
|
if (mode === "folders" && (needle.length === 0 || entry.name.toLowerCase().includes(needle))) found2.push(full);
|
|
@@ -105870,11 +106294,11 @@ var SHARED_COLLECTIONS = [
|
|
|
105870
106294
|
{ key: "mcpServers" }
|
|
105871
106295
|
];
|
|
105872
106296
|
async function createSession(options) {
|
|
105873
|
-
const userDir =
|
|
106297
|
+
const userDir = import_node_path67.default.join(options.dataDir, "users", storageKeyFor(options.principal));
|
|
105874
106298
|
await import_promises37.default.mkdir(userDir, { recursive: true, mode: 448 });
|
|
105875
106299
|
const variableStore = new UserVariableStore(userVariablesPath(userDir));
|
|
105876
106300
|
const userVariables = () => variableStore.read();
|
|
105877
|
-
const workspaceState = new FileWorkspaceState(
|
|
106301
|
+
const workspaceState = new FileWorkspaceState(import_node_path67.default.join(userDir, "workspace-state.json"));
|
|
105878
106302
|
await workspaceState.load();
|
|
105879
106303
|
const services = {
|
|
105880
106304
|
/*
|
|
@@ -105969,16 +106393,16 @@ async function createSession(options) {
|
|
|
105969
106393
|
*/
|
|
105970
106394
|
secrets: new CredentialPointerStore(
|
|
105971
106395
|
withCredentialTool(
|
|
105972
|
-
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ??
|
|
105973
|
-
new FileSecretStore(options.secretsFile ??
|
|
106396
|
+
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ?? import_node_path67.default.join(userDir, "secrets.json"), options.secretsKey) : new RoutedSecretStore(
|
|
106397
|
+
new FileSecretStore(options.secretsFile ?? import_node_path67.default.join(userDir, "secrets.json"), options.secretsKey),
|
|
105974
106398
|
options.sharedSecrets
|
|
105975
106399
|
),
|
|
105976
106400
|
options
|
|
105977
106401
|
)
|
|
105978
106402
|
),
|
|
105979
106403
|
configStore: withSharedEntries(
|
|
105980
|
-
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ??
|
|
105981
|
-
new FileConfigStore(options.configFile ??
|
|
106404
|
+
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ?? import_node_path67.default.join(userDir, "config.json"), options.workspaceRoot) : new SharedProfileConfigStore(
|
|
106405
|
+
new FileConfigStore(options.configFile ?? import_node_path67.default.join(userDir, "config.json"), options.workspaceRoot),
|
|
105982
106406
|
options.sharedProfiles
|
|
105983
106407
|
),
|
|
105984
106408
|
options
|
|
@@ -106096,8 +106520,8 @@ async function startServer(options) {
|
|
|
106096
106520
|
));
|
|
106097
106521
|
const roles = options.roles ?? SINGLE_USER_POLICY;
|
|
106098
106522
|
const sharedStore = options.sharedConfig;
|
|
106099
|
-
const sharedSecretStore = new FileSecretStore(
|
|
106100
|
-
const reviews = new ReviewQueue(
|
|
106523
|
+
const sharedSecretStore = new FileSecretStore(import_node_path68.default.join(options.dataDir, "shared-secrets.json"));
|
|
106524
|
+
const reviews = new ReviewQueue(import_node_path68.default.join(options.dataDir, "reviews.json"));
|
|
106101
106525
|
let sharedCache = {
|
|
106102
106526
|
variables: [],
|
|
106103
106527
|
adminIds: [],
|
|
@@ -106478,14 +106902,14 @@ async function startServer(options) {
|
|
|
106478
106902
|
return "No workspace is open, so there is nowhere to write it.";
|
|
106479
106903
|
try {
|
|
106480
106904
|
if (item2.kind === "skill") {
|
|
106481
|
-
const dir2 =
|
|
106905
|
+
const dir2 = import_node_path68.default.join(options.workspaceRoot, ".lightcode", "skills");
|
|
106482
106906
|
await import_promises38.default.mkdir(dir2, { recursive: true });
|
|
106483
|
-
await import_promises38.default.writeFile(
|
|
106907
|
+
await import_promises38.default.writeFile(import_node_path68.default.join(dir2, `${item2.name}.md`), item2.content, "utf8");
|
|
106484
106908
|
return void 0;
|
|
106485
106909
|
}
|
|
106486
|
-
const dir =
|
|
106910
|
+
const dir = import_node_path68.default.join(options.workspaceRoot, ".lightcode", "tools");
|
|
106487
106911
|
await import_promises38.default.mkdir(dir, { recursive: true });
|
|
106488
|
-
await import_promises38.default.writeFile(
|
|
106912
|
+
await import_promises38.default.writeFile(import_node_path68.default.join(dir, `${item2.name}.py`), item2.content, "utf8");
|
|
106489
106913
|
return void 0;
|
|
106490
106914
|
} catch (error51) {
|
|
106491
106915
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -106524,7 +106948,7 @@ async function startServer(options) {
|
|
|
106524
106948
|
connection.transport.post({ type: "credentials", credentials: await readCredentials() });
|
|
106525
106949
|
}
|
|
106526
106950
|
if (options.credentialsFile !== void 0) {
|
|
106527
|
-
(0,
|
|
106951
|
+
(0, import_node_fs19.watchFile)(options.credentialsFile, { interval: 1500 }, () => {
|
|
106528
106952
|
for (const connection of connections.values()) void postCredentials(connection);
|
|
106529
106953
|
});
|
|
106530
106954
|
}
|
|
@@ -106634,7 +107058,7 @@ async function startServer(options) {
|
|
|
106634
107058
|
return;
|
|
106635
107059
|
}
|
|
106636
107060
|
response.writeHead(200, {
|
|
106637
|
-
"Content-Type": CONTENT_TYPES2[
|
|
107061
|
+
"Content-Type": CONTENT_TYPES2[import_node_path68.default.extname(asset)] ?? "application/octet-stream",
|
|
106638
107062
|
...securityHeaders()
|
|
106639
107063
|
});
|
|
106640
107064
|
response.end(body);
|