@chosengeneration/light-code 0.188.0 → 0.190.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 +955 -651
- package/dist/server.cjs +916 -612
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -494,14 +494,14 @@ var require_util = __commonJS({
|
|
|
494
494
|
}
|
|
495
495
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
496
496
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol}//${url2.hostname}:${port}`;
|
|
497
|
-
let
|
|
497
|
+
let path68 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
498
498
|
if (origin.endsWith("/")) {
|
|
499
499
|
origin = origin.substring(0, origin.length - 1);
|
|
500
500
|
}
|
|
501
|
-
if (
|
|
502
|
-
|
|
501
|
+
if (path68 && !path68.startsWith("/")) {
|
|
502
|
+
path68 = `/${path68}`;
|
|
503
503
|
}
|
|
504
|
-
url2 = new URL(origin +
|
|
504
|
+
url2 = new URL(origin + path68);
|
|
505
505
|
}
|
|
506
506
|
return url2;
|
|
507
507
|
}
|
|
@@ -2115,20 +2115,20 @@ var require_parseParams = __commonJS({
|
|
|
2115
2115
|
var require_basename = __commonJS({
|
|
2116
2116
|
"../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/basename.js"(exports2, module2) {
|
|
2117
2117
|
"use strict";
|
|
2118
|
-
module2.exports = function basename(
|
|
2119
|
-
if (typeof
|
|
2118
|
+
module2.exports = function basename(path68) {
|
|
2119
|
+
if (typeof path68 !== "string") {
|
|
2120
2120
|
return "";
|
|
2121
2121
|
}
|
|
2122
|
-
for (var i =
|
|
2123
|
-
switch (
|
|
2122
|
+
for (var i = path68.length - 1; i >= 0; --i) {
|
|
2123
|
+
switch (path68.charCodeAt(i)) {
|
|
2124
2124
|
case 47:
|
|
2125
2125
|
// '/'
|
|
2126
2126
|
case 92:
|
|
2127
|
-
|
|
2128
|
-
return
|
|
2127
|
+
path68 = path68.slice(i + 1);
|
|
2128
|
+
return path68 === ".." || path68 === "." ? "" : path68;
|
|
2129
2129
|
}
|
|
2130
2130
|
}
|
|
2131
|
-
return
|
|
2131
|
+
return path68 === ".." || path68 === "." ? "" : path68;
|
|
2132
2132
|
};
|
|
2133
2133
|
}
|
|
2134
2134
|
});
|
|
@@ -5158,7 +5158,7 @@ var require_request = __commonJS({
|
|
|
5158
5158
|
}
|
|
5159
5159
|
var Request = class _Request {
|
|
5160
5160
|
constructor(origin, {
|
|
5161
|
-
path:
|
|
5161
|
+
path: path68,
|
|
5162
5162
|
method,
|
|
5163
5163
|
body,
|
|
5164
5164
|
headers,
|
|
@@ -5172,11 +5172,11 @@ var require_request = __commonJS({
|
|
|
5172
5172
|
throwOnError,
|
|
5173
5173
|
expectContinue
|
|
5174
5174
|
}, handler) {
|
|
5175
|
-
if (typeof
|
|
5175
|
+
if (typeof path68 !== "string") {
|
|
5176
5176
|
throw new InvalidArgumentError("path must be a string");
|
|
5177
|
-
} else if (
|
|
5177
|
+
} else if (path68[0] !== "/" && !(path68.startsWith("http://") || path68.startsWith("https://")) && method !== "CONNECT") {
|
|
5178
5178
|
throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
|
|
5179
|
-
} else if (invalidPathRegex.exec(
|
|
5179
|
+
} else if (invalidPathRegex.exec(path68) !== null) {
|
|
5180
5180
|
throw new InvalidArgumentError("invalid request path");
|
|
5181
5181
|
}
|
|
5182
5182
|
if (typeof method !== "string") {
|
|
@@ -5239,7 +5239,7 @@ var require_request = __commonJS({
|
|
|
5239
5239
|
this.completed = false;
|
|
5240
5240
|
this.aborted = false;
|
|
5241
5241
|
this.upgrade = upgrade || null;
|
|
5242
|
-
this.path = query ? util.buildURL(
|
|
5242
|
+
this.path = query ? util.buildURL(path68, query) : path68;
|
|
5243
5243
|
this.origin = origin;
|
|
5244
5244
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
5245
5245
|
this.blocking = blocking == null ? false : blocking;
|
|
@@ -6247,9 +6247,9 @@ var require_RedirectHandler = __commonJS({
|
|
|
6247
6247
|
return this.handler.onHeaders(statusCode, headers, resume, statusText);
|
|
6248
6248
|
}
|
|
6249
6249
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
6250
|
-
const
|
|
6250
|
+
const path68 = search ? `${pathname}${search}` : pathname;
|
|
6251
6251
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
6252
|
-
this.opts.path =
|
|
6252
|
+
this.opts.path = path68;
|
|
6253
6253
|
this.opts.origin = origin;
|
|
6254
6254
|
this.opts.maxRedirections = 0;
|
|
6255
6255
|
this.opts.query = null;
|
|
@@ -7489,7 +7489,7 @@ var require_client = __commonJS({
|
|
|
7489
7489
|
writeH2(client, client[kHTTP2Session], request2);
|
|
7490
7490
|
return;
|
|
7491
7491
|
}
|
|
7492
|
-
const { body, method, path:
|
|
7492
|
+
const { body, method, path: path68, host, upgrade, headers, blocking, reset } = request2;
|
|
7493
7493
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
7494
7494
|
if (body && typeof body.read === "function") {
|
|
7495
7495
|
body.read(0);
|
|
@@ -7539,7 +7539,7 @@ var require_client = __commonJS({
|
|
|
7539
7539
|
if (blocking) {
|
|
7540
7540
|
socket[kBlocking] = true;
|
|
7541
7541
|
}
|
|
7542
|
-
let header2 = `${method} ${
|
|
7542
|
+
let header2 = `${method} ${path68} HTTP/1.1\r
|
|
7543
7543
|
`;
|
|
7544
7544
|
if (typeof host === "string") {
|
|
7545
7545
|
header2 += `host: ${host}\r
|
|
@@ -7602,7 +7602,7 @@ upgrade: ${upgrade}\r
|
|
|
7602
7602
|
return true;
|
|
7603
7603
|
}
|
|
7604
7604
|
function writeH2(client, session, request2) {
|
|
7605
|
-
const { body, method, path:
|
|
7605
|
+
const { body, method, path: path68, host, upgrade, expectContinue, signal, headers: reqHeaders } = request2;
|
|
7606
7606
|
let headers;
|
|
7607
7607
|
if (typeof reqHeaders === "string") headers = Request[kHTTP2CopyHeaders](reqHeaders.trim());
|
|
7608
7608
|
else headers = reqHeaders;
|
|
@@ -7645,7 +7645,7 @@ upgrade: ${upgrade}\r
|
|
|
7645
7645
|
});
|
|
7646
7646
|
return true;
|
|
7647
7647
|
}
|
|
7648
|
-
headers[HTTP2_HEADER_PATH] =
|
|
7648
|
+
headers[HTTP2_HEADER_PATH] = path68;
|
|
7649
7649
|
headers[HTTP2_HEADER_SCHEME] = "https";
|
|
7650
7650
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
7651
7651
|
if (body && typeof body.read === "function") {
|
|
@@ -9885,20 +9885,20 @@ var require_mock_utils = __commonJS({
|
|
|
9885
9885
|
}
|
|
9886
9886
|
return true;
|
|
9887
9887
|
}
|
|
9888
|
-
function safeUrl(
|
|
9889
|
-
if (typeof
|
|
9890
|
-
return
|
|
9888
|
+
function safeUrl(path68) {
|
|
9889
|
+
if (typeof path68 !== "string") {
|
|
9890
|
+
return path68;
|
|
9891
9891
|
}
|
|
9892
|
-
const pathSegments =
|
|
9892
|
+
const pathSegments = path68.split("?");
|
|
9893
9893
|
if (pathSegments.length !== 2) {
|
|
9894
|
-
return
|
|
9894
|
+
return path68;
|
|
9895
9895
|
}
|
|
9896
9896
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
9897
9897
|
qp.sort();
|
|
9898
9898
|
return [...pathSegments, qp.toString()].join("?");
|
|
9899
9899
|
}
|
|
9900
|
-
function matchKey(mockDispatch2, { path:
|
|
9901
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
9900
|
+
function matchKey(mockDispatch2, { path: path68, method, body, headers }) {
|
|
9901
|
+
const pathMatch = matchValue(mockDispatch2.path, path68);
|
|
9902
9902
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
9903
9903
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
9904
9904
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -9916,7 +9916,7 @@ var require_mock_utils = __commonJS({
|
|
|
9916
9916
|
function getMockDispatch(mockDispatches, key3) {
|
|
9917
9917
|
const basePath = key3.query ? buildURL(key3.path, key3.query) : key3.path;
|
|
9918
9918
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
9919
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
9919
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path68 }) => matchValue(safeUrl(path68), resolvedPath));
|
|
9920
9920
|
if (matchedMockDispatches.length === 0) {
|
|
9921
9921
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
9922
9922
|
}
|
|
@@ -9953,9 +9953,9 @@ var require_mock_utils = __commonJS({
|
|
|
9953
9953
|
}
|
|
9954
9954
|
}
|
|
9955
9955
|
function buildKey(opts) {
|
|
9956
|
-
const { path:
|
|
9956
|
+
const { path: path68, method, body, headers, query } = opts;
|
|
9957
9957
|
return {
|
|
9958
|
-
path:
|
|
9958
|
+
path: path68,
|
|
9959
9959
|
method,
|
|
9960
9960
|
body,
|
|
9961
9961
|
headers,
|
|
@@ -10404,10 +10404,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
10404
10404
|
}
|
|
10405
10405
|
format(pendingInterceptors) {
|
|
10406
10406
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
10407
|
-
({ method, path:
|
|
10407
|
+
({ method, path: path68, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
10408
10408
|
Method: method,
|
|
10409
10409
|
Origin: origin,
|
|
10410
|
-
Path:
|
|
10410
|
+
Path: path68,
|
|
10411
10411
|
"Status code": statusCode,
|
|
10412
10412
|
Persistent: persist ? "\u2705" : "\u274C",
|
|
10413
10413
|
Invocations: timesInvoked,
|
|
@@ -15027,8 +15027,8 @@ var require_util6 = __commonJS({
|
|
|
15027
15027
|
}
|
|
15028
15028
|
}
|
|
15029
15029
|
}
|
|
15030
|
-
function validateCookiePath(
|
|
15031
|
-
for (const char of
|
|
15030
|
+
function validateCookiePath(path68) {
|
|
15031
|
+
for (const char of path68) {
|
|
15032
15032
|
const code = char.charCodeAt(0);
|
|
15033
15033
|
if (code < 33 || char === ";") {
|
|
15034
15034
|
throw new Error("Invalid cookie path");
|
|
@@ -16708,11 +16708,11 @@ var require_undici = __commonJS({
|
|
|
16708
16708
|
if (typeof opts.path !== "string") {
|
|
16709
16709
|
throw new InvalidArgumentError("invalid opts.path");
|
|
16710
16710
|
}
|
|
16711
|
-
let
|
|
16711
|
+
let path68 = opts.path;
|
|
16712
16712
|
if (!opts.path.startsWith("/")) {
|
|
16713
|
-
|
|
16713
|
+
path68 = `/${path68}`;
|
|
16714
16714
|
}
|
|
16715
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
16715
|
+
url2 = new URL(util.parseOrigin(url2).origin + path68);
|
|
16716
16716
|
} else {
|
|
16717
16717
|
if (!opts) {
|
|
16718
16718
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -19983,8 +19983,8 @@ var require_utils2 = __commonJS({
|
|
|
19983
19983
|
}
|
|
19984
19984
|
return ind;
|
|
19985
19985
|
}
|
|
19986
|
-
function removeDotSegments(
|
|
19987
|
-
let input =
|
|
19986
|
+
function removeDotSegments(path68) {
|
|
19987
|
+
let input = path68;
|
|
19988
19988
|
const output = [];
|
|
19989
19989
|
let nextSlash = -1;
|
|
19990
19990
|
let len = 0;
|
|
@@ -20236,8 +20236,8 @@ var require_schemes = __commonJS({
|
|
|
20236
20236
|
wsComponent.secure = void 0;
|
|
20237
20237
|
}
|
|
20238
20238
|
if (wsComponent.resourceName) {
|
|
20239
|
-
const [
|
|
20240
|
-
wsComponent.path =
|
|
20239
|
+
const [path68, query] = wsComponent.resourceName.split("?");
|
|
20240
|
+
wsComponent.path = path68 && path68 !== "/" ? path68 : void 0;
|
|
20241
20241
|
wsComponent.query = query;
|
|
20242
20242
|
wsComponent.resourceName = void 0;
|
|
20243
20243
|
}
|
|
@@ -23636,12 +23636,12 @@ var require_dist = __commonJS({
|
|
|
23636
23636
|
throw new Error(`Unknown format "${name}"`);
|
|
23637
23637
|
return f;
|
|
23638
23638
|
};
|
|
23639
|
-
function addFormats(ajv, list2,
|
|
23639
|
+
function addFormats(ajv, list2, fs48, exportName) {
|
|
23640
23640
|
var _a3;
|
|
23641
23641
|
var _b;
|
|
23642
23642
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
23643
23643
|
for (const f of list2)
|
|
23644
|
-
ajv.addFormat(f,
|
|
23644
|
+
ajv.addFormat(f, fs48[f]);
|
|
23645
23645
|
}
|
|
23646
23646
|
module2.exports = exports2 = formatsPlugin;
|
|
23647
23647
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -23654,8 +23654,8 @@ var require_windows = __commonJS({
|
|
|
23654
23654
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports2, module2) {
|
|
23655
23655
|
module2.exports = isexe;
|
|
23656
23656
|
isexe.sync = sync;
|
|
23657
|
-
var
|
|
23658
|
-
function checkPathExt(
|
|
23657
|
+
var fs48 = require("fs");
|
|
23658
|
+
function checkPathExt(path68, options) {
|
|
23659
23659
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
23660
23660
|
if (!pathext) {
|
|
23661
23661
|
return true;
|
|
@@ -23666,25 +23666,25 @@ var require_windows = __commonJS({
|
|
|
23666
23666
|
}
|
|
23667
23667
|
for (var i = 0; i < pathext.length; i++) {
|
|
23668
23668
|
var p = pathext[i].toLowerCase();
|
|
23669
|
-
if (p &&
|
|
23669
|
+
if (p && path68.substr(-p.length).toLowerCase() === p) {
|
|
23670
23670
|
return true;
|
|
23671
23671
|
}
|
|
23672
23672
|
}
|
|
23673
23673
|
return false;
|
|
23674
23674
|
}
|
|
23675
|
-
function checkStat(stat,
|
|
23675
|
+
function checkStat(stat, path68, options) {
|
|
23676
23676
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
23677
23677
|
return false;
|
|
23678
23678
|
}
|
|
23679
|
-
return checkPathExt(
|
|
23679
|
+
return checkPathExt(path68, options);
|
|
23680
23680
|
}
|
|
23681
|
-
function isexe(
|
|
23682
|
-
|
|
23683
|
-
cb(er, er ? false : checkStat(stat,
|
|
23681
|
+
function isexe(path68, options, cb) {
|
|
23682
|
+
fs48.stat(path68, function(er, stat) {
|
|
23683
|
+
cb(er, er ? false : checkStat(stat, path68, options));
|
|
23684
23684
|
});
|
|
23685
23685
|
}
|
|
23686
|
-
function sync(
|
|
23687
|
-
return checkStat(
|
|
23686
|
+
function sync(path68, options) {
|
|
23687
|
+
return checkStat(fs48.statSync(path68), path68, options);
|
|
23688
23688
|
}
|
|
23689
23689
|
}
|
|
23690
23690
|
});
|
|
@@ -23694,14 +23694,14 @@ var require_mode = __commonJS({
|
|
|
23694
23694
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports2, module2) {
|
|
23695
23695
|
module2.exports = isexe;
|
|
23696
23696
|
isexe.sync = sync;
|
|
23697
|
-
var
|
|
23698
|
-
function isexe(
|
|
23699
|
-
|
|
23697
|
+
var fs48 = require("fs");
|
|
23698
|
+
function isexe(path68, options, cb) {
|
|
23699
|
+
fs48.stat(path68, function(er, stat) {
|
|
23700
23700
|
cb(er, er ? false : checkStat(stat, options));
|
|
23701
23701
|
});
|
|
23702
23702
|
}
|
|
23703
|
-
function sync(
|
|
23704
|
-
return checkStat(
|
|
23703
|
+
function sync(path68, options) {
|
|
23704
|
+
return checkStat(fs48.statSync(path68), options);
|
|
23705
23705
|
}
|
|
23706
23706
|
function checkStat(stat, options) {
|
|
23707
23707
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -23725,7 +23725,7 @@ var require_mode = __commonJS({
|
|
|
23725
23725
|
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
23726
23726
|
var require_isexe = __commonJS({
|
|
23727
23727
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports2, module2) {
|
|
23728
|
-
var
|
|
23728
|
+
var fs48 = require("fs");
|
|
23729
23729
|
var core;
|
|
23730
23730
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
23731
23731
|
core = require_windows();
|
|
@@ -23734,7 +23734,7 @@ var require_isexe = __commonJS({
|
|
|
23734
23734
|
}
|
|
23735
23735
|
module2.exports = isexe;
|
|
23736
23736
|
isexe.sync = sync;
|
|
23737
|
-
function isexe(
|
|
23737
|
+
function isexe(path68, options, cb) {
|
|
23738
23738
|
if (typeof options === "function") {
|
|
23739
23739
|
cb = options;
|
|
23740
23740
|
options = {};
|
|
@@ -23744,7 +23744,7 @@ var require_isexe = __commonJS({
|
|
|
23744
23744
|
throw new TypeError("callback not provided");
|
|
23745
23745
|
}
|
|
23746
23746
|
return new Promise(function(resolve, reject2) {
|
|
23747
|
-
isexe(
|
|
23747
|
+
isexe(path68, options || {}, function(er, is) {
|
|
23748
23748
|
if (er) {
|
|
23749
23749
|
reject2(er);
|
|
23750
23750
|
} else {
|
|
@@ -23753,7 +23753,7 @@ var require_isexe = __commonJS({
|
|
|
23753
23753
|
});
|
|
23754
23754
|
});
|
|
23755
23755
|
}
|
|
23756
|
-
core(
|
|
23756
|
+
core(path68, options || {}, function(er, is) {
|
|
23757
23757
|
if (er) {
|
|
23758
23758
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
23759
23759
|
er = null;
|
|
@@ -23763,9 +23763,9 @@ var require_isexe = __commonJS({
|
|
|
23763
23763
|
cb(er, is);
|
|
23764
23764
|
});
|
|
23765
23765
|
}
|
|
23766
|
-
function sync(
|
|
23766
|
+
function sync(path68, options) {
|
|
23767
23767
|
try {
|
|
23768
|
-
return core.sync(
|
|
23768
|
+
return core.sync(path68, options || {});
|
|
23769
23769
|
} catch (er) {
|
|
23770
23770
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
23771
23771
|
return false;
|
|
@@ -23781,7 +23781,7 @@ var require_isexe = __commonJS({
|
|
|
23781
23781
|
var require_which = __commonJS({
|
|
23782
23782
|
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports2, module2) {
|
|
23783
23783
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
23784
|
-
var
|
|
23784
|
+
var path68 = require("path");
|
|
23785
23785
|
var COLON = isWindows ? ";" : ":";
|
|
23786
23786
|
var isexe = require_isexe();
|
|
23787
23787
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -23819,7 +23819,7 @@ var require_which = __commonJS({
|
|
|
23819
23819
|
return opt.all && found2.length ? resolve(found2) : reject2(getNotFoundError(cmd));
|
|
23820
23820
|
const ppRaw = pathEnv[i];
|
|
23821
23821
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
23822
|
-
const pCmd =
|
|
23822
|
+
const pCmd = path68.join(pathPart, cmd);
|
|
23823
23823
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
23824
23824
|
resolve(subStep(p, i, 0));
|
|
23825
23825
|
});
|
|
@@ -23846,7 +23846,7 @@ var require_which = __commonJS({
|
|
|
23846
23846
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
23847
23847
|
const ppRaw = pathEnv[i];
|
|
23848
23848
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
23849
|
-
const pCmd =
|
|
23849
|
+
const pCmd = path68.join(pathPart, cmd);
|
|
23850
23850
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
23851
23851
|
for (let j = 0; j < pathExt.length; j++) {
|
|
23852
23852
|
const cur = p + pathExt[j];
|
|
@@ -23894,7 +23894,7 @@ var require_path_key = __commonJS({
|
|
|
23894
23894
|
var require_resolveCommand = __commonJS({
|
|
23895
23895
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
|
|
23896
23896
|
"use strict";
|
|
23897
|
-
var
|
|
23897
|
+
var path68 = require("path");
|
|
23898
23898
|
var which = require_which();
|
|
23899
23899
|
var getPathKey = require_path_key();
|
|
23900
23900
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -23912,7 +23912,7 @@ var require_resolveCommand = __commonJS({
|
|
|
23912
23912
|
try {
|
|
23913
23913
|
resolved = which.sync(parsed.command, {
|
|
23914
23914
|
path: env2[getPathKey({ env: env2 })],
|
|
23915
|
-
pathExt: withoutPathExt ?
|
|
23915
|
+
pathExt: withoutPathExt ? path68.delimiter : void 0
|
|
23916
23916
|
});
|
|
23917
23917
|
} catch (e) {
|
|
23918
23918
|
} finally {
|
|
@@ -23921,7 +23921,7 @@ var require_resolveCommand = __commonJS({
|
|
|
23921
23921
|
}
|
|
23922
23922
|
}
|
|
23923
23923
|
if (resolved) {
|
|
23924
|
-
resolved =
|
|
23924
|
+
resolved = path68.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
23925
23925
|
}
|
|
23926
23926
|
return resolved;
|
|
23927
23927
|
}
|
|
@@ -23975,8 +23975,8 @@ var require_shebang_command = __commonJS({
|
|
|
23975
23975
|
if (!match) {
|
|
23976
23976
|
return null;
|
|
23977
23977
|
}
|
|
23978
|
-
const [
|
|
23979
|
-
const binary =
|
|
23978
|
+
const [path68, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
23979
|
+
const binary = path68.split("/").pop();
|
|
23980
23980
|
if (binary === "env") {
|
|
23981
23981
|
return argument;
|
|
23982
23982
|
}
|
|
@@ -23989,16 +23989,16 @@ var require_shebang_command = __commonJS({
|
|
|
23989
23989
|
var require_readShebang = __commonJS({
|
|
23990
23990
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
|
|
23991
23991
|
"use strict";
|
|
23992
|
-
var
|
|
23992
|
+
var fs48 = require("fs");
|
|
23993
23993
|
var shebangCommand = require_shebang_command();
|
|
23994
23994
|
function readShebang(command) {
|
|
23995
23995
|
const size = 150;
|
|
23996
23996
|
const buffer = Buffer.alloc(size);
|
|
23997
23997
|
let fd;
|
|
23998
23998
|
try {
|
|
23999
|
-
fd =
|
|
24000
|
-
|
|
24001
|
-
|
|
23999
|
+
fd = fs48.openSync(command, "r");
|
|
24000
|
+
fs48.readSync(fd, buffer, 0, size, 0);
|
|
24001
|
+
fs48.closeSync(fd);
|
|
24002
24002
|
} catch (e) {
|
|
24003
24003
|
}
|
|
24004
24004
|
return shebangCommand(buffer.toString());
|
|
@@ -24011,7 +24011,7 @@ var require_readShebang = __commonJS({
|
|
|
24011
24011
|
var require_parse2 = __commonJS({
|
|
24012
24012
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
|
|
24013
24013
|
"use strict";
|
|
24014
|
-
var
|
|
24014
|
+
var path68 = require("path");
|
|
24015
24015
|
var resolveCommand = require_resolveCommand();
|
|
24016
24016
|
var escape4 = require_escape();
|
|
24017
24017
|
var readShebang = require_readShebang();
|
|
@@ -24036,7 +24036,7 @@ var require_parse2 = __commonJS({
|
|
|
24036
24036
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
24037
24037
|
if (parsed.options.forceShell || needsShell) {
|
|
24038
24038
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
24039
|
-
parsed.command =
|
|
24039
|
+
parsed.command = path68.normalize(parsed.command);
|
|
24040
24040
|
parsed.command = escape4.command(parsed.command);
|
|
24041
24041
|
parsed.args = parsed.args.map((arg) => escape4.argument(arg, needsDoubleEscapeMetaChars));
|
|
24042
24042
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -24258,9 +24258,9 @@ __export(server_exports, {
|
|
|
24258
24258
|
});
|
|
24259
24259
|
module.exports = __toCommonJS(server_exports);
|
|
24260
24260
|
var import_promises38 = __toESM(require("node:fs/promises"), 1);
|
|
24261
|
-
var
|
|
24261
|
+
var import_node_fs19 = require("node:fs");
|
|
24262
24262
|
var import_node_http = require("node:http");
|
|
24263
|
-
var
|
|
24263
|
+
var import_node_path68 = __toESM(require("node:path"), 1);
|
|
24264
24264
|
|
|
24265
24265
|
// ../../packages/core/dist/platform/http.js
|
|
24266
24266
|
var import_node_crypto = require("node:crypto");
|
|
@@ -25428,10 +25428,10 @@ function mergeDefs(...defs) {
|
|
|
25428
25428
|
function cloneDef(schema12) {
|
|
25429
25429
|
return mergeDefs(schema12._zod.def);
|
|
25430
25430
|
}
|
|
25431
|
-
function getElementAtPath(obj,
|
|
25432
|
-
if (!
|
|
25431
|
+
function getElementAtPath(obj, path68) {
|
|
25432
|
+
if (!path68)
|
|
25433
25433
|
return obj;
|
|
25434
|
-
return
|
|
25434
|
+
return path68.reduce((acc, key3) => acc?.[key3], obj);
|
|
25435
25435
|
}
|
|
25436
25436
|
function promiseAllObject(promisesObj) {
|
|
25437
25437
|
const keys = Object.keys(promisesObj);
|
|
@@ -25840,11 +25840,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
25840
25840
|
}
|
|
25841
25841
|
return false;
|
|
25842
25842
|
}
|
|
25843
|
-
function prefixIssues(
|
|
25843
|
+
function prefixIssues(path68, issues) {
|
|
25844
25844
|
return issues.map((iss) => {
|
|
25845
25845
|
var _a3;
|
|
25846
25846
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
25847
|
-
iss.path.unshift(
|
|
25847
|
+
iss.path.unshift(path68);
|
|
25848
25848
|
return iss;
|
|
25849
25849
|
});
|
|
25850
25850
|
}
|
|
@@ -25991,16 +25991,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
25991
25991
|
}
|
|
25992
25992
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
25993
25993
|
const fieldErrors = { _errors: [] };
|
|
25994
|
-
const processError = (error52,
|
|
25994
|
+
const processError = (error52, path68 = []) => {
|
|
25995
25995
|
for (const issue2 of error52.issues) {
|
|
25996
25996
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
25997
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
25997
|
+
issue2.errors.map((issues) => processError({ issues }, [...path68, ...issue2.path]));
|
|
25998
25998
|
} else if (issue2.code === "invalid_key") {
|
|
25999
|
-
processError({ issues: issue2.issues }, [...
|
|
25999
|
+
processError({ issues: issue2.issues }, [...path68, ...issue2.path]);
|
|
26000
26000
|
} else if (issue2.code === "invalid_element") {
|
|
26001
|
-
processError({ issues: issue2.issues }, [...
|
|
26001
|
+
processError({ issues: issue2.issues }, [...path68, ...issue2.path]);
|
|
26002
26002
|
} else {
|
|
26003
|
-
const fullpath = [...
|
|
26003
|
+
const fullpath = [...path68, ...issue2.path];
|
|
26004
26004
|
if (fullpath.length === 0) {
|
|
26005
26005
|
fieldErrors._errors.push(mapper(issue2));
|
|
26006
26006
|
} else {
|
|
@@ -26027,17 +26027,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26027
26027
|
}
|
|
26028
26028
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
26029
26029
|
const result = { errors: [] };
|
|
26030
|
-
const processError = (error52,
|
|
26030
|
+
const processError = (error52, path68 = []) => {
|
|
26031
26031
|
var _a3, _b;
|
|
26032
26032
|
for (const issue2 of error52.issues) {
|
|
26033
26033
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
26034
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
26034
|
+
issue2.errors.map((issues) => processError({ issues }, [...path68, ...issue2.path]));
|
|
26035
26035
|
} else if (issue2.code === "invalid_key") {
|
|
26036
|
-
processError({ issues: issue2.issues }, [...
|
|
26036
|
+
processError({ issues: issue2.issues }, [...path68, ...issue2.path]);
|
|
26037
26037
|
} else if (issue2.code === "invalid_element") {
|
|
26038
|
-
processError({ issues: issue2.issues }, [...
|
|
26038
|
+
processError({ issues: issue2.issues }, [...path68, ...issue2.path]);
|
|
26039
26039
|
} else {
|
|
26040
|
-
const fullpath = [...
|
|
26040
|
+
const fullpath = [...path68, ...issue2.path];
|
|
26041
26041
|
if (fullpath.length === 0) {
|
|
26042
26042
|
result.errors.push(mapper(issue2));
|
|
26043
26043
|
continue;
|
|
@@ -26069,8 +26069,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26069
26069
|
}
|
|
26070
26070
|
function toDotPath(_path) {
|
|
26071
26071
|
const segs = [];
|
|
26072
|
-
const
|
|
26073
|
-
for (const seg of
|
|
26072
|
+
const path68 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
26073
|
+
for (const seg of path68) {
|
|
26074
26074
|
if (typeof seg === "number")
|
|
26075
26075
|
segs.push(`[${seg}]`);
|
|
26076
26076
|
else if (typeof seg === "symbol")
|
|
@@ -38762,13 +38762,13 @@ function resolveRef(ref, ctx) {
|
|
|
38762
38762
|
if (!ref.startsWith("#")) {
|
|
38763
38763
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
38764
38764
|
}
|
|
38765
|
-
const
|
|
38766
|
-
if (
|
|
38765
|
+
const path68 = ref.slice(1).split("/").filter(Boolean);
|
|
38766
|
+
if (path68.length === 0) {
|
|
38767
38767
|
return ctx.rootSchema;
|
|
38768
38768
|
}
|
|
38769
38769
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
38770
|
-
if (
|
|
38771
|
-
const key3 =
|
|
38770
|
+
if (path68[0] === defsKey) {
|
|
38771
|
+
const key3 = path68[1];
|
|
38772
38772
|
if (!key3 || !ctx.defs[key3]) {
|
|
38773
38773
|
throw new Error(`Reference not found: ${ref}`);
|
|
38774
38774
|
}
|
|
@@ -39550,6 +39550,7 @@ function describeStrategy(strategy, roleName) {
|
|
|
39550
39550
|
return `the box "${groupName(group)}" (step${inside.length === 1 ? "" : "s"} ${inside.join(", ")})`;
|
|
39551
39551
|
};
|
|
39552
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(", ")}]` : ""}`;
|
|
39553
|
+
const askAs = (role) => roleName(role).trim().toLowerCase() === role ? "" : ` (ask_agent role "${role}")`;
|
|
39553
39554
|
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
39555
|
const announced = /* @__PURE__ */ new Set();
|
|
39555
39556
|
for (const node of order2) {
|
|
@@ -39560,7 +39561,7 @@ function describeStrategy(strategy, roleName) {
|
|
|
39560
39561
|
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
|
}
|
|
39562
39563
|
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
|
+
lines2.push(`${group !== void 0 ? " " : ""}${String(number5.get(node.id))}. ${roleName(node.role)}${askAs(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
39565
|
if (group !== void 0) {
|
|
39565
39566
|
const members = groupMembers(strategy, group.id);
|
|
39566
39567
|
const last = order2.filter((n) => members.some((m) => m.id === n.id)).at(-1);
|
|
@@ -39589,7 +39590,7 @@ function describeStrategy(strategy, roleName) {
|
|
|
39589
39590
|
if (boxes.length > 0) {
|
|
39590
39591
|
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.");
|
|
39591
39592
|
}
|
|
39592
|
-
lines2.push("", "How to follow it:", "- Before doing anything else
|
|
39593
|
+
lines2.push("", "How to follow it:", "- This strategy applies to every piece of work asked for in this chat, not only the first. Before doing anything else for a request - including a new topic after an earlier one is finished - propose a plan with update_plan that carries out every step above in order for that request, naming the role for each step and writing each back-and-forth as one step with its condition and its maximum rounds. Then follow the plan. A new plan for a new topic starts the loops afresh; do not reuse an earlier topic's plan or skip the specialists because they were consulted before.", "- Each specialist works in its own context and does not see this conversation. Light Code hands each step the latest full answers of the steps connected into it, directly - do not paste earlier specialists' answers into your question. Say what this step should do now, and add only what it cannot get that way: the user's request and anything from this conversation it needs. You are given each specialist's summary, not its whole answer; read the full one with strategy_history only when you need the detail. 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.");
|
|
39593
39594
|
return lines2.join("\n");
|
|
39594
39595
|
}
|
|
39595
39596
|
function readVerdict(answer) {
|
|
@@ -39754,6 +39755,48 @@ function askForMissing(missing, previous) {
|
|
|
39754
39755
|
previous.length > 6e3 ? `${previous.slice(0, 6e3)}\u2026` : previous
|
|
39755
39756
|
].join("\n");
|
|
39756
39757
|
}
|
|
39758
|
+
function handOverSources(strategy, role) {
|
|
39759
|
+
const mine = strategy.nodes.filter((node) => node.role === role);
|
|
39760
|
+
if (mine.length === 0)
|
|
39761
|
+
return [];
|
|
39762
|
+
const ids = new Set(mine.map((node) => node.id));
|
|
39763
|
+
const groups = new Set(mine.map((node) => node.group).filter((group) => group !== void 0));
|
|
39764
|
+
const into = (edge) => ids.has(edge.to) || groups.has(edge.to);
|
|
39765
|
+
const sources = /* @__PURE__ */ new Set();
|
|
39766
|
+
for (const edge of strategy.edges) {
|
|
39767
|
+
if (into(edge))
|
|
39768
|
+
for (const node of endpointNodes(strategy, edge.from))
|
|
39769
|
+
sources.add(node.role);
|
|
39770
|
+
if (edge.twoWay === true && (ids.has(edge.from) || groups.has(edge.from)))
|
|
39771
|
+
for (const node of endpointNodes(strategy, edge.to))
|
|
39772
|
+
sources.add(node.role);
|
|
39773
|
+
}
|
|
39774
|
+
sources.delete(role);
|
|
39775
|
+
return [...sources];
|
|
39776
|
+
}
|
|
39777
|
+
var SUMMARY_HEADING = "Summary for the main agent";
|
|
39778
|
+
var SUMMARY_REQUEST = `Your full answer is kept and passed on to the next step of the strategy directly. End it with a section headed "${SUMMARY_HEADING}:" - at most eight short lines: what you did or found, any decision the main agent must make, and anything blocking. Only that section reaches the main agent.`;
|
|
39779
|
+
var SUMMARY_LIMIT = 2e3;
|
|
39780
|
+
var SHORT_ANSWER = 2500;
|
|
39781
|
+
function answerForMain(answer, role) {
|
|
39782
|
+
const lines2 = answer.split(/\r?\n/);
|
|
39783
|
+
const heading = lines2.findIndex((line) => /^\s*(?:#+\s*)?(?:\*\*)?\s*summary for the main agent\b/i.test(line));
|
|
39784
|
+
if (heading >= 0) {
|
|
39785
|
+
const first = lines2[heading].replace(/^\s*(?:#+\s*)?(?:\*\*)?\s*summary for the main agent\s*:?\s*(?:\*\*)?\s*:?\s*/i, "");
|
|
39786
|
+
const summary = [first, ...lines2.slice(heading + 1)].join("\n").trim();
|
|
39787
|
+
if (summary.length > 0) {
|
|
39788
|
+
const cut = summary.length > SUMMARY_LIMIT ? `${summary.slice(0, SUMMARY_LIMIT)}\u2026` : summary;
|
|
39789
|
+
return `${cut}
|
|
39790
|
+
|
|
39791
|
+
[The ${role}'s full answer (${String(answer.length)} characters) was passed to the next step directly and is in the strategy record; read it with strategy_history only if you need the detail.]`;
|
|
39792
|
+
}
|
|
39793
|
+
}
|
|
39794
|
+
if (answer.length <= SHORT_ANSWER)
|
|
39795
|
+
return answer;
|
|
39796
|
+
return `${answer.slice(0, SUMMARY_LIMIT)}\u2026
|
|
39797
|
+
|
|
39798
|
+
[Shortened for you: the ${role}'s full answer (${String(answer.length)} characters) was passed to the next step directly and is in the strategy record; read it with strategy_history only if you need the detail.]`;
|
|
39799
|
+
}
|
|
39757
39800
|
|
|
39758
39801
|
// ../../packages/core/dist/mcp/types.js
|
|
39759
39802
|
var mcpDenyRuleSchema = external_exports.object({
|
|
@@ -41300,6 +41343,20 @@ var configSchema = external_exports.object({
|
|
|
41300
41343
|
* and a provider refusing an over-long conversation says so and points there.
|
|
41301
41344
|
*/
|
|
41302
41345
|
autoCompact: external_exports.boolean(),
|
|
41346
|
+
/**
|
|
41347
|
+
* Start a new chat from a handoff by itself when this one reaches the context limit, instead of compacting it.
|
|
41348
|
+
* Asked for: "a checkbox, when enabled it should auto handoff to new session when context limit is hit". The
|
|
41349
|
+
* handoff note and the user's own messages carry the work over, and the new chat carries on by itself; the old
|
|
41350
|
+
* chat stays in History. Compacting automatically wins when both are ticked - it was asked for first and keeps
|
|
41351
|
+
* the chat. Off unless set to true.
|
|
41352
|
+
*/
|
|
41353
|
+
autoHandoff: external_exports.boolean(),
|
|
41354
|
+
/**
|
|
41355
|
+
* No step limit for a chat's replies: the agent runs until it finishes, is stopped, or fails the same way three times
|
|
41356
|
+
* in a row. Asked for, with the Anti Hallucinator watching and guiding it. Scheduled runs keep `maxIterations` -
|
|
41357
|
+
* nobody is there to press Stop. Off unless set to true.
|
|
41358
|
+
*/
|
|
41359
|
+
unlimitedSteps: external_exports.boolean(),
|
|
41303
41360
|
/**
|
|
41304
41361
|
* Model requests that fail or go silent. `stallSeconds`: how long a request may send nothing at
|
|
41305
41362
|
* all before it is stopped and sent again (0 = never; default 300). `retries`: how many times a
|
|
@@ -43612,8 +43669,8 @@ function restoreArguments(argumentsJson, reshaped) {
|
|
|
43612
43669
|
restoreAt(args, entry.path, entry.kind);
|
|
43613
43670
|
return JSON.stringify(args);
|
|
43614
43671
|
}
|
|
43615
|
-
function restoreAt(value,
|
|
43616
|
-
if (
|
|
43672
|
+
function restoreAt(value, path68, kind) {
|
|
43673
|
+
if (path68.length === 0) {
|
|
43617
43674
|
if (typeof value !== "string")
|
|
43618
43675
|
return value;
|
|
43619
43676
|
if (kind === "number") {
|
|
@@ -43626,7 +43683,7 @@ function restoreAt(value, path67, kind) {
|
|
|
43626
43683
|
return value;
|
|
43627
43684
|
}
|
|
43628
43685
|
}
|
|
43629
|
-
const [head, ...rest] =
|
|
43686
|
+
const [head, ...rest] = path68;
|
|
43630
43687
|
if (head === "[]") {
|
|
43631
43688
|
if (Array.isArray(value))
|
|
43632
43689
|
for (let i = 0; i < value.length; i += 1)
|
|
@@ -43639,16 +43696,16 @@ function restoreAt(value, path67, kind) {
|
|
|
43639
43696
|
}
|
|
43640
43697
|
var SCALARS = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean"]);
|
|
43641
43698
|
var MAX_DEPTH = 12;
|
|
43642
|
-
function convert(schema12, root,
|
|
43699
|
+
function convert(schema12, root, path68, found2, depth, isRoot = false) {
|
|
43643
43700
|
if (!isRecord2(schema12))
|
|
43644
43701
|
return { type: "string" };
|
|
43645
43702
|
if (depth > MAX_DEPTH)
|
|
43646
|
-
return asJsonString(schema12,
|
|
43703
|
+
return asJsonString(schema12, path68, found2, "nested too deeply to describe here");
|
|
43647
43704
|
let node = { ...schema12 };
|
|
43648
43705
|
if (typeof node.$ref === "string") {
|
|
43649
43706
|
const target = resolveRef2(node.$ref, root);
|
|
43650
43707
|
if (target === void 0)
|
|
43651
|
-
return asJsonString(node,
|
|
43708
|
+
return asJsonString(node, path68, found2, "a structured value");
|
|
43652
43709
|
const { $ref: _ref, ...siblings } = node;
|
|
43653
43710
|
void _ref;
|
|
43654
43711
|
node = { ...target, ...siblings };
|
|
@@ -43664,7 +43721,7 @@ function convert(schema12, root, path67, found2, depth, isRoot = false) {
|
|
|
43664
43721
|
const merged = { ...branches[0] };
|
|
43665
43722
|
if (describedBase !== void 0 && merged.description === void 0)
|
|
43666
43723
|
merged.description = describedBase;
|
|
43667
|
-
const converted = convert(merged, root,
|
|
43724
|
+
const converted = convert(merged, root, path68, found2, depth + 1);
|
|
43668
43725
|
if (nullable2)
|
|
43669
43726
|
converted.nullable = true;
|
|
43670
43727
|
return converted;
|
|
@@ -43672,16 +43729,16 @@ function convert(schema12, root, path67, found2, depth, isRoot = false) {
|
|
|
43672
43729
|
const allEnums = branches.every((branch) => Array.isArray(branch.enum) || branch.const !== void 0);
|
|
43673
43730
|
if (allEnums) {
|
|
43674
43731
|
const values = branches.flatMap((branch) => Array.isArray(branch.enum) ? branch.enum : [branch.const]);
|
|
43675
|
-
return convert({ ...withoutUnion(node), enum: values, ...nullable2 ? { nullable: true } : {} }, root,
|
|
43732
|
+
return convert({ ...withoutUnion(node), enum: values, ...nullable2 ? { nullable: true } : {} }, root, path68, found2, depth + 1);
|
|
43676
43733
|
}
|
|
43677
43734
|
const allScalars = branches.every((branch) => typeof branch.type === "string" && SCALARS.has(branch.type));
|
|
43678
43735
|
if (allScalars) {
|
|
43679
43736
|
const types = branches.map((branch) => branch.type);
|
|
43680
43737
|
const chosen = types.includes("string") ? "string" : types[0];
|
|
43681
43738
|
const note = `Accepts ${types.join(" or ")}.`;
|
|
43682
|
-
return convert({ ...withoutUnion(node), type: chosen, description: join(baseDescription(node), note), ...nullable2 ? { nullable: true } : {} }, root,
|
|
43739
|
+
return convert({ ...withoutUnion(node), type: chosen, description: join(baseDescription(node), note), ...nullable2 ? { nullable: true } : {} }, root, path68, found2, depth + 1);
|
|
43683
43740
|
}
|
|
43684
|
-
return asJsonString(node,
|
|
43741
|
+
return asJsonString(node, path68, found2, describeUnion(branches));
|
|
43685
43742
|
}
|
|
43686
43743
|
const type = node.type;
|
|
43687
43744
|
const notes = describeDropped(node);
|
|
@@ -43693,10 +43750,10 @@ function convert(schema12, root, path67, found2, depth, isRoot = false) {
|
|
|
43693
43750
|
const properties = isRecord2(node.properties) ? node.properties : {};
|
|
43694
43751
|
const names = Object.keys(properties);
|
|
43695
43752
|
if (names.length === 0 && !isRoot)
|
|
43696
|
-
return asJsonString(node,
|
|
43753
|
+
return asJsonString(node, path68, found2, "an object with any keys");
|
|
43697
43754
|
const converted = {};
|
|
43698
43755
|
for (const name of names)
|
|
43699
|
-
converted[name] = convert(properties[name], root, [...
|
|
43756
|
+
converted[name] = convert(properties[name], root, [...path68, name], found2, depth + 1);
|
|
43700
43757
|
out.properties = converted;
|
|
43701
43758
|
if (Array.isArray(node.required)) {
|
|
43702
43759
|
const required2 = node.required.filter((name) => typeof name === "string" && name in converted);
|
|
@@ -43704,9 +43761,9 @@ function convert(schema12, root, path67, found2, depth, isRoot = false) {
|
|
|
43704
43761
|
out.required = required2;
|
|
43705
43762
|
}
|
|
43706
43763
|
} else if (type === "array") {
|
|
43707
|
-
out.items = node.items === void 0 ? { type: "string" } : convert(node.items, root, [...
|
|
43764
|
+
out.items = node.items === void 0 ? { type: "string" } : convert(node.items, root, [...path68, "[]"], found2, depth + 1);
|
|
43708
43765
|
} else if (type === void 0 && node.enum === void 0) {
|
|
43709
|
-
return asJsonString(node,
|
|
43766
|
+
return asJsonString(node, path68, found2, "any JSON value");
|
|
43710
43767
|
}
|
|
43711
43768
|
if (Array.isArray(node.enum)) {
|
|
43712
43769
|
const values = node.enum.filter((value) => value !== null);
|
|
@@ -43716,7 +43773,7 @@ function convert(schema12, root, path67, found2, depth, isRoot = false) {
|
|
|
43716
43773
|
} else if (values.every((value) => typeof value === "number")) {
|
|
43717
43774
|
out.type = "string";
|
|
43718
43775
|
out.enum = values.map(String);
|
|
43719
|
-
found2.push({ path:
|
|
43776
|
+
found2.push({ path: path68, kind: "number" });
|
|
43720
43777
|
} else {
|
|
43721
43778
|
notes.push(`One of: ${values.map((value) => JSON.stringify(value)).join(", ")}.`);
|
|
43722
43779
|
}
|
|
@@ -43730,8 +43787,8 @@ function convert(schema12, root, path67, found2, depth, isRoot = false) {
|
|
|
43730
43787
|
out.description = description;
|
|
43731
43788
|
return out;
|
|
43732
43789
|
}
|
|
43733
|
-
function asJsonString(node,
|
|
43734
|
-
found2.push({ path:
|
|
43790
|
+
function asJsonString(node, path68, found2, what) {
|
|
43791
|
+
found2.push({ path: path68, kind: "json" });
|
|
43735
43792
|
const example = exampleFor(node);
|
|
43736
43793
|
return {
|
|
43737
43794
|
type: "string",
|
|
@@ -45110,8 +45167,8 @@ var SUPERSEDED_MARKER = "[Superseded: this file was read again later in the conv
|
|
|
45110
45167
|
function readFilePath(argumentsJson) {
|
|
45111
45168
|
try {
|
|
45112
45169
|
const parsed = JSON.parse(argumentsJson.length > 0 ? argumentsJson : "{}");
|
|
45113
|
-
const
|
|
45114
|
-
return typeof
|
|
45170
|
+
const path68 = parsed.path;
|
|
45171
|
+
return typeof path68 === "string" && path68.length > 0 ? path68 : void 0;
|
|
45115
45172
|
} catch {
|
|
45116
45173
|
return void 0;
|
|
45117
45174
|
}
|
|
@@ -45124,8 +45181,8 @@ function dropSupersededReads(messages) {
|
|
|
45124
45181
|
for (const toolCall of message6.toolCalls ?? []) {
|
|
45125
45182
|
if (toolCall.name !== "read_file")
|
|
45126
45183
|
continue;
|
|
45127
|
-
const
|
|
45128
|
-
if (
|
|
45184
|
+
const path68 = readFilePath(toolCall.arguments);
|
|
45185
|
+
if (path68 === void 0)
|
|
45129
45186
|
continue;
|
|
45130
45187
|
keyByCallId.set(toolCall.id, toolCall.arguments);
|
|
45131
45188
|
}
|
|
@@ -46133,6 +46190,18 @@ function pruneProgress(plan3, progress) {
|
|
|
46133
46190
|
kept[id] = entry;
|
|
46134
46191
|
return kept;
|
|
46135
46192
|
}
|
|
46193
|
+
function startsNewWork(previousPlan, previousProgress, nextPlan) {
|
|
46194
|
+
const before = parseCheckpoints(previousPlan);
|
|
46195
|
+
const after = parseCheckpoints(nextPlan);
|
|
46196
|
+
if (after.length === 0)
|
|
46197
|
+
return false;
|
|
46198
|
+
if (before.length === 0)
|
|
46199
|
+
return true;
|
|
46200
|
+
if (before.every((step) => previousProgress?.[step.id]?.status === "done"))
|
|
46201
|
+
return true;
|
|
46202
|
+
const kept = new Set(before.map((step) => step.id));
|
|
46203
|
+
return !after.some((step) => kept.has(step.id));
|
|
46204
|
+
}
|
|
46136
46205
|
function markCheckpoint(plan3, progress, index, status2) {
|
|
46137
46206
|
const checkpoint = parseCheckpoints(plan3).find((candidate) => candidate.index === index);
|
|
46138
46207
|
if (checkpoint === void 0)
|
|
@@ -46693,7 +46762,7 @@ ${withBudget}` : withBudget;
|
|
|
46693
46762
|
|
|
46694
46763
|
// ../../packages/core/dist/tools/askAgent.js
|
|
46695
46764
|
var paramsSchema3 = external_exports.object({
|
|
46696
|
-
role: external_exports.string().describe(`Which specialist to ask: ${AGENT_ROLES.join(", ")}
|
|
46765
|
+
role: external_exports.string().describe(`Which specialist to ask: ${AGENT_ROLES.join(", ")}, or a custom role from Settings \u2192 Agents by its id. Only the ones assigned there can answer.`),
|
|
46697
46766
|
question: external_exports.string().min(1).describe("The question, with the code, error or output needed to answer it. The specialist cannot see this conversation or read files \u2014 paste what matters."),
|
|
46698
46767
|
files: external_exports.array(external_exports.string()).optional().describe("Workspace-relative paths you are working in, so it knows what you are looking at.")
|
|
46699
46768
|
});
|
|
@@ -46718,11 +46787,11 @@ Files named as relevant: ${params3.files.join(", ")}` : "")
|
|
|
46718
46787
|
},
|
|
46719
46788
|
async execute(params3, context) {
|
|
46720
46789
|
const team = options.agents();
|
|
46721
|
-
const
|
|
46722
|
-
|
|
46790
|
+
const agent = find(team, params3.role);
|
|
46791
|
+
const role = agent?.role ?? params3.role.trim().toLowerCase();
|
|
46792
|
+
if (agent === void 0 && !isAgentRole(role)) {
|
|
46723
46793
|
return { content: unknownRole(role, team), isError: true };
|
|
46724
46794
|
}
|
|
46725
|
-
const agent = find(team, role);
|
|
46726
46795
|
if (agent === void 0) {
|
|
46727
46796
|
return {
|
|
46728
46797
|
content: `No ${role} is assigned. ${describeTeam(team)} Assign one in Settings \u2192 Agents, or ask a different role.`,
|
|
@@ -46766,11 +46835,13 @@ ${trailerFor(agent, team)}`
|
|
|
46766
46835
|
};
|
|
46767
46836
|
}
|
|
46768
46837
|
function find(team, role) {
|
|
46769
|
-
const
|
|
46770
|
-
|
|
46838
|
+
const squash = (text2) => text2.trim().toLowerCase().replace(/[\s_-]+/g, "-");
|
|
46839
|
+
const wanted = squash(role);
|
|
46840
|
+
return team.find((agent) => agent.role === wanted) ?? team.find((agent) => squash(agent.name) === wanted);
|
|
46771
46841
|
}
|
|
46772
46842
|
function unknownRole(role, team) {
|
|
46773
|
-
|
|
46843
|
+
const roles = [.../* @__PURE__ */ new Set([...AGENT_ROLES, ...team.map((agent) => agent.role)])];
|
|
46844
|
+
return `There is no "${role}" role. The roles are: ${roles.join(", ")}. ${describeTeam(team)}`;
|
|
46774
46845
|
}
|
|
46775
46846
|
function describeTeam(team) {
|
|
46776
46847
|
const usable = team.filter((agent) => agent.available).map((agent) => agent.role);
|
|
@@ -48234,13 +48305,13 @@ var OpenSearchClient = class {
|
|
|
48234
48305
|
* `_bulk`, `_delete_by_query`, index creation — is refused here rather than merely
|
|
48235
48306
|
* unused, so no future edit or crafted argument can turn a read client into a writer.
|
|
48236
48307
|
*/
|
|
48237
|
-
async request(
|
|
48308
|
+
async request(path68, options = {}) {
|
|
48238
48309
|
const method = options.method ?? "GET";
|
|
48239
|
-
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(
|
|
48310
|
+
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(path68);
|
|
48240
48311
|
if (method !== "GET" && !isSearchPost) {
|
|
48241
|
-
throw new OpenSearchError(`Refusing ${method} ${
|
|
48312
|
+
throw new OpenSearchError(`Refusing ${method} ${path68}: this client is read-only. Indexing goes through the indexer, which the user starts from Settings.`);
|
|
48242
48313
|
}
|
|
48243
|
-
const url2 = `${this.base}${
|
|
48314
|
+
const url2 = `${this.base}${path68}`;
|
|
48244
48315
|
const request2 = {
|
|
48245
48316
|
method,
|
|
48246
48317
|
headers: this.headers()
|
|
@@ -48407,11 +48478,11 @@ function collectFields(properties, prefix, out) {
|
|
|
48407
48478
|
return;
|
|
48408
48479
|
for (const [name, raw] of Object.entries(properties)) {
|
|
48409
48480
|
const field2 = raw;
|
|
48410
|
-
const
|
|
48481
|
+
const path68 = prefix.length > 0 ? `${prefix}.${name}` : name;
|
|
48411
48482
|
if (typeof field2.type === "string")
|
|
48412
|
-
out[
|
|
48483
|
+
out[path68] = field2.type;
|
|
48413
48484
|
if (field2.properties !== void 0)
|
|
48414
|
-
collectFields(field2.properties,
|
|
48485
|
+
collectFields(field2.properties, path68, out);
|
|
48415
48486
|
}
|
|
48416
48487
|
}
|
|
48417
48488
|
function describeStatus(status2, url2, body) {
|
|
@@ -48430,23 +48501,23 @@ function describeStatus(status2, url2, body) {
|
|
|
48430
48501
|
var TEXT_TYPES = /* @__PURE__ */ new Set(["text", "match_only_text", "search_as_you_type", "wildcard"]);
|
|
48431
48502
|
var KEYWORD_TYPES = /* @__PURE__ */ new Set(["keyword", "constant_keyword"]);
|
|
48432
48503
|
var NOISE_FIELDS = /* @__PURE__ */ new Set(["@version", "ecs", "tags", "stream", "input", "agent", "host", "event"]);
|
|
48433
|
-
function leafName(
|
|
48434
|
-
const parts =
|
|
48435
|
-
return parts[parts.length - 1] ??
|
|
48504
|
+
function leafName(path68) {
|
|
48505
|
+
const parts = path68.split(".");
|
|
48506
|
+
return parts[parts.length - 1] ?? path68;
|
|
48436
48507
|
}
|
|
48437
48508
|
function selectQueryFields(mapping, limit = 25) {
|
|
48438
48509
|
const text2 = [];
|
|
48439
48510
|
const keyword = [];
|
|
48440
|
-
for (const [
|
|
48441
|
-
if (NOISE_FIELDS.has(leafName(
|
|
48511
|
+
for (const [path68, type] of Object.entries(mapping)) {
|
|
48512
|
+
if (NOISE_FIELDS.has(leafName(path68)) || NOISE_FIELDS.has(path68.split(".")[0] ?? ""))
|
|
48442
48513
|
continue;
|
|
48443
48514
|
if (TEXT_TYPES.has(type)) {
|
|
48444
|
-
text2.push(
|
|
48515
|
+
text2.push(path68);
|
|
48445
48516
|
} else if (KEYWORD_TYPES.has(type)) {
|
|
48446
|
-
const parent =
|
|
48447
|
-
if (
|
|
48517
|
+
const parent = path68.replace(/\.keyword$/, "");
|
|
48518
|
+
if (path68.endsWith(".keyword") && TEXT_TYPES.has(mapping[parent] ?? ""))
|
|
48448
48519
|
continue;
|
|
48449
|
-
keyword.push(
|
|
48520
|
+
keyword.push(path68);
|
|
48450
48521
|
}
|
|
48451
48522
|
}
|
|
48452
48523
|
const byDepth = (a, b) => a.split(".").length - b.split(".").length || a.localeCompare(b);
|
|
@@ -48588,8 +48659,8 @@ var OpenSearchIndexWriter = class {
|
|
|
48588
48659
|
}
|
|
48589
48660
|
return headers;
|
|
48590
48661
|
}
|
|
48591
|
-
async request(
|
|
48592
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
48662
|
+
async request(path68, method, body, signal) {
|
|
48663
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path68}`;
|
|
48593
48664
|
const request2 = { method, headers: this.headers() };
|
|
48594
48665
|
if (body !== void 0) {
|
|
48595
48666
|
if (typeof body === "string") {
|
|
@@ -48803,13 +48874,13 @@ var OpenSearchIndexWriter = class {
|
|
|
48803
48874
|
for (const hit of hits) {
|
|
48804
48875
|
const source = hit._source ?? {};
|
|
48805
48876
|
const vector = source.vector;
|
|
48806
|
-
const
|
|
48807
|
-
if (typeof
|
|
48877
|
+
const path68 = source.path;
|
|
48878
|
+
if (typeof path68 !== "string" || !Array.isArray(vector))
|
|
48808
48879
|
continue;
|
|
48809
48880
|
documents.push({
|
|
48810
48881
|
id: hit._id ?? "",
|
|
48811
48882
|
text: typeof source.text === "string" ? source.text : "",
|
|
48812
|
-
path:
|
|
48883
|
+
path: path68,
|
|
48813
48884
|
startLine: typeof source.startLine === "number" ? source.startLine : 1,
|
|
48814
48885
|
endLine: typeof source.endLine === "number" ? source.endLine : 1,
|
|
48815
48886
|
vector
|
|
@@ -48885,8 +48956,8 @@ var RestTransport = class {
|
|
|
48885
48956
|
* threw would push every caller into catching and re-inspecting an error to find out
|
|
48886
48957
|
* whether it was really an error. `expectOk` is there for the cases that are.
|
|
48887
48958
|
*/
|
|
48888
|
-
async send(
|
|
48889
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
48959
|
+
async send(path68, method, body, signal) {
|
|
48960
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path68}`;
|
|
48890
48961
|
const request2 = { method, headers: this.headers() };
|
|
48891
48962
|
if (body !== void 0)
|
|
48892
48963
|
request2.body = JSON.stringify(body);
|
|
@@ -48912,11 +48983,11 @@ var RestTransport = class {
|
|
|
48912
48983
|
return { status: response.status, body: parsed };
|
|
48913
48984
|
}
|
|
48914
48985
|
/** Sends, and throws unless the status is 2xx. */
|
|
48915
|
-
async expectOk(
|
|
48916
|
-
const result = await this.send(
|
|
48986
|
+
async expectOk(path68, method, body, signal) {
|
|
48987
|
+
const result = await this.send(path68, method, body, signal);
|
|
48917
48988
|
if (result.status < 200 || result.status >= 300) {
|
|
48918
48989
|
const detail = typeof result.body === "string" ? result.body : JSON.stringify(result.body ?? "");
|
|
48919
|
-
throw new VectorStoreError(`${method} ${
|
|
48990
|
+
throw new VectorStoreError(`${method} ${path68} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}` + this.explain(result.body), result.status);
|
|
48920
48991
|
}
|
|
48921
48992
|
return result.body;
|
|
48922
48993
|
}
|
|
@@ -49102,10 +49173,10 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
49102
49173
|
const matches = [];
|
|
49103
49174
|
for (let index = 0; index < ids.length; index++) {
|
|
49104
49175
|
const metadata = metadatas[index] ?? {};
|
|
49105
|
-
const
|
|
49106
|
-
if (
|
|
49176
|
+
const path68 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
49177
|
+
if (path68 === void 0)
|
|
49107
49178
|
continue;
|
|
49108
|
-
if (prefix !== void 0 && prefix.length > 0 && !
|
|
49179
|
+
if (prefix !== void 0 && prefix.length > 0 && !path68.startsWith(prefix))
|
|
49109
49180
|
continue;
|
|
49110
49181
|
if (projectHere && typeof metadata.project === "string" && !options.project?.names.includes(metadata.project))
|
|
49111
49182
|
continue;
|
|
@@ -49119,7 +49190,7 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
49119
49190
|
*/
|
|
49120
49191
|
score: typeof distance === "number" ? 1 / (1 + Math.max(0, distance)) : 0,
|
|
49121
49192
|
text: documents[index] ?? (typeof metadata.text === "string" ? metadata.text : ""),
|
|
49122
|
-
path:
|
|
49193
|
+
path: path68
|
|
49123
49194
|
};
|
|
49124
49195
|
if (typeof metadata.startLine === "number")
|
|
49125
49196
|
match.startLine = metadata.startLine;
|
|
@@ -49230,13 +49301,13 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
49230
49301
|
for (let index = 0; index < ids.length; index++) {
|
|
49231
49302
|
const metadata = result.metadatas?.[index] ?? {};
|
|
49232
49303
|
const vector = result.embeddings?.[index];
|
|
49233
|
-
const
|
|
49234
|
-
if (
|
|
49304
|
+
const path68 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
49305
|
+
if (path68 === void 0 || !Array.isArray(vector))
|
|
49235
49306
|
continue;
|
|
49236
49307
|
documents.push({
|
|
49237
49308
|
id: ids[index] ?? "",
|
|
49238
49309
|
text: result.documents?.[index] ?? "",
|
|
49239
|
-
path:
|
|
49310
|
+
path: path68,
|
|
49240
49311
|
startLine: typeof metadata.startLine === "number" ? metadata.startLine : 1,
|
|
49241
49312
|
endLine: typeof metadata.endLine === "number" ? metadata.endLine : 1,
|
|
49242
49313
|
vector
|
|
@@ -49253,9 +49324,9 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
49253
49324
|
const result = await this.rest.expectOk(`${this.base}/collections/${found2.id}/get`, "POST", { include: ["metadatas"], limit }, options.signal);
|
|
49254
49325
|
const paths = /* @__PURE__ */ new Set();
|
|
49255
49326
|
for (const metadata of result.metadatas ?? []) {
|
|
49256
|
-
const
|
|
49257
|
-
if (typeof
|
|
49258
|
-
paths.add(
|
|
49327
|
+
const path68 = metadata?.path;
|
|
49328
|
+
if (typeof path68 === "string")
|
|
49329
|
+
paths.add(path68);
|
|
49259
49330
|
}
|
|
49260
49331
|
return [...paths];
|
|
49261
49332
|
}
|
|
@@ -49282,14 +49353,14 @@ var MARKER_ID = "5f6d2a41-0000-5000-8000-6c69676874c0";
|
|
|
49282
49353
|
var MARKER_MARK = "light-code";
|
|
49283
49354
|
function toMatch(point) {
|
|
49284
49355
|
const payload = point.payload ?? {};
|
|
49285
|
-
const
|
|
49286
|
-
if (
|
|
49356
|
+
const path68 = typeof payload.path === "string" ? payload.path : void 0;
|
|
49357
|
+
if (path68 === void 0)
|
|
49287
49358
|
return void 0;
|
|
49288
49359
|
const match = {
|
|
49289
49360
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
49290
49361
|
score: typeof point.score === "number" ? point.score : 0,
|
|
49291
49362
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
49292
|
-
path:
|
|
49363
|
+
path: path68
|
|
49293
49364
|
};
|
|
49294
49365
|
if (typeof payload.startLine === "number")
|
|
49295
49366
|
match.startLine = payload.startLine;
|
|
@@ -49483,13 +49554,13 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
49483
49554
|
const documents = [];
|
|
49484
49555
|
for (const point of result.body.result?.points ?? []) {
|
|
49485
49556
|
const payload = point.payload ?? {};
|
|
49486
|
-
const
|
|
49487
|
-
if (
|
|
49557
|
+
const path68 = typeof payload.path === "string" ? payload.path : void 0;
|
|
49558
|
+
if (path68 === void 0 || !Array.isArray(point.vector))
|
|
49488
49559
|
continue;
|
|
49489
49560
|
documents.push({
|
|
49490
49561
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
49491
49562
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
49492
|
-
path:
|
|
49563
|
+
path: path68,
|
|
49493
49564
|
startLine: typeof payload.startLine === "number" ? payload.startLine : 1,
|
|
49494
49565
|
endLine: typeof payload.endLine === "number" ? payload.endLine : 1,
|
|
49495
49566
|
vector: point.vector
|
|
@@ -49516,9 +49587,9 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
49516
49587
|
throw new VectorStoreError(`Could not list "${collection}" (HTTP ${String(result.status)}).` + wrongServerHint("qdrant", result.body, this.rest.label), result.status);
|
|
49517
49588
|
}
|
|
49518
49589
|
for (const point of result.body.result?.points ?? []) {
|
|
49519
|
-
const
|
|
49520
|
-
if (typeof
|
|
49521
|
-
paths.add(
|
|
49590
|
+
const path68 = point.payload?.path;
|
|
49591
|
+
if (typeof path68 === "string")
|
|
49592
|
+
paths.add(path68);
|
|
49522
49593
|
}
|
|
49523
49594
|
offset = result.body.result?.next_page_offset;
|
|
49524
49595
|
if (offset === void 0 || offset === null)
|
|
@@ -50052,8 +50123,8 @@ function teamSkillDocument(skill, body, vector, attribution) {
|
|
|
50052
50123
|
vector
|
|
50053
50124
|
};
|
|
50054
50125
|
}
|
|
50055
|
-
function nameFromPath(
|
|
50056
|
-
return
|
|
50126
|
+
function nameFromPath(path68) {
|
|
50127
|
+
return path68.startsWith("skill:") ? path68.slice("skill:".length) : path68;
|
|
50057
50128
|
}
|
|
50058
50129
|
function toHit(match, self) {
|
|
50059
50130
|
return {
|
|
@@ -53139,8 +53210,8 @@ function createMailCoverageTool(options) {
|
|
|
53139
53210
|
}
|
|
53140
53211
|
};
|
|
53141
53212
|
}
|
|
53142
|
-
function normaliseFolder(
|
|
53143
|
-
return
|
|
53213
|
+
function normaliseFolder(path68) {
|
|
53214
|
+
return path68.toLowerCase().replace(/[\\/]+/g, "\\");
|
|
53144
53215
|
}
|
|
53145
53216
|
function haystackOf(record2) {
|
|
53146
53217
|
return `${record2.subject}
|
|
@@ -53636,7 +53707,7 @@ async function refreshMail(options) {
|
|
|
53636
53707
|
const limit = options.batchLimit ?? 2e3;
|
|
53637
53708
|
const previewChars = options.previewChars ?? 400;
|
|
53638
53709
|
const sinceMs = Date.now() - options.days * 24 * 60 * 60 * 1e3;
|
|
53639
|
-
const harvested = await options.harvest(options.folders.map((
|
|
53710
|
+
const harvested = await options.harvest(options.folders.map((path68) => ({ path: path68, sinceMs })), { limit, previewChars });
|
|
53640
53711
|
const fetched = harvested.messages.map(toRecord);
|
|
53641
53712
|
if (fetched.length === 0) {
|
|
53642
53713
|
return { added: 0, more: false, total: known.length, embedded: 0, backfilled: 0, complete: [] };
|
|
@@ -53677,9 +53748,9 @@ async function syncMail(options) {
|
|
|
53677
53748
|
const backfillDone = await options.store.loadBackfillState();
|
|
53678
53749
|
const limit = options.batchLimit ?? 500;
|
|
53679
53750
|
const previewChars = options.previewChars ?? 400;
|
|
53680
|
-
const forwardRequests = options.folders.map((
|
|
53681
|
-
const mark = marks.get(
|
|
53682
|
-
return mark === void 0 ? { path:
|
|
53751
|
+
const forwardRequests = options.folders.map((path68) => {
|
|
53752
|
+
const mark = marks.get(path68);
|
|
53753
|
+
return mark === void 0 ? { path: path68 } : { path: path68, sinceMs: mark.newest - 1e3 };
|
|
53683
53754
|
});
|
|
53684
53755
|
const forward = await options.harvest(forwardRequests, { limit, previewChars });
|
|
53685
53756
|
let candidates = forward.messages.map(toRecord);
|
|
@@ -53688,15 +53759,15 @@ async function syncMail(options) {
|
|
|
53688
53759
|
let more = forward.truncated;
|
|
53689
53760
|
const remaining = limit - candidates.length;
|
|
53690
53761
|
const floor = options.retentionMonths === void 0 ? void 0 : monthsBefore(options.now ?? Date.now(), options.retentionMonths);
|
|
53691
|
-
const outstanding = options.folders.filter((
|
|
53692
|
-
const atFloor = floor === void 0 ? [] : outstanding.filter((
|
|
53693
|
-
const behind = outstanding.filter((
|
|
53762
|
+
const outstanding = options.folders.filter((path68) => marks.has(path68) && backfillDone[path68] !== true);
|
|
53763
|
+
const atFloor = floor === void 0 ? [] : outstanding.filter((path68) => marks.get(path68).oldest <= floor);
|
|
53764
|
+
const behind = outstanding.filter((path68) => !atFloor.includes(path68));
|
|
53694
53765
|
completed.push(...atFloor);
|
|
53695
53766
|
if (remaining > 0 && behind.length > 0 && options.signal?.aborted !== true) {
|
|
53696
|
-
const backRequests = behind.map((
|
|
53697
|
-
path:
|
|
53767
|
+
const backRequests = behind.map((path68) => ({
|
|
53768
|
+
path: path68,
|
|
53698
53769
|
// Strictly older, so the oldest held message is not fetched again every pass.
|
|
53699
|
-
beforeMs: marks.get(
|
|
53770
|
+
beforeMs: marks.get(path68).oldest,
|
|
53700
53771
|
// And no older than retention wants. The harvest ANDs the two into one window.
|
|
53701
53772
|
...floor === void 0 ? {} : { sinceMs: floor }
|
|
53702
53773
|
}));
|
|
@@ -53704,9 +53775,9 @@ async function syncMail(options) {
|
|
|
53704
53775
|
backfilled = backward.messages.length;
|
|
53705
53776
|
candidates = [...candidates, ...backward.messages.map(toRecord)];
|
|
53706
53777
|
const returnedFor = new Set(backward.messages.map((message6) => message6.folder));
|
|
53707
|
-
for (const
|
|
53708
|
-
if (!returnedFor.has(
|
|
53709
|
-
completed.push(
|
|
53778
|
+
for (const path68 of behind) {
|
|
53779
|
+
if (!returnedFor.has(path68))
|
|
53780
|
+
completed.push(path68);
|
|
53710
53781
|
}
|
|
53711
53782
|
if (backward.truncated || backfilled > 0)
|
|
53712
53783
|
more = true;
|
|
@@ -53714,7 +53785,7 @@ async function syncMail(options) {
|
|
|
53714
53785
|
if (completed.length > 0) {
|
|
53715
53786
|
await options.store.saveBackfillState({
|
|
53716
53787
|
...backfillDone,
|
|
53717
|
-
...Object.fromEntries(completed.map((
|
|
53788
|
+
...Object.fromEntries(completed.map((path68) => [path68, true]))
|
|
53718
53789
|
});
|
|
53719
53790
|
}
|
|
53720
53791
|
const fresh = withoutKnown(candidates, known);
|
|
@@ -54061,14 +54132,14 @@ function formatBytes(size) {
|
|
|
54061
54132
|
return `${(size / (1 << 10)).toFixed(1)}KB`;
|
|
54062
54133
|
return `${String(size)}B`;
|
|
54063
54134
|
}
|
|
54064
|
-
async function readTail(
|
|
54135
|
+
async function readTail(fs48, path68, size, count3) {
|
|
54065
54136
|
let span = Math.min(size, CHUNK);
|
|
54066
54137
|
let text2;
|
|
54067
54138
|
let start;
|
|
54068
54139
|
for (; ; ) {
|
|
54069
54140
|
start = Math.max(0, size - span);
|
|
54070
54141
|
const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
|
|
54071
|
-
text2 = decoder2.write(await
|
|
54142
|
+
text2 = decoder2.write(await fs48.readBytesSlice(path68, start, size)) + decoder2.end();
|
|
54072
54143
|
const enough = text2.split("\n").length > count3;
|
|
54073
54144
|
if (enough || start === 0 || span >= size)
|
|
54074
54145
|
break;
|
|
@@ -54086,7 +54157,7 @@ async function readTail(fs47, path67, size, count3) {
|
|
|
54086
54157
|
hasMoreAfter: false
|
|
54087
54158
|
};
|
|
54088
54159
|
}
|
|
54089
|
-
async function readLineWindow(
|
|
54160
|
+
async function readLineWindow(fs48, path68, size, from, count3) {
|
|
54090
54161
|
const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
|
|
54091
54162
|
const lines2 = [];
|
|
54092
54163
|
let pending = "";
|
|
@@ -54101,7 +54172,7 @@ async function readLineWindow(fs47, path67, size, from, count3) {
|
|
|
54101
54172
|
};
|
|
54102
54173
|
scan: while (position < size) {
|
|
54103
54174
|
const end = Math.min(size, position + CHUNK);
|
|
54104
|
-
pending += decoder2.write(await
|
|
54175
|
+
pending += decoder2.write(await fs48.readBytesSlice(path68, position, end));
|
|
54105
54176
|
position = end;
|
|
54106
54177
|
const parts = pending.split(/\r\n|\r|\n/);
|
|
54107
54178
|
pending = parts.pop() ?? "";
|
|
@@ -54124,13 +54195,13 @@ async function readLineWindow(fs47, path67, size, from, count3) {
|
|
|
54124
54195
|
hasMoreAfter: !reachedEnd || lineNumber > from + lines2.length
|
|
54125
54196
|
};
|
|
54126
54197
|
}
|
|
54127
|
-
async function countLines(
|
|
54198
|
+
async function countLines(fs48, path68, size) {
|
|
54128
54199
|
let newlines = 0;
|
|
54129
54200
|
let position = 0;
|
|
54130
54201
|
let lastByte = -1;
|
|
54131
54202
|
while (position < size) {
|
|
54132
54203
|
const end = Math.min(size, position + CHUNK);
|
|
54133
|
-
const buffer = await
|
|
54204
|
+
const buffer = await fs48.readBytesSlice(path68, position, end);
|
|
54134
54205
|
for (const byte of buffer)
|
|
54135
54206
|
if (byte === 10)
|
|
54136
54207
|
newlines += 1;
|
|
@@ -61590,13 +61661,13 @@ function appendSkillImages(body, images) {
|
|
|
61590
61661
|
const trimmed = body.replace(/\s+$/, "");
|
|
61591
61662
|
return [trimmed, "", "## Images", "", ...missing.map(renderSkillImage)].join("\n");
|
|
61592
61663
|
}
|
|
61593
|
-
async function listSkillImages(skillFilePath,
|
|
61664
|
+
async function listSkillImages(skillFilePath, fs48) {
|
|
61594
61665
|
const asPosix = skillFilePath.split(String.fromCharCode(92)).join("/");
|
|
61595
61666
|
if (!asPosix.toLowerCase().endsWith("/skill.md"))
|
|
61596
61667
|
return [];
|
|
61597
61668
|
const dir = `${skillFilePath.slice(0, skillFilePath.length - "SKILL.md".length)}${SKILL_IMAGE_DIR}`;
|
|
61598
61669
|
try {
|
|
61599
|
-
const entries = await
|
|
61670
|
+
const entries = await fs48.readdir(dir);
|
|
61600
61671
|
return entries.filter((entry) => !entry.isDirectory && skillImageType(entry.name) !== void 0).map((entry) => entry.name).sort();
|
|
61601
61672
|
} catch {
|
|
61602
61673
|
return [];
|
|
@@ -61646,12 +61717,12 @@ function skillFilesDir(skillFilePath) {
|
|
|
61646
61717
|
return void 0;
|
|
61647
61718
|
return `${skillFilePath.slice(0, skillFilePath.length - "SKILL.md".length)}${SKILL_FILE_DIR}`;
|
|
61648
61719
|
}
|
|
61649
|
-
async function listSkillFiles(skillFilePath,
|
|
61720
|
+
async function listSkillFiles(skillFilePath, fs48) {
|
|
61650
61721
|
const dir = skillFilesDir(skillFilePath);
|
|
61651
61722
|
if (dir === void 0)
|
|
61652
61723
|
return [];
|
|
61653
61724
|
try {
|
|
61654
|
-
const entries = await
|
|
61725
|
+
const entries = await fs48.readdir(dir);
|
|
61655
61726
|
return entries.filter((entry) => !entry.isDirectory).map((entry) => entry.name).sort();
|
|
61656
61727
|
} catch {
|
|
61657
61728
|
return [];
|
|
@@ -62185,7 +62256,7 @@ var SHARE_SECTIONS = [
|
|
|
62185
62256
|
id: "workspace",
|
|
62186
62257
|
label: "Workspace behaviour",
|
|
62187
62258
|
description: "Mode, step cap, automatic compaction, retries, folders tools may read, and folders hidden from the @ picker.",
|
|
62188
|
-
keys: ["modeId", "maxIterations", "autoCompact", "connection", "filesystem"],
|
|
62259
|
+
keys: ["modeId", "maxIterations", "autoCompact", "autoHandoff", "unlimitedSteps", "connection", "filesystem"],
|
|
62189
62260
|
machineSpecific: true
|
|
62190
62261
|
},
|
|
62191
62262
|
{
|
|
@@ -62306,9 +62377,9 @@ function secretRefsFor(section, config2) {
|
|
|
62306
62377
|
}
|
|
62307
62378
|
return refs;
|
|
62308
62379
|
}
|
|
62309
|
-
function getPath2(source,
|
|
62380
|
+
function getPath2(source, path68) {
|
|
62310
62381
|
let value = source;
|
|
62311
|
-
for (const part of
|
|
62382
|
+
for (const part of path68.split(".")) {
|
|
62312
62383
|
if (typeof value !== "object" || value === null)
|
|
62313
62384
|
return void 0;
|
|
62314
62385
|
value = value[part];
|
|
@@ -62322,8 +62393,8 @@ function hasValue(value) {
|
|
|
62322
62393
|
return Object.keys(value).length > 0;
|
|
62323
62394
|
return true;
|
|
62324
62395
|
}
|
|
62325
|
-
function setPath(target,
|
|
62326
|
-
const [head, ...rest] =
|
|
62396
|
+
function setPath(target, path68, value) {
|
|
62397
|
+
const [head, ...rest] = path68.split(".");
|
|
62327
62398
|
if (head === void 0)
|
|
62328
62399
|
return;
|
|
62329
62400
|
if (rest.length === 0) {
|
|
@@ -62343,8 +62414,8 @@ function setPath(target, path67, value) {
|
|
|
62343
62414
|
var NESTED_PATHS = SHARE_SECTIONS.flatMap((section) => section.nested ?? []);
|
|
62344
62415
|
function withoutNested(config2) {
|
|
62345
62416
|
const copy = { ...config2 };
|
|
62346
|
-
for (const
|
|
62347
|
-
setPath(copy,
|
|
62417
|
+
for (const path68 of NESTED_PATHS)
|
|
62418
|
+
setPath(copy, path68, void 0);
|
|
62348
62419
|
return copy;
|
|
62349
62420
|
}
|
|
62350
62421
|
function describeSections(config2) {
|
|
@@ -62353,7 +62424,7 @@ function describeSections(config2) {
|
|
|
62353
62424
|
id: section.id,
|
|
62354
62425
|
label: section.label,
|
|
62355
62426
|
description: section.description,
|
|
62356
|
-
present: section.keys.some((key3) => has(owned, key3)) || (section.nested ?? []).some((
|
|
62427
|
+
present: section.keys.some((key3) => has(owned, key3)) || (section.nested ?? []).some((path68) => hasValue(getPath2(config2, path68))),
|
|
62357
62428
|
detail: detailFor(section, config2),
|
|
62358
62429
|
secretRefs: secretRefsFor(section, config2),
|
|
62359
62430
|
...section.machineSpecific === true ? { machineSpecific: true } : {},
|
|
@@ -62374,18 +62445,18 @@ function buildExport(config2, selected) {
|
|
|
62374
62445
|
if (has(config2, key3))
|
|
62375
62446
|
exported[key3] = config2[key3];
|
|
62376
62447
|
}
|
|
62377
|
-
for (const
|
|
62378
|
-
const value = getPath2(config2,
|
|
62448
|
+
for (const path68 of section.nested ?? []) {
|
|
62449
|
+
const value = getPath2(config2, path68);
|
|
62379
62450
|
if (hasValue(value))
|
|
62380
|
-
setPath(exported,
|
|
62451
|
+
setPath(exported, path68, value);
|
|
62381
62452
|
}
|
|
62382
|
-
for (const
|
|
62383
|
-
stripPath(exported,
|
|
62453
|
+
for (const path68 of section.strip ?? [])
|
|
62454
|
+
stripPath(exported, path68);
|
|
62384
62455
|
}
|
|
62385
62456
|
return exported;
|
|
62386
62457
|
}
|
|
62387
|
-
function stripPath(target,
|
|
62388
|
-
const [head, ...rest] =
|
|
62458
|
+
function stripPath(target, path68) {
|
|
62459
|
+
const [head, ...rest] = path68.split(".");
|
|
62389
62460
|
if (head === void 0)
|
|
62390
62461
|
return;
|
|
62391
62462
|
const value = target[head];
|
|
@@ -62413,22 +62484,22 @@ function applyImport(existing, imported, selected) {
|
|
|
62413
62484
|
else
|
|
62414
62485
|
delete merged[key3];
|
|
62415
62486
|
}
|
|
62416
|
-
for (const
|
|
62417
|
-
carryPath(existing, merged,
|
|
62487
|
+
for (const path68 of section.strip ?? []) {
|
|
62488
|
+
carryPath(existing, merged, path68);
|
|
62418
62489
|
}
|
|
62419
62490
|
}
|
|
62420
62491
|
for (const section of SHARE_SECTIONS) {
|
|
62421
62492
|
if (!chosen.has(section.id))
|
|
62422
62493
|
continue;
|
|
62423
|
-
for (const
|
|
62424
|
-
const value = getPath2(imported,
|
|
62425
|
-
setPath(merged,
|
|
62494
|
+
for (const path68 of section.nested ?? []) {
|
|
62495
|
+
const value = getPath2(imported, path68);
|
|
62496
|
+
setPath(merged, path68, hasValue(value) ? value : void 0);
|
|
62426
62497
|
}
|
|
62427
62498
|
}
|
|
62428
62499
|
return merged;
|
|
62429
62500
|
}
|
|
62430
|
-
function carryPath(from, to,
|
|
62431
|
-
const [head, ...rest] =
|
|
62501
|
+
function carryPath(from, to, path68) {
|
|
62502
|
+
const [head, ...rest] = path68.split(".");
|
|
62432
62503
|
if (head === void 0)
|
|
62433
62504
|
return;
|
|
62434
62505
|
const source = from[head];
|
|
@@ -64518,6 +64589,11 @@ async function prepareModelMessages(conversation, provider, tools, options, even
|
|
|
64518
64589
|
const contextWindow = options.contextWindow ?? 0;
|
|
64519
64590
|
const ratio = calibrationFor(options.usageKey ?? "");
|
|
64520
64591
|
let messages = repairUnansweredToolCalls(conversation.toModelMessages());
|
|
64592
|
+
if (options.onContextFull !== void 0 && options.autoCompact === false && options.compactionEnabled !== false && contextWindow > 0 && options.contextWindowKnown !== false && meter !== void 0) {
|
|
64593
|
+
const estimated = scaleBreakdown(computeBreakdown(messages, tools, contextWindow), ratio).total;
|
|
64594
|
+
if (shouldCompact(messages, estimated, contextWindow, { ...options.compaction ?? {}, minimumToCompact: 0 }))
|
|
64595
|
+
meter.contextFull = true;
|
|
64596
|
+
}
|
|
64521
64597
|
if (options.compactionEnabled !== false && options.autoCompact !== false && contextWindow > 0 && options.contextWindowKnown !== false) {
|
|
64522
64598
|
const estimated = scaleBreakdown(computeBreakdown(messages, tools, contextWindow), ratio).total;
|
|
64523
64599
|
if (shouldCompact(messages, estimated, contextWindow, options.compaction ?? {})) {
|
|
@@ -64724,6 +64800,11 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
64724
64800
|
streamOptions.signal = options.signal;
|
|
64725
64801
|
const meter = { estimated: 0, dropped: 0 };
|
|
64726
64802
|
const modelMessages = await prepareModelMessages(conversation, provider, tools, options, events, meter);
|
|
64803
|
+
if (meter.contextFull === true && options.onContextFull !== void 0) {
|
|
64804
|
+
options.onContextFull();
|
|
64805
|
+
events.onDone();
|
|
64806
|
+
return;
|
|
64807
|
+
}
|
|
64727
64808
|
const stallSeconds = options.stallSeconds ?? DEFAULT_STALL_SECONDS;
|
|
64728
64809
|
const maxRetries = Math.max(0, options.retries ?? DEFAULT_RETRIES);
|
|
64729
64810
|
const cancelled = () => options.signal?.aborted === true;
|
|
@@ -64765,6 +64846,11 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
64765
64846
|
events.onContextWindowLearned?.(statedWindow);
|
|
64766
64847
|
}
|
|
64767
64848
|
if (streamError !== void 0 && assistantText.length === 0 && toolCall === void 0 && options.autoCompact === false && isContextOverflow(streamError)) {
|
|
64849
|
+
if (options.onContextFull !== void 0) {
|
|
64850
|
+
options.onContextFull();
|
|
64851
|
+
events.onDone();
|
|
64852
|
+
return;
|
|
64853
|
+
}
|
|
64768
64854
|
events.onError(`${streamError}
|
|
64769
64855
|
|
|
64770
64856
|
The conversation is longer than this model accepts. Press **Compact now** under the token bar to summarise the older part (the saved transcript keeps everything), then send again - or tick "Compact automatically" there to have this done for you. Or press **New chat with a handoff** (beside + at the top): the assistant writes up this chat - goal, decisions, what is done, next steps - and a new chat starts from it, a clean start that keeps the thread.`);
|
|
@@ -64881,7 +64967,7 @@ The conversation is longer than this model accepts, and it could not be shortene
|
|
|
64881
64967
|
}
|
|
64882
64968
|
|
|
64883
64969
|
// ../../packages/core/dist/host/bridge.js
|
|
64884
|
-
var
|
|
64970
|
+
var import_node_crypto21 = require("node:crypto");
|
|
64885
64971
|
|
|
64886
64972
|
// ../../packages/core/dist/atlassian/autosysGateway.js
|
|
64887
64973
|
function withBasicCredentials(auth2, headerName, username, password) {
|
|
@@ -65006,7 +65092,7 @@ function gatewayFromSettings(input, stored) {
|
|
|
65006
65092
|
}
|
|
65007
65093
|
|
|
65008
65094
|
// ../../packages/core/dist/host/bridge.js
|
|
65009
|
-
var
|
|
65095
|
+
var import_node_fs14 = require("node:fs");
|
|
65010
65096
|
var import_node_child_process19 = require("node:child_process");
|
|
65011
65097
|
var import_promises31 = __toESM(require("node:fs/promises"), 1);
|
|
65012
65098
|
|
|
@@ -65790,7 +65876,7 @@ function ignoreDecision(rules, relative, isDirectory2, initial) {
|
|
|
65790
65876
|
}
|
|
65791
65877
|
return ignored;
|
|
65792
65878
|
}
|
|
65793
|
-
async function repositoryWideRules(
|
|
65879
|
+
async function repositoryWideRules(fs48, root, globalIgnoreFile) {
|
|
65794
65880
|
const sources = [
|
|
65795
65881
|
globalIgnoreFile ?? import_node_path29.default.join(process.env["XDG_CONFIG_HOME"] ?? import_node_path29.default.join(import_node_os4.default.homedir(), ".config"), "git", "ignore"),
|
|
65796
65882
|
import_node_path29.default.join(root, ".git", "info", "exclude")
|
|
@@ -65798,16 +65884,16 @@ async function repositoryWideRules(fs47, root, globalIgnoreFile) {
|
|
|
65798
65884
|
const rules = [];
|
|
65799
65885
|
for (const source of sources) {
|
|
65800
65886
|
try {
|
|
65801
|
-
rules.push(...parseIgnoreFile(await
|
|
65887
|
+
rules.push(...parseIgnoreFile(await fs48.readFile(source), ""));
|
|
65802
65888
|
} catch {
|
|
65803
65889
|
}
|
|
65804
65890
|
}
|
|
65805
65891
|
return rules;
|
|
65806
65892
|
}
|
|
65807
|
-
async function walkFiles(
|
|
65893
|
+
async function walkFiles(fs48, root, options) {
|
|
65808
65894
|
const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
|
|
65809
65895
|
const files = [];
|
|
65810
|
-
const baseRules = options.includeIgnored ? [] : await repositoryWideRules(
|
|
65896
|
+
const baseRules = options.includeIgnored ? [] : await repositoryWideRules(fs48, root, options.globalIgnoreFile);
|
|
65811
65897
|
const pending = [{ relative: "", rules: baseRules }];
|
|
65812
65898
|
while (pending.length > 0) {
|
|
65813
65899
|
if (options.signal?.aborted === true)
|
|
@@ -65816,14 +65902,14 @@ async function walkFiles(fs47, root, options) {
|
|
|
65816
65902
|
const absolute = relative.length > 0 ? import_node_path29.default.join(root, ...relative.split("/")) : root;
|
|
65817
65903
|
let entries;
|
|
65818
65904
|
try {
|
|
65819
|
-
entries = await
|
|
65905
|
+
entries = await fs48.readdir(absolute);
|
|
65820
65906
|
} catch {
|
|
65821
65907
|
continue;
|
|
65822
65908
|
}
|
|
65823
65909
|
let rules = inherited;
|
|
65824
65910
|
if (!options.includeIgnored && entries.some((entry) => entry.name === ".gitignore" && !entry.isDirectory)) {
|
|
65825
65911
|
try {
|
|
65826
|
-
const text2 = await
|
|
65912
|
+
const text2 = await fs48.readFile(import_node_path29.default.join(absolute, ".gitignore"));
|
|
65827
65913
|
rules = [...inherited, ...parseIgnoreFile(text2, relative)];
|
|
65828
65914
|
} catch {
|
|
65829
65915
|
}
|
|
@@ -65885,12 +65971,12 @@ function fileFilter(filePattern) {
|
|
|
65885
65971
|
const regex = globToRegExp(glob.startsWith("/") ? glob.slice(1) : glob, anchored);
|
|
65886
65972
|
return (relative) => regex.test(relative) !== exclude;
|
|
65887
65973
|
}
|
|
65888
|
-
async function searchFiles(
|
|
65974
|
+
async function searchFiles(fs48, root, options) {
|
|
65889
65975
|
const regex = compilePattern(options.pattern);
|
|
65890
65976
|
const admits = fileFilter(options.filePattern);
|
|
65891
65977
|
const context = options.contextLines ?? 2;
|
|
65892
65978
|
const maxOutput = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT;
|
|
65893
|
-
const { files, truncated: walkTruncated } = await walkFiles(
|
|
65979
|
+
const { files, truncated: walkTruncated } = await walkFiles(fs48, root, options);
|
|
65894
65980
|
const separator = process.platform === "win32" ? "\\" : "/";
|
|
65895
65981
|
const chunks = [];
|
|
65896
65982
|
let size = 0;
|
|
@@ -65903,10 +65989,10 @@ async function searchFiles(fs47, root, options) {
|
|
|
65903
65989
|
const absolute = import_node_path29.default.join(root, ...relative.split("/"));
|
|
65904
65990
|
let bytes;
|
|
65905
65991
|
try {
|
|
65906
|
-
const stat = await
|
|
65992
|
+
const stat = await fs48.stat(absolute);
|
|
65907
65993
|
if (stat.size > MAX_FILE_BYTES)
|
|
65908
65994
|
continue;
|
|
65909
|
-
bytes = await
|
|
65995
|
+
bytes = await fs48.readBytes(absolute);
|
|
65910
65996
|
} catch {
|
|
65911
65997
|
continue;
|
|
65912
65998
|
}
|
|
@@ -67936,8 +68022,8 @@ function pick2(hubs, name) {
|
|
|
67936
68022
|
|
|
67937
68023
|
// ../../packages/core/dist/host/bridge.js
|
|
67938
68024
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
67939
|
-
var
|
|
67940
|
-
var
|
|
68025
|
+
var import_node_fs15 = require("node:fs");
|
|
68026
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
67941
68027
|
|
|
67942
68028
|
// ../../packages/core/dist/modes/autoGuidance.js
|
|
67943
68029
|
function idiomsFor(environment) {
|
|
@@ -70096,8 +70182,8 @@ var ChangeLedger = class {
|
|
|
70096
70182
|
this.chat = chat;
|
|
70097
70183
|
}
|
|
70098
70184
|
/** Best effort: a ledger that cannot be written must never fail an edit that happened. */
|
|
70099
|
-
record(
|
|
70100
|
-
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(
|
|
70185
|
+
record(path68) {
|
|
70186
|
+
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(path68), at: Date.now() });
|
|
70101
70187
|
void (0, import_promises24.appendFile)(this.file, `${line}
|
|
70102
70188
|
`).catch(() => void 0);
|
|
70103
70189
|
}
|
|
@@ -75104,10 +75190,10 @@ function isSafeSegment(value) {
|
|
|
75104
75190
|
function isSafeTagName(name) {
|
|
75105
75191
|
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("."));
|
|
75106
75192
|
}
|
|
75107
|
-
function encodeRepoPath(
|
|
75108
|
-
const segments =
|
|
75193
|
+
function encodeRepoPath(path68) {
|
|
75194
|
+
const segments = path68.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0);
|
|
75109
75195
|
if (segments.length === 0 || segments.some((segment) => segment === ".." || segment === ".")) {
|
|
75110
|
-
throw new AtlassianError(`"${
|
|
75196
|
+
throw new AtlassianError(`"${path68}" is not a file path inside the repository.`);
|
|
75111
75197
|
}
|
|
75112
75198
|
return segments.map(encodeURIComponent).join("/");
|
|
75113
75199
|
}
|
|
@@ -75192,24 +75278,24 @@ var BitbucketClient = class {
|
|
|
75192
75278
|
* redirect was followed, the login page came back, and the file "could not be read" although
|
|
75193
75279
|
* pull requests on the same repository could. `browse` is REST, so it authenticates like those.
|
|
75194
75280
|
*/
|
|
75195
|
-
async file(repo,
|
|
75196
|
-
const target = encodeRepoPath(
|
|
75281
|
+
async file(repo, path68, ref, signal) {
|
|
75282
|
+
const target = encodeRepoPath(path68);
|
|
75197
75283
|
const lines2 = [];
|
|
75198
75284
|
let start = 0;
|
|
75199
75285
|
for (let page = 0; page < MAX_FILE_PAGES; page += 1) {
|
|
75200
75286
|
const query = new URLSearchParams({ start: String(start), limit: String(FILE_PAGE_LINES) });
|
|
75201
75287
|
if (ref !== void 0 && ref.length > 0)
|
|
75202
75288
|
query.set("at", ref);
|
|
75203
|
-
const body = await this.rest.json(`reading ${
|
|
75289
|
+
const body = await this.rest.json(`reading ${path68}`, `${this.repoPath(repo)}/browse/${target}?${query.toString()}`, { method: "GET" }, signal);
|
|
75204
75290
|
if (body.children !== void 0) {
|
|
75205
75291
|
const names = (body.children.values ?? []).map((child) => {
|
|
75206
75292
|
const name = child.path?.toString ?? child.path?.name ?? "?";
|
|
75207
75293
|
return child.type === "DIRECTORY" ? `${name}/` : name;
|
|
75208
75294
|
});
|
|
75209
|
-
throw new AtlassianError(`${
|
|
75295
|
+
throw new AtlassianError(`${path68} is a folder, not a file. It holds: ${names.join(", ") || "nothing"}.`);
|
|
75210
75296
|
}
|
|
75211
75297
|
if (body.binary === true)
|
|
75212
|
-
throw new AtlassianError(`${
|
|
75298
|
+
throw new AtlassianError(`${path68} is a binary file, so there is no text to read.`);
|
|
75213
75299
|
for (const line of body.lines ?? [])
|
|
75214
75300
|
lines2.push(line.text ?? "");
|
|
75215
75301
|
if (body.isLastPage !== false || body.nextPageStart === void 0 || body.nextPageStart <= start)
|
|
@@ -75320,9 +75406,9 @@ var BitbucketClient = class {
|
|
|
75320
75406
|
return out;
|
|
75321
75407
|
}
|
|
75322
75408
|
/** A file's bytes at `at`, or undefined when it is not there. */
|
|
75323
|
-
async readBytes(repo,
|
|
75409
|
+
async readBytes(repo, path68, at, signal) {
|
|
75324
75410
|
try {
|
|
75325
|
-
return await this.rest.bytes(`reading ${
|
|
75411
|
+
return await this.rest.bytes(`reading ${path68}`, `${this.repoPath(repo)}/raw/${encodeRepoPath(path68)}?${new URLSearchParams({ at }).toString()}`, signal);
|
|
75326
75412
|
} catch (error51) {
|
|
75327
75413
|
if (error51 instanceof AtlassianError && error51.status === 404)
|
|
75328
75414
|
return void 0;
|
|
@@ -76146,8 +76232,8 @@ ${text2.slice(-2e4)}`);
|
|
|
76146
76232
|
}
|
|
76147
76233
|
/** Queues a build, then follows the queue item briefly to learn its number. */
|
|
76148
76234
|
async startBuild(job, parameters, signal) {
|
|
76149
|
-
const
|
|
76150
|
-
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${
|
|
76235
|
+
const path68 = jobPath(job, this.base);
|
|
76236
|
+
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${path68}/buildWithParameters` : `${path68}/build`, parameters ?? {}, signal);
|
|
76151
76237
|
const location = response.headers["location"];
|
|
76152
76238
|
const queueId = location === void 0 ? void 0 : /\/queue\/item\/(\d+)/.exec(location)?.[1];
|
|
76153
76239
|
if (queueId === void 0)
|
|
@@ -76184,10 +76270,10 @@ ${text2.slice(-2e4)}`);
|
|
|
76184
76270
|
}
|
|
76185
76271
|
/** Creates a job from a whole config.xml, in the folder its name gives (`folder/sub/new-job`). */
|
|
76186
76272
|
async createJob(job, xml, signal) {
|
|
76187
|
-
const
|
|
76188
|
-
const cut =
|
|
76189
|
-
const parent =
|
|
76190
|
-
const name = decodeURIComponent(
|
|
76273
|
+
const path68 = jobPath(job, this.base);
|
|
76274
|
+
const cut = path68.lastIndexOf("/job/");
|
|
76275
|
+
const parent = path68.slice(0, cut);
|
|
76276
|
+
const name = decodeURIComponent(path68.slice(cut + "/job/".length));
|
|
76191
76277
|
await this.postBody(`creating ${job}`, `${parent}/createItem?${new URLSearchParams({ name }).toString()}`, xml, "application/xml", signal);
|
|
76192
76278
|
}
|
|
76193
76279
|
/** Replaces a job's config.xml. */
|
|
@@ -76500,14 +76586,14 @@ ${client.base}${jobPath(job, client.base)}/${buildRef(params3.build)}/`
|
|
|
76500
76586
|
};
|
|
76501
76587
|
return tool;
|
|
76502
76588
|
}
|
|
76503
|
-
async function readJenkinsfile(
|
|
76504
|
-
const resolved = await resolveToolPath(context,
|
|
76589
|
+
async function readJenkinsfile(path68, context) {
|
|
76590
|
+
const resolved = await resolveToolPath(context, path68);
|
|
76505
76591
|
if (!resolved.ok)
|
|
76506
76592
|
return { ok: false, message: resolved.message };
|
|
76507
76593
|
try {
|
|
76508
76594
|
return { ok: true, text: await context.fs.readFile(resolved.realPath), realPath: resolved.realPath };
|
|
76509
76595
|
} catch (error51) {
|
|
76510
|
-
return { ok: false, message: `Could not read ${
|
|
76596
|
+
return { ok: false, message: `Could not read ${path68}: ${error51 instanceof Error ? error51.message : String(error51)}` };
|
|
76511
76597
|
}
|
|
76512
76598
|
}
|
|
76513
76599
|
var checkSchema = external_exports.object({
|
|
@@ -77283,9 +77369,9 @@ var AutosysClient = class _AutosysClient {
|
|
|
77283
77369
|
* Something this server may not offer at the documented address: undefined for a 404, so a tool can
|
|
77284
77370
|
* say which setting (`autosys.paths`) points elsewhere, rather than reporting "found nothing".
|
|
77285
77371
|
*/
|
|
77286
|
-
async optional(doing,
|
|
77372
|
+
async optional(doing, path68, signal) {
|
|
77287
77373
|
try {
|
|
77288
|
-
return asList(await this.rest.json(doing,
|
|
77374
|
+
return asList(await this.rest.json(doing, path68, { method: "GET" }, signal));
|
|
77289
77375
|
} catch (error51) {
|
|
77290
77376
|
if (error51 instanceof AtlassianError && error51.status === 404)
|
|
77291
77377
|
return void 0;
|
|
@@ -78588,13 +78674,13 @@ var MonitorHistoryStore = class {
|
|
|
78588
78674
|
if (!isSafeIndexName(index))
|
|
78589
78675
|
throw new MonitorHistoryError(`"${index}" is not a usable index name (lowercase letters, digits, - and _).`);
|
|
78590
78676
|
}
|
|
78591
|
-
async send(method,
|
|
78677
|
+
async send(method, path68, body) {
|
|
78592
78678
|
const headers = { "Content-Type": "application/json" };
|
|
78593
78679
|
const { username, password } = this.connection;
|
|
78594
78680
|
if (username !== void 0 && username.length > 0) {
|
|
78595
78681
|
headers.Authorization = `Basic ${Buffer.from(`${username}:${password ?? ""}`).toString("base64")}`;
|
|
78596
78682
|
}
|
|
78597
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${
|
|
78683
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${path68}`;
|
|
78598
78684
|
const request2 = { method, headers };
|
|
78599
78685
|
if (body !== void 0)
|
|
78600
78686
|
request2.body = JSON.stringify(body);
|
|
@@ -82233,7 +82319,7 @@ function message4(error51) {
|
|
|
82233
82319
|
}
|
|
82234
82320
|
function filesIn(params3) {
|
|
82235
82321
|
return [
|
|
82236
|
-
...(params3.attachments ?? []).map((
|
|
82322
|
+
...(params3.attachments ?? []).map((path68) => ({ path: path68, inline: false })),
|
|
82237
82323
|
...(params3.inlineImages ?? []).map((image) => ({ path: image.path, inline: true }))
|
|
82238
82324
|
];
|
|
82239
82325
|
}
|
|
@@ -82941,6 +83027,50 @@ function mcpToolCacheFile(dir) {
|
|
|
82941
83027
|
return import_node_path49.default.join(dir, MCP_TOOL_CACHE_FILE);
|
|
82942
83028
|
}
|
|
82943
83029
|
|
|
83030
|
+
// ../../packages/core/dist/agent/chatSteering.js
|
|
83031
|
+
var import_node_crypto17 = require("node:crypto");
|
|
83032
|
+
var import_node_fs9 = require("node:fs");
|
|
83033
|
+
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
83034
|
+
function pendingSteeringFile(storageDir, workspaceRoot) {
|
|
83035
|
+
const key3 = (0, import_node_crypto17.createHash)("sha256").update(process.platform === "win32" ? import_node_path50.default.resolve(workspaceRoot).toLowerCase() : import_node_path50.default.resolve(workspaceRoot)).digest("hex").slice(0, 16);
|
|
83036
|
+
return import_node_path50.default.join(storageDir, "pending-chat", `${key3}.json`);
|
|
83037
|
+
}
|
|
83038
|
+
async function writePendingSteering(file2, steering) {
|
|
83039
|
+
if (steering.plan === void 0 && steering.strategy === void 0) {
|
|
83040
|
+
await clearPendingSteering(file2);
|
|
83041
|
+
return;
|
|
83042
|
+
}
|
|
83043
|
+
await writeFileAtomically(file2, JSON.stringify({ version: 1, ...steering }));
|
|
83044
|
+
}
|
|
83045
|
+
async function clearPendingSteering(file2) {
|
|
83046
|
+
await import_node_fs9.promises.rm(file2, { force: true }).catch(() => void 0);
|
|
83047
|
+
}
|
|
83048
|
+
async function readPendingSteering(file2) {
|
|
83049
|
+
let raw;
|
|
83050
|
+
try {
|
|
83051
|
+
raw = JSON.parse(await import_node_fs9.promises.readFile(file2, "utf8"));
|
|
83052
|
+
} catch {
|
|
83053
|
+
return void 0;
|
|
83054
|
+
}
|
|
83055
|
+
if (raw === null || typeof raw !== "object")
|
|
83056
|
+
return void 0;
|
|
83057
|
+
const value = raw;
|
|
83058
|
+
const out = {};
|
|
83059
|
+
if (typeof value["plan"] === "string" && value["plan"].trim().length > 0)
|
|
83060
|
+
out.plan = value["plan"];
|
|
83061
|
+
if (value["planProgress"] !== null && typeof value["planProgress"] === "object")
|
|
83062
|
+
out.planProgress = value["planProgress"];
|
|
83063
|
+
const strategy = strategySchema.safeParse(value["strategy"]);
|
|
83064
|
+
if (strategy.success) {
|
|
83065
|
+
out.strategy = strategy.data;
|
|
83066
|
+
if (value["strategyProgress"] !== null && typeof value["strategyProgress"] === "object")
|
|
83067
|
+
out.strategyProgress = value["strategyProgress"];
|
|
83068
|
+
if (Array.isArray(value["strategyExchanges"]))
|
|
83069
|
+
out.strategyExchanges = value["strategyExchanges"];
|
|
83070
|
+
}
|
|
83071
|
+
return out.plan === void 0 && out.strategy === void 0 ? void 0 : out;
|
|
83072
|
+
}
|
|
83073
|
+
|
|
82944
83074
|
// ../../packages/core/dist/host/approvalGate.js
|
|
82945
83075
|
var WebviewApprovalGate = class {
|
|
82946
83076
|
post;
|
|
@@ -82991,17 +83121,17 @@ var WebviewApprovalGate = class {
|
|
|
82991
83121
|
// ../../packages/core/dist/platform/node/filesystem.js
|
|
82992
83122
|
var import_promises29 = __toESM(require("node:fs/promises"), 1);
|
|
82993
83123
|
var NodeFileSystem = class {
|
|
82994
|
-
async readFile(
|
|
82995
|
-
return import_promises29.default.readFile(
|
|
83124
|
+
async readFile(path68) {
|
|
83125
|
+
return import_promises29.default.readFile(path68, "utf8");
|
|
82996
83126
|
}
|
|
82997
|
-
async readBytes(
|
|
82998
|
-
return import_promises29.default.readFile(
|
|
83127
|
+
async readBytes(path68) {
|
|
83128
|
+
return import_promises29.default.readFile(path68);
|
|
82999
83129
|
}
|
|
83000
|
-
async readBytesSlice(
|
|
83130
|
+
async readBytesSlice(path68, start, end) {
|
|
83001
83131
|
const length = Math.max(0, end - start);
|
|
83002
83132
|
if (length === 0)
|
|
83003
83133
|
return Buffer.alloc(0);
|
|
83004
|
-
const handle = await import_promises29.default.open(
|
|
83134
|
+
const handle = await import_promises29.default.open(path68, "r");
|
|
83005
83135
|
try {
|
|
83006
83136
|
const buffer = Buffer.alloc(length);
|
|
83007
83137
|
const { bytesRead } = await handle.read(buffer, 0, length, start);
|
|
@@ -83010,18 +83140,18 @@ var NodeFileSystem = class {
|
|
|
83010
83140
|
await handle.close();
|
|
83011
83141
|
}
|
|
83012
83142
|
}
|
|
83013
|
-
async writeFile(
|
|
83014
|
-
await import_promises29.default.writeFile(
|
|
83143
|
+
async writeFile(path68, contents) {
|
|
83144
|
+
await import_promises29.default.writeFile(path68, contents, "utf8");
|
|
83015
83145
|
}
|
|
83016
83146
|
/** The counterpart of `readBytes`, and deliberately as bare as `writeFile` beside it. */
|
|
83017
|
-
async writeBytes(
|
|
83018
|
-
await import_promises29.default.writeFile(
|
|
83147
|
+
async writeBytes(path68, contents) {
|
|
83148
|
+
await import_promises29.default.writeFile(path68, contents);
|
|
83019
83149
|
}
|
|
83020
83150
|
async rename(from, to) {
|
|
83021
83151
|
await replaceFile(from, to);
|
|
83022
83152
|
}
|
|
83023
|
-
async stat(
|
|
83024
|
-
const stat = await import_promises29.default.lstat(
|
|
83153
|
+
async stat(path68) {
|
|
83154
|
+
const stat = await import_promises29.default.lstat(path68);
|
|
83025
83155
|
return {
|
|
83026
83156
|
size: stat.size,
|
|
83027
83157
|
mtimeMs: stat.mtimeMs,
|
|
@@ -83030,8 +83160,8 @@ var NodeFileSystem = class {
|
|
|
83030
83160
|
isSymbolicLink: stat.isSymbolicLink()
|
|
83031
83161
|
};
|
|
83032
83162
|
}
|
|
83033
|
-
async readdir(
|
|
83034
|
-
const entries = await import_promises29.default.readdir(
|
|
83163
|
+
async readdir(path68) {
|
|
83164
|
+
const entries = await import_promises29.default.readdir(path68, { withFileTypes: true });
|
|
83035
83165
|
return entries.map((entry) => ({
|
|
83036
83166
|
name: entry.name,
|
|
83037
83167
|
isFile: entry.isFile(),
|
|
@@ -83039,21 +83169,21 @@ var NodeFileSystem = class {
|
|
|
83039
83169
|
isSymbolicLink: entry.isSymbolicLink()
|
|
83040
83170
|
}));
|
|
83041
83171
|
}
|
|
83042
|
-
async exists(
|
|
83172
|
+
async exists(path68) {
|
|
83043
83173
|
try {
|
|
83044
|
-
await import_promises29.default.access(
|
|
83174
|
+
await import_promises29.default.access(path68);
|
|
83045
83175
|
return true;
|
|
83046
83176
|
} catch {
|
|
83047
83177
|
return false;
|
|
83048
83178
|
}
|
|
83049
83179
|
}
|
|
83050
|
-
async mkdir(
|
|
83051
|
-
await import_promises29.default.mkdir(
|
|
83180
|
+
async mkdir(path68) {
|
|
83181
|
+
await import_promises29.default.mkdir(path68, { recursive: true });
|
|
83052
83182
|
}
|
|
83053
83183
|
};
|
|
83054
83184
|
|
|
83055
83185
|
// ../../packages/core/dist/config/project.js
|
|
83056
|
-
var
|
|
83186
|
+
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
83057
83187
|
function configuredProjectName(config2) {
|
|
83058
83188
|
const name = config2?.project?.name?.trim();
|
|
83059
83189
|
return name !== void 0 && name.length > 0 ? name : void 0;
|
|
@@ -83062,7 +83192,7 @@ function projectName(config2, workspaceRoot) {
|
|
|
83062
83192
|
const configured = configuredProjectName(config2);
|
|
83063
83193
|
if (configured !== void 0)
|
|
83064
83194
|
return configured;
|
|
83065
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
83195
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path51.default.basename(import_node_path51.default.resolve(workspaceRoot));
|
|
83066
83196
|
}
|
|
83067
83197
|
function projectSlug(name) {
|
|
83068
83198
|
if (name === void 0)
|
|
@@ -83072,8 +83202,8 @@ function projectSlug(name) {
|
|
|
83072
83202
|
}
|
|
83073
83203
|
|
|
83074
83204
|
// ../../packages/core/dist/rag/renameIndexes.js
|
|
83075
|
-
var
|
|
83076
|
-
var
|
|
83205
|
+
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
83206
|
+
var import_node_fs10 = require("node:fs");
|
|
83077
83207
|
function planIndexRenames(names) {
|
|
83078
83208
|
const plans = [];
|
|
83079
83209
|
for (const kind of ["codebase", "docs", "skills"]) {
|
|
@@ -83125,7 +83255,7 @@ async function copyIndex(options) {
|
|
|
83125
83255
|
async function copyBookkeeping(directory, from, to, storeId) {
|
|
83126
83256
|
let entries;
|
|
83127
83257
|
try {
|
|
83128
|
-
entries = await
|
|
83258
|
+
entries = await import_node_fs10.promises.readdir(directory);
|
|
83129
83259
|
} catch {
|
|
83130
83260
|
return [];
|
|
83131
83261
|
}
|
|
@@ -83136,7 +83266,7 @@ async function copyBookkeeping(directory, from, to, storeId) {
|
|
|
83136
83266
|
continue;
|
|
83137
83267
|
const target = `${to}@${storeId}.${entry.slice(prefix.length)}`;
|
|
83138
83268
|
try {
|
|
83139
|
-
await
|
|
83269
|
+
await import_node_fs10.promises.copyFile(import_node_path52.default.join(directory, entry), import_node_path52.default.join(directory, target), import_node_fs10.constants.COPYFILE_EXCL);
|
|
83140
83270
|
copied.push(target);
|
|
83141
83271
|
} catch {
|
|
83142
83272
|
}
|
|
@@ -83225,7 +83355,7 @@ var NodeTerminal = class {
|
|
|
83225
83355
|
|
|
83226
83356
|
// ../../packages/core/dist/platform/node/taskStore.js
|
|
83227
83357
|
var import_promises30 = __toESM(require("node:fs/promises"), 1);
|
|
83228
|
-
var
|
|
83358
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
83229
83359
|
|
|
83230
83360
|
// ../../packages/core/dist/history/types.js
|
|
83231
83361
|
function taskSummary(task) {
|
|
@@ -83248,7 +83378,7 @@ var JsonTaskStore = class {
|
|
|
83248
83378
|
constructor(globalStoragePath, truncationStore, logger) {
|
|
83249
83379
|
this.truncationStore = truncationStore;
|
|
83250
83380
|
this.logger = logger;
|
|
83251
|
-
this.directory =
|
|
83381
|
+
this.directory = import_node_path53.default.join(globalStoragePath, "tasks");
|
|
83252
83382
|
}
|
|
83253
83383
|
async list(workspaceRoot) {
|
|
83254
83384
|
const index = await this.readIndex();
|
|
@@ -83297,11 +83427,11 @@ var JsonTaskStore = class {
|
|
|
83297
83427
|
await this.writeIndex(index.filter((entry) => entry.id !== id));
|
|
83298
83428
|
}
|
|
83299
83429
|
fileFor(id) {
|
|
83300
|
-
return
|
|
83430
|
+
return import_node_path53.default.join(this.directory, `${id}.json`);
|
|
83301
83431
|
}
|
|
83302
83432
|
async readIndex() {
|
|
83303
83433
|
try {
|
|
83304
|
-
const raw = await import_promises30.default.readFile(
|
|
83434
|
+
const raw = await import_promises30.default.readFile(import_node_path53.default.join(this.directory, INDEX_FILE), "utf8");
|
|
83305
83435
|
const parsed = JSON.parse(raw);
|
|
83306
83436
|
if (Array.isArray(parsed))
|
|
83307
83437
|
return parsed.filter(isIndexEntry);
|
|
@@ -83336,7 +83466,7 @@ var JsonTaskStore = class {
|
|
|
83336
83466
|
}
|
|
83337
83467
|
async writeIndex(entries) {
|
|
83338
83468
|
await import_promises30.default.mkdir(this.directory, { recursive: true });
|
|
83339
|
-
const target =
|
|
83469
|
+
const target = import_node_path53.default.join(this.directory, INDEX_FILE);
|
|
83340
83470
|
const temporary = `${target}.tmp`;
|
|
83341
83471
|
await import_promises30.default.writeFile(temporary, JSON.stringify(entries, null, 2), "utf8");
|
|
83342
83472
|
await replaceFile(temporary, target);
|
|
@@ -83380,8 +83510,8 @@ function isRecord3(value) {
|
|
|
83380
83510
|
}
|
|
83381
83511
|
|
|
83382
83512
|
// ../../packages/core/dist/usage/store.js
|
|
83383
|
-
var
|
|
83384
|
-
var
|
|
83513
|
+
var import_node_fs11 = require("node:fs");
|
|
83514
|
+
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
83385
83515
|
|
|
83386
83516
|
// ../../packages/core/dist/s3/keys.js
|
|
83387
83517
|
function normalisePrefix(prefix) {
|
|
@@ -83514,7 +83644,7 @@ var FolderShardStore = class {
|
|
|
83514
83644
|
await this.ask({ action: "write", user: shardSegment(shard.user), day: shard.day, instance: shard.instance, events });
|
|
83515
83645
|
return;
|
|
83516
83646
|
}
|
|
83517
|
-
await this.writeAtomically(
|
|
83647
|
+
await this.writeAtomically(import_node_path54.default.join(this.root, shardSegment(shard.user), `${shard.day}__${shard.instance}.jsonl`), shardText(events));
|
|
83518
83648
|
}
|
|
83519
83649
|
async read(fromDay, toDay) {
|
|
83520
83650
|
this.lastProblems = [];
|
|
@@ -83534,8 +83664,8 @@ var FolderShardStore = class {
|
|
|
83534
83664
|
}
|
|
83535
83665
|
const files = await this.listFiles();
|
|
83536
83666
|
const wanted = selectShards(files, fromDay, toDay);
|
|
83537
|
-
const texts = await pooled(wanted, 8, (file2) =>
|
|
83538
|
-
this.lastProblems.push(`${
|
|
83667
|
+
const texts = await pooled(wanted, 8, (file2) => import_node_fs11.promises.readFile(import_node_path54.default.join(this.root, file2.user, file2.name), "utf8").catch((error51) => {
|
|
83668
|
+
this.lastProblems.push(`${import_node_path54.default.join(this.root, file2.user, file2.name)}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
83539
83669
|
return "";
|
|
83540
83670
|
}));
|
|
83541
83671
|
return texts.flatMap(parseUsageLines);
|
|
@@ -83544,7 +83674,7 @@ var FolderShardStore = class {
|
|
|
83544
83674
|
async listFiles() {
|
|
83545
83675
|
let users;
|
|
83546
83676
|
try {
|
|
83547
|
-
users = (await
|
|
83677
|
+
users = (await import_node_fs11.promises.readdir(this.root, { withFileTypes: true })).filter((entry) => entry.isDirectory() && entry.name !== "_profiles").map((entry) => entry.name);
|
|
83548
83678
|
} catch (error51) {
|
|
83549
83679
|
if (error51.code === "ENOENT")
|
|
83550
83680
|
return [];
|
|
@@ -83552,10 +83682,10 @@ var FolderShardStore = class {
|
|
|
83552
83682
|
}
|
|
83553
83683
|
const files = [];
|
|
83554
83684
|
for (const user of users) {
|
|
83555
|
-
const folder =
|
|
83685
|
+
const folder = import_node_path54.default.join(this.root, user);
|
|
83556
83686
|
let names;
|
|
83557
83687
|
try {
|
|
83558
|
-
names = await
|
|
83688
|
+
names = await import_node_fs11.promises.readdir(folder);
|
|
83559
83689
|
} catch (error51) {
|
|
83560
83690
|
names = [];
|
|
83561
83691
|
this.lastProblems.push(`${folder}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -83571,7 +83701,7 @@ var FolderShardStore = class {
|
|
|
83571
83701
|
}
|
|
83572
83702
|
async readShard(shard) {
|
|
83573
83703
|
try {
|
|
83574
|
-
return parseUsageLines(await
|
|
83704
|
+
return parseUsageLines(await import_node_fs11.promises.readFile(import_node_path54.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), "utf8"));
|
|
83575
83705
|
} catch (error51) {
|
|
83576
83706
|
if (error51.code === "ENOENT")
|
|
83577
83707
|
return void 0;
|
|
@@ -83579,10 +83709,10 @@ var FolderShardStore = class {
|
|
|
83579
83709
|
}
|
|
83580
83710
|
}
|
|
83581
83711
|
async putMonth(shard, events) {
|
|
83582
|
-
await this.writeAtomically(
|
|
83712
|
+
await this.writeAtomically(import_node_path54.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), shardText(events));
|
|
83583
83713
|
}
|
|
83584
83714
|
async removeShard(shard) {
|
|
83585
|
-
await
|
|
83715
|
+
await import_node_fs11.promises.rm(import_node_path54.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), { force: true });
|
|
83586
83716
|
}
|
|
83587
83717
|
async putProfile(user, profile) {
|
|
83588
83718
|
this.profilesFromRead = void 0;
|
|
@@ -83590,7 +83720,7 @@ var FolderShardStore = class {
|
|
|
83590
83720
|
await this.ask({ action: "writeProfile", user: shardSegment(user), profile: cleanProfile(profile) });
|
|
83591
83721
|
return;
|
|
83592
83722
|
}
|
|
83593
|
-
await this.writeAtomically(
|
|
83723
|
+
await this.writeAtomically(import_node_path54.default.join(this.root, "_profiles", `${shardSegment(user)}.json`), JSON.stringify(cleanProfile(profile)));
|
|
83594
83724
|
}
|
|
83595
83725
|
async readProfiles() {
|
|
83596
83726
|
if (this.profilesFromRead !== void 0)
|
|
@@ -83599,13 +83729,13 @@ var FolderShardStore = class {
|
|
|
83599
83729
|
await this.read("9999-12-31", "9999-12-31");
|
|
83600
83730
|
return this.profilesFromRead ?? {};
|
|
83601
83731
|
}
|
|
83602
|
-
const folder =
|
|
83732
|
+
const folder = import_node_path54.default.join(this.root, "_profiles");
|
|
83603
83733
|
const profiles = {};
|
|
83604
|
-
for (const name of await
|
|
83734
|
+
for (const name of await import_node_fs11.promises.readdir(folder).catch(() => [])) {
|
|
83605
83735
|
if (!name.endsWith(".json"))
|
|
83606
83736
|
continue;
|
|
83607
83737
|
try {
|
|
83608
|
-
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await
|
|
83738
|
+
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs11.promises.readFile(import_node_path54.default.join(folder, name), "utf8")));
|
|
83609
83739
|
} catch {
|
|
83610
83740
|
}
|
|
83611
83741
|
}
|
|
@@ -84420,8 +84550,8 @@ function usageCollectionOn(config2, choice) {
|
|
|
84420
84550
|
}
|
|
84421
84551
|
|
|
84422
84552
|
// ../../packages/core/dist/usage/backfill.js
|
|
84423
|
-
var
|
|
84424
|
-
var
|
|
84553
|
+
var import_node_fs12 = require("node:fs");
|
|
84554
|
+
var import_node_path55 = __toESM(require("node:path"), 1);
|
|
84425
84555
|
function comparablePath(value) {
|
|
84426
84556
|
return value.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
84427
84557
|
}
|
|
@@ -84431,7 +84561,7 @@ function eventsFromTask(task, context) {
|
|
|
84431
84561
|
return [];
|
|
84432
84562
|
const created = typeof task.createdAt === "number" && task.createdAt <= updated ? task.createdAt : updated;
|
|
84433
84563
|
const root = typeof task.workspaceRoot === "string" ? task.workspaceRoot : void 0;
|
|
84434
|
-
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ?
|
|
84564
|
+
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ? import_node_path55.default.basename(root.replace(/\\/g, "/")) : void 0;
|
|
84435
84565
|
const skillsByPath = new Map(context.skills.map((skill) => [comparablePath(skill.filePath), skill]));
|
|
84436
84566
|
const skip = new Set(context.skip);
|
|
84437
84567
|
const calls = [];
|
|
@@ -84468,7 +84598,7 @@ function eventsFromTask(task, context) {
|
|
|
84468
84598
|
let skill;
|
|
84469
84599
|
if (call.name === "read_file" && typeof call.args["path"] === "string") {
|
|
84470
84600
|
const requested2 = call.args["path"];
|
|
84471
|
-
const absolute =
|
|
84601
|
+
const absolute = import_node_path55.default.isAbsolute(requested2) || /^[A-Za-z]:[\\/]/.test(requested2) || root === void 0 ? requested2 : import_node_path55.default.join(root, requested2);
|
|
84472
84602
|
skill = skillsByPath.get(comparablePath(absolute));
|
|
84473
84603
|
}
|
|
84474
84604
|
if (call.name === "use_skill_file" && typeof call.args["skill"] === "string") {
|
|
@@ -84505,7 +84635,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
84505
84635
|
}
|
|
84506
84636
|
let names;
|
|
84507
84637
|
try {
|
|
84508
|
-
names = (await
|
|
84638
|
+
names = (await import_node_fs12.promises.readdir(tasksDir)).filter((name) => name.endsWith(".json") && name !== "index.json");
|
|
84509
84639
|
} catch {
|
|
84510
84640
|
return { events: [], tasks: 0, unreadable: 0, via: "node" };
|
|
84511
84641
|
}
|
|
@@ -84513,7 +84643,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
84513
84643
|
let unreadable = 0;
|
|
84514
84644
|
for (const name of names) {
|
|
84515
84645
|
try {
|
|
84516
|
-
events.push(...eventsFromTask(JSON.parse(await
|
|
84646
|
+
events.push(...eventsFromTask(JSON.parse(await import_node_fs12.promises.readFile(import_node_path55.default.join(tasksDir, name), "utf8")), context));
|
|
84517
84647
|
} catch {
|
|
84518
84648
|
unreadable++;
|
|
84519
84649
|
}
|
|
@@ -84521,24 +84651,24 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
84521
84651
|
return { events, tasks: names.length, unreadable, via: "node" };
|
|
84522
84652
|
}
|
|
84523
84653
|
async function backfillOnce(options) {
|
|
84524
|
-
const doneFile =
|
|
84654
|
+
const doneFile = import_node_path55.default.join(options.usageDir, "backfill.json");
|
|
84525
84655
|
for (const file2 of [doneFile, ...options.legacyDoneFile !== void 0 ? [options.legacyDoneFile] : []]) {
|
|
84526
|
-
if (await
|
|
84656
|
+
if (await import_node_fs12.promises.stat(file2).then(() => true, () => false))
|
|
84527
84657
|
return { ran: false };
|
|
84528
84658
|
}
|
|
84529
|
-
await
|
|
84530
|
-
const startFile =
|
|
84659
|
+
await import_node_fs12.promises.mkdir(options.usageDir, { recursive: true });
|
|
84660
|
+
const startFile = import_node_path55.default.join(options.usageDir, "backfill-start.json");
|
|
84531
84661
|
let before;
|
|
84532
84662
|
try {
|
|
84533
84663
|
before = (options.now ?? Date.now)();
|
|
84534
|
-
await
|
|
84664
|
+
await import_node_fs12.promises.writeFile(startFile, JSON.stringify({ before }), { encoding: "utf8", flag: "wx" });
|
|
84535
84665
|
} catch (error51) {
|
|
84536
84666
|
if (error51.code !== "EEXIST")
|
|
84537
84667
|
throw error51;
|
|
84538
84668
|
let claimed;
|
|
84539
84669
|
for (let attempt = 0; attempt < 40 && claimed === void 0; attempt++) {
|
|
84540
84670
|
try {
|
|
84541
|
-
const parsed = JSON.parse(await
|
|
84671
|
+
const parsed = JSON.parse(await import_node_fs12.promises.readFile(startFile, "utf8"));
|
|
84542
84672
|
if (typeof parsed.before === "number")
|
|
84543
84673
|
claimed = parsed.before;
|
|
84544
84674
|
} catch {
|
|
@@ -84833,7 +84963,7 @@ async function lookupDirectory(names, options = {}) {
|
|
|
84833
84963
|
}
|
|
84834
84964
|
|
|
84835
84965
|
// ../../packages/core/dist/observers/auditIndex.js
|
|
84836
|
-
var
|
|
84966
|
+
var import_node_crypto18 = require("node:crypto");
|
|
84837
84967
|
var MAPPING2 = {
|
|
84838
84968
|
mappings: {
|
|
84839
84969
|
dynamic: false,
|
|
@@ -84881,7 +85011,7 @@ function recordText(record2) {
|
|
|
84881
85011
|
return parts.join("\n").slice(0, 2e4);
|
|
84882
85012
|
}
|
|
84883
85013
|
function recordId(record2) {
|
|
84884
|
-
return (0,
|
|
85014
|
+
return (0, import_node_crypto18.createHash)("sha256").update(JSON.stringify(record2)).digest("hex").slice(0, 32);
|
|
84885
85015
|
}
|
|
84886
85016
|
var AuditIndex = class {
|
|
84887
85017
|
http;
|
|
@@ -84895,13 +85025,13 @@ var AuditIndex = class {
|
|
|
84895
85025
|
if (!isSafeIndexName(index))
|
|
84896
85026
|
throw new Error(`"${index}" is not a usable index name (lowercase letters, digits, - and _).`);
|
|
84897
85027
|
}
|
|
84898
|
-
async send(method,
|
|
85028
|
+
async send(method, path68, body, contentType2 = "application/json") {
|
|
84899
85029
|
const headers = { "Content-Type": contentType2 };
|
|
84900
85030
|
const { username, password } = this.connection;
|
|
84901
85031
|
if (username !== void 0 && username.length > 0) {
|
|
84902
85032
|
headers.Authorization = `Basic ${Buffer.from(`${username}:${password ?? ""}`).toString("base64")}`;
|
|
84903
85033
|
}
|
|
84904
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${
|
|
85034
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${path68}`;
|
|
84905
85035
|
const request2 = { method, headers };
|
|
84906
85036
|
if (body !== void 0)
|
|
84907
85037
|
request2.body = body;
|
|
@@ -84995,20 +85125,20 @@ var AuditIndex = class {
|
|
|
84995
85125
|
};
|
|
84996
85126
|
|
|
84997
85127
|
// ../../packages/core/dist/observers/journal.js
|
|
84998
|
-
var
|
|
84999
|
-
var
|
|
85000
|
-
var
|
|
85128
|
+
var import_node_crypto19 = require("node:crypto");
|
|
85129
|
+
var import_node_fs13 = require("node:fs");
|
|
85130
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
85001
85131
|
function auditRoot(storageDir) {
|
|
85002
|
-
return
|
|
85132
|
+
return import_node_path56.default.join(storageDir, "audit");
|
|
85003
85133
|
}
|
|
85004
85134
|
function workspaceAuditFolder(workspace) {
|
|
85005
|
-
const resolved =
|
|
85135
|
+
const resolved = import_node_path56.default.resolve(workspace);
|
|
85006
85136
|
const key3 = process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
85007
|
-
const base =
|
|
85008
|
-
return `${base}-${(0,
|
|
85137
|
+
const base = import_node_path56.default.basename(key3).replace(/[^A-Za-z0-9._-]+/g, "-").slice(0, 40) || "workspace";
|
|
85138
|
+
return `${base}-${(0, import_node_crypto19.createHash)("sha256").update(key3).digest("hex").slice(0, 10)}`;
|
|
85009
85139
|
}
|
|
85010
85140
|
function newSessionId() {
|
|
85011
|
-
return `${Date.now().toString(36)}-${(0,
|
|
85141
|
+
return `${Date.now().toString(36)}-${(0, import_node_crypto19.randomBytes)(4).toString("hex")}`;
|
|
85012
85142
|
}
|
|
85013
85143
|
function day(at) {
|
|
85014
85144
|
const d = new Date(at);
|
|
@@ -85020,17 +85150,17 @@ var AuditJournal = class {
|
|
|
85020
85150
|
folder;
|
|
85021
85151
|
constructor(storageDir, workspace, session) {
|
|
85022
85152
|
this.session = session;
|
|
85023
|
-
this.folder =
|
|
85153
|
+
this.folder = import_node_path56.default.join(auditRoot(storageDir), workspaceAuditFolder(workspace));
|
|
85024
85154
|
}
|
|
85025
85155
|
/** Appends in order; a failure is reported to `onError` and never blocks the next record. */
|
|
85026
85156
|
append(record2, onError) {
|
|
85027
85157
|
const line = `${JSON.stringify(record2)}
|
|
85028
85158
|
`;
|
|
85029
|
-
const file2 =
|
|
85159
|
+
const file2 = import_node_path56.default.join(this.folder, `${day(record2.at)}__${this.session}.jsonl`);
|
|
85030
85160
|
this.chain = this.chain.then(async () => {
|
|
85031
85161
|
try {
|
|
85032
|
-
await
|
|
85033
|
-
await
|
|
85162
|
+
await import_node_fs13.promises.mkdir(this.folder, { recursive: true });
|
|
85163
|
+
await import_node_fs13.promises.appendFile(file2, line, "utf8");
|
|
85034
85164
|
} catch (error51) {
|
|
85035
85165
|
onError(error51);
|
|
85036
85166
|
}
|
|
@@ -85046,11 +85176,11 @@ async function pruneAudit(storageDir, days, now = Date.now()) {
|
|
|
85046
85176
|
const cutoff = day(now - days * 864e5);
|
|
85047
85177
|
let removed = 0;
|
|
85048
85178
|
const root = auditRoot(storageDir);
|
|
85049
|
-
for (const folder of await
|
|
85050
|
-
for (const name of await
|
|
85179
|
+
for (const folder of await import_node_fs13.promises.readdir(root).catch(() => [])) {
|
|
85180
|
+
for (const name of await import_node_fs13.promises.readdir(import_node_path56.default.join(root, folder)).catch(() => [])) {
|
|
85051
85181
|
const fileDay = /^(\d{4}-\d{2}-\d{2})__/.exec(name)?.[1];
|
|
85052
85182
|
if (fileDay !== void 0 && fileDay < cutoff) {
|
|
85053
|
-
await
|
|
85183
|
+
await import_node_fs13.promises.rm(import_node_path56.default.join(root, folder, name), { force: true }).then(() => removed += 1, () => void 0);
|
|
85054
85184
|
}
|
|
85055
85185
|
}
|
|
85056
85186
|
}
|
|
@@ -85058,12 +85188,12 @@ async function pruneAudit(storageDir, days, now = Date.now()) {
|
|
|
85058
85188
|
}
|
|
85059
85189
|
async function readAudit(storageDir, workspace, query) {
|
|
85060
85190
|
const root = auditRoot(storageDir);
|
|
85061
|
-
const folders = query.allWorkspaces === true || workspace === void 0 ? await
|
|
85191
|
+
const folders = query.allWorkspaces === true || workspace === void 0 ? await import_node_fs13.promises.readdir(root).catch(() => []) : [workspaceAuditFolder(workspace)];
|
|
85062
85192
|
const fromDay = query.from !== void 0 ? day(query.from) : void 0;
|
|
85063
85193
|
const untilDay = query.until !== void 0 ? day(query.until) : void 0;
|
|
85064
85194
|
const files = [];
|
|
85065
85195
|
for (const folder of folders) {
|
|
85066
|
-
for (const name of await
|
|
85196
|
+
for (const name of await import_node_fs13.promises.readdir(import_node_path56.default.join(root, folder)).catch(() => [])) {
|
|
85067
85197
|
const fileDay = /^(\d{4}-\d{2}-\d{2})__(.+)\.jsonl$/.exec(name);
|
|
85068
85198
|
if (fileDay === null)
|
|
85069
85199
|
continue;
|
|
@@ -85073,7 +85203,7 @@ async function readAudit(storageDir, workspace, query) {
|
|
|
85073
85203
|
continue;
|
|
85074
85204
|
if (query.session !== void 0 && fileDay[2] !== query.session)
|
|
85075
85205
|
continue;
|
|
85076
|
-
files.push(
|
|
85206
|
+
files.push(import_node_path56.default.join(root, folder, name));
|
|
85077
85207
|
}
|
|
85078
85208
|
}
|
|
85079
85209
|
const needle = query.contains?.toLowerCase();
|
|
@@ -85083,7 +85213,7 @@ async function readAudit(storageDir, workspace, query) {
|
|
|
85083
85213
|
for (const file2 of files) {
|
|
85084
85214
|
let text2;
|
|
85085
85215
|
try {
|
|
85086
|
-
text2 = await
|
|
85216
|
+
text2 = await import_node_fs13.promises.readFile(file2, "utf8");
|
|
85087
85217
|
} catch (error51) {
|
|
85088
85218
|
unreadable.push(`${file2}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
85089
85219
|
continue;
|
|
@@ -86099,7 +86229,7 @@ Not in the strategy, so left alone: ${unknown2.join(", ")}` : "")
|
|
|
86099
86229
|
}
|
|
86100
86230
|
|
|
86101
86231
|
// ../../packages/core/dist/team/admins.js
|
|
86102
|
-
var
|
|
86232
|
+
var import_node_crypto20 = require("node:crypto");
|
|
86103
86233
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
86104
86234
|
function windowsUserId() {
|
|
86105
86235
|
return normaliseUserId(import_node_os6.default.userInfo().username);
|
|
@@ -86169,13 +86299,13 @@ var TeamStore = class {
|
|
|
86169
86299
|
if (!isSafeIndexName(index))
|
|
86170
86300
|
throw new TeamStoreError(`"${index}" is not a usable index name (lowercase letters, digits, - and _).`);
|
|
86171
86301
|
}
|
|
86172
|
-
async send(method,
|
|
86302
|
+
async send(method, path68, body) {
|
|
86173
86303
|
const headers = { "Content-Type": "application/json" };
|
|
86174
86304
|
const { username, password } = this.connection;
|
|
86175
86305
|
if (username !== void 0 && username.length > 0) {
|
|
86176
86306
|
headers.Authorization = `Basic ${Buffer.from(`${username}:${password ?? ""}`).toString("base64")}`;
|
|
86177
86307
|
}
|
|
86178
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${
|
|
86308
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${path68}`;
|
|
86179
86309
|
const request2 = { method, headers };
|
|
86180
86310
|
if (body !== void 0)
|
|
86181
86311
|
request2.body = JSON.stringify(body);
|
|
@@ -86279,7 +86409,7 @@ var TeamStore = class {
|
|
|
86279
86409
|
}
|
|
86280
86410
|
async submit(review) {
|
|
86281
86411
|
await this.ensureIndex();
|
|
86282
|
-
const id = `review:${(0,
|
|
86412
|
+
const id = `review:${(0, import_node_crypto20.randomUUID)()}`;
|
|
86283
86413
|
const { status: status2, json: json2 } = await this.send("PUT", `/_create/${encodeURIComponent(id)}?refresh=true`, {
|
|
86284
86414
|
type: "review",
|
|
86285
86415
|
kind: review.kind,
|
|
@@ -86452,8 +86582,8 @@ function wireChatBridge(services) {
|
|
|
86452
86582
|
const workspaceBranch = workspaceRoot !== void 0 ? currentBranchOf(workspaceRoot) : void 0;
|
|
86453
86583
|
const machineApprovals = services.machineApprovalsFile !== void 0 ? new FileMachineApprovals(services.machineApprovalsFile) : void 0;
|
|
86454
86584
|
const mirrorRoot = services.mirrorRoot ?? storageDir;
|
|
86455
|
-
const personalSkillsDir = services.personalDir !== void 0 ?
|
|
86456
|
-
const personalToolsDir = services.personalDir !== void 0 ?
|
|
86585
|
+
const personalSkillsDir = services.personalDir !== void 0 ? import_node_path57.default.join(services.personalDir, "skills") : void 0;
|
|
86586
|
+
const personalToolsDir = services.personalDir !== void 0 ? import_node_path57.default.join(services.personalDir, "tools") : void 0;
|
|
86457
86587
|
const logger = new Logger({ level: "debug", sink: services.logSink });
|
|
86458
86588
|
let fastFsOps;
|
|
86459
86589
|
const fastFsAnswered = services.fastFs === void 0 ? Promise.resolve(void 0) : fastFsCapabilities(services.fastFs).then((answer) => {
|
|
@@ -86475,14 +86605,14 @@ function wireChatBridge(services) {
|
|
|
86475
86605
|
let cachedSecretValues = [];
|
|
86476
86606
|
const droppedFilesRoot2 = droppedFilesRoot();
|
|
86477
86607
|
const mailAttachmentsRoot2 = mailAttachmentsRoot();
|
|
86478
|
-
const droppedFilesDir =
|
|
86479
|
-
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(
|
|
86608
|
+
const droppedFilesDir = import_node_path57.default.join(droppedFilesRoot2, (0, import_node_crypto21.randomUUID)().slice(0, 8));
|
|
86609
|
+
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(import_node_path57.default.join(storageDir, "tool-results"), () => cachedSecretValues));
|
|
86480
86610
|
const taskStore = new JsonTaskStore(storageDir, truncationStore, logger);
|
|
86481
86611
|
const manifestsRoot = services.codebaseDir ?? storageDir;
|
|
86482
86612
|
const codebaseInstructionsFile = codebaseInstructionsPath({ codebaseDir: services.codebaseDir, storageDir, workspaceRoot: projectRoot });
|
|
86483
86613
|
if (services.codebaseDir !== void 0) {
|
|
86484
|
-
const shared =
|
|
86485
|
-
void import_promises31.default.access(shared).catch(() => import_promises31.default.cp(
|
|
86614
|
+
const shared = import_node_path57.default.join(services.codebaseDir, "index-manifests");
|
|
86615
|
+
void import_promises31.default.access(shared).catch(() => import_promises31.default.cp(import_node_path57.default.join(storageDir, "index-manifests"), shared, { recursive: true, errorOnExist: false, force: false })).catch(() => void 0);
|
|
86486
86616
|
}
|
|
86487
86617
|
const python = new PythonManager({
|
|
86488
86618
|
workspaceRoot,
|
|
@@ -86660,7 +86790,7 @@ ${preview.text}` } : {}
|
|
|
86660
86790
|
}
|
|
86661
86791
|
return gitCheck.answer;
|
|
86662
86792
|
}
|
|
86663
|
-
const defaultSkillsDir = workspaceRoot !== void 0 ?
|
|
86793
|
+
const defaultSkillsDir = workspaceRoot !== void 0 ? import_node_path57.default.join(workspaceRoot, ".lightcode", "skills") : void 0;
|
|
86664
86794
|
let skillsDir = defaultSkillsDir;
|
|
86665
86795
|
let localSkillsDir = defaultSkillsDir;
|
|
86666
86796
|
let extraSkillDirs = [];
|
|
@@ -86683,9 +86813,9 @@ ${preview.text}` } : {}
|
|
|
86683
86813
|
const trimmed = entry.trim();
|
|
86684
86814
|
if (trimmed.length === 0)
|
|
86685
86815
|
return void 0;
|
|
86686
|
-
if (
|
|
86687
|
-
return
|
|
86688
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
86816
|
+
if (import_node_path57.default.isAbsolute(trimmed))
|
|
86817
|
+
return import_node_path57.default.resolve(trimmed);
|
|
86818
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path57.default.resolve(workspaceRoot, trimmed);
|
|
86689
86819
|
}
|
|
86690
86820
|
function skillSearchPath() {
|
|
86691
86821
|
return [skillsDir, ...extraSkillDirs].filter((dir) => dir !== void 0);
|
|
@@ -86722,12 +86852,12 @@ ${preview.text}` } : {}
|
|
|
86722
86852
|
function watchSkillFolders() {
|
|
86723
86853
|
stopWatchingSkills();
|
|
86724
86854
|
const dirs = skillSearchPath();
|
|
86725
|
-
for (const dir of [...dirs, ...dirs.map((entry) =>
|
|
86855
|
+
for (const dir of [...dirs, ...dirs.map((entry) => import_node_path57.default.dirname(entry))]) {
|
|
86726
86856
|
try {
|
|
86727
86857
|
skillWatchers.push(
|
|
86728
86858
|
// Recursive, because a skill may be a folder with SKILL.md inside — a non-recursive
|
|
86729
86859
|
// watch sees the folder appear and then never hears about the file written into it.
|
|
86730
|
-
(0,
|
|
86860
|
+
(0, import_node_fs14.watch)(dir, { recursive: true }, () => {
|
|
86731
86861
|
if (skillWatchTimer !== void 0)
|
|
86732
86862
|
clearTimeout(skillWatchTimer);
|
|
86733
86863
|
skillWatchTimer = setTimeout(() => {
|
|
@@ -86799,7 +86929,7 @@ ${preview.text}` } : {}
|
|
|
86799
86929
|
await openInPanelEditor(filePath);
|
|
86800
86930
|
return;
|
|
86801
86931
|
}
|
|
86802
|
-
const real = await confineToAny(
|
|
86932
|
+
const real = await confineToAny(import_node_path57.default.resolve(filePath), roots);
|
|
86803
86933
|
await ui.openFile?.(real);
|
|
86804
86934
|
} catch (error51) {
|
|
86805
86935
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -86810,9 +86940,9 @@ ${preview.text}` } : {}
|
|
|
86810
86940
|
python.toolsDirectory(),
|
|
86811
86941
|
...skillsDir === void 0 ? [] : [skillsDir],
|
|
86812
86942
|
...extraSkillDirs.filter((dir) => dir !== void 0),
|
|
86813
|
-
|
|
86943
|
+
import_node_path57.default.join(storageDir, "reports"),
|
|
86814
86944
|
// Its own folder: nothing else lives there.
|
|
86815
|
-
...codebaseInstructionsFile === void 0 ? [] : [
|
|
86945
|
+
...codebaseInstructionsFile === void 0 ? [] : [import_node_path57.default.dirname(codebaseInstructionsFile)]
|
|
86816
86946
|
].filter((dir) => dir.length > 0);
|
|
86817
86947
|
}
|
|
86818
86948
|
function mostlyCrlf(text2) {
|
|
@@ -86821,17 +86951,17 @@ ${preview.text}` } : {}
|
|
|
86821
86951
|
}
|
|
86822
86952
|
const EDITOR_MAX_BYTES = 2 * 1024 * 1024;
|
|
86823
86953
|
async function openInPanelEditor(filePath) {
|
|
86824
|
-
const real = await confineToAny(
|
|
86954
|
+
const real = await confineToAny(import_node_path57.default.resolve(filePath), managedRoots());
|
|
86825
86955
|
const stat = await import_promises31.default.stat(real);
|
|
86826
86956
|
if (stat.size > EDITOR_MAX_BYTES)
|
|
86827
|
-
throw new Error(`${
|
|
86957
|
+
throw new Error(`${import_node_path57.default.basename(real)} is too large to edit here (${String(Math.round(stat.size / 1024))} KB).`);
|
|
86828
86958
|
const raw = await import_promises31.default.readFile(real, "utf8");
|
|
86829
86959
|
const crlf = mostlyCrlf(raw);
|
|
86830
|
-
post({ type: "editorFile", path: real, name:
|
|
86960
|
+
post({ type: "editorFile", path: real, name: import_node_path57.default.basename(real), content: raw.split("\r\n").join("\n"), mtimeMs: stat.mtimeMs, eol: crlf ? "crlf" : "lf" });
|
|
86831
86961
|
}
|
|
86832
86962
|
async function handleSaveEditorFile(filePath, content, mtimeMs) {
|
|
86833
86963
|
try {
|
|
86834
|
-
const real = await confineToAny(
|
|
86964
|
+
const real = await confineToAny(import_node_path57.default.resolve(filePath), managedRoots());
|
|
86835
86965
|
const current = await import_promises31.default.stat(real).catch(() => void 0);
|
|
86836
86966
|
if (current !== void 0 && Math.abs(current.mtimeMs - mtimeMs) > 1) {
|
|
86837
86967
|
post({
|
|
@@ -86839,7 +86969,7 @@ ${preview.text}` } : {}
|
|
|
86839
86969
|
path: real,
|
|
86840
86970
|
ok: false,
|
|
86841
86971
|
conflict: true,
|
|
86842
|
-
message: `${
|
|
86972
|
+
message: `${import_node_path57.default.basename(real)} was changed on disk after you opened it. Copy your text, close the editor, and open it again to see the new version.`
|
|
86843
86973
|
});
|
|
86844
86974
|
return;
|
|
86845
86975
|
}
|
|
@@ -86863,7 +86993,7 @@ ${preview.text}` } : {}
|
|
|
86863
86993
|
await handleOpenManagedFile(existing.filePath);
|
|
86864
86994
|
return;
|
|
86865
86995
|
}
|
|
86866
|
-
const target =
|
|
86996
|
+
const target = import_node_path57.default.join(skillsDir, "standing-instructions.md");
|
|
86867
86997
|
try {
|
|
86868
86998
|
await import_promises31.default.mkdir(skillsDir, { recursive: true });
|
|
86869
86999
|
await import_promises31.default.writeFile(target, STANDING_SKILL_TEMPLATE, { encoding: "utf8", flag: "wx" });
|
|
@@ -86883,7 +87013,7 @@ ${preview.text}` } : {}
|
|
|
86883
87013
|
return;
|
|
86884
87014
|
}
|
|
86885
87015
|
try {
|
|
86886
|
-
await import_promises31.default.mkdir(
|
|
87016
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(codebaseInstructionsFile), { recursive: true });
|
|
86887
87017
|
await import_promises31.default.writeFile(codebaseInstructionsFile, "", { encoding: "utf8", flag: "wx" });
|
|
86888
87018
|
} catch (error51) {
|
|
86889
87019
|
if (error51.code !== "EEXIST") {
|
|
@@ -86900,11 +87030,11 @@ ${preview.text}` } : {}
|
|
|
86900
87030
|
return;
|
|
86901
87031
|
if (!isValidToolName(name))
|
|
86902
87032
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
86903
|
-
const ownCopy =
|
|
87033
|
+
const ownCopy = import_node_path57.default.join(dir, toolFileName(name));
|
|
86904
87034
|
if (filePath !== void 0) {
|
|
86905
|
-
const same2 = (a, b) => normalizeForComparison(
|
|
87035
|
+
const same2 = (a, b) => normalizeForComparison(import_node_path57.default.resolve(a)) === normalizeForComparison(import_node_path57.default.resolve(b));
|
|
86906
87036
|
if (!same2(filePath, ownCopy)) {
|
|
86907
|
-
const fromBucket = mirroredToolsDirs.some((mirror) => same2(
|
|
87037
|
+
const fromBucket = mirroredToolsDirs.some((mirror) => same2(import_node_path57.default.dirname(filePath), mirror));
|
|
86908
87038
|
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.`);
|
|
86909
87039
|
}
|
|
86910
87040
|
}
|
|
@@ -86930,7 +87060,7 @@ ${preview.text}` } : {}
|
|
|
86930
87060
|
let dir;
|
|
86931
87061
|
let filePath = "";
|
|
86932
87062
|
for (const candidate of python.toolDirectories()) {
|
|
86933
|
-
const attempt =
|
|
87063
|
+
const attempt = import_node_path57.default.join(candidate, toolFileName(name));
|
|
86934
87064
|
if (await onDisk(attempt)) {
|
|
86935
87065
|
dir = candidate;
|
|
86936
87066
|
filePath = attempt;
|
|
@@ -86961,7 +87091,7 @@ ${preview.text}` } : {}
|
|
|
86961
87091
|
function samePath(a, b) {
|
|
86962
87092
|
if (a === void 0 || b === void 0)
|
|
86963
87093
|
return false;
|
|
86964
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
87094
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path57.default.resolve(value).toLowerCase() : import_node_path57.default.resolve(value);
|
|
86965
87095
|
return norm2(a) === norm2(b);
|
|
86966
87096
|
}
|
|
86967
87097
|
function publishFolder(kind, mirrors) {
|
|
@@ -87070,7 +87200,7 @@ ${preview.text}` } : {}
|
|
|
87070
87200
|
target,
|
|
87071
87201
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
|
|
87072
87202
|
relative: entry,
|
|
87073
|
-
contents: await import_promises31.default.readFile(
|
|
87203
|
+
contents: await import_promises31.default.readFile(import_node_path57.default.join(dir, entry))
|
|
87074
87204
|
});
|
|
87075
87205
|
uploaded += 1;
|
|
87076
87206
|
} catch (error51) {
|
|
@@ -87092,7 +87222,7 @@ ${preview.text}` } : {}
|
|
|
87092
87222
|
if (!isValidToolName(name))
|
|
87093
87223
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
87094
87224
|
for (const candidate of python.toolDirectories()) {
|
|
87095
|
-
const attempt =
|
|
87225
|
+
const attempt = import_node_path57.default.join(candidate, toolFileName(name));
|
|
87096
87226
|
try {
|
|
87097
87227
|
post({ type: "pythonToolSource", name, source: await import_promises31.default.readFile(attempt, "utf8") });
|
|
87098
87228
|
return;
|
|
@@ -87145,7 +87275,7 @@ ${preview.text}` } : {}
|
|
|
87145
87275
|
continue;
|
|
87146
87276
|
for (const candidate of python.toolDirectories()) {
|
|
87147
87277
|
try {
|
|
87148
|
-
const source = await import_promises31.default.readFile(
|
|
87278
|
+
const source = await import_promises31.default.readFile(import_node_path57.default.join(candidate, toolFileName(name)), "utf8");
|
|
87149
87279
|
declined[name] = hashSource(source);
|
|
87150
87280
|
recorded += 1;
|
|
87151
87281
|
break;
|
|
@@ -87203,7 +87333,7 @@ ${preview.text}` } : {}
|
|
|
87203
87333
|
let dir;
|
|
87204
87334
|
let filePath = "";
|
|
87205
87335
|
for (const candidate of python.toolDirectories()) {
|
|
87206
|
-
const attempt =
|
|
87336
|
+
const attempt = import_node_path57.default.join(candidate, toolFileName(name));
|
|
87207
87337
|
if (await onDisk(attempt)) {
|
|
87208
87338
|
dir = candidate;
|
|
87209
87339
|
filePath = attempt;
|
|
@@ -87229,7 +87359,7 @@ ${preview.text}` } : {}
|
|
|
87229
87359
|
function mirrorForDir(sourceDir) {
|
|
87230
87360
|
if (sourceDir === void 0)
|
|
87231
87361
|
return void 0;
|
|
87232
|
-
const wanted =
|
|
87362
|
+
const wanted = import_node_path57.default.resolve(sourceDir).toLowerCase();
|
|
87233
87363
|
for (const mirror of cachedSkillMirrors) {
|
|
87234
87364
|
if (mirror.enabled !== true)
|
|
87235
87365
|
continue;
|
|
@@ -87239,7 +87369,7 @@ ${preview.text}` } : {}
|
|
|
87239
87369
|
kind: "skills",
|
|
87240
87370
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
87241
87371
|
});
|
|
87242
|
-
if (
|
|
87372
|
+
if (import_node_path57.default.resolve(localDir).toLowerCase() === wanted)
|
|
87243
87373
|
return { mirror, localDir };
|
|
87244
87374
|
}
|
|
87245
87375
|
return void 0;
|
|
@@ -87304,8 +87434,8 @@ ${preview.text}` } : {}
|
|
|
87304
87434
|
});
|
|
87305
87435
|
let localProblem;
|
|
87306
87436
|
try {
|
|
87307
|
-
await import_promises31.default.rm(
|
|
87308
|
-
await import_promises31.default.rm(
|
|
87437
|
+
await import_promises31.default.rm(import_node_path57.default.join(found2.localDir, `${name}.md`), { force: true });
|
|
87438
|
+
await import_promises31.default.rm(import_node_path57.default.join(found2.localDir, name), { recursive: true, force: true });
|
|
87309
87439
|
} catch (error51) {
|
|
87310
87440
|
localProblem = error51 instanceof Error ? error51.message : String(error51);
|
|
87311
87441
|
}
|
|
@@ -87340,7 +87470,7 @@ ${preview.text}` } : {}
|
|
|
87340
87470
|
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.`);
|
|
87341
87471
|
}
|
|
87342
87472
|
const from = existing?.sourceDir !== void 0 && samePath(existing.sourceDir, personalSkillsDir) ? existing.sourceDir : skillsDir;
|
|
87343
|
-
await import_promises31.default.rm(
|
|
87473
|
+
await import_promises31.default.rm(import_node_path57.default.join(from, skillFileName(name)), { force: true });
|
|
87344
87474
|
await postSkills();
|
|
87345
87475
|
} catch (error51) {
|
|
87346
87476
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -87416,7 +87546,14 @@ ${preview.text}` } : {}
|
|
|
87416
87546
|
}
|
|
87417
87547
|
async function applyPlan(next) {
|
|
87418
87548
|
const trimmed = next?.slice(0, PLAN_LIMIT).trim();
|
|
87419
|
-
|
|
87549
|
+
const nextPlan = trimmed !== void 0 && trimmed.length > 0 ? trimmed : void 0;
|
|
87550
|
+
if (activeStrategy !== void 0 && startsNewWork(activePlan, activePlanProgress, nextPlan)) {
|
|
87551
|
+
strategyProgress = {};
|
|
87552
|
+
strategyLastRole = void 0;
|
|
87553
|
+
resetHandOvers();
|
|
87554
|
+
void postStrategies();
|
|
87555
|
+
}
|
|
87556
|
+
activePlan = nextPlan;
|
|
87420
87557
|
activePlanProgress = pruneProgress(activePlan, activePlanProgress);
|
|
87421
87558
|
await persistActiveTask();
|
|
87422
87559
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
@@ -87525,7 +87662,7 @@ ${preview.text}` } : {}
|
|
|
87525
87662
|
let scheduleToolAccess;
|
|
87526
87663
|
const approvalsKey = projectRoot ?? "__no_workspace__";
|
|
87527
87664
|
function comparableApprovalsKey(key3) {
|
|
87528
|
-
return key3 === "__no_workspace__" ? key3 : normalizeForComparison(
|
|
87665
|
+
return key3 === "__no_workspace__" ? key3 : normalizeForComparison(import_node_path57.default.resolve(key3));
|
|
87529
87666
|
}
|
|
87530
87667
|
function approvalsFrom(stored) {
|
|
87531
87668
|
if (stored === void 0)
|
|
@@ -87548,6 +87685,9 @@ ${preview.text}` } : {}
|
|
|
87548
87685
|
const commandToolset = () => probedTools ??= detectCommandTools();
|
|
87549
87686
|
let cachedMaxIterations = 25;
|
|
87550
87687
|
let cachedAutoCompact = false;
|
|
87688
|
+
let cachedAutoHandoff = false;
|
|
87689
|
+
let cachedUnlimitedSteps = false;
|
|
87690
|
+
let handoffAtLimit = false;
|
|
87551
87691
|
let cachedStallSeconds = DEFAULT_STALL_SECONDS;
|
|
87552
87692
|
let cachedRetries = DEFAULT_RETRIES;
|
|
87553
87693
|
let cachedAccentColor = "#22C55E";
|
|
@@ -87739,7 +87879,7 @@ ${preview.text}` } : {}
|
|
|
87739
87879
|
...taskExpertEstimate === void 0 ? {} : { estimate: taskExpertEstimate }
|
|
87740
87880
|
});
|
|
87741
87881
|
}
|
|
87742
|
-
const expertEventsPath =
|
|
87882
|
+
const expertEventsPath = import_node_path57.default.join(storageDir, "expert-events.jsonl");
|
|
87743
87883
|
let expertEvents;
|
|
87744
87884
|
let juniorTurnWithoutExpert = false;
|
|
87745
87885
|
async function loadExpertEvents() {
|
|
@@ -87767,7 +87907,7 @@ ${preview.text}` } : {}
|
|
|
87767
87907
|
try {
|
|
87768
87908
|
const events = await loadExpertEvents();
|
|
87769
87909
|
events.push(event);
|
|
87770
|
-
await import_promises31.default.mkdir(
|
|
87910
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(expertEventsPath), { recursive: true });
|
|
87771
87911
|
await import_promises31.default.appendFile(expertEventsPath, `${JSON.stringify(event)}
|
|
87772
87912
|
`, "utf8");
|
|
87773
87913
|
} catch (error51) {
|
|
@@ -87909,6 +88049,8 @@ ${preview.text}` } : {}
|
|
|
87909
88049
|
cachedModeId = config2.modeId;
|
|
87910
88050
|
cachedMaxIterations = config2.maxIterations ?? 25;
|
|
87911
88051
|
cachedAutoCompact = config2.autoCompact === true;
|
|
88052
|
+
cachedAutoHandoff = config2.autoHandoff === true;
|
|
88053
|
+
cachedUnlimitedSteps = config2.unlimitedSteps === true;
|
|
87912
88054
|
cachedStallSeconds = config2.connection?.stallSeconds ?? DEFAULT_STALL_SECONDS;
|
|
87913
88055
|
cachedRetries = config2.connection?.retries ?? DEFAULT_RETRIES;
|
|
87914
88056
|
cachedAccentColor = config2.ui?.accentColor ?? "#22C55E";
|
|
@@ -88001,6 +88143,8 @@ ${preview.text}` } : {}
|
|
|
88001
88143
|
approvals,
|
|
88002
88144
|
maxIterations: cachedMaxIterations,
|
|
88003
88145
|
autoCompact: cachedAutoCompact,
|
|
88146
|
+
autoHandoff: cachedAutoHandoff,
|
|
88147
|
+
unlimitedSteps: cachedUnlimitedSteps,
|
|
88004
88148
|
stallSeconds: cachedStallSeconds,
|
|
88005
88149
|
retries: cachedRetries,
|
|
88006
88150
|
accentColor: cachedAccentColor,
|
|
@@ -88055,15 +88199,15 @@ ${preview.text}` } : {}
|
|
|
88055
88199
|
function contextMentionPath(file2) {
|
|
88056
88200
|
if (workspaceRoot === void 0)
|
|
88057
88201
|
return file2;
|
|
88058
|
-
const relative =
|
|
88059
|
-
return relative.length > 0 && !relative.startsWith("..") && !
|
|
88202
|
+
const relative = import_node_path57.default.relative(workspaceRoot, file2);
|
|
88203
|
+
return relative.length > 0 && !relative.startsWith("..") && !import_node_path57.default.isAbsolute(relative) ? relative.split(import_node_path57.default.sep).join("/") : file2;
|
|
88060
88204
|
}
|
|
88061
88205
|
function hostCapabilities() {
|
|
88062
88206
|
return {
|
|
88063
88207
|
// The branch this window or tab works on, shown under the chat's name; and the repository, when this
|
|
88064
88208
|
// folder is one of its branch folders (git/worktrees.ts).
|
|
88065
88209
|
...workspaceBranch !== void 0 ? { workspaceBranch } : {},
|
|
88066
|
-
...projectRoot !== void 0 && workspaceRoot !== void 0 && projectRoot !== workspaceRoot ? { branchFolderOf:
|
|
88210
|
+
...projectRoot !== void 0 && workspaceRoot !== void 0 && projectRoot !== workspaceRoot ? { branchFolderOf: import_node_path57.default.basename(projectRoot) } : {},
|
|
88067
88211
|
// The GitHub Copilot preset, offered only where VS Code's models can be reached.
|
|
88068
88212
|
hostModels: services.languageModels !== void 0,
|
|
88069
88213
|
nativeGuide: ui.openWalkthrough !== void 0,
|
|
@@ -88121,11 +88265,47 @@ ${preview.text}` } : {}
|
|
|
88121
88265
|
mcpConfigs = servers;
|
|
88122
88266
|
mcpJson = JSON.stringify({ mcpServers: servers }, null, 2);
|
|
88123
88267
|
}
|
|
88268
|
+
const startupWaits = /* @__PURE__ */ new Map();
|
|
88269
|
+
const mcpStartingSince = /* @__PURE__ */ new Map();
|
|
88270
|
+
let lastStartupPosted = "";
|
|
88271
|
+
function postStartupProgress(force = false) {
|
|
88272
|
+
const now = Date.now();
|
|
88273
|
+
let states = [];
|
|
88274
|
+
try {
|
|
88275
|
+
states = mcp.states_();
|
|
88276
|
+
} catch {
|
|
88277
|
+
}
|
|
88278
|
+
const blocking = new Set(states.filter((state) => state.enabled && state.status === "connecting" && state.tools.length === 0).map((state) => state.name));
|
|
88279
|
+
for (const name of [...mcpStartingSince.keys()])
|
|
88280
|
+
if (!blocking.has(name))
|
|
88281
|
+
mcpStartingSince.delete(name);
|
|
88282
|
+
for (const name of blocking)
|
|
88283
|
+
if (!mcpStartingSince.has(name))
|
|
88284
|
+
mcpStartingSince.set(name, now);
|
|
88285
|
+
const waiting = [
|
|
88286
|
+
...[...mcpStartingSince].map(([name, since2]) => ({ label: `MCP server "${name}" starting`, since: since2 })),
|
|
88287
|
+
...[...startupWaits].map(([label, since2]) => ({ label, since: since2 }))
|
|
88288
|
+
].sort((a, b) => a.since - b.since);
|
|
88289
|
+
const key3 = JSON.stringify(waiting);
|
|
88290
|
+
if (!force && key3 === lastStartupPosted)
|
|
88291
|
+
return;
|
|
88292
|
+
lastStartupPosted = key3;
|
|
88293
|
+
post({ type: "startupProgress", waiting });
|
|
88294
|
+
}
|
|
88295
|
+
function trackStartup(label, work) {
|
|
88296
|
+
startupWaits.set(label, Date.now());
|
|
88297
|
+
postStartupProgress();
|
|
88298
|
+
return work.finally(() => {
|
|
88299
|
+
startupWaits.delete(label);
|
|
88300
|
+
postStartupProgress();
|
|
88301
|
+
});
|
|
88302
|
+
}
|
|
88124
88303
|
const mcp = new McpRegistry(
|
|
88125
88304
|
secrets,
|
|
88126
88305
|
{
|
|
88127
88306
|
onStateChanged: () => {
|
|
88128
88307
|
postMcp();
|
|
88308
|
+
postStartupProgress();
|
|
88129
88309
|
void postSchedules();
|
|
88130
88310
|
void postTools();
|
|
88131
88311
|
void postDatasetStatus();
|
|
@@ -88629,14 +88809,14 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88629
88809
|
}
|
|
88630
88810
|
function readUserNpmrc() {
|
|
88631
88811
|
try {
|
|
88632
|
-
return (0,
|
|
88812
|
+
return (0, import_node_fs15.readFileSync)(process.env["NPM_CONFIG_USERCONFIG"] ?? import_node_path57.default.join(import_node_os7.default.homedir(), ".npmrc"), "utf8");
|
|
88633
88813
|
} catch {
|
|
88634
88814
|
return void 0;
|
|
88635
88815
|
}
|
|
88636
88816
|
}
|
|
88637
88817
|
function addonFolders(config2) {
|
|
88638
88818
|
return {
|
|
88639
|
-
configured: (config2.addons?.folders ?? []).map((folder) =>
|
|
88819
|
+
configured: (config2.addons?.folders ?? []).map((folder) => import_node_path57.default.resolve(folder)),
|
|
88640
88820
|
defaults: defaultAddonFolders(process.env, process.execPath, process.platform, readUserNpmrc())
|
|
88641
88821
|
};
|
|
88642
88822
|
}
|
|
@@ -88748,7 +88928,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88748
88928
|
if (id === void 0) {
|
|
88749
88929
|
if (records.length >= (spec.max ?? 500))
|
|
88750
88930
|
return postAddonPage(message6.package, { error: `No more than ${String(spec.max ?? 500)} ${spec.noun}s.` });
|
|
88751
|
-
id = (0,
|
|
88931
|
+
id = (0, import_node_crypto21.randomBytes)(6).toString("hex");
|
|
88752
88932
|
records.push({ id, values: cleaned.values });
|
|
88753
88933
|
} else {
|
|
88754
88934
|
const at = records.findIndex((record2) => record2.id === id);
|
|
@@ -88917,7 +89097,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88917
89097
|
}
|
|
88918
89098
|
async function handleSaveAddonFolders(folders) {
|
|
88919
89099
|
const cleaned = [...new Set(folders.map((folder) => folder.trim()).filter((folder) => folder.length > 0))];
|
|
88920
|
-
const relative = cleaned.find((folder) => !
|
|
89100
|
+
const relative = cleaned.find((folder) => !import_node_path57.default.isAbsolute(folder));
|
|
88921
89101
|
if (relative !== void 0) {
|
|
88922
89102
|
await postAddons(`"${relative}" is not a full path. Add-on folders are full paths, such as C:\\addons.`);
|
|
88923
89103
|
return;
|
|
@@ -88928,7 +89108,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88928
89108
|
postMcp();
|
|
88929
89109
|
await postAddons();
|
|
88930
89110
|
}
|
|
88931
|
-
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot,
|
|
89111
|
+
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot, import_node_path57.default.join(storageDir, "checkpoints", "shadow.git"), services.codebaseDir !== void 0 ? import_node_path57.default.join(services.codebaseDir, "checkpoint-objects") : void 0) : void 0;
|
|
88932
89112
|
async function postProfiles() {
|
|
88933
89113
|
const { config: config2 } = await configManager.load();
|
|
88934
89114
|
const profiles = await Promise.all((config2.profiles ?? []).map((profile) => toSummary(profile, secrets)));
|
|
@@ -88966,7 +89146,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
88966
89146
|
let warning;
|
|
88967
89147
|
if (tls2.cert !== void 0 && tls2.key !== void 0) {
|
|
88968
89148
|
out.cert = tls2.cert.toString("utf8");
|
|
88969
|
-
const key3 = (0,
|
|
89149
|
+
const key3 = (0, import_node_crypto21.createPrivateKey)(tls2.passphrase !== void 0 ? { key: tls2.key, passphrase: tls2.passphrase } : { key: tls2.key });
|
|
88970
89150
|
out.key = key3.export({ type: "pkcs8", format: "pem" }).toString();
|
|
88971
89151
|
} else if (tls2.pfx !== void 0) {
|
|
88972
89152
|
warning = "The client certificate is a .pfx, which the observer process cannot present; it connects without one. If the gateway requires it, use a PEM certificate and key.";
|
|
@@ -89097,7 +89277,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89097
89277
|
await observerHub.configure(settings);
|
|
89098
89278
|
if (restart)
|
|
89099
89279
|
await observerHub.restart();
|
|
89100
|
-
auditRecordExists = settings.auditor.enabled || (0,
|
|
89280
|
+
auditRecordExists = settings.auditor.enabled || (0, import_node_fs15.existsSync)(observerHub.journalFolder);
|
|
89101
89281
|
if (settings.auditor.enabled && !auditPruned) {
|
|
89102
89282
|
auditPruned = true;
|
|
89103
89283
|
void pruneAudit(storageDir, o.auditor?.retentionDays ?? 90).then((n) => {
|
|
@@ -89142,7 +89322,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89142
89322
|
return;
|
|
89143
89323
|
}
|
|
89144
89324
|
if (ui.openFile !== void 0)
|
|
89145
|
-
await ui.openFile(
|
|
89325
|
+
await ui.openFile(import_node_path57.default.join(folder, newest));
|
|
89146
89326
|
else
|
|
89147
89327
|
ui.showInfo(`The audit journal is in ${folder} (newest: ${newest}).`);
|
|
89148
89328
|
}
|
|
@@ -89180,7 +89360,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89180
89360
|
async function handleOpenArtifact(relative, how) {
|
|
89181
89361
|
if (workspaceRoot === void 0)
|
|
89182
89362
|
return;
|
|
89183
|
-
const absolute = await confine(
|
|
89363
|
+
const absolute = await confine(import_node_path57.default.resolve(workspaceRoot, relative), workspaceRoot);
|
|
89184
89364
|
if (await denylist.isDenied(absolute)) {
|
|
89185
89365
|
ui.showWarning(`${relative} is on the deny list, so it is not opened.`);
|
|
89186
89366
|
return;
|
|
@@ -89293,7 +89473,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89293
89473
|
return { ok: true, message: `Saved in ${file2}; it reaches colleagues through this project's own sharing.` };
|
|
89294
89474
|
}
|
|
89295
89475
|
const enabled = cachedToolMirrors.filter((each) => each.enabled === true);
|
|
89296
|
-
const index = mirroredToolsDirs.findIndex((dir) => samePath(
|
|
89476
|
+
const index = mirroredToolsDirs.findIndex((dir) => samePath(import_node_path57.default.dirname(file2), dir));
|
|
89297
89477
|
try {
|
|
89298
89478
|
await writeFileAtomically(file2, review.content);
|
|
89299
89479
|
const mirror = index >= 0 ? enabled[index] : void 0;
|
|
@@ -89301,7 +89481,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89301
89481
|
const target = targetById(cachedS3, mirror.connectionId);
|
|
89302
89482
|
if (target === void 0 || target.readOnly === true)
|
|
89303
89483
|
return { ok: false, message: `${target?.label ?? mirror.connectionId} is read-only here, so the approved tool cannot be published from this computer.` };
|
|
89304
|
-
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative:
|
|
89484
|
+
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: import_node_path57.default.basename(file2), contents: Buffer.from(review.content, "utf8") });
|
|
89305
89485
|
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.` };
|
|
89306
89486
|
}
|
|
89307
89487
|
scheduleTeamRepoPush();
|
|
@@ -89433,7 +89613,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89433
89613
|
const roleProcesses = /* @__PURE__ */ new Map();
|
|
89434
89614
|
async function roleProcessFor(agent, profile, config2, exe, system, tools) {
|
|
89435
89615
|
const definitions = toToolDefinitions([...tools]);
|
|
89436
|
-
const key3 = JSON.stringify([profile.id, profile.baseUrl, profile.model, profile.maxTokens ?? null, (0,
|
|
89616
|
+
const key3 = JSON.stringify([profile.id, profile.baseUrl, profile.model, profile.maxTokens ?? null, (0, import_node_crypto21.createHash)("sha256").update(system).digest("hex"), definitions.map((d) => d.name)]);
|
|
89437
89617
|
const existing = roleProcesses.get(agent.role);
|
|
89438
89618
|
if (existing !== void 0 && existing.key === key3)
|
|
89439
89619
|
return existing.process;
|
|
@@ -89530,6 +89710,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89530
89710
|
strategyProgress = {};
|
|
89531
89711
|
strategyExchanges = [];
|
|
89532
89712
|
strategyLastRole = void 0;
|
|
89713
|
+
resetHandOvers();
|
|
89533
89714
|
await persistActiveTask();
|
|
89534
89715
|
await postStrategies();
|
|
89535
89716
|
}
|
|
@@ -89582,8 +89763,8 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89582
89763
|
persistTimer.unref?.();
|
|
89583
89764
|
}
|
|
89584
89765
|
function composerDraftFile() {
|
|
89585
|
-
const id = (0,
|
|
89586
|
-
return
|
|
89766
|
+
const id = (0, import_node_crypto21.createHash)("sha256").update((workspaceRoot ?? "").toLowerCase()).digest("hex").slice(0, 16);
|
|
89767
|
+
return import_node_path57.default.join(storageDir, "drafts", `${id}.txt`);
|
|
89587
89768
|
}
|
|
89588
89769
|
let draftWrites = Promise.resolve();
|
|
89589
89770
|
function saveComposerDraft(text2) {
|
|
@@ -89596,10 +89777,20 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89596
89777
|
return import_promises31.default.readFile(composerDraftFile(), "utf8").catch(() => "");
|
|
89597
89778
|
}
|
|
89598
89779
|
async function persistActiveTask() {
|
|
89599
|
-
if (workspaceRoot === void 0
|
|
89780
|
+
if (workspaceRoot === void 0)
|
|
89781
|
+
return;
|
|
89782
|
+
const pending = pendingSteeringPath();
|
|
89783
|
+
if (conversation.isEmpty()) {
|
|
89784
|
+
if (pending !== void 0 && backgroundRun !== true) {
|
|
89785
|
+
await writePendingSteering(pending, {
|
|
89786
|
+
...activePlan !== void 0 ? { plan: activePlan, planProgress: activePlanProgress } : {},
|
|
89787
|
+
...activeStrategy !== void 0 ? { strategy: activeStrategy, strategyProgress, strategyExchanges } : {}
|
|
89788
|
+
}).catch((error51) => logger.warn(`Could not keep this chat's plan and strategy: ${describeFailure2(error51, true)}`));
|
|
89789
|
+
}
|
|
89600
89790
|
return;
|
|
89791
|
+
}
|
|
89601
89792
|
if (activeTaskId === void 0) {
|
|
89602
|
-
await setActiveTaskId((0,
|
|
89793
|
+
await setActiveTaskId((0, import_node_crypto21.randomUUID)());
|
|
89603
89794
|
activeTaskCreatedAt = Date.now();
|
|
89604
89795
|
truncationStore.startTask();
|
|
89605
89796
|
}
|
|
@@ -89621,6 +89812,8 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89621
89812
|
};
|
|
89622
89813
|
try {
|
|
89623
89814
|
await taskStore.save(redactTask(task, await knownSecretValues()));
|
|
89815
|
+
if (pending !== void 0 && backgroundRun !== true)
|
|
89816
|
+
await clearPendingSteering(pending);
|
|
89624
89817
|
} catch (error51) {
|
|
89625
89818
|
logger.warn("could not save task history", String(error51));
|
|
89626
89819
|
}
|
|
@@ -89656,20 +89849,28 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89656
89849
|
void _resumes;
|
|
89657
89850
|
void taskStore.save(settled).catch(() => void 0);
|
|
89658
89851
|
}
|
|
89659
|
-
|
|
89660
|
-
activePlanProgress = pruneProgress(activePlan, task.planProgress);
|
|
89661
|
-
activeStrategy = task.strategy;
|
|
89662
|
-
strategyProgress = task.strategyProgress ?? {};
|
|
89663
|
-
strategyExchanges = task.strategyExchanges ?? [];
|
|
89664
|
-
strategyLastRole = void 0;
|
|
89665
|
-
stopRoleProcesses();
|
|
89852
|
+
adoptSteering(task);
|
|
89666
89853
|
await setActiveTaskId(task.id);
|
|
89667
89854
|
post({ type: "taskRestored", taskId: task.id, entries: toTranscript(task.messages) });
|
|
89855
|
+
postSteering();
|
|
89856
|
+
await postTasks();
|
|
89857
|
+
}
|
|
89858
|
+
function adoptSteering(source) {
|
|
89859
|
+
activePlan = source.plan;
|
|
89860
|
+
activePlanProgress = pruneProgress(activePlan, source.planProgress);
|
|
89861
|
+
activeStrategy = source.strategy;
|
|
89862
|
+
strategyProgress = source.strategyProgress ?? {};
|
|
89863
|
+
strategyExchanges = source.strategyExchanges ?? [];
|
|
89864
|
+
strategyLastRole = void 0;
|
|
89865
|
+
resetHandOvers(0);
|
|
89866
|
+
stopRoleProcesses();
|
|
89867
|
+
}
|
|
89868
|
+
function postSteering() {
|
|
89668
89869
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
89669
89870
|
postPlanProgress();
|
|
89670
89871
|
void postStrategies();
|
|
89671
|
-
await postTasks();
|
|
89672
89872
|
}
|
|
89873
|
+
const pendingSteeringPath = () => workspaceRoot === void 0 ? void 0 : pendingSteeringFile(storageDir, workspaceRoot);
|
|
89673
89874
|
async function startNewTask() {
|
|
89674
89875
|
conversation.reset();
|
|
89675
89876
|
crashResumes = 0;
|
|
@@ -89688,8 +89889,12 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89688
89889
|
strategyProgress = {};
|
|
89689
89890
|
strategyExchanges = [];
|
|
89690
89891
|
strategyLastRole = void 0;
|
|
89892
|
+
resetHandOvers();
|
|
89691
89893
|
stopRoleProcesses();
|
|
89692
89894
|
await setActiveTaskId(void 0);
|
|
89895
|
+
const pending = pendingSteeringPath();
|
|
89896
|
+
if (pending !== void 0 && backgroundRun !== true)
|
|
89897
|
+
await clearPendingSteering(pending);
|
|
89693
89898
|
post({ type: "taskRestored", taskId: void 0, entries: [] });
|
|
89694
89899
|
post({ type: "plan", plan: "" });
|
|
89695
89900
|
postPlanProgress();
|
|
@@ -89713,6 +89918,10 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89713
89918
|
userTurnRunning = false;
|
|
89714
89919
|
userTurnWindingDown = false;
|
|
89715
89920
|
onSettled?.();
|
|
89921
|
+
if (handoffAtLimit) {
|
|
89922
|
+
handoffAtLimit = false;
|
|
89923
|
+
void handleHandoff();
|
|
89924
|
+
}
|
|
89716
89925
|
}
|
|
89717
89926
|
})();
|
|
89718
89927
|
}
|
|
@@ -89823,14 +90032,23 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89823
90032
|
await postTasks();
|
|
89824
90033
|
}
|
|
89825
90034
|
async function restoreActiveTaskOnLoad() {
|
|
89826
|
-
|
|
90035
|
+
const restoreEmptyChat = async () => {
|
|
89827
90036
|
post({ type: "taskRestored", taskId: void 0, entries: [] });
|
|
90037
|
+
const pending = pendingSteeringPath();
|
|
90038
|
+
const steering = pending === void 0 ? void 0 : await readPendingSteering(pending);
|
|
90039
|
+
if (steering === void 0 || !conversation.isEmpty() || activeTaskId !== void 0 || activeStrategy !== void 0 || activePlan !== void 0)
|
|
90040
|
+
return;
|
|
90041
|
+
adoptSteering(steering);
|
|
90042
|
+
postSteering();
|
|
90043
|
+
};
|
|
90044
|
+
if (activeTaskId === void 0) {
|
|
90045
|
+
await restoreEmptyChat();
|
|
89828
90046
|
return;
|
|
89829
90047
|
}
|
|
89830
90048
|
const task = await taskStore.load(activeTaskId);
|
|
89831
90049
|
if (task === void 0 || task.workspaceRoot !== workspaceRoot) {
|
|
89832
90050
|
await setActiveTaskId(void 0);
|
|
89833
|
-
|
|
90051
|
+
await restoreEmptyChat();
|
|
89834
90052
|
return;
|
|
89835
90053
|
}
|
|
89836
90054
|
conversation.restore(task.messages);
|
|
@@ -89838,7 +90056,9 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
89838
90056
|
truncationStore.startTask(task.resultHandles);
|
|
89839
90057
|
restoredInterruptedTurn = task.turnRunning === true;
|
|
89840
90058
|
crashResumes = typeof task.crashResumes === "number" ? task.crashResumes : 0;
|
|
90059
|
+
adoptSteering(task);
|
|
89841
90060
|
post({ type: "taskRestored", taskId: task.id, entries: toTranscript(task.messages) });
|
|
90061
|
+
postSteering();
|
|
89842
90062
|
}
|
|
89843
90063
|
async function resumeInterruptedTurn() {
|
|
89844
90064
|
const decision = resumeDecision({ asked: services.resumeInterrupted === true, turnWasRunning: restoredInterruptedTurn, resumesSoFar: crashResumes });
|
|
@@ -90080,7 +90300,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
90080
90300
|
...schedule === void 0 ? { requestForm } : {},
|
|
90081
90301
|
// A skill read with the user's defaults for its placeholders carries them (`skills/defaults.ts`).
|
|
90082
90302
|
annotateRead: (realPath) => {
|
|
90083
|
-
const fold = (value) => process.platform === "win32" ?
|
|
90303
|
+
const fold = (value) => process.platform === "win32" ? import_node_path57.default.resolve(value).toLowerCase() : import_node_path57.default.resolve(value);
|
|
90084
90304
|
const skill = skills.find((each) => fold(each.filePath) === fold(realPath));
|
|
90085
90305
|
return skill === void 0 ? void 0 : skillDefaultsReadNote(skill.name, config2.skillDefaults?.[skill.name]);
|
|
90086
90306
|
},
|
|
@@ -90132,13 +90352,26 @@ ${direction}` : attachMentions(text2, mentions);
|
|
|
90132
90352
|
// So images a tool returns (a Confluence page's pictures) reach a model that can see them.
|
|
90133
90353
|
supportsVision: capabilities.supportsVision,
|
|
90134
90354
|
// CLAUDE.md §5 has called this configurable since Phase 0; until now it was not.
|
|
90135
|
-
|
|
90355
|
+
// No limit when the user switched it off - never for a scheduled run, which nobody is watching to stop.
|
|
90356
|
+
maxIterations: cachedUnlimitedSteps && schedule === void 0 ? Number.POSITIVE_INFINITY : cachedMaxIterations,
|
|
90136
90357
|
/*
|
|
90137
90358
|
* Off unless switched on: compaction loses detail, and when is the user's call. A scheduled
|
|
90138
90359
|
* run always may, because nobody is there to press "Compact now" and a run that stops at
|
|
90139
90360
|
* the limit overnight reports nothing useful in the morning.
|
|
90140
90361
|
*/
|
|
90141
90362
|
autoCompact: cachedAutoCompact || schedule !== void 0,
|
|
90363
|
+
// A chat at its limit hands off by itself, when that is switched on (never a scheduled run: nobody is there).
|
|
90364
|
+
/*
|
|
90365
|
+
* Only once the chat holds an earlier message of the user's: a chat that is full on its first message (a handoff's
|
|
90366
|
+
* own opening, or one enormous paste) would hand off into a chat just as full, and again, for ever. That case
|
|
90367
|
+
* gets the ordinary message saying what to do.
|
|
90368
|
+
*/
|
|
90369
|
+
...cachedAutoHandoff && !cachedAutoCompact && schedule === void 0 && conversation.toArray().filter((m) => m.role === "user" && !isObserverNote(m.content)).length >= 1 ? {
|
|
90370
|
+
onContextFull: () => {
|
|
90371
|
+
handoffAtLimit = true;
|
|
90372
|
+
logger.info("the conversation reached the context limit: handing off to a new chat");
|
|
90373
|
+
}
|
|
90374
|
+
} : {},
|
|
90142
90375
|
stallSeconds: cachedStallSeconds,
|
|
90143
90376
|
retries: cachedRetries,
|
|
90144
90377
|
drainQueuedMessages: () => {
|
|
@@ -90539,7 +90772,7 @@ ${direction}` : attachMentions(text2, mentions);
|
|
|
90539
90772
|
try {
|
|
90540
90773
|
const { config: config2 } = await configManager.load();
|
|
90541
90774
|
const profiles = config2.profiles ?? [];
|
|
90542
|
-
const id = input.id ?? (0,
|
|
90775
|
+
const id = input.id ?? (0, import_node_crypto21.randomUUID)();
|
|
90543
90776
|
const existing = profiles.find((p) => p.id === id);
|
|
90544
90777
|
const auth2 = await buildAuthFromInput(input, id);
|
|
90545
90778
|
const saved = {
|
|
@@ -90577,7 +90810,7 @@ ${direction}` : attachMentions(text2, mentions);
|
|
|
90577
90810
|
post({ type: "error", message: `Profile "${id}" no longer exists.` });
|
|
90578
90811
|
return;
|
|
90579
90812
|
}
|
|
90580
|
-
const newId = (0,
|
|
90813
|
+
const newId = (0, import_node_crypto21.randomUUID)();
|
|
90581
90814
|
async function copySecret(fromRef, toRef) {
|
|
90582
90815
|
if (fromRef === void 0)
|
|
90583
90816
|
return false;
|
|
@@ -91388,7 +91621,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91388
91621
|
return { mode: cachedSearchScope, author: cachedAttribution.author };
|
|
91389
91622
|
}
|
|
91390
91623
|
function currentProjectNames() {
|
|
91391
|
-
const names = [cachedAttribution.project, workspaceRoot !== void 0 ?
|
|
91624
|
+
const names = [cachedAttribution.project, workspaceRoot !== void 0 ? import_node_path57.default.basename(workspaceRoot) : void 0];
|
|
91392
91625
|
return names.filter((name) => name !== void 0 && name.length > 0);
|
|
91393
91626
|
}
|
|
91394
91627
|
function indexProject(config2) {
|
|
@@ -91491,8 +91724,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91491
91724
|
limit: limits.limit,
|
|
91492
91725
|
previewChars: limits.previewChars
|
|
91493
91726
|
});
|
|
91494
|
-
for (const
|
|
91495
|
-
skipped2.add(
|
|
91727
|
+
for (const path68 of answer.skipped ?? [])
|
|
91728
|
+
skipped2.add(path68);
|
|
91496
91729
|
return { messages: answer.messages, truncated: answer.truncated };
|
|
91497
91730
|
},
|
|
91498
91731
|
...embedder !== void 0 && search !== void 0 && collection !== void 0 ? {
|
|
@@ -91791,9 +92024,9 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91791
92024
|
});
|
|
91792
92025
|
const all = result.folders.map((entry) => entry.path);
|
|
91793
92026
|
const wanted = new Set(chosen);
|
|
91794
|
-
for (const
|
|
91795
|
-
if (chosen.some((root) =>
|
|
91796
|
-
wanted.add(
|
|
92027
|
+
for (const path68 of all) {
|
|
92028
|
+
if (chosen.some((root) => path68 === root || path68.startsWith(`${root}\\`)))
|
|
92029
|
+
wanted.add(path68);
|
|
91797
92030
|
}
|
|
91798
92031
|
return [...wanted];
|
|
91799
92032
|
} catch {
|
|
@@ -91801,7 +92034,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91801
92034
|
}
|
|
91802
92035
|
}
|
|
91803
92036
|
async function handleRequestOutlookFolders(depth, force = false) {
|
|
91804
|
-
const cachePath =
|
|
92037
|
+
const cachePath = import_node_path57.default.join(storageDir, "outlook-folders.json");
|
|
91805
92038
|
let served = false;
|
|
91806
92039
|
try {
|
|
91807
92040
|
const cached2 = JSON.parse(await import_promises31.default.readFile(cachePath, "utf8"));
|
|
@@ -91821,7 +92054,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
91821
92054
|
const scannedAt = Date.now();
|
|
91822
92055
|
post({ type: "outlookFolders", folders: result.folders, scannedAt });
|
|
91823
92056
|
try {
|
|
91824
|
-
await import_promises31.default.mkdir(
|
|
92057
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(cachePath), { recursive: true });
|
|
91825
92058
|
await import_promises31.default.writeFile(cachePath, JSON.stringify({ scannedAt, folders: result.folders }), "utf8");
|
|
91826
92059
|
} catch {
|
|
91827
92060
|
}
|
|
@@ -92066,7 +92299,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92066
92299
|
if (auth2.clientId === void 0 || auth2.clientSecretRef === void 0) {
|
|
92067
92300
|
throw new AtlassianError("AutoSys uses the API gateway but the client id or secret is missing. Settings \u2192 DevOps \u2192 AutoSys \u2192 API gateway: enter both and save.");
|
|
92068
92301
|
}
|
|
92069
|
-
const key3 = JSON.stringify({ auth: auth2, baseUrl: config2.autosys?.baseUrl, tls: tls2 === void 0 ? 0 : (0,
|
|
92302
|
+
const key3 = JSON.stringify({ auth: auth2, baseUrl: config2.autosys?.baseUrl, tls: tls2 === void 0 ? 0 : (0, import_node_crypto21.createHash)("sha256").update(JSON.stringify(tls2)).digest("hex") });
|
|
92070
92303
|
const testing = http !== httpClient;
|
|
92071
92304
|
if (!testing && autosysGateway?.key === key3)
|
|
92072
92305
|
return autosysGateway.strategy;
|
|
@@ -92738,13 +92971,13 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92738
92971
|
return { reason: "Off." };
|
|
92739
92972
|
if (!isSafeSegment(settings.project) || !isSafeSegment(settings.repo))
|
|
92740
92973
|
return { reason: "Enter the project key and repository slug." };
|
|
92741
|
-
const digest = (0,
|
|
92742
|
-
const root =
|
|
92974
|
+
const digest = (0, import_node_crypto21.createHash)("sha256").update(JSON.stringify([bitbucket.baseUrl, settings.project, settings.repo, settings.branch, settings.folder]).toLowerCase()).digest("hex").slice(0, 12);
|
|
92975
|
+
const root = import_node_path57.default.join(mirrorRoot, "teamrepo", `${settings.project}-${settings.repo}-${digest}`.toLowerCase());
|
|
92743
92976
|
return {
|
|
92744
|
-
dirs: { skills:
|
|
92977
|
+
dirs: { skills: import_node_path57.default.join(root, "skills"), tools: import_node_path57.default.join(root, "tools") },
|
|
92745
92978
|
// Where new skills and tools are saved while the repository is on - see loadSettings and pythonFolders.
|
|
92746
|
-
own: { skills:
|
|
92747
|
-
stateFile:
|
|
92979
|
+
own: { skills: import_node_path57.default.join(root, "saved-here", "skills"), tools: import_node_path57.default.join(root, "saved-here", "tools") },
|
|
92980
|
+
stateFile: import_node_path57.default.join(root, TEAM_REPO_STATE_FILE),
|
|
92748
92981
|
settings
|
|
92749
92982
|
};
|
|
92750
92983
|
}
|
|
@@ -92787,14 +93020,14 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92787
93020
|
const config2 = await loadSettings();
|
|
92788
93021
|
const plan3 = teamRepoPlan(config2);
|
|
92789
93022
|
if (!("reason" in plan3)) {
|
|
92790
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
93023
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path57.default.resolve(value).toLowerCase() : import_node_path57.default.resolve(value);
|
|
92791
93024
|
const folders = [
|
|
92792
93025
|
...[plan3.dirs.skills, plan3.own.skills, ...skillSearchPath()].map((dir) => [dir, "skills"]),
|
|
92793
93026
|
...[plan3.dirs.tools, plan3.own.tools, ...python.toolDirectories()].map((dir) => [dir, "tools"])
|
|
92794
93027
|
];
|
|
92795
|
-
const holder = folders.find(([dir]) => norm2(file2).startsWith(norm2(dir) +
|
|
93028
|
+
const holder = folders.find(([dir]) => norm2(file2).startsWith(norm2(dir) + import_node_path57.default.sep));
|
|
92796
93029
|
if (holder !== void 0) {
|
|
92797
|
-
const relative =
|
|
93030
|
+
const relative = import_node_path57.default.relative(import_node_path57.default.resolve(holder[0]), import_node_path57.default.resolve(file2)).split(import_node_path57.default.sep).join("/");
|
|
92798
93031
|
const where = repoPathFor(plan3.settings.folder, holder[1], relative);
|
|
92799
93032
|
try {
|
|
92800
93033
|
const client = await bitbucketClient();
|
|
@@ -92826,21 +93059,21 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92826
93059
|
const has2 = async (target) => import_promises31.default.stat(target).then(() => true, () => false);
|
|
92827
93060
|
if (kind === "skill") {
|
|
92828
93061
|
for (const dir of unique([skillsDir, localSkillsDir, personalSkillsDir, ...mirroredSkillsDirs])) {
|
|
92829
|
-
if (await has2(
|
|
92830
|
-
plan3.local.push(
|
|
92831
|
-
if (await has2(
|
|
92832
|
-
plan3.local.push(
|
|
93062
|
+
if (await has2(import_node_path57.default.join(dir, skillFileName(name))))
|
|
93063
|
+
plan3.local.push(import_node_path57.default.join(dir, skillFileName(name)));
|
|
93064
|
+
if (await has2(import_node_path57.default.join(dir, name, "SKILL.md")))
|
|
93065
|
+
plan3.local.push(import_node_path57.default.join(dir, name));
|
|
92833
93066
|
}
|
|
92834
93067
|
for (const extra of config2.skills?.paths ?? []) {
|
|
92835
93068
|
const dir = resolveSkillDir(extra);
|
|
92836
|
-
if (dir !== void 0 && (await has2(
|
|
93069
|
+
if (dir !== void 0 && (await has2(import_node_path57.default.join(dir, skillFileName(name))) || await has2(import_node_path57.default.join(dir, name, "SKILL.md")))) {
|
|
92837
93070
|
plan3.notes.push(`Also in ${dir}, a folder you added in Settings -> Skills - not removed; delete it there.`);
|
|
92838
93071
|
}
|
|
92839
93072
|
}
|
|
92840
93073
|
} else {
|
|
92841
93074
|
for (const dir of unique([pythonFolders(config2).toolsDir, localToolsDir(config2), personalToolsDir, ...mirroredToolsDirs])) {
|
|
92842
|
-
if (await has2(
|
|
92843
|
-
plan3.local.push(
|
|
93075
|
+
if (await has2(import_node_path57.default.join(dir, toolFileName(name))))
|
|
93076
|
+
plan3.local.push(import_node_path57.default.join(dir, toolFileName(name)));
|
|
92844
93077
|
}
|
|
92845
93078
|
}
|
|
92846
93079
|
const mirrors = (kind === "skill" ? cachedSkillMirrors : cachedToolMirrors).filter((mirror) => mirror.enabled === true);
|
|
@@ -92938,7 +93171,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92938
93171
|
try {
|
|
92939
93172
|
await import_promises31.default.rm(entry, { recursive: true, force: true });
|
|
92940
93173
|
if (kind === "tool")
|
|
92941
|
-
await forgetTool(
|
|
93174
|
+
await forgetTool(import_node_path57.default.dirname(entry), name).catch(() => void 0);
|
|
92942
93175
|
} catch (error51) {
|
|
92943
93176
|
localProblems.push(`${entry} (${error51 instanceof Error ? error51.message : String(error51)})`);
|
|
92944
93177
|
}
|
|
@@ -92964,24 +93197,24 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
92964
93197
|
}
|
|
92965
93198
|
async function writeTeamMonitorSkill(file2, content) {
|
|
92966
93199
|
const config2 = await loadSettings();
|
|
92967
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
93200
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path57.default.resolve(value).toLowerCase() : import_node_path57.default.resolve(value);
|
|
92968
93201
|
const inside = (dir) => {
|
|
92969
93202
|
const target = norm2(file2);
|
|
92970
93203
|
const root = norm2(dir);
|
|
92971
|
-
return target.startsWith(root +
|
|
93204
|
+
return target.startsWith(root + import_node_path57.default.sep) ? import_node_path57.default.relative(import_node_path57.default.resolve(dir), import_node_path57.default.resolve(file2)) : void 0;
|
|
92972
93205
|
};
|
|
92973
93206
|
const saveIn = async (dir, relative) => {
|
|
92974
|
-
const destination =
|
|
93207
|
+
const destination = import_node_path57.default.join(dir, relative);
|
|
92975
93208
|
const enabled = cachedSkillMirrors.filter((each) => each.enabled === true);
|
|
92976
93209
|
const mirror = enabled.find((_, i) => samePath(mirroredSkillsDirs[i], dir));
|
|
92977
93210
|
const target = mirror !== void 0 ? targetById(cachedS3, mirror.connectionId) : void 0;
|
|
92978
93211
|
if (mirror !== void 0 && (target === void 0 || target.readOnly === true)) {
|
|
92979
93212
|
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.`);
|
|
92980
93213
|
}
|
|
92981
|
-
await import_promises31.default.mkdir(
|
|
93214
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(destination), { recursive: true });
|
|
92982
93215
|
await writeFileAtomically(destination, content);
|
|
92983
93216
|
if (mirror !== void 0 && target !== void 0) {
|
|
92984
|
-
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: relative.split(
|
|
93217
|
+
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: relative.split(import_node_path57.default.sep).join("/"), contents: Buffer.from(content, "utf8") });
|
|
92985
93218
|
return `uploaded to the bucket ${target.label}`;
|
|
92986
93219
|
}
|
|
92987
93220
|
return `saved in ${dir}`;
|
|
@@ -93003,7 +93236,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
93003
93236
|
throw new Error("There is no folder to save skills in, so the change cannot reach the team repository.");
|
|
93004
93237
|
const where = await saveIn(skillsDir, relative);
|
|
93005
93238
|
await handleTeamRepoSync("a monitor changed on the dashboard");
|
|
93006
|
-
const problem = teamRepoStatus?.error ?? teamRepoStatus?.conflicts.find((c2) => c2.path.endsWith(relative.split(
|
|
93239
|
+
const problem = teamRepoStatus?.error ?? teamRepoStatus?.conflicts.find((c2) => c2.path.endsWith(relative.split(import_node_path57.default.sep).join("/")))?.reason;
|
|
93007
93240
|
if (problem !== void 0) {
|
|
93008
93241
|
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.` };
|
|
93009
93242
|
}
|
|
@@ -93033,8 +93266,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
93033
93266
|
function isPersonalSkill(skill) {
|
|
93034
93267
|
if (personalSkillsDir === void 0)
|
|
93035
93268
|
return false;
|
|
93036
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
93037
|
-
return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) +
|
|
93269
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path57.default.resolve(value).toLowerCase() : import_node_path57.default.resolve(value);
|
|
93270
|
+
return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) + import_node_path57.default.sep);
|
|
93038
93271
|
}
|
|
93039
93272
|
function bucketFolderLabels(config2) {
|
|
93040
93273
|
const label = (kind, mirror) => {
|
|
@@ -93282,7 +93515,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
93282
93515
|
}
|
|
93283
93516
|
const command = config2.branches?.setupCommand?.trim();
|
|
93284
93517
|
if (command !== void 0 && command.length > 0) {
|
|
93285
|
-
const label = workspaceBranch ??
|
|
93518
|
+
const label = workspaceBranch ?? import_node_path57.default.basename(workspaceRoot);
|
|
93286
93519
|
if (ui.runInTerminal !== void 0) {
|
|
93287
93520
|
ui.runInTerminal({ name: `Set up ${label}`, command, cwd: workspaceRoot, env: branchEnv });
|
|
93288
93521
|
parts.push(`running "${command}" in a terminal`);
|
|
@@ -93356,7 +93589,7 @@ ${last}` : ""}`);
|
|
|
93356
93589
|
approvalStamps.set("machine", stamp2);
|
|
93357
93590
|
}
|
|
93358
93591
|
for (const dir of python.toolDirectories()) {
|
|
93359
|
-
const file2 =
|
|
93592
|
+
const file2 = import_node_path57.default.join(dir, REGISTRY_FILE);
|
|
93360
93593
|
const stamp2 = await import_promises31.default.stat(file2).then((stat) => stat.mtimeMs, () => 0);
|
|
93361
93594
|
if (approvalStamps.has(file2) && approvalStamps.get(file2) !== stamp2)
|
|
93362
93595
|
changed = true;
|
|
@@ -93458,7 +93691,7 @@ ${last}` : ""}`);
|
|
|
93458
93691
|
return;
|
|
93459
93692
|
}
|
|
93460
93693
|
const folder = skill.filePath.slice(0, skill.filePath.length - "SKILL.md".length);
|
|
93461
|
-
const bytes = await import_promises31.default.readFile(
|
|
93694
|
+
const bytes = await import_promises31.default.readFile(import_node_path57.default.join(folder, SKILL_IMAGE_DIR, image));
|
|
93462
93695
|
const dataUri = skillImageDataUri(image, bytes);
|
|
93463
93696
|
post({
|
|
93464
93697
|
type: "skillImage",
|
|
@@ -93824,13 +94057,13 @@ ${last}` : ""}`);
|
|
|
93824
94057
|
}
|
|
93825
94058
|
function docsFingerprintPath(index, storeId, kind) {
|
|
93826
94059
|
const suffix = kind === void 0 ? "docs" : `docs.${kind}`;
|
|
93827
|
-
return
|
|
94060
|
+
return import_node_path57.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.${suffix}.json`);
|
|
93828
94061
|
}
|
|
93829
94062
|
function manifestKey(index, storeId) {
|
|
93830
94063
|
return `${index}@${storeId}`;
|
|
93831
94064
|
}
|
|
93832
94065
|
function manifestPath(index, storeId) {
|
|
93833
|
-
return
|
|
94066
|
+
return import_node_path57.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.json`);
|
|
93834
94067
|
}
|
|
93835
94068
|
async function readDocsFingerprint(index, storeId, kind) {
|
|
93836
94069
|
try {
|
|
@@ -93860,7 +94093,7 @@ ${last}` : ""}`);
|
|
|
93860
94093
|
});
|
|
93861
94094
|
const wanted = options.kind;
|
|
93862
94095
|
const entries = wanted === void 0 ? all : all.filter((entry) => entry.kind === wanted);
|
|
93863
|
-
const fingerprint = (0,
|
|
94096
|
+
const fingerprint = (0, import_node_crypto21.createHash)("sha256").update(`${wanted ?? "all"}:${embedder.model}:${String(embedder.dimensions)}`).update(entries.map((entry) => `${entry.id}\0${entry.text}`).join("")).digest("hex");
|
|
93864
94097
|
if (!options.force && fingerprint === await readDocsFingerprint(index, search.id, wanted)) {
|
|
93865
94098
|
return { unchanged: true, index, indexed: entries.length };
|
|
93866
94099
|
}
|
|
@@ -93894,7 +94127,7 @@ ${last}` : ""}`);
|
|
|
93894
94127
|
}
|
|
93895
94128
|
options.report?.("Writing", { done: 0, total: documents.length });
|
|
93896
94129
|
await writer.upsert(index, documents);
|
|
93897
|
-
await import_promises31.default.mkdir(
|
|
94130
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(docsFingerprintPath(index, search.id, wanted)), {
|
|
93898
94131
|
recursive: true
|
|
93899
94132
|
});
|
|
93900
94133
|
await import_promises31.default.writeFile(docsFingerprintPath(index, search.id, wanted), JSON.stringify({ fingerprint, indexedAt: Date.now(), count: documents.length }), "utf8");
|
|
@@ -94084,7 +94317,7 @@ ${last}` : ""}`);
|
|
|
94084
94317
|
});
|
|
94085
94318
|
if (manifest !== void 0) {
|
|
94086
94319
|
const targetPath = manifestPath(index, target.id);
|
|
94087
|
-
await import_promises31.default.mkdir(
|
|
94320
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(targetPath), { recursive: true });
|
|
94088
94321
|
await import_promises31.default.writeFile(targetPath, JSON.stringify(manifest), "utf8");
|
|
94089
94322
|
}
|
|
94090
94323
|
post({ type: "storeSync", running: false, copied: result.copied, fromLabel: source.label });
|
|
@@ -94133,7 +94366,7 @@ ${last}` : ""}`);
|
|
|
94133
94366
|
type: "project",
|
|
94134
94367
|
hasWorkspace: workspaceRoot !== void 0,
|
|
94135
94368
|
...configured !== void 0 ? { configured } : {},
|
|
94136
|
-
...workspaceRoot !== void 0 ? { folder:
|
|
94369
|
+
...workspaceRoot !== void 0 ? { folder: import_node_path57.default.basename(workspaceRoot) } : {},
|
|
94137
94370
|
...author !== void 0 ? { author } : {},
|
|
94138
94371
|
...index !== void 0 ? { indexName: index } : {},
|
|
94139
94372
|
...ownerConfigured !== void 0 && ownerConfigured.length > 0 ? { ownerConfigured } : {},
|
|
@@ -94273,8 +94506,8 @@ ${last}` : ""}`);
|
|
|
94273
94506
|
if (workspaceRoot === void 0)
|
|
94274
94507
|
return found2;
|
|
94275
94508
|
const root = workspaceRoot;
|
|
94276
|
-
const relative =
|
|
94277
|
-
if (relative.startsWith("..") ||
|
|
94509
|
+
const relative = import_node_path57.default.relative(root, folder);
|
|
94510
|
+
if (relative.startsWith("..") || import_node_path57.default.isAbsolute(relative))
|
|
94278
94511
|
return found2;
|
|
94279
94512
|
const output = await new Promise((resolve) => {
|
|
94280
94513
|
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 : "."], {
|
|
@@ -94291,7 +94524,7 @@ ${last}` : ""}`);
|
|
|
94291
94524
|
if (line.startsWith("@@"))
|
|
94292
94525
|
author = line.slice(2).trim();
|
|
94293
94526
|
else if (line.trim().length > 0 && author !== void 0 && author.length > 0) {
|
|
94294
|
-
found2.set(normalizeForComparison(
|
|
94527
|
+
found2.set(normalizeForComparison(import_node_path57.default.resolve(root, line.trim())), author);
|
|
94295
94528
|
}
|
|
94296
94529
|
}
|
|
94297
94530
|
return found2;
|
|
@@ -94335,7 +94568,7 @@ ${last}` : ""}`);
|
|
|
94335
94568
|
},
|
|
94336
94569
|
source,
|
|
94337
94570
|
folder,
|
|
94338
|
-
relative:
|
|
94571
|
+
relative: import_node_path57.default.relative(folder, filePath).split(import_node_path57.default.sep).join("/")
|
|
94339
94572
|
});
|
|
94340
94573
|
};
|
|
94341
94574
|
for (const folder of skillFolders) {
|
|
@@ -94353,7 +94586,7 @@ ${last}` : ""}`);
|
|
|
94353
94586
|
const name = entry.slice(0, -3);
|
|
94354
94587
|
if (!isValidToolName(name))
|
|
94355
94588
|
continue;
|
|
94356
|
-
await consider("tool", name,
|
|
94589
|
+
await consider("tool", name, import_node_path57.default.join(folder, entry), folder, location);
|
|
94357
94590
|
}
|
|
94358
94591
|
}
|
|
94359
94592
|
const readOnly = skills.filter((skill) => skill.sourceDir !== void 0 && !skillFolders.some((folder) => samePath(folder, skill.sourceDir))).length;
|
|
@@ -94385,7 +94618,7 @@ ${last}` : ""}`);
|
|
|
94385
94618
|
} catch {
|
|
94386
94619
|
}
|
|
94387
94620
|
}
|
|
94388
|
-
const gitAuthor = gitAuthors.get(normalizeForComparison(
|
|
94621
|
+
const gitAuthor = gitAuthors.get(normalizeForComparison(import_node_path57.default.resolve(candidate.entry.filePath)));
|
|
94389
94622
|
if (gitAuthor !== void 0) {
|
|
94390
94623
|
candidate.entry.suggestion = { author: gitAuthor, source: "git: the commit that added this file" };
|
|
94391
94624
|
}
|
|
@@ -94494,7 +94727,7 @@ ${last}` : ""}`);
|
|
|
94494
94727
|
aliases: plan3.kind === "codebase" ? codebaseAliases(config2) : plan3.kind === "skills" ? skillAliases(config2) : [],
|
|
94495
94728
|
onProgress: (count3) => post({ type: "indexRenames", running: true, plans, store, current: plan3.to, copied: count3 })
|
|
94496
94729
|
});
|
|
94497
|
-
await copyBookkeeping(
|
|
94730
|
+
await copyBookkeeping(import_node_path57.default.join(manifestsRoot, "index-manifests"), plan3.from, plan3.to, search.id);
|
|
94498
94731
|
done.push({ ...plan3, copied });
|
|
94499
94732
|
}
|
|
94500
94733
|
post({ type: "indexRenames", running: false, plans: [], store, done });
|
|
@@ -94524,7 +94757,7 @@ ${last}` : ""}`);
|
|
|
94524
94757
|
project: projectName(config2, workspaceRoot),
|
|
94525
94758
|
aliases: codebaseAliases(config2)
|
|
94526
94759
|
});
|
|
94527
|
-
await copyBookkeeping(
|
|
94760
|
+
await copyBookkeeping(import_node_path57.default.join(manifestsRoot, "index-manifests"), legacy, current, search.id);
|
|
94528
94761
|
post({ type: "indexRenames", running: false, plans: [], done: [{ kind: "codebase", from: legacy, to: current, copied }] });
|
|
94529
94762
|
logger.info(`copied ${String(copied)} chunks from ${legacy} to ${current} rather than re-embedding them`);
|
|
94530
94763
|
}
|
|
@@ -94690,7 +94923,7 @@ ${last}` : ""}`);
|
|
|
94690
94923
|
denylist,
|
|
94691
94924
|
manifest,
|
|
94692
94925
|
saveManifest: async (next) => {
|
|
94693
|
-
await import_promises31.default.mkdir(
|
|
94926
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(manifestFile), { recursive: true });
|
|
94694
94927
|
await import_promises31.default.writeFile(manifestFile, JSON.stringify(next), "utf8");
|
|
94695
94928
|
},
|
|
94696
94929
|
...isIgnored2 !== void 0 ? { isIgnored: isIgnored2 } : {},
|
|
@@ -94776,9 +95009,9 @@ ${last}` : ""}`);
|
|
|
94776
95009
|
}
|
|
94777
95010
|
const usageLog = new UsageLog(storageDir);
|
|
94778
95011
|
const usageInstance = usageInstanceId(storageDir);
|
|
94779
|
-
const usageProfileFile =
|
|
94780
|
-
const legacyBackfillFile =
|
|
94781
|
-
const usageDir =
|
|
95012
|
+
const usageProfileFile = import_node_path57.default.join(storageDir, "usage-profile.json");
|
|
95013
|
+
const legacyBackfillFile = import_node_path57.default.join(storageDir, "usage-backfill.json");
|
|
95014
|
+
const usageDir = import_node_path57.default.join(storageDir, "usage");
|
|
94782
95015
|
const toolStartedAt = /* @__PURE__ */ new Map();
|
|
94783
95016
|
let usagePushTimer;
|
|
94784
95017
|
let usagePushing;
|
|
@@ -94796,7 +95029,7 @@ ${last}` : ""}`);
|
|
|
94796
95029
|
return (request2) => runFastFs(exe, request2);
|
|
94797
95030
|
}
|
|
94798
95031
|
function skillAtPath(requested2) {
|
|
94799
|
-
const absolute =
|
|
95032
|
+
const absolute = import_node_path57.default.isAbsolute(requested2) ? requested2 : workspaceRoot === void 0 ? void 0 : import_node_path57.default.resolve(workspaceRoot, requested2);
|
|
94800
95033
|
if (absolute === void 0)
|
|
94801
95034
|
return void 0;
|
|
94802
95035
|
return skills.find((skill) => samePath(skill.filePath, absolute));
|
|
@@ -94886,7 +95119,7 @@ ${last}` : ""}`);
|
|
|
94886
95119
|
const folder = chosen.path?.trim();
|
|
94887
95120
|
if (folder === void 0 || folder.length === 0)
|
|
94888
95121
|
return { problem: "The shared folder has no path." };
|
|
94889
|
-
if (!
|
|
95122
|
+
if (!import_node_path57.default.isAbsolute(folder))
|
|
94890
95123
|
return { problem: `"${folder}" is not an absolute path. Use the full path of a folder everybody can reach, such as a network share.` };
|
|
94891
95124
|
const helper = usageHelper();
|
|
94892
95125
|
return { store: new FolderShardStore(folder, ...helper !== void 0 ? [helper] : []), target };
|
|
@@ -94915,7 +95148,7 @@ ${last}` : ""}`);
|
|
|
94915
95148
|
}
|
|
94916
95149
|
async function readUsageBackfill() {
|
|
94917
95150
|
try {
|
|
94918
|
-
const text2 = await import_promises31.default.readFile(
|
|
95151
|
+
const text2 = await import_promises31.default.readFile(import_node_path57.default.join(usageDir, "backfill.json"), "utf8").catch(() => import_promises31.default.readFile(legacyBackfillFile, "utf8"));
|
|
94919
95152
|
const saved = JSON.parse(text2);
|
|
94920
95153
|
if (typeof saved.at !== "number")
|
|
94921
95154
|
return void 0;
|
|
@@ -94931,7 +95164,7 @@ ${last}` : ""}`);
|
|
|
94931
95164
|
legacyDoneFile: legacyBackfillFile,
|
|
94932
95165
|
run: async (before) => {
|
|
94933
95166
|
const status2 = python.status();
|
|
94934
|
-
return backfillFromTasks(
|
|
95167
|
+
return backfillFromTasks(import_node_path57.default.join(storageDir, "tasks"), {
|
|
94935
95168
|
user: cachedAttribution.author ?? "unknown",
|
|
94936
95169
|
project: cachedAttribution.project,
|
|
94937
95170
|
workspaceRoot,
|
|
@@ -95029,7 +95262,7 @@ ${last}` : ""}`);
|
|
|
95029
95262
|
try {
|
|
95030
95263
|
const text2 = (await import_promises31.default.readFile(file2, "utf8")).replace(/\r\n/g, "\n");
|
|
95031
95264
|
const meaningful = text2.split("\n").filter((line) => !/^(author|project|version|updated)\s*:/i.test(line) && !/^__(author|project|version|updated)__\s*=/.test(line)).join("\n").trim();
|
|
95032
|
-
return (0,
|
|
95265
|
+
return (0, import_node_crypto21.createHash)("sha256").update(meaningful).digest("hex").slice(0, 16);
|
|
95033
95266
|
} catch {
|
|
95034
95267
|
return void 0;
|
|
95035
95268
|
}
|
|
@@ -95104,14 +95337,14 @@ ${last}` : ""}`);
|
|
|
95104
95337
|
kind: "tool",
|
|
95105
95338
|
name: issue2.name,
|
|
95106
95339
|
filePath: issue2.filePath,
|
|
95107
|
-
deletable: samePath(
|
|
95108
|
-
location: where(
|
|
95340
|
+
deletable: samePath(import_node_path57.default.dirname(issue2.filePath), status2.toolsDir),
|
|
95341
|
+
location: where(import_node_path57.default.dirname(issue2.filePath), status2.toolsDir),
|
|
95109
95342
|
issue: issue2.kind === "unapproved" ? "waiting for approval" : issue2.kind === "hash-mismatch" ? "changed since approval" : issue2.detail.split("\n")[0] ?? "not loaded"
|
|
95110
95343
|
});
|
|
95111
95344
|
}
|
|
95112
95345
|
return items;
|
|
95113
95346
|
}
|
|
95114
|
-
const usageDirectoryFile =
|
|
95347
|
+
const usageDirectoryFile = import_node_path57.default.join(storageDir, "usage-directory.json");
|
|
95115
95348
|
let directoryRunning;
|
|
95116
95349
|
async function readDirectoryCache() {
|
|
95117
95350
|
try {
|
|
@@ -95446,7 +95679,7 @@ ${last}` : ""}`);
|
|
|
95446
95679
|
let indexedFiles = 0;
|
|
95447
95680
|
if (index !== void 0) {
|
|
95448
95681
|
try {
|
|
95449
|
-
const manifest = JSON.parse(await import_promises31.default.readFile(
|
|
95682
|
+
const manifest = JSON.parse(await import_promises31.default.readFile(import_node_path57.default.join(manifestsRoot, "index-manifests", `${index}.json`), "utf8"));
|
|
95450
95683
|
indexedFiles = Object.keys(manifest.files ?? {}).length;
|
|
95451
95684
|
} catch {
|
|
95452
95685
|
}
|
|
@@ -95722,7 +95955,7 @@ ${last}` : ""}`);
|
|
|
95722
95955
|
return;
|
|
95723
95956
|
}
|
|
95724
95957
|
const { config: config2 } = await configManager.load();
|
|
95725
|
-
const id = input.id ?? (0,
|
|
95958
|
+
const id = input.id ?? (0, import_node_crypto21.randomUUID)();
|
|
95726
95959
|
if (input.username !== void 0 && input.username.length > 0)
|
|
95727
95960
|
await secrets.set(searchUserRefFor(id), input.username);
|
|
95728
95961
|
if (input.password !== void 0 && input.password.length > 0)
|
|
@@ -95926,11 +96159,11 @@ ${last}` : ""}`);
|
|
|
95926
96159
|
answer({ error: bytes.length === 0 ? "There was nothing to save." : "That file is too large to save from here." });
|
|
95927
96160
|
return;
|
|
95928
96161
|
}
|
|
95929
|
-
const safeName = [...
|
|
95930
|
-
const extension =
|
|
96162
|
+
const safeName = [...import_node_path57.default.basename(name)].map((c2) => c2.charCodeAt(0) < 32 || '<>:"/\\|?*'.includes(c2) ? "-" : c2).join("") || "file";
|
|
96163
|
+
const extension = import_node_path57.default.extname(safeName).slice(1);
|
|
95931
96164
|
try {
|
|
95932
96165
|
const target = await ui.showSaveDialog({
|
|
95933
|
-
defaultName: workspaceRoot !== void 0 ?
|
|
96166
|
+
defaultName: workspaceRoot !== void 0 ? import_node_path57.default.join(workspaceRoot, safeName) : safeName,
|
|
95934
96167
|
...extension.length > 0 ? { extensions: [extension] } : {}
|
|
95935
96168
|
});
|
|
95936
96169
|
if (target === void 0) {
|
|
@@ -96011,8 +96244,8 @@ ${last}` : ""}`);
|
|
|
96011
96244
|
continue;
|
|
96012
96245
|
for (const key3 of section.keys)
|
|
96013
96246
|
patch[key3] = key3 === "profiles" && merged.profiles !== void 0 ? reconciled : merged[key3];
|
|
96014
|
-
for (const
|
|
96015
|
-
const head =
|
|
96247
|
+
for (const path68 of section.nested ?? []) {
|
|
96248
|
+
const head = path68.split(".")[0];
|
|
96016
96249
|
patch[head] = merged[head];
|
|
96017
96250
|
}
|
|
96018
96251
|
}
|
|
@@ -96056,7 +96289,7 @@ ${last}` : ""}`);
|
|
|
96056
96289
|
if (changeLedger !== void 0) {
|
|
96057
96290
|
const shared = await changeLedger.othersSince(targets, taskCheckpoint.createdAt);
|
|
96058
96291
|
if (shared.size > 0) {
|
|
96059
|
-
const shown2 = (file2) =>
|
|
96292
|
+
const shown2 = (file2) => import_node_path57.default.relative(workspaceRoot ?? "", file2).split(import_node_path57.default.sep).join("/");
|
|
96060
96293
|
const detail = [...shared].map(([file2, chats]) => `${shown2(file2)} (${chats.join(", ")})`).join("; ");
|
|
96061
96294
|
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");
|
|
96062
96295
|
if (!all) {
|
|
@@ -96100,9 +96333,10 @@ ${last}` : ""}`);
|
|
|
96100
96333
|
if (mentioned.length > 0)
|
|
96101
96334
|
stepNotes = attachMentions(stepNotes, mentioned);
|
|
96102
96335
|
}
|
|
96103
|
-
const
|
|
96336
|
+
const handed = handOverSources(strategy, agent.role).map((role) => ({ role, answer: latestStrategyAnswer(role) })).filter((entry) => entry.answer !== void 0).map((entry) => `## Handed over from ${name(entry.role)} (its latest answer, passed on directly)
|
|
96104
96337
|
|
|
96105
|
-
${
|
|
96338
|
+
${entry.answer.length > HANDOVER_LIMIT ? `${entry.answer.slice(0, HANDOVER_LIMIT)}\u2026 [cut at ${String(HANDOVER_LIMIT)} characters]` : entry.answer}`);
|
|
96339
|
+
const question = [request2.question, ...handed, ...stepNotes.length > 0 ? [stepNotes] : [], SUMMARY_REQUEST].join("\n\n");
|
|
96106
96340
|
strategyRunning.add(agent.role);
|
|
96107
96341
|
strategyLastRole = agent.role;
|
|
96108
96342
|
void postStrategies();
|
|
@@ -96131,14 +96365,30 @@ ${more.advice}` };
|
|
|
96131
96365
|
strategyProgress = recorded.progress;
|
|
96132
96366
|
const exchange2 = exchangeOf(agent.role, request2.question, answer.advice, before, recorded.progress, request2.parallel === true);
|
|
96133
96367
|
recordExchange(checks.length > 0 ? { ...exchange2, contracts: checks.map((check2) => ({ ...check2, askedAgain: askedAgain.get(check2.edgeId) ?? 0 })) } : exchange2);
|
|
96368
|
+
strategyAnswers.set(agent.role, answer.advice);
|
|
96134
96369
|
strategyLastRole = agent.role;
|
|
96135
96370
|
persistSoon();
|
|
96136
96371
|
void postStrategies();
|
|
96137
96372
|
const contractNotes = checks.filter((check2) => check2.missing.length > 0 || (askedAgain.get(check2.edgeId) ?? 0) > 0).map((check2) => check2.missing.length > 0 ? `[Strategy] The hand-over to ${name(check2.to)} is incomplete even after asking again: missing ${check2.missing.join(", ")}. Pass on what arrived and say plainly what is missing.` : `[Strategy] The hand-over to ${name(check2.to)} is complete (${check2.required.join(", ")}), after asking ${name(agent.role)} again for what it had left out.`);
|
|
96138
96373
|
const notes = [...contractNotes, ...recorded.note !== void 0 ? [recorded.note] : []];
|
|
96139
|
-
|
|
96374
|
+
const forMain = answerForMain(answer.advice, name(agent.role));
|
|
96375
|
+
return { ...answer, advice: notes.length > 0 ? `${forMain}
|
|
96140
96376
|
|
|
96141
|
-
${notes.join("\n")}`
|
|
96377
|
+
${notes.join("\n")}` : forMain };
|
|
96378
|
+
}
|
|
96379
|
+
const strategyAnswers = /* @__PURE__ */ new Map();
|
|
96380
|
+
let strategyTopicSince = 0;
|
|
96381
|
+
const HANDOVER_LIMIT = 24e3;
|
|
96382
|
+
function resetHandOvers(since2 = Date.now()) {
|
|
96383
|
+
strategyAnswers.clear();
|
|
96384
|
+
strategyTopicSince = since2;
|
|
96385
|
+
}
|
|
96386
|
+
function latestStrategyAnswer(role) {
|
|
96387
|
+
const kept = strategyAnswers.get(role);
|
|
96388
|
+
if (kept !== void 0)
|
|
96389
|
+
return kept;
|
|
96390
|
+
const logged = [...strategyExchanges].reverse().find((exchange2) => exchange2.role === role && exchange2.at >= strategyTopicSince && exchange2.refused === void 0 && exchange2.answer.length > 0);
|
|
96391
|
+
return logged?.answer;
|
|
96142
96392
|
}
|
|
96143
96393
|
function recordExchange(exchange2) {
|
|
96144
96394
|
strategyExchanges = [...strategyExchanges, exchange2].slice(-MAX_EXCHANGES);
|
|
@@ -96346,7 +96596,7 @@ ${notes.join("\n")}` } : answer;
|
|
|
96346
96596
|
const pathRequest = pendingPathApprovals.get(id);
|
|
96347
96597
|
userGate.resolve(id, "approve");
|
|
96348
96598
|
if (pathRequest !== void 0) {
|
|
96349
|
-
const folder =
|
|
96599
|
+
const folder = import_node_path57.default.dirname(pathRequest);
|
|
96350
96600
|
sessionPathGrants.add(normalizeForComparison(pathRequest));
|
|
96351
96601
|
if (scope === "folder" && !cachedReadRoots.includes(folder)) {
|
|
96352
96602
|
const { config: config2 } = await configManager.load();
|
|
@@ -96586,10 +96836,10 @@ ${notes.join("\n")}` } : answer;
|
|
|
96586
96836
|
});
|
|
96587
96837
|
return;
|
|
96588
96838
|
}
|
|
96589
|
-
let dir =
|
|
96839
|
+
let dir = import_node_path57.default.dirname(import_node_path57.default.resolve(scriptPath));
|
|
96590
96840
|
for (let depth = 0; depth < 3; depth++) {
|
|
96591
96841
|
for (const name of VENV_DIR_NAMES) {
|
|
96592
|
-
const candidate =
|
|
96842
|
+
const candidate = import_node_path57.default.join(dir, name);
|
|
96593
96843
|
const found2 = await search(candidate);
|
|
96594
96844
|
if (found2 !== void 0) {
|
|
96595
96845
|
post({
|
|
@@ -96601,7 +96851,7 @@ ${notes.join("\n")}` } : answer;
|
|
|
96601
96851
|
return;
|
|
96602
96852
|
}
|
|
96603
96853
|
}
|
|
96604
|
-
const parent =
|
|
96854
|
+
const parent = import_node_path57.default.dirname(dir);
|
|
96605
96855
|
if (parent === dir)
|
|
96606
96856
|
break;
|
|
96607
96857
|
dir = parent;
|
|
@@ -96785,6 +97035,12 @@ ${notes.join("\n")}` } : answer;
|
|
|
96785
97035
|
void configManager.save("user", { connection: { stallSeconds: message6.stallSeconds, retries: message6.retries } }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
96786
97036
|
} else if (message6.type === "setAutoCompact") {
|
|
96787
97037
|
void configManager.save("user", { autoCompact: message6.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
97038
|
+
} else if (message6.type === "setUnlimitedSteps") {
|
|
97039
|
+
void configManager.save("user", { unlimitedSteps: message6.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
97040
|
+
} else if (message6.type === "requestStartupProgress") {
|
|
97041
|
+
postStartupProgress(true);
|
|
97042
|
+
} else if (message6.type === "setAutoHandoff") {
|
|
97043
|
+
void configManager.save("user", { autoHandoff: message6.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
96788
97044
|
} else if (message6.type === "setMaxIterations") {
|
|
96789
97045
|
void configManager.save("user", { maxIterations: message6.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
96790
97046
|
} else if (message6.type === "setProgrammingProfile") {
|
|
@@ -97425,22 +97681,22 @@ ${notes.join("\n")}` } : answer;
|
|
|
97425
97681
|
try {
|
|
97426
97682
|
const config2 = await loadSettings();
|
|
97427
97683
|
const startedAt = Date.now();
|
|
97428
|
-
const timed = (label, work) => work.finally(() => {
|
|
97684
|
+
const timed = (label, work, shown2 = true) => (shown2 ? trackStartup(label, work) : work).finally(() => {
|
|
97429
97685
|
const seconds = (Date.now() - startedAt) / 1e3;
|
|
97430
97686
|
if (seconds >= 2)
|
|
97431
97687
|
logger.info(`[startup] ${label} ready after ${seconds.toFixed(1)}s`);
|
|
97432
97688
|
});
|
|
97433
97689
|
const parts = [
|
|
97434
|
-
timed("
|
|
97435
|
-
timed("
|
|
97690
|
+
timed("Stored credentials", knownSecretValues()),
|
|
97691
|
+
timed("Skills", refreshSkills()),
|
|
97436
97692
|
timed("Python tools", configurePython(config2)),
|
|
97437
|
-
timed("
|
|
97438
|
-
timed("
|
|
97439
|
-
timed("MCP
|
|
97693
|
+
timed("Git", gitAvailable()),
|
|
97694
|
+
timed("Expert", resolveExpert(config2)),
|
|
97695
|
+
timed("MCP servers", mcpStarted, false)
|
|
97440
97696
|
];
|
|
97441
97697
|
if ((config2.profiles ?? []).length > 0) {
|
|
97442
97698
|
const profile = resolveActiveProfile(config2);
|
|
97443
|
-
parts.push(timed("
|
|
97699
|
+
parts.push(timed("Model gateway sign-in", (async () => {
|
|
97444
97700
|
if (profile.wireFormat !== "vscode-lm")
|
|
97445
97701
|
await authStrategyFor(config2, profile).resolveHeaders();
|
|
97446
97702
|
await reportedWindowFor(config2, profile);
|
|
@@ -97547,11 +97803,11 @@ ${entry.content}`);
|
|
|
97547
97803
|
let lastReportPath;
|
|
97548
97804
|
async function saveReport(title, contents) {
|
|
97549
97805
|
try {
|
|
97550
|
-
const directory =
|
|
97806
|
+
const directory = import_node_path57.default.join(storageDir, "reports");
|
|
97551
97807
|
await import_promises31.default.mkdir(directory, { recursive: true });
|
|
97552
97808
|
const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
97553
97809
|
const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
97554
|
-
const target =
|
|
97810
|
+
const target = import_node_path57.default.join(directory, `${stamp2}${slug.length > 0 ? `-${slug}` : ""}.md`);
|
|
97555
97811
|
await import_promises31.default.writeFile(target, `# ${title}
|
|
97556
97812
|
|
|
97557
97813
|
${contents}
|
|
@@ -97567,7 +97823,7 @@ ${contents}
|
|
|
97567
97823
|
const keep = 100;
|
|
97568
97824
|
const entries = (await import_promises31.default.readdir(directory)).filter((name) => name.endsWith(".md")).sort();
|
|
97569
97825
|
for (const name of entries.slice(0, Math.max(0, entries.length - keep))) {
|
|
97570
|
-
await import_promises31.default.rm(
|
|
97826
|
+
await import_promises31.default.rm(import_node_path57.default.join(directory, name), { force: true });
|
|
97571
97827
|
}
|
|
97572
97828
|
}
|
|
97573
97829
|
let scheduleTimer;
|
|
@@ -97640,7 +97896,7 @@ ${contents}
|
|
|
97640
97896
|
async function handleSaveSchedule(schedule) {
|
|
97641
97897
|
try {
|
|
97642
97898
|
const schedules = await loadSchedules();
|
|
97643
|
-
const id = schedule.id.length > 0 ? schedule.id : (0,
|
|
97899
|
+
const id = schedule.id.length > 0 ? schedule.id : (0, import_node_crypto21.createHash)("sha256").update(`${schedule.name}:${String(Date.now())}`).digest("hex").slice(0, 12);
|
|
97644
97900
|
const armed = { ...schedule, id, nextRunAt: nextFireTime(schedule, Date.now()) };
|
|
97645
97901
|
await saveSchedules({ ...schedules, [id]: armed });
|
|
97646
97902
|
} catch (error51) {
|
|
@@ -97649,7 +97905,7 @@ ${contents}
|
|
|
97649
97905
|
}
|
|
97650
97906
|
async function createScheduleFromProposal(proposal) {
|
|
97651
97907
|
const schedules = await loadSchedules();
|
|
97652
|
-
const id = (0,
|
|
97908
|
+
const id = (0, import_node_crypto21.createHash)("sha256").update(`${proposal.name}:${String(Date.now())}`).digest("hex").slice(0, 12);
|
|
97653
97909
|
const schedule = {
|
|
97654
97910
|
id,
|
|
97655
97911
|
name: proposal.name,
|
|
@@ -97680,10 +97936,10 @@ ${contents}
|
|
|
97680
97936
|
}
|
|
97681
97937
|
const CLAIM_STALE_MS = 60 * 60 * 1e3;
|
|
97682
97938
|
async function claimSchedule(id) {
|
|
97683
|
-
const claimPath =
|
|
97939
|
+
const claimPath = import_node_path57.default.join(storageDir, "schedule-claims", `${id}.json`);
|
|
97684
97940
|
const mine = JSON.stringify({ pid: process.pid, at: Date.now() });
|
|
97685
97941
|
try {
|
|
97686
|
-
await import_promises31.default.mkdir(
|
|
97942
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(claimPath), { recursive: true });
|
|
97687
97943
|
await import_promises31.default.writeFile(claimPath, mine, { encoding: "utf8", flag: "wx" });
|
|
97688
97944
|
return true;
|
|
97689
97945
|
} catch (error51) {
|
|
@@ -97708,7 +97964,7 @@ ${contents}
|
|
|
97708
97964
|
}
|
|
97709
97965
|
}
|
|
97710
97966
|
async function releaseSchedule(id) {
|
|
97711
|
-
await import_promises31.default.rm(
|
|
97967
|
+
await import_promises31.default.rm(import_node_path57.default.join(storageDir, "schedule-claims", `${id}.json`), { force: true }).catch(() => void 0);
|
|
97712
97968
|
}
|
|
97713
97969
|
async function runSchedule(id, reason) {
|
|
97714
97970
|
if (reason === "due" && !await claimSchedule(id))
|
|
@@ -98403,11 +98659,11 @@ function createShowDiagramTool() {
|
|
|
98403
98659
|
|
|
98404
98660
|
// ../../packages/core/dist/lsp/manager.js
|
|
98405
98661
|
var import_promises32 = __toESM(require("node:fs/promises"), 1);
|
|
98406
|
-
var
|
|
98662
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
98407
98663
|
|
|
98408
98664
|
// ../../packages/core/dist/lsp/catalog.js
|
|
98409
|
-
var
|
|
98410
|
-
var
|
|
98665
|
+
var import_node_fs16 = require("node:fs");
|
|
98666
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
98411
98667
|
var c = (command, ...args) => ({ command, args });
|
|
98412
98668
|
var LSP_LANGUAGES = [
|
|
98413
98669
|
{ id: "python", label: "Python", extensions: ["py", "pyi"], candidates: [c("pyright-langserver", "--stdio"), c("basedpyright-langserver", "--stdio"), c("pylsp"), c("jedi-language-server")] },
|
|
@@ -98455,17 +98711,17 @@ var LSP_LANGUAGES = [
|
|
|
98455
98711
|
{ id: "sql", label: "SQL", extensions: ["sql"], candidates: [c("sql-language-server", "up", "--method", "stdio")] }
|
|
98456
98712
|
];
|
|
98457
98713
|
function languageFor(file2) {
|
|
98458
|
-
const ext =
|
|
98714
|
+
const ext = import_node_path58.default.extname(file2).slice(1).toLowerCase();
|
|
98459
98715
|
return LSP_LANGUAGES.find((l) => l.extensions.includes(ext));
|
|
98460
98716
|
}
|
|
98461
98717
|
function languageIdFor(language, file2) {
|
|
98462
|
-
const ext =
|
|
98718
|
+
const ext = import_node_path58.default.extname(file2).slice(1).toLowerCase();
|
|
98463
98719
|
return language.languageIdFor?.(ext) ?? language.id;
|
|
98464
98720
|
}
|
|
98465
98721
|
var found = /* @__PURE__ */ new Map();
|
|
98466
98722
|
function findOnPath(command, env2 = process.env) {
|
|
98467
|
-
if (
|
|
98468
|
-
return (0,
|
|
98723
|
+
if (import_node_path58.default.isAbsolute(command))
|
|
98724
|
+
return (0, import_node_fs16.existsSync)(command) ? command : void 0;
|
|
98469
98725
|
if (env2 !== process.env)
|
|
98470
98726
|
return searchPath(command, env2);
|
|
98471
98727
|
const hit = found.get(command);
|
|
@@ -98476,12 +98732,12 @@ function findOnPath(command, env2 = process.env) {
|
|
|
98476
98732
|
return value;
|
|
98477
98733
|
}
|
|
98478
98734
|
function searchPath(command, env2) {
|
|
98479
|
-
const dirs = (env2.PATH ?? env2.Path ?? "").split(
|
|
98735
|
+
const dirs = (env2.PATH ?? env2.Path ?? "").split(import_node_path58.default.delimiter).filter((d) => d.length > 0);
|
|
98480
98736
|
const exts = process.platform === "win32" ? ["", ...(env2.PATHEXT ?? ".EXE;.CMD;.BAT").toLowerCase().split(";")] : [""];
|
|
98481
98737
|
for (const dir of dirs) {
|
|
98482
98738
|
for (const ext of exts) {
|
|
98483
|
-
const candidate =
|
|
98484
|
-
if ((0,
|
|
98739
|
+
const candidate = import_node_path58.default.join(dir, command + ext);
|
|
98740
|
+
if ((0, import_node_fs16.existsSync)(candidate) && (process.platform !== "win32" || ext !== "" || /\.(exe|cmd|bat)$/i.test(candidate)))
|
|
98485
98741
|
return candidate;
|
|
98486
98742
|
}
|
|
98487
98743
|
}
|
|
@@ -98713,7 +98969,7 @@ var LspManager = class {
|
|
|
98713
98969
|
return void 0;
|
|
98714
98970
|
const args = [...found2.candidate.args];
|
|
98715
98971
|
if (language.id === "java" && !args.includes("-data"))
|
|
98716
|
-
args.push("-data",
|
|
98972
|
+
args.push("-data", import_node_path59.default.join(this.storageDir, "jdtls-workspace"));
|
|
98717
98973
|
try {
|
|
98718
98974
|
client = new LspClient(found2.executable, args, this.root, this.log);
|
|
98719
98975
|
this.clients.set(language.id, client);
|
|
@@ -98734,7 +98990,7 @@ var LspManager = class {
|
|
|
98734
98990
|
this.failed.set(language.id, client.lastError ?? "stopped");
|
|
98735
98991
|
return void 0;
|
|
98736
98992
|
}
|
|
98737
|
-
return { server:
|
|
98993
|
+
return { server: import_node_path59.default.basename(client.executable).replace(/\.(exe|cmd|bat)$/i, ""), diagnostics: diagnostics ?? [] };
|
|
98738
98994
|
} catch (error51) {
|
|
98739
98995
|
this.failed.set(language.id, error51 instanceof Error ? error51.message : String(error51));
|
|
98740
98996
|
client.dispose();
|
|
@@ -101994,8 +102250,10 @@ between chats - but what they offer can. Every chat of a codebase remembers each
|
|
|
101994
102250
|
one shared file, so a chat started after a crash or a sleep offers those tools at once and replies
|
|
101995
102251
|
without waiting for the servers; a server keeps starting in the background, and a call to one of its
|
|
101996
102252
|
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.
|
|
101998
|
-
|
|
102253
|
+
reply goes ahead and its tools join the next message. While anything is still getting ready, a bar over
|
|
102254
|
+
the message box names it with how long it has taken - each MCP server still starting, Python tools, skills, the model
|
|
102255
|
+
gateway's sign-in - and goes when nothing is left; a message sent meanwhile waits for what it needs. The agent log
|
|
102256
|
+
(\`host.log\`) also names each slow part with a \`[startup]\` line.
|
|
101999
102257
|
|
|
102000
102258
|
**Not in Fire Code**: editor file pickers \u2014 paths are typed. Fire Code's
|
|
102001
102259
|
Settings \u2192 Export source code saves the whole repository as a zip that builds offline.
|
|
@@ -102283,6 +102541,18 @@ morning, by which time a toast is long gone. The run log keeps a Report button.
|
|
|
102283
102541
|
"parallel",
|
|
102284
102542
|
"parallel box",
|
|
102285
102543
|
"contract",
|
|
102544
|
+
"custom role",
|
|
102545
|
+
"custom roles",
|
|
102546
|
+
"own context",
|
|
102547
|
+
"context filling up",
|
|
102548
|
+
"hand over",
|
|
102549
|
+
"handover between agents",
|
|
102550
|
+
"strategy per chat",
|
|
102551
|
+
"different strategy",
|
|
102552
|
+
"strategy lost",
|
|
102553
|
+
"keep the strategy",
|
|
102554
|
+
"new topic",
|
|
102555
|
+
"strategy after restart",
|
|
102286
102556
|
"connect a box",
|
|
102287
102557
|
"box to an agent",
|
|
102288
102558
|
"group of agents",
|
|
@@ -102356,6 +102626,24 @@ once. If several of them need your approval at once, the prompts come one at a t
|
|
|
102356
102626
|
connectors between them, else as drawn. A box of either kind can be switched on the right ("Run at the same time" or
|
|
102357
102627
|
"Run as a group").
|
|
102358
102628
|
|
|
102629
|
+
**A strategy belongs to its chat.** Each chat keeps its own strategy, or none: choosing one with **Save and use in
|
|
102630
|
+
this chat** sets it for that chat only, and a new chat starts with none until you pick one. It is saved with the chat
|
|
102631
|
+
and comes back whenever the chat does - reopened from History, after the window reloads, when a Fire Code chat wakes
|
|
102632
|
+
from sleep or restarts after a crash - and it is kept even if you chose it before sending anything. **New chat with a
|
|
102633
|
+
handoff** carries it into the new chat. **Stop using** in the Strategy window takes it off the chat. Every request in
|
|
102634
|
+
the chat follows it, not only the first: for a new topic the agent proposes a new plan that goes through the strategy
|
|
102635
|
+
again, and the back-and-forth loops start afresh for it, with their full number of rounds.
|
|
102636
|
+
|
|
102637
|
+
**Custom roles work in a strategy** like the built-in ones: a role made in Settings \u2192 Agents is consulted by its id
|
|
102638
|
+
or its name, and the strategy tells the agent the id beside a custom role's name.
|
|
102639
|
+
|
|
102640
|
+
**Each specialist keeps its own context, and the main chat stays lean.** A specialist runs in its own process with
|
|
102641
|
+
its own memory. When a step is consulted, Light Code hands it the latest full answer of every step connected into it -
|
|
102642
|
+
a box's steps for a connector from a box, and in a back-and-forth the other side's latest - so the main agent does not
|
|
102643
|
+
paste one specialist's answer into the next one's question. Each specialist ends with a short "Summary for the main
|
|
102644
|
+
agent", and that summary (with any loop verdict or contract note) is all the main chat receives; the full answer stays
|
|
102645
|
+
in the strategy record, readable with strategy_history. A new topic starts these hand-overs afresh.
|
|
102646
|
+
|
|
102359
102647
|
**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
102648
|
**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
102649
|
out of a box is followed only once every step inside has answered; a connector into a box gives every step inside what
|
|
@@ -102518,6 +102806,13 @@ called at all.
|
|
|
102518
102806
|
"forgets",
|
|
102519
102807
|
"auto compact",
|
|
102520
102808
|
"compact automatically",
|
|
102809
|
+
"auto handoff",
|
|
102810
|
+
"hand off automatically",
|
|
102811
|
+
"handoff at limit",
|
|
102812
|
+
"no step limit",
|
|
102813
|
+
"unlimited steps",
|
|
102814
|
+
"disable step limit",
|
|
102815
|
+
"step limit",
|
|
102521
102816
|
"retry",
|
|
102522
102817
|
"retries",
|
|
102523
102818
|
"stuck thinking",
|
|
@@ -102577,6 +102872,10 @@ shortened transcript.
|
|
|
102577
102872
|
older part (highlighted near the limit); the stored transcript keeps everything, only what is sent to
|
|
102578
102873
|
the model is shortened, and never in the middle of a tool call. Your own messages are kept **word for
|
|
102579
102874
|
word** inside the summary, every time, so what you asked for is never paraphrased away.
|
|
102875
|
+
Or tick **Hand off automatically** (config:autoHandoff) instead: when the chat reaches the limit the reply stops,
|
|
102876
|
+
the assistant writes a handoff, and a new chat starts from it and carries on by itself - this chat stays in History,
|
|
102877
|
+
nothing in it summarised. The two are one or the other; ticking one unticks the other. It applies once the chat holds an
|
|
102878
|
+
earlier message of yours, so a chat full on its very first message is not handed over and over.
|
|
102580
102879
|
Tick **Compact automatically** beside the button (config:autoCompact) to have it done near the limit,
|
|
102581
102880
|
keeping roughly the last third of the window verbatim - and only for a model whose window Light Code
|
|
102582
102881
|
knows: from the table, from the model's own server (a self-hosted vLLM or SGLang reports its real
|
|
@@ -102611,6 +102910,9 @@ Light Code chat**. Typing \`@\` does the same from the keyboard, everywhere.
|
|
|
102611
102910
|
something. If it trips, nothing is lost: send another message and it carries on with the full
|
|
102612
102911
|
transcript. Typing **while a turn is running** grants a fresh 25 as well \u2014 the cap exists to stop a
|
|
102613
102912
|
model looping unattended, and somebody typing is evidence that this is not that.
|
|
102913
|
+
**No step limit** (Settings \u2192 Approvals, config:unlimitedSteps) lets a chat's reply run until the job is done, you
|
|
102914
|
+
press Stop, or the same thing fails three times in a row - pair it with the Anti Hallucinator (Settings \u2192 Project),
|
|
102915
|
+
which watches each step and steers the agent back when it drifts. Scheduled runs keep the limit.
|
|
102614
102916
|
|
|
102615
102917
|
**Prompt caching is why tool definitions do not change mid-session.** They sit at the front of the
|
|
102616
102918
|
prompt, so swapping them to "save context" would throw away the cached prefix *and all the history
|
|
@@ -103364,7 +103666,7 @@ function createLightCodeHelpTool() {
|
|
|
103364
103666
|
|
|
103365
103667
|
// ../../packages/core/dist/tools/listFiles.js
|
|
103366
103668
|
var import_node_child_process21 = require("node:child_process");
|
|
103367
|
-
var
|
|
103669
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
103368
103670
|
|
|
103369
103671
|
// ../../packages/core/dist/tools/ripgrepError.js
|
|
103370
103672
|
function ripgrepDidNotStart(error51) {
|
|
@@ -103445,7 +103747,7 @@ var listFilesTool = {
|
|
|
103445
103747
|
});
|
|
103446
103748
|
if (files.length === 0)
|
|
103447
103749
|
return noFiles;
|
|
103448
|
-
const listed = files.map((file2) => file2.split("/").join(
|
|
103750
|
+
const listed = files.map((file2) => file2.split("/").join(import_node_path60.default.sep)).join("\n");
|
|
103449
103751
|
return { content: truncated ? `${listed}
|
|
103450
103752
|
(listing cut short \u2014 list a narrower folder)` : listed };
|
|
103451
103753
|
}
|
|
@@ -103513,10 +103815,10 @@ function readSmall(raw, params3) {
|
|
|
103513
103815
|
const end = params3.limit !== void 0 ? start + params3.limit : lines2.length;
|
|
103514
103816
|
return number4(lines2.slice(start, end), start + 1);
|
|
103515
103817
|
}
|
|
103516
|
-
async function readLarge(
|
|
103818
|
+
async function readLarge(fs48, realPath, params3, size) {
|
|
103517
103819
|
const human = formatBytes(size);
|
|
103518
103820
|
if (params3.tail !== void 0) {
|
|
103519
|
-
const part = await readTail(
|
|
103821
|
+
const part = await readTail(fs48, realPath, size, params3.tail);
|
|
103520
103822
|
return [
|
|
103521
103823
|
`${human} file \u2014 last ${String(part.lines.length)} lines.`,
|
|
103522
103824
|
/*
|
|
@@ -103531,7 +103833,7 @@ async function readLarge(fs47, realPath, params3, size) {
|
|
|
103531
103833
|
}
|
|
103532
103834
|
if (params3.offset !== void 0) {
|
|
103533
103835
|
const limit = params3.limit ?? DEFAULT_LARGE_LIMIT;
|
|
103534
|
-
const part = await readLineWindow(
|
|
103836
|
+
const part = await readLineWindow(fs48, realPath, size, params3.offset, limit);
|
|
103535
103837
|
const shown2 = part.lines.length;
|
|
103536
103838
|
return [
|
|
103537
103839
|
`${human} file \u2014 lines ${String(params3.offset)}\u2013${String(params3.offset + shown2 - 1)}${part.hasMoreAfter ? ", more follows" : " (end of file)"}.`,
|
|
@@ -103539,7 +103841,7 @@ async function readLarge(fs47, realPath, params3, size) {
|
|
|
103539
103841
|
number4(part.lines, params3.offset)
|
|
103540
103842
|
].join("\n");
|
|
103541
103843
|
}
|
|
103542
|
-
const total = await countLines(
|
|
103844
|
+
const total = await countLines(fs48, realPath, size);
|
|
103543
103845
|
return [
|
|
103544
103846
|
`${realPathName(realPath)} is ${human} (${total.toLocaleString()} lines) \u2014 too large to read at once.`,
|
|
103545
103847
|
"",
|
|
@@ -103674,7 +103976,7 @@ var searchFilesTool = {
|
|
|
103674
103976
|
};
|
|
103675
103977
|
|
|
103676
103978
|
// ../../packages/core/dist/tools/writeToFile.js
|
|
103677
|
-
var
|
|
103979
|
+
var import_node_path61 = __toESM(require("node:path"), 1);
|
|
103678
103980
|
var paramsSchema23 = external_exports.object({
|
|
103679
103981
|
path: external_exports.string().min(1).describe("Path to the file, relative to the workspace root."),
|
|
103680
103982
|
content: external_exports.string().describe("Full file content to write.")
|
|
@@ -103702,7 +104004,7 @@ var writeToFileTool = {
|
|
|
103702
104004
|
return { content: changed, isError: true, path: params3.path };
|
|
103703
104005
|
}
|
|
103704
104006
|
if (!exists2) {
|
|
103705
|
-
await context.fs.mkdir(
|
|
104007
|
+
await context.fs.mkdir(import_node_path61.default.dirname(resolved.realPath));
|
|
103706
104008
|
}
|
|
103707
104009
|
await context.fs.writeFile(resolved.realPath, params3.content);
|
|
103708
104010
|
await recordWrite(context, resolved.realPath);
|
|
@@ -103804,14 +104106,14 @@ function createDefaultToolRegistry() {
|
|
|
103804
104106
|
|
|
103805
104107
|
// ../../packages/core/dist/dataset/store.js
|
|
103806
104108
|
var import_promises33 = __toESM(require("node:fs/promises"), 1);
|
|
103807
|
-
var
|
|
104109
|
+
var import_node_path62 = __toESM(require("node:path"), 1);
|
|
103808
104110
|
var DatasetStore = class {
|
|
103809
104111
|
filePath;
|
|
103810
104112
|
statePath;
|
|
103811
104113
|
constructor(storageDir, datasetId) {
|
|
103812
104114
|
const safe = datasetId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
103813
|
-
this.filePath =
|
|
103814
|
-
this.statePath =
|
|
104115
|
+
this.filePath = import_node_path62.default.join(storageDir, "datasets", `${safe}.jsonl`);
|
|
104116
|
+
this.statePath = import_node_path62.default.join(storageDir, "datasets", `${safe}.state.json`);
|
|
103815
104117
|
}
|
|
103816
104118
|
/** Every record. A malformed line is skipped — one bad line costs one record, not the corpus. */
|
|
103817
104119
|
async load() {
|
|
@@ -103839,7 +104141,7 @@ var DatasetStore = class {
|
|
|
103839
104141
|
async append(records) {
|
|
103840
104142
|
if (records.length === 0)
|
|
103841
104143
|
return;
|
|
103842
|
-
await import_promises33.default.mkdir(
|
|
104144
|
+
await import_promises33.default.mkdir(import_node_path62.default.dirname(this.filePath), { recursive: true });
|
|
103843
104145
|
await import_promises33.default.writeFile(this.filePath, "", { flag: "a" });
|
|
103844
104146
|
const lines2 = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
103845
104147
|
await import_promises33.default.appendFile(this.filePath, `${lines2}
|
|
@@ -103847,7 +104149,7 @@ var DatasetStore = class {
|
|
|
103847
104149
|
}
|
|
103848
104150
|
/** Rewrites with exactly these. Temp-and-rename, so an interrupted prune leaves the old file. */
|
|
103849
104151
|
async replace(records) {
|
|
103850
|
-
await import_promises33.default.mkdir(
|
|
104152
|
+
await import_promises33.default.mkdir(import_node_path62.default.dirname(this.filePath), { recursive: true });
|
|
103851
104153
|
const temporary = `${this.filePath}.tmp`;
|
|
103852
104154
|
const body = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
103853
104155
|
await import_promises33.default.writeFile(temporary, records.length === 0 ? "" : `${body}
|
|
@@ -103901,7 +104203,7 @@ var DatasetStore = class {
|
|
|
103901
104203
|
}
|
|
103902
104204
|
}
|
|
103903
104205
|
async recordSync(at) {
|
|
103904
|
-
await import_promises33.default.mkdir(
|
|
104206
|
+
await import_promises33.default.mkdir(import_node_path62.default.dirname(this.statePath), { recursive: true });
|
|
103905
104207
|
const temporary = `${this.statePath}.tmp`;
|
|
103906
104208
|
await import_promises33.default.writeFile(temporary, JSON.stringify({ lastSyncedAt: at }), "utf8");
|
|
103907
104209
|
await replaceFile(temporary, this.statePath);
|
|
@@ -104240,8 +104542,8 @@ That is a fault in the tool itself, or the source is unreachable from here. Fix
|
|
|
104240
104542
|
}
|
|
104241
104543
|
|
|
104242
104544
|
// ../../packages/core/dist/s3/sigv4.js
|
|
104243
|
-
var
|
|
104244
|
-
var EMPTY_PAYLOAD_SHA256 = (0,
|
|
104545
|
+
var import_node_crypto22 = require("node:crypto");
|
|
104546
|
+
var EMPTY_PAYLOAD_SHA256 = (0, import_node_crypto22.createHash)("sha256").update("").digest("hex");
|
|
104245
104547
|
function encodeSegment(segment) {
|
|
104246
104548
|
return encodeURIComponent(segment).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
104247
104549
|
}
|
|
@@ -104265,10 +104567,10 @@ function amzDate(now) {
|
|
|
104265
104567
|
return `${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z`;
|
|
104266
104568
|
}
|
|
104267
104569
|
function signingKey(secretAccessKey, date5, region, service) {
|
|
104268
|
-
const dateKey = (0,
|
|
104269
|
-
const regionKey = (0,
|
|
104270
|
-
const serviceKey = (0,
|
|
104271
|
-
return (0,
|
|
104570
|
+
const dateKey = (0, import_node_crypto22.createHmac)("sha256", `AWS4${secretAccessKey}`).update(date5).digest();
|
|
104571
|
+
const regionKey = (0, import_node_crypto22.createHmac)("sha256", dateKey).update(region).digest();
|
|
104572
|
+
const serviceKey = (0, import_node_crypto22.createHmac)("sha256", regionKey).update(service).digest();
|
|
104573
|
+
return (0, import_node_crypto22.createHmac)("sha256", serviceKey).update("aws4_request").digest();
|
|
104272
104574
|
}
|
|
104273
104575
|
function signRequest(input) {
|
|
104274
104576
|
const service = input.service ?? "s3";
|
|
@@ -104277,7 +104579,7 @@ function signRequest(input) {
|
|
|
104277
104579
|
const date5 = timestamp.slice(0, 8);
|
|
104278
104580
|
const url2 = new URL(input.url);
|
|
104279
104581
|
const body = input.body ?? Buffer.alloc(0);
|
|
104280
|
-
const payloadHash = (0,
|
|
104582
|
+
const payloadHash = (0, import_node_crypto22.createHash)("sha256").update(body).digest("hex");
|
|
104281
104583
|
const headers = {
|
|
104282
104584
|
...input.headers,
|
|
104283
104585
|
host: url2.host,
|
|
@@ -104301,9 +104603,9 @@ function signRequest(input) {
|
|
|
104301
104603
|
"AWS4-HMAC-SHA256",
|
|
104302
104604
|
timestamp,
|
|
104303
104605
|
scope,
|
|
104304
|
-
(0,
|
|
104606
|
+
(0, import_node_crypto22.createHash)("sha256").update(canonicalRequest).digest("hex")
|
|
104305
104607
|
].join("\n");
|
|
104306
|
-
const signature = (0,
|
|
104608
|
+
const signature = (0, import_node_crypto22.createHmac)("sha256", signingKey(input.secretAccessKey, date5, input.region, service)).update(stringToSign).digest("hex");
|
|
104307
104609
|
return {
|
|
104308
104610
|
headers: {
|
|
104309
104611
|
...headers,
|
|
@@ -104333,8 +104635,8 @@ var S3Client = class {
|
|
|
104333
104635
|
const host = inPath ? origin.host : `${bucket}.${origin.host}`;
|
|
104334
104636
|
const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
|
|
104335
104637
|
const prefix = inPath ? `${mount}/${bucket}` : mount;
|
|
104336
|
-
const
|
|
104337
|
-
const url2 = new URL(`${origin.protocol}//${host}${prefix}${
|
|
104638
|
+
const path68 = key3 === "" ? "" : `/${key3.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
|
|
104639
|
+
const url2 = new URL(`${origin.protocol}//${host}${prefix}${path68}`);
|
|
104338
104640
|
for (const [name, value] of Object.entries(call.query ?? {}))
|
|
104339
104641
|
url2.searchParams.set(name, value);
|
|
104340
104642
|
return url2.toString();
|
|
@@ -104601,9 +104903,9 @@ async function syncFromS3(options) {
|
|
|
104601
104903
|
return result;
|
|
104602
104904
|
}
|
|
104603
104905
|
var MANIFEST_NAME = ".lightcode-sync.json";
|
|
104604
|
-
async function readManifest(
|
|
104906
|
+
async function readManifest(fs48, manifestPath) {
|
|
104605
104907
|
try {
|
|
104606
|
-
const parsed = JSON.parse((await
|
|
104908
|
+
const parsed = JSON.parse((await fs48.readBytes(manifestPath)).toString("utf8"));
|
|
104607
104909
|
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
104608
104910
|
} catch {
|
|
104609
104911
|
return {};
|
|
@@ -104621,14 +104923,14 @@ function join2(dir, relative) {
|
|
|
104621
104923
|
const left = dir.replace(/[\\/]+$/, "");
|
|
104622
104924
|
return `${left}/${relative}`;
|
|
104623
104925
|
}
|
|
104624
|
-
async function writeWhole3(
|
|
104625
|
-
if (
|
|
104626
|
-
await
|
|
104926
|
+
async function writeWhole3(fs48, target, bytes) {
|
|
104927
|
+
if (fs48.rename === void 0) {
|
|
104928
|
+
await fs48.writeBytes(target, bytes);
|
|
104627
104929
|
return;
|
|
104628
104930
|
}
|
|
104629
104931
|
const temporary = `${target}.${String(process.pid)}.${String(Date.now())}.part`;
|
|
104630
|
-
await
|
|
104631
|
-
await
|
|
104932
|
+
await fs48.writeBytes(temporary, bytes);
|
|
104933
|
+
await fs48.rename(temporary, target);
|
|
104632
104934
|
}
|
|
104633
104935
|
function dirname(filePath) {
|
|
104634
104936
|
const cut = filePath.lastIndexOf("/");
|
|
@@ -104824,15 +105126,15 @@ function createS3Tools(targets) {
|
|
|
104824
105126
|
}
|
|
104825
105127
|
|
|
104826
105128
|
// ../../packages/core/dist/s3/localFolder.js
|
|
104827
|
-
var
|
|
105129
|
+
var import_node_crypto23 = require("node:crypto");
|
|
104828
105130
|
function mirrorFolder(options) {
|
|
104829
105131
|
const connection = safeSegment(options.connectionId);
|
|
104830
|
-
const digest = (0,
|
|
105132
|
+
const digest = (0, import_node_crypto23.createHash)("sha256").update((options.prefix ?? "").trim().toLowerCase()).digest("hex").slice(0, 8);
|
|
104831
105133
|
return join3(options.storageDir, "s3", connection, `${options.kind}-${digest}`);
|
|
104832
105134
|
}
|
|
104833
105135
|
function safeSegment(id) {
|
|
104834
105136
|
const cleaned = id.replace(/[^a-zA-Z0-9._-]/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 40);
|
|
104835
|
-
const suffix = (0,
|
|
105137
|
+
const suffix = (0, import_node_crypto23.createHash)("sha256").update(id).digest("hex").slice(0, 6);
|
|
104836
105138
|
return `${cleaned === "" ? "connection" : cleaned}-${suffix}`;
|
|
104837
105139
|
}
|
|
104838
105140
|
function join3(...parts) {
|
|
@@ -104949,13 +105251,13 @@ function reachableOrigins(hosts, extra = []) {
|
|
|
104949
105251
|
}
|
|
104950
105252
|
|
|
104951
105253
|
// src/identity.ts
|
|
104952
|
-
var
|
|
105254
|
+
var import_node_crypto24 = __toESM(require("node:crypto"), 1);
|
|
104953
105255
|
var SingleUserIdentity = class _SingleUserIdentity {
|
|
104954
105256
|
describe;
|
|
104955
105257
|
static PRINCIPAL = { id: "local", displayName: "Local user" };
|
|
104956
105258
|
principal;
|
|
104957
105259
|
/** Long-lived, minted per server run, only ever sent in an `Authorization` header. */
|
|
104958
|
-
sessionToken =
|
|
105260
|
+
sessionToken = import_node_crypto24.default.randomBytes(32).toString("base64url");
|
|
104959
105261
|
/**
|
|
104960
105262
|
* Single-use and short-lived, because it travels in the launch URL's fragment where it
|
|
104961
105263
|
* can end up in shell history or a terminal scrollback (§14).
|
|
@@ -104965,7 +105267,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
104965
105267
|
* raises it, and what that costs is stated where it is set: a longer window is a longer time in
|
|
104966
105268
|
* which somebody reading that scrollback can use it before you do.
|
|
104967
105269
|
*/
|
|
104968
|
-
handoffToken =
|
|
105270
|
+
handoffToken = import_node_crypto24.default.randomBytes(32).toString("base64url");
|
|
104969
105271
|
handoffExpiresAt;
|
|
104970
105272
|
handoffSeconds;
|
|
104971
105273
|
/**
|
|
@@ -104999,7 +105301,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
104999
105301
|
* which is the same person it was printed to in the first place.
|
|
105000
105302
|
*/
|
|
105001
105303
|
remintHandoff() {
|
|
105002
|
-
this.handoffToken =
|
|
105304
|
+
this.handoffToken = import_node_crypto24.default.randomBytes(32).toString("base64url");
|
|
105003
105305
|
this.handoffExpiresAt = Date.now() + this.handoffSeconds * 1e3;
|
|
105004
105306
|
return this.handoffToken;
|
|
105005
105307
|
}
|
|
@@ -105038,10 +105340,10 @@ function timingSafeEquals(a, b) {
|
|
|
105038
105340
|
const left = Buffer.from(a);
|
|
105039
105341
|
const right = Buffer.from(b);
|
|
105040
105342
|
if (left.length !== right.length) return false;
|
|
105041
|
-
return
|
|
105343
|
+
return import_node_crypto24.default.timingSafeEqual(left, right);
|
|
105042
105344
|
}
|
|
105043
105345
|
function storageKeyFor(principal) {
|
|
105044
|
-
return
|
|
105346
|
+
return import_node_crypto24.default.createHash("sha256").update(principal.id).digest("hex").slice(0, 32);
|
|
105045
105347
|
}
|
|
105046
105348
|
var OpenIdentity = class _OpenIdentity {
|
|
105047
105349
|
describe = "single user, no token (--no-token)";
|
|
@@ -105193,6 +105495,8 @@ var PERSONAL_SETTINGS = /* @__PURE__ */ new Set([
|
|
|
105193
105495
|
"setMaxIterations",
|
|
105194
105496
|
// Whether *this user's* chats compact by themselves - their own conversations, nobody else's.
|
|
105195
105497
|
"setAutoCompact",
|
|
105498
|
+
"setAutoHandoff",
|
|
105499
|
+
"setUnlimitedSteps",
|
|
105196
105500
|
// How patiently *this user's* requests are retried.
|
|
105197
105501
|
"setConnectionRetry",
|
|
105198
105502
|
"setTaskExpertLimits",
|
|
@@ -105312,22 +105616,22 @@ async function readJsonBody(request2, maxBytes = 32 * 1024 * 1024) {
|
|
|
105312
105616
|
|
|
105313
105617
|
// src/fileSecretStore.ts
|
|
105314
105618
|
var import_promises34 = __toESM(require("node:fs/promises"), 1);
|
|
105315
|
-
var
|
|
105619
|
+
var import_node_path63 = __toESM(require("node:path"), 1);
|
|
105316
105620
|
|
|
105317
105621
|
// src/vaultCrypto.ts
|
|
105318
|
-
var
|
|
105622
|
+
var import_node_crypto25 = require("node:crypto");
|
|
105319
105623
|
function isVaultEnvelope(value) {
|
|
105320
105624
|
const v = value;
|
|
105321
105625
|
return typeof v === "object" && v !== null && v.sunVault === 1 && typeof v.iv === "string" && typeof v.tag === "string" && typeof v.data === "string";
|
|
105322
105626
|
}
|
|
105323
105627
|
function sealSecrets(secrets, key3) {
|
|
105324
|
-
const iv = (0,
|
|
105325
|
-
const cipher = (0,
|
|
105628
|
+
const iv = (0, import_node_crypto25.randomBytes)(12);
|
|
105629
|
+
const cipher = (0, import_node_crypto25.createCipheriv)("aes-256-gcm", key3, iv);
|
|
105326
105630
|
const data = Buffer.concat([cipher.update(JSON.stringify(secrets), "utf8"), cipher.final()]);
|
|
105327
105631
|
return { sunVault: 1, iv: iv.toString("base64"), tag: cipher.getAuthTag().toString("base64"), data: data.toString("base64") };
|
|
105328
105632
|
}
|
|
105329
105633
|
function openSecrets(envelope, key3) {
|
|
105330
|
-
const decipher = (0,
|
|
105634
|
+
const decipher = (0, import_node_crypto25.createDecipheriv)("aes-256-gcm", key3, Buffer.from(envelope.iv, "base64"));
|
|
105331
105635
|
decipher.setAuthTag(Buffer.from(envelope.tag, "base64"));
|
|
105332
105636
|
const plain = Buffer.concat([decipher.update(Buffer.from(envelope.data, "base64")), decipher.final()]);
|
|
105333
105637
|
const parsed = JSON.parse(plain.toString("utf8"));
|
|
@@ -105410,7 +105714,7 @@ var FileSecretStore = class {
|
|
|
105410
105714
|
);
|
|
105411
105715
|
}
|
|
105412
105716
|
mutate(secrets);
|
|
105413
|
-
await import_promises34.default.mkdir(
|
|
105717
|
+
await import_promises34.default.mkdir(import_node_path63.default.dirname(this.filePath), { recursive: true });
|
|
105414
105718
|
const temp = `${this.filePath}.${process.pid}.tmp`;
|
|
105415
105719
|
const body = this.key === void 0 ? secrets : sealSecrets(secrets, this.key);
|
|
105416
105720
|
await import_promises34.default.writeFile(temp, JSON.stringify(body, null, 2), { encoding: "utf8", mode: 384 });
|
|
@@ -105445,9 +105749,9 @@ var FileSecretStore = class {
|
|
|
105445
105749
|
};
|
|
105446
105750
|
|
|
105447
105751
|
// src/reviewQueue.ts
|
|
105448
|
-
var
|
|
105752
|
+
var import_node_crypto26 = __toESM(require("node:crypto"), 1);
|
|
105449
105753
|
var import_promises35 = __toESM(require("node:fs/promises"), 1);
|
|
105450
|
-
var
|
|
105754
|
+
var import_node_path64 = __toESM(require("node:path"), 1);
|
|
105451
105755
|
var ReviewQueue = class {
|
|
105452
105756
|
constructor(filePath) {
|
|
105453
105757
|
this.filePath = filePath;
|
|
@@ -105466,7 +105770,7 @@ var ReviewQueue = class {
|
|
|
105466
105770
|
}
|
|
105467
105771
|
async persist(items) {
|
|
105468
105772
|
this.cache = items;
|
|
105469
|
-
await import_promises35.default.mkdir(
|
|
105773
|
+
await import_promises35.default.mkdir(import_node_path64.default.dirname(this.filePath), { recursive: true });
|
|
105470
105774
|
const temporary = `${this.filePath}.tmp`;
|
|
105471
105775
|
await import_promises35.default.writeFile(temporary, JSON.stringify(items, null, 2), { encoding: "utf8", mode: 384 });
|
|
105472
105776
|
await replaceFile(temporary, this.filePath);
|
|
@@ -105484,7 +105788,7 @@ var ReviewQueue = class {
|
|
|
105484
105788
|
);
|
|
105485
105789
|
const queued = {
|
|
105486
105790
|
...request2,
|
|
105487
|
-
id:
|
|
105791
|
+
id: import_node_crypto26.default.randomUUID(),
|
|
105488
105792
|
submittedAt: Date.now(),
|
|
105489
105793
|
status: "pending"
|
|
105490
105794
|
};
|
|
@@ -105707,8 +106011,8 @@ var RoutedSecretStore = class {
|
|
|
105707
106011
|
|
|
105708
106012
|
// src/userVariables.ts
|
|
105709
106013
|
var import_promises36 = __toESM(require("node:fs/promises"), 1);
|
|
105710
|
-
var
|
|
105711
|
-
var
|
|
106014
|
+
var import_node_fs17 = require("node:fs");
|
|
106015
|
+
var import_node_path65 = __toESM(require("node:path"), 1);
|
|
105712
106016
|
var UserVariableStore = class {
|
|
105713
106017
|
constructor(filePath) {
|
|
105714
106018
|
this.filePath = filePath;
|
|
@@ -105723,7 +106027,7 @@ var UserVariableStore = class {
|
|
|
105723
106027
|
}
|
|
105724
106028
|
async save(variables) {
|
|
105725
106029
|
const parsed = sessionVariablesSchema.parse(variables);
|
|
105726
|
-
await import_promises36.default.mkdir(
|
|
106030
|
+
await import_promises36.default.mkdir(import_node_path65.default.dirname(this.filePath), { recursive: true });
|
|
105727
106031
|
const temporary = `${this.filePath}.tmp`;
|
|
105728
106032
|
await import_promises36.default.writeFile(temporary, JSON.stringify({ variables: parsed }, null, 2), {
|
|
105729
106033
|
encoding: "utf8",
|
|
@@ -105734,14 +106038,14 @@ var UserVariableStore = class {
|
|
|
105734
106038
|
}
|
|
105735
106039
|
};
|
|
105736
106040
|
function userVariableStoreFor(dataDir, principal) {
|
|
105737
|
-
return new UserVariableStore(userVariablesPath(
|
|
106041
|
+
return new UserVariableStore(userVariablesPath(import_node_path65.default.join(dataDir, "users", storageKeyFor(principal))));
|
|
105738
106042
|
}
|
|
105739
106043
|
function userVariablesPath(userDir) {
|
|
105740
|
-
return
|
|
106044
|
+
return import_node_path65.default.join(userDir, "variables.json");
|
|
105741
106045
|
}
|
|
105742
106046
|
function readVariablesFile(filePath) {
|
|
105743
106047
|
try {
|
|
105744
|
-
const raw = JSON.parse((0,
|
|
106048
|
+
const raw = JSON.parse((0, import_node_fs17.readFileSync)(filePath, "utf8"));
|
|
105745
106049
|
const parsed = sessionVariablesSchema.safeParse(raw["variables"]);
|
|
105746
106050
|
return parsed.success ? parsed.data : [];
|
|
105747
106051
|
} catch {
|
|
@@ -105765,13 +106069,13 @@ function hostedUser(env2 = process.env) {
|
|
|
105765
106069
|
}
|
|
105766
106070
|
|
|
105767
106071
|
// src/session.ts
|
|
105768
|
-
var
|
|
106072
|
+
var import_node_fs18 = require("node:fs");
|
|
105769
106073
|
var import_promises37 = __toESM(require("node:fs/promises"), 1);
|
|
105770
|
-
var
|
|
106074
|
+
var import_node_path67 = __toESM(require("node:path"), 1);
|
|
105771
106075
|
|
|
105772
106076
|
// src/credentialTool.ts
|
|
105773
106077
|
var import_node_child_process23 = require("node:child_process");
|
|
105774
|
-
var
|
|
106078
|
+
var import_node_path66 = __toESM(require("node:path"), 1);
|
|
105775
106079
|
var CREDENTIAL_PREFIX2 = "tool:";
|
|
105776
106080
|
var WRAPPER = [
|
|
105777
106081
|
"import importlib.util, json, sys",
|
|
@@ -105791,7 +106095,7 @@ async function fetchCredential(options, reference) {
|
|
|
105791
106095
|
if (name.length === 0) return { problem: "A credential reference needs a name: tool:<name>." };
|
|
105792
106096
|
const budget = options.timeoutMs ?? 3e4;
|
|
105793
106097
|
const run3 = await new Promise((resolve) => {
|
|
105794
|
-
const child = (0, import_node_child_process23.spawn)(options.interpreter, ["-c", WRAPPER,
|
|
106098
|
+
const child = (0, import_node_child_process23.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path66.default.resolve(options.file), name], {
|
|
105795
106099
|
windowsHide: true,
|
|
105796
106100
|
// The environment this was started in, as with the identity function: the libraries that
|
|
105797
106101
|
// hold credentials are configured through it, and nothing here is model-authored.
|
|
@@ -105987,7 +106291,7 @@ var FileConfigStore = class {
|
|
|
105987
106291
|
const filePath = this.pathFor(scope);
|
|
105988
106292
|
if (filePath === void 0)
|
|
105989
106293
|
throw new Error(`Cannot write ${scope} config: no workspace is open`);
|
|
105990
|
-
await import_promises37.default.mkdir(
|
|
106294
|
+
await import_promises37.default.mkdir(import_node_path67.default.dirname(filePath), { recursive: true });
|
|
105991
106295
|
const temporary = `${filePath}.${process.pid.toString(36)}.tmp`;
|
|
105992
106296
|
await import_promises37.default.writeFile(temporary, contents, { encoding: "utf8", mode: 384 });
|
|
105993
106297
|
await replaceFile(temporary, filePath);
|
|
@@ -106024,8 +106328,8 @@ var FileConfigStore = class {
|
|
|
106024
106328
|
};
|
|
106025
106329
|
let watcher;
|
|
106026
106330
|
try {
|
|
106027
|
-
watcher = (0,
|
|
106028
|
-
if (filename ===
|
|
106331
|
+
watcher = (0, import_node_fs18.watch)(import_node_path67.default.dirname(filePath), (_event, filename) => {
|
|
106332
|
+
if (filename === import_node_path67.default.basename(filePath)) onChange();
|
|
106029
106333
|
});
|
|
106030
106334
|
} catch {
|
|
106031
106335
|
}
|
|
@@ -106053,7 +106357,7 @@ var FileWorkspaceState = class {
|
|
|
106053
106357
|
async set(key3, value) {
|
|
106054
106358
|
if (value === void 0) delete this.values[key3];
|
|
106055
106359
|
else this.values[key3] = value;
|
|
106056
|
-
await import_promises37.default.mkdir(
|
|
106360
|
+
await import_promises37.default.mkdir(import_node_path67.default.dirname(this.filePath), { recursive: true });
|
|
106057
106361
|
await import_promises37.default.writeFile(this.filePath, JSON.stringify(this.values, null, 2), {
|
|
106058
106362
|
encoding: "utf8",
|
|
106059
106363
|
mode: 384
|
|
@@ -106103,7 +106407,7 @@ function createBrowserUi(workspaceRoot, post, fastFs, shared) {
|
|
|
106103
106407
|
openFile: async (filePath) => {
|
|
106104
106408
|
try {
|
|
106105
106409
|
post(
|
|
106106
|
-
[`[info] ${
|
|
106410
|
+
[`[info] ${import_node_path67.default.basename(filePath)}`, "", await import_promises37.default.readFile(filePath, "utf8")].join("\n")
|
|
106107
106411
|
);
|
|
106108
106412
|
} catch (error51) {
|
|
106109
106413
|
post(`[warning] Could not read ${filePath}: ${String(error51)}`);
|
|
@@ -106147,7 +106451,7 @@ function createBrowserUi(workspaceRoot, post, fastFs, shared) {
|
|
|
106147
106451
|
for (const entry of entries) {
|
|
106148
106452
|
if (found2.length >= limit) return;
|
|
106149
106453
|
if (entry.name.startsWith(".") && entry.name !== ".env") continue;
|
|
106150
|
-
const full =
|
|
106454
|
+
const full = import_node_path67.default.join(dir, entry.name);
|
|
106151
106455
|
if (entry.isDirectory()) {
|
|
106152
106456
|
if (skip.has(entry.name)) continue;
|
|
106153
106457
|
if (mode === "folders" && (needle.length === 0 || entry.name.toLowerCase().includes(needle))) found2.push(full);
|
|
@@ -106185,11 +106489,11 @@ var SHARED_COLLECTIONS = [
|
|
|
106185
106489
|
{ key: "mcpServers" }
|
|
106186
106490
|
];
|
|
106187
106491
|
async function createSession(options) {
|
|
106188
|
-
const userDir =
|
|
106492
|
+
const userDir = import_node_path67.default.join(options.dataDir, "users", storageKeyFor(options.principal));
|
|
106189
106493
|
await import_promises37.default.mkdir(userDir, { recursive: true, mode: 448 });
|
|
106190
106494
|
const variableStore = new UserVariableStore(userVariablesPath(userDir));
|
|
106191
106495
|
const userVariables = () => variableStore.read();
|
|
106192
|
-
const workspaceState = new FileWorkspaceState(
|
|
106496
|
+
const workspaceState = new FileWorkspaceState(import_node_path67.default.join(userDir, "workspace-state.json"));
|
|
106193
106497
|
await workspaceState.load();
|
|
106194
106498
|
const services = {
|
|
106195
106499
|
/*
|
|
@@ -106284,16 +106588,16 @@ async function createSession(options) {
|
|
|
106284
106588
|
*/
|
|
106285
106589
|
secrets: new CredentialPointerStore(
|
|
106286
106590
|
withCredentialTool(
|
|
106287
|
-
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ??
|
|
106288
|
-
new FileSecretStore(options.secretsFile ??
|
|
106591
|
+
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ?? import_node_path67.default.join(userDir, "secrets.json"), options.secretsKey) : new RoutedSecretStore(
|
|
106592
|
+
new FileSecretStore(options.secretsFile ?? import_node_path67.default.join(userDir, "secrets.json"), options.secretsKey),
|
|
106289
106593
|
options.sharedSecrets
|
|
106290
106594
|
),
|
|
106291
106595
|
options
|
|
106292
106596
|
)
|
|
106293
106597
|
),
|
|
106294
106598
|
configStore: withSharedEntries(
|
|
106295
|
-
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ??
|
|
106296
|
-
new FileConfigStore(options.configFile ??
|
|
106599
|
+
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ?? import_node_path67.default.join(userDir, "config.json"), options.workspaceRoot) : new SharedProfileConfigStore(
|
|
106600
|
+
new FileConfigStore(options.configFile ?? import_node_path67.default.join(userDir, "config.json"), options.workspaceRoot),
|
|
106297
106601
|
options.sharedProfiles
|
|
106298
106602
|
),
|
|
106299
106603
|
options
|
|
@@ -106411,8 +106715,8 @@ async function startServer(options) {
|
|
|
106411
106715
|
));
|
|
106412
106716
|
const roles = options.roles ?? SINGLE_USER_POLICY;
|
|
106413
106717
|
const sharedStore = options.sharedConfig;
|
|
106414
|
-
const sharedSecretStore = new FileSecretStore(
|
|
106415
|
-
const reviews = new ReviewQueue(
|
|
106718
|
+
const sharedSecretStore = new FileSecretStore(import_node_path68.default.join(options.dataDir, "shared-secrets.json"));
|
|
106719
|
+
const reviews = new ReviewQueue(import_node_path68.default.join(options.dataDir, "reviews.json"));
|
|
106416
106720
|
let sharedCache = {
|
|
106417
106721
|
variables: [],
|
|
106418
106722
|
adminIds: [],
|
|
@@ -106793,14 +107097,14 @@ async function startServer(options) {
|
|
|
106793
107097
|
return "No workspace is open, so there is nowhere to write it.";
|
|
106794
107098
|
try {
|
|
106795
107099
|
if (item2.kind === "skill") {
|
|
106796
|
-
const dir2 =
|
|
107100
|
+
const dir2 = import_node_path68.default.join(options.workspaceRoot, ".lightcode", "skills");
|
|
106797
107101
|
await import_promises38.default.mkdir(dir2, { recursive: true });
|
|
106798
|
-
await import_promises38.default.writeFile(
|
|
107102
|
+
await import_promises38.default.writeFile(import_node_path68.default.join(dir2, `${item2.name}.md`), item2.content, "utf8");
|
|
106799
107103
|
return void 0;
|
|
106800
107104
|
}
|
|
106801
|
-
const dir =
|
|
107105
|
+
const dir = import_node_path68.default.join(options.workspaceRoot, ".lightcode", "tools");
|
|
106802
107106
|
await import_promises38.default.mkdir(dir, { recursive: true });
|
|
106803
|
-
await import_promises38.default.writeFile(
|
|
107107
|
+
await import_promises38.default.writeFile(import_node_path68.default.join(dir, `${item2.name}.py`), item2.content, "utf8");
|
|
106804
107108
|
return void 0;
|
|
106805
107109
|
} catch (error51) {
|
|
106806
107110
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -106839,7 +107143,7 @@ async function startServer(options) {
|
|
|
106839
107143
|
connection.transport.post({ type: "credentials", credentials: await readCredentials() });
|
|
106840
107144
|
}
|
|
106841
107145
|
if (options.credentialsFile !== void 0) {
|
|
106842
|
-
(0,
|
|
107146
|
+
(0, import_node_fs19.watchFile)(options.credentialsFile, { interval: 1500 }, () => {
|
|
106843
107147
|
for (const connection of connections.values()) void postCredentials(connection);
|
|
106844
107148
|
});
|
|
106845
107149
|
}
|
|
@@ -106949,7 +107253,7 @@ async function startServer(options) {
|
|
|
106949
107253
|
return;
|
|
106950
107254
|
}
|
|
106951
107255
|
response.writeHead(200, {
|
|
106952
|
-
"Content-Type": CONTENT_TYPES2[
|
|
107256
|
+
"Content-Type": CONTENT_TYPES2[import_node_path68.default.extname(asset)] ?? "application/octet-stream",
|
|
106953
107257
|
...securityHeaders()
|
|
106954
107258
|
});
|
|
106955
107259
|
response.end(body);
|