@massa-ai/tools-api 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/index.js +345 -273
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1263,7 +1263,8 @@ var init_config = __esm(() => {
|
|
|
1263
1263
|
},
|
|
1264
1264
|
logging: {
|
|
1265
1265
|
level: process.env.LOG_LEVEL || fileConfig.logging?.level || "info",
|
|
1266
|
-
enableMetrics: process.env.ENABLE_METRICS === "true" || process.env.ENABLE_METRICS === undefined && !!fileConfig.logging?.enableMetrics
|
|
1266
|
+
enableMetrics: process.env.ENABLE_METRICS === "true" || process.env.ENABLE_METRICS === undefined && !!fileConfig.logging?.enableMetrics,
|
|
1267
|
+
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file || undefined
|
|
1267
1268
|
},
|
|
1268
1269
|
synapse: {
|
|
1269
1270
|
enabled: process.env.SYNAPSE_ENABLED !== "false",
|
|
@@ -6602,20 +6603,25 @@ var init_types = __esm(() => {
|
|
|
6602
6603
|
var init_interfaces = () => {};
|
|
6603
6604
|
|
|
6604
6605
|
// ../../packages/shared/dist/utils/logger.js
|
|
6606
|
+
import fs3 from "fs";
|
|
6607
|
+
|
|
6605
6608
|
class Logger {
|
|
6606
6609
|
_level;
|
|
6607
6610
|
_enableMetrics;
|
|
6611
|
+
_logFilePath;
|
|
6608
6612
|
_initialized = false;
|
|
6609
6613
|
constructor() {}
|
|
6610
6614
|
ensureInitialized() {
|
|
6611
6615
|
if (!this._initialized) {
|
|
6612
6616
|
try {
|
|
6613
|
-
const
|
|
6614
|
-
this._level = this.parseLogLevel(
|
|
6615
|
-
this._enableMetrics =
|
|
6617
|
+
const loggingConfig = config.get("logging");
|
|
6618
|
+
this._level = this.parseLogLevel(loggingConfig.level);
|
|
6619
|
+
this._enableMetrics = loggingConfig.enableMetrics;
|
|
6620
|
+
this._logFilePath = loggingConfig.file;
|
|
6616
6621
|
} catch {
|
|
6617
6622
|
this._level = LogLevel.INFO;
|
|
6618
6623
|
this._enableMetrics = false;
|
|
6624
|
+
this._logFilePath = undefined;
|
|
6619
6625
|
}
|
|
6620
6626
|
this._initialized = true;
|
|
6621
6627
|
}
|
|
@@ -6628,6 +6634,10 @@ class Logger {
|
|
|
6628
6634
|
this.ensureInitialized();
|
|
6629
6635
|
return this._enableMetrics;
|
|
6630
6636
|
}
|
|
6637
|
+
get logFilePath() {
|
|
6638
|
+
this.ensureInitialized();
|
|
6639
|
+
return this._logFilePath;
|
|
6640
|
+
}
|
|
6631
6641
|
parseLogLevel(level) {
|
|
6632
6642
|
const levels = {
|
|
6633
6643
|
debug: LogLevel.DEBUG,
|
|
@@ -6647,6 +6657,13 @@ class Logger {
|
|
|
6647
6657
|
}
|
|
6648
6658
|
write(message, _level) {
|
|
6649
6659
|
console.error(message);
|
|
6660
|
+
const filePath = this.logFilePath;
|
|
6661
|
+
if (filePath) {
|
|
6662
|
+
try {
|
|
6663
|
+
fs3.appendFileSync(filePath, message + `
|
|
6664
|
+
`);
|
|
6665
|
+
} catch {}
|
|
6666
|
+
}
|
|
6650
6667
|
}
|
|
6651
6668
|
debug(message, meta) {
|
|
6652
6669
|
if (this.shouldLog(LogLevel.DEBUG)) {
|
|
@@ -7056,7 +7073,7 @@ var init_hosts = __esm(() => {
|
|
|
7056
7073
|
});
|
|
7057
7074
|
|
|
7058
7075
|
// ../../packages/shared/dist/profile-switch/state.js
|
|
7059
|
-
import
|
|
7076
|
+
import fs4 from "fs";
|
|
7060
7077
|
import path7 from "path";
|
|
7061
7078
|
function namedError(name, message) {
|
|
7062
7079
|
const err = new InstallStateError(message);
|
|
@@ -7083,7 +7100,7 @@ function validateShape(raw2, filePath) {
|
|
|
7083
7100
|
function readInstallState(filePath) {
|
|
7084
7101
|
let text;
|
|
7085
7102
|
try {
|
|
7086
|
-
text =
|
|
7103
|
+
text = fs4.readFileSync(filePath, "utf-8");
|
|
7087
7104
|
} catch (err) {
|
|
7088
7105
|
const code = err.code;
|
|
7089
7106
|
if (code === "ENOENT")
|
|
@@ -7103,8 +7120,8 @@ function writeInstallState(filePath, state) {
|
|
|
7103
7120
|
const text = `${JSON.stringify(validated, null, 2)}
|
|
7104
7121
|
`;
|
|
7105
7122
|
try {
|
|
7106
|
-
|
|
7107
|
-
|
|
7123
|
+
fs4.mkdirSync(path7.dirname(filePath), { recursive: true });
|
|
7124
|
+
fs4.writeFileSync(filePath, text);
|
|
7108
7125
|
} catch (err) {
|
|
7109
7126
|
throw UnwritableInstallStateError(filePath, err.message);
|
|
7110
7127
|
}
|
|
@@ -7131,7 +7148,7 @@ var init_state = __esm(() => {
|
|
|
7131
7148
|
});
|
|
7132
7149
|
|
|
7133
7150
|
// ../../packages/shared/dist/profile-switch/lock.js
|
|
7134
|
-
import
|
|
7151
|
+
import fs5 from "fs";
|
|
7135
7152
|
import path8 from "path";
|
|
7136
7153
|
import os4 from "os";
|
|
7137
7154
|
import crypto4 from "crypto";
|
|
@@ -7144,7 +7161,7 @@ function namedError2(name, message) {
|
|
|
7144
7161
|
function readOwner(ownerPath) {
|
|
7145
7162
|
let raw2;
|
|
7146
7163
|
try {
|
|
7147
|
-
raw2 = JSON.parse(
|
|
7164
|
+
raw2 = JSON.parse(fs5.readFileSync(ownerPath, "utf-8"));
|
|
7148
7165
|
} catch {
|
|
7149
7166
|
return null;
|
|
7150
7167
|
}
|
|
@@ -7160,7 +7177,7 @@ function releaseIfOwned(lockDir, ownerPath, token) {
|
|
|
7160
7177
|
const owner = readOwner(ownerPath);
|
|
7161
7178
|
if (owner === null || owner.token !== token)
|
|
7162
7179
|
return;
|
|
7163
|
-
|
|
7180
|
+
fs5.rmSync(lockDir, { recursive: true, force: true });
|
|
7164
7181
|
}
|
|
7165
7182
|
function acquireLock(stateFilePath, options = {}) {
|
|
7166
7183
|
const lockDir = `${stateFilePath}.switch.lock`;
|
|
@@ -7169,11 +7186,11 @@ function acquireLock(stateFilePath, options = {}) {
|
|
|
7169
7186
|
const identity = options.identity ?? DEFAULT_IDENTITY;
|
|
7170
7187
|
const staleAfterMs = options.staleAfterMs ?? DEFAULT_STALE_AFTER_MS;
|
|
7171
7188
|
const createFresh = () => {
|
|
7172
|
-
|
|
7189
|
+
fs5.mkdirSync(lockDir);
|
|
7173
7190
|
const pid = identity.pid();
|
|
7174
7191
|
const startedAt = identity.processStart(pid);
|
|
7175
7192
|
if (startedAt == null) {
|
|
7176
|
-
|
|
7193
|
+
fs5.rmSync(lockDir, { recursive: true, force: true });
|
|
7177
7194
|
throw LockAcquireError(lockDir, "could not determine this process's start-time identity");
|
|
7178
7195
|
}
|
|
7179
7196
|
const token = crypto4.randomUUID();
|
|
@@ -7184,8 +7201,8 @@ function acquireLock(stateFilePath, options = {}) {
|
|
|
7184
7201
|
token,
|
|
7185
7202
|
timestamp: clock.now()
|
|
7186
7203
|
};
|
|
7187
|
-
|
|
7188
|
-
|
|
7204
|
+
fs5.mkdirSync(path8.dirname(ownerPath), { recursive: true });
|
|
7205
|
+
fs5.writeFileSync(ownerPath, JSON.stringify(record));
|
|
7189
7206
|
return { lockDir, release: () => releaseIfOwned(lockDir, ownerPath, token) };
|
|
7190
7207
|
};
|
|
7191
7208
|
try {
|
|
@@ -7200,11 +7217,11 @@ function acquireLock(stateFilePath, options = {}) {
|
|
|
7200
7217
|
throw LockHeldError(lockDir);
|
|
7201
7218
|
const reclaimDir = `${lockDir}.reclaim.${owner.token}`;
|
|
7202
7219
|
try {
|
|
7203
|
-
|
|
7220
|
+
fs5.renameSync(lockDir, reclaimDir);
|
|
7204
7221
|
} catch {
|
|
7205
7222
|
throw LockHeldError(lockDir);
|
|
7206
7223
|
}
|
|
7207
|
-
|
|
7224
|
+
fs5.rmSync(reclaimDir, { recursive: true, force: true });
|
|
7208
7225
|
try {
|
|
7209
7226
|
return createFresh();
|
|
7210
7227
|
} catch {
|
|
@@ -7238,7 +7255,7 @@ var init_lock = __esm(() => {
|
|
|
7238
7255
|
});
|
|
7239
7256
|
|
|
7240
7257
|
// ../../packages/shared/dist/profile-switch/engine.js
|
|
7241
|
-
import
|
|
7258
|
+
import fs6 from "fs";
|
|
7242
7259
|
import path9 from "path";
|
|
7243
7260
|
import os5 from "os";
|
|
7244
7261
|
import crypto5 from "crypto";
|
|
@@ -7272,7 +7289,7 @@ function listProfiles(opts = {}) {
|
|
|
7272
7289
|
availableProfiles: []
|
|
7273
7290
|
};
|
|
7274
7291
|
}
|
|
7275
|
-
const installed =
|
|
7292
|
+
const installed = fs6.existsSync(layout.activeDir);
|
|
7276
7293
|
const availableProfiles = listVariantProfiles(layout);
|
|
7277
7294
|
const platform = state.platforms[host];
|
|
7278
7295
|
return {
|
|
@@ -7288,9 +7305,9 @@ function listProfiles(opts = {}) {
|
|
|
7288
7305
|
return { hosts };
|
|
7289
7306
|
}
|
|
7290
7307
|
function listVariantProfiles(layout) {
|
|
7291
|
-
if (!
|
|
7308
|
+
if (!fs6.existsSync(layout.variantsRoot))
|
|
7292
7309
|
return [];
|
|
7293
|
-
return
|
|
7310
|
+
return fs6.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
7294
7311
|
}
|
|
7295
7312
|
function matchesGlob(filename, glob) {
|
|
7296
7313
|
const starIdx = glob.indexOf("*");
|
|
@@ -7303,32 +7320,32 @@ function matchesGlob(filename, glob) {
|
|
|
7303
7320
|
function assertStateWritable(stateFilePath) {
|
|
7304
7321
|
const dir = path9.dirname(stateFilePath);
|
|
7305
7322
|
try {
|
|
7306
|
-
|
|
7323
|
+
fs6.mkdirSync(dir, { recursive: true });
|
|
7307
7324
|
} catch (err) {
|
|
7308
7325
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
7309
7326
|
}
|
|
7310
|
-
const checkPath =
|
|
7327
|
+
const checkPath = fs6.existsSync(stateFilePath) ? stateFilePath : dir;
|
|
7311
7328
|
try {
|
|
7312
|
-
|
|
7329
|
+
fs6.accessSync(checkPath, fs6.constants.W_OK);
|
|
7313
7330
|
} catch (err) {
|
|
7314
7331
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
7315
7332
|
}
|
|
7316
7333
|
}
|
|
7317
7334
|
function copyFileRouteVariant(layout, variantDir) {
|
|
7318
|
-
|
|
7335
|
+
fs6.mkdirSync(layout.activeDir, { recursive: true });
|
|
7319
7336
|
let changed = 0;
|
|
7320
|
-
for (const entry of
|
|
7337
|
+
for (const entry of fs6.readdirSync(variantDir, { withFileTypes: true })) {
|
|
7321
7338
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
7322
7339
|
continue;
|
|
7323
|
-
|
|
7340
|
+
fs6.copyFileSync(path9.join(variantDir, entry.name), path9.join(layout.activeDir, entry.name));
|
|
7324
7341
|
changed++;
|
|
7325
7342
|
}
|
|
7326
7343
|
return changed;
|
|
7327
7344
|
}
|
|
7328
7345
|
function repointOpencodeVariant(layout, variantDir) {
|
|
7329
|
-
|
|
7346
|
+
fs6.mkdirSync(layout.activeDir, { recursive: true });
|
|
7330
7347
|
let changed = 0;
|
|
7331
|
-
for (const entry of
|
|
7348
|
+
for (const entry of fs6.readdirSync(variantDir, { withFileTypes: true })) {
|
|
7332
7349
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
7333
7350
|
continue;
|
|
7334
7351
|
const dest = path9.join(layout.activeDir, entry.name);
|
|
@@ -7336,15 +7353,15 @@ function repointOpencodeVariant(layout, variantDir) {
|
|
|
7336
7353
|
let destExists = true;
|
|
7337
7354
|
let destIsSymlink = false;
|
|
7338
7355
|
try {
|
|
7339
|
-
destIsSymlink =
|
|
7356
|
+
destIsSymlink = fs6.lstatSync(dest).isSymbolicLink();
|
|
7340
7357
|
} catch {
|
|
7341
7358
|
destExists = false;
|
|
7342
7359
|
}
|
|
7343
7360
|
if (destExists && !destIsSymlink)
|
|
7344
7361
|
continue;
|
|
7345
7362
|
const tmp = `${dest}.massa-ai-switch.${crypto5.randomUUID()}`;
|
|
7346
|
-
|
|
7347
|
-
|
|
7363
|
+
fs6.symlinkSync(target, tmp);
|
|
7364
|
+
fs6.renameSync(tmp, dest);
|
|
7348
7365
|
changed++;
|
|
7349
7366
|
}
|
|
7350
7367
|
return changed;
|
|
@@ -7366,13 +7383,13 @@ function switchProfile(opts) {
|
|
|
7366
7383
|
if (fileHosts.length === 0) {
|
|
7367
7384
|
return { profile: opts.profile, dryRun, hosts: orderRows(universe, skipRows), restartRequired: false };
|
|
7368
7385
|
}
|
|
7369
|
-
const installedFileHosts = fileHosts.filter((h) =>
|
|
7386
|
+
const installedFileHosts = fileHosts.filter((h) => fs6.existsSync(h.layout.activeDir));
|
|
7370
7387
|
if (installedFileHosts.length === 0)
|
|
7371
7388
|
throw NoHostsDetectedError();
|
|
7372
7389
|
const withAvailability = fileHosts.map((h) => {
|
|
7373
|
-
const variantsRootExists =
|
|
7390
|
+
const variantsRootExists = fs6.existsSync(h.layout.variantsRoot);
|
|
7374
7391
|
const variantDir = h.layout.variantDir(opts.profile);
|
|
7375
|
-
const available = variantsRootExists &&
|
|
7392
|
+
const available = variantsRootExists && fs6.existsSync(variantDir) && fs6.statSync(variantDir).isDirectory();
|
|
7376
7393
|
return { ...h, variantsRootExists, variantDir, available };
|
|
7377
7394
|
});
|
|
7378
7395
|
if (!withAvailability.some((h) => h.available)) {
|
|
@@ -11580,8 +11597,8 @@ var init_esm4 = __esm(() => {
|
|
|
11580
11597
|
#children;
|
|
11581
11598
|
nocase;
|
|
11582
11599
|
#fs;
|
|
11583
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
11584
|
-
this.#fs = fsFromOption(
|
|
11600
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs7 = defaultFS } = {}) {
|
|
11601
|
+
this.#fs = fsFromOption(fs7);
|
|
11585
11602
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
11586
11603
|
cwd = fileURLToPath(cwd);
|
|
11587
11604
|
}
|
|
@@ -12056,8 +12073,8 @@ var init_esm4 = __esm(() => {
|
|
|
12056
12073
|
parseRootPath(dir) {
|
|
12057
12074
|
return win32.parse(dir).root.toUpperCase();
|
|
12058
12075
|
}
|
|
12059
|
-
newRoot(
|
|
12060
|
-
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
12076
|
+
newRoot(fs7) {
|
|
12077
|
+
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs7 });
|
|
12061
12078
|
}
|
|
12062
12079
|
isAbsolute(p) {
|
|
12063
12080
|
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
@@ -12073,8 +12090,8 @@ var init_esm4 = __esm(() => {
|
|
|
12073
12090
|
parseRootPath(_dir) {
|
|
12074
12091
|
return "/";
|
|
12075
12092
|
}
|
|
12076
|
-
newRoot(
|
|
12077
|
-
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
12093
|
+
newRoot(fs7) {
|
|
12094
|
+
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs7 });
|
|
12078
12095
|
}
|
|
12079
12096
|
isAbsolute(p) {
|
|
12080
12097
|
return p.startsWith("/");
|
|
@@ -13480,7 +13497,7 @@ var init_capture_policy = __esm(() => {
|
|
|
13480
13497
|
});
|
|
13481
13498
|
|
|
13482
13499
|
// ../../packages/core/dist/services/search/ignore-patterns.js
|
|
13483
|
-
import
|
|
13500
|
+
import fs7 from "fs/promises";
|
|
13484
13501
|
import path11 from "path";
|
|
13485
13502
|
function buildExtensionGlob(extensions2) {
|
|
13486
13503
|
return extensions2.map((ext2) => `**/*${ext2}`);
|
|
@@ -13505,7 +13522,7 @@ async function loadProjectIgnore(projectPath) {
|
|
|
13505
13522
|
ig.add(DEFAULT_IGNORES);
|
|
13506
13523
|
try {
|
|
13507
13524
|
const gitignorePath = path11.join(projectPath, ".gitignore");
|
|
13508
|
-
const gitignoreContent = await
|
|
13525
|
+
const gitignoreContent = await fs7.readFile(gitignorePath, "utf8");
|
|
13509
13526
|
const rules = gitignoreContent.split(`
|
|
13510
13527
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
13511
13528
|
ig.add(rules);
|
|
@@ -13587,6 +13604,89 @@ var init_db_connection = __esm(() => {
|
|
|
13587
13604
|
init_config();
|
|
13588
13605
|
});
|
|
13589
13606
|
|
|
13607
|
+
// ../../packages/core/dist/kernel/sanitize/credential-scrub.js
|
|
13608
|
+
function markerFor(id) {
|
|
13609
|
+
return `[REDACTED:${id}]`;
|
|
13610
|
+
}
|
|
13611
|
+
function fullMatchRule(id, pattern) {
|
|
13612
|
+
const marker = markerFor(id);
|
|
13613
|
+
return {
|
|
13614
|
+
id,
|
|
13615
|
+
replace(text) {
|
|
13616
|
+
let count = 0;
|
|
13617
|
+
const replaced = text.replace(pattern, () => {
|
|
13618
|
+
count++;
|
|
13619
|
+
return marker;
|
|
13620
|
+
});
|
|
13621
|
+
return { text: replaced, count };
|
|
13622
|
+
}
|
|
13623
|
+
};
|
|
13624
|
+
}
|
|
13625
|
+
function scrubCredentials(payloadJson) {
|
|
13626
|
+
const redactions = {};
|
|
13627
|
+
for (const id of RULE_IDS)
|
|
13628
|
+
redactions[id] = 0;
|
|
13629
|
+
let text = payloadJson;
|
|
13630
|
+
for (const rule of RULES) {
|
|
13631
|
+
const { text: next, count } = rule.replace(text);
|
|
13632
|
+
text = next;
|
|
13633
|
+
redactions[rule.id] += count;
|
|
13634
|
+
}
|
|
13635
|
+
const total = Object.values(redactions).reduce((sum, n2) => sum + n2, 0);
|
|
13636
|
+
return {
|
|
13637
|
+
sanitized: text,
|
|
13638
|
+
redactions,
|
|
13639
|
+
total
|
|
13640
|
+
};
|
|
13641
|
+
}
|
|
13642
|
+
var PEM_PATTERN, JWT_PATTERN, AWS_KEY_PATTERN, SK_KEY_PATTERN, GITHUB_TOKEN_PATTERN, SLACK_TOKEN_PATTERN, BEARER_PATTERN, RULES, RULE_IDS;
|
|
13643
|
+
var init_credential_scrub = __esm(() => {
|
|
13644
|
+
PEM_PATTERN = /-----BEGIN [A-Z ]{0,32}PRIVATE KEY-----[\s\S]{0,8192}?-----END [A-Z ]{0,32}PRIVATE KEY-----/g;
|
|
13645
|
+
JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
|
|
13646
|
+
AWS_KEY_PATTERN = /\b(?:AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16}\b/g;
|
|
13647
|
+
SK_KEY_PATTERN = /\bsk-[A-Za-z0-9_-]{20,}\b/g;
|
|
13648
|
+
GITHUB_TOKEN_PATTERN = /\bgh[pousr]_[A-Za-z0-9]{36,}\b|\bgithub_pat_[A-Za-z0-9_]{22,}\b/g;
|
|
13649
|
+
SLACK_TOKEN_PATTERN = /\bxox[baprs]-[A-Za-z0-9-]{18,}\b/g;
|
|
13650
|
+
BEARER_PATTERN = /(Bearer\s+)([A-Za-z0-9._~+/=-]{20,})/g;
|
|
13651
|
+
RULES = [
|
|
13652
|
+
fullMatchRule("pem", PEM_PATTERN),
|
|
13653
|
+
fullMatchRule("jwt", JWT_PATTERN),
|
|
13654
|
+
fullMatchRule("aws-key", AWS_KEY_PATTERN),
|
|
13655
|
+
fullMatchRule("sk-key", SK_KEY_PATTERN),
|
|
13656
|
+
fullMatchRule("github-token", GITHUB_TOKEN_PATTERN),
|
|
13657
|
+
fullMatchRule("slack-token", SLACK_TOKEN_PATTERN),
|
|
13658
|
+
{
|
|
13659
|
+
id: "bearer",
|
|
13660
|
+
replace(text) {
|
|
13661
|
+
let count = 0;
|
|
13662
|
+
const replaced = text.replace(BEARER_PATTERN, (_m, prefix) => {
|
|
13663
|
+
count++;
|
|
13664
|
+
return `${prefix}${markerFor("bearer")}`;
|
|
13665
|
+
});
|
|
13666
|
+
return { text: replaced, count };
|
|
13667
|
+
}
|
|
13668
|
+
}
|
|
13669
|
+
];
|
|
13670
|
+
RULE_IDS = RULES.map((r2) => r2.id);
|
|
13671
|
+
});
|
|
13672
|
+
|
|
13673
|
+
// ../../packages/core/dist/kernel/sanitize/safe-error-summary.js
|
|
13674
|
+
function safeErrorSummary(error) {
|
|
13675
|
+
if (error instanceof Error) {
|
|
13676
|
+
return {
|
|
13677
|
+
name: error.name,
|
|
13678
|
+
message: scrubCredentials(error.message).sanitized
|
|
13679
|
+
};
|
|
13680
|
+
}
|
|
13681
|
+
return {
|
|
13682
|
+
name: "UnknownError",
|
|
13683
|
+
message: scrubCredentials(String(error)).sanitized
|
|
13684
|
+
};
|
|
13685
|
+
}
|
|
13686
|
+
var init_safe_error_summary = __esm(() => {
|
|
13687
|
+
init_credential_scrub();
|
|
13688
|
+
});
|
|
13689
|
+
|
|
13590
13690
|
// ../../packages/core/dist/kernel/alias-resolver.js
|
|
13591
13691
|
class ProjectIdentityAliasResolver {
|
|
13592
13692
|
ttlMs;
|
|
@@ -13612,9 +13712,7 @@ class ProjectIdentityAliasResolver {
|
|
|
13612
13712
|
this.cache.set(projectId, { canonical, expiresAt: this.now() + this.ttlMs });
|
|
13613
13713
|
return canonical;
|
|
13614
13714
|
} catch (error) {
|
|
13615
|
-
logger.warn("[project-identity] alias resolution failed; using original id (
|
|
13616
|
-
name: error instanceof Error ? error.name : "unknown"
|
|
13617
|
-
});
|
|
13715
|
+
logger.warn("[project-identity] alias resolution failed; using original id", safeErrorSummary(error));
|
|
13618
13716
|
return projectId;
|
|
13619
13717
|
}
|
|
13620
13718
|
}
|
|
@@ -13671,10 +13769,11 @@ var DEFAULT_TTL_MS = 30000, DEFAULT_RESOLVE_TIMEOUT_MS = 250, sharedResolver = n
|
|
|
13671
13769
|
var init_alias_resolver = __esm(() => {
|
|
13672
13770
|
init_dist();
|
|
13673
13771
|
init_db_connection();
|
|
13772
|
+
init_safe_error_summary();
|
|
13674
13773
|
});
|
|
13675
13774
|
|
|
13676
13775
|
// ../../packages/core/dist/services/search/index-manager.js
|
|
13677
|
-
import
|
|
13776
|
+
import fs8 from "fs";
|
|
13678
13777
|
import path12 from "path";
|
|
13679
13778
|
|
|
13680
13779
|
class IndexManager {
|
|
@@ -13770,7 +13869,7 @@ class IndexManager {
|
|
|
13770
13869
|
for (const filePath of indexedFiles) {
|
|
13771
13870
|
const fullPath = path12.join(projectPath, filePath);
|
|
13772
13871
|
try {
|
|
13773
|
-
const stat2 = await
|
|
13872
|
+
const stat2 = await fs8.promises.stat(fullPath);
|
|
13774
13873
|
fileMetadata[filePath] = {
|
|
13775
13874
|
path: filePath,
|
|
13776
13875
|
mtime: stat2.mtimeMs,
|
|
@@ -13823,7 +13922,7 @@ class IndexManager {
|
|
|
13823
13922
|
}
|
|
13824
13923
|
const fullPath = path12.join(projectPath, match2);
|
|
13825
13924
|
try {
|
|
13826
|
-
const stat2 = await
|
|
13925
|
+
const stat2 = await fs8.promises.stat(fullPath);
|
|
13827
13926
|
files.set(match2, {
|
|
13828
13927
|
path: match2,
|
|
13829
13928
|
mtime: stat2.mtimeMs,
|
|
@@ -35514,7 +35613,7 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
35514
35613
|
writeAuthConfig: () => writeAuthConfig
|
|
35515
35614
|
});
|
|
35516
35615
|
module.exports = __toCommonJS2(auth_config_exports);
|
|
35517
|
-
var
|
|
35616
|
+
var fs9 = __toESM2(__require("fs"));
|
|
35518
35617
|
var path13 = __toESM2(__require("path"));
|
|
35519
35618
|
var import_token_util = require_token_util();
|
|
35520
35619
|
function getAuthConfigPath() {
|
|
@@ -35527,10 +35626,10 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
35527
35626
|
function readAuthConfig() {
|
|
35528
35627
|
try {
|
|
35529
35628
|
const authPath = getAuthConfigPath();
|
|
35530
|
-
if (!
|
|
35629
|
+
if (!fs9.existsSync(authPath)) {
|
|
35531
35630
|
return null;
|
|
35532
35631
|
}
|
|
35533
|
-
const content =
|
|
35632
|
+
const content = fs9.readFileSync(authPath, "utf8");
|
|
35534
35633
|
if (!content) {
|
|
35535
35634
|
return null;
|
|
35536
35635
|
}
|
|
@@ -35542,10 +35641,10 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
35542
35641
|
function writeAuthConfig(config3) {
|
|
35543
35642
|
const authPath = getAuthConfigPath();
|
|
35544
35643
|
const authDir = path13.dirname(authPath);
|
|
35545
|
-
if (!
|
|
35546
|
-
|
|
35644
|
+
if (!fs9.existsSync(authDir)) {
|
|
35645
|
+
fs9.mkdirSync(authDir, { mode: 504, recursive: true });
|
|
35547
35646
|
}
|
|
35548
|
-
|
|
35647
|
+
fs9.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
|
|
35549
35648
|
}
|
|
35550
35649
|
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
35551
35650
|
if (!authConfig.token)
|
|
@@ -35721,7 +35820,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
35721
35820
|
});
|
|
35722
35821
|
module.exports = __toCommonJS2(token_util_exports);
|
|
35723
35822
|
var path13 = __toESM2(__require("path"));
|
|
35724
|
-
var
|
|
35823
|
+
var fs9 = __toESM2(__require("fs"));
|
|
35725
35824
|
var import_token_error = require_token_error();
|
|
35726
35825
|
var import_token_io = require_token_io();
|
|
35727
35826
|
var import_auth_config = require_auth_config();
|
|
@@ -35802,10 +35901,10 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
35802
35901
|
throw new import_token_error.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");
|
|
35803
35902
|
}
|
|
35804
35903
|
const prjPath = path13.join(dir, ".vercel", "project.json");
|
|
35805
|
-
if (!
|
|
35904
|
+
if (!fs9.existsSync(prjPath)) {
|
|
35806
35905
|
throw new import_token_error.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");
|
|
35807
35906
|
}
|
|
35808
|
-
const prj = JSON.parse(
|
|
35907
|
+
const prj = JSON.parse(fs9.readFileSync(prjPath, "utf8"));
|
|
35809
35908
|
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
|
|
35810
35909
|
throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");
|
|
35811
35910
|
}
|
|
@@ -35818,9 +35917,9 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
35818
35917
|
}
|
|
35819
35918
|
const tokenPath = path13.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
35820
35919
|
const tokenJson = JSON.stringify(token);
|
|
35821
|
-
|
|
35822
|
-
|
|
35823
|
-
|
|
35920
|
+
fs9.mkdirSync(path13.dirname(tokenPath), { mode: 504, recursive: true });
|
|
35921
|
+
fs9.writeFileSync(tokenPath, tokenJson);
|
|
35922
|
+
fs9.chmodSync(tokenPath, 432);
|
|
35824
35923
|
return;
|
|
35825
35924
|
}
|
|
35826
35925
|
function loadToken(projectId) {
|
|
@@ -35829,10 +35928,10 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
35829
35928
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
35830
35929
|
}
|
|
35831
35930
|
const tokenPath = path13.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
35832
|
-
if (!
|
|
35931
|
+
if (!fs9.existsSync(tokenPath)) {
|
|
35833
35932
|
return null;
|
|
35834
35933
|
}
|
|
35835
|
-
const token = JSON.parse(
|
|
35934
|
+
const token = JSON.parse(fs9.readFileSync(tokenPath, "utf8"));
|
|
35836
35935
|
assertVercelOidcTokenResponse(token);
|
|
35837
35936
|
return token;
|
|
35838
35937
|
}
|
|
@@ -63262,26 +63361,26 @@ var require_process = __commonJS((exports, module) => {
|
|
|
63262
63361
|
|
|
63263
63362
|
// ../../node_modules/detect-libc/lib/filesystem.js
|
|
63264
63363
|
var require_filesystem = __commonJS((exports, module) => {
|
|
63265
|
-
var
|
|
63364
|
+
var fs9 = __require("fs");
|
|
63266
63365
|
var LDD_PATH = "/usr/bin/ldd";
|
|
63267
63366
|
var SELF_PATH = "/proc/self/exe";
|
|
63268
63367
|
var MAX_LENGTH = 2048;
|
|
63269
63368
|
var readFileSync2 = (path13) => {
|
|
63270
|
-
const fd =
|
|
63369
|
+
const fd = fs9.openSync(path13, "r");
|
|
63271
63370
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
63272
|
-
const bytesRead =
|
|
63273
|
-
|
|
63371
|
+
const bytesRead = fs9.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
63372
|
+
fs9.close(fd, () => {});
|
|
63274
63373
|
return buffer.subarray(0, bytesRead);
|
|
63275
63374
|
};
|
|
63276
63375
|
var readFile = (path13) => new Promise((resolve4, reject) => {
|
|
63277
|
-
|
|
63376
|
+
fs9.open(path13, "r", (err, fd) => {
|
|
63278
63377
|
if (err) {
|
|
63279
63378
|
reject(err);
|
|
63280
63379
|
} else {
|
|
63281
63380
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
63282
|
-
|
|
63381
|
+
fs9.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
|
|
63283
63382
|
resolve4(buffer.subarray(0, bytesRead));
|
|
63284
|
-
|
|
63383
|
+
fs9.close(fd, () => {});
|
|
63285
63384
|
});
|
|
63286
63385
|
}
|
|
63287
63386
|
});
|
|
@@ -99944,10 +100043,10 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a12;
|
|
|
99944
100043
|
super(t2, "P2023", r2);
|
|
99945
100044
|
}
|
|
99946
100045
|
};
|
|
99947
|
-
var
|
|
100046
|
+
var fs9 = new WeakMap;
|
|
99948
100047
|
function Ep(e) {
|
|
99949
|
-
let t2 =
|
|
99950
|
-
return t2 || (t2 = Object.entries(e),
|
|
100048
|
+
let t2 = fs9.get(e);
|
|
100049
|
+
return t2 || (t2 = Object.entries(e), fs9.set(e, t2)), t2;
|
|
99951
100050
|
}
|
|
99952
100051
|
function hs(e, t2, r2) {
|
|
99953
100052
|
switch (t2.type) {
|
|
@@ -113391,6 +113490,89 @@ var init_reranker = __esm(() => {
|
|
|
113391
113490
|
});
|
|
113392
113491
|
});
|
|
113393
113492
|
|
|
113493
|
+
// ../../packages/core/dist/kernel/search-diagnostics.js
|
|
113494
|
+
function searchBackendUnavailable(component, cause) {
|
|
113495
|
+
return cause instanceof SearchServiceError ? cause : new SearchServiceError("SEARCH_BACKEND_UNAVAILABLE", component, { cause });
|
|
113496
|
+
}
|
|
113497
|
+
function storeCorruption(component, cause) {
|
|
113498
|
+
return cause instanceof SearchServiceError ? cause : new SearchServiceError("STORE_CORRUPTION", component, {
|
|
113499
|
+
cause,
|
|
113500
|
+
statusCode: 500
|
|
113501
|
+
});
|
|
113502
|
+
}
|
|
113503
|
+
function projectNotIndexed(projectId, message) {
|
|
113504
|
+
return new SearchServiceError("PROJECT_NOT_INDEXED", projectId, {
|
|
113505
|
+
message,
|
|
113506
|
+
statusCode: 404
|
|
113507
|
+
});
|
|
113508
|
+
}
|
|
113509
|
+
function recordSearchDegradation(code, component, projectId) {
|
|
113510
|
+
const degradation = {
|
|
113511
|
+
code,
|
|
113512
|
+
component,
|
|
113513
|
+
message: DEGRADATION_MESSAGES[code]
|
|
113514
|
+
};
|
|
113515
|
+
diagnostics.push({
|
|
113516
|
+
kind: "degradation",
|
|
113517
|
+
...degradation,
|
|
113518
|
+
projectId,
|
|
113519
|
+
timestamp: new Date().toISOString()
|
|
113520
|
+
});
|
|
113521
|
+
if (diagnostics.length > MAX_DIAGNOSTICS) {
|
|
113522
|
+
diagnostics.splice(0, diagnostics.length - MAX_DIAGNOSTICS);
|
|
113523
|
+
}
|
|
113524
|
+
return degradation;
|
|
113525
|
+
}
|
|
113526
|
+
function recordSearchFailure(error51, projectId) {
|
|
113527
|
+
if (recordedFailures.has(error51))
|
|
113528
|
+
return;
|
|
113529
|
+
recordedFailures.add(error51);
|
|
113530
|
+
diagnostics.push({
|
|
113531
|
+
kind: "failure",
|
|
113532
|
+
code: error51.code,
|
|
113533
|
+
component: error51.component,
|
|
113534
|
+
message: error51.message,
|
|
113535
|
+
projectId,
|
|
113536
|
+
timestamp: new Date().toISOString()
|
|
113537
|
+
});
|
|
113538
|
+
if (diagnostics.length > MAX_DIAGNOSTICS) {
|
|
113539
|
+
diagnostics.splice(0, diagnostics.length - MAX_DIAGNOSTICS);
|
|
113540
|
+
}
|
|
113541
|
+
}
|
|
113542
|
+
function getSearchDiagnostics() {
|
|
113543
|
+
return diagnostics.map((diagnostic) => ({ ...diagnostic }));
|
|
113544
|
+
}
|
|
113545
|
+
function resetSearchDiagnosticsForTests() {
|
|
113546
|
+
diagnostics.length = 0;
|
|
113547
|
+
}
|
|
113548
|
+
var MAX_DIAGNOSTICS = 100, diagnostics, recordedFailures, DEGRADATION_MESSAGES, SearchServiceError;
|
|
113549
|
+
var init_search_diagnostics = __esm(() => {
|
|
113550
|
+
diagnostics = [];
|
|
113551
|
+
recordedFailures = new WeakSet;
|
|
113552
|
+
DEGRADATION_MESSAGES = {
|
|
113553
|
+
QUERY_UNDERSTANDING_UNAVAILABLE: "Query understanding was unavailable; original query used",
|
|
113554
|
+
TRIGRAM_UNAVAILABLE: "Trigram enrichment was unavailable",
|
|
113555
|
+
FUZZY_SEARCH_UNAVAILABLE: "Fuzzy enrichment was unavailable",
|
|
113556
|
+
PROXIMITY_RERANK_UNAVAILABLE: "Proximity reranking was unavailable; fused order preserved",
|
|
113557
|
+
GRAPH_AUGMENTATION_UNAVAILABLE: "Graph augmentation was unavailable",
|
|
113558
|
+
SYNAPSE_UNAVAILABLE: "Synapse enrichment was unavailable; stateless results used",
|
|
113559
|
+
SEARCH_AUDIT_UNAVAILABLE: "Search event auditing was unavailable",
|
|
113560
|
+
SEARCH_ANALYTICS_UNAVAILABLE: "Search analytics were unavailable"
|
|
113561
|
+
};
|
|
113562
|
+
SearchServiceError = class SearchServiceError extends Error {
|
|
113563
|
+
code;
|
|
113564
|
+
component;
|
|
113565
|
+
statusCode;
|
|
113566
|
+
constructor(code, component, options) {
|
|
113567
|
+
super(options?.message ?? (code === "STORE_CORRUPTION" ? "Stored data is invalid" : "A required search backend is unavailable"), options?.cause === undefined ? undefined : { cause: options.cause });
|
|
113568
|
+
this.code = code;
|
|
113569
|
+
this.component = component;
|
|
113570
|
+
this.name = "SearchServiceError";
|
|
113571
|
+
this.statusCode = options?.statusCode ?? 503;
|
|
113572
|
+
}
|
|
113573
|
+
};
|
|
113574
|
+
});
|
|
113575
|
+
|
|
113394
113576
|
// ../../packages/core/dist/kernel/enum-validation.js
|
|
113395
113577
|
function validateEnum(paramName, value, validValues) {
|
|
113396
113578
|
if (typeof value !== "string" || !validValues.includes(value)) {
|
|
@@ -113499,7 +113681,7 @@ class SearchController {
|
|
|
113499
113681
|
});
|
|
113500
113682
|
const admission = await this.contextualSearch.checkSearchAdmission(projectId, projectPath);
|
|
113501
113683
|
if (!admission.admitted) {
|
|
113502
|
-
throw
|
|
113684
|
+
throw projectNotIndexed(projectId, admission.error ?? `Project '${projectId}' is not indexed`);
|
|
113503
113685
|
}
|
|
113504
113686
|
const staleWarning = admission.stale ?? null;
|
|
113505
113687
|
let reindexInfo = null;
|
|
@@ -113723,6 +113905,7 @@ var init_search_controller = __esm(() => {
|
|
|
113723
113905
|
init_contextual_search_rlm();
|
|
113724
113906
|
init_event_bus();
|
|
113725
113907
|
init_reranker();
|
|
113908
|
+
init_search_diagnostics();
|
|
113726
113909
|
init_esm();
|
|
113727
113910
|
init_filter_validation();
|
|
113728
113911
|
});
|
|
@@ -114208,83 +114391,6 @@ var init_session_bias = __esm(() => {
|
|
|
114208
114391
|
init_synapse();
|
|
114209
114392
|
});
|
|
114210
114393
|
|
|
114211
|
-
// ../../packages/core/dist/kernel/search-diagnostics.js
|
|
114212
|
-
function searchBackendUnavailable(component, cause) {
|
|
114213
|
-
return cause instanceof SearchServiceError ? cause : new SearchServiceError("SEARCH_BACKEND_UNAVAILABLE", component, { cause });
|
|
114214
|
-
}
|
|
114215
|
-
function storeCorruption(component, cause) {
|
|
114216
|
-
return cause instanceof SearchServiceError ? cause : new SearchServiceError("STORE_CORRUPTION", component, {
|
|
114217
|
-
cause,
|
|
114218
|
-
statusCode: 500
|
|
114219
|
-
});
|
|
114220
|
-
}
|
|
114221
|
-
function recordSearchDegradation(code, component, projectId) {
|
|
114222
|
-
const degradation = {
|
|
114223
|
-
code,
|
|
114224
|
-
component,
|
|
114225
|
-
message: DEGRADATION_MESSAGES[code]
|
|
114226
|
-
};
|
|
114227
|
-
diagnostics.push({
|
|
114228
|
-
kind: "degradation",
|
|
114229
|
-
...degradation,
|
|
114230
|
-
projectId,
|
|
114231
|
-
timestamp: new Date().toISOString()
|
|
114232
|
-
});
|
|
114233
|
-
if (diagnostics.length > MAX_DIAGNOSTICS) {
|
|
114234
|
-
diagnostics.splice(0, diagnostics.length - MAX_DIAGNOSTICS);
|
|
114235
|
-
}
|
|
114236
|
-
return degradation;
|
|
114237
|
-
}
|
|
114238
|
-
function recordSearchFailure(error51, projectId) {
|
|
114239
|
-
if (recordedFailures.has(error51))
|
|
114240
|
-
return;
|
|
114241
|
-
recordedFailures.add(error51);
|
|
114242
|
-
diagnostics.push({
|
|
114243
|
-
kind: "failure",
|
|
114244
|
-
code: error51.code,
|
|
114245
|
-
component: error51.component,
|
|
114246
|
-
message: error51.message,
|
|
114247
|
-
projectId,
|
|
114248
|
-
timestamp: new Date().toISOString()
|
|
114249
|
-
});
|
|
114250
|
-
if (diagnostics.length > MAX_DIAGNOSTICS) {
|
|
114251
|
-
diagnostics.splice(0, diagnostics.length - MAX_DIAGNOSTICS);
|
|
114252
|
-
}
|
|
114253
|
-
}
|
|
114254
|
-
function getSearchDiagnostics() {
|
|
114255
|
-
return diagnostics.map((diagnostic) => ({ ...diagnostic }));
|
|
114256
|
-
}
|
|
114257
|
-
function resetSearchDiagnosticsForTests() {
|
|
114258
|
-
diagnostics.length = 0;
|
|
114259
|
-
}
|
|
114260
|
-
var MAX_DIAGNOSTICS = 100, diagnostics, recordedFailures, DEGRADATION_MESSAGES, SearchServiceError;
|
|
114261
|
-
var init_search_diagnostics = __esm(() => {
|
|
114262
|
-
diagnostics = [];
|
|
114263
|
-
recordedFailures = new WeakSet;
|
|
114264
|
-
DEGRADATION_MESSAGES = {
|
|
114265
|
-
QUERY_UNDERSTANDING_UNAVAILABLE: "Query understanding was unavailable; original query used",
|
|
114266
|
-
TRIGRAM_UNAVAILABLE: "Trigram enrichment was unavailable",
|
|
114267
|
-
FUZZY_SEARCH_UNAVAILABLE: "Fuzzy enrichment was unavailable",
|
|
114268
|
-
PROXIMITY_RERANK_UNAVAILABLE: "Proximity reranking was unavailable; fused order preserved",
|
|
114269
|
-
GRAPH_AUGMENTATION_UNAVAILABLE: "Graph augmentation was unavailable",
|
|
114270
|
-
SYNAPSE_UNAVAILABLE: "Synapse enrichment was unavailable; stateless results used",
|
|
114271
|
-
SEARCH_AUDIT_UNAVAILABLE: "Search event auditing was unavailable",
|
|
114272
|
-
SEARCH_ANALYTICS_UNAVAILABLE: "Search analytics were unavailable"
|
|
114273
|
-
};
|
|
114274
|
-
SearchServiceError = class SearchServiceError extends Error {
|
|
114275
|
-
code;
|
|
114276
|
-
component;
|
|
114277
|
-
statusCode;
|
|
114278
|
-
constructor(code, component, options) {
|
|
114279
|
-
super(code === "STORE_CORRUPTION" ? "Stored data is invalid" : "A required search backend is unavailable", options?.cause === undefined ? undefined : { cause: options.cause });
|
|
114280
|
-
this.code = code;
|
|
114281
|
-
this.component = component;
|
|
114282
|
-
this.name = "SearchServiceError";
|
|
114283
|
-
this.statusCode = options?.statusCode ?? 503;
|
|
114284
|
-
}
|
|
114285
|
-
};
|
|
114286
|
-
});
|
|
114287
|
-
|
|
114288
114394
|
// ../../packages/core/dist/services/search/hybrid-search.js
|
|
114289
114395
|
async function search(deps, query, projectId, options = {}) {
|
|
114290
114396
|
const maxResults = options.maxResults ?? 10;
|
|
@@ -115641,7 +115747,7 @@ var init_managed_run_repository_pg = __esm(() => {
|
|
|
115641
115747
|
});
|
|
115642
115748
|
|
|
115643
115749
|
// ../../packages/core/dist/services/search/project-indexer.js
|
|
115644
|
-
import
|
|
115750
|
+
import fs9 from "fs/promises";
|
|
115645
115751
|
import path14 from "path";
|
|
115646
115752
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
115647
115753
|
async function runWithIndexLock(lockMap, projectId, work) {
|
|
@@ -115901,7 +116007,7 @@ async function checkSearchAdmission(deps, projectId, projectPath) {
|
|
|
115901
116007
|
}
|
|
115902
116008
|
async function indexFile(deps, filePath, projectId, projectRoot, centralityMap) {
|
|
115903
116009
|
projectId = await getProjectIdentityAliasResolver().resolve(projectId);
|
|
115904
|
-
const content = await
|
|
116010
|
+
const content = await fs9.readFile(filePath, "utf-8");
|
|
115905
116011
|
const relativePath = path14.relative(projectRoot, filePath);
|
|
115906
116012
|
const maxFileSize = config.get("security").maxFileSize || 1024 * 1024;
|
|
115907
116013
|
if (content.length > maxFileSize) {
|
|
@@ -116767,7 +116873,7 @@ function stripNul(content) {
|
|
|
116767
116873
|
}
|
|
116768
116874
|
|
|
116769
116875
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
116770
|
-
import
|
|
116876
|
+
import fs10 from "fs/promises";
|
|
116771
116877
|
import path15 from "path";
|
|
116772
116878
|
import { createHash as createHash5 } from "crypto";
|
|
116773
116879
|
|
|
@@ -116855,8 +116961,8 @@ class DiscoverStage {
|
|
|
116855
116961
|
async processFile(ctx, relativePath, forceReindex) {
|
|
116856
116962
|
const absolutePath = path15.join(ctx.projectPath, relativePath);
|
|
116857
116963
|
try {
|
|
116858
|
-
const stat2 = await
|
|
116859
|
-
const content = stripNul(await
|
|
116964
|
+
const stat2 = await fs10.stat(absolutePath);
|
|
116965
|
+
const content = stripNul(await fs10.readFile(absolutePath, "utf-8"));
|
|
116860
116966
|
const contentHash = createHash5("sha256").update(content).digest("hex");
|
|
116861
116967
|
let needsReparse = forceReindex;
|
|
116862
116968
|
if (!forceReindex) {
|
|
@@ -116900,7 +117006,7 @@ class DiscoverStage {
|
|
|
116900
117006
|
}
|
|
116901
117007
|
try {
|
|
116902
117008
|
const gitignorePath = path15.join(projectPath, ".gitignore");
|
|
116903
|
-
const gitignoreContent = await
|
|
117009
|
+
const gitignoreContent = await fs10.readFile(gitignorePath, "utf8");
|
|
116904
117010
|
const rules = gitignoreContent.split(`
|
|
116905
117011
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
116906
117012
|
ig.add(rules);
|
|
@@ -119229,7 +119335,7 @@ var init_structural_runtime = __esm(() => {
|
|
|
119229
119335
|
|
|
119230
119336
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
119231
119337
|
import path16 from "path";
|
|
119232
|
-
import
|
|
119338
|
+
import fs11 from "fs/promises";
|
|
119233
119339
|
function resolveChunkerMaxChars() {
|
|
119234
119340
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
119235
119341
|
if (Number.isFinite(global2) && global2 > 0)
|
|
@@ -119321,7 +119427,7 @@ class ParseStage {
|
|
|
119321
119427
|
if (!file3.needsReparse) {
|
|
119322
119428
|
const extension = path16.extname(file3.relativePath).toLowerCase();
|
|
119323
119429
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
119324
|
-
const content = file3.snapshotContent ?? await
|
|
119430
|
+
const content = file3.snapshotContent ?? await fs11.readFile(file3.absolutePath, "utf8");
|
|
119325
119431
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
119326
119432
|
if (outcome.status === "failed")
|
|
119327
119433
|
throw new StructuralEtlParseError(file3.relativePath, outcome.failureKind, `Structural evidence parse failed (${outcome.failureKind})`, outcome.diagnosticCount, outcome.diagnostics.slice(0, 10));
|
|
@@ -119333,7 +119439,7 @@ class ParseStage {
|
|
|
119333
119439
|
return { file: file3, chunks: [], symbols: [], rawImports: [], rawEdges: [] };
|
|
119334
119440
|
}
|
|
119335
119441
|
try {
|
|
119336
|
-
const content = file3.snapshotContent ?? await
|
|
119442
|
+
const content = file3.snapshotContent ?? await fs11.readFile(file3.absolutePath, "utf-8");
|
|
119337
119443
|
const ext2 = path16.extname(file3.relativePath).toLowerCase();
|
|
119338
119444
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
119339
119445
|
const chunks = smartChunk(content, file3.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
@@ -120374,7 +120480,7 @@ var init_data_document2 = __esm(() => {
|
|
|
120374
120480
|
|
|
120375
120481
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
120376
120482
|
import path19 from "path";
|
|
120377
|
-
import
|
|
120483
|
+
import fs12 from "fs";
|
|
120378
120484
|
|
|
120379
120485
|
class ResolveStage {
|
|
120380
120486
|
symbolRepository;
|
|
@@ -120691,7 +120797,7 @@ class ResolveStage {
|
|
|
120691
120797
|
const aliases = [];
|
|
120692
120798
|
const tsconfigPath = path19.join(projectPath, "tsconfig.json");
|
|
120693
120799
|
try {
|
|
120694
|
-
const raw2 =
|
|
120800
|
+
const raw2 = fs12.readFileSync(tsconfigPath, "utf-8");
|
|
120695
120801
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
120696
120802
|
const tsconfig = JSON.parse(stripped);
|
|
120697
120803
|
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
@@ -122987,7 +123093,7 @@ __export(exports_symbol_graph_service, {
|
|
|
122987
123093
|
SymbolGraphService: () => SymbolGraphService
|
|
122988
123094
|
});
|
|
122989
123095
|
import path23 from "path";
|
|
122990
|
-
import
|
|
123096
|
+
import fs13 from "fs/promises";
|
|
122991
123097
|
|
|
122992
123098
|
class SymbolGraphService {
|
|
122993
123099
|
identityLookup;
|
|
@@ -123315,7 +123421,7 @@ class SymbolGraphService {
|
|
|
123315
123421
|
async readSnippet(relativePath, lineStart, lineEnd, projectId) {
|
|
123316
123422
|
try {
|
|
123317
123423
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
123318
|
-
const content = await
|
|
123424
|
+
const content = await fs13.readFile(absolutePath, "utf-8");
|
|
123319
123425
|
const lines = content.split(`
|
|
123320
123426
|
`);
|
|
123321
123427
|
return lines.slice(Math.max(0, lineStart - 1), Math.min(lines.length, lineEnd)).join(`
|
|
@@ -123327,7 +123433,7 @@ class SymbolGraphService {
|
|
|
123327
123433
|
async readContext(relativePath, lineNumber, contextLines, projectId) {
|
|
123328
123434
|
try {
|
|
123329
123435
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
123330
|
-
const content = await
|
|
123436
|
+
const content = await fs13.readFile(absolutePath, "utf-8");
|
|
123331
123437
|
const lines = content.split(`
|
|
123332
123438
|
`);
|
|
123333
123439
|
const start = Math.max(0, lineNumber - contextLines - 1);
|
|
@@ -130496,7 +130602,7 @@ var init_l1_memory_cache = __esm(() => {
|
|
|
130496
130602
|
});
|
|
130497
130603
|
|
|
130498
130604
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
130499
|
-
import
|
|
130605
|
+
import fs16 from "fs/promises";
|
|
130500
130606
|
import { existsSync as existsSync3 } from "fs";
|
|
130501
130607
|
import path28 from "path";
|
|
130502
130608
|
|
|
@@ -130532,10 +130638,10 @@ class LocalHealthChecker {
|
|
|
130532
130638
|
const start = Date.now();
|
|
130533
130639
|
try {
|
|
130534
130640
|
if (!existsSync3(this.dataDir))
|
|
130535
|
-
await
|
|
130641
|
+
await fs16.mkdir(this.dataDir, { recursive: true });
|
|
130536
130642
|
const probe2 = path28.join(this.dataDir, ".health-check-test");
|
|
130537
|
-
await
|
|
130538
|
-
await
|
|
130643
|
+
await fs16.writeFile(probe2, "ok");
|
|
130644
|
+
await fs16.unlink(probe2);
|
|
130539
130645
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
130540
130646
|
} catch (error51) {
|
|
130541
130647
|
return { available: false, latency: Date.now() - start, error: `Data directory error: ${error51.message}` };
|
|
@@ -132445,7 +132551,7 @@ var init_scheduler2 = __esm(() => {
|
|
|
132445
132551
|
});
|
|
132446
132552
|
|
|
132447
132553
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
132448
|
-
import
|
|
132554
|
+
import fs17 from "fs/promises";
|
|
132449
132555
|
import { existsSync as existsSync4 } from "fs";
|
|
132450
132556
|
import path29 from "path";
|
|
132451
132557
|
function getModelsDevClient() {
|
|
@@ -132475,7 +132581,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
132475
132581
|
if (!existsSync4(cachePath)) {
|
|
132476
132582
|
return null;
|
|
132477
132583
|
}
|
|
132478
|
-
const content = await
|
|
132584
|
+
const content = await fs17.readFile(cachePath, "utf-8");
|
|
132479
132585
|
const data = JSON.parse(content);
|
|
132480
132586
|
const age = Date.now() - data.timestamp;
|
|
132481
132587
|
if (age > ModelsDevClient.LOCAL_CACHE_TTL) {
|
|
@@ -132503,13 +132609,13 @@ var init_models_dev_client = __esm(() => {
|
|
|
132503
132609
|
const cachePath = this.getLocalCachePath();
|
|
132504
132610
|
try {
|
|
132505
132611
|
const dir = path29.dirname(cachePath);
|
|
132506
|
-
await
|
|
132612
|
+
await fs17.mkdir(dir, { recursive: true });
|
|
132507
132613
|
const data = {
|
|
132508
132614
|
timestamp: Date.now(),
|
|
132509
132615
|
version: "1.0.0",
|
|
132510
132616
|
models: Object.fromEntries(models)
|
|
132511
132617
|
};
|
|
132512
|
-
await
|
|
132618
|
+
await fs17.writeFile(cachePath, JSON.stringify(data), "utf-8");
|
|
132513
132619
|
logger.debug("Saved pricing to local cache", {
|
|
132514
132620
|
models: models.size,
|
|
132515
132621
|
path: cachePath
|
|
@@ -132838,7 +132944,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
132838
132944
|
const cachePath = this.getLocalCachePath();
|
|
132839
132945
|
try {
|
|
132840
132946
|
if (existsSync4(cachePath)) {
|
|
132841
|
-
await
|
|
132947
|
+
await fs17.unlink(cachePath);
|
|
132842
132948
|
logger.debug("Local pricing cache file deleted");
|
|
132843
132949
|
}
|
|
132844
132950
|
} catch (error51) {
|
|
@@ -150856,6 +150962,7 @@ __export(exports_services, {
|
|
|
150856
150962
|
selectCompressionCandidates: () => selectCompressionCandidates,
|
|
150857
150963
|
searchSessionHook: () => searchSessionHook,
|
|
150858
150964
|
searchBackendUnavailable: () => searchBackendUnavailable,
|
|
150965
|
+
safeErrorSummary: () => safeErrorSummary,
|
|
150859
150966
|
runPool: () => runPool,
|
|
150860
150967
|
resolveStructuralParseLanguage: () => resolveStructuralParseLanguage,
|
|
150861
150968
|
resetSynapseManager: () => resetSynapseManager,
|
|
@@ -150870,6 +150977,7 @@ __export(exports_services, {
|
|
|
150870
150977
|
recordSearchFailure: () => recordSearchFailure,
|
|
150871
150978
|
recordSearchDegradation: () => recordSearchDegradation,
|
|
150872
150979
|
quoteDiscoveredIdentifier: () => quoteDiscoveredIdentifier,
|
|
150980
|
+
projectNotIndexed: () => projectNotIndexed,
|
|
150873
150981
|
payloadStorePolicies: () => payloadStorePolicies,
|
|
150874
150982
|
parseStructuralFqn: () => parseStructuralFqn,
|
|
150875
150983
|
parseProjectIdentityPreviewRequest: () => parseProjectIdentityPreviewRequest,
|
|
@@ -151087,6 +151195,7 @@ var init_services = __esm(() => {
|
|
|
151087
151195
|
init_search_analytics_pg();
|
|
151088
151196
|
init_index_manager();
|
|
151089
151197
|
init_search_diagnostics();
|
|
151198
|
+
init_safe_error_summary();
|
|
151090
151199
|
init_memory_controller();
|
|
151091
151200
|
init_llm_client();
|
|
151092
151201
|
init_search_controller();
|
|
@@ -175534,7 +175643,8 @@ init_compaction_snapshot_service();
|
|
|
175534
175643
|
init_dist();
|
|
175535
175644
|
init_db_connection();
|
|
175536
175645
|
init_alias_resolver();
|
|
175537
|
-
|
|
175646
|
+
init_safe_error_summary();
|
|
175647
|
+
import fs14 from "fs";
|
|
175538
175648
|
import os6 from "os";
|
|
175539
175649
|
import path25 from "path";
|
|
175540
175650
|
|
|
@@ -175611,9 +175721,7 @@ class PgWorkspaceRootProvider {
|
|
|
175611
175721
|
this.cache = { roots, expiresAt: this.now() + PROVIDER_TTL_MS };
|
|
175612
175722
|
return roots;
|
|
175613
175723
|
} catch (error51) {
|
|
175614
|
-
logger.warn("[hook-attribution] workspace roots lookup failed; containment disabled (
|
|
175615
|
-
name: error51 instanceof Error ? error51.name : "unknown"
|
|
175616
|
-
});
|
|
175724
|
+
logger.warn("[hook-attribution] workspace roots lookup failed; containment disabled", safeErrorSummary(error51));
|
|
175617
175725
|
return [];
|
|
175618
175726
|
} finally {
|
|
175619
175727
|
if (timer)
|
|
@@ -175722,7 +175830,7 @@ class AttributionResolver {
|
|
|
175722
175830
|
}
|
|
175723
175831
|
function defaultCanonicalize(cwd) {
|
|
175724
175832
|
try {
|
|
175725
|
-
return
|
|
175833
|
+
return fs14.realpathSync(cwd);
|
|
175726
175834
|
} catch {
|
|
175727
175835
|
try {
|
|
175728
175836
|
return path25.resolve(cwd);
|
|
@@ -175738,70 +175846,9 @@ function getAttributionResolver() {
|
|
|
175738
175846
|
return sharedResolver2;
|
|
175739
175847
|
}
|
|
175740
175848
|
|
|
175741
|
-
// ../../packages/core/dist/kernel/sanitize/credential-scrub.js
|
|
175742
|
-
function markerFor(id) {
|
|
175743
|
-
return `[REDACTED:${id}]`;
|
|
175744
|
-
}
|
|
175745
|
-
function fullMatchRule(id, pattern) {
|
|
175746
|
-
const marker26 = markerFor(id);
|
|
175747
|
-
return {
|
|
175748
|
-
id,
|
|
175749
|
-
replace(text3) {
|
|
175750
|
-
let count = 0;
|
|
175751
|
-
const replaced = text3.replace(pattern, () => {
|
|
175752
|
-
count++;
|
|
175753
|
-
return marker26;
|
|
175754
|
-
});
|
|
175755
|
-
return { text: replaced, count };
|
|
175756
|
-
}
|
|
175757
|
-
};
|
|
175758
|
-
}
|
|
175759
|
-
var PEM_PATTERN = /-----BEGIN [A-Z ]{0,32}PRIVATE KEY-----[\s\S]{0,8192}?-----END [A-Z ]{0,32}PRIVATE KEY-----/g;
|
|
175760
|
-
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
|
|
175761
|
-
var AWS_KEY_PATTERN = /\b(?:AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16}\b/g;
|
|
175762
|
-
var SK_KEY_PATTERN = /\bsk-[A-Za-z0-9_-]{20,}\b/g;
|
|
175763
|
-
var GITHUB_TOKEN_PATTERN = /\bgh[pousr]_[A-Za-z0-9]{36,}\b|\bgithub_pat_[A-Za-z0-9_]{22,}\b/g;
|
|
175764
|
-
var SLACK_TOKEN_PATTERN = /\bxox[baprs]-[A-Za-z0-9-]{18,}\b/g;
|
|
175765
|
-
var BEARER_PATTERN = /(Bearer\s+)([A-Za-z0-9._~+/=-]{20,})/g;
|
|
175766
|
-
var RULES = [
|
|
175767
|
-
fullMatchRule("pem", PEM_PATTERN),
|
|
175768
|
-
fullMatchRule("jwt", JWT_PATTERN),
|
|
175769
|
-
fullMatchRule("aws-key", AWS_KEY_PATTERN),
|
|
175770
|
-
fullMatchRule("sk-key", SK_KEY_PATTERN),
|
|
175771
|
-
fullMatchRule("github-token", GITHUB_TOKEN_PATTERN),
|
|
175772
|
-
fullMatchRule("slack-token", SLACK_TOKEN_PATTERN),
|
|
175773
|
-
{
|
|
175774
|
-
id: "bearer",
|
|
175775
|
-
replace(text3) {
|
|
175776
|
-
let count = 0;
|
|
175777
|
-
const replaced = text3.replace(BEARER_PATTERN, (_m, prefix) => {
|
|
175778
|
-
count++;
|
|
175779
|
-
return `${prefix}${markerFor("bearer")}`;
|
|
175780
|
-
});
|
|
175781
|
-
return { text: replaced, count };
|
|
175782
|
-
}
|
|
175783
|
-
}
|
|
175784
|
-
];
|
|
175785
|
-
var RULE_IDS = RULES.map((r2) => r2.id);
|
|
175786
|
-
function scrubCredentials(payloadJson) {
|
|
175787
|
-
const redactions = {};
|
|
175788
|
-
for (const id of RULE_IDS)
|
|
175789
|
-
redactions[id] = 0;
|
|
175790
|
-
let text3 = payloadJson;
|
|
175791
|
-
for (const rule of RULES) {
|
|
175792
|
-
const { text: next, count } = rule.replace(text3);
|
|
175793
|
-
text3 = next;
|
|
175794
|
-
redactions[rule.id] += count;
|
|
175795
|
-
}
|
|
175796
|
-
const total = Object.values(redactions).reduce((sum, n2) => sum + n2, 0);
|
|
175797
|
-
return {
|
|
175798
|
-
sanitized: text3,
|
|
175799
|
-
redactions,
|
|
175800
|
-
total
|
|
175801
|
-
};
|
|
175802
|
-
}
|
|
175803
|
-
|
|
175804
175849
|
// ../../packages/core/dist/tools/compact_snapshot.js
|
|
175850
|
+
init_credential_scrub();
|
|
175851
|
+
|
|
175805
175852
|
class CompactSnapshotTool {
|
|
175806
175853
|
name = "compact_snapshot";
|
|
175807
175854
|
storeOverride;
|
|
@@ -176323,7 +176370,7 @@ init_code_compressor();
|
|
|
176323
176370
|
|
|
176324
176371
|
// ../../packages/core/dist/services/file-read/file-content-cache.js
|
|
176325
176372
|
init_dist();
|
|
176326
|
-
import
|
|
176373
|
+
import fs15 from "fs/promises";
|
|
176327
176374
|
|
|
176328
176375
|
class FileContentCache {
|
|
176329
176376
|
extractMetadata;
|
|
@@ -176356,7 +176403,7 @@ class FileContentCache {
|
|
|
176356
176403
|
metadata: cached2.metadata
|
|
176357
176404
|
};
|
|
176358
176405
|
}
|
|
176359
|
-
const content = await
|
|
176406
|
+
const content = await fs15.readFile(filePath, "utf-8");
|
|
176360
176407
|
const metadata = await this.extractMetadata(content, filePath, options);
|
|
176361
176408
|
evictOldest(this.fileCache, this.FILE_CACHE_MAX_ENTRIES - 1);
|
|
176362
176409
|
this.fileCache.set(cacheKey, {
|
|
@@ -177191,6 +177238,8 @@ class WriterQueue {
|
|
|
177191
177238
|
// ../../packages/core/dist/services/hooks/hook-service.js
|
|
177192
177239
|
init_observation_extractor();
|
|
177193
177240
|
init_observation_consolidation_job();
|
|
177241
|
+
init_credential_scrub();
|
|
177242
|
+
|
|
177194
177243
|
class NoopBridge {
|
|
177195
177244
|
maybeRun() {}
|
|
177196
177245
|
}
|
|
@@ -177395,7 +177444,7 @@ init_event_bus();
|
|
|
177395
177444
|
init_llm_client();
|
|
177396
177445
|
init_symbol_graph_service();
|
|
177397
177446
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
177398
|
-
import
|
|
177447
|
+
import fs18 from "fs";
|
|
177399
177448
|
import path30 from "path";
|
|
177400
177449
|
import { spawn as spawn2 } from "child_process";
|
|
177401
177450
|
var FALLBACK_BOOTSTRAP = {
|
|
@@ -177581,8 +177630,8 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
177581
177630
|
try {
|
|
177582
177631
|
for (const name26 of README_CANDIDATES) {
|
|
177583
177632
|
const p = path30.join(projectRoot, name26);
|
|
177584
|
-
if (
|
|
177585
|
-
const buf =
|
|
177633
|
+
if (fs18.existsSync(p) && fs18.statSync(p).isFile()) {
|
|
177634
|
+
const buf = fs18.readFileSync(p);
|
|
177586
177635
|
signals.readme = buf.slice(0, MAX_README_BYTES).toString("utf8");
|
|
177587
177636
|
break;
|
|
177588
177637
|
}
|
|
@@ -177592,11 +177641,11 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
177592
177641
|
}
|
|
177593
177642
|
try {
|
|
177594
177643
|
const docsDir = path30.join(projectRoot, "docs");
|
|
177595
|
-
if (
|
|
177644
|
+
if (fs18.existsSync(docsDir) && fs18.statSync(docsDir).isDirectory()) {
|
|
177596
177645
|
const entries = walkMarkdown(docsDir).slice(0, MAX_DOCS);
|
|
177597
177646
|
for (const rel of entries) {
|
|
177598
177647
|
try {
|
|
177599
|
-
const buf =
|
|
177648
|
+
const buf = fs18.readFileSync(rel);
|
|
177600
177649
|
signals.docs.push({
|
|
177601
177650
|
path: path30.relative(projectRoot, rel),
|
|
177602
177651
|
snippet: buf.slice(0, MAX_DOC_BYTES).toString("utf8")
|
|
@@ -177610,9 +177659,9 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
177610
177659
|
try {
|
|
177611
177660
|
for (const name26 of MANIFEST_FILES) {
|
|
177612
177661
|
const p = path30.join(projectRoot, name26);
|
|
177613
|
-
if (!
|
|
177662
|
+
if (!fs18.existsSync(p) || !fs18.statSync(p).isFile())
|
|
177614
177663
|
continue;
|
|
177615
|
-
const raw2 =
|
|
177664
|
+
const raw2 = fs18.readFileSync(p).slice(0, MAX_MANIFEST_BYTES).toString("utf8");
|
|
177616
177665
|
const kind = name26;
|
|
177617
177666
|
if (name26 === "package.json") {
|
|
177618
177667
|
try {
|
|
@@ -177652,7 +177701,7 @@ function walkMarkdown(dir) {
|
|
|
177652
177701
|
const cur = stack.pop();
|
|
177653
177702
|
let entries;
|
|
177654
177703
|
try {
|
|
177655
|
-
entries =
|
|
177704
|
+
entries = fs18.readdirSync(cur, { withFileTypes: true });
|
|
177656
177705
|
} catch {
|
|
177657
177706
|
continue;
|
|
177658
177707
|
}
|
|
@@ -178690,7 +178739,7 @@ var checkpointRoutes = new Elysia({ prefix: "/api/v1/checkpoints" }).post("/list
|
|
|
178690
178739
|
|
|
178691
178740
|
// src/routes/project.ts
|
|
178692
178741
|
init_dist();
|
|
178693
|
-
import
|
|
178742
|
+
import fs19 from "fs/promises";
|
|
178694
178743
|
import path31 from "path";
|
|
178695
178744
|
var indexProjectTool = null;
|
|
178696
178745
|
var indexStatusTool = null;
|
|
@@ -178902,8 +178951,8 @@ var projectRoutes = new Elysia({ prefix: "/api/v1/project" }).get("/list", async
|
|
|
178902
178951
|
const finalProjectId = rawBase.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 128);
|
|
178903
178952
|
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR || path31.join(getGlobalDataDir(), "uploads");
|
|
178904
178953
|
const stagingDir = path31.resolve(uploadRoot, finalProjectId);
|
|
178905
|
-
await
|
|
178906
|
-
await
|
|
178954
|
+
await fs19.rm(stagingDir, { recursive: true, force: true });
|
|
178955
|
+
await fs19.mkdir(stagingDir, { recursive: true });
|
|
178907
178956
|
const WRITE_BATCH = 20;
|
|
178908
178957
|
for (let i = 0;i < body.files.length; i += WRITE_BATCH) {
|
|
178909
178958
|
await Promise.all(body.files.slice(i, i + WRITE_BATCH).map(async (file3) => {
|
|
@@ -178914,8 +178963,8 @@ var projectRoutes = new Elysia({ prefix: "/api/v1/project" }).get("/list", async
|
|
|
178914
178963
|
if (!dest.startsWith(stagingDir + path31.sep)) {
|
|
178915
178964
|
throw new Error(`Path escapes staging directory: ${file3.relativePath}`);
|
|
178916
178965
|
}
|
|
178917
|
-
await
|
|
178918
|
-
await
|
|
178966
|
+
await fs19.mkdir(path31.dirname(dest), { recursive: true });
|
|
178967
|
+
await fs19.writeFile(dest, file3.content, "utf-8");
|
|
178919
178968
|
}));
|
|
178920
178969
|
}
|
|
178921
178970
|
return await getIndexProjectTool().handle({
|
|
@@ -179070,7 +179119,7 @@ var analyticsRoutes = new Elysia({ prefix: "/api/v1/analytics" }).post("/", asyn
|
|
|
179070
179119
|
// src/routes/system.ts
|
|
179071
179120
|
init_dist();
|
|
179072
179121
|
import path32 from "path";
|
|
179073
|
-
import
|
|
179122
|
+
import fs20 from "fs";
|
|
179074
179123
|
import os7 from "os";
|
|
179075
179124
|
function databaseUrlParts() {
|
|
179076
179125
|
const url2 = new URL(process.env.DATABASE_URL);
|
|
@@ -179146,9 +179195,9 @@ var systemRoutes = new Elysia({ prefix: "/api/v1/system" }).get("/info", async (
|
|
|
179146
179195
|
}).get("/metrics", async () => {
|
|
179147
179196
|
const metricsPath = path32.join(process.cwd(), "data", "metrics.json");
|
|
179148
179197
|
let metrics2 = {};
|
|
179149
|
-
if (
|
|
179198
|
+
if (fs20.existsSync(metricsPath)) {
|
|
179150
179199
|
try {
|
|
179151
|
-
metrics2 = JSON.parse(
|
|
179200
|
+
metrics2 = JSON.parse(fs20.readFileSync(metricsPath, "utf-8"));
|
|
179152
179201
|
} catch {}
|
|
179153
179202
|
}
|
|
179154
179203
|
const database = await getDatabaseInfo();
|
|
@@ -179298,7 +179347,7 @@ var eventsRoutes = new Elysia({ prefix: "/api/v1" }).get("/events", async ({ que
|
|
|
179298
179347
|
});
|
|
179299
179348
|
|
|
179300
179349
|
// src/routes/workspace.ts
|
|
179301
|
-
import
|
|
179350
|
+
import fs21 from "fs/promises";
|
|
179302
179351
|
import path33 from "path";
|
|
179303
179352
|
import { realpathSync as realpathSync4 } from "fs";
|
|
179304
179353
|
var indexProjectTool2 = null;
|
|
@@ -179824,7 +179873,7 @@ var workspaceRoutes = new Elysia({ prefix: "/api/v1" }).get("/workspace/list", a
|
|
|
179824
179873
|
end = start + 20;
|
|
179825
179874
|
}
|
|
179826
179875
|
const absolutePath = path33.join(workspace.project_path, file3);
|
|
179827
|
-
const content = await
|
|
179876
|
+
const content = await fs21.readFile(absolutePath, "utf-8");
|
|
179828
179877
|
const lines = content.split(/\r?\n/);
|
|
179829
179878
|
const slice = lines.slice(start - 1, Math.min(lines.length, end));
|
|
179830
179879
|
const formatted = slice.map((text3, idx) => ({
|
|
@@ -179862,8 +179911,18 @@ function getReadFileTool() {
|
|
|
179862
179911
|
}
|
|
179863
179912
|
return readFileTool;
|
|
179864
179913
|
}
|
|
179865
|
-
|
|
179866
|
-
|
|
179914
|
+
function classifyReadFileFailureStatus(message) {
|
|
179915
|
+
if (message && /ENOENT|no such file/i.test(message)) {
|
|
179916
|
+
return 404;
|
|
179917
|
+
}
|
|
179918
|
+
return 400;
|
|
179919
|
+
}
|
|
179920
|
+
var fileRoutes = new Elysia({ prefix: "/api/v1/file" }).post("/read", async ({ body, set: set3 }) => {
|
|
179921
|
+
const result = await getReadFileTool().handle(body);
|
|
179922
|
+
if (result.success === false) {
|
|
179923
|
+
set3.status = classifyReadFileFailureStatus(result.error);
|
|
179924
|
+
}
|
|
179925
|
+
return result;
|
|
179867
179926
|
}, {
|
|
179868
179927
|
body: t.Object({
|
|
179869
179928
|
filePath: t.String({
|
|
@@ -180739,7 +180798,7 @@ var webRoutes = new Elysia({ prefix: "/api/v1/web" }).post("/fetch_and_index", a
|
|
|
180739
180798
|
});
|
|
180740
180799
|
|
|
180741
180800
|
// src/routes/web-ui.ts
|
|
180742
|
-
import
|
|
180801
|
+
import fs22 from "fs/promises";
|
|
180743
180802
|
import path34 from "path";
|
|
180744
180803
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
180745
180804
|
|
|
@@ -180798,7 +180857,7 @@ var STATIC_DIR_CANDIDATES = buildStaticDirCandidates(path34.dirname(fileURLToPat
|
|
|
180798
180857
|
async function resolveStaticDir() {
|
|
180799
180858
|
for (const dir of STATIC_DIR_CANDIDATES) {
|
|
180800
180859
|
try {
|
|
180801
|
-
const st = await
|
|
180860
|
+
const st = await fs22.stat(dir);
|
|
180802
180861
|
if (st.isDirectory())
|
|
180803
180862
|
return dir;
|
|
180804
180863
|
} catch {}
|
|
@@ -180836,7 +180895,7 @@ async function resolveSafePath(staticDir, sub) {
|
|
|
180836
180895
|
return null;
|
|
180837
180896
|
}
|
|
180838
180897
|
try {
|
|
180839
|
-
await
|
|
180898
|
+
await fs22.stat(abs);
|
|
180840
180899
|
return { abs, exists: true };
|
|
180841
180900
|
} catch {
|
|
180842
180901
|
return { abs, exists: false };
|
|
@@ -180859,7 +180918,7 @@ function injectAccessMarkup(html, apiKey, trusted) {
|
|
|
180859
180918
|
return out;
|
|
180860
180919
|
}
|
|
180861
180920
|
async function readShell(indexPath, remoteAddress) {
|
|
180862
|
-
const raw2 = await
|
|
180921
|
+
const raw2 = await fs22.readFile(indexPath, "utf-8");
|
|
180863
180922
|
const trusted = isTrustedWebUiCaller(remoteAddress);
|
|
180864
180923
|
return Buffer.from(injectAccessMarkup(raw2, getConfiguredApiKey(), trusted), "utf-8");
|
|
180865
180924
|
}
|
|
@@ -180909,7 +180968,7 @@ var webUiRoutes = new Elysia().get("/ui", async ({ set: set3, request }) => {
|
|
|
180909
180968
|
}
|
|
180910
180969
|
if (resolved.exists) {
|
|
180911
180970
|
try {
|
|
180912
|
-
const body = await
|
|
180971
|
+
const body = await fs22.readFile(resolved.abs);
|
|
180913
180972
|
set3.headers["content-type"] = contentTypeFor(resolved.abs);
|
|
180914
180973
|
return body;
|
|
180915
180974
|
} catch {
|
|
@@ -181145,10 +181204,13 @@ var profileRoutes = new Elysia({ prefix: "/api/v1/profiles" }).get("/", ({ query
|
|
|
181145
181204
|
});
|
|
181146
181205
|
|
|
181147
181206
|
// src/middleware/error.ts
|
|
181148
|
-
|
|
181149
|
-
|
|
181150
|
-
|
|
181151
|
-
|
|
181207
|
+
init_dist();
|
|
181208
|
+
var errorHandler = new Elysia({ name: "error-handler" }).onError(({ code, error: error51, set: set3, path: path35, request }) => {
|
|
181209
|
+
logger.error("[massa-ai-api] Request failed", undefined, {
|
|
181210
|
+
...safeErrorSummary(error51),
|
|
181211
|
+
code,
|
|
181212
|
+
path: path35,
|
|
181213
|
+
method: request.method
|
|
181152
181214
|
});
|
|
181153
181215
|
if (error51 instanceof SearchServiceError) {
|
|
181154
181216
|
set3.status = error51.statusCode;
|
|
@@ -181171,6 +181233,16 @@ var errorHandler = new Elysia({ name: "error-handler" }).onError(({ code, error:
|
|
|
181171
181233
|
}
|
|
181172
181234
|
};
|
|
181173
181235
|
}
|
|
181236
|
+
if (code === "NOT_FOUND") {
|
|
181237
|
+
set3.status = 404;
|
|
181238
|
+
return {
|
|
181239
|
+
success: false,
|
|
181240
|
+
error: {
|
|
181241
|
+
code: "NOT_FOUND",
|
|
181242
|
+
message: "Route not found"
|
|
181243
|
+
}
|
|
181244
|
+
};
|
|
181245
|
+
}
|
|
181174
181246
|
if (!set3.status || set3.status === 200) {
|
|
181175
181247
|
set3.status = 500;
|
|
181176
181248
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@massa-ai/tools-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
4
4
|
"author": "luizgmassa",
|
|
5
5
|
"description": "massa-ai REST API server - Semantic code search, memory, and context compression",
|
|
6
6
|
"type": "module",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"test": "bun scripts/run-tests-isolated.ts"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@massa-ai/core": "^1.
|
|
25
|
-
"@massa-ai/shared": "^1.
|
|
24
|
+
"@massa-ai/core": "^1.37.0",
|
|
25
|
+
"@massa-ai/shared": "^1.37.0",
|
|
26
26
|
"elysia": "^1.2.25",
|
|
27
27
|
"@elysiajs/swagger": "^1.2.0",
|
|
28
28
|
"@elysiajs/cors": "^1.2.0",
|