@massa-ai/mcp-client 1.36.0 → 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 +288 -181
- package/dist/index.js +316 -274
- 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) {
|
|
@@ -124350,7 +124456,7 @@ function stripNul(content) {
|
|
|
124350
124456
|
}
|
|
124351
124457
|
|
|
124352
124458
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
124353
|
-
import
|
|
124459
|
+
import fs9 from "fs/promises";
|
|
124354
124460
|
import path14 from "path";
|
|
124355
124461
|
import { createHash as createHash5 } from "crypto";
|
|
124356
124462
|
|
|
@@ -124438,8 +124544,8 @@ class DiscoverStage {
|
|
|
124438
124544
|
async processFile(ctx, relativePath, forceReindex) {
|
|
124439
124545
|
const absolutePath = path14.join(ctx.projectPath, relativePath);
|
|
124440
124546
|
try {
|
|
124441
|
-
const stat = await
|
|
124442
|
-
const content = stripNul(await
|
|
124547
|
+
const stat = await fs9.stat(absolutePath);
|
|
124548
|
+
const content = stripNul(await fs9.readFile(absolutePath, "utf-8"));
|
|
124443
124549
|
const contentHash = createHash5("sha256").update(content).digest("hex");
|
|
124444
124550
|
let needsReparse = forceReindex;
|
|
124445
124551
|
if (!forceReindex) {
|
|
@@ -124483,7 +124589,7 @@ class DiscoverStage {
|
|
|
124483
124589
|
}
|
|
124484
124590
|
try {
|
|
124485
124591
|
const gitignorePath = path14.join(projectPath, ".gitignore");
|
|
124486
|
-
const gitignoreContent = await
|
|
124592
|
+
const gitignoreContent = await fs9.readFile(gitignorePath, "utf8");
|
|
124487
124593
|
const rules = gitignoreContent.split(`
|
|
124488
124594
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
124489
124595
|
ig.add(rules);
|
|
@@ -126812,7 +126918,7 @@ var init_structural_runtime = __esm(() => {
|
|
|
126812
126918
|
|
|
126813
126919
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
126814
126920
|
import path15 from "path";
|
|
126815
|
-
import
|
|
126921
|
+
import fs10 from "fs/promises";
|
|
126816
126922
|
function resolveChunkerMaxChars() {
|
|
126817
126923
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
126818
126924
|
if (Number.isFinite(global2) && global2 > 0)
|
|
@@ -126904,7 +127010,7 @@ class ParseStage {
|
|
|
126904
127010
|
if (!file2.needsReparse) {
|
|
126905
127011
|
const extension = path15.extname(file2.relativePath).toLowerCase();
|
|
126906
127012
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
126907
|
-
const content = file2.snapshotContent ?? await
|
|
127013
|
+
const content = file2.snapshotContent ?? await fs10.readFile(file2.absolutePath, "utf8");
|
|
126908
127014
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
126909
127015
|
if (outcome.status === "failed")
|
|
126910
127016
|
throw new StructuralEtlParseError(file2.relativePath, outcome.failureKind, `Structural evidence parse failed (${outcome.failureKind})`, outcome.diagnosticCount, outcome.diagnostics.slice(0, 10));
|
|
@@ -126916,7 +127022,7 @@ class ParseStage {
|
|
|
126916
127022
|
return { file: file2, chunks: [], symbols: [], rawImports: [], rawEdges: [] };
|
|
126917
127023
|
}
|
|
126918
127024
|
try {
|
|
126919
|
-
const content = file2.snapshotContent ?? await
|
|
127025
|
+
const content = file2.snapshotContent ?? await fs10.readFile(file2.absolutePath, "utf-8");
|
|
126920
127026
|
const ext2 = path15.extname(file2.relativePath).toLowerCase();
|
|
126921
127027
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
126922
127028
|
const chunks = smartChunk(content, file2.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
@@ -127957,7 +128063,7 @@ var init_data_document2 = __esm(() => {
|
|
|
127957
128063
|
|
|
127958
128064
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
127959
128065
|
import path18 from "path";
|
|
127960
|
-
import
|
|
128066
|
+
import fs11 from "fs";
|
|
127961
128067
|
|
|
127962
128068
|
class ResolveStage {
|
|
127963
128069
|
symbolRepository;
|
|
@@ -128274,7 +128380,7 @@ class ResolveStage {
|
|
|
128274
128380
|
const aliases = [];
|
|
128275
128381
|
const tsconfigPath = path18.join(projectPath, "tsconfig.json");
|
|
128276
128382
|
try {
|
|
128277
|
-
const raw2 =
|
|
128383
|
+
const raw2 = fs11.readFileSync(tsconfigPath, "utf-8");
|
|
128278
128384
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
128279
128385
|
const tsconfig = JSON.parse(stripped);
|
|
128280
128386
|
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
@@ -130697,7 +130803,7 @@ __export(exports_symbol_graph_service, {
|
|
|
130697
130803
|
SymbolGraphService: () => SymbolGraphService
|
|
130698
130804
|
});
|
|
130699
130805
|
import path22 from "path";
|
|
130700
|
-
import
|
|
130806
|
+
import fs12 from "fs/promises";
|
|
130701
130807
|
|
|
130702
130808
|
class SymbolGraphService {
|
|
130703
130809
|
identityLookup;
|
|
@@ -131025,7 +131131,7 @@ class SymbolGraphService {
|
|
|
131025
131131
|
async readSnippet(relativePath, lineStart, lineEnd, projectId) {
|
|
131026
131132
|
try {
|
|
131027
131133
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
131028
|
-
const content = await
|
|
131134
|
+
const content = await fs12.readFile(absolutePath, "utf-8");
|
|
131029
131135
|
const lines = content.split(`
|
|
131030
131136
|
`);
|
|
131031
131137
|
return lines.slice(Math.max(0, lineStart - 1), Math.min(lines.length, lineEnd)).join(`
|
|
@@ -131037,7 +131143,7 @@ class SymbolGraphService {
|
|
|
131037
131143
|
async readContext(relativePath, lineNumber, contextLines, projectId) {
|
|
131038
131144
|
try {
|
|
131039
131145
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
131040
|
-
const content = await
|
|
131146
|
+
const content = await fs12.readFile(absolutePath, "utf-8");
|
|
131041
131147
|
const lines = content.split(`
|
|
131042
131148
|
`);
|
|
131043
131149
|
const start = Math.max(0, lineNumber - contextLines - 1);
|
|
@@ -136882,7 +136988,7 @@ var init_session_pin_store = __esm(() => {
|
|
|
136882
136988
|
});
|
|
136883
136989
|
|
|
136884
136990
|
// ../../packages/core/dist/services/hooks/attribution-resolver.js
|
|
136885
|
-
import
|
|
136991
|
+
import fs13 from "fs";
|
|
136886
136992
|
import os6 from "os";
|
|
136887
136993
|
import path24 from "path";
|
|
136888
136994
|
|
|
@@ -136909,9 +137015,7 @@ class PgWorkspaceRootProvider {
|
|
|
136909
137015
|
this.cache = { roots, expiresAt: this.now() + PROVIDER_TTL_MS };
|
|
136910
137016
|
return roots;
|
|
136911
137017
|
} catch (error51) {
|
|
136912
|
-
logger.warn("[hook-attribution] workspace roots lookup failed; containment disabled (
|
|
136913
|
-
name: error51 instanceof Error ? error51.name : "unknown"
|
|
136914
|
-
});
|
|
137018
|
+
logger.warn("[hook-attribution] workspace roots lookup failed; containment disabled", safeErrorSummary(error51));
|
|
136915
137019
|
return [];
|
|
136916
137020
|
} finally {
|
|
136917
137021
|
if (timer)
|
|
@@ -137020,7 +137124,7 @@ class AttributionResolver {
|
|
|
137020
137124
|
}
|
|
137021
137125
|
function defaultCanonicalize(cwd) {
|
|
137022
137126
|
try {
|
|
137023
|
-
return
|
|
137127
|
+
return fs13.realpathSync(cwd);
|
|
137024
137128
|
} catch {
|
|
137025
137129
|
try {
|
|
137026
137130
|
return path24.resolve(cwd);
|
|
@@ -137039,75 +137143,10 @@ var init_attribution_resolver = __esm(() => {
|
|
|
137039
137143
|
init_dist();
|
|
137040
137144
|
init_db_connection();
|
|
137041
137145
|
init_alias_resolver();
|
|
137146
|
+
init_safe_error_summary();
|
|
137042
137147
|
init_session_pin_store();
|
|
137043
137148
|
});
|
|
137044
137149
|
|
|
137045
|
-
// ../../packages/core/dist/kernel/sanitize/credential-scrub.js
|
|
137046
|
-
function markerFor(id) {
|
|
137047
|
-
return `[REDACTED:${id}]`;
|
|
137048
|
-
}
|
|
137049
|
-
function fullMatchRule(id, pattern) {
|
|
137050
|
-
const marker26 = markerFor(id);
|
|
137051
|
-
return {
|
|
137052
|
-
id,
|
|
137053
|
-
replace(text3) {
|
|
137054
|
-
let count = 0;
|
|
137055
|
-
const replaced = text3.replace(pattern, () => {
|
|
137056
|
-
count++;
|
|
137057
|
-
return marker26;
|
|
137058
|
-
});
|
|
137059
|
-
return { text: replaced, count };
|
|
137060
|
-
}
|
|
137061
|
-
};
|
|
137062
|
-
}
|
|
137063
|
-
function scrubCredentials(payloadJson) {
|
|
137064
|
-
const redactions = {};
|
|
137065
|
-
for (const id of RULE_IDS)
|
|
137066
|
-
redactions[id] = 0;
|
|
137067
|
-
let text3 = payloadJson;
|
|
137068
|
-
for (const rule of RULES) {
|
|
137069
|
-
const { text: next, count } = rule.replace(text3);
|
|
137070
|
-
text3 = next;
|
|
137071
|
-
redactions[rule.id] += count;
|
|
137072
|
-
}
|
|
137073
|
-
const total = Object.values(redactions).reduce((sum, n) => sum + n, 0);
|
|
137074
|
-
return {
|
|
137075
|
-
sanitized: text3,
|
|
137076
|
-
redactions,
|
|
137077
|
-
total
|
|
137078
|
-
};
|
|
137079
|
-
}
|
|
137080
|
-
var PEM_PATTERN, JWT_PATTERN, AWS_KEY_PATTERN, SK_KEY_PATTERN, GITHUB_TOKEN_PATTERN, SLACK_TOKEN_PATTERN, BEARER_PATTERN, RULES, RULE_IDS;
|
|
137081
|
-
var init_credential_scrub = __esm(() => {
|
|
137082
|
-
PEM_PATTERN = /-----BEGIN [A-Z ]{0,32}PRIVATE KEY-----[\s\S]{0,8192}?-----END [A-Z ]{0,32}PRIVATE KEY-----/g;
|
|
137083
|
-
JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
|
|
137084
|
-
AWS_KEY_PATTERN = /\b(?:AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16}\b/g;
|
|
137085
|
-
SK_KEY_PATTERN = /\bsk-[A-Za-z0-9_-]{20,}\b/g;
|
|
137086
|
-
GITHUB_TOKEN_PATTERN = /\bgh[pousr]_[A-Za-z0-9]{36,}\b|\bgithub_pat_[A-Za-z0-9_]{22,}\b/g;
|
|
137087
|
-
SLACK_TOKEN_PATTERN = /\bxox[baprs]-[A-Za-z0-9-]{18,}\b/g;
|
|
137088
|
-
BEARER_PATTERN = /(Bearer\s+)([A-Za-z0-9._~+/=-]{20,})/g;
|
|
137089
|
-
RULES = [
|
|
137090
|
-
fullMatchRule("pem", PEM_PATTERN),
|
|
137091
|
-
fullMatchRule("jwt", JWT_PATTERN),
|
|
137092
|
-
fullMatchRule("aws-key", AWS_KEY_PATTERN),
|
|
137093
|
-
fullMatchRule("sk-key", SK_KEY_PATTERN),
|
|
137094
|
-
fullMatchRule("github-token", GITHUB_TOKEN_PATTERN),
|
|
137095
|
-
fullMatchRule("slack-token", SLACK_TOKEN_PATTERN),
|
|
137096
|
-
{
|
|
137097
|
-
id: "bearer",
|
|
137098
|
-
replace(text3) {
|
|
137099
|
-
let count = 0;
|
|
137100
|
-
const replaced = text3.replace(BEARER_PATTERN, (_m, prefix) => {
|
|
137101
|
-
count++;
|
|
137102
|
-
return `${prefix}${markerFor("bearer")}`;
|
|
137103
|
-
});
|
|
137104
|
-
return { text: replaced, count };
|
|
137105
|
-
}
|
|
137106
|
-
}
|
|
137107
|
-
];
|
|
137108
|
-
RULE_IDS = RULES.map((r) => r.id);
|
|
137109
|
-
});
|
|
137110
|
-
|
|
137111
137150
|
// ../../packages/core/dist/tools/compact_snapshot.js
|
|
137112
137151
|
class CompactSnapshotTool {
|
|
137113
137152
|
name = "compact_snapshot";
|
|
@@ -138693,7 +138732,7 @@ var init_get_architecture = __esm(() => {
|
|
|
138693
138732
|
});
|
|
138694
138733
|
|
|
138695
138734
|
// ../../packages/core/dist/services/file-read/file-content-cache.js
|
|
138696
|
-
import
|
|
138735
|
+
import fs14 from "fs/promises";
|
|
138697
138736
|
|
|
138698
138737
|
class FileContentCache {
|
|
138699
138738
|
extractMetadata;
|
|
@@ -138726,7 +138765,7 @@ class FileContentCache {
|
|
|
138726
138765
|
metadata: cached2.metadata
|
|
138727
138766
|
};
|
|
138728
138767
|
}
|
|
138729
|
-
const content = await
|
|
138768
|
+
const content = await fs14.readFile(filePath, "utf-8");
|
|
138730
138769
|
const metadata = await this.extractMetadata(content, filePath, options);
|
|
138731
138770
|
evictOldest(this.fileCache, this.FILE_CACHE_MAX_ENTRIES - 1);
|
|
138732
138771
|
this.fileCache.set(cacheKey, {
|
|
@@ -142151,7 +142190,7 @@ var init_l1_memory_cache = __esm(() => {
|
|
|
142151
142190
|
});
|
|
142152
142191
|
|
|
142153
142192
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
142154
|
-
import
|
|
142193
|
+
import fs15 from "fs/promises";
|
|
142155
142194
|
import { existsSync as existsSync3 } from "fs";
|
|
142156
142195
|
import path27 from "path";
|
|
142157
142196
|
|
|
@@ -142187,10 +142226,10 @@ class LocalHealthChecker {
|
|
|
142187
142226
|
const start = Date.now();
|
|
142188
142227
|
try {
|
|
142189
142228
|
if (!existsSync3(this.dataDir))
|
|
142190
|
-
await
|
|
142229
|
+
await fs15.mkdir(this.dataDir, { recursive: true });
|
|
142191
142230
|
const probe2 = path27.join(this.dataDir, ".health-check-test");
|
|
142192
|
-
await
|
|
142193
|
-
await
|
|
142231
|
+
await fs15.writeFile(probe2, "ok");
|
|
142232
|
+
await fs15.unlink(probe2);
|
|
142194
142233
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
142195
142234
|
} catch (error51) {
|
|
142196
142235
|
return { available: false, latency: Date.now() - start, error: `Data directory error: ${error51.message}` };
|
|
@@ -144129,7 +144168,7 @@ var init_scheduler2 = __esm(() => {
|
|
|
144129
144168
|
});
|
|
144130
144169
|
|
|
144131
144170
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
144132
|
-
import
|
|
144171
|
+
import fs16 from "fs/promises";
|
|
144133
144172
|
import { existsSync as existsSync4 } from "fs";
|
|
144134
144173
|
import path28 from "path";
|
|
144135
144174
|
function getModelsDevClient() {
|
|
@@ -144159,7 +144198,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
144159
144198
|
if (!existsSync4(cachePath)) {
|
|
144160
144199
|
return null;
|
|
144161
144200
|
}
|
|
144162
|
-
const content = await
|
|
144201
|
+
const content = await fs16.readFile(cachePath, "utf-8");
|
|
144163
144202
|
const data = JSON.parse(content);
|
|
144164
144203
|
const age = Date.now() - data.timestamp;
|
|
144165
144204
|
if (age > ModelsDevClient.LOCAL_CACHE_TTL) {
|
|
@@ -144187,13 +144226,13 @@ var init_models_dev_client = __esm(() => {
|
|
|
144187
144226
|
const cachePath = this.getLocalCachePath();
|
|
144188
144227
|
try {
|
|
144189
144228
|
const dir = path28.dirname(cachePath);
|
|
144190
|
-
await
|
|
144229
|
+
await fs16.mkdir(dir, { recursive: true });
|
|
144191
144230
|
const data = {
|
|
144192
144231
|
timestamp: Date.now(),
|
|
144193
144232
|
version: "1.0.0",
|
|
144194
144233
|
models: Object.fromEntries(models)
|
|
144195
144234
|
};
|
|
144196
|
-
await
|
|
144235
|
+
await fs16.writeFile(cachePath, JSON.stringify(data), "utf-8");
|
|
144197
144236
|
logger.debug("Saved pricing to local cache", {
|
|
144198
144237
|
models: models.size,
|
|
144199
144238
|
path: cachePath
|
|
@@ -144522,7 +144561,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
144522
144561
|
const cachePath = this.getLocalCachePath();
|
|
144523
144562
|
try {
|
|
144524
144563
|
if (existsSync4(cachePath)) {
|
|
144525
|
-
await
|
|
144564
|
+
await fs16.unlink(cachePath);
|
|
144526
144565
|
logger.debug("Local pricing cache file deleted");
|
|
144527
144566
|
}
|
|
144528
144567
|
} catch (error51) {
|
|
@@ -162529,6 +162568,7 @@ var init_services = __esm(() => {
|
|
|
162529
162568
|
init_search_analytics_pg();
|
|
162530
162569
|
init_index_manager();
|
|
162531
162570
|
init_search_diagnostics();
|
|
162571
|
+
init_safe_error_summary();
|
|
162532
162572
|
init_memory_controller();
|
|
162533
162573
|
init_llm_client();
|
|
162534
162574
|
init_search_controller();
|
|
@@ -162966,7 +163006,7 @@ var init_hook_service = __esm(() => {
|
|
|
162966
163006
|
|
|
162967
163007
|
// ../../packages/core/dist/services/bootstrap/bootstrap-service.js
|
|
162968
163008
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
162969
|
-
import
|
|
163009
|
+
import fs17 from "fs";
|
|
162970
163010
|
import path29 from "path";
|
|
162971
163011
|
import { spawn as spawn2 } from "child_process";
|
|
162972
163012
|
function readBootstrapConfig() {
|
|
@@ -163128,8 +163168,8 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
163128
163168
|
try {
|
|
163129
163169
|
for (const name26 of README_CANDIDATES) {
|
|
163130
163170
|
const p = path29.join(projectRoot, name26);
|
|
163131
|
-
if (
|
|
163132
|
-
const buf =
|
|
163171
|
+
if (fs17.existsSync(p) && fs17.statSync(p).isFile()) {
|
|
163172
|
+
const buf = fs17.readFileSync(p);
|
|
163133
163173
|
signals.readme = buf.slice(0, MAX_README_BYTES).toString("utf8");
|
|
163134
163174
|
break;
|
|
163135
163175
|
}
|
|
@@ -163139,11 +163179,11 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
163139
163179
|
}
|
|
163140
163180
|
try {
|
|
163141
163181
|
const docsDir = path29.join(projectRoot, "docs");
|
|
163142
|
-
if (
|
|
163182
|
+
if (fs17.existsSync(docsDir) && fs17.statSync(docsDir).isDirectory()) {
|
|
163143
163183
|
const entries = walkMarkdown(docsDir).slice(0, MAX_DOCS);
|
|
163144
163184
|
for (const rel of entries) {
|
|
163145
163185
|
try {
|
|
163146
|
-
const buf =
|
|
163186
|
+
const buf = fs17.readFileSync(rel);
|
|
163147
163187
|
signals.docs.push({
|
|
163148
163188
|
path: path29.relative(projectRoot, rel),
|
|
163149
163189
|
snippet: buf.slice(0, MAX_DOC_BYTES).toString("utf8")
|
|
@@ -163157,9 +163197,9 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
163157
163197
|
try {
|
|
163158
163198
|
for (const name26 of MANIFEST_FILES) {
|
|
163159
163199
|
const p = path29.join(projectRoot, name26);
|
|
163160
|
-
if (!
|
|
163200
|
+
if (!fs17.existsSync(p) || !fs17.statSync(p).isFile())
|
|
163161
163201
|
continue;
|
|
163162
|
-
const raw2 =
|
|
163202
|
+
const raw2 = fs17.readFileSync(p).slice(0, MAX_MANIFEST_BYTES).toString("utf8");
|
|
163163
163203
|
const kind = name26;
|
|
163164
163204
|
if (name26 === "package.json") {
|
|
163165
163205
|
try {
|
|
@@ -163199,7 +163239,7 @@ function walkMarkdown(dir) {
|
|
|
163199
163239
|
const cur = stack.pop();
|
|
163200
163240
|
let entries;
|
|
163201
163241
|
try {
|
|
163202
|
-
entries =
|
|
163242
|
+
entries = fs17.readdirSync(cur, { withFileTypes: true });
|
|
163203
163243
|
} catch {
|
|
163204
163244
|
continue;
|
|
163205
163245
|
}
|
|
@@ -163934,6 +163974,7 @@ __export(exports_dist, {
|
|
|
163934
163974
|
searchSessionHook: () => searchSessionHook,
|
|
163935
163975
|
searchBackendUnavailable: () => searchBackendUnavailable,
|
|
163936
163976
|
scanSignals: () => scanSignals,
|
|
163977
|
+
safeErrorSummary: () => safeErrorSummary,
|
|
163937
163978
|
runPool: () => runPool,
|
|
163938
163979
|
ruleBasedSeed: () => ruleBasedSeed,
|
|
163939
163980
|
resolveStructuralParseLanguage: () => resolveStructuralParseLanguage,
|
|
@@ -163957,6 +163998,7 @@ __export(exports_dist, {
|
|
|
163957
163998
|
recordSearchFailure: () => recordSearchFailure,
|
|
163958
163999
|
recordSearchDegradation: () => recordSearchDegradation,
|
|
163959
164000
|
quoteDiscoveredIdentifier: () => quoteDiscoveredIdentifier,
|
|
164001
|
+
projectNotIndexed: () => projectNotIndexed,
|
|
163960
164002
|
payloadStorePolicies: () => payloadStorePolicies,
|
|
163961
164003
|
parseStructuralFqn: () => parseStructuralFqn,
|
|
163962
164004
|
parseProjectIdentityPreviewRequest: () => parseProjectIdentityPreviewRequest,
|
|
@@ -166614,7 +166656,7 @@ class StdioServerTransport {
|
|
|
166614
166656
|
}
|
|
166615
166657
|
|
|
166616
166658
|
// src/index.ts
|
|
166617
|
-
import
|
|
166659
|
+
import fs20 from "fs/promises";
|
|
166618
166660
|
|
|
166619
166661
|
// src/api-client.ts
|
|
166620
166662
|
init_config();
|
|
@@ -166724,7 +166766,7 @@ init_dist();
|
|
|
166724
166766
|
init_dist();
|
|
166725
166767
|
init_dist15();
|
|
166726
166768
|
init_dist();
|
|
166727
|
-
import
|
|
166769
|
+
import fs18 from "fs/promises";
|
|
166728
166770
|
import path30 from "path";
|
|
166729
166771
|
var _indexProjectTool = null;
|
|
166730
166772
|
function indexProjectTool() {
|
|
@@ -167009,7 +167051,7 @@ class EmbeddedApiClient {
|
|
|
167009
167051
|
end = start + 20;
|
|
167010
167052
|
}
|
|
167011
167053
|
const absolutePath = path30.join(workspace.project_path, file2);
|
|
167012
|
-
const content = await
|
|
167054
|
+
const content = await fs18.readFile(absolutePath, "utf-8");
|
|
167013
167055
|
const lines = content.split(/\r?\n/);
|
|
167014
167056
|
const slice = lines.slice(start - 1, Math.min(lines.length, end));
|
|
167015
167057
|
const formatted = slice.map((text3, idx) => ({ lineNumber: start + idx, content: text3 }));
|
|
@@ -167248,8 +167290,8 @@ class EmbeddedApiClient {
|
|
|
167248
167290
|
const finalProjectId = rawBase.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 128);
|
|
167249
167291
|
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR || path30.join(getGlobalDataDir(), "uploads");
|
|
167250
167292
|
const stagingDir = path30.resolve(uploadRoot, finalProjectId);
|
|
167251
|
-
await
|
|
167252
|
-
await
|
|
167293
|
+
await fs18.rm(stagingDir, { recursive: true, force: true });
|
|
167294
|
+
await fs18.mkdir(stagingDir, { recursive: true });
|
|
167253
167295
|
const WRITE_BATCH = 20;
|
|
167254
167296
|
for (let i = 0;i < params.files.length; i += WRITE_BATCH) {
|
|
167255
167297
|
await Promise.all(params.files.slice(i, i + WRITE_BATCH).map(async (file2) => {
|
|
@@ -167260,8 +167302,8 @@ class EmbeddedApiClient {
|
|
|
167260
167302
|
if (!dest.startsWith(stagingDir + path30.sep)) {
|
|
167261
167303
|
throw new Error(`Path escapes staging directory: ${file2.relativePath}`);
|
|
167262
167304
|
}
|
|
167263
|
-
await
|
|
167264
|
-
await
|
|
167305
|
+
await fs18.mkdir(path30.dirname(dest), { recursive: true });
|
|
167306
|
+
await fs18.writeFile(dest, file2.content, "utf-8");
|
|
167265
167307
|
}));
|
|
167266
167308
|
}
|
|
167267
167309
|
return await indexProjectTool().handle({
|
|
@@ -167605,7 +167647,7 @@ class EmbeddedApiClient {
|
|
|
167605
167647
|
|
|
167606
167648
|
// src/file-collector.ts
|
|
167607
167649
|
init_config();
|
|
167608
|
-
import
|
|
167650
|
+
import fs19 from "fs/promises";
|
|
167609
167651
|
import path31 from "path";
|
|
167610
167652
|
var SKIP_DIRS = new Set([
|
|
167611
167653
|
"node_modules",
|
|
@@ -167647,7 +167689,7 @@ async function walk2(root2, dir, files, state, allowed) {
|
|
|
167647
167689
|
return;
|
|
167648
167690
|
let entries;
|
|
167649
167691
|
try {
|
|
167650
|
-
entries = await
|
|
167692
|
+
entries = await fs19.readdir(dir, { withFileTypes: true });
|
|
167651
167693
|
} catch {
|
|
167652
167694
|
return;
|
|
167653
167695
|
}
|
|
@@ -167664,12 +167706,12 @@ async function walk2(root2, dir, files, state, allowed) {
|
|
|
167664
167706
|
continue;
|
|
167665
167707
|
const fullPath = path31.join(dir, entry2.name);
|
|
167666
167708
|
try {
|
|
167667
|
-
const stat = await
|
|
167709
|
+
const stat = await fs19.stat(fullPath);
|
|
167668
167710
|
if (stat.size > MAX_FILE_BYTES)
|
|
167669
167711
|
continue;
|
|
167670
167712
|
if (state.totalBytes + stat.size > MAX_TOTAL_BYTES)
|
|
167671
167713
|
continue;
|
|
167672
|
-
const content = await
|
|
167714
|
+
const content = await fs19.readFile(fullPath, "utf-8");
|
|
167673
167715
|
state.totalBytes += stat.size;
|
|
167674
167716
|
const relativePath = path31.relative(root2, fullPath).split(path31.sep).join("/");
|
|
167675
167717
|
files.push({ relativePath, content });
|
|
@@ -169572,7 +169614,7 @@ class McpProxyServer {
|
|
|
169572
169614
|
return textContent(JSON.stringify({ success: false, error: "projectPath is required" }));
|
|
169573
169615
|
}
|
|
169574
169616
|
try {
|
|
169575
|
-
if (!(await
|
|
169617
|
+
if (!(await fs20.stat(projectPath2)).isDirectory()) {
|
|
169576
169618
|
return textContent(JSON.stringify({ success: false, error: `${projectPath2} is not a directory` }));
|
|
169577
169619
|
}
|
|
169578
169620
|
} catch {
|