@chosengeneration/light-code 0.35.0 → 0.37.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.js +1109 -281
- package/dist/client/client.js +50 -50
- package/dist/client/guide/appearance-dark.svg +1 -1
- package/dist/client/guide/appearance-light.svg +1 -1
- package/dist/client/guide/approvals-dark.svg +1 -1
- package/dist/client/guide/approvals-light.svg +1 -1
- package/dist/client/guide/customData-dark.svg +1 -0
- package/dist/client/guide/customData-light.svg +1 -0
- package/dist/client/guide/expert-dark.svg +1 -1
- package/dist/client/guide/expert-light.svg +1 -1
- package/dist/client/guide/mcp-dark.svg +1 -1
- package/dist/client/guide/mcp-light.svg +1 -1
- package/dist/client/guide/network-dark.svg +1 -1
- package/dist/client/guide/network-light.svg +1 -1
- package/dist/client/guide/providers-dark.svg +1 -1
- package/dist/client/guide/providers-light.svg +1 -1
- package/dist/client/guide/python-dark.svg +1 -1
- package/dist/client/guide/python-light.svg +1 -1
- package/dist/client/guide/schedules-dark.svg +1 -1
- package/dist/client/guide/schedules-light.svg +1 -1
- package/dist/client/guide/search-dark.svg +1 -1
- package/dist/client/guide/search-light.svg +1 -1
- package/dist/client/guide/skills-dark.svg +1 -1
- package/dist/client/guide/skills-light.svg +1 -1
- package/dist/client/guide/tools-dark.svg +1 -1
- package/dist/client/guide/tools-light.svg +1 -1
- package/dist/server.js +1061 -265
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -500,14 +500,14 @@ var require_util = __commonJS({
|
|
|
500
500
|
}
|
|
501
501
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
502
502
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol}//${url2.hostname}:${port}`;
|
|
503
|
-
let
|
|
503
|
+
let path34 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
504
504
|
if (origin.endsWith("/")) {
|
|
505
505
|
origin = origin.substring(0, origin.length - 1);
|
|
506
506
|
}
|
|
507
|
-
if (
|
|
508
|
-
|
|
507
|
+
if (path34 && !path34.startsWith("/")) {
|
|
508
|
+
path34 = `/${path34}`;
|
|
509
509
|
}
|
|
510
|
-
url2 = new URL(origin +
|
|
510
|
+
url2 = new URL(origin + path34);
|
|
511
511
|
}
|
|
512
512
|
return url2;
|
|
513
513
|
}
|
|
@@ -2121,20 +2121,20 @@ var require_parseParams = __commonJS({
|
|
|
2121
2121
|
var require_basename = __commonJS({
|
|
2122
2122
|
"../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/basename.js"(exports, module) {
|
|
2123
2123
|
"use strict";
|
|
2124
|
-
module.exports = function basename(
|
|
2125
|
-
if (typeof
|
|
2124
|
+
module.exports = function basename(path34) {
|
|
2125
|
+
if (typeof path34 !== "string") {
|
|
2126
2126
|
return "";
|
|
2127
2127
|
}
|
|
2128
|
-
for (var i =
|
|
2129
|
-
switch (
|
|
2128
|
+
for (var i = path34.length - 1; i >= 0; --i) {
|
|
2129
|
+
switch (path34.charCodeAt(i)) {
|
|
2130
2130
|
case 47:
|
|
2131
2131
|
// '/'
|
|
2132
2132
|
case 92:
|
|
2133
|
-
|
|
2134
|
-
return
|
|
2133
|
+
path34 = path34.slice(i + 1);
|
|
2134
|
+
return path34 === ".." || path34 === "." ? "" : path34;
|
|
2135
2135
|
}
|
|
2136
2136
|
}
|
|
2137
|
-
return
|
|
2137
|
+
return path34 === ".." || path34 === "." ? "" : path34;
|
|
2138
2138
|
};
|
|
2139
2139
|
}
|
|
2140
2140
|
});
|
|
@@ -5164,7 +5164,7 @@ var require_request = __commonJS({
|
|
|
5164
5164
|
}
|
|
5165
5165
|
var Request = class _Request {
|
|
5166
5166
|
constructor(origin, {
|
|
5167
|
-
path:
|
|
5167
|
+
path: path34,
|
|
5168
5168
|
method,
|
|
5169
5169
|
body,
|
|
5170
5170
|
headers,
|
|
@@ -5178,11 +5178,11 @@ var require_request = __commonJS({
|
|
|
5178
5178
|
throwOnError,
|
|
5179
5179
|
expectContinue
|
|
5180
5180
|
}, handler) {
|
|
5181
|
-
if (typeof
|
|
5181
|
+
if (typeof path34 !== "string") {
|
|
5182
5182
|
throw new InvalidArgumentError("path must be a string");
|
|
5183
|
-
} else if (
|
|
5183
|
+
} else if (path34[0] !== "/" && !(path34.startsWith("http://") || path34.startsWith("https://")) && method !== "CONNECT") {
|
|
5184
5184
|
throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
|
|
5185
|
-
} else if (invalidPathRegex.exec(
|
|
5185
|
+
} else if (invalidPathRegex.exec(path34) !== null) {
|
|
5186
5186
|
throw new InvalidArgumentError("invalid request path");
|
|
5187
5187
|
}
|
|
5188
5188
|
if (typeof method !== "string") {
|
|
@@ -5245,7 +5245,7 @@ var require_request = __commonJS({
|
|
|
5245
5245
|
this.completed = false;
|
|
5246
5246
|
this.aborted = false;
|
|
5247
5247
|
this.upgrade = upgrade || null;
|
|
5248
|
-
this.path = query ? util.buildURL(
|
|
5248
|
+
this.path = query ? util.buildURL(path34, query) : path34;
|
|
5249
5249
|
this.origin = origin;
|
|
5250
5250
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
5251
5251
|
this.blocking = blocking == null ? false : blocking;
|
|
@@ -6253,9 +6253,9 @@ var require_RedirectHandler = __commonJS({
|
|
|
6253
6253
|
return this.handler.onHeaders(statusCode, headers, resume, statusText);
|
|
6254
6254
|
}
|
|
6255
6255
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
6256
|
-
const
|
|
6256
|
+
const path34 = search ? `${pathname}${search}` : pathname;
|
|
6257
6257
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
6258
|
-
this.opts.path =
|
|
6258
|
+
this.opts.path = path34;
|
|
6259
6259
|
this.opts.origin = origin;
|
|
6260
6260
|
this.opts.maxRedirections = 0;
|
|
6261
6261
|
this.opts.query = null;
|
|
@@ -7495,7 +7495,7 @@ var require_client = __commonJS({
|
|
|
7495
7495
|
writeH2(client, client[kHTTP2Session], request);
|
|
7496
7496
|
return;
|
|
7497
7497
|
}
|
|
7498
|
-
const { body, method, path:
|
|
7498
|
+
const { body, method, path: path34, host, upgrade, headers, blocking, reset } = request;
|
|
7499
7499
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
7500
7500
|
if (body && typeof body.read === "function") {
|
|
7501
7501
|
body.read(0);
|
|
@@ -7545,7 +7545,7 @@ var require_client = __commonJS({
|
|
|
7545
7545
|
if (blocking) {
|
|
7546
7546
|
socket[kBlocking] = true;
|
|
7547
7547
|
}
|
|
7548
|
-
let header = `${method} ${
|
|
7548
|
+
let header = `${method} ${path34} HTTP/1.1\r
|
|
7549
7549
|
`;
|
|
7550
7550
|
if (typeof host === "string") {
|
|
7551
7551
|
header += `host: ${host}\r
|
|
@@ -7608,7 +7608,7 @@ upgrade: ${upgrade}\r
|
|
|
7608
7608
|
return true;
|
|
7609
7609
|
}
|
|
7610
7610
|
function writeH2(client, session, request) {
|
|
7611
|
-
const { body, method, path:
|
|
7611
|
+
const { body, method, path: path34, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
|
|
7612
7612
|
let headers;
|
|
7613
7613
|
if (typeof reqHeaders === "string") headers = Request[kHTTP2CopyHeaders](reqHeaders.trim());
|
|
7614
7614
|
else headers = reqHeaders;
|
|
@@ -7651,7 +7651,7 @@ upgrade: ${upgrade}\r
|
|
|
7651
7651
|
});
|
|
7652
7652
|
return true;
|
|
7653
7653
|
}
|
|
7654
|
-
headers[HTTP2_HEADER_PATH] =
|
|
7654
|
+
headers[HTTP2_HEADER_PATH] = path34;
|
|
7655
7655
|
headers[HTTP2_HEADER_SCHEME] = "https";
|
|
7656
7656
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
7657
7657
|
if (body && typeof body.read === "function") {
|
|
@@ -9891,20 +9891,20 @@ var require_mock_utils = __commonJS({
|
|
|
9891
9891
|
}
|
|
9892
9892
|
return true;
|
|
9893
9893
|
}
|
|
9894
|
-
function safeUrl(
|
|
9895
|
-
if (typeof
|
|
9896
|
-
return
|
|
9894
|
+
function safeUrl(path34) {
|
|
9895
|
+
if (typeof path34 !== "string") {
|
|
9896
|
+
return path34;
|
|
9897
9897
|
}
|
|
9898
|
-
const pathSegments =
|
|
9898
|
+
const pathSegments = path34.split("?");
|
|
9899
9899
|
if (pathSegments.length !== 2) {
|
|
9900
|
-
return
|
|
9900
|
+
return path34;
|
|
9901
9901
|
}
|
|
9902
9902
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
9903
9903
|
qp.sort();
|
|
9904
9904
|
return [...pathSegments, qp.toString()].join("?");
|
|
9905
9905
|
}
|
|
9906
|
-
function matchKey(mockDispatch2, { path:
|
|
9907
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
9906
|
+
function matchKey(mockDispatch2, { path: path34, method, body, headers }) {
|
|
9907
|
+
const pathMatch = matchValue(mockDispatch2.path, path34);
|
|
9908
9908
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
9909
9909
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
9910
9910
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -9922,7 +9922,7 @@ var require_mock_utils = __commonJS({
|
|
|
9922
9922
|
function getMockDispatch(mockDispatches, key) {
|
|
9923
9923
|
const basePath = key.query ? buildURL(key.path, key.query) : key.path;
|
|
9924
9924
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
9925
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
9925
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path34 }) => matchValue(safeUrl(path34), resolvedPath));
|
|
9926
9926
|
if (matchedMockDispatches.length === 0) {
|
|
9927
9927
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
9928
9928
|
}
|
|
@@ -9959,9 +9959,9 @@ var require_mock_utils = __commonJS({
|
|
|
9959
9959
|
}
|
|
9960
9960
|
}
|
|
9961
9961
|
function buildKey(opts) {
|
|
9962
|
-
const { path:
|
|
9962
|
+
const { path: path34, method, body, headers, query } = opts;
|
|
9963
9963
|
return {
|
|
9964
|
-
path:
|
|
9964
|
+
path: path34,
|
|
9965
9965
|
method,
|
|
9966
9966
|
body,
|
|
9967
9967
|
headers,
|
|
@@ -10410,10 +10410,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
10410
10410
|
}
|
|
10411
10411
|
format(pendingInterceptors) {
|
|
10412
10412
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
10413
|
-
({ method, path:
|
|
10413
|
+
({ method, path: path34, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
10414
10414
|
Method: method,
|
|
10415
10415
|
Origin: origin,
|
|
10416
|
-
Path:
|
|
10416
|
+
Path: path34,
|
|
10417
10417
|
"Status code": statusCode,
|
|
10418
10418
|
Persistent: persist ? "\u2705" : "\u274C",
|
|
10419
10419
|
Invocations: timesInvoked,
|
|
@@ -15033,8 +15033,8 @@ var require_util6 = __commonJS({
|
|
|
15033
15033
|
}
|
|
15034
15034
|
}
|
|
15035
15035
|
}
|
|
15036
|
-
function validateCookiePath(
|
|
15037
|
-
for (const char of
|
|
15036
|
+
function validateCookiePath(path34) {
|
|
15037
|
+
for (const char of path34) {
|
|
15038
15038
|
const code = char.charCodeAt(0);
|
|
15039
15039
|
if (code < 33 || char === ";") {
|
|
15040
15040
|
throw new Error("Invalid cookie path");
|
|
@@ -16714,11 +16714,11 @@ var require_undici = __commonJS({
|
|
|
16714
16714
|
if (typeof opts.path !== "string") {
|
|
16715
16715
|
throw new InvalidArgumentError("invalid opts.path");
|
|
16716
16716
|
}
|
|
16717
|
-
let
|
|
16717
|
+
let path34 = opts.path;
|
|
16718
16718
|
if (!opts.path.startsWith("/")) {
|
|
16719
|
-
|
|
16719
|
+
path34 = `/${path34}`;
|
|
16720
16720
|
}
|
|
16721
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
16721
|
+
url2 = new URL(util.parseOrigin(url2).origin + path34);
|
|
16722
16722
|
} else {
|
|
16723
16723
|
if (!opts) {
|
|
16724
16724
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -19989,8 +19989,8 @@ var require_utils2 = __commonJS({
|
|
|
19989
19989
|
}
|
|
19990
19990
|
return ind;
|
|
19991
19991
|
}
|
|
19992
|
-
function removeDotSegments(
|
|
19993
|
-
let input =
|
|
19992
|
+
function removeDotSegments(path34) {
|
|
19993
|
+
let input = path34;
|
|
19994
19994
|
const output = [];
|
|
19995
19995
|
let nextSlash = -1;
|
|
19996
19996
|
let len = 0;
|
|
@@ -20242,8 +20242,8 @@ var require_schemes = __commonJS({
|
|
|
20242
20242
|
wsComponent.secure = void 0;
|
|
20243
20243
|
}
|
|
20244
20244
|
if (wsComponent.resourceName) {
|
|
20245
|
-
const [
|
|
20246
|
-
wsComponent.path =
|
|
20245
|
+
const [path34, query] = wsComponent.resourceName.split("?");
|
|
20246
|
+
wsComponent.path = path34 && path34 !== "/" ? path34 : void 0;
|
|
20247
20247
|
wsComponent.query = query;
|
|
20248
20248
|
wsComponent.resourceName = void 0;
|
|
20249
20249
|
}
|
|
@@ -23642,12 +23642,12 @@ var require_dist = __commonJS({
|
|
|
23642
23642
|
throw new Error(`Unknown format "${name}"`);
|
|
23643
23643
|
return f;
|
|
23644
23644
|
};
|
|
23645
|
-
function addFormats(ajv, list,
|
|
23645
|
+
function addFormats(ajv, list, fs27, exportName) {
|
|
23646
23646
|
var _a3;
|
|
23647
23647
|
var _b;
|
|
23648
23648
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
23649
23649
|
for (const f of list)
|
|
23650
|
-
ajv.addFormat(f,
|
|
23650
|
+
ajv.addFormat(f, fs27[f]);
|
|
23651
23651
|
}
|
|
23652
23652
|
module.exports = exports = formatsPlugin;
|
|
23653
23653
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -23660,8 +23660,8 @@ var require_windows = __commonJS({
|
|
|
23660
23660
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
|
|
23661
23661
|
module.exports = isexe;
|
|
23662
23662
|
isexe.sync = sync;
|
|
23663
|
-
var
|
|
23664
|
-
function checkPathExt(
|
|
23663
|
+
var fs27 = __require("fs");
|
|
23664
|
+
function checkPathExt(path34, options) {
|
|
23665
23665
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
23666
23666
|
if (!pathext) {
|
|
23667
23667
|
return true;
|
|
@@ -23672,25 +23672,25 @@ var require_windows = __commonJS({
|
|
|
23672
23672
|
}
|
|
23673
23673
|
for (var i = 0; i < pathext.length; i++) {
|
|
23674
23674
|
var p = pathext[i].toLowerCase();
|
|
23675
|
-
if (p &&
|
|
23675
|
+
if (p && path34.substr(-p.length).toLowerCase() === p) {
|
|
23676
23676
|
return true;
|
|
23677
23677
|
}
|
|
23678
23678
|
}
|
|
23679
23679
|
return false;
|
|
23680
23680
|
}
|
|
23681
|
-
function checkStat(stat,
|
|
23681
|
+
function checkStat(stat, path34, options) {
|
|
23682
23682
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
23683
23683
|
return false;
|
|
23684
23684
|
}
|
|
23685
|
-
return checkPathExt(
|
|
23685
|
+
return checkPathExt(path34, options);
|
|
23686
23686
|
}
|
|
23687
|
-
function isexe(
|
|
23688
|
-
|
|
23689
|
-
cb(er, er ? false : checkStat(stat,
|
|
23687
|
+
function isexe(path34, options, cb) {
|
|
23688
|
+
fs27.stat(path34, function(er, stat) {
|
|
23689
|
+
cb(er, er ? false : checkStat(stat, path34, options));
|
|
23690
23690
|
});
|
|
23691
23691
|
}
|
|
23692
|
-
function sync(
|
|
23693
|
-
return checkStat(
|
|
23692
|
+
function sync(path34, options) {
|
|
23693
|
+
return checkStat(fs27.statSync(path34), path34, options);
|
|
23694
23694
|
}
|
|
23695
23695
|
}
|
|
23696
23696
|
});
|
|
@@ -23700,14 +23700,14 @@ var require_mode = __commonJS({
|
|
|
23700
23700
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
|
|
23701
23701
|
module.exports = isexe;
|
|
23702
23702
|
isexe.sync = sync;
|
|
23703
|
-
var
|
|
23704
|
-
function isexe(
|
|
23705
|
-
|
|
23703
|
+
var fs27 = __require("fs");
|
|
23704
|
+
function isexe(path34, options, cb) {
|
|
23705
|
+
fs27.stat(path34, function(er, stat) {
|
|
23706
23706
|
cb(er, er ? false : checkStat(stat, options));
|
|
23707
23707
|
});
|
|
23708
23708
|
}
|
|
23709
|
-
function sync(
|
|
23710
|
-
return checkStat(
|
|
23709
|
+
function sync(path34, options) {
|
|
23710
|
+
return checkStat(fs27.statSync(path34), options);
|
|
23711
23711
|
}
|
|
23712
23712
|
function checkStat(stat, options) {
|
|
23713
23713
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -23731,7 +23731,7 @@ var require_mode = __commonJS({
|
|
|
23731
23731
|
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
23732
23732
|
var require_isexe = __commonJS({
|
|
23733
23733
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
|
|
23734
|
-
var
|
|
23734
|
+
var fs27 = __require("fs");
|
|
23735
23735
|
var core;
|
|
23736
23736
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
23737
23737
|
core = require_windows();
|
|
@@ -23740,7 +23740,7 @@ var require_isexe = __commonJS({
|
|
|
23740
23740
|
}
|
|
23741
23741
|
module.exports = isexe;
|
|
23742
23742
|
isexe.sync = sync;
|
|
23743
|
-
function isexe(
|
|
23743
|
+
function isexe(path34, options, cb) {
|
|
23744
23744
|
if (typeof options === "function") {
|
|
23745
23745
|
cb = options;
|
|
23746
23746
|
options = {};
|
|
@@ -23750,7 +23750,7 @@ var require_isexe = __commonJS({
|
|
|
23750
23750
|
throw new TypeError("callback not provided");
|
|
23751
23751
|
}
|
|
23752
23752
|
return new Promise(function(resolve, reject2) {
|
|
23753
|
-
isexe(
|
|
23753
|
+
isexe(path34, options || {}, function(er, is) {
|
|
23754
23754
|
if (er) {
|
|
23755
23755
|
reject2(er);
|
|
23756
23756
|
} else {
|
|
@@ -23759,7 +23759,7 @@ var require_isexe = __commonJS({
|
|
|
23759
23759
|
});
|
|
23760
23760
|
});
|
|
23761
23761
|
}
|
|
23762
|
-
core(
|
|
23762
|
+
core(path34, options || {}, function(er, is) {
|
|
23763
23763
|
if (er) {
|
|
23764
23764
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
23765
23765
|
er = null;
|
|
@@ -23769,9 +23769,9 @@ var require_isexe = __commonJS({
|
|
|
23769
23769
|
cb(er, is);
|
|
23770
23770
|
});
|
|
23771
23771
|
}
|
|
23772
|
-
function sync(
|
|
23772
|
+
function sync(path34, options) {
|
|
23773
23773
|
try {
|
|
23774
|
-
return core.sync(
|
|
23774
|
+
return core.sync(path34, options || {});
|
|
23775
23775
|
} catch (er) {
|
|
23776
23776
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
23777
23777
|
return false;
|
|
@@ -23787,7 +23787,7 @@ var require_isexe = __commonJS({
|
|
|
23787
23787
|
var require_which = __commonJS({
|
|
23788
23788
|
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
|
|
23789
23789
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
23790
|
-
var
|
|
23790
|
+
var path34 = __require("path");
|
|
23791
23791
|
var COLON = isWindows ? ";" : ":";
|
|
23792
23792
|
var isexe = require_isexe();
|
|
23793
23793
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -23825,7 +23825,7 @@ var require_which = __commonJS({
|
|
|
23825
23825
|
return opt.all && found.length ? resolve(found) : reject2(getNotFoundError(cmd));
|
|
23826
23826
|
const ppRaw = pathEnv[i];
|
|
23827
23827
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
23828
|
-
const pCmd =
|
|
23828
|
+
const pCmd = path34.join(pathPart, cmd);
|
|
23829
23829
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
23830
23830
|
resolve(subStep(p, i, 0));
|
|
23831
23831
|
});
|
|
@@ -23852,7 +23852,7 @@ var require_which = __commonJS({
|
|
|
23852
23852
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
23853
23853
|
const ppRaw = pathEnv[i];
|
|
23854
23854
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
23855
|
-
const pCmd =
|
|
23855
|
+
const pCmd = path34.join(pathPart, cmd);
|
|
23856
23856
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
23857
23857
|
for (let j = 0; j < pathExt.length; j++) {
|
|
23858
23858
|
const cur = p + pathExt[j];
|
|
@@ -23900,7 +23900,7 @@ var require_path_key = __commonJS({
|
|
|
23900
23900
|
var require_resolveCommand = __commonJS({
|
|
23901
23901
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
23902
23902
|
"use strict";
|
|
23903
|
-
var
|
|
23903
|
+
var path34 = __require("path");
|
|
23904
23904
|
var which = require_which();
|
|
23905
23905
|
var getPathKey = require_path_key();
|
|
23906
23906
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -23918,7 +23918,7 @@ var require_resolveCommand = __commonJS({
|
|
|
23918
23918
|
try {
|
|
23919
23919
|
resolved = which.sync(parsed.command, {
|
|
23920
23920
|
path: env2[getPathKey({ env: env2 })],
|
|
23921
|
-
pathExt: withoutPathExt ?
|
|
23921
|
+
pathExt: withoutPathExt ? path34.delimiter : void 0
|
|
23922
23922
|
});
|
|
23923
23923
|
} catch (e) {
|
|
23924
23924
|
} finally {
|
|
@@ -23927,7 +23927,7 @@ var require_resolveCommand = __commonJS({
|
|
|
23927
23927
|
}
|
|
23928
23928
|
}
|
|
23929
23929
|
if (resolved) {
|
|
23930
|
-
resolved =
|
|
23930
|
+
resolved = path34.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
23931
23931
|
}
|
|
23932
23932
|
return resolved;
|
|
23933
23933
|
}
|
|
@@ -23981,8 +23981,8 @@ var require_shebang_command = __commonJS({
|
|
|
23981
23981
|
if (!match) {
|
|
23982
23982
|
return null;
|
|
23983
23983
|
}
|
|
23984
|
-
const [
|
|
23985
|
-
const binary =
|
|
23984
|
+
const [path34, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
23985
|
+
const binary = path34.split("/").pop();
|
|
23986
23986
|
if (binary === "env") {
|
|
23987
23987
|
return argument;
|
|
23988
23988
|
}
|
|
@@ -23995,16 +23995,16 @@ var require_shebang_command = __commonJS({
|
|
|
23995
23995
|
var require_readShebang = __commonJS({
|
|
23996
23996
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
23997
23997
|
"use strict";
|
|
23998
|
-
var
|
|
23998
|
+
var fs27 = __require("fs");
|
|
23999
23999
|
var shebangCommand = require_shebang_command();
|
|
24000
24000
|
function readShebang(command) {
|
|
24001
24001
|
const size = 150;
|
|
24002
24002
|
const buffer = Buffer.alloc(size);
|
|
24003
24003
|
let fd;
|
|
24004
24004
|
try {
|
|
24005
|
-
fd =
|
|
24006
|
-
|
|
24007
|
-
|
|
24005
|
+
fd = fs27.openSync(command, "r");
|
|
24006
|
+
fs27.readSync(fd, buffer, 0, size, 0);
|
|
24007
|
+
fs27.closeSync(fd);
|
|
24008
24008
|
} catch (e) {
|
|
24009
24009
|
}
|
|
24010
24010
|
return shebangCommand(buffer.toString());
|
|
@@ -24017,7 +24017,7 @@ var require_readShebang = __commonJS({
|
|
|
24017
24017
|
var require_parse2 = __commonJS({
|
|
24018
24018
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
24019
24019
|
"use strict";
|
|
24020
|
-
var
|
|
24020
|
+
var path34 = __require("path");
|
|
24021
24021
|
var resolveCommand = require_resolveCommand();
|
|
24022
24022
|
var escape2 = require_escape();
|
|
24023
24023
|
var readShebang = require_readShebang();
|
|
@@ -24042,7 +24042,7 @@ var require_parse2 = __commonJS({
|
|
|
24042
24042
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
24043
24043
|
if (parsed.options.forceShell || needsShell) {
|
|
24044
24044
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
24045
|
-
parsed.command =
|
|
24045
|
+
parsed.command = path34.normalize(parsed.command);
|
|
24046
24046
|
parsed.command = escape2.command(parsed.command);
|
|
24047
24047
|
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
|
|
24048
24048
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -24305,9 +24305,9 @@ function installNodeCompat() {
|
|
|
24305
24305
|
|
|
24306
24306
|
// src/cli.ts
|
|
24307
24307
|
import { spawn as spawn7 } from "node:child_process";
|
|
24308
|
-
import
|
|
24308
|
+
import fs26 from "node:fs/promises";
|
|
24309
24309
|
import os3 from "node:os";
|
|
24310
|
-
import
|
|
24310
|
+
import path33 from "node:path";
|
|
24311
24311
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
24312
24312
|
|
|
24313
24313
|
// ../../node_modules/.pnpm/env-paths@3.0.0/node_modules/env-paths/index.js
|
|
@@ -24764,8 +24764,8 @@ function renderGuide(colour, source = OPERATOR_GUIDE) {
|
|
|
24764
24764
|
}
|
|
24765
24765
|
|
|
24766
24766
|
// src/sharedConfig.ts
|
|
24767
|
-
import
|
|
24768
|
-
import
|
|
24767
|
+
import fs20 from "node:fs/promises";
|
|
24768
|
+
import path27 from "node:path";
|
|
24769
24769
|
|
|
24770
24770
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
24771
24771
|
var external_exports = {};
|
|
@@ -25533,10 +25533,10 @@ function mergeDefs(...defs) {
|
|
|
25533
25533
|
function cloneDef(schema) {
|
|
25534
25534
|
return mergeDefs(schema._zod.def);
|
|
25535
25535
|
}
|
|
25536
|
-
function getElementAtPath(obj,
|
|
25537
|
-
if (!
|
|
25536
|
+
function getElementAtPath(obj, path34) {
|
|
25537
|
+
if (!path34)
|
|
25538
25538
|
return obj;
|
|
25539
|
-
return
|
|
25539
|
+
return path34.reduce((acc, key) => acc?.[key], obj);
|
|
25540
25540
|
}
|
|
25541
25541
|
function promiseAllObject(promisesObj) {
|
|
25542
25542
|
const keys = Object.keys(promisesObj);
|
|
@@ -25945,11 +25945,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
25945
25945
|
}
|
|
25946
25946
|
return false;
|
|
25947
25947
|
}
|
|
25948
|
-
function prefixIssues(
|
|
25948
|
+
function prefixIssues(path34, issues) {
|
|
25949
25949
|
return issues.map((iss) => {
|
|
25950
25950
|
var _a3;
|
|
25951
25951
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
25952
|
-
iss.path.unshift(
|
|
25952
|
+
iss.path.unshift(path34);
|
|
25953
25953
|
return iss;
|
|
25954
25954
|
});
|
|
25955
25955
|
}
|
|
@@ -26096,16 +26096,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26096
26096
|
}
|
|
26097
26097
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
26098
26098
|
const fieldErrors = { _errors: [] };
|
|
26099
|
-
const processError = (error52,
|
|
26099
|
+
const processError = (error52, path34 = []) => {
|
|
26100
26100
|
for (const issue2 of error52.issues) {
|
|
26101
26101
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
26102
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
26102
|
+
issue2.errors.map((issues) => processError({ issues }, [...path34, ...issue2.path]));
|
|
26103
26103
|
} else if (issue2.code === "invalid_key") {
|
|
26104
|
-
processError({ issues: issue2.issues }, [...
|
|
26104
|
+
processError({ issues: issue2.issues }, [...path34, ...issue2.path]);
|
|
26105
26105
|
} else if (issue2.code === "invalid_element") {
|
|
26106
|
-
processError({ issues: issue2.issues }, [...
|
|
26106
|
+
processError({ issues: issue2.issues }, [...path34, ...issue2.path]);
|
|
26107
26107
|
} else {
|
|
26108
|
-
const fullpath = [...
|
|
26108
|
+
const fullpath = [...path34, ...issue2.path];
|
|
26109
26109
|
if (fullpath.length === 0) {
|
|
26110
26110
|
fieldErrors._errors.push(mapper(issue2));
|
|
26111
26111
|
} else {
|
|
@@ -26132,17 +26132,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26132
26132
|
}
|
|
26133
26133
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
26134
26134
|
const result = { errors: [] };
|
|
26135
|
-
const processError = (error52,
|
|
26135
|
+
const processError = (error52, path34 = []) => {
|
|
26136
26136
|
var _a3, _b;
|
|
26137
26137
|
for (const issue2 of error52.issues) {
|
|
26138
26138
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
26139
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
26139
|
+
issue2.errors.map((issues) => processError({ issues }, [...path34, ...issue2.path]));
|
|
26140
26140
|
} else if (issue2.code === "invalid_key") {
|
|
26141
|
-
processError({ issues: issue2.issues }, [...
|
|
26141
|
+
processError({ issues: issue2.issues }, [...path34, ...issue2.path]);
|
|
26142
26142
|
} else if (issue2.code === "invalid_element") {
|
|
26143
|
-
processError({ issues: issue2.issues }, [...
|
|
26143
|
+
processError({ issues: issue2.issues }, [...path34, ...issue2.path]);
|
|
26144
26144
|
} else {
|
|
26145
|
-
const fullpath = [...
|
|
26145
|
+
const fullpath = [...path34, ...issue2.path];
|
|
26146
26146
|
if (fullpath.length === 0) {
|
|
26147
26147
|
result.errors.push(mapper(issue2));
|
|
26148
26148
|
continue;
|
|
@@ -26174,8 +26174,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26174
26174
|
}
|
|
26175
26175
|
function toDotPath(_path) {
|
|
26176
26176
|
const segs = [];
|
|
26177
|
-
const
|
|
26178
|
-
for (const seg of
|
|
26177
|
+
const path34 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
26178
|
+
for (const seg of path34) {
|
|
26179
26179
|
if (typeof seg === "number")
|
|
26180
26180
|
segs.push(`[${seg}]`);
|
|
26181
26181
|
else if (typeof seg === "symbol")
|
|
@@ -38867,13 +38867,13 @@ function resolveRef(ref, ctx) {
|
|
|
38867
38867
|
if (!ref.startsWith("#")) {
|
|
38868
38868
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
38869
38869
|
}
|
|
38870
|
-
const
|
|
38871
|
-
if (
|
|
38870
|
+
const path34 = ref.slice(1).split("/").filter(Boolean);
|
|
38871
|
+
if (path34.length === 0) {
|
|
38872
38872
|
return ctx.rootSchema;
|
|
38873
38873
|
}
|
|
38874
38874
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
38875
|
-
if (
|
|
38876
|
-
const key =
|
|
38875
|
+
if (path34[0] === defsKey) {
|
|
38876
|
+
const key = path34[1];
|
|
38877
38877
|
if (!key || !ctx.defs[key]) {
|
|
38878
38878
|
throw new Error(`Reference not found: ${ref}`);
|
|
38879
38879
|
}
|
|
@@ -39447,6 +39447,79 @@ async function build(options, paths) {
|
|
|
39447
39447
|
return tls2;
|
|
39448
39448
|
}
|
|
39449
39449
|
|
|
39450
|
+
// ../../packages/core/dist/dataset/types.js
|
|
39451
|
+
var datasetRecordSchema = external_exports.object({
|
|
39452
|
+
/**
|
|
39453
|
+
* Stable across syncs. The same record from the source must come back with the same id, or a
|
|
39454
|
+
* re-sync duplicates it rather than replacing it — which is the failure that turns a useful
|
|
39455
|
+
* corpus into noise a few runs in.
|
|
39456
|
+
*/
|
|
39457
|
+
id: external_exports.string().min(1),
|
|
39458
|
+
/** What gets embedded and what a search returns. */
|
|
39459
|
+
text: external_exports.string().min(1),
|
|
39460
|
+
/** A heading for the search result. Falls back to the opening of `text`. */
|
|
39461
|
+
title: external_exports.string().optional(),
|
|
39462
|
+
/** Where it came from — a ticket URL, a file path. Shown so a hit can be followed up. */
|
|
39463
|
+
url: external_exports.string().optional(),
|
|
39464
|
+
/**
|
|
39465
|
+
* Epoch milliseconds. Retention and "what changed this week" both need it.
|
|
39466
|
+
*
|
|
39467
|
+
* Absent is allowed and means "no age", which retention then cannot remove. Defaulting it to
|
|
39468
|
+
* *now* would be worse: every record would age from whenever it was last synced, so nothing
|
|
39469
|
+
* would ever look old and retention would silently never fire.
|
|
39470
|
+
*/
|
|
39471
|
+
timestamp: external_exports.number().optional(),
|
|
39472
|
+
/** Anything else the tool wants to keep. Filterable exactly, never embedded. */
|
|
39473
|
+
tags: external_exports.record(external_exports.string(), external_exports.string()).optional()
|
|
39474
|
+
});
|
|
39475
|
+
var datasetPayloadSchema = external_exports.union([
|
|
39476
|
+
external_exports.object({ records: external_exports.array(datasetRecordSchema) }),
|
|
39477
|
+
external_exports.array(datasetRecordSchema)
|
|
39478
|
+
]);
|
|
39479
|
+
function parseDatasetPayload(value) {
|
|
39480
|
+
const parsed = datasetPayloadSchema.safeParse(value);
|
|
39481
|
+
if (parsed.success) {
|
|
39482
|
+
return { records: Array.isArray(parsed.data) ? parsed.data : parsed.data.records };
|
|
39483
|
+
}
|
|
39484
|
+
return {
|
|
39485
|
+
error: 'The collector tool did not return records in the expected shape. Return a list of {"id": ..., "text": ...} objects, or {"records": [...]}. Each id must be stable across runs so a re-sync updates rather than duplicates. ' + parsed.error.issues.slice(0, 5).map((issue2) => `${issue2.path.join(".")}: ${issue2.message}`).join("; ")
|
|
39486
|
+
};
|
|
39487
|
+
}
|
|
39488
|
+
var datasetConfigSchema = external_exports.object({
|
|
39489
|
+
id: external_exports.string().min(1),
|
|
39490
|
+
name: external_exports.string().min(1, "Give it a name"),
|
|
39491
|
+
/** The Python tool that produces the records, by its bare name. */
|
|
39492
|
+
toolName: external_exports.string().min(1, "Choose a collector tool"),
|
|
39493
|
+
/** Passed to the tool as its arguments, so one tool can serve several datasets. */
|
|
39494
|
+
arguments: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
39495
|
+
enabled: external_exports.boolean().optional(),
|
|
39496
|
+
/** How often to re-run the collector. Zero or absent means only when asked. */
|
|
39497
|
+
syncMinutes: external_exports.number().int().min(0).optional(),
|
|
39498
|
+
/** Drop records older than this. Absent means keep everything. */
|
|
39499
|
+
retentionDays: external_exports.number().int().positive().optional(),
|
|
39500
|
+
/** Which vector store to write to. Falls back to the one named for `data`, then the active one. */
|
|
39501
|
+
storeId: external_exports.string().optional()
|
|
39502
|
+
});
|
|
39503
|
+
var COLLECTOR_TOOL_GUIDANCE = [
|
|
39504
|
+
"Writing a collector for a custom dataset:",
|
|
39505
|
+
"- A collector is an ordinary Python tool. Its `run` returns a list of records, each a dict",
|
|
39506
|
+
" with `id` and `text`, and optionally `title`, `url`, `timestamp` (epoch milliseconds) and",
|
|
39507
|
+
" `tags` (a flat dict of strings).",
|
|
39508
|
+
"- **`id` must be stable across runs.** Use the source's own identifier \u2014 a ticket key, a row",
|
|
39509
|
+
" id, a file path. A generated or time-based id makes every sync duplicate the whole corpus",
|
|
39510
|
+
" instead of updating it, which is not obvious until the results are full of near-copies.",
|
|
39511
|
+
"- **`text` is what gets embedded and what a search shows.** Put the meaning in it: a subject",
|
|
39512
|
+
" and a body, not an id and a status code. Roughly a paragraph to a page each works best.",
|
|
39513
|
+
'- Set `timestamp` wherever the source has one. Retention and any "what changed recently"',
|
|
39514
|
+
" question both need it, and it cannot be recovered later.",
|
|
39515
|
+
"- The tool is called with whatever arguments the dataset configures, plus `since` \u2014 epoch",
|
|
39516
|
+
" milliseconds of the last successful sync, or absent on the first. Use it to fetch only what",
|
|
39517
|
+
" changed if the source allows; returning everything each time is correct but slower.",
|
|
39518
|
+
"- Return `[]` when there is nothing new. That is a successful sync, not an error.",
|
|
39519
|
+
"- Keep credentials out of the tool: read them from the environment or from a file the user",
|
|
39520
|
+
" already has. A tool file lives in the workspace and lands in git."
|
|
39521
|
+
].join("\n");
|
|
39522
|
+
|
|
39450
39523
|
// ../../packages/core/dist/mcp/types.js
|
|
39451
39524
|
var stdioServerSchema = external_exports.object({
|
|
39452
39525
|
command: external_exports.string().min(1),
|
|
@@ -39718,6 +39791,20 @@ var authSchema = external_exports.discriminatedUnion("type", [
|
|
|
39718
39791
|
*/
|
|
39719
39792
|
external_exports.object({ type: external_exports.literal("apiKey"), apiKeyRef: external_exports.string().min(1) }),
|
|
39720
39793
|
external_exports.object({ type: external_exports.literal("tokenCommand"), tokenCommand: tokenCommandSchema }),
|
|
39794
|
+
/**
|
|
39795
|
+
* A fixed header the gateway expects, with no API key involved.
|
|
39796
|
+
*
|
|
39797
|
+
* Each value is a *reference* — a secret-store key, or `env:NAME` — never a literal, because
|
|
39798
|
+
* the profile lives in the config file and §15 is explicit that a credential never does.
|
|
39799
|
+
*/
|
|
39800
|
+
external_exports.object({
|
|
39801
|
+
type: external_exports.literal("header"),
|
|
39802
|
+
headers: external_exports.array(external_exports.object({
|
|
39803
|
+
name: external_exports.string().min(1, "Give the header name"),
|
|
39804
|
+
valueRef: external_exports.string().min(1, "Give the value, or env:NAME"),
|
|
39805
|
+
prefix: external_exports.string().optional()
|
|
39806
|
+
})).min(1, "Add at least one header")
|
|
39807
|
+
}),
|
|
39721
39808
|
external_exports.object({
|
|
39722
39809
|
type: external_exports.literal("apigeeMtls"),
|
|
39723
39810
|
certs: certConfigSchema,
|
|
@@ -39761,6 +39848,7 @@ var providerProfileSchema = external_exports.object({
|
|
|
39761
39848
|
});
|
|
39762
39849
|
|
|
39763
39850
|
// ../../packages/core/dist/config/schema.js
|
|
39851
|
+
var datasetsConfigSchema = external_exports.array(datasetConfigSchema);
|
|
39764
39852
|
var pythonConfigSchema = external_exports.object({
|
|
39765
39853
|
/**
|
|
39766
39854
|
* Off by default and explicitly three-state. This is the sharpest surface in the
|
|
@@ -40050,7 +40138,15 @@ var retrievalConfigSchema = external_exports.object({
|
|
|
40050
40138
|
/** Indexed mail. Usually local, and deliberately easy to keep separate. */
|
|
40051
40139
|
mail: external_exports.string().min(1),
|
|
40052
40140
|
/** The team's shared skills. Often the same cluster as the code. */
|
|
40053
|
-
skills: external_exports.string().min(1)
|
|
40141
|
+
skills: external_exports.string().min(1),
|
|
40142
|
+
/**
|
|
40143
|
+
* Corpora the user collects themselves.
|
|
40144
|
+
*
|
|
40145
|
+
* Routed separately for the same reason mail is: somebody's own collected data —
|
|
40146
|
+
* tickets, extracts from an internal system — is frequently the thing they most want
|
|
40147
|
+
* kept off a cluster their team shares.
|
|
40148
|
+
*/
|
|
40149
|
+
data: external_exports.string().min(1)
|
|
40054
40150
|
}).partial()
|
|
40055
40151
|
}).partial();
|
|
40056
40152
|
function storeIdFor(purpose, config2) {
|
|
@@ -40238,6 +40334,7 @@ var configSchema = external_exports.object({
|
|
|
40238
40334
|
programmingProfileId: external_exports.string(),
|
|
40239
40335
|
certDir: external_exports.string(),
|
|
40240
40336
|
python: pythonConfigSchema,
|
|
40337
|
+
datasets: datasetsConfigSchema,
|
|
40241
40338
|
/**
|
|
40242
40339
|
* Keyed by workspace path. Per-workspace in *behaviour* (§8) but stored user-side and
|
|
40243
40340
|
* user-scope-only (invariant 5) — a repo must not be able to ship its own
|
|
@@ -40709,6 +40806,19 @@ var GUIDE_STEPS = [
|
|
|
40709
40806
|
"You get a writable folder plus any number of read-only ones, such as a shared team folder, with PATH-style precedence and shadowing reported rather than silently applied. Writing a skill needs approval too: it is prose that steers every future turn."
|
|
40710
40807
|
]
|
|
40711
40808
|
},
|
|
40809
|
+
{
|
|
40810
|
+
id: "customData",
|
|
40811
|
+
title: "Custom data - bring your own corpus",
|
|
40812
|
+
tab: "customData",
|
|
40813
|
+
completionEvents: ["onStepSelected"],
|
|
40814
|
+
altText: "The Custom data tab, showing a dataset with its collector tool, record count, schedule and last sync, alongside buttons for syncing, rebuilding and clearing it.",
|
|
40815
|
+
body: [
|
|
40816
|
+
"The data you most want the assistant to know is rarely on disk. It is in a ticketing system, a wiki, a database, an internal API - reachable, but only through something that knows how your organisation authenticates.",
|
|
40817
|
+
"So you point at a tool that returns records, and Light Code does the rest: embedding them, keeping them current, and searching them with `search_data`. The collector is an ordinary Python tool or an MCP tool you already have - one function signature rather than a connector per system.",
|
|
40818
|
+
"You do not have to write it. Tell the assistant where the data lives and ask for a collector; it already has the contract and will offer one for you to approve.",
|
|
40819
|
+
"Each dataset has its own schedule - including **only when I ask**, which is the right answer for a source that is expensive or that only changes when somebody does something. Clear, rebuild and a retention window are all here, and a progress bar with a Stop for the first sync of something large."
|
|
40820
|
+
]
|
|
40821
|
+
},
|
|
40712
40822
|
{
|
|
40713
40823
|
id: "search",
|
|
40714
40824
|
title: "Search - find things by meaning",
|
|
@@ -40811,6 +40921,9 @@ var USER_SCOPE_ONLY_KEYS = [
|
|
|
40811
40921
|
// Added for Phase 8b, and the sharpest entries on this list. A workspace able to name a
|
|
40812
40922
|
// cluster, or repoint the embedder at a profile of its choosing, would exfiltrate
|
|
40813
40923
|
// whatever gets indexed — and what gets indexed is the source code.
|
|
40924
|
+
// A dataset names a program to run *and* a store to write what it produced into — the `python`
|
|
40925
|
+
// threat and the `embedder` threat in one key, on a timer.
|
|
40926
|
+
"datasets",
|
|
40814
40927
|
"vectorStores",
|
|
40815
40928
|
"activeVectorStoreId",
|
|
40816
40929
|
"embedder",
|
|
@@ -41366,6 +41479,27 @@ var NoAuthStrategy = class {
|
|
|
41366
41479
|
}
|
|
41367
41480
|
};
|
|
41368
41481
|
|
|
41482
|
+
// ../../packages/core/dist/providers/auth/header.js
|
|
41483
|
+
var HeaderAuthStrategy = class {
|
|
41484
|
+
secrets;
|
|
41485
|
+
credentials;
|
|
41486
|
+
constructor(secrets, credentials) {
|
|
41487
|
+
this.secrets = secrets;
|
|
41488
|
+
this.credentials = credentials;
|
|
41489
|
+
}
|
|
41490
|
+
async resolveHeaders() {
|
|
41491
|
+
const headers = {};
|
|
41492
|
+
for (const credential of this.credentials) {
|
|
41493
|
+
const value = await resolveSecretRef(credential.valueRef, { secrets: this.secrets });
|
|
41494
|
+
if (value === void 0) {
|
|
41495
|
+
throw new Error(`${describeMissingSecret(credential.valueRef, `the value for header "${credential.name}"`)}`);
|
|
41496
|
+
}
|
|
41497
|
+
headers[credential.name] = `${credential.prefix ?? ""}${value}`;
|
|
41498
|
+
}
|
|
41499
|
+
return headers;
|
|
41500
|
+
}
|
|
41501
|
+
};
|
|
41502
|
+
|
|
41369
41503
|
// ../../packages/core/dist/providers/auth/tokenCommand.js
|
|
41370
41504
|
import { spawn } from "node:child_process";
|
|
41371
41505
|
function readPath(source, dotted) {
|
|
@@ -41911,6 +42045,8 @@ function createBaseAuthStrategy(auth2, context) {
|
|
|
41911
42045
|
headerPrefix: auth2.tokenCommand.headerPrefix ?? context.apiKeyHeaderPrefix ?? derived.prefix
|
|
41912
42046
|
});
|
|
41913
42047
|
}
|
|
42048
|
+
case "header":
|
|
42049
|
+
return new HeaderAuthStrategy(context.secrets, auth2.headers);
|
|
41914
42050
|
case "none":
|
|
41915
42051
|
return new NoAuthStrategy();
|
|
41916
42052
|
case "apigeeMtls": {
|
|
@@ -42889,8 +43025,8 @@ var SUPERSEDED_MARKER = "[Superseded: this file was read again later in the conv
|
|
|
42889
43025
|
function readFilePath(argumentsJson) {
|
|
42890
43026
|
try {
|
|
42891
43027
|
const parsed = JSON.parse(argumentsJson.length > 0 ? argumentsJson : "{}");
|
|
42892
|
-
const
|
|
42893
|
-
return typeof
|
|
43028
|
+
const path34 = parsed.path;
|
|
43029
|
+
return typeof path34 === "string" && path34.length > 0 ? path34 : void 0;
|
|
42894
43030
|
} catch {
|
|
42895
43031
|
return void 0;
|
|
42896
43032
|
}
|
|
@@ -42903,8 +43039,8 @@ function dropSupersededReads(messages) {
|
|
|
42903
43039
|
for (const toolCall of message3.toolCalls ?? []) {
|
|
42904
43040
|
if (toolCall.name !== "read_file")
|
|
42905
43041
|
continue;
|
|
42906
|
-
const
|
|
42907
|
-
if (
|
|
43042
|
+
const path34 = readFilePath(toolCall.arguments);
|
|
43043
|
+
if (path34 === void 0)
|
|
42908
43044
|
continue;
|
|
42909
43045
|
keyByCallId.set(toolCall.id, toolCall.arguments);
|
|
42910
43046
|
}
|
|
@@ -43339,6 +43475,15 @@ function buildSystemPrompt(workspaceRoot, options = {}) {
|
|
|
43339
43475
|
lines.push("", "Recording what you learn:", "- When the user explains something durable about their environment \u2014 an internal", " library and how to use it, a house convention, the shape of an in-house API, a", " gotcha specific to this codebase \u2014 offer to record it with write_skill. Ask first;", " do not write one unprompted.", '- "Durable" means it would be true again next week and useful to a future', " conversation. A one-off instruction for the current task is not a skill.", options.skillsSearchable === true ? "- Before writing a new skill, search for one with search_docs: if a note already covers the subject, read it and update that instead of creating a near-duplicate." : "- Before writing a new skill, check the list above: if one already covers the subject, read it and update that instead of creating a near-duplicate.", "- When you learn something *corrects* an existing skill, say so and offer to update", " it. A stale skill is worse than a missing one, because it is trusted.", "- Write for a reader who has none of this conversation: name the package, the import", ' path, the function, and show a short example. Avoid "as discussed" and "the usual".', options.skillsSearchable === true ? "- The description line is what search matches on, so make it say what subject the skill covers in the words someone would search for \u2014 it is a trigger, not a summary." : "- The description line is the only part always in context, so make it say what subject the skill covers \u2014 it is a trigger for reading, not a summary.");
|
|
43340
43476
|
}
|
|
43341
43477
|
lines.push("", "Charts:", "- **Draw one whenever numbers are easier seen than read** \u2014 a count per folder or per day, a", " value trending over time, a breakdown of a total. Use show_chart; do not print a table of", " figures where a chart would answer the question faster.", "- **Always fill in `detail`** when the numbers count things that can be named \u2014 the subjects,", ' the files, the ids. A bar reading 14 is only useful if "which fourteen?" has an answer, and', " the detail is what lets the user open the bar instead of asking you to search again.", "- Say in `note` where the numbers came from and what they exclude. A chart is believed", " without being checked, so its limits have to travel with it.", "- Series must have exactly one value per category. A mismatch is refused rather than padded,", " because a chart drawn from misaligned data looks correct and is not.", "- After drawing, describe what it shows. Do not recite the numbers again \u2014 they are on screen.", "- **A Python tool can produce the data.** Have it return JSON shaped", ' `{"categories": [...], "series": [{"name": ..., "values": [...], "detail": [[...], ...]}]}`', " and pass that straight to show_chart. That is the intended way to chart anything you have", " analysed in Python \u2014 the tool does the arithmetic, show_chart draws it, and the numbers are", " never retyped by you in between.");
|
|
43478
|
+
if (options.datasets !== void 0 && options.datasets.length > 0) {
|
|
43479
|
+
lines.push("", "Custom datasets:", `- The user collects these themselves: ${options.datasets.map((dataset) => `${dataset.name} (${String(dataset.records)} records)`).join(", ")}.`, "- **Use search_data for anything about data the organisation collects itself** \u2014 tickets,", " wiki pages, rows from an internal system. It is the only way to reach these; they are not", " in the codebase and not in the mail index.", "- It searches what has been **synced**, not the live source. If the answer turns on", " something very recent, say when the dataset was last synced rather than implying it is", " current. Do not offer to refresh it yourself \u2014 syncing is triggered by the user.", ...options.canWriteCollectors === true ? [
|
|
43480
|
+
"- If they want a dataset you cannot find, you can write the collector: it is an",
|
|
43481
|
+
" ordinary Python tool returning records. Offer, do not assume \u2014 then they configure",
|
|
43482
|
+
" it in Settings, Custom data. The contract is below.",
|
|
43483
|
+
"",
|
|
43484
|
+
COLLECTOR_TOOL_GUIDANCE
|
|
43485
|
+
] : []);
|
|
43486
|
+
}
|
|
43342
43487
|
if (options.mailIndexed === true) {
|
|
43343
43488
|
lines.push("", "Email:", "- **Always answer questions about email from the index, using search_mail and", " mail_patterns.** That is what it is for. It is fast, it answers questions about time", " and recurrence that a live search cannot, and it does not disturb the running Outlook.", '- **Only search Outlook itself when the user asks you to.** "Check Outlook", "look at my', ' actual mailbox", "is it there now" and anything similar are the instruction to use', " outlook_search. Do not reach for it on your own initiative.", "- If the index has nothing, say so plainly and say when it was last synced. Do not", " quietly fall back to scanning Outlook - a slow live scan that nobody asked for reads", " as the assistant having hung.", "- One exception worth naming: if the user is asking about something that arrived in the", " last few minutes, the index may not have it yet. Say that, and offer to check Outlook", " rather than doing it unasked.", "- **The index holds plain text.** Colours, highlighting and images are not in it. When", " those could carry meaning \u2014 a red line marking a failure, a highlighted cell \u2014 use", " outlook_read_email on the id, which reads the live message and reports the colours.", " Never conclude a message looks fine from indexed text alone.", "- mail_coverage says which folders are indexed and how far back. Check it before saying", " something is not in the mail: an empty search over an unindexed folder looks exactly", " like an empty search over an indexed one.", "- **Use mail_stats for any question with a number in the answer** \u2014 how many alerts per", " folder, per day, per hour, which senders, whether a figure inside the alerts is climbing.", " It counts everything the filters matched. Never count search results by eye: search", " returns a page, so counting what you were shown reports a sample as if it were the total.", "- mail_stats already returns categories, values and detail in the shape show_chart wants.", " Pass it through rather than retyping the numbers, and keep the detail.");
|
|
43344
43489
|
}
|
|
@@ -43978,13 +44123,13 @@ var OpenSearchClient = class {
|
|
|
43978
44123
|
* `_bulk`, `_delete_by_query`, index creation — is refused here rather than merely
|
|
43979
44124
|
* unused, so no future edit or crafted argument can turn a read client into a writer.
|
|
43980
44125
|
*/
|
|
43981
|
-
async request(
|
|
44126
|
+
async request(path34, options = {}) {
|
|
43982
44127
|
const method = options.method ?? "GET";
|
|
43983
|
-
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(
|
|
44128
|
+
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(path34);
|
|
43984
44129
|
if (method !== "GET" && !isSearchPost) {
|
|
43985
|
-
throw new OpenSearchError(`Refusing ${method} ${
|
|
44130
|
+
throw new OpenSearchError(`Refusing ${method} ${path34}: this client is read-only. Indexing goes through the indexer, which the user starts from Settings.`);
|
|
43986
44131
|
}
|
|
43987
|
-
const url2 = `${this.base}${
|
|
44132
|
+
const url2 = `${this.base}${path34}`;
|
|
43988
44133
|
const request = {
|
|
43989
44134
|
method,
|
|
43990
44135
|
headers: this.headers()
|
|
@@ -44147,11 +44292,11 @@ function collectFields(properties, prefix, out) {
|
|
|
44147
44292
|
return;
|
|
44148
44293
|
for (const [name, raw] of Object.entries(properties)) {
|
|
44149
44294
|
const field = raw;
|
|
44150
|
-
const
|
|
44295
|
+
const path34 = prefix.length > 0 ? `${prefix}.${name}` : name;
|
|
44151
44296
|
if (typeof field.type === "string")
|
|
44152
|
-
out[
|
|
44297
|
+
out[path34] = field.type;
|
|
44153
44298
|
if (field.properties !== void 0)
|
|
44154
|
-
collectFields(field.properties,
|
|
44299
|
+
collectFields(field.properties, path34, out);
|
|
44155
44300
|
}
|
|
44156
44301
|
}
|
|
44157
44302
|
function describeStatus(status, url2, body) {
|
|
@@ -44170,23 +44315,23 @@ function describeStatus(status, url2, body) {
|
|
|
44170
44315
|
var TEXT_TYPES = /* @__PURE__ */ new Set(["text", "match_only_text", "search_as_you_type", "wildcard"]);
|
|
44171
44316
|
var KEYWORD_TYPES = /* @__PURE__ */ new Set(["keyword", "constant_keyword"]);
|
|
44172
44317
|
var NOISE_FIELDS = /* @__PURE__ */ new Set(["@version", "ecs", "tags", "stream", "input", "agent", "host", "event"]);
|
|
44173
|
-
function leafName(
|
|
44174
|
-
const parts =
|
|
44175
|
-
return parts[parts.length - 1] ??
|
|
44318
|
+
function leafName(path34) {
|
|
44319
|
+
const parts = path34.split(".");
|
|
44320
|
+
return parts[parts.length - 1] ?? path34;
|
|
44176
44321
|
}
|
|
44177
44322
|
function selectQueryFields(mapping, limit = 25) {
|
|
44178
44323
|
const text = [];
|
|
44179
44324
|
const keyword = [];
|
|
44180
|
-
for (const [
|
|
44181
|
-
if (NOISE_FIELDS.has(leafName(
|
|
44325
|
+
for (const [path34, type] of Object.entries(mapping)) {
|
|
44326
|
+
if (NOISE_FIELDS.has(leafName(path34)) || NOISE_FIELDS.has(path34.split(".")[0] ?? ""))
|
|
44182
44327
|
continue;
|
|
44183
44328
|
if (TEXT_TYPES.has(type)) {
|
|
44184
|
-
text.push(
|
|
44329
|
+
text.push(path34);
|
|
44185
44330
|
} else if (KEYWORD_TYPES.has(type)) {
|
|
44186
|
-
const parent =
|
|
44187
|
-
if (
|
|
44331
|
+
const parent = path34.replace(/\.keyword$/, "");
|
|
44332
|
+
if (path34.endsWith(".keyword") && TEXT_TYPES.has(mapping[parent] ?? ""))
|
|
44188
44333
|
continue;
|
|
44189
|
-
keyword.push(
|
|
44334
|
+
keyword.push(path34);
|
|
44190
44335
|
}
|
|
44191
44336
|
}
|
|
44192
44337
|
const byDepth = (a, b) => a.split(".").length - b.split(".").length || a.localeCompare(b);
|
|
@@ -44328,8 +44473,8 @@ var OpenSearchIndexWriter = class {
|
|
|
44328
44473
|
}
|
|
44329
44474
|
return headers;
|
|
44330
44475
|
}
|
|
44331
|
-
async request(
|
|
44332
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
44476
|
+
async request(path34, method, body, signal) {
|
|
44477
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path34}`;
|
|
44333
44478
|
const request = { method, headers: this.headers() };
|
|
44334
44479
|
if (body !== void 0) {
|
|
44335
44480
|
if (typeof body === "string") {
|
|
@@ -44543,13 +44688,13 @@ var OpenSearchIndexWriter = class {
|
|
|
44543
44688
|
for (const hit of hits) {
|
|
44544
44689
|
const source = hit._source ?? {};
|
|
44545
44690
|
const vector = source.vector;
|
|
44546
|
-
const
|
|
44547
|
-
if (typeof
|
|
44691
|
+
const path34 = source.path;
|
|
44692
|
+
if (typeof path34 !== "string" || !Array.isArray(vector))
|
|
44548
44693
|
continue;
|
|
44549
44694
|
documents.push({
|
|
44550
44695
|
id: hit._id ?? "",
|
|
44551
44696
|
text: typeof source.text === "string" ? source.text : "",
|
|
44552
|
-
path:
|
|
44697
|
+
path: path34,
|
|
44553
44698
|
startLine: typeof source.startLine === "number" ? source.startLine : 1,
|
|
44554
44699
|
endLine: typeof source.endLine === "number" ? source.endLine : 1,
|
|
44555
44700
|
vector
|
|
@@ -44623,8 +44768,8 @@ var RestTransport = class {
|
|
|
44623
44768
|
* threw would push every caller into catching and re-inspecting an error to find out
|
|
44624
44769
|
* whether it was really an error. `expectOk` is there for the cases that are.
|
|
44625
44770
|
*/
|
|
44626
|
-
async send(
|
|
44627
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
44771
|
+
async send(path34, method, body, signal) {
|
|
44772
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path34}`;
|
|
44628
44773
|
const request = { method, headers: this.headers() };
|
|
44629
44774
|
if (body !== void 0)
|
|
44630
44775
|
request.body = JSON.stringify(body);
|
|
@@ -44650,11 +44795,11 @@ var RestTransport = class {
|
|
|
44650
44795
|
return { status: response.status, body: parsed };
|
|
44651
44796
|
}
|
|
44652
44797
|
/** Sends, and throws unless the status is 2xx. */
|
|
44653
|
-
async expectOk(
|
|
44654
|
-
const result = await this.send(
|
|
44798
|
+
async expectOk(path34, method, body, signal) {
|
|
44799
|
+
const result = await this.send(path34, method, body, signal);
|
|
44655
44800
|
if (result.status < 200 || result.status >= 300) {
|
|
44656
44801
|
const detail = typeof result.body === "string" ? result.body : JSON.stringify(result.body ?? "");
|
|
44657
|
-
throw new VectorStoreError(`${method} ${
|
|
44802
|
+
throw new VectorStoreError(`${method} ${path34} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}`, result.status);
|
|
44658
44803
|
}
|
|
44659
44804
|
return result.body;
|
|
44660
44805
|
}
|
|
@@ -44755,10 +44900,10 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
44755
44900
|
const matches = [];
|
|
44756
44901
|
for (let index = 0; index < ids.length; index++) {
|
|
44757
44902
|
const metadata = metadatas[index] ?? {};
|
|
44758
|
-
const
|
|
44759
|
-
if (
|
|
44903
|
+
const path34 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
44904
|
+
if (path34 === void 0)
|
|
44760
44905
|
continue;
|
|
44761
|
-
if (filtering && !
|
|
44906
|
+
if (filtering && !path34.startsWith(prefix))
|
|
44762
44907
|
continue;
|
|
44763
44908
|
const distance = distances[index];
|
|
44764
44909
|
const match = {
|
|
@@ -44770,7 +44915,7 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
44770
44915
|
*/
|
|
44771
44916
|
score: typeof distance === "number" ? 1 / (1 + Math.max(0, distance)) : 0,
|
|
44772
44917
|
text: documents[index] ?? (typeof metadata.text === "string" ? metadata.text : ""),
|
|
44773
|
-
path:
|
|
44918
|
+
path: path34
|
|
44774
44919
|
};
|
|
44775
44920
|
if (typeof metadata.startLine === "number")
|
|
44776
44921
|
match.startLine = metadata.startLine;
|
|
@@ -44881,13 +45026,13 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
44881
45026
|
for (let index = 0; index < ids.length; index++) {
|
|
44882
45027
|
const metadata = result.metadatas?.[index] ?? {};
|
|
44883
45028
|
const vector = result.embeddings?.[index];
|
|
44884
|
-
const
|
|
44885
|
-
if (
|
|
45029
|
+
const path34 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
45030
|
+
if (path34 === void 0 || !Array.isArray(vector))
|
|
44886
45031
|
continue;
|
|
44887
45032
|
documents.push({
|
|
44888
45033
|
id: ids[index] ?? "",
|
|
44889
45034
|
text: result.documents?.[index] ?? "",
|
|
44890
|
-
path:
|
|
45035
|
+
path: path34,
|
|
44891
45036
|
startLine: typeof metadata.startLine === "number" ? metadata.startLine : 1,
|
|
44892
45037
|
endLine: typeof metadata.endLine === "number" ? metadata.endLine : 1,
|
|
44893
45038
|
vector
|
|
@@ -44904,9 +45049,9 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
44904
45049
|
const result = await this.rest.expectOk(`${this.base}/collections/${found.id}/get`, "POST", { include: ["metadatas"], limit }, options.signal);
|
|
44905
45050
|
const paths = /* @__PURE__ */ new Set();
|
|
44906
45051
|
for (const metadata of result.metadatas ?? []) {
|
|
44907
|
-
const
|
|
44908
|
-
if (typeof
|
|
44909
|
-
paths.add(
|
|
45052
|
+
const path34 = metadata?.path;
|
|
45053
|
+
if (typeof path34 === "string")
|
|
45054
|
+
paths.add(path34);
|
|
44910
45055
|
}
|
|
44911
45056
|
return [...paths];
|
|
44912
45057
|
}
|
|
@@ -44933,14 +45078,14 @@ var MARKER_ID = "5f6d2a41-0000-5000-8000-6c69676874c0";
|
|
|
44933
45078
|
var MARKER_MARK = "light-code";
|
|
44934
45079
|
function toMatch(point) {
|
|
44935
45080
|
const payload = point.payload ?? {};
|
|
44936
|
-
const
|
|
44937
|
-
if (
|
|
45081
|
+
const path34 = typeof payload.path === "string" ? payload.path : void 0;
|
|
45082
|
+
if (path34 === void 0)
|
|
44938
45083
|
return void 0;
|
|
44939
45084
|
const match = {
|
|
44940
45085
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
44941
45086
|
score: typeof point.score === "number" ? point.score : 0,
|
|
44942
45087
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
44943
|
-
path:
|
|
45088
|
+
path: path34
|
|
44944
45089
|
};
|
|
44945
45090
|
if (typeof payload.startLine === "number")
|
|
44946
45091
|
match.startLine = payload.startLine;
|
|
@@ -45118,13 +45263,13 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
45118
45263
|
const documents = [];
|
|
45119
45264
|
for (const point of result.body.result?.points ?? []) {
|
|
45120
45265
|
const payload = point.payload ?? {};
|
|
45121
|
-
const
|
|
45122
|
-
if (
|
|
45266
|
+
const path34 = typeof payload.path === "string" ? payload.path : void 0;
|
|
45267
|
+
if (path34 === void 0 || !Array.isArray(point.vector))
|
|
45123
45268
|
continue;
|
|
45124
45269
|
documents.push({
|
|
45125
45270
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
45126
45271
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
45127
|
-
path:
|
|
45272
|
+
path: path34,
|
|
45128
45273
|
startLine: typeof payload.startLine === "number" ? payload.startLine : 1,
|
|
45129
45274
|
endLine: typeof payload.endLine === "number" ? payload.endLine : 1,
|
|
45130
45275
|
vector: point.vector
|
|
@@ -45151,9 +45296,9 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
45151
45296
|
throw new VectorStoreError(`Could not list "${collection}" (HTTP ${String(result.status)}).`, result.status);
|
|
45152
45297
|
}
|
|
45153
45298
|
for (const point of result.body.result?.points ?? []) {
|
|
45154
|
-
const
|
|
45155
|
-
if (typeof
|
|
45156
|
-
paths.add(
|
|
45299
|
+
const path34 = point.payload?.path;
|
|
45300
|
+
if (typeof path34 === "string")
|
|
45301
|
+
paths.add(path34);
|
|
45157
45302
|
}
|
|
45158
45303
|
offset = result.body.result?.next_page_offset;
|
|
45159
45304
|
if (offset === void 0 || offset === null)
|
|
@@ -45567,8 +45712,8 @@ function teamSkillDocument(skill, body, vector, attribution) {
|
|
|
45567
45712
|
vector
|
|
45568
45713
|
};
|
|
45569
45714
|
}
|
|
45570
|
-
function nameFromPath(
|
|
45571
|
-
return
|
|
45715
|
+
function nameFromPath(path34) {
|
|
45716
|
+
return path34.startsWith("skill:") ? path34.slice("skill:".length) : path34;
|
|
45572
45717
|
}
|
|
45573
45718
|
function toHit(match, self) {
|
|
45574
45719
|
return {
|
|
@@ -46954,8 +47099,8 @@ function createMailCoverageTool(options) {
|
|
|
46954
47099
|
}
|
|
46955
47100
|
};
|
|
46956
47101
|
}
|
|
46957
|
-
function normaliseFolder(
|
|
46958
|
-
return
|
|
47102
|
+
function normaliseFolder(path34) {
|
|
47103
|
+
return path34.toLowerCase().replace(/[\\/]+/g, "\\");
|
|
46959
47104
|
}
|
|
46960
47105
|
function haystackOf(record2) {
|
|
46961
47106
|
return `${record2.subject}
|
|
@@ -47413,7 +47558,7 @@ async function refreshMail(options) {
|
|
|
47413
47558
|
const limit = options.batchLimit ?? 2e3;
|
|
47414
47559
|
const previewChars = options.previewChars ?? 400;
|
|
47415
47560
|
const sinceMs = Date.now() - options.days * 24 * 60 * 60 * 1e3;
|
|
47416
|
-
const harvested = await options.harvest(options.folders.map((
|
|
47561
|
+
const harvested = await options.harvest(options.folders.map((path34) => ({ path: path34, sinceMs })), { limit, previewChars });
|
|
47417
47562
|
const fetched = harvested.messages.map(toRecord);
|
|
47418
47563
|
if (fetched.length === 0) {
|
|
47419
47564
|
return { added: 0, more: false, total: known.length, embedded: 0, backfilled: 0, complete: [] };
|
|
@@ -47454,9 +47599,9 @@ async function syncMail(options) {
|
|
|
47454
47599
|
const backfillDone = await options.store.loadBackfillState();
|
|
47455
47600
|
const limit = options.batchLimit ?? 500;
|
|
47456
47601
|
const previewChars = options.previewChars ?? 400;
|
|
47457
|
-
const forwardRequests = options.folders.map((
|
|
47458
|
-
const mark = marks.get(
|
|
47459
|
-
return mark === void 0 ? { path:
|
|
47602
|
+
const forwardRequests = options.folders.map((path34) => {
|
|
47603
|
+
const mark = marks.get(path34);
|
|
47604
|
+
return mark === void 0 ? { path: path34 } : { path: path34, sinceMs: mark.newest - 1e3 };
|
|
47460
47605
|
});
|
|
47461
47606
|
const forward = await options.harvest(forwardRequests, { limit, previewChars });
|
|
47462
47607
|
let candidates = forward.messages.map(toRecord);
|
|
@@ -47465,15 +47610,15 @@ async function syncMail(options) {
|
|
|
47465
47610
|
let more = forward.truncated;
|
|
47466
47611
|
const remaining = limit - candidates.length;
|
|
47467
47612
|
const floor = options.retentionMonths === void 0 ? void 0 : monthsBefore(options.now ?? Date.now(), options.retentionMonths);
|
|
47468
|
-
const outstanding = options.folders.filter((
|
|
47469
|
-
const atFloor = floor === void 0 ? [] : outstanding.filter((
|
|
47470
|
-
const behind = outstanding.filter((
|
|
47613
|
+
const outstanding = options.folders.filter((path34) => marks.has(path34) && backfillDone[path34] !== true);
|
|
47614
|
+
const atFloor = floor === void 0 ? [] : outstanding.filter((path34) => marks.get(path34).oldest <= floor);
|
|
47615
|
+
const behind = outstanding.filter((path34) => !atFloor.includes(path34));
|
|
47471
47616
|
completed.push(...atFloor);
|
|
47472
47617
|
if (remaining > 0 && behind.length > 0 && options.signal?.aborted !== true) {
|
|
47473
|
-
const backRequests = behind.map((
|
|
47474
|
-
path:
|
|
47618
|
+
const backRequests = behind.map((path34) => ({
|
|
47619
|
+
path: path34,
|
|
47475
47620
|
// Strictly older, so the oldest held message is not fetched again every pass.
|
|
47476
|
-
beforeMs: marks.get(
|
|
47621
|
+
beforeMs: marks.get(path34).oldest,
|
|
47477
47622
|
// And no older than retention wants. The harvest ANDs the two into one window.
|
|
47478
47623
|
...floor === void 0 ? {} : { sinceMs: floor }
|
|
47479
47624
|
}));
|
|
@@ -47481,9 +47626,9 @@ async function syncMail(options) {
|
|
|
47481
47626
|
backfilled = backward.messages.length;
|
|
47482
47627
|
candidates = [...candidates, ...backward.messages.map(toRecord)];
|
|
47483
47628
|
const returnedFor = new Set(backward.messages.map((message3) => message3.folder));
|
|
47484
|
-
for (const
|
|
47485
|
-
if (!returnedFor.has(
|
|
47486
|
-
completed.push(
|
|
47629
|
+
for (const path34 of behind) {
|
|
47630
|
+
if (!returnedFor.has(path34))
|
|
47631
|
+
completed.push(path34);
|
|
47487
47632
|
}
|
|
47488
47633
|
if (backward.truncated || backfilled > 0)
|
|
47489
47634
|
more = true;
|
|
@@ -47491,7 +47636,7 @@ async function syncMail(options) {
|
|
|
47491
47636
|
if (completed.length > 0) {
|
|
47492
47637
|
await options.store.saveBackfillState({
|
|
47493
47638
|
...backfillDone,
|
|
47494
|
-
...Object.fromEntries(completed.map((
|
|
47639
|
+
...Object.fromEntries(completed.map((path34) => [path34, true]))
|
|
47495
47640
|
});
|
|
47496
47641
|
}
|
|
47497
47642
|
const fresh = withoutKnown(candidates, known);
|
|
@@ -48409,14 +48554,14 @@ function formatBytes(size) {
|
|
|
48409
48554
|
return `${(size / (1 << 10)).toFixed(1)}KB`;
|
|
48410
48555
|
return `${String(size)}B`;
|
|
48411
48556
|
}
|
|
48412
|
-
async function readTail(
|
|
48557
|
+
async function readTail(fs27, path34, size, count) {
|
|
48413
48558
|
let span = Math.min(size, CHUNK);
|
|
48414
48559
|
let text;
|
|
48415
48560
|
let start;
|
|
48416
48561
|
for (; ; ) {
|
|
48417
48562
|
start = Math.max(0, size - span);
|
|
48418
48563
|
const decoder = new StringDecoder("utf8");
|
|
48419
|
-
text = decoder.write(await
|
|
48564
|
+
text = decoder.write(await fs27.readBytesSlice(path34, start, size)) + decoder.end();
|
|
48420
48565
|
const enough = text.split("\n").length > count;
|
|
48421
48566
|
if (enough || start === 0 || span >= size)
|
|
48422
48567
|
break;
|
|
@@ -48434,7 +48579,7 @@ async function readTail(fs26, path33, size, count) {
|
|
|
48434
48579
|
hasMoreAfter: false
|
|
48435
48580
|
};
|
|
48436
48581
|
}
|
|
48437
|
-
async function readLineWindow(
|
|
48582
|
+
async function readLineWindow(fs27, path34, size, from, count) {
|
|
48438
48583
|
const decoder = new StringDecoder("utf8");
|
|
48439
48584
|
const lines = [];
|
|
48440
48585
|
let pending = "";
|
|
@@ -48449,7 +48594,7 @@ async function readLineWindow(fs26, path33, size, from, count) {
|
|
|
48449
48594
|
};
|
|
48450
48595
|
scan: while (position < size) {
|
|
48451
48596
|
const end = Math.min(size, position + CHUNK);
|
|
48452
|
-
pending += decoder.write(await
|
|
48597
|
+
pending += decoder.write(await fs27.readBytesSlice(path34, position, end));
|
|
48453
48598
|
position = end;
|
|
48454
48599
|
const parts = pending.split(/\r\n|\r|\n/);
|
|
48455
48600
|
pending = parts.pop() ?? "";
|
|
@@ -48472,13 +48617,13 @@ async function readLineWindow(fs26, path33, size, from, count) {
|
|
|
48472
48617
|
hasMoreAfter: !reachedEnd || lineNumber > from + lines.length
|
|
48473
48618
|
};
|
|
48474
48619
|
}
|
|
48475
|
-
async function countLines(
|
|
48620
|
+
async function countLines(fs27, path34, size) {
|
|
48476
48621
|
let newlines = 0;
|
|
48477
48622
|
let position = 0;
|
|
48478
48623
|
let lastByte = -1;
|
|
48479
48624
|
while (position < size) {
|
|
48480
48625
|
const end = Math.min(size, position + CHUNK);
|
|
48481
|
-
const buffer = await
|
|
48626
|
+
const buffer = await fs27.readBytesSlice(path34, position, end);
|
|
48482
48627
|
for (const byte of buffer)
|
|
48483
48628
|
if (byte === 10)
|
|
48484
48629
|
newlines += 1;
|
|
@@ -58986,17 +59131,17 @@ var WebviewApprovalGate = class {
|
|
|
58986
59131
|
// ../../packages/core/dist/platform/node/filesystem.js
|
|
58987
59132
|
import fs16 from "node:fs/promises";
|
|
58988
59133
|
var NodeFileSystem = class {
|
|
58989
|
-
async readFile(
|
|
58990
|
-
return fs16.readFile(
|
|
59134
|
+
async readFile(path34) {
|
|
59135
|
+
return fs16.readFile(path34, "utf8");
|
|
58991
59136
|
}
|
|
58992
|
-
async readBytes(
|
|
58993
|
-
return fs16.readFile(
|
|
59137
|
+
async readBytes(path34) {
|
|
59138
|
+
return fs16.readFile(path34);
|
|
58994
59139
|
}
|
|
58995
|
-
async readBytesSlice(
|
|
59140
|
+
async readBytesSlice(path34, start, end) {
|
|
58996
59141
|
const length = Math.max(0, end - start);
|
|
58997
59142
|
if (length === 0)
|
|
58998
59143
|
return Buffer.alloc(0);
|
|
58999
|
-
const handle = await fs16.open(
|
|
59144
|
+
const handle = await fs16.open(path34, "r");
|
|
59000
59145
|
try {
|
|
59001
59146
|
const buffer = Buffer.alloc(length);
|
|
59002
59147
|
const { bytesRead } = await handle.read(buffer, 0, length, start);
|
|
@@ -59005,11 +59150,11 @@ var NodeFileSystem = class {
|
|
|
59005
59150
|
await handle.close();
|
|
59006
59151
|
}
|
|
59007
59152
|
}
|
|
59008
|
-
async writeFile(
|
|
59009
|
-
await fs16.writeFile(
|
|
59153
|
+
async writeFile(path34, contents) {
|
|
59154
|
+
await fs16.writeFile(path34, contents, "utf8");
|
|
59010
59155
|
}
|
|
59011
|
-
async stat(
|
|
59012
|
-
const stat = await fs16.lstat(
|
|
59156
|
+
async stat(path34) {
|
|
59157
|
+
const stat = await fs16.lstat(path34);
|
|
59013
59158
|
return {
|
|
59014
59159
|
size: stat.size,
|
|
59015
59160
|
mtimeMs: stat.mtimeMs,
|
|
@@ -59018,8 +59163,8 @@ var NodeFileSystem = class {
|
|
|
59018
59163
|
isSymbolicLink: stat.isSymbolicLink()
|
|
59019
59164
|
};
|
|
59020
59165
|
}
|
|
59021
|
-
async readdir(
|
|
59022
|
-
const entries = await fs16.readdir(
|
|
59166
|
+
async readdir(path34) {
|
|
59167
|
+
const entries = await fs16.readdir(path34, { withFileTypes: true });
|
|
59023
59168
|
return entries.map((entry) => ({
|
|
59024
59169
|
name: entry.name,
|
|
59025
59170
|
isFile: entry.isFile(),
|
|
@@ -59027,16 +59172,16 @@ var NodeFileSystem = class {
|
|
|
59027
59172
|
isSymbolicLink: entry.isSymbolicLink()
|
|
59028
59173
|
}));
|
|
59029
59174
|
}
|
|
59030
|
-
async exists(
|
|
59175
|
+
async exists(path34) {
|
|
59031
59176
|
try {
|
|
59032
|
-
await fs16.access(
|
|
59177
|
+
await fs16.access(path34);
|
|
59033
59178
|
return true;
|
|
59034
59179
|
} catch {
|
|
59035
59180
|
return false;
|
|
59036
59181
|
}
|
|
59037
59182
|
}
|
|
59038
|
-
async mkdir(
|
|
59039
|
-
await fs16.mkdir(
|
|
59183
|
+
async mkdir(path34) {
|
|
59184
|
+
await fs16.mkdir(path34, { recursive: true });
|
|
59040
59185
|
}
|
|
59041
59186
|
};
|
|
59042
59187
|
|
|
@@ -59281,6 +59426,8 @@ async function toSummary(profile, secrets) {
|
|
|
59281
59426
|
...profile.auth.type === "apiKey" && describeSecretRef(profile.auth.apiKeyRef).kind === "env" ? { apiKeyEnvVar: describeSecretRef(profile.auth.apiKeyRef).envVar } : {},
|
|
59282
59427
|
// Not a secret: a command describes how to *get* a credential. The token it produces never
|
|
59283
59428
|
// crosses the bridge, and a form cannot edit what it is never shown.
|
|
59429
|
+
// References only — a store key or a variable name, never the credential (invariant 7).
|
|
59430
|
+
...profile.auth.type === "header" ? { authHeaders: profile.auth.headers } : {},
|
|
59284
59431
|
...profile.auth.type === "tokenCommand" ? {
|
|
59285
59432
|
/*
|
|
59286
59433
|
* `env` is dropped on the way out, deliberately.
|
|
@@ -59808,6 +59955,9 @@ function wireChatBridge(services) {
|
|
|
59808
59955
|
let cachedProgrammingProfileId;
|
|
59809
59956
|
let cachedOffice = {};
|
|
59810
59957
|
let cachedMail = {};
|
|
59958
|
+
let cachedDatasets = [];
|
|
59959
|
+
let datasetSummaryForPrompt = [];
|
|
59960
|
+
let cachedPythonEnabled = false;
|
|
59811
59961
|
const mailStore = new MailStore(storageDir);
|
|
59812
59962
|
let mailBusy = false;
|
|
59813
59963
|
let mailTimer;
|
|
@@ -59840,6 +59990,12 @@ function wireChatBridge(services) {
|
|
|
59840
59990
|
cachedProgrammingProfileId = config2.programmingProfileId;
|
|
59841
59991
|
cachedOffice = config2.office ?? {};
|
|
59842
59992
|
cachedMail = config2.mail ?? {};
|
|
59993
|
+
cachedDatasets = config2.datasets ?? [];
|
|
59994
|
+
cachedPythonEnabled = config2.python?.dynamicTools === "on";
|
|
59995
|
+
datasetSummaryForPrompt = await Promise.all(cachedDatasets.map(async (dataset) => ({
|
|
59996
|
+
name: dataset.name,
|
|
59997
|
+
records: (await new DatasetStore(storageDir, dataset.id).load()).length
|
|
59998
|
+
})));
|
|
59843
59999
|
cachedModeId = config2.modeId;
|
|
59844
60000
|
cachedMaxIterations = config2.maxIterations ?? 25;
|
|
59845
60001
|
cachedAccentColor = config2.ui?.accentColor ?? "#22C55E";
|
|
@@ -59940,7 +60096,7 @@ function wireChatBridge(services) {
|
|
|
59940
60096
|
platform: process.platform === "win32" ? "win32" : "posix"
|
|
59941
60097
|
});
|
|
59942
60098
|
}
|
|
59943
|
-
function currentToolRegistry(expert, search, codebase, docs, dispatcher = false, hideSkills = false, teamSkills, mailSemantic) {
|
|
60099
|
+
function currentToolRegistry(expert, search, codebase, docs, dispatcher = false, hideSkills = false, teamSkills, mailSemantic, datasetSemanticForTools) {
|
|
59944
60100
|
const combined = new ToolRegistry();
|
|
59945
60101
|
for (const tool of builtinTools.list())
|
|
59946
60102
|
combined.register(tool);
|
|
@@ -60027,6 +60183,16 @@ function wireChatBridge(services) {
|
|
|
60027
60183
|
if (codebase !== void 0) {
|
|
60028
60184
|
combined.register(createSearchCodebaseTool({ ...codebase, observer: searchLog }));
|
|
60029
60185
|
}
|
|
60186
|
+
if (cachedDatasets.length > 0) {
|
|
60187
|
+
combined.register(createSearchDataTool({
|
|
60188
|
+
load: async () => Promise.all(cachedDatasets.map(async (dataset) => ({
|
|
60189
|
+
id: dataset.id,
|
|
60190
|
+
name: dataset.name,
|
|
60191
|
+
records: await new DatasetStore(storageDir, dataset.id).load()
|
|
60192
|
+
}))),
|
|
60193
|
+
...datasetSemanticForTools !== void 0 ? { semantic: datasetSemanticForTools } : {}
|
|
60194
|
+
}));
|
|
60195
|
+
}
|
|
60030
60196
|
if (officeSupported() && (cachedOffice.excel === true || cachedOffice.outlook === true)) {
|
|
60031
60197
|
const officeOptions = { bridge: office() };
|
|
60032
60198
|
if (cachedOffice.excel === true) {
|
|
@@ -60302,6 +60468,9 @@ function wireChatBridge(services) {
|
|
|
60302
60468
|
expertAvailable: expertCliInfo !== void 0,
|
|
60303
60469
|
// Named only when there is an index to prefer.
|
|
60304
60470
|
mailIndexed: cachedMail.enabled === true && cachedOffice.outlook === true,
|
|
60471
|
+
// Counted here rather than in the prompt builder, which has no filesystem.
|
|
60472
|
+
datasets: datasetSummaryForPrompt,
|
|
60473
|
+
canWriteCollectors: cachedPythonEnabled,
|
|
60305
60474
|
/*
|
|
60306
60475
|
* Either the whole list or a count and an instruction to search — never both, and
|
|
60307
60476
|
* never neither. `renderSkillsHintForPrompt` explains why the count stays.
|
|
@@ -60452,7 +60621,17 @@ function wireChatBridge(services) {
|
|
|
60452
60621
|
* is frequently a local Qdrant while the code goes to a shared cluster — mail is the
|
|
60453
60622
|
* corpus people most want kept off a team's infrastructure.
|
|
60454
60623
|
*/
|
|
60455
|
-
mailCollection !== void 0 && mailSearch !== void 0 && embedder !== void 0 ? { searcher: mailSearch.searcher, embedder, collection: mailCollection } : void 0
|
|
60624
|
+
mailCollection !== void 0 && mailSearch !== void 0 && embedder !== void 0 ? { searcher: mailSearch.searcher, embedder, collection: mailCollection } : void 0,
|
|
60625
|
+
/*
|
|
60626
|
+
* Datasets share one collection, resolved against whichever store `retrieval.stores.data`
|
|
60627
|
+
* names — the same per-corpus routing §12e added, for the same reason: somebody's own
|
|
60628
|
+
* collected data is frequently the corpus they most want kept off a shared cluster.
|
|
60629
|
+
*/
|
|
60630
|
+
await (async () => {
|
|
60631
|
+
const collection = datasetCollectionName(config2);
|
|
60632
|
+
const search2 = await resolveDatasetSearch(config2);
|
|
60633
|
+
return collection !== void 0 && search2 !== void 0 && embedder !== void 0 ? { searcher: search2.searcher, embedder, collection } : void 0;
|
|
60634
|
+
})()
|
|
60456
60635
|
);
|
|
60457
60636
|
const turnRegistry = schedule !== void 0 ? registryForSchedule(fullRegistry.list(), schedule) : fullRegistry;
|
|
60458
60637
|
turnOptions.timeoutForTool = toolTimeout;
|
|
@@ -60572,6 +60751,21 @@ function wireChatBridge(services) {
|
|
|
60572
60751
|
}
|
|
60573
60752
|
};
|
|
60574
60753
|
}
|
|
60754
|
+
if (input.authType === "header") {
|
|
60755
|
+
const headers = (input.authHeaders ?? []).map((header) => ({
|
|
60756
|
+
name: header.name.trim(),
|
|
60757
|
+
valueRef: header.valueRef.trim(),
|
|
60758
|
+
...header.prefix !== void 0 && header.prefix.length > 0 ? { prefix: header.prefix } : {}
|
|
60759
|
+
})).filter((header) => header.name.length > 0 && header.valueRef.length > 0);
|
|
60760
|
+
const stored = await Promise.all(headers.map(async (header, index) => {
|
|
60761
|
+
if (describeSecretRef(header.valueRef).kind === "env")
|
|
60762
|
+
return header;
|
|
60763
|
+
const ref = `profile:${id}:header:${String(index)}`;
|
|
60764
|
+
await secrets.set(ref, header.valueRef);
|
|
60765
|
+
return { ...header, valueRef: ref };
|
|
60766
|
+
}));
|
|
60767
|
+
return stored.length > 0 ? { type: "header", headers: stored } : { type: "none" };
|
|
60768
|
+
}
|
|
60575
60769
|
if (input.authType === "tokenCommand") {
|
|
60576
60770
|
if (services.executableAuthRefusal !== void 0)
|
|
60577
60771
|
throw new Error(services.executableAuthRefusal);
|
|
@@ -61197,8 +61391,8 @@ function wireChatBridge(services) {
|
|
|
61197
61391
|
limit: limits.limit,
|
|
61198
61392
|
previewChars: limits.previewChars
|
|
61199
61393
|
});
|
|
61200
|
-
for (const
|
|
61201
|
-
skipped.add(
|
|
61394
|
+
for (const path34 of answer.skipped ?? [])
|
|
61395
|
+
skipped.add(path34);
|
|
61202
61396
|
return { messages: answer.messages, truncated: answer.truncated };
|
|
61203
61397
|
},
|
|
61204
61398
|
...embedder !== void 0 && search !== void 0 && collection !== void 0 ? {
|
|
@@ -61230,6 +61424,206 @@ function wireChatBridge(services) {
|
|
|
61230
61424
|
endIndexing("mail");
|
|
61231
61425
|
}
|
|
61232
61426
|
}
|
|
61427
|
+
const datasetTimers = /* @__PURE__ */ new Map();
|
|
61428
|
+
const datasetBusy = /* @__PURE__ */ new Set();
|
|
61429
|
+
const datasetResults = /* @__PURE__ */ new Map();
|
|
61430
|
+
function datasetStoreFor(id) {
|
|
61431
|
+
return new DatasetStore(storageDir, id);
|
|
61432
|
+
}
|
|
61433
|
+
function datasetCollectionName(config2) {
|
|
61434
|
+
const base = codebaseIndexName(config2);
|
|
61435
|
+
return base === void 0 ? void 0 : `${base}-data`;
|
|
61436
|
+
}
|
|
61437
|
+
async function resolveDatasetSearch(config2, dataset) {
|
|
61438
|
+
const wanted = dataset?.storeId ?? storeIdFor("data", config2);
|
|
61439
|
+
return resolveSearch(config2, wanted);
|
|
61440
|
+
}
|
|
61441
|
+
async function datasetSemantic(config2, dataset) {
|
|
61442
|
+
const collection = datasetCollectionName(config2);
|
|
61443
|
+
const search = await resolveDatasetSearch(config2, dataset);
|
|
61444
|
+
const embedder = await resolveEmbedder(config2);
|
|
61445
|
+
if (collection === void 0 || search === void 0 || embedder === void 0)
|
|
61446
|
+
return void 0;
|
|
61447
|
+
return {
|
|
61448
|
+
embedder,
|
|
61449
|
+
collection,
|
|
61450
|
+
writer: createVectorIndexWriter(httpClient, search.store, await vectorStoreConnectionFor(search.store, search.id)),
|
|
61451
|
+
searcher: search.searcher
|
|
61452
|
+
};
|
|
61453
|
+
}
|
|
61454
|
+
async function runDatasetSync(id, reason) {
|
|
61455
|
+
if (datasetBusy.has(id))
|
|
61456
|
+
return;
|
|
61457
|
+
const config2 = await loadSettings();
|
|
61458
|
+
const dataset = (config2.datasets ?? []).find((entry) => entry.id === id);
|
|
61459
|
+
if (dataset === void 0)
|
|
61460
|
+
return;
|
|
61461
|
+
datasetBusy.add(id);
|
|
61462
|
+
const signal = beginIndexing(`dataset:${id}`);
|
|
61463
|
+
reportIndexing("dataset", `Syncing ${dataset.name}`, { detail: `via ${dataset.toolName}` });
|
|
61464
|
+
try {
|
|
61465
|
+
const semantic = await datasetSemantic(config2, dataset);
|
|
61466
|
+
const result = await syncDataset({
|
|
61467
|
+
datasetId: id,
|
|
61468
|
+
store: datasetStoreFor(id),
|
|
61469
|
+
signal,
|
|
61470
|
+
onProgress: (done, total, phase) => reportIndexing("dataset", phase, { done, total }),
|
|
61471
|
+
...dataset.retentionDays !== void 0 ? { retentionDays: dataset.retentionDays } : {},
|
|
61472
|
+
...semantic !== void 0 ? { semantic: { embedder: semantic.embedder, writer: semantic.writer, collection: semantic.collection } } : {},
|
|
61473
|
+
/*
|
|
61474
|
+
* The collector runs through the ordinary Python tool path, so it is the same code that
|
|
61475
|
+
* validated it, the same worker, the same timeout. A second execution path would be a
|
|
61476
|
+
* second thing to keep in step with tool approval.
|
|
61477
|
+
*/
|
|
61478
|
+
collect: async (since2) => {
|
|
61479
|
+
const registry2 = currentToolRegistry();
|
|
61480
|
+
const tool = registry2.get(dataset.toolName) ?? registry2.get(`py__${dataset.toolName}`);
|
|
61481
|
+
if (tool === void 0) {
|
|
61482
|
+
throw new Error(`The collector tool "${dataset.toolName}" is not registered. A Python tool may have been deleted or Python switched off; an MCP tool may be from a server that is disconnected or disabled. Settings \u2192 Tools lists everything callable.`);
|
|
61483
|
+
}
|
|
61484
|
+
const args = { ...dataset.arguments ?? {}, ...since2 === void 0 ? {} : { since: since2 } };
|
|
61485
|
+
const output = await tool.execute(args, { signal });
|
|
61486
|
+
if (output.isError === true)
|
|
61487
|
+
throw new Error(String(output.content));
|
|
61488
|
+
try {
|
|
61489
|
+
return JSON.parse(typeof output.content === "string" ? output.content : JSON.stringify(output.content));
|
|
61490
|
+
} catch {
|
|
61491
|
+
throw new Error("The collector tool did not return JSON. It must return a list of records \u2014 see the guidance in Settings \u2192 Custom data.");
|
|
61492
|
+
}
|
|
61493
|
+
}
|
|
61494
|
+
});
|
|
61495
|
+
const detail = result.updated === 0 ? `No changes (${reason}). ${String(result.total)} record(s) held.` : `${String(result.updated)} record(s) updated, ${String(result.embedded)} embedded${result.removed > 0 ? `, ${String(result.removed)} removed by retention` : ""}. ${String(result.total)} held.`;
|
|
61496
|
+
datasetResults.set(id, { detail, failed: false, at: Date.now() });
|
|
61497
|
+
reportIndexing("dataset", "Finished", { detail, running: false });
|
|
61498
|
+
} catch (error51) {
|
|
61499
|
+
const stopped = signal.aborted;
|
|
61500
|
+
const detail = stopped ? "Stopped." : error51 instanceof Error ? error51.message : String(error51);
|
|
61501
|
+
datasetResults.set(id, { detail, failed: !stopped, at: Date.now() });
|
|
61502
|
+
if (!stopped)
|
|
61503
|
+
logger.warn(`dataset "${dataset.name}" sync failed: ${detail}`);
|
|
61504
|
+
reportIndexing("dataset", stopped ? "Stopped" : "Failed", { detail, running: false });
|
|
61505
|
+
} finally {
|
|
61506
|
+
datasetBusy.delete(id);
|
|
61507
|
+
endIndexing(`dataset:${id}`);
|
|
61508
|
+
await postDatasetStatus();
|
|
61509
|
+
}
|
|
61510
|
+
}
|
|
61511
|
+
async function handleClearDataset(id, resync) {
|
|
61512
|
+
if (datasetBusy.has(id))
|
|
61513
|
+
return;
|
|
61514
|
+
const config2 = await loadSettings();
|
|
61515
|
+
const dataset = (config2.datasets ?? []).find((entry) => entry.id === id);
|
|
61516
|
+
if (dataset === void 0)
|
|
61517
|
+
return;
|
|
61518
|
+
datasetBusy.add(id);
|
|
61519
|
+
const signal = beginIndexing(`dataset:${id}`);
|
|
61520
|
+
reportIndexing("dataset", `Clearing ${dataset.name}`);
|
|
61521
|
+
try {
|
|
61522
|
+
const semantic = await datasetSemantic(config2, dataset);
|
|
61523
|
+
const { removed } = await clearDataset({
|
|
61524
|
+
datasetId: id,
|
|
61525
|
+
store: datasetStoreFor(id),
|
|
61526
|
+
signal,
|
|
61527
|
+
onProgress: (done, total, phase) => reportIndexing("dataset", phase, { done, total }),
|
|
61528
|
+
...semantic !== void 0 ? { semantic: { writer: semantic.writer, collection: semantic.collection } } : {}
|
|
61529
|
+
});
|
|
61530
|
+
const detail = `Cleared ${String(removed)} record(s).`;
|
|
61531
|
+
datasetResults.set(id, { detail, failed: false, at: Date.now() });
|
|
61532
|
+
reportIndexing("dataset", "Finished", { detail, running: false });
|
|
61533
|
+
} catch (error51) {
|
|
61534
|
+
const detail = error51 instanceof Error ? error51.message : String(error51);
|
|
61535
|
+
datasetResults.set(id, { detail, failed: true, at: Date.now() });
|
|
61536
|
+
logger.warn(`dataset clear failed: ${detail}`);
|
|
61537
|
+
reportIndexing("dataset", "Failed", { detail, running: false });
|
|
61538
|
+
} finally {
|
|
61539
|
+
datasetBusy.delete(id);
|
|
61540
|
+
endIndexing(`dataset:${id}`);
|
|
61541
|
+
await postDatasetStatus();
|
|
61542
|
+
}
|
|
61543
|
+
if (resync)
|
|
61544
|
+
await runDatasetSync(id, "rebuild");
|
|
61545
|
+
}
|
|
61546
|
+
function reconcileDatasetTimers(config2) {
|
|
61547
|
+
for (const timer of datasetTimers.values())
|
|
61548
|
+
clearInterval(timer);
|
|
61549
|
+
datasetTimers.clear();
|
|
61550
|
+
for (const dataset of config2.datasets ?? []) {
|
|
61551
|
+
const minutes = dataset.syncMinutes ?? 0;
|
|
61552
|
+
if (dataset.enabled === false || minutes <= 0)
|
|
61553
|
+
continue;
|
|
61554
|
+
const timer = setInterval(() => void runDatasetSync(dataset.id, "scheduled"), minutes * 60 * 1e3);
|
|
61555
|
+
timer.unref?.();
|
|
61556
|
+
datasetTimers.set(dataset.id, timer);
|
|
61557
|
+
}
|
|
61558
|
+
}
|
|
61559
|
+
async function postDatasetStatus() {
|
|
61560
|
+
const config2 = (await configManager.load()).config;
|
|
61561
|
+
const datasets = config2.datasets ?? [];
|
|
61562
|
+
const collection = datasetCollectionName(config2);
|
|
61563
|
+
const embedder = await resolveEmbedder(config2).catch(() => void 0);
|
|
61564
|
+
const entries = await Promise.all(datasets.map(async (dataset) => {
|
|
61565
|
+
const store = datasetStoreFor(dataset.id);
|
|
61566
|
+
const records = await store.load();
|
|
61567
|
+
const times = records.map((record2) => record2.timestamp).filter((at) => at !== void 0);
|
|
61568
|
+
const search = await resolveDatasetSearch(config2, dataset).catch(() => void 0);
|
|
61569
|
+
return {
|
|
61570
|
+
...dataset,
|
|
61571
|
+
records: records.length,
|
|
61572
|
+
sizeBytes: await store.sizeBytes(),
|
|
61573
|
+
...times.length > 0 ? { oldest: Math.min(...times), newest: Math.max(...times) } : {},
|
|
61574
|
+
...await store.lastSyncedAt() !== void 0 ? { lastSyncedAt: await store.lastSyncedAt() } : {},
|
|
61575
|
+
busy: datasetBusy.has(dataset.id),
|
|
61576
|
+
...datasetResults.get(dataset.id) !== void 0 ? {
|
|
61577
|
+
lastResult: datasetResults.get(dataset.id).detail,
|
|
61578
|
+
lastFailed: datasetResults.get(dataset.id).failed,
|
|
61579
|
+
lastAttemptAt: datasetResults.get(dataset.id).at
|
|
61580
|
+
} : {},
|
|
61581
|
+
storeLabel: search?.store.label ?? "none"
|
|
61582
|
+
};
|
|
61583
|
+
}));
|
|
61584
|
+
post({
|
|
61585
|
+
type: "datasetStatus",
|
|
61586
|
+
datasets: entries,
|
|
61587
|
+
// Said plainly, because a dataset with no embedder still syncs and still searches — on words
|
|
61588
|
+
// rather than meaning — and someone seeing results would otherwise assume it is semantic.
|
|
61589
|
+
semantic: collection !== void 0 && embedder !== void 0,
|
|
61590
|
+
/*
|
|
61591
|
+
* Python tools and MCP tools, selected by what they *are* rather than by group.
|
|
61592
|
+
*
|
|
61593
|
+
* Filtering on `group` was wrong and showed only the built-ins: a Python tool is registered
|
|
61594
|
+
* as `command`, because it runs code, and an MCP tool as `mcp`. Those two groups also hold
|
|
61595
|
+
* `execute_command` and the tool-authoring tools, which are not data sources — so the test
|
|
61596
|
+
* is the `py__` prefix and the mcp group, not a permission category. Reported as the picker
|
|
61597
|
+
* listing only built-in tools.
|
|
61598
|
+
*/
|
|
61599
|
+
tools: currentToolRegistry().list().filter((tool) => tool.name.startsWith("py__") || tool.group === "mcp").map((tool) => ({
|
|
61600
|
+
name: tool.name,
|
|
61601
|
+
description: tool.description,
|
|
61602
|
+
// Grouped in the picker, because "which of these is mine?" is the first question with
|
|
61603
|
+
// forty MCP tools in the list.
|
|
61604
|
+
kind: tool.name.startsWith("py__") ? "python" : "mcp"
|
|
61605
|
+
})),
|
|
61606
|
+
guidance: COLLECTOR_TOOL_GUIDANCE
|
|
61607
|
+
});
|
|
61608
|
+
}
|
|
61609
|
+
async function handleSaveDataset(dataset) {
|
|
61610
|
+
const { config: config2 } = await configManager.load();
|
|
61611
|
+
const existing = config2.datasets ?? [];
|
|
61612
|
+
const next = existing.some((entry) => entry.id === dataset.id) ? existing.map((entry) => entry.id === dataset.id ? dataset : entry) : [...existing, dataset];
|
|
61613
|
+
await configManager.save("user", { datasets: next });
|
|
61614
|
+
reconcileDatasetTimers((await configManager.load()).config);
|
|
61615
|
+
await postDatasetStatus();
|
|
61616
|
+
}
|
|
61617
|
+
async function handleDeleteDataset(id) {
|
|
61618
|
+
const { config: config2 } = await configManager.load();
|
|
61619
|
+
await handleClearDataset(id, false);
|
|
61620
|
+
await configManager.save("user", {
|
|
61621
|
+
datasets: (config2.datasets ?? []).filter((entry) => entry.id !== id)
|
|
61622
|
+
});
|
|
61623
|
+
datasetResults.delete(id);
|
|
61624
|
+
reconcileDatasetTimers((await configManager.load()).config);
|
|
61625
|
+
await postDatasetStatus();
|
|
61626
|
+
}
|
|
61233
61627
|
function reconcileMailTimer(config2) {
|
|
61234
61628
|
if (mailTimer !== void 0) {
|
|
61235
61629
|
clearInterval(mailTimer);
|
|
@@ -61279,9 +61673,9 @@ function wireChatBridge(services) {
|
|
|
61279
61673
|
});
|
|
61280
61674
|
const all = result.folders.map((entry) => entry.path);
|
|
61281
61675
|
const wanted = new Set(chosen);
|
|
61282
|
-
for (const
|
|
61283
|
-
if (chosen.some((root) =>
|
|
61284
|
-
wanted.add(
|
|
61676
|
+
for (const path34 of all) {
|
|
61677
|
+
if (chosen.some((root) => path34 === root || path34.startsWith(`${root}\\`)))
|
|
61678
|
+
wanted.add(path34);
|
|
61285
61679
|
}
|
|
61286
61680
|
return [...wanted];
|
|
61287
61681
|
} catch {
|
|
@@ -61498,6 +61892,7 @@ function wireChatBridge(services) {
|
|
|
61498
61892
|
});
|
|
61499
61893
|
const config2 = await loadSettings();
|
|
61500
61894
|
reconcileMailTimer(config2);
|
|
61895
|
+
reconcileDatasetTimers(config2);
|
|
61501
61896
|
await postMailStatus();
|
|
61502
61897
|
if (config2.mail?.enabled === true)
|
|
61503
61898
|
void runMailSync("just enabled");
|
|
@@ -61776,6 +62171,28 @@ function wireChatBridge(services) {
|
|
|
61776
62171
|
const { config: config2 } = await configManager.load();
|
|
61777
62172
|
const search = await resolveSearch(config2);
|
|
61778
62173
|
const embedder = await resolveEmbedder(config2);
|
|
62174
|
+
if (target === "data") {
|
|
62175
|
+
const datasets = config2.datasets ?? [];
|
|
62176
|
+
const collection = datasetCollectionName(config2);
|
|
62177
|
+
const dataSearch = await resolveDatasetSearch(config2);
|
|
62178
|
+
const tool2 = createSearchDataTool({
|
|
62179
|
+
load: async () => Promise.all(datasets.map(async (dataset) => ({
|
|
62180
|
+
id: dataset.id,
|
|
62181
|
+
name: dataset.name,
|
|
62182
|
+
records: await new DatasetStore(storageDir, dataset.id).load()
|
|
62183
|
+
}))),
|
|
62184
|
+
...collection !== void 0 && dataSearch !== void 0 && embedder !== void 0 ? { semantic: { searcher: dataSearch.searcher, embedder, collection } } : {}
|
|
62185
|
+
});
|
|
62186
|
+
const result2 = await tool2.execute({ query, limit: 25 }, {});
|
|
62187
|
+
post({
|
|
62188
|
+
type: "searchProbe",
|
|
62189
|
+
target,
|
|
62190
|
+
query,
|
|
62191
|
+
text: result2.content,
|
|
62192
|
+
...result2.isError === true ? { error: "The search failed." } : {}
|
|
62193
|
+
});
|
|
62194
|
+
return;
|
|
62195
|
+
}
|
|
61779
62196
|
if (target === "mail") {
|
|
61780
62197
|
const collection = mailCollectionName(config2);
|
|
61781
62198
|
const mailSearch = await resolveMailSearch(config2);
|
|
@@ -62967,6 +63384,7 @@ function wireChatBridge(services) {
|
|
|
62967
63384
|
} else if (message3.type === "requestMailStatus") {
|
|
62968
63385
|
void loadSettings().then((config2) => {
|
|
62969
63386
|
reconcileMailTimer(config2);
|
|
63387
|
+
reconcileDatasetTimers(config2);
|
|
62970
63388
|
return postMailStatus();
|
|
62971
63389
|
});
|
|
62972
63390
|
} else if (message3.type === "saveMailSettings") {
|
|
@@ -62982,6 +63400,16 @@ function wireChatBridge(services) {
|
|
|
62982
63400
|
void handleClearTeamSkills();
|
|
62983
63401
|
} else if (message3.type === "refreshMail") {
|
|
62984
63402
|
void handleRefreshMail(message3.days);
|
|
63403
|
+
} else if (message3.type === "requestDatasetStatus") {
|
|
63404
|
+
void postDatasetStatus();
|
|
63405
|
+
} else if (message3.type === "saveDataset") {
|
|
63406
|
+
void handleSaveDataset(message3.dataset);
|
|
63407
|
+
} else if (message3.type === "deleteDataset") {
|
|
63408
|
+
void handleDeleteDataset(message3.id);
|
|
63409
|
+
} else if (message3.type === "syncDataset") {
|
|
63410
|
+
void runDatasetSync(message3.id, "manual");
|
|
63411
|
+
} else if (message3.type === "clearDataset") {
|
|
63412
|
+
void handleClearDataset(message3.id, message3.resync === true);
|
|
62985
63413
|
} else if (message3.type === "clearMailIndex") {
|
|
62986
63414
|
void handleClearMailIndex(message3.resync === true);
|
|
62987
63415
|
} else if (message3.type === "saveSkillsAlias") {
|
|
@@ -64386,10 +64814,10 @@ function readSmall(raw, params) {
|
|
|
64386
64814
|
const end = params.limit !== void 0 ? start + params.limit : lines.length;
|
|
64387
64815
|
return number4(lines.slice(start, end), start + 1);
|
|
64388
64816
|
}
|
|
64389
|
-
async function readLarge(
|
|
64817
|
+
async function readLarge(fs27, realPath, params, size) {
|
|
64390
64818
|
const human = formatBytes(size);
|
|
64391
64819
|
if (params.tail !== void 0) {
|
|
64392
|
-
const part = await readTail(
|
|
64820
|
+
const part = await readTail(fs27, realPath, size, params.tail);
|
|
64393
64821
|
return [
|
|
64394
64822
|
`${human} file \u2014 last ${String(part.lines.length)} lines.`,
|
|
64395
64823
|
/*
|
|
@@ -64404,7 +64832,7 @@ async function readLarge(fs26, realPath, params, size) {
|
|
|
64404
64832
|
}
|
|
64405
64833
|
if (params.offset !== void 0) {
|
|
64406
64834
|
const limit = params.limit ?? DEFAULT_LARGE_LIMIT;
|
|
64407
|
-
const part = await readLineWindow(
|
|
64835
|
+
const part = await readLineWindow(fs27, realPath, size, params.offset, limit);
|
|
64408
64836
|
const shown = part.lines.length;
|
|
64409
64837
|
return [
|
|
64410
64838
|
`${human} file \u2014 lines ${String(params.offset)}\u2013${String(params.offset + shown - 1)}${part.hasMoreAfter ? ", more follows" : " (end of file)"}.`,
|
|
@@ -64412,7 +64840,7 @@ async function readLarge(fs26, realPath, params, size) {
|
|
|
64412
64840
|
number4(part.lines, params.offset)
|
|
64413
64841
|
].join("\n");
|
|
64414
64842
|
}
|
|
64415
|
-
const total = await countLines(
|
|
64843
|
+
const total = await countLines(fs27, realPath, size);
|
|
64416
64844
|
return [
|
|
64417
64845
|
`${realPathName(realPath)} is ${human} (${total.toLocaleString()} lines) \u2014 too large to read at once.`,
|
|
64418
64846
|
"",
|
|
@@ -64611,6 +65039,334 @@ function createDefaultToolRegistry() {
|
|
|
64611
65039
|
return registry2;
|
|
64612
65040
|
}
|
|
64613
65041
|
|
|
65042
|
+
// ../../packages/core/dist/dataset/store.js
|
|
65043
|
+
import fs19 from "node:fs/promises";
|
|
65044
|
+
import path26 from "node:path";
|
|
65045
|
+
var DatasetStore = class {
|
|
65046
|
+
filePath;
|
|
65047
|
+
statePath;
|
|
65048
|
+
constructor(storageDir, datasetId) {
|
|
65049
|
+
const safe = datasetId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
65050
|
+
this.filePath = path26.join(storageDir, "datasets", `${safe}.jsonl`);
|
|
65051
|
+
this.statePath = path26.join(storageDir, "datasets", `${safe}.state.json`);
|
|
65052
|
+
}
|
|
65053
|
+
/** Every record. A malformed line is skipped — one bad line costs one record, not the corpus. */
|
|
65054
|
+
async load() {
|
|
65055
|
+
let raw;
|
|
65056
|
+
try {
|
|
65057
|
+
raw = await fs19.readFile(this.filePath, "utf8");
|
|
65058
|
+
} catch {
|
|
65059
|
+
return [];
|
|
65060
|
+
}
|
|
65061
|
+
const byId = /* @__PURE__ */ new Map();
|
|
65062
|
+
for (const line of raw.split("\n")) {
|
|
65063
|
+
const trimmed = line.trim();
|
|
65064
|
+
if (trimmed.length === 0)
|
|
65065
|
+
continue;
|
|
65066
|
+
try {
|
|
65067
|
+
const parsed = JSON.parse(trimmed);
|
|
65068
|
+
if (typeof parsed.id === "string" && typeof parsed.text === "string")
|
|
65069
|
+
byId.set(parsed.id, parsed);
|
|
65070
|
+
} catch {
|
|
65071
|
+
}
|
|
65072
|
+
}
|
|
65073
|
+
return [...byId.values()];
|
|
65074
|
+
}
|
|
65075
|
+
/** Appends. Re-appending an existing id is how an update is recorded — see `load`. */
|
|
65076
|
+
async append(records) {
|
|
65077
|
+
if (records.length === 0)
|
|
65078
|
+
return;
|
|
65079
|
+
await fs19.mkdir(path26.dirname(this.filePath), { recursive: true });
|
|
65080
|
+
await fs19.writeFile(this.filePath, "", { flag: "a" });
|
|
65081
|
+
const lines = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
65082
|
+
await fs19.appendFile(this.filePath, `${lines}
|
|
65083
|
+
`, "utf8");
|
|
65084
|
+
}
|
|
65085
|
+
/** Rewrites with exactly these. Temp-and-rename, so an interrupted prune leaves the old file. */
|
|
65086
|
+
async replace(records) {
|
|
65087
|
+
await fs19.mkdir(path26.dirname(this.filePath), { recursive: true });
|
|
65088
|
+
const temporary = `${this.filePath}.tmp`;
|
|
65089
|
+
const body = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
65090
|
+
await fs19.writeFile(temporary, records.length === 0 ? "" : `${body}
|
|
65091
|
+
`, "utf8");
|
|
65092
|
+
await fs19.rename(temporary, this.filePath);
|
|
65093
|
+
}
|
|
65094
|
+
/**
|
|
65095
|
+
* Rewrites the file with the duplicates collapsed.
|
|
65096
|
+
*
|
|
65097
|
+
* Append-as-upsert means a record updated every hour adds a line every hour, so the file grows
|
|
65098
|
+
* with the *number of syncs* rather than the size of the corpus. Compaction is cheap and only
|
|
65099
|
+
* worth doing when it would actually shrink anything, which the caller decides.
|
|
65100
|
+
*/
|
|
65101
|
+
async compact() {
|
|
65102
|
+
let before;
|
|
65103
|
+
try {
|
|
65104
|
+
before = (await fs19.readFile(this.filePath, "utf8")).split("\n").filter((line) => line.trim().length > 0).length;
|
|
65105
|
+
} catch {
|
|
65106
|
+
return { before: 0, after: 0 };
|
|
65107
|
+
}
|
|
65108
|
+
const records = await this.load();
|
|
65109
|
+
if (records.length === before)
|
|
65110
|
+
return { before, after: before };
|
|
65111
|
+
await this.replace(records);
|
|
65112
|
+
return { before, after: records.length };
|
|
65113
|
+
}
|
|
65114
|
+
async clear() {
|
|
65115
|
+
await fs19.rm(this.filePath, { force: true });
|
|
65116
|
+
await fs19.rm(this.statePath, { force: true });
|
|
65117
|
+
}
|
|
65118
|
+
async sizeBytes() {
|
|
65119
|
+
try {
|
|
65120
|
+
return (await fs19.stat(this.filePath)).size;
|
|
65121
|
+
} catch {
|
|
65122
|
+
return 0;
|
|
65123
|
+
}
|
|
65124
|
+
}
|
|
65125
|
+
/**
|
|
65126
|
+
* When the last successful sync finished, passed to the collector as `since`.
|
|
65127
|
+
*
|
|
65128
|
+
* Written only on success, deliberately: after a failed run the next one must ask for the same
|
|
65129
|
+
* window again, or whatever the source produced while it was broken is skipped for ever with
|
|
65130
|
+
* nothing anywhere recording the gap.
|
|
65131
|
+
*/
|
|
65132
|
+
async lastSyncedAt() {
|
|
65133
|
+
try {
|
|
65134
|
+
const parsed = JSON.parse(await fs19.readFile(this.statePath, "utf8"));
|
|
65135
|
+
return typeof parsed.lastSyncedAt === "number" ? parsed.lastSyncedAt : void 0;
|
|
65136
|
+
} catch {
|
|
65137
|
+
return void 0;
|
|
65138
|
+
}
|
|
65139
|
+
}
|
|
65140
|
+
async recordSync(at) {
|
|
65141
|
+
await fs19.mkdir(path26.dirname(this.statePath), { recursive: true });
|
|
65142
|
+
const temporary = `${this.statePath}.tmp`;
|
|
65143
|
+
await fs19.writeFile(temporary, JSON.stringify({ lastSyncedAt: at }), "utf8");
|
|
65144
|
+
await fs19.rename(temporary, this.statePath);
|
|
65145
|
+
}
|
|
65146
|
+
};
|
|
65147
|
+
function partitionByAge(records, cutoff) {
|
|
65148
|
+
const kept = [];
|
|
65149
|
+
const removed = [];
|
|
65150
|
+
for (const record2 of records) {
|
|
65151
|
+
if (record2.timestamp !== void 0 && record2.timestamp < cutoff)
|
|
65152
|
+
removed.push(record2);
|
|
65153
|
+
else
|
|
65154
|
+
kept.push(record2);
|
|
65155
|
+
}
|
|
65156
|
+
return { kept, removed };
|
|
65157
|
+
}
|
|
65158
|
+
|
|
65159
|
+
// ../../packages/core/dist/dataset/sync.js
|
|
65160
|
+
function datasetEmbedText(record2) {
|
|
65161
|
+
return [record2.title, record2.text].filter((part) => part !== void 0 && part.length > 0).join("\n");
|
|
65162
|
+
}
|
|
65163
|
+
function datasetVectorId(datasetId, recordId) {
|
|
65164
|
+
return `data:${datasetId}:${recordId}`;
|
|
65165
|
+
}
|
|
65166
|
+
async function syncDataset(options) {
|
|
65167
|
+
const now = options.now ?? Date.now();
|
|
65168
|
+
const held = await options.store.load();
|
|
65169
|
+
const heldById = new Map(held.map((record2) => [record2.id, record2]));
|
|
65170
|
+
options.onProgress?.(0, 0, "Running the collector");
|
|
65171
|
+
const since2 = await options.store.lastSyncedAt();
|
|
65172
|
+
const payload = await options.collect(since2);
|
|
65173
|
+
const parsed = parseDatasetPayload(payload);
|
|
65174
|
+
if ("error" in parsed)
|
|
65175
|
+
throw new Error(parsed.error);
|
|
65176
|
+
const collected = parsed.records;
|
|
65177
|
+
const changed = collected.filter((record2) => {
|
|
65178
|
+
const existing = heldById.get(record2.id);
|
|
65179
|
+
return existing === void 0 || JSON.stringify(existing) !== JSON.stringify(record2);
|
|
65180
|
+
});
|
|
65181
|
+
let embedded = 0;
|
|
65182
|
+
if (options.semantic !== void 0 && changed.length > 0) {
|
|
65183
|
+
const { embedder, writer, collection } = options.semantic;
|
|
65184
|
+
await writer.ensureCollection(collection, embedder.dimensions, options.signal);
|
|
65185
|
+
const documents = [];
|
|
65186
|
+
for (const record2 of changed) {
|
|
65187
|
+
if (options.signal?.aborted === true)
|
|
65188
|
+
throw new Error("Stopped.");
|
|
65189
|
+
options.onProgress?.(documents.length, changed.length, "Embedding new and changed records");
|
|
65190
|
+
const existing = heldById.get(record2.id);
|
|
65191
|
+
if (existing !== void 0 && datasetEmbedText(existing) === datasetEmbedText(record2))
|
|
65192
|
+
continue;
|
|
65193
|
+
const text = datasetEmbedText(record2);
|
|
65194
|
+
if (text.trim().length === 0)
|
|
65195
|
+
continue;
|
|
65196
|
+
documents.push({
|
|
65197
|
+
id: datasetVectorId(options.datasetId, record2.id),
|
|
65198
|
+
text,
|
|
65199
|
+
// The id travels in `path`, which is how a hit is joined back to its record.
|
|
65200
|
+
path: datasetVectorId(options.datasetId, record2.id),
|
|
65201
|
+
startLine: 1,
|
|
65202
|
+
endLine: 1,
|
|
65203
|
+
vector: await embedder.embed(text)
|
|
65204
|
+
});
|
|
65205
|
+
}
|
|
65206
|
+
if (documents.length > 0) {
|
|
65207
|
+
await writer.upsert(collection, documents, options.signal);
|
|
65208
|
+
embedded = documents.length;
|
|
65209
|
+
}
|
|
65210
|
+
}
|
|
65211
|
+
if (changed.length > 0)
|
|
65212
|
+
await options.store.append(changed);
|
|
65213
|
+
let removed = 0;
|
|
65214
|
+
if (options.retentionDays !== void 0) {
|
|
65215
|
+
const cutoff = now - options.retentionDays * 24 * 60 * 60 * 1e3;
|
|
65216
|
+
const after = await options.store.load();
|
|
65217
|
+
const { kept, removed: old } = partitionByAge(after, cutoff);
|
|
65218
|
+
if (old.length > 0) {
|
|
65219
|
+
options.onProgress?.(0, old.length, "Removing records past retention");
|
|
65220
|
+
if (options.semantic !== void 0) {
|
|
65221
|
+
await options.semantic.writer.deleteByPaths(options.semantic.collection, old.map((record2) => datasetVectorId(options.datasetId, record2.id)), options.signal);
|
|
65222
|
+
}
|
|
65223
|
+
await options.store.replace(kept);
|
|
65224
|
+
removed = old.length;
|
|
65225
|
+
}
|
|
65226
|
+
}
|
|
65227
|
+
await options.store.compact();
|
|
65228
|
+
await options.store.recordSync(now);
|
|
65229
|
+
const total = (await options.store.load()).length;
|
|
65230
|
+
return { collected: collected.length, updated: changed.length, embedded, removed, total };
|
|
65231
|
+
}
|
|
65232
|
+
async function clearDataset(options) {
|
|
65233
|
+
const held = await options.store.load();
|
|
65234
|
+
if (options.semantic !== void 0 && held.length > 0) {
|
|
65235
|
+
const size = 500;
|
|
65236
|
+
const paths = held.map((record2) => datasetVectorId(options.datasetId, record2.id));
|
|
65237
|
+
for (let start = 0; start < paths.length; start += size) {
|
|
65238
|
+
if (options.signal?.aborted === true)
|
|
65239
|
+
throw new Error("Stopped.");
|
|
65240
|
+
options.onProgress?.(Math.min(start + size, paths.length), paths.length, "Removing vectors");
|
|
65241
|
+
await options.semantic.writer.deleteByPaths(options.semantic.collection, paths.slice(start, start + size), options.signal);
|
|
65242
|
+
}
|
|
65243
|
+
}
|
|
65244
|
+
await options.store.clear();
|
|
65245
|
+
return { removed: held.length };
|
|
65246
|
+
}
|
|
65247
|
+
|
|
65248
|
+
// ../../packages/core/dist/tools/searchData.js
|
|
65249
|
+
var searchSchema3 = external_exports.object({
|
|
65250
|
+
dataset: external_exports.string().optional().describe("Which dataset to search, by name. Omit to search all of them."),
|
|
65251
|
+
query: external_exports.string().optional().describe("Rank by meaning. Omit to get the most recent records in the window."),
|
|
65252
|
+
withinDays: external_exports.number().min(0.01).optional().describe("Only records with a timestamp this recent. Records with no timestamp are excluded."),
|
|
65253
|
+
contains: external_exports.string().optional().describe("Only records whose title or text contains this text. Exact, case-insensitive."),
|
|
65254
|
+
tag: external_exports.string().optional().describe("Filter on a tag, as `name=value`. Exact."),
|
|
65255
|
+
limit: external_exports.number().int().min(1).max(50).optional().describe("How many to return. Default 15.")
|
|
65256
|
+
});
|
|
65257
|
+
function describe4(record2, dataset) {
|
|
65258
|
+
const when = record2.timestamp === void 0 ? "" : `${new Date(record2.timestamp).toLocaleString()} `;
|
|
65259
|
+
const heading = record2.title ?? record2.text.trim().split("\n")[0]?.slice(0, 100) ?? record2.id;
|
|
65260
|
+
const body = record2.text.trim().slice(0, 400);
|
|
65261
|
+
return `${when}[${dataset}] ${heading}
|
|
65262
|
+
id: ${record2.id}${record2.url === void 0 ? "" : ` ${record2.url}`}
|
|
65263
|
+
${body}`;
|
|
65264
|
+
}
|
|
65265
|
+
function createSearchDataTool(options) {
|
|
65266
|
+
return {
|
|
65267
|
+
name: "search_data",
|
|
65268
|
+
group: "read",
|
|
65269
|
+
description: "Searches the custom datasets the user collects with their own Python tools \u2014 tickets, wiki pages, rows from an internal system, whatever they have set up. Use it whenever a question is about the organisation's own data rather than about this codebase. `dataset` picks one by name, `withinDays` and `tag` are exact filters applied before any ranking, and `query` ranks what is left by meaning. Call it with no arguments to see what is there. These are exact counts over what has been synced, not a live query against the source \u2014 so the answer is only as current as the last sync, which is reported.",
|
|
65270
|
+
parametersSchema: searchSchema3,
|
|
65271
|
+
execute: async (params) => {
|
|
65272
|
+
try {
|
|
65273
|
+
const datasets = await options.load();
|
|
65274
|
+
if (datasets.length === 0) {
|
|
65275
|
+
return {
|
|
65276
|
+
content: "No custom datasets are configured, so there is nothing to search. The user sets these up in Settings \u2192 Custom data, by pointing at a Python tool that returns records. Say that rather than reporting that nothing was found."
|
|
65277
|
+
};
|
|
65278
|
+
}
|
|
65279
|
+
const wanted = params.dataset === void 0 ? datasets : datasets.filter((entry) => entry.name.toLowerCase() === params.dataset?.toLowerCase());
|
|
65280
|
+
if (wanted.length === 0) {
|
|
65281
|
+
return {
|
|
65282
|
+
content: `There is no dataset called "${params.dataset ?? ""}". Configured: ${datasets.map((entry) => entry.name).join(", ")}.`,
|
|
65283
|
+
isError: true
|
|
65284
|
+
};
|
|
65285
|
+
}
|
|
65286
|
+
let candidates = wanted.flatMap((entry) => entry.records.map((record2) => ({ dataset: entry.name, datasetId: entry.id, record: record2 })));
|
|
65287
|
+
const narrowed = [];
|
|
65288
|
+
if (params.withinDays !== void 0) {
|
|
65289
|
+
const cutoff = Date.now() - params.withinDays * 24 * 60 * 60 * 1e3;
|
|
65290
|
+
candidates = candidates.filter((entry) => entry.record.timestamp !== void 0 && entry.record.timestamp >= cutoff);
|
|
65291
|
+
narrowed.push(`in the last ${String(params.withinDays)} day(s)`);
|
|
65292
|
+
}
|
|
65293
|
+
if (params.tag !== void 0) {
|
|
65294
|
+
const [name, value] = params.tag.split("=");
|
|
65295
|
+
candidates = candidates.filter((entry) => value === void 0 ? entry.record.tags?.[name ?? ""] !== void 0 : entry.record.tags?.[name ?? ""] === value);
|
|
65296
|
+
narrowed.push(`tagged ${params.tag}`);
|
|
65297
|
+
}
|
|
65298
|
+
if (params.contains !== void 0) {
|
|
65299
|
+
const needle = params.contains.toLowerCase();
|
|
65300
|
+
candidates = candidates.filter((entry) => `${entry.record.title ?? ""}
|
|
65301
|
+
${entry.record.text}`.toLowerCase().includes(needle));
|
|
65302
|
+
narrowed.push(`containing "${params.contains}"`);
|
|
65303
|
+
}
|
|
65304
|
+
const criteria = narrowed.length === 0 ? "" : `, ${narrowed.join(", ")}`;
|
|
65305
|
+
if (candidates.length === 0) {
|
|
65306
|
+
return {
|
|
65307
|
+
content: `Nothing in ${wanted.map((entry) => entry.name).join(", ")}${criteria}. This is an exact answer over what has been synced \u2014 but it is only as current as the last sync.`
|
|
65308
|
+
};
|
|
65309
|
+
}
|
|
65310
|
+
const limit = params.limit ?? 15;
|
|
65311
|
+
let ordered = candidates.sort((a, b) => (b.record.timestamp ?? 0) - (a.record.timestamp ?? 0));
|
|
65312
|
+
let how = "";
|
|
65313
|
+
const asked = params.query?.trim() ?? "";
|
|
65314
|
+
if (asked.length > 0 && options.semantic === void 0) {
|
|
65315
|
+
const words = asked.toLowerCase().split(/\s+/).filter((word) => word.length > 2);
|
|
65316
|
+
const needle = asked.toLowerCase();
|
|
65317
|
+
candidates = candidates.filter((entry) => {
|
|
65318
|
+
const haystack = `${entry.record.title ?? ""}
|
|
65319
|
+
${entry.record.text}`.toLowerCase();
|
|
65320
|
+
return words.length === 0 ? haystack.includes(needle) : words.some((word) => haystack.includes(word));
|
|
65321
|
+
});
|
|
65322
|
+
if (candidates.length === 0) {
|
|
65323
|
+
return {
|
|
65324
|
+
content: `Nothing in ${wanted.map((entry) => entry.name).join(", ")}${criteria} mentions "${asked}". No embedding model is configured, so this was matched on words rather than meaning \u2014 something saying the same thing differently would not be found.`
|
|
65325
|
+
};
|
|
65326
|
+
}
|
|
65327
|
+
ordered = candidates;
|
|
65328
|
+
how = " matched on words, not meaning \u2014 no embedding model is configured";
|
|
65329
|
+
}
|
|
65330
|
+
if (asked.length > 0 && options.semantic !== void 0) {
|
|
65331
|
+
const vector = await options.semantic.embedder.embed(asked);
|
|
65332
|
+
const hits = await options.semantic.searcher.searchByVector(options.semantic.collection, vector, {
|
|
65333
|
+
size: Math.min(100, Math.max(limit * 4, 40))
|
|
65334
|
+
});
|
|
65335
|
+
const rank2 = /* @__PURE__ */ new Map();
|
|
65336
|
+
hits.forEach((hit, position) => {
|
|
65337
|
+
if (!rank2.has(hit.path))
|
|
65338
|
+
rank2.set(hit.path, position);
|
|
65339
|
+
});
|
|
65340
|
+
ordered = [...candidates].sort((a, b) => {
|
|
65341
|
+
const left = rank2.get(`data:${a.datasetId}:${a.record.id}`);
|
|
65342
|
+
const right = rank2.get(`data:${b.datasetId}:${b.record.id}`);
|
|
65343
|
+
if (left !== void 0 && right !== void 0)
|
|
65344
|
+
return left - right;
|
|
65345
|
+
if (left !== void 0)
|
|
65346
|
+
return -1;
|
|
65347
|
+
if (right !== void 0)
|
|
65348
|
+
return 1;
|
|
65349
|
+
return (b.record.timestamp ?? 0) - (a.record.timestamp ?? 0);
|
|
65350
|
+
});
|
|
65351
|
+
how = " ranked by meaning";
|
|
65352
|
+
}
|
|
65353
|
+
const shown = ordered.slice(0, limit);
|
|
65354
|
+
return {
|
|
65355
|
+
content: [
|
|
65356
|
+
`${String(candidates.length)} record(s) in ${wanted.map((entry) => entry.name).join(", ")}${criteria}${how}${candidates.length > shown.length ? `, showing ${String(shown.length)}` : ""}:`,
|
|
65357
|
+
"",
|
|
65358
|
+
...shown.map((entry) => describe4(entry.record, entry.dataset)),
|
|
65359
|
+
"",
|
|
65360
|
+
"This is what has been synced, not a live query against the source. If the answer depends on something very recent, say when the dataset was last synced rather than implying it is current."
|
|
65361
|
+
].join("\n")
|
|
65362
|
+
};
|
|
65363
|
+
} catch (error51) {
|
|
65364
|
+
return { content: error51 instanceof Error ? error51.message : String(error51), isError: true };
|
|
65365
|
+
}
|
|
65366
|
+
}
|
|
65367
|
+
};
|
|
65368
|
+
}
|
|
65369
|
+
|
|
64614
65370
|
// src/sharedConfig.ts
|
|
64615
65371
|
var EMPTY = { variables: [], adminIds: [], profiles: [] };
|
|
64616
65372
|
var SharedConfigStore = class {
|
|
@@ -64622,7 +65378,7 @@ var SharedConfigStore = class {
|
|
|
64622
65378
|
async load() {
|
|
64623
65379
|
if (this.cache !== void 0) return this.cache;
|
|
64624
65380
|
try {
|
|
64625
|
-
const raw = JSON.parse(await
|
|
65381
|
+
const raw = JSON.parse(await fs20.readFile(this.filePath, "utf8"));
|
|
64626
65382
|
const variables = sessionVariablesSchema.safeParse(raw["variables"]);
|
|
64627
65383
|
const adminIds = Array.isArray(raw["adminIds"]) ? raw["adminIds"].filter((id) => typeof id === "string") : [];
|
|
64628
65384
|
const profiles = external_exports.array(providerProfileSchema).safeParse(raw["profiles"]);
|
|
@@ -64643,21 +65399,21 @@ var SharedConfigStore = class {
|
|
|
64643
65399
|
async save(next) {
|
|
64644
65400
|
const current = await this.load();
|
|
64645
65401
|
const merged = { ...current, ...next };
|
|
64646
|
-
await
|
|
65402
|
+
await fs20.mkdir(path27.dirname(this.filePath), { recursive: true });
|
|
64647
65403
|
const temporary = `${this.filePath}.tmp`;
|
|
64648
|
-
await
|
|
64649
|
-
await
|
|
65404
|
+
await fs20.writeFile(temporary, JSON.stringify(merged, null, 2), { encoding: "utf8", mode: 384 });
|
|
65405
|
+
await fs20.rename(temporary, this.filePath);
|
|
64650
65406
|
this.cache = merged;
|
|
64651
65407
|
return merged;
|
|
64652
65408
|
}
|
|
64653
65409
|
};
|
|
64654
65410
|
|
|
64655
65411
|
// src/server.ts
|
|
64656
|
-
import
|
|
65412
|
+
import fs25 from "node:fs/promises";
|
|
64657
65413
|
import {
|
|
64658
65414
|
createServer
|
|
64659
65415
|
} from "node:http";
|
|
64660
|
-
import
|
|
65416
|
+
import path32 from "node:path";
|
|
64661
65417
|
|
|
64662
65418
|
// src/identity.ts
|
|
64663
65419
|
import crypto5 from "node:crypto";
|
|
@@ -64669,13 +65425,36 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
64669
65425
|
/**
|
|
64670
65426
|
* Single-use and short-lived, because it travels in the launch URL's fragment where it
|
|
64671
65427
|
* can end up in shell history or a terminal scrollback (§14).
|
|
65428
|
+
*
|
|
65429
|
+
* Ten seconds is right when the browser opens itself, and far too short when a person has to
|
|
65430
|
+
* move the URL by hand — into another application, a remote session, a phone. `--handoff-seconds`
|
|
65431
|
+
* raises it, and what that costs is stated where it is set: a longer window is a longer time in
|
|
65432
|
+
* which somebody reading that scrollback can use it before you do.
|
|
64672
65433
|
*/
|
|
64673
65434
|
handoffToken = crypto5.randomBytes(32).toString("base64url");
|
|
64674
|
-
handoffExpiresAt
|
|
65435
|
+
handoffExpiresAt;
|
|
65436
|
+
handoffSeconds;
|
|
65437
|
+
constructor(handoffSeconds = 10) {
|
|
65438
|
+
this.handoffSeconds = handoffSeconds;
|
|
65439
|
+
this.handoffExpiresAt = Date.now() + handoffSeconds * 1e3;
|
|
65440
|
+
}
|
|
64675
65441
|
get launchToken() {
|
|
64676
65442
|
if (this.handoffToken === void 0) throw new Error("handoff token already consumed");
|
|
64677
65443
|
return this.handoffToken;
|
|
64678
65444
|
}
|
|
65445
|
+
/**
|
|
65446
|
+
* Mints a fresh handoff token, replacing any outstanding one.
|
|
65447
|
+
*
|
|
65448
|
+
* For the case the old design had no answer to: the token expired unused, and the only way back
|
|
65449
|
+
* was to stop the server and start it again — losing the session, the conversation and anything
|
|
65450
|
+
* running. A new token grants exactly what the first one did, to whoever can read the terminal,
|
|
65451
|
+
* which is the same person it was printed to in the first place.
|
|
65452
|
+
*/
|
|
65453
|
+
remintHandoff() {
|
|
65454
|
+
this.handoffToken = crypto5.randomBytes(32).toString("base64url");
|
|
65455
|
+
this.handoffExpiresAt = Date.now() + this.handoffSeconds * 1e3;
|
|
65456
|
+
return this.handoffToken;
|
|
65457
|
+
}
|
|
64679
65458
|
/**
|
|
64680
65459
|
* Exchanges the handoff token for the session token, once.
|
|
64681
65460
|
*
|
|
@@ -64683,11 +65462,23 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
64683
65462
|
* or an attack, and in both cases the right answer is that this token is now spent.
|
|
64684
65463
|
*/
|
|
64685
65464
|
redeemHandoff(presented) {
|
|
65465
|
+
return this.redeem(presented).token;
|
|
65466
|
+
}
|
|
65467
|
+
/**
|
|
65468
|
+
* The same exchange, saying *why* it failed.
|
|
65469
|
+
*
|
|
65470
|
+
* The reasons need different handling and only one of them is anybody's fault. An expired token
|
|
65471
|
+
* is an ordinary mishap — the browser was slow, the URL was pasted late — and the right response
|
|
65472
|
+
* is to offer another. A token that does not match is either a bug or an attack, and the right
|
|
65473
|
+
* response there is nothing at all.
|
|
65474
|
+
*/
|
|
65475
|
+
redeem(presented) {
|
|
64686
65476
|
const expected = this.handoffToken;
|
|
64687
65477
|
const expiresAt = this.handoffExpiresAt;
|
|
64688
65478
|
this.handoffToken = void 0;
|
|
64689
|
-
if (expected === void 0
|
|
64690
|
-
|
|
65479
|
+
if (expected === void 0) return { reason: "spent" };
|
|
65480
|
+
if (Date.now() > expiresAt) return { reason: "expired" };
|
|
65481
|
+
return timingSafeEquals(presented, expected) ? { token: this.sessionToken } : { reason: "mismatch" };
|
|
64691
65482
|
}
|
|
64692
65483
|
async authenticate(request) {
|
|
64693
65484
|
const header = request.headers.authorization;
|
|
@@ -64770,8 +65561,8 @@ async function readJsonBody(request, maxBytes = 32 * 1024 * 1024) {
|
|
|
64770
65561
|
}
|
|
64771
65562
|
|
|
64772
65563
|
// src/fileSecretStore.ts
|
|
64773
|
-
import
|
|
64774
|
-
import
|
|
65564
|
+
import fs21 from "node:fs/promises";
|
|
65565
|
+
import path28 from "node:path";
|
|
64775
65566
|
var FileSecretStore = class {
|
|
64776
65567
|
constructor(filePath) {
|
|
64777
65568
|
this.filePath = filePath;
|
|
@@ -64783,7 +65574,7 @@ var FileSecretStore = class {
|
|
|
64783
65574
|
async load() {
|
|
64784
65575
|
if (this.cache !== void 0) return this.cache;
|
|
64785
65576
|
try {
|
|
64786
|
-
const raw = await
|
|
65577
|
+
const raw = await fs21.readFile(this.filePath, "utf8");
|
|
64787
65578
|
const parsed = JSON.parse(raw);
|
|
64788
65579
|
this.cache = typeof parsed === "object" && parsed !== null ? parsed : {};
|
|
64789
65580
|
} catch {
|
|
@@ -64795,10 +65586,10 @@ var FileSecretStore = class {
|
|
|
64795
65586
|
this.queue = this.queue.then(async () => {
|
|
64796
65587
|
const secrets = await this.load();
|
|
64797
65588
|
mutate(secrets);
|
|
64798
|
-
await
|
|
65589
|
+
await fs21.mkdir(path28.dirname(this.filePath), { recursive: true });
|
|
64799
65590
|
const temp = `${this.filePath}.${process.pid}.tmp`;
|
|
64800
|
-
await
|
|
64801
|
-
await
|
|
65591
|
+
await fs21.writeFile(temp, JSON.stringify(secrets, null, 2), { encoding: "utf8", mode: 384 });
|
|
65592
|
+
await fs21.rename(temp, this.filePath);
|
|
64802
65593
|
});
|
|
64803
65594
|
return this.queue;
|
|
64804
65595
|
}
|
|
@@ -64829,8 +65620,8 @@ var FileSecretStore = class {
|
|
|
64829
65620
|
|
|
64830
65621
|
// src/reviewQueue.ts
|
|
64831
65622
|
import crypto6 from "node:crypto";
|
|
64832
|
-
import
|
|
64833
|
-
import
|
|
65623
|
+
import fs22 from "node:fs/promises";
|
|
65624
|
+
import path29 from "node:path";
|
|
64834
65625
|
var ReviewQueue = class {
|
|
64835
65626
|
constructor(filePath) {
|
|
64836
65627
|
this.filePath = filePath;
|
|
@@ -64840,7 +65631,7 @@ var ReviewQueue = class {
|
|
|
64840
65631
|
async load() {
|
|
64841
65632
|
if (this.cache !== void 0) return this.cache;
|
|
64842
65633
|
try {
|
|
64843
|
-
const parsed = JSON.parse(await
|
|
65634
|
+
const parsed = JSON.parse(await fs22.readFile(this.filePath, "utf8"));
|
|
64844
65635
|
this.cache = Array.isArray(parsed) ? parsed : [];
|
|
64845
65636
|
} catch {
|
|
64846
65637
|
this.cache = [];
|
|
@@ -64849,10 +65640,10 @@ var ReviewQueue = class {
|
|
|
64849
65640
|
}
|
|
64850
65641
|
async persist(items) {
|
|
64851
65642
|
this.cache = items;
|
|
64852
|
-
await
|
|
65643
|
+
await fs22.mkdir(path29.dirname(this.filePath), { recursive: true });
|
|
64853
65644
|
const temporary = `${this.filePath}.tmp`;
|
|
64854
|
-
await
|
|
64855
|
-
await
|
|
65645
|
+
await fs22.writeFile(temporary, JSON.stringify(items, null, 2), { encoding: "utf8", mode: 384 });
|
|
65646
|
+
await fs22.rename(temporary, this.filePath);
|
|
64856
65647
|
}
|
|
64857
65648
|
async list() {
|
|
64858
65649
|
return [...await this.load()];
|
|
@@ -65007,9 +65798,9 @@ var RoutedSecretStore = class {
|
|
|
65007
65798
|
};
|
|
65008
65799
|
|
|
65009
65800
|
// src/userVariables.ts
|
|
65010
|
-
import
|
|
65801
|
+
import fs23 from "node:fs/promises";
|
|
65011
65802
|
import { readFileSync } from "node:fs";
|
|
65012
|
-
import
|
|
65803
|
+
import path30 from "node:path";
|
|
65013
65804
|
var UserVariableStore = class {
|
|
65014
65805
|
constructor(filePath) {
|
|
65015
65806
|
this.filePath = filePath;
|
|
@@ -65024,21 +65815,21 @@ var UserVariableStore = class {
|
|
|
65024
65815
|
}
|
|
65025
65816
|
async save(variables) {
|
|
65026
65817
|
const parsed = sessionVariablesSchema.parse(variables);
|
|
65027
|
-
await
|
|
65818
|
+
await fs23.mkdir(path30.dirname(this.filePath), { recursive: true });
|
|
65028
65819
|
const temporary = `${this.filePath}.tmp`;
|
|
65029
|
-
await
|
|
65820
|
+
await fs23.writeFile(temporary, JSON.stringify({ variables: parsed }, null, 2), {
|
|
65030
65821
|
encoding: "utf8",
|
|
65031
65822
|
mode: 384
|
|
65032
65823
|
});
|
|
65033
|
-
await
|
|
65824
|
+
await fs23.rename(temporary, this.filePath);
|
|
65034
65825
|
return parsed;
|
|
65035
65826
|
}
|
|
65036
65827
|
};
|
|
65037
65828
|
function userVariableStoreFor(dataDir, principal) {
|
|
65038
|
-
return new UserVariableStore(userVariablesPath(
|
|
65829
|
+
return new UserVariableStore(userVariablesPath(path30.join(dataDir, "users", storageKeyFor(principal))));
|
|
65039
65830
|
}
|
|
65040
65831
|
function userVariablesPath(userDir) {
|
|
65041
|
-
return
|
|
65832
|
+
return path30.join(userDir, "variables.json");
|
|
65042
65833
|
}
|
|
65043
65834
|
function readVariablesFile(filePath) {
|
|
65044
65835
|
try {
|
|
@@ -65052,8 +65843,8 @@ function readVariablesFile(filePath) {
|
|
|
65052
65843
|
|
|
65053
65844
|
// src/session.ts
|
|
65054
65845
|
import { watch as fsWatch } from "node:fs";
|
|
65055
|
-
import
|
|
65056
|
-
import
|
|
65846
|
+
import fs24 from "node:fs/promises";
|
|
65847
|
+
import path31 from "node:path";
|
|
65057
65848
|
var FileConfigStore = class {
|
|
65058
65849
|
constructor(userConfigPath, workspaceRoot) {
|
|
65059
65850
|
this.userConfigPath = userConfigPath;
|
|
@@ -65069,7 +65860,7 @@ var FileConfigStore = class {
|
|
|
65069
65860
|
const filePath = this.pathFor(scope);
|
|
65070
65861
|
if (filePath === void 0) return void 0;
|
|
65071
65862
|
try {
|
|
65072
|
-
return await
|
|
65863
|
+
return await fs24.readFile(filePath, "utf8");
|
|
65073
65864
|
} catch (error51) {
|
|
65074
65865
|
if (error51.code === "ENOENT") return void 0;
|
|
65075
65866
|
throw error51;
|
|
@@ -65079,14 +65870,14 @@ var FileConfigStore = class {
|
|
|
65079
65870
|
async write(scope, contents) {
|
|
65080
65871
|
const filePath = this.pathFor(scope);
|
|
65081
65872
|
if (filePath === void 0) throw new Error(`Cannot write ${scope} config: no workspace is open`);
|
|
65082
|
-
await
|
|
65873
|
+
await fs24.mkdir(path31.dirname(filePath), { recursive: true });
|
|
65083
65874
|
const temporary = `${filePath}.${process.pid.toString(36)}.tmp`;
|
|
65084
|
-
await
|
|
65085
|
-
await
|
|
65875
|
+
await fs24.writeFile(temporary, contents, { encoding: "utf8", mode: 384 });
|
|
65876
|
+
await fs24.rename(temporary, filePath);
|
|
65086
65877
|
try {
|
|
65087
65878
|
const backupTemp = `${configBackupPath(filePath)}.tmp`;
|
|
65088
|
-
await
|
|
65089
|
-
await
|
|
65879
|
+
await fs24.writeFile(backupTemp, contents, { encoding: "utf8", mode: 384 });
|
|
65880
|
+
await fs24.rename(backupTemp, configBackupPath(filePath));
|
|
65090
65881
|
} catch {
|
|
65091
65882
|
}
|
|
65092
65883
|
}
|
|
@@ -65094,7 +65885,7 @@ var FileConfigStore = class {
|
|
|
65094
65885
|
const filePath = this.pathFor(scope);
|
|
65095
65886
|
if (filePath === void 0) return void 0;
|
|
65096
65887
|
try {
|
|
65097
|
-
return await
|
|
65888
|
+
return await fs24.readFile(configBackupPath(filePath), "utf8");
|
|
65098
65889
|
} catch {
|
|
65099
65890
|
return void 0;
|
|
65100
65891
|
}
|
|
@@ -65104,7 +65895,7 @@ var FileConfigStore = class {
|
|
|
65104
65895
|
if (filePath === void 0) return void 0;
|
|
65105
65896
|
const target = `${filePath}.corrupt-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
|
|
65106
65897
|
try {
|
|
65107
|
-
await
|
|
65898
|
+
await fs24.rename(filePath, target);
|
|
65108
65899
|
return target;
|
|
65109
65900
|
} catch {
|
|
65110
65901
|
return void 0;
|
|
@@ -65116,8 +65907,8 @@ var FileConfigStore = class {
|
|
|
65116
65907
|
};
|
|
65117
65908
|
let watcher;
|
|
65118
65909
|
try {
|
|
65119
|
-
watcher = fsWatch(
|
|
65120
|
-
if (filename ===
|
|
65910
|
+
watcher = fsWatch(path31.dirname(filePath), (_event, filename) => {
|
|
65911
|
+
if (filename === path31.basename(filePath)) onChange();
|
|
65121
65912
|
});
|
|
65122
65913
|
} catch {
|
|
65123
65914
|
}
|
|
@@ -65132,7 +65923,7 @@ var FileWorkspaceState = class {
|
|
|
65132
65923
|
values = {};
|
|
65133
65924
|
async load() {
|
|
65134
65925
|
try {
|
|
65135
|
-
const parsed = JSON.parse(await
|
|
65926
|
+
const parsed = JSON.parse(await fs24.readFile(this.filePath, "utf8"));
|
|
65136
65927
|
if (typeof parsed === "object" && parsed !== null) this.values = parsed;
|
|
65137
65928
|
} catch {
|
|
65138
65929
|
this.values = {};
|
|
@@ -65144,8 +65935,8 @@ var FileWorkspaceState = class {
|
|
|
65144
65935
|
async set(key, value) {
|
|
65145
65936
|
if (value === void 0) delete this.values[key];
|
|
65146
65937
|
else this.values[key] = value;
|
|
65147
|
-
await
|
|
65148
|
-
await
|
|
65938
|
+
await fs24.mkdir(path31.dirname(this.filePath), { recursive: true });
|
|
65939
|
+
await fs24.writeFile(this.filePath, JSON.stringify(this.values, null, 2), { encoding: "utf8", mode: 384 });
|
|
65149
65940
|
}
|
|
65150
65941
|
};
|
|
65151
65942
|
function createBrowserUi(workspaceRoot, post) {
|
|
@@ -65183,7 +65974,7 @@ function createBrowserUi(workspaceRoot, post) {
|
|
|
65183
65974
|
*/
|
|
65184
65975
|
openFile: async (filePath) => {
|
|
65185
65976
|
try {
|
|
65186
|
-
post([`[info] ${
|
|
65977
|
+
post([`[info] ${path31.basename(filePath)}`, "", await fs24.readFile(filePath, "utf8")].join("\n"));
|
|
65187
65978
|
} catch (error51) {
|
|
65188
65979
|
post(`[warning] Could not read ${filePath}: ${String(error51)}`);
|
|
65189
65980
|
}
|
|
@@ -65201,14 +65992,14 @@ function createBrowserUi(workspaceRoot, post) {
|
|
|
65201
65992
|
if (found.length >= limit || depth > 12) return;
|
|
65202
65993
|
let entries;
|
|
65203
65994
|
try {
|
|
65204
|
-
entries = await
|
|
65995
|
+
entries = await fs24.readdir(dir, { withFileTypes: true });
|
|
65205
65996
|
} catch {
|
|
65206
65997
|
return;
|
|
65207
65998
|
}
|
|
65208
65999
|
for (const entry of entries) {
|
|
65209
66000
|
if (found.length >= limit) return;
|
|
65210
66001
|
if (entry.name.startsWith(".") && entry.name !== ".env") continue;
|
|
65211
|
-
const full =
|
|
66002
|
+
const full = path31.join(dir, entry.name);
|
|
65212
66003
|
if (entry.isDirectory()) {
|
|
65213
66004
|
if (!skip.has(entry.name)) await walk(full, depth + 1);
|
|
65214
66005
|
} else if (needle.length === 0 || entry.name.toLowerCase().includes(needle)) {
|
|
@@ -65222,11 +66013,11 @@ function createBrowserUi(workspaceRoot, post) {
|
|
|
65222
66013
|
};
|
|
65223
66014
|
}
|
|
65224
66015
|
async function createSession(options) {
|
|
65225
|
-
const userDir =
|
|
65226
|
-
await
|
|
66016
|
+
const userDir = path31.join(options.dataDir, "users", storageKeyFor(options.principal));
|
|
66017
|
+
await fs24.mkdir(userDir, { recursive: true, mode: 448 });
|
|
65227
66018
|
const variableStore = new UserVariableStore(userVariablesPath(userDir));
|
|
65228
66019
|
const userVariables = () => variableStore.read();
|
|
65229
|
-
const workspaceState = new FileWorkspaceState(
|
|
66020
|
+
const workspaceState = new FileWorkspaceState(path31.join(userDir, "workspace-state.json"));
|
|
65230
66021
|
await workspaceState.load();
|
|
65231
66022
|
const services = {
|
|
65232
66023
|
transport: options.transport,
|
|
@@ -65234,9 +66025,9 @@ async function createSession(options) {
|
|
|
65234
66025
|
* A shared profile's API key belongs to the administrator and lives beside the shared config;
|
|
65235
66026
|
* everything else is this user's. Routed by the reference, which is all a secret store gets.
|
|
65236
66027
|
*/
|
|
65237
|
-
secrets: options.sharedSecrets === void 0 ? new FileSecretStore(
|
|
65238
|
-
configStore: options.sharedProfiles === void 0 ? new FileConfigStore(
|
|
65239
|
-
new FileConfigStore(
|
|
66028
|
+
secrets: options.sharedSecrets === void 0 ? new FileSecretStore(path31.join(userDir, "secrets.json")) : new RoutedSecretStore(new FileSecretStore(path31.join(userDir, "secrets.json")), options.sharedSecrets),
|
|
66029
|
+
configStore: options.sharedProfiles === void 0 ? new FileConfigStore(path31.join(userDir, "config.json"), options.workspaceRoot) : new SharedProfileConfigStore(
|
|
66030
|
+
new FileConfigStore(path31.join(userDir, "config.json"), options.workspaceRoot),
|
|
65240
66031
|
options.sharedProfiles
|
|
65241
66032
|
),
|
|
65242
66033
|
workspaceState,
|
|
@@ -65321,11 +66112,11 @@ var CONTENT_TYPES = {
|
|
|
65321
66112
|
async function startServer(options) {
|
|
65322
66113
|
const log = options.logSink ?? ((line) => process.stderr.write(`${line}
|
|
65323
66114
|
`));
|
|
65324
|
-
const identity = options.identity ?? new SingleUserIdentity();
|
|
66115
|
+
const identity = options.identity ?? new SingleUserIdentity(options.handoffSeconds);
|
|
65325
66116
|
const roles = options.roles ?? SINGLE_USER_POLICY;
|
|
65326
66117
|
const sharedStore = options.sharedConfig;
|
|
65327
|
-
const sharedSecretStore = new FileSecretStore(
|
|
65328
|
-
const reviews = new ReviewQueue(
|
|
66118
|
+
const sharedSecretStore = new FileSecretStore(path32.join(options.dataDir, "shared-secrets.json"));
|
|
66119
|
+
const reviews = new ReviewQueue(path32.join(options.dataDir, "reviews.json"));
|
|
65329
66120
|
let sharedCache = { variables: [], adminIds: [], profiles: [] };
|
|
65330
66121
|
const bindAddress = options.bindAddress ?? "127.0.0.1";
|
|
65331
66122
|
if (sharedStore !== void 0) sharedCache = await sharedStore.load();
|
|
@@ -65438,12 +66229,16 @@ async function startServer(options) {
|
|
|
65438
66229
|
}
|
|
65439
66230
|
const body = await readJsonBody(request);
|
|
65440
66231
|
const handoff = typeof body?.handoff === "string" ? body.handoff : "";
|
|
65441
|
-
const
|
|
65442
|
-
if (token === void 0) {
|
|
65443
|
-
|
|
66232
|
+
const outcome = identity.redeem(handoff);
|
|
66233
|
+
if (outcome.token === void 0) {
|
|
66234
|
+
if (outcome.reason === "expired" || outcome.reason === "spent") options.onHandoffLapsed?.(outcome.reason);
|
|
66235
|
+
reject(response, {
|
|
66236
|
+
status: 401,
|
|
66237
|
+
reason: outcome.reason === "expired" ? "That link expired. A fresh one has been printed in the terminal running light-code." : outcome.reason === "spent" ? "That link has already been used. A fresh one has been printed in the terminal." : "Handoff token invalid."
|
|
66238
|
+
});
|
|
65444
66239
|
return;
|
|
65445
66240
|
}
|
|
65446
|
-
respondJson(response, 200, { token });
|
|
66241
|
+
respondJson(response, 200, { token: outcome.token });
|
|
65447
66242
|
return;
|
|
65448
66243
|
}
|
|
65449
66244
|
const principal = await identity.authenticate(request);
|
|
@@ -65536,14 +66331,14 @@ async function startServer(options) {
|
|
|
65536
66331
|
if (options.workspaceRoot === void 0) return "No workspace is open, so there is nowhere to write it.";
|
|
65537
66332
|
try {
|
|
65538
66333
|
if (item.kind === "skill") {
|
|
65539
|
-
const dir2 =
|
|
65540
|
-
await
|
|
65541
|
-
await
|
|
66334
|
+
const dir2 = path32.join(options.workspaceRoot, ".lightcode", "skills");
|
|
66335
|
+
await fs25.mkdir(dir2, { recursive: true });
|
|
66336
|
+
await fs25.writeFile(path32.join(dir2, `${item.name}.md`), item.content, "utf8");
|
|
65542
66337
|
return void 0;
|
|
65543
66338
|
}
|
|
65544
|
-
const dir =
|
|
65545
|
-
await
|
|
65546
|
-
await
|
|
66339
|
+
const dir = path32.join(options.workspaceRoot, ".lightcode", "tools");
|
|
66340
|
+
await fs25.mkdir(dir, { recursive: true });
|
|
66341
|
+
await fs25.writeFile(path32.join(dir, `${item.name}.py`), item.content, "utf8");
|
|
65547
66342
|
return void 0;
|
|
65548
66343
|
} catch (error51) {
|
|
65549
66344
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -65644,9 +66439,9 @@ async function startServer(options) {
|
|
|
65644
66439
|
return;
|
|
65645
66440
|
}
|
|
65646
66441
|
try {
|
|
65647
|
-
const body = await
|
|
66442
|
+
const body = await fs25.readFile(path32.join(options.clientDir, asset));
|
|
65648
66443
|
response.writeHead(200, {
|
|
65649
|
-
"Content-Type": CONTENT_TYPES[
|
|
66444
|
+
"Content-Type": CONTENT_TYPES[path32.extname(asset)] ?? "application/octet-stream",
|
|
65650
66445
|
...securityHeaders()
|
|
65651
66446
|
});
|
|
65652
66447
|
response.end(body);
|
|
@@ -65662,6 +66457,7 @@ async function startServer(options) {
|
|
|
65662
66457
|
return {
|
|
65663
66458
|
url: `http://${authority}`,
|
|
65664
66459
|
launchToken: identity instanceof SingleUserIdentity ? identity.launchToken : void 0,
|
|
66460
|
+
newLaunchUrl: identity instanceof SingleUserIdentity ? () => `http://${authority}/#t=${identity.remintHandoff()}` : void 0,
|
|
65665
66461
|
close: () => new Promise((resolve) => {
|
|
65666
66462
|
for (const connection of connections.values()) connection.dispose();
|
|
65667
66463
|
connections.clear();
|
|
@@ -65688,8 +66484,8 @@ async function main() {
|
|
|
65688
66484
|
process.stdout.write("\n");
|
|
65689
66485
|
return;
|
|
65690
66486
|
}
|
|
65691
|
-
const file2 =
|
|
65692
|
-
await
|
|
66487
|
+
const file2 = path33.join(os3.tmpdir(), "light-code-guide.html");
|
|
66488
|
+
await fs26.writeFile(file2, guidePage(OPERATOR_GUIDE), "utf8");
|
|
65693
66489
|
process.stdout.write(`Opening the guide: ${file2}
|
|
65694
66490
|
(--guide --no-open prints it instead.)
|
|
65695
66491
|
`);
|
|
@@ -65722,9 +66518,13 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
|
|
|
65722
66518
|
const adminIds = valuesOf(args, "--admin-id");
|
|
65723
66519
|
const trustedProxies = valuesOf(args, "--trust-proxy");
|
|
65724
66520
|
const userHeader = valueOf(args, "--user-header");
|
|
65725
|
-
const workspaceRoot =
|
|
66521
|
+
const workspaceRoot = path33.resolve(valueOf(args, "--workspace") ?? process.cwd());
|
|
65726
66522
|
const dataDir = valueOf(args, "--data-dir") ?? envPaths("light-code", { suffix: "" }).data;
|
|
65727
66523
|
const port = Number.parseInt(valueOf(args, "--port") ?? "0", 10);
|
|
66524
|
+
const handoffSeconds = Math.min(
|
|
66525
|
+
600,
|
|
66526
|
+
Math.max(1, Number.parseInt(valueOf(args, "--handoff-seconds") ?? "10", 10) || 10)
|
|
66527
|
+
);
|
|
65728
66528
|
const bindAddress = valueOf(args, "--bind");
|
|
65729
66529
|
const noOpen = args.includes("--no-open") || serverMode;
|
|
65730
66530
|
let identity;
|
|
@@ -65746,18 +66546,41 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
|
|
|
65746
66546
|
...userHeader !== void 0 ? { userHeader } : {}
|
|
65747
66547
|
});
|
|
65748
66548
|
}
|
|
65749
|
-
const sharedConfig = new SharedConfigStore(
|
|
66549
|
+
const sharedConfig = new SharedConfigStore(path33.join(dataDir, "shared.json"));
|
|
65750
66550
|
const shared = await sharedConfig.load();
|
|
65751
66551
|
const effectiveAdminIds = [.../* @__PURE__ */ new Set([...shared.adminIds, ...adminIds])];
|
|
65752
66552
|
if (adminIds.length > 0 && effectiveAdminIds.length !== shared.adminIds.length) {
|
|
65753
66553
|
await sharedConfig.save({ adminIds: effectiveAdminIds });
|
|
65754
66554
|
}
|
|
65755
|
-
const here =
|
|
66555
|
+
const here = path33.dirname(fileURLToPath(import.meta.url));
|
|
65756
66556
|
const server = await startServer({
|
|
65757
66557
|
workspaceRoot,
|
|
65758
66558
|
dataDir,
|
|
65759
|
-
clientDir:
|
|
66559
|
+
clientDir: path33.join(here, "client"),
|
|
65760
66560
|
ripgrepPath: resolveRipgrep(),
|
|
66561
|
+
handoffSeconds,
|
|
66562
|
+
/*
|
|
66563
|
+
* A lapsed link is replaced rather than ending the session.
|
|
66564
|
+
*
|
|
66565
|
+
* Before this the only way back from pasting a URL a few seconds late was to stop the server
|
|
66566
|
+
* and start it again, losing the conversation and anything running with it. The fresh link is
|
|
66567
|
+
* printed to this terminal, which is where the first one was printed, so it reaches nobody it
|
|
66568
|
+
* had not already reached.
|
|
66569
|
+
*
|
|
66570
|
+
* Printed with a sentence, because a URL appearing on its own reads as the server having
|
|
66571
|
+
* restarted itself.
|
|
66572
|
+
*/
|
|
66573
|
+
onHandoffLapsed: (reason) => {
|
|
66574
|
+
const fresh = server.newLaunchUrl?.();
|
|
66575
|
+
if (fresh === void 0) return;
|
|
66576
|
+
process.stdout.write(
|
|
66577
|
+
`
|
|
66578
|
+
That link ${reason === "expired" ? "expired" : "had already been used"}. Here is a fresh one, good for ${String(handoffSeconds)} seconds:
|
|
66579
|
+
${fresh}
|
|
66580
|
+
|
|
66581
|
+
`
|
|
66582
|
+
);
|
|
66583
|
+
},
|
|
65761
66584
|
port: Number.isNaN(port) ? 0 : port,
|
|
65762
66585
|
...serverMode ? { roles: adminListPolicy(effectiveAdminIds), sharedConfig } : {},
|
|
65763
66586
|
...identity !== void 0 ? { identity } : {},
|
|
@@ -65802,10 +66625,10 @@ Both go through your proxy. Anyone reaching /admin directly is an administrator.
|
|
|
65802
66625
|
} else {
|
|
65803
66626
|
process.stdout.write(
|
|
65804
66627
|
`Opening ${server.url}
|
|
65805
|
-
(If the browser does not open, paste this within
|
|
66628
|
+
(If the browser does not open, paste this within ${String(handoffSeconds)} seconds:)
|
|
65806
66629
|
${launchUrl}
|
|
65807
66630
|
|
|
65808
|
-
`
|
|
66631
|
+
` + (handoffSeconds === 10 ? " Not long enough? Start with --handoff-seconds 120.\n If it does lapse, a fresh link is printed here \u2014 no need to restart.\n\n" : " If it does lapse, a fresh link is printed here \u2014 no need to restart.\n\n")
|
|
65809
66632
|
);
|
|
65810
66633
|
}
|
|
65811
66634
|
if (!noOpen) openBrowser(launchUrl);
|
|
@@ -65819,6 +66642,7 @@ ${launchUrl}
|
|
|
65819
66642
|
var KNOWN_FLAGS = /* @__PURE__ */ new Set([
|
|
65820
66643
|
"--help",
|
|
65821
66644
|
"-h",
|
|
66645
|
+
"--handoff-seconds",
|
|
65822
66646
|
"--workspace",
|
|
65823
66647
|
"--port",
|
|
65824
66648
|
"--data-dir",
|
|
@@ -65869,6 +66693,10 @@ Usage: light-code [options]
|
|
|
65869
66693
|
--port <n> Port to bind (default: an unused one)
|
|
65870
66694
|
--data-dir <dir> Where config, secrets and task history live
|
|
65871
66695
|
--no-open Print the URL instead of launching a browser
|
|
66696
|
+
--handoff-seconds <n> How long the launch link stays valid (default 10, max 600).
|
|
66697
|
+
Raise it when carrying the URL by hand. It rides in the URL
|
|
66698
|
+
fragment, so a longer window is longer for anyone reading
|
|
66699
|
+
your scrollback to use it first.
|
|
65872
66700
|
--server Shared mode: configuration is read-only for everyone
|
|
65873
66701
|
except the administrators named below
|
|
65874
66702
|
--admin Open the administrator's interface (/admin) instead
|