@massa-ai/mcp-client 1.35.1 → 1.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/config-cli.js +311 -183
- package/dist/index.js +339 -276
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -26159,7 +26159,8 @@ var init_config = __esm(() => {
|
|
|
26159
26159
|
},
|
|
26160
26160
|
logging: {
|
|
26161
26161
|
level: process.env.LOG_LEVEL || fileConfig.logging?.level || "info",
|
|
26162
|
-
enableMetrics: process.env.ENABLE_METRICS === "true" || process.env.ENABLE_METRICS === undefined && !!fileConfig.logging?.enableMetrics
|
|
26162
|
+
enableMetrics: process.env.ENABLE_METRICS === "true" || process.env.ENABLE_METRICS === undefined && !!fileConfig.logging?.enableMetrics,
|
|
26163
|
+
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file || undefined
|
|
26163
26164
|
},
|
|
26164
26165
|
synapse: {
|
|
26165
26166
|
enabled: process.env.SYNAPSE_ENABLED !== "false",
|
|
@@ -26313,20 +26314,25 @@ var init_types2 = __esm(() => {
|
|
|
26313
26314
|
var init_interfaces = () => {};
|
|
26314
26315
|
|
|
26315
26316
|
// ../../packages/shared/dist/utils/logger.js
|
|
26317
|
+
import fs2 from "fs";
|
|
26318
|
+
|
|
26316
26319
|
class Logger {
|
|
26317
26320
|
_level;
|
|
26318
26321
|
_enableMetrics;
|
|
26322
|
+
_logFilePath;
|
|
26319
26323
|
_initialized = false;
|
|
26320
26324
|
constructor() {}
|
|
26321
26325
|
ensureInitialized() {
|
|
26322
26326
|
if (!this._initialized) {
|
|
26323
26327
|
try {
|
|
26324
|
-
const
|
|
26325
|
-
this._level = this.parseLogLevel(
|
|
26326
|
-
this._enableMetrics =
|
|
26328
|
+
const loggingConfig = config2.get("logging");
|
|
26329
|
+
this._level = this.parseLogLevel(loggingConfig.level);
|
|
26330
|
+
this._enableMetrics = loggingConfig.enableMetrics;
|
|
26331
|
+
this._logFilePath = loggingConfig.file;
|
|
26327
26332
|
} catch {
|
|
26328
26333
|
this._level = LogLevel.INFO;
|
|
26329
26334
|
this._enableMetrics = false;
|
|
26335
|
+
this._logFilePath = undefined;
|
|
26330
26336
|
}
|
|
26331
26337
|
this._initialized = true;
|
|
26332
26338
|
}
|
|
@@ -26339,6 +26345,10 @@ class Logger {
|
|
|
26339
26345
|
this.ensureInitialized();
|
|
26340
26346
|
return this._enableMetrics;
|
|
26341
26347
|
}
|
|
26348
|
+
get logFilePath() {
|
|
26349
|
+
this.ensureInitialized();
|
|
26350
|
+
return this._logFilePath;
|
|
26351
|
+
}
|
|
26342
26352
|
parseLogLevel(level) {
|
|
26343
26353
|
const levels = {
|
|
26344
26354
|
debug: LogLevel.DEBUG,
|
|
@@ -26358,6 +26368,13 @@ class Logger {
|
|
|
26358
26368
|
}
|
|
26359
26369
|
write(message, _level) {
|
|
26360
26370
|
console.error(message);
|
|
26371
|
+
const filePath = this.logFilePath;
|
|
26372
|
+
if (filePath) {
|
|
26373
|
+
try {
|
|
26374
|
+
fs2.appendFileSync(filePath, message + `
|
|
26375
|
+
`);
|
|
26376
|
+
} catch {}
|
|
26377
|
+
}
|
|
26361
26378
|
}
|
|
26362
26379
|
debug(message, meta3) {
|
|
26363
26380
|
if (this.shouldLog(LogLevel.DEBUG)) {
|
|
@@ -26767,7 +26784,7 @@ var init_hosts = __esm(() => {
|
|
|
26767
26784
|
});
|
|
26768
26785
|
|
|
26769
26786
|
// ../../packages/shared/dist/profile-switch/state.js
|
|
26770
|
-
import
|
|
26787
|
+
import fs3 from "fs";
|
|
26771
26788
|
import path6 from "path";
|
|
26772
26789
|
function namedError(name, message) {
|
|
26773
26790
|
const err = new InstallStateError(message);
|
|
@@ -26794,7 +26811,7 @@ function validateShape(raw2, filePath) {
|
|
|
26794
26811
|
function readInstallState(filePath) {
|
|
26795
26812
|
let text;
|
|
26796
26813
|
try {
|
|
26797
|
-
text =
|
|
26814
|
+
text = fs3.readFileSync(filePath, "utf-8");
|
|
26798
26815
|
} catch (err) {
|
|
26799
26816
|
const code = err.code;
|
|
26800
26817
|
if (code === "ENOENT")
|
|
@@ -26814,8 +26831,8 @@ function writeInstallState(filePath, state) {
|
|
|
26814
26831
|
const text = `${JSON.stringify(validated, null, 2)}
|
|
26815
26832
|
`;
|
|
26816
26833
|
try {
|
|
26817
|
-
|
|
26818
|
-
|
|
26834
|
+
fs3.mkdirSync(path6.dirname(filePath), { recursive: true });
|
|
26835
|
+
fs3.writeFileSync(filePath, text);
|
|
26819
26836
|
} catch (err) {
|
|
26820
26837
|
throw UnwritableInstallStateError(filePath, err.message);
|
|
26821
26838
|
}
|
|
@@ -26842,7 +26859,7 @@ var init_state = __esm(() => {
|
|
|
26842
26859
|
});
|
|
26843
26860
|
|
|
26844
26861
|
// ../../packages/shared/dist/profile-switch/lock.js
|
|
26845
|
-
import
|
|
26862
|
+
import fs4 from "fs";
|
|
26846
26863
|
import path7 from "path";
|
|
26847
26864
|
import os4 from "os";
|
|
26848
26865
|
import crypto3 from "crypto";
|
|
@@ -26855,7 +26872,7 @@ function namedError2(name, message) {
|
|
|
26855
26872
|
function readOwner(ownerPath) {
|
|
26856
26873
|
let raw2;
|
|
26857
26874
|
try {
|
|
26858
|
-
raw2 = JSON.parse(
|
|
26875
|
+
raw2 = JSON.parse(fs4.readFileSync(ownerPath, "utf-8"));
|
|
26859
26876
|
} catch {
|
|
26860
26877
|
return null;
|
|
26861
26878
|
}
|
|
@@ -26871,7 +26888,7 @@ function releaseIfOwned(lockDir, ownerPath, token) {
|
|
|
26871
26888
|
const owner = readOwner(ownerPath);
|
|
26872
26889
|
if (owner === null || owner.token !== token)
|
|
26873
26890
|
return;
|
|
26874
|
-
|
|
26891
|
+
fs4.rmSync(lockDir, { recursive: true, force: true });
|
|
26875
26892
|
}
|
|
26876
26893
|
function acquireLock(stateFilePath, options = {}) {
|
|
26877
26894
|
const lockDir = `${stateFilePath}.switch.lock`;
|
|
@@ -26880,11 +26897,11 @@ function acquireLock(stateFilePath, options = {}) {
|
|
|
26880
26897
|
const identity = options.identity ?? DEFAULT_IDENTITY;
|
|
26881
26898
|
const staleAfterMs = options.staleAfterMs ?? DEFAULT_STALE_AFTER_MS;
|
|
26882
26899
|
const createFresh = () => {
|
|
26883
|
-
|
|
26900
|
+
fs4.mkdirSync(lockDir);
|
|
26884
26901
|
const pid = identity.pid();
|
|
26885
26902
|
const startedAt = identity.processStart(pid);
|
|
26886
26903
|
if (startedAt == null) {
|
|
26887
|
-
|
|
26904
|
+
fs4.rmSync(lockDir, { recursive: true, force: true });
|
|
26888
26905
|
throw LockAcquireError(lockDir, "could not determine this process's start-time identity");
|
|
26889
26906
|
}
|
|
26890
26907
|
const token = crypto3.randomUUID();
|
|
@@ -26895,8 +26912,8 @@ function acquireLock(stateFilePath, options = {}) {
|
|
|
26895
26912
|
token,
|
|
26896
26913
|
timestamp: clock.now()
|
|
26897
26914
|
};
|
|
26898
|
-
|
|
26899
|
-
|
|
26915
|
+
fs4.mkdirSync(path7.dirname(ownerPath), { recursive: true });
|
|
26916
|
+
fs4.writeFileSync(ownerPath, JSON.stringify(record3));
|
|
26900
26917
|
return { lockDir, release: () => releaseIfOwned(lockDir, ownerPath, token) };
|
|
26901
26918
|
};
|
|
26902
26919
|
try {
|
|
@@ -26911,11 +26928,11 @@ function acquireLock(stateFilePath, options = {}) {
|
|
|
26911
26928
|
throw LockHeldError(lockDir);
|
|
26912
26929
|
const reclaimDir = `${lockDir}.reclaim.${owner.token}`;
|
|
26913
26930
|
try {
|
|
26914
|
-
|
|
26931
|
+
fs4.renameSync(lockDir, reclaimDir);
|
|
26915
26932
|
} catch {
|
|
26916
26933
|
throw LockHeldError(lockDir);
|
|
26917
26934
|
}
|
|
26918
|
-
|
|
26935
|
+
fs4.rmSync(reclaimDir, { recursive: true, force: true });
|
|
26919
26936
|
try {
|
|
26920
26937
|
return createFresh();
|
|
26921
26938
|
} catch {
|
|
@@ -26949,7 +26966,7 @@ var init_lock = __esm(() => {
|
|
|
26949
26966
|
});
|
|
26950
26967
|
|
|
26951
26968
|
// ../../packages/shared/dist/profile-switch/engine.js
|
|
26952
|
-
import
|
|
26969
|
+
import fs5 from "fs";
|
|
26953
26970
|
import path8 from "path";
|
|
26954
26971
|
import os5 from "os";
|
|
26955
26972
|
import crypto4 from "crypto";
|
|
@@ -26983,7 +27000,7 @@ function listProfiles(opts = {}) {
|
|
|
26983
27000
|
availableProfiles: []
|
|
26984
27001
|
};
|
|
26985
27002
|
}
|
|
26986
|
-
const installed =
|
|
27003
|
+
const installed = fs5.existsSync(layout.activeDir);
|
|
26987
27004
|
const availableProfiles = listVariantProfiles(layout);
|
|
26988
27005
|
const platform = state.platforms[host];
|
|
26989
27006
|
return {
|
|
@@ -26999,9 +27016,9 @@ function listProfiles(opts = {}) {
|
|
|
26999
27016
|
return { hosts };
|
|
27000
27017
|
}
|
|
27001
27018
|
function listVariantProfiles(layout) {
|
|
27002
|
-
if (!
|
|
27019
|
+
if (!fs5.existsSync(layout.variantsRoot))
|
|
27003
27020
|
return [];
|
|
27004
|
-
return
|
|
27021
|
+
return fs5.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
27005
27022
|
}
|
|
27006
27023
|
function matchesGlob(filename, glob) {
|
|
27007
27024
|
const starIdx = glob.indexOf("*");
|
|
@@ -27014,32 +27031,32 @@ function matchesGlob(filename, glob) {
|
|
|
27014
27031
|
function assertStateWritable(stateFilePath) {
|
|
27015
27032
|
const dir = path8.dirname(stateFilePath);
|
|
27016
27033
|
try {
|
|
27017
|
-
|
|
27034
|
+
fs5.mkdirSync(dir, { recursive: true });
|
|
27018
27035
|
} catch (err) {
|
|
27019
27036
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
27020
27037
|
}
|
|
27021
|
-
const checkPath =
|
|
27038
|
+
const checkPath = fs5.existsSync(stateFilePath) ? stateFilePath : dir;
|
|
27022
27039
|
try {
|
|
27023
|
-
|
|
27040
|
+
fs5.accessSync(checkPath, fs5.constants.W_OK);
|
|
27024
27041
|
} catch (err) {
|
|
27025
27042
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
27026
27043
|
}
|
|
27027
27044
|
}
|
|
27028
27045
|
function copyFileRouteVariant(layout, variantDir) {
|
|
27029
|
-
|
|
27046
|
+
fs5.mkdirSync(layout.activeDir, { recursive: true });
|
|
27030
27047
|
let changed = 0;
|
|
27031
|
-
for (const entry of
|
|
27048
|
+
for (const entry of fs5.readdirSync(variantDir, { withFileTypes: true })) {
|
|
27032
27049
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
27033
27050
|
continue;
|
|
27034
|
-
|
|
27051
|
+
fs5.copyFileSync(path8.join(variantDir, entry.name), path8.join(layout.activeDir, entry.name));
|
|
27035
27052
|
changed++;
|
|
27036
27053
|
}
|
|
27037
27054
|
return changed;
|
|
27038
27055
|
}
|
|
27039
27056
|
function repointOpencodeVariant(layout, variantDir) {
|
|
27040
|
-
|
|
27057
|
+
fs5.mkdirSync(layout.activeDir, { recursive: true });
|
|
27041
27058
|
let changed = 0;
|
|
27042
|
-
for (const entry of
|
|
27059
|
+
for (const entry of fs5.readdirSync(variantDir, { withFileTypes: true })) {
|
|
27043
27060
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
27044
27061
|
continue;
|
|
27045
27062
|
const dest = path8.join(layout.activeDir, entry.name);
|
|
@@ -27047,15 +27064,15 @@ function repointOpencodeVariant(layout, variantDir) {
|
|
|
27047
27064
|
let destExists = true;
|
|
27048
27065
|
let destIsSymlink = false;
|
|
27049
27066
|
try {
|
|
27050
|
-
destIsSymlink =
|
|
27067
|
+
destIsSymlink = fs5.lstatSync(dest).isSymbolicLink();
|
|
27051
27068
|
} catch {
|
|
27052
27069
|
destExists = false;
|
|
27053
27070
|
}
|
|
27054
27071
|
if (destExists && !destIsSymlink)
|
|
27055
27072
|
continue;
|
|
27056
27073
|
const tmp = `${dest}.massa-ai-switch.${crypto4.randomUUID()}`;
|
|
27057
|
-
|
|
27058
|
-
|
|
27074
|
+
fs5.symlinkSync(target, tmp);
|
|
27075
|
+
fs5.renameSync(tmp, dest);
|
|
27059
27076
|
changed++;
|
|
27060
27077
|
}
|
|
27061
27078
|
return changed;
|
|
@@ -27077,13 +27094,13 @@ function switchProfile(opts) {
|
|
|
27077
27094
|
if (fileHosts.length === 0) {
|
|
27078
27095
|
return { profile: opts.profile, dryRun, hosts: orderRows(universe, skipRows), restartRequired: false };
|
|
27079
27096
|
}
|
|
27080
|
-
const installedFileHosts = fileHosts.filter((h) =>
|
|
27097
|
+
const installedFileHosts = fileHosts.filter((h) => fs5.existsSync(h.layout.activeDir));
|
|
27081
27098
|
if (installedFileHosts.length === 0)
|
|
27082
27099
|
throw NoHostsDetectedError();
|
|
27083
27100
|
const withAvailability = fileHosts.map((h) => {
|
|
27084
|
-
const variantsRootExists =
|
|
27101
|
+
const variantsRootExists = fs5.existsSync(h.layout.variantsRoot);
|
|
27085
27102
|
const variantDir = h.layout.variantDir(opts.profile);
|
|
27086
|
-
const available = variantsRootExists &&
|
|
27103
|
+
const available = variantsRootExists && fs5.existsSync(variantDir) && fs5.statSync(variantDir).isDirectory();
|
|
27087
27104
|
return { ...h, variantsRootExists, variantDir, available };
|
|
27088
27105
|
});
|
|
27089
27106
|
if (!withAvailability.some((h) => h.available)) {
|
|
@@ -31297,8 +31314,8 @@ var init_esm4 = __esm(() => {
|
|
|
31297
31314
|
#children;
|
|
31298
31315
|
nocase;
|
|
31299
31316
|
#fs;
|
|
31300
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
31301
|
-
this.#fs = fsFromOption(
|
|
31317
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs6 = defaultFS } = {}) {
|
|
31318
|
+
this.#fs = fsFromOption(fs6);
|
|
31302
31319
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
31303
31320
|
cwd = fileURLToPath(cwd);
|
|
31304
31321
|
}
|
|
@@ -31773,8 +31790,8 @@ var init_esm4 = __esm(() => {
|
|
|
31773
31790
|
parseRootPath(dir) {
|
|
31774
31791
|
return win32.parse(dir).root.toUpperCase();
|
|
31775
31792
|
}
|
|
31776
|
-
newRoot(
|
|
31777
|
-
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
31793
|
+
newRoot(fs6) {
|
|
31794
|
+
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs6 });
|
|
31778
31795
|
}
|
|
31779
31796
|
isAbsolute(p) {
|
|
31780
31797
|
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
@@ -31790,8 +31807,8 @@ var init_esm4 = __esm(() => {
|
|
|
31790
31807
|
parseRootPath(_dir) {
|
|
31791
31808
|
return "/";
|
|
31792
31809
|
}
|
|
31793
|
-
newRoot(
|
|
31794
|
-
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
31810
|
+
newRoot(fs6) {
|
|
31811
|
+
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs6 });
|
|
31795
31812
|
}
|
|
31796
31813
|
isAbsolute(p) {
|
|
31797
31814
|
return p.startsWith("/");
|
|
@@ -33197,7 +33214,7 @@ var init_capture_policy = __esm(() => {
|
|
|
33197
33214
|
});
|
|
33198
33215
|
|
|
33199
33216
|
// ../../packages/core/dist/services/search/ignore-patterns.js
|
|
33200
|
-
import
|
|
33217
|
+
import fs6 from "fs/promises";
|
|
33201
33218
|
import path10 from "path";
|
|
33202
33219
|
function buildExtensionGlob(extensions) {
|
|
33203
33220
|
return extensions.map((ext2) => `**/*${ext2}`);
|
|
@@ -33222,7 +33239,7 @@ async function loadProjectIgnore(projectPath) {
|
|
|
33222
33239
|
ig.add(DEFAULT_IGNORES);
|
|
33223
33240
|
try {
|
|
33224
33241
|
const gitignorePath = path10.join(projectPath, ".gitignore");
|
|
33225
|
-
const gitignoreContent = await
|
|
33242
|
+
const gitignoreContent = await fs6.readFile(gitignorePath, "utf8");
|
|
33226
33243
|
const rules = gitignoreContent.split(`
|
|
33227
33244
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
33228
33245
|
ig.add(rules);
|
|
@@ -34818,15 +34835,15 @@ var require_pg_connection_string = __commonJS((exports, module) => {
|
|
|
34818
34835
|
if (config3.sslnegotiation === "direct" && config3.ssl === undefined) {
|
|
34819
34836
|
config3.ssl = true;
|
|
34820
34837
|
}
|
|
34821
|
-
const
|
|
34838
|
+
const fs7 = config3.sslcert || config3.sslkey || config3.sslrootcert ? __require("fs") : null;
|
|
34822
34839
|
if (config3.sslcert) {
|
|
34823
|
-
config3.ssl.cert =
|
|
34840
|
+
config3.ssl.cert = fs7.readFileSync(config3.sslcert).toString();
|
|
34824
34841
|
}
|
|
34825
34842
|
if (config3.sslkey) {
|
|
34826
|
-
config3.ssl.key =
|
|
34843
|
+
config3.ssl.key = fs7.readFileSync(config3.sslkey).toString();
|
|
34827
34844
|
}
|
|
34828
34845
|
if (config3.sslrootcert) {
|
|
34829
|
-
config3.ssl.ca =
|
|
34846
|
+
config3.ssl.ca = fs7.readFileSync(config3.sslrootcert).toString();
|
|
34830
34847
|
}
|
|
34831
34848
|
if (options.useLibpqCompat && config3.uselibpqcompat) {
|
|
34832
34849
|
throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");
|
|
@@ -36705,15 +36722,15 @@ var require_helper = __commonJS((exports, module) => {
|
|
|
36705
36722
|
// ../../node_modules/pgpass/lib/index.js
|
|
36706
36723
|
var require_lib = __commonJS((exports, module) => {
|
|
36707
36724
|
var path11 = __require("path");
|
|
36708
|
-
var
|
|
36725
|
+
var fs7 = __require("fs");
|
|
36709
36726
|
var helper = require_helper();
|
|
36710
36727
|
module.exports = function(connInfo, cb) {
|
|
36711
36728
|
var file2 = helper.getFileName();
|
|
36712
|
-
|
|
36729
|
+
fs7.stat(file2, function(err, stat) {
|
|
36713
36730
|
if (err || !helper.usePgPass(stat, file2)) {
|
|
36714
36731
|
return cb(undefined);
|
|
36715
36732
|
}
|
|
36716
|
-
var st =
|
|
36733
|
+
var st = fs7.createReadStream(file2);
|
|
36717
36734
|
helper.getPassword(connInfo, st, cb);
|
|
36718
36735
|
});
|
|
36719
36736
|
};
|
|
@@ -38243,6 +38260,89 @@ var init_db_connection = __esm(() => {
|
|
|
38243
38260
|
init_config();
|
|
38244
38261
|
});
|
|
38245
38262
|
|
|
38263
|
+
// ../../packages/core/dist/kernel/sanitize/credential-scrub.js
|
|
38264
|
+
function markerFor(id) {
|
|
38265
|
+
return `[REDACTED:${id}]`;
|
|
38266
|
+
}
|
|
38267
|
+
function fullMatchRule(id, pattern) {
|
|
38268
|
+
const marker = markerFor(id);
|
|
38269
|
+
return {
|
|
38270
|
+
id,
|
|
38271
|
+
replace(text) {
|
|
38272
|
+
let count = 0;
|
|
38273
|
+
const replaced = text.replace(pattern, () => {
|
|
38274
|
+
count++;
|
|
38275
|
+
return marker;
|
|
38276
|
+
});
|
|
38277
|
+
return { text: replaced, count };
|
|
38278
|
+
}
|
|
38279
|
+
};
|
|
38280
|
+
}
|
|
38281
|
+
function scrubCredentials(payloadJson) {
|
|
38282
|
+
const redactions = {};
|
|
38283
|
+
for (const id of RULE_IDS)
|
|
38284
|
+
redactions[id] = 0;
|
|
38285
|
+
let text = payloadJson;
|
|
38286
|
+
for (const rule of RULES) {
|
|
38287
|
+
const { text: next, count } = rule.replace(text);
|
|
38288
|
+
text = next;
|
|
38289
|
+
redactions[rule.id] += count;
|
|
38290
|
+
}
|
|
38291
|
+
const total = Object.values(redactions).reduce((sum, n) => sum + n, 0);
|
|
38292
|
+
return {
|
|
38293
|
+
sanitized: text,
|
|
38294
|
+
redactions,
|
|
38295
|
+
total
|
|
38296
|
+
};
|
|
38297
|
+
}
|
|
38298
|
+
var PEM_PATTERN, JWT_PATTERN, AWS_KEY_PATTERN, SK_KEY_PATTERN, GITHUB_TOKEN_PATTERN, SLACK_TOKEN_PATTERN, BEARER_PATTERN, RULES, RULE_IDS;
|
|
38299
|
+
var init_credential_scrub = __esm(() => {
|
|
38300
|
+
PEM_PATTERN = /-----BEGIN [A-Z ]{0,32}PRIVATE KEY-----[\s\S]{0,8192}?-----END [A-Z ]{0,32}PRIVATE KEY-----/g;
|
|
38301
|
+
JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
|
|
38302
|
+
AWS_KEY_PATTERN = /\b(?:AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16}\b/g;
|
|
38303
|
+
SK_KEY_PATTERN = /\bsk-[A-Za-z0-9_-]{20,}\b/g;
|
|
38304
|
+
GITHUB_TOKEN_PATTERN = /\bgh[pousr]_[A-Za-z0-9]{36,}\b|\bgithub_pat_[A-Za-z0-9_]{22,}\b/g;
|
|
38305
|
+
SLACK_TOKEN_PATTERN = /\bxox[baprs]-[A-Za-z0-9-]{18,}\b/g;
|
|
38306
|
+
BEARER_PATTERN = /(Bearer\s+)([A-Za-z0-9._~+/=-]{20,})/g;
|
|
38307
|
+
RULES = [
|
|
38308
|
+
fullMatchRule("pem", PEM_PATTERN),
|
|
38309
|
+
fullMatchRule("jwt", JWT_PATTERN),
|
|
38310
|
+
fullMatchRule("aws-key", AWS_KEY_PATTERN),
|
|
38311
|
+
fullMatchRule("sk-key", SK_KEY_PATTERN),
|
|
38312
|
+
fullMatchRule("github-token", GITHUB_TOKEN_PATTERN),
|
|
38313
|
+
fullMatchRule("slack-token", SLACK_TOKEN_PATTERN),
|
|
38314
|
+
{
|
|
38315
|
+
id: "bearer",
|
|
38316
|
+
replace(text) {
|
|
38317
|
+
let count = 0;
|
|
38318
|
+
const replaced = text.replace(BEARER_PATTERN, (_m, prefix) => {
|
|
38319
|
+
count++;
|
|
38320
|
+
return `${prefix}${markerFor("bearer")}`;
|
|
38321
|
+
});
|
|
38322
|
+
return { text: replaced, count };
|
|
38323
|
+
}
|
|
38324
|
+
}
|
|
38325
|
+
];
|
|
38326
|
+
RULE_IDS = RULES.map((r) => r.id);
|
|
38327
|
+
});
|
|
38328
|
+
|
|
38329
|
+
// ../../packages/core/dist/kernel/sanitize/safe-error-summary.js
|
|
38330
|
+
function safeErrorSummary(error51) {
|
|
38331
|
+
if (error51 instanceof Error) {
|
|
38332
|
+
return {
|
|
38333
|
+
name: error51.name,
|
|
38334
|
+
message: scrubCredentials(error51.message).sanitized
|
|
38335
|
+
};
|
|
38336
|
+
}
|
|
38337
|
+
return {
|
|
38338
|
+
name: "UnknownError",
|
|
38339
|
+
message: scrubCredentials(String(error51)).sanitized
|
|
38340
|
+
};
|
|
38341
|
+
}
|
|
38342
|
+
var init_safe_error_summary = __esm(() => {
|
|
38343
|
+
init_credential_scrub();
|
|
38344
|
+
});
|
|
38345
|
+
|
|
38246
38346
|
// ../../packages/core/dist/kernel/alias-resolver.js
|
|
38247
38347
|
class ProjectIdentityAliasResolver {
|
|
38248
38348
|
ttlMs;
|
|
@@ -38268,9 +38368,7 @@ class ProjectIdentityAliasResolver {
|
|
|
38268
38368
|
this.cache.set(projectId, { canonical, expiresAt: this.now() + this.ttlMs });
|
|
38269
38369
|
return canonical;
|
|
38270
38370
|
} catch (error51) {
|
|
38271
|
-
logger.warn("[project-identity] alias resolution failed; using original id (
|
|
38272
|
-
name: error51 instanceof Error ? error51.name : "unknown"
|
|
38273
|
-
});
|
|
38371
|
+
logger.warn("[project-identity] alias resolution failed; using original id", safeErrorSummary(error51));
|
|
38274
38372
|
return projectId;
|
|
38275
38373
|
}
|
|
38276
38374
|
}
|
|
@@ -38327,10 +38425,11 @@ var DEFAULT_TTL_MS = 30000, DEFAULT_RESOLVE_TIMEOUT_MS = 250, sharedResolver = n
|
|
|
38327
38425
|
var init_alias_resolver = __esm(() => {
|
|
38328
38426
|
init_dist();
|
|
38329
38427
|
init_db_connection();
|
|
38428
|
+
init_safe_error_summary();
|
|
38330
38429
|
});
|
|
38331
38430
|
|
|
38332
38431
|
// ../../packages/core/dist/services/search/index-manager.js
|
|
38333
|
-
import
|
|
38432
|
+
import fs7 from "fs";
|
|
38334
38433
|
import path11 from "path";
|
|
38335
38434
|
|
|
38336
38435
|
class IndexManager {
|
|
@@ -38426,7 +38525,7 @@ class IndexManager {
|
|
|
38426
38525
|
for (const filePath of indexedFiles) {
|
|
38427
38526
|
const fullPath = path11.join(projectPath, filePath);
|
|
38428
38527
|
try {
|
|
38429
|
-
const stat = await
|
|
38528
|
+
const stat = await fs7.promises.stat(fullPath);
|
|
38430
38529
|
fileMetadata[filePath] = {
|
|
38431
38530
|
path: filePath,
|
|
38432
38531
|
mtime: stat.mtimeMs,
|
|
@@ -38479,7 +38578,7 @@ class IndexManager {
|
|
|
38479
38578
|
}
|
|
38480
38579
|
const fullPath = path11.join(projectPath, match2);
|
|
38481
38580
|
try {
|
|
38482
|
-
const stat = await
|
|
38581
|
+
const stat = await fs7.promises.stat(fullPath);
|
|
38483
38582
|
files.set(match2, {
|
|
38484
38583
|
path: match2,
|
|
38485
38584
|
mtime: stat.mtimeMs,
|
|
@@ -41732,7 +41831,7 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
41732
41831
|
writeAuthConfig: () => writeAuthConfig
|
|
41733
41832
|
});
|
|
41734
41833
|
module.exports = __toCommonJS2(auth_config_exports);
|
|
41735
|
-
var
|
|
41834
|
+
var fs8 = __toESM2(__require("fs"));
|
|
41736
41835
|
var path12 = __toESM2(__require("path"));
|
|
41737
41836
|
var import_token_util = require_token_util();
|
|
41738
41837
|
function getAuthConfigPath() {
|
|
@@ -41745,10 +41844,10 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
41745
41844
|
function readAuthConfig() {
|
|
41746
41845
|
try {
|
|
41747
41846
|
const authPath = getAuthConfigPath();
|
|
41748
|
-
if (!
|
|
41847
|
+
if (!fs8.existsSync(authPath)) {
|
|
41749
41848
|
return null;
|
|
41750
41849
|
}
|
|
41751
|
-
const content =
|
|
41850
|
+
const content = fs8.readFileSync(authPath, "utf8");
|
|
41752
41851
|
if (!content) {
|
|
41753
41852
|
return null;
|
|
41754
41853
|
}
|
|
@@ -41760,10 +41859,10 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
41760
41859
|
function writeAuthConfig(config3) {
|
|
41761
41860
|
const authPath = getAuthConfigPath();
|
|
41762
41861
|
const authDir = path12.dirname(authPath);
|
|
41763
|
-
if (!
|
|
41764
|
-
|
|
41862
|
+
if (!fs8.existsSync(authDir)) {
|
|
41863
|
+
fs8.mkdirSync(authDir, { mode: 504, recursive: true });
|
|
41765
41864
|
}
|
|
41766
|
-
|
|
41865
|
+
fs8.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
|
|
41767
41866
|
}
|
|
41768
41867
|
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
41769
41868
|
if (!authConfig.token)
|
|
@@ -41939,7 +42038,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
41939
42038
|
});
|
|
41940
42039
|
module.exports = __toCommonJS2(token_util_exports);
|
|
41941
42040
|
var path12 = __toESM2(__require("path"));
|
|
41942
|
-
var
|
|
42041
|
+
var fs8 = __toESM2(__require("fs"));
|
|
41943
42042
|
var import_token_error = require_token_error();
|
|
41944
42043
|
var import_token_io = require_token_io();
|
|
41945
42044
|
var import_auth_config = require_auth_config();
|
|
@@ -42020,10 +42119,10 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
42020
42119
|
throw new import_token_error.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");
|
|
42021
42120
|
}
|
|
42022
42121
|
const prjPath = path12.join(dir, ".vercel", "project.json");
|
|
42023
|
-
if (!
|
|
42122
|
+
if (!fs8.existsSync(prjPath)) {
|
|
42024
42123
|
throw new import_token_error.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");
|
|
42025
42124
|
}
|
|
42026
|
-
const prj = JSON.parse(
|
|
42125
|
+
const prj = JSON.parse(fs8.readFileSync(prjPath, "utf8"));
|
|
42027
42126
|
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
|
|
42028
42127
|
throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");
|
|
42029
42128
|
}
|
|
@@ -42036,9 +42135,9 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
42036
42135
|
}
|
|
42037
42136
|
const tokenPath = path12.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
42038
42137
|
const tokenJson = JSON.stringify(token);
|
|
42039
|
-
|
|
42040
|
-
|
|
42041
|
-
|
|
42138
|
+
fs8.mkdirSync(path12.dirname(tokenPath), { mode: 504, recursive: true });
|
|
42139
|
+
fs8.writeFileSync(tokenPath, tokenJson);
|
|
42140
|
+
fs8.chmodSync(tokenPath, 432);
|
|
42042
42141
|
return;
|
|
42043
42142
|
}
|
|
42044
42143
|
function loadToken(projectId) {
|
|
@@ -42047,10 +42146,10 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
42047
42146
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
42048
42147
|
}
|
|
42049
42148
|
const tokenPath = path12.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
42050
|
-
if (!
|
|
42149
|
+
if (!fs8.existsSync(tokenPath)) {
|
|
42051
42150
|
return null;
|
|
42052
42151
|
}
|
|
42053
|
-
const token = JSON.parse(
|
|
42152
|
+
const token = JSON.parse(fs8.readFileSync(tokenPath, "utf8"));
|
|
42054
42153
|
assertVercelOidcTokenResponse(token);
|
|
42055
42154
|
return token;
|
|
42056
42155
|
}
|
|
@@ -69480,26 +69579,26 @@ var require_process = __commonJS((exports, module) => {
|
|
|
69480
69579
|
|
|
69481
69580
|
// ../../node_modules/detect-libc/lib/filesystem.js
|
|
69482
69581
|
var require_filesystem = __commonJS((exports, module) => {
|
|
69483
|
-
var
|
|
69582
|
+
var fs8 = __require("fs");
|
|
69484
69583
|
var LDD_PATH = "/usr/bin/ldd";
|
|
69485
69584
|
var SELF_PATH = "/proc/self/exe";
|
|
69486
69585
|
var MAX_LENGTH = 2048;
|
|
69487
69586
|
var readFileSync2 = (path12) => {
|
|
69488
|
-
const fd =
|
|
69587
|
+
const fd = fs8.openSync(path12, "r");
|
|
69489
69588
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
69490
|
-
const bytesRead =
|
|
69491
|
-
|
|
69589
|
+
const bytesRead = fs8.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
69590
|
+
fs8.close(fd, () => {});
|
|
69492
69591
|
return buffer.subarray(0, bytesRead);
|
|
69493
69592
|
};
|
|
69494
69593
|
var readFile = (path12) => new Promise((resolve4, reject) => {
|
|
69495
|
-
|
|
69594
|
+
fs8.open(path12, "r", (err, fd) => {
|
|
69496
69595
|
if (err) {
|
|
69497
69596
|
reject(err);
|
|
69498
69597
|
} else {
|
|
69499
69598
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
69500
|
-
|
|
69599
|
+
fs8.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
69501
69600
|
resolve4(buffer.subarray(0, bytesRead));
|
|
69502
|
-
|
|
69601
|
+
fs8.close(fd, () => {});
|
|
69503
69602
|
});
|
|
69504
69603
|
}
|
|
69505
69604
|
});
|
|
@@ -106162,10 +106261,10 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a;
|
|
|
106162
106261
|
super(t, "P2023", r);
|
|
106163
106262
|
}
|
|
106164
106263
|
};
|
|
106165
|
-
var
|
|
106264
|
+
var fs8 = new WeakMap;
|
|
106166
106265
|
function Ep(e) {
|
|
106167
|
-
let t =
|
|
106168
|
-
return t || (t = Object.entries(e),
|
|
106266
|
+
let t = fs8.get(e);
|
|
106267
|
+
return t || (t = Object.entries(e), fs8.set(e, t)), t;
|
|
106169
106268
|
}
|
|
106170
106269
|
function hs(e, t, r) {
|
|
106171
106270
|
switch (t.type) {
|
|
@@ -120974,6 +121073,89 @@ var init_reranker = __esm(() => {
|
|
|
120974
121073
|
});
|
|
120975
121074
|
});
|
|
120976
121075
|
|
|
121076
|
+
// ../../packages/core/dist/kernel/search-diagnostics.js
|
|
121077
|
+
function searchBackendUnavailable(component, cause) {
|
|
121078
|
+
return cause instanceof SearchServiceError ? cause : new SearchServiceError("SEARCH_BACKEND_UNAVAILABLE", component, { cause });
|
|
121079
|
+
}
|
|
121080
|
+
function storeCorruption(component, cause) {
|
|
121081
|
+
return cause instanceof SearchServiceError ? cause : new SearchServiceError("STORE_CORRUPTION", component, {
|
|
121082
|
+
cause,
|
|
121083
|
+
statusCode: 500
|
|
121084
|
+
});
|
|
121085
|
+
}
|
|
121086
|
+
function projectNotIndexed(projectId, message) {
|
|
121087
|
+
return new SearchServiceError("PROJECT_NOT_INDEXED", projectId, {
|
|
121088
|
+
message,
|
|
121089
|
+
statusCode: 404
|
|
121090
|
+
});
|
|
121091
|
+
}
|
|
121092
|
+
function recordSearchDegradation(code, component, projectId) {
|
|
121093
|
+
const degradation = {
|
|
121094
|
+
code,
|
|
121095
|
+
component,
|
|
121096
|
+
message: DEGRADATION_MESSAGES[code]
|
|
121097
|
+
};
|
|
121098
|
+
diagnostics.push({
|
|
121099
|
+
kind: "degradation",
|
|
121100
|
+
...degradation,
|
|
121101
|
+
projectId,
|
|
121102
|
+
timestamp: new Date().toISOString()
|
|
121103
|
+
});
|
|
121104
|
+
if (diagnostics.length > MAX_DIAGNOSTICS) {
|
|
121105
|
+
diagnostics.splice(0, diagnostics.length - MAX_DIAGNOSTICS);
|
|
121106
|
+
}
|
|
121107
|
+
return degradation;
|
|
121108
|
+
}
|
|
121109
|
+
function recordSearchFailure(error51, projectId) {
|
|
121110
|
+
if (recordedFailures.has(error51))
|
|
121111
|
+
return;
|
|
121112
|
+
recordedFailures.add(error51);
|
|
121113
|
+
diagnostics.push({
|
|
121114
|
+
kind: "failure",
|
|
121115
|
+
code: error51.code,
|
|
121116
|
+
component: error51.component,
|
|
121117
|
+
message: error51.message,
|
|
121118
|
+
projectId,
|
|
121119
|
+
timestamp: new Date().toISOString()
|
|
121120
|
+
});
|
|
121121
|
+
if (diagnostics.length > MAX_DIAGNOSTICS) {
|
|
121122
|
+
diagnostics.splice(0, diagnostics.length - MAX_DIAGNOSTICS);
|
|
121123
|
+
}
|
|
121124
|
+
}
|
|
121125
|
+
function getSearchDiagnostics() {
|
|
121126
|
+
return diagnostics.map((diagnostic) => ({ ...diagnostic }));
|
|
121127
|
+
}
|
|
121128
|
+
function resetSearchDiagnosticsForTests() {
|
|
121129
|
+
diagnostics.length = 0;
|
|
121130
|
+
}
|
|
121131
|
+
var MAX_DIAGNOSTICS = 100, diagnostics, recordedFailures, DEGRADATION_MESSAGES, SearchServiceError;
|
|
121132
|
+
var init_search_diagnostics = __esm(() => {
|
|
121133
|
+
diagnostics = [];
|
|
121134
|
+
recordedFailures = new WeakSet;
|
|
121135
|
+
DEGRADATION_MESSAGES = {
|
|
121136
|
+
QUERY_UNDERSTANDING_UNAVAILABLE: "Query understanding was unavailable; original query used",
|
|
121137
|
+
TRIGRAM_UNAVAILABLE: "Trigram enrichment was unavailable",
|
|
121138
|
+
FUZZY_SEARCH_UNAVAILABLE: "Fuzzy enrichment was unavailable",
|
|
121139
|
+
PROXIMITY_RERANK_UNAVAILABLE: "Proximity reranking was unavailable; fused order preserved",
|
|
121140
|
+
GRAPH_AUGMENTATION_UNAVAILABLE: "Graph augmentation was unavailable",
|
|
121141
|
+
SYNAPSE_UNAVAILABLE: "Synapse enrichment was unavailable; stateless results used",
|
|
121142
|
+
SEARCH_AUDIT_UNAVAILABLE: "Search event auditing was unavailable",
|
|
121143
|
+
SEARCH_ANALYTICS_UNAVAILABLE: "Search analytics were unavailable"
|
|
121144
|
+
};
|
|
121145
|
+
SearchServiceError = class SearchServiceError extends Error {
|
|
121146
|
+
code;
|
|
121147
|
+
component;
|
|
121148
|
+
statusCode;
|
|
121149
|
+
constructor(code, component, options) {
|
|
121150
|
+
super(options?.message ?? (code === "STORE_CORRUPTION" ? "Stored data is invalid" : "A required search backend is unavailable"), options?.cause === undefined ? undefined : { cause: options.cause });
|
|
121151
|
+
this.code = code;
|
|
121152
|
+
this.component = component;
|
|
121153
|
+
this.name = "SearchServiceError";
|
|
121154
|
+
this.statusCode = options?.statusCode ?? 503;
|
|
121155
|
+
}
|
|
121156
|
+
};
|
|
121157
|
+
});
|
|
121158
|
+
|
|
120977
121159
|
// ../../packages/core/dist/kernel/enum-validation.js
|
|
120978
121160
|
function validateEnum(paramName, value, validValues) {
|
|
120979
121161
|
if (typeof value !== "string" || !validValues.includes(value)) {
|
|
@@ -121082,7 +121264,7 @@ class SearchController {
|
|
|
121082
121264
|
});
|
|
121083
121265
|
const admission = await this.contextualSearch.checkSearchAdmission(projectId, projectPath);
|
|
121084
121266
|
if (!admission.admitted) {
|
|
121085
|
-
throw
|
|
121267
|
+
throw projectNotIndexed(projectId, admission.error ?? `Project '${projectId}' is not indexed`);
|
|
121086
121268
|
}
|
|
121087
121269
|
const staleWarning = admission.stale ?? null;
|
|
121088
121270
|
let reindexInfo = null;
|
|
@@ -121306,6 +121488,7 @@ var init_search_controller = __esm(() => {
|
|
|
121306
121488
|
init_contextual_search_rlm();
|
|
121307
121489
|
init_event_bus();
|
|
121308
121490
|
init_reranker();
|
|
121491
|
+
init_search_diagnostics();
|
|
121309
121492
|
init_esm();
|
|
121310
121493
|
init_filter_validation();
|
|
121311
121494
|
});
|
|
@@ -121791,83 +121974,6 @@ var init_session_bias = __esm(() => {
|
|
|
121791
121974
|
init_synapse();
|
|
121792
121975
|
});
|
|
121793
121976
|
|
|
121794
|
-
// ../../packages/core/dist/kernel/search-diagnostics.js
|
|
121795
|
-
function searchBackendUnavailable(component, cause) {
|
|
121796
|
-
return cause instanceof SearchServiceError ? cause : new SearchServiceError("SEARCH_BACKEND_UNAVAILABLE", component, { cause });
|
|
121797
|
-
}
|
|
121798
|
-
function storeCorruption(component, cause) {
|
|
121799
|
-
return cause instanceof SearchServiceError ? cause : new SearchServiceError("STORE_CORRUPTION", component, {
|
|
121800
|
-
cause,
|
|
121801
|
-
statusCode: 500
|
|
121802
|
-
});
|
|
121803
|
-
}
|
|
121804
|
-
function recordSearchDegradation(code, component, projectId) {
|
|
121805
|
-
const degradation = {
|
|
121806
|
-
code,
|
|
121807
|
-
component,
|
|
121808
|
-
message: DEGRADATION_MESSAGES[code]
|
|
121809
|
-
};
|
|
121810
|
-
diagnostics.push({
|
|
121811
|
-
kind: "degradation",
|
|
121812
|
-
...degradation,
|
|
121813
|
-
projectId,
|
|
121814
|
-
timestamp: new Date().toISOString()
|
|
121815
|
-
});
|
|
121816
|
-
if (diagnostics.length > MAX_DIAGNOSTICS) {
|
|
121817
|
-
diagnostics.splice(0, diagnostics.length - MAX_DIAGNOSTICS);
|
|
121818
|
-
}
|
|
121819
|
-
return degradation;
|
|
121820
|
-
}
|
|
121821
|
-
function recordSearchFailure(error51, projectId) {
|
|
121822
|
-
if (recordedFailures.has(error51))
|
|
121823
|
-
return;
|
|
121824
|
-
recordedFailures.add(error51);
|
|
121825
|
-
diagnostics.push({
|
|
121826
|
-
kind: "failure",
|
|
121827
|
-
code: error51.code,
|
|
121828
|
-
component: error51.component,
|
|
121829
|
-
message: error51.message,
|
|
121830
|
-
projectId,
|
|
121831
|
-
timestamp: new Date().toISOString()
|
|
121832
|
-
});
|
|
121833
|
-
if (diagnostics.length > MAX_DIAGNOSTICS) {
|
|
121834
|
-
diagnostics.splice(0, diagnostics.length - MAX_DIAGNOSTICS);
|
|
121835
|
-
}
|
|
121836
|
-
}
|
|
121837
|
-
function getSearchDiagnostics() {
|
|
121838
|
-
return diagnostics.map((diagnostic) => ({ ...diagnostic }));
|
|
121839
|
-
}
|
|
121840
|
-
function resetSearchDiagnosticsForTests() {
|
|
121841
|
-
diagnostics.length = 0;
|
|
121842
|
-
}
|
|
121843
|
-
var MAX_DIAGNOSTICS = 100, diagnostics, recordedFailures, DEGRADATION_MESSAGES, SearchServiceError;
|
|
121844
|
-
var init_search_diagnostics = __esm(() => {
|
|
121845
|
-
diagnostics = [];
|
|
121846
|
-
recordedFailures = new WeakSet;
|
|
121847
|
-
DEGRADATION_MESSAGES = {
|
|
121848
|
-
QUERY_UNDERSTANDING_UNAVAILABLE: "Query understanding was unavailable; original query used",
|
|
121849
|
-
TRIGRAM_UNAVAILABLE: "Trigram enrichment was unavailable",
|
|
121850
|
-
FUZZY_SEARCH_UNAVAILABLE: "Fuzzy enrichment was unavailable",
|
|
121851
|
-
PROXIMITY_RERANK_UNAVAILABLE: "Proximity reranking was unavailable; fused order preserved",
|
|
121852
|
-
GRAPH_AUGMENTATION_UNAVAILABLE: "Graph augmentation was unavailable",
|
|
121853
|
-
SYNAPSE_UNAVAILABLE: "Synapse enrichment was unavailable; stateless results used",
|
|
121854
|
-
SEARCH_AUDIT_UNAVAILABLE: "Search event auditing was unavailable",
|
|
121855
|
-
SEARCH_ANALYTICS_UNAVAILABLE: "Search analytics were unavailable"
|
|
121856
|
-
};
|
|
121857
|
-
SearchServiceError = class SearchServiceError extends Error {
|
|
121858
|
-
code;
|
|
121859
|
-
component;
|
|
121860
|
-
statusCode;
|
|
121861
|
-
constructor(code, component, options) {
|
|
121862
|
-
super(code === "STORE_CORRUPTION" ? "Stored data is invalid" : "A required search backend is unavailable", options?.cause === undefined ? undefined : { cause: options.cause });
|
|
121863
|
-
this.code = code;
|
|
121864
|
-
this.component = component;
|
|
121865
|
-
this.name = "SearchServiceError";
|
|
121866
|
-
this.statusCode = options?.statusCode ?? 503;
|
|
121867
|
-
}
|
|
121868
|
-
};
|
|
121869
|
-
});
|
|
121870
|
-
|
|
121871
121977
|
// ../../packages/core/dist/services/search/hybrid-search.js
|
|
121872
121978
|
async function search(deps, query, projectId, options = {}) {
|
|
121873
121979
|
const maxResults = options.maxResults ?? 10;
|
|
@@ -123224,7 +123330,7 @@ var init_managed_run_repository_pg = __esm(() => {
|
|
|
123224
123330
|
});
|
|
123225
123331
|
|
|
123226
123332
|
// ../../packages/core/dist/services/search/project-indexer.js
|
|
123227
|
-
import
|
|
123333
|
+
import fs8 from "fs/promises";
|
|
123228
123334
|
import path13 from "path";
|
|
123229
123335
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
123230
123336
|
async function runWithIndexLock(lockMap, projectId, work) {
|
|
@@ -123484,7 +123590,7 @@ async function checkSearchAdmission(deps, projectId, projectPath) {
|
|
|
123484
123590
|
}
|
|
123485
123591
|
async function indexFile(deps, filePath, projectId, projectRoot, centralityMap) {
|
|
123486
123592
|
projectId = await getProjectIdentityAliasResolver().resolve(projectId);
|
|
123487
|
-
const content = await
|
|
123593
|
+
const content = await fs8.readFile(filePath, "utf-8");
|
|
123488
123594
|
const relativePath = path13.relative(projectRoot, filePath);
|
|
123489
123595
|
const maxFileSize = config2.get("security").maxFileSize || 1024 * 1024;
|
|
123490
123596
|
if (content.length > maxFileSize) {
|
|
@@ -124322,6 +124428,7 @@ class IndexJobTracker {
|
|
|
124322
124428
|
filesIndexed: r?.filesIndexed ?? 0,
|
|
124323
124429
|
chunksIndexed: r?.chunksIndexed ?? 0,
|
|
124324
124430
|
symbolsIndexed: 0,
|
|
124431
|
+
errors: r?.errors ?? 0,
|
|
124325
124432
|
durationMs: r?.duration ?? 0,
|
|
124326
124433
|
activatedGraphGenerationId: r?.activatedGraphGenerationId ?? ""
|
|
124327
124434
|
});
|
|
@@ -124343,8 +124450,13 @@ var init_index_job_tracker = __esm(() => {
|
|
|
124343
124450
|
indexJobTracker = IndexJobTracker.getInstance();
|
|
124344
124451
|
});
|
|
124345
124452
|
|
|
124453
|
+
// ../../packages/core/dist/kernel/sanitize/strip-nul.js
|
|
124454
|
+
function stripNul(content) {
|
|
124455
|
+
return content.includes("\x00") ? content.replaceAll("\x00", "") : content;
|
|
124456
|
+
}
|
|
124457
|
+
|
|
124346
124458
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
124347
|
-
import
|
|
124459
|
+
import fs9 from "fs/promises";
|
|
124348
124460
|
import path14 from "path";
|
|
124349
124461
|
import { createHash as createHash5 } from "crypto";
|
|
124350
124462
|
|
|
@@ -124432,8 +124544,8 @@ class DiscoverStage {
|
|
|
124432
124544
|
async processFile(ctx, relativePath, forceReindex) {
|
|
124433
124545
|
const absolutePath = path14.join(ctx.projectPath, relativePath);
|
|
124434
124546
|
try {
|
|
124435
|
-
const stat = await
|
|
124436
|
-
const content = await
|
|
124547
|
+
const stat = await fs9.stat(absolutePath);
|
|
124548
|
+
const content = stripNul(await fs9.readFile(absolutePath, "utf-8"));
|
|
124437
124549
|
const contentHash = createHash5("sha256").update(content).digest("hex");
|
|
124438
124550
|
let needsReparse = forceReindex;
|
|
124439
124551
|
if (!forceReindex) {
|
|
@@ -124477,7 +124589,7 @@ class DiscoverStage {
|
|
|
124477
124589
|
}
|
|
124478
124590
|
try {
|
|
124479
124591
|
const gitignorePath = path14.join(projectPath, ".gitignore");
|
|
124480
|
-
const gitignoreContent = await
|
|
124592
|
+
const gitignoreContent = await fs9.readFile(gitignorePath, "utf8");
|
|
124481
124593
|
const rules = gitignoreContent.split(`
|
|
124482
124594
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
124483
124595
|
ig.add(rules);
|
|
@@ -126806,7 +126918,7 @@ var init_structural_runtime = __esm(() => {
|
|
|
126806
126918
|
|
|
126807
126919
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
126808
126920
|
import path15 from "path";
|
|
126809
|
-
import
|
|
126921
|
+
import fs10 from "fs/promises";
|
|
126810
126922
|
function resolveChunkerMaxChars() {
|
|
126811
126923
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
126812
126924
|
if (Number.isFinite(global2) && global2 > 0)
|
|
@@ -126898,7 +127010,7 @@ class ParseStage {
|
|
|
126898
127010
|
if (!file2.needsReparse) {
|
|
126899
127011
|
const extension = path15.extname(file2.relativePath).toLowerCase();
|
|
126900
127012
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
126901
|
-
const content = file2.snapshotContent ?? await
|
|
127013
|
+
const content = file2.snapshotContent ?? await fs10.readFile(file2.absolutePath, "utf8");
|
|
126902
127014
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
126903
127015
|
if (outcome.status === "failed")
|
|
126904
127016
|
throw new StructuralEtlParseError(file2.relativePath, outcome.failureKind, `Structural evidence parse failed (${outcome.failureKind})`, outcome.diagnosticCount, outcome.diagnostics.slice(0, 10));
|
|
@@ -126910,7 +127022,7 @@ class ParseStage {
|
|
|
126910
127022
|
return { file: file2, chunks: [], symbols: [], rawImports: [], rawEdges: [] };
|
|
126911
127023
|
}
|
|
126912
127024
|
try {
|
|
126913
|
-
const content = file2.snapshotContent ?? await
|
|
127025
|
+
const content = file2.snapshotContent ?? await fs10.readFile(file2.absolutePath, "utf-8");
|
|
126914
127026
|
const ext2 = path15.extname(file2.relativePath).toLowerCase();
|
|
126915
127027
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
126916
127028
|
const chunks = smartChunk(content, file2.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
@@ -127951,7 +128063,7 @@ var init_data_document2 = __esm(() => {
|
|
|
127951
128063
|
|
|
127952
128064
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
127953
128065
|
import path18 from "path";
|
|
127954
|
-
import
|
|
128066
|
+
import fs11 from "fs";
|
|
127955
128067
|
|
|
127956
128068
|
class ResolveStage {
|
|
127957
128069
|
symbolRepository;
|
|
@@ -128268,7 +128380,7 @@ class ResolveStage {
|
|
|
128268
128380
|
const aliases = [];
|
|
128269
128381
|
const tsconfigPath = path18.join(projectPath, "tsconfig.json");
|
|
128270
128382
|
try {
|
|
128271
|
-
const raw2 =
|
|
128383
|
+
const raw2 = fs11.readFileSync(tsconfigPath, "utf-8");
|
|
128272
128384
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
128273
128385
|
const tsconfig = JSON.parse(stripped);
|
|
128274
128386
|
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
@@ -128494,6 +128606,7 @@ class LoadStage {
|
|
|
128494
128606
|
let chunksLoaded = 0;
|
|
128495
128607
|
let symbolsLoaded = 0;
|
|
128496
128608
|
let errors4 = 0;
|
|
128609
|
+
const fileErrors = [];
|
|
128497
128610
|
let processedSinceStart = 0;
|
|
128498
128611
|
let lastEtaLogAt = 0;
|
|
128499
128612
|
const BATCH = 10;
|
|
@@ -128564,6 +128677,12 @@ class LoadStage {
|
|
|
128564
128677
|
} catch (err) {
|
|
128565
128678
|
errors4++;
|
|
128566
128679
|
processedSinceStart++;
|
|
128680
|
+
if (fileErrors.length < MAX_FILE_ERRORS) {
|
|
128681
|
+
fileErrors.push({
|
|
128682
|
+
filePath: file2.file.relativePath,
|
|
128683
|
+
error: err.message
|
|
128684
|
+
});
|
|
128685
|
+
}
|
|
128567
128686
|
if (emitLifecycle)
|
|
128568
128687
|
ctx.emit({
|
|
128569
128688
|
type: "file_error",
|
|
@@ -128629,7 +128748,7 @@ class LoadStage {
|
|
|
128629
128748
|
duration: formatDuration(durationMs),
|
|
128630
128749
|
filesPerSec: filesLoaded > 0 && durationMs > 0 ? Number((filesLoaded / durationMs * 1000).toFixed(2)) : 0
|
|
128631
128750
|
});
|
|
128632
|
-
return { filesLoaded, chunksLoaded, symbolsLoaded, errors: errors4 };
|
|
128751
|
+
return { filesLoaded, chunksLoaded, symbolsLoaded, errors: errors4, fileErrors };
|
|
128633
128752
|
}
|
|
128634
128753
|
async loadToSearchStores(ctx, file2) {
|
|
128635
128754
|
if (file2.chunks.length === 0)
|
|
@@ -128701,6 +128820,7 @@ class LoadStage {
|
|
|
128701
128820
|
return batch.definitions.length;
|
|
128702
128821
|
}
|
|
128703
128822
|
}
|
|
128823
|
+
var MAX_FILE_ERRORS = 50;
|
|
128704
128824
|
var init_load = __esm(() => {
|
|
128705
128825
|
init_dist();
|
|
128706
128826
|
init_with_deadlock_retry();
|
|
@@ -129443,7 +129563,12 @@ var init_pipeline = __esm(() => {
|
|
|
129443
129563
|
throw managedRunLeaseLost;
|
|
129444
129564
|
stageTimings.load = Math.round(performance.now() - st4);
|
|
129445
129565
|
if (loadResult.errors > 0) {
|
|
129446
|
-
|
|
129566
|
+
logger.warn("EtlPipeline: completed with file errors", {
|
|
129567
|
+
projectId,
|
|
129568
|
+
jobId,
|
|
129569
|
+
errors: loadResult.errors,
|
|
129570
|
+
fileErrors: (loadResult.fileErrors ?? []).slice(0, 10)
|
|
129571
|
+
});
|
|
129447
129572
|
}
|
|
129448
129573
|
const activationSnapshot = await abortable(this.discover.run(ctx, { forceReindex, includeTests: include_tests }), graphAbortController.signal);
|
|
129449
129574
|
if (buildGraphInputSnapshotHash(activationSnapshot) !== graphGenerationLease.inputSnapshotHash) {
|
|
@@ -129500,6 +129625,7 @@ var init_pipeline = __esm(() => {
|
|
|
129500
129625
|
filesIndexed: result.filesIndexed,
|
|
129501
129626
|
chunksIndexed: result.chunksIndexed,
|
|
129502
129627
|
errors: result.errors,
|
|
129628
|
+
fileErrors: loadResult.fileErrors ?? [],
|
|
129503
129629
|
duration: durationMs,
|
|
129504
129630
|
activatedGraphGenerationId: result.activatedGraphGenerationId,
|
|
129505
129631
|
parserDiagnostics: result.parserDiagnostics
|
|
@@ -129510,6 +129636,7 @@ var init_pipeline = __esm(() => {
|
|
|
129510
129636
|
filesIndexed: result.filesIndexed,
|
|
129511
129637
|
chunksIndexed: result.chunksIndexed,
|
|
129512
129638
|
symbolsIndexed: result.symbolsIndexed,
|
|
129639
|
+
errors: result.errors,
|
|
129513
129640
|
durationMs,
|
|
129514
129641
|
activatedGraphGenerationId: result.activatedGraphGenerationId
|
|
129515
129642
|
});
|
|
@@ -130676,7 +130803,7 @@ __export(exports_symbol_graph_service, {
|
|
|
130676
130803
|
SymbolGraphService: () => SymbolGraphService
|
|
130677
130804
|
});
|
|
130678
130805
|
import path22 from "path";
|
|
130679
|
-
import
|
|
130806
|
+
import fs12 from "fs/promises";
|
|
130680
130807
|
|
|
130681
130808
|
class SymbolGraphService {
|
|
130682
130809
|
identityLookup;
|
|
@@ -131004,7 +131131,7 @@ class SymbolGraphService {
|
|
|
131004
131131
|
async readSnippet(relativePath, lineStart, lineEnd, projectId) {
|
|
131005
131132
|
try {
|
|
131006
131133
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
131007
|
-
const content = await
|
|
131134
|
+
const content = await fs12.readFile(absolutePath, "utf-8");
|
|
131008
131135
|
const lines = content.split(`
|
|
131009
131136
|
`);
|
|
131010
131137
|
return lines.slice(Math.max(0, lineStart - 1), Math.min(lines.length, lineEnd)).join(`
|
|
@@ -131016,7 +131143,7 @@ class SymbolGraphService {
|
|
|
131016
131143
|
async readContext(relativePath, lineNumber, contextLines, projectId) {
|
|
131017
131144
|
try {
|
|
131018
131145
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
131019
|
-
const content = await
|
|
131146
|
+
const content = await fs12.readFile(absolutePath, "utf-8");
|
|
131020
131147
|
const lines = content.split(`
|
|
131021
131148
|
`);
|
|
131022
131149
|
const start = Math.max(0, lineNumber - contextLines - 1);
|
|
@@ -136861,7 +136988,7 @@ var init_session_pin_store = __esm(() => {
|
|
|
136861
136988
|
});
|
|
136862
136989
|
|
|
136863
136990
|
// ../../packages/core/dist/services/hooks/attribution-resolver.js
|
|
136864
|
-
import
|
|
136991
|
+
import fs13 from "fs";
|
|
136865
136992
|
import os6 from "os";
|
|
136866
136993
|
import path24 from "path";
|
|
136867
136994
|
|
|
@@ -136888,9 +137015,7 @@ class PgWorkspaceRootProvider {
|
|
|
136888
137015
|
this.cache = { roots, expiresAt: this.now() + PROVIDER_TTL_MS };
|
|
136889
137016
|
return roots;
|
|
136890
137017
|
} catch (error51) {
|
|
136891
|
-
logger.warn("[hook-attribution] workspace roots lookup failed; containment disabled (
|
|
136892
|
-
name: error51 instanceof Error ? error51.name : "unknown"
|
|
136893
|
-
});
|
|
137018
|
+
logger.warn("[hook-attribution] workspace roots lookup failed; containment disabled", safeErrorSummary(error51));
|
|
136894
137019
|
return [];
|
|
136895
137020
|
} finally {
|
|
136896
137021
|
if (timer)
|
|
@@ -136999,7 +137124,7 @@ class AttributionResolver {
|
|
|
136999
137124
|
}
|
|
137000
137125
|
function defaultCanonicalize(cwd) {
|
|
137001
137126
|
try {
|
|
137002
|
-
return
|
|
137127
|
+
return fs13.realpathSync(cwd);
|
|
137003
137128
|
} catch {
|
|
137004
137129
|
try {
|
|
137005
137130
|
return path24.resolve(cwd);
|
|
@@ -137018,75 +137143,10 @@ var init_attribution_resolver = __esm(() => {
|
|
|
137018
137143
|
init_dist();
|
|
137019
137144
|
init_db_connection();
|
|
137020
137145
|
init_alias_resolver();
|
|
137146
|
+
init_safe_error_summary();
|
|
137021
137147
|
init_session_pin_store();
|
|
137022
137148
|
});
|
|
137023
137149
|
|
|
137024
|
-
// ../../packages/core/dist/kernel/sanitize/credential-scrub.js
|
|
137025
|
-
function markerFor(id) {
|
|
137026
|
-
return `[REDACTED:${id}]`;
|
|
137027
|
-
}
|
|
137028
|
-
function fullMatchRule(id, pattern) {
|
|
137029
|
-
const marker26 = markerFor(id);
|
|
137030
|
-
return {
|
|
137031
|
-
id,
|
|
137032
|
-
replace(text3) {
|
|
137033
|
-
let count = 0;
|
|
137034
|
-
const replaced = text3.replace(pattern, () => {
|
|
137035
|
-
count++;
|
|
137036
|
-
return marker26;
|
|
137037
|
-
});
|
|
137038
|
-
return { text: replaced, count };
|
|
137039
|
-
}
|
|
137040
|
-
};
|
|
137041
|
-
}
|
|
137042
|
-
function scrubCredentials(payloadJson) {
|
|
137043
|
-
const redactions = {};
|
|
137044
|
-
for (const id of RULE_IDS)
|
|
137045
|
-
redactions[id] = 0;
|
|
137046
|
-
let text3 = payloadJson;
|
|
137047
|
-
for (const rule of RULES) {
|
|
137048
|
-
const { text: next, count } = rule.replace(text3);
|
|
137049
|
-
text3 = next;
|
|
137050
|
-
redactions[rule.id] += count;
|
|
137051
|
-
}
|
|
137052
|
-
const total = Object.values(redactions).reduce((sum, n) => sum + n, 0);
|
|
137053
|
-
return {
|
|
137054
|
-
sanitized: text3,
|
|
137055
|
-
redactions,
|
|
137056
|
-
total
|
|
137057
|
-
};
|
|
137058
|
-
}
|
|
137059
|
-
var PEM_PATTERN, JWT_PATTERN, AWS_KEY_PATTERN, SK_KEY_PATTERN, GITHUB_TOKEN_PATTERN, SLACK_TOKEN_PATTERN, BEARER_PATTERN, RULES, RULE_IDS;
|
|
137060
|
-
var init_credential_scrub = __esm(() => {
|
|
137061
|
-
PEM_PATTERN = /-----BEGIN [A-Z ]{0,32}PRIVATE KEY-----[\s\S]{0,8192}?-----END [A-Z ]{0,32}PRIVATE KEY-----/g;
|
|
137062
|
-
JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
|
|
137063
|
-
AWS_KEY_PATTERN = /\b(?:AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16}\b/g;
|
|
137064
|
-
SK_KEY_PATTERN = /\bsk-[A-Za-z0-9_-]{20,}\b/g;
|
|
137065
|
-
GITHUB_TOKEN_PATTERN = /\bgh[pousr]_[A-Za-z0-9]{36,}\b|\bgithub_pat_[A-Za-z0-9_]{22,}\b/g;
|
|
137066
|
-
SLACK_TOKEN_PATTERN = /\bxox[baprs]-[A-Za-z0-9-]{18,}\b/g;
|
|
137067
|
-
BEARER_PATTERN = /(Bearer\s+)([A-Za-z0-9._~+/=-]{20,})/g;
|
|
137068
|
-
RULES = [
|
|
137069
|
-
fullMatchRule("pem", PEM_PATTERN),
|
|
137070
|
-
fullMatchRule("jwt", JWT_PATTERN),
|
|
137071
|
-
fullMatchRule("aws-key", AWS_KEY_PATTERN),
|
|
137072
|
-
fullMatchRule("sk-key", SK_KEY_PATTERN),
|
|
137073
|
-
fullMatchRule("github-token", GITHUB_TOKEN_PATTERN),
|
|
137074
|
-
fullMatchRule("slack-token", SLACK_TOKEN_PATTERN),
|
|
137075
|
-
{
|
|
137076
|
-
id: "bearer",
|
|
137077
|
-
replace(text3) {
|
|
137078
|
-
let count = 0;
|
|
137079
|
-
const replaced = text3.replace(BEARER_PATTERN, (_m, prefix) => {
|
|
137080
|
-
count++;
|
|
137081
|
-
return `${prefix}${markerFor("bearer")}`;
|
|
137082
|
-
});
|
|
137083
|
-
return { text: replaced, count };
|
|
137084
|
-
}
|
|
137085
|
-
}
|
|
137086
|
-
];
|
|
137087
|
-
RULE_IDS = RULES.map((r) => r.id);
|
|
137088
|
-
});
|
|
137089
|
-
|
|
137090
137150
|
// ../../packages/core/dist/tools/compact_snapshot.js
|
|
137091
137151
|
class CompactSnapshotTool {
|
|
137092
137152
|
name = "compact_snapshot";
|
|
@@ -138672,7 +138732,7 @@ var init_get_architecture = __esm(() => {
|
|
|
138672
138732
|
});
|
|
138673
138733
|
|
|
138674
138734
|
// ../../packages/core/dist/services/file-read/file-content-cache.js
|
|
138675
|
-
import
|
|
138735
|
+
import fs14 from "fs/promises";
|
|
138676
138736
|
|
|
138677
138737
|
class FileContentCache {
|
|
138678
138738
|
extractMetadata;
|
|
@@ -138705,7 +138765,7 @@ class FileContentCache {
|
|
|
138705
138765
|
metadata: cached2.metadata
|
|
138706
138766
|
};
|
|
138707
138767
|
}
|
|
138708
|
-
const content = await
|
|
138768
|
+
const content = await fs14.readFile(filePath, "utf-8");
|
|
138709
138769
|
const metadata = await this.extractMetadata(content, filePath, options);
|
|
138710
138770
|
evictOldest(this.fileCache, this.FILE_CACHE_MAX_ENTRIES - 1);
|
|
138711
138771
|
this.fileCache.set(cacheKey, {
|
|
@@ -142130,7 +142190,7 @@ var init_l1_memory_cache = __esm(() => {
|
|
|
142130
142190
|
});
|
|
142131
142191
|
|
|
142132
142192
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
142133
|
-
import
|
|
142193
|
+
import fs15 from "fs/promises";
|
|
142134
142194
|
import { existsSync as existsSync3 } from "fs";
|
|
142135
142195
|
import path27 from "path";
|
|
142136
142196
|
|
|
@@ -142166,10 +142226,10 @@ class LocalHealthChecker {
|
|
|
142166
142226
|
const start = Date.now();
|
|
142167
142227
|
try {
|
|
142168
142228
|
if (!existsSync3(this.dataDir))
|
|
142169
|
-
await
|
|
142229
|
+
await fs15.mkdir(this.dataDir, { recursive: true });
|
|
142170
142230
|
const probe2 = path27.join(this.dataDir, ".health-check-test");
|
|
142171
|
-
await
|
|
142172
|
-
await
|
|
142231
|
+
await fs15.writeFile(probe2, "ok");
|
|
142232
|
+
await fs15.unlink(probe2);
|
|
142173
142233
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
142174
142234
|
} catch (error51) {
|
|
142175
142235
|
return { available: false, latency: Date.now() - start, error: `Data directory error: ${error51.message}` };
|
|
@@ -144108,7 +144168,7 @@ var init_scheduler2 = __esm(() => {
|
|
|
144108
144168
|
});
|
|
144109
144169
|
|
|
144110
144170
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
144111
|
-
import
|
|
144171
|
+
import fs16 from "fs/promises";
|
|
144112
144172
|
import { existsSync as existsSync4 } from "fs";
|
|
144113
144173
|
import path28 from "path";
|
|
144114
144174
|
function getModelsDevClient() {
|
|
@@ -144138,7 +144198,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
144138
144198
|
if (!existsSync4(cachePath)) {
|
|
144139
144199
|
return null;
|
|
144140
144200
|
}
|
|
144141
|
-
const content = await
|
|
144201
|
+
const content = await fs16.readFile(cachePath, "utf-8");
|
|
144142
144202
|
const data = JSON.parse(content);
|
|
144143
144203
|
const age = Date.now() - data.timestamp;
|
|
144144
144204
|
if (age > ModelsDevClient.LOCAL_CACHE_TTL) {
|
|
@@ -144166,13 +144226,13 @@ var init_models_dev_client = __esm(() => {
|
|
|
144166
144226
|
const cachePath = this.getLocalCachePath();
|
|
144167
144227
|
try {
|
|
144168
144228
|
const dir = path28.dirname(cachePath);
|
|
144169
|
-
await
|
|
144229
|
+
await fs16.mkdir(dir, { recursive: true });
|
|
144170
144230
|
const data = {
|
|
144171
144231
|
timestamp: Date.now(),
|
|
144172
144232
|
version: "1.0.0",
|
|
144173
144233
|
models: Object.fromEntries(models)
|
|
144174
144234
|
};
|
|
144175
|
-
await
|
|
144235
|
+
await fs16.writeFile(cachePath, JSON.stringify(data), "utf-8");
|
|
144176
144236
|
logger.debug("Saved pricing to local cache", {
|
|
144177
144237
|
models: models.size,
|
|
144178
144238
|
path: cachePath
|
|
@@ -144501,7 +144561,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
144501
144561
|
const cachePath = this.getLocalCachePath();
|
|
144502
144562
|
try {
|
|
144503
144563
|
if (existsSync4(cachePath)) {
|
|
144504
|
-
await
|
|
144564
|
+
await fs16.unlink(cachePath);
|
|
144505
144565
|
logger.debug("Local pricing cache file deleted");
|
|
144506
144566
|
}
|
|
144507
144567
|
} catch (error51) {
|
|
@@ -162508,6 +162568,7 @@ var init_services = __esm(() => {
|
|
|
162508
162568
|
init_search_analytics_pg();
|
|
162509
162569
|
init_index_manager();
|
|
162510
162570
|
init_search_diagnostics();
|
|
162571
|
+
init_safe_error_summary();
|
|
162511
162572
|
init_memory_controller();
|
|
162512
162573
|
init_llm_client();
|
|
162513
162574
|
init_search_controller();
|
|
@@ -162945,7 +163006,7 @@ var init_hook_service = __esm(() => {
|
|
|
162945
163006
|
|
|
162946
163007
|
// ../../packages/core/dist/services/bootstrap/bootstrap-service.js
|
|
162947
163008
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
162948
|
-
import
|
|
163009
|
+
import fs17 from "fs";
|
|
162949
163010
|
import path29 from "path";
|
|
162950
163011
|
import { spawn as spawn2 } from "child_process";
|
|
162951
163012
|
function readBootstrapConfig() {
|
|
@@ -163107,8 +163168,8 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
163107
163168
|
try {
|
|
163108
163169
|
for (const name26 of README_CANDIDATES) {
|
|
163109
163170
|
const p = path29.join(projectRoot, name26);
|
|
163110
|
-
if (
|
|
163111
|
-
const buf =
|
|
163171
|
+
if (fs17.existsSync(p) && fs17.statSync(p).isFile()) {
|
|
163172
|
+
const buf = fs17.readFileSync(p);
|
|
163112
163173
|
signals.readme = buf.slice(0, MAX_README_BYTES).toString("utf8");
|
|
163113
163174
|
break;
|
|
163114
163175
|
}
|
|
@@ -163118,11 +163179,11 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
163118
163179
|
}
|
|
163119
163180
|
try {
|
|
163120
163181
|
const docsDir = path29.join(projectRoot, "docs");
|
|
163121
|
-
if (
|
|
163182
|
+
if (fs17.existsSync(docsDir) && fs17.statSync(docsDir).isDirectory()) {
|
|
163122
163183
|
const entries = walkMarkdown(docsDir).slice(0, MAX_DOCS);
|
|
163123
163184
|
for (const rel of entries) {
|
|
163124
163185
|
try {
|
|
163125
|
-
const buf =
|
|
163186
|
+
const buf = fs17.readFileSync(rel);
|
|
163126
163187
|
signals.docs.push({
|
|
163127
163188
|
path: path29.relative(projectRoot, rel),
|
|
163128
163189
|
snippet: buf.slice(0, MAX_DOC_BYTES).toString("utf8")
|
|
@@ -163136,9 +163197,9 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
163136
163197
|
try {
|
|
163137
163198
|
for (const name26 of MANIFEST_FILES) {
|
|
163138
163199
|
const p = path29.join(projectRoot, name26);
|
|
163139
|
-
if (!
|
|
163200
|
+
if (!fs17.existsSync(p) || !fs17.statSync(p).isFile())
|
|
163140
163201
|
continue;
|
|
163141
|
-
const raw2 =
|
|
163202
|
+
const raw2 = fs17.readFileSync(p).slice(0, MAX_MANIFEST_BYTES).toString("utf8");
|
|
163142
163203
|
const kind = name26;
|
|
163143
163204
|
if (name26 === "package.json") {
|
|
163144
163205
|
try {
|
|
@@ -163178,7 +163239,7 @@ function walkMarkdown(dir) {
|
|
|
163178
163239
|
const cur = stack.pop();
|
|
163179
163240
|
let entries;
|
|
163180
163241
|
try {
|
|
163181
|
-
entries =
|
|
163242
|
+
entries = fs17.readdirSync(cur, { withFileTypes: true });
|
|
163182
163243
|
} catch {
|
|
163183
163244
|
continue;
|
|
163184
163245
|
}
|
|
@@ -163913,6 +163974,7 @@ __export(exports_dist, {
|
|
|
163913
163974
|
searchSessionHook: () => searchSessionHook,
|
|
163914
163975
|
searchBackendUnavailable: () => searchBackendUnavailable,
|
|
163915
163976
|
scanSignals: () => scanSignals,
|
|
163977
|
+
safeErrorSummary: () => safeErrorSummary,
|
|
163916
163978
|
runPool: () => runPool,
|
|
163917
163979
|
ruleBasedSeed: () => ruleBasedSeed,
|
|
163918
163980
|
resolveStructuralParseLanguage: () => resolveStructuralParseLanguage,
|
|
@@ -163936,6 +163998,7 @@ __export(exports_dist, {
|
|
|
163936
163998
|
recordSearchFailure: () => recordSearchFailure,
|
|
163937
163999
|
recordSearchDegradation: () => recordSearchDegradation,
|
|
163938
164000
|
quoteDiscoveredIdentifier: () => quoteDiscoveredIdentifier,
|
|
164001
|
+
projectNotIndexed: () => projectNotIndexed,
|
|
163939
164002
|
payloadStorePolicies: () => payloadStorePolicies,
|
|
163940
164003
|
parseStructuralFqn: () => parseStructuralFqn,
|
|
163941
164004
|
parseProjectIdentityPreviewRequest: () => parseProjectIdentityPreviewRequest,
|
|
@@ -166593,7 +166656,7 @@ class StdioServerTransport {
|
|
|
166593
166656
|
}
|
|
166594
166657
|
|
|
166595
166658
|
// src/index.ts
|
|
166596
|
-
import
|
|
166659
|
+
import fs20 from "fs/promises";
|
|
166597
166660
|
|
|
166598
166661
|
// src/api-client.ts
|
|
166599
166662
|
init_config();
|
|
@@ -166703,7 +166766,7 @@ init_dist();
|
|
|
166703
166766
|
init_dist();
|
|
166704
166767
|
init_dist15();
|
|
166705
166768
|
init_dist();
|
|
166706
|
-
import
|
|
166769
|
+
import fs18 from "fs/promises";
|
|
166707
166770
|
import path30 from "path";
|
|
166708
166771
|
var _indexProjectTool = null;
|
|
166709
166772
|
function indexProjectTool() {
|
|
@@ -166988,7 +167051,7 @@ class EmbeddedApiClient {
|
|
|
166988
167051
|
end = start + 20;
|
|
166989
167052
|
}
|
|
166990
167053
|
const absolutePath = path30.join(workspace.project_path, file2);
|
|
166991
|
-
const content = await
|
|
167054
|
+
const content = await fs18.readFile(absolutePath, "utf-8");
|
|
166992
167055
|
const lines = content.split(/\r?\n/);
|
|
166993
167056
|
const slice = lines.slice(start - 1, Math.min(lines.length, end));
|
|
166994
167057
|
const formatted = slice.map((text3, idx) => ({ lineNumber: start + idx, content: text3 }));
|
|
@@ -167227,8 +167290,8 @@ class EmbeddedApiClient {
|
|
|
167227
167290
|
const finalProjectId = rawBase.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 128);
|
|
167228
167291
|
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR || path30.join(getGlobalDataDir(), "uploads");
|
|
167229
167292
|
const stagingDir = path30.resolve(uploadRoot, finalProjectId);
|
|
167230
|
-
await
|
|
167231
|
-
await
|
|
167293
|
+
await fs18.rm(stagingDir, { recursive: true, force: true });
|
|
167294
|
+
await fs18.mkdir(stagingDir, { recursive: true });
|
|
167232
167295
|
const WRITE_BATCH = 20;
|
|
167233
167296
|
for (let i = 0;i < params.files.length; i += WRITE_BATCH) {
|
|
167234
167297
|
await Promise.all(params.files.slice(i, i + WRITE_BATCH).map(async (file2) => {
|
|
@@ -167239,8 +167302,8 @@ class EmbeddedApiClient {
|
|
|
167239
167302
|
if (!dest.startsWith(stagingDir + path30.sep)) {
|
|
167240
167303
|
throw new Error(`Path escapes staging directory: ${file2.relativePath}`);
|
|
167241
167304
|
}
|
|
167242
|
-
await
|
|
167243
|
-
await
|
|
167305
|
+
await fs18.mkdir(path30.dirname(dest), { recursive: true });
|
|
167306
|
+
await fs18.writeFile(dest, file2.content, "utf-8");
|
|
167244
167307
|
}));
|
|
167245
167308
|
}
|
|
167246
167309
|
return await indexProjectTool().handle({
|
|
@@ -167584,7 +167647,7 @@ class EmbeddedApiClient {
|
|
|
167584
167647
|
|
|
167585
167648
|
// src/file-collector.ts
|
|
167586
167649
|
init_config();
|
|
167587
|
-
import
|
|
167650
|
+
import fs19 from "fs/promises";
|
|
167588
167651
|
import path31 from "path";
|
|
167589
167652
|
var SKIP_DIRS = new Set([
|
|
167590
167653
|
"node_modules",
|
|
@@ -167626,7 +167689,7 @@ async function walk2(root2, dir, files, state, allowed) {
|
|
|
167626
167689
|
return;
|
|
167627
167690
|
let entries;
|
|
167628
167691
|
try {
|
|
167629
|
-
entries = await
|
|
167692
|
+
entries = await fs19.readdir(dir, { withFileTypes: true });
|
|
167630
167693
|
} catch {
|
|
167631
167694
|
return;
|
|
167632
167695
|
}
|
|
@@ -167643,12 +167706,12 @@ async function walk2(root2, dir, files, state, allowed) {
|
|
|
167643
167706
|
continue;
|
|
167644
167707
|
const fullPath = path31.join(dir, entry2.name);
|
|
167645
167708
|
try {
|
|
167646
|
-
const stat = await
|
|
167709
|
+
const stat = await fs19.stat(fullPath);
|
|
167647
167710
|
if (stat.size > MAX_FILE_BYTES)
|
|
167648
167711
|
continue;
|
|
167649
167712
|
if (state.totalBytes + stat.size > MAX_TOTAL_BYTES)
|
|
167650
167713
|
continue;
|
|
167651
|
-
const content = await
|
|
167714
|
+
const content = await fs19.readFile(fullPath, "utf-8");
|
|
167652
167715
|
state.totalBytes += stat.size;
|
|
167653
167716
|
const relativePath = path31.relative(root2, fullPath).split(path31.sep).join("/");
|
|
167654
167717
|
files.push({ relativePath, content });
|
|
@@ -169551,7 +169614,7 @@ class McpProxyServer {
|
|
|
169551
169614
|
return textContent(JSON.stringify({ success: false, error: "projectPath is required" }));
|
|
169552
169615
|
}
|
|
169553
169616
|
try {
|
|
169554
|
-
if (!(await
|
|
169617
|
+
if (!(await fs20.stat(projectPath2)).isDirectory()) {
|
|
169555
169618
|
return textContent(JSON.stringify({ success: false, error: `${projectPath2} is not a directory` }));
|
|
169556
169619
|
}
|
|
169557
169620
|
} catch {
|