@massa-ai/tools-api 1.60.0 → 1.60.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +689 -496
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8333,12 +8333,13 @@ function selectRecord(records) {
|
|
|
8333
8333
|
}
|
|
8334
8334
|
return best ?? pool[pool.length - 1];
|
|
8335
8335
|
}
|
|
8336
|
-
function
|
|
8336
|
+
function resolveClaudeMarketplaceInstall(opts = {}) {
|
|
8337
8337
|
const targetHome = opts.targetHome ?? os5.homedir();
|
|
8338
8338
|
const pluginKey = opts.pluginKey ?? DEFAULT_PLUGIN_KEY;
|
|
8339
8339
|
const directoryResult = resolveDirectorySourceRoot(targetHome, pluginKey);
|
|
8340
|
-
if (directoryResult !== undefined)
|
|
8341
|
-
return directoryResult;
|
|
8340
|
+
if (directoryResult !== undefined) {
|
|
8341
|
+
return directoryResult === null ? null : { root: directoryResult, route: "directory-source" };
|
|
8342
|
+
}
|
|
8342
8343
|
const registryPath = path11.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
8343
8344
|
let records;
|
|
8344
8345
|
try {
|
|
@@ -8360,15 +8361,197 @@ function resolveClaudeMarketplaceRoot(opts = {}) {
|
|
|
8360
8361
|
} catch {
|
|
8361
8362
|
return null;
|
|
8362
8363
|
}
|
|
8363
|
-
return installPath;
|
|
8364
|
+
return { root: installPath, route: "registry-cache" };
|
|
8365
|
+
}
|
|
8366
|
+
function resolveClaudeMarketplaceRoot(opts = {}) {
|
|
8367
|
+
return resolveClaudeMarketplaceInstall(opts)?.root ?? null;
|
|
8368
|
+
}
|
|
8369
|
+
function readInstalledPluginVersion(opts = {}) {
|
|
8370
|
+
const targetHome = opts.targetHome ?? os5.homedir();
|
|
8371
|
+
const pluginKey = opts.pluginKey ?? DEFAULT_PLUGIN_KEY;
|
|
8372
|
+
const registryPath = path11.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
8373
|
+
let records;
|
|
8374
|
+
try {
|
|
8375
|
+
const parsed = JSON.parse(fs7.readFileSync(registryPath, "utf8"));
|
|
8376
|
+
records = parsed?.plugins?.[pluginKey];
|
|
8377
|
+
} catch {
|
|
8378
|
+
return null;
|
|
8379
|
+
}
|
|
8380
|
+
if (!Array.isArray(records) || records.length === 0)
|
|
8381
|
+
return null;
|
|
8382
|
+
return selectRecord(records)?.version ?? null;
|
|
8364
8383
|
}
|
|
8365
8384
|
var DEFAULT_PLUGIN_KEY = "massa-ai@massa-ai";
|
|
8366
8385
|
var init_claude_marketplace = () => {};
|
|
8367
8386
|
|
|
8368
|
-
// ../../packages/shared/dist/profile-switch/
|
|
8387
|
+
// ../../packages/shared/dist/profile-switch/frontmatter.js
|
|
8388
|
+
function parseFrontmatter(raw2) {
|
|
8389
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/.exec(raw2);
|
|
8390
|
+
if (!match) {
|
|
8391
|
+
throw new Error("charter missing YAML frontmatter (--- ... ---) block");
|
|
8392
|
+
}
|
|
8393
|
+
const yamlText = match[1] ?? "";
|
|
8394
|
+
const body = (match[2] ?? "").replace(/^\r?\n/, "");
|
|
8395
|
+
const frontmatter = parseSimpleYaml(yamlText);
|
|
8396
|
+
return { frontmatter, body };
|
|
8397
|
+
}
|
|
8398
|
+
function parseSimpleYaml(text) {
|
|
8399
|
+
const result = {};
|
|
8400
|
+
const lines = text.split(/\r?\n/);
|
|
8401
|
+
let i = 0;
|
|
8402
|
+
while (i < lines.length) {
|
|
8403
|
+
const line = lines[i] ?? "";
|
|
8404
|
+
if (line.trim() === "" || line.trim().startsWith("#")) {
|
|
8405
|
+
i++;
|
|
8406
|
+
continue;
|
|
8407
|
+
}
|
|
8408
|
+
const m2 = /^([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/.exec(line);
|
|
8409
|
+
if (!m2) {
|
|
8410
|
+
i++;
|
|
8411
|
+
continue;
|
|
8412
|
+
}
|
|
8413
|
+
const key = m2[1];
|
|
8414
|
+
const rest = (m2[2] ?? "").trim();
|
|
8415
|
+
if (rest !== "") {
|
|
8416
|
+
result[key] = unquoteScalar(rest);
|
|
8417
|
+
i++;
|
|
8418
|
+
continue;
|
|
8419
|
+
}
|
|
8420
|
+
const nested = {};
|
|
8421
|
+
i++;
|
|
8422
|
+
while (i < lines.length) {
|
|
8423
|
+
const nestedLine = lines[i] ?? "";
|
|
8424
|
+
if (/^\s{2,}\S/.test(nestedLine) === false)
|
|
8425
|
+
break;
|
|
8426
|
+
const nm = /^\s{2,}([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/.exec(nestedLine);
|
|
8427
|
+
if (!nm)
|
|
8428
|
+
break;
|
|
8429
|
+
nested[nm[1]] = unquoteScalar((nm[2] ?? "").trim());
|
|
8430
|
+
i++;
|
|
8431
|
+
}
|
|
8432
|
+
result[key] = nested;
|
|
8433
|
+
}
|
|
8434
|
+
return result;
|
|
8435
|
+
}
|
|
8436
|
+
function unquoteScalar(s) {
|
|
8437
|
+
if (s.startsWith('"') && s.endsWith('"') || s.startsWith("'") && s.endsWith("'")) {
|
|
8438
|
+
return s.slice(1, -1);
|
|
8439
|
+
}
|
|
8440
|
+
return s;
|
|
8441
|
+
}
|
|
8442
|
+
|
|
8443
|
+
// ../../packages/shared/dist/profile-switch/doctor.js
|
|
8369
8444
|
import fs8 from "fs";
|
|
8370
|
-
import path12 from "path";
|
|
8371
8445
|
import os6 from "os";
|
|
8446
|
+
import path12 from "path";
|
|
8447
|
+
function readTextFile(filePath) {
|
|
8448
|
+
try {
|
|
8449
|
+
return fs8.readFileSync(filePath, "utf8");
|
|
8450
|
+
} catch {
|
|
8451
|
+
return null;
|
|
8452
|
+
}
|
|
8453
|
+
}
|
|
8454
|
+
function readJsonFile(filePath) {
|
|
8455
|
+
const raw2 = readTextFile(filePath);
|
|
8456
|
+
if (raw2 === null)
|
|
8457
|
+
return null;
|
|
8458
|
+
try {
|
|
8459
|
+
return JSON.parse(raw2);
|
|
8460
|
+
} catch {
|
|
8461
|
+
return null;
|
|
8462
|
+
}
|
|
8463
|
+
}
|
|
8464
|
+
function readPluginVersion(pluginRoot) {
|
|
8465
|
+
const manifest = readJsonFile(path12.join(pluginRoot, ".claude-plugin", "plugin.json"));
|
|
8466
|
+
return typeof manifest?.version === "string" ? manifest.version : null;
|
|
8467
|
+
}
|
|
8468
|
+
function detectEnvOverride(env3) {
|
|
8469
|
+
for (const name of ENV_OVERRIDE_VARS) {
|
|
8470
|
+
const value = env3[name];
|
|
8471
|
+
if (typeof value === "string" && value.trim()) {
|
|
8472
|
+
return { name, value: value.trim() };
|
|
8473
|
+
}
|
|
8474
|
+
}
|
|
8475
|
+
return null;
|
|
8476
|
+
}
|
|
8477
|
+
function readRoles(liveRoot, activeProfile) {
|
|
8478
|
+
const agentsDir = path12.join(liveRoot, "agents");
|
|
8479
|
+
let entries;
|
|
8480
|
+
try {
|
|
8481
|
+
entries = fs8.readdirSync(agentsDir, { withFileTypes: true });
|
|
8482
|
+
} catch {
|
|
8483
|
+
return [];
|
|
8484
|
+
}
|
|
8485
|
+
const roles = [];
|
|
8486
|
+
for (const entry of entries) {
|
|
8487
|
+
if (!entry.isFile() || !entry.name.startsWith("massa-ai-") || !entry.name.endsWith(".md")) {
|
|
8488
|
+
continue;
|
|
8489
|
+
}
|
|
8490
|
+
const activeRaw = readTextFile(path12.join(agentsDir, entry.name));
|
|
8491
|
+
let model = null;
|
|
8492
|
+
let effort = null;
|
|
8493
|
+
if (activeRaw !== null) {
|
|
8494
|
+
try {
|
|
8495
|
+
const { frontmatter } = parseFrontmatter(activeRaw);
|
|
8496
|
+
model = typeof frontmatter.model === "string" ? frontmatter.model : null;
|
|
8497
|
+
effort = typeof frontmatter.effort === "string" ? frontmatter.effort : null;
|
|
8498
|
+
} catch {}
|
|
8499
|
+
}
|
|
8500
|
+
let staleVariant = false;
|
|
8501
|
+
if (activeProfile && activeRaw !== null) {
|
|
8502
|
+
const variantRaw = readTextFile(path12.join(liveRoot, "agent-profiles", activeProfile, entry.name));
|
|
8503
|
+
if (variantRaw !== null) {
|
|
8504
|
+
staleVariant = variantRaw !== activeRaw;
|
|
8505
|
+
}
|
|
8506
|
+
}
|
|
8507
|
+
roles.push({ name: entry.name, model, effort, staleVariant });
|
|
8508
|
+
}
|
|
8509
|
+
return roles.sort((a12, b) => a12.name.localeCompare(b.name));
|
|
8510
|
+
}
|
|
8511
|
+
function runtimeDriftReport(opts = {}) {
|
|
8512
|
+
const targetHome = opts.targetHome ?? os6.homedir();
|
|
8513
|
+
const stateFilePath = opts.stateFilePath ?? path12.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
8514
|
+
let state = opts.state ?? null;
|
|
8515
|
+
if (state === null) {
|
|
8516
|
+
try {
|
|
8517
|
+
state = readInstallState(stateFilePath);
|
|
8518
|
+
} catch {
|
|
8519
|
+
state = null;
|
|
8520
|
+
}
|
|
8521
|
+
}
|
|
8522
|
+
const platform = state?.platforms?.claude;
|
|
8523
|
+
const stateVersion = typeof platform?.plugin?.version === "string" ? platform.plugin.version : null;
|
|
8524
|
+
const activeProfile = platform?.modelProfile?.profile ?? null;
|
|
8525
|
+
const install = resolveClaudeMarketplaceInstall({ targetHome, pluginKey: opts.pluginKey });
|
|
8526
|
+
const liveRoot = install?.root ?? null;
|
|
8527
|
+
const sourceVersion = liveRoot === null ? null : readPluginVersion(liveRoot);
|
|
8528
|
+
const pinnedVersion = readInstalledPluginVersion({ targetHome, pluginKey: opts.pluginKey });
|
|
8529
|
+
const roles = liveRoot === null ? [] : readRoles(liveRoot, activeProfile);
|
|
8530
|
+
return {
|
|
8531
|
+
host: "claude",
|
|
8532
|
+
route: install?.route ?? "unresolved",
|
|
8533
|
+
liveRoot,
|
|
8534
|
+
sourceVersion,
|
|
8535
|
+
stateVersion,
|
|
8536
|
+
pinnedVersion,
|
|
8537
|
+
activeProfile,
|
|
8538
|
+
roles,
|
|
8539
|
+
envOverride: detectEnvOverride(opts.env ?? process.env),
|
|
8540
|
+
versionDrift: sourceVersion !== null && stateVersion !== null && sourceVersion !== stateVersion,
|
|
8541
|
+
profileMaterialized: roles.some((role) => role.staleVariant)
|
|
8542
|
+
};
|
|
8543
|
+
}
|
|
8544
|
+
var ENV_OVERRIDE_VARS;
|
|
8545
|
+
var init_doctor = __esm(() => {
|
|
8546
|
+
init_claude_marketplace();
|
|
8547
|
+
init_state();
|
|
8548
|
+
ENV_OVERRIDE_VARS = ["CLAUDE_CODE_SUBAGENT_MODEL"];
|
|
8549
|
+
});
|
|
8550
|
+
|
|
8551
|
+
// ../../packages/shared/dist/profile-switch/engine.js
|
|
8552
|
+
import fs9 from "fs";
|
|
8553
|
+
import path13 from "path";
|
|
8554
|
+
import os7 from "os";
|
|
8372
8555
|
import crypto5 from "crypto";
|
|
8373
8556
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
8374
8557
|
function namedError3(name, message) {
|
|
@@ -8377,10 +8560,10 @@ function namedError3(name, message) {
|
|
|
8377
8560
|
return err;
|
|
8378
8561
|
}
|
|
8379
8562
|
function defaultStatePath(targetHome) {
|
|
8380
|
-
return
|
|
8563
|
+
return path13.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
8381
8564
|
}
|
|
8382
8565
|
function resolveCommon(opts) {
|
|
8383
|
-
const targetHome = opts.targetHome ??
|
|
8566
|
+
const targetHome = opts.targetHome ?? os7.homedir();
|
|
8384
8567
|
const stateFilePath = opts.stateFilePath ?? defaultStatePath(targetHome);
|
|
8385
8568
|
return { targetHome, stateFilePath };
|
|
8386
8569
|
}
|
|
@@ -8388,7 +8571,7 @@ function marketplaceRoots(targetHome, state) {
|
|
|
8388
8571
|
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
8389
8572
|
}
|
|
8390
8573
|
function claudeMarketplaceUnresolvedReason(targetHome) {
|
|
8391
|
-
const registryPath =
|
|
8574
|
+
const registryPath = path13.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
8392
8575
|
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";
|
|
8393
8576
|
}
|
|
8394
8577
|
function listProfiles(opts = {}) {
|
|
@@ -8396,6 +8579,12 @@ function listProfiles(opts = {}) {
|
|
|
8396
8579
|
const state = readInstallState(stateFilePath);
|
|
8397
8580
|
const roots = marketplaceRoots(targetHome, state);
|
|
8398
8581
|
const universe = opts.hosts ?? HOSTS;
|
|
8582
|
+
const claudeDrift = universe.includes("claude") ? runtimeDriftReport({ targetHome, stateFilePath, state, env: opts.env }) : null;
|
|
8583
|
+
const claudeDriftFields = (host) => host === "claude" && claudeDrift !== null ? {
|
|
8584
|
+
liveRoot: claudeDrift.liveRoot,
|
|
8585
|
+
sourceVersion: claudeDrift.sourceVersion,
|
|
8586
|
+
envOverride: claudeDrift.envOverride ? `${claudeDrift.envOverride.name}=${claudeDrift.envOverride.value}` : null
|
|
8587
|
+
} : { liveRoot: null, sourceVersion: null, envOverride: null };
|
|
8399
8588
|
const hosts = universe.map((host) => {
|
|
8400
8589
|
if (host === "claude" && state.platforms.claude?.installRoute === "marketplace" && roots.claude === undefined) {
|
|
8401
8590
|
const platform2 = state.platforms.claude;
|
|
@@ -8406,7 +8595,8 @@ function listProfiles(opts = {}) {
|
|
|
8406
8595
|
skipReason: null,
|
|
8407
8596
|
activeProfile: platform2.modelProfile?.profile ?? opts.hostDefaults?.[host] ?? "balanced",
|
|
8408
8597
|
bundleVersion: platform2.plugin?.version ?? null,
|
|
8409
|
-
availableProfiles: []
|
|
8598
|
+
availableProfiles: [],
|
|
8599
|
+
...claudeDriftFields(host)
|
|
8410
8600
|
};
|
|
8411
8601
|
}
|
|
8412
8602
|
const layout = resolveHostLayout(host, { targetHome, projectRoot: opts.projectRoot, marketplaceRoot: roots });
|
|
@@ -8418,10 +8608,11 @@ function listProfiles(opts = {}) {
|
|
|
8418
8608
|
skipReason: layout.reason,
|
|
8419
8609
|
activeProfile: null,
|
|
8420
8610
|
bundleVersion: null,
|
|
8421
|
-
availableProfiles: []
|
|
8611
|
+
availableProfiles: [],
|
|
8612
|
+
...claudeDriftFields(host)
|
|
8422
8613
|
};
|
|
8423
8614
|
}
|
|
8424
|
-
const installed =
|
|
8615
|
+
const installed = fs9.existsSync(layout.activeDir);
|
|
8425
8616
|
const availableProfiles = listVariantProfiles(layout);
|
|
8426
8617
|
const platform = state.platforms[host];
|
|
8427
8618
|
return {
|
|
@@ -8431,15 +8622,16 @@ function listProfiles(opts = {}) {
|
|
|
8431
8622
|
skipReason: null,
|
|
8432
8623
|
activeProfile: platform?.modelProfile?.profile ?? opts.hostDefaults?.[host] ?? "balanced",
|
|
8433
8624
|
bundleVersion: platform?.plugin?.version ?? null,
|
|
8434
|
-
availableProfiles
|
|
8625
|
+
availableProfiles,
|
|
8626
|
+
...claudeDriftFields(host)
|
|
8435
8627
|
};
|
|
8436
8628
|
});
|
|
8437
8629
|
return { hosts };
|
|
8438
8630
|
}
|
|
8439
8631
|
function listVariantProfiles(layout) {
|
|
8440
|
-
if (!
|
|
8632
|
+
if (!fs9.existsSync(layout.variantsRoot))
|
|
8441
8633
|
return [];
|
|
8442
|
-
return
|
|
8634
|
+
return fs9.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
8443
8635
|
}
|
|
8444
8636
|
function matchesGlob(filename, glob) {
|
|
8445
8637
|
const starIdx = glob.indexOf("*");
|
|
@@ -8450,7 +8642,7 @@ function matchesGlob(filename, glob) {
|
|
|
8450
8642
|
return filename.length >= prefix.length + suffix.length && filename.startsWith(prefix) && filename.endsWith(suffix);
|
|
8451
8643
|
}
|
|
8452
8644
|
function matchingFileNames(dir, glob) {
|
|
8453
|
-
return
|
|
8645
|
+
return fs9.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && matchesGlob(e.name, glob)).map((e) => e.name);
|
|
8454
8646
|
}
|
|
8455
8647
|
function detectGitAvailability(dir) {
|
|
8456
8648
|
try {
|
|
@@ -8476,7 +8668,7 @@ function gitTrackedFileNames(dir, filenames) {
|
|
|
8476
8668
|
}
|
|
8477
8669
|
}
|
|
8478
8670
|
function checkTrackedPathGuard(activeDir, filenames) {
|
|
8479
|
-
if (filenames.length === 0 || !
|
|
8671
|
+
if (filenames.length === 0 || !fs9.existsSync(activeDir))
|
|
8480
8672
|
return GUARD_PASS;
|
|
8481
8673
|
const availability = detectGitAvailability(activeDir);
|
|
8482
8674
|
if (availability === "no-git")
|
|
@@ -8487,53 +8679,53 @@ function checkTrackedPathGuard(activeDir, filenames) {
|
|
|
8487
8679
|
if (tracked.size === 0)
|
|
8488
8680
|
return GUARD_PASS;
|
|
8489
8681
|
const offending = filenames.find((name) => tracked.has(name));
|
|
8490
|
-
return { blocked: true, path:
|
|
8682
|
+
return { blocked: true, path: path13.join(activeDir, offending), unchecked: false };
|
|
8491
8683
|
}
|
|
8492
8684
|
function assertStateWritable(stateFilePath) {
|
|
8493
|
-
const dir =
|
|
8685
|
+
const dir = path13.dirname(stateFilePath);
|
|
8494
8686
|
try {
|
|
8495
|
-
|
|
8687
|
+
fs9.mkdirSync(dir, { recursive: true });
|
|
8496
8688
|
} catch (err) {
|
|
8497
8689
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
8498
8690
|
}
|
|
8499
|
-
const checkPath =
|
|
8691
|
+
const checkPath = fs9.existsSync(stateFilePath) ? stateFilePath : dir;
|
|
8500
8692
|
try {
|
|
8501
|
-
|
|
8693
|
+
fs9.accessSync(checkPath, fs9.constants.W_OK);
|
|
8502
8694
|
} catch (err) {
|
|
8503
8695
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
8504
8696
|
}
|
|
8505
8697
|
}
|
|
8506
8698
|
function copyFileRouteVariant(layout, variantDir) {
|
|
8507
|
-
|
|
8699
|
+
fs9.mkdirSync(layout.activeDir, { recursive: true });
|
|
8508
8700
|
let changed = 0;
|
|
8509
|
-
for (const entry of
|
|
8701
|
+
for (const entry of fs9.readdirSync(variantDir, { withFileTypes: true })) {
|
|
8510
8702
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
8511
8703
|
continue;
|
|
8512
|
-
|
|
8704
|
+
fs9.copyFileSync(path13.join(variantDir, entry.name), path13.join(layout.activeDir, entry.name));
|
|
8513
8705
|
changed++;
|
|
8514
8706
|
}
|
|
8515
8707
|
return changed;
|
|
8516
8708
|
}
|
|
8517
8709
|
function repointOpencodeVariant(layout, variantDir) {
|
|
8518
|
-
|
|
8710
|
+
fs9.mkdirSync(layout.activeDir, { recursive: true });
|
|
8519
8711
|
let changed = 0;
|
|
8520
|
-
for (const entry of
|
|
8712
|
+
for (const entry of fs9.readdirSync(variantDir, { withFileTypes: true })) {
|
|
8521
8713
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
8522
8714
|
continue;
|
|
8523
|
-
const dest =
|
|
8524
|
-
const target =
|
|
8715
|
+
const dest = path13.join(layout.activeDir, entry.name);
|
|
8716
|
+
const target = path13.resolve(path13.join(variantDir, entry.name));
|
|
8525
8717
|
let destExists = true;
|
|
8526
8718
|
let destIsSymlink = false;
|
|
8527
8719
|
try {
|
|
8528
|
-
destIsSymlink =
|
|
8720
|
+
destIsSymlink = fs9.lstatSync(dest).isSymbolicLink();
|
|
8529
8721
|
} catch {
|
|
8530
8722
|
destExists = false;
|
|
8531
8723
|
}
|
|
8532
8724
|
if (destExists && !destIsSymlink)
|
|
8533
8725
|
continue;
|
|
8534
8726
|
const tmp = `${dest}.massa-ai-switch.${crypto5.randomUUID()}`;
|
|
8535
|
-
|
|
8536
|
-
|
|
8727
|
+
fs9.symlinkSync(target, tmp);
|
|
8728
|
+
fs9.renameSync(tmp, dest);
|
|
8537
8729
|
changed++;
|
|
8538
8730
|
}
|
|
8539
8731
|
return changed;
|
|
@@ -8573,13 +8765,13 @@ function switchProfile(opts) {
|
|
|
8573
8765
|
if (fileHosts.length === 0) {
|
|
8574
8766
|
return { profile: opts.profile, dryRun, hosts: orderRows(universe, skipRows), restartRequired: false };
|
|
8575
8767
|
}
|
|
8576
|
-
const installedFileHosts = fileHosts.filter((h) =>
|
|
8768
|
+
const installedFileHosts = fileHosts.filter((h) => fs9.existsSync(h.layout.activeDir));
|
|
8577
8769
|
if (installedFileHosts.length === 0)
|
|
8578
8770
|
throw NoHostsDetectedError();
|
|
8579
8771
|
const withAvailability = fileHosts.map((h) => {
|
|
8580
|
-
const variantsRootExists =
|
|
8772
|
+
const variantsRootExists = fs9.existsSync(h.layout.variantsRoot);
|
|
8581
8773
|
const variantDir = h.layout.variantDir(opts.profile);
|
|
8582
|
-
const available = variantsRootExists &&
|
|
8774
|
+
const available = variantsRootExists && fs9.existsSync(variantDir) && fs9.statSync(variantDir).isDirectory();
|
|
8583
8775
|
return { ...h, variantsRootExists, variantDir, available };
|
|
8584
8776
|
});
|
|
8585
8777
|
if (!withAvailability.some((h) => h.available)) {
|
|
@@ -8615,7 +8807,7 @@ function switchProfile(opts) {
|
|
|
8615
8807
|
continue;
|
|
8616
8808
|
}
|
|
8617
8809
|
if (dryRun) {
|
|
8618
|
-
rows.push({ host: h.host, status: "
|
|
8810
|
+
rows.push({ host: h.host, status: "would-switch" });
|
|
8619
8811
|
continue;
|
|
8620
8812
|
}
|
|
8621
8813
|
const candidateNames = matchingFileNames(h.variantDir, h.layout.activeGlob);
|
|
@@ -8660,6 +8852,7 @@ var init_engine = __esm(() => {
|
|
|
8660
8852
|
init_state();
|
|
8661
8853
|
init_lock();
|
|
8662
8854
|
init_claude_marketplace();
|
|
8855
|
+
init_doctor();
|
|
8663
8856
|
SwitchEngineError = class SwitchEngineError extends Error {
|
|
8664
8857
|
constructor(message) {
|
|
8665
8858
|
super(message);
|
|
@@ -8672,29 +8865,29 @@ var init_engine = __esm(() => {
|
|
|
8672
8865
|
|
|
8673
8866
|
// ../../packages/shared/dist/profile-switch/report.js
|
|
8674
8867
|
function reportSucceeded(report) {
|
|
8675
|
-
return report.hosts.every((h) => h.status === "switched" || h.status === "skipped");
|
|
8868
|
+
return report.hosts.every((h) => h.status === "switched" || h.status === "would-switch" || h.status === "skipped");
|
|
8676
8869
|
}
|
|
8677
8870
|
|
|
8678
8871
|
// ../../packages/shared/dist/profile-switch/variant-sync.js
|
|
8679
|
-
import
|
|
8680
|
-
import
|
|
8681
|
-
import
|
|
8872
|
+
import fs10 from "fs";
|
|
8873
|
+
import path14 from "path";
|
|
8874
|
+
import os8 from "os";
|
|
8682
8875
|
import crypto6 from "crypto";
|
|
8683
8876
|
function defaultStatePath2(targetHome) {
|
|
8684
|
-
return
|
|
8877
|
+
return path14.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
8685
8878
|
}
|
|
8686
8879
|
function marketplaceRoots2(targetHome, state) {
|
|
8687
8880
|
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
8688
8881
|
}
|
|
8689
8882
|
function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
8690
8883
|
const unique = `${process.pid}.${++tempFileCounter2}.${crypto6.randomBytes(6).toString("hex")}`;
|
|
8691
|
-
const tempFile =
|
|
8884
|
+
const tempFile = path14.join(destDir, `.${destName}.${unique}.tmp`);
|
|
8692
8885
|
try {
|
|
8693
|
-
|
|
8694
|
-
|
|
8886
|
+
fs10.writeFileSync(tempFile, content);
|
|
8887
|
+
fs10.renameSync(tempFile, path14.join(destDir, destName));
|
|
8695
8888
|
} catch (error) {
|
|
8696
8889
|
try {
|
|
8697
|
-
|
|
8890
|
+
fs10.unlinkSync(tempFile);
|
|
8698
8891
|
} catch {}
|
|
8699
8892
|
throw error;
|
|
8700
8893
|
}
|
|
@@ -8702,20 +8895,20 @@ function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
|
8702
8895
|
function isSafeDirName(name) {
|
|
8703
8896
|
if (name === "." || name === "..")
|
|
8704
8897
|
return false;
|
|
8705
|
-
if (name.includes("/") || name.includes("\\") || name.includes(
|
|
8898
|
+
if (name.includes("/") || name.includes("\\") || name.includes(path14.sep))
|
|
8706
8899
|
return false;
|
|
8707
|
-
return
|
|
8900
|
+
return path14.basename(name) === name;
|
|
8708
8901
|
}
|
|
8709
8902
|
function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
8710
8903
|
const layout = resolveHostLayout(host, { targetHome, marketplaceRoot });
|
|
8711
8904
|
if (layout.route === "skip") {
|
|
8712
8905
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: layout.reason };
|
|
8713
8906
|
}
|
|
8714
|
-
const srcDir =
|
|
8715
|
-
if (!
|
|
8907
|
+
const srcDir = path14.join(sourceRoot, "apps", `${host}-plugin`, "agent-profiles");
|
|
8908
|
+
if (!fs10.existsSync(srcDir) || !fs10.statSync(srcDir).isDirectory()) {
|
|
8716
8909
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: "no generated variants for this host" };
|
|
8717
8910
|
}
|
|
8718
|
-
if (!
|
|
8911
|
+
if (!fs10.existsSync(layout.variantsRoot)) {
|
|
8719
8912
|
return {
|
|
8720
8913
|
host,
|
|
8721
8914
|
status: "skipped",
|
|
@@ -8727,24 +8920,24 @@ function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
|
8727
8920
|
}
|
|
8728
8921
|
const profiles = [];
|
|
8729
8922
|
let files = 0;
|
|
8730
|
-
for (const entry of
|
|
8923
|
+
for (const entry of fs10.readdirSync(srcDir, { withFileTypes: true })) {
|
|
8731
8924
|
if (!entry.isDirectory())
|
|
8732
8925
|
continue;
|
|
8733
8926
|
if (!isSafeDirName(entry.name))
|
|
8734
8927
|
continue;
|
|
8735
|
-
const srcProfileDir =
|
|
8736
|
-
const destProfileDir =
|
|
8737
|
-
|
|
8738
|
-
for (const fileEntry of
|
|
8928
|
+
const srcProfileDir = path14.join(srcDir, entry.name);
|
|
8929
|
+
const destProfileDir = path14.join(layout.variantsRoot, entry.name);
|
|
8930
|
+
fs10.mkdirSync(destProfileDir, { recursive: true });
|
|
8931
|
+
for (const fileEntry of fs10.readdirSync(srcProfileDir, { withFileTypes: true })) {
|
|
8739
8932
|
if (!fileEntry.isFile())
|
|
8740
8933
|
continue;
|
|
8741
|
-
const content =
|
|
8934
|
+
const content = fs10.readFileSync(path14.join(srcProfileDir, fileEntry.name));
|
|
8742
8935
|
writeFileIntoDirAtomically(destProfileDir, fileEntry.name, content);
|
|
8743
8936
|
files++;
|
|
8744
8937
|
}
|
|
8745
8938
|
profiles.push(entry.name);
|
|
8746
8939
|
}
|
|
8747
|
-
const retained =
|
|
8940
|
+
const retained = fs10.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory() && !profiles.includes(e.name)).map((e) => e.name).sort();
|
|
8748
8941
|
return { host, status: "synced", profiles: profiles.sort(), retained, files };
|
|
8749
8942
|
}
|
|
8750
8943
|
function syncGeneratedVariants(opts) {
|
|
@@ -8760,7 +8953,7 @@ function syncGeneratedVariants(opts) {
|
|
|
8760
8953
|
}));
|
|
8761
8954
|
}
|
|
8762
8955
|
const sourceRoot = opts.sourceRoot;
|
|
8763
|
-
const targetHome = opts.targetHome ??
|
|
8956
|
+
const targetHome = opts.targetHome ?? os8.homedir();
|
|
8764
8957
|
const state = readInstallState(defaultStatePath2(targetHome));
|
|
8765
8958
|
const roots = marketplaceRoots2(targetHome, state);
|
|
8766
8959
|
return hosts.map((host) => {
|
|
@@ -8779,14 +8972,14 @@ var init_variant_sync = __esm(() => {
|
|
|
8779
8972
|
});
|
|
8780
8973
|
|
|
8781
8974
|
// ../../packages/shared/dist/profile-switch/repo-root.js
|
|
8782
|
-
import
|
|
8783
|
-
import
|
|
8975
|
+
import fs11 from "fs";
|
|
8976
|
+
import path15 from "path";
|
|
8784
8977
|
function findRepoRootWithMarker(startDir, marker, maxLevels) {
|
|
8785
8978
|
let dir = startDir;
|
|
8786
8979
|
for (let i = 0;i <= maxLevels; i++) {
|
|
8787
|
-
if (
|
|
8980
|
+
if (fs11.existsSync(path15.join(dir, marker)))
|
|
8788
8981
|
return dir;
|
|
8789
|
-
const parent =
|
|
8982
|
+
const parent = path15.dirname(dir);
|
|
8790
8983
|
if (parent === dir)
|
|
8791
8984
|
break;
|
|
8792
8985
|
dir = parent;
|
|
@@ -10426,7 +10619,7 @@ var import_brace_expansion, minimatch = (p, pattern, options = {}) => {
|
|
|
10426
10619
|
}, qmarksTestNoExtDot = ([$0]) => {
|
|
10427
10620
|
const len = $0.length;
|
|
10428
10621
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
10429
|
-
}, defaultPlatform,
|
|
10622
|
+
}, defaultPlatform, path16, sep, GLOBSTAR, qmark2 = "[^/]", star2, twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?", filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options), ext = (a12, b = {}) => Object.assign({}, a12, b), defaults = (def) => {
|
|
10430
10623
|
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
10431
10624
|
return minimatch;
|
|
10432
10625
|
}
|
|
@@ -10484,11 +10677,11 @@ var init_esm = __esm(() => {
|
|
|
10484
10677
|
starRE = /^\*+$/;
|
|
10485
10678
|
qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
10486
10679
|
defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
10487
|
-
|
|
10680
|
+
path16 = {
|
|
10488
10681
|
win32: { sep: "\\" },
|
|
10489
10682
|
posix: { sep: "/" }
|
|
10490
10683
|
};
|
|
10491
|
-
sep = defaultPlatform === "win32" ?
|
|
10684
|
+
sep = defaultPlatform === "win32" ? path16.win32.sep : path16.posix.sep;
|
|
10492
10685
|
minimatch.sep = sep;
|
|
10493
10686
|
GLOBSTAR = Symbol("globstar **");
|
|
10494
10687
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -12454,12 +12647,12 @@ var init_esm4 = __esm(() => {
|
|
|
12454
12647
|
childrenCache() {
|
|
12455
12648
|
return this.#children;
|
|
12456
12649
|
}
|
|
12457
|
-
resolve(
|
|
12458
|
-
if (!
|
|
12650
|
+
resolve(path17) {
|
|
12651
|
+
if (!path17) {
|
|
12459
12652
|
return this;
|
|
12460
12653
|
}
|
|
12461
|
-
const rootPath = this.getRootString(
|
|
12462
|
-
const dir =
|
|
12654
|
+
const rootPath = this.getRootString(path17);
|
|
12655
|
+
const dir = path17.substring(rootPath.length);
|
|
12463
12656
|
const dirParts = dir.split(this.splitSep);
|
|
12464
12657
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
12465
12658
|
return result;
|
|
@@ -12987,8 +13180,8 @@ var init_esm4 = __esm(() => {
|
|
|
12987
13180
|
newChild(name, type = UNKNOWN, opts = {}) {
|
|
12988
13181
|
return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
|
12989
13182
|
}
|
|
12990
|
-
getRootString(
|
|
12991
|
-
return win32.parse(
|
|
13183
|
+
getRootString(path17) {
|
|
13184
|
+
return win32.parse(path17).root;
|
|
12992
13185
|
}
|
|
12993
13186
|
getRoot(rootPath) {
|
|
12994
13187
|
rootPath = uncToDrive(rootPath.toUpperCase());
|
|
@@ -13013,8 +13206,8 @@ var init_esm4 = __esm(() => {
|
|
|
13013
13206
|
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
|
13014
13207
|
super(name, type, root, roots, nocase, children, opts);
|
|
13015
13208
|
}
|
|
13016
|
-
getRootString(
|
|
13017
|
-
return
|
|
13209
|
+
getRootString(path17) {
|
|
13210
|
+
return path17.startsWith("/") ? "/" : "";
|
|
13018
13211
|
}
|
|
13019
13212
|
getRoot(_rootPath) {
|
|
13020
13213
|
return this.root;
|
|
@@ -13033,8 +13226,8 @@ var init_esm4 = __esm(() => {
|
|
|
13033
13226
|
#children;
|
|
13034
13227
|
nocase;
|
|
13035
13228
|
#fs;
|
|
13036
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
13037
|
-
this.#fs = fsFromOption(
|
|
13229
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs12 = defaultFS } = {}) {
|
|
13230
|
+
this.#fs = fsFromOption(fs12);
|
|
13038
13231
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
13039
13232
|
cwd = fileURLToPath(cwd);
|
|
13040
13233
|
}
|
|
@@ -13070,11 +13263,11 @@ var init_esm4 = __esm(() => {
|
|
|
13070
13263
|
}
|
|
13071
13264
|
this.cwd = prev;
|
|
13072
13265
|
}
|
|
13073
|
-
depth(
|
|
13074
|
-
if (typeof
|
|
13075
|
-
|
|
13266
|
+
depth(path17 = this.cwd) {
|
|
13267
|
+
if (typeof path17 === "string") {
|
|
13268
|
+
path17 = this.cwd.resolve(path17);
|
|
13076
13269
|
}
|
|
13077
|
-
return
|
|
13270
|
+
return path17.depth();
|
|
13078
13271
|
}
|
|
13079
13272
|
childrenCache() {
|
|
13080
13273
|
return this.#children;
|
|
@@ -13490,9 +13683,9 @@ var init_esm4 = __esm(() => {
|
|
|
13490
13683
|
process2();
|
|
13491
13684
|
return results;
|
|
13492
13685
|
}
|
|
13493
|
-
chdir(
|
|
13686
|
+
chdir(path17 = this.cwd) {
|
|
13494
13687
|
const oldCwd = this.cwd;
|
|
13495
|
-
this.cwd = typeof
|
|
13688
|
+
this.cwd = typeof path17 === "string" ? this.cwd.resolve(path17) : path17;
|
|
13496
13689
|
this.cwd[setAsCwd](oldCwd);
|
|
13497
13690
|
}
|
|
13498
13691
|
};
|
|
@@ -13509,8 +13702,8 @@ var init_esm4 = __esm(() => {
|
|
|
13509
13702
|
parseRootPath(dir) {
|
|
13510
13703
|
return win32.parse(dir).root.toUpperCase();
|
|
13511
13704
|
}
|
|
13512
|
-
newRoot(
|
|
13513
|
-
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
13705
|
+
newRoot(fs12) {
|
|
13706
|
+
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs12 });
|
|
13514
13707
|
}
|
|
13515
13708
|
isAbsolute(p) {
|
|
13516
13709
|
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
@@ -13526,8 +13719,8 @@ var init_esm4 = __esm(() => {
|
|
|
13526
13719
|
parseRootPath(_dir) {
|
|
13527
13720
|
return "/";
|
|
13528
13721
|
}
|
|
13529
|
-
newRoot(
|
|
13530
|
-
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
13722
|
+
newRoot(fs12) {
|
|
13723
|
+
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs12 });
|
|
13531
13724
|
}
|
|
13532
13725
|
isAbsolute(p) {
|
|
13533
13726
|
return p.startsWith("/");
|
|
@@ -13784,8 +13977,8 @@ class MatchRecord {
|
|
|
13784
13977
|
this.store.set(target, current === undefined ? n2 : n2 & current);
|
|
13785
13978
|
}
|
|
13786
13979
|
entries() {
|
|
13787
|
-
return [...this.store.entries()].map(([
|
|
13788
|
-
|
|
13980
|
+
return [...this.store.entries()].map(([path17, n2]) => [
|
|
13981
|
+
path17,
|
|
13789
13982
|
!!(n2 & 2),
|
|
13790
13983
|
!!(n2 & 1)
|
|
13791
13984
|
]);
|
|
@@ -13989,9 +14182,9 @@ class GlobUtil {
|
|
|
13989
14182
|
signal;
|
|
13990
14183
|
maxDepth;
|
|
13991
14184
|
includeChildMatches;
|
|
13992
|
-
constructor(patterns,
|
|
14185
|
+
constructor(patterns, path17, opts) {
|
|
13993
14186
|
this.patterns = patterns;
|
|
13994
|
-
this.path =
|
|
14187
|
+
this.path = path17;
|
|
13995
14188
|
this.opts = opts;
|
|
13996
14189
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
13997
14190
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -14010,11 +14203,11 @@ class GlobUtil {
|
|
|
14010
14203
|
});
|
|
14011
14204
|
}
|
|
14012
14205
|
}
|
|
14013
|
-
#ignored(
|
|
14014
|
-
return this.seen.has(
|
|
14206
|
+
#ignored(path17) {
|
|
14207
|
+
return this.seen.has(path17) || !!this.#ignore?.ignored?.(path17);
|
|
14015
14208
|
}
|
|
14016
|
-
#childrenIgnored(
|
|
14017
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
14209
|
+
#childrenIgnored(path17) {
|
|
14210
|
+
return !!this.#ignore?.childrenIgnored?.(path17);
|
|
14018
14211
|
}
|
|
14019
14212
|
pause() {
|
|
14020
14213
|
this.paused = true;
|
|
@@ -14231,8 +14424,8 @@ var init_walker = __esm(() => {
|
|
|
14231
14424
|
init_processor();
|
|
14232
14425
|
GlobWalker = class GlobWalker extends GlobUtil {
|
|
14233
14426
|
matches = new Set;
|
|
14234
|
-
constructor(patterns,
|
|
14235
|
-
super(patterns,
|
|
14427
|
+
constructor(patterns, path17, opts) {
|
|
14428
|
+
super(patterns, path17, opts);
|
|
14236
14429
|
}
|
|
14237
14430
|
matchEmit(e) {
|
|
14238
14431
|
this.matches.add(e);
|
|
@@ -14269,8 +14462,8 @@ var init_walker = __esm(() => {
|
|
|
14269
14462
|
};
|
|
14270
14463
|
GlobStream = class GlobStream extends GlobUtil {
|
|
14271
14464
|
results;
|
|
14272
|
-
constructor(patterns,
|
|
14273
|
-
super(patterns,
|
|
14465
|
+
constructor(patterns, path17, opts) {
|
|
14466
|
+
super(patterns, path17, opts);
|
|
14274
14467
|
this.results = new Minipass({
|
|
14275
14468
|
signal: this.signal,
|
|
14276
14469
|
objectMode: true
|
|
@@ -14698,20 +14891,20 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14698
14891
|
var throwError = (message, Ctor) => {
|
|
14699
14892
|
throw new Ctor(message);
|
|
14700
14893
|
};
|
|
14701
|
-
var checkPath = (
|
|
14702
|
-
if (!isString(
|
|
14894
|
+
var checkPath = (path17, originalPath, doThrow) => {
|
|
14895
|
+
if (!isString(path17)) {
|
|
14703
14896
|
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
14704
14897
|
}
|
|
14705
|
-
if (!
|
|
14898
|
+
if (!path17) {
|
|
14706
14899
|
return doThrow(`path must not be empty`, TypeError);
|
|
14707
14900
|
}
|
|
14708
|
-
if (checkPath.isNotRelative(
|
|
14901
|
+
if (checkPath.isNotRelative(path17)) {
|
|
14709
14902
|
const r2 = "`path.relative()`d";
|
|
14710
14903
|
return doThrow(`path should be a ${r2} string, but got "${originalPath}"`, RangeError);
|
|
14711
14904
|
}
|
|
14712
14905
|
return true;
|
|
14713
14906
|
};
|
|
14714
|
-
var isNotRelative = (
|
|
14907
|
+
var isNotRelative = (path17) => REGEX_TEST_INVALID_PATH.test(path17);
|
|
14715
14908
|
checkPath.isNotRelative = isNotRelative;
|
|
14716
14909
|
checkPath.convert = (p) => p;
|
|
14717
14910
|
|
|
@@ -14754,7 +14947,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14754
14947
|
addPattern(pattern) {
|
|
14755
14948
|
return this.add(pattern);
|
|
14756
14949
|
}
|
|
14757
|
-
_testOne(
|
|
14950
|
+
_testOne(path17, checkUnignored) {
|
|
14758
14951
|
let ignored = false;
|
|
14759
14952
|
let unignored = false;
|
|
14760
14953
|
this._rules.forEach((rule) => {
|
|
@@ -14762,7 +14955,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14762
14955
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
14763
14956
|
return;
|
|
14764
14957
|
}
|
|
14765
|
-
const matched = rule.regex.test(
|
|
14958
|
+
const matched = rule.regex.test(path17);
|
|
14766
14959
|
if (matched) {
|
|
14767
14960
|
ignored = !negative;
|
|
14768
14961
|
unignored = negative;
|
|
@@ -14774,39 +14967,39 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14774
14967
|
};
|
|
14775
14968
|
}
|
|
14776
14969
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
14777
|
-
const
|
|
14778
|
-
checkPath(
|
|
14779
|
-
return this._t(
|
|
14970
|
+
const path17 = originalPath && checkPath.convert(originalPath);
|
|
14971
|
+
checkPath(path17, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
14972
|
+
return this._t(path17, cache, checkUnignored, slices);
|
|
14780
14973
|
}
|
|
14781
|
-
_t(
|
|
14782
|
-
if (
|
|
14783
|
-
return cache[
|
|
14974
|
+
_t(path17, cache, checkUnignored, slices) {
|
|
14975
|
+
if (path17 in cache) {
|
|
14976
|
+
return cache[path17];
|
|
14784
14977
|
}
|
|
14785
14978
|
if (!slices) {
|
|
14786
|
-
slices =
|
|
14979
|
+
slices = path17.split(SLASH);
|
|
14787
14980
|
}
|
|
14788
14981
|
slices.pop();
|
|
14789
14982
|
if (!slices.length) {
|
|
14790
|
-
return cache[
|
|
14983
|
+
return cache[path17] = this._testOne(path17, checkUnignored);
|
|
14791
14984
|
}
|
|
14792
14985
|
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
14793
|
-
return cache[
|
|
14986
|
+
return cache[path17] = parent.ignored ? parent : this._testOne(path17, checkUnignored);
|
|
14794
14987
|
}
|
|
14795
|
-
ignores(
|
|
14796
|
-
return this._test(
|
|
14988
|
+
ignores(path17) {
|
|
14989
|
+
return this._test(path17, this._ignoreCache, false).ignored;
|
|
14797
14990
|
}
|
|
14798
14991
|
createFilter() {
|
|
14799
|
-
return (
|
|
14992
|
+
return (path17) => !this.ignores(path17);
|
|
14800
14993
|
}
|
|
14801
14994
|
filter(paths) {
|
|
14802
14995
|
return makeArray(paths).filter(this.createFilter());
|
|
14803
14996
|
}
|
|
14804
|
-
test(
|
|
14805
|
-
return this._test(
|
|
14997
|
+
test(path17) {
|
|
14998
|
+
return this._test(path17, this._testCache, true);
|
|
14806
14999
|
}
|
|
14807
15000
|
}
|
|
14808
15001
|
var factory = (options) => new Ignore2(options);
|
|
14809
|
-
var isPathValid = (
|
|
15002
|
+
var isPathValid = (path17) => checkPath(path17 && checkPath.convert(path17), path17, RETURN_FALSE);
|
|
14810
15003
|
factory.isPathValid = isPathValid;
|
|
14811
15004
|
factory.default = factory;
|
|
14812
15005
|
module.exports = factory;
|
|
@@ -14814,7 +15007,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14814
15007
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
14815
15008
|
checkPath.convert = makePosix;
|
|
14816
15009
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
14817
|
-
checkPath.isNotRelative = (
|
|
15010
|
+
checkPath.isNotRelative = (path17) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path17) || isNotRelative(path17);
|
|
14818
15011
|
}
|
|
14819
15012
|
});
|
|
14820
15013
|
|
|
@@ -14876,13 +15069,13 @@ function validatePolicy(policy, opts = {}) {
|
|
|
14876
15069
|
}
|
|
14877
15070
|
}
|
|
14878
15071
|
}
|
|
14879
|
-
function matchesGlob2(
|
|
15072
|
+
function matchesGlob2(path17, pattern) {
|
|
14880
15073
|
let re = regexCache.get(pattern);
|
|
14881
15074
|
if (!re) {
|
|
14882
15075
|
re = globToRegex(pattern);
|
|
14883
15076
|
regexCache.set(pattern, re);
|
|
14884
15077
|
}
|
|
14885
|
-
return re.test(
|
|
15078
|
+
return re.test(path17);
|
|
14886
15079
|
}
|
|
14887
15080
|
var DEFAULT_POLICY, applyPolicy = (filePath, policy) => {
|
|
14888
15081
|
const normalized = filePath.trim();
|
|
@@ -14899,8 +15092,8 @@ var init_capture_policy = __esm(() => {
|
|
|
14899
15092
|
});
|
|
14900
15093
|
|
|
14901
15094
|
// ../../packages/core/dist/services/search/ignore-patterns.js
|
|
14902
|
-
import
|
|
14903
|
-
import
|
|
15095
|
+
import fs12 from "fs/promises";
|
|
15096
|
+
import path17 from "path";
|
|
14904
15097
|
function buildExtensionGlob(extensions2) {
|
|
14905
15098
|
return extensions2.map((ext2) => `**/*${ext2}`);
|
|
14906
15099
|
}
|
|
@@ -14923,8 +15116,8 @@ async function loadProjectIgnore(projectPath) {
|
|
|
14923
15116
|
const ig = ignore();
|
|
14924
15117
|
ig.add(DEFAULT_IGNORES);
|
|
14925
15118
|
try {
|
|
14926
|
-
const gitignorePath =
|
|
14927
|
-
const gitignoreContent = await
|
|
15119
|
+
const gitignorePath = path17.join(projectPath, ".gitignore");
|
|
15120
|
+
const gitignoreContent = await fs12.readFile(gitignorePath, "utf8");
|
|
14928
15121
|
const rules = gitignoreContent.split(`
|
|
14929
15122
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
14930
15123
|
ig.add(rules);
|
|
@@ -15178,8 +15371,8 @@ var init_alias_resolver = __esm(() => {
|
|
|
15178
15371
|
});
|
|
15179
15372
|
|
|
15180
15373
|
// ../../packages/core/dist/services/search/index-manager.js
|
|
15181
|
-
import
|
|
15182
|
-
import
|
|
15374
|
+
import fs13 from "fs";
|
|
15375
|
+
import path18 from "path";
|
|
15183
15376
|
|
|
15184
15377
|
class IndexManager {
|
|
15185
15378
|
metadataCache = new Map;
|
|
@@ -15272,9 +15465,9 @@ class IndexManager {
|
|
|
15272
15465
|
const fileMetadata = {};
|
|
15273
15466
|
let totalSize = 0;
|
|
15274
15467
|
for (const filePath of indexedFiles) {
|
|
15275
|
-
const fullPath =
|
|
15468
|
+
const fullPath = path18.join(projectPath, filePath);
|
|
15276
15469
|
try {
|
|
15277
|
-
const stat2 = await
|
|
15470
|
+
const stat2 = await fs13.promises.stat(fullPath);
|
|
15278
15471
|
fileMetadata[filePath] = {
|
|
15279
15472
|
path: filePath,
|
|
15280
15473
|
mtime: stat2.mtimeMs,
|
|
@@ -15325,9 +15518,9 @@ class IndexManager {
|
|
|
15325
15518
|
if (ig.ignores(match2)) {
|
|
15326
15519
|
continue;
|
|
15327
15520
|
}
|
|
15328
|
-
const fullPath =
|
|
15521
|
+
const fullPath = path18.join(projectPath, match2);
|
|
15329
15522
|
try {
|
|
15330
|
-
const stat2 = await
|
|
15523
|
+
const stat2 = await fs13.promises.stat(fullPath);
|
|
15331
15524
|
files.set(match2, {
|
|
15332
15525
|
path: match2,
|
|
15333
15526
|
mtime: stat2.mtimeMs,
|
|
@@ -15778,10 +15971,10 @@ function mergeDefs(...defs) {
|
|
|
15778
15971
|
function cloneDef(schema) {
|
|
15779
15972
|
return mergeDefs(schema._zod.def);
|
|
15780
15973
|
}
|
|
15781
|
-
function getElementAtPath(obj,
|
|
15782
|
-
if (!
|
|
15974
|
+
function getElementAtPath(obj, path19) {
|
|
15975
|
+
if (!path19)
|
|
15783
15976
|
return obj;
|
|
15784
|
-
return
|
|
15977
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
15785
15978
|
}
|
|
15786
15979
|
function promiseAllObject(promisesObj) {
|
|
15787
15980
|
const keys = Object.keys(promisesObj);
|
|
@@ -16109,11 +16302,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
16109
16302
|
}
|
|
16110
16303
|
return false;
|
|
16111
16304
|
}
|
|
16112
|
-
function prefixIssues(
|
|
16305
|
+
function prefixIssues(path19, issues) {
|
|
16113
16306
|
return issues.map((iss) => {
|
|
16114
16307
|
var _a4;
|
|
16115
16308
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
16116
|
-
iss.path.unshift(
|
|
16309
|
+
iss.path.unshift(path19);
|
|
16117
16310
|
return iss;
|
|
16118
16311
|
});
|
|
16119
16312
|
}
|
|
@@ -16326,16 +16519,16 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
|
|
|
16326
16519
|
}
|
|
16327
16520
|
function formatError(error, mapper = (issue2) => issue2.message) {
|
|
16328
16521
|
const fieldErrors = { _errors: [] };
|
|
16329
|
-
const processError = (error2,
|
|
16522
|
+
const processError = (error2, path19 = []) => {
|
|
16330
16523
|
for (const issue2 of error2.issues) {
|
|
16331
16524
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
16332
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
16525
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
16333
16526
|
} else if (issue2.code === "invalid_key") {
|
|
16334
|
-
processError({ issues: issue2.issues }, [...
|
|
16527
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16335
16528
|
} else if (issue2.code === "invalid_element") {
|
|
16336
|
-
processError({ issues: issue2.issues }, [...
|
|
16529
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16337
16530
|
} else {
|
|
16338
|
-
const fullpath = [...
|
|
16531
|
+
const fullpath = [...path19, ...issue2.path];
|
|
16339
16532
|
if (fullpath.length === 0) {
|
|
16340
16533
|
fieldErrors._errors.push(mapper(issue2));
|
|
16341
16534
|
} else {
|
|
@@ -16362,17 +16555,17 @@ function formatError(error, mapper = (issue2) => issue2.message) {
|
|
|
16362
16555
|
}
|
|
16363
16556
|
function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
16364
16557
|
const result = { errors: [] };
|
|
16365
|
-
const processError = (error2,
|
|
16558
|
+
const processError = (error2, path19 = []) => {
|
|
16366
16559
|
var _a4, _b;
|
|
16367
16560
|
for (const issue2 of error2.issues) {
|
|
16368
16561
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
16369
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
16562
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
16370
16563
|
} else if (issue2.code === "invalid_key") {
|
|
16371
|
-
processError({ issues: issue2.issues }, [...
|
|
16564
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16372
16565
|
} else if (issue2.code === "invalid_element") {
|
|
16373
|
-
processError({ issues: issue2.issues }, [...
|
|
16566
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16374
16567
|
} else {
|
|
16375
|
-
const fullpath = [...
|
|
16568
|
+
const fullpath = [...path19, ...issue2.path];
|
|
16376
16569
|
if (fullpath.length === 0) {
|
|
16377
16570
|
result.errors.push(mapper(issue2));
|
|
16378
16571
|
continue;
|
|
@@ -16404,8 +16597,8 @@ function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
|
16404
16597
|
}
|
|
16405
16598
|
function toDotPath(_path) {
|
|
16406
16599
|
const segs = [];
|
|
16407
|
-
const
|
|
16408
|
-
for (const seg of
|
|
16600
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
16601
|
+
for (const seg of path19) {
|
|
16409
16602
|
if (typeof seg === "number")
|
|
16410
16603
|
segs.push(`[${seg}]`);
|
|
16411
16604
|
else if (typeof seg === "symbol")
|
|
@@ -29408,13 +29601,13 @@ function resolveRef(ref, ctx) {
|
|
|
29408
29601
|
if (!ref.startsWith("#")) {
|
|
29409
29602
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
29410
29603
|
}
|
|
29411
|
-
const
|
|
29412
|
-
if (
|
|
29604
|
+
const path19 = ref.slice(1).split("/").filter(Boolean);
|
|
29605
|
+
if (path19.length === 0) {
|
|
29413
29606
|
return ctx.rootSchema;
|
|
29414
29607
|
}
|
|
29415
29608
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
29416
|
-
if (
|
|
29417
|
-
const key =
|
|
29609
|
+
if (path19[0] === defsKey) {
|
|
29610
|
+
const key = path19[1];
|
|
29418
29611
|
if (!key || !ctx.defs[key]) {
|
|
29419
29612
|
throw new Error(`Reference not found: ${ref}`);
|
|
29420
29613
|
}
|
|
@@ -30903,8 +31096,8 @@ class ParseStatus2 {
|
|
|
30903
31096
|
}
|
|
30904
31097
|
}
|
|
30905
31098
|
var makeIssue2 = (params) => {
|
|
30906
|
-
const { data, path:
|
|
30907
|
-
const fullPath = [...
|
|
31099
|
+
const { data, path: path19, errorMaps, issueData } = params;
|
|
31100
|
+
const fullPath = [...path19, ...issueData.path || []];
|
|
30908
31101
|
const fullIssue = {
|
|
30909
31102
|
...issueData,
|
|
30910
31103
|
path: fullPath
|
|
@@ -30949,11 +31142,11 @@ var init_errorUtil = __esm(() => {
|
|
|
30949
31142
|
|
|
30950
31143
|
// ../../node_modules/zod/v3/types.js
|
|
30951
31144
|
class ParseInputLazyPath2 {
|
|
30952
|
-
constructor(parent, value,
|
|
31145
|
+
constructor(parent, value, path19, key) {
|
|
30953
31146
|
this._cachedPath = [];
|
|
30954
31147
|
this.parent = parent;
|
|
30955
31148
|
this.data = value;
|
|
30956
|
-
this._path =
|
|
31149
|
+
this._path = path19;
|
|
30957
31150
|
this._key = key;
|
|
30958
31151
|
}
|
|
30959
31152
|
get path() {
|
|
@@ -37018,23 +37211,23 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
37018
37211
|
writeAuthConfig: () => writeAuthConfig
|
|
37019
37212
|
});
|
|
37020
37213
|
module.exports = __toCommonJS2(auth_config_exports);
|
|
37021
|
-
var
|
|
37022
|
-
var
|
|
37214
|
+
var fs14 = __toESM2(__require("fs"));
|
|
37215
|
+
var path19 = __toESM2(__require("path"));
|
|
37023
37216
|
var import_token_util = require_token_util();
|
|
37024
37217
|
function getAuthConfigPath() {
|
|
37025
37218
|
const dataDir = (0, import_token_util.getVercelDataDir)();
|
|
37026
37219
|
if (!dataDir) {
|
|
37027
37220
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
37028
37221
|
}
|
|
37029
|
-
return
|
|
37222
|
+
return path19.join(dataDir, "auth.json");
|
|
37030
37223
|
}
|
|
37031
37224
|
function readAuthConfig() {
|
|
37032
37225
|
try {
|
|
37033
37226
|
const authPath = getAuthConfigPath();
|
|
37034
|
-
if (!
|
|
37227
|
+
if (!fs14.existsSync(authPath)) {
|
|
37035
37228
|
return null;
|
|
37036
37229
|
}
|
|
37037
|
-
const content =
|
|
37230
|
+
const content = fs14.readFileSync(authPath, "utf8");
|
|
37038
37231
|
if (!content) {
|
|
37039
37232
|
return null;
|
|
37040
37233
|
}
|
|
@@ -37045,11 +37238,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
37045
37238
|
}
|
|
37046
37239
|
function writeAuthConfig(config3) {
|
|
37047
37240
|
const authPath = getAuthConfigPath();
|
|
37048
|
-
const authDir =
|
|
37049
|
-
if (!
|
|
37050
|
-
|
|
37241
|
+
const authDir = path19.dirname(authPath);
|
|
37242
|
+
if (!fs14.existsSync(authDir)) {
|
|
37243
|
+
fs14.mkdirSync(authDir, { mode: 504, recursive: true });
|
|
37051
37244
|
}
|
|
37052
|
-
|
|
37245
|
+
fs14.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
|
|
37053
37246
|
}
|
|
37054
37247
|
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
37055
37248
|
if (!authConfig.token)
|
|
@@ -37224,8 +37417,8 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37224
37417
|
saveToken: () => saveToken
|
|
37225
37418
|
});
|
|
37226
37419
|
module.exports = __toCommonJS2(token_util_exports);
|
|
37227
|
-
var
|
|
37228
|
-
var
|
|
37420
|
+
var path19 = __toESM2(__require("path"));
|
|
37421
|
+
var fs14 = __toESM2(__require("fs"));
|
|
37229
37422
|
var import_token_error = require_token_error();
|
|
37230
37423
|
var import_token_io = require_token_io();
|
|
37231
37424
|
var import_auth_config = require_auth_config();
|
|
@@ -37237,7 +37430,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37237
37430
|
if (!dataDir) {
|
|
37238
37431
|
return null;
|
|
37239
37432
|
}
|
|
37240
|
-
return
|
|
37433
|
+
return path19.join(dataDir, vercelFolder);
|
|
37241
37434
|
}
|
|
37242
37435
|
async function getVercelToken2(options) {
|
|
37243
37436
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -37305,11 +37498,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37305
37498
|
if (!dir) {
|
|
37306
37499
|
throw new import_token_error.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");
|
|
37307
37500
|
}
|
|
37308
|
-
const prjPath =
|
|
37309
|
-
if (!
|
|
37501
|
+
const prjPath = path19.join(dir, ".vercel", "project.json");
|
|
37502
|
+
if (!fs14.existsSync(prjPath)) {
|
|
37310
37503
|
throw new import_token_error.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");
|
|
37311
37504
|
}
|
|
37312
|
-
const prj = JSON.parse(
|
|
37505
|
+
const prj = JSON.parse(fs14.readFileSync(prjPath, "utf8"));
|
|
37313
37506
|
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
|
|
37314
37507
|
throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");
|
|
37315
37508
|
}
|
|
@@ -37320,11 +37513,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37320
37513
|
if (!dir) {
|
|
37321
37514
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
37322
37515
|
}
|
|
37323
|
-
const tokenPath =
|
|
37516
|
+
const tokenPath = path19.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
37324
37517
|
const tokenJson = JSON.stringify(token);
|
|
37325
|
-
|
|
37326
|
-
|
|
37327
|
-
|
|
37518
|
+
fs14.mkdirSync(path19.dirname(tokenPath), { mode: 504, recursive: true });
|
|
37519
|
+
fs14.writeFileSync(tokenPath, tokenJson);
|
|
37520
|
+
fs14.chmodSync(tokenPath, 432);
|
|
37328
37521
|
return;
|
|
37329
37522
|
}
|
|
37330
37523
|
function loadToken(projectId) {
|
|
@@ -37332,11 +37525,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37332
37525
|
if (!dir) {
|
|
37333
37526
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
37334
37527
|
}
|
|
37335
|
-
const tokenPath =
|
|
37336
|
-
if (!
|
|
37528
|
+
const tokenPath = path19.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
37529
|
+
if (!fs14.existsSync(tokenPath)) {
|
|
37337
37530
|
return null;
|
|
37338
37531
|
}
|
|
37339
|
-
const token = JSON.parse(
|
|
37532
|
+
const token = JSON.parse(fs14.readFileSync(tokenPath, "utf8"));
|
|
37340
37533
|
assertVercelOidcTokenResponse(token);
|
|
37341
37534
|
return token;
|
|
37342
37535
|
}
|
|
@@ -48178,37 +48371,37 @@ function createOpenAI(options = {}) {
|
|
|
48178
48371
|
}, `ai-sdk/openai/${VERSION4}`);
|
|
48179
48372
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
48180
48373
|
provider: `${providerName}.chat`,
|
|
48181
|
-
url: ({ path:
|
|
48374
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48182
48375
|
headers: getHeaders,
|
|
48183
48376
|
fetch: options.fetch
|
|
48184
48377
|
});
|
|
48185
48378
|
const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
|
|
48186
48379
|
provider: `${providerName}.completion`,
|
|
48187
|
-
url: ({ path:
|
|
48380
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48188
48381
|
headers: getHeaders,
|
|
48189
48382
|
fetch: options.fetch
|
|
48190
48383
|
});
|
|
48191
48384
|
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
48192
48385
|
provider: `${providerName}.embedding`,
|
|
48193
|
-
url: ({ path:
|
|
48386
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48194
48387
|
headers: getHeaders,
|
|
48195
48388
|
fetch: options.fetch
|
|
48196
48389
|
});
|
|
48197
48390
|
const createImageModel = (modelId) => new OpenAIImageModel(modelId, {
|
|
48198
48391
|
provider: `${providerName}.image`,
|
|
48199
|
-
url: ({ path:
|
|
48392
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48200
48393
|
headers: getHeaders,
|
|
48201
48394
|
fetch: options.fetch
|
|
48202
48395
|
});
|
|
48203
48396
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
48204
48397
|
provider: `${providerName}.transcription`,
|
|
48205
|
-
url: ({ path:
|
|
48398
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48206
48399
|
headers: getHeaders,
|
|
48207
48400
|
fetch: options.fetch
|
|
48208
48401
|
});
|
|
48209
48402
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
48210
48403
|
provider: `${providerName}.speech`,
|
|
48211
|
-
url: ({ path:
|
|
48404
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48212
48405
|
headers: getHeaders,
|
|
48213
48406
|
fetch: options.fetch
|
|
48214
48407
|
});
|
|
@@ -48221,7 +48414,7 @@ function createOpenAI(options = {}) {
|
|
|
48221
48414
|
const createResponsesModel = (modelId) => {
|
|
48222
48415
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
48223
48416
|
provider: `${providerName}.responses`,
|
|
48224
|
-
url: ({ path:
|
|
48417
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48225
48418
|
headers: getHeaders,
|
|
48226
48419
|
fetch: options.fetch,
|
|
48227
48420
|
fileIdPrefixes: ["file-"]
|
|
@@ -64833,26 +65026,26 @@ var require_process = __commonJS((exports, module) => {
|
|
|
64833
65026
|
|
|
64834
65027
|
// ../../node_modules/detect-libc/lib/filesystem.js
|
|
64835
65028
|
var require_filesystem = __commonJS((exports, module) => {
|
|
64836
|
-
var
|
|
65029
|
+
var fs14 = __require("fs");
|
|
64837
65030
|
var LDD_PATH = "/usr/bin/ldd";
|
|
64838
65031
|
var SELF_PATH = "/proc/self/exe";
|
|
64839
65032
|
var MAX_LENGTH = 2048;
|
|
64840
|
-
var readFileSync2 = (
|
|
64841
|
-
const fd =
|
|
65033
|
+
var readFileSync2 = (path19) => {
|
|
65034
|
+
const fd = fs14.openSync(path19, "r");
|
|
64842
65035
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
64843
|
-
const bytesRead =
|
|
64844
|
-
|
|
65036
|
+
const bytesRead = fs14.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
65037
|
+
fs14.close(fd, () => {});
|
|
64845
65038
|
return buffer.subarray(0, bytesRead);
|
|
64846
65039
|
};
|
|
64847
|
-
var readFile = (
|
|
64848
|
-
|
|
65040
|
+
var readFile = (path19) => new Promise((resolve4, reject) => {
|
|
65041
|
+
fs14.open(path19, "r", (err, fd) => {
|
|
64849
65042
|
if (err) {
|
|
64850
65043
|
reject(err);
|
|
64851
65044
|
} else {
|
|
64852
65045
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
64853
|
-
|
|
65046
|
+
fs14.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
|
|
64854
65047
|
resolve4(buffer.subarray(0, bytesRead));
|
|
64855
|
-
|
|
65048
|
+
fs14.close(fd, () => {});
|
|
64856
65049
|
});
|
|
64857
65050
|
}
|
|
64858
65051
|
});
|
|
@@ -64957,11 +65150,11 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
64957
65150
|
}
|
|
64958
65151
|
return null;
|
|
64959
65152
|
};
|
|
64960
|
-
var familyFromInterpreterPath = (
|
|
64961
|
-
if (
|
|
64962
|
-
if (
|
|
65153
|
+
var familyFromInterpreterPath = (path19) => {
|
|
65154
|
+
if (path19) {
|
|
65155
|
+
if (path19.includes("/ld-musl-")) {
|
|
64963
65156
|
return MUSL;
|
|
64964
|
-
} else if (
|
|
65157
|
+
} else if (path19.includes("/ld-linux-")) {
|
|
64965
65158
|
return GLIBC;
|
|
64966
65159
|
}
|
|
64967
65160
|
}
|
|
@@ -65006,8 +65199,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
65006
65199
|
cachedFamilyInterpreter = null;
|
|
65007
65200
|
try {
|
|
65008
65201
|
const selfContent = await readFile(SELF_PATH);
|
|
65009
|
-
const
|
|
65010
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
65202
|
+
const path19 = interpreterPath(selfContent);
|
|
65203
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path19);
|
|
65011
65204
|
} catch (e) {}
|
|
65012
65205
|
return cachedFamilyInterpreter;
|
|
65013
65206
|
};
|
|
@@ -65018,8 +65211,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
65018
65211
|
cachedFamilyInterpreter = null;
|
|
65019
65212
|
try {
|
|
65020
65213
|
const selfContent = readFileSync2(SELF_PATH);
|
|
65021
|
-
const
|
|
65022
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
65214
|
+
const path19 = interpreterPath(selfContent);
|
|
65215
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path19);
|
|
65023
65216
|
} catch (e) {}
|
|
65024
65217
|
return cachedFamilyInterpreter;
|
|
65025
65218
|
};
|
|
@@ -66681,18 +66874,18 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
66681
66874
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
66682
66875
|
"@img/sharp-wasm32/sharp.node"
|
|
66683
66876
|
];
|
|
66684
|
-
var
|
|
66877
|
+
var path19;
|
|
66685
66878
|
var sharp;
|
|
66686
66879
|
var errors5 = [];
|
|
66687
|
-
for (
|
|
66880
|
+
for (path19 of paths) {
|
|
66688
66881
|
try {
|
|
66689
|
-
sharp = __require(
|
|
66882
|
+
sharp = __require(path19);
|
|
66690
66883
|
break;
|
|
66691
66884
|
} catch (err) {
|
|
66692
66885
|
errors5.push(err);
|
|
66693
66886
|
}
|
|
66694
66887
|
}
|
|
66695
|
-
if (sharp &&
|
|
66888
|
+
if (sharp && path19.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
66696
66889
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
66697
66890
|
err.code = "Unsupported CPU";
|
|
66698
66891
|
errors5.push(err);
|
|
@@ -66701,7 +66894,7 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
66701
66894
|
if (sharp) {
|
|
66702
66895
|
module.exports = sharp;
|
|
66703
66896
|
} else {
|
|
66704
|
-
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((
|
|
66897
|
+
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((os9) => runtimePlatform.startsWith(os9));
|
|
66705
66898
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
66706
66899
|
errors5.forEach((err) => {
|
|
66707
66900
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -66714,9 +66907,9 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
66714
66907
|
const { found, expected } = isUnsupportedNodeRuntime();
|
|
66715
66908
|
help.push("- Please upgrade Node.js:", ` Found ${found}`, ` Requires ${expected}`);
|
|
66716
66909
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
66717
|
-
const [
|
|
66718
|
-
const libc =
|
|
66719
|
-
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=${
|
|
66910
|
+
const [os9, cpu] = runtimePlatform.split("-");
|
|
66911
|
+
const libc = os9.endsWith("musl") ? " --libc=musl" : "";
|
|
66912
|
+
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=${os9.replace("musl", "")}${libc} --cpu=${cpu} sharp`);
|
|
66720
66913
|
} else {
|
|
66721
66914
|
help.push(`- Manually install libvips >= ${minimumLibvipsVersion}`, "- Add experimental WebAssembly-based dependencies:", " npm install --cpu=wasm32 sharp", " npm install @img/sharp-wasm32");
|
|
66722
66915
|
}
|
|
@@ -69554,15 +69747,15 @@ var require_color = __commonJS((exports, module) => {
|
|
|
69554
69747
|
};
|
|
69555
69748
|
}
|
|
69556
69749
|
function wrapConversion(toModel, graph) {
|
|
69557
|
-
const
|
|
69750
|
+
const path19 = [graph[toModel].parent, toModel];
|
|
69558
69751
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
69559
69752
|
let cur = graph[toModel].parent;
|
|
69560
69753
|
while (graph[cur].parent) {
|
|
69561
|
-
|
|
69754
|
+
path19.unshift(graph[cur].parent);
|
|
69562
69755
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
69563
69756
|
cur = graph[cur].parent;
|
|
69564
69757
|
}
|
|
69565
|
-
fn.conversion =
|
|
69758
|
+
fn.conversion = path19;
|
|
69566
69759
|
return fn;
|
|
69567
69760
|
}
|
|
69568
69761
|
function route(fromModel) {
|
|
@@ -70167,7 +70360,7 @@ var require_output = __commonJS((exports, module) => {
|
|
|
70167
70360
|
Copyright 2013 Lovell Fuller and others.
|
|
70168
70361
|
SPDX-License-Identifier: Apache-2.0
|
|
70169
70362
|
*/
|
|
70170
|
-
var
|
|
70363
|
+
var path19 = __require("path");
|
|
70171
70364
|
var is = require_is();
|
|
70172
70365
|
var sharp = require_sharp();
|
|
70173
70366
|
var formats = new Map([
|
|
@@ -70198,9 +70391,9 @@ var require_output = __commonJS((exports, module) => {
|
|
|
70198
70391
|
let err;
|
|
70199
70392
|
if (!is.string(fileOut)) {
|
|
70200
70393
|
err = new Error("Missing output file path");
|
|
70201
|
-
} else if (is.string(this.options.input.file) &&
|
|
70394
|
+
} else if (is.string(this.options.input.file) && path19.resolve(this.options.input.file) === path19.resolve(fileOut)) {
|
|
70202
70395
|
err = new Error("Cannot use same file for input and output");
|
|
70203
|
-
} else if (jp2Regex.test(
|
|
70396
|
+
} else if (jp2Regex.test(path19.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
70204
70397
|
err = errJp2Save();
|
|
70205
70398
|
}
|
|
70206
70399
|
if (err) {
|
|
@@ -77447,11 +77640,11 @@ var init_transformers_node = __esm(() => {
|
|
|
77447
77640
|
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}).`);
|
|
77448
77641
|
}
|
|
77449
77642
|
for (let i = 0;i < num_chunks; ++i) {
|
|
77450
|
-
const
|
|
77451
|
-
const fullPath = `${options.subfolder ?? ""}/${
|
|
77643
|
+
const path19 = `${baseName}_data${i === 0 ? "" : "_" + i}`;
|
|
77644
|
+
const fullPath = `${options.subfolder ?? ""}/${path19}`;
|
|
77452
77645
|
externalDataPromises.push(new Promise(async (resolve4, reject) => {
|
|
77453
77646
|
const data = await (0, _utils_hub_js__WEBPACK_IMPORTED_MODULE_5__.getModelFile)(pretrained_model_name_or_path, fullPath, true, options, return_path);
|
|
77454
|
-
resolve4(data instanceof Uint8Array ? { path:
|
|
77647
|
+
resolve4(data instanceof Uint8Array ? { path: path19, data } : path19);
|
|
77455
77648
|
}));
|
|
77456
77649
|
}
|
|
77457
77650
|
} else if (session_options.externalData !== undefined) {
|
|
@@ -90515,7 +90708,7 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90515
90708
|
const blob = new Blob([wav], { type: "audio/wav" });
|
|
90516
90709
|
return blob;
|
|
90517
90710
|
}
|
|
90518
|
-
async save(
|
|
90711
|
+
async save(path19) {
|
|
90519
90712
|
let fn;
|
|
90520
90713
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_BROWSER_ENV) {
|
|
90521
90714
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_WEBWORKER_ENV) {
|
|
@@ -90523,14 +90716,14 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90523
90716
|
}
|
|
90524
90717
|
fn = _core_js__WEBPACK_IMPORTED_MODULE_2__.saveBlob;
|
|
90525
90718
|
} else if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_FS_AVAILABLE) {
|
|
90526
|
-
fn = async (
|
|
90719
|
+
fn = async (path20, blob) => {
|
|
90527
90720
|
let buffer = await blob.arrayBuffer();
|
|
90528
|
-
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(
|
|
90721
|
+
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(path20, Buffer.from(buffer));
|
|
90529
90722
|
};
|
|
90530
90723
|
} else {
|
|
90531
90724
|
throw new Error("Unable to save because filesystem is disabled in this environment.");
|
|
90532
90725
|
}
|
|
90533
|
-
await fn(
|
|
90726
|
+
await fn(path19, this.toBlob());
|
|
90534
90727
|
}
|
|
90535
90728
|
}
|
|
90536
90729
|
},
|
|
@@ -90626,11 +90819,11 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90626
90819
|
function calculateReflectOffset(i, w) {
|
|
90627
90820
|
return Math.abs((i + w) % (2 * w) - w);
|
|
90628
90821
|
}
|
|
90629
|
-
function saveBlob(
|
|
90822
|
+
function saveBlob(path19, blob) {
|
|
90630
90823
|
const dataURL = URL.createObjectURL(blob);
|
|
90631
90824
|
const downloadLink = document.createElement("a");
|
|
90632
90825
|
downloadLink.href = dataURL;
|
|
90633
|
-
downloadLink.download =
|
|
90826
|
+
downloadLink.download = path19;
|
|
90634
90827
|
downloadLink.click();
|
|
90635
90828
|
downloadLink.remove();
|
|
90636
90829
|
URL.revokeObjectURL(dataURL);
|
|
@@ -91231,8 +91424,8 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
91231
91424
|
}
|
|
91232
91425
|
|
|
91233
91426
|
class FileCache {
|
|
91234
|
-
constructor(
|
|
91235
|
-
this.path =
|
|
91427
|
+
constructor(path19) {
|
|
91428
|
+
this.path = path19;
|
|
91236
91429
|
}
|
|
91237
91430
|
async match(request) {
|
|
91238
91431
|
let filePath = node_path__WEBPACK_IMPORTED_MODULE_1__["default"].join(this.path, request);
|
|
@@ -91988,20 +92181,20 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
91988
92181
|
}
|
|
91989
92182
|
return this;
|
|
91990
92183
|
}
|
|
91991
|
-
async save(
|
|
92184
|
+
async save(path19) {
|
|
91992
92185
|
if (IS_BROWSER_OR_WEBWORKER) {
|
|
91993
92186
|
if (_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_WEBWORKER_ENV) {
|
|
91994
92187
|
throw new Error("Unable to save an image from a Web Worker.");
|
|
91995
92188
|
}
|
|
91996
|
-
const extension =
|
|
92189
|
+
const extension = path19.split(".").pop().toLowerCase();
|
|
91997
92190
|
const mime2 = CONTENT_TYPE_MAP.get(extension) ?? "image/png";
|
|
91998
92191
|
const blob = await this.toBlob(mime2);
|
|
91999
|
-
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(
|
|
92192
|
+
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(path19, blob);
|
|
92000
92193
|
} else if (!_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_FS_AVAILABLE) {
|
|
92001
92194
|
throw new Error("Unable to save the image because filesystem is disabled in this environment.");
|
|
92002
92195
|
} else {
|
|
92003
92196
|
const img = this.toSharp();
|
|
92004
|
-
return await img.toFile(
|
|
92197
|
+
return await img.toFile(path19);
|
|
92005
92198
|
}
|
|
92006
92199
|
}
|
|
92007
92200
|
toSharp() {
|
|
@@ -101230,7 +101423,7 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a12;
|
|
|
101230
101423
|
function ns(e = Yo, t2 = Yo) {
|
|
101231
101424
|
return (r2) => e(t2(r2));
|
|
101232
101425
|
}
|
|
101233
|
-
function
|
|
101426
|
+
function os9({ dataPath: e, modelName: t2, args: r2, runtimeDataModel: n2 }) {
|
|
101234
101427
|
let i = { modelName: t2, args: r2 ?? {} }, o = dp(e);
|
|
101235
101428
|
if (!o || o.length === 0)
|
|
101236
101429
|
return i;
|
|
@@ -101535,10 +101728,10 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a12;
|
|
|
101535
101728
|
super(t2, "P2023", r2);
|
|
101536
101729
|
}
|
|
101537
101730
|
};
|
|
101538
|
-
var
|
|
101731
|
+
var fs14 = new WeakMap;
|
|
101539
101732
|
function Ep(e) {
|
|
101540
|
-
let t2 =
|
|
101541
|
-
return t2 || (t2 = Object.entries(e),
|
|
101733
|
+
let t2 = fs14.get(e);
|
|
101734
|
+
return t2 || (t2 = Object.entries(e), fs14.set(e, t2)), t2;
|
|
101542
101735
|
}
|
|
101543
101736
|
function hs(e, t2, r2) {
|
|
101544
101737
|
switch (t2.type) {
|
|
@@ -105103,7 +105296,7 @@ new PrismaClient({
|
|
|
105103
105296
|
let m2 = await es(this, d);
|
|
105104
105297
|
if (!d.model)
|
|
105105
105298
|
return m2;
|
|
105106
|
-
let g =
|
|
105299
|
+
let g = os9({ dataPath: d.dataPath, modelName: d.model, args: d.args, runtimeDataModel: this._runtimeDataModel });
|
|
105107
105300
|
return Wo({ result: m2, modelName: g.modelName, args: g.args, extensions: this._extensions, runtimeDataModel: this._runtimeDataModel, globalOmit: this._globalOmit });
|
|
105108
105301
|
};
|
|
105109
105302
|
return this._tracingHelper.runInChildSpan(s.operation, () => new zl.AsyncResource("prisma-client-request").runInAsyncScope(() => a12(o)));
|
|
@@ -105506,7 +105699,7 @@ var require_prisma = __commonJS((exports) => {
|
|
|
105506
105699
|
Prisma.JsonNull = JsonNull2;
|
|
105507
105700
|
Prisma.AnyNull = AnyNull2;
|
|
105508
105701
|
Prisma.NullTypes = NullTypes2;
|
|
105509
|
-
var
|
|
105702
|
+
var path19 = __require("path");
|
|
105510
105703
|
exports.Prisma.TransactionIsolationLevel = makeStrictEnum2({
|
|
105511
105704
|
ReadUncommitted: "ReadUncommitted",
|
|
105512
105705
|
ReadCommitted: "ReadCommitted",
|
|
@@ -115839,10 +116032,10 @@ var init_chunker_code = __esm(() => {
|
|
|
115839
116032
|
});
|
|
115840
116033
|
|
|
115841
116034
|
// ../../packages/core/dist/services/search/smart-chunker.js
|
|
115842
|
-
import
|
|
116035
|
+
import path19 from "path";
|
|
115843
116036
|
function smartChunk(content, filePath, config3 = {}) {
|
|
115844
116037
|
const cfg = { ...DEFAULT_CONFIG, ...config3 };
|
|
115845
|
-
const ext2 =
|
|
116038
|
+
const ext2 = path19.extname(filePath).toLowerCase();
|
|
115846
116039
|
const relativePath = filePath;
|
|
115847
116040
|
const fileImports = isCodeFile(ext2) ? extractFileImports(content, ext2) : undefined;
|
|
115848
116041
|
let chunks;
|
|
@@ -116180,8 +116373,8 @@ var init_embedding_freshness = __esm(() => {
|
|
|
116180
116373
|
});
|
|
116181
116374
|
|
|
116182
116375
|
// ../../packages/core/dist/services/search/project-indexer.js
|
|
116183
|
-
import
|
|
116184
|
-
import
|
|
116376
|
+
import fs14 from "fs/promises";
|
|
116377
|
+
import path20 from "path";
|
|
116185
116378
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
116186
116379
|
async function runWithIndexLock(lockMap, projectId, work) {
|
|
116187
116380
|
const prevLock = lockMap.get(projectId);
|
|
@@ -116224,7 +116417,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
116224
116417
|
dot: false
|
|
116225
116418
|
});
|
|
116226
116419
|
const filteredFiles = files.filter((file3) => {
|
|
116227
|
-
const relativePath =
|
|
116420
|
+
const relativePath = path20.relative(projectPath, file3);
|
|
116228
116421
|
const shouldIgnore = ig.ignores(relativePath);
|
|
116229
116422
|
if (shouldIgnore) {
|
|
116230
116423
|
logger.debug("Ignoring file per .gitignore during indexing", {
|
|
@@ -116264,7 +116457,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
116264
116457
|
});
|
|
116265
116458
|
}
|
|
116266
116459
|
}
|
|
116267
|
-
const indexedFilesList = filteredFiles.map((f) =>
|
|
116460
|
+
const indexedFilesList = filteredFiles.map((f) => path20.relative(projectPath, f));
|
|
116268
116461
|
await deps.indexManager.updateIndexMetadata(projectId, projectPath, indexedFilesList);
|
|
116269
116462
|
logger.info("Project indexing completed", {
|
|
116270
116463
|
projectId,
|
|
@@ -116394,7 +116587,7 @@ async function ensureFreshIndex(deps, projectId, projectPath, options = {}) {
|
|
|
116394
116587
|
let errors5 = 0;
|
|
116395
116588
|
for (const relativeFilePath of filesToReindex) {
|
|
116396
116589
|
try {
|
|
116397
|
-
const fullPath =
|
|
116590
|
+
const fullPath = path20.join(projectPath, relativeFilePath);
|
|
116398
116591
|
const result = await deps.indexFile(fullPath, projectId, projectPath, centralityMap);
|
|
116399
116592
|
filesIndexed++;
|
|
116400
116593
|
chunksIndexed += result.chunks;
|
|
@@ -116454,8 +116647,8 @@ async function checkSearchAdmission(deps, projectId, projectPath) {
|
|
|
116454
116647
|
}
|
|
116455
116648
|
async function indexFile(deps, filePath, projectId, projectRoot, centralityMap) {
|
|
116456
116649
|
projectId = await getProjectIdentityAliasResolver().resolve(projectId);
|
|
116457
|
-
const content = await
|
|
116458
|
-
const relativePath =
|
|
116650
|
+
const content = await fs14.readFile(filePath, "utf-8");
|
|
116651
|
+
const relativePath = path20.relative(projectRoot, filePath);
|
|
116459
116652
|
const maxFileSize = config.get("security").maxFileSize || 1024 * 1024;
|
|
116460
116653
|
if (content.length > maxFileSize) {
|
|
116461
116654
|
logger.warn("File too large, skipping", {
|
|
@@ -116475,7 +116668,7 @@ async function indexFile(deps, filePath, projectId, projectRoot, centralityMap)
|
|
|
116475
116668
|
chunkIndex: i,
|
|
116476
116669
|
totalChunks: chunks.length,
|
|
116477
116670
|
type: chunk.type,
|
|
116478
|
-
language:
|
|
116671
|
+
language: path20.extname(filePath).slice(1),
|
|
116479
116672
|
lineStart: chunk.lineStart,
|
|
116480
116673
|
lineEnd: chunk.lineEnd,
|
|
116481
116674
|
label: chunk.label,
|
|
@@ -118540,8 +118733,8 @@ function stripNul(content) {
|
|
|
118540
118733
|
}
|
|
118541
118734
|
|
|
118542
118735
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
118543
|
-
import
|
|
118544
|
-
import
|
|
118736
|
+
import fs15 from "fs/promises";
|
|
118737
|
+
import path21 from "path";
|
|
118545
118738
|
import { createHash as createHash5 } from "crypto";
|
|
118546
118739
|
|
|
118547
118740
|
class DiscoverStage {
|
|
@@ -118567,7 +118760,7 @@ class DiscoverStage {
|
|
|
118567
118760
|
dot: false,
|
|
118568
118761
|
absolute: false
|
|
118569
118762
|
});
|
|
118570
|
-
relPaths = found.map((p) =>
|
|
118763
|
+
relPaths = found.map((p) => path21.isAbsolute(p) ? path21.relative(ctx.projectPath, p) : p).filter((p) => !ig.ignores(p) && applyPolicy(p, policy) !== "Drop");
|
|
118571
118764
|
}
|
|
118572
118765
|
if (ctx.resumeCursor?.path) {
|
|
118573
118766
|
const cursorPath = ctx.resumeCursor.path;
|
|
@@ -118626,10 +118819,10 @@ class DiscoverStage {
|
|
|
118626
118819
|
return discovered;
|
|
118627
118820
|
}
|
|
118628
118821
|
async processFile(ctx, relativePath, forceReindex) {
|
|
118629
|
-
const absolutePath =
|
|
118822
|
+
const absolutePath = path21.join(ctx.projectPath, relativePath);
|
|
118630
118823
|
try {
|
|
118631
|
-
const stat2 = await
|
|
118632
|
-
const content = stripNul(await
|
|
118824
|
+
const stat2 = await fs15.stat(absolutePath);
|
|
118825
|
+
const content = stripNul(await fs15.readFile(absolutePath, "utf-8"));
|
|
118633
118826
|
const contentHash = createHash5("sha256").update(content).digest("hex");
|
|
118634
118827
|
let needsReparse = forceReindex;
|
|
118635
118828
|
if (!forceReindex) {
|
|
@@ -118672,8 +118865,8 @@ class DiscoverStage {
|
|
|
118672
118865
|
ig.add(pattern);
|
|
118673
118866
|
}
|
|
118674
118867
|
try {
|
|
118675
|
-
const gitignorePath =
|
|
118676
|
-
const gitignoreContent = await
|
|
118868
|
+
const gitignorePath = path21.join(projectPath, ".gitignore");
|
|
118869
|
+
const gitignoreContent = await fs15.readFile(gitignorePath, "utf8");
|
|
118677
118870
|
const rules = gitignoreContent.split(`
|
|
118678
118871
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
118679
118872
|
ig.add(rules);
|
|
@@ -120028,8 +120221,8 @@ function rustUseLeaves(node2, source, prefix = []) {
|
|
|
120028
120221
|
}
|
|
120029
120222
|
if (node2.type === "use_wildcard")
|
|
120030
120223
|
return [{ path: [...prefix, "*"], glob: true }];
|
|
120031
|
-
const
|
|
120032
|
-
return
|
|
120224
|
+
const path22 = rustPathSegments(node2, source);
|
|
120225
|
+
return path22.length ? [{ path: [...prefix, ...path22] }] : [];
|
|
120033
120226
|
}
|
|
120034
120227
|
function functionalCaptures(captures, source, family) {
|
|
120035
120228
|
if (family !== "clojure")
|
|
@@ -121001,8 +121194,8 @@ var init_structural_runtime = __esm(() => {
|
|
|
121001
121194
|
});
|
|
121002
121195
|
|
|
121003
121196
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
121004
|
-
import
|
|
121005
|
-
import
|
|
121197
|
+
import path22 from "path";
|
|
121198
|
+
import fs16 from "fs/promises";
|
|
121006
121199
|
function resolveChunkerMaxChars() {
|
|
121007
121200
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
121008
121201
|
if (Number.isFinite(global2) && global2 > 0)
|
|
@@ -121030,8 +121223,8 @@ class ParseStage {
|
|
|
121030
121223
|
const results = new Map;
|
|
121031
121224
|
let processed = 0;
|
|
121032
121225
|
const phases = [
|
|
121033
|
-
files.filter((file3) =>
|
|
121034
|
-
files.filter((file3) =>
|
|
121226
|
+
files.filter((file3) => path22.extname(file3.relativePath).toLowerCase() !== ".h"),
|
|
121227
|
+
files.filter((file3) => path22.extname(file3.relativePath).toLowerCase() === ".h")
|
|
121035
121228
|
];
|
|
121036
121229
|
const batches = phases.flatMap((phase) => Array.from({ length: Math.ceil(phase.length / BATCH_SIZE) }, (_2, index) => phase.slice(index * BATCH_SIZE, (index + 1) * BATCH_SIZE)));
|
|
121037
121230
|
for (const batch of batches) {
|
|
@@ -121069,19 +121262,19 @@ class ParseStage {
|
|
|
121069
121262
|
return files.map((file3) => results.get(file3.relativePath));
|
|
121070
121263
|
}
|
|
121071
121264
|
recordHeaderImporterEvidence(ctx, files, parsedFiles) {
|
|
121072
|
-
const knownHeaders = new Set(files.filter((file3) =>
|
|
121265
|
+
const knownHeaders = new Set(files.filter((file3) => path22.extname(file3.relativePath).toLowerCase() === ".h").map((file3) => path22.posix.normalize(file3.relativePath)));
|
|
121073
121266
|
const mutable = {
|
|
121074
121267
|
...ctx.structuralHeaderEvidenceByFile
|
|
121075
121268
|
};
|
|
121076
121269
|
for (const parsed of parsedFiles) {
|
|
121077
|
-
const extension =
|
|
121270
|
+
const extension = path22.extname(parsed.file.relativePath).toLowerCase();
|
|
121078
121271
|
const key = extension === ".c" ? "cImporters" : [".cpp", ".hpp"].includes(extension) ? "cppImporters" : undefined;
|
|
121079
121272
|
if (!key)
|
|
121080
121273
|
continue;
|
|
121081
121274
|
for (const imported of parsed.rawImports) {
|
|
121082
121275
|
if (!["c_include", "cpp_include"].includes(imported.form) || imported.specifier.startsWith("<"))
|
|
121083
121276
|
continue;
|
|
121084
|
-
const header =
|
|
121277
|
+
const header = path22.posix.normalize(path22.posix.join(path22.posix.dirname(parsed.file.relativePath), imported.specifier));
|
|
121085
121278
|
if (!knownHeaders.has(header))
|
|
121086
121279
|
continue;
|
|
121087
121280
|
const existing = mutable[header] ?? {};
|
|
@@ -121092,9 +121285,9 @@ class ParseStage {
|
|
|
121092
121285
|
}
|
|
121093
121286
|
async parseFile(ctx, file3) {
|
|
121094
121287
|
if (!file3.needsReparse) {
|
|
121095
|
-
const extension =
|
|
121288
|
+
const extension = path22.extname(file3.relativePath).toLowerCase();
|
|
121096
121289
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
121097
|
-
const content = file3.snapshotContent ?? await
|
|
121290
|
+
const content = file3.snapshotContent ?? await fs16.readFile(file3.absolutePath, "utf8");
|
|
121098
121291
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
121099
121292
|
if (outcome.status === "failed")
|
|
121100
121293
|
throw new StructuralEtlParseError(file3.relativePath, outcome.failureKind, `Structural evidence parse failed (${outcome.failureKind})`, outcome.diagnosticCount, outcome.diagnostics.slice(0, 10));
|
|
@@ -121106,8 +121299,8 @@ class ParseStage {
|
|
|
121106
121299
|
return { file: file3, chunks: [], symbols: [], rawImports: [], rawEdges: [] };
|
|
121107
121300
|
}
|
|
121108
121301
|
try {
|
|
121109
|
-
const content = file3.snapshotContent ?? await
|
|
121110
|
-
const ext2 =
|
|
121302
|
+
const content = file3.snapshotContent ?? await fs16.readFile(file3.absolutePath, "utf-8");
|
|
121303
|
+
const ext2 = path22.extname(file3.relativePath).toLowerCase();
|
|
121111
121304
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
121112
121305
|
const chunks = smartChunk(content, file3.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
121113
121306
|
let symbols;
|
|
@@ -121661,7 +121854,7 @@ var init_resolver = __esm(() => {
|
|
|
121661
121854
|
});
|
|
121662
121855
|
|
|
121663
121856
|
// ../../packages/core/dist/services/structural/resolvers/typescript.js
|
|
121664
|
-
import
|
|
121857
|
+
import path23 from "path";
|
|
121665
121858
|
function candidates(identities) {
|
|
121666
121859
|
return Object.freeze(identities.map((identity) => Object.freeze({
|
|
121667
121860
|
fqn: identity.fqn,
|
|
@@ -121756,7 +121949,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
121756
121949
|
const bases = /\.[cm]?jsx?$/u.test(base) ? [base.replace(/\.[cm]?jsx?$/u, ".ts"), base.replace(/\.[cm]?jsx?$/u, ".tsx"), base] : [base];
|
|
121757
121950
|
for (const candidateBase of bases)
|
|
121758
121951
|
for (const suffix of DIALECT_PROBES[dialect] ?? [""]) {
|
|
121759
|
-
const value =
|
|
121952
|
+
const value = path23.posix.normalize(`${candidateBase}${suffix}`);
|
|
121760
121953
|
if (!value.startsWith("../") && value !== ".." && known.has(value))
|
|
121761
121954
|
return value;
|
|
121762
121955
|
}
|
|
@@ -121765,7 +121958,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
121765
121958
|
function resolveStructuralSpecifier(specifier, fromFile, build, dialect = "typescript") {
|
|
121766
121959
|
const known = new Set(build.knownFiles.map(normalizeStructuralFile));
|
|
121767
121960
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
121768
|
-
return probe(
|
|
121961
|
+
return probe(path23.posix.join(path23.posix.dirname(fromFile), specifier), known, dialect);
|
|
121769
121962
|
}
|
|
121770
121963
|
const aliases = build.pathAliasesByFile?.[normalizeStructuralFile(fromFile)] ?? build.pathAliases ?? [];
|
|
121771
121964
|
for (const alias of aliases) {
|
|
@@ -122029,7 +122222,7 @@ var init_scripting2 = __esm(() => {
|
|
|
122029
122222
|
});
|
|
122030
122223
|
|
|
122031
122224
|
// ../../packages/core/dist/services/structural/resolvers/systems.js
|
|
122032
|
-
import
|
|
122225
|
+
import path24 from "path";
|
|
122033
122226
|
var DIALECTS, SYSTEMS_LANGUAGE_RESOLVER;
|
|
122034
122227
|
var init_systems2 = __esm(() => {
|
|
122035
122228
|
init_typescript2();
|
|
@@ -122048,7 +122241,7 @@ var init_systems2 = __esm(() => {
|
|
|
122048
122241
|
const bindings = item.bindings.map((binding) => binding.imported === "*" && binding.local === "*" && unresolvedTarget && !unresolvedTarget.qualifier ? { ...binding, imported: unresolvedTarget.name, local: unresolvedTarget.name } : binding);
|
|
122049
122242
|
if (item.specifier === "crate" || item.specifier.startsWith("crate/")) {
|
|
122050
122243
|
const crateRoot = file3.file.startsWith("src/") ? "src" : "";
|
|
122051
|
-
return { ...item, bindings, specifier: `./${
|
|
122244
|
+
return { ...item, bindings, specifier: `./${path24.posix.relative(path24.posix.dirname(file3.file), path24.posix.join(crateRoot, item.specifier.replace(/^crate\/?/u, "")))}` };
|
|
122052
122245
|
}
|
|
122053
122246
|
if (item.specifier === "self" || item.specifier.startsWith("self/"))
|
|
122054
122247
|
return { ...item, bindings, specifier: `./${item.specifier.replace(/^self\/?/u, "")}` };
|
|
@@ -122146,8 +122339,8 @@ var init_data_document2 = __esm(() => {
|
|
|
122146
122339
|
});
|
|
122147
122340
|
|
|
122148
122341
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
122149
|
-
import
|
|
122150
|
-
import
|
|
122342
|
+
import path25 from "path";
|
|
122343
|
+
import fs17 from "fs";
|
|
122151
122344
|
|
|
122152
122345
|
class ResolveStage {
|
|
122153
122346
|
symbolRepository;
|
|
@@ -122171,7 +122364,7 @@ class ResolveStage {
|
|
|
122171
122364
|
const structuralDocuments = files.flatMap((file3) => {
|
|
122172
122365
|
if (!file3.structure)
|
|
122173
122366
|
return [];
|
|
122174
|
-
const language = resolveStructuralLanguage(
|
|
122367
|
+
const language = resolveStructuralLanguage(path25.extname(file3.file.relativePath));
|
|
122175
122368
|
if (language.status !== "supported")
|
|
122176
122369
|
throw new Error(`structural_manifest_missing:${file3.file.relativePath}`);
|
|
122177
122370
|
return [{
|
|
@@ -122183,13 +122376,13 @@ class ResolveStage {
|
|
|
122183
122376
|
}];
|
|
122184
122377
|
});
|
|
122185
122378
|
const currentStructuralFiles = new Set(structuralDocuments.map((document2) => document2.file));
|
|
122186
|
-
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
122379
|
+
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));
|
|
122187
122380
|
const pathAliasesByFile = Object.fromEntries([...knownRelPaths].map((file3) => [
|
|
122188
122381
|
file3,
|
|
122189
122382
|
this.structuralAliasesFor(file3, rootAliases, monorepoPackages)
|
|
122190
122383
|
]));
|
|
122191
122384
|
const buildMetadata = { knownFiles: [...knownRelPaths], pathAliasesByFile };
|
|
122192
|
-
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(
|
|
122385
|
+
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));
|
|
122193
122386
|
const seedIds = new Set;
|
|
122194
122387
|
for (const definition of seedRows) {
|
|
122195
122388
|
if (seedIds.has(definition.id))
|
|
@@ -122282,7 +122475,7 @@ class ResolveStage {
|
|
|
122282
122475
|
if (parsed.file !== definition.file_path) {
|
|
122283
122476
|
throw new Error(`structural_repository_seed_file_mismatch:${definition.id}`);
|
|
122284
122477
|
}
|
|
122285
|
-
const language = resolveStructuralLanguage(
|
|
122478
|
+
const language = resolveStructuralLanguage(path25.extname(definition.file_path));
|
|
122286
122479
|
if (language.status !== "supported")
|
|
122287
122480
|
throw new Error(`structural_repository_seed_language:${definition.id}`);
|
|
122288
122481
|
let identity;
|
|
@@ -122334,7 +122527,7 @@ class ResolveStage {
|
|
|
122334
122527
|
});
|
|
122335
122528
|
}
|
|
122336
122529
|
resolveFile(parsed, projectPath, knownRelPaths, rootAliases, monorepoPackages, symbolIndex, knownFqns) {
|
|
122337
|
-
const fromDir =
|
|
122530
|
+
const fromDir = path25.dirname(path25.join(projectPath, parsed.file.relativePath));
|
|
122338
122531
|
const packageAliases = this.getPackageAliases(parsed.file.relativePath, monorepoPackages);
|
|
122339
122532
|
const allAliases = [...packageAliases, ...rootAliases];
|
|
122340
122533
|
const resolvedImports = parsed.rawImports.map((raw2) => {
|
|
@@ -122405,7 +122598,7 @@ class ResolveStage {
|
|
|
122405
122598
|
index.set(def.name, `${def.file_path}#${def.name}`);
|
|
122406
122599
|
}
|
|
122407
122600
|
} catch (err) {
|
|
122408
|
-
const skippedStructural = files.some((file3) => !file3.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
122601
|
+
const skippedStructural = files.some((file3) => !file3.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path25.extname(file3.file.relativePath).toLowerCase()));
|
|
122409
122602
|
if (skippedStructural)
|
|
122410
122603
|
throw new Error("structural_repository_seed_failed", { cause: err });
|
|
122411
122604
|
logger.warn("buildSymbolIndex: repo seed failed, in-batch only", {
|
|
@@ -122429,7 +122622,7 @@ class ResolveStage {
|
|
|
122429
122622
|
}
|
|
122430
122623
|
resolveSpecifier(specifier, fromDir, projectPath, knownRelPaths, aliases) {
|
|
122431
122624
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
122432
|
-
const resolved = this.probeExtensions(
|
|
122625
|
+
const resolved = this.probeExtensions(path25.resolve(fromDir, specifier), projectPath, knownRelPaths);
|
|
122433
122626
|
return { resolvedPath: resolved, external: false };
|
|
122434
122627
|
}
|
|
122435
122628
|
for (const alias of aliases) {
|
|
@@ -122437,8 +122630,8 @@ class ResolveStage {
|
|
|
122437
122630
|
const suffix = specifier.slice(alias.prefix.length);
|
|
122438
122631
|
for (const target of alias.targets) {
|
|
122439
122632
|
const cleanTarget = target.replace(/\/\*$/, "");
|
|
122440
|
-
const basePath = alias.packagePath ?
|
|
122441
|
-
const absPath =
|
|
122633
|
+
const basePath = alias.packagePath ? path25.join(projectPath, alias.packagePath) : projectPath;
|
|
122634
|
+
const absPath = path25.join(basePath, cleanTarget + suffix);
|
|
122442
122635
|
const resolved = this.probeExtensions(absPath, projectPath, knownRelPaths);
|
|
122443
122636
|
if (resolved)
|
|
122444
122637
|
return { resolvedPath: resolved, external: false };
|
|
@@ -122454,7 +122647,7 @@ class ResolveStage {
|
|
|
122454
122647
|
...TS_EXTENSIONS.map((ext2) => absPath.replace(/\.[^.]+$/, ext2))
|
|
122455
122648
|
];
|
|
122456
122649
|
for (const candidate2 of candidates2) {
|
|
122457
|
-
const rel =
|
|
122650
|
+
const rel = path25.relative(projectPath, candidate2).replace(/\\/g, "/");
|
|
122458
122651
|
if (knownRelPaths.has(rel))
|
|
122459
122652
|
return rel;
|
|
122460
122653
|
}
|
|
@@ -122462,9 +122655,9 @@ class ResolveStage {
|
|
|
122462
122655
|
}
|
|
122463
122656
|
loadTsConfigPaths(projectPath, packageBase) {
|
|
122464
122657
|
const aliases = [];
|
|
122465
|
-
const tsconfigPath =
|
|
122658
|
+
const tsconfigPath = path25.join(projectPath, "tsconfig.json");
|
|
122466
122659
|
try {
|
|
122467
|
-
const raw2 =
|
|
122660
|
+
const raw2 = fs17.readFileSync(tsconfigPath, "utf-8");
|
|
122468
122661
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
122469
122662
|
const tsconfig = JSON.parse(stripped);
|
|
122470
122663
|
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
@@ -122493,7 +122686,7 @@ class ResolveStage {
|
|
|
122493
122686
|
}
|
|
122494
122687
|
}
|
|
122495
122688
|
for (const packageRelPath of packagePaths) {
|
|
122496
|
-
const absPackagePath =
|
|
122689
|
+
const absPackagePath = path25.join(projectPath, packageRelPath);
|
|
122497
122690
|
const aliases = this.loadTsConfigPaths(absPackagePath, packageRelPath);
|
|
122498
122691
|
if (aliases.length > 0) {
|
|
122499
122692
|
packages.push({
|
|
@@ -122523,7 +122716,7 @@ class ResolveStage {
|
|
|
122523
122716
|
structuralAliasesFor(filePath, rootAliases, packages) {
|
|
122524
122717
|
return [...this.getPackageAliases(filePath, packages), ...rootAliases].map((alias) => ({
|
|
122525
122718
|
pattern: alias.prefix + (alias.targets.some((target) => target.includes("*")) ? "/*" : ""),
|
|
122526
|
-
targets: alias.targets.map((target) => alias.packagePath ?
|
|
122719
|
+
targets: alias.targets.map((target) => alias.packagePath ? path25.posix.join(alias.packagePath, target) : target)
|
|
122527
122720
|
}));
|
|
122528
122721
|
}
|
|
122529
122722
|
}
|
|
@@ -122587,7 +122780,7 @@ var init_with_deadlock_retry = __esm(() => {
|
|
|
122587
122780
|
});
|
|
122588
122781
|
|
|
122589
122782
|
// ../../packages/core/dist/services/etl/stages/load.js
|
|
122590
|
-
import
|
|
122783
|
+
import path26 from "path";
|
|
122591
122784
|
function formatDuration(ms) {
|
|
122592
122785
|
const totalSec = Math.max(0, Math.round(ms / 1000));
|
|
122593
122786
|
if (totalSec < 60)
|
|
@@ -122864,7 +123057,7 @@ class LoadStage {
|
|
|
122864
123057
|
const filePath = file3.file.relativePath;
|
|
122865
123058
|
const batch = buildSymbolPersistenceBatch(ctx.projectId, file3);
|
|
122866
123059
|
if (ctx.graphGenerationLease) {
|
|
122867
|
-
const manifest = getLanguageManifestEntry(
|
|
123060
|
+
const manifest = getLanguageManifestEntry(path26.extname(filePath));
|
|
122868
123061
|
const diagnostics2 = (file3.structuralDiagnostics ?? []).slice(0, 10).map((diagnostic2) => ({
|
|
122869
123062
|
code: diagnostic2.code,
|
|
122870
123063
|
severity: diagnostic2.severity,
|
|
@@ -123321,9 +123514,9 @@ var init_graph_generation_coordinator = __esm(() => {
|
|
|
123321
123514
|
// ../../packages/core/dist/services/etl/pipeline.js
|
|
123322
123515
|
import { createHash as createHash7 } from "crypto";
|
|
123323
123516
|
import { setTimeout as delay2 } from "timers/promises";
|
|
123324
|
-
import
|
|
123517
|
+
import path27 from "path";
|
|
123325
123518
|
function buildHeaderLanguageEvidence(files) {
|
|
123326
|
-
const headers = new Set(files.filter((file3) =>
|
|
123519
|
+
const headers = new Set(files.filter((file3) => path27.posix.extname(file3.relativePath).toLowerCase() === ".h").map((file3) => path27.posix.normalize(file3.relativePath)));
|
|
123327
123520
|
const mutable = new Map;
|
|
123328
123521
|
const entry2 = (header) => {
|
|
123329
123522
|
let value = mutable.get(header);
|
|
@@ -123334,7 +123527,7 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
123334
123527
|
return value;
|
|
123335
123528
|
};
|
|
123336
123529
|
for (const file3 of files) {
|
|
123337
|
-
if (
|
|
123530
|
+
if (path27.posix.basename(file3.relativePath) !== "compile_commands.json" || file3.snapshotContent === undefined)
|
|
123338
123531
|
continue;
|
|
123339
123532
|
let commands;
|
|
123340
123533
|
try {
|
|
@@ -123350,11 +123543,11 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
123350
123543
|
const record2 = command;
|
|
123351
123544
|
if (typeof record2.file !== "string")
|
|
123352
123545
|
continue;
|
|
123353
|
-
const projectRoot =
|
|
123354
|
-
const commandDirectory = typeof record2.directory === "string" ?
|
|
123355
|
-
const absoluteInput =
|
|
123356
|
-
const relative2 =
|
|
123357
|
-
const header =
|
|
123546
|
+
const projectRoot = path27.resolve(file3.absolutePath, ...file3.relativePath.split("/").map(() => ".."));
|
|
123547
|
+
const commandDirectory = typeof record2.directory === "string" ? path27.resolve(projectRoot, record2.directory) : projectRoot;
|
|
123548
|
+
const absoluteInput = path27.resolve(commandDirectory, record2.file);
|
|
123549
|
+
const relative2 = path27.relative(projectRoot, absoluteInput);
|
|
123550
|
+
const header = path27.posix.normalize(relative2.replaceAll(path27.sep, "/"));
|
|
123358
123551
|
if (!headers.has(header))
|
|
123359
123552
|
continue;
|
|
123360
123553
|
const invocation = typeof record2.command === "string" ? record2.command : Array.isArray(record2.arguments) ? record2.arguments.join(" ") : "";
|
|
@@ -124529,16 +124722,16 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
124529
124722
|
const seen = new Set;
|
|
124530
124723
|
const out = [];
|
|
124531
124724
|
for (const e of httpEdges) {
|
|
124532
|
-
const
|
|
124533
|
-
if (!
|
|
124725
|
+
const path29 = e.route;
|
|
124726
|
+
if (!path29)
|
|
124534
124727
|
continue;
|
|
124535
124728
|
const method = (e.method ?? "ANY").toUpperCase();
|
|
124536
|
-
const key = method + " " +
|
|
124729
|
+
const key = method + " " + path29;
|
|
124537
124730
|
if (seen.has(key))
|
|
124538
124731
|
continue;
|
|
124539
124732
|
seen.add(key);
|
|
124540
124733
|
out.push({
|
|
124541
|
-
path:
|
|
124734
|
+
path: path29,
|
|
124542
124735
|
method: e.method,
|
|
124543
124736
|
file: e.fromFile,
|
|
124544
124737
|
handler: e.targetFqn ?? e.symbolName
|
|
@@ -124549,12 +124742,12 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
124549
124742
|
continue;
|
|
124550
124743
|
const parsed = parseRouteName(d.name);
|
|
124551
124744
|
const method = parsed?.method ?? "ANY";
|
|
124552
|
-
const
|
|
124553
|
-
const key = method + " " +
|
|
124745
|
+
const path29 = parsed?.path ?? d.name;
|
|
124746
|
+
const key = method + " " + path29;
|
|
124554
124747
|
if (seen.has(key))
|
|
124555
124748
|
continue;
|
|
124556
124749
|
seen.add(key);
|
|
124557
|
-
out.push({ path:
|
|
124750
|
+
out.push({ path: path29, method: parsed?.method, file: d.filePath, handler: d.name });
|
|
124558
124751
|
}
|
|
124559
124752
|
for (const d of defs) {
|
|
124560
124753
|
const parsed = parseRouteName(d.name);
|
|
@@ -124775,8 +124968,8 @@ __export(exports_symbol_graph_service, {
|
|
|
124775
124968
|
symbolGraphService: () => symbolGraphService,
|
|
124776
124969
|
SymbolGraphService: () => SymbolGraphService
|
|
124777
124970
|
});
|
|
124778
|
-
import
|
|
124779
|
-
import
|
|
124971
|
+
import path29 from "path";
|
|
124972
|
+
import fs18 from "fs/promises";
|
|
124780
124973
|
|
|
124781
124974
|
class SymbolGraphService {
|
|
124782
124975
|
identityLookup;
|
|
@@ -125104,7 +125297,7 @@ class SymbolGraphService {
|
|
|
125104
125297
|
async readSnippet(relativePath, lineStart, lineEnd, projectId) {
|
|
125105
125298
|
try {
|
|
125106
125299
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
125107
|
-
const content = await
|
|
125300
|
+
const content = await fs18.readFile(absolutePath, "utf-8");
|
|
125108
125301
|
const lines = content.split(`
|
|
125109
125302
|
`);
|
|
125110
125303
|
return lines.slice(Math.max(0, lineStart - 1), Math.min(lines.length, lineEnd)).join(`
|
|
@@ -125116,7 +125309,7 @@ class SymbolGraphService {
|
|
|
125116
125309
|
async readContext(relativePath, lineNumber, contextLines, projectId) {
|
|
125117
125310
|
try {
|
|
125118
125311
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
125119
|
-
const content = await
|
|
125312
|
+
const content = await fs18.readFile(absolutePath, "utf-8");
|
|
125120
125313
|
const lines = content.split(`
|
|
125121
125314
|
`);
|
|
125122
125315
|
const start = Math.max(0, lineNumber - contextLines - 1);
|
|
@@ -125129,7 +125322,7 @@ class SymbolGraphService {
|
|
|
125129
125322
|
}
|
|
125130
125323
|
async resolveToAbsolute(relativePath, projectId) {
|
|
125131
125324
|
const root = await this.getProjectRoot(projectId);
|
|
125132
|
-
return root ?
|
|
125325
|
+
return root ? path29.resolve(root, relativePath) : relativePath;
|
|
125133
125326
|
}
|
|
125134
125327
|
async getProjectRoot(projectId) {
|
|
125135
125328
|
const cached2 = this.projectRootCache.get(projectId);
|
|
@@ -129134,31 +129327,31 @@ class TracePathService {
|
|
|
129134
129327
|
const chains = [];
|
|
129135
129328
|
const seen = new Set;
|
|
129136
129329
|
let walks = 0;
|
|
129137
|
-
const walk = (fqn,
|
|
129330
|
+
const walk = (fqn, path32) => {
|
|
129138
129331
|
if (chains.length >= CHAIN_CAP)
|
|
129139
129332
|
return;
|
|
129140
129333
|
if (walks >= MAX_WALKS)
|
|
129141
129334
|
return;
|
|
129142
129335
|
walks++;
|
|
129143
|
-
const key =
|
|
129336
|
+
const key = path32.join("\u2192");
|
|
129144
129337
|
if (seen.has(key))
|
|
129145
129338
|
return;
|
|
129146
129339
|
seen.add(key);
|
|
129147
129340
|
const next = adj.get(fqn);
|
|
129148
129341
|
if (!next || next.length === 0 || !whoHasChild.has(fqn)) {
|
|
129149
|
-
if (
|
|
129150
|
-
chains.push(
|
|
129342
|
+
if (path32.length > 1)
|
|
129343
|
+
chains.push(path32.map((n2) => this.fqnToName(n2)).join(" \u2192 "));
|
|
129151
129344
|
return;
|
|
129152
129345
|
}
|
|
129153
129346
|
for (const child of next) {
|
|
129154
129347
|
if (chains.length >= CHAIN_CAP || walks >= MAX_WALKS)
|
|
129155
129348
|
return;
|
|
129156
|
-
if (
|
|
129157
|
-
const cycled = [...
|
|
129349
|
+
if (path32.includes(child)) {
|
|
129350
|
+
const cycled = [...path32, `${this.fqnToName(child)}\u21BA`];
|
|
129158
129351
|
chains.push(cycled.map((n2) => n2).join(" \u2192 "));
|
|
129159
129352
|
continue;
|
|
129160
129353
|
}
|
|
129161
|
-
walk(child, [...
|
|
129354
|
+
walk(child, [...path32, child]);
|
|
129162
129355
|
}
|
|
129163
129356
|
};
|
|
129164
129357
|
for (const seed of seeds) {
|
|
@@ -132329,9 +132522,9 @@ var init_inference_probe = __esm(() => {
|
|
|
132329
132522
|
});
|
|
132330
132523
|
|
|
132331
132524
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
132332
|
-
import
|
|
132525
|
+
import fs21 from "fs/promises";
|
|
132333
132526
|
import { existsSync as existsSync3 } from "fs";
|
|
132334
|
-
import
|
|
132527
|
+
import path34 from "path";
|
|
132335
132528
|
|
|
132336
132529
|
class LocalHealthChecker {
|
|
132337
132530
|
dataDir = config.get("dataDir");
|
|
@@ -132409,10 +132602,10 @@ class LocalHealthChecker {
|
|
|
132409
132602
|
const start = Date.now();
|
|
132410
132603
|
try {
|
|
132411
132604
|
if (!existsSync3(this.dataDir))
|
|
132412
|
-
await
|
|
132413
|
-
const probe2 =
|
|
132414
|
-
await
|
|
132415
|
-
await
|
|
132605
|
+
await fs21.mkdir(this.dataDir, { recursive: true });
|
|
132606
|
+
const probe2 = path34.join(this.dataDir, ".health-check-test");
|
|
132607
|
+
await fs21.writeFile(probe2, "ok");
|
|
132608
|
+
await fs21.unlink(probe2);
|
|
132416
132609
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
132417
132610
|
} catch (error51) {
|
|
132418
132611
|
return { available: false, latency: Date.now() - start, error: `Data directory error: ${error51.message}` };
|
|
@@ -134482,9 +134675,9 @@ var init_scheduler2 = __esm(() => {
|
|
|
134482
134675
|
});
|
|
134483
134676
|
|
|
134484
134677
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
134485
|
-
import
|
|
134678
|
+
import fs22 from "fs/promises";
|
|
134486
134679
|
import { existsSync as existsSync4 } from "fs";
|
|
134487
|
-
import
|
|
134680
|
+
import path35 from "path";
|
|
134488
134681
|
function getModelsDevClient() {
|
|
134489
134682
|
if (!clientInstance) {
|
|
134490
134683
|
clientInstance = new ModelsDevClient;
|
|
@@ -134504,7 +134697,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
134504
134697
|
memoryCacheTimestamp = 0;
|
|
134505
134698
|
getLocalCachePath() {
|
|
134506
134699
|
const dataDir = config.get("dataDir");
|
|
134507
|
-
return
|
|
134700
|
+
return path35.join(dataDir, ModelsDevClient.LOCAL_CACHE_FILE);
|
|
134508
134701
|
}
|
|
134509
134702
|
async loadLocalCache() {
|
|
134510
134703
|
const cachePath = this.getLocalCachePath();
|
|
@@ -134512,7 +134705,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
134512
134705
|
if (!existsSync4(cachePath)) {
|
|
134513
134706
|
return null;
|
|
134514
134707
|
}
|
|
134515
|
-
const content = await
|
|
134708
|
+
const content = await fs22.readFile(cachePath, "utf-8");
|
|
134516
134709
|
const data = JSON.parse(content);
|
|
134517
134710
|
const age = Date.now() - data.timestamp;
|
|
134518
134711
|
if (age > ModelsDevClient.LOCAL_CACHE_TTL) {
|
|
@@ -134539,14 +134732,14 @@ var init_models_dev_client = __esm(() => {
|
|
|
134539
134732
|
async saveLocalCache(models) {
|
|
134540
134733
|
const cachePath = this.getLocalCachePath();
|
|
134541
134734
|
try {
|
|
134542
|
-
const dir =
|
|
134543
|
-
await
|
|
134735
|
+
const dir = path35.dirname(cachePath);
|
|
134736
|
+
await fs22.mkdir(dir, { recursive: true });
|
|
134544
134737
|
const data = {
|
|
134545
134738
|
timestamp: Date.now(),
|
|
134546
134739
|
version: "1.0.0",
|
|
134547
134740
|
models: Object.fromEntries(models)
|
|
134548
134741
|
};
|
|
134549
|
-
await
|
|
134742
|
+
await fs22.writeFile(cachePath, JSON.stringify(data), "utf-8");
|
|
134550
134743
|
logger.debug("Saved pricing to local cache", {
|
|
134551
134744
|
models: models.size,
|
|
134552
134745
|
path: cachePath
|
|
@@ -134875,7 +135068,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
134875
135068
|
const cachePath = this.getLocalCachePath();
|
|
134876
135069
|
try {
|
|
134877
135070
|
if (existsSync4(cachePath)) {
|
|
134878
|
-
await
|
|
135071
|
+
await fs22.unlink(cachePath);
|
|
134879
135072
|
logger.debug("Local pricing cache file deleted");
|
|
134880
135073
|
}
|
|
134881
135074
|
} catch (error51) {
|
|
@@ -140430,33 +140623,33 @@ var require_URL = __commonJS((exports, module) => {
|
|
|
140430
140623
|
else
|
|
140431
140624
|
return basepath.substring(0, lastslash + 1) + refpath;
|
|
140432
140625
|
}
|
|
140433
|
-
function remove_dot_segments(
|
|
140434
|
-
if (!
|
|
140435
|
-
return
|
|
140626
|
+
function remove_dot_segments(path36) {
|
|
140627
|
+
if (!path36)
|
|
140628
|
+
return path36;
|
|
140436
140629
|
var output = "";
|
|
140437
|
-
while (
|
|
140438
|
-
if (
|
|
140439
|
-
|
|
140630
|
+
while (path36.length > 0) {
|
|
140631
|
+
if (path36 === "." || path36 === "..") {
|
|
140632
|
+
path36 = "";
|
|
140440
140633
|
break;
|
|
140441
140634
|
}
|
|
140442
|
-
var twochars =
|
|
140443
|
-
var threechars =
|
|
140444
|
-
var fourchars =
|
|
140635
|
+
var twochars = path36.substring(0, 2);
|
|
140636
|
+
var threechars = path36.substring(0, 3);
|
|
140637
|
+
var fourchars = path36.substring(0, 4);
|
|
140445
140638
|
if (threechars === "../") {
|
|
140446
|
-
|
|
140639
|
+
path36 = path36.substring(3);
|
|
140447
140640
|
} else if (twochars === "./") {
|
|
140448
|
-
|
|
140641
|
+
path36 = path36.substring(2);
|
|
140449
140642
|
} else if (threechars === "/./") {
|
|
140450
|
-
|
|
140451
|
-
} else if (twochars === "/." &&
|
|
140452
|
-
|
|
140453
|
-
} else if (fourchars === "/../" || threechars === "/.." &&
|
|
140454
|
-
|
|
140643
|
+
path36 = "/" + path36.substring(3);
|
|
140644
|
+
} else if (twochars === "/." && path36.length === 2) {
|
|
140645
|
+
path36 = "/";
|
|
140646
|
+
} else if (fourchars === "/../" || threechars === "/.." && path36.length === 3) {
|
|
140647
|
+
path36 = "/" + path36.substring(4);
|
|
140455
140648
|
output = output.replace(/\/?[^\/]*$/, "");
|
|
140456
140649
|
} else {
|
|
140457
|
-
var segment =
|
|
140650
|
+
var segment = path36.match(/(\/?([^\/]*))/)[0];
|
|
140458
140651
|
output += segment;
|
|
140459
|
-
|
|
140652
|
+
path36 = path36.substring(segment.length);
|
|
140460
140653
|
}
|
|
140461
140654
|
}
|
|
140462
140655
|
return output;
|
|
@@ -152526,21 +152719,21 @@ function jsonToKeyPathChunks(value, label = "$") {
|
|
|
152526
152719
|
walk(value, label, out);
|
|
152527
152720
|
return out;
|
|
152528
152721
|
}
|
|
152529
|
-
function walk(val,
|
|
152722
|
+
function walk(val, path36, out) {
|
|
152530
152723
|
if (val === null || val === undefined)
|
|
152531
152724
|
return;
|
|
152532
152725
|
if (Array.isArray(val)) {
|
|
152533
152726
|
if (val.length === 0) {
|
|
152534
|
-
out.push({ path:
|
|
152727
|
+
out.push({ path: path36, content: `**${path36}** = _[]_` });
|
|
152535
152728
|
return;
|
|
152536
152729
|
}
|
|
152537
152730
|
if (val.every((v) => v !== null && typeof v === "object")) {
|
|
152538
|
-
val.forEach((v, i) => walk(v, `${
|
|
152731
|
+
val.forEach((v, i) => walk(v, `${path36}[${i}]`, out));
|
|
152539
152732
|
return;
|
|
152540
152733
|
}
|
|
152541
152734
|
const items = val.map((v) => `- \`${String(v)}\``).join(`
|
|
152542
152735
|
`);
|
|
152543
|
-
out.push({ path:
|
|
152736
|
+
out.push({ path: path36, content: `**${path36}**
|
|
152544
152737
|
|
|
152545
152738
|
${items}` });
|
|
152546
152739
|
return;
|
|
@@ -152548,16 +152741,16 @@ ${items}` });
|
|
|
152548
152741
|
if (typeof val === "object") {
|
|
152549
152742
|
const entries = Object.entries(val);
|
|
152550
152743
|
if (entries.length === 0) {
|
|
152551
|
-
out.push({ path:
|
|
152744
|
+
out.push({ path: path36, content: `**${path36}** = _{}_` });
|
|
152552
152745
|
return;
|
|
152553
152746
|
}
|
|
152554
152747
|
for (const [k2, v] of entries) {
|
|
152555
152748
|
const safeKey = /^[A-Za-z_$][\w$]*$/.test(k2) ? k2 : JSON.stringify(k2);
|
|
152556
|
-
walk(v, `${
|
|
152749
|
+
walk(v, `${path36}.${safeKey}`, out);
|
|
152557
152750
|
}
|
|
152558
152751
|
return;
|
|
152559
152752
|
}
|
|
152560
|
-
out.push({ path:
|
|
152753
|
+
out.push({ path: path36, content: `**${path36}** = \`${String(val)}\`` });
|
|
152561
152754
|
}
|
|
152562
152755
|
var gfm, STRIP_SELECTORS, tdCache = null;
|
|
152563
152756
|
var init_html_to_md = __esm(() => {
|
|
@@ -175548,9 +175741,9 @@ async function acquireIndexingLease(request) {
|
|
|
175548
175741
|
|
|
175549
175742
|
// ../../packages/core/dist/services/project-identity/project-root-identity.js
|
|
175550
175743
|
import { realpath as realpath2 } from "fs/promises";
|
|
175551
|
-
import
|
|
175744
|
+
import path28 from "path";
|
|
175552
175745
|
async function canonicalizeProjectRoot(projectPath, canonicalize = realpath2) {
|
|
175553
|
-
return canonicalize(
|
|
175746
|
+
return canonicalize(path28.resolve(projectPath));
|
|
175554
175747
|
}
|
|
175555
175748
|
async function assertProjectRootReuse(options) {
|
|
175556
175749
|
if (!options.storedProjectPath || options.forceReindex)
|
|
@@ -175558,9 +175751,9 @@ async function assertProjectRootReuse(options) {
|
|
|
175558
175751
|
const canonicalize = options.canonicalize ?? realpath2;
|
|
175559
175752
|
let storedCanonical;
|
|
175560
175753
|
try {
|
|
175561
|
-
storedCanonical = await canonicalize(
|
|
175754
|
+
storedCanonical = await canonicalize(path28.resolve(options.storedProjectPath));
|
|
175562
175755
|
} catch {
|
|
175563
|
-
storedCanonical =
|
|
175756
|
+
storedCanonical = path28.resolve(options.storedProjectPath);
|
|
175564
175757
|
}
|
|
175565
175758
|
if (storedCanonical !== options.canonicalProjectPath) {
|
|
175566
175759
|
throw new Error(`Project ID "${options.projectId}" already indexes canonical root ` + `"${storedCanonical}", not "${options.canonicalProjectPath}"; ` + "use forceReindex only after verifying ownership of the existing project");
|
|
@@ -175570,7 +175763,7 @@ async function assertProjectRootReuse(options) {
|
|
|
175570
175763
|
// ../../packages/core/dist/tools/index_project.js
|
|
175571
175764
|
init_workspace_manager();
|
|
175572
175765
|
init_parser_readiness();
|
|
175573
|
-
import
|
|
175766
|
+
import path30 from "path";
|
|
175574
175767
|
|
|
175575
175768
|
class IndexProjectTool {
|
|
175576
175769
|
name = "index_project";
|
|
@@ -175618,7 +175811,7 @@ class IndexProjectTool {
|
|
|
175618
175811
|
try {
|
|
175619
175812
|
await assertParserReadyForIndexing();
|
|
175620
175813
|
const canonicalProjectPath = await canonicalizeProjectRoot(projectPath);
|
|
175621
|
-
const finalProjectId = projectId ||
|
|
175814
|
+
const finalProjectId = projectId || path30.basename(canonicalProjectPath) || "default";
|
|
175622
175815
|
const existing = await workspaceManager.getWorkspace(finalProjectId);
|
|
175623
175816
|
await assertProjectRootReuse({
|
|
175624
175817
|
projectId: finalProjectId,
|
|
@@ -176172,17 +176365,17 @@ function applyReplacer(root, replacer) {
|
|
|
176172
176365
|
return transformChildren(root, replacer, []);
|
|
176173
176366
|
return transformChildren(normalizeValue(replacedRoot), replacer, []);
|
|
176174
176367
|
}
|
|
176175
|
-
function transformChildren(value, replacer,
|
|
176368
|
+
function transformChildren(value, replacer, path31) {
|
|
176176
176369
|
if (isJsonObject(value))
|
|
176177
|
-
return transformObject(value, replacer,
|
|
176370
|
+
return transformObject(value, replacer, path31);
|
|
176178
176371
|
if (isJsonArray(value))
|
|
176179
|
-
return transformArray(value, replacer,
|
|
176372
|
+
return transformArray(value, replacer, path31);
|
|
176180
176373
|
return value;
|
|
176181
176374
|
}
|
|
176182
|
-
function transformObject(obj, replacer,
|
|
176375
|
+
function transformObject(obj, replacer, path31) {
|
|
176183
176376
|
const result = {};
|
|
176184
176377
|
for (const [key, value] of Object.entries(obj)) {
|
|
176185
|
-
const childPath = [...
|
|
176378
|
+
const childPath = [...path31, key];
|
|
176186
176379
|
const replacedValue = replacer(key, value, childPath);
|
|
176187
176380
|
if (replacedValue === undefined)
|
|
176188
176381
|
continue;
|
|
@@ -176190,11 +176383,11 @@ function transformObject(obj, replacer, path30) {
|
|
|
176190
176383
|
}
|
|
176191
176384
|
return result;
|
|
176192
176385
|
}
|
|
176193
|
-
function transformArray(arr, replacer,
|
|
176386
|
+
function transformArray(arr, replacer, path31) {
|
|
176194
176387
|
const result = [];
|
|
176195
176388
|
for (let i = 0;i < arr.length; i++) {
|
|
176196
176389
|
const value = arr[i];
|
|
176197
|
-
const childPath = [...
|
|
176390
|
+
const childPath = [...path31, i];
|
|
176198
176391
|
const replacedValue = replacer(String(i), value, childPath);
|
|
176199
176392
|
if (replacedValue === undefined)
|
|
176200
176393
|
continue;
|
|
@@ -177575,9 +177768,9 @@ init_dist();
|
|
|
177575
177768
|
init_db_connection();
|
|
177576
177769
|
init_alias_resolver();
|
|
177577
177770
|
init_safe_error_summary();
|
|
177578
|
-
import
|
|
177579
|
-
import
|
|
177580
|
-
import
|
|
177771
|
+
import fs19 from "fs";
|
|
177772
|
+
import os9 from "os";
|
|
177773
|
+
import path31 from "path";
|
|
177581
177774
|
|
|
177582
177775
|
// ../../packages/core/dist/services/hooks/session-pin-store.js
|
|
177583
177776
|
var DEFAULT_MAX_SIZE = 1000;
|
|
@@ -177676,8 +177869,8 @@ class AttributionResolver {
|
|
|
177676
177869
|
this.aliasResolver = options.aliasResolver ?? getProjectIdentityAliasResolver();
|
|
177677
177870
|
this.pins = options.pins ?? new SessionPinStore;
|
|
177678
177871
|
this.canonicalize = options.canonicalize ?? defaultCanonicalize;
|
|
177679
|
-
this.homedir = options.homedir ??
|
|
177680
|
-
this.fsRoot = options.fsRoot ?? (() =>
|
|
177872
|
+
this.homedir = options.homedir ?? os9.homedir;
|
|
177873
|
+
this.fsRoot = options.fsRoot ?? (() => path31.parse(path31.sep).root);
|
|
177681
177874
|
}
|
|
177682
177875
|
async resolve(input) {
|
|
177683
177876
|
const caller = input.callerProjectId;
|
|
@@ -177728,7 +177921,7 @@ class AttributionResolver {
|
|
|
177728
177921
|
}
|
|
177729
177922
|
let bestPath = null;
|
|
177730
177923
|
for (const candidate2 of byPath.keys()) {
|
|
177731
|
-
if (canonicalCwd === candidate2 || canonicalCwd.startsWith(candidate2.endsWith(
|
|
177924
|
+
if (canonicalCwd === candidate2 || canonicalCwd.startsWith(candidate2.endsWith(path31.sep) ? candidate2 : candidate2 + path31.sep)) {
|
|
177732
177925
|
if (bestPath === null || candidate2.length > bestPath.length) {
|
|
177733
177926
|
bestPath = candidate2;
|
|
177734
177927
|
}
|
|
@@ -177751,7 +177944,7 @@ class AttributionResolver {
|
|
|
177751
177944
|
return projectPath2;
|
|
177752
177945
|
const fsRoot = this.fsRoot();
|
|
177753
177946
|
let normalized = projectPath2;
|
|
177754
|
-
while (normalized.length > fsRoot.length && normalized.endsWith(
|
|
177947
|
+
while (normalized.length > fsRoot.length && normalized.endsWith(path31.sep)) {
|
|
177755
177948
|
normalized = normalized.slice(0, -1);
|
|
177756
177949
|
}
|
|
177757
177950
|
return normalized;
|
|
@@ -177759,10 +177952,10 @@ class AttributionResolver {
|
|
|
177759
177952
|
}
|
|
177760
177953
|
function defaultCanonicalize(cwd) {
|
|
177761
177954
|
try {
|
|
177762
|
-
return
|
|
177955
|
+
return fs19.realpathSync(cwd);
|
|
177763
177956
|
} catch {
|
|
177764
177957
|
try {
|
|
177765
|
-
return
|
|
177958
|
+
return path31.resolve(cwd);
|
|
177766
177959
|
} catch {
|
|
177767
177960
|
return;
|
|
177768
177961
|
}
|
|
@@ -178299,7 +178492,7 @@ init_code_compressor();
|
|
|
178299
178492
|
|
|
178300
178493
|
// ../../packages/core/dist/services/file-read/file-content-cache.js
|
|
178301
178494
|
init_dist();
|
|
178302
|
-
import
|
|
178495
|
+
import fs20 from "fs/promises";
|
|
178303
178496
|
|
|
178304
178497
|
class FileContentCache {
|
|
178305
178498
|
extractMetadata;
|
|
@@ -178332,7 +178525,7 @@ class FileContentCache {
|
|
|
178332
178525
|
metadata: cached2.metadata
|
|
178333
178526
|
};
|
|
178334
178527
|
}
|
|
178335
|
-
const content = await
|
|
178528
|
+
const content = await fs20.readFile(filePath, "utf-8");
|
|
178336
178529
|
const metadata = await this.extractMetadata(content, filePath, options);
|
|
178337
178530
|
evictOldest(this.fileCache, this.FILE_CACHE_MAX_ENTRIES - 1);
|
|
178338
178531
|
this.fileCache.set(cacheKey, {
|
|
@@ -178347,7 +178540,7 @@ class FileContentCache {
|
|
|
178347
178540
|
|
|
178348
178541
|
// ../../packages/core/dist/services/file-read/file-metadata.js
|
|
178349
178542
|
init_dist();
|
|
178350
|
-
import
|
|
178543
|
+
import path32 from "path";
|
|
178351
178544
|
|
|
178352
178545
|
class FileMetadataExtractor {
|
|
178353
178546
|
symbolGraph;
|
|
@@ -178383,7 +178576,7 @@ class FileMetadataExtractor {
|
|
|
178383
178576
|
return metadata;
|
|
178384
178577
|
}
|
|
178385
178578
|
detectLanguage(filePath) {
|
|
178386
|
-
const ext2 =
|
|
178579
|
+
const ext2 = path32.extname(filePath).toLowerCase();
|
|
178387
178580
|
const languageMap2 = {
|
|
178388
178581
|
".ts": "TypeScript",
|
|
178389
178582
|
".tsx": "TypeScript",
|
|
@@ -178500,7 +178693,7 @@ function selectLines(lines, range) {
|
|
|
178500
178693
|
|
|
178501
178694
|
// ../../packages/core/dist/services/file-read/path-containment.js
|
|
178502
178695
|
init_dist();
|
|
178503
|
-
import
|
|
178696
|
+
import path33 from "path";
|
|
178504
178697
|
|
|
178505
178698
|
class PathContainment {
|
|
178506
178699
|
projectRoots;
|
|
@@ -178508,14 +178701,14 @@ class PathContainment {
|
|
|
178508
178701
|
this.projectRoots = projectRoots;
|
|
178509
178702
|
}
|
|
178510
178703
|
async resolveFilePath(filePath, projectId) {
|
|
178511
|
-
if (
|
|
178512
|
-
return
|
|
178704
|
+
if (path33.isAbsolute(filePath)) {
|
|
178705
|
+
return path33.resolve(filePath);
|
|
178513
178706
|
}
|
|
178514
178707
|
if (projectId) {
|
|
178515
178708
|
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
178516
178709
|
if (root) {
|
|
178517
178710
|
const cleaned = sanitizeFilePath(filePath);
|
|
178518
|
-
return
|
|
178711
|
+
return path33.resolve(root, cleaned);
|
|
178519
178712
|
}
|
|
178520
178713
|
return null;
|
|
178521
178714
|
}
|
|
@@ -178526,17 +178719,17 @@ class PathContainment {
|
|
|
178526
178719
|
if (projectId) {
|
|
178527
178720
|
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
178528
178721
|
if (root)
|
|
178529
|
-
roots.push(
|
|
178722
|
+
roots.push(path33.resolve(root));
|
|
178530
178723
|
}
|
|
178531
|
-
roots.push(
|
|
178724
|
+
roots.push(path33.resolve(process.cwd()));
|
|
178532
178725
|
const envRoots = (process.env.MASSA_AI_READ_FILE_ROOTS ?? "").split(":").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
178533
178726
|
for (const extra of envRoots) {
|
|
178534
|
-
roots.push(
|
|
178727
|
+
roots.push(path33.resolve(extra));
|
|
178535
178728
|
}
|
|
178536
|
-
const target =
|
|
178729
|
+
const target = path33.resolve(absoluteFilePath);
|
|
178537
178730
|
for (const root of roots) {
|
|
178538
|
-
const rel =
|
|
178539
|
-
if (rel !== "" && !rel.startsWith("..") && !
|
|
178731
|
+
const rel = path33.relative(root, target);
|
|
178732
|
+
if (rel !== "" && !rel.startsWith("..") && !path33.isAbsolute(rel)) {
|
|
178540
178733
|
return { allowed: true };
|
|
178541
178734
|
}
|
|
178542
178735
|
if (rel === "")
|
|
@@ -179373,8 +179566,8 @@ init_event_bus();
|
|
|
179373
179566
|
init_llm_client();
|
|
179374
179567
|
init_symbol_graph_service();
|
|
179375
179568
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
179376
|
-
import
|
|
179377
|
-
import
|
|
179569
|
+
import fs23 from "fs";
|
|
179570
|
+
import path36 from "path";
|
|
179378
179571
|
import { spawn as spawn2 } from "child_process";
|
|
179379
179572
|
var FALLBACK_BOOTSTRAP = {
|
|
179380
179573
|
enabled: true,
|
|
@@ -179558,9 +179751,9 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
179558
179751
|
}
|
|
179559
179752
|
try {
|
|
179560
179753
|
for (const name26 of README_CANDIDATES) {
|
|
179561
|
-
const p =
|
|
179562
|
-
if (
|
|
179563
|
-
const buf =
|
|
179754
|
+
const p = path36.join(projectRoot, name26);
|
|
179755
|
+
if (fs23.existsSync(p) && fs23.statSync(p).isFile()) {
|
|
179756
|
+
const buf = fs23.readFileSync(p);
|
|
179564
179757
|
signals.readme = buf.slice(0, MAX_README_BYTES).toString("utf8");
|
|
179565
179758
|
break;
|
|
179566
179759
|
}
|
|
@@ -179569,14 +179762,14 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
179569
179762
|
logger.debug("bootstrap scan: README read failed", { error: e.message });
|
|
179570
179763
|
}
|
|
179571
179764
|
try {
|
|
179572
|
-
const docsDir =
|
|
179573
|
-
if (
|
|
179765
|
+
const docsDir = path36.join(projectRoot, "docs");
|
|
179766
|
+
if (fs23.existsSync(docsDir) && fs23.statSync(docsDir).isDirectory()) {
|
|
179574
179767
|
const entries = walkMarkdown(docsDir).slice(0, MAX_DOCS);
|
|
179575
179768
|
for (const rel of entries) {
|
|
179576
179769
|
try {
|
|
179577
|
-
const buf =
|
|
179770
|
+
const buf = fs23.readFileSync(rel);
|
|
179578
179771
|
signals.docs.push({
|
|
179579
|
-
path:
|
|
179772
|
+
path: path36.relative(projectRoot, rel),
|
|
179580
179773
|
snippet: buf.slice(0, MAX_DOC_BYTES).toString("utf8")
|
|
179581
179774
|
});
|
|
179582
179775
|
} catch {}
|
|
@@ -179587,10 +179780,10 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
179587
179780
|
}
|
|
179588
179781
|
try {
|
|
179589
179782
|
for (const name26 of MANIFEST_FILES) {
|
|
179590
|
-
const p =
|
|
179591
|
-
if (!
|
|
179783
|
+
const p = path36.join(projectRoot, name26);
|
|
179784
|
+
if (!fs23.existsSync(p) || !fs23.statSync(p).isFile())
|
|
179592
179785
|
continue;
|
|
179593
|
-
const raw2 =
|
|
179786
|
+
const raw2 = fs23.readFileSync(p).slice(0, MAX_MANIFEST_BYTES).toString("utf8");
|
|
179594
179787
|
const kind = name26;
|
|
179595
179788
|
if (name26 === "package.json") {
|
|
179596
179789
|
try {
|
|
@@ -179630,12 +179823,12 @@ function walkMarkdown(dir) {
|
|
|
179630
179823
|
const cur = stack.pop();
|
|
179631
179824
|
let entries;
|
|
179632
179825
|
try {
|
|
179633
|
-
entries =
|
|
179826
|
+
entries = fs23.readdirSync(cur, { withFileTypes: true });
|
|
179634
179827
|
} catch {
|
|
179635
179828
|
continue;
|
|
179636
179829
|
}
|
|
179637
179830
|
for (const e of entries) {
|
|
179638
|
-
const full =
|
|
179831
|
+
const full = path36.join(cur, e.name);
|
|
179639
179832
|
if (e.isDirectory()) {
|
|
179640
179833
|
if (e.name === "node_modules" || e.name.startsWith("."))
|
|
179641
179834
|
continue;
|
|
@@ -180796,8 +180989,8 @@ var checkpointRoutes = new Elysia({ prefix: "/api/v1/checkpoints" }).post("/list
|
|
|
180796
180989
|
|
|
180797
180990
|
// src/routes/project.ts
|
|
180798
180991
|
init_dist();
|
|
180799
|
-
import
|
|
180800
|
-
import
|
|
180992
|
+
import fs24 from "fs/promises";
|
|
180993
|
+
import path37 from "path";
|
|
180801
180994
|
function isDimensionMismatchError(error51) {
|
|
180802
180995
|
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
180803
180996
|
return /dimension mismatch/i.test(message);
|
|
@@ -181017,22 +181210,22 @@ var projectRoutes = new Elysia({ prefix: "/api/v1/project" }).get("/list", async
|
|
|
181017
181210
|
}).post("/upload-and-index", async ({ body }) => {
|
|
181018
181211
|
const rawBase = body.projectId || body.projectPath.replace(/\\/g, "/").split("/").filter(Boolean).pop() || "default";
|
|
181019
181212
|
const finalProjectId = rawBase.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 128);
|
|
181020
|
-
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR ||
|
|
181021
|
-
const stagingDir =
|
|
181022
|
-
await
|
|
181023
|
-
await
|
|
181213
|
+
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR || path37.join(getGlobalDataDir(), "uploads");
|
|
181214
|
+
const stagingDir = path37.resolve(uploadRoot, finalProjectId);
|
|
181215
|
+
await fs24.rm(stagingDir, { recursive: true, force: true });
|
|
181216
|
+
await fs24.mkdir(stagingDir, { recursive: true });
|
|
181024
181217
|
const WRITE_BATCH = 20;
|
|
181025
181218
|
for (let i = 0;i < body.files.length; i += WRITE_BATCH) {
|
|
181026
181219
|
await Promise.all(body.files.slice(i, i + WRITE_BATCH).map(async (file3) => {
|
|
181027
|
-
if (
|
|
181220
|
+
if (path37.isAbsolute(file3.relativePath) || file3.relativePath.includes("..")) {
|
|
181028
181221
|
throw new Error(`Invalid file path: ${file3.relativePath}`);
|
|
181029
181222
|
}
|
|
181030
|
-
const dest =
|
|
181031
|
-
if (!dest.startsWith(stagingDir +
|
|
181223
|
+
const dest = path37.resolve(stagingDir, file3.relativePath.replace(/\//g, path37.sep));
|
|
181224
|
+
if (!dest.startsWith(stagingDir + path37.sep)) {
|
|
181032
181225
|
throw new Error(`Path escapes staging directory: ${file3.relativePath}`);
|
|
181033
181226
|
}
|
|
181034
|
-
await
|
|
181035
|
-
await
|
|
181227
|
+
await fs24.mkdir(path37.dirname(dest), { recursive: true });
|
|
181228
|
+
await fs24.writeFile(dest, file3.content, "utf-8");
|
|
181036
181229
|
}));
|
|
181037
181230
|
}
|
|
181038
181231
|
return await getIndexProjectTool().handle({
|
|
@@ -181188,9 +181381,9 @@ var analyticsRoutes = new Elysia({ prefix: "/api/v1/analytics" }).post("/", asyn
|
|
|
181188
181381
|
init_dist();
|
|
181189
181382
|
init_config();
|
|
181190
181383
|
init_inference_providers();
|
|
181191
|
-
import
|
|
181192
|
-
import
|
|
181193
|
-
import
|
|
181384
|
+
import path38 from "path";
|
|
181385
|
+
import fs25 from "fs";
|
|
181386
|
+
import os10 from "os";
|
|
181194
181387
|
function resolveConfiguredOllamaEmbeddingModel() {
|
|
181195
181388
|
return process.env.OLLAMA_EMBEDDING_MODEL || loadRawUserConfig().embedding?.model || INFERENCE_PROVIDERS.ollama.defaultModels.embedding;
|
|
181196
181389
|
}
|
|
@@ -181224,13 +181417,13 @@ var systemRoutes = new Elysia({ prefix: "/api/v1/system" }).get("/info", async (
|
|
|
181224
181417
|
version: "1.0.0",
|
|
181225
181418
|
service: "massa-ai-tools-api",
|
|
181226
181419
|
node: process.version,
|
|
181227
|
-
platform:
|
|
181228
|
-
arch:
|
|
181420
|
+
platform: os10.platform(),
|
|
181421
|
+
arch: os10.arch(),
|
|
181229
181422
|
uptime: process.uptime(),
|
|
181230
181423
|
memory: {
|
|
181231
|
-
total:
|
|
181232
|
-
free:
|
|
181233
|
-
used:
|
|
181424
|
+
total: os10.totalmem(),
|
|
181425
|
+
free: os10.freemem(),
|
|
181426
|
+
used: os10.totalmem() - os10.freemem(),
|
|
181234
181427
|
process: process.memoryUsage()
|
|
181235
181428
|
},
|
|
181236
181429
|
dataDir: config.get("dataDir"),
|
|
@@ -181266,11 +181459,11 @@ var systemRoutes = new Elysia({ prefix: "/api/v1/system" }).get("/info", async (
|
|
|
181266
181459
|
description: "Check PostgreSQL, pgvector, Ollama, and local artifact directory health"
|
|
181267
181460
|
}
|
|
181268
181461
|
}).get("/metrics", async () => {
|
|
181269
|
-
const metricsPath =
|
|
181462
|
+
const metricsPath = path38.join(process.cwd(), "data", "metrics.json");
|
|
181270
181463
|
let metrics2 = {};
|
|
181271
|
-
if (
|
|
181464
|
+
if (fs25.existsSync(metricsPath)) {
|
|
181272
181465
|
try {
|
|
181273
|
-
metrics2 = JSON.parse(
|
|
181466
|
+
metrics2 = JSON.parse(fs25.readFileSync(metricsPath, "utf-8"));
|
|
181274
181467
|
} catch {}
|
|
181275
181468
|
}
|
|
181276
181469
|
const database = await getDatabaseInfo();
|
|
@@ -181464,8 +181657,8 @@ var eventsRoutes = new Elysia({ prefix: "/api/v1" }).get("/events", async ({ que
|
|
|
181464
181657
|
});
|
|
181465
181658
|
|
|
181466
181659
|
// src/routes/workspace.ts
|
|
181467
|
-
import
|
|
181468
|
-
import
|
|
181660
|
+
import fs26 from "fs/promises";
|
|
181661
|
+
import path39 from "path";
|
|
181469
181662
|
import { realpathSync as realpathSync4 } from "fs";
|
|
181470
181663
|
var indexProjectTool2 = null;
|
|
181471
181664
|
function getIndexProjectTool2() {
|
|
@@ -181507,7 +181700,7 @@ function realpathSafe(p) {
|
|
|
181507
181700
|
try {
|
|
181508
181701
|
return realpathSync4(p);
|
|
181509
181702
|
} catch {
|
|
181510
|
-
return
|
|
181703
|
+
return path39.resolve(p);
|
|
181511
181704
|
}
|
|
181512
181705
|
}
|
|
181513
181706
|
var graphController = null;
|
|
@@ -181858,8 +182051,8 @@ var workspaceRoutes = new Elysia({ prefix: "/api/v1" }).get("/workspace/list", a
|
|
|
181858
182051
|
}
|
|
181859
182052
|
const registeredRoot = realpathSafe(workspace.project_path);
|
|
181860
182053
|
const callerRoot = realpathSafe(projectPath2);
|
|
181861
|
-
const rel =
|
|
181862
|
-
const escapes = rel.startsWith("..") ||
|
|
182054
|
+
const rel = path39.relative(registeredRoot, callerRoot);
|
|
182055
|
+
const escapes = rel.startsWith("..") || path39.isAbsolute(rel);
|
|
181863
182056
|
if (registeredRoot !== callerRoot && escapes) {
|
|
181864
182057
|
return {
|
|
181865
182058
|
success: false,
|
|
@@ -181989,8 +182182,8 @@ var workspaceRoutes = new Elysia({ prefix: "/api/v1" }).get("/workspace/list", a
|
|
|
181989
182182
|
} else {
|
|
181990
182183
|
end = start + 20;
|
|
181991
182184
|
}
|
|
181992
|
-
const absolutePath =
|
|
181993
|
-
const content = await
|
|
182185
|
+
const absolutePath = path39.join(workspace.project_path, file3);
|
|
182186
|
+
const content = await fs26.readFile(absolutePath, "utf-8");
|
|
181994
182187
|
const lines = content.split(/\r?\n/);
|
|
181995
182188
|
const slice = lines.slice(start - 1, Math.min(lines.length, end));
|
|
181996
182189
|
const formatted = slice.map((text3, idx) => ({
|
|
@@ -183241,8 +183434,8 @@ var webRoutes = new Elysia({ prefix: "/api/v1/web" }).post("/fetch_and_index", a
|
|
|
183241
183434
|
});
|
|
183242
183435
|
|
|
183243
183436
|
// src/routes/web-ui.ts
|
|
183244
|
-
import
|
|
183245
|
-
import
|
|
183437
|
+
import fs27 from "fs/promises";
|
|
183438
|
+
import path40 from "path";
|
|
183246
183439
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
183247
183440
|
|
|
183248
183441
|
// src/web-ui-trust.ts
|
|
@@ -183286,9 +183479,9 @@ function buildStaticDirCandidates(moduleDir, cwd) {
|
|
|
183286
183479
|
for (const root2 of [moduleDir, cwd]) {
|
|
183287
183480
|
let dir = root2;
|
|
183288
183481
|
for (let i = 0;i < 10; i++) {
|
|
183289
|
-
candidates2.push(
|
|
183290
|
-
candidates2.push(
|
|
183291
|
-
const parent =
|
|
183482
|
+
candidates2.push(path40.resolve(dir, "apps/web-ui/dist/static"));
|
|
183483
|
+
candidates2.push(path40.resolve(dir, "web-ui/dist/static"));
|
|
183484
|
+
const parent = path40.dirname(dir);
|
|
183292
183485
|
if (parent === dir)
|
|
183293
183486
|
break;
|
|
183294
183487
|
dir = parent;
|
|
@@ -183296,11 +183489,11 @@ function buildStaticDirCandidates(moduleDir, cwd) {
|
|
|
183296
183489
|
}
|
|
183297
183490
|
return [...new Set(candidates2)];
|
|
183298
183491
|
}
|
|
183299
|
-
var STATIC_DIR_CANDIDATES = buildStaticDirCandidates(
|
|
183492
|
+
var STATIC_DIR_CANDIDATES = buildStaticDirCandidates(path40.dirname(fileURLToPath3(import.meta.url)), process.cwd());
|
|
183300
183493
|
async function resolveStaticDir() {
|
|
183301
183494
|
for (const dir of STATIC_DIR_CANDIDATES) {
|
|
183302
183495
|
try {
|
|
183303
|
-
const st = await
|
|
183496
|
+
const st = await fs27.stat(dir);
|
|
183304
183497
|
if (st.isDirectory())
|
|
183305
183498
|
return dir;
|
|
183306
183499
|
} catch {}
|
|
@@ -183321,7 +183514,7 @@ var CONTENT_TYPES = {
|
|
|
183321
183514
|
".woff2": "font/woff2"
|
|
183322
183515
|
};
|
|
183323
183516
|
function contentTypeFor(filePath) {
|
|
183324
|
-
const ext2 =
|
|
183517
|
+
const ext2 = path40.extname(filePath).toLowerCase();
|
|
183325
183518
|
return CONTENT_TYPES[ext2] ?? "application/octet-stream";
|
|
183326
183519
|
}
|
|
183327
183520
|
function webUiDisabled() {
|
|
@@ -183332,13 +183525,13 @@ function webUiDisabled() {
|
|
|
183332
183525
|
}
|
|
183333
183526
|
async function resolveSafePath(staticDir, sub) {
|
|
183334
183527
|
const cleaned = sub.replace(/^\/+/, "");
|
|
183335
|
-
const abs =
|
|
183336
|
-
const rel =
|
|
183337
|
-
if (rel.startsWith("..") ||
|
|
183528
|
+
const abs = path40.resolve(staticDir, cleaned);
|
|
183529
|
+
const rel = path40.relative(staticDir, abs);
|
|
183530
|
+
if (rel.startsWith("..") || path40.isAbsolute(rel)) {
|
|
183338
183531
|
return null;
|
|
183339
183532
|
}
|
|
183340
183533
|
try {
|
|
183341
|
-
await
|
|
183534
|
+
await fs27.stat(abs);
|
|
183342
183535
|
return { abs, exists: true };
|
|
183343
183536
|
} catch {
|
|
183344
183537
|
return { abs, exists: false };
|
|
@@ -183361,7 +183554,7 @@ function injectAccessMarkup(html, apiKey, trusted) {
|
|
|
183361
183554
|
return out;
|
|
183362
183555
|
}
|
|
183363
183556
|
async function readShell(indexPath, remoteAddress) {
|
|
183364
|
-
const raw2 = await
|
|
183557
|
+
const raw2 = await fs27.readFile(indexPath, "utf-8");
|
|
183365
183558
|
const trusted = isTrustedWebUiCaller(remoteAddress);
|
|
183366
183559
|
return Buffer.from(injectAccessMarkup(raw2, getConfiguredApiKey(), trusted), "utf-8");
|
|
183367
183560
|
}
|
|
@@ -183378,7 +183571,7 @@ var webUiRoutes = new Elysia().get("/ui", async ({ set: set3, request }) => {
|
|
|
183378
183571
|
set3.status = 500;
|
|
183379
183572
|
return { status: 500, error: "web ui static dir not found" };
|
|
183380
183573
|
}
|
|
183381
|
-
const indexPath =
|
|
183574
|
+
const indexPath = path40.join(dir, "index.html");
|
|
183382
183575
|
try {
|
|
183383
183576
|
const body = await readShell(indexPath, remoteAddressOf(request));
|
|
183384
183577
|
set3.headers["content-type"] = contentTypeFor(indexPath);
|
|
@@ -183411,7 +183604,7 @@ var webUiRoutes = new Elysia().get("/ui", async ({ set: set3, request }) => {
|
|
|
183411
183604
|
}
|
|
183412
183605
|
if (resolved.exists) {
|
|
183413
183606
|
try {
|
|
183414
|
-
const body = await
|
|
183607
|
+
const body = await fs27.readFile(resolved.abs);
|
|
183415
183608
|
set3.headers["content-type"] = contentTypeFor(resolved.abs);
|
|
183416
183609
|
return body;
|
|
183417
183610
|
} catch {
|
|
@@ -183420,7 +183613,7 @@ var webUiRoutes = new Elysia().get("/ui", async ({ set: set3, request }) => {
|
|
|
183420
183613
|
}
|
|
183421
183614
|
}
|
|
183422
183615
|
try {
|
|
183423
|
-
const body = await readShell(
|
|
183616
|
+
const body = await readShell(path40.join(dir, "index.html"), remoteAddressOf(request));
|
|
183424
183617
|
set3.headers["content-type"] = "text/html; charset=utf-8";
|
|
183425
183618
|
return body;
|
|
183426
183619
|
} catch {
|
|
@@ -183568,8 +183761,8 @@ init_dist();
|
|
|
183568
183761
|
|
|
183569
183762
|
// src/routes/model-registry-deployment.ts
|
|
183570
183763
|
init_dist();
|
|
183571
|
-
import
|
|
183572
|
-
var MARKER =
|
|
183764
|
+
import path41 from "path";
|
|
183765
|
+
var MARKER = path41.join("scripts", "generate-subagent-artifacts.ts");
|
|
183573
183766
|
var MAX_LEVELS2 = 6;
|
|
183574
183767
|
var cachedRoot;
|
|
183575
183768
|
function findDeploymentRoot(startDir) {
|
|
@@ -183587,8 +183780,8 @@ function deploymentUnavailableMessage(what) {
|
|
|
183587
183780
|
|
|
183588
183781
|
// src/routes/model-registry.ts
|
|
183589
183782
|
init_config();
|
|
183590
|
-
import
|
|
183591
|
-
import
|
|
183783
|
+
import fs28 from "fs";
|
|
183784
|
+
import path42 from "path";
|
|
183592
183785
|
import { spawnSync } from "child_process";
|
|
183593
183786
|
var _profilesLib = null;
|
|
183594
183787
|
function profilesLib() {
|
|
@@ -183597,7 +183790,7 @@ function profilesLib() {
|
|
|
183597
183790
|
if (!root2) {
|
|
183598
183791
|
throw new Error(deploymentUnavailableMessage("scripts/lib/model-profiles.ts"));
|
|
183599
183792
|
}
|
|
183600
|
-
const libPath =
|
|
183793
|
+
const libPath = path42.join(root2, "scripts", "lib", "model-profiles.ts");
|
|
183601
183794
|
_profilesLib = __require(libPath);
|
|
183602
183795
|
}
|
|
183603
183796
|
return _profilesLib;
|
|
@@ -183622,7 +183815,7 @@ function generatorLib() {
|
|
|
183622
183815
|
if (!root2) {
|
|
183623
183816
|
throw new Error(deploymentUnavailableMessage("scripts/generate-subagent-artifacts.ts"));
|
|
183624
183817
|
}
|
|
183625
|
-
const libPath =
|
|
183818
|
+
const libPath = path42.join(root2, "scripts", "generate-subagent-artifacts.ts");
|
|
183626
183819
|
_generatorLib = __require(libPath);
|
|
183627
183820
|
}
|
|
183628
183821
|
return _generatorLib;
|
|
@@ -183639,7 +183832,7 @@ async function loadAgentsInventory() {
|
|
|
183639
183832
|
var REGISTRY_DETAIL = {
|
|
183640
183833
|
tags: ["model-registry"]
|
|
183641
183834
|
};
|
|
183642
|
-
var OVERLAY_PATH =
|
|
183835
|
+
var OVERLAY_PATH = path42.join(configDir("massa-ai"), "model-profiles.json");
|
|
183643
183836
|
var ZERO_OVERLAY_OVERRIDE_BREAKDOWN = {
|
|
183644
183837
|
hostDefaults: 0,
|
|
183645
183838
|
workflowTiers: 0,
|
|
@@ -183731,7 +183924,7 @@ var modelRegistryRoutes = new Elysia({ prefix: "/api/v1/model-registry" }).get("
|
|
|
183731
183924
|
set3.status = 501;
|
|
183732
183925
|
return { success: false, error: deploymentUnavailableMessage("scripts/generate-subagent-artifacts.ts") };
|
|
183733
183926
|
}
|
|
183734
|
-
const generateScript =
|
|
183927
|
+
const generateScript = path42.join(root2, "scripts", "generate-subagent-artifacts.ts");
|
|
183735
183928
|
try {
|
|
183736
183929
|
const child = spawnSync("bun", [generateScript], {
|
|
183737
183930
|
env: { ...process.env },
|
|
@@ -183770,8 +183963,8 @@ var modelRegistryRoutes = new Elysia({ prefix: "/api/v1/model-registry" }).get("
|
|
|
183770
183963
|
}
|
|
183771
183964
|
const lib = profilesLib();
|
|
183772
183965
|
try {
|
|
183773
|
-
if (
|
|
183774
|
-
|
|
183966
|
+
if (fs28.existsSync(OVERLAY_PATH)) {
|
|
183967
|
+
fs28.unlinkSync(OVERLAY_PATH);
|
|
183775
183968
|
}
|
|
183776
183969
|
const builtin = lib.loadRegistry(lib.DEFAULT_REGISTRY_PATH);
|
|
183777
183970
|
set3.status = 200;
|
|
@@ -183797,17 +183990,17 @@ var modelRegistryRoutes = new Elysia({ prefix: "/api/v1/model-registry" }).get("
|
|
|
183797
183990
|
}
|
|
183798
183991
|
});
|
|
183799
183992
|
function writeOverlayAtomically(overlayPath, data) {
|
|
183800
|
-
const dir =
|
|
183801
|
-
if (!
|
|
183802
|
-
|
|
183993
|
+
const dir = path42.dirname(overlayPath);
|
|
183994
|
+
if (!fs28.existsSync(dir)) {
|
|
183995
|
+
fs28.mkdirSync(dir, { recursive: true });
|
|
183803
183996
|
}
|
|
183804
183997
|
const tmp = `${overlayPath}.${process.pid}.${Date.now()}.tmp`;
|
|
183805
183998
|
try {
|
|
183806
|
-
|
|
183807
|
-
|
|
183999
|
+
fs28.writeFileSync(tmp, JSON.stringify(data, null, 2));
|
|
184000
|
+
fs28.renameSync(tmp, overlayPath);
|
|
183808
184001
|
} catch (e) {
|
|
183809
184002
|
try {
|
|
183810
|
-
|
|
184003
|
+
fs28.unlinkSync(tmp);
|
|
183811
184004
|
} catch {}
|
|
183812
184005
|
throw e;
|
|
183813
184006
|
}
|
|
@@ -184011,8 +184204,8 @@ var configRoutes = new Elysia({ prefix: "/api/v1/config" }).get("/", ({ set: set
|
|
|
184011
184204
|
// src/routes/model-registry-stream.ts
|
|
184012
184205
|
init_config();
|
|
184013
184206
|
init_dist();
|
|
184014
|
-
import
|
|
184015
|
-
import
|
|
184207
|
+
import fs29 from "fs";
|
|
184208
|
+
import path43 from "path";
|
|
184016
184209
|
import { spawn as spawn3 } from "child_process";
|
|
184017
184210
|
var encoder3 = new TextEncoder;
|
|
184018
184211
|
function sseFrame(data) {
|
|
@@ -184024,10 +184217,10 @@ var KNOWN_GENERATOR_FILENAMES = ["generate-skill-artifacts.ts", "generate-subage
|
|
|
184024
184217
|
var SH_C_WRAPPER = /^sh -c '(.*)' --$/;
|
|
184025
184218
|
var GENERATOR_SEGMENT = /^bun\s+(\S+\.ts)(?:\s+"\$@")?$/;
|
|
184026
184219
|
function deriveGeneratorScripts(root2) {
|
|
184027
|
-
const pkgPath =
|
|
184220
|
+
const pkgPath = path43.join(root2, "package.json");
|
|
184028
184221
|
let raw2;
|
|
184029
184222
|
try {
|
|
184030
|
-
raw2 =
|
|
184223
|
+
raw2 = fs29.readFileSync(pkgPath, "utf-8");
|
|
184031
184224
|
} catch (e) {
|
|
184032
184225
|
throw new Error(`cannot read ${pkgPath}: ${e.message}`);
|
|
184033
184226
|
}
|
|
@@ -184054,7 +184247,7 @@ function deriveGeneratorScripts(root2) {
|
|
|
184054
184247
|
throw new Error(`"generate:artifacts" segment does not match the expected "bun <script.ts>" shape: ${JSON.stringify(segment)}`);
|
|
184055
184248
|
}
|
|
184056
184249
|
const relPath = match2[1];
|
|
184057
|
-
return { relPath, name:
|
|
184250
|
+
return { relPath, name: path43.basename(relPath) };
|
|
184058
184251
|
});
|
|
184059
184252
|
}
|
|
184060
184253
|
function assertGeneratorBackstop(scripts) {
|
|
@@ -184206,7 +184399,7 @@ function createRegenerateStreamHandler() {
|
|
|
184206
184399
|
return;
|
|
184207
184400
|
}
|
|
184208
184401
|
const generator = generatorScripts[index];
|
|
184209
|
-
const scriptPath =
|
|
184402
|
+
const scriptPath = path43.join(root2, generator.relPath);
|
|
184210
184403
|
try {
|
|
184211
184404
|
child = spawn3("bun", [scriptPath], {
|
|
184212
184405
|
env: { ...process.env },
|
|
@@ -184364,7 +184557,7 @@ var restartRoutes = new Elysia({ prefix: "/api/v1/system" }).onAfterResponse(()
|
|
|
184364
184557
|
|
|
184365
184558
|
// src/routes/logs.ts
|
|
184366
184559
|
init_dist();
|
|
184367
|
-
import
|
|
184560
|
+
import fs30 from "fs";
|
|
184368
184561
|
var LOGS_DETAIL = { tags: ["logs"] };
|
|
184369
184562
|
var MAX_SCAN_BYTES = 64 * 1024 * 1024;
|
|
184370
184563
|
var MAX_LIMIT = 1000;
|
|
@@ -184444,7 +184637,7 @@ function parseLine(line, prevTs) {
|
|
|
184444
184637
|
function realReadTail(filePath, maxBytes) {
|
|
184445
184638
|
let size;
|
|
184446
184639
|
try {
|
|
184447
|
-
size =
|
|
184640
|
+
size = fs30.statSync(filePath).size;
|
|
184448
184641
|
} catch {
|
|
184449
184642
|
return { content: "", truncated: false };
|
|
184450
184643
|
}
|
|
@@ -184452,24 +184645,24 @@ function realReadTail(filePath, maxBytes) {
|
|
|
184452
184645
|
return { content: "", truncated: false };
|
|
184453
184646
|
if (size <= maxBytes) {
|
|
184454
184647
|
try {
|
|
184455
|
-
return { content:
|
|
184648
|
+
return { content: fs30.readFileSync(filePath, "utf8"), truncated: false };
|
|
184456
184649
|
} catch {
|
|
184457
184650
|
return { content: "", truncated: false };
|
|
184458
184651
|
}
|
|
184459
184652
|
}
|
|
184460
184653
|
try {
|
|
184461
|
-
const fd =
|
|
184654
|
+
const fd = fs30.openSync(filePath, "r");
|
|
184462
184655
|
try {
|
|
184463
184656
|
const start = size - maxBytes;
|
|
184464
184657
|
const buf = Buffer.alloc(maxBytes);
|
|
184465
|
-
|
|
184658
|
+
fs30.readSync(fd, buf, 0, maxBytes, start);
|
|
184466
184659
|
let text3 = buf.toString("utf8");
|
|
184467
184660
|
const firstNewline = text3.indexOf(`
|
|
184468
184661
|
`);
|
|
184469
184662
|
text3 = firstNewline !== -1 ? text3.slice(firstNewline + 1) : "";
|
|
184470
184663
|
return { content: text3, truncated: true };
|
|
184471
184664
|
} finally {
|
|
184472
|
-
|
|
184665
|
+
fs30.closeSync(fd);
|
|
184473
184666
|
}
|
|
184474
184667
|
} catch {
|
|
184475
184668
|
return { content: "", truncated: true };
|
|
@@ -184479,7 +184672,7 @@ var realReader = {
|
|
|
184479
184672
|
listFiles(filePath, maxFiles) {
|
|
184480
184673
|
return sinkFiles(filePath, maxFiles).filter((f) => {
|
|
184481
184674
|
try {
|
|
184482
|
-
|
|
184675
|
+
fs30.accessSync(f, fs30.constants.R_OK);
|
|
184483
184676
|
return true;
|
|
184484
184677
|
} catch {
|
|
184485
184678
|
return false;
|
|
@@ -184568,7 +184761,7 @@ function startSinkTail(enqueue) {
|
|
|
184568
184761
|
let currentFile = initial[0];
|
|
184569
184762
|
let offset;
|
|
184570
184763
|
try {
|
|
184571
|
-
offset =
|
|
184764
|
+
offset = fs30.statSync(currentFile).size;
|
|
184572
184765
|
} catch {
|
|
184573
184766
|
return;
|
|
184574
184767
|
}
|
|
@@ -184584,7 +184777,7 @@ function startSinkTail(enqueue) {
|
|
|
184584
184777
|
offset = 0;
|
|
184585
184778
|
carry = "";
|
|
184586
184779
|
}
|
|
184587
|
-
const size =
|
|
184780
|
+
const size = fs30.statSync(currentFile).size;
|
|
184588
184781
|
if (size < offset) {
|
|
184589
184782
|
offset = 0;
|
|
184590
184783
|
carry = "";
|
|
@@ -184593,11 +184786,11 @@ function startSinkTail(enqueue) {
|
|
|
184593
184786
|
return;
|
|
184594
184787
|
const length = Math.min(size - offset, SINK_POLL_MAX_BYTES);
|
|
184595
184788
|
const buf = Buffer.alloc(length);
|
|
184596
|
-
const fd =
|
|
184789
|
+
const fd = fs30.openSync(currentFile, "r");
|
|
184597
184790
|
try {
|
|
184598
|
-
|
|
184791
|
+
fs30.readSync(fd, buf, 0, length, offset);
|
|
184599
184792
|
} finally {
|
|
184600
|
-
|
|
184793
|
+
fs30.closeSync(fd);
|
|
184601
184794
|
}
|
|
184602
184795
|
offset += length;
|
|
184603
184796
|
const text3 = carry + buf.toString("utf8");
|
|
@@ -184797,12 +184990,12 @@ var READ_ONLY_ROUTES = [
|
|
|
184797
184990
|
justification: "Clean. apps/tools-api/src/routes/workspace.ts:542-673 calls " + "`getGraphController().analyzeImpact(...)`, which " + "(packages/core/src/services/symbol/graph-controller.ts:189-232) delegates to " + "`impactAnalysisService.analyze(...)` " + "(packages/core/src/services/symbol/impact-analysis.ts). Every git invocation there " + "runs through `execFileSync` for `rev-parse`/`diff`/`status`-class read commands, " + "plus one `hash-object -t tree --stdin` with no `-w` flag (so nothing is written to " + "the git object database) \u2014 no `git commit`, `git add`, or `-w` flag anywhere in " + "the module."
|
|
184798
184991
|
}
|
|
184799
184992
|
];
|
|
184800
|
-
function normalizeRoutePath(
|
|
184801
|
-
return
|
|
184993
|
+
function normalizeRoutePath(path44) {
|
|
184994
|
+
return path44.length > 1 && path44.endsWith("/") ? path44.slice(0, -1) : path44;
|
|
184802
184995
|
}
|
|
184803
184996
|
var READ_ONLY_INDEX = new Map(READ_ONLY_ROUTES.map((entry2) => [`${entry2.method} ${entry2.path}`, entry2]));
|
|
184804
|
-
function findReadOnlyRoute(method,
|
|
184805
|
-
return READ_ONLY_INDEX.get(`${method.toUpperCase()} ${normalizeRoutePath(
|
|
184997
|
+
function findReadOnlyRoute(method, path44) {
|
|
184998
|
+
return READ_ONLY_INDEX.get(`${method.toUpperCase()} ${normalizeRoutePath(path44)}`);
|
|
184806
184999
|
}
|
|
184807
185000
|
|
|
184808
185001
|
// src/middleware/write-mode.ts
|
|
@@ -184821,14 +185014,14 @@ var WRITE_REFUSED = {
|
|
|
184821
185014
|
success: false,
|
|
184822
185015
|
error: "Write refused: read-only mode is active"
|
|
184823
185016
|
};
|
|
184824
|
-
var writeModeMiddleware = new Elysia({ name: "write-mode" }).onBeforeHandle({ as: "global" }, ({ request, path:
|
|
185017
|
+
var writeModeMiddleware = new Elysia({ name: "write-mode" }).onBeforeHandle({ as: "global" }, ({ request, path: path44, set: set3, body }) => {
|
|
184825
185018
|
if (request.method.toUpperCase() === "GET")
|
|
184826
185019
|
return;
|
|
184827
|
-
if (isPublicPath(
|
|
185020
|
+
if (isPublicPath(path44))
|
|
184828
185021
|
return;
|
|
184829
185022
|
if (!isReadOnlyModeActive())
|
|
184830
185023
|
return;
|
|
184831
|
-
const entry2 = findReadOnlyRoute(request.method,
|
|
185024
|
+
const entry2 = findReadOnlyRoute(request.method, path44);
|
|
184832
185025
|
if (entry2) {
|
|
184833
185026
|
if (entry2.sanitizeBody && body && typeof body === "object") {
|
|
184834
185027
|
entry2.sanitizeBody(body);
|
|
@@ -184841,11 +185034,11 @@ var writeModeMiddleware = new Elysia({ name: "write-mode" }).onBeforeHandle({ as
|
|
|
184841
185034
|
|
|
184842
185035
|
// src/middleware/error.ts
|
|
184843
185036
|
init_dist();
|
|
184844
|
-
var errorHandler = new Elysia({ name: "error-handler" }).onError(({ code, error: error51, set: set3, path:
|
|
185037
|
+
var errorHandler = new Elysia({ name: "error-handler" }).onError(({ code, error: error51, set: set3, path: path44, request }) => {
|
|
184845
185038
|
logger.error("[massa-ai-api] Request failed", undefined, {
|
|
184846
185039
|
...safeErrorSummary(error51),
|
|
184847
185040
|
code,
|
|
184848
|
-
path:
|
|
185041
|
+
path: path44,
|
|
184849
185042
|
method: request.method
|
|
184850
185043
|
});
|
|
184851
185044
|
if (error51 instanceof SearchServiceError) {
|