@chosengeneration/light-code 0.187.0 → 0.188.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 +980 -665
- package/dist/server.cjs +937 -622
- 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 path67 = 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 (path67 && !path67.startsWith("/")) {
|
|
502
|
+
path67 = `/${path67}`;
|
|
503
503
|
}
|
|
504
|
-
url2 = new URL(origin +
|
|
504
|
+
url2 = new URL(origin + path67);
|
|
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(path67) {
|
|
2119
|
+
if (typeof path67 !== "string") {
|
|
2120
2120
|
return "";
|
|
2121
2121
|
}
|
|
2122
|
-
for (var i =
|
|
2123
|
-
switch (
|
|
2122
|
+
for (var i = path67.length - 1; i >= 0; --i) {
|
|
2123
|
+
switch (path67.charCodeAt(i)) {
|
|
2124
2124
|
case 47:
|
|
2125
2125
|
// '/'
|
|
2126
2126
|
case 92:
|
|
2127
|
-
|
|
2128
|
-
return
|
|
2127
|
+
path67 = path67.slice(i + 1);
|
|
2128
|
+
return path67 === ".." || path67 === "." ? "" : path67;
|
|
2129
2129
|
}
|
|
2130
2130
|
}
|
|
2131
|
-
return
|
|
2131
|
+
return path67 === ".." || path67 === "." ? "" : path67;
|
|
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: path67,
|
|
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 path67 !== "string") {
|
|
5176
5176
|
throw new InvalidArgumentError("path must be a string");
|
|
5177
|
-
} else if (
|
|
5177
|
+
} else if (path67[0] !== "/" && !(path67.startsWith("http://") || path67.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(path67) !== 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(path67, query) : path67;
|
|
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 path67 = 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 = path67;
|
|
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: path67, 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} ${path67} 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: path67, 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] = path67;
|
|
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(path67) {
|
|
9889
|
+
if (typeof path67 !== "string") {
|
|
9890
|
+
return path67;
|
|
9891
9891
|
}
|
|
9892
|
-
const pathSegments =
|
|
9892
|
+
const pathSegments = path67.split("?");
|
|
9893
9893
|
if (pathSegments.length !== 2) {
|
|
9894
|
-
return
|
|
9894
|
+
return path67;
|
|
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: path67, method, body, headers }) {
|
|
9901
|
+
const pathMatch = matchValue(mockDispatch2.path, path67);
|
|
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: path67 }) => matchValue(safeUrl(path67), 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: path67, method, body, headers, query } = opts;
|
|
9957
9957
|
return {
|
|
9958
|
-
path:
|
|
9958
|
+
path: path67,
|
|
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: path67, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
10408
10408
|
Method: method,
|
|
10409
10409
|
Origin: origin,
|
|
10410
|
-
Path:
|
|
10410
|
+
Path: path67,
|
|
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(path67) {
|
|
15031
|
+
for (const char of path67) {
|
|
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 path67 = opts.path;
|
|
16712
16712
|
if (!opts.path.startsWith("/")) {
|
|
16713
|
-
|
|
16713
|
+
path67 = `/${path67}`;
|
|
16714
16714
|
}
|
|
16715
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
16715
|
+
url2 = new URL(util.parseOrigin(url2).origin + path67);
|
|
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(path67) {
|
|
19987
|
+
let input = path67;
|
|
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 [path67, query] = wsComponent.resourceName.split("?");
|
|
20240
|
+
wsComponent.path = path67 && path67 !== "/" ? path67 : 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, fs47, 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, fs47[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 fs47 = require("fs");
|
|
23658
|
+
function checkPathExt(path67, 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 && path67.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, path67, options) {
|
|
23676
23676
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
23677
23677
|
return false;
|
|
23678
23678
|
}
|
|
23679
|
-
return checkPathExt(
|
|
23679
|
+
return checkPathExt(path67, options);
|
|
23680
23680
|
}
|
|
23681
|
-
function isexe(
|
|
23682
|
-
|
|
23683
|
-
cb(er, er ? false : checkStat(stat,
|
|
23681
|
+
function isexe(path67, options, cb) {
|
|
23682
|
+
fs47.stat(path67, function(er, stat) {
|
|
23683
|
+
cb(er, er ? false : checkStat(stat, path67, options));
|
|
23684
23684
|
});
|
|
23685
23685
|
}
|
|
23686
|
-
function sync(
|
|
23687
|
-
return checkStat(
|
|
23686
|
+
function sync(path67, options) {
|
|
23687
|
+
return checkStat(fs47.statSync(path67), path67, 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 fs47 = require("fs");
|
|
23698
|
+
function isexe(path67, options, cb) {
|
|
23699
|
+
fs47.stat(path67, 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(path67, options) {
|
|
23704
|
+
return checkStat(fs47.statSync(path67), 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 fs47 = 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(path67, 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(path67, 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(path67, 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(path67, options) {
|
|
23767
23767
|
try {
|
|
23768
|
-
return core.sync(
|
|
23768
|
+
return core.sync(path67, 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 path67 = 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 = path67.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 = path67.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 path67 = 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 ? path67.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 = path67.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 [path67, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
23979
|
+
const binary = path67.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 fs47 = 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 = fs47.openSync(command, "r");
|
|
24000
|
+
fs47.readSync(fd, buffer, 0, size, 0);
|
|
24001
|
+
fs47.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 path67 = 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 = path67.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_fs18 = require("node:fs");
|
|
24262
24262
|
var import_node_http = require("node:http");
|
|
24263
|
-
var
|
|
24263
|
+
var import_node_path67 = __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, path67) {
|
|
25432
|
+
if (!path67)
|
|
25433
25433
|
return obj;
|
|
25434
|
-
return
|
|
25434
|
+
return path67.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(path67, 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(path67);
|
|
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, path67 = []) => {
|
|
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 }, [...path67, ...issue2.path]));
|
|
25998
25998
|
} else if (issue2.code === "invalid_key") {
|
|
25999
|
-
processError({ issues: issue2.issues }, [...
|
|
25999
|
+
processError({ issues: issue2.issues }, [...path67, ...issue2.path]);
|
|
26000
26000
|
} else if (issue2.code === "invalid_element") {
|
|
26001
|
-
processError({ issues: issue2.issues }, [...
|
|
26001
|
+
processError({ issues: issue2.issues }, [...path67, ...issue2.path]);
|
|
26002
26002
|
} else {
|
|
26003
|
-
const fullpath = [...
|
|
26003
|
+
const fullpath = [...path67, ...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, path67 = []) => {
|
|
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 }, [...path67, ...issue2.path]));
|
|
26035
26035
|
} else if (issue2.code === "invalid_key") {
|
|
26036
|
-
processError({ issues: issue2.issues }, [...
|
|
26036
|
+
processError({ issues: issue2.issues }, [...path67, ...issue2.path]);
|
|
26037
26037
|
} else if (issue2.code === "invalid_element") {
|
|
26038
|
-
processError({ issues: issue2.issues }, [...
|
|
26038
|
+
processError({ issues: issue2.issues }, [...path67, ...issue2.path]);
|
|
26039
26039
|
} else {
|
|
26040
|
-
const fullpath = [...
|
|
26040
|
+
const fullpath = [...path67, ...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 path67 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
26073
|
+
for (const seg of path67) {
|
|
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 path67 = ref.slice(1).split("/").filter(Boolean);
|
|
38766
|
+
if (path67.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 (path67[0] === defsKey) {
|
|
38771
|
+
const key3 = path67[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,11 +39579,15 @@ 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
39592
|
lines2.push("", "How to follow it:", "- Before doing anything else in a task, propose a plan with update_plan that carries out every step above in order, 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.", "- 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");
|
|
@@ -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, path67, kind) {
|
|
43616
|
+
if (path67.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] = path67;
|
|
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, path67, 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, path67, 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, path67, 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, path67, 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, path67, 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, path67, found2, depth + 1);
|
|
43573
43683
|
}
|
|
43574
|
-
return asJsonString(node,
|
|
43684
|
+
return asJsonString(node, path67, 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, path67, 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, [...path67, 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, [...path67, "[]"], found2, depth + 1);
|
|
43598
43708
|
} else if (type === void 0 && node.enum === void 0) {
|
|
43599
|
-
return asJsonString(node,
|
|
43709
|
+
return asJsonString(node, path67, 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: path67, 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, path67, found2, what) {
|
|
43734
|
+
found2.push({ path: path67, 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 path67 = parsed.path;
|
|
45114
|
+
return typeof path67 === "string" && path67.length > 0 ? path67 : 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 path67 = readFilePath(toolCall.arguments);
|
|
45128
|
+
if (path67 === void 0)
|
|
45019
45129
|
continue;
|
|
45020
45130
|
keyByCallId.set(toolCall.id, toolCall.arguments);
|
|
45021
45131
|
}
|
|
@@ -48124,13 +48234,13 @@ var OpenSearchClient = class {
|
|
|
48124
48234
|
* `_bulk`, `_delete_by_query`, index creation — is refused here rather than merely
|
|
48125
48235
|
* unused, so no future edit or crafted argument can turn a read client into a writer.
|
|
48126
48236
|
*/
|
|
48127
|
-
async request(
|
|
48237
|
+
async request(path67, options = {}) {
|
|
48128
48238
|
const method = options.method ?? "GET";
|
|
48129
|
-
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(
|
|
48239
|
+
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(path67);
|
|
48130
48240
|
if (method !== "GET" && !isSearchPost) {
|
|
48131
|
-
throw new OpenSearchError(`Refusing ${method} ${
|
|
48241
|
+
throw new OpenSearchError(`Refusing ${method} ${path67}: this client is read-only. Indexing goes through the indexer, which the user starts from Settings.`);
|
|
48132
48242
|
}
|
|
48133
|
-
const url2 = `${this.base}${
|
|
48243
|
+
const url2 = `${this.base}${path67}`;
|
|
48134
48244
|
const request2 = {
|
|
48135
48245
|
method,
|
|
48136
48246
|
headers: this.headers()
|
|
@@ -48297,11 +48407,11 @@ function collectFields(properties, prefix, out) {
|
|
|
48297
48407
|
return;
|
|
48298
48408
|
for (const [name, raw] of Object.entries(properties)) {
|
|
48299
48409
|
const field2 = raw;
|
|
48300
|
-
const
|
|
48410
|
+
const path67 = prefix.length > 0 ? `${prefix}.${name}` : name;
|
|
48301
48411
|
if (typeof field2.type === "string")
|
|
48302
|
-
out[
|
|
48412
|
+
out[path67] = field2.type;
|
|
48303
48413
|
if (field2.properties !== void 0)
|
|
48304
|
-
collectFields(field2.properties,
|
|
48414
|
+
collectFields(field2.properties, path67, out);
|
|
48305
48415
|
}
|
|
48306
48416
|
}
|
|
48307
48417
|
function describeStatus(status2, url2, body) {
|
|
@@ -48320,23 +48430,23 @@ function describeStatus(status2, url2, body) {
|
|
|
48320
48430
|
var TEXT_TYPES = /* @__PURE__ */ new Set(["text", "match_only_text", "search_as_you_type", "wildcard"]);
|
|
48321
48431
|
var KEYWORD_TYPES = /* @__PURE__ */ new Set(["keyword", "constant_keyword"]);
|
|
48322
48432
|
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] ??
|
|
48433
|
+
function leafName(path67) {
|
|
48434
|
+
const parts = path67.split(".");
|
|
48435
|
+
return parts[parts.length - 1] ?? path67;
|
|
48326
48436
|
}
|
|
48327
48437
|
function selectQueryFields(mapping, limit = 25) {
|
|
48328
48438
|
const text2 = [];
|
|
48329
48439
|
const keyword = [];
|
|
48330
|
-
for (const [
|
|
48331
|
-
if (NOISE_FIELDS.has(leafName(
|
|
48440
|
+
for (const [path67, type] of Object.entries(mapping)) {
|
|
48441
|
+
if (NOISE_FIELDS.has(leafName(path67)) || NOISE_FIELDS.has(path67.split(".")[0] ?? ""))
|
|
48332
48442
|
continue;
|
|
48333
48443
|
if (TEXT_TYPES.has(type)) {
|
|
48334
|
-
text2.push(
|
|
48444
|
+
text2.push(path67);
|
|
48335
48445
|
} else if (KEYWORD_TYPES.has(type)) {
|
|
48336
|
-
const parent =
|
|
48337
|
-
if (
|
|
48446
|
+
const parent = path67.replace(/\.keyword$/, "");
|
|
48447
|
+
if (path67.endsWith(".keyword") && TEXT_TYPES.has(mapping[parent] ?? ""))
|
|
48338
48448
|
continue;
|
|
48339
|
-
keyword.push(
|
|
48449
|
+
keyword.push(path67);
|
|
48340
48450
|
}
|
|
48341
48451
|
}
|
|
48342
48452
|
const byDepth = (a, b) => a.split(".").length - b.split(".").length || a.localeCompare(b);
|
|
@@ -48478,8 +48588,8 @@ var OpenSearchIndexWriter = class {
|
|
|
48478
48588
|
}
|
|
48479
48589
|
return headers;
|
|
48480
48590
|
}
|
|
48481
|
-
async request(
|
|
48482
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
48591
|
+
async request(path67, method, body, signal) {
|
|
48592
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path67}`;
|
|
48483
48593
|
const request2 = { method, headers: this.headers() };
|
|
48484
48594
|
if (body !== void 0) {
|
|
48485
48595
|
if (typeof body === "string") {
|
|
@@ -48693,13 +48803,13 @@ var OpenSearchIndexWriter = class {
|
|
|
48693
48803
|
for (const hit of hits) {
|
|
48694
48804
|
const source = hit._source ?? {};
|
|
48695
48805
|
const vector = source.vector;
|
|
48696
|
-
const
|
|
48697
|
-
if (typeof
|
|
48806
|
+
const path67 = source.path;
|
|
48807
|
+
if (typeof path67 !== "string" || !Array.isArray(vector))
|
|
48698
48808
|
continue;
|
|
48699
48809
|
documents.push({
|
|
48700
48810
|
id: hit._id ?? "",
|
|
48701
48811
|
text: typeof source.text === "string" ? source.text : "",
|
|
48702
|
-
path:
|
|
48812
|
+
path: path67,
|
|
48703
48813
|
startLine: typeof source.startLine === "number" ? source.startLine : 1,
|
|
48704
48814
|
endLine: typeof source.endLine === "number" ? source.endLine : 1,
|
|
48705
48815
|
vector
|
|
@@ -48775,8 +48885,8 @@ var RestTransport = class {
|
|
|
48775
48885
|
* threw would push every caller into catching and re-inspecting an error to find out
|
|
48776
48886
|
* whether it was really an error. `expectOk` is there for the cases that are.
|
|
48777
48887
|
*/
|
|
48778
|
-
async send(
|
|
48779
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
48888
|
+
async send(path67, method, body, signal) {
|
|
48889
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path67}`;
|
|
48780
48890
|
const request2 = { method, headers: this.headers() };
|
|
48781
48891
|
if (body !== void 0)
|
|
48782
48892
|
request2.body = JSON.stringify(body);
|
|
@@ -48802,11 +48912,11 @@ var RestTransport = class {
|
|
|
48802
48912
|
return { status: response.status, body: parsed };
|
|
48803
48913
|
}
|
|
48804
48914
|
/** Sends, and throws unless the status is 2xx. */
|
|
48805
|
-
async expectOk(
|
|
48806
|
-
const result = await this.send(
|
|
48915
|
+
async expectOk(path67, method, body, signal) {
|
|
48916
|
+
const result = await this.send(path67, method, body, signal);
|
|
48807
48917
|
if (result.status < 200 || result.status >= 300) {
|
|
48808
48918
|
const detail = typeof result.body === "string" ? result.body : JSON.stringify(result.body ?? "");
|
|
48809
|
-
throw new VectorStoreError(`${method} ${
|
|
48919
|
+
throw new VectorStoreError(`${method} ${path67} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}` + this.explain(result.body), result.status);
|
|
48810
48920
|
}
|
|
48811
48921
|
return result.body;
|
|
48812
48922
|
}
|
|
@@ -48992,10 +49102,10 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
48992
49102
|
const matches = [];
|
|
48993
49103
|
for (let index = 0; index < ids.length; index++) {
|
|
48994
49104
|
const metadata = metadatas[index] ?? {};
|
|
48995
|
-
const
|
|
48996
|
-
if (
|
|
49105
|
+
const path67 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
49106
|
+
if (path67 === void 0)
|
|
48997
49107
|
continue;
|
|
48998
|
-
if (prefix !== void 0 && prefix.length > 0 && !
|
|
49108
|
+
if (prefix !== void 0 && prefix.length > 0 && !path67.startsWith(prefix))
|
|
48999
49109
|
continue;
|
|
49000
49110
|
if (projectHere && typeof metadata.project === "string" && !options.project?.names.includes(metadata.project))
|
|
49001
49111
|
continue;
|
|
@@ -49009,7 +49119,7 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
49009
49119
|
*/
|
|
49010
49120
|
score: typeof distance === "number" ? 1 / (1 + Math.max(0, distance)) : 0,
|
|
49011
49121
|
text: documents[index] ?? (typeof metadata.text === "string" ? metadata.text : ""),
|
|
49012
|
-
path:
|
|
49122
|
+
path: path67
|
|
49013
49123
|
};
|
|
49014
49124
|
if (typeof metadata.startLine === "number")
|
|
49015
49125
|
match.startLine = metadata.startLine;
|
|
@@ -49120,13 +49230,13 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
49120
49230
|
for (let index = 0; index < ids.length; index++) {
|
|
49121
49231
|
const metadata = result.metadatas?.[index] ?? {};
|
|
49122
49232
|
const vector = result.embeddings?.[index];
|
|
49123
|
-
const
|
|
49124
|
-
if (
|
|
49233
|
+
const path67 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
49234
|
+
if (path67 === void 0 || !Array.isArray(vector))
|
|
49125
49235
|
continue;
|
|
49126
49236
|
documents.push({
|
|
49127
49237
|
id: ids[index] ?? "",
|
|
49128
49238
|
text: result.documents?.[index] ?? "",
|
|
49129
|
-
path:
|
|
49239
|
+
path: path67,
|
|
49130
49240
|
startLine: typeof metadata.startLine === "number" ? metadata.startLine : 1,
|
|
49131
49241
|
endLine: typeof metadata.endLine === "number" ? metadata.endLine : 1,
|
|
49132
49242
|
vector
|
|
@@ -49143,9 +49253,9 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
49143
49253
|
const result = await this.rest.expectOk(`${this.base}/collections/${found2.id}/get`, "POST", { include: ["metadatas"], limit }, options.signal);
|
|
49144
49254
|
const paths = /* @__PURE__ */ new Set();
|
|
49145
49255
|
for (const metadata of result.metadatas ?? []) {
|
|
49146
|
-
const
|
|
49147
|
-
if (typeof
|
|
49148
|
-
paths.add(
|
|
49256
|
+
const path67 = metadata?.path;
|
|
49257
|
+
if (typeof path67 === "string")
|
|
49258
|
+
paths.add(path67);
|
|
49149
49259
|
}
|
|
49150
49260
|
return [...paths];
|
|
49151
49261
|
}
|
|
@@ -49172,14 +49282,14 @@ var MARKER_ID = "5f6d2a41-0000-5000-8000-6c69676874c0";
|
|
|
49172
49282
|
var MARKER_MARK = "light-code";
|
|
49173
49283
|
function toMatch(point) {
|
|
49174
49284
|
const payload = point.payload ?? {};
|
|
49175
|
-
const
|
|
49176
|
-
if (
|
|
49285
|
+
const path67 = typeof payload.path === "string" ? payload.path : void 0;
|
|
49286
|
+
if (path67 === void 0)
|
|
49177
49287
|
return void 0;
|
|
49178
49288
|
const match = {
|
|
49179
49289
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
49180
49290
|
score: typeof point.score === "number" ? point.score : 0,
|
|
49181
49291
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
49182
|
-
path:
|
|
49292
|
+
path: path67
|
|
49183
49293
|
};
|
|
49184
49294
|
if (typeof payload.startLine === "number")
|
|
49185
49295
|
match.startLine = payload.startLine;
|
|
@@ -49373,13 +49483,13 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
49373
49483
|
const documents = [];
|
|
49374
49484
|
for (const point of result.body.result?.points ?? []) {
|
|
49375
49485
|
const payload = point.payload ?? {};
|
|
49376
|
-
const
|
|
49377
|
-
if (
|
|
49486
|
+
const path67 = typeof payload.path === "string" ? payload.path : void 0;
|
|
49487
|
+
if (path67 === void 0 || !Array.isArray(point.vector))
|
|
49378
49488
|
continue;
|
|
49379
49489
|
documents.push({
|
|
49380
49490
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
49381
49491
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
49382
|
-
path:
|
|
49492
|
+
path: path67,
|
|
49383
49493
|
startLine: typeof payload.startLine === "number" ? payload.startLine : 1,
|
|
49384
49494
|
endLine: typeof payload.endLine === "number" ? payload.endLine : 1,
|
|
49385
49495
|
vector: point.vector
|
|
@@ -49406,9 +49516,9 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
49406
49516
|
throw new VectorStoreError(`Could not list "${collection}" (HTTP ${String(result.status)}).` + wrongServerHint("qdrant", result.body, this.rest.label), result.status);
|
|
49407
49517
|
}
|
|
49408
49518
|
for (const point of result.body.result?.points ?? []) {
|
|
49409
|
-
const
|
|
49410
|
-
if (typeof
|
|
49411
|
-
paths.add(
|
|
49519
|
+
const path67 = point.payload?.path;
|
|
49520
|
+
if (typeof path67 === "string")
|
|
49521
|
+
paths.add(path67);
|
|
49412
49522
|
}
|
|
49413
49523
|
offset = result.body.result?.next_page_offset;
|
|
49414
49524
|
if (offset === void 0 || offset === null)
|
|
@@ -49942,8 +50052,8 @@ function teamSkillDocument(skill, body, vector, attribution) {
|
|
|
49942
50052
|
vector
|
|
49943
50053
|
};
|
|
49944
50054
|
}
|
|
49945
|
-
function nameFromPath(
|
|
49946
|
-
return
|
|
50055
|
+
function nameFromPath(path67) {
|
|
50056
|
+
return path67.startsWith("skill:") ? path67.slice("skill:".length) : path67;
|
|
49947
50057
|
}
|
|
49948
50058
|
function toHit(match, self) {
|
|
49949
50059
|
return {
|
|
@@ -53029,8 +53139,8 @@ function createMailCoverageTool(options) {
|
|
|
53029
53139
|
}
|
|
53030
53140
|
};
|
|
53031
53141
|
}
|
|
53032
|
-
function normaliseFolder(
|
|
53033
|
-
return
|
|
53142
|
+
function normaliseFolder(path67) {
|
|
53143
|
+
return path67.toLowerCase().replace(/[\\/]+/g, "\\");
|
|
53034
53144
|
}
|
|
53035
53145
|
function haystackOf(record2) {
|
|
53036
53146
|
return `${record2.subject}
|
|
@@ -53526,7 +53636,7 @@ async function refreshMail(options) {
|
|
|
53526
53636
|
const limit = options.batchLimit ?? 2e3;
|
|
53527
53637
|
const previewChars = options.previewChars ?? 400;
|
|
53528
53638
|
const sinceMs = Date.now() - options.days * 24 * 60 * 60 * 1e3;
|
|
53529
|
-
const harvested = await options.harvest(options.folders.map((
|
|
53639
|
+
const harvested = await options.harvest(options.folders.map((path67) => ({ path: path67, sinceMs })), { limit, previewChars });
|
|
53530
53640
|
const fetched = harvested.messages.map(toRecord);
|
|
53531
53641
|
if (fetched.length === 0) {
|
|
53532
53642
|
return { added: 0, more: false, total: known.length, embedded: 0, backfilled: 0, complete: [] };
|
|
@@ -53567,9 +53677,9 @@ async function syncMail(options) {
|
|
|
53567
53677
|
const backfillDone = await options.store.loadBackfillState();
|
|
53568
53678
|
const limit = options.batchLimit ?? 500;
|
|
53569
53679
|
const previewChars = options.previewChars ?? 400;
|
|
53570
|
-
const forwardRequests = options.folders.map((
|
|
53571
|
-
const mark = marks.get(
|
|
53572
|
-
return mark === void 0 ? { path:
|
|
53680
|
+
const forwardRequests = options.folders.map((path67) => {
|
|
53681
|
+
const mark = marks.get(path67);
|
|
53682
|
+
return mark === void 0 ? { path: path67 } : { path: path67, sinceMs: mark.newest - 1e3 };
|
|
53573
53683
|
});
|
|
53574
53684
|
const forward = await options.harvest(forwardRequests, { limit, previewChars });
|
|
53575
53685
|
let candidates = forward.messages.map(toRecord);
|
|
@@ -53578,15 +53688,15 @@ async function syncMail(options) {
|
|
|
53578
53688
|
let more = forward.truncated;
|
|
53579
53689
|
const remaining = limit - candidates.length;
|
|
53580
53690
|
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((
|
|
53691
|
+
const outstanding = options.folders.filter((path67) => marks.has(path67) && backfillDone[path67] !== true);
|
|
53692
|
+
const atFloor = floor === void 0 ? [] : outstanding.filter((path67) => marks.get(path67).oldest <= floor);
|
|
53693
|
+
const behind = outstanding.filter((path67) => !atFloor.includes(path67));
|
|
53584
53694
|
completed.push(...atFloor);
|
|
53585
53695
|
if (remaining > 0 && behind.length > 0 && options.signal?.aborted !== true) {
|
|
53586
|
-
const backRequests = behind.map((
|
|
53587
|
-
path:
|
|
53696
|
+
const backRequests = behind.map((path67) => ({
|
|
53697
|
+
path: path67,
|
|
53588
53698
|
// Strictly older, so the oldest held message is not fetched again every pass.
|
|
53589
|
-
beforeMs: marks.get(
|
|
53699
|
+
beforeMs: marks.get(path67).oldest,
|
|
53590
53700
|
// And no older than retention wants. The harvest ANDs the two into one window.
|
|
53591
53701
|
...floor === void 0 ? {} : { sinceMs: floor }
|
|
53592
53702
|
}));
|
|
@@ -53594,9 +53704,9 @@ async function syncMail(options) {
|
|
|
53594
53704
|
backfilled = backward.messages.length;
|
|
53595
53705
|
candidates = [...candidates, ...backward.messages.map(toRecord)];
|
|
53596
53706
|
const returnedFor = new Set(backward.messages.map((message6) => message6.folder));
|
|
53597
|
-
for (const
|
|
53598
|
-
if (!returnedFor.has(
|
|
53599
|
-
completed.push(
|
|
53707
|
+
for (const path67 of behind) {
|
|
53708
|
+
if (!returnedFor.has(path67))
|
|
53709
|
+
completed.push(path67);
|
|
53600
53710
|
}
|
|
53601
53711
|
if (backward.truncated || backfilled > 0)
|
|
53602
53712
|
more = true;
|
|
@@ -53604,7 +53714,7 @@ async function syncMail(options) {
|
|
|
53604
53714
|
if (completed.length > 0) {
|
|
53605
53715
|
await options.store.saveBackfillState({
|
|
53606
53716
|
...backfillDone,
|
|
53607
|
-
...Object.fromEntries(completed.map((
|
|
53717
|
+
...Object.fromEntries(completed.map((path67) => [path67, true]))
|
|
53608
53718
|
});
|
|
53609
53719
|
}
|
|
53610
53720
|
const fresh = withoutKnown(candidates, known);
|
|
@@ -53951,14 +54061,14 @@ function formatBytes(size) {
|
|
|
53951
54061
|
return `${(size / (1 << 10)).toFixed(1)}KB`;
|
|
53952
54062
|
return `${String(size)}B`;
|
|
53953
54063
|
}
|
|
53954
|
-
async function readTail(
|
|
54064
|
+
async function readTail(fs47, path67, size, count3) {
|
|
53955
54065
|
let span = Math.min(size, CHUNK);
|
|
53956
54066
|
let text2;
|
|
53957
54067
|
let start;
|
|
53958
54068
|
for (; ; ) {
|
|
53959
54069
|
start = Math.max(0, size - span);
|
|
53960
54070
|
const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
|
|
53961
|
-
text2 = decoder2.write(await
|
|
54071
|
+
text2 = decoder2.write(await fs47.readBytesSlice(path67, start, size)) + decoder2.end();
|
|
53962
54072
|
const enough = text2.split("\n").length > count3;
|
|
53963
54073
|
if (enough || start === 0 || span >= size)
|
|
53964
54074
|
break;
|
|
@@ -53976,7 +54086,7 @@ async function readTail(fs46, path66, size, count3) {
|
|
|
53976
54086
|
hasMoreAfter: false
|
|
53977
54087
|
};
|
|
53978
54088
|
}
|
|
53979
|
-
async function readLineWindow(
|
|
54089
|
+
async function readLineWindow(fs47, path67, size, from, count3) {
|
|
53980
54090
|
const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
|
|
53981
54091
|
const lines2 = [];
|
|
53982
54092
|
let pending = "";
|
|
@@ -53991,7 +54101,7 @@ async function readLineWindow(fs46, path66, size, from, count3) {
|
|
|
53991
54101
|
};
|
|
53992
54102
|
scan: while (position < size) {
|
|
53993
54103
|
const end = Math.min(size, position + CHUNK);
|
|
53994
|
-
pending += decoder2.write(await
|
|
54104
|
+
pending += decoder2.write(await fs47.readBytesSlice(path67, position, end));
|
|
53995
54105
|
position = end;
|
|
53996
54106
|
const parts = pending.split(/\r\n|\r|\n/);
|
|
53997
54107
|
pending = parts.pop() ?? "";
|
|
@@ -54014,13 +54124,13 @@ async function readLineWindow(fs46, path66, size, from, count3) {
|
|
|
54014
54124
|
hasMoreAfter: !reachedEnd || lineNumber > from + lines2.length
|
|
54015
54125
|
};
|
|
54016
54126
|
}
|
|
54017
|
-
async function countLines(
|
|
54127
|
+
async function countLines(fs47, path67, size) {
|
|
54018
54128
|
let newlines = 0;
|
|
54019
54129
|
let position = 0;
|
|
54020
54130
|
let lastByte = -1;
|
|
54021
54131
|
while (position < size) {
|
|
54022
54132
|
const end = Math.min(size, position + CHUNK);
|
|
54023
|
-
const buffer = await
|
|
54133
|
+
const buffer = await fs47.readBytesSlice(path67, position, end);
|
|
54024
54134
|
for (const byte of buffer)
|
|
54025
54135
|
if (byte === 10)
|
|
54026
54136
|
newlines += 1;
|
|
@@ -60388,6 +60498,7 @@ var McpRegistry = class {
|
|
|
60388
60498
|
getAlwaysAllowed;
|
|
60389
60499
|
defaultTimeout;
|
|
60390
60500
|
isRepositoryServer;
|
|
60501
|
+
toolCache;
|
|
60391
60502
|
connections = /* @__PURE__ */ new Map();
|
|
60392
60503
|
statuses = /* @__PURE__ */ new Map();
|
|
60393
60504
|
errors = /* @__PURE__ */ new Map();
|
|
@@ -60396,13 +60507,90 @@ var McpRegistry = class {
|
|
|
60396
60507
|
panelTools = /* @__PURE__ */ new Map();
|
|
60397
60508
|
logs = /* @__PURE__ */ new Map();
|
|
60398
60509
|
servers = {};
|
|
60399
|
-
constructor(secrets, events, logger, getAlwaysAllowed = () => [], defaultTimeout = void 0, isRepositoryServer = async () => false) {
|
|
60510
|
+
constructor(secrets, events, logger, getAlwaysAllowed = () => [], defaultTimeout = void 0, isRepositoryServer = async () => false, toolCache = void 0) {
|
|
60400
60511
|
this.secrets = secrets;
|
|
60401
60512
|
this.events = events;
|
|
60402
60513
|
this.logger = logger;
|
|
60403
60514
|
this.getAlwaysAllowed = getAlwaysAllowed;
|
|
60404
60515
|
this.defaultTimeout = defaultTimeout;
|
|
60405
60516
|
this.isRepositoryServer = isRepositoryServer;
|
|
60517
|
+
this.toolCache = toolCache;
|
|
60518
|
+
}
|
|
60519
|
+
/** Connections being opened, so two callers asking at once share one start rather than spawning two servers. */
|
|
60520
|
+
connecting = /* @__PURE__ */ new Map();
|
|
60521
|
+
/** Servers whose tools are, for now, the remembered list rather than one the server gave this session. */
|
|
60522
|
+
fromCache = /* @__PURE__ */ new Set();
|
|
60523
|
+
/**
|
|
60524
|
+
* Offers the remembered tools of every enabled server that has not listed its own yet in this session,
|
|
60525
|
+
* when its connection settings are the ones the list was read under. A call to one waits for the server.
|
|
60526
|
+
*/
|
|
60527
|
+
async primeFromCache() {
|
|
60528
|
+
if (this.toolCache === void 0)
|
|
60529
|
+
return;
|
|
60530
|
+
let cached2;
|
|
60531
|
+
try {
|
|
60532
|
+
cached2 = await this.toolCache.read();
|
|
60533
|
+
} catch {
|
|
60534
|
+
return;
|
|
60535
|
+
}
|
|
60536
|
+
for (const [name, config2] of Object.entries(this.servers)) {
|
|
60537
|
+
if (config2.disabled === true || this.toolsByServer.has(name))
|
|
60538
|
+
continue;
|
|
60539
|
+
const entry = cached2[name];
|
|
60540
|
+
if (entry === void 0 || entry.signature !== connectionSignature(config2))
|
|
60541
|
+
continue;
|
|
60542
|
+
this.setTools(name, entry.tools, async () => this.liveConnection(name));
|
|
60543
|
+
this.fromCache.add(name);
|
|
60544
|
+
}
|
|
60545
|
+
}
|
|
60546
|
+
/** The server's connection, started (or waited for) when it is not open yet. Throws with the reason it failed. */
|
|
60547
|
+
async liveConnection(name) {
|
|
60548
|
+
const open = this.connections.get(name);
|
|
60549
|
+
if (open !== void 0)
|
|
60550
|
+
return open;
|
|
60551
|
+
await this.connectServer(name);
|
|
60552
|
+
const connection = this.connections.get(name);
|
|
60553
|
+
if (connection === void 0)
|
|
60554
|
+
throw new Error(`the server did not start${this.errors.has(name) ? `: ${this.errors.get(name) ?? ""}` : ""}`);
|
|
60555
|
+
return connection;
|
|
60556
|
+
}
|
|
60557
|
+
/** Records a server's tools - live or remembered - as tools the loop can call. */
|
|
60558
|
+
setTools(name, listed, connectionFor) {
|
|
60559
|
+
this.panelTools.set(name, new Set(listed.filter((descriptor) => descriptor.panelOnly === true).map((descriptor) => descriptor.name)));
|
|
60560
|
+
const descriptors = listed.filter((descriptor) => descriptor.panelOnly !== true);
|
|
60561
|
+
this.toolsByServer.set(name, descriptors.map((descriptor) => ({
|
|
60562
|
+
descriptor,
|
|
60563
|
+
tool: adaptTool(name, descriptor.name, descriptor.description, descriptor.inputSchema, async (args) => {
|
|
60564
|
+
const decision = denyCheck(descriptor.name, args, this.servers[name]?.deny);
|
|
60565
|
+
if (decision.denied) {
|
|
60566
|
+
this.appendLog(name, decision.message ?? "Refused by a deny rule.");
|
|
60567
|
+
throw new Error(decision.message ?? "Refused by a deny rule.");
|
|
60568
|
+
}
|
|
60569
|
+
return (await connectionFor()).callTool(descriptor.name, args);
|
|
60570
|
+
})
|
|
60571
|
+
})));
|
|
60572
|
+
}
|
|
60573
|
+
/**
|
|
60574
|
+
* Starts every enabled server that is not connected yet and waits only for those this session has no
|
|
60575
|
+
* tools for: a server whose remembered list is offered keeps starting in the background, and a call to it
|
|
60576
|
+
* waits for it then. Waits at most `maxWaitMs` even for the others, so one server that never answers
|
|
60577
|
+
* cannot hold a reply - its tools join the turn after it does. Returns the servers still starting.
|
|
60578
|
+
*/
|
|
60579
|
+
async ensureReady(maxWaitMs = 45e3) {
|
|
60580
|
+
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) }));
|
|
60581
|
+
const needed = starting.filter((entry) => !this.toolsByServer.has(entry.name));
|
|
60582
|
+
if (needed.length > 0) {
|
|
60583
|
+
let timer;
|
|
60584
|
+
await Promise.race([
|
|
60585
|
+
Promise.all(needed.map((entry) => entry.done)),
|
|
60586
|
+
new Promise((resolve) => {
|
|
60587
|
+
timer = setTimeout(resolve, maxWaitMs);
|
|
60588
|
+
})
|
|
60589
|
+
]);
|
|
60590
|
+
if (timer !== void 0)
|
|
60591
|
+
clearTimeout(timer);
|
|
60592
|
+
}
|
|
60593
|
+
return starting.filter((entry) => this.statuses.get(entry.name) === "connecting").map((entry) => entry.name);
|
|
60406
60594
|
}
|
|
60407
60595
|
/** Replaces the configured server set, closing any that disappeared or changed. */
|
|
60408
60596
|
async configure(servers) {
|
|
@@ -60420,6 +60608,7 @@ var McpRegistry = class {
|
|
|
60420
60608
|
if (config2.disabled === true) {
|
|
60421
60609
|
this.statuses.set(name, "disabled");
|
|
60422
60610
|
this.toolsByServer.delete(name);
|
|
60611
|
+
this.fromCache.delete(name);
|
|
60423
60612
|
await this.disconnect(name, { silent: true });
|
|
60424
60613
|
} else if (!this.statuses.has(name) || this.statuses.get(name) === "disabled") {
|
|
60425
60614
|
this.statuses.set(name, "idle");
|
|
@@ -60430,15 +60619,17 @@ var McpRegistry = class {
|
|
|
60430
60619
|
this.statuses.delete(name);
|
|
60431
60620
|
this.errors.delete(name);
|
|
60432
60621
|
this.toolsByServer.delete(name);
|
|
60622
|
+
this.fromCache.delete(name);
|
|
60433
60623
|
}
|
|
60434
60624
|
}
|
|
60435
60625
|
for (const name of reconnect) {
|
|
60436
60626
|
const config2 = servers[name];
|
|
60437
60627
|
if (config2 !== void 0 && config2.disabled !== true) {
|
|
60438
|
-
void this.
|
|
60628
|
+
void this.connectServer(name).catch(() => {
|
|
60439
60629
|
});
|
|
60440
60630
|
}
|
|
60441
60631
|
}
|
|
60632
|
+
await this.primeFromCache();
|
|
60442
60633
|
this.events.onStateChanged();
|
|
60443
60634
|
}
|
|
60444
60635
|
/** Warnings the UI should surface before a server is started, e.g. package runners. */
|
|
@@ -60461,14 +60652,22 @@ var McpRegistry = class {
|
|
|
60461
60652
|
async connectServer(name) {
|
|
60462
60653
|
if (this.connections.has(name))
|
|
60463
60654
|
return;
|
|
60655
|
+
const already = this.connecting.get(name);
|
|
60656
|
+
if (already !== void 0)
|
|
60657
|
+
return already;
|
|
60464
60658
|
const config2 = this.servers[name];
|
|
60465
60659
|
if (config2 === void 0 || config2.disabled === true)
|
|
60466
60660
|
return;
|
|
60467
|
-
|
|
60661
|
+
const started = this.connect(name, config2).finally(() => {
|
|
60662
|
+
if (this.connecting.get(name) === started)
|
|
60663
|
+
this.connecting.delete(name);
|
|
60664
|
+
});
|
|
60665
|
+
this.connecting.set(name, started);
|
|
60666
|
+
return started;
|
|
60468
60667
|
}
|
|
60469
60668
|
/** Connects every enabled server that is not connected yet. Failures are per-server. */
|
|
60470
60669
|
async ensureConnected() {
|
|
60471
|
-
await Promise.all(Object.entries(this.servers).filter(([name, config2]) => config2.disabled !== true && !this.connections.has(name)).map(([name
|
|
60670
|
+
await Promise.all(Object.entries(this.servers).filter(([name, config2]) => config2.disabled !== true && !this.connections.has(name)).map(([name]) => this.connectServer(name)));
|
|
60472
60671
|
}
|
|
60473
60672
|
/** Bounded so a chatty server cannot grow this without limit over a long session. */
|
|
60474
60673
|
appendLog(name, line) {
|
|
@@ -60499,14 +60698,20 @@ var McpRegistry = class {
|
|
|
60499
60698
|
this.defaultTimeout,
|
|
60500
60699
|
{ repositoryDefined: await this.isRepositoryServer(name) }
|
|
60501
60700
|
);
|
|
60701
|
+
const startedAt = Date.now();
|
|
60502
60702
|
try {
|
|
60503
60703
|
await connection.connect();
|
|
60504
60704
|
this.connections.set(name, connection);
|
|
60505
60705
|
this.appendLog(name, "Connected.");
|
|
60506
60706
|
await this.refreshTools(name);
|
|
60707
|
+
const seconds = (Date.now() - startedAt) / 1e3;
|
|
60708
|
+
if (seconds >= 2)
|
|
60709
|
+
this.logger?.info(`[startup] MCP server "${name}" took ${seconds.toFixed(1)}s to start and list its tools`);
|
|
60507
60710
|
} catch (error51) {
|
|
60508
60711
|
const message6 = error51 instanceof Error ? error51.message : String(error51);
|
|
60509
|
-
this.
|
|
60712
|
+
if (this.fromCache.delete(name))
|
|
60713
|
+
this.toolsByServer.delete(name);
|
|
60714
|
+
this.logger?.warn(`MCP server "${name}" failed to connect after ${((Date.now() - startedAt) / 1e3).toFixed(1)}s: ${message6}`);
|
|
60510
60715
|
this.statuses.set(name, "failed");
|
|
60511
60716
|
this.errors.set(name, message6);
|
|
60512
60717
|
this.appendLog(name, `Failed: ${message6}`);
|
|
@@ -60519,22 +60724,15 @@ var McpRegistry = class {
|
|
|
60519
60724
|
return;
|
|
60520
60725
|
try {
|
|
60521
60726
|
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
|
-
})));
|
|
60727
|
+
this.setTools(name, listed, async () => connection);
|
|
60728
|
+
this.fromCache.delete(name);
|
|
60729
|
+
const config2 = this.servers[name];
|
|
60730
|
+
if (config2 !== void 0 && this.toolCache !== void 0) {
|
|
60731
|
+
void this.toolCache.write(name, { signature: connectionSignature(config2), tools: listed, at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
60732
|
+
}
|
|
60535
60733
|
this.statuses.set(name, "ready");
|
|
60536
60734
|
this.errors.delete(name);
|
|
60537
|
-
this.appendLog(name, `Discovered ${
|
|
60735
|
+
this.appendLog(name, `Discovered ${listed.filter((descriptor) => descriptor.panelOnly !== true).length} tool(s).`);
|
|
60538
60736
|
} catch (error51) {
|
|
60539
60737
|
this.statuses.set(name, "failed");
|
|
60540
60738
|
this.errors.set(name, error51 instanceof Error ? error51.message : String(error51));
|
|
@@ -60545,6 +60743,7 @@ var McpRegistry = class {
|
|
|
60545
60743
|
await this.connections.get(name)?.close();
|
|
60546
60744
|
this.connections.delete(name);
|
|
60547
60745
|
this.toolsByServer.delete(name);
|
|
60746
|
+
this.fromCache.delete(name);
|
|
60548
60747
|
if (this.servers[name] !== void 0 && this.servers[name]?.disabled !== true) {
|
|
60549
60748
|
this.statuses.set(name, "idle");
|
|
60550
60749
|
}
|
|
@@ -61391,13 +61590,13 @@ function appendSkillImages(body, images) {
|
|
|
61391
61590
|
const trimmed = body.replace(/\s+$/, "");
|
|
61392
61591
|
return [trimmed, "", "## Images", "", ...missing.map(renderSkillImage)].join("\n");
|
|
61393
61592
|
}
|
|
61394
|
-
async function listSkillImages(skillFilePath,
|
|
61593
|
+
async function listSkillImages(skillFilePath, fs47) {
|
|
61395
61594
|
const asPosix = skillFilePath.split(String.fromCharCode(92)).join("/");
|
|
61396
61595
|
if (!asPosix.toLowerCase().endsWith("/skill.md"))
|
|
61397
61596
|
return [];
|
|
61398
61597
|
const dir = `${skillFilePath.slice(0, skillFilePath.length - "SKILL.md".length)}${SKILL_IMAGE_DIR}`;
|
|
61399
61598
|
try {
|
|
61400
|
-
const entries = await
|
|
61599
|
+
const entries = await fs47.readdir(dir);
|
|
61401
61600
|
return entries.filter((entry) => !entry.isDirectory && skillImageType(entry.name) !== void 0).map((entry) => entry.name).sort();
|
|
61402
61601
|
} catch {
|
|
61403
61602
|
return [];
|
|
@@ -61447,12 +61646,12 @@ function skillFilesDir(skillFilePath) {
|
|
|
61447
61646
|
return void 0;
|
|
61448
61647
|
return `${skillFilePath.slice(0, skillFilePath.length - "SKILL.md".length)}${SKILL_FILE_DIR}`;
|
|
61449
61648
|
}
|
|
61450
|
-
async function listSkillFiles(skillFilePath,
|
|
61649
|
+
async function listSkillFiles(skillFilePath, fs47) {
|
|
61451
61650
|
const dir = skillFilesDir(skillFilePath);
|
|
61452
61651
|
if (dir === void 0)
|
|
61453
61652
|
return [];
|
|
61454
61653
|
try {
|
|
61455
|
-
const entries = await
|
|
61654
|
+
const entries = await fs47.readdir(dir);
|
|
61456
61655
|
return entries.filter((entry) => !entry.isDirectory).map((entry) => entry.name).sort();
|
|
61457
61656
|
} catch {
|
|
61458
61657
|
return [];
|
|
@@ -62107,9 +62306,9 @@ function secretRefsFor(section, config2) {
|
|
|
62107
62306
|
}
|
|
62108
62307
|
return refs;
|
|
62109
62308
|
}
|
|
62110
|
-
function getPath2(source,
|
|
62309
|
+
function getPath2(source, path67) {
|
|
62111
62310
|
let value = source;
|
|
62112
|
-
for (const part of
|
|
62311
|
+
for (const part of path67.split(".")) {
|
|
62113
62312
|
if (typeof value !== "object" || value === null)
|
|
62114
62313
|
return void 0;
|
|
62115
62314
|
value = value[part];
|
|
@@ -62123,8 +62322,8 @@ function hasValue(value) {
|
|
|
62123
62322
|
return Object.keys(value).length > 0;
|
|
62124
62323
|
return true;
|
|
62125
62324
|
}
|
|
62126
|
-
function setPath(target,
|
|
62127
|
-
const [head, ...rest] =
|
|
62325
|
+
function setPath(target, path67, value) {
|
|
62326
|
+
const [head, ...rest] = path67.split(".");
|
|
62128
62327
|
if (head === void 0)
|
|
62129
62328
|
return;
|
|
62130
62329
|
if (rest.length === 0) {
|
|
@@ -62144,8 +62343,8 @@ function setPath(target, path66, value) {
|
|
|
62144
62343
|
var NESTED_PATHS = SHARE_SECTIONS.flatMap((section) => section.nested ?? []);
|
|
62145
62344
|
function withoutNested(config2) {
|
|
62146
62345
|
const copy = { ...config2 };
|
|
62147
|
-
for (const
|
|
62148
|
-
setPath(copy,
|
|
62346
|
+
for (const path67 of NESTED_PATHS)
|
|
62347
|
+
setPath(copy, path67, void 0);
|
|
62149
62348
|
return copy;
|
|
62150
62349
|
}
|
|
62151
62350
|
function describeSections(config2) {
|
|
@@ -62154,7 +62353,7 @@ function describeSections(config2) {
|
|
|
62154
62353
|
id: section.id,
|
|
62155
62354
|
label: section.label,
|
|
62156
62355
|
description: section.description,
|
|
62157
|
-
present: section.keys.some((key3) => has(owned, key3)) || (section.nested ?? []).some((
|
|
62356
|
+
present: section.keys.some((key3) => has(owned, key3)) || (section.nested ?? []).some((path67) => hasValue(getPath2(config2, path67))),
|
|
62158
62357
|
detail: detailFor(section, config2),
|
|
62159
62358
|
secretRefs: secretRefsFor(section, config2),
|
|
62160
62359
|
...section.machineSpecific === true ? { machineSpecific: true } : {},
|
|
@@ -62175,18 +62374,18 @@ function buildExport(config2, selected) {
|
|
|
62175
62374
|
if (has(config2, key3))
|
|
62176
62375
|
exported[key3] = config2[key3];
|
|
62177
62376
|
}
|
|
62178
|
-
for (const
|
|
62179
|
-
const value = getPath2(config2,
|
|
62377
|
+
for (const path67 of section.nested ?? []) {
|
|
62378
|
+
const value = getPath2(config2, path67);
|
|
62180
62379
|
if (hasValue(value))
|
|
62181
|
-
setPath(exported,
|
|
62380
|
+
setPath(exported, path67, value);
|
|
62182
62381
|
}
|
|
62183
|
-
for (const
|
|
62184
|
-
stripPath(exported,
|
|
62382
|
+
for (const path67 of section.strip ?? [])
|
|
62383
|
+
stripPath(exported, path67);
|
|
62185
62384
|
}
|
|
62186
62385
|
return exported;
|
|
62187
62386
|
}
|
|
62188
|
-
function stripPath(target,
|
|
62189
|
-
const [head, ...rest] =
|
|
62387
|
+
function stripPath(target, path67) {
|
|
62388
|
+
const [head, ...rest] = path67.split(".");
|
|
62190
62389
|
if (head === void 0)
|
|
62191
62390
|
return;
|
|
62192
62391
|
const value = target[head];
|
|
@@ -62214,22 +62413,22 @@ function applyImport(existing, imported, selected) {
|
|
|
62214
62413
|
else
|
|
62215
62414
|
delete merged[key3];
|
|
62216
62415
|
}
|
|
62217
|
-
for (const
|
|
62218
|
-
carryPath(existing, merged,
|
|
62416
|
+
for (const path67 of section.strip ?? []) {
|
|
62417
|
+
carryPath(existing, merged, path67);
|
|
62219
62418
|
}
|
|
62220
62419
|
}
|
|
62221
62420
|
for (const section of SHARE_SECTIONS) {
|
|
62222
62421
|
if (!chosen.has(section.id))
|
|
62223
62422
|
continue;
|
|
62224
|
-
for (const
|
|
62225
|
-
const value = getPath2(imported,
|
|
62226
|
-
setPath(merged,
|
|
62423
|
+
for (const path67 of section.nested ?? []) {
|
|
62424
|
+
const value = getPath2(imported, path67);
|
|
62425
|
+
setPath(merged, path67, hasValue(value) ? value : void 0);
|
|
62227
62426
|
}
|
|
62228
62427
|
}
|
|
62229
62428
|
return merged;
|
|
62230
62429
|
}
|
|
62231
|
-
function carryPath(from, to,
|
|
62232
|
-
const [head, ...rest] =
|
|
62430
|
+
function carryPath(from, to, path67) {
|
|
62431
|
+
const [head, ...rest] = path67.split(".");
|
|
62233
62432
|
if (head === void 0)
|
|
62234
62433
|
return;
|
|
62235
62434
|
const source = from[head];
|
|
@@ -64807,7 +65006,7 @@ function gatewayFromSettings(input, stored) {
|
|
|
64807
65006
|
}
|
|
64808
65007
|
|
|
64809
65008
|
// ../../packages/core/dist/host/bridge.js
|
|
64810
|
-
var
|
|
65009
|
+
var import_node_fs13 = require("node:fs");
|
|
64811
65010
|
var import_node_child_process19 = require("node:child_process");
|
|
64812
65011
|
var import_promises31 = __toESM(require("node:fs/promises"), 1);
|
|
64813
65012
|
|
|
@@ -65591,7 +65790,7 @@ function ignoreDecision(rules, relative, isDirectory2, initial) {
|
|
|
65591
65790
|
}
|
|
65592
65791
|
return ignored;
|
|
65593
65792
|
}
|
|
65594
|
-
async function repositoryWideRules(
|
|
65793
|
+
async function repositoryWideRules(fs47, root, globalIgnoreFile) {
|
|
65595
65794
|
const sources = [
|
|
65596
65795
|
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
65796
|
import_node_path29.default.join(root, ".git", "info", "exclude")
|
|
@@ -65599,16 +65798,16 @@ async function repositoryWideRules(fs46, root, globalIgnoreFile) {
|
|
|
65599
65798
|
const rules = [];
|
|
65600
65799
|
for (const source of sources) {
|
|
65601
65800
|
try {
|
|
65602
|
-
rules.push(...parseIgnoreFile(await
|
|
65801
|
+
rules.push(...parseIgnoreFile(await fs47.readFile(source), ""));
|
|
65603
65802
|
} catch {
|
|
65604
65803
|
}
|
|
65605
65804
|
}
|
|
65606
65805
|
return rules;
|
|
65607
65806
|
}
|
|
65608
|
-
async function walkFiles(
|
|
65807
|
+
async function walkFiles(fs47, root, options) {
|
|
65609
65808
|
const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
|
|
65610
65809
|
const files = [];
|
|
65611
|
-
const baseRules = options.includeIgnored ? [] : await repositoryWideRules(
|
|
65810
|
+
const baseRules = options.includeIgnored ? [] : await repositoryWideRules(fs47, root, options.globalIgnoreFile);
|
|
65612
65811
|
const pending = [{ relative: "", rules: baseRules }];
|
|
65613
65812
|
while (pending.length > 0) {
|
|
65614
65813
|
if (options.signal?.aborted === true)
|
|
@@ -65617,14 +65816,14 @@ async function walkFiles(fs46, root, options) {
|
|
|
65617
65816
|
const absolute = relative.length > 0 ? import_node_path29.default.join(root, ...relative.split("/")) : root;
|
|
65618
65817
|
let entries;
|
|
65619
65818
|
try {
|
|
65620
|
-
entries = await
|
|
65819
|
+
entries = await fs47.readdir(absolute);
|
|
65621
65820
|
} catch {
|
|
65622
65821
|
continue;
|
|
65623
65822
|
}
|
|
65624
65823
|
let rules = inherited;
|
|
65625
65824
|
if (!options.includeIgnored && entries.some((entry) => entry.name === ".gitignore" && !entry.isDirectory)) {
|
|
65626
65825
|
try {
|
|
65627
|
-
const text2 = await
|
|
65826
|
+
const text2 = await fs47.readFile(import_node_path29.default.join(absolute, ".gitignore"));
|
|
65628
65827
|
rules = [...inherited, ...parseIgnoreFile(text2, relative)];
|
|
65629
65828
|
} catch {
|
|
65630
65829
|
}
|
|
@@ -65686,12 +65885,12 @@ function fileFilter(filePattern) {
|
|
|
65686
65885
|
const regex = globToRegExp(glob.startsWith("/") ? glob.slice(1) : glob, anchored);
|
|
65687
65886
|
return (relative) => regex.test(relative) !== exclude;
|
|
65688
65887
|
}
|
|
65689
|
-
async function searchFiles(
|
|
65888
|
+
async function searchFiles(fs47, root, options) {
|
|
65690
65889
|
const regex = compilePattern(options.pattern);
|
|
65691
65890
|
const admits = fileFilter(options.filePattern);
|
|
65692
65891
|
const context = options.contextLines ?? 2;
|
|
65693
65892
|
const maxOutput = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT;
|
|
65694
|
-
const { files, truncated: walkTruncated } = await walkFiles(
|
|
65893
|
+
const { files, truncated: walkTruncated } = await walkFiles(fs47, root, options);
|
|
65695
65894
|
const separator = process.platform === "win32" ? "\\" : "/";
|
|
65696
65895
|
const chunks = [];
|
|
65697
65896
|
let size = 0;
|
|
@@ -65704,10 +65903,10 @@ async function searchFiles(fs46, root, options) {
|
|
|
65704
65903
|
const absolute = import_node_path29.default.join(root, ...relative.split("/"));
|
|
65705
65904
|
let bytes;
|
|
65706
65905
|
try {
|
|
65707
|
-
const stat = await
|
|
65906
|
+
const stat = await fs47.stat(absolute);
|
|
65708
65907
|
if (stat.size > MAX_FILE_BYTES)
|
|
65709
65908
|
continue;
|
|
65710
|
-
bytes = await
|
|
65909
|
+
bytes = await fs47.readBytes(absolute);
|
|
65711
65910
|
} catch {
|
|
65712
65911
|
continue;
|
|
65713
65912
|
}
|
|
@@ -67737,8 +67936,8 @@ function pick2(hubs, name) {
|
|
|
67737
67936
|
|
|
67738
67937
|
// ../../packages/core/dist/host/bridge.js
|
|
67739
67938
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
67740
|
-
var
|
|
67741
|
-
var
|
|
67939
|
+
var import_node_fs14 = require("node:fs");
|
|
67940
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
67742
67941
|
|
|
67743
67942
|
// ../../packages/core/dist/modes/autoGuidance.js
|
|
67744
67943
|
function idiomsFor(environment) {
|
|
@@ -69897,8 +70096,8 @@ var ChangeLedger = class {
|
|
|
69897
70096
|
this.chat = chat;
|
|
69898
70097
|
}
|
|
69899
70098
|
/** 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(
|
|
70099
|
+
record(path67) {
|
|
70100
|
+
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(path67), at: Date.now() });
|
|
69902
70101
|
void (0, import_promises24.appendFile)(this.file, `${line}
|
|
69903
70102
|
`).catch(() => void 0);
|
|
69904
70103
|
}
|
|
@@ -74905,10 +75104,10 @@ function isSafeSegment(value) {
|
|
|
74905
75104
|
function isSafeTagName(name) {
|
|
74906
75105
|
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
75106
|
}
|
|
74908
|
-
function encodeRepoPath(
|
|
74909
|
-
const segments =
|
|
75107
|
+
function encodeRepoPath(path67) {
|
|
75108
|
+
const segments = path67.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0);
|
|
74910
75109
|
if (segments.length === 0 || segments.some((segment) => segment === ".." || segment === ".")) {
|
|
74911
|
-
throw new AtlassianError(`"${
|
|
75110
|
+
throw new AtlassianError(`"${path67}" is not a file path inside the repository.`);
|
|
74912
75111
|
}
|
|
74913
75112
|
return segments.map(encodeURIComponent).join("/");
|
|
74914
75113
|
}
|
|
@@ -74993,24 +75192,24 @@ var BitbucketClient = class {
|
|
|
74993
75192
|
* redirect was followed, the login page came back, and the file "could not be read" although
|
|
74994
75193
|
* pull requests on the same repository could. `browse` is REST, so it authenticates like those.
|
|
74995
75194
|
*/
|
|
74996
|
-
async file(repo,
|
|
74997
|
-
const target = encodeRepoPath(
|
|
75195
|
+
async file(repo, path67, ref, signal) {
|
|
75196
|
+
const target = encodeRepoPath(path67);
|
|
74998
75197
|
const lines2 = [];
|
|
74999
75198
|
let start = 0;
|
|
75000
75199
|
for (let page = 0; page < MAX_FILE_PAGES; page += 1) {
|
|
75001
75200
|
const query = new URLSearchParams({ start: String(start), limit: String(FILE_PAGE_LINES) });
|
|
75002
75201
|
if (ref !== void 0 && ref.length > 0)
|
|
75003
75202
|
query.set("at", ref);
|
|
75004
|
-
const body = await this.rest.json(`reading ${
|
|
75203
|
+
const body = await this.rest.json(`reading ${path67}`, `${this.repoPath(repo)}/browse/${target}?${query.toString()}`, { method: "GET" }, signal);
|
|
75005
75204
|
if (body.children !== void 0) {
|
|
75006
75205
|
const names = (body.children.values ?? []).map((child) => {
|
|
75007
75206
|
const name = child.path?.toString ?? child.path?.name ?? "?";
|
|
75008
75207
|
return child.type === "DIRECTORY" ? `${name}/` : name;
|
|
75009
75208
|
});
|
|
75010
|
-
throw new AtlassianError(`${
|
|
75209
|
+
throw new AtlassianError(`${path67} is a folder, not a file. It holds: ${names.join(", ") || "nothing"}.`);
|
|
75011
75210
|
}
|
|
75012
75211
|
if (body.binary === true)
|
|
75013
|
-
throw new AtlassianError(`${
|
|
75212
|
+
throw new AtlassianError(`${path67} is a binary file, so there is no text to read.`);
|
|
75014
75213
|
for (const line of body.lines ?? [])
|
|
75015
75214
|
lines2.push(line.text ?? "");
|
|
75016
75215
|
if (body.isLastPage !== false || body.nextPageStart === void 0 || body.nextPageStart <= start)
|
|
@@ -75121,9 +75320,9 @@ var BitbucketClient = class {
|
|
|
75121
75320
|
return out;
|
|
75122
75321
|
}
|
|
75123
75322
|
/** A file's bytes at `at`, or undefined when it is not there. */
|
|
75124
|
-
async readBytes(repo,
|
|
75323
|
+
async readBytes(repo, path67, at, signal) {
|
|
75125
75324
|
try {
|
|
75126
|
-
return await this.rest.bytes(`reading ${
|
|
75325
|
+
return await this.rest.bytes(`reading ${path67}`, `${this.repoPath(repo)}/raw/${encodeRepoPath(path67)}?${new URLSearchParams({ at }).toString()}`, signal);
|
|
75127
75326
|
} catch (error51) {
|
|
75128
75327
|
if (error51 instanceof AtlassianError && error51.status === 404)
|
|
75129
75328
|
return void 0;
|
|
@@ -75947,8 +76146,8 @@ ${text2.slice(-2e4)}`);
|
|
|
75947
76146
|
}
|
|
75948
76147
|
/** Queues a build, then follows the queue item briefly to learn its number. */
|
|
75949
76148
|
async startBuild(job, parameters, signal) {
|
|
75950
|
-
const
|
|
75951
|
-
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${
|
|
76149
|
+
const path67 = jobPath(job, this.base);
|
|
76150
|
+
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${path67}/buildWithParameters` : `${path67}/build`, parameters ?? {}, signal);
|
|
75952
76151
|
const location = response.headers["location"];
|
|
75953
76152
|
const queueId = location === void 0 ? void 0 : /\/queue\/item\/(\d+)/.exec(location)?.[1];
|
|
75954
76153
|
if (queueId === void 0)
|
|
@@ -75985,10 +76184,10 @@ ${text2.slice(-2e4)}`);
|
|
|
75985
76184
|
}
|
|
75986
76185
|
/** Creates a job from a whole config.xml, in the folder its name gives (`folder/sub/new-job`). */
|
|
75987
76186
|
async createJob(job, xml, signal) {
|
|
75988
|
-
const
|
|
75989
|
-
const cut =
|
|
75990
|
-
const parent =
|
|
75991
|
-
const name = decodeURIComponent(
|
|
76187
|
+
const path67 = jobPath(job, this.base);
|
|
76188
|
+
const cut = path67.lastIndexOf("/job/");
|
|
76189
|
+
const parent = path67.slice(0, cut);
|
|
76190
|
+
const name = decodeURIComponent(path67.slice(cut + "/job/".length));
|
|
75992
76191
|
await this.postBody(`creating ${job}`, `${parent}/createItem?${new URLSearchParams({ name }).toString()}`, xml, "application/xml", signal);
|
|
75993
76192
|
}
|
|
75994
76193
|
/** Replaces a job's config.xml. */
|
|
@@ -76301,14 +76500,14 @@ ${client.base}${jobPath(job, client.base)}/${buildRef(params3.build)}/`
|
|
|
76301
76500
|
};
|
|
76302
76501
|
return tool;
|
|
76303
76502
|
}
|
|
76304
|
-
async function readJenkinsfile(
|
|
76305
|
-
const resolved = await resolveToolPath(context,
|
|
76503
|
+
async function readJenkinsfile(path67, context) {
|
|
76504
|
+
const resolved = await resolveToolPath(context, path67);
|
|
76306
76505
|
if (!resolved.ok)
|
|
76307
76506
|
return { ok: false, message: resolved.message };
|
|
76308
76507
|
try {
|
|
76309
76508
|
return { ok: true, text: await context.fs.readFile(resolved.realPath), realPath: resolved.realPath };
|
|
76310
76509
|
} catch (error51) {
|
|
76311
|
-
return { ok: false, message: `Could not read ${
|
|
76510
|
+
return { ok: false, message: `Could not read ${path67}: ${error51 instanceof Error ? error51.message : String(error51)}` };
|
|
76312
76511
|
}
|
|
76313
76512
|
}
|
|
76314
76513
|
var checkSchema = external_exports.object({
|
|
@@ -77084,9 +77283,9 @@ var AutosysClient = class _AutosysClient {
|
|
|
77084
77283
|
* Something this server may not offer at the documented address: undefined for a 404, so a tool can
|
|
77085
77284
|
* say which setting (`autosys.paths`) points elsewhere, rather than reporting "found nothing".
|
|
77086
77285
|
*/
|
|
77087
|
-
async optional(doing,
|
|
77286
|
+
async optional(doing, path67, signal) {
|
|
77088
77287
|
try {
|
|
77089
|
-
return asList(await this.rest.json(doing,
|
|
77288
|
+
return asList(await this.rest.json(doing, path67, { method: "GET" }, signal));
|
|
77090
77289
|
} catch (error51) {
|
|
77091
77290
|
if (error51 instanceof AtlassianError && error51.status === 404)
|
|
77092
77291
|
return void 0;
|
|
@@ -78389,13 +78588,13 @@ var MonitorHistoryStore = class {
|
|
|
78389
78588
|
if (!isSafeIndexName(index))
|
|
78390
78589
|
throw new MonitorHistoryError(`"${index}" is not a usable index name (lowercase letters, digits, - and _).`);
|
|
78391
78590
|
}
|
|
78392
|
-
async send(method,
|
|
78591
|
+
async send(method, path67, body) {
|
|
78393
78592
|
const headers = { "Content-Type": "application/json" };
|
|
78394
78593
|
const { username, password } = this.connection;
|
|
78395
78594
|
if (username !== void 0 && username.length > 0) {
|
|
78396
78595
|
headers.Authorization = `Basic ${Buffer.from(`${username}:${password ?? ""}`).toString("base64")}`;
|
|
78397
78596
|
}
|
|
78398
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${
|
|
78597
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${path67}`;
|
|
78399
78598
|
const request2 = { method, headers };
|
|
78400
78599
|
if (body !== void 0)
|
|
78401
78600
|
request2.body = JSON.stringify(body);
|
|
@@ -82034,7 +82233,7 @@ function message4(error51) {
|
|
|
82034
82233
|
}
|
|
82035
82234
|
function filesIn(params3) {
|
|
82036
82235
|
return [
|
|
82037
|
-
...(params3.attachments ?? []).map((
|
|
82236
|
+
...(params3.attachments ?? []).map((path67) => ({ path: path67, inline: false })),
|
|
82038
82237
|
...(params3.inlineImages ?? []).map((image) => ({ path: image.path, inline: true }))
|
|
82039
82238
|
];
|
|
82040
82239
|
}
|
|
@@ -82682,6 +82881,66 @@ function isTranscriptMessage(type) {
|
|
|
82682
82881
|
return TRANSCRIPT_MESSAGES.has(type);
|
|
82683
82882
|
}
|
|
82684
82883
|
|
|
82884
|
+
// ../../packages/core/dist/mcp/toolCache.js
|
|
82885
|
+
var import_node_fs8 = require("node:fs");
|
|
82886
|
+
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
82887
|
+
var MAX_SERVERS = 200;
|
|
82888
|
+
function parse3(text2) {
|
|
82889
|
+
const out = {};
|
|
82890
|
+
let raw;
|
|
82891
|
+
try {
|
|
82892
|
+
raw = JSON.parse(text2);
|
|
82893
|
+
} catch {
|
|
82894
|
+
return out;
|
|
82895
|
+
}
|
|
82896
|
+
if (raw === null || typeof raw !== "object")
|
|
82897
|
+
return out;
|
|
82898
|
+
const servers = raw.servers;
|
|
82899
|
+
if (servers === null || typeof servers !== "object")
|
|
82900
|
+
return out;
|
|
82901
|
+
for (const [name, value] of Object.entries(servers)) {
|
|
82902
|
+
if (value === null || typeof value !== "object")
|
|
82903
|
+
continue;
|
|
82904
|
+
const entry = value;
|
|
82905
|
+
if (typeof entry.signature !== "string" || !Array.isArray(entry.tools))
|
|
82906
|
+
continue;
|
|
82907
|
+
const tools = entry.tools.filter((tool) => tool !== null && typeof tool === "object" && typeof tool.name === "string" && typeof tool.description === "string");
|
|
82908
|
+
out[name] = { signature: entry.signature, tools, at: typeof entry.at === "string" ? entry.at : "" };
|
|
82909
|
+
}
|
|
82910
|
+
return out;
|
|
82911
|
+
}
|
|
82912
|
+
function fileMcpToolCache(file2) {
|
|
82913
|
+
let writing = Promise.resolve();
|
|
82914
|
+
const read = async () => {
|
|
82915
|
+
try {
|
|
82916
|
+
return parse3(await import_node_fs8.promises.readFile(file2, "utf8"));
|
|
82917
|
+
} catch {
|
|
82918
|
+
return {};
|
|
82919
|
+
}
|
|
82920
|
+
};
|
|
82921
|
+
return {
|
|
82922
|
+
read,
|
|
82923
|
+
write(server, entry) {
|
|
82924
|
+
writing = writing.then(async () => {
|
|
82925
|
+
const servers = await read();
|
|
82926
|
+
servers[server] = entry;
|
|
82927
|
+
const names = Object.keys(servers);
|
|
82928
|
+
if (names.length > MAX_SERVERS) {
|
|
82929
|
+
names.sort((a, b) => (servers[a]?.at ?? "").localeCompare(servers[b]?.at ?? ""));
|
|
82930
|
+
for (const name of names.slice(0, names.length - MAX_SERVERS))
|
|
82931
|
+
delete servers[name];
|
|
82932
|
+
}
|
|
82933
|
+
await writeFileAtomically(file2, JSON.stringify({ version: 1, servers }));
|
|
82934
|
+
}).catch(() => void 0);
|
|
82935
|
+
return writing;
|
|
82936
|
+
}
|
|
82937
|
+
};
|
|
82938
|
+
}
|
|
82939
|
+
var MCP_TOOL_CACHE_FILE = "mcp-tools.json";
|
|
82940
|
+
function mcpToolCacheFile(dir) {
|
|
82941
|
+
return import_node_path49.default.join(dir, MCP_TOOL_CACHE_FILE);
|
|
82942
|
+
}
|
|
82943
|
+
|
|
82685
82944
|
// ../../packages/core/dist/host/approvalGate.js
|
|
82686
82945
|
var WebviewApprovalGate = class {
|
|
82687
82946
|
post;
|
|
@@ -82732,17 +82991,17 @@ var WebviewApprovalGate = class {
|
|
|
82732
82991
|
// ../../packages/core/dist/platform/node/filesystem.js
|
|
82733
82992
|
var import_promises29 = __toESM(require("node:fs/promises"), 1);
|
|
82734
82993
|
var NodeFileSystem = class {
|
|
82735
|
-
async readFile(
|
|
82736
|
-
return import_promises29.default.readFile(
|
|
82994
|
+
async readFile(path67) {
|
|
82995
|
+
return import_promises29.default.readFile(path67, "utf8");
|
|
82737
82996
|
}
|
|
82738
|
-
async readBytes(
|
|
82739
|
-
return import_promises29.default.readFile(
|
|
82997
|
+
async readBytes(path67) {
|
|
82998
|
+
return import_promises29.default.readFile(path67);
|
|
82740
82999
|
}
|
|
82741
|
-
async readBytesSlice(
|
|
83000
|
+
async readBytesSlice(path67, start, end) {
|
|
82742
83001
|
const length = Math.max(0, end - start);
|
|
82743
83002
|
if (length === 0)
|
|
82744
83003
|
return Buffer.alloc(0);
|
|
82745
|
-
const handle = await import_promises29.default.open(
|
|
83004
|
+
const handle = await import_promises29.default.open(path67, "r");
|
|
82746
83005
|
try {
|
|
82747
83006
|
const buffer = Buffer.alloc(length);
|
|
82748
83007
|
const { bytesRead } = await handle.read(buffer, 0, length, start);
|
|
@@ -82751,18 +83010,18 @@ var NodeFileSystem = class {
|
|
|
82751
83010
|
await handle.close();
|
|
82752
83011
|
}
|
|
82753
83012
|
}
|
|
82754
|
-
async writeFile(
|
|
82755
|
-
await import_promises29.default.writeFile(
|
|
83013
|
+
async writeFile(path67, contents) {
|
|
83014
|
+
await import_promises29.default.writeFile(path67, contents, "utf8");
|
|
82756
83015
|
}
|
|
82757
83016
|
/** The counterpart of `readBytes`, and deliberately as bare as `writeFile` beside it. */
|
|
82758
|
-
async writeBytes(
|
|
82759
|
-
await import_promises29.default.writeFile(
|
|
83017
|
+
async writeBytes(path67, contents) {
|
|
83018
|
+
await import_promises29.default.writeFile(path67, contents);
|
|
82760
83019
|
}
|
|
82761
83020
|
async rename(from, to) {
|
|
82762
83021
|
await replaceFile(from, to);
|
|
82763
83022
|
}
|
|
82764
|
-
async stat(
|
|
82765
|
-
const stat = await import_promises29.default.lstat(
|
|
83023
|
+
async stat(path67) {
|
|
83024
|
+
const stat = await import_promises29.default.lstat(path67);
|
|
82766
83025
|
return {
|
|
82767
83026
|
size: stat.size,
|
|
82768
83027
|
mtimeMs: stat.mtimeMs,
|
|
@@ -82771,8 +83030,8 @@ var NodeFileSystem = class {
|
|
|
82771
83030
|
isSymbolicLink: stat.isSymbolicLink()
|
|
82772
83031
|
};
|
|
82773
83032
|
}
|
|
82774
|
-
async readdir(
|
|
82775
|
-
const entries = await import_promises29.default.readdir(
|
|
83033
|
+
async readdir(path67) {
|
|
83034
|
+
const entries = await import_promises29.default.readdir(path67, { withFileTypes: true });
|
|
82776
83035
|
return entries.map((entry) => ({
|
|
82777
83036
|
name: entry.name,
|
|
82778
83037
|
isFile: entry.isFile(),
|
|
@@ -82780,21 +83039,21 @@ var NodeFileSystem = class {
|
|
|
82780
83039
|
isSymbolicLink: entry.isSymbolicLink()
|
|
82781
83040
|
}));
|
|
82782
83041
|
}
|
|
82783
|
-
async exists(
|
|
83042
|
+
async exists(path67) {
|
|
82784
83043
|
try {
|
|
82785
|
-
await import_promises29.default.access(
|
|
83044
|
+
await import_promises29.default.access(path67);
|
|
82786
83045
|
return true;
|
|
82787
83046
|
} catch {
|
|
82788
83047
|
return false;
|
|
82789
83048
|
}
|
|
82790
83049
|
}
|
|
82791
|
-
async mkdir(
|
|
82792
|
-
await import_promises29.default.mkdir(
|
|
83050
|
+
async mkdir(path67) {
|
|
83051
|
+
await import_promises29.default.mkdir(path67, { recursive: true });
|
|
82793
83052
|
}
|
|
82794
83053
|
};
|
|
82795
83054
|
|
|
82796
83055
|
// ../../packages/core/dist/config/project.js
|
|
82797
|
-
var
|
|
83056
|
+
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
82798
83057
|
function configuredProjectName(config2) {
|
|
82799
83058
|
const name = config2?.project?.name?.trim();
|
|
82800
83059
|
return name !== void 0 && name.length > 0 ? name : void 0;
|
|
@@ -82803,7 +83062,7 @@ function projectName(config2, workspaceRoot) {
|
|
|
82803
83062
|
const configured = configuredProjectName(config2);
|
|
82804
83063
|
if (configured !== void 0)
|
|
82805
83064
|
return configured;
|
|
82806
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
83065
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path50.default.basename(import_node_path50.default.resolve(workspaceRoot));
|
|
82807
83066
|
}
|
|
82808
83067
|
function projectSlug(name) {
|
|
82809
83068
|
if (name === void 0)
|
|
@@ -82813,8 +83072,8 @@ function projectSlug(name) {
|
|
|
82813
83072
|
}
|
|
82814
83073
|
|
|
82815
83074
|
// ../../packages/core/dist/rag/renameIndexes.js
|
|
82816
|
-
var
|
|
82817
|
-
var
|
|
83075
|
+
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
83076
|
+
var import_node_fs9 = require("node:fs");
|
|
82818
83077
|
function planIndexRenames(names) {
|
|
82819
83078
|
const plans = [];
|
|
82820
83079
|
for (const kind of ["codebase", "docs", "skills"]) {
|
|
@@ -82866,7 +83125,7 @@ async function copyIndex(options) {
|
|
|
82866
83125
|
async function copyBookkeeping(directory, from, to, storeId) {
|
|
82867
83126
|
let entries;
|
|
82868
83127
|
try {
|
|
82869
|
-
entries = await
|
|
83128
|
+
entries = await import_node_fs9.promises.readdir(directory);
|
|
82870
83129
|
} catch {
|
|
82871
83130
|
return [];
|
|
82872
83131
|
}
|
|
@@ -82877,7 +83136,7 @@ async function copyBookkeeping(directory, from, to, storeId) {
|
|
|
82877
83136
|
continue;
|
|
82878
83137
|
const target = `${to}@${storeId}.${entry.slice(prefix.length)}`;
|
|
82879
83138
|
try {
|
|
82880
|
-
await
|
|
83139
|
+
await import_node_fs9.promises.copyFile(import_node_path51.default.join(directory, entry), import_node_path51.default.join(directory, target), import_node_fs9.constants.COPYFILE_EXCL);
|
|
82881
83140
|
copied.push(target);
|
|
82882
83141
|
} catch {
|
|
82883
83142
|
}
|
|
@@ -82966,7 +83225,7 @@ var NodeTerminal = class {
|
|
|
82966
83225
|
|
|
82967
83226
|
// ../../packages/core/dist/platform/node/taskStore.js
|
|
82968
83227
|
var import_promises30 = __toESM(require("node:fs/promises"), 1);
|
|
82969
|
-
var
|
|
83228
|
+
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
82970
83229
|
|
|
82971
83230
|
// ../../packages/core/dist/history/types.js
|
|
82972
83231
|
function taskSummary(task) {
|
|
@@ -82989,7 +83248,7 @@ var JsonTaskStore = class {
|
|
|
82989
83248
|
constructor(globalStoragePath, truncationStore, logger) {
|
|
82990
83249
|
this.truncationStore = truncationStore;
|
|
82991
83250
|
this.logger = logger;
|
|
82992
|
-
this.directory =
|
|
83251
|
+
this.directory = import_node_path52.default.join(globalStoragePath, "tasks");
|
|
82993
83252
|
}
|
|
82994
83253
|
async list(workspaceRoot) {
|
|
82995
83254
|
const index = await this.readIndex();
|
|
@@ -83038,11 +83297,11 @@ var JsonTaskStore = class {
|
|
|
83038
83297
|
await this.writeIndex(index.filter((entry) => entry.id !== id));
|
|
83039
83298
|
}
|
|
83040
83299
|
fileFor(id) {
|
|
83041
|
-
return
|
|
83300
|
+
return import_node_path52.default.join(this.directory, `${id}.json`);
|
|
83042
83301
|
}
|
|
83043
83302
|
async readIndex() {
|
|
83044
83303
|
try {
|
|
83045
|
-
const raw = await import_promises30.default.readFile(
|
|
83304
|
+
const raw = await import_promises30.default.readFile(import_node_path52.default.join(this.directory, INDEX_FILE), "utf8");
|
|
83046
83305
|
const parsed = JSON.parse(raw);
|
|
83047
83306
|
if (Array.isArray(parsed))
|
|
83048
83307
|
return parsed.filter(isIndexEntry);
|
|
@@ -83077,7 +83336,7 @@ var JsonTaskStore = class {
|
|
|
83077
83336
|
}
|
|
83078
83337
|
async writeIndex(entries) {
|
|
83079
83338
|
await import_promises30.default.mkdir(this.directory, { recursive: true });
|
|
83080
|
-
const target =
|
|
83339
|
+
const target = import_node_path52.default.join(this.directory, INDEX_FILE);
|
|
83081
83340
|
const temporary = `${target}.tmp`;
|
|
83082
83341
|
await import_promises30.default.writeFile(temporary, JSON.stringify(entries, null, 2), "utf8");
|
|
83083
83342
|
await replaceFile(temporary, target);
|
|
@@ -83121,8 +83380,8 @@ function isRecord3(value) {
|
|
|
83121
83380
|
}
|
|
83122
83381
|
|
|
83123
83382
|
// ../../packages/core/dist/usage/store.js
|
|
83124
|
-
var
|
|
83125
|
-
var
|
|
83383
|
+
var import_node_fs10 = require("node:fs");
|
|
83384
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
83126
83385
|
|
|
83127
83386
|
// ../../packages/core/dist/s3/keys.js
|
|
83128
83387
|
function normalisePrefix(prefix) {
|
|
@@ -83255,7 +83514,7 @@ var FolderShardStore = class {
|
|
|
83255
83514
|
await this.ask({ action: "write", user: shardSegment(shard.user), day: shard.day, instance: shard.instance, events });
|
|
83256
83515
|
return;
|
|
83257
83516
|
}
|
|
83258
|
-
await this.writeAtomically(
|
|
83517
|
+
await this.writeAtomically(import_node_path53.default.join(this.root, shardSegment(shard.user), `${shard.day}__${shard.instance}.jsonl`), shardText(events));
|
|
83259
83518
|
}
|
|
83260
83519
|
async read(fromDay, toDay) {
|
|
83261
83520
|
this.lastProblems = [];
|
|
@@ -83275,8 +83534,8 @@ var FolderShardStore = class {
|
|
|
83275
83534
|
}
|
|
83276
83535
|
const files = await this.listFiles();
|
|
83277
83536
|
const wanted = selectShards(files, fromDay, toDay);
|
|
83278
|
-
const texts = await pooled(wanted, 8, (file2) =>
|
|
83279
|
-
this.lastProblems.push(`${
|
|
83537
|
+
const texts = await pooled(wanted, 8, (file2) => import_node_fs10.promises.readFile(import_node_path53.default.join(this.root, file2.user, file2.name), "utf8").catch((error51) => {
|
|
83538
|
+
this.lastProblems.push(`${import_node_path53.default.join(this.root, file2.user, file2.name)}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
83280
83539
|
return "";
|
|
83281
83540
|
}));
|
|
83282
83541
|
return texts.flatMap(parseUsageLines);
|
|
@@ -83285,7 +83544,7 @@ var FolderShardStore = class {
|
|
|
83285
83544
|
async listFiles() {
|
|
83286
83545
|
let users;
|
|
83287
83546
|
try {
|
|
83288
|
-
users = (await
|
|
83547
|
+
users = (await import_node_fs10.promises.readdir(this.root, { withFileTypes: true })).filter((entry) => entry.isDirectory() && entry.name !== "_profiles").map((entry) => entry.name);
|
|
83289
83548
|
} catch (error51) {
|
|
83290
83549
|
if (error51.code === "ENOENT")
|
|
83291
83550
|
return [];
|
|
@@ -83293,10 +83552,10 @@ var FolderShardStore = class {
|
|
|
83293
83552
|
}
|
|
83294
83553
|
const files = [];
|
|
83295
83554
|
for (const user of users) {
|
|
83296
|
-
const folder =
|
|
83555
|
+
const folder = import_node_path53.default.join(this.root, user);
|
|
83297
83556
|
let names;
|
|
83298
83557
|
try {
|
|
83299
|
-
names = await
|
|
83558
|
+
names = await import_node_fs10.promises.readdir(folder);
|
|
83300
83559
|
} catch (error51) {
|
|
83301
83560
|
names = [];
|
|
83302
83561
|
this.lastProblems.push(`${folder}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -83312,7 +83571,7 @@ var FolderShardStore = class {
|
|
|
83312
83571
|
}
|
|
83313
83572
|
async readShard(shard) {
|
|
83314
83573
|
try {
|
|
83315
|
-
return parseUsageLines(await
|
|
83574
|
+
return parseUsageLines(await import_node_fs10.promises.readFile(import_node_path53.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), "utf8"));
|
|
83316
83575
|
} catch (error51) {
|
|
83317
83576
|
if (error51.code === "ENOENT")
|
|
83318
83577
|
return void 0;
|
|
@@ -83320,10 +83579,10 @@ var FolderShardStore = class {
|
|
|
83320
83579
|
}
|
|
83321
83580
|
}
|
|
83322
83581
|
async putMonth(shard, events) {
|
|
83323
|
-
await this.writeAtomically(
|
|
83582
|
+
await this.writeAtomically(import_node_path53.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), shardText(events));
|
|
83324
83583
|
}
|
|
83325
83584
|
async removeShard(shard) {
|
|
83326
|
-
await
|
|
83585
|
+
await import_node_fs10.promises.rm(import_node_path53.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), { force: true });
|
|
83327
83586
|
}
|
|
83328
83587
|
async putProfile(user, profile) {
|
|
83329
83588
|
this.profilesFromRead = void 0;
|
|
@@ -83331,7 +83590,7 @@ var FolderShardStore = class {
|
|
|
83331
83590
|
await this.ask({ action: "writeProfile", user: shardSegment(user), profile: cleanProfile(profile) });
|
|
83332
83591
|
return;
|
|
83333
83592
|
}
|
|
83334
|
-
await this.writeAtomically(
|
|
83593
|
+
await this.writeAtomically(import_node_path53.default.join(this.root, "_profiles", `${shardSegment(user)}.json`), JSON.stringify(cleanProfile(profile)));
|
|
83335
83594
|
}
|
|
83336
83595
|
async readProfiles() {
|
|
83337
83596
|
if (this.profilesFromRead !== void 0)
|
|
@@ -83340,13 +83599,13 @@ var FolderShardStore = class {
|
|
|
83340
83599
|
await this.read("9999-12-31", "9999-12-31");
|
|
83341
83600
|
return this.profilesFromRead ?? {};
|
|
83342
83601
|
}
|
|
83343
|
-
const folder =
|
|
83602
|
+
const folder = import_node_path53.default.join(this.root, "_profiles");
|
|
83344
83603
|
const profiles = {};
|
|
83345
|
-
for (const name of await
|
|
83604
|
+
for (const name of await import_node_fs10.promises.readdir(folder).catch(() => [])) {
|
|
83346
83605
|
if (!name.endsWith(".json"))
|
|
83347
83606
|
continue;
|
|
83348
83607
|
try {
|
|
83349
|
-
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await
|
|
83608
|
+
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs10.promises.readFile(import_node_path53.default.join(folder, name), "utf8")));
|
|
83350
83609
|
} catch {
|
|
83351
83610
|
}
|
|
83352
83611
|
}
|
|
@@ -84161,8 +84420,8 @@ function usageCollectionOn(config2, choice) {
|
|
|
84161
84420
|
}
|
|
84162
84421
|
|
|
84163
84422
|
// ../../packages/core/dist/usage/backfill.js
|
|
84164
|
-
var
|
|
84165
|
-
var
|
|
84423
|
+
var import_node_fs11 = require("node:fs");
|
|
84424
|
+
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
84166
84425
|
function comparablePath(value) {
|
|
84167
84426
|
return value.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
84168
84427
|
}
|
|
@@ -84172,7 +84431,7 @@ function eventsFromTask(task, context) {
|
|
|
84172
84431
|
return [];
|
|
84173
84432
|
const created = typeof task.createdAt === "number" && task.createdAt <= updated ? task.createdAt : updated;
|
|
84174
84433
|
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 ?
|
|
84434
|
+
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ? import_node_path54.default.basename(root.replace(/\\/g, "/")) : void 0;
|
|
84176
84435
|
const skillsByPath = new Map(context.skills.map((skill) => [comparablePath(skill.filePath), skill]));
|
|
84177
84436
|
const skip = new Set(context.skip);
|
|
84178
84437
|
const calls = [];
|
|
@@ -84209,7 +84468,7 @@ function eventsFromTask(task, context) {
|
|
|
84209
84468
|
let skill;
|
|
84210
84469
|
if (call.name === "read_file" && typeof call.args["path"] === "string") {
|
|
84211
84470
|
const requested2 = call.args["path"];
|
|
84212
|
-
const absolute =
|
|
84471
|
+
const absolute = import_node_path54.default.isAbsolute(requested2) || /^[A-Za-z]:[\\/]/.test(requested2) || root === void 0 ? requested2 : import_node_path54.default.join(root, requested2);
|
|
84213
84472
|
skill = skillsByPath.get(comparablePath(absolute));
|
|
84214
84473
|
}
|
|
84215
84474
|
if (call.name === "use_skill_file" && typeof call.args["skill"] === "string") {
|
|
@@ -84246,7 +84505,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
84246
84505
|
}
|
|
84247
84506
|
let names;
|
|
84248
84507
|
try {
|
|
84249
|
-
names = (await
|
|
84508
|
+
names = (await import_node_fs11.promises.readdir(tasksDir)).filter((name) => name.endsWith(".json") && name !== "index.json");
|
|
84250
84509
|
} catch {
|
|
84251
84510
|
return { events: [], tasks: 0, unreadable: 0, via: "node" };
|
|
84252
84511
|
}
|
|
@@ -84254,7 +84513,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
84254
84513
|
let unreadable = 0;
|
|
84255
84514
|
for (const name of names) {
|
|
84256
84515
|
try {
|
|
84257
|
-
events.push(...eventsFromTask(JSON.parse(await
|
|
84516
|
+
events.push(...eventsFromTask(JSON.parse(await import_node_fs11.promises.readFile(import_node_path54.default.join(tasksDir, name), "utf8")), context));
|
|
84258
84517
|
} catch {
|
|
84259
84518
|
unreadable++;
|
|
84260
84519
|
}
|
|
@@ -84262,24 +84521,24 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
84262
84521
|
return { events, tasks: names.length, unreadable, via: "node" };
|
|
84263
84522
|
}
|
|
84264
84523
|
async function backfillOnce(options) {
|
|
84265
|
-
const doneFile =
|
|
84524
|
+
const doneFile = import_node_path54.default.join(options.usageDir, "backfill.json");
|
|
84266
84525
|
for (const file2 of [doneFile, ...options.legacyDoneFile !== void 0 ? [options.legacyDoneFile] : []]) {
|
|
84267
|
-
if (await
|
|
84526
|
+
if (await import_node_fs11.promises.stat(file2).then(() => true, () => false))
|
|
84268
84527
|
return { ran: false };
|
|
84269
84528
|
}
|
|
84270
|
-
await
|
|
84271
|
-
const startFile =
|
|
84529
|
+
await import_node_fs11.promises.mkdir(options.usageDir, { recursive: true });
|
|
84530
|
+
const startFile = import_node_path54.default.join(options.usageDir, "backfill-start.json");
|
|
84272
84531
|
let before;
|
|
84273
84532
|
try {
|
|
84274
84533
|
before = (options.now ?? Date.now)();
|
|
84275
|
-
await
|
|
84534
|
+
await import_node_fs11.promises.writeFile(startFile, JSON.stringify({ before }), { encoding: "utf8", flag: "wx" });
|
|
84276
84535
|
} catch (error51) {
|
|
84277
84536
|
if (error51.code !== "EEXIST")
|
|
84278
84537
|
throw error51;
|
|
84279
84538
|
let claimed;
|
|
84280
84539
|
for (let attempt = 0; attempt < 40 && claimed === void 0; attempt++) {
|
|
84281
84540
|
try {
|
|
84282
|
-
const parsed = JSON.parse(await
|
|
84541
|
+
const parsed = JSON.parse(await import_node_fs11.promises.readFile(startFile, "utf8"));
|
|
84283
84542
|
if (typeof parsed.before === "number")
|
|
84284
84543
|
claimed = parsed.before;
|
|
84285
84544
|
} catch {
|
|
@@ -84316,12 +84575,12 @@ var params = external_exports.object({
|
|
|
84316
84575
|
limit: external_exports.number().int().min(1).max(2e5).optional().describe("events: at most this many rows, newest first (default 20000).")
|
|
84317
84576
|
});
|
|
84318
84577
|
function statsRange(input, now = Date.now()) {
|
|
84319
|
-
const
|
|
84320
|
-
const to = input.to !== void 0 ?
|
|
84578
|
+
const parse4 = (value, endOfDay) => Date.parse(`${value}T${endOfDay ? "23:59:59.999" : "00:00:00"}Z`);
|
|
84579
|
+
const to = input.to !== void 0 ? parse4(input.to, true) : now;
|
|
84321
84580
|
if (!Number.isFinite(to))
|
|
84322
84581
|
return { problem: `"${String(input.to)}" is not a date. Use YYYY-MM-DD.` };
|
|
84323
84582
|
if (input.from !== void 0) {
|
|
84324
|
-
const from =
|
|
84583
|
+
const from = parse4(input.from, false);
|
|
84325
84584
|
if (!Number.isFinite(from))
|
|
84326
84585
|
return { problem: `"${input.from}" is not a date. Use YYYY-MM-DD.` };
|
|
84327
84586
|
if (from > to)
|
|
@@ -84636,13 +84895,13 @@ var AuditIndex = class {
|
|
|
84636
84895
|
if (!isSafeIndexName(index))
|
|
84637
84896
|
throw new Error(`"${index}" is not a usable index name (lowercase letters, digits, - and _).`);
|
|
84638
84897
|
}
|
|
84639
|
-
async send(method,
|
|
84898
|
+
async send(method, path67, body, contentType2 = "application/json") {
|
|
84640
84899
|
const headers = { "Content-Type": contentType2 };
|
|
84641
84900
|
const { username, password } = this.connection;
|
|
84642
84901
|
if (username !== void 0 && username.length > 0) {
|
|
84643
84902
|
headers.Authorization = `Basic ${Buffer.from(`${username}:${password ?? ""}`).toString("base64")}`;
|
|
84644
84903
|
}
|
|
84645
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${
|
|
84904
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${path67}`;
|
|
84646
84905
|
const request2 = { method, headers };
|
|
84647
84906
|
if (body !== void 0)
|
|
84648
84907
|
request2.body = body;
|
|
@@ -84737,15 +84996,15 @@ var AuditIndex = class {
|
|
|
84737
84996
|
|
|
84738
84997
|
// ../../packages/core/dist/observers/journal.js
|
|
84739
84998
|
var import_node_crypto18 = require("node:crypto");
|
|
84740
|
-
var
|
|
84741
|
-
var
|
|
84999
|
+
var import_node_fs12 = require("node:fs");
|
|
85000
|
+
var import_node_path55 = __toESM(require("node:path"), 1);
|
|
84742
85001
|
function auditRoot(storageDir) {
|
|
84743
|
-
return
|
|
85002
|
+
return import_node_path55.default.join(storageDir, "audit");
|
|
84744
85003
|
}
|
|
84745
85004
|
function workspaceAuditFolder(workspace) {
|
|
84746
|
-
const resolved =
|
|
85005
|
+
const resolved = import_node_path55.default.resolve(workspace);
|
|
84747
85006
|
const key3 = process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
84748
|
-
const base =
|
|
85007
|
+
const base = import_node_path55.default.basename(key3).replace(/[^A-Za-z0-9._-]+/g, "-").slice(0, 40) || "workspace";
|
|
84749
85008
|
return `${base}-${(0, import_node_crypto18.createHash)("sha256").update(key3).digest("hex").slice(0, 10)}`;
|
|
84750
85009
|
}
|
|
84751
85010
|
function newSessionId() {
|
|
@@ -84761,17 +85020,17 @@ var AuditJournal = class {
|
|
|
84761
85020
|
folder;
|
|
84762
85021
|
constructor(storageDir, workspace, session) {
|
|
84763
85022
|
this.session = session;
|
|
84764
|
-
this.folder =
|
|
85023
|
+
this.folder = import_node_path55.default.join(auditRoot(storageDir), workspaceAuditFolder(workspace));
|
|
84765
85024
|
}
|
|
84766
85025
|
/** Appends in order; a failure is reported to `onError` and never blocks the next record. */
|
|
84767
85026
|
append(record2, onError) {
|
|
84768
85027
|
const line = `${JSON.stringify(record2)}
|
|
84769
85028
|
`;
|
|
84770
|
-
const file2 =
|
|
85029
|
+
const file2 = import_node_path55.default.join(this.folder, `${day(record2.at)}__${this.session}.jsonl`);
|
|
84771
85030
|
this.chain = this.chain.then(async () => {
|
|
84772
85031
|
try {
|
|
84773
|
-
await
|
|
84774
|
-
await
|
|
85032
|
+
await import_node_fs12.promises.mkdir(this.folder, { recursive: true });
|
|
85033
|
+
await import_node_fs12.promises.appendFile(file2, line, "utf8");
|
|
84775
85034
|
} catch (error51) {
|
|
84776
85035
|
onError(error51);
|
|
84777
85036
|
}
|
|
@@ -84787,11 +85046,11 @@ async function pruneAudit(storageDir, days, now = Date.now()) {
|
|
|
84787
85046
|
const cutoff = day(now - days * 864e5);
|
|
84788
85047
|
let removed = 0;
|
|
84789
85048
|
const root = auditRoot(storageDir);
|
|
84790
|
-
for (const folder of await
|
|
84791
|
-
for (const name of await
|
|
85049
|
+
for (const folder of await import_node_fs12.promises.readdir(root).catch(() => [])) {
|
|
85050
|
+
for (const name of await import_node_fs12.promises.readdir(import_node_path55.default.join(root, folder)).catch(() => [])) {
|
|
84792
85051
|
const fileDay = /^(\d{4}-\d{2}-\d{2})__/.exec(name)?.[1];
|
|
84793
85052
|
if (fileDay !== void 0 && fileDay < cutoff) {
|
|
84794
|
-
await
|
|
85053
|
+
await import_node_fs12.promises.rm(import_node_path55.default.join(root, folder, name), { force: true }).then(() => removed += 1, () => void 0);
|
|
84795
85054
|
}
|
|
84796
85055
|
}
|
|
84797
85056
|
}
|
|
@@ -84799,12 +85058,12 @@ async function pruneAudit(storageDir, days, now = Date.now()) {
|
|
|
84799
85058
|
}
|
|
84800
85059
|
async function readAudit(storageDir, workspace, query) {
|
|
84801
85060
|
const root = auditRoot(storageDir);
|
|
84802
|
-
const folders = query.allWorkspaces === true || workspace === void 0 ? await
|
|
85061
|
+
const folders = query.allWorkspaces === true || workspace === void 0 ? await import_node_fs12.promises.readdir(root).catch(() => []) : [workspaceAuditFolder(workspace)];
|
|
84803
85062
|
const fromDay = query.from !== void 0 ? day(query.from) : void 0;
|
|
84804
85063
|
const untilDay = query.until !== void 0 ? day(query.until) : void 0;
|
|
84805
85064
|
const files = [];
|
|
84806
85065
|
for (const folder of folders) {
|
|
84807
|
-
for (const name of await
|
|
85066
|
+
for (const name of await import_node_fs12.promises.readdir(import_node_path55.default.join(root, folder)).catch(() => [])) {
|
|
84808
85067
|
const fileDay = /^(\d{4}-\d{2}-\d{2})__(.+)\.jsonl$/.exec(name);
|
|
84809
85068
|
if (fileDay === null)
|
|
84810
85069
|
continue;
|
|
@@ -84814,7 +85073,7 @@ async function readAudit(storageDir, workspace, query) {
|
|
|
84814
85073
|
continue;
|
|
84815
85074
|
if (query.session !== void 0 && fileDay[2] !== query.session)
|
|
84816
85075
|
continue;
|
|
84817
|
-
files.push(
|
|
85076
|
+
files.push(import_node_path55.default.join(root, folder, name));
|
|
84818
85077
|
}
|
|
84819
85078
|
}
|
|
84820
85079
|
const needle = query.contains?.toLowerCase();
|
|
@@ -84824,7 +85083,7 @@ async function readAudit(storageDir, workspace, query) {
|
|
|
84824
85083
|
for (const file2 of files) {
|
|
84825
85084
|
let text2;
|
|
84826
85085
|
try {
|
|
84827
|
-
text2 = await
|
|
85086
|
+
text2 = await import_node_fs12.promises.readFile(file2, "utf8");
|
|
84828
85087
|
} catch (error51) {
|
|
84829
85088
|
unreadable.push(`${file2}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
84830
85089
|
continue;
|
|
@@ -85762,8 +86021,8 @@ function createStrategyHistoryTool(deps) {
|
|
|
85762
86021
|
|
|
85763
86022
|
// ../../packages/core/dist/strategy/contractsTool.js
|
|
85764
86023
|
var item = external_exports.object({
|
|
85765
|
-
from: external_exports.string().min(1).describe(
|
|
85766
|
-
to: external_exports.string().min(1).describe(
|
|
86024
|
+
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.`),
|
|
86025
|
+
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
86026
|
contract: external_exports.string().max(1e3).optional().describe("What passes along this connector, in a sentence."),
|
|
85768
86027
|
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
86028
|
});
|
|
@@ -85771,7 +86030,10 @@ var schema8 = external_exports.object({
|
|
|
85771
86030
|
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
86031
|
});
|
|
85773
86032
|
function findEdge(strategy, from, to) {
|
|
85774
|
-
const roleOf = (id) => strategy.nodes.find((n) => n.id === id)?.role
|
|
86033
|
+
const roleOf = (id) => strategy.nodes.find((n) => n.id === id)?.role ?? (() => {
|
|
86034
|
+
const group = strategy.groups?.find((g) => g.id === id);
|
|
86035
|
+
return group === void 0 ? void 0 : groupName(group).toLowerCase();
|
|
86036
|
+
})();
|
|
85775
86037
|
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
86038
|
}
|
|
85777
86039
|
function applyContracts(strategy, params3, roleName) {
|
|
@@ -85907,13 +86169,13 @@ var TeamStore = class {
|
|
|
85907
86169
|
if (!isSafeIndexName(index))
|
|
85908
86170
|
throw new TeamStoreError(`"${index}" is not a usable index name (lowercase letters, digits, - and _).`);
|
|
85909
86171
|
}
|
|
85910
|
-
async send(method,
|
|
86172
|
+
async send(method, path67, body) {
|
|
85911
86173
|
const headers = { "Content-Type": "application/json" };
|
|
85912
86174
|
const { username, password } = this.connection;
|
|
85913
86175
|
if (username !== void 0 && username.length > 0) {
|
|
85914
86176
|
headers.Authorization = `Basic ${Buffer.from(`${username}:${password ?? ""}`).toString("base64")}`;
|
|
85915
86177
|
}
|
|
85916
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${
|
|
86178
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${path67}`;
|
|
85917
86179
|
const request2 = { method, headers };
|
|
85918
86180
|
if (body !== void 0)
|
|
85919
86181
|
request2.body = JSON.stringify(body);
|
|
@@ -86190,8 +86452,8 @@ function wireChatBridge(services) {
|
|
|
86190
86452
|
const workspaceBranch = workspaceRoot !== void 0 ? currentBranchOf(workspaceRoot) : void 0;
|
|
86191
86453
|
const machineApprovals = services.machineApprovalsFile !== void 0 ? new FileMachineApprovals(services.machineApprovalsFile) : void 0;
|
|
86192
86454
|
const mirrorRoot = services.mirrorRoot ?? storageDir;
|
|
86193
|
-
const personalSkillsDir = services.personalDir !== void 0 ?
|
|
86194
|
-
const personalToolsDir = services.personalDir !== void 0 ?
|
|
86455
|
+
const personalSkillsDir = services.personalDir !== void 0 ? import_node_path56.default.join(services.personalDir, "skills") : void 0;
|
|
86456
|
+
const personalToolsDir = services.personalDir !== void 0 ? import_node_path56.default.join(services.personalDir, "tools") : void 0;
|
|
86195
86457
|
const logger = new Logger({ level: "debug", sink: services.logSink });
|
|
86196
86458
|
let fastFsOps;
|
|
86197
86459
|
const fastFsAnswered = services.fastFs === void 0 ? Promise.resolve(void 0) : fastFsCapabilities(services.fastFs).then((answer) => {
|
|
@@ -86213,14 +86475,14 @@ function wireChatBridge(services) {
|
|
|
86213
86475
|
let cachedSecretValues = [];
|
|
86214
86476
|
const droppedFilesRoot2 = droppedFilesRoot();
|
|
86215
86477
|
const mailAttachmentsRoot2 = mailAttachmentsRoot();
|
|
86216
|
-
const droppedFilesDir =
|
|
86217
|
-
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(
|
|
86478
|
+
const droppedFilesDir = import_node_path56.default.join(droppedFilesRoot2, (0, import_node_crypto20.randomUUID)().slice(0, 8));
|
|
86479
|
+
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(import_node_path56.default.join(storageDir, "tool-results"), () => cachedSecretValues));
|
|
86218
86480
|
const taskStore = new JsonTaskStore(storageDir, truncationStore, logger);
|
|
86219
86481
|
const manifestsRoot = services.codebaseDir ?? storageDir;
|
|
86220
86482
|
const codebaseInstructionsFile = codebaseInstructionsPath({ codebaseDir: services.codebaseDir, storageDir, workspaceRoot: projectRoot });
|
|
86221
86483
|
if (services.codebaseDir !== void 0) {
|
|
86222
|
-
const shared =
|
|
86223
|
-
void import_promises31.default.access(shared).catch(() => import_promises31.default.cp(
|
|
86484
|
+
const shared = import_node_path56.default.join(services.codebaseDir, "index-manifests");
|
|
86485
|
+
void import_promises31.default.access(shared).catch(() => import_promises31.default.cp(import_node_path56.default.join(storageDir, "index-manifests"), shared, { recursive: true, errorOnExist: false, force: false })).catch(() => void 0);
|
|
86224
86486
|
}
|
|
86225
86487
|
const python = new PythonManager({
|
|
86226
86488
|
workspaceRoot,
|
|
@@ -86398,7 +86660,7 @@ ${preview.text}` } : {}
|
|
|
86398
86660
|
}
|
|
86399
86661
|
return gitCheck.answer;
|
|
86400
86662
|
}
|
|
86401
|
-
const defaultSkillsDir = workspaceRoot !== void 0 ?
|
|
86663
|
+
const defaultSkillsDir = workspaceRoot !== void 0 ? import_node_path56.default.join(workspaceRoot, ".lightcode", "skills") : void 0;
|
|
86402
86664
|
let skillsDir = defaultSkillsDir;
|
|
86403
86665
|
let localSkillsDir = defaultSkillsDir;
|
|
86404
86666
|
let extraSkillDirs = [];
|
|
@@ -86421,9 +86683,9 @@ ${preview.text}` } : {}
|
|
|
86421
86683
|
const trimmed = entry.trim();
|
|
86422
86684
|
if (trimmed.length === 0)
|
|
86423
86685
|
return void 0;
|
|
86424
|
-
if (
|
|
86425
|
-
return
|
|
86426
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
86686
|
+
if (import_node_path56.default.isAbsolute(trimmed))
|
|
86687
|
+
return import_node_path56.default.resolve(trimmed);
|
|
86688
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path56.default.resolve(workspaceRoot, trimmed);
|
|
86427
86689
|
}
|
|
86428
86690
|
function skillSearchPath() {
|
|
86429
86691
|
return [skillsDir, ...extraSkillDirs].filter((dir) => dir !== void 0);
|
|
@@ -86460,12 +86722,12 @@ ${preview.text}` } : {}
|
|
|
86460
86722
|
function watchSkillFolders() {
|
|
86461
86723
|
stopWatchingSkills();
|
|
86462
86724
|
const dirs = skillSearchPath();
|
|
86463
|
-
for (const dir of [...dirs, ...dirs.map((entry) =>
|
|
86725
|
+
for (const dir of [...dirs, ...dirs.map((entry) => import_node_path56.default.dirname(entry))]) {
|
|
86464
86726
|
try {
|
|
86465
86727
|
skillWatchers.push(
|
|
86466
86728
|
// Recursive, because a skill may be a folder with SKILL.md inside — a non-recursive
|
|
86467
86729
|
// watch sees the folder appear and then never hears about the file written into it.
|
|
86468
|
-
(0,
|
|
86730
|
+
(0, import_node_fs13.watch)(dir, { recursive: true }, () => {
|
|
86469
86731
|
if (skillWatchTimer !== void 0)
|
|
86470
86732
|
clearTimeout(skillWatchTimer);
|
|
86471
86733
|
skillWatchTimer = setTimeout(() => {
|
|
@@ -86537,7 +86799,7 @@ ${preview.text}` } : {}
|
|
|
86537
86799
|
await openInPanelEditor(filePath);
|
|
86538
86800
|
return;
|
|
86539
86801
|
}
|
|
86540
|
-
const real = await confineToAny(
|
|
86802
|
+
const real = await confineToAny(import_node_path56.default.resolve(filePath), roots);
|
|
86541
86803
|
await ui.openFile?.(real);
|
|
86542
86804
|
} catch (error51) {
|
|
86543
86805
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -86548,9 +86810,9 @@ ${preview.text}` } : {}
|
|
|
86548
86810
|
python.toolsDirectory(),
|
|
86549
86811
|
...skillsDir === void 0 ? [] : [skillsDir],
|
|
86550
86812
|
...extraSkillDirs.filter((dir) => dir !== void 0),
|
|
86551
|
-
|
|
86813
|
+
import_node_path56.default.join(storageDir, "reports"),
|
|
86552
86814
|
// Its own folder: nothing else lives there.
|
|
86553
|
-
...codebaseInstructionsFile === void 0 ? [] : [
|
|
86815
|
+
...codebaseInstructionsFile === void 0 ? [] : [import_node_path56.default.dirname(codebaseInstructionsFile)]
|
|
86554
86816
|
].filter((dir) => dir.length > 0);
|
|
86555
86817
|
}
|
|
86556
86818
|
function mostlyCrlf(text2) {
|
|
@@ -86559,17 +86821,17 @@ ${preview.text}` } : {}
|
|
|
86559
86821
|
}
|
|
86560
86822
|
const EDITOR_MAX_BYTES = 2 * 1024 * 1024;
|
|
86561
86823
|
async function openInPanelEditor(filePath) {
|
|
86562
|
-
const real = await confineToAny(
|
|
86824
|
+
const real = await confineToAny(import_node_path56.default.resolve(filePath), managedRoots());
|
|
86563
86825
|
const stat = await import_promises31.default.stat(real);
|
|
86564
86826
|
if (stat.size > EDITOR_MAX_BYTES)
|
|
86565
|
-
throw new Error(`${
|
|
86827
|
+
throw new Error(`${import_node_path56.default.basename(real)} is too large to edit here (${String(Math.round(stat.size / 1024))} KB).`);
|
|
86566
86828
|
const raw = await import_promises31.default.readFile(real, "utf8");
|
|
86567
86829
|
const crlf = mostlyCrlf(raw);
|
|
86568
|
-
post({ type: "editorFile", path: real, name:
|
|
86830
|
+
post({ type: "editorFile", path: real, name: import_node_path56.default.basename(real), content: raw.split("\r\n").join("\n"), mtimeMs: stat.mtimeMs, eol: crlf ? "crlf" : "lf" });
|
|
86569
86831
|
}
|
|
86570
86832
|
async function handleSaveEditorFile(filePath, content, mtimeMs) {
|
|
86571
86833
|
try {
|
|
86572
|
-
const real = await confineToAny(
|
|
86834
|
+
const real = await confineToAny(import_node_path56.default.resolve(filePath), managedRoots());
|
|
86573
86835
|
const current = await import_promises31.default.stat(real).catch(() => void 0);
|
|
86574
86836
|
if (current !== void 0 && Math.abs(current.mtimeMs - mtimeMs) > 1) {
|
|
86575
86837
|
post({
|
|
@@ -86577,7 +86839,7 @@ ${preview.text}` } : {}
|
|
|
86577
86839
|
path: real,
|
|
86578
86840
|
ok: false,
|
|
86579
86841
|
conflict: true,
|
|
86580
|
-
message: `${
|
|
86842
|
+
message: `${import_node_path56.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
86843
|
});
|
|
86582
86844
|
return;
|
|
86583
86845
|
}
|
|
@@ -86601,7 +86863,7 @@ ${preview.text}` } : {}
|
|
|
86601
86863
|
await handleOpenManagedFile(existing.filePath);
|
|
86602
86864
|
return;
|
|
86603
86865
|
}
|
|
86604
|
-
const target =
|
|
86866
|
+
const target = import_node_path56.default.join(skillsDir, "standing-instructions.md");
|
|
86605
86867
|
try {
|
|
86606
86868
|
await import_promises31.default.mkdir(skillsDir, { recursive: true });
|
|
86607
86869
|
await import_promises31.default.writeFile(target, STANDING_SKILL_TEMPLATE, { encoding: "utf8", flag: "wx" });
|
|
@@ -86621,7 +86883,7 @@ ${preview.text}` } : {}
|
|
|
86621
86883
|
return;
|
|
86622
86884
|
}
|
|
86623
86885
|
try {
|
|
86624
|
-
await import_promises31.default.mkdir(
|
|
86886
|
+
await import_promises31.default.mkdir(import_node_path56.default.dirname(codebaseInstructionsFile), { recursive: true });
|
|
86625
86887
|
await import_promises31.default.writeFile(codebaseInstructionsFile, "", { encoding: "utf8", flag: "wx" });
|
|
86626
86888
|
} catch (error51) {
|
|
86627
86889
|
if (error51.code !== "EEXIST") {
|
|
@@ -86638,11 +86900,11 @@ ${preview.text}` } : {}
|
|
|
86638
86900
|
return;
|
|
86639
86901
|
if (!isValidToolName(name))
|
|
86640
86902
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
86641
|
-
const ownCopy =
|
|
86903
|
+
const ownCopy = import_node_path56.default.join(dir, toolFileName(name));
|
|
86642
86904
|
if (filePath !== void 0) {
|
|
86643
|
-
const same2 = (a, b) => normalizeForComparison(
|
|
86905
|
+
const same2 = (a, b) => normalizeForComparison(import_node_path56.default.resolve(a)) === normalizeForComparison(import_node_path56.default.resolve(b));
|
|
86644
86906
|
if (!same2(filePath, ownCopy)) {
|
|
86645
|
-
const fromBucket = mirroredToolsDirs.some((mirror) => same2(
|
|
86907
|
+
const fromBucket = mirroredToolsDirs.some((mirror) => same2(import_node_path56.default.dirname(filePath), mirror));
|
|
86646
86908
|
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
86909
|
}
|
|
86648
86910
|
}
|
|
@@ -86668,7 +86930,7 @@ ${preview.text}` } : {}
|
|
|
86668
86930
|
let dir;
|
|
86669
86931
|
let filePath = "";
|
|
86670
86932
|
for (const candidate of python.toolDirectories()) {
|
|
86671
|
-
const attempt =
|
|
86933
|
+
const attempt = import_node_path56.default.join(candidate, toolFileName(name));
|
|
86672
86934
|
if (await onDisk(attempt)) {
|
|
86673
86935
|
dir = candidate;
|
|
86674
86936
|
filePath = attempt;
|
|
@@ -86699,7 +86961,7 @@ ${preview.text}` } : {}
|
|
|
86699
86961
|
function samePath(a, b) {
|
|
86700
86962
|
if (a === void 0 || b === void 0)
|
|
86701
86963
|
return false;
|
|
86702
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
86964
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path56.default.resolve(value).toLowerCase() : import_node_path56.default.resolve(value);
|
|
86703
86965
|
return norm2(a) === norm2(b);
|
|
86704
86966
|
}
|
|
86705
86967
|
function publishFolder(kind, mirrors) {
|
|
@@ -86808,7 +87070,7 @@ ${preview.text}` } : {}
|
|
|
86808
87070
|
target,
|
|
86809
87071
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
|
|
86810
87072
|
relative: entry,
|
|
86811
|
-
contents: await import_promises31.default.readFile(
|
|
87073
|
+
contents: await import_promises31.default.readFile(import_node_path56.default.join(dir, entry))
|
|
86812
87074
|
});
|
|
86813
87075
|
uploaded += 1;
|
|
86814
87076
|
} catch (error51) {
|
|
@@ -86830,7 +87092,7 @@ ${preview.text}` } : {}
|
|
|
86830
87092
|
if (!isValidToolName(name))
|
|
86831
87093
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
86832
87094
|
for (const candidate of python.toolDirectories()) {
|
|
86833
|
-
const attempt =
|
|
87095
|
+
const attempt = import_node_path56.default.join(candidate, toolFileName(name));
|
|
86834
87096
|
try {
|
|
86835
87097
|
post({ type: "pythonToolSource", name, source: await import_promises31.default.readFile(attempt, "utf8") });
|
|
86836
87098
|
return;
|
|
@@ -86883,7 +87145,7 @@ ${preview.text}` } : {}
|
|
|
86883
87145
|
continue;
|
|
86884
87146
|
for (const candidate of python.toolDirectories()) {
|
|
86885
87147
|
try {
|
|
86886
|
-
const source = await import_promises31.default.readFile(
|
|
87148
|
+
const source = await import_promises31.default.readFile(import_node_path56.default.join(candidate, toolFileName(name)), "utf8");
|
|
86887
87149
|
declined[name] = hashSource(source);
|
|
86888
87150
|
recorded += 1;
|
|
86889
87151
|
break;
|
|
@@ -86941,7 +87203,7 @@ ${preview.text}` } : {}
|
|
|
86941
87203
|
let dir;
|
|
86942
87204
|
let filePath = "";
|
|
86943
87205
|
for (const candidate of python.toolDirectories()) {
|
|
86944
|
-
const attempt =
|
|
87206
|
+
const attempt = import_node_path56.default.join(candidate, toolFileName(name));
|
|
86945
87207
|
if (await onDisk(attempt)) {
|
|
86946
87208
|
dir = candidate;
|
|
86947
87209
|
filePath = attempt;
|
|
@@ -86967,7 +87229,7 @@ ${preview.text}` } : {}
|
|
|
86967
87229
|
function mirrorForDir(sourceDir) {
|
|
86968
87230
|
if (sourceDir === void 0)
|
|
86969
87231
|
return void 0;
|
|
86970
|
-
const wanted =
|
|
87232
|
+
const wanted = import_node_path56.default.resolve(sourceDir).toLowerCase();
|
|
86971
87233
|
for (const mirror of cachedSkillMirrors) {
|
|
86972
87234
|
if (mirror.enabled !== true)
|
|
86973
87235
|
continue;
|
|
@@ -86977,7 +87239,7 @@ ${preview.text}` } : {}
|
|
|
86977
87239
|
kind: "skills",
|
|
86978
87240
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
86979
87241
|
});
|
|
86980
|
-
if (
|
|
87242
|
+
if (import_node_path56.default.resolve(localDir).toLowerCase() === wanted)
|
|
86981
87243
|
return { mirror, localDir };
|
|
86982
87244
|
}
|
|
86983
87245
|
return void 0;
|
|
@@ -87042,8 +87304,8 @@ ${preview.text}` } : {}
|
|
|
87042
87304
|
});
|
|
87043
87305
|
let localProblem;
|
|
87044
87306
|
try {
|
|
87045
|
-
await import_promises31.default.rm(
|
|
87046
|
-
await import_promises31.default.rm(
|
|
87307
|
+
await import_promises31.default.rm(import_node_path56.default.join(found2.localDir, `${name}.md`), { force: true });
|
|
87308
|
+
await import_promises31.default.rm(import_node_path56.default.join(found2.localDir, name), { recursive: true, force: true });
|
|
87047
87309
|
} catch (error51) {
|
|
87048
87310
|
localProblem = error51 instanceof Error ? error51.message : String(error51);
|
|
87049
87311
|
}
|
|
@@ -87078,7 +87340,7 @@ ${preview.text}` } : {}
|
|
|
87078
87340
|
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
87341
|
}
|
|
87080
87342
|
const from = existing?.sourceDir !== void 0 && samePath(existing.sourceDir, personalSkillsDir) ? existing.sourceDir : skillsDir;
|
|
87081
|
-
await import_promises31.default.rm(
|
|
87343
|
+
await import_promises31.default.rm(import_node_path56.default.join(from, skillFileName(name)), { force: true });
|
|
87082
87344
|
await postSkills();
|
|
87083
87345
|
} catch (error51) {
|
|
87084
87346
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -87263,7 +87525,7 @@ ${preview.text}` } : {}
|
|
|
87263
87525
|
let scheduleToolAccess;
|
|
87264
87526
|
const approvalsKey = projectRoot ?? "__no_workspace__";
|
|
87265
87527
|
function comparableApprovalsKey(key3) {
|
|
87266
|
-
return key3 === "__no_workspace__" ? key3 : normalizeForComparison(
|
|
87528
|
+
return key3 === "__no_workspace__" ? key3 : normalizeForComparison(import_node_path56.default.resolve(key3));
|
|
87267
87529
|
}
|
|
87268
87530
|
function approvalsFrom(stored) {
|
|
87269
87531
|
if (stored === void 0)
|
|
@@ -87477,7 +87739,7 @@ ${preview.text}` } : {}
|
|
|
87477
87739
|
...taskExpertEstimate === void 0 ? {} : { estimate: taskExpertEstimate }
|
|
87478
87740
|
});
|
|
87479
87741
|
}
|
|
87480
|
-
const expertEventsPath =
|
|
87742
|
+
const expertEventsPath = import_node_path56.default.join(storageDir, "expert-events.jsonl");
|
|
87481
87743
|
let expertEvents;
|
|
87482
87744
|
let juniorTurnWithoutExpert = false;
|
|
87483
87745
|
async function loadExpertEvents() {
|
|
@@ -87505,7 +87767,7 @@ ${preview.text}` } : {}
|
|
|
87505
87767
|
try {
|
|
87506
87768
|
const events = await loadExpertEvents();
|
|
87507
87769
|
events.push(event);
|
|
87508
|
-
await import_promises31.default.mkdir(
|
|
87770
|
+
await import_promises31.default.mkdir(import_node_path56.default.dirname(expertEventsPath), { recursive: true });
|
|
87509
87771
|
await import_promises31.default.appendFile(expertEventsPath, `${JSON.stringify(event)}
|
|
87510
87772
|
`, "utf8");
|
|
87511
87773
|
} catch (error51) {
|
|
@@ -87793,15 +88055,15 @@ ${preview.text}` } : {}
|
|
|
87793
88055
|
function contextMentionPath(file2) {
|
|
87794
88056
|
if (workspaceRoot === void 0)
|
|
87795
88057
|
return file2;
|
|
87796
|
-
const relative =
|
|
87797
|
-
return relative.length > 0 && !relative.startsWith("..") && !
|
|
88058
|
+
const relative = import_node_path56.default.relative(workspaceRoot, file2);
|
|
88059
|
+
return relative.length > 0 && !relative.startsWith("..") && !import_node_path56.default.isAbsolute(relative) ? relative.split(import_node_path56.default.sep).join("/") : file2;
|
|
87798
88060
|
}
|
|
87799
88061
|
function hostCapabilities() {
|
|
87800
88062
|
return {
|
|
87801
88063
|
// The branch this window or tab works on, shown under the chat's name; and the repository, when this
|
|
87802
88064
|
// folder is one of its branch folders (git/worktrees.ts).
|
|
87803
88065
|
...workspaceBranch !== void 0 ? { workspaceBranch } : {},
|
|
87804
|
-
...projectRoot !== void 0 && workspaceRoot !== void 0 && projectRoot !== workspaceRoot ? { branchFolderOf:
|
|
88066
|
+
...projectRoot !== void 0 && workspaceRoot !== void 0 && projectRoot !== workspaceRoot ? { branchFolderOf: import_node_path56.default.basename(projectRoot) } : {},
|
|
87805
88067
|
// The GitHub Copilot preset, offered only where VS Code's models can be reached.
|
|
87806
88068
|
hostModels: services.languageModels !== void 0,
|
|
87807
88069
|
nativeGuide: ui.openWalkthrough !== void 0,
|
|
@@ -87881,7 +88143,10 @@ ${preview.text}` } : {}
|
|
|
87881
88143
|
} catch {
|
|
87882
88144
|
return true;
|
|
87883
88145
|
}
|
|
87884
|
-
}
|
|
88146
|
+
},
|
|
88147
|
+
// Shared by every chat of a codebase in Fire Code (`codebaseDir`), so a chat starting after a crash or a
|
|
88148
|
+
// sleep offers the servers' tools at once instead of waiting for each to start (`mcp/toolCache.ts`).
|
|
88149
|
+
fileMcpToolCache(mcpToolCacheFile(services.codebaseDir ?? storageDir))
|
|
87885
88150
|
);
|
|
87886
88151
|
function postMcp() {
|
|
87887
88152
|
const servers = mcp.states_();
|
|
@@ -88364,14 +88629,14 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88364
88629
|
}
|
|
88365
88630
|
function readUserNpmrc() {
|
|
88366
88631
|
try {
|
|
88367
|
-
return (0,
|
|
88632
|
+
return (0, import_node_fs14.readFileSync)(process.env["NPM_CONFIG_USERCONFIG"] ?? import_node_path56.default.join(import_node_os7.default.homedir(), ".npmrc"), "utf8");
|
|
88368
88633
|
} catch {
|
|
88369
88634
|
return void 0;
|
|
88370
88635
|
}
|
|
88371
88636
|
}
|
|
88372
88637
|
function addonFolders(config2) {
|
|
88373
88638
|
return {
|
|
88374
|
-
configured: (config2.addons?.folders ?? []).map((folder) =>
|
|
88639
|
+
configured: (config2.addons?.folders ?? []).map((folder) => import_node_path56.default.resolve(folder)),
|
|
88375
88640
|
defaults: defaultAddonFolders(process.env, process.execPath, process.platform, readUserNpmrc())
|
|
88376
88641
|
};
|
|
88377
88642
|
}
|
|
@@ -88652,7 +88917,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88652
88917
|
}
|
|
88653
88918
|
async function handleSaveAddonFolders(folders) {
|
|
88654
88919
|
const cleaned = [...new Set(folders.map((folder) => folder.trim()).filter((folder) => folder.length > 0))];
|
|
88655
|
-
const relative = cleaned.find((folder) => !
|
|
88920
|
+
const relative = cleaned.find((folder) => !import_node_path56.default.isAbsolute(folder));
|
|
88656
88921
|
if (relative !== void 0) {
|
|
88657
88922
|
await postAddons(`"${relative}" is not a full path. Add-on folders are full paths, such as C:\\addons.`);
|
|
88658
88923
|
return;
|
|
@@ -88663,7 +88928,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88663
88928
|
postMcp();
|
|
88664
88929
|
await postAddons();
|
|
88665
88930
|
}
|
|
88666
|
-
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot,
|
|
88931
|
+
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot, import_node_path56.default.join(storageDir, "checkpoints", "shadow.git"), services.codebaseDir !== void 0 ? import_node_path56.default.join(services.codebaseDir, "checkpoint-objects") : void 0) : void 0;
|
|
88667
88932
|
async function postProfiles() {
|
|
88668
88933
|
const { config: config2 } = await configManager.load();
|
|
88669
88934
|
const profiles = await Promise.all((config2.profiles ?? []).map((profile) => toSummary(profile, secrets)));
|
|
@@ -88832,7 +89097,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88832
89097
|
await observerHub.configure(settings);
|
|
88833
89098
|
if (restart)
|
|
88834
89099
|
await observerHub.restart();
|
|
88835
|
-
auditRecordExists = settings.auditor.enabled || (0,
|
|
89100
|
+
auditRecordExists = settings.auditor.enabled || (0, import_node_fs14.existsSync)(observerHub.journalFolder);
|
|
88836
89101
|
if (settings.auditor.enabled && !auditPruned) {
|
|
88837
89102
|
auditPruned = true;
|
|
88838
89103
|
void pruneAudit(storageDir, o.auditor?.retentionDays ?? 90).then((n) => {
|
|
@@ -88877,7 +89142,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88877
89142
|
return;
|
|
88878
89143
|
}
|
|
88879
89144
|
if (ui.openFile !== void 0)
|
|
88880
|
-
await ui.openFile(
|
|
89145
|
+
await ui.openFile(import_node_path56.default.join(folder, newest));
|
|
88881
89146
|
else
|
|
88882
89147
|
ui.showInfo(`The audit journal is in ${folder} (newest: ${newest}).`);
|
|
88883
89148
|
}
|
|
@@ -88915,7 +89180,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88915
89180
|
async function handleOpenArtifact(relative, how) {
|
|
88916
89181
|
if (workspaceRoot === void 0)
|
|
88917
89182
|
return;
|
|
88918
|
-
const absolute = await confine(
|
|
89183
|
+
const absolute = await confine(import_node_path56.default.resolve(workspaceRoot, relative), workspaceRoot);
|
|
88919
89184
|
if (await denylist.isDenied(absolute)) {
|
|
88920
89185
|
ui.showWarning(`${relative} is on the deny list, so it is not opened.`);
|
|
88921
89186
|
return;
|
|
@@ -89028,7 +89293,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89028
89293
|
return { ok: true, message: `Saved in ${file2}; it reaches colleagues through this project's own sharing.` };
|
|
89029
89294
|
}
|
|
89030
89295
|
const enabled = cachedToolMirrors.filter((each) => each.enabled === true);
|
|
89031
|
-
const index = mirroredToolsDirs.findIndex((dir) => samePath(
|
|
89296
|
+
const index = mirroredToolsDirs.findIndex((dir) => samePath(import_node_path56.default.dirname(file2), dir));
|
|
89032
89297
|
try {
|
|
89033
89298
|
await writeFileAtomically(file2, review.content);
|
|
89034
89299
|
const mirror = index >= 0 ? enabled[index] : void 0;
|
|
@@ -89036,7 +89301,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89036
89301
|
const target = targetById(cachedS3, mirror.connectionId);
|
|
89037
89302
|
if (target === void 0 || target.readOnly === true)
|
|
89038
89303
|
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:
|
|
89304
|
+
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: import_node_path56.default.basename(file2), contents: Buffer.from(review.content, "utf8") });
|
|
89040
89305
|
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
89306
|
}
|
|
89042
89307
|
scheduleTeamRepoPush();
|
|
@@ -89318,7 +89583,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89318
89583
|
}
|
|
89319
89584
|
function composerDraftFile() {
|
|
89320
89585
|
const id = (0, import_node_crypto20.createHash)("sha256").update((workspaceRoot ?? "").toLowerCase()).digest("hex").slice(0, 16);
|
|
89321
|
-
return
|
|
89586
|
+
return import_node_path56.default.join(storageDir, "drafts", `${id}.txt`);
|
|
89322
89587
|
}
|
|
89323
89588
|
let draftWrites = Promise.resolve();
|
|
89324
89589
|
function saveComposerDraft(text2) {
|
|
@@ -89617,7 +89882,9 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89617
89882
|
const instructionsReady = early(readCodebaseInstructions(codebaseInstructionsFile));
|
|
89618
89883
|
const toolsReady = early((async () => {
|
|
89619
89884
|
await syncMcpFromConfig(config2);
|
|
89620
|
-
await mcp.
|
|
89885
|
+
const still = await mcp.ensureReady();
|
|
89886
|
+
if (still.length > 0)
|
|
89887
|
+
logger.info(`[startup] replying without waiting longer for MCP server(s) still starting: ${still.join(", ")}`);
|
|
89621
89888
|
await configurePython(config2);
|
|
89622
89889
|
})());
|
|
89623
89890
|
const capabilities = withReportedWindow(resolveModelCapabilities(profile.model, profile.modelCapabilities), await windowReady, profile.modelCapabilities);
|
|
@@ -89813,7 +90080,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89813
90080
|
...schedule === void 0 ? { requestForm } : {},
|
|
89814
90081
|
// A skill read with the user's defaults for its placeholders carries them (`skills/defaults.ts`).
|
|
89815
90082
|
annotateRead: (realPath) => {
|
|
89816
|
-
const fold = (value) => process.platform === "win32" ?
|
|
90083
|
+
const fold = (value) => process.platform === "win32" ? import_node_path56.default.resolve(value).toLowerCase() : import_node_path56.default.resolve(value);
|
|
89817
90084
|
const skill = skills.find((each) => fold(each.filePath) === fold(realPath));
|
|
89818
90085
|
return skill === void 0 ? void 0 : skillDefaultsReadNote(skill.name, config2.skillDefaults?.[skill.name]);
|
|
89819
90086
|
},
|
|
@@ -91121,7 +91388,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91121
91388
|
return { mode: cachedSearchScope, author: cachedAttribution.author };
|
|
91122
91389
|
}
|
|
91123
91390
|
function currentProjectNames() {
|
|
91124
|
-
const names = [cachedAttribution.project, workspaceRoot !== void 0 ?
|
|
91391
|
+
const names = [cachedAttribution.project, workspaceRoot !== void 0 ? import_node_path56.default.basename(workspaceRoot) : void 0];
|
|
91125
91392
|
return names.filter((name) => name !== void 0 && name.length > 0);
|
|
91126
91393
|
}
|
|
91127
91394
|
function indexProject(config2) {
|
|
@@ -91224,8 +91491,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91224
91491
|
limit: limits.limit,
|
|
91225
91492
|
previewChars: limits.previewChars
|
|
91226
91493
|
});
|
|
91227
|
-
for (const
|
|
91228
|
-
skipped2.add(
|
|
91494
|
+
for (const path67 of answer.skipped ?? [])
|
|
91495
|
+
skipped2.add(path67);
|
|
91229
91496
|
return { messages: answer.messages, truncated: answer.truncated };
|
|
91230
91497
|
},
|
|
91231
91498
|
...embedder !== void 0 && search !== void 0 && collection !== void 0 ? {
|
|
@@ -91524,9 +91791,9 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91524
91791
|
});
|
|
91525
91792
|
const all = result.folders.map((entry) => entry.path);
|
|
91526
91793
|
const wanted = new Set(chosen);
|
|
91527
|
-
for (const
|
|
91528
|
-
if (chosen.some((root) =>
|
|
91529
|
-
wanted.add(
|
|
91794
|
+
for (const path67 of all) {
|
|
91795
|
+
if (chosen.some((root) => path67 === root || path67.startsWith(`${root}\\`)))
|
|
91796
|
+
wanted.add(path67);
|
|
91530
91797
|
}
|
|
91531
91798
|
return [...wanted];
|
|
91532
91799
|
} catch {
|
|
@@ -91534,7 +91801,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91534
91801
|
}
|
|
91535
91802
|
}
|
|
91536
91803
|
async function handleRequestOutlookFolders(depth, force = false) {
|
|
91537
|
-
const cachePath =
|
|
91804
|
+
const cachePath = import_node_path56.default.join(storageDir, "outlook-folders.json");
|
|
91538
91805
|
let served = false;
|
|
91539
91806
|
try {
|
|
91540
91807
|
const cached2 = JSON.parse(await import_promises31.default.readFile(cachePath, "utf8"));
|
|
@@ -91554,7 +91821,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91554
91821
|
const scannedAt = Date.now();
|
|
91555
91822
|
post({ type: "outlookFolders", folders: result.folders, scannedAt });
|
|
91556
91823
|
try {
|
|
91557
|
-
await import_promises31.default.mkdir(
|
|
91824
|
+
await import_promises31.default.mkdir(import_node_path56.default.dirname(cachePath), { recursive: true });
|
|
91558
91825
|
await import_promises31.default.writeFile(cachePath, JSON.stringify({ scannedAt, folders: result.folders }), "utf8");
|
|
91559
91826
|
} catch {
|
|
91560
91827
|
}
|
|
@@ -92472,12 +92739,12 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92472
92739
|
if (!isSafeSegment(settings.project) || !isSafeSegment(settings.repo))
|
|
92473
92740
|
return { reason: "Enter the project key and repository slug." };
|
|
92474
92741
|
const digest = (0, import_node_crypto20.createHash)("sha256").update(JSON.stringify([bitbucket.baseUrl, settings.project, settings.repo, settings.branch, settings.folder]).toLowerCase()).digest("hex").slice(0, 12);
|
|
92475
|
-
const root =
|
|
92742
|
+
const root = import_node_path56.default.join(mirrorRoot, "teamrepo", `${settings.project}-${settings.repo}-${digest}`.toLowerCase());
|
|
92476
92743
|
return {
|
|
92477
|
-
dirs: { skills:
|
|
92744
|
+
dirs: { skills: import_node_path56.default.join(root, "skills"), tools: import_node_path56.default.join(root, "tools") },
|
|
92478
92745
|
// Where new skills and tools are saved while the repository is on - see loadSettings and pythonFolders.
|
|
92479
|
-
own: { skills:
|
|
92480
|
-
stateFile:
|
|
92746
|
+
own: { skills: import_node_path56.default.join(root, "saved-here", "skills"), tools: import_node_path56.default.join(root, "saved-here", "tools") },
|
|
92747
|
+
stateFile: import_node_path56.default.join(root, TEAM_REPO_STATE_FILE),
|
|
92481
92748
|
settings
|
|
92482
92749
|
};
|
|
92483
92750
|
}
|
|
@@ -92520,14 +92787,14 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92520
92787
|
const config2 = await loadSettings();
|
|
92521
92788
|
const plan3 = teamRepoPlan(config2);
|
|
92522
92789
|
if (!("reason" in plan3)) {
|
|
92523
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
92790
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path56.default.resolve(value).toLowerCase() : import_node_path56.default.resolve(value);
|
|
92524
92791
|
const folders = [
|
|
92525
92792
|
...[plan3.dirs.skills, plan3.own.skills, ...skillSearchPath()].map((dir) => [dir, "skills"]),
|
|
92526
92793
|
...[plan3.dirs.tools, plan3.own.tools, ...python.toolDirectories()].map((dir) => [dir, "tools"])
|
|
92527
92794
|
];
|
|
92528
|
-
const holder = folders.find(([dir]) => norm2(file2).startsWith(norm2(dir) +
|
|
92795
|
+
const holder = folders.find(([dir]) => norm2(file2).startsWith(norm2(dir) + import_node_path56.default.sep));
|
|
92529
92796
|
if (holder !== void 0) {
|
|
92530
|
-
const relative =
|
|
92797
|
+
const relative = import_node_path56.default.relative(import_node_path56.default.resolve(holder[0]), import_node_path56.default.resolve(file2)).split(import_node_path56.default.sep).join("/");
|
|
92531
92798
|
const where = repoPathFor(plan3.settings.folder, holder[1], relative);
|
|
92532
92799
|
try {
|
|
92533
92800
|
const client = await bitbucketClient();
|
|
@@ -92559,21 +92826,21 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92559
92826
|
const has2 = async (target) => import_promises31.default.stat(target).then(() => true, () => false);
|
|
92560
92827
|
if (kind === "skill") {
|
|
92561
92828
|
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(
|
|
92829
|
+
if (await has2(import_node_path56.default.join(dir, skillFileName(name))))
|
|
92830
|
+
plan3.local.push(import_node_path56.default.join(dir, skillFileName(name)));
|
|
92831
|
+
if (await has2(import_node_path56.default.join(dir, name, "SKILL.md")))
|
|
92832
|
+
plan3.local.push(import_node_path56.default.join(dir, name));
|
|
92566
92833
|
}
|
|
92567
92834
|
for (const extra of config2.skills?.paths ?? []) {
|
|
92568
92835
|
const dir = resolveSkillDir(extra);
|
|
92569
|
-
if (dir !== void 0 && (await has2(
|
|
92836
|
+
if (dir !== void 0 && (await has2(import_node_path56.default.join(dir, skillFileName(name))) || await has2(import_node_path56.default.join(dir, name, "SKILL.md")))) {
|
|
92570
92837
|
plan3.notes.push(`Also in ${dir}, a folder you added in Settings -> Skills - not removed; delete it there.`);
|
|
92571
92838
|
}
|
|
92572
92839
|
}
|
|
92573
92840
|
} else {
|
|
92574
92841
|
for (const dir of unique([pythonFolders(config2).toolsDir, localToolsDir(config2), personalToolsDir, ...mirroredToolsDirs])) {
|
|
92575
|
-
if (await has2(
|
|
92576
|
-
plan3.local.push(
|
|
92842
|
+
if (await has2(import_node_path56.default.join(dir, toolFileName(name))))
|
|
92843
|
+
plan3.local.push(import_node_path56.default.join(dir, toolFileName(name)));
|
|
92577
92844
|
}
|
|
92578
92845
|
}
|
|
92579
92846
|
const mirrors = (kind === "skill" ? cachedSkillMirrors : cachedToolMirrors).filter((mirror) => mirror.enabled === true);
|
|
@@ -92671,7 +92938,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92671
92938
|
try {
|
|
92672
92939
|
await import_promises31.default.rm(entry, { recursive: true, force: true });
|
|
92673
92940
|
if (kind === "tool")
|
|
92674
|
-
await forgetTool(
|
|
92941
|
+
await forgetTool(import_node_path56.default.dirname(entry), name).catch(() => void 0);
|
|
92675
92942
|
} catch (error51) {
|
|
92676
92943
|
localProblems.push(`${entry} (${error51 instanceof Error ? error51.message : String(error51)})`);
|
|
92677
92944
|
}
|
|
@@ -92697,24 +92964,24 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92697
92964
|
}
|
|
92698
92965
|
async function writeTeamMonitorSkill(file2, content) {
|
|
92699
92966
|
const config2 = await loadSettings();
|
|
92700
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
92967
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path56.default.resolve(value).toLowerCase() : import_node_path56.default.resolve(value);
|
|
92701
92968
|
const inside = (dir) => {
|
|
92702
92969
|
const target = norm2(file2);
|
|
92703
92970
|
const root = norm2(dir);
|
|
92704
|
-
return target.startsWith(root +
|
|
92971
|
+
return target.startsWith(root + import_node_path56.default.sep) ? import_node_path56.default.relative(import_node_path56.default.resolve(dir), import_node_path56.default.resolve(file2)) : void 0;
|
|
92705
92972
|
};
|
|
92706
92973
|
const saveIn = async (dir, relative) => {
|
|
92707
|
-
const destination =
|
|
92974
|
+
const destination = import_node_path56.default.join(dir, relative);
|
|
92708
92975
|
const enabled = cachedSkillMirrors.filter((each) => each.enabled === true);
|
|
92709
92976
|
const mirror = enabled.find((_, i) => samePath(mirroredSkillsDirs[i], dir));
|
|
92710
92977
|
const target = mirror !== void 0 ? targetById(cachedS3, mirror.connectionId) : void 0;
|
|
92711
92978
|
if (mirror !== void 0 && (target === void 0 || target.readOnly === true)) {
|
|
92712
92979
|
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
92980
|
}
|
|
92714
|
-
await import_promises31.default.mkdir(
|
|
92981
|
+
await import_promises31.default.mkdir(import_node_path56.default.dirname(destination), { recursive: true });
|
|
92715
92982
|
await writeFileAtomically(destination, content);
|
|
92716
92983
|
if (mirror !== void 0 && target !== void 0) {
|
|
92717
|
-
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: relative.split(
|
|
92984
|
+
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: relative.split(import_node_path56.default.sep).join("/"), contents: Buffer.from(content, "utf8") });
|
|
92718
92985
|
return `uploaded to the bucket ${target.label}`;
|
|
92719
92986
|
}
|
|
92720
92987
|
return `saved in ${dir}`;
|
|
@@ -92736,7 +93003,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92736
93003
|
throw new Error("There is no folder to save skills in, so the change cannot reach the team repository.");
|
|
92737
93004
|
const where = await saveIn(skillsDir, relative);
|
|
92738
93005
|
await handleTeamRepoSync("a monitor changed on the dashboard");
|
|
92739
|
-
const problem = teamRepoStatus?.error ?? teamRepoStatus?.conflicts.find((c2) => c2.path.endsWith(relative.split(
|
|
93006
|
+
const problem = teamRepoStatus?.error ?? teamRepoStatus?.conflicts.find((c2) => c2.path.endsWith(relative.split(import_node_path56.default.sep).join("/")))?.reason;
|
|
92740
93007
|
if (problem !== void 0) {
|
|
92741
93008
|
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
93009
|
}
|
|
@@ -92766,8 +93033,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92766
93033
|
function isPersonalSkill(skill) {
|
|
92767
93034
|
if (personalSkillsDir === void 0)
|
|
92768
93035
|
return false;
|
|
92769
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
92770
|
-
return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) +
|
|
93036
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path56.default.resolve(value).toLowerCase() : import_node_path56.default.resolve(value);
|
|
93037
|
+
return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) + import_node_path56.default.sep);
|
|
92771
93038
|
}
|
|
92772
93039
|
function bucketFolderLabels(config2) {
|
|
92773
93040
|
const label = (kind, mirror) => {
|
|
@@ -93015,7 +93282,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
93015
93282
|
}
|
|
93016
93283
|
const command = config2.branches?.setupCommand?.trim();
|
|
93017
93284
|
if (command !== void 0 && command.length > 0) {
|
|
93018
|
-
const label = workspaceBranch ??
|
|
93285
|
+
const label = workspaceBranch ?? import_node_path56.default.basename(workspaceRoot);
|
|
93019
93286
|
if (ui.runInTerminal !== void 0) {
|
|
93020
93287
|
ui.runInTerminal({ name: `Set up ${label}`, command, cwd: workspaceRoot, env: branchEnv });
|
|
93021
93288
|
parts.push(`running "${command}" in a terminal`);
|
|
@@ -93089,7 +93356,7 @@ ${last}` : ""}`);
|
|
|
93089
93356
|
approvalStamps.set("machine", stamp2);
|
|
93090
93357
|
}
|
|
93091
93358
|
for (const dir of python.toolDirectories()) {
|
|
93092
|
-
const file2 =
|
|
93359
|
+
const file2 = import_node_path56.default.join(dir, REGISTRY_FILE);
|
|
93093
93360
|
const stamp2 = await import_promises31.default.stat(file2).then((stat) => stat.mtimeMs, () => 0);
|
|
93094
93361
|
if (approvalStamps.has(file2) && approvalStamps.get(file2) !== stamp2)
|
|
93095
93362
|
changed = true;
|
|
@@ -93191,7 +93458,7 @@ ${last}` : ""}`);
|
|
|
93191
93458
|
return;
|
|
93192
93459
|
}
|
|
93193
93460
|
const folder = skill.filePath.slice(0, skill.filePath.length - "SKILL.md".length);
|
|
93194
|
-
const bytes = await import_promises31.default.readFile(
|
|
93461
|
+
const bytes = await import_promises31.default.readFile(import_node_path56.default.join(folder, SKILL_IMAGE_DIR, image));
|
|
93195
93462
|
const dataUri = skillImageDataUri(image, bytes);
|
|
93196
93463
|
post({
|
|
93197
93464
|
type: "skillImage",
|
|
@@ -93557,13 +93824,13 @@ ${last}` : ""}`);
|
|
|
93557
93824
|
}
|
|
93558
93825
|
function docsFingerprintPath(index, storeId, kind) {
|
|
93559
93826
|
const suffix = kind === void 0 ? "docs" : `docs.${kind}`;
|
|
93560
|
-
return
|
|
93827
|
+
return import_node_path56.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.${suffix}.json`);
|
|
93561
93828
|
}
|
|
93562
93829
|
function manifestKey(index, storeId) {
|
|
93563
93830
|
return `${index}@${storeId}`;
|
|
93564
93831
|
}
|
|
93565
93832
|
function manifestPath(index, storeId) {
|
|
93566
|
-
return
|
|
93833
|
+
return import_node_path56.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.json`);
|
|
93567
93834
|
}
|
|
93568
93835
|
async function readDocsFingerprint(index, storeId, kind) {
|
|
93569
93836
|
try {
|
|
@@ -93627,7 +93894,7 @@ ${last}` : ""}`);
|
|
|
93627
93894
|
}
|
|
93628
93895
|
options.report?.("Writing", { done: 0, total: documents.length });
|
|
93629
93896
|
await writer.upsert(index, documents);
|
|
93630
|
-
await import_promises31.default.mkdir(
|
|
93897
|
+
await import_promises31.default.mkdir(import_node_path56.default.dirname(docsFingerprintPath(index, search.id, wanted)), {
|
|
93631
93898
|
recursive: true
|
|
93632
93899
|
});
|
|
93633
93900
|
await import_promises31.default.writeFile(docsFingerprintPath(index, search.id, wanted), JSON.stringify({ fingerprint, indexedAt: Date.now(), count: documents.length }), "utf8");
|
|
@@ -93817,7 +94084,7 @@ ${last}` : ""}`);
|
|
|
93817
94084
|
});
|
|
93818
94085
|
if (manifest !== void 0) {
|
|
93819
94086
|
const targetPath = manifestPath(index, target.id);
|
|
93820
|
-
await import_promises31.default.mkdir(
|
|
94087
|
+
await import_promises31.default.mkdir(import_node_path56.default.dirname(targetPath), { recursive: true });
|
|
93821
94088
|
await import_promises31.default.writeFile(targetPath, JSON.stringify(manifest), "utf8");
|
|
93822
94089
|
}
|
|
93823
94090
|
post({ type: "storeSync", running: false, copied: result.copied, fromLabel: source.label });
|
|
@@ -93866,7 +94133,7 @@ ${last}` : ""}`);
|
|
|
93866
94133
|
type: "project",
|
|
93867
94134
|
hasWorkspace: workspaceRoot !== void 0,
|
|
93868
94135
|
...configured !== void 0 ? { configured } : {},
|
|
93869
|
-
...workspaceRoot !== void 0 ? { folder:
|
|
94136
|
+
...workspaceRoot !== void 0 ? { folder: import_node_path56.default.basename(workspaceRoot) } : {},
|
|
93870
94137
|
...author !== void 0 ? { author } : {},
|
|
93871
94138
|
...index !== void 0 ? { indexName: index } : {},
|
|
93872
94139
|
...ownerConfigured !== void 0 && ownerConfigured.length > 0 ? { ownerConfigured } : {},
|
|
@@ -94006,8 +94273,8 @@ ${last}` : ""}`);
|
|
|
94006
94273
|
if (workspaceRoot === void 0)
|
|
94007
94274
|
return found2;
|
|
94008
94275
|
const root = workspaceRoot;
|
|
94009
|
-
const relative =
|
|
94010
|
-
if (relative.startsWith("..") ||
|
|
94276
|
+
const relative = import_node_path56.default.relative(root, folder);
|
|
94277
|
+
if (relative.startsWith("..") || import_node_path56.default.isAbsolute(relative))
|
|
94011
94278
|
return found2;
|
|
94012
94279
|
const output = await new Promise((resolve) => {
|
|
94013
94280
|
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 +94291,7 @@ ${last}` : ""}`);
|
|
|
94024
94291
|
if (line.startsWith("@@"))
|
|
94025
94292
|
author = line.slice(2).trim();
|
|
94026
94293
|
else if (line.trim().length > 0 && author !== void 0 && author.length > 0) {
|
|
94027
|
-
found2.set(normalizeForComparison(
|
|
94294
|
+
found2.set(normalizeForComparison(import_node_path56.default.resolve(root, line.trim())), author);
|
|
94028
94295
|
}
|
|
94029
94296
|
}
|
|
94030
94297
|
return found2;
|
|
@@ -94068,7 +94335,7 @@ ${last}` : ""}`);
|
|
|
94068
94335
|
},
|
|
94069
94336
|
source,
|
|
94070
94337
|
folder,
|
|
94071
|
-
relative:
|
|
94338
|
+
relative: import_node_path56.default.relative(folder, filePath).split(import_node_path56.default.sep).join("/")
|
|
94072
94339
|
});
|
|
94073
94340
|
};
|
|
94074
94341
|
for (const folder of skillFolders) {
|
|
@@ -94086,7 +94353,7 @@ ${last}` : ""}`);
|
|
|
94086
94353
|
const name = entry.slice(0, -3);
|
|
94087
94354
|
if (!isValidToolName(name))
|
|
94088
94355
|
continue;
|
|
94089
|
-
await consider("tool", name,
|
|
94356
|
+
await consider("tool", name, import_node_path56.default.join(folder, entry), folder, location);
|
|
94090
94357
|
}
|
|
94091
94358
|
}
|
|
94092
94359
|
const readOnly = skills.filter((skill) => skill.sourceDir !== void 0 && !skillFolders.some((folder) => samePath(folder, skill.sourceDir))).length;
|
|
@@ -94118,7 +94385,7 @@ ${last}` : ""}`);
|
|
|
94118
94385
|
} catch {
|
|
94119
94386
|
}
|
|
94120
94387
|
}
|
|
94121
|
-
const gitAuthor = gitAuthors.get(normalizeForComparison(
|
|
94388
|
+
const gitAuthor = gitAuthors.get(normalizeForComparison(import_node_path56.default.resolve(candidate.entry.filePath)));
|
|
94122
94389
|
if (gitAuthor !== void 0) {
|
|
94123
94390
|
candidate.entry.suggestion = { author: gitAuthor, source: "git: the commit that added this file" };
|
|
94124
94391
|
}
|
|
@@ -94227,7 +94494,7 @@ ${last}` : ""}`);
|
|
|
94227
94494
|
aliases: plan3.kind === "codebase" ? codebaseAliases(config2) : plan3.kind === "skills" ? skillAliases(config2) : [],
|
|
94228
94495
|
onProgress: (count3) => post({ type: "indexRenames", running: true, plans, store, current: plan3.to, copied: count3 })
|
|
94229
94496
|
});
|
|
94230
|
-
await copyBookkeeping(
|
|
94497
|
+
await copyBookkeeping(import_node_path56.default.join(manifestsRoot, "index-manifests"), plan3.from, plan3.to, search.id);
|
|
94231
94498
|
done.push({ ...plan3, copied });
|
|
94232
94499
|
}
|
|
94233
94500
|
post({ type: "indexRenames", running: false, plans: [], store, done });
|
|
@@ -94257,7 +94524,7 @@ ${last}` : ""}`);
|
|
|
94257
94524
|
project: projectName(config2, workspaceRoot),
|
|
94258
94525
|
aliases: codebaseAliases(config2)
|
|
94259
94526
|
});
|
|
94260
|
-
await copyBookkeeping(
|
|
94527
|
+
await copyBookkeeping(import_node_path56.default.join(manifestsRoot, "index-manifests"), legacy, current, search.id);
|
|
94261
94528
|
post({ type: "indexRenames", running: false, plans: [], done: [{ kind: "codebase", from: legacy, to: current, copied }] });
|
|
94262
94529
|
logger.info(`copied ${String(copied)} chunks from ${legacy} to ${current} rather than re-embedding them`);
|
|
94263
94530
|
}
|
|
@@ -94423,7 +94690,7 @@ ${last}` : ""}`);
|
|
|
94423
94690
|
denylist,
|
|
94424
94691
|
manifest,
|
|
94425
94692
|
saveManifest: async (next) => {
|
|
94426
|
-
await import_promises31.default.mkdir(
|
|
94693
|
+
await import_promises31.default.mkdir(import_node_path56.default.dirname(manifestFile), { recursive: true });
|
|
94427
94694
|
await import_promises31.default.writeFile(manifestFile, JSON.stringify(next), "utf8");
|
|
94428
94695
|
},
|
|
94429
94696
|
...isIgnored2 !== void 0 ? { isIgnored: isIgnored2 } : {},
|
|
@@ -94509,9 +94776,9 @@ ${last}` : ""}`);
|
|
|
94509
94776
|
}
|
|
94510
94777
|
const usageLog = new UsageLog(storageDir);
|
|
94511
94778
|
const usageInstance = usageInstanceId(storageDir);
|
|
94512
|
-
const usageProfileFile =
|
|
94513
|
-
const legacyBackfillFile =
|
|
94514
|
-
const usageDir =
|
|
94779
|
+
const usageProfileFile = import_node_path56.default.join(storageDir, "usage-profile.json");
|
|
94780
|
+
const legacyBackfillFile = import_node_path56.default.join(storageDir, "usage-backfill.json");
|
|
94781
|
+
const usageDir = import_node_path56.default.join(storageDir, "usage");
|
|
94515
94782
|
const toolStartedAt = /* @__PURE__ */ new Map();
|
|
94516
94783
|
let usagePushTimer;
|
|
94517
94784
|
let usagePushing;
|
|
@@ -94529,7 +94796,7 @@ ${last}` : ""}`);
|
|
|
94529
94796
|
return (request2) => runFastFs(exe, request2);
|
|
94530
94797
|
}
|
|
94531
94798
|
function skillAtPath(requested2) {
|
|
94532
|
-
const absolute =
|
|
94799
|
+
const absolute = import_node_path56.default.isAbsolute(requested2) ? requested2 : workspaceRoot === void 0 ? void 0 : import_node_path56.default.resolve(workspaceRoot, requested2);
|
|
94533
94800
|
if (absolute === void 0)
|
|
94534
94801
|
return void 0;
|
|
94535
94802
|
return skills.find((skill) => samePath(skill.filePath, absolute));
|
|
@@ -94619,7 +94886,7 @@ ${last}` : ""}`);
|
|
|
94619
94886
|
const folder = chosen.path?.trim();
|
|
94620
94887
|
if (folder === void 0 || folder.length === 0)
|
|
94621
94888
|
return { problem: "The shared folder has no path." };
|
|
94622
|
-
if (!
|
|
94889
|
+
if (!import_node_path56.default.isAbsolute(folder))
|
|
94623
94890
|
return { problem: `"${folder}" is not an absolute path. Use the full path of a folder everybody can reach, such as a network share.` };
|
|
94624
94891
|
const helper = usageHelper();
|
|
94625
94892
|
return { store: new FolderShardStore(folder, ...helper !== void 0 ? [helper] : []), target };
|
|
@@ -94648,7 +94915,7 @@ ${last}` : ""}`);
|
|
|
94648
94915
|
}
|
|
94649
94916
|
async function readUsageBackfill() {
|
|
94650
94917
|
try {
|
|
94651
|
-
const text2 = await import_promises31.default.readFile(
|
|
94918
|
+
const text2 = await import_promises31.default.readFile(import_node_path56.default.join(usageDir, "backfill.json"), "utf8").catch(() => import_promises31.default.readFile(legacyBackfillFile, "utf8"));
|
|
94652
94919
|
const saved = JSON.parse(text2);
|
|
94653
94920
|
if (typeof saved.at !== "number")
|
|
94654
94921
|
return void 0;
|
|
@@ -94664,7 +94931,7 @@ ${last}` : ""}`);
|
|
|
94664
94931
|
legacyDoneFile: legacyBackfillFile,
|
|
94665
94932
|
run: async (before) => {
|
|
94666
94933
|
const status2 = python.status();
|
|
94667
|
-
return backfillFromTasks(
|
|
94934
|
+
return backfillFromTasks(import_node_path56.default.join(storageDir, "tasks"), {
|
|
94668
94935
|
user: cachedAttribution.author ?? "unknown",
|
|
94669
94936
|
project: cachedAttribution.project,
|
|
94670
94937
|
workspaceRoot,
|
|
@@ -94837,14 +95104,14 @@ ${last}` : ""}`);
|
|
|
94837
95104
|
kind: "tool",
|
|
94838
95105
|
name: issue2.name,
|
|
94839
95106
|
filePath: issue2.filePath,
|
|
94840
|
-
deletable: samePath(
|
|
94841
|
-
location: where(
|
|
95107
|
+
deletable: samePath(import_node_path56.default.dirname(issue2.filePath), status2.toolsDir),
|
|
95108
|
+
location: where(import_node_path56.default.dirname(issue2.filePath), status2.toolsDir),
|
|
94842
95109
|
issue: issue2.kind === "unapproved" ? "waiting for approval" : issue2.kind === "hash-mismatch" ? "changed since approval" : issue2.detail.split("\n")[0] ?? "not loaded"
|
|
94843
95110
|
});
|
|
94844
95111
|
}
|
|
94845
95112
|
return items;
|
|
94846
95113
|
}
|
|
94847
|
-
const usageDirectoryFile =
|
|
95114
|
+
const usageDirectoryFile = import_node_path56.default.join(storageDir, "usage-directory.json");
|
|
94848
95115
|
let directoryRunning;
|
|
94849
95116
|
async function readDirectoryCache() {
|
|
94850
95117
|
try {
|
|
@@ -95179,7 +95446,7 @@ ${last}` : ""}`);
|
|
|
95179
95446
|
let indexedFiles = 0;
|
|
95180
95447
|
if (index !== void 0) {
|
|
95181
95448
|
try {
|
|
95182
|
-
const manifest = JSON.parse(await import_promises31.default.readFile(
|
|
95449
|
+
const manifest = JSON.parse(await import_promises31.default.readFile(import_node_path56.default.join(manifestsRoot, "index-manifests", `${index}.json`), "utf8"));
|
|
95183
95450
|
indexedFiles = Object.keys(manifest.files ?? {}).length;
|
|
95184
95451
|
} catch {
|
|
95185
95452
|
}
|
|
@@ -95659,11 +95926,11 @@ ${last}` : ""}`);
|
|
|
95659
95926
|
answer({ error: bytes.length === 0 ? "There was nothing to save." : "That file is too large to save from here." });
|
|
95660
95927
|
return;
|
|
95661
95928
|
}
|
|
95662
|
-
const safeName = [...
|
|
95663
|
-
const extension =
|
|
95929
|
+
const safeName = [...import_node_path56.default.basename(name)].map((c2) => c2.charCodeAt(0) < 32 || '<>:"/\\|?*'.includes(c2) ? "-" : c2).join("") || "file";
|
|
95930
|
+
const extension = import_node_path56.default.extname(safeName).slice(1);
|
|
95664
95931
|
try {
|
|
95665
95932
|
const target = await ui.showSaveDialog({
|
|
95666
|
-
defaultName: workspaceRoot !== void 0 ?
|
|
95933
|
+
defaultName: workspaceRoot !== void 0 ? import_node_path56.default.join(workspaceRoot, safeName) : safeName,
|
|
95667
95934
|
...extension.length > 0 ? { extensions: [extension] } : {}
|
|
95668
95935
|
});
|
|
95669
95936
|
if (target === void 0) {
|
|
@@ -95744,8 +96011,8 @@ ${last}` : ""}`);
|
|
|
95744
96011
|
continue;
|
|
95745
96012
|
for (const key3 of section.keys)
|
|
95746
96013
|
patch[key3] = key3 === "profiles" && merged.profiles !== void 0 ? reconciled : merged[key3];
|
|
95747
|
-
for (const
|
|
95748
|
-
const head =
|
|
96014
|
+
for (const path67 of section.nested ?? []) {
|
|
96015
|
+
const head = path67.split(".")[0];
|
|
95749
96016
|
patch[head] = merged[head];
|
|
95750
96017
|
}
|
|
95751
96018
|
}
|
|
@@ -95789,7 +96056,7 @@ ${last}` : ""}`);
|
|
|
95789
96056
|
if (changeLedger !== void 0) {
|
|
95790
96057
|
const shared = await changeLedger.othersSince(targets, taskCheckpoint.createdAt);
|
|
95791
96058
|
if (shared.size > 0) {
|
|
95792
|
-
const shown2 = (file2) =>
|
|
96059
|
+
const shown2 = (file2) => import_node_path56.default.relative(workspaceRoot ?? "", file2).split(import_node_path56.default.sep).join("/");
|
|
95793
96060
|
const detail = [...shared].map(([file2, chats]) => `${shown2(file2)} (${chats.join(", ")})`).join("; ");
|
|
95794
96061
|
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
96062
|
if (!all) {
|
|
@@ -95827,9 +96094,15 @@ ${last}` : ""}`);
|
|
|
95827
96094
|
recordExchange({ at: Date.now(), role: agent.role, question: request2.question.slice(0, 4e3), answer: "", refused: planned.refuse });
|
|
95828
96095
|
throw new Error(planned.refuse);
|
|
95829
96096
|
}
|
|
95830
|
-
|
|
96097
|
+
let stepNotes = planned.addToPrompt;
|
|
96098
|
+
if (stepNotes.includes("@") && workspaceRoot !== void 0) {
|
|
96099
|
+
const mentioned = await resolveMentions(stepNotes, { fs: new NodeFileSystem(), workspaceRoot, denylist, siblings: mentionCodebases() }).catch(() => []);
|
|
96100
|
+
if (mentioned.length > 0)
|
|
96101
|
+
stepNotes = attachMentions(stepNotes, mentioned);
|
|
96102
|
+
}
|
|
96103
|
+
const question = stepNotes.length > 0 ? `${request2.question}
|
|
95831
96104
|
|
|
95832
|
-
${
|
|
96105
|
+
${stepNotes}` : request2.question;
|
|
95833
96106
|
strategyRunning.add(agent.role);
|
|
95834
96107
|
strategyLastRole = agent.role;
|
|
95835
96108
|
void postStrategies();
|
|
@@ -96073,7 +96346,7 @@ ${notes.join("\n")}` } : answer;
|
|
|
96073
96346
|
const pathRequest = pendingPathApprovals.get(id);
|
|
96074
96347
|
userGate.resolve(id, "approve");
|
|
96075
96348
|
if (pathRequest !== void 0) {
|
|
96076
|
-
const folder =
|
|
96349
|
+
const folder = import_node_path56.default.dirname(pathRequest);
|
|
96077
96350
|
sessionPathGrants.add(normalizeForComparison(pathRequest));
|
|
96078
96351
|
if (scope === "folder" && !cachedReadRoots.includes(folder)) {
|
|
96079
96352
|
const { config: config2 } = await configManager.load();
|
|
@@ -96313,10 +96586,10 @@ ${notes.join("\n")}` } : answer;
|
|
|
96313
96586
|
});
|
|
96314
96587
|
return;
|
|
96315
96588
|
}
|
|
96316
|
-
let dir =
|
|
96589
|
+
let dir = import_node_path56.default.dirname(import_node_path56.default.resolve(scriptPath));
|
|
96317
96590
|
for (let depth = 0; depth < 3; depth++) {
|
|
96318
96591
|
for (const name of VENV_DIR_NAMES) {
|
|
96319
|
-
const candidate =
|
|
96592
|
+
const candidate = import_node_path56.default.join(dir, name);
|
|
96320
96593
|
const found2 = await search(candidate);
|
|
96321
96594
|
if (found2 !== void 0) {
|
|
96322
96595
|
post({
|
|
@@ -96328,7 +96601,7 @@ ${notes.join("\n")}` } : answer;
|
|
|
96328
96601
|
return;
|
|
96329
96602
|
}
|
|
96330
96603
|
}
|
|
96331
|
-
const parent =
|
|
96604
|
+
const parent = import_node_path56.default.dirname(dir);
|
|
96332
96605
|
if (parent === dir)
|
|
96333
96606
|
break;
|
|
96334
96607
|
dir = parent;
|
|
@@ -97140,7 +97413,7 @@ ${notes.join("\n")}` } : answer;
|
|
|
97140
97413
|
try {
|
|
97141
97414
|
const { config: config2 } = await configManager.load();
|
|
97142
97415
|
await syncMcpFromConfig(config2);
|
|
97143
|
-
await mcp.
|
|
97416
|
+
await mcp.ensureReady();
|
|
97144
97417
|
mcpStartProblem = void 0;
|
|
97145
97418
|
} catch (error51) {
|
|
97146
97419
|
logger.warn(`Could not start MCP servers: ${describeFailure2(error51, true)}`);
|
|
@@ -97151,14 +97424,27 @@ ${notes.join("\n")}` } : answer;
|
|
|
97151
97424
|
void (async () => {
|
|
97152
97425
|
try {
|
|
97153
97426
|
const config2 = await loadSettings();
|
|
97154
|
-
const
|
|
97427
|
+
const startedAt = Date.now();
|
|
97428
|
+
const timed = (label, work) => work.finally(() => {
|
|
97429
|
+
const seconds = (Date.now() - startedAt) / 1e3;
|
|
97430
|
+
if (seconds >= 2)
|
|
97431
|
+
logger.info(`[startup] ${label} ready after ${seconds.toFixed(1)}s`);
|
|
97432
|
+
});
|
|
97433
|
+
const parts = [
|
|
97434
|
+
timed("secrets", knownSecretValues()),
|
|
97435
|
+
timed("skills", refreshSkills()),
|
|
97436
|
+
timed("Python tools", configurePython(config2)),
|
|
97437
|
+
timed("git check", gitAvailable()),
|
|
97438
|
+
timed("expert", resolveExpert(config2)),
|
|
97439
|
+
timed("MCP tools", mcpStarted)
|
|
97440
|
+
];
|
|
97155
97441
|
if ((config2.profiles ?? []).length > 0) {
|
|
97156
97442
|
const profile = resolveActiveProfile(config2);
|
|
97157
|
-
parts.push((async () => {
|
|
97443
|
+
parts.push(timed("model gateway (sign-in and context window)", (async () => {
|
|
97158
97444
|
if (profile.wireFormat !== "vscode-lm")
|
|
97159
97445
|
await authStrategyFor(config2, profile).resolveHeaders();
|
|
97160
97446
|
await reportedWindowFor(config2, profile);
|
|
97161
|
-
})());
|
|
97447
|
+
})()));
|
|
97162
97448
|
}
|
|
97163
97449
|
const results = await Promise.allSettled(parts);
|
|
97164
97450
|
for (const result of results) {
|
|
@@ -97261,11 +97547,11 @@ ${entry.content}`);
|
|
|
97261
97547
|
let lastReportPath;
|
|
97262
97548
|
async function saveReport(title, contents) {
|
|
97263
97549
|
try {
|
|
97264
|
-
const directory =
|
|
97550
|
+
const directory = import_node_path56.default.join(storageDir, "reports");
|
|
97265
97551
|
await import_promises31.default.mkdir(directory, { recursive: true });
|
|
97266
97552
|
const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
97267
97553
|
const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
97268
|
-
const target =
|
|
97554
|
+
const target = import_node_path56.default.join(directory, `${stamp2}${slug.length > 0 ? `-${slug}` : ""}.md`);
|
|
97269
97555
|
await import_promises31.default.writeFile(target, `# ${title}
|
|
97270
97556
|
|
|
97271
97557
|
${contents}
|
|
@@ -97281,7 +97567,7 @@ ${contents}
|
|
|
97281
97567
|
const keep = 100;
|
|
97282
97568
|
const entries = (await import_promises31.default.readdir(directory)).filter((name) => name.endsWith(".md")).sort();
|
|
97283
97569
|
for (const name of entries.slice(0, Math.max(0, entries.length - keep))) {
|
|
97284
|
-
await import_promises31.default.rm(
|
|
97570
|
+
await import_promises31.default.rm(import_node_path56.default.join(directory, name), { force: true });
|
|
97285
97571
|
}
|
|
97286
97572
|
}
|
|
97287
97573
|
let scheduleTimer;
|
|
@@ -97394,10 +97680,10 @@ ${contents}
|
|
|
97394
97680
|
}
|
|
97395
97681
|
const CLAIM_STALE_MS = 60 * 60 * 1e3;
|
|
97396
97682
|
async function claimSchedule(id) {
|
|
97397
|
-
const claimPath =
|
|
97683
|
+
const claimPath = import_node_path56.default.join(storageDir, "schedule-claims", `${id}.json`);
|
|
97398
97684
|
const mine = JSON.stringify({ pid: process.pid, at: Date.now() });
|
|
97399
97685
|
try {
|
|
97400
|
-
await import_promises31.default.mkdir(
|
|
97686
|
+
await import_promises31.default.mkdir(import_node_path56.default.dirname(claimPath), { recursive: true });
|
|
97401
97687
|
await import_promises31.default.writeFile(claimPath, mine, { encoding: "utf8", flag: "wx" });
|
|
97402
97688
|
return true;
|
|
97403
97689
|
} catch (error51) {
|
|
@@ -97422,7 +97708,7 @@ ${contents}
|
|
|
97422
97708
|
}
|
|
97423
97709
|
}
|
|
97424
97710
|
async function releaseSchedule(id) {
|
|
97425
|
-
await import_promises31.default.rm(
|
|
97711
|
+
await import_promises31.default.rm(import_node_path56.default.join(storageDir, "schedule-claims", `${id}.json`), { force: true }).catch(() => void 0);
|
|
97426
97712
|
}
|
|
97427
97713
|
async function runSchedule(id, reason) {
|
|
97428
97714
|
if (reason === "due" && !await claimSchedule(id))
|
|
@@ -98117,11 +98403,11 @@ function createShowDiagramTool() {
|
|
|
98117
98403
|
|
|
98118
98404
|
// ../../packages/core/dist/lsp/manager.js
|
|
98119
98405
|
var import_promises32 = __toESM(require("node:fs/promises"), 1);
|
|
98120
|
-
var
|
|
98406
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
98121
98407
|
|
|
98122
98408
|
// ../../packages/core/dist/lsp/catalog.js
|
|
98123
|
-
var
|
|
98124
|
-
var
|
|
98409
|
+
var import_node_fs15 = require("node:fs");
|
|
98410
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
98125
98411
|
var c = (command, ...args) => ({ command, args });
|
|
98126
98412
|
var LSP_LANGUAGES = [
|
|
98127
98413
|
{ id: "python", label: "Python", extensions: ["py", "pyi"], candidates: [c("pyright-langserver", "--stdio"), c("basedpyright-langserver", "--stdio"), c("pylsp"), c("jedi-language-server")] },
|
|
@@ -98169,17 +98455,17 @@ var LSP_LANGUAGES = [
|
|
|
98169
98455
|
{ id: "sql", label: "SQL", extensions: ["sql"], candidates: [c("sql-language-server", "up", "--method", "stdio")] }
|
|
98170
98456
|
];
|
|
98171
98457
|
function languageFor(file2) {
|
|
98172
|
-
const ext =
|
|
98458
|
+
const ext = import_node_path57.default.extname(file2).slice(1).toLowerCase();
|
|
98173
98459
|
return LSP_LANGUAGES.find((l) => l.extensions.includes(ext));
|
|
98174
98460
|
}
|
|
98175
98461
|
function languageIdFor(language, file2) {
|
|
98176
|
-
const ext =
|
|
98462
|
+
const ext = import_node_path57.default.extname(file2).slice(1).toLowerCase();
|
|
98177
98463
|
return language.languageIdFor?.(ext) ?? language.id;
|
|
98178
98464
|
}
|
|
98179
98465
|
var found = /* @__PURE__ */ new Map();
|
|
98180
98466
|
function findOnPath(command, env2 = process.env) {
|
|
98181
|
-
if (
|
|
98182
|
-
return (0,
|
|
98467
|
+
if (import_node_path57.default.isAbsolute(command))
|
|
98468
|
+
return (0, import_node_fs15.existsSync)(command) ? command : void 0;
|
|
98183
98469
|
if (env2 !== process.env)
|
|
98184
98470
|
return searchPath(command, env2);
|
|
98185
98471
|
const hit = found.get(command);
|
|
@@ -98190,12 +98476,12 @@ function findOnPath(command, env2 = process.env) {
|
|
|
98190
98476
|
return value;
|
|
98191
98477
|
}
|
|
98192
98478
|
function searchPath(command, env2) {
|
|
98193
|
-
const dirs = (env2.PATH ?? env2.Path ?? "").split(
|
|
98479
|
+
const dirs = (env2.PATH ?? env2.Path ?? "").split(import_node_path57.default.delimiter).filter((d) => d.length > 0);
|
|
98194
98480
|
const exts = process.platform === "win32" ? ["", ...(env2.PATHEXT ?? ".EXE;.CMD;.BAT").toLowerCase().split(";")] : [""];
|
|
98195
98481
|
for (const dir of dirs) {
|
|
98196
98482
|
for (const ext of exts) {
|
|
98197
|
-
const candidate =
|
|
98198
|
-
if ((0,
|
|
98483
|
+
const candidate = import_node_path57.default.join(dir, command + ext);
|
|
98484
|
+
if ((0, import_node_fs15.existsSync)(candidate) && (process.platform !== "win32" || ext !== "" || /\.(exe|cmd|bat)$/i.test(candidate)))
|
|
98199
98485
|
return candidate;
|
|
98200
98486
|
}
|
|
98201
98487
|
}
|
|
@@ -98427,7 +98713,7 @@ var LspManager = class {
|
|
|
98427
98713
|
return void 0;
|
|
98428
98714
|
const args = [...found2.candidate.args];
|
|
98429
98715
|
if (language.id === "java" && !args.includes("-data"))
|
|
98430
|
-
args.push("-data",
|
|
98716
|
+
args.push("-data", import_node_path58.default.join(this.storageDir, "jdtls-workspace"));
|
|
98431
98717
|
try {
|
|
98432
98718
|
client = new LspClient(found2.executable, args, this.root, this.log);
|
|
98433
98719
|
this.clients.set(language.id, client);
|
|
@@ -98448,7 +98734,7 @@ var LspManager = class {
|
|
|
98448
98734
|
this.failed.set(language.id, client.lastError ?? "stopped");
|
|
98449
98735
|
return void 0;
|
|
98450
98736
|
}
|
|
98451
|
-
return { server:
|
|
98737
|
+
return { server: import_node_path58.default.basename(client.executable).replace(/\.(exe|cmd|bat)$/i, ""), diagnostics: diagnostics ?? [] };
|
|
98452
98738
|
} catch (error51) {
|
|
98453
98739
|
this.failed.set(language.id, error51 instanceof Error ? error51.message : String(error51));
|
|
98454
98740
|
client.dispose();
|
|
@@ -101089,7 +101375,8 @@ reported for these codebases. Commands run with execute_command run on this comp
|
|
|
101089
101375
|
|
|
101090
101376
|
**Git runs on the hub too**: the repository, its remote and its credentials are there, not in the
|
|
101091
101377
|
copy. Fire Code's sidebar counts and its Commit and push / Pull buttons work for a hub codebase while
|
|
101092
|
-
|
|
101378
|
+
any chat of it can run - whichever chat is loaded answers, an unloaded chat page is loaded again, and a
|
|
101379
|
+
sleeping codebase is woken for a Commit or Pull - local edits are saved to the hub first, then git commits and pushes there
|
|
101093
101380
|
(fast-forward-only pulls, fetched here afterwards); "Write with agent" describes the hub's diff. The
|
|
101094
101381
|
agent runs any other git command with \`hub_run\` shell, approved like any command.
|
|
101095
101382
|
**Outside the added folders**: \`hub_browse\` lists folders, finds files by name and reads text files
|
|
@@ -101702,6 +101989,14 @@ the idle time set there. The chats of one codebase **share** its checkpoint stor
|
|
|
101702
101989
|
and its index bookkeeping, so a new chat no longer adds another copy of the codebase's snapshots.
|
|
101703
101990
|
WebView2's cache is capped at 32 MB.
|
|
101704
101991
|
|
|
101992
|
+
**Starting a chat quickly.** MCP servers are processes of each chat's own agent, so they cannot be shared
|
|
101993
|
+
between chats - but what they offer can. Every chat of a codebase remembers each server's tool list in
|
|
101994
|
+
one shared file, so a chat started after a crash or a sleep offers those tools at once and replies
|
|
101995
|
+
without waiting for the servers; a server keeps starting in the background, and a call to one of its
|
|
101996
|
+
tools waits for it. A server with no remembered list is waited for at most 45 seconds, after which the
|
|
101997
|
+
reply goes ahead and its tools join the next message. When starting is still slow, the agent log
|
|
101998
|
+
(\`host.log\`) names each slow part with a \`[startup]\` line - the server, Python, skills or the gateway.
|
|
101999
|
+
|
|
101705
102000
|
**Not in Fire Code**: editor file pickers \u2014 paths are typed. Fire Code's
|
|
101706
102001
|
Settings \u2192 Export source code saves the whole repository as a zip that builds offline.
|
|
101707
102002
|
`
|
|
@@ -101988,6 +102283,13 @@ morning, by which time a toast is long gone. The run log keeps a Report button.
|
|
|
101988
102283
|
"parallel",
|
|
101989
102284
|
"parallel box",
|
|
101990
102285
|
"contract",
|
|
102286
|
+
"connect a box",
|
|
102287
|
+
"box to an agent",
|
|
102288
|
+
"group of agents",
|
|
102289
|
+
"box of agents",
|
|
102290
|
+
"when they all complete",
|
|
102291
|
+
"instructions for each agent",
|
|
102292
|
+
"reference files in instructions",
|
|
101991
102293
|
"read-only role",
|
|
101992
102294
|
"instructions for a role",
|
|
101993
102295
|
"what passed between",
|
|
@@ -102047,12 +102349,25 @@ refuses a round past the maximum - the agent then stops and tells you what is st
|
|
|
102047
102349
|
|
|
102048
102350
|
**A parallel box.** Press **Add a parallel box** on the left and drop steps into it: they are consulted at the same
|
|
102049
102351
|
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
|
-
|
|
102352
|
+
ask_agents call). Drag the box to move it with its steps, its corner to resize it. One role belongs in a parallel box
|
|
102353
|
+
once. If several of them need your approval at once, the prompts come one at a time.
|
|
102354
|
+
|
|
102355
|
+
**A box (a group of steps).** Press **Add a box** for steps done as a group, one after another - in the order of the
|
|
102356
|
+
connectors between them, else as drawn. A box of either kind can be switched on the right ("Run at the same time" or
|
|
102357
|
+
"Run as a group").
|
|
102358
|
+
|
|
102359
|
+
**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
|
|
102360
|
+
**Connect to...** when it is selected, to a step or to another box - and connect a step or a box into it. A connector
|
|
102361
|
+
out of a box is followed only once every step inside has answered; a connector into a box gives every step inside what
|
|
102362
|
+
arrives along it. A back-and-forth joins two steps, never a box, and a box is not connected to a step inside it -
|
|
102363
|
+
connect the steps inside to each other instead. A contract on a connector out of a box is told to every step inside;
|
|
102364
|
+
its required items are part of that contract rather than checked, since no single answer holds all of them.
|
|
102365
|
+
|
|
102366
|
+
**Each step:** the \u270E on a step opens **Instructions for this specialist** - what is expected of it in this strategy -
|
|
102367
|
+
sent to it with every question it is asked under this strategy. Type **@** in it to name a workspace file or folder,
|
|
102368
|
+
as in the message box: its contents are attached each time the specialist is asked, with the same confinement and
|
|
102369
|
+
deny list as @ in the chat. Leave it empty and the main agent decides what to ask it, from its plan. **Read-only** means
|
|
102370
|
+
it cannot change anything: it gets no tool that edits or runs commands, and recommends instead.
|
|
102056
102371
|
|
|
102057
102372
|
**A contract on a connector** ("What passes along here"): what one step hands to the next, such as "the failing
|
|
102058
102373
|
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 +103364,7 @@ function createLightCodeHelpTool() {
|
|
|
103049
103364
|
|
|
103050
103365
|
// ../../packages/core/dist/tools/listFiles.js
|
|
103051
103366
|
var import_node_child_process21 = require("node:child_process");
|
|
103052
|
-
var
|
|
103367
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
103053
103368
|
|
|
103054
103369
|
// ../../packages/core/dist/tools/ripgrepError.js
|
|
103055
103370
|
function ripgrepDidNotStart(error51) {
|
|
@@ -103130,7 +103445,7 @@ var listFilesTool = {
|
|
|
103130
103445
|
});
|
|
103131
103446
|
if (files.length === 0)
|
|
103132
103447
|
return noFiles;
|
|
103133
|
-
const listed = files.map((file2) => file2.split("/").join(
|
|
103448
|
+
const listed = files.map((file2) => file2.split("/").join(import_node_path59.default.sep)).join("\n");
|
|
103134
103449
|
return { content: truncated ? `${listed}
|
|
103135
103450
|
(listing cut short \u2014 list a narrower folder)` : listed };
|
|
103136
103451
|
}
|
|
@@ -103198,10 +103513,10 @@ function readSmall(raw, params3) {
|
|
|
103198
103513
|
const end = params3.limit !== void 0 ? start + params3.limit : lines2.length;
|
|
103199
103514
|
return number4(lines2.slice(start, end), start + 1);
|
|
103200
103515
|
}
|
|
103201
|
-
async function readLarge(
|
|
103516
|
+
async function readLarge(fs47, realPath, params3, size) {
|
|
103202
103517
|
const human = formatBytes(size);
|
|
103203
103518
|
if (params3.tail !== void 0) {
|
|
103204
|
-
const part = await readTail(
|
|
103519
|
+
const part = await readTail(fs47, realPath, size, params3.tail);
|
|
103205
103520
|
return [
|
|
103206
103521
|
`${human} file \u2014 last ${String(part.lines.length)} lines.`,
|
|
103207
103522
|
/*
|
|
@@ -103216,7 +103531,7 @@ async function readLarge(fs46, realPath, params3, size) {
|
|
|
103216
103531
|
}
|
|
103217
103532
|
if (params3.offset !== void 0) {
|
|
103218
103533
|
const limit = params3.limit ?? DEFAULT_LARGE_LIMIT;
|
|
103219
|
-
const part = await readLineWindow(
|
|
103534
|
+
const part = await readLineWindow(fs47, realPath, size, params3.offset, limit);
|
|
103220
103535
|
const shown2 = part.lines.length;
|
|
103221
103536
|
return [
|
|
103222
103537
|
`${human} file \u2014 lines ${String(params3.offset)}\u2013${String(params3.offset + shown2 - 1)}${part.hasMoreAfter ? ", more follows" : " (end of file)"}.`,
|
|
@@ -103224,7 +103539,7 @@ async function readLarge(fs46, realPath, params3, size) {
|
|
|
103224
103539
|
number4(part.lines, params3.offset)
|
|
103225
103540
|
].join("\n");
|
|
103226
103541
|
}
|
|
103227
|
-
const total = await countLines(
|
|
103542
|
+
const total = await countLines(fs47, realPath, size);
|
|
103228
103543
|
return [
|
|
103229
103544
|
`${realPathName(realPath)} is ${human} (${total.toLocaleString()} lines) \u2014 too large to read at once.`,
|
|
103230
103545
|
"",
|
|
@@ -103359,7 +103674,7 @@ var searchFilesTool = {
|
|
|
103359
103674
|
};
|
|
103360
103675
|
|
|
103361
103676
|
// ../../packages/core/dist/tools/writeToFile.js
|
|
103362
|
-
var
|
|
103677
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
103363
103678
|
var paramsSchema23 = external_exports.object({
|
|
103364
103679
|
path: external_exports.string().min(1).describe("Path to the file, relative to the workspace root."),
|
|
103365
103680
|
content: external_exports.string().describe("Full file content to write.")
|
|
@@ -103387,7 +103702,7 @@ var writeToFileTool = {
|
|
|
103387
103702
|
return { content: changed, isError: true, path: params3.path };
|
|
103388
103703
|
}
|
|
103389
103704
|
if (!exists2) {
|
|
103390
|
-
await context.fs.mkdir(
|
|
103705
|
+
await context.fs.mkdir(import_node_path60.default.dirname(resolved.realPath));
|
|
103391
103706
|
}
|
|
103392
103707
|
await context.fs.writeFile(resolved.realPath, params3.content);
|
|
103393
103708
|
await recordWrite(context, resolved.realPath);
|
|
@@ -103489,14 +103804,14 @@ function createDefaultToolRegistry() {
|
|
|
103489
103804
|
|
|
103490
103805
|
// ../../packages/core/dist/dataset/store.js
|
|
103491
103806
|
var import_promises33 = __toESM(require("node:fs/promises"), 1);
|
|
103492
|
-
var
|
|
103807
|
+
var import_node_path61 = __toESM(require("node:path"), 1);
|
|
103493
103808
|
var DatasetStore = class {
|
|
103494
103809
|
filePath;
|
|
103495
103810
|
statePath;
|
|
103496
103811
|
constructor(storageDir, datasetId) {
|
|
103497
103812
|
const safe = datasetId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
103498
|
-
this.filePath =
|
|
103499
|
-
this.statePath =
|
|
103813
|
+
this.filePath = import_node_path61.default.join(storageDir, "datasets", `${safe}.jsonl`);
|
|
103814
|
+
this.statePath = import_node_path61.default.join(storageDir, "datasets", `${safe}.state.json`);
|
|
103500
103815
|
}
|
|
103501
103816
|
/** Every record. A malformed line is skipped — one bad line costs one record, not the corpus. */
|
|
103502
103817
|
async load() {
|
|
@@ -103524,7 +103839,7 @@ var DatasetStore = class {
|
|
|
103524
103839
|
async append(records) {
|
|
103525
103840
|
if (records.length === 0)
|
|
103526
103841
|
return;
|
|
103527
|
-
await import_promises33.default.mkdir(
|
|
103842
|
+
await import_promises33.default.mkdir(import_node_path61.default.dirname(this.filePath), { recursive: true });
|
|
103528
103843
|
await import_promises33.default.writeFile(this.filePath, "", { flag: "a" });
|
|
103529
103844
|
const lines2 = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
103530
103845
|
await import_promises33.default.appendFile(this.filePath, `${lines2}
|
|
@@ -103532,7 +103847,7 @@ var DatasetStore = class {
|
|
|
103532
103847
|
}
|
|
103533
103848
|
/** Rewrites with exactly these. Temp-and-rename, so an interrupted prune leaves the old file. */
|
|
103534
103849
|
async replace(records) {
|
|
103535
|
-
await import_promises33.default.mkdir(
|
|
103850
|
+
await import_promises33.default.mkdir(import_node_path61.default.dirname(this.filePath), { recursive: true });
|
|
103536
103851
|
const temporary = `${this.filePath}.tmp`;
|
|
103537
103852
|
const body = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
103538
103853
|
await import_promises33.default.writeFile(temporary, records.length === 0 ? "" : `${body}
|
|
@@ -103586,7 +103901,7 @@ var DatasetStore = class {
|
|
|
103586
103901
|
}
|
|
103587
103902
|
}
|
|
103588
103903
|
async recordSync(at) {
|
|
103589
|
-
await import_promises33.default.mkdir(
|
|
103904
|
+
await import_promises33.default.mkdir(import_node_path61.default.dirname(this.statePath), { recursive: true });
|
|
103590
103905
|
const temporary = `${this.statePath}.tmp`;
|
|
103591
103906
|
await import_promises33.default.writeFile(temporary, JSON.stringify({ lastSyncedAt: at }), "utf8");
|
|
103592
103907
|
await replaceFile(temporary, this.statePath);
|
|
@@ -104018,8 +104333,8 @@ var S3Client = class {
|
|
|
104018
104333
|
const host = inPath ? origin.host : `${bucket}.${origin.host}`;
|
|
104019
104334
|
const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
|
|
104020
104335
|
const prefix = inPath ? `${mount}/${bucket}` : mount;
|
|
104021
|
-
const
|
|
104022
|
-
const url2 = new URL(`${origin.protocol}//${host}${prefix}${
|
|
104336
|
+
const path67 = key3 === "" ? "" : `/${key3.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
|
|
104337
|
+
const url2 = new URL(`${origin.protocol}//${host}${prefix}${path67}`);
|
|
104023
104338
|
for (const [name, value] of Object.entries(call.query ?? {}))
|
|
104024
104339
|
url2.searchParams.set(name, value);
|
|
104025
104340
|
return url2.toString();
|
|
@@ -104286,9 +104601,9 @@ async function syncFromS3(options) {
|
|
|
104286
104601
|
return result;
|
|
104287
104602
|
}
|
|
104288
104603
|
var MANIFEST_NAME = ".lightcode-sync.json";
|
|
104289
|
-
async function readManifest(
|
|
104604
|
+
async function readManifest(fs47, manifestPath) {
|
|
104290
104605
|
try {
|
|
104291
|
-
const parsed = JSON.parse((await
|
|
104606
|
+
const parsed = JSON.parse((await fs47.readBytes(manifestPath)).toString("utf8"));
|
|
104292
104607
|
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
104293
104608
|
} catch {
|
|
104294
104609
|
return {};
|
|
@@ -104306,14 +104621,14 @@ function join2(dir, relative) {
|
|
|
104306
104621
|
const left = dir.replace(/[\\/]+$/, "");
|
|
104307
104622
|
return `${left}/${relative}`;
|
|
104308
104623
|
}
|
|
104309
|
-
async function writeWhole3(
|
|
104310
|
-
if (
|
|
104311
|
-
await
|
|
104624
|
+
async function writeWhole3(fs47, target, bytes) {
|
|
104625
|
+
if (fs47.rename === void 0) {
|
|
104626
|
+
await fs47.writeBytes(target, bytes);
|
|
104312
104627
|
return;
|
|
104313
104628
|
}
|
|
104314
104629
|
const temporary = `${target}.${String(process.pid)}.${String(Date.now())}.part`;
|
|
104315
|
-
await
|
|
104316
|
-
await
|
|
104630
|
+
await fs47.writeBytes(temporary, bytes);
|
|
104631
|
+
await fs47.rename(temporary, target);
|
|
104317
104632
|
}
|
|
104318
104633
|
function dirname(filePath) {
|
|
104319
104634
|
const cut = filePath.lastIndexOf("/");
|
|
@@ -104997,7 +105312,7 @@ async function readJsonBody(request2, maxBytes = 32 * 1024 * 1024) {
|
|
|
104997
105312
|
|
|
104998
105313
|
// src/fileSecretStore.ts
|
|
104999
105314
|
var import_promises34 = __toESM(require("node:fs/promises"), 1);
|
|
105000
|
-
var
|
|
105315
|
+
var import_node_path62 = __toESM(require("node:path"), 1);
|
|
105001
105316
|
|
|
105002
105317
|
// src/vaultCrypto.ts
|
|
105003
105318
|
var import_node_crypto24 = require("node:crypto");
|
|
@@ -105095,7 +105410,7 @@ var FileSecretStore = class {
|
|
|
105095
105410
|
);
|
|
105096
105411
|
}
|
|
105097
105412
|
mutate(secrets);
|
|
105098
|
-
await import_promises34.default.mkdir(
|
|
105413
|
+
await import_promises34.default.mkdir(import_node_path62.default.dirname(this.filePath), { recursive: true });
|
|
105099
105414
|
const temp = `${this.filePath}.${process.pid}.tmp`;
|
|
105100
105415
|
const body = this.key === void 0 ? secrets : sealSecrets(secrets, this.key);
|
|
105101
105416
|
await import_promises34.default.writeFile(temp, JSON.stringify(body, null, 2), { encoding: "utf8", mode: 384 });
|
|
@@ -105132,7 +105447,7 @@ var FileSecretStore = class {
|
|
|
105132
105447
|
// src/reviewQueue.ts
|
|
105133
105448
|
var import_node_crypto25 = __toESM(require("node:crypto"), 1);
|
|
105134
105449
|
var import_promises35 = __toESM(require("node:fs/promises"), 1);
|
|
105135
|
-
var
|
|
105450
|
+
var import_node_path63 = __toESM(require("node:path"), 1);
|
|
105136
105451
|
var ReviewQueue = class {
|
|
105137
105452
|
constructor(filePath) {
|
|
105138
105453
|
this.filePath = filePath;
|
|
@@ -105151,7 +105466,7 @@ var ReviewQueue = class {
|
|
|
105151
105466
|
}
|
|
105152
105467
|
async persist(items) {
|
|
105153
105468
|
this.cache = items;
|
|
105154
|
-
await import_promises35.default.mkdir(
|
|
105469
|
+
await import_promises35.default.mkdir(import_node_path63.default.dirname(this.filePath), { recursive: true });
|
|
105155
105470
|
const temporary = `${this.filePath}.tmp`;
|
|
105156
105471
|
await import_promises35.default.writeFile(temporary, JSON.stringify(items, null, 2), { encoding: "utf8", mode: 384 });
|
|
105157
105472
|
await replaceFile(temporary, this.filePath);
|
|
@@ -105392,8 +105707,8 @@ var RoutedSecretStore = class {
|
|
|
105392
105707
|
|
|
105393
105708
|
// src/userVariables.ts
|
|
105394
105709
|
var import_promises36 = __toESM(require("node:fs/promises"), 1);
|
|
105395
|
-
var
|
|
105396
|
-
var
|
|
105710
|
+
var import_node_fs16 = require("node:fs");
|
|
105711
|
+
var import_node_path64 = __toESM(require("node:path"), 1);
|
|
105397
105712
|
var UserVariableStore = class {
|
|
105398
105713
|
constructor(filePath) {
|
|
105399
105714
|
this.filePath = filePath;
|
|
@@ -105408,7 +105723,7 @@ var UserVariableStore = class {
|
|
|
105408
105723
|
}
|
|
105409
105724
|
async save(variables) {
|
|
105410
105725
|
const parsed = sessionVariablesSchema.parse(variables);
|
|
105411
|
-
await import_promises36.default.mkdir(
|
|
105726
|
+
await import_promises36.default.mkdir(import_node_path64.default.dirname(this.filePath), { recursive: true });
|
|
105412
105727
|
const temporary = `${this.filePath}.tmp`;
|
|
105413
105728
|
await import_promises36.default.writeFile(temporary, JSON.stringify({ variables: parsed }, null, 2), {
|
|
105414
105729
|
encoding: "utf8",
|
|
@@ -105419,14 +105734,14 @@ var UserVariableStore = class {
|
|
|
105419
105734
|
}
|
|
105420
105735
|
};
|
|
105421
105736
|
function userVariableStoreFor(dataDir, principal) {
|
|
105422
|
-
return new UserVariableStore(userVariablesPath(
|
|
105737
|
+
return new UserVariableStore(userVariablesPath(import_node_path64.default.join(dataDir, "users", storageKeyFor(principal))));
|
|
105423
105738
|
}
|
|
105424
105739
|
function userVariablesPath(userDir) {
|
|
105425
|
-
return
|
|
105740
|
+
return import_node_path64.default.join(userDir, "variables.json");
|
|
105426
105741
|
}
|
|
105427
105742
|
function readVariablesFile(filePath) {
|
|
105428
105743
|
try {
|
|
105429
|
-
const raw = JSON.parse((0,
|
|
105744
|
+
const raw = JSON.parse((0, import_node_fs16.readFileSync)(filePath, "utf8"));
|
|
105430
105745
|
const parsed = sessionVariablesSchema.safeParse(raw["variables"]);
|
|
105431
105746
|
return parsed.success ? parsed.data : [];
|
|
105432
105747
|
} catch {
|
|
@@ -105450,13 +105765,13 @@ function hostedUser(env2 = process.env) {
|
|
|
105450
105765
|
}
|
|
105451
105766
|
|
|
105452
105767
|
// src/session.ts
|
|
105453
|
-
var
|
|
105768
|
+
var import_node_fs17 = require("node:fs");
|
|
105454
105769
|
var import_promises37 = __toESM(require("node:fs/promises"), 1);
|
|
105455
|
-
var
|
|
105770
|
+
var import_node_path66 = __toESM(require("node:path"), 1);
|
|
105456
105771
|
|
|
105457
105772
|
// src/credentialTool.ts
|
|
105458
105773
|
var import_node_child_process23 = require("node:child_process");
|
|
105459
|
-
var
|
|
105774
|
+
var import_node_path65 = __toESM(require("node:path"), 1);
|
|
105460
105775
|
var CREDENTIAL_PREFIX2 = "tool:";
|
|
105461
105776
|
var WRAPPER = [
|
|
105462
105777
|
"import importlib.util, json, sys",
|
|
@@ -105476,7 +105791,7 @@ async function fetchCredential(options, reference) {
|
|
|
105476
105791
|
if (name.length === 0) return { problem: "A credential reference needs a name: tool:<name>." };
|
|
105477
105792
|
const budget = options.timeoutMs ?? 3e4;
|
|
105478
105793
|
const run3 = await new Promise((resolve) => {
|
|
105479
|
-
const child = (0, import_node_child_process23.spawn)(options.interpreter, ["-c", WRAPPER,
|
|
105794
|
+
const child = (0, import_node_child_process23.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path65.default.resolve(options.file), name], {
|
|
105480
105795
|
windowsHide: true,
|
|
105481
105796
|
// The environment this was started in, as with the identity function: the libraries that
|
|
105482
105797
|
// hold credentials are configured through it, and nothing here is model-authored.
|
|
@@ -105672,7 +105987,7 @@ var FileConfigStore = class {
|
|
|
105672
105987
|
const filePath = this.pathFor(scope);
|
|
105673
105988
|
if (filePath === void 0)
|
|
105674
105989
|
throw new Error(`Cannot write ${scope} config: no workspace is open`);
|
|
105675
|
-
await import_promises37.default.mkdir(
|
|
105990
|
+
await import_promises37.default.mkdir(import_node_path66.default.dirname(filePath), { recursive: true });
|
|
105676
105991
|
const temporary = `${filePath}.${process.pid.toString(36)}.tmp`;
|
|
105677
105992
|
await import_promises37.default.writeFile(temporary, contents, { encoding: "utf8", mode: 384 });
|
|
105678
105993
|
await replaceFile(temporary, filePath);
|
|
@@ -105709,8 +106024,8 @@ var FileConfigStore = class {
|
|
|
105709
106024
|
};
|
|
105710
106025
|
let watcher;
|
|
105711
106026
|
try {
|
|
105712
|
-
watcher = (0,
|
|
105713
|
-
if (filename ===
|
|
106027
|
+
watcher = (0, import_node_fs17.watch)(import_node_path66.default.dirname(filePath), (_event, filename) => {
|
|
106028
|
+
if (filename === import_node_path66.default.basename(filePath)) onChange();
|
|
105714
106029
|
});
|
|
105715
106030
|
} catch {
|
|
105716
106031
|
}
|
|
@@ -105738,7 +106053,7 @@ var FileWorkspaceState = class {
|
|
|
105738
106053
|
async set(key3, value) {
|
|
105739
106054
|
if (value === void 0) delete this.values[key3];
|
|
105740
106055
|
else this.values[key3] = value;
|
|
105741
|
-
await import_promises37.default.mkdir(
|
|
106056
|
+
await import_promises37.default.mkdir(import_node_path66.default.dirname(this.filePath), { recursive: true });
|
|
105742
106057
|
await import_promises37.default.writeFile(this.filePath, JSON.stringify(this.values, null, 2), {
|
|
105743
106058
|
encoding: "utf8",
|
|
105744
106059
|
mode: 384
|
|
@@ -105788,7 +106103,7 @@ function createBrowserUi(workspaceRoot, post, fastFs, shared) {
|
|
|
105788
106103
|
openFile: async (filePath) => {
|
|
105789
106104
|
try {
|
|
105790
106105
|
post(
|
|
105791
|
-
[`[info] ${
|
|
106106
|
+
[`[info] ${import_node_path66.default.basename(filePath)}`, "", await import_promises37.default.readFile(filePath, "utf8")].join("\n")
|
|
105792
106107
|
);
|
|
105793
106108
|
} catch (error51) {
|
|
105794
106109
|
post(`[warning] Could not read ${filePath}: ${String(error51)}`);
|
|
@@ -105832,7 +106147,7 @@ function createBrowserUi(workspaceRoot, post, fastFs, shared) {
|
|
|
105832
106147
|
for (const entry of entries) {
|
|
105833
106148
|
if (found2.length >= limit) return;
|
|
105834
106149
|
if (entry.name.startsWith(".") && entry.name !== ".env") continue;
|
|
105835
|
-
const full =
|
|
106150
|
+
const full = import_node_path66.default.join(dir, entry.name);
|
|
105836
106151
|
if (entry.isDirectory()) {
|
|
105837
106152
|
if (skip.has(entry.name)) continue;
|
|
105838
106153
|
if (mode === "folders" && (needle.length === 0 || entry.name.toLowerCase().includes(needle))) found2.push(full);
|
|
@@ -105870,11 +106185,11 @@ var SHARED_COLLECTIONS = [
|
|
|
105870
106185
|
{ key: "mcpServers" }
|
|
105871
106186
|
];
|
|
105872
106187
|
async function createSession(options) {
|
|
105873
|
-
const userDir =
|
|
106188
|
+
const userDir = import_node_path66.default.join(options.dataDir, "users", storageKeyFor(options.principal));
|
|
105874
106189
|
await import_promises37.default.mkdir(userDir, { recursive: true, mode: 448 });
|
|
105875
106190
|
const variableStore = new UserVariableStore(userVariablesPath(userDir));
|
|
105876
106191
|
const userVariables = () => variableStore.read();
|
|
105877
|
-
const workspaceState = new FileWorkspaceState(
|
|
106192
|
+
const workspaceState = new FileWorkspaceState(import_node_path66.default.join(userDir, "workspace-state.json"));
|
|
105878
106193
|
await workspaceState.load();
|
|
105879
106194
|
const services = {
|
|
105880
106195
|
/*
|
|
@@ -105969,16 +106284,16 @@ async function createSession(options) {
|
|
|
105969
106284
|
*/
|
|
105970
106285
|
secrets: new CredentialPointerStore(
|
|
105971
106286
|
withCredentialTool(
|
|
105972
|
-
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ??
|
|
105973
|
-
new FileSecretStore(options.secretsFile ??
|
|
106287
|
+
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ?? import_node_path66.default.join(userDir, "secrets.json"), options.secretsKey) : new RoutedSecretStore(
|
|
106288
|
+
new FileSecretStore(options.secretsFile ?? import_node_path66.default.join(userDir, "secrets.json"), options.secretsKey),
|
|
105974
106289
|
options.sharedSecrets
|
|
105975
106290
|
),
|
|
105976
106291
|
options
|
|
105977
106292
|
)
|
|
105978
106293
|
),
|
|
105979
106294
|
configStore: withSharedEntries(
|
|
105980
|
-
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ??
|
|
105981
|
-
new FileConfigStore(options.configFile ??
|
|
106295
|
+
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ?? import_node_path66.default.join(userDir, "config.json"), options.workspaceRoot) : new SharedProfileConfigStore(
|
|
106296
|
+
new FileConfigStore(options.configFile ?? import_node_path66.default.join(userDir, "config.json"), options.workspaceRoot),
|
|
105982
106297
|
options.sharedProfiles
|
|
105983
106298
|
),
|
|
105984
106299
|
options
|
|
@@ -106096,8 +106411,8 @@ async function startServer(options) {
|
|
|
106096
106411
|
));
|
|
106097
106412
|
const roles = options.roles ?? SINGLE_USER_POLICY;
|
|
106098
106413
|
const sharedStore = options.sharedConfig;
|
|
106099
|
-
const sharedSecretStore = new FileSecretStore(
|
|
106100
|
-
const reviews = new ReviewQueue(
|
|
106414
|
+
const sharedSecretStore = new FileSecretStore(import_node_path67.default.join(options.dataDir, "shared-secrets.json"));
|
|
106415
|
+
const reviews = new ReviewQueue(import_node_path67.default.join(options.dataDir, "reviews.json"));
|
|
106101
106416
|
let sharedCache = {
|
|
106102
106417
|
variables: [],
|
|
106103
106418
|
adminIds: [],
|
|
@@ -106478,14 +106793,14 @@ async function startServer(options) {
|
|
|
106478
106793
|
return "No workspace is open, so there is nowhere to write it.";
|
|
106479
106794
|
try {
|
|
106480
106795
|
if (item2.kind === "skill") {
|
|
106481
|
-
const dir2 =
|
|
106796
|
+
const dir2 = import_node_path67.default.join(options.workspaceRoot, ".lightcode", "skills");
|
|
106482
106797
|
await import_promises38.default.mkdir(dir2, { recursive: true });
|
|
106483
|
-
await import_promises38.default.writeFile(
|
|
106798
|
+
await import_promises38.default.writeFile(import_node_path67.default.join(dir2, `${item2.name}.md`), item2.content, "utf8");
|
|
106484
106799
|
return void 0;
|
|
106485
106800
|
}
|
|
106486
|
-
const dir =
|
|
106801
|
+
const dir = import_node_path67.default.join(options.workspaceRoot, ".lightcode", "tools");
|
|
106487
106802
|
await import_promises38.default.mkdir(dir, { recursive: true });
|
|
106488
|
-
await import_promises38.default.writeFile(
|
|
106803
|
+
await import_promises38.default.writeFile(import_node_path67.default.join(dir, `${item2.name}.py`), item2.content, "utf8");
|
|
106489
106804
|
return void 0;
|
|
106490
106805
|
} catch (error51) {
|
|
106491
106806
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -106524,7 +106839,7 @@ async function startServer(options) {
|
|
|
106524
106839
|
connection.transport.post({ type: "credentials", credentials: await readCredentials() });
|
|
106525
106840
|
}
|
|
106526
106841
|
if (options.credentialsFile !== void 0) {
|
|
106527
|
-
(0,
|
|
106842
|
+
(0, import_node_fs18.watchFile)(options.credentialsFile, { interval: 1500 }, () => {
|
|
106528
106843
|
for (const connection of connections.values()) void postCredentials(connection);
|
|
106529
106844
|
});
|
|
106530
106845
|
}
|
|
@@ -106634,7 +106949,7 @@ async function startServer(options) {
|
|
|
106634
106949
|
return;
|
|
106635
106950
|
}
|
|
106636
106951
|
response.writeHead(200, {
|
|
106637
|
-
"Content-Type": CONTENT_TYPES2[
|
|
106952
|
+
"Content-Type": CONTENT_TYPES2[import_node_path67.default.extname(asset)] ?? "application/octet-stream",
|
|
106638
106953
|
...securityHeaders()
|
|
106639
106954
|
});
|
|
106640
106955
|
response.end(body);
|