@chosengeneration/light-code 0.171.0 → 0.174.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 +1040 -536
- package/dist/server.cjs +990 -494
- 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 path64 = 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 (path64 && !path64.startsWith("/")) {
|
|
502
|
+
path64 = `/${path64}`;
|
|
503
503
|
}
|
|
504
|
-
url2 = new URL(origin +
|
|
504
|
+
url2 = new URL(origin + path64);
|
|
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(path64) {
|
|
2119
|
+
if (typeof path64 !== "string") {
|
|
2120
2120
|
return "";
|
|
2121
2121
|
}
|
|
2122
|
-
for (var i =
|
|
2123
|
-
switch (
|
|
2122
|
+
for (var i = path64.length - 1; i >= 0; --i) {
|
|
2123
|
+
switch (path64.charCodeAt(i)) {
|
|
2124
2124
|
case 47:
|
|
2125
2125
|
// '/'
|
|
2126
2126
|
case 92:
|
|
2127
|
-
|
|
2128
|
-
return
|
|
2127
|
+
path64 = path64.slice(i + 1);
|
|
2128
|
+
return path64 === ".." || path64 === "." ? "" : path64;
|
|
2129
2129
|
}
|
|
2130
2130
|
}
|
|
2131
|
-
return
|
|
2131
|
+
return path64 === ".." || path64 === "." ? "" : path64;
|
|
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: path64,
|
|
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 path64 !== "string") {
|
|
5176
5176
|
throw new InvalidArgumentError("path must be a string");
|
|
5177
|
-
} else if (
|
|
5177
|
+
} else if (path64[0] !== "/" && !(path64.startsWith("http://") || path64.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(path64) !== 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(path64, query) : path64;
|
|
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 path64 = 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 = path64;
|
|
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: path64, 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} ${path64} 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: path64, 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] = path64;
|
|
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(path64) {
|
|
9889
|
+
if (typeof path64 !== "string") {
|
|
9890
|
+
return path64;
|
|
9891
9891
|
}
|
|
9892
|
-
const pathSegments =
|
|
9892
|
+
const pathSegments = path64.split("?");
|
|
9893
9893
|
if (pathSegments.length !== 2) {
|
|
9894
|
-
return
|
|
9894
|
+
return path64;
|
|
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: path64, method, body, headers }) {
|
|
9901
|
+
const pathMatch = matchValue(mockDispatch2.path, path64);
|
|
9902
9902
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
9903
9903
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
9904
9904
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -9916,7 +9916,7 @@ var require_mock_utils = __commonJS({
|
|
|
9916
9916
|
function getMockDispatch(mockDispatches, key3) {
|
|
9917
9917
|
const basePath = key3.query ? buildURL(key3.path, key3.query) : key3.path;
|
|
9918
9918
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
9919
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
9919
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path64 }) => matchValue(safeUrl(path64), 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: path64, method, body, headers, query } = opts;
|
|
9957
9957
|
return {
|
|
9958
|
-
path:
|
|
9958
|
+
path: path64,
|
|
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: path64, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
10408
10408
|
Method: method,
|
|
10409
10409
|
Origin: origin,
|
|
10410
|
-
Path:
|
|
10410
|
+
Path: path64,
|
|
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(path64) {
|
|
15031
|
+
for (const char of path64) {
|
|
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 path64 = opts.path;
|
|
16712
16712
|
if (!opts.path.startsWith("/")) {
|
|
16713
|
-
|
|
16713
|
+
path64 = `/${path64}`;
|
|
16714
16714
|
}
|
|
16715
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
16715
|
+
url2 = new URL(util.parseOrigin(url2).origin + path64);
|
|
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(path64) {
|
|
19987
|
+
let input = path64;
|
|
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 [path64, query] = wsComponent.resourceName.split("?");
|
|
20240
|
+
wsComponent.path = path64 && path64 !== "/" ? path64 : 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 fs43 = require("fs");
|
|
23658
|
-
function checkPathExt(
|
|
23658
|
+
function checkPathExt(path64, 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 && path64.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, path64, options) {
|
|
23676
23676
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
23677
23677
|
return false;
|
|
23678
23678
|
}
|
|
23679
|
-
return checkPathExt(
|
|
23679
|
+
return checkPathExt(path64, options);
|
|
23680
23680
|
}
|
|
23681
|
-
function isexe(
|
|
23682
|
-
fs43.stat(
|
|
23683
|
-
cb(er, er ? false : checkStat(stat,
|
|
23681
|
+
function isexe(path64, options, cb) {
|
|
23682
|
+
fs43.stat(path64, function(er, stat) {
|
|
23683
|
+
cb(er, er ? false : checkStat(stat, path64, options));
|
|
23684
23684
|
});
|
|
23685
23685
|
}
|
|
23686
|
-
function sync(
|
|
23687
|
-
return checkStat(fs43.statSync(
|
|
23686
|
+
function sync(path64, options) {
|
|
23687
|
+
return checkStat(fs43.statSync(path64), path64, 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 fs43 = require("fs");
|
|
23698
|
-
function isexe(
|
|
23699
|
-
fs43.stat(
|
|
23698
|
+
function isexe(path64, options, cb) {
|
|
23699
|
+
fs43.stat(path64, function(er, stat) {
|
|
23700
23700
|
cb(er, er ? false : checkStat(stat, options));
|
|
23701
23701
|
});
|
|
23702
23702
|
}
|
|
23703
|
-
function sync(
|
|
23704
|
-
return checkStat(fs43.statSync(
|
|
23703
|
+
function sync(path64, options) {
|
|
23704
|
+
return checkStat(fs43.statSync(path64), 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(path64, 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(path64, 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(path64, 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(path64, options) {
|
|
23767
23767
|
try {
|
|
23768
|
-
return core.sync(
|
|
23768
|
+
return core.sync(path64, 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 path64 = 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 = path64.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 = path64.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 path64 = 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 ? path64.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 = path64.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 [path64, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
23979
|
+
const binary = path64.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 path64 = 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 = path64.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(" ");
|
|
@@ -24260,7 +24260,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
24260
24260
|
var import_promises36 = __toESM(require("node:fs/promises"), 1);
|
|
24261
24261
|
var import_node_fs16 = require("node:fs");
|
|
24262
24262
|
var import_node_http = require("node:http");
|
|
24263
|
-
var
|
|
24263
|
+
var import_node_path64 = __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, path64) {
|
|
25425
|
+
if (!path64)
|
|
25426
25426
|
return obj;
|
|
25427
|
-
return
|
|
25427
|
+
return path64.reduce((acc, key3) => acc?.[key3], 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(path64, 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(path64);
|
|
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, path64 = []) => {
|
|
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 }, [...path64, ...issue2.path]));
|
|
25991
25991
|
} else if (issue2.code === "invalid_key") {
|
|
25992
|
-
processError({ issues: issue2.issues }, [...
|
|
25992
|
+
processError({ issues: issue2.issues }, [...path64, ...issue2.path]);
|
|
25993
25993
|
} else if (issue2.code === "invalid_element") {
|
|
25994
|
-
processError({ issues: issue2.issues }, [...
|
|
25994
|
+
processError({ issues: issue2.issues }, [...path64, ...issue2.path]);
|
|
25995
25995
|
} else {
|
|
25996
|
-
const fullpath = [...
|
|
25996
|
+
const fullpath = [...path64, ...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, path64 = []) => {
|
|
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 }, [...path64, ...issue2.path]));
|
|
26028
26028
|
} else if (issue2.code === "invalid_key") {
|
|
26029
|
-
processError({ issues: issue2.issues }, [...
|
|
26029
|
+
processError({ issues: issue2.issues }, [...path64, ...issue2.path]);
|
|
26030
26030
|
} else if (issue2.code === "invalid_element") {
|
|
26031
|
-
processError({ issues: issue2.issues }, [...
|
|
26031
|
+
processError({ issues: issue2.issues }, [...path64, ...issue2.path]);
|
|
26032
26032
|
} else {
|
|
26033
|
-
const fullpath = [...
|
|
26033
|
+
const fullpath = [...path64, ...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 path64 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
26066
|
+
for (const seg of path64) {
|
|
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 path64 = ref.slice(1).split("/").filter(Boolean);
|
|
38759
|
+
if (path64.length === 0) {
|
|
38760
38760
|
return ctx.rootSchema;
|
|
38761
38761
|
}
|
|
38762
38762
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
38763
|
-
if (
|
|
38764
|
-
const key3 =
|
|
38763
|
+
if (path64[0] === defsKey) {
|
|
38764
|
+
const key3 = path64[1];
|
|
38765
38765
|
if (!key3 || !ctx.defs[key3]) {
|
|
38766
38766
|
throw new Error(`Reference not found: ${ref}`);
|
|
38767
38767
|
}
|
|
@@ -43203,6 +43203,9 @@ var OpenAIProvider = class {
|
|
|
43203
43203
|
body.tools = toOpenAITools(options.tools);
|
|
43204
43204
|
body.tool_choice = "auto";
|
|
43205
43205
|
}
|
|
43206
|
+
const usageKey = this.profile.baseUrl.replace(/\/+$/, "");
|
|
43207
|
+
if (!NO_STREAM_USAGE.has(usageKey))
|
|
43208
|
+
body.stream_options = { include_usage: true };
|
|
43206
43209
|
if (this.profile.temperature !== void 0)
|
|
43207
43210
|
body.temperature = this.profile.temperature;
|
|
43208
43211
|
if (this.profile.topP !== void 0)
|
|
@@ -43212,6 +43215,17 @@ var OpenAIProvider = class {
|
|
|
43212
43215
|
try {
|
|
43213
43216
|
await this.auth.ensureTokenForStream?.();
|
|
43214
43217
|
response = await this.send(url2, body, options.signal);
|
|
43218
|
+
if (response.status >= 400 && response.status < 500 && response.status !== 401 && body.stream_options !== void 0) {
|
|
43219
|
+
const text2 = await response.text().catch(() => "");
|
|
43220
|
+
if (/stream_options|include_usage/i.test(text2)) {
|
|
43221
|
+
NO_STREAM_USAGE.add(usageKey);
|
|
43222
|
+
delete body.stream_options;
|
|
43223
|
+
response = await this.send(url2, body, options.signal);
|
|
43224
|
+
} else {
|
|
43225
|
+
yield { type: "error", error: `Request to ${url2} failed with HTTP ${response.status}${text2 ? `: ${text2.slice(0, 500)}` : ""}` };
|
|
43226
|
+
return;
|
|
43227
|
+
}
|
|
43228
|
+
}
|
|
43215
43229
|
if (response.status === 401 && this.auth.onUnauthorized !== void 0) {
|
|
43216
43230
|
this.logger?.debug("401 received; asking the auth strategy to refresh once");
|
|
43217
43231
|
if (await this.auth.onUnauthorized()) {
|
|
@@ -43252,6 +43266,20 @@ var OpenAIProvider = class {
|
|
|
43252
43266
|
return this.http.request(url2, request);
|
|
43253
43267
|
}
|
|
43254
43268
|
};
|
|
43269
|
+
var NO_STREAM_USAGE = /* @__PURE__ */ new Set();
|
|
43270
|
+
function usageFrom(parsed) {
|
|
43271
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
43272
|
+
return void 0;
|
|
43273
|
+
const usage = parsed.usage;
|
|
43274
|
+
if (usage === void 0 || usage === null || typeof usage.prompt_tokens !== "number")
|
|
43275
|
+
return void 0;
|
|
43276
|
+
return {
|
|
43277
|
+
type: "usage",
|
|
43278
|
+
inputTokens: usage.prompt_tokens,
|
|
43279
|
+
...typeof usage.completion_tokens === "number" ? { outputTokens: usage.completion_tokens } : {},
|
|
43280
|
+
...typeof usage.prompt_tokens_details?.cached_tokens === "number" ? { cachedTokens: usage.prompt_tokens_details.cached_tokens } : {}
|
|
43281
|
+
};
|
|
43282
|
+
}
|
|
43255
43283
|
function extractChoice(parsed) {
|
|
43256
43284
|
if (typeof parsed !== "object" || parsed === null || !("choices" in parsed))
|
|
43257
43285
|
return void 0;
|
|
@@ -43294,9 +43322,30 @@ async function* parseSseStream(body, url2, signal, logger) {
|
|
|
43294
43322
|
let buffer = "";
|
|
43295
43323
|
const thinking = new ThinkTagSplitter();
|
|
43296
43324
|
const toolCallAccumulators = /* @__PURE__ */ new Map();
|
|
43325
|
+
let finishedAt;
|
|
43326
|
+
const AFTER_FINISH_MS = 5e3;
|
|
43297
43327
|
try {
|
|
43298
43328
|
while (true) {
|
|
43299
|
-
|
|
43329
|
+
let next;
|
|
43330
|
+
if (finishedAt === void 0)
|
|
43331
|
+
next = await reader.read();
|
|
43332
|
+
else {
|
|
43333
|
+
const left = Math.max(0, AFTER_FINISH_MS - (Date.now() - finishedAt));
|
|
43334
|
+
let timer;
|
|
43335
|
+
next = await Promise.race([
|
|
43336
|
+
reader.read(),
|
|
43337
|
+
new Promise((resolve) => {
|
|
43338
|
+
timer = setTimeout(() => resolve("late"), left);
|
|
43339
|
+
})
|
|
43340
|
+
]);
|
|
43341
|
+
clearTimeout(timer);
|
|
43342
|
+
}
|
|
43343
|
+
if (next === "late") {
|
|
43344
|
+
void reader.cancel().catch(() => void 0);
|
|
43345
|
+
yield { type: "done" };
|
|
43346
|
+
return;
|
|
43347
|
+
}
|
|
43348
|
+
const { done, value } = next;
|
|
43300
43349
|
if (done)
|
|
43301
43350
|
break;
|
|
43302
43351
|
buffer += decoder2.decode(value, { stream: true });
|
|
@@ -43315,6 +43364,9 @@ async function* parseSseStream(body, url2, signal, logger) {
|
|
|
43315
43364
|
}
|
|
43316
43365
|
try {
|
|
43317
43366
|
const parsed = JSON.parse(data);
|
|
43367
|
+
const usage = usageFrom(parsed);
|
|
43368
|
+
if (usage !== void 0)
|
|
43369
|
+
yield usage;
|
|
43318
43370
|
const choice = extractChoice(parsed);
|
|
43319
43371
|
if (choice === void 0)
|
|
43320
43372
|
continue;
|
|
@@ -43330,12 +43382,11 @@ async function* parseSseStream(body, url2, signal, logger) {
|
|
|
43330
43382
|
yield { type: "text", text: split.text };
|
|
43331
43383
|
}
|
|
43332
43384
|
accumulateToolCallDeltas(toolCallAccumulators, choice.delta.tool_calls);
|
|
43333
|
-
if (choice.finishReason === "tool_calls") {
|
|
43385
|
+
if (choice.finishReason === "tool_calls" && finishedAt === void 0) {
|
|
43334
43386
|
for (const toolCall of completedToolCalls(toolCallAccumulators)) {
|
|
43335
43387
|
yield { type: "toolCall", toolCall };
|
|
43336
43388
|
}
|
|
43337
|
-
|
|
43338
|
-
return;
|
|
43389
|
+
finishedAt = Date.now();
|
|
43339
43390
|
}
|
|
43340
43391
|
} catch {
|
|
43341
43392
|
}
|
|
@@ -43524,6 +43575,14 @@ async function* parseAnthropicStream(body, url2, signal, logger) {
|
|
|
43524
43575
|
continue;
|
|
43525
43576
|
}
|
|
43526
43577
|
const eventType = parsed.type;
|
|
43578
|
+
if (eventType === "message_start") {
|
|
43579
|
+
const usage = parsed.message?.usage;
|
|
43580
|
+
if (typeof usage?.input_tokens === "number") {
|
|
43581
|
+
const cached2 = typeof usage.cache_read_input_tokens === "number" ? usage.cache_read_input_tokens : 0;
|
|
43582
|
+
const created = typeof usage.cache_creation_input_tokens === "number" ? usage.cache_creation_input_tokens : 0;
|
|
43583
|
+
yield { type: "usage", inputTokens: usage.input_tokens + cached2 + created, cachedTokens: cached2 };
|
|
43584
|
+
}
|
|
43585
|
+
}
|
|
43527
43586
|
if (eventType === "content_block_start") {
|
|
43528
43587
|
const index = typeof parsed.index === "number" ? parsed.index : 0;
|
|
43529
43588
|
const block2 = parsed.content_block;
|
|
@@ -43761,6 +43820,15 @@ async function* parseGeminiStream(body, url2, signal) {
|
|
|
43761
43820
|
} catch {
|
|
43762
43821
|
continue;
|
|
43763
43822
|
}
|
|
43823
|
+
const usage = parsed.usageMetadata;
|
|
43824
|
+
if (typeof usage?.promptTokenCount === "number") {
|
|
43825
|
+
yield {
|
|
43826
|
+
type: "usage",
|
|
43827
|
+
inputTokens: usage.promptTokenCount,
|
|
43828
|
+
...typeof usage.candidatesTokenCount === "number" ? { outputTokens: usage.candidatesTokenCount } : {},
|
|
43829
|
+
...typeof usage.cachedContentTokenCount === "number" ? { cachedTokens: usage.cachedContentTokenCount } : {}
|
|
43830
|
+
};
|
|
43831
|
+
}
|
|
43764
43832
|
const candidates = parsed.candidates;
|
|
43765
43833
|
if (!Array.isArray(candidates) || candidates.length === 0)
|
|
43766
43834
|
continue;
|
|
@@ -44060,6 +44128,40 @@ function estimateTokens(text2) {
|
|
|
44060
44128
|
return 0;
|
|
44061
44129
|
return Math.ceil(text2.length / 4);
|
|
44062
44130
|
}
|
|
44131
|
+
var calibrations = /* @__PURE__ */ new Map();
|
|
44132
|
+
function calibrate(key3, estimated, reported) {
|
|
44133
|
+
if (!(estimated > 0) || !(reported > 0))
|
|
44134
|
+
return;
|
|
44135
|
+
const ratio = reported / estimated;
|
|
44136
|
+
if (ratio < 0.5 || ratio > 4)
|
|
44137
|
+
return;
|
|
44138
|
+
const previous = calibrations.get(key3);
|
|
44139
|
+
calibrations.set(key3, previous === void 0 ? ratio : previous * 0.3 + ratio * 0.7);
|
|
44140
|
+
}
|
|
44141
|
+
function calibrationFor(key3) {
|
|
44142
|
+
return calibrations.get(key3);
|
|
44143
|
+
}
|
|
44144
|
+
function scaleBreakdown(breakdown, ratio) {
|
|
44145
|
+
if (ratio === void 0 || ratio === 1)
|
|
44146
|
+
return breakdown;
|
|
44147
|
+
const s = (n) => Math.round(n * ratio);
|
|
44148
|
+
return { ...breakdown, system: s(breakdown.system), toolDefinitions: s(breakdown.toolDefinitions), history: s(breakdown.history), results: s(breakdown.results), total: s(breakdown.total) };
|
|
44149
|
+
}
|
|
44150
|
+
function promptTokensFromError(error51) {
|
|
44151
|
+
const patterns = [
|
|
44152
|
+
/prompt contains (?:at least )?([\d,]+) (?:input )?tokens/i,
|
|
44153
|
+
/prompt is too long:?\s*([\d,]+)\s*tokens/i,
|
|
44154
|
+
/(?:requested|resulted in|have)\s+([\d,]+)\s+tokens?\b[^.]*(?:messages|prompt|input)/i,
|
|
44155
|
+
/input (?:length|tokens?)[^\d]{0,20}([\d,]+)/i
|
|
44156
|
+
];
|
|
44157
|
+
for (const pattern of patterns) {
|
|
44158
|
+
const m = pattern.exec(error51);
|
|
44159
|
+
const n = m?.[1] !== void 0 ? Number(m[1].replace(/,/g, "")) : NaN;
|
|
44160
|
+
if (Number.isFinite(n) && n > 0)
|
|
44161
|
+
return n;
|
|
44162
|
+
}
|
|
44163
|
+
return void 0;
|
|
44164
|
+
}
|
|
44063
44165
|
function computeBreakdown(messages, tools, contextWindow) {
|
|
44064
44166
|
let system = 0;
|
|
44065
44167
|
let history = 0;
|
|
@@ -44094,14 +44196,33 @@ function computeBreakdown(messages, tools, contextWindow) {
|
|
|
44094
44196
|
estimated: true
|
|
44095
44197
|
};
|
|
44096
44198
|
}
|
|
44199
|
+
function applyReportedUsage(breakdown, usage) {
|
|
44200
|
+
const reportedInput = usage?.inputTokens;
|
|
44201
|
+
if (reportedInput === void 0)
|
|
44202
|
+
return breakdown;
|
|
44203
|
+
const estimatedTotal = breakdown.total;
|
|
44204
|
+
const trueTotal = reportedInput + (usage?.cacheReadTokens ?? 0);
|
|
44205
|
+
if (estimatedTotal === 0)
|
|
44206
|
+
return { ...breakdown, total: trueTotal, estimated: false };
|
|
44207
|
+
const scale = trueTotal / estimatedTotal;
|
|
44208
|
+
return {
|
|
44209
|
+
system: Math.round(breakdown.system * scale),
|
|
44210
|
+
toolDefinitions: Math.round(breakdown.toolDefinitions * scale),
|
|
44211
|
+
history: Math.round(breakdown.history * scale),
|
|
44212
|
+
results: Math.round(breakdown.results * scale),
|
|
44213
|
+
total: trueTotal,
|
|
44214
|
+
contextWindow: breakdown.contextWindow,
|
|
44215
|
+
estimated: false
|
|
44216
|
+
};
|
|
44217
|
+
}
|
|
44097
44218
|
|
|
44098
44219
|
// ../../packages/core/dist/context/supersede.js
|
|
44099
44220
|
var SUPERSEDED_MARKER = "[Superseded: this file was read again later in the conversation. See the most recent read for current contents.]";
|
|
44100
44221
|
function readFilePath(argumentsJson) {
|
|
44101
44222
|
try {
|
|
44102
44223
|
const parsed = JSON.parse(argumentsJson.length > 0 ? argumentsJson : "{}");
|
|
44103
|
-
const
|
|
44104
|
-
return typeof
|
|
44224
|
+
const path64 = parsed.path;
|
|
44225
|
+
return typeof path64 === "string" && path64.length > 0 ? path64 : void 0;
|
|
44105
44226
|
} catch {
|
|
44106
44227
|
return void 0;
|
|
44107
44228
|
}
|
|
@@ -44114,8 +44235,8 @@ function dropSupersededReads(messages) {
|
|
|
44114
44235
|
for (const toolCall of message5.toolCalls ?? []) {
|
|
44115
44236
|
if (toolCall.name !== "read_file")
|
|
44116
44237
|
continue;
|
|
44117
|
-
const
|
|
44118
|
-
if (
|
|
44238
|
+
const path64 = readFilePath(toolCall.arguments);
|
|
44239
|
+
if (path64 === void 0)
|
|
44119
44240
|
continue;
|
|
44120
44241
|
keyByCallId.set(toolCall.id, toolCall.arguments);
|
|
44121
44242
|
}
|
|
@@ -46971,13 +47092,13 @@ var OpenSearchClient = class {
|
|
|
46971
47092
|
* `_bulk`, `_delete_by_query`, index creation — is refused here rather than merely
|
|
46972
47093
|
* unused, so no future edit or crafted argument can turn a read client into a writer.
|
|
46973
47094
|
*/
|
|
46974
|
-
async request(
|
|
47095
|
+
async request(path64, options = {}) {
|
|
46975
47096
|
const method = options.method ?? "GET";
|
|
46976
|
-
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(
|
|
47097
|
+
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(path64);
|
|
46977
47098
|
if (method !== "GET" && !isSearchPost) {
|
|
46978
|
-
throw new OpenSearchError(`Refusing ${method} ${
|
|
47099
|
+
throw new OpenSearchError(`Refusing ${method} ${path64}: this client is read-only. Indexing goes through the indexer, which the user starts from Settings.`);
|
|
46979
47100
|
}
|
|
46980
|
-
const url2 = `${this.base}${
|
|
47101
|
+
const url2 = `${this.base}${path64}`;
|
|
46981
47102
|
const request = {
|
|
46982
47103
|
method,
|
|
46983
47104
|
headers: this.headers()
|
|
@@ -47144,11 +47265,11 @@ function collectFields(properties, prefix, out) {
|
|
|
47144
47265
|
return;
|
|
47145
47266
|
for (const [name, raw] of Object.entries(properties)) {
|
|
47146
47267
|
const field2 = raw;
|
|
47147
|
-
const
|
|
47268
|
+
const path64 = prefix.length > 0 ? `${prefix}.${name}` : name;
|
|
47148
47269
|
if (typeof field2.type === "string")
|
|
47149
|
-
out[
|
|
47270
|
+
out[path64] = field2.type;
|
|
47150
47271
|
if (field2.properties !== void 0)
|
|
47151
|
-
collectFields(field2.properties,
|
|
47272
|
+
collectFields(field2.properties, path64, out);
|
|
47152
47273
|
}
|
|
47153
47274
|
}
|
|
47154
47275
|
function describeStatus(status2, url2, body) {
|
|
@@ -47167,23 +47288,23 @@ function describeStatus(status2, url2, body) {
|
|
|
47167
47288
|
var TEXT_TYPES = /* @__PURE__ */ new Set(["text", "match_only_text", "search_as_you_type", "wildcard"]);
|
|
47168
47289
|
var KEYWORD_TYPES = /* @__PURE__ */ new Set(["keyword", "constant_keyword"]);
|
|
47169
47290
|
var NOISE_FIELDS = /* @__PURE__ */ new Set(["@version", "ecs", "tags", "stream", "input", "agent", "host", "event"]);
|
|
47170
|
-
function leafName(
|
|
47171
|
-
const parts =
|
|
47172
|
-
return parts[parts.length - 1] ??
|
|
47291
|
+
function leafName(path64) {
|
|
47292
|
+
const parts = path64.split(".");
|
|
47293
|
+
return parts[parts.length - 1] ?? path64;
|
|
47173
47294
|
}
|
|
47174
47295
|
function selectQueryFields(mapping, limit = 25) {
|
|
47175
47296
|
const text2 = [];
|
|
47176
47297
|
const keyword = [];
|
|
47177
|
-
for (const [
|
|
47178
|
-
if (NOISE_FIELDS.has(leafName(
|
|
47298
|
+
for (const [path64, type] of Object.entries(mapping)) {
|
|
47299
|
+
if (NOISE_FIELDS.has(leafName(path64)) || NOISE_FIELDS.has(path64.split(".")[0] ?? ""))
|
|
47179
47300
|
continue;
|
|
47180
47301
|
if (TEXT_TYPES.has(type)) {
|
|
47181
|
-
text2.push(
|
|
47302
|
+
text2.push(path64);
|
|
47182
47303
|
} else if (KEYWORD_TYPES.has(type)) {
|
|
47183
|
-
const parent =
|
|
47184
|
-
if (
|
|
47304
|
+
const parent = path64.replace(/\.keyword$/, "");
|
|
47305
|
+
if (path64.endsWith(".keyword") && TEXT_TYPES.has(mapping[parent] ?? ""))
|
|
47185
47306
|
continue;
|
|
47186
|
-
keyword.push(
|
|
47307
|
+
keyword.push(path64);
|
|
47187
47308
|
}
|
|
47188
47309
|
}
|
|
47189
47310
|
const byDepth = (a, b) => a.split(".").length - b.split(".").length || a.localeCompare(b);
|
|
@@ -47325,8 +47446,8 @@ var OpenSearchIndexWriter = class {
|
|
|
47325
47446
|
}
|
|
47326
47447
|
return headers;
|
|
47327
47448
|
}
|
|
47328
|
-
async request(
|
|
47329
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
47449
|
+
async request(path64, method, body, signal) {
|
|
47450
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path64}`;
|
|
47330
47451
|
const request = { method, headers: this.headers() };
|
|
47331
47452
|
if (body !== void 0) {
|
|
47332
47453
|
if (typeof body === "string") {
|
|
@@ -47540,13 +47661,13 @@ var OpenSearchIndexWriter = class {
|
|
|
47540
47661
|
for (const hit of hits) {
|
|
47541
47662
|
const source = hit._source ?? {};
|
|
47542
47663
|
const vector = source.vector;
|
|
47543
|
-
const
|
|
47544
|
-
if (typeof
|
|
47664
|
+
const path64 = source.path;
|
|
47665
|
+
if (typeof path64 !== "string" || !Array.isArray(vector))
|
|
47545
47666
|
continue;
|
|
47546
47667
|
documents.push({
|
|
47547
47668
|
id: hit._id ?? "",
|
|
47548
47669
|
text: typeof source.text === "string" ? source.text : "",
|
|
47549
|
-
path:
|
|
47670
|
+
path: path64,
|
|
47550
47671
|
startLine: typeof source.startLine === "number" ? source.startLine : 1,
|
|
47551
47672
|
endLine: typeof source.endLine === "number" ? source.endLine : 1,
|
|
47552
47673
|
vector
|
|
@@ -47620,8 +47741,8 @@ var RestTransport = class {
|
|
|
47620
47741
|
* threw would push every caller into catching and re-inspecting an error to find out
|
|
47621
47742
|
* whether it was really an error. `expectOk` is there for the cases that are.
|
|
47622
47743
|
*/
|
|
47623
|
-
async send(
|
|
47624
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
47744
|
+
async send(path64, method, body, signal) {
|
|
47745
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path64}`;
|
|
47625
47746
|
const request = { method, headers: this.headers() };
|
|
47626
47747
|
if (body !== void 0)
|
|
47627
47748
|
request.body = JSON.stringify(body);
|
|
@@ -47647,11 +47768,11 @@ var RestTransport = class {
|
|
|
47647
47768
|
return { status: response.status, body: parsed };
|
|
47648
47769
|
}
|
|
47649
47770
|
/** Sends, and throws unless the status is 2xx. */
|
|
47650
|
-
async expectOk(
|
|
47651
|
-
const result = await this.send(
|
|
47771
|
+
async expectOk(path64, method, body, signal) {
|
|
47772
|
+
const result = await this.send(path64, method, body, signal);
|
|
47652
47773
|
if (result.status < 200 || result.status >= 300) {
|
|
47653
47774
|
const detail = typeof result.body === "string" ? result.body : JSON.stringify(result.body ?? "");
|
|
47654
|
-
throw new VectorStoreError(`${method} ${
|
|
47775
|
+
throw new VectorStoreError(`${method} ${path64} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}`, result.status);
|
|
47655
47776
|
}
|
|
47656
47777
|
return result.body;
|
|
47657
47778
|
}
|
|
@@ -47759,10 +47880,10 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
47759
47880
|
const matches = [];
|
|
47760
47881
|
for (let index = 0; index < ids.length; index++) {
|
|
47761
47882
|
const metadata = metadatas[index] ?? {};
|
|
47762
|
-
const
|
|
47763
|
-
if (
|
|
47883
|
+
const path64 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
47884
|
+
if (path64 === void 0)
|
|
47764
47885
|
continue;
|
|
47765
|
-
if (prefix !== void 0 && prefix.length > 0 && !
|
|
47886
|
+
if (prefix !== void 0 && prefix.length > 0 && !path64.startsWith(prefix))
|
|
47766
47887
|
continue;
|
|
47767
47888
|
if (projectHere && typeof metadata.project === "string" && !options.project?.names.includes(metadata.project))
|
|
47768
47889
|
continue;
|
|
@@ -47776,7 +47897,7 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
47776
47897
|
*/
|
|
47777
47898
|
score: typeof distance === "number" ? 1 / (1 + Math.max(0, distance)) : 0,
|
|
47778
47899
|
text: documents[index] ?? (typeof metadata.text === "string" ? metadata.text : ""),
|
|
47779
|
-
path:
|
|
47900
|
+
path: path64
|
|
47780
47901
|
};
|
|
47781
47902
|
if (typeof metadata.startLine === "number")
|
|
47782
47903
|
match.startLine = metadata.startLine;
|
|
@@ -47887,13 +48008,13 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
47887
48008
|
for (let index = 0; index < ids.length; index++) {
|
|
47888
48009
|
const metadata = result.metadatas?.[index] ?? {};
|
|
47889
48010
|
const vector = result.embeddings?.[index];
|
|
47890
|
-
const
|
|
47891
|
-
if (
|
|
48011
|
+
const path64 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
48012
|
+
if (path64 === void 0 || !Array.isArray(vector))
|
|
47892
48013
|
continue;
|
|
47893
48014
|
documents.push({
|
|
47894
48015
|
id: ids[index] ?? "",
|
|
47895
48016
|
text: result.documents?.[index] ?? "",
|
|
47896
|
-
path:
|
|
48017
|
+
path: path64,
|
|
47897
48018
|
startLine: typeof metadata.startLine === "number" ? metadata.startLine : 1,
|
|
47898
48019
|
endLine: typeof metadata.endLine === "number" ? metadata.endLine : 1,
|
|
47899
48020
|
vector
|
|
@@ -47910,9 +48031,9 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
47910
48031
|
const result = await this.rest.expectOk(`${this.base}/collections/${found2.id}/get`, "POST", { include: ["metadatas"], limit }, options.signal);
|
|
47911
48032
|
const paths = /* @__PURE__ */ new Set();
|
|
47912
48033
|
for (const metadata of result.metadatas ?? []) {
|
|
47913
|
-
const
|
|
47914
|
-
if (typeof
|
|
47915
|
-
paths.add(
|
|
48034
|
+
const path64 = metadata?.path;
|
|
48035
|
+
if (typeof path64 === "string")
|
|
48036
|
+
paths.add(path64);
|
|
47916
48037
|
}
|
|
47917
48038
|
return [...paths];
|
|
47918
48039
|
}
|
|
@@ -47939,14 +48060,14 @@ var MARKER_ID = "5f6d2a41-0000-5000-8000-6c69676874c0";
|
|
|
47939
48060
|
var MARKER_MARK = "light-code";
|
|
47940
48061
|
function toMatch(point) {
|
|
47941
48062
|
const payload = point.payload ?? {};
|
|
47942
|
-
const
|
|
47943
|
-
if (
|
|
48063
|
+
const path64 = typeof payload.path === "string" ? payload.path : void 0;
|
|
48064
|
+
if (path64 === void 0)
|
|
47944
48065
|
return void 0;
|
|
47945
48066
|
const match = {
|
|
47946
48067
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
47947
48068
|
score: typeof point.score === "number" ? point.score : 0,
|
|
47948
48069
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
47949
|
-
path:
|
|
48070
|
+
path: path64
|
|
47950
48071
|
};
|
|
47951
48072
|
if (typeof payload.startLine === "number")
|
|
47952
48073
|
match.startLine = payload.startLine;
|
|
@@ -48140,13 +48261,13 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
48140
48261
|
const documents = [];
|
|
48141
48262
|
for (const point of result.body.result?.points ?? []) {
|
|
48142
48263
|
const payload = point.payload ?? {};
|
|
48143
|
-
const
|
|
48144
|
-
if (
|
|
48264
|
+
const path64 = typeof payload.path === "string" ? payload.path : void 0;
|
|
48265
|
+
if (path64 === void 0 || !Array.isArray(point.vector))
|
|
48145
48266
|
continue;
|
|
48146
48267
|
documents.push({
|
|
48147
48268
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
48148
48269
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
48149
|
-
path:
|
|
48270
|
+
path: path64,
|
|
48150
48271
|
startLine: typeof payload.startLine === "number" ? payload.startLine : 1,
|
|
48151
48272
|
endLine: typeof payload.endLine === "number" ? payload.endLine : 1,
|
|
48152
48273
|
vector: point.vector
|
|
@@ -48173,9 +48294,9 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
48173
48294
|
throw new VectorStoreError(`Could not list "${collection}" (HTTP ${String(result.status)}).`, result.status);
|
|
48174
48295
|
}
|
|
48175
48296
|
for (const point of result.body.result?.points ?? []) {
|
|
48176
|
-
const
|
|
48177
|
-
if (typeof
|
|
48178
|
-
paths.add(
|
|
48297
|
+
const path64 = point.payload?.path;
|
|
48298
|
+
if (typeof path64 === "string")
|
|
48299
|
+
paths.add(path64);
|
|
48179
48300
|
}
|
|
48180
48301
|
offset = result.body.result?.next_page_offset;
|
|
48181
48302
|
if (offset === void 0 || offset === null)
|
|
@@ -48709,8 +48830,8 @@ function teamSkillDocument(skill, body, vector, attribution) {
|
|
|
48709
48830
|
vector
|
|
48710
48831
|
};
|
|
48711
48832
|
}
|
|
48712
|
-
function nameFromPath(
|
|
48713
|
-
return
|
|
48833
|
+
function nameFromPath(path64) {
|
|
48834
|
+
return path64.startsWith("skill:") ? path64.slice("skill:".length) : path64;
|
|
48714
48835
|
}
|
|
48715
48836
|
function toHit(match, self) {
|
|
48716
48837
|
return {
|
|
@@ -51796,8 +51917,8 @@ function createMailCoverageTool(options) {
|
|
|
51796
51917
|
}
|
|
51797
51918
|
};
|
|
51798
51919
|
}
|
|
51799
|
-
function normaliseFolder(
|
|
51800
|
-
return
|
|
51920
|
+
function normaliseFolder(path64) {
|
|
51921
|
+
return path64.toLowerCase().replace(/[\\/]+/g, "\\");
|
|
51801
51922
|
}
|
|
51802
51923
|
function haystackOf(record2) {
|
|
51803
51924
|
return `${record2.subject}
|
|
@@ -52293,7 +52414,7 @@ async function refreshMail(options) {
|
|
|
52293
52414
|
const limit = options.batchLimit ?? 2e3;
|
|
52294
52415
|
const previewChars = options.previewChars ?? 400;
|
|
52295
52416
|
const sinceMs = Date.now() - options.days * 24 * 60 * 60 * 1e3;
|
|
52296
|
-
const harvested = await options.harvest(options.folders.map((
|
|
52417
|
+
const harvested = await options.harvest(options.folders.map((path64) => ({ path: path64, sinceMs })), { limit, previewChars });
|
|
52297
52418
|
const fetched = harvested.messages.map(toRecord);
|
|
52298
52419
|
if (fetched.length === 0) {
|
|
52299
52420
|
return { added: 0, more: false, total: known.length, embedded: 0, backfilled: 0, complete: [] };
|
|
@@ -52334,9 +52455,9 @@ async function syncMail(options) {
|
|
|
52334
52455
|
const backfillDone = await options.store.loadBackfillState();
|
|
52335
52456
|
const limit = options.batchLimit ?? 500;
|
|
52336
52457
|
const previewChars = options.previewChars ?? 400;
|
|
52337
|
-
const forwardRequests = options.folders.map((
|
|
52338
|
-
const mark = marks.get(
|
|
52339
|
-
return mark === void 0 ? { path:
|
|
52458
|
+
const forwardRequests = options.folders.map((path64) => {
|
|
52459
|
+
const mark = marks.get(path64);
|
|
52460
|
+
return mark === void 0 ? { path: path64 } : { path: path64, sinceMs: mark.newest - 1e3 };
|
|
52340
52461
|
});
|
|
52341
52462
|
const forward = await options.harvest(forwardRequests, { limit, previewChars });
|
|
52342
52463
|
let candidates = forward.messages.map(toRecord);
|
|
@@ -52345,15 +52466,15 @@ async function syncMail(options) {
|
|
|
52345
52466
|
let more = forward.truncated;
|
|
52346
52467
|
const remaining = limit - candidates.length;
|
|
52347
52468
|
const floor = options.retentionMonths === void 0 ? void 0 : monthsBefore(options.now ?? Date.now(), options.retentionMonths);
|
|
52348
|
-
const outstanding = options.folders.filter((
|
|
52349
|
-
const atFloor = floor === void 0 ? [] : outstanding.filter((
|
|
52350
|
-
const behind = outstanding.filter((
|
|
52469
|
+
const outstanding = options.folders.filter((path64) => marks.has(path64) && backfillDone[path64] !== true);
|
|
52470
|
+
const atFloor = floor === void 0 ? [] : outstanding.filter((path64) => marks.get(path64).oldest <= floor);
|
|
52471
|
+
const behind = outstanding.filter((path64) => !atFloor.includes(path64));
|
|
52351
52472
|
completed.push(...atFloor);
|
|
52352
52473
|
if (remaining > 0 && behind.length > 0 && options.signal?.aborted !== true) {
|
|
52353
|
-
const backRequests = behind.map((
|
|
52354
|
-
path:
|
|
52474
|
+
const backRequests = behind.map((path64) => ({
|
|
52475
|
+
path: path64,
|
|
52355
52476
|
// Strictly older, so the oldest held message is not fetched again every pass.
|
|
52356
|
-
beforeMs: marks.get(
|
|
52477
|
+
beforeMs: marks.get(path64).oldest,
|
|
52357
52478
|
// And no older than retention wants. The harvest ANDs the two into one window.
|
|
52358
52479
|
...floor === void 0 ? {} : { sinceMs: floor }
|
|
52359
52480
|
}));
|
|
@@ -52361,9 +52482,9 @@ async function syncMail(options) {
|
|
|
52361
52482
|
backfilled = backward.messages.length;
|
|
52362
52483
|
candidates = [...candidates, ...backward.messages.map(toRecord)];
|
|
52363
52484
|
const returnedFor = new Set(backward.messages.map((message5) => message5.folder));
|
|
52364
|
-
for (const
|
|
52365
|
-
if (!returnedFor.has(
|
|
52366
|
-
completed.push(
|
|
52485
|
+
for (const path64 of behind) {
|
|
52486
|
+
if (!returnedFor.has(path64))
|
|
52487
|
+
completed.push(path64);
|
|
52367
52488
|
}
|
|
52368
52489
|
if (backward.truncated || backfilled > 0)
|
|
52369
52490
|
more = true;
|
|
@@ -52371,7 +52492,7 @@ async function syncMail(options) {
|
|
|
52371
52492
|
if (completed.length > 0) {
|
|
52372
52493
|
await options.store.saveBackfillState({
|
|
52373
52494
|
...backfillDone,
|
|
52374
|
-
...Object.fromEntries(completed.map((
|
|
52495
|
+
...Object.fromEntries(completed.map((path64) => [path64, true]))
|
|
52375
52496
|
});
|
|
52376
52497
|
}
|
|
52377
52498
|
const fresh = withoutKnown(candidates, known);
|
|
@@ -52711,14 +52832,14 @@ function formatBytes(size) {
|
|
|
52711
52832
|
return `${(size / (1 << 10)).toFixed(1)}KB`;
|
|
52712
52833
|
return `${String(size)}B`;
|
|
52713
52834
|
}
|
|
52714
|
-
async function readTail(fs43,
|
|
52835
|
+
async function readTail(fs43, path64, size, count3) {
|
|
52715
52836
|
let span = Math.min(size, CHUNK);
|
|
52716
52837
|
let text2;
|
|
52717
52838
|
let start;
|
|
52718
52839
|
for (; ; ) {
|
|
52719
52840
|
start = Math.max(0, size - span);
|
|
52720
52841
|
const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
|
|
52721
|
-
text2 = decoder2.write(await fs43.readBytesSlice(
|
|
52842
|
+
text2 = decoder2.write(await fs43.readBytesSlice(path64, start, size)) + decoder2.end();
|
|
52722
52843
|
const enough = text2.split("\n").length > count3;
|
|
52723
52844
|
if (enough || start === 0 || span >= size)
|
|
52724
52845
|
break;
|
|
@@ -52736,7 +52857,7 @@ async function readTail(fs43, path63, size, count3) {
|
|
|
52736
52857
|
hasMoreAfter: false
|
|
52737
52858
|
};
|
|
52738
52859
|
}
|
|
52739
|
-
async function readLineWindow(fs43,
|
|
52860
|
+
async function readLineWindow(fs43, path64, size, from, count3) {
|
|
52740
52861
|
const decoder2 = new import_node_string_decoder.StringDecoder("utf8");
|
|
52741
52862
|
const lines2 = [];
|
|
52742
52863
|
let pending = "";
|
|
@@ -52751,7 +52872,7 @@ async function readLineWindow(fs43, path63, size, from, count3) {
|
|
|
52751
52872
|
};
|
|
52752
52873
|
scan: while (position < size) {
|
|
52753
52874
|
const end = Math.min(size, position + CHUNK);
|
|
52754
|
-
pending += decoder2.write(await fs43.readBytesSlice(
|
|
52875
|
+
pending += decoder2.write(await fs43.readBytesSlice(path64, position, end));
|
|
52755
52876
|
position = end;
|
|
52756
52877
|
const parts = pending.split(/\r\n|\r|\n/);
|
|
52757
52878
|
pending = parts.pop() ?? "";
|
|
@@ -52774,13 +52895,13 @@ async function readLineWindow(fs43, path63, size, from, count3) {
|
|
|
52774
52895
|
hasMoreAfter: !reachedEnd || lineNumber > from + lines2.length
|
|
52775
52896
|
};
|
|
52776
52897
|
}
|
|
52777
|
-
async function countLines(fs43,
|
|
52898
|
+
async function countLines(fs43, path64, size) {
|
|
52778
52899
|
let newlines = 0;
|
|
52779
52900
|
let position = 0;
|
|
52780
52901
|
let lastByte = -1;
|
|
52781
52902
|
while (position < size) {
|
|
52782
52903
|
const end = Math.min(size, position + CHUNK);
|
|
52783
|
-
const buffer = await fs43.readBytesSlice(
|
|
52904
|
+
const buffer = await fs43.readBytesSlice(path64, position, end);
|
|
52784
52905
|
for (const byte of buffer)
|
|
52785
52906
|
if (byte === 10)
|
|
52786
52907
|
newlines += 1;
|
|
@@ -59549,6 +59670,29 @@ async function pythonVersion(program) {
|
|
|
59549
59670
|
// ../../packages/core/dist/python/worker.js
|
|
59550
59671
|
var import_node_child_process5 = require("node:child_process");
|
|
59551
59672
|
var import_node_readline = require("node:readline");
|
|
59673
|
+
function describeWorkerExit(code, signal) {
|
|
59674
|
+
if (signal !== null)
|
|
59675
|
+
return `The Python worker was stopped (${signal}).`;
|
|
59676
|
+
if (code === null)
|
|
59677
|
+
return "The Python worker exited.";
|
|
59678
|
+
const unsigned = code < 0 ? code + 4294967296 : code;
|
|
59679
|
+
const hex3 = `0x${unsigned.toString(16).toUpperCase().padStart(8, "0")}`;
|
|
59680
|
+
const known = {
|
|
59681
|
+
"0xC0000005": "an access violation inside Python or a library it loaded (a native extension, or a DLL it found on PATH)",
|
|
59682
|
+
"0xC00000FD": "a stack overflow - usually deep recursion in a tool",
|
|
59683
|
+
"0xC0000409": "a security check failure in native code",
|
|
59684
|
+
"0xC0000374": "heap corruption in native code",
|
|
59685
|
+
"0xC000001D": "an illegal instruction - a library built for a newer CPU",
|
|
59686
|
+
"0xC0000135": "a DLL it needs could not be found",
|
|
59687
|
+
"0xC0000017": "it ran out of memory",
|
|
59688
|
+
"0xC000013A": "it was interrupted (Ctrl+C)"
|
|
59689
|
+
};
|
|
59690
|
+
if (known[hex3] !== void 0)
|
|
59691
|
+
return `The Python worker crashed (${hex3}: ${known[hex3]}).`;
|
|
59692
|
+
if (unsigned >= 3221225472)
|
|
59693
|
+
return `The Python worker crashed (Windows code ${hex3}).`;
|
|
59694
|
+
return `The Python worker exited with code ${String(code)}.`;
|
|
59695
|
+
}
|
|
59552
59696
|
var PythonWorkerError = class extends Error {
|
|
59553
59697
|
traceback;
|
|
59554
59698
|
constructor(message5, traceback) {
|
|
@@ -59568,6 +59712,8 @@ var PythonWorker = class {
|
|
|
59568
59712
|
constructor(options) {
|
|
59569
59713
|
this.options = options;
|
|
59570
59714
|
}
|
|
59715
|
+
/** The worker's last stderr, for saying why it crashed. */
|
|
59716
|
+
stderrTail = "";
|
|
59571
59717
|
start() {
|
|
59572
59718
|
if (this.child !== void 0 && this.child.exitCode === null && !this.child.killed)
|
|
59573
59719
|
return this.child;
|
|
@@ -59582,10 +59728,20 @@ var PythonWorker = class {
|
|
|
59582
59728
|
this.reader = (0, import_node_readline.createInterface)({ input: child.stdout });
|
|
59583
59729
|
this.reader.on("line", (line) => this.onLine(line));
|
|
59584
59730
|
child.stderr.on("data", (chunk) => {
|
|
59585
|
-
|
|
59731
|
+
const text2 = chunk.toString("utf8").trimEnd();
|
|
59732
|
+
this.options.logger.warn("python worker stderr", text2);
|
|
59733
|
+
this.stderrTail = `${this.stderrTail}
|
|
59734
|
+
${text2}`.slice(-4e3);
|
|
59586
59735
|
});
|
|
59736
|
+
child.stdin.on("error", (error51) => this.options.logger.warn("python worker input closed", String(error51)));
|
|
59587
59737
|
child.on("exit", (code, signal) => {
|
|
59588
|
-
const reason = new PythonWorkerError(
|
|
59738
|
+
const reason = new PythonWorkerError(`${describeWorkerExit(code, signal)} It will restart on the next call.${this.stderrTail.trim() ? `
|
|
59739
|
+
|
|
59740
|
+
Its last output:
|
|
59741
|
+
${this.stderrTail.trim().split("\n").slice(-15).join("\n")}` : ""}`);
|
|
59742
|
+
if (code !== 0 && code !== null)
|
|
59743
|
+
this.options.logger.warn("python worker crashed", describeWorkerExit(code, signal));
|
|
59744
|
+
this.stderrTail = "";
|
|
59589
59745
|
for (const [, entry] of this.pending) {
|
|
59590
59746
|
clearTimeout(entry.timer);
|
|
59591
59747
|
entry.reject(reason);
|
|
@@ -60608,11 +60764,21 @@ var SHARE_SECTIONS = [
|
|
|
60608
60764
|
{
|
|
60609
60765
|
id: "atlassian",
|
|
60610
60766
|
label: "DevOps",
|
|
60611
|
-
description: "The Confluence, Jira, Bitbucket
|
|
60612
|
-
keys: ["confluence", "jira", "bitbucket", "jenkins", "
|
|
60767
|
+
description: "The Confluence, Jira, Bitbucket and Jenkins sites, their defaults and read-only settings, and the team repository for skills and tools. Tokens and passwords are not included. AutoSys is its own section, below.",
|
|
60768
|
+
keys: ["confluence", "jira", "bitbucket", "jenkins", "teamRepo"],
|
|
60613
60769
|
// A user id names one person: kept out of the file, and the importer's own is kept.
|
|
60614
|
-
strip: ["jenkins.username"
|
|
60615
|
-
stripNote: "Your Jenkins
|
|
60770
|
+
strip: ["jenkins.username"],
|
|
60771
|
+
stripNote: "Your Jenkins user name is left out; each person uses their own."
|
|
60772
|
+
},
|
|
60773
|
+
{
|
|
60774
|
+
// Asked for: "export only the AutoSys config and import only that". Its own section, so a file can carry
|
|
60775
|
+
// AutoSys alone, and importing it replaces the AutoSys settings and nothing else.
|
|
60776
|
+
id: "autosys",
|
|
60777
|
+
label: "AutoSys",
|
|
60778
|
+
description: "The AutoSys site, its addresses, the API gateway (token address, client id, headers), the test job and read-only setting. Passwords, secrets and certificate passphrases are not included. Alone, an import changes only AutoSys.",
|
|
60779
|
+
keys: ["autosys"],
|
|
60780
|
+
strip: ["autosys.username"],
|
|
60781
|
+
stripNote: "Your AutoSys user name is left out; each person uses their own."
|
|
60616
60782
|
},
|
|
60617
60783
|
{
|
|
60618
60784
|
id: "autosysAddresses",
|
|
@@ -60717,6 +60883,8 @@ function detailFor(section, config2) {
|
|
|
60717
60883
|
const sites = [config2.confluence?.baseUrl, config2.jira?.baseUrl, config2.bitbucket?.baseUrl].filter((site) => site !== void 0);
|
|
60718
60884
|
return sites.length > 0 ? sites.join(", ") : "not set up";
|
|
60719
60885
|
}
|
|
60886
|
+
case "autosys":
|
|
60887
|
+
return config2.autosys?.baseUrl ?? "not set up";
|
|
60720
60888
|
case "autosysAddresses":
|
|
60721
60889
|
return count(Object.keys(config2.autosys?.paths ?? {}).length, "address", "addresses");
|
|
60722
60890
|
case "datasets":
|
|
@@ -60766,6 +60934,8 @@ function secretRefsFor(section, config2) {
|
|
|
60766
60934
|
refs.push("Bitbucket: personal access token");
|
|
60767
60935
|
if (config2.jenkins?.tokenRef !== void 0)
|
|
60768
60936
|
refs.push("Jenkins: API token and user id");
|
|
60937
|
+
break;
|
|
60938
|
+
case "autosys":
|
|
60769
60939
|
if (config2.autosys?.auth?.type === "apigee") {
|
|
60770
60940
|
refs.push("AutoSys: gateway client secret");
|
|
60771
60941
|
if (config2.autosys.auth.passphraseRef !== void 0)
|
|
@@ -60792,9 +60962,9 @@ function secretRefsFor(section, config2) {
|
|
|
60792
60962
|
}
|
|
60793
60963
|
return refs;
|
|
60794
60964
|
}
|
|
60795
|
-
function getPath2(source,
|
|
60965
|
+
function getPath2(source, path64) {
|
|
60796
60966
|
let value = source;
|
|
60797
|
-
for (const part of
|
|
60967
|
+
for (const part of path64.split(".")) {
|
|
60798
60968
|
if (typeof value !== "object" || value === null)
|
|
60799
60969
|
return void 0;
|
|
60800
60970
|
value = value[part];
|
|
@@ -60808,8 +60978,8 @@ function hasValue(value) {
|
|
|
60808
60978
|
return Object.keys(value).length > 0;
|
|
60809
60979
|
return true;
|
|
60810
60980
|
}
|
|
60811
|
-
function setPath(target,
|
|
60812
|
-
const [head, ...rest] =
|
|
60981
|
+
function setPath(target, path64, value) {
|
|
60982
|
+
const [head, ...rest] = path64.split(".");
|
|
60813
60983
|
if (head === void 0)
|
|
60814
60984
|
return;
|
|
60815
60985
|
if (rest.length === 0) {
|
|
@@ -60829,8 +60999,8 @@ function setPath(target, path63, value) {
|
|
|
60829
60999
|
var NESTED_PATHS = SHARE_SECTIONS.flatMap((section) => section.nested ?? []);
|
|
60830
61000
|
function withoutNested(config2) {
|
|
60831
61001
|
const copy = { ...config2 };
|
|
60832
|
-
for (const
|
|
60833
|
-
setPath(copy,
|
|
61002
|
+
for (const path64 of NESTED_PATHS)
|
|
61003
|
+
setPath(copy, path64, void 0);
|
|
60834
61004
|
return copy;
|
|
60835
61005
|
}
|
|
60836
61006
|
function describeSections(config2) {
|
|
@@ -60839,7 +61009,7 @@ function describeSections(config2) {
|
|
|
60839
61009
|
id: section.id,
|
|
60840
61010
|
label: section.label,
|
|
60841
61011
|
description: section.description,
|
|
60842
|
-
present: section.keys.some((key3) => has(owned, key3)) || (section.nested ?? []).some((
|
|
61012
|
+
present: section.keys.some((key3) => has(owned, key3)) || (section.nested ?? []).some((path64) => hasValue(getPath2(config2, path64))),
|
|
60843
61013
|
detail: detailFor(section, config2),
|
|
60844
61014
|
secretRefs: secretRefsFor(section, config2),
|
|
60845
61015
|
...section.machineSpecific === true ? { machineSpecific: true } : {},
|
|
@@ -60860,18 +61030,18 @@ function buildExport(config2, selected) {
|
|
|
60860
61030
|
if (has(config2, key3))
|
|
60861
61031
|
exported[key3] = config2[key3];
|
|
60862
61032
|
}
|
|
60863
|
-
for (const
|
|
60864
|
-
const value = getPath2(config2,
|
|
61033
|
+
for (const path64 of section.nested ?? []) {
|
|
61034
|
+
const value = getPath2(config2, path64);
|
|
60865
61035
|
if (hasValue(value))
|
|
60866
|
-
setPath(exported,
|
|
61036
|
+
setPath(exported, path64, value);
|
|
60867
61037
|
}
|
|
60868
|
-
for (const
|
|
60869
|
-
stripPath(exported,
|
|
61038
|
+
for (const path64 of section.strip ?? [])
|
|
61039
|
+
stripPath(exported, path64);
|
|
60870
61040
|
}
|
|
60871
61041
|
return exported;
|
|
60872
61042
|
}
|
|
60873
|
-
function stripPath(target,
|
|
60874
|
-
const [head, ...rest] =
|
|
61043
|
+
function stripPath(target, path64) {
|
|
61044
|
+
const [head, ...rest] = path64.split(".");
|
|
60875
61045
|
if (head === void 0)
|
|
60876
61046
|
return;
|
|
60877
61047
|
const value = target[head];
|
|
@@ -60899,22 +61069,22 @@ function applyImport(existing, imported, selected) {
|
|
|
60899
61069
|
else
|
|
60900
61070
|
delete merged[key3];
|
|
60901
61071
|
}
|
|
60902
|
-
for (const
|
|
60903
|
-
carryPath(existing, merged,
|
|
61072
|
+
for (const path64 of section.strip ?? []) {
|
|
61073
|
+
carryPath(existing, merged, path64);
|
|
60904
61074
|
}
|
|
60905
61075
|
}
|
|
60906
61076
|
for (const section of SHARE_SECTIONS) {
|
|
60907
61077
|
if (!chosen.has(section.id))
|
|
60908
61078
|
continue;
|
|
60909
|
-
for (const
|
|
60910
|
-
const value = getPath2(imported,
|
|
60911
|
-
setPath(merged,
|
|
61079
|
+
for (const path64 of section.nested ?? []) {
|
|
61080
|
+
const value = getPath2(imported, path64);
|
|
61081
|
+
setPath(merged, path64, hasValue(value) ? value : void 0);
|
|
60912
61082
|
}
|
|
60913
61083
|
}
|
|
60914
61084
|
return merged;
|
|
60915
61085
|
}
|
|
60916
|
-
function carryPath(from, to,
|
|
60917
|
-
const [head, ...rest] =
|
|
61086
|
+
function carryPath(from, to, path64) {
|
|
61087
|
+
const [head, ...rest] = path64.split(".");
|
|
60918
61088
|
if (head === void 0)
|
|
60919
61089
|
return;
|
|
60920
61090
|
const source = from[head];
|
|
@@ -62373,6 +62543,11 @@ var PythonManager = class {
|
|
|
62373
62543
|
* declaration would be the setting not working.
|
|
62374
62544
|
*/
|
|
62375
62545
|
...this.jupyterConnectionFile !== void 0 ? { [JUPYTER_CONNECTION_ENV]: this.jupyterConnectionFile } : {},
|
|
62546
|
+
/*
|
|
62547
|
+
* A native crash - "python.exe has stopped working" - prints the Python stack it happened in to stderr, which
|
|
62548
|
+
* the worker keeps and reports. Without it the only trace was Windows' dialog. A user setting wins.
|
|
62549
|
+
*/
|
|
62550
|
+
PYTHONFAULTHANDLER: "1",
|
|
62376
62551
|
...resolved.env,
|
|
62377
62552
|
// Last, so nothing declared in python.env can replace the list the worker enforces.
|
|
62378
62553
|
LIGHT_CODE_BANNED_CALLS: JSON.stringify(this.bannedCalls)
|
|
@@ -62964,6 +63139,8 @@ async function consumeStream(provider, messages, streamOptions, stallSeconds, ev
|
|
|
62964
63139
|
} else if (chunk.type === "toolCall") {
|
|
62965
63140
|
if (outcome.toolCall === void 0)
|
|
62966
63141
|
outcome.toolCall = chunk.toolCall;
|
|
63142
|
+
} else if (chunk.type === "usage") {
|
|
63143
|
+
outcome.usage = { inputTokens: chunk.inputTokens, ...chunk.outputTokens !== void 0 ? { outputTokens: chunk.outputTokens } : {}, ...chunk.cachedTokens !== void 0 ? { cachedTokens: chunk.cachedTokens } : {} };
|
|
62967
63144
|
} else if (chunk.type === "error") {
|
|
62968
63145
|
outcome.error = chunk.error;
|
|
62969
63146
|
} else if (chunk.type === "done") {
|
|
@@ -62982,11 +63159,12 @@ var MAX_REFUNDED_STEPS = 20;
|
|
|
62982
63159
|
var FORM_DISMISSED = "The user dismissed the form without answering.";
|
|
62983
63160
|
var MAX_FORM_RESETS = 5;
|
|
62984
63161
|
var MAX_CONSECUTIVE_MISTAKES = 3;
|
|
62985
|
-
async function prepareModelMessages(conversation, provider, tools, options, events) {
|
|
63162
|
+
async function prepareModelMessages(conversation, provider, tools, options, events, meter) {
|
|
62986
63163
|
const contextWindow = options.contextWindow ?? 0;
|
|
63164
|
+
const ratio = calibrationFor(options.usageKey ?? "");
|
|
62987
63165
|
let messages = repairUnansweredToolCalls(conversation.toModelMessages());
|
|
62988
63166
|
if (options.compactionEnabled !== false && options.autoCompact !== false && contextWindow > 0 && options.contextWindowKnown !== false) {
|
|
62989
|
-
const estimated = computeBreakdown(messages, tools, contextWindow).total;
|
|
63167
|
+
const estimated = scaleBreakdown(computeBreakdown(messages, tools, contextWindow), ratio).total;
|
|
62990
63168
|
if (shouldCompact(messages, estimated, contextWindow, options.compaction ?? {})) {
|
|
62991
63169
|
const result = await compactHistory(messages, provider, {
|
|
62992
63170
|
// Keep recent history by size as well as by count, so a long window keeps a long tail.
|
|
@@ -63005,8 +63183,13 @@ async function prepareModelMessages(conversation, provider, tools, options, even
|
|
|
63005
63183
|
}
|
|
63006
63184
|
const superseded = dropSupersededReads(messages);
|
|
63007
63185
|
const evicted = dropEvictedDocs(superseded.messages);
|
|
63008
|
-
const
|
|
63009
|
-
|
|
63186
|
+
const raw = computeBreakdown(evicted.messages, tools, contextWindow);
|
|
63187
|
+
if (meter !== void 0) {
|
|
63188
|
+
meter.estimated = raw.total;
|
|
63189
|
+
meter.breakdown = raw;
|
|
63190
|
+
meter.dropped = superseded.supersededCount + evicted.evictedCount;
|
|
63191
|
+
}
|
|
63192
|
+
events.onContextUpdate?.(scaleBreakdown(raw, ratio), superseded.supersededCount + evicted.evictedCount, conversation.compactedCount());
|
|
63010
63193
|
return evicted.messages;
|
|
63011
63194
|
}
|
|
63012
63195
|
function unwrapDispatch(toolCall) {
|
|
@@ -63181,7 +63364,8 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
63181
63364
|
const streamOptions = { tools };
|
|
63182
63365
|
if (options.signal !== void 0)
|
|
63183
63366
|
streamOptions.signal = options.signal;
|
|
63184
|
-
const
|
|
63367
|
+
const meter = { estimated: 0, dropped: 0 };
|
|
63368
|
+
const modelMessages = await prepareModelMessages(conversation, provider, tools, options, events, meter);
|
|
63185
63369
|
const stallSeconds = options.stallSeconds ?? DEFAULT_STALL_SECONDS;
|
|
63186
63370
|
const maxRetries = Math.max(0, options.retries ?? DEFAULT_RETRIES);
|
|
63187
63371
|
const cancelled = () => options.signal?.aborted === true;
|
|
@@ -63202,6 +63386,17 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
63202
63386
|
const assistantText = outcome.text;
|
|
63203
63387
|
const toolCall = outcome.toolCall;
|
|
63204
63388
|
let streamError = outcome.error;
|
|
63389
|
+
const reportedInput = outcome.usage?.inputTokens ?? (streamError !== void 0 && isContextOverflow(streamError) ? promptTokensFromError(streamError) : void 0);
|
|
63390
|
+
if (reportedInput !== void 0 && meter.breakdown !== void 0) {
|
|
63391
|
+
calibrate(options.usageKey ?? "", meter.estimated, reportedInput);
|
|
63392
|
+
events.onContextUpdate?.(applyReportedUsage(meter.breakdown, { inputTokens: reportedInput }), meter.dropped, conversation.compactedCount());
|
|
63393
|
+
}
|
|
63394
|
+
if (outcome.usage !== void 0) {
|
|
63395
|
+
events.onUsage?.({ inputTokens: outcome.usage.inputTokens, outputTokens: outcome.usage.outputTokens ?? estimateTokens(assistantText), ...outcome.usage.cachedTokens !== void 0 ? { cachedTokens: outcome.usage.cachedTokens } : {}, estimated: outcome.usage.outputTokens === void 0 });
|
|
63396
|
+
} else if (streamError === void 0 && meter.breakdown !== void 0) {
|
|
63397
|
+
const output = estimateTokens(assistantText) + (toolCall !== void 0 ? estimateTokens(toolCall.name + toolCall.arguments) : 0);
|
|
63398
|
+
events.onUsage?.({ inputTokens: scaleBreakdown(meter.breakdown, calibrationFor(options.usageKey ?? "")).total, outputTokens: output, estimated: true });
|
|
63399
|
+
}
|
|
63205
63400
|
if (outcome.stalled && !cancelled()) {
|
|
63206
63401
|
streamError = `${stallDescription(stallSeconds)}, so the request was stopped` + (maxRetries > 0 ? ` (tried ${String(maxRetries + 1)} times)` : "") + '. The gateway may be overloaded, or the connection dropped without saying so. Send your message again to retry. If this model genuinely thinks for longer than that without streaming anything, raise "Give up on a silent reply after" in Settings \u2192 Approvals.';
|
|
63207
63402
|
}
|
|
@@ -63445,7 +63640,7 @@ function gatewayFromSettings(input, stored) {
|
|
|
63445
63640
|
|
|
63446
63641
|
// ../../packages/core/dist/host/bridge.js
|
|
63447
63642
|
var import_node_fs11 = require("node:fs");
|
|
63448
|
-
var
|
|
63643
|
+
var import_node_child_process16 = require("node:child_process");
|
|
63449
63644
|
var import_promises29 = __toESM(require("node:fs/promises"), 1);
|
|
63450
63645
|
|
|
63451
63646
|
// ../../packages/core/dist/jupyter/spec.js
|
|
@@ -65021,11 +65216,12 @@ var import_node_crypto12 = require("node:crypto");
|
|
|
65021
65216
|
var import_node_fs5 = require("node:fs");
|
|
65022
65217
|
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
65023
65218
|
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
65219
|
+
var isTokenEvent = (event) => event.k === "tokens";
|
|
65024
65220
|
function isUsageEvent(value) {
|
|
65025
65221
|
if (value === null || typeof value !== "object")
|
|
65026
65222
|
return false;
|
|
65027
65223
|
const event = value;
|
|
65028
|
-
return typeof event["t"] === "number" && typeof event["u"] === "string" && (event["k"] === "skill" || event["k"] === "tool") && typeof event["n"] === "string";
|
|
65224
|
+
return typeof event["t"] === "number" && typeof event["u"] === "string" && (event["k"] === "skill" || event["k"] === "tool" || event["k"] === "tokens") && typeof event["n"] === "string";
|
|
65029
65225
|
}
|
|
65030
65226
|
function parseUsageLines(text2) {
|
|
65031
65227
|
const events = [];
|
|
@@ -66028,7 +66224,7 @@ function pick2(hubs, name) {
|
|
|
66028
66224
|
// ../../packages/core/dist/host/bridge.js
|
|
66029
66225
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
66030
66226
|
var import_node_fs12 = require("node:fs");
|
|
66031
|
-
var
|
|
66227
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
66032
66228
|
|
|
66033
66229
|
// ../../packages/core/dist/modes/autoGuidance.js
|
|
66034
66230
|
function idiomsFor(environment) {
|
|
@@ -66351,6 +66547,7 @@ function fastFsCapabilities(exe, timeoutMs = 5e3) {
|
|
|
66351
66547
|
done(void 0);
|
|
66352
66548
|
}
|
|
66353
66549
|
});
|
|
66550
|
+
child.stdin.on("error", () => void 0);
|
|
66354
66551
|
child.stdin.end(JSON.stringify({ op: "capabilities" }));
|
|
66355
66552
|
});
|
|
66356
66553
|
}
|
|
@@ -66448,6 +66645,7 @@ function runHelper(exe, request, signal) {
|
|
|
66448
66645
|
reject2(new Error(`The file helper gave no answer${err.length > 0 ? `: ${err.slice(0, 300)}` : "."}`));
|
|
66449
66646
|
}
|
|
66450
66647
|
});
|
|
66648
|
+
child.stdin.on("error", () => void 0);
|
|
66451
66649
|
child.stdin.end(JSON.stringify(request));
|
|
66452
66650
|
});
|
|
66453
66651
|
}
|
|
@@ -67789,6 +67987,7 @@ function negotiateRequest(request, signal) {
|
|
|
67789
67987
|
}
|
|
67790
67988
|
resolve({ status: answer.status ?? 0, headers: answer.headers ?? {}, body: Buffer.from(answer.body ?? "", "base64") });
|
|
67791
67989
|
});
|
|
67990
|
+
child.stdin.on("error", () => void 0);
|
|
67792
67991
|
child.stdin.end(JSON.stringify(request));
|
|
67793
67992
|
});
|
|
67794
67993
|
}
|
|
@@ -67926,8 +68125,8 @@ var ChangeLedger = class {
|
|
|
67926
68125
|
this.chat = chat;
|
|
67927
68126
|
}
|
|
67928
68127
|
/** Best effort: a ledger that cannot be written must never fail an edit that happened. */
|
|
67929
|
-
record(
|
|
67930
|
-
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(
|
|
68128
|
+
record(path64) {
|
|
68129
|
+
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(path64), at: Date.now() });
|
|
67931
68130
|
void (0, import_promises23.appendFile)(this.file, `${line}
|
|
67932
68131
|
`).catch(() => void 0);
|
|
67933
68132
|
}
|
|
@@ -70728,6 +70927,7 @@ var OfficeBridge = class {
|
|
|
70728
70927
|
child.stderr?.on("data", (chunk) => {
|
|
70729
70928
|
this.options.logger.warn(`office worker: ${String(chunk).trim().slice(0, 500)}`);
|
|
70730
70929
|
});
|
|
70930
|
+
child.stdin?.on("error", () => void 0);
|
|
70731
70931
|
child.on("exit", (code) => {
|
|
70732
70932
|
if (this.child !== child)
|
|
70733
70933
|
return;
|
|
@@ -72274,10 +72474,10 @@ function isSafeSegment(value) {
|
|
|
72274
72474
|
function isSafeTagName(name) {
|
|
72275
72475
|
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("."));
|
|
72276
72476
|
}
|
|
72277
|
-
function encodeRepoPath(
|
|
72278
|
-
const segments =
|
|
72477
|
+
function encodeRepoPath(path64) {
|
|
72478
|
+
const segments = path64.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0);
|
|
72279
72479
|
if (segments.length === 0 || segments.some((segment) => segment === ".." || segment === ".")) {
|
|
72280
|
-
throw new AtlassianError(`"${
|
|
72480
|
+
throw new AtlassianError(`"${path64}" is not a file path inside the repository.`);
|
|
72281
72481
|
}
|
|
72282
72482
|
return segments.map(encodeURIComponent).join("/");
|
|
72283
72483
|
}
|
|
@@ -72362,24 +72562,24 @@ var BitbucketClient = class {
|
|
|
72362
72562
|
* redirect was followed, the login page came back, and the file "could not be read" although
|
|
72363
72563
|
* pull requests on the same repository could. `browse` is REST, so it authenticates like those.
|
|
72364
72564
|
*/
|
|
72365
|
-
async file(repo,
|
|
72366
|
-
const target = encodeRepoPath(
|
|
72565
|
+
async file(repo, path64, ref, signal) {
|
|
72566
|
+
const target = encodeRepoPath(path64);
|
|
72367
72567
|
const lines2 = [];
|
|
72368
72568
|
let start = 0;
|
|
72369
72569
|
for (let page = 0; page < MAX_FILE_PAGES; page += 1) {
|
|
72370
72570
|
const query = new URLSearchParams({ start: String(start), limit: String(FILE_PAGE_LINES) });
|
|
72371
72571
|
if (ref !== void 0 && ref.length > 0)
|
|
72372
72572
|
query.set("at", ref);
|
|
72373
|
-
const body = await this.rest.json(`reading ${
|
|
72573
|
+
const body = await this.rest.json(`reading ${path64}`, `${this.repoPath(repo)}/browse/${target}?${query.toString()}`, { method: "GET" }, signal);
|
|
72374
72574
|
if (body.children !== void 0) {
|
|
72375
72575
|
const names = (body.children.values ?? []).map((child) => {
|
|
72376
72576
|
const name = child.path?.toString ?? child.path?.name ?? "?";
|
|
72377
72577
|
return child.type === "DIRECTORY" ? `${name}/` : name;
|
|
72378
72578
|
});
|
|
72379
|
-
throw new AtlassianError(`${
|
|
72579
|
+
throw new AtlassianError(`${path64} is a folder, not a file. It holds: ${names.join(", ") || "nothing"}.`);
|
|
72380
72580
|
}
|
|
72381
72581
|
if (body.binary === true)
|
|
72382
|
-
throw new AtlassianError(`${
|
|
72582
|
+
throw new AtlassianError(`${path64} is a binary file, so there is no text to read.`);
|
|
72383
72583
|
for (const line of body.lines ?? [])
|
|
72384
72584
|
lines2.push(line.text ?? "");
|
|
72385
72585
|
if (body.isLastPage !== false || body.nextPageStart === void 0 || body.nextPageStart <= start)
|
|
@@ -72402,6 +72602,27 @@ var BitbucketClient = class {
|
|
|
72402
72602
|
}
|
|
72403
72603
|
// --- A repository as a store of files: the team repository for skills and tools (`teamrepo/sync.ts`). ---
|
|
72404
72604
|
// Every call is REST under /rest/, so the personal access token authenticates it like the rest (no git, no web URL).
|
|
72605
|
+
/**
|
|
72606
|
+
* The commits that changed one file on a branch, newest first - who changed a team skill or tool, and when
|
|
72607
|
+
* (`sharing/provenance.ts`). Empty when the file is not in the repository.
|
|
72608
|
+
*/
|
|
72609
|
+
async fileCommits(repo, file2, branch, limit = 50, signal) {
|
|
72610
|
+
try {
|
|
72611
|
+
const page = await this.rest.json(`reading the history of ${file2}`, `${this.repoPath(repo)}/commits?${new URLSearchParams({ path: file2, until: `refs/heads/${branch}`, limit: String(limit) }).toString()}`, { method: "GET" }, signal);
|
|
72612
|
+
return (page.values ?? []).map((c2) => ({
|
|
72613
|
+
id: c2.displayId ?? (c2.id ?? "").slice(0, 11),
|
|
72614
|
+
by: c2.author?.displayName ?? c2.author?.name ?? "unknown",
|
|
72615
|
+
...c2.author?.emailAddress !== void 0 ? { email: c2.author.emailAddress } : {},
|
|
72616
|
+
at: Math.floor((c2.authorTimestamp ?? 0) / 1e3),
|
|
72617
|
+
// The first line: the subject of the commit.
|
|
72618
|
+
message: (c2.message ?? "").split(/\r?\n/)[0] ?? ""
|
|
72619
|
+
}));
|
|
72620
|
+
} catch (error51) {
|
|
72621
|
+
if (error51 instanceof AtlassianError && (error51.status === 404 || error51.status === 400))
|
|
72622
|
+
return [];
|
|
72623
|
+
throw error51;
|
|
72624
|
+
}
|
|
72625
|
+
}
|
|
72405
72626
|
/** The newest commit on a branch, or undefined when the branch does not exist. */
|
|
72406
72627
|
async branchHead(repo, branch, signal) {
|
|
72407
72628
|
try {
|
|
@@ -72469,9 +72690,9 @@ var BitbucketClient = class {
|
|
|
72469
72690
|
return out;
|
|
72470
72691
|
}
|
|
72471
72692
|
/** A file's bytes at `at`, or undefined when it is not there. */
|
|
72472
|
-
async readBytes(repo,
|
|
72693
|
+
async readBytes(repo, path64, at, signal) {
|
|
72473
72694
|
try {
|
|
72474
|
-
return await this.rest.bytes(`reading ${
|
|
72695
|
+
return await this.rest.bytes(`reading ${path64}`, `${this.repoPath(repo)}/raw/${encodeRepoPath(path64)}?${new URLSearchParams({ at }).toString()}`, signal);
|
|
72475
72696
|
} catch (error51) {
|
|
72476
72697
|
if (error51 instanceof AtlassianError && error51.status === 404)
|
|
72477
72698
|
return void 0;
|
|
@@ -73295,8 +73516,8 @@ ${text2.slice(-2e4)}`);
|
|
|
73295
73516
|
}
|
|
73296
73517
|
/** Queues a build, then follows the queue item briefly to learn its number. */
|
|
73297
73518
|
async startBuild(job, parameters, signal) {
|
|
73298
|
-
const
|
|
73299
|
-
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${
|
|
73519
|
+
const path64 = jobPath(job, this.base);
|
|
73520
|
+
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${path64}/buildWithParameters` : `${path64}/build`, parameters ?? {}, signal);
|
|
73300
73521
|
const location = response.headers["location"];
|
|
73301
73522
|
const queueId = location === void 0 ? void 0 : /\/queue\/item\/(\d+)/.exec(location)?.[1];
|
|
73302
73523
|
if (queueId === void 0)
|
|
@@ -73333,10 +73554,10 @@ ${text2.slice(-2e4)}`);
|
|
|
73333
73554
|
}
|
|
73334
73555
|
/** Creates a job from a whole config.xml, in the folder its name gives (`folder/sub/new-job`). */
|
|
73335
73556
|
async createJob(job, xml, signal) {
|
|
73336
|
-
const
|
|
73337
|
-
const cut =
|
|
73338
|
-
const parent =
|
|
73339
|
-
const name = decodeURIComponent(
|
|
73557
|
+
const path64 = jobPath(job, this.base);
|
|
73558
|
+
const cut = path64.lastIndexOf("/job/");
|
|
73559
|
+
const parent = path64.slice(0, cut);
|
|
73560
|
+
const name = decodeURIComponent(path64.slice(cut + "/job/".length));
|
|
73340
73561
|
await this.postBody(`creating ${job}`, `${parent}/createItem?${new URLSearchParams({ name }).toString()}`, xml, "application/xml", signal);
|
|
73341
73562
|
}
|
|
73342
73563
|
/** Replaces a job's config.xml. */
|
|
@@ -73649,14 +73870,14 @@ ${client.base}${jobPath(job, client.base)}/${buildRef(params3.build)}/`
|
|
|
73649
73870
|
};
|
|
73650
73871
|
return tool;
|
|
73651
73872
|
}
|
|
73652
|
-
async function readJenkinsfile(
|
|
73653
|
-
const resolved = await resolveToolPath(context,
|
|
73873
|
+
async function readJenkinsfile(path64, context) {
|
|
73874
|
+
const resolved = await resolveToolPath(context, path64);
|
|
73654
73875
|
if (!resolved.ok)
|
|
73655
73876
|
return { ok: false, message: resolved.message };
|
|
73656
73877
|
try {
|
|
73657
73878
|
return { ok: true, text: await context.fs.readFile(resolved.realPath), realPath: resolved.realPath };
|
|
73658
73879
|
} catch (error51) {
|
|
73659
|
-
return { ok: false, message: `Could not read ${
|
|
73880
|
+
return { ok: false, message: `Could not read ${path64}: ${error51 instanceof Error ? error51.message : String(error51)}` };
|
|
73660
73881
|
}
|
|
73661
73882
|
}
|
|
73662
73883
|
var checkSchema = external_exports.object({
|
|
@@ -74121,7 +74342,8 @@ function isAutosysName(name, pattern = false) {
|
|
|
74121
74342
|
function fill(template, values) {
|
|
74122
74343
|
return template.replace(/\{(filter:)?(\w+)\}/g, (_, filter, key3) => {
|
|
74123
74344
|
if (filter !== void 0) {
|
|
74124
|
-
|
|
74345
|
+
const value = values["pattern"] ?? values[key3] ?? values["job"] ?? "";
|
|
74346
|
+
return encodeURIComponent(`${key3}${value.includes("*") ? "=@" : "=="}${value}`);
|
|
74125
74347
|
}
|
|
74126
74348
|
return encodeURIComponent(values[key3] ?? "");
|
|
74127
74349
|
});
|
|
@@ -74431,9 +74653,9 @@ var AutosysClient = class _AutosysClient {
|
|
|
74431
74653
|
* Something this server may not offer at the documented address: undefined for a 404, so a tool can
|
|
74432
74654
|
* say which setting (`autosys.paths`) points elsewhere, rather than reporting "found nothing".
|
|
74433
74655
|
*/
|
|
74434
|
-
async optional(doing,
|
|
74656
|
+
async optional(doing, path64, signal) {
|
|
74435
74657
|
try {
|
|
74436
|
-
return asList(await this.rest.json(doing,
|
|
74658
|
+
return asList(await this.rest.json(doing, path64, { method: "GET" }, signal));
|
|
74437
74659
|
} catch (error51) {
|
|
74438
74660
|
if (error51 instanceof AtlassianError && error51.status === 404)
|
|
74439
74661
|
return void 0;
|
|
@@ -75736,13 +75958,13 @@ var MonitorHistoryStore = class {
|
|
|
75736
75958
|
if (!isSafeIndexName(index))
|
|
75737
75959
|
throw new MonitorHistoryError(`"${index}" is not a usable index name (lowercase letters, digits, - and _).`);
|
|
75738
75960
|
}
|
|
75739
|
-
async send(method,
|
|
75961
|
+
async send(method, path64, body) {
|
|
75740
75962
|
const headers = { "Content-Type": "application/json" };
|
|
75741
75963
|
const { username, password } = this.connection;
|
|
75742
75964
|
if (username !== void 0 && username.length > 0) {
|
|
75743
75965
|
headers.Authorization = `Basic ${Buffer.from(`${username}:${password ?? ""}`).toString("base64")}`;
|
|
75744
75966
|
}
|
|
75745
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${
|
|
75967
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}/${encodeURIComponent(this.index)}${path64}`;
|
|
75746
75968
|
const request = { method, headers };
|
|
75747
75969
|
if (body !== void 0)
|
|
75748
75970
|
request.body = JSON.stringify(body);
|
|
@@ -76155,7 +76377,7 @@ var createSchema2 = external_exports.object({
|
|
|
76155
76377
|
name: external_exports.string().describe('kebab-case, e.g. "overnight-batch" - the monitor and its skill file.'),
|
|
76156
76378
|
title: external_exports.string().describe('What the tile says, a few words: "Overnight batch".'),
|
|
76157
76379
|
summary: external_exports.string().describe("One sentence shown on hover: what it watches and what an alert means."),
|
|
76158
|
-
audience: external_exports.enum(["me", "team"]).optional().describe(`"me": a Personal monitor, only on this computer - always possible. "team": shown under Team alerts and shared where the team shares skills; needs the team's OpenSearch history (Settings \u2192 Monitoring). Left out: team when that history is set up, otherwise personal. Use "me"
|
|
76380
|
+
audience: external_exports.enum(["me", "team"]).optional().describe(`"me": a Personal monitor, only on this computer - always possible. "team": shown under Team alerts and shared where the team shares skills; needs the team's OpenSearch history (Settings \u2192 Monitoring). Left out: team when that history is set up, otherwise personal. Use "me" whenever the user says personal, private, just for me or similar - and a request worded that way is made personal whatever is passed.`),
|
|
76159
76381
|
every: external_exports.union([external_exports.string(), external_exports.number()]).optional().describe('How often to check: "5m", "15m", "1h", "1d" (one minute at least). Leave out when "at" gives the times instead; both together check at the times and in between.'),
|
|
76160
76382
|
at: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional().describe('Exact times of day: "07:30" for once a day, or ["07:30", "12:00", "18:00"]. Run on the "days" given, whatever activeHours says.'),
|
|
76161
76383
|
activeHours: external_exports.string().optional().describe('A run window for "every": "07:00-19:00" (past midnight is allowed), "09:00-" for not before nine, "-17:00" for until five.'),
|
|
@@ -76216,6 +76438,15 @@ function describeEvaluation(e) {
|
|
|
76216
76438
|
].join("\n");
|
|
76217
76439
|
}
|
|
76218
76440
|
var message2 = (error51) => error51 instanceof Error ? error51.message : String(error51);
|
|
76441
|
+
function askedAudience(text2) {
|
|
76442
|
+
const personal = /\b(personal|private|privately|just (for )?me|only (for )?me|for myself|my own|only on (this|my) (computer|machine|pc|laptop))\b/i.test(text2);
|
|
76443
|
+
const team = /\b(team|shared|for everyone|for the team|colleagues)\b/i.test(text2.replace(/\bteam (history|index|opensearch)\b/gi, ""));
|
|
76444
|
+
if (personal && !team)
|
|
76445
|
+
return "me";
|
|
76446
|
+
if (team && !personal)
|
|
76447
|
+
return "team";
|
|
76448
|
+
return void 0;
|
|
76449
|
+
}
|
|
76219
76450
|
function createMonitorCreateTool(options) {
|
|
76220
76451
|
const skillParams = (params3, block2, audience) => ({
|
|
76221
76452
|
name: params3.name,
|
|
@@ -76223,9 +76454,14 @@ function createMonitorCreateTool(options) {
|
|
|
76223
76454
|
body: monitorSkillBody(params3, block2),
|
|
76224
76455
|
audience
|
|
76225
76456
|
});
|
|
76226
|
-
const audienceFor = async (params3) => {
|
|
76457
|
+
const audienceFor = async (params3, context) => {
|
|
76458
|
+
const asked = askedAudience(context?.lastUserText?.() ?? "");
|
|
76459
|
+
if (asked === "me" && params3.audience !== "me")
|
|
76460
|
+
return { audience: "me", note: "Personal (only on this computer), as you asked." };
|
|
76227
76461
|
if (params3.audience !== void 0)
|
|
76228
76462
|
return { audience: params3.audience };
|
|
76463
|
+
if (asked === "team")
|
|
76464
|
+
return { audience: "team" };
|
|
76229
76465
|
try {
|
|
76230
76466
|
const listed = await options.channel.request("list");
|
|
76231
76467
|
if (listed.teamReady === true)
|
|
@@ -76260,7 +76496,7 @@ ${describeEvaluation(tried)}` };
|
|
|
76260
76496
|
return {
|
|
76261
76497
|
name: "monitor_create",
|
|
76262
76498
|
group: "edit",
|
|
76263
|
-
description: `Create or replace a Fire Code monitor: a check that runs on a schedule and shows on the Monitoring dashboard as a coloured tile, with a data grid whose cells or rows are coloured by alert rules, and Windows notifications at the levels the user chose. Before creating one: find an existing tool that returns the data (search_docs, or the tools you have) and reuse it; if none does, write a Python tool with create_python_tool from the template in monitor_check_tool, and run monitor_check_tool until it says PASS - then use the columns and key it gives. A SQLite database or CSV/Excel file needs no tool. Rules are judged by Fire Code itself on every check - no model is involved - so make them exact. ASK THE AUTHOR (ask_user_form, one field per rule plus a general one) what each alert means and what to do about it, unless they already said, and put it in each rule's "advice" and in "runbook": that is what an agent tells whoever meets the alert later. A team monitor needs the team's OpenSearch history set in Fire Code \u2192 Settings \u2192 Monitoring; without it the monitor is created personal (only on this computer), which always works - say so to the user.The user approves the skill file; the result shows what the first check found. ` + MONITOR_TOOL_FORMAT,
|
|
76499
|
+
description: `Create or replace a Fire Code monitor: a check that runs on a schedule and shows on the Monitoring dashboard as a coloured tile, with a data grid whose cells or rows are coloured by alert rules, and Windows notifications at the levels the user chose. Before creating one: find an existing tool that returns the data (search_docs, or the tools you have) and reuse it; if none does, write a Python tool with create_python_tool from the template in monitor_check_tool, and run monitor_check_tool until it says PASS - then use the columns and key it gives. A SQLite database or CSV/Excel file needs no tool. Rules are judged by Fire Code itself on every check - no model is involved - so make them exact. ASK THE AUTHOR (ask_user_form, one field per rule plus a general one) what each alert means and what to do about it, unless they already said, and put it in each rule's "advice" and in "runbook": that is what an agent tells whoever meets the alert later. A team monitor needs the team's OpenSearch history set in Fire Code \u2192 Settings \u2192 Monitoring; without it the monitor is created personal (only on this computer), which always works - say so to the user. The user approves the skill file; the result shows what the first check found. ` + MONITOR_TOOL_FORMAT,
|
|
76264
76500
|
parametersSchema: createSchema2,
|
|
76265
76501
|
async preview(params3, context) {
|
|
76266
76502
|
const block2 = monitorBlock(params3);
|
|
@@ -76272,7 +76508,7 @@ ${describeEvaluation(tried)}` };
|
|
|
76272
76508
|
${"tool" in params3.source ? `Run ${params3.source.tool}(${JSON.stringify(params3.source.args ?? {})})` : `Read ${JSON.stringify(params3.source)}`}`
|
|
76273
76509
|
};
|
|
76274
76510
|
}
|
|
76275
|
-
const { audience, note: forWhom } = await audienceFor(params3);
|
|
76511
|
+
const { audience, note: forWhom } = await audienceFor(params3, context);
|
|
76276
76512
|
const tried = await tryIt(block2, audience === "team");
|
|
76277
76513
|
if (!tried.ok) {
|
|
76278
76514
|
return { kind: "text", text: `This monitor cannot be created as written - nothing will be saved:
|
|
@@ -76287,7 +76523,7 @@ ${tried.error}` };
|
|
|
76287
76523
|
},
|
|
76288
76524
|
async execute(params3, context) {
|
|
76289
76525
|
const block2 = monitorBlock(params3);
|
|
76290
|
-
const { audience, note: forWhom } = params3.tryOnly === true ? { audience: "me", note: void 0 } : await audienceFor(params3);
|
|
76526
|
+
const { audience, note: forWhom } = params3.tryOnly === true ? { audience: "me", note: void 0 } : await audienceFor(params3, context);
|
|
76291
76527
|
const tried = await tryIt(block2, audience === "team");
|
|
76292
76528
|
if (!tried.ok)
|
|
76293
76529
|
return { content: `Not created: ${tried.error}`, isError: true };
|
|
@@ -77069,6 +77305,35 @@ async function repoFilesOf(options) {
|
|
|
77069
77305
|
}).map(([repoPath]) => repoPath).sort();
|
|
77070
77306
|
}
|
|
77071
77307
|
|
|
77308
|
+
// ../../packages/core/dist/sharing/provenance.js
|
|
77309
|
+
var import_node_child_process14 = require("node:child_process");
|
|
77310
|
+
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
77311
|
+
var SEPARATOR = "";
|
|
77312
|
+
function git2(args, cwd) {
|
|
77313
|
+
return new Promise((resolve) => {
|
|
77314
|
+
(0, import_node_child_process14.execFile)("git", [...args], { cwd, maxBuffer: 4 * 1024 * 1024, windowsHide: true, timeout: 15e3 }, (error51, stdout) => {
|
|
77315
|
+
resolve(error51 ? void 0 : stdout);
|
|
77316
|
+
});
|
|
77317
|
+
});
|
|
77318
|
+
}
|
|
77319
|
+
function parseGitLog(text2) {
|
|
77320
|
+
return text2.split(/\r?\n/).map((line) => line.split(SEPARATOR)).filter((parts) => parts.length >= 5 && parts[0] !== "").map(([id, by, email3, at, ...message5]) => ({ id: id ?? "", by: by ?? "", ...email3 ? { email: email3 } : {}, at: Number(at), message: message5.join(SEPARATOR) })).filter((c2) => Number.isFinite(c2.at));
|
|
77321
|
+
}
|
|
77322
|
+
async function gitFileHistory(file2, limit = 50) {
|
|
77323
|
+
const dir = import_node_path47.default.dirname(file2);
|
|
77324
|
+
const top = (await git2(["rev-parse", "--show-toplevel"], dir))?.trim();
|
|
77325
|
+
if (top === void 0 || top === "")
|
|
77326
|
+
return void 0;
|
|
77327
|
+
const log = await git2(["--no-optional-locks", "log", `-n${String(limit)}`, "--follow", `--format=%h${"%x1f"}%an${"%x1f"}%ae${"%x1f"}%at${"%x1f"}%s`, "--", import_node_path47.default.basename(file2)], dir);
|
|
77328
|
+
if (log === void 0)
|
|
77329
|
+
return void 0;
|
|
77330
|
+
const commits = parseGitLog(log);
|
|
77331
|
+
if (commits.length === 0)
|
|
77332
|
+
return void 0;
|
|
77333
|
+
const status2 = await git2(["--no-optional-locks", "status", "--porcelain", "--", import_node_path47.default.basename(file2)], dir);
|
|
77334
|
+
return { source: "git", commits, ...status2 !== void 0 && status2.trim() !== "" ? { uncommitted: true } : {}, where: import_node_path47.default.relative(top, file2).split(import_node_path47.default.sep).join("/") };
|
|
77335
|
+
}
|
|
77336
|
+
|
|
77072
77337
|
// ../../packages/core/dist/platform/httpTrace.js
|
|
77073
77338
|
var SECRET_NAME = /secret|password|passwd|token|api[-_]?key|assertion|credential|session|signature|cookie/i;
|
|
77074
77339
|
var MASK = "\u2022\u2022\u2022";
|
|
@@ -78721,7 +78986,7 @@ function message3(error51) {
|
|
|
78721
78986
|
}
|
|
78722
78987
|
function filesIn(params3) {
|
|
78723
78988
|
return [
|
|
78724
|
-
...(params3.attachments ?? []).map((
|
|
78989
|
+
...(params3.attachments ?? []).map((path64) => ({ path: path64, inline: false })),
|
|
78725
78990
|
...(params3.inlineImages ?? []).map((image) => ({ path: image.path, inline: true }))
|
|
78726
78991
|
];
|
|
78727
78992
|
}
|
|
@@ -79404,17 +79669,17 @@ var WebviewApprovalGate = class {
|
|
|
79404
79669
|
// ../../packages/core/dist/platform/node/filesystem.js
|
|
79405
79670
|
var import_promises27 = __toESM(require("node:fs/promises"), 1);
|
|
79406
79671
|
var NodeFileSystem = class {
|
|
79407
|
-
async readFile(
|
|
79408
|
-
return import_promises27.default.readFile(
|
|
79672
|
+
async readFile(path64) {
|
|
79673
|
+
return import_promises27.default.readFile(path64, "utf8");
|
|
79409
79674
|
}
|
|
79410
|
-
async readBytes(
|
|
79411
|
-
return import_promises27.default.readFile(
|
|
79675
|
+
async readBytes(path64) {
|
|
79676
|
+
return import_promises27.default.readFile(path64);
|
|
79412
79677
|
}
|
|
79413
|
-
async readBytesSlice(
|
|
79678
|
+
async readBytesSlice(path64, start, end) {
|
|
79414
79679
|
const length = Math.max(0, end - start);
|
|
79415
79680
|
if (length === 0)
|
|
79416
79681
|
return Buffer.alloc(0);
|
|
79417
|
-
const handle = await import_promises27.default.open(
|
|
79682
|
+
const handle = await import_promises27.default.open(path64, "r");
|
|
79418
79683
|
try {
|
|
79419
79684
|
const buffer = Buffer.alloc(length);
|
|
79420
79685
|
const { bytesRead } = await handle.read(buffer, 0, length, start);
|
|
@@ -79423,18 +79688,18 @@ var NodeFileSystem = class {
|
|
|
79423
79688
|
await handle.close();
|
|
79424
79689
|
}
|
|
79425
79690
|
}
|
|
79426
|
-
async writeFile(
|
|
79427
|
-
await import_promises27.default.writeFile(
|
|
79691
|
+
async writeFile(path64, contents) {
|
|
79692
|
+
await import_promises27.default.writeFile(path64, contents, "utf8");
|
|
79428
79693
|
}
|
|
79429
79694
|
/** The counterpart of `readBytes`, and deliberately as bare as `writeFile` beside it. */
|
|
79430
|
-
async writeBytes(
|
|
79431
|
-
await import_promises27.default.writeFile(
|
|
79695
|
+
async writeBytes(path64, contents) {
|
|
79696
|
+
await import_promises27.default.writeFile(path64, contents);
|
|
79432
79697
|
}
|
|
79433
79698
|
async rename(from, to) {
|
|
79434
79699
|
await replaceFile(from, to);
|
|
79435
79700
|
}
|
|
79436
|
-
async stat(
|
|
79437
|
-
const stat = await import_promises27.default.lstat(
|
|
79701
|
+
async stat(path64) {
|
|
79702
|
+
const stat = await import_promises27.default.lstat(path64);
|
|
79438
79703
|
return {
|
|
79439
79704
|
size: stat.size,
|
|
79440
79705
|
mtimeMs: stat.mtimeMs,
|
|
@@ -79443,8 +79708,8 @@ var NodeFileSystem = class {
|
|
|
79443
79708
|
isSymbolicLink: stat.isSymbolicLink()
|
|
79444
79709
|
};
|
|
79445
79710
|
}
|
|
79446
|
-
async readdir(
|
|
79447
|
-
const entries = await import_promises27.default.readdir(
|
|
79711
|
+
async readdir(path64) {
|
|
79712
|
+
const entries = await import_promises27.default.readdir(path64, { withFileTypes: true });
|
|
79448
79713
|
return entries.map((entry) => ({
|
|
79449
79714
|
name: entry.name,
|
|
79450
79715
|
isFile: entry.isFile(),
|
|
@@ -79452,21 +79717,21 @@ var NodeFileSystem = class {
|
|
|
79452
79717
|
isSymbolicLink: entry.isSymbolicLink()
|
|
79453
79718
|
}));
|
|
79454
79719
|
}
|
|
79455
|
-
async exists(
|
|
79720
|
+
async exists(path64) {
|
|
79456
79721
|
try {
|
|
79457
|
-
await import_promises27.default.access(
|
|
79722
|
+
await import_promises27.default.access(path64);
|
|
79458
79723
|
return true;
|
|
79459
79724
|
} catch {
|
|
79460
79725
|
return false;
|
|
79461
79726
|
}
|
|
79462
79727
|
}
|
|
79463
|
-
async mkdir(
|
|
79464
|
-
await import_promises27.default.mkdir(
|
|
79728
|
+
async mkdir(path64) {
|
|
79729
|
+
await import_promises27.default.mkdir(path64, { recursive: true });
|
|
79465
79730
|
}
|
|
79466
79731
|
};
|
|
79467
79732
|
|
|
79468
79733
|
// ../../packages/core/dist/config/project.js
|
|
79469
|
-
var
|
|
79734
|
+
var import_node_path48 = __toESM(require("node:path"), 1);
|
|
79470
79735
|
function configuredProjectName(config2) {
|
|
79471
79736
|
const name = config2?.project?.name?.trim();
|
|
79472
79737
|
return name !== void 0 && name.length > 0 ? name : void 0;
|
|
@@ -79475,7 +79740,7 @@ function projectName(config2, workspaceRoot) {
|
|
|
79475
79740
|
const configured = configuredProjectName(config2);
|
|
79476
79741
|
if (configured !== void 0)
|
|
79477
79742
|
return configured;
|
|
79478
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
79743
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path48.default.basename(import_node_path48.default.resolve(workspaceRoot));
|
|
79479
79744
|
}
|
|
79480
79745
|
function projectSlug(name) {
|
|
79481
79746
|
if (name === void 0)
|
|
@@ -79485,7 +79750,7 @@ function projectSlug(name) {
|
|
|
79485
79750
|
}
|
|
79486
79751
|
|
|
79487
79752
|
// ../../packages/core/dist/rag/renameIndexes.js
|
|
79488
|
-
var
|
|
79753
|
+
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
79489
79754
|
var import_node_fs8 = require("node:fs");
|
|
79490
79755
|
function planIndexRenames(names) {
|
|
79491
79756
|
const plans = [];
|
|
@@ -79549,7 +79814,7 @@ async function copyBookkeeping(directory, from, to, storeId) {
|
|
|
79549
79814
|
continue;
|
|
79550
79815
|
const target = `${to}@${storeId}.${entry.slice(prefix.length)}`;
|
|
79551
79816
|
try {
|
|
79552
|
-
await import_node_fs8.promises.copyFile(
|
|
79817
|
+
await import_node_fs8.promises.copyFile(import_node_path49.default.join(directory, entry), import_node_path49.default.join(directory, target), import_node_fs8.constants.COPYFILE_EXCL);
|
|
79553
79818
|
copied.push(target);
|
|
79554
79819
|
} catch {
|
|
79555
79820
|
}
|
|
@@ -79558,7 +79823,7 @@ async function copyBookkeeping(directory, from, to, storeId) {
|
|
|
79558
79823
|
}
|
|
79559
79824
|
|
|
79560
79825
|
// ../../packages/core/dist/platform/node/terminal.js
|
|
79561
|
-
var
|
|
79826
|
+
var import_node_child_process15 = require("node:child_process");
|
|
79562
79827
|
var NodeTerminalProcess = class {
|
|
79563
79828
|
child;
|
|
79564
79829
|
dataListeners = [];
|
|
@@ -79579,6 +79844,8 @@ var NodeTerminalProcess = class {
|
|
|
79579
79844
|
this.exitListeners.push(listener);
|
|
79580
79845
|
}
|
|
79581
79846
|
write(data) {
|
|
79847
|
+
if (this.child.stdin !== null && this.child.stdin.listenerCount("error") === 0)
|
|
79848
|
+
this.child.stdin.on("error", () => void 0);
|
|
79582
79849
|
this.child.stdin?.write(data);
|
|
79583
79850
|
}
|
|
79584
79851
|
/** `child.kill()` alone leaves grandchildren running — see CLAUDE.md §16. */
|
|
@@ -79588,7 +79855,7 @@ var NodeTerminalProcess = class {
|
|
|
79588
79855
|
return;
|
|
79589
79856
|
if (process.platform === "win32") {
|
|
79590
79857
|
await new Promise((resolve) => {
|
|
79591
|
-
(0,
|
|
79858
|
+
(0, import_node_child_process15.execFile)("taskkill", ["/PID", String(pid), "/T", "/F"], () => resolve());
|
|
79592
79859
|
});
|
|
79593
79860
|
return;
|
|
79594
79861
|
}
|
|
@@ -79623,7 +79890,7 @@ var NodeTerminal = class {
|
|
|
79623
79890
|
}
|
|
79624
79891
|
run(command, options = {}) {
|
|
79625
79892
|
const chosen = this.shell?.trim();
|
|
79626
|
-
const child = (0,
|
|
79893
|
+
const child = (0, import_node_child_process15.spawn)(command, {
|
|
79627
79894
|
cwd: options.cwd,
|
|
79628
79895
|
env: options.env ? { ...process.env, ...options.env } : process.env,
|
|
79629
79896
|
// `true` is Node's own default shell, which is what has always run. A string names one.
|
|
@@ -79636,7 +79903,7 @@ var NodeTerminal = class {
|
|
|
79636
79903
|
|
|
79637
79904
|
// ../../packages/core/dist/platform/node/taskStore.js
|
|
79638
79905
|
var import_promises28 = __toESM(require("node:fs/promises"), 1);
|
|
79639
|
-
var
|
|
79906
|
+
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
79640
79907
|
|
|
79641
79908
|
// ../../packages/core/dist/history/types.js
|
|
79642
79909
|
function taskSummary(task) {
|
|
@@ -79659,7 +79926,7 @@ var JsonTaskStore = class {
|
|
|
79659
79926
|
constructor(globalStoragePath, truncationStore, logger) {
|
|
79660
79927
|
this.truncationStore = truncationStore;
|
|
79661
79928
|
this.logger = logger;
|
|
79662
|
-
this.directory =
|
|
79929
|
+
this.directory = import_node_path50.default.join(globalStoragePath, "tasks");
|
|
79663
79930
|
}
|
|
79664
79931
|
async list(workspaceRoot) {
|
|
79665
79932
|
const index = await this.readIndex();
|
|
@@ -79708,11 +79975,11 @@ var JsonTaskStore = class {
|
|
|
79708
79975
|
await this.writeIndex(index.filter((entry) => entry.id !== id));
|
|
79709
79976
|
}
|
|
79710
79977
|
fileFor(id) {
|
|
79711
|
-
return
|
|
79978
|
+
return import_node_path50.default.join(this.directory, `${id}.json`);
|
|
79712
79979
|
}
|
|
79713
79980
|
async readIndex() {
|
|
79714
79981
|
try {
|
|
79715
|
-
const raw = await import_promises28.default.readFile(
|
|
79982
|
+
const raw = await import_promises28.default.readFile(import_node_path50.default.join(this.directory, INDEX_FILE), "utf8");
|
|
79716
79983
|
const parsed = JSON.parse(raw);
|
|
79717
79984
|
if (Array.isArray(parsed))
|
|
79718
79985
|
return parsed.filter(isIndexEntry);
|
|
@@ -79747,7 +80014,7 @@ var JsonTaskStore = class {
|
|
|
79747
80014
|
}
|
|
79748
80015
|
async writeIndex(entries) {
|
|
79749
80016
|
await import_promises28.default.mkdir(this.directory, { recursive: true });
|
|
79750
|
-
const target =
|
|
80017
|
+
const target = import_node_path50.default.join(this.directory, INDEX_FILE);
|
|
79751
80018
|
const temporary = `${target}.tmp`;
|
|
79752
80019
|
await import_promises28.default.writeFile(temporary, JSON.stringify(entries, null, 2), "utf8");
|
|
79753
80020
|
await replaceFile(temporary, target);
|
|
@@ -79779,7 +80046,7 @@ function parseTask(raw) {
|
|
|
79779
80046
|
|
|
79780
80047
|
// ../../packages/core/dist/usage/store.js
|
|
79781
80048
|
var import_node_fs9 = require("node:fs");
|
|
79782
|
-
var
|
|
80049
|
+
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
79783
80050
|
|
|
79784
80051
|
// ../../packages/core/dist/s3/keys.js
|
|
79785
80052
|
function normalisePrefix(prefix) {
|
|
@@ -79912,7 +80179,7 @@ var FolderShardStore = class {
|
|
|
79912
80179
|
await this.ask({ action: "write", user: shardSegment(shard.user), day: shard.day, instance: shard.instance, events });
|
|
79913
80180
|
return;
|
|
79914
80181
|
}
|
|
79915
|
-
await this.writeAtomically(
|
|
80182
|
+
await this.writeAtomically(import_node_path51.default.join(this.root, shardSegment(shard.user), `${shard.day}__${shard.instance}.jsonl`), shardText(events));
|
|
79916
80183
|
}
|
|
79917
80184
|
async read(fromDay, toDay) {
|
|
79918
80185
|
this.lastProblems = [];
|
|
@@ -79932,8 +80199,8 @@ var FolderShardStore = class {
|
|
|
79932
80199
|
}
|
|
79933
80200
|
const files = await this.listFiles();
|
|
79934
80201
|
const wanted = selectShards(files, fromDay, toDay);
|
|
79935
|
-
const texts = await pooled(wanted, 8, (file2) => import_node_fs9.promises.readFile(
|
|
79936
|
-
this.lastProblems.push(`${
|
|
80202
|
+
const texts = await pooled(wanted, 8, (file2) => import_node_fs9.promises.readFile(import_node_path51.default.join(this.root, file2.user, file2.name), "utf8").catch((error51) => {
|
|
80203
|
+
this.lastProblems.push(`${import_node_path51.default.join(this.root, file2.user, file2.name)}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
79937
80204
|
return "";
|
|
79938
80205
|
}));
|
|
79939
80206
|
return texts.flatMap(parseUsageLines);
|
|
@@ -79950,7 +80217,7 @@ var FolderShardStore = class {
|
|
|
79950
80217
|
}
|
|
79951
80218
|
const files = [];
|
|
79952
80219
|
for (const user of users) {
|
|
79953
|
-
const folder =
|
|
80220
|
+
const folder = import_node_path51.default.join(this.root, user);
|
|
79954
80221
|
let names;
|
|
79955
80222
|
try {
|
|
79956
80223
|
names = await import_node_fs9.promises.readdir(folder);
|
|
@@ -79969,7 +80236,7 @@ var FolderShardStore = class {
|
|
|
79969
80236
|
}
|
|
79970
80237
|
async readShard(shard) {
|
|
79971
80238
|
try {
|
|
79972
|
-
return parseUsageLines(await import_node_fs9.promises.readFile(
|
|
80239
|
+
return parseUsageLines(await import_node_fs9.promises.readFile(import_node_path51.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), "utf8"));
|
|
79973
80240
|
} catch (error51) {
|
|
79974
80241
|
if (error51.code === "ENOENT")
|
|
79975
80242
|
return void 0;
|
|
@@ -79977,10 +80244,10 @@ var FolderShardStore = class {
|
|
|
79977
80244
|
}
|
|
79978
80245
|
}
|
|
79979
80246
|
async putMonth(shard, events) {
|
|
79980
|
-
await this.writeAtomically(
|
|
80247
|
+
await this.writeAtomically(import_node_path51.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), shardText(events));
|
|
79981
80248
|
}
|
|
79982
80249
|
async removeShard(shard) {
|
|
79983
|
-
await import_node_fs9.promises.rm(
|
|
80250
|
+
await import_node_fs9.promises.rm(import_node_path51.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), { force: true });
|
|
79984
80251
|
}
|
|
79985
80252
|
async putProfile(user, profile) {
|
|
79986
80253
|
this.profilesFromRead = void 0;
|
|
@@ -79988,7 +80255,7 @@ var FolderShardStore = class {
|
|
|
79988
80255
|
await this.ask({ action: "writeProfile", user: shardSegment(user), profile: cleanProfile(profile) });
|
|
79989
80256
|
return;
|
|
79990
80257
|
}
|
|
79991
|
-
await this.writeAtomically(
|
|
80258
|
+
await this.writeAtomically(import_node_path51.default.join(this.root, "_profiles", `${shardSegment(user)}.json`), JSON.stringify(cleanProfile(profile)));
|
|
79992
80259
|
}
|
|
79993
80260
|
async readProfiles() {
|
|
79994
80261
|
if (this.profilesFromRead !== void 0)
|
|
@@ -79997,13 +80264,13 @@ var FolderShardStore = class {
|
|
|
79997
80264
|
await this.read("9999-12-31", "9999-12-31");
|
|
79998
80265
|
return this.profilesFromRead ?? {};
|
|
79999
80266
|
}
|
|
80000
|
-
const folder =
|
|
80267
|
+
const folder = import_node_path51.default.join(this.root, "_profiles");
|
|
80001
80268
|
const profiles = {};
|
|
80002
80269
|
for (const name of await import_node_fs9.promises.readdir(folder).catch(() => [])) {
|
|
80003
80270
|
if (!name.endsWith(".json"))
|
|
80004
80271
|
continue;
|
|
80005
80272
|
try {
|
|
80006
|
-
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs9.promises.readFile(
|
|
80273
|
+
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs9.promises.readFile(import_node_path51.default.join(folder, name), "utf8")));
|
|
80007
80274
|
} catch {
|
|
80008
80275
|
}
|
|
80009
80276
|
}
|
|
@@ -80287,6 +80554,69 @@ async function rollUpMonths(options) {
|
|
|
80287
80554
|
// ../../packages/core/dist/usage/dashboard.js
|
|
80288
80555
|
var HOUR = 36e5;
|
|
80289
80556
|
var DAY = 24 * HOUR;
|
|
80557
|
+
var zeroTokens = () => ({ input: 0, output: 0, cached: 0, requests: 0 });
|
|
80558
|
+
function addTokens(into, event) {
|
|
80559
|
+
into.input += event.i ?? 0;
|
|
80560
|
+
into.output += event.o ?? 0;
|
|
80561
|
+
into.cached += event.c ?? 0;
|
|
80562
|
+
into.requests += 1;
|
|
80563
|
+
}
|
|
80564
|
+
function tokenStats(events, o) {
|
|
80565
|
+
const inScope = (event) => o.scope === "team" || event.u === o.me;
|
|
80566
|
+
const current = events.filter((event) => event.t >= o.from && event.t <= o.to && inScope(event));
|
|
80567
|
+
const total = zeroTokens();
|
|
80568
|
+
const previous = zeroTokens();
|
|
80569
|
+
for (const event of events)
|
|
80570
|
+
if (event.t >= o.previousFrom && event.t < o.from && inScope(event))
|
|
80571
|
+
addTokens(previous, event);
|
|
80572
|
+
const people = /* @__PURE__ */ new Map();
|
|
80573
|
+
const models = /* @__PURE__ */ new Map();
|
|
80574
|
+
const timeline = o.starts.map((start) => ({ start, input: 0, output: 0 }));
|
|
80575
|
+
let estimated = 0;
|
|
80576
|
+
for (const event of current) {
|
|
80577
|
+
addTokens(total, event);
|
|
80578
|
+
if (event.e === 1)
|
|
80579
|
+
estimated += 1;
|
|
80580
|
+
let person = people.get(event.u);
|
|
80581
|
+
if (person === void 0) {
|
|
80582
|
+
person = { ...zeroTokens(), lastActive: 0, spark: new Array(o.starts.length).fill(0), models: /* @__PURE__ */ new Set() };
|
|
80583
|
+
people.set(event.u, person);
|
|
80584
|
+
}
|
|
80585
|
+
addTokens(person, event);
|
|
80586
|
+
person.lastActive = Math.max(person.lastActive, event.t);
|
|
80587
|
+
person.models.add(event.n);
|
|
80588
|
+
const at = bucketIndex(o.starts, event.t);
|
|
80589
|
+
person.spark[at] = (person.spark[at] ?? 0) + (event.i ?? 0) + (event.o ?? 0);
|
|
80590
|
+
const bucket = timeline[at];
|
|
80591
|
+
if (bucket !== void 0) {
|
|
80592
|
+
bucket.input += event.i ?? 0;
|
|
80593
|
+
bucket.output += event.o ?? 0;
|
|
80594
|
+
}
|
|
80595
|
+
const model = models.get(event.n) ?? zeroTokens();
|
|
80596
|
+
addTokens(model, event);
|
|
80597
|
+
models.set(event.n, model);
|
|
80598
|
+
}
|
|
80599
|
+
const grand = total.input + total.output;
|
|
80600
|
+
return {
|
|
80601
|
+
total,
|
|
80602
|
+
previous,
|
|
80603
|
+
estimatedShare: current.length === 0 ? 0 : estimated / current.length,
|
|
80604
|
+
people: [...people.entries()].map(([user, p]) => ({
|
|
80605
|
+
user,
|
|
80606
|
+
...o.who(user),
|
|
80607
|
+
input: p.input,
|
|
80608
|
+
output: p.output,
|
|
80609
|
+
cached: p.cached,
|
|
80610
|
+
requests: p.requests,
|
|
80611
|
+
share: grand === 0 ? 0 : (p.input + p.output) / grand,
|
|
80612
|
+
lastActive: p.lastActive,
|
|
80613
|
+
spark: p.spark,
|
|
80614
|
+
models: [...p.models].sort()
|
|
80615
|
+
})).sort((a, b) => b.input + b.output - (a.input + a.output)),
|
|
80616
|
+
models: [...models.entries()].map(([model, m]) => ({ model, ...m })).sort((a, b) => b.input + b.output - (a.input + a.output)),
|
|
80617
|
+
timeline
|
|
80618
|
+
};
|
|
80619
|
+
}
|
|
80290
80620
|
var toolLabel = (name) => name.startsWith("py__") ? name.slice(4) : name;
|
|
80291
80621
|
function bucketUnit(span) {
|
|
80292
80622
|
if (span <= 2 * DAY)
|
|
@@ -80365,7 +80695,9 @@ function count2(events) {
|
|
|
80365
80695
|
}
|
|
80366
80696
|
return { uses: events.length, skillUses, toolUses, failures, people: people.size, skillsUsed: skills.size, toolsUsed: tools.size };
|
|
80367
80697
|
}
|
|
80368
|
-
function computeDashboard(
|
|
80698
|
+
function computeDashboard(given) {
|
|
80699
|
+
const tokenEvents = given.events.filter(isTokenEvent);
|
|
80700
|
+
const input = { ...given, events: given.events.filter((event) => !isTokenEvent(event)) };
|
|
80369
80701
|
const { from, to, scope, me } = input;
|
|
80370
80702
|
const profileOf = (user) => input.profiles?.[shardSegment(user)] ?? input.profiles?.[shardSegment(user).toLowerCase()];
|
|
80371
80703
|
const who = (user) => {
|
|
@@ -80414,7 +80746,7 @@ function computeDashboard(input) {
|
|
|
80414
80746
|
const item = installed.get(inventoryKey(event));
|
|
80415
80747
|
const author = event.a ?? item?.author;
|
|
80416
80748
|
entry = {
|
|
80417
|
-
kind: event.k,
|
|
80749
|
+
kind: event.k === "skill" ? "skill" : "tool",
|
|
80418
80750
|
name: event.n,
|
|
80419
80751
|
label: event.k === "tool" ? toolLabel(event.n) : event.n,
|
|
80420
80752
|
uses: 0,
|
|
@@ -80578,6 +80910,7 @@ function computeDashboard(input) {
|
|
|
80578
80910
|
const topSkill = [...entry.skills.entries()].sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
80579
80911
|
return { team, people: entry.people.size, uses: entry.uses, skillUses: entry.skillUses, ...topSkill !== void 0 ? { topSkill } : {} };
|
|
80580
80912
|
}).sort((a, b) => b.uses - a.uses);
|
|
80913
|
+
const tokens = tokenStats(tokenEvents, { from, to, previousFrom, scope, me, starts, who });
|
|
80581
80914
|
return {
|
|
80582
80915
|
scope,
|
|
80583
80916
|
me,
|
|
@@ -80609,7 +80942,8 @@ function computeDashboard(input) {
|
|
|
80609
80942
|
tools: input.inventory.filter((item) => item.kind === "tool").length,
|
|
80610
80943
|
authors: new Set(input.inventory.map((item) => item.author).filter((author) => author !== void 0)).size
|
|
80611
80944
|
},
|
|
80612
|
-
eventsInStore: allInRange.length
|
|
80945
|
+
eventsInStore: allInRange.length,
|
|
80946
|
+
tokens
|
|
80613
80947
|
};
|
|
80614
80948
|
}
|
|
80615
80949
|
function asProblemItem(item, note) {
|
|
@@ -80752,7 +81086,7 @@ function usageCollectionOn(config2, choice) {
|
|
|
80752
81086
|
|
|
80753
81087
|
// ../../packages/core/dist/usage/backfill.js
|
|
80754
81088
|
var import_node_fs10 = require("node:fs");
|
|
80755
|
-
var
|
|
81089
|
+
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
80756
81090
|
function comparablePath(value) {
|
|
80757
81091
|
return value.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
80758
81092
|
}
|
|
@@ -80762,7 +81096,7 @@ function eventsFromTask(task, context) {
|
|
|
80762
81096
|
return [];
|
|
80763
81097
|
const created = typeof task.createdAt === "number" && task.createdAt <= updated ? task.createdAt : updated;
|
|
80764
81098
|
const root = typeof task.workspaceRoot === "string" ? task.workspaceRoot : void 0;
|
|
80765
|
-
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ?
|
|
81099
|
+
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ? import_node_path52.default.basename(root.replace(/\\/g, "/")) : void 0;
|
|
80766
81100
|
const skillsByPath = new Map(context.skills.map((skill) => [comparablePath(skill.filePath), skill]));
|
|
80767
81101
|
const skip = new Set(context.skip);
|
|
80768
81102
|
const calls = [];
|
|
@@ -80799,7 +81133,7 @@ function eventsFromTask(task, context) {
|
|
|
80799
81133
|
let skill;
|
|
80800
81134
|
if (call.name === "read_file" && typeof call.args["path"] === "string") {
|
|
80801
81135
|
const requested2 = call.args["path"];
|
|
80802
|
-
const absolute =
|
|
81136
|
+
const absolute = import_node_path52.default.isAbsolute(requested2) || /^[A-Za-z]:[\\/]/.test(requested2) || root === void 0 ? requested2 : import_node_path52.default.join(root, requested2);
|
|
80803
81137
|
skill = skillsByPath.get(comparablePath(absolute));
|
|
80804
81138
|
}
|
|
80805
81139
|
if (call.name === "use_skill_file" && typeof call.args["skill"] === "string") {
|
|
@@ -80844,7 +81178,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
80844
81178
|
let unreadable = 0;
|
|
80845
81179
|
for (const name of names) {
|
|
80846
81180
|
try {
|
|
80847
|
-
events.push(...eventsFromTask(JSON.parse(await import_node_fs10.promises.readFile(
|
|
81181
|
+
events.push(...eventsFromTask(JSON.parse(await import_node_fs10.promises.readFile(import_node_path52.default.join(tasksDir, name), "utf8")), context));
|
|
80848
81182
|
} catch {
|
|
80849
81183
|
unreadable++;
|
|
80850
81184
|
}
|
|
@@ -80852,13 +81186,13 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
80852
81186
|
return { events, tasks: names.length, unreadable, via: "node" };
|
|
80853
81187
|
}
|
|
80854
81188
|
async function backfillOnce(options) {
|
|
80855
|
-
const doneFile =
|
|
81189
|
+
const doneFile = import_node_path52.default.join(options.usageDir, "backfill.json");
|
|
80856
81190
|
for (const file2 of [doneFile, ...options.legacyDoneFile !== void 0 ? [options.legacyDoneFile] : []]) {
|
|
80857
81191
|
if (await import_node_fs10.promises.stat(file2).then(() => true, () => false))
|
|
80858
81192
|
return { ran: false };
|
|
80859
81193
|
}
|
|
80860
81194
|
await import_node_fs10.promises.mkdir(options.usageDir, { recursive: true });
|
|
80861
|
-
const startFile =
|
|
81195
|
+
const startFile = import_node_path52.default.join(options.usageDir, "backfill-start.json");
|
|
80862
81196
|
let before;
|
|
80863
81197
|
try {
|
|
80864
81198
|
before = (options.now ?? Date.now)();
|
|
@@ -80900,7 +81234,7 @@ var params = external_exports.object({
|
|
|
80900
81234
|
to: external_exports.string().optional().describe("End date, YYYY-MM-DD (inclusive; default today)."),
|
|
80901
81235
|
scope: external_exports.enum(["me", "team"]).optional().describe("me: only the current user's use. Default team."),
|
|
80902
81236
|
user: external_exports.string().optional().describe("events: only this user (login or display name, any case)."),
|
|
80903
|
-
kind: external_exports.enum(["skill", "tool"]).optional().describe("events: only skill uses or only
|
|
81237
|
+
kind: external_exports.enum(["skill", "tool", "tokens"]).optional().describe("events: only skill uses, only tool calls, or only token counts (one row per model request: model, inputTokens, outputTokens, cachedTokens, estimated)."),
|
|
80904
81238
|
name: external_exports.string().optional().describe("events: only skills or tools whose name contains this (any case)."),
|
|
80905
81239
|
team: external_exports.string().optional().describe("events: only people in this team or department (any case)."),
|
|
80906
81240
|
limit: external_exports.number().int().min(1).max(2e5).optional().describe("events: at most this many rows, newest first (default 20000).")
|
|
@@ -80939,6 +81273,7 @@ function renderSummary(d, storeLabel) {
|
|
|
80939
81273
|
`- Skill uses: ${String(d.totals.skillUses.value)}${pct(d.totals.skillUses.value, d.totals.skillUses.previous)}; skills in use ${String(d.totals.skillsUsed.value)} of ${String(d.inventory.skills)} installed`,
|
|
80940
81274
|
`- Tool calls: ${String(d.totals.toolUses.value)}${pct(d.totals.toolUses.value, d.totals.toolUses.previous)}; failed ${String(d.totals.failures.value)}`,
|
|
80941
81275
|
`- Active people: ${String(d.totals.people.value)}${pct(d.totals.people.value, d.totals.people.previous)}`,
|
|
81276
|
+
`- Tokens: ${(d.tokens.total.input + d.tokens.total.output).toLocaleString("en")} (${d.tokens.total.input.toLocaleString("en")} in, ${d.tokens.total.output.toLocaleString("en")} out, ${d.tokens.total.cached.toLocaleString("en")} of the input cached) over ${String(d.tokens.total.requests)} requests${pct(d.tokens.total.input + d.tokens.total.output, d.tokens.previous.input + d.tokens.previous.output)}${d.tokens.estimatedShare > 0 ? `; ${String(Math.round(d.tokens.estimatedShare * 100))}% of requests estimated` : ""}`,
|
|
80942
81277
|
`- Your contribution: ${String(d.myImpact.skills)} skills and ${String(d.myImpact.tools)} tools, used ${String(d.myImpact.uses)} times by ${String(d.myImpact.reached)} people`
|
|
80943
81278
|
];
|
|
80944
81279
|
const table = (title, header2, rows) => {
|
|
@@ -80953,6 +81288,9 @@ function renderSummary(d, storeLabel) {
|
|
|
80953
81288
|
table("People", "| Person | Team | Uses | Skills | Favourite skill |", d.people.slice(0, 20).map((p) => `| ${name(p.user, p.displayName)} | ${p.team ?? ""} | ${String(p.uses)} | ${String(p.skills)} | ${p.favourite ?? ""} |`));
|
|
80954
81289
|
table("Teams", "| Team | People | Uses | Skill uses | Top skill |", d.teams.map((t) => `| ${t.team} | ${String(t.people)} | ${String(t.uses)} | ${String(t.skillUses)} | ${t.topSkill ?? ""} |`));
|
|
80955
81290
|
}
|
|
81291
|
+
const n = (v) => v.toLocaleString("en");
|
|
81292
|
+
table("Tokens by person", "| Person | Team | Total | Input | Output | Cached | Requests | Share | Models |", d.tokens.people.slice(0, 30).map((p) => `| ${name(p.user, p.displayName)} | ${p.team ?? ""} | ${n(p.input + p.output)} | ${n(p.input)} | ${n(p.output)} | ${n(p.cached)} | ${n(p.requests)} | ${String(Math.round(p.share * 100))}% | ${p.models.join(", ")} |`));
|
|
81293
|
+
table("Tokens by model", "| Model | Total | Input | Output | Requests |", d.tokens.models.slice(0, 15).map((m) => `| ${m.model} | ${n(m.input + m.output)} | ${n(m.input)} | ${n(m.output)} | ${n(m.requests)} |`));
|
|
80956
81294
|
if (d.problems.length > 0) {
|
|
80957
81295
|
lines2.push("", "## Needs attention");
|
|
80958
81296
|
for (const problem of d.problems)
|
|
@@ -81039,7 +81377,8 @@ Note: ${data.storeProblem}` : "";
|
|
|
81039
81377
|
author: event.a ?? null,
|
|
81040
81378
|
project: event.p ?? null,
|
|
81041
81379
|
failed: event.ok === false,
|
|
81042
|
-
ms: event.d ?? null
|
|
81380
|
+
ms: event.d ?? null,
|
|
81381
|
+
...event.k === "tokens" ? { model: event.n, inputTokens: event.i ?? 0, outputTokens: event.o ?? 0, cachedTokens: event.c ?? 0, estimated: event.e === 1 } : {}
|
|
81043
81382
|
}));
|
|
81044
81383
|
if (rows.length === 0)
|
|
81045
81384
|
return { content: `No usage matched in ${new Date(range.from).toISOString().slice(0, 10)} to ${new Date(range.to).toISOString().slice(0, 10)}.${note}` };
|
|
@@ -81255,8 +81594,8 @@ function wireChatBridge(services) {
|
|
|
81255
81594
|
const workspaceBranch = workspaceRoot !== void 0 ? currentBranchOf(workspaceRoot) : void 0;
|
|
81256
81595
|
const machineApprovals = services.machineApprovalsFile !== void 0 ? new FileMachineApprovals(services.machineApprovalsFile) : void 0;
|
|
81257
81596
|
const mirrorRoot = services.mirrorRoot ?? storageDir;
|
|
81258
|
-
const personalSkillsDir = services.personalDir !== void 0 ?
|
|
81259
|
-
const personalToolsDir = services.personalDir !== void 0 ?
|
|
81597
|
+
const personalSkillsDir = services.personalDir !== void 0 ? import_node_path53.default.join(services.personalDir, "skills") : void 0;
|
|
81598
|
+
const personalToolsDir = services.personalDir !== void 0 ? import_node_path53.default.join(services.personalDir, "tools") : void 0;
|
|
81260
81599
|
const logger = new Logger({ level: "debug", sink: services.logSink });
|
|
81261
81600
|
let fastFsOps;
|
|
81262
81601
|
if (services.fastFs !== void 0) {
|
|
@@ -81271,14 +81610,14 @@ function wireChatBridge(services) {
|
|
|
81271
81610
|
let cachedSecretValues = [];
|
|
81272
81611
|
const droppedFilesRoot2 = droppedFilesRoot();
|
|
81273
81612
|
const mailAttachmentsRoot2 = mailAttachmentsRoot();
|
|
81274
|
-
const droppedFilesDir =
|
|
81275
|
-
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(
|
|
81613
|
+
const droppedFilesDir = import_node_path53.default.join(droppedFilesRoot2, (0, import_node_crypto17.randomUUID)().slice(0, 8));
|
|
81614
|
+
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(import_node_path53.default.join(storageDir, "tool-results"), () => cachedSecretValues));
|
|
81276
81615
|
const taskStore = new JsonTaskStore(storageDir, truncationStore, logger);
|
|
81277
81616
|
const manifestsRoot = services.codebaseDir ?? storageDir;
|
|
81278
81617
|
const codebaseInstructionsFile = codebaseInstructionsPath({ codebaseDir: services.codebaseDir, storageDir, workspaceRoot: projectRoot });
|
|
81279
81618
|
if (services.codebaseDir !== void 0) {
|
|
81280
|
-
const shared =
|
|
81281
|
-
void import_promises29.default.access(shared).catch(() => import_promises29.default.cp(
|
|
81619
|
+
const shared = import_node_path53.default.join(services.codebaseDir, "index-manifests");
|
|
81620
|
+
void import_promises29.default.access(shared).catch(() => import_promises29.default.cp(import_node_path53.default.join(storageDir, "index-manifests"), shared, { recursive: true, errorOnExist: false, force: false })).catch(() => void 0);
|
|
81282
81621
|
}
|
|
81283
81622
|
const python = new PythonManager({
|
|
81284
81623
|
workspaceRoot,
|
|
@@ -81420,7 +81759,7 @@ ${preview.text}` } : {}
|
|
|
81420
81759
|
void postDatasetStatus();
|
|
81421
81760
|
}
|
|
81422
81761
|
});
|
|
81423
|
-
const defaultSkillsDir = workspaceRoot !== void 0 ?
|
|
81762
|
+
const defaultSkillsDir = workspaceRoot !== void 0 ? import_node_path53.default.join(workspaceRoot, ".lightcode", "skills") : void 0;
|
|
81424
81763
|
let skillsDir = defaultSkillsDir;
|
|
81425
81764
|
let localSkillsDir = defaultSkillsDir;
|
|
81426
81765
|
let extraSkillDirs = [];
|
|
@@ -81443,9 +81782,9 @@ ${preview.text}` } : {}
|
|
|
81443
81782
|
const trimmed = entry.trim();
|
|
81444
81783
|
if (trimmed.length === 0)
|
|
81445
81784
|
return void 0;
|
|
81446
|
-
if (
|
|
81447
|
-
return
|
|
81448
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
81785
|
+
if (import_node_path53.default.isAbsolute(trimmed))
|
|
81786
|
+
return import_node_path53.default.resolve(trimmed);
|
|
81787
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path53.default.resolve(workspaceRoot, trimmed);
|
|
81449
81788
|
}
|
|
81450
81789
|
function skillSearchPath() {
|
|
81451
81790
|
return [skillsDir, ...extraSkillDirs].filter((dir) => dir !== void 0);
|
|
@@ -81477,7 +81816,7 @@ ${preview.text}` } : {}
|
|
|
81477
81816
|
function watchSkillFolders() {
|
|
81478
81817
|
stopWatchingSkills();
|
|
81479
81818
|
const dirs = skillSearchPath();
|
|
81480
|
-
for (const dir of [...dirs, ...dirs.map((entry) =>
|
|
81819
|
+
for (const dir of [...dirs, ...dirs.map((entry) => import_node_path53.default.dirname(entry))]) {
|
|
81481
81820
|
try {
|
|
81482
81821
|
skillWatchers.push(
|
|
81483
81822
|
// Recursive, because a skill may be a folder with SKILL.md inside — a non-recursive
|
|
@@ -81554,7 +81893,7 @@ ${preview.text}` } : {}
|
|
|
81554
81893
|
await openInPanelEditor(filePath);
|
|
81555
81894
|
return;
|
|
81556
81895
|
}
|
|
81557
|
-
const real = await confineToAny(
|
|
81896
|
+
const real = await confineToAny(import_node_path53.default.resolve(filePath), roots);
|
|
81558
81897
|
await ui.openFile?.(real);
|
|
81559
81898
|
} catch (error51) {
|
|
81560
81899
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -81565,9 +81904,9 @@ ${preview.text}` } : {}
|
|
|
81565
81904
|
python.toolsDirectory(),
|
|
81566
81905
|
...skillsDir === void 0 ? [] : [skillsDir],
|
|
81567
81906
|
...extraSkillDirs.filter((dir) => dir !== void 0),
|
|
81568
|
-
|
|
81907
|
+
import_node_path53.default.join(storageDir, "reports"),
|
|
81569
81908
|
// Its own folder: nothing else lives there.
|
|
81570
|
-
...codebaseInstructionsFile === void 0 ? [] : [
|
|
81909
|
+
...codebaseInstructionsFile === void 0 ? [] : [import_node_path53.default.dirname(codebaseInstructionsFile)]
|
|
81571
81910
|
].filter((dir) => dir.length > 0);
|
|
81572
81911
|
}
|
|
81573
81912
|
function mostlyCrlf(text2) {
|
|
@@ -81576,17 +81915,17 @@ ${preview.text}` } : {}
|
|
|
81576
81915
|
}
|
|
81577
81916
|
const EDITOR_MAX_BYTES = 2 * 1024 * 1024;
|
|
81578
81917
|
async function openInPanelEditor(filePath) {
|
|
81579
|
-
const real = await confineToAny(
|
|
81918
|
+
const real = await confineToAny(import_node_path53.default.resolve(filePath), managedRoots());
|
|
81580
81919
|
const stat = await import_promises29.default.stat(real);
|
|
81581
81920
|
if (stat.size > EDITOR_MAX_BYTES)
|
|
81582
|
-
throw new Error(`${
|
|
81921
|
+
throw new Error(`${import_node_path53.default.basename(real)} is too large to edit here (${String(Math.round(stat.size / 1024))} KB).`);
|
|
81583
81922
|
const raw = await import_promises29.default.readFile(real, "utf8");
|
|
81584
81923
|
const crlf = mostlyCrlf(raw);
|
|
81585
|
-
post({ type: "editorFile", path: real, name:
|
|
81924
|
+
post({ type: "editorFile", path: real, name: import_node_path53.default.basename(real), content: raw.split("\r\n").join("\n"), mtimeMs: stat.mtimeMs, eol: crlf ? "crlf" : "lf" });
|
|
81586
81925
|
}
|
|
81587
81926
|
async function handleSaveEditorFile(filePath, content, mtimeMs) {
|
|
81588
81927
|
try {
|
|
81589
|
-
const real = await confineToAny(
|
|
81928
|
+
const real = await confineToAny(import_node_path53.default.resolve(filePath), managedRoots());
|
|
81590
81929
|
const current = await import_promises29.default.stat(real).catch(() => void 0);
|
|
81591
81930
|
if (current !== void 0 && Math.abs(current.mtimeMs - mtimeMs) > 1) {
|
|
81592
81931
|
post({
|
|
@@ -81594,7 +81933,7 @@ ${preview.text}` } : {}
|
|
|
81594
81933
|
path: real,
|
|
81595
81934
|
ok: false,
|
|
81596
81935
|
conflict: true,
|
|
81597
|
-
message: `${
|
|
81936
|
+
message: `${import_node_path53.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.`
|
|
81598
81937
|
});
|
|
81599
81938
|
return;
|
|
81600
81939
|
}
|
|
@@ -81618,7 +81957,7 @@ ${preview.text}` } : {}
|
|
|
81618
81957
|
await handleOpenManagedFile(existing.filePath);
|
|
81619
81958
|
return;
|
|
81620
81959
|
}
|
|
81621
|
-
const target =
|
|
81960
|
+
const target = import_node_path53.default.join(skillsDir, "standing-instructions.md");
|
|
81622
81961
|
try {
|
|
81623
81962
|
await import_promises29.default.mkdir(skillsDir, { recursive: true });
|
|
81624
81963
|
await import_promises29.default.writeFile(target, STANDING_SKILL_TEMPLATE, { encoding: "utf8", flag: "wx" });
|
|
@@ -81638,7 +81977,7 @@ ${preview.text}` } : {}
|
|
|
81638
81977
|
return;
|
|
81639
81978
|
}
|
|
81640
81979
|
try {
|
|
81641
|
-
await import_promises29.default.mkdir(
|
|
81980
|
+
await import_promises29.default.mkdir(import_node_path53.default.dirname(codebaseInstructionsFile), { recursive: true });
|
|
81642
81981
|
await import_promises29.default.writeFile(codebaseInstructionsFile, "", { encoding: "utf8", flag: "wx" });
|
|
81643
81982
|
} catch (error51) {
|
|
81644
81983
|
if (error51.code !== "EEXIST") {
|
|
@@ -81655,11 +81994,11 @@ ${preview.text}` } : {}
|
|
|
81655
81994
|
return;
|
|
81656
81995
|
if (!isValidToolName(name))
|
|
81657
81996
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
81658
|
-
const ownCopy =
|
|
81997
|
+
const ownCopy = import_node_path53.default.join(dir, toolFileName(name));
|
|
81659
81998
|
if (filePath !== void 0) {
|
|
81660
|
-
const same2 = (a, b) => normalizeForComparison(
|
|
81999
|
+
const same2 = (a, b) => normalizeForComparison(import_node_path53.default.resolve(a)) === normalizeForComparison(import_node_path53.default.resolve(b));
|
|
81661
82000
|
if (!same2(filePath, ownCopy)) {
|
|
81662
|
-
const fromBucket = mirroredToolsDirs.some((mirror) => same2(
|
|
82001
|
+
const fromBucket = mirroredToolsDirs.some((mirror) => same2(import_node_path53.default.dirname(filePath), mirror));
|
|
81663
82002
|
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.`);
|
|
81664
82003
|
}
|
|
81665
82004
|
}
|
|
@@ -81685,7 +82024,7 @@ ${preview.text}` } : {}
|
|
|
81685
82024
|
let dir;
|
|
81686
82025
|
let filePath = "";
|
|
81687
82026
|
for (const candidate of python.toolDirectories()) {
|
|
81688
|
-
const attempt =
|
|
82027
|
+
const attempt = import_node_path53.default.join(candidate, toolFileName(name));
|
|
81689
82028
|
if (await onDisk(attempt)) {
|
|
81690
82029
|
dir = candidate;
|
|
81691
82030
|
filePath = attempt;
|
|
@@ -81716,7 +82055,7 @@ ${preview.text}` } : {}
|
|
|
81716
82055
|
function samePath(a, b) {
|
|
81717
82056
|
if (a === void 0 || b === void 0)
|
|
81718
82057
|
return false;
|
|
81719
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
82058
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path53.default.resolve(value).toLowerCase() : import_node_path53.default.resolve(value);
|
|
81720
82059
|
return norm2(a) === norm2(b);
|
|
81721
82060
|
}
|
|
81722
82061
|
function publishFolder(kind, mirrors) {
|
|
@@ -81825,7 +82164,7 @@ ${preview.text}` } : {}
|
|
|
81825
82164
|
target,
|
|
81826
82165
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
|
|
81827
82166
|
relative: entry,
|
|
81828
|
-
contents: await import_promises29.default.readFile(
|
|
82167
|
+
contents: await import_promises29.default.readFile(import_node_path53.default.join(dir, entry))
|
|
81829
82168
|
});
|
|
81830
82169
|
uploaded += 1;
|
|
81831
82170
|
} catch (error51) {
|
|
@@ -81847,7 +82186,7 @@ ${preview.text}` } : {}
|
|
|
81847
82186
|
if (!isValidToolName(name))
|
|
81848
82187
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
81849
82188
|
for (const candidate of python.toolDirectories()) {
|
|
81850
|
-
const attempt =
|
|
82189
|
+
const attempt = import_node_path53.default.join(candidate, toolFileName(name));
|
|
81851
82190
|
try {
|
|
81852
82191
|
post({ type: "pythonToolSource", name, source: await import_promises29.default.readFile(attempt, "utf8") });
|
|
81853
82192
|
return;
|
|
@@ -81900,7 +82239,7 @@ ${preview.text}` } : {}
|
|
|
81900
82239
|
continue;
|
|
81901
82240
|
for (const candidate of python.toolDirectories()) {
|
|
81902
82241
|
try {
|
|
81903
|
-
const source = await import_promises29.default.readFile(
|
|
82242
|
+
const source = await import_promises29.default.readFile(import_node_path53.default.join(candidate, toolFileName(name)), "utf8");
|
|
81904
82243
|
declined[name] = hashSource(source);
|
|
81905
82244
|
recorded += 1;
|
|
81906
82245
|
break;
|
|
@@ -81958,7 +82297,7 @@ ${preview.text}` } : {}
|
|
|
81958
82297
|
let dir;
|
|
81959
82298
|
let filePath = "";
|
|
81960
82299
|
for (const candidate of python.toolDirectories()) {
|
|
81961
|
-
const attempt =
|
|
82300
|
+
const attempt = import_node_path53.default.join(candidate, toolFileName(name));
|
|
81962
82301
|
if (await onDisk(attempt)) {
|
|
81963
82302
|
dir = candidate;
|
|
81964
82303
|
filePath = attempt;
|
|
@@ -81984,7 +82323,7 @@ ${preview.text}` } : {}
|
|
|
81984
82323
|
function mirrorForDir(sourceDir) {
|
|
81985
82324
|
if (sourceDir === void 0)
|
|
81986
82325
|
return void 0;
|
|
81987
|
-
const wanted =
|
|
82326
|
+
const wanted = import_node_path53.default.resolve(sourceDir).toLowerCase();
|
|
81988
82327
|
for (const mirror of cachedSkillMirrors) {
|
|
81989
82328
|
if (mirror.enabled !== true)
|
|
81990
82329
|
continue;
|
|
@@ -81994,7 +82333,7 @@ ${preview.text}` } : {}
|
|
|
81994
82333
|
kind: "skills",
|
|
81995
82334
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
81996
82335
|
});
|
|
81997
|
-
if (
|
|
82336
|
+
if (import_node_path53.default.resolve(localDir).toLowerCase() === wanted)
|
|
81998
82337
|
return { mirror, localDir };
|
|
81999
82338
|
}
|
|
82000
82339
|
return void 0;
|
|
@@ -82059,8 +82398,8 @@ ${preview.text}` } : {}
|
|
|
82059
82398
|
});
|
|
82060
82399
|
let localProblem;
|
|
82061
82400
|
try {
|
|
82062
|
-
await import_promises29.default.rm(
|
|
82063
|
-
await import_promises29.default.rm(
|
|
82401
|
+
await import_promises29.default.rm(import_node_path53.default.join(found2.localDir, `${name}.md`), { force: true });
|
|
82402
|
+
await import_promises29.default.rm(import_node_path53.default.join(found2.localDir, name), { recursive: true, force: true });
|
|
82064
82403
|
} catch (error51) {
|
|
82065
82404
|
localProblem = error51 instanceof Error ? error51.message : String(error51);
|
|
82066
82405
|
}
|
|
@@ -82095,7 +82434,7 @@ ${preview.text}` } : {}
|
|
|
82095
82434
|
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.`);
|
|
82096
82435
|
}
|
|
82097
82436
|
const from = existing?.sourceDir !== void 0 && samePath(existing.sourceDir, personalSkillsDir) ? existing.sourceDir : skillsDir;
|
|
82098
|
-
await import_promises29.default.rm(
|
|
82437
|
+
await import_promises29.default.rm(import_node_path53.default.join(from, skillFileName(name)), { force: true });
|
|
82099
82438
|
await postSkills();
|
|
82100
82439
|
} catch (error51) {
|
|
82101
82440
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -82277,7 +82616,7 @@ ${preview.text}` } : {}
|
|
|
82277
82616
|
let scheduleToolAccess;
|
|
82278
82617
|
const approvalsKey = projectRoot ?? "__no_workspace__";
|
|
82279
82618
|
function comparableApprovalsKey(key3) {
|
|
82280
|
-
return key3 === "__no_workspace__" ? key3 : normalizeForComparison(
|
|
82619
|
+
return key3 === "__no_workspace__" ? key3 : normalizeForComparison(import_node_path53.default.resolve(key3));
|
|
82281
82620
|
}
|
|
82282
82621
|
function approvalsFrom(stored) {
|
|
82283
82622
|
if (stored === void 0)
|
|
@@ -82488,7 +82827,7 @@ ${preview.text}` } : {}
|
|
|
82488
82827
|
...taskExpertEstimate === void 0 ? {} : { estimate: taskExpertEstimate }
|
|
82489
82828
|
});
|
|
82490
82829
|
}
|
|
82491
|
-
const expertEventsPath =
|
|
82830
|
+
const expertEventsPath = import_node_path53.default.join(storageDir, "expert-events.jsonl");
|
|
82492
82831
|
let expertEvents;
|
|
82493
82832
|
let juniorTurnWithoutExpert = false;
|
|
82494
82833
|
async function loadExpertEvents() {
|
|
@@ -82516,7 +82855,7 @@ ${preview.text}` } : {}
|
|
|
82516
82855
|
try {
|
|
82517
82856
|
const events = await loadExpertEvents();
|
|
82518
82857
|
events.push(event);
|
|
82519
|
-
await import_promises29.default.mkdir(
|
|
82858
|
+
await import_promises29.default.mkdir(import_node_path53.default.dirname(expertEventsPath), { recursive: true });
|
|
82520
82859
|
await import_promises29.default.appendFile(expertEventsPath, `${JSON.stringify(event)}
|
|
82521
82860
|
`, "utf8");
|
|
82522
82861
|
} catch (error51) {
|
|
@@ -82802,15 +83141,15 @@ ${preview.text}` } : {}
|
|
|
82802
83141
|
function contextMentionPath(file2) {
|
|
82803
83142
|
if (workspaceRoot === void 0)
|
|
82804
83143
|
return file2;
|
|
82805
|
-
const relative =
|
|
82806
|
-
return relative.length > 0 && !relative.startsWith("..") && !
|
|
83144
|
+
const relative = import_node_path53.default.relative(workspaceRoot, file2);
|
|
83145
|
+
return relative.length > 0 && !relative.startsWith("..") && !import_node_path53.default.isAbsolute(relative) ? relative.split(import_node_path53.default.sep).join("/") : file2;
|
|
82807
83146
|
}
|
|
82808
83147
|
function hostCapabilities() {
|
|
82809
83148
|
return {
|
|
82810
83149
|
// The branch this window or tab works on, shown under the chat's name; and the repository, when this
|
|
82811
83150
|
// folder is one of its branch folders (git/worktrees.ts).
|
|
82812
83151
|
...workspaceBranch !== void 0 ? { workspaceBranch } : {},
|
|
82813
|
-
...projectRoot !== void 0 && workspaceRoot !== void 0 && projectRoot !== workspaceRoot ? { branchFolderOf:
|
|
83152
|
+
...projectRoot !== void 0 && workspaceRoot !== void 0 && projectRoot !== workspaceRoot ? { branchFolderOf: import_node_path53.default.basename(projectRoot) } : {},
|
|
82814
83153
|
// The GitHub Copilot preset, offered only where VS Code's models can be reached.
|
|
82815
83154
|
hostModels: services.languageModels !== void 0,
|
|
82816
83155
|
nativeGuide: ui.openWalkthrough !== void 0,
|
|
@@ -83350,14 +83689,14 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
83350
83689
|
}
|
|
83351
83690
|
function readUserNpmrc() {
|
|
83352
83691
|
try {
|
|
83353
|
-
return (0, import_node_fs12.readFileSync)(process.env["NPM_CONFIG_USERCONFIG"] ??
|
|
83692
|
+
return (0, import_node_fs12.readFileSync)(process.env["NPM_CONFIG_USERCONFIG"] ?? import_node_path53.default.join(import_node_os6.default.homedir(), ".npmrc"), "utf8");
|
|
83354
83693
|
} catch {
|
|
83355
83694
|
return void 0;
|
|
83356
83695
|
}
|
|
83357
83696
|
}
|
|
83358
83697
|
function addonFolders(config2) {
|
|
83359
83698
|
return {
|
|
83360
|
-
configured: (config2.addons?.folders ?? []).map((folder) =>
|
|
83699
|
+
configured: (config2.addons?.folders ?? []).map((folder) => import_node_path53.default.resolve(folder)),
|
|
83361
83700
|
defaults: defaultAddonFolders(process.env, process.execPath, process.platform, readUserNpmrc())
|
|
83362
83701
|
};
|
|
83363
83702
|
}
|
|
@@ -83638,7 +83977,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
83638
83977
|
}
|
|
83639
83978
|
async function handleSaveAddonFolders(folders) {
|
|
83640
83979
|
const cleaned = [...new Set(folders.map((folder) => folder.trim()).filter((folder) => folder.length > 0))];
|
|
83641
|
-
const relative = cleaned.find((folder) => !
|
|
83980
|
+
const relative = cleaned.find((folder) => !import_node_path53.default.isAbsolute(folder));
|
|
83642
83981
|
if (relative !== void 0) {
|
|
83643
83982
|
await postAddons(`"${relative}" is not a full path. Add-on folders are full paths, such as C:\\addons.`);
|
|
83644
83983
|
return;
|
|
@@ -83649,7 +83988,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
83649
83988
|
postMcp();
|
|
83650
83989
|
await postAddons();
|
|
83651
83990
|
}
|
|
83652
|
-
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot,
|
|
83991
|
+
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot, import_node_path53.default.join(storageDir, "checkpoints", "shadow.git"), services.codebaseDir !== void 0 ? import_node_path53.default.join(services.codebaseDir, "checkpoint-objects") : void 0) : void 0;
|
|
83653
83992
|
async function postProfiles() {
|
|
83654
83993
|
const { config: config2 } = await configManager.load();
|
|
83655
83994
|
const profiles = await Promise.all((config2.profiles ?? []).map((profile) => toSummary(profile, secrets)));
|
|
@@ -83702,6 +84041,31 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
83702
84041
|
return [];
|
|
83703
84042
|
}
|
|
83704
84043
|
}
|
|
84044
|
+
let persistTimer;
|
|
84045
|
+
let persisting = Promise.resolve();
|
|
84046
|
+
function persistSoon() {
|
|
84047
|
+
if (persistTimer !== void 0)
|
|
84048
|
+
return;
|
|
84049
|
+
persistTimer = setTimeout(() => {
|
|
84050
|
+
persistTimer = void 0;
|
|
84051
|
+
persisting = persisting.then(() => persistActiveTask()).catch(() => void 0);
|
|
84052
|
+
}, 3e3);
|
|
84053
|
+
persistTimer.unref?.();
|
|
84054
|
+
}
|
|
84055
|
+
function composerDraftFile() {
|
|
84056
|
+
const id = (0, import_node_crypto17.createHash)("sha256").update((workspaceRoot ?? "").toLowerCase()).digest("hex").slice(0, 16);
|
|
84057
|
+
return import_node_path53.default.join(storageDir, "drafts", `${id}.txt`);
|
|
84058
|
+
}
|
|
84059
|
+
let draftWrites = Promise.resolve();
|
|
84060
|
+
function saveComposerDraft(text2) {
|
|
84061
|
+
const kept = text2.slice(0, 2e5);
|
|
84062
|
+
draftWrites = draftWrites.then(() => kept.length === 0 ? import_promises29.default.rm(composerDraftFile(), { force: true }) : writeFileAtomically(composerDraftFile(), kept)).catch((error51) => logger.warn("could not keep the draft", String(error51)));
|
|
84063
|
+
return draftWrites;
|
|
84064
|
+
}
|
|
84065
|
+
async function readComposerDraft() {
|
|
84066
|
+
await draftWrites;
|
|
84067
|
+
return import_promises29.default.readFile(composerDraftFile(), "utf8").catch(() => "");
|
|
84068
|
+
}
|
|
83705
84069
|
async function persistActiveTask() {
|
|
83706
84070
|
if (workspaceRoot === void 0 || conversation.isEmpty())
|
|
83707
84071
|
return;
|
|
@@ -84086,7 +84450,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
84086
84450
|
...schedule === void 0 ? { requestForm } : {},
|
|
84087
84451
|
// A skill read with the user's defaults for its placeholders carries them (`skills/defaults.ts`).
|
|
84088
84452
|
annotateRead: (realPath) => {
|
|
84089
|
-
const fold = (value) => process.platform === "win32" ?
|
|
84453
|
+
const fold = (value) => process.platform === "win32" ? import_node_path53.default.resolve(value).toLowerCase() : import_node_path53.default.resolve(value);
|
|
84090
84454
|
const skill = skills.find((each) => fold(each.filePath) === fold(realPath));
|
|
84091
84455
|
return skill === void 0 ? void 0 : skillDefaultsReadNote(skill.name, config2.skillDefaults?.[skill.name]);
|
|
84092
84456
|
},
|
|
@@ -84095,6 +84459,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
84095
84459
|
// What the user has said, for `http_request`'s host rule. Not the images a tool returned (labelled
|
|
84096
84460
|
// user messages nobody typed) and not the loop's own nudge to continue.
|
|
84097
84461
|
userText: () => conversation.toArray().filter((message5) => message5.role === "user" && !message5.content.startsWith("[Images returned by ") && message5.content !== CONTINUE_PROMPT).map((message5) => message5.content).join("\n"),
|
|
84462
|
+
lastUserText: () => conversation.toArray().filter((message5) => message5.role === "user" && !message5.content.startsWith("[Images returned by ") && message5.content !== CONTINUE_PROMPT).at(-1)?.content ?? "",
|
|
84098
84463
|
signal: activeAbortController.signal,
|
|
84099
84464
|
/*
|
|
84100
84465
|
* Supplied by the host, not imported by core: the binary is platform-specific and
|
|
@@ -84132,6 +84497,8 @@ ${direction}` : attachMentions(text2, mentions);
|
|
|
84132
84497
|
contextWindow: capabilities.contextWindow,
|
|
84133
84498
|
// A guessed window must not drive compaction - see `contextWindowKnown`.
|
|
84134
84499
|
contextWindowKnown: capabilities.contextWindowKnown !== false,
|
|
84500
|
+
// The provider's real token counts correct the estimate for this model (`context/budget.ts`).
|
|
84501
|
+
usageKey: `${profile.baseUrl}|${profile.model}`,
|
|
84135
84502
|
// So images a tool returns (a Confluence page's pictures) reach a model that can see them.
|
|
84136
84503
|
supportsVision: capabilities.supportsVision,
|
|
84137
84504
|
// CLAUDE.md §5 has called this configurable since Phase 0; until now it was not.
|
|
@@ -84259,8 +84626,10 @@ ${direction}` : attachMentions(text2, mentions);
|
|
|
84259
84626
|
await runAgentTurn(provider, conversation, messageText, turnRegistry, toolContext, {
|
|
84260
84627
|
onContextUpdate: (breakdown, supersededCount, compactedCount) => {
|
|
84261
84628
|
post({ type: "contextUsage", usage: { ...breakdown, supersededCount, compactedCount } });
|
|
84629
|
+
persistSoon();
|
|
84262
84630
|
},
|
|
84263
84631
|
onCompacted: (summarisedCount) => post({ type: "compacted", summarisedCount }),
|
|
84632
|
+
onUsage: (counted) => recordTokens(profile.model, counted),
|
|
84264
84633
|
onContextWindowLearned: (tokens) => {
|
|
84265
84634
|
if (profile.modelCapabilities?.contextWindow !== void 0)
|
|
84266
84635
|
return;
|
|
@@ -84328,6 +84697,7 @@ ${direction}` : attachMentions(text2, mentions);
|
|
|
84328
84697
|
},
|
|
84329
84698
|
onToolResult: (toolCall, result) => {
|
|
84330
84699
|
recordUsage(toolCall, result);
|
|
84700
|
+
persistSoon();
|
|
84331
84701
|
if (CONTROL_TOOLS.has(toolCall.name)) {
|
|
84332
84702
|
const streamed = textBeforeControlTool;
|
|
84333
84703
|
textBeforeControlTool = "";
|
|
@@ -84715,8 +85085,8 @@ ${direction}` : attachMentions(text2, mentions);
|
|
|
84715
85085
|
const fromHub = hub === void 0 || root !== workspaceRoot ? void 0 : await hubGitDiff(hub);
|
|
84716
85086
|
if (typeof fromHub === "string")
|
|
84717
85087
|
throw new Error(fromHub);
|
|
84718
|
-
const
|
|
84719
|
-
const child = (0,
|
|
85088
|
+
const git3 = (args) => new Promise((resolve) => {
|
|
85089
|
+
const child = (0, import_node_child_process16.spawn)("git", ["--no-optional-locks", "-C", root, ...args], {
|
|
84720
85090
|
env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
|
|
84721
85091
|
windowsHide: true
|
|
84722
85092
|
});
|
|
@@ -84732,15 +85102,15 @@ ${direction}` : attachMentions(text2, mentions);
|
|
|
84732
85102
|
resolve({ ok: code === 0, out });
|
|
84733
85103
|
});
|
|
84734
85104
|
});
|
|
84735
|
-
const status2 = fromHub !== void 0 ? { ok: true, out: fromHub.status } : await
|
|
85105
|
+
const status2 = fromHub !== void 0 ? { ok: true, out: fromHub.status } : await git3(["status", "--short", "--untracked-files=normal"]);
|
|
84736
85106
|
if (!status2.ok)
|
|
84737
85107
|
throw new Error("This folder is not a git repository, or git could not be run.");
|
|
84738
85108
|
if (status2.out.trim().length === 0)
|
|
84739
85109
|
throw new Error("Nothing has changed, so there is nothing to describe.");
|
|
84740
|
-
const staged = fromHub === void 0 && options.preferStaged === true ? await
|
|
84741
|
-
let diff = fromHub !== void 0 ? { ok: true, out: fromHub.diff } : staged !== void 0 && staged.ok && staged.out.trim().length > 0 ? staged : await
|
|
85110
|
+
const staged = fromHub === void 0 && options.preferStaged === true ? await git3(["diff", "--cached", "--no-color", "--no-ext-diff", "--stat", "--patch"]) : void 0;
|
|
85111
|
+
let diff = fromHub !== void 0 ? { ok: true, out: fromHub.diff } : staged !== void 0 && staged.ok && staged.out.trim().length > 0 ? staged : await git3(["diff", "HEAD", "--no-color", "--no-ext-diff", "--stat", "--patch"]);
|
|
84742
85112
|
if (!diff.ok)
|
|
84743
|
-
diff = await
|
|
85113
|
+
diff = await git3(["diff", "--no-color", "--no-ext-diff", "--stat", "--patch"]);
|
|
84744
85114
|
const shown2 = diff.out.length > 24e3 ? `${diff.out.slice(0, 24e3)}
|
|
84745
85115
|
... (diff cut here)` : diff.out;
|
|
84746
85116
|
const config2 = await loadSettings();
|
|
@@ -85347,7 +85717,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85347
85717
|
return { mode: cachedSearchScope, author: cachedAttribution.author };
|
|
85348
85718
|
}
|
|
85349
85719
|
function currentProjectNames() {
|
|
85350
|
-
const names = [cachedAttribution.project, workspaceRoot !== void 0 ?
|
|
85720
|
+
const names = [cachedAttribution.project, workspaceRoot !== void 0 ? import_node_path53.default.basename(workspaceRoot) : void 0];
|
|
85351
85721
|
return names.filter((name) => name !== void 0 && name.length > 0);
|
|
85352
85722
|
}
|
|
85353
85723
|
function indexProject(config2) {
|
|
@@ -85450,8 +85820,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85450
85820
|
limit: limits.limit,
|
|
85451
85821
|
previewChars: limits.previewChars
|
|
85452
85822
|
});
|
|
85453
|
-
for (const
|
|
85454
|
-
skipped.add(
|
|
85823
|
+
for (const path64 of answer.skipped ?? [])
|
|
85824
|
+
skipped.add(path64);
|
|
85455
85825
|
return { messages: answer.messages, truncated: answer.truncated };
|
|
85456
85826
|
},
|
|
85457
85827
|
...embedder !== void 0 && search !== void 0 && collection !== void 0 ? {
|
|
@@ -85750,9 +86120,9 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85750
86120
|
});
|
|
85751
86121
|
const all = result.folders.map((entry) => entry.path);
|
|
85752
86122
|
const wanted = new Set(chosen);
|
|
85753
|
-
for (const
|
|
85754
|
-
if (chosen.some((root) =>
|
|
85755
|
-
wanted.add(
|
|
86123
|
+
for (const path64 of all) {
|
|
86124
|
+
if (chosen.some((root) => path64 === root || path64.startsWith(`${root}\\`)))
|
|
86125
|
+
wanted.add(path64);
|
|
85756
86126
|
}
|
|
85757
86127
|
return [...wanted];
|
|
85758
86128
|
} catch {
|
|
@@ -85760,7 +86130,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85760
86130
|
}
|
|
85761
86131
|
}
|
|
85762
86132
|
async function handleRequestOutlookFolders(depth, force = false) {
|
|
85763
|
-
const cachePath =
|
|
86133
|
+
const cachePath = import_node_path53.default.join(storageDir, "outlook-folders.json");
|
|
85764
86134
|
let served = false;
|
|
85765
86135
|
try {
|
|
85766
86136
|
const cached2 = JSON.parse(await import_promises29.default.readFile(cachePath, "utf8"));
|
|
@@ -85780,7 +86150,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85780
86150
|
const scannedAt = Date.now();
|
|
85781
86151
|
post({ type: "outlookFolders", folders: result.folders, scannedAt });
|
|
85782
86152
|
try {
|
|
85783
|
-
await import_promises29.default.mkdir(
|
|
86153
|
+
await import_promises29.default.mkdir(import_node_path53.default.dirname(cachePath), { recursive: true });
|
|
85784
86154
|
await import_promises29.default.writeFile(cachePath, JSON.stringify({ scannedAt, folders: result.folders }), "utf8");
|
|
85785
86155
|
} catch {
|
|
85786
86156
|
}
|
|
@@ -86324,6 +86694,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
86324
86694
|
}
|
|
86325
86695
|
return { ok: true, data: { synced } };
|
|
86326
86696
|
}
|
|
86697
|
+
case "history":
|
|
86698
|
+
return { ok: true, data: await fileHistory(request.file) ?? null };
|
|
86327
86699
|
case "skill": {
|
|
86328
86700
|
const done = request.op === "write" ? await writeTeamMonitorSkill(request.file, request.content ?? "") : await deleteEverywhere(await planDeleteEverywhere("skill", request.name));
|
|
86329
86701
|
return done.ok ? { ok: true, data: done.message } : { ok: false, error: done.message };
|
|
@@ -86691,12 +87063,12 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
86691
87063
|
if (!isSafeSegment(settings.project) || !isSafeSegment(settings.repo))
|
|
86692
87064
|
return { reason: "Enter the project key and repository slug." };
|
|
86693
87065
|
const digest = (0, import_node_crypto17.createHash)("sha256").update(JSON.stringify([bitbucket.baseUrl, settings.project, settings.repo, settings.branch, settings.folder]).toLowerCase()).digest("hex").slice(0, 12);
|
|
86694
|
-
const root =
|
|
87066
|
+
const root = import_node_path53.default.join(mirrorRoot, "teamrepo", `${settings.project}-${settings.repo}-${digest}`.toLowerCase());
|
|
86695
87067
|
return {
|
|
86696
|
-
dirs: { skills:
|
|
87068
|
+
dirs: { skills: import_node_path53.default.join(root, "skills"), tools: import_node_path53.default.join(root, "tools") },
|
|
86697
87069
|
// Where new skills and tools are saved while the repository is on - see loadSettings and pythonFolders.
|
|
86698
|
-
own: { skills:
|
|
86699
|
-
stateFile:
|
|
87070
|
+
own: { skills: import_node_path53.default.join(root, "saved-here", "skills"), tools: import_node_path53.default.join(root, "saved-here", "tools") },
|
|
87071
|
+
stateFile: import_node_path53.default.join(root, TEAM_REPO_STATE_FILE),
|
|
86700
87072
|
settings
|
|
86701
87073
|
};
|
|
86702
87074
|
}
|
|
@@ -86735,6 +87107,31 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
86735
87107
|
commitFile: (file2) => client.commitFile(repoRef, file2)
|
|
86736
87108
|
};
|
|
86737
87109
|
}
|
|
87110
|
+
async function fileHistory(file2) {
|
|
87111
|
+
const config2 = await loadSettings();
|
|
87112
|
+
const plan3 = teamRepoPlan(config2);
|
|
87113
|
+
if (!("reason" in plan3)) {
|
|
87114
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path53.default.resolve(value).toLowerCase() : import_node_path53.default.resolve(value);
|
|
87115
|
+
const folders = [
|
|
87116
|
+
...[plan3.dirs.skills, plan3.own.skills, ...skillSearchPath()].map((dir) => [dir, "skills"]),
|
|
87117
|
+
...[plan3.dirs.tools, plan3.own.tools, ...python.toolDirectories()].map((dir) => [dir, "tools"])
|
|
87118
|
+
];
|
|
87119
|
+
const holder = folders.find(([dir]) => norm2(file2).startsWith(norm2(dir) + import_node_path53.default.sep));
|
|
87120
|
+
if (holder !== void 0) {
|
|
87121
|
+
const relative = import_node_path53.default.relative(import_node_path53.default.resolve(holder[0]), import_node_path53.default.resolve(file2)).split(import_node_path53.default.sep).join("/");
|
|
87122
|
+
const where = repoPathFor(plan3.settings.folder, holder[1], relative);
|
|
87123
|
+
try {
|
|
87124
|
+
const client = await bitbucketClient();
|
|
87125
|
+
const commits = await client.fileCommits({ project: plan3.settings.project, repo: plan3.settings.repo }, where, plan3.settings.branch);
|
|
87126
|
+
if (commits.length > 0)
|
|
87127
|
+
return { source: "bitbucket", commits, where: `${plan3.settings.project}/${plan3.settings.repo} ${where}` };
|
|
87128
|
+
} catch (error51) {
|
|
87129
|
+
logger.warn("reading a file history from the team repository failed", error51 instanceof Error ? error51.message : String(error51));
|
|
87130
|
+
}
|
|
87131
|
+
}
|
|
87132
|
+
}
|
|
87133
|
+
return gitFileHistory(file2);
|
|
87134
|
+
}
|
|
86738
87135
|
async function planDeleteEverywhere(kind, name) {
|
|
86739
87136
|
const plan3 = { kind, name, local: [], buckets: [], repo: [], notes: [] };
|
|
86740
87137
|
const valid = kind === "skill" ? isValidSkillName(name) : isValidToolName(name);
|
|
@@ -86753,21 +87150,21 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
86753
87150
|
const has2 = async (target) => import_promises29.default.stat(target).then(() => true, () => false);
|
|
86754
87151
|
if (kind === "skill") {
|
|
86755
87152
|
for (const dir of unique([skillsDir, localSkillsDir, personalSkillsDir, ...mirroredSkillsDirs])) {
|
|
86756
|
-
if (await has2(
|
|
86757
|
-
plan3.local.push(
|
|
86758
|
-
if (await has2(
|
|
86759
|
-
plan3.local.push(
|
|
87153
|
+
if (await has2(import_node_path53.default.join(dir, skillFileName(name))))
|
|
87154
|
+
plan3.local.push(import_node_path53.default.join(dir, skillFileName(name)));
|
|
87155
|
+
if (await has2(import_node_path53.default.join(dir, name, "SKILL.md")))
|
|
87156
|
+
plan3.local.push(import_node_path53.default.join(dir, name));
|
|
86760
87157
|
}
|
|
86761
87158
|
for (const extra of config2.skills?.paths ?? []) {
|
|
86762
87159
|
const dir = resolveSkillDir(extra);
|
|
86763
|
-
if (dir !== void 0 && (await has2(
|
|
87160
|
+
if (dir !== void 0 && (await has2(import_node_path53.default.join(dir, skillFileName(name))) || await has2(import_node_path53.default.join(dir, name, "SKILL.md")))) {
|
|
86764
87161
|
plan3.notes.push(`Also in ${dir}, a folder you added in Settings -> Skills - not removed; delete it there.`);
|
|
86765
87162
|
}
|
|
86766
87163
|
}
|
|
86767
87164
|
} else {
|
|
86768
87165
|
for (const dir of unique([pythonFolders(config2).toolsDir, localToolsDir(config2), personalToolsDir, ...mirroredToolsDirs])) {
|
|
86769
|
-
if (await has2(
|
|
86770
|
-
plan3.local.push(
|
|
87166
|
+
if (await has2(import_node_path53.default.join(dir, toolFileName(name))))
|
|
87167
|
+
plan3.local.push(import_node_path53.default.join(dir, toolFileName(name)));
|
|
86771
87168
|
}
|
|
86772
87169
|
}
|
|
86773
87170
|
const mirrors = (kind === "skill" ? cachedSkillMirrors : cachedToolMirrors).filter((mirror) => mirror.enabled === true);
|
|
@@ -86858,7 +87255,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
86858
87255
|
try {
|
|
86859
87256
|
await import_promises29.default.rm(entry, { recursive: true, force: true });
|
|
86860
87257
|
if (kind === "tool")
|
|
86861
|
-
await forgetTool(
|
|
87258
|
+
await forgetTool(import_node_path53.default.dirname(entry), name).catch(() => void 0);
|
|
86862
87259
|
} catch (error51) {
|
|
86863
87260
|
localProblems.push(`${entry} (${error51 instanceof Error ? error51.message : String(error51)})`);
|
|
86864
87261
|
}
|
|
@@ -86884,24 +87281,24 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
86884
87281
|
}
|
|
86885
87282
|
async function writeTeamMonitorSkill(file2, content) {
|
|
86886
87283
|
const config2 = await loadSettings();
|
|
86887
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
87284
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path53.default.resolve(value).toLowerCase() : import_node_path53.default.resolve(value);
|
|
86888
87285
|
const inside = (dir) => {
|
|
86889
87286
|
const target = norm2(file2);
|
|
86890
87287
|
const root = norm2(dir);
|
|
86891
|
-
return target.startsWith(root +
|
|
87288
|
+
return target.startsWith(root + import_node_path53.default.sep) ? import_node_path53.default.relative(import_node_path53.default.resolve(dir), import_node_path53.default.resolve(file2)) : void 0;
|
|
86892
87289
|
};
|
|
86893
87290
|
const saveIn = async (dir, relative) => {
|
|
86894
|
-
const destination =
|
|
87291
|
+
const destination = import_node_path53.default.join(dir, relative);
|
|
86895
87292
|
const enabled = cachedSkillMirrors.filter((each) => each.enabled === true);
|
|
86896
87293
|
const mirror = enabled.find((_, i) => samePath(mirroredSkillsDirs[i], dir));
|
|
86897
87294
|
const target = mirror !== void 0 ? targetById(cachedS3, mirror.connectionId) : void 0;
|
|
86898
87295
|
if (mirror !== void 0 && (target === void 0 || target.readOnly === true)) {
|
|
86899
87296
|
throw new Error(`${target?.label ?? mirror.connectionId} is read-only here, so this team monitor cannot be changed from this computer - ask whoever owns that bucket.`);
|
|
86900
87297
|
}
|
|
86901
|
-
await import_promises29.default.mkdir(
|
|
87298
|
+
await import_promises29.default.mkdir(import_node_path53.default.dirname(destination), { recursive: true });
|
|
86902
87299
|
await writeFileAtomically(destination, content);
|
|
86903
87300
|
if (mirror !== void 0 && target !== void 0) {
|
|
86904
|
-
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: relative.split(
|
|
87301
|
+
await uploadToS3({ target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, relative: relative.split(import_node_path53.default.sep).join("/"), contents: Buffer.from(content, "utf8") });
|
|
86905
87302
|
return `uploaded to the bucket ${target.label}`;
|
|
86906
87303
|
}
|
|
86907
87304
|
return `saved in ${dir}`;
|
|
@@ -86923,7 +87320,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
86923
87320
|
throw new Error("There is no folder to save skills in, so the change cannot reach the team repository.");
|
|
86924
87321
|
const where = await saveIn(skillsDir, relative);
|
|
86925
87322
|
await handleTeamRepoSync("a monitor changed on the dashboard");
|
|
86926
|
-
const problem = teamRepoStatus?.error ?? teamRepoStatus?.conflicts.find((c2) => c2.path.endsWith(relative.split(
|
|
87323
|
+
const problem = teamRepoStatus?.error ?? teamRepoStatus?.conflicts.find((c2) => c2.path.endsWith(relative.split(import_node_path53.default.sep).join("/")))?.reason;
|
|
86927
87324
|
if (problem !== void 0) {
|
|
86928
87325
|
return { ok: false, message: `Saved here (${where}), but not committed to the team repository: ${problem}. Nothing was overwritten - see Settings \u2192 DevOps \u2192 Team repository.` };
|
|
86929
87326
|
}
|
|
@@ -86953,8 +87350,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
86953
87350
|
function isPersonalSkill(skill) {
|
|
86954
87351
|
if (personalSkillsDir === void 0)
|
|
86955
87352
|
return false;
|
|
86956
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
86957
|
-
return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) +
|
|
87353
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path53.default.resolve(value).toLowerCase() : import_node_path53.default.resolve(value);
|
|
87354
|
+
return norm2(skill.filePath).startsWith(norm2(personalSkillsDir) + import_node_path53.default.sep);
|
|
86958
87355
|
}
|
|
86959
87356
|
function bucketFolderLabels(config2) {
|
|
86960
87357
|
const label = (kind, mirror) => {
|
|
@@ -87202,7 +87599,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
87202
87599
|
}
|
|
87203
87600
|
const command = config2.branches?.setupCommand?.trim();
|
|
87204
87601
|
if (command !== void 0 && command.length > 0) {
|
|
87205
|
-
const label = workspaceBranch ??
|
|
87602
|
+
const label = workspaceBranch ?? import_node_path53.default.basename(workspaceRoot);
|
|
87206
87603
|
if (ui.runInTerminal !== void 0) {
|
|
87207
87604
|
ui.runInTerminal({ name: `Set up ${label}`, command, cwd: workspaceRoot, env: branchEnv });
|
|
87208
87605
|
parts.push(`running "${command}" in a terminal`);
|
|
@@ -87276,7 +87673,7 @@ ${last}` : ""}`);
|
|
|
87276
87673
|
approvalStamps.set("machine", stamp2);
|
|
87277
87674
|
}
|
|
87278
87675
|
for (const dir of python.toolDirectories()) {
|
|
87279
|
-
const file2 =
|
|
87676
|
+
const file2 = import_node_path53.default.join(dir, REGISTRY_FILE);
|
|
87280
87677
|
const stamp2 = await import_promises29.default.stat(file2).then((stat) => stat.mtimeMs, () => 0);
|
|
87281
87678
|
if (approvalStamps.has(file2) && approvalStamps.get(file2) !== stamp2)
|
|
87282
87679
|
changed = true;
|
|
@@ -87378,7 +87775,7 @@ ${last}` : ""}`);
|
|
|
87378
87775
|
return;
|
|
87379
87776
|
}
|
|
87380
87777
|
const folder = skill.filePath.slice(0, skill.filePath.length - "SKILL.md".length);
|
|
87381
|
-
const bytes = await import_promises29.default.readFile(
|
|
87778
|
+
const bytes = await import_promises29.default.readFile(import_node_path53.default.join(folder, SKILL_IMAGE_DIR, image));
|
|
87382
87779
|
const dataUri = skillImageDataUri(image, bytes);
|
|
87383
87780
|
post({
|
|
87384
87781
|
type: "skillImage",
|
|
@@ -87705,7 +88102,7 @@ ${last}` : ""}`);
|
|
|
87705
88102
|
return withoutRipgrep();
|
|
87706
88103
|
try {
|
|
87707
88104
|
const listed = await new Promise((resolve, reject2) => {
|
|
87708
|
-
const child = (0,
|
|
88105
|
+
const child = (0, import_node_child_process16.spawn)(ripgrepPath, ["--files", "--hidden", "--glob", "!.git"], {
|
|
87709
88106
|
cwd: workspaceRoot
|
|
87710
88107
|
});
|
|
87711
88108
|
let out = "";
|
|
@@ -87744,13 +88141,13 @@ ${last}` : ""}`);
|
|
|
87744
88141
|
}
|
|
87745
88142
|
function docsFingerprintPath(index, storeId, kind) {
|
|
87746
88143
|
const suffix = kind === void 0 ? "docs" : `docs.${kind}`;
|
|
87747
|
-
return
|
|
88144
|
+
return import_node_path53.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.${suffix}.json`);
|
|
87748
88145
|
}
|
|
87749
88146
|
function manifestKey(index, storeId) {
|
|
87750
88147
|
return `${index}@${storeId}`;
|
|
87751
88148
|
}
|
|
87752
88149
|
function manifestPath(index, storeId) {
|
|
87753
|
-
return
|
|
88150
|
+
return import_node_path53.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.json`);
|
|
87754
88151
|
}
|
|
87755
88152
|
async function readDocsFingerprint(index, storeId, kind) {
|
|
87756
88153
|
try {
|
|
@@ -87814,7 +88211,7 @@ ${last}` : ""}`);
|
|
|
87814
88211
|
}
|
|
87815
88212
|
options.report?.("Writing", { done: 0, total: documents.length });
|
|
87816
88213
|
await writer.upsert(index, documents);
|
|
87817
|
-
await import_promises29.default.mkdir(
|
|
88214
|
+
await import_promises29.default.mkdir(import_node_path53.default.dirname(docsFingerprintPath(index, search.id, wanted)), {
|
|
87818
88215
|
recursive: true
|
|
87819
88216
|
});
|
|
87820
88217
|
await import_promises29.default.writeFile(docsFingerprintPath(index, search.id, wanted), JSON.stringify({ fingerprint, indexedAt: Date.now(), count: documents.length }), "utf8");
|
|
@@ -88004,7 +88401,7 @@ ${last}` : ""}`);
|
|
|
88004
88401
|
});
|
|
88005
88402
|
if (manifest !== void 0) {
|
|
88006
88403
|
const targetPath = manifestPath(index, target.id);
|
|
88007
|
-
await import_promises29.default.mkdir(
|
|
88404
|
+
await import_promises29.default.mkdir(import_node_path53.default.dirname(targetPath), { recursive: true });
|
|
88008
88405
|
await import_promises29.default.writeFile(targetPath, JSON.stringify(manifest), "utf8");
|
|
88009
88406
|
}
|
|
88010
88407
|
post({ type: "storeSync", running: false, copied: result.copied, fromLabel: source.label });
|
|
@@ -88053,7 +88450,7 @@ ${last}` : ""}`);
|
|
|
88053
88450
|
type: "project",
|
|
88054
88451
|
hasWorkspace: workspaceRoot !== void 0,
|
|
88055
88452
|
...configured !== void 0 ? { configured } : {},
|
|
88056
|
-
...workspaceRoot !== void 0 ? { folder:
|
|
88453
|
+
...workspaceRoot !== void 0 ? { folder: import_node_path53.default.basename(workspaceRoot) } : {},
|
|
88057
88454
|
...author !== void 0 ? { author } : {},
|
|
88058
88455
|
...index !== void 0 ? { indexName: index } : {},
|
|
88059
88456
|
...ownerConfigured !== void 0 && ownerConfigured.length > 0 ? { ownerConfigured } : {},
|
|
@@ -88193,11 +88590,11 @@ ${last}` : ""}`);
|
|
|
88193
88590
|
if (workspaceRoot === void 0)
|
|
88194
88591
|
return found2;
|
|
88195
88592
|
const root = workspaceRoot;
|
|
88196
|
-
const relative =
|
|
88197
|
-
if (relative.startsWith("..") ||
|
|
88593
|
+
const relative = import_node_path53.default.relative(root, folder);
|
|
88594
|
+
if (relative.startsWith("..") || import_node_path53.default.isAbsolute(relative))
|
|
88198
88595
|
return found2;
|
|
88199
88596
|
const output = await new Promise((resolve) => {
|
|
88200
|
-
const child = (0,
|
|
88597
|
+
const child = (0, import_node_child_process16.spawn)("git", ["-c", "core.quotePath=false", "log", "--diff-filter=A", "--relative", "--format=@@%an", "--name-only", "--", relative.length > 0 ? relative : "."], {
|
|
88201
88598
|
cwd: root,
|
|
88202
88599
|
windowsHide: true
|
|
88203
88600
|
});
|
|
@@ -88211,7 +88608,7 @@ ${last}` : ""}`);
|
|
|
88211
88608
|
if (line.startsWith("@@"))
|
|
88212
88609
|
author = line.slice(2).trim();
|
|
88213
88610
|
else if (line.trim().length > 0 && author !== void 0 && author.length > 0) {
|
|
88214
|
-
found2.set(normalizeForComparison(
|
|
88611
|
+
found2.set(normalizeForComparison(import_node_path53.default.resolve(root, line.trim())), author);
|
|
88215
88612
|
}
|
|
88216
88613
|
}
|
|
88217
88614
|
return found2;
|
|
@@ -88255,7 +88652,7 @@ ${last}` : ""}`);
|
|
|
88255
88652
|
},
|
|
88256
88653
|
source,
|
|
88257
88654
|
folder,
|
|
88258
|
-
relative:
|
|
88655
|
+
relative: import_node_path53.default.relative(folder, filePath).split(import_node_path53.default.sep).join("/")
|
|
88259
88656
|
});
|
|
88260
88657
|
};
|
|
88261
88658
|
for (const folder of skillFolders) {
|
|
@@ -88273,7 +88670,7 @@ ${last}` : ""}`);
|
|
|
88273
88670
|
const name = entry.slice(0, -3);
|
|
88274
88671
|
if (!isValidToolName(name))
|
|
88275
88672
|
continue;
|
|
88276
|
-
await consider("tool", name,
|
|
88673
|
+
await consider("tool", name, import_node_path53.default.join(folder, entry), folder, location);
|
|
88277
88674
|
}
|
|
88278
88675
|
}
|
|
88279
88676
|
const readOnly = skills.filter((skill) => skill.sourceDir !== void 0 && !skillFolders.some((folder) => samePath(folder, skill.sourceDir))).length;
|
|
@@ -88305,7 +88702,7 @@ ${last}` : ""}`);
|
|
|
88305
88702
|
} catch {
|
|
88306
88703
|
}
|
|
88307
88704
|
}
|
|
88308
|
-
const gitAuthor = gitAuthors.get(normalizeForComparison(
|
|
88705
|
+
const gitAuthor = gitAuthors.get(normalizeForComparison(import_node_path53.default.resolve(candidate.entry.filePath)));
|
|
88309
88706
|
if (gitAuthor !== void 0) {
|
|
88310
88707
|
candidate.entry.suggestion = { author: gitAuthor, source: "git: the commit that added this file" };
|
|
88311
88708
|
}
|
|
@@ -88414,7 +88811,7 @@ ${last}` : ""}`);
|
|
|
88414
88811
|
aliases: plan3.kind === "codebase" ? codebaseAliases(config2) : plan3.kind === "skills" ? skillAliases(config2) : [],
|
|
88415
88812
|
onProgress: (count3) => post({ type: "indexRenames", running: true, plans, store, current: plan3.to, copied: count3 })
|
|
88416
88813
|
});
|
|
88417
|
-
await copyBookkeeping(
|
|
88814
|
+
await copyBookkeeping(import_node_path53.default.join(manifestsRoot, "index-manifests"), plan3.from, plan3.to, search.id);
|
|
88418
88815
|
done.push({ ...plan3, copied });
|
|
88419
88816
|
}
|
|
88420
88817
|
post({ type: "indexRenames", running: false, plans: [], store, done });
|
|
@@ -88444,7 +88841,7 @@ ${last}` : ""}`);
|
|
|
88444
88841
|
project: projectName(config2, workspaceRoot),
|
|
88445
88842
|
aliases: codebaseAliases(config2)
|
|
88446
88843
|
});
|
|
88447
|
-
await copyBookkeeping(
|
|
88844
|
+
await copyBookkeeping(import_node_path53.default.join(manifestsRoot, "index-manifests"), legacy, current, search.id);
|
|
88448
88845
|
post({ type: "indexRenames", running: false, plans: [], done: [{ kind: "codebase", from: legacy, to: current, copied }] });
|
|
88449
88846
|
logger.info(`copied ${String(copied)} chunks from ${legacy} to ${current} rather than re-embedding them`);
|
|
88450
88847
|
}
|
|
@@ -88610,7 +89007,7 @@ ${last}` : ""}`);
|
|
|
88610
89007
|
denylist,
|
|
88611
89008
|
manifest,
|
|
88612
89009
|
saveManifest: async (next) => {
|
|
88613
|
-
await import_promises29.default.mkdir(
|
|
89010
|
+
await import_promises29.default.mkdir(import_node_path53.default.dirname(manifestFile), { recursive: true });
|
|
88614
89011
|
await import_promises29.default.writeFile(manifestFile, JSON.stringify(next), "utf8");
|
|
88615
89012
|
},
|
|
88616
89013
|
...isIgnored2 !== void 0 ? { isIgnored: isIgnored2 } : {},
|
|
@@ -88696,9 +89093,9 @@ ${last}` : ""}`);
|
|
|
88696
89093
|
}
|
|
88697
89094
|
const usageLog = new UsageLog(storageDir);
|
|
88698
89095
|
const usageInstance = usageInstanceId(storageDir);
|
|
88699
|
-
const usageProfileFile =
|
|
88700
|
-
const legacyBackfillFile =
|
|
88701
|
-
const usageDir =
|
|
89096
|
+
const usageProfileFile = import_node_path53.default.join(storageDir, "usage-profile.json");
|
|
89097
|
+
const legacyBackfillFile = import_node_path53.default.join(storageDir, "usage-backfill.json");
|
|
89098
|
+
const usageDir = import_node_path53.default.join(storageDir, "usage");
|
|
88702
89099
|
const toolStartedAt = /* @__PURE__ */ new Map();
|
|
88703
89100
|
let usagePushTimer;
|
|
88704
89101
|
let usagePushing;
|
|
@@ -88716,7 +89113,7 @@ ${last}` : ""}`);
|
|
|
88716
89113
|
return (request) => runFastFs(exe, request);
|
|
88717
89114
|
}
|
|
88718
89115
|
function skillAtPath(requested2) {
|
|
88719
|
-
const absolute =
|
|
89116
|
+
const absolute = import_node_path53.default.isAbsolute(requested2) ? requested2 : workspaceRoot === void 0 ? void 0 : import_node_path53.default.resolve(workspaceRoot, requested2);
|
|
88720
89117
|
if (absolute === void 0)
|
|
88721
89118
|
return void 0;
|
|
88722
89119
|
return skills.find((skill) => samePath(skill.filePath, absolute));
|
|
@@ -88769,6 +89166,23 @@ ${last}` : ""}`);
|
|
|
88769
89166
|
}
|
|
88770
89167
|
void Promise.all(events.map((event) => usageLog.append(event))).then(() => scheduleUsagePush()).catch((error51) => logger.warn(`usage: could not record: ${String(error51)}`));
|
|
88771
89168
|
}
|
|
89169
|
+
function recordTokens(model, counted) {
|
|
89170
|
+
if (!usageCollecting())
|
|
89171
|
+
return;
|
|
89172
|
+
const project = cachedAttribution.project;
|
|
89173
|
+
const event = {
|
|
89174
|
+
t: Date.now(),
|
|
89175
|
+
u: cachedAttribution.author ?? "unknown",
|
|
89176
|
+
...project !== void 0 ? { p: project } : {},
|
|
89177
|
+
k: "tokens",
|
|
89178
|
+
n: model,
|
|
89179
|
+
i: Math.max(0, Math.round(counted.inputTokens)),
|
|
89180
|
+
o: Math.max(0, Math.round(counted.outputTokens)),
|
|
89181
|
+
...counted.cachedTokens !== void 0 && counted.cachedTokens > 0 ? { c: Math.round(counted.cachedTokens) } : {},
|
|
89182
|
+
...counted.estimated ? { e: 1 } : {}
|
|
89183
|
+
};
|
|
89184
|
+
void usageLog.append(event).then(() => scheduleUsagePush()).catch((error51) => logger.warn(`usage: could not record tokens: ${String(error51)}`));
|
|
89185
|
+
}
|
|
88772
89186
|
function scheduleUsagePush() {
|
|
88773
89187
|
if (usagePushTimer !== void 0)
|
|
88774
89188
|
clearTimeout(usagePushTimer);
|
|
@@ -88789,7 +89203,7 @@ ${last}` : ""}`);
|
|
|
88789
89203
|
const folder = chosen.path?.trim();
|
|
88790
89204
|
if (folder === void 0 || folder.length === 0)
|
|
88791
89205
|
return { problem: "The shared folder has no path." };
|
|
88792
|
-
if (!
|
|
89206
|
+
if (!import_node_path53.default.isAbsolute(folder))
|
|
88793
89207
|
return { problem: `"${folder}" is not an absolute path. Use the full path of a folder everybody can reach, such as a network share.` };
|
|
88794
89208
|
const helper = usageHelper();
|
|
88795
89209
|
return { store: new FolderShardStore(folder, ...helper !== void 0 ? [helper] : []), target };
|
|
@@ -88818,7 +89232,7 @@ ${last}` : ""}`);
|
|
|
88818
89232
|
}
|
|
88819
89233
|
async function readUsageBackfill() {
|
|
88820
89234
|
try {
|
|
88821
|
-
const text2 = await import_promises29.default.readFile(
|
|
89235
|
+
const text2 = await import_promises29.default.readFile(import_node_path53.default.join(usageDir, "backfill.json"), "utf8").catch(() => import_promises29.default.readFile(legacyBackfillFile, "utf8"));
|
|
88822
89236
|
const saved = JSON.parse(text2);
|
|
88823
89237
|
if (typeof saved.at !== "number")
|
|
88824
89238
|
return void 0;
|
|
@@ -88834,7 +89248,7 @@ ${last}` : ""}`);
|
|
|
88834
89248
|
legacyDoneFile: legacyBackfillFile,
|
|
88835
89249
|
run: async (before) => {
|
|
88836
89250
|
const status2 = python.status();
|
|
88837
|
-
return backfillFromTasks(
|
|
89251
|
+
return backfillFromTasks(import_node_path53.default.join(storageDir, "tasks"), {
|
|
88838
89252
|
user: cachedAttribution.author ?? "unknown",
|
|
88839
89253
|
project: cachedAttribution.project,
|
|
88840
89254
|
workspaceRoot,
|
|
@@ -89007,14 +89421,14 @@ ${last}` : ""}`);
|
|
|
89007
89421
|
kind: "tool",
|
|
89008
89422
|
name: issue2.name,
|
|
89009
89423
|
filePath: issue2.filePath,
|
|
89010
|
-
deletable: samePath(
|
|
89011
|
-
location: where(
|
|
89424
|
+
deletable: samePath(import_node_path53.default.dirname(issue2.filePath), status2.toolsDir),
|
|
89425
|
+
location: where(import_node_path53.default.dirname(issue2.filePath), status2.toolsDir),
|
|
89012
89426
|
issue: issue2.kind === "unapproved" ? "waiting for approval" : issue2.kind === "hash-mismatch" ? "changed since approval" : issue2.detail.split("\n")[0] ?? "not loaded"
|
|
89013
89427
|
});
|
|
89014
89428
|
}
|
|
89015
89429
|
return items;
|
|
89016
89430
|
}
|
|
89017
|
-
const usageDirectoryFile =
|
|
89431
|
+
const usageDirectoryFile = import_node_path53.default.join(storageDir, "usage-directory.json");
|
|
89018
89432
|
let directoryRunning;
|
|
89019
89433
|
async function readDirectoryCache() {
|
|
89020
89434
|
try {
|
|
@@ -89349,7 +89763,7 @@ ${last}` : ""}`);
|
|
|
89349
89763
|
let indexedFiles = 0;
|
|
89350
89764
|
if (index !== void 0) {
|
|
89351
89765
|
try {
|
|
89352
|
-
const manifest = JSON.parse(await import_promises29.default.readFile(
|
|
89766
|
+
const manifest = JSON.parse(await import_promises29.default.readFile(import_node_path53.default.join(manifestsRoot, "index-manifests", `${index}.json`), "utf8"));
|
|
89353
89767
|
indexedFiles = Object.keys(manifest.files ?? {}).length;
|
|
89354
89768
|
} catch {
|
|
89355
89769
|
}
|
|
@@ -89824,11 +90238,11 @@ ${last}` : ""}`);
|
|
|
89824
90238
|
answer({ error: bytes.length === 0 ? "There was nothing to save." : "That file is too large to save from here." });
|
|
89825
90239
|
return;
|
|
89826
90240
|
}
|
|
89827
|
-
const safeName = [...
|
|
89828
|
-
const extension =
|
|
90241
|
+
const safeName = [...import_node_path53.default.basename(name)].map((c2) => c2.charCodeAt(0) < 32 || '<>:"/\\|?*'.includes(c2) ? "-" : c2).join("") || "file";
|
|
90242
|
+
const extension = import_node_path53.default.extname(safeName).slice(1);
|
|
89829
90243
|
try {
|
|
89830
90244
|
const target = await ui.showSaveDialog({
|
|
89831
|
-
defaultName: workspaceRoot !== void 0 ?
|
|
90245
|
+
defaultName: workspaceRoot !== void 0 ? import_node_path53.default.join(workspaceRoot, safeName) : safeName,
|
|
89832
90246
|
...extension.length > 0 ? { extensions: [extension] } : {}
|
|
89833
90247
|
});
|
|
89834
90248
|
if (target === void 0) {
|
|
@@ -89909,8 +90323,8 @@ ${last}` : ""}`);
|
|
|
89909
90323
|
continue;
|
|
89910
90324
|
for (const key3 of section.keys)
|
|
89911
90325
|
patch[key3] = key3 === "profiles" && merged.profiles !== void 0 ? reconciled : merged[key3];
|
|
89912
|
-
for (const
|
|
89913
|
-
const head =
|
|
90326
|
+
for (const path64 of section.nested ?? []) {
|
|
90327
|
+
const head = path64.split(".")[0];
|
|
89914
90328
|
patch[head] = merged[head];
|
|
89915
90329
|
}
|
|
89916
90330
|
}
|
|
@@ -89946,7 +90360,7 @@ ${last}` : ""}`);
|
|
|
89946
90360
|
if (changeLedger !== void 0) {
|
|
89947
90361
|
const shared = await changeLedger.othersSince(targets, taskCheckpoint.createdAt);
|
|
89948
90362
|
if (shared.size > 0) {
|
|
89949
|
-
const shown2 = (file2) =>
|
|
90363
|
+
const shown2 = (file2) => import_node_path53.default.relative(workspaceRoot ?? "", file2).split(import_node_path53.default.sep).join("/");
|
|
89950
90364
|
const detail = [...shared].map(([file2, chats]) => `${shown2(file2)} (${chats.join(", ")})`).join("; ");
|
|
89951
90365
|
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");
|
|
89952
90366
|
if (!all) {
|
|
@@ -90144,7 +90558,7 @@ ${last}` : ""}`);
|
|
|
90144
90558
|
const pathRequest = pendingPathApprovals.get(id);
|
|
90145
90559
|
userGate.resolve(id, "approve");
|
|
90146
90560
|
if (pathRequest !== void 0) {
|
|
90147
|
-
const folder =
|
|
90561
|
+
const folder = import_node_path53.default.dirname(pathRequest);
|
|
90148
90562
|
sessionPathGrants.add(normalizeForComparison(pathRequest));
|
|
90149
90563
|
if (scope === "folder" && !cachedReadRoots.includes(folder)) {
|
|
90150
90564
|
const { config: config2 } = await configManager.load();
|
|
@@ -90384,10 +90798,10 @@ ${last}` : ""}`);
|
|
|
90384
90798
|
});
|
|
90385
90799
|
return;
|
|
90386
90800
|
}
|
|
90387
|
-
let dir =
|
|
90801
|
+
let dir = import_node_path53.default.dirname(import_node_path53.default.resolve(scriptPath));
|
|
90388
90802
|
for (let depth = 0; depth < 3; depth++) {
|
|
90389
90803
|
for (const name of VENV_DIR_NAMES) {
|
|
90390
|
-
const candidate =
|
|
90804
|
+
const candidate = import_node_path53.default.join(dir, name);
|
|
90391
90805
|
const found2 = await search(candidate);
|
|
90392
90806
|
if (found2 !== void 0) {
|
|
90393
90807
|
post({
|
|
@@ -90399,7 +90813,7 @@ ${last}` : ""}`);
|
|
|
90399
90813
|
return;
|
|
90400
90814
|
}
|
|
90401
90815
|
}
|
|
90402
|
-
const parent =
|
|
90816
|
+
const parent = import_node_path53.default.dirname(dir);
|
|
90403
90817
|
if (parent === dir)
|
|
90404
90818
|
break;
|
|
90405
90819
|
dir = parent;
|
|
@@ -90513,6 +90927,10 @@ ${last}` : ""}`);
|
|
|
90513
90927
|
userTurnWindingDown = false;
|
|
90514
90928
|
}
|
|
90515
90929
|
})();
|
|
90930
|
+
} else if (message5.type === "saveComposerDraft") {
|
|
90931
|
+
void saveComposerDraft(message5.text);
|
|
90932
|
+
} else if (message5.type === "requestComposerDraft") {
|
|
90933
|
+
void readComposerDraft().then((text2) => post({ type: "composerDraft", text: text2 }));
|
|
90516
90934
|
} else if (message5.type === "compactConversation") {
|
|
90517
90935
|
reportFailure("handleCompactConversation", handleCompactConversation());
|
|
90518
90936
|
} else if (message5.type === "pickContextFiles") {
|
|
@@ -91281,11 +91699,11 @@ Could not be drawn: ${entry.message}`);
|
|
|
91281
91699
|
let lastReportPath;
|
|
91282
91700
|
async function saveReport(title, contents) {
|
|
91283
91701
|
try {
|
|
91284
|
-
const directory =
|
|
91702
|
+
const directory = import_node_path53.default.join(storageDir, "reports");
|
|
91285
91703
|
await import_promises29.default.mkdir(directory, { recursive: true });
|
|
91286
91704
|
const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
91287
91705
|
const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
91288
|
-
const target =
|
|
91706
|
+
const target = import_node_path53.default.join(directory, `${stamp2}${slug.length > 0 ? `-${slug}` : ""}.md`);
|
|
91289
91707
|
await import_promises29.default.writeFile(target, `# ${title}
|
|
91290
91708
|
|
|
91291
91709
|
${contents}
|
|
@@ -91301,7 +91719,7 @@ ${contents}
|
|
|
91301
91719
|
const keep = 100;
|
|
91302
91720
|
const entries = (await import_promises29.default.readdir(directory)).filter((name) => name.endsWith(".md")).sort();
|
|
91303
91721
|
for (const name of entries.slice(0, Math.max(0, entries.length - keep))) {
|
|
91304
|
-
await import_promises29.default.rm(
|
|
91722
|
+
await import_promises29.default.rm(import_node_path53.default.join(directory, name), { force: true });
|
|
91305
91723
|
}
|
|
91306
91724
|
}
|
|
91307
91725
|
let scheduleTimer;
|
|
@@ -91414,10 +91832,10 @@ ${contents}
|
|
|
91414
91832
|
}
|
|
91415
91833
|
const CLAIM_STALE_MS = 60 * 60 * 1e3;
|
|
91416
91834
|
async function claimSchedule(id) {
|
|
91417
|
-
const claimPath =
|
|
91835
|
+
const claimPath = import_node_path53.default.join(storageDir, "schedule-claims", `${id}.json`);
|
|
91418
91836
|
const mine = JSON.stringify({ pid: process.pid, at: Date.now() });
|
|
91419
91837
|
try {
|
|
91420
|
-
await import_promises29.default.mkdir(
|
|
91838
|
+
await import_promises29.default.mkdir(import_node_path53.default.dirname(claimPath), { recursive: true });
|
|
91421
91839
|
await import_promises29.default.writeFile(claimPath, mine, { encoding: "utf8", flag: "wx" });
|
|
91422
91840
|
return true;
|
|
91423
91841
|
} catch (error51) {
|
|
@@ -91442,7 +91860,7 @@ ${contents}
|
|
|
91442
91860
|
}
|
|
91443
91861
|
}
|
|
91444
91862
|
async function releaseSchedule(id) {
|
|
91445
|
-
await import_promises29.default.rm(
|
|
91863
|
+
await import_promises29.default.rm(import_node_path53.default.join(storageDir, "schedule-claims", `${id}.json`), { force: true }).catch(() => void 0);
|
|
91446
91864
|
}
|
|
91447
91865
|
async function runSchedule(id, reason) {
|
|
91448
91866
|
if (reason === "due" && !await claimSchedule(id))
|
|
@@ -92113,11 +92531,11 @@ function createShowDiagramTool() {
|
|
|
92113
92531
|
|
|
92114
92532
|
// ../../packages/core/dist/lsp/manager.js
|
|
92115
92533
|
var import_promises30 = __toESM(require("node:fs/promises"), 1);
|
|
92116
|
-
var
|
|
92534
|
+
var import_node_path55 = __toESM(require("node:path"), 1);
|
|
92117
92535
|
|
|
92118
92536
|
// ../../packages/core/dist/lsp/catalog.js
|
|
92119
92537
|
var import_node_fs13 = require("node:fs");
|
|
92120
|
-
var
|
|
92538
|
+
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
92121
92539
|
var c = (command, ...args) => ({ command, args });
|
|
92122
92540
|
var LSP_LANGUAGES = [
|
|
92123
92541
|
{ id: "python", label: "Python", extensions: ["py", "pyi"], candidates: [c("pyright-langserver", "--stdio"), c("basedpyright-langserver", "--stdio"), c("pylsp"), c("jedi-language-server")] },
|
|
@@ -92165,16 +92583,16 @@ var LSP_LANGUAGES = [
|
|
|
92165
92583
|
{ id: "sql", label: "SQL", extensions: ["sql"], candidates: [c("sql-language-server", "up", "--method", "stdio")] }
|
|
92166
92584
|
];
|
|
92167
92585
|
function languageFor(file2) {
|
|
92168
|
-
const ext =
|
|
92586
|
+
const ext = import_node_path54.default.extname(file2).slice(1).toLowerCase();
|
|
92169
92587
|
return LSP_LANGUAGES.find((l) => l.extensions.includes(ext));
|
|
92170
92588
|
}
|
|
92171
92589
|
function languageIdFor(language, file2) {
|
|
92172
|
-
const ext =
|
|
92590
|
+
const ext = import_node_path54.default.extname(file2).slice(1).toLowerCase();
|
|
92173
92591
|
return language.languageIdFor?.(ext) ?? language.id;
|
|
92174
92592
|
}
|
|
92175
92593
|
var found = /* @__PURE__ */ new Map();
|
|
92176
92594
|
function findOnPath(command, env2 = process.env) {
|
|
92177
|
-
if (
|
|
92595
|
+
if (import_node_path54.default.isAbsolute(command))
|
|
92178
92596
|
return (0, import_node_fs13.existsSync)(command) ? command : void 0;
|
|
92179
92597
|
if (env2 !== process.env)
|
|
92180
92598
|
return searchPath(command, env2);
|
|
@@ -92186,11 +92604,11 @@ function findOnPath(command, env2 = process.env) {
|
|
|
92186
92604
|
return value;
|
|
92187
92605
|
}
|
|
92188
92606
|
function searchPath(command, env2) {
|
|
92189
|
-
const dirs = (env2.PATH ?? env2.Path ?? "").split(
|
|
92607
|
+
const dirs = (env2.PATH ?? env2.Path ?? "").split(import_node_path54.default.delimiter).filter((d) => d.length > 0);
|
|
92190
92608
|
const exts = process.platform === "win32" ? ["", ...(env2.PATHEXT ?? ".EXE;.CMD;.BAT").toLowerCase().split(";")] : [""];
|
|
92191
92609
|
for (const dir of dirs) {
|
|
92192
92610
|
for (const ext of exts) {
|
|
92193
|
-
const candidate =
|
|
92611
|
+
const candidate = import_node_path54.default.join(dir, command + ext);
|
|
92194
92612
|
if ((0, import_node_fs13.existsSync)(candidate) && (process.platform !== "win32" || ext !== "" || /\.(exe|cmd|bat)$/i.test(candidate)))
|
|
92195
92613
|
return candidate;
|
|
92196
92614
|
}
|
|
@@ -92199,7 +92617,7 @@ function searchPath(command, env2) {
|
|
|
92199
92617
|
}
|
|
92200
92618
|
|
|
92201
92619
|
// ../../packages/core/dist/lsp/client.js
|
|
92202
|
-
var
|
|
92620
|
+
var import_node_child_process17 = require("node:child_process");
|
|
92203
92621
|
var import_node_url = require("node:url");
|
|
92204
92622
|
function keyFor(uri) {
|
|
92205
92623
|
try {
|
|
@@ -92229,7 +92647,7 @@ var LspClient = class {
|
|
|
92229
92647
|
this.root = root;
|
|
92230
92648
|
this.log = log;
|
|
92231
92649
|
const shim = /\.(cmd|bat)$/i.test(executable);
|
|
92232
|
-
this.child = shim ? (0,
|
|
92650
|
+
this.child = shim ? (0, import_node_child_process17.spawn)(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", `"${executable}"`, ...args], { cwd: root, windowsHide: true, windowsVerbatimArguments: true }) : (0, import_node_child_process17.spawn)(executable, args, { cwd: root, windowsHide: true });
|
|
92233
92651
|
this.child.stdout?.on("data", (chunk) => this.onData(chunk));
|
|
92234
92652
|
this.child.stderr?.on("data", (chunk) => {
|
|
92235
92653
|
const text2 = chunk.toString("utf8").trim();
|
|
@@ -92243,6 +92661,7 @@ var LspClient = class {
|
|
|
92243
92661
|
p.reject(error51);
|
|
92244
92662
|
this.pending.clear();
|
|
92245
92663
|
});
|
|
92664
|
+
this.child.stdin?.on("error", () => void 0);
|
|
92246
92665
|
this.child.on("exit", (code) => {
|
|
92247
92666
|
this.exited = true;
|
|
92248
92667
|
this.lastError ??= `exited with code ${String(code)}`;
|
|
@@ -92422,7 +92841,7 @@ var LspManager = class {
|
|
|
92422
92841
|
return void 0;
|
|
92423
92842
|
const args = [...found2.candidate.args];
|
|
92424
92843
|
if (language.id === "java" && !args.includes("-data"))
|
|
92425
|
-
args.push("-data",
|
|
92844
|
+
args.push("-data", import_node_path55.default.join(this.storageDir, "jdtls-workspace"));
|
|
92426
92845
|
try {
|
|
92427
92846
|
client = new LspClient(found2.executable, args, this.root, this.log);
|
|
92428
92847
|
this.clients.set(language.id, client);
|
|
@@ -92443,7 +92862,7 @@ var LspManager = class {
|
|
|
92443
92862
|
this.failed.set(language.id, client.lastError ?? "stopped");
|
|
92444
92863
|
return void 0;
|
|
92445
92864
|
}
|
|
92446
|
-
return { server:
|
|
92865
|
+
return { server: import_node_path55.default.basename(client.executable).replace(/\.(exe|cmd|bat)$/i, ""), diagnostics: diagnostics ?? [] };
|
|
92447
92866
|
} catch (error51) {
|
|
92448
92867
|
this.failed.set(language.id, error51 instanceof Error ? error51.message : String(error51));
|
|
92449
92868
|
client.dispose();
|
|
@@ -92681,7 +93100,7 @@ ${snippet}`;
|
|
|
92681
93100
|
|
|
92682
93101
|
// ../../packages/core/dist/tools/applyDiff/parse.js
|
|
92683
93102
|
var SEARCH_MARKER = "<<<<<<< SEARCH";
|
|
92684
|
-
var
|
|
93103
|
+
var SEPARATOR2 = "=======";
|
|
92685
93104
|
var REPLACE_MARKER = ">>>>>>> REPLACE";
|
|
92686
93105
|
var DASH_SEPARATOR = "-------";
|
|
92687
93106
|
var START_LINE_PATTERN = /^:start_line:(\d+)$/;
|
|
@@ -92709,7 +93128,7 @@ function parseDiff(diffText) {
|
|
|
92709
93128
|
i++;
|
|
92710
93129
|
}
|
|
92711
93130
|
const searchLines = [];
|
|
92712
|
-
while (i < lines2.length && lines2[i] !==
|
|
93131
|
+
while (i < lines2.length && lines2[i] !== SEPARATOR2) {
|
|
92713
93132
|
const line = lines2[i] ?? "";
|
|
92714
93133
|
if (line === SEARCH_MARKER || line === REPLACE_MARKER || START_LINE_PATTERN.test(line)) {
|
|
92715
93134
|
return { ok: false, error: `Unexpected marker inside the SEARCH block at line ${i + 1}: "${line}"` };
|
|
@@ -92718,13 +93137,13 @@ function parseDiff(diffText) {
|
|
|
92718
93137
|
i++;
|
|
92719
93138
|
}
|
|
92720
93139
|
if (i >= lines2.length) {
|
|
92721
|
-
return { ok: false, error: `Missing "${
|
|
93140
|
+
return { ok: false, error: `Missing "${SEPARATOR2}" to end the SEARCH block.` };
|
|
92722
93141
|
}
|
|
92723
93142
|
i++;
|
|
92724
93143
|
const replaceLines = [];
|
|
92725
93144
|
while (i < lines2.length && lines2[i] !== REPLACE_MARKER) {
|
|
92726
93145
|
const line = lines2[i] ?? "";
|
|
92727
|
-
if (line === SEARCH_MARKER || line ===
|
|
93146
|
+
if (line === SEARCH_MARKER || line === SEPARATOR2 || START_LINE_PATTERN.test(line)) {
|
|
92728
93147
|
return { ok: false, error: `Unexpected marker inside the REPLACE block at line ${i + 1}: "${line}"` };
|
|
92729
93148
|
}
|
|
92730
93149
|
replaceLines.push(line);
|
|
@@ -93924,11 +94343,15 @@ what the page names, since a wiki page can be out of date and the server cannot.
|
|
|
93924
94343
|
then saves the ones that answered: it asks **every time**, the prompt shows the addresses before and after
|
|
93925
94344
|
with each changed one tried live, and it is never available to a schedule or with read-only access.
|
|
93926
94345
|
Addresses must be paths on your site (\`/v1/job/{job}\`) - never another host - and the ones that send
|
|
93927
|
-
(events, JIL) are never tried. Placeholders: {job}, {pattern}, {filter:name} (\`name==PAY_*\`), {runNum},
|
|
94346
|
+
(events, JIL) are never tried. Placeholders: {job}, {pattern}, {filter:name} (\`name==PAY_LOAD\` for one job, \`name=@PAY_*\` for a pattern - \`=@\` is how AutoSys matches a wildcard), {runNum},
|
|
93928
94347
|
{type}, {machine}, {calendar}. Even without any of this, a **pattern** works on a server with no pattern
|
|
93929
94348
|
status address: the jobs are listed and each one's status read in turn.
|
|
93930
94349
|
|
|
93931
|
-
**Share
|
|
94350
|
+
**Share all of AutoSys**: Settings \u2192 Export, tick only **AutoSys** - the site, addresses, gateway (token address, client
|
|
94351
|
+
id, headers), test job and read-only setting, without your user name or any password or secret; importing it with only
|
|
94352
|
+
**AutoSys** ticked replaces the importer's AutoSys settings and nothing else, keeping their own user name.
|
|
94353
|
+
|
|
94354
|
+
**Share only the addresses**: Settings \u2192 Export, tick only **AutoSys addresses**; colleagues import the
|
|
93932
94355
|
file with that section ticked. It carries config:autosys (paths) alone, so their own site, sign-in and
|
|
93933
94356
|
other DevOps settings are not touched. The assistant can write the same file (\`light_code_export_config\`
|
|
93934
94357
|
with the section \`autosysAddresses\`), for example next to an onboarding page.
|
|
@@ -94475,13 +94898,25 @@ data is empty, not 0. Needs Fire Code's helper (Fire Code, or VS Code with Fire
|
|
|
94475
94898
|
"most contributions",
|
|
94476
94899
|
"usage_stats",
|
|
94477
94900
|
"custom metrics",
|
|
94478
|
-
"usage data"
|
|
94901
|
+
"usage data",
|
|
94902
|
+
"tokens burned",
|
|
94903
|
+
"token usage",
|
|
94904
|
+
"tokens by person",
|
|
94905
|
+
"tokens per user",
|
|
94906
|
+
"token spend",
|
|
94907
|
+
"who uses the most tokens"
|
|
94479
94908
|
],
|
|
94480
94909
|
body: `
|
|
94481
94910
|
**Settings \u2192 Usage** shows which skills and tools are used, by whom, who writes them, and what needs
|
|
94482
94911
|
attention - for **Me** or the whole **Team**, over the last 24 hours, 7 days, 30 days, 90 days, a year,
|
|
94483
94912
|
or a **custom** date range. Every figure is compared with the previous period of the same length.
|
|
94484
94913
|
|
|
94914
|
+
**Tokens burned**: every model request's tokens - input (cached included), output, and how much of the input the
|
|
94915
|
+
provider served from its cache - by person (with each person's share of the team's tokens, a trend line and the
|
|
94916
|
+
models they used) and by model. The counts are the providers' own; a request whose provider gave no count is
|
|
94917
|
+
estimated, and the section says what share was. Counts and the model only, never the prompt or the reply. The
|
|
94918
|
+
\`usage_stats\` tool's \`events\` with kind \`tokens\` gives one row per request for your own sums.
|
|
94919
|
+
|
|
94485
94920
|
**Collection is automatic** wherever the team already shares a store: an **OpenSearch** connection
|
|
94486
94921
|
first, then **any other vector store** (Qdrant, Chroma - from Settings \u2192 Search, in a collection named
|
|
94487
94922
|
\`light-code-usage\`), then a **team S3 bucket** (one a skills or tools folder syncs or publishes to,
|
|
@@ -94723,7 +95158,7 @@ one with an \`ac:image\` element naming the attachment.
|
|
|
94723
95158
|
body: `
|
|
94724
95159
|
**Export once, import on each machine.** Settings \u2192 Providers \u2192 Share settings with your team \u2192
|
|
94725
95160
|
**Export** writes a JSON file of the sections you tick \u2014 providers, MCP servers, search, skills,
|
|
94726
|
-
Python, buckets, Confluence and more. The assistant can write the same file with
|
|
95161
|
+
Python, buckets, DevOps (Confluence, Jira, Bitbucket, Jenkins), AutoSys on its own, and more. The assistant can write the same file with
|
|
94727
95162
|
\`light_code_export_config\` for a guide or a page.
|
|
94728
95163
|
|
|
94729
95164
|
**Never in the file**: any secret (API keys, passwords, tokens), approvals, other per-project settings,
|
|
@@ -94958,7 +95393,24 @@ edits made outside the agent (in VS Code, say) are saved with \`hub_sync\` "push
|
|
|
94958
95393
|
"changes to the monitor",
|
|
94959
95394
|
"audit of changes",
|
|
94960
95395
|
"updated_by",
|
|
94961
|
-
"takeover"
|
|
95396
|
+
"takeover",
|
|
95397
|
+
"due since",
|
|
95398
|
+
"who changed this monitor",
|
|
95399
|
+
"commits",
|
|
95400
|
+
"bitbucket history",
|
|
95401
|
+
"git history",
|
|
95402
|
+
"personal check created as team",
|
|
95403
|
+
"copy from the grid",
|
|
95404
|
+
"copy cell",
|
|
95405
|
+
"copy the grid",
|
|
95406
|
+
"copy rows",
|
|
95407
|
+
"filter the grid",
|
|
95408
|
+
"column filter",
|
|
95409
|
+
"filter by value",
|
|
95410
|
+
"column chooser",
|
|
95411
|
+
"hide columns",
|
|
95412
|
+
"greater than",
|
|
95413
|
+
"between"
|
|
94962
95414
|
],
|
|
94963
95415
|
body: `
|
|
94964
95416
|
**Fire Code only.** Settings \u2192 Monitoring switches it on; a Monitoring button then appears at the top of the
|
|
@@ -95054,7 +95506,8 @@ a window, when it tries again rather than leave it unrun.
|
|
|
95054
95506
|
|
|
95055
95507
|
**When a check has not run on time**, its tile says so: **waiting\u2026** with the reason on hover (making sure it can run
|
|
95056
95508
|
here first, its turn behind 4 checks already running, a colleague's Fire Code has this window, the monitoring
|
|
95057
|
-
executor still starting), or **due N min ago** when it is past its time
|
|
95509
|
+
executor still starting), or **due N min ago** when it is past its time; its grid window says **Due since** the time
|
|
95510
|
+
it should have started (never "Next \u2026 ago"). The executor is started as soon as a monitor
|
|
95058
95511
|
uses a tool, not when the check falls due, and a tool's timeout counts from when the executor is up. A file or
|
|
95059
95512
|
database path on a share is checked in the background, so a share that does not answer never holds the dashboard up.
|
|
95060
95513
|
**If the colleague who won a window never reports** (their Fire Code closed or failed mid-check), one other member
|
|
@@ -95063,28 +95516,44 @@ takes the window over once its timeout and three more minutes have passed - by a
|
|
|
95063
95516
|
**Is the scheduler working?** A line at the top of the dashboard says **Scheduler running** and when it last looked
|
|
95064
95517
|
(every 3 seconds), with **Stop**; stopped, it says so, with **Start**; not heard from for 90 seconds it says **not
|
|
95065
95518
|
responding**, with **Start again**, which lets go of anything stuck and restarts its timer. Stopped means no check
|
|
95066
|
-
starts by itself - Run now still works and colleagues' checks still show -
|
|
95067
|
-
|
|
95519
|
+
starts by itself - Run now still works and colleagues' checks still show - until you start it again or Fire Code
|
|
95520
|
+
restarts: **it always starts with Fire Code**. Only you stop or start it, never an agent.
|
|
95068
95521
|
|
|
95069
95522
|
**Refresh** (the circular arrow at the top of the dashboard) brings the team's skills down now - its bucket folders and
|
|
95070
95523
|
the team repository - instead of at the next timed sync, reads the folders again, and says which monitors are new
|
|
95071
95524
|
and which are gone.
|
|
95072
95525
|
|
|
95073
|
-
**Who wrote it, and who changed it
|
|
95074
|
-
|
|
95075
|
-
|
|
95526
|
+
**Who wrote it, and who changed it** come from the file's history first: its commits in the **team repository
|
|
95527
|
+
(Bitbucket)** when it is kept there, else in the **git checkout** holding it - the newest commit says who changed it
|
|
95528
|
+
and when, unless the file has changed here since. Otherwise from its labels: every save Light Code or Fire Code makes
|
|
95529
|
+
labels a skill with \`version\`, \`updated\` and \`updated_by\` (who saved it), and a new one with its \`author\`; a
|
|
95530
|
+
file saved before \`updated_by\` existed shows no "by" rather than its author. The tile's tooltip and the grid
|
|
95531
|
+
window's header show them, with "(Bitbucket)" or "(git)" when from a commit; **Changes** (the grid window's arrow button, or "Updated \u2026 by \u2026" in its header) lists every
|
|
95076
95532
|
version - when, by whom, what changed (the schedule, which fields, or only the text around the monitor) and the
|
|
95077
|
-
monitor as it was. Each Fire Code records a version as it arrives; a team monitor's changes are also kept in the team
|
|
95533
|
+
monitor as it was - and the file's commits, with who, when and the commit message. Each Fire Code records a version as it arrives; a team monitor's changes are also kept in the team
|
|
95078
95534
|
index, so every member sees the same list however long their Fire Code was closed. Cleaning up history keeps them;
|
|
95079
95535
|
deleting the monitor removes your own record of it. The grid window's buttons are icons - hover one to see what it does.
|
|
95080
95536
|
|
|
95537
|
+
**Filtering the grid**: every column has a filter box under its name - text to find, or a condition: \`>50\`, \`>=50\`,
|
|
95538
|
+
\`<50\`, \`10..50\` (between), \`=x\`, \`!=x\`, \`!text\` (does not contain), \`"exact"\`, \`=\` (empty), \`!=\` (not empty);
|
|
95539
|
+
\`a, b\` for either and \`>10 & <50\` for both. A time column compares times. The funnel beside a column's name lists its
|
|
95540
|
+
values with how many rows have each - search them, tick the ones to show, **Only these** for what the search found.
|
|
95541
|
+
**Columns** in the toolbar chooses the columns shown, remembered for that monitor. Only the rows in view are drawn, so
|
|
95542
|
+
a grid of 100,000 rows filters, sorts and scrolls quickly; the count says how many rows the filters leave, with
|
|
95543
|
+
**Clear filters**.
|
|
95544
|
+
|
|
95545
|
+
**Copying from the grid**: click a cell to select it, Shift+click another for the block between, Ctrl+C to copy;
|
|
95546
|
+
right-click a cell for Copy cell / row / column / whole grid; the grid window's copy button takes every row the filters
|
|
95547
|
+
show, with headers. It pastes into Excel as cells and into Word or Outlook as a table, in the text the grid shows.
|
|
95548
|
+
|
|
95081
95549
|
**Offline**: when the team history cannot be reached, a team monitor still runs on this computer - its tile, colours
|
|
95082
95550
|
and notifications stay current - and the tile says **Offline \xB7 N not shared**. Once the history answers again, each
|
|
95083
95551
|
offline check claims its window: written if nobody had it, dropped if a colleague already checked that window. At
|
|
95084
95552
|
most 50 per monitor are kept for this, on disk.
|
|
95085
95553
|
|
|
95086
95554
|
**Personal monitors need nothing set up.** Ask for "a personal check" (or just a check, before team history exists)
|
|
95087
|
-
and the agent makes one only on this computer.
|
|
95555
|
+
and the agent makes one only on this computer. Your own words decide: a request saying personal, private or just
|
|
95556
|
+
for me is made personal whatever the agent passes.
|
|
95088
95557
|
|
|
95089
95558
|
**Team monitors need OpenSearch** (Settings \u2192 Monitoring \u2192 Team history): choose an OpenSearch connection from the
|
|
95090
95559
|
codebase monitoring runs with, and an index name the whole team shares. Without it a team monitor stays grey
|
|
@@ -95760,9 +96229,13 @@ called at all.
|
|
|
95760
96229
|
],
|
|
95761
96230
|
body: `
|
|
95762
96231
|
The token bar under the composer shows where the window is going \u2014 system prompt, tool
|
|
95763
|
-
definitions, history, results \u2014 plus the cache hit rate.
|
|
95764
|
-
|
|
95765
|
-
|
|
96232
|
+
definitions, history, results \u2014 plus the cache hit rate. Before a reply the numbers are **estimates**: a real tokeniser would be a large download and
|
|
96233
|
+
would still be wrong for a gateway that rewrites the prompt. **After each reply the total is the
|
|
96234
|
+
provider's own count** (OpenAI-compatible gateways and vLLM are asked for it; Anthropic and Gemini
|
|
96235
|
+
send it), and that count corrects the estimate for the same model from then on - so the bar, and
|
|
96236
|
+
the point where compaction starts, follow what the model really holds. Code, JSON, paths and logs
|
|
96237
|
+
take more tokens per character than prose, which is why an estimate alone read 175k while the
|
|
96238
|
+
gateway already counted over 262k. A refusal for length that states the prompt's size corrects it too.
|
|
95766
96239
|
|
|
95767
96240
|
**Results dominate**, not the prompt. So an oversized tool result is capped, the full output is
|
|
95768
96241
|
written to disk, and a handle is returned that the model can re-read with an offset. Nothing is
|
|
@@ -96047,6 +96520,8 @@ transcript was written.
|
|
|
96047
96520
|
"light mode",
|
|
96048
96521
|
"change the colour",
|
|
96049
96522
|
"change the color",
|
|
96523
|
+
"pycharm dark",
|
|
96524
|
+
"intellij dark",
|
|
96050
96525
|
"copy",
|
|
96051
96526
|
"paste",
|
|
96052
96527
|
"word",
|
|
@@ -96078,6 +96553,10 @@ is \`system\`, \`light\` or \`dark\`, because \`prefers-color-scheme\` follows t
|
|
|
96078
96553
|
setting, and a corporate browser pinned to light shows a light panel on a dark desktop with no way
|
|
96079
96554
|
out.
|
|
96080
96555
|
|
|
96556
|
+
**In IntelliJ and PyCharm the panel follows the IDE's theme**, and changes with it (plugin 0.4.63 on).
|
|
96557
|
+
There \`system\` means the IDE's theme - the embedded browser on its own always reports light - and
|
|
96558
|
+
Light or Dark in Settings \u2192 Appearance overrides it.
|
|
96559
|
+
|
|
96081
96560
|
Everything else follows the editor's theme through its own CSS variables, so Light Code tracks
|
|
96082
96561
|
whatever you have active rather than a fixed palette.
|
|
96083
96562
|
|
|
@@ -96145,9 +96624,26 @@ walkthrough, whose steps link straight into the tab each one is about. On the No
|
|
|
96145
96624
|
"grayed out",
|
|
96146
96625
|
"disabled",
|
|
96147
96626
|
"cannot click",
|
|
96148
|
-
"not clickable"
|
|
96627
|
+
"not clickable",
|
|
96628
|
+
"python.exe crashed",
|
|
96629
|
+
"python crashed",
|
|
96630
|
+
"stopped working",
|
|
96631
|
+
"agent crashed",
|
|
96632
|
+
"conversation lost",
|
|
96633
|
+
"draft lost",
|
|
96634
|
+
"typed message gone",
|
|
96635
|
+
"host.log"
|
|
96149
96636
|
],
|
|
96150
96637
|
body: `
|
|
96638
|
+
**The agent crashed, or python.exe "stopped working".** A Python tool's worker that crashes is restarted on the
|
|
96639
|
+
next call, and the call that hit it says why - the Windows crash code in words (an access violation in a native
|
|
96640
|
+
library, a stack overflow, a missing DLL) and Python's own last lines, which it now prints on a native crash. It no
|
|
96641
|
+
longer takes the agent down with it (it used to, through the worker's closed input). Fire Code also stops Windows
|
|
96642
|
+
showing its "stopped working" box for the programs it starts, which kept a crashed worker alive until dismissed. The
|
|
96643
|
+
conversation is saved as the turn goes - after your message and after each tool result - and what you were typing is
|
|
96644
|
+
kept by the agent as well, so a restart loses neither. Each chat's log is \`host.log\` in its data folder, with the
|
|
96645
|
+
run before as \`host.previous.log\`: an error the agent survived is written there as "kept running".
|
|
96646
|
+
|
|
96151
96647
|
**A button is greyed out.** Hover over it: every control that can be disabled says why in its
|
|
96152
96648
|
tooltip - nothing changed since the last save, a field still empty, a reply still running, a
|
|
96153
96649
|
feature switched off elsewhere - and usually what to do about it.
|
|
@@ -96405,8 +96901,8 @@ function createLightCodeHelpTool() {
|
|
|
96405
96901
|
}
|
|
96406
96902
|
|
|
96407
96903
|
// ../../packages/core/dist/tools/listFiles.js
|
|
96408
|
-
var
|
|
96409
|
-
var
|
|
96904
|
+
var import_node_child_process18 = require("node:child_process");
|
|
96905
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
96410
96906
|
|
|
96411
96907
|
// ../../packages/core/dist/tools/ripgrepError.js
|
|
96412
96908
|
function ripgrepDidNotStart(error51) {
|
|
@@ -96439,7 +96935,7 @@ function isRipgrepNoMatchError(error51) {
|
|
|
96439
96935
|
}
|
|
96440
96936
|
function runRipgrepFiles(rgPath, dir, signal, includeIgnored) {
|
|
96441
96937
|
return new Promise((resolve, reject2) => {
|
|
96442
|
-
(0,
|
|
96938
|
+
(0, import_node_child_process18.execFile)(rgPath, [
|
|
96443
96939
|
"--files",
|
|
96444
96940
|
"--hidden",
|
|
96445
96941
|
...includeIgnored ? ["--no-ignore-vcs"] : [],
|
|
@@ -96487,7 +96983,7 @@ var listFilesTool = {
|
|
|
96487
96983
|
});
|
|
96488
96984
|
if (files.length === 0)
|
|
96489
96985
|
return noFiles;
|
|
96490
|
-
const listed = files.map((file2) => file2.split("/").join(
|
|
96986
|
+
const listed = files.map((file2) => file2.split("/").join(import_node_path56.default.sep)).join("\n");
|
|
96491
96987
|
return { content: truncated ? `${listed}
|
|
96492
96988
|
(listing cut short \u2014 list a narrower folder)` : listed };
|
|
96493
96989
|
}
|
|
@@ -96649,7 +97145,7 @@ var readDocumentTool = {
|
|
|
96649
97145
|
};
|
|
96650
97146
|
|
|
96651
97147
|
// ../../packages/core/dist/tools/searchFiles.js
|
|
96652
|
-
var
|
|
97148
|
+
var import_node_child_process19 = require("node:child_process");
|
|
96653
97149
|
var paramsSchema22 = external_exports.object({
|
|
96654
97150
|
path: external_exports.string().min(1).default(".").describe("Directory to search, relative to the workspace root."),
|
|
96655
97151
|
pattern: external_exports.string().min(1).describe("Regular expression to search for."),
|
|
@@ -96668,7 +97164,7 @@ function runRipgrepSearch(rgPath, dir, pattern, filePattern, signal, includeIgno
|
|
|
96668
97164
|
args.push("-g", filePattern);
|
|
96669
97165
|
args.push("--regexp", pattern, ".");
|
|
96670
97166
|
return new Promise((resolve, reject2) => {
|
|
96671
|
-
(0,
|
|
97167
|
+
(0, import_node_child_process19.execFile)(rgPath, args, { cwd: dir, signal, maxBuffer: 10 * 1024 * 1024 }, (error51, stdout) => {
|
|
96672
97168
|
if (error51 && !isRipgrepNoMatchError2(error51)) {
|
|
96673
97169
|
reject2(error51);
|
|
96674
97170
|
return;
|
|
@@ -96716,7 +97212,7 @@ var searchFilesTool = {
|
|
|
96716
97212
|
};
|
|
96717
97213
|
|
|
96718
97214
|
// ../../packages/core/dist/tools/writeToFile.js
|
|
96719
|
-
var
|
|
97215
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
96720
97216
|
var paramsSchema23 = external_exports.object({
|
|
96721
97217
|
path: external_exports.string().min(1).describe("Path to the file, relative to the workspace root."),
|
|
96722
97218
|
content: external_exports.string().describe("Full file content to write.")
|
|
@@ -96744,7 +97240,7 @@ var writeToFileTool = {
|
|
|
96744
97240
|
return { content: changed, isError: true, path: params3.path };
|
|
96745
97241
|
}
|
|
96746
97242
|
if (!exists2) {
|
|
96747
|
-
await context.fs.mkdir(
|
|
97243
|
+
await context.fs.mkdir(import_node_path57.default.dirname(resolved.realPath));
|
|
96748
97244
|
}
|
|
96749
97245
|
await context.fs.writeFile(resolved.realPath, params3.content);
|
|
96750
97246
|
await recordWrite(context, resolved.realPath);
|
|
@@ -96846,14 +97342,14 @@ function createDefaultToolRegistry() {
|
|
|
96846
97342
|
|
|
96847
97343
|
// ../../packages/core/dist/dataset/store.js
|
|
96848
97344
|
var import_promises31 = __toESM(require("node:fs/promises"), 1);
|
|
96849
|
-
var
|
|
97345
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
96850
97346
|
var DatasetStore = class {
|
|
96851
97347
|
filePath;
|
|
96852
97348
|
statePath;
|
|
96853
97349
|
constructor(storageDir, datasetId) {
|
|
96854
97350
|
const safe = datasetId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
96855
|
-
this.filePath =
|
|
96856
|
-
this.statePath =
|
|
97351
|
+
this.filePath = import_node_path58.default.join(storageDir, "datasets", `${safe}.jsonl`);
|
|
97352
|
+
this.statePath = import_node_path58.default.join(storageDir, "datasets", `${safe}.state.json`);
|
|
96857
97353
|
}
|
|
96858
97354
|
/** Every record. A malformed line is skipped — one bad line costs one record, not the corpus. */
|
|
96859
97355
|
async load() {
|
|
@@ -96881,7 +97377,7 @@ var DatasetStore = class {
|
|
|
96881
97377
|
async append(records) {
|
|
96882
97378
|
if (records.length === 0)
|
|
96883
97379
|
return;
|
|
96884
|
-
await import_promises31.default.mkdir(
|
|
97380
|
+
await import_promises31.default.mkdir(import_node_path58.default.dirname(this.filePath), { recursive: true });
|
|
96885
97381
|
await import_promises31.default.writeFile(this.filePath, "", { flag: "a" });
|
|
96886
97382
|
const lines2 = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
96887
97383
|
await import_promises31.default.appendFile(this.filePath, `${lines2}
|
|
@@ -96889,7 +97385,7 @@ var DatasetStore = class {
|
|
|
96889
97385
|
}
|
|
96890
97386
|
/** Rewrites with exactly these. Temp-and-rename, so an interrupted prune leaves the old file. */
|
|
96891
97387
|
async replace(records) {
|
|
96892
|
-
await import_promises31.default.mkdir(
|
|
97388
|
+
await import_promises31.default.mkdir(import_node_path58.default.dirname(this.filePath), { recursive: true });
|
|
96893
97389
|
const temporary = `${this.filePath}.tmp`;
|
|
96894
97390
|
const body = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
96895
97391
|
await import_promises31.default.writeFile(temporary, records.length === 0 ? "" : `${body}
|
|
@@ -96943,7 +97439,7 @@ var DatasetStore = class {
|
|
|
96943
97439
|
}
|
|
96944
97440
|
}
|
|
96945
97441
|
async recordSync(at) {
|
|
96946
|
-
await import_promises31.default.mkdir(
|
|
97442
|
+
await import_promises31.default.mkdir(import_node_path58.default.dirname(this.statePath), { recursive: true });
|
|
96947
97443
|
const temporary = `${this.statePath}.tmp`;
|
|
96948
97444
|
await import_promises31.default.writeFile(temporary, JSON.stringify({ lastSyncedAt: at }), "utf8");
|
|
96949
97445
|
await replaceFile(temporary, this.statePath);
|
|
@@ -97375,8 +97871,8 @@ var S3Client = class {
|
|
|
97375
97871
|
const host = inPath ? origin.host : `${bucket}.${origin.host}`;
|
|
97376
97872
|
const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
|
|
97377
97873
|
const prefix = inPath ? `${mount}/${bucket}` : mount;
|
|
97378
|
-
const
|
|
97379
|
-
const url2 = new URL(`${origin.protocol}//${host}${prefix}${
|
|
97874
|
+
const path64 = key3 === "" ? "" : `/${key3.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
|
|
97875
|
+
const url2 = new URL(`${origin.protocol}//${host}${prefix}${path64}`);
|
|
97380
97876
|
for (const [name, value] of Object.entries(call.query ?? {}))
|
|
97381
97877
|
url2.searchParams.set(name, value);
|
|
97382
97878
|
return url2.toString();
|
|
@@ -98354,7 +98850,7 @@ async function readJsonBody(request, maxBytes = 32 * 1024 * 1024) {
|
|
|
98354
98850
|
|
|
98355
98851
|
// src/fileSecretStore.ts
|
|
98356
98852
|
var import_promises32 = __toESM(require("node:fs/promises"), 1);
|
|
98357
|
-
var
|
|
98853
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
98358
98854
|
|
|
98359
98855
|
// src/vaultCrypto.ts
|
|
98360
98856
|
var import_node_crypto21 = require("node:crypto");
|
|
@@ -98452,7 +98948,7 @@ var FileSecretStore = class {
|
|
|
98452
98948
|
);
|
|
98453
98949
|
}
|
|
98454
98950
|
mutate(secrets);
|
|
98455
|
-
await import_promises32.default.mkdir(
|
|
98951
|
+
await import_promises32.default.mkdir(import_node_path59.default.dirname(this.filePath), { recursive: true });
|
|
98456
98952
|
const temp = `${this.filePath}.${process.pid}.tmp`;
|
|
98457
98953
|
const body = this.key === void 0 ? secrets : sealSecrets(secrets, this.key);
|
|
98458
98954
|
await import_promises32.default.writeFile(temp, JSON.stringify(body, null, 2), { encoding: "utf8", mode: 384 });
|
|
@@ -98489,7 +98985,7 @@ var FileSecretStore = class {
|
|
|
98489
98985
|
// src/reviewQueue.ts
|
|
98490
98986
|
var import_node_crypto22 = __toESM(require("node:crypto"), 1);
|
|
98491
98987
|
var import_promises33 = __toESM(require("node:fs/promises"), 1);
|
|
98492
|
-
var
|
|
98988
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
98493
98989
|
var ReviewQueue = class {
|
|
98494
98990
|
constructor(filePath) {
|
|
98495
98991
|
this.filePath = filePath;
|
|
@@ -98508,7 +99004,7 @@ var ReviewQueue = class {
|
|
|
98508
99004
|
}
|
|
98509
99005
|
async persist(items) {
|
|
98510
99006
|
this.cache = items;
|
|
98511
|
-
await import_promises33.default.mkdir(
|
|
99007
|
+
await import_promises33.default.mkdir(import_node_path60.default.dirname(this.filePath), { recursive: true });
|
|
98512
99008
|
const temporary = `${this.filePath}.tmp`;
|
|
98513
99009
|
await import_promises33.default.writeFile(temporary, JSON.stringify(items, null, 2), { encoding: "utf8", mode: 384 });
|
|
98514
99010
|
await replaceFile(temporary, this.filePath);
|
|
@@ -98750,7 +99246,7 @@ var RoutedSecretStore = class {
|
|
|
98750
99246
|
// src/userVariables.ts
|
|
98751
99247
|
var import_promises34 = __toESM(require("node:fs/promises"), 1);
|
|
98752
99248
|
var import_node_fs14 = require("node:fs");
|
|
98753
|
-
var
|
|
99249
|
+
var import_node_path61 = __toESM(require("node:path"), 1);
|
|
98754
99250
|
var UserVariableStore = class {
|
|
98755
99251
|
constructor(filePath) {
|
|
98756
99252
|
this.filePath = filePath;
|
|
@@ -98765,7 +99261,7 @@ var UserVariableStore = class {
|
|
|
98765
99261
|
}
|
|
98766
99262
|
async save(variables) {
|
|
98767
99263
|
const parsed = sessionVariablesSchema.parse(variables);
|
|
98768
|
-
await import_promises34.default.mkdir(
|
|
99264
|
+
await import_promises34.default.mkdir(import_node_path61.default.dirname(this.filePath), { recursive: true });
|
|
98769
99265
|
const temporary = `${this.filePath}.tmp`;
|
|
98770
99266
|
await import_promises34.default.writeFile(temporary, JSON.stringify({ variables: parsed }, null, 2), {
|
|
98771
99267
|
encoding: "utf8",
|
|
@@ -98776,10 +99272,10 @@ var UserVariableStore = class {
|
|
|
98776
99272
|
}
|
|
98777
99273
|
};
|
|
98778
99274
|
function userVariableStoreFor(dataDir, principal) {
|
|
98779
|
-
return new UserVariableStore(userVariablesPath(
|
|
99275
|
+
return new UserVariableStore(userVariablesPath(import_node_path61.default.join(dataDir, "users", storageKeyFor(principal))));
|
|
98780
99276
|
}
|
|
98781
99277
|
function userVariablesPath(userDir) {
|
|
98782
|
-
return
|
|
99278
|
+
return import_node_path61.default.join(userDir, "variables.json");
|
|
98783
99279
|
}
|
|
98784
99280
|
function readVariablesFile(filePath) {
|
|
98785
99281
|
try {
|
|
@@ -98809,11 +99305,11 @@ function hostedUser(env2 = process.env) {
|
|
|
98809
99305
|
// src/session.ts
|
|
98810
99306
|
var import_node_fs15 = require("node:fs");
|
|
98811
99307
|
var import_promises35 = __toESM(require("node:fs/promises"), 1);
|
|
98812
|
-
var
|
|
99308
|
+
var import_node_path63 = __toESM(require("node:path"), 1);
|
|
98813
99309
|
|
|
98814
99310
|
// src/credentialTool.ts
|
|
98815
|
-
var
|
|
98816
|
-
var
|
|
99311
|
+
var import_node_child_process20 = require("node:child_process");
|
|
99312
|
+
var import_node_path62 = __toESM(require("node:path"), 1);
|
|
98817
99313
|
var CREDENTIAL_PREFIX2 = "tool:";
|
|
98818
99314
|
var WRAPPER = [
|
|
98819
99315
|
"import importlib.util, json, sys",
|
|
@@ -98833,7 +99329,7 @@ async function fetchCredential(options, reference) {
|
|
|
98833
99329
|
if (name.length === 0) return { problem: "A credential reference needs a name: tool:<name>." };
|
|
98834
99330
|
const budget = options.timeoutMs ?? 3e4;
|
|
98835
99331
|
const run3 = await new Promise((resolve) => {
|
|
98836
|
-
const child = (0,
|
|
99332
|
+
const child = (0, import_node_child_process20.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path62.default.resolve(options.file), name], {
|
|
98837
99333
|
windowsHide: true,
|
|
98838
99334
|
// The environment this was started in, as with the identity function: the libraries that
|
|
98839
99335
|
// hold credentials are configured through it, and nothing here is model-authored.
|
|
@@ -99029,7 +99525,7 @@ var FileConfigStore = class {
|
|
|
99029
99525
|
const filePath = this.pathFor(scope);
|
|
99030
99526
|
if (filePath === void 0)
|
|
99031
99527
|
throw new Error(`Cannot write ${scope} config: no workspace is open`);
|
|
99032
|
-
await import_promises35.default.mkdir(
|
|
99528
|
+
await import_promises35.default.mkdir(import_node_path63.default.dirname(filePath), { recursive: true });
|
|
99033
99529
|
const temporary = `${filePath}.${process.pid.toString(36)}.tmp`;
|
|
99034
99530
|
await import_promises35.default.writeFile(temporary, contents, { encoding: "utf8", mode: 384 });
|
|
99035
99531
|
await replaceFile(temporary, filePath);
|
|
@@ -99066,8 +99562,8 @@ var FileConfigStore = class {
|
|
|
99066
99562
|
};
|
|
99067
99563
|
let watcher;
|
|
99068
99564
|
try {
|
|
99069
|
-
watcher = (0, import_node_fs15.watch)(
|
|
99070
|
-
if (filename ===
|
|
99565
|
+
watcher = (0, import_node_fs15.watch)(import_node_path63.default.dirname(filePath), (_event, filename) => {
|
|
99566
|
+
if (filename === import_node_path63.default.basename(filePath)) onChange();
|
|
99071
99567
|
});
|
|
99072
99568
|
} catch {
|
|
99073
99569
|
}
|
|
@@ -99095,7 +99591,7 @@ var FileWorkspaceState = class {
|
|
|
99095
99591
|
async set(key3, value) {
|
|
99096
99592
|
if (value === void 0) delete this.values[key3];
|
|
99097
99593
|
else this.values[key3] = value;
|
|
99098
|
-
await import_promises35.default.mkdir(
|
|
99594
|
+
await import_promises35.default.mkdir(import_node_path63.default.dirname(this.filePath), { recursive: true });
|
|
99099
99595
|
await import_promises35.default.writeFile(this.filePath, JSON.stringify(this.values, null, 2), {
|
|
99100
99596
|
encoding: "utf8",
|
|
99101
99597
|
mode: 384
|
|
@@ -99144,7 +99640,7 @@ function createBrowserUi(workspaceRoot, post, fastFs) {
|
|
|
99144
99640
|
openFile: async (filePath) => {
|
|
99145
99641
|
try {
|
|
99146
99642
|
post(
|
|
99147
|
-
[`[info] ${
|
|
99643
|
+
[`[info] ${import_node_path63.default.basename(filePath)}`, "", await import_promises35.default.readFile(filePath, "utf8")].join("\n")
|
|
99148
99644
|
);
|
|
99149
99645
|
} catch (error51) {
|
|
99150
99646
|
post(`[warning] Could not read ${filePath}: ${String(error51)}`);
|
|
@@ -99186,7 +99682,7 @@ function createBrowserUi(workspaceRoot, post, fastFs) {
|
|
|
99186
99682
|
for (const entry of entries) {
|
|
99187
99683
|
if (found2.length >= limit) return;
|
|
99188
99684
|
if (entry.name.startsWith(".") && entry.name !== ".env") continue;
|
|
99189
|
-
const full =
|
|
99685
|
+
const full = import_node_path63.default.join(dir, entry.name);
|
|
99190
99686
|
if (entry.isDirectory()) {
|
|
99191
99687
|
if (!skip.has(entry.name)) await walk(full, level2 + 1);
|
|
99192
99688
|
} else if (depth !== void 0 && level2 !== depth) {
|
|
@@ -99222,11 +99718,11 @@ var SHARED_COLLECTIONS = [
|
|
|
99222
99718
|
{ key: "mcpServers" }
|
|
99223
99719
|
];
|
|
99224
99720
|
async function createSession(options) {
|
|
99225
|
-
const userDir =
|
|
99721
|
+
const userDir = import_node_path63.default.join(options.dataDir, "users", storageKeyFor(options.principal));
|
|
99226
99722
|
await import_promises35.default.mkdir(userDir, { recursive: true, mode: 448 });
|
|
99227
99723
|
const variableStore = new UserVariableStore(userVariablesPath(userDir));
|
|
99228
99724
|
const userVariables = () => variableStore.read();
|
|
99229
|
-
const workspaceState = new FileWorkspaceState(
|
|
99725
|
+
const workspaceState = new FileWorkspaceState(import_node_path63.default.join(userDir, "workspace-state.json"));
|
|
99230
99726
|
await workspaceState.load();
|
|
99231
99727
|
const services = {
|
|
99232
99728
|
/*
|
|
@@ -99318,16 +99814,16 @@ async function createSession(options) {
|
|
|
99318
99814
|
*/
|
|
99319
99815
|
secrets: new CredentialPointerStore(
|
|
99320
99816
|
withCredentialTool(
|
|
99321
|
-
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ??
|
|
99322
|
-
new FileSecretStore(options.secretsFile ??
|
|
99817
|
+
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ?? import_node_path63.default.join(userDir, "secrets.json"), options.secretsKey) : new RoutedSecretStore(
|
|
99818
|
+
new FileSecretStore(options.secretsFile ?? import_node_path63.default.join(userDir, "secrets.json"), options.secretsKey),
|
|
99323
99819
|
options.sharedSecrets
|
|
99324
99820
|
),
|
|
99325
99821
|
options
|
|
99326
99822
|
)
|
|
99327
99823
|
),
|
|
99328
99824
|
configStore: withSharedEntries(
|
|
99329
|
-
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ??
|
|
99330
|
-
new FileConfigStore(options.configFile ??
|
|
99825
|
+
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ?? import_node_path63.default.join(userDir, "config.json"), options.workspaceRoot) : new SharedProfileConfigStore(
|
|
99826
|
+
new FileConfigStore(options.configFile ?? import_node_path63.default.join(userDir, "config.json"), options.workspaceRoot),
|
|
99331
99827
|
options.sharedProfiles
|
|
99332
99828
|
),
|
|
99333
99829
|
options
|
|
@@ -99445,8 +99941,8 @@ async function startServer(options) {
|
|
|
99445
99941
|
));
|
|
99446
99942
|
const roles = options.roles ?? SINGLE_USER_POLICY;
|
|
99447
99943
|
const sharedStore = options.sharedConfig;
|
|
99448
|
-
const sharedSecretStore = new FileSecretStore(
|
|
99449
|
-
const reviews = new ReviewQueue(
|
|
99944
|
+
const sharedSecretStore = new FileSecretStore(import_node_path64.default.join(options.dataDir, "shared-secrets.json"));
|
|
99945
|
+
const reviews = new ReviewQueue(import_node_path64.default.join(options.dataDir, "reviews.json"));
|
|
99450
99946
|
let sharedCache = {
|
|
99451
99947
|
variables: [],
|
|
99452
99948
|
adminIds: [],
|
|
@@ -99825,14 +100321,14 @@ async function startServer(options) {
|
|
|
99825
100321
|
return "No workspace is open, so there is nowhere to write it.";
|
|
99826
100322
|
try {
|
|
99827
100323
|
if (item.kind === "skill") {
|
|
99828
|
-
const dir2 =
|
|
100324
|
+
const dir2 = import_node_path64.default.join(options.workspaceRoot, ".lightcode", "skills");
|
|
99829
100325
|
await import_promises36.default.mkdir(dir2, { recursive: true });
|
|
99830
|
-
await import_promises36.default.writeFile(
|
|
100326
|
+
await import_promises36.default.writeFile(import_node_path64.default.join(dir2, `${item.name}.md`), item.content, "utf8");
|
|
99831
100327
|
return void 0;
|
|
99832
100328
|
}
|
|
99833
|
-
const dir =
|
|
100329
|
+
const dir = import_node_path64.default.join(options.workspaceRoot, ".lightcode", "tools");
|
|
99834
100330
|
await import_promises36.default.mkdir(dir, { recursive: true });
|
|
99835
|
-
await import_promises36.default.writeFile(
|
|
100331
|
+
await import_promises36.default.writeFile(import_node_path64.default.join(dir, `${item.name}.py`), item.content, "utf8");
|
|
99836
100332
|
return void 0;
|
|
99837
100333
|
} catch (error51) {
|
|
99838
100334
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -99981,7 +100477,7 @@ async function startServer(options) {
|
|
|
99981
100477
|
return;
|
|
99982
100478
|
}
|
|
99983
100479
|
response.writeHead(200, {
|
|
99984
|
-
"Content-Type": CONTENT_TYPES2[
|
|
100480
|
+
"Content-Type": CONTENT_TYPES2[import_node_path64.default.extname(asset)] ?? "application/octet-stream",
|
|
99985
100481
|
...securityHeaders()
|
|
99986
100482
|
});
|
|
99987
100483
|
response.end(body);
|