@chosengeneration/light-code 0.142.0 → 0.144.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 +1064 -536
- package/dist/server.cjs +1029 -501
- 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 path61 = 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 (path61 && !path61.startsWith("/")) {
|
|
502
|
+
path61 = `/${path61}`;
|
|
503
503
|
}
|
|
504
|
-
url2 = new URL(origin +
|
|
504
|
+
url2 = new URL(origin + path61);
|
|
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(path61) {
|
|
2119
|
+
if (typeof path61 !== "string") {
|
|
2120
2120
|
return "";
|
|
2121
2121
|
}
|
|
2122
|
-
for (var i =
|
|
2123
|
-
switch (
|
|
2122
|
+
for (var i = path61.length - 1; i >= 0; --i) {
|
|
2123
|
+
switch (path61.charCodeAt(i)) {
|
|
2124
2124
|
case 47:
|
|
2125
2125
|
// '/'
|
|
2126
2126
|
case 92:
|
|
2127
|
-
|
|
2128
|
-
return
|
|
2127
|
+
path61 = path61.slice(i + 1);
|
|
2128
|
+
return path61 === ".." || path61 === "." ? "" : path61;
|
|
2129
2129
|
}
|
|
2130
2130
|
}
|
|
2131
|
-
return
|
|
2131
|
+
return path61 === ".." || path61 === "." ? "" : path61;
|
|
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: path61,
|
|
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 path61 !== "string") {
|
|
5176
5176
|
throw new InvalidArgumentError("path must be a string");
|
|
5177
|
-
} else if (
|
|
5177
|
+
} else if (path61[0] !== "/" && !(path61.startsWith("http://") || path61.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(path61) !== 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(path61, query) : path61;
|
|
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 path61 = 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 = path61;
|
|
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], request);
|
|
7490
7490
|
return;
|
|
7491
7491
|
}
|
|
7492
|
-
const { body, method, path:
|
|
7492
|
+
const { body, method, path: path61, host, upgrade, headers, blocking, reset } = request;
|
|
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} ${path61} 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, request) {
|
|
7605
|
-
const { body, method, path:
|
|
7605
|
+
const { body, method, path: path61, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
|
|
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] = path61;
|
|
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(path61) {
|
|
9889
|
+
if (typeof path61 !== "string") {
|
|
9890
|
+
return path61;
|
|
9891
9891
|
}
|
|
9892
|
-
const pathSegments =
|
|
9892
|
+
const pathSegments = path61.split("?");
|
|
9893
9893
|
if (pathSegments.length !== 2) {
|
|
9894
|
-
return
|
|
9894
|
+
return path61;
|
|
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: path61, method, body, headers }) {
|
|
9901
|
+
const pathMatch = matchValue(mockDispatch2.path, path61);
|
|
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, key2) {
|
|
9917
9917
|
const basePath = key2.query ? buildURL(key2.path, key2.query) : key2.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: path61 }) => matchValue(safeUrl(path61), 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: path61, method, body, headers, query } = opts;
|
|
9957
9957
|
return {
|
|
9958
|
-
path:
|
|
9958
|
+
path: path61,
|
|
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: path61, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
10408
10408
|
Method: method,
|
|
10409
10409
|
Origin: origin,
|
|
10410
|
-
Path:
|
|
10410
|
+
Path: path61,
|
|
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(path61) {
|
|
15031
|
+
for (const char of path61) {
|
|
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 path61 = opts.path;
|
|
16712
16712
|
if (!opts.path.startsWith("/")) {
|
|
16713
|
-
|
|
16713
|
+
path61 = `/${path61}`;
|
|
16714
16714
|
}
|
|
16715
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
16715
|
+
url2 = new URL(util.parseOrigin(url2).origin + path61);
|
|
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(path61) {
|
|
19987
|
+
let input = path61;
|
|
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 [path61, query] = wsComponent.resourceName.split("?");
|
|
20240
|
+
wsComponent.path = path61 && path61 !== "/" ? path61 : void 0;
|
|
20241
20241
|
wsComponent.query = query;
|
|
20242
20242
|
wsComponent.resourceName = void 0;
|
|
20243
20243
|
}
|
|
@@ -23655,7 +23655,7 @@ var require_windows = __commonJS({
|
|
|
23655
23655
|
module2.exports = isexe;
|
|
23656
23656
|
isexe.sync = sync;
|
|
23657
23657
|
var fs41 = require("fs");
|
|
23658
|
-
function checkPathExt(
|
|
23658
|
+
function checkPathExt(path61, 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 && path61.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, path61, options) {
|
|
23676
23676
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
23677
23677
|
return false;
|
|
23678
23678
|
}
|
|
23679
|
-
return checkPathExt(
|
|
23679
|
+
return checkPathExt(path61, options);
|
|
23680
23680
|
}
|
|
23681
|
-
function isexe(
|
|
23682
|
-
fs41.stat(
|
|
23683
|
-
cb(er, er ? false : checkStat(stat,
|
|
23681
|
+
function isexe(path61, options, cb) {
|
|
23682
|
+
fs41.stat(path61, function(er, stat) {
|
|
23683
|
+
cb(er, er ? false : checkStat(stat, path61, options));
|
|
23684
23684
|
});
|
|
23685
23685
|
}
|
|
23686
|
-
function sync(
|
|
23687
|
-
return checkStat(fs41.statSync(
|
|
23686
|
+
function sync(path61, options) {
|
|
23687
|
+
return checkStat(fs41.statSync(path61), path61, options);
|
|
23688
23688
|
}
|
|
23689
23689
|
}
|
|
23690
23690
|
});
|
|
@@ -23695,13 +23695,13 @@ var require_mode = __commonJS({
|
|
|
23695
23695
|
module2.exports = isexe;
|
|
23696
23696
|
isexe.sync = sync;
|
|
23697
23697
|
var fs41 = require("fs");
|
|
23698
|
-
function isexe(
|
|
23699
|
-
fs41.stat(
|
|
23698
|
+
function isexe(path61, options, cb) {
|
|
23699
|
+
fs41.stat(path61, function(er, stat) {
|
|
23700
23700
|
cb(er, er ? false : checkStat(stat, options));
|
|
23701
23701
|
});
|
|
23702
23702
|
}
|
|
23703
|
-
function sync(
|
|
23704
|
-
return checkStat(fs41.statSync(
|
|
23703
|
+
function sync(path61, options) {
|
|
23704
|
+
return checkStat(fs41.statSync(path61), options);
|
|
23705
23705
|
}
|
|
23706
23706
|
function checkStat(stat, options) {
|
|
23707
23707
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -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(path61, 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(path61, 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(path61, 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(path61, options) {
|
|
23767
23767
|
try {
|
|
23768
|
-
return core.sync(
|
|
23768
|
+
return core.sync(path61, 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 path61 = 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 = path61.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 = path61.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 path61 = 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 ? path61.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 = path61.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 [path61, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
23979
|
+
const binary = path61.split("/").pop();
|
|
23980
23980
|
if (binary === "env") {
|
|
23981
23981
|
return argument;
|
|
23982
23982
|
}
|
|
@@ -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 path61 = 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 = path61.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_promises34 = __toESM(require("node:fs/promises"), 1);
|
|
24261
|
-
var
|
|
24261
|
+
var import_node_fs15 = require("node:fs");
|
|
24262
24262
|
var import_node_http = require("node:http");
|
|
24263
|
-
var
|
|
24263
|
+
var import_node_path61 = __toESM(require("node:path"), 1);
|
|
24264
24264
|
|
|
24265
24265
|
// ../../packages/core/dist/platform/http.js
|
|
24266
24266
|
var import_node_crypto = require("node:crypto");
|
|
@@ -25421,10 +25421,10 @@ function mergeDefs(...defs) {
|
|
|
25421
25421
|
function cloneDef(schema8) {
|
|
25422
25422
|
return mergeDefs(schema8._zod.def);
|
|
25423
25423
|
}
|
|
25424
|
-
function getElementAtPath(obj,
|
|
25425
|
-
if (!
|
|
25424
|
+
function getElementAtPath(obj, path61) {
|
|
25425
|
+
if (!path61)
|
|
25426
25426
|
return obj;
|
|
25427
|
-
return
|
|
25427
|
+
return path61.reduce((acc, key2) => acc?.[key2], obj);
|
|
25428
25428
|
}
|
|
25429
25429
|
function promiseAllObject(promisesObj) {
|
|
25430
25430
|
const keys = Object.keys(promisesObj);
|
|
@@ -25833,11 +25833,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
25833
25833
|
}
|
|
25834
25834
|
return false;
|
|
25835
25835
|
}
|
|
25836
|
-
function prefixIssues(
|
|
25836
|
+
function prefixIssues(path61, issues) {
|
|
25837
25837
|
return issues.map((iss) => {
|
|
25838
25838
|
var _a3;
|
|
25839
25839
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
25840
|
-
iss.path.unshift(
|
|
25840
|
+
iss.path.unshift(path61);
|
|
25841
25841
|
return iss;
|
|
25842
25842
|
});
|
|
25843
25843
|
}
|
|
@@ -25984,16 +25984,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
25984
25984
|
}
|
|
25985
25985
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
25986
25986
|
const fieldErrors = { _errors: [] };
|
|
25987
|
-
const processError = (error52,
|
|
25987
|
+
const processError = (error52, path61 = []) => {
|
|
25988
25988
|
for (const issue2 of error52.issues) {
|
|
25989
25989
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
25990
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
25990
|
+
issue2.errors.map((issues) => processError({ issues }, [...path61, ...issue2.path]));
|
|
25991
25991
|
} else if (issue2.code === "invalid_key") {
|
|
25992
|
-
processError({ issues: issue2.issues }, [...
|
|
25992
|
+
processError({ issues: issue2.issues }, [...path61, ...issue2.path]);
|
|
25993
25993
|
} else if (issue2.code === "invalid_element") {
|
|
25994
|
-
processError({ issues: issue2.issues }, [...
|
|
25994
|
+
processError({ issues: issue2.issues }, [...path61, ...issue2.path]);
|
|
25995
25995
|
} else {
|
|
25996
|
-
const fullpath = [...
|
|
25996
|
+
const fullpath = [...path61, ...issue2.path];
|
|
25997
25997
|
if (fullpath.length === 0) {
|
|
25998
25998
|
fieldErrors._errors.push(mapper(issue2));
|
|
25999
25999
|
} else {
|
|
@@ -26020,17 +26020,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26020
26020
|
}
|
|
26021
26021
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
26022
26022
|
const result = { errors: [] };
|
|
26023
|
-
const processError = (error52,
|
|
26023
|
+
const processError = (error52, path61 = []) => {
|
|
26024
26024
|
var _a3, _b;
|
|
26025
26025
|
for (const issue2 of error52.issues) {
|
|
26026
26026
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
26027
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
26027
|
+
issue2.errors.map((issues) => processError({ issues }, [...path61, ...issue2.path]));
|
|
26028
26028
|
} else if (issue2.code === "invalid_key") {
|
|
26029
|
-
processError({ issues: issue2.issues }, [...
|
|
26029
|
+
processError({ issues: issue2.issues }, [...path61, ...issue2.path]);
|
|
26030
26030
|
} else if (issue2.code === "invalid_element") {
|
|
26031
|
-
processError({ issues: issue2.issues }, [...
|
|
26031
|
+
processError({ issues: issue2.issues }, [...path61, ...issue2.path]);
|
|
26032
26032
|
} else {
|
|
26033
|
-
const fullpath = [...
|
|
26033
|
+
const fullpath = [...path61, ...issue2.path];
|
|
26034
26034
|
if (fullpath.length === 0) {
|
|
26035
26035
|
result.errors.push(mapper(issue2));
|
|
26036
26036
|
continue;
|
|
@@ -26062,8 +26062,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26062
26062
|
}
|
|
26063
26063
|
function toDotPath(_path) {
|
|
26064
26064
|
const segs = [];
|
|
26065
|
-
const
|
|
26066
|
-
for (const seg of
|
|
26065
|
+
const path61 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
26066
|
+
for (const seg of path61) {
|
|
26067
26067
|
if (typeof seg === "number")
|
|
26068
26068
|
segs.push(`[${seg}]`);
|
|
26069
26069
|
else if (typeof seg === "symbol")
|
|
@@ -38755,13 +38755,13 @@ function resolveRef(ref, ctx) {
|
|
|
38755
38755
|
if (!ref.startsWith("#")) {
|
|
38756
38756
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
38757
38757
|
}
|
|
38758
|
-
const
|
|
38759
|
-
if (
|
|
38758
|
+
const path61 = ref.slice(1).split("/").filter(Boolean);
|
|
38759
|
+
if (path61.length === 0) {
|
|
38760
38760
|
return ctx.rootSchema;
|
|
38761
38761
|
}
|
|
38762
38762
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
38763
|
-
if (
|
|
38764
|
-
const key2 =
|
|
38763
|
+
if (path61[0] === defsKey) {
|
|
38764
|
+
const key2 = path61[1];
|
|
38765
38765
|
if (!key2 || !ctx.defs[key2]) {
|
|
38766
38766
|
throw new Error(`Reference not found: ${ref}`);
|
|
38767
38767
|
}
|
|
@@ -40546,7 +40546,15 @@ var configSchema = external_exports.object({
|
|
|
40546
40546
|
* able to add a folder could offer its own add-on under a familiar name.
|
|
40547
40547
|
*/
|
|
40548
40548
|
addons: external_exports.object({
|
|
40549
|
-
folders: external_exports.array(external_exports.string().min(1)).max(50)
|
|
40549
|
+
folders: external_exports.array(external_exports.string().min(1)).max(50),
|
|
40550
|
+
/**
|
|
40551
|
+
* What the user entered on each add-on's own tab (`addons/page.ts`), by package name. Never
|
|
40552
|
+
* a secret: those are in secret storage under `addon:<package>:<record>:<field>`.
|
|
40553
|
+
*/
|
|
40554
|
+
settings: external_exports.record(external_exports.string(), external_exports.object({
|
|
40555
|
+
values: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
40556
|
+
records: external_exports.array(external_exports.object({ id: external_exports.string().min(1).max(40), values: external_exports.record(external_exports.string(), external_exports.unknown()) })).max(500).optional()
|
|
40557
|
+
}))
|
|
40550
40558
|
}).partial(),
|
|
40551
40559
|
lsp: external_exports.object({
|
|
40552
40560
|
enabled: external_exports.boolean(),
|
|
@@ -44014,8 +44022,8 @@ var SUPERSEDED_MARKER = "[Superseded: this file was read again later in the conv
|
|
|
44014
44022
|
function readFilePath(argumentsJson) {
|
|
44015
44023
|
try {
|
|
44016
44024
|
const parsed = JSON.parse(argumentsJson.length > 0 ? argumentsJson : "{}");
|
|
44017
|
-
const
|
|
44018
|
-
return typeof
|
|
44025
|
+
const path61 = parsed.path;
|
|
44026
|
+
return typeof path61 === "string" && path61.length > 0 ? path61 : void 0;
|
|
44019
44027
|
} catch {
|
|
44020
44028
|
return void 0;
|
|
44021
44029
|
}
|
|
@@ -44028,8 +44036,8 @@ function dropSupersededReads(messages) {
|
|
|
44028
44036
|
for (const toolCall of message4.toolCalls ?? []) {
|
|
44029
44037
|
if (toolCall.name !== "read_file")
|
|
44030
44038
|
continue;
|
|
44031
|
-
const
|
|
44032
|
-
if (
|
|
44039
|
+
const path61 = readFilePath(toolCall.arguments);
|
|
44040
|
+
if (path61 === void 0)
|
|
44033
44041
|
continue;
|
|
44034
44042
|
keyByCallId.set(toolCall.id, toolCall.arguments);
|
|
44035
44043
|
}
|
|
@@ -46873,13 +46881,13 @@ var OpenSearchClient = class {
|
|
|
46873
46881
|
* `_bulk`, `_delete_by_query`, index creation — is refused here rather than merely
|
|
46874
46882
|
* unused, so no future edit or crafted argument can turn a read client into a writer.
|
|
46875
46883
|
*/
|
|
46876
|
-
async request(
|
|
46884
|
+
async request(path61, options = {}) {
|
|
46877
46885
|
const method = options.method ?? "GET";
|
|
46878
|
-
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(
|
|
46886
|
+
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(path61);
|
|
46879
46887
|
if (method !== "GET" && !isSearchPost) {
|
|
46880
|
-
throw new OpenSearchError(`Refusing ${method} ${
|
|
46888
|
+
throw new OpenSearchError(`Refusing ${method} ${path61}: this client is read-only. Indexing goes through the indexer, which the user starts from Settings.`);
|
|
46881
46889
|
}
|
|
46882
|
-
const url2 = `${this.base}${
|
|
46890
|
+
const url2 = `${this.base}${path61}`;
|
|
46883
46891
|
const request = {
|
|
46884
46892
|
method,
|
|
46885
46893
|
headers: this.headers()
|
|
@@ -47046,11 +47054,11 @@ function collectFields(properties, prefix, out) {
|
|
|
47046
47054
|
return;
|
|
47047
47055
|
for (const [name, raw] of Object.entries(properties)) {
|
|
47048
47056
|
const field2 = raw;
|
|
47049
|
-
const
|
|
47057
|
+
const path61 = prefix.length > 0 ? `${prefix}.${name}` : name;
|
|
47050
47058
|
if (typeof field2.type === "string")
|
|
47051
|
-
out[
|
|
47059
|
+
out[path61] = field2.type;
|
|
47052
47060
|
if (field2.properties !== void 0)
|
|
47053
|
-
collectFields(field2.properties,
|
|
47061
|
+
collectFields(field2.properties, path61, out);
|
|
47054
47062
|
}
|
|
47055
47063
|
}
|
|
47056
47064
|
function describeStatus(status2, url2, body) {
|
|
@@ -47069,23 +47077,23 @@ function describeStatus(status2, url2, body) {
|
|
|
47069
47077
|
var TEXT_TYPES = /* @__PURE__ */ new Set(["text", "match_only_text", "search_as_you_type", "wildcard"]);
|
|
47070
47078
|
var KEYWORD_TYPES = /* @__PURE__ */ new Set(["keyword", "constant_keyword"]);
|
|
47071
47079
|
var NOISE_FIELDS = /* @__PURE__ */ new Set(["@version", "ecs", "tags", "stream", "input", "agent", "host", "event"]);
|
|
47072
|
-
function leafName(
|
|
47073
|
-
const parts =
|
|
47074
|
-
return parts[parts.length - 1] ??
|
|
47080
|
+
function leafName(path61) {
|
|
47081
|
+
const parts = path61.split(".");
|
|
47082
|
+
return parts[parts.length - 1] ?? path61;
|
|
47075
47083
|
}
|
|
47076
47084
|
function selectQueryFields(mapping, limit = 25) {
|
|
47077
47085
|
const text = [];
|
|
47078
47086
|
const keyword = [];
|
|
47079
|
-
for (const [
|
|
47080
|
-
if (NOISE_FIELDS.has(leafName(
|
|
47087
|
+
for (const [path61, type] of Object.entries(mapping)) {
|
|
47088
|
+
if (NOISE_FIELDS.has(leafName(path61)) || NOISE_FIELDS.has(path61.split(".")[0] ?? ""))
|
|
47081
47089
|
continue;
|
|
47082
47090
|
if (TEXT_TYPES.has(type)) {
|
|
47083
|
-
text.push(
|
|
47091
|
+
text.push(path61);
|
|
47084
47092
|
} else if (KEYWORD_TYPES.has(type)) {
|
|
47085
|
-
const parent =
|
|
47086
|
-
if (
|
|
47093
|
+
const parent = path61.replace(/\.keyword$/, "");
|
|
47094
|
+
if (path61.endsWith(".keyword") && TEXT_TYPES.has(mapping[parent] ?? ""))
|
|
47087
47095
|
continue;
|
|
47088
|
-
keyword.push(
|
|
47096
|
+
keyword.push(path61);
|
|
47089
47097
|
}
|
|
47090
47098
|
}
|
|
47091
47099
|
const byDepth = (a, b) => a.split(".").length - b.split(".").length || a.localeCompare(b);
|
|
@@ -47227,8 +47235,8 @@ var OpenSearchIndexWriter = class {
|
|
|
47227
47235
|
}
|
|
47228
47236
|
return headers;
|
|
47229
47237
|
}
|
|
47230
|
-
async request(
|
|
47231
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
47238
|
+
async request(path61, method, body, signal) {
|
|
47239
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path61}`;
|
|
47232
47240
|
const request = { method, headers: this.headers() };
|
|
47233
47241
|
if (body !== void 0) {
|
|
47234
47242
|
if (typeof body === "string") {
|
|
@@ -47442,13 +47450,13 @@ var OpenSearchIndexWriter = class {
|
|
|
47442
47450
|
for (const hit of hits) {
|
|
47443
47451
|
const source = hit._source ?? {};
|
|
47444
47452
|
const vector = source.vector;
|
|
47445
|
-
const
|
|
47446
|
-
if (typeof
|
|
47453
|
+
const path61 = source.path;
|
|
47454
|
+
if (typeof path61 !== "string" || !Array.isArray(vector))
|
|
47447
47455
|
continue;
|
|
47448
47456
|
documents.push({
|
|
47449
47457
|
id: hit._id ?? "",
|
|
47450
47458
|
text: typeof source.text === "string" ? source.text : "",
|
|
47451
|
-
path:
|
|
47459
|
+
path: path61,
|
|
47452
47460
|
startLine: typeof source.startLine === "number" ? source.startLine : 1,
|
|
47453
47461
|
endLine: typeof source.endLine === "number" ? source.endLine : 1,
|
|
47454
47462
|
vector
|
|
@@ -47522,8 +47530,8 @@ var RestTransport = class {
|
|
|
47522
47530
|
* threw would push every caller into catching and re-inspecting an error to find out
|
|
47523
47531
|
* whether it was really an error. `expectOk` is there for the cases that are.
|
|
47524
47532
|
*/
|
|
47525
|
-
async send(
|
|
47526
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
47533
|
+
async send(path61, method, body, signal) {
|
|
47534
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path61}`;
|
|
47527
47535
|
const request = { method, headers: this.headers() };
|
|
47528
47536
|
if (body !== void 0)
|
|
47529
47537
|
request.body = JSON.stringify(body);
|
|
@@ -47549,11 +47557,11 @@ var RestTransport = class {
|
|
|
47549
47557
|
return { status: response.status, body: parsed };
|
|
47550
47558
|
}
|
|
47551
47559
|
/** Sends, and throws unless the status is 2xx. */
|
|
47552
|
-
async expectOk(
|
|
47553
|
-
const result = await this.send(
|
|
47560
|
+
async expectOk(path61, method, body, signal) {
|
|
47561
|
+
const result = await this.send(path61, method, body, signal);
|
|
47554
47562
|
if (result.status < 200 || result.status >= 300) {
|
|
47555
47563
|
const detail = typeof result.body === "string" ? result.body : JSON.stringify(result.body ?? "");
|
|
47556
|
-
throw new VectorStoreError(`${method} ${
|
|
47564
|
+
throw new VectorStoreError(`${method} ${path61} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}`, result.status);
|
|
47557
47565
|
}
|
|
47558
47566
|
return result.body;
|
|
47559
47567
|
}
|
|
@@ -47661,10 +47669,10 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
47661
47669
|
const matches = [];
|
|
47662
47670
|
for (let index = 0; index < ids.length; index++) {
|
|
47663
47671
|
const metadata = metadatas[index] ?? {};
|
|
47664
|
-
const
|
|
47665
|
-
if (
|
|
47672
|
+
const path61 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
47673
|
+
if (path61 === void 0)
|
|
47666
47674
|
continue;
|
|
47667
|
-
if (prefix !== void 0 && prefix.length > 0 && !
|
|
47675
|
+
if (prefix !== void 0 && prefix.length > 0 && !path61.startsWith(prefix))
|
|
47668
47676
|
continue;
|
|
47669
47677
|
if (projectHere && typeof metadata.project === "string" && !options.project?.names.includes(metadata.project))
|
|
47670
47678
|
continue;
|
|
@@ -47678,7 +47686,7 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
47678
47686
|
*/
|
|
47679
47687
|
score: typeof distance === "number" ? 1 / (1 + Math.max(0, distance)) : 0,
|
|
47680
47688
|
text: documents[index] ?? (typeof metadata.text === "string" ? metadata.text : ""),
|
|
47681
|
-
path:
|
|
47689
|
+
path: path61
|
|
47682
47690
|
};
|
|
47683
47691
|
if (typeof metadata.startLine === "number")
|
|
47684
47692
|
match.startLine = metadata.startLine;
|
|
@@ -47789,13 +47797,13 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
47789
47797
|
for (let index = 0; index < ids.length; index++) {
|
|
47790
47798
|
const metadata = result.metadatas?.[index] ?? {};
|
|
47791
47799
|
const vector = result.embeddings?.[index];
|
|
47792
|
-
const
|
|
47793
|
-
if (
|
|
47800
|
+
const path61 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
47801
|
+
if (path61 === void 0 || !Array.isArray(vector))
|
|
47794
47802
|
continue;
|
|
47795
47803
|
documents.push({
|
|
47796
47804
|
id: ids[index] ?? "",
|
|
47797
47805
|
text: result.documents?.[index] ?? "",
|
|
47798
|
-
path:
|
|
47806
|
+
path: path61,
|
|
47799
47807
|
startLine: typeof metadata.startLine === "number" ? metadata.startLine : 1,
|
|
47800
47808
|
endLine: typeof metadata.endLine === "number" ? metadata.endLine : 1,
|
|
47801
47809
|
vector
|
|
@@ -47812,9 +47820,9 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
47812
47820
|
const result = await this.rest.expectOk(`${this.base}/collections/${found2.id}/get`, "POST", { include: ["metadatas"], limit }, options.signal);
|
|
47813
47821
|
const paths = /* @__PURE__ */ new Set();
|
|
47814
47822
|
for (const metadata of result.metadatas ?? []) {
|
|
47815
|
-
const
|
|
47816
|
-
if (typeof
|
|
47817
|
-
paths.add(
|
|
47823
|
+
const path61 = metadata?.path;
|
|
47824
|
+
if (typeof path61 === "string")
|
|
47825
|
+
paths.add(path61);
|
|
47818
47826
|
}
|
|
47819
47827
|
return [...paths];
|
|
47820
47828
|
}
|
|
@@ -47841,14 +47849,14 @@ var MARKER_ID = "5f6d2a41-0000-5000-8000-6c69676874c0";
|
|
|
47841
47849
|
var MARKER_MARK = "light-code";
|
|
47842
47850
|
function toMatch(point) {
|
|
47843
47851
|
const payload = point.payload ?? {};
|
|
47844
|
-
const
|
|
47845
|
-
if (
|
|
47852
|
+
const path61 = typeof payload.path === "string" ? payload.path : void 0;
|
|
47853
|
+
if (path61 === void 0)
|
|
47846
47854
|
return void 0;
|
|
47847
47855
|
const match = {
|
|
47848
47856
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
47849
47857
|
score: typeof point.score === "number" ? point.score : 0,
|
|
47850
47858
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
47851
|
-
path:
|
|
47859
|
+
path: path61
|
|
47852
47860
|
};
|
|
47853
47861
|
if (typeof payload.startLine === "number")
|
|
47854
47862
|
match.startLine = payload.startLine;
|
|
@@ -48042,13 +48050,13 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
48042
48050
|
const documents = [];
|
|
48043
48051
|
for (const point of result.body.result?.points ?? []) {
|
|
48044
48052
|
const payload = point.payload ?? {};
|
|
48045
|
-
const
|
|
48046
|
-
if (
|
|
48053
|
+
const path61 = typeof payload.path === "string" ? payload.path : void 0;
|
|
48054
|
+
if (path61 === void 0 || !Array.isArray(point.vector))
|
|
48047
48055
|
continue;
|
|
48048
48056
|
documents.push({
|
|
48049
48057
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
48050
48058
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
48051
|
-
path:
|
|
48059
|
+
path: path61,
|
|
48052
48060
|
startLine: typeof payload.startLine === "number" ? payload.startLine : 1,
|
|
48053
48061
|
endLine: typeof payload.endLine === "number" ? payload.endLine : 1,
|
|
48054
48062
|
vector: point.vector
|
|
@@ -48075,9 +48083,9 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
48075
48083
|
throw new VectorStoreError(`Could not list "${collection}" (HTTP ${String(result.status)}).`, result.status);
|
|
48076
48084
|
}
|
|
48077
48085
|
for (const point of result.body.result?.points ?? []) {
|
|
48078
|
-
const
|
|
48079
|
-
if (typeof
|
|
48080
|
-
paths.add(
|
|
48086
|
+
const path61 = point.payload?.path;
|
|
48087
|
+
if (typeof path61 === "string")
|
|
48088
|
+
paths.add(path61);
|
|
48081
48089
|
}
|
|
48082
48090
|
offset = result.body.result?.next_page_offset;
|
|
48083
48091
|
if (offset === void 0 || offset === null)
|
|
@@ -48611,8 +48619,8 @@ function teamSkillDocument(skill, body, vector, attribution) {
|
|
|
48611
48619
|
vector
|
|
48612
48620
|
};
|
|
48613
48621
|
}
|
|
48614
|
-
function nameFromPath(
|
|
48615
|
-
return
|
|
48622
|
+
function nameFromPath(path61) {
|
|
48623
|
+
return path61.startsWith("skill:") ? path61.slice("skill:".length) : path61;
|
|
48616
48624
|
}
|
|
48617
48625
|
function toHit(match, self) {
|
|
48618
48626
|
return {
|
|
@@ -51694,8 +51702,8 @@ function createMailCoverageTool(options) {
|
|
|
51694
51702
|
}
|
|
51695
51703
|
};
|
|
51696
51704
|
}
|
|
51697
|
-
function normaliseFolder(
|
|
51698
|
-
return
|
|
51705
|
+
function normaliseFolder(path61) {
|
|
51706
|
+
return path61.toLowerCase().replace(/[\\/]+/g, "\\");
|
|
51699
51707
|
}
|
|
51700
51708
|
function haystackOf(record2) {
|
|
51701
51709
|
return `${record2.subject}
|
|
@@ -52191,7 +52199,7 @@ async function refreshMail(options) {
|
|
|
52191
52199
|
const limit = options.batchLimit ?? 2e3;
|
|
52192
52200
|
const previewChars = options.previewChars ?? 400;
|
|
52193
52201
|
const sinceMs = Date.now() - options.days * 24 * 60 * 60 * 1e3;
|
|
52194
|
-
const harvested = await options.harvest(options.folders.map((
|
|
52202
|
+
const harvested = await options.harvest(options.folders.map((path61) => ({ path: path61, sinceMs })), { limit, previewChars });
|
|
52195
52203
|
const fetched = harvested.messages.map(toRecord);
|
|
52196
52204
|
if (fetched.length === 0) {
|
|
52197
52205
|
return { added: 0, more: false, total: known.length, embedded: 0, backfilled: 0, complete: [] };
|
|
@@ -52232,9 +52240,9 @@ async function syncMail(options) {
|
|
|
52232
52240
|
const backfillDone = await options.store.loadBackfillState();
|
|
52233
52241
|
const limit = options.batchLimit ?? 500;
|
|
52234
52242
|
const previewChars = options.previewChars ?? 400;
|
|
52235
|
-
const forwardRequests = options.folders.map((
|
|
52236
|
-
const mark = marks.get(
|
|
52237
|
-
return mark === void 0 ? { path:
|
|
52243
|
+
const forwardRequests = options.folders.map((path61) => {
|
|
52244
|
+
const mark = marks.get(path61);
|
|
52245
|
+
return mark === void 0 ? { path: path61 } : { path: path61, sinceMs: mark.newest - 1e3 };
|
|
52238
52246
|
});
|
|
52239
52247
|
const forward = await options.harvest(forwardRequests, { limit, previewChars });
|
|
52240
52248
|
let candidates = forward.messages.map(toRecord);
|
|
@@ -52243,15 +52251,15 @@ async function syncMail(options) {
|
|
|
52243
52251
|
let more = forward.truncated;
|
|
52244
52252
|
const remaining = limit - candidates.length;
|
|
52245
52253
|
const floor = options.retentionMonths === void 0 ? void 0 : monthsBefore(options.now ?? Date.now(), options.retentionMonths);
|
|
52246
|
-
const outstanding = options.folders.filter((
|
|
52247
|
-
const atFloor = floor === void 0 ? [] : outstanding.filter((
|
|
52248
|
-
const behind = outstanding.filter((
|
|
52254
|
+
const outstanding = options.folders.filter((path61) => marks.has(path61) && backfillDone[path61] !== true);
|
|
52255
|
+
const atFloor = floor === void 0 ? [] : outstanding.filter((path61) => marks.get(path61).oldest <= floor);
|
|
52256
|
+
const behind = outstanding.filter((path61) => !atFloor.includes(path61));
|
|
52249
52257
|
completed.push(...atFloor);
|
|
52250
52258
|
if (remaining > 0 && behind.length > 0 && options.signal?.aborted !== true) {
|
|
52251
|
-
const backRequests = behind.map((
|
|
52252
|
-
path:
|
|
52259
|
+
const backRequests = behind.map((path61) => ({
|
|
52260
|
+
path: path61,
|
|
52253
52261
|
// Strictly older, so the oldest held message is not fetched again every pass.
|
|
52254
|
-
beforeMs: marks.get(
|
|
52262
|
+
beforeMs: marks.get(path61).oldest,
|
|
52255
52263
|
// And no older than retention wants. The harvest ANDs the two into one window.
|
|
52256
52264
|
...floor === void 0 ? {} : { sinceMs: floor }
|
|
52257
52265
|
}));
|
|
@@ -52259,9 +52267,9 @@ async function syncMail(options) {
|
|
|
52259
52267
|
backfilled = backward.messages.length;
|
|
52260
52268
|
candidates = [...candidates, ...backward.messages.map(toRecord)];
|
|
52261
52269
|
const returnedFor = new Set(backward.messages.map((message4) => message4.folder));
|
|
52262
|
-
for (const
|
|
52263
|
-
if (!returnedFor.has(
|
|
52264
|
-
completed.push(
|
|
52270
|
+
for (const path61 of behind) {
|
|
52271
|
+
if (!returnedFor.has(path61))
|
|
52272
|
+
completed.push(path61);
|
|
52265
52273
|
}
|
|
52266
52274
|
if (backward.truncated || backfilled > 0)
|
|
52267
52275
|
more = true;
|
|
@@ -52269,7 +52277,7 @@ async function syncMail(options) {
|
|
|
52269
52277
|
if (completed.length > 0) {
|
|
52270
52278
|
await options.store.saveBackfillState({
|
|
52271
52279
|
...backfillDone,
|
|
52272
|
-
...Object.fromEntries(completed.map((
|
|
52280
|
+
...Object.fromEntries(completed.map((path61) => [path61, true]))
|
|
52273
52281
|
});
|
|
52274
52282
|
}
|
|
52275
52283
|
const fresh = withoutKnown(candidates, known);
|
|
@@ -52603,14 +52611,14 @@ function formatBytes(size) {
|
|
|
52603
52611
|
return `${(size / (1 << 10)).toFixed(1)}KB`;
|
|
52604
52612
|
return `${String(size)}B`;
|
|
52605
52613
|
}
|
|
52606
|
-
async function readTail(fs41,
|
|
52614
|
+
async function readTail(fs41, path61, size, count3) {
|
|
52607
52615
|
let span = Math.min(size, CHUNK);
|
|
52608
52616
|
let text;
|
|
52609
52617
|
let start;
|
|
52610
52618
|
for (; ; ) {
|
|
52611
52619
|
start = Math.max(0, size - span);
|
|
52612
52620
|
const decoder = new import_node_string_decoder.StringDecoder("utf8");
|
|
52613
|
-
text = decoder.write(await fs41.readBytesSlice(
|
|
52621
|
+
text = decoder.write(await fs41.readBytesSlice(path61, start, size)) + decoder.end();
|
|
52614
52622
|
const enough = text.split("\n").length > count3;
|
|
52615
52623
|
if (enough || start === 0 || span >= size)
|
|
52616
52624
|
break;
|
|
@@ -52628,7 +52636,7 @@ async function readTail(fs41, path60, size, count3) {
|
|
|
52628
52636
|
hasMoreAfter: false
|
|
52629
52637
|
};
|
|
52630
52638
|
}
|
|
52631
|
-
async function readLineWindow(fs41,
|
|
52639
|
+
async function readLineWindow(fs41, path61, size, from, count3) {
|
|
52632
52640
|
const decoder = new import_node_string_decoder.StringDecoder("utf8");
|
|
52633
52641
|
const lines = [];
|
|
52634
52642
|
let pending = "";
|
|
@@ -52643,7 +52651,7 @@ async function readLineWindow(fs41, path60, size, from, count3) {
|
|
|
52643
52651
|
};
|
|
52644
52652
|
scan: while (position < size) {
|
|
52645
52653
|
const end = Math.min(size, position + CHUNK);
|
|
52646
|
-
pending += decoder.write(await fs41.readBytesSlice(
|
|
52654
|
+
pending += decoder.write(await fs41.readBytesSlice(path61, position, end));
|
|
52647
52655
|
position = end;
|
|
52648
52656
|
const parts = pending.split(/\r\n|\r|\n/);
|
|
52649
52657
|
pending = parts.pop() ?? "";
|
|
@@ -52666,13 +52674,13 @@ async function readLineWindow(fs41, path60, size, from, count3) {
|
|
|
52666
52674
|
hasMoreAfter: !reachedEnd || lineNumber > from + lines.length
|
|
52667
52675
|
};
|
|
52668
52676
|
}
|
|
52669
|
-
async function countLines(fs41,
|
|
52677
|
+
async function countLines(fs41, path61, size) {
|
|
52670
52678
|
let newlines = 0;
|
|
52671
52679
|
let position = 0;
|
|
52672
52680
|
let lastByte = -1;
|
|
52673
52681
|
while (position < size) {
|
|
52674
52682
|
const end = Math.min(size, position + CHUNK);
|
|
52675
|
-
const buffer = await fs41.readBytesSlice(
|
|
52683
|
+
const buffer = await fs41.readBytesSlice(path61, position, end);
|
|
52676
52684
|
for (const byte of buffer)
|
|
52677
52685
|
if (byte === 10)
|
|
52678
52686
|
newlines += 1;
|
|
@@ -57276,8 +57284,8 @@ async function random(size) {
|
|
|
57276
57284
|
const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
|
|
57277
57285
|
let result = "";
|
|
57278
57286
|
while (result.length < size) {
|
|
57279
|
-
const
|
|
57280
|
-
for (const randomByte of
|
|
57287
|
+
const randomBytes4 = await getRandomValues(size - result.length);
|
|
57288
|
+
for (const randomByte of randomBytes4) {
|
|
57281
57289
|
if (randomByte < evenDistCutoff) {
|
|
57282
57290
|
result += mask[randomByte % mask.length];
|
|
57283
57291
|
}
|
|
@@ -58878,9 +58886,22 @@ var McpConnection = class {
|
|
|
58878
58886
|
return result.tools.map((tool) => ({
|
|
58879
58887
|
name: tool.name,
|
|
58880
58888
|
description: tool.description ?? "",
|
|
58881
|
-
inputSchema: tool.inputSchema
|
|
58889
|
+
inputSchema: tool.inputSchema,
|
|
58890
|
+
...tool._meta?.["lightCode/panelOnly"] === true ? { panelOnly: true } : {}
|
|
58882
58891
|
}));
|
|
58883
58892
|
}
|
|
58893
|
+
/** The same call, keeping what a button needs that the model's text rendering drops. */
|
|
58894
|
+
async callToolRaw(name, args) {
|
|
58895
|
+
if (this.client === void 0)
|
|
58896
|
+
throw new Error(`MCP server "${this.serverName}" is not connected.`);
|
|
58897
|
+
const timeoutSeconds = this.config.toolTimeouts?.[name] ?? this.config.timeout ?? this.defaultTimeout?.();
|
|
58898
|
+
const result = await this.client.callTool({ name, arguments: args }, void 0, timeoutSeconds === void 0 ? void 0 : { timeout: timeoutSeconds * 1e3 });
|
|
58899
|
+
return {
|
|
58900
|
+
text: renderToolResult(result),
|
|
58901
|
+
isError: result.isError === true,
|
|
58902
|
+
...result.structuredContent !== void 0 ? { structured: result.structuredContent } : {}
|
|
58903
|
+
};
|
|
58904
|
+
}
|
|
58884
58905
|
async callTool(name, args) {
|
|
58885
58906
|
if (this.client === void 0)
|
|
58886
58907
|
throw new Error(`MCP server "${this.serverName}" is not connected.`);
|
|
@@ -59031,6 +59052,8 @@ var McpRegistry = class {
|
|
|
59031
59052
|
statuses = /* @__PURE__ */ new Map();
|
|
59032
59053
|
errors = /* @__PURE__ */ new Map();
|
|
59033
59054
|
toolsByServer = /* @__PURE__ */ new Map();
|
|
59055
|
+
/** Tools a server marked for its own settings-tab buttons only: never offered to the model. */
|
|
59056
|
+
panelTools = /* @__PURE__ */ new Map();
|
|
59034
59057
|
logs = /* @__PURE__ */ new Map();
|
|
59035
59058
|
servers = {};
|
|
59036
59059
|
constructor(secrets, events, logger, getAlwaysAllowed = () => [], defaultTimeout = void 0, isRepositoryServer = async () => false) {
|
|
@@ -59155,7 +59178,9 @@ var McpRegistry = class {
|
|
|
59155
59178
|
if (connection === void 0)
|
|
59156
59179
|
return;
|
|
59157
59180
|
try {
|
|
59158
|
-
const
|
|
59181
|
+
const listed = await connection.listTools();
|
|
59182
|
+
this.panelTools.set(name, new Set(listed.filter((descriptor) => descriptor.panelOnly === true).map((descriptor) => descriptor.name)));
|
|
59183
|
+
const descriptors = listed.filter((descriptor) => descriptor.panelOnly !== true);
|
|
59159
59184
|
this.toolsByServer.set(name, descriptors.map((descriptor) => ({
|
|
59160
59185
|
descriptor,
|
|
59161
59186
|
tool: adaptTool(name, descriptor.name, descriptor.description, descriptor.inputSchema, async (args) => {
|
|
@@ -59186,6 +59211,22 @@ var McpRegistry = class {
|
|
|
59186
59211
|
if (options.silent !== true)
|
|
59187
59212
|
this.events.onStateChanged();
|
|
59188
59213
|
}
|
|
59214
|
+
/**
|
|
59215
|
+
* Calls one of a server's tools for a button the user pressed, returning the structured answer as
|
|
59216
|
+
* well as the text. Reaches a panel-only tool, and an ordinary one; deny rules still apply.
|
|
59217
|
+
*/
|
|
59218
|
+
async callPanelTool(server, tool, args) {
|
|
59219
|
+
const connection = this.connections.get(server);
|
|
59220
|
+
if (connection === void 0)
|
|
59221
|
+
throw new Error(`MCP server "${server}" is not running.`);
|
|
59222
|
+
const known = this.panelTools.get(server)?.has(tool) === true || (this.toolsByServer.get(server) ?? []).some((entry) => entry.descriptor.name === tool);
|
|
59223
|
+
if (!known)
|
|
59224
|
+
throw new Error(`"${server}" offers no tool "${tool}".`);
|
|
59225
|
+
const decision = denyCheck(tool, args, this.servers[server]?.deny);
|
|
59226
|
+
if (decision.denied)
|
|
59227
|
+
throw new Error(decision.message ?? "Refused by a deny rule.");
|
|
59228
|
+
return connection.callToolRaw(tool, args);
|
|
59229
|
+
}
|
|
59189
59230
|
async restart(name) {
|
|
59190
59231
|
await this.disconnect(name);
|
|
59191
59232
|
const config2 = this.servers[name];
|
|
@@ -60618,13 +60659,13 @@ function buildExport(config2, selected) {
|
|
|
60618
60659
|
if (has(config2, key2))
|
|
60619
60660
|
exported[key2] = config2[key2];
|
|
60620
60661
|
}
|
|
60621
|
-
for (const
|
|
60622
|
-
stripPath(exported,
|
|
60662
|
+
for (const path61 of section.strip ?? [])
|
|
60663
|
+
stripPath(exported, path61);
|
|
60623
60664
|
}
|
|
60624
60665
|
return exported;
|
|
60625
60666
|
}
|
|
60626
|
-
function stripPath(target,
|
|
60627
|
-
const [head, ...rest] =
|
|
60667
|
+
function stripPath(target, path61) {
|
|
60668
|
+
const [head, ...rest] = path61.split(".");
|
|
60628
60669
|
if (head === void 0)
|
|
60629
60670
|
return;
|
|
60630
60671
|
const value = target[head];
|
|
@@ -60652,14 +60693,14 @@ function applyImport(existing, imported, selected) {
|
|
|
60652
60693
|
else
|
|
60653
60694
|
delete merged[key2];
|
|
60654
60695
|
}
|
|
60655
|
-
for (const
|
|
60656
|
-
carryPath(existing, merged,
|
|
60696
|
+
for (const path61 of section.strip ?? []) {
|
|
60697
|
+
carryPath(existing, merged, path61);
|
|
60657
60698
|
}
|
|
60658
60699
|
}
|
|
60659
60700
|
return merged;
|
|
60660
60701
|
}
|
|
60661
|
-
function carryPath(from, to,
|
|
60662
|
-
const [head, ...rest] =
|
|
60702
|
+
function carryPath(from, to, path61) {
|
|
60703
|
+
const [head, ...rest] = path61.split(".");
|
|
60663
60704
|
if (head === void 0)
|
|
60664
60705
|
return;
|
|
60665
60706
|
const source = from[head];
|
|
@@ -62958,7 +62999,7 @@ The conversation is longer than this model accepts, and it could not be shortene
|
|
|
62958
62999
|
}
|
|
62959
63000
|
|
|
62960
63001
|
// ../../packages/core/dist/host/bridge.js
|
|
62961
|
-
var
|
|
63002
|
+
var import_node_crypto15 = require("node:crypto");
|
|
62962
63003
|
|
|
62963
63004
|
// ../../packages/core/dist/atlassian/autosysGateway.js
|
|
62964
63005
|
function withBasicCredentials(auth2, headerName, username, password) {
|
|
@@ -64243,21 +64284,141 @@ var FileMachineApprovals = class {
|
|
|
64243
64284
|
// ../../packages/core/dist/addons/discover.js
|
|
64244
64285
|
var import_promises18 = __toESM(require("node:fs/promises"), 1);
|
|
64245
64286
|
var import_node_path32 = __toESM(require("node:path"), 1);
|
|
64246
|
-
|
|
64287
|
+
|
|
64288
|
+
// ../../packages/core/dist/addons/page.js
|
|
64289
|
+
var KEY = /^[a-zA-Z][a-zA-Z0-9_]{0,40}$/;
|
|
64290
|
+
var addonFieldSchema = external_exports.object({
|
|
64291
|
+
key: external_exports.string().regex(KEY),
|
|
64292
|
+
label: external_exports.string().min(1).max(80),
|
|
64293
|
+
type: external_exports.enum(["string", "number", "boolean", "choice", "secret", "path", "text"]),
|
|
64294
|
+
required: external_exports.boolean().optional(),
|
|
64295
|
+
default: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()]).optional(),
|
|
64296
|
+
options: external_exports.array(external_exports.object({ value: external_exports.string(), label: external_exports.string() })).max(30).optional(),
|
|
64297
|
+
placeholder: external_exports.string().max(200).optional(),
|
|
64298
|
+
help: external_exports.string().max(500).optional(),
|
|
64299
|
+
/** A pattern the value must match, with the sentence shown when it does not. */
|
|
64300
|
+
pattern: external_exports.string().max(200).optional(),
|
|
64301
|
+
patternMessage: external_exports.string().max(200).optional(),
|
|
64302
|
+
/** Shown only while another field of the same form has this value - auth fields by auth method. */
|
|
64303
|
+
showWhen: external_exports.object({ field: external_exports.string().regex(KEY), equals: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]) }).optional()
|
|
64304
|
+
});
|
|
64305
|
+
var addonPageSchema = external_exports.object({
|
|
64306
|
+
title: external_exports.string().min(1).max(40),
|
|
64307
|
+
description: external_exports.string().max(1e3).optional(),
|
|
64308
|
+
/** Settings of the add-on as a whole. */
|
|
64309
|
+
fields: external_exports.array(addonFieldSchema).max(30).optional(),
|
|
64310
|
+
/** A list of things the user adds - machines, sites, accounts. */
|
|
64311
|
+
records: external_exports.object({
|
|
64312
|
+
/** What one is called: "machine". */
|
|
64313
|
+
noun: external_exports.string().min(1).max(30),
|
|
64314
|
+
title: external_exports.string().min(1).max(40),
|
|
64315
|
+
description: external_exports.string().max(1e3).optional(),
|
|
64316
|
+
/** The field that names a record, unique among them: what the user and the agent call it. */
|
|
64317
|
+
keyField: external_exports.string().regex(KEY),
|
|
64318
|
+
/** One line under the name, e.g. "{username}@{host}:{port}". */
|
|
64319
|
+
summary: external_exports.string().max(200).optional(),
|
|
64320
|
+
fields: external_exports.array(addonFieldSchema).min(1).max(30),
|
|
64321
|
+
/**
|
|
64322
|
+
* Buttons on each record, each calling one of the add-on's own tools with `{ [keyField]: name }`
|
|
64323
|
+
* - "Test connection". Pressed by the user, about a record they are looking at, so it is not an
|
|
64324
|
+
* agent's tool call and asks no approval.
|
|
64325
|
+
*/
|
|
64326
|
+
actions: external_exports.array(external_exports.object({
|
|
64327
|
+
label: external_exports.string().min(1).max(40),
|
|
64328
|
+
tool: external_exports.string().regex(/^[a-zA-Z0-9_-]{1,64}$/),
|
|
64329
|
+
/** Shown before it runs, needing a second press: for an action that changes something. */
|
|
64330
|
+
confirm: external_exports.string().max(800).optional(),
|
|
64331
|
+
/** Offered only for records with this value - "Set up SSH key" for password sign-in. */
|
|
64332
|
+
showWhen: external_exports.object({ field: external_exports.string().regex(KEY), equals: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]) }).optional()
|
|
64333
|
+
})).max(5).optional(),
|
|
64334
|
+
max: external_exports.number().int().positive().max(500).optional()
|
|
64335
|
+
}).optional()
|
|
64336
|
+
});
|
|
64337
|
+
function addonSecretRef(pkg, recordId, field2) {
|
|
64338
|
+
return `addon:${pkg}:${recordId ?? "_"}:${field2}`;
|
|
64339
|
+
}
|
|
64340
|
+
function cleanAddonValues(fields, values) {
|
|
64341
|
+
const out = {};
|
|
64342
|
+
const effective = { ...values };
|
|
64343
|
+
for (const field2 of fields) {
|
|
64344
|
+
const given = values[field2.key];
|
|
64345
|
+
if ((given === void 0 || given === "" || given === null) && field2.default !== void 0)
|
|
64346
|
+
effective[field2.key] = field2.default;
|
|
64347
|
+
}
|
|
64348
|
+
for (const field2 of fields) {
|
|
64349
|
+
if (field2.type === "secret")
|
|
64350
|
+
continue;
|
|
64351
|
+
const value = effective[field2.key];
|
|
64352
|
+
if (!isShown(field2, effective))
|
|
64353
|
+
continue;
|
|
64354
|
+
if (value === void 0 || value === "") {
|
|
64355
|
+
if (field2.required === true)
|
|
64356
|
+
return { ok: false, message: `${field2.label} is required.` };
|
|
64357
|
+
continue;
|
|
64358
|
+
}
|
|
64359
|
+
switch (field2.type) {
|
|
64360
|
+
case "number": {
|
|
64361
|
+
const n = typeof value === "number" ? value : Number(String(value).trim());
|
|
64362
|
+
if (!Number.isFinite(n))
|
|
64363
|
+
return { ok: false, message: `${field2.label} must be a number.` };
|
|
64364
|
+
out[field2.key] = n;
|
|
64365
|
+
break;
|
|
64366
|
+
}
|
|
64367
|
+
case "boolean":
|
|
64368
|
+
out[field2.key] = value === true || value === "true";
|
|
64369
|
+
break;
|
|
64370
|
+
case "choice": {
|
|
64371
|
+
const text = String(value);
|
|
64372
|
+
if (!(field2.options ?? []).some((option) => option.value === text))
|
|
64373
|
+
return { ok: false, message: `${field2.label}: choose one of the options.` };
|
|
64374
|
+
out[field2.key] = text;
|
|
64375
|
+
break;
|
|
64376
|
+
}
|
|
64377
|
+
default: {
|
|
64378
|
+
const text = String(value).trim();
|
|
64379
|
+
if (field2.pattern !== void 0 && !new RegExp(field2.pattern).test(text)) {
|
|
64380
|
+
return { ok: false, message: field2.patternMessage ?? `${field2.label} is not in the expected form.` };
|
|
64381
|
+
}
|
|
64382
|
+
out[field2.key] = text;
|
|
64383
|
+
}
|
|
64384
|
+
}
|
|
64385
|
+
}
|
|
64386
|
+
return { ok: true, values: out };
|
|
64387
|
+
}
|
|
64388
|
+
function recordUpdateFrom(structured) {
|
|
64389
|
+
const update = structured?.lightCode?.recordUpdate;
|
|
64390
|
+
return update !== null && typeof update === "object" && !Array.isArray(update) ? update : void 0;
|
|
64391
|
+
}
|
|
64392
|
+
function isShown(field2, values) {
|
|
64393
|
+
if (field2.showWhen === void 0)
|
|
64394
|
+
return true;
|
|
64395
|
+
const current = String(values[field2.showWhen.field] ?? "");
|
|
64396
|
+
const wanted = field2.showWhen.equals;
|
|
64397
|
+
return Array.isArray(wanted) ? wanted.includes(current) : current === wanted;
|
|
64398
|
+
}
|
|
64399
|
+
|
|
64400
|
+
// ../../packages/core/dist/addons/discover.js
|
|
64401
|
+
function defaultAddonFolders(env2, execPath, platform, npmrc) {
|
|
64247
64402
|
const folders = [];
|
|
64248
|
-
const
|
|
64403
|
+
const configured = npmrc?.split(/\r?\n/).map((line) => /^\s*prefix\s*=\s*(.+?)\s*$/.exec(line)?.[1]).find((value) => value !== void 0)?.replace(/^["']|["']$/g, "");
|
|
64404
|
+
const prefixes = [env2["npm_config_prefix"] ?? env2["NPM_CONFIG_PREFIX"], configured].filter((p) => p !== void 0 && p.length > 0);
|
|
64249
64405
|
if (platform === "win32") {
|
|
64250
|
-
|
|
64251
|
-
folders.push(import_node_path32.default.join(prefix, "node_modules"));
|
|
64406
|
+
for (const prefix of prefixes)
|
|
64407
|
+
folders.push(import_node_path32.default.join(expandWindows(prefix, env2), "node_modules"));
|
|
64252
64408
|
if (env2["APPDATA"] !== void 0)
|
|
64253
64409
|
folders.push(import_node_path32.default.join(env2["APPDATA"], "npm", "node_modules"));
|
|
64410
|
+
if (import_node_path32.default.basename(execPath).toLowerCase() === "node.exe")
|
|
64411
|
+
folders.push(import_node_path32.default.join(import_node_path32.default.dirname(execPath), "node_modules"));
|
|
64254
64412
|
} else {
|
|
64255
|
-
|
|
64256
|
-
folders.push(import_node_path32.default.join(prefix, "lib", "node_modules"));
|
|
64413
|
+
for (const prefix of prefixes)
|
|
64414
|
+
folders.push(import_node_path32.default.join(prefix.replace(/^~(?=\/|$)/, env2["HOME"] ?? "~"), "lib", "node_modules"));
|
|
64257
64415
|
folders.push(import_node_path32.default.join(import_node_path32.default.dirname(import_node_path32.default.dirname(execPath)), "lib", "node_modules"));
|
|
64258
64416
|
}
|
|
64259
64417
|
return [...new Set(folders.map((folder) => import_node_path32.default.resolve(folder)))];
|
|
64260
64418
|
}
|
|
64419
|
+
function expandWindows(value, env2) {
|
|
64420
|
+
return value.replace(/%([^%]+)%|\$\{([^}]+)\}/g, (whole, a, b) => env2[a ?? b ?? ""] ?? whole);
|
|
64421
|
+
}
|
|
64261
64422
|
function addonServerName(pkg) {
|
|
64262
64423
|
const bare = pkg.replace(/^@[^/]+\//, "").replace(/^(light-code|lightcode|fire-code)-addon-/i, "");
|
|
64263
64424
|
const slug = bare.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -64296,6 +64457,7 @@ async function readAddon(dir) {
|
|
|
64296
64457
|
const args = Array.isArray(fields["args"]) ? fields["args"].filter((arg) => typeof arg === "string") : [];
|
|
64297
64458
|
const displayName = typeof fields["displayName"] === "string" && fields["displayName"].trim().length > 0 ? fields["displayName"].trim() : pkg;
|
|
64298
64459
|
const description = typeof fields["description"] === "string" ? fields["description"] : typeof manifest["description"] === "string" ? manifest["description"] : void 0;
|
|
64460
|
+
const extras = await readPageAndIcon(dir, fields);
|
|
64299
64461
|
return {
|
|
64300
64462
|
package: pkg,
|
|
64301
64463
|
version: version2,
|
|
@@ -64304,9 +64466,64 @@ async function readAddon(dir) {
|
|
|
64304
64466
|
dir,
|
|
64305
64467
|
main,
|
|
64306
64468
|
args,
|
|
64307
|
-
server: addonServerName(pkg)
|
|
64469
|
+
server: addonServerName(pkg),
|
|
64470
|
+
...extras
|
|
64308
64471
|
};
|
|
64309
64472
|
}
|
|
64473
|
+
var ICON_MAX_BYTES = 64 * 1024;
|
|
64474
|
+
async function readPageAndIcon(dir, fields) {
|
|
64475
|
+
const out = {};
|
|
64476
|
+
const inside = (relative) => {
|
|
64477
|
+
const full = import_node_path32.default.resolve(dir, relative);
|
|
64478
|
+
const rel = import_node_path32.default.relative(dir, full);
|
|
64479
|
+
return rel.startsWith("..") || import_node_path32.default.isAbsolute(rel) ? void 0 : full;
|
|
64480
|
+
};
|
|
64481
|
+
const problems = [];
|
|
64482
|
+
if (typeof fields["icon"] === "string") {
|
|
64483
|
+
const file2 = inside(fields["icon"]);
|
|
64484
|
+
try {
|
|
64485
|
+
if (file2 === void 0)
|
|
64486
|
+
throw new Error("is outside the package folder");
|
|
64487
|
+
const bytes = await import_promises18.default.readFile(file2);
|
|
64488
|
+
const text = bytes.toString("utf8");
|
|
64489
|
+
if (bytes.length > ICON_MAX_BYTES)
|
|
64490
|
+
throw new Error("is larger than 64 KB");
|
|
64491
|
+
if (!/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*<svg[\s>]/i.test(text))
|
|
64492
|
+
throw new Error("is not an SVG file");
|
|
64493
|
+
out.icon = `data:image/svg+xml;base64,${bytes.toString("base64")}`;
|
|
64494
|
+
} catch (error51) {
|
|
64495
|
+
problems.push(`icon ${String(fields["icon"])} ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
64496
|
+
}
|
|
64497
|
+
}
|
|
64498
|
+
let declared = fields["settings"];
|
|
64499
|
+
if (typeof declared === "string") {
|
|
64500
|
+
const file2 = inside(declared);
|
|
64501
|
+
try {
|
|
64502
|
+
if (file2 === void 0)
|
|
64503
|
+
throw new Error("is outside the package folder");
|
|
64504
|
+
declared = JSON.parse((await import_promises18.default.readFile(file2, "utf8")).replace(/^\uFEFF/, ""));
|
|
64505
|
+
} catch (error51) {
|
|
64506
|
+
problems.push(`settings ${String(fields["settings"])} ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
64507
|
+
declared = void 0;
|
|
64508
|
+
}
|
|
64509
|
+
}
|
|
64510
|
+
if (declared !== void 0) {
|
|
64511
|
+
const parsed = addonPageSchema.safeParse(declared);
|
|
64512
|
+
if (parsed.success) {
|
|
64513
|
+
const page = parsed.data;
|
|
64514
|
+
const keys = page.records?.fields.map((field2) => field2.key) ?? [];
|
|
64515
|
+
if (page.records !== void 0 && !keys.includes(page.records.keyField))
|
|
64516
|
+
problems.push(`settings: keyField "${page.records.keyField}" is not one of its fields`);
|
|
64517
|
+
else
|
|
64518
|
+
out.page = page;
|
|
64519
|
+
} else {
|
|
64520
|
+
problems.push(`settings: ${parsed.error.issues.map((issue2) => `${issue2.path.join(".")} ${issue2.message}`).join("; ")}`);
|
|
64521
|
+
}
|
|
64522
|
+
}
|
|
64523
|
+
if (problems.length > 0)
|
|
64524
|
+
out.pageProblem = problems.join(". ");
|
|
64525
|
+
return out;
|
|
64526
|
+
}
|
|
64310
64527
|
async function discoverAddons(folders) {
|
|
64311
64528
|
const addons = [];
|
|
64312
64529
|
const problems = [];
|
|
@@ -64388,7 +64605,7 @@ function tagOf(entry) {
|
|
|
64388
64605
|
const tag = entry?.addon;
|
|
64389
64606
|
return typeof tag?.package === "string" && typeof tag.version === "string" ? { package: tag.package, version: tag.version } : void 0;
|
|
64390
64607
|
}
|
|
64391
|
-
function runnableServers(servers, addons, runtime, repositoryServers = []) {
|
|
64608
|
+
function runnableServers(servers, addons, runtime, repositoryServers = [], extraEnv = () => ({})) {
|
|
64392
64609
|
const out = {};
|
|
64393
64610
|
for (const [name, entry] of Object.entries(servers)) {
|
|
64394
64611
|
const tag = tagOf(entry);
|
|
@@ -64401,27 +64618,83 @@ function runnableServers(servers, addons, runtime, repositoryServers = []) {
|
|
|
64401
64618
|
out[name] = { ...entry, disabled: true };
|
|
64402
64619
|
continue;
|
|
64403
64620
|
}
|
|
64621
|
+
const env2 = { ...entry.env ?? {}, ...extraEnv(installed), ...runtime.electron ? { ELECTRON_RUN_AS_NODE: "1" } : {} };
|
|
64404
64622
|
out[name] = {
|
|
64405
64623
|
...entry,
|
|
64406
64624
|
command: runtime.execPath,
|
|
64407
64625
|
args: [installed.main, ...installed.args],
|
|
64408
64626
|
cwd: installed.dir,
|
|
64409
|
-
...
|
|
64627
|
+
...Object.keys(env2).length > 0 ? { env: env2 } : {}
|
|
64410
64628
|
};
|
|
64411
64629
|
}
|
|
64412
64630
|
return out;
|
|
64413
64631
|
}
|
|
64414
64632
|
|
|
64633
|
+
// ../../packages/core/dist/addons/delivery.js
|
|
64634
|
+
var import_node_crypto11 = require("node:crypto");
|
|
64635
|
+
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
64636
|
+
var SETTINGS_ENV = "LIGHT_CODE_ADDON_SETTINGS";
|
|
64637
|
+
var DATA_ENV = "LIGHT_CODE_ADDON_DATA";
|
|
64638
|
+
var DOWNLOADS_ENV = "LIGHT_CODE_ADDON_DOWNLOADS";
|
|
64639
|
+
var PANEL_TOOLS_ENV = "LIGHT_CODE_ADDON_PANEL_TOOLS";
|
|
64640
|
+
function addonDataDir(storageDir, addon) {
|
|
64641
|
+
return import_node_path33.default.join(storageDir, "addons", addon.server);
|
|
64642
|
+
}
|
|
64643
|
+
function addonDownloadsDir(storageDir, addon) {
|
|
64644
|
+
return import_node_path33.default.join(addonDataDir(storageDir, addon), "downloads");
|
|
64645
|
+
}
|
|
64646
|
+
function secretEnvName(ref) {
|
|
64647
|
+
return `LC_SECRET_${(0, import_node_crypto11.createHash)("sha256").update(ref).digest("hex").slice(0, 16).toUpperCase()}`;
|
|
64648
|
+
}
|
|
64649
|
+
function deliveryFor(storageDir, addon, settings, stored) {
|
|
64650
|
+
const dir = addonDataDir(storageDir, addon);
|
|
64651
|
+
const file2 = import_node_path33.default.join(dir, "settings.json");
|
|
64652
|
+
const env2 = {
|
|
64653
|
+
[SETTINGS_ENV]: file2,
|
|
64654
|
+
[DATA_ENV]: dir,
|
|
64655
|
+
[DOWNLOADS_ENV]: addonDownloadsDir(storageDir, addon),
|
|
64656
|
+
[PANEL_TOOLS_ENV]: "1"
|
|
64657
|
+
};
|
|
64658
|
+
const secrets = {};
|
|
64659
|
+
const secretFields = (owner) => ((owner === "record" ? addon.page?.records?.fields : addon.page?.fields) ?? []).filter((field2) => field2.type === "secret").map((field2) => field2.key);
|
|
64660
|
+
const give = (recordId, field2) => {
|
|
64661
|
+
const ref = addonSecretRef(addon.package, recordId, field2);
|
|
64662
|
+
if (!stored.has(ref))
|
|
64663
|
+
return;
|
|
64664
|
+
const name = secretEnvName(ref);
|
|
64665
|
+
env2[name] = `\${secret:${ref}}`;
|
|
64666
|
+
(secrets[recordId ?? "_"] ??= {})[field2] = name;
|
|
64667
|
+
};
|
|
64668
|
+
for (const field2 of secretFields("page"))
|
|
64669
|
+
give(void 0, field2);
|
|
64670
|
+
for (const record2 of settings?.records ?? [])
|
|
64671
|
+
for (const field2 of secretFields("record"))
|
|
64672
|
+
give(record2.id, field2);
|
|
64673
|
+
return { file: file2, contents: { values: settings?.values ?? {}, records: settings?.records ?? [], secrets }, env: env2 };
|
|
64674
|
+
}
|
|
64675
|
+
function possibleSecretRefs(addon, settings) {
|
|
64676
|
+
const refs = [];
|
|
64677
|
+
for (const field2 of addon.page?.fields ?? [])
|
|
64678
|
+
if (field2.type === "secret")
|
|
64679
|
+
refs.push(addonSecretRef(addon.package, void 0, field2.key));
|
|
64680
|
+
for (const record2 of settings?.records ?? []) {
|
|
64681
|
+
for (const field2 of addon.page?.records?.fields ?? [])
|
|
64682
|
+
if (field2.type === "secret")
|
|
64683
|
+
refs.push(addonSecretRef(addon.package, record2.id, field2.key));
|
|
64684
|
+
}
|
|
64685
|
+
return refs;
|
|
64686
|
+
}
|
|
64687
|
+
|
|
64415
64688
|
// ../../packages/core/dist/agent/codebaseInstructions.js
|
|
64416
|
-
var
|
|
64689
|
+
var import_node_crypto13 = require("node:crypto");
|
|
64417
64690
|
var import_promises19 = __toESM(require("node:fs/promises"), 1);
|
|
64418
|
-
var
|
|
64691
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
64419
64692
|
|
|
64420
64693
|
// ../../packages/core/dist/usage/events.js
|
|
64421
|
-
var
|
|
64694
|
+
var import_node_crypto12 = require("node:crypto");
|
|
64422
64695
|
var import_node_fs5 = require("node:fs");
|
|
64423
64696
|
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
64424
|
-
var
|
|
64697
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
64425
64698
|
function isUsageEvent(value) {
|
|
64426
64699
|
if (value === null || typeof value !== "object")
|
|
64427
64700
|
return false;
|
|
@@ -64446,12 +64719,12 @@ function usageDay(t) {
|
|
|
64446
64719
|
return new Date(t).toISOString().slice(0, 10);
|
|
64447
64720
|
}
|
|
64448
64721
|
function usageInstanceId(storageDir) {
|
|
64449
|
-
return (0,
|
|
64450
|
-
${
|
|
64722
|
+
return (0, import_node_crypto12.createHash)("sha256").update(`${import_node_os5.default.hostname()}
|
|
64723
|
+
${import_node_path34.default.resolve(storageDir).toLowerCase()}`).digest("hex").slice(0, 12);
|
|
64451
64724
|
}
|
|
64452
64725
|
async function writeFileAtomically(target, text) {
|
|
64453
|
-
await import_node_fs5.promises.mkdir(
|
|
64454
|
-
const temporary = `${target}.${(0,
|
|
64726
|
+
await import_node_fs5.promises.mkdir(import_node_path34.default.dirname(target), { recursive: true });
|
|
64727
|
+
const temporary = `${target}.${(0, import_node_crypto12.randomBytes)(6).toString("hex")}.tmp`;
|
|
64455
64728
|
await import_node_fs5.promises.writeFile(temporary, text, "utf8");
|
|
64456
64729
|
try {
|
|
64457
64730
|
await replaceFile(temporary, target);
|
|
@@ -64469,15 +64742,15 @@ var UsageLog = class {
|
|
|
64469
64742
|
session;
|
|
64470
64743
|
constructor(storageDir, session) {
|
|
64471
64744
|
this.storageDir = storageDir;
|
|
64472
|
-
this.queueDir =
|
|
64473
|
-
this.manifestFile =
|
|
64474
|
-
this.rolledFile =
|
|
64475
|
-
this.legacyFile =
|
|
64476
|
-
this.session = session ?? (0,
|
|
64745
|
+
this.queueDir = import_node_path34.default.join(storageDir, "usage", "queue");
|
|
64746
|
+
this.manifestFile = import_node_path34.default.join(storageDir, "usage", "pushed.json");
|
|
64747
|
+
this.rolledFile = import_node_path34.default.join(storageDir, "usage", "rolled.json");
|
|
64748
|
+
this.legacyFile = import_node_path34.default.join(storageDir, "usage-events.jsonl");
|
|
64749
|
+
this.session = session ?? (0, import_node_crypto12.randomBytes)(6).toString("hex");
|
|
64477
64750
|
}
|
|
64478
64751
|
async append(event) {
|
|
64479
64752
|
await import_node_fs5.promises.mkdir(this.queueDir, { recursive: true });
|
|
64480
|
-
await import_node_fs5.promises.appendFile(
|
|
64753
|
+
await import_node_fs5.promises.appendFile(import_node_path34.default.join(this.queueDir, `${usageDay(event.t)}__${this.session}.jsonl`), `${JSON.stringify(event)}
|
|
64481
64754
|
`, "utf8");
|
|
64482
64755
|
}
|
|
64483
64756
|
/**
|
|
@@ -64485,7 +64758,7 @@ var UsageLog = class {
|
|
|
64485
64758
|
* never appended, so two sessions importing at once leave one copy rather than two.
|
|
64486
64759
|
*/
|
|
64487
64760
|
async writeFixed(day, name, events) {
|
|
64488
|
-
await writeFileAtomically(
|
|
64761
|
+
await writeFileAtomically(import_node_path34.default.join(this.queueDir, `${day}__${name}.jsonl`), events.map((event) => JSON.stringify(event)).join("\n") + (events.length > 0 ? "\n" : ""));
|
|
64489
64762
|
}
|
|
64490
64763
|
/**
|
|
64491
64764
|
* Moves a 0.156/0.157 single queue file into the per-day layout, once. Deterministic names, so two
|
|
@@ -64505,7 +64778,7 @@ var UsageLog = class {
|
|
|
64505
64778
|
for (const [day, events] of byDay)
|
|
64506
64779
|
await this.writeFixed(day, "legacy", events);
|
|
64507
64780
|
await import_node_fs5.promises.rename(this.legacyFile, `${this.legacyFile}.migrated`).catch(() => void 0);
|
|
64508
|
-
await import_node_fs5.promises.rm(
|
|
64781
|
+
await import_node_fs5.promises.rm(import_node_path34.default.join(this.storageDir, "usage-sync.json"), { force: true }).catch(() => void 0);
|
|
64509
64782
|
}
|
|
64510
64783
|
/** Every day with local files, and its signature. */
|
|
64511
64784
|
async days() {
|
|
@@ -64520,7 +64793,7 @@ var UsageLog = class {
|
|
|
64520
64793
|
const match = QUEUE_FILE.exec(name);
|
|
64521
64794
|
if (match === null)
|
|
64522
64795
|
continue;
|
|
64523
|
-
const size = await import_node_fs5.promises.stat(
|
|
64796
|
+
const size = await import_node_fs5.promises.stat(import_node_path34.default.join(this.queueDir, name)).then((stat) => stat.size).catch(() => void 0);
|
|
64524
64797
|
if (size === void 0)
|
|
64525
64798
|
continue;
|
|
64526
64799
|
const entry = days.get(match[1]) ?? { files: [], signature: "" };
|
|
@@ -64542,7 +64815,7 @@ var UsageLog = class {
|
|
|
64542
64815
|
const entry = (await this.days()).get(day);
|
|
64543
64816
|
if (entry === void 0)
|
|
64544
64817
|
return [];
|
|
64545
|
-
const texts = await Promise.all(entry.files.map((file2) => import_node_fs5.promises.readFile(
|
|
64818
|
+
const texts = await Promise.all(entry.files.map((file2) => import_node_fs5.promises.readFile(import_node_path34.default.join(this.queueDir, file2.name), "utf8").catch(() => "")));
|
|
64546
64819
|
return texts.flatMap(parseUsageLines).sort((a, b) => a.t - b.t);
|
|
64547
64820
|
}
|
|
64548
64821
|
/** Every queued event (the last few weeks), for finding names worth looking up. */
|
|
@@ -64589,7 +64862,7 @@ var UsageLog = class {
|
|
|
64589
64862
|
if (day >= cutoff || pushed[day] !== entry.signature)
|
|
64590
64863
|
continue;
|
|
64591
64864
|
for (const file2 of entry.files) {
|
|
64592
|
-
await import_node_fs5.promises.rm(
|
|
64865
|
+
await import_node_fs5.promises.rm(import_node_path34.default.join(this.queueDir, file2.name), { force: true }).catch(() => void 0);
|
|
64593
64866
|
removed++;
|
|
64594
64867
|
}
|
|
64595
64868
|
}
|
|
@@ -64602,14 +64875,14 @@ var CODEBASE_INSTRUCTIONS_FILE = "codebase-instructions.md";
|
|
|
64602
64875
|
var CODEBASE_INSTRUCTIONS_LIMIT = 2e4;
|
|
64603
64876
|
function codebaseInstructionsPath(options) {
|
|
64604
64877
|
if (options.codebaseDir !== void 0)
|
|
64605
|
-
return
|
|
64878
|
+
return import_node_path35.default.join(options.codebaseDir, "instructions", CODEBASE_INSTRUCTIONS_FILE);
|
|
64606
64879
|
if (options.workspaceRoot === void 0)
|
|
64607
64880
|
return void 0;
|
|
64608
|
-
const resolved =
|
|
64881
|
+
const resolved = import_node_path35.default.resolve(options.workspaceRoot);
|
|
64609
64882
|
const key2 = process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
64610
|
-
const digest = (0,
|
|
64611
|
-
const slug =
|
|
64612
|
-
return
|
|
64883
|
+
const digest = (0, import_node_crypto13.createHash)("sha256").update(key2).digest("hex").slice(0, 12);
|
|
64884
|
+
const slug = import_node_path35.default.basename(resolved).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "workspace";
|
|
64885
|
+
return import_node_path35.default.join(options.storageDir, "codebases", `${slug}-${digest}`, CODEBASE_INSTRUCTIONS_FILE);
|
|
64613
64886
|
}
|
|
64614
64887
|
async function readCodebaseInstructions(file2) {
|
|
64615
64888
|
if (file2 === void 0)
|
|
@@ -64709,7 +64982,7 @@ async function readToolCredential(options) {
|
|
|
64709
64982
|
|
|
64710
64983
|
// ../../packages/core/dist/jupyter/tools.js
|
|
64711
64984
|
var import_promises21 = __toESM(require("node:fs/promises"), 1);
|
|
64712
|
-
var
|
|
64985
|
+
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
64713
64986
|
var RUN_DEFAULT_SECONDS = 300;
|
|
64714
64987
|
var SCRIPT_PREVIEW_CHARS = 6e3;
|
|
64715
64988
|
var runSchema = external_exports.object({
|
|
@@ -64933,7 +65206,7 @@ ${pending.map((p) => `- ${p.local} (${p.kind}${p.kind === "deleted" ? " here; st
|
|
|
64933
65206
|
for (const file2 of pending.files) {
|
|
64934
65207
|
const result = await runtime.mirror.push(file2, context.signal);
|
|
64935
65208
|
failed2 ||= !result.saved && result.ignored !== true;
|
|
64936
|
-
lines.push(`- ${
|
|
65209
|
+
lines.push(`- ${import_node_path36.default.relative(runtime.mirror.root, file2).split(import_node_path36.default.sep).join("/")}: ${result.message}`);
|
|
64937
65210
|
}
|
|
64938
65211
|
return { content: lines.length > 0 ? lines.join("\n") : "Nothing to save.", ...failed2 ? { isError: true } : {} };
|
|
64939
65212
|
}
|
|
@@ -64972,7 +65245,7 @@ async function pendingFor(runtime, context, target) {
|
|
|
64972
65245
|
const pending = (await runtime.mirror.pending()).filter((p) => p.kind !== "deleted");
|
|
64973
65246
|
return {
|
|
64974
65247
|
ok: true,
|
|
64975
|
-
files: pending.map((p) =>
|
|
65248
|
+
files: pending.map((p) => import_node_path36.default.join(runtime.mirror.root, ...p.local.split("/"))),
|
|
64976
65249
|
changes: pending.map((p) => `${p.local} \u2192 ${p.remote} (${p.kind})`)
|
|
64977
65250
|
};
|
|
64978
65251
|
}
|
|
@@ -65022,7 +65295,7 @@ if __SOURCE__:
|
|
|
65022
65295
|
`;
|
|
65023
65296
|
|
|
65024
65297
|
// ../../packages/core/dist/jupyter/hubGit.js
|
|
65025
|
-
var
|
|
65298
|
+
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
65026
65299
|
var MARKER = "__LC_HUBGIT__";
|
|
65027
65300
|
var LISTED = 40;
|
|
65028
65301
|
var py2 = (value) => JSON.stringify(value);
|
|
@@ -65137,7 +65410,7 @@ async function hubGitStatus(runtime, signal) {
|
|
|
65137
65410
|
total.upstream &&= one.upstream;
|
|
65138
65411
|
if (total.branch === void 0 && one.branch !== void 0)
|
|
65139
65412
|
total.branch = one.branch;
|
|
65140
|
-
const prefix = results.length > 1 ? `${
|
|
65413
|
+
const prefix = results.length > 1 ? `${import_node_path37.default.posix.basename(repo.repo)}/` : "";
|
|
65141
65414
|
for (const file2 of one.files)
|
|
65142
65415
|
if (total.files.length < LISTED)
|
|
65143
65416
|
total.files.push(`${file2.slice(0, 2)}${prefix}${file2.slice(2)}`);
|
|
@@ -65150,7 +65423,7 @@ async function hubGitCommitPush(runtime, message4, signal) {
|
|
|
65150
65423
|
return { ok: false, text: "Write a commit message first." };
|
|
65151
65424
|
const pending = await runtime.mirror.pending();
|
|
65152
65425
|
for (const change of pending.filter((p) => p.kind !== "deleted")) {
|
|
65153
|
-
const saved = await runtime.mirror.push(
|
|
65426
|
+
const saved = await runtime.mirror.push(import_node_path37.default.join(runtime.mirror.root, ...change.local.split("/")), signal);
|
|
65154
65427
|
if (!saved.saved)
|
|
65155
65428
|
return { ok: false, text: `Nothing was committed: ${change.local} could not be saved to the hub first (${saved.message}).` };
|
|
65156
65429
|
}
|
|
@@ -65163,7 +65436,7 @@ async function hubGitCommitPush(runtime, message4, signal) {
|
|
|
65163
65436
|
const lines = [];
|
|
65164
65437
|
let ok = true;
|
|
65165
65438
|
for (const repo of results) {
|
|
65166
|
-
const name = results.length > 1 ? `${
|
|
65439
|
+
const name = results.length > 1 ? `${import_node_path37.default.posix.basename(repo.repo)}: ` : "";
|
|
65167
65440
|
const committed = repo.commit?.ok === true;
|
|
65168
65441
|
const nothing = /nothing to commit/.test(`${repo.commit?.out ?? ""}${repo.commit?.err ?? ""}`);
|
|
65169
65442
|
if (repo.add?.ok !== true) {
|
|
@@ -65193,7 +65466,7 @@ async function hubGitPull(runtime, signal) {
|
|
|
65193
65466
|
const lines = [];
|
|
65194
65467
|
let ok = true;
|
|
65195
65468
|
for (const repo of results) {
|
|
65196
|
-
const name = results.length > 1 ? `${
|
|
65469
|
+
const name = results.length > 1 ? `${import_node_path37.default.posix.basename(repo.repo)}: ` : "";
|
|
65197
65470
|
const all = `${repo.pull?.out ?? ""}${repo.pull?.err ?? ""}`;
|
|
65198
65471
|
if (repo.pull?.ok === true)
|
|
65199
65472
|
lines.push(`${name}${/Already up.to.date/i.test(all) ? "Already up to date." : "Pulled on the hub."}`);
|
|
@@ -65375,7 +65648,8 @@ function pick2(hubs, name) {
|
|
|
65375
65648
|
|
|
65376
65649
|
// ../../packages/core/dist/host/bridge.js
|
|
65377
65650
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
65378
|
-
var
|
|
65651
|
+
var import_node_fs11 = require("node:fs");
|
|
65652
|
+
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
65379
65653
|
|
|
65380
65654
|
// ../../packages/core/dist/modes/autoGuidance.js
|
|
65381
65655
|
function idiomsFor(environment) {
|
|
@@ -65471,7 +65745,7 @@ function buildAutoGuidance(environment) {
|
|
|
65471
65745
|
|
|
65472
65746
|
// ../../packages/core/dist/migrate/folders.js
|
|
65473
65747
|
var import_promises22 = __toESM(require("node:fs/promises"), 1);
|
|
65474
|
-
var
|
|
65748
|
+
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
65475
65749
|
function nameOf(entry, kind) {
|
|
65476
65750
|
return kind === "skills" ? entry.replace(/\.md$/i, "") : entry.replace(/\.py$/i, "");
|
|
65477
65751
|
}
|
|
@@ -65496,7 +65770,7 @@ async function namesAt(dir, kind) {
|
|
|
65496
65770
|
if (kind === "skills") {
|
|
65497
65771
|
if (entry.toLowerCase().endsWith(".md"))
|
|
65498
65772
|
found2.add(nameOf(entry, kind));
|
|
65499
|
-
else if (await isDirectory(
|
|
65773
|
+
else if (await isDirectory(import_node_path38.default.join(dir, entry)))
|
|
65500
65774
|
found2.add(entry);
|
|
65501
65775
|
} else if (entry.toLowerCase().endsWith(".py")) {
|
|
65502
65776
|
found2.add(nameOf(entry, kind));
|
|
@@ -65508,7 +65782,7 @@ async function planMigration(options) {
|
|
|
65508
65782
|
const { from, to, kind } = options;
|
|
65509
65783
|
const copy = [];
|
|
65510
65784
|
const skip = [];
|
|
65511
|
-
if (
|
|
65785
|
+
if (import_node_path38.default.resolve(from) === import_node_path38.default.resolve(to))
|
|
65512
65786
|
return { copy, skip };
|
|
65513
65787
|
const existing = await namesAt(to, kind);
|
|
65514
65788
|
let entries;
|
|
@@ -65520,14 +65794,14 @@ async function planMigration(options) {
|
|
|
65520
65794
|
for (const entry of entries) {
|
|
65521
65795
|
if (entry.startsWith("."))
|
|
65522
65796
|
continue;
|
|
65523
|
-
const source =
|
|
65797
|
+
const source = import_node_path38.default.join(from, entry);
|
|
65524
65798
|
const directory = await isDirectory(source);
|
|
65525
65799
|
if (kind === "skills") {
|
|
65526
65800
|
if (!directory && !entry.toLowerCase().endsWith(".md"))
|
|
65527
65801
|
continue;
|
|
65528
65802
|
if (directory) {
|
|
65529
65803
|
try {
|
|
65530
|
-
await import_promises22.default.stat(
|
|
65804
|
+
await import_promises22.default.stat(import_node_path38.default.join(source, "SKILL.md"));
|
|
65531
65805
|
} catch {
|
|
65532
65806
|
continue;
|
|
65533
65807
|
}
|
|
@@ -65540,7 +65814,7 @@ async function planMigration(options) {
|
|
|
65540
65814
|
skip.push(name);
|
|
65541
65815
|
continue;
|
|
65542
65816
|
}
|
|
65543
|
-
copy.push({ name, source, destination:
|
|
65817
|
+
copy.push({ name, source, destination: import_node_path38.default.join(to, entry), directory });
|
|
65544
65818
|
}
|
|
65545
65819
|
copy.sort((a, b) => a.name.localeCompare(b.name));
|
|
65546
65820
|
skip.sort();
|
|
@@ -65551,7 +65825,7 @@ async function runMigration(plan2) {
|
|
|
65551
65825
|
const failed2 = [];
|
|
65552
65826
|
for (const item of plan2.copy) {
|
|
65553
65827
|
try {
|
|
65554
|
-
await import_promises22.default.mkdir(
|
|
65828
|
+
await import_promises22.default.mkdir(import_node_path38.default.dirname(item.destination), { recursive: true });
|
|
65555
65829
|
await import_promises22.default.cp(item.source, item.destination, {
|
|
65556
65830
|
recursive: item.directory,
|
|
65557
65831
|
force: false,
|
|
@@ -65578,7 +65852,7 @@ function describeMigration(result, kind) {
|
|
|
65578
65852
|
|
|
65579
65853
|
// ../../packages/core/dist/platform/node/shell.js
|
|
65580
65854
|
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
65581
|
-
var
|
|
65855
|
+
var import_node_path39 = __toESM(require("node:path"), 1);
|
|
65582
65856
|
function windowsExtensions(env2) {
|
|
65583
65857
|
const raw = env2["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD";
|
|
65584
65858
|
return raw.split(";").filter((entry) => entry.length > 0);
|
|
@@ -65592,7 +65866,7 @@ function onPath(name, env2 = process.env) {
|
|
|
65592
65866
|
continue;
|
|
65593
65867
|
for (const extension of extensions) {
|
|
65594
65868
|
try {
|
|
65595
|
-
const candidate =
|
|
65869
|
+
const candidate = import_node_path39.default.join(directory, name + extension);
|
|
65596
65870
|
if (import_node_fs6.default.statSync(candidate).isFile())
|
|
65597
65871
|
return true;
|
|
65598
65872
|
} catch {
|
|
@@ -65614,7 +65888,7 @@ function resolveShell(configured, env2 = process.env) {
|
|
|
65614
65888
|
return { command: void 0, kind: "posix", label: env2["SHELL"] ?? "/bin/sh" };
|
|
65615
65889
|
}
|
|
65616
65890
|
function kindOf(command) {
|
|
65617
|
-
const base =
|
|
65891
|
+
const base = import_node_path39.default.basename(command).toLowerCase().replace(/\.exe$/, "");
|
|
65618
65892
|
if (base === "pwsh")
|
|
65619
65893
|
return "pwsh";
|
|
65620
65894
|
if (base === "powershell")
|
|
@@ -65624,7 +65898,7 @@ function kindOf(command) {
|
|
|
65624
65898
|
return "posix";
|
|
65625
65899
|
}
|
|
65626
65900
|
function labelFor(command) {
|
|
65627
|
-
const base =
|
|
65901
|
+
const base = import_node_path39.default.basename(command).toLowerCase().replace(/\.exe$/, "");
|
|
65628
65902
|
if (base === "pwsh")
|
|
65629
65903
|
return "PowerShell 7 (pwsh)";
|
|
65630
65904
|
if (base === "powershell")
|
|
@@ -65706,7 +65980,7 @@ function fastFsCapabilities(exe, timeoutMs = 5e3) {
|
|
|
65706
65980
|
var import_node_child_process9 = require("node:child_process");
|
|
65707
65981
|
|
|
65708
65982
|
// ../../packages/core/dist/tools/readStamps.js
|
|
65709
|
-
var
|
|
65983
|
+
var import_node_path40 = __toESM(require("node:path"), 1);
|
|
65710
65984
|
async function stamp(context, realPath) {
|
|
65711
65985
|
try {
|
|
65712
65986
|
const s = await context.fs.stat(realPath);
|
|
@@ -65751,14 +66025,14 @@ async function staleFilesNamedIn(context, command) {
|
|
|
65751
66025
|
};
|
|
65752
66026
|
const stale = [];
|
|
65753
66027
|
for (const [key2, known] of context.readStamps) {
|
|
65754
|
-
const relative =
|
|
65755
|
-
const names = [key2, relative, relative.split(
|
|
66028
|
+
const relative = import_node_path40.default.relative(root, key2);
|
|
66029
|
+
const names = [key2, relative, relative.split(import_node_path40.default.sep).join("/"), import_node_path40.default.basename(key2)].map((n) => n.toLowerCase());
|
|
65756
66030
|
if (!names.some(stands))
|
|
65757
66031
|
continue;
|
|
65758
66032
|
try {
|
|
65759
66033
|
const s = await context.fs.stat(key2);
|
|
65760
66034
|
if (`${String(s.mtimeMs)}:${String(s.size)}` !== known)
|
|
65761
|
-
stale.push(relative.split(
|
|
66035
|
+
stale.push(relative.split(import_node_path40.default.sep).join("/"));
|
|
65762
66036
|
} catch {
|
|
65763
66037
|
}
|
|
65764
66038
|
}
|
|
@@ -67239,8 +67513,8 @@ var ChangeLedger = class {
|
|
|
67239
67513
|
this.chat = chat;
|
|
67240
67514
|
}
|
|
67241
67515
|
/** Best effort: a ledger that cannot be written must never fail an edit that happened. */
|
|
67242
|
-
record(
|
|
67243
|
-
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(
|
|
67516
|
+
record(path61) {
|
|
67517
|
+
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(path61), at: Date.now() });
|
|
67244
67518
|
void (0, import_promises23.appendFile)(this.file, `${line}
|
|
67245
67519
|
`).catch(() => void 0);
|
|
67246
67520
|
}
|
|
@@ -67288,7 +67562,7 @@ var RecordedChanges = class extends Set {
|
|
|
67288
67562
|
// ../../packages/core/dist/office/bridge.js
|
|
67289
67563
|
var import_node_child_process11 = require("node:child_process");
|
|
67290
67564
|
var import_promises24 = __toESM(require("node:fs/promises"), 1);
|
|
67291
|
-
var
|
|
67565
|
+
var import_node_path41 = __toESM(require("node:path"), 1);
|
|
67292
67566
|
|
|
67293
67567
|
// ../../packages/core/dist/office/workerSource.js
|
|
67294
67568
|
var OFFICE_WORKER_SOURCE = `# Light Code office worker.
|
|
@@ -70022,7 +70296,7 @@ var OfficeBridge = class {
|
|
|
70022
70296
|
return this.starting;
|
|
70023
70297
|
}
|
|
70024
70298
|
async start() {
|
|
70025
|
-
const target =
|
|
70299
|
+
const target = import_node_path41.default.join(this.options.storageDir, "office-worker.ps1");
|
|
70026
70300
|
await import_promises24.default.mkdir(this.options.storageDir, { recursive: true });
|
|
70027
70301
|
const BOM = "\uFEFF";
|
|
70028
70302
|
await import_promises24.default.writeFile(target, `${BOM}${OFFICE_WORKER_SOURCE}`, "utf8");
|
|
@@ -70528,8 +70802,8 @@ function createDeleteRoleTool(access) {
|
|
|
70528
70802
|
}
|
|
70529
70803
|
|
|
70530
70804
|
// ../../packages/core/dist/rag/indexNaming.js
|
|
70531
|
-
var
|
|
70532
|
-
var
|
|
70805
|
+
var import_node_crypto14 = __toESM(require("node:crypto"), 1);
|
|
70806
|
+
var import_node_path42 = __toESM(require("node:path"), 1);
|
|
70533
70807
|
var DEFAULT_INDEX_PREFIX = "light-code";
|
|
70534
70808
|
var DOMAIN_OR_PATH = /[\\/]/;
|
|
70535
70809
|
function normaliseOwner(owner) {
|
|
@@ -70544,15 +70818,15 @@ function ownerSlug(owner) {
|
|
|
70544
70818
|
function deriveIndexName(input) {
|
|
70545
70819
|
const prefix = input.prefix ?? DEFAULT_INDEX_PREFIX;
|
|
70546
70820
|
const slug = ownerSlug(input.owner);
|
|
70547
|
-
const root =
|
|
70821
|
+
const root = import_node_path42.default.resolve(input.workspaceRoot).toLowerCase();
|
|
70548
70822
|
const identity = input.owner === void 0 ? "" : normaliseOwner(input.owner);
|
|
70549
|
-
const digest =
|
|
70823
|
+
const digest = import_node_crypto14.default.createHash("sha256").update(`${identity}\0${root}`).digest("hex").slice(0, 16);
|
|
70550
70824
|
const base = slug === void 0 ? `${prefix}-${digest}` : `${prefix}-${slug}-${digest}`;
|
|
70551
70825
|
return input.project === void 0 ? base : `${input.project}-${base}`;
|
|
70552
70826
|
}
|
|
70553
70827
|
|
|
70554
70828
|
// ../../packages/core/dist/tools/exportConfig.js
|
|
70555
|
-
var
|
|
70829
|
+
var import_node_path43 = __toESM(require("node:path"), 1);
|
|
70556
70830
|
var sectionIds = SHARE_SECTIONS.map((section) => section.id);
|
|
70557
70831
|
var paramsSchema11 = external_exports.object({
|
|
70558
70832
|
path: external_exports.string().min(1).describe('Where to write it in the workspace, e.g. "onboarding/light-code-team.json".'),
|
|
@@ -70592,7 +70866,7 @@ function createExportConfigTool(options) {
|
|
|
70592
70866
|
if (!resolved.ok)
|
|
70593
70867
|
return { content: resolved.message, isError: true };
|
|
70594
70868
|
const { json: json2, notes } = prepare(await options.loadConfig(), params3);
|
|
70595
|
-
await context.fs.mkdir(
|
|
70869
|
+
await context.fs.mkdir(import_node_path43.default.dirname(resolved.realPath));
|
|
70596
70870
|
await context.fs.writeFile(resolved.realPath, json2);
|
|
70597
70871
|
return { content: `Wrote ${params3.path}. ${notes}`, path: resolved.realPath };
|
|
70598
70872
|
}
|
|
@@ -70761,7 +71035,7 @@ function describeAtlassianFailure(product, doing, status2, body) {
|
|
|
70761
71035
|
}
|
|
70762
71036
|
|
|
70763
71037
|
// ../../packages/core/dist/atlassian/uploads.js
|
|
70764
|
-
var
|
|
71038
|
+
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
70765
71039
|
|
|
70766
71040
|
// ../../packages/core/dist/diagrams/layout.js
|
|
70767
71041
|
var NODE_HEIGHT = 52;
|
|
@@ -71403,7 +71677,7 @@ async function prepareUploads(params3, context) {
|
|
|
71403
71677
|
const resolved = await resolveToolPath(context, attachment.path);
|
|
71404
71678
|
if (!resolved.ok)
|
|
71405
71679
|
return { ok: false, message: resolved.message };
|
|
71406
|
-
const name = attachment.name ??
|
|
71680
|
+
const name = attachment.name ?? import_node_path44.default.basename(resolved.realPath);
|
|
71407
71681
|
const problem = claim(name);
|
|
71408
71682
|
if (problem !== void 0)
|
|
71409
71683
|
return { ok: false, message: problem };
|
|
@@ -71587,10 +71861,10 @@ function isSafeSegment(value) {
|
|
|
71587
71861
|
function isSafeTagName(name) {
|
|
71588
71862
|
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("."));
|
|
71589
71863
|
}
|
|
71590
|
-
function encodeRepoPath(
|
|
71591
|
-
const segments =
|
|
71864
|
+
function encodeRepoPath(path61) {
|
|
71865
|
+
const segments = path61.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0);
|
|
71592
71866
|
if (segments.length === 0 || segments.some((segment) => segment === ".." || segment === ".")) {
|
|
71593
|
-
throw new AtlassianError(`"${
|
|
71867
|
+
throw new AtlassianError(`"${path61}" is not a file path inside the repository.`);
|
|
71594
71868
|
}
|
|
71595
71869
|
return segments.map(encodeURIComponent).join("/");
|
|
71596
71870
|
}
|
|
@@ -71675,24 +71949,24 @@ var BitbucketClient = class {
|
|
|
71675
71949
|
* redirect was followed, the login page came back, and the file "could not be read" although
|
|
71676
71950
|
* pull requests on the same repository could. `browse` is REST, so it authenticates like those.
|
|
71677
71951
|
*/
|
|
71678
|
-
async file(repo,
|
|
71679
|
-
const target = encodeRepoPath(
|
|
71952
|
+
async file(repo, path61, ref, signal) {
|
|
71953
|
+
const target = encodeRepoPath(path61);
|
|
71680
71954
|
const lines = [];
|
|
71681
71955
|
let start = 0;
|
|
71682
71956
|
for (let page = 0; page < MAX_FILE_PAGES; page += 1) {
|
|
71683
71957
|
const query = new URLSearchParams({ start: String(start), limit: String(FILE_PAGE_LINES) });
|
|
71684
71958
|
if (ref !== void 0 && ref.length > 0)
|
|
71685
71959
|
query.set("at", ref);
|
|
71686
|
-
const body = await this.rest.json(`reading ${
|
|
71960
|
+
const body = await this.rest.json(`reading ${path61}`, `${this.repoPath(repo)}/browse/${target}?${query.toString()}`, { method: "GET" }, signal);
|
|
71687
71961
|
if (body.children !== void 0) {
|
|
71688
71962
|
const names = (body.children.values ?? []).map((child) => {
|
|
71689
71963
|
const name = child.path?.toString ?? child.path?.name ?? "?";
|
|
71690
71964
|
return child.type === "DIRECTORY" ? `${name}/` : name;
|
|
71691
71965
|
});
|
|
71692
|
-
throw new AtlassianError(`${
|
|
71966
|
+
throw new AtlassianError(`${path61} is a folder, not a file. It holds: ${names.join(", ") || "nothing"}.`);
|
|
71693
71967
|
}
|
|
71694
71968
|
if (body.binary === true)
|
|
71695
|
-
throw new AtlassianError(`${
|
|
71969
|
+
throw new AtlassianError(`${path61} is a binary file, so there is no text to read.`);
|
|
71696
71970
|
for (const line of body.lines ?? [])
|
|
71697
71971
|
lines.push(line.text ?? "");
|
|
71698
71972
|
if (body.isLastPage !== false || body.nextPageStart === void 0 || body.nextPageStart <= start)
|
|
@@ -72270,8 +72544,8 @@ ${text.slice(-2e4)}`);
|
|
|
72270
72544
|
}
|
|
72271
72545
|
/** Queues a build, then follows the queue item briefly to learn its number. */
|
|
72272
72546
|
async startBuild(job, parameters, signal) {
|
|
72273
|
-
const
|
|
72274
|
-
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${
|
|
72547
|
+
const path61 = jobPath(job, this.base);
|
|
72548
|
+
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${path61}/buildWithParameters` : `${path61}/build`, parameters ?? {}, signal);
|
|
72275
72549
|
const location = response.headers["location"];
|
|
72276
72550
|
const queueId = location === void 0 ? void 0 : /\/queue\/item\/(\d+)/.exec(location)?.[1];
|
|
72277
72551
|
if (queueId === void 0)
|
|
@@ -72597,14 +72871,14 @@ ${client.base}${jobPath(job, client.base)}/${buildRef(params3.build)}/`
|
|
|
72597
72871
|
};
|
|
72598
72872
|
return tool;
|
|
72599
72873
|
}
|
|
72600
|
-
async function readJenkinsfile(
|
|
72601
|
-
const resolved = await resolveToolPath(context,
|
|
72874
|
+
async function readJenkinsfile(path61, context) {
|
|
72875
|
+
const resolved = await resolveToolPath(context, path61);
|
|
72602
72876
|
if (!resolved.ok)
|
|
72603
72877
|
return { ok: false, message: resolved.message };
|
|
72604
72878
|
try {
|
|
72605
72879
|
return { ok: true, text: await context.fs.readFile(resolved.realPath), realPath: resolved.realPath };
|
|
72606
72880
|
} catch (error51) {
|
|
72607
|
-
return { ok: false, message: `Could not read ${
|
|
72881
|
+
return { ok: false, message: `Could not read ${path61}: ${error51 instanceof Error ? error51.message : String(error51)}` };
|
|
72608
72882
|
}
|
|
72609
72883
|
}
|
|
72610
72884
|
var checkSchema = external_exports.object({
|
|
@@ -72873,8 +73147,8 @@ var AutosysClient = class {
|
|
|
72873
73147
|
async runInfo(pattern, signal) {
|
|
72874
73148
|
if (!isAutosysName(pattern, true))
|
|
72875
73149
|
throw new AtlassianError(`"${pattern}" is not a job name or pattern.`);
|
|
72876
|
-
const
|
|
72877
|
-
return asList(await this.rest.json(`reading the status of ${pattern}`,
|
|
73150
|
+
const path61 = pattern.includes("*") ? fill(this.paths.runInfo, { pattern }) : fill(this.paths.jobRunInfo, { job: pattern });
|
|
73151
|
+
return asList(await this.rest.json(`reading the status of ${pattern}`, path61, { method: "GET" }, signal)).map(toRun);
|
|
72878
73152
|
}
|
|
72879
73153
|
/** A job's log, or undefined when this server has no log endpoint (404). */
|
|
72880
73154
|
async log(name, runNum, type, signal) {
|
|
@@ -74875,7 +75149,7 @@ function message2(error51) {
|
|
|
74875
75149
|
}
|
|
74876
75150
|
function filesIn(params3) {
|
|
74877
75151
|
return [
|
|
74878
|
-
...(params3.attachments ?? []).map((
|
|
75152
|
+
...(params3.attachments ?? []).map((path61) => ({ path: path61, inline: false })),
|
|
74879
75153
|
...(params3.inlineImages ?? []).map((image) => ({ path: image.path, inline: true }))
|
|
74880
75154
|
];
|
|
74881
75155
|
}
|
|
@@ -75558,17 +75832,17 @@ var WebviewApprovalGate = class {
|
|
|
75558
75832
|
// ../../packages/core/dist/platform/node/filesystem.js
|
|
75559
75833
|
var import_promises25 = __toESM(require("node:fs/promises"), 1);
|
|
75560
75834
|
var NodeFileSystem = class {
|
|
75561
|
-
async readFile(
|
|
75562
|
-
return import_promises25.default.readFile(
|
|
75835
|
+
async readFile(path61) {
|
|
75836
|
+
return import_promises25.default.readFile(path61, "utf8");
|
|
75563
75837
|
}
|
|
75564
|
-
async readBytes(
|
|
75565
|
-
return import_promises25.default.readFile(
|
|
75838
|
+
async readBytes(path61) {
|
|
75839
|
+
return import_promises25.default.readFile(path61);
|
|
75566
75840
|
}
|
|
75567
|
-
async readBytesSlice(
|
|
75841
|
+
async readBytesSlice(path61, start, end) {
|
|
75568
75842
|
const length = Math.max(0, end - start);
|
|
75569
75843
|
if (length === 0)
|
|
75570
75844
|
return Buffer.alloc(0);
|
|
75571
|
-
const handle = await import_promises25.default.open(
|
|
75845
|
+
const handle = await import_promises25.default.open(path61, "r");
|
|
75572
75846
|
try {
|
|
75573
75847
|
const buffer = Buffer.alloc(length);
|
|
75574
75848
|
const { bytesRead } = await handle.read(buffer, 0, length, start);
|
|
@@ -75577,18 +75851,18 @@ var NodeFileSystem = class {
|
|
|
75577
75851
|
await handle.close();
|
|
75578
75852
|
}
|
|
75579
75853
|
}
|
|
75580
|
-
async writeFile(
|
|
75581
|
-
await import_promises25.default.writeFile(
|
|
75854
|
+
async writeFile(path61, contents) {
|
|
75855
|
+
await import_promises25.default.writeFile(path61, contents, "utf8");
|
|
75582
75856
|
}
|
|
75583
75857
|
/** The counterpart of `readBytes`, and deliberately as bare as `writeFile` beside it. */
|
|
75584
|
-
async writeBytes(
|
|
75585
|
-
await import_promises25.default.writeFile(
|
|
75858
|
+
async writeBytes(path61, contents) {
|
|
75859
|
+
await import_promises25.default.writeFile(path61, contents);
|
|
75586
75860
|
}
|
|
75587
75861
|
async rename(from, to) {
|
|
75588
75862
|
await replaceFile(from, to);
|
|
75589
75863
|
}
|
|
75590
|
-
async stat(
|
|
75591
|
-
const stat = await import_promises25.default.lstat(
|
|
75864
|
+
async stat(path61) {
|
|
75865
|
+
const stat = await import_promises25.default.lstat(path61);
|
|
75592
75866
|
return {
|
|
75593
75867
|
size: stat.size,
|
|
75594
75868
|
mtimeMs: stat.mtimeMs,
|
|
@@ -75597,8 +75871,8 @@ var NodeFileSystem = class {
|
|
|
75597
75871
|
isSymbolicLink: stat.isSymbolicLink()
|
|
75598
75872
|
};
|
|
75599
75873
|
}
|
|
75600
|
-
async readdir(
|
|
75601
|
-
const entries = await import_promises25.default.readdir(
|
|
75874
|
+
async readdir(path61) {
|
|
75875
|
+
const entries = await import_promises25.default.readdir(path61, { withFileTypes: true });
|
|
75602
75876
|
return entries.map((entry) => ({
|
|
75603
75877
|
name: entry.name,
|
|
75604
75878
|
isFile: entry.isFile(),
|
|
@@ -75606,21 +75880,21 @@ var NodeFileSystem = class {
|
|
|
75606
75880
|
isSymbolicLink: entry.isSymbolicLink()
|
|
75607
75881
|
}));
|
|
75608
75882
|
}
|
|
75609
|
-
async exists(
|
|
75883
|
+
async exists(path61) {
|
|
75610
75884
|
try {
|
|
75611
|
-
await import_promises25.default.access(
|
|
75885
|
+
await import_promises25.default.access(path61);
|
|
75612
75886
|
return true;
|
|
75613
75887
|
} catch {
|
|
75614
75888
|
return false;
|
|
75615
75889
|
}
|
|
75616
75890
|
}
|
|
75617
|
-
async mkdir(
|
|
75618
|
-
await import_promises25.default.mkdir(
|
|
75891
|
+
async mkdir(path61) {
|
|
75892
|
+
await import_promises25.default.mkdir(path61, { recursive: true });
|
|
75619
75893
|
}
|
|
75620
75894
|
};
|
|
75621
75895
|
|
|
75622
75896
|
// ../../packages/core/dist/config/project.js
|
|
75623
|
-
var
|
|
75897
|
+
var import_node_path45 = __toESM(require("node:path"), 1);
|
|
75624
75898
|
function configuredProjectName(config2) {
|
|
75625
75899
|
const name = config2?.project?.name?.trim();
|
|
75626
75900
|
return name !== void 0 && name.length > 0 ? name : void 0;
|
|
@@ -75629,7 +75903,7 @@ function projectName(config2, workspaceRoot) {
|
|
|
75629
75903
|
const configured = configuredProjectName(config2);
|
|
75630
75904
|
if (configured !== void 0)
|
|
75631
75905
|
return configured;
|
|
75632
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
75906
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path45.default.basename(import_node_path45.default.resolve(workspaceRoot));
|
|
75633
75907
|
}
|
|
75634
75908
|
function projectSlug(name) {
|
|
75635
75909
|
if (name === void 0)
|
|
@@ -75639,7 +75913,7 @@ function projectSlug(name) {
|
|
|
75639
75913
|
}
|
|
75640
75914
|
|
|
75641
75915
|
// ../../packages/core/dist/rag/renameIndexes.js
|
|
75642
|
-
var
|
|
75916
|
+
var import_node_path46 = __toESM(require("node:path"), 1);
|
|
75643
75917
|
var import_node_fs7 = require("node:fs");
|
|
75644
75918
|
function planIndexRenames(names) {
|
|
75645
75919
|
const plans = [];
|
|
@@ -75703,7 +75977,7 @@ async function copyBookkeeping(directory, from, to, storeId) {
|
|
|
75703
75977
|
continue;
|
|
75704
75978
|
const target = `${to}@${storeId}.${entry.slice(prefix.length)}`;
|
|
75705
75979
|
try {
|
|
75706
|
-
await import_node_fs7.promises.copyFile(
|
|
75980
|
+
await import_node_fs7.promises.copyFile(import_node_path46.default.join(directory, entry), import_node_path46.default.join(directory, target), import_node_fs7.constants.COPYFILE_EXCL);
|
|
75707
75981
|
copied.push(target);
|
|
75708
75982
|
} catch {
|
|
75709
75983
|
}
|
|
@@ -75790,7 +76064,7 @@ var NodeTerminal = class {
|
|
|
75790
76064
|
|
|
75791
76065
|
// ../../packages/core/dist/platform/node/taskStore.js
|
|
75792
76066
|
var import_promises26 = __toESM(require("node:fs/promises"), 1);
|
|
75793
|
-
var
|
|
76067
|
+
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
75794
76068
|
|
|
75795
76069
|
// ../../packages/core/dist/history/types.js
|
|
75796
76070
|
function taskSummary(task) {
|
|
@@ -75813,7 +76087,7 @@ var JsonTaskStore = class {
|
|
|
75813
76087
|
constructor(globalStoragePath, truncationStore, logger) {
|
|
75814
76088
|
this.truncationStore = truncationStore;
|
|
75815
76089
|
this.logger = logger;
|
|
75816
|
-
this.directory =
|
|
76090
|
+
this.directory = import_node_path47.default.join(globalStoragePath, "tasks");
|
|
75817
76091
|
}
|
|
75818
76092
|
async list(workspaceRoot) {
|
|
75819
76093
|
const index = await this.readIndex();
|
|
@@ -75862,11 +76136,11 @@ var JsonTaskStore = class {
|
|
|
75862
76136
|
await this.writeIndex(index.filter((entry) => entry.id !== id));
|
|
75863
76137
|
}
|
|
75864
76138
|
fileFor(id) {
|
|
75865
|
-
return
|
|
76139
|
+
return import_node_path47.default.join(this.directory, `${id}.json`);
|
|
75866
76140
|
}
|
|
75867
76141
|
async readIndex() {
|
|
75868
76142
|
try {
|
|
75869
|
-
const raw = await import_promises26.default.readFile(
|
|
76143
|
+
const raw = await import_promises26.default.readFile(import_node_path47.default.join(this.directory, INDEX_FILE), "utf8");
|
|
75870
76144
|
const parsed = JSON.parse(raw);
|
|
75871
76145
|
if (Array.isArray(parsed))
|
|
75872
76146
|
return parsed.filter(isIndexEntry);
|
|
@@ -75901,7 +76175,7 @@ var JsonTaskStore = class {
|
|
|
75901
76175
|
}
|
|
75902
76176
|
async writeIndex(entries) {
|
|
75903
76177
|
await import_promises26.default.mkdir(this.directory, { recursive: true });
|
|
75904
|
-
const target =
|
|
76178
|
+
const target = import_node_path47.default.join(this.directory, INDEX_FILE);
|
|
75905
76179
|
const temporary = `${target}.tmp`;
|
|
75906
76180
|
await import_promises26.default.writeFile(temporary, JSON.stringify(entries, null, 2), "utf8");
|
|
75907
76181
|
await replaceFile(temporary, target);
|
|
@@ -75933,7 +76207,7 @@ function parseTask(raw) {
|
|
|
75933
76207
|
|
|
75934
76208
|
// ../../packages/core/dist/usage/store.js
|
|
75935
76209
|
var import_node_fs8 = require("node:fs");
|
|
75936
|
-
var
|
|
76210
|
+
var import_node_path48 = __toESM(require("node:path"), 1);
|
|
75937
76211
|
|
|
75938
76212
|
// ../../packages/core/dist/s3/keys.js
|
|
75939
76213
|
function normalisePrefix(prefix) {
|
|
@@ -76066,7 +76340,7 @@ var FolderShardStore = class {
|
|
|
76066
76340
|
await this.ask({ action: "write", user: shardSegment(shard.user), day: shard.day, instance: shard.instance, events });
|
|
76067
76341
|
return;
|
|
76068
76342
|
}
|
|
76069
|
-
await this.writeAtomically(
|
|
76343
|
+
await this.writeAtomically(import_node_path48.default.join(this.root, shardSegment(shard.user), `${shard.day}__${shard.instance}.jsonl`), shardText(events));
|
|
76070
76344
|
}
|
|
76071
76345
|
async read(fromDay, toDay) {
|
|
76072
76346
|
this.lastProblems = [];
|
|
@@ -76086,8 +76360,8 @@ var FolderShardStore = class {
|
|
|
76086
76360
|
}
|
|
76087
76361
|
const files = await this.listFiles();
|
|
76088
76362
|
const wanted = selectShards(files, fromDay, toDay);
|
|
76089
|
-
const texts = await pooled(wanted, 8, (file2) => import_node_fs8.promises.readFile(
|
|
76090
|
-
this.lastProblems.push(`${
|
|
76363
|
+
const texts = await pooled(wanted, 8, (file2) => import_node_fs8.promises.readFile(import_node_path48.default.join(this.root, file2.user, file2.name), "utf8").catch((error51) => {
|
|
76364
|
+
this.lastProblems.push(`${import_node_path48.default.join(this.root, file2.user, file2.name)}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
76091
76365
|
return "";
|
|
76092
76366
|
}));
|
|
76093
76367
|
return texts.flatMap(parseUsageLines);
|
|
@@ -76104,7 +76378,7 @@ var FolderShardStore = class {
|
|
|
76104
76378
|
}
|
|
76105
76379
|
const files = [];
|
|
76106
76380
|
for (const user of users) {
|
|
76107
|
-
const folder =
|
|
76381
|
+
const folder = import_node_path48.default.join(this.root, user);
|
|
76108
76382
|
let names;
|
|
76109
76383
|
try {
|
|
76110
76384
|
names = await import_node_fs8.promises.readdir(folder);
|
|
@@ -76123,7 +76397,7 @@ var FolderShardStore = class {
|
|
|
76123
76397
|
}
|
|
76124
76398
|
async readShard(shard) {
|
|
76125
76399
|
try {
|
|
76126
|
-
return parseUsageLines(await import_node_fs8.promises.readFile(
|
|
76400
|
+
return parseUsageLines(await import_node_fs8.promises.readFile(import_node_path48.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), "utf8"));
|
|
76127
76401
|
} catch (error51) {
|
|
76128
76402
|
if (error51.code === "ENOENT")
|
|
76129
76403
|
return void 0;
|
|
@@ -76131,10 +76405,10 @@ var FolderShardStore = class {
|
|
|
76131
76405
|
}
|
|
76132
76406
|
}
|
|
76133
76407
|
async putMonth(shard, events) {
|
|
76134
|
-
await this.writeAtomically(
|
|
76408
|
+
await this.writeAtomically(import_node_path48.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), shardText(events));
|
|
76135
76409
|
}
|
|
76136
76410
|
async removeShard(shard) {
|
|
76137
|
-
await import_node_fs8.promises.rm(
|
|
76411
|
+
await import_node_fs8.promises.rm(import_node_path48.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), { force: true });
|
|
76138
76412
|
}
|
|
76139
76413
|
async putProfile(user, profile) {
|
|
76140
76414
|
this.profilesFromRead = void 0;
|
|
@@ -76142,7 +76416,7 @@ var FolderShardStore = class {
|
|
|
76142
76416
|
await this.ask({ action: "writeProfile", user: shardSegment(user), profile: cleanProfile(profile) });
|
|
76143
76417
|
return;
|
|
76144
76418
|
}
|
|
76145
|
-
await this.writeAtomically(
|
|
76419
|
+
await this.writeAtomically(import_node_path48.default.join(this.root, "_profiles", `${shardSegment(user)}.json`), JSON.stringify(cleanProfile(profile)));
|
|
76146
76420
|
}
|
|
76147
76421
|
async readProfiles() {
|
|
76148
76422
|
if (this.profilesFromRead !== void 0)
|
|
@@ -76151,13 +76425,13 @@ var FolderShardStore = class {
|
|
|
76151
76425
|
await this.read("9999-12-31", "9999-12-31");
|
|
76152
76426
|
return this.profilesFromRead ?? {};
|
|
76153
76427
|
}
|
|
76154
|
-
const folder =
|
|
76428
|
+
const folder = import_node_path48.default.join(this.root, "_profiles");
|
|
76155
76429
|
const profiles = {};
|
|
76156
76430
|
for (const name of await import_node_fs8.promises.readdir(folder).catch(() => [])) {
|
|
76157
76431
|
if (!name.endsWith(".json"))
|
|
76158
76432
|
continue;
|
|
76159
76433
|
try {
|
|
76160
|
-
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs8.promises.readFile(
|
|
76434
|
+
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs8.promises.readFile(import_node_path48.default.join(folder, name), "utf8")));
|
|
76161
76435
|
} catch {
|
|
76162
76436
|
}
|
|
76163
76437
|
}
|
|
@@ -76906,7 +77180,7 @@ function usageCollectionOn(config2, choice) {
|
|
|
76906
77180
|
|
|
76907
77181
|
// ../../packages/core/dist/usage/backfill.js
|
|
76908
77182
|
var import_node_fs9 = require("node:fs");
|
|
76909
|
-
var
|
|
77183
|
+
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
76910
77184
|
function comparablePath(value) {
|
|
76911
77185
|
return value.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
76912
77186
|
}
|
|
@@ -76916,7 +77190,7 @@ function eventsFromTask(task, context) {
|
|
|
76916
77190
|
return [];
|
|
76917
77191
|
const created = typeof task.createdAt === "number" && task.createdAt <= updated ? task.createdAt : updated;
|
|
76918
77192
|
const root = typeof task.workspaceRoot === "string" ? task.workspaceRoot : void 0;
|
|
76919
|
-
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ?
|
|
77193
|
+
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ? import_node_path49.default.basename(root.replace(/\\/g, "/")) : void 0;
|
|
76920
77194
|
const skillsByPath = new Map(context.skills.map((skill) => [comparablePath(skill.filePath), skill]));
|
|
76921
77195
|
const skip = new Set(context.skip);
|
|
76922
77196
|
const calls = [];
|
|
@@ -76953,7 +77227,7 @@ function eventsFromTask(task, context) {
|
|
|
76953
77227
|
let skill;
|
|
76954
77228
|
if (call.name === "read_file" && typeof call.args["path"] === "string") {
|
|
76955
77229
|
const requested2 = call.args["path"];
|
|
76956
|
-
const absolute =
|
|
77230
|
+
const absolute = import_node_path49.default.isAbsolute(requested2) || /^[A-Za-z]:[\\/]/.test(requested2) || root === void 0 ? requested2 : import_node_path49.default.join(root, requested2);
|
|
76957
77231
|
skill = skillsByPath.get(comparablePath(absolute));
|
|
76958
77232
|
}
|
|
76959
77233
|
if (call.name === "use_skill_file" && typeof call.args["skill"] === "string") {
|
|
@@ -76998,7 +77272,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
76998
77272
|
let unreadable = 0;
|
|
76999
77273
|
for (const name of names) {
|
|
77000
77274
|
try {
|
|
77001
|
-
events.push(...eventsFromTask(JSON.parse(await import_node_fs9.promises.readFile(
|
|
77275
|
+
events.push(...eventsFromTask(JSON.parse(await import_node_fs9.promises.readFile(import_node_path49.default.join(tasksDir, name), "utf8")), context));
|
|
77002
77276
|
} catch {
|
|
77003
77277
|
unreadable++;
|
|
77004
77278
|
}
|
|
@@ -77006,13 +77280,13 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
77006
77280
|
return { events, tasks: names.length, unreadable, via: "node" };
|
|
77007
77281
|
}
|
|
77008
77282
|
async function backfillOnce(options) {
|
|
77009
|
-
const doneFile =
|
|
77283
|
+
const doneFile = import_node_path49.default.join(options.usageDir, "backfill.json");
|
|
77010
77284
|
for (const file2 of [doneFile, ...options.legacyDoneFile !== void 0 ? [options.legacyDoneFile] : []]) {
|
|
77011
77285
|
if (await import_node_fs9.promises.stat(file2).then(() => true, () => false))
|
|
77012
77286
|
return { ran: false };
|
|
77013
77287
|
}
|
|
77014
77288
|
await import_node_fs9.promises.mkdir(options.usageDir, { recursive: true });
|
|
77015
|
-
const startFile =
|
|
77289
|
+
const startFile = import_node_path49.default.join(options.usageDir, "backfill-start.json");
|
|
77016
77290
|
let before;
|
|
77017
77291
|
try {
|
|
77018
77292
|
before = (options.now ?? Date.now)();
|
|
@@ -77421,14 +77695,14 @@ function wireChatBridge(services) {
|
|
|
77421
77695
|
let cachedSecretValues = [];
|
|
77422
77696
|
const droppedFilesRoot2 = droppedFilesRoot();
|
|
77423
77697
|
const mailAttachmentsRoot2 = mailAttachmentsRoot();
|
|
77424
|
-
const droppedFilesDir =
|
|
77425
|
-
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(
|
|
77698
|
+
const droppedFilesDir = import_node_path50.default.join(droppedFilesRoot2, (0, import_node_crypto15.randomUUID)().slice(0, 8));
|
|
77699
|
+
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(import_node_path50.default.join(storageDir, "tool-results"), () => cachedSecretValues));
|
|
77426
77700
|
const taskStore = new JsonTaskStore(storageDir, truncationStore, logger);
|
|
77427
77701
|
const manifestsRoot = services.codebaseDir ?? storageDir;
|
|
77428
77702
|
const codebaseInstructionsFile = codebaseInstructionsPath({ codebaseDir: services.codebaseDir, storageDir, workspaceRoot });
|
|
77429
77703
|
if (services.codebaseDir !== void 0) {
|
|
77430
|
-
const shared =
|
|
77431
|
-
void import_promises27.default.access(shared).catch(() => import_promises27.default.cp(
|
|
77704
|
+
const shared = import_node_path50.default.join(services.codebaseDir, "index-manifests");
|
|
77705
|
+
void import_promises27.default.access(shared).catch(() => import_promises27.default.cp(import_node_path50.default.join(storageDir, "index-manifests"), shared, { recursive: true, errorOnExist: false, force: false })).catch(() => void 0);
|
|
77432
77706
|
}
|
|
77433
77707
|
const python = new PythonManager({
|
|
77434
77708
|
workspaceRoot,
|
|
@@ -77554,7 +77828,7 @@ ${preview.text}` } : {}
|
|
|
77554
77828
|
void postDatasetStatus();
|
|
77555
77829
|
}
|
|
77556
77830
|
});
|
|
77557
|
-
const defaultSkillsDir = workspaceRoot !== void 0 ?
|
|
77831
|
+
const defaultSkillsDir = workspaceRoot !== void 0 ? import_node_path50.default.join(workspaceRoot, ".lightcode", "skills") : void 0;
|
|
77558
77832
|
let skillsDir = defaultSkillsDir;
|
|
77559
77833
|
let localSkillsDir = defaultSkillsDir;
|
|
77560
77834
|
let extraSkillDirs = [];
|
|
@@ -77577,9 +77851,9 @@ ${preview.text}` } : {}
|
|
|
77577
77851
|
const trimmed = entry.trim();
|
|
77578
77852
|
if (trimmed.length === 0)
|
|
77579
77853
|
return void 0;
|
|
77580
|
-
if (
|
|
77581
|
-
return
|
|
77582
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
77854
|
+
if (import_node_path50.default.isAbsolute(trimmed))
|
|
77855
|
+
return import_node_path50.default.resolve(trimmed);
|
|
77856
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path50.default.resolve(workspaceRoot, trimmed);
|
|
77583
77857
|
}
|
|
77584
77858
|
function skillSearchPath() {
|
|
77585
77859
|
return [skillsDir, ...extraSkillDirs].filter((dir) => dir !== void 0);
|
|
@@ -77611,7 +77885,7 @@ ${preview.text}` } : {}
|
|
|
77611
77885
|
function watchSkillFolders() {
|
|
77612
77886
|
stopWatchingSkills();
|
|
77613
77887
|
const dirs = skillSearchPath();
|
|
77614
|
-
for (const dir of [...dirs, ...dirs.map((entry) =>
|
|
77888
|
+
for (const dir of [...dirs, ...dirs.map((entry) => import_node_path50.default.dirname(entry))]) {
|
|
77615
77889
|
try {
|
|
77616
77890
|
skillWatchers.push(
|
|
77617
77891
|
// Recursive, because a skill may be a folder with SKILL.md inside — a non-recursive
|
|
@@ -77682,7 +77956,7 @@ ${preview.text}` } : {}
|
|
|
77682
77956
|
await openInPanelEditor(filePath);
|
|
77683
77957
|
return;
|
|
77684
77958
|
}
|
|
77685
|
-
const real = await confineToAny(
|
|
77959
|
+
const real = await confineToAny(import_node_path50.default.resolve(filePath), roots);
|
|
77686
77960
|
await ui.openFile?.(real);
|
|
77687
77961
|
} catch (error51) {
|
|
77688
77962
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -77693,9 +77967,9 @@ ${preview.text}` } : {}
|
|
|
77693
77967
|
python.toolsDirectory(),
|
|
77694
77968
|
...skillsDir === void 0 ? [] : [skillsDir],
|
|
77695
77969
|
...extraSkillDirs.filter((dir) => dir !== void 0),
|
|
77696
|
-
|
|
77970
|
+
import_node_path50.default.join(storageDir, "reports"),
|
|
77697
77971
|
// Its own folder: nothing else lives there.
|
|
77698
|
-
...codebaseInstructionsFile === void 0 ? [] : [
|
|
77972
|
+
...codebaseInstructionsFile === void 0 ? [] : [import_node_path50.default.dirname(codebaseInstructionsFile)]
|
|
77699
77973
|
].filter((dir) => dir.length > 0);
|
|
77700
77974
|
}
|
|
77701
77975
|
function mostlyCrlf(text) {
|
|
@@ -77704,17 +77978,17 @@ ${preview.text}` } : {}
|
|
|
77704
77978
|
}
|
|
77705
77979
|
const EDITOR_MAX_BYTES = 2 * 1024 * 1024;
|
|
77706
77980
|
async function openInPanelEditor(filePath) {
|
|
77707
|
-
const real = await confineToAny(
|
|
77981
|
+
const real = await confineToAny(import_node_path50.default.resolve(filePath), managedRoots());
|
|
77708
77982
|
const stat = await import_promises27.default.stat(real);
|
|
77709
77983
|
if (stat.size > EDITOR_MAX_BYTES)
|
|
77710
|
-
throw new Error(`${
|
|
77984
|
+
throw new Error(`${import_node_path50.default.basename(real)} is too large to edit here (${String(Math.round(stat.size / 1024))} KB).`);
|
|
77711
77985
|
const raw = await import_promises27.default.readFile(real, "utf8");
|
|
77712
77986
|
const crlf = mostlyCrlf(raw);
|
|
77713
|
-
post({ type: "editorFile", path: real, name:
|
|
77987
|
+
post({ type: "editorFile", path: real, name: import_node_path50.default.basename(real), content: raw.split("\r\n").join("\n"), mtimeMs: stat.mtimeMs, eol: crlf ? "crlf" : "lf" });
|
|
77714
77988
|
}
|
|
77715
77989
|
async function handleSaveEditorFile(filePath, content, mtimeMs) {
|
|
77716
77990
|
try {
|
|
77717
|
-
const real = await confineToAny(
|
|
77991
|
+
const real = await confineToAny(import_node_path50.default.resolve(filePath), managedRoots());
|
|
77718
77992
|
const current = await import_promises27.default.stat(real).catch(() => void 0);
|
|
77719
77993
|
if (current !== void 0 && Math.abs(current.mtimeMs - mtimeMs) > 1) {
|
|
77720
77994
|
post({
|
|
@@ -77722,7 +77996,7 @@ ${preview.text}` } : {}
|
|
|
77722
77996
|
path: real,
|
|
77723
77997
|
ok: false,
|
|
77724
77998
|
conflict: true,
|
|
77725
|
-
message: `${
|
|
77999
|
+
message: `${import_node_path50.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.`
|
|
77726
78000
|
});
|
|
77727
78001
|
return;
|
|
77728
78002
|
}
|
|
@@ -77746,7 +78020,7 @@ ${preview.text}` } : {}
|
|
|
77746
78020
|
await handleOpenManagedFile(existing.filePath);
|
|
77747
78021
|
return;
|
|
77748
78022
|
}
|
|
77749
|
-
const target =
|
|
78023
|
+
const target = import_node_path50.default.join(skillsDir, "standing-instructions.md");
|
|
77750
78024
|
try {
|
|
77751
78025
|
await import_promises27.default.mkdir(skillsDir, { recursive: true });
|
|
77752
78026
|
await import_promises27.default.writeFile(target, STANDING_SKILL_TEMPLATE, { encoding: "utf8", flag: "wx" });
|
|
@@ -77766,7 +78040,7 @@ ${preview.text}` } : {}
|
|
|
77766
78040
|
return;
|
|
77767
78041
|
}
|
|
77768
78042
|
try {
|
|
77769
|
-
await import_promises27.default.mkdir(
|
|
78043
|
+
await import_promises27.default.mkdir(import_node_path50.default.dirname(codebaseInstructionsFile), { recursive: true });
|
|
77770
78044
|
await import_promises27.default.writeFile(codebaseInstructionsFile, "", { encoding: "utf8", flag: "wx" });
|
|
77771
78045
|
} catch (error51) {
|
|
77772
78046
|
if (error51.code !== "EEXIST") {
|
|
@@ -77783,11 +78057,11 @@ ${preview.text}` } : {}
|
|
|
77783
78057
|
return;
|
|
77784
78058
|
if (!isValidToolName(name))
|
|
77785
78059
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
77786
|
-
const ownCopy =
|
|
78060
|
+
const ownCopy = import_node_path50.default.join(dir, toolFileName(name));
|
|
77787
78061
|
if (filePath !== void 0) {
|
|
77788
|
-
const same2 = (a, b) => normalizeForComparison(
|
|
78062
|
+
const same2 = (a, b) => normalizeForComparison(import_node_path50.default.resolve(a)) === normalizeForComparison(import_node_path50.default.resolve(b));
|
|
77789
78063
|
if (!same2(filePath, ownCopy)) {
|
|
77790
|
-
const fromBucket = mirroredToolsDirs.some((mirror) => same2(
|
|
78064
|
+
const fromBucket = mirroredToolsDirs.some((mirror) => same2(import_node_path50.default.dirname(filePath), mirror));
|
|
77791
78065
|
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.`);
|
|
77792
78066
|
}
|
|
77793
78067
|
}
|
|
@@ -77813,7 +78087,7 @@ ${preview.text}` } : {}
|
|
|
77813
78087
|
let dir;
|
|
77814
78088
|
let filePath = "";
|
|
77815
78089
|
for (const candidate of python.toolDirectories()) {
|
|
77816
|
-
const attempt =
|
|
78090
|
+
const attempt = import_node_path50.default.join(candidate, toolFileName(name));
|
|
77817
78091
|
if (await onDisk(attempt)) {
|
|
77818
78092
|
dir = candidate;
|
|
77819
78093
|
filePath = attempt;
|
|
@@ -77844,7 +78118,7 @@ ${preview.text}` } : {}
|
|
|
77844
78118
|
function samePath(a, b) {
|
|
77845
78119
|
if (a === void 0 || b === void 0)
|
|
77846
78120
|
return false;
|
|
77847
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
78121
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path50.default.resolve(value).toLowerCase() : import_node_path50.default.resolve(value);
|
|
77848
78122
|
return norm2(a) === norm2(b);
|
|
77849
78123
|
}
|
|
77850
78124
|
function publishFolder(kind, mirrors) {
|
|
@@ -77949,7 +78223,7 @@ ${preview.text}` } : {}
|
|
|
77949
78223
|
target,
|
|
77950
78224
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
|
|
77951
78225
|
relative: entry,
|
|
77952
|
-
contents: await import_promises27.default.readFile(
|
|
78226
|
+
contents: await import_promises27.default.readFile(import_node_path50.default.join(dir, entry))
|
|
77953
78227
|
});
|
|
77954
78228
|
uploaded += 1;
|
|
77955
78229
|
} catch (error51) {
|
|
@@ -77971,7 +78245,7 @@ ${preview.text}` } : {}
|
|
|
77971
78245
|
if (!isValidToolName(name))
|
|
77972
78246
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
77973
78247
|
for (const candidate of python.toolDirectories()) {
|
|
77974
|
-
const attempt =
|
|
78248
|
+
const attempt = import_node_path50.default.join(candidate, toolFileName(name));
|
|
77975
78249
|
try {
|
|
77976
78250
|
post({ type: "pythonToolSource", name, source: await import_promises27.default.readFile(attempt, "utf8") });
|
|
77977
78251
|
return;
|
|
@@ -78024,7 +78298,7 @@ ${preview.text}` } : {}
|
|
|
78024
78298
|
continue;
|
|
78025
78299
|
for (const candidate of python.toolDirectories()) {
|
|
78026
78300
|
try {
|
|
78027
|
-
const source = await import_promises27.default.readFile(
|
|
78301
|
+
const source = await import_promises27.default.readFile(import_node_path50.default.join(candidate, toolFileName(name)), "utf8");
|
|
78028
78302
|
declined[name] = hashSource(source);
|
|
78029
78303
|
recorded += 1;
|
|
78030
78304
|
break;
|
|
@@ -78082,7 +78356,7 @@ ${preview.text}` } : {}
|
|
|
78082
78356
|
let dir;
|
|
78083
78357
|
let filePath = "";
|
|
78084
78358
|
for (const candidate of python.toolDirectories()) {
|
|
78085
|
-
const attempt =
|
|
78359
|
+
const attempt = import_node_path50.default.join(candidate, toolFileName(name));
|
|
78086
78360
|
if (await onDisk(attempt)) {
|
|
78087
78361
|
dir = candidate;
|
|
78088
78362
|
filePath = attempt;
|
|
@@ -78108,7 +78382,7 @@ ${preview.text}` } : {}
|
|
|
78108
78382
|
function mirrorForDir(sourceDir) {
|
|
78109
78383
|
if (sourceDir === void 0)
|
|
78110
78384
|
return void 0;
|
|
78111
|
-
const wanted =
|
|
78385
|
+
const wanted = import_node_path50.default.resolve(sourceDir).toLowerCase();
|
|
78112
78386
|
for (const mirror of cachedSkillMirrors) {
|
|
78113
78387
|
if (mirror.enabled !== true)
|
|
78114
78388
|
continue;
|
|
@@ -78118,7 +78392,7 @@ ${preview.text}` } : {}
|
|
|
78118
78392
|
kind: "skills",
|
|
78119
78393
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
78120
78394
|
});
|
|
78121
|
-
if (
|
|
78395
|
+
if (import_node_path50.default.resolve(localDir).toLowerCase() === wanted)
|
|
78122
78396
|
return { mirror, localDir };
|
|
78123
78397
|
}
|
|
78124
78398
|
return void 0;
|
|
@@ -78183,8 +78457,8 @@ ${preview.text}` } : {}
|
|
|
78183
78457
|
});
|
|
78184
78458
|
let localProblem;
|
|
78185
78459
|
try {
|
|
78186
|
-
await import_promises27.default.rm(
|
|
78187
|
-
await import_promises27.default.rm(
|
|
78460
|
+
await import_promises27.default.rm(import_node_path50.default.join(found2.localDir, `${name}.md`), { force: true });
|
|
78461
|
+
await import_promises27.default.rm(import_node_path50.default.join(found2.localDir, name), { recursive: true, force: true });
|
|
78188
78462
|
} catch (error51) {
|
|
78189
78463
|
localProblem = error51 instanceof Error ? error51.message : String(error51);
|
|
78190
78464
|
}
|
|
@@ -78217,7 +78491,7 @@ ${preview.text}` } : {}
|
|
|
78217
78491
|
if (existing !== void 0 && existing.sourceDir !== void 0 && existing.sourceDir !== skillsDir) {
|
|
78218
78492
|
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.`);
|
|
78219
78493
|
}
|
|
78220
|
-
await import_promises27.default.rm(
|
|
78494
|
+
await import_promises27.default.rm(import_node_path50.default.join(skillsDir, skillFileName(name)), { force: true });
|
|
78221
78495
|
await postSkills();
|
|
78222
78496
|
} catch (error51) {
|
|
78223
78497
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -78389,6 +78663,8 @@ ${preview.text}` } : {}
|
|
|
78389
78663
|
let backgroundRun = false;
|
|
78390
78664
|
let backgroundRunErrors = [];
|
|
78391
78665
|
let userTurnRunning = false;
|
|
78666
|
+
let userTurnSettled;
|
|
78667
|
+
let userTurnWindingDown = false;
|
|
78392
78668
|
let scheduledRunInFlight;
|
|
78393
78669
|
let pythonNestedContext;
|
|
78394
78670
|
let pythonNestedCallsAllowed = false;
|
|
@@ -78397,7 +78673,7 @@ ${preview.text}` } : {}
|
|
|
78397
78673
|
let scheduleToolAccess;
|
|
78398
78674
|
const approvalsKey = workspaceRoot ?? "__no_workspace__";
|
|
78399
78675
|
function comparableApprovalsKey(key2) {
|
|
78400
|
-
return key2 === "__no_workspace__" ? key2 : normalizeForComparison(
|
|
78676
|
+
return key2 === "__no_workspace__" ? key2 : normalizeForComparison(import_node_path50.default.resolve(key2));
|
|
78401
78677
|
}
|
|
78402
78678
|
function approvalsFrom(stored) {
|
|
78403
78679
|
if (stored === void 0)
|
|
@@ -78608,7 +78884,7 @@ ${preview.text}` } : {}
|
|
|
78608
78884
|
...taskExpertEstimate === void 0 ? {} : { estimate: taskExpertEstimate }
|
|
78609
78885
|
});
|
|
78610
78886
|
}
|
|
78611
|
-
const expertEventsPath =
|
|
78887
|
+
const expertEventsPath = import_node_path50.default.join(storageDir, "expert-events.jsonl");
|
|
78612
78888
|
let expertEvents;
|
|
78613
78889
|
let juniorTurnWithoutExpert = false;
|
|
78614
78890
|
async function loadExpertEvents() {
|
|
@@ -78636,7 +78912,7 @@ ${preview.text}` } : {}
|
|
|
78636
78912
|
try {
|
|
78637
78913
|
const events = await loadExpertEvents();
|
|
78638
78914
|
events.push(event);
|
|
78639
|
-
await import_promises27.default.mkdir(
|
|
78915
|
+
await import_promises27.default.mkdir(import_node_path50.default.dirname(expertEventsPath), { recursive: true });
|
|
78640
78916
|
await import_promises27.default.appendFile(expertEventsPath, `${JSON.stringify(event)}
|
|
78641
78917
|
`, "utf8");
|
|
78642
78918
|
} catch (error51) {
|
|
@@ -78910,8 +79186,8 @@ ${preview.text}` } : {}
|
|
|
78910
79186
|
function contextMentionPath(file2) {
|
|
78911
79187
|
if (workspaceRoot === void 0)
|
|
78912
79188
|
return file2;
|
|
78913
|
-
const relative =
|
|
78914
|
-
return relative.length > 0 && !relative.startsWith("..") && !
|
|
79189
|
+
const relative = import_node_path50.default.relative(workspaceRoot, file2);
|
|
79190
|
+
return relative.length > 0 && !relative.startsWith("..") && !import_node_path50.default.isAbsolute(relative) ? relative.split(import_node_path50.default.sep).join("/") : file2;
|
|
78915
79191
|
}
|
|
78916
79192
|
function hostCapabilities() {
|
|
78917
79193
|
return {
|
|
@@ -79409,10 +79685,18 @@ ${preview.text}` } : {}
|
|
|
79409
79685
|
}
|
|
79410
79686
|
let installedAddons = [];
|
|
79411
79687
|
let addonProblems = [];
|
|
79688
|
+
const addonRoot = services.codebaseDir ?? storageDir;
|
|
79689
|
+
function readUserNpmrc() {
|
|
79690
|
+
try {
|
|
79691
|
+
return (0, import_node_fs11.readFileSync)(process.env["NPM_CONFIG_USERCONFIG"] ?? import_node_path50.default.join(import_node_os6.default.homedir(), ".npmrc"), "utf8");
|
|
79692
|
+
} catch {
|
|
79693
|
+
return void 0;
|
|
79694
|
+
}
|
|
79695
|
+
}
|
|
79412
79696
|
function addonFolders(config2) {
|
|
79413
79697
|
return {
|
|
79414
|
-
configured: (config2.addons?.folders ?? []).map((folder) =>
|
|
79415
|
-
defaults: defaultAddonFolders(process.env, process.execPath, process.platform)
|
|
79698
|
+
configured: (config2.addons?.folders ?? []).map((folder) => import_node_path50.default.resolve(folder)),
|
|
79699
|
+
defaults: defaultAddonFolders(process.env, process.execPath, process.platform, readUserNpmrc())
|
|
79416
79700
|
};
|
|
79417
79701
|
}
|
|
79418
79702
|
async function rescanAddons(config2) {
|
|
@@ -79422,8 +79706,171 @@ ${preview.text}` } : {}
|
|
|
79422
79706
|
addonProblems = found2.problems;
|
|
79423
79707
|
}
|
|
79424
79708
|
async function configureMcp(servers) {
|
|
79425
|
-
const { workspaceMcpServers } = await configManager.load();
|
|
79426
|
-
|
|
79709
|
+
const { config: config2, workspaceMcpServers } = await configManager.load();
|
|
79710
|
+
const delivered = /* @__PURE__ */ new Map();
|
|
79711
|
+
for (const addon of installedAddons) {
|
|
79712
|
+
if (addon.page === void 0)
|
|
79713
|
+
continue;
|
|
79714
|
+
const settings = config2.addons?.settings?.[addon.package];
|
|
79715
|
+
const stored = /* @__PURE__ */ new Set();
|
|
79716
|
+
for (const ref of possibleSecretRefs(addon, settings))
|
|
79717
|
+
if (await secrets.get(ref) !== void 0)
|
|
79718
|
+
stored.add(ref);
|
|
79719
|
+
const delivery = deliveryFor(addonRoot, addon, settings, stored);
|
|
79720
|
+
try {
|
|
79721
|
+
await writeFileAtomically(delivery.file, JSON.stringify(delivery.contents, null, 2));
|
|
79722
|
+
await import_promises27.default.mkdir(addonDownloadsDir(addonRoot, addon), { recursive: true });
|
|
79723
|
+
delivered.set(addon.package, delivery.env);
|
|
79724
|
+
} catch (error51) {
|
|
79725
|
+
logger.warn(`Could not write the settings for add-on ${addon.package}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
79726
|
+
}
|
|
79727
|
+
}
|
|
79728
|
+
await mcp.configure(runnableServers(servers, installedAddons, { execPath: process.execPath, electron: process.versions["electron"] !== void 0 }, workspaceMcpServers, (addon) => delivered.get(addon.package) ?? {}));
|
|
79729
|
+
}
|
|
79730
|
+
async function postAddonPage(pkg, extra = {}) {
|
|
79731
|
+
const { config: config2 } = await configManager.load();
|
|
79732
|
+
const addon = installedAddons.find((candidate) => candidate.package === pkg);
|
|
79733
|
+
if (addon?.page === void 0) {
|
|
79734
|
+
post({ type: "addonPage", package: pkg, error: `${pkg} is not installed, or has no settings of its own.` });
|
|
79735
|
+
return;
|
|
79736
|
+
}
|
|
79737
|
+
const settings = config2.addons?.settings?.[pkg];
|
|
79738
|
+
const isSet = async (recordId, fields) => {
|
|
79739
|
+
const set2 = [];
|
|
79740
|
+
for (const field2 of fields) {
|
|
79741
|
+
if (field2.type === "secret" && await secrets.get(addonSecretRef(pkg, recordId, field2.key)) !== void 0)
|
|
79742
|
+
set2.push(field2.key);
|
|
79743
|
+
}
|
|
79744
|
+
return set2;
|
|
79745
|
+
};
|
|
79746
|
+
post({
|
|
79747
|
+
type: "addonPage",
|
|
79748
|
+
package: pkg,
|
|
79749
|
+
...extra,
|
|
79750
|
+
view: {
|
|
79751
|
+
package: pkg,
|
|
79752
|
+
displayName: addon.displayName,
|
|
79753
|
+
...addon.icon !== void 0 ? { icon: addon.icon } : {},
|
|
79754
|
+
page: addon.page,
|
|
79755
|
+
state: addonState(addon, config2.mcpServers ?? {}),
|
|
79756
|
+
values: settings?.values ?? {},
|
|
79757
|
+
secretsSet: await isSet(void 0, addon.page.fields ?? []),
|
|
79758
|
+
records: await Promise.all((settings?.records ?? []).map(async (record2) => ({ ...record2, secretsSet: await isSet(record2.id, addon.page?.records?.fields ?? []) }))),
|
|
79759
|
+
tools: (mcp.states_().find((server) => server.name === addon.server)?.tools ?? []).map((tool) => ({
|
|
79760
|
+
name: tool.namespacedName,
|
|
79761
|
+
server: addon.server,
|
|
79762
|
+
tool: tool.name,
|
|
79763
|
+
description: tool.description,
|
|
79764
|
+
permission: tool.permission
|
|
79765
|
+
}))
|
|
79766
|
+
}
|
|
79767
|
+
});
|
|
79768
|
+
}
|
|
79769
|
+
async function storeAddonSettings(addon, next) {
|
|
79770
|
+
const { config: config2 } = await configManager.load();
|
|
79771
|
+
const all = { ...config2.addons?.settings ?? {}, [addon.package]: next };
|
|
79772
|
+
await configManager.save("user", { addons: { ...config2.addons ?? {}, settings: all } });
|
|
79773
|
+
const reloaded = (await configManager.load()).config;
|
|
79774
|
+
await configureMcp(reloaded.mcpServers ?? {});
|
|
79775
|
+
if (mcp.states_().some((server) => server.name === addon.server && server.status === "ready")) {
|
|
79776
|
+
await mcp.restart(addon.server).catch(() => void 0);
|
|
79777
|
+
}
|
|
79778
|
+
}
|
|
79779
|
+
async function writeAddonSecrets(pkg, recordId, fields, given, clear = []) {
|
|
79780
|
+
for (const field2 of fields) {
|
|
79781
|
+
if (field2.type !== "secret")
|
|
79782
|
+
continue;
|
|
79783
|
+
const ref = addonSecretRef(pkg, recordId, field2.key);
|
|
79784
|
+
const value = given[field2.key];
|
|
79785
|
+
if (typeof value === "string" && value.length > 0)
|
|
79786
|
+
await secrets.set(ref, value);
|
|
79787
|
+
else if (clear.includes(field2.key))
|
|
79788
|
+
await secrets.delete(ref);
|
|
79789
|
+
}
|
|
79790
|
+
}
|
|
79791
|
+
async function handleSaveAddonRecord(message4) {
|
|
79792
|
+
const addon = installedAddons.find((candidate) => candidate.package === message4.package);
|
|
79793
|
+
const spec = addon?.page?.records;
|
|
79794
|
+
if (addon === void 0 || spec === void 0)
|
|
79795
|
+
return postAddonPage(message4.package, { error: "This add-on keeps no list." });
|
|
79796
|
+
const cleaned = cleanAddonValues(spec.fields, message4.values);
|
|
79797
|
+
if (!cleaned.ok)
|
|
79798
|
+
return postAddonPage(message4.package, { error: cleaned.message });
|
|
79799
|
+
const { config: config2 } = await configManager.load();
|
|
79800
|
+
const current = config2.addons?.settings?.[addon.package] ?? {};
|
|
79801
|
+
const records = [...current.records ?? []];
|
|
79802
|
+
const name = String(cleaned.values[spec.keyField] ?? "");
|
|
79803
|
+
const clash = records.find((record2) => record2.id !== message4.id && String(record2.values[spec.keyField] ?? "").toLowerCase() === name.toLowerCase());
|
|
79804
|
+
if (clash !== void 0)
|
|
79805
|
+
return postAddonPage(message4.package, { error: `There is already a ${spec.noun} called "${name}".` });
|
|
79806
|
+
let id = message4.id;
|
|
79807
|
+
if (id === void 0) {
|
|
79808
|
+
if (records.length >= (spec.max ?? 500))
|
|
79809
|
+
return postAddonPage(message4.package, { error: `No more than ${String(spec.max ?? 500)} ${spec.noun}s.` });
|
|
79810
|
+
id = (0, import_node_crypto15.randomBytes)(6).toString("hex");
|
|
79811
|
+
records.push({ id, values: cleaned.values });
|
|
79812
|
+
} else {
|
|
79813
|
+
const at = records.findIndex((record2) => record2.id === id);
|
|
79814
|
+
if (at < 0)
|
|
79815
|
+
return postAddonPage(message4.package, { error: `That ${spec.noun} no longer exists.` });
|
|
79816
|
+
records[at] = { id, values: cleaned.values };
|
|
79817
|
+
}
|
|
79818
|
+
await writeAddonSecrets(addon.package, id, spec.fields, message4.secrets, message4.clearSecrets);
|
|
79819
|
+
await storeAddonSettings(addon, { ...current, records });
|
|
79820
|
+
await postAddonPage(message4.package, { saved: true });
|
|
79821
|
+
}
|
|
79822
|
+
async function handleDeleteAddonRecord(pkg, id) {
|
|
79823
|
+
const addon = installedAddons.find((candidate) => candidate.package === pkg);
|
|
79824
|
+
const spec = addon?.page?.records;
|
|
79825
|
+
if (addon === void 0 || spec === void 0)
|
|
79826
|
+
return postAddonPage(pkg);
|
|
79827
|
+
const { config: config2 } = await configManager.load();
|
|
79828
|
+
const current = config2.addons?.settings?.[pkg] ?? {};
|
|
79829
|
+
await writeAddonSecrets(pkg, id, spec.fields, {}, spec.fields.map((field2) => field2.key));
|
|
79830
|
+
await storeAddonSettings(addon, { ...current, records: (current.records ?? []).filter((record2) => record2.id !== id) });
|
|
79831
|
+
await postAddonPage(pkg, { saved: true });
|
|
79832
|
+
}
|
|
79833
|
+
async function handleSaveAddonValues(message4) {
|
|
79834
|
+
const addon = installedAddons.find((candidate) => candidate.package === message4.package);
|
|
79835
|
+
const fields = addon?.page?.fields;
|
|
79836
|
+
if (addon === void 0 || fields === void 0)
|
|
79837
|
+
return postAddonPage(message4.package);
|
|
79838
|
+
const cleaned = cleanAddonValues(fields, message4.values);
|
|
79839
|
+
if (!cleaned.ok)
|
|
79840
|
+
return postAddonPage(message4.package, { error: cleaned.message });
|
|
79841
|
+
const { config: config2 } = await configManager.load();
|
|
79842
|
+
await writeAddonSecrets(addon.package, void 0, fields, message4.secrets, message4.clearSecrets);
|
|
79843
|
+
await storeAddonSettings(addon, { ...config2.addons?.settings?.[addon.package] ?? {}, values: cleaned.values });
|
|
79844
|
+
await postAddonPage(message4.package, { saved: true });
|
|
79845
|
+
}
|
|
79846
|
+
async function handleRunAddonAction(pkg, id, tool) {
|
|
79847
|
+
const reply = (ok, text) => post({ type: "addonActionResult", package: pkg, id, tool, ok, text });
|
|
79848
|
+
const addon = installedAddons.find((candidate) => candidate.package === pkg);
|
|
79849
|
+
const spec = addon?.page?.records;
|
|
79850
|
+
if (addon === void 0 || spec === void 0 || !(spec.actions ?? []).some((action) => action.tool === tool))
|
|
79851
|
+
return reply(false, "That button is not one this add-on declares.");
|
|
79852
|
+
const { config: config2 } = await configManager.load();
|
|
79853
|
+
if (addonState(addon, config2.mcpServers ?? {}) !== "enabled")
|
|
79854
|
+
return reply(false, `Enable ${addon.displayName} first, on the Add-ons tab in Settings.`);
|
|
79855
|
+
const record2 = (config2.addons?.settings?.[pkg]?.records ?? []).find((candidate) => candidate.id === id);
|
|
79856
|
+
if (record2 === void 0)
|
|
79857
|
+
return reply(false, `That ${spec.noun} no longer exists.`);
|
|
79858
|
+
await mcp.ensureConnected();
|
|
79859
|
+
try {
|
|
79860
|
+
const result = await mcp.callPanelTool(addon.server, tool, { [spec.keyField]: record2.values[spec.keyField] });
|
|
79861
|
+
const update = result.isError ? void 0 : recordUpdateFrom(result.structured);
|
|
79862
|
+
if (update !== void 0) {
|
|
79863
|
+
const cleaned = cleanAddonValues(spec.fields, { ...record2.values, ...update });
|
|
79864
|
+
if (cleaned.ok) {
|
|
79865
|
+
const current = config2.addons?.settings?.[pkg] ?? {};
|
|
79866
|
+
await storeAddonSettings(addon, { ...current, records: (current.records ?? []).map((r) => r.id === id ? { id, values: cleaned.values } : r) });
|
|
79867
|
+
await postAddonPage(pkg);
|
|
79868
|
+
}
|
|
79869
|
+
}
|
|
79870
|
+
reply(!result.isError, result.text.slice(0, 4e3));
|
|
79871
|
+
} catch (error51) {
|
|
79872
|
+
reply(false, error51 instanceof Error ? error51.message : String(error51));
|
|
79873
|
+
}
|
|
79427
79874
|
}
|
|
79428
79875
|
async function syncMcpFromConfig(config2) {
|
|
79429
79876
|
const servers = config2.mcpServers ?? {};
|
|
@@ -79448,7 +79895,16 @@ ${preview.text}` } : {}
|
|
|
79448
79895
|
main: addon.main,
|
|
79449
79896
|
server: addon.server,
|
|
79450
79897
|
state,
|
|
79451
|
-
...state === "updated" && enabled !== void 0 ? { enabledVersion: enabled } : {}
|
|
79898
|
+
...state === "updated" && enabled !== void 0 ? { enabledVersion: enabled } : {},
|
|
79899
|
+
...addon.page !== void 0 ? { pageTitle: addon.page.title } : {},
|
|
79900
|
+
...addon.icon !== void 0 ? { icon: addon.icon } : {},
|
|
79901
|
+
...addon.pageProblem !== void 0 ? { pageProblem: addon.pageProblem } : {},
|
|
79902
|
+
...(() => {
|
|
79903
|
+
const running = state === "enabled" ? mcp.states_().find((server) => server.name === addon.server) : void 0;
|
|
79904
|
+
if (running === void 0)
|
|
79905
|
+
return {};
|
|
79906
|
+
return { status: running.status, ...running.error !== void 0 ? { error: running.error } : {}, logs: running.logs.slice(-40) };
|
|
79907
|
+
})()
|
|
79452
79908
|
};
|
|
79453
79909
|
});
|
|
79454
79910
|
post({
|
|
@@ -79504,7 +79960,7 @@ ${preview.text}` } : {}
|
|
|
79504
79960
|
}
|
|
79505
79961
|
async function handleSaveAddonFolders(folders) {
|
|
79506
79962
|
const cleaned = [...new Set(folders.map((folder) => folder.trim()).filter((folder) => folder.length > 0))];
|
|
79507
|
-
const relative = cleaned.find((folder) => !
|
|
79963
|
+
const relative = cleaned.find((folder) => !import_node_path50.default.isAbsolute(folder));
|
|
79508
79964
|
if (relative !== void 0) {
|
|
79509
79965
|
await postAddons(`"${relative}" is not a full path. Add-on folders are full paths, such as C:\\addons.`);
|
|
79510
79966
|
return;
|
|
@@ -79515,7 +79971,7 @@ ${preview.text}` } : {}
|
|
|
79515
79971
|
postMcp();
|
|
79516
79972
|
await postAddons();
|
|
79517
79973
|
}
|
|
79518
|
-
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot,
|
|
79974
|
+
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot, import_node_path50.default.join(storageDir, "checkpoints", "shadow.git"), services.codebaseDir !== void 0 ? import_node_path50.default.join(services.codebaseDir, "checkpoint-objects") : void 0) : void 0;
|
|
79519
79975
|
async function postProfiles() {
|
|
79520
79976
|
const { config: config2 } = await configManager.load();
|
|
79521
79977
|
const profiles = await Promise.all((config2.profiles ?? []).map((profile) => toSummary(profile, secrets)));
|
|
@@ -79572,7 +80028,7 @@ ${preview.text}` } : {}
|
|
|
79572
80028
|
if (workspaceRoot === void 0 || conversation.isEmpty())
|
|
79573
80029
|
return;
|
|
79574
80030
|
if (activeTaskId === void 0) {
|
|
79575
|
-
await setActiveTaskId((0,
|
|
80031
|
+
await setActiveTaskId((0, import_node_crypto15.randomUUID)());
|
|
79576
80032
|
activeTaskCreatedAt = Date.now();
|
|
79577
80033
|
truncationStore.startTask();
|
|
79578
80034
|
}
|
|
@@ -79650,6 +80106,9 @@ ${preview.text}` } : {}
|
|
|
79650
80106
|
if (handoffAbort !== void 0)
|
|
79651
80107
|
return;
|
|
79652
80108
|
const progress = (phase, extra = {}) => post({ type: "handoffProgress", phase, ...extra });
|
|
80109
|
+
if (userTurnRunning && userTurnWindingDown && userTurnSettled !== void 0) {
|
|
80110
|
+
await Promise.race([userTurnSettled, new Promise((resolve) => setTimeout(resolve, 3e4))]);
|
|
80111
|
+
}
|
|
79653
80112
|
if (userTurnRunning || scheduledRunInFlight !== void 0) {
|
|
79654
80113
|
progress("failed", { message: "A reply is still running. Wait for it to finish, or press Stop, then try again." });
|
|
79655
80114
|
return;
|
|
@@ -79917,7 +80376,9 @@ ${preview.text}` } : {}
|
|
|
79917
80376
|
...cachedReadRoots,
|
|
79918
80377
|
...(services.siblings ?? []).map((s) => s.path),
|
|
79919
80378
|
droppedFilesRoot2,
|
|
79920
|
-
mailAttachmentsRoot2
|
|
80379
|
+
mailAttachmentsRoot2,
|
|
80380
|
+
// What an add-on fetched for investigation (a file from a Linux machine, say) is read without asking.
|
|
80381
|
+
...installedAddons.map((addon) => addonDownloadsDir(addonRoot, addon))
|
|
79921
80382
|
],
|
|
79922
80383
|
...services.fileReach === "anywhere" ? { reach: "anywhere" } : {},
|
|
79923
80384
|
// Resolved per turn by the host, so an edit applies to the next command rather than
|
|
@@ -80209,7 +80670,10 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
80209
80670
|
taskCheckpoint = checkpoint;
|
|
80210
80671
|
post({ type: "checkpointAvailable" });
|
|
80211
80672
|
},
|
|
80212
|
-
onDone: (ending) =>
|
|
80673
|
+
onDone: (ending) => {
|
|
80674
|
+
userTurnWindingDown = true;
|
|
80675
|
+
post({ type: "done", ...ending === "question" ? { awaitingAnswer: true } : {} });
|
|
80676
|
+
},
|
|
80213
80677
|
onError: (message4) => post({ type: "error", message: message4 })
|
|
80214
80678
|
}, turnOptions);
|
|
80215
80679
|
} catch (error51) {
|
|
@@ -80330,7 +80794,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
80330
80794
|
try {
|
|
80331
80795
|
const { config: config2 } = await configManager.load();
|
|
80332
80796
|
const profiles = config2.profiles ?? [];
|
|
80333
|
-
const id = input.id ?? (0,
|
|
80797
|
+
const id = input.id ?? (0, import_node_crypto15.randomUUID)();
|
|
80334
80798
|
const existing = profiles.find((p) => p.id === id);
|
|
80335
80799
|
const auth2 = await buildAuthFromInput(input, id);
|
|
80336
80800
|
const saved = {
|
|
@@ -80368,7 +80832,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
80368
80832
|
post({ type: "error", message: `Profile "${id}" no longer exists.` });
|
|
80369
80833
|
return;
|
|
80370
80834
|
}
|
|
80371
|
-
const newId = (0,
|
|
80835
|
+
const newId = (0, import_node_crypto15.randomUUID)();
|
|
80372
80836
|
async function copySecret(fromRef, toRef) {
|
|
80373
80837
|
if (fromRef === void 0)
|
|
80374
80838
|
return false;
|
|
@@ -81185,7 +81649,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81185
81649
|
return { mode: cachedSearchScope, author: cachedAttribution.author };
|
|
81186
81650
|
}
|
|
81187
81651
|
function currentProjectNames() {
|
|
81188
|
-
const names = [cachedAttribution.project, workspaceRoot !== void 0 ?
|
|
81652
|
+
const names = [cachedAttribution.project, workspaceRoot !== void 0 ? import_node_path50.default.basename(workspaceRoot) : void 0];
|
|
81189
81653
|
return names.filter((name) => name !== void 0 && name.length > 0);
|
|
81190
81654
|
}
|
|
81191
81655
|
function indexProject(config2) {
|
|
@@ -81288,8 +81752,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81288
81752
|
limit: limits.limit,
|
|
81289
81753
|
previewChars: limits.previewChars
|
|
81290
81754
|
});
|
|
81291
|
-
for (const
|
|
81292
|
-
skipped.add(
|
|
81755
|
+
for (const path61 of answer.skipped ?? [])
|
|
81756
|
+
skipped.add(path61);
|
|
81293
81757
|
return { messages: answer.messages, truncated: answer.truncated };
|
|
81294
81758
|
},
|
|
81295
81759
|
...embedder !== void 0 && search !== void 0 && collection !== void 0 ? {
|
|
@@ -81588,9 +82052,9 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81588
82052
|
});
|
|
81589
82053
|
const all = result.folders.map((entry) => entry.path);
|
|
81590
82054
|
const wanted = new Set(chosen);
|
|
81591
|
-
for (const
|
|
81592
|
-
if (chosen.some((root) =>
|
|
81593
|
-
wanted.add(
|
|
82055
|
+
for (const path61 of all) {
|
|
82056
|
+
if (chosen.some((root) => path61 === root || path61.startsWith(`${root}\\`)))
|
|
82057
|
+
wanted.add(path61);
|
|
81594
82058
|
}
|
|
81595
82059
|
return [...wanted];
|
|
81596
82060
|
} catch {
|
|
@@ -81598,7 +82062,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81598
82062
|
}
|
|
81599
82063
|
}
|
|
81600
82064
|
async function handleRequestOutlookFolders(depth, force = false) {
|
|
81601
|
-
const cachePath =
|
|
82065
|
+
const cachePath = import_node_path50.default.join(storageDir, "outlook-folders.json");
|
|
81602
82066
|
let served = false;
|
|
81603
82067
|
try {
|
|
81604
82068
|
const cached2 = JSON.parse(await import_promises27.default.readFile(cachePath, "utf8"));
|
|
@@ -81618,7 +82082,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81618
82082
|
const scannedAt = Date.now();
|
|
81619
82083
|
post({ type: "outlookFolders", folders: result.folders, scannedAt });
|
|
81620
82084
|
try {
|
|
81621
|
-
await import_promises27.default.mkdir(
|
|
82085
|
+
await import_promises27.default.mkdir(import_node_path50.default.dirname(cachePath), { recursive: true });
|
|
81622
82086
|
await import_promises27.default.writeFile(cachePath, JSON.stringify({ scannedAt, folders: result.folders }), "utf8");
|
|
81623
82087
|
} catch {
|
|
81624
82088
|
}
|
|
@@ -81863,7 +82327,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81863
82327
|
if (auth2.clientId === void 0 || auth2.clientSecretRef === void 0) {
|
|
81864
82328
|
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.");
|
|
81865
82329
|
}
|
|
81866
|
-
const key2 = JSON.stringify({ auth: auth2, baseUrl: config2.autosys?.baseUrl, tls: tls2 === void 0 ? 0 : (0,
|
|
82330
|
+
const key2 = JSON.stringify({ auth: auth2, baseUrl: config2.autosys?.baseUrl, tls: tls2 === void 0 ? 0 : (0, import_node_crypto15.createHash)("sha256").update(JSON.stringify(tls2)).digest("hex") });
|
|
81867
82331
|
if (autosysGateway?.key === key2)
|
|
81868
82332
|
return autosysGateway.strategy;
|
|
81869
82333
|
const secretRef = auth2.clientSecretRef;
|
|
@@ -82284,7 +82748,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82284
82748
|
approvalStamps.set("machine", stamp2);
|
|
82285
82749
|
}
|
|
82286
82750
|
for (const dir of python.toolDirectories()) {
|
|
82287
|
-
const file2 =
|
|
82751
|
+
const file2 = import_node_path50.default.join(dir, REGISTRY_FILE);
|
|
82288
82752
|
const stamp2 = await import_promises27.default.stat(file2).then((stat) => stat.mtimeMs, () => 0);
|
|
82289
82753
|
if (approvalStamps.has(file2) && approvalStamps.get(file2) !== stamp2)
|
|
82290
82754
|
changed = true;
|
|
@@ -82375,7 +82839,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82375
82839
|
return;
|
|
82376
82840
|
}
|
|
82377
82841
|
const folder = skill.filePath.slice(0, skill.filePath.length - "SKILL.md".length);
|
|
82378
|
-
const bytes = await import_promises27.default.readFile(
|
|
82842
|
+
const bytes = await import_promises27.default.readFile(import_node_path50.default.join(folder, SKILL_IMAGE_DIR, image));
|
|
82379
82843
|
const dataUri = skillImageDataUri(image, bytes);
|
|
82380
82844
|
post({
|
|
82381
82845
|
type: "skillImage",
|
|
@@ -82703,13 +83167,13 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82703
83167
|
}
|
|
82704
83168
|
function docsFingerprintPath(index, storeId, kind) {
|
|
82705
83169
|
const suffix = kind === void 0 ? "docs" : `docs.${kind}`;
|
|
82706
|
-
return
|
|
83170
|
+
return import_node_path50.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.${suffix}.json`);
|
|
82707
83171
|
}
|
|
82708
83172
|
function manifestKey(index, storeId) {
|
|
82709
83173
|
return `${index}@${storeId}`;
|
|
82710
83174
|
}
|
|
82711
83175
|
function manifestPath(index, storeId) {
|
|
82712
|
-
return
|
|
83176
|
+
return import_node_path50.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.json`);
|
|
82713
83177
|
}
|
|
82714
83178
|
async function readDocsFingerprint(index, storeId, kind) {
|
|
82715
83179
|
try {
|
|
@@ -82739,7 +83203,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82739
83203
|
});
|
|
82740
83204
|
const wanted = options.kind;
|
|
82741
83205
|
const entries = wanted === void 0 ? all : all.filter((entry) => entry.kind === wanted);
|
|
82742
|
-
const fingerprint = (0,
|
|
83206
|
+
const fingerprint = (0, import_node_crypto15.createHash)("sha256").update(`${wanted ?? "all"}:${embedder.model}:${String(embedder.dimensions)}`).update(entries.map((entry) => `${entry.id}\0${entry.text}`).join("")).digest("hex");
|
|
82743
83207
|
if (!options.force && fingerprint === await readDocsFingerprint(index, search.id, wanted)) {
|
|
82744
83208
|
return { unchanged: true, index, indexed: entries.length };
|
|
82745
83209
|
}
|
|
@@ -82773,7 +83237,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82773
83237
|
}
|
|
82774
83238
|
options.report?.("Writing", { done: 0, total: documents.length });
|
|
82775
83239
|
await writer.upsert(index, documents);
|
|
82776
|
-
await import_promises27.default.mkdir(
|
|
83240
|
+
await import_promises27.default.mkdir(import_node_path50.default.dirname(docsFingerprintPath(index, search.id, wanted)), {
|
|
82777
83241
|
recursive: true
|
|
82778
83242
|
});
|
|
82779
83243
|
await import_promises27.default.writeFile(docsFingerprintPath(index, search.id, wanted), JSON.stringify({ fingerprint, indexedAt: Date.now(), count: documents.length }), "utf8");
|
|
@@ -82963,7 +83427,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82963
83427
|
});
|
|
82964
83428
|
if (manifest !== void 0) {
|
|
82965
83429
|
const targetPath = manifestPath(index, target.id);
|
|
82966
|
-
await import_promises27.default.mkdir(
|
|
83430
|
+
await import_promises27.default.mkdir(import_node_path50.default.dirname(targetPath), { recursive: true });
|
|
82967
83431
|
await import_promises27.default.writeFile(targetPath, JSON.stringify(manifest), "utf8");
|
|
82968
83432
|
}
|
|
82969
83433
|
post({ type: "storeSync", running: false, copied: result.copied, fromLabel: source.label });
|
|
@@ -83012,7 +83476,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83012
83476
|
type: "project",
|
|
83013
83477
|
hasWorkspace: workspaceRoot !== void 0,
|
|
83014
83478
|
...configured !== void 0 ? { configured } : {},
|
|
83015
|
-
...workspaceRoot !== void 0 ? { folder:
|
|
83479
|
+
...workspaceRoot !== void 0 ? { folder: import_node_path50.default.basename(workspaceRoot) } : {},
|
|
83016
83480
|
...author !== void 0 ? { author } : {},
|
|
83017
83481
|
...index !== void 0 ? { indexName: index } : {},
|
|
83018
83482
|
...ownerConfigured !== void 0 && ownerConfigured.length > 0 ? { ownerConfigured } : {},
|
|
@@ -83152,8 +83616,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83152
83616
|
if (workspaceRoot === void 0)
|
|
83153
83617
|
return found2;
|
|
83154
83618
|
const root = workspaceRoot;
|
|
83155
|
-
const relative =
|
|
83156
|
-
if (relative.startsWith("..") ||
|
|
83619
|
+
const relative = import_node_path50.default.relative(root, folder);
|
|
83620
|
+
if (relative.startsWith("..") || import_node_path50.default.isAbsolute(relative))
|
|
83157
83621
|
return found2;
|
|
83158
83622
|
const output = await new Promise((resolve) => {
|
|
83159
83623
|
const child = (0, import_node_child_process14.spawn)("git", ["-c", "core.quotePath=false", "log", "--diff-filter=A", "--relative", "--format=@@%an", "--name-only", "--", relative.length > 0 ? relative : "."], {
|
|
@@ -83170,7 +83634,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83170
83634
|
if (line.startsWith("@@"))
|
|
83171
83635
|
author = line.slice(2).trim();
|
|
83172
83636
|
else if (line.trim().length > 0 && author !== void 0 && author.length > 0) {
|
|
83173
|
-
found2.set(normalizeForComparison(
|
|
83637
|
+
found2.set(normalizeForComparison(import_node_path50.default.resolve(root, line.trim())), author);
|
|
83174
83638
|
}
|
|
83175
83639
|
}
|
|
83176
83640
|
return found2;
|
|
@@ -83214,7 +83678,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83214
83678
|
},
|
|
83215
83679
|
source,
|
|
83216
83680
|
folder,
|
|
83217
|
-
relative:
|
|
83681
|
+
relative: import_node_path50.default.relative(folder, filePath).split(import_node_path50.default.sep).join("/")
|
|
83218
83682
|
});
|
|
83219
83683
|
};
|
|
83220
83684
|
for (const folder of skillFolders) {
|
|
@@ -83232,7 +83696,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83232
83696
|
const name = entry.slice(0, -3);
|
|
83233
83697
|
if (!isValidToolName(name))
|
|
83234
83698
|
continue;
|
|
83235
|
-
await consider("tool", name,
|
|
83699
|
+
await consider("tool", name, import_node_path50.default.join(folder, entry), folder, location);
|
|
83236
83700
|
}
|
|
83237
83701
|
}
|
|
83238
83702
|
const readOnly = skills.filter((skill) => skill.sourceDir !== void 0 && !skillFolders.some((folder) => samePath(folder, skill.sourceDir))).length;
|
|
@@ -83264,7 +83728,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83264
83728
|
} catch {
|
|
83265
83729
|
}
|
|
83266
83730
|
}
|
|
83267
|
-
const gitAuthor = gitAuthors.get(normalizeForComparison(
|
|
83731
|
+
const gitAuthor = gitAuthors.get(normalizeForComparison(import_node_path50.default.resolve(candidate.entry.filePath)));
|
|
83268
83732
|
if (gitAuthor !== void 0) {
|
|
83269
83733
|
candidate.entry.suggestion = { author: gitAuthor, source: "git: the commit that added this file" };
|
|
83270
83734
|
}
|
|
@@ -83373,7 +83837,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83373
83837
|
aliases: plan2.kind === "codebase" ? codebaseAliases(config2) : plan2.kind === "skills" ? skillAliases(config2) : [],
|
|
83374
83838
|
onProgress: (count3) => post({ type: "indexRenames", running: true, plans, store, current: plan2.to, copied: count3 })
|
|
83375
83839
|
});
|
|
83376
|
-
await copyBookkeeping(
|
|
83840
|
+
await copyBookkeeping(import_node_path50.default.join(manifestsRoot, "index-manifests"), plan2.from, plan2.to, search.id);
|
|
83377
83841
|
done.push({ ...plan2, copied });
|
|
83378
83842
|
}
|
|
83379
83843
|
post({ type: "indexRenames", running: false, plans: [], store, done });
|
|
@@ -83403,7 +83867,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83403
83867
|
project: projectName(config2, workspaceRoot),
|
|
83404
83868
|
aliases: codebaseAliases(config2)
|
|
83405
83869
|
});
|
|
83406
|
-
await copyBookkeeping(
|
|
83870
|
+
await copyBookkeeping(import_node_path50.default.join(manifestsRoot, "index-manifests"), legacy, current, search.id);
|
|
83407
83871
|
post({ type: "indexRenames", running: false, plans: [], done: [{ kind: "codebase", from: legacy, to: current, copied }] });
|
|
83408
83872
|
logger.info(`copied ${String(copied)} chunks from ${legacy} to ${current} rather than re-embedding them`);
|
|
83409
83873
|
}
|
|
@@ -83569,7 +84033,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83569
84033
|
denylist,
|
|
83570
84034
|
manifest,
|
|
83571
84035
|
saveManifest: async (next) => {
|
|
83572
|
-
await import_promises27.default.mkdir(
|
|
84036
|
+
await import_promises27.default.mkdir(import_node_path50.default.dirname(manifestFile), { recursive: true });
|
|
83573
84037
|
await import_promises27.default.writeFile(manifestFile, JSON.stringify(next), "utf8");
|
|
83574
84038
|
},
|
|
83575
84039
|
...isIgnored2 !== void 0 ? { isIgnored: isIgnored2 } : {},
|
|
@@ -83616,9 +84080,9 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83616
84080
|
}
|
|
83617
84081
|
const usageLog = new UsageLog(storageDir);
|
|
83618
84082
|
const usageInstance = usageInstanceId(storageDir);
|
|
83619
|
-
const usageProfileFile =
|
|
83620
|
-
const legacyBackfillFile =
|
|
83621
|
-
const usageDir =
|
|
84083
|
+
const usageProfileFile = import_node_path50.default.join(storageDir, "usage-profile.json");
|
|
84084
|
+
const legacyBackfillFile = import_node_path50.default.join(storageDir, "usage-backfill.json");
|
|
84085
|
+
const usageDir = import_node_path50.default.join(storageDir, "usage");
|
|
83622
84086
|
const toolStartedAt = /* @__PURE__ */ new Map();
|
|
83623
84087
|
let usagePushTimer;
|
|
83624
84088
|
let usagePushing;
|
|
@@ -83636,7 +84100,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83636
84100
|
return (request) => runFastFs(exe, request);
|
|
83637
84101
|
}
|
|
83638
84102
|
function skillAtPath(requested2) {
|
|
83639
|
-
const absolute =
|
|
84103
|
+
const absolute = import_node_path50.default.isAbsolute(requested2) ? requested2 : workspaceRoot === void 0 ? void 0 : import_node_path50.default.resolve(workspaceRoot, requested2);
|
|
83640
84104
|
if (absolute === void 0)
|
|
83641
84105
|
return void 0;
|
|
83642
84106
|
return skills.find((skill) => samePath(skill.filePath, absolute));
|
|
@@ -83709,7 +84173,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83709
84173
|
const folder = chosen.path?.trim();
|
|
83710
84174
|
if (folder === void 0 || folder.length === 0)
|
|
83711
84175
|
return { problem: "The shared folder has no path." };
|
|
83712
|
-
if (!
|
|
84176
|
+
if (!import_node_path50.default.isAbsolute(folder))
|
|
83713
84177
|
return { problem: `"${folder}" is not an absolute path. Use the full path of a folder everybody can reach, such as a network share.` };
|
|
83714
84178
|
const helper = usageHelper();
|
|
83715
84179
|
return { store: new FolderShardStore(folder, ...helper !== void 0 ? [helper] : []), target };
|
|
@@ -83738,7 +84202,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83738
84202
|
}
|
|
83739
84203
|
async function readUsageBackfill() {
|
|
83740
84204
|
try {
|
|
83741
|
-
const text = await import_promises27.default.readFile(
|
|
84205
|
+
const text = await import_promises27.default.readFile(import_node_path50.default.join(usageDir, "backfill.json"), "utf8").catch(() => import_promises27.default.readFile(legacyBackfillFile, "utf8"));
|
|
83742
84206
|
const saved = JSON.parse(text);
|
|
83743
84207
|
if (typeof saved.at !== "number")
|
|
83744
84208
|
return void 0;
|
|
@@ -83754,7 +84218,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83754
84218
|
legacyDoneFile: legacyBackfillFile,
|
|
83755
84219
|
run: async (before) => {
|
|
83756
84220
|
const status2 = python.status();
|
|
83757
|
-
return backfillFromTasks(
|
|
84221
|
+
return backfillFromTasks(import_node_path50.default.join(storageDir, "tasks"), {
|
|
83758
84222
|
user: cachedAttribution.author ?? "unknown",
|
|
83759
84223
|
project: cachedAttribution.project,
|
|
83760
84224
|
workspaceRoot,
|
|
@@ -83852,7 +84316,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83852
84316
|
try {
|
|
83853
84317
|
const text = (await import_promises27.default.readFile(file2, "utf8")).replace(/\r\n/g, "\n");
|
|
83854
84318
|
const meaningful = text.split("\n").filter((line) => !/^(author|project|version|updated)\s*:/i.test(line) && !/^__(author|project|version|updated)__\s*=/.test(line)).join("\n").trim();
|
|
83855
|
-
return (0,
|
|
84319
|
+
return (0, import_node_crypto15.createHash)("sha256").update(meaningful).digest("hex").slice(0, 16);
|
|
83856
84320
|
} catch {
|
|
83857
84321
|
return void 0;
|
|
83858
84322
|
}
|
|
@@ -83927,14 +84391,14 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83927
84391
|
kind: "tool",
|
|
83928
84392
|
name: issue2.name,
|
|
83929
84393
|
filePath: issue2.filePath,
|
|
83930
|
-
deletable: samePath(
|
|
83931
|
-
location: where(
|
|
84394
|
+
deletable: samePath(import_node_path50.default.dirname(issue2.filePath), status2.toolsDir),
|
|
84395
|
+
location: where(import_node_path50.default.dirname(issue2.filePath), status2.toolsDir),
|
|
83932
84396
|
issue: issue2.kind === "unapproved" ? "waiting for approval" : issue2.kind === "hash-mismatch" ? "changed since approval" : issue2.detail.split("\n")[0] ?? "not loaded"
|
|
83933
84397
|
});
|
|
83934
84398
|
}
|
|
83935
84399
|
return items;
|
|
83936
84400
|
}
|
|
83937
|
-
const usageDirectoryFile =
|
|
84401
|
+
const usageDirectoryFile = import_node_path50.default.join(storageDir, "usage-directory.json");
|
|
83938
84402
|
let directoryRunning;
|
|
83939
84403
|
async function readDirectoryCache() {
|
|
83940
84404
|
try {
|
|
@@ -84266,7 +84730,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84266
84730
|
let indexedFiles = 0;
|
|
84267
84731
|
if (index !== void 0) {
|
|
84268
84732
|
try {
|
|
84269
|
-
const manifest = JSON.parse(await import_promises27.default.readFile(
|
|
84733
|
+
const manifest = JSON.parse(await import_promises27.default.readFile(import_node_path50.default.join(manifestsRoot, "index-manifests", `${index}.json`), "utf8"));
|
|
84270
84734
|
indexedFiles = Object.keys(manifest.files ?? {}).length;
|
|
84271
84735
|
} catch {
|
|
84272
84736
|
}
|
|
@@ -84538,7 +85002,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84538
85002
|
return;
|
|
84539
85003
|
}
|
|
84540
85004
|
const { config: config2 } = await configManager.load();
|
|
84541
|
-
const id = input.id ?? (0,
|
|
85005
|
+
const id = input.id ?? (0, import_node_crypto15.randomUUID)();
|
|
84542
85006
|
if (input.username !== void 0 && input.username.length > 0)
|
|
84543
85007
|
await secrets.set(searchUserRefFor(id), input.username);
|
|
84544
85008
|
if (input.password !== void 0 && input.password.length > 0)
|
|
@@ -84834,7 +85298,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84834
85298
|
if (changeLedger !== void 0) {
|
|
84835
85299
|
const shared = await changeLedger.othersSince(targets, taskCheckpoint.createdAt);
|
|
84836
85300
|
if (shared.size > 0) {
|
|
84837
|
-
const shown2 = (file2) =>
|
|
85301
|
+
const shown2 = (file2) => import_node_path50.default.relative(workspaceRoot ?? "", file2).split(import_node_path50.default.sep).join("/");
|
|
84838
85302
|
const detail = [...shared].map(([file2, chats]) => `${shown2(file2)} (${chats.join(", ")})`).join("; ");
|
|
84839
85303
|
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");
|
|
84840
85304
|
if (!all) {
|
|
@@ -85032,7 +85496,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85032
85496
|
const pathRequest = pendingPathApprovals.get(id);
|
|
85033
85497
|
userGate.resolve(id, "approve");
|
|
85034
85498
|
if (pathRequest !== void 0) {
|
|
85035
|
-
const folder =
|
|
85499
|
+
const folder = import_node_path50.default.dirname(pathRequest);
|
|
85036
85500
|
sessionPathGrants.add(normalizeForComparison(pathRequest));
|
|
85037
85501
|
if (scope === "folder" && !cachedReadRoots.includes(folder)) {
|
|
85038
85502
|
const { config: config2 } = await configManager.load();
|
|
@@ -85272,10 +85736,10 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85272
85736
|
});
|
|
85273
85737
|
return;
|
|
85274
85738
|
}
|
|
85275
|
-
let dir =
|
|
85739
|
+
let dir = import_node_path50.default.dirname(import_node_path50.default.resolve(scriptPath));
|
|
85276
85740
|
for (let depth = 0; depth < 3; depth++) {
|
|
85277
85741
|
for (const name of VENV_DIR_NAMES) {
|
|
85278
|
-
const candidate =
|
|
85742
|
+
const candidate = import_node_path50.default.join(dir, name);
|
|
85279
85743
|
const found2 = await search(candidate);
|
|
85280
85744
|
if (found2 !== void 0) {
|
|
85281
85745
|
post({
|
|
@@ -85287,7 +85751,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85287
85751
|
return;
|
|
85288
85752
|
}
|
|
85289
85753
|
}
|
|
85290
|
-
const parent =
|
|
85754
|
+
const parent = import_node_path50.default.dirname(dir);
|
|
85291
85755
|
if (parent === dir)
|
|
85292
85756
|
break;
|
|
85293
85757
|
dir = parent;
|
|
@@ -85377,10 +85841,14 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85377
85841
|
await scheduledRunInFlight;
|
|
85378
85842
|
}
|
|
85379
85843
|
userTurnRunning = true;
|
|
85844
|
+
userTurnWindingDown = false;
|
|
85845
|
+
const turn = handleSendMessage(composeUserText(message4.text, { replyTo: boundedQuote(message4.replyTo), reactions: takeReactions() }), message4.images);
|
|
85846
|
+
userTurnSettled = turn.then(() => void 0, () => void 0);
|
|
85380
85847
|
try {
|
|
85381
|
-
await
|
|
85848
|
+
await turn;
|
|
85382
85849
|
} finally {
|
|
85383
85850
|
userTurnRunning = false;
|
|
85851
|
+
userTurnWindingDown = false;
|
|
85384
85852
|
}
|
|
85385
85853
|
})();
|
|
85386
85854
|
} else if (message4.type === "compactConversation") {
|
|
@@ -85605,6 +86073,16 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85605
86073
|
reportFailure("handleClearCodebaseIndex", handleClearCodebaseIndex());
|
|
85606
86074
|
} else if (message4.type === "openStandingSkill") {
|
|
85607
86075
|
reportFailure("handleOpenStandingSkill", handleOpenStandingSkill());
|
|
86076
|
+
} else if (message4.type === "requestAddonPage") {
|
|
86077
|
+
reportFailure("postAddonPage", postAddonPage(message4.package));
|
|
86078
|
+
} else if (message4.type === "saveAddonRecord") {
|
|
86079
|
+
reportFailure("handleSaveAddonRecord", handleSaveAddonRecord(message4));
|
|
86080
|
+
} else if (message4.type === "deleteAddonRecord") {
|
|
86081
|
+
reportFailure("handleDeleteAddonRecord", handleDeleteAddonRecord(message4.package, message4.id));
|
|
86082
|
+
} else if (message4.type === "saveAddonValues") {
|
|
86083
|
+
reportFailure("handleSaveAddonValues", handleSaveAddonValues(message4));
|
|
86084
|
+
} else if (message4.type === "runAddonAction") {
|
|
86085
|
+
reportFailure("handleRunAddonAction", handleRunAddonAction(message4.package, message4.id, message4.tool));
|
|
85608
86086
|
} else if (message4.type === "requestAddons") {
|
|
85609
86087
|
reportFailure("postAddons", postAddons());
|
|
85610
86088
|
} else if (message4.type === "enableAddon") {
|
|
@@ -86118,11 +86596,11 @@ Could not be drawn: ${entry.message}`);
|
|
|
86118
86596
|
let lastReportPath;
|
|
86119
86597
|
async function saveReport(title, contents) {
|
|
86120
86598
|
try {
|
|
86121
|
-
const directory =
|
|
86599
|
+
const directory = import_node_path50.default.join(storageDir, "reports");
|
|
86122
86600
|
await import_promises27.default.mkdir(directory, { recursive: true });
|
|
86123
86601
|
const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
86124
86602
|
const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
86125
|
-
const target =
|
|
86603
|
+
const target = import_node_path50.default.join(directory, `${stamp2}${slug.length > 0 ? `-${slug}` : ""}.md`);
|
|
86126
86604
|
await import_promises27.default.writeFile(target, `# ${title}
|
|
86127
86605
|
|
|
86128
86606
|
${contents}
|
|
@@ -86138,7 +86616,7 @@ ${contents}
|
|
|
86138
86616
|
const keep = 100;
|
|
86139
86617
|
const entries = (await import_promises27.default.readdir(directory)).filter((name) => name.endsWith(".md")).sort();
|
|
86140
86618
|
for (const name of entries.slice(0, Math.max(0, entries.length - keep))) {
|
|
86141
|
-
await import_promises27.default.rm(
|
|
86619
|
+
await import_promises27.default.rm(import_node_path50.default.join(directory, name), { force: true });
|
|
86142
86620
|
}
|
|
86143
86621
|
}
|
|
86144
86622
|
let scheduleTimer;
|
|
@@ -86211,7 +86689,7 @@ ${contents}
|
|
|
86211
86689
|
async function handleSaveSchedule(schedule) {
|
|
86212
86690
|
try {
|
|
86213
86691
|
const schedules = await loadSchedules();
|
|
86214
|
-
const id = schedule.id.length > 0 ? schedule.id : (0,
|
|
86692
|
+
const id = schedule.id.length > 0 ? schedule.id : (0, import_node_crypto15.createHash)("sha256").update(`${schedule.name}:${String(Date.now())}`).digest("hex").slice(0, 12);
|
|
86215
86693
|
const armed = { ...schedule, id, nextRunAt: nextFireTime(schedule, Date.now()) };
|
|
86216
86694
|
await saveSchedules({ ...schedules, [id]: armed });
|
|
86217
86695
|
} catch (error51) {
|
|
@@ -86220,7 +86698,7 @@ ${contents}
|
|
|
86220
86698
|
}
|
|
86221
86699
|
async function createScheduleFromProposal(proposal) {
|
|
86222
86700
|
const schedules = await loadSchedules();
|
|
86223
|
-
const id = (0,
|
|
86701
|
+
const id = (0, import_node_crypto15.createHash)("sha256").update(`${proposal.name}:${String(Date.now())}`).digest("hex").slice(0, 12);
|
|
86224
86702
|
const schedule = {
|
|
86225
86703
|
id,
|
|
86226
86704
|
name: proposal.name,
|
|
@@ -86251,10 +86729,10 @@ ${contents}
|
|
|
86251
86729
|
}
|
|
86252
86730
|
const CLAIM_STALE_MS = 60 * 60 * 1e3;
|
|
86253
86731
|
async function claimSchedule(id) {
|
|
86254
|
-
const claimPath =
|
|
86732
|
+
const claimPath = import_node_path50.default.join(storageDir, "schedule-claims", `${id}.json`);
|
|
86255
86733
|
const mine = JSON.stringify({ pid: process.pid, at: Date.now() });
|
|
86256
86734
|
try {
|
|
86257
|
-
await import_promises27.default.mkdir(
|
|
86735
|
+
await import_promises27.default.mkdir(import_node_path50.default.dirname(claimPath), { recursive: true });
|
|
86258
86736
|
await import_promises27.default.writeFile(claimPath, mine, { encoding: "utf8", flag: "wx" });
|
|
86259
86737
|
return true;
|
|
86260
86738
|
} catch (error51) {
|
|
@@ -86279,7 +86757,7 @@ ${contents}
|
|
|
86279
86757
|
}
|
|
86280
86758
|
}
|
|
86281
86759
|
async function releaseSchedule(id) {
|
|
86282
|
-
await import_promises27.default.rm(
|
|
86760
|
+
await import_promises27.default.rm(import_node_path50.default.join(storageDir, "schedule-claims", `${id}.json`), { force: true }).catch(() => void 0);
|
|
86283
86761
|
}
|
|
86284
86762
|
async function runSchedule(id, reason) {
|
|
86285
86763
|
if (reason === "due" && !await claimSchedule(id))
|
|
@@ -86947,11 +87425,11 @@ function createShowDiagramTool() {
|
|
|
86947
87425
|
|
|
86948
87426
|
// ../../packages/core/dist/lsp/manager.js
|
|
86949
87427
|
var import_promises28 = __toESM(require("node:fs/promises"), 1);
|
|
86950
|
-
var
|
|
87428
|
+
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
86951
87429
|
|
|
86952
87430
|
// ../../packages/core/dist/lsp/catalog.js
|
|
86953
|
-
var
|
|
86954
|
-
var
|
|
87431
|
+
var import_node_fs12 = require("node:fs");
|
|
87432
|
+
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
86955
87433
|
var c = (command, ...args) => ({ command, args });
|
|
86956
87434
|
var LSP_LANGUAGES = [
|
|
86957
87435
|
{ id: "python", label: "Python", extensions: ["py", "pyi"], candidates: [c("pyright-langserver", "--stdio"), c("basedpyright-langserver", "--stdio"), c("pylsp"), c("jedi-language-server")] },
|
|
@@ -86999,17 +87477,17 @@ var LSP_LANGUAGES = [
|
|
|
86999
87477
|
{ id: "sql", label: "SQL", extensions: ["sql"], candidates: [c("sql-language-server", "up", "--method", "stdio")] }
|
|
87000
87478
|
];
|
|
87001
87479
|
function languageFor(file2) {
|
|
87002
|
-
const ext =
|
|
87480
|
+
const ext = import_node_path51.default.extname(file2).slice(1).toLowerCase();
|
|
87003
87481
|
return LSP_LANGUAGES.find((l) => l.extensions.includes(ext));
|
|
87004
87482
|
}
|
|
87005
87483
|
function languageIdFor(language, file2) {
|
|
87006
|
-
const ext =
|
|
87484
|
+
const ext = import_node_path51.default.extname(file2).slice(1).toLowerCase();
|
|
87007
87485
|
return language.languageIdFor?.(ext) ?? language.id;
|
|
87008
87486
|
}
|
|
87009
87487
|
var found = /* @__PURE__ */ new Map();
|
|
87010
87488
|
function findOnPath(command, env2 = process.env) {
|
|
87011
|
-
if (
|
|
87012
|
-
return (0,
|
|
87489
|
+
if (import_node_path51.default.isAbsolute(command))
|
|
87490
|
+
return (0, import_node_fs12.existsSync)(command) ? command : void 0;
|
|
87013
87491
|
if (env2 !== process.env)
|
|
87014
87492
|
return searchPath(command, env2);
|
|
87015
87493
|
const hit = found.get(command);
|
|
@@ -87020,12 +87498,12 @@ function findOnPath(command, env2 = process.env) {
|
|
|
87020
87498
|
return value;
|
|
87021
87499
|
}
|
|
87022
87500
|
function searchPath(command, env2) {
|
|
87023
|
-
const dirs = (env2.PATH ?? env2.Path ?? "").split(
|
|
87501
|
+
const dirs = (env2.PATH ?? env2.Path ?? "").split(import_node_path51.default.delimiter).filter((d) => d.length > 0);
|
|
87024
87502
|
const exts = process.platform === "win32" ? ["", ...(env2.PATHEXT ?? ".EXE;.CMD;.BAT").toLowerCase().split(";")] : [""];
|
|
87025
87503
|
for (const dir of dirs) {
|
|
87026
87504
|
for (const ext of exts) {
|
|
87027
|
-
const candidate =
|
|
87028
|
-
if ((0,
|
|
87505
|
+
const candidate = import_node_path51.default.join(dir, command + ext);
|
|
87506
|
+
if ((0, import_node_fs12.existsSync)(candidate) && (process.platform !== "win32" || ext !== "" || /\.(exe|cmd|bat)$/i.test(candidate)))
|
|
87029
87507
|
return candidate;
|
|
87030
87508
|
}
|
|
87031
87509
|
}
|
|
@@ -87256,7 +87734,7 @@ var LspManager = class {
|
|
|
87256
87734
|
return void 0;
|
|
87257
87735
|
const args = [...found2.candidate.args];
|
|
87258
87736
|
if (language.id === "java" && !args.includes("-data"))
|
|
87259
|
-
args.push("-data",
|
|
87737
|
+
args.push("-data", import_node_path52.default.join(this.storageDir, "jdtls-workspace"));
|
|
87260
87738
|
try {
|
|
87261
87739
|
client = new LspClient(found2.executable, args, this.root, this.log);
|
|
87262
87740
|
this.clients.set(language.id, client);
|
|
@@ -87277,7 +87755,7 @@ var LspManager = class {
|
|
|
87277
87755
|
this.failed.set(language.id, client.lastError ?? "stopped");
|
|
87278
87756
|
return void 0;
|
|
87279
87757
|
}
|
|
87280
|
-
return { server:
|
|
87758
|
+
return { server: import_node_path52.default.basename(client.executable).replace(/\.(exe|cmd|bat)$/i, ""), diagnostics: diagnostics ?? [] };
|
|
87281
87759
|
} catch (error51) {
|
|
87282
87760
|
this.failed.set(language.id, error51 instanceof Error ? error51.message : String(error51));
|
|
87283
87761
|
client.dispose();
|
|
@@ -89610,7 +90088,32 @@ Settings \u2192 Export source code saves the whole repository as a zip that buil
|
|
|
89610
90088
|
"fire code addon",
|
|
89611
90089
|
"addon for light code",
|
|
89612
90090
|
"light code addon",
|
|
89613
|
-
"addon tools"
|
|
90091
|
+
"addon tools",
|
|
90092
|
+
"linux",
|
|
90093
|
+
"linux machine",
|
|
90094
|
+
"linux server",
|
|
90095
|
+
"ssh",
|
|
90096
|
+
"putty",
|
|
90097
|
+
"plink",
|
|
90098
|
+
"pageant",
|
|
90099
|
+
"remote server",
|
|
90100
|
+
"connect to a server",
|
|
90101
|
+
"run a command on a server",
|
|
90102
|
+
"download a log",
|
|
90103
|
+
"jump host",
|
|
90104
|
+
"bastion",
|
|
90105
|
+
"host key",
|
|
90106
|
+
"addon tab",
|
|
90107
|
+
"linux tab",
|
|
90108
|
+
"add-ons tab",
|
|
90109
|
+
"enable addon",
|
|
90110
|
+
"disable addon",
|
|
90111
|
+
"linux tab missing",
|
|
90112
|
+
"ssh key",
|
|
90113
|
+
"set up ssh key",
|
|
90114
|
+
"key setup",
|
|
90115
|
+
"authorized_keys",
|
|
90116
|
+
"passwordless"
|
|
89614
90117
|
],
|
|
89615
90118
|
body: `
|
|
89616
90119
|
**An add-on is an npm package that runs an MCP server**, labelled in its \`package.json\`:
|
|
@@ -89627,11 +90130,12 @@ Settings \u2192 Export source code saves the whole repository as a zip that buil
|
|
|
89627
90130
|
\`registerTool\`, \`StdioServerTransport\`). \`examples/light-code-addon-hello\` in the source is a
|
|
89628
90131
|
complete one. Light Code, Fire Code, the Node host and the JetBrains plugin all use the same add-ons.
|
|
89629
90132
|
|
|
89630
|
-
**Install it** with \`npm i -g <package or folder>\`, then **Settings \u2192
|
|
89631
|
-
|
|
89632
|
-
|
|
89633
|
-
|
|
89634
|
-
|
|
90133
|
+
**Install it** with \`npm i -g <package or folder>\`, then open **Settings \u2192 Add-ons** (the puzzle
|
|
90134
|
+
piece). Light Code finds it by itself in npm's global folder - also where \`npm config set prefix\` moved
|
|
90135
|
+
it, and beside node.exe - and in any folders listed there (Browse\u2026 adds one). **Installed is not
|
|
90136
|
+
enabled**: press Enable, read the program it will run, and confirm. Its tools then appear as
|
|
90137
|
+
\`addon-<name>__<tool>\` and are asked about like every other tool. An add-on's server is not listed on
|
|
90138
|
+
the MCP tab, which keeps the servers you configured yourself.
|
|
89635
90139
|
|
|
89636
90140
|
**An update stays off until you enable the new version** - new code is looked at first. An add-on
|
|
89637
90141
|
that is no longer installed stays off and is listed so you can remove it. Enabling writes an ordinary
|
|
@@ -89641,6 +90145,30 @@ can never switch an add-on on. \`addons.folders\` is user-scope only.
|
|
|
89641
90145
|
|
|
89642
90146
|
**Add-ons run as you and can do anything you can.** Only install ones you trust. They run with the
|
|
89643
90147
|
editor's own Node inside VS Code, so no Node install is needed there; Fire Code uses its Node.
|
|
90148
|
+
|
|
90149
|
+
**An add-on can bring its own settings tab**, with its own icon - it appears in Settings only while
|
|
90150
|
+
the add-on is installed **and enabled**; disable it and the tab goes (what you entered is kept). The tab
|
|
90151
|
+
lists the tools the add-on gives the assistant, each with Ask first / Always allow / Never. The add-on describes the fields in \`package.json\`
|
|
90152
|
+
(\`lightCode.addon.settings\`: a title, its own fields, and a list such as "machines" with buttons like
|
|
90153
|
+
Test connection); Light Code draws the form. What you enter is kept in your settings, passwords in
|
|
90154
|
+
secret storage, and the add-on receives them when it starts - saving the tab restarts it.
|
|
90155
|
+
|
|
90156
|
+
**The Linux add-on** (\`npm i -g @chosengeneration/light-code-addon-linux\`): enable it on the
|
|
90157
|
+
**Add-ons** tab, then add machines on its **Linux** tab, each with a short label (\`prod-web-1\`), host, user
|
|
90158
|
+
and sign-in (Pageant - the default - the Windows OpenSSH agent, a key file, or a password), and press
|
|
90159
|
+
Test connection. The assistant can then list the machines, **run read-only commands** (\`df -h\`, \`tail\`,
|
|
90160
|
+
\`grep\`, \`ps\`, \`journalctl\`, \`systemctl status\`, \`docker ps\`... joined with \`|\`; nothing that writes,
|
|
90161
|
+
chains or never ends is sent) and **download a file** to read here. SSH runs inside Node - no plink, no
|
|
90162
|
+
ssh.exe, no new program - with one sign-in per machine reused, and a refused sign-in never retried, so
|
|
90163
|
+
it does not set off security monitoring or lock an account. Host keys are trusted the first time and
|
|
90164
|
+
checked after; a changed key is refused until you press Forget host key. A machine behind a bastion:
|
|
90165
|
+
add the bastion too and put its label in *Connect through*. Newer PuTTY keys (.ppk version 3): load
|
|
90166
|
+
them into Pageant, or export an OpenSSH key from PuTTYgen. **No key yet?** Choose Password, then press
|
|
90167
|
+
**Set up SSH key** on the machine: it makes one key for this PC (\`.ssh\\light-code_ed25519\`), adds its
|
|
90168
|
+
public half to the server's authorized_keys with the stored password, proves the key works, and switches
|
|
90169
|
+
the machine to it. It is a button only - the assistant cannot call it - and the tab lists the tools the
|
|
90170
|
+
assistant does get. A globally installed add-on is found by itself (npm's folder, your .npmrc prefix,
|
|
90171
|
+
or beside node.exe); the folder box is only for somewhere else.
|
|
89644
90172
|
`
|
|
89645
90173
|
},
|
|
89646
90174
|
{
|
|
@@ -90517,7 +91045,7 @@ function createLightCodeHelpTool() {
|
|
|
90517
91045
|
|
|
90518
91046
|
// ../../packages/core/dist/tools/listFiles.js
|
|
90519
91047
|
var import_node_child_process16 = require("node:child_process");
|
|
90520
|
-
var
|
|
91048
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
90521
91049
|
|
|
90522
91050
|
// ../../packages/core/dist/tools/ripgrepError.js
|
|
90523
91051
|
function ripgrepDidNotStart(error51) {
|
|
@@ -90598,7 +91126,7 @@ var listFilesTool = {
|
|
|
90598
91126
|
});
|
|
90599
91127
|
if (files.length === 0)
|
|
90600
91128
|
return noFiles;
|
|
90601
|
-
const listed = files.map((file2) => file2.split("/").join(
|
|
91129
|
+
const listed = files.map((file2) => file2.split("/").join(import_node_path53.default.sep)).join("\n");
|
|
90602
91130
|
return { content: truncated ? `${listed}
|
|
90603
91131
|
(listing cut short \u2014 list a narrower folder)` : listed };
|
|
90604
91132
|
}
|
|
@@ -90826,7 +91354,7 @@ var searchFilesTool = {
|
|
|
90826
91354
|
};
|
|
90827
91355
|
|
|
90828
91356
|
// ../../packages/core/dist/tools/writeToFile.js
|
|
90829
|
-
var
|
|
91357
|
+
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
90830
91358
|
var paramsSchema23 = external_exports.object({
|
|
90831
91359
|
path: external_exports.string().min(1).describe("Path to the file, relative to the workspace root."),
|
|
90832
91360
|
content: external_exports.string().describe("Full file content to write.")
|
|
@@ -90854,7 +91382,7 @@ var writeToFileTool = {
|
|
|
90854
91382
|
return { content: changed, isError: true, path: params3.path };
|
|
90855
91383
|
}
|
|
90856
91384
|
if (!exists2) {
|
|
90857
|
-
await context.fs.mkdir(
|
|
91385
|
+
await context.fs.mkdir(import_node_path54.default.dirname(resolved.realPath));
|
|
90858
91386
|
}
|
|
90859
91387
|
await context.fs.writeFile(resolved.realPath, params3.content);
|
|
90860
91388
|
await recordWrite(context, resolved.realPath);
|
|
@@ -90956,14 +91484,14 @@ function createDefaultToolRegistry() {
|
|
|
90956
91484
|
|
|
90957
91485
|
// ../../packages/core/dist/dataset/store.js
|
|
90958
91486
|
var import_promises29 = __toESM(require("node:fs/promises"), 1);
|
|
90959
|
-
var
|
|
91487
|
+
var import_node_path55 = __toESM(require("node:path"), 1);
|
|
90960
91488
|
var DatasetStore = class {
|
|
90961
91489
|
filePath;
|
|
90962
91490
|
statePath;
|
|
90963
91491
|
constructor(storageDir, datasetId) {
|
|
90964
91492
|
const safe = datasetId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
90965
|
-
this.filePath =
|
|
90966
|
-
this.statePath =
|
|
91493
|
+
this.filePath = import_node_path55.default.join(storageDir, "datasets", `${safe}.jsonl`);
|
|
91494
|
+
this.statePath = import_node_path55.default.join(storageDir, "datasets", `${safe}.state.json`);
|
|
90967
91495
|
}
|
|
90968
91496
|
/** Every record. A malformed line is skipped — one bad line costs one record, not the corpus. */
|
|
90969
91497
|
async load() {
|
|
@@ -90991,7 +91519,7 @@ var DatasetStore = class {
|
|
|
90991
91519
|
async append(records) {
|
|
90992
91520
|
if (records.length === 0)
|
|
90993
91521
|
return;
|
|
90994
|
-
await import_promises29.default.mkdir(
|
|
91522
|
+
await import_promises29.default.mkdir(import_node_path55.default.dirname(this.filePath), { recursive: true });
|
|
90995
91523
|
await import_promises29.default.writeFile(this.filePath, "", { flag: "a" });
|
|
90996
91524
|
const lines = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
90997
91525
|
await import_promises29.default.appendFile(this.filePath, `${lines}
|
|
@@ -90999,7 +91527,7 @@ var DatasetStore = class {
|
|
|
90999
91527
|
}
|
|
91000
91528
|
/** Rewrites with exactly these. Temp-and-rename, so an interrupted prune leaves the old file. */
|
|
91001
91529
|
async replace(records) {
|
|
91002
|
-
await import_promises29.default.mkdir(
|
|
91530
|
+
await import_promises29.default.mkdir(import_node_path55.default.dirname(this.filePath), { recursive: true });
|
|
91003
91531
|
const temporary = `${this.filePath}.tmp`;
|
|
91004
91532
|
const body = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
91005
91533
|
await import_promises29.default.writeFile(temporary, records.length === 0 ? "" : `${body}
|
|
@@ -91053,7 +91581,7 @@ var DatasetStore = class {
|
|
|
91053
91581
|
}
|
|
91054
91582
|
}
|
|
91055
91583
|
async recordSync(at) {
|
|
91056
|
-
await import_promises29.default.mkdir(
|
|
91584
|
+
await import_promises29.default.mkdir(import_node_path55.default.dirname(this.statePath), { recursive: true });
|
|
91057
91585
|
const temporary = `${this.statePath}.tmp`;
|
|
91058
91586
|
await import_promises29.default.writeFile(temporary, JSON.stringify({ lastSyncedAt: at }), "utf8");
|
|
91059
91587
|
await replaceFile(temporary, this.statePath);
|
|
@@ -91390,8 +91918,8 @@ That is a fault in the tool itself, or the source is unreachable from here. Fix
|
|
|
91390
91918
|
}
|
|
91391
91919
|
|
|
91392
91920
|
// ../../packages/core/dist/s3/sigv4.js
|
|
91393
|
-
var
|
|
91394
|
-
var EMPTY_PAYLOAD_SHA256 = (0,
|
|
91921
|
+
var import_node_crypto16 = require("node:crypto");
|
|
91922
|
+
var EMPTY_PAYLOAD_SHA256 = (0, import_node_crypto16.createHash)("sha256").update("").digest("hex");
|
|
91395
91923
|
function encodeSegment(segment) {
|
|
91396
91924
|
return encodeURIComponent(segment).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
91397
91925
|
}
|
|
@@ -91415,10 +91943,10 @@ function amzDate(now) {
|
|
|
91415
91943
|
return `${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z`;
|
|
91416
91944
|
}
|
|
91417
91945
|
function signingKey(secretAccessKey, date5, region, service) {
|
|
91418
|
-
const dateKey = (0,
|
|
91419
|
-
const regionKey = (0,
|
|
91420
|
-
const serviceKey = (0,
|
|
91421
|
-
return (0,
|
|
91946
|
+
const dateKey = (0, import_node_crypto16.createHmac)("sha256", `AWS4${secretAccessKey}`).update(date5).digest();
|
|
91947
|
+
const regionKey = (0, import_node_crypto16.createHmac)("sha256", dateKey).update(region).digest();
|
|
91948
|
+
const serviceKey = (0, import_node_crypto16.createHmac)("sha256", regionKey).update(service).digest();
|
|
91949
|
+
return (0, import_node_crypto16.createHmac)("sha256", serviceKey).update("aws4_request").digest();
|
|
91422
91950
|
}
|
|
91423
91951
|
function signRequest(input) {
|
|
91424
91952
|
const service = input.service ?? "s3";
|
|
@@ -91427,7 +91955,7 @@ function signRequest(input) {
|
|
|
91427
91955
|
const date5 = timestamp.slice(0, 8);
|
|
91428
91956
|
const url2 = new URL(input.url);
|
|
91429
91957
|
const body = input.body ?? Buffer.alloc(0);
|
|
91430
|
-
const payloadHash = (0,
|
|
91958
|
+
const payloadHash = (0, import_node_crypto16.createHash)("sha256").update(body).digest("hex");
|
|
91431
91959
|
const headers = {
|
|
91432
91960
|
...input.headers,
|
|
91433
91961
|
host: url2.host,
|
|
@@ -91451,9 +91979,9 @@ function signRequest(input) {
|
|
|
91451
91979
|
"AWS4-HMAC-SHA256",
|
|
91452
91980
|
timestamp,
|
|
91453
91981
|
scope,
|
|
91454
|
-
(0,
|
|
91982
|
+
(0, import_node_crypto16.createHash)("sha256").update(canonicalRequest).digest("hex")
|
|
91455
91983
|
].join("\n");
|
|
91456
|
-
const signature = (0,
|
|
91984
|
+
const signature = (0, import_node_crypto16.createHmac)("sha256", signingKey(input.secretAccessKey, date5, input.region, service)).update(stringToSign).digest("hex");
|
|
91457
91985
|
return {
|
|
91458
91986
|
headers: {
|
|
91459
91987
|
...headers,
|
|
@@ -91483,8 +92011,8 @@ var S3Client = class {
|
|
|
91483
92011
|
const host = inPath ? origin.host : `${bucket}.${origin.host}`;
|
|
91484
92012
|
const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
|
|
91485
92013
|
const prefix = inPath ? `${mount}/${bucket}` : mount;
|
|
91486
|
-
const
|
|
91487
|
-
const url2 = new URL(`${origin.protocol}//${host}${prefix}${
|
|
92014
|
+
const path61 = key2 === "" ? "" : `/${key2.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
|
|
92015
|
+
const url2 = new URL(`${origin.protocol}//${host}${prefix}${path61}`);
|
|
91488
92016
|
for (const [name, value] of Object.entries(call.query ?? {}))
|
|
91489
92017
|
url2.searchParams.set(name, value);
|
|
91490
92018
|
return url2.toString();
|
|
@@ -91974,15 +92502,15 @@ function createS3Tools(targets) {
|
|
|
91974
92502
|
}
|
|
91975
92503
|
|
|
91976
92504
|
// ../../packages/core/dist/s3/localFolder.js
|
|
91977
|
-
var
|
|
92505
|
+
var import_node_crypto17 = require("node:crypto");
|
|
91978
92506
|
function mirrorFolder(options) {
|
|
91979
92507
|
const connection = safeSegment(options.connectionId);
|
|
91980
|
-
const digest = (0,
|
|
92508
|
+
const digest = (0, import_node_crypto17.createHash)("sha256").update((options.prefix ?? "").trim().toLowerCase()).digest("hex").slice(0, 8);
|
|
91981
92509
|
return join2(options.storageDir, "s3", connection, `${options.kind}-${digest}`);
|
|
91982
92510
|
}
|
|
91983
92511
|
function safeSegment(id) {
|
|
91984
92512
|
const cleaned = id.replace(/[^a-zA-Z0-9._-]/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 40);
|
|
91985
|
-
const suffix = (0,
|
|
92513
|
+
const suffix = (0, import_node_crypto17.createHash)("sha256").update(id).digest("hex").slice(0, 6);
|
|
91986
92514
|
return `${cleaned === "" ? "connection" : cleaned}-${suffix}`;
|
|
91987
92515
|
}
|
|
91988
92516
|
function join2(...parts) {
|
|
@@ -92069,13 +92597,13 @@ function reachableOrigins(hosts, extra = []) {
|
|
|
92069
92597
|
}
|
|
92070
92598
|
|
|
92071
92599
|
// src/identity.ts
|
|
92072
|
-
var
|
|
92600
|
+
var import_node_crypto18 = __toESM(require("node:crypto"), 1);
|
|
92073
92601
|
var SingleUserIdentity = class _SingleUserIdentity {
|
|
92074
92602
|
describe;
|
|
92075
92603
|
static PRINCIPAL = { id: "local", displayName: "Local user" };
|
|
92076
92604
|
principal;
|
|
92077
92605
|
/** Long-lived, minted per server run, only ever sent in an `Authorization` header. */
|
|
92078
|
-
sessionToken =
|
|
92606
|
+
sessionToken = import_node_crypto18.default.randomBytes(32).toString("base64url");
|
|
92079
92607
|
/**
|
|
92080
92608
|
* Single-use and short-lived, because it travels in the launch URL's fragment where it
|
|
92081
92609
|
* can end up in shell history or a terminal scrollback (§14).
|
|
@@ -92085,7 +92613,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
92085
92613
|
* raises it, and what that costs is stated where it is set: a longer window is a longer time in
|
|
92086
92614
|
* which somebody reading that scrollback can use it before you do.
|
|
92087
92615
|
*/
|
|
92088
|
-
handoffToken =
|
|
92616
|
+
handoffToken = import_node_crypto18.default.randomBytes(32).toString("base64url");
|
|
92089
92617
|
handoffExpiresAt;
|
|
92090
92618
|
handoffSeconds;
|
|
92091
92619
|
/**
|
|
@@ -92115,7 +92643,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
92115
92643
|
* which is the same person it was printed to in the first place.
|
|
92116
92644
|
*/
|
|
92117
92645
|
remintHandoff() {
|
|
92118
|
-
this.handoffToken =
|
|
92646
|
+
this.handoffToken = import_node_crypto18.default.randomBytes(32).toString("base64url");
|
|
92119
92647
|
this.handoffExpiresAt = Date.now() + this.handoffSeconds * 1e3;
|
|
92120
92648
|
return this.handoffToken;
|
|
92121
92649
|
}
|
|
@@ -92154,10 +92682,10 @@ function timingSafeEquals(a, b) {
|
|
|
92154
92682
|
const left = Buffer.from(a);
|
|
92155
92683
|
const right = Buffer.from(b);
|
|
92156
92684
|
if (left.length !== right.length) return false;
|
|
92157
|
-
return
|
|
92685
|
+
return import_node_crypto18.default.timingSafeEqual(left, right);
|
|
92158
92686
|
}
|
|
92159
92687
|
function storageKeyFor(principal) {
|
|
92160
|
-
return
|
|
92688
|
+
return import_node_crypto18.default.createHash("sha256").update(principal.id).digest("hex").slice(0, 32);
|
|
92161
92689
|
}
|
|
92162
92690
|
var OpenIdentity = class _OpenIdentity {
|
|
92163
92691
|
describe = "single user, no token (--no-token)";
|
|
@@ -92426,22 +92954,22 @@ async function readJsonBody(request, maxBytes = 32 * 1024 * 1024) {
|
|
|
92426
92954
|
|
|
92427
92955
|
// src/fileSecretStore.ts
|
|
92428
92956
|
var import_promises30 = __toESM(require("node:fs/promises"), 1);
|
|
92429
|
-
var
|
|
92957
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
92430
92958
|
|
|
92431
92959
|
// src/vaultCrypto.ts
|
|
92432
|
-
var
|
|
92960
|
+
var import_node_crypto19 = require("node:crypto");
|
|
92433
92961
|
function isVaultEnvelope(value) {
|
|
92434
92962
|
const v = value;
|
|
92435
92963
|
return typeof v === "object" && v !== null && v.sunVault === 1 && typeof v.iv === "string" && typeof v.tag === "string" && typeof v.data === "string";
|
|
92436
92964
|
}
|
|
92437
92965
|
function sealSecrets(secrets, key2) {
|
|
92438
|
-
const iv = (0,
|
|
92439
|
-
const cipher = (0,
|
|
92966
|
+
const iv = (0, import_node_crypto19.randomBytes)(12);
|
|
92967
|
+
const cipher = (0, import_node_crypto19.createCipheriv)("aes-256-gcm", key2, iv);
|
|
92440
92968
|
const data = Buffer.concat([cipher.update(JSON.stringify(secrets), "utf8"), cipher.final()]);
|
|
92441
92969
|
return { sunVault: 1, iv: iv.toString("base64"), tag: cipher.getAuthTag().toString("base64"), data: data.toString("base64") };
|
|
92442
92970
|
}
|
|
92443
92971
|
function openSecrets(envelope, key2) {
|
|
92444
|
-
const decipher = (0,
|
|
92972
|
+
const decipher = (0, import_node_crypto19.createDecipheriv)("aes-256-gcm", key2, Buffer.from(envelope.iv, "base64"));
|
|
92445
92973
|
decipher.setAuthTag(Buffer.from(envelope.tag, "base64"));
|
|
92446
92974
|
const plain = Buffer.concat([decipher.update(Buffer.from(envelope.data, "base64")), decipher.final()]);
|
|
92447
92975
|
const parsed = JSON.parse(plain.toString("utf8"));
|
|
@@ -92524,7 +93052,7 @@ var FileSecretStore = class {
|
|
|
92524
93052
|
);
|
|
92525
93053
|
}
|
|
92526
93054
|
mutate(secrets);
|
|
92527
|
-
await import_promises30.default.mkdir(
|
|
93055
|
+
await import_promises30.default.mkdir(import_node_path56.default.dirname(this.filePath), { recursive: true });
|
|
92528
93056
|
const temp = `${this.filePath}.${process.pid}.tmp`;
|
|
92529
93057
|
const body = this.key === void 0 ? secrets : sealSecrets(secrets, this.key);
|
|
92530
93058
|
await import_promises30.default.writeFile(temp, JSON.stringify(body, null, 2), { encoding: "utf8", mode: 384 });
|
|
@@ -92559,9 +93087,9 @@ var FileSecretStore = class {
|
|
|
92559
93087
|
};
|
|
92560
93088
|
|
|
92561
93089
|
// src/reviewQueue.ts
|
|
92562
|
-
var
|
|
93090
|
+
var import_node_crypto20 = __toESM(require("node:crypto"), 1);
|
|
92563
93091
|
var import_promises31 = __toESM(require("node:fs/promises"), 1);
|
|
92564
|
-
var
|
|
93092
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
92565
93093
|
var ReviewQueue = class {
|
|
92566
93094
|
constructor(filePath) {
|
|
92567
93095
|
this.filePath = filePath;
|
|
@@ -92580,7 +93108,7 @@ var ReviewQueue = class {
|
|
|
92580
93108
|
}
|
|
92581
93109
|
async persist(items) {
|
|
92582
93110
|
this.cache = items;
|
|
92583
|
-
await import_promises31.default.mkdir(
|
|
93111
|
+
await import_promises31.default.mkdir(import_node_path57.default.dirname(this.filePath), { recursive: true });
|
|
92584
93112
|
const temporary = `${this.filePath}.tmp`;
|
|
92585
93113
|
await import_promises31.default.writeFile(temporary, JSON.stringify(items, null, 2), { encoding: "utf8", mode: 384 });
|
|
92586
93114
|
await replaceFile(temporary, this.filePath);
|
|
@@ -92598,7 +93126,7 @@ var ReviewQueue = class {
|
|
|
92598
93126
|
);
|
|
92599
93127
|
const queued = {
|
|
92600
93128
|
...request,
|
|
92601
|
-
id:
|
|
93129
|
+
id: import_node_crypto20.default.randomUUID(),
|
|
92602
93130
|
submittedAt: Date.now(),
|
|
92603
93131
|
status: "pending"
|
|
92604
93132
|
};
|
|
@@ -92821,8 +93349,8 @@ var RoutedSecretStore = class {
|
|
|
92821
93349
|
|
|
92822
93350
|
// src/userVariables.ts
|
|
92823
93351
|
var import_promises32 = __toESM(require("node:fs/promises"), 1);
|
|
92824
|
-
var
|
|
92825
|
-
var
|
|
93352
|
+
var import_node_fs13 = require("node:fs");
|
|
93353
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
92826
93354
|
var UserVariableStore = class {
|
|
92827
93355
|
constructor(filePath) {
|
|
92828
93356
|
this.filePath = filePath;
|
|
@@ -92837,7 +93365,7 @@ var UserVariableStore = class {
|
|
|
92837
93365
|
}
|
|
92838
93366
|
async save(variables) {
|
|
92839
93367
|
const parsed = sessionVariablesSchema.parse(variables);
|
|
92840
|
-
await import_promises32.default.mkdir(
|
|
93368
|
+
await import_promises32.default.mkdir(import_node_path58.default.dirname(this.filePath), { recursive: true });
|
|
92841
93369
|
const temporary = `${this.filePath}.tmp`;
|
|
92842
93370
|
await import_promises32.default.writeFile(temporary, JSON.stringify({ variables: parsed }, null, 2), {
|
|
92843
93371
|
encoding: "utf8",
|
|
@@ -92848,14 +93376,14 @@ var UserVariableStore = class {
|
|
|
92848
93376
|
}
|
|
92849
93377
|
};
|
|
92850
93378
|
function userVariableStoreFor(dataDir, principal) {
|
|
92851
|
-
return new UserVariableStore(userVariablesPath(
|
|
93379
|
+
return new UserVariableStore(userVariablesPath(import_node_path58.default.join(dataDir, "users", storageKeyFor(principal))));
|
|
92852
93380
|
}
|
|
92853
93381
|
function userVariablesPath(userDir) {
|
|
92854
|
-
return
|
|
93382
|
+
return import_node_path58.default.join(userDir, "variables.json");
|
|
92855
93383
|
}
|
|
92856
93384
|
function readVariablesFile(filePath) {
|
|
92857
93385
|
try {
|
|
92858
|
-
const raw = JSON.parse((0,
|
|
93386
|
+
const raw = JSON.parse((0, import_node_fs13.readFileSync)(filePath, "utf8"));
|
|
92859
93387
|
const parsed = sessionVariablesSchema.safeParse(raw["variables"]);
|
|
92860
93388
|
return parsed.success ? parsed.data : [];
|
|
92861
93389
|
} catch {
|
|
@@ -92879,13 +93407,13 @@ function hostedUser(env2 = process.env) {
|
|
|
92879
93407
|
}
|
|
92880
93408
|
|
|
92881
93409
|
// src/session.ts
|
|
92882
|
-
var
|
|
93410
|
+
var import_node_fs14 = require("node:fs");
|
|
92883
93411
|
var import_promises33 = __toESM(require("node:fs/promises"), 1);
|
|
92884
|
-
var
|
|
93412
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
92885
93413
|
|
|
92886
93414
|
// src/credentialTool.ts
|
|
92887
93415
|
var import_node_child_process18 = require("node:child_process");
|
|
92888
|
-
var
|
|
93416
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
92889
93417
|
var CREDENTIAL_PREFIX2 = "tool:";
|
|
92890
93418
|
var WRAPPER = [
|
|
92891
93419
|
"import importlib.util, json, sys",
|
|
@@ -92905,7 +93433,7 @@ async function fetchCredential(options, reference) {
|
|
|
92905
93433
|
if (name.length === 0) return { problem: "A credential reference needs a name: tool:<name>." };
|
|
92906
93434
|
const budget = options.timeoutMs ?? 3e4;
|
|
92907
93435
|
const run3 = await new Promise((resolve) => {
|
|
92908
|
-
const child = (0, import_node_child_process18.spawn)(options.interpreter, ["-c", WRAPPER,
|
|
93436
|
+
const child = (0, import_node_child_process18.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path59.default.resolve(options.file), name], {
|
|
92909
93437
|
windowsHide: true,
|
|
92910
93438
|
// The environment this was started in, as with the identity function: the libraries that
|
|
92911
93439
|
// hold credentials are configured through it, and nothing here is model-authored.
|
|
@@ -93101,7 +93629,7 @@ var FileConfigStore = class {
|
|
|
93101
93629
|
const filePath = this.pathFor(scope);
|
|
93102
93630
|
if (filePath === void 0)
|
|
93103
93631
|
throw new Error(`Cannot write ${scope} config: no workspace is open`);
|
|
93104
|
-
await import_promises33.default.mkdir(
|
|
93632
|
+
await import_promises33.default.mkdir(import_node_path60.default.dirname(filePath), { recursive: true });
|
|
93105
93633
|
const temporary = `${filePath}.${process.pid.toString(36)}.tmp`;
|
|
93106
93634
|
await import_promises33.default.writeFile(temporary, contents, { encoding: "utf8", mode: 384 });
|
|
93107
93635
|
await replaceFile(temporary, filePath);
|
|
@@ -93138,8 +93666,8 @@ var FileConfigStore = class {
|
|
|
93138
93666
|
};
|
|
93139
93667
|
let watcher;
|
|
93140
93668
|
try {
|
|
93141
|
-
watcher = (0,
|
|
93142
|
-
if (filename ===
|
|
93669
|
+
watcher = (0, import_node_fs14.watch)(import_node_path60.default.dirname(filePath), (_event, filename) => {
|
|
93670
|
+
if (filename === import_node_path60.default.basename(filePath)) onChange();
|
|
93143
93671
|
});
|
|
93144
93672
|
} catch {
|
|
93145
93673
|
}
|
|
@@ -93167,7 +93695,7 @@ var FileWorkspaceState = class {
|
|
|
93167
93695
|
async set(key2, value) {
|
|
93168
93696
|
if (value === void 0) delete this.values[key2];
|
|
93169
93697
|
else this.values[key2] = value;
|
|
93170
|
-
await import_promises33.default.mkdir(
|
|
93698
|
+
await import_promises33.default.mkdir(import_node_path60.default.dirname(this.filePath), { recursive: true });
|
|
93171
93699
|
await import_promises33.default.writeFile(this.filePath, JSON.stringify(this.values, null, 2), {
|
|
93172
93700
|
encoding: "utf8",
|
|
93173
93701
|
mode: 384
|
|
@@ -93216,7 +93744,7 @@ function createBrowserUi(workspaceRoot, post, fastFs) {
|
|
|
93216
93744
|
openFile: async (filePath) => {
|
|
93217
93745
|
try {
|
|
93218
93746
|
post(
|
|
93219
|
-
[`[info] ${
|
|
93747
|
+
[`[info] ${import_node_path60.default.basename(filePath)}`, "", await import_promises33.default.readFile(filePath, "utf8")].join("\n")
|
|
93220
93748
|
);
|
|
93221
93749
|
} catch (error51) {
|
|
93222
93750
|
post(`[warning] Could not read ${filePath}: ${String(error51)}`);
|
|
@@ -93258,7 +93786,7 @@ function createBrowserUi(workspaceRoot, post, fastFs) {
|
|
|
93258
93786
|
for (const entry of entries) {
|
|
93259
93787
|
if (found2.length >= limit) return;
|
|
93260
93788
|
if (entry.name.startsWith(".") && entry.name !== ".env") continue;
|
|
93261
|
-
const full =
|
|
93789
|
+
const full = import_node_path60.default.join(dir, entry.name);
|
|
93262
93790
|
if (entry.isDirectory()) {
|
|
93263
93791
|
if (!skip.has(entry.name)) await walk(full, level + 1);
|
|
93264
93792
|
} else if (depth !== void 0 && level !== depth) {
|
|
@@ -93294,11 +93822,11 @@ var SHARED_COLLECTIONS = [
|
|
|
93294
93822
|
{ key: "mcpServers" }
|
|
93295
93823
|
];
|
|
93296
93824
|
async function createSession(options) {
|
|
93297
|
-
const userDir =
|
|
93825
|
+
const userDir = import_node_path60.default.join(options.dataDir, "users", storageKeyFor(options.principal));
|
|
93298
93826
|
await import_promises33.default.mkdir(userDir, { recursive: true, mode: 448 });
|
|
93299
93827
|
const variableStore = new UserVariableStore(userVariablesPath(userDir));
|
|
93300
93828
|
const userVariables = () => variableStore.read();
|
|
93301
|
-
const workspaceState = new FileWorkspaceState(
|
|
93829
|
+
const workspaceState = new FileWorkspaceState(import_node_path60.default.join(userDir, "workspace-state.json"));
|
|
93302
93830
|
await workspaceState.load();
|
|
93303
93831
|
const services = {
|
|
93304
93832
|
/*
|
|
@@ -93386,16 +93914,16 @@ async function createSession(options) {
|
|
|
93386
93914
|
*/
|
|
93387
93915
|
secrets: new CredentialPointerStore(
|
|
93388
93916
|
withCredentialTool(
|
|
93389
|
-
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ??
|
|
93390
|
-
new FileSecretStore(options.secretsFile ??
|
|
93917
|
+
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ?? import_node_path60.default.join(userDir, "secrets.json"), options.secretsKey) : new RoutedSecretStore(
|
|
93918
|
+
new FileSecretStore(options.secretsFile ?? import_node_path60.default.join(userDir, "secrets.json"), options.secretsKey),
|
|
93391
93919
|
options.sharedSecrets
|
|
93392
93920
|
),
|
|
93393
93921
|
options
|
|
93394
93922
|
)
|
|
93395
93923
|
),
|
|
93396
93924
|
configStore: withSharedEntries(
|
|
93397
|
-
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ??
|
|
93398
|
-
new FileConfigStore(options.configFile ??
|
|
93925
|
+
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ?? import_node_path60.default.join(userDir, "config.json"), options.workspaceRoot) : new SharedProfileConfigStore(
|
|
93926
|
+
new FileConfigStore(options.configFile ?? import_node_path60.default.join(userDir, "config.json"), options.workspaceRoot),
|
|
93399
93927
|
options.sharedProfiles
|
|
93400
93928
|
),
|
|
93401
93929
|
options
|
|
@@ -93513,8 +94041,8 @@ async function startServer(options) {
|
|
|
93513
94041
|
));
|
|
93514
94042
|
const roles = options.roles ?? SINGLE_USER_POLICY;
|
|
93515
94043
|
const sharedStore = options.sharedConfig;
|
|
93516
|
-
const sharedSecretStore = new FileSecretStore(
|
|
93517
|
-
const reviews = new ReviewQueue(
|
|
94044
|
+
const sharedSecretStore = new FileSecretStore(import_node_path61.default.join(options.dataDir, "shared-secrets.json"));
|
|
94045
|
+
const reviews = new ReviewQueue(import_node_path61.default.join(options.dataDir, "reviews.json"));
|
|
93518
94046
|
let sharedCache = {
|
|
93519
94047
|
variables: [],
|
|
93520
94048
|
adminIds: [],
|
|
@@ -93890,14 +94418,14 @@ async function startServer(options) {
|
|
|
93890
94418
|
return "No workspace is open, so there is nowhere to write it.";
|
|
93891
94419
|
try {
|
|
93892
94420
|
if (item.kind === "skill") {
|
|
93893
|
-
const dir2 =
|
|
94421
|
+
const dir2 = import_node_path61.default.join(options.workspaceRoot, ".lightcode", "skills");
|
|
93894
94422
|
await import_promises34.default.mkdir(dir2, { recursive: true });
|
|
93895
|
-
await import_promises34.default.writeFile(
|
|
94423
|
+
await import_promises34.default.writeFile(import_node_path61.default.join(dir2, `${item.name}.md`), item.content, "utf8");
|
|
93896
94424
|
return void 0;
|
|
93897
94425
|
}
|
|
93898
|
-
const dir =
|
|
94426
|
+
const dir = import_node_path61.default.join(options.workspaceRoot, ".lightcode", "tools");
|
|
93899
94427
|
await import_promises34.default.mkdir(dir, { recursive: true });
|
|
93900
|
-
await import_promises34.default.writeFile(
|
|
94428
|
+
await import_promises34.default.writeFile(import_node_path61.default.join(dir, `${item.name}.py`), item.content, "utf8");
|
|
93901
94429
|
return void 0;
|
|
93902
94430
|
} catch (error51) {
|
|
93903
94431
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -93936,7 +94464,7 @@ async function startServer(options) {
|
|
|
93936
94464
|
connection.transport.post({ type: "credentials", credentials: await readCredentials() });
|
|
93937
94465
|
}
|
|
93938
94466
|
if (options.credentialsFile !== void 0) {
|
|
93939
|
-
(0,
|
|
94467
|
+
(0, import_node_fs15.watchFile)(options.credentialsFile, { interval: 1500 }, () => {
|
|
93940
94468
|
for (const connection of connections.values()) void postCredentials(connection);
|
|
93941
94469
|
});
|
|
93942
94470
|
}
|
|
@@ -94046,7 +94574,7 @@ async function startServer(options) {
|
|
|
94046
94574
|
return;
|
|
94047
94575
|
}
|
|
94048
94576
|
response.writeHead(200, {
|
|
94049
|
-
"Content-Type": CONTENT_TYPES2[
|
|
94577
|
+
"Content-Type": CONTENT_TYPES2[import_node_path61.default.extname(asset)] ?? "application/octet-stream",
|
|
94050
94578
|
...securityHeaders()
|
|
94051
94579
|
});
|
|
94052
94580
|
response.end(body);
|