@massa-ai/mcp-client 1.46.0 → 1.47.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 +836 -425
- package/dist/index.js +885 -474
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -25398,9 +25398,16 @@ var init_xdg = () => {};
|
|
|
25398
25398
|
|
|
25399
25399
|
// ../../packages/shared/dist/config/massa-ai-config.js
|
|
25400
25400
|
import path2 from "path";
|
|
25401
|
-
var defaultMassaAiConfig;
|
|
25401
|
+
var SCHEDULER_JOB_KINDS, defaultMassaAiConfig;
|
|
25402
25402
|
var init_massa_ai_config = __esm(() => {
|
|
25403
25403
|
init_xdg();
|
|
25404
|
+
SCHEDULER_JOB_KINDS = [
|
|
25405
|
+
"memory-consolidation",
|
|
25406
|
+
"decay-sweep",
|
|
25407
|
+
"auto-improve",
|
|
25408
|
+
"observation-bridge",
|
|
25409
|
+
"checkpoint-purge"
|
|
25410
|
+
];
|
|
25404
25411
|
defaultMassaAiConfig = {
|
|
25405
25412
|
database: {
|
|
25406
25413
|
url: ""
|
|
@@ -25734,6 +25741,7 @@ var init_env = __esm(() => {
|
|
|
25734
25741
|
// ../../packages/shared/dist/config/config-writer.js
|
|
25735
25742
|
var init_config_writer = __esm(() => {
|
|
25736
25743
|
init_config_loader();
|
|
25744
|
+
init_massa_ai_config();
|
|
25737
25745
|
});
|
|
25738
25746
|
|
|
25739
25747
|
// ../../packages/shared/dist/config/api-key.js
|
|
@@ -25804,6 +25812,22 @@ function envList(key, fallback) {
|
|
|
25804
25812
|
const parsed = s.split(",").map((v) => v.trim()).filter((v) => v.length > 0);
|
|
25805
25813
|
return parsed.length > 0 ? parsed : fallback;
|
|
25806
25814
|
}
|
|
25815
|
+
function readSchedulerConfig(rawFileConfig) {
|
|
25816
|
+
try {
|
|
25817
|
+
const cfg = rawFileConfig;
|
|
25818
|
+
return cfg?.scheduler ?? {};
|
|
25819
|
+
} catch {
|
|
25820
|
+
return {};
|
|
25821
|
+
}
|
|
25822
|
+
}
|
|
25823
|
+
function resolveSchedulerJob(kind, fileJobs) {
|
|
25824
|
+
const meta3 = SCHEDULER_JOB_ENV[kind];
|
|
25825
|
+
const fileJob = fileJobs?.[kind];
|
|
25826
|
+
return {
|
|
25827
|
+
enabled: envBool(meta3.enabledVar, fileJob?.enabled ?? false),
|
|
25828
|
+
intervalMs: envNum(meta3.intervalVar, fileJob?.intervalMs ?? meta3.defaultIntervalMs)
|
|
25829
|
+
};
|
|
25830
|
+
}
|
|
25807
25831
|
function validateCapturePolicyConfig(raw2) {
|
|
25808
25832
|
if (!raw2 || typeof raw2 !== "object")
|
|
25809
25833
|
throw new TypeError("capturePolicy must be an object");
|
|
@@ -25931,6 +25955,11 @@ class Config {
|
|
|
25931
25955
|
rateLimit: { ...defaults.rateLimit, ...overrides.rateLimit },
|
|
25932
25956
|
security: { ...defaults.security, ...overrides.security },
|
|
25933
25957
|
logging: { ...defaults.logging, ...overrides.logging },
|
|
25958
|
+
scheduler: {
|
|
25959
|
+
...defaults.scheduler,
|
|
25960
|
+
...overrides.scheduler,
|
|
25961
|
+
jobs: { ...defaults.scheduler.jobs, ...overrides.scheduler?.jobs }
|
|
25962
|
+
},
|
|
25934
25963
|
synapse: {
|
|
25935
25964
|
...defaults.synapse,
|
|
25936
25965
|
...overrides.synapse,
|
|
@@ -25999,15 +26028,43 @@ class Config {
|
|
|
25999
26028
|
this.config[key] = value;
|
|
26000
26029
|
}
|
|
26001
26030
|
}
|
|
26002
|
-
var DEFAULT_LLM_MODEL = "qwen2.5:7b-instruct", DEFAULT_LLM_CODE_MODEL = "qwen2.5-coder:7b", MAX_IGNORE_PATTERNS = 1024, DEFAULT_ALLOWED_EXTENSIONS, fileConfig, fileCacheL1Bytes, fileCacheL2Bytes, defaultConfig, config2;
|
|
26031
|
+
var DEFAULT_LLM_MODEL = "qwen2.5:7b-instruct", DEFAULT_LLM_CODE_MODEL = "qwen2.5-coder:7b", SCHEDULER_JOB_ENV, MAX_IGNORE_PATTERNS = 1024, DEFAULT_ALLOWED_EXTENSIONS, fileConfig, fileCacheL1Bytes, fileCacheL2Bytes, resolvedDataDir, defaultConfig, config2;
|
|
26003
26032
|
var init_config = __esm(() => {
|
|
26004
26033
|
init_env();
|
|
26005
26034
|
init_config_loader();
|
|
26006
26035
|
init_massa_ai_config();
|
|
26036
|
+
init_massa_ai_config();
|
|
26007
26037
|
init_config_loader();
|
|
26008
26038
|
init_config_writer();
|
|
26009
26039
|
init_xdg();
|
|
26010
26040
|
init_api_key();
|
|
26041
|
+
SCHEDULER_JOB_ENV = {
|
|
26042
|
+
"memory-consolidation": {
|
|
26043
|
+
enabledVar: "MASSA_AI_SCHEDULER_CONSOLIDATION_ENABLED",
|
|
26044
|
+
intervalVar: "MASSA_AI_SCHEDULER_CONSOLIDATION_INTERVAL_MS",
|
|
26045
|
+
defaultIntervalMs: 30 * 60 * 1000
|
|
26046
|
+
},
|
|
26047
|
+
"decay-sweep": {
|
|
26048
|
+
enabledVar: "MASSA_AI_SCHEDULER_DECAY_ENABLED",
|
|
26049
|
+
intervalVar: "MASSA_AI_SCHEDULER_DECAY_INTERVAL_MS",
|
|
26050
|
+
defaultIntervalMs: 60 * 60 * 1000
|
|
26051
|
+
},
|
|
26052
|
+
"auto-improve": {
|
|
26053
|
+
enabledVar: "MASSA_AI_SCHEDULER_AUTO_IMPROVE_ENABLED",
|
|
26054
|
+
intervalVar: "MASSA_AI_SCHEDULER_AUTO_IMPROVE_INTERVAL_MS",
|
|
26055
|
+
defaultIntervalMs: 30 * 60 * 1000
|
|
26056
|
+
},
|
|
26057
|
+
"observation-bridge": {
|
|
26058
|
+
enabledVar: "MASSA_AI_SCHEDULER_OBSERVATION_BRIDGE_ENABLED",
|
|
26059
|
+
intervalVar: "MASSA_AI_SCHEDULER_OBSERVATION_BRIDGE_INTERVAL_MS",
|
|
26060
|
+
defaultIntervalMs: 30 * 60 * 1000
|
|
26061
|
+
},
|
|
26062
|
+
"checkpoint-purge": {
|
|
26063
|
+
enabledVar: "MASSA_AI_SCHEDULER_CHECKPOINT_PURGE_ENABLED",
|
|
26064
|
+
intervalVar: "MASSA_AI_SCHEDULER_CHECKPOINT_PURGE_INTERVAL_MS",
|
|
26065
|
+
defaultIntervalMs: 60 * 60 * 1000
|
|
26066
|
+
}
|
|
26067
|
+
};
|
|
26011
26068
|
DEFAULT_ALLOWED_EXTENSIONS = [
|
|
26012
26069
|
".ts",
|
|
26013
26070
|
".js",
|
|
@@ -26046,10 +26103,11 @@ var init_config = __esm(() => {
|
|
|
26046
26103
|
fileConfig = loadConfigSafe();
|
|
26047
26104
|
fileCacheL1Bytes = fileConfig.cache?.l1MaxSizeMB ? fileConfig.cache.l1MaxSizeMB * 1024 * 1024 : undefined;
|
|
26048
26105
|
fileCacheL2Bytes = fileConfig.cache?.l2MaxSizeMB ? fileConfig.cache.l2MaxSizeMB * 1024 * 1024 : undefined;
|
|
26106
|
+
resolvedDataDir = getGlobalDataDir();
|
|
26049
26107
|
defaultConfig = {
|
|
26050
26108
|
name: "massa-ai-server",
|
|
26051
26109
|
version: "1.0.0",
|
|
26052
|
-
dataDir:
|
|
26110
|
+
dataDir: resolvedDataDir,
|
|
26053
26111
|
cache: {
|
|
26054
26112
|
l1: {
|
|
26055
26113
|
maxSize: envNum("L1_CACHE_MAX_SIZE", fileCacheL1Bytes ?? 100 * 1024 * 1024),
|
|
@@ -26173,8 +26231,24 @@ var init_config = __esm(() => {
|
|
|
26173
26231
|
logging: {
|
|
26174
26232
|
level: process.env.LOG_LEVEL || fileConfig.logging?.level || "info",
|
|
26175
26233
|
enableMetrics: process.env.ENABLE_METRICS === "true" || process.env.ENABLE_METRICS === undefined && !!fileConfig.logging?.enableMetrics,
|
|
26176
|
-
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file ||
|
|
26177
|
-
|
|
26234
|
+
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file || path4.join(resolvedDataDir, "logs", "massa-ai.log"),
|
|
26235
|
+
enableFileSink: envBool("MASSA_AI_LOG_ENABLE_FILE_SINK", fileConfig.logging?.enableFileSink ?? true),
|
|
26236
|
+
bufferSize: envNum("MASSA_AI_LOG_BUFFER_SIZE", fileConfig.logging?.bufferSize ?? 2000),
|
|
26237
|
+
maxFileSizeMb: envNum("MASSA_AI_LOG_MAX_FILE_SIZE_MB", fileConfig.logging?.maxFileSizeMb ?? 32),
|
|
26238
|
+
maxFiles: envNum("MASSA_AI_LOG_MAX_FILES", fileConfig.logging?.maxFiles ?? 5)
|
|
26239
|
+
},
|
|
26240
|
+
scheduler: (() => {
|
|
26241
|
+
const fileScheduler = readSchedulerConfig(fileConfig);
|
|
26242
|
+
return {
|
|
26243
|
+
enabled: envBool("MASSA_AI_SCHEDULER_ENABLED", fileScheduler.enabled ?? false),
|
|
26244
|
+
tickMs: envNum("MASSA_AI_SCHEDULER_TICK_MS", fileScheduler.tickMs ?? 60000),
|
|
26245
|
+
maxConcurrent: envNum("MASSA_AI_SCHEDULER_MAX_CONCURRENT", fileScheduler.maxConcurrent ?? 2),
|
|
26246
|
+
jobs: Object.fromEntries(SCHEDULER_JOB_KINDS.map((kind) => [
|
|
26247
|
+
kind,
|
|
26248
|
+
resolveSchedulerJob(kind, fileScheduler.jobs)
|
|
26249
|
+
]))
|
|
26250
|
+
};
|
|
26251
|
+
})(),
|
|
26178
26252
|
synapse: {
|
|
26179
26253
|
enabled: process.env.SYNAPSE_ENABLED !== "false",
|
|
26180
26254
|
inhibition: {
|
|
@@ -26326,13 +26400,175 @@ var init_types2 = __esm(() => {
|
|
|
26326
26400
|
// ../../packages/shared/dist/types/interfaces.js
|
|
26327
26401
|
var init_interfaces = () => {};
|
|
26328
26402
|
|
|
26329
|
-
// ../../packages/shared/dist/utils/
|
|
26403
|
+
// ../../packages/shared/dist/utils/log-sink.js
|
|
26330
26404
|
import fs2 from "fs";
|
|
26405
|
+
import path5 from "path";
|
|
26406
|
+
function getState(filePath) {
|
|
26407
|
+
let state = pathState.get(filePath);
|
|
26408
|
+
if (!state) {
|
|
26409
|
+
state = { trackedSize: 0, deltaSinceStat: 0, primed: false };
|
|
26410
|
+
pathState.set(filePath, state);
|
|
26411
|
+
}
|
|
26412
|
+
return state;
|
|
26413
|
+
}
|
|
26414
|
+
function ensureDir(filePath) {
|
|
26415
|
+
const dir = path5.dirname(filePath);
|
|
26416
|
+
if (ensuredDirs.has(dir))
|
|
26417
|
+
return;
|
|
26418
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
26419
|
+
ensuredDirs.add(dir);
|
|
26420
|
+
}
|
|
26421
|
+
function restat(filePath, state) {
|
|
26422
|
+
try {
|
|
26423
|
+
state.trackedSize = fs2.statSync(filePath).size;
|
|
26424
|
+
} catch {
|
|
26425
|
+
state.trackedSize = 0;
|
|
26426
|
+
}
|
|
26427
|
+
state.deltaSinceStat = 0;
|
|
26428
|
+
state.primed = true;
|
|
26429
|
+
}
|
|
26430
|
+
function rotate(filePath, maxFiles) {
|
|
26431
|
+
if (maxFiles <= 0) {
|
|
26432
|
+
if (fs2.existsSync(filePath))
|
|
26433
|
+
fs2.unlinkSync(filePath);
|
|
26434
|
+
return;
|
|
26435
|
+
}
|
|
26436
|
+
const oldest = `${filePath}.${maxFiles}`;
|
|
26437
|
+
if (fs2.existsSync(oldest))
|
|
26438
|
+
fs2.unlinkSync(oldest);
|
|
26439
|
+
for (let n = maxFiles - 1;n >= 1; n--) {
|
|
26440
|
+
const src = `${filePath}.${n}`;
|
|
26441
|
+
const dest = `${filePath}.${n + 1}`;
|
|
26442
|
+
if (fs2.existsSync(src))
|
|
26443
|
+
fs2.renameSync(src, dest);
|
|
26444
|
+
}
|
|
26445
|
+
if (fs2.existsSync(filePath))
|
|
26446
|
+
fs2.renameSync(filePath, `${filePath}.1`);
|
|
26447
|
+
}
|
|
26448
|
+
function appendLine(opts, line) {
|
|
26449
|
+
const { filePath, maxFileSizeBytes, maxFiles } = opts;
|
|
26450
|
+
try {
|
|
26451
|
+
ensureDir(filePath);
|
|
26452
|
+
const state = getState(filePath);
|
|
26453
|
+
const lineBytes = Buffer.byteLength(line + `
|
|
26454
|
+
`, "utf8");
|
|
26455
|
+
if (!state.primed || state.deltaSinceStat >= STAT_DELTA_THRESHOLD_BYTES || state.trackedSize + state.deltaSinceStat >= maxFileSizeBytes) {
|
|
26456
|
+
restat(filePath, state);
|
|
26457
|
+
}
|
|
26458
|
+
if (maxFileSizeBytes > 0 && state.trackedSize >= maxFileSizeBytes) {
|
|
26459
|
+
rotate(filePath, maxFiles);
|
|
26460
|
+
state.trackedSize = 0;
|
|
26461
|
+
state.deltaSinceStat = 0;
|
|
26462
|
+
state.primed = true;
|
|
26463
|
+
}
|
|
26464
|
+
fs2.appendFileSync(filePath, line + `
|
|
26465
|
+
`);
|
|
26466
|
+
state.trackedSize += lineBytes;
|
|
26467
|
+
state.deltaSinceStat += lineBytes;
|
|
26468
|
+
} catch (err) {
|
|
26469
|
+
lastError = err;
|
|
26470
|
+
}
|
|
26471
|
+
}
|
|
26472
|
+
var STAT_DELTA_THRESHOLD_BYTES, ensuredDirs, pathState, lastError;
|
|
26473
|
+
var init_log_sink = __esm(() => {
|
|
26474
|
+
STAT_DELTA_THRESHOLD_BYTES = 1024 * 1024;
|
|
26475
|
+
ensuredDirs = new Set;
|
|
26476
|
+
pathState = new Map;
|
|
26477
|
+
});
|
|
26478
|
+
|
|
26479
|
+
// ../../packages/shared/dist/utils/log-buffer.js
|
|
26480
|
+
class LogBufferImpl {
|
|
26481
|
+
capacity = DEFAULT_CAPACITY;
|
|
26482
|
+
entries = [];
|
|
26483
|
+
subscribers = new Set;
|
|
26484
|
+
nextSeq = 0;
|
|
26485
|
+
dispatching = false;
|
|
26486
|
+
pending = [];
|
|
26487
|
+
push(entry) {
|
|
26488
|
+
if (this.dispatching) {
|
|
26489
|
+
this.pending.push(entry);
|
|
26490
|
+
return;
|
|
26491
|
+
}
|
|
26492
|
+
this.dispatching = true;
|
|
26493
|
+
try {
|
|
26494
|
+
this.pushOne(entry);
|
|
26495
|
+
while (this.pending.length > 0) {
|
|
26496
|
+
const next = this.pending.shift();
|
|
26497
|
+
this.pushOne(next);
|
|
26498
|
+
}
|
|
26499
|
+
} finally {
|
|
26500
|
+
this.dispatching = false;
|
|
26501
|
+
}
|
|
26502
|
+
}
|
|
26503
|
+
pushOne(entry) {
|
|
26504
|
+
const full = { ...entry, seq: this.nextSeq++ };
|
|
26505
|
+
this.entries.push(full);
|
|
26506
|
+
while (this.entries.length > this.capacity) {
|
|
26507
|
+
this.entries.shift();
|
|
26508
|
+
}
|
|
26509
|
+
for (const fn of this.subscribers) {
|
|
26510
|
+
try {
|
|
26511
|
+
fn(full);
|
|
26512
|
+
} catch {}
|
|
26513
|
+
}
|
|
26514
|
+
}
|
|
26515
|
+
snapshot(opts) {
|
|
26516
|
+
const from = opts?.from;
|
|
26517
|
+
const to = opts?.to;
|
|
26518
|
+
const level = opts?.level;
|
|
26519
|
+
const q = opts?.q?.toLowerCase();
|
|
26520
|
+
const result = [];
|
|
26521
|
+
for (let i = this.entries.length - 1;i >= 0; i--) {
|
|
26522
|
+
const e = this.entries[i];
|
|
26523
|
+
if (from !== undefined && e.seq < from)
|
|
26524
|
+
continue;
|
|
26525
|
+
if (to !== undefined && e.seq > to)
|
|
26526
|
+
continue;
|
|
26527
|
+
if (level !== undefined && e.level !== level)
|
|
26528
|
+
continue;
|
|
26529
|
+
if (q !== undefined && !e.message.toLowerCase().includes(q))
|
|
26530
|
+
continue;
|
|
26531
|
+
result.push(e);
|
|
26532
|
+
}
|
|
26533
|
+
return result;
|
|
26534
|
+
}
|
|
26535
|
+
subscribe(fn) {
|
|
26536
|
+
this.subscribers.add(fn);
|
|
26537
|
+
return () => {
|
|
26538
|
+
this.subscribers.delete(fn);
|
|
26539
|
+
};
|
|
26540
|
+
}
|
|
26541
|
+
setCapacity(n) {
|
|
26542
|
+
this.capacity = n > 0 ? n : 0;
|
|
26543
|
+
while (this.entries.length > this.capacity) {
|
|
26544
|
+
this.entries.shift();
|
|
26545
|
+
}
|
|
26546
|
+
}
|
|
26547
|
+
size() {
|
|
26548
|
+
return this.entries.length;
|
|
26549
|
+
}
|
|
26550
|
+
_resetForTesting() {
|
|
26551
|
+
this.entries = [];
|
|
26552
|
+
this.subscribers.clear();
|
|
26553
|
+
this.nextSeq = 0;
|
|
26554
|
+
this.dispatching = false;
|
|
26555
|
+
this.pending = [];
|
|
26556
|
+
this.capacity = DEFAULT_CAPACITY;
|
|
26557
|
+
}
|
|
26558
|
+
}
|
|
26559
|
+
var DEFAULT_CAPACITY = 2000, logBuffer;
|
|
26560
|
+
var init_log_buffer = __esm(() => {
|
|
26561
|
+
logBuffer = new LogBufferImpl;
|
|
26562
|
+
});
|
|
26331
26563
|
|
|
26564
|
+
// ../../packages/shared/dist/utils/logger.js
|
|
26332
26565
|
class Logger {
|
|
26333
26566
|
_level;
|
|
26334
26567
|
_enableMetrics;
|
|
26335
26568
|
_logFilePath;
|
|
26569
|
+
_enableFileSink;
|
|
26570
|
+
_maxFileSizeBytes;
|
|
26571
|
+
_maxFiles;
|
|
26336
26572
|
_initialized = false;
|
|
26337
26573
|
constructor() {}
|
|
26338
26574
|
ensureInitialized() {
|
|
@@ -26342,10 +26578,18 @@ class Logger {
|
|
|
26342
26578
|
this._level = this.parseLogLevel(loggingConfig.level);
|
|
26343
26579
|
this._enableMetrics = loggingConfig.enableMetrics;
|
|
26344
26580
|
this._logFilePath = loggingConfig.file;
|
|
26581
|
+
this._enableFileSink = loggingConfig.enableFileSink;
|
|
26582
|
+
this._maxFileSizeBytes = loggingConfig.maxFileSizeMb * 1024 * 1024;
|
|
26583
|
+
this._maxFiles = loggingConfig.maxFiles;
|
|
26584
|
+
logBuffer.setCapacity(loggingConfig.bufferSize);
|
|
26345
26585
|
} catch {
|
|
26346
26586
|
this._level = LogLevel.INFO;
|
|
26347
26587
|
this._enableMetrics = false;
|
|
26348
26588
|
this._logFilePath = undefined;
|
|
26589
|
+
this._enableFileSink = false;
|
|
26590
|
+
this._maxFileSizeBytes = 32 * 1024 * 1024;
|
|
26591
|
+
this._maxFiles = 5;
|
|
26592
|
+
logBuffer.setCapacity(2000);
|
|
26349
26593
|
}
|
|
26350
26594
|
this._initialized = true;
|
|
26351
26595
|
}
|
|
@@ -26362,6 +26606,18 @@ class Logger {
|
|
|
26362
26606
|
this.ensureInitialized();
|
|
26363
26607
|
return this._logFilePath;
|
|
26364
26608
|
}
|
|
26609
|
+
get enableFileSink() {
|
|
26610
|
+
this.ensureInitialized();
|
|
26611
|
+
return this._enableFileSink;
|
|
26612
|
+
}
|
|
26613
|
+
get maxFileSizeBytes() {
|
|
26614
|
+
this.ensureInitialized();
|
|
26615
|
+
return this._maxFileSizeBytes;
|
|
26616
|
+
}
|
|
26617
|
+
get maxFiles() {
|
|
26618
|
+
this.ensureInitialized();
|
|
26619
|
+
return this._maxFiles;
|
|
26620
|
+
}
|
|
26365
26621
|
parseLogLevel(level) {
|
|
26366
26622
|
const levels = {
|
|
26367
26623
|
debug: LogLevel.DEBUG,
|
|
@@ -26374,34 +26630,40 @@ class Logger {
|
|
|
26374
26630
|
shouldLog(level) {
|
|
26375
26631
|
return level >= this.level;
|
|
26376
26632
|
}
|
|
26377
|
-
formatMessage(level, message, meta3) {
|
|
26378
|
-
const timestamp = new Date().toISOString();
|
|
26633
|
+
formatMessage(level, message, meta3, timestamp = new Date().toISOString()) {
|
|
26379
26634
|
const metaStr = meta3 ? ` ${JSON.stringify(meta3)}` : "";
|
|
26380
26635
|
return `[${timestamp}] [${level}] ${message}${metaStr}`;
|
|
26381
26636
|
}
|
|
26382
|
-
|
|
26383
|
-
|
|
26384
|
-
const
|
|
26385
|
-
|
|
26386
|
-
|
|
26387
|
-
|
|
26388
|
-
|
|
26389
|
-
|
|
26637
|
+
emit(level, message, meta3) {
|
|
26638
|
+
const ts = new Date().toISOString();
|
|
26639
|
+
const line = this.formatMessage(LOG_LEVEL_LABELS[level], message, meta3, ts);
|
|
26640
|
+
console.error(line);
|
|
26641
|
+
if (this.enableFileSink) {
|
|
26642
|
+
const filePath = this.logFilePath;
|
|
26643
|
+
if (filePath) {
|
|
26644
|
+
appendLine({ filePath, maxFileSizeBytes: this.maxFileSizeBytes, maxFiles: this.maxFiles }, line);
|
|
26645
|
+
}
|
|
26390
26646
|
}
|
|
26647
|
+
logBuffer.push({
|
|
26648
|
+
ts,
|
|
26649
|
+
level: LOG_LEVEL_BUFFER_TAGS[level],
|
|
26650
|
+
message,
|
|
26651
|
+
...meta3 ? { meta: meta3 } : {}
|
|
26652
|
+
});
|
|
26391
26653
|
}
|
|
26392
26654
|
debug(message, meta3) {
|
|
26393
26655
|
if (this.shouldLog(LogLevel.DEBUG)) {
|
|
26394
|
-
this.
|
|
26656
|
+
this.emit(LogLevel.DEBUG, message, meta3);
|
|
26395
26657
|
}
|
|
26396
26658
|
}
|
|
26397
26659
|
info(message, meta3) {
|
|
26398
26660
|
if (this.shouldLog(LogLevel.INFO)) {
|
|
26399
|
-
this.
|
|
26661
|
+
this.emit(LogLevel.INFO, message, meta3);
|
|
26400
26662
|
}
|
|
26401
26663
|
}
|
|
26402
26664
|
warn(message, meta3) {
|
|
26403
26665
|
if (this.shouldLog(LogLevel.WARN)) {
|
|
26404
|
-
this.
|
|
26666
|
+
this.emit(LogLevel.WARN, message, meta3);
|
|
26405
26667
|
}
|
|
26406
26668
|
}
|
|
26407
26669
|
error(message, error51, meta3) {
|
|
@@ -26414,7 +26676,7 @@ class Logger {
|
|
|
26414
26676
|
stack: error51.stack
|
|
26415
26677
|
}
|
|
26416
26678
|
} : meta3;
|
|
26417
|
-
this.
|
|
26679
|
+
this.emit(LogLevel.ERROR, message, errorMeta);
|
|
26418
26680
|
}
|
|
26419
26681
|
}
|
|
26420
26682
|
metric(name, value, unit) {
|
|
@@ -26443,15 +26705,29 @@ class Logger {
|
|
|
26443
26705
|
return childLogger;
|
|
26444
26706
|
}
|
|
26445
26707
|
}
|
|
26446
|
-
var LogLevel, logger;
|
|
26708
|
+
var LogLevel, LOG_LEVEL_LABELS, LOG_LEVEL_BUFFER_TAGS, logger;
|
|
26447
26709
|
var init_logger = __esm(() => {
|
|
26448
26710
|
init_config();
|
|
26711
|
+
init_log_sink();
|
|
26712
|
+
init_log_buffer();
|
|
26449
26713
|
(function(LogLevel2) {
|
|
26450
26714
|
LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
|
|
26451
26715
|
LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
|
|
26452
26716
|
LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
|
|
26453
26717
|
LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
|
|
26454
26718
|
})(LogLevel || (LogLevel = {}));
|
|
26719
|
+
LOG_LEVEL_LABELS = {
|
|
26720
|
+
[LogLevel.DEBUG]: "DEBUG",
|
|
26721
|
+
[LogLevel.INFO]: "INFO",
|
|
26722
|
+
[LogLevel.WARN]: "WARN",
|
|
26723
|
+
[LogLevel.ERROR]: "ERROR"
|
|
26724
|
+
};
|
|
26725
|
+
LOG_LEVEL_BUFFER_TAGS = {
|
|
26726
|
+
[LogLevel.DEBUG]: "debug",
|
|
26727
|
+
[LogLevel.INFO]: "info",
|
|
26728
|
+
[LogLevel.WARN]: "warn",
|
|
26729
|
+
[LogLevel.ERROR]: "error"
|
|
26730
|
+
};
|
|
26455
26731
|
logger = new Logger;
|
|
26456
26732
|
});
|
|
26457
26733
|
|
|
@@ -26734,6 +27010,8 @@ var init_rate_limiter = __esm(() => {
|
|
|
26734
27010
|
// ../../packages/shared/dist/utils/index.js
|
|
26735
27011
|
var init_utils = __esm(() => {
|
|
26736
27012
|
init_logger();
|
|
27013
|
+
init_log_buffer();
|
|
27014
|
+
init_log_sink();
|
|
26737
27015
|
init_sanitizer();
|
|
26738
27016
|
init_metrics();
|
|
26739
27017
|
init_rate_limiter();
|
|
@@ -26741,7 +27019,7 @@ var init_utils = __esm(() => {
|
|
|
26741
27019
|
|
|
26742
27020
|
// ../../packages/shared/dist/profile-switch/hosts.js
|
|
26743
27021
|
import os3 from "os";
|
|
26744
|
-
import
|
|
27022
|
+
import path6 from "path";
|
|
26745
27023
|
function isHost(v) {
|
|
26746
27024
|
return typeof v === "string" && HOSTS.includes(v);
|
|
26747
27025
|
}
|
|
@@ -26752,7 +27030,7 @@ function fileLayout(host, activeDir, activeGlob, variantsRoot) {
|
|
|
26752
27030
|
activeDir,
|
|
26753
27031
|
activeGlob,
|
|
26754
27032
|
variantsRoot,
|
|
26755
|
-
variantDir: (profile) =>
|
|
27033
|
+
variantDir: (profile) => path6.join(variantsRoot, profile)
|
|
26756
27034
|
};
|
|
26757
27035
|
}
|
|
26758
27036
|
function resolveHostLayout(host, opts = {}) {
|
|
@@ -26762,25 +27040,37 @@ function resolveHostLayout(host, opts = {}) {
|
|
|
26762
27040
|
case "cursor":
|
|
26763
27041
|
return { host, route: "skip", reason: CURSOR_SKIP_REASON };
|
|
26764
27042
|
case "claude": {
|
|
26765
|
-
const
|
|
26766
|
-
|
|
27043
|
+
const marketplaceRoot = opts.marketplaceRoot?.claude;
|
|
27044
|
+
if (override === undefined && marketplaceRoot !== undefined) {
|
|
27045
|
+
return fileLayout(host, path6.join(marketplaceRoot, "agents"), "massa-ai-*.md", path6.join(marketplaceRoot, "agent-profiles"));
|
|
27046
|
+
}
|
|
27047
|
+
const root = override ?? path6.join(targetHome, ".claude");
|
|
27048
|
+
return fileLayout(host, path6.join(root, "agents"), "massa-ai-*.md", path6.join(root, "massa-ai", "agent-profiles"));
|
|
26767
27049
|
}
|
|
26768
27050
|
case "codex": {
|
|
26769
|
-
const root = override ??
|
|
26770
|
-
return fileLayout(host,
|
|
27051
|
+
const root = override ?? path6.join(targetHome, ".codex");
|
|
27052
|
+
return fileLayout(host, path6.join(root, "agents"), "massa-ai-*.toml", path6.join(root, "massa-ai", "agent-profiles"));
|
|
26771
27053
|
}
|
|
26772
27054
|
case "opencode": {
|
|
26773
|
-
const root = override ??
|
|
26774
|
-
const pluginsDir =
|
|
26775
|
-
return fileLayout(host,
|
|
27055
|
+
const root = override ?? path6.join(targetHome, ".config", "opencode");
|
|
27056
|
+
const pluginsDir = path6.join(root, "plugins", "massa-ai");
|
|
27057
|
+
return fileLayout(host, path6.join(root, "agents"), "massa-ai-*.md", path6.join(pluginsDir, "agent-profiles"));
|
|
26776
27058
|
}
|
|
26777
27059
|
}
|
|
26778
27060
|
}
|
|
26779
|
-
function detectRoute(platform) {
|
|
27061
|
+
function detectRoute(platform, host) {
|
|
26780
27062
|
const route = platform?.installRoute;
|
|
26781
27063
|
if (route === "file")
|
|
26782
27064
|
return { kind: "proceed" };
|
|
26783
27065
|
if (route === "marketplace") {
|
|
27066
|
+
if (host === "claude")
|
|
27067
|
+
return { kind: "proceed" };
|
|
27068
|
+
if (host === "codex") {
|
|
27069
|
+
return {
|
|
27070
|
+
kind: "refuse",
|
|
27071
|
+
reason: "codex marketplace-route installs are refused (in-place bundle rewrite would dirty a checkout " + "and break the drift gate) \u2014 use the dev path: MASSA_AI_MODEL_PROFILE + regenerate."
|
|
27072
|
+
};
|
|
27073
|
+
}
|
|
26784
27074
|
return {
|
|
26785
27075
|
kind: "refuse",
|
|
26786
27076
|
reason: "claude/codex marketplace-route installs are refused (in-place bundle rewrite would dirty a checkout " + "and break the drift gate) \u2014 use the dev path: MASSA_AI_MODEL_PROFILE + regenerate."
|
|
@@ -26798,7 +27088,7 @@ var init_hosts = __esm(() => {
|
|
|
26798
27088
|
|
|
26799
27089
|
// ../../packages/shared/dist/profile-switch/state.js
|
|
26800
27090
|
import fs3 from "fs";
|
|
26801
|
-
import
|
|
27091
|
+
import path7 from "path";
|
|
26802
27092
|
function namedError(name, message) {
|
|
26803
27093
|
const err = new InstallStateError(message);
|
|
26804
27094
|
err.name = name;
|
|
@@ -26844,7 +27134,7 @@ function writeInstallState(filePath, state) {
|
|
|
26844
27134
|
const text = `${JSON.stringify(validated, null, 2)}
|
|
26845
27135
|
`;
|
|
26846
27136
|
try {
|
|
26847
|
-
fs3.mkdirSync(
|
|
27137
|
+
fs3.mkdirSync(path7.dirname(filePath), { recursive: true });
|
|
26848
27138
|
fs3.writeFileSync(filePath, text);
|
|
26849
27139
|
} catch (err) {
|
|
26850
27140
|
throw UnwritableInstallStateError(filePath, err.message);
|
|
@@ -26873,7 +27163,7 @@ var init_state = __esm(() => {
|
|
|
26873
27163
|
|
|
26874
27164
|
// ../../packages/shared/dist/profile-switch/lock.js
|
|
26875
27165
|
import fs4 from "fs";
|
|
26876
|
-
import
|
|
27166
|
+
import path8 from "path";
|
|
26877
27167
|
import os4 from "os";
|
|
26878
27168
|
import crypto3 from "crypto";
|
|
26879
27169
|
import { execFileSync } from "child_process";
|
|
@@ -26905,7 +27195,7 @@ function releaseIfOwned(lockDir, ownerPath, token) {
|
|
|
26905
27195
|
}
|
|
26906
27196
|
function acquireLock(stateFilePath, options = {}) {
|
|
26907
27197
|
const lockDir = `${stateFilePath}.switch.lock`;
|
|
26908
|
-
const ownerPath =
|
|
27198
|
+
const ownerPath = path8.join(lockDir, "owner.json");
|
|
26909
27199
|
const clock = options.clock ?? DEFAULT_CLOCK;
|
|
26910
27200
|
const identity = options.identity ?? DEFAULT_IDENTITY;
|
|
26911
27201
|
const staleAfterMs = options.staleAfterMs ?? DEFAULT_STALE_AFTER_MS;
|
|
@@ -26925,7 +27215,7 @@ function acquireLock(stateFilePath, options = {}) {
|
|
|
26925
27215
|
token,
|
|
26926
27216
|
timestamp: clock.now()
|
|
26927
27217
|
};
|
|
26928
|
-
fs4.mkdirSync(
|
|
27218
|
+
fs4.mkdirSync(path8.dirname(ownerPath), { recursive: true });
|
|
26929
27219
|
fs4.writeFileSync(ownerPath, JSON.stringify(record3));
|
|
26930
27220
|
return { lockDir, release: () => releaseIfOwned(lockDir, ownerPath, token) };
|
|
26931
27221
|
};
|
|
@@ -26978,10 +27268,59 @@ var init_lock = __esm(() => {
|
|
|
26978
27268
|
};
|
|
26979
27269
|
});
|
|
26980
27270
|
|
|
26981
|
-
// ../../packages/shared/dist/profile-switch/
|
|
27271
|
+
// ../../packages/shared/dist/profile-switch/claude-marketplace.js
|
|
26982
27272
|
import fs5 from "fs";
|
|
26983
|
-
import path8 from "path";
|
|
26984
27273
|
import os5 from "os";
|
|
27274
|
+
import path9 from "path";
|
|
27275
|
+
function selectRecord(records) {
|
|
27276
|
+
if (records.length === 0)
|
|
27277
|
+
return;
|
|
27278
|
+
const userScoped = records.filter((r) => r.scope === "user");
|
|
27279
|
+
const pool = userScoped.length > 0 ? userScoped : records;
|
|
27280
|
+
let best;
|
|
27281
|
+
let bestTime = -Infinity;
|
|
27282
|
+
for (const record3 of pool) {
|
|
27283
|
+
const parsed = record3.lastUpdated ? Date.parse(record3.lastUpdated) : NaN;
|
|
27284
|
+
if (Number.isFinite(parsed) && parsed >= bestTime) {
|
|
27285
|
+
best = record3;
|
|
27286
|
+
bestTime = parsed;
|
|
27287
|
+
}
|
|
27288
|
+
}
|
|
27289
|
+
return best ?? pool[pool.length - 1];
|
|
27290
|
+
}
|
|
27291
|
+
function resolveClaudeMarketplaceRoot(opts = {}) {
|
|
27292
|
+
const targetHome = opts.targetHome ?? os5.homedir();
|
|
27293
|
+
const pluginKey = opts.pluginKey ?? DEFAULT_PLUGIN_KEY;
|
|
27294
|
+
const registryPath = path9.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
27295
|
+
let records;
|
|
27296
|
+
try {
|
|
27297
|
+
const raw2 = fs5.readFileSync(registryPath, "utf8");
|
|
27298
|
+
const parsed = JSON.parse(raw2);
|
|
27299
|
+
records = parsed?.plugins?.[pluginKey];
|
|
27300
|
+
} catch {
|
|
27301
|
+
return null;
|
|
27302
|
+
}
|
|
27303
|
+
if (!Array.isArray(records) || records.length === 0)
|
|
27304
|
+
return null;
|
|
27305
|
+
const selected = selectRecord(records);
|
|
27306
|
+
const installPath = selected?.installPath;
|
|
27307
|
+
if (!installPath)
|
|
27308
|
+
return null;
|
|
27309
|
+
try {
|
|
27310
|
+
if (!fs5.existsSync(installPath))
|
|
27311
|
+
return null;
|
|
27312
|
+
} catch {
|
|
27313
|
+
return null;
|
|
27314
|
+
}
|
|
27315
|
+
return installPath;
|
|
27316
|
+
}
|
|
27317
|
+
var DEFAULT_PLUGIN_KEY = "massa-ai@massa-ai";
|
|
27318
|
+
var init_claude_marketplace = () => {};
|
|
27319
|
+
|
|
27320
|
+
// ../../packages/shared/dist/profile-switch/engine.js
|
|
27321
|
+
import fs6 from "fs";
|
|
27322
|
+
import path10 from "path";
|
|
27323
|
+
import os6 from "os";
|
|
26985
27324
|
import crypto4 from "crypto";
|
|
26986
27325
|
function namedError3(name, message) {
|
|
26987
27326
|
const err = new SwitchEngineError(message);
|
|
@@ -26989,19 +27328,39 @@ function namedError3(name, message) {
|
|
|
26989
27328
|
return err;
|
|
26990
27329
|
}
|
|
26991
27330
|
function defaultStatePath(targetHome) {
|
|
26992
|
-
return
|
|
27331
|
+
return path10.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
26993
27332
|
}
|
|
26994
27333
|
function resolveCommon(opts) {
|
|
26995
|
-
const targetHome = opts.targetHome ??
|
|
27334
|
+
const targetHome = opts.targetHome ?? os6.homedir();
|
|
26996
27335
|
const stateFilePath = opts.stateFilePath ?? defaultStatePath(targetHome);
|
|
26997
27336
|
return { targetHome, stateFilePath };
|
|
26998
27337
|
}
|
|
27338
|
+
function marketplaceRoots(targetHome, state) {
|
|
27339
|
+
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
27340
|
+
}
|
|
27341
|
+
function claudeMarketplaceUnresolvedReason(targetHome) {
|
|
27342
|
+
const registryPath = path10.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
27343
|
+
return `claude installRoute is "marketplace" but no install root could be resolved from ${registryPath} ` + "\u2014 re-run the Claude plugin installer, or verify the plugin registry file";
|
|
27344
|
+
}
|
|
26999
27345
|
function listProfiles(opts = {}) {
|
|
27000
27346
|
const { targetHome, stateFilePath } = resolveCommon(opts);
|
|
27001
27347
|
const state = readInstallState(stateFilePath);
|
|
27348
|
+
const roots = marketplaceRoots(targetHome, state);
|
|
27002
27349
|
const universe = opts.hosts ?? HOSTS;
|
|
27003
27350
|
const hosts = universe.map((host) => {
|
|
27004
|
-
|
|
27351
|
+
if (host === "claude" && state.platforms.claude?.installRoute === "marketplace" && roots.claude === undefined) {
|
|
27352
|
+
const platform2 = state.platforms.claude;
|
|
27353
|
+
return {
|
|
27354
|
+
host,
|
|
27355
|
+
installed: false,
|
|
27356
|
+
skipped: false,
|
|
27357
|
+
skipReason: null,
|
|
27358
|
+
activeProfile: platform2.modelProfile?.profile ?? opts.hostDefaults?.[host] ?? "balanced",
|
|
27359
|
+
bundleVersion: platform2.plugin?.version ?? null,
|
|
27360
|
+
availableProfiles: []
|
|
27361
|
+
};
|
|
27362
|
+
}
|
|
27363
|
+
const layout = resolveHostLayout(host, { targetHome, projectRoot: opts.projectRoot, marketplaceRoot: roots });
|
|
27005
27364
|
if (layout.route === "skip") {
|
|
27006
27365
|
return {
|
|
27007
27366
|
host,
|
|
@@ -27013,7 +27372,7 @@ function listProfiles(opts = {}) {
|
|
|
27013
27372
|
availableProfiles: []
|
|
27014
27373
|
};
|
|
27015
27374
|
}
|
|
27016
|
-
const installed =
|
|
27375
|
+
const installed = fs6.existsSync(layout.activeDir);
|
|
27017
27376
|
const availableProfiles = listVariantProfiles(layout);
|
|
27018
27377
|
const platform = state.platforms[host];
|
|
27019
27378
|
return {
|
|
@@ -27029,9 +27388,9 @@ function listProfiles(opts = {}) {
|
|
|
27029
27388
|
return { hosts };
|
|
27030
27389
|
}
|
|
27031
27390
|
function listVariantProfiles(layout) {
|
|
27032
|
-
if (!
|
|
27391
|
+
if (!fs6.existsSync(layout.variantsRoot))
|
|
27033
27392
|
return [];
|
|
27034
|
-
return
|
|
27393
|
+
return fs6.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
27035
27394
|
}
|
|
27036
27395
|
function matchesGlob(filename, glob) {
|
|
27037
27396
|
const starIdx = glob.indexOf("*");
|
|
@@ -27042,50 +27401,50 @@ function matchesGlob(filename, glob) {
|
|
|
27042
27401
|
return filename.length >= prefix.length + suffix.length && filename.startsWith(prefix) && filename.endsWith(suffix);
|
|
27043
27402
|
}
|
|
27044
27403
|
function assertStateWritable(stateFilePath) {
|
|
27045
|
-
const dir =
|
|
27404
|
+
const dir = path10.dirname(stateFilePath);
|
|
27046
27405
|
try {
|
|
27047
|
-
|
|
27406
|
+
fs6.mkdirSync(dir, { recursive: true });
|
|
27048
27407
|
} catch (err) {
|
|
27049
27408
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
27050
27409
|
}
|
|
27051
|
-
const checkPath =
|
|
27410
|
+
const checkPath = fs6.existsSync(stateFilePath) ? stateFilePath : dir;
|
|
27052
27411
|
try {
|
|
27053
|
-
|
|
27412
|
+
fs6.accessSync(checkPath, fs6.constants.W_OK);
|
|
27054
27413
|
} catch (err) {
|
|
27055
27414
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
27056
27415
|
}
|
|
27057
27416
|
}
|
|
27058
27417
|
function copyFileRouteVariant(layout, variantDir) {
|
|
27059
|
-
|
|
27418
|
+
fs6.mkdirSync(layout.activeDir, { recursive: true });
|
|
27060
27419
|
let changed = 0;
|
|
27061
|
-
for (const entry of
|
|
27420
|
+
for (const entry of fs6.readdirSync(variantDir, { withFileTypes: true })) {
|
|
27062
27421
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
27063
27422
|
continue;
|
|
27064
|
-
|
|
27423
|
+
fs6.copyFileSync(path10.join(variantDir, entry.name), path10.join(layout.activeDir, entry.name));
|
|
27065
27424
|
changed++;
|
|
27066
27425
|
}
|
|
27067
27426
|
return changed;
|
|
27068
27427
|
}
|
|
27069
27428
|
function repointOpencodeVariant(layout, variantDir) {
|
|
27070
|
-
|
|
27429
|
+
fs6.mkdirSync(layout.activeDir, { recursive: true });
|
|
27071
27430
|
let changed = 0;
|
|
27072
|
-
for (const entry of
|
|
27431
|
+
for (const entry of fs6.readdirSync(variantDir, { withFileTypes: true })) {
|
|
27073
27432
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
27074
27433
|
continue;
|
|
27075
|
-
const dest =
|
|
27076
|
-
const target =
|
|
27434
|
+
const dest = path10.join(layout.activeDir, entry.name);
|
|
27435
|
+
const target = path10.resolve(path10.join(variantDir, entry.name));
|
|
27077
27436
|
let destExists = true;
|
|
27078
27437
|
let destIsSymlink = false;
|
|
27079
27438
|
try {
|
|
27080
|
-
destIsSymlink =
|
|
27439
|
+
destIsSymlink = fs6.lstatSync(dest).isSymbolicLink();
|
|
27081
27440
|
} catch {
|
|
27082
27441
|
destExists = false;
|
|
27083
27442
|
}
|
|
27084
27443
|
if (destExists && !destIsSymlink)
|
|
27085
27444
|
continue;
|
|
27086
27445
|
const tmp = `${dest}.massa-ai-switch.${crypto4.randomUUID()}`;
|
|
27087
|
-
|
|
27088
|
-
|
|
27446
|
+
fs6.symlinkSync(target, tmp);
|
|
27447
|
+
fs6.renameSync(tmp, dest);
|
|
27089
27448
|
changed++;
|
|
27090
27449
|
}
|
|
27091
27450
|
return changed;
|
|
@@ -27101,19 +27460,37 @@ function switchProfile(opts) {
|
|
|
27101
27460
|
const state = readInstallState(stateFilePath);
|
|
27102
27461
|
if (!dryRun)
|
|
27103
27462
|
assertStateWritable(stateFilePath);
|
|
27104
|
-
const
|
|
27105
|
-
const
|
|
27463
|
+
const roots = marketplaceRoots(targetHome, state);
|
|
27464
|
+
const unresolvedRows = [];
|
|
27465
|
+
const resolvableUniverse = universe.filter((host) => {
|
|
27466
|
+
if (host !== "claude")
|
|
27467
|
+
return true;
|
|
27468
|
+
if (state.platforms.claude?.installRoute !== "marketplace")
|
|
27469
|
+
return true;
|
|
27470
|
+
if (roots.claude !== undefined)
|
|
27471
|
+
return true;
|
|
27472
|
+
unresolvedRows.push({ host, status: "failed", reason: claudeMarketplaceUnresolvedReason(targetHome) });
|
|
27473
|
+
return false;
|
|
27474
|
+
});
|
|
27475
|
+
const layouts = resolvableUniverse.map((host) => ({
|
|
27476
|
+
host,
|
|
27477
|
+
layout: resolveHostLayout(host, { targetHome, projectRoot: opts.projectRoot, marketplaceRoot: roots })
|
|
27478
|
+
}));
|
|
27479
|
+
const skipRows = [
|
|
27480
|
+
...unresolvedRows,
|
|
27481
|
+
...layouts.filter((l) => l.layout.route === "skip").map((l) => ({ host: l.host, status: "skipped", reason: l.layout.reason }))
|
|
27482
|
+
];
|
|
27106
27483
|
const fileHosts = layouts.filter((l) => l.layout.route === "files");
|
|
27107
27484
|
if (fileHosts.length === 0) {
|
|
27108
27485
|
return { profile: opts.profile, dryRun, hosts: orderRows(universe, skipRows), restartRequired: false };
|
|
27109
27486
|
}
|
|
27110
|
-
const installedFileHosts = fileHosts.filter((h) =>
|
|
27487
|
+
const installedFileHosts = fileHosts.filter((h) => fs6.existsSync(h.layout.activeDir));
|
|
27111
27488
|
if (installedFileHosts.length === 0)
|
|
27112
27489
|
throw NoHostsDetectedError();
|
|
27113
27490
|
const withAvailability = fileHosts.map((h) => {
|
|
27114
|
-
const variantsRootExists =
|
|
27491
|
+
const variantsRootExists = fs6.existsSync(h.layout.variantsRoot);
|
|
27115
27492
|
const variantDir = h.layout.variantDir(opts.profile);
|
|
27116
|
-
const available = variantsRootExists &&
|
|
27493
|
+
const available = variantsRootExists && fs6.existsSync(variantDir) && fs6.statSync(variantDir).isDirectory();
|
|
27117
27494
|
return { ...h, variantsRootExists, variantDir, available };
|
|
27118
27495
|
});
|
|
27119
27496
|
if (!withAvailability.some((h) => h.available)) {
|
|
@@ -27143,7 +27520,7 @@ function switchProfile(opts) {
|
|
|
27143
27520
|
});
|
|
27144
27521
|
continue;
|
|
27145
27522
|
}
|
|
27146
|
-
const route = detectRoute(state.platforms[h.host]);
|
|
27523
|
+
const route = detectRoute(state.platforms[h.host], h.host);
|
|
27147
27524
|
if (route.kind === "refuse") {
|
|
27148
27525
|
rows.push({ host: h.host, status: "failed", reason: route.reason });
|
|
27149
27526
|
continue;
|
|
@@ -27178,6 +27555,7 @@ var init_engine = __esm(() => {
|
|
|
27178
27555
|
init_hosts();
|
|
27179
27556
|
init_state();
|
|
27180
27557
|
init_lock();
|
|
27558
|
+
init_claude_marketplace();
|
|
27181
27559
|
SwitchEngineError = class SwitchEngineError extends Error {
|
|
27182
27560
|
constructor(message) {
|
|
27183
27561
|
super(message);
|
|
@@ -27192,18 +27570,25 @@ function reportSucceeded(report) {
|
|
|
27192
27570
|
}
|
|
27193
27571
|
|
|
27194
27572
|
// ../../packages/shared/dist/profile-switch/variant-sync.js
|
|
27195
|
-
import
|
|
27196
|
-
import
|
|
27573
|
+
import fs7 from "fs";
|
|
27574
|
+
import path11 from "path";
|
|
27575
|
+
import os7 from "os";
|
|
27197
27576
|
import crypto5 from "crypto";
|
|
27577
|
+
function defaultStatePath2(targetHome) {
|
|
27578
|
+
return path11.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
27579
|
+
}
|
|
27580
|
+
function marketplaceRoots2(targetHome, state) {
|
|
27581
|
+
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
27582
|
+
}
|
|
27198
27583
|
function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
27199
27584
|
const unique = `${process.pid}.${++tempFileCounter2}.${crypto5.randomBytes(6).toString("hex")}`;
|
|
27200
|
-
const tempFile =
|
|
27585
|
+
const tempFile = path11.join(destDir, `.${destName}.${unique}.tmp`);
|
|
27201
27586
|
try {
|
|
27202
|
-
|
|
27203
|
-
|
|
27587
|
+
fs7.writeFileSync(tempFile, content);
|
|
27588
|
+
fs7.renameSync(tempFile, path11.join(destDir, destName));
|
|
27204
27589
|
} catch (error51) {
|
|
27205
27590
|
try {
|
|
27206
|
-
|
|
27591
|
+
fs7.unlinkSync(tempFile);
|
|
27207
27592
|
} catch {}
|
|
27208
27593
|
throw error51;
|
|
27209
27594
|
}
|
|
@@ -27211,20 +27596,20 @@ function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
|
27211
27596
|
function isSafeDirName(name) {
|
|
27212
27597
|
if (name === "." || name === "..")
|
|
27213
27598
|
return false;
|
|
27214
|
-
if (name.includes("/") || name.includes("\\") || name.includes(
|
|
27599
|
+
if (name.includes("/") || name.includes("\\") || name.includes(path11.sep))
|
|
27215
27600
|
return false;
|
|
27216
|
-
return
|
|
27601
|
+
return path11.basename(name) === name;
|
|
27217
27602
|
}
|
|
27218
|
-
function syncHost(host, sourceRoot, targetHome) {
|
|
27219
|
-
const layout = resolveHostLayout(host, { targetHome });
|
|
27603
|
+
function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
27604
|
+
const layout = resolveHostLayout(host, { targetHome, marketplaceRoot });
|
|
27220
27605
|
if (layout.route === "skip") {
|
|
27221
27606
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: layout.reason };
|
|
27222
27607
|
}
|
|
27223
|
-
const srcDir =
|
|
27224
|
-
if (!
|
|
27608
|
+
const srcDir = path11.join(sourceRoot, "apps", `${host}-plugin`, "agent-profiles");
|
|
27609
|
+
if (!fs7.existsSync(srcDir) || !fs7.statSync(srcDir).isDirectory()) {
|
|
27225
27610
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: "no generated variants for this host" };
|
|
27226
27611
|
}
|
|
27227
|
-
if (!
|
|
27612
|
+
if (!fs7.existsSync(layout.variantsRoot)) {
|
|
27228
27613
|
return {
|
|
27229
27614
|
host,
|
|
27230
27615
|
status: "skipped",
|
|
@@ -27236,24 +27621,24 @@ function syncHost(host, sourceRoot, targetHome) {
|
|
|
27236
27621
|
}
|
|
27237
27622
|
const profiles = [];
|
|
27238
27623
|
let files = 0;
|
|
27239
|
-
for (const entry of
|
|
27624
|
+
for (const entry of fs7.readdirSync(srcDir, { withFileTypes: true })) {
|
|
27240
27625
|
if (!entry.isDirectory())
|
|
27241
27626
|
continue;
|
|
27242
27627
|
if (!isSafeDirName(entry.name))
|
|
27243
27628
|
continue;
|
|
27244
|
-
const srcProfileDir =
|
|
27245
|
-
const destProfileDir =
|
|
27246
|
-
|
|
27247
|
-
for (const fileEntry of
|
|
27629
|
+
const srcProfileDir = path11.join(srcDir, entry.name);
|
|
27630
|
+
const destProfileDir = path11.join(layout.variantsRoot, entry.name);
|
|
27631
|
+
fs7.mkdirSync(destProfileDir, { recursive: true });
|
|
27632
|
+
for (const fileEntry of fs7.readdirSync(srcProfileDir, { withFileTypes: true })) {
|
|
27248
27633
|
if (!fileEntry.isFile())
|
|
27249
27634
|
continue;
|
|
27250
|
-
const content =
|
|
27635
|
+
const content = fs7.readFileSync(path11.join(srcProfileDir, fileEntry.name));
|
|
27251
27636
|
writeFileIntoDirAtomically(destProfileDir, fileEntry.name, content);
|
|
27252
27637
|
files++;
|
|
27253
27638
|
}
|
|
27254
27639
|
profiles.push(entry.name);
|
|
27255
27640
|
}
|
|
27256
|
-
const retained =
|
|
27641
|
+
const retained = fs7.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory() && !profiles.includes(e.name)).map((e) => e.name).sort();
|
|
27257
27642
|
return { host, status: "synced", profiles: profiles.sort(), retained, files };
|
|
27258
27643
|
}
|
|
27259
27644
|
function syncGeneratedVariants(opts) {
|
|
@@ -27269,9 +27654,12 @@ function syncGeneratedVariants(opts) {
|
|
|
27269
27654
|
}));
|
|
27270
27655
|
}
|
|
27271
27656
|
const sourceRoot = opts.sourceRoot;
|
|
27657
|
+
const targetHome = opts.targetHome ?? os7.homedir();
|
|
27658
|
+
const state = readInstallState(defaultStatePath2(targetHome));
|
|
27659
|
+
const roots = marketplaceRoots2(targetHome, state);
|
|
27272
27660
|
return hosts.map((host) => {
|
|
27273
27661
|
try {
|
|
27274
|
-
return syncHost(host, sourceRoot, opts.targetHome);
|
|
27662
|
+
return syncHost(host, sourceRoot, opts.targetHome, roots);
|
|
27275
27663
|
} catch (err) {
|
|
27276
27664
|
return { host, status: "failed", profiles: [], retained: [], files: 0, error: err.message };
|
|
27277
27665
|
}
|
|
@@ -27280,17 +27668,19 @@ function syncGeneratedVariants(opts) {
|
|
|
27280
27668
|
var tempFileCounter2 = 0;
|
|
27281
27669
|
var init_variant_sync = __esm(() => {
|
|
27282
27670
|
init_hosts();
|
|
27671
|
+
init_state();
|
|
27672
|
+
init_claude_marketplace();
|
|
27283
27673
|
});
|
|
27284
27674
|
|
|
27285
27675
|
// ../../packages/shared/dist/profile-switch/repo-root.js
|
|
27286
|
-
import
|
|
27287
|
-
import
|
|
27676
|
+
import fs8 from "fs";
|
|
27677
|
+
import path12 from "path";
|
|
27288
27678
|
function findRepoRootWithMarker(startDir, marker, maxLevels) {
|
|
27289
27679
|
let dir = startDir;
|
|
27290
27680
|
for (let i = 0;i <= maxLevels; i++) {
|
|
27291
|
-
if (
|
|
27681
|
+
if (fs8.existsSync(path12.join(dir, marker)))
|
|
27292
27682
|
return dir;
|
|
27293
|
-
const parent =
|
|
27683
|
+
const parent = path12.dirname(dir);
|
|
27294
27684
|
if (parent === dir)
|
|
27295
27685
|
break;
|
|
27296
27686
|
dir = parent;
|
|
@@ -28830,7 +29220,7 @@ var import_brace_expansion, minimatch = (p, pattern, options = {}) => {
|
|
|
28830
29220
|
}, qmarksTestNoExtDot = ([$0]) => {
|
|
28831
29221
|
const len = $0.length;
|
|
28832
29222
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
28833
|
-
}, defaultPlatform,
|
|
29223
|
+
}, defaultPlatform, path13, sep, GLOBSTAR, qmark2 = "[^/]", star2, twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?", filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options), ext = (a, b = {}) => Object.assign({}, a, b), defaults = (def) => {
|
|
28834
29224
|
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
28835
29225
|
return minimatch;
|
|
28836
29226
|
}
|
|
@@ -28888,11 +29278,11 @@ var init_esm = __esm(() => {
|
|
|
28888
29278
|
starRE = /^\*+$/;
|
|
28889
29279
|
qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
28890
29280
|
defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
28891
|
-
|
|
29281
|
+
path13 = {
|
|
28892
29282
|
win32: { sep: "\\" },
|
|
28893
29283
|
posix: { sep: "/" }
|
|
28894
29284
|
};
|
|
28895
|
-
sep = defaultPlatform === "win32" ?
|
|
29285
|
+
sep = defaultPlatform === "win32" ? path13.win32.sep : path13.posix.sep;
|
|
28896
29286
|
minimatch.sep = sep;
|
|
28897
29287
|
GLOBSTAR = Symbol("globstar **");
|
|
28898
29288
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -30858,12 +31248,12 @@ var init_esm4 = __esm(() => {
|
|
|
30858
31248
|
childrenCache() {
|
|
30859
31249
|
return this.#children;
|
|
30860
31250
|
}
|
|
30861
|
-
resolve(
|
|
30862
|
-
if (!
|
|
31251
|
+
resolve(path14) {
|
|
31252
|
+
if (!path14) {
|
|
30863
31253
|
return this;
|
|
30864
31254
|
}
|
|
30865
|
-
const rootPath = this.getRootString(
|
|
30866
|
-
const dir =
|
|
31255
|
+
const rootPath = this.getRootString(path14);
|
|
31256
|
+
const dir = path14.substring(rootPath.length);
|
|
30867
31257
|
const dirParts = dir.split(this.splitSep);
|
|
30868
31258
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
30869
31259
|
return result;
|
|
@@ -31391,8 +31781,8 @@ var init_esm4 = __esm(() => {
|
|
|
31391
31781
|
newChild(name, type = UNKNOWN, opts = {}) {
|
|
31392
31782
|
return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
|
31393
31783
|
}
|
|
31394
|
-
getRootString(
|
|
31395
|
-
return win32.parse(
|
|
31784
|
+
getRootString(path14) {
|
|
31785
|
+
return win32.parse(path14).root;
|
|
31396
31786
|
}
|
|
31397
31787
|
getRoot(rootPath) {
|
|
31398
31788
|
rootPath = uncToDrive(rootPath.toUpperCase());
|
|
@@ -31417,8 +31807,8 @@ var init_esm4 = __esm(() => {
|
|
|
31417
31807
|
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
|
31418
31808
|
super(name, type, root, roots, nocase, children, opts);
|
|
31419
31809
|
}
|
|
31420
|
-
getRootString(
|
|
31421
|
-
return
|
|
31810
|
+
getRootString(path14) {
|
|
31811
|
+
return path14.startsWith("/") ? "/" : "";
|
|
31422
31812
|
}
|
|
31423
31813
|
getRoot(_rootPath) {
|
|
31424
31814
|
return this.root;
|
|
@@ -31437,8 +31827,8 @@ var init_esm4 = __esm(() => {
|
|
|
31437
31827
|
#children;
|
|
31438
31828
|
nocase;
|
|
31439
31829
|
#fs;
|
|
31440
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
31441
|
-
this.#fs = fsFromOption(
|
|
31830
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs9 = defaultFS } = {}) {
|
|
31831
|
+
this.#fs = fsFromOption(fs9);
|
|
31442
31832
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
31443
31833
|
cwd = fileURLToPath(cwd);
|
|
31444
31834
|
}
|
|
@@ -31474,11 +31864,11 @@ var init_esm4 = __esm(() => {
|
|
|
31474
31864
|
}
|
|
31475
31865
|
this.cwd = prev;
|
|
31476
31866
|
}
|
|
31477
|
-
depth(
|
|
31478
|
-
if (typeof
|
|
31479
|
-
|
|
31867
|
+
depth(path14 = this.cwd) {
|
|
31868
|
+
if (typeof path14 === "string") {
|
|
31869
|
+
path14 = this.cwd.resolve(path14);
|
|
31480
31870
|
}
|
|
31481
|
-
return
|
|
31871
|
+
return path14.depth();
|
|
31482
31872
|
}
|
|
31483
31873
|
childrenCache() {
|
|
31484
31874
|
return this.#children;
|
|
@@ -31894,9 +32284,9 @@ var init_esm4 = __esm(() => {
|
|
|
31894
32284
|
process4();
|
|
31895
32285
|
return results;
|
|
31896
32286
|
}
|
|
31897
|
-
chdir(
|
|
32287
|
+
chdir(path14 = this.cwd) {
|
|
31898
32288
|
const oldCwd = this.cwd;
|
|
31899
|
-
this.cwd = typeof
|
|
32289
|
+
this.cwd = typeof path14 === "string" ? this.cwd.resolve(path14) : path14;
|
|
31900
32290
|
this.cwd[setAsCwd](oldCwd);
|
|
31901
32291
|
}
|
|
31902
32292
|
};
|
|
@@ -31913,8 +32303,8 @@ var init_esm4 = __esm(() => {
|
|
|
31913
32303
|
parseRootPath(dir) {
|
|
31914
32304
|
return win32.parse(dir).root.toUpperCase();
|
|
31915
32305
|
}
|
|
31916
|
-
newRoot(
|
|
31917
|
-
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
32306
|
+
newRoot(fs9) {
|
|
32307
|
+
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
|
|
31918
32308
|
}
|
|
31919
32309
|
isAbsolute(p) {
|
|
31920
32310
|
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
@@ -31930,8 +32320,8 @@ var init_esm4 = __esm(() => {
|
|
|
31930
32320
|
parseRootPath(_dir) {
|
|
31931
32321
|
return "/";
|
|
31932
32322
|
}
|
|
31933
|
-
newRoot(
|
|
31934
|
-
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
32323
|
+
newRoot(fs9) {
|
|
32324
|
+
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
|
|
31935
32325
|
}
|
|
31936
32326
|
isAbsolute(p) {
|
|
31937
32327
|
return p.startsWith("/");
|
|
@@ -32188,8 +32578,8 @@ class MatchRecord {
|
|
|
32188
32578
|
this.store.set(target, current === undefined ? n : n & current);
|
|
32189
32579
|
}
|
|
32190
32580
|
entries() {
|
|
32191
|
-
return [...this.store.entries()].map(([
|
|
32192
|
-
|
|
32581
|
+
return [...this.store.entries()].map(([path14, n]) => [
|
|
32582
|
+
path14,
|
|
32193
32583
|
!!(n & 2),
|
|
32194
32584
|
!!(n & 1)
|
|
32195
32585
|
]);
|
|
@@ -32393,9 +32783,9 @@ class GlobUtil {
|
|
|
32393
32783
|
signal;
|
|
32394
32784
|
maxDepth;
|
|
32395
32785
|
includeChildMatches;
|
|
32396
|
-
constructor(patterns,
|
|
32786
|
+
constructor(patterns, path14, opts) {
|
|
32397
32787
|
this.patterns = patterns;
|
|
32398
|
-
this.path =
|
|
32788
|
+
this.path = path14;
|
|
32399
32789
|
this.opts = opts;
|
|
32400
32790
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
32401
32791
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -32414,11 +32804,11 @@ class GlobUtil {
|
|
|
32414
32804
|
});
|
|
32415
32805
|
}
|
|
32416
32806
|
}
|
|
32417
|
-
#ignored(
|
|
32418
|
-
return this.seen.has(
|
|
32807
|
+
#ignored(path14) {
|
|
32808
|
+
return this.seen.has(path14) || !!this.#ignore?.ignored?.(path14);
|
|
32419
32809
|
}
|
|
32420
|
-
#childrenIgnored(
|
|
32421
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
32810
|
+
#childrenIgnored(path14) {
|
|
32811
|
+
return !!this.#ignore?.childrenIgnored?.(path14);
|
|
32422
32812
|
}
|
|
32423
32813
|
pause() {
|
|
32424
32814
|
this.paused = true;
|
|
@@ -32635,8 +33025,8 @@ var init_walker = __esm(() => {
|
|
|
32635
33025
|
init_processor();
|
|
32636
33026
|
GlobWalker = class GlobWalker extends GlobUtil {
|
|
32637
33027
|
matches = new Set;
|
|
32638
|
-
constructor(patterns,
|
|
32639
|
-
super(patterns,
|
|
33028
|
+
constructor(patterns, path14, opts) {
|
|
33029
|
+
super(patterns, path14, opts);
|
|
32640
33030
|
}
|
|
32641
33031
|
matchEmit(e) {
|
|
32642
33032
|
this.matches.add(e);
|
|
@@ -32673,8 +33063,8 @@ var init_walker = __esm(() => {
|
|
|
32673
33063
|
};
|
|
32674
33064
|
GlobStream = class GlobStream extends GlobUtil {
|
|
32675
33065
|
results;
|
|
32676
|
-
constructor(patterns,
|
|
32677
|
-
super(patterns,
|
|
33066
|
+
constructor(patterns, path14, opts) {
|
|
33067
|
+
super(patterns, path14, opts);
|
|
32678
33068
|
this.results = new Minipass({
|
|
32679
33069
|
signal: this.signal,
|
|
32680
33070
|
objectMode: true
|
|
@@ -33102,20 +33492,20 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
33102
33492
|
var throwError = (message, Ctor) => {
|
|
33103
33493
|
throw new Ctor(message);
|
|
33104
33494
|
};
|
|
33105
|
-
var checkPath = (
|
|
33106
|
-
if (!isString(
|
|
33495
|
+
var checkPath = (path14, originalPath, doThrow) => {
|
|
33496
|
+
if (!isString(path14)) {
|
|
33107
33497
|
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
33108
33498
|
}
|
|
33109
|
-
if (!
|
|
33499
|
+
if (!path14) {
|
|
33110
33500
|
return doThrow(`path must not be empty`, TypeError);
|
|
33111
33501
|
}
|
|
33112
|
-
if (checkPath.isNotRelative(
|
|
33502
|
+
if (checkPath.isNotRelative(path14)) {
|
|
33113
33503
|
const r = "`path.relative()`d";
|
|
33114
33504
|
return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
|
33115
33505
|
}
|
|
33116
33506
|
return true;
|
|
33117
33507
|
};
|
|
33118
|
-
var isNotRelative = (
|
|
33508
|
+
var isNotRelative = (path14) => REGEX_TEST_INVALID_PATH.test(path14);
|
|
33119
33509
|
checkPath.isNotRelative = isNotRelative;
|
|
33120
33510
|
checkPath.convert = (p) => p;
|
|
33121
33511
|
|
|
@@ -33158,7 +33548,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
33158
33548
|
addPattern(pattern) {
|
|
33159
33549
|
return this.add(pattern);
|
|
33160
33550
|
}
|
|
33161
|
-
_testOne(
|
|
33551
|
+
_testOne(path14, checkUnignored) {
|
|
33162
33552
|
let ignored = false;
|
|
33163
33553
|
let unignored = false;
|
|
33164
33554
|
this._rules.forEach((rule) => {
|
|
@@ -33166,7 +33556,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
33166
33556
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
33167
33557
|
return;
|
|
33168
33558
|
}
|
|
33169
|
-
const matched = rule.regex.test(
|
|
33559
|
+
const matched = rule.regex.test(path14);
|
|
33170
33560
|
if (matched) {
|
|
33171
33561
|
ignored = !negative;
|
|
33172
33562
|
unignored = negative;
|
|
@@ -33178,39 +33568,39 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
33178
33568
|
};
|
|
33179
33569
|
}
|
|
33180
33570
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
33181
|
-
const
|
|
33182
|
-
checkPath(
|
|
33183
|
-
return this._t(
|
|
33571
|
+
const path14 = originalPath && checkPath.convert(originalPath);
|
|
33572
|
+
checkPath(path14, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
33573
|
+
return this._t(path14, cache, checkUnignored, slices);
|
|
33184
33574
|
}
|
|
33185
|
-
_t(
|
|
33186
|
-
if (
|
|
33187
|
-
return cache[
|
|
33575
|
+
_t(path14, cache, checkUnignored, slices) {
|
|
33576
|
+
if (path14 in cache) {
|
|
33577
|
+
return cache[path14];
|
|
33188
33578
|
}
|
|
33189
33579
|
if (!slices) {
|
|
33190
|
-
slices =
|
|
33580
|
+
slices = path14.split(SLASH);
|
|
33191
33581
|
}
|
|
33192
33582
|
slices.pop();
|
|
33193
33583
|
if (!slices.length) {
|
|
33194
|
-
return cache[
|
|
33584
|
+
return cache[path14] = this._testOne(path14, checkUnignored);
|
|
33195
33585
|
}
|
|
33196
33586
|
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
33197
|
-
return cache[
|
|
33587
|
+
return cache[path14] = parent.ignored ? parent : this._testOne(path14, checkUnignored);
|
|
33198
33588
|
}
|
|
33199
|
-
ignores(
|
|
33200
|
-
return this._test(
|
|
33589
|
+
ignores(path14) {
|
|
33590
|
+
return this._test(path14, this._ignoreCache, false).ignored;
|
|
33201
33591
|
}
|
|
33202
33592
|
createFilter() {
|
|
33203
|
-
return (
|
|
33593
|
+
return (path14) => !this.ignores(path14);
|
|
33204
33594
|
}
|
|
33205
33595
|
filter(paths) {
|
|
33206
33596
|
return makeArray(paths).filter(this.createFilter());
|
|
33207
33597
|
}
|
|
33208
|
-
test(
|
|
33209
|
-
return this._test(
|
|
33598
|
+
test(path14) {
|
|
33599
|
+
return this._test(path14, this._testCache, true);
|
|
33210
33600
|
}
|
|
33211
33601
|
}
|
|
33212
33602
|
var factory = (options) => new Ignore2(options);
|
|
33213
|
-
var isPathValid = (
|
|
33603
|
+
var isPathValid = (path14) => checkPath(path14 && checkPath.convert(path14), path14, RETURN_FALSE);
|
|
33214
33604
|
factory.isPathValid = isPathValid;
|
|
33215
33605
|
factory.default = factory;
|
|
33216
33606
|
module.exports = factory;
|
|
@@ -33218,7 +33608,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
33218
33608
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
33219
33609
|
checkPath.convert = makePosix;
|
|
33220
33610
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
33221
|
-
checkPath.isNotRelative = (
|
|
33611
|
+
checkPath.isNotRelative = (path14) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path14) || isNotRelative(path14);
|
|
33222
33612
|
}
|
|
33223
33613
|
});
|
|
33224
33614
|
|
|
@@ -33280,13 +33670,13 @@ function validatePolicy(policy, opts = {}) {
|
|
|
33280
33670
|
}
|
|
33281
33671
|
}
|
|
33282
33672
|
}
|
|
33283
|
-
function matchesGlob2(
|
|
33673
|
+
function matchesGlob2(path14, pattern) {
|
|
33284
33674
|
let re = regexCache.get(pattern);
|
|
33285
33675
|
if (!re) {
|
|
33286
33676
|
re = globToRegex(pattern);
|
|
33287
33677
|
regexCache.set(pattern, re);
|
|
33288
33678
|
}
|
|
33289
|
-
return re.test(
|
|
33679
|
+
return re.test(path14);
|
|
33290
33680
|
}
|
|
33291
33681
|
var MAX_MATCH_WORK = 1e5, MAX_IGNORE_PATTERNS2 = 1024, DEFAULT_POLICY, applyPolicy = (filePath, policy) => {
|
|
33292
33682
|
const normalized = filePath.trim();
|
|
@@ -33337,8 +33727,8 @@ var init_capture_policy = __esm(() => {
|
|
|
33337
33727
|
});
|
|
33338
33728
|
|
|
33339
33729
|
// ../../packages/core/dist/services/search/ignore-patterns.js
|
|
33340
|
-
import
|
|
33341
|
-
import
|
|
33730
|
+
import fs9 from "fs/promises";
|
|
33731
|
+
import path14 from "path";
|
|
33342
33732
|
function buildExtensionGlob(extensions) {
|
|
33343
33733
|
return extensions.map((ext2) => `**/*${ext2}`);
|
|
33344
33734
|
}
|
|
@@ -33361,8 +33751,8 @@ async function loadProjectIgnore(projectPath) {
|
|
|
33361
33751
|
const ig = ignore();
|
|
33362
33752
|
ig.add(DEFAULT_IGNORES);
|
|
33363
33753
|
try {
|
|
33364
|
-
const gitignorePath =
|
|
33365
|
-
const gitignoreContent = await
|
|
33754
|
+
const gitignorePath = path14.join(projectPath, ".gitignore");
|
|
33755
|
+
const gitignoreContent = await fs9.readFile(gitignorePath, "utf8");
|
|
33366
33756
|
const rules = gitignoreContent.split(`
|
|
33367
33757
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
33368
33758
|
ig.add(rules);
|
|
@@ -34958,15 +35348,15 @@ var require_pg_connection_string = __commonJS((exports, module) => {
|
|
|
34958
35348
|
if (config3.sslnegotiation === "direct" && config3.ssl === undefined) {
|
|
34959
35349
|
config3.ssl = true;
|
|
34960
35350
|
}
|
|
34961
|
-
const
|
|
35351
|
+
const fs10 = config3.sslcert || config3.sslkey || config3.sslrootcert ? __require("fs") : null;
|
|
34962
35352
|
if (config3.sslcert) {
|
|
34963
|
-
config3.ssl.cert =
|
|
35353
|
+
config3.ssl.cert = fs10.readFileSync(config3.sslcert).toString();
|
|
34964
35354
|
}
|
|
34965
35355
|
if (config3.sslkey) {
|
|
34966
|
-
config3.ssl.key =
|
|
35356
|
+
config3.ssl.key = fs10.readFileSync(config3.sslkey).toString();
|
|
34967
35357
|
}
|
|
34968
35358
|
if (config3.sslrootcert) {
|
|
34969
|
-
config3.ssl.ca =
|
|
35359
|
+
config3.ssl.ca = fs10.readFileSync(config3.sslrootcert).toString();
|
|
34970
35360
|
}
|
|
34971
35361
|
if (options.useLibpqCompat && config3.uselibpqcompat) {
|
|
34972
35362
|
throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");
|
|
@@ -36680,7 +37070,7 @@ var require_split2 = __commonJS((exports, module) => {
|
|
|
36680
37070
|
|
|
36681
37071
|
// ../../node_modules/pgpass/lib/helper.js
|
|
36682
37072
|
var require_helper = __commonJS((exports, module) => {
|
|
36683
|
-
var
|
|
37073
|
+
var path15 = __require("path");
|
|
36684
37074
|
var Stream2 = __require("stream").Stream;
|
|
36685
37075
|
var split = require_split2();
|
|
36686
37076
|
var util3 = __require("util");
|
|
@@ -36720,7 +37110,7 @@ var require_helper = __commonJS((exports, module) => {
|
|
|
36720
37110
|
};
|
|
36721
37111
|
exports.getFileName = function(rawEnv) {
|
|
36722
37112
|
var env = rawEnv || process.env;
|
|
36723
|
-
var file2 = env.PGPASSFILE || (isWin ?
|
|
37113
|
+
var file2 = env.PGPASSFILE || (isWin ? path15.join(env.APPDATA || "./", "postgresql", "pgpass.conf") : path15.join(env.HOME || "./", ".pgpass"));
|
|
36724
37114
|
return file2;
|
|
36725
37115
|
};
|
|
36726
37116
|
exports.usePgPass = function(stats, fname) {
|
|
@@ -36844,16 +37234,16 @@ var require_helper = __commonJS((exports, module) => {
|
|
|
36844
37234
|
|
|
36845
37235
|
// ../../node_modules/pgpass/lib/index.js
|
|
36846
37236
|
var require_lib = __commonJS((exports, module) => {
|
|
36847
|
-
var
|
|
36848
|
-
var
|
|
37237
|
+
var path15 = __require("path");
|
|
37238
|
+
var fs10 = __require("fs");
|
|
36849
37239
|
var helper = require_helper();
|
|
36850
37240
|
module.exports = function(connInfo, cb) {
|
|
36851
37241
|
var file2 = helper.getFileName();
|
|
36852
|
-
|
|
37242
|
+
fs10.stat(file2, function(err, stat) {
|
|
36853
37243
|
if (err || !helper.usePgPass(stat, file2)) {
|
|
36854
37244
|
return cb(undefined);
|
|
36855
37245
|
}
|
|
36856
|
-
var st =
|
|
37246
|
+
var st = fs10.createReadStream(file2);
|
|
36857
37247
|
helper.getPassword(connInfo, st, cb);
|
|
36858
37248
|
});
|
|
36859
37249
|
};
|
|
@@ -38552,8 +38942,8 @@ var init_alias_resolver = __esm(() => {
|
|
|
38552
38942
|
});
|
|
38553
38943
|
|
|
38554
38944
|
// ../../packages/core/dist/services/search/index-manager.js
|
|
38555
|
-
import
|
|
38556
|
-
import
|
|
38945
|
+
import fs10 from "fs";
|
|
38946
|
+
import path15 from "path";
|
|
38557
38947
|
|
|
38558
38948
|
class IndexManager {
|
|
38559
38949
|
metadataCache = new Map;
|
|
@@ -38646,9 +39036,9 @@ class IndexManager {
|
|
|
38646
39036
|
const fileMetadata = {};
|
|
38647
39037
|
let totalSize = 0;
|
|
38648
39038
|
for (const filePath of indexedFiles) {
|
|
38649
|
-
const fullPath =
|
|
39039
|
+
const fullPath = path15.join(projectPath, filePath);
|
|
38650
39040
|
try {
|
|
38651
|
-
const stat = await
|
|
39041
|
+
const stat = await fs10.promises.stat(fullPath);
|
|
38652
39042
|
fileMetadata[filePath] = {
|
|
38653
39043
|
path: filePath,
|
|
38654
39044
|
mtime: stat.mtimeMs,
|
|
@@ -38699,9 +39089,9 @@ class IndexManager {
|
|
|
38699
39089
|
if (ig.ignores(match2)) {
|
|
38700
39090
|
continue;
|
|
38701
39091
|
}
|
|
38702
|
-
const fullPath =
|
|
39092
|
+
const fullPath = path15.join(projectPath, match2);
|
|
38703
39093
|
try {
|
|
38704
|
-
const stat = await
|
|
39094
|
+
const stat = await fs10.promises.stat(fullPath);
|
|
38705
39095
|
files.set(match2, {
|
|
38706
39096
|
path: match2,
|
|
38707
39097
|
mtime: stat.mtimeMs,
|
|
@@ -41886,19 +42276,19 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
41886
42276
|
getUserDataDir: () => getUserDataDir
|
|
41887
42277
|
});
|
|
41888
42278
|
module.exports = __toCommonJS2(token_io_exports);
|
|
41889
|
-
var
|
|
41890
|
-
var
|
|
42279
|
+
var import_path9 = __toESM2(__require("path"));
|
|
42280
|
+
var import_fs6 = __toESM2(__require("fs"));
|
|
41891
42281
|
var import_os3 = __toESM2(__require("os"));
|
|
41892
42282
|
var import_token_error = require_token_error();
|
|
41893
42283
|
function findRootDir() {
|
|
41894
42284
|
try {
|
|
41895
42285
|
let dir = process.cwd();
|
|
41896
|
-
while (dir !==
|
|
41897
|
-
const pkgPath =
|
|
41898
|
-
if (
|
|
42286
|
+
while (dir !== import_path9.default.dirname(dir)) {
|
|
42287
|
+
const pkgPath = import_path9.default.join(dir, ".vercel");
|
|
42288
|
+
if (import_fs6.default.existsSync(pkgPath)) {
|
|
41899
42289
|
return dir;
|
|
41900
42290
|
}
|
|
41901
|
-
dir =
|
|
42291
|
+
dir = import_path9.default.dirname(dir);
|
|
41902
42292
|
}
|
|
41903
42293
|
} catch (e) {
|
|
41904
42294
|
throw new import_token_error.VercelOidcTokenError("Token refresh only supported in node server environments");
|
|
@@ -41911,9 +42301,9 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
41911
42301
|
}
|
|
41912
42302
|
switch (import_os3.default.platform()) {
|
|
41913
42303
|
case "darwin":
|
|
41914
|
-
return
|
|
42304
|
+
return import_path9.default.join(import_os3.default.homedir(), "Library/Application Support");
|
|
41915
42305
|
case "linux":
|
|
41916
|
-
return
|
|
42306
|
+
return import_path9.default.join(import_os3.default.homedir(), ".local/share");
|
|
41917
42307
|
case "win32":
|
|
41918
42308
|
if (process.env.LOCALAPPDATA) {
|
|
41919
42309
|
return process.env.LOCALAPPDATA;
|
|
@@ -41954,23 +42344,23 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
41954
42344
|
writeAuthConfig: () => writeAuthConfig
|
|
41955
42345
|
});
|
|
41956
42346
|
module.exports = __toCommonJS2(auth_config_exports);
|
|
41957
|
-
var
|
|
41958
|
-
var
|
|
42347
|
+
var fs11 = __toESM2(__require("fs"));
|
|
42348
|
+
var path16 = __toESM2(__require("path"));
|
|
41959
42349
|
var import_token_util = require_token_util();
|
|
41960
42350
|
function getAuthConfigPath() {
|
|
41961
42351
|
const dataDir = (0, import_token_util.getVercelDataDir)();
|
|
41962
42352
|
if (!dataDir) {
|
|
41963
42353
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
41964
42354
|
}
|
|
41965
|
-
return
|
|
42355
|
+
return path16.join(dataDir, "auth.json");
|
|
41966
42356
|
}
|
|
41967
42357
|
function readAuthConfig() {
|
|
41968
42358
|
try {
|
|
41969
42359
|
const authPath = getAuthConfigPath();
|
|
41970
|
-
if (!
|
|
42360
|
+
if (!fs11.existsSync(authPath)) {
|
|
41971
42361
|
return null;
|
|
41972
42362
|
}
|
|
41973
|
-
const content =
|
|
42363
|
+
const content = fs11.readFileSync(authPath, "utf8");
|
|
41974
42364
|
if (!content) {
|
|
41975
42365
|
return null;
|
|
41976
42366
|
}
|
|
@@ -41981,11 +42371,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
41981
42371
|
}
|
|
41982
42372
|
function writeAuthConfig(config3) {
|
|
41983
42373
|
const authPath = getAuthConfigPath();
|
|
41984
|
-
const authDir =
|
|
41985
|
-
if (!
|
|
41986
|
-
|
|
42374
|
+
const authDir = path16.dirname(authPath);
|
|
42375
|
+
if (!fs11.existsSync(authDir)) {
|
|
42376
|
+
fs11.mkdirSync(authDir, { mode: 504, recursive: true });
|
|
41987
42377
|
}
|
|
41988
|
-
|
|
42378
|
+
fs11.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
|
|
41989
42379
|
}
|
|
41990
42380
|
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
41991
42381
|
if (!authConfig.token)
|
|
@@ -42160,8 +42550,8 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
42160
42550
|
saveToken: () => saveToken
|
|
42161
42551
|
});
|
|
42162
42552
|
module.exports = __toCommonJS2(token_util_exports);
|
|
42163
|
-
var
|
|
42164
|
-
var
|
|
42553
|
+
var path16 = __toESM2(__require("path"));
|
|
42554
|
+
var fs11 = __toESM2(__require("fs"));
|
|
42165
42555
|
var import_token_error = require_token_error();
|
|
42166
42556
|
var import_token_io = require_token_io();
|
|
42167
42557
|
var import_auth_config = require_auth_config();
|
|
@@ -42173,7 +42563,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
42173
42563
|
if (!dataDir) {
|
|
42174
42564
|
return null;
|
|
42175
42565
|
}
|
|
42176
|
-
return
|
|
42566
|
+
return path16.join(dataDir, vercelFolder);
|
|
42177
42567
|
}
|
|
42178
42568
|
async function getVercelToken2(options) {
|
|
42179
42569
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -42241,11 +42631,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
42241
42631
|
if (!dir) {
|
|
42242
42632
|
throw new import_token_error.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");
|
|
42243
42633
|
}
|
|
42244
|
-
const prjPath =
|
|
42245
|
-
if (!
|
|
42634
|
+
const prjPath = path16.join(dir, ".vercel", "project.json");
|
|
42635
|
+
if (!fs11.existsSync(prjPath)) {
|
|
42246
42636
|
throw new import_token_error.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");
|
|
42247
42637
|
}
|
|
42248
|
-
const prj = JSON.parse(
|
|
42638
|
+
const prj = JSON.parse(fs11.readFileSync(prjPath, "utf8"));
|
|
42249
42639
|
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
|
|
42250
42640
|
throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");
|
|
42251
42641
|
}
|
|
@@ -42256,11 +42646,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
42256
42646
|
if (!dir) {
|
|
42257
42647
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
42258
42648
|
}
|
|
42259
|
-
const tokenPath =
|
|
42649
|
+
const tokenPath = path16.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
42260
42650
|
const tokenJson = JSON.stringify(token);
|
|
42261
|
-
|
|
42262
|
-
|
|
42263
|
-
|
|
42651
|
+
fs11.mkdirSync(path16.dirname(tokenPath), { mode: 504, recursive: true });
|
|
42652
|
+
fs11.writeFileSync(tokenPath, tokenJson);
|
|
42653
|
+
fs11.chmodSync(tokenPath, 432);
|
|
42264
42654
|
return;
|
|
42265
42655
|
}
|
|
42266
42656
|
function loadToken(projectId) {
|
|
@@ -42268,11 +42658,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
42268
42658
|
if (!dir) {
|
|
42269
42659
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
42270
42660
|
}
|
|
42271
|
-
const tokenPath =
|
|
42272
|
-
if (!
|
|
42661
|
+
const tokenPath = path16.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
42662
|
+
if (!fs11.existsSync(tokenPath)) {
|
|
42273
42663
|
return null;
|
|
42274
42664
|
}
|
|
42275
|
-
const token = JSON.parse(
|
|
42665
|
+
const token = JSON.parse(fs11.readFileSync(tokenPath, "utf8"));
|
|
42276
42666
|
assertVercelOidcTokenResponse(token);
|
|
42277
42667
|
return token;
|
|
42278
42668
|
}
|
|
@@ -53114,37 +53504,37 @@ function createOpenAI(options = {}) {
|
|
|
53114
53504
|
}, `ai-sdk/openai/${VERSION4}`);
|
|
53115
53505
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
53116
53506
|
provider: `${providerName}.chat`,
|
|
53117
|
-
url: ({ path:
|
|
53507
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
53118
53508
|
headers: getHeaders,
|
|
53119
53509
|
fetch: options.fetch
|
|
53120
53510
|
});
|
|
53121
53511
|
const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
|
|
53122
53512
|
provider: `${providerName}.completion`,
|
|
53123
|
-
url: ({ path:
|
|
53513
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
53124
53514
|
headers: getHeaders,
|
|
53125
53515
|
fetch: options.fetch
|
|
53126
53516
|
});
|
|
53127
53517
|
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
53128
53518
|
provider: `${providerName}.embedding`,
|
|
53129
|
-
url: ({ path:
|
|
53519
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
53130
53520
|
headers: getHeaders,
|
|
53131
53521
|
fetch: options.fetch
|
|
53132
53522
|
});
|
|
53133
53523
|
const createImageModel = (modelId) => new OpenAIImageModel(modelId, {
|
|
53134
53524
|
provider: `${providerName}.image`,
|
|
53135
|
-
url: ({ path:
|
|
53525
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
53136
53526
|
headers: getHeaders,
|
|
53137
53527
|
fetch: options.fetch
|
|
53138
53528
|
});
|
|
53139
53529
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
53140
53530
|
provider: `${providerName}.transcription`,
|
|
53141
|
-
url: ({ path:
|
|
53531
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
53142
53532
|
headers: getHeaders,
|
|
53143
53533
|
fetch: options.fetch
|
|
53144
53534
|
});
|
|
53145
53535
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
53146
53536
|
provider: `${providerName}.speech`,
|
|
53147
|
-
url: ({ path:
|
|
53537
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
53148
53538
|
headers: getHeaders,
|
|
53149
53539
|
fetch: options.fetch
|
|
53150
53540
|
});
|
|
@@ -53157,7 +53547,7 @@ function createOpenAI(options = {}) {
|
|
|
53157
53547
|
const createResponsesModel = (modelId) => {
|
|
53158
53548
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
53159
53549
|
provider: `${providerName}.responses`,
|
|
53160
|
-
url: ({ path:
|
|
53550
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
53161
53551
|
headers: getHeaders,
|
|
53162
53552
|
fetch: options.fetch,
|
|
53163
53553
|
fileIdPrefixes: ["file-"]
|
|
@@ -69702,26 +70092,26 @@ var require_process = __commonJS((exports, module) => {
|
|
|
69702
70092
|
|
|
69703
70093
|
// ../../node_modules/detect-libc/lib/filesystem.js
|
|
69704
70094
|
var require_filesystem = __commonJS((exports, module) => {
|
|
69705
|
-
var
|
|
70095
|
+
var fs11 = __require("fs");
|
|
69706
70096
|
var LDD_PATH = "/usr/bin/ldd";
|
|
69707
70097
|
var SELF_PATH = "/proc/self/exe";
|
|
69708
70098
|
var MAX_LENGTH = 2048;
|
|
69709
|
-
var readFileSync2 = (
|
|
69710
|
-
const fd =
|
|
70099
|
+
var readFileSync2 = (path16) => {
|
|
70100
|
+
const fd = fs11.openSync(path16, "r");
|
|
69711
70101
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
69712
|
-
const bytesRead =
|
|
69713
|
-
|
|
70102
|
+
const bytesRead = fs11.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
70103
|
+
fs11.close(fd, () => {});
|
|
69714
70104
|
return buffer.subarray(0, bytesRead);
|
|
69715
70105
|
};
|
|
69716
|
-
var readFile = (
|
|
69717
|
-
|
|
70106
|
+
var readFile = (path16) => new Promise((resolve4, reject) => {
|
|
70107
|
+
fs11.open(path16, "r", (err, fd) => {
|
|
69718
70108
|
if (err) {
|
|
69719
70109
|
reject(err);
|
|
69720
70110
|
} else {
|
|
69721
70111
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
69722
|
-
|
|
70112
|
+
fs11.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
69723
70113
|
resolve4(buffer.subarray(0, bytesRead));
|
|
69724
|
-
|
|
70114
|
+
fs11.close(fd, () => {});
|
|
69725
70115
|
});
|
|
69726
70116
|
}
|
|
69727
70117
|
});
|
|
@@ -69826,11 +70216,11 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
69826
70216
|
}
|
|
69827
70217
|
return null;
|
|
69828
70218
|
};
|
|
69829
|
-
var familyFromInterpreterPath = (
|
|
69830
|
-
if (
|
|
69831
|
-
if (
|
|
70219
|
+
var familyFromInterpreterPath = (path16) => {
|
|
70220
|
+
if (path16) {
|
|
70221
|
+
if (path16.includes("/ld-musl-")) {
|
|
69832
70222
|
return MUSL;
|
|
69833
|
-
} else if (
|
|
70223
|
+
} else if (path16.includes("/ld-linux-")) {
|
|
69834
70224
|
return GLIBC;
|
|
69835
70225
|
}
|
|
69836
70226
|
}
|
|
@@ -69875,8 +70265,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
69875
70265
|
cachedFamilyInterpreter = null;
|
|
69876
70266
|
try {
|
|
69877
70267
|
const selfContent = await readFile(SELF_PATH);
|
|
69878
|
-
const
|
|
69879
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
70268
|
+
const path16 = interpreterPath(selfContent);
|
|
70269
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path16);
|
|
69880
70270
|
} catch (e) {}
|
|
69881
70271
|
return cachedFamilyInterpreter;
|
|
69882
70272
|
};
|
|
@@ -69887,8 +70277,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
69887
70277
|
cachedFamilyInterpreter = null;
|
|
69888
70278
|
try {
|
|
69889
70279
|
const selfContent = readFileSync2(SELF_PATH);
|
|
69890
|
-
const
|
|
69891
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
70280
|
+
const path16 = interpreterPath(selfContent);
|
|
70281
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path16);
|
|
69892
70282
|
} catch (e) {}
|
|
69893
70283
|
return cachedFamilyInterpreter;
|
|
69894
70284
|
};
|
|
@@ -71550,18 +71940,18 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
71550
71940
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
71551
71941
|
"@img/sharp-wasm32/sharp.node"
|
|
71552
71942
|
];
|
|
71553
|
-
var
|
|
71943
|
+
var path16;
|
|
71554
71944
|
var sharp;
|
|
71555
71945
|
var errors4 = [];
|
|
71556
|
-
for (
|
|
71946
|
+
for (path16 of paths) {
|
|
71557
71947
|
try {
|
|
71558
|
-
sharp = __require(
|
|
71948
|
+
sharp = __require(path16);
|
|
71559
71949
|
break;
|
|
71560
71950
|
} catch (err) {
|
|
71561
71951
|
errors4.push(err);
|
|
71562
71952
|
}
|
|
71563
71953
|
}
|
|
71564
|
-
if (sharp &&
|
|
71954
|
+
if (sharp && path16.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
71565
71955
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
71566
71956
|
err.code = "Unsupported CPU";
|
|
71567
71957
|
errors4.push(err);
|
|
@@ -71570,7 +71960,7 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
71570
71960
|
if (sharp) {
|
|
71571
71961
|
module.exports = sharp;
|
|
71572
71962
|
} else {
|
|
71573
|
-
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((
|
|
71963
|
+
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((os8) => runtimePlatform.startsWith(os8));
|
|
71574
71964
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
71575
71965
|
errors4.forEach((err) => {
|
|
71576
71966
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -71583,9 +71973,9 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
71583
71973
|
const { found, expected } = isUnsupportedNodeRuntime();
|
|
71584
71974
|
help.push("- Please upgrade Node.js:", ` Found ${found}`, ` Requires ${expected}`);
|
|
71585
71975
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
71586
|
-
const [
|
|
71587
|
-
const libc =
|
|
71588
|
-
help.push("- Ensure optional dependencies can be installed:", " npm install --include=optional sharp", "- Ensure your package manager supports multi-platform installation:", " See https://sharp.pixelplumbing.com/install#cross-platform", "- Add platform-specific dependencies:", ` npm install --os=${
|
|
71976
|
+
const [os8, cpu] = runtimePlatform.split("-");
|
|
71977
|
+
const libc = os8.endsWith("musl") ? " --libc=musl" : "";
|
|
71978
|
+
help.push("- Ensure optional dependencies can be installed:", " npm install --include=optional sharp", "- Ensure your package manager supports multi-platform installation:", " See https://sharp.pixelplumbing.com/install#cross-platform", "- Add platform-specific dependencies:", ` npm install --os=${os8.replace("musl", "")}${libc} --cpu=${cpu} sharp`);
|
|
71589
71979
|
} else {
|
|
71590
71980
|
help.push(`- Manually install libvips >= ${minimumLibvipsVersion}`, "- Add experimental WebAssembly-based dependencies:", " npm install --cpu=wasm32 sharp", " npm install @img/sharp-wasm32");
|
|
71591
71981
|
}
|
|
@@ -72845,7 +73235,7 @@ var require_operation = __commonJS((exports, module) => {
|
|
|
72845
73235
|
float: "float",
|
|
72846
73236
|
approximate: "approximate"
|
|
72847
73237
|
};
|
|
72848
|
-
function
|
|
73238
|
+
function rotate2(angle, options) {
|
|
72849
73239
|
if (!is.defined(angle)) {
|
|
72850
73240
|
return this.autoOrient();
|
|
72851
73241
|
}
|
|
@@ -73272,7 +73662,7 @@ var require_operation = __commonJS((exports, module) => {
|
|
|
73272
73662
|
module.exports = (Sharp) => {
|
|
73273
73663
|
Object.assign(Sharp.prototype, {
|
|
73274
73664
|
autoOrient,
|
|
73275
|
-
rotate,
|
|
73665
|
+
rotate: rotate2,
|
|
73276
73666
|
flip,
|
|
73277
73667
|
flop,
|
|
73278
73668
|
affine,
|
|
@@ -74423,15 +74813,15 @@ var require_color = __commonJS((exports, module) => {
|
|
|
74423
74813
|
};
|
|
74424
74814
|
}
|
|
74425
74815
|
function wrapConversion(toModel, graph) {
|
|
74426
|
-
const
|
|
74816
|
+
const path16 = [graph[toModel].parent, toModel];
|
|
74427
74817
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
74428
74818
|
let cur = graph[toModel].parent;
|
|
74429
74819
|
while (graph[cur].parent) {
|
|
74430
|
-
|
|
74820
|
+
path16.unshift(graph[cur].parent);
|
|
74431
74821
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
74432
74822
|
cur = graph[cur].parent;
|
|
74433
74823
|
}
|
|
74434
|
-
fn.conversion =
|
|
74824
|
+
fn.conversion = path16;
|
|
74435
74825
|
return fn;
|
|
74436
74826
|
}
|
|
74437
74827
|
function route(fromModel) {
|
|
@@ -75036,7 +75426,7 @@ var require_output = __commonJS((exports, module) => {
|
|
|
75036
75426
|
Copyright 2013 Lovell Fuller and others.
|
|
75037
75427
|
SPDX-License-Identifier: Apache-2.0
|
|
75038
75428
|
*/
|
|
75039
|
-
var
|
|
75429
|
+
var path16 = __require("path");
|
|
75040
75430
|
var is = require_is();
|
|
75041
75431
|
var sharp = require_sharp();
|
|
75042
75432
|
var formats = new Map([
|
|
@@ -75067,9 +75457,9 @@ var require_output = __commonJS((exports, module) => {
|
|
|
75067
75457
|
let err;
|
|
75068
75458
|
if (!is.string(fileOut)) {
|
|
75069
75459
|
err = new Error("Missing output file path");
|
|
75070
|
-
} else if (is.string(this.options.input.file) &&
|
|
75460
|
+
} else if (is.string(this.options.input.file) && path16.resolve(this.options.input.file) === path16.resolve(fileOut)) {
|
|
75071
75461
|
err = new Error("Cannot use same file for input and output");
|
|
75072
|
-
} else if (jp2Regex.test(
|
|
75462
|
+
} else if (jp2Regex.test(path16.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
75073
75463
|
err = errJp2Save();
|
|
75074
75464
|
}
|
|
75075
75465
|
if (err) {
|
|
@@ -82316,11 +82706,11 @@ var init_transformers_node = __esm(() => {
|
|
|
82316
82706
|
throw new Error(`The number of external data chunks (${num_chunks}) exceeds the maximum allowed value (${_utils_hub_js__WEBPACK_IMPORTED_MODULE_5__.MAX_EXTERNAL_DATA_CHUNKS}).`);
|
|
82317
82707
|
}
|
|
82318
82708
|
for (let i = 0;i < num_chunks; ++i) {
|
|
82319
|
-
const
|
|
82320
|
-
const fullPath = `${options.subfolder ?? ""}/${
|
|
82709
|
+
const path16 = `${baseName}_data${i === 0 ? "" : "_" + i}`;
|
|
82710
|
+
const fullPath = `${options.subfolder ?? ""}/${path16}`;
|
|
82321
82711
|
externalDataPromises.push(new Promise(async (resolve4, reject) => {
|
|
82322
82712
|
const data = await (0, _utils_hub_js__WEBPACK_IMPORTED_MODULE_5__.getModelFile)(pretrained_model_name_or_path, fullPath, true, options, return_path);
|
|
82323
|
-
resolve4(data instanceof Uint8Array ? { path:
|
|
82713
|
+
resolve4(data instanceof Uint8Array ? { path: path16, data } : path16);
|
|
82324
82714
|
}));
|
|
82325
82715
|
}
|
|
82326
82716
|
} else if (session_options.externalData !== undefined) {
|
|
@@ -95384,7 +95774,7 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
95384
95774
|
const blob = new Blob([wav], { type: "audio/wav" });
|
|
95385
95775
|
return blob;
|
|
95386
95776
|
}
|
|
95387
|
-
async save(
|
|
95777
|
+
async save(path16) {
|
|
95388
95778
|
let fn;
|
|
95389
95779
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_BROWSER_ENV) {
|
|
95390
95780
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_WEBWORKER_ENV) {
|
|
@@ -95392,14 +95782,14 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
95392
95782
|
}
|
|
95393
95783
|
fn = _core_js__WEBPACK_IMPORTED_MODULE_2__.saveBlob;
|
|
95394
95784
|
} else if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_FS_AVAILABLE) {
|
|
95395
|
-
fn = async (
|
|
95785
|
+
fn = async (path17, blob) => {
|
|
95396
95786
|
let buffer = await blob.arrayBuffer();
|
|
95397
|
-
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(
|
|
95787
|
+
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(path17, Buffer.from(buffer));
|
|
95398
95788
|
};
|
|
95399
95789
|
} else {
|
|
95400
95790
|
throw new Error("Unable to save because filesystem is disabled in this environment.");
|
|
95401
95791
|
}
|
|
95402
|
-
await fn(
|
|
95792
|
+
await fn(path16, this.toBlob());
|
|
95403
95793
|
}
|
|
95404
95794
|
}
|
|
95405
95795
|
},
|
|
@@ -95495,11 +95885,11 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
95495
95885
|
function calculateReflectOffset(i, w) {
|
|
95496
95886
|
return Math.abs((i + w) % (2 * w) - w);
|
|
95497
95887
|
}
|
|
95498
|
-
function saveBlob(
|
|
95888
|
+
function saveBlob(path16, blob) {
|
|
95499
95889
|
const dataURL = URL.createObjectURL(blob);
|
|
95500
95890
|
const downloadLink = document.createElement("a");
|
|
95501
95891
|
downloadLink.href = dataURL;
|
|
95502
|
-
downloadLink.download =
|
|
95892
|
+
downloadLink.download = path16;
|
|
95503
95893
|
downloadLink.click();
|
|
95504
95894
|
downloadLink.remove();
|
|
95505
95895
|
URL.revokeObjectURL(dataURL);
|
|
@@ -96100,8 +96490,8 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
96100
96490
|
}
|
|
96101
96491
|
|
|
96102
96492
|
class FileCache {
|
|
96103
|
-
constructor(
|
|
96104
|
-
this.path =
|
|
96493
|
+
constructor(path16) {
|
|
96494
|
+
this.path = path16;
|
|
96105
96495
|
}
|
|
96106
96496
|
async match(request) {
|
|
96107
96497
|
let filePath = node_path__WEBPACK_IMPORTED_MODULE_1__["default"].join(this.path, request);
|
|
@@ -96857,20 +97247,20 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
96857
97247
|
}
|
|
96858
97248
|
return this;
|
|
96859
97249
|
}
|
|
96860
|
-
async save(
|
|
97250
|
+
async save(path16) {
|
|
96861
97251
|
if (IS_BROWSER_OR_WEBWORKER) {
|
|
96862
97252
|
if (_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_WEBWORKER_ENV) {
|
|
96863
97253
|
throw new Error("Unable to save an image from a Web Worker.");
|
|
96864
97254
|
}
|
|
96865
|
-
const extension =
|
|
97255
|
+
const extension = path16.split(".").pop().toLowerCase();
|
|
96866
97256
|
const mime = CONTENT_TYPE_MAP.get(extension) ?? "image/png";
|
|
96867
97257
|
const blob = await this.toBlob(mime);
|
|
96868
|
-
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(
|
|
97258
|
+
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(path16, blob);
|
|
96869
97259
|
} else if (!_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_FS_AVAILABLE) {
|
|
96870
97260
|
throw new Error("Unable to save the image because filesystem is disabled in this environment.");
|
|
96871
97261
|
} else {
|
|
96872
97262
|
const img = this.toSharp();
|
|
96873
|
-
return await img.toFile(
|
|
97263
|
+
return await img.toFile(path16);
|
|
96874
97264
|
}
|
|
96875
97265
|
}
|
|
96876
97266
|
toSharp() {
|
|
@@ -100397,20 +100787,20 @@ function getRetryDelay(attempt, config3) {
|
|
|
100397
100787
|
return Math.min(delay2, config3.maxDelay);
|
|
100398
100788
|
}
|
|
100399
100789
|
async function withRetry(fn, config3, context2) {
|
|
100400
|
-
let
|
|
100790
|
+
let lastError2;
|
|
100401
100791
|
for (let attempt = 0;attempt <= config3.maxRetries; attempt++) {
|
|
100402
100792
|
try {
|
|
100403
100793
|
return await fn();
|
|
100404
100794
|
} catch (error51) {
|
|
100405
|
-
|
|
100795
|
+
lastError2 = error51;
|
|
100406
100796
|
if (attempt < config3.maxRetries) {
|
|
100407
100797
|
const delay2 = getRetryDelay(attempt, config3);
|
|
100408
|
-
logger.warn(`[EmbeddingProvider] ${context2} failed (attempt ${attempt + 1}/${config3.maxRetries + 1}), retrying in ${delay2}ms`, { error:
|
|
100798
|
+
logger.warn(`[EmbeddingProvider] ${context2} failed (attempt ${attempt + 1}/${config3.maxRetries + 1}), retrying in ${delay2}ms`, { error: lastError2.message });
|
|
100409
100799
|
await sleep(delay2);
|
|
100410
100800
|
}
|
|
100411
100801
|
}
|
|
100412
100802
|
}
|
|
100413
|
-
throw new Error(`${context2} failed after ${config3.maxRetries + 1} attempts: ${
|
|
100803
|
+
throw new Error(`${context2} failed after ${config3.maxRetries + 1} attempts: ${lastError2?.message}`);
|
|
100414
100804
|
}
|
|
100415
100805
|
async function withTimeout(fn, timeoutMs, context2) {
|
|
100416
100806
|
let timeoutId;
|
|
@@ -106096,7 +106486,7 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a;
|
|
|
106096
106486
|
function ns(e = Yo, t = Yo) {
|
|
106097
106487
|
return (r) => e(t(r));
|
|
106098
106488
|
}
|
|
106099
|
-
function
|
|
106489
|
+
function os8({ dataPath: e, modelName: t, args: r, runtimeDataModel: n }) {
|
|
106100
106490
|
let i = { modelName: t, args: r ?? {} }, o = dp(e);
|
|
106101
106491
|
if (!o || o.length === 0)
|
|
106102
106492
|
return i;
|
|
@@ -106401,10 +106791,10 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a;
|
|
|
106401
106791
|
super(t, "P2023", r);
|
|
106402
106792
|
}
|
|
106403
106793
|
};
|
|
106404
|
-
var
|
|
106794
|
+
var fs11 = new WeakMap;
|
|
106405
106795
|
function Ep(e) {
|
|
106406
|
-
let t =
|
|
106407
|
-
return t || (t = Object.entries(e),
|
|
106796
|
+
let t = fs11.get(e);
|
|
106797
|
+
return t || (t = Object.entries(e), fs11.set(e, t)), t;
|
|
106408
106798
|
}
|
|
106409
106799
|
function hs(e, t, r) {
|
|
106410
106800
|
switch (t.type) {
|
|
@@ -109969,7 +110359,7 @@ new PrismaClient({
|
|
|
109969
110359
|
let m = await es(this, d);
|
|
109970
110360
|
if (!d.model)
|
|
109971
110361
|
return m;
|
|
109972
|
-
let g =
|
|
110362
|
+
let g = os8({ dataPath: d.dataPath, modelName: d.model, args: d.args, runtimeDataModel: this._runtimeDataModel });
|
|
109973
110363
|
return Wo({ result: m, modelName: g.modelName, args: g.args, extensions: this._extensions, runtimeDataModel: this._runtimeDataModel, globalOmit: this._globalOmit });
|
|
109974
110364
|
};
|
|
109975
110365
|
return this._tracingHelper.runInChildSpan(s.operation, () => new zl.AsyncResource("prisma-client-request").runInAsyncScope(() => a(o)));
|
|
@@ -110372,7 +110762,7 @@ var require_prisma = __commonJS((exports) => {
|
|
|
110372
110762
|
Prisma.JsonNull = JsonNull2;
|
|
110373
110763
|
Prisma.AnyNull = AnyNull2;
|
|
110374
110764
|
Prisma.NullTypes = NullTypes2;
|
|
110375
|
-
var
|
|
110765
|
+
var path16 = __require("path");
|
|
110376
110766
|
exports.Prisma.TransactionIsolationLevel = makeStrictEnum2({
|
|
110377
110767
|
ReadUncommitted: "ReadUncommitted",
|
|
110378
110768
|
ReadCommitted: "ReadCommitted",
|
|
@@ -117885,7 +118275,7 @@ async function upsertWorkspace(ws) {
|
|
|
117885
118275
|
}, { timeout: 60000, maxWait: 1e4 });
|
|
117886
118276
|
}
|
|
117887
118277
|
async function updateWorkspaceStatus(projectId, status, opts) {
|
|
117888
|
-
const
|
|
118278
|
+
const lastError2 = typeof opts === "string" ? opts : opts?.lastError ?? null;
|
|
117889
118279
|
const filesCount = typeof opts === "object" ? opts?.filesCount : undefined;
|
|
117890
118280
|
const chunksCount = typeof opts === "object" ? opts?.chunksCount : undefined;
|
|
117891
118281
|
const symbolsCount = typeof opts === "object" ? opts?.symbolsCount : undefined;
|
|
@@ -117895,7 +118285,7 @@ async function updateWorkspaceStatus(projectId, status, opts) {
|
|
|
117895
118285
|
await tx.$executeRaw`
|
|
117896
118286
|
UPDATE workspaces SET
|
|
117897
118287
|
status = ${status},
|
|
117898
|
-
last_error = ${
|
|
118288
|
+
last_error = ${lastError2},
|
|
117899
118289
|
last_indexed_at = ${lastIndexedAt ?? null},
|
|
117900
118290
|
files_count = COALESCE(${filesCount ?? null}, files_count),
|
|
117901
118291
|
chunks_count = COALESCE(${chunksCount ?? null}, chunks_count),
|
|
@@ -123239,10 +123629,10 @@ var init_chunker_code = __esm(() => {
|
|
|
123239
123629
|
});
|
|
123240
123630
|
|
|
123241
123631
|
// ../../packages/core/dist/services/search/smart-chunker.js
|
|
123242
|
-
import
|
|
123632
|
+
import path16 from "path";
|
|
123243
123633
|
function smartChunk(content, filePath, config3 = {}) {
|
|
123244
123634
|
const cfg = { ...DEFAULT_CONFIG, ...config3 };
|
|
123245
|
-
const ext2 =
|
|
123635
|
+
const ext2 = path16.extname(filePath).toLowerCase();
|
|
123246
123636
|
const relativePath = filePath;
|
|
123247
123637
|
const fileImports = isCodeFile(ext2) ? extractFileImports(content, ext2) : undefined;
|
|
123248
123638
|
let chunks;
|
|
@@ -123549,8 +123939,8 @@ var init_managed_run_repository_pg = __esm(() => {
|
|
|
123549
123939
|
});
|
|
123550
123940
|
|
|
123551
123941
|
// ../../packages/core/dist/services/search/project-indexer.js
|
|
123552
|
-
import
|
|
123553
|
-
import
|
|
123942
|
+
import fs11 from "fs/promises";
|
|
123943
|
+
import path17 from "path";
|
|
123554
123944
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
123555
123945
|
async function runWithIndexLock(lockMap, projectId, work) {
|
|
123556
123946
|
const prevLock = lockMap.get(projectId);
|
|
@@ -123593,7 +123983,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
123593
123983
|
dot: false
|
|
123594
123984
|
});
|
|
123595
123985
|
const filteredFiles = files.filter((file2) => {
|
|
123596
|
-
const relativePath =
|
|
123986
|
+
const relativePath = path17.relative(projectPath, file2);
|
|
123597
123987
|
const shouldIgnore = ig.ignores(relativePath);
|
|
123598
123988
|
if (shouldIgnore) {
|
|
123599
123989
|
logger.debug("Ignoring file per .gitignore during indexing", {
|
|
@@ -123633,7 +124023,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
123633
124023
|
});
|
|
123634
124024
|
}
|
|
123635
124025
|
}
|
|
123636
|
-
const indexedFilesList = filteredFiles.map((f) =>
|
|
124026
|
+
const indexedFilesList = filteredFiles.map((f) => path17.relative(projectPath, f));
|
|
123637
124027
|
await deps.indexManager.updateIndexMetadata(projectId, projectPath, indexedFilesList);
|
|
123638
124028
|
logger.info("Project indexing completed", {
|
|
123639
124029
|
projectId,
|
|
@@ -123758,7 +124148,7 @@ async function ensureFreshIndex(deps, projectId, projectPath, options = {}) {
|
|
|
123758
124148
|
let errors4 = 0;
|
|
123759
124149
|
for (const relativeFilePath of filesToReindex) {
|
|
123760
124150
|
try {
|
|
123761
|
-
const fullPath =
|
|
124151
|
+
const fullPath = path17.join(projectPath, relativeFilePath);
|
|
123762
124152
|
const result = await deps.indexFile(fullPath, projectId, projectPath, centralityMap);
|
|
123763
124153
|
filesIndexed++;
|
|
123764
124154
|
chunksIndexed += result.chunks;
|
|
@@ -123809,8 +124199,8 @@ async function checkSearchAdmission(deps, projectId, projectPath) {
|
|
|
123809
124199
|
}
|
|
123810
124200
|
async function indexFile(deps, filePath, projectId, projectRoot, centralityMap) {
|
|
123811
124201
|
projectId = await getProjectIdentityAliasResolver().resolve(projectId);
|
|
123812
|
-
const content = await
|
|
123813
|
-
const relativePath =
|
|
124202
|
+
const content = await fs11.readFile(filePath, "utf-8");
|
|
124203
|
+
const relativePath = path17.relative(projectRoot, filePath);
|
|
123814
124204
|
const maxFileSize = config2.get("security").maxFileSize || 1024 * 1024;
|
|
123815
124205
|
if (content.length > maxFileSize) {
|
|
123816
124206
|
logger.warn("File too large, skipping", {
|
|
@@ -123830,7 +124220,7 @@ async function indexFile(deps, filePath, projectId, projectRoot, centralityMap)
|
|
|
123830
124220
|
chunkIndex: i,
|
|
123831
124221
|
totalChunks: chunks.length,
|
|
123832
124222
|
type: chunk.type,
|
|
123833
|
-
language:
|
|
124223
|
+
language: path17.extname(filePath).slice(1),
|
|
123834
124224
|
lineStart: chunk.lineStart,
|
|
123835
124225
|
lineEnd: chunk.lineEnd,
|
|
123836
124226
|
label: chunk.label,
|
|
@@ -124675,8 +125065,8 @@ function stripNul(content) {
|
|
|
124675
125065
|
}
|
|
124676
125066
|
|
|
124677
125067
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
124678
|
-
import
|
|
124679
|
-
import
|
|
125068
|
+
import fs12 from "fs/promises";
|
|
125069
|
+
import path18 from "path";
|
|
124680
125070
|
import { createHash as createHash5 } from "crypto";
|
|
124681
125071
|
|
|
124682
125072
|
class DiscoverStage {
|
|
@@ -124702,7 +125092,7 @@ class DiscoverStage {
|
|
|
124702
125092
|
dot: false,
|
|
124703
125093
|
absolute: false
|
|
124704
125094
|
});
|
|
124705
|
-
relPaths = found.map((p) =>
|
|
125095
|
+
relPaths = found.map((p) => path18.isAbsolute(p) ? path18.relative(ctx.projectPath, p) : p).filter((p) => !ig.ignores(p) && applyPolicy(p, policy) !== "Drop");
|
|
124706
125096
|
}
|
|
124707
125097
|
if (ctx.resumeCursor?.path) {
|
|
124708
125098
|
const cursorPath = ctx.resumeCursor.path;
|
|
@@ -124761,10 +125151,10 @@ class DiscoverStage {
|
|
|
124761
125151
|
return discovered;
|
|
124762
125152
|
}
|
|
124763
125153
|
async processFile(ctx, relativePath, forceReindex) {
|
|
124764
|
-
const absolutePath =
|
|
125154
|
+
const absolutePath = path18.join(ctx.projectPath, relativePath);
|
|
124765
125155
|
try {
|
|
124766
|
-
const stat = await
|
|
124767
|
-
const content = stripNul(await
|
|
125156
|
+
const stat = await fs12.stat(absolutePath);
|
|
125157
|
+
const content = stripNul(await fs12.readFile(absolutePath, "utf-8"));
|
|
124768
125158
|
const contentHash = createHash5("sha256").update(content).digest("hex");
|
|
124769
125159
|
let needsReparse = forceReindex;
|
|
124770
125160
|
if (!forceReindex) {
|
|
@@ -124807,8 +125197,8 @@ class DiscoverStage {
|
|
|
124807
125197
|
ig.add(pattern);
|
|
124808
125198
|
}
|
|
124809
125199
|
try {
|
|
124810
|
-
const gitignorePath =
|
|
124811
|
-
const gitignoreContent = await
|
|
125200
|
+
const gitignorePath = path18.join(projectPath, ".gitignore");
|
|
125201
|
+
const gitignoreContent = await fs12.readFile(gitignorePath, "utf8");
|
|
124812
125202
|
const rules = gitignoreContent.split(`
|
|
124813
125203
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
124814
125204
|
ig.add(rules);
|
|
@@ -126163,8 +126553,8 @@ function rustUseLeaves(node, source, prefix = []) {
|
|
|
126163
126553
|
}
|
|
126164
126554
|
if (node.type === "use_wildcard")
|
|
126165
126555
|
return [{ path: [...prefix, "*"], glob: true }];
|
|
126166
|
-
const
|
|
126167
|
-
return
|
|
126556
|
+
const path19 = rustPathSegments(node, source);
|
|
126557
|
+
return path19.length ? [{ path: [...prefix, ...path19] }] : [];
|
|
126168
126558
|
}
|
|
126169
126559
|
function functionalCaptures(captures, source, family) {
|
|
126170
126560
|
if (family !== "clojure")
|
|
@@ -127136,8 +127526,8 @@ var init_structural_runtime = __esm(() => {
|
|
|
127136
127526
|
});
|
|
127137
127527
|
|
|
127138
127528
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
127139
|
-
import
|
|
127140
|
-
import
|
|
127529
|
+
import path19 from "path";
|
|
127530
|
+
import fs13 from "fs/promises";
|
|
127141
127531
|
function resolveChunkerMaxChars() {
|
|
127142
127532
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
127143
127533
|
if (Number.isFinite(global2) && global2 > 0)
|
|
@@ -127165,8 +127555,8 @@ class ParseStage {
|
|
|
127165
127555
|
const results = new Map;
|
|
127166
127556
|
let processed = 0;
|
|
127167
127557
|
const phases = [
|
|
127168
|
-
files.filter((file2) =>
|
|
127169
|
-
files.filter((file2) =>
|
|
127558
|
+
files.filter((file2) => path19.extname(file2.relativePath).toLowerCase() !== ".h"),
|
|
127559
|
+
files.filter((file2) => path19.extname(file2.relativePath).toLowerCase() === ".h")
|
|
127170
127560
|
];
|
|
127171
127561
|
const batches = phases.flatMap((phase) => Array.from({ length: Math.ceil(phase.length / BATCH_SIZE) }, (_, index) => phase.slice(index * BATCH_SIZE, (index + 1) * BATCH_SIZE)));
|
|
127172
127562
|
for (const batch of batches) {
|
|
@@ -127204,19 +127594,19 @@ class ParseStage {
|
|
|
127204
127594
|
return files.map((file2) => results.get(file2.relativePath));
|
|
127205
127595
|
}
|
|
127206
127596
|
recordHeaderImporterEvidence(ctx, files, parsedFiles) {
|
|
127207
|
-
const knownHeaders = new Set(files.filter((file2) =>
|
|
127597
|
+
const knownHeaders = new Set(files.filter((file2) => path19.extname(file2.relativePath).toLowerCase() === ".h").map((file2) => path19.posix.normalize(file2.relativePath)));
|
|
127208
127598
|
const mutable = {
|
|
127209
127599
|
...ctx.structuralHeaderEvidenceByFile
|
|
127210
127600
|
};
|
|
127211
127601
|
for (const parsed of parsedFiles) {
|
|
127212
|
-
const extension =
|
|
127602
|
+
const extension = path19.extname(parsed.file.relativePath).toLowerCase();
|
|
127213
127603
|
const key = extension === ".c" ? "cImporters" : [".cpp", ".hpp"].includes(extension) ? "cppImporters" : undefined;
|
|
127214
127604
|
if (!key)
|
|
127215
127605
|
continue;
|
|
127216
127606
|
for (const imported of parsed.rawImports) {
|
|
127217
127607
|
if (!["c_include", "cpp_include"].includes(imported.form) || imported.specifier.startsWith("<"))
|
|
127218
127608
|
continue;
|
|
127219
|
-
const header =
|
|
127609
|
+
const header = path19.posix.normalize(path19.posix.join(path19.posix.dirname(parsed.file.relativePath), imported.specifier));
|
|
127220
127610
|
if (!knownHeaders.has(header))
|
|
127221
127611
|
continue;
|
|
127222
127612
|
const existing = mutable[header] ?? {};
|
|
@@ -127227,9 +127617,9 @@ class ParseStage {
|
|
|
127227
127617
|
}
|
|
127228
127618
|
async parseFile(ctx, file2) {
|
|
127229
127619
|
if (!file2.needsReparse) {
|
|
127230
|
-
const extension =
|
|
127620
|
+
const extension = path19.extname(file2.relativePath).toLowerCase();
|
|
127231
127621
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
127232
|
-
const content = file2.snapshotContent ?? await
|
|
127622
|
+
const content = file2.snapshotContent ?? await fs13.readFile(file2.absolutePath, "utf8");
|
|
127233
127623
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
127234
127624
|
if (outcome.status === "failed")
|
|
127235
127625
|
throw new StructuralEtlParseError(file2.relativePath, outcome.failureKind, `Structural evidence parse failed (${outcome.failureKind})`, outcome.diagnosticCount, outcome.diagnostics.slice(0, 10));
|
|
@@ -127241,8 +127631,8 @@ class ParseStage {
|
|
|
127241
127631
|
return { file: file2, chunks: [], symbols: [], rawImports: [], rawEdges: [] };
|
|
127242
127632
|
}
|
|
127243
127633
|
try {
|
|
127244
|
-
const content = file2.snapshotContent ?? await
|
|
127245
|
-
const ext2 =
|
|
127634
|
+
const content = file2.snapshotContent ?? await fs13.readFile(file2.absolutePath, "utf-8");
|
|
127635
|
+
const ext2 = path19.extname(file2.relativePath).toLowerCase();
|
|
127246
127636
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
127247
127637
|
const chunks = smartChunk(content, file2.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
127248
127638
|
let symbols;
|
|
@@ -127796,7 +128186,7 @@ var init_resolver = __esm(() => {
|
|
|
127796
128186
|
});
|
|
127797
128187
|
|
|
127798
128188
|
// ../../packages/core/dist/services/structural/resolvers/typescript.js
|
|
127799
|
-
import
|
|
128189
|
+
import path20 from "path";
|
|
127800
128190
|
function candidates(identities) {
|
|
127801
128191
|
return Object.freeze(identities.map((identity) => Object.freeze({
|
|
127802
128192
|
fqn: identity.fqn,
|
|
@@ -127891,7 +128281,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
127891
128281
|
const bases = /\.[cm]?jsx?$/u.test(base) ? [base.replace(/\.[cm]?jsx?$/u, ".ts"), base.replace(/\.[cm]?jsx?$/u, ".tsx"), base] : [base];
|
|
127892
128282
|
for (const candidateBase of bases)
|
|
127893
128283
|
for (const suffix of DIALECT_PROBES[dialect] ?? [""]) {
|
|
127894
|
-
const value =
|
|
128284
|
+
const value = path20.posix.normalize(`${candidateBase}${suffix}`);
|
|
127895
128285
|
if (!value.startsWith("../") && value !== ".." && known.has(value))
|
|
127896
128286
|
return value;
|
|
127897
128287
|
}
|
|
@@ -127900,7 +128290,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
127900
128290
|
function resolveStructuralSpecifier(specifier, fromFile, build, dialect = "typescript") {
|
|
127901
128291
|
const known = new Set(build.knownFiles.map(normalizeStructuralFile));
|
|
127902
128292
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
127903
|
-
return probe(
|
|
128293
|
+
return probe(path20.posix.join(path20.posix.dirname(fromFile), specifier), known, dialect);
|
|
127904
128294
|
}
|
|
127905
128295
|
const aliases = build.pathAliasesByFile?.[normalizeStructuralFile(fromFile)] ?? build.pathAliases ?? [];
|
|
127906
128296
|
for (const alias of aliases) {
|
|
@@ -128164,7 +128554,7 @@ var init_scripting2 = __esm(() => {
|
|
|
128164
128554
|
});
|
|
128165
128555
|
|
|
128166
128556
|
// ../../packages/core/dist/services/structural/resolvers/systems.js
|
|
128167
|
-
import
|
|
128557
|
+
import path21 from "path";
|
|
128168
128558
|
var DIALECTS, SYSTEMS_LANGUAGE_RESOLVER;
|
|
128169
128559
|
var init_systems2 = __esm(() => {
|
|
128170
128560
|
init_typescript2();
|
|
@@ -128183,7 +128573,7 @@ var init_systems2 = __esm(() => {
|
|
|
128183
128573
|
const bindings = item.bindings.map((binding) => binding.imported === "*" && binding.local === "*" && unresolvedTarget && !unresolvedTarget.qualifier ? { ...binding, imported: unresolvedTarget.name, local: unresolvedTarget.name } : binding);
|
|
128184
128574
|
if (item.specifier === "crate" || item.specifier.startsWith("crate/")) {
|
|
128185
128575
|
const crateRoot = file2.file.startsWith("src/") ? "src" : "";
|
|
128186
|
-
return { ...item, bindings, specifier: `./${
|
|
128576
|
+
return { ...item, bindings, specifier: `./${path21.posix.relative(path21.posix.dirname(file2.file), path21.posix.join(crateRoot, item.specifier.replace(/^crate\/?/u, "")))}` };
|
|
128187
128577
|
}
|
|
128188
128578
|
if (item.specifier === "self" || item.specifier.startsWith("self/"))
|
|
128189
128579
|
return { ...item, bindings, specifier: `./${item.specifier.replace(/^self\/?/u, "")}` };
|
|
@@ -128281,8 +128671,8 @@ var init_data_document2 = __esm(() => {
|
|
|
128281
128671
|
});
|
|
128282
128672
|
|
|
128283
128673
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
128284
|
-
import
|
|
128285
|
-
import
|
|
128674
|
+
import path22 from "path";
|
|
128675
|
+
import fs14 from "fs";
|
|
128286
128676
|
|
|
128287
128677
|
class ResolveStage {
|
|
128288
128678
|
symbolRepository;
|
|
@@ -128306,7 +128696,7 @@ class ResolveStage {
|
|
|
128306
128696
|
const structuralDocuments = files.flatMap((file2) => {
|
|
128307
128697
|
if (!file2.structure)
|
|
128308
128698
|
return [];
|
|
128309
|
-
const language = resolveStructuralLanguage(
|
|
128699
|
+
const language = resolveStructuralLanguage(path22.extname(file2.file.relativePath));
|
|
128310
128700
|
if (language.status !== "supported")
|
|
128311
128701
|
throw new Error(`structural_manifest_missing:${file2.file.relativePath}`);
|
|
128312
128702
|
return [{
|
|
@@ -128318,13 +128708,13 @@ class ResolveStage {
|
|
|
128318
128708
|
}];
|
|
128319
128709
|
});
|
|
128320
128710
|
const currentStructuralFiles = new Set(structuralDocuments.map((document2) => document2.file));
|
|
128321
|
-
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
128711
|
+
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path22.extname(item.file.relativePath).toLowerCase())).map((item) => item.file.relativePath));
|
|
128322
128712
|
const pathAliasesByFile = Object.fromEntries([...knownRelPaths].map((file2) => [
|
|
128323
128713
|
file2,
|
|
128324
128714
|
this.structuralAliasesFor(file2, rootAliases, monorepoPackages)
|
|
128325
128715
|
]));
|
|
128326
128716
|
const buildMetadata = { knownFiles: [...knownRelPaths], pathAliasesByFile };
|
|
128327
|
-
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(
|
|
128717
|
+
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(path22.extname(definition.file_path).toLowerCase())).filter((definition) => knownRelPaths.has(definition.file_path) && skippedStructuralFiles.has(definition.file_path)).filter((definition) => !currentStructuralFiles.has(definition.file_path));
|
|
128328
128718
|
const seedIds = new Set;
|
|
128329
128719
|
for (const definition of seedRows) {
|
|
128330
128720
|
if (seedIds.has(definition.id))
|
|
@@ -128417,7 +128807,7 @@ class ResolveStage {
|
|
|
128417
128807
|
if (parsed.file !== definition.file_path) {
|
|
128418
128808
|
throw new Error(`structural_repository_seed_file_mismatch:${definition.id}`);
|
|
128419
128809
|
}
|
|
128420
|
-
const language = resolveStructuralLanguage(
|
|
128810
|
+
const language = resolveStructuralLanguage(path22.extname(definition.file_path));
|
|
128421
128811
|
if (language.status !== "supported")
|
|
128422
128812
|
throw new Error(`structural_repository_seed_language:${definition.id}`);
|
|
128423
128813
|
let identity;
|
|
@@ -128469,7 +128859,7 @@ class ResolveStage {
|
|
|
128469
128859
|
});
|
|
128470
128860
|
}
|
|
128471
128861
|
resolveFile(parsed, projectPath, knownRelPaths, rootAliases, monorepoPackages, symbolIndex, knownFqns) {
|
|
128472
|
-
const fromDir =
|
|
128862
|
+
const fromDir = path22.dirname(path22.join(projectPath, parsed.file.relativePath));
|
|
128473
128863
|
const packageAliases = this.getPackageAliases(parsed.file.relativePath, monorepoPackages);
|
|
128474
128864
|
const allAliases = [...packageAliases, ...rootAliases];
|
|
128475
128865
|
const resolvedImports = parsed.rawImports.map((raw2) => {
|
|
@@ -128540,7 +128930,7 @@ class ResolveStage {
|
|
|
128540
128930
|
index.set(def.name, `${def.file_path}#${def.name}`);
|
|
128541
128931
|
}
|
|
128542
128932
|
} catch (err) {
|
|
128543
|
-
const skippedStructural = files.some((file2) => !file2.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
128933
|
+
const skippedStructural = files.some((file2) => !file2.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path22.extname(file2.file.relativePath).toLowerCase()));
|
|
128544
128934
|
if (skippedStructural)
|
|
128545
128935
|
throw new Error("structural_repository_seed_failed", { cause: err });
|
|
128546
128936
|
logger.warn("buildSymbolIndex: repo seed failed, in-batch only", {
|
|
@@ -128564,7 +128954,7 @@ class ResolveStage {
|
|
|
128564
128954
|
}
|
|
128565
128955
|
resolveSpecifier(specifier, fromDir, projectPath, knownRelPaths, aliases) {
|
|
128566
128956
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
128567
|
-
const resolved = this.probeExtensions(
|
|
128957
|
+
const resolved = this.probeExtensions(path22.resolve(fromDir, specifier), projectPath, knownRelPaths);
|
|
128568
128958
|
return { resolvedPath: resolved, external: false };
|
|
128569
128959
|
}
|
|
128570
128960
|
for (const alias of aliases) {
|
|
@@ -128572,8 +128962,8 @@ class ResolveStage {
|
|
|
128572
128962
|
const suffix = specifier.slice(alias.prefix.length);
|
|
128573
128963
|
for (const target of alias.targets) {
|
|
128574
128964
|
const cleanTarget = target.replace(/\/\*$/, "");
|
|
128575
|
-
const basePath = alias.packagePath ?
|
|
128576
|
-
const absPath =
|
|
128965
|
+
const basePath = alias.packagePath ? path22.join(projectPath, alias.packagePath) : projectPath;
|
|
128966
|
+
const absPath = path22.join(basePath, cleanTarget + suffix);
|
|
128577
128967
|
const resolved = this.probeExtensions(absPath, projectPath, knownRelPaths);
|
|
128578
128968
|
if (resolved)
|
|
128579
128969
|
return { resolvedPath: resolved, external: false };
|
|
@@ -128589,7 +128979,7 @@ class ResolveStage {
|
|
|
128589
128979
|
...TS_EXTENSIONS.map((ext2) => absPath.replace(/\.[^.]+$/, ext2))
|
|
128590
128980
|
];
|
|
128591
128981
|
for (const candidate2 of candidates2) {
|
|
128592
|
-
const rel =
|
|
128982
|
+
const rel = path22.relative(projectPath, candidate2).replace(/\\/g, "/");
|
|
128593
128983
|
if (knownRelPaths.has(rel))
|
|
128594
128984
|
return rel;
|
|
128595
128985
|
}
|
|
@@ -128597,9 +128987,9 @@ class ResolveStage {
|
|
|
128597
128987
|
}
|
|
128598
128988
|
loadTsConfigPaths(projectPath, packageBase) {
|
|
128599
128989
|
const aliases = [];
|
|
128600
|
-
const tsconfigPath =
|
|
128990
|
+
const tsconfigPath = path22.join(projectPath, "tsconfig.json");
|
|
128601
128991
|
try {
|
|
128602
|
-
const raw2 =
|
|
128992
|
+
const raw2 = fs14.readFileSync(tsconfigPath, "utf-8");
|
|
128603
128993
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
128604
128994
|
const tsconfig = JSON.parse(stripped);
|
|
128605
128995
|
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
@@ -128628,7 +129018,7 @@ class ResolveStage {
|
|
|
128628
129018
|
}
|
|
128629
129019
|
}
|
|
128630
129020
|
for (const packageRelPath of packagePaths) {
|
|
128631
|
-
const absPackagePath =
|
|
129021
|
+
const absPackagePath = path22.join(projectPath, packageRelPath);
|
|
128632
129022
|
const aliases = this.loadTsConfigPaths(absPackagePath, packageRelPath);
|
|
128633
129023
|
if (aliases.length > 0) {
|
|
128634
129024
|
packages.push({
|
|
@@ -128658,7 +129048,7 @@ class ResolveStage {
|
|
|
128658
129048
|
structuralAliasesFor(filePath, rootAliases, packages) {
|
|
128659
129049
|
return [...this.getPackageAliases(filePath, packages), ...rootAliases].map((alias) => ({
|
|
128660
129050
|
pattern: alias.prefix + (alias.targets.some((target) => target.includes("*")) ? "/*" : ""),
|
|
128661
|
-
targets: alias.targets.map((target) => alias.packagePath ?
|
|
129051
|
+
targets: alias.targets.map((target) => alias.packagePath ? path22.posix.join(alias.packagePath, target) : target)
|
|
128662
129052
|
}));
|
|
128663
129053
|
}
|
|
128664
129054
|
}
|
|
@@ -128722,7 +129112,7 @@ var init_with_deadlock_retry = __esm(() => {
|
|
|
128722
129112
|
});
|
|
128723
129113
|
|
|
128724
129114
|
// ../../packages/core/dist/services/etl/stages/load.js
|
|
128725
|
-
import
|
|
129115
|
+
import path23 from "path";
|
|
128726
129116
|
function formatDuration(ms) {
|
|
128727
129117
|
const totalSec = Math.max(0, Math.round(ms / 1000));
|
|
128728
129118
|
if (totalSec < 60)
|
|
@@ -128999,7 +129389,7 @@ class LoadStage {
|
|
|
128999
129389
|
const filePath = file2.file.relativePath;
|
|
129000
129390
|
const batch = buildSymbolPersistenceBatch(ctx.projectId, file2);
|
|
129001
129391
|
if (ctx.graphGenerationLease) {
|
|
129002
|
-
const manifest = getLanguageManifestEntry(
|
|
129392
|
+
const manifest = getLanguageManifestEntry(path23.extname(filePath));
|
|
129003
129393
|
const diagnostics2 = (file2.structuralDiagnostics ?? []).slice(0, 10).map((diagnostic2) => ({
|
|
129004
129394
|
code: diagnostic2.code,
|
|
129005
129395
|
severity: diagnostic2.severity,
|
|
@@ -129456,9 +129846,9 @@ var init_graph_generation_coordinator = __esm(() => {
|
|
|
129456
129846
|
// ../../packages/core/dist/services/etl/pipeline.js
|
|
129457
129847
|
import { createHash as createHash7 } from "crypto";
|
|
129458
129848
|
import { setTimeout as delay2 } from "timers/promises";
|
|
129459
|
-
import
|
|
129849
|
+
import path24 from "path";
|
|
129460
129850
|
function buildHeaderLanguageEvidence(files) {
|
|
129461
|
-
const headers = new Set(files.filter((file2) =>
|
|
129851
|
+
const headers = new Set(files.filter((file2) => path24.posix.extname(file2.relativePath).toLowerCase() === ".h").map((file2) => path24.posix.normalize(file2.relativePath)));
|
|
129462
129852
|
const mutable = new Map;
|
|
129463
129853
|
const entry2 = (header) => {
|
|
129464
129854
|
let value = mutable.get(header);
|
|
@@ -129469,7 +129859,7 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
129469
129859
|
return value;
|
|
129470
129860
|
};
|
|
129471
129861
|
for (const file2 of files) {
|
|
129472
|
-
if (
|
|
129862
|
+
if (path24.posix.basename(file2.relativePath) !== "compile_commands.json" || file2.snapshotContent === undefined)
|
|
129473
129863
|
continue;
|
|
129474
129864
|
let commands;
|
|
129475
129865
|
try {
|
|
@@ -129485,11 +129875,11 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
129485
129875
|
const record3 = command;
|
|
129486
129876
|
if (typeof record3.file !== "string")
|
|
129487
129877
|
continue;
|
|
129488
|
-
const projectRoot =
|
|
129489
|
-
const commandDirectory = typeof record3.directory === "string" ?
|
|
129490
|
-
const absoluteInput =
|
|
129491
|
-
const relative2 =
|
|
129492
|
-
const header =
|
|
129878
|
+
const projectRoot = path24.resolve(file2.absolutePath, ...file2.relativePath.split("/").map(() => ".."));
|
|
129879
|
+
const commandDirectory = typeof record3.directory === "string" ? path24.resolve(projectRoot, record3.directory) : projectRoot;
|
|
129880
|
+
const absoluteInput = path24.resolve(commandDirectory, record3.file);
|
|
129881
|
+
const relative2 = path24.relative(projectRoot, absoluteInput);
|
|
129882
|
+
const header = path24.posix.normalize(relative2.replaceAll(path24.sep, "/"));
|
|
129493
129883
|
if (!headers.has(header))
|
|
129494
129884
|
continue;
|
|
129495
129885
|
const invocation = typeof record3.command === "string" ? record3.command : Array.isArray(record3.arguments) ? record3.arguments.join(" ") : "";
|
|
@@ -130020,9 +130410,9 @@ var init_acquire_indexing_lease = __esm(() => {
|
|
|
130020
130410
|
|
|
130021
130411
|
// ../../packages/core/dist/services/project-identity/project-root-identity.js
|
|
130022
130412
|
import { realpath as realpath2 } from "fs/promises";
|
|
130023
|
-
import
|
|
130413
|
+
import path25 from "path";
|
|
130024
130414
|
async function canonicalizeProjectRoot(projectPath, canonicalize = realpath2) {
|
|
130025
|
-
return canonicalize(
|
|
130415
|
+
return canonicalize(path25.resolve(projectPath));
|
|
130026
130416
|
}
|
|
130027
130417
|
async function assertProjectRootReuse(options) {
|
|
130028
130418
|
if (!options.storedProjectPath || options.forceReindex)
|
|
@@ -130030,9 +130420,9 @@ async function assertProjectRootReuse(options) {
|
|
|
130030
130420
|
const canonicalize = options.canonicalize ?? realpath2;
|
|
130031
130421
|
let storedCanonical;
|
|
130032
130422
|
try {
|
|
130033
|
-
storedCanonical = await canonicalize(
|
|
130423
|
+
storedCanonical = await canonicalize(path25.resolve(options.storedProjectPath));
|
|
130034
130424
|
} catch {
|
|
130035
|
-
storedCanonical =
|
|
130425
|
+
storedCanonical = path25.resolve(options.storedProjectPath);
|
|
130036
130426
|
}
|
|
130037
130427
|
if (storedCanonical !== options.canonicalProjectPath) {
|
|
130038
130428
|
throw new Error(`Project ID "${options.projectId}" already indexes canonical root ` + `"${storedCanonical}", not "${options.canonicalProjectPath}"; ` + "use forceReindex only after verifying ownership of the existing project");
|
|
@@ -130775,16 +131165,16 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
130775
131165
|
const seen = new Set;
|
|
130776
131166
|
const out = [];
|
|
130777
131167
|
for (const e of httpEdges) {
|
|
130778
|
-
const
|
|
130779
|
-
if (!
|
|
131168
|
+
const path26 = e.route;
|
|
131169
|
+
if (!path26)
|
|
130780
131170
|
continue;
|
|
130781
131171
|
const method = (e.method ?? "ANY").toUpperCase();
|
|
130782
|
-
const key = method + " " +
|
|
131172
|
+
const key = method + " " + path26;
|
|
130783
131173
|
if (seen.has(key))
|
|
130784
131174
|
continue;
|
|
130785
131175
|
seen.add(key);
|
|
130786
131176
|
out.push({
|
|
130787
|
-
path:
|
|
131177
|
+
path: path26,
|
|
130788
131178
|
method: e.method,
|
|
130789
131179
|
file: e.fromFile,
|
|
130790
131180
|
handler: e.targetFqn ?? e.symbolName
|
|
@@ -130795,12 +131185,12 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
130795
131185
|
continue;
|
|
130796
131186
|
const parsed = parseRouteName(d.name);
|
|
130797
131187
|
const method = parsed?.method ?? "ANY";
|
|
130798
|
-
const
|
|
130799
|
-
const key = method + " " +
|
|
131188
|
+
const path26 = parsed?.path ?? d.name;
|
|
131189
|
+
const key = method + " " + path26;
|
|
130800
131190
|
if (seen.has(key))
|
|
130801
131191
|
continue;
|
|
130802
131192
|
seen.add(key);
|
|
130803
|
-
out.push({ path:
|
|
131193
|
+
out.push({ path: path26, method: parsed?.method, file: d.filePath, handler: d.name });
|
|
130804
131194
|
}
|
|
130805
131195
|
for (const d of defs) {
|
|
130806
131196
|
const parsed = parseRouteName(d.name);
|
|
@@ -131021,8 +131411,8 @@ __export(exports_symbol_graph_service, {
|
|
|
131021
131411
|
symbolGraphService: () => symbolGraphService,
|
|
131022
131412
|
SymbolGraphService: () => SymbolGraphService
|
|
131023
131413
|
});
|
|
131024
|
-
import
|
|
131025
|
-
import
|
|
131414
|
+
import path26 from "path";
|
|
131415
|
+
import fs15 from "fs/promises";
|
|
131026
131416
|
|
|
131027
131417
|
class SymbolGraphService {
|
|
131028
131418
|
identityLookup;
|
|
@@ -131350,7 +131740,7 @@ class SymbolGraphService {
|
|
|
131350
131740
|
async readSnippet(relativePath, lineStart, lineEnd, projectId) {
|
|
131351
131741
|
try {
|
|
131352
131742
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
131353
|
-
const content = await
|
|
131743
|
+
const content = await fs15.readFile(absolutePath, "utf-8");
|
|
131354
131744
|
const lines = content.split(`
|
|
131355
131745
|
`);
|
|
131356
131746
|
return lines.slice(Math.max(0, lineStart - 1), Math.min(lines.length, lineEnd)).join(`
|
|
@@ -131362,7 +131752,7 @@ class SymbolGraphService {
|
|
|
131362
131752
|
async readContext(relativePath, lineNumber, contextLines, projectId) {
|
|
131363
131753
|
try {
|
|
131364
131754
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
131365
|
-
const content = await
|
|
131755
|
+
const content = await fs15.readFile(absolutePath, "utf-8");
|
|
131366
131756
|
const lines = content.split(`
|
|
131367
131757
|
`);
|
|
131368
131758
|
const start = Math.max(0, lineNumber - contextLines - 1);
|
|
@@ -131375,7 +131765,7 @@ class SymbolGraphService {
|
|
|
131375
131765
|
}
|
|
131376
131766
|
async resolveToAbsolute(relativePath, projectId) {
|
|
131377
131767
|
const root = await this.getProjectRoot(projectId);
|
|
131378
|
-
return root ?
|
|
131768
|
+
return root ? path26.resolve(root, relativePath) : relativePath;
|
|
131379
131769
|
}
|
|
131380
131770
|
async getProjectRoot(projectId) {
|
|
131381
131771
|
const cached2 = this.projectRootCache.get(projectId);
|
|
@@ -131518,7 +131908,7 @@ var init_workspace_manager = __esm(() => {
|
|
|
131518
131908
|
});
|
|
131519
131909
|
|
|
131520
131910
|
// ../../packages/core/dist/tools/index_project.js
|
|
131521
|
-
import
|
|
131911
|
+
import path27 from "path";
|
|
131522
131912
|
|
|
131523
131913
|
class IndexProjectTool {
|
|
131524
131914
|
name = "index_project";
|
|
@@ -131566,7 +131956,7 @@ class IndexProjectTool {
|
|
|
131566
131956
|
try {
|
|
131567
131957
|
await assertParserReadyForIndexing();
|
|
131568
131958
|
const canonicalProjectPath = await canonicalizeProjectRoot(projectPath);
|
|
131569
|
-
const finalProjectId = projectId ||
|
|
131959
|
+
const finalProjectId = projectId || path27.basename(canonicalProjectPath) || "default";
|
|
131570
131960
|
const existing = await workspaceManager.getWorkspace(finalProjectId);
|
|
131571
131961
|
await assertProjectRootReuse({
|
|
131572
131962
|
projectId: finalProjectId,
|
|
@@ -132119,17 +132509,17 @@ function applyReplacer(root, replacer) {
|
|
|
132119
132509
|
return transformChildren(root, replacer, []);
|
|
132120
132510
|
return transformChildren(normalizeValue(replacedRoot), replacer, []);
|
|
132121
132511
|
}
|
|
132122
|
-
function transformChildren(value, replacer,
|
|
132512
|
+
function transformChildren(value, replacer, path28) {
|
|
132123
132513
|
if (isJsonObject(value))
|
|
132124
|
-
return transformObject(value, replacer,
|
|
132514
|
+
return transformObject(value, replacer, path28);
|
|
132125
132515
|
if (isJsonArray(value))
|
|
132126
|
-
return transformArray(value, replacer,
|
|
132516
|
+
return transformArray(value, replacer, path28);
|
|
132127
132517
|
return value;
|
|
132128
132518
|
}
|
|
132129
|
-
function transformObject(obj, replacer,
|
|
132519
|
+
function transformObject(obj, replacer, path28) {
|
|
132130
132520
|
const result = {};
|
|
132131
132521
|
for (const [key, value] of Object.entries(obj)) {
|
|
132132
|
-
const childPath = [...
|
|
132522
|
+
const childPath = [...path28, key];
|
|
132133
132523
|
const replacedValue = replacer(key, value, childPath);
|
|
132134
132524
|
if (replacedValue === undefined)
|
|
132135
132525
|
continue;
|
|
@@ -132137,11 +132527,11 @@ function transformObject(obj, replacer, path26) {
|
|
|
132137
132527
|
}
|
|
132138
132528
|
return result;
|
|
132139
132529
|
}
|
|
132140
|
-
function transformArray(arr, replacer,
|
|
132530
|
+
function transformArray(arr, replacer, path28) {
|
|
132141
132531
|
const result = [];
|
|
132142
132532
|
for (let i = 0;i < arr.length; i++) {
|
|
132143
132533
|
const value = arr[i];
|
|
132144
|
-
const childPath = [...
|
|
132534
|
+
const childPath = [...path28, i];
|
|
132145
132535
|
const replacedValue = replacer(String(i), value, childPath);
|
|
132146
132536
|
if (replacedValue === undefined)
|
|
132147
132537
|
continue;
|
|
@@ -137211,9 +137601,9 @@ var init_session_pin_store = __esm(() => {
|
|
|
137211
137601
|
});
|
|
137212
137602
|
|
|
137213
137603
|
// ../../packages/core/dist/services/hooks/attribution-resolver.js
|
|
137214
|
-
import
|
|
137215
|
-
import
|
|
137216
|
-
import
|
|
137604
|
+
import fs16 from "fs";
|
|
137605
|
+
import os8 from "os";
|
|
137606
|
+
import path28 from "path";
|
|
137217
137607
|
|
|
137218
137608
|
class PgWorkspaceRootProvider {
|
|
137219
137609
|
cache = null;
|
|
@@ -137262,8 +137652,8 @@ class AttributionResolver {
|
|
|
137262
137652
|
this.aliasResolver = options.aliasResolver ?? getProjectIdentityAliasResolver();
|
|
137263
137653
|
this.pins = options.pins ?? new SessionPinStore;
|
|
137264
137654
|
this.canonicalize = options.canonicalize ?? defaultCanonicalize;
|
|
137265
|
-
this.homedir = options.homedir ??
|
|
137266
|
-
this.fsRoot = options.fsRoot ?? (() =>
|
|
137655
|
+
this.homedir = options.homedir ?? os8.homedir;
|
|
137656
|
+
this.fsRoot = options.fsRoot ?? (() => path28.parse(path28.sep).root);
|
|
137267
137657
|
}
|
|
137268
137658
|
async resolve(input) {
|
|
137269
137659
|
const caller = input.callerProjectId;
|
|
@@ -137314,7 +137704,7 @@ class AttributionResolver {
|
|
|
137314
137704
|
}
|
|
137315
137705
|
let bestPath = null;
|
|
137316
137706
|
for (const candidate2 of byPath.keys()) {
|
|
137317
|
-
if (canonicalCwd === candidate2 || canonicalCwd.startsWith(candidate2.endsWith(
|
|
137707
|
+
if (canonicalCwd === candidate2 || canonicalCwd.startsWith(candidate2.endsWith(path28.sep) ? candidate2 : candidate2 + path28.sep)) {
|
|
137318
137708
|
if (bestPath === null || candidate2.length > bestPath.length) {
|
|
137319
137709
|
bestPath = candidate2;
|
|
137320
137710
|
}
|
|
@@ -137337,7 +137727,7 @@ class AttributionResolver {
|
|
|
137337
137727
|
return projectPath2;
|
|
137338
137728
|
const fsRoot = this.fsRoot();
|
|
137339
137729
|
let normalized = projectPath2;
|
|
137340
|
-
while (normalized.length > fsRoot.length && normalized.endsWith(
|
|
137730
|
+
while (normalized.length > fsRoot.length && normalized.endsWith(path28.sep)) {
|
|
137341
137731
|
normalized = normalized.slice(0, -1);
|
|
137342
137732
|
}
|
|
137343
137733
|
return normalized;
|
|
@@ -137345,10 +137735,10 @@ class AttributionResolver {
|
|
|
137345
137735
|
}
|
|
137346
137736
|
function defaultCanonicalize(cwd) {
|
|
137347
137737
|
try {
|
|
137348
|
-
return
|
|
137738
|
+
return fs16.realpathSync(cwd);
|
|
137349
137739
|
} catch {
|
|
137350
137740
|
try {
|
|
137351
|
-
return
|
|
137741
|
+
return path28.resolve(cwd);
|
|
137352
137742
|
} catch {
|
|
137353
137743
|
return;
|
|
137354
137744
|
}
|
|
@@ -138096,31 +138486,31 @@ class TracePathService {
|
|
|
138096
138486
|
const chains = [];
|
|
138097
138487
|
const seen = new Set;
|
|
138098
138488
|
let walks = 0;
|
|
138099
|
-
const walk = (fqn,
|
|
138489
|
+
const walk = (fqn, path29) => {
|
|
138100
138490
|
if (chains.length >= CHAIN_CAP)
|
|
138101
138491
|
return;
|
|
138102
138492
|
if (walks >= MAX_WALKS)
|
|
138103
138493
|
return;
|
|
138104
138494
|
walks++;
|
|
138105
|
-
const key =
|
|
138495
|
+
const key = path29.join("\u2192");
|
|
138106
138496
|
if (seen.has(key))
|
|
138107
138497
|
return;
|
|
138108
138498
|
seen.add(key);
|
|
138109
138499
|
const next = adj.get(fqn);
|
|
138110
138500
|
if (!next || next.length === 0 || !whoHasChild.has(fqn)) {
|
|
138111
|
-
if (
|
|
138112
|
-
chains.push(
|
|
138501
|
+
if (path29.length > 1)
|
|
138502
|
+
chains.push(path29.map((n) => this.fqnToName(n)).join(" \u2192 "));
|
|
138113
138503
|
return;
|
|
138114
138504
|
}
|
|
138115
138505
|
for (const child of next) {
|
|
138116
138506
|
if (chains.length >= CHAIN_CAP || walks >= MAX_WALKS)
|
|
138117
138507
|
return;
|
|
138118
|
-
if (
|
|
138119
|
-
const cycled = [...
|
|
138508
|
+
if (path29.includes(child)) {
|
|
138509
|
+
const cycled = [...path29, `${this.fqnToName(child)}\u21BA`];
|
|
138120
138510
|
chains.push(cycled.map((n) => n).join(" \u2192 "));
|
|
138121
138511
|
continue;
|
|
138122
138512
|
}
|
|
138123
|
-
walk(child, [...
|
|
138513
|
+
walk(child, [...path29, child]);
|
|
138124
138514
|
}
|
|
138125
138515
|
};
|
|
138126
138516
|
for (const seed of seeds) {
|
|
@@ -138953,7 +139343,7 @@ var init_get_architecture = __esm(() => {
|
|
|
138953
139343
|
});
|
|
138954
139344
|
|
|
138955
139345
|
// ../../packages/core/dist/services/file-read/file-content-cache.js
|
|
138956
|
-
import
|
|
139346
|
+
import fs17 from "fs/promises";
|
|
138957
139347
|
|
|
138958
139348
|
class FileContentCache {
|
|
138959
139349
|
extractMetadata;
|
|
@@ -138986,7 +139376,7 @@ class FileContentCache {
|
|
|
138986
139376
|
metadata: cached2.metadata
|
|
138987
139377
|
};
|
|
138988
139378
|
}
|
|
138989
|
-
const content = await
|
|
139379
|
+
const content = await fs17.readFile(filePath, "utf-8");
|
|
138990
139380
|
const metadata = await this.extractMetadata(content, filePath, options);
|
|
138991
139381
|
evictOldest(this.fileCache, this.FILE_CACHE_MAX_ENTRIES - 1);
|
|
138992
139382
|
this.fileCache.set(cacheKey, {
|
|
@@ -139003,7 +139393,7 @@ var init_file_content_cache = __esm(() => {
|
|
|
139003
139393
|
});
|
|
139004
139394
|
|
|
139005
139395
|
// ../../packages/core/dist/services/file-read/file-metadata.js
|
|
139006
|
-
import
|
|
139396
|
+
import path29 from "path";
|
|
139007
139397
|
|
|
139008
139398
|
class FileMetadataExtractor {
|
|
139009
139399
|
symbolGraph;
|
|
@@ -139039,7 +139429,7 @@ class FileMetadataExtractor {
|
|
|
139039
139429
|
return metadata;
|
|
139040
139430
|
}
|
|
139041
139431
|
detectLanguage(filePath) {
|
|
139042
|
-
const ext2 =
|
|
139432
|
+
const ext2 = path29.extname(filePath).toLowerCase();
|
|
139043
139433
|
const languageMap2 = {
|
|
139044
139434
|
".ts": "TypeScript",
|
|
139045
139435
|
".tsx": "TypeScript",
|
|
@@ -139161,7 +139551,7 @@ var init_line_range = __esm(() => {
|
|
|
139161
139551
|
});
|
|
139162
139552
|
|
|
139163
139553
|
// ../../packages/core/dist/services/file-read/path-containment.js
|
|
139164
|
-
import
|
|
139554
|
+
import path30 from "path";
|
|
139165
139555
|
|
|
139166
139556
|
class PathContainment {
|
|
139167
139557
|
projectRoots;
|
|
@@ -139169,14 +139559,14 @@ class PathContainment {
|
|
|
139169
139559
|
this.projectRoots = projectRoots;
|
|
139170
139560
|
}
|
|
139171
139561
|
async resolveFilePath(filePath, projectId) {
|
|
139172
|
-
if (
|
|
139173
|
-
return
|
|
139562
|
+
if (path30.isAbsolute(filePath)) {
|
|
139563
|
+
return path30.resolve(filePath);
|
|
139174
139564
|
}
|
|
139175
139565
|
if (projectId) {
|
|
139176
139566
|
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
139177
139567
|
if (root) {
|
|
139178
139568
|
const cleaned = sanitizeFilePath(filePath);
|
|
139179
|
-
return
|
|
139569
|
+
return path30.resolve(root, cleaned);
|
|
139180
139570
|
}
|
|
139181
139571
|
return null;
|
|
139182
139572
|
}
|
|
@@ -139187,17 +139577,17 @@ class PathContainment {
|
|
|
139187
139577
|
if (projectId) {
|
|
139188
139578
|
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
139189
139579
|
if (root)
|
|
139190
|
-
roots.push(
|
|
139580
|
+
roots.push(path30.resolve(root));
|
|
139191
139581
|
}
|
|
139192
|
-
roots.push(
|
|
139582
|
+
roots.push(path30.resolve(process.cwd()));
|
|
139193
139583
|
const envRoots = (process.env.MASSA_AI_READ_FILE_ROOTS ?? "").split(":").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
139194
139584
|
for (const extra of envRoots) {
|
|
139195
|
-
roots.push(
|
|
139585
|
+
roots.push(path30.resolve(extra));
|
|
139196
139586
|
}
|
|
139197
|
-
const target =
|
|
139587
|
+
const target = path30.resolve(absoluteFilePath);
|
|
139198
139588
|
for (const root of roots) {
|
|
139199
|
-
const rel =
|
|
139200
|
-
if (rel !== "" && !rel.startsWith("..") && !
|
|
139589
|
+
const rel = path30.relative(root, target);
|
|
139590
|
+
if (rel !== "" && !rel.startsWith("..") && !path30.isAbsolute(rel)) {
|
|
139201
139591
|
return { allowed: true };
|
|
139202
139592
|
}
|
|
139203
139593
|
if (rel === "")
|
|
@@ -142411,9 +142801,9 @@ var init_l1_memory_cache = __esm(() => {
|
|
|
142411
142801
|
});
|
|
142412
142802
|
|
|
142413
142803
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
142414
|
-
import
|
|
142804
|
+
import fs18 from "fs/promises";
|
|
142415
142805
|
import { existsSync as existsSync3 } from "fs";
|
|
142416
|
-
import
|
|
142806
|
+
import path31 from "path";
|
|
142417
142807
|
|
|
142418
142808
|
class LocalHealthChecker {
|
|
142419
142809
|
ollamaBaseUrl = process.env.OLLAMA_BASE_URL || "http://localhost:11434";
|
|
@@ -142447,10 +142837,10 @@ class LocalHealthChecker {
|
|
|
142447
142837
|
const start = Date.now();
|
|
142448
142838
|
try {
|
|
142449
142839
|
if (!existsSync3(this.dataDir))
|
|
142450
|
-
await
|
|
142451
|
-
const probe2 =
|
|
142452
|
-
await
|
|
142453
|
-
await
|
|
142840
|
+
await fs18.mkdir(this.dataDir, { recursive: true });
|
|
142841
|
+
const probe2 = path31.join(this.dataDir, ".health-check-test");
|
|
142842
|
+
await fs18.writeFile(probe2, "ok");
|
|
142843
|
+
await fs18.unlink(probe2);
|
|
142454
142844
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
142455
142845
|
} catch (error51) {
|
|
142456
142846
|
return { available: false, latency: Date.now() - start, error: `Data directory error: ${error51.message}` };
|
|
@@ -142846,10 +143236,18 @@ var init_scheduler_store_factory = __esm(() => {
|
|
|
142846
143236
|
});
|
|
142847
143237
|
|
|
142848
143238
|
// ../../packages/core/dist/services/scheduler/scheduler.js
|
|
142849
|
-
function
|
|
143239
|
+
function readEnabledEnv() {
|
|
142850
143240
|
const raw2 = process.env.MASSA_AI_SCHEDULER_ENABLED;
|
|
143241
|
+
if (raw2 === undefined)
|
|
143242
|
+
return;
|
|
142851
143243
|
return raw2 === "true" || raw2 === "1";
|
|
142852
143244
|
}
|
|
143245
|
+
function envPositiveInt(raw2) {
|
|
143246
|
+
if (raw2 === undefined || raw2 === "")
|
|
143247
|
+
return;
|
|
143248
|
+
const parsed = parsePositiveIntEnv(raw2, NaN);
|
|
143249
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
143250
|
+
}
|
|
142853
143251
|
|
|
142854
143252
|
class Scheduler {
|
|
142855
143253
|
store;
|
|
@@ -142863,9 +143261,10 @@ class Scheduler {
|
|
|
142863
143261
|
started = false;
|
|
142864
143262
|
constructor(opts = {}) {
|
|
142865
143263
|
this.store = opts.store ?? getScheduledJobStore();
|
|
142866
|
-
|
|
142867
|
-
this.
|
|
142868
|
-
this.
|
|
143264
|
+
const schedulerConfig = config2.get("scheduler");
|
|
143265
|
+
this.tickIntervalMs = opts.tickIntervalMs ?? envPositiveInt(process.env.MASSA_AI_SCHEDULER_TICK_MS) ?? schedulerConfig?.tickMs ?? DEFAULTS.tickMs;
|
|
143266
|
+
this.maxConcurrent = opts.maxConcurrent ?? envPositiveInt(process.env.MASSA_AI_SCHEDULER_MAX_CONCURRENT) ?? schedulerConfig?.maxConcurrent ?? DEFAULTS.maxConcurrent;
|
|
143267
|
+
this.enabled = opts.enabled ?? readEnabledEnv() ?? schedulerConfig?.enabled ?? false;
|
|
142869
143268
|
}
|
|
142870
143269
|
registerHandler(jobKind, handler) {
|
|
142871
143270
|
this.handlers.set(jobKind, handler);
|
|
@@ -144258,21 +144657,31 @@ var init_observation_consolidation_job = __esm(() => {
|
|
|
144258
144657
|
});
|
|
144259
144658
|
|
|
144260
144659
|
// ../../packages/core/dist/services/scheduler/scheduler-defaults.js
|
|
144261
|
-
function envBool2(key, fallback) {
|
|
144660
|
+
function envBool2(key, fileValue, fallback) {
|
|
144262
144661
|
const raw2 = process.env[key];
|
|
144263
144662
|
if (raw2 === undefined)
|
|
144264
|
-
return fallback;
|
|
144663
|
+
return fileValue ?? fallback;
|
|
144265
144664
|
return raw2 === "true" || raw2 === "1";
|
|
144266
144665
|
}
|
|
144267
|
-
function envNum2(key, fallback) {
|
|
144666
|
+
function envNum2(key, fileValue, fallback) {
|
|
144268
144667
|
const raw2 = process.env[key];
|
|
144269
|
-
if (raw2
|
|
144270
|
-
|
|
144271
|
-
|
|
144272
|
-
|
|
144668
|
+
if (raw2 !== undefined && raw2 !== "") {
|
|
144669
|
+
const n = Number(raw2);
|
|
144670
|
+
if (Number.isFinite(n) && n > 0)
|
|
144671
|
+
return n;
|
|
144672
|
+
}
|
|
144673
|
+
return fileValue ?? fallback;
|
|
144674
|
+
}
|
|
144675
|
+
function readFileSchedulerJobs() {
|
|
144676
|
+
try {
|
|
144677
|
+
const raw2 = loadConfigSafe().scheduler?.jobs;
|
|
144678
|
+
return raw2;
|
|
144679
|
+
} catch {
|
|
144680
|
+
return;
|
|
144681
|
+
}
|
|
144273
144682
|
}
|
|
144274
144683
|
function applySafeDefaults(job) {
|
|
144275
|
-
if (!envBool2("MASSA_AI_SCHEDULER_SAFE_DEFAULTS", false)) {
|
|
144684
|
+
if (!envBool2("MASSA_AI_SCHEDULER_SAFE_DEFAULTS", undefined, false)) {
|
|
144276
144685
|
return job;
|
|
144277
144686
|
}
|
|
144278
144687
|
if (job.jobKind === "memory-consolidation") {
|
|
@@ -144319,10 +144728,12 @@ function registerDefaultJobs(scheduler) {
|
|
|
144319
144728
|
const count = CheckpointManager2.getInstance().purgeExpired();
|
|
144320
144729
|
logger.info("Scheduled checkpoint purge completed", { count });
|
|
144321
144730
|
});
|
|
144731
|
+
const fileJobs = readFileSchedulerJobs();
|
|
144322
144732
|
for (const rawDef of DEFAULT_SCHEDULED_JOBS) {
|
|
144323
144733
|
const def = applySafeDefaults(rawDef);
|
|
144324
|
-
const
|
|
144325
|
-
const
|
|
144734
|
+
const fileJob = fileJobs?.[def.jobKind];
|
|
144735
|
+
const enabled2 = envBool2(def.enableEnvVar, fileJob?.enabled, def.defaultEnabled);
|
|
144736
|
+
const intervalMs = envNum2(def.intervalEnvVar, fileJob?.intervalMs, def.schedule.intervalMs ?? THIRTY_MIN);
|
|
144326
144737
|
const schedule = { type: "interval", intervalMs };
|
|
144327
144738
|
scheduler.registerOrResumeJob({
|
|
144328
144739
|
id: def.id,
|
|
@@ -144403,9 +144814,9 @@ var init_scheduler2 = __esm(() => {
|
|
|
144403
144814
|
});
|
|
144404
144815
|
|
|
144405
144816
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
144406
|
-
import
|
|
144817
|
+
import fs19 from "fs/promises";
|
|
144407
144818
|
import { existsSync as existsSync4 } from "fs";
|
|
144408
|
-
import
|
|
144819
|
+
import path32 from "path";
|
|
144409
144820
|
function getModelsDevClient() {
|
|
144410
144821
|
if (!clientInstance) {
|
|
144411
144822
|
clientInstance = new ModelsDevClient;
|
|
@@ -144425,7 +144836,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
144425
144836
|
memoryCacheTimestamp = 0;
|
|
144426
144837
|
getLocalCachePath() {
|
|
144427
144838
|
const dataDir = config2.get("dataDir");
|
|
144428
|
-
return
|
|
144839
|
+
return path32.join(dataDir, ModelsDevClient.LOCAL_CACHE_FILE);
|
|
144429
144840
|
}
|
|
144430
144841
|
async loadLocalCache() {
|
|
144431
144842
|
const cachePath = this.getLocalCachePath();
|
|
@@ -144433,7 +144844,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
144433
144844
|
if (!existsSync4(cachePath)) {
|
|
144434
144845
|
return null;
|
|
144435
144846
|
}
|
|
144436
|
-
const content = await
|
|
144847
|
+
const content = await fs19.readFile(cachePath, "utf-8");
|
|
144437
144848
|
const data = JSON.parse(content);
|
|
144438
144849
|
const age = Date.now() - data.timestamp;
|
|
144439
144850
|
if (age > ModelsDevClient.LOCAL_CACHE_TTL) {
|
|
@@ -144460,14 +144871,14 @@ var init_models_dev_client = __esm(() => {
|
|
|
144460
144871
|
async saveLocalCache(models) {
|
|
144461
144872
|
const cachePath = this.getLocalCachePath();
|
|
144462
144873
|
try {
|
|
144463
|
-
const dir =
|
|
144464
|
-
await
|
|
144874
|
+
const dir = path32.dirname(cachePath);
|
|
144875
|
+
await fs19.mkdir(dir, { recursive: true });
|
|
144465
144876
|
const data = {
|
|
144466
144877
|
timestamp: Date.now(),
|
|
144467
144878
|
version: "1.0.0",
|
|
144468
144879
|
models: Object.fromEntries(models)
|
|
144469
144880
|
};
|
|
144470
|
-
await
|
|
144881
|
+
await fs19.writeFile(cachePath, JSON.stringify(data), "utf-8");
|
|
144471
144882
|
logger.debug("Saved pricing to local cache", {
|
|
144472
144883
|
models: models.size,
|
|
144473
144884
|
path: cachePath
|
|
@@ -144796,7 +145207,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
144796
145207
|
const cachePath = this.getLocalCachePath();
|
|
144797
145208
|
try {
|
|
144798
145209
|
if (existsSync4(cachePath)) {
|
|
144799
|
-
await
|
|
145210
|
+
await fs19.unlink(cachePath);
|
|
144800
145211
|
logger.debug("Local pricing cache file deleted");
|
|
144801
145212
|
}
|
|
144802
145213
|
} catch (error51) {
|
|
@@ -150351,33 +150762,33 @@ var require_URL = __commonJS((exports, module) => {
|
|
|
150351
150762
|
else
|
|
150352
150763
|
return basepath.substring(0, lastslash + 1) + refpath;
|
|
150353
150764
|
}
|
|
150354
|
-
function remove_dot_segments(
|
|
150355
|
-
if (!
|
|
150356
|
-
return
|
|
150765
|
+
function remove_dot_segments(path33) {
|
|
150766
|
+
if (!path33)
|
|
150767
|
+
return path33;
|
|
150357
150768
|
var output = "";
|
|
150358
|
-
while (
|
|
150359
|
-
if (
|
|
150360
|
-
|
|
150769
|
+
while (path33.length > 0) {
|
|
150770
|
+
if (path33 === "." || path33 === "..") {
|
|
150771
|
+
path33 = "";
|
|
150361
150772
|
break;
|
|
150362
150773
|
}
|
|
150363
|
-
var twochars =
|
|
150364
|
-
var threechars =
|
|
150365
|
-
var fourchars =
|
|
150774
|
+
var twochars = path33.substring(0, 2);
|
|
150775
|
+
var threechars = path33.substring(0, 3);
|
|
150776
|
+
var fourchars = path33.substring(0, 4);
|
|
150366
150777
|
if (threechars === "../") {
|
|
150367
|
-
|
|
150778
|
+
path33 = path33.substring(3);
|
|
150368
150779
|
} else if (twochars === "./") {
|
|
150369
|
-
|
|
150780
|
+
path33 = path33.substring(2);
|
|
150370
150781
|
} else if (threechars === "/./") {
|
|
150371
|
-
|
|
150372
|
-
} else if (twochars === "/." &&
|
|
150373
|
-
|
|
150374
|
-
} else if (fourchars === "/../" || threechars === "/.." &&
|
|
150375
|
-
|
|
150782
|
+
path33 = "/" + path33.substring(3);
|
|
150783
|
+
} else if (twochars === "/." && path33.length === 2) {
|
|
150784
|
+
path33 = "/";
|
|
150785
|
+
} else if (fourchars === "/../" || threechars === "/.." && path33.length === 3) {
|
|
150786
|
+
path33 = "/" + path33.substring(4);
|
|
150376
150787
|
output = output.replace(/\/?[^\/]*$/, "");
|
|
150377
150788
|
} else {
|
|
150378
|
-
var segment =
|
|
150789
|
+
var segment = path33.match(/(\/?([^\/]*))/)[0];
|
|
150379
150790
|
output += segment;
|
|
150380
|
-
|
|
150791
|
+
path33 = path33.substring(segment.length);
|
|
150381
150792
|
}
|
|
150382
150793
|
}
|
|
150383
150794
|
return output;
|
|
@@ -162447,21 +162858,21 @@ function jsonToKeyPathChunks(value, label = "$") {
|
|
|
162447
162858
|
walk(value, label, out);
|
|
162448
162859
|
return out;
|
|
162449
162860
|
}
|
|
162450
|
-
function walk(val,
|
|
162861
|
+
function walk(val, path33, out) {
|
|
162451
162862
|
if (val === null || val === undefined)
|
|
162452
162863
|
return;
|
|
162453
162864
|
if (Array.isArray(val)) {
|
|
162454
162865
|
if (val.length === 0) {
|
|
162455
|
-
out.push({ path:
|
|
162866
|
+
out.push({ path: path33, content: `**${path33}** = _[]_` });
|
|
162456
162867
|
return;
|
|
162457
162868
|
}
|
|
162458
162869
|
if (val.every((v) => v !== null && typeof v === "object")) {
|
|
162459
|
-
val.forEach((v, i) => walk(v, `${
|
|
162870
|
+
val.forEach((v, i) => walk(v, `${path33}[${i}]`, out));
|
|
162460
162871
|
return;
|
|
162461
162872
|
}
|
|
162462
162873
|
const items = val.map((v) => `- \`${String(v)}\``).join(`
|
|
162463
162874
|
`);
|
|
162464
|
-
out.push({ path:
|
|
162875
|
+
out.push({ path: path33, content: `**${path33}**
|
|
162465
162876
|
|
|
162466
162877
|
${items}` });
|
|
162467
162878
|
return;
|
|
@@ -162469,16 +162880,16 @@ ${items}` });
|
|
|
162469
162880
|
if (typeof val === "object") {
|
|
162470
162881
|
const entries = Object.entries(val);
|
|
162471
162882
|
if (entries.length === 0) {
|
|
162472
|
-
out.push({ path:
|
|
162883
|
+
out.push({ path: path33, content: `**${path33}** = _{}_` });
|
|
162473
162884
|
return;
|
|
162474
162885
|
}
|
|
162475
162886
|
for (const [k, v] of entries) {
|
|
162476
162887
|
const safeKey = /^[A-Za-z_$][\w$]*$/.test(k) ? k : JSON.stringify(k);
|
|
162477
|
-
walk(v, `${
|
|
162888
|
+
walk(v, `${path33}.${safeKey}`, out);
|
|
162478
162889
|
}
|
|
162479
162890
|
return;
|
|
162480
162891
|
}
|
|
162481
|
-
out.push({ path:
|
|
162892
|
+
out.push({ path: path33, content: `**${path33}** = \`${String(val)}\`` });
|
|
162482
162893
|
}
|
|
162483
162894
|
var gfm, STRIP_SELECTORS, tdCache = null;
|
|
162484
162895
|
var init_html_to_md = __esm(() => {
|
|
@@ -163241,8 +163652,8 @@ var init_hook_service = __esm(() => {
|
|
|
163241
163652
|
|
|
163242
163653
|
// ../../packages/core/dist/services/bootstrap/bootstrap-service.js
|
|
163243
163654
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
163244
|
-
import
|
|
163245
|
-
import
|
|
163655
|
+
import fs20 from "fs";
|
|
163656
|
+
import path33 from "path";
|
|
163246
163657
|
import { spawn as spawn2 } from "child_process";
|
|
163247
163658
|
function readBootstrapConfig() {
|
|
163248
163659
|
try {
|
|
@@ -163402,9 +163813,9 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
163402
163813
|
}
|
|
163403
163814
|
try {
|
|
163404
163815
|
for (const name26 of README_CANDIDATES) {
|
|
163405
|
-
const p =
|
|
163406
|
-
if (
|
|
163407
|
-
const buf =
|
|
163816
|
+
const p = path33.join(projectRoot, name26);
|
|
163817
|
+
if (fs20.existsSync(p) && fs20.statSync(p).isFile()) {
|
|
163818
|
+
const buf = fs20.readFileSync(p);
|
|
163408
163819
|
signals.readme = buf.slice(0, MAX_README_BYTES).toString("utf8");
|
|
163409
163820
|
break;
|
|
163410
163821
|
}
|
|
@@ -163413,14 +163824,14 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
163413
163824
|
logger.debug("bootstrap scan: README read failed", { error: e.message });
|
|
163414
163825
|
}
|
|
163415
163826
|
try {
|
|
163416
|
-
const docsDir =
|
|
163417
|
-
if (
|
|
163827
|
+
const docsDir = path33.join(projectRoot, "docs");
|
|
163828
|
+
if (fs20.existsSync(docsDir) && fs20.statSync(docsDir).isDirectory()) {
|
|
163418
163829
|
const entries = walkMarkdown(docsDir).slice(0, MAX_DOCS);
|
|
163419
163830
|
for (const rel of entries) {
|
|
163420
163831
|
try {
|
|
163421
|
-
const buf =
|
|
163832
|
+
const buf = fs20.readFileSync(rel);
|
|
163422
163833
|
signals.docs.push({
|
|
163423
|
-
path:
|
|
163834
|
+
path: path33.relative(projectRoot, rel),
|
|
163424
163835
|
snippet: buf.slice(0, MAX_DOC_BYTES).toString("utf8")
|
|
163425
163836
|
});
|
|
163426
163837
|
} catch {}
|
|
@@ -163431,10 +163842,10 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
163431
163842
|
}
|
|
163432
163843
|
try {
|
|
163433
163844
|
for (const name26 of MANIFEST_FILES) {
|
|
163434
|
-
const p =
|
|
163435
|
-
if (!
|
|
163845
|
+
const p = path33.join(projectRoot, name26);
|
|
163846
|
+
if (!fs20.existsSync(p) || !fs20.statSync(p).isFile())
|
|
163436
163847
|
continue;
|
|
163437
|
-
const raw2 =
|
|
163848
|
+
const raw2 = fs20.readFileSync(p).slice(0, MAX_MANIFEST_BYTES).toString("utf8");
|
|
163438
163849
|
const kind = name26;
|
|
163439
163850
|
if (name26 === "package.json") {
|
|
163440
163851
|
try {
|
|
@@ -163474,12 +163885,12 @@ function walkMarkdown(dir) {
|
|
|
163474
163885
|
const cur = stack.pop();
|
|
163475
163886
|
let entries;
|
|
163476
163887
|
try {
|
|
163477
|
-
entries =
|
|
163888
|
+
entries = fs20.readdirSync(cur, { withFileTypes: true });
|
|
163478
163889
|
} catch {
|
|
163479
163890
|
continue;
|
|
163480
163891
|
}
|
|
163481
163892
|
for (const e of entries) {
|
|
163482
|
-
const full =
|
|
163893
|
+
const full = path33.join(cur, e.name);
|
|
163483
163894
|
if (e.isDirectory()) {
|
|
163484
163895
|
if (e.name === "node_modules" || e.name.startsWith("."))
|
|
163485
163896
|
continue;
|
|
@@ -166891,7 +167302,7 @@ class StdioServerTransport {
|
|
|
166891
167302
|
}
|
|
166892
167303
|
|
|
166893
167304
|
// src/index.ts
|
|
166894
|
-
import
|
|
167305
|
+
import fs23 from "fs/promises";
|
|
166895
167306
|
|
|
166896
167307
|
// src/api-client.ts
|
|
166897
167308
|
init_config();
|
|
@@ -167001,8 +167412,8 @@ init_dist();
|
|
|
167001
167412
|
init_dist();
|
|
167002
167413
|
init_dist15();
|
|
167003
167414
|
init_dist();
|
|
167004
|
-
import
|
|
167005
|
-
import
|
|
167415
|
+
import fs21 from "fs/promises";
|
|
167416
|
+
import path34 from "path";
|
|
167006
167417
|
var _indexProjectTool = null;
|
|
167007
167418
|
function indexProjectTool() {
|
|
167008
167419
|
if (!_indexProjectTool)
|
|
@@ -167285,8 +167696,8 @@ class EmbeddedApiClient {
|
|
|
167285
167696
|
} else {
|
|
167286
167697
|
end = start + 20;
|
|
167287
167698
|
}
|
|
167288
|
-
const absolutePath =
|
|
167289
|
-
const content = await
|
|
167699
|
+
const absolutePath = path34.join(workspace.project_path, file2);
|
|
167700
|
+
const content = await fs21.readFile(absolutePath, "utf-8");
|
|
167290
167701
|
const lines = content.split(/\r?\n/);
|
|
167291
167702
|
const slice = lines.slice(start - 1, Math.min(lines.length, end));
|
|
167292
167703
|
const formatted = slice.map((text3, idx) => ({ lineNumber: start + idx, content: text3 }));
|
|
@@ -167523,22 +167934,22 @@ class EmbeddedApiClient {
|
|
|
167523
167934
|
async uploadAndIndex(params) {
|
|
167524
167935
|
const rawBase = params.projectId || params.projectPath.replace(/\\/g, "/").split("/").filter(Boolean).pop() || "default";
|
|
167525
167936
|
const finalProjectId = rawBase.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 128);
|
|
167526
|
-
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR ||
|
|
167527
|
-
const stagingDir =
|
|
167528
|
-
await
|
|
167529
|
-
await
|
|
167937
|
+
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR || path34.join(getGlobalDataDir(), "uploads");
|
|
167938
|
+
const stagingDir = path34.resolve(uploadRoot, finalProjectId);
|
|
167939
|
+
await fs21.rm(stagingDir, { recursive: true, force: true });
|
|
167940
|
+
await fs21.mkdir(stagingDir, { recursive: true });
|
|
167530
167941
|
const WRITE_BATCH = 20;
|
|
167531
167942
|
for (let i = 0;i < params.files.length; i += WRITE_BATCH) {
|
|
167532
167943
|
await Promise.all(params.files.slice(i, i + WRITE_BATCH).map(async (file2) => {
|
|
167533
|
-
if (
|
|
167944
|
+
if (path34.isAbsolute(file2.relativePath) || file2.relativePath.includes("..")) {
|
|
167534
167945
|
throw new Error(`Invalid file path: ${file2.relativePath}`);
|
|
167535
167946
|
}
|
|
167536
|
-
const dest =
|
|
167537
|
-
if (!dest.startsWith(stagingDir +
|
|
167947
|
+
const dest = path34.resolve(stagingDir, file2.relativePath.replace(/\//g, path34.sep));
|
|
167948
|
+
if (!dest.startsWith(stagingDir + path34.sep)) {
|
|
167538
167949
|
throw new Error(`Path escapes staging directory: ${file2.relativePath}`);
|
|
167539
167950
|
}
|
|
167540
|
-
await
|
|
167541
|
-
await
|
|
167951
|
+
await fs21.mkdir(path34.dirname(dest), { recursive: true });
|
|
167952
|
+
await fs21.writeFile(dest, file2.content, "utf-8");
|
|
167542
167953
|
}));
|
|
167543
167954
|
}
|
|
167544
167955
|
return await indexProjectTool().handle({
|
|
@@ -167882,8 +168293,8 @@ class EmbeddedApiClient {
|
|
|
167882
168293
|
|
|
167883
168294
|
// src/file-collector.ts
|
|
167884
168295
|
init_config();
|
|
167885
|
-
import
|
|
167886
|
-
import
|
|
168296
|
+
import fs22 from "fs/promises";
|
|
168297
|
+
import path35 from "path";
|
|
167887
168298
|
var SKIP_DIRS = new Set([
|
|
167888
168299
|
"node_modules",
|
|
167889
168300
|
".git",
|
|
@@ -167924,7 +168335,7 @@ async function walk2(root2, dir, files, state, allowed) {
|
|
|
167924
168335
|
return;
|
|
167925
168336
|
let entries;
|
|
167926
168337
|
try {
|
|
167927
|
-
entries = await
|
|
168338
|
+
entries = await fs22.readdir(dir, { withFileTypes: true });
|
|
167928
168339
|
} catch {
|
|
167929
168340
|
return;
|
|
167930
168341
|
}
|
|
@@ -167933,22 +168344,22 @@ async function walk2(root2, dir, files, state, allowed) {
|
|
|
167933
168344
|
break;
|
|
167934
168345
|
if (entry2.isDirectory()) {
|
|
167935
168346
|
if (!SKIP_DIRS.has(entry2.name) && !entry2.name.startsWith(".")) {
|
|
167936
|
-
await walk2(root2,
|
|
168347
|
+
await walk2(root2, path35.join(dir, entry2.name), files, state, allowed);
|
|
167937
168348
|
}
|
|
167938
168349
|
} else if (entry2.isFile()) {
|
|
167939
|
-
const ext2 =
|
|
168350
|
+
const ext2 = path35.extname(entry2.name).toLowerCase();
|
|
167940
168351
|
if (!allowed.has(ext2))
|
|
167941
168352
|
continue;
|
|
167942
|
-
const fullPath =
|
|
168353
|
+
const fullPath = path35.join(dir, entry2.name);
|
|
167943
168354
|
try {
|
|
167944
|
-
const stat = await
|
|
168355
|
+
const stat = await fs22.stat(fullPath);
|
|
167945
168356
|
if (stat.size > MAX_FILE_BYTES)
|
|
167946
168357
|
continue;
|
|
167947
168358
|
if (state.totalBytes + stat.size > MAX_TOTAL_BYTES)
|
|
167948
168359
|
continue;
|
|
167949
|
-
const content = await
|
|
168360
|
+
const content = await fs22.readFile(fullPath, "utf-8");
|
|
167950
168361
|
state.totalBytes += stat.size;
|
|
167951
|
-
const relativePath =
|
|
168362
|
+
const relativePath = path35.relative(root2, fullPath).split(path35.sep).join("/");
|
|
167952
168363
|
files.push({ relativePath, content });
|
|
167953
168364
|
} catch {}
|
|
167954
168365
|
}
|
|
@@ -169849,7 +170260,7 @@ class McpProxyServer {
|
|
|
169849
170260
|
return textContent(JSON.stringify({ success: false, error: "projectPath is required" }));
|
|
169850
170261
|
}
|
|
169851
170262
|
try {
|
|
169852
|
-
if (!(await
|
|
170263
|
+
if (!(await fs23.stat(projectPath2)).isDirectory()) {
|
|
169853
170264
|
return textContent(JSON.stringify({ success: false, error: `${projectPath2} is not a directory` }));
|
|
169854
170265
|
}
|
|
169855
170266
|
} catch {
|