@massa-ai/mcp-client 1.60.0 → 1.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-cli.js +1019 -554
- package/dist/index.js +1013 -609
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -25994,7 +25994,7 @@ function getConfigForEnv() {
|
|
|
25994
25994
|
} else {
|
|
25995
25995
|
console.error(`[getConfigForEnv] embedding.provider "${provider}" has no env-projection branch \u2014 no embedding env vars were set`);
|
|
25996
25996
|
}
|
|
25997
|
-
env.
|
|
25997
|
+
env.MASSA_AI_LOG_LEVEL = config2.logging.level;
|
|
25998
25998
|
env.ENABLE_METRICS = String(config2.logging.enableMetrics);
|
|
25999
25999
|
return env;
|
|
26000
26000
|
}
|
|
@@ -26568,7 +26568,7 @@ var init_config = __esm(() => {
|
|
|
26568
26568
|
corsOrigins: envList("MASSA_AI_API_CORS_ORIGINS", fileConfig.security?.corsOrigins ?? [])
|
|
26569
26569
|
},
|
|
26570
26570
|
logging: {
|
|
26571
|
-
level: process.env.
|
|
26571
|
+
level: process.env.MASSA_AI_LOG_LEVEL || fileConfig.logging?.level || "info",
|
|
26572
26572
|
enableMetrics: process.env.ENABLE_METRICS === "true" || process.env.ENABLE_METRICS === undefined && !!fileConfig.logging?.enableMetrics,
|
|
26573
26573
|
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file || path4.join(resolvedDataDir, "logs", "massa-ai.log"),
|
|
26574
26574
|
enableFileSink: envBool("MASSA_AI_LOG_ENABLE_FILE_SINK", fileConfig.logging?.enableFileSink ?? true),
|
|
@@ -26901,6 +26901,32 @@ var init_log_buffer = __esm(() => {
|
|
|
26901
26901
|
});
|
|
26902
26902
|
|
|
26903
26903
|
// ../../packages/shared/dist/utils/logger.js
|
|
26904
|
+
function formatAgo(ms) {
|
|
26905
|
+
const totalSeconds = Math.floor(ms / 1000);
|
|
26906
|
+
if (totalSeconds < 60)
|
|
26907
|
+
return `${totalSeconds}s`;
|
|
26908
|
+
return `${Math.floor(totalSeconds / 60)}m`;
|
|
26909
|
+
}
|
|
26910
|
+
function capErrorText(value) {
|
|
26911
|
+
if (value.length <= MAX_ERROR_TEXT_CHARS)
|
|
26912
|
+
return value;
|
|
26913
|
+
const truncatedChars = value.length - MAX_ERROR_TEXT_CHARS;
|
|
26914
|
+
return `${value.slice(0, MAX_ERROR_TEXT_CHARS)}\u2026(truncated ${truncatedChars} chars)`;
|
|
26915
|
+
}
|
|
26916
|
+
function pickErrorFields(err, includeStack) {
|
|
26917
|
+
const out = { name: err.name, message: capErrorText(err.message) };
|
|
26918
|
+
if (includeStack)
|
|
26919
|
+
out.stack = err.stack;
|
|
26920
|
+
const code = err.code;
|
|
26921
|
+
if (code !== undefined)
|
|
26922
|
+
out.code = code;
|
|
26923
|
+
const cause = err.cause;
|
|
26924
|
+
if (cause !== undefined) {
|
|
26925
|
+
out.cause = capErrorText(cause instanceof Error ? cause.message : String(cause));
|
|
26926
|
+
}
|
|
26927
|
+
return out;
|
|
26928
|
+
}
|
|
26929
|
+
|
|
26904
26930
|
class Logger {
|
|
26905
26931
|
_level;
|
|
26906
26932
|
_enableMetrics;
|
|
@@ -26909,6 +26935,7 @@ class Logger {
|
|
|
26909
26935
|
_maxFileSizeBytes;
|
|
26910
26936
|
_maxFiles;
|
|
26911
26937
|
_initialized = false;
|
|
26938
|
+
repeats = new Map;
|
|
26912
26939
|
constructor() {}
|
|
26913
26940
|
ensureInitialized() {
|
|
26914
26941
|
if (!this._initialized) {
|
|
@@ -26969,13 +26996,70 @@ class Logger {
|
|
|
26969
26996
|
shouldLog(level) {
|
|
26970
26997
|
return level >= this.level;
|
|
26971
26998
|
}
|
|
26999
|
+
serializeMetaErrors(meta3) {
|
|
27000
|
+
if (!meta3)
|
|
27001
|
+
return meta3;
|
|
27002
|
+
let out;
|
|
27003
|
+
for (const [key, value] of Object.entries(meta3)) {
|
|
27004
|
+
if (value instanceof Error) {
|
|
27005
|
+
if (!out)
|
|
27006
|
+
out = { ...meta3 };
|
|
27007
|
+
out[key] = pickErrorFields(value, false);
|
|
27008
|
+
}
|
|
27009
|
+
}
|
|
27010
|
+
return out ?? meta3;
|
|
27011
|
+
}
|
|
27012
|
+
applyRepeatAccounting(level, message, meta3) {
|
|
27013
|
+
if (level !== LogLevel.WARN && level !== LogLevel.ERROR)
|
|
27014
|
+
return meta3;
|
|
27015
|
+
const label = typeof meta3?.label === "string" ? meta3.label : "";
|
|
27016
|
+
const key = `${level}|${message}|${label}`;
|
|
27017
|
+
const now = Date.now();
|
|
27018
|
+
const existing = this.repeats.get(key);
|
|
27019
|
+
if (!existing || now - existing.firstSeenAt > REPEAT_WINDOW_MS) {
|
|
27020
|
+
if (this.repeats.size >= MAX_REPEAT_KEYS)
|
|
27021
|
+
this.repeats.clear();
|
|
27022
|
+
this.repeats.set(key, { firstSeenAt: now, count: 1 });
|
|
27023
|
+
return meta3;
|
|
27024
|
+
}
|
|
27025
|
+
existing.count += 1;
|
|
27026
|
+
return {
|
|
27027
|
+
...meta3,
|
|
27028
|
+
occurrences: existing.count,
|
|
27029
|
+
firstSeenAgo: formatAgo(now - existing.firstSeenAt)
|
|
27030
|
+
};
|
|
27031
|
+
}
|
|
27032
|
+
_resetRepeatsForTesting() {
|
|
27033
|
+
this.repeats.clear();
|
|
27034
|
+
}
|
|
27035
|
+
safeStringifyMeta(meta3) {
|
|
27036
|
+
const seen = new WeakSet;
|
|
27037
|
+
try {
|
|
27038
|
+
return JSON.stringify(meta3, (_key, value) => {
|
|
27039
|
+
if (typeof value === "bigint")
|
|
27040
|
+
return value.toString();
|
|
27041
|
+
if (typeof value === "object" && value !== null) {
|
|
27042
|
+
if (seen.has(value))
|
|
27043
|
+
return "[Circular]";
|
|
27044
|
+
seen.add(value);
|
|
27045
|
+
}
|
|
27046
|
+
return value;
|
|
27047
|
+
});
|
|
27048
|
+
} catch (err) {
|
|
27049
|
+
return JSON.stringify({
|
|
27050
|
+
metaUnserializable: err instanceof Error ? err.message : String(err)
|
|
27051
|
+
});
|
|
27052
|
+
}
|
|
27053
|
+
}
|
|
26972
27054
|
formatMessage(level, message, meta3, timestamp = new Date().toISOString()) {
|
|
26973
|
-
const metaStr = meta3 ? ` ${
|
|
27055
|
+
const metaStr = meta3 ? ` ${this.safeStringifyMeta(meta3)}` : "";
|
|
26974
27056
|
return `[${timestamp}] [${level}] ${message}${metaStr}`;
|
|
26975
27057
|
}
|
|
26976
27058
|
emit(level, message, meta3) {
|
|
27059
|
+
const serializedMeta = this.serializeMetaErrors(meta3);
|
|
27060
|
+
const finalMeta = this.applyRepeatAccounting(level, message, serializedMeta);
|
|
26977
27061
|
const ts = new Date().toISOString();
|
|
26978
|
-
const line = this.formatMessage(LOG_LEVEL_LABELS[level], message,
|
|
27062
|
+
const line = this.formatMessage(LOG_LEVEL_LABELS[level], message, finalMeta, ts);
|
|
26979
27063
|
console.error(line);
|
|
26980
27064
|
if (this.enableFileSink) {
|
|
26981
27065
|
const filePath = this.logFilePath;
|
|
@@ -26987,7 +27071,7 @@ class Logger {
|
|
|
26987
27071
|
ts,
|
|
26988
27072
|
level: LOG_LEVEL_BUFFER_TAGS[level],
|
|
26989
27073
|
message,
|
|
26990
|
-
...
|
|
27074
|
+
...finalMeta ? { meta: finalMeta } : {}
|
|
26991
27075
|
});
|
|
26992
27076
|
}
|
|
26993
27077
|
debug(message, meta3) {
|
|
@@ -27009,11 +27093,7 @@ class Logger {
|
|
|
27009
27093
|
if (this.shouldLog(LogLevel.ERROR)) {
|
|
27010
27094
|
const errorMeta = error51 ? {
|
|
27011
27095
|
...meta3,
|
|
27012
|
-
error: {
|
|
27013
|
-
name: error51.name,
|
|
27014
|
-
message: error51.message,
|
|
27015
|
-
stack: error51.stack
|
|
27016
|
-
}
|
|
27096
|
+
error: error51 instanceof Error ? pickErrorFields(error51, true) : { message: String(error51) }
|
|
27017
27097
|
} : meta3;
|
|
27018
27098
|
this.emit(LogLevel.ERROR, message, errorMeta);
|
|
27019
27099
|
}
|
|
@@ -27044,7 +27124,7 @@ class Logger {
|
|
|
27044
27124
|
return childLogger;
|
|
27045
27125
|
}
|
|
27046
27126
|
}
|
|
27047
|
-
var LogLevel, LOG_LEVEL_LABELS, LOG_LEVEL_BUFFER_TAGS, logger;
|
|
27127
|
+
var LogLevel, LOG_LEVEL_LABELS, LOG_LEVEL_BUFFER_TAGS, REPEAT_WINDOW_MS, MAX_REPEAT_KEYS = 500, MAX_ERROR_TEXT_CHARS = 300, logger;
|
|
27048
27128
|
var init_logger = __esm(() => {
|
|
27049
27129
|
init_config();
|
|
27050
27130
|
init_log_sink();
|
|
@@ -27067,6 +27147,7 @@ var init_logger = __esm(() => {
|
|
|
27067
27147
|
[LogLevel.WARN]: "warn",
|
|
27068
27148
|
[LogLevel.ERROR]: "error"
|
|
27069
27149
|
};
|
|
27150
|
+
REPEAT_WINDOW_MS = 15 * 60 * 1000;
|
|
27070
27151
|
logger = new Logger;
|
|
27071
27152
|
});
|
|
27072
27153
|
|
|
@@ -27122,8 +27203,9 @@ var init_metrics = __esm(() => {
|
|
|
27122
27203
|
}
|
|
27123
27204
|
} catch (error51) {
|
|
27124
27205
|
const err = error51 instanceof Error ? error51 : new Error(String(error51));
|
|
27125
|
-
logger.warn(
|
|
27126
|
-
|
|
27206
|
+
logger.warn("MetricsCollector: failed to fetch pricing", {
|
|
27207
|
+
modelId,
|
|
27208
|
+
error: err
|
|
27127
27209
|
});
|
|
27128
27210
|
}
|
|
27129
27211
|
const fallback = FALLBACK_PRICING[modelId];
|
|
@@ -27131,7 +27213,7 @@ var init_metrics = __esm(() => {
|
|
|
27131
27213
|
logger.debug(`Using fallback pricing for ${modelId}`);
|
|
27132
27214
|
return fallback;
|
|
27133
27215
|
}
|
|
27134
|
-
logger.warn(
|
|
27216
|
+
logger.warn("MetricsCollector: unknown model, using gpt-4 pricing as default", { modelId });
|
|
27135
27217
|
return FALLBACK_PRICING["gpt-4"];
|
|
27136
27218
|
}
|
|
27137
27219
|
static calculateCost(inputTokens, outputTokens, model) {
|
|
@@ -27310,7 +27392,9 @@ class SmartRateLimiter {
|
|
|
27310
27392
|
const hasRequestCapacity = this.requestLimiter.tryConsume(1);
|
|
27311
27393
|
const hasTokenCapacity = this.tokenLimiter.tryConsume(estimatedTokens);
|
|
27312
27394
|
if (!hasRequestCapacity) {
|
|
27313
|
-
logger.warn("Request rate limit exceeded"
|
|
27395
|
+
logger.warn("Request rate limit exceeded", {
|
|
27396
|
+
availableTokens: this.requestLimiter.getAvailableTokens()
|
|
27397
|
+
});
|
|
27314
27398
|
return false;
|
|
27315
27399
|
}
|
|
27316
27400
|
if (!hasTokenCapacity) {
|
|
@@ -27676,12 +27760,13 @@ function selectRecord(records) {
|
|
|
27676
27760
|
}
|
|
27677
27761
|
return best ?? pool[pool.length - 1];
|
|
27678
27762
|
}
|
|
27679
|
-
function
|
|
27763
|
+
function resolveClaudeMarketplaceInstall(opts = {}) {
|
|
27680
27764
|
const targetHome = opts.targetHome ?? os5.homedir();
|
|
27681
27765
|
const pluginKey = opts.pluginKey ?? DEFAULT_PLUGIN_KEY;
|
|
27682
27766
|
const directoryResult = resolveDirectorySourceRoot(targetHome, pluginKey);
|
|
27683
|
-
if (directoryResult !== undefined)
|
|
27684
|
-
return directoryResult;
|
|
27767
|
+
if (directoryResult !== undefined) {
|
|
27768
|
+
return directoryResult === null ? null : { root: directoryResult, route: "directory-source" };
|
|
27769
|
+
}
|
|
27685
27770
|
const registryPath = path9.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
27686
27771
|
let records;
|
|
27687
27772
|
try {
|
|
@@ -27703,15 +27788,213 @@ function resolveClaudeMarketplaceRoot(opts = {}) {
|
|
|
27703
27788
|
} catch {
|
|
27704
27789
|
return null;
|
|
27705
27790
|
}
|
|
27706
|
-
return installPath;
|
|
27791
|
+
return { root: installPath, route: "registry-cache" };
|
|
27792
|
+
}
|
|
27793
|
+
function resolveClaudeMarketplaceRoot(opts = {}) {
|
|
27794
|
+
return resolveClaudeMarketplaceInstall(opts)?.root ?? null;
|
|
27795
|
+
}
|
|
27796
|
+
function readInstalledPluginVersion(opts = {}) {
|
|
27797
|
+
const targetHome = opts.targetHome ?? os5.homedir();
|
|
27798
|
+
const pluginKey = opts.pluginKey ?? DEFAULT_PLUGIN_KEY;
|
|
27799
|
+
const registryPath = path9.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
27800
|
+
let records;
|
|
27801
|
+
try {
|
|
27802
|
+
const parsed = JSON.parse(fs5.readFileSync(registryPath, "utf8"));
|
|
27803
|
+
records = parsed?.plugins?.[pluginKey];
|
|
27804
|
+
} catch {
|
|
27805
|
+
return null;
|
|
27806
|
+
}
|
|
27807
|
+
if (!Array.isArray(records) || records.length === 0)
|
|
27808
|
+
return null;
|
|
27809
|
+
return selectRecord(records)?.version ?? null;
|
|
27707
27810
|
}
|
|
27708
27811
|
var DEFAULT_PLUGIN_KEY = "massa-ai@massa-ai";
|
|
27709
27812
|
var init_claude_marketplace = () => {};
|
|
27710
27813
|
|
|
27711
|
-
// ../../packages/shared/dist/profile-switch/
|
|
27814
|
+
// ../../packages/shared/dist/profile-switch/frontmatter.js
|
|
27815
|
+
function parseFrontmatter(raw2) {
|
|
27816
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/.exec(raw2);
|
|
27817
|
+
if (!match) {
|
|
27818
|
+
throw new Error("charter missing YAML frontmatter (--- ... ---) block");
|
|
27819
|
+
}
|
|
27820
|
+
const yamlText = match[1] ?? "";
|
|
27821
|
+
const body = (match[2] ?? "").replace(/^\r?\n/, "");
|
|
27822
|
+
const frontmatter = parseSimpleYaml(yamlText);
|
|
27823
|
+
return { frontmatter, body };
|
|
27824
|
+
}
|
|
27825
|
+
function parseSimpleYaml(text) {
|
|
27826
|
+
const result = {};
|
|
27827
|
+
const lines = text.split(/\r?\n/);
|
|
27828
|
+
let i = 0;
|
|
27829
|
+
while (i < lines.length) {
|
|
27830
|
+
const line = lines[i] ?? "";
|
|
27831
|
+
if (line.trim() === "" || line.trim().startsWith("#")) {
|
|
27832
|
+
i++;
|
|
27833
|
+
continue;
|
|
27834
|
+
}
|
|
27835
|
+
const m = /^([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/.exec(line);
|
|
27836
|
+
if (!m) {
|
|
27837
|
+
i++;
|
|
27838
|
+
continue;
|
|
27839
|
+
}
|
|
27840
|
+
const key = m[1];
|
|
27841
|
+
const rest = (m[2] ?? "").trim();
|
|
27842
|
+
if (rest !== "") {
|
|
27843
|
+
result[key] = unquoteScalar(rest);
|
|
27844
|
+
i++;
|
|
27845
|
+
continue;
|
|
27846
|
+
}
|
|
27847
|
+
const nested = {};
|
|
27848
|
+
i++;
|
|
27849
|
+
while (i < lines.length) {
|
|
27850
|
+
const nestedLine = lines[i] ?? "";
|
|
27851
|
+
if (/^\s{2,}\S/.test(nestedLine) === false)
|
|
27852
|
+
break;
|
|
27853
|
+
const nm = /^\s{2,}([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/.exec(nestedLine);
|
|
27854
|
+
if (!nm)
|
|
27855
|
+
break;
|
|
27856
|
+
nested[nm[1]] = unquoteScalar((nm[2] ?? "").trim());
|
|
27857
|
+
i++;
|
|
27858
|
+
}
|
|
27859
|
+
result[key] = nested;
|
|
27860
|
+
}
|
|
27861
|
+
return result;
|
|
27862
|
+
}
|
|
27863
|
+
function unquoteScalar(s) {
|
|
27864
|
+
if (s.startsWith('"') && s.endsWith('"') || s.startsWith("'") && s.endsWith("'")) {
|
|
27865
|
+
return s.slice(1, -1);
|
|
27866
|
+
}
|
|
27867
|
+
return s;
|
|
27868
|
+
}
|
|
27869
|
+
|
|
27870
|
+
// ../../packages/shared/dist/profile-switch/doctor.js
|
|
27712
27871
|
import fs6 from "fs";
|
|
27713
|
-
import path10 from "path";
|
|
27714
27872
|
import os6 from "os";
|
|
27873
|
+
import path10 from "path";
|
|
27874
|
+
function readTextFile(filePath) {
|
|
27875
|
+
try {
|
|
27876
|
+
return fs6.readFileSync(filePath, "utf8");
|
|
27877
|
+
} catch {
|
|
27878
|
+
return null;
|
|
27879
|
+
}
|
|
27880
|
+
}
|
|
27881
|
+
function readJsonFile(filePath) {
|
|
27882
|
+
const raw2 = readTextFile(filePath);
|
|
27883
|
+
if (raw2 === null)
|
|
27884
|
+
return null;
|
|
27885
|
+
try {
|
|
27886
|
+
return JSON.parse(raw2);
|
|
27887
|
+
} catch {
|
|
27888
|
+
return null;
|
|
27889
|
+
}
|
|
27890
|
+
}
|
|
27891
|
+
function readPluginVersion(pluginRoot) {
|
|
27892
|
+
const manifest = readJsonFile(path10.join(pluginRoot, ".claude-plugin", "plugin.json"));
|
|
27893
|
+
return typeof manifest?.version === "string" ? manifest.version : null;
|
|
27894
|
+
}
|
|
27895
|
+
function detectEnvOverride(env) {
|
|
27896
|
+
for (const name of ENV_OVERRIDE_VARS) {
|
|
27897
|
+
const value = env[name];
|
|
27898
|
+
if (typeof value === "string" && value.trim()) {
|
|
27899
|
+
return { name, value: value.trim() };
|
|
27900
|
+
}
|
|
27901
|
+
}
|
|
27902
|
+
return null;
|
|
27903
|
+
}
|
|
27904
|
+
function readRoles(liveRoot, activeProfile) {
|
|
27905
|
+
const agentsDir = path10.join(liveRoot, "agents");
|
|
27906
|
+
let entries;
|
|
27907
|
+
try {
|
|
27908
|
+
entries = fs6.readdirSync(agentsDir, { withFileTypes: true });
|
|
27909
|
+
} catch {
|
|
27910
|
+
return [];
|
|
27911
|
+
}
|
|
27912
|
+
const roles = [];
|
|
27913
|
+
for (const entry of entries) {
|
|
27914
|
+
if (!entry.isFile() || !entry.name.startsWith("massa-ai-") || !entry.name.endsWith(".md")) {
|
|
27915
|
+
continue;
|
|
27916
|
+
}
|
|
27917
|
+
const activeRaw = readTextFile(path10.join(agentsDir, entry.name));
|
|
27918
|
+
let model = null;
|
|
27919
|
+
let effort = null;
|
|
27920
|
+
if (activeRaw !== null) {
|
|
27921
|
+
try {
|
|
27922
|
+
const { frontmatter } = parseFrontmatter(activeRaw);
|
|
27923
|
+
model = typeof frontmatter.model === "string" ? frontmatter.model : null;
|
|
27924
|
+
effort = typeof frontmatter.effort === "string" ? frontmatter.effort : null;
|
|
27925
|
+
} catch {}
|
|
27926
|
+
}
|
|
27927
|
+
let staleVariant = false;
|
|
27928
|
+
if (activeProfile && activeRaw !== null) {
|
|
27929
|
+
const variantRaw = readTextFile(path10.join(liveRoot, "agent-profiles", activeProfile, entry.name));
|
|
27930
|
+
if (variantRaw !== null) {
|
|
27931
|
+
staleVariant = variantRaw !== activeRaw;
|
|
27932
|
+
}
|
|
27933
|
+
}
|
|
27934
|
+
roles.push({ name: entry.name, model, effort, staleVariant });
|
|
27935
|
+
}
|
|
27936
|
+
return roles.sort((a, b) => a.name.localeCompare(b.name));
|
|
27937
|
+
}
|
|
27938
|
+
function runtimeDriftReport(opts = {}) {
|
|
27939
|
+
const targetHome = opts.targetHome ?? os6.homedir();
|
|
27940
|
+
const host = opts.host ?? "claude";
|
|
27941
|
+
const stateFilePath = opts.stateFilePath ?? path10.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
27942
|
+
let state = opts.state ?? null;
|
|
27943
|
+
if (state === null) {
|
|
27944
|
+
try {
|
|
27945
|
+
state = readInstallState(stateFilePath);
|
|
27946
|
+
} catch {
|
|
27947
|
+
state = null;
|
|
27948
|
+
}
|
|
27949
|
+
}
|
|
27950
|
+
const platform = state?.platforms?.[host];
|
|
27951
|
+
const stateVersion = typeof platform?.plugin?.version === "string" ? platform.plugin.version : null;
|
|
27952
|
+
const activeProfile = platform?.modelProfile?.profile ?? null;
|
|
27953
|
+
if (host !== "claude") {
|
|
27954
|
+
return {
|
|
27955
|
+
host,
|
|
27956
|
+
route: "unresolved",
|
|
27957
|
+
liveRoot: null,
|
|
27958
|
+
sourceVersion: null,
|
|
27959
|
+
stateVersion,
|
|
27960
|
+
pinnedVersion: null,
|
|
27961
|
+
activeProfile,
|
|
27962
|
+
roles: [],
|
|
27963
|
+
envOverride: detectEnvOverride(opts.env ?? process.env),
|
|
27964
|
+
versionDrift: false,
|
|
27965
|
+
profileMaterialized: false
|
|
27966
|
+
};
|
|
27967
|
+
}
|
|
27968
|
+
const install = resolveClaudeMarketplaceInstall({ targetHome, pluginKey: opts.pluginKey });
|
|
27969
|
+
const liveRoot = install?.root ?? null;
|
|
27970
|
+
const sourceVersion = liveRoot === null ? null : readPluginVersion(liveRoot);
|
|
27971
|
+
const pinnedVersion = readInstalledPluginVersion({ targetHome, pluginKey: opts.pluginKey });
|
|
27972
|
+
const roles = liveRoot === null ? [] : readRoles(liveRoot, activeProfile);
|
|
27973
|
+
return {
|
|
27974
|
+
host: "claude",
|
|
27975
|
+
route: install?.route ?? "unresolved",
|
|
27976
|
+
liveRoot,
|
|
27977
|
+
sourceVersion,
|
|
27978
|
+
stateVersion,
|
|
27979
|
+
pinnedVersion,
|
|
27980
|
+
activeProfile,
|
|
27981
|
+
roles,
|
|
27982
|
+
envOverride: detectEnvOverride(opts.env ?? process.env),
|
|
27983
|
+
versionDrift: sourceVersion !== null && stateVersion !== null && sourceVersion !== stateVersion,
|
|
27984
|
+
profileMaterialized: roles.some((role) => role.staleVariant)
|
|
27985
|
+
};
|
|
27986
|
+
}
|
|
27987
|
+
var ENV_OVERRIDE_VARS;
|
|
27988
|
+
var init_doctor = __esm(() => {
|
|
27989
|
+
init_claude_marketplace();
|
|
27990
|
+
init_state();
|
|
27991
|
+
ENV_OVERRIDE_VARS = ["CLAUDE_CODE_SUBAGENT_MODEL"];
|
|
27992
|
+
});
|
|
27993
|
+
|
|
27994
|
+
// ../../packages/shared/dist/profile-switch/engine.js
|
|
27995
|
+
import fs7 from "fs";
|
|
27996
|
+
import path11 from "path";
|
|
27997
|
+
import os7 from "os";
|
|
27715
27998
|
import crypto4 from "crypto";
|
|
27716
27999
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
27717
28000
|
function namedError3(name, message) {
|
|
@@ -27720,10 +28003,10 @@ function namedError3(name, message) {
|
|
|
27720
28003
|
return err;
|
|
27721
28004
|
}
|
|
27722
28005
|
function defaultStatePath(targetHome) {
|
|
27723
|
-
return
|
|
28006
|
+
return path11.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
27724
28007
|
}
|
|
27725
28008
|
function resolveCommon(opts) {
|
|
27726
|
-
const targetHome = opts.targetHome ??
|
|
28009
|
+
const targetHome = opts.targetHome ?? os7.homedir();
|
|
27727
28010
|
const stateFilePath = opts.stateFilePath ?? defaultStatePath(targetHome);
|
|
27728
28011
|
return { targetHome, stateFilePath };
|
|
27729
28012
|
}
|
|
@@ -27731,7 +28014,7 @@ function marketplaceRoots(targetHome, state) {
|
|
|
27731
28014
|
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
27732
28015
|
}
|
|
27733
28016
|
function claudeMarketplaceUnresolvedReason(targetHome) {
|
|
27734
|
-
const registryPath =
|
|
28017
|
+
const registryPath = path11.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
27735
28018
|
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";
|
|
27736
28019
|
}
|
|
27737
28020
|
function listProfiles(opts = {}) {
|
|
@@ -27739,6 +28022,12 @@ function listProfiles(opts = {}) {
|
|
|
27739
28022
|
const state = readInstallState(stateFilePath);
|
|
27740
28023
|
const roots = marketplaceRoots(targetHome, state);
|
|
27741
28024
|
const universe = opts.hosts ?? HOSTS;
|
|
28025
|
+
const claudeDrift = universe.includes("claude") ? runtimeDriftReport({ targetHome, stateFilePath, state, env: opts.env }) : null;
|
|
28026
|
+
const claudeDriftFields = (host) => host === "claude" && claudeDrift !== null ? {
|
|
28027
|
+
liveRoot: claudeDrift.liveRoot,
|
|
28028
|
+
sourceVersion: claudeDrift.sourceVersion,
|
|
28029
|
+
envOverride: claudeDrift.envOverride ? `${claudeDrift.envOverride.name}=${claudeDrift.envOverride.value}` : null
|
|
28030
|
+
} : { liveRoot: null, sourceVersion: null, envOverride: null };
|
|
27742
28031
|
const hosts = universe.map((host) => {
|
|
27743
28032
|
if (host === "claude" && state.platforms.claude?.installRoute === "marketplace" && roots.claude === undefined) {
|
|
27744
28033
|
const platform2 = state.platforms.claude;
|
|
@@ -27747,9 +28036,10 @@ function listProfiles(opts = {}) {
|
|
|
27747
28036
|
installed: false,
|
|
27748
28037
|
skipped: false,
|
|
27749
28038
|
skipReason: null,
|
|
27750
|
-
activeProfile: platform2.modelProfile?.profile ??
|
|
28039
|
+
activeProfile: platform2.modelProfile?.profile ?? "balanced",
|
|
27751
28040
|
bundleVersion: platform2.plugin?.version ?? null,
|
|
27752
|
-
availableProfiles: []
|
|
28041
|
+
availableProfiles: [],
|
|
28042
|
+
...claudeDriftFields(host)
|
|
27753
28043
|
};
|
|
27754
28044
|
}
|
|
27755
28045
|
const layout = resolveHostLayout(host, { targetHome, projectRoot: opts.projectRoot, marketplaceRoot: roots });
|
|
@@ -27761,10 +28051,11 @@ function listProfiles(opts = {}) {
|
|
|
27761
28051
|
skipReason: layout.reason,
|
|
27762
28052
|
activeProfile: null,
|
|
27763
28053
|
bundleVersion: null,
|
|
27764
|
-
availableProfiles: []
|
|
28054
|
+
availableProfiles: [],
|
|
28055
|
+
...claudeDriftFields(host)
|
|
27765
28056
|
};
|
|
27766
28057
|
}
|
|
27767
|
-
const installed =
|
|
28058
|
+
const installed = fs7.existsSync(layout.activeDir);
|
|
27768
28059
|
const availableProfiles = listVariantProfiles(layout);
|
|
27769
28060
|
const platform = state.platforms[host];
|
|
27770
28061
|
return {
|
|
@@ -27772,17 +28063,18 @@ function listProfiles(opts = {}) {
|
|
|
27772
28063
|
installed,
|
|
27773
28064
|
skipped: false,
|
|
27774
28065
|
skipReason: null,
|
|
27775
|
-
activeProfile: platform?.modelProfile?.profile ??
|
|
28066
|
+
activeProfile: platform?.modelProfile?.profile ?? "balanced",
|
|
27776
28067
|
bundleVersion: platform?.plugin?.version ?? null,
|
|
27777
|
-
availableProfiles
|
|
28068
|
+
availableProfiles,
|
|
28069
|
+
...claudeDriftFields(host)
|
|
27778
28070
|
};
|
|
27779
28071
|
});
|
|
27780
28072
|
return { hosts };
|
|
27781
28073
|
}
|
|
27782
28074
|
function listVariantProfiles(layout) {
|
|
27783
|
-
if (!
|
|
28075
|
+
if (!fs7.existsSync(layout.variantsRoot))
|
|
27784
28076
|
return [];
|
|
27785
|
-
return
|
|
28077
|
+
return fs7.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
27786
28078
|
}
|
|
27787
28079
|
function matchesGlob(filename, glob) {
|
|
27788
28080
|
const starIdx = glob.indexOf("*");
|
|
@@ -27793,7 +28085,7 @@ function matchesGlob(filename, glob) {
|
|
|
27793
28085
|
return filename.length >= prefix.length + suffix.length && filename.startsWith(prefix) && filename.endsWith(suffix);
|
|
27794
28086
|
}
|
|
27795
28087
|
function matchingFileNames(dir, glob) {
|
|
27796
|
-
return
|
|
28088
|
+
return fs7.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && matchesGlob(e.name, glob)).map((e) => e.name);
|
|
27797
28089
|
}
|
|
27798
28090
|
function detectGitAvailability(dir) {
|
|
27799
28091
|
try {
|
|
@@ -27819,7 +28111,7 @@ function gitTrackedFileNames(dir, filenames) {
|
|
|
27819
28111
|
}
|
|
27820
28112
|
}
|
|
27821
28113
|
function checkTrackedPathGuard(activeDir, filenames) {
|
|
27822
|
-
if (filenames.length === 0 || !
|
|
28114
|
+
if (filenames.length === 0 || !fs7.existsSync(activeDir))
|
|
27823
28115
|
return GUARD_PASS;
|
|
27824
28116
|
const availability = detectGitAvailability(activeDir);
|
|
27825
28117
|
if (availability === "no-git")
|
|
@@ -27830,53 +28122,53 @@ function checkTrackedPathGuard(activeDir, filenames) {
|
|
|
27830
28122
|
if (tracked.size === 0)
|
|
27831
28123
|
return GUARD_PASS;
|
|
27832
28124
|
const offending = filenames.find((name) => tracked.has(name));
|
|
27833
|
-
return { blocked: true, path:
|
|
28125
|
+
return { blocked: true, path: path11.join(activeDir, offending), unchecked: false };
|
|
27834
28126
|
}
|
|
27835
28127
|
function assertStateWritable(stateFilePath) {
|
|
27836
|
-
const dir =
|
|
28128
|
+
const dir = path11.dirname(stateFilePath);
|
|
27837
28129
|
try {
|
|
27838
|
-
|
|
28130
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
27839
28131
|
} catch (err) {
|
|
27840
28132
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
27841
28133
|
}
|
|
27842
|
-
const checkPath =
|
|
28134
|
+
const checkPath = fs7.existsSync(stateFilePath) ? stateFilePath : dir;
|
|
27843
28135
|
try {
|
|
27844
|
-
|
|
28136
|
+
fs7.accessSync(checkPath, fs7.constants.W_OK);
|
|
27845
28137
|
} catch (err) {
|
|
27846
28138
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
27847
28139
|
}
|
|
27848
28140
|
}
|
|
27849
28141
|
function copyFileRouteVariant(layout, variantDir) {
|
|
27850
|
-
|
|
28142
|
+
fs7.mkdirSync(layout.activeDir, { recursive: true });
|
|
27851
28143
|
let changed = 0;
|
|
27852
|
-
for (const entry of
|
|
28144
|
+
for (const entry of fs7.readdirSync(variantDir, { withFileTypes: true })) {
|
|
27853
28145
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
27854
28146
|
continue;
|
|
27855
|
-
|
|
28147
|
+
fs7.copyFileSync(path11.join(variantDir, entry.name), path11.join(layout.activeDir, entry.name));
|
|
27856
28148
|
changed++;
|
|
27857
28149
|
}
|
|
27858
28150
|
return changed;
|
|
27859
28151
|
}
|
|
27860
28152
|
function repointOpencodeVariant(layout, variantDir) {
|
|
27861
|
-
|
|
28153
|
+
fs7.mkdirSync(layout.activeDir, { recursive: true });
|
|
27862
28154
|
let changed = 0;
|
|
27863
|
-
for (const entry of
|
|
28155
|
+
for (const entry of fs7.readdirSync(variantDir, { withFileTypes: true })) {
|
|
27864
28156
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
27865
28157
|
continue;
|
|
27866
|
-
const dest =
|
|
27867
|
-
const target =
|
|
28158
|
+
const dest = path11.join(layout.activeDir, entry.name);
|
|
28159
|
+
const target = path11.resolve(path11.join(variantDir, entry.name));
|
|
27868
28160
|
let destExists = true;
|
|
27869
28161
|
let destIsSymlink = false;
|
|
27870
28162
|
try {
|
|
27871
|
-
destIsSymlink =
|
|
28163
|
+
destIsSymlink = fs7.lstatSync(dest).isSymbolicLink();
|
|
27872
28164
|
} catch {
|
|
27873
28165
|
destExists = false;
|
|
27874
28166
|
}
|
|
27875
28167
|
if (destExists && !destIsSymlink)
|
|
27876
28168
|
continue;
|
|
27877
28169
|
const tmp = `${dest}.massa-ai-switch.${crypto4.randomUUID()}`;
|
|
27878
|
-
|
|
27879
|
-
|
|
28170
|
+
fs7.symlinkSync(target, tmp);
|
|
28171
|
+
fs7.renameSync(tmp, dest);
|
|
27880
28172
|
changed++;
|
|
27881
28173
|
}
|
|
27882
28174
|
return changed;
|
|
@@ -27916,13 +28208,13 @@ function switchProfile(opts) {
|
|
|
27916
28208
|
if (fileHosts.length === 0) {
|
|
27917
28209
|
return { profile: opts.profile, dryRun, hosts: orderRows(universe, skipRows), restartRequired: false };
|
|
27918
28210
|
}
|
|
27919
|
-
const installedFileHosts = fileHosts.filter((h) =>
|
|
28211
|
+
const installedFileHosts = fileHosts.filter((h) => fs7.existsSync(h.layout.activeDir));
|
|
27920
28212
|
if (installedFileHosts.length === 0)
|
|
27921
28213
|
throw NoHostsDetectedError();
|
|
27922
28214
|
const withAvailability = fileHosts.map((h) => {
|
|
27923
|
-
const variantsRootExists =
|
|
28215
|
+
const variantsRootExists = fs7.existsSync(h.layout.variantsRoot);
|
|
27924
28216
|
const variantDir = h.layout.variantDir(opts.profile);
|
|
27925
|
-
const available = variantsRootExists &&
|
|
28217
|
+
const available = variantsRootExists && fs7.existsSync(variantDir) && fs7.statSync(variantDir).isDirectory();
|
|
27926
28218
|
return { ...h, variantsRootExists, variantDir, available };
|
|
27927
28219
|
});
|
|
27928
28220
|
if (!withAvailability.some((h) => h.available)) {
|
|
@@ -27958,7 +28250,7 @@ function switchProfile(opts) {
|
|
|
27958
28250
|
continue;
|
|
27959
28251
|
}
|
|
27960
28252
|
if (dryRun) {
|
|
27961
|
-
rows.push({ host: h.host, status: "
|
|
28253
|
+
rows.push({ host: h.host, status: "would-switch" });
|
|
27962
28254
|
continue;
|
|
27963
28255
|
}
|
|
27964
28256
|
const candidateNames = matchingFileNames(h.variantDir, h.layout.activeGlob);
|
|
@@ -28003,6 +28295,7 @@ var init_engine = __esm(() => {
|
|
|
28003
28295
|
init_state();
|
|
28004
28296
|
init_lock();
|
|
28005
28297
|
init_claude_marketplace();
|
|
28298
|
+
init_doctor();
|
|
28006
28299
|
SwitchEngineError = class SwitchEngineError extends Error {
|
|
28007
28300
|
constructor(message) {
|
|
28008
28301
|
super(message);
|
|
@@ -28015,29 +28308,29 @@ var init_engine = __esm(() => {
|
|
|
28015
28308
|
|
|
28016
28309
|
// ../../packages/shared/dist/profile-switch/report.js
|
|
28017
28310
|
function reportSucceeded(report) {
|
|
28018
|
-
return report.hosts.every((h) => h.status === "switched" || h.status === "skipped");
|
|
28311
|
+
return report.hosts.every((h) => h.status === "switched" || h.status === "would-switch" || h.status === "skipped");
|
|
28019
28312
|
}
|
|
28020
28313
|
|
|
28021
28314
|
// ../../packages/shared/dist/profile-switch/variant-sync.js
|
|
28022
|
-
import
|
|
28023
|
-
import
|
|
28024
|
-
import
|
|
28315
|
+
import fs8 from "fs";
|
|
28316
|
+
import path12 from "path";
|
|
28317
|
+
import os8 from "os";
|
|
28025
28318
|
import crypto5 from "crypto";
|
|
28026
28319
|
function defaultStatePath2(targetHome) {
|
|
28027
|
-
return
|
|
28320
|
+
return path12.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
28028
28321
|
}
|
|
28029
28322
|
function marketplaceRoots2(targetHome, state) {
|
|
28030
28323
|
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
28031
28324
|
}
|
|
28032
28325
|
function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
28033
28326
|
const unique = `${process.pid}.${++tempFileCounter2}.${crypto5.randomBytes(6).toString("hex")}`;
|
|
28034
|
-
const tempFile =
|
|
28327
|
+
const tempFile = path12.join(destDir, `.${destName}.${unique}.tmp`);
|
|
28035
28328
|
try {
|
|
28036
|
-
|
|
28037
|
-
|
|
28329
|
+
fs8.writeFileSync(tempFile, content);
|
|
28330
|
+
fs8.renameSync(tempFile, path12.join(destDir, destName));
|
|
28038
28331
|
} catch (error51) {
|
|
28039
28332
|
try {
|
|
28040
|
-
|
|
28333
|
+
fs8.unlinkSync(tempFile);
|
|
28041
28334
|
} catch {}
|
|
28042
28335
|
throw error51;
|
|
28043
28336
|
}
|
|
@@ -28045,20 +28338,20 @@ function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
|
28045
28338
|
function isSafeDirName(name) {
|
|
28046
28339
|
if (name === "." || name === "..")
|
|
28047
28340
|
return false;
|
|
28048
|
-
if (name.includes("/") || name.includes("\\") || name.includes(
|
|
28341
|
+
if (name.includes("/") || name.includes("\\") || name.includes(path12.sep))
|
|
28049
28342
|
return false;
|
|
28050
|
-
return
|
|
28343
|
+
return path12.basename(name) === name;
|
|
28051
28344
|
}
|
|
28052
28345
|
function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
28053
28346
|
const layout = resolveHostLayout(host, { targetHome, marketplaceRoot });
|
|
28054
28347
|
if (layout.route === "skip") {
|
|
28055
28348
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: layout.reason };
|
|
28056
28349
|
}
|
|
28057
|
-
const srcDir =
|
|
28058
|
-
if (!
|
|
28350
|
+
const srcDir = path12.join(sourceRoot, "apps", `${host}-plugin`, "agent-profiles");
|
|
28351
|
+
if (!fs8.existsSync(srcDir) || !fs8.statSync(srcDir).isDirectory()) {
|
|
28059
28352
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: "no generated variants for this host" };
|
|
28060
28353
|
}
|
|
28061
|
-
if (!
|
|
28354
|
+
if (!fs8.existsSync(layout.variantsRoot)) {
|
|
28062
28355
|
return {
|
|
28063
28356
|
host,
|
|
28064
28357
|
status: "skipped",
|
|
@@ -28070,24 +28363,24 @@ function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
|
28070
28363
|
}
|
|
28071
28364
|
const profiles = [];
|
|
28072
28365
|
let files = 0;
|
|
28073
|
-
for (const entry of
|
|
28366
|
+
for (const entry of fs8.readdirSync(srcDir, { withFileTypes: true })) {
|
|
28074
28367
|
if (!entry.isDirectory())
|
|
28075
28368
|
continue;
|
|
28076
28369
|
if (!isSafeDirName(entry.name))
|
|
28077
28370
|
continue;
|
|
28078
|
-
const srcProfileDir =
|
|
28079
|
-
const destProfileDir =
|
|
28080
|
-
|
|
28081
|
-
for (const fileEntry of
|
|
28371
|
+
const srcProfileDir = path12.join(srcDir, entry.name);
|
|
28372
|
+
const destProfileDir = path12.join(layout.variantsRoot, entry.name);
|
|
28373
|
+
fs8.mkdirSync(destProfileDir, { recursive: true });
|
|
28374
|
+
for (const fileEntry of fs8.readdirSync(srcProfileDir, { withFileTypes: true })) {
|
|
28082
28375
|
if (!fileEntry.isFile())
|
|
28083
28376
|
continue;
|
|
28084
|
-
const content =
|
|
28377
|
+
const content = fs8.readFileSync(path12.join(srcProfileDir, fileEntry.name));
|
|
28085
28378
|
writeFileIntoDirAtomically(destProfileDir, fileEntry.name, content);
|
|
28086
28379
|
files++;
|
|
28087
28380
|
}
|
|
28088
28381
|
profiles.push(entry.name);
|
|
28089
28382
|
}
|
|
28090
|
-
const retained =
|
|
28383
|
+
const retained = fs8.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory() && !profiles.includes(e.name)).map((e) => e.name).sort();
|
|
28091
28384
|
return { host, status: "synced", profiles: profiles.sort(), retained, files };
|
|
28092
28385
|
}
|
|
28093
28386
|
function syncGeneratedVariants(opts) {
|
|
@@ -28103,7 +28396,7 @@ function syncGeneratedVariants(opts) {
|
|
|
28103
28396
|
}));
|
|
28104
28397
|
}
|
|
28105
28398
|
const sourceRoot = opts.sourceRoot;
|
|
28106
|
-
const targetHome = opts.targetHome ??
|
|
28399
|
+
const targetHome = opts.targetHome ?? os8.homedir();
|
|
28107
28400
|
const state = readInstallState(defaultStatePath2(targetHome));
|
|
28108
28401
|
const roots = marketplaceRoots2(targetHome, state);
|
|
28109
28402
|
return hosts.map((host) => {
|
|
@@ -28122,14 +28415,14 @@ var init_variant_sync = __esm(() => {
|
|
|
28122
28415
|
});
|
|
28123
28416
|
|
|
28124
28417
|
// ../../packages/shared/dist/profile-switch/repo-root.js
|
|
28125
|
-
import
|
|
28126
|
-
import
|
|
28418
|
+
import fs9 from "fs";
|
|
28419
|
+
import path13 from "path";
|
|
28127
28420
|
function findRepoRootWithMarker(startDir, marker, maxLevels) {
|
|
28128
28421
|
let dir = startDir;
|
|
28129
28422
|
for (let i = 0;i <= maxLevels; i++) {
|
|
28130
|
-
if (
|
|
28423
|
+
if (fs9.existsSync(path13.join(dir, marker)))
|
|
28131
28424
|
return dir;
|
|
28132
|
-
const parent =
|
|
28425
|
+
const parent = path13.dirname(dir);
|
|
28133
28426
|
if (parent === dir)
|
|
28134
28427
|
break;
|
|
28135
28428
|
dir = parent;
|
|
@@ -28227,7 +28520,7 @@ var init_rules = __esm(() => {
|
|
|
28227
28520
|
});
|
|
28228
28521
|
|
|
28229
28522
|
// ../../packages/shared/dist/bootstrap/state.js
|
|
28230
|
-
import
|
|
28523
|
+
import fs10 from "fs";
|
|
28231
28524
|
function isPlainObject4(value) {
|
|
28232
28525
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28233
28526
|
}
|
|
@@ -28258,7 +28551,7 @@ function resolveBootstrapState(doc2) {
|
|
|
28258
28551
|
}
|
|
28259
28552
|
function readConfigBytes() {
|
|
28260
28553
|
try {
|
|
28261
|
-
return
|
|
28554
|
+
return fs10.readFileSync(getConfigPath(), "utf-8");
|
|
28262
28555
|
} catch (error51) {
|
|
28263
28556
|
if (error51?.code === "ENOENT")
|
|
28264
28557
|
return "";
|
|
@@ -28313,7 +28606,7 @@ var init_state2 = __esm(() => {
|
|
|
28313
28606
|
});
|
|
28314
28607
|
|
|
28315
28608
|
// ../../packages/shared/dist/bootstrap/render.js
|
|
28316
|
-
import
|
|
28609
|
+
import path14 from "path";
|
|
28317
28610
|
function wrapBootstrapBlock(body) {
|
|
28318
28611
|
return `${BOOTSTRAP_BLOCK_START}
|
|
28319
28612
|
${body.replace(/\n+$/, "")}
|
|
@@ -28326,19 +28619,19 @@ function ruleMarker(id, suffix) {
|
|
|
28326
28619
|
function resolveHostRoot(host, targetHome, hostRoot) {
|
|
28327
28620
|
requireAbsoluteTargetHome(targetHome);
|
|
28328
28621
|
if (hostRoot === undefined)
|
|
28329
|
-
return
|
|
28330
|
-
const relative =
|
|
28331
|
-
if (!
|
|
28622
|
+
return path14.join(targetHome, ...HOST_CONFIG_DIR[host]);
|
|
28623
|
+
const relative = path14.relative(targetHome, hostRoot);
|
|
28624
|
+
if (!path14.isAbsolute(hostRoot) || relative === "" || relative.startsWith("..") || path14.isAbsolute(relative)) {
|
|
28332
28625
|
throw new BootstrapRenderError("HostRootOutsideTargetHomeError", `hostRoot must be an absolute directory inside targetHome, got "${hostRoot}" for targetHome "${targetHome}"`, [hostRoot, targetHome]);
|
|
28333
28626
|
}
|
|
28334
28627
|
return hostRoot;
|
|
28335
28628
|
}
|
|
28336
28629
|
function bootstrapContractPath(host, targetHome, hostRoot) {
|
|
28337
|
-
return
|
|
28630
|
+
return path14.join(resolveHostRoot(host, targetHome, hostRoot), CONTRACT_FILENAME);
|
|
28338
28631
|
}
|
|
28339
28632
|
function bootstrapStateFilePath(targetHome) {
|
|
28340
28633
|
requireAbsoluteTargetHome(targetHome);
|
|
28341
|
-
return
|
|
28634
|
+
return path14.join(targetHome, ".config", "massa-ai", "config.json");
|
|
28342
28635
|
}
|
|
28343
28636
|
function renderBootstrap(options) {
|
|
28344
28637
|
const { source, state, host, targetHome, hostRoot } = options;
|
|
@@ -28361,7 +28654,7 @@ ${body}`;
|
|
|
28361
28654
|
return { contract, pointer };
|
|
28362
28655
|
}
|
|
28363
28656
|
function requireAbsoluteTargetHome(targetHome) {
|
|
28364
|
-
if (!
|
|
28657
|
+
if (!path14.isAbsolute(targetHome)) {
|
|
28365
28658
|
throw new BootstrapRenderError("TargetHomeNotAbsoluteError", `targetHome must be an absolute path, got "${targetHome}"`, [targetHome]);
|
|
28366
28659
|
}
|
|
28367
28660
|
}
|
|
@@ -28538,14 +28831,14 @@ var init_report = __esm(() => {
|
|
|
28538
28831
|
});
|
|
28539
28832
|
|
|
28540
28833
|
// ../../packages/shared/dist/bootstrap/engine.js
|
|
28541
|
-
import
|
|
28542
|
-
import
|
|
28834
|
+
import fs11 from "fs";
|
|
28835
|
+
import path15 from "path";
|
|
28543
28836
|
function applyBootstrapState(options) {
|
|
28544
28837
|
const { targetHome } = options;
|
|
28545
28838
|
const dryRun = options.dryRun ?? false;
|
|
28546
28839
|
const warn = options.onWarning ?? ((message) => console.warn(message));
|
|
28547
28840
|
const configPath = bootstrapStateFilePath(targetHome);
|
|
28548
|
-
const installStatePath =
|
|
28841
|
+
const installStatePath = path15.join(path15.dirname(configPath), INSTALL_STATE_FILENAME);
|
|
28549
28842
|
const { platforms } = readInstallState(installStatePath);
|
|
28550
28843
|
const installed = HOSTS.filter((host) => platforms[host] !== undefined);
|
|
28551
28844
|
if (installed.length === 0) {
|
|
@@ -28638,22 +28931,22 @@ function applyHost(input) {
|
|
|
28638
28931
|
}
|
|
28639
28932
|
function wiringArtifact(host, targetHome, hostRoot) {
|
|
28640
28933
|
const root = resolveHostRoot(host, targetHome, hostRoot);
|
|
28641
|
-
const contractPath =
|
|
28934
|
+
const contractPath = path15.join(root, CONTRACT_FILENAME);
|
|
28642
28935
|
switch (host) {
|
|
28643
28936
|
case "claude":
|
|
28644
|
-
return { file:
|
|
28937
|
+
return { file: path15.join(root, "CLAUDE.md"), token: `@${CONTRACT_FILENAME}` };
|
|
28645
28938
|
case "codex":
|
|
28646
28939
|
case "cursor":
|
|
28647
|
-
return { file:
|
|
28940
|
+
return { file: path15.join(root, "AGENTS.md"), token: contractPath };
|
|
28648
28941
|
case "opencode":
|
|
28649
28942
|
return { file: openCodeConfigPath(root), token: `"${contractPath}"` };
|
|
28650
28943
|
}
|
|
28651
28944
|
}
|
|
28652
28945
|
function openCodeConfigPath(root) {
|
|
28653
|
-
const json2 =
|
|
28654
|
-
if (
|
|
28946
|
+
const json2 = path15.join(root, "opencode.json");
|
|
28947
|
+
if (fs11.existsSync(json2))
|
|
28655
28948
|
return json2;
|
|
28656
|
-
return
|
|
28949
|
+
return path15.join(root, "opencode.jsonc");
|
|
28657
28950
|
}
|
|
28658
28951
|
function isWired(host, targetHome, hostRoot) {
|
|
28659
28952
|
const artifact = wiringArtifact(host, targetHome, hostRoot);
|
|
@@ -28666,7 +28959,7 @@ function notWiredReason(host, targetHome, hostRoot) {
|
|
|
28666
28959
|
}
|
|
28667
28960
|
function readFileOrNull(filePath) {
|
|
28668
28961
|
try {
|
|
28669
|
-
return
|
|
28962
|
+
return fs11.readFileSync(filePath, "utf-8");
|
|
28670
28963
|
} catch {
|
|
28671
28964
|
return null;
|
|
28672
28965
|
}
|
|
@@ -28750,6 +29043,7 @@ var init_dist = __esm(() => {
|
|
|
28750
29043
|
init_engine();
|
|
28751
29044
|
init_variant_sync();
|
|
28752
29045
|
init_repo_root();
|
|
29046
|
+
init_doctor();
|
|
28753
29047
|
init_bootstrap();
|
|
28754
29048
|
init_types2();
|
|
28755
29049
|
init_interfaces();
|
|
@@ -30272,7 +30566,7 @@ var import_brace_expansion, minimatch = (p, pattern, options = {}) => {
|
|
|
30272
30566
|
}, qmarksTestNoExtDot = ([$0]) => {
|
|
30273
30567
|
const len = $0.length;
|
|
30274
30568
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
30275
|
-
}, defaultPlatform,
|
|
30569
|
+
}, defaultPlatform, path16, sep, GLOBSTAR, qmark2 = "[^/]", star2, twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?", filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options), ext = (a, b = {}) => Object.assign({}, a, b), defaults = (def) => {
|
|
30276
30570
|
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
30277
30571
|
return minimatch;
|
|
30278
30572
|
}
|
|
@@ -30330,11 +30624,11 @@ var init_esm = __esm(() => {
|
|
|
30330
30624
|
starRE = /^\*+$/;
|
|
30331
30625
|
qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
30332
30626
|
defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
30333
|
-
|
|
30627
|
+
path16 = {
|
|
30334
30628
|
win32: { sep: "\\" },
|
|
30335
30629
|
posix: { sep: "/" }
|
|
30336
30630
|
};
|
|
30337
|
-
sep = defaultPlatform === "win32" ?
|
|
30631
|
+
sep = defaultPlatform === "win32" ? path16.win32.sep : path16.posix.sep;
|
|
30338
30632
|
minimatch.sep = sep;
|
|
30339
30633
|
GLOBSTAR = Symbol("globstar **");
|
|
30340
30634
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -32300,12 +32594,12 @@ var init_esm4 = __esm(() => {
|
|
|
32300
32594
|
childrenCache() {
|
|
32301
32595
|
return this.#children;
|
|
32302
32596
|
}
|
|
32303
|
-
resolve(
|
|
32304
|
-
if (!
|
|
32597
|
+
resolve(path17) {
|
|
32598
|
+
if (!path17) {
|
|
32305
32599
|
return this;
|
|
32306
32600
|
}
|
|
32307
|
-
const rootPath = this.getRootString(
|
|
32308
|
-
const dir =
|
|
32601
|
+
const rootPath = this.getRootString(path17);
|
|
32602
|
+
const dir = path17.substring(rootPath.length);
|
|
32309
32603
|
const dirParts = dir.split(this.splitSep);
|
|
32310
32604
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
32311
32605
|
return result;
|
|
@@ -32833,8 +33127,8 @@ var init_esm4 = __esm(() => {
|
|
|
32833
33127
|
newChild(name, type = UNKNOWN, opts = {}) {
|
|
32834
33128
|
return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
|
32835
33129
|
}
|
|
32836
|
-
getRootString(
|
|
32837
|
-
return win32.parse(
|
|
33130
|
+
getRootString(path17) {
|
|
33131
|
+
return win32.parse(path17).root;
|
|
32838
33132
|
}
|
|
32839
33133
|
getRoot(rootPath) {
|
|
32840
33134
|
rootPath = uncToDrive(rootPath.toUpperCase());
|
|
@@ -32859,8 +33153,8 @@ var init_esm4 = __esm(() => {
|
|
|
32859
33153
|
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
|
32860
33154
|
super(name, type, root, roots, nocase, children, opts);
|
|
32861
33155
|
}
|
|
32862
|
-
getRootString(
|
|
32863
|
-
return
|
|
33156
|
+
getRootString(path17) {
|
|
33157
|
+
return path17.startsWith("/") ? "/" : "";
|
|
32864
33158
|
}
|
|
32865
33159
|
getRoot(_rootPath) {
|
|
32866
33160
|
return this.root;
|
|
@@ -32879,8 +33173,8 @@ var init_esm4 = __esm(() => {
|
|
|
32879
33173
|
#children;
|
|
32880
33174
|
nocase;
|
|
32881
33175
|
#fs;
|
|
32882
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
32883
|
-
this.#fs = fsFromOption(
|
|
33176
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs12 = defaultFS } = {}) {
|
|
33177
|
+
this.#fs = fsFromOption(fs12);
|
|
32884
33178
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
32885
33179
|
cwd = fileURLToPath(cwd);
|
|
32886
33180
|
}
|
|
@@ -32916,11 +33210,11 @@ var init_esm4 = __esm(() => {
|
|
|
32916
33210
|
}
|
|
32917
33211
|
this.cwd = prev;
|
|
32918
33212
|
}
|
|
32919
|
-
depth(
|
|
32920
|
-
if (typeof
|
|
32921
|
-
|
|
33213
|
+
depth(path17 = this.cwd) {
|
|
33214
|
+
if (typeof path17 === "string") {
|
|
33215
|
+
path17 = this.cwd.resolve(path17);
|
|
32922
33216
|
}
|
|
32923
|
-
return
|
|
33217
|
+
return path17.depth();
|
|
32924
33218
|
}
|
|
32925
33219
|
childrenCache() {
|
|
32926
33220
|
return this.#children;
|
|
@@ -33336,9 +33630,9 @@ var init_esm4 = __esm(() => {
|
|
|
33336
33630
|
process4();
|
|
33337
33631
|
return results;
|
|
33338
33632
|
}
|
|
33339
|
-
chdir(
|
|
33633
|
+
chdir(path17 = this.cwd) {
|
|
33340
33634
|
const oldCwd = this.cwd;
|
|
33341
|
-
this.cwd = typeof
|
|
33635
|
+
this.cwd = typeof path17 === "string" ? this.cwd.resolve(path17) : path17;
|
|
33342
33636
|
this.cwd[setAsCwd](oldCwd);
|
|
33343
33637
|
}
|
|
33344
33638
|
};
|
|
@@ -33355,8 +33649,8 @@ var init_esm4 = __esm(() => {
|
|
|
33355
33649
|
parseRootPath(dir) {
|
|
33356
33650
|
return win32.parse(dir).root.toUpperCase();
|
|
33357
33651
|
}
|
|
33358
|
-
newRoot(
|
|
33359
|
-
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
33652
|
+
newRoot(fs12) {
|
|
33653
|
+
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs12 });
|
|
33360
33654
|
}
|
|
33361
33655
|
isAbsolute(p) {
|
|
33362
33656
|
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
@@ -33372,8 +33666,8 @@ var init_esm4 = __esm(() => {
|
|
|
33372
33666
|
parseRootPath(_dir) {
|
|
33373
33667
|
return "/";
|
|
33374
33668
|
}
|
|
33375
|
-
newRoot(
|
|
33376
|
-
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
33669
|
+
newRoot(fs12) {
|
|
33670
|
+
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs12 });
|
|
33377
33671
|
}
|
|
33378
33672
|
isAbsolute(p) {
|
|
33379
33673
|
return p.startsWith("/");
|
|
@@ -33630,8 +33924,8 @@ class MatchRecord {
|
|
|
33630
33924
|
this.store.set(target, current === undefined ? n : n & current);
|
|
33631
33925
|
}
|
|
33632
33926
|
entries() {
|
|
33633
|
-
return [...this.store.entries()].map(([
|
|
33634
|
-
|
|
33927
|
+
return [...this.store.entries()].map(([path17, n]) => [
|
|
33928
|
+
path17,
|
|
33635
33929
|
!!(n & 2),
|
|
33636
33930
|
!!(n & 1)
|
|
33637
33931
|
]);
|
|
@@ -33835,9 +34129,9 @@ class GlobUtil {
|
|
|
33835
34129
|
signal;
|
|
33836
34130
|
maxDepth;
|
|
33837
34131
|
includeChildMatches;
|
|
33838
|
-
constructor(patterns,
|
|
34132
|
+
constructor(patterns, path17, opts) {
|
|
33839
34133
|
this.patterns = patterns;
|
|
33840
|
-
this.path =
|
|
34134
|
+
this.path = path17;
|
|
33841
34135
|
this.opts = opts;
|
|
33842
34136
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
33843
34137
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -33856,11 +34150,11 @@ class GlobUtil {
|
|
|
33856
34150
|
});
|
|
33857
34151
|
}
|
|
33858
34152
|
}
|
|
33859
|
-
#ignored(
|
|
33860
|
-
return this.seen.has(
|
|
34153
|
+
#ignored(path17) {
|
|
34154
|
+
return this.seen.has(path17) || !!this.#ignore?.ignored?.(path17);
|
|
33861
34155
|
}
|
|
33862
|
-
#childrenIgnored(
|
|
33863
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
34156
|
+
#childrenIgnored(path17) {
|
|
34157
|
+
return !!this.#ignore?.childrenIgnored?.(path17);
|
|
33864
34158
|
}
|
|
33865
34159
|
pause() {
|
|
33866
34160
|
this.paused = true;
|
|
@@ -34077,8 +34371,8 @@ var init_walker = __esm(() => {
|
|
|
34077
34371
|
init_processor();
|
|
34078
34372
|
GlobWalker = class GlobWalker extends GlobUtil {
|
|
34079
34373
|
matches = new Set;
|
|
34080
|
-
constructor(patterns,
|
|
34081
|
-
super(patterns,
|
|
34374
|
+
constructor(patterns, path17, opts) {
|
|
34375
|
+
super(patterns, path17, opts);
|
|
34082
34376
|
}
|
|
34083
34377
|
matchEmit(e) {
|
|
34084
34378
|
this.matches.add(e);
|
|
@@ -34115,8 +34409,8 @@ var init_walker = __esm(() => {
|
|
|
34115
34409
|
};
|
|
34116
34410
|
GlobStream = class GlobStream extends GlobUtil {
|
|
34117
34411
|
results;
|
|
34118
|
-
constructor(patterns,
|
|
34119
|
-
super(patterns,
|
|
34412
|
+
constructor(patterns, path17, opts) {
|
|
34413
|
+
super(patterns, path17, opts);
|
|
34120
34414
|
this.results = new Minipass({
|
|
34121
34415
|
signal: this.signal,
|
|
34122
34416
|
objectMode: true
|
|
@@ -34544,20 +34838,20 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
34544
34838
|
var throwError = (message, Ctor) => {
|
|
34545
34839
|
throw new Ctor(message);
|
|
34546
34840
|
};
|
|
34547
|
-
var checkPath = (
|
|
34548
|
-
if (!isString(
|
|
34841
|
+
var checkPath = (path17, originalPath, doThrow) => {
|
|
34842
|
+
if (!isString(path17)) {
|
|
34549
34843
|
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
34550
34844
|
}
|
|
34551
|
-
if (!
|
|
34845
|
+
if (!path17) {
|
|
34552
34846
|
return doThrow(`path must not be empty`, TypeError);
|
|
34553
34847
|
}
|
|
34554
|
-
if (checkPath.isNotRelative(
|
|
34848
|
+
if (checkPath.isNotRelative(path17)) {
|
|
34555
34849
|
const r = "`path.relative()`d";
|
|
34556
34850
|
return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
|
34557
34851
|
}
|
|
34558
34852
|
return true;
|
|
34559
34853
|
};
|
|
34560
|
-
var isNotRelative = (
|
|
34854
|
+
var isNotRelative = (path17) => REGEX_TEST_INVALID_PATH.test(path17);
|
|
34561
34855
|
checkPath.isNotRelative = isNotRelative;
|
|
34562
34856
|
checkPath.convert = (p) => p;
|
|
34563
34857
|
|
|
@@ -34600,7 +34894,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
34600
34894
|
addPattern(pattern) {
|
|
34601
34895
|
return this.add(pattern);
|
|
34602
34896
|
}
|
|
34603
|
-
_testOne(
|
|
34897
|
+
_testOne(path17, checkUnignored) {
|
|
34604
34898
|
let ignored = false;
|
|
34605
34899
|
let unignored = false;
|
|
34606
34900
|
this._rules.forEach((rule) => {
|
|
@@ -34608,7 +34902,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
34608
34902
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
34609
34903
|
return;
|
|
34610
34904
|
}
|
|
34611
|
-
const matched = rule.regex.test(
|
|
34905
|
+
const matched = rule.regex.test(path17);
|
|
34612
34906
|
if (matched) {
|
|
34613
34907
|
ignored = !negative;
|
|
34614
34908
|
unignored = negative;
|
|
@@ -34620,39 +34914,39 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
34620
34914
|
};
|
|
34621
34915
|
}
|
|
34622
34916
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
34623
|
-
const
|
|
34624
|
-
checkPath(
|
|
34625
|
-
return this._t(
|
|
34917
|
+
const path17 = originalPath && checkPath.convert(originalPath);
|
|
34918
|
+
checkPath(path17, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
34919
|
+
return this._t(path17, cache, checkUnignored, slices);
|
|
34626
34920
|
}
|
|
34627
|
-
_t(
|
|
34628
|
-
if (
|
|
34629
|
-
return cache[
|
|
34921
|
+
_t(path17, cache, checkUnignored, slices) {
|
|
34922
|
+
if (path17 in cache) {
|
|
34923
|
+
return cache[path17];
|
|
34630
34924
|
}
|
|
34631
34925
|
if (!slices) {
|
|
34632
|
-
slices =
|
|
34926
|
+
slices = path17.split(SLASH2);
|
|
34633
34927
|
}
|
|
34634
34928
|
slices.pop();
|
|
34635
34929
|
if (!slices.length) {
|
|
34636
|
-
return cache[
|
|
34930
|
+
return cache[path17] = this._testOne(path17, checkUnignored);
|
|
34637
34931
|
}
|
|
34638
34932
|
const parent = this._t(slices.join(SLASH2) + SLASH2, cache, checkUnignored, slices);
|
|
34639
|
-
return cache[
|
|
34933
|
+
return cache[path17] = parent.ignored ? parent : this._testOne(path17, checkUnignored);
|
|
34640
34934
|
}
|
|
34641
|
-
ignores(
|
|
34642
|
-
return this._test(
|
|
34935
|
+
ignores(path17) {
|
|
34936
|
+
return this._test(path17, this._ignoreCache, false).ignored;
|
|
34643
34937
|
}
|
|
34644
34938
|
createFilter() {
|
|
34645
|
-
return (
|
|
34939
|
+
return (path17) => !this.ignores(path17);
|
|
34646
34940
|
}
|
|
34647
34941
|
filter(paths) {
|
|
34648
34942
|
return makeArray(paths).filter(this.createFilter());
|
|
34649
34943
|
}
|
|
34650
|
-
test(
|
|
34651
|
-
return this._test(
|
|
34944
|
+
test(path17) {
|
|
34945
|
+
return this._test(path17, this._testCache, true);
|
|
34652
34946
|
}
|
|
34653
34947
|
}
|
|
34654
34948
|
var factory = (options) => new Ignore2(options);
|
|
34655
|
-
var isPathValid = (
|
|
34949
|
+
var isPathValid = (path17) => checkPath(path17 && checkPath.convert(path17), path17, RETURN_FALSE);
|
|
34656
34950
|
factory.isPathValid = isPathValid;
|
|
34657
34951
|
factory.default = factory;
|
|
34658
34952
|
module.exports = factory;
|
|
@@ -34660,7 +34954,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
34660
34954
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
34661
34955
|
checkPath.convert = makePosix;
|
|
34662
34956
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
34663
|
-
checkPath.isNotRelative = (
|
|
34957
|
+
checkPath.isNotRelative = (path17) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path17) || isNotRelative(path17);
|
|
34664
34958
|
}
|
|
34665
34959
|
});
|
|
34666
34960
|
|
|
@@ -34722,13 +35016,13 @@ function validatePolicy(policy, opts = {}) {
|
|
|
34722
35016
|
}
|
|
34723
35017
|
}
|
|
34724
35018
|
}
|
|
34725
|
-
function matchesGlob2(
|
|
35019
|
+
function matchesGlob2(path17, pattern) {
|
|
34726
35020
|
let re = regexCache.get(pattern);
|
|
34727
35021
|
if (!re) {
|
|
34728
35022
|
re = globToRegex(pattern);
|
|
34729
35023
|
regexCache.set(pattern, re);
|
|
34730
35024
|
}
|
|
34731
|
-
return re.test(
|
|
35025
|
+
return re.test(path17);
|
|
34732
35026
|
}
|
|
34733
35027
|
var DEFAULT_POLICY, applyPolicy = (filePath, policy) => {
|
|
34734
35028
|
const normalized = filePath.trim();
|
|
@@ -34745,8 +35039,8 @@ var init_capture_policy = __esm(() => {
|
|
|
34745
35039
|
});
|
|
34746
35040
|
|
|
34747
35041
|
// ../../packages/core/dist/services/search/ignore-patterns.js
|
|
34748
|
-
import
|
|
34749
|
-
import
|
|
35042
|
+
import fs12 from "fs/promises";
|
|
35043
|
+
import path17 from "path";
|
|
34750
35044
|
function buildExtensionGlob(extensions) {
|
|
34751
35045
|
return extensions.map((ext2) => `**/*${ext2}`);
|
|
34752
35046
|
}
|
|
@@ -34769,8 +35063,8 @@ async function loadProjectIgnore(projectPath) {
|
|
|
34769
35063
|
const ig = ignore();
|
|
34770
35064
|
ig.add(DEFAULT_IGNORES);
|
|
34771
35065
|
try {
|
|
34772
|
-
const gitignorePath =
|
|
34773
|
-
const gitignoreContent = await
|
|
35066
|
+
const gitignorePath = path17.join(projectPath, ".gitignore");
|
|
35067
|
+
const gitignoreContent = await fs12.readFile(gitignorePath, "utf8");
|
|
34774
35068
|
const rules = gitignoreContent.split(`
|
|
34775
35069
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
34776
35070
|
ig.add(rules);
|
|
@@ -36369,15 +36663,15 @@ var require_pg_connection_string = __commonJS((exports, module) => {
|
|
|
36369
36663
|
if (config3.sslnegotiation === "direct" && config3.ssl === undefined) {
|
|
36370
36664
|
config3.ssl = true;
|
|
36371
36665
|
}
|
|
36372
|
-
const
|
|
36666
|
+
const fs13 = config3.sslcert || config3.sslkey || config3.sslrootcert ? __require("fs") : null;
|
|
36373
36667
|
if (config3.sslcert) {
|
|
36374
|
-
config3.ssl.cert =
|
|
36668
|
+
config3.ssl.cert = fs13.readFileSync(config3.sslcert).toString();
|
|
36375
36669
|
}
|
|
36376
36670
|
if (config3.sslkey) {
|
|
36377
|
-
config3.ssl.key =
|
|
36671
|
+
config3.ssl.key = fs13.readFileSync(config3.sslkey).toString();
|
|
36378
36672
|
}
|
|
36379
36673
|
if (config3.sslrootcert) {
|
|
36380
|
-
config3.ssl.ca =
|
|
36674
|
+
config3.ssl.ca = fs13.readFileSync(config3.sslrootcert).toString();
|
|
36381
36675
|
}
|
|
36382
36676
|
if (options.useLibpqCompat && config3.uselibpqcompat) {
|
|
36383
36677
|
throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");
|
|
@@ -38091,7 +38385,7 @@ var require_split2 = __commonJS((exports, module) => {
|
|
|
38091
38385
|
|
|
38092
38386
|
// ../../node_modules/pgpass/lib/helper.js
|
|
38093
38387
|
var require_helper = __commonJS((exports, module) => {
|
|
38094
|
-
var
|
|
38388
|
+
var path18 = __require("path");
|
|
38095
38389
|
var Stream2 = __require("stream").Stream;
|
|
38096
38390
|
var split = require_split2();
|
|
38097
38391
|
var util3 = __require("util");
|
|
@@ -38131,7 +38425,7 @@ var require_helper = __commonJS((exports, module) => {
|
|
|
38131
38425
|
};
|
|
38132
38426
|
exports.getFileName = function(rawEnv) {
|
|
38133
38427
|
var env = rawEnv || process.env;
|
|
38134
|
-
var file2 = env.PGPASSFILE || (isWin ?
|
|
38428
|
+
var file2 = env.PGPASSFILE || (isWin ? path18.join(env.APPDATA || "./", "postgresql", "pgpass.conf") : path18.join(env.HOME || "./", ".pgpass"));
|
|
38135
38429
|
return file2;
|
|
38136
38430
|
};
|
|
38137
38431
|
exports.usePgPass = function(stats, fname) {
|
|
@@ -38255,16 +38549,16 @@ var require_helper = __commonJS((exports, module) => {
|
|
|
38255
38549
|
|
|
38256
38550
|
// ../../node_modules/pgpass/lib/index.js
|
|
38257
38551
|
var require_lib = __commonJS((exports, module) => {
|
|
38258
|
-
var
|
|
38259
|
-
var
|
|
38552
|
+
var path18 = __require("path");
|
|
38553
|
+
var fs13 = __require("fs");
|
|
38260
38554
|
var helper = require_helper();
|
|
38261
38555
|
module.exports = function(connInfo, cb) {
|
|
38262
38556
|
var file2 = helper.getFileName();
|
|
38263
|
-
|
|
38557
|
+
fs13.stat(file2, function(err, stat) {
|
|
38264
38558
|
if (err || !helper.usePgPass(stat, file2)) {
|
|
38265
38559
|
return cb(undefined);
|
|
38266
38560
|
}
|
|
38267
|
-
var st =
|
|
38561
|
+
var st = fs13.createReadStream(file2);
|
|
38268
38562
|
helper.getPassword(connInfo, st, cb);
|
|
38269
38563
|
});
|
|
38270
38564
|
};
|
|
@@ -39902,7 +40196,7 @@ class ProjectIdentityAliasResolver {
|
|
|
39902
40196
|
this.cache.set(projectId, { canonical, expiresAt: this.now() + this.ttlMs });
|
|
39903
40197
|
return canonical;
|
|
39904
40198
|
} catch (error51) {
|
|
39905
|
-
logger.warn("[project-identity] alias resolution failed; using original id", safeErrorSummary(error51));
|
|
40199
|
+
logger.warn("[project-identity] alias resolution failed; using original id", { projectId, ...safeErrorSummary(error51) });
|
|
39906
40200
|
return projectId;
|
|
39907
40201
|
}
|
|
39908
40202
|
}
|
|
@@ -39963,8 +40257,8 @@ var init_alias_resolver = __esm(() => {
|
|
|
39963
40257
|
});
|
|
39964
40258
|
|
|
39965
40259
|
// ../../packages/core/dist/services/search/index-manager.js
|
|
39966
|
-
import
|
|
39967
|
-
import
|
|
40260
|
+
import fs13 from "fs";
|
|
40261
|
+
import path18 from "path";
|
|
39968
40262
|
|
|
39969
40263
|
class IndexManager {
|
|
39970
40264
|
metadataCache = new Map;
|
|
@@ -40057,9 +40351,9 @@ class IndexManager {
|
|
|
40057
40351
|
const fileMetadata = {};
|
|
40058
40352
|
let totalSize = 0;
|
|
40059
40353
|
for (const filePath of indexedFiles) {
|
|
40060
|
-
const fullPath =
|
|
40354
|
+
const fullPath = path18.join(projectPath, filePath);
|
|
40061
40355
|
try {
|
|
40062
|
-
const stat = await
|
|
40356
|
+
const stat = await fs13.promises.stat(fullPath);
|
|
40063
40357
|
fileMetadata[filePath] = {
|
|
40064
40358
|
path: filePath,
|
|
40065
40359
|
mtime: stat.mtimeMs,
|
|
@@ -40110,9 +40404,9 @@ class IndexManager {
|
|
|
40110
40404
|
if (ig.ignores(match2)) {
|
|
40111
40405
|
continue;
|
|
40112
40406
|
}
|
|
40113
|
-
const fullPath =
|
|
40407
|
+
const fullPath = path18.join(projectPath, match2);
|
|
40114
40408
|
try {
|
|
40115
|
-
const stat = await
|
|
40409
|
+
const stat = await fs13.promises.stat(fullPath);
|
|
40116
40410
|
files.set(match2, {
|
|
40117
40411
|
path: match2,
|
|
40118
40412
|
mtime: stat.mtimeMs,
|
|
@@ -43365,23 +43659,23 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
43365
43659
|
writeAuthConfig: () => writeAuthConfig
|
|
43366
43660
|
});
|
|
43367
43661
|
module.exports = __toCommonJS2(auth_config_exports);
|
|
43368
|
-
var
|
|
43369
|
-
var
|
|
43662
|
+
var fs14 = __toESM2(__require("fs"));
|
|
43663
|
+
var path19 = __toESM2(__require("path"));
|
|
43370
43664
|
var import_token_util = require_token_util();
|
|
43371
43665
|
function getAuthConfigPath() {
|
|
43372
43666
|
const dataDir = (0, import_token_util.getVercelDataDir)();
|
|
43373
43667
|
if (!dataDir) {
|
|
43374
43668
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
43375
43669
|
}
|
|
43376
|
-
return
|
|
43670
|
+
return path19.join(dataDir, "auth.json");
|
|
43377
43671
|
}
|
|
43378
43672
|
function readAuthConfig() {
|
|
43379
43673
|
try {
|
|
43380
43674
|
const authPath = getAuthConfigPath();
|
|
43381
|
-
if (!
|
|
43675
|
+
if (!fs14.existsSync(authPath)) {
|
|
43382
43676
|
return null;
|
|
43383
43677
|
}
|
|
43384
|
-
const content =
|
|
43678
|
+
const content = fs14.readFileSync(authPath, "utf8");
|
|
43385
43679
|
if (!content) {
|
|
43386
43680
|
return null;
|
|
43387
43681
|
}
|
|
@@ -43392,11 +43686,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
43392
43686
|
}
|
|
43393
43687
|
function writeAuthConfig(config3) {
|
|
43394
43688
|
const authPath = getAuthConfigPath();
|
|
43395
|
-
const authDir =
|
|
43396
|
-
if (!
|
|
43397
|
-
|
|
43689
|
+
const authDir = path19.dirname(authPath);
|
|
43690
|
+
if (!fs14.existsSync(authDir)) {
|
|
43691
|
+
fs14.mkdirSync(authDir, { mode: 504, recursive: true });
|
|
43398
43692
|
}
|
|
43399
|
-
|
|
43693
|
+
fs14.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
|
|
43400
43694
|
}
|
|
43401
43695
|
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
43402
43696
|
if (!authConfig.token)
|
|
@@ -43571,8 +43865,8 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
43571
43865
|
saveToken: () => saveToken
|
|
43572
43866
|
});
|
|
43573
43867
|
module.exports = __toCommonJS2(token_util_exports);
|
|
43574
|
-
var
|
|
43575
|
-
var
|
|
43868
|
+
var path19 = __toESM2(__require("path"));
|
|
43869
|
+
var fs14 = __toESM2(__require("fs"));
|
|
43576
43870
|
var import_token_error = require_token_error();
|
|
43577
43871
|
var import_token_io = require_token_io();
|
|
43578
43872
|
var import_auth_config = require_auth_config();
|
|
@@ -43584,7 +43878,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
43584
43878
|
if (!dataDir) {
|
|
43585
43879
|
return null;
|
|
43586
43880
|
}
|
|
43587
|
-
return
|
|
43881
|
+
return path19.join(dataDir, vercelFolder);
|
|
43588
43882
|
}
|
|
43589
43883
|
async function getVercelToken2(options) {
|
|
43590
43884
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -43652,11 +43946,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
43652
43946
|
if (!dir) {
|
|
43653
43947
|
throw new import_token_error.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");
|
|
43654
43948
|
}
|
|
43655
|
-
const prjPath =
|
|
43656
|
-
if (!
|
|
43949
|
+
const prjPath = path19.join(dir, ".vercel", "project.json");
|
|
43950
|
+
if (!fs14.existsSync(prjPath)) {
|
|
43657
43951
|
throw new import_token_error.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");
|
|
43658
43952
|
}
|
|
43659
|
-
const prj = JSON.parse(
|
|
43953
|
+
const prj = JSON.parse(fs14.readFileSync(prjPath, "utf8"));
|
|
43660
43954
|
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
|
|
43661
43955
|
throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");
|
|
43662
43956
|
}
|
|
@@ -43667,11 +43961,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
43667
43961
|
if (!dir) {
|
|
43668
43962
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
43669
43963
|
}
|
|
43670
|
-
const tokenPath =
|
|
43964
|
+
const tokenPath = path19.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
43671
43965
|
const tokenJson = JSON.stringify(token);
|
|
43672
|
-
|
|
43673
|
-
|
|
43674
|
-
|
|
43966
|
+
fs14.mkdirSync(path19.dirname(tokenPath), { mode: 504, recursive: true });
|
|
43967
|
+
fs14.writeFileSync(tokenPath, tokenJson);
|
|
43968
|
+
fs14.chmodSync(tokenPath, 432);
|
|
43675
43969
|
return;
|
|
43676
43970
|
}
|
|
43677
43971
|
function loadToken(projectId) {
|
|
@@ -43679,11 +43973,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
43679
43973
|
if (!dir) {
|
|
43680
43974
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
43681
43975
|
}
|
|
43682
|
-
const tokenPath =
|
|
43683
|
-
if (!
|
|
43976
|
+
const tokenPath = path19.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
43977
|
+
if (!fs14.existsSync(tokenPath)) {
|
|
43684
43978
|
return null;
|
|
43685
43979
|
}
|
|
43686
|
-
const token = JSON.parse(
|
|
43980
|
+
const token = JSON.parse(fs14.readFileSync(tokenPath, "utf8"));
|
|
43687
43981
|
assertVercelOidcTokenResponse(token);
|
|
43688
43982
|
return token;
|
|
43689
43983
|
}
|
|
@@ -54525,37 +54819,37 @@ function createOpenAI(options = {}) {
|
|
|
54525
54819
|
}, `ai-sdk/openai/${VERSION4}`);
|
|
54526
54820
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
54527
54821
|
provider: `${providerName}.chat`,
|
|
54528
|
-
url: ({ path:
|
|
54822
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
54529
54823
|
headers: getHeaders,
|
|
54530
54824
|
fetch: options.fetch
|
|
54531
54825
|
});
|
|
54532
54826
|
const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
|
|
54533
54827
|
provider: `${providerName}.completion`,
|
|
54534
|
-
url: ({ path:
|
|
54828
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
54535
54829
|
headers: getHeaders,
|
|
54536
54830
|
fetch: options.fetch
|
|
54537
54831
|
});
|
|
54538
54832
|
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
54539
54833
|
provider: `${providerName}.embedding`,
|
|
54540
|
-
url: ({ path:
|
|
54834
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
54541
54835
|
headers: getHeaders,
|
|
54542
54836
|
fetch: options.fetch
|
|
54543
54837
|
});
|
|
54544
54838
|
const createImageModel = (modelId) => new OpenAIImageModel(modelId, {
|
|
54545
54839
|
provider: `${providerName}.image`,
|
|
54546
|
-
url: ({ path:
|
|
54840
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
54547
54841
|
headers: getHeaders,
|
|
54548
54842
|
fetch: options.fetch
|
|
54549
54843
|
});
|
|
54550
54844
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
54551
54845
|
provider: `${providerName}.transcription`,
|
|
54552
|
-
url: ({ path:
|
|
54846
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
54553
54847
|
headers: getHeaders,
|
|
54554
54848
|
fetch: options.fetch
|
|
54555
54849
|
});
|
|
54556
54850
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
54557
54851
|
provider: `${providerName}.speech`,
|
|
54558
|
-
url: ({ path:
|
|
54852
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
54559
54853
|
headers: getHeaders,
|
|
54560
54854
|
fetch: options.fetch
|
|
54561
54855
|
});
|
|
@@ -54568,7 +54862,7 @@ function createOpenAI(options = {}) {
|
|
|
54568
54862
|
const createResponsesModel = (modelId) => {
|
|
54569
54863
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
54570
54864
|
provider: `${providerName}.responses`,
|
|
54571
|
-
url: ({ path:
|
|
54865
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
54572
54866
|
headers: getHeaders,
|
|
54573
54867
|
fetch: options.fetch,
|
|
54574
54868
|
fileIdPrefixes: ["file-"]
|
|
@@ -59009,7 +59303,7 @@ async function _checkJsonSchemaSupport() {
|
|
|
59009
59303
|
} catch (e) {
|
|
59010
59304
|
_jsonSchemaSupported = false;
|
|
59011
59305
|
logger.warn("json_schema: version check error \u2014 falling back to json_object", {
|
|
59012
|
-
error: e
|
|
59306
|
+
error: e
|
|
59013
59307
|
});
|
|
59014
59308
|
return false;
|
|
59015
59309
|
}
|
|
@@ -59057,7 +59351,7 @@ function hostPort(url2) {
|
|
|
59057
59351
|
return null;
|
|
59058
59352
|
}
|
|
59059
59353
|
}
|
|
59060
|
-
function
|
|
59354
|
+
function resolveMatchedProviderSpec(baseUrl) {
|
|
59061
59355
|
const target = hostPort(baseUrl);
|
|
59062
59356
|
if (target) {
|
|
59063
59357
|
const match2 = inferenceProviderList().find((spec) => hostPort(spec.defaultLlmBaseUrl) === target);
|
|
@@ -59075,7 +59369,13 @@ function resolveInferenceSpec(baseUrl) {
|
|
|
59075
59369
|
if (embeddingProvider && LOCAL_INFERENCE_IDS.includes(embeddingProvider)) {
|
|
59076
59370
|
return INFERENCE_PROVIDERS[embeddingProvider];
|
|
59077
59371
|
}
|
|
59078
|
-
return
|
|
59372
|
+
return;
|
|
59373
|
+
}
|
|
59374
|
+
function resolveInferenceSpec(baseUrl) {
|
|
59375
|
+
return resolveMatchedProviderSpec(baseUrl) ?? INFERENCE_PROVIDERS.ollama;
|
|
59376
|
+
}
|
|
59377
|
+
function resolveProviderIdForLogging(baseUrl) {
|
|
59378
|
+
return resolveMatchedProviderSpec(baseUrl)?.id ?? "unknown";
|
|
59079
59379
|
}
|
|
59080
59380
|
function _wrapFetchDisableThink(baseFetch) {
|
|
59081
59381
|
const wrapped = async (input, init) => {
|
|
@@ -59218,12 +59518,40 @@ function _isAbortOrTimeoutError(err) {
|
|
|
59218
59518
|
}
|
|
59219
59519
|
return false;
|
|
59220
59520
|
}
|
|
59221
|
-
|
|
59521
|
+
function summarizeZodIssues(error51, maxIssues = 5) {
|
|
59522
|
+
return error51.issues.slice(0, maxIssues).map((issue2) => `${issue2.path.join(".") || "(root)"}: ${issue2.message}`).join("; ");
|
|
59523
|
+
}
|
|
59524
|
+
function recordLlmFailure(label, role, model, baseUrl, timeoutMs, elapsedMs, err) {
|
|
59525
|
+
const consecutiveFailures = (llmFailureStreaks.get(label) ?? 0) + 1;
|
|
59526
|
+
llmFailureStreaks.set(label, consecutiveFailures);
|
|
59527
|
+
logger.warn("LLM call failed \u2014 using non-LLM fallback", {
|
|
59528
|
+
label,
|
|
59529
|
+
role,
|
|
59530
|
+
model,
|
|
59531
|
+
provider: resolveProviderIdForLogging(baseUrl),
|
|
59532
|
+
timeoutMs,
|
|
59533
|
+
elapsedMs,
|
|
59534
|
+
timedOut: _isAbortOrTimeoutError(err),
|
|
59535
|
+
error: err,
|
|
59536
|
+
consecutiveFailures
|
|
59537
|
+
});
|
|
59538
|
+
return consecutiveFailures;
|
|
59539
|
+
}
|
|
59540
|
+
function recordLlmSuccess(label, model) {
|
|
59541
|
+
const priorFailures = llmFailureStreaks.get(label) ?? 0;
|
|
59542
|
+
if (priorFailures > 0) {
|
|
59543
|
+
logger.info("LLM call recovered", { label, model, afterFailures: priorFailures });
|
|
59544
|
+
}
|
|
59545
|
+
llmFailureStreaks.set(label, 0);
|
|
59546
|
+
}
|
|
59547
|
+
async function llmComplete(prompt, opts) {
|
|
59222
59548
|
if (!isLlmEnabled()) {
|
|
59223
59549
|
return { ok: false, error: "llm disabled" };
|
|
59224
59550
|
}
|
|
59225
59551
|
const llm = getLlmConfig({ modelRole: opts.modelRole });
|
|
59552
|
+
const role = opts.modelRole ?? "instruct";
|
|
59226
59553
|
const timeoutMs = opts.timeoutMs ?? llm.timeoutMs;
|
|
59554
|
+
const startedAt = Date.now();
|
|
59227
59555
|
try {
|
|
59228
59556
|
const result = await generateText({
|
|
59229
59557
|
model: buildProvider(llm),
|
|
@@ -59234,14 +59562,17 @@ async function llmComplete(prompt, opts = {}) {
|
|
|
59234
59562
|
abortSignal: timeoutSignal(timeoutMs)
|
|
59235
59563
|
});
|
|
59236
59564
|
const text2 = result.text ?? "";
|
|
59237
|
-
if (text2.length > 0)
|
|
59565
|
+
if (text2.length > 0) {
|
|
59566
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59238
59567
|
return { ok: true, value: text2 };
|
|
59568
|
+
}
|
|
59239
59569
|
if (llm.disableThink) {
|
|
59240
59570
|
const reasoning = _reasoningToText(result);
|
|
59241
59571
|
if (reasoning.length > 0) {
|
|
59242
59572
|
logger.warn("llmComplete: empty content \u2014 recovered from reasoning channel", {
|
|
59243
59573
|
reasoningLen: reasoning.length
|
|
59244
59574
|
});
|
|
59575
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59245
59576
|
return { ok: true, value: reasoning };
|
|
59246
59577
|
}
|
|
59247
59578
|
logger.warn("llm reasoning-recovery empty", {
|
|
@@ -59249,21 +59580,22 @@ async function llmComplete(prompt, opts = {}) {
|
|
|
59249
59580
|
finishReason: result?.finishReason ?? null
|
|
59250
59581
|
});
|
|
59251
59582
|
}
|
|
59252
|
-
|
|
59253
|
-
|
|
59583
|
+
const emptyErr = new Error("empty content (thinking model)");
|
|
59584
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, emptyErr);
|
|
59585
|
+
return { ok: false, error: emptyErr.message };
|
|
59254
59586
|
} catch (e) {
|
|
59255
|
-
|
|
59256
|
-
error: e.message
|
|
59257
|
-
});
|
|
59587
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, e);
|
|
59258
59588
|
return { ok: false, error: e.message };
|
|
59259
59589
|
}
|
|
59260
59590
|
}
|
|
59261
|
-
async function llmObject(prompt, schema, opts
|
|
59591
|
+
async function llmObject(prompt, schema, opts) {
|
|
59262
59592
|
if (!isLlmEnabled()) {
|
|
59263
59593
|
return { ok: false, error: "llm disabled" };
|
|
59264
59594
|
}
|
|
59265
59595
|
const llm = getLlmConfig({ modelRole: opts.modelRole });
|
|
59596
|
+
const role = opts.modelRole ?? "instruct";
|
|
59266
59597
|
const timeoutMs = opts.timeoutMs ?? llm.timeoutMs;
|
|
59598
|
+
const startedAt = Date.now();
|
|
59267
59599
|
let result = null;
|
|
59268
59600
|
try {
|
|
59269
59601
|
const useJsonSchema = llm.disableThink && await _checkJsonSchemaSupport();
|
|
@@ -59278,7 +59610,8 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
59278
59610
|
maxOutputTokens: llm.maxOutputTokens,
|
|
59279
59611
|
abortSignal: timeoutSignal(timeoutMs)
|
|
59280
59612
|
});
|
|
59281
|
-
logger.
|
|
59613
|
+
logger.debug("json_schema: constrained decoding used", { label: opts.label, model: llm.model });
|
|
59614
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59282
59615
|
return { ok: true, value: result.object };
|
|
59283
59616
|
}
|
|
59284
59617
|
result = await generateObject({
|
|
@@ -59292,7 +59625,8 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
59292
59625
|
});
|
|
59293
59626
|
const validated = schema.safeParse(result.object);
|
|
59294
59627
|
if (validated.success) {
|
|
59295
|
-
logger.
|
|
59628
|
+
logger.debug("json_schema: fallback to json_object \u2014 validated", { label: opts.label, model: llm.model });
|
|
59629
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59296
59630
|
return { ok: true, value: validated.data };
|
|
59297
59631
|
}
|
|
59298
59632
|
if (llm.disableThink) {
|
|
@@ -59305,15 +59639,17 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
59305
59639
|
logger.warn("llmObject: recovered object from reasoning channel (fallback path)", {
|
|
59306
59640
|
reasoningLen: reasoning.length
|
|
59307
59641
|
});
|
|
59642
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59308
59643
|
return { ok: true, value: recovered.data };
|
|
59309
59644
|
}
|
|
59310
59645
|
}
|
|
59311
59646
|
}
|
|
59312
59647
|
}
|
|
59313
|
-
|
|
59314
|
-
|
|
59648
|
+
const validationErr = new Error("schema validation failed (fallback path)", {
|
|
59649
|
+
cause: summarizeZodIssues(validated.error)
|
|
59315
59650
|
});
|
|
59316
|
-
|
|
59651
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, validationErr);
|
|
59652
|
+
return { ok: false, error: validationErr.message };
|
|
59317
59653
|
} catch (e) {
|
|
59318
59654
|
if (llm.disableThink && !_isAbortOrTimeoutError(e)) {
|
|
59319
59655
|
const reasoning = _reasoningToText(result).length > 0 ? _reasoningToText(result) : _reasoningToText(e);
|
|
@@ -59325,6 +59661,7 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
59325
59661
|
logger.warn("llmObject: recovered object from reasoning channel", {
|
|
59326
59662
|
reasoningLen: reasoning.length
|
|
59327
59663
|
});
|
|
59664
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59328
59665
|
return { ok: true, value: validated.data };
|
|
59329
59666
|
}
|
|
59330
59667
|
}
|
|
@@ -59334,19 +59671,18 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
59334
59671
|
finishReason: e?.finishReason ?? null
|
|
59335
59672
|
});
|
|
59336
59673
|
}
|
|
59337
|
-
|
|
59338
|
-
error: e.message
|
|
59339
|
-
});
|
|
59674
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, e);
|
|
59340
59675
|
return { ok: false, error: e.message };
|
|
59341
59676
|
}
|
|
59342
59677
|
}
|
|
59343
|
-
var _jsonSchemaSupported = null, testEnabledOverride = null, testBaseUrlOverride = null, llm;
|
|
59678
|
+
var _jsonSchemaSupported = null, testEnabledOverride = null, testBaseUrlOverride = null, llmFailureStreaks, llm;
|
|
59344
59679
|
var init_llm_client = __esm(() => {
|
|
59345
59680
|
init_dist6();
|
|
59346
59681
|
init_dist7();
|
|
59347
59682
|
init_dist();
|
|
59348
59683
|
init_config();
|
|
59349
59684
|
init_inference_providers();
|
|
59685
|
+
llmFailureStreaks = new Map;
|
|
59350
59686
|
llm = {
|
|
59351
59687
|
complete: llmComplete,
|
|
59352
59688
|
object: llmObject,
|
|
@@ -68359,7 +68695,7 @@ class MetricsCollector2 {
|
|
|
68359
68695
|
try {
|
|
68360
68696
|
writeFileSync(this.metricsPath, JSON.stringify(this.currentMetrics, null, 2));
|
|
68361
68697
|
} catch (error51) {
|
|
68362
|
-
logger.error("
|
|
68698
|
+
logger.error("Metrics: failed to save", error51, { path: this.metricsPath });
|
|
68363
68699
|
}
|
|
68364
68700
|
}
|
|
68365
68701
|
reset() {
|
|
@@ -68534,7 +68870,8 @@ class EmbeddingRateLimiter {
|
|
|
68534
68870
|
}
|
|
68535
68871
|
}
|
|
68536
68872
|
if (this.config.requestsPerDay && this.dailyRequestsWindow.length >= this.config.requestsPerDay) {
|
|
68537
|
-
logger.warn(
|
|
68873
|
+
logger.warn("EmbeddingRateLimiter: RPD limit reached, waiting 60s", {
|
|
68874
|
+
providerId: this.providerId,
|
|
68538
68875
|
rpd: this.config.requestsPerDay,
|
|
68539
68876
|
current: this.dailyRequestsWindow.length
|
|
68540
68877
|
});
|
|
@@ -71180,26 +71517,26 @@ var require_process = __commonJS((exports, module) => {
|
|
|
71180
71517
|
|
|
71181
71518
|
// ../../node_modules/detect-libc/lib/filesystem.js
|
|
71182
71519
|
var require_filesystem = __commonJS((exports, module) => {
|
|
71183
|
-
var
|
|
71520
|
+
var fs14 = __require("fs");
|
|
71184
71521
|
var LDD_PATH = "/usr/bin/ldd";
|
|
71185
71522
|
var SELF_PATH = "/proc/self/exe";
|
|
71186
71523
|
var MAX_LENGTH = 2048;
|
|
71187
|
-
var readFileSync2 = (
|
|
71188
|
-
const fd =
|
|
71524
|
+
var readFileSync2 = (path19) => {
|
|
71525
|
+
const fd = fs14.openSync(path19, "r");
|
|
71189
71526
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
71190
|
-
const bytesRead =
|
|
71191
|
-
|
|
71527
|
+
const bytesRead = fs14.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
71528
|
+
fs14.close(fd, () => {});
|
|
71192
71529
|
return buffer.subarray(0, bytesRead);
|
|
71193
71530
|
};
|
|
71194
|
-
var readFile = (
|
|
71195
|
-
|
|
71531
|
+
var readFile = (path19) => new Promise((resolve4, reject) => {
|
|
71532
|
+
fs14.open(path19, "r", (err, fd) => {
|
|
71196
71533
|
if (err) {
|
|
71197
71534
|
reject(err);
|
|
71198
71535
|
} else {
|
|
71199
71536
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
71200
|
-
|
|
71537
|
+
fs14.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
71201
71538
|
resolve4(buffer.subarray(0, bytesRead));
|
|
71202
|
-
|
|
71539
|
+
fs14.close(fd, () => {});
|
|
71203
71540
|
});
|
|
71204
71541
|
}
|
|
71205
71542
|
});
|
|
@@ -71304,11 +71641,11 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
71304
71641
|
}
|
|
71305
71642
|
return null;
|
|
71306
71643
|
};
|
|
71307
|
-
var familyFromInterpreterPath = (
|
|
71308
|
-
if (
|
|
71309
|
-
if (
|
|
71644
|
+
var familyFromInterpreterPath = (path19) => {
|
|
71645
|
+
if (path19) {
|
|
71646
|
+
if (path19.includes("/ld-musl-")) {
|
|
71310
71647
|
return MUSL;
|
|
71311
|
-
} else if (
|
|
71648
|
+
} else if (path19.includes("/ld-linux-")) {
|
|
71312
71649
|
return GLIBC;
|
|
71313
71650
|
}
|
|
71314
71651
|
}
|
|
@@ -71353,8 +71690,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
71353
71690
|
cachedFamilyInterpreter = null;
|
|
71354
71691
|
try {
|
|
71355
71692
|
const selfContent = await readFile(SELF_PATH);
|
|
71356
|
-
const
|
|
71357
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
71693
|
+
const path19 = interpreterPath(selfContent);
|
|
71694
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path19);
|
|
71358
71695
|
} catch (e) {}
|
|
71359
71696
|
return cachedFamilyInterpreter;
|
|
71360
71697
|
};
|
|
@@ -71365,8 +71702,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
71365
71702
|
cachedFamilyInterpreter = null;
|
|
71366
71703
|
try {
|
|
71367
71704
|
const selfContent = readFileSync2(SELF_PATH);
|
|
71368
|
-
const
|
|
71369
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
71705
|
+
const path19 = interpreterPath(selfContent);
|
|
71706
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path19);
|
|
71370
71707
|
} catch (e) {}
|
|
71371
71708
|
return cachedFamilyInterpreter;
|
|
71372
71709
|
};
|
|
@@ -73028,18 +73365,18 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
73028
73365
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
73029
73366
|
"@img/sharp-wasm32/sharp.node"
|
|
73030
73367
|
];
|
|
73031
|
-
var
|
|
73368
|
+
var path19;
|
|
73032
73369
|
var sharp;
|
|
73033
73370
|
var errors4 = [];
|
|
73034
|
-
for (
|
|
73371
|
+
for (path19 of paths) {
|
|
73035
73372
|
try {
|
|
73036
|
-
sharp = __require(
|
|
73373
|
+
sharp = __require(path19);
|
|
73037
73374
|
break;
|
|
73038
73375
|
} catch (err) {
|
|
73039
73376
|
errors4.push(err);
|
|
73040
73377
|
}
|
|
73041
73378
|
}
|
|
73042
|
-
if (sharp &&
|
|
73379
|
+
if (sharp && path19.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
73043
73380
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
73044
73381
|
err.code = "Unsupported CPU";
|
|
73045
73382
|
errors4.push(err);
|
|
@@ -73048,7 +73385,7 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
73048
73385
|
if (sharp) {
|
|
73049
73386
|
module.exports = sharp;
|
|
73050
73387
|
} else {
|
|
73051
|
-
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((
|
|
73388
|
+
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((os9) => runtimePlatform.startsWith(os9));
|
|
73052
73389
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
73053
73390
|
errors4.forEach((err) => {
|
|
73054
73391
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -73061,9 +73398,9 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
73061
73398
|
const { found, expected } = isUnsupportedNodeRuntime();
|
|
73062
73399
|
help.push("- Please upgrade Node.js:", ` Found ${found}`, ` Requires ${expected}`);
|
|
73063
73400
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
73064
|
-
const [
|
|
73065
|
-
const libc =
|
|
73066
|
-
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=${
|
|
73401
|
+
const [os9, cpu] = runtimePlatform.split("-");
|
|
73402
|
+
const libc = os9.endsWith("musl") ? " --libc=musl" : "";
|
|
73403
|
+
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`);
|
|
73067
73404
|
} else {
|
|
73068
73405
|
help.push(`- Manually install libvips >= ${minimumLibvipsVersion}`, "- Add experimental WebAssembly-based dependencies:", " npm install --cpu=wasm32 sharp", " npm install @img/sharp-wasm32");
|
|
73069
73406
|
}
|
|
@@ -75901,15 +76238,15 @@ var require_color = __commonJS((exports, module) => {
|
|
|
75901
76238
|
};
|
|
75902
76239
|
}
|
|
75903
76240
|
function wrapConversion(toModel, graph) {
|
|
75904
|
-
const
|
|
76241
|
+
const path19 = [graph[toModel].parent, toModel];
|
|
75905
76242
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
75906
76243
|
let cur = graph[toModel].parent;
|
|
75907
76244
|
while (graph[cur].parent) {
|
|
75908
|
-
|
|
76245
|
+
path19.unshift(graph[cur].parent);
|
|
75909
76246
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
75910
76247
|
cur = graph[cur].parent;
|
|
75911
76248
|
}
|
|
75912
|
-
fn.conversion =
|
|
76249
|
+
fn.conversion = path19;
|
|
75913
76250
|
return fn;
|
|
75914
76251
|
}
|
|
75915
76252
|
function route(fromModel) {
|
|
@@ -76514,7 +76851,7 @@ var require_output = __commonJS((exports, module) => {
|
|
|
76514
76851
|
Copyright 2013 Lovell Fuller and others.
|
|
76515
76852
|
SPDX-License-Identifier: Apache-2.0
|
|
76516
76853
|
*/
|
|
76517
|
-
var
|
|
76854
|
+
var path19 = __require("path");
|
|
76518
76855
|
var is = require_is();
|
|
76519
76856
|
var sharp = require_sharp();
|
|
76520
76857
|
var formats = new Map([
|
|
@@ -76545,9 +76882,9 @@ var require_output = __commonJS((exports, module) => {
|
|
|
76545
76882
|
let err;
|
|
76546
76883
|
if (!is.string(fileOut)) {
|
|
76547
76884
|
err = new Error("Missing output file path");
|
|
76548
|
-
} else if (is.string(this.options.input.file) &&
|
|
76885
|
+
} else if (is.string(this.options.input.file) && path19.resolve(this.options.input.file) === path19.resolve(fileOut)) {
|
|
76549
76886
|
err = new Error("Cannot use same file for input and output");
|
|
76550
|
-
} else if (jp2Regex.test(
|
|
76887
|
+
} else if (jp2Regex.test(path19.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
76551
76888
|
err = errJp2Save();
|
|
76552
76889
|
}
|
|
76553
76890
|
if (err) {
|
|
@@ -83794,11 +84131,11 @@ var init_transformers_node = __esm(() => {
|
|
|
83794
84131
|
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}).`);
|
|
83795
84132
|
}
|
|
83796
84133
|
for (let i = 0;i < num_chunks; ++i) {
|
|
83797
|
-
const
|
|
83798
|
-
const fullPath = `${options.subfolder ?? ""}/${
|
|
84134
|
+
const path19 = `${baseName}_data${i === 0 ? "" : "_" + i}`;
|
|
84135
|
+
const fullPath = `${options.subfolder ?? ""}/${path19}`;
|
|
83799
84136
|
externalDataPromises.push(new Promise(async (resolve4, reject) => {
|
|
83800
84137
|
const data = await (0, _utils_hub_js__WEBPACK_IMPORTED_MODULE_5__.getModelFile)(pretrained_model_name_or_path, fullPath, true, options, return_path);
|
|
83801
|
-
resolve4(data instanceof Uint8Array ? { path:
|
|
84138
|
+
resolve4(data instanceof Uint8Array ? { path: path19, data } : path19);
|
|
83802
84139
|
}));
|
|
83803
84140
|
}
|
|
83804
84141
|
} else if (session_options.externalData !== undefined) {
|
|
@@ -96862,7 +97199,7 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
96862
97199
|
const blob = new Blob([wav], { type: "audio/wav" });
|
|
96863
97200
|
return blob;
|
|
96864
97201
|
}
|
|
96865
|
-
async save(
|
|
97202
|
+
async save(path19) {
|
|
96866
97203
|
let fn;
|
|
96867
97204
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_BROWSER_ENV) {
|
|
96868
97205
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_WEBWORKER_ENV) {
|
|
@@ -96870,14 +97207,14 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
96870
97207
|
}
|
|
96871
97208
|
fn = _core_js__WEBPACK_IMPORTED_MODULE_2__.saveBlob;
|
|
96872
97209
|
} else if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_FS_AVAILABLE) {
|
|
96873
|
-
fn = async (
|
|
97210
|
+
fn = async (path20, blob) => {
|
|
96874
97211
|
let buffer = await blob.arrayBuffer();
|
|
96875
|
-
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(
|
|
97212
|
+
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(path20, Buffer.from(buffer));
|
|
96876
97213
|
};
|
|
96877
97214
|
} else {
|
|
96878
97215
|
throw new Error("Unable to save because filesystem is disabled in this environment.");
|
|
96879
97216
|
}
|
|
96880
|
-
await fn(
|
|
97217
|
+
await fn(path19, this.toBlob());
|
|
96881
97218
|
}
|
|
96882
97219
|
}
|
|
96883
97220
|
},
|
|
@@ -96973,11 +97310,11 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
96973
97310
|
function calculateReflectOffset(i, w) {
|
|
96974
97311
|
return Math.abs((i + w) % (2 * w) - w);
|
|
96975
97312
|
}
|
|
96976
|
-
function saveBlob(
|
|
97313
|
+
function saveBlob(path19, blob) {
|
|
96977
97314
|
const dataURL = URL.createObjectURL(blob);
|
|
96978
97315
|
const downloadLink = document.createElement("a");
|
|
96979
97316
|
downloadLink.href = dataURL;
|
|
96980
|
-
downloadLink.download =
|
|
97317
|
+
downloadLink.download = path19;
|
|
96981
97318
|
downloadLink.click();
|
|
96982
97319
|
downloadLink.remove();
|
|
96983
97320
|
URL.revokeObjectURL(dataURL);
|
|
@@ -97578,8 +97915,8 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
97578
97915
|
}
|
|
97579
97916
|
|
|
97580
97917
|
class FileCache {
|
|
97581
|
-
constructor(
|
|
97582
|
-
this.path =
|
|
97918
|
+
constructor(path19) {
|
|
97919
|
+
this.path = path19;
|
|
97583
97920
|
}
|
|
97584
97921
|
async match(request) {
|
|
97585
97922
|
let filePath = node_path__WEBPACK_IMPORTED_MODULE_1__["default"].join(this.path, request);
|
|
@@ -98335,20 +98672,20 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
98335
98672
|
}
|
|
98336
98673
|
return this;
|
|
98337
98674
|
}
|
|
98338
|
-
async save(
|
|
98675
|
+
async save(path19) {
|
|
98339
98676
|
if (IS_BROWSER_OR_WEBWORKER) {
|
|
98340
98677
|
if (_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_WEBWORKER_ENV) {
|
|
98341
98678
|
throw new Error("Unable to save an image from a Web Worker.");
|
|
98342
98679
|
}
|
|
98343
|
-
const extension =
|
|
98680
|
+
const extension = path19.split(".").pop().toLowerCase();
|
|
98344
98681
|
const mime = CONTENT_TYPE_MAP.get(extension) ?? "image/png";
|
|
98345
98682
|
const blob = await this.toBlob(mime);
|
|
98346
|
-
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(
|
|
98683
|
+
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(path19, blob);
|
|
98347
98684
|
} else if (!_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_FS_AVAILABLE) {
|
|
98348
98685
|
throw new Error("Unable to save the image because filesystem is disabled in this environment.");
|
|
98349
98686
|
} else {
|
|
98350
98687
|
const img = this.toSharp();
|
|
98351
|
-
return await img.toFile(
|
|
98688
|
+
return await img.toFile(path19);
|
|
98352
98689
|
}
|
|
98353
98690
|
}
|
|
98354
98691
|
toSharp() {
|
|
@@ -101837,16 +102174,16 @@ class LocalTransformersEmbeddingProvider {
|
|
|
101837
102174
|
const out = await extractor("test", { pooling: "mean", normalize: true });
|
|
101838
102175
|
const vec = Array.from(out.data);
|
|
101839
102176
|
if (!Array.isArray(vec) || vec.length !== this.dimensions) {
|
|
101840
|
-
logger.error(
|
|
102177
|
+
logger.error("LocalTransformersProvider: invalid embedding dimensions", undefined, { providerId: this.id, expected: this.dimensions, got: vec.length });
|
|
101841
102178
|
return false;
|
|
101842
102179
|
}
|
|
101843
102180
|
if (vec.some((v) => typeof v !== "number" || isNaN(v))) {
|
|
101844
|
-
logger.error(
|
|
102181
|
+
logger.error("LocalTransformersProvider: invalid embedding values (not numbers)", undefined, { providerId: this.id });
|
|
101845
102182
|
return false;
|
|
101846
102183
|
}
|
|
101847
102184
|
return true;
|
|
101848
102185
|
} catch (error51) {
|
|
101849
|
-
logger.error(
|
|
102186
|
+
logger.error("LocalTransformersProvider: provider unavailable", error51, { providerId: this.id });
|
|
101850
102187
|
return false;
|
|
101851
102188
|
}
|
|
101852
102189
|
}
|
|
@@ -101886,7 +102223,13 @@ async function withRetry(fn, config3, context2) {
|
|
|
101886
102223
|
lastError2 = error51;
|
|
101887
102224
|
if (attempt < config3.maxRetries) {
|
|
101888
102225
|
const delay2 = getRetryDelay(attempt, config3);
|
|
101889
|
-
logger.warn(
|
|
102226
|
+
logger.warn("EmbeddingProvider: operation failed, retrying", {
|
|
102227
|
+
context: context2,
|
|
102228
|
+
attempt: attempt + 1,
|
|
102229
|
+
maxAttempts: config3.maxRetries + 1,
|
|
102230
|
+
delayMs: delay2,
|
|
102231
|
+
error: lastError2
|
|
102232
|
+
});
|
|
101890
102233
|
await sleep(delay2);
|
|
101891
102234
|
}
|
|
101892
102235
|
}
|
|
@@ -102202,7 +102545,7 @@ var init_provider = __esm(() => {
|
|
|
102202
102545
|
return output;
|
|
102203
102546
|
}, this.retryConfig, `[${this.id}] embedBatchDirect (${texts.length} texts)`), this.timeout, `[${this.id}] embedBatchDirect`);
|
|
102204
102547
|
} catch (error51) {
|
|
102205
|
-
logger.warn(
|
|
102548
|
+
logger.warn("EmbeddingProvider: Ollama batch endpoint unavailable, falling back to sequential embeds", { providerId: this.id, textCount: texts.length, error: error51 });
|
|
102206
102549
|
const embeddings = [];
|
|
102207
102550
|
let consecutiveFailures = 0;
|
|
102208
102551
|
for (const text2 of texts) {
|
|
@@ -102241,11 +102584,11 @@ var init_provider = __esm(() => {
|
|
|
102241
102584
|
});
|
|
102242
102585
|
clearTimeout(timeoutId);
|
|
102243
102586
|
if (!response.ok) {
|
|
102244
|
-
logger.error(
|
|
102587
|
+
logger.error("EmbeddingProvider: Ollama API returned non-OK status", undefined, { providerId: this.id, status: response.status });
|
|
102245
102588
|
return false;
|
|
102246
102589
|
}
|
|
102247
102590
|
} catch {
|
|
102248
|
-
logger.error(
|
|
102591
|
+
logger.error("EmbeddingProvider: Ollama service unreachable", undefined, { providerId: this.id, baseURL: this.baseURL, timeoutMs: 2000 });
|
|
102249
102592
|
return false;
|
|
102250
102593
|
}
|
|
102251
102594
|
}
|
|
@@ -102255,16 +102598,16 @@ var init_provider = __esm(() => {
|
|
|
102255
102598
|
if (Array.isArray(embedding)) {
|
|
102256
102599
|
this.lastDimensionMismatch = new DimensionMismatchError(this.id, this.dimensions, embedding.length);
|
|
102257
102600
|
}
|
|
102258
|
-
logger.error(
|
|
102601
|
+
logger.error("EmbeddingProvider: invalid embedding dimensions", undefined, { providerId: this.id, expected: this.dimensions, got: embedding.length });
|
|
102259
102602
|
return false;
|
|
102260
102603
|
}
|
|
102261
102604
|
if (!embedding.every((v) => typeof v === "number" && !isNaN(v))) {
|
|
102262
|
-
logger.error(
|
|
102605
|
+
logger.error("EmbeddingProvider: invalid embedding values (not numbers)", undefined, { providerId: this.id });
|
|
102263
102606
|
return false;
|
|
102264
102607
|
}
|
|
102265
102608
|
return true;
|
|
102266
102609
|
} catch (error51) {
|
|
102267
|
-
logger.error(
|
|
102610
|
+
logger.error("EmbeddingProvider: provider unavailable", error51, { providerId: this.id });
|
|
102268
102611
|
return false;
|
|
102269
102612
|
}
|
|
102270
102613
|
}
|
|
@@ -107577,7 +107920,7 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a;
|
|
|
107577
107920
|
function ns(e = Yo, t = Yo) {
|
|
107578
107921
|
return (r) => e(t(r));
|
|
107579
107922
|
}
|
|
107580
|
-
function
|
|
107923
|
+
function os9({ dataPath: e, modelName: t, args: r, runtimeDataModel: n }) {
|
|
107581
107924
|
let i = { modelName: t, args: r ?? {} }, o = dp(e);
|
|
107582
107925
|
if (!o || o.length === 0)
|
|
107583
107926
|
return i;
|
|
@@ -107882,10 +108225,10 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a;
|
|
|
107882
108225
|
super(t, "P2023", r);
|
|
107883
108226
|
}
|
|
107884
108227
|
};
|
|
107885
|
-
var
|
|
108228
|
+
var fs14 = new WeakMap;
|
|
107886
108229
|
function Ep(e) {
|
|
107887
|
-
let t =
|
|
107888
|
-
return t || (t = Object.entries(e),
|
|
108230
|
+
let t = fs14.get(e);
|
|
108231
|
+
return t || (t = Object.entries(e), fs14.set(e, t)), t;
|
|
107889
108232
|
}
|
|
107890
108233
|
function hs(e, t, r) {
|
|
107891
108234
|
switch (t.type) {
|
|
@@ -111450,7 +111793,7 @@ new PrismaClient({
|
|
|
111450
111793
|
let m = await es(this, d);
|
|
111451
111794
|
if (!d.model)
|
|
111452
111795
|
return m;
|
|
111453
|
-
let g =
|
|
111796
|
+
let g = os9({ dataPath: d.dataPath, modelName: d.model, args: d.args, runtimeDataModel: this._runtimeDataModel });
|
|
111454
111797
|
return Wo({ result: m, modelName: g.modelName, args: g.args, extensions: this._extensions, runtimeDataModel: this._runtimeDataModel, globalOmit: this._globalOmit });
|
|
111455
111798
|
};
|
|
111456
111799
|
return this._tracingHelper.runInChildSpan(s.operation, () => new zl.AsyncResource("prisma-client-request").runInAsyncScope(() => a(o)));
|
|
@@ -111853,7 +112196,7 @@ var require_prisma = __commonJS((exports) => {
|
|
|
111853
112196
|
Prisma.JsonNull = JsonNull2;
|
|
111854
112197
|
Prisma.AnyNull = AnyNull2;
|
|
111855
112198
|
Prisma.NullTypes = NullTypes2;
|
|
111856
|
-
var
|
|
112199
|
+
var path19 = __require("path");
|
|
111857
112200
|
exports.Prisma.TransactionIsolationLevel = makeStrictEnum2({
|
|
111858
112201
|
ReadUncommitted: "ReadUncommitted",
|
|
111859
112202
|
ReadCommitted: "ReadCommitted",
|
|
@@ -114480,7 +114823,7 @@ function getPrismaClient2() {
|
|
|
114480
114823
|
const pg2 = _adapters.loadPg();
|
|
114481
114824
|
const { PrismaPg: PrismaPg2 } = _adapters.loadPrismaPg();
|
|
114482
114825
|
const pool = new pg2.Pool({ connectionString: databaseUrl, max: 10, idleTimeoutMillis: 30000, connectionTimeoutMillis: 5000 });
|
|
114483
|
-
pool.on("error", (error51) => logger.error("
|
|
114826
|
+
pool.on("error", (error51) => logger.error("prisma-client: unexpected PG pool error", error51, { poolMax: 10 }));
|
|
114484
114827
|
prismaPool = pool;
|
|
114485
114828
|
prismaInstance = new import_prisma.PrismaClient({ adapter: new PrismaPg2(pool) });
|
|
114486
114829
|
logger.info("Prisma Client initialized with PostgreSQL");
|
|
@@ -114789,7 +115132,10 @@ var init_config2 = __esm(() => {
|
|
|
114789
115132
|
"local"
|
|
114790
115133
|
]);
|
|
114791
115134
|
if (!SELECTABLE_PROVIDERS.has(selectedProvider)) {
|
|
114792
|
-
logger.warn(
|
|
115135
|
+
logger.warn("EmbeddingConfig: selected provider has no runtime entry, falling back to priority order", {
|
|
115136
|
+
selectedProvider,
|
|
115137
|
+
source: process.env.EMBEDDING_PROVIDER ? "EMBEDDING_PROVIDER env" : "config.json embedding.provider"
|
|
115138
|
+
});
|
|
114793
115139
|
}
|
|
114794
115140
|
embeddingProviders = {
|
|
114795
115141
|
google: (() => {
|
|
@@ -114829,7 +115175,12 @@ var init_config2 = __esm(() => {
|
|
|
114829
115175
|
const envDimensions = Number.isInteger(rawEnvDimensions) && rawEnvDimensions > 0 ? rawEnvDimensions : undefined;
|
|
114830
115176
|
const resolvedDimensions = resolveEmbeddingDimensions(model, file2?.dimensions, envDimensions);
|
|
114831
115177
|
if (resolvedDimensions.correctedFrom !== undefined) {
|
|
114832
|
-
logger.warn(
|
|
115178
|
+
logger.warn("EmbeddingConfig: ollama config.json dimensions mismatch corrected", {
|
|
115179
|
+
provider: "ollama",
|
|
115180
|
+
model,
|
|
115181
|
+
configuredDimensions: resolvedDimensions.correctedFrom,
|
|
115182
|
+
correctedDimensions: resolvedDimensions.dimensions
|
|
115183
|
+
});
|
|
114833
115184
|
}
|
|
114834
115185
|
return {
|
|
114835
115186
|
provider: "ollama",
|
|
@@ -114981,8 +115332,8 @@ class EmbeddingService {
|
|
|
114981
115332
|
dimensions: this.provider.dimensions
|
|
114982
115333
|
});
|
|
114983
115334
|
} catch (error51) {
|
|
114984
|
-
logger.error("Failed to initialize embedding service", error51);
|
|
114985
|
-
logger.warn("Embedding service will use fallback mode");
|
|
115335
|
+
logger.error("Failed to initialize embedding service", error51, { stage: "initialize" });
|
|
115336
|
+
logger.warn("Embedding service will use fallback mode", { stage: "initialize" });
|
|
114986
115337
|
}
|
|
114987
115338
|
}
|
|
114988
115339
|
async ensureInitialized() {
|
|
@@ -115064,7 +115415,7 @@ async function tryCreateProvider(config3, providerId, skipHealthCheck) {
|
|
|
115064
115415
|
return { provider };
|
|
115065
115416
|
}
|
|
115066
115417
|
function refuseOnDimensionMismatch(providerId, mismatch) {
|
|
115067
|
-
logger.error(
|
|
115418
|
+
logger.error("EmbeddingProvider: configured provider failed with a dimension mismatch, refusing to fall through", mismatch, { providerId, configuredDimensions: mismatch.expected, modelDimensions: mismatch.got });
|
|
115068
115419
|
throw mismatch;
|
|
115069
115420
|
}
|
|
115070
115421
|
async function createEmbeddingProvider(options = {}) {
|
|
@@ -115163,6 +115514,7 @@ Write the hypothetical implementation paragraph.`;
|
|
|
115163
115514
|
}
|
|
115164
115515
|
async function rewriteQuery(query, surface, opts = {}) {
|
|
115165
115516
|
const res = await surface.object(rewritePrompt(query), QueryRewriteSchema, {
|
|
115517
|
+
label: "query-rewrite",
|
|
115166
115518
|
system: REWRITE_SYSTEM,
|
|
115167
115519
|
timeoutMs: opts.timeoutMs
|
|
115168
115520
|
});
|
|
@@ -115175,6 +115527,7 @@ async function rewriteQuery(query, surface, opts = {}) {
|
|
|
115175
115527
|
}
|
|
115176
115528
|
async function hyde(query, surface, embedFn, opts = {}) {
|
|
115177
115529
|
const text2 = await surface.complete(hydePrompt(query), {
|
|
115530
|
+
label: "hyde",
|
|
115178
115531
|
system: HYDE_SYSTEM,
|
|
115179
115532
|
timeoutMs: opts.timeoutMs
|
|
115180
115533
|
});
|
|
@@ -115188,7 +115541,7 @@ async function hyde(query, surface, embedFn, opts = {}) {
|
|
|
115188
115541
|
return vec;
|
|
115189
115542
|
} catch (e) {
|
|
115190
115543
|
logger.warn("hyde embed failed \u2014 skipping HyDE stream", {
|
|
115191
|
-
error: e
|
|
115544
|
+
error: e
|
|
115192
115545
|
});
|
|
115193
115546
|
return null;
|
|
115194
115547
|
}
|
|
@@ -116916,7 +117269,7 @@ class KeywordSearchPg {
|
|
|
116916
117269
|
`);
|
|
116917
117270
|
this.trigramAvailable = true;
|
|
116918
117271
|
} catch (error51) {
|
|
116919
|
-
logger.warn("pg_trgm unavailable \u2014 trigram RRF stream disabled on PG", {
|
|
117272
|
+
logger.warn("pg_trgm unavailable \u2014 trigram RRF stream disabled on PG", { error: error51 });
|
|
116920
117273
|
this.trigramAvailable = false;
|
|
116921
117274
|
}
|
|
116922
117275
|
logger.info("PostgreSQL keyword search initialized", {
|
|
@@ -117455,7 +117808,8 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
117455
117808
|
this.schemaDimensions = providerDimensions;
|
|
117456
117809
|
const { rows } = await client.query(`SELECT tablename FROM pg_tables WHERE tablename = $1`, [this.tableName]);
|
|
117457
117810
|
if (rows.length === 0) {
|
|
117458
|
-
logger.warn(
|
|
117811
|
+
logger.warn("PostgresVectorStore: table not found, creating fallback table", {
|
|
117812
|
+
tableName: this.tableName,
|
|
117459
117813
|
note: 'Run "prisma migrate deploy" to create tables via migrations'
|
|
117460
117814
|
});
|
|
117461
117815
|
await this.createFallbackTable(client, providerDimensions);
|
|
@@ -117492,10 +117846,12 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
117492
117846
|
if (projects.length === 0)
|
|
117493
117847
|
continue;
|
|
117494
117848
|
const otherDim = tablename.match(/_([0-9]+)d$/)?.[1];
|
|
117495
|
-
logger.warn(
|
|
117849
|
+
logger.warn("PostgresVectorStore: orphaned chunks detected, embedding model likely changed, reindex required", {
|
|
117496
117850
|
currentTable: this.tableName,
|
|
117497
117851
|
currentCount,
|
|
117852
|
+
currentDim,
|
|
117498
117853
|
orphanedTable: tablename,
|
|
117854
|
+
orphanedDim: otherDim,
|
|
117499
117855
|
affectedProjects: projects.map((p) => ({ projectId: p.project_id, chunks: p.n }))
|
|
117500
117856
|
});
|
|
117501
117857
|
}
|
|
@@ -117639,7 +117995,7 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
117639
117995
|
logger.warn("[postgres] Sub-batch embedding failed, falling back per-document", {
|
|
117640
117996
|
subBatchIndex: Math.floor(i / EMBED_SUB_BATCH_SIZE),
|
|
117641
117997
|
count: subBatch.length,
|
|
117642
|
-
error: error51
|
|
117998
|
+
error: error51
|
|
117643
117999
|
});
|
|
117644
118000
|
}
|
|
117645
118001
|
if (embeddings) {
|
|
@@ -117651,7 +118007,7 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
117651
118007
|
logger.warn("[postgres] Sub-batch insert failed, falling back per-document", {
|
|
117652
118008
|
subBatchIndex: Math.floor(i / EMBED_SUB_BATCH_SIZE),
|
|
117653
118009
|
count: subBatch.length,
|
|
117654
|
-
error: error51
|
|
118010
|
+
error: error51
|
|
117655
118011
|
});
|
|
117656
118012
|
}
|
|
117657
118013
|
}
|
|
@@ -117664,7 +118020,7 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
117664
118020
|
totalFailed++;
|
|
117665
118021
|
logger.warn("[postgres] Skipping document due to embedding/insert error", {
|
|
117666
118022
|
id: doc2.id,
|
|
117667
|
-
error: singleError
|
|
118023
|
+
error: singleError
|
|
117668
118024
|
});
|
|
117669
118025
|
}
|
|
117670
118026
|
}
|
|
@@ -118336,7 +118692,9 @@ class SearchAnalyticsPg {
|
|
|
118336
118692
|
}
|
|
118337
118693
|
trackSearch(event) {
|
|
118338
118694
|
this.trackSearchAsync(event).catch((err) => {
|
|
118339
|
-
logger.error("Failed to track search event", err
|
|
118695
|
+
logger.error("Failed to track search event", err, {
|
|
118696
|
+
projectId: event.projectId
|
|
118697
|
+
});
|
|
118340
118698
|
});
|
|
118341
118699
|
}
|
|
118342
118700
|
async trackSearchAsync(event) {
|
|
@@ -118361,7 +118719,9 @@ class SearchAnalyticsPg {
|
|
|
118361
118719
|
event.score || null
|
|
118362
118720
|
]);
|
|
118363
118721
|
} catch (error51) {
|
|
118364
|
-
logger.error("Failed to track search event in PostgreSQL", error51
|
|
118722
|
+
logger.error("Failed to track search event in PostgreSQL", error51, {
|
|
118723
|
+
projectId: event.projectId
|
|
118724
|
+
});
|
|
118365
118725
|
}
|
|
118366
118726
|
}
|
|
118367
118727
|
async recordQuery(query, projectId, resultsCount = 0, duration3 = 0, cacheHit = false) {
|
|
@@ -120962,7 +121322,11 @@ class GraphStorePg {
|
|
|
120962
121322
|
`;
|
|
120963
121323
|
return rows[0] ? rowToEdge(rows[0]) : null;
|
|
120964
121324
|
} catch (error51) {
|
|
120965
|
-
logger.error("Failed to create edge", error51
|
|
121325
|
+
logger.error("Failed to create edge", error51, {
|
|
121326
|
+
sourceId: edge.sourceId,
|
|
121327
|
+
targetId: edge.targetId,
|
|
121328
|
+
relationType: edge.relationType
|
|
121329
|
+
});
|
|
120966
121330
|
return null;
|
|
120967
121331
|
}
|
|
120968
121332
|
}
|
|
@@ -121558,7 +121922,7 @@ class PgSynapseSessionStore {
|
|
|
121558
121922
|
} catch (e) {
|
|
121559
121923
|
this.hydrateFailedAt = Date.now();
|
|
121560
121924
|
logger.warn("PgSynapseSessionStore hydrate failed (best-effort)", {
|
|
121561
|
-
error: e
|
|
121925
|
+
error: e
|
|
121562
121926
|
});
|
|
121563
121927
|
} finally {
|
|
121564
121928
|
this.hydrating = null;
|
|
@@ -121693,7 +122057,7 @@ class PgSynapseSessionStore {
|
|
|
121693
122057
|
const next = prev.then(fn).catch((e) => {
|
|
121694
122058
|
logger.warn("PgSynapseSessionStore write failed (best-effort)", {
|
|
121695
122059
|
key,
|
|
121696
|
-
error: e
|
|
122060
|
+
error: e
|
|
121697
122061
|
});
|
|
121698
122062
|
});
|
|
121699
122063
|
this.inflight.set(key, next);
|
|
@@ -121799,7 +122163,7 @@ class SessionRegistry {
|
|
|
121799
122163
|
try {
|
|
121800
122164
|
this.store?.save(session);
|
|
121801
122165
|
} catch (error51) {
|
|
121802
|
-
logger.warn("
|
|
122166
|
+
logger.warn("SessionRegistry: store save failed", { sessionId: session.sessionId, error: error51 });
|
|
121803
122167
|
}
|
|
121804
122168
|
return session;
|
|
121805
122169
|
}
|
|
@@ -121807,7 +122171,7 @@ class SessionRegistry {
|
|
|
121807
122171
|
try {
|
|
121808
122172
|
await this.store?.ensureReady();
|
|
121809
122173
|
} catch (error51) {
|
|
121810
|
-
logger.warn("
|
|
122174
|
+
logger.warn("SessionRegistry: store ensureReady failed", { error: error51 });
|
|
121811
122175
|
}
|
|
121812
122176
|
}
|
|
121813
122177
|
async getAsync(sessionId, now2 = Date.now()) {
|
|
@@ -121828,7 +122192,7 @@ class SessionRegistry {
|
|
|
121828
122192
|
session = loaded;
|
|
121829
122193
|
}
|
|
121830
122194
|
} catch (error51) {
|
|
121831
|
-
logger.warn("
|
|
122195
|
+
logger.warn("SessionRegistry: store load failed", { sessionId, error: error51 });
|
|
121832
122196
|
}
|
|
121833
122197
|
}
|
|
121834
122198
|
if (!session)
|
|
@@ -121838,7 +122202,7 @@ class SessionRegistry {
|
|
|
121838
122202
|
try {
|
|
121839
122203
|
this.store?.delete(sessionId);
|
|
121840
122204
|
} catch (error51) {
|
|
121841
|
-
logger.warn("
|
|
122205
|
+
logger.warn("SessionRegistry: store delete (expired) failed", { sessionId, error: error51 });
|
|
121842
122206
|
}
|
|
121843
122207
|
return null;
|
|
121844
122208
|
}
|
|
@@ -121860,7 +122224,7 @@ class SessionRegistry {
|
|
|
121860
122224
|
try {
|
|
121861
122225
|
this.store?.save(session);
|
|
121862
122226
|
} catch (error51) {
|
|
121863
|
-
logger.warn("
|
|
122227
|
+
logger.warn("SessionRegistry: store save (updateTaskContext) failed", { sessionId, error: error51 });
|
|
121864
122228
|
}
|
|
121865
122229
|
return session;
|
|
121866
122230
|
}
|
|
@@ -121887,7 +122251,7 @@ class SessionRegistry {
|
|
|
121887
122251
|
try {
|
|
121888
122252
|
this.store?.recordAccess(sessionId, memoryId, nextCount);
|
|
121889
122253
|
} catch (error51) {
|
|
121890
|
-
logger.warn("
|
|
122254
|
+
logger.warn("SessionRegistry: store recordAccess failed", { sessionId, memoryId, error: error51 });
|
|
121891
122255
|
}
|
|
121892
122256
|
}
|
|
121893
122257
|
delete(sessionId) {
|
|
@@ -121895,7 +122259,7 @@ class SessionRegistry {
|
|
|
121895
122259
|
try {
|
|
121896
122260
|
this.store?.delete(sessionId);
|
|
121897
122261
|
} catch (error51) {
|
|
121898
|
-
logger.warn("
|
|
122262
|
+
logger.warn("SessionRegistry: store delete failed", { sessionId, error: error51 });
|
|
121899
122263
|
}
|
|
121900
122264
|
return removed;
|
|
121901
122265
|
}
|
|
@@ -121923,7 +122287,7 @@ function getSessionRegistry() {
|
|
|
121923
122287
|
const { getSessionStore: getSessionStore2 } = (init_session_store(), __toCommonJS(exports_session_store));
|
|
121924
122288
|
store2 = getSessionStore2();
|
|
121925
122289
|
} catch (error51) {
|
|
121926
|
-
logger.warn("
|
|
122290
|
+
logger.warn("SessionRegistry: store init failed, falling back to MemorySessionStore", { error: error51 });
|
|
121927
122291
|
const { MemorySessionStore: MemorySessionStore2 } = (init_session_store(), __toCommonJS(exports_session_store));
|
|
121928
122292
|
store2 = new MemorySessionStore2;
|
|
121929
122293
|
}
|
|
@@ -122740,19 +123104,22 @@ class LLMJudgeReranker {
|
|
|
122740
123104
|
const tail = results.slice(k);
|
|
122741
123105
|
const prompt = buildPrompt(query, head);
|
|
122742
123106
|
let verdict;
|
|
123107
|
+
let verdictError;
|
|
122743
123108
|
try {
|
|
122744
|
-
const res = await this.llm.object(prompt, RerankVerdictSchema, { modelRole: "code" });
|
|
123109
|
+
const res = await this.llm.object(prompt, RerankVerdictSchema, { label: "reranker", modelRole: "code" });
|
|
122745
123110
|
verdict = res.ok ? res.value ?? null : null;
|
|
123111
|
+
verdictError = res.ok ? undefined : res.error;
|
|
122746
123112
|
} catch (e) {
|
|
122747
123113
|
logger.warn("LLMJudgeReranker threw \u2014 degrading to input order", {
|
|
122748
123114
|
query,
|
|
122749
|
-
error: e
|
|
123115
|
+
error: e
|
|
122750
123116
|
});
|
|
122751
123117
|
return results;
|
|
122752
123118
|
}
|
|
122753
123119
|
if (!verdict) {
|
|
122754
123120
|
logger.warn("LLMJudgeReranker got {ok:false} \u2014 degrading to input order", {
|
|
122755
|
-
query
|
|
123121
|
+
query,
|
|
123122
|
+
error: verdictError
|
|
122756
123123
|
});
|
|
122757
123124
|
return results;
|
|
122758
123125
|
}
|
|
@@ -123551,10 +123918,10 @@ var init_chunker_code = __esm(() => {
|
|
|
123551
123918
|
});
|
|
123552
123919
|
|
|
123553
123920
|
// ../../packages/core/dist/services/search/smart-chunker.js
|
|
123554
|
-
import
|
|
123921
|
+
import path19 from "path";
|
|
123555
123922
|
function smartChunk(content, filePath, config3 = {}) {
|
|
123556
123923
|
const cfg = { ...DEFAULT_CONFIG, ...config3 };
|
|
123557
|
-
const ext2 =
|
|
123924
|
+
const ext2 = path19.extname(filePath).toLowerCase();
|
|
123558
123925
|
const relativePath = filePath;
|
|
123559
123926
|
const fileImports = isCodeFile(ext2) ? extractFileImports(content, ext2) : undefined;
|
|
123560
123927
|
let chunks;
|
|
@@ -123892,8 +124259,8 @@ var init_embedding_freshness = __esm(() => {
|
|
|
123892
124259
|
});
|
|
123893
124260
|
|
|
123894
124261
|
// ../../packages/core/dist/services/search/project-indexer.js
|
|
123895
|
-
import
|
|
123896
|
-
import
|
|
124262
|
+
import fs14 from "fs/promises";
|
|
124263
|
+
import path20 from "path";
|
|
123897
124264
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
123898
124265
|
async function runWithIndexLock(lockMap, projectId, work) {
|
|
123899
124266
|
const prevLock = lockMap.get(projectId);
|
|
@@ -123936,7 +124303,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
123936
124303
|
dot: false
|
|
123937
124304
|
});
|
|
123938
124305
|
const filteredFiles = files.filter((file2) => {
|
|
123939
|
-
const relativePath =
|
|
124306
|
+
const relativePath = path20.relative(projectPath, file2);
|
|
123940
124307
|
const shouldIgnore = ig.ignores(relativePath);
|
|
123941
124308
|
if (shouldIgnore) {
|
|
123942
124309
|
logger.debug("Ignoring file per .gitignore during indexing", {
|
|
@@ -123976,7 +124343,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
123976
124343
|
});
|
|
123977
124344
|
}
|
|
123978
124345
|
}
|
|
123979
|
-
const indexedFilesList = filteredFiles.map((f) =>
|
|
124346
|
+
const indexedFilesList = filteredFiles.map((f) => path20.relative(projectPath, f));
|
|
123980
124347
|
await deps.indexManager.updateIndexMetadata(projectId, projectPath, indexedFilesList);
|
|
123981
124348
|
logger.info("Project indexing completed", {
|
|
123982
124349
|
projectId,
|
|
@@ -124106,7 +124473,7 @@ async function ensureFreshIndex(deps, projectId, projectPath, options = {}) {
|
|
|
124106
124473
|
let errors4 = 0;
|
|
124107
124474
|
for (const relativeFilePath of filesToReindex) {
|
|
124108
124475
|
try {
|
|
124109
|
-
const fullPath =
|
|
124476
|
+
const fullPath = path20.join(projectPath, relativeFilePath);
|
|
124110
124477
|
const result = await deps.indexFile(fullPath, projectId, projectPath, centralityMap);
|
|
124111
124478
|
filesIndexed++;
|
|
124112
124479
|
chunksIndexed += result.chunks;
|
|
@@ -124166,8 +124533,8 @@ async function checkSearchAdmission(deps, projectId, projectPath) {
|
|
|
124166
124533
|
}
|
|
124167
124534
|
async function indexFile(deps, filePath, projectId, projectRoot, centralityMap) {
|
|
124168
124535
|
projectId = await getProjectIdentityAliasResolver().resolve(projectId);
|
|
124169
|
-
const content = await
|
|
124170
|
-
const relativePath =
|
|
124536
|
+
const content = await fs14.readFile(filePath, "utf-8");
|
|
124537
|
+
const relativePath = path20.relative(projectRoot, filePath);
|
|
124171
124538
|
const maxFileSize = config2.get("security").maxFileSize || 1024 * 1024;
|
|
124172
124539
|
if (content.length > maxFileSize) {
|
|
124173
124540
|
logger.warn("File too large, skipping", {
|
|
@@ -124187,7 +124554,7 @@ async function indexFile(deps, filePath, projectId, projectRoot, centralityMap)
|
|
|
124187
124554
|
chunkIndex: i,
|
|
124188
124555
|
totalChunks: chunks.length,
|
|
124189
124556
|
type: chunk.type,
|
|
124190
|
-
language:
|
|
124557
|
+
language: path20.extname(filePath).slice(1),
|
|
124191
124558
|
lineStart: chunk.lineStart,
|
|
124192
124559
|
lineEnd: chunk.lineEnd,
|
|
124193
124560
|
label: chunk.label,
|
|
@@ -124598,7 +124965,7 @@ class TaskEnvelopeService {
|
|
|
124598
124965
|
errors4.push("prime");
|
|
124599
124966
|
logger.warn("synapse_task_begin: prime sub-step failed", {
|
|
124600
124967
|
sessionId,
|
|
124601
|
-
error: err
|
|
124968
|
+
error: err
|
|
124602
124969
|
});
|
|
124603
124970
|
}
|
|
124604
124971
|
}
|
|
@@ -124621,7 +124988,7 @@ class TaskEnvelopeService {
|
|
|
124621
124988
|
errors4.push("search");
|
|
124622
124989
|
logger.warn("synapse_task_begin: search sub-step failed", {
|
|
124623
124990
|
sessionId,
|
|
124624
|
-
error: err
|
|
124991
|
+
error: err
|
|
124625
124992
|
});
|
|
124626
124993
|
}
|
|
124627
124994
|
if (firstHitFile) {
|
|
@@ -124644,7 +125011,7 @@ class TaskEnvelopeService {
|
|
|
124644
125011
|
errors4.push("prefetch");
|
|
124645
125012
|
logger.warn("synapse_task_begin: prefetch sub-step failed", {
|
|
124646
125013
|
sessionId,
|
|
124647
|
-
error: err
|
|
125014
|
+
error: err
|
|
124648
125015
|
});
|
|
124649
125016
|
}
|
|
124650
125017
|
}
|
|
@@ -124655,7 +125022,7 @@ class TaskEnvelopeService {
|
|
|
124655
125022
|
errors4.push("access");
|
|
124656
125023
|
logger.warn("synapse_task_begin: access sub-step failed", {
|
|
124657
125024
|
sessionId,
|
|
124658
|
-
error: err
|
|
125025
|
+
error: err
|
|
124659
125026
|
});
|
|
124660
125027
|
}
|
|
124661
125028
|
}
|
|
@@ -124998,7 +125365,7 @@ async function applySynapseState(deps, baseResults, query, projectId, sessionId,
|
|
|
124998
125365
|
logger.warn("Synapse session lookup failed \u2014 using stateless search", {
|
|
124999
125366
|
sessionId,
|
|
125000
125367
|
projectId,
|
|
125001
|
-
error: error51
|
|
125368
|
+
error: error51
|
|
125002
125369
|
});
|
|
125003
125370
|
return baseResults;
|
|
125004
125371
|
}
|
|
@@ -125019,7 +125386,7 @@ async function applySynapseState(deps, baseResults, query, projectId, sessionId,
|
|
|
125019
125386
|
logger.warn("Synapse processing failed \u2014 using stateless search", {
|
|
125020
125387
|
sessionId,
|
|
125021
125388
|
projectId,
|
|
125022
|
-
error: error51
|
|
125389
|
+
error: error51
|
|
125023
125390
|
});
|
|
125024
125391
|
return baseResults;
|
|
125025
125392
|
}
|
|
@@ -125779,7 +126146,7 @@ class PgJobStore {
|
|
|
125779
126146
|
} catch (e) {
|
|
125780
126147
|
this.recovered = true;
|
|
125781
126148
|
logger.warn("PgJobStore markStaleRunningFailed failed (best-effort)", {
|
|
125782
|
-
error: e
|
|
126149
|
+
error: e
|
|
125783
126150
|
});
|
|
125784
126151
|
}
|
|
125785
126152
|
}
|
|
@@ -125805,7 +126172,7 @@ class PgJobStore {
|
|
|
125805
126172
|
logger.info("PgJobStore hydrated", { rows: this.mirror.size });
|
|
125806
126173
|
} catch (e) {
|
|
125807
126174
|
logger.warn("PgJobStore hydrate failed (best-effort)", {
|
|
125808
|
-
error: e
|
|
126175
|
+
error: e
|
|
125809
126176
|
});
|
|
125810
126177
|
} finally {
|
|
125811
126178
|
this.hydrating = null;
|
|
@@ -125828,7 +126195,7 @@ class PgJobStore {
|
|
|
125828
126195
|
next.catch((e) => {
|
|
125829
126196
|
logger.warn("PgJobStore.save failed (best-effort)", {
|
|
125830
126197
|
jobId: job.jobId,
|
|
125831
|
-
error: e
|
|
126198
|
+
error: e
|
|
125832
126199
|
});
|
|
125833
126200
|
});
|
|
125834
126201
|
}
|
|
@@ -125960,7 +126327,7 @@ class PgJobStore {
|
|
|
125960
126327
|
}
|
|
125961
126328
|
} catch (e) {
|
|
125962
126329
|
logger.warn("PgJobStore markStaleRunningFailed failed (best-effort)", {
|
|
125963
|
-
error: e
|
|
126330
|
+
error: e
|
|
125964
126331
|
});
|
|
125965
126332
|
}
|
|
125966
126333
|
})();
|
|
@@ -126150,7 +126517,13 @@ class IndexJobTracker {
|
|
|
126150
126517
|
const stale = hbMs != null && hbMs < cutoff || hbMs == null && startedMs != null && startedMs < cutoff;
|
|
126151
126518
|
if (!stale)
|
|
126152
126519
|
continue;
|
|
126153
|
-
logger.warn(
|
|
126520
|
+
logger.warn("indexJobTracker: reaping stale running job", {
|
|
126521
|
+
jobId: job.jobId,
|
|
126522
|
+
projectId: job.projectId,
|
|
126523
|
+
staleMs,
|
|
126524
|
+
heartbeatAt: job.heartbeatAt?.toISOString() ?? "n/a",
|
|
126525
|
+
startedAt: job.startedAt?.toISOString() ?? "n/a"
|
|
126526
|
+
});
|
|
126154
126527
|
this.jobs.set(job.jobId, job);
|
|
126155
126528
|
const reapedPrevStatus = job.status;
|
|
126156
126529
|
this.setResult(job.jobId, undefined, "heartbeat stale (possible crash/OOM)");
|
|
@@ -126175,7 +126548,7 @@ class IndexJobTracker {
|
|
|
126175
126548
|
try {
|
|
126176
126549
|
this.store?.save(job);
|
|
126177
126550
|
} catch (err) {
|
|
126178
|
-
logger.warn(
|
|
126551
|
+
logger.warn("indexJobTracker: job store write failed on setResult", { jobId, error: err });
|
|
126179
126552
|
}
|
|
126180
126553
|
if (prevStatus === "pending") {
|
|
126181
126554
|
this.publishStateChange(job, prevStatus);
|
|
@@ -126205,7 +126578,7 @@ class IndexJobTracker {
|
|
|
126205
126578
|
const survivors = remaining.slice(0, this.MAX_JOBS);
|
|
126206
126579
|
const overflow = remaining.slice(this.MAX_JOBS);
|
|
126207
126580
|
for (const job of overflow) {
|
|
126208
|
-
logger.warn(
|
|
126581
|
+
logger.warn("indexJobTracker: evicting non-terminal job to honor MAX_JOBS cap \u2014 caller may lose visibility", { jobId: job.jobId, projectId: job.projectId, status: job.status });
|
|
126209
126582
|
this.jobs.delete(job.jobId);
|
|
126210
126583
|
}
|
|
126211
126584
|
}
|
|
@@ -126252,8 +126625,8 @@ function stripNul(content) {
|
|
|
126252
126625
|
}
|
|
126253
126626
|
|
|
126254
126627
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
126255
|
-
import
|
|
126256
|
-
import
|
|
126628
|
+
import fs15 from "fs/promises";
|
|
126629
|
+
import path21 from "path";
|
|
126257
126630
|
import { createHash as createHash5 } from "crypto";
|
|
126258
126631
|
|
|
126259
126632
|
class DiscoverStage {
|
|
@@ -126279,7 +126652,7 @@ class DiscoverStage {
|
|
|
126279
126652
|
dot: false,
|
|
126280
126653
|
absolute: false
|
|
126281
126654
|
});
|
|
126282
|
-
relPaths = found.map((p) =>
|
|
126655
|
+
relPaths = found.map((p) => path21.isAbsolute(p) ? path21.relative(ctx.projectPath, p) : p).filter((p) => !ig.ignores(p) && applyPolicy(p, policy) !== "Drop");
|
|
126283
126656
|
}
|
|
126284
126657
|
if (ctx.resumeCursor?.path) {
|
|
126285
126658
|
const cursorPath = ctx.resumeCursor.path;
|
|
@@ -126338,10 +126711,10 @@ class DiscoverStage {
|
|
|
126338
126711
|
return discovered;
|
|
126339
126712
|
}
|
|
126340
126713
|
async processFile(ctx, relativePath, forceReindex) {
|
|
126341
|
-
const absolutePath =
|
|
126714
|
+
const absolutePath = path21.join(ctx.projectPath, relativePath);
|
|
126342
126715
|
try {
|
|
126343
|
-
const stat = await
|
|
126344
|
-
const content = stripNul(await
|
|
126716
|
+
const stat = await fs15.stat(absolutePath);
|
|
126717
|
+
const content = stripNul(await fs15.readFile(absolutePath, "utf-8"));
|
|
126345
126718
|
const contentHash = createHash5("sha256").update(content).digest("hex");
|
|
126346
126719
|
let needsReparse = forceReindex;
|
|
126347
126720
|
if (!forceReindex) {
|
|
@@ -126359,8 +126732,9 @@ class DiscoverStage {
|
|
|
126359
126732
|
};
|
|
126360
126733
|
} catch (err) {
|
|
126361
126734
|
logger.warn("DiscoverStage: failed to stat/read file", {
|
|
126735
|
+
projectId: ctx.projectId,
|
|
126362
126736
|
relativePath,
|
|
126363
|
-
error: err
|
|
126737
|
+
error: err
|
|
126364
126738
|
});
|
|
126365
126739
|
throw new Error(`required_file_unreadable:${relativePath}:${err.message}`);
|
|
126366
126740
|
}
|
|
@@ -126384,8 +126758,8 @@ class DiscoverStage {
|
|
|
126384
126758
|
ig.add(pattern);
|
|
126385
126759
|
}
|
|
126386
126760
|
try {
|
|
126387
|
-
const gitignorePath =
|
|
126388
|
-
const gitignoreContent = await
|
|
126761
|
+
const gitignorePath = path21.join(projectPath, ".gitignore");
|
|
126762
|
+
const gitignoreContent = await fs15.readFile(gitignorePath, "utf8");
|
|
126389
126763
|
const rules = gitignoreContent.split(`
|
|
126390
126764
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
126391
126765
|
ig.add(rules);
|
|
@@ -127740,8 +128114,8 @@ function rustUseLeaves(node, source, prefix = []) {
|
|
|
127740
128114
|
}
|
|
127741
128115
|
if (node.type === "use_wildcard")
|
|
127742
128116
|
return [{ path: [...prefix, "*"], glob: true }];
|
|
127743
|
-
const
|
|
127744
|
-
return
|
|
128117
|
+
const path22 = rustPathSegments(node, source);
|
|
128118
|
+
return path22.length ? [{ path: [...prefix, ...path22] }] : [];
|
|
127745
128119
|
}
|
|
127746
128120
|
function functionalCaptures(captures, source, family) {
|
|
127747
128121
|
if (family !== "clojure")
|
|
@@ -128713,8 +129087,8 @@ var init_structural_runtime = __esm(() => {
|
|
|
128713
129087
|
});
|
|
128714
129088
|
|
|
128715
129089
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
128716
|
-
import
|
|
128717
|
-
import
|
|
129090
|
+
import path22 from "path";
|
|
129091
|
+
import fs16 from "fs/promises";
|
|
128718
129092
|
function resolveChunkerMaxChars() {
|
|
128719
129093
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
128720
129094
|
if (Number.isFinite(global2) && global2 > 0)
|
|
@@ -128742,8 +129116,8 @@ class ParseStage {
|
|
|
128742
129116
|
const results = new Map;
|
|
128743
129117
|
let processed = 0;
|
|
128744
129118
|
const phases = [
|
|
128745
|
-
files.filter((file2) =>
|
|
128746
|
-
files.filter((file2) =>
|
|
129119
|
+
files.filter((file2) => path22.extname(file2.relativePath).toLowerCase() !== ".h"),
|
|
129120
|
+
files.filter((file2) => path22.extname(file2.relativePath).toLowerCase() === ".h")
|
|
128747
129121
|
];
|
|
128748
129122
|
const batches = phases.flatMap((phase) => Array.from({ length: Math.ceil(phase.length / BATCH_SIZE) }, (_, index) => phase.slice(index * BATCH_SIZE, (index + 1) * BATCH_SIZE)));
|
|
128749
129123
|
for (const batch of batches) {
|
|
@@ -128781,19 +129155,19 @@ class ParseStage {
|
|
|
128781
129155
|
return files.map((file2) => results.get(file2.relativePath));
|
|
128782
129156
|
}
|
|
128783
129157
|
recordHeaderImporterEvidence(ctx, files, parsedFiles) {
|
|
128784
|
-
const knownHeaders = new Set(files.filter((file2) =>
|
|
129158
|
+
const knownHeaders = new Set(files.filter((file2) => path22.extname(file2.relativePath).toLowerCase() === ".h").map((file2) => path22.posix.normalize(file2.relativePath)));
|
|
128785
129159
|
const mutable = {
|
|
128786
129160
|
...ctx.structuralHeaderEvidenceByFile
|
|
128787
129161
|
};
|
|
128788
129162
|
for (const parsed of parsedFiles) {
|
|
128789
|
-
const extension =
|
|
129163
|
+
const extension = path22.extname(parsed.file.relativePath).toLowerCase();
|
|
128790
129164
|
const key = extension === ".c" ? "cImporters" : [".cpp", ".hpp"].includes(extension) ? "cppImporters" : undefined;
|
|
128791
129165
|
if (!key)
|
|
128792
129166
|
continue;
|
|
128793
129167
|
for (const imported of parsed.rawImports) {
|
|
128794
129168
|
if (!["c_include", "cpp_include"].includes(imported.form) || imported.specifier.startsWith("<"))
|
|
128795
129169
|
continue;
|
|
128796
|
-
const header =
|
|
129170
|
+
const header = path22.posix.normalize(path22.posix.join(path22.posix.dirname(parsed.file.relativePath), imported.specifier));
|
|
128797
129171
|
if (!knownHeaders.has(header))
|
|
128798
129172
|
continue;
|
|
128799
129173
|
const existing = mutable[header] ?? {};
|
|
@@ -128804,9 +129178,9 @@ class ParseStage {
|
|
|
128804
129178
|
}
|
|
128805
129179
|
async parseFile(ctx, file2) {
|
|
128806
129180
|
if (!file2.needsReparse) {
|
|
128807
|
-
const extension =
|
|
129181
|
+
const extension = path22.extname(file2.relativePath).toLowerCase();
|
|
128808
129182
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
128809
|
-
const content = file2.snapshotContent ?? await
|
|
129183
|
+
const content = file2.snapshotContent ?? await fs16.readFile(file2.absolutePath, "utf8");
|
|
128810
129184
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
128811
129185
|
if (outcome.status === "failed")
|
|
128812
129186
|
throw new StructuralEtlParseError(file2.relativePath, outcome.failureKind, `Structural evidence parse failed (${outcome.failureKind})`, outcome.diagnosticCount, outcome.diagnostics.slice(0, 10));
|
|
@@ -128818,8 +129192,8 @@ class ParseStage {
|
|
|
128818
129192
|
return { file: file2, chunks: [], symbols: [], rawImports: [], rawEdges: [] };
|
|
128819
129193
|
}
|
|
128820
129194
|
try {
|
|
128821
|
-
const content = file2.snapshotContent ?? await
|
|
128822
|
-
const ext2 =
|
|
129195
|
+
const content = file2.snapshotContent ?? await fs16.readFile(file2.absolutePath, "utf-8");
|
|
129196
|
+
const ext2 = path22.extname(file2.relativePath).toLowerCase();
|
|
128823
129197
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
128824
129198
|
const chunks = smartChunk(content, file2.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
128825
129199
|
let symbols;
|
|
@@ -128885,8 +129259,9 @@ class ParseStage {
|
|
|
128885
129259
|
timestamp: Date.now()
|
|
128886
129260
|
});
|
|
128887
129261
|
logger.warn("ParseStage: failed to parse file", {
|
|
129262
|
+
projectId: ctx.projectId,
|
|
128888
129263
|
filePath: file2.relativePath,
|
|
128889
|
-
error: err
|
|
129264
|
+
error: err
|
|
128890
129265
|
});
|
|
128891
129266
|
if (err instanceof StructuralEtlParseError)
|
|
128892
129267
|
throw err;
|
|
@@ -129373,7 +129748,7 @@ var init_resolver = __esm(() => {
|
|
|
129373
129748
|
});
|
|
129374
129749
|
|
|
129375
129750
|
// ../../packages/core/dist/services/structural/resolvers/typescript.js
|
|
129376
|
-
import
|
|
129751
|
+
import path23 from "path";
|
|
129377
129752
|
function candidates(identities) {
|
|
129378
129753
|
return Object.freeze(identities.map((identity) => Object.freeze({
|
|
129379
129754
|
fqn: identity.fqn,
|
|
@@ -129468,7 +129843,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
129468
129843
|
const bases = /\.[cm]?jsx?$/u.test(base) ? [base.replace(/\.[cm]?jsx?$/u, ".ts"), base.replace(/\.[cm]?jsx?$/u, ".tsx"), base] : [base];
|
|
129469
129844
|
for (const candidateBase of bases)
|
|
129470
129845
|
for (const suffix of DIALECT_PROBES[dialect] ?? [""]) {
|
|
129471
|
-
const value =
|
|
129846
|
+
const value = path23.posix.normalize(`${candidateBase}${suffix}`);
|
|
129472
129847
|
if (!value.startsWith("../") && value !== ".." && known.has(value))
|
|
129473
129848
|
return value;
|
|
129474
129849
|
}
|
|
@@ -129477,7 +129852,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
129477
129852
|
function resolveStructuralSpecifier(specifier, fromFile, build, dialect = "typescript") {
|
|
129478
129853
|
const known = new Set(build.knownFiles.map(normalizeStructuralFile));
|
|
129479
129854
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
129480
|
-
return probe(
|
|
129855
|
+
return probe(path23.posix.join(path23.posix.dirname(fromFile), specifier), known, dialect);
|
|
129481
129856
|
}
|
|
129482
129857
|
const aliases = build.pathAliasesByFile?.[normalizeStructuralFile(fromFile)] ?? build.pathAliases ?? [];
|
|
129483
129858
|
for (const alias of aliases) {
|
|
@@ -129741,7 +130116,7 @@ var init_scripting2 = __esm(() => {
|
|
|
129741
130116
|
});
|
|
129742
130117
|
|
|
129743
130118
|
// ../../packages/core/dist/services/structural/resolvers/systems.js
|
|
129744
|
-
import
|
|
130119
|
+
import path24 from "path";
|
|
129745
130120
|
var DIALECTS, SYSTEMS_LANGUAGE_RESOLVER;
|
|
129746
130121
|
var init_systems2 = __esm(() => {
|
|
129747
130122
|
init_typescript2();
|
|
@@ -129760,7 +130135,7 @@ var init_systems2 = __esm(() => {
|
|
|
129760
130135
|
const bindings = item.bindings.map((binding) => binding.imported === "*" && binding.local === "*" && unresolvedTarget && !unresolvedTarget.qualifier ? { ...binding, imported: unresolvedTarget.name, local: unresolvedTarget.name } : binding);
|
|
129761
130136
|
if (item.specifier === "crate" || item.specifier.startsWith("crate/")) {
|
|
129762
130137
|
const crateRoot = file2.file.startsWith("src/") ? "src" : "";
|
|
129763
|
-
return { ...item, bindings, specifier: `./${
|
|
130138
|
+
return { ...item, bindings, specifier: `./${path24.posix.relative(path24.posix.dirname(file2.file), path24.posix.join(crateRoot, item.specifier.replace(/^crate\/?/u, "")))}` };
|
|
129764
130139
|
}
|
|
129765
130140
|
if (item.specifier === "self" || item.specifier.startsWith("self/"))
|
|
129766
130141
|
return { ...item, bindings, specifier: `./${item.specifier.replace(/^self\/?/u, "")}` };
|
|
@@ -129858,8 +130233,8 @@ var init_data_document2 = __esm(() => {
|
|
|
129858
130233
|
});
|
|
129859
130234
|
|
|
129860
130235
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
129861
|
-
import
|
|
129862
|
-
import
|
|
130236
|
+
import path25 from "path";
|
|
130237
|
+
import fs17 from "fs";
|
|
129863
130238
|
|
|
129864
130239
|
class ResolveStage {
|
|
129865
130240
|
symbolRepository;
|
|
@@ -129883,7 +130258,7 @@ class ResolveStage {
|
|
|
129883
130258
|
const structuralDocuments = files.flatMap((file2) => {
|
|
129884
130259
|
if (!file2.structure)
|
|
129885
130260
|
return [];
|
|
129886
|
-
const language = resolveStructuralLanguage(
|
|
130261
|
+
const language = resolveStructuralLanguage(path25.extname(file2.file.relativePath));
|
|
129887
130262
|
if (language.status !== "supported")
|
|
129888
130263
|
throw new Error(`structural_manifest_missing:${file2.file.relativePath}`);
|
|
129889
130264
|
return [{
|
|
@@ -129895,13 +130270,13 @@ class ResolveStage {
|
|
|
129895
130270
|
}];
|
|
129896
130271
|
});
|
|
129897
130272
|
const currentStructuralFiles = new Set(structuralDocuments.map((document2) => document2.file));
|
|
129898
|
-
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
130273
|
+
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));
|
|
129899
130274
|
const pathAliasesByFile = Object.fromEntries([...knownRelPaths].map((file2) => [
|
|
129900
130275
|
file2,
|
|
129901
130276
|
this.structuralAliasesFor(file2, rootAliases, monorepoPackages)
|
|
129902
130277
|
]));
|
|
129903
130278
|
const buildMetadata = { knownFiles: [...knownRelPaths], pathAliasesByFile };
|
|
129904
|
-
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(
|
|
130279
|
+
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));
|
|
129905
130280
|
const seedIds = new Set;
|
|
129906
130281
|
for (const definition of seedRows) {
|
|
129907
130282
|
if (seedIds.has(definition.id))
|
|
@@ -129994,7 +130369,7 @@ class ResolveStage {
|
|
|
129994
130369
|
if (parsed.file !== definition.file_path) {
|
|
129995
130370
|
throw new Error(`structural_repository_seed_file_mismatch:${definition.id}`);
|
|
129996
130371
|
}
|
|
129997
|
-
const language = resolveStructuralLanguage(
|
|
130372
|
+
const language = resolveStructuralLanguage(path25.extname(definition.file_path));
|
|
129998
130373
|
if (language.status !== "supported")
|
|
129999
130374
|
throw new Error(`structural_repository_seed_language:${definition.id}`);
|
|
130000
130375
|
let identity;
|
|
@@ -130046,7 +130421,7 @@ class ResolveStage {
|
|
|
130046
130421
|
});
|
|
130047
130422
|
}
|
|
130048
130423
|
resolveFile(parsed, projectPath, knownRelPaths, rootAliases, monorepoPackages, symbolIndex, knownFqns) {
|
|
130049
|
-
const fromDir =
|
|
130424
|
+
const fromDir = path25.dirname(path25.join(projectPath, parsed.file.relativePath));
|
|
130050
130425
|
const packageAliases = this.getPackageAliases(parsed.file.relativePath, monorepoPackages);
|
|
130051
130426
|
const allAliases = [...packageAliases, ...rootAliases];
|
|
130052
130427
|
const resolvedImports = parsed.rawImports.map((raw2) => {
|
|
@@ -130117,12 +130492,12 @@ class ResolveStage {
|
|
|
130117
130492
|
index.set(def.name, `${def.file_path}#${def.name}`);
|
|
130118
130493
|
}
|
|
130119
130494
|
} catch (err) {
|
|
130120
|
-
const skippedStructural = files.some((file2) => !file2.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
130495
|
+
const skippedStructural = files.some((file2) => !file2.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path25.extname(file2.file.relativePath).toLowerCase()));
|
|
130121
130496
|
if (skippedStructural)
|
|
130122
130497
|
throw new Error("structural_repository_seed_failed", { cause: err });
|
|
130123
130498
|
logger.warn("buildSymbolIndex: repo seed failed, in-batch only", {
|
|
130124
130499
|
projectId,
|
|
130125
|
-
error: err
|
|
130500
|
+
error: err
|
|
130126
130501
|
});
|
|
130127
130502
|
}
|
|
130128
130503
|
const inBatch = new Map;
|
|
@@ -130141,7 +130516,7 @@ class ResolveStage {
|
|
|
130141
130516
|
}
|
|
130142
130517
|
resolveSpecifier(specifier, fromDir, projectPath, knownRelPaths, aliases) {
|
|
130143
130518
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
130144
|
-
const resolved = this.probeExtensions(
|
|
130519
|
+
const resolved = this.probeExtensions(path25.resolve(fromDir, specifier), projectPath, knownRelPaths);
|
|
130145
130520
|
return { resolvedPath: resolved, external: false };
|
|
130146
130521
|
}
|
|
130147
130522
|
for (const alias of aliases) {
|
|
@@ -130149,8 +130524,8 @@ class ResolveStage {
|
|
|
130149
130524
|
const suffix = specifier.slice(alias.prefix.length);
|
|
130150
130525
|
for (const target of alias.targets) {
|
|
130151
130526
|
const cleanTarget = target.replace(/\/\*$/, "");
|
|
130152
|
-
const basePath = alias.packagePath ?
|
|
130153
|
-
const absPath =
|
|
130527
|
+
const basePath = alias.packagePath ? path25.join(projectPath, alias.packagePath) : projectPath;
|
|
130528
|
+
const absPath = path25.join(basePath, cleanTarget + suffix);
|
|
130154
130529
|
const resolved = this.probeExtensions(absPath, projectPath, knownRelPaths);
|
|
130155
130530
|
if (resolved)
|
|
130156
130531
|
return { resolvedPath: resolved, external: false };
|
|
@@ -130166,7 +130541,7 @@ class ResolveStage {
|
|
|
130166
130541
|
...TS_EXTENSIONS.map((ext2) => absPath.replace(/\.[^.]+$/, ext2))
|
|
130167
130542
|
];
|
|
130168
130543
|
for (const candidate2 of candidates2) {
|
|
130169
|
-
const rel =
|
|
130544
|
+
const rel = path25.relative(projectPath, candidate2).replace(/\\/g, "/");
|
|
130170
130545
|
if (knownRelPaths.has(rel))
|
|
130171
130546
|
return rel;
|
|
130172
130547
|
}
|
|
@@ -130174,9 +130549,9 @@ class ResolveStage {
|
|
|
130174
130549
|
}
|
|
130175
130550
|
loadTsConfigPaths(projectPath, packageBase) {
|
|
130176
130551
|
const aliases = [];
|
|
130177
|
-
const tsconfigPath =
|
|
130552
|
+
const tsconfigPath = path25.join(projectPath, "tsconfig.json");
|
|
130178
130553
|
try {
|
|
130179
|
-
const raw2 =
|
|
130554
|
+
const raw2 = fs17.readFileSync(tsconfigPath, "utf-8");
|
|
130180
130555
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
130181
130556
|
const tsconfig = JSON.parse(stripped);
|
|
130182
130557
|
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
@@ -130205,7 +130580,7 @@ class ResolveStage {
|
|
|
130205
130580
|
}
|
|
130206
130581
|
}
|
|
130207
130582
|
for (const packageRelPath of packagePaths) {
|
|
130208
|
-
const absPackagePath =
|
|
130583
|
+
const absPackagePath = path25.join(projectPath, packageRelPath);
|
|
130209
130584
|
const aliases = this.loadTsConfigPaths(absPackagePath, packageRelPath);
|
|
130210
130585
|
if (aliases.length > 0) {
|
|
130211
130586
|
packages.push({
|
|
@@ -130235,7 +130610,7 @@ class ResolveStage {
|
|
|
130235
130610
|
structuralAliasesFor(filePath, rootAliases, packages) {
|
|
130236
130611
|
return [...this.getPackageAliases(filePath, packages), ...rootAliases].map((alias) => ({
|
|
130237
130612
|
pattern: alias.prefix + (alias.targets.some((target) => target.includes("*")) ? "/*" : ""),
|
|
130238
|
-
targets: alias.targets.map((target) => alias.packagePath ?
|
|
130613
|
+
targets: alias.targets.map((target) => alias.packagePath ? path25.posix.join(alias.packagePath, target) : target)
|
|
130239
130614
|
}));
|
|
130240
130615
|
}
|
|
130241
130616
|
}
|
|
@@ -130285,7 +130660,7 @@ async function withDeadlockRetry(operation, options = {}) {
|
|
|
130285
130660
|
attempt,
|
|
130286
130661
|
maxAttempts,
|
|
130287
130662
|
delayMs,
|
|
130288
|
-
error: error51
|
|
130663
|
+
error: error51
|
|
130289
130664
|
});
|
|
130290
130665
|
await new Promise((resolve5) => setTimeout(resolve5, delayMs));
|
|
130291
130666
|
}
|
|
@@ -130299,7 +130674,7 @@ var init_with_deadlock_retry = __esm(() => {
|
|
|
130299
130674
|
});
|
|
130300
130675
|
|
|
130301
130676
|
// ../../packages/core/dist/services/etl/stages/load.js
|
|
130302
|
-
import
|
|
130677
|
+
import path26 from "path";
|
|
130303
130678
|
function formatDuration(ms) {
|
|
130304
130679
|
const totalSec = Math.max(0, Math.round(ms / 1000));
|
|
130305
130680
|
if (totalSec < 60)
|
|
@@ -130576,7 +130951,7 @@ class LoadStage {
|
|
|
130576
130951
|
const filePath = file2.file.relativePath;
|
|
130577
130952
|
const batch = buildSymbolPersistenceBatch(ctx.projectId, file2);
|
|
130578
130953
|
if (ctx.graphGenerationLease) {
|
|
130579
|
-
const manifest = getLanguageManifestEntry(
|
|
130954
|
+
const manifest = getLanguageManifestEntry(path26.extname(filePath));
|
|
130580
130955
|
const diagnostics2 = (file2.structuralDiagnostics ?? []).slice(0, 10).map((diagnostic2) => ({
|
|
130581
130956
|
code: diagnostic2.code,
|
|
130582
130957
|
severity: diagnostic2.severity,
|
|
@@ -131033,9 +131408,9 @@ var init_graph_generation_coordinator = __esm(() => {
|
|
|
131033
131408
|
// ../../packages/core/dist/services/etl/pipeline.js
|
|
131034
131409
|
import { createHash as createHash7 } from "crypto";
|
|
131035
131410
|
import { setTimeout as delay2 } from "timers/promises";
|
|
131036
|
-
import
|
|
131411
|
+
import path27 from "path";
|
|
131037
131412
|
function buildHeaderLanguageEvidence(files) {
|
|
131038
|
-
const headers = new Set(files.filter((file2) =>
|
|
131413
|
+
const headers = new Set(files.filter((file2) => path27.posix.extname(file2.relativePath).toLowerCase() === ".h").map((file2) => path27.posix.normalize(file2.relativePath)));
|
|
131039
131414
|
const mutable = new Map;
|
|
131040
131415
|
const entry2 = (header) => {
|
|
131041
131416
|
let value = mutable.get(header);
|
|
@@ -131046,7 +131421,7 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
131046
131421
|
return value;
|
|
131047
131422
|
};
|
|
131048
131423
|
for (const file2 of files) {
|
|
131049
|
-
if (
|
|
131424
|
+
if (path27.posix.basename(file2.relativePath) !== "compile_commands.json" || file2.snapshotContent === undefined)
|
|
131050
131425
|
continue;
|
|
131051
131426
|
let commands;
|
|
131052
131427
|
try {
|
|
@@ -131062,11 +131437,11 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
131062
131437
|
const record3 = command;
|
|
131063
131438
|
if (typeof record3.file !== "string")
|
|
131064
131439
|
continue;
|
|
131065
|
-
const projectRoot =
|
|
131066
|
-
const commandDirectory = typeof record3.directory === "string" ?
|
|
131067
|
-
const absoluteInput =
|
|
131068
|
-
const relative2 =
|
|
131069
|
-
const header =
|
|
131440
|
+
const projectRoot = path27.resolve(file2.absolutePath, ...file2.relativePath.split("/").map(() => ".."));
|
|
131441
|
+
const commandDirectory = typeof record3.directory === "string" ? path27.resolve(projectRoot, record3.directory) : projectRoot;
|
|
131442
|
+
const absoluteInput = path27.resolve(commandDirectory, record3.file);
|
|
131443
|
+
const relative2 = path27.relative(projectRoot, absoluteInput);
|
|
131444
|
+
const header = path27.posix.normalize(relative2.replaceAll(path27.sep, "/"));
|
|
131070
131445
|
if (!headers.has(header))
|
|
131071
131446
|
continue;
|
|
131072
131447
|
const invocation = typeof record3.command === "string" ? record3.command : Array.isArray(record3.arguments) ? record3.arguments.join(" ") : "";
|
|
@@ -131415,7 +131790,7 @@ var init_pipeline = __esm(() => {
|
|
|
131415
131790
|
logger.warn("EtlPipeline: search-admission marker write failed", {
|
|
131416
131791
|
projectId,
|
|
131417
131792
|
jobId,
|
|
131418
|
-
error: markerError
|
|
131793
|
+
error: markerError
|
|
131419
131794
|
});
|
|
131420
131795
|
}
|
|
131421
131796
|
if (forceReindex) {
|
|
@@ -131427,7 +131802,7 @@ var init_pipeline = __esm(() => {
|
|
|
131427
131802
|
logger.warn("EtlPipeline: embedding fingerprint stamp failed", {
|
|
131428
131803
|
projectId,
|
|
131429
131804
|
jobId,
|
|
131430
|
-
error: stampError
|
|
131805
|
+
error: stampError
|
|
131431
131806
|
});
|
|
131432
131807
|
}
|
|
131433
131808
|
}
|
|
@@ -131613,9 +131988,9 @@ var init_acquire_indexing_lease = __esm(() => {
|
|
|
131613
131988
|
|
|
131614
131989
|
// ../../packages/core/dist/services/project-identity/project-root-identity.js
|
|
131615
131990
|
import { realpath as realpath2 } from "fs/promises";
|
|
131616
|
-
import
|
|
131991
|
+
import path28 from "path";
|
|
131617
131992
|
async function canonicalizeProjectRoot(projectPath, canonicalize = realpath2) {
|
|
131618
|
-
return canonicalize(
|
|
131993
|
+
return canonicalize(path28.resolve(projectPath));
|
|
131619
131994
|
}
|
|
131620
131995
|
async function assertProjectRootReuse(options) {
|
|
131621
131996
|
if (!options.storedProjectPath || options.forceReindex)
|
|
@@ -131623,9 +131998,9 @@ async function assertProjectRootReuse(options) {
|
|
|
131623
131998
|
const canonicalize = options.canonicalize ?? realpath2;
|
|
131624
131999
|
let storedCanonical;
|
|
131625
132000
|
try {
|
|
131626
|
-
storedCanonical = await canonicalize(
|
|
132001
|
+
storedCanonical = await canonicalize(path28.resolve(options.storedProjectPath));
|
|
131627
132002
|
} catch {
|
|
131628
|
-
storedCanonical =
|
|
132003
|
+
storedCanonical = path28.resolve(options.storedProjectPath);
|
|
131629
132004
|
}
|
|
131630
132005
|
if (storedCanonical !== options.canonicalProjectPath) {
|
|
131631
132006
|
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");
|
|
@@ -132368,16 +132743,16 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
132368
132743
|
const seen = new Set;
|
|
132369
132744
|
const out = [];
|
|
132370
132745
|
for (const e of httpEdges) {
|
|
132371
|
-
const
|
|
132372
|
-
if (!
|
|
132746
|
+
const path29 = e.route;
|
|
132747
|
+
if (!path29)
|
|
132373
132748
|
continue;
|
|
132374
132749
|
const method = (e.method ?? "ANY").toUpperCase();
|
|
132375
|
-
const key = method + " " +
|
|
132750
|
+
const key = method + " " + path29;
|
|
132376
132751
|
if (seen.has(key))
|
|
132377
132752
|
continue;
|
|
132378
132753
|
seen.add(key);
|
|
132379
132754
|
out.push({
|
|
132380
|
-
path:
|
|
132755
|
+
path: path29,
|
|
132381
132756
|
method: e.method,
|
|
132382
132757
|
file: e.fromFile,
|
|
132383
132758
|
handler: e.targetFqn ?? e.symbolName
|
|
@@ -132388,12 +132763,12 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
132388
132763
|
continue;
|
|
132389
132764
|
const parsed = parseRouteName(d.name);
|
|
132390
132765
|
const method = parsed?.method ?? "ANY";
|
|
132391
|
-
const
|
|
132392
|
-
const key = method + " " +
|
|
132766
|
+
const path29 = parsed?.path ?? d.name;
|
|
132767
|
+
const key = method + " " + path29;
|
|
132393
132768
|
if (seen.has(key))
|
|
132394
132769
|
continue;
|
|
132395
132770
|
seen.add(key);
|
|
132396
|
-
out.push({ path:
|
|
132771
|
+
out.push({ path: path29, method: parsed?.method, file: d.filePath, handler: d.name });
|
|
132397
132772
|
}
|
|
132398
132773
|
for (const d of defs) {
|
|
132399
132774
|
const parsed = parseRouteName(d.name);
|
|
@@ -132614,8 +132989,8 @@ __export(exports_symbol_graph_service, {
|
|
|
132614
132989
|
symbolGraphService: () => symbolGraphService,
|
|
132615
132990
|
SymbolGraphService: () => SymbolGraphService
|
|
132616
132991
|
});
|
|
132617
|
-
import
|
|
132618
|
-
import
|
|
132992
|
+
import path29 from "path";
|
|
132993
|
+
import fs18 from "fs/promises";
|
|
132619
132994
|
|
|
132620
132995
|
class SymbolGraphService {
|
|
132621
132996
|
identityLookup;
|
|
@@ -132786,9 +133161,9 @@ class SymbolGraphService {
|
|
|
132786
133161
|
return null;
|
|
132787
133162
|
const workspace = graphSnapshot.workspace;
|
|
132788
133163
|
const arch = await this.computeArchitectureMapSafe(graphSnapshot.architecture).catch((err) => {
|
|
132789
|
-
logger.warn("
|
|
133164
|
+
logger.warn("SymbolGraphService: getProjectMap architecture map failed, skipping", {
|
|
132790
133165
|
projectId,
|
|
132791
|
-
error: err
|
|
133166
|
+
error: err
|
|
132792
133167
|
});
|
|
132793
133168
|
return null;
|
|
132794
133169
|
});
|
|
@@ -132943,7 +133318,7 @@ class SymbolGraphService {
|
|
|
132943
133318
|
async readSnippet(relativePath, lineStart, lineEnd, projectId) {
|
|
132944
133319
|
try {
|
|
132945
133320
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
132946
|
-
const content = await
|
|
133321
|
+
const content = await fs18.readFile(absolutePath, "utf-8");
|
|
132947
133322
|
const lines = content.split(`
|
|
132948
133323
|
`);
|
|
132949
133324
|
return lines.slice(Math.max(0, lineStart - 1), Math.min(lines.length, lineEnd)).join(`
|
|
@@ -132955,7 +133330,7 @@ class SymbolGraphService {
|
|
|
132955
133330
|
async readContext(relativePath, lineNumber, contextLines, projectId) {
|
|
132956
133331
|
try {
|
|
132957
133332
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
132958
|
-
const content = await
|
|
133333
|
+
const content = await fs18.readFile(absolutePath, "utf-8");
|
|
132959
133334
|
const lines = content.split(`
|
|
132960
133335
|
`);
|
|
132961
133336
|
const start = Math.max(0, lineNumber - contextLines - 1);
|
|
@@ -132968,7 +133343,7 @@ class SymbolGraphService {
|
|
|
132968
133343
|
}
|
|
132969
133344
|
async resolveToAbsolute(relativePath, projectId) {
|
|
132970
133345
|
const root = await this.getProjectRoot(projectId);
|
|
132971
|
-
return root ?
|
|
133346
|
+
return root ? path29.resolve(root, relativePath) : relativePath;
|
|
132972
133347
|
}
|
|
132973
133348
|
async getProjectRoot(projectId) {
|
|
132974
133349
|
const cached2 = this.projectRootCache.get(projectId);
|
|
@@ -133111,7 +133486,7 @@ var init_workspace_manager = __esm(() => {
|
|
|
133111
133486
|
});
|
|
133112
133487
|
|
|
133113
133488
|
// ../../packages/core/dist/tools/index_project.js
|
|
133114
|
-
import
|
|
133489
|
+
import path30 from "path";
|
|
133115
133490
|
|
|
133116
133491
|
class IndexProjectTool {
|
|
133117
133492
|
name = "index_project";
|
|
@@ -133159,7 +133534,7 @@ class IndexProjectTool {
|
|
|
133159
133534
|
try {
|
|
133160
133535
|
await assertParserReadyForIndexing();
|
|
133161
133536
|
const canonicalProjectPath = await canonicalizeProjectRoot(projectPath);
|
|
133162
|
-
const finalProjectId = projectId ||
|
|
133537
|
+
const finalProjectId = projectId || path30.basename(canonicalProjectPath) || "default";
|
|
133163
133538
|
const existing = await workspaceManager.getWorkspace(finalProjectId);
|
|
133164
133539
|
await assertProjectRootReuse({
|
|
133165
133540
|
projectId: finalProjectId,
|
|
@@ -133712,17 +134087,17 @@ function applyReplacer(root, replacer) {
|
|
|
133712
134087
|
return transformChildren(root, replacer, []);
|
|
133713
134088
|
return transformChildren(normalizeValue(replacedRoot), replacer, []);
|
|
133714
134089
|
}
|
|
133715
|
-
function transformChildren(value, replacer,
|
|
134090
|
+
function transformChildren(value, replacer, path31) {
|
|
133716
134091
|
if (isJsonObject(value))
|
|
133717
|
-
return transformObject(value, replacer,
|
|
134092
|
+
return transformObject(value, replacer, path31);
|
|
133718
134093
|
if (isJsonArray(value))
|
|
133719
|
-
return transformArray(value, replacer,
|
|
134094
|
+
return transformArray(value, replacer, path31);
|
|
133720
134095
|
return value;
|
|
133721
134096
|
}
|
|
133722
|
-
function transformObject(obj, replacer,
|
|
134097
|
+
function transformObject(obj, replacer, path31) {
|
|
133723
134098
|
const result = {};
|
|
133724
134099
|
for (const [key, value] of Object.entries(obj)) {
|
|
133725
|
-
const childPath = [...
|
|
134100
|
+
const childPath = [...path31, key];
|
|
133726
134101
|
const replacedValue = replacer(key, value, childPath);
|
|
133727
134102
|
if (replacedValue === undefined)
|
|
133728
134103
|
continue;
|
|
@@ -133730,11 +134105,11 @@ function transformObject(obj, replacer, path30) {
|
|
|
133730
134105
|
}
|
|
133731
134106
|
return result;
|
|
133732
134107
|
}
|
|
133733
|
-
function transformArray(arr, replacer,
|
|
134108
|
+
function transformArray(arr, replacer, path31) {
|
|
133734
134109
|
const result = [];
|
|
133735
134110
|
for (let i = 0;i < arr.length; i++) {
|
|
133736
134111
|
const value = arr[i];
|
|
133737
|
-
const childPath = [...
|
|
134112
|
+
const childPath = [...path31, i];
|
|
133738
134113
|
const replacedValue = replacer(String(i), value, childPath);
|
|
133739
134114
|
if (replacedValue === undefined)
|
|
133740
134115
|
continue;
|
|
@@ -134507,7 +134882,7 @@ class RelationExtractor {
|
|
|
134507
134882
|
} catch (error51) {
|
|
134508
134883
|
logger.warn("RelationExtractor: extraction failed", {
|
|
134509
134884
|
memoryId,
|
|
134510
|
-
error: error51
|
|
134885
|
+
error: error51
|
|
134511
134886
|
});
|
|
134512
134887
|
}
|
|
134513
134888
|
return edgesCreated;
|
|
@@ -134954,7 +135329,7 @@ class MemoryGraphService {
|
|
|
134954
135329
|
} catch (error51) {
|
|
134955
135330
|
logger.warn("Graph update failed after memory store", {
|
|
134956
135331
|
memoryId,
|
|
134957
|
-
error: error51
|
|
135332
|
+
error: error51
|
|
134958
135333
|
});
|
|
134959
135334
|
}
|
|
134960
135335
|
}
|
|
@@ -134970,7 +135345,7 @@ class MemoryGraphService {
|
|
|
134970
135345
|
} catch (error51) {
|
|
134971
135346
|
logger.warn("Graph cleanup failed after memory delete", {
|
|
134972
135347
|
memoryId,
|
|
134973
|
-
error: error51
|
|
135348
|
+
error: error51
|
|
134974
135349
|
});
|
|
134975
135350
|
}
|
|
134976
135351
|
}
|
|
@@ -135119,7 +135494,7 @@ async function consolidateWindow(candidates2, llm2, opts = {}) {
|
|
|
135119
135494
|
if (!llm2.isEnabled())
|
|
135120
135495
|
return null;
|
|
135121
135496
|
const prompt = buildPrompt2(window2);
|
|
135122
|
-
const result = await llm2.object(prompt, ConsolidatedBatchSchema);
|
|
135497
|
+
const result = await llm2.object(prompt, ConsolidatedBatchSchema, { label: "memory-consolidation" });
|
|
135123
135498
|
if (!result.ok || !result.value)
|
|
135124
135499
|
return null;
|
|
135125
135500
|
const batch = {
|
|
@@ -135220,7 +135595,7 @@ class MemoryConsolidationJob {
|
|
|
135220
135595
|
} catch (error51) {
|
|
135221
135596
|
logger.warn("Memory consolidation skipped", {
|
|
135222
135597
|
trigger,
|
|
135223
|
-
error: error51
|
|
135598
|
+
error: error51
|
|
135224
135599
|
});
|
|
135225
135600
|
} finally {
|
|
135226
135601
|
this.running = false;
|
|
@@ -135243,7 +135618,7 @@ class MemoryConsolidationJob {
|
|
|
135243
135618
|
candidates2 = await Promise.resolve(repo.listConsolidationCandidates(staleSinceMs, 500));
|
|
135244
135619
|
} catch (e) {
|
|
135245
135620
|
logger.warn("consolidation: candidate list failed (decay)", {
|
|
135246
|
-
error: e
|
|
135621
|
+
error: e
|
|
135247
135622
|
});
|
|
135248
135623
|
return 0;
|
|
135249
135624
|
}
|
|
@@ -135265,7 +135640,7 @@ class MemoryConsolidationJob {
|
|
|
135265
135640
|
} catch (e) {
|
|
135266
135641
|
logger.warn("consolidation: decay write failed", {
|
|
135267
135642
|
id: row.id,
|
|
135268
|
-
error: e
|
|
135643
|
+
error: e
|
|
135269
135644
|
});
|
|
135270
135645
|
}
|
|
135271
135646
|
}
|
|
@@ -135294,14 +135669,14 @@ class MemoryConsolidationJob {
|
|
|
135294
135669
|
} catch (e) {
|
|
135295
135670
|
logger.warn("consolidation: soft-delete failed", {
|
|
135296
135671
|
id: row.id,
|
|
135297
|
-
error: e
|
|
135672
|
+
error: e
|
|
135298
135673
|
});
|
|
135299
135674
|
}
|
|
135300
135675
|
}
|
|
135301
135676
|
}
|
|
135302
135677
|
} catch (e) {
|
|
135303
135678
|
logger.warn("consolidation: prune scan failed", {
|
|
135304
|
-
error: e
|
|
135679
|
+
error: e
|
|
135305
135680
|
});
|
|
135306
135681
|
}
|
|
135307
135682
|
return pruned;
|
|
@@ -135312,7 +135687,7 @@ class MemoryConsolidationJob {
|
|
|
135312
135687
|
candidates2 = await Promise.resolve(repo.listConsolidationCandidates(staleSinceMs, 200));
|
|
135313
135688
|
} catch (e) {
|
|
135314
135689
|
logger.warn("consolidation: candidate list failed (merge)", {
|
|
135315
|
-
error: e
|
|
135690
|
+
error: e
|
|
135316
135691
|
});
|
|
135317
135692
|
return { merged: 0, batchesCreated: 0 };
|
|
135318
135693
|
}
|
|
@@ -135338,7 +135713,7 @@ class MemoryConsolidationJob {
|
|
|
135338
135713
|
} catch (e) {
|
|
135339
135714
|
logger.warn("consolidation: merge insert failed", {
|
|
135340
135715
|
batchId: batch.id,
|
|
135341
|
-
error: e
|
|
135716
|
+
error: e
|
|
135342
135717
|
});
|
|
135343
135718
|
return { merged: 0, batchesCreated: 0 };
|
|
135344
135719
|
}
|
|
@@ -135351,7 +135726,7 @@ class MemoryConsolidationJob {
|
|
|
135351
135726
|
logger.warn("consolidation: addSupercedesEdge failed", {
|
|
135352
135727
|
newId,
|
|
135353
135728
|
sourceId,
|
|
135354
|
-
error: e
|
|
135729
|
+
error: e
|
|
135355
135730
|
});
|
|
135356
135731
|
}
|
|
135357
135732
|
}
|
|
@@ -135391,7 +135766,7 @@ class MemoryConsolidationJob {
|
|
|
135391
135766
|
return result;
|
|
135392
135767
|
} catch (e) {
|
|
135393
135768
|
logger.warn("consolidation: promote (PG) failed", {
|
|
135394
|
-
error: e
|
|
135769
|
+
error: e
|
|
135395
135770
|
});
|
|
135396
135771
|
return 0;
|
|
135397
135772
|
}
|
|
@@ -135430,19 +135805,22 @@ class SalienceJudge {
|
|
|
135430
135805
|
}
|
|
135431
135806
|
const prompt = buildPrompt3(trimmed, type);
|
|
135432
135807
|
let verdict;
|
|
135808
|
+
let verdictError;
|
|
135433
135809
|
try {
|
|
135434
|
-
const res = await this.llm.object(prompt, SalienceSchema);
|
|
135810
|
+
const res = await this.llm.object(prompt, SalienceSchema, { label: "salience-judge" });
|
|
135435
135811
|
verdict = res.ok ? res.value ?? null : null;
|
|
135812
|
+
verdictError = res.ok ? undefined : res.error;
|
|
135436
135813
|
} catch (e) {
|
|
135437
135814
|
logger.warn("SalienceJudge threw \u2014 degrading to neutral default", {
|
|
135438
135815
|
type,
|
|
135439
|
-
error: e
|
|
135816
|
+
error: e
|
|
135440
135817
|
});
|
|
135441
135818
|
return { salience: NEUTRAL_SALIENCE, source: "default" };
|
|
135442
135819
|
}
|
|
135443
135820
|
if (!verdict) {
|
|
135444
135821
|
logger.warn("SalienceJudge got {ok:false} \u2014 degrading to neutral default", {
|
|
135445
|
-
type
|
|
135822
|
+
type,
|
|
135823
|
+
error: verdictError
|
|
135446
135824
|
});
|
|
135447
135825
|
return { salience: NEUTRAL_SALIENCE, source: "default" };
|
|
135448
135826
|
}
|
|
@@ -135657,7 +136035,8 @@ class MemoryController {
|
|
|
135657
136035
|
}
|
|
135658
136036
|
} catch (err) {
|
|
135659
136037
|
logger.warn("Graph enrichment failed", {
|
|
135660
|
-
|
|
136038
|
+
projectId,
|
|
136039
|
+
error: err
|
|
135661
136040
|
});
|
|
135662
136041
|
}
|
|
135663
136042
|
}
|
|
@@ -135859,7 +136238,7 @@ class CodeCompressor {
|
|
|
135859
136238
|
}
|
|
135860
136239
|
const prompt = buildLlmCompressPrompt(content, language3, targetRatio, preservedElements);
|
|
135861
136240
|
try {
|
|
135862
|
-
const res = await this.llmCompleteFn(prompt, { timeoutMs, modelRole: "code" });
|
|
136241
|
+
const res = await this.llmCompleteFn(prompt, { label: "code-compressor", timeoutMs, modelRole: "code" });
|
|
135863
136242
|
if (res.ok && typeof res.value === "string" && res.value.trim().length > 0 && res.value.length <= content.length) {
|
|
135864
136243
|
compressed = res.value;
|
|
135865
136244
|
compressionSource = "llm";
|
|
@@ -135899,7 +136278,10 @@ class CodeCompressor {
|
|
|
135899
136278
|
});
|
|
135900
136279
|
return compressedContent;
|
|
135901
136280
|
} catch (error51) {
|
|
135902
|
-
logger.error("Code compression failed", error51
|
|
136281
|
+
logger.error("Code compression failed", error51, {
|
|
136282
|
+
strategy: useStrategy,
|
|
136283
|
+
originalLength: content.length
|
|
136284
|
+
});
|
|
135903
136285
|
return CompressedContent.identity(content);
|
|
135904
136286
|
}
|
|
135905
136287
|
}
|
|
@@ -136209,9 +136591,9 @@ class TokenMetrics {
|
|
|
136209
136591
|
}
|
|
136210
136592
|
throw new Error("Model not found in models.dev");
|
|
136211
136593
|
} catch (error51) {
|
|
136212
|
-
logger.warn("
|
|
136594
|
+
logger.warn("TokenMetrics: failed to fetch pricing from models.dev, using fallback", {
|
|
136213
136595
|
modelId,
|
|
136214
|
-
error: error51
|
|
136596
|
+
error: error51
|
|
136215
136597
|
});
|
|
136216
136598
|
const fallback = FALLBACK_PRICING2[modelId] || FALLBACK_PRICING2["gpt-4"];
|
|
136217
136599
|
this.pricingCache.set(modelId, {
|
|
@@ -136549,7 +136931,7 @@ class ContextController {
|
|
|
136549
136931
|
});
|
|
136550
136932
|
}
|
|
136551
136933
|
} catch (err) {
|
|
136552
|
-
logger.warn("
|
|
136934
|
+
logger.warn("ContextController: graph prefilter failed", { projectId, query, error: err });
|
|
136553
136935
|
}
|
|
136554
136936
|
}
|
|
136555
136937
|
const [searchResult, memories] = await Promise.all([
|
|
@@ -136703,9 +137085,11 @@ class ContextController {
|
|
|
136703
137085
|
});
|
|
136704
137086
|
return result.memories;
|
|
136705
137087
|
} catch (error51) {
|
|
136706
|
-
logger.warn("
|
|
136707
|
-
|
|
136708
|
-
|
|
137088
|
+
logger.warn("ContextController: memory search failed, continuing without memories", {
|
|
137089
|
+
projectId: opts.projectId,
|
|
137090
|
+
sessionId: opts.sessionId,
|
|
137091
|
+
query: query.slice(0, 30),
|
|
137092
|
+
error: error51
|
|
136709
137093
|
});
|
|
136710
137094
|
return [];
|
|
136711
137095
|
}
|
|
@@ -137381,7 +137765,7 @@ class PgCheckpointStore {
|
|
|
137381
137765
|
} catch (e) {
|
|
137382
137766
|
this.hydrateFailedAt = Date.now();
|
|
137383
137767
|
logger.warn("PgCheckpointStore hydrate failed (best-effort)", {
|
|
137384
|
-
error: e
|
|
137768
|
+
error: e
|
|
137385
137769
|
});
|
|
137386
137770
|
} finally {
|
|
137387
137771
|
this.hydrating = null;
|
|
@@ -137575,8 +137959,9 @@ class PgCheckpointStore {
|
|
|
137575
137959
|
}
|
|
137576
137960
|
return existing;
|
|
137577
137961
|
} catch (e) {
|
|
137578
|
-
logger.warn("countExistingMemoryIds failed (best-effort
|
|
137579
|
-
|
|
137962
|
+
logger.warn("PgCheckpointStore: countExistingMemoryIds failed (best-effort, assuming all exist)", {
|
|
137963
|
+
memoryIdCount: memoryIds.length,
|
|
137964
|
+
error: e
|
|
137580
137965
|
});
|
|
137581
137966
|
return memoryIds;
|
|
137582
137967
|
}
|
|
@@ -137643,7 +138028,7 @@ class PgCheckpointStore {
|
|
|
137643
138028
|
const next = prev.then(fn).catch((e) => {
|
|
137644
138029
|
logger.warn("PgCheckpointStore write failed (best-effort)", {
|
|
137645
138030
|
key,
|
|
137646
|
-
error: e
|
|
138031
|
+
error: e
|
|
137647
138032
|
});
|
|
137648
138033
|
});
|
|
137649
138034
|
this.inflight.set(key, next);
|
|
@@ -138069,7 +138454,7 @@ class ListCheckpointsTool {
|
|
|
138069
138454
|
};
|
|
138070
138455
|
return serializeToolResponse(responseData, { format, fields });
|
|
138071
138456
|
} catch (error51) {
|
|
138072
|
-
logger.error("Failed to list checkpoints", error51);
|
|
138457
|
+
logger.error("Failed to list checkpoints", error51, { taskId, projectId });
|
|
138073
138458
|
return {
|
|
138074
138459
|
success: false,
|
|
138075
138460
|
error: `Failed to list checkpoints: ${error51.message}`
|
|
@@ -138161,7 +138546,7 @@ class PgObservationStore {
|
|
|
138161
138546
|
} catch (e) {
|
|
138162
138547
|
this.hydrateFailedAt = Date.now();
|
|
138163
138548
|
logger.warn("PgObservationStore hydrate failed (best-effort)", {
|
|
138164
|
-
error: e
|
|
138549
|
+
error: e
|
|
138165
138550
|
});
|
|
138166
138551
|
} finally {
|
|
138167
138552
|
this.hydrating = null;
|
|
@@ -138212,7 +138597,7 @@ class PgObservationStore {
|
|
|
138212
138597
|
const next = prev.then(fn).catch((e) => {
|
|
138213
138598
|
logger.warn("PgObservationStore.insert failed (best-effort)", {
|
|
138214
138599
|
id: key,
|
|
138215
|
-
error: e
|
|
138600
|
+
error: e
|
|
138216
138601
|
});
|
|
138217
138602
|
});
|
|
138218
138603
|
this.inflight.set(key, next);
|
|
@@ -138815,9 +139200,9 @@ var init_session_pin_store = __esm(() => {
|
|
|
138815
139200
|
});
|
|
138816
139201
|
|
|
138817
139202
|
// ../../packages/core/dist/services/hooks/attribution-resolver.js
|
|
138818
|
-
import
|
|
138819
|
-
import
|
|
138820
|
-
import
|
|
139203
|
+
import fs19 from "fs";
|
|
139204
|
+
import os9 from "os";
|
|
139205
|
+
import path31 from "path";
|
|
138821
139206
|
|
|
138822
139207
|
class PgWorkspaceRootProvider {
|
|
138823
139208
|
cache = null;
|
|
@@ -138866,8 +139251,8 @@ class AttributionResolver {
|
|
|
138866
139251
|
this.aliasResolver = options.aliasResolver ?? getProjectIdentityAliasResolver();
|
|
138867
139252
|
this.pins = options.pins ?? new SessionPinStore;
|
|
138868
139253
|
this.canonicalize = options.canonicalize ?? defaultCanonicalize;
|
|
138869
|
-
this.homedir = options.homedir ??
|
|
138870
|
-
this.fsRoot = options.fsRoot ?? (() =>
|
|
139254
|
+
this.homedir = options.homedir ?? os9.homedir;
|
|
139255
|
+
this.fsRoot = options.fsRoot ?? (() => path31.parse(path31.sep).root);
|
|
138871
139256
|
}
|
|
138872
139257
|
async resolve(input) {
|
|
138873
139258
|
const caller = input.callerProjectId;
|
|
@@ -138918,7 +139303,7 @@ class AttributionResolver {
|
|
|
138918
139303
|
}
|
|
138919
139304
|
let bestPath = null;
|
|
138920
139305
|
for (const candidate2 of byPath.keys()) {
|
|
138921
|
-
if (canonicalCwd === candidate2 || canonicalCwd.startsWith(candidate2.endsWith(
|
|
139306
|
+
if (canonicalCwd === candidate2 || canonicalCwd.startsWith(candidate2.endsWith(path31.sep) ? candidate2 : candidate2 + path31.sep)) {
|
|
138922
139307
|
if (bestPath === null || candidate2.length > bestPath.length) {
|
|
138923
139308
|
bestPath = candidate2;
|
|
138924
139309
|
}
|
|
@@ -138941,7 +139326,7 @@ class AttributionResolver {
|
|
|
138941
139326
|
return projectPath2;
|
|
138942
139327
|
const fsRoot = this.fsRoot();
|
|
138943
139328
|
let normalized = projectPath2;
|
|
138944
|
-
while (normalized.length > fsRoot.length && normalized.endsWith(
|
|
139329
|
+
while (normalized.length > fsRoot.length && normalized.endsWith(path31.sep)) {
|
|
138945
139330
|
normalized = normalized.slice(0, -1);
|
|
138946
139331
|
}
|
|
138947
139332
|
return normalized;
|
|
@@ -138949,10 +139334,10 @@ class AttributionResolver {
|
|
|
138949
139334
|
}
|
|
138950
139335
|
function defaultCanonicalize(cwd) {
|
|
138951
139336
|
try {
|
|
138952
|
-
return
|
|
139337
|
+
return fs19.realpathSync(cwd);
|
|
138953
139338
|
} catch {
|
|
138954
139339
|
try {
|
|
138955
|
-
return
|
|
139340
|
+
return path31.resolve(cwd);
|
|
138956
139341
|
} catch {
|
|
138957
139342
|
return;
|
|
138958
139343
|
}
|
|
@@ -139055,7 +139440,8 @@ class CompactSnapshotTool {
|
|
|
139055
139440
|
});
|
|
139056
139441
|
} catch (e) {
|
|
139057
139442
|
logger.warn("compact_snapshot: persist failed (non-fatal)", {
|
|
139058
|
-
|
|
139443
|
+
sessionId,
|
|
139444
|
+
error: e
|
|
139059
139445
|
});
|
|
139060
139446
|
persistedId = undefined;
|
|
139061
139447
|
}
|
|
@@ -139700,31 +140086,31 @@ class TracePathService {
|
|
|
139700
140086
|
const chains = [];
|
|
139701
140087
|
const seen = new Set;
|
|
139702
140088
|
let walks = 0;
|
|
139703
|
-
const walk = (fqn,
|
|
140089
|
+
const walk = (fqn, path32) => {
|
|
139704
140090
|
if (chains.length >= CHAIN_CAP)
|
|
139705
140091
|
return;
|
|
139706
140092
|
if (walks >= MAX_WALKS)
|
|
139707
140093
|
return;
|
|
139708
140094
|
walks++;
|
|
139709
|
-
const key =
|
|
140095
|
+
const key = path32.join("\u2192");
|
|
139710
140096
|
if (seen.has(key))
|
|
139711
140097
|
return;
|
|
139712
140098
|
seen.add(key);
|
|
139713
140099
|
const next = adj.get(fqn);
|
|
139714
140100
|
if (!next || next.length === 0 || !whoHasChild.has(fqn)) {
|
|
139715
|
-
if (
|
|
139716
|
-
chains.push(
|
|
140101
|
+
if (path32.length > 1)
|
|
140102
|
+
chains.push(path32.map((n) => this.fqnToName(n)).join(" \u2192 "));
|
|
139717
140103
|
return;
|
|
139718
140104
|
}
|
|
139719
140105
|
for (const child of next) {
|
|
139720
140106
|
if (chains.length >= CHAIN_CAP || walks >= MAX_WALKS)
|
|
139721
140107
|
return;
|
|
139722
|
-
if (
|
|
139723
|
-
const cycled = [...
|
|
140108
|
+
if (path32.includes(child)) {
|
|
140109
|
+
const cycled = [...path32, `${this.fqnToName(child)}\u21BA`];
|
|
139724
140110
|
chains.push(cycled.map((n) => n).join(" \u2192 "));
|
|
139725
140111
|
continue;
|
|
139726
140112
|
}
|
|
139727
|
-
walk(child, [...
|
|
140113
|
+
walk(child, [...path32, child]);
|
|
139728
140114
|
}
|
|
139729
140115
|
};
|
|
139730
140116
|
for (const seed of seeds) {
|
|
@@ -140557,7 +140943,7 @@ var init_get_architecture = __esm(() => {
|
|
|
140557
140943
|
});
|
|
140558
140944
|
|
|
140559
140945
|
// ../../packages/core/dist/services/file-read/file-content-cache.js
|
|
140560
|
-
import
|
|
140946
|
+
import fs20 from "fs/promises";
|
|
140561
140947
|
|
|
140562
140948
|
class FileContentCache {
|
|
140563
140949
|
extractMetadata;
|
|
@@ -140590,7 +140976,7 @@ class FileContentCache {
|
|
|
140590
140976
|
metadata: cached2.metadata
|
|
140591
140977
|
};
|
|
140592
140978
|
}
|
|
140593
|
-
const content = await
|
|
140979
|
+
const content = await fs20.readFile(filePath, "utf-8");
|
|
140594
140980
|
const metadata = await this.extractMetadata(content, filePath, options);
|
|
140595
140981
|
evictOldest(this.fileCache, this.FILE_CACHE_MAX_ENTRIES - 1);
|
|
140596
140982
|
this.fileCache.set(cacheKey, {
|
|
@@ -140607,7 +140993,7 @@ var init_file_content_cache = __esm(() => {
|
|
|
140607
140993
|
});
|
|
140608
140994
|
|
|
140609
140995
|
// ../../packages/core/dist/services/file-read/file-metadata.js
|
|
140610
|
-
import
|
|
140996
|
+
import path32 from "path";
|
|
140611
140997
|
|
|
140612
140998
|
class FileMetadataExtractor {
|
|
140613
140999
|
symbolGraph;
|
|
@@ -140643,7 +141029,7 @@ class FileMetadataExtractor {
|
|
|
140643
141029
|
return metadata;
|
|
140644
141030
|
}
|
|
140645
141031
|
detectLanguage(filePath) {
|
|
140646
|
-
const ext2 =
|
|
141032
|
+
const ext2 = path32.extname(filePath).toLowerCase();
|
|
140647
141033
|
const languageMap2 = {
|
|
140648
141034
|
".ts": "TypeScript",
|
|
140649
141035
|
".tsx": "TypeScript",
|
|
@@ -140765,7 +141151,7 @@ var init_line_range = __esm(() => {
|
|
|
140765
141151
|
});
|
|
140766
141152
|
|
|
140767
141153
|
// ../../packages/core/dist/services/file-read/path-containment.js
|
|
140768
|
-
import
|
|
141154
|
+
import path33 from "path";
|
|
140769
141155
|
|
|
140770
141156
|
class PathContainment {
|
|
140771
141157
|
projectRoots;
|
|
@@ -140773,14 +141159,14 @@ class PathContainment {
|
|
|
140773
141159
|
this.projectRoots = projectRoots;
|
|
140774
141160
|
}
|
|
140775
141161
|
async resolveFilePath(filePath, projectId) {
|
|
140776
|
-
if (
|
|
140777
|
-
return
|
|
141162
|
+
if (path33.isAbsolute(filePath)) {
|
|
141163
|
+
return path33.resolve(filePath);
|
|
140778
141164
|
}
|
|
140779
141165
|
if (projectId) {
|
|
140780
141166
|
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
140781
141167
|
if (root) {
|
|
140782
141168
|
const cleaned = sanitizeFilePath(filePath);
|
|
140783
|
-
return
|
|
141169
|
+
return path33.resolve(root, cleaned);
|
|
140784
141170
|
}
|
|
140785
141171
|
return null;
|
|
140786
141172
|
}
|
|
@@ -140791,17 +141177,17 @@ class PathContainment {
|
|
|
140791
141177
|
if (projectId) {
|
|
140792
141178
|
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
140793
141179
|
if (root)
|
|
140794
|
-
roots.push(
|
|
141180
|
+
roots.push(path33.resolve(root));
|
|
140795
141181
|
}
|
|
140796
|
-
roots.push(
|
|
141182
|
+
roots.push(path33.resolve(process.cwd()));
|
|
140797
141183
|
const envRoots = (process.env.MASSA_AI_READ_FILE_ROOTS ?? "").split(":").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
140798
141184
|
for (const extra of envRoots) {
|
|
140799
|
-
roots.push(
|
|
141185
|
+
roots.push(path33.resolve(extra));
|
|
140800
141186
|
}
|
|
140801
|
-
const target =
|
|
141187
|
+
const target = path33.resolve(absoluteFilePath);
|
|
140802
141188
|
for (const root of roots) {
|
|
140803
|
-
const rel =
|
|
140804
|
-
if (rel !== "" && !rel.startsWith("..") && !
|
|
141189
|
+
const rel = path33.relative(root, target);
|
|
141190
|
+
if (rel !== "" && !rel.startsWith("..") && !path33.isAbsolute(rel)) {
|
|
140805
141191
|
return { allowed: true };
|
|
140806
141192
|
}
|
|
140807
141193
|
if (rel === "")
|
|
@@ -140849,7 +141235,7 @@ class ProjectRootCache {
|
|
|
140849
141235
|
return workspace.project_path;
|
|
140850
141236
|
}
|
|
140851
141237
|
} catch (error51) {
|
|
140852
|
-
logger.warn("
|
|
141238
|
+
logger.warn("ProjectRootCache: failed to look up project root", { projectId, error: error51 });
|
|
140853
141239
|
}
|
|
140854
141240
|
return null;
|
|
140855
141241
|
}
|
|
@@ -141517,7 +141903,7 @@ function warnSandboxUnavailable() {
|
|
|
141517
141903
|
return;
|
|
141518
141904
|
_warnedAboutNoSandbox = true;
|
|
141519
141905
|
const missingTool = process.platform === "darwin" ? "sandbox-exec" : "docker";
|
|
141520
|
-
logger.warn(
|
|
141906
|
+
logger.warn("Sandbox: no sandbox tool found for auto mode, falling back to best-effort containment", { missingTool, platform: process.platform, effectiveMode: "none" });
|
|
141521
141907
|
}
|
|
141522
141908
|
function getSandboxMode() {
|
|
141523
141909
|
const env4 = process.env.MASSA_AI_EXECUTOR_SANDBOX ?? "auto";
|
|
@@ -142432,7 +142818,10 @@ class ExecutorController {
|
|
|
142432
142818
|
}
|
|
142433
142819
|
};
|
|
142434
142820
|
} catch (error51) {
|
|
142435
|
-
logger.error("batch_execute failed", error51
|
|
142821
|
+
logger.error("batch_execute failed", error51, {
|
|
142822
|
+
commandCount: commands.length,
|
|
142823
|
+
concurrency: effectiveConcurrency
|
|
142824
|
+
});
|
|
142436
142825
|
return {
|
|
142437
142826
|
success: false,
|
|
142438
142827
|
error: `batch_execute failed: ${error51.message}`
|
|
@@ -144044,9 +144433,9 @@ var init_inference_probe = __esm(() => {
|
|
|
144044
144433
|
});
|
|
144045
144434
|
|
|
144046
144435
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
144047
|
-
import
|
|
144436
|
+
import fs21 from "fs/promises";
|
|
144048
144437
|
import { existsSync as existsSync3 } from "fs";
|
|
144049
|
-
import
|
|
144438
|
+
import path34 from "path";
|
|
144050
144439
|
|
|
144051
144440
|
class LocalHealthChecker {
|
|
144052
144441
|
dataDir = config2.get("dataDir");
|
|
@@ -144124,10 +144513,10 @@ class LocalHealthChecker {
|
|
|
144124
144513
|
const start = Date.now();
|
|
144125
144514
|
try {
|
|
144126
144515
|
if (!existsSync3(this.dataDir))
|
|
144127
|
-
await
|
|
144128
|
-
const probe2 =
|
|
144129
|
-
await
|
|
144130
|
-
await
|
|
144516
|
+
await fs21.mkdir(this.dataDir, { recursive: true });
|
|
144517
|
+
const probe2 = path34.join(this.dataDir, ".health-check-test");
|
|
144518
|
+
await fs21.writeFile(probe2, "ok");
|
|
144519
|
+
await fs21.unlink(probe2);
|
|
144131
144520
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
144132
144521
|
} catch (error51) {
|
|
144133
144522
|
return { available: false, latency: Date.now() - start, error: `Data directory error: ${error51.message}` };
|
|
@@ -144374,7 +144763,7 @@ class PgScheduledJobStore {
|
|
|
144374
144763
|
logger.info("PgScheduledJobStore hydrated", { rows: this.mirror.size });
|
|
144375
144764
|
} catch (e) {
|
|
144376
144765
|
logger.warn("PgScheduledJobStore hydrate failed (best-effort)", {
|
|
144377
|
-
error: e
|
|
144766
|
+
error: e
|
|
144378
144767
|
});
|
|
144379
144768
|
} finally {
|
|
144380
144769
|
this.hydrating = null;
|
|
@@ -144388,9 +144777,10 @@ class PgScheduledJobStore {
|
|
|
144388
144777
|
try {
|
|
144389
144778
|
await action();
|
|
144390
144779
|
} catch (e) {
|
|
144391
|
-
logger.warn(
|
|
144780
|
+
logger.warn("PgScheduledJobStore mutation failed (best-effort)", {
|
|
144392
144781
|
id,
|
|
144393
|
-
|
|
144782
|
+
operation,
|
|
144783
|
+
error: e
|
|
144394
144784
|
});
|
|
144395
144785
|
}
|
|
144396
144786
|
};
|
|
@@ -144643,7 +145033,7 @@ class Scheduler {
|
|
|
144643
145033
|
this.timer = setInterval(() => {
|
|
144644
145034
|
this.tick().catch((e) => {
|
|
144645
145035
|
logger.warn("Scheduler tick failed (swallowed)", {
|
|
144646
|
-
error: e
|
|
145036
|
+
error: e
|
|
144647
145037
|
});
|
|
144648
145038
|
});
|
|
144649
145039
|
}, this.tickIntervalMs);
|
|
@@ -144758,7 +145148,7 @@ class Scheduler {
|
|
|
144758
145148
|
logger.warn("Scheduler: job handler threw (caught)", {
|
|
144759
145149
|
id: job.id,
|
|
144760
145150
|
jobKind: job.jobKind,
|
|
144761
|
-
error:
|
|
145151
|
+
error: e
|
|
144762
145152
|
});
|
|
144763
145153
|
} finally {
|
|
144764
145154
|
if (succeeded) {
|
|
@@ -144777,7 +145167,7 @@ class Scheduler {
|
|
|
144777
145167
|
} catch (e) {
|
|
144778
145168
|
logger.warn("Scheduler: persist after fire failed", {
|
|
144779
145169
|
id: job.id,
|
|
144780
|
-
error: e
|
|
145170
|
+
error: e
|
|
144781
145171
|
});
|
|
144782
145172
|
}
|
|
144783
145173
|
this.running.delete(job.jobKind);
|
|
@@ -144797,6 +145187,8 @@ class Scheduler {
|
|
|
144797
145187
|
enabled: j.enabled,
|
|
144798
145188
|
nextRunAt: j.nextRunAt,
|
|
144799
145189
|
lastRunAt: j.lastRunAt,
|
|
145190
|
+
lastSuccessAt: j.lastSuccessAt ?? null,
|
|
145191
|
+
consecutiveFailures: j.consecutiveFailures ?? 0,
|
|
144800
145192
|
due: j.enabled && j.nextRunAt <= now2,
|
|
144801
145193
|
currentlyRunning: this.running.has(j.jobKind)
|
|
144802
145194
|
}))
|
|
@@ -145443,7 +145835,7 @@ async function enrichWithLlm(candidates2, observations, surface) {
|
|
|
145443
145835
|
const prompt = buildEnrichmentPrompt(candidates2, observations);
|
|
145444
145836
|
let enrichment = null;
|
|
145445
145837
|
try {
|
|
145446
|
-
const res = await surface.object(prompt, ProposalEnrichmentSchema);
|
|
145838
|
+
const res = await surface.object(prompt, ProposalEnrichmentSchema, { label: "auto-improve" });
|
|
145447
145839
|
if (!res.ok || !res.value || !Array.isArray(res.value.items)) {
|
|
145448
145840
|
return { candidates: candidates2, used: false };
|
|
145449
145841
|
}
|
|
@@ -145639,7 +146031,7 @@ async function runOnce(job, projectId) {
|
|
|
145639
146031
|
try {
|
|
145640
146032
|
observations = job.observationStore.listRecent(projectId, job.maxWindow);
|
|
145641
146033
|
} catch (e) {
|
|
145642
|
-
logger.warn("auto-improve: listRecent failed", { projectId, error: e
|
|
146034
|
+
logger.warn("auto-improve: listRecent failed", { projectId, error: e });
|
|
145643
146035
|
return noop2;
|
|
145644
146036
|
}
|
|
145645
146037
|
if (observations.length < 2)
|
|
@@ -145654,7 +146046,7 @@ async function runOnce(job, projectId) {
|
|
|
145654
146046
|
if (res.used)
|
|
145655
146047
|
source = "llm";
|
|
145656
146048
|
} catch (e) {
|
|
145657
|
-
logger.warn("auto-improve: enrichWithLlm threw (silent)", { projectId, error: e
|
|
146049
|
+
logger.warn("auto-improve: enrichWithLlm threw (silent)", { projectId, error: e });
|
|
145658
146050
|
}
|
|
145659
146051
|
const seen = new Set;
|
|
145660
146052
|
const unique = candidates2.filter((c) => {
|
|
@@ -145702,7 +146094,7 @@ async function runOnce(job, projectId) {
|
|
|
145702
146094
|
} catch (e) {
|
|
145703
146095
|
if (e instanceof SearchServiceError)
|
|
145704
146096
|
throw e;
|
|
145705
|
-
logger.warn("proposal:auto-approved:threw", { id: r.id, projectId, error: e
|
|
146097
|
+
logger.warn("proposal:auto-approved:threw", { id: r.id, projectId, error: e });
|
|
145706
146098
|
}
|
|
145707
146099
|
}
|
|
145708
146100
|
result.proposalsApplied = applied;
|
|
@@ -145731,7 +146123,7 @@ async function approve(job, id, projectId, source = "rule-based") {
|
|
|
145731
146123
|
appliedMemoryId = await applyProposal(job, row);
|
|
145732
146124
|
} catch (e) {
|
|
145733
146125
|
const reason = e instanceof ApplyRejection ? e.reason : "apply-failed";
|
|
145734
|
-
logger.warn("proposal:apply-failed", { id, projectId: row.projectId, reason, error: e
|
|
146126
|
+
logger.warn("proposal:apply-failed", { id, projectId: row.projectId, reason, error: e });
|
|
145735
146127
|
return { ok: false, reason };
|
|
145736
146128
|
}
|
|
145737
146129
|
let updated;
|
|
@@ -145866,9 +146258,9 @@ class AutoImproveJob {
|
|
|
145866
146258
|
return;
|
|
145867
146259
|
this.newSinceRun = 0;
|
|
145868
146260
|
this.lastRunAt = now2;
|
|
145869
|
-
this.runOnce(projectId).catch((e) => logger.warn("auto-improve: runOnce failed (silent)", { projectId, error: e
|
|
146261
|
+
this.runOnce(projectId).catch((e) => logger.warn("auto-improve: runOnce failed (silent)", { projectId, error: e }));
|
|
145870
146262
|
} catch (e) {
|
|
145871
|
-
logger.warn("auto-improve: maybeRun swallowed", { projectId, error: e
|
|
146263
|
+
logger.warn("auto-improve: maybeRun swallowed", { projectId, error: e });
|
|
145872
146264
|
}
|
|
145873
146265
|
}
|
|
145874
146266
|
async runOnce(projectId) {
|
|
@@ -145968,13 +146360,13 @@ class ObservationConsolidationJob {
|
|
|
145968
146360
|
this.runOnce(projectId).catch((e) => {
|
|
145969
146361
|
logger.warn("observation consolidation: runOnce failed (silent)", {
|
|
145970
146362
|
projectId,
|
|
145971
|
-
error: e
|
|
146363
|
+
error: e
|
|
145972
146364
|
});
|
|
145973
146365
|
});
|
|
145974
146366
|
} catch (e) {
|
|
145975
146367
|
logger.warn("observation consolidation: maybeRun swallowed", {
|
|
145976
146368
|
projectId,
|
|
145977
|
-
error: e
|
|
146369
|
+
error: e
|
|
145978
146370
|
});
|
|
145979
146371
|
}
|
|
145980
146372
|
}
|
|
@@ -145998,7 +146390,7 @@ class ObservationConsolidationJob {
|
|
|
145998
146390
|
} catch (e) {
|
|
145999
146391
|
logger.warn("observation consolidation: listRecent failed", {
|
|
146000
146392
|
projectId,
|
|
146001
|
-
error: e
|
|
146393
|
+
error: e
|
|
146002
146394
|
});
|
|
146003
146395
|
return noop2;
|
|
146004
146396
|
}
|
|
@@ -146009,7 +146401,7 @@ class ObservationConsolidationJob {
|
|
|
146009
146401
|
const prompt = buildObservationPrompt(window2);
|
|
146010
146402
|
let batch;
|
|
146011
146403
|
try {
|
|
146012
|
-
const res = await this.llm.object(prompt, ConsolidatedBatchSchema);
|
|
146404
|
+
const res = await this.llm.object(prompt, ConsolidatedBatchSchema, { label: "observation-consolidation" });
|
|
146013
146405
|
if (!res.ok || !res.value) {
|
|
146014
146406
|
return noop2;
|
|
146015
146407
|
}
|
|
@@ -146025,7 +146417,7 @@ class ObservationConsolidationJob {
|
|
|
146025
146417
|
} catch (e) {
|
|
146026
146418
|
logger.warn("observation consolidation: llm.object threw (silent)", {
|
|
146027
146419
|
projectId,
|
|
146028
|
-
error: e
|
|
146420
|
+
error: e
|
|
146029
146421
|
});
|
|
146030
146422
|
return noop2;
|
|
146031
146423
|
}
|
|
@@ -146054,7 +146446,7 @@ class ObservationConsolidationJob {
|
|
|
146054
146446
|
} catch (e) {
|
|
146055
146447
|
logger.warn("observation consolidation: summary insert failed", {
|
|
146056
146448
|
batchId: batch.id,
|
|
146057
|
-
error: e
|
|
146449
|
+
error: e
|
|
146058
146450
|
});
|
|
146059
146451
|
return noop2;
|
|
146060
146452
|
}
|
|
@@ -146261,9 +146653,9 @@ var init_scheduler2 = __esm(() => {
|
|
|
146261
146653
|
});
|
|
146262
146654
|
|
|
146263
146655
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
146264
|
-
import
|
|
146656
|
+
import fs22 from "fs/promises";
|
|
146265
146657
|
import { existsSync as existsSync4 } from "fs";
|
|
146266
|
-
import
|
|
146658
|
+
import path35 from "path";
|
|
146267
146659
|
function getModelsDevClient() {
|
|
146268
146660
|
if (!clientInstance) {
|
|
146269
146661
|
clientInstance = new ModelsDevClient;
|
|
@@ -146283,7 +146675,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
146283
146675
|
memoryCacheTimestamp = 0;
|
|
146284
146676
|
getLocalCachePath() {
|
|
146285
146677
|
const dataDir = config2.get("dataDir");
|
|
146286
|
-
return
|
|
146678
|
+
return path35.join(dataDir, ModelsDevClient.LOCAL_CACHE_FILE);
|
|
146287
146679
|
}
|
|
146288
146680
|
async loadLocalCache() {
|
|
146289
146681
|
const cachePath = this.getLocalCachePath();
|
|
@@ -146291,7 +146683,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
146291
146683
|
if (!existsSync4(cachePath)) {
|
|
146292
146684
|
return null;
|
|
146293
146685
|
}
|
|
146294
|
-
const content = await
|
|
146686
|
+
const content = await fs22.readFile(cachePath, "utf-8");
|
|
146295
146687
|
const data = JSON.parse(content);
|
|
146296
146688
|
const age = Date.now() - data.timestamp;
|
|
146297
146689
|
if (age > ModelsDevClient.LOCAL_CACHE_TTL) {
|
|
@@ -146318,21 +146710,22 @@ var init_models_dev_client = __esm(() => {
|
|
|
146318
146710
|
async saveLocalCache(models) {
|
|
146319
146711
|
const cachePath = this.getLocalCachePath();
|
|
146320
146712
|
try {
|
|
146321
|
-
const dir =
|
|
146322
|
-
await
|
|
146713
|
+
const dir = path35.dirname(cachePath);
|
|
146714
|
+
await fs22.mkdir(dir, { recursive: true });
|
|
146323
146715
|
const data = {
|
|
146324
146716
|
timestamp: Date.now(),
|
|
146325
146717
|
version: "1.0.0",
|
|
146326
146718
|
models: Object.fromEntries(models)
|
|
146327
146719
|
};
|
|
146328
|
-
await
|
|
146720
|
+
await fs22.writeFile(cachePath, JSON.stringify(data), "utf-8");
|
|
146329
146721
|
logger.debug("Saved pricing to local cache", {
|
|
146330
146722
|
models: models.size,
|
|
146331
146723
|
path: cachePath
|
|
146332
146724
|
});
|
|
146333
146725
|
} catch (error51) {
|
|
146334
|
-
logger.warn("
|
|
146335
|
-
|
|
146726
|
+
logger.warn("ModelsDevClient: failed to save local pricing cache", {
|
|
146727
|
+
path: cachePath,
|
|
146728
|
+
error: error51
|
|
146336
146729
|
});
|
|
146337
146730
|
}
|
|
146338
146731
|
}
|
|
@@ -146554,7 +146947,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
146554
146947
|
return value;
|
|
146555
146948
|
}
|
|
146556
146949
|
}
|
|
146557
|
-
logger.warn(
|
|
146950
|
+
logger.warn("ModelsDevClient: model pricing not found", { modelId });
|
|
146558
146951
|
return null;
|
|
146559
146952
|
}
|
|
146560
146953
|
async searchModels(query) {
|
|
@@ -146654,12 +147047,13 @@ var init_models_dev_client = __esm(() => {
|
|
|
146654
147047
|
const cachePath = this.getLocalCachePath();
|
|
146655
147048
|
try {
|
|
146656
147049
|
if (existsSync4(cachePath)) {
|
|
146657
|
-
await
|
|
147050
|
+
await fs22.unlink(cachePath);
|
|
146658
147051
|
logger.debug("Local pricing cache file deleted");
|
|
146659
147052
|
}
|
|
146660
147053
|
} catch (error51) {
|
|
146661
|
-
logger.warn("
|
|
146662
|
-
|
|
147054
|
+
logger.warn("ModelsDevClient: failed to delete local pricing cache", {
|
|
147055
|
+
path: cachePath,
|
|
147056
|
+
error: error51
|
|
146663
147057
|
});
|
|
146664
147058
|
}
|
|
146665
147059
|
}
|
|
@@ -147315,9 +147709,10 @@ class SearchSessionHook {
|
|
|
147315
147709
|
});
|
|
147316
147710
|
} catch (err) {
|
|
147317
147711
|
logger.warn("SearchSessionHook: store failed (best-effort)", {
|
|
147318
|
-
error: err.message,
|
|
147319
147712
|
projectId,
|
|
147320
|
-
|
|
147713
|
+
sessionId,
|
|
147714
|
+
query: query.slice(0, 60),
|
|
147715
|
+
error: err
|
|
147321
147716
|
});
|
|
147322
147717
|
}
|
|
147323
147718
|
}
|
|
@@ -147393,8 +147788,10 @@ class CoRetrievalHook {
|
|
|
147393
147788
|
peers = await this.findPeers(memoryId, projectId, sessionId);
|
|
147394
147789
|
} catch (err) {
|
|
147395
147790
|
logger.warn("CoRetrievalHook: peer lookup failed", {
|
|
147396
|
-
|
|
147397
|
-
|
|
147791
|
+
projectId,
|
|
147792
|
+
sessionId,
|
|
147793
|
+
memoryId,
|
|
147794
|
+
error: err
|
|
147398
147795
|
});
|
|
147399
147796
|
return;
|
|
147400
147797
|
}
|
|
@@ -152209,33 +152606,33 @@ var require_URL = __commonJS((exports, module) => {
|
|
|
152209
152606
|
else
|
|
152210
152607
|
return basepath.substring(0, lastslash + 1) + refpath;
|
|
152211
152608
|
}
|
|
152212
|
-
function remove_dot_segments(
|
|
152213
|
-
if (!
|
|
152214
|
-
return
|
|
152609
|
+
function remove_dot_segments(path36) {
|
|
152610
|
+
if (!path36)
|
|
152611
|
+
return path36;
|
|
152215
152612
|
var output = "";
|
|
152216
|
-
while (
|
|
152217
|
-
if (
|
|
152218
|
-
|
|
152613
|
+
while (path36.length > 0) {
|
|
152614
|
+
if (path36 === "." || path36 === "..") {
|
|
152615
|
+
path36 = "";
|
|
152219
152616
|
break;
|
|
152220
152617
|
}
|
|
152221
|
-
var twochars =
|
|
152222
|
-
var threechars =
|
|
152223
|
-
var fourchars =
|
|
152618
|
+
var twochars = path36.substring(0, 2);
|
|
152619
|
+
var threechars = path36.substring(0, 3);
|
|
152620
|
+
var fourchars = path36.substring(0, 4);
|
|
152224
152621
|
if (threechars === "../") {
|
|
152225
|
-
|
|
152622
|
+
path36 = path36.substring(3);
|
|
152226
152623
|
} else if (twochars === "./") {
|
|
152227
|
-
|
|
152624
|
+
path36 = path36.substring(2);
|
|
152228
152625
|
} else if (threechars === "/./") {
|
|
152229
|
-
|
|
152230
|
-
} else if (twochars === "/." &&
|
|
152231
|
-
|
|
152232
|
-
} else if (fourchars === "/../" || threechars === "/.." &&
|
|
152233
|
-
|
|
152626
|
+
path36 = "/" + path36.substring(3);
|
|
152627
|
+
} else if (twochars === "/." && path36.length === 2) {
|
|
152628
|
+
path36 = "/";
|
|
152629
|
+
} else if (fourchars === "/../" || threechars === "/.." && path36.length === 3) {
|
|
152630
|
+
path36 = "/" + path36.substring(4);
|
|
152234
152631
|
output = output.replace(/\/?[^\/]*$/, "");
|
|
152235
152632
|
} else {
|
|
152236
|
-
var segment =
|
|
152633
|
+
var segment = path36.match(/(\/?([^\/]*))/)[0];
|
|
152237
152634
|
output += segment;
|
|
152238
|
-
|
|
152635
|
+
path36 = path36.substring(segment.length);
|
|
152239
152636
|
}
|
|
152240
152637
|
}
|
|
152241
152638
|
return output;
|
|
@@ -164305,21 +164702,21 @@ function jsonToKeyPathChunks(value, label = "$") {
|
|
|
164305
164702
|
walk(value, label, out);
|
|
164306
164703
|
return out;
|
|
164307
164704
|
}
|
|
164308
|
-
function walk(val,
|
|
164705
|
+
function walk(val, path36, out) {
|
|
164309
164706
|
if (val === null || val === undefined)
|
|
164310
164707
|
return;
|
|
164311
164708
|
if (Array.isArray(val)) {
|
|
164312
164709
|
if (val.length === 0) {
|
|
164313
|
-
out.push({ path:
|
|
164710
|
+
out.push({ path: path36, content: `**${path36}** = _[]_` });
|
|
164314
164711
|
return;
|
|
164315
164712
|
}
|
|
164316
164713
|
if (val.every((v) => v !== null && typeof v === "object")) {
|
|
164317
|
-
val.forEach((v, i) => walk(v, `${
|
|
164714
|
+
val.forEach((v, i) => walk(v, `${path36}[${i}]`, out));
|
|
164318
164715
|
return;
|
|
164319
164716
|
}
|
|
164320
164717
|
const items = val.map((v) => `- \`${String(v)}\``).join(`
|
|
164321
164718
|
`);
|
|
164322
|
-
out.push({ path:
|
|
164719
|
+
out.push({ path: path36, content: `**${path36}**
|
|
164323
164720
|
|
|
164324
164721
|
${items}` });
|
|
164325
164722
|
return;
|
|
@@ -164327,16 +164724,16 @@ ${items}` });
|
|
|
164327
164724
|
if (typeof val === "object") {
|
|
164328
164725
|
const entries = Object.entries(val);
|
|
164329
164726
|
if (entries.length === 0) {
|
|
164330
|
-
out.push({ path:
|
|
164727
|
+
out.push({ path: path36, content: `**${path36}** = _{}_` });
|
|
164331
164728
|
return;
|
|
164332
164729
|
}
|
|
164333
164730
|
for (const [k, v] of entries) {
|
|
164334
164731
|
const safeKey = /^[A-Za-z_$][\w$]*$/.test(k) ? k : JSON.stringify(k);
|
|
164335
|
-
walk(v, `${
|
|
164732
|
+
walk(v, `${path36}.${safeKey}`, out);
|
|
164336
164733
|
}
|
|
164337
164734
|
return;
|
|
164338
164735
|
}
|
|
164339
|
-
out.push({ path:
|
|
164736
|
+
out.push({ path: path36, content: `**${path36}** = \`${String(val)}\`` });
|
|
164340
164737
|
}
|
|
164341
164738
|
var gfm, STRIP_SELECTORS, tdCache = null;
|
|
164342
164739
|
var init_html_to_md = __esm(() => {
|
|
@@ -164440,6 +164837,7 @@ async function fetchAndConvertOne(url2, deps, opts = {}) {
|
|
|
164440
164837
|
} catch (err) {
|
|
164441
164838
|
const msg = err instanceof Error ? err.message : String(err);
|
|
164442
164839
|
logger.error("fetch_and_index indexChunk failed", err, {
|
|
164840
|
+
projectId,
|
|
164443
164841
|
url: url2,
|
|
164444
164842
|
chunkId: chunk.id
|
|
164445
164843
|
});
|
|
@@ -164630,6 +165028,7 @@ class WebController {
|
|
|
164630
165028
|
return s.value;
|
|
164631
165029
|
const msg = s.reason instanceof Error ? s.reason.message : String(s.reason);
|
|
164632
165030
|
logger.error("fetch_and_index job rejected", s.reason, {
|
|
165031
|
+
projectId,
|
|
164633
165032
|
url: batch[i].url
|
|
164634
165033
|
});
|
|
164635
165034
|
return { kind: "error", url: batch[i].url, error: msg };
|
|
@@ -164818,7 +165217,7 @@ class OperationLogRepositoryPg {
|
|
|
164818
165217
|
op: input.op,
|
|
164819
165218
|
projectId,
|
|
164820
165219
|
result: input.result,
|
|
164821
|
-
error: err
|
|
165220
|
+
error: err
|
|
164822
165221
|
});
|
|
164823
165222
|
}
|
|
164824
165223
|
}
|
|
@@ -165031,9 +165430,11 @@ class HookService {
|
|
|
165031
165430
|
});
|
|
165032
165431
|
this.bridge.maybeRun(obs.projectId);
|
|
165033
165432
|
} catch (e) {
|
|
165034
|
-
logger.warn("observation persist failed", {
|
|
165433
|
+
logger.warn("HookService: observation persist failed", {
|
|
165035
165434
|
id: obs.id,
|
|
165036
|
-
|
|
165435
|
+
projectId: obs.projectId,
|
|
165436
|
+
sessionId: obs.sessionId,
|
|
165437
|
+
error: e
|
|
165037
165438
|
});
|
|
165038
165439
|
}
|
|
165039
165440
|
});
|
|
@@ -165099,8 +165500,8 @@ var init_hook_service = __esm(() => {
|
|
|
165099
165500
|
|
|
165100
165501
|
// ../../packages/core/dist/services/bootstrap/bootstrap-service.js
|
|
165101
165502
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
165102
|
-
import
|
|
165103
|
-
import
|
|
165503
|
+
import fs23 from "fs";
|
|
165504
|
+
import path36 from "path";
|
|
165104
165505
|
import { spawn as spawn2 } from "child_process";
|
|
165105
165506
|
function readBootstrapConfig() {
|
|
165106
165507
|
try {
|
|
@@ -165159,7 +165560,7 @@ class BootstrapService {
|
|
|
165159
165560
|
} catch (e) {
|
|
165160
165561
|
logger.warn("bootstrap: marker check threw (continuing)", {
|
|
165161
165562
|
projectId,
|
|
165162
|
-
error: e
|
|
165563
|
+
error: e
|
|
165163
165564
|
});
|
|
165164
165565
|
}
|
|
165165
165566
|
} else if (!cfg.refreshEnabled) {
|
|
@@ -165207,7 +165608,7 @@ class BootstrapService {
|
|
|
165207
165608
|
} catch (e) {
|
|
165208
165609
|
logger.warn("bootstrap: storeSeeds failed (silent)", {
|
|
165209
165610
|
projectId,
|
|
165210
|
-
error: e
|
|
165611
|
+
error: e
|
|
165211
165612
|
});
|
|
165212
165613
|
return { ...noopResult("insert-failed"), signalCount, source };
|
|
165213
165614
|
}
|
|
@@ -165260,9 +165661,9 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
165260
165661
|
}
|
|
165261
165662
|
try {
|
|
165262
165663
|
for (const name26 of README_CANDIDATES) {
|
|
165263
|
-
const p =
|
|
165264
|
-
if (
|
|
165265
|
-
const buf =
|
|
165664
|
+
const p = path36.join(projectRoot, name26);
|
|
165665
|
+
if (fs23.existsSync(p) && fs23.statSync(p).isFile()) {
|
|
165666
|
+
const buf = fs23.readFileSync(p);
|
|
165266
165667
|
signals.readme = buf.slice(0, MAX_README_BYTES).toString("utf8");
|
|
165267
165668
|
break;
|
|
165268
165669
|
}
|
|
@@ -165271,14 +165672,14 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
165271
165672
|
logger.debug("bootstrap scan: README read failed", { error: e.message });
|
|
165272
165673
|
}
|
|
165273
165674
|
try {
|
|
165274
|
-
const docsDir =
|
|
165275
|
-
if (
|
|
165675
|
+
const docsDir = path36.join(projectRoot, "docs");
|
|
165676
|
+
if (fs23.existsSync(docsDir) && fs23.statSync(docsDir).isDirectory()) {
|
|
165276
165677
|
const entries = walkMarkdown(docsDir).slice(0, MAX_DOCS);
|
|
165277
165678
|
for (const rel of entries) {
|
|
165278
165679
|
try {
|
|
165279
|
-
const buf =
|
|
165680
|
+
const buf = fs23.readFileSync(rel);
|
|
165280
165681
|
signals.docs.push({
|
|
165281
|
-
path:
|
|
165682
|
+
path: path36.relative(projectRoot, rel),
|
|
165282
165683
|
snippet: buf.slice(0, MAX_DOC_BYTES).toString("utf8")
|
|
165283
165684
|
});
|
|
165284
165685
|
} catch {}
|
|
@@ -165289,10 +165690,10 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
165289
165690
|
}
|
|
165290
165691
|
try {
|
|
165291
165692
|
for (const name26 of MANIFEST_FILES) {
|
|
165292
|
-
const p =
|
|
165293
|
-
if (!
|
|
165693
|
+
const p = path36.join(projectRoot, name26);
|
|
165694
|
+
if (!fs23.existsSync(p) || !fs23.statSync(p).isFile())
|
|
165294
165695
|
continue;
|
|
165295
|
-
const raw2 =
|
|
165696
|
+
const raw2 = fs23.readFileSync(p).slice(0, MAX_MANIFEST_BYTES).toString("utf8");
|
|
165296
165697
|
const kind = name26;
|
|
165297
165698
|
if (name26 === "package.json") {
|
|
165298
165699
|
try {
|
|
@@ -165332,12 +165733,12 @@ function walkMarkdown(dir) {
|
|
|
165332
165733
|
const cur = stack.pop();
|
|
165333
165734
|
let entries;
|
|
165334
165735
|
try {
|
|
165335
|
-
entries =
|
|
165736
|
+
entries = fs23.readdirSync(cur, { withFileTypes: true });
|
|
165336
165737
|
} catch {
|
|
165337
165738
|
continue;
|
|
165338
165739
|
}
|
|
165339
165740
|
for (const e of entries) {
|
|
165340
|
-
const full =
|
|
165741
|
+
const full = path36.join(cur, e.name);
|
|
165341
165742
|
if (e.isDirectory()) {
|
|
165342
165743
|
if (e.name === "node_modules" || e.name.startsWith("."))
|
|
165343
165744
|
continue;
|
|
@@ -165360,7 +165761,7 @@ async function summarizeWithLlm(signals, surface, maxSeedMemories) {
|
|
|
165360
165761
|
return { ok: false, reason: "llm disabled" };
|
|
165361
165762
|
const prompt = buildSummarizePrompt(signals, maxSeedMemories);
|
|
165362
165763
|
try {
|
|
165363
|
-
const res = await surface.object(prompt, SeedMemoriesSchema, { modelRole: "code" });
|
|
165764
|
+
const res = await surface.object(prompt, SeedMemoriesSchema, { label: "bootstrap-seed", modelRole: "code" });
|
|
165364
165765
|
if (!res.ok || !res.value) {
|
|
165365
165766
|
return { ok: false, reason: res.error || "llm returned no value" };
|
|
165366
165767
|
}
|
|
@@ -166043,7 +166444,7 @@ function formatMemoryContent(record3) {
|
|
|
166043
166444
|
}
|
|
166044
166445
|
async function polishSummary(surface, input) {
|
|
166045
166446
|
const prompt = buildPolishPrompt(input);
|
|
166046
|
-
const res = await surface.object(prompt, HandoffSummarySchema);
|
|
166447
|
+
const res = await surface.object(prompt, HandoffSummarySchema, { label: "handoff-summary" });
|
|
166047
166448
|
if (!res.ok || !res.value || !res.value.summary)
|
|
166048
166449
|
return null;
|
|
166049
166450
|
return res.value.summary;
|
|
@@ -168867,7 +169268,7 @@ class StdioServerTransport {
|
|
|
168867
169268
|
}
|
|
168868
169269
|
|
|
168869
169270
|
// src/index.ts
|
|
168870
|
-
import
|
|
169271
|
+
import fs26 from "fs/promises";
|
|
168871
169272
|
|
|
168872
169273
|
// src/api-client.ts
|
|
168873
169274
|
init_config();
|
|
@@ -168977,8 +169378,8 @@ init_dist();
|
|
|
168977
169378
|
init_dist();
|
|
168978
169379
|
init_dist15();
|
|
168979
169380
|
init_dist();
|
|
168980
|
-
import
|
|
168981
|
-
import
|
|
169381
|
+
import fs24 from "fs/promises";
|
|
169382
|
+
import path37 from "path";
|
|
168982
169383
|
var _indexProjectTool = null;
|
|
168983
169384
|
function indexProjectTool() {
|
|
168984
169385
|
if (!_indexProjectTool)
|
|
@@ -169281,8 +169682,8 @@ class EmbeddedApiClient {
|
|
|
169281
169682
|
} else {
|
|
169282
169683
|
end = start + 20;
|
|
169283
169684
|
}
|
|
169284
|
-
const absolutePath =
|
|
169285
|
-
const content = await
|
|
169685
|
+
const absolutePath = path37.join(workspace.project_path, file2);
|
|
169686
|
+
const content = await fs24.readFile(absolutePath, "utf-8");
|
|
169286
169687
|
const lines = content.split(/\r?\n/);
|
|
169287
169688
|
const slice = lines.slice(start - 1, Math.min(lines.length, end));
|
|
169288
169689
|
const formatted = slice.map((text3, idx) => ({ lineNumber: start + idx, content: text3 }));
|
|
@@ -169537,22 +169938,22 @@ class EmbeddedApiClient {
|
|
|
169537
169938
|
async uploadAndIndex(params) {
|
|
169538
169939
|
const rawBase = params.projectId || params.projectPath.replace(/\\/g, "/").split("/").filter(Boolean).pop() || "default";
|
|
169539
169940
|
const finalProjectId = rawBase.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 128);
|
|
169540
|
-
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR ||
|
|
169541
|
-
const stagingDir =
|
|
169542
|
-
await
|
|
169543
|
-
await
|
|
169941
|
+
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR || path37.join(getGlobalDataDir(), "uploads");
|
|
169942
|
+
const stagingDir = path37.resolve(uploadRoot, finalProjectId);
|
|
169943
|
+
await fs24.rm(stagingDir, { recursive: true, force: true });
|
|
169944
|
+
await fs24.mkdir(stagingDir, { recursive: true });
|
|
169544
169945
|
const WRITE_BATCH = 20;
|
|
169545
169946
|
for (let i = 0;i < params.files.length; i += WRITE_BATCH) {
|
|
169546
169947
|
await Promise.all(params.files.slice(i, i + WRITE_BATCH).map(async (file2) => {
|
|
169547
|
-
if (
|
|
169948
|
+
if (path37.isAbsolute(file2.relativePath) || file2.relativePath.includes("..")) {
|
|
169548
169949
|
throw new Error(`Invalid file path: ${file2.relativePath}`);
|
|
169549
169950
|
}
|
|
169550
|
-
const dest =
|
|
169551
|
-
if (!dest.startsWith(stagingDir +
|
|
169951
|
+
const dest = path37.resolve(stagingDir, file2.relativePath.replace(/\//g, path37.sep));
|
|
169952
|
+
if (!dest.startsWith(stagingDir + path37.sep)) {
|
|
169552
169953
|
throw new Error(`Path escapes staging directory: ${file2.relativePath}`);
|
|
169553
169954
|
}
|
|
169554
|
-
await
|
|
169555
|
-
await
|
|
169955
|
+
await fs24.mkdir(path37.dirname(dest), { recursive: true });
|
|
169956
|
+
await fs24.writeFile(dest, file2.content, "utf-8");
|
|
169556
169957
|
}));
|
|
169557
169958
|
}
|
|
169558
169959
|
return await indexProjectTool().handle({
|
|
@@ -169598,7 +169999,10 @@ class EmbeddedApiClient {
|
|
|
169598
169999
|
const rows = filtered.slice(offset, offset + limit);
|
|
169599
170000
|
return { success: true, data: { memories: rows, total, limit, offset } };
|
|
169600
170001
|
} catch (error51) {
|
|
169601
|
-
logger.error("Failed to list memories (embedded)", error51
|
|
170002
|
+
logger.error("Failed to list memories (embedded)", error51, {
|
|
170003
|
+
projectId: body.projectId,
|
|
170004
|
+
sessionId: body.sessionId
|
|
170005
|
+
});
|
|
169602
170006
|
return { success: false, error: `Failed to list memories: ${error51.message}` };
|
|
169603
170007
|
}
|
|
169604
170008
|
}
|
|
@@ -170049,8 +170453,8 @@ class EmbeddedApiClient {
|
|
|
170049
170453
|
|
|
170050
170454
|
// src/file-collector.ts
|
|
170051
170455
|
init_config();
|
|
170052
|
-
import
|
|
170053
|
-
import
|
|
170456
|
+
import fs25 from "fs/promises";
|
|
170457
|
+
import path38 from "path";
|
|
170054
170458
|
var SKIP_DIRS = new Set([
|
|
170055
170459
|
"node_modules",
|
|
170056
170460
|
".git",
|
|
@@ -170091,7 +170495,7 @@ async function walk2(root2, dir, files, state, allowed) {
|
|
|
170091
170495
|
return;
|
|
170092
170496
|
let entries;
|
|
170093
170497
|
try {
|
|
170094
|
-
entries = await
|
|
170498
|
+
entries = await fs25.readdir(dir, { withFileTypes: true });
|
|
170095
170499
|
} catch {
|
|
170096
170500
|
return;
|
|
170097
170501
|
}
|
|
@@ -170100,22 +170504,22 @@ async function walk2(root2, dir, files, state, allowed) {
|
|
|
170100
170504
|
break;
|
|
170101
170505
|
if (entry2.isDirectory()) {
|
|
170102
170506
|
if (!SKIP_DIRS.has(entry2.name) && !entry2.name.startsWith(".")) {
|
|
170103
|
-
await walk2(root2,
|
|
170507
|
+
await walk2(root2, path38.join(dir, entry2.name), files, state, allowed);
|
|
170104
170508
|
}
|
|
170105
170509
|
} else if (entry2.isFile()) {
|
|
170106
|
-
const ext2 =
|
|
170510
|
+
const ext2 = path38.extname(entry2.name).toLowerCase();
|
|
170107
170511
|
if (!allowed.has(ext2))
|
|
170108
170512
|
continue;
|
|
170109
|
-
const fullPath =
|
|
170513
|
+
const fullPath = path38.join(dir, entry2.name);
|
|
170110
170514
|
try {
|
|
170111
|
-
const stat = await
|
|
170515
|
+
const stat = await fs25.stat(fullPath);
|
|
170112
170516
|
if (stat.size > MAX_FILE_BYTES)
|
|
170113
170517
|
continue;
|
|
170114
170518
|
if (state.totalBytes + stat.size > MAX_TOTAL_BYTES)
|
|
170115
170519
|
continue;
|
|
170116
|
-
const content = await
|
|
170520
|
+
const content = await fs25.readFile(fullPath, "utf-8");
|
|
170117
170521
|
state.totalBytes += stat.size;
|
|
170118
|
-
const relativePath =
|
|
170522
|
+
const relativePath = path38.relative(root2, fullPath).split(path38.sep).join("/");
|
|
170119
170523
|
files.push({ relativePath, content });
|
|
170120
170524
|
} catch {}
|
|
170121
170525
|
}
|
|
@@ -171353,7 +171757,7 @@ var PROJECT_TOOL_DEFINITIONS = [
|
|
|
171353
171757
|
},
|
|
171354
171758
|
{
|
|
171355
171759
|
name: "profile_list",
|
|
171356
|
-
description: "List shipped model profiles and, per detected host, the currently active profile (from recorded state; " + "'balanced' shown when unrecorded) and bundle version. Offline \u2014 reads on-disk variant directories only, " + "never the registry.",
|
|
171760
|
+
description: "List shipped model profiles and, per detected host, the currently active profile (from recorded state; " + "'balanced' shown when unrecorded) and bundle version. Offline \u2014 reads on-disk variant directories only, " + "never the registry. The claude row also carries agent-runtime-drift fields: liveRoot + sourceVersion " + "(the live tree the host actually loads, beside the recorded bundleVersion) and envOverride (a host env " + "var such as CLAUDE_CODE_SUBAGENT_MODEL that overrides every per-agent model at runtime).",
|
|
171357
171761
|
apiEndpoint: "/api/v1/profiles",
|
|
171358
171762
|
apiMethod: "GET",
|
|
171359
171763
|
inputSchema: {
|
|
@@ -172098,7 +172502,7 @@ class McpProxyServer {
|
|
|
172098
172502
|
return textContent(JSON.stringify({ success: false, error: "projectPath is required" }));
|
|
172099
172503
|
}
|
|
172100
172504
|
try {
|
|
172101
|
-
if (!(await
|
|
172505
|
+
if (!(await fs26.stat(projectPath2)).isDirectory()) {
|
|
172102
172506
|
return textContent(JSON.stringify({ success: false, error: `${projectPath2} is not a directory` }));
|
|
172103
172507
|
}
|
|
172104
172508
|
} catch {
|