@massa-ai/tools-api 1.59.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 +775 -538
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -487,13 +487,33 @@ var init_inference_providers = __esm(() => {
|
|
|
487
487
|
},
|
|
488
488
|
knownDimensions: {
|
|
489
489
|
"text-embedding-nomic-embed-text-v1.5": 768,
|
|
490
|
-
"text-embedding-qwen3-embedding-0.6b": 1024
|
|
490
|
+
"text-embedding-qwen3-embedding-0.6b": 1024,
|
|
491
|
+
"qwen3-embedding-0.6b-dwq": 1024
|
|
491
492
|
},
|
|
492
493
|
defaultModels: {
|
|
493
494
|
embedding: "text-embedding-qwen3-embedding-0.6b",
|
|
494
495
|
instruct: "qwen3-vl-8b-instruct",
|
|
495
496
|
coding: "qwen2.5-coder-7b-instruct"
|
|
496
497
|
},
|
|
498
|
+
mlxModels: {
|
|
499
|
+
embedding: {
|
|
500
|
+
repo: "mlx-community/Qwen3-Embedding-0.6B-4bit-DWQ",
|
|
501
|
+
model: "qwen3-embedding-0.6b-dwq"
|
|
502
|
+
},
|
|
503
|
+
instruct: {
|
|
504
|
+
repo: "mlx-community/Qwen3-VL-8B-Instruct-4bit",
|
|
505
|
+
model: "qwen3-vl-8b-instruct"
|
|
506
|
+
},
|
|
507
|
+
coding: {
|
|
508
|
+
repo: "mlx-community/Qwen2.5-Coder-7B-Instruct-4bit",
|
|
509
|
+
model: "qwen2.5-coder-7b-instruct"
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
ggufRepos: {
|
|
513
|
+
embedding: "Qwen/Qwen3-Embedding-0.6B-GGUF",
|
|
514
|
+
instruct: "lmstudio-community/Qwen3-VL-8B-Instruct-GGUF",
|
|
515
|
+
coding: "lmstudio-community/Qwen2.5-Coder-7B-Instruct-GGUF"
|
|
516
|
+
},
|
|
497
517
|
appliesContextPerRequest: false,
|
|
498
518
|
embedBatchSize: 64,
|
|
499
519
|
supportsOllamaVersionProbe: false,
|
|
@@ -8313,12 +8333,13 @@ function selectRecord(records) {
|
|
|
8313
8333
|
}
|
|
8314
8334
|
return best ?? pool[pool.length - 1];
|
|
8315
8335
|
}
|
|
8316
|
-
function
|
|
8336
|
+
function resolveClaudeMarketplaceInstall(opts = {}) {
|
|
8317
8337
|
const targetHome = opts.targetHome ?? os5.homedir();
|
|
8318
8338
|
const pluginKey = opts.pluginKey ?? DEFAULT_PLUGIN_KEY;
|
|
8319
8339
|
const directoryResult = resolveDirectorySourceRoot(targetHome, pluginKey);
|
|
8320
|
-
if (directoryResult !== undefined)
|
|
8321
|
-
return directoryResult;
|
|
8340
|
+
if (directoryResult !== undefined) {
|
|
8341
|
+
return directoryResult === null ? null : { root: directoryResult, route: "directory-source" };
|
|
8342
|
+
}
|
|
8322
8343
|
const registryPath = path11.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
8323
8344
|
let records;
|
|
8324
8345
|
try {
|
|
@@ -8340,15 +8361,197 @@ function resolveClaudeMarketplaceRoot(opts = {}) {
|
|
|
8340
8361
|
} catch {
|
|
8341
8362
|
return null;
|
|
8342
8363
|
}
|
|
8343
|
-
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;
|
|
8344
8383
|
}
|
|
8345
8384
|
var DEFAULT_PLUGIN_KEY = "massa-ai@massa-ai";
|
|
8346
8385
|
var init_claude_marketplace = () => {};
|
|
8347
8386
|
|
|
8348
|
-
// ../../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
|
|
8349
8444
|
import fs8 from "fs";
|
|
8350
|
-
import path12 from "path";
|
|
8351
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";
|
|
8352
8555
|
import crypto5 from "crypto";
|
|
8353
8556
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
8354
8557
|
function namedError3(name, message) {
|
|
@@ -8357,10 +8560,10 @@ function namedError3(name, message) {
|
|
|
8357
8560
|
return err;
|
|
8358
8561
|
}
|
|
8359
8562
|
function defaultStatePath(targetHome) {
|
|
8360
|
-
return
|
|
8563
|
+
return path13.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
8361
8564
|
}
|
|
8362
8565
|
function resolveCommon(opts) {
|
|
8363
|
-
const targetHome = opts.targetHome ??
|
|
8566
|
+
const targetHome = opts.targetHome ?? os7.homedir();
|
|
8364
8567
|
const stateFilePath = opts.stateFilePath ?? defaultStatePath(targetHome);
|
|
8365
8568
|
return { targetHome, stateFilePath };
|
|
8366
8569
|
}
|
|
@@ -8368,7 +8571,7 @@ function marketplaceRoots(targetHome, state) {
|
|
|
8368
8571
|
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
8369
8572
|
}
|
|
8370
8573
|
function claudeMarketplaceUnresolvedReason(targetHome) {
|
|
8371
|
-
const registryPath =
|
|
8574
|
+
const registryPath = path13.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
8372
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";
|
|
8373
8576
|
}
|
|
8374
8577
|
function listProfiles(opts = {}) {
|
|
@@ -8376,6 +8579,12 @@ function listProfiles(opts = {}) {
|
|
|
8376
8579
|
const state = readInstallState(stateFilePath);
|
|
8377
8580
|
const roots = marketplaceRoots(targetHome, state);
|
|
8378
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 };
|
|
8379
8588
|
const hosts = universe.map((host) => {
|
|
8380
8589
|
if (host === "claude" && state.platforms.claude?.installRoute === "marketplace" && roots.claude === undefined) {
|
|
8381
8590
|
const platform2 = state.platforms.claude;
|
|
@@ -8386,7 +8595,8 @@ function listProfiles(opts = {}) {
|
|
|
8386
8595
|
skipReason: null,
|
|
8387
8596
|
activeProfile: platform2.modelProfile?.profile ?? opts.hostDefaults?.[host] ?? "balanced",
|
|
8388
8597
|
bundleVersion: platform2.plugin?.version ?? null,
|
|
8389
|
-
availableProfiles: []
|
|
8598
|
+
availableProfiles: [],
|
|
8599
|
+
...claudeDriftFields(host)
|
|
8390
8600
|
};
|
|
8391
8601
|
}
|
|
8392
8602
|
const layout = resolveHostLayout(host, { targetHome, projectRoot: opts.projectRoot, marketplaceRoot: roots });
|
|
@@ -8398,10 +8608,11 @@ function listProfiles(opts = {}) {
|
|
|
8398
8608
|
skipReason: layout.reason,
|
|
8399
8609
|
activeProfile: null,
|
|
8400
8610
|
bundleVersion: null,
|
|
8401
|
-
availableProfiles: []
|
|
8611
|
+
availableProfiles: [],
|
|
8612
|
+
...claudeDriftFields(host)
|
|
8402
8613
|
};
|
|
8403
8614
|
}
|
|
8404
|
-
const installed =
|
|
8615
|
+
const installed = fs9.existsSync(layout.activeDir);
|
|
8405
8616
|
const availableProfiles = listVariantProfiles(layout);
|
|
8406
8617
|
const platform = state.platforms[host];
|
|
8407
8618
|
return {
|
|
@@ -8411,15 +8622,16 @@ function listProfiles(opts = {}) {
|
|
|
8411
8622
|
skipReason: null,
|
|
8412
8623
|
activeProfile: platform?.modelProfile?.profile ?? opts.hostDefaults?.[host] ?? "balanced",
|
|
8413
8624
|
bundleVersion: platform?.plugin?.version ?? null,
|
|
8414
|
-
availableProfiles
|
|
8625
|
+
availableProfiles,
|
|
8626
|
+
...claudeDriftFields(host)
|
|
8415
8627
|
};
|
|
8416
8628
|
});
|
|
8417
8629
|
return { hosts };
|
|
8418
8630
|
}
|
|
8419
8631
|
function listVariantProfiles(layout) {
|
|
8420
|
-
if (!
|
|
8632
|
+
if (!fs9.existsSync(layout.variantsRoot))
|
|
8421
8633
|
return [];
|
|
8422
|
-
return
|
|
8634
|
+
return fs9.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
8423
8635
|
}
|
|
8424
8636
|
function matchesGlob(filename, glob) {
|
|
8425
8637
|
const starIdx = glob.indexOf("*");
|
|
@@ -8430,7 +8642,7 @@ function matchesGlob(filename, glob) {
|
|
|
8430
8642
|
return filename.length >= prefix.length + suffix.length && filename.startsWith(prefix) && filename.endsWith(suffix);
|
|
8431
8643
|
}
|
|
8432
8644
|
function matchingFileNames(dir, glob) {
|
|
8433
|
-
return
|
|
8645
|
+
return fs9.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && matchesGlob(e.name, glob)).map((e) => e.name);
|
|
8434
8646
|
}
|
|
8435
8647
|
function detectGitAvailability(dir) {
|
|
8436
8648
|
try {
|
|
@@ -8456,7 +8668,7 @@ function gitTrackedFileNames(dir, filenames) {
|
|
|
8456
8668
|
}
|
|
8457
8669
|
}
|
|
8458
8670
|
function checkTrackedPathGuard(activeDir, filenames) {
|
|
8459
|
-
if (filenames.length === 0 || !
|
|
8671
|
+
if (filenames.length === 0 || !fs9.existsSync(activeDir))
|
|
8460
8672
|
return GUARD_PASS;
|
|
8461
8673
|
const availability = detectGitAvailability(activeDir);
|
|
8462
8674
|
if (availability === "no-git")
|
|
@@ -8467,53 +8679,53 @@ function checkTrackedPathGuard(activeDir, filenames) {
|
|
|
8467
8679
|
if (tracked.size === 0)
|
|
8468
8680
|
return GUARD_PASS;
|
|
8469
8681
|
const offending = filenames.find((name) => tracked.has(name));
|
|
8470
|
-
return { blocked: true, path:
|
|
8682
|
+
return { blocked: true, path: path13.join(activeDir, offending), unchecked: false };
|
|
8471
8683
|
}
|
|
8472
8684
|
function assertStateWritable(stateFilePath) {
|
|
8473
|
-
const dir =
|
|
8685
|
+
const dir = path13.dirname(stateFilePath);
|
|
8474
8686
|
try {
|
|
8475
|
-
|
|
8687
|
+
fs9.mkdirSync(dir, { recursive: true });
|
|
8476
8688
|
} catch (err) {
|
|
8477
8689
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
8478
8690
|
}
|
|
8479
|
-
const checkPath =
|
|
8691
|
+
const checkPath = fs9.existsSync(stateFilePath) ? stateFilePath : dir;
|
|
8480
8692
|
try {
|
|
8481
|
-
|
|
8693
|
+
fs9.accessSync(checkPath, fs9.constants.W_OK);
|
|
8482
8694
|
} catch (err) {
|
|
8483
8695
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
8484
8696
|
}
|
|
8485
8697
|
}
|
|
8486
8698
|
function copyFileRouteVariant(layout, variantDir) {
|
|
8487
|
-
|
|
8699
|
+
fs9.mkdirSync(layout.activeDir, { recursive: true });
|
|
8488
8700
|
let changed = 0;
|
|
8489
|
-
for (const entry of
|
|
8701
|
+
for (const entry of fs9.readdirSync(variantDir, { withFileTypes: true })) {
|
|
8490
8702
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
8491
8703
|
continue;
|
|
8492
|
-
|
|
8704
|
+
fs9.copyFileSync(path13.join(variantDir, entry.name), path13.join(layout.activeDir, entry.name));
|
|
8493
8705
|
changed++;
|
|
8494
8706
|
}
|
|
8495
8707
|
return changed;
|
|
8496
8708
|
}
|
|
8497
8709
|
function repointOpencodeVariant(layout, variantDir) {
|
|
8498
|
-
|
|
8710
|
+
fs9.mkdirSync(layout.activeDir, { recursive: true });
|
|
8499
8711
|
let changed = 0;
|
|
8500
|
-
for (const entry of
|
|
8712
|
+
for (const entry of fs9.readdirSync(variantDir, { withFileTypes: true })) {
|
|
8501
8713
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
8502
8714
|
continue;
|
|
8503
|
-
const dest =
|
|
8504
|
-
const target =
|
|
8715
|
+
const dest = path13.join(layout.activeDir, entry.name);
|
|
8716
|
+
const target = path13.resolve(path13.join(variantDir, entry.name));
|
|
8505
8717
|
let destExists = true;
|
|
8506
8718
|
let destIsSymlink = false;
|
|
8507
8719
|
try {
|
|
8508
|
-
destIsSymlink =
|
|
8720
|
+
destIsSymlink = fs9.lstatSync(dest).isSymbolicLink();
|
|
8509
8721
|
} catch {
|
|
8510
8722
|
destExists = false;
|
|
8511
8723
|
}
|
|
8512
8724
|
if (destExists && !destIsSymlink)
|
|
8513
8725
|
continue;
|
|
8514
8726
|
const tmp = `${dest}.massa-ai-switch.${crypto5.randomUUID()}`;
|
|
8515
|
-
|
|
8516
|
-
|
|
8727
|
+
fs9.symlinkSync(target, tmp);
|
|
8728
|
+
fs9.renameSync(tmp, dest);
|
|
8517
8729
|
changed++;
|
|
8518
8730
|
}
|
|
8519
8731
|
return changed;
|
|
@@ -8553,13 +8765,13 @@ function switchProfile(opts) {
|
|
|
8553
8765
|
if (fileHosts.length === 0) {
|
|
8554
8766
|
return { profile: opts.profile, dryRun, hosts: orderRows(universe, skipRows), restartRequired: false };
|
|
8555
8767
|
}
|
|
8556
|
-
const installedFileHosts = fileHosts.filter((h) =>
|
|
8768
|
+
const installedFileHosts = fileHosts.filter((h) => fs9.existsSync(h.layout.activeDir));
|
|
8557
8769
|
if (installedFileHosts.length === 0)
|
|
8558
8770
|
throw NoHostsDetectedError();
|
|
8559
8771
|
const withAvailability = fileHosts.map((h) => {
|
|
8560
|
-
const variantsRootExists =
|
|
8772
|
+
const variantsRootExists = fs9.existsSync(h.layout.variantsRoot);
|
|
8561
8773
|
const variantDir = h.layout.variantDir(opts.profile);
|
|
8562
|
-
const available = variantsRootExists &&
|
|
8774
|
+
const available = variantsRootExists && fs9.existsSync(variantDir) && fs9.statSync(variantDir).isDirectory();
|
|
8563
8775
|
return { ...h, variantsRootExists, variantDir, available };
|
|
8564
8776
|
});
|
|
8565
8777
|
if (!withAvailability.some((h) => h.available)) {
|
|
@@ -8595,7 +8807,7 @@ function switchProfile(opts) {
|
|
|
8595
8807
|
continue;
|
|
8596
8808
|
}
|
|
8597
8809
|
if (dryRun) {
|
|
8598
|
-
rows.push({ host: h.host, status: "
|
|
8810
|
+
rows.push({ host: h.host, status: "would-switch" });
|
|
8599
8811
|
continue;
|
|
8600
8812
|
}
|
|
8601
8813
|
const candidateNames = matchingFileNames(h.variantDir, h.layout.activeGlob);
|
|
@@ -8640,6 +8852,7 @@ var init_engine = __esm(() => {
|
|
|
8640
8852
|
init_state();
|
|
8641
8853
|
init_lock();
|
|
8642
8854
|
init_claude_marketplace();
|
|
8855
|
+
init_doctor();
|
|
8643
8856
|
SwitchEngineError = class SwitchEngineError extends Error {
|
|
8644
8857
|
constructor(message) {
|
|
8645
8858
|
super(message);
|
|
@@ -8652,29 +8865,29 @@ var init_engine = __esm(() => {
|
|
|
8652
8865
|
|
|
8653
8866
|
// ../../packages/shared/dist/profile-switch/report.js
|
|
8654
8867
|
function reportSucceeded(report) {
|
|
8655
|
-
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");
|
|
8656
8869
|
}
|
|
8657
8870
|
|
|
8658
8871
|
// ../../packages/shared/dist/profile-switch/variant-sync.js
|
|
8659
|
-
import
|
|
8660
|
-
import
|
|
8661
|
-
import
|
|
8872
|
+
import fs10 from "fs";
|
|
8873
|
+
import path14 from "path";
|
|
8874
|
+
import os8 from "os";
|
|
8662
8875
|
import crypto6 from "crypto";
|
|
8663
8876
|
function defaultStatePath2(targetHome) {
|
|
8664
|
-
return
|
|
8877
|
+
return path14.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
8665
8878
|
}
|
|
8666
8879
|
function marketplaceRoots2(targetHome, state) {
|
|
8667
8880
|
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
8668
8881
|
}
|
|
8669
8882
|
function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
8670
8883
|
const unique = `${process.pid}.${++tempFileCounter2}.${crypto6.randomBytes(6).toString("hex")}`;
|
|
8671
|
-
const tempFile =
|
|
8884
|
+
const tempFile = path14.join(destDir, `.${destName}.${unique}.tmp`);
|
|
8672
8885
|
try {
|
|
8673
|
-
|
|
8674
|
-
|
|
8886
|
+
fs10.writeFileSync(tempFile, content);
|
|
8887
|
+
fs10.renameSync(tempFile, path14.join(destDir, destName));
|
|
8675
8888
|
} catch (error) {
|
|
8676
8889
|
try {
|
|
8677
|
-
|
|
8890
|
+
fs10.unlinkSync(tempFile);
|
|
8678
8891
|
} catch {}
|
|
8679
8892
|
throw error;
|
|
8680
8893
|
}
|
|
@@ -8682,20 +8895,20 @@ function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
|
8682
8895
|
function isSafeDirName(name) {
|
|
8683
8896
|
if (name === "." || name === "..")
|
|
8684
8897
|
return false;
|
|
8685
|
-
if (name.includes("/") || name.includes("\\") || name.includes(
|
|
8898
|
+
if (name.includes("/") || name.includes("\\") || name.includes(path14.sep))
|
|
8686
8899
|
return false;
|
|
8687
|
-
return
|
|
8900
|
+
return path14.basename(name) === name;
|
|
8688
8901
|
}
|
|
8689
8902
|
function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
8690
8903
|
const layout = resolveHostLayout(host, { targetHome, marketplaceRoot });
|
|
8691
8904
|
if (layout.route === "skip") {
|
|
8692
8905
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: layout.reason };
|
|
8693
8906
|
}
|
|
8694
|
-
const srcDir =
|
|
8695
|
-
if (!
|
|
8907
|
+
const srcDir = path14.join(sourceRoot, "apps", `${host}-plugin`, "agent-profiles");
|
|
8908
|
+
if (!fs10.existsSync(srcDir) || !fs10.statSync(srcDir).isDirectory()) {
|
|
8696
8909
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: "no generated variants for this host" };
|
|
8697
8910
|
}
|
|
8698
|
-
if (!
|
|
8911
|
+
if (!fs10.existsSync(layout.variantsRoot)) {
|
|
8699
8912
|
return {
|
|
8700
8913
|
host,
|
|
8701
8914
|
status: "skipped",
|
|
@@ -8707,24 +8920,24 @@ function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
|
8707
8920
|
}
|
|
8708
8921
|
const profiles = [];
|
|
8709
8922
|
let files = 0;
|
|
8710
|
-
for (const entry of
|
|
8923
|
+
for (const entry of fs10.readdirSync(srcDir, { withFileTypes: true })) {
|
|
8711
8924
|
if (!entry.isDirectory())
|
|
8712
8925
|
continue;
|
|
8713
8926
|
if (!isSafeDirName(entry.name))
|
|
8714
8927
|
continue;
|
|
8715
|
-
const srcProfileDir =
|
|
8716
|
-
const destProfileDir =
|
|
8717
|
-
|
|
8718
|
-
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 })) {
|
|
8719
8932
|
if (!fileEntry.isFile())
|
|
8720
8933
|
continue;
|
|
8721
|
-
const content =
|
|
8934
|
+
const content = fs10.readFileSync(path14.join(srcProfileDir, fileEntry.name));
|
|
8722
8935
|
writeFileIntoDirAtomically(destProfileDir, fileEntry.name, content);
|
|
8723
8936
|
files++;
|
|
8724
8937
|
}
|
|
8725
8938
|
profiles.push(entry.name);
|
|
8726
8939
|
}
|
|
8727
|
-
const retained =
|
|
8940
|
+
const retained = fs10.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory() && !profiles.includes(e.name)).map((e) => e.name).sort();
|
|
8728
8941
|
return { host, status: "synced", profiles: profiles.sort(), retained, files };
|
|
8729
8942
|
}
|
|
8730
8943
|
function syncGeneratedVariants(opts) {
|
|
@@ -8740,7 +8953,7 @@ function syncGeneratedVariants(opts) {
|
|
|
8740
8953
|
}));
|
|
8741
8954
|
}
|
|
8742
8955
|
const sourceRoot = opts.sourceRoot;
|
|
8743
|
-
const targetHome = opts.targetHome ??
|
|
8956
|
+
const targetHome = opts.targetHome ?? os8.homedir();
|
|
8744
8957
|
const state = readInstallState(defaultStatePath2(targetHome));
|
|
8745
8958
|
const roots = marketplaceRoots2(targetHome, state);
|
|
8746
8959
|
return hosts.map((host) => {
|
|
@@ -8759,14 +8972,14 @@ var init_variant_sync = __esm(() => {
|
|
|
8759
8972
|
});
|
|
8760
8973
|
|
|
8761
8974
|
// ../../packages/shared/dist/profile-switch/repo-root.js
|
|
8762
|
-
import
|
|
8763
|
-
import
|
|
8975
|
+
import fs11 from "fs";
|
|
8976
|
+
import path15 from "path";
|
|
8764
8977
|
function findRepoRootWithMarker(startDir, marker, maxLevels) {
|
|
8765
8978
|
let dir = startDir;
|
|
8766
8979
|
for (let i = 0;i <= maxLevels; i++) {
|
|
8767
|
-
if (
|
|
8980
|
+
if (fs11.existsSync(path15.join(dir, marker)))
|
|
8768
8981
|
return dir;
|
|
8769
|
-
const parent =
|
|
8982
|
+
const parent = path15.dirname(dir);
|
|
8770
8983
|
if (parent === dir)
|
|
8771
8984
|
break;
|
|
8772
8985
|
dir = parent;
|
|
@@ -10406,7 +10619,7 @@ var import_brace_expansion, minimatch = (p, pattern, options = {}) => {
|
|
|
10406
10619
|
}, qmarksTestNoExtDot = ([$0]) => {
|
|
10407
10620
|
const len = $0.length;
|
|
10408
10621
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
10409
|
-
}, 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) => {
|
|
10410
10623
|
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
10411
10624
|
return minimatch;
|
|
10412
10625
|
}
|
|
@@ -10464,11 +10677,11 @@ var init_esm = __esm(() => {
|
|
|
10464
10677
|
starRE = /^\*+$/;
|
|
10465
10678
|
qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
10466
10679
|
defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
10467
|
-
|
|
10680
|
+
path16 = {
|
|
10468
10681
|
win32: { sep: "\\" },
|
|
10469
10682
|
posix: { sep: "/" }
|
|
10470
10683
|
};
|
|
10471
|
-
sep = defaultPlatform === "win32" ?
|
|
10684
|
+
sep = defaultPlatform === "win32" ? path16.win32.sep : path16.posix.sep;
|
|
10472
10685
|
minimatch.sep = sep;
|
|
10473
10686
|
GLOBSTAR = Symbol("globstar **");
|
|
10474
10687
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -12434,12 +12647,12 @@ var init_esm4 = __esm(() => {
|
|
|
12434
12647
|
childrenCache() {
|
|
12435
12648
|
return this.#children;
|
|
12436
12649
|
}
|
|
12437
|
-
resolve(
|
|
12438
|
-
if (!
|
|
12650
|
+
resolve(path17) {
|
|
12651
|
+
if (!path17) {
|
|
12439
12652
|
return this;
|
|
12440
12653
|
}
|
|
12441
|
-
const rootPath = this.getRootString(
|
|
12442
|
-
const dir =
|
|
12654
|
+
const rootPath = this.getRootString(path17);
|
|
12655
|
+
const dir = path17.substring(rootPath.length);
|
|
12443
12656
|
const dirParts = dir.split(this.splitSep);
|
|
12444
12657
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
12445
12658
|
return result;
|
|
@@ -12967,8 +13180,8 @@ var init_esm4 = __esm(() => {
|
|
|
12967
13180
|
newChild(name, type = UNKNOWN, opts = {}) {
|
|
12968
13181
|
return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
|
12969
13182
|
}
|
|
12970
|
-
getRootString(
|
|
12971
|
-
return win32.parse(
|
|
13183
|
+
getRootString(path17) {
|
|
13184
|
+
return win32.parse(path17).root;
|
|
12972
13185
|
}
|
|
12973
13186
|
getRoot(rootPath) {
|
|
12974
13187
|
rootPath = uncToDrive(rootPath.toUpperCase());
|
|
@@ -12993,8 +13206,8 @@ var init_esm4 = __esm(() => {
|
|
|
12993
13206
|
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
|
12994
13207
|
super(name, type, root, roots, nocase, children, opts);
|
|
12995
13208
|
}
|
|
12996
|
-
getRootString(
|
|
12997
|
-
return
|
|
13209
|
+
getRootString(path17) {
|
|
13210
|
+
return path17.startsWith("/") ? "/" : "";
|
|
12998
13211
|
}
|
|
12999
13212
|
getRoot(_rootPath) {
|
|
13000
13213
|
return this.root;
|
|
@@ -13013,8 +13226,8 @@ var init_esm4 = __esm(() => {
|
|
|
13013
13226
|
#children;
|
|
13014
13227
|
nocase;
|
|
13015
13228
|
#fs;
|
|
13016
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
13017
|
-
this.#fs = fsFromOption(
|
|
13229
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs12 = defaultFS } = {}) {
|
|
13230
|
+
this.#fs = fsFromOption(fs12);
|
|
13018
13231
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
13019
13232
|
cwd = fileURLToPath(cwd);
|
|
13020
13233
|
}
|
|
@@ -13050,11 +13263,11 @@ var init_esm4 = __esm(() => {
|
|
|
13050
13263
|
}
|
|
13051
13264
|
this.cwd = prev;
|
|
13052
13265
|
}
|
|
13053
|
-
depth(
|
|
13054
|
-
if (typeof
|
|
13055
|
-
|
|
13266
|
+
depth(path17 = this.cwd) {
|
|
13267
|
+
if (typeof path17 === "string") {
|
|
13268
|
+
path17 = this.cwd.resolve(path17);
|
|
13056
13269
|
}
|
|
13057
|
-
return
|
|
13270
|
+
return path17.depth();
|
|
13058
13271
|
}
|
|
13059
13272
|
childrenCache() {
|
|
13060
13273
|
return this.#children;
|
|
@@ -13470,9 +13683,9 @@ var init_esm4 = __esm(() => {
|
|
|
13470
13683
|
process2();
|
|
13471
13684
|
return results;
|
|
13472
13685
|
}
|
|
13473
|
-
chdir(
|
|
13686
|
+
chdir(path17 = this.cwd) {
|
|
13474
13687
|
const oldCwd = this.cwd;
|
|
13475
|
-
this.cwd = typeof
|
|
13688
|
+
this.cwd = typeof path17 === "string" ? this.cwd.resolve(path17) : path17;
|
|
13476
13689
|
this.cwd[setAsCwd](oldCwd);
|
|
13477
13690
|
}
|
|
13478
13691
|
};
|
|
@@ -13489,8 +13702,8 @@ var init_esm4 = __esm(() => {
|
|
|
13489
13702
|
parseRootPath(dir) {
|
|
13490
13703
|
return win32.parse(dir).root.toUpperCase();
|
|
13491
13704
|
}
|
|
13492
|
-
newRoot(
|
|
13493
|
-
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 });
|
|
13494
13707
|
}
|
|
13495
13708
|
isAbsolute(p) {
|
|
13496
13709
|
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
@@ -13506,8 +13719,8 @@ var init_esm4 = __esm(() => {
|
|
|
13506
13719
|
parseRootPath(_dir) {
|
|
13507
13720
|
return "/";
|
|
13508
13721
|
}
|
|
13509
|
-
newRoot(
|
|
13510
|
-
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 });
|
|
13511
13724
|
}
|
|
13512
13725
|
isAbsolute(p) {
|
|
13513
13726
|
return p.startsWith("/");
|
|
@@ -13764,8 +13977,8 @@ class MatchRecord {
|
|
|
13764
13977
|
this.store.set(target, current === undefined ? n2 : n2 & current);
|
|
13765
13978
|
}
|
|
13766
13979
|
entries() {
|
|
13767
|
-
return [...this.store.entries()].map(([
|
|
13768
|
-
|
|
13980
|
+
return [...this.store.entries()].map(([path17, n2]) => [
|
|
13981
|
+
path17,
|
|
13769
13982
|
!!(n2 & 2),
|
|
13770
13983
|
!!(n2 & 1)
|
|
13771
13984
|
]);
|
|
@@ -13969,9 +14182,9 @@ class GlobUtil {
|
|
|
13969
14182
|
signal;
|
|
13970
14183
|
maxDepth;
|
|
13971
14184
|
includeChildMatches;
|
|
13972
|
-
constructor(patterns,
|
|
14185
|
+
constructor(patterns, path17, opts) {
|
|
13973
14186
|
this.patterns = patterns;
|
|
13974
|
-
this.path =
|
|
14187
|
+
this.path = path17;
|
|
13975
14188
|
this.opts = opts;
|
|
13976
14189
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
13977
14190
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -13990,11 +14203,11 @@ class GlobUtil {
|
|
|
13990
14203
|
});
|
|
13991
14204
|
}
|
|
13992
14205
|
}
|
|
13993
|
-
#ignored(
|
|
13994
|
-
return this.seen.has(
|
|
14206
|
+
#ignored(path17) {
|
|
14207
|
+
return this.seen.has(path17) || !!this.#ignore?.ignored?.(path17);
|
|
13995
14208
|
}
|
|
13996
|
-
#childrenIgnored(
|
|
13997
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
14209
|
+
#childrenIgnored(path17) {
|
|
14210
|
+
return !!this.#ignore?.childrenIgnored?.(path17);
|
|
13998
14211
|
}
|
|
13999
14212
|
pause() {
|
|
14000
14213
|
this.paused = true;
|
|
@@ -14211,8 +14424,8 @@ var init_walker = __esm(() => {
|
|
|
14211
14424
|
init_processor();
|
|
14212
14425
|
GlobWalker = class GlobWalker extends GlobUtil {
|
|
14213
14426
|
matches = new Set;
|
|
14214
|
-
constructor(patterns,
|
|
14215
|
-
super(patterns,
|
|
14427
|
+
constructor(patterns, path17, opts) {
|
|
14428
|
+
super(patterns, path17, opts);
|
|
14216
14429
|
}
|
|
14217
14430
|
matchEmit(e) {
|
|
14218
14431
|
this.matches.add(e);
|
|
@@ -14249,8 +14462,8 @@ var init_walker = __esm(() => {
|
|
|
14249
14462
|
};
|
|
14250
14463
|
GlobStream = class GlobStream extends GlobUtil {
|
|
14251
14464
|
results;
|
|
14252
|
-
constructor(patterns,
|
|
14253
|
-
super(patterns,
|
|
14465
|
+
constructor(patterns, path17, opts) {
|
|
14466
|
+
super(patterns, path17, opts);
|
|
14254
14467
|
this.results = new Minipass({
|
|
14255
14468
|
signal: this.signal,
|
|
14256
14469
|
objectMode: true
|
|
@@ -14678,20 +14891,20 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14678
14891
|
var throwError = (message, Ctor) => {
|
|
14679
14892
|
throw new Ctor(message);
|
|
14680
14893
|
};
|
|
14681
|
-
var checkPath = (
|
|
14682
|
-
if (!isString(
|
|
14894
|
+
var checkPath = (path17, originalPath, doThrow) => {
|
|
14895
|
+
if (!isString(path17)) {
|
|
14683
14896
|
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
14684
14897
|
}
|
|
14685
|
-
if (!
|
|
14898
|
+
if (!path17) {
|
|
14686
14899
|
return doThrow(`path must not be empty`, TypeError);
|
|
14687
14900
|
}
|
|
14688
|
-
if (checkPath.isNotRelative(
|
|
14901
|
+
if (checkPath.isNotRelative(path17)) {
|
|
14689
14902
|
const r2 = "`path.relative()`d";
|
|
14690
14903
|
return doThrow(`path should be a ${r2} string, but got "${originalPath}"`, RangeError);
|
|
14691
14904
|
}
|
|
14692
14905
|
return true;
|
|
14693
14906
|
};
|
|
14694
|
-
var isNotRelative = (
|
|
14907
|
+
var isNotRelative = (path17) => REGEX_TEST_INVALID_PATH.test(path17);
|
|
14695
14908
|
checkPath.isNotRelative = isNotRelative;
|
|
14696
14909
|
checkPath.convert = (p) => p;
|
|
14697
14910
|
|
|
@@ -14734,7 +14947,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14734
14947
|
addPattern(pattern) {
|
|
14735
14948
|
return this.add(pattern);
|
|
14736
14949
|
}
|
|
14737
|
-
_testOne(
|
|
14950
|
+
_testOne(path17, checkUnignored) {
|
|
14738
14951
|
let ignored = false;
|
|
14739
14952
|
let unignored = false;
|
|
14740
14953
|
this._rules.forEach((rule) => {
|
|
@@ -14742,7 +14955,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14742
14955
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
14743
14956
|
return;
|
|
14744
14957
|
}
|
|
14745
|
-
const matched = rule.regex.test(
|
|
14958
|
+
const matched = rule.regex.test(path17);
|
|
14746
14959
|
if (matched) {
|
|
14747
14960
|
ignored = !negative;
|
|
14748
14961
|
unignored = negative;
|
|
@@ -14754,39 +14967,39 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14754
14967
|
};
|
|
14755
14968
|
}
|
|
14756
14969
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
14757
|
-
const
|
|
14758
|
-
checkPath(
|
|
14759
|
-
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);
|
|
14760
14973
|
}
|
|
14761
|
-
_t(
|
|
14762
|
-
if (
|
|
14763
|
-
return cache[
|
|
14974
|
+
_t(path17, cache, checkUnignored, slices) {
|
|
14975
|
+
if (path17 in cache) {
|
|
14976
|
+
return cache[path17];
|
|
14764
14977
|
}
|
|
14765
14978
|
if (!slices) {
|
|
14766
|
-
slices =
|
|
14979
|
+
slices = path17.split(SLASH);
|
|
14767
14980
|
}
|
|
14768
14981
|
slices.pop();
|
|
14769
14982
|
if (!slices.length) {
|
|
14770
|
-
return cache[
|
|
14983
|
+
return cache[path17] = this._testOne(path17, checkUnignored);
|
|
14771
14984
|
}
|
|
14772
14985
|
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
14773
|
-
return cache[
|
|
14986
|
+
return cache[path17] = parent.ignored ? parent : this._testOne(path17, checkUnignored);
|
|
14774
14987
|
}
|
|
14775
|
-
ignores(
|
|
14776
|
-
return this._test(
|
|
14988
|
+
ignores(path17) {
|
|
14989
|
+
return this._test(path17, this._ignoreCache, false).ignored;
|
|
14777
14990
|
}
|
|
14778
14991
|
createFilter() {
|
|
14779
|
-
return (
|
|
14992
|
+
return (path17) => !this.ignores(path17);
|
|
14780
14993
|
}
|
|
14781
14994
|
filter(paths) {
|
|
14782
14995
|
return makeArray(paths).filter(this.createFilter());
|
|
14783
14996
|
}
|
|
14784
|
-
test(
|
|
14785
|
-
return this._test(
|
|
14997
|
+
test(path17) {
|
|
14998
|
+
return this._test(path17, this._testCache, true);
|
|
14786
14999
|
}
|
|
14787
15000
|
}
|
|
14788
15001
|
var factory = (options) => new Ignore2(options);
|
|
14789
|
-
var isPathValid = (
|
|
15002
|
+
var isPathValid = (path17) => checkPath(path17 && checkPath.convert(path17), path17, RETURN_FALSE);
|
|
14790
15003
|
factory.isPathValid = isPathValid;
|
|
14791
15004
|
factory.default = factory;
|
|
14792
15005
|
module.exports = factory;
|
|
@@ -14794,7 +15007,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14794
15007
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
14795
15008
|
checkPath.convert = makePosix;
|
|
14796
15009
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
14797
|
-
checkPath.isNotRelative = (
|
|
15010
|
+
checkPath.isNotRelative = (path17) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path17) || isNotRelative(path17);
|
|
14798
15011
|
}
|
|
14799
15012
|
});
|
|
14800
15013
|
|
|
@@ -14856,13 +15069,13 @@ function validatePolicy(policy, opts = {}) {
|
|
|
14856
15069
|
}
|
|
14857
15070
|
}
|
|
14858
15071
|
}
|
|
14859
|
-
function matchesGlob2(
|
|
15072
|
+
function matchesGlob2(path17, pattern) {
|
|
14860
15073
|
let re = regexCache.get(pattern);
|
|
14861
15074
|
if (!re) {
|
|
14862
15075
|
re = globToRegex(pattern);
|
|
14863
15076
|
regexCache.set(pattern, re);
|
|
14864
15077
|
}
|
|
14865
|
-
return re.test(
|
|
15078
|
+
return re.test(path17);
|
|
14866
15079
|
}
|
|
14867
15080
|
var DEFAULT_POLICY, applyPolicy = (filePath, policy) => {
|
|
14868
15081
|
const normalized = filePath.trim();
|
|
@@ -14879,8 +15092,8 @@ var init_capture_policy = __esm(() => {
|
|
|
14879
15092
|
});
|
|
14880
15093
|
|
|
14881
15094
|
// ../../packages/core/dist/services/search/ignore-patterns.js
|
|
14882
|
-
import
|
|
14883
|
-
import
|
|
15095
|
+
import fs12 from "fs/promises";
|
|
15096
|
+
import path17 from "path";
|
|
14884
15097
|
function buildExtensionGlob(extensions2) {
|
|
14885
15098
|
return extensions2.map((ext2) => `**/*${ext2}`);
|
|
14886
15099
|
}
|
|
@@ -14903,8 +15116,8 @@ async function loadProjectIgnore(projectPath) {
|
|
|
14903
15116
|
const ig = ignore();
|
|
14904
15117
|
ig.add(DEFAULT_IGNORES);
|
|
14905
15118
|
try {
|
|
14906
|
-
const gitignorePath =
|
|
14907
|
-
const gitignoreContent = await
|
|
15119
|
+
const gitignorePath = path17.join(projectPath, ".gitignore");
|
|
15120
|
+
const gitignoreContent = await fs12.readFile(gitignorePath, "utf8");
|
|
14908
15121
|
const rules = gitignoreContent.split(`
|
|
14909
15122
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
14910
15123
|
ig.add(rules);
|
|
@@ -15158,8 +15371,8 @@ var init_alias_resolver = __esm(() => {
|
|
|
15158
15371
|
});
|
|
15159
15372
|
|
|
15160
15373
|
// ../../packages/core/dist/services/search/index-manager.js
|
|
15161
|
-
import
|
|
15162
|
-
import
|
|
15374
|
+
import fs13 from "fs";
|
|
15375
|
+
import path18 from "path";
|
|
15163
15376
|
|
|
15164
15377
|
class IndexManager {
|
|
15165
15378
|
metadataCache = new Map;
|
|
@@ -15252,9 +15465,9 @@ class IndexManager {
|
|
|
15252
15465
|
const fileMetadata = {};
|
|
15253
15466
|
let totalSize = 0;
|
|
15254
15467
|
for (const filePath of indexedFiles) {
|
|
15255
|
-
const fullPath =
|
|
15468
|
+
const fullPath = path18.join(projectPath, filePath);
|
|
15256
15469
|
try {
|
|
15257
|
-
const stat2 = await
|
|
15470
|
+
const stat2 = await fs13.promises.stat(fullPath);
|
|
15258
15471
|
fileMetadata[filePath] = {
|
|
15259
15472
|
path: filePath,
|
|
15260
15473
|
mtime: stat2.mtimeMs,
|
|
@@ -15305,9 +15518,9 @@ class IndexManager {
|
|
|
15305
15518
|
if (ig.ignores(match2)) {
|
|
15306
15519
|
continue;
|
|
15307
15520
|
}
|
|
15308
|
-
const fullPath =
|
|
15521
|
+
const fullPath = path18.join(projectPath, match2);
|
|
15309
15522
|
try {
|
|
15310
|
-
const stat2 = await
|
|
15523
|
+
const stat2 = await fs13.promises.stat(fullPath);
|
|
15311
15524
|
files.set(match2, {
|
|
15312
15525
|
path: match2,
|
|
15313
15526
|
mtime: stat2.mtimeMs,
|
|
@@ -15758,10 +15971,10 @@ function mergeDefs(...defs) {
|
|
|
15758
15971
|
function cloneDef(schema) {
|
|
15759
15972
|
return mergeDefs(schema._zod.def);
|
|
15760
15973
|
}
|
|
15761
|
-
function getElementAtPath(obj,
|
|
15762
|
-
if (!
|
|
15974
|
+
function getElementAtPath(obj, path19) {
|
|
15975
|
+
if (!path19)
|
|
15763
15976
|
return obj;
|
|
15764
|
-
return
|
|
15977
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
15765
15978
|
}
|
|
15766
15979
|
function promiseAllObject(promisesObj) {
|
|
15767
15980
|
const keys = Object.keys(promisesObj);
|
|
@@ -16089,11 +16302,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
16089
16302
|
}
|
|
16090
16303
|
return false;
|
|
16091
16304
|
}
|
|
16092
|
-
function prefixIssues(
|
|
16305
|
+
function prefixIssues(path19, issues) {
|
|
16093
16306
|
return issues.map((iss) => {
|
|
16094
16307
|
var _a4;
|
|
16095
16308
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
16096
|
-
iss.path.unshift(
|
|
16309
|
+
iss.path.unshift(path19);
|
|
16097
16310
|
return iss;
|
|
16098
16311
|
});
|
|
16099
16312
|
}
|
|
@@ -16306,16 +16519,16 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
|
|
|
16306
16519
|
}
|
|
16307
16520
|
function formatError(error, mapper = (issue2) => issue2.message) {
|
|
16308
16521
|
const fieldErrors = { _errors: [] };
|
|
16309
|
-
const processError = (error2,
|
|
16522
|
+
const processError = (error2, path19 = []) => {
|
|
16310
16523
|
for (const issue2 of error2.issues) {
|
|
16311
16524
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
16312
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
16525
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
16313
16526
|
} else if (issue2.code === "invalid_key") {
|
|
16314
|
-
processError({ issues: issue2.issues }, [...
|
|
16527
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16315
16528
|
} else if (issue2.code === "invalid_element") {
|
|
16316
|
-
processError({ issues: issue2.issues }, [...
|
|
16529
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16317
16530
|
} else {
|
|
16318
|
-
const fullpath = [...
|
|
16531
|
+
const fullpath = [...path19, ...issue2.path];
|
|
16319
16532
|
if (fullpath.length === 0) {
|
|
16320
16533
|
fieldErrors._errors.push(mapper(issue2));
|
|
16321
16534
|
} else {
|
|
@@ -16342,17 +16555,17 @@ function formatError(error, mapper = (issue2) => issue2.message) {
|
|
|
16342
16555
|
}
|
|
16343
16556
|
function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
16344
16557
|
const result = { errors: [] };
|
|
16345
|
-
const processError = (error2,
|
|
16558
|
+
const processError = (error2, path19 = []) => {
|
|
16346
16559
|
var _a4, _b;
|
|
16347
16560
|
for (const issue2 of error2.issues) {
|
|
16348
16561
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
16349
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
16562
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
16350
16563
|
} else if (issue2.code === "invalid_key") {
|
|
16351
|
-
processError({ issues: issue2.issues }, [...
|
|
16564
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16352
16565
|
} else if (issue2.code === "invalid_element") {
|
|
16353
|
-
processError({ issues: issue2.issues }, [...
|
|
16566
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16354
16567
|
} else {
|
|
16355
|
-
const fullpath = [...
|
|
16568
|
+
const fullpath = [...path19, ...issue2.path];
|
|
16356
16569
|
if (fullpath.length === 0) {
|
|
16357
16570
|
result.errors.push(mapper(issue2));
|
|
16358
16571
|
continue;
|
|
@@ -16384,8 +16597,8 @@ function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
|
16384
16597
|
}
|
|
16385
16598
|
function toDotPath(_path) {
|
|
16386
16599
|
const segs = [];
|
|
16387
|
-
const
|
|
16388
|
-
for (const seg of
|
|
16600
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
16601
|
+
for (const seg of path19) {
|
|
16389
16602
|
if (typeof seg === "number")
|
|
16390
16603
|
segs.push(`[${seg}]`);
|
|
16391
16604
|
else if (typeof seg === "symbol")
|
|
@@ -29388,13 +29601,13 @@ function resolveRef(ref, ctx) {
|
|
|
29388
29601
|
if (!ref.startsWith("#")) {
|
|
29389
29602
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
29390
29603
|
}
|
|
29391
|
-
const
|
|
29392
|
-
if (
|
|
29604
|
+
const path19 = ref.slice(1).split("/").filter(Boolean);
|
|
29605
|
+
if (path19.length === 0) {
|
|
29393
29606
|
return ctx.rootSchema;
|
|
29394
29607
|
}
|
|
29395
29608
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
29396
|
-
if (
|
|
29397
|
-
const key =
|
|
29609
|
+
if (path19[0] === defsKey) {
|
|
29610
|
+
const key = path19[1];
|
|
29398
29611
|
if (!key || !ctx.defs[key]) {
|
|
29399
29612
|
throw new Error(`Reference not found: ${ref}`);
|
|
29400
29613
|
}
|
|
@@ -30883,8 +31096,8 @@ class ParseStatus2 {
|
|
|
30883
31096
|
}
|
|
30884
31097
|
}
|
|
30885
31098
|
var makeIssue2 = (params) => {
|
|
30886
|
-
const { data, path:
|
|
30887
|
-
const fullPath = [...
|
|
31099
|
+
const { data, path: path19, errorMaps, issueData } = params;
|
|
31100
|
+
const fullPath = [...path19, ...issueData.path || []];
|
|
30888
31101
|
const fullIssue = {
|
|
30889
31102
|
...issueData,
|
|
30890
31103
|
path: fullPath
|
|
@@ -30929,11 +31142,11 @@ var init_errorUtil = __esm(() => {
|
|
|
30929
31142
|
|
|
30930
31143
|
// ../../node_modules/zod/v3/types.js
|
|
30931
31144
|
class ParseInputLazyPath2 {
|
|
30932
|
-
constructor(parent, value,
|
|
31145
|
+
constructor(parent, value, path19, key) {
|
|
30933
31146
|
this._cachedPath = [];
|
|
30934
31147
|
this.parent = parent;
|
|
30935
31148
|
this.data = value;
|
|
30936
|
-
this._path =
|
|
31149
|
+
this._path = path19;
|
|
30937
31150
|
this._key = key;
|
|
30938
31151
|
}
|
|
30939
31152
|
get path() {
|
|
@@ -36998,23 +37211,23 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
36998
37211
|
writeAuthConfig: () => writeAuthConfig
|
|
36999
37212
|
});
|
|
37000
37213
|
module.exports = __toCommonJS2(auth_config_exports);
|
|
37001
|
-
var
|
|
37002
|
-
var
|
|
37214
|
+
var fs14 = __toESM2(__require("fs"));
|
|
37215
|
+
var path19 = __toESM2(__require("path"));
|
|
37003
37216
|
var import_token_util = require_token_util();
|
|
37004
37217
|
function getAuthConfigPath() {
|
|
37005
37218
|
const dataDir = (0, import_token_util.getVercelDataDir)();
|
|
37006
37219
|
if (!dataDir) {
|
|
37007
37220
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
37008
37221
|
}
|
|
37009
|
-
return
|
|
37222
|
+
return path19.join(dataDir, "auth.json");
|
|
37010
37223
|
}
|
|
37011
37224
|
function readAuthConfig() {
|
|
37012
37225
|
try {
|
|
37013
37226
|
const authPath = getAuthConfigPath();
|
|
37014
|
-
if (!
|
|
37227
|
+
if (!fs14.existsSync(authPath)) {
|
|
37015
37228
|
return null;
|
|
37016
37229
|
}
|
|
37017
|
-
const content =
|
|
37230
|
+
const content = fs14.readFileSync(authPath, "utf8");
|
|
37018
37231
|
if (!content) {
|
|
37019
37232
|
return null;
|
|
37020
37233
|
}
|
|
@@ -37025,11 +37238,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
37025
37238
|
}
|
|
37026
37239
|
function writeAuthConfig(config3) {
|
|
37027
37240
|
const authPath = getAuthConfigPath();
|
|
37028
|
-
const authDir =
|
|
37029
|
-
if (!
|
|
37030
|
-
|
|
37241
|
+
const authDir = path19.dirname(authPath);
|
|
37242
|
+
if (!fs14.existsSync(authDir)) {
|
|
37243
|
+
fs14.mkdirSync(authDir, { mode: 504, recursive: true });
|
|
37031
37244
|
}
|
|
37032
|
-
|
|
37245
|
+
fs14.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
|
|
37033
37246
|
}
|
|
37034
37247
|
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
37035
37248
|
if (!authConfig.token)
|
|
@@ -37204,8 +37417,8 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37204
37417
|
saveToken: () => saveToken
|
|
37205
37418
|
});
|
|
37206
37419
|
module.exports = __toCommonJS2(token_util_exports);
|
|
37207
|
-
var
|
|
37208
|
-
var
|
|
37420
|
+
var path19 = __toESM2(__require("path"));
|
|
37421
|
+
var fs14 = __toESM2(__require("fs"));
|
|
37209
37422
|
var import_token_error = require_token_error();
|
|
37210
37423
|
var import_token_io = require_token_io();
|
|
37211
37424
|
var import_auth_config = require_auth_config();
|
|
@@ -37217,7 +37430,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37217
37430
|
if (!dataDir) {
|
|
37218
37431
|
return null;
|
|
37219
37432
|
}
|
|
37220
|
-
return
|
|
37433
|
+
return path19.join(dataDir, vercelFolder);
|
|
37221
37434
|
}
|
|
37222
37435
|
async function getVercelToken2(options) {
|
|
37223
37436
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -37285,11 +37498,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37285
37498
|
if (!dir) {
|
|
37286
37499
|
throw new import_token_error.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");
|
|
37287
37500
|
}
|
|
37288
|
-
const prjPath =
|
|
37289
|
-
if (!
|
|
37501
|
+
const prjPath = path19.join(dir, ".vercel", "project.json");
|
|
37502
|
+
if (!fs14.existsSync(prjPath)) {
|
|
37290
37503
|
throw new import_token_error.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");
|
|
37291
37504
|
}
|
|
37292
|
-
const prj = JSON.parse(
|
|
37505
|
+
const prj = JSON.parse(fs14.readFileSync(prjPath, "utf8"));
|
|
37293
37506
|
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
|
|
37294
37507
|
throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");
|
|
37295
37508
|
}
|
|
@@ -37300,11 +37513,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37300
37513
|
if (!dir) {
|
|
37301
37514
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
37302
37515
|
}
|
|
37303
|
-
const tokenPath =
|
|
37516
|
+
const tokenPath = path19.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
37304
37517
|
const tokenJson = JSON.stringify(token);
|
|
37305
|
-
|
|
37306
|
-
|
|
37307
|
-
|
|
37518
|
+
fs14.mkdirSync(path19.dirname(tokenPath), { mode: 504, recursive: true });
|
|
37519
|
+
fs14.writeFileSync(tokenPath, tokenJson);
|
|
37520
|
+
fs14.chmodSync(tokenPath, 432);
|
|
37308
37521
|
return;
|
|
37309
37522
|
}
|
|
37310
37523
|
function loadToken(projectId) {
|
|
@@ -37312,11 +37525,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37312
37525
|
if (!dir) {
|
|
37313
37526
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
37314
37527
|
}
|
|
37315
|
-
const tokenPath =
|
|
37316
|
-
if (!
|
|
37528
|
+
const tokenPath = path19.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
37529
|
+
if (!fs14.existsSync(tokenPath)) {
|
|
37317
37530
|
return null;
|
|
37318
37531
|
}
|
|
37319
|
-
const token = JSON.parse(
|
|
37532
|
+
const token = JSON.parse(fs14.readFileSync(tokenPath, "utf8"));
|
|
37320
37533
|
assertVercelOidcTokenResponse(token);
|
|
37321
37534
|
return token;
|
|
37322
37535
|
}
|
|
@@ -48158,37 +48371,37 @@ function createOpenAI(options = {}) {
|
|
|
48158
48371
|
}, `ai-sdk/openai/${VERSION4}`);
|
|
48159
48372
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
48160
48373
|
provider: `${providerName}.chat`,
|
|
48161
|
-
url: ({ path:
|
|
48374
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48162
48375
|
headers: getHeaders,
|
|
48163
48376
|
fetch: options.fetch
|
|
48164
48377
|
});
|
|
48165
48378
|
const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
|
|
48166
48379
|
provider: `${providerName}.completion`,
|
|
48167
|
-
url: ({ path:
|
|
48380
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48168
48381
|
headers: getHeaders,
|
|
48169
48382
|
fetch: options.fetch
|
|
48170
48383
|
});
|
|
48171
48384
|
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
48172
48385
|
provider: `${providerName}.embedding`,
|
|
48173
|
-
url: ({ path:
|
|
48386
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48174
48387
|
headers: getHeaders,
|
|
48175
48388
|
fetch: options.fetch
|
|
48176
48389
|
});
|
|
48177
48390
|
const createImageModel = (modelId) => new OpenAIImageModel(modelId, {
|
|
48178
48391
|
provider: `${providerName}.image`,
|
|
48179
|
-
url: ({ path:
|
|
48392
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48180
48393
|
headers: getHeaders,
|
|
48181
48394
|
fetch: options.fetch
|
|
48182
48395
|
});
|
|
48183
48396
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
48184
48397
|
provider: `${providerName}.transcription`,
|
|
48185
|
-
url: ({ path:
|
|
48398
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48186
48399
|
headers: getHeaders,
|
|
48187
48400
|
fetch: options.fetch
|
|
48188
48401
|
});
|
|
48189
48402
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
48190
48403
|
provider: `${providerName}.speech`,
|
|
48191
|
-
url: ({ path:
|
|
48404
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48192
48405
|
headers: getHeaders,
|
|
48193
48406
|
fetch: options.fetch
|
|
48194
48407
|
});
|
|
@@ -48201,7 +48414,7 @@ function createOpenAI(options = {}) {
|
|
|
48201
48414
|
const createResponsesModel = (modelId) => {
|
|
48202
48415
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
48203
48416
|
provider: `${providerName}.responses`,
|
|
48204
|
-
url: ({ path:
|
|
48417
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48205
48418
|
headers: getHeaders,
|
|
48206
48419
|
fetch: options.fetch,
|
|
48207
48420
|
fileIdPrefixes: ["file-"]
|
|
@@ -64813,26 +65026,26 @@ var require_process = __commonJS((exports, module) => {
|
|
|
64813
65026
|
|
|
64814
65027
|
// ../../node_modules/detect-libc/lib/filesystem.js
|
|
64815
65028
|
var require_filesystem = __commonJS((exports, module) => {
|
|
64816
|
-
var
|
|
65029
|
+
var fs14 = __require("fs");
|
|
64817
65030
|
var LDD_PATH = "/usr/bin/ldd";
|
|
64818
65031
|
var SELF_PATH = "/proc/self/exe";
|
|
64819
65032
|
var MAX_LENGTH = 2048;
|
|
64820
|
-
var readFileSync2 = (
|
|
64821
|
-
const fd =
|
|
65033
|
+
var readFileSync2 = (path19) => {
|
|
65034
|
+
const fd = fs14.openSync(path19, "r");
|
|
64822
65035
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
64823
|
-
const bytesRead =
|
|
64824
|
-
|
|
65036
|
+
const bytesRead = fs14.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
65037
|
+
fs14.close(fd, () => {});
|
|
64825
65038
|
return buffer.subarray(0, bytesRead);
|
|
64826
65039
|
};
|
|
64827
|
-
var readFile = (
|
|
64828
|
-
|
|
65040
|
+
var readFile = (path19) => new Promise((resolve4, reject) => {
|
|
65041
|
+
fs14.open(path19, "r", (err, fd) => {
|
|
64829
65042
|
if (err) {
|
|
64830
65043
|
reject(err);
|
|
64831
65044
|
} else {
|
|
64832
65045
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
64833
|
-
|
|
65046
|
+
fs14.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
|
|
64834
65047
|
resolve4(buffer.subarray(0, bytesRead));
|
|
64835
|
-
|
|
65048
|
+
fs14.close(fd, () => {});
|
|
64836
65049
|
});
|
|
64837
65050
|
}
|
|
64838
65051
|
});
|
|
@@ -64937,11 +65150,11 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
64937
65150
|
}
|
|
64938
65151
|
return null;
|
|
64939
65152
|
};
|
|
64940
|
-
var familyFromInterpreterPath = (
|
|
64941
|
-
if (
|
|
64942
|
-
if (
|
|
65153
|
+
var familyFromInterpreterPath = (path19) => {
|
|
65154
|
+
if (path19) {
|
|
65155
|
+
if (path19.includes("/ld-musl-")) {
|
|
64943
65156
|
return MUSL;
|
|
64944
|
-
} else if (
|
|
65157
|
+
} else if (path19.includes("/ld-linux-")) {
|
|
64945
65158
|
return GLIBC;
|
|
64946
65159
|
}
|
|
64947
65160
|
}
|
|
@@ -64986,8 +65199,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
64986
65199
|
cachedFamilyInterpreter = null;
|
|
64987
65200
|
try {
|
|
64988
65201
|
const selfContent = await readFile(SELF_PATH);
|
|
64989
|
-
const
|
|
64990
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
65202
|
+
const path19 = interpreterPath(selfContent);
|
|
65203
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path19);
|
|
64991
65204
|
} catch (e) {}
|
|
64992
65205
|
return cachedFamilyInterpreter;
|
|
64993
65206
|
};
|
|
@@ -64998,8 +65211,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
64998
65211
|
cachedFamilyInterpreter = null;
|
|
64999
65212
|
try {
|
|
65000
65213
|
const selfContent = readFileSync2(SELF_PATH);
|
|
65001
|
-
const
|
|
65002
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
65214
|
+
const path19 = interpreterPath(selfContent);
|
|
65215
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path19);
|
|
65003
65216
|
} catch (e) {}
|
|
65004
65217
|
return cachedFamilyInterpreter;
|
|
65005
65218
|
};
|
|
@@ -66661,18 +66874,18 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
66661
66874
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
66662
66875
|
"@img/sharp-wasm32/sharp.node"
|
|
66663
66876
|
];
|
|
66664
|
-
var
|
|
66877
|
+
var path19;
|
|
66665
66878
|
var sharp;
|
|
66666
66879
|
var errors5 = [];
|
|
66667
|
-
for (
|
|
66880
|
+
for (path19 of paths) {
|
|
66668
66881
|
try {
|
|
66669
|
-
sharp = __require(
|
|
66882
|
+
sharp = __require(path19);
|
|
66670
66883
|
break;
|
|
66671
66884
|
} catch (err) {
|
|
66672
66885
|
errors5.push(err);
|
|
66673
66886
|
}
|
|
66674
66887
|
}
|
|
66675
|
-
if (sharp &&
|
|
66888
|
+
if (sharp && path19.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
66676
66889
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
66677
66890
|
err.code = "Unsupported CPU";
|
|
66678
66891
|
errors5.push(err);
|
|
@@ -66681,7 +66894,7 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
66681
66894
|
if (sharp) {
|
|
66682
66895
|
module.exports = sharp;
|
|
66683
66896
|
} else {
|
|
66684
|
-
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((
|
|
66897
|
+
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((os9) => runtimePlatform.startsWith(os9));
|
|
66685
66898
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
66686
66899
|
errors5.forEach((err) => {
|
|
66687
66900
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -66694,9 +66907,9 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
66694
66907
|
const { found, expected } = isUnsupportedNodeRuntime();
|
|
66695
66908
|
help.push("- Please upgrade Node.js:", ` Found ${found}`, ` Requires ${expected}`);
|
|
66696
66909
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
66697
|
-
const [
|
|
66698
|
-
const libc =
|
|
66699
|
-
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`);
|
|
66700
66913
|
} else {
|
|
66701
66914
|
help.push(`- Manually install libvips >= ${minimumLibvipsVersion}`, "- Add experimental WebAssembly-based dependencies:", " npm install --cpu=wasm32 sharp", " npm install @img/sharp-wasm32");
|
|
66702
66915
|
}
|
|
@@ -69534,15 +69747,15 @@ var require_color = __commonJS((exports, module) => {
|
|
|
69534
69747
|
};
|
|
69535
69748
|
}
|
|
69536
69749
|
function wrapConversion(toModel, graph) {
|
|
69537
|
-
const
|
|
69750
|
+
const path19 = [graph[toModel].parent, toModel];
|
|
69538
69751
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
69539
69752
|
let cur = graph[toModel].parent;
|
|
69540
69753
|
while (graph[cur].parent) {
|
|
69541
|
-
|
|
69754
|
+
path19.unshift(graph[cur].parent);
|
|
69542
69755
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
69543
69756
|
cur = graph[cur].parent;
|
|
69544
69757
|
}
|
|
69545
|
-
fn.conversion =
|
|
69758
|
+
fn.conversion = path19;
|
|
69546
69759
|
return fn;
|
|
69547
69760
|
}
|
|
69548
69761
|
function route(fromModel) {
|
|
@@ -70147,7 +70360,7 @@ var require_output = __commonJS((exports, module) => {
|
|
|
70147
70360
|
Copyright 2013 Lovell Fuller and others.
|
|
70148
70361
|
SPDX-License-Identifier: Apache-2.0
|
|
70149
70362
|
*/
|
|
70150
|
-
var
|
|
70363
|
+
var path19 = __require("path");
|
|
70151
70364
|
var is = require_is();
|
|
70152
70365
|
var sharp = require_sharp();
|
|
70153
70366
|
var formats = new Map([
|
|
@@ -70178,9 +70391,9 @@ var require_output = __commonJS((exports, module) => {
|
|
|
70178
70391
|
let err;
|
|
70179
70392
|
if (!is.string(fileOut)) {
|
|
70180
70393
|
err = new Error("Missing output file path");
|
|
70181
|
-
} 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)) {
|
|
70182
70395
|
err = new Error("Cannot use same file for input and output");
|
|
70183
|
-
} else if (jp2Regex.test(
|
|
70396
|
+
} else if (jp2Regex.test(path19.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
70184
70397
|
err = errJp2Save();
|
|
70185
70398
|
}
|
|
70186
70399
|
if (err) {
|
|
@@ -77427,11 +77640,11 @@ var init_transformers_node = __esm(() => {
|
|
|
77427
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}).`);
|
|
77428
77641
|
}
|
|
77429
77642
|
for (let i = 0;i < num_chunks; ++i) {
|
|
77430
|
-
const
|
|
77431
|
-
const fullPath = `${options.subfolder ?? ""}/${
|
|
77643
|
+
const path19 = `${baseName}_data${i === 0 ? "" : "_" + i}`;
|
|
77644
|
+
const fullPath = `${options.subfolder ?? ""}/${path19}`;
|
|
77432
77645
|
externalDataPromises.push(new Promise(async (resolve4, reject) => {
|
|
77433
77646
|
const data = await (0, _utils_hub_js__WEBPACK_IMPORTED_MODULE_5__.getModelFile)(pretrained_model_name_or_path, fullPath, true, options, return_path);
|
|
77434
|
-
resolve4(data instanceof Uint8Array ? { path:
|
|
77647
|
+
resolve4(data instanceof Uint8Array ? { path: path19, data } : path19);
|
|
77435
77648
|
}));
|
|
77436
77649
|
}
|
|
77437
77650
|
} else if (session_options.externalData !== undefined) {
|
|
@@ -90495,7 +90708,7 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90495
90708
|
const blob = new Blob([wav], { type: "audio/wav" });
|
|
90496
90709
|
return blob;
|
|
90497
90710
|
}
|
|
90498
|
-
async save(
|
|
90711
|
+
async save(path19) {
|
|
90499
90712
|
let fn;
|
|
90500
90713
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_BROWSER_ENV) {
|
|
90501
90714
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_WEBWORKER_ENV) {
|
|
@@ -90503,14 +90716,14 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90503
90716
|
}
|
|
90504
90717
|
fn = _core_js__WEBPACK_IMPORTED_MODULE_2__.saveBlob;
|
|
90505
90718
|
} else if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_FS_AVAILABLE) {
|
|
90506
|
-
fn = async (
|
|
90719
|
+
fn = async (path20, blob) => {
|
|
90507
90720
|
let buffer = await blob.arrayBuffer();
|
|
90508
|
-
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(
|
|
90721
|
+
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(path20, Buffer.from(buffer));
|
|
90509
90722
|
};
|
|
90510
90723
|
} else {
|
|
90511
90724
|
throw new Error("Unable to save because filesystem is disabled in this environment.");
|
|
90512
90725
|
}
|
|
90513
|
-
await fn(
|
|
90726
|
+
await fn(path19, this.toBlob());
|
|
90514
90727
|
}
|
|
90515
90728
|
}
|
|
90516
90729
|
},
|
|
@@ -90606,11 +90819,11 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90606
90819
|
function calculateReflectOffset(i, w) {
|
|
90607
90820
|
return Math.abs((i + w) % (2 * w) - w);
|
|
90608
90821
|
}
|
|
90609
|
-
function saveBlob(
|
|
90822
|
+
function saveBlob(path19, blob) {
|
|
90610
90823
|
const dataURL = URL.createObjectURL(blob);
|
|
90611
90824
|
const downloadLink = document.createElement("a");
|
|
90612
90825
|
downloadLink.href = dataURL;
|
|
90613
|
-
downloadLink.download =
|
|
90826
|
+
downloadLink.download = path19;
|
|
90614
90827
|
downloadLink.click();
|
|
90615
90828
|
downloadLink.remove();
|
|
90616
90829
|
URL.revokeObjectURL(dataURL);
|
|
@@ -91211,8 +91424,8 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
91211
91424
|
}
|
|
91212
91425
|
|
|
91213
91426
|
class FileCache {
|
|
91214
|
-
constructor(
|
|
91215
|
-
this.path =
|
|
91427
|
+
constructor(path19) {
|
|
91428
|
+
this.path = path19;
|
|
91216
91429
|
}
|
|
91217
91430
|
async match(request) {
|
|
91218
91431
|
let filePath = node_path__WEBPACK_IMPORTED_MODULE_1__["default"].join(this.path, request);
|
|
@@ -91968,20 +92181,20 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
91968
92181
|
}
|
|
91969
92182
|
return this;
|
|
91970
92183
|
}
|
|
91971
|
-
async save(
|
|
92184
|
+
async save(path19) {
|
|
91972
92185
|
if (IS_BROWSER_OR_WEBWORKER) {
|
|
91973
92186
|
if (_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_WEBWORKER_ENV) {
|
|
91974
92187
|
throw new Error("Unable to save an image from a Web Worker.");
|
|
91975
92188
|
}
|
|
91976
|
-
const extension =
|
|
92189
|
+
const extension = path19.split(".").pop().toLowerCase();
|
|
91977
92190
|
const mime2 = CONTENT_TYPE_MAP.get(extension) ?? "image/png";
|
|
91978
92191
|
const blob = await this.toBlob(mime2);
|
|
91979
|
-
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(
|
|
92192
|
+
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(path19, blob);
|
|
91980
92193
|
} else if (!_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_FS_AVAILABLE) {
|
|
91981
92194
|
throw new Error("Unable to save the image because filesystem is disabled in this environment.");
|
|
91982
92195
|
} else {
|
|
91983
92196
|
const img = this.toSharp();
|
|
91984
|
-
return await img.toFile(
|
|
92197
|
+
return await img.toFile(path19);
|
|
91985
92198
|
}
|
|
91986
92199
|
}
|
|
91987
92200
|
toSharp() {
|
|
@@ -101210,7 +101423,7 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a12;
|
|
|
101210
101423
|
function ns(e = Yo, t2 = Yo) {
|
|
101211
101424
|
return (r2) => e(t2(r2));
|
|
101212
101425
|
}
|
|
101213
|
-
function
|
|
101426
|
+
function os9({ dataPath: e, modelName: t2, args: r2, runtimeDataModel: n2 }) {
|
|
101214
101427
|
let i = { modelName: t2, args: r2 ?? {} }, o = dp(e);
|
|
101215
101428
|
if (!o || o.length === 0)
|
|
101216
101429
|
return i;
|
|
@@ -101515,10 +101728,10 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a12;
|
|
|
101515
101728
|
super(t2, "P2023", r2);
|
|
101516
101729
|
}
|
|
101517
101730
|
};
|
|
101518
|
-
var
|
|
101731
|
+
var fs14 = new WeakMap;
|
|
101519
101732
|
function Ep(e) {
|
|
101520
|
-
let t2 =
|
|
101521
|
-
return t2 || (t2 = Object.entries(e),
|
|
101733
|
+
let t2 = fs14.get(e);
|
|
101734
|
+
return t2 || (t2 = Object.entries(e), fs14.set(e, t2)), t2;
|
|
101522
101735
|
}
|
|
101523
101736
|
function hs(e, t2, r2) {
|
|
101524
101737
|
switch (t2.type) {
|
|
@@ -105083,7 +105296,7 @@ new PrismaClient({
|
|
|
105083
105296
|
let m2 = await es(this, d);
|
|
105084
105297
|
if (!d.model)
|
|
105085
105298
|
return m2;
|
|
105086
|
-
let g =
|
|
105299
|
+
let g = os9({ dataPath: d.dataPath, modelName: d.model, args: d.args, runtimeDataModel: this._runtimeDataModel });
|
|
105087
105300
|
return Wo({ result: m2, modelName: g.modelName, args: g.args, extensions: this._extensions, runtimeDataModel: this._runtimeDataModel, globalOmit: this._globalOmit });
|
|
105088
105301
|
};
|
|
105089
105302
|
return this._tracingHelper.runInChildSpan(s.operation, () => new zl.AsyncResource("prisma-client-request").runInAsyncScope(() => a12(o)));
|
|
@@ -105486,7 +105699,7 @@ var require_prisma = __commonJS((exports) => {
|
|
|
105486
105699
|
Prisma.JsonNull = JsonNull2;
|
|
105487
105700
|
Prisma.AnyNull = AnyNull2;
|
|
105488
105701
|
Prisma.NullTypes = NullTypes2;
|
|
105489
|
-
var
|
|
105702
|
+
var path19 = __require("path");
|
|
105490
105703
|
exports.Prisma.TransactionIsolationLevel = makeStrictEnum2({
|
|
105491
105704
|
ReadUncommitted: "ReadUncommitted",
|
|
105492
105705
|
ReadCommitted: "ReadCommitted",
|
|
@@ -115819,10 +116032,10 @@ var init_chunker_code = __esm(() => {
|
|
|
115819
116032
|
});
|
|
115820
116033
|
|
|
115821
116034
|
// ../../packages/core/dist/services/search/smart-chunker.js
|
|
115822
|
-
import
|
|
116035
|
+
import path19 from "path";
|
|
115823
116036
|
function smartChunk(content, filePath, config3 = {}) {
|
|
115824
116037
|
const cfg = { ...DEFAULT_CONFIG, ...config3 };
|
|
115825
|
-
const ext2 =
|
|
116038
|
+
const ext2 = path19.extname(filePath).toLowerCase();
|
|
115826
116039
|
const relativePath = filePath;
|
|
115827
116040
|
const fileImports = isCodeFile(ext2) ? extractFileImports(content, ext2) : undefined;
|
|
115828
116041
|
let chunks;
|
|
@@ -116160,8 +116373,8 @@ var init_embedding_freshness = __esm(() => {
|
|
|
116160
116373
|
});
|
|
116161
116374
|
|
|
116162
116375
|
// ../../packages/core/dist/services/search/project-indexer.js
|
|
116163
|
-
import
|
|
116164
|
-
import
|
|
116376
|
+
import fs14 from "fs/promises";
|
|
116377
|
+
import path20 from "path";
|
|
116165
116378
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
116166
116379
|
async function runWithIndexLock(lockMap, projectId, work) {
|
|
116167
116380
|
const prevLock = lockMap.get(projectId);
|
|
@@ -116204,7 +116417,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
116204
116417
|
dot: false
|
|
116205
116418
|
});
|
|
116206
116419
|
const filteredFiles = files.filter((file3) => {
|
|
116207
|
-
const relativePath =
|
|
116420
|
+
const relativePath = path20.relative(projectPath, file3);
|
|
116208
116421
|
const shouldIgnore = ig.ignores(relativePath);
|
|
116209
116422
|
if (shouldIgnore) {
|
|
116210
116423
|
logger.debug("Ignoring file per .gitignore during indexing", {
|
|
@@ -116244,7 +116457,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
116244
116457
|
});
|
|
116245
116458
|
}
|
|
116246
116459
|
}
|
|
116247
|
-
const indexedFilesList = filteredFiles.map((f) =>
|
|
116460
|
+
const indexedFilesList = filteredFiles.map((f) => path20.relative(projectPath, f));
|
|
116248
116461
|
await deps.indexManager.updateIndexMetadata(projectId, projectPath, indexedFilesList);
|
|
116249
116462
|
logger.info("Project indexing completed", {
|
|
116250
116463
|
projectId,
|
|
@@ -116374,7 +116587,7 @@ async function ensureFreshIndex(deps, projectId, projectPath, options = {}) {
|
|
|
116374
116587
|
let errors5 = 0;
|
|
116375
116588
|
for (const relativeFilePath of filesToReindex) {
|
|
116376
116589
|
try {
|
|
116377
|
-
const fullPath =
|
|
116590
|
+
const fullPath = path20.join(projectPath, relativeFilePath);
|
|
116378
116591
|
const result = await deps.indexFile(fullPath, projectId, projectPath, centralityMap);
|
|
116379
116592
|
filesIndexed++;
|
|
116380
116593
|
chunksIndexed += result.chunks;
|
|
@@ -116434,8 +116647,8 @@ async function checkSearchAdmission(deps, projectId, projectPath) {
|
|
|
116434
116647
|
}
|
|
116435
116648
|
async function indexFile(deps, filePath, projectId, projectRoot, centralityMap) {
|
|
116436
116649
|
projectId = await getProjectIdentityAliasResolver().resolve(projectId);
|
|
116437
|
-
const content = await
|
|
116438
|
-
const relativePath =
|
|
116650
|
+
const content = await fs14.readFile(filePath, "utf-8");
|
|
116651
|
+
const relativePath = path20.relative(projectRoot, filePath);
|
|
116439
116652
|
const maxFileSize = config.get("security").maxFileSize || 1024 * 1024;
|
|
116440
116653
|
if (content.length > maxFileSize) {
|
|
116441
116654
|
logger.warn("File too large, skipping", {
|
|
@@ -116455,7 +116668,7 @@ async function indexFile(deps, filePath, projectId, projectRoot, centralityMap)
|
|
|
116455
116668
|
chunkIndex: i,
|
|
116456
116669
|
totalChunks: chunks.length,
|
|
116457
116670
|
type: chunk.type,
|
|
116458
|
-
language:
|
|
116671
|
+
language: path20.extname(filePath).slice(1),
|
|
116459
116672
|
lineStart: chunk.lineStart,
|
|
116460
116673
|
lineEnd: chunk.lineEnd,
|
|
116461
116674
|
label: chunk.label,
|
|
@@ -118520,8 +118733,8 @@ function stripNul(content) {
|
|
|
118520
118733
|
}
|
|
118521
118734
|
|
|
118522
118735
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
118523
|
-
import
|
|
118524
|
-
import
|
|
118736
|
+
import fs15 from "fs/promises";
|
|
118737
|
+
import path21 from "path";
|
|
118525
118738
|
import { createHash as createHash5 } from "crypto";
|
|
118526
118739
|
|
|
118527
118740
|
class DiscoverStage {
|
|
@@ -118547,7 +118760,7 @@ class DiscoverStage {
|
|
|
118547
118760
|
dot: false,
|
|
118548
118761
|
absolute: false
|
|
118549
118762
|
});
|
|
118550
|
-
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");
|
|
118551
118764
|
}
|
|
118552
118765
|
if (ctx.resumeCursor?.path) {
|
|
118553
118766
|
const cursorPath = ctx.resumeCursor.path;
|
|
@@ -118606,10 +118819,10 @@ class DiscoverStage {
|
|
|
118606
118819
|
return discovered;
|
|
118607
118820
|
}
|
|
118608
118821
|
async processFile(ctx, relativePath, forceReindex) {
|
|
118609
|
-
const absolutePath =
|
|
118822
|
+
const absolutePath = path21.join(ctx.projectPath, relativePath);
|
|
118610
118823
|
try {
|
|
118611
|
-
const stat2 = await
|
|
118612
|
-
const content = stripNul(await
|
|
118824
|
+
const stat2 = await fs15.stat(absolutePath);
|
|
118825
|
+
const content = stripNul(await fs15.readFile(absolutePath, "utf-8"));
|
|
118613
118826
|
const contentHash = createHash5("sha256").update(content).digest("hex");
|
|
118614
118827
|
let needsReparse = forceReindex;
|
|
118615
118828
|
if (!forceReindex) {
|
|
@@ -118652,8 +118865,8 @@ class DiscoverStage {
|
|
|
118652
118865
|
ig.add(pattern);
|
|
118653
118866
|
}
|
|
118654
118867
|
try {
|
|
118655
|
-
const gitignorePath =
|
|
118656
|
-
const gitignoreContent = await
|
|
118868
|
+
const gitignorePath = path21.join(projectPath, ".gitignore");
|
|
118869
|
+
const gitignoreContent = await fs15.readFile(gitignorePath, "utf8");
|
|
118657
118870
|
const rules = gitignoreContent.split(`
|
|
118658
118871
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
118659
118872
|
ig.add(rules);
|
|
@@ -120008,8 +120221,8 @@ function rustUseLeaves(node2, source, prefix = []) {
|
|
|
120008
120221
|
}
|
|
120009
120222
|
if (node2.type === "use_wildcard")
|
|
120010
120223
|
return [{ path: [...prefix, "*"], glob: true }];
|
|
120011
|
-
const
|
|
120012
|
-
return
|
|
120224
|
+
const path22 = rustPathSegments(node2, source);
|
|
120225
|
+
return path22.length ? [{ path: [...prefix, ...path22] }] : [];
|
|
120013
120226
|
}
|
|
120014
120227
|
function functionalCaptures(captures, source, family) {
|
|
120015
120228
|
if (family !== "clojure")
|
|
@@ -120981,8 +121194,8 @@ var init_structural_runtime = __esm(() => {
|
|
|
120981
121194
|
});
|
|
120982
121195
|
|
|
120983
121196
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
120984
|
-
import
|
|
120985
|
-
import
|
|
121197
|
+
import path22 from "path";
|
|
121198
|
+
import fs16 from "fs/promises";
|
|
120986
121199
|
function resolveChunkerMaxChars() {
|
|
120987
121200
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
120988
121201
|
if (Number.isFinite(global2) && global2 > 0)
|
|
@@ -121010,8 +121223,8 @@ class ParseStage {
|
|
|
121010
121223
|
const results = new Map;
|
|
121011
121224
|
let processed = 0;
|
|
121012
121225
|
const phases = [
|
|
121013
|
-
files.filter((file3) =>
|
|
121014
|
-
files.filter((file3) =>
|
|
121226
|
+
files.filter((file3) => path22.extname(file3.relativePath).toLowerCase() !== ".h"),
|
|
121227
|
+
files.filter((file3) => path22.extname(file3.relativePath).toLowerCase() === ".h")
|
|
121015
121228
|
];
|
|
121016
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)));
|
|
121017
121230
|
for (const batch of batches) {
|
|
@@ -121049,19 +121262,19 @@ class ParseStage {
|
|
|
121049
121262
|
return files.map((file3) => results.get(file3.relativePath));
|
|
121050
121263
|
}
|
|
121051
121264
|
recordHeaderImporterEvidence(ctx, files, parsedFiles) {
|
|
121052
|
-
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)));
|
|
121053
121266
|
const mutable = {
|
|
121054
121267
|
...ctx.structuralHeaderEvidenceByFile
|
|
121055
121268
|
};
|
|
121056
121269
|
for (const parsed of parsedFiles) {
|
|
121057
|
-
const extension =
|
|
121270
|
+
const extension = path22.extname(parsed.file.relativePath).toLowerCase();
|
|
121058
121271
|
const key = extension === ".c" ? "cImporters" : [".cpp", ".hpp"].includes(extension) ? "cppImporters" : undefined;
|
|
121059
121272
|
if (!key)
|
|
121060
121273
|
continue;
|
|
121061
121274
|
for (const imported of parsed.rawImports) {
|
|
121062
121275
|
if (!["c_include", "cpp_include"].includes(imported.form) || imported.specifier.startsWith("<"))
|
|
121063
121276
|
continue;
|
|
121064
|
-
const header =
|
|
121277
|
+
const header = path22.posix.normalize(path22.posix.join(path22.posix.dirname(parsed.file.relativePath), imported.specifier));
|
|
121065
121278
|
if (!knownHeaders.has(header))
|
|
121066
121279
|
continue;
|
|
121067
121280
|
const existing = mutable[header] ?? {};
|
|
@@ -121072,9 +121285,9 @@ class ParseStage {
|
|
|
121072
121285
|
}
|
|
121073
121286
|
async parseFile(ctx, file3) {
|
|
121074
121287
|
if (!file3.needsReparse) {
|
|
121075
|
-
const extension =
|
|
121288
|
+
const extension = path22.extname(file3.relativePath).toLowerCase();
|
|
121076
121289
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
121077
|
-
const content = file3.snapshotContent ?? await
|
|
121290
|
+
const content = file3.snapshotContent ?? await fs16.readFile(file3.absolutePath, "utf8");
|
|
121078
121291
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
121079
121292
|
if (outcome.status === "failed")
|
|
121080
121293
|
throw new StructuralEtlParseError(file3.relativePath, outcome.failureKind, `Structural evidence parse failed (${outcome.failureKind})`, outcome.diagnosticCount, outcome.diagnostics.slice(0, 10));
|
|
@@ -121086,8 +121299,8 @@ class ParseStage {
|
|
|
121086
121299
|
return { file: file3, chunks: [], symbols: [], rawImports: [], rawEdges: [] };
|
|
121087
121300
|
}
|
|
121088
121301
|
try {
|
|
121089
|
-
const content = file3.snapshotContent ?? await
|
|
121090
|
-
const ext2 =
|
|
121302
|
+
const content = file3.snapshotContent ?? await fs16.readFile(file3.absolutePath, "utf-8");
|
|
121303
|
+
const ext2 = path22.extname(file3.relativePath).toLowerCase();
|
|
121091
121304
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
121092
121305
|
const chunks = smartChunk(content, file3.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
121093
121306
|
let symbols;
|
|
@@ -121641,7 +121854,7 @@ var init_resolver = __esm(() => {
|
|
|
121641
121854
|
});
|
|
121642
121855
|
|
|
121643
121856
|
// ../../packages/core/dist/services/structural/resolvers/typescript.js
|
|
121644
|
-
import
|
|
121857
|
+
import path23 from "path";
|
|
121645
121858
|
function candidates(identities) {
|
|
121646
121859
|
return Object.freeze(identities.map((identity) => Object.freeze({
|
|
121647
121860
|
fqn: identity.fqn,
|
|
@@ -121736,7 +121949,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
121736
121949
|
const bases = /\.[cm]?jsx?$/u.test(base) ? [base.replace(/\.[cm]?jsx?$/u, ".ts"), base.replace(/\.[cm]?jsx?$/u, ".tsx"), base] : [base];
|
|
121737
121950
|
for (const candidateBase of bases)
|
|
121738
121951
|
for (const suffix of DIALECT_PROBES[dialect] ?? [""]) {
|
|
121739
|
-
const value =
|
|
121952
|
+
const value = path23.posix.normalize(`${candidateBase}${suffix}`);
|
|
121740
121953
|
if (!value.startsWith("../") && value !== ".." && known.has(value))
|
|
121741
121954
|
return value;
|
|
121742
121955
|
}
|
|
@@ -121745,7 +121958,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
121745
121958
|
function resolveStructuralSpecifier(specifier, fromFile, build, dialect = "typescript") {
|
|
121746
121959
|
const known = new Set(build.knownFiles.map(normalizeStructuralFile));
|
|
121747
121960
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
121748
|
-
return probe(
|
|
121961
|
+
return probe(path23.posix.join(path23.posix.dirname(fromFile), specifier), known, dialect);
|
|
121749
121962
|
}
|
|
121750
121963
|
const aliases = build.pathAliasesByFile?.[normalizeStructuralFile(fromFile)] ?? build.pathAliases ?? [];
|
|
121751
121964
|
for (const alias of aliases) {
|
|
@@ -122009,7 +122222,7 @@ var init_scripting2 = __esm(() => {
|
|
|
122009
122222
|
});
|
|
122010
122223
|
|
|
122011
122224
|
// ../../packages/core/dist/services/structural/resolvers/systems.js
|
|
122012
|
-
import
|
|
122225
|
+
import path24 from "path";
|
|
122013
122226
|
var DIALECTS, SYSTEMS_LANGUAGE_RESOLVER;
|
|
122014
122227
|
var init_systems2 = __esm(() => {
|
|
122015
122228
|
init_typescript2();
|
|
@@ -122028,7 +122241,7 @@ var init_systems2 = __esm(() => {
|
|
|
122028
122241
|
const bindings = item.bindings.map((binding) => binding.imported === "*" && binding.local === "*" && unresolvedTarget && !unresolvedTarget.qualifier ? { ...binding, imported: unresolvedTarget.name, local: unresolvedTarget.name } : binding);
|
|
122029
122242
|
if (item.specifier === "crate" || item.specifier.startsWith("crate/")) {
|
|
122030
122243
|
const crateRoot = file3.file.startsWith("src/") ? "src" : "";
|
|
122031
|
-
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, "")))}` };
|
|
122032
122245
|
}
|
|
122033
122246
|
if (item.specifier === "self" || item.specifier.startsWith("self/"))
|
|
122034
122247
|
return { ...item, bindings, specifier: `./${item.specifier.replace(/^self\/?/u, "")}` };
|
|
@@ -122126,8 +122339,8 @@ var init_data_document2 = __esm(() => {
|
|
|
122126
122339
|
});
|
|
122127
122340
|
|
|
122128
122341
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
122129
|
-
import
|
|
122130
|
-
import
|
|
122342
|
+
import path25 from "path";
|
|
122343
|
+
import fs17 from "fs";
|
|
122131
122344
|
|
|
122132
122345
|
class ResolveStage {
|
|
122133
122346
|
symbolRepository;
|
|
@@ -122151,7 +122364,7 @@ class ResolveStage {
|
|
|
122151
122364
|
const structuralDocuments = files.flatMap((file3) => {
|
|
122152
122365
|
if (!file3.structure)
|
|
122153
122366
|
return [];
|
|
122154
|
-
const language = resolveStructuralLanguage(
|
|
122367
|
+
const language = resolveStructuralLanguage(path25.extname(file3.file.relativePath));
|
|
122155
122368
|
if (language.status !== "supported")
|
|
122156
122369
|
throw new Error(`structural_manifest_missing:${file3.file.relativePath}`);
|
|
122157
122370
|
return [{
|
|
@@ -122163,13 +122376,13 @@ class ResolveStage {
|
|
|
122163
122376
|
}];
|
|
122164
122377
|
});
|
|
122165
122378
|
const currentStructuralFiles = new Set(structuralDocuments.map((document2) => document2.file));
|
|
122166
|
-
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));
|
|
122167
122380
|
const pathAliasesByFile = Object.fromEntries([...knownRelPaths].map((file3) => [
|
|
122168
122381
|
file3,
|
|
122169
122382
|
this.structuralAliasesFor(file3, rootAliases, monorepoPackages)
|
|
122170
122383
|
]));
|
|
122171
122384
|
const buildMetadata = { knownFiles: [...knownRelPaths], pathAliasesByFile };
|
|
122172
|
-
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));
|
|
122173
122386
|
const seedIds = new Set;
|
|
122174
122387
|
for (const definition of seedRows) {
|
|
122175
122388
|
if (seedIds.has(definition.id))
|
|
@@ -122262,7 +122475,7 @@ class ResolveStage {
|
|
|
122262
122475
|
if (parsed.file !== definition.file_path) {
|
|
122263
122476
|
throw new Error(`structural_repository_seed_file_mismatch:${definition.id}`);
|
|
122264
122477
|
}
|
|
122265
|
-
const language = resolveStructuralLanguage(
|
|
122478
|
+
const language = resolveStructuralLanguage(path25.extname(definition.file_path));
|
|
122266
122479
|
if (language.status !== "supported")
|
|
122267
122480
|
throw new Error(`structural_repository_seed_language:${definition.id}`);
|
|
122268
122481
|
let identity;
|
|
@@ -122314,7 +122527,7 @@ class ResolveStage {
|
|
|
122314
122527
|
});
|
|
122315
122528
|
}
|
|
122316
122529
|
resolveFile(parsed, projectPath, knownRelPaths, rootAliases, monorepoPackages, symbolIndex, knownFqns) {
|
|
122317
|
-
const fromDir =
|
|
122530
|
+
const fromDir = path25.dirname(path25.join(projectPath, parsed.file.relativePath));
|
|
122318
122531
|
const packageAliases = this.getPackageAliases(parsed.file.relativePath, monorepoPackages);
|
|
122319
122532
|
const allAliases = [...packageAliases, ...rootAliases];
|
|
122320
122533
|
const resolvedImports = parsed.rawImports.map((raw2) => {
|
|
@@ -122385,7 +122598,7 @@ class ResolveStage {
|
|
|
122385
122598
|
index.set(def.name, `${def.file_path}#${def.name}`);
|
|
122386
122599
|
}
|
|
122387
122600
|
} catch (err) {
|
|
122388
|
-
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()));
|
|
122389
122602
|
if (skippedStructural)
|
|
122390
122603
|
throw new Error("structural_repository_seed_failed", { cause: err });
|
|
122391
122604
|
logger.warn("buildSymbolIndex: repo seed failed, in-batch only", {
|
|
@@ -122409,7 +122622,7 @@ class ResolveStage {
|
|
|
122409
122622
|
}
|
|
122410
122623
|
resolveSpecifier(specifier, fromDir, projectPath, knownRelPaths, aliases) {
|
|
122411
122624
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
122412
|
-
const resolved = this.probeExtensions(
|
|
122625
|
+
const resolved = this.probeExtensions(path25.resolve(fromDir, specifier), projectPath, knownRelPaths);
|
|
122413
122626
|
return { resolvedPath: resolved, external: false };
|
|
122414
122627
|
}
|
|
122415
122628
|
for (const alias of aliases) {
|
|
@@ -122417,8 +122630,8 @@ class ResolveStage {
|
|
|
122417
122630
|
const suffix = specifier.slice(alias.prefix.length);
|
|
122418
122631
|
for (const target of alias.targets) {
|
|
122419
122632
|
const cleanTarget = target.replace(/\/\*$/, "");
|
|
122420
|
-
const basePath = alias.packagePath ?
|
|
122421
|
-
const absPath =
|
|
122633
|
+
const basePath = alias.packagePath ? path25.join(projectPath, alias.packagePath) : projectPath;
|
|
122634
|
+
const absPath = path25.join(basePath, cleanTarget + suffix);
|
|
122422
122635
|
const resolved = this.probeExtensions(absPath, projectPath, knownRelPaths);
|
|
122423
122636
|
if (resolved)
|
|
122424
122637
|
return { resolvedPath: resolved, external: false };
|
|
@@ -122434,7 +122647,7 @@ class ResolveStage {
|
|
|
122434
122647
|
...TS_EXTENSIONS.map((ext2) => absPath.replace(/\.[^.]+$/, ext2))
|
|
122435
122648
|
];
|
|
122436
122649
|
for (const candidate2 of candidates2) {
|
|
122437
|
-
const rel =
|
|
122650
|
+
const rel = path25.relative(projectPath, candidate2).replace(/\\/g, "/");
|
|
122438
122651
|
if (knownRelPaths.has(rel))
|
|
122439
122652
|
return rel;
|
|
122440
122653
|
}
|
|
@@ -122442,9 +122655,9 @@ class ResolveStage {
|
|
|
122442
122655
|
}
|
|
122443
122656
|
loadTsConfigPaths(projectPath, packageBase) {
|
|
122444
122657
|
const aliases = [];
|
|
122445
|
-
const tsconfigPath =
|
|
122658
|
+
const tsconfigPath = path25.join(projectPath, "tsconfig.json");
|
|
122446
122659
|
try {
|
|
122447
|
-
const raw2 =
|
|
122660
|
+
const raw2 = fs17.readFileSync(tsconfigPath, "utf-8");
|
|
122448
122661
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
122449
122662
|
const tsconfig = JSON.parse(stripped);
|
|
122450
122663
|
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
@@ -122473,7 +122686,7 @@ class ResolveStage {
|
|
|
122473
122686
|
}
|
|
122474
122687
|
}
|
|
122475
122688
|
for (const packageRelPath of packagePaths) {
|
|
122476
|
-
const absPackagePath =
|
|
122689
|
+
const absPackagePath = path25.join(projectPath, packageRelPath);
|
|
122477
122690
|
const aliases = this.loadTsConfigPaths(absPackagePath, packageRelPath);
|
|
122478
122691
|
if (aliases.length > 0) {
|
|
122479
122692
|
packages.push({
|
|
@@ -122503,7 +122716,7 @@ class ResolveStage {
|
|
|
122503
122716
|
structuralAliasesFor(filePath, rootAliases, packages) {
|
|
122504
122717
|
return [...this.getPackageAliases(filePath, packages), ...rootAliases].map((alias) => ({
|
|
122505
122718
|
pattern: alias.prefix + (alias.targets.some((target) => target.includes("*")) ? "/*" : ""),
|
|
122506
|
-
targets: alias.targets.map((target) => alias.packagePath ?
|
|
122719
|
+
targets: alias.targets.map((target) => alias.packagePath ? path25.posix.join(alias.packagePath, target) : target)
|
|
122507
122720
|
}));
|
|
122508
122721
|
}
|
|
122509
122722
|
}
|
|
@@ -122567,7 +122780,7 @@ var init_with_deadlock_retry = __esm(() => {
|
|
|
122567
122780
|
});
|
|
122568
122781
|
|
|
122569
122782
|
// ../../packages/core/dist/services/etl/stages/load.js
|
|
122570
|
-
import
|
|
122783
|
+
import path26 from "path";
|
|
122571
122784
|
function formatDuration(ms) {
|
|
122572
122785
|
const totalSec = Math.max(0, Math.round(ms / 1000));
|
|
122573
122786
|
if (totalSec < 60)
|
|
@@ -122844,7 +123057,7 @@ class LoadStage {
|
|
|
122844
123057
|
const filePath = file3.file.relativePath;
|
|
122845
123058
|
const batch = buildSymbolPersistenceBatch(ctx.projectId, file3);
|
|
122846
123059
|
if (ctx.graphGenerationLease) {
|
|
122847
|
-
const manifest = getLanguageManifestEntry(
|
|
123060
|
+
const manifest = getLanguageManifestEntry(path26.extname(filePath));
|
|
122848
123061
|
const diagnostics2 = (file3.structuralDiagnostics ?? []).slice(0, 10).map((diagnostic2) => ({
|
|
122849
123062
|
code: diagnostic2.code,
|
|
122850
123063
|
severity: diagnostic2.severity,
|
|
@@ -123301,9 +123514,9 @@ var init_graph_generation_coordinator = __esm(() => {
|
|
|
123301
123514
|
// ../../packages/core/dist/services/etl/pipeline.js
|
|
123302
123515
|
import { createHash as createHash7 } from "crypto";
|
|
123303
123516
|
import { setTimeout as delay2 } from "timers/promises";
|
|
123304
|
-
import
|
|
123517
|
+
import path27 from "path";
|
|
123305
123518
|
function buildHeaderLanguageEvidence(files) {
|
|
123306
|
-
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)));
|
|
123307
123520
|
const mutable = new Map;
|
|
123308
123521
|
const entry2 = (header) => {
|
|
123309
123522
|
let value = mutable.get(header);
|
|
@@ -123314,7 +123527,7 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
123314
123527
|
return value;
|
|
123315
123528
|
};
|
|
123316
123529
|
for (const file3 of files) {
|
|
123317
|
-
if (
|
|
123530
|
+
if (path27.posix.basename(file3.relativePath) !== "compile_commands.json" || file3.snapshotContent === undefined)
|
|
123318
123531
|
continue;
|
|
123319
123532
|
let commands;
|
|
123320
123533
|
try {
|
|
@@ -123330,11 +123543,11 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
123330
123543
|
const record2 = command;
|
|
123331
123544
|
if (typeof record2.file !== "string")
|
|
123332
123545
|
continue;
|
|
123333
|
-
const projectRoot =
|
|
123334
|
-
const commandDirectory = typeof record2.directory === "string" ?
|
|
123335
|
-
const absoluteInput =
|
|
123336
|
-
const relative2 =
|
|
123337
|
-
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, "/"));
|
|
123338
123551
|
if (!headers.has(header))
|
|
123339
123552
|
continue;
|
|
123340
123553
|
const invocation = typeof record2.command === "string" ? record2.command : Array.isArray(record2.arguments) ? record2.arguments.join(" ") : "";
|
|
@@ -124509,16 +124722,16 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
124509
124722
|
const seen = new Set;
|
|
124510
124723
|
const out = [];
|
|
124511
124724
|
for (const e of httpEdges) {
|
|
124512
|
-
const
|
|
124513
|
-
if (!
|
|
124725
|
+
const path29 = e.route;
|
|
124726
|
+
if (!path29)
|
|
124514
124727
|
continue;
|
|
124515
124728
|
const method = (e.method ?? "ANY").toUpperCase();
|
|
124516
|
-
const key = method + " " +
|
|
124729
|
+
const key = method + " " + path29;
|
|
124517
124730
|
if (seen.has(key))
|
|
124518
124731
|
continue;
|
|
124519
124732
|
seen.add(key);
|
|
124520
124733
|
out.push({
|
|
124521
|
-
path:
|
|
124734
|
+
path: path29,
|
|
124522
124735
|
method: e.method,
|
|
124523
124736
|
file: e.fromFile,
|
|
124524
124737
|
handler: e.targetFqn ?? e.symbolName
|
|
@@ -124529,12 +124742,12 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
124529
124742
|
continue;
|
|
124530
124743
|
const parsed = parseRouteName(d.name);
|
|
124531
124744
|
const method = parsed?.method ?? "ANY";
|
|
124532
|
-
const
|
|
124533
|
-
const key = method + " " +
|
|
124745
|
+
const path29 = parsed?.path ?? d.name;
|
|
124746
|
+
const key = method + " " + path29;
|
|
124534
124747
|
if (seen.has(key))
|
|
124535
124748
|
continue;
|
|
124536
124749
|
seen.add(key);
|
|
124537
|
-
out.push({ path:
|
|
124750
|
+
out.push({ path: path29, method: parsed?.method, file: d.filePath, handler: d.name });
|
|
124538
124751
|
}
|
|
124539
124752
|
for (const d of defs) {
|
|
124540
124753
|
const parsed = parseRouteName(d.name);
|
|
@@ -124755,8 +124968,8 @@ __export(exports_symbol_graph_service, {
|
|
|
124755
124968
|
symbolGraphService: () => symbolGraphService,
|
|
124756
124969
|
SymbolGraphService: () => SymbolGraphService
|
|
124757
124970
|
});
|
|
124758
|
-
import
|
|
124759
|
-
import
|
|
124971
|
+
import path29 from "path";
|
|
124972
|
+
import fs18 from "fs/promises";
|
|
124760
124973
|
|
|
124761
124974
|
class SymbolGraphService {
|
|
124762
124975
|
identityLookup;
|
|
@@ -125084,7 +125297,7 @@ class SymbolGraphService {
|
|
|
125084
125297
|
async readSnippet(relativePath, lineStart, lineEnd, projectId) {
|
|
125085
125298
|
try {
|
|
125086
125299
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
125087
|
-
const content = await
|
|
125300
|
+
const content = await fs18.readFile(absolutePath, "utf-8");
|
|
125088
125301
|
const lines = content.split(`
|
|
125089
125302
|
`);
|
|
125090
125303
|
return lines.slice(Math.max(0, lineStart - 1), Math.min(lines.length, lineEnd)).join(`
|
|
@@ -125096,7 +125309,7 @@ class SymbolGraphService {
|
|
|
125096
125309
|
async readContext(relativePath, lineNumber, contextLines, projectId) {
|
|
125097
125310
|
try {
|
|
125098
125311
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
125099
|
-
const content = await
|
|
125312
|
+
const content = await fs18.readFile(absolutePath, "utf-8");
|
|
125100
125313
|
const lines = content.split(`
|
|
125101
125314
|
`);
|
|
125102
125315
|
const start = Math.max(0, lineNumber - contextLines - 1);
|
|
@@ -125109,7 +125322,7 @@ class SymbolGraphService {
|
|
|
125109
125322
|
}
|
|
125110
125323
|
async resolveToAbsolute(relativePath, projectId) {
|
|
125111
125324
|
const root = await this.getProjectRoot(projectId);
|
|
125112
|
-
return root ?
|
|
125325
|
+
return root ? path29.resolve(root, relativePath) : relativePath;
|
|
125113
125326
|
}
|
|
125114
125327
|
async getProjectRoot(projectId) {
|
|
125115
125328
|
const cached2 = this.projectRootCache.get(projectId);
|
|
@@ -128211,6 +128424,7 @@ class PgObservationStore {
|
|
|
128211
128424
|
mirror = new Map;
|
|
128212
128425
|
hydrated = false;
|
|
128213
128426
|
hydrating = null;
|
|
128427
|
+
inflight = new Map;
|
|
128214
128428
|
hydrateFailedAt = 0;
|
|
128215
128429
|
static HYDRATE_RETRY_MS = 30000;
|
|
128216
128430
|
getClient() {
|
|
@@ -128262,46 +128476,53 @@ class PgObservationStore {
|
|
|
128262
128476
|
const cachedCanonical = getProjectIdentityAliasResolver().resolveCached(obs.projectId);
|
|
128263
128477
|
this.mirror.set(obs.id, cachedCanonical && cachedCanonical !== obs.projectId ? { ...obs, projectId: cachedCanonical } : obs);
|
|
128264
128478
|
this.ensureHydrated();
|
|
128265
|
-
(async () => {
|
|
128266
|
-
|
|
128267
|
-
|
|
128268
|
-
|
|
128269
|
-
|
|
128270
|
-
this.mirror.set(obs.id, { ...obs, projectId: canonicalProjectId });
|
|
128271
|
-
}
|
|
128272
|
-
await prisma2.$executeRaw`
|
|
128273
|
-
INSERT INTO observations (
|
|
128274
|
-
id, project_id, session_id, source, category, payload_json, importance, created_at, agent_id, attribution_source
|
|
128275
|
-
) VALUES (
|
|
128276
|
-
${obs.id},
|
|
128277
|
-
${canonicalProjectId},
|
|
128278
|
-
${obs.sessionId},
|
|
128279
|
-
${obs.source},
|
|
128280
|
-
${obs.category ?? null},
|
|
128281
|
-
${obs.payloadJson},
|
|
128282
|
-
${obs.importance},
|
|
128283
|
-
${obs.createdAt}::bigint,
|
|
128284
|
-
${obs.agentId ?? null},
|
|
128285
|
-
${obs.attributionSource ?? null}
|
|
128286
|
-
)
|
|
128287
|
-
ON CONFLICT (id) DO UPDATE SET
|
|
128288
|
-
project_id = EXCLUDED.project_id,
|
|
128289
|
-
session_id = EXCLUDED.session_id,
|
|
128290
|
-
source = EXCLUDED.source,
|
|
128291
|
-
category = EXCLUDED.category,
|
|
128292
|
-
payload_json = EXCLUDED.payload_json,
|
|
128293
|
-
importance = EXCLUDED.importance,
|
|
128294
|
-
created_at = EXCLUDED.created_at,
|
|
128295
|
-
agent_id = EXCLUDED.agent_id,
|
|
128296
|
-
attribution_source = EXCLUDED.attribution_source
|
|
128297
|
-
`;
|
|
128298
|
-
} catch (e) {
|
|
128299
|
-
logger.warn("PgObservationStore.insert failed (best-effort)", {
|
|
128300
|
-
id: obs.id,
|
|
128301
|
-
error: e.message
|
|
128302
|
-
});
|
|
128479
|
+
this.chainWrite(obs.id, async () => {
|
|
128480
|
+
const prisma2 = this.getClient();
|
|
128481
|
+
const canonicalProjectId = await getProjectIdentityAliasResolver().resolve(obs.projectId);
|
|
128482
|
+
if (canonicalProjectId !== obs.projectId) {
|
|
128483
|
+
this.mirror.set(obs.id, { ...obs, projectId: canonicalProjectId });
|
|
128303
128484
|
}
|
|
128304
|
-
|
|
128485
|
+
await prisma2.$executeRaw`
|
|
128486
|
+
INSERT INTO observations (
|
|
128487
|
+
id, project_id, session_id, source, category, payload_json, importance, created_at, agent_id, attribution_source
|
|
128488
|
+
) VALUES (
|
|
128489
|
+
${obs.id},
|
|
128490
|
+
${canonicalProjectId},
|
|
128491
|
+
${obs.sessionId},
|
|
128492
|
+
${obs.source},
|
|
128493
|
+
${obs.category ?? null},
|
|
128494
|
+
${obs.payloadJson},
|
|
128495
|
+
${obs.importance},
|
|
128496
|
+
${obs.createdAt}::bigint,
|
|
128497
|
+
${obs.agentId ?? null},
|
|
128498
|
+
${obs.attributionSource ?? null}
|
|
128499
|
+
)
|
|
128500
|
+
ON CONFLICT (id) DO UPDATE SET
|
|
128501
|
+
project_id = EXCLUDED.project_id,
|
|
128502
|
+
session_id = EXCLUDED.session_id,
|
|
128503
|
+
source = EXCLUDED.source,
|
|
128504
|
+
category = EXCLUDED.category,
|
|
128505
|
+
payload_json = EXCLUDED.payload_json,
|
|
128506
|
+
importance = EXCLUDED.importance,
|
|
128507
|
+
created_at = EXCLUDED.created_at,
|
|
128508
|
+
agent_id = EXCLUDED.agent_id,
|
|
128509
|
+
attribution_source = EXCLUDED.attribution_source
|
|
128510
|
+
`;
|
|
128511
|
+
});
|
|
128512
|
+
}
|
|
128513
|
+
chainWrite(key, fn) {
|
|
128514
|
+
const prev = this.inflight.get(key) ?? Promise.resolve();
|
|
128515
|
+
const next = prev.then(fn).catch((e) => {
|
|
128516
|
+
logger.warn("PgObservationStore.insert failed (best-effort)", {
|
|
128517
|
+
id: key,
|
|
128518
|
+
error: e.message
|
|
128519
|
+
});
|
|
128520
|
+
});
|
|
128521
|
+
this.inflight.set(key, next);
|
|
128522
|
+
next.then(() => {
|
|
128523
|
+
if (this.inflight.get(key) === next)
|
|
128524
|
+
this.inflight.delete(key);
|
|
128525
|
+
});
|
|
128305
128526
|
}
|
|
128306
128527
|
listRecent(projectId, limit) {
|
|
128307
128528
|
this.ensureHydrated();
|
|
@@ -128328,6 +128549,9 @@ class PgObservationStore {
|
|
|
128328
128549
|
await this.ensureHydrated();
|
|
128329
128550
|
}
|
|
128330
128551
|
async __drain() {
|
|
128552
|
+
const pending = Array.from(this.inflight.values());
|
|
128553
|
+
if (pending.length > 0)
|
|
128554
|
+
await Promise.allSettled(pending);
|
|
128331
128555
|
await new Promise((r2) => setTimeout(r2, 10));
|
|
128332
128556
|
}
|
|
128333
128557
|
}
|
|
@@ -129103,31 +129327,31 @@ class TracePathService {
|
|
|
129103
129327
|
const chains = [];
|
|
129104
129328
|
const seen = new Set;
|
|
129105
129329
|
let walks = 0;
|
|
129106
|
-
const walk = (fqn,
|
|
129330
|
+
const walk = (fqn, path32) => {
|
|
129107
129331
|
if (chains.length >= CHAIN_CAP)
|
|
129108
129332
|
return;
|
|
129109
129333
|
if (walks >= MAX_WALKS)
|
|
129110
129334
|
return;
|
|
129111
129335
|
walks++;
|
|
129112
|
-
const key =
|
|
129336
|
+
const key = path32.join("\u2192");
|
|
129113
129337
|
if (seen.has(key))
|
|
129114
129338
|
return;
|
|
129115
129339
|
seen.add(key);
|
|
129116
129340
|
const next = adj.get(fqn);
|
|
129117
129341
|
if (!next || next.length === 0 || !whoHasChild.has(fqn)) {
|
|
129118
|
-
if (
|
|
129119
|
-
chains.push(
|
|
129342
|
+
if (path32.length > 1)
|
|
129343
|
+
chains.push(path32.map((n2) => this.fqnToName(n2)).join(" \u2192 "));
|
|
129120
129344
|
return;
|
|
129121
129345
|
}
|
|
129122
129346
|
for (const child of next) {
|
|
129123
129347
|
if (chains.length >= CHAIN_CAP || walks >= MAX_WALKS)
|
|
129124
129348
|
return;
|
|
129125
|
-
if (
|
|
129126
|
-
const cycled = [...
|
|
129349
|
+
if (path32.includes(child)) {
|
|
129350
|
+
const cycled = [...path32, `${this.fqnToName(child)}\u21BA`];
|
|
129127
129351
|
chains.push(cycled.map((n2) => n2).join(" \u2192 "));
|
|
129128
129352
|
continue;
|
|
129129
129353
|
}
|
|
129130
|
-
walk(child, [...
|
|
129354
|
+
walk(child, [...path32, child]);
|
|
129131
129355
|
}
|
|
129132
129356
|
};
|
|
129133
129357
|
for (const seed of seeds) {
|
|
@@ -132298,9 +132522,9 @@ var init_inference_probe = __esm(() => {
|
|
|
132298
132522
|
});
|
|
132299
132523
|
|
|
132300
132524
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
132301
|
-
import
|
|
132525
|
+
import fs21 from "fs/promises";
|
|
132302
132526
|
import { existsSync as existsSync3 } from "fs";
|
|
132303
|
-
import
|
|
132527
|
+
import path34 from "path";
|
|
132304
132528
|
|
|
132305
132529
|
class LocalHealthChecker {
|
|
132306
132530
|
dataDir = config.get("dataDir");
|
|
@@ -132378,10 +132602,10 @@ class LocalHealthChecker {
|
|
|
132378
132602
|
const start = Date.now();
|
|
132379
132603
|
try {
|
|
132380
132604
|
if (!existsSync3(this.dataDir))
|
|
132381
|
-
await
|
|
132382
|
-
const probe2 =
|
|
132383
|
-
await
|
|
132384
|
-
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);
|
|
132385
132609
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
132386
132610
|
} catch (error51) {
|
|
132387
132611
|
return { available: false, latency: Date.now() - start, error: `Data directory error: ${error51.message}` };
|
|
@@ -134451,9 +134675,9 @@ var init_scheduler2 = __esm(() => {
|
|
|
134451
134675
|
});
|
|
134452
134676
|
|
|
134453
134677
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
134454
|
-
import
|
|
134678
|
+
import fs22 from "fs/promises";
|
|
134455
134679
|
import { existsSync as existsSync4 } from "fs";
|
|
134456
|
-
import
|
|
134680
|
+
import path35 from "path";
|
|
134457
134681
|
function getModelsDevClient() {
|
|
134458
134682
|
if (!clientInstance) {
|
|
134459
134683
|
clientInstance = new ModelsDevClient;
|
|
@@ -134473,7 +134697,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
134473
134697
|
memoryCacheTimestamp = 0;
|
|
134474
134698
|
getLocalCachePath() {
|
|
134475
134699
|
const dataDir = config.get("dataDir");
|
|
134476
|
-
return
|
|
134700
|
+
return path35.join(dataDir, ModelsDevClient.LOCAL_CACHE_FILE);
|
|
134477
134701
|
}
|
|
134478
134702
|
async loadLocalCache() {
|
|
134479
134703
|
const cachePath = this.getLocalCachePath();
|
|
@@ -134481,7 +134705,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
134481
134705
|
if (!existsSync4(cachePath)) {
|
|
134482
134706
|
return null;
|
|
134483
134707
|
}
|
|
134484
|
-
const content = await
|
|
134708
|
+
const content = await fs22.readFile(cachePath, "utf-8");
|
|
134485
134709
|
const data = JSON.parse(content);
|
|
134486
134710
|
const age = Date.now() - data.timestamp;
|
|
134487
134711
|
if (age > ModelsDevClient.LOCAL_CACHE_TTL) {
|
|
@@ -134508,14 +134732,14 @@ var init_models_dev_client = __esm(() => {
|
|
|
134508
134732
|
async saveLocalCache(models) {
|
|
134509
134733
|
const cachePath = this.getLocalCachePath();
|
|
134510
134734
|
try {
|
|
134511
|
-
const dir =
|
|
134512
|
-
await
|
|
134735
|
+
const dir = path35.dirname(cachePath);
|
|
134736
|
+
await fs22.mkdir(dir, { recursive: true });
|
|
134513
134737
|
const data = {
|
|
134514
134738
|
timestamp: Date.now(),
|
|
134515
134739
|
version: "1.0.0",
|
|
134516
134740
|
models: Object.fromEntries(models)
|
|
134517
134741
|
};
|
|
134518
|
-
await
|
|
134742
|
+
await fs22.writeFile(cachePath, JSON.stringify(data), "utf-8");
|
|
134519
134743
|
logger.debug("Saved pricing to local cache", {
|
|
134520
134744
|
models: models.size,
|
|
134521
134745
|
path: cachePath
|
|
@@ -134844,7 +135068,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
134844
135068
|
const cachePath = this.getLocalCachePath();
|
|
134845
135069
|
try {
|
|
134846
135070
|
if (existsSync4(cachePath)) {
|
|
134847
|
-
await
|
|
135071
|
+
await fs22.unlink(cachePath);
|
|
134848
135072
|
logger.debug("Local pricing cache file deleted");
|
|
134849
135073
|
}
|
|
134850
135074
|
} catch (error51) {
|
|
@@ -140399,33 +140623,33 @@ var require_URL = __commonJS((exports, module) => {
|
|
|
140399
140623
|
else
|
|
140400
140624
|
return basepath.substring(0, lastslash + 1) + refpath;
|
|
140401
140625
|
}
|
|
140402
|
-
function remove_dot_segments(
|
|
140403
|
-
if (!
|
|
140404
|
-
return
|
|
140626
|
+
function remove_dot_segments(path36) {
|
|
140627
|
+
if (!path36)
|
|
140628
|
+
return path36;
|
|
140405
140629
|
var output = "";
|
|
140406
|
-
while (
|
|
140407
|
-
if (
|
|
140408
|
-
|
|
140630
|
+
while (path36.length > 0) {
|
|
140631
|
+
if (path36 === "." || path36 === "..") {
|
|
140632
|
+
path36 = "";
|
|
140409
140633
|
break;
|
|
140410
140634
|
}
|
|
140411
|
-
var twochars =
|
|
140412
|
-
var threechars =
|
|
140413
|
-
var fourchars =
|
|
140635
|
+
var twochars = path36.substring(0, 2);
|
|
140636
|
+
var threechars = path36.substring(0, 3);
|
|
140637
|
+
var fourchars = path36.substring(0, 4);
|
|
140414
140638
|
if (threechars === "../") {
|
|
140415
|
-
|
|
140639
|
+
path36 = path36.substring(3);
|
|
140416
140640
|
} else if (twochars === "./") {
|
|
140417
|
-
|
|
140641
|
+
path36 = path36.substring(2);
|
|
140418
140642
|
} else if (threechars === "/./") {
|
|
140419
|
-
|
|
140420
|
-
} else if (twochars === "/." &&
|
|
140421
|
-
|
|
140422
|
-
} else if (fourchars === "/../" || threechars === "/.." &&
|
|
140423
|
-
|
|
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);
|
|
140424
140648
|
output = output.replace(/\/?[^\/]*$/, "");
|
|
140425
140649
|
} else {
|
|
140426
|
-
var segment =
|
|
140650
|
+
var segment = path36.match(/(\/?([^\/]*))/)[0];
|
|
140427
140651
|
output += segment;
|
|
140428
|
-
|
|
140652
|
+
path36 = path36.substring(segment.length);
|
|
140429
140653
|
}
|
|
140430
140654
|
}
|
|
140431
140655
|
return output;
|
|
@@ -152495,21 +152719,21 @@ function jsonToKeyPathChunks(value, label = "$") {
|
|
|
152495
152719
|
walk(value, label, out);
|
|
152496
152720
|
return out;
|
|
152497
152721
|
}
|
|
152498
|
-
function walk(val,
|
|
152722
|
+
function walk(val, path36, out) {
|
|
152499
152723
|
if (val === null || val === undefined)
|
|
152500
152724
|
return;
|
|
152501
152725
|
if (Array.isArray(val)) {
|
|
152502
152726
|
if (val.length === 0) {
|
|
152503
|
-
out.push({ path:
|
|
152727
|
+
out.push({ path: path36, content: `**${path36}** = _[]_` });
|
|
152504
152728
|
return;
|
|
152505
152729
|
}
|
|
152506
152730
|
if (val.every((v) => v !== null && typeof v === "object")) {
|
|
152507
|
-
val.forEach((v, i) => walk(v, `${
|
|
152731
|
+
val.forEach((v, i) => walk(v, `${path36}[${i}]`, out));
|
|
152508
152732
|
return;
|
|
152509
152733
|
}
|
|
152510
152734
|
const items = val.map((v) => `- \`${String(v)}\``).join(`
|
|
152511
152735
|
`);
|
|
152512
|
-
out.push({ path:
|
|
152736
|
+
out.push({ path: path36, content: `**${path36}**
|
|
152513
152737
|
|
|
152514
152738
|
${items}` });
|
|
152515
152739
|
return;
|
|
@@ -152517,16 +152741,16 @@ ${items}` });
|
|
|
152517
152741
|
if (typeof val === "object") {
|
|
152518
152742
|
const entries = Object.entries(val);
|
|
152519
152743
|
if (entries.length === 0) {
|
|
152520
|
-
out.push({ path:
|
|
152744
|
+
out.push({ path: path36, content: `**${path36}** = _{}_` });
|
|
152521
152745
|
return;
|
|
152522
152746
|
}
|
|
152523
152747
|
for (const [k2, v] of entries) {
|
|
152524
152748
|
const safeKey = /^[A-Za-z_$][\w$]*$/.test(k2) ? k2 : JSON.stringify(k2);
|
|
152525
|
-
walk(v, `${
|
|
152749
|
+
walk(v, `${path36}.${safeKey}`, out);
|
|
152526
152750
|
}
|
|
152527
152751
|
return;
|
|
152528
152752
|
}
|
|
152529
|
-
out.push({ path:
|
|
152753
|
+
out.push({ path: path36, content: `**${path36}** = \`${String(val)}\`` });
|
|
152530
152754
|
}
|
|
152531
152755
|
var gfm, STRIP_SELECTORS, tdCache = null;
|
|
152532
152756
|
var init_html_to_md = __esm(() => {
|
|
@@ -175517,9 +175741,9 @@ async function acquireIndexingLease(request) {
|
|
|
175517
175741
|
|
|
175518
175742
|
// ../../packages/core/dist/services/project-identity/project-root-identity.js
|
|
175519
175743
|
import { realpath as realpath2 } from "fs/promises";
|
|
175520
|
-
import
|
|
175744
|
+
import path28 from "path";
|
|
175521
175745
|
async function canonicalizeProjectRoot(projectPath, canonicalize = realpath2) {
|
|
175522
|
-
return canonicalize(
|
|
175746
|
+
return canonicalize(path28.resolve(projectPath));
|
|
175523
175747
|
}
|
|
175524
175748
|
async function assertProjectRootReuse(options) {
|
|
175525
175749
|
if (!options.storedProjectPath || options.forceReindex)
|
|
@@ -175527,9 +175751,9 @@ async function assertProjectRootReuse(options) {
|
|
|
175527
175751
|
const canonicalize = options.canonicalize ?? realpath2;
|
|
175528
175752
|
let storedCanonical;
|
|
175529
175753
|
try {
|
|
175530
|
-
storedCanonical = await canonicalize(
|
|
175754
|
+
storedCanonical = await canonicalize(path28.resolve(options.storedProjectPath));
|
|
175531
175755
|
} catch {
|
|
175532
|
-
storedCanonical =
|
|
175756
|
+
storedCanonical = path28.resolve(options.storedProjectPath);
|
|
175533
175757
|
}
|
|
175534
175758
|
if (storedCanonical !== options.canonicalProjectPath) {
|
|
175535
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");
|
|
@@ -175539,7 +175763,7 @@ async function assertProjectRootReuse(options) {
|
|
|
175539
175763
|
// ../../packages/core/dist/tools/index_project.js
|
|
175540
175764
|
init_workspace_manager();
|
|
175541
175765
|
init_parser_readiness();
|
|
175542
|
-
import
|
|
175766
|
+
import path30 from "path";
|
|
175543
175767
|
|
|
175544
175768
|
class IndexProjectTool {
|
|
175545
175769
|
name = "index_project";
|
|
@@ -175587,7 +175811,7 @@ class IndexProjectTool {
|
|
|
175587
175811
|
try {
|
|
175588
175812
|
await assertParserReadyForIndexing();
|
|
175589
175813
|
const canonicalProjectPath = await canonicalizeProjectRoot(projectPath);
|
|
175590
|
-
const finalProjectId = projectId ||
|
|
175814
|
+
const finalProjectId = projectId || path30.basename(canonicalProjectPath) || "default";
|
|
175591
175815
|
const existing = await workspaceManager.getWorkspace(finalProjectId);
|
|
175592
175816
|
await assertProjectRootReuse({
|
|
175593
175817
|
projectId: finalProjectId,
|
|
@@ -176141,17 +176365,17 @@ function applyReplacer(root, replacer) {
|
|
|
176141
176365
|
return transformChildren(root, replacer, []);
|
|
176142
176366
|
return transformChildren(normalizeValue(replacedRoot), replacer, []);
|
|
176143
176367
|
}
|
|
176144
|
-
function transformChildren(value, replacer,
|
|
176368
|
+
function transformChildren(value, replacer, path31) {
|
|
176145
176369
|
if (isJsonObject(value))
|
|
176146
|
-
return transformObject(value, replacer,
|
|
176370
|
+
return transformObject(value, replacer, path31);
|
|
176147
176371
|
if (isJsonArray(value))
|
|
176148
|
-
return transformArray(value, replacer,
|
|
176372
|
+
return transformArray(value, replacer, path31);
|
|
176149
176373
|
return value;
|
|
176150
176374
|
}
|
|
176151
|
-
function transformObject(obj, replacer,
|
|
176375
|
+
function transformObject(obj, replacer, path31) {
|
|
176152
176376
|
const result = {};
|
|
176153
176377
|
for (const [key, value] of Object.entries(obj)) {
|
|
176154
|
-
const childPath = [...
|
|
176378
|
+
const childPath = [...path31, key];
|
|
176155
176379
|
const replacedValue = replacer(key, value, childPath);
|
|
176156
176380
|
if (replacedValue === undefined)
|
|
176157
176381
|
continue;
|
|
@@ -176159,11 +176383,11 @@ function transformObject(obj, replacer, path30) {
|
|
|
176159
176383
|
}
|
|
176160
176384
|
return result;
|
|
176161
176385
|
}
|
|
176162
|
-
function transformArray(arr, replacer,
|
|
176386
|
+
function transformArray(arr, replacer, path31) {
|
|
176163
176387
|
const result = [];
|
|
176164
176388
|
for (let i = 0;i < arr.length; i++) {
|
|
176165
176389
|
const value = arr[i];
|
|
176166
|
-
const childPath = [...
|
|
176390
|
+
const childPath = [...path31, i];
|
|
176167
176391
|
const replacedValue = replacer(String(i), value, childPath);
|
|
176168
176392
|
if (replacedValue === undefined)
|
|
176169
176393
|
continue;
|
|
@@ -177544,9 +177768,9 @@ init_dist();
|
|
|
177544
177768
|
init_db_connection();
|
|
177545
177769
|
init_alias_resolver();
|
|
177546
177770
|
init_safe_error_summary();
|
|
177547
|
-
import
|
|
177548
|
-
import
|
|
177549
|
-
import
|
|
177771
|
+
import fs19 from "fs";
|
|
177772
|
+
import os9 from "os";
|
|
177773
|
+
import path31 from "path";
|
|
177550
177774
|
|
|
177551
177775
|
// ../../packages/core/dist/services/hooks/session-pin-store.js
|
|
177552
177776
|
var DEFAULT_MAX_SIZE = 1000;
|
|
@@ -177645,8 +177869,8 @@ class AttributionResolver {
|
|
|
177645
177869
|
this.aliasResolver = options.aliasResolver ?? getProjectIdentityAliasResolver();
|
|
177646
177870
|
this.pins = options.pins ?? new SessionPinStore;
|
|
177647
177871
|
this.canonicalize = options.canonicalize ?? defaultCanonicalize;
|
|
177648
|
-
this.homedir = options.homedir ??
|
|
177649
|
-
this.fsRoot = options.fsRoot ?? (() =>
|
|
177872
|
+
this.homedir = options.homedir ?? os9.homedir;
|
|
177873
|
+
this.fsRoot = options.fsRoot ?? (() => path31.parse(path31.sep).root);
|
|
177650
177874
|
}
|
|
177651
177875
|
async resolve(input) {
|
|
177652
177876
|
const caller = input.callerProjectId;
|
|
@@ -177697,7 +177921,7 @@ class AttributionResolver {
|
|
|
177697
177921
|
}
|
|
177698
177922
|
let bestPath = null;
|
|
177699
177923
|
for (const candidate2 of byPath.keys()) {
|
|
177700
|
-
if (canonicalCwd === candidate2 || canonicalCwd.startsWith(candidate2.endsWith(
|
|
177924
|
+
if (canonicalCwd === candidate2 || canonicalCwd.startsWith(candidate2.endsWith(path31.sep) ? candidate2 : candidate2 + path31.sep)) {
|
|
177701
177925
|
if (bestPath === null || candidate2.length > bestPath.length) {
|
|
177702
177926
|
bestPath = candidate2;
|
|
177703
177927
|
}
|
|
@@ -177720,7 +177944,7 @@ class AttributionResolver {
|
|
|
177720
177944
|
return projectPath2;
|
|
177721
177945
|
const fsRoot = this.fsRoot();
|
|
177722
177946
|
let normalized = projectPath2;
|
|
177723
|
-
while (normalized.length > fsRoot.length && normalized.endsWith(
|
|
177947
|
+
while (normalized.length > fsRoot.length && normalized.endsWith(path31.sep)) {
|
|
177724
177948
|
normalized = normalized.slice(0, -1);
|
|
177725
177949
|
}
|
|
177726
177950
|
return normalized;
|
|
@@ -177728,10 +177952,10 @@ class AttributionResolver {
|
|
|
177728
177952
|
}
|
|
177729
177953
|
function defaultCanonicalize(cwd) {
|
|
177730
177954
|
try {
|
|
177731
|
-
return
|
|
177955
|
+
return fs19.realpathSync(cwd);
|
|
177732
177956
|
} catch {
|
|
177733
177957
|
try {
|
|
177734
|
-
return
|
|
177958
|
+
return path31.resolve(cwd);
|
|
177735
177959
|
} catch {
|
|
177736
177960
|
return;
|
|
177737
177961
|
}
|
|
@@ -178268,7 +178492,7 @@ init_code_compressor();
|
|
|
178268
178492
|
|
|
178269
178493
|
// ../../packages/core/dist/services/file-read/file-content-cache.js
|
|
178270
178494
|
init_dist();
|
|
178271
|
-
import
|
|
178495
|
+
import fs20 from "fs/promises";
|
|
178272
178496
|
|
|
178273
178497
|
class FileContentCache {
|
|
178274
178498
|
extractMetadata;
|
|
@@ -178301,7 +178525,7 @@ class FileContentCache {
|
|
|
178301
178525
|
metadata: cached2.metadata
|
|
178302
178526
|
};
|
|
178303
178527
|
}
|
|
178304
|
-
const content = await
|
|
178528
|
+
const content = await fs20.readFile(filePath, "utf-8");
|
|
178305
178529
|
const metadata = await this.extractMetadata(content, filePath, options);
|
|
178306
178530
|
evictOldest(this.fileCache, this.FILE_CACHE_MAX_ENTRIES - 1);
|
|
178307
178531
|
this.fileCache.set(cacheKey, {
|
|
@@ -178316,7 +178540,7 @@ class FileContentCache {
|
|
|
178316
178540
|
|
|
178317
178541
|
// ../../packages/core/dist/services/file-read/file-metadata.js
|
|
178318
178542
|
init_dist();
|
|
178319
|
-
import
|
|
178543
|
+
import path32 from "path";
|
|
178320
178544
|
|
|
178321
178545
|
class FileMetadataExtractor {
|
|
178322
178546
|
symbolGraph;
|
|
@@ -178352,7 +178576,7 @@ class FileMetadataExtractor {
|
|
|
178352
178576
|
return metadata;
|
|
178353
178577
|
}
|
|
178354
178578
|
detectLanguage(filePath) {
|
|
178355
|
-
const ext2 =
|
|
178579
|
+
const ext2 = path32.extname(filePath).toLowerCase();
|
|
178356
178580
|
const languageMap2 = {
|
|
178357
178581
|
".ts": "TypeScript",
|
|
178358
178582
|
".tsx": "TypeScript",
|
|
@@ -178469,7 +178693,7 @@ function selectLines(lines, range) {
|
|
|
178469
178693
|
|
|
178470
178694
|
// ../../packages/core/dist/services/file-read/path-containment.js
|
|
178471
178695
|
init_dist();
|
|
178472
|
-
import
|
|
178696
|
+
import path33 from "path";
|
|
178473
178697
|
|
|
178474
178698
|
class PathContainment {
|
|
178475
178699
|
projectRoots;
|
|
@@ -178477,14 +178701,14 @@ class PathContainment {
|
|
|
178477
178701
|
this.projectRoots = projectRoots;
|
|
178478
178702
|
}
|
|
178479
178703
|
async resolveFilePath(filePath, projectId) {
|
|
178480
|
-
if (
|
|
178481
|
-
return
|
|
178704
|
+
if (path33.isAbsolute(filePath)) {
|
|
178705
|
+
return path33.resolve(filePath);
|
|
178482
178706
|
}
|
|
178483
178707
|
if (projectId) {
|
|
178484
178708
|
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
178485
178709
|
if (root) {
|
|
178486
178710
|
const cleaned = sanitizeFilePath(filePath);
|
|
178487
|
-
return
|
|
178711
|
+
return path33.resolve(root, cleaned);
|
|
178488
178712
|
}
|
|
178489
178713
|
return null;
|
|
178490
178714
|
}
|
|
@@ -178495,17 +178719,17 @@ class PathContainment {
|
|
|
178495
178719
|
if (projectId) {
|
|
178496
178720
|
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
178497
178721
|
if (root)
|
|
178498
|
-
roots.push(
|
|
178722
|
+
roots.push(path33.resolve(root));
|
|
178499
178723
|
}
|
|
178500
|
-
roots.push(
|
|
178724
|
+
roots.push(path33.resolve(process.cwd()));
|
|
178501
178725
|
const envRoots = (process.env.MASSA_AI_READ_FILE_ROOTS ?? "").split(":").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
178502
178726
|
for (const extra of envRoots) {
|
|
178503
|
-
roots.push(
|
|
178727
|
+
roots.push(path33.resolve(extra));
|
|
178504
178728
|
}
|
|
178505
|
-
const target =
|
|
178729
|
+
const target = path33.resolve(absoluteFilePath);
|
|
178506
178730
|
for (const root of roots) {
|
|
178507
|
-
const rel =
|
|
178508
|
-
if (rel !== "" && !rel.startsWith("..") && !
|
|
178731
|
+
const rel = path33.relative(root, target);
|
|
178732
|
+
if (rel !== "" && !rel.startsWith("..") && !path33.isAbsolute(rel)) {
|
|
178509
178733
|
return { allowed: true };
|
|
178510
178734
|
}
|
|
178511
178735
|
if (rel === "")
|
|
@@ -179342,8 +179566,8 @@ init_event_bus();
|
|
|
179342
179566
|
init_llm_client();
|
|
179343
179567
|
init_symbol_graph_service();
|
|
179344
179568
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
179345
|
-
import
|
|
179346
|
-
import
|
|
179569
|
+
import fs23 from "fs";
|
|
179570
|
+
import path36 from "path";
|
|
179347
179571
|
import { spawn as spawn2 } from "child_process";
|
|
179348
179572
|
var FALLBACK_BOOTSTRAP = {
|
|
179349
179573
|
enabled: true,
|
|
@@ -179527,9 +179751,9 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
179527
179751
|
}
|
|
179528
179752
|
try {
|
|
179529
179753
|
for (const name26 of README_CANDIDATES) {
|
|
179530
|
-
const p =
|
|
179531
|
-
if (
|
|
179532
|
-
const buf =
|
|
179754
|
+
const p = path36.join(projectRoot, name26);
|
|
179755
|
+
if (fs23.existsSync(p) && fs23.statSync(p).isFile()) {
|
|
179756
|
+
const buf = fs23.readFileSync(p);
|
|
179533
179757
|
signals.readme = buf.slice(0, MAX_README_BYTES).toString("utf8");
|
|
179534
179758
|
break;
|
|
179535
179759
|
}
|
|
@@ -179538,14 +179762,14 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
179538
179762
|
logger.debug("bootstrap scan: README read failed", { error: e.message });
|
|
179539
179763
|
}
|
|
179540
179764
|
try {
|
|
179541
|
-
const docsDir =
|
|
179542
|
-
if (
|
|
179765
|
+
const docsDir = path36.join(projectRoot, "docs");
|
|
179766
|
+
if (fs23.existsSync(docsDir) && fs23.statSync(docsDir).isDirectory()) {
|
|
179543
179767
|
const entries = walkMarkdown(docsDir).slice(0, MAX_DOCS);
|
|
179544
179768
|
for (const rel of entries) {
|
|
179545
179769
|
try {
|
|
179546
|
-
const buf =
|
|
179770
|
+
const buf = fs23.readFileSync(rel);
|
|
179547
179771
|
signals.docs.push({
|
|
179548
|
-
path:
|
|
179772
|
+
path: path36.relative(projectRoot, rel),
|
|
179549
179773
|
snippet: buf.slice(0, MAX_DOC_BYTES).toString("utf8")
|
|
179550
179774
|
});
|
|
179551
179775
|
} catch {}
|
|
@@ -179556,10 +179780,10 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
179556
179780
|
}
|
|
179557
179781
|
try {
|
|
179558
179782
|
for (const name26 of MANIFEST_FILES) {
|
|
179559
|
-
const p =
|
|
179560
|
-
if (!
|
|
179783
|
+
const p = path36.join(projectRoot, name26);
|
|
179784
|
+
if (!fs23.existsSync(p) || !fs23.statSync(p).isFile())
|
|
179561
179785
|
continue;
|
|
179562
|
-
const raw2 =
|
|
179786
|
+
const raw2 = fs23.readFileSync(p).slice(0, MAX_MANIFEST_BYTES).toString("utf8");
|
|
179563
179787
|
const kind = name26;
|
|
179564
179788
|
if (name26 === "package.json") {
|
|
179565
179789
|
try {
|
|
@@ -179599,12 +179823,12 @@ function walkMarkdown(dir) {
|
|
|
179599
179823
|
const cur = stack.pop();
|
|
179600
179824
|
let entries;
|
|
179601
179825
|
try {
|
|
179602
|
-
entries =
|
|
179826
|
+
entries = fs23.readdirSync(cur, { withFileTypes: true });
|
|
179603
179827
|
} catch {
|
|
179604
179828
|
continue;
|
|
179605
179829
|
}
|
|
179606
179830
|
for (const e of entries) {
|
|
179607
|
-
const full =
|
|
179831
|
+
const full = path36.join(cur, e.name);
|
|
179608
179832
|
if (e.isDirectory()) {
|
|
179609
179833
|
if (e.name === "node_modules" || e.name.startsWith("."))
|
|
179610
179834
|
continue;
|
|
@@ -180765,8 +180989,8 @@ var checkpointRoutes = new Elysia({ prefix: "/api/v1/checkpoints" }).post("/list
|
|
|
180765
180989
|
|
|
180766
180990
|
// src/routes/project.ts
|
|
180767
180991
|
init_dist();
|
|
180768
|
-
import
|
|
180769
|
-
import
|
|
180992
|
+
import fs24 from "fs/promises";
|
|
180993
|
+
import path37 from "path";
|
|
180770
180994
|
function isDimensionMismatchError(error51) {
|
|
180771
180995
|
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
180772
180996
|
return /dimension mismatch/i.test(message);
|
|
@@ -180986,22 +181210,22 @@ var projectRoutes = new Elysia({ prefix: "/api/v1/project" }).get("/list", async
|
|
|
180986
181210
|
}).post("/upload-and-index", async ({ body }) => {
|
|
180987
181211
|
const rawBase = body.projectId || body.projectPath.replace(/\\/g, "/").split("/").filter(Boolean).pop() || "default";
|
|
180988
181212
|
const finalProjectId = rawBase.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 128);
|
|
180989
|
-
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR ||
|
|
180990
|
-
const stagingDir =
|
|
180991
|
-
await
|
|
180992
|
-
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 });
|
|
180993
181217
|
const WRITE_BATCH = 20;
|
|
180994
181218
|
for (let i = 0;i < body.files.length; i += WRITE_BATCH) {
|
|
180995
181219
|
await Promise.all(body.files.slice(i, i + WRITE_BATCH).map(async (file3) => {
|
|
180996
|
-
if (
|
|
181220
|
+
if (path37.isAbsolute(file3.relativePath) || file3.relativePath.includes("..")) {
|
|
180997
181221
|
throw new Error(`Invalid file path: ${file3.relativePath}`);
|
|
180998
181222
|
}
|
|
180999
|
-
const dest =
|
|
181000
|
-
if (!dest.startsWith(stagingDir +
|
|
181223
|
+
const dest = path37.resolve(stagingDir, file3.relativePath.replace(/\//g, path37.sep));
|
|
181224
|
+
if (!dest.startsWith(stagingDir + path37.sep)) {
|
|
181001
181225
|
throw new Error(`Path escapes staging directory: ${file3.relativePath}`);
|
|
181002
181226
|
}
|
|
181003
|
-
await
|
|
181004
|
-
await
|
|
181227
|
+
await fs24.mkdir(path37.dirname(dest), { recursive: true });
|
|
181228
|
+
await fs24.writeFile(dest, file3.content, "utf-8");
|
|
181005
181229
|
}));
|
|
181006
181230
|
}
|
|
181007
181231
|
return await getIndexProjectTool().handle({
|
|
@@ -181157,9 +181381,9 @@ var analyticsRoutes = new Elysia({ prefix: "/api/v1/analytics" }).post("/", asyn
|
|
|
181157
181381
|
init_dist();
|
|
181158
181382
|
init_config();
|
|
181159
181383
|
init_inference_providers();
|
|
181160
|
-
import
|
|
181161
|
-
import
|
|
181162
|
-
import
|
|
181384
|
+
import path38 from "path";
|
|
181385
|
+
import fs25 from "fs";
|
|
181386
|
+
import os10 from "os";
|
|
181163
181387
|
function resolveConfiguredOllamaEmbeddingModel() {
|
|
181164
181388
|
return process.env.OLLAMA_EMBEDDING_MODEL || loadRawUserConfig().embedding?.model || INFERENCE_PROVIDERS.ollama.defaultModels.embedding;
|
|
181165
181389
|
}
|
|
@@ -181193,13 +181417,13 @@ var systemRoutes = new Elysia({ prefix: "/api/v1/system" }).get("/info", async (
|
|
|
181193
181417
|
version: "1.0.0",
|
|
181194
181418
|
service: "massa-ai-tools-api",
|
|
181195
181419
|
node: process.version,
|
|
181196
|
-
platform:
|
|
181197
|
-
arch:
|
|
181420
|
+
platform: os10.platform(),
|
|
181421
|
+
arch: os10.arch(),
|
|
181198
181422
|
uptime: process.uptime(),
|
|
181199
181423
|
memory: {
|
|
181200
|
-
total:
|
|
181201
|
-
free:
|
|
181202
|
-
used:
|
|
181424
|
+
total: os10.totalmem(),
|
|
181425
|
+
free: os10.freemem(),
|
|
181426
|
+
used: os10.totalmem() - os10.freemem(),
|
|
181203
181427
|
process: process.memoryUsage()
|
|
181204
181428
|
},
|
|
181205
181429
|
dataDir: config.get("dataDir"),
|
|
@@ -181235,11 +181459,11 @@ var systemRoutes = new Elysia({ prefix: "/api/v1/system" }).get("/info", async (
|
|
|
181235
181459
|
description: "Check PostgreSQL, pgvector, Ollama, and local artifact directory health"
|
|
181236
181460
|
}
|
|
181237
181461
|
}).get("/metrics", async () => {
|
|
181238
|
-
const metricsPath =
|
|
181462
|
+
const metricsPath = path38.join(process.cwd(), "data", "metrics.json");
|
|
181239
181463
|
let metrics2 = {};
|
|
181240
|
-
if (
|
|
181464
|
+
if (fs25.existsSync(metricsPath)) {
|
|
181241
181465
|
try {
|
|
181242
|
-
metrics2 = JSON.parse(
|
|
181466
|
+
metrics2 = JSON.parse(fs25.readFileSync(metricsPath, "utf-8"));
|
|
181243
181467
|
} catch {}
|
|
181244
181468
|
}
|
|
181245
181469
|
const database = await getDatabaseInfo();
|
|
@@ -181433,8 +181657,8 @@ var eventsRoutes = new Elysia({ prefix: "/api/v1" }).get("/events", async ({ que
|
|
|
181433
181657
|
});
|
|
181434
181658
|
|
|
181435
181659
|
// src/routes/workspace.ts
|
|
181436
|
-
import
|
|
181437
|
-
import
|
|
181660
|
+
import fs26 from "fs/promises";
|
|
181661
|
+
import path39 from "path";
|
|
181438
181662
|
import { realpathSync as realpathSync4 } from "fs";
|
|
181439
181663
|
var indexProjectTool2 = null;
|
|
181440
181664
|
function getIndexProjectTool2() {
|
|
@@ -181476,7 +181700,7 @@ function realpathSafe(p) {
|
|
|
181476
181700
|
try {
|
|
181477
181701
|
return realpathSync4(p);
|
|
181478
181702
|
} catch {
|
|
181479
|
-
return
|
|
181703
|
+
return path39.resolve(p);
|
|
181480
181704
|
}
|
|
181481
181705
|
}
|
|
181482
181706
|
var graphController = null;
|
|
@@ -181827,8 +182051,8 @@ var workspaceRoutes = new Elysia({ prefix: "/api/v1" }).get("/workspace/list", a
|
|
|
181827
182051
|
}
|
|
181828
182052
|
const registeredRoot = realpathSafe(workspace.project_path);
|
|
181829
182053
|
const callerRoot = realpathSafe(projectPath2);
|
|
181830
|
-
const rel =
|
|
181831
|
-
const escapes = rel.startsWith("..") ||
|
|
182054
|
+
const rel = path39.relative(registeredRoot, callerRoot);
|
|
182055
|
+
const escapes = rel.startsWith("..") || path39.isAbsolute(rel);
|
|
181832
182056
|
if (registeredRoot !== callerRoot && escapes) {
|
|
181833
182057
|
return {
|
|
181834
182058
|
success: false,
|
|
@@ -181958,8 +182182,8 @@ var workspaceRoutes = new Elysia({ prefix: "/api/v1" }).get("/workspace/list", a
|
|
|
181958
182182
|
} else {
|
|
181959
182183
|
end = start + 20;
|
|
181960
182184
|
}
|
|
181961
|
-
const absolutePath =
|
|
181962
|
-
const content = await
|
|
182185
|
+
const absolutePath = path39.join(workspace.project_path, file3);
|
|
182186
|
+
const content = await fs26.readFile(absolutePath, "utf-8");
|
|
181963
182187
|
const lines = content.split(/\r?\n/);
|
|
181964
182188
|
const slice = lines.slice(start - 1, Math.min(lines.length, end));
|
|
181965
182189
|
const formatted = slice.map((text3, idx) => ({
|
|
@@ -183210,8 +183434,8 @@ var webRoutes = new Elysia({ prefix: "/api/v1/web" }).post("/fetch_and_index", a
|
|
|
183210
183434
|
});
|
|
183211
183435
|
|
|
183212
183436
|
// src/routes/web-ui.ts
|
|
183213
|
-
import
|
|
183214
|
-
import
|
|
183437
|
+
import fs27 from "fs/promises";
|
|
183438
|
+
import path40 from "path";
|
|
183215
183439
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
183216
183440
|
|
|
183217
183441
|
// src/web-ui-trust.ts
|
|
@@ -183255,9 +183479,9 @@ function buildStaticDirCandidates(moduleDir, cwd) {
|
|
|
183255
183479
|
for (const root2 of [moduleDir, cwd]) {
|
|
183256
183480
|
let dir = root2;
|
|
183257
183481
|
for (let i = 0;i < 10; i++) {
|
|
183258
|
-
candidates2.push(
|
|
183259
|
-
candidates2.push(
|
|
183260
|
-
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);
|
|
183261
183485
|
if (parent === dir)
|
|
183262
183486
|
break;
|
|
183263
183487
|
dir = parent;
|
|
@@ -183265,11 +183489,11 @@ function buildStaticDirCandidates(moduleDir, cwd) {
|
|
|
183265
183489
|
}
|
|
183266
183490
|
return [...new Set(candidates2)];
|
|
183267
183491
|
}
|
|
183268
|
-
var STATIC_DIR_CANDIDATES = buildStaticDirCandidates(
|
|
183492
|
+
var STATIC_DIR_CANDIDATES = buildStaticDirCandidates(path40.dirname(fileURLToPath3(import.meta.url)), process.cwd());
|
|
183269
183493
|
async function resolveStaticDir() {
|
|
183270
183494
|
for (const dir of STATIC_DIR_CANDIDATES) {
|
|
183271
183495
|
try {
|
|
183272
|
-
const st = await
|
|
183496
|
+
const st = await fs27.stat(dir);
|
|
183273
183497
|
if (st.isDirectory())
|
|
183274
183498
|
return dir;
|
|
183275
183499
|
} catch {}
|
|
@@ -183290,7 +183514,7 @@ var CONTENT_TYPES = {
|
|
|
183290
183514
|
".woff2": "font/woff2"
|
|
183291
183515
|
};
|
|
183292
183516
|
function contentTypeFor(filePath) {
|
|
183293
|
-
const ext2 =
|
|
183517
|
+
const ext2 = path40.extname(filePath).toLowerCase();
|
|
183294
183518
|
return CONTENT_TYPES[ext2] ?? "application/octet-stream";
|
|
183295
183519
|
}
|
|
183296
183520
|
function webUiDisabled() {
|
|
@@ -183301,13 +183525,13 @@ function webUiDisabled() {
|
|
|
183301
183525
|
}
|
|
183302
183526
|
async function resolveSafePath(staticDir, sub) {
|
|
183303
183527
|
const cleaned = sub.replace(/^\/+/, "");
|
|
183304
|
-
const abs =
|
|
183305
|
-
const rel =
|
|
183306
|
-
if (rel.startsWith("..") ||
|
|
183528
|
+
const abs = path40.resolve(staticDir, cleaned);
|
|
183529
|
+
const rel = path40.relative(staticDir, abs);
|
|
183530
|
+
if (rel.startsWith("..") || path40.isAbsolute(rel)) {
|
|
183307
183531
|
return null;
|
|
183308
183532
|
}
|
|
183309
183533
|
try {
|
|
183310
|
-
await
|
|
183534
|
+
await fs27.stat(abs);
|
|
183311
183535
|
return { abs, exists: true };
|
|
183312
183536
|
} catch {
|
|
183313
183537
|
return { abs, exists: false };
|
|
@@ -183330,7 +183554,7 @@ function injectAccessMarkup(html, apiKey, trusted) {
|
|
|
183330
183554
|
return out;
|
|
183331
183555
|
}
|
|
183332
183556
|
async function readShell(indexPath, remoteAddress) {
|
|
183333
|
-
const raw2 = await
|
|
183557
|
+
const raw2 = await fs27.readFile(indexPath, "utf-8");
|
|
183334
183558
|
const trusted = isTrustedWebUiCaller(remoteAddress);
|
|
183335
183559
|
return Buffer.from(injectAccessMarkup(raw2, getConfiguredApiKey(), trusted), "utf-8");
|
|
183336
183560
|
}
|
|
@@ -183347,7 +183571,7 @@ var webUiRoutes = new Elysia().get("/ui", async ({ set: set3, request }) => {
|
|
|
183347
183571
|
set3.status = 500;
|
|
183348
183572
|
return { status: 500, error: "web ui static dir not found" };
|
|
183349
183573
|
}
|
|
183350
|
-
const indexPath =
|
|
183574
|
+
const indexPath = path40.join(dir, "index.html");
|
|
183351
183575
|
try {
|
|
183352
183576
|
const body = await readShell(indexPath, remoteAddressOf(request));
|
|
183353
183577
|
set3.headers["content-type"] = contentTypeFor(indexPath);
|
|
@@ -183380,7 +183604,7 @@ var webUiRoutes = new Elysia().get("/ui", async ({ set: set3, request }) => {
|
|
|
183380
183604
|
}
|
|
183381
183605
|
if (resolved.exists) {
|
|
183382
183606
|
try {
|
|
183383
|
-
const body = await
|
|
183607
|
+
const body = await fs27.readFile(resolved.abs);
|
|
183384
183608
|
set3.headers["content-type"] = contentTypeFor(resolved.abs);
|
|
183385
183609
|
return body;
|
|
183386
183610
|
} catch {
|
|
@@ -183389,7 +183613,7 @@ var webUiRoutes = new Elysia().get("/ui", async ({ set: set3, request }) => {
|
|
|
183389
183613
|
}
|
|
183390
183614
|
}
|
|
183391
183615
|
try {
|
|
183392
|
-
const body = await readShell(
|
|
183616
|
+
const body = await readShell(path40.join(dir, "index.html"), remoteAddressOf(request));
|
|
183393
183617
|
set3.headers["content-type"] = "text/html; charset=utf-8";
|
|
183394
183618
|
return body;
|
|
183395
183619
|
} catch {
|
|
@@ -183537,8 +183761,8 @@ init_dist();
|
|
|
183537
183761
|
|
|
183538
183762
|
// src/routes/model-registry-deployment.ts
|
|
183539
183763
|
init_dist();
|
|
183540
|
-
import
|
|
183541
|
-
var MARKER =
|
|
183764
|
+
import path41 from "path";
|
|
183765
|
+
var MARKER = path41.join("scripts", "generate-subagent-artifacts.ts");
|
|
183542
183766
|
var MAX_LEVELS2 = 6;
|
|
183543
183767
|
var cachedRoot;
|
|
183544
183768
|
function findDeploymentRoot(startDir) {
|
|
@@ -183556,8 +183780,8 @@ function deploymentUnavailableMessage(what) {
|
|
|
183556
183780
|
|
|
183557
183781
|
// src/routes/model-registry.ts
|
|
183558
183782
|
init_config();
|
|
183559
|
-
import
|
|
183560
|
-
import
|
|
183783
|
+
import fs28 from "fs";
|
|
183784
|
+
import path42 from "path";
|
|
183561
183785
|
import { spawnSync } from "child_process";
|
|
183562
183786
|
var _profilesLib = null;
|
|
183563
183787
|
function profilesLib() {
|
|
@@ -183566,7 +183790,7 @@ function profilesLib() {
|
|
|
183566
183790
|
if (!root2) {
|
|
183567
183791
|
throw new Error(deploymentUnavailableMessage("scripts/lib/model-profiles.ts"));
|
|
183568
183792
|
}
|
|
183569
|
-
const libPath =
|
|
183793
|
+
const libPath = path42.join(root2, "scripts", "lib", "model-profiles.ts");
|
|
183570
183794
|
_profilesLib = __require(libPath);
|
|
183571
183795
|
}
|
|
183572
183796
|
return _profilesLib;
|
|
@@ -183591,7 +183815,7 @@ function generatorLib() {
|
|
|
183591
183815
|
if (!root2) {
|
|
183592
183816
|
throw new Error(deploymentUnavailableMessage("scripts/generate-subagent-artifacts.ts"));
|
|
183593
183817
|
}
|
|
183594
|
-
const libPath =
|
|
183818
|
+
const libPath = path42.join(root2, "scripts", "generate-subagent-artifacts.ts");
|
|
183595
183819
|
_generatorLib = __require(libPath);
|
|
183596
183820
|
}
|
|
183597
183821
|
return _generatorLib;
|
|
@@ -183608,7 +183832,7 @@ async function loadAgentsInventory() {
|
|
|
183608
183832
|
var REGISTRY_DETAIL = {
|
|
183609
183833
|
tags: ["model-registry"]
|
|
183610
183834
|
};
|
|
183611
|
-
var OVERLAY_PATH =
|
|
183835
|
+
var OVERLAY_PATH = path42.join(configDir("massa-ai"), "model-profiles.json");
|
|
183612
183836
|
var ZERO_OVERLAY_OVERRIDE_BREAKDOWN = {
|
|
183613
183837
|
hostDefaults: 0,
|
|
183614
183838
|
workflowTiers: 0,
|
|
@@ -183700,7 +183924,7 @@ var modelRegistryRoutes = new Elysia({ prefix: "/api/v1/model-registry" }).get("
|
|
|
183700
183924
|
set3.status = 501;
|
|
183701
183925
|
return { success: false, error: deploymentUnavailableMessage("scripts/generate-subagent-artifacts.ts") };
|
|
183702
183926
|
}
|
|
183703
|
-
const generateScript =
|
|
183927
|
+
const generateScript = path42.join(root2, "scripts", "generate-subagent-artifacts.ts");
|
|
183704
183928
|
try {
|
|
183705
183929
|
const child = spawnSync("bun", [generateScript], {
|
|
183706
183930
|
env: { ...process.env },
|
|
@@ -183739,8 +183963,8 @@ var modelRegistryRoutes = new Elysia({ prefix: "/api/v1/model-registry" }).get("
|
|
|
183739
183963
|
}
|
|
183740
183964
|
const lib = profilesLib();
|
|
183741
183965
|
try {
|
|
183742
|
-
if (
|
|
183743
|
-
|
|
183966
|
+
if (fs28.existsSync(OVERLAY_PATH)) {
|
|
183967
|
+
fs28.unlinkSync(OVERLAY_PATH);
|
|
183744
183968
|
}
|
|
183745
183969
|
const builtin = lib.loadRegistry(lib.DEFAULT_REGISTRY_PATH);
|
|
183746
183970
|
set3.status = 200;
|
|
@@ -183766,17 +183990,17 @@ var modelRegistryRoutes = new Elysia({ prefix: "/api/v1/model-registry" }).get("
|
|
|
183766
183990
|
}
|
|
183767
183991
|
});
|
|
183768
183992
|
function writeOverlayAtomically(overlayPath, data) {
|
|
183769
|
-
const dir =
|
|
183770
|
-
if (!
|
|
183771
|
-
|
|
183993
|
+
const dir = path42.dirname(overlayPath);
|
|
183994
|
+
if (!fs28.existsSync(dir)) {
|
|
183995
|
+
fs28.mkdirSync(dir, { recursive: true });
|
|
183772
183996
|
}
|
|
183773
183997
|
const tmp = `${overlayPath}.${process.pid}.${Date.now()}.tmp`;
|
|
183774
183998
|
try {
|
|
183775
|
-
|
|
183776
|
-
|
|
183999
|
+
fs28.writeFileSync(tmp, JSON.stringify(data, null, 2));
|
|
184000
|
+
fs28.renameSync(tmp, overlayPath);
|
|
183777
184001
|
} catch (e) {
|
|
183778
184002
|
try {
|
|
183779
|
-
|
|
184003
|
+
fs28.unlinkSync(tmp);
|
|
183780
184004
|
} catch {}
|
|
183781
184005
|
throw e;
|
|
183782
184006
|
}
|
|
@@ -183870,9 +184094,14 @@ var profileRoutes = new Elysia({ prefix: "/api/v1/profiles" }).get("/", ({ query
|
|
|
183870
184094
|
|
|
183871
184095
|
// src/routes/config.ts
|
|
183872
184096
|
init_dist();
|
|
184097
|
+
init_inference_providers();
|
|
183873
184098
|
var CONFIG_DETAIL = {
|
|
183874
184099
|
tags: ["config"]
|
|
183875
184100
|
};
|
|
184101
|
+
function defaultEmbedBatchSize(provider) {
|
|
184102
|
+
const spec = typeof provider === "string" && LOCAL_INFERENCE_IDS.includes(provider) ? INFERENCE_PROVIDERS[provider] : INFERENCE_PROVIDERS.ollama;
|
|
184103
|
+
return spec.embedBatchSize;
|
|
184104
|
+
}
|
|
183876
184105
|
var SENSITIVE_FIELDS = {
|
|
183877
184106
|
database: ["url"],
|
|
183878
184107
|
embedding: ["apiKey"],
|
|
@@ -183897,7 +184126,15 @@ var configRoutes = new Elysia({ prefix: "/api/v1/config" }).get("/", ({ set: set
|
|
|
183897
184126
|
const config3 = loadConfig();
|
|
183898
184127
|
const masked = maskSensitive(config3);
|
|
183899
184128
|
const restart = restartNeededSections(config3);
|
|
183900
|
-
const
|
|
184129
|
+
const shipped = maskSensitive(defaultMassaAiConfig);
|
|
184130
|
+
const defaults2 = {
|
|
184131
|
+
...shipped,
|
|
184132
|
+
embedding: {
|
|
184133
|
+
...shipped.embedding,
|
|
184134
|
+
contextWindow: INFERENCE_ROLE_DEFAULTS.embedding.contextWindow,
|
|
184135
|
+
batchSize: defaultEmbedBatchSize(config3.embedding?.provider)
|
|
184136
|
+
}
|
|
184137
|
+
};
|
|
183901
184138
|
set3.status = 200;
|
|
183902
184139
|
return {
|
|
183903
184140
|
success: true,
|
|
@@ -183907,7 +184144,7 @@ var configRoutes = new Elysia({ prefix: "/api/v1/config" }).get("/", ({ set: set
|
|
|
183907
184144
|
detail: {
|
|
183908
184145
|
...CONFIG_DETAIL,
|
|
183909
184146
|
summary: "Get current config with sensitive fields masked",
|
|
183910
|
-
description: "Returns the current config.json with security.apiKey, llm.apiKey, embedding.apiKey, and database.url masked to '***'. Includes restartNeededSections \u2014 the subset of [database, embedding, llm, security] present in the config \u2014 and defaults, the shipped default config (also masked) the Config tab falls back to for any field the persisted file omits."
|
|
184147
|
+
description: "Returns the current config.json with security.apiKey, llm.apiKey, embedding.apiKey, and database.url masked to '***'. Includes restartNeededSections \u2014 the subset of [database, embedding, llm, security] present in the config \u2014 and defaults, the shipped default config (also masked) the Config tab falls back to for any field the persisted file omits. defaults.embedding.contextWindow and defaults.embedding.batchSize are derived rather than shipped: they come from the role table and the resolved provider's seam entry, because defaultMassaAiConfig deliberately leaves both unset (PDM-12)."
|
|
183911
184148
|
}
|
|
183912
184149
|
}).get("/reveal", ({ query, set: set3 }) => {
|
|
183913
184150
|
const section = query.section;
|
|
@@ -183967,8 +184204,8 @@ var configRoutes = new Elysia({ prefix: "/api/v1/config" }).get("/", ({ set: set
|
|
|
183967
184204
|
// src/routes/model-registry-stream.ts
|
|
183968
184205
|
init_config();
|
|
183969
184206
|
init_dist();
|
|
183970
|
-
import
|
|
183971
|
-
import
|
|
184207
|
+
import fs29 from "fs";
|
|
184208
|
+
import path43 from "path";
|
|
183972
184209
|
import { spawn as spawn3 } from "child_process";
|
|
183973
184210
|
var encoder3 = new TextEncoder;
|
|
183974
184211
|
function sseFrame(data) {
|
|
@@ -183980,10 +184217,10 @@ var KNOWN_GENERATOR_FILENAMES = ["generate-skill-artifacts.ts", "generate-subage
|
|
|
183980
184217
|
var SH_C_WRAPPER = /^sh -c '(.*)' --$/;
|
|
183981
184218
|
var GENERATOR_SEGMENT = /^bun\s+(\S+\.ts)(?:\s+"\$@")?$/;
|
|
183982
184219
|
function deriveGeneratorScripts(root2) {
|
|
183983
|
-
const pkgPath =
|
|
184220
|
+
const pkgPath = path43.join(root2, "package.json");
|
|
183984
184221
|
let raw2;
|
|
183985
184222
|
try {
|
|
183986
|
-
raw2 =
|
|
184223
|
+
raw2 = fs29.readFileSync(pkgPath, "utf-8");
|
|
183987
184224
|
} catch (e) {
|
|
183988
184225
|
throw new Error(`cannot read ${pkgPath}: ${e.message}`);
|
|
183989
184226
|
}
|
|
@@ -184010,7 +184247,7 @@ function deriveGeneratorScripts(root2) {
|
|
|
184010
184247
|
throw new Error(`"generate:artifacts" segment does not match the expected "bun <script.ts>" shape: ${JSON.stringify(segment)}`);
|
|
184011
184248
|
}
|
|
184012
184249
|
const relPath = match2[1];
|
|
184013
|
-
return { relPath, name:
|
|
184250
|
+
return { relPath, name: path43.basename(relPath) };
|
|
184014
184251
|
});
|
|
184015
184252
|
}
|
|
184016
184253
|
function assertGeneratorBackstop(scripts) {
|
|
@@ -184162,7 +184399,7 @@ function createRegenerateStreamHandler() {
|
|
|
184162
184399
|
return;
|
|
184163
184400
|
}
|
|
184164
184401
|
const generator = generatorScripts[index];
|
|
184165
|
-
const scriptPath =
|
|
184402
|
+
const scriptPath = path43.join(root2, generator.relPath);
|
|
184166
184403
|
try {
|
|
184167
184404
|
child = spawn3("bun", [scriptPath], {
|
|
184168
184405
|
env: { ...process.env },
|
|
@@ -184320,7 +184557,7 @@ var restartRoutes = new Elysia({ prefix: "/api/v1/system" }).onAfterResponse(()
|
|
|
184320
184557
|
|
|
184321
184558
|
// src/routes/logs.ts
|
|
184322
184559
|
init_dist();
|
|
184323
|
-
import
|
|
184560
|
+
import fs30 from "fs";
|
|
184324
184561
|
var LOGS_DETAIL = { tags: ["logs"] };
|
|
184325
184562
|
var MAX_SCAN_BYTES = 64 * 1024 * 1024;
|
|
184326
184563
|
var MAX_LIMIT = 1000;
|
|
@@ -184400,7 +184637,7 @@ function parseLine(line, prevTs) {
|
|
|
184400
184637
|
function realReadTail(filePath, maxBytes) {
|
|
184401
184638
|
let size;
|
|
184402
184639
|
try {
|
|
184403
|
-
size =
|
|
184640
|
+
size = fs30.statSync(filePath).size;
|
|
184404
184641
|
} catch {
|
|
184405
184642
|
return { content: "", truncated: false };
|
|
184406
184643
|
}
|
|
@@ -184408,24 +184645,24 @@ function realReadTail(filePath, maxBytes) {
|
|
|
184408
184645
|
return { content: "", truncated: false };
|
|
184409
184646
|
if (size <= maxBytes) {
|
|
184410
184647
|
try {
|
|
184411
|
-
return { content:
|
|
184648
|
+
return { content: fs30.readFileSync(filePath, "utf8"), truncated: false };
|
|
184412
184649
|
} catch {
|
|
184413
184650
|
return { content: "", truncated: false };
|
|
184414
184651
|
}
|
|
184415
184652
|
}
|
|
184416
184653
|
try {
|
|
184417
|
-
const fd =
|
|
184654
|
+
const fd = fs30.openSync(filePath, "r");
|
|
184418
184655
|
try {
|
|
184419
184656
|
const start = size - maxBytes;
|
|
184420
184657
|
const buf = Buffer.alloc(maxBytes);
|
|
184421
|
-
|
|
184658
|
+
fs30.readSync(fd, buf, 0, maxBytes, start);
|
|
184422
184659
|
let text3 = buf.toString("utf8");
|
|
184423
184660
|
const firstNewline = text3.indexOf(`
|
|
184424
184661
|
`);
|
|
184425
184662
|
text3 = firstNewline !== -1 ? text3.slice(firstNewline + 1) : "";
|
|
184426
184663
|
return { content: text3, truncated: true };
|
|
184427
184664
|
} finally {
|
|
184428
|
-
|
|
184665
|
+
fs30.closeSync(fd);
|
|
184429
184666
|
}
|
|
184430
184667
|
} catch {
|
|
184431
184668
|
return { content: "", truncated: true };
|
|
@@ -184435,7 +184672,7 @@ var realReader = {
|
|
|
184435
184672
|
listFiles(filePath, maxFiles) {
|
|
184436
184673
|
return sinkFiles(filePath, maxFiles).filter((f) => {
|
|
184437
184674
|
try {
|
|
184438
|
-
|
|
184675
|
+
fs30.accessSync(f, fs30.constants.R_OK);
|
|
184439
184676
|
return true;
|
|
184440
184677
|
} catch {
|
|
184441
184678
|
return false;
|
|
@@ -184524,7 +184761,7 @@ function startSinkTail(enqueue) {
|
|
|
184524
184761
|
let currentFile = initial[0];
|
|
184525
184762
|
let offset;
|
|
184526
184763
|
try {
|
|
184527
|
-
offset =
|
|
184764
|
+
offset = fs30.statSync(currentFile).size;
|
|
184528
184765
|
} catch {
|
|
184529
184766
|
return;
|
|
184530
184767
|
}
|
|
@@ -184540,7 +184777,7 @@ function startSinkTail(enqueue) {
|
|
|
184540
184777
|
offset = 0;
|
|
184541
184778
|
carry = "";
|
|
184542
184779
|
}
|
|
184543
|
-
const size =
|
|
184780
|
+
const size = fs30.statSync(currentFile).size;
|
|
184544
184781
|
if (size < offset) {
|
|
184545
184782
|
offset = 0;
|
|
184546
184783
|
carry = "";
|
|
@@ -184549,11 +184786,11 @@ function startSinkTail(enqueue) {
|
|
|
184549
184786
|
return;
|
|
184550
184787
|
const length = Math.min(size - offset, SINK_POLL_MAX_BYTES);
|
|
184551
184788
|
const buf = Buffer.alloc(length);
|
|
184552
|
-
const fd =
|
|
184789
|
+
const fd = fs30.openSync(currentFile, "r");
|
|
184553
184790
|
try {
|
|
184554
|
-
|
|
184791
|
+
fs30.readSync(fd, buf, 0, length, offset);
|
|
184555
184792
|
} finally {
|
|
184556
|
-
|
|
184793
|
+
fs30.closeSync(fd);
|
|
184557
184794
|
}
|
|
184558
184795
|
offset += length;
|
|
184559
184796
|
const text3 = carry + buf.toString("utf8");
|
|
@@ -184753,12 +184990,12 @@ var READ_ONLY_ROUTES = [
|
|
|
184753
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."
|
|
184754
184991
|
}
|
|
184755
184992
|
];
|
|
184756
|
-
function normalizeRoutePath(
|
|
184757
|
-
return
|
|
184993
|
+
function normalizeRoutePath(path44) {
|
|
184994
|
+
return path44.length > 1 && path44.endsWith("/") ? path44.slice(0, -1) : path44;
|
|
184758
184995
|
}
|
|
184759
184996
|
var READ_ONLY_INDEX = new Map(READ_ONLY_ROUTES.map((entry2) => [`${entry2.method} ${entry2.path}`, entry2]));
|
|
184760
|
-
function findReadOnlyRoute(method,
|
|
184761
|
-
return READ_ONLY_INDEX.get(`${method.toUpperCase()} ${normalizeRoutePath(
|
|
184997
|
+
function findReadOnlyRoute(method, path44) {
|
|
184998
|
+
return READ_ONLY_INDEX.get(`${method.toUpperCase()} ${normalizeRoutePath(path44)}`);
|
|
184762
184999
|
}
|
|
184763
185000
|
|
|
184764
185001
|
// src/middleware/write-mode.ts
|
|
@@ -184777,14 +185014,14 @@ var WRITE_REFUSED = {
|
|
|
184777
185014
|
success: false,
|
|
184778
185015
|
error: "Write refused: read-only mode is active"
|
|
184779
185016
|
};
|
|
184780
|
-
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 }) => {
|
|
184781
185018
|
if (request.method.toUpperCase() === "GET")
|
|
184782
185019
|
return;
|
|
184783
|
-
if (isPublicPath(
|
|
185020
|
+
if (isPublicPath(path44))
|
|
184784
185021
|
return;
|
|
184785
185022
|
if (!isReadOnlyModeActive())
|
|
184786
185023
|
return;
|
|
184787
|
-
const entry2 = findReadOnlyRoute(request.method,
|
|
185024
|
+
const entry2 = findReadOnlyRoute(request.method, path44);
|
|
184788
185025
|
if (entry2) {
|
|
184789
185026
|
if (entry2.sanitizeBody && body && typeof body === "object") {
|
|
184790
185027
|
entry2.sanitizeBody(body);
|
|
@@ -184797,11 +185034,11 @@ var writeModeMiddleware = new Elysia({ name: "write-mode" }).onBeforeHandle({ as
|
|
|
184797
185034
|
|
|
184798
185035
|
// src/middleware/error.ts
|
|
184799
185036
|
init_dist();
|
|
184800
|
-
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 }) => {
|
|
184801
185038
|
logger.error("[massa-ai-api] Request failed", undefined, {
|
|
184802
185039
|
...safeErrorSummary(error51),
|
|
184803
185040
|
code,
|
|
184804
|
-
path:
|
|
185041
|
+
path: path44,
|
|
184805
185042
|
method: request.method
|
|
184806
185043
|
});
|
|
184807
185044
|
if (error51 instanceof SearchServiceError) {
|