@massa-ai/mcp-client 1.45.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 +837 -426
- package/dist/index.js +885 -474
- package/package.json +3 -3
package/dist/config-cli.js
CHANGED
|
@@ -401,9 +401,16 @@ var init_xdg = () => {};
|
|
|
401
401
|
|
|
402
402
|
// ../../packages/shared/dist/config/massa-ai-config.js
|
|
403
403
|
import path2 from "path";
|
|
404
|
-
var defaultMassaAiConfig;
|
|
404
|
+
var SCHEDULER_JOB_KINDS, defaultMassaAiConfig;
|
|
405
405
|
var init_massa_ai_config = __esm(() => {
|
|
406
406
|
init_xdg();
|
|
407
|
+
SCHEDULER_JOB_KINDS = [
|
|
408
|
+
"memory-consolidation",
|
|
409
|
+
"decay-sweep",
|
|
410
|
+
"auto-improve",
|
|
411
|
+
"observation-bridge",
|
|
412
|
+
"checkpoint-purge"
|
|
413
|
+
];
|
|
407
414
|
defaultMassaAiConfig = {
|
|
408
415
|
database: {
|
|
409
416
|
url: ""
|
|
@@ -737,6 +744,7 @@ var init_env = __esm(() => {
|
|
|
737
744
|
// ../../packages/shared/dist/config/config-writer.js
|
|
738
745
|
var init_config_writer = __esm(() => {
|
|
739
746
|
init_config_loader();
|
|
747
|
+
init_massa_ai_config();
|
|
740
748
|
});
|
|
741
749
|
|
|
742
750
|
// ../../packages/shared/dist/config/api-key.js
|
|
@@ -807,6 +815,22 @@ function envList(key, fallback) {
|
|
|
807
815
|
const parsed = s.split(",").map((v) => v.trim()).filter((v) => v.length > 0);
|
|
808
816
|
return parsed.length > 0 ? parsed : fallback;
|
|
809
817
|
}
|
|
818
|
+
function readSchedulerConfig(rawFileConfig) {
|
|
819
|
+
try {
|
|
820
|
+
const cfg = rawFileConfig;
|
|
821
|
+
return cfg?.scheduler ?? {};
|
|
822
|
+
} catch {
|
|
823
|
+
return {};
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
function resolveSchedulerJob(kind, fileJobs) {
|
|
827
|
+
const meta = SCHEDULER_JOB_ENV[kind];
|
|
828
|
+
const fileJob = fileJobs?.[kind];
|
|
829
|
+
return {
|
|
830
|
+
enabled: envBool(meta.enabledVar, fileJob?.enabled ?? false),
|
|
831
|
+
intervalMs: envNum(meta.intervalVar, fileJob?.intervalMs ?? meta.defaultIntervalMs)
|
|
832
|
+
};
|
|
833
|
+
}
|
|
810
834
|
function validateCapturePolicyConfig(raw2) {
|
|
811
835
|
if (!raw2 || typeof raw2 !== "object")
|
|
812
836
|
throw new TypeError("capturePolicy must be an object");
|
|
@@ -934,6 +958,11 @@ class Config {
|
|
|
934
958
|
rateLimit: { ...defaults.rateLimit, ...overrides.rateLimit },
|
|
935
959
|
security: { ...defaults.security, ...overrides.security },
|
|
936
960
|
logging: { ...defaults.logging, ...overrides.logging },
|
|
961
|
+
scheduler: {
|
|
962
|
+
...defaults.scheduler,
|
|
963
|
+
...overrides.scheduler,
|
|
964
|
+
jobs: { ...defaults.scheduler.jobs, ...overrides.scheduler?.jobs }
|
|
965
|
+
},
|
|
937
966
|
synapse: {
|
|
938
967
|
...defaults.synapse,
|
|
939
968
|
...overrides.synapse,
|
|
@@ -1002,15 +1031,43 @@ class Config {
|
|
|
1002
1031
|
this.config[key] = value;
|
|
1003
1032
|
}
|
|
1004
1033
|
}
|
|
1005
|
-
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, config;
|
|
1034
|
+
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, config;
|
|
1006
1035
|
var init_config = __esm(() => {
|
|
1007
1036
|
init_env();
|
|
1008
1037
|
init_config_loader();
|
|
1009
1038
|
init_massa_ai_config();
|
|
1039
|
+
init_massa_ai_config();
|
|
1010
1040
|
init_config_loader();
|
|
1011
1041
|
init_config_writer();
|
|
1012
1042
|
init_xdg();
|
|
1013
1043
|
init_api_key();
|
|
1044
|
+
SCHEDULER_JOB_ENV = {
|
|
1045
|
+
"memory-consolidation": {
|
|
1046
|
+
enabledVar: "MASSA_AI_SCHEDULER_CONSOLIDATION_ENABLED",
|
|
1047
|
+
intervalVar: "MASSA_AI_SCHEDULER_CONSOLIDATION_INTERVAL_MS",
|
|
1048
|
+
defaultIntervalMs: 30 * 60 * 1000
|
|
1049
|
+
},
|
|
1050
|
+
"decay-sweep": {
|
|
1051
|
+
enabledVar: "MASSA_AI_SCHEDULER_DECAY_ENABLED",
|
|
1052
|
+
intervalVar: "MASSA_AI_SCHEDULER_DECAY_INTERVAL_MS",
|
|
1053
|
+
defaultIntervalMs: 60 * 60 * 1000
|
|
1054
|
+
},
|
|
1055
|
+
"auto-improve": {
|
|
1056
|
+
enabledVar: "MASSA_AI_SCHEDULER_AUTO_IMPROVE_ENABLED",
|
|
1057
|
+
intervalVar: "MASSA_AI_SCHEDULER_AUTO_IMPROVE_INTERVAL_MS",
|
|
1058
|
+
defaultIntervalMs: 30 * 60 * 1000
|
|
1059
|
+
},
|
|
1060
|
+
"observation-bridge": {
|
|
1061
|
+
enabledVar: "MASSA_AI_SCHEDULER_OBSERVATION_BRIDGE_ENABLED",
|
|
1062
|
+
intervalVar: "MASSA_AI_SCHEDULER_OBSERVATION_BRIDGE_INTERVAL_MS",
|
|
1063
|
+
defaultIntervalMs: 30 * 60 * 1000
|
|
1064
|
+
},
|
|
1065
|
+
"checkpoint-purge": {
|
|
1066
|
+
enabledVar: "MASSA_AI_SCHEDULER_CHECKPOINT_PURGE_ENABLED",
|
|
1067
|
+
intervalVar: "MASSA_AI_SCHEDULER_CHECKPOINT_PURGE_INTERVAL_MS",
|
|
1068
|
+
defaultIntervalMs: 60 * 60 * 1000
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1014
1071
|
DEFAULT_ALLOWED_EXTENSIONS = [
|
|
1015
1072
|
".ts",
|
|
1016
1073
|
".js",
|
|
@@ -1049,10 +1106,11 @@ var init_config = __esm(() => {
|
|
|
1049
1106
|
fileConfig = loadConfigSafe();
|
|
1050
1107
|
fileCacheL1Bytes = fileConfig.cache?.l1MaxSizeMB ? fileConfig.cache.l1MaxSizeMB * 1024 * 1024 : undefined;
|
|
1051
1108
|
fileCacheL2Bytes = fileConfig.cache?.l2MaxSizeMB ? fileConfig.cache.l2MaxSizeMB * 1024 * 1024 : undefined;
|
|
1109
|
+
resolvedDataDir = getGlobalDataDir();
|
|
1052
1110
|
defaultConfig = {
|
|
1053
1111
|
name: "massa-ai-server",
|
|
1054
1112
|
version: "1.0.0",
|
|
1055
|
-
dataDir:
|
|
1113
|
+
dataDir: resolvedDataDir,
|
|
1056
1114
|
cache: {
|
|
1057
1115
|
l1: {
|
|
1058
1116
|
maxSize: envNum("L1_CACHE_MAX_SIZE", fileCacheL1Bytes ?? 100 * 1024 * 1024),
|
|
@@ -1176,8 +1234,24 @@ var init_config = __esm(() => {
|
|
|
1176
1234
|
logging: {
|
|
1177
1235
|
level: process.env.LOG_LEVEL || fileConfig.logging?.level || "info",
|
|
1178
1236
|
enableMetrics: process.env.ENABLE_METRICS === "true" || process.env.ENABLE_METRICS === undefined && !!fileConfig.logging?.enableMetrics,
|
|
1179
|
-
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file ||
|
|
1180
|
-
|
|
1237
|
+
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file || path4.join(resolvedDataDir, "logs", "massa-ai.log"),
|
|
1238
|
+
enableFileSink: envBool("MASSA_AI_LOG_ENABLE_FILE_SINK", fileConfig.logging?.enableFileSink ?? true),
|
|
1239
|
+
bufferSize: envNum("MASSA_AI_LOG_BUFFER_SIZE", fileConfig.logging?.bufferSize ?? 2000),
|
|
1240
|
+
maxFileSizeMb: envNum("MASSA_AI_LOG_MAX_FILE_SIZE_MB", fileConfig.logging?.maxFileSizeMb ?? 32),
|
|
1241
|
+
maxFiles: envNum("MASSA_AI_LOG_MAX_FILES", fileConfig.logging?.maxFiles ?? 5)
|
|
1242
|
+
},
|
|
1243
|
+
scheduler: (() => {
|
|
1244
|
+
const fileScheduler = readSchedulerConfig(fileConfig);
|
|
1245
|
+
return {
|
|
1246
|
+
enabled: envBool("MASSA_AI_SCHEDULER_ENABLED", fileScheduler.enabled ?? false),
|
|
1247
|
+
tickMs: envNum("MASSA_AI_SCHEDULER_TICK_MS", fileScheduler.tickMs ?? 60000),
|
|
1248
|
+
maxConcurrent: envNum("MASSA_AI_SCHEDULER_MAX_CONCURRENT", fileScheduler.maxConcurrent ?? 2),
|
|
1249
|
+
jobs: Object.fromEntries(SCHEDULER_JOB_KINDS.map((kind) => [
|
|
1250
|
+
kind,
|
|
1251
|
+
resolveSchedulerJob(kind, fileScheduler.jobs)
|
|
1252
|
+
]))
|
|
1253
|
+
};
|
|
1254
|
+
})(),
|
|
1181
1255
|
synapse: {
|
|
1182
1256
|
enabled: process.env.SYNAPSE_ENABLED !== "false",
|
|
1183
1257
|
inhibition: {
|
|
@@ -1329,13 +1403,175 @@ var init_types = __esm(() => {
|
|
|
1329
1403
|
// ../../packages/shared/dist/types/interfaces.js
|
|
1330
1404
|
var init_interfaces = () => {};
|
|
1331
1405
|
|
|
1332
|
-
// ../../packages/shared/dist/utils/
|
|
1406
|
+
// ../../packages/shared/dist/utils/log-sink.js
|
|
1333
1407
|
import fs2 from "fs";
|
|
1408
|
+
import path5 from "path";
|
|
1409
|
+
function getState(filePath) {
|
|
1410
|
+
let state = pathState.get(filePath);
|
|
1411
|
+
if (!state) {
|
|
1412
|
+
state = { trackedSize: 0, deltaSinceStat: 0, primed: false };
|
|
1413
|
+
pathState.set(filePath, state);
|
|
1414
|
+
}
|
|
1415
|
+
return state;
|
|
1416
|
+
}
|
|
1417
|
+
function ensureDir(filePath) {
|
|
1418
|
+
const dir = path5.dirname(filePath);
|
|
1419
|
+
if (ensuredDirs.has(dir))
|
|
1420
|
+
return;
|
|
1421
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
1422
|
+
ensuredDirs.add(dir);
|
|
1423
|
+
}
|
|
1424
|
+
function restat(filePath, state) {
|
|
1425
|
+
try {
|
|
1426
|
+
state.trackedSize = fs2.statSync(filePath).size;
|
|
1427
|
+
} catch {
|
|
1428
|
+
state.trackedSize = 0;
|
|
1429
|
+
}
|
|
1430
|
+
state.deltaSinceStat = 0;
|
|
1431
|
+
state.primed = true;
|
|
1432
|
+
}
|
|
1433
|
+
function rotate(filePath, maxFiles) {
|
|
1434
|
+
if (maxFiles <= 0) {
|
|
1435
|
+
if (fs2.existsSync(filePath))
|
|
1436
|
+
fs2.unlinkSync(filePath);
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
const oldest = `${filePath}.${maxFiles}`;
|
|
1440
|
+
if (fs2.existsSync(oldest))
|
|
1441
|
+
fs2.unlinkSync(oldest);
|
|
1442
|
+
for (let n = maxFiles - 1;n >= 1; n--) {
|
|
1443
|
+
const src = `${filePath}.${n}`;
|
|
1444
|
+
const dest = `${filePath}.${n + 1}`;
|
|
1445
|
+
if (fs2.existsSync(src))
|
|
1446
|
+
fs2.renameSync(src, dest);
|
|
1447
|
+
}
|
|
1448
|
+
if (fs2.existsSync(filePath))
|
|
1449
|
+
fs2.renameSync(filePath, `${filePath}.1`);
|
|
1450
|
+
}
|
|
1451
|
+
function appendLine(opts, line) {
|
|
1452
|
+
const { filePath, maxFileSizeBytes, maxFiles } = opts;
|
|
1453
|
+
try {
|
|
1454
|
+
ensureDir(filePath);
|
|
1455
|
+
const state = getState(filePath);
|
|
1456
|
+
const lineBytes = Buffer.byteLength(line + `
|
|
1457
|
+
`, "utf8");
|
|
1458
|
+
if (!state.primed || state.deltaSinceStat >= STAT_DELTA_THRESHOLD_BYTES || state.trackedSize + state.deltaSinceStat >= maxFileSizeBytes) {
|
|
1459
|
+
restat(filePath, state);
|
|
1460
|
+
}
|
|
1461
|
+
if (maxFileSizeBytes > 0 && state.trackedSize >= maxFileSizeBytes) {
|
|
1462
|
+
rotate(filePath, maxFiles);
|
|
1463
|
+
state.trackedSize = 0;
|
|
1464
|
+
state.deltaSinceStat = 0;
|
|
1465
|
+
state.primed = true;
|
|
1466
|
+
}
|
|
1467
|
+
fs2.appendFileSync(filePath, line + `
|
|
1468
|
+
`);
|
|
1469
|
+
state.trackedSize += lineBytes;
|
|
1470
|
+
state.deltaSinceStat += lineBytes;
|
|
1471
|
+
} catch (err) {
|
|
1472
|
+
lastError = err;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
var STAT_DELTA_THRESHOLD_BYTES, ensuredDirs, pathState, lastError;
|
|
1476
|
+
var init_log_sink = __esm(() => {
|
|
1477
|
+
STAT_DELTA_THRESHOLD_BYTES = 1024 * 1024;
|
|
1478
|
+
ensuredDirs = new Set;
|
|
1479
|
+
pathState = new Map;
|
|
1480
|
+
});
|
|
1481
|
+
|
|
1482
|
+
// ../../packages/shared/dist/utils/log-buffer.js
|
|
1483
|
+
class LogBufferImpl {
|
|
1484
|
+
capacity = DEFAULT_CAPACITY;
|
|
1485
|
+
entries = [];
|
|
1486
|
+
subscribers = new Set;
|
|
1487
|
+
nextSeq = 0;
|
|
1488
|
+
dispatching = false;
|
|
1489
|
+
pending = [];
|
|
1490
|
+
push(entry) {
|
|
1491
|
+
if (this.dispatching) {
|
|
1492
|
+
this.pending.push(entry);
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1495
|
+
this.dispatching = true;
|
|
1496
|
+
try {
|
|
1497
|
+
this.pushOne(entry);
|
|
1498
|
+
while (this.pending.length > 0) {
|
|
1499
|
+
const next = this.pending.shift();
|
|
1500
|
+
this.pushOne(next);
|
|
1501
|
+
}
|
|
1502
|
+
} finally {
|
|
1503
|
+
this.dispatching = false;
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
pushOne(entry) {
|
|
1507
|
+
const full = { ...entry, seq: this.nextSeq++ };
|
|
1508
|
+
this.entries.push(full);
|
|
1509
|
+
while (this.entries.length > this.capacity) {
|
|
1510
|
+
this.entries.shift();
|
|
1511
|
+
}
|
|
1512
|
+
for (const fn of this.subscribers) {
|
|
1513
|
+
try {
|
|
1514
|
+
fn(full);
|
|
1515
|
+
} catch {}
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
snapshot(opts) {
|
|
1519
|
+
const from = opts?.from;
|
|
1520
|
+
const to = opts?.to;
|
|
1521
|
+
const level = opts?.level;
|
|
1522
|
+
const q = opts?.q?.toLowerCase();
|
|
1523
|
+
const result = [];
|
|
1524
|
+
for (let i = this.entries.length - 1;i >= 0; i--) {
|
|
1525
|
+
const e = this.entries[i];
|
|
1526
|
+
if (from !== undefined && e.seq < from)
|
|
1527
|
+
continue;
|
|
1528
|
+
if (to !== undefined && e.seq > to)
|
|
1529
|
+
continue;
|
|
1530
|
+
if (level !== undefined && e.level !== level)
|
|
1531
|
+
continue;
|
|
1532
|
+
if (q !== undefined && !e.message.toLowerCase().includes(q))
|
|
1533
|
+
continue;
|
|
1534
|
+
result.push(e);
|
|
1535
|
+
}
|
|
1536
|
+
return result;
|
|
1537
|
+
}
|
|
1538
|
+
subscribe(fn) {
|
|
1539
|
+
this.subscribers.add(fn);
|
|
1540
|
+
return () => {
|
|
1541
|
+
this.subscribers.delete(fn);
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
setCapacity(n) {
|
|
1545
|
+
this.capacity = n > 0 ? n : 0;
|
|
1546
|
+
while (this.entries.length > this.capacity) {
|
|
1547
|
+
this.entries.shift();
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
size() {
|
|
1551
|
+
return this.entries.length;
|
|
1552
|
+
}
|
|
1553
|
+
_resetForTesting() {
|
|
1554
|
+
this.entries = [];
|
|
1555
|
+
this.subscribers.clear();
|
|
1556
|
+
this.nextSeq = 0;
|
|
1557
|
+
this.dispatching = false;
|
|
1558
|
+
this.pending = [];
|
|
1559
|
+
this.capacity = DEFAULT_CAPACITY;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
var DEFAULT_CAPACITY = 2000, logBuffer;
|
|
1563
|
+
var init_log_buffer = __esm(() => {
|
|
1564
|
+
logBuffer = new LogBufferImpl;
|
|
1565
|
+
});
|
|
1334
1566
|
|
|
1567
|
+
// ../../packages/shared/dist/utils/logger.js
|
|
1335
1568
|
class Logger {
|
|
1336
1569
|
_level;
|
|
1337
1570
|
_enableMetrics;
|
|
1338
1571
|
_logFilePath;
|
|
1572
|
+
_enableFileSink;
|
|
1573
|
+
_maxFileSizeBytes;
|
|
1574
|
+
_maxFiles;
|
|
1339
1575
|
_initialized = false;
|
|
1340
1576
|
constructor() {}
|
|
1341
1577
|
ensureInitialized() {
|
|
@@ -1345,10 +1581,18 @@ class Logger {
|
|
|
1345
1581
|
this._level = this.parseLogLevel(loggingConfig.level);
|
|
1346
1582
|
this._enableMetrics = loggingConfig.enableMetrics;
|
|
1347
1583
|
this._logFilePath = loggingConfig.file;
|
|
1584
|
+
this._enableFileSink = loggingConfig.enableFileSink;
|
|
1585
|
+
this._maxFileSizeBytes = loggingConfig.maxFileSizeMb * 1024 * 1024;
|
|
1586
|
+
this._maxFiles = loggingConfig.maxFiles;
|
|
1587
|
+
logBuffer.setCapacity(loggingConfig.bufferSize);
|
|
1348
1588
|
} catch {
|
|
1349
1589
|
this._level = LogLevel.INFO;
|
|
1350
1590
|
this._enableMetrics = false;
|
|
1351
1591
|
this._logFilePath = undefined;
|
|
1592
|
+
this._enableFileSink = false;
|
|
1593
|
+
this._maxFileSizeBytes = 32 * 1024 * 1024;
|
|
1594
|
+
this._maxFiles = 5;
|
|
1595
|
+
logBuffer.setCapacity(2000);
|
|
1352
1596
|
}
|
|
1353
1597
|
this._initialized = true;
|
|
1354
1598
|
}
|
|
@@ -1365,6 +1609,18 @@ class Logger {
|
|
|
1365
1609
|
this.ensureInitialized();
|
|
1366
1610
|
return this._logFilePath;
|
|
1367
1611
|
}
|
|
1612
|
+
get enableFileSink() {
|
|
1613
|
+
this.ensureInitialized();
|
|
1614
|
+
return this._enableFileSink;
|
|
1615
|
+
}
|
|
1616
|
+
get maxFileSizeBytes() {
|
|
1617
|
+
this.ensureInitialized();
|
|
1618
|
+
return this._maxFileSizeBytes;
|
|
1619
|
+
}
|
|
1620
|
+
get maxFiles() {
|
|
1621
|
+
this.ensureInitialized();
|
|
1622
|
+
return this._maxFiles;
|
|
1623
|
+
}
|
|
1368
1624
|
parseLogLevel(level) {
|
|
1369
1625
|
const levels = {
|
|
1370
1626
|
debug: LogLevel.DEBUG,
|
|
@@ -1377,34 +1633,40 @@ class Logger {
|
|
|
1377
1633
|
shouldLog(level) {
|
|
1378
1634
|
return level >= this.level;
|
|
1379
1635
|
}
|
|
1380
|
-
formatMessage(level, message, meta) {
|
|
1381
|
-
const timestamp = new Date().toISOString();
|
|
1636
|
+
formatMessage(level, message, meta, timestamp = new Date().toISOString()) {
|
|
1382
1637
|
const metaStr = meta ? ` ${JSON.stringify(meta)}` : "";
|
|
1383
1638
|
return `[${timestamp}] [${level}] ${message}${metaStr}`;
|
|
1384
1639
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
const
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1640
|
+
emit(level, message, meta) {
|
|
1641
|
+
const ts = new Date().toISOString();
|
|
1642
|
+
const line = this.formatMessage(LOG_LEVEL_LABELS[level], message, meta, ts);
|
|
1643
|
+
console.error(line);
|
|
1644
|
+
if (this.enableFileSink) {
|
|
1645
|
+
const filePath = this.logFilePath;
|
|
1646
|
+
if (filePath) {
|
|
1647
|
+
appendLine({ filePath, maxFileSizeBytes: this.maxFileSizeBytes, maxFiles: this.maxFiles }, line);
|
|
1648
|
+
}
|
|
1393
1649
|
}
|
|
1650
|
+
logBuffer.push({
|
|
1651
|
+
ts,
|
|
1652
|
+
level: LOG_LEVEL_BUFFER_TAGS[level],
|
|
1653
|
+
message,
|
|
1654
|
+
...meta ? { meta } : {}
|
|
1655
|
+
});
|
|
1394
1656
|
}
|
|
1395
1657
|
debug(message, meta) {
|
|
1396
1658
|
if (this.shouldLog(LogLevel.DEBUG)) {
|
|
1397
|
-
this.
|
|
1659
|
+
this.emit(LogLevel.DEBUG, message, meta);
|
|
1398
1660
|
}
|
|
1399
1661
|
}
|
|
1400
1662
|
info(message, meta) {
|
|
1401
1663
|
if (this.shouldLog(LogLevel.INFO)) {
|
|
1402
|
-
this.
|
|
1664
|
+
this.emit(LogLevel.INFO, message, meta);
|
|
1403
1665
|
}
|
|
1404
1666
|
}
|
|
1405
1667
|
warn(message, meta) {
|
|
1406
1668
|
if (this.shouldLog(LogLevel.WARN)) {
|
|
1407
|
-
this.
|
|
1669
|
+
this.emit(LogLevel.WARN, message, meta);
|
|
1408
1670
|
}
|
|
1409
1671
|
}
|
|
1410
1672
|
error(message, error, meta) {
|
|
@@ -1417,7 +1679,7 @@ class Logger {
|
|
|
1417
1679
|
stack: error.stack
|
|
1418
1680
|
}
|
|
1419
1681
|
} : meta;
|
|
1420
|
-
this.
|
|
1682
|
+
this.emit(LogLevel.ERROR, message, errorMeta);
|
|
1421
1683
|
}
|
|
1422
1684
|
}
|
|
1423
1685
|
metric(name, value, unit) {
|
|
@@ -1446,15 +1708,29 @@ class Logger {
|
|
|
1446
1708
|
return childLogger;
|
|
1447
1709
|
}
|
|
1448
1710
|
}
|
|
1449
|
-
var LogLevel, logger;
|
|
1711
|
+
var LogLevel, LOG_LEVEL_LABELS, LOG_LEVEL_BUFFER_TAGS, logger;
|
|
1450
1712
|
var init_logger = __esm(() => {
|
|
1451
1713
|
init_config();
|
|
1714
|
+
init_log_sink();
|
|
1715
|
+
init_log_buffer();
|
|
1452
1716
|
(function(LogLevel2) {
|
|
1453
1717
|
LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
|
|
1454
1718
|
LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
|
|
1455
1719
|
LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
|
|
1456
1720
|
LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
|
|
1457
1721
|
})(LogLevel || (LogLevel = {}));
|
|
1722
|
+
LOG_LEVEL_LABELS = {
|
|
1723
|
+
[LogLevel.DEBUG]: "DEBUG",
|
|
1724
|
+
[LogLevel.INFO]: "INFO",
|
|
1725
|
+
[LogLevel.WARN]: "WARN",
|
|
1726
|
+
[LogLevel.ERROR]: "ERROR"
|
|
1727
|
+
};
|
|
1728
|
+
LOG_LEVEL_BUFFER_TAGS = {
|
|
1729
|
+
[LogLevel.DEBUG]: "debug",
|
|
1730
|
+
[LogLevel.INFO]: "info",
|
|
1731
|
+
[LogLevel.WARN]: "warn",
|
|
1732
|
+
[LogLevel.ERROR]: "error"
|
|
1733
|
+
};
|
|
1458
1734
|
logger = new Logger;
|
|
1459
1735
|
});
|
|
1460
1736
|
|
|
@@ -1737,6 +2013,8 @@ var init_rate_limiter = __esm(() => {
|
|
|
1737
2013
|
// ../../packages/shared/dist/utils/index.js
|
|
1738
2014
|
var init_utils = __esm(() => {
|
|
1739
2015
|
init_logger();
|
|
2016
|
+
init_log_buffer();
|
|
2017
|
+
init_log_sink();
|
|
1740
2018
|
init_sanitizer();
|
|
1741
2019
|
init_metrics();
|
|
1742
2020
|
init_rate_limiter();
|
|
@@ -1744,7 +2022,7 @@ var init_utils = __esm(() => {
|
|
|
1744
2022
|
|
|
1745
2023
|
// ../../packages/shared/dist/profile-switch/hosts.js
|
|
1746
2024
|
import os3 from "os";
|
|
1747
|
-
import
|
|
2025
|
+
import path6 from "path";
|
|
1748
2026
|
function isHost(v) {
|
|
1749
2027
|
return typeof v === "string" && HOSTS.includes(v);
|
|
1750
2028
|
}
|
|
@@ -1755,7 +2033,7 @@ function fileLayout(host, activeDir, activeGlob, variantsRoot) {
|
|
|
1755
2033
|
activeDir,
|
|
1756
2034
|
activeGlob,
|
|
1757
2035
|
variantsRoot,
|
|
1758
|
-
variantDir: (profile) =>
|
|
2036
|
+
variantDir: (profile) => path6.join(variantsRoot, profile)
|
|
1759
2037
|
};
|
|
1760
2038
|
}
|
|
1761
2039
|
function resolveHostLayout(host, opts = {}) {
|
|
@@ -1765,25 +2043,37 @@ function resolveHostLayout(host, opts = {}) {
|
|
|
1765
2043
|
case "cursor":
|
|
1766
2044
|
return { host, route: "skip", reason: CURSOR_SKIP_REASON };
|
|
1767
2045
|
case "claude": {
|
|
1768
|
-
const
|
|
1769
|
-
|
|
2046
|
+
const marketplaceRoot = opts.marketplaceRoot?.claude;
|
|
2047
|
+
if (override === undefined && marketplaceRoot !== undefined) {
|
|
2048
|
+
return fileLayout(host, path6.join(marketplaceRoot, "agents"), "massa-ai-*.md", path6.join(marketplaceRoot, "agent-profiles"));
|
|
2049
|
+
}
|
|
2050
|
+
const root = override ?? path6.join(targetHome, ".claude");
|
|
2051
|
+
return fileLayout(host, path6.join(root, "agents"), "massa-ai-*.md", path6.join(root, "massa-ai", "agent-profiles"));
|
|
1770
2052
|
}
|
|
1771
2053
|
case "codex": {
|
|
1772
|
-
const root = override ??
|
|
1773
|
-
return fileLayout(host,
|
|
2054
|
+
const root = override ?? path6.join(targetHome, ".codex");
|
|
2055
|
+
return fileLayout(host, path6.join(root, "agents"), "massa-ai-*.toml", path6.join(root, "massa-ai", "agent-profiles"));
|
|
1774
2056
|
}
|
|
1775
2057
|
case "opencode": {
|
|
1776
|
-
const root = override ??
|
|
1777
|
-
const pluginsDir =
|
|
1778
|
-
return fileLayout(host,
|
|
2058
|
+
const root = override ?? path6.join(targetHome, ".config", "opencode");
|
|
2059
|
+
const pluginsDir = path6.join(root, "plugins", "massa-ai");
|
|
2060
|
+
return fileLayout(host, path6.join(root, "agents"), "massa-ai-*.md", path6.join(pluginsDir, "agent-profiles"));
|
|
1779
2061
|
}
|
|
1780
2062
|
}
|
|
1781
2063
|
}
|
|
1782
|
-
function detectRoute(platform) {
|
|
2064
|
+
function detectRoute(platform, host) {
|
|
1783
2065
|
const route = platform?.installRoute;
|
|
1784
2066
|
if (route === "file")
|
|
1785
2067
|
return { kind: "proceed" };
|
|
1786
2068
|
if (route === "marketplace") {
|
|
2069
|
+
if (host === "claude")
|
|
2070
|
+
return { kind: "proceed" };
|
|
2071
|
+
if (host === "codex") {
|
|
2072
|
+
return {
|
|
2073
|
+
kind: "refuse",
|
|
2074
|
+
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."
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
1787
2077
|
return {
|
|
1788
2078
|
kind: "refuse",
|
|
1789
2079
|
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."
|
|
@@ -1801,7 +2091,7 @@ var init_hosts = __esm(() => {
|
|
|
1801
2091
|
|
|
1802
2092
|
// ../../packages/shared/dist/profile-switch/state.js
|
|
1803
2093
|
import fs3 from "fs";
|
|
1804
|
-
import
|
|
2094
|
+
import path7 from "path";
|
|
1805
2095
|
function namedError(name, message) {
|
|
1806
2096
|
const err = new InstallStateError(message);
|
|
1807
2097
|
err.name = name;
|
|
@@ -1847,7 +2137,7 @@ function writeInstallState(filePath, state) {
|
|
|
1847
2137
|
const text = `${JSON.stringify(validated, null, 2)}
|
|
1848
2138
|
`;
|
|
1849
2139
|
try {
|
|
1850
|
-
fs3.mkdirSync(
|
|
2140
|
+
fs3.mkdirSync(path7.dirname(filePath), { recursive: true });
|
|
1851
2141
|
fs3.writeFileSync(filePath, text);
|
|
1852
2142
|
} catch (err) {
|
|
1853
2143
|
throw UnwritableInstallStateError(filePath, err.message);
|
|
@@ -1876,7 +2166,7 @@ var init_state = __esm(() => {
|
|
|
1876
2166
|
|
|
1877
2167
|
// ../../packages/shared/dist/profile-switch/lock.js
|
|
1878
2168
|
import fs4 from "fs";
|
|
1879
|
-
import
|
|
2169
|
+
import path8 from "path";
|
|
1880
2170
|
import os4 from "os";
|
|
1881
2171
|
import crypto3 from "crypto";
|
|
1882
2172
|
import { execFileSync } from "child_process";
|
|
@@ -1908,7 +2198,7 @@ function releaseIfOwned(lockDir, ownerPath, token) {
|
|
|
1908
2198
|
}
|
|
1909
2199
|
function acquireLock(stateFilePath, options = {}) {
|
|
1910
2200
|
const lockDir = `${stateFilePath}.switch.lock`;
|
|
1911
|
-
const ownerPath =
|
|
2201
|
+
const ownerPath = path8.join(lockDir, "owner.json");
|
|
1912
2202
|
const clock = options.clock ?? DEFAULT_CLOCK;
|
|
1913
2203
|
const identity = options.identity ?? DEFAULT_IDENTITY;
|
|
1914
2204
|
const staleAfterMs = options.staleAfterMs ?? DEFAULT_STALE_AFTER_MS;
|
|
@@ -1928,7 +2218,7 @@ function acquireLock(stateFilePath, options = {}) {
|
|
|
1928
2218
|
token,
|
|
1929
2219
|
timestamp: clock.now()
|
|
1930
2220
|
};
|
|
1931
|
-
fs4.mkdirSync(
|
|
2221
|
+
fs4.mkdirSync(path8.dirname(ownerPath), { recursive: true });
|
|
1932
2222
|
fs4.writeFileSync(ownerPath, JSON.stringify(record));
|
|
1933
2223
|
return { lockDir, release: () => releaseIfOwned(lockDir, ownerPath, token) };
|
|
1934
2224
|
};
|
|
@@ -1981,10 +2271,59 @@ var init_lock = __esm(() => {
|
|
|
1981
2271
|
};
|
|
1982
2272
|
});
|
|
1983
2273
|
|
|
1984
|
-
// ../../packages/shared/dist/profile-switch/
|
|
2274
|
+
// ../../packages/shared/dist/profile-switch/claude-marketplace.js
|
|
1985
2275
|
import fs5 from "fs";
|
|
1986
|
-
import path8 from "path";
|
|
1987
2276
|
import os5 from "os";
|
|
2277
|
+
import path9 from "path";
|
|
2278
|
+
function selectRecord(records) {
|
|
2279
|
+
if (records.length === 0)
|
|
2280
|
+
return;
|
|
2281
|
+
const userScoped = records.filter((r) => r.scope === "user");
|
|
2282
|
+
const pool = userScoped.length > 0 ? userScoped : records;
|
|
2283
|
+
let best;
|
|
2284
|
+
let bestTime = -Infinity;
|
|
2285
|
+
for (const record of pool) {
|
|
2286
|
+
const parsed = record.lastUpdated ? Date.parse(record.lastUpdated) : NaN;
|
|
2287
|
+
if (Number.isFinite(parsed) && parsed >= bestTime) {
|
|
2288
|
+
best = record;
|
|
2289
|
+
bestTime = parsed;
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
return best ?? pool[pool.length - 1];
|
|
2293
|
+
}
|
|
2294
|
+
function resolveClaudeMarketplaceRoot(opts = {}) {
|
|
2295
|
+
const targetHome = opts.targetHome ?? os5.homedir();
|
|
2296
|
+
const pluginKey = opts.pluginKey ?? DEFAULT_PLUGIN_KEY;
|
|
2297
|
+
const registryPath = path9.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
2298
|
+
let records;
|
|
2299
|
+
try {
|
|
2300
|
+
const raw2 = fs5.readFileSync(registryPath, "utf8");
|
|
2301
|
+
const parsed = JSON.parse(raw2);
|
|
2302
|
+
records = parsed?.plugins?.[pluginKey];
|
|
2303
|
+
} catch {
|
|
2304
|
+
return null;
|
|
2305
|
+
}
|
|
2306
|
+
if (!Array.isArray(records) || records.length === 0)
|
|
2307
|
+
return null;
|
|
2308
|
+
const selected = selectRecord(records);
|
|
2309
|
+
const installPath = selected?.installPath;
|
|
2310
|
+
if (!installPath)
|
|
2311
|
+
return null;
|
|
2312
|
+
try {
|
|
2313
|
+
if (!fs5.existsSync(installPath))
|
|
2314
|
+
return null;
|
|
2315
|
+
} catch {
|
|
2316
|
+
return null;
|
|
2317
|
+
}
|
|
2318
|
+
return installPath;
|
|
2319
|
+
}
|
|
2320
|
+
var DEFAULT_PLUGIN_KEY = "massa-ai@massa-ai";
|
|
2321
|
+
var init_claude_marketplace = () => {};
|
|
2322
|
+
|
|
2323
|
+
// ../../packages/shared/dist/profile-switch/engine.js
|
|
2324
|
+
import fs6 from "fs";
|
|
2325
|
+
import path10 from "path";
|
|
2326
|
+
import os6 from "os";
|
|
1988
2327
|
import crypto4 from "crypto";
|
|
1989
2328
|
function namedError3(name, message) {
|
|
1990
2329
|
const err = new SwitchEngineError(message);
|
|
@@ -1992,19 +2331,39 @@ function namedError3(name, message) {
|
|
|
1992
2331
|
return err;
|
|
1993
2332
|
}
|
|
1994
2333
|
function defaultStatePath(targetHome) {
|
|
1995
|
-
return
|
|
2334
|
+
return path10.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
1996
2335
|
}
|
|
1997
2336
|
function resolveCommon(opts) {
|
|
1998
|
-
const targetHome = opts.targetHome ??
|
|
2337
|
+
const targetHome = opts.targetHome ?? os6.homedir();
|
|
1999
2338
|
const stateFilePath = opts.stateFilePath ?? defaultStatePath(targetHome);
|
|
2000
2339
|
return { targetHome, stateFilePath };
|
|
2001
2340
|
}
|
|
2341
|
+
function marketplaceRoots(targetHome, state) {
|
|
2342
|
+
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
2343
|
+
}
|
|
2344
|
+
function claudeMarketplaceUnresolvedReason(targetHome) {
|
|
2345
|
+
const registryPath = path10.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
2346
|
+
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";
|
|
2347
|
+
}
|
|
2002
2348
|
function listProfiles(opts = {}) {
|
|
2003
2349
|
const { targetHome, stateFilePath } = resolveCommon(opts);
|
|
2004
2350
|
const state = readInstallState(stateFilePath);
|
|
2351
|
+
const roots = marketplaceRoots(targetHome, state);
|
|
2005
2352
|
const universe = opts.hosts ?? HOSTS;
|
|
2006
2353
|
const hosts = universe.map((host) => {
|
|
2007
|
-
|
|
2354
|
+
if (host === "claude" && state.platforms.claude?.installRoute === "marketplace" && roots.claude === undefined) {
|
|
2355
|
+
const platform2 = state.platforms.claude;
|
|
2356
|
+
return {
|
|
2357
|
+
host,
|
|
2358
|
+
installed: false,
|
|
2359
|
+
skipped: false,
|
|
2360
|
+
skipReason: null,
|
|
2361
|
+
activeProfile: platform2.modelProfile?.profile ?? opts.hostDefaults?.[host] ?? "balanced",
|
|
2362
|
+
bundleVersion: platform2.plugin?.version ?? null,
|
|
2363
|
+
availableProfiles: []
|
|
2364
|
+
};
|
|
2365
|
+
}
|
|
2366
|
+
const layout = resolveHostLayout(host, { targetHome, projectRoot: opts.projectRoot, marketplaceRoot: roots });
|
|
2008
2367
|
if (layout.route === "skip") {
|
|
2009
2368
|
return {
|
|
2010
2369
|
host,
|
|
@@ -2016,7 +2375,7 @@ function listProfiles(opts = {}) {
|
|
|
2016
2375
|
availableProfiles: []
|
|
2017
2376
|
};
|
|
2018
2377
|
}
|
|
2019
|
-
const installed =
|
|
2378
|
+
const installed = fs6.existsSync(layout.activeDir);
|
|
2020
2379
|
const availableProfiles = listVariantProfiles(layout);
|
|
2021
2380
|
const platform = state.platforms[host];
|
|
2022
2381
|
return {
|
|
@@ -2032,9 +2391,9 @@ function listProfiles(opts = {}) {
|
|
|
2032
2391
|
return { hosts };
|
|
2033
2392
|
}
|
|
2034
2393
|
function listVariantProfiles(layout) {
|
|
2035
|
-
if (!
|
|
2394
|
+
if (!fs6.existsSync(layout.variantsRoot))
|
|
2036
2395
|
return [];
|
|
2037
|
-
return
|
|
2396
|
+
return fs6.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
2038
2397
|
}
|
|
2039
2398
|
function matchesGlob(filename, glob) {
|
|
2040
2399
|
const starIdx = glob.indexOf("*");
|
|
@@ -2045,50 +2404,50 @@ function matchesGlob(filename, glob) {
|
|
|
2045
2404
|
return filename.length >= prefix.length + suffix.length && filename.startsWith(prefix) && filename.endsWith(suffix);
|
|
2046
2405
|
}
|
|
2047
2406
|
function assertStateWritable(stateFilePath) {
|
|
2048
|
-
const dir =
|
|
2407
|
+
const dir = path10.dirname(stateFilePath);
|
|
2049
2408
|
try {
|
|
2050
|
-
|
|
2409
|
+
fs6.mkdirSync(dir, { recursive: true });
|
|
2051
2410
|
} catch (err) {
|
|
2052
2411
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
2053
2412
|
}
|
|
2054
|
-
const checkPath =
|
|
2413
|
+
const checkPath = fs6.existsSync(stateFilePath) ? stateFilePath : dir;
|
|
2055
2414
|
try {
|
|
2056
|
-
|
|
2415
|
+
fs6.accessSync(checkPath, fs6.constants.W_OK);
|
|
2057
2416
|
} catch (err) {
|
|
2058
2417
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
2059
2418
|
}
|
|
2060
2419
|
}
|
|
2061
2420
|
function copyFileRouteVariant(layout, variantDir) {
|
|
2062
|
-
|
|
2421
|
+
fs6.mkdirSync(layout.activeDir, { recursive: true });
|
|
2063
2422
|
let changed = 0;
|
|
2064
|
-
for (const entry of
|
|
2423
|
+
for (const entry of fs6.readdirSync(variantDir, { withFileTypes: true })) {
|
|
2065
2424
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
2066
2425
|
continue;
|
|
2067
|
-
|
|
2426
|
+
fs6.copyFileSync(path10.join(variantDir, entry.name), path10.join(layout.activeDir, entry.name));
|
|
2068
2427
|
changed++;
|
|
2069
2428
|
}
|
|
2070
2429
|
return changed;
|
|
2071
2430
|
}
|
|
2072
2431
|
function repointOpencodeVariant(layout, variantDir) {
|
|
2073
|
-
|
|
2432
|
+
fs6.mkdirSync(layout.activeDir, { recursive: true });
|
|
2074
2433
|
let changed = 0;
|
|
2075
|
-
for (const entry of
|
|
2434
|
+
for (const entry of fs6.readdirSync(variantDir, { withFileTypes: true })) {
|
|
2076
2435
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
2077
2436
|
continue;
|
|
2078
|
-
const dest =
|
|
2079
|
-
const target =
|
|
2437
|
+
const dest = path10.join(layout.activeDir, entry.name);
|
|
2438
|
+
const target = path10.resolve(path10.join(variantDir, entry.name));
|
|
2080
2439
|
let destExists = true;
|
|
2081
2440
|
let destIsSymlink = false;
|
|
2082
2441
|
try {
|
|
2083
|
-
destIsSymlink =
|
|
2442
|
+
destIsSymlink = fs6.lstatSync(dest).isSymbolicLink();
|
|
2084
2443
|
} catch {
|
|
2085
2444
|
destExists = false;
|
|
2086
2445
|
}
|
|
2087
2446
|
if (destExists && !destIsSymlink)
|
|
2088
2447
|
continue;
|
|
2089
2448
|
const tmp = `${dest}.massa-ai-switch.${crypto4.randomUUID()}`;
|
|
2090
|
-
|
|
2091
|
-
|
|
2449
|
+
fs6.symlinkSync(target, tmp);
|
|
2450
|
+
fs6.renameSync(tmp, dest);
|
|
2092
2451
|
changed++;
|
|
2093
2452
|
}
|
|
2094
2453
|
return changed;
|
|
@@ -2104,19 +2463,37 @@ function switchProfile(opts) {
|
|
|
2104
2463
|
const state = readInstallState(stateFilePath);
|
|
2105
2464
|
if (!dryRun)
|
|
2106
2465
|
assertStateWritable(stateFilePath);
|
|
2107
|
-
const
|
|
2108
|
-
const
|
|
2466
|
+
const roots = marketplaceRoots(targetHome, state);
|
|
2467
|
+
const unresolvedRows = [];
|
|
2468
|
+
const resolvableUniverse = universe.filter((host) => {
|
|
2469
|
+
if (host !== "claude")
|
|
2470
|
+
return true;
|
|
2471
|
+
if (state.platforms.claude?.installRoute !== "marketplace")
|
|
2472
|
+
return true;
|
|
2473
|
+
if (roots.claude !== undefined)
|
|
2474
|
+
return true;
|
|
2475
|
+
unresolvedRows.push({ host, status: "failed", reason: claudeMarketplaceUnresolvedReason(targetHome) });
|
|
2476
|
+
return false;
|
|
2477
|
+
});
|
|
2478
|
+
const layouts = resolvableUniverse.map((host) => ({
|
|
2479
|
+
host,
|
|
2480
|
+
layout: resolveHostLayout(host, { targetHome, projectRoot: opts.projectRoot, marketplaceRoot: roots })
|
|
2481
|
+
}));
|
|
2482
|
+
const skipRows = [
|
|
2483
|
+
...unresolvedRows,
|
|
2484
|
+
...layouts.filter((l) => l.layout.route === "skip").map((l) => ({ host: l.host, status: "skipped", reason: l.layout.reason }))
|
|
2485
|
+
];
|
|
2109
2486
|
const fileHosts = layouts.filter((l) => l.layout.route === "files");
|
|
2110
2487
|
if (fileHosts.length === 0) {
|
|
2111
2488
|
return { profile: opts.profile, dryRun, hosts: orderRows(universe, skipRows), restartRequired: false };
|
|
2112
2489
|
}
|
|
2113
|
-
const installedFileHosts = fileHosts.filter((h) =>
|
|
2490
|
+
const installedFileHosts = fileHosts.filter((h) => fs6.existsSync(h.layout.activeDir));
|
|
2114
2491
|
if (installedFileHosts.length === 0)
|
|
2115
2492
|
throw NoHostsDetectedError();
|
|
2116
2493
|
const withAvailability = fileHosts.map((h) => {
|
|
2117
|
-
const variantsRootExists =
|
|
2494
|
+
const variantsRootExists = fs6.existsSync(h.layout.variantsRoot);
|
|
2118
2495
|
const variantDir = h.layout.variantDir(opts.profile);
|
|
2119
|
-
const available = variantsRootExists &&
|
|
2496
|
+
const available = variantsRootExists && fs6.existsSync(variantDir) && fs6.statSync(variantDir).isDirectory();
|
|
2120
2497
|
return { ...h, variantsRootExists, variantDir, available };
|
|
2121
2498
|
});
|
|
2122
2499
|
if (!withAvailability.some((h) => h.available)) {
|
|
@@ -2146,7 +2523,7 @@ function switchProfile(opts) {
|
|
|
2146
2523
|
});
|
|
2147
2524
|
continue;
|
|
2148
2525
|
}
|
|
2149
|
-
const route = detectRoute(state.platforms[h.host]);
|
|
2526
|
+
const route = detectRoute(state.platforms[h.host], h.host);
|
|
2150
2527
|
if (route.kind === "refuse") {
|
|
2151
2528
|
rows.push({ host: h.host, status: "failed", reason: route.reason });
|
|
2152
2529
|
continue;
|
|
@@ -2181,6 +2558,7 @@ var init_engine = __esm(() => {
|
|
|
2181
2558
|
init_hosts();
|
|
2182
2559
|
init_state();
|
|
2183
2560
|
init_lock();
|
|
2561
|
+
init_claude_marketplace();
|
|
2184
2562
|
SwitchEngineError = class SwitchEngineError extends Error {
|
|
2185
2563
|
constructor(message) {
|
|
2186
2564
|
super(message);
|
|
@@ -2195,18 +2573,25 @@ function reportSucceeded(report) {
|
|
|
2195
2573
|
}
|
|
2196
2574
|
|
|
2197
2575
|
// ../../packages/shared/dist/profile-switch/variant-sync.js
|
|
2198
|
-
import
|
|
2199
|
-
import
|
|
2576
|
+
import fs7 from "fs";
|
|
2577
|
+
import path11 from "path";
|
|
2578
|
+
import os7 from "os";
|
|
2200
2579
|
import crypto5 from "crypto";
|
|
2580
|
+
function defaultStatePath2(targetHome) {
|
|
2581
|
+
return path11.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
2582
|
+
}
|
|
2583
|
+
function marketplaceRoots2(targetHome, state) {
|
|
2584
|
+
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
2585
|
+
}
|
|
2201
2586
|
function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
2202
2587
|
const unique = `${process.pid}.${++tempFileCounter2}.${crypto5.randomBytes(6).toString("hex")}`;
|
|
2203
|
-
const tempFile =
|
|
2588
|
+
const tempFile = path11.join(destDir, `.${destName}.${unique}.tmp`);
|
|
2204
2589
|
try {
|
|
2205
|
-
|
|
2206
|
-
|
|
2590
|
+
fs7.writeFileSync(tempFile, content);
|
|
2591
|
+
fs7.renameSync(tempFile, path11.join(destDir, destName));
|
|
2207
2592
|
} catch (error) {
|
|
2208
2593
|
try {
|
|
2209
|
-
|
|
2594
|
+
fs7.unlinkSync(tempFile);
|
|
2210
2595
|
} catch {}
|
|
2211
2596
|
throw error;
|
|
2212
2597
|
}
|
|
@@ -2214,20 +2599,20 @@ function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
|
2214
2599
|
function isSafeDirName(name) {
|
|
2215
2600
|
if (name === "." || name === "..")
|
|
2216
2601
|
return false;
|
|
2217
|
-
if (name.includes("/") || name.includes("\\") || name.includes(
|
|
2602
|
+
if (name.includes("/") || name.includes("\\") || name.includes(path11.sep))
|
|
2218
2603
|
return false;
|
|
2219
|
-
return
|
|
2604
|
+
return path11.basename(name) === name;
|
|
2220
2605
|
}
|
|
2221
|
-
function syncHost(host, sourceRoot, targetHome) {
|
|
2222
|
-
const layout = resolveHostLayout(host, { targetHome });
|
|
2606
|
+
function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
2607
|
+
const layout = resolveHostLayout(host, { targetHome, marketplaceRoot });
|
|
2223
2608
|
if (layout.route === "skip") {
|
|
2224
2609
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: layout.reason };
|
|
2225
2610
|
}
|
|
2226
|
-
const srcDir =
|
|
2227
|
-
if (!
|
|
2611
|
+
const srcDir = path11.join(sourceRoot, "apps", `${host}-plugin`, "agent-profiles");
|
|
2612
|
+
if (!fs7.existsSync(srcDir) || !fs7.statSync(srcDir).isDirectory()) {
|
|
2228
2613
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: "no generated variants for this host" };
|
|
2229
2614
|
}
|
|
2230
|
-
if (!
|
|
2615
|
+
if (!fs7.existsSync(layout.variantsRoot)) {
|
|
2231
2616
|
return {
|
|
2232
2617
|
host,
|
|
2233
2618
|
status: "skipped",
|
|
@@ -2239,24 +2624,24 @@ function syncHost(host, sourceRoot, targetHome) {
|
|
|
2239
2624
|
}
|
|
2240
2625
|
const profiles = [];
|
|
2241
2626
|
let files = 0;
|
|
2242
|
-
for (const entry of
|
|
2627
|
+
for (const entry of fs7.readdirSync(srcDir, { withFileTypes: true })) {
|
|
2243
2628
|
if (!entry.isDirectory())
|
|
2244
2629
|
continue;
|
|
2245
2630
|
if (!isSafeDirName(entry.name))
|
|
2246
2631
|
continue;
|
|
2247
|
-
const srcProfileDir =
|
|
2248
|
-
const destProfileDir =
|
|
2249
|
-
|
|
2250
|
-
for (const fileEntry of
|
|
2632
|
+
const srcProfileDir = path11.join(srcDir, entry.name);
|
|
2633
|
+
const destProfileDir = path11.join(layout.variantsRoot, entry.name);
|
|
2634
|
+
fs7.mkdirSync(destProfileDir, { recursive: true });
|
|
2635
|
+
for (const fileEntry of fs7.readdirSync(srcProfileDir, { withFileTypes: true })) {
|
|
2251
2636
|
if (!fileEntry.isFile())
|
|
2252
2637
|
continue;
|
|
2253
|
-
const content =
|
|
2638
|
+
const content = fs7.readFileSync(path11.join(srcProfileDir, fileEntry.name));
|
|
2254
2639
|
writeFileIntoDirAtomically(destProfileDir, fileEntry.name, content);
|
|
2255
2640
|
files++;
|
|
2256
2641
|
}
|
|
2257
2642
|
profiles.push(entry.name);
|
|
2258
2643
|
}
|
|
2259
|
-
const retained =
|
|
2644
|
+
const retained = fs7.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory() && !profiles.includes(e.name)).map((e) => e.name).sort();
|
|
2260
2645
|
return { host, status: "synced", profiles: profiles.sort(), retained, files };
|
|
2261
2646
|
}
|
|
2262
2647
|
function syncGeneratedVariants(opts) {
|
|
@@ -2272,9 +2657,12 @@ function syncGeneratedVariants(opts) {
|
|
|
2272
2657
|
}));
|
|
2273
2658
|
}
|
|
2274
2659
|
const sourceRoot = opts.sourceRoot;
|
|
2660
|
+
const targetHome = opts.targetHome ?? os7.homedir();
|
|
2661
|
+
const state = readInstallState(defaultStatePath2(targetHome));
|
|
2662
|
+
const roots = marketplaceRoots2(targetHome, state);
|
|
2275
2663
|
return hosts.map((host) => {
|
|
2276
2664
|
try {
|
|
2277
|
-
return syncHost(host, sourceRoot, opts.targetHome);
|
|
2665
|
+
return syncHost(host, sourceRoot, opts.targetHome, roots);
|
|
2278
2666
|
} catch (err) {
|
|
2279
2667
|
return { host, status: "failed", profiles: [], retained: [], files: 0, error: err.message };
|
|
2280
2668
|
}
|
|
@@ -2283,17 +2671,19 @@ function syncGeneratedVariants(opts) {
|
|
|
2283
2671
|
var tempFileCounter2 = 0;
|
|
2284
2672
|
var init_variant_sync = __esm(() => {
|
|
2285
2673
|
init_hosts();
|
|
2674
|
+
init_state();
|
|
2675
|
+
init_claude_marketplace();
|
|
2286
2676
|
});
|
|
2287
2677
|
|
|
2288
2678
|
// ../../packages/shared/dist/profile-switch/repo-root.js
|
|
2289
|
-
import
|
|
2290
|
-
import
|
|
2679
|
+
import fs8 from "fs";
|
|
2680
|
+
import path12 from "path";
|
|
2291
2681
|
function findRepoRootWithMarker(startDir, marker, maxLevels) {
|
|
2292
2682
|
let dir = startDir;
|
|
2293
2683
|
for (let i = 0;i <= maxLevels; i++) {
|
|
2294
|
-
if (
|
|
2684
|
+
if (fs8.existsSync(path12.join(dir, marker)))
|
|
2295
2685
|
return dir;
|
|
2296
|
-
const parent =
|
|
2686
|
+
const parent = path12.dirname(dir);
|
|
2297
2687
|
if (parent === dir)
|
|
2298
2688
|
break;
|
|
2299
2689
|
dir = parent;
|
|
@@ -3833,7 +4223,7 @@ var import_brace_expansion, minimatch = (p, pattern, options = {}) => {
|
|
|
3833
4223
|
}, qmarksTestNoExtDot = ([$0]) => {
|
|
3834
4224
|
const len = $0.length;
|
|
3835
4225
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
3836
|
-
}, defaultPlatform,
|
|
4226
|
+
}, 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) => {
|
|
3837
4227
|
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
3838
4228
|
return minimatch;
|
|
3839
4229
|
}
|
|
@@ -3891,11 +4281,11 @@ var init_esm = __esm(() => {
|
|
|
3891
4281
|
starRE = /^\*+$/;
|
|
3892
4282
|
qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
3893
4283
|
defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
3894
|
-
|
|
4284
|
+
path13 = {
|
|
3895
4285
|
win32: { sep: "\\" },
|
|
3896
4286
|
posix: { sep: "/" }
|
|
3897
4287
|
};
|
|
3898
|
-
sep = defaultPlatform === "win32" ?
|
|
4288
|
+
sep = defaultPlatform === "win32" ? path13.win32.sep : path13.posix.sep;
|
|
3899
4289
|
minimatch.sep = sep;
|
|
3900
4290
|
GLOBSTAR = Symbol("globstar **");
|
|
3901
4291
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -5861,12 +6251,12 @@ var init_esm4 = __esm(() => {
|
|
|
5861
6251
|
childrenCache() {
|
|
5862
6252
|
return this.#children;
|
|
5863
6253
|
}
|
|
5864
|
-
resolve(
|
|
5865
|
-
if (!
|
|
6254
|
+
resolve(path14) {
|
|
6255
|
+
if (!path14) {
|
|
5866
6256
|
return this;
|
|
5867
6257
|
}
|
|
5868
|
-
const rootPath = this.getRootString(
|
|
5869
|
-
const dir =
|
|
6258
|
+
const rootPath = this.getRootString(path14);
|
|
6259
|
+
const dir = path14.substring(rootPath.length);
|
|
5870
6260
|
const dirParts = dir.split(this.splitSep);
|
|
5871
6261
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
5872
6262
|
return result;
|
|
@@ -6394,8 +6784,8 @@ var init_esm4 = __esm(() => {
|
|
|
6394
6784
|
newChild(name, type = UNKNOWN, opts = {}) {
|
|
6395
6785
|
return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
|
6396
6786
|
}
|
|
6397
|
-
getRootString(
|
|
6398
|
-
return win32.parse(
|
|
6787
|
+
getRootString(path14) {
|
|
6788
|
+
return win32.parse(path14).root;
|
|
6399
6789
|
}
|
|
6400
6790
|
getRoot(rootPath) {
|
|
6401
6791
|
rootPath = uncToDrive(rootPath.toUpperCase());
|
|
@@ -6420,8 +6810,8 @@ var init_esm4 = __esm(() => {
|
|
|
6420
6810
|
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
|
6421
6811
|
super(name, type, root, roots, nocase, children, opts);
|
|
6422
6812
|
}
|
|
6423
|
-
getRootString(
|
|
6424
|
-
return
|
|
6813
|
+
getRootString(path14) {
|
|
6814
|
+
return path14.startsWith("/") ? "/" : "";
|
|
6425
6815
|
}
|
|
6426
6816
|
getRoot(_rootPath) {
|
|
6427
6817
|
return this.root;
|
|
@@ -6440,8 +6830,8 @@ var init_esm4 = __esm(() => {
|
|
|
6440
6830
|
#children;
|
|
6441
6831
|
nocase;
|
|
6442
6832
|
#fs;
|
|
6443
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
6444
|
-
this.#fs = fsFromOption(
|
|
6833
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs9 = defaultFS } = {}) {
|
|
6834
|
+
this.#fs = fsFromOption(fs9);
|
|
6445
6835
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
6446
6836
|
cwd = fileURLToPath(cwd);
|
|
6447
6837
|
}
|
|
@@ -6477,11 +6867,11 @@ var init_esm4 = __esm(() => {
|
|
|
6477
6867
|
}
|
|
6478
6868
|
this.cwd = prev;
|
|
6479
6869
|
}
|
|
6480
|
-
depth(
|
|
6481
|
-
if (typeof
|
|
6482
|
-
|
|
6870
|
+
depth(path14 = this.cwd) {
|
|
6871
|
+
if (typeof path14 === "string") {
|
|
6872
|
+
path14 = this.cwd.resolve(path14);
|
|
6483
6873
|
}
|
|
6484
|
-
return
|
|
6874
|
+
return path14.depth();
|
|
6485
6875
|
}
|
|
6486
6876
|
childrenCache() {
|
|
6487
6877
|
return this.#children;
|
|
@@ -6897,9 +7287,9 @@ var init_esm4 = __esm(() => {
|
|
|
6897
7287
|
process2();
|
|
6898
7288
|
return results;
|
|
6899
7289
|
}
|
|
6900
|
-
chdir(
|
|
7290
|
+
chdir(path14 = this.cwd) {
|
|
6901
7291
|
const oldCwd = this.cwd;
|
|
6902
|
-
this.cwd = typeof
|
|
7292
|
+
this.cwd = typeof path14 === "string" ? this.cwd.resolve(path14) : path14;
|
|
6903
7293
|
this.cwd[setAsCwd](oldCwd);
|
|
6904
7294
|
}
|
|
6905
7295
|
};
|
|
@@ -6916,8 +7306,8 @@ var init_esm4 = __esm(() => {
|
|
|
6916
7306
|
parseRootPath(dir) {
|
|
6917
7307
|
return win32.parse(dir).root.toUpperCase();
|
|
6918
7308
|
}
|
|
6919
|
-
newRoot(
|
|
6920
|
-
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
7309
|
+
newRoot(fs9) {
|
|
7310
|
+
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
|
|
6921
7311
|
}
|
|
6922
7312
|
isAbsolute(p) {
|
|
6923
7313
|
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
@@ -6933,8 +7323,8 @@ var init_esm4 = __esm(() => {
|
|
|
6933
7323
|
parseRootPath(_dir) {
|
|
6934
7324
|
return "/";
|
|
6935
7325
|
}
|
|
6936
|
-
newRoot(
|
|
6937
|
-
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
7326
|
+
newRoot(fs9) {
|
|
7327
|
+
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
|
|
6938
7328
|
}
|
|
6939
7329
|
isAbsolute(p) {
|
|
6940
7330
|
return p.startsWith("/");
|
|
@@ -7191,8 +7581,8 @@ class MatchRecord {
|
|
|
7191
7581
|
this.store.set(target, current === undefined ? n : n & current);
|
|
7192
7582
|
}
|
|
7193
7583
|
entries() {
|
|
7194
|
-
return [...this.store.entries()].map(([
|
|
7195
|
-
|
|
7584
|
+
return [...this.store.entries()].map(([path14, n]) => [
|
|
7585
|
+
path14,
|
|
7196
7586
|
!!(n & 2),
|
|
7197
7587
|
!!(n & 1)
|
|
7198
7588
|
]);
|
|
@@ -7396,9 +7786,9 @@ class GlobUtil {
|
|
|
7396
7786
|
signal;
|
|
7397
7787
|
maxDepth;
|
|
7398
7788
|
includeChildMatches;
|
|
7399
|
-
constructor(patterns,
|
|
7789
|
+
constructor(patterns, path14, opts) {
|
|
7400
7790
|
this.patterns = patterns;
|
|
7401
|
-
this.path =
|
|
7791
|
+
this.path = path14;
|
|
7402
7792
|
this.opts = opts;
|
|
7403
7793
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
7404
7794
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -7417,11 +7807,11 @@ class GlobUtil {
|
|
|
7417
7807
|
});
|
|
7418
7808
|
}
|
|
7419
7809
|
}
|
|
7420
|
-
#ignored(
|
|
7421
|
-
return this.seen.has(
|
|
7810
|
+
#ignored(path14) {
|
|
7811
|
+
return this.seen.has(path14) || !!this.#ignore?.ignored?.(path14);
|
|
7422
7812
|
}
|
|
7423
|
-
#childrenIgnored(
|
|
7424
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
7813
|
+
#childrenIgnored(path14) {
|
|
7814
|
+
return !!this.#ignore?.childrenIgnored?.(path14);
|
|
7425
7815
|
}
|
|
7426
7816
|
pause() {
|
|
7427
7817
|
this.paused = true;
|
|
@@ -7638,8 +8028,8 @@ var init_walker = __esm(() => {
|
|
|
7638
8028
|
init_processor();
|
|
7639
8029
|
GlobWalker = class GlobWalker extends GlobUtil {
|
|
7640
8030
|
matches = new Set;
|
|
7641
|
-
constructor(patterns,
|
|
7642
|
-
super(patterns,
|
|
8031
|
+
constructor(patterns, path14, opts) {
|
|
8032
|
+
super(patterns, path14, opts);
|
|
7643
8033
|
}
|
|
7644
8034
|
matchEmit(e) {
|
|
7645
8035
|
this.matches.add(e);
|
|
@@ -7676,8 +8066,8 @@ var init_walker = __esm(() => {
|
|
|
7676
8066
|
};
|
|
7677
8067
|
GlobStream = class GlobStream extends GlobUtil {
|
|
7678
8068
|
results;
|
|
7679
|
-
constructor(patterns,
|
|
7680
|
-
super(patterns,
|
|
8069
|
+
constructor(patterns, path14, opts) {
|
|
8070
|
+
super(patterns, path14, opts);
|
|
7681
8071
|
this.results = new Minipass({
|
|
7682
8072
|
signal: this.signal,
|
|
7683
8073
|
objectMode: true
|
|
@@ -8105,20 +8495,20 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
8105
8495
|
var throwError = (message, Ctor) => {
|
|
8106
8496
|
throw new Ctor(message);
|
|
8107
8497
|
};
|
|
8108
|
-
var checkPath = (
|
|
8109
|
-
if (!isString(
|
|
8498
|
+
var checkPath = (path14, originalPath, doThrow) => {
|
|
8499
|
+
if (!isString(path14)) {
|
|
8110
8500
|
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
8111
8501
|
}
|
|
8112
|
-
if (!
|
|
8502
|
+
if (!path14) {
|
|
8113
8503
|
return doThrow(`path must not be empty`, TypeError);
|
|
8114
8504
|
}
|
|
8115
|
-
if (checkPath.isNotRelative(
|
|
8505
|
+
if (checkPath.isNotRelative(path14)) {
|
|
8116
8506
|
const r = "`path.relative()`d";
|
|
8117
8507
|
return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
|
8118
8508
|
}
|
|
8119
8509
|
return true;
|
|
8120
8510
|
};
|
|
8121
|
-
var isNotRelative = (
|
|
8511
|
+
var isNotRelative = (path14) => REGEX_TEST_INVALID_PATH.test(path14);
|
|
8122
8512
|
checkPath.isNotRelative = isNotRelative;
|
|
8123
8513
|
checkPath.convert = (p) => p;
|
|
8124
8514
|
|
|
@@ -8161,7 +8551,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
8161
8551
|
addPattern(pattern) {
|
|
8162
8552
|
return this.add(pattern);
|
|
8163
8553
|
}
|
|
8164
|
-
_testOne(
|
|
8554
|
+
_testOne(path14, checkUnignored) {
|
|
8165
8555
|
let ignored = false;
|
|
8166
8556
|
let unignored = false;
|
|
8167
8557
|
this._rules.forEach((rule) => {
|
|
@@ -8169,7 +8559,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
8169
8559
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
8170
8560
|
return;
|
|
8171
8561
|
}
|
|
8172
|
-
const matched = rule.regex.test(
|
|
8562
|
+
const matched = rule.regex.test(path14);
|
|
8173
8563
|
if (matched) {
|
|
8174
8564
|
ignored = !negative;
|
|
8175
8565
|
unignored = negative;
|
|
@@ -8181,39 +8571,39 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
8181
8571
|
};
|
|
8182
8572
|
}
|
|
8183
8573
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
8184
|
-
const
|
|
8185
|
-
checkPath(
|
|
8186
|
-
return this._t(
|
|
8574
|
+
const path14 = originalPath && checkPath.convert(originalPath);
|
|
8575
|
+
checkPath(path14, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
8576
|
+
return this._t(path14, cache, checkUnignored, slices);
|
|
8187
8577
|
}
|
|
8188
|
-
_t(
|
|
8189
|
-
if (
|
|
8190
|
-
return cache[
|
|
8578
|
+
_t(path14, cache, checkUnignored, slices) {
|
|
8579
|
+
if (path14 in cache) {
|
|
8580
|
+
return cache[path14];
|
|
8191
8581
|
}
|
|
8192
8582
|
if (!slices) {
|
|
8193
|
-
slices =
|
|
8583
|
+
slices = path14.split(SLASH);
|
|
8194
8584
|
}
|
|
8195
8585
|
slices.pop();
|
|
8196
8586
|
if (!slices.length) {
|
|
8197
|
-
return cache[
|
|
8587
|
+
return cache[path14] = this._testOne(path14, checkUnignored);
|
|
8198
8588
|
}
|
|
8199
8589
|
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
8200
|
-
return cache[
|
|
8590
|
+
return cache[path14] = parent.ignored ? parent : this._testOne(path14, checkUnignored);
|
|
8201
8591
|
}
|
|
8202
|
-
ignores(
|
|
8203
|
-
return this._test(
|
|
8592
|
+
ignores(path14) {
|
|
8593
|
+
return this._test(path14, this._ignoreCache, false).ignored;
|
|
8204
8594
|
}
|
|
8205
8595
|
createFilter() {
|
|
8206
|
-
return (
|
|
8596
|
+
return (path14) => !this.ignores(path14);
|
|
8207
8597
|
}
|
|
8208
8598
|
filter(paths) {
|
|
8209
8599
|
return makeArray(paths).filter(this.createFilter());
|
|
8210
8600
|
}
|
|
8211
|
-
test(
|
|
8212
|
-
return this._test(
|
|
8601
|
+
test(path14) {
|
|
8602
|
+
return this._test(path14, this._testCache, true);
|
|
8213
8603
|
}
|
|
8214
8604
|
}
|
|
8215
8605
|
var factory = (options) => new Ignore2(options);
|
|
8216
|
-
var isPathValid = (
|
|
8606
|
+
var isPathValid = (path14) => checkPath(path14 && checkPath.convert(path14), path14, RETURN_FALSE);
|
|
8217
8607
|
factory.isPathValid = isPathValid;
|
|
8218
8608
|
factory.default = factory;
|
|
8219
8609
|
module.exports = factory;
|
|
@@ -8221,7 +8611,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
8221
8611
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
8222
8612
|
checkPath.convert = makePosix;
|
|
8223
8613
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
8224
|
-
checkPath.isNotRelative = (
|
|
8614
|
+
checkPath.isNotRelative = (path14) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path14) || isNotRelative(path14);
|
|
8225
8615
|
}
|
|
8226
8616
|
});
|
|
8227
8617
|
|
|
@@ -8283,13 +8673,13 @@ function validatePolicy(policy, opts = {}) {
|
|
|
8283
8673
|
}
|
|
8284
8674
|
}
|
|
8285
8675
|
}
|
|
8286
|
-
function matchesGlob2(
|
|
8676
|
+
function matchesGlob2(path14, pattern) {
|
|
8287
8677
|
let re = regexCache.get(pattern);
|
|
8288
8678
|
if (!re) {
|
|
8289
8679
|
re = globToRegex(pattern);
|
|
8290
8680
|
regexCache.set(pattern, re);
|
|
8291
8681
|
}
|
|
8292
|
-
return re.test(
|
|
8682
|
+
return re.test(path14);
|
|
8293
8683
|
}
|
|
8294
8684
|
var MAX_MATCH_WORK = 1e5, MAX_IGNORE_PATTERNS2 = 1024, DEFAULT_POLICY, applyPolicy = (filePath, policy) => {
|
|
8295
8685
|
const normalized = filePath.trim();
|
|
@@ -8340,8 +8730,8 @@ var init_capture_policy = __esm(() => {
|
|
|
8340
8730
|
});
|
|
8341
8731
|
|
|
8342
8732
|
// ../../packages/core/dist/services/search/ignore-patterns.js
|
|
8343
|
-
import
|
|
8344
|
-
import
|
|
8733
|
+
import fs9 from "fs/promises";
|
|
8734
|
+
import path14 from "path";
|
|
8345
8735
|
function buildExtensionGlob(extensions) {
|
|
8346
8736
|
return extensions.map((ext2) => `**/*${ext2}`);
|
|
8347
8737
|
}
|
|
@@ -8364,8 +8754,8 @@ async function loadProjectIgnore(projectPath) {
|
|
|
8364
8754
|
const ig = ignore();
|
|
8365
8755
|
ig.add(DEFAULT_IGNORES);
|
|
8366
8756
|
try {
|
|
8367
|
-
const gitignorePath =
|
|
8368
|
-
const gitignoreContent = await
|
|
8757
|
+
const gitignorePath = path14.join(projectPath, ".gitignore");
|
|
8758
|
+
const gitignoreContent = await fs9.readFile(gitignorePath, "utf8");
|
|
8369
8759
|
const rules = gitignoreContent.split(`
|
|
8370
8760
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
8371
8761
|
ig.add(rules);
|
|
@@ -9961,15 +10351,15 @@ var require_pg_connection_string = __commonJS((exports, module) => {
|
|
|
9961
10351
|
if (config2.sslnegotiation === "direct" && config2.ssl === undefined) {
|
|
9962
10352
|
config2.ssl = true;
|
|
9963
10353
|
}
|
|
9964
|
-
const
|
|
10354
|
+
const fs10 = config2.sslcert || config2.sslkey || config2.sslrootcert ? __require("fs") : null;
|
|
9965
10355
|
if (config2.sslcert) {
|
|
9966
|
-
config2.ssl.cert =
|
|
10356
|
+
config2.ssl.cert = fs10.readFileSync(config2.sslcert).toString();
|
|
9967
10357
|
}
|
|
9968
10358
|
if (config2.sslkey) {
|
|
9969
|
-
config2.ssl.key =
|
|
10359
|
+
config2.ssl.key = fs10.readFileSync(config2.sslkey).toString();
|
|
9970
10360
|
}
|
|
9971
10361
|
if (config2.sslrootcert) {
|
|
9972
|
-
config2.ssl.ca =
|
|
10362
|
+
config2.ssl.ca = fs10.readFileSync(config2.sslrootcert).toString();
|
|
9973
10363
|
}
|
|
9974
10364
|
if (options.useLibpqCompat && config2.uselibpqcompat) {
|
|
9975
10365
|
throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");
|
|
@@ -11683,7 +12073,7 @@ var require_split2 = __commonJS((exports, module) => {
|
|
|
11683
12073
|
|
|
11684
12074
|
// ../../node_modules/pgpass/lib/helper.js
|
|
11685
12075
|
var require_helper = __commonJS((exports, module) => {
|
|
11686
|
-
var
|
|
12076
|
+
var path15 = __require("path");
|
|
11687
12077
|
var Stream2 = __require("stream").Stream;
|
|
11688
12078
|
var split = require_split2();
|
|
11689
12079
|
var util = __require("util");
|
|
@@ -11723,7 +12113,7 @@ var require_helper = __commonJS((exports, module) => {
|
|
|
11723
12113
|
};
|
|
11724
12114
|
exports.getFileName = function(rawEnv) {
|
|
11725
12115
|
var env = rawEnv || process.env;
|
|
11726
|
-
var file = env.PGPASSFILE || (isWin ?
|
|
12116
|
+
var file = env.PGPASSFILE || (isWin ? path15.join(env.APPDATA || "./", "postgresql", "pgpass.conf") : path15.join(env.HOME || "./", ".pgpass"));
|
|
11727
12117
|
return file;
|
|
11728
12118
|
};
|
|
11729
12119
|
exports.usePgPass = function(stats, fname) {
|
|
@@ -11847,16 +12237,16 @@ var require_helper = __commonJS((exports, module) => {
|
|
|
11847
12237
|
|
|
11848
12238
|
// ../../node_modules/pgpass/lib/index.js
|
|
11849
12239
|
var require_lib = __commonJS((exports, module) => {
|
|
11850
|
-
var
|
|
11851
|
-
var
|
|
12240
|
+
var path15 = __require("path");
|
|
12241
|
+
var fs10 = __require("fs");
|
|
11852
12242
|
var helper = require_helper();
|
|
11853
12243
|
module.exports = function(connInfo, cb) {
|
|
11854
12244
|
var file = helper.getFileName();
|
|
11855
|
-
|
|
12245
|
+
fs10.stat(file, function(err, stat) {
|
|
11856
12246
|
if (err || !helper.usePgPass(stat, file)) {
|
|
11857
12247
|
return cb(undefined);
|
|
11858
12248
|
}
|
|
11859
|
-
var st =
|
|
12249
|
+
var st = fs10.createReadStream(file);
|
|
11860
12250
|
helper.getPassword(connInfo, st, cb);
|
|
11861
12251
|
});
|
|
11862
12252
|
};
|
|
@@ -13555,8 +13945,8 @@ var init_alias_resolver = __esm(() => {
|
|
|
13555
13945
|
});
|
|
13556
13946
|
|
|
13557
13947
|
// ../../packages/core/dist/services/search/index-manager.js
|
|
13558
|
-
import
|
|
13559
|
-
import
|
|
13948
|
+
import fs10 from "fs";
|
|
13949
|
+
import path15 from "path";
|
|
13560
13950
|
|
|
13561
13951
|
class IndexManager {
|
|
13562
13952
|
metadataCache = new Map;
|
|
@@ -13649,9 +14039,9 @@ class IndexManager {
|
|
|
13649
14039
|
const fileMetadata = {};
|
|
13650
14040
|
let totalSize = 0;
|
|
13651
14041
|
for (const filePath of indexedFiles) {
|
|
13652
|
-
const fullPath =
|
|
14042
|
+
const fullPath = path15.join(projectPath, filePath);
|
|
13653
14043
|
try {
|
|
13654
|
-
const stat = await
|
|
14044
|
+
const stat = await fs10.promises.stat(fullPath);
|
|
13655
14045
|
fileMetadata[filePath] = {
|
|
13656
14046
|
path: filePath,
|
|
13657
14047
|
mtime: stat.mtimeMs,
|
|
@@ -13702,9 +14092,9 @@ class IndexManager {
|
|
|
13702
14092
|
if (ig.ignores(match2)) {
|
|
13703
14093
|
continue;
|
|
13704
14094
|
}
|
|
13705
|
-
const fullPath =
|
|
14095
|
+
const fullPath = path15.join(projectPath, match2);
|
|
13706
14096
|
try {
|
|
13707
|
-
const stat = await
|
|
14097
|
+
const stat = await fs10.promises.stat(fullPath);
|
|
13708
14098
|
files.set(match2, {
|
|
13709
14099
|
path: match2,
|
|
13710
14100
|
mtime: stat.mtimeMs,
|
|
@@ -14155,10 +14545,10 @@ function mergeDefs(...defs) {
|
|
|
14155
14545
|
function cloneDef(schema) {
|
|
14156
14546
|
return mergeDefs(schema._zod.def);
|
|
14157
14547
|
}
|
|
14158
|
-
function getElementAtPath(obj,
|
|
14159
|
-
if (!
|
|
14548
|
+
function getElementAtPath(obj, path16) {
|
|
14549
|
+
if (!path16)
|
|
14160
14550
|
return obj;
|
|
14161
|
-
return
|
|
14551
|
+
return path16.reduce((acc, key) => acc?.[key], obj);
|
|
14162
14552
|
}
|
|
14163
14553
|
function promiseAllObject(promisesObj) {
|
|
14164
14554
|
const keys = Object.keys(promisesObj);
|
|
@@ -14486,11 +14876,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
14486
14876
|
}
|
|
14487
14877
|
return false;
|
|
14488
14878
|
}
|
|
14489
|
-
function prefixIssues(
|
|
14879
|
+
function prefixIssues(path16, issues) {
|
|
14490
14880
|
return issues.map((iss) => {
|
|
14491
14881
|
var _a3;
|
|
14492
14882
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
14493
|
-
iss.path.unshift(
|
|
14883
|
+
iss.path.unshift(path16);
|
|
14494
14884
|
return iss;
|
|
14495
14885
|
});
|
|
14496
14886
|
}
|
|
@@ -14703,16 +15093,16 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
|
|
|
14703
15093
|
}
|
|
14704
15094
|
function formatError(error, mapper = (issue2) => issue2.message) {
|
|
14705
15095
|
const fieldErrors = { _errors: [] };
|
|
14706
|
-
const processError = (error2,
|
|
15096
|
+
const processError = (error2, path16 = []) => {
|
|
14707
15097
|
for (const issue2 of error2.issues) {
|
|
14708
15098
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
14709
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
15099
|
+
issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
|
|
14710
15100
|
} else if (issue2.code === "invalid_key") {
|
|
14711
|
-
processError({ issues: issue2.issues }, [...
|
|
15101
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
14712
15102
|
} else if (issue2.code === "invalid_element") {
|
|
14713
|
-
processError({ issues: issue2.issues }, [...
|
|
15103
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
14714
15104
|
} else {
|
|
14715
|
-
const fullpath = [...
|
|
15105
|
+
const fullpath = [...path16, ...issue2.path];
|
|
14716
15106
|
if (fullpath.length === 0) {
|
|
14717
15107
|
fieldErrors._errors.push(mapper(issue2));
|
|
14718
15108
|
} else {
|
|
@@ -14739,17 +15129,17 @@ function formatError(error, mapper = (issue2) => issue2.message) {
|
|
|
14739
15129
|
}
|
|
14740
15130
|
function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
14741
15131
|
const result = { errors: [] };
|
|
14742
|
-
const processError = (error2,
|
|
15132
|
+
const processError = (error2, path16 = []) => {
|
|
14743
15133
|
var _a3, _b;
|
|
14744
15134
|
for (const issue2 of error2.issues) {
|
|
14745
15135
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
14746
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
15136
|
+
issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
|
|
14747
15137
|
} else if (issue2.code === "invalid_key") {
|
|
14748
|
-
processError({ issues: issue2.issues }, [...
|
|
15138
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
14749
15139
|
} else if (issue2.code === "invalid_element") {
|
|
14750
|
-
processError({ issues: issue2.issues }, [...
|
|
15140
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
14751
15141
|
} else {
|
|
14752
|
-
const fullpath = [...
|
|
15142
|
+
const fullpath = [...path16, ...issue2.path];
|
|
14753
15143
|
if (fullpath.length === 0) {
|
|
14754
15144
|
result.errors.push(mapper(issue2));
|
|
14755
15145
|
continue;
|
|
@@ -14781,8 +15171,8 @@ function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
|
14781
15171
|
}
|
|
14782
15172
|
function toDotPath(_path) {
|
|
14783
15173
|
const segs = [];
|
|
14784
|
-
const
|
|
14785
|
-
for (const seg of
|
|
15174
|
+
const path16 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
15175
|
+
for (const seg of path16) {
|
|
14786
15176
|
if (typeof seg === "number")
|
|
14787
15177
|
segs.push(`[${seg}]`);
|
|
14788
15178
|
else if (typeof seg === "symbol")
|
|
@@ -27785,13 +28175,13 @@ function resolveRef(ref, ctx) {
|
|
|
27785
28175
|
if (!ref.startsWith("#")) {
|
|
27786
28176
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
27787
28177
|
}
|
|
27788
|
-
const
|
|
27789
|
-
if (
|
|
28178
|
+
const path16 = ref.slice(1).split("/").filter(Boolean);
|
|
28179
|
+
if (path16.length === 0) {
|
|
27790
28180
|
return ctx.rootSchema;
|
|
27791
28181
|
}
|
|
27792
28182
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
27793
|
-
if (
|
|
27794
|
-
const key =
|
|
28183
|
+
if (path16[0] === defsKey) {
|
|
28184
|
+
const key = path16[1];
|
|
27795
28185
|
if (!key || !ctx.defs[key]) {
|
|
27796
28186
|
throw new Error(`Reference not found: ${ref}`);
|
|
27797
28187
|
}
|
|
@@ -29280,8 +29670,8 @@ class ParseStatus {
|
|
|
29280
29670
|
}
|
|
29281
29671
|
}
|
|
29282
29672
|
var makeIssue = (params) => {
|
|
29283
|
-
const { data, path:
|
|
29284
|
-
const fullPath = [...
|
|
29673
|
+
const { data, path: path16, errorMaps, issueData } = params;
|
|
29674
|
+
const fullPath = [...path16, ...issueData.path || []];
|
|
29285
29675
|
const fullIssue = {
|
|
29286
29676
|
...issueData,
|
|
29287
29677
|
path: fullPath
|
|
@@ -29326,11 +29716,11 @@ var init_errorUtil = __esm(() => {
|
|
|
29326
29716
|
|
|
29327
29717
|
// ../../node_modules/zod/v3/types.js
|
|
29328
29718
|
class ParseInputLazyPath {
|
|
29329
|
-
constructor(parent, value,
|
|
29719
|
+
constructor(parent, value, path16, key) {
|
|
29330
29720
|
this._cachedPath = [];
|
|
29331
29721
|
this.parent = parent;
|
|
29332
29722
|
this.data = value;
|
|
29333
|
-
this._path =
|
|
29723
|
+
this._path = path16;
|
|
29334
29724
|
this._key = key;
|
|
29335
29725
|
}
|
|
29336
29726
|
get path() {
|
|
@@ -35327,19 +35717,19 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
35327
35717
|
getUserDataDir: () => getUserDataDir
|
|
35328
35718
|
});
|
|
35329
35719
|
module.exports = __toCommonJS2(token_io_exports);
|
|
35330
|
-
var
|
|
35331
|
-
var
|
|
35720
|
+
var import_path9 = __toESM2(__require("path"));
|
|
35721
|
+
var import_fs6 = __toESM2(__require("fs"));
|
|
35332
35722
|
var import_os3 = __toESM2(__require("os"));
|
|
35333
35723
|
var import_token_error = require_token_error();
|
|
35334
35724
|
function findRootDir() {
|
|
35335
35725
|
try {
|
|
35336
35726
|
let dir = process.cwd();
|
|
35337
|
-
while (dir !==
|
|
35338
|
-
const pkgPath =
|
|
35339
|
-
if (
|
|
35727
|
+
while (dir !== import_path9.default.dirname(dir)) {
|
|
35728
|
+
const pkgPath = import_path9.default.join(dir, ".vercel");
|
|
35729
|
+
if (import_fs6.default.existsSync(pkgPath)) {
|
|
35340
35730
|
return dir;
|
|
35341
35731
|
}
|
|
35342
|
-
dir =
|
|
35732
|
+
dir = import_path9.default.dirname(dir);
|
|
35343
35733
|
}
|
|
35344
35734
|
} catch (e) {
|
|
35345
35735
|
throw new import_token_error.VercelOidcTokenError("Token refresh only supported in node server environments");
|
|
@@ -35352,9 +35742,9 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
35352
35742
|
}
|
|
35353
35743
|
switch (import_os3.default.platform()) {
|
|
35354
35744
|
case "darwin":
|
|
35355
|
-
return
|
|
35745
|
+
return import_path9.default.join(import_os3.default.homedir(), "Library/Application Support");
|
|
35356
35746
|
case "linux":
|
|
35357
|
-
return
|
|
35747
|
+
return import_path9.default.join(import_os3.default.homedir(), ".local/share");
|
|
35358
35748
|
case "win32":
|
|
35359
35749
|
if (process.env.LOCALAPPDATA) {
|
|
35360
35750
|
return process.env.LOCALAPPDATA;
|
|
@@ -35395,23 +35785,23 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
35395
35785
|
writeAuthConfig: () => writeAuthConfig
|
|
35396
35786
|
});
|
|
35397
35787
|
module.exports = __toCommonJS2(auth_config_exports);
|
|
35398
|
-
var
|
|
35399
|
-
var
|
|
35788
|
+
var fs11 = __toESM2(__require("fs"));
|
|
35789
|
+
var path16 = __toESM2(__require("path"));
|
|
35400
35790
|
var import_token_util = require_token_util();
|
|
35401
35791
|
function getAuthConfigPath() {
|
|
35402
35792
|
const dataDir = (0, import_token_util.getVercelDataDir)();
|
|
35403
35793
|
if (!dataDir) {
|
|
35404
35794
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
35405
35795
|
}
|
|
35406
|
-
return
|
|
35796
|
+
return path16.join(dataDir, "auth.json");
|
|
35407
35797
|
}
|
|
35408
35798
|
function readAuthConfig() {
|
|
35409
35799
|
try {
|
|
35410
35800
|
const authPath = getAuthConfigPath();
|
|
35411
|
-
if (!
|
|
35801
|
+
if (!fs11.existsSync(authPath)) {
|
|
35412
35802
|
return null;
|
|
35413
35803
|
}
|
|
35414
|
-
const content =
|
|
35804
|
+
const content = fs11.readFileSync(authPath, "utf8");
|
|
35415
35805
|
if (!content) {
|
|
35416
35806
|
return null;
|
|
35417
35807
|
}
|
|
@@ -35422,11 +35812,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
35422
35812
|
}
|
|
35423
35813
|
function writeAuthConfig(config3) {
|
|
35424
35814
|
const authPath = getAuthConfigPath();
|
|
35425
|
-
const authDir =
|
|
35426
|
-
if (!
|
|
35427
|
-
|
|
35815
|
+
const authDir = path16.dirname(authPath);
|
|
35816
|
+
if (!fs11.existsSync(authDir)) {
|
|
35817
|
+
fs11.mkdirSync(authDir, { mode: 504, recursive: true });
|
|
35428
35818
|
}
|
|
35429
|
-
|
|
35819
|
+
fs11.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
|
|
35430
35820
|
}
|
|
35431
35821
|
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
35432
35822
|
if (!authConfig.token)
|
|
@@ -35601,8 +35991,8 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
35601
35991
|
saveToken: () => saveToken
|
|
35602
35992
|
});
|
|
35603
35993
|
module.exports = __toCommonJS2(token_util_exports);
|
|
35604
|
-
var
|
|
35605
|
-
var
|
|
35994
|
+
var path16 = __toESM2(__require("path"));
|
|
35995
|
+
var fs11 = __toESM2(__require("fs"));
|
|
35606
35996
|
var import_token_error = require_token_error();
|
|
35607
35997
|
var import_token_io = require_token_io();
|
|
35608
35998
|
var import_auth_config = require_auth_config();
|
|
@@ -35614,7 +36004,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
35614
36004
|
if (!dataDir) {
|
|
35615
36005
|
return null;
|
|
35616
36006
|
}
|
|
35617
|
-
return
|
|
36007
|
+
return path16.join(dataDir, vercelFolder);
|
|
35618
36008
|
}
|
|
35619
36009
|
async function getVercelToken2(options) {
|
|
35620
36010
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -35682,11 +36072,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
35682
36072
|
if (!dir) {
|
|
35683
36073
|
throw new import_token_error.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");
|
|
35684
36074
|
}
|
|
35685
|
-
const prjPath =
|
|
35686
|
-
if (!
|
|
36075
|
+
const prjPath = path16.join(dir, ".vercel", "project.json");
|
|
36076
|
+
if (!fs11.existsSync(prjPath)) {
|
|
35687
36077
|
throw new import_token_error.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");
|
|
35688
36078
|
}
|
|
35689
|
-
const prj = JSON.parse(
|
|
36079
|
+
const prj = JSON.parse(fs11.readFileSync(prjPath, "utf8"));
|
|
35690
36080
|
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
|
|
35691
36081
|
throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");
|
|
35692
36082
|
}
|
|
@@ -35697,11 +36087,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
35697
36087
|
if (!dir) {
|
|
35698
36088
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
35699
36089
|
}
|
|
35700
|
-
const tokenPath =
|
|
36090
|
+
const tokenPath = path16.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
35701
36091
|
const tokenJson = JSON.stringify(token);
|
|
35702
|
-
|
|
35703
|
-
|
|
35704
|
-
|
|
36092
|
+
fs11.mkdirSync(path16.dirname(tokenPath), { mode: 504, recursive: true });
|
|
36093
|
+
fs11.writeFileSync(tokenPath, tokenJson);
|
|
36094
|
+
fs11.chmodSync(tokenPath, 432);
|
|
35705
36095
|
return;
|
|
35706
36096
|
}
|
|
35707
36097
|
function loadToken(projectId) {
|
|
@@ -35709,11 +36099,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
35709
36099
|
if (!dir) {
|
|
35710
36100
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
35711
36101
|
}
|
|
35712
|
-
const tokenPath =
|
|
35713
|
-
if (!
|
|
36102
|
+
const tokenPath = path16.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
36103
|
+
if (!fs11.existsSync(tokenPath)) {
|
|
35714
36104
|
return null;
|
|
35715
36105
|
}
|
|
35716
|
-
const token = JSON.parse(
|
|
36106
|
+
const token = JSON.parse(fs11.readFileSync(tokenPath, "utf8"));
|
|
35717
36107
|
assertVercelOidcTokenResponse(token);
|
|
35718
36108
|
return token;
|
|
35719
36109
|
}
|
|
@@ -46555,37 +46945,37 @@ function createOpenAI(options = {}) {
|
|
|
46555
46945
|
}, `ai-sdk/openai/${VERSION4}`);
|
|
46556
46946
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
46557
46947
|
provider: `${providerName}.chat`,
|
|
46558
|
-
url: ({ path:
|
|
46948
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
46559
46949
|
headers: getHeaders,
|
|
46560
46950
|
fetch: options.fetch
|
|
46561
46951
|
});
|
|
46562
46952
|
const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
|
|
46563
46953
|
provider: `${providerName}.completion`,
|
|
46564
|
-
url: ({ path:
|
|
46954
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
46565
46955
|
headers: getHeaders,
|
|
46566
46956
|
fetch: options.fetch
|
|
46567
46957
|
});
|
|
46568
46958
|
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
46569
46959
|
provider: `${providerName}.embedding`,
|
|
46570
|
-
url: ({ path:
|
|
46960
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
46571
46961
|
headers: getHeaders,
|
|
46572
46962
|
fetch: options.fetch
|
|
46573
46963
|
});
|
|
46574
46964
|
const createImageModel = (modelId) => new OpenAIImageModel(modelId, {
|
|
46575
46965
|
provider: `${providerName}.image`,
|
|
46576
|
-
url: ({ path:
|
|
46966
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
46577
46967
|
headers: getHeaders,
|
|
46578
46968
|
fetch: options.fetch
|
|
46579
46969
|
});
|
|
46580
46970
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
46581
46971
|
provider: `${providerName}.transcription`,
|
|
46582
|
-
url: ({ path:
|
|
46972
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
46583
46973
|
headers: getHeaders,
|
|
46584
46974
|
fetch: options.fetch
|
|
46585
46975
|
});
|
|
46586
46976
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
46587
46977
|
provider: `${providerName}.speech`,
|
|
46588
|
-
url: ({ path:
|
|
46978
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
46589
46979
|
headers: getHeaders,
|
|
46590
46980
|
fetch: options.fetch
|
|
46591
46981
|
});
|
|
@@ -46598,7 +46988,7 @@ function createOpenAI(options = {}) {
|
|
|
46598
46988
|
const createResponsesModel = (modelId) => {
|
|
46599
46989
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
46600
46990
|
provider: `${providerName}.responses`,
|
|
46601
|
-
url: ({ path:
|
|
46991
|
+
url: ({ path: path16 }) => `${baseURL}${path16}`,
|
|
46602
46992
|
headers: getHeaders,
|
|
46603
46993
|
fetch: options.fetch,
|
|
46604
46994
|
fileIdPrefixes: ["file-"]
|
|
@@ -63143,26 +63533,26 @@ var require_process = __commonJS((exports, module) => {
|
|
|
63143
63533
|
|
|
63144
63534
|
// ../../node_modules/detect-libc/lib/filesystem.js
|
|
63145
63535
|
var require_filesystem = __commonJS((exports, module) => {
|
|
63146
|
-
var
|
|
63536
|
+
var fs11 = __require("fs");
|
|
63147
63537
|
var LDD_PATH = "/usr/bin/ldd";
|
|
63148
63538
|
var SELF_PATH = "/proc/self/exe";
|
|
63149
63539
|
var MAX_LENGTH = 2048;
|
|
63150
|
-
var readFileSync2 = (
|
|
63151
|
-
const fd =
|
|
63540
|
+
var readFileSync2 = (path16) => {
|
|
63541
|
+
const fd = fs11.openSync(path16, "r");
|
|
63152
63542
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
63153
|
-
const bytesRead =
|
|
63154
|
-
|
|
63543
|
+
const bytesRead = fs11.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
63544
|
+
fs11.close(fd, () => {});
|
|
63155
63545
|
return buffer.subarray(0, bytesRead);
|
|
63156
63546
|
};
|
|
63157
|
-
var readFile = (
|
|
63158
|
-
|
|
63547
|
+
var readFile = (path16) => new Promise((resolve4, reject) => {
|
|
63548
|
+
fs11.open(path16, "r", (err, fd) => {
|
|
63159
63549
|
if (err) {
|
|
63160
63550
|
reject(err);
|
|
63161
63551
|
} else {
|
|
63162
63552
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
63163
|
-
|
|
63553
|
+
fs11.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
63164
63554
|
resolve4(buffer.subarray(0, bytesRead));
|
|
63165
|
-
|
|
63555
|
+
fs11.close(fd, () => {});
|
|
63166
63556
|
});
|
|
63167
63557
|
}
|
|
63168
63558
|
});
|
|
@@ -63267,11 +63657,11 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
63267
63657
|
}
|
|
63268
63658
|
return null;
|
|
63269
63659
|
};
|
|
63270
|
-
var familyFromInterpreterPath = (
|
|
63271
|
-
if (
|
|
63272
|
-
if (
|
|
63660
|
+
var familyFromInterpreterPath = (path16) => {
|
|
63661
|
+
if (path16) {
|
|
63662
|
+
if (path16.includes("/ld-musl-")) {
|
|
63273
63663
|
return MUSL;
|
|
63274
|
-
} else if (
|
|
63664
|
+
} else if (path16.includes("/ld-linux-")) {
|
|
63275
63665
|
return GLIBC;
|
|
63276
63666
|
}
|
|
63277
63667
|
}
|
|
@@ -63316,8 +63706,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
63316
63706
|
cachedFamilyInterpreter = null;
|
|
63317
63707
|
try {
|
|
63318
63708
|
const selfContent = await readFile(SELF_PATH);
|
|
63319
|
-
const
|
|
63320
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
63709
|
+
const path16 = interpreterPath(selfContent);
|
|
63710
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path16);
|
|
63321
63711
|
} catch (e) {}
|
|
63322
63712
|
return cachedFamilyInterpreter;
|
|
63323
63713
|
};
|
|
@@ -63328,8 +63718,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
63328
63718
|
cachedFamilyInterpreter = null;
|
|
63329
63719
|
try {
|
|
63330
63720
|
const selfContent = readFileSync2(SELF_PATH);
|
|
63331
|
-
const
|
|
63332
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
63721
|
+
const path16 = interpreterPath(selfContent);
|
|
63722
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path16);
|
|
63333
63723
|
} catch (e) {}
|
|
63334
63724
|
return cachedFamilyInterpreter;
|
|
63335
63725
|
};
|
|
@@ -64991,18 +65381,18 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
64991
65381
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
64992
65382
|
"@img/sharp-wasm32/sharp.node"
|
|
64993
65383
|
];
|
|
64994
|
-
var
|
|
65384
|
+
var path16;
|
|
64995
65385
|
var sharp;
|
|
64996
65386
|
var errors4 = [];
|
|
64997
|
-
for (
|
|
65387
|
+
for (path16 of paths) {
|
|
64998
65388
|
try {
|
|
64999
|
-
sharp = __require(
|
|
65389
|
+
sharp = __require(path16);
|
|
65000
65390
|
break;
|
|
65001
65391
|
} catch (err) {
|
|
65002
65392
|
errors4.push(err);
|
|
65003
65393
|
}
|
|
65004
65394
|
}
|
|
65005
|
-
if (sharp &&
|
|
65395
|
+
if (sharp && path16.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
65006
65396
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
65007
65397
|
err.code = "Unsupported CPU";
|
|
65008
65398
|
errors4.push(err);
|
|
@@ -65011,7 +65401,7 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
65011
65401
|
if (sharp) {
|
|
65012
65402
|
module.exports = sharp;
|
|
65013
65403
|
} else {
|
|
65014
|
-
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((
|
|
65404
|
+
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((os8) => runtimePlatform.startsWith(os8));
|
|
65015
65405
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
65016
65406
|
errors4.forEach((err) => {
|
|
65017
65407
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -65024,9 +65414,9 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
65024
65414
|
const { found, expected } = isUnsupportedNodeRuntime();
|
|
65025
65415
|
help.push("- Please upgrade Node.js:", ` Found ${found}`, ` Requires ${expected}`);
|
|
65026
65416
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
65027
|
-
const [
|
|
65028
|
-
const libc =
|
|
65029
|
-
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=${
|
|
65417
|
+
const [os8, cpu] = runtimePlatform.split("-");
|
|
65418
|
+
const libc = os8.endsWith("musl") ? " --libc=musl" : "";
|
|
65419
|
+
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`);
|
|
65030
65420
|
} else {
|
|
65031
65421
|
help.push(`- Manually install libvips >= ${minimumLibvipsVersion}`, "- Add experimental WebAssembly-based dependencies:", " npm install --cpu=wasm32 sharp", " npm install @img/sharp-wasm32");
|
|
65032
65422
|
}
|
|
@@ -66286,7 +66676,7 @@ var require_operation = __commonJS((exports, module) => {
|
|
|
66286
66676
|
float: "float",
|
|
66287
66677
|
approximate: "approximate"
|
|
66288
66678
|
};
|
|
66289
|
-
function
|
|
66679
|
+
function rotate2(angle, options) {
|
|
66290
66680
|
if (!is.defined(angle)) {
|
|
66291
66681
|
return this.autoOrient();
|
|
66292
66682
|
}
|
|
@@ -66713,7 +67103,7 @@ var require_operation = __commonJS((exports, module) => {
|
|
|
66713
67103
|
module.exports = (Sharp) => {
|
|
66714
67104
|
Object.assign(Sharp.prototype, {
|
|
66715
67105
|
autoOrient,
|
|
66716
|
-
rotate,
|
|
67106
|
+
rotate: rotate2,
|
|
66717
67107
|
flip,
|
|
66718
67108
|
flop,
|
|
66719
67109
|
affine,
|
|
@@ -67864,15 +68254,15 @@ var require_color = __commonJS((exports, module) => {
|
|
|
67864
68254
|
};
|
|
67865
68255
|
}
|
|
67866
68256
|
function wrapConversion(toModel, graph) {
|
|
67867
|
-
const
|
|
68257
|
+
const path16 = [graph[toModel].parent, toModel];
|
|
67868
68258
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
67869
68259
|
let cur = graph[toModel].parent;
|
|
67870
68260
|
while (graph[cur].parent) {
|
|
67871
|
-
|
|
68261
|
+
path16.unshift(graph[cur].parent);
|
|
67872
68262
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
67873
68263
|
cur = graph[cur].parent;
|
|
67874
68264
|
}
|
|
67875
|
-
fn.conversion =
|
|
68265
|
+
fn.conversion = path16;
|
|
67876
68266
|
return fn;
|
|
67877
68267
|
}
|
|
67878
68268
|
function route(fromModel) {
|
|
@@ -68477,7 +68867,7 @@ var require_output = __commonJS((exports, module) => {
|
|
|
68477
68867
|
Copyright 2013 Lovell Fuller and others.
|
|
68478
68868
|
SPDX-License-Identifier: Apache-2.0
|
|
68479
68869
|
*/
|
|
68480
|
-
var
|
|
68870
|
+
var path16 = __require("path");
|
|
68481
68871
|
var is = require_is();
|
|
68482
68872
|
var sharp = require_sharp();
|
|
68483
68873
|
var formats = new Map([
|
|
@@ -68508,9 +68898,9 @@ var require_output = __commonJS((exports, module) => {
|
|
|
68508
68898
|
let err;
|
|
68509
68899
|
if (!is.string(fileOut)) {
|
|
68510
68900
|
err = new Error("Missing output file path");
|
|
68511
|
-
} else if (is.string(this.options.input.file) &&
|
|
68901
|
+
} else if (is.string(this.options.input.file) && path16.resolve(this.options.input.file) === path16.resolve(fileOut)) {
|
|
68512
68902
|
err = new Error("Cannot use same file for input and output");
|
|
68513
|
-
} else if (jp2Regex.test(
|
|
68903
|
+
} else if (jp2Regex.test(path16.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
68514
68904
|
err = errJp2Save();
|
|
68515
68905
|
}
|
|
68516
68906
|
if (err) {
|
|
@@ -75757,11 +76147,11 @@ var init_transformers_node = __esm(() => {
|
|
|
75757
76147
|
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}).`);
|
|
75758
76148
|
}
|
|
75759
76149
|
for (let i = 0;i < num_chunks; ++i) {
|
|
75760
|
-
const
|
|
75761
|
-
const fullPath = `${options.subfolder ?? ""}/${
|
|
76150
|
+
const path16 = `${baseName}_data${i === 0 ? "" : "_" + i}`;
|
|
76151
|
+
const fullPath = `${options.subfolder ?? ""}/${path16}`;
|
|
75762
76152
|
externalDataPromises.push(new Promise(async (resolve4, reject) => {
|
|
75763
76153
|
const data = await (0, _utils_hub_js__WEBPACK_IMPORTED_MODULE_5__.getModelFile)(pretrained_model_name_or_path, fullPath, true, options, return_path);
|
|
75764
|
-
resolve4(data instanceof Uint8Array ? { path:
|
|
76154
|
+
resolve4(data instanceof Uint8Array ? { path: path16, data } : path16);
|
|
75765
76155
|
}));
|
|
75766
76156
|
}
|
|
75767
76157
|
} else if (session_options.externalData !== undefined) {
|
|
@@ -88825,7 +89215,7 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
88825
89215
|
const blob = new Blob([wav], { type: "audio/wav" });
|
|
88826
89216
|
return blob;
|
|
88827
89217
|
}
|
|
88828
|
-
async save(
|
|
89218
|
+
async save(path16) {
|
|
88829
89219
|
let fn;
|
|
88830
89220
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_BROWSER_ENV) {
|
|
88831
89221
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_WEBWORKER_ENV) {
|
|
@@ -88833,14 +89223,14 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
88833
89223
|
}
|
|
88834
89224
|
fn = _core_js__WEBPACK_IMPORTED_MODULE_2__.saveBlob;
|
|
88835
89225
|
} else if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_FS_AVAILABLE) {
|
|
88836
|
-
fn = async (
|
|
89226
|
+
fn = async (path17, blob) => {
|
|
88837
89227
|
let buffer = await blob.arrayBuffer();
|
|
88838
|
-
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(
|
|
89228
|
+
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(path17, Buffer.from(buffer));
|
|
88839
89229
|
};
|
|
88840
89230
|
} else {
|
|
88841
89231
|
throw new Error("Unable to save because filesystem is disabled in this environment.");
|
|
88842
89232
|
}
|
|
88843
|
-
await fn(
|
|
89233
|
+
await fn(path16, this.toBlob());
|
|
88844
89234
|
}
|
|
88845
89235
|
}
|
|
88846
89236
|
},
|
|
@@ -88936,11 +89326,11 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
88936
89326
|
function calculateReflectOffset(i, w) {
|
|
88937
89327
|
return Math.abs((i + w) % (2 * w) - w);
|
|
88938
89328
|
}
|
|
88939
|
-
function saveBlob(
|
|
89329
|
+
function saveBlob(path16, blob) {
|
|
88940
89330
|
const dataURL = URL.createObjectURL(blob);
|
|
88941
89331
|
const downloadLink = document.createElement("a");
|
|
88942
89332
|
downloadLink.href = dataURL;
|
|
88943
|
-
downloadLink.download =
|
|
89333
|
+
downloadLink.download = path16;
|
|
88944
89334
|
downloadLink.click();
|
|
88945
89335
|
downloadLink.remove();
|
|
88946
89336
|
URL.revokeObjectURL(dataURL);
|
|
@@ -89541,8 +89931,8 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
89541
89931
|
}
|
|
89542
89932
|
|
|
89543
89933
|
class FileCache {
|
|
89544
|
-
constructor(
|
|
89545
|
-
this.path =
|
|
89934
|
+
constructor(path16) {
|
|
89935
|
+
this.path = path16;
|
|
89546
89936
|
}
|
|
89547
89937
|
async match(request) {
|
|
89548
89938
|
let filePath = node_path__WEBPACK_IMPORTED_MODULE_1__["default"].join(this.path, request);
|
|
@@ -90298,20 +90688,20 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90298
90688
|
}
|
|
90299
90689
|
return this;
|
|
90300
90690
|
}
|
|
90301
|
-
async save(
|
|
90691
|
+
async save(path16) {
|
|
90302
90692
|
if (IS_BROWSER_OR_WEBWORKER) {
|
|
90303
90693
|
if (_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_WEBWORKER_ENV) {
|
|
90304
90694
|
throw new Error("Unable to save an image from a Web Worker.");
|
|
90305
90695
|
}
|
|
90306
|
-
const extension =
|
|
90696
|
+
const extension = path16.split(".").pop().toLowerCase();
|
|
90307
90697
|
const mime = CONTENT_TYPE_MAP.get(extension) ?? "image/png";
|
|
90308
90698
|
const blob = await this.toBlob(mime);
|
|
90309
|
-
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(
|
|
90699
|
+
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(path16, blob);
|
|
90310
90700
|
} else if (!_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_FS_AVAILABLE) {
|
|
90311
90701
|
throw new Error("Unable to save the image because filesystem is disabled in this environment.");
|
|
90312
90702
|
} else {
|
|
90313
90703
|
const img = this.toSharp();
|
|
90314
|
-
return await img.toFile(
|
|
90704
|
+
return await img.toFile(path16);
|
|
90315
90705
|
}
|
|
90316
90706
|
}
|
|
90317
90707
|
toSharp() {
|
|
@@ -93838,20 +94228,20 @@ function getRetryDelay(attempt, config3) {
|
|
|
93838
94228
|
return Math.min(delay2, config3.maxDelay);
|
|
93839
94229
|
}
|
|
93840
94230
|
async function withRetry(fn, config3, context2) {
|
|
93841
|
-
let
|
|
94231
|
+
let lastError2;
|
|
93842
94232
|
for (let attempt = 0;attempt <= config3.maxRetries; attempt++) {
|
|
93843
94233
|
try {
|
|
93844
94234
|
return await fn();
|
|
93845
94235
|
} catch (error51) {
|
|
93846
|
-
|
|
94236
|
+
lastError2 = error51;
|
|
93847
94237
|
if (attempt < config3.maxRetries) {
|
|
93848
94238
|
const delay2 = getRetryDelay(attempt, config3);
|
|
93849
|
-
logger.warn(`[EmbeddingProvider] ${context2} failed (attempt ${attempt + 1}/${config3.maxRetries + 1}), retrying in ${delay2}ms`, { error:
|
|
94239
|
+
logger.warn(`[EmbeddingProvider] ${context2} failed (attempt ${attempt + 1}/${config3.maxRetries + 1}), retrying in ${delay2}ms`, { error: lastError2.message });
|
|
93850
94240
|
await sleep(delay2);
|
|
93851
94241
|
}
|
|
93852
94242
|
}
|
|
93853
94243
|
}
|
|
93854
|
-
throw new Error(`${context2} failed after ${config3.maxRetries + 1} attempts: ${
|
|
94244
|
+
throw new Error(`${context2} failed after ${config3.maxRetries + 1} attempts: ${lastError2?.message}`);
|
|
93855
94245
|
}
|
|
93856
94246
|
async function withTimeout(fn, timeoutMs, context2) {
|
|
93857
94247
|
let timeoutId;
|
|
@@ -99537,7 +99927,7 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a;
|
|
|
99537
99927
|
function ns(e = Yo, t = Yo) {
|
|
99538
99928
|
return (r) => e(t(r));
|
|
99539
99929
|
}
|
|
99540
|
-
function
|
|
99930
|
+
function os8({ dataPath: e, modelName: t, args: r, runtimeDataModel: n }) {
|
|
99541
99931
|
let i = { modelName: t, args: r ?? {} }, o = dp(e);
|
|
99542
99932
|
if (!o || o.length === 0)
|
|
99543
99933
|
return i;
|
|
@@ -99842,10 +100232,10 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a;
|
|
|
99842
100232
|
super(t, "P2023", r);
|
|
99843
100233
|
}
|
|
99844
100234
|
};
|
|
99845
|
-
var
|
|
100235
|
+
var fs11 = new WeakMap;
|
|
99846
100236
|
function Ep(e) {
|
|
99847
|
-
let t =
|
|
99848
|
-
return t || (t = Object.entries(e),
|
|
100237
|
+
let t = fs11.get(e);
|
|
100238
|
+
return t || (t = Object.entries(e), fs11.set(e, t)), t;
|
|
99849
100239
|
}
|
|
99850
100240
|
function hs(e, t, r) {
|
|
99851
100241
|
switch (t.type) {
|
|
@@ -103410,7 +103800,7 @@ new PrismaClient({
|
|
|
103410
103800
|
let m = await es(this, d);
|
|
103411
103801
|
if (!d.model)
|
|
103412
103802
|
return m;
|
|
103413
|
-
let g =
|
|
103803
|
+
let g = os8({ dataPath: d.dataPath, modelName: d.model, args: d.args, runtimeDataModel: this._runtimeDataModel });
|
|
103414
103804
|
return Wo({ result: m, modelName: g.modelName, args: g.args, extensions: this._extensions, runtimeDataModel: this._runtimeDataModel, globalOmit: this._globalOmit });
|
|
103415
103805
|
};
|
|
103416
103806
|
return this._tracingHelper.runInChildSpan(s.operation, () => new zl.AsyncResource("prisma-client-request").runInAsyncScope(() => a(o)));
|
|
@@ -103813,7 +104203,7 @@ var require_prisma = __commonJS((exports) => {
|
|
|
103813
104203
|
Prisma.JsonNull = JsonNull2;
|
|
103814
104204
|
Prisma.AnyNull = AnyNull2;
|
|
103815
104205
|
Prisma.NullTypes = NullTypes2;
|
|
103816
|
-
var
|
|
104206
|
+
var path16 = __require("path");
|
|
103817
104207
|
exports.Prisma.TransactionIsolationLevel = makeStrictEnum2({
|
|
103818
104208
|
ReadUncommitted: "ReadUncommitted",
|
|
103819
104209
|
ReadCommitted: "ReadCommitted",
|
|
@@ -111326,7 +111716,7 @@ async function upsertWorkspace(ws) {
|
|
|
111326
111716
|
}, { timeout: 60000, maxWait: 1e4 });
|
|
111327
111717
|
}
|
|
111328
111718
|
async function updateWorkspaceStatus(projectId, status, opts) {
|
|
111329
|
-
const
|
|
111719
|
+
const lastError2 = typeof opts === "string" ? opts : opts?.lastError ?? null;
|
|
111330
111720
|
const filesCount = typeof opts === "object" ? opts?.filesCount : undefined;
|
|
111331
111721
|
const chunksCount = typeof opts === "object" ? opts?.chunksCount : undefined;
|
|
111332
111722
|
const symbolsCount = typeof opts === "object" ? opts?.symbolsCount : undefined;
|
|
@@ -111336,7 +111726,7 @@ async function updateWorkspaceStatus(projectId, status, opts) {
|
|
|
111336
111726
|
await tx.$executeRaw`
|
|
111337
111727
|
UPDATE workspaces SET
|
|
111338
111728
|
status = ${status},
|
|
111339
|
-
last_error = ${
|
|
111729
|
+
last_error = ${lastError2},
|
|
111340
111730
|
last_indexed_at = ${lastIndexedAt ?? null},
|
|
111341
111731
|
files_count = COALESCE(${filesCount ?? null}, files_count),
|
|
111342
111732
|
chunks_count = COALESCE(${chunksCount ?? null}, chunks_count),
|
|
@@ -116680,10 +117070,10 @@ var init_chunker_code = __esm(() => {
|
|
|
116680
117070
|
});
|
|
116681
117071
|
|
|
116682
117072
|
// ../../packages/core/dist/services/search/smart-chunker.js
|
|
116683
|
-
import
|
|
117073
|
+
import path16 from "path";
|
|
116684
117074
|
function smartChunk(content, filePath, config3 = {}) {
|
|
116685
117075
|
const cfg = { ...DEFAULT_CONFIG, ...config3 };
|
|
116686
|
-
const ext2 =
|
|
117076
|
+
const ext2 = path16.extname(filePath).toLowerCase();
|
|
116687
117077
|
const relativePath = filePath;
|
|
116688
117078
|
const fileImports = isCodeFile(ext2) ? extractFileImports(content, ext2) : undefined;
|
|
116689
117079
|
let chunks;
|
|
@@ -116990,8 +117380,8 @@ var init_managed_run_repository_pg = __esm(() => {
|
|
|
116990
117380
|
});
|
|
116991
117381
|
|
|
116992
117382
|
// ../../packages/core/dist/services/search/project-indexer.js
|
|
116993
|
-
import
|
|
116994
|
-
import
|
|
117383
|
+
import fs11 from "fs/promises";
|
|
117384
|
+
import path17 from "path";
|
|
116995
117385
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
116996
117386
|
async function runWithIndexLock(lockMap, projectId, work) {
|
|
116997
117387
|
const prevLock = lockMap.get(projectId);
|
|
@@ -117034,7 +117424,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
117034
117424
|
dot: false
|
|
117035
117425
|
});
|
|
117036
117426
|
const filteredFiles = files.filter((file2) => {
|
|
117037
|
-
const relativePath =
|
|
117427
|
+
const relativePath = path17.relative(projectPath, file2);
|
|
117038
117428
|
const shouldIgnore = ig.ignores(relativePath);
|
|
117039
117429
|
if (shouldIgnore) {
|
|
117040
117430
|
logger.debug("Ignoring file per .gitignore during indexing", {
|
|
@@ -117074,7 +117464,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
117074
117464
|
});
|
|
117075
117465
|
}
|
|
117076
117466
|
}
|
|
117077
|
-
const indexedFilesList = filteredFiles.map((f) =>
|
|
117467
|
+
const indexedFilesList = filteredFiles.map((f) => path17.relative(projectPath, f));
|
|
117078
117468
|
await deps.indexManager.updateIndexMetadata(projectId, projectPath, indexedFilesList);
|
|
117079
117469
|
logger.info("Project indexing completed", {
|
|
117080
117470
|
projectId,
|
|
@@ -117199,7 +117589,7 @@ async function ensureFreshIndex(deps, projectId, projectPath, options = {}) {
|
|
|
117199
117589
|
let errors4 = 0;
|
|
117200
117590
|
for (const relativeFilePath of filesToReindex) {
|
|
117201
117591
|
try {
|
|
117202
|
-
const fullPath =
|
|
117592
|
+
const fullPath = path17.join(projectPath, relativeFilePath);
|
|
117203
117593
|
const result = await deps.indexFile(fullPath, projectId, projectPath, centralityMap);
|
|
117204
117594
|
filesIndexed++;
|
|
117205
117595
|
chunksIndexed += result.chunks;
|
|
@@ -117250,8 +117640,8 @@ async function checkSearchAdmission(deps, projectId, projectPath) {
|
|
|
117250
117640
|
}
|
|
117251
117641
|
async function indexFile(deps, filePath, projectId, projectRoot, centralityMap) {
|
|
117252
117642
|
projectId = await getProjectIdentityAliasResolver().resolve(projectId);
|
|
117253
|
-
const content = await
|
|
117254
|
-
const relativePath =
|
|
117643
|
+
const content = await fs11.readFile(filePath, "utf-8");
|
|
117644
|
+
const relativePath = path17.relative(projectRoot, filePath);
|
|
117255
117645
|
const maxFileSize = config.get("security").maxFileSize || 1024 * 1024;
|
|
117256
117646
|
if (content.length > maxFileSize) {
|
|
117257
117647
|
logger.warn("File too large, skipping", {
|
|
@@ -117271,7 +117661,7 @@ async function indexFile(deps, filePath, projectId, projectRoot, centralityMap)
|
|
|
117271
117661
|
chunkIndex: i,
|
|
117272
117662
|
totalChunks: chunks.length,
|
|
117273
117663
|
type: chunk.type,
|
|
117274
|
-
language:
|
|
117664
|
+
language: path17.extname(filePath).slice(1),
|
|
117275
117665
|
lineStart: chunk.lineStart,
|
|
117276
117666
|
lineEnd: chunk.lineEnd,
|
|
117277
117667
|
label: chunk.label,
|
|
@@ -120602,16 +120992,16 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
120602
120992
|
const seen = new Set;
|
|
120603
120993
|
const out = [];
|
|
120604
120994
|
for (const e of httpEdges) {
|
|
120605
|
-
const
|
|
120606
|
-
if (!
|
|
120995
|
+
const path18 = e.route;
|
|
120996
|
+
if (!path18)
|
|
120607
120997
|
continue;
|
|
120608
120998
|
const method = (e.method ?? "ANY").toUpperCase();
|
|
120609
|
-
const key = method + " " +
|
|
120999
|
+
const key = method + " " + path18;
|
|
120610
121000
|
if (seen.has(key))
|
|
120611
121001
|
continue;
|
|
120612
121002
|
seen.add(key);
|
|
120613
121003
|
out.push({
|
|
120614
|
-
path:
|
|
121004
|
+
path: path18,
|
|
120615
121005
|
method: e.method,
|
|
120616
121006
|
file: e.fromFile,
|
|
120617
121007
|
handler: e.targetFqn ?? e.symbolName
|
|
@@ -120622,12 +121012,12 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
120622
121012
|
continue;
|
|
120623
121013
|
const parsed = parseRouteName(d.name);
|
|
120624
121014
|
const method = parsed?.method ?? "ANY";
|
|
120625
|
-
const
|
|
120626
|
-
const key = method + " " +
|
|
121015
|
+
const path18 = parsed?.path ?? d.name;
|
|
121016
|
+
const key = method + " " + path18;
|
|
120627
121017
|
if (seen.has(key))
|
|
120628
121018
|
continue;
|
|
120629
121019
|
seen.add(key);
|
|
120630
|
-
out.push({ path:
|
|
121020
|
+
out.push({ path: path18, method: parsed?.method, file: d.filePath, handler: d.name });
|
|
120631
121021
|
}
|
|
120632
121022
|
for (const d of defs) {
|
|
120633
121023
|
const parsed = parseRouteName(d.name);
|
|
@@ -120848,8 +121238,8 @@ __export(exports_symbol_graph_service, {
|
|
|
120848
121238
|
symbolGraphService: () => symbolGraphService,
|
|
120849
121239
|
SymbolGraphService: () => SymbolGraphService
|
|
120850
121240
|
});
|
|
120851
|
-
import
|
|
120852
|
-
import
|
|
121241
|
+
import path18 from "path";
|
|
121242
|
+
import fs12 from "fs/promises";
|
|
120853
121243
|
|
|
120854
121244
|
class SymbolGraphService {
|
|
120855
121245
|
identityLookup;
|
|
@@ -121177,7 +121567,7 @@ class SymbolGraphService {
|
|
|
121177
121567
|
async readSnippet(relativePath, lineStart, lineEnd, projectId) {
|
|
121178
121568
|
try {
|
|
121179
121569
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
121180
|
-
const content = await
|
|
121570
|
+
const content = await fs12.readFile(absolutePath, "utf-8");
|
|
121181
121571
|
const lines = content.split(`
|
|
121182
121572
|
`);
|
|
121183
121573
|
return lines.slice(Math.max(0, lineStart - 1), Math.min(lines.length, lineEnd)).join(`
|
|
@@ -121189,7 +121579,7 @@ class SymbolGraphService {
|
|
|
121189
121579
|
async readContext(relativePath, lineNumber, contextLines, projectId) {
|
|
121190
121580
|
try {
|
|
121191
121581
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
121192
|
-
const content = await
|
|
121582
|
+
const content = await fs12.readFile(absolutePath, "utf-8");
|
|
121193
121583
|
const lines = content.split(`
|
|
121194
121584
|
`);
|
|
121195
121585
|
const start = Math.max(0, lineNumber - contextLines - 1);
|
|
@@ -121202,7 +121592,7 @@ class SymbolGraphService {
|
|
|
121202
121592
|
}
|
|
121203
121593
|
async resolveToAbsolute(relativePath, projectId) {
|
|
121204
121594
|
const root = await this.getProjectRoot(projectId);
|
|
121205
|
-
return root ?
|
|
121595
|
+
return root ? path18.resolve(root, relativePath) : relativePath;
|
|
121206
121596
|
}
|
|
121207
121597
|
async getProjectRoot(projectId) {
|
|
121208
121598
|
const cached2 = this.projectRootCache.get(projectId);
|
|
@@ -122980,31 +123370,31 @@ class TracePathService {
|
|
|
122980
123370
|
const chains = [];
|
|
122981
123371
|
const seen = new Set;
|
|
122982
123372
|
let walks = 0;
|
|
122983
|
-
const walk = (fqn,
|
|
123373
|
+
const walk = (fqn, path19) => {
|
|
122984
123374
|
if (chains.length >= CHAIN_CAP)
|
|
122985
123375
|
return;
|
|
122986
123376
|
if (walks >= MAX_WALKS)
|
|
122987
123377
|
return;
|
|
122988
123378
|
walks++;
|
|
122989
|
-
const key =
|
|
123379
|
+
const key = path19.join("\u2192");
|
|
122990
123380
|
if (seen.has(key))
|
|
122991
123381
|
return;
|
|
122992
123382
|
seen.add(key);
|
|
122993
123383
|
const next = adj.get(fqn);
|
|
122994
123384
|
if (!next || next.length === 0 || !whoHasChild.has(fqn)) {
|
|
122995
|
-
if (
|
|
122996
|
-
chains.push(
|
|
123385
|
+
if (path19.length > 1)
|
|
123386
|
+
chains.push(path19.map((n) => this.fqnToName(n)).join(" \u2192 "));
|
|
122997
123387
|
return;
|
|
122998
123388
|
}
|
|
122999
123389
|
for (const child of next) {
|
|
123000
123390
|
if (chains.length >= CHAIN_CAP || walks >= MAX_WALKS)
|
|
123001
123391
|
return;
|
|
123002
|
-
if (
|
|
123003
|
-
const cycled = [...
|
|
123392
|
+
if (path19.includes(child)) {
|
|
123393
|
+
const cycled = [...path19, `${this.fqnToName(child)}\u21BA`];
|
|
123004
123394
|
chains.push(cycled.map((n) => n).join(" \u2192 "));
|
|
123005
123395
|
continue;
|
|
123006
123396
|
}
|
|
123007
|
-
walk(child, [...
|
|
123397
|
+
walk(child, [...path19, child]);
|
|
123008
123398
|
}
|
|
123009
123399
|
};
|
|
123010
123400
|
for (const seed of seeds) {
|
|
@@ -124998,9 +125388,9 @@ var init_l1_memory_cache = __esm(() => {
|
|
|
124998
125388
|
});
|
|
124999
125389
|
|
|
125000
125390
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
125001
|
-
import
|
|
125391
|
+
import fs13 from "fs/promises";
|
|
125002
125392
|
import { existsSync as existsSync3 } from "fs";
|
|
125003
|
-
import
|
|
125393
|
+
import path19 from "path";
|
|
125004
125394
|
|
|
125005
125395
|
class LocalHealthChecker {
|
|
125006
125396
|
ollamaBaseUrl = process.env.OLLAMA_BASE_URL || "http://localhost:11434";
|
|
@@ -125034,10 +125424,10 @@ class LocalHealthChecker {
|
|
|
125034
125424
|
const start = Date.now();
|
|
125035
125425
|
try {
|
|
125036
125426
|
if (!existsSync3(this.dataDir))
|
|
125037
|
-
await
|
|
125038
|
-
const probe =
|
|
125039
|
-
await
|
|
125040
|
-
await
|
|
125427
|
+
await fs13.mkdir(this.dataDir, { recursive: true });
|
|
125428
|
+
const probe = path19.join(this.dataDir, ".health-check-test");
|
|
125429
|
+
await fs13.writeFile(probe, "ok");
|
|
125430
|
+
await fs13.unlink(probe);
|
|
125041
125431
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
125042
125432
|
} catch (error51) {
|
|
125043
125433
|
return { available: false, latency: Date.now() - start, error: `Data directory error: ${error51.message}` };
|
|
@@ -125985,10 +126375,18 @@ var init_scheduler_store_factory = __esm(() => {
|
|
|
125985
126375
|
});
|
|
125986
126376
|
|
|
125987
126377
|
// ../../packages/core/dist/services/scheduler/scheduler.js
|
|
125988
|
-
function
|
|
126378
|
+
function readEnabledEnv() {
|
|
125989
126379
|
const raw2 = process.env.MASSA_AI_SCHEDULER_ENABLED;
|
|
126380
|
+
if (raw2 === undefined)
|
|
126381
|
+
return;
|
|
125990
126382
|
return raw2 === "true" || raw2 === "1";
|
|
125991
126383
|
}
|
|
126384
|
+
function envPositiveInt(raw2) {
|
|
126385
|
+
if (raw2 === undefined || raw2 === "")
|
|
126386
|
+
return;
|
|
126387
|
+
const parsed = parsePositiveIntEnv(raw2, NaN);
|
|
126388
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
126389
|
+
}
|
|
125992
126390
|
|
|
125993
126391
|
class Scheduler {
|
|
125994
126392
|
store;
|
|
@@ -126002,9 +126400,10 @@ class Scheduler {
|
|
|
126002
126400
|
started = false;
|
|
126003
126401
|
constructor(opts = {}) {
|
|
126004
126402
|
this.store = opts.store ?? getScheduledJobStore();
|
|
126005
|
-
|
|
126006
|
-
this.
|
|
126007
|
-
this.
|
|
126403
|
+
const schedulerConfig = config.get("scheduler");
|
|
126404
|
+
this.tickIntervalMs = opts.tickIntervalMs ?? envPositiveInt(process.env.MASSA_AI_SCHEDULER_TICK_MS) ?? schedulerConfig?.tickMs ?? DEFAULTS.tickMs;
|
|
126405
|
+
this.maxConcurrent = opts.maxConcurrent ?? envPositiveInt(process.env.MASSA_AI_SCHEDULER_MAX_CONCURRENT) ?? schedulerConfig?.maxConcurrent ?? DEFAULTS.maxConcurrent;
|
|
126406
|
+
this.enabled = opts.enabled ?? readEnabledEnv() ?? schedulerConfig?.enabled ?? false;
|
|
126008
126407
|
}
|
|
126009
126408
|
registerHandler(jobKind, handler) {
|
|
126010
126409
|
this.handlers.set(jobKind, handler);
|
|
@@ -127991,21 +128390,31 @@ var init_checkpoint_manager = __esm(() => {
|
|
|
127991
128390
|
});
|
|
127992
128391
|
|
|
127993
128392
|
// ../../packages/core/dist/services/scheduler/scheduler-defaults.js
|
|
127994
|
-
function envBool2(key, fallback) {
|
|
128393
|
+
function envBool2(key, fileValue, fallback) {
|
|
127995
128394
|
const raw2 = process.env[key];
|
|
127996
128395
|
if (raw2 === undefined)
|
|
127997
|
-
return fallback;
|
|
128396
|
+
return fileValue ?? fallback;
|
|
127998
128397
|
return raw2 === "true" || raw2 === "1";
|
|
127999
128398
|
}
|
|
128000
|
-
function envNum2(key, fallback) {
|
|
128399
|
+
function envNum2(key, fileValue, fallback) {
|
|
128001
128400
|
const raw2 = process.env[key];
|
|
128002
|
-
if (raw2
|
|
128003
|
-
|
|
128004
|
-
|
|
128005
|
-
|
|
128401
|
+
if (raw2 !== undefined && raw2 !== "") {
|
|
128402
|
+
const n = Number(raw2);
|
|
128403
|
+
if (Number.isFinite(n) && n > 0)
|
|
128404
|
+
return n;
|
|
128405
|
+
}
|
|
128406
|
+
return fileValue ?? fallback;
|
|
128407
|
+
}
|
|
128408
|
+
function readFileSchedulerJobs() {
|
|
128409
|
+
try {
|
|
128410
|
+
const raw2 = loadConfigSafe().scheduler?.jobs;
|
|
128411
|
+
return raw2;
|
|
128412
|
+
} catch {
|
|
128413
|
+
return;
|
|
128414
|
+
}
|
|
128006
128415
|
}
|
|
128007
128416
|
function applySafeDefaults(job) {
|
|
128008
|
-
if (!envBool2("MASSA_AI_SCHEDULER_SAFE_DEFAULTS", false)) {
|
|
128417
|
+
if (!envBool2("MASSA_AI_SCHEDULER_SAFE_DEFAULTS", undefined, false)) {
|
|
128009
128418
|
return job;
|
|
128010
128419
|
}
|
|
128011
128420
|
if (job.jobKind === "memory-consolidation") {
|
|
@@ -128052,10 +128461,12 @@ function registerDefaultJobs(scheduler) {
|
|
|
128052
128461
|
const count = CheckpointManager2.getInstance().purgeExpired();
|
|
128053
128462
|
logger.info("Scheduled checkpoint purge completed", { count });
|
|
128054
128463
|
});
|
|
128464
|
+
const fileJobs = readFileSchedulerJobs();
|
|
128055
128465
|
for (const rawDef of DEFAULT_SCHEDULED_JOBS) {
|
|
128056
128466
|
const def = applySafeDefaults(rawDef);
|
|
128057
|
-
const
|
|
128058
|
-
const
|
|
128467
|
+
const fileJob = fileJobs?.[def.jobKind];
|
|
128468
|
+
const enabled = envBool2(def.enableEnvVar, fileJob?.enabled, def.defaultEnabled);
|
|
128469
|
+
const intervalMs = envNum2(def.intervalEnvVar, fileJob?.intervalMs, def.schedule.intervalMs ?? THIRTY_MIN);
|
|
128059
128470
|
const schedule = { type: "interval", intervalMs };
|
|
128060
128471
|
scheduler.registerOrResumeJob({
|
|
128061
128472
|
id: def.id,
|
|
@@ -128136,9 +128547,9 @@ var init_scheduler2 = __esm(() => {
|
|
|
128136
128547
|
});
|
|
128137
128548
|
|
|
128138
128549
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
128139
|
-
import
|
|
128550
|
+
import fs14 from "fs/promises";
|
|
128140
128551
|
import { existsSync as existsSync4 } from "fs";
|
|
128141
|
-
import
|
|
128552
|
+
import path20 from "path";
|
|
128142
128553
|
function getModelsDevClient() {
|
|
128143
128554
|
if (!clientInstance) {
|
|
128144
128555
|
clientInstance = new ModelsDevClient;
|
|
@@ -128158,7 +128569,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
128158
128569
|
memoryCacheTimestamp = 0;
|
|
128159
128570
|
getLocalCachePath() {
|
|
128160
128571
|
const dataDir = config.get("dataDir");
|
|
128161
|
-
return
|
|
128572
|
+
return path20.join(dataDir, ModelsDevClient.LOCAL_CACHE_FILE);
|
|
128162
128573
|
}
|
|
128163
128574
|
async loadLocalCache() {
|
|
128164
128575
|
const cachePath = this.getLocalCachePath();
|
|
@@ -128166,7 +128577,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
128166
128577
|
if (!existsSync4(cachePath)) {
|
|
128167
128578
|
return null;
|
|
128168
128579
|
}
|
|
128169
|
-
const content = await
|
|
128580
|
+
const content = await fs14.readFile(cachePath, "utf-8");
|
|
128170
128581
|
const data = JSON.parse(content);
|
|
128171
128582
|
const age = Date.now() - data.timestamp;
|
|
128172
128583
|
if (age > ModelsDevClient.LOCAL_CACHE_TTL) {
|
|
@@ -128193,14 +128604,14 @@ var init_models_dev_client = __esm(() => {
|
|
|
128193
128604
|
async saveLocalCache(models) {
|
|
128194
128605
|
const cachePath = this.getLocalCachePath();
|
|
128195
128606
|
try {
|
|
128196
|
-
const dir =
|
|
128197
|
-
await
|
|
128607
|
+
const dir = path20.dirname(cachePath);
|
|
128608
|
+
await fs14.mkdir(dir, { recursive: true });
|
|
128198
128609
|
const data = {
|
|
128199
128610
|
timestamp: Date.now(),
|
|
128200
128611
|
version: "1.0.0",
|
|
128201
128612
|
models: Object.fromEntries(models)
|
|
128202
128613
|
};
|
|
128203
|
-
await
|
|
128614
|
+
await fs14.writeFile(cachePath, JSON.stringify(data), "utf-8");
|
|
128204
128615
|
logger.debug("Saved pricing to local cache", {
|
|
128205
128616
|
models: models.size,
|
|
128206
128617
|
path: cachePath
|
|
@@ -128529,7 +128940,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
128529
128940
|
const cachePath = this.getLocalCachePath();
|
|
128530
128941
|
try {
|
|
128531
128942
|
if (existsSync4(cachePath)) {
|
|
128532
|
-
await
|
|
128943
|
+
await fs14.unlink(cachePath);
|
|
128533
128944
|
logger.debug("Local pricing cache file deleted");
|
|
128534
128945
|
}
|
|
128535
128946
|
} catch (error51) {
|
|
@@ -129132,8 +129543,8 @@ function stripNul(content) {
|
|
|
129132
129543
|
}
|
|
129133
129544
|
|
|
129134
129545
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
129135
|
-
import
|
|
129136
|
-
import
|
|
129546
|
+
import fs15 from "fs/promises";
|
|
129547
|
+
import path21 from "path";
|
|
129137
129548
|
import { createHash as createHash8 } from "crypto";
|
|
129138
129549
|
|
|
129139
129550
|
class DiscoverStage {
|
|
@@ -129159,7 +129570,7 @@ class DiscoverStage {
|
|
|
129159
129570
|
dot: false,
|
|
129160
129571
|
absolute: false
|
|
129161
129572
|
});
|
|
129162
|
-
relPaths = found.map((p) =>
|
|
129573
|
+
relPaths = found.map((p) => path21.isAbsolute(p) ? path21.relative(ctx.projectPath, p) : p).filter((p) => !ig.ignores(p) && applyPolicy(p, policy) !== "Drop");
|
|
129163
129574
|
}
|
|
129164
129575
|
if (ctx.resumeCursor?.path) {
|
|
129165
129576
|
const cursorPath = ctx.resumeCursor.path;
|
|
@@ -129218,10 +129629,10 @@ class DiscoverStage {
|
|
|
129218
129629
|
return discovered;
|
|
129219
129630
|
}
|
|
129220
129631
|
async processFile(ctx, relativePath, forceReindex) {
|
|
129221
|
-
const absolutePath =
|
|
129632
|
+
const absolutePath = path21.join(ctx.projectPath, relativePath);
|
|
129222
129633
|
try {
|
|
129223
|
-
const stat = await
|
|
129224
|
-
const content = stripNul(await
|
|
129634
|
+
const stat = await fs15.stat(absolutePath);
|
|
129635
|
+
const content = stripNul(await fs15.readFile(absolutePath, "utf-8"));
|
|
129225
129636
|
const contentHash = createHash8("sha256").update(content).digest("hex");
|
|
129226
129637
|
let needsReparse = forceReindex;
|
|
129227
129638
|
if (!forceReindex) {
|
|
@@ -129264,8 +129675,8 @@ class DiscoverStage {
|
|
|
129264
129675
|
ig.add(pattern);
|
|
129265
129676
|
}
|
|
129266
129677
|
try {
|
|
129267
|
-
const gitignorePath =
|
|
129268
|
-
const gitignoreContent = await
|
|
129678
|
+
const gitignorePath = path21.join(projectPath, ".gitignore");
|
|
129679
|
+
const gitignoreContent = await fs15.readFile(gitignorePath, "utf8");
|
|
129269
129680
|
const rules = gitignoreContent.split(`
|
|
129270
129681
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
129271
129682
|
ig.add(rules);
|
|
@@ -130620,8 +131031,8 @@ function rustUseLeaves(node, source, prefix = []) {
|
|
|
130620
131031
|
}
|
|
130621
131032
|
if (node.type === "use_wildcard")
|
|
130622
131033
|
return [{ path: [...prefix, "*"], glob: true }];
|
|
130623
|
-
const
|
|
130624
|
-
return
|
|
131034
|
+
const path22 = rustPathSegments(node, source);
|
|
131035
|
+
return path22.length ? [{ path: [...prefix, ...path22] }] : [];
|
|
130625
131036
|
}
|
|
130626
131037
|
function functionalCaptures(captures, source, family) {
|
|
130627
131038
|
if (family !== "clojure")
|
|
@@ -131593,8 +132004,8 @@ var init_structural_runtime = __esm(() => {
|
|
|
131593
132004
|
});
|
|
131594
132005
|
|
|
131595
132006
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
131596
|
-
import
|
|
131597
|
-
import
|
|
132007
|
+
import path22 from "path";
|
|
132008
|
+
import fs16 from "fs/promises";
|
|
131598
132009
|
function resolveChunkerMaxChars() {
|
|
131599
132010
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
131600
132011
|
if (Number.isFinite(global2) && global2 > 0)
|
|
@@ -131622,8 +132033,8 @@ class ParseStage {
|
|
|
131622
132033
|
const results = new Map;
|
|
131623
132034
|
let processed = 0;
|
|
131624
132035
|
const phases = [
|
|
131625
|
-
files.filter((file2) =>
|
|
131626
|
-
files.filter((file2) =>
|
|
132036
|
+
files.filter((file2) => path22.extname(file2.relativePath).toLowerCase() !== ".h"),
|
|
132037
|
+
files.filter((file2) => path22.extname(file2.relativePath).toLowerCase() === ".h")
|
|
131627
132038
|
];
|
|
131628
132039
|
const batches = phases.flatMap((phase) => Array.from({ length: Math.ceil(phase.length / BATCH_SIZE) }, (_, index) => phase.slice(index * BATCH_SIZE, (index + 1) * BATCH_SIZE)));
|
|
131629
132040
|
for (const batch of batches) {
|
|
@@ -131661,19 +132072,19 @@ class ParseStage {
|
|
|
131661
132072
|
return files.map((file2) => results.get(file2.relativePath));
|
|
131662
132073
|
}
|
|
131663
132074
|
recordHeaderImporterEvidence(ctx, files, parsedFiles) {
|
|
131664
|
-
const knownHeaders = new Set(files.filter((file2) =>
|
|
132075
|
+
const knownHeaders = new Set(files.filter((file2) => path22.extname(file2.relativePath).toLowerCase() === ".h").map((file2) => path22.posix.normalize(file2.relativePath)));
|
|
131665
132076
|
const mutable = {
|
|
131666
132077
|
...ctx.structuralHeaderEvidenceByFile
|
|
131667
132078
|
};
|
|
131668
132079
|
for (const parsed of parsedFiles) {
|
|
131669
|
-
const extension =
|
|
132080
|
+
const extension = path22.extname(parsed.file.relativePath).toLowerCase();
|
|
131670
132081
|
const key = extension === ".c" ? "cImporters" : [".cpp", ".hpp"].includes(extension) ? "cppImporters" : undefined;
|
|
131671
132082
|
if (!key)
|
|
131672
132083
|
continue;
|
|
131673
132084
|
for (const imported of parsed.rawImports) {
|
|
131674
132085
|
if (!["c_include", "cpp_include"].includes(imported.form) || imported.specifier.startsWith("<"))
|
|
131675
132086
|
continue;
|
|
131676
|
-
const header =
|
|
132087
|
+
const header = path22.posix.normalize(path22.posix.join(path22.posix.dirname(parsed.file.relativePath), imported.specifier));
|
|
131677
132088
|
if (!knownHeaders.has(header))
|
|
131678
132089
|
continue;
|
|
131679
132090
|
const existing = mutable[header] ?? {};
|
|
@@ -131684,9 +132095,9 @@ class ParseStage {
|
|
|
131684
132095
|
}
|
|
131685
132096
|
async parseFile(ctx, file2) {
|
|
131686
132097
|
if (!file2.needsReparse) {
|
|
131687
|
-
const extension =
|
|
132098
|
+
const extension = path22.extname(file2.relativePath).toLowerCase();
|
|
131688
132099
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
131689
|
-
const content = file2.snapshotContent ?? await
|
|
132100
|
+
const content = file2.snapshotContent ?? await fs16.readFile(file2.absolutePath, "utf8");
|
|
131690
132101
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
131691
132102
|
if (outcome.status === "failed")
|
|
131692
132103
|
throw new StructuralEtlParseError(file2.relativePath, outcome.failureKind, `Structural evidence parse failed (${outcome.failureKind})`, outcome.diagnosticCount, outcome.diagnostics.slice(0, 10));
|
|
@@ -131698,8 +132109,8 @@ class ParseStage {
|
|
|
131698
132109
|
return { file: file2, chunks: [], symbols: [], rawImports: [], rawEdges: [] };
|
|
131699
132110
|
}
|
|
131700
132111
|
try {
|
|
131701
|
-
const content = file2.snapshotContent ?? await
|
|
131702
|
-
const ext2 =
|
|
132112
|
+
const content = file2.snapshotContent ?? await fs16.readFile(file2.absolutePath, "utf-8");
|
|
132113
|
+
const ext2 = path22.extname(file2.relativePath).toLowerCase();
|
|
131703
132114
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
131704
132115
|
const chunks = smartChunk(content, file2.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
131705
132116
|
let symbols;
|
|
@@ -132253,7 +132664,7 @@ var init_resolver = __esm(() => {
|
|
|
132253
132664
|
});
|
|
132254
132665
|
|
|
132255
132666
|
// ../../packages/core/dist/services/structural/resolvers/typescript.js
|
|
132256
|
-
import
|
|
132667
|
+
import path23 from "path";
|
|
132257
132668
|
function candidates(identities) {
|
|
132258
132669
|
return Object.freeze(identities.map((identity) => Object.freeze({
|
|
132259
132670
|
fqn: identity.fqn,
|
|
@@ -132348,7 +132759,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
132348
132759
|
const bases = /\.[cm]?jsx?$/u.test(base) ? [base.replace(/\.[cm]?jsx?$/u, ".ts"), base.replace(/\.[cm]?jsx?$/u, ".tsx"), base] : [base];
|
|
132349
132760
|
for (const candidateBase of bases)
|
|
132350
132761
|
for (const suffix of DIALECT_PROBES[dialect] ?? [""]) {
|
|
132351
|
-
const value =
|
|
132762
|
+
const value = path23.posix.normalize(`${candidateBase}${suffix}`);
|
|
132352
132763
|
if (!value.startsWith("../") && value !== ".." && known.has(value))
|
|
132353
132764
|
return value;
|
|
132354
132765
|
}
|
|
@@ -132357,7 +132768,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
132357
132768
|
function resolveStructuralSpecifier(specifier, fromFile, build, dialect = "typescript") {
|
|
132358
132769
|
const known = new Set(build.knownFiles.map(normalizeStructuralFile));
|
|
132359
132770
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
132360
|
-
return probe(
|
|
132771
|
+
return probe(path23.posix.join(path23.posix.dirname(fromFile), specifier), known, dialect);
|
|
132361
132772
|
}
|
|
132362
132773
|
const aliases = build.pathAliasesByFile?.[normalizeStructuralFile(fromFile)] ?? build.pathAliases ?? [];
|
|
132363
132774
|
for (const alias of aliases) {
|
|
@@ -132621,7 +133032,7 @@ var init_scripting2 = __esm(() => {
|
|
|
132621
133032
|
});
|
|
132622
133033
|
|
|
132623
133034
|
// ../../packages/core/dist/services/structural/resolvers/systems.js
|
|
132624
|
-
import
|
|
133035
|
+
import path24 from "path";
|
|
132625
133036
|
var DIALECTS, SYSTEMS_LANGUAGE_RESOLVER;
|
|
132626
133037
|
var init_systems2 = __esm(() => {
|
|
132627
133038
|
init_typescript2();
|
|
@@ -132640,7 +133051,7 @@ var init_systems2 = __esm(() => {
|
|
|
132640
133051
|
const bindings = item.bindings.map((binding) => binding.imported === "*" && binding.local === "*" && unresolvedTarget && !unresolvedTarget.qualifier ? { ...binding, imported: unresolvedTarget.name, local: unresolvedTarget.name } : binding);
|
|
132641
133052
|
if (item.specifier === "crate" || item.specifier.startsWith("crate/")) {
|
|
132642
133053
|
const crateRoot = file2.file.startsWith("src/") ? "src" : "";
|
|
132643
|
-
return { ...item, bindings, specifier: `./${
|
|
133054
|
+
return { ...item, bindings, specifier: `./${path24.posix.relative(path24.posix.dirname(file2.file), path24.posix.join(crateRoot, item.specifier.replace(/^crate\/?/u, "")))}` };
|
|
132644
133055
|
}
|
|
132645
133056
|
if (item.specifier === "self" || item.specifier.startsWith("self/"))
|
|
132646
133057
|
return { ...item, bindings, specifier: `./${item.specifier.replace(/^self\/?/u, "")}` };
|
|
@@ -132738,8 +133149,8 @@ var init_data_document2 = __esm(() => {
|
|
|
132738
133149
|
});
|
|
132739
133150
|
|
|
132740
133151
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
132741
|
-
import
|
|
132742
|
-
import
|
|
133152
|
+
import path25 from "path";
|
|
133153
|
+
import fs17 from "fs";
|
|
132743
133154
|
|
|
132744
133155
|
class ResolveStage {
|
|
132745
133156
|
symbolRepository;
|
|
@@ -132763,7 +133174,7 @@ class ResolveStage {
|
|
|
132763
133174
|
const structuralDocuments = files.flatMap((file2) => {
|
|
132764
133175
|
if (!file2.structure)
|
|
132765
133176
|
return [];
|
|
132766
|
-
const language = resolveStructuralLanguage(
|
|
133177
|
+
const language = resolveStructuralLanguage(path25.extname(file2.file.relativePath));
|
|
132767
133178
|
if (language.status !== "supported")
|
|
132768
133179
|
throw new Error(`structural_manifest_missing:${file2.file.relativePath}`);
|
|
132769
133180
|
return [{
|
|
@@ -132775,13 +133186,13 @@ class ResolveStage {
|
|
|
132775
133186
|
}];
|
|
132776
133187
|
});
|
|
132777
133188
|
const currentStructuralFiles = new Set(structuralDocuments.map((document2) => document2.file));
|
|
132778
|
-
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
133189
|
+
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path25.extname(item.file.relativePath).toLowerCase())).map((item) => item.file.relativePath));
|
|
132779
133190
|
const pathAliasesByFile = Object.fromEntries([...knownRelPaths].map((file2) => [
|
|
132780
133191
|
file2,
|
|
132781
133192
|
this.structuralAliasesFor(file2, rootAliases, monorepoPackages)
|
|
132782
133193
|
]));
|
|
132783
133194
|
const buildMetadata = { knownFiles: [...knownRelPaths], pathAliasesByFile };
|
|
132784
|
-
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(
|
|
133195
|
+
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(path25.extname(definition.file_path).toLowerCase())).filter((definition) => knownRelPaths.has(definition.file_path) && skippedStructuralFiles.has(definition.file_path)).filter((definition) => !currentStructuralFiles.has(definition.file_path));
|
|
132785
133196
|
const seedIds = new Set;
|
|
132786
133197
|
for (const definition of seedRows) {
|
|
132787
133198
|
if (seedIds.has(definition.id))
|
|
@@ -132874,7 +133285,7 @@ class ResolveStage {
|
|
|
132874
133285
|
if (parsed.file !== definition.file_path) {
|
|
132875
133286
|
throw new Error(`structural_repository_seed_file_mismatch:${definition.id}`);
|
|
132876
133287
|
}
|
|
132877
|
-
const language = resolveStructuralLanguage(
|
|
133288
|
+
const language = resolveStructuralLanguage(path25.extname(definition.file_path));
|
|
132878
133289
|
if (language.status !== "supported")
|
|
132879
133290
|
throw new Error(`structural_repository_seed_language:${definition.id}`);
|
|
132880
133291
|
let identity;
|
|
@@ -132926,7 +133337,7 @@ class ResolveStage {
|
|
|
132926
133337
|
});
|
|
132927
133338
|
}
|
|
132928
133339
|
resolveFile(parsed, projectPath, knownRelPaths, rootAliases, monorepoPackages, symbolIndex, knownFqns) {
|
|
132929
|
-
const fromDir =
|
|
133340
|
+
const fromDir = path25.dirname(path25.join(projectPath, parsed.file.relativePath));
|
|
132930
133341
|
const packageAliases = this.getPackageAliases(parsed.file.relativePath, monorepoPackages);
|
|
132931
133342
|
const allAliases = [...packageAliases, ...rootAliases];
|
|
132932
133343
|
const resolvedImports = parsed.rawImports.map((raw2) => {
|
|
@@ -132997,7 +133408,7 @@ class ResolveStage {
|
|
|
132997
133408
|
index.set(def.name, `${def.file_path}#${def.name}`);
|
|
132998
133409
|
}
|
|
132999
133410
|
} catch (err) {
|
|
133000
|
-
const skippedStructural = files.some((file2) => !file2.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
133411
|
+
const skippedStructural = files.some((file2) => !file2.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path25.extname(file2.file.relativePath).toLowerCase()));
|
|
133001
133412
|
if (skippedStructural)
|
|
133002
133413
|
throw new Error("structural_repository_seed_failed", { cause: err });
|
|
133003
133414
|
logger.warn("buildSymbolIndex: repo seed failed, in-batch only", {
|
|
@@ -133021,7 +133432,7 @@ class ResolveStage {
|
|
|
133021
133432
|
}
|
|
133022
133433
|
resolveSpecifier(specifier, fromDir, projectPath, knownRelPaths, aliases) {
|
|
133023
133434
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
133024
|
-
const resolved = this.probeExtensions(
|
|
133435
|
+
const resolved = this.probeExtensions(path25.resolve(fromDir, specifier), projectPath, knownRelPaths);
|
|
133025
133436
|
return { resolvedPath: resolved, external: false };
|
|
133026
133437
|
}
|
|
133027
133438
|
for (const alias of aliases) {
|
|
@@ -133029,8 +133440,8 @@ class ResolveStage {
|
|
|
133029
133440
|
const suffix = specifier.slice(alias.prefix.length);
|
|
133030
133441
|
for (const target of alias.targets) {
|
|
133031
133442
|
const cleanTarget = target.replace(/\/\*$/, "");
|
|
133032
|
-
const basePath = alias.packagePath ?
|
|
133033
|
-
const absPath =
|
|
133443
|
+
const basePath = alias.packagePath ? path25.join(projectPath, alias.packagePath) : projectPath;
|
|
133444
|
+
const absPath = path25.join(basePath, cleanTarget + suffix);
|
|
133034
133445
|
const resolved = this.probeExtensions(absPath, projectPath, knownRelPaths);
|
|
133035
133446
|
if (resolved)
|
|
133036
133447
|
return { resolvedPath: resolved, external: false };
|
|
@@ -133046,7 +133457,7 @@ class ResolveStage {
|
|
|
133046
133457
|
...TS_EXTENSIONS.map((ext2) => absPath.replace(/\.[^.]+$/, ext2))
|
|
133047
133458
|
];
|
|
133048
133459
|
for (const candidate2 of candidates2) {
|
|
133049
|
-
const rel =
|
|
133460
|
+
const rel = path25.relative(projectPath, candidate2).replace(/\\/g, "/");
|
|
133050
133461
|
if (knownRelPaths.has(rel))
|
|
133051
133462
|
return rel;
|
|
133052
133463
|
}
|
|
@@ -133054,9 +133465,9 @@ class ResolveStage {
|
|
|
133054
133465
|
}
|
|
133055
133466
|
loadTsConfigPaths(projectPath, packageBase) {
|
|
133056
133467
|
const aliases = [];
|
|
133057
|
-
const tsconfigPath =
|
|
133468
|
+
const tsconfigPath = path25.join(projectPath, "tsconfig.json");
|
|
133058
133469
|
try {
|
|
133059
|
-
const raw2 =
|
|
133470
|
+
const raw2 = fs17.readFileSync(tsconfigPath, "utf-8");
|
|
133060
133471
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
133061
133472
|
const tsconfig = JSON.parse(stripped);
|
|
133062
133473
|
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
@@ -133085,7 +133496,7 @@ class ResolveStage {
|
|
|
133085
133496
|
}
|
|
133086
133497
|
}
|
|
133087
133498
|
for (const packageRelPath of packagePaths) {
|
|
133088
|
-
const absPackagePath =
|
|
133499
|
+
const absPackagePath = path25.join(projectPath, packageRelPath);
|
|
133089
133500
|
const aliases = this.loadTsConfigPaths(absPackagePath, packageRelPath);
|
|
133090
133501
|
if (aliases.length > 0) {
|
|
133091
133502
|
packages.push({
|
|
@@ -133115,7 +133526,7 @@ class ResolveStage {
|
|
|
133115
133526
|
structuralAliasesFor(filePath, rootAliases, packages) {
|
|
133116
133527
|
return [...this.getPackageAliases(filePath, packages), ...rootAliases].map((alias) => ({
|
|
133117
133528
|
pattern: alias.prefix + (alias.targets.some((target) => target.includes("*")) ? "/*" : ""),
|
|
133118
|
-
targets: alias.targets.map((target) => alias.packagePath ?
|
|
133529
|
+
targets: alias.targets.map((target) => alias.packagePath ? path25.posix.join(alias.packagePath, target) : target)
|
|
133119
133530
|
}));
|
|
133120
133531
|
}
|
|
133121
133532
|
}
|
|
@@ -133179,7 +133590,7 @@ var init_with_deadlock_retry = __esm(() => {
|
|
|
133179
133590
|
});
|
|
133180
133591
|
|
|
133181
133592
|
// ../../packages/core/dist/services/etl/stages/load.js
|
|
133182
|
-
import
|
|
133593
|
+
import path26 from "path";
|
|
133183
133594
|
function formatDuration(ms) {
|
|
133184
133595
|
const totalSec = Math.max(0, Math.round(ms / 1000));
|
|
133185
133596
|
if (totalSec < 60)
|
|
@@ -133456,7 +133867,7 @@ class LoadStage {
|
|
|
133456
133867
|
const filePath = file2.file.relativePath;
|
|
133457
133868
|
const batch = buildSymbolPersistenceBatch(ctx.projectId, file2);
|
|
133458
133869
|
if (ctx.graphGenerationLease) {
|
|
133459
|
-
const manifest = getLanguageManifestEntry(
|
|
133870
|
+
const manifest = getLanguageManifestEntry(path26.extname(filePath));
|
|
133460
133871
|
const diagnostics2 = (file2.structuralDiagnostics ?? []).slice(0, 10).map((diagnostic2) => ({
|
|
133461
133872
|
code: diagnostic2.code,
|
|
133462
133873
|
severity: diagnostic2.severity,
|
|
@@ -133913,9 +134324,9 @@ var init_graph_generation_coordinator = __esm(() => {
|
|
|
133913
134324
|
// ../../packages/core/dist/services/etl/pipeline.js
|
|
133914
134325
|
import { createHash as createHash10 } from "crypto";
|
|
133915
134326
|
import { setTimeout as delay2 } from "timers/promises";
|
|
133916
|
-
import
|
|
134327
|
+
import path27 from "path";
|
|
133917
134328
|
function buildHeaderLanguageEvidence(files) {
|
|
133918
|
-
const headers = new Set(files.filter((file2) =>
|
|
134329
|
+
const headers = new Set(files.filter((file2) => path27.posix.extname(file2.relativePath).toLowerCase() === ".h").map((file2) => path27.posix.normalize(file2.relativePath)));
|
|
133919
134330
|
const mutable = new Map;
|
|
133920
134331
|
const entry2 = (header) => {
|
|
133921
134332
|
let value = mutable.get(header);
|
|
@@ -133926,7 +134337,7 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
133926
134337
|
return value;
|
|
133927
134338
|
};
|
|
133928
134339
|
for (const file2 of files) {
|
|
133929
|
-
if (
|
|
134340
|
+
if (path27.posix.basename(file2.relativePath) !== "compile_commands.json" || file2.snapshotContent === undefined)
|
|
133930
134341
|
continue;
|
|
133931
134342
|
let commands;
|
|
133932
134343
|
try {
|
|
@@ -133942,11 +134353,11 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
133942
134353
|
const record2 = command;
|
|
133943
134354
|
if (typeof record2.file !== "string")
|
|
133944
134355
|
continue;
|
|
133945
|
-
const projectRoot =
|
|
133946
|
-
const commandDirectory = typeof record2.directory === "string" ?
|
|
133947
|
-
const absoluteInput =
|
|
133948
|
-
const relative3 =
|
|
133949
|
-
const header =
|
|
134356
|
+
const projectRoot = path27.resolve(file2.absolutePath, ...file2.relativePath.split("/").map(() => ".."));
|
|
134357
|
+
const commandDirectory = typeof record2.directory === "string" ? path27.resolve(projectRoot, record2.directory) : projectRoot;
|
|
134358
|
+
const absoluteInput = path27.resolve(commandDirectory, record2.file);
|
|
134359
|
+
const relative3 = path27.relative(projectRoot, absoluteInput);
|
|
134360
|
+
const header = path27.posix.normalize(relative3.replaceAll(path27.sep, "/"));
|
|
133950
134361
|
if (!headers.has(header))
|
|
133951
134362
|
continue;
|
|
133952
134363
|
const invocation = typeof record2.command === "string" ? record2.command : Array.isArray(record2.arguments) ? record2.arguments.join(" ") : "";
|
|
@@ -139812,33 +140223,33 @@ var require_URL = __commonJS((exports, module) => {
|
|
|
139812
140223
|
else
|
|
139813
140224
|
return basepath.substring(0, lastslash + 1) + refpath;
|
|
139814
140225
|
}
|
|
139815
|
-
function remove_dot_segments(
|
|
139816
|
-
if (!
|
|
139817
|
-
return
|
|
140226
|
+
function remove_dot_segments(path28) {
|
|
140227
|
+
if (!path28)
|
|
140228
|
+
return path28;
|
|
139818
140229
|
var output = "";
|
|
139819
|
-
while (
|
|
139820
|
-
if (
|
|
139821
|
-
|
|
140230
|
+
while (path28.length > 0) {
|
|
140231
|
+
if (path28 === "." || path28 === "..") {
|
|
140232
|
+
path28 = "";
|
|
139822
140233
|
break;
|
|
139823
140234
|
}
|
|
139824
|
-
var twochars =
|
|
139825
|
-
var threechars =
|
|
139826
|
-
var fourchars =
|
|
140235
|
+
var twochars = path28.substring(0, 2);
|
|
140236
|
+
var threechars = path28.substring(0, 3);
|
|
140237
|
+
var fourchars = path28.substring(0, 4);
|
|
139827
140238
|
if (threechars === "../") {
|
|
139828
|
-
|
|
140239
|
+
path28 = path28.substring(3);
|
|
139829
140240
|
} else if (twochars === "./") {
|
|
139830
|
-
|
|
140241
|
+
path28 = path28.substring(2);
|
|
139831
140242
|
} else if (threechars === "/./") {
|
|
139832
|
-
|
|
139833
|
-
} else if (twochars === "/." &&
|
|
139834
|
-
|
|
139835
|
-
} else if (fourchars === "/../" || threechars === "/.." &&
|
|
139836
|
-
|
|
140243
|
+
path28 = "/" + path28.substring(3);
|
|
140244
|
+
} else if (twochars === "/." && path28.length === 2) {
|
|
140245
|
+
path28 = "/";
|
|
140246
|
+
} else if (fourchars === "/../" || threechars === "/.." && path28.length === 3) {
|
|
140247
|
+
path28 = "/" + path28.substring(4);
|
|
139837
140248
|
output = output.replace(/\/?[^\/]*$/, "");
|
|
139838
140249
|
} else {
|
|
139839
|
-
var segment =
|
|
140250
|
+
var segment = path28.match(/(\/?([^\/]*))/)[0];
|
|
139840
140251
|
output += segment;
|
|
139841
|
-
|
|
140252
|
+
path28 = path28.substring(segment.length);
|
|
139842
140253
|
}
|
|
139843
140254
|
}
|
|
139844
140255
|
return output;
|
|
@@ -151908,21 +152319,21 @@ function jsonToKeyPathChunks(value, label = "$") {
|
|
|
151908
152319
|
walk(value, label, out);
|
|
151909
152320
|
return out;
|
|
151910
152321
|
}
|
|
151911
|
-
function walk(val,
|
|
152322
|
+
function walk(val, path28, out) {
|
|
151912
152323
|
if (val === null || val === undefined)
|
|
151913
152324
|
return;
|
|
151914
152325
|
if (Array.isArray(val)) {
|
|
151915
152326
|
if (val.length === 0) {
|
|
151916
|
-
out.push({ path:
|
|
152327
|
+
out.push({ path: path28, content: `**${path28}** = _[]_` });
|
|
151917
152328
|
return;
|
|
151918
152329
|
}
|
|
151919
152330
|
if (val.every((v) => v !== null && typeof v === "object")) {
|
|
151920
|
-
val.forEach((v, i) => walk(v, `${
|
|
152331
|
+
val.forEach((v, i) => walk(v, `${path28}[${i}]`, out));
|
|
151921
152332
|
return;
|
|
151922
152333
|
}
|
|
151923
152334
|
const items = val.map((v) => `- \`${String(v)}\``).join(`
|
|
151924
152335
|
`);
|
|
151925
|
-
out.push({ path:
|
|
152336
|
+
out.push({ path: path28, content: `**${path28}**
|
|
151926
152337
|
|
|
151927
152338
|
${items}` });
|
|
151928
152339
|
return;
|
|
@@ -151930,16 +152341,16 @@ ${items}` });
|
|
|
151930
152341
|
if (typeof val === "object") {
|
|
151931
152342
|
const entries = Object.entries(val);
|
|
151932
152343
|
if (entries.length === 0) {
|
|
151933
|
-
out.push({ path:
|
|
152344
|
+
out.push({ path: path28, content: `**${path28}** = _{}_` });
|
|
151934
152345
|
return;
|
|
151935
152346
|
}
|
|
151936
152347
|
for (const [k, v] of entries) {
|
|
151937
152348
|
const safeKey = /^[A-Za-z_$][\w$]*$/.test(k) ? k : JSON.stringify(k);
|
|
151938
|
-
walk(v, `${
|
|
152349
|
+
walk(v, `${path28}.${safeKey}`, out);
|
|
151939
152350
|
}
|
|
151940
152351
|
return;
|
|
151941
152352
|
}
|
|
151942
|
-
out.push({ path:
|
|
152353
|
+
out.push({ path: path28, content: `**${path28}** = \`${String(val)}\`` });
|
|
151943
152354
|
}
|
|
151944
152355
|
var gfm, STRIP_SELECTORS, tdCache = null;
|
|
151945
152356
|
var init_html_to_md = __esm(() => {
|
|
@@ -152536,7 +152947,7 @@ Using defaults:`);
|
|
|
152536
152947
|
provider: "ollama",
|
|
152537
152948
|
model: options.model || "qwen3-embedding:4b",
|
|
152538
152949
|
baseURL: options["base-url"] || "http://localhost:11434",
|
|
152539
|
-
dimensions:
|
|
152950
|
+
dimensions: 2560
|
|
152540
152951
|
};
|
|
152541
152952
|
} else if (provider === "mistral") {
|
|
152542
152953
|
if (!options["api-key"]) {
|