@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/config-cli.js
CHANGED
|
@@ -997,7 +997,7 @@ function getConfigForEnv() {
|
|
|
997
997
|
} else {
|
|
998
998
|
console.error(`[getConfigForEnv] embedding.provider "${provider}" has no env-projection branch \u2014 no embedding env vars were set`);
|
|
999
999
|
}
|
|
1000
|
-
env.
|
|
1000
|
+
env.MASSA_AI_LOG_LEVEL = config.logging.level;
|
|
1001
1001
|
env.ENABLE_METRICS = String(config.logging.enableMetrics);
|
|
1002
1002
|
return env;
|
|
1003
1003
|
}
|
|
@@ -1571,7 +1571,7 @@ var init_config = __esm(() => {
|
|
|
1571
1571
|
corsOrigins: envList("MASSA_AI_API_CORS_ORIGINS", fileConfig.security?.corsOrigins ?? [])
|
|
1572
1572
|
},
|
|
1573
1573
|
logging: {
|
|
1574
|
-
level: process.env.
|
|
1574
|
+
level: process.env.MASSA_AI_LOG_LEVEL || fileConfig.logging?.level || "info",
|
|
1575
1575
|
enableMetrics: process.env.ENABLE_METRICS === "true" || process.env.ENABLE_METRICS === undefined && !!fileConfig.logging?.enableMetrics,
|
|
1576
1576
|
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file || path4.join(resolvedDataDir, "logs", "massa-ai.log"),
|
|
1577
1577
|
enableFileSink: envBool("MASSA_AI_LOG_ENABLE_FILE_SINK", fileConfig.logging?.enableFileSink ?? true),
|
|
@@ -1904,6 +1904,32 @@ var init_log_buffer = __esm(() => {
|
|
|
1904
1904
|
});
|
|
1905
1905
|
|
|
1906
1906
|
// ../../packages/shared/dist/utils/logger.js
|
|
1907
|
+
function formatAgo(ms) {
|
|
1908
|
+
const totalSeconds = Math.floor(ms / 1000);
|
|
1909
|
+
if (totalSeconds < 60)
|
|
1910
|
+
return `${totalSeconds}s`;
|
|
1911
|
+
return `${Math.floor(totalSeconds / 60)}m`;
|
|
1912
|
+
}
|
|
1913
|
+
function capErrorText(value) {
|
|
1914
|
+
if (value.length <= MAX_ERROR_TEXT_CHARS)
|
|
1915
|
+
return value;
|
|
1916
|
+
const truncatedChars = value.length - MAX_ERROR_TEXT_CHARS;
|
|
1917
|
+
return `${value.slice(0, MAX_ERROR_TEXT_CHARS)}\u2026(truncated ${truncatedChars} chars)`;
|
|
1918
|
+
}
|
|
1919
|
+
function pickErrorFields(err, includeStack) {
|
|
1920
|
+
const out = { name: err.name, message: capErrorText(err.message) };
|
|
1921
|
+
if (includeStack)
|
|
1922
|
+
out.stack = err.stack;
|
|
1923
|
+
const code = err.code;
|
|
1924
|
+
if (code !== undefined)
|
|
1925
|
+
out.code = code;
|
|
1926
|
+
const cause = err.cause;
|
|
1927
|
+
if (cause !== undefined) {
|
|
1928
|
+
out.cause = capErrorText(cause instanceof Error ? cause.message : String(cause));
|
|
1929
|
+
}
|
|
1930
|
+
return out;
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1907
1933
|
class Logger {
|
|
1908
1934
|
_level;
|
|
1909
1935
|
_enableMetrics;
|
|
@@ -1912,6 +1938,7 @@ class Logger {
|
|
|
1912
1938
|
_maxFileSizeBytes;
|
|
1913
1939
|
_maxFiles;
|
|
1914
1940
|
_initialized = false;
|
|
1941
|
+
repeats = new Map;
|
|
1915
1942
|
constructor() {}
|
|
1916
1943
|
ensureInitialized() {
|
|
1917
1944
|
if (!this._initialized) {
|
|
@@ -1972,13 +1999,70 @@ class Logger {
|
|
|
1972
1999
|
shouldLog(level) {
|
|
1973
2000
|
return level >= this.level;
|
|
1974
2001
|
}
|
|
2002
|
+
serializeMetaErrors(meta) {
|
|
2003
|
+
if (!meta)
|
|
2004
|
+
return meta;
|
|
2005
|
+
let out;
|
|
2006
|
+
for (const [key, value] of Object.entries(meta)) {
|
|
2007
|
+
if (value instanceof Error) {
|
|
2008
|
+
if (!out)
|
|
2009
|
+
out = { ...meta };
|
|
2010
|
+
out[key] = pickErrorFields(value, false);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
return out ?? meta;
|
|
2014
|
+
}
|
|
2015
|
+
applyRepeatAccounting(level, message, meta) {
|
|
2016
|
+
if (level !== LogLevel.WARN && level !== LogLevel.ERROR)
|
|
2017
|
+
return meta;
|
|
2018
|
+
const label = typeof meta?.label === "string" ? meta.label : "";
|
|
2019
|
+
const key = `${level}|${message}|${label}`;
|
|
2020
|
+
const now = Date.now();
|
|
2021
|
+
const existing = this.repeats.get(key);
|
|
2022
|
+
if (!existing || now - existing.firstSeenAt > REPEAT_WINDOW_MS) {
|
|
2023
|
+
if (this.repeats.size >= MAX_REPEAT_KEYS)
|
|
2024
|
+
this.repeats.clear();
|
|
2025
|
+
this.repeats.set(key, { firstSeenAt: now, count: 1 });
|
|
2026
|
+
return meta;
|
|
2027
|
+
}
|
|
2028
|
+
existing.count += 1;
|
|
2029
|
+
return {
|
|
2030
|
+
...meta,
|
|
2031
|
+
occurrences: existing.count,
|
|
2032
|
+
firstSeenAgo: formatAgo(now - existing.firstSeenAt)
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
_resetRepeatsForTesting() {
|
|
2036
|
+
this.repeats.clear();
|
|
2037
|
+
}
|
|
2038
|
+
safeStringifyMeta(meta) {
|
|
2039
|
+
const seen = new WeakSet;
|
|
2040
|
+
try {
|
|
2041
|
+
return JSON.stringify(meta, (_key, value) => {
|
|
2042
|
+
if (typeof value === "bigint")
|
|
2043
|
+
return value.toString();
|
|
2044
|
+
if (typeof value === "object" && value !== null) {
|
|
2045
|
+
if (seen.has(value))
|
|
2046
|
+
return "[Circular]";
|
|
2047
|
+
seen.add(value);
|
|
2048
|
+
}
|
|
2049
|
+
return value;
|
|
2050
|
+
});
|
|
2051
|
+
} catch (err) {
|
|
2052
|
+
return JSON.stringify({
|
|
2053
|
+
metaUnserializable: err instanceof Error ? err.message : String(err)
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
1975
2057
|
formatMessage(level, message, meta, timestamp = new Date().toISOString()) {
|
|
1976
|
-
const metaStr = meta ? ` ${
|
|
2058
|
+
const metaStr = meta ? ` ${this.safeStringifyMeta(meta)}` : "";
|
|
1977
2059
|
return `[${timestamp}] [${level}] ${message}${metaStr}`;
|
|
1978
2060
|
}
|
|
1979
2061
|
emit(level, message, meta) {
|
|
2062
|
+
const serializedMeta = this.serializeMetaErrors(meta);
|
|
2063
|
+
const finalMeta = this.applyRepeatAccounting(level, message, serializedMeta);
|
|
1980
2064
|
const ts = new Date().toISOString();
|
|
1981
|
-
const line = this.formatMessage(LOG_LEVEL_LABELS[level], message,
|
|
2065
|
+
const line = this.formatMessage(LOG_LEVEL_LABELS[level], message, finalMeta, ts);
|
|
1982
2066
|
console.error(line);
|
|
1983
2067
|
if (this.enableFileSink) {
|
|
1984
2068
|
const filePath = this.logFilePath;
|
|
@@ -1990,7 +2074,7 @@ class Logger {
|
|
|
1990
2074
|
ts,
|
|
1991
2075
|
level: LOG_LEVEL_BUFFER_TAGS[level],
|
|
1992
2076
|
message,
|
|
1993
|
-
...
|
|
2077
|
+
...finalMeta ? { meta: finalMeta } : {}
|
|
1994
2078
|
});
|
|
1995
2079
|
}
|
|
1996
2080
|
debug(message, meta) {
|
|
@@ -2012,11 +2096,7 @@ class Logger {
|
|
|
2012
2096
|
if (this.shouldLog(LogLevel.ERROR)) {
|
|
2013
2097
|
const errorMeta = error ? {
|
|
2014
2098
|
...meta,
|
|
2015
|
-
error: {
|
|
2016
|
-
name: error.name,
|
|
2017
|
-
message: error.message,
|
|
2018
|
-
stack: error.stack
|
|
2019
|
-
}
|
|
2099
|
+
error: error instanceof Error ? pickErrorFields(error, true) : { message: String(error) }
|
|
2020
2100
|
} : meta;
|
|
2021
2101
|
this.emit(LogLevel.ERROR, message, errorMeta);
|
|
2022
2102
|
}
|
|
@@ -2047,7 +2127,7 @@ class Logger {
|
|
|
2047
2127
|
return childLogger;
|
|
2048
2128
|
}
|
|
2049
2129
|
}
|
|
2050
|
-
var LogLevel, LOG_LEVEL_LABELS, LOG_LEVEL_BUFFER_TAGS, logger;
|
|
2130
|
+
var LogLevel, LOG_LEVEL_LABELS, LOG_LEVEL_BUFFER_TAGS, REPEAT_WINDOW_MS, MAX_REPEAT_KEYS = 500, MAX_ERROR_TEXT_CHARS = 300, logger;
|
|
2051
2131
|
var init_logger = __esm(() => {
|
|
2052
2132
|
init_config();
|
|
2053
2133
|
init_log_sink();
|
|
@@ -2070,6 +2150,7 @@ var init_logger = __esm(() => {
|
|
|
2070
2150
|
[LogLevel.WARN]: "warn",
|
|
2071
2151
|
[LogLevel.ERROR]: "error"
|
|
2072
2152
|
};
|
|
2153
|
+
REPEAT_WINDOW_MS = 15 * 60 * 1000;
|
|
2073
2154
|
logger = new Logger;
|
|
2074
2155
|
});
|
|
2075
2156
|
|
|
@@ -2125,8 +2206,9 @@ var init_metrics = __esm(() => {
|
|
|
2125
2206
|
}
|
|
2126
2207
|
} catch (error) {
|
|
2127
2208
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
2128
|
-
logger.warn(
|
|
2129
|
-
|
|
2209
|
+
logger.warn("MetricsCollector: failed to fetch pricing", {
|
|
2210
|
+
modelId,
|
|
2211
|
+
error: err
|
|
2130
2212
|
});
|
|
2131
2213
|
}
|
|
2132
2214
|
const fallback = FALLBACK_PRICING[modelId];
|
|
@@ -2134,7 +2216,7 @@ var init_metrics = __esm(() => {
|
|
|
2134
2216
|
logger.debug(`Using fallback pricing for ${modelId}`);
|
|
2135
2217
|
return fallback;
|
|
2136
2218
|
}
|
|
2137
|
-
logger.warn(
|
|
2219
|
+
logger.warn("MetricsCollector: unknown model, using gpt-4 pricing as default", { modelId });
|
|
2138
2220
|
return FALLBACK_PRICING["gpt-4"];
|
|
2139
2221
|
}
|
|
2140
2222
|
static calculateCost(inputTokens, outputTokens, model) {
|
|
@@ -2313,7 +2395,9 @@ class SmartRateLimiter {
|
|
|
2313
2395
|
const hasRequestCapacity = this.requestLimiter.tryConsume(1);
|
|
2314
2396
|
const hasTokenCapacity = this.tokenLimiter.tryConsume(estimatedTokens);
|
|
2315
2397
|
if (!hasRequestCapacity) {
|
|
2316
|
-
logger.warn("Request rate limit exceeded"
|
|
2398
|
+
logger.warn("Request rate limit exceeded", {
|
|
2399
|
+
availableTokens: this.requestLimiter.getAvailableTokens()
|
|
2400
|
+
});
|
|
2317
2401
|
return false;
|
|
2318
2402
|
}
|
|
2319
2403
|
if (!hasTokenCapacity) {
|
|
@@ -2679,12 +2763,13 @@ function selectRecord(records) {
|
|
|
2679
2763
|
}
|
|
2680
2764
|
return best ?? pool[pool.length - 1];
|
|
2681
2765
|
}
|
|
2682
|
-
function
|
|
2766
|
+
function resolveClaudeMarketplaceInstall(opts = {}) {
|
|
2683
2767
|
const targetHome = opts.targetHome ?? os5.homedir();
|
|
2684
2768
|
const pluginKey = opts.pluginKey ?? DEFAULT_PLUGIN_KEY;
|
|
2685
2769
|
const directoryResult = resolveDirectorySourceRoot(targetHome, pluginKey);
|
|
2686
|
-
if (directoryResult !== undefined)
|
|
2687
|
-
return directoryResult;
|
|
2770
|
+
if (directoryResult !== undefined) {
|
|
2771
|
+
return directoryResult === null ? null : { root: directoryResult, route: "directory-source" };
|
|
2772
|
+
}
|
|
2688
2773
|
const registryPath = path9.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
2689
2774
|
let records;
|
|
2690
2775
|
try {
|
|
@@ -2706,15 +2791,213 @@ function resolveClaudeMarketplaceRoot(opts = {}) {
|
|
|
2706
2791
|
} catch {
|
|
2707
2792
|
return null;
|
|
2708
2793
|
}
|
|
2709
|
-
return installPath;
|
|
2794
|
+
return { root: installPath, route: "registry-cache" };
|
|
2795
|
+
}
|
|
2796
|
+
function resolveClaudeMarketplaceRoot(opts = {}) {
|
|
2797
|
+
return resolveClaudeMarketplaceInstall(opts)?.root ?? null;
|
|
2798
|
+
}
|
|
2799
|
+
function readInstalledPluginVersion(opts = {}) {
|
|
2800
|
+
const targetHome = opts.targetHome ?? os5.homedir();
|
|
2801
|
+
const pluginKey = opts.pluginKey ?? DEFAULT_PLUGIN_KEY;
|
|
2802
|
+
const registryPath = path9.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
2803
|
+
let records;
|
|
2804
|
+
try {
|
|
2805
|
+
const parsed = JSON.parse(fs5.readFileSync(registryPath, "utf8"));
|
|
2806
|
+
records = parsed?.plugins?.[pluginKey];
|
|
2807
|
+
} catch {
|
|
2808
|
+
return null;
|
|
2809
|
+
}
|
|
2810
|
+
if (!Array.isArray(records) || records.length === 0)
|
|
2811
|
+
return null;
|
|
2812
|
+
return selectRecord(records)?.version ?? null;
|
|
2710
2813
|
}
|
|
2711
2814
|
var DEFAULT_PLUGIN_KEY = "massa-ai@massa-ai";
|
|
2712
2815
|
var init_claude_marketplace = () => {};
|
|
2713
2816
|
|
|
2714
|
-
// ../../packages/shared/dist/profile-switch/
|
|
2817
|
+
// ../../packages/shared/dist/profile-switch/frontmatter.js
|
|
2818
|
+
function parseFrontmatter(raw2) {
|
|
2819
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/.exec(raw2);
|
|
2820
|
+
if (!match) {
|
|
2821
|
+
throw new Error("charter missing YAML frontmatter (--- ... ---) block");
|
|
2822
|
+
}
|
|
2823
|
+
const yamlText = match[1] ?? "";
|
|
2824
|
+
const body = (match[2] ?? "").replace(/^\r?\n/, "");
|
|
2825
|
+
const frontmatter = parseSimpleYaml(yamlText);
|
|
2826
|
+
return { frontmatter, body };
|
|
2827
|
+
}
|
|
2828
|
+
function parseSimpleYaml(text) {
|
|
2829
|
+
const result = {};
|
|
2830
|
+
const lines = text.split(/\r?\n/);
|
|
2831
|
+
let i = 0;
|
|
2832
|
+
while (i < lines.length) {
|
|
2833
|
+
const line = lines[i] ?? "";
|
|
2834
|
+
if (line.trim() === "" || line.trim().startsWith("#")) {
|
|
2835
|
+
i++;
|
|
2836
|
+
continue;
|
|
2837
|
+
}
|
|
2838
|
+
const m = /^([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/.exec(line);
|
|
2839
|
+
if (!m) {
|
|
2840
|
+
i++;
|
|
2841
|
+
continue;
|
|
2842
|
+
}
|
|
2843
|
+
const key = m[1];
|
|
2844
|
+
const rest = (m[2] ?? "").trim();
|
|
2845
|
+
if (rest !== "") {
|
|
2846
|
+
result[key] = unquoteScalar(rest);
|
|
2847
|
+
i++;
|
|
2848
|
+
continue;
|
|
2849
|
+
}
|
|
2850
|
+
const nested = {};
|
|
2851
|
+
i++;
|
|
2852
|
+
while (i < lines.length) {
|
|
2853
|
+
const nestedLine = lines[i] ?? "";
|
|
2854
|
+
if (/^\s{2,}\S/.test(nestedLine) === false)
|
|
2855
|
+
break;
|
|
2856
|
+
const nm = /^\s{2,}([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/.exec(nestedLine);
|
|
2857
|
+
if (!nm)
|
|
2858
|
+
break;
|
|
2859
|
+
nested[nm[1]] = unquoteScalar((nm[2] ?? "").trim());
|
|
2860
|
+
i++;
|
|
2861
|
+
}
|
|
2862
|
+
result[key] = nested;
|
|
2863
|
+
}
|
|
2864
|
+
return result;
|
|
2865
|
+
}
|
|
2866
|
+
function unquoteScalar(s) {
|
|
2867
|
+
if (s.startsWith('"') && s.endsWith('"') || s.startsWith("'") && s.endsWith("'")) {
|
|
2868
|
+
return s.slice(1, -1);
|
|
2869
|
+
}
|
|
2870
|
+
return s;
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
// ../../packages/shared/dist/profile-switch/doctor.js
|
|
2715
2874
|
import fs6 from "fs";
|
|
2716
|
-
import path10 from "path";
|
|
2717
2875
|
import os6 from "os";
|
|
2876
|
+
import path10 from "path";
|
|
2877
|
+
function readTextFile(filePath) {
|
|
2878
|
+
try {
|
|
2879
|
+
return fs6.readFileSync(filePath, "utf8");
|
|
2880
|
+
} catch {
|
|
2881
|
+
return null;
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
function readJsonFile(filePath) {
|
|
2885
|
+
const raw2 = readTextFile(filePath);
|
|
2886
|
+
if (raw2 === null)
|
|
2887
|
+
return null;
|
|
2888
|
+
try {
|
|
2889
|
+
return JSON.parse(raw2);
|
|
2890
|
+
} catch {
|
|
2891
|
+
return null;
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
function readPluginVersion(pluginRoot) {
|
|
2895
|
+
const manifest = readJsonFile(path10.join(pluginRoot, ".claude-plugin", "plugin.json"));
|
|
2896
|
+
return typeof manifest?.version === "string" ? manifest.version : null;
|
|
2897
|
+
}
|
|
2898
|
+
function detectEnvOverride(env) {
|
|
2899
|
+
for (const name of ENV_OVERRIDE_VARS) {
|
|
2900
|
+
const value = env[name];
|
|
2901
|
+
if (typeof value === "string" && value.trim()) {
|
|
2902
|
+
return { name, value: value.trim() };
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
return null;
|
|
2906
|
+
}
|
|
2907
|
+
function readRoles(liveRoot, activeProfile) {
|
|
2908
|
+
const agentsDir = path10.join(liveRoot, "agents");
|
|
2909
|
+
let entries;
|
|
2910
|
+
try {
|
|
2911
|
+
entries = fs6.readdirSync(agentsDir, { withFileTypes: true });
|
|
2912
|
+
} catch {
|
|
2913
|
+
return [];
|
|
2914
|
+
}
|
|
2915
|
+
const roles = [];
|
|
2916
|
+
for (const entry of entries) {
|
|
2917
|
+
if (!entry.isFile() || !entry.name.startsWith("massa-ai-") || !entry.name.endsWith(".md")) {
|
|
2918
|
+
continue;
|
|
2919
|
+
}
|
|
2920
|
+
const activeRaw = readTextFile(path10.join(agentsDir, entry.name));
|
|
2921
|
+
let model = null;
|
|
2922
|
+
let effort = null;
|
|
2923
|
+
if (activeRaw !== null) {
|
|
2924
|
+
try {
|
|
2925
|
+
const { frontmatter } = parseFrontmatter(activeRaw);
|
|
2926
|
+
model = typeof frontmatter.model === "string" ? frontmatter.model : null;
|
|
2927
|
+
effort = typeof frontmatter.effort === "string" ? frontmatter.effort : null;
|
|
2928
|
+
} catch {}
|
|
2929
|
+
}
|
|
2930
|
+
let staleVariant = false;
|
|
2931
|
+
if (activeProfile && activeRaw !== null) {
|
|
2932
|
+
const variantRaw = readTextFile(path10.join(liveRoot, "agent-profiles", activeProfile, entry.name));
|
|
2933
|
+
if (variantRaw !== null) {
|
|
2934
|
+
staleVariant = variantRaw !== activeRaw;
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
roles.push({ name: entry.name, model, effort, staleVariant });
|
|
2938
|
+
}
|
|
2939
|
+
return roles.sort((a, b) => a.name.localeCompare(b.name));
|
|
2940
|
+
}
|
|
2941
|
+
function runtimeDriftReport(opts = {}) {
|
|
2942
|
+
const targetHome = opts.targetHome ?? os6.homedir();
|
|
2943
|
+
const host = opts.host ?? "claude";
|
|
2944
|
+
const stateFilePath = opts.stateFilePath ?? path10.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
2945
|
+
let state = opts.state ?? null;
|
|
2946
|
+
if (state === null) {
|
|
2947
|
+
try {
|
|
2948
|
+
state = readInstallState(stateFilePath);
|
|
2949
|
+
} catch {
|
|
2950
|
+
state = null;
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
const platform = state?.platforms?.[host];
|
|
2954
|
+
const stateVersion = typeof platform?.plugin?.version === "string" ? platform.plugin.version : null;
|
|
2955
|
+
const activeProfile = platform?.modelProfile?.profile ?? null;
|
|
2956
|
+
if (host !== "claude") {
|
|
2957
|
+
return {
|
|
2958
|
+
host,
|
|
2959
|
+
route: "unresolved",
|
|
2960
|
+
liveRoot: null,
|
|
2961
|
+
sourceVersion: null,
|
|
2962
|
+
stateVersion,
|
|
2963
|
+
pinnedVersion: null,
|
|
2964
|
+
activeProfile,
|
|
2965
|
+
roles: [],
|
|
2966
|
+
envOverride: detectEnvOverride(opts.env ?? process.env),
|
|
2967
|
+
versionDrift: false,
|
|
2968
|
+
profileMaterialized: false
|
|
2969
|
+
};
|
|
2970
|
+
}
|
|
2971
|
+
const install = resolveClaudeMarketplaceInstall({ targetHome, pluginKey: opts.pluginKey });
|
|
2972
|
+
const liveRoot = install?.root ?? null;
|
|
2973
|
+
const sourceVersion = liveRoot === null ? null : readPluginVersion(liveRoot);
|
|
2974
|
+
const pinnedVersion = readInstalledPluginVersion({ targetHome, pluginKey: opts.pluginKey });
|
|
2975
|
+
const roles = liveRoot === null ? [] : readRoles(liveRoot, activeProfile);
|
|
2976
|
+
return {
|
|
2977
|
+
host: "claude",
|
|
2978
|
+
route: install?.route ?? "unresolved",
|
|
2979
|
+
liveRoot,
|
|
2980
|
+
sourceVersion,
|
|
2981
|
+
stateVersion,
|
|
2982
|
+
pinnedVersion,
|
|
2983
|
+
activeProfile,
|
|
2984
|
+
roles,
|
|
2985
|
+
envOverride: detectEnvOverride(opts.env ?? process.env),
|
|
2986
|
+
versionDrift: sourceVersion !== null && stateVersion !== null && sourceVersion !== stateVersion,
|
|
2987
|
+
profileMaterialized: roles.some((role) => role.staleVariant)
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
var ENV_OVERRIDE_VARS;
|
|
2991
|
+
var init_doctor = __esm(() => {
|
|
2992
|
+
init_claude_marketplace();
|
|
2993
|
+
init_state();
|
|
2994
|
+
ENV_OVERRIDE_VARS = ["CLAUDE_CODE_SUBAGENT_MODEL"];
|
|
2995
|
+
});
|
|
2996
|
+
|
|
2997
|
+
// ../../packages/shared/dist/profile-switch/engine.js
|
|
2998
|
+
import fs7 from "fs";
|
|
2999
|
+
import path11 from "path";
|
|
3000
|
+
import os7 from "os";
|
|
2718
3001
|
import crypto4 from "crypto";
|
|
2719
3002
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
2720
3003
|
function namedError3(name, message) {
|
|
@@ -2723,10 +3006,10 @@ function namedError3(name, message) {
|
|
|
2723
3006
|
return err;
|
|
2724
3007
|
}
|
|
2725
3008
|
function defaultStatePath(targetHome) {
|
|
2726
|
-
return
|
|
3009
|
+
return path11.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
2727
3010
|
}
|
|
2728
3011
|
function resolveCommon(opts) {
|
|
2729
|
-
const targetHome = opts.targetHome ??
|
|
3012
|
+
const targetHome = opts.targetHome ?? os7.homedir();
|
|
2730
3013
|
const stateFilePath = opts.stateFilePath ?? defaultStatePath(targetHome);
|
|
2731
3014
|
return { targetHome, stateFilePath };
|
|
2732
3015
|
}
|
|
@@ -2734,7 +3017,7 @@ function marketplaceRoots(targetHome, state) {
|
|
|
2734
3017
|
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
2735
3018
|
}
|
|
2736
3019
|
function claudeMarketplaceUnresolvedReason(targetHome) {
|
|
2737
|
-
const registryPath =
|
|
3020
|
+
const registryPath = path11.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
2738
3021
|
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";
|
|
2739
3022
|
}
|
|
2740
3023
|
function listProfiles(opts = {}) {
|
|
@@ -2742,6 +3025,12 @@ function listProfiles(opts = {}) {
|
|
|
2742
3025
|
const state = readInstallState(stateFilePath);
|
|
2743
3026
|
const roots = marketplaceRoots(targetHome, state);
|
|
2744
3027
|
const universe = opts.hosts ?? HOSTS;
|
|
3028
|
+
const claudeDrift = universe.includes("claude") ? runtimeDriftReport({ targetHome, stateFilePath, state, env: opts.env }) : null;
|
|
3029
|
+
const claudeDriftFields = (host) => host === "claude" && claudeDrift !== null ? {
|
|
3030
|
+
liveRoot: claudeDrift.liveRoot,
|
|
3031
|
+
sourceVersion: claudeDrift.sourceVersion,
|
|
3032
|
+
envOverride: claudeDrift.envOverride ? `${claudeDrift.envOverride.name}=${claudeDrift.envOverride.value}` : null
|
|
3033
|
+
} : { liveRoot: null, sourceVersion: null, envOverride: null };
|
|
2745
3034
|
const hosts = universe.map((host) => {
|
|
2746
3035
|
if (host === "claude" && state.platforms.claude?.installRoute === "marketplace" && roots.claude === undefined) {
|
|
2747
3036
|
const platform2 = state.platforms.claude;
|
|
@@ -2750,9 +3039,10 @@ function listProfiles(opts = {}) {
|
|
|
2750
3039
|
installed: false,
|
|
2751
3040
|
skipped: false,
|
|
2752
3041
|
skipReason: null,
|
|
2753
|
-
activeProfile: platform2.modelProfile?.profile ??
|
|
3042
|
+
activeProfile: platform2.modelProfile?.profile ?? "balanced",
|
|
2754
3043
|
bundleVersion: platform2.plugin?.version ?? null,
|
|
2755
|
-
availableProfiles: []
|
|
3044
|
+
availableProfiles: [],
|
|
3045
|
+
...claudeDriftFields(host)
|
|
2756
3046
|
};
|
|
2757
3047
|
}
|
|
2758
3048
|
const layout = resolveHostLayout(host, { targetHome, projectRoot: opts.projectRoot, marketplaceRoot: roots });
|
|
@@ -2764,10 +3054,11 @@ function listProfiles(opts = {}) {
|
|
|
2764
3054
|
skipReason: layout.reason,
|
|
2765
3055
|
activeProfile: null,
|
|
2766
3056
|
bundleVersion: null,
|
|
2767
|
-
availableProfiles: []
|
|
3057
|
+
availableProfiles: [],
|
|
3058
|
+
...claudeDriftFields(host)
|
|
2768
3059
|
};
|
|
2769
3060
|
}
|
|
2770
|
-
const installed =
|
|
3061
|
+
const installed = fs7.existsSync(layout.activeDir);
|
|
2771
3062
|
const availableProfiles = listVariantProfiles(layout);
|
|
2772
3063
|
const platform = state.platforms[host];
|
|
2773
3064
|
return {
|
|
@@ -2775,17 +3066,18 @@ function listProfiles(opts = {}) {
|
|
|
2775
3066
|
installed,
|
|
2776
3067
|
skipped: false,
|
|
2777
3068
|
skipReason: null,
|
|
2778
|
-
activeProfile: platform?.modelProfile?.profile ??
|
|
3069
|
+
activeProfile: platform?.modelProfile?.profile ?? "balanced",
|
|
2779
3070
|
bundleVersion: platform?.plugin?.version ?? null,
|
|
2780
|
-
availableProfiles
|
|
3071
|
+
availableProfiles,
|
|
3072
|
+
...claudeDriftFields(host)
|
|
2781
3073
|
};
|
|
2782
3074
|
});
|
|
2783
3075
|
return { hosts };
|
|
2784
3076
|
}
|
|
2785
3077
|
function listVariantProfiles(layout) {
|
|
2786
|
-
if (!
|
|
3078
|
+
if (!fs7.existsSync(layout.variantsRoot))
|
|
2787
3079
|
return [];
|
|
2788
|
-
return
|
|
3080
|
+
return fs7.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
2789
3081
|
}
|
|
2790
3082
|
function matchesGlob(filename, glob) {
|
|
2791
3083
|
const starIdx = glob.indexOf("*");
|
|
@@ -2796,7 +3088,7 @@ function matchesGlob(filename, glob) {
|
|
|
2796
3088
|
return filename.length >= prefix.length + suffix.length && filename.startsWith(prefix) && filename.endsWith(suffix);
|
|
2797
3089
|
}
|
|
2798
3090
|
function matchingFileNames(dir, glob) {
|
|
2799
|
-
return
|
|
3091
|
+
return fs7.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && matchesGlob(e.name, glob)).map((e) => e.name);
|
|
2800
3092
|
}
|
|
2801
3093
|
function detectGitAvailability(dir) {
|
|
2802
3094
|
try {
|
|
@@ -2822,7 +3114,7 @@ function gitTrackedFileNames(dir, filenames) {
|
|
|
2822
3114
|
}
|
|
2823
3115
|
}
|
|
2824
3116
|
function checkTrackedPathGuard(activeDir, filenames) {
|
|
2825
|
-
if (filenames.length === 0 || !
|
|
3117
|
+
if (filenames.length === 0 || !fs7.existsSync(activeDir))
|
|
2826
3118
|
return GUARD_PASS;
|
|
2827
3119
|
const availability = detectGitAvailability(activeDir);
|
|
2828
3120
|
if (availability === "no-git")
|
|
@@ -2833,53 +3125,53 @@ function checkTrackedPathGuard(activeDir, filenames) {
|
|
|
2833
3125
|
if (tracked.size === 0)
|
|
2834
3126
|
return GUARD_PASS;
|
|
2835
3127
|
const offending = filenames.find((name) => tracked.has(name));
|
|
2836
|
-
return { blocked: true, path:
|
|
3128
|
+
return { blocked: true, path: path11.join(activeDir, offending), unchecked: false };
|
|
2837
3129
|
}
|
|
2838
3130
|
function assertStateWritable(stateFilePath) {
|
|
2839
|
-
const dir =
|
|
3131
|
+
const dir = path11.dirname(stateFilePath);
|
|
2840
3132
|
try {
|
|
2841
|
-
|
|
3133
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
2842
3134
|
} catch (err) {
|
|
2843
3135
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
2844
3136
|
}
|
|
2845
|
-
const checkPath =
|
|
3137
|
+
const checkPath = fs7.existsSync(stateFilePath) ? stateFilePath : dir;
|
|
2846
3138
|
try {
|
|
2847
|
-
|
|
3139
|
+
fs7.accessSync(checkPath, fs7.constants.W_OK);
|
|
2848
3140
|
} catch (err) {
|
|
2849
3141
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
2850
3142
|
}
|
|
2851
3143
|
}
|
|
2852
3144
|
function copyFileRouteVariant(layout, variantDir) {
|
|
2853
|
-
|
|
3145
|
+
fs7.mkdirSync(layout.activeDir, { recursive: true });
|
|
2854
3146
|
let changed = 0;
|
|
2855
|
-
for (const entry of
|
|
3147
|
+
for (const entry of fs7.readdirSync(variantDir, { withFileTypes: true })) {
|
|
2856
3148
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
2857
3149
|
continue;
|
|
2858
|
-
|
|
3150
|
+
fs7.copyFileSync(path11.join(variantDir, entry.name), path11.join(layout.activeDir, entry.name));
|
|
2859
3151
|
changed++;
|
|
2860
3152
|
}
|
|
2861
3153
|
return changed;
|
|
2862
3154
|
}
|
|
2863
3155
|
function repointOpencodeVariant(layout, variantDir) {
|
|
2864
|
-
|
|
3156
|
+
fs7.mkdirSync(layout.activeDir, { recursive: true });
|
|
2865
3157
|
let changed = 0;
|
|
2866
|
-
for (const entry of
|
|
3158
|
+
for (const entry of fs7.readdirSync(variantDir, { withFileTypes: true })) {
|
|
2867
3159
|
if (!entry.isFile() || !matchesGlob(entry.name, layout.activeGlob))
|
|
2868
3160
|
continue;
|
|
2869
|
-
const dest =
|
|
2870
|
-
const target =
|
|
3161
|
+
const dest = path11.join(layout.activeDir, entry.name);
|
|
3162
|
+
const target = path11.resolve(path11.join(variantDir, entry.name));
|
|
2871
3163
|
let destExists = true;
|
|
2872
3164
|
let destIsSymlink = false;
|
|
2873
3165
|
try {
|
|
2874
|
-
destIsSymlink =
|
|
3166
|
+
destIsSymlink = fs7.lstatSync(dest).isSymbolicLink();
|
|
2875
3167
|
} catch {
|
|
2876
3168
|
destExists = false;
|
|
2877
3169
|
}
|
|
2878
3170
|
if (destExists && !destIsSymlink)
|
|
2879
3171
|
continue;
|
|
2880
3172
|
const tmp = `${dest}.massa-ai-switch.${crypto4.randomUUID()}`;
|
|
2881
|
-
|
|
2882
|
-
|
|
3173
|
+
fs7.symlinkSync(target, tmp);
|
|
3174
|
+
fs7.renameSync(tmp, dest);
|
|
2883
3175
|
changed++;
|
|
2884
3176
|
}
|
|
2885
3177
|
return changed;
|
|
@@ -2919,13 +3211,13 @@ function switchProfile(opts) {
|
|
|
2919
3211
|
if (fileHosts.length === 0) {
|
|
2920
3212
|
return { profile: opts.profile, dryRun, hosts: orderRows(universe, skipRows), restartRequired: false };
|
|
2921
3213
|
}
|
|
2922
|
-
const installedFileHosts = fileHosts.filter((h) =>
|
|
3214
|
+
const installedFileHosts = fileHosts.filter((h) => fs7.existsSync(h.layout.activeDir));
|
|
2923
3215
|
if (installedFileHosts.length === 0)
|
|
2924
3216
|
throw NoHostsDetectedError();
|
|
2925
3217
|
const withAvailability = fileHosts.map((h) => {
|
|
2926
|
-
const variantsRootExists =
|
|
3218
|
+
const variantsRootExists = fs7.existsSync(h.layout.variantsRoot);
|
|
2927
3219
|
const variantDir = h.layout.variantDir(opts.profile);
|
|
2928
|
-
const available = variantsRootExists &&
|
|
3220
|
+
const available = variantsRootExists && fs7.existsSync(variantDir) && fs7.statSync(variantDir).isDirectory();
|
|
2929
3221
|
return { ...h, variantsRootExists, variantDir, available };
|
|
2930
3222
|
});
|
|
2931
3223
|
if (!withAvailability.some((h) => h.available)) {
|
|
@@ -2961,7 +3253,7 @@ function switchProfile(opts) {
|
|
|
2961
3253
|
continue;
|
|
2962
3254
|
}
|
|
2963
3255
|
if (dryRun) {
|
|
2964
|
-
rows.push({ host: h.host, status: "
|
|
3256
|
+
rows.push({ host: h.host, status: "would-switch" });
|
|
2965
3257
|
continue;
|
|
2966
3258
|
}
|
|
2967
3259
|
const candidateNames = matchingFileNames(h.variantDir, h.layout.activeGlob);
|
|
@@ -3006,6 +3298,7 @@ var init_engine = __esm(() => {
|
|
|
3006
3298
|
init_state();
|
|
3007
3299
|
init_lock();
|
|
3008
3300
|
init_claude_marketplace();
|
|
3301
|
+
init_doctor();
|
|
3009
3302
|
SwitchEngineError = class SwitchEngineError extends Error {
|
|
3010
3303
|
constructor(message) {
|
|
3011
3304
|
super(message);
|
|
@@ -3018,29 +3311,29 @@ var init_engine = __esm(() => {
|
|
|
3018
3311
|
|
|
3019
3312
|
// ../../packages/shared/dist/profile-switch/report.js
|
|
3020
3313
|
function reportSucceeded(report) {
|
|
3021
|
-
return report.hosts.every((h) => h.status === "switched" || h.status === "skipped");
|
|
3314
|
+
return report.hosts.every((h) => h.status === "switched" || h.status === "would-switch" || h.status === "skipped");
|
|
3022
3315
|
}
|
|
3023
3316
|
|
|
3024
3317
|
// ../../packages/shared/dist/profile-switch/variant-sync.js
|
|
3025
|
-
import
|
|
3026
|
-
import
|
|
3027
|
-
import
|
|
3318
|
+
import fs8 from "fs";
|
|
3319
|
+
import path12 from "path";
|
|
3320
|
+
import os8 from "os";
|
|
3028
3321
|
import crypto5 from "crypto";
|
|
3029
3322
|
function defaultStatePath2(targetHome) {
|
|
3030
|
-
return
|
|
3323
|
+
return path12.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
3031
3324
|
}
|
|
3032
3325
|
function marketplaceRoots2(targetHome, state) {
|
|
3033
3326
|
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
3034
3327
|
}
|
|
3035
3328
|
function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
3036
3329
|
const unique = `${process.pid}.${++tempFileCounter2}.${crypto5.randomBytes(6).toString("hex")}`;
|
|
3037
|
-
const tempFile =
|
|
3330
|
+
const tempFile = path12.join(destDir, `.${destName}.${unique}.tmp`);
|
|
3038
3331
|
try {
|
|
3039
|
-
|
|
3040
|
-
|
|
3332
|
+
fs8.writeFileSync(tempFile, content);
|
|
3333
|
+
fs8.renameSync(tempFile, path12.join(destDir, destName));
|
|
3041
3334
|
} catch (error) {
|
|
3042
3335
|
try {
|
|
3043
|
-
|
|
3336
|
+
fs8.unlinkSync(tempFile);
|
|
3044
3337
|
} catch {}
|
|
3045
3338
|
throw error;
|
|
3046
3339
|
}
|
|
@@ -3048,20 +3341,20 @@ function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
|
3048
3341
|
function isSafeDirName(name) {
|
|
3049
3342
|
if (name === "." || name === "..")
|
|
3050
3343
|
return false;
|
|
3051
|
-
if (name.includes("/") || name.includes("\\") || name.includes(
|
|
3344
|
+
if (name.includes("/") || name.includes("\\") || name.includes(path12.sep))
|
|
3052
3345
|
return false;
|
|
3053
|
-
return
|
|
3346
|
+
return path12.basename(name) === name;
|
|
3054
3347
|
}
|
|
3055
3348
|
function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
3056
3349
|
const layout = resolveHostLayout(host, { targetHome, marketplaceRoot });
|
|
3057
3350
|
if (layout.route === "skip") {
|
|
3058
3351
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: layout.reason };
|
|
3059
3352
|
}
|
|
3060
|
-
const srcDir =
|
|
3061
|
-
if (!
|
|
3353
|
+
const srcDir = path12.join(sourceRoot, "apps", `${host}-plugin`, "agent-profiles");
|
|
3354
|
+
if (!fs8.existsSync(srcDir) || !fs8.statSync(srcDir).isDirectory()) {
|
|
3062
3355
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: "no generated variants for this host" };
|
|
3063
3356
|
}
|
|
3064
|
-
if (!
|
|
3357
|
+
if (!fs8.existsSync(layout.variantsRoot)) {
|
|
3065
3358
|
return {
|
|
3066
3359
|
host,
|
|
3067
3360
|
status: "skipped",
|
|
@@ -3073,24 +3366,24 @@ function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
|
3073
3366
|
}
|
|
3074
3367
|
const profiles = [];
|
|
3075
3368
|
let files = 0;
|
|
3076
|
-
for (const entry of
|
|
3369
|
+
for (const entry of fs8.readdirSync(srcDir, { withFileTypes: true })) {
|
|
3077
3370
|
if (!entry.isDirectory())
|
|
3078
3371
|
continue;
|
|
3079
3372
|
if (!isSafeDirName(entry.name))
|
|
3080
3373
|
continue;
|
|
3081
|
-
const srcProfileDir =
|
|
3082
|
-
const destProfileDir =
|
|
3083
|
-
|
|
3084
|
-
for (const fileEntry of
|
|
3374
|
+
const srcProfileDir = path12.join(srcDir, entry.name);
|
|
3375
|
+
const destProfileDir = path12.join(layout.variantsRoot, entry.name);
|
|
3376
|
+
fs8.mkdirSync(destProfileDir, { recursive: true });
|
|
3377
|
+
for (const fileEntry of fs8.readdirSync(srcProfileDir, { withFileTypes: true })) {
|
|
3085
3378
|
if (!fileEntry.isFile())
|
|
3086
3379
|
continue;
|
|
3087
|
-
const content =
|
|
3380
|
+
const content = fs8.readFileSync(path12.join(srcProfileDir, fileEntry.name));
|
|
3088
3381
|
writeFileIntoDirAtomically(destProfileDir, fileEntry.name, content);
|
|
3089
3382
|
files++;
|
|
3090
3383
|
}
|
|
3091
3384
|
profiles.push(entry.name);
|
|
3092
3385
|
}
|
|
3093
|
-
const retained =
|
|
3386
|
+
const retained = fs8.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory() && !profiles.includes(e.name)).map((e) => e.name).sort();
|
|
3094
3387
|
return { host, status: "synced", profiles: profiles.sort(), retained, files };
|
|
3095
3388
|
}
|
|
3096
3389
|
function syncGeneratedVariants(opts) {
|
|
@@ -3106,7 +3399,7 @@ function syncGeneratedVariants(opts) {
|
|
|
3106
3399
|
}));
|
|
3107
3400
|
}
|
|
3108
3401
|
const sourceRoot = opts.sourceRoot;
|
|
3109
|
-
const targetHome = opts.targetHome ??
|
|
3402
|
+
const targetHome = opts.targetHome ?? os8.homedir();
|
|
3110
3403
|
const state = readInstallState(defaultStatePath2(targetHome));
|
|
3111
3404
|
const roots = marketplaceRoots2(targetHome, state);
|
|
3112
3405
|
return hosts.map((host) => {
|
|
@@ -3125,14 +3418,14 @@ var init_variant_sync = __esm(() => {
|
|
|
3125
3418
|
});
|
|
3126
3419
|
|
|
3127
3420
|
// ../../packages/shared/dist/profile-switch/repo-root.js
|
|
3128
|
-
import
|
|
3129
|
-
import
|
|
3421
|
+
import fs9 from "fs";
|
|
3422
|
+
import path13 from "path";
|
|
3130
3423
|
function findRepoRootWithMarker(startDir, marker, maxLevels) {
|
|
3131
3424
|
let dir = startDir;
|
|
3132
3425
|
for (let i = 0;i <= maxLevels; i++) {
|
|
3133
|
-
if (
|
|
3426
|
+
if (fs9.existsSync(path13.join(dir, marker)))
|
|
3134
3427
|
return dir;
|
|
3135
|
-
const parent =
|
|
3428
|
+
const parent = path13.dirname(dir);
|
|
3136
3429
|
if (parent === dir)
|
|
3137
3430
|
break;
|
|
3138
3431
|
dir = parent;
|
|
@@ -3230,7 +3523,7 @@ var init_rules = __esm(() => {
|
|
|
3230
3523
|
});
|
|
3231
3524
|
|
|
3232
3525
|
// ../../packages/shared/dist/bootstrap/state.js
|
|
3233
|
-
import
|
|
3526
|
+
import fs10 from "fs";
|
|
3234
3527
|
function isPlainObject2(value) {
|
|
3235
3528
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3236
3529
|
}
|
|
@@ -3261,7 +3554,7 @@ function resolveBootstrapState(doc) {
|
|
|
3261
3554
|
}
|
|
3262
3555
|
function readConfigBytes() {
|
|
3263
3556
|
try {
|
|
3264
|
-
return
|
|
3557
|
+
return fs10.readFileSync(getConfigPath(), "utf-8");
|
|
3265
3558
|
} catch (error) {
|
|
3266
3559
|
if (error?.code === "ENOENT")
|
|
3267
3560
|
return "";
|
|
@@ -3316,7 +3609,7 @@ var init_state2 = __esm(() => {
|
|
|
3316
3609
|
});
|
|
3317
3610
|
|
|
3318
3611
|
// ../../packages/shared/dist/bootstrap/render.js
|
|
3319
|
-
import
|
|
3612
|
+
import path14 from "path";
|
|
3320
3613
|
function wrapBootstrapBlock(body) {
|
|
3321
3614
|
return `${BOOTSTRAP_BLOCK_START}
|
|
3322
3615
|
${body.replace(/\n+$/, "")}
|
|
@@ -3329,19 +3622,19 @@ function ruleMarker(id, suffix) {
|
|
|
3329
3622
|
function resolveHostRoot(host, targetHome, hostRoot) {
|
|
3330
3623
|
requireAbsoluteTargetHome(targetHome);
|
|
3331
3624
|
if (hostRoot === undefined)
|
|
3332
|
-
return
|
|
3333
|
-
const relative =
|
|
3334
|
-
if (!
|
|
3625
|
+
return path14.join(targetHome, ...HOST_CONFIG_DIR[host]);
|
|
3626
|
+
const relative = path14.relative(targetHome, hostRoot);
|
|
3627
|
+
if (!path14.isAbsolute(hostRoot) || relative === "" || relative.startsWith("..") || path14.isAbsolute(relative)) {
|
|
3335
3628
|
throw new BootstrapRenderError("HostRootOutsideTargetHomeError", `hostRoot must be an absolute directory inside targetHome, got "${hostRoot}" for targetHome "${targetHome}"`, [hostRoot, targetHome]);
|
|
3336
3629
|
}
|
|
3337
3630
|
return hostRoot;
|
|
3338
3631
|
}
|
|
3339
3632
|
function bootstrapContractPath(host, targetHome, hostRoot) {
|
|
3340
|
-
return
|
|
3633
|
+
return path14.join(resolveHostRoot(host, targetHome, hostRoot), CONTRACT_FILENAME);
|
|
3341
3634
|
}
|
|
3342
3635
|
function bootstrapStateFilePath(targetHome) {
|
|
3343
3636
|
requireAbsoluteTargetHome(targetHome);
|
|
3344
|
-
return
|
|
3637
|
+
return path14.join(targetHome, ".config", "massa-ai", "config.json");
|
|
3345
3638
|
}
|
|
3346
3639
|
function renderBootstrap(options) {
|
|
3347
3640
|
const { source, state, host, targetHome, hostRoot } = options;
|
|
@@ -3364,7 +3657,7 @@ ${body}`;
|
|
|
3364
3657
|
return { contract, pointer };
|
|
3365
3658
|
}
|
|
3366
3659
|
function requireAbsoluteTargetHome(targetHome) {
|
|
3367
|
-
if (!
|
|
3660
|
+
if (!path14.isAbsolute(targetHome)) {
|
|
3368
3661
|
throw new BootstrapRenderError("TargetHomeNotAbsoluteError", `targetHome must be an absolute path, got "${targetHome}"`, [targetHome]);
|
|
3369
3662
|
}
|
|
3370
3663
|
}
|
|
@@ -3541,14 +3834,14 @@ var init_report = __esm(() => {
|
|
|
3541
3834
|
});
|
|
3542
3835
|
|
|
3543
3836
|
// ../../packages/shared/dist/bootstrap/engine.js
|
|
3544
|
-
import
|
|
3545
|
-
import
|
|
3837
|
+
import fs11 from "fs";
|
|
3838
|
+
import path15 from "path";
|
|
3546
3839
|
function applyBootstrapState(options) {
|
|
3547
3840
|
const { targetHome } = options;
|
|
3548
3841
|
const dryRun = options.dryRun ?? false;
|
|
3549
3842
|
const warn = options.onWarning ?? ((message) => console.warn(message));
|
|
3550
3843
|
const configPath = bootstrapStateFilePath(targetHome);
|
|
3551
|
-
const installStatePath =
|
|
3844
|
+
const installStatePath = path15.join(path15.dirname(configPath), INSTALL_STATE_FILENAME);
|
|
3552
3845
|
const { platforms } = readInstallState(installStatePath);
|
|
3553
3846
|
const installed = HOSTS.filter((host) => platforms[host] !== undefined);
|
|
3554
3847
|
if (installed.length === 0) {
|
|
@@ -3641,22 +3934,22 @@ function applyHost(input) {
|
|
|
3641
3934
|
}
|
|
3642
3935
|
function wiringArtifact(host, targetHome, hostRoot) {
|
|
3643
3936
|
const root = resolveHostRoot(host, targetHome, hostRoot);
|
|
3644
|
-
const contractPath =
|
|
3937
|
+
const contractPath = path15.join(root, CONTRACT_FILENAME);
|
|
3645
3938
|
switch (host) {
|
|
3646
3939
|
case "claude":
|
|
3647
|
-
return { file:
|
|
3940
|
+
return { file: path15.join(root, "CLAUDE.md"), token: `@${CONTRACT_FILENAME}` };
|
|
3648
3941
|
case "codex":
|
|
3649
3942
|
case "cursor":
|
|
3650
|
-
return { file:
|
|
3943
|
+
return { file: path15.join(root, "AGENTS.md"), token: contractPath };
|
|
3651
3944
|
case "opencode":
|
|
3652
3945
|
return { file: openCodeConfigPath(root), token: `"${contractPath}"` };
|
|
3653
3946
|
}
|
|
3654
3947
|
}
|
|
3655
3948
|
function openCodeConfigPath(root) {
|
|
3656
|
-
const json =
|
|
3657
|
-
if (
|
|
3949
|
+
const json = path15.join(root, "opencode.json");
|
|
3950
|
+
if (fs11.existsSync(json))
|
|
3658
3951
|
return json;
|
|
3659
|
-
return
|
|
3952
|
+
return path15.join(root, "opencode.jsonc");
|
|
3660
3953
|
}
|
|
3661
3954
|
function isWired(host, targetHome, hostRoot) {
|
|
3662
3955
|
const artifact = wiringArtifact(host, targetHome, hostRoot);
|
|
@@ -3669,7 +3962,7 @@ function notWiredReason(host, targetHome, hostRoot) {
|
|
|
3669
3962
|
}
|
|
3670
3963
|
function readFileOrNull(filePath) {
|
|
3671
3964
|
try {
|
|
3672
|
-
return
|
|
3965
|
+
return fs11.readFileSync(filePath, "utf-8");
|
|
3673
3966
|
} catch {
|
|
3674
3967
|
return null;
|
|
3675
3968
|
}
|
|
@@ -3753,6 +4046,7 @@ var init_dist = __esm(() => {
|
|
|
3753
4046
|
init_engine();
|
|
3754
4047
|
init_variant_sync();
|
|
3755
4048
|
init_repo_root();
|
|
4049
|
+
init_doctor();
|
|
3756
4050
|
init_bootstrap();
|
|
3757
4051
|
init_types();
|
|
3758
4052
|
init_interfaces();
|
|
@@ -5275,7 +5569,7 @@ var import_brace_expansion, minimatch = (p, pattern, options = {}) => {
|
|
|
5275
5569
|
}, qmarksTestNoExtDot = ([$0]) => {
|
|
5276
5570
|
const len = $0.length;
|
|
5277
5571
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
5278
|
-
}, defaultPlatform,
|
|
5572
|
+
}, 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) => {
|
|
5279
5573
|
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
5280
5574
|
return minimatch;
|
|
5281
5575
|
}
|
|
@@ -5333,11 +5627,11 @@ var init_esm = __esm(() => {
|
|
|
5333
5627
|
starRE = /^\*+$/;
|
|
5334
5628
|
qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
5335
5629
|
defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
5336
|
-
|
|
5630
|
+
path16 = {
|
|
5337
5631
|
win32: { sep: "\\" },
|
|
5338
5632
|
posix: { sep: "/" }
|
|
5339
5633
|
};
|
|
5340
|
-
sep = defaultPlatform === "win32" ?
|
|
5634
|
+
sep = defaultPlatform === "win32" ? path16.win32.sep : path16.posix.sep;
|
|
5341
5635
|
minimatch.sep = sep;
|
|
5342
5636
|
GLOBSTAR = Symbol("globstar **");
|
|
5343
5637
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -7303,12 +7597,12 @@ var init_esm4 = __esm(() => {
|
|
|
7303
7597
|
childrenCache() {
|
|
7304
7598
|
return this.#children;
|
|
7305
7599
|
}
|
|
7306
|
-
resolve(
|
|
7307
|
-
if (!
|
|
7600
|
+
resolve(path17) {
|
|
7601
|
+
if (!path17) {
|
|
7308
7602
|
return this;
|
|
7309
7603
|
}
|
|
7310
|
-
const rootPath = this.getRootString(
|
|
7311
|
-
const dir =
|
|
7604
|
+
const rootPath = this.getRootString(path17);
|
|
7605
|
+
const dir = path17.substring(rootPath.length);
|
|
7312
7606
|
const dirParts = dir.split(this.splitSep);
|
|
7313
7607
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
7314
7608
|
return result;
|
|
@@ -7836,8 +8130,8 @@ var init_esm4 = __esm(() => {
|
|
|
7836
8130
|
newChild(name, type = UNKNOWN, opts = {}) {
|
|
7837
8131
|
return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
|
7838
8132
|
}
|
|
7839
|
-
getRootString(
|
|
7840
|
-
return win32.parse(
|
|
8133
|
+
getRootString(path17) {
|
|
8134
|
+
return win32.parse(path17).root;
|
|
7841
8135
|
}
|
|
7842
8136
|
getRoot(rootPath) {
|
|
7843
8137
|
rootPath = uncToDrive(rootPath.toUpperCase());
|
|
@@ -7862,8 +8156,8 @@ var init_esm4 = __esm(() => {
|
|
|
7862
8156
|
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
|
7863
8157
|
super(name, type, root, roots, nocase, children, opts);
|
|
7864
8158
|
}
|
|
7865
|
-
getRootString(
|
|
7866
|
-
return
|
|
8159
|
+
getRootString(path17) {
|
|
8160
|
+
return path17.startsWith("/") ? "/" : "";
|
|
7867
8161
|
}
|
|
7868
8162
|
getRoot(_rootPath) {
|
|
7869
8163
|
return this.root;
|
|
@@ -7882,8 +8176,8 @@ var init_esm4 = __esm(() => {
|
|
|
7882
8176
|
#children;
|
|
7883
8177
|
nocase;
|
|
7884
8178
|
#fs;
|
|
7885
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
7886
|
-
this.#fs = fsFromOption(
|
|
8179
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs12 = defaultFS } = {}) {
|
|
8180
|
+
this.#fs = fsFromOption(fs12);
|
|
7887
8181
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
7888
8182
|
cwd = fileURLToPath(cwd);
|
|
7889
8183
|
}
|
|
@@ -7919,11 +8213,11 @@ var init_esm4 = __esm(() => {
|
|
|
7919
8213
|
}
|
|
7920
8214
|
this.cwd = prev;
|
|
7921
8215
|
}
|
|
7922
|
-
depth(
|
|
7923
|
-
if (typeof
|
|
7924
|
-
|
|
8216
|
+
depth(path17 = this.cwd) {
|
|
8217
|
+
if (typeof path17 === "string") {
|
|
8218
|
+
path17 = this.cwd.resolve(path17);
|
|
7925
8219
|
}
|
|
7926
|
-
return
|
|
8220
|
+
return path17.depth();
|
|
7927
8221
|
}
|
|
7928
8222
|
childrenCache() {
|
|
7929
8223
|
return this.#children;
|
|
@@ -8339,9 +8633,9 @@ var init_esm4 = __esm(() => {
|
|
|
8339
8633
|
process2();
|
|
8340
8634
|
return results;
|
|
8341
8635
|
}
|
|
8342
|
-
chdir(
|
|
8636
|
+
chdir(path17 = this.cwd) {
|
|
8343
8637
|
const oldCwd = this.cwd;
|
|
8344
|
-
this.cwd = typeof
|
|
8638
|
+
this.cwd = typeof path17 === "string" ? this.cwd.resolve(path17) : path17;
|
|
8345
8639
|
this.cwd[setAsCwd](oldCwd);
|
|
8346
8640
|
}
|
|
8347
8641
|
};
|
|
@@ -8358,8 +8652,8 @@ var init_esm4 = __esm(() => {
|
|
|
8358
8652
|
parseRootPath(dir) {
|
|
8359
8653
|
return win32.parse(dir).root.toUpperCase();
|
|
8360
8654
|
}
|
|
8361
|
-
newRoot(
|
|
8362
|
-
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
8655
|
+
newRoot(fs12) {
|
|
8656
|
+
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs12 });
|
|
8363
8657
|
}
|
|
8364
8658
|
isAbsolute(p) {
|
|
8365
8659
|
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
@@ -8375,8 +8669,8 @@ var init_esm4 = __esm(() => {
|
|
|
8375
8669
|
parseRootPath(_dir) {
|
|
8376
8670
|
return "/";
|
|
8377
8671
|
}
|
|
8378
|
-
newRoot(
|
|
8379
|
-
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
8672
|
+
newRoot(fs12) {
|
|
8673
|
+
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs12 });
|
|
8380
8674
|
}
|
|
8381
8675
|
isAbsolute(p) {
|
|
8382
8676
|
return p.startsWith("/");
|
|
@@ -8633,8 +8927,8 @@ class MatchRecord {
|
|
|
8633
8927
|
this.store.set(target, current === undefined ? n : n & current);
|
|
8634
8928
|
}
|
|
8635
8929
|
entries() {
|
|
8636
|
-
return [...this.store.entries()].map(([
|
|
8637
|
-
|
|
8930
|
+
return [...this.store.entries()].map(([path17, n]) => [
|
|
8931
|
+
path17,
|
|
8638
8932
|
!!(n & 2),
|
|
8639
8933
|
!!(n & 1)
|
|
8640
8934
|
]);
|
|
@@ -8838,9 +9132,9 @@ class GlobUtil {
|
|
|
8838
9132
|
signal;
|
|
8839
9133
|
maxDepth;
|
|
8840
9134
|
includeChildMatches;
|
|
8841
|
-
constructor(patterns,
|
|
9135
|
+
constructor(patterns, path17, opts) {
|
|
8842
9136
|
this.patterns = patterns;
|
|
8843
|
-
this.path =
|
|
9137
|
+
this.path = path17;
|
|
8844
9138
|
this.opts = opts;
|
|
8845
9139
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
8846
9140
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -8859,11 +9153,11 @@ class GlobUtil {
|
|
|
8859
9153
|
});
|
|
8860
9154
|
}
|
|
8861
9155
|
}
|
|
8862
|
-
#ignored(
|
|
8863
|
-
return this.seen.has(
|
|
9156
|
+
#ignored(path17) {
|
|
9157
|
+
return this.seen.has(path17) || !!this.#ignore?.ignored?.(path17);
|
|
8864
9158
|
}
|
|
8865
|
-
#childrenIgnored(
|
|
8866
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
9159
|
+
#childrenIgnored(path17) {
|
|
9160
|
+
return !!this.#ignore?.childrenIgnored?.(path17);
|
|
8867
9161
|
}
|
|
8868
9162
|
pause() {
|
|
8869
9163
|
this.paused = true;
|
|
@@ -9080,8 +9374,8 @@ var init_walker = __esm(() => {
|
|
|
9080
9374
|
init_processor();
|
|
9081
9375
|
GlobWalker = class GlobWalker extends GlobUtil {
|
|
9082
9376
|
matches = new Set;
|
|
9083
|
-
constructor(patterns,
|
|
9084
|
-
super(patterns,
|
|
9377
|
+
constructor(patterns, path17, opts) {
|
|
9378
|
+
super(patterns, path17, opts);
|
|
9085
9379
|
}
|
|
9086
9380
|
matchEmit(e) {
|
|
9087
9381
|
this.matches.add(e);
|
|
@@ -9118,8 +9412,8 @@ var init_walker = __esm(() => {
|
|
|
9118
9412
|
};
|
|
9119
9413
|
GlobStream = class GlobStream extends GlobUtil {
|
|
9120
9414
|
results;
|
|
9121
|
-
constructor(patterns,
|
|
9122
|
-
super(patterns,
|
|
9415
|
+
constructor(patterns, path17, opts) {
|
|
9416
|
+
super(patterns, path17, opts);
|
|
9123
9417
|
this.results = new Minipass({
|
|
9124
9418
|
signal: this.signal,
|
|
9125
9419
|
objectMode: true
|
|
@@ -9547,20 +9841,20 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
9547
9841
|
var throwError = (message, Ctor) => {
|
|
9548
9842
|
throw new Ctor(message);
|
|
9549
9843
|
};
|
|
9550
|
-
var checkPath = (
|
|
9551
|
-
if (!isString(
|
|
9844
|
+
var checkPath = (path17, originalPath, doThrow) => {
|
|
9845
|
+
if (!isString(path17)) {
|
|
9552
9846
|
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
9553
9847
|
}
|
|
9554
|
-
if (!
|
|
9848
|
+
if (!path17) {
|
|
9555
9849
|
return doThrow(`path must not be empty`, TypeError);
|
|
9556
9850
|
}
|
|
9557
|
-
if (checkPath.isNotRelative(
|
|
9851
|
+
if (checkPath.isNotRelative(path17)) {
|
|
9558
9852
|
const r = "`path.relative()`d";
|
|
9559
9853
|
return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
|
9560
9854
|
}
|
|
9561
9855
|
return true;
|
|
9562
9856
|
};
|
|
9563
|
-
var isNotRelative = (
|
|
9857
|
+
var isNotRelative = (path17) => REGEX_TEST_INVALID_PATH.test(path17);
|
|
9564
9858
|
checkPath.isNotRelative = isNotRelative;
|
|
9565
9859
|
checkPath.convert = (p) => p;
|
|
9566
9860
|
|
|
@@ -9603,7 +9897,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
9603
9897
|
addPattern(pattern) {
|
|
9604
9898
|
return this.add(pattern);
|
|
9605
9899
|
}
|
|
9606
|
-
_testOne(
|
|
9900
|
+
_testOne(path17, checkUnignored) {
|
|
9607
9901
|
let ignored = false;
|
|
9608
9902
|
let unignored = false;
|
|
9609
9903
|
this._rules.forEach((rule) => {
|
|
@@ -9611,7 +9905,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
9611
9905
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
9612
9906
|
return;
|
|
9613
9907
|
}
|
|
9614
|
-
const matched = rule.regex.test(
|
|
9908
|
+
const matched = rule.regex.test(path17);
|
|
9615
9909
|
if (matched) {
|
|
9616
9910
|
ignored = !negative;
|
|
9617
9911
|
unignored = negative;
|
|
@@ -9623,39 +9917,39 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
9623
9917
|
};
|
|
9624
9918
|
}
|
|
9625
9919
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
9626
|
-
const
|
|
9627
|
-
checkPath(
|
|
9628
|
-
return this._t(
|
|
9920
|
+
const path17 = originalPath && checkPath.convert(originalPath);
|
|
9921
|
+
checkPath(path17, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
9922
|
+
return this._t(path17, cache, checkUnignored, slices);
|
|
9629
9923
|
}
|
|
9630
|
-
_t(
|
|
9631
|
-
if (
|
|
9632
|
-
return cache[
|
|
9924
|
+
_t(path17, cache, checkUnignored, slices) {
|
|
9925
|
+
if (path17 in cache) {
|
|
9926
|
+
return cache[path17];
|
|
9633
9927
|
}
|
|
9634
9928
|
if (!slices) {
|
|
9635
|
-
slices =
|
|
9929
|
+
slices = path17.split(SLASH2);
|
|
9636
9930
|
}
|
|
9637
9931
|
slices.pop();
|
|
9638
9932
|
if (!slices.length) {
|
|
9639
|
-
return cache[
|
|
9933
|
+
return cache[path17] = this._testOne(path17, checkUnignored);
|
|
9640
9934
|
}
|
|
9641
9935
|
const parent = this._t(slices.join(SLASH2) + SLASH2, cache, checkUnignored, slices);
|
|
9642
|
-
return cache[
|
|
9936
|
+
return cache[path17] = parent.ignored ? parent : this._testOne(path17, checkUnignored);
|
|
9643
9937
|
}
|
|
9644
|
-
ignores(
|
|
9645
|
-
return this._test(
|
|
9938
|
+
ignores(path17) {
|
|
9939
|
+
return this._test(path17, this._ignoreCache, false).ignored;
|
|
9646
9940
|
}
|
|
9647
9941
|
createFilter() {
|
|
9648
|
-
return (
|
|
9942
|
+
return (path17) => !this.ignores(path17);
|
|
9649
9943
|
}
|
|
9650
9944
|
filter(paths) {
|
|
9651
9945
|
return makeArray(paths).filter(this.createFilter());
|
|
9652
9946
|
}
|
|
9653
|
-
test(
|
|
9654
|
-
return this._test(
|
|
9947
|
+
test(path17) {
|
|
9948
|
+
return this._test(path17, this._testCache, true);
|
|
9655
9949
|
}
|
|
9656
9950
|
}
|
|
9657
9951
|
var factory = (options) => new Ignore2(options);
|
|
9658
|
-
var isPathValid = (
|
|
9952
|
+
var isPathValid = (path17) => checkPath(path17 && checkPath.convert(path17), path17, RETURN_FALSE);
|
|
9659
9953
|
factory.isPathValid = isPathValid;
|
|
9660
9954
|
factory.default = factory;
|
|
9661
9955
|
module.exports = factory;
|
|
@@ -9663,7 +9957,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
9663
9957
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
9664
9958
|
checkPath.convert = makePosix;
|
|
9665
9959
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
9666
|
-
checkPath.isNotRelative = (
|
|
9960
|
+
checkPath.isNotRelative = (path17) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path17) || isNotRelative(path17);
|
|
9667
9961
|
}
|
|
9668
9962
|
});
|
|
9669
9963
|
|
|
@@ -9725,13 +10019,13 @@ function validatePolicy(policy, opts = {}) {
|
|
|
9725
10019
|
}
|
|
9726
10020
|
}
|
|
9727
10021
|
}
|
|
9728
|
-
function matchesGlob2(
|
|
10022
|
+
function matchesGlob2(path17, pattern) {
|
|
9729
10023
|
let re = regexCache.get(pattern);
|
|
9730
10024
|
if (!re) {
|
|
9731
10025
|
re = globToRegex(pattern);
|
|
9732
10026
|
regexCache.set(pattern, re);
|
|
9733
10027
|
}
|
|
9734
|
-
return re.test(
|
|
10028
|
+
return re.test(path17);
|
|
9735
10029
|
}
|
|
9736
10030
|
var DEFAULT_POLICY, applyPolicy = (filePath, policy) => {
|
|
9737
10031
|
const normalized = filePath.trim();
|
|
@@ -9748,8 +10042,8 @@ var init_capture_policy = __esm(() => {
|
|
|
9748
10042
|
});
|
|
9749
10043
|
|
|
9750
10044
|
// ../../packages/core/dist/services/search/ignore-patterns.js
|
|
9751
|
-
import
|
|
9752
|
-
import
|
|
10045
|
+
import fs12 from "fs/promises";
|
|
10046
|
+
import path17 from "path";
|
|
9753
10047
|
function buildExtensionGlob(extensions) {
|
|
9754
10048
|
return extensions.map((ext2) => `**/*${ext2}`);
|
|
9755
10049
|
}
|
|
@@ -9772,8 +10066,8 @@ async function loadProjectIgnore(projectPath) {
|
|
|
9772
10066
|
const ig = ignore();
|
|
9773
10067
|
ig.add(DEFAULT_IGNORES);
|
|
9774
10068
|
try {
|
|
9775
|
-
const gitignorePath =
|
|
9776
|
-
const gitignoreContent = await
|
|
10069
|
+
const gitignorePath = path17.join(projectPath, ".gitignore");
|
|
10070
|
+
const gitignoreContent = await fs12.readFile(gitignorePath, "utf8");
|
|
9777
10071
|
const rules = gitignoreContent.split(`
|
|
9778
10072
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
9779
10073
|
ig.add(rules);
|
|
@@ -11372,15 +11666,15 @@ var require_pg_connection_string = __commonJS((exports, module) => {
|
|
|
11372
11666
|
if (config2.sslnegotiation === "direct" && config2.ssl === undefined) {
|
|
11373
11667
|
config2.ssl = true;
|
|
11374
11668
|
}
|
|
11375
|
-
const
|
|
11669
|
+
const fs13 = config2.sslcert || config2.sslkey || config2.sslrootcert ? __require("fs") : null;
|
|
11376
11670
|
if (config2.sslcert) {
|
|
11377
|
-
config2.ssl.cert =
|
|
11671
|
+
config2.ssl.cert = fs13.readFileSync(config2.sslcert).toString();
|
|
11378
11672
|
}
|
|
11379
11673
|
if (config2.sslkey) {
|
|
11380
|
-
config2.ssl.key =
|
|
11674
|
+
config2.ssl.key = fs13.readFileSync(config2.sslkey).toString();
|
|
11381
11675
|
}
|
|
11382
11676
|
if (config2.sslrootcert) {
|
|
11383
|
-
config2.ssl.ca =
|
|
11677
|
+
config2.ssl.ca = fs13.readFileSync(config2.sslrootcert).toString();
|
|
11384
11678
|
}
|
|
11385
11679
|
if (options.useLibpqCompat && config2.uselibpqcompat) {
|
|
11386
11680
|
throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");
|
|
@@ -13094,7 +13388,7 @@ var require_split2 = __commonJS((exports, module) => {
|
|
|
13094
13388
|
|
|
13095
13389
|
// ../../node_modules/pgpass/lib/helper.js
|
|
13096
13390
|
var require_helper = __commonJS((exports, module) => {
|
|
13097
|
-
var
|
|
13391
|
+
var path18 = __require("path");
|
|
13098
13392
|
var Stream2 = __require("stream").Stream;
|
|
13099
13393
|
var split = require_split2();
|
|
13100
13394
|
var util = __require("util");
|
|
@@ -13134,7 +13428,7 @@ var require_helper = __commonJS((exports, module) => {
|
|
|
13134
13428
|
};
|
|
13135
13429
|
exports.getFileName = function(rawEnv) {
|
|
13136
13430
|
var env = rawEnv || process.env;
|
|
13137
|
-
var file = env.PGPASSFILE || (isWin ?
|
|
13431
|
+
var file = env.PGPASSFILE || (isWin ? path18.join(env.APPDATA || "./", "postgresql", "pgpass.conf") : path18.join(env.HOME || "./", ".pgpass"));
|
|
13138
13432
|
return file;
|
|
13139
13433
|
};
|
|
13140
13434
|
exports.usePgPass = function(stats, fname) {
|
|
@@ -13258,16 +13552,16 @@ var require_helper = __commonJS((exports, module) => {
|
|
|
13258
13552
|
|
|
13259
13553
|
// ../../node_modules/pgpass/lib/index.js
|
|
13260
13554
|
var require_lib = __commonJS((exports, module) => {
|
|
13261
|
-
var
|
|
13262
|
-
var
|
|
13555
|
+
var path18 = __require("path");
|
|
13556
|
+
var fs13 = __require("fs");
|
|
13263
13557
|
var helper = require_helper();
|
|
13264
13558
|
module.exports = function(connInfo, cb) {
|
|
13265
13559
|
var file = helper.getFileName();
|
|
13266
|
-
|
|
13560
|
+
fs13.stat(file, function(err, stat) {
|
|
13267
13561
|
if (err || !helper.usePgPass(stat, file)) {
|
|
13268
13562
|
return cb(undefined);
|
|
13269
13563
|
}
|
|
13270
|
-
var st =
|
|
13564
|
+
var st = fs13.createReadStream(file);
|
|
13271
13565
|
helper.getPassword(connInfo, st, cb);
|
|
13272
13566
|
});
|
|
13273
13567
|
};
|
|
@@ -14905,7 +15199,7 @@ class ProjectIdentityAliasResolver {
|
|
|
14905
15199
|
this.cache.set(projectId, { canonical, expiresAt: this.now() + this.ttlMs });
|
|
14906
15200
|
return canonical;
|
|
14907
15201
|
} catch (error) {
|
|
14908
|
-
logger.warn("[project-identity] alias resolution failed; using original id", safeErrorSummary(error));
|
|
15202
|
+
logger.warn("[project-identity] alias resolution failed; using original id", { projectId, ...safeErrorSummary(error) });
|
|
14909
15203
|
return projectId;
|
|
14910
15204
|
}
|
|
14911
15205
|
}
|
|
@@ -14966,8 +15260,8 @@ var init_alias_resolver = __esm(() => {
|
|
|
14966
15260
|
});
|
|
14967
15261
|
|
|
14968
15262
|
// ../../packages/core/dist/services/search/index-manager.js
|
|
14969
|
-
import
|
|
14970
|
-
import
|
|
15263
|
+
import fs13 from "fs";
|
|
15264
|
+
import path18 from "path";
|
|
14971
15265
|
|
|
14972
15266
|
class IndexManager {
|
|
14973
15267
|
metadataCache = new Map;
|
|
@@ -15060,9 +15354,9 @@ class IndexManager {
|
|
|
15060
15354
|
const fileMetadata = {};
|
|
15061
15355
|
let totalSize = 0;
|
|
15062
15356
|
for (const filePath of indexedFiles) {
|
|
15063
|
-
const fullPath =
|
|
15357
|
+
const fullPath = path18.join(projectPath, filePath);
|
|
15064
15358
|
try {
|
|
15065
|
-
const stat = await
|
|
15359
|
+
const stat = await fs13.promises.stat(fullPath);
|
|
15066
15360
|
fileMetadata[filePath] = {
|
|
15067
15361
|
path: filePath,
|
|
15068
15362
|
mtime: stat.mtimeMs,
|
|
@@ -15113,9 +15407,9 @@ class IndexManager {
|
|
|
15113
15407
|
if (ig.ignores(match2)) {
|
|
15114
15408
|
continue;
|
|
15115
15409
|
}
|
|
15116
|
-
const fullPath =
|
|
15410
|
+
const fullPath = path18.join(projectPath, match2);
|
|
15117
15411
|
try {
|
|
15118
|
-
const stat = await
|
|
15412
|
+
const stat = await fs13.promises.stat(fullPath);
|
|
15119
15413
|
files.set(match2, {
|
|
15120
15414
|
path: match2,
|
|
15121
15415
|
mtime: stat.mtimeMs,
|
|
@@ -15566,10 +15860,10 @@ function mergeDefs(...defs) {
|
|
|
15566
15860
|
function cloneDef(schema) {
|
|
15567
15861
|
return mergeDefs(schema._zod.def);
|
|
15568
15862
|
}
|
|
15569
|
-
function getElementAtPath(obj,
|
|
15570
|
-
if (!
|
|
15863
|
+
function getElementAtPath(obj, path19) {
|
|
15864
|
+
if (!path19)
|
|
15571
15865
|
return obj;
|
|
15572
|
-
return
|
|
15866
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
15573
15867
|
}
|
|
15574
15868
|
function promiseAllObject(promisesObj) {
|
|
15575
15869
|
const keys = Object.keys(promisesObj);
|
|
@@ -15897,11 +16191,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
15897
16191
|
}
|
|
15898
16192
|
return false;
|
|
15899
16193
|
}
|
|
15900
|
-
function prefixIssues(
|
|
16194
|
+
function prefixIssues(path19, issues) {
|
|
15901
16195
|
return issues.map((iss) => {
|
|
15902
16196
|
var _a3;
|
|
15903
16197
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
15904
|
-
iss.path.unshift(
|
|
16198
|
+
iss.path.unshift(path19);
|
|
15905
16199
|
return iss;
|
|
15906
16200
|
});
|
|
15907
16201
|
}
|
|
@@ -16114,16 +16408,16 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
|
|
|
16114
16408
|
}
|
|
16115
16409
|
function formatError(error, mapper = (issue2) => issue2.message) {
|
|
16116
16410
|
const fieldErrors = { _errors: [] };
|
|
16117
|
-
const processError = (error2,
|
|
16411
|
+
const processError = (error2, path19 = []) => {
|
|
16118
16412
|
for (const issue2 of error2.issues) {
|
|
16119
16413
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
16120
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
16414
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
16121
16415
|
} else if (issue2.code === "invalid_key") {
|
|
16122
|
-
processError({ issues: issue2.issues }, [...
|
|
16416
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16123
16417
|
} else if (issue2.code === "invalid_element") {
|
|
16124
|
-
processError({ issues: issue2.issues }, [...
|
|
16418
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16125
16419
|
} else {
|
|
16126
|
-
const fullpath = [...
|
|
16420
|
+
const fullpath = [...path19, ...issue2.path];
|
|
16127
16421
|
if (fullpath.length === 0) {
|
|
16128
16422
|
fieldErrors._errors.push(mapper(issue2));
|
|
16129
16423
|
} else {
|
|
@@ -16150,17 +16444,17 @@ function formatError(error, mapper = (issue2) => issue2.message) {
|
|
|
16150
16444
|
}
|
|
16151
16445
|
function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
16152
16446
|
const result = { errors: [] };
|
|
16153
|
-
const processError = (error2,
|
|
16447
|
+
const processError = (error2, path19 = []) => {
|
|
16154
16448
|
var _a3, _b;
|
|
16155
16449
|
for (const issue2 of error2.issues) {
|
|
16156
16450
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
16157
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
16451
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
16158
16452
|
} else if (issue2.code === "invalid_key") {
|
|
16159
|
-
processError({ issues: issue2.issues }, [...
|
|
16453
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16160
16454
|
} else if (issue2.code === "invalid_element") {
|
|
16161
|
-
processError({ issues: issue2.issues }, [...
|
|
16455
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
16162
16456
|
} else {
|
|
16163
|
-
const fullpath = [...
|
|
16457
|
+
const fullpath = [...path19, ...issue2.path];
|
|
16164
16458
|
if (fullpath.length === 0) {
|
|
16165
16459
|
result.errors.push(mapper(issue2));
|
|
16166
16460
|
continue;
|
|
@@ -16192,8 +16486,8 @@ function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
|
16192
16486
|
}
|
|
16193
16487
|
function toDotPath(_path) {
|
|
16194
16488
|
const segs = [];
|
|
16195
|
-
const
|
|
16196
|
-
for (const seg of
|
|
16489
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
16490
|
+
for (const seg of path19) {
|
|
16197
16491
|
if (typeof seg === "number")
|
|
16198
16492
|
segs.push(`[${seg}]`);
|
|
16199
16493
|
else if (typeof seg === "symbol")
|
|
@@ -29196,13 +29490,13 @@ function resolveRef(ref, ctx) {
|
|
|
29196
29490
|
if (!ref.startsWith("#")) {
|
|
29197
29491
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
29198
29492
|
}
|
|
29199
|
-
const
|
|
29200
|
-
if (
|
|
29493
|
+
const path19 = ref.slice(1).split("/").filter(Boolean);
|
|
29494
|
+
if (path19.length === 0) {
|
|
29201
29495
|
return ctx.rootSchema;
|
|
29202
29496
|
}
|
|
29203
29497
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
29204
|
-
if (
|
|
29205
|
-
const key =
|
|
29498
|
+
if (path19[0] === defsKey) {
|
|
29499
|
+
const key = path19[1];
|
|
29206
29500
|
if (!key || !ctx.defs[key]) {
|
|
29207
29501
|
throw new Error(`Reference not found: ${ref}`);
|
|
29208
29502
|
}
|
|
@@ -30691,8 +30985,8 @@ class ParseStatus {
|
|
|
30691
30985
|
}
|
|
30692
30986
|
}
|
|
30693
30987
|
var makeIssue = (params) => {
|
|
30694
|
-
const { data, path:
|
|
30695
|
-
const fullPath = [...
|
|
30988
|
+
const { data, path: path19, errorMaps, issueData } = params;
|
|
30989
|
+
const fullPath = [...path19, ...issueData.path || []];
|
|
30696
30990
|
const fullIssue = {
|
|
30697
30991
|
...issueData,
|
|
30698
30992
|
path: fullPath
|
|
@@ -30737,11 +31031,11 @@ var init_errorUtil = __esm(() => {
|
|
|
30737
31031
|
|
|
30738
31032
|
// ../../node_modules/zod/v3/types.js
|
|
30739
31033
|
class ParseInputLazyPath {
|
|
30740
|
-
constructor(parent, value,
|
|
31034
|
+
constructor(parent, value, path19, key) {
|
|
30741
31035
|
this._cachedPath = [];
|
|
30742
31036
|
this.parent = parent;
|
|
30743
31037
|
this.data = value;
|
|
30744
|
-
this._path =
|
|
31038
|
+
this._path = path19;
|
|
30745
31039
|
this._key = key;
|
|
30746
31040
|
}
|
|
30747
31041
|
get path() {
|
|
@@ -36806,23 +37100,23 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
36806
37100
|
writeAuthConfig: () => writeAuthConfig
|
|
36807
37101
|
});
|
|
36808
37102
|
module.exports = __toCommonJS2(auth_config_exports);
|
|
36809
|
-
var
|
|
36810
|
-
var
|
|
37103
|
+
var fs14 = __toESM2(__require("fs"));
|
|
37104
|
+
var path19 = __toESM2(__require("path"));
|
|
36811
37105
|
var import_token_util = require_token_util();
|
|
36812
37106
|
function getAuthConfigPath() {
|
|
36813
37107
|
const dataDir = (0, import_token_util.getVercelDataDir)();
|
|
36814
37108
|
if (!dataDir) {
|
|
36815
37109
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
36816
37110
|
}
|
|
36817
|
-
return
|
|
37111
|
+
return path19.join(dataDir, "auth.json");
|
|
36818
37112
|
}
|
|
36819
37113
|
function readAuthConfig() {
|
|
36820
37114
|
try {
|
|
36821
37115
|
const authPath = getAuthConfigPath();
|
|
36822
|
-
if (!
|
|
37116
|
+
if (!fs14.existsSync(authPath)) {
|
|
36823
37117
|
return null;
|
|
36824
37118
|
}
|
|
36825
|
-
const content =
|
|
37119
|
+
const content = fs14.readFileSync(authPath, "utf8");
|
|
36826
37120
|
if (!content) {
|
|
36827
37121
|
return null;
|
|
36828
37122
|
}
|
|
@@ -36833,11 +37127,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
36833
37127
|
}
|
|
36834
37128
|
function writeAuthConfig(config3) {
|
|
36835
37129
|
const authPath = getAuthConfigPath();
|
|
36836
|
-
const authDir =
|
|
36837
|
-
if (!
|
|
36838
|
-
|
|
37130
|
+
const authDir = path19.dirname(authPath);
|
|
37131
|
+
if (!fs14.existsSync(authDir)) {
|
|
37132
|
+
fs14.mkdirSync(authDir, { mode: 504, recursive: true });
|
|
36839
37133
|
}
|
|
36840
|
-
|
|
37134
|
+
fs14.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
|
|
36841
37135
|
}
|
|
36842
37136
|
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
36843
37137
|
if (!authConfig.token)
|
|
@@ -37012,8 +37306,8 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37012
37306
|
saveToken: () => saveToken
|
|
37013
37307
|
});
|
|
37014
37308
|
module.exports = __toCommonJS2(token_util_exports);
|
|
37015
|
-
var
|
|
37016
|
-
var
|
|
37309
|
+
var path19 = __toESM2(__require("path"));
|
|
37310
|
+
var fs14 = __toESM2(__require("fs"));
|
|
37017
37311
|
var import_token_error = require_token_error();
|
|
37018
37312
|
var import_token_io = require_token_io();
|
|
37019
37313
|
var import_auth_config = require_auth_config();
|
|
@@ -37025,7 +37319,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37025
37319
|
if (!dataDir) {
|
|
37026
37320
|
return null;
|
|
37027
37321
|
}
|
|
37028
|
-
return
|
|
37322
|
+
return path19.join(dataDir, vercelFolder);
|
|
37029
37323
|
}
|
|
37030
37324
|
async function getVercelToken2(options) {
|
|
37031
37325
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -37093,11 +37387,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37093
37387
|
if (!dir) {
|
|
37094
37388
|
throw new import_token_error.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");
|
|
37095
37389
|
}
|
|
37096
|
-
const prjPath =
|
|
37097
|
-
if (!
|
|
37390
|
+
const prjPath = path19.join(dir, ".vercel", "project.json");
|
|
37391
|
+
if (!fs14.existsSync(prjPath)) {
|
|
37098
37392
|
throw new import_token_error.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");
|
|
37099
37393
|
}
|
|
37100
|
-
const prj = JSON.parse(
|
|
37394
|
+
const prj = JSON.parse(fs14.readFileSync(prjPath, "utf8"));
|
|
37101
37395
|
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
|
|
37102
37396
|
throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");
|
|
37103
37397
|
}
|
|
@@ -37108,11 +37402,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37108
37402
|
if (!dir) {
|
|
37109
37403
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
37110
37404
|
}
|
|
37111
|
-
const tokenPath =
|
|
37405
|
+
const tokenPath = path19.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
37112
37406
|
const tokenJson = JSON.stringify(token);
|
|
37113
|
-
|
|
37114
|
-
|
|
37115
|
-
|
|
37407
|
+
fs14.mkdirSync(path19.dirname(tokenPath), { mode: 504, recursive: true });
|
|
37408
|
+
fs14.writeFileSync(tokenPath, tokenJson);
|
|
37409
|
+
fs14.chmodSync(tokenPath, 432);
|
|
37116
37410
|
return;
|
|
37117
37411
|
}
|
|
37118
37412
|
function loadToken(projectId) {
|
|
@@ -37120,11 +37414,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37120
37414
|
if (!dir) {
|
|
37121
37415
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
37122
37416
|
}
|
|
37123
|
-
const tokenPath =
|
|
37124
|
-
if (!
|
|
37417
|
+
const tokenPath = path19.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
37418
|
+
if (!fs14.existsSync(tokenPath)) {
|
|
37125
37419
|
return null;
|
|
37126
37420
|
}
|
|
37127
|
-
const token = JSON.parse(
|
|
37421
|
+
const token = JSON.parse(fs14.readFileSync(tokenPath, "utf8"));
|
|
37128
37422
|
assertVercelOidcTokenResponse(token);
|
|
37129
37423
|
return token;
|
|
37130
37424
|
}
|
|
@@ -47966,37 +48260,37 @@ function createOpenAI(options = {}) {
|
|
|
47966
48260
|
}, `ai-sdk/openai/${VERSION4}`);
|
|
47967
48261
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
47968
48262
|
provider: `${providerName}.chat`,
|
|
47969
|
-
url: ({ path:
|
|
48263
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
47970
48264
|
headers: getHeaders,
|
|
47971
48265
|
fetch: options.fetch
|
|
47972
48266
|
});
|
|
47973
48267
|
const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
|
|
47974
48268
|
provider: `${providerName}.completion`,
|
|
47975
|
-
url: ({ path:
|
|
48269
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
47976
48270
|
headers: getHeaders,
|
|
47977
48271
|
fetch: options.fetch
|
|
47978
48272
|
});
|
|
47979
48273
|
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
47980
48274
|
provider: `${providerName}.embedding`,
|
|
47981
|
-
url: ({ path:
|
|
48275
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
47982
48276
|
headers: getHeaders,
|
|
47983
48277
|
fetch: options.fetch
|
|
47984
48278
|
});
|
|
47985
48279
|
const createImageModel = (modelId) => new OpenAIImageModel(modelId, {
|
|
47986
48280
|
provider: `${providerName}.image`,
|
|
47987
|
-
url: ({ path:
|
|
48281
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
47988
48282
|
headers: getHeaders,
|
|
47989
48283
|
fetch: options.fetch
|
|
47990
48284
|
});
|
|
47991
48285
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
47992
48286
|
provider: `${providerName}.transcription`,
|
|
47993
|
-
url: ({ path:
|
|
48287
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
47994
48288
|
headers: getHeaders,
|
|
47995
48289
|
fetch: options.fetch
|
|
47996
48290
|
});
|
|
47997
48291
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
47998
48292
|
provider: `${providerName}.speech`,
|
|
47999
|
-
url: ({ path:
|
|
48293
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48000
48294
|
headers: getHeaders,
|
|
48001
48295
|
fetch: options.fetch
|
|
48002
48296
|
});
|
|
@@ -48009,7 +48303,7 @@ function createOpenAI(options = {}) {
|
|
|
48009
48303
|
const createResponsesModel = (modelId) => {
|
|
48010
48304
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
48011
48305
|
provider: `${providerName}.responses`,
|
|
48012
|
-
url: ({ path:
|
|
48306
|
+
url: ({ path: path19 }) => `${baseURL}${path19}`,
|
|
48013
48307
|
headers: getHeaders,
|
|
48014
48308
|
fetch: options.fetch,
|
|
48015
48309
|
fileIdPrefixes: ["file-"]
|
|
@@ -52450,7 +52744,7 @@ async function _checkJsonSchemaSupport() {
|
|
|
52450
52744
|
} catch (e) {
|
|
52451
52745
|
_jsonSchemaSupported = false;
|
|
52452
52746
|
logger.warn("json_schema: version check error \u2014 falling back to json_object", {
|
|
52453
|
-
error: e
|
|
52747
|
+
error: e
|
|
52454
52748
|
});
|
|
52455
52749
|
return false;
|
|
52456
52750
|
}
|
|
@@ -52498,7 +52792,7 @@ function hostPort(url2) {
|
|
|
52498
52792
|
return null;
|
|
52499
52793
|
}
|
|
52500
52794
|
}
|
|
52501
|
-
function
|
|
52795
|
+
function resolveMatchedProviderSpec(baseUrl) {
|
|
52502
52796
|
const target = hostPort(baseUrl);
|
|
52503
52797
|
if (target) {
|
|
52504
52798
|
const match2 = inferenceProviderList().find((spec) => hostPort(spec.defaultLlmBaseUrl) === target);
|
|
@@ -52516,7 +52810,13 @@ function resolveInferenceSpec(baseUrl) {
|
|
|
52516
52810
|
if (embeddingProvider && LOCAL_INFERENCE_IDS.includes(embeddingProvider)) {
|
|
52517
52811
|
return INFERENCE_PROVIDERS[embeddingProvider];
|
|
52518
52812
|
}
|
|
52519
|
-
return
|
|
52813
|
+
return;
|
|
52814
|
+
}
|
|
52815
|
+
function resolveInferenceSpec(baseUrl) {
|
|
52816
|
+
return resolveMatchedProviderSpec(baseUrl) ?? INFERENCE_PROVIDERS.ollama;
|
|
52817
|
+
}
|
|
52818
|
+
function resolveProviderIdForLogging(baseUrl) {
|
|
52819
|
+
return resolveMatchedProviderSpec(baseUrl)?.id ?? "unknown";
|
|
52520
52820
|
}
|
|
52521
52821
|
function _wrapFetchDisableThink(baseFetch) {
|
|
52522
52822
|
const wrapped = async (input, init) => {
|
|
@@ -52659,12 +52959,40 @@ function _isAbortOrTimeoutError(err) {
|
|
|
52659
52959
|
}
|
|
52660
52960
|
return false;
|
|
52661
52961
|
}
|
|
52662
|
-
|
|
52962
|
+
function summarizeZodIssues(error51, maxIssues = 5) {
|
|
52963
|
+
return error51.issues.slice(0, maxIssues).map((issue2) => `${issue2.path.join(".") || "(root)"}: ${issue2.message}`).join("; ");
|
|
52964
|
+
}
|
|
52965
|
+
function recordLlmFailure(label, role, model, baseUrl, timeoutMs, elapsedMs, err) {
|
|
52966
|
+
const consecutiveFailures = (llmFailureStreaks.get(label) ?? 0) + 1;
|
|
52967
|
+
llmFailureStreaks.set(label, consecutiveFailures);
|
|
52968
|
+
logger.warn("LLM call failed \u2014 using non-LLM fallback", {
|
|
52969
|
+
label,
|
|
52970
|
+
role,
|
|
52971
|
+
model,
|
|
52972
|
+
provider: resolveProviderIdForLogging(baseUrl),
|
|
52973
|
+
timeoutMs,
|
|
52974
|
+
elapsedMs,
|
|
52975
|
+
timedOut: _isAbortOrTimeoutError(err),
|
|
52976
|
+
error: err,
|
|
52977
|
+
consecutiveFailures
|
|
52978
|
+
});
|
|
52979
|
+
return consecutiveFailures;
|
|
52980
|
+
}
|
|
52981
|
+
function recordLlmSuccess(label, model) {
|
|
52982
|
+
const priorFailures = llmFailureStreaks.get(label) ?? 0;
|
|
52983
|
+
if (priorFailures > 0) {
|
|
52984
|
+
logger.info("LLM call recovered", { label, model, afterFailures: priorFailures });
|
|
52985
|
+
}
|
|
52986
|
+
llmFailureStreaks.set(label, 0);
|
|
52987
|
+
}
|
|
52988
|
+
async function llmComplete(prompt, opts) {
|
|
52663
52989
|
if (!isLlmEnabled()) {
|
|
52664
52990
|
return { ok: false, error: "llm disabled" };
|
|
52665
52991
|
}
|
|
52666
52992
|
const llm = getLlmConfig({ modelRole: opts.modelRole });
|
|
52993
|
+
const role = opts.modelRole ?? "instruct";
|
|
52667
52994
|
const timeoutMs = opts.timeoutMs ?? llm.timeoutMs;
|
|
52995
|
+
const startedAt = Date.now();
|
|
52668
52996
|
try {
|
|
52669
52997
|
const result = await generateText({
|
|
52670
52998
|
model: buildProvider(llm),
|
|
@@ -52675,14 +53003,17 @@ async function llmComplete(prompt, opts = {}) {
|
|
|
52675
53003
|
abortSignal: timeoutSignal(timeoutMs)
|
|
52676
53004
|
});
|
|
52677
53005
|
const text2 = result.text ?? "";
|
|
52678
|
-
if (text2.length > 0)
|
|
53006
|
+
if (text2.length > 0) {
|
|
53007
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
52679
53008
|
return { ok: true, value: text2 };
|
|
53009
|
+
}
|
|
52680
53010
|
if (llm.disableThink) {
|
|
52681
53011
|
const reasoning = _reasoningToText(result);
|
|
52682
53012
|
if (reasoning.length > 0) {
|
|
52683
53013
|
logger.warn("llmComplete: empty content \u2014 recovered from reasoning channel", {
|
|
52684
53014
|
reasoningLen: reasoning.length
|
|
52685
53015
|
});
|
|
53016
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
52686
53017
|
return { ok: true, value: reasoning };
|
|
52687
53018
|
}
|
|
52688
53019
|
logger.warn("llm reasoning-recovery empty", {
|
|
@@ -52690,21 +53021,22 @@ async function llmComplete(prompt, opts = {}) {
|
|
|
52690
53021
|
finishReason: result?.finishReason ?? null
|
|
52691
53022
|
});
|
|
52692
53023
|
}
|
|
52693
|
-
|
|
52694
|
-
|
|
53024
|
+
const emptyErr = new Error("empty content (thinking model)");
|
|
53025
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, emptyErr);
|
|
53026
|
+
return { ok: false, error: emptyErr.message };
|
|
52695
53027
|
} catch (e) {
|
|
52696
|
-
|
|
52697
|
-
error: e.message
|
|
52698
|
-
});
|
|
53028
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, e);
|
|
52699
53029
|
return { ok: false, error: e.message };
|
|
52700
53030
|
}
|
|
52701
53031
|
}
|
|
52702
|
-
async function llmObject(prompt, schema, opts
|
|
53032
|
+
async function llmObject(prompt, schema, opts) {
|
|
52703
53033
|
if (!isLlmEnabled()) {
|
|
52704
53034
|
return { ok: false, error: "llm disabled" };
|
|
52705
53035
|
}
|
|
52706
53036
|
const llm = getLlmConfig({ modelRole: opts.modelRole });
|
|
53037
|
+
const role = opts.modelRole ?? "instruct";
|
|
52707
53038
|
const timeoutMs = opts.timeoutMs ?? llm.timeoutMs;
|
|
53039
|
+
const startedAt = Date.now();
|
|
52708
53040
|
let result = null;
|
|
52709
53041
|
try {
|
|
52710
53042
|
const useJsonSchema = llm.disableThink && await _checkJsonSchemaSupport();
|
|
@@ -52719,7 +53051,8 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
52719
53051
|
maxOutputTokens: llm.maxOutputTokens,
|
|
52720
53052
|
abortSignal: timeoutSignal(timeoutMs)
|
|
52721
53053
|
});
|
|
52722
|
-
logger.
|
|
53054
|
+
logger.debug("json_schema: constrained decoding used", { label: opts.label, model: llm.model });
|
|
53055
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
52723
53056
|
return { ok: true, value: result.object };
|
|
52724
53057
|
}
|
|
52725
53058
|
result = await generateObject({
|
|
@@ -52733,7 +53066,8 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
52733
53066
|
});
|
|
52734
53067
|
const validated = schema.safeParse(result.object);
|
|
52735
53068
|
if (validated.success) {
|
|
52736
|
-
logger.
|
|
53069
|
+
logger.debug("json_schema: fallback to json_object \u2014 validated", { label: opts.label, model: llm.model });
|
|
53070
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
52737
53071
|
return { ok: true, value: validated.data };
|
|
52738
53072
|
}
|
|
52739
53073
|
if (llm.disableThink) {
|
|
@@ -52746,15 +53080,17 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
52746
53080
|
logger.warn("llmObject: recovered object from reasoning channel (fallback path)", {
|
|
52747
53081
|
reasoningLen: reasoning.length
|
|
52748
53082
|
});
|
|
53083
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
52749
53084
|
return { ok: true, value: recovered.data };
|
|
52750
53085
|
}
|
|
52751
53086
|
}
|
|
52752
53087
|
}
|
|
52753
53088
|
}
|
|
52754
|
-
|
|
52755
|
-
|
|
53089
|
+
const validationErr = new Error("schema validation failed (fallback path)", {
|
|
53090
|
+
cause: summarizeZodIssues(validated.error)
|
|
52756
53091
|
});
|
|
52757
|
-
|
|
53092
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, validationErr);
|
|
53093
|
+
return { ok: false, error: validationErr.message };
|
|
52758
53094
|
} catch (e) {
|
|
52759
53095
|
if (llm.disableThink && !_isAbortOrTimeoutError(e)) {
|
|
52760
53096
|
const reasoning = _reasoningToText(result).length > 0 ? _reasoningToText(result) : _reasoningToText(e);
|
|
@@ -52766,6 +53102,7 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
52766
53102
|
logger.warn("llmObject: recovered object from reasoning channel", {
|
|
52767
53103
|
reasoningLen: reasoning.length
|
|
52768
53104
|
});
|
|
53105
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
52769
53106
|
return { ok: true, value: validated.data };
|
|
52770
53107
|
}
|
|
52771
53108
|
}
|
|
@@ -52775,19 +53112,18 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
52775
53112
|
finishReason: e?.finishReason ?? null
|
|
52776
53113
|
});
|
|
52777
53114
|
}
|
|
52778
|
-
|
|
52779
|
-
error: e.message
|
|
52780
|
-
});
|
|
53115
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, e);
|
|
52781
53116
|
return { ok: false, error: e.message };
|
|
52782
53117
|
}
|
|
52783
53118
|
}
|
|
52784
|
-
var _jsonSchemaSupported = null, testEnabledOverride = null, testBaseUrlOverride = null, llm;
|
|
53119
|
+
var _jsonSchemaSupported = null, testEnabledOverride = null, testBaseUrlOverride = null, llmFailureStreaks, llm;
|
|
52785
53120
|
var init_llm_client = __esm(() => {
|
|
52786
53121
|
init_dist6();
|
|
52787
53122
|
init_dist7();
|
|
52788
53123
|
init_dist();
|
|
52789
53124
|
init_config();
|
|
52790
53125
|
init_inference_providers();
|
|
53126
|
+
llmFailureStreaks = new Map;
|
|
52791
53127
|
llm = {
|
|
52792
53128
|
complete: llmComplete,
|
|
52793
53129
|
object: llmObject,
|
|
@@ -61800,7 +62136,7 @@ class MetricsCollector2 {
|
|
|
61800
62136
|
try {
|
|
61801
62137
|
writeFileSync(this.metricsPath, JSON.stringify(this.currentMetrics, null, 2));
|
|
61802
62138
|
} catch (error51) {
|
|
61803
|
-
logger.error("
|
|
62139
|
+
logger.error("Metrics: failed to save", error51, { path: this.metricsPath });
|
|
61804
62140
|
}
|
|
61805
62141
|
}
|
|
61806
62142
|
reset() {
|
|
@@ -61975,7 +62311,8 @@ class EmbeddingRateLimiter {
|
|
|
61975
62311
|
}
|
|
61976
62312
|
}
|
|
61977
62313
|
if (this.config.requestsPerDay && this.dailyRequestsWindow.length >= this.config.requestsPerDay) {
|
|
61978
|
-
logger.warn(
|
|
62314
|
+
logger.warn("EmbeddingRateLimiter: RPD limit reached, waiting 60s", {
|
|
62315
|
+
providerId: this.providerId,
|
|
61979
62316
|
rpd: this.config.requestsPerDay,
|
|
61980
62317
|
current: this.dailyRequestsWindow.length
|
|
61981
62318
|
});
|
|
@@ -64621,26 +64958,26 @@ var require_process = __commonJS((exports, module) => {
|
|
|
64621
64958
|
|
|
64622
64959
|
// ../../node_modules/detect-libc/lib/filesystem.js
|
|
64623
64960
|
var require_filesystem = __commonJS((exports, module) => {
|
|
64624
|
-
var
|
|
64961
|
+
var fs14 = __require("fs");
|
|
64625
64962
|
var LDD_PATH = "/usr/bin/ldd";
|
|
64626
64963
|
var SELF_PATH = "/proc/self/exe";
|
|
64627
64964
|
var MAX_LENGTH = 2048;
|
|
64628
|
-
var readFileSync2 = (
|
|
64629
|
-
const fd =
|
|
64965
|
+
var readFileSync2 = (path19) => {
|
|
64966
|
+
const fd = fs14.openSync(path19, "r");
|
|
64630
64967
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
64631
|
-
const bytesRead =
|
|
64632
|
-
|
|
64968
|
+
const bytesRead = fs14.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
64969
|
+
fs14.close(fd, () => {});
|
|
64633
64970
|
return buffer.subarray(0, bytesRead);
|
|
64634
64971
|
};
|
|
64635
|
-
var readFile = (
|
|
64636
|
-
|
|
64972
|
+
var readFile = (path19) => new Promise((resolve4, reject) => {
|
|
64973
|
+
fs14.open(path19, "r", (err, fd) => {
|
|
64637
64974
|
if (err) {
|
|
64638
64975
|
reject(err);
|
|
64639
64976
|
} else {
|
|
64640
64977
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
64641
|
-
|
|
64978
|
+
fs14.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
64642
64979
|
resolve4(buffer.subarray(0, bytesRead));
|
|
64643
|
-
|
|
64980
|
+
fs14.close(fd, () => {});
|
|
64644
64981
|
});
|
|
64645
64982
|
}
|
|
64646
64983
|
});
|
|
@@ -64745,11 +65082,11 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
64745
65082
|
}
|
|
64746
65083
|
return null;
|
|
64747
65084
|
};
|
|
64748
|
-
var familyFromInterpreterPath = (
|
|
64749
|
-
if (
|
|
64750
|
-
if (
|
|
65085
|
+
var familyFromInterpreterPath = (path19) => {
|
|
65086
|
+
if (path19) {
|
|
65087
|
+
if (path19.includes("/ld-musl-")) {
|
|
64751
65088
|
return MUSL;
|
|
64752
|
-
} else if (
|
|
65089
|
+
} else if (path19.includes("/ld-linux-")) {
|
|
64753
65090
|
return GLIBC;
|
|
64754
65091
|
}
|
|
64755
65092
|
}
|
|
@@ -64794,8 +65131,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
64794
65131
|
cachedFamilyInterpreter = null;
|
|
64795
65132
|
try {
|
|
64796
65133
|
const selfContent = await readFile(SELF_PATH);
|
|
64797
|
-
const
|
|
64798
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
65134
|
+
const path19 = interpreterPath(selfContent);
|
|
65135
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path19);
|
|
64799
65136
|
} catch (e) {}
|
|
64800
65137
|
return cachedFamilyInterpreter;
|
|
64801
65138
|
};
|
|
@@ -64806,8 +65143,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
64806
65143
|
cachedFamilyInterpreter = null;
|
|
64807
65144
|
try {
|
|
64808
65145
|
const selfContent = readFileSync2(SELF_PATH);
|
|
64809
|
-
const
|
|
64810
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
65146
|
+
const path19 = interpreterPath(selfContent);
|
|
65147
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path19);
|
|
64811
65148
|
} catch (e) {}
|
|
64812
65149
|
return cachedFamilyInterpreter;
|
|
64813
65150
|
};
|
|
@@ -66469,18 +66806,18 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
66469
66806
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
66470
66807
|
"@img/sharp-wasm32/sharp.node"
|
|
66471
66808
|
];
|
|
66472
|
-
var
|
|
66809
|
+
var path19;
|
|
66473
66810
|
var sharp;
|
|
66474
66811
|
var errors4 = [];
|
|
66475
|
-
for (
|
|
66812
|
+
for (path19 of paths) {
|
|
66476
66813
|
try {
|
|
66477
|
-
sharp = __require(
|
|
66814
|
+
sharp = __require(path19);
|
|
66478
66815
|
break;
|
|
66479
66816
|
} catch (err) {
|
|
66480
66817
|
errors4.push(err);
|
|
66481
66818
|
}
|
|
66482
66819
|
}
|
|
66483
|
-
if (sharp &&
|
|
66820
|
+
if (sharp && path19.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
66484
66821
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
66485
66822
|
err.code = "Unsupported CPU";
|
|
66486
66823
|
errors4.push(err);
|
|
@@ -66489,7 +66826,7 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
66489
66826
|
if (sharp) {
|
|
66490
66827
|
module.exports = sharp;
|
|
66491
66828
|
} else {
|
|
66492
|
-
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((
|
|
66829
|
+
const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((os9) => runtimePlatform.startsWith(os9));
|
|
66493
66830
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
66494
66831
|
errors4.forEach((err) => {
|
|
66495
66832
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -66502,9 +66839,9 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
66502
66839
|
const { found, expected } = isUnsupportedNodeRuntime();
|
|
66503
66840
|
help.push("- Please upgrade Node.js:", ` Found ${found}`, ` Requires ${expected}`);
|
|
66504
66841
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
66505
|
-
const [
|
|
66506
|
-
const libc =
|
|
66507
|
-
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=${
|
|
66842
|
+
const [os9, cpu] = runtimePlatform.split("-");
|
|
66843
|
+
const libc = os9.endsWith("musl") ? " --libc=musl" : "";
|
|
66844
|
+
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`);
|
|
66508
66845
|
} else {
|
|
66509
66846
|
help.push(`- Manually install libvips >= ${minimumLibvipsVersion}`, "- Add experimental WebAssembly-based dependencies:", " npm install --cpu=wasm32 sharp", " npm install @img/sharp-wasm32");
|
|
66510
66847
|
}
|
|
@@ -69342,15 +69679,15 @@ var require_color = __commonJS((exports, module) => {
|
|
|
69342
69679
|
};
|
|
69343
69680
|
}
|
|
69344
69681
|
function wrapConversion(toModel, graph) {
|
|
69345
|
-
const
|
|
69682
|
+
const path19 = [graph[toModel].parent, toModel];
|
|
69346
69683
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
69347
69684
|
let cur = graph[toModel].parent;
|
|
69348
69685
|
while (graph[cur].parent) {
|
|
69349
|
-
|
|
69686
|
+
path19.unshift(graph[cur].parent);
|
|
69350
69687
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
69351
69688
|
cur = graph[cur].parent;
|
|
69352
69689
|
}
|
|
69353
|
-
fn.conversion =
|
|
69690
|
+
fn.conversion = path19;
|
|
69354
69691
|
return fn;
|
|
69355
69692
|
}
|
|
69356
69693
|
function route(fromModel) {
|
|
@@ -69955,7 +70292,7 @@ var require_output = __commonJS((exports, module) => {
|
|
|
69955
70292
|
Copyright 2013 Lovell Fuller and others.
|
|
69956
70293
|
SPDX-License-Identifier: Apache-2.0
|
|
69957
70294
|
*/
|
|
69958
|
-
var
|
|
70295
|
+
var path19 = __require("path");
|
|
69959
70296
|
var is = require_is();
|
|
69960
70297
|
var sharp = require_sharp();
|
|
69961
70298
|
var formats = new Map([
|
|
@@ -69986,9 +70323,9 @@ var require_output = __commonJS((exports, module) => {
|
|
|
69986
70323
|
let err;
|
|
69987
70324
|
if (!is.string(fileOut)) {
|
|
69988
70325
|
err = new Error("Missing output file path");
|
|
69989
|
-
} else if (is.string(this.options.input.file) &&
|
|
70326
|
+
} else if (is.string(this.options.input.file) && path19.resolve(this.options.input.file) === path19.resolve(fileOut)) {
|
|
69990
70327
|
err = new Error("Cannot use same file for input and output");
|
|
69991
|
-
} else if (jp2Regex.test(
|
|
70328
|
+
} else if (jp2Regex.test(path19.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
69992
70329
|
err = errJp2Save();
|
|
69993
70330
|
}
|
|
69994
70331
|
if (err) {
|
|
@@ -77235,11 +77572,11 @@ var init_transformers_node = __esm(() => {
|
|
|
77235
77572
|
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}).`);
|
|
77236
77573
|
}
|
|
77237
77574
|
for (let i = 0;i < num_chunks; ++i) {
|
|
77238
|
-
const
|
|
77239
|
-
const fullPath = `${options.subfolder ?? ""}/${
|
|
77575
|
+
const path19 = `${baseName}_data${i === 0 ? "" : "_" + i}`;
|
|
77576
|
+
const fullPath = `${options.subfolder ?? ""}/${path19}`;
|
|
77240
77577
|
externalDataPromises.push(new Promise(async (resolve4, reject) => {
|
|
77241
77578
|
const data = await (0, _utils_hub_js__WEBPACK_IMPORTED_MODULE_5__.getModelFile)(pretrained_model_name_or_path, fullPath, true, options, return_path);
|
|
77242
|
-
resolve4(data instanceof Uint8Array ? { path:
|
|
77579
|
+
resolve4(data instanceof Uint8Array ? { path: path19, data } : path19);
|
|
77243
77580
|
}));
|
|
77244
77581
|
}
|
|
77245
77582
|
} else if (session_options.externalData !== undefined) {
|
|
@@ -90303,7 +90640,7 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90303
90640
|
const blob = new Blob([wav], { type: "audio/wav" });
|
|
90304
90641
|
return blob;
|
|
90305
90642
|
}
|
|
90306
|
-
async save(
|
|
90643
|
+
async save(path19) {
|
|
90307
90644
|
let fn;
|
|
90308
90645
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_BROWSER_ENV) {
|
|
90309
90646
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_WEBWORKER_ENV) {
|
|
@@ -90311,14 +90648,14 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90311
90648
|
}
|
|
90312
90649
|
fn = _core_js__WEBPACK_IMPORTED_MODULE_2__.saveBlob;
|
|
90313
90650
|
} else if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_FS_AVAILABLE) {
|
|
90314
|
-
fn = async (
|
|
90651
|
+
fn = async (path20, blob) => {
|
|
90315
90652
|
let buffer = await blob.arrayBuffer();
|
|
90316
|
-
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(
|
|
90653
|
+
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(path20, Buffer.from(buffer));
|
|
90317
90654
|
};
|
|
90318
90655
|
} else {
|
|
90319
90656
|
throw new Error("Unable to save because filesystem is disabled in this environment.");
|
|
90320
90657
|
}
|
|
90321
|
-
await fn(
|
|
90658
|
+
await fn(path19, this.toBlob());
|
|
90322
90659
|
}
|
|
90323
90660
|
}
|
|
90324
90661
|
},
|
|
@@ -90414,11 +90751,11 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90414
90751
|
function calculateReflectOffset(i, w) {
|
|
90415
90752
|
return Math.abs((i + w) % (2 * w) - w);
|
|
90416
90753
|
}
|
|
90417
|
-
function saveBlob(
|
|
90754
|
+
function saveBlob(path19, blob) {
|
|
90418
90755
|
const dataURL = URL.createObjectURL(blob);
|
|
90419
90756
|
const downloadLink = document.createElement("a");
|
|
90420
90757
|
downloadLink.href = dataURL;
|
|
90421
|
-
downloadLink.download =
|
|
90758
|
+
downloadLink.download = path19;
|
|
90422
90759
|
downloadLink.click();
|
|
90423
90760
|
downloadLink.remove();
|
|
90424
90761
|
URL.revokeObjectURL(dataURL);
|
|
@@ -91019,8 +91356,8 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
91019
91356
|
}
|
|
91020
91357
|
|
|
91021
91358
|
class FileCache {
|
|
91022
|
-
constructor(
|
|
91023
|
-
this.path =
|
|
91359
|
+
constructor(path19) {
|
|
91360
|
+
this.path = path19;
|
|
91024
91361
|
}
|
|
91025
91362
|
async match(request) {
|
|
91026
91363
|
let filePath = node_path__WEBPACK_IMPORTED_MODULE_1__["default"].join(this.path, request);
|
|
@@ -91776,20 +92113,20 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
91776
92113
|
}
|
|
91777
92114
|
return this;
|
|
91778
92115
|
}
|
|
91779
|
-
async save(
|
|
92116
|
+
async save(path19) {
|
|
91780
92117
|
if (IS_BROWSER_OR_WEBWORKER) {
|
|
91781
92118
|
if (_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_WEBWORKER_ENV) {
|
|
91782
92119
|
throw new Error("Unable to save an image from a Web Worker.");
|
|
91783
92120
|
}
|
|
91784
|
-
const extension =
|
|
92121
|
+
const extension = path19.split(".").pop().toLowerCase();
|
|
91785
92122
|
const mime = CONTENT_TYPE_MAP.get(extension) ?? "image/png";
|
|
91786
92123
|
const blob = await this.toBlob(mime);
|
|
91787
|
-
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(
|
|
92124
|
+
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(path19, blob);
|
|
91788
92125
|
} else if (!_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_FS_AVAILABLE) {
|
|
91789
92126
|
throw new Error("Unable to save the image because filesystem is disabled in this environment.");
|
|
91790
92127
|
} else {
|
|
91791
92128
|
const img = this.toSharp();
|
|
91792
|
-
return await img.toFile(
|
|
92129
|
+
return await img.toFile(path19);
|
|
91793
92130
|
}
|
|
91794
92131
|
}
|
|
91795
92132
|
toSharp() {
|
|
@@ -95278,16 +95615,16 @@ class LocalTransformersEmbeddingProvider {
|
|
|
95278
95615
|
const out = await extractor("test", { pooling: "mean", normalize: true });
|
|
95279
95616
|
const vec = Array.from(out.data);
|
|
95280
95617
|
if (!Array.isArray(vec) || vec.length !== this.dimensions) {
|
|
95281
|
-
logger.error(
|
|
95618
|
+
logger.error("LocalTransformersProvider: invalid embedding dimensions", undefined, { providerId: this.id, expected: this.dimensions, got: vec.length });
|
|
95282
95619
|
return false;
|
|
95283
95620
|
}
|
|
95284
95621
|
if (vec.some((v) => typeof v !== "number" || isNaN(v))) {
|
|
95285
|
-
logger.error(
|
|
95622
|
+
logger.error("LocalTransformersProvider: invalid embedding values (not numbers)", undefined, { providerId: this.id });
|
|
95286
95623
|
return false;
|
|
95287
95624
|
}
|
|
95288
95625
|
return true;
|
|
95289
95626
|
} catch (error51) {
|
|
95290
|
-
logger.error(
|
|
95627
|
+
logger.error("LocalTransformersProvider: provider unavailable", error51, { providerId: this.id });
|
|
95291
95628
|
return false;
|
|
95292
95629
|
}
|
|
95293
95630
|
}
|
|
@@ -95327,7 +95664,13 @@ async function withRetry(fn, config3, context2) {
|
|
|
95327
95664
|
lastError2 = error51;
|
|
95328
95665
|
if (attempt < config3.maxRetries) {
|
|
95329
95666
|
const delay2 = getRetryDelay(attempt, config3);
|
|
95330
|
-
logger.warn(
|
|
95667
|
+
logger.warn("EmbeddingProvider: operation failed, retrying", {
|
|
95668
|
+
context: context2,
|
|
95669
|
+
attempt: attempt + 1,
|
|
95670
|
+
maxAttempts: config3.maxRetries + 1,
|
|
95671
|
+
delayMs: delay2,
|
|
95672
|
+
error: lastError2
|
|
95673
|
+
});
|
|
95331
95674
|
await sleep(delay2);
|
|
95332
95675
|
}
|
|
95333
95676
|
}
|
|
@@ -95643,7 +95986,7 @@ var init_provider = __esm(() => {
|
|
|
95643
95986
|
return output;
|
|
95644
95987
|
}, this.retryConfig, `[${this.id}] embedBatchDirect (${texts.length} texts)`), this.timeout, `[${this.id}] embedBatchDirect`);
|
|
95645
95988
|
} catch (error51) {
|
|
95646
|
-
logger.warn(
|
|
95989
|
+
logger.warn("EmbeddingProvider: Ollama batch endpoint unavailable, falling back to sequential embeds", { providerId: this.id, textCount: texts.length, error: error51 });
|
|
95647
95990
|
const embeddings = [];
|
|
95648
95991
|
let consecutiveFailures = 0;
|
|
95649
95992
|
for (const text2 of texts) {
|
|
@@ -95682,11 +96025,11 @@ var init_provider = __esm(() => {
|
|
|
95682
96025
|
});
|
|
95683
96026
|
clearTimeout(timeoutId);
|
|
95684
96027
|
if (!response.ok) {
|
|
95685
|
-
logger.error(
|
|
96028
|
+
logger.error("EmbeddingProvider: Ollama API returned non-OK status", undefined, { providerId: this.id, status: response.status });
|
|
95686
96029
|
return false;
|
|
95687
96030
|
}
|
|
95688
96031
|
} catch {
|
|
95689
|
-
logger.error(
|
|
96032
|
+
logger.error("EmbeddingProvider: Ollama service unreachable", undefined, { providerId: this.id, baseURL: this.baseURL, timeoutMs: 2000 });
|
|
95690
96033
|
return false;
|
|
95691
96034
|
}
|
|
95692
96035
|
}
|
|
@@ -95696,16 +96039,16 @@ var init_provider = __esm(() => {
|
|
|
95696
96039
|
if (Array.isArray(embedding)) {
|
|
95697
96040
|
this.lastDimensionMismatch = new DimensionMismatchError(this.id, this.dimensions, embedding.length);
|
|
95698
96041
|
}
|
|
95699
|
-
logger.error(
|
|
96042
|
+
logger.error("EmbeddingProvider: invalid embedding dimensions", undefined, { providerId: this.id, expected: this.dimensions, got: embedding.length });
|
|
95700
96043
|
return false;
|
|
95701
96044
|
}
|
|
95702
96045
|
if (!embedding.every((v) => typeof v === "number" && !isNaN(v))) {
|
|
95703
|
-
logger.error(
|
|
96046
|
+
logger.error("EmbeddingProvider: invalid embedding values (not numbers)", undefined, { providerId: this.id });
|
|
95704
96047
|
return false;
|
|
95705
96048
|
}
|
|
95706
96049
|
return true;
|
|
95707
96050
|
} catch (error51) {
|
|
95708
|
-
logger.error(
|
|
96051
|
+
logger.error("EmbeddingProvider: provider unavailable", error51, { providerId: this.id });
|
|
95709
96052
|
return false;
|
|
95710
96053
|
}
|
|
95711
96054
|
}
|
|
@@ -101018,7 +101361,7 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a;
|
|
|
101018
101361
|
function ns(e = Yo, t = Yo) {
|
|
101019
101362
|
return (r) => e(t(r));
|
|
101020
101363
|
}
|
|
101021
|
-
function
|
|
101364
|
+
function os9({ dataPath: e, modelName: t, args: r, runtimeDataModel: n }) {
|
|
101022
101365
|
let i = { modelName: t, args: r ?? {} }, o = dp(e);
|
|
101023
101366
|
if (!o || o.length === 0)
|
|
101024
101367
|
return i;
|
|
@@ -101323,10 +101666,10 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a;
|
|
|
101323
101666
|
super(t, "P2023", r);
|
|
101324
101667
|
}
|
|
101325
101668
|
};
|
|
101326
|
-
var
|
|
101669
|
+
var fs14 = new WeakMap;
|
|
101327
101670
|
function Ep(e) {
|
|
101328
|
-
let t =
|
|
101329
|
-
return t || (t = Object.entries(e),
|
|
101671
|
+
let t = fs14.get(e);
|
|
101672
|
+
return t || (t = Object.entries(e), fs14.set(e, t)), t;
|
|
101330
101673
|
}
|
|
101331
101674
|
function hs(e, t, r) {
|
|
101332
101675
|
switch (t.type) {
|
|
@@ -104891,7 +105234,7 @@ new PrismaClient({
|
|
|
104891
105234
|
let m = await es(this, d);
|
|
104892
105235
|
if (!d.model)
|
|
104893
105236
|
return m;
|
|
104894
|
-
let g =
|
|
105237
|
+
let g = os9({ dataPath: d.dataPath, modelName: d.model, args: d.args, runtimeDataModel: this._runtimeDataModel });
|
|
104895
105238
|
return Wo({ result: m, modelName: g.modelName, args: g.args, extensions: this._extensions, runtimeDataModel: this._runtimeDataModel, globalOmit: this._globalOmit });
|
|
104896
105239
|
};
|
|
104897
105240
|
return this._tracingHelper.runInChildSpan(s.operation, () => new zl.AsyncResource("prisma-client-request").runInAsyncScope(() => a(o)));
|
|
@@ -105294,7 +105637,7 @@ var require_prisma = __commonJS((exports) => {
|
|
|
105294
105637
|
Prisma.JsonNull = JsonNull2;
|
|
105295
105638
|
Prisma.AnyNull = AnyNull2;
|
|
105296
105639
|
Prisma.NullTypes = NullTypes2;
|
|
105297
|
-
var
|
|
105640
|
+
var path19 = __require("path");
|
|
105298
105641
|
exports.Prisma.TransactionIsolationLevel = makeStrictEnum2({
|
|
105299
105642
|
ReadUncommitted: "ReadUncommitted",
|
|
105300
105643
|
ReadCommitted: "ReadCommitted",
|
|
@@ -107921,7 +108264,7 @@ function getPrismaClient2() {
|
|
|
107921
108264
|
const pg2 = _adapters.loadPg();
|
|
107922
108265
|
const { PrismaPg: PrismaPg2 } = _adapters.loadPrismaPg();
|
|
107923
108266
|
const pool = new pg2.Pool({ connectionString: databaseUrl, max: 10, idleTimeoutMillis: 30000, connectionTimeoutMillis: 5000 });
|
|
107924
|
-
pool.on("error", (error51) => logger.error("
|
|
108267
|
+
pool.on("error", (error51) => logger.error("prisma-client: unexpected PG pool error", error51, { poolMax: 10 }));
|
|
107925
108268
|
prismaPool = pool;
|
|
107926
108269
|
prismaInstance = new import_prisma.PrismaClient({ adapter: new PrismaPg2(pool) });
|
|
107927
108270
|
logger.info("Prisma Client initialized with PostgreSQL");
|
|
@@ -108230,7 +108573,10 @@ var init_config2 = __esm(() => {
|
|
|
108230
108573
|
"local"
|
|
108231
108574
|
]);
|
|
108232
108575
|
if (!SELECTABLE_PROVIDERS.has(selectedProvider)) {
|
|
108233
|
-
logger.warn(
|
|
108576
|
+
logger.warn("EmbeddingConfig: selected provider has no runtime entry, falling back to priority order", {
|
|
108577
|
+
selectedProvider,
|
|
108578
|
+
source: process.env.EMBEDDING_PROVIDER ? "EMBEDDING_PROVIDER env" : "config.json embedding.provider"
|
|
108579
|
+
});
|
|
108234
108580
|
}
|
|
108235
108581
|
embeddingProviders = {
|
|
108236
108582
|
google: (() => {
|
|
@@ -108270,7 +108616,12 @@ var init_config2 = __esm(() => {
|
|
|
108270
108616
|
const envDimensions = Number.isInteger(rawEnvDimensions) && rawEnvDimensions > 0 ? rawEnvDimensions : undefined;
|
|
108271
108617
|
const resolvedDimensions = resolveEmbeddingDimensions(model, file2?.dimensions, envDimensions);
|
|
108272
108618
|
if (resolvedDimensions.correctedFrom !== undefined) {
|
|
108273
|
-
logger.warn(
|
|
108619
|
+
logger.warn("EmbeddingConfig: ollama config.json dimensions mismatch corrected", {
|
|
108620
|
+
provider: "ollama",
|
|
108621
|
+
model,
|
|
108622
|
+
configuredDimensions: resolvedDimensions.correctedFrom,
|
|
108623
|
+
correctedDimensions: resolvedDimensions.dimensions
|
|
108624
|
+
});
|
|
108274
108625
|
}
|
|
108275
108626
|
return {
|
|
108276
108627
|
provider: "ollama",
|
|
@@ -108422,8 +108773,8 @@ class EmbeddingService {
|
|
|
108422
108773
|
dimensions: this.provider.dimensions
|
|
108423
108774
|
});
|
|
108424
108775
|
} catch (error51) {
|
|
108425
|
-
logger.error("Failed to initialize embedding service", error51);
|
|
108426
|
-
logger.warn("Embedding service will use fallback mode");
|
|
108776
|
+
logger.error("Failed to initialize embedding service", error51, { stage: "initialize" });
|
|
108777
|
+
logger.warn("Embedding service will use fallback mode", { stage: "initialize" });
|
|
108427
108778
|
}
|
|
108428
108779
|
}
|
|
108429
108780
|
async ensureInitialized() {
|
|
@@ -108505,7 +108856,7 @@ async function tryCreateProvider(config3, providerId, skipHealthCheck) {
|
|
|
108505
108856
|
return { provider };
|
|
108506
108857
|
}
|
|
108507
108858
|
function refuseOnDimensionMismatch(providerId, mismatch) {
|
|
108508
|
-
logger.error(
|
|
108859
|
+
logger.error("EmbeddingProvider: configured provider failed with a dimension mismatch, refusing to fall through", mismatch, { providerId, configuredDimensions: mismatch.expected, modelDimensions: mismatch.got });
|
|
108509
108860
|
throw mismatch;
|
|
108510
108861
|
}
|
|
108511
108862
|
async function createEmbeddingProvider(options = {}) {
|
|
@@ -108604,6 +108955,7 @@ Write the hypothetical implementation paragraph.`;
|
|
|
108604
108955
|
}
|
|
108605
108956
|
async function rewriteQuery(query, surface, opts = {}) {
|
|
108606
108957
|
const res = await surface.object(rewritePrompt(query), QueryRewriteSchema, {
|
|
108958
|
+
label: "query-rewrite",
|
|
108607
108959
|
system: REWRITE_SYSTEM,
|
|
108608
108960
|
timeoutMs: opts.timeoutMs
|
|
108609
108961
|
});
|
|
@@ -108616,6 +108968,7 @@ async function rewriteQuery(query, surface, opts = {}) {
|
|
|
108616
108968
|
}
|
|
108617
108969
|
async function hyde(query, surface, embedFn, opts = {}) {
|
|
108618
108970
|
const text2 = await surface.complete(hydePrompt(query), {
|
|
108971
|
+
label: "hyde",
|
|
108619
108972
|
system: HYDE_SYSTEM,
|
|
108620
108973
|
timeoutMs: opts.timeoutMs
|
|
108621
108974
|
});
|
|
@@ -108629,7 +108982,7 @@ async function hyde(query, surface, embedFn, opts = {}) {
|
|
|
108629
108982
|
return vec;
|
|
108630
108983
|
} catch (e) {
|
|
108631
108984
|
logger.warn("hyde embed failed \u2014 skipping HyDE stream", {
|
|
108632
|
-
error: e
|
|
108985
|
+
error: e
|
|
108633
108986
|
});
|
|
108634
108987
|
return null;
|
|
108635
108988
|
}
|
|
@@ -110357,7 +110710,7 @@ class KeywordSearchPg {
|
|
|
110357
110710
|
`);
|
|
110358
110711
|
this.trigramAvailable = true;
|
|
110359
110712
|
} catch (error51) {
|
|
110360
|
-
logger.warn("pg_trgm unavailable \u2014 trigram RRF stream disabled on PG", {
|
|
110713
|
+
logger.warn("pg_trgm unavailable \u2014 trigram RRF stream disabled on PG", { error: error51 });
|
|
110361
110714
|
this.trigramAvailable = false;
|
|
110362
110715
|
}
|
|
110363
110716
|
logger.info("PostgreSQL keyword search initialized", {
|
|
@@ -110896,7 +111249,8 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
110896
111249
|
this.schemaDimensions = providerDimensions;
|
|
110897
111250
|
const { rows } = await client.query(`SELECT tablename FROM pg_tables WHERE tablename = $1`, [this.tableName]);
|
|
110898
111251
|
if (rows.length === 0) {
|
|
110899
|
-
logger.warn(
|
|
111252
|
+
logger.warn("PostgresVectorStore: table not found, creating fallback table", {
|
|
111253
|
+
tableName: this.tableName,
|
|
110900
111254
|
note: 'Run "prisma migrate deploy" to create tables via migrations'
|
|
110901
111255
|
});
|
|
110902
111256
|
await this.createFallbackTable(client, providerDimensions);
|
|
@@ -110933,10 +111287,12 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
110933
111287
|
if (projects.length === 0)
|
|
110934
111288
|
continue;
|
|
110935
111289
|
const otherDim = tablename.match(/_([0-9]+)d$/)?.[1];
|
|
110936
|
-
logger.warn(
|
|
111290
|
+
logger.warn("PostgresVectorStore: orphaned chunks detected, embedding model likely changed, reindex required", {
|
|
110937
111291
|
currentTable: this.tableName,
|
|
110938
111292
|
currentCount,
|
|
111293
|
+
currentDim,
|
|
110939
111294
|
orphanedTable: tablename,
|
|
111295
|
+
orphanedDim: otherDim,
|
|
110940
111296
|
affectedProjects: projects.map((p) => ({ projectId: p.project_id, chunks: p.n }))
|
|
110941
111297
|
});
|
|
110942
111298
|
}
|
|
@@ -111080,7 +111436,7 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
111080
111436
|
logger.warn("[postgres] Sub-batch embedding failed, falling back per-document", {
|
|
111081
111437
|
subBatchIndex: Math.floor(i / EMBED_SUB_BATCH_SIZE),
|
|
111082
111438
|
count: subBatch.length,
|
|
111083
|
-
error: error51
|
|
111439
|
+
error: error51
|
|
111084
111440
|
});
|
|
111085
111441
|
}
|
|
111086
111442
|
if (embeddings) {
|
|
@@ -111092,7 +111448,7 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
111092
111448
|
logger.warn("[postgres] Sub-batch insert failed, falling back per-document", {
|
|
111093
111449
|
subBatchIndex: Math.floor(i / EMBED_SUB_BATCH_SIZE),
|
|
111094
111450
|
count: subBatch.length,
|
|
111095
|
-
error: error51
|
|
111451
|
+
error: error51
|
|
111096
111452
|
});
|
|
111097
111453
|
}
|
|
111098
111454
|
}
|
|
@@ -111105,7 +111461,7 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
111105
111461
|
totalFailed++;
|
|
111106
111462
|
logger.warn("[postgres] Skipping document due to embedding/insert error", {
|
|
111107
111463
|
id: doc2.id,
|
|
111108
|
-
error: singleError
|
|
111464
|
+
error: singleError
|
|
111109
111465
|
});
|
|
111110
111466
|
}
|
|
111111
111467
|
}
|
|
@@ -111777,7 +112133,9 @@ class SearchAnalyticsPg {
|
|
|
111777
112133
|
}
|
|
111778
112134
|
trackSearch(event) {
|
|
111779
112135
|
this.trackSearchAsync(event).catch((err) => {
|
|
111780
|
-
logger.error("Failed to track search event", err
|
|
112136
|
+
logger.error("Failed to track search event", err, {
|
|
112137
|
+
projectId: event.projectId
|
|
112138
|
+
});
|
|
111781
112139
|
});
|
|
111782
112140
|
}
|
|
111783
112141
|
async trackSearchAsync(event) {
|
|
@@ -111802,7 +112160,9 @@ class SearchAnalyticsPg {
|
|
|
111802
112160
|
event.score || null
|
|
111803
112161
|
]);
|
|
111804
112162
|
} catch (error51) {
|
|
111805
|
-
logger.error("Failed to track search event in PostgreSQL", error51
|
|
112163
|
+
logger.error("Failed to track search event in PostgreSQL", error51, {
|
|
112164
|
+
projectId: event.projectId
|
|
112165
|
+
});
|
|
111806
112166
|
}
|
|
111807
112167
|
}
|
|
111808
112168
|
async recordQuery(query, projectId, resultsCount = 0, duration3 = 0, cacheHit = false) {
|
|
@@ -114403,7 +114763,11 @@ class GraphStorePg {
|
|
|
114403
114763
|
`;
|
|
114404
114764
|
return rows[0] ? rowToEdge(rows[0]) : null;
|
|
114405
114765
|
} catch (error51) {
|
|
114406
|
-
logger.error("Failed to create edge", error51
|
|
114766
|
+
logger.error("Failed to create edge", error51, {
|
|
114767
|
+
sourceId: edge.sourceId,
|
|
114768
|
+
targetId: edge.targetId,
|
|
114769
|
+
relationType: edge.relationType
|
|
114770
|
+
});
|
|
114407
114771
|
return null;
|
|
114408
114772
|
}
|
|
114409
114773
|
}
|
|
@@ -114999,7 +115363,7 @@ class PgSynapseSessionStore {
|
|
|
114999
115363
|
} catch (e) {
|
|
115000
115364
|
this.hydrateFailedAt = Date.now();
|
|
115001
115365
|
logger.warn("PgSynapseSessionStore hydrate failed (best-effort)", {
|
|
115002
|
-
error: e
|
|
115366
|
+
error: e
|
|
115003
115367
|
});
|
|
115004
115368
|
} finally {
|
|
115005
115369
|
this.hydrating = null;
|
|
@@ -115134,7 +115498,7 @@ class PgSynapseSessionStore {
|
|
|
115134
115498
|
const next = prev.then(fn).catch((e) => {
|
|
115135
115499
|
logger.warn("PgSynapseSessionStore write failed (best-effort)", {
|
|
115136
115500
|
key,
|
|
115137
|
-
error: e
|
|
115501
|
+
error: e
|
|
115138
115502
|
});
|
|
115139
115503
|
});
|
|
115140
115504
|
this.inflight.set(key, next);
|
|
@@ -115240,7 +115604,7 @@ class SessionRegistry {
|
|
|
115240
115604
|
try {
|
|
115241
115605
|
this.store?.save(session);
|
|
115242
115606
|
} catch (error51) {
|
|
115243
|
-
logger.warn("
|
|
115607
|
+
logger.warn("SessionRegistry: store save failed", { sessionId: session.sessionId, error: error51 });
|
|
115244
115608
|
}
|
|
115245
115609
|
return session;
|
|
115246
115610
|
}
|
|
@@ -115248,7 +115612,7 @@ class SessionRegistry {
|
|
|
115248
115612
|
try {
|
|
115249
115613
|
await this.store?.ensureReady();
|
|
115250
115614
|
} catch (error51) {
|
|
115251
|
-
logger.warn("
|
|
115615
|
+
logger.warn("SessionRegistry: store ensureReady failed", { error: error51 });
|
|
115252
115616
|
}
|
|
115253
115617
|
}
|
|
115254
115618
|
async getAsync(sessionId, now2 = Date.now()) {
|
|
@@ -115269,7 +115633,7 @@ class SessionRegistry {
|
|
|
115269
115633
|
session = loaded;
|
|
115270
115634
|
}
|
|
115271
115635
|
} catch (error51) {
|
|
115272
|
-
logger.warn("
|
|
115636
|
+
logger.warn("SessionRegistry: store load failed", { sessionId, error: error51 });
|
|
115273
115637
|
}
|
|
115274
115638
|
}
|
|
115275
115639
|
if (!session)
|
|
@@ -115279,7 +115643,7 @@ class SessionRegistry {
|
|
|
115279
115643
|
try {
|
|
115280
115644
|
this.store?.delete(sessionId);
|
|
115281
115645
|
} catch (error51) {
|
|
115282
|
-
logger.warn("
|
|
115646
|
+
logger.warn("SessionRegistry: store delete (expired) failed", { sessionId, error: error51 });
|
|
115283
115647
|
}
|
|
115284
115648
|
return null;
|
|
115285
115649
|
}
|
|
@@ -115301,7 +115665,7 @@ class SessionRegistry {
|
|
|
115301
115665
|
try {
|
|
115302
115666
|
this.store?.save(session);
|
|
115303
115667
|
} catch (error51) {
|
|
115304
|
-
logger.warn("
|
|
115668
|
+
logger.warn("SessionRegistry: store save (updateTaskContext) failed", { sessionId, error: error51 });
|
|
115305
115669
|
}
|
|
115306
115670
|
return session;
|
|
115307
115671
|
}
|
|
@@ -115328,7 +115692,7 @@ class SessionRegistry {
|
|
|
115328
115692
|
try {
|
|
115329
115693
|
this.store?.recordAccess(sessionId, memoryId, nextCount);
|
|
115330
115694
|
} catch (error51) {
|
|
115331
|
-
logger.warn("
|
|
115695
|
+
logger.warn("SessionRegistry: store recordAccess failed", { sessionId, memoryId, error: error51 });
|
|
115332
115696
|
}
|
|
115333
115697
|
}
|
|
115334
115698
|
delete(sessionId) {
|
|
@@ -115336,7 +115700,7 @@ class SessionRegistry {
|
|
|
115336
115700
|
try {
|
|
115337
115701
|
this.store?.delete(sessionId);
|
|
115338
115702
|
} catch (error51) {
|
|
115339
|
-
logger.warn("
|
|
115703
|
+
logger.warn("SessionRegistry: store delete failed", { sessionId, error: error51 });
|
|
115340
115704
|
}
|
|
115341
115705
|
return removed;
|
|
115342
115706
|
}
|
|
@@ -115364,7 +115728,7 @@ function getSessionRegistry() {
|
|
|
115364
115728
|
const { getSessionStore: getSessionStore2 } = (init_session_store(), __toCommonJS(exports_session_store));
|
|
115365
115729
|
store2 = getSessionStore2();
|
|
115366
115730
|
} catch (error51) {
|
|
115367
|
-
logger.warn("
|
|
115731
|
+
logger.warn("SessionRegistry: store init failed, falling back to MemorySessionStore", { error: error51 });
|
|
115368
115732
|
const { MemorySessionStore: MemorySessionStore2 } = (init_session_store(), __toCommonJS(exports_session_store));
|
|
115369
115733
|
store2 = new MemorySessionStore2;
|
|
115370
115734
|
}
|
|
@@ -116181,19 +116545,22 @@ class LLMJudgeReranker {
|
|
|
116181
116545
|
const tail = results.slice(k);
|
|
116182
116546
|
const prompt = buildPrompt(query, head);
|
|
116183
116547
|
let verdict;
|
|
116548
|
+
let verdictError;
|
|
116184
116549
|
try {
|
|
116185
|
-
const res = await this.llm.object(prompt, RerankVerdictSchema, { modelRole: "code" });
|
|
116550
|
+
const res = await this.llm.object(prompt, RerankVerdictSchema, { label: "reranker", modelRole: "code" });
|
|
116186
116551
|
verdict = res.ok ? res.value ?? null : null;
|
|
116552
|
+
verdictError = res.ok ? undefined : res.error;
|
|
116187
116553
|
} catch (e) {
|
|
116188
116554
|
logger.warn("LLMJudgeReranker threw \u2014 degrading to input order", {
|
|
116189
116555
|
query,
|
|
116190
|
-
error: e
|
|
116556
|
+
error: e
|
|
116191
116557
|
});
|
|
116192
116558
|
return results;
|
|
116193
116559
|
}
|
|
116194
116560
|
if (!verdict) {
|
|
116195
116561
|
logger.warn("LLMJudgeReranker got {ok:false} \u2014 degrading to input order", {
|
|
116196
|
-
query
|
|
116562
|
+
query,
|
|
116563
|
+
error: verdictError
|
|
116197
116564
|
});
|
|
116198
116565
|
return results;
|
|
116199
116566
|
}
|
|
@@ -116992,10 +117359,10 @@ var init_chunker_code = __esm(() => {
|
|
|
116992
117359
|
});
|
|
116993
117360
|
|
|
116994
117361
|
// ../../packages/core/dist/services/search/smart-chunker.js
|
|
116995
|
-
import
|
|
117362
|
+
import path19 from "path";
|
|
116996
117363
|
function smartChunk(content, filePath, config3 = {}) {
|
|
116997
117364
|
const cfg = { ...DEFAULT_CONFIG, ...config3 };
|
|
116998
|
-
const ext2 =
|
|
117365
|
+
const ext2 = path19.extname(filePath).toLowerCase();
|
|
116999
117366
|
const relativePath = filePath;
|
|
117000
117367
|
const fileImports = isCodeFile(ext2) ? extractFileImports(content, ext2) : undefined;
|
|
117001
117368
|
let chunks;
|
|
@@ -117333,8 +117700,8 @@ var init_embedding_freshness = __esm(() => {
|
|
|
117333
117700
|
});
|
|
117334
117701
|
|
|
117335
117702
|
// ../../packages/core/dist/services/search/project-indexer.js
|
|
117336
|
-
import
|
|
117337
|
-
import
|
|
117703
|
+
import fs14 from "fs/promises";
|
|
117704
|
+
import path20 from "path";
|
|
117338
117705
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
117339
117706
|
async function runWithIndexLock(lockMap, projectId, work) {
|
|
117340
117707
|
const prevLock = lockMap.get(projectId);
|
|
@@ -117377,7 +117744,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
117377
117744
|
dot: false
|
|
117378
117745
|
});
|
|
117379
117746
|
const filteredFiles = files.filter((file2) => {
|
|
117380
|
-
const relativePath =
|
|
117747
|
+
const relativePath = path20.relative(projectPath, file2);
|
|
117381
117748
|
const shouldIgnore = ig.ignores(relativePath);
|
|
117382
117749
|
if (shouldIgnore) {
|
|
117383
117750
|
logger.debug("Ignoring file per .gitignore during indexing", {
|
|
@@ -117417,7 +117784,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
117417
117784
|
});
|
|
117418
117785
|
}
|
|
117419
117786
|
}
|
|
117420
|
-
const indexedFilesList = filteredFiles.map((f) =>
|
|
117787
|
+
const indexedFilesList = filteredFiles.map((f) => path20.relative(projectPath, f));
|
|
117421
117788
|
await deps.indexManager.updateIndexMetadata(projectId, projectPath, indexedFilesList);
|
|
117422
117789
|
logger.info("Project indexing completed", {
|
|
117423
117790
|
projectId,
|
|
@@ -117547,7 +117914,7 @@ async function ensureFreshIndex(deps, projectId, projectPath, options = {}) {
|
|
|
117547
117914
|
let errors4 = 0;
|
|
117548
117915
|
for (const relativeFilePath of filesToReindex) {
|
|
117549
117916
|
try {
|
|
117550
|
-
const fullPath =
|
|
117917
|
+
const fullPath = path20.join(projectPath, relativeFilePath);
|
|
117551
117918
|
const result = await deps.indexFile(fullPath, projectId, projectPath, centralityMap);
|
|
117552
117919
|
filesIndexed++;
|
|
117553
117920
|
chunksIndexed += result.chunks;
|
|
@@ -117607,8 +117974,8 @@ async function checkSearchAdmission(deps, projectId, projectPath) {
|
|
|
117607
117974
|
}
|
|
117608
117975
|
async function indexFile(deps, filePath, projectId, projectRoot, centralityMap) {
|
|
117609
117976
|
projectId = await getProjectIdentityAliasResolver().resolve(projectId);
|
|
117610
|
-
const content = await
|
|
117611
|
-
const relativePath =
|
|
117977
|
+
const content = await fs14.readFile(filePath, "utf-8");
|
|
117978
|
+
const relativePath = path20.relative(projectRoot, filePath);
|
|
117612
117979
|
const maxFileSize = config.get("security").maxFileSize || 1024 * 1024;
|
|
117613
117980
|
if (content.length > maxFileSize) {
|
|
117614
117981
|
logger.warn("File too large, skipping", {
|
|
@@ -117628,7 +117995,7 @@ async function indexFile(deps, filePath, projectId, projectRoot, centralityMap)
|
|
|
117628
117995
|
chunkIndex: i,
|
|
117629
117996
|
totalChunks: chunks.length,
|
|
117630
117997
|
type: chunk.type,
|
|
117631
|
-
language:
|
|
117998
|
+
language: path20.extname(filePath).slice(1),
|
|
117632
117999
|
lineStart: chunk.lineStart,
|
|
117633
118000
|
lineEnd: chunk.lineEnd,
|
|
117634
118001
|
label: chunk.label,
|
|
@@ -118039,7 +118406,7 @@ class TaskEnvelopeService {
|
|
|
118039
118406
|
errors4.push("prime");
|
|
118040
118407
|
logger.warn("synapse_task_begin: prime sub-step failed", {
|
|
118041
118408
|
sessionId,
|
|
118042
|
-
error: err
|
|
118409
|
+
error: err
|
|
118043
118410
|
});
|
|
118044
118411
|
}
|
|
118045
118412
|
}
|
|
@@ -118062,7 +118429,7 @@ class TaskEnvelopeService {
|
|
|
118062
118429
|
errors4.push("search");
|
|
118063
118430
|
logger.warn("synapse_task_begin: search sub-step failed", {
|
|
118064
118431
|
sessionId,
|
|
118065
|
-
error: err
|
|
118432
|
+
error: err
|
|
118066
118433
|
});
|
|
118067
118434
|
}
|
|
118068
118435
|
if (firstHitFile) {
|
|
@@ -118085,7 +118452,7 @@ class TaskEnvelopeService {
|
|
|
118085
118452
|
errors4.push("prefetch");
|
|
118086
118453
|
logger.warn("synapse_task_begin: prefetch sub-step failed", {
|
|
118087
118454
|
sessionId,
|
|
118088
|
-
error: err
|
|
118455
|
+
error: err
|
|
118089
118456
|
});
|
|
118090
118457
|
}
|
|
118091
118458
|
}
|
|
@@ -118096,7 +118463,7 @@ class TaskEnvelopeService {
|
|
|
118096
118463
|
errors4.push("access");
|
|
118097
118464
|
logger.warn("synapse_task_begin: access sub-step failed", {
|
|
118098
118465
|
sessionId,
|
|
118099
|
-
error: err
|
|
118466
|
+
error: err
|
|
118100
118467
|
});
|
|
118101
118468
|
}
|
|
118102
118469
|
}
|
|
@@ -118439,7 +118806,7 @@ async function applySynapseState(deps, baseResults, query, projectId, sessionId,
|
|
|
118439
118806
|
logger.warn("Synapse session lookup failed \u2014 using stateless search", {
|
|
118440
118807
|
sessionId,
|
|
118441
118808
|
projectId,
|
|
118442
|
-
error: error51
|
|
118809
|
+
error: error51
|
|
118443
118810
|
});
|
|
118444
118811
|
return baseResults;
|
|
118445
118812
|
}
|
|
@@ -118460,7 +118827,7 @@ async function applySynapseState(deps, baseResults, query, projectId, sessionId,
|
|
|
118460
118827
|
logger.warn("Synapse processing failed \u2014 using stateless search", {
|
|
118461
118828
|
sessionId,
|
|
118462
118829
|
projectId,
|
|
118463
|
-
error: error51
|
|
118830
|
+
error: error51
|
|
118464
118831
|
});
|
|
118465
118832
|
return baseResults;
|
|
118466
118833
|
}
|
|
@@ -119355,7 +119722,7 @@ class RelationExtractor {
|
|
|
119355
119722
|
} catch (error51) {
|
|
119356
119723
|
logger.warn("RelationExtractor: extraction failed", {
|
|
119357
119724
|
memoryId,
|
|
119358
|
-
error: error51
|
|
119725
|
+
error: error51
|
|
119359
119726
|
});
|
|
119360
119727
|
}
|
|
119361
119728
|
return edgesCreated;
|
|
@@ -119802,7 +120169,7 @@ class MemoryGraphService {
|
|
|
119802
120169
|
} catch (error51) {
|
|
119803
120170
|
logger.warn("Graph update failed after memory store", {
|
|
119804
120171
|
memoryId,
|
|
119805
|
-
error: error51
|
|
120172
|
+
error: error51
|
|
119806
120173
|
});
|
|
119807
120174
|
}
|
|
119808
120175
|
}
|
|
@@ -119818,7 +120185,7 @@ class MemoryGraphService {
|
|
|
119818
120185
|
} catch (error51) {
|
|
119819
120186
|
logger.warn("Graph cleanup failed after memory delete", {
|
|
119820
120187
|
memoryId,
|
|
119821
|
-
error: error51
|
|
120188
|
+
error: error51
|
|
119822
120189
|
});
|
|
119823
120190
|
}
|
|
119824
120191
|
}
|
|
@@ -119967,7 +120334,7 @@ async function consolidateWindow(candidates, llm2, opts = {}) {
|
|
|
119967
120334
|
if (!llm2.isEnabled())
|
|
119968
120335
|
return null;
|
|
119969
120336
|
const prompt = buildPrompt2(window2);
|
|
119970
|
-
const result = await llm2.object(prompt, ConsolidatedBatchSchema);
|
|
120337
|
+
const result = await llm2.object(prompt, ConsolidatedBatchSchema, { label: "memory-consolidation" });
|
|
119971
120338
|
if (!result.ok || !result.value)
|
|
119972
120339
|
return null;
|
|
119973
120340
|
const batch = {
|
|
@@ -120068,7 +120435,7 @@ class MemoryConsolidationJob {
|
|
|
120068
120435
|
} catch (error51) {
|
|
120069
120436
|
logger.warn("Memory consolidation skipped", {
|
|
120070
120437
|
trigger,
|
|
120071
|
-
error: error51
|
|
120438
|
+
error: error51
|
|
120072
120439
|
});
|
|
120073
120440
|
} finally {
|
|
120074
120441
|
this.running = false;
|
|
@@ -120091,7 +120458,7 @@ class MemoryConsolidationJob {
|
|
|
120091
120458
|
candidates = await Promise.resolve(repo.listConsolidationCandidates(staleSinceMs, 500));
|
|
120092
120459
|
} catch (e) {
|
|
120093
120460
|
logger.warn("consolidation: candidate list failed (decay)", {
|
|
120094
|
-
error: e
|
|
120461
|
+
error: e
|
|
120095
120462
|
});
|
|
120096
120463
|
return 0;
|
|
120097
120464
|
}
|
|
@@ -120113,7 +120480,7 @@ class MemoryConsolidationJob {
|
|
|
120113
120480
|
} catch (e) {
|
|
120114
120481
|
logger.warn("consolidation: decay write failed", {
|
|
120115
120482
|
id: row.id,
|
|
120116
|
-
error: e
|
|
120483
|
+
error: e
|
|
120117
120484
|
});
|
|
120118
120485
|
}
|
|
120119
120486
|
}
|
|
@@ -120142,14 +120509,14 @@ class MemoryConsolidationJob {
|
|
|
120142
120509
|
} catch (e) {
|
|
120143
120510
|
logger.warn("consolidation: soft-delete failed", {
|
|
120144
120511
|
id: row.id,
|
|
120145
|
-
error: e
|
|
120512
|
+
error: e
|
|
120146
120513
|
});
|
|
120147
120514
|
}
|
|
120148
120515
|
}
|
|
120149
120516
|
}
|
|
120150
120517
|
} catch (e) {
|
|
120151
120518
|
logger.warn("consolidation: prune scan failed", {
|
|
120152
|
-
error: e
|
|
120519
|
+
error: e
|
|
120153
120520
|
});
|
|
120154
120521
|
}
|
|
120155
120522
|
return pruned;
|
|
@@ -120160,7 +120527,7 @@ class MemoryConsolidationJob {
|
|
|
120160
120527
|
candidates = await Promise.resolve(repo.listConsolidationCandidates(staleSinceMs, 200));
|
|
120161
120528
|
} catch (e) {
|
|
120162
120529
|
logger.warn("consolidation: candidate list failed (merge)", {
|
|
120163
|
-
error: e
|
|
120530
|
+
error: e
|
|
120164
120531
|
});
|
|
120165
120532
|
return { merged: 0, batchesCreated: 0 };
|
|
120166
120533
|
}
|
|
@@ -120186,7 +120553,7 @@ class MemoryConsolidationJob {
|
|
|
120186
120553
|
} catch (e) {
|
|
120187
120554
|
logger.warn("consolidation: merge insert failed", {
|
|
120188
120555
|
batchId: batch.id,
|
|
120189
|
-
error: e
|
|
120556
|
+
error: e
|
|
120190
120557
|
});
|
|
120191
120558
|
return { merged: 0, batchesCreated: 0 };
|
|
120192
120559
|
}
|
|
@@ -120199,7 +120566,7 @@ class MemoryConsolidationJob {
|
|
|
120199
120566
|
logger.warn("consolidation: addSupercedesEdge failed", {
|
|
120200
120567
|
newId,
|
|
120201
120568
|
sourceId,
|
|
120202
|
-
error: e
|
|
120569
|
+
error: e
|
|
120203
120570
|
});
|
|
120204
120571
|
}
|
|
120205
120572
|
}
|
|
@@ -120239,7 +120606,7 @@ class MemoryConsolidationJob {
|
|
|
120239
120606
|
return result;
|
|
120240
120607
|
} catch (e) {
|
|
120241
120608
|
logger.warn("consolidation: promote (PG) failed", {
|
|
120242
|
-
error: e
|
|
120609
|
+
error: e
|
|
120243
120610
|
});
|
|
120244
120611
|
return 0;
|
|
120245
120612
|
}
|
|
@@ -120278,19 +120645,22 @@ class SalienceJudge {
|
|
|
120278
120645
|
}
|
|
120279
120646
|
const prompt = buildPrompt3(trimmed, type);
|
|
120280
120647
|
let verdict;
|
|
120648
|
+
let verdictError;
|
|
120281
120649
|
try {
|
|
120282
|
-
const res = await this.llm.object(prompt, SalienceSchema);
|
|
120650
|
+
const res = await this.llm.object(prompt, SalienceSchema, { label: "salience-judge" });
|
|
120283
120651
|
verdict = res.ok ? res.value ?? null : null;
|
|
120652
|
+
verdictError = res.ok ? undefined : res.error;
|
|
120284
120653
|
} catch (e) {
|
|
120285
120654
|
logger.warn("SalienceJudge threw \u2014 degrading to neutral default", {
|
|
120286
120655
|
type,
|
|
120287
|
-
error: e
|
|
120656
|
+
error: e
|
|
120288
120657
|
});
|
|
120289
120658
|
return { salience: NEUTRAL_SALIENCE, source: "default" };
|
|
120290
120659
|
}
|
|
120291
120660
|
if (!verdict) {
|
|
120292
120661
|
logger.warn("SalienceJudge got {ok:false} \u2014 degrading to neutral default", {
|
|
120293
|
-
type
|
|
120662
|
+
type,
|
|
120663
|
+
error: verdictError
|
|
120294
120664
|
});
|
|
120295
120665
|
return { salience: NEUTRAL_SALIENCE, source: "default" };
|
|
120296
120666
|
}
|
|
@@ -120505,7 +120875,8 @@ class MemoryController {
|
|
|
120505
120875
|
}
|
|
120506
120876
|
} catch (err) {
|
|
120507
120877
|
logger.warn("Graph enrichment failed", {
|
|
120508
|
-
|
|
120878
|
+
projectId,
|
|
120879
|
+
error: err
|
|
120509
120880
|
});
|
|
120510
120881
|
}
|
|
120511
120882
|
}
|
|
@@ -120707,7 +121078,7 @@ class CodeCompressor {
|
|
|
120707
121078
|
}
|
|
120708
121079
|
const prompt = buildLlmCompressPrompt(content, language3, targetRatio, preservedElements);
|
|
120709
121080
|
try {
|
|
120710
|
-
const res = await this.llmCompleteFn(prompt, { timeoutMs, modelRole: "code" });
|
|
121081
|
+
const res = await this.llmCompleteFn(prompt, { label: "code-compressor", timeoutMs, modelRole: "code" });
|
|
120711
121082
|
if (res.ok && typeof res.value === "string" && res.value.trim().length > 0 && res.value.length <= content.length) {
|
|
120712
121083
|
compressed = res.value;
|
|
120713
121084
|
compressionSource = "llm";
|
|
@@ -120747,7 +121118,10 @@ class CodeCompressor {
|
|
|
120747
121118
|
});
|
|
120748
121119
|
return compressedContent;
|
|
120749
121120
|
} catch (error51) {
|
|
120750
|
-
logger.error("Code compression failed", error51
|
|
121121
|
+
logger.error("Code compression failed", error51, {
|
|
121122
|
+
strategy: useStrategy,
|
|
121123
|
+
originalLength: content.length
|
|
121124
|
+
});
|
|
120751
121125
|
return CompressedContent.identity(content);
|
|
120752
121126
|
}
|
|
120753
121127
|
}
|
|
@@ -121057,9 +121431,9 @@ class TokenMetrics {
|
|
|
121057
121431
|
}
|
|
121058
121432
|
throw new Error("Model not found in models.dev");
|
|
121059
121433
|
} catch (error51) {
|
|
121060
|
-
logger.warn("
|
|
121434
|
+
logger.warn("TokenMetrics: failed to fetch pricing from models.dev, using fallback", {
|
|
121061
121435
|
modelId,
|
|
121062
|
-
error: error51
|
|
121436
|
+
error: error51
|
|
121063
121437
|
});
|
|
121064
121438
|
const fallback = FALLBACK_PRICING2[modelId] || FALLBACK_PRICING2["gpt-4"];
|
|
121065
121439
|
this.pricingCache.set(modelId, {
|
|
@@ -122179,16 +122553,16 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
122179
122553
|
const seen = new Set;
|
|
122180
122554
|
const out = [];
|
|
122181
122555
|
for (const e of httpEdges) {
|
|
122182
|
-
const
|
|
122183
|
-
if (!
|
|
122556
|
+
const path21 = e.route;
|
|
122557
|
+
if (!path21)
|
|
122184
122558
|
continue;
|
|
122185
122559
|
const method = (e.method ?? "ANY").toUpperCase();
|
|
122186
|
-
const key = method + " " +
|
|
122560
|
+
const key = method + " " + path21;
|
|
122187
122561
|
if (seen.has(key))
|
|
122188
122562
|
continue;
|
|
122189
122563
|
seen.add(key);
|
|
122190
122564
|
out.push({
|
|
122191
|
-
path:
|
|
122565
|
+
path: path21,
|
|
122192
122566
|
method: e.method,
|
|
122193
122567
|
file: e.fromFile,
|
|
122194
122568
|
handler: e.targetFqn ?? e.symbolName
|
|
@@ -122199,12 +122573,12 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
122199
122573
|
continue;
|
|
122200
122574
|
const parsed = parseRouteName(d.name);
|
|
122201
122575
|
const method = parsed?.method ?? "ANY";
|
|
122202
|
-
const
|
|
122203
|
-
const key = method + " " +
|
|
122576
|
+
const path21 = parsed?.path ?? d.name;
|
|
122577
|
+
const key = method + " " + path21;
|
|
122204
122578
|
if (seen.has(key))
|
|
122205
122579
|
continue;
|
|
122206
122580
|
seen.add(key);
|
|
122207
|
-
out.push({ path:
|
|
122581
|
+
out.push({ path: path21, method: parsed?.method, file: d.filePath, handler: d.name });
|
|
122208
122582
|
}
|
|
122209
122583
|
for (const d of defs) {
|
|
122210
122584
|
const parsed = parseRouteName(d.name);
|
|
@@ -122425,8 +122799,8 @@ __export(exports_symbol_graph_service, {
|
|
|
122425
122799
|
symbolGraphService: () => symbolGraphService,
|
|
122426
122800
|
SymbolGraphService: () => SymbolGraphService
|
|
122427
122801
|
});
|
|
122428
|
-
import
|
|
122429
|
-
import
|
|
122802
|
+
import path21 from "path";
|
|
122803
|
+
import fs15 from "fs/promises";
|
|
122430
122804
|
|
|
122431
122805
|
class SymbolGraphService {
|
|
122432
122806
|
identityLookup;
|
|
@@ -122597,9 +122971,9 @@ class SymbolGraphService {
|
|
|
122597
122971
|
return null;
|
|
122598
122972
|
const workspace = graphSnapshot.workspace;
|
|
122599
122973
|
const arch = await this.computeArchitectureMapSafe(graphSnapshot.architecture).catch((err) => {
|
|
122600
|
-
logger.warn("
|
|
122974
|
+
logger.warn("SymbolGraphService: getProjectMap architecture map failed, skipping", {
|
|
122601
122975
|
projectId,
|
|
122602
|
-
error: err
|
|
122976
|
+
error: err
|
|
122603
122977
|
});
|
|
122604
122978
|
return null;
|
|
122605
122979
|
});
|
|
@@ -122754,7 +123128,7 @@ class SymbolGraphService {
|
|
|
122754
123128
|
async readSnippet(relativePath, lineStart, lineEnd, projectId) {
|
|
122755
123129
|
try {
|
|
122756
123130
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
122757
|
-
const content = await
|
|
123131
|
+
const content = await fs15.readFile(absolutePath, "utf-8");
|
|
122758
123132
|
const lines = content.split(`
|
|
122759
123133
|
`);
|
|
122760
123134
|
return lines.slice(Math.max(0, lineStart - 1), Math.min(lines.length, lineEnd)).join(`
|
|
@@ -122766,7 +123140,7 @@ class SymbolGraphService {
|
|
|
122766
123140
|
async readContext(relativePath, lineNumber, contextLines, projectId) {
|
|
122767
123141
|
try {
|
|
122768
123142
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
122769
|
-
const content = await
|
|
123143
|
+
const content = await fs15.readFile(absolutePath, "utf-8");
|
|
122770
123144
|
const lines = content.split(`
|
|
122771
123145
|
`);
|
|
122772
123146
|
const start = Math.max(0, lineNumber - contextLines - 1);
|
|
@@ -122779,7 +123153,7 @@ class SymbolGraphService {
|
|
|
122779
123153
|
}
|
|
122780
123154
|
async resolveToAbsolute(relativePath, projectId) {
|
|
122781
123155
|
const root = await this.getProjectRoot(projectId);
|
|
122782
|
-
return root ?
|
|
123156
|
+
return root ? path21.resolve(root, relativePath) : relativePath;
|
|
122783
123157
|
}
|
|
122784
123158
|
async getProjectRoot(projectId) {
|
|
122785
123159
|
const cached2 = this.projectRootCache.get(projectId);
|
|
@@ -122874,7 +123248,7 @@ class ContextController {
|
|
|
122874
123248
|
});
|
|
122875
123249
|
}
|
|
122876
123250
|
} catch (err) {
|
|
122877
|
-
logger.warn("
|
|
123251
|
+
logger.warn("ContextController: graph prefilter failed", { projectId, query, error: err });
|
|
122878
123252
|
}
|
|
122879
123253
|
}
|
|
122880
123254
|
const [searchResult, memories] = await Promise.all([
|
|
@@ -123028,9 +123402,11 @@ class ContextController {
|
|
|
123028
123402
|
});
|
|
123029
123403
|
return result.memories;
|
|
123030
123404
|
} catch (error51) {
|
|
123031
|
-
logger.warn("
|
|
123032
|
-
|
|
123033
|
-
|
|
123405
|
+
logger.warn("ContextController: memory search failed, continuing without memories", {
|
|
123406
|
+
projectId: opts.projectId,
|
|
123407
|
+
sessionId: opts.sessionId,
|
|
123408
|
+
query: query.slice(0, 30),
|
|
123409
|
+
error: error51
|
|
123034
123410
|
});
|
|
123035
123411
|
return [];
|
|
123036
123412
|
}
|
|
@@ -123352,7 +123728,7 @@ function warnSandboxUnavailable() {
|
|
|
123352
123728
|
return;
|
|
123353
123729
|
_warnedAboutNoSandbox = true;
|
|
123354
123730
|
const missingTool = process.platform === "darwin" ? "sandbox-exec" : "docker";
|
|
123355
|
-
logger.warn(
|
|
123731
|
+
logger.warn("Sandbox: no sandbox tool found for auto mode, falling back to best-effort containment", { missingTool, platform: process.platform, effectiveMode: "none" });
|
|
123356
123732
|
}
|
|
123357
123733
|
function getSandboxMode() {
|
|
123358
123734
|
const env4 = process.env.MASSA_AI_EXECUTOR_SANDBOX ?? "auto";
|
|
@@ -124267,7 +124643,10 @@ class ExecutorController {
|
|
|
124267
124643
|
}
|
|
124268
124644
|
};
|
|
124269
124645
|
} catch (error51) {
|
|
124270
|
-
logger.error("batch_execute failed", error51
|
|
124646
|
+
logger.error("batch_execute failed", error51, {
|
|
124647
|
+
commandCount: commands.length,
|
|
124648
|
+
concurrency: effectiveConcurrency
|
|
124649
|
+
});
|
|
124271
124650
|
return {
|
|
124272
124651
|
success: false,
|
|
124273
124652
|
error: `batch_execute failed: ${error51.message}`
|
|
@@ -124557,31 +124936,31 @@ class TracePathService {
|
|
|
124557
124936
|
const chains = [];
|
|
124558
124937
|
const seen = new Set;
|
|
124559
124938
|
let walks = 0;
|
|
124560
|
-
const walk = (fqn,
|
|
124939
|
+
const walk = (fqn, path22) => {
|
|
124561
124940
|
if (chains.length >= CHAIN_CAP)
|
|
124562
124941
|
return;
|
|
124563
124942
|
if (walks >= MAX_WALKS)
|
|
124564
124943
|
return;
|
|
124565
124944
|
walks++;
|
|
124566
|
-
const key =
|
|
124945
|
+
const key = path22.join("\u2192");
|
|
124567
124946
|
if (seen.has(key))
|
|
124568
124947
|
return;
|
|
124569
124948
|
seen.add(key);
|
|
124570
124949
|
const next = adj.get(fqn);
|
|
124571
124950
|
if (!next || next.length === 0 || !whoHasChild.has(fqn)) {
|
|
124572
|
-
if (
|
|
124573
|
-
chains.push(
|
|
124951
|
+
if (path22.length > 1)
|
|
124952
|
+
chains.push(path22.map((n) => this.fqnToName(n)).join(" \u2192 "));
|
|
124574
124953
|
return;
|
|
124575
124954
|
}
|
|
124576
124955
|
for (const child of next) {
|
|
124577
124956
|
if (chains.length >= CHAIN_CAP || walks >= MAX_WALKS)
|
|
124578
124957
|
return;
|
|
124579
|
-
if (
|
|
124580
|
-
const cycled = [...
|
|
124958
|
+
if (path22.includes(child)) {
|
|
124959
|
+
const cycled = [...path22, `${this.fqnToName(child)}\u21BA`];
|
|
124581
124960
|
chains.push(cycled.map((n) => n).join(" \u2192 "));
|
|
124582
124961
|
continue;
|
|
124583
124962
|
}
|
|
124584
|
-
walk(child, [...
|
|
124963
|
+
walk(child, [...path22, child]);
|
|
124585
124964
|
}
|
|
124586
124965
|
};
|
|
124587
124966
|
for (const seed of seeds) {
|
|
@@ -126604,9 +126983,9 @@ var init_inference_probe = __esm(() => {
|
|
|
126604
126983
|
});
|
|
126605
126984
|
|
|
126606
126985
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
126607
|
-
import
|
|
126986
|
+
import fs16 from "fs/promises";
|
|
126608
126987
|
import { existsSync as existsSync3 } from "fs";
|
|
126609
|
-
import
|
|
126988
|
+
import path22 from "path";
|
|
126610
126989
|
|
|
126611
126990
|
class LocalHealthChecker {
|
|
126612
126991
|
dataDir = config.get("dataDir");
|
|
@@ -126684,10 +127063,10 @@ class LocalHealthChecker {
|
|
|
126684
127063
|
const start = Date.now();
|
|
126685
127064
|
try {
|
|
126686
127065
|
if (!existsSync3(this.dataDir))
|
|
126687
|
-
await
|
|
126688
|
-
const probe =
|
|
126689
|
-
await
|
|
126690
|
-
await
|
|
127066
|
+
await fs16.mkdir(this.dataDir, { recursive: true });
|
|
127067
|
+
const probe = path22.join(this.dataDir, ".health-check-test");
|
|
127068
|
+
await fs16.writeFile(probe, "ok");
|
|
127069
|
+
await fs16.unlink(probe);
|
|
126691
127070
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
126692
127071
|
} catch (error51) {
|
|
126693
127072
|
return { available: false, latency: Date.now() - start, error: `Data directory error: ${error51.message}` };
|
|
@@ -126823,7 +127202,7 @@ class PgJobStore {
|
|
|
126823
127202
|
} catch (e) {
|
|
126824
127203
|
this.recovered = true;
|
|
126825
127204
|
logger.warn("PgJobStore markStaleRunningFailed failed (best-effort)", {
|
|
126826
|
-
error: e
|
|
127205
|
+
error: e
|
|
126827
127206
|
});
|
|
126828
127207
|
}
|
|
126829
127208
|
}
|
|
@@ -126849,7 +127228,7 @@ class PgJobStore {
|
|
|
126849
127228
|
logger.info("PgJobStore hydrated", { rows: this.mirror.size });
|
|
126850
127229
|
} catch (e) {
|
|
126851
127230
|
logger.warn("PgJobStore hydrate failed (best-effort)", {
|
|
126852
|
-
error: e
|
|
127231
|
+
error: e
|
|
126853
127232
|
});
|
|
126854
127233
|
} finally {
|
|
126855
127234
|
this.hydrating = null;
|
|
@@ -126872,7 +127251,7 @@ class PgJobStore {
|
|
|
126872
127251
|
next.catch((e) => {
|
|
126873
127252
|
logger.warn("PgJobStore.save failed (best-effort)", {
|
|
126874
127253
|
jobId: job.jobId,
|
|
126875
|
-
error: e
|
|
127254
|
+
error: e
|
|
126876
127255
|
});
|
|
126877
127256
|
});
|
|
126878
127257
|
}
|
|
@@ -127004,7 +127383,7 @@ class PgJobStore {
|
|
|
127004
127383
|
}
|
|
127005
127384
|
} catch (e) {
|
|
127006
127385
|
logger.warn("PgJobStore markStaleRunningFailed failed (best-effort)", {
|
|
127007
|
-
error: e
|
|
127386
|
+
error: e
|
|
127008
127387
|
});
|
|
127009
127388
|
}
|
|
127010
127389
|
})();
|
|
@@ -127194,7 +127573,13 @@ class IndexJobTracker {
|
|
|
127194
127573
|
const stale = hbMs != null && hbMs < cutoff || hbMs == null && startedMs != null && startedMs < cutoff;
|
|
127195
127574
|
if (!stale)
|
|
127196
127575
|
continue;
|
|
127197
|
-
logger.warn(
|
|
127576
|
+
logger.warn("indexJobTracker: reaping stale running job", {
|
|
127577
|
+
jobId: job.jobId,
|
|
127578
|
+
projectId: job.projectId,
|
|
127579
|
+
staleMs,
|
|
127580
|
+
heartbeatAt: job.heartbeatAt?.toISOString() ?? "n/a",
|
|
127581
|
+
startedAt: job.startedAt?.toISOString() ?? "n/a"
|
|
127582
|
+
});
|
|
127198
127583
|
this.jobs.set(job.jobId, job);
|
|
127199
127584
|
const reapedPrevStatus = job.status;
|
|
127200
127585
|
this.setResult(job.jobId, undefined, "heartbeat stale (possible crash/OOM)");
|
|
@@ -127219,7 +127604,7 @@ class IndexJobTracker {
|
|
|
127219
127604
|
try {
|
|
127220
127605
|
this.store?.save(job);
|
|
127221
127606
|
} catch (err) {
|
|
127222
|
-
logger.warn(
|
|
127607
|
+
logger.warn("indexJobTracker: job store write failed on setResult", { jobId, error: err });
|
|
127223
127608
|
}
|
|
127224
127609
|
if (prevStatus === "pending") {
|
|
127225
127610
|
this.publishStateChange(job, prevStatus);
|
|
@@ -127249,7 +127634,7 @@ class IndexJobTracker {
|
|
|
127249
127634
|
const survivors = remaining.slice(0, this.MAX_JOBS);
|
|
127250
127635
|
const overflow = remaining.slice(this.MAX_JOBS);
|
|
127251
127636
|
for (const job of overflow) {
|
|
127252
|
-
logger.warn(
|
|
127637
|
+
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 });
|
|
127253
127638
|
this.jobs.delete(job.jobId);
|
|
127254
127639
|
}
|
|
127255
127640
|
}
|
|
@@ -127486,7 +127871,7 @@ class PgScheduledJobStore {
|
|
|
127486
127871
|
logger.info("PgScheduledJobStore hydrated", { rows: this.mirror.size });
|
|
127487
127872
|
} catch (e) {
|
|
127488
127873
|
logger.warn("PgScheduledJobStore hydrate failed (best-effort)", {
|
|
127489
|
-
error: e
|
|
127874
|
+
error: e
|
|
127490
127875
|
});
|
|
127491
127876
|
} finally {
|
|
127492
127877
|
this.hydrating = null;
|
|
@@ -127500,9 +127885,10 @@ class PgScheduledJobStore {
|
|
|
127500
127885
|
try {
|
|
127501
127886
|
await action();
|
|
127502
127887
|
} catch (e) {
|
|
127503
|
-
logger.warn(
|
|
127888
|
+
logger.warn("PgScheduledJobStore mutation failed (best-effort)", {
|
|
127504
127889
|
id,
|
|
127505
|
-
|
|
127890
|
+
operation,
|
|
127891
|
+
error: e
|
|
127506
127892
|
});
|
|
127507
127893
|
}
|
|
127508
127894
|
};
|
|
@@ -127755,7 +128141,7 @@ class Scheduler {
|
|
|
127755
128141
|
this.timer = setInterval(() => {
|
|
127756
128142
|
this.tick().catch((e) => {
|
|
127757
128143
|
logger.warn("Scheduler tick failed (swallowed)", {
|
|
127758
|
-
error: e
|
|
128144
|
+
error: e
|
|
127759
128145
|
});
|
|
127760
128146
|
});
|
|
127761
128147
|
}, this.tickIntervalMs);
|
|
@@ -127870,7 +128256,7 @@ class Scheduler {
|
|
|
127870
128256
|
logger.warn("Scheduler: job handler threw (caught)", {
|
|
127871
128257
|
id: job.id,
|
|
127872
128258
|
jobKind: job.jobKind,
|
|
127873
|
-
error:
|
|
128259
|
+
error: e
|
|
127874
128260
|
});
|
|
127875
128261
|
} finally {
|
|
127876
128262
|
if (succeeded) {
|
|
@@ -127889,7 +128275,7 @@ class Scheduler {
|
|
|
127889
128275
|
} catch (e) {
|
|
127890
128276
|
logger.warn("Scheduler: persist after fire failed", {
|
|
127891
128277
|
id: job.id,
|
|
127892
|
-
error: e
|
|
128278
|
+
error: e
|
|
127893
128279
|
});
|
|
127894
128280
|
}
|
|
127895
128281
|
this.running.delete(job.jobKind);
|
|
@@ -127909,6 +128295,8 @@ class Scheduler {
|
|
|
127909
128295
|
enabled: j.enabled,
|
|
127910
128296
|
nextRunAt: j.nextRunAt,
|
|
127911
128297
|
lastRunAt: j.lastRunAt,
|
|
128298
|
+
lastSuccessAt: j.lastSuccessAt ?? null,
|
|
128299
|
+
consecutiveFailures: j.consecutiveFailures ?? 0,
|
|
127912
128300
|
due: j.enabled && j.nextRunAt <= now2,
|
|
127913
128301
|
currentlyRunning: this.running.has(j.jobKind)
|
|
127914
128302
|
}))
|
|
@@ -128410,7 +128798,7 @@ class PgObservationStore {
|
|
|
128410
128798
|
} catch (e) {
|
|
128411
128799
|
this.hydrateFailedAt = Date.now();
|
|
128412
128800
|
logger.warn("PgObservationStore hydrate failed (best-effort)", {
|
|
128413
|
-
error: e
|
|
128801
|
+
error: e
|
|
128414
128802
|
});
|
|
128415
128803
|
} finally {
|
|
128416
128804
|
this.hydrating = null;
|
|
@@ -128461,7 +128849,7 @@ class PgObservationStore {
|
|
|
128461
128849
|
const next = prev.then(fn).catch((e) => {
|
|
128462
128850
|
logger.warn("PgObservationStore.insert failed (best-effort)", {
|
|
128463
128851
|
id: key,
|
|
128464
|
-
error: e
|
|
128852
|
+
error: e
|
|
128465
128853
|
});
|
|
128466
128854
|
});
|
|
128467
128855
|
this.inflight.set(key, next);
|
|
@@ -128775,7 +129163,7 @@ async function enrichWithLlm(candidates, observations, surface) {
|
|
|
128775
129163
|
const prompt = buildEnrichmentPrompt(candidates, observations);
|
|
128776
129164
|
let enrichment = null;
|
|
128777
129165
|
try {
|
|
128778
|
-
const res = await surface.object(prompt, ProposalEnrichmentSchema);
|
|
129166
|
+
const res = await surface.object(prompt, ProposalEnrichmentSchema, { label: "auto-improve" });
|
|
128779
129167
|
if (!res.ok || !res.value || !Array.isArray(res.value.items)) {
|
|
128780
129168
|
return { candidates, used: false };
|
|
128781
129169
|
}
|
|
@@ -128971,7 +129359,7 @@ async function runOnce(job, projectId) {
|
|
|
128971
129359
|
try {
|
|
128972
129360
|
observations = job.observationStore.listRecent(projectId, job.maxWindow);
|
|
128973
129361
|
} catch (e) {
|
|
128974
|
-
logger.warn("auto-improve: listRecent failed", { projectId, error: e
|
|
129362
|
+
logger.warn("auto-improve: listRecent failed", { projectId, error: e });
|
|
128975
129363
|
return noop2;
|
|
128976
129364
|
}
|
|
128977
129365
|
if (observations.length < 2)
|
|
@@ -128986,7 +129374,7 @@ async function runOnce(job, projectId) {
|
|
|
128986
129374
|
if (res.used)
|
|
128987
129375
|
source = "llm";
|
|
128988
129376
|
} catch (e) {
|
|
128989
|
-
logger.warn("auto-improve: enrichWithLlm threw (silent)", { projectId, error: e
|
|
129377
|
+
logger.warn("auto-improve: enrichWithLlm threw (silent)", { projectId, error: e });
|
|
128990
129378
|
}
|
|
128991
129379
|
const seen = new Set;
|
|
128992
129380
|
const unique = candidates.filter((c) => {
|
|
@@ -129034,7 +129422,7 @@ async function runOnce(job, projectId) {
|
|
|
129034
129422
|
} catch (e) {
|
|
129035
129423
|
if (e instanceof SearchServiceError)
|
|
129036
129424
|
throw e;
|
|
129037
|
-
logger.warn("proposal:auto-approved:threw", { id: r.id, projectId, error: e
|
|
129425
|
+
logger.warn("proposal:auto-approved:threw", { id: r.id, projectId, error: e });
|
|
129038
129426
|
}
|
|
129039
129427
|
}
|
|
129040
129428
|
result.proposalsApplied = applied;
|
|
@@ -129063,7 +129451,7 @@ async function approve(job, id, projectId, source = "rule-based") {
|
|
|
129063
129451
|
appliedMemoryId = await applyProposal(job, row);
|
|
129064
129452
|
} catch (e) {
|
|
129065
129453
|
const reason = e instanceof ApplyRejection ? e.reason : "apply-failed";
|
|
129066
|
-
logger.warn("proposal:apply-failed", { id, projectId: row.projectId, reason, error: e
|
|
129454
|
+
logger.warn("proposal:apply-failed", { id, projectId: row.projectId, reason, error: e });
|
|
129067
129455
|
return { ok: false, reason };
|
|
129068
129456
|
}
|
|
129069
129457
|
let updated;
|
|
@@ -129198,9 +129586,9 @@ class AutoImproveJob {
|
|
|
129198
129586
|
return;
|
|
129199
129587
|
this.newSinceRun = 0;
|
|
129200
129588
|
this.lastRunAt = now2;
|
|
129201
|
-
this.runOnce(projectId).catch((e) => logger.warn("auto-improve: runOnce failed (silent)", { projectId, error: e
|
|
129589
|
+
this.runOnce(projectId).catch((e) => logger.warn("auto-improve: runOnce failed (silent)", { projectId, error: e }));
|
|
129202
129590
|
} catch (e) {
|
|
129203
|
-
logger.warn("auto-improve: maybeRun swallowed", { projectId, error: e
|
|
129591
|
+
logger.warn("auto-improve: maybeRun swallowed", { projectId, error: e });
|
|
129204
129592
|
}
|
|
129205
129593
|
}
|
|
129206
129594
|
async runOnce(projectId) {
|
|
@@ -129300,13 +129688,13 @@ class ObservationConsolidationJob {
|
|
|
129300
129688
|
this.runOnce(projectId).catch((e) => {
|
|
129301
129689
|
logger.warn("observation consolidation: runOnce failed (silent)", {
|
|
129302
129690
|
projectId,
|
|
129303
|
-
error: e
|
|
129691
|
+
error: e
|
|
129304
129692
|
});
|
|
129305
129693
|
});
|
|
129306
129694
|
} catch (e) {
|
|
129307
129695
|
logger.warn("observation consolidation: maybeRun swallowed", {
|
|
129308
129696
|
projectId,
|
|
129309
|
-
error: e
|
|
129697
|
+
error: e
|
|
129310
129698
|
});
|
|
129311
129699
|
}
|
|
129312
129700
|
}
|
|
@@ -129330,7 +129718,7 @@ class ObservationConsolidationJob {
|
|
|
129330
129718
|
} catch (e) {
|
|
129331
129719
|
logger.warn("observation consolidation: listRecent failed", {
|
|
129332
129720
|
projectId,
|
|
129333
|
-
error: e
|
|
129721
|
+
error: e
|
|
129334
129722
|
});
|
|
129335
129723
|
return noop2;
|
|
129336
129724
|
}
|
|
@@ -129341,7 +129729,7 @@ class ObservationConsolidationJob {
|
|
|
129341
129729
|
const prompt = buildObservationPrompt(window2);
|
|
129342
129730
|
let batch;
|
|
129343
129731
|
try {
|
|
129344
|
-
const res = await this.llm.object(prompt, ConsolidatedBatchSchema);
|
|
129732
|
+
const res = await this.llm.object(prompt, ConsolidatedBatchSchema, { label: "observation-consolidation" });
|
|
129345
129733
|
if (!res.ok || !res.value) {
|
|
129346
129734
|
return noop2;
|
|
129347
129735
|
}
|
|
@@ -129357,7 +129745,7 @@ class ObservationConsolidationJob {
|
|
|
129357
129745
|
} catch (e) {
|
|
129358
129746
|
logger.warn("observation consolidation: llm.object threw (silent)", {
|
|
129359
129747
|
projectId,
|
|
129360
|
-
error: e
|
|
129748
|
+
error: e
|
|
129361
129749
|
});
|
|
129362
129750
|
return noop2;
|
|
129363
129751
|
}
|
|
@@ -129386,7 +129774,7 @@ class ObservationConsolidationJob {
|
|
|
129386
129774
|
} catch (e) {
|
|
129387
129775
|
logger.warn("observation consolidation: summary insert failed", {
|
|
129388
129776
|
batchId: batch.id,
|
|
129389
|
-
error: e
|
|
129777
|
+
error: e
|
|
129390
129778
|
});
|
|
129391
129779
|
return noop2;
|
|
129392
129780
|
}
|
|
@@ -129497,7 +129885,7 @@ class PgCheckpointStore {
|
|
|
129497
129885
|
} catch (e) {
|
|
129498
129886
|
this.hydrateFailedAt = Date.now();
|
|
129499
129887
|
logger.warn("PgCheckpointStore hydrate failed (best-effort)", {
|
|
129500
|
-
error: e
|
|
129888
|
+
error: e
|
|
129501
129889
|
});
|
|
129502
129890
|
} finally {
|
|
129503
129891
|
this.hydrating = null;
|
|
@@ -129691,8 +130079,9 @@ class PgCheckpointStore {
|
|
|
129691
130079
|
}
|
|
129692
130080
|
return existing;
|
|
129693
130081
|
} catch (e) {
|
|
129694
|
-
logger.warn("countExistingMemoryIds failed (best-effort
|
|
129695
|
-
|
|
130082
|
+
logger.warn("PgCheckpointStore: countExistingMemoryIds failed (best-effort, assuming all exist)", {
|
|
130083
|
+
memoryIdCount: memoryIds.length,
|
|
130084
|
+
error: e
|
|
129696
130085
|
});
|
|
129697
130086
|
return memoryIds;
|
|
129698
130087
|
}
|
|
@@ -129759,7 +130148,7 @@ class PgCheckpointStore {
|
|
|
129759
130148
|
const next = prev.then(fn).catch((e) => {
|
|
129760
130149
|
logger.warn("PgCheckpointStore write failed (best-effort)", {
|
|
129761
130150
|
key,
|
|
129762
|
-
error: e
|
|
130151
|
+
error: e
|
|
129763
130152
|
});
|
|
129764
130153
|
});
|
|
129765
130154
|
this.inflight.set(key, next);
|
|
@@ -129978,9 +130367,9 @@ var init_scheduler2 = __esm(() => {
|
|
|
129978
130367
|
});
|
|
129979
130368
|
|
|
129980
130369
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
129981
|
-
import
|
|
130370
|
+
import fs17 from "fs/promises";
|
|
129982
130371
|
import { existsSync as existsSync4 } from "fs";
|
|
129983
|
-
import
|
|
130372
|
+
import path23 from "path";
|
|
129984
130373
|
function getModelsDevClient() {
|
|
129985
130374
|
if (!clientInstance) {
|
|
129986
130375
|
clientInstance = new ModelsDevClient;
|
|
@@ -130000,7 +130389,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
130000
130389
|
memoryCacheTimestamp = 0;
|
|
130001
130390
|
getLocalCachePath() {
|
|
130002
130391
|
const dataDir = config.get("dataDir");
|
|
130003
|
-
return
|
|
130392
|
+
return path23.join(dataDir, ModelsDevClient.LOCAL_CACHE_FILE);
|
|
130004
130393
|
}
|
|
130005
130394
|
async loadLocalCache() {
|
|
130006
130395
|
const cachePath = this.getLocalCachePath();
|
|
@@ -130008,7 +130397,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
130008
130397
|
if (!existsSync4(cachePath)) {
|
|
130009
130398
|
return null;
|
|
130010
130399
|
}
|
|
130011
|
-
const content = await
|
|
130400
|
+
const content = await fs17.readFile(cachePath, "utf-8");
|
|
130012
130401
|
const data = JSON.parse(content);
|
|
130013
130402
|
const age = Date.now() - data.timestamp;
|
|
130014
130403
|
if (age > ModelsDevClient.LOCAL_CACHE_TTL) {
|
|
@@ -130035,21 +130424,22 @@ var init_models_dev_client = __esm(() => {
|
|
|
130035
130424
|
async saveLocalCache(models) {
|
|
130036
130425
|
const cachePath = this.getLocalCachePath();
|
|
130037
130426
|
try {
|
|
130038
|
-
const dir =
|
|
130039
|
-
await
|
|
130427
|
+
const dir = path23.dirname(cachePath);
|
|
130428
|
+
await fs17.mkdir(dir, { recursive: true });
|
|
130040
130429
|
const data = {
|
|
130041
130430
|
timestamp: Date.now(),
|
|
130042
130431
|
version: "1.0.0",
|
|
130043
130432
|
models: Object.fromEntries(models)
|
|
130044
130433
|
};
|
|
130045
|
-
await
|
|
130434
|
+
await fs17.writeFile(cachePath, JSON.stringify(data), "utf-8");
|
|
130046
130435
|
logger.debug("Saved pricing to local cache", {
|
|
130047
130436
|
models: models.size,
|
|
130048
130437
|
path: cachePath
|
|
130049
130438
|
});
|
|
130050
130439
|
} catch (error51) {
|
|
130051
|
-
logger.warn("
|
|
130052
|
-
|
|
130440
|
+
logger.warn("ModelsDevClient: failed to save local pricing cache", {
|
|
130441
|
+
path: cachePath,
|
|
130442
|
+
error: error51
|
|
130053
130443
|
});
|
|
130054
130444
|
}
|
|
130055
130445
|
}
|
|
@@ -130271,7 +130661,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
130271
130661
|
return value;
|
|
130272
130662
|
}
|
|
130273
130663
|
}
|
|
130274
|
-
logger.warn(
|
|
130664
|
+
logger.warn("ModelsDevClient: model pricing not found", { modelId });
|
|
130275
130665
|
return null;
|
|
130276
130666
|
}
|
|
130277
130667
|
async searchModels(query) {
|
|
@@ -130371,12 +130761,13 @@ var init_models_dev_client = __esm(() => {
|
|
|
130371
130761
|
const cachePath = this.getLocalCachePath();
|
|
130372
130762
|
try {
|
|
130373
130763
|
if (existsSync4(cachePath)) {
|
|
130374
|
-
await
|
|
130764
|
+
await fs17.unlink(cachePath);
|
|
130375
130765
|
logger.debug("Local pricing cache file deleted");
|
|
130376
130766
|
}
|
|
130377
130767
|
} catch (error51) {
|
|
130378
|
-
logger.warn("
|
|
130379
|
-
|
|
130768
|
+
logger.warn("ModelsDevClient: failed to delete local pricing cache", {
|
|
130769
|
+
path: cachePath,
|
|
130770
|
+
error: error51
|
|
130380
130771
|
});
|
|
130381
130772
|
}
|
|
130382
130773
|
}
|
|
@@ -130974,8 +131365,8 @@ function stripNul(content) {
|
|
|
130974
131365
|
}
|
|
130975
131366
|
|
|
130976
131367
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
130977
|
-
import
|
|
130978
|
-
import
|
|
131368
|
+
import fs18 from "fs/promises";
|
|
131369
|
+
import path24 from "path";
|
|
130979
131370
|
import { createHash as createHash8 } from "crypto";
|
|
130980
131371
|
|
|
130981
131372
|
class DiscoverStage {
|
|
@@ -131001,7 +131392,7 @@ class DiscoverStage {
|
|
|
131001
131392
|
dot: false,
|
|
131002
131393
|
absolute: false
|
|
131003
131394
|
});
|
|
131004
|
-
relPaths = found.map((p) =>
|
|
131395
|
+
relPaths = found.map((p) => path24.isAbsolute(p) ? path24.relative(ctx.projectPath, p) : p).filter((p) => !ig.ignores(p) && applyPolicy(p, policy) !== "Drop");
|
|
131005
131396
|
}
|
|
131006
131397
|
if (ctx.resumeCursor?.path) {
|
|
131007
131398
|
const cursorPath = ctx.resumeCursor.path;
|
|
@@ -131060,10 +131451,10 @@ class DiscoverStage {
|
|
|
131060
131451
|
return discovered;
|
|
131061
131452
|
}
|
|
131062
131453
|
async processFile(ctx, relativePath, forceReindex) {
|
|
131063
|
-
const absolutePath =
|
|
131454
|
+
const absolutePath = path24.join(ctx.projectPath, relativePath);
|
|
131064
131455
|
try {
|
|
131065
|
-
const stat = await
|
|
131066
|
-
const content = stripNul(await
|
|
131456
|
+
const stat = await fs18.stat(absolutePath);
|
|
131457
|
+
const content = stripNul(await fs18.readFile(absolutePath, "utf-8"));
|
|
131067
131458
|
const contentHash = createHash8("sha256").update(content).digest("hex");
|
|
131068
131459
|
let needsReparse = forceReindex;
|
|
131069
131460
|
if (!forceReindex) {
|
|
@@ -131081,8 +131472,9 @@ class DiscoverStage {
|
|
|
131081
131472
|
};
|
|
131082
131473
|
} catch (err) {
|
|
131083
131474
|
logger.warn("DiscoverStage: failed to stat/read file", {
|
|
131475
|
+
projectId: ctx.projectId,
|
|
131084
131476
|
relativePath,
|
|
131085
|
-
error: err
|
|
131477
|
+
error: err
|
|
131086
131478
|
});
|
|
131087
131479
|
throw new Error(`required_file_unreadable:${relativePath}:${err.message}`);
|
|
131088
131480
|
}
|
|
@@ -131106,8 +131498,8 @@ class DiscoverStage {
|
|
|
131106
131498
|
ig.add(pattern);
|
|
131107
131499
|
}
|
|
131108
131500
|
try {
|
|
131109
|
-
const gitignorePath =
|
|
131110
|
-
const gitignoreContent = await
|
|
131501
|
+
const gitignorePath = path24.join(projectPath, ".gitignore");
|
|
131502
|
+
const gitignoreContent = await fs18.readFile(gitignorePath, "utf8");
|
|
131111
131503
|
const rules = gitignoreContent.split(`
|
|
131112
131504
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
131113
131505
|
ig.add(rules);
|
|
@@ -132462,8 +132854,8 @@ function rustUseLeaves(node, source, prefix = []) {
|
|
|
132462
132854
|
}
|
|
132463
132855
|
if (node.type === "use_wildcard")
|
|
132464
132856
|
return [{ path: [...prefix, "*"], glob: true }];
|
|
132465
|
-
const
|
|
132466
|
-
return
|
|
132857
|
+
const path25 = rustPathSegments(node, source);
|
|
132858
|
+
return path25.length ? [{ path: [...prefix, ...path25] }] : [];
|
|
132467
132859
|
}
|
|
132468
132860
|
function functionalCaptures(captures, source, family) {
|
|
132469
132861
|
if (family !== "clojure")
|
|
@@ -133435,8 +133827,8 @@ var init_structural_runtime = __esm(() => {
|
|
|
133435
133827
|
});
|
|
133436
133828
|
|
|
133437
133829
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
133438
|
-
import
|
|
133439
|
-
import
|
|
133830
|
+
import path25 from "path";
|
|
133831
|
+
import fs19 from "fs/promises";
|
|
133440
133832
|
function resolveChunkerMaxChars() {
|
|
133441
133833
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
133442
133834
|
if (Number.isFinite(global2) && global2 > 0)
|
|
@@ -133464,8 +133856,8 @@ class ParseStage {
|
|
|
133464
133856
|
const results = new Map;
|
|
133465
133857
|
let processed = 0;
|
|
133466
133858
|
const phases = [
|
|
133467
|
-
files.filter((file2) =>
|
|
133468
|
-
files.filter((file2) =>
|
|
133859
|
+
files.filter((file2) => path25.extname(file2.relativePath).toLowerCase() !== ".h"),
|
|
133860
|
+
files.filter((file2) => path25.extname(file2.relativePath).toLowerCase() === ".h")
|
|
133469
133861
|
];
|
|
133470
133862
|
const batches = phases.flatMap((phase) => Array.from({ length: Math.ceil(phase.length / BATCH_SIZE) }, (_, index) => phase.slice(index * BATCH_SIZE, (index + 1) * BATCH_SIZE)));
|
|
133471
133863
|
for (const batch of batches) {
|
|
@@ -133503,19 +133895,19 @@ class ParseStage {
|
|
|
133503
133895
|
return files.map((file2) => results.get(file2.relativePath));
|
|
133504
133896
|
}
|
|
133505
133897
|
recordHeaderImporterEvidence(ctx, files, parsedFiles) {
|
|
133506
|
-
const knownHeaders = new Set(files.filter((file2) =>
|
|
133898
|
+
const knownHeaders = new Set(files.filter((file2) => path25.extname(file2.relativePath).toLowerCase() === ".h").map((file2) => path25.posix.normalize(file2.relativePath)));
|
|
133507
133899
|
const mutable = {
|
|
133508
133900
|
...ctx.structuralHeaderEvidenceByFile
|
|
133509
133901
|
};
|
|
133510
133902
|
for (const parsed of parsedFiles) {
|
|
133511
|
-
const extension =
|
|
133903
|
+
const extension = path25.extname(parsed.file.relativePath).toLowerCase();
|
|
133512
133904
|
const key = extension === ".c" ? "cImporters" : [".cpp", ".hpp"].includes(extension) ? "cppImporters" : undefined;
|
|
133513
133905
|
if (!key)
|
|
133514
133906
|
continue;
|
|
133515
133907
|
for (const imported of parsed.rawImports) {
|
|
133516
133908
|
if (!["c_include", "cpp_include"].includes(imported.form) || imported.specifier.startsWith("<"))
|
|
133517
133909
|
continue;
|
|
133518
|
-
const header =
|
|
133910
|
+
const header = path25.posix.normalize(path25.posix.join(path25.posix.dirname(parsed.file.relativePath), imported.specifier));
|
|
133519
133911
|
if (!knownHeaders.has(header))
|
|
133520
133912
|
continue;
|
|
133521
133913
|
const existing = mutable[header] ?? {};
|
|
@@ -133526,9 +133918,9 @@ class ParseStage {
|
|
|
133526
133918
|
}
|
|
133527
133919
|
async parseFile(ctx, file2) {
|
|
133528
133920
|
if (!file2.needsReparse) {
|
|
133529
|
-
const extension =
|
|
133921
|
+
const extension = path25.extname(file2.relativePath).toLowerCase();
|
|
133530
133922
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
133531
|
-
const content = file2.snapshotContent ?? await
|
|
133923
|
+
const content = file2.snapshotContent ?? await fs19.readFile(file2.absolutePath, "utf8");
|
|
133532
133924
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
133533
133925
|
if (outcome.status === "failed")
|
|
133534
133926
|
throw new StructuralEtlParseError(file2.relativePath, outcome.failureKind, `Structural evidence parse failed (${outcome.failureKind})`, outcome.diagnosticCount, outcome.diagnostics.slice(0, 10));
|
|
@@ -133540,8 +133932,8 @@ class ParseStage {
|
|
|
133540
133932
|
return { file: file2, chunks: [], symbols: [], rawImports: [], rawEdges: [] };
|
|
133541
133933
|
}
|
|
133542
133934
|
try {
|
|
133543
|
-
const content = file2.snapshotContent ?? await
|
|
133544
|
-
const ext2 =
|
|
133935
|
+
const content = file2.snapshotContent ?? await fs19.readFile(file2.absolutePath, "utf-8");
|
|
133936
|
+
const ext2 = path25.extname(file2.relativePath).toLowerCase();
|
|
133545
133937
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
133546
133938
|
const chunks = smartChunk(content, file2.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
133547
133939
|
let symbols;
|
|
@@ -133607,8 +133999,9 @@ class ParseStage {
|
|
|
133607
133999
|
timestamp: Date.now()
|
|
133608
134000
|
});
|
|
133609
134001
|
logger.warn("ParseStage: failed to parse file", {
|
|
134002
|
+
projectId: ctx.projectId,
|
|
133610
134003
|
filePath: file2.relativePath,
|
|
133611
|
-
error: err
|
|
134004
|
+
error: err
|
|
133612
134005
|
});
|
|
133613
134006
|
if (err instanceof StructuralEtlParseError)
|
|
133614
134007
|
throw err;
|
|
@@ -134095,7 +134488,7 @@ var init_resolver = __esm(() => {
|
|
|
134095
134488
|
});
|
|
134096
134489
|
|
|
134097
134490
|
// ../../packages/core/dist/services/structural/resolvers/typescript.js
|
|
134098
|
-
import
|
|
134491
|
+
import path26 from "path";
|
|
134099
134492
|
function candidates(identities) {
|
|
134100
134493
|
return Object.freeze(identities.map((identity) => Object.freeze({
|
|
134101
134494
|
fqn: identity.fqn,
|
|
@@ -134190,7 +134583,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
134190
134583
|
const bases = /\.[cm]?jsx?$/u.test(base) ? [base.replace(/\.[cm]?jsx?$/u, ".ts"), base.replace(/\.[cm]?jsx?$/u, ".tsx"), base] : [base];
|
|
134191
134584
|
for (const candidateBase of bases)
|
|
134192
134585
|
for (const suffix of DIALECT_PROBES[dialect] ?? [""]) {
|
|
134193
|
-
const value =
|
|
134586
|
+
const value = path26.posix.normalize(`${candidateBase}${suffix}`);
|
|
134194
134587
|
if (!value.startsWith("../") && value !== ".." && known.has(value))
|
|
134195
134588
|
return value;
|
|
134196
134589
|
}
|
|
@@ -134199,7 +134592,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
134199
134592
|
function resolveStructuralSpecifier(specifier, fromFile, build, dialect = "typescript") {
|
|
134200
134593
|
const known = new Set(build.knownFiles.map(normalizeStructuralFile));
|
|
134201
134594
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
134202
|
-
return probe(
|
|
134595
|
+
return probe(path26.posix.join(path26.posix.dirname(fromFile), specifier), known, dialect);
|
|
134203
134596
|
}
|
|
134204
134597
|
const aliases = build.pathAliasesByFile?.[normalizeStructuralFile(fromFile)] ?? build.pathAliases ?? [];
|
|
134205
134598
|
for (const alias of aliases) {
|
|
@@ -134463,7 +134856,7 @@ var init_scripting2 = __esm(() => {
|
|
|
134463
134856
|
});
|
|
134464
134857
|
|
|
134465
134858
|
// ../../packages/core/dist/services/structural/resolvers/systems.js
|
|
134466
|
-
import
|
|
134859
|
+
import path27 from "path";
|
|
134467
134860
|
var DIALECTS, SYSTEMS_LANGUAGE_RESOLVER;
|
|
134468
134861
|
var init_systems2 = __esm(() => {
|
|
134469
134862
|
init_typescript2();
|
|
@@ -134482,7 +134875,7 @@ var init_systems2 = __esm(() => {
|
|
|
134482
134875
|
const bindings = item.bindings.map((binding) => binding.imported === "*" && binding.local === "*" && unresolvedTarget && !unresolvedTarget.qualifier ? { ...binding, imported: unresolvedTarget.name, local: unresolvedTarget.name } : binding);
|
|
134483
134876
|
if (item.specifier === "crate" || item.specifier.startsWith("crate/")) {
|
|
134484
134877
|
const crateRoot = file2.file.startsWith("src/") ? "src" : "";
|
|
134485
|
-
return { ...item, bindings, specifier: `./${
|
|
134878
|
+
return { ...item, bindings, specifier: `./${path27.posix.relative(path27.posix.dirname(file2.file), path27.posix.join(crateRoot, item.specifier.replace(/^crate\/?/u, "")))}` };
|
|
134486
134879
|
}
|
|
134487
134880
|
if (item.specifier === "self" || item.specifier.startsWith("self/"))
|
|
134488
134881
|
return { ...item, bindings, specifier: `./${item.specifier.replace(/^self\/?/u, "")}` };
|
|
@@ -134580,8 +134973,8 @@ var init_data_document2 = __esm(() => {
|
|
|
134580
134973
|
});
|
|
134581
134974
|
|
|
134582
134975
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
134583
|
-
import
|
|
134584
|
-
import
|
|
134976
|
+
import path28 from "path";
|
|
134977
|
+
import fs20 from "fs";
|
|
134585
134978
|
|
|
134586
134979
|
class ResolveStage {
|
|
134587
134980
|
symbolRepository;
|
|
@@ -134605,7 +134998,7 @@ class ResolveStage {
|
|
|
134605
134998
|
const structuralDocuments = files.flatMap((file2) => {
|
|
134606
134999
|
if (!file2.structure)
|
|
134607
135000
|
return [];
|
|
134608
|
-
const language = resolveStructuralLanguage(
|
|
135001
|
+
const language = resolveStructuralLanguage(path28.extname(file2.file.relativePath));
|
|
134609
135002
|
if (language.status !== "supported")
|
|
134610
135003
|
throw new Error(`structural_manifest_missing:${file2.file.relativePath}`);
|
|
134611
135004
|
return [{
|
|
@@ -134617,13 +135010,13 @@ class ResolveStage {
|
|
|
134617
135010
|
}];
|
|
134618
135011
|
});
|
|
134619
135012
|
const currentStructuralFiles = new Set(structuralDocuments.map((document2) => document2.file));
|
|
134620
|
-
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
135013
|
+
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path28.extname(item.file.relativePath).toLowerCase())).map((item) => item.file.relativePath));
|
|
134621
135014
|
const pathAliasesByFile = Object.fromEntries([...knownRelPaths].map((file2) => [
|
|
134622
135015
|
file2,
|
|
134623
135016
|
this.structuralAliasesFor(file2, rootAliases, monorepoPackages)
|
|
134624
135017
|
]));
|
|
134625
135018
|
const buildMetadata = { knownFiles: [...knownRelPaths], pathAliasesByFile };
|
|
134626
|
-
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(
|
|
135019
|
+
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(path28.extname(definition.file_path).toLowerCase())).filter((definition) => knownRelPaths.has(definition.file_path) && skippedStructuralFiles.has(definition.file_path)).filter((definition) => !currentStructuralFiles.has(definition.file_path));
|
|
134627
135020
|
const seedIds = new Set;
|
|
134628
135021
|
for (const definition of seedRows) {
|
|
134629
135022
|
if (seedIds.has(definition.id))
|
|
@@ -134716,7 +135109,7 @@ class ResolveStage {
|
|
|
134716
135109
|
if (parsed.file !== definition.file_path) {
|
|
134717
135110
|
throw new Error(`structural_repository_seed_file_mismatch:${definition.id}`);
|
|
134718
135111
|
}
|
|
134719
|
-
const language = resolveStructuralLanguage(
|
|
135112
|
+
const language = resolveStructuralLanguage(path28.extname(definition.file_path));
|
|
134720
135113
|
if (language.status !== "supported")
|
|
134721
135114
|
throw new Error(`structural_repository_seed_language:${definition.id}`);
|
|
134722
135115
|
let identity;
|
|
@@ -134768,7 +135161,7 @@ class ResolveStage {
|
|
|
134768
135161
|
});
|
|
134769
135162
|
}
|
|
134770
135163
|
resolveFile(parsed, projectPath, knownRelPaths, rootAliases, monorepoPackages, symbolIndex, knownFqns) {
|
|
134771
|
-
const fromDir =
|
|
135164
|
+
const fromDir = path28.dirname(path28.join(projectPath, parsed.file.relativePath));
|
|
134772
135165
|
const packageAliases = this.getPackageAliases(parsed.file.relativePath, monorepoPackages);
|
|
134773
135166
|
const allAliases = [...packageAliases, ...rootAliases];
|
|
134774
135167
|
const resolvedImports = parsed.rawImports.map((raw2) => {
|
|
@@ -134839,12 +135232,12 @@ class ResolveStage {
|
|
|
134839
135232
|
index.set(def.name, `${def.file_path}#${def.name}`);
|
|
134840
135233
|
}
|
|
134841
135234
|
} catch (err) {
|
|
134842
|
-
const skippedStructural = files.some((file2) => !file2.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
135235
|
+
const skippedStructural = files.some((file2) => !file2.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path28.extname(file2.file.relativePath).toLowerCase()));
|
|
134843
135236
|
if (skippedStructural)
|
|
134844
135237
|
throw new Error("structural_repository_seed_failed", { cause: err });
|
|
134845
135238
|
logger.warn("buildSymbolIndex: repo seed failed, in-batch only", {
|
|
134846
135239
|
projectId,
|
|
134847
|
-
error: err
|
|
135240
|
+
error: err
|
|
134848
135241
|
});
|
|
134849
135242
|
}
|
|
134850
135243
|
const inBatch = new Map;
|
|
@@ -134863,7 +135256,7 @@ class ResolveStage {
|
|
|
134863
135256
|
}
|
|
134864
135257
|
resolveSpecifier(specifier, fromDir, projectPath, knownRelPaths, aliases) {
|
|
134865
135258
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
134866
|
-
const resolved = this.probeExtensions(
|
|
135259
|
+
const resolved = this.probeExtensions(path28.resolve(fromDir, specifier), projectPath, knownRelPaths);
|
|
134867
135260
|
return { resolvedPath: resolved, external: false };
|
|
134868
135261
|
}
|
|
134869
135262
|
for (const alias of aliases) {
|
|
@@ -134871,8 +135264,8 @@ class ResolveStage {
|
|
|
134871
135264
|
const suffix = specifier.slice(alias.prefix.length);
|
|
134872
135265
|
for (const target of alias.targets) {
|
|
134873
135266
|
const cleanTarget = target.replace(/\/\*$/, "");
|
|
134874
|
-
const basePath = alias.packagePath ?
|
|
134875
|
-
const absPath =
|
|
135267
|
+
const basePath = alias.packagePath ? path28.join(projectPath, alias.packagePath) : projectPath;
|
|
135268
|
+
const absPath = path28.join(basePath, cleanTarget + suffix);
|
|
134876
135269
|
const resolved = this.probeExtensions(absPath, projectPath, knownRelPaths);
|
|
134877
135270
|
if (resolved)
|
|
134878
135271
|
return { resolvedPath: resolved, external: false };
|
|
@@ -134888,7 +135281,7 @@ class ResolveStage {
|
|
|
134888
135281
|
...TS_EXTENSIONS.map((ext2) => absPath.replace(/\.[^.]+$/, ext2))
|
|
134889
135282
|
];
|
|
134890
135283
|
for (const candidate2 of candidates2) {
|
|
134891
|
-
const rel =
|
|
135284
|
+
const rel = path28.relative(projectPath, candidate2).replace(/\\/g, "/");
|
|
134892
135285
|
if (knownRelPaths.has(rel))
|
|
134893
135286
|
return rel;
|
|
134894
135287
|
}
|
|
@@ -134896,9 +135289,9 @@ class ResolveStage {
|
|
|
134896
135289
|
}
|
|
134897
135290
|
loadTsConfigPaths(projectPath, packageBase) {
|
|
134898
135291
|
const aliases = [];
|
|
134899
|
-
const tsconfigPath =
|
|
135292
|
+
const tsconfigPath = path28.join(projectPath, "tsconfig.json");
|
|
134900
135293
|
try {
|
|
134901
|
-
const raw2 =
|
|
135294
|
+
const raw2 = fs20.readFileSync(tsconfigPath, "utf-8");
|
|
134902
135295
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
134903
135296
|
const tsconfig = JSON.parse(stripped);
|
|
134904
135297
|
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
@@ -134927,7 +135320,7 @@ class ResolveStage {
|
|
|
134927
135320
|
}
|
|
134928
135321
|
}
|
|
134929
135322
|
for (const packageRelPath of packagePaths) {
|
|
134930
|
-
const absPackagePath =
|
|
135323
|
+
const absPackagePath = path28.join(projectPath, packageRelPath);
|
|
134931
135324
|
const aliases = this.loadTsConfigPaths(absPackagePath, packageRelPath);
|
|
134932
135325
|
if (aliases.length > 0) {
|
|
134933
135326
|
packages.push({
|
|
@@ -134957,7 +135350,7 @@ class ResolveStage {
|
|
|
134957
135350
|
structuralAliasesFor(filePath, rootAliases, packages) {
|
|
134958
135351
|
return [...this.getPackageAliases(filePath, packages), ...rootAliases].map((alias) => ({
|
|
134959
135352
|
pattern: alias.prefix + (alias.targets.some((target) => target.includes("*")) ? "/*" : ""),
|
|
134960
|
-
targets: alias.targets.map((target) => alias.packagePath ?
|
|
135353
|
+
targets: alias.targets.map((target) => alias.packagePath ? path28.posix.join(alias.packagePath, target) : target)
|
|
134961
135354
|
}));
|
|
134962
135355
|
}
|
|
134963
135356
|
}
|
|
@@ -135007,7 +135400,7 @@ async function withDeadlockRetry(operation, options = {}) {
|
|
|
135007
135400
|
attempt,
|
|
135008
135401
|
maxAttempts,
|
|
135009
135402
|
delayMs,
|
|
135010
|
-
error: error51
|
|
135403
|
+
error: error51
|
|
135011
135404
|
});
|
|
135012
135405
|
await new Promise((resolve7) => setTimeout(resolve7, delayMs));
|
|
135013
135406
|
}
|
|
@@ -135021,7 +135414,7 @@ var init_with_deadlock_retry = __esm(() => {
|
|
|
135021
135414
|
});
|
|
135022
135415
|
|
|
135023
135416
|
// ../../packages/core/dist/services/etl/stages/load.js
|
|
135024
|
-
import
|
|
135417
|
+
import path29 from "path";
|
|
135025
135418
|
function formatDuration(ms) {
|
|
135026
135419
|
const totalSec = Math.max(0, Math.round(ms / 1000));
|
|
135027
135420
|
if (totalSec < 60)
|
|
@@ -135298,7 +135691,7 @@ class LoadStage {
|
|
|
135298
135691
|
const filePath = file2.file.relativePath;
|
|
135299
135692
|
const batch = buildSymbolPersistenceBatch(ctx.projectId, file2);
|
|
135300
135693
|
if (ctx.graphGenerationLease) {
|
|
135301
|
-
const manifest = getLanguageManifestEntry(
|
|
135694
|
+
const manifest = getLanguageManifestEntry(path29.extname(filePath));
|
|
135302
135695
|
const diagnostics2 = (file2.structuralDiagnostics ?? []).slice(0, 10).map((diagnostic2) => ({
|
|
135303
135696
|
code: diagnostic2.code,
|
|
135304
135697
|
severity: diagnostic2.severity,
|
|
@@ -135755,9 +136148,9 @@ var init_graph_generation_coordinator = __esm(() => {
|
|
|
135755
136148
|
// ../../packages/core/dist/services/etl/pipeline.js
|
|
135756
136149
|
import { createHash as createHash10 } from "crypto";
|
|
135757
136150
|
import { setTimeout as delay2 } from "timers/promises";
|
|
135758
|
-
import
|
|
136151
|
+
import path30 from "path";
|
|
135759
136152
|
function buildHeaderLanguageEvidence(files) {
|
|
135760
|
-
const headers = new Set(files.filter((file2) =>
|
|
136153
|
+
const headers = new Set(files.filter((file2) => path30.posix.extname(file2.relativePath).toLowerCase() === ".h").map((file2) => path30.posix.normalize(file2.relativePath)));
|
|
135761
136154
|
const mutable = new Map;
|
|
135762
136155
|
const entry2 = (header) => {
|
|
135763
136156
|
let value = mutable.get(header);
|
|
@@ -135768,7 +136161,7 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
135768
136161
|
return value;
|
|
135769
136162
|
};
|
|
135770
136163
|
for (const file2 of files) {
|
|
135771
|
-
if (
|
|
136164
|
+
if (path30.posix.basename(file2.relativePath) !== "compile_commands.json" || file2.snapshotContent === undefined)
|
|
135772
136165
|
continue;
|
|
135773
136166
|
let commands;
|
|
135774
136167
|
try {
|
|
@@ -135784,11 +136177,11 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
135784
136177
|
const record2 = command;
|
|
135785
136178
|
if (typeof record2.file !== "string")
|
|
135786
136179
|
continue;
|
|
135787
|
-
const projectRoot =
|
|
135788
|
-
const commandDirectory = typeof record2.directory === "string" ?
|
|
135789
|
-
const absoluteInput =
|
|
135790
|
-
const relative3 =
|
|
135791
|
-
const header =
|
|
136180
|
+
const projectRoot = path30.resolve(file2.absolutePath, ...file2.relativePath.split("/").map(() => ".."));
|
|
136181
|
+
const commandDirectory = typeof record2.directory === "string" ? path30.resolve(projectRoot, record2.directory) : projectRoot;
|
|
136182
|
+
const absoluteInput = path30.resolve(commandDirectory, record2.file);
|
|
136183
|
+
const relative3 = path30.relative(projectRoot, absoluteInput);
|
|
136184
|
+
const header = path30.posix.normalize(relative3.replaceAll(path30.sep, "/"));
|
|
135792
136185
|
if (!headers.has(header))
|
|
135793
136186
|
continue;
|
|
135794
136187
|
const invocation = typeof record2.command === "string" ? record2.command : Array.isArray(record2.arguments) ? record2.arguments.join(" ") : "";
|
|
@@ -136137,7 +136530,7 @@ var init_pipeline = __esm(() => {
|
|
|
136137
136530
|
logger.warn("EtlPipeline: search-admission marker write failed", {
|
|
136138
136531
|
projectId,
|
|
136139
136532
|
jobId,
|
|
136140
|
-
error: markerError
|
|
136533
|
+
error: markerError
|
|
136141
136534
|
});
|
|
136142
136535
|
}
|
|
136143
136536
|
if (forceReindex) {
|
|
@@ -136149,7 +136542,7 @@ var init_pipeline = __esm(() => {
|
|
|
136149
136542
|
logger.warn("EtlPipeline: embedding fingerprint stamp failed", {
|
|
136150
136543
|
projectId,
|
|
136151
136544
|
jobId,
|
|
136152
|
-
error: stampError
|
|
136545
|
+
error: stampError
|
|
136153
136546
|
});
|
|
136154
136547
|
}
|
|
136155
136548
|
}
|
|
@@ -136312,9 +136705,10 @@ class SearchSessionHook {
|
|
|
136312
136705
|
});
|
|
136313
136706
|
} catch (err) {
|
|
136314
136707
|
logger.warn("SearchSessionHook: store failed (best-effort)", {
|
|
136315
|
-
error: err.message,
|
|
136316
136708
|
projectId,
|
|
136317
|
-
|
|
136709
|
+
sessionId,
|
|
136710
|
+
query: query.slice(0, 60),
|
|
136711
|
+
error: err
|
|
136318
136712
|
});
|
|
136319
136713
|
}
|
|
136320
136714
|
}
|
|
@@ -136390,8 +136784,10 @@ class CoRetrievalHook {
|
|
|
136390
136784
|
peers = await this.findPeers(memoryId, projectId, sessionId);
|
|
136391
136785
|
} catch (err) {
|
|
136392
136786
|
logger.warn("CoRetrievalHook: peer lookup failed", {
|
|
136393
|
-
|
|
136394
|
-
|
|
136787
|
+
projectId,
|
|
136788
|
+
sessionId,
|
|
136789
|
+
memoryId,
|
|
136790
|
+
error: err
|
|
136395
136791
|
});
|
|
136396
136792
|
return;
|
|
136397
136793
|
}
|
|
@@ -141670,33 +142066,33 @@ var require_URL = __commonJS((exports, module) => {
|
|
|
141670
142066
|
else
|
|
141671
142067
|
return basepath.substring(0, lastslash + 1) + refpath;
|
|
141672
142068
|
}
|
|
141673
|
-
function remove_dot_segments(
|
|
141674
|
-
if (!
|
|
141675
|
-
return
|
|
142069
|
+
function remove_dot_segments(path31) {
|
|
142070
|
+
if (!path31)
|
|
142071
|
+
return path31;
|
|
141676
142072
|
var output = "";
|
|
141677
|
-
while (
|
|
141678
|
-
if (
|
|
141679
|
-
|
|
142073
|
+
while (path31.length > 0) {
|
|
142074
|
+
if (path31 === "." || path31 === "..") {
|
|
142075
|
+
path31 = "";
|
|
141680
142076
|
break;
|
|
141681
142077
|
}
|
|
141682
|
-
var twochars =
|
|
141683
|
-
var threechars =
|
|
141684
|
-
var fourchars =
|
|
142078
|
+
var twochars = path31.substring(0, 2);
|
|
142079
|
+
var threechars = path31.substring(0, 3);
|
|
142080
|
+
var fourchars = path31.substring(0, 4);
|
|
141685
142081
|
if (threechars === "../") {
|
|
141686
|
-
|
|
142082
|
+
path31 = path31.substring(3);
|
|
141687
142083
|
} else if (twochars === "./") {
|
|
141688
|
-
|
|
142084
|
+
path31 = path31.substring(2);
|
|
141689
142085
|
} else if (threechars === "/./") {
|
|
141690
|
-
|
|
141691
|
-
} else if (twochars === "/." &&
|
|
141692
|
-
|
|
141693
|
-
} else if (fourchars === "/../" || threechars === "/.." &&
|
|
141694
|
-
|
|
142086
|
+
path31 = "/" + path31.substring(3);
|
|
142087
|
+
} else if (twochars === "/." && path31.length === 2) {
|
|
142088
|
+
path31 = "/";
|
|
142089
|
+
} else if (fourchars === "/../" || threechars === "/.." && path31.length === 3) {
|
|
142090
|
+
path31 = "/" + path31.substring(4);
|
|
141695
142091
|
output = output.replace(/\/?[^\/]*$/, "");
|
|
141696
142092
|
} else {
|
|
141697
|
-
var segment =
|
|
142093
|
+
var segment = path31.match(/(\/?([^\/]*))/)[0];
|
|
141698
142094
|
output += segment;
|
|
141699
|
-
|
|
142095
|
+
path31 = path31.substring(segment.length);
|
|
141700
142096
|
}
|
|
141701
142097
|
}
|
|
141702
142098
|
return output;
|
|
@@ -153766,21 +154162,21 @@ function jsonToKeyPathChunks(value, label = "$") {
|
|
|
153766
154162
|
walk(value, label, out);
|
|
153767
154163
|
return out;
|
|
153768
154164
|
}
|
|
153769
|
-
function walk(val,
|
|
154165
|
+
function walk(val, path31, out) {
|
|
153770
154166
|
if (val === null || val === undefined)
|
|
153771
154167
|
return;
|
|
153772
154168
|
if (Array.isArray(val)) {
|
|
153773
154169
|
if (val.length === 0) {
|
|
153774
|
-
out.push({ path:
|
|
154170
|
+
out.push({ path: path31, content: `**${path31}** = _[]_` });
|
|
153775
154171
|
return;
|
|
153776
154172
|
}
|
|
153777
154173
|
if (val.every((v) => v !== null && typeof v === "object")) {
|
|
153778
|
-
val.forEach((v, i) => walk(v, `${
|
|
154174
|
+
val.forEach((v, i) => walk(v, `${path31}[${i}]`, out));
|
|
153779
154175
|
return;
|
|
153780
154176
|
}
|
|
153781
154177
|
const items = val.map((v) => `- \`${String(v)}\``).join(`
|
|
153782
154178
|
`);
|
|
153783
|
-
out.push({ path:
|
|
154179
|
+
out.push({ path: path31, content: `**${path31}**
|
|
153784
154180
|
|
|
153785
154181
|
${items}` });
|
|
153786
154182
|
return;
|
|
@@ -153788,16 +154184,16 @@ ${items}` });
|
|
|
153788
154184
|
if (typeof val === "object") {
|
|
153789
154185
|
const entries = Object.entries(val);
|
|
153790
154186
|
if (entries.length === 0) {
|
|
153791
|
-
out.push({ path:
|
|
154187
|
+
out.push({ path: path31, content: `**${path31}** = _{}_` });
|
|
153792
154188
|
return;
|
|
153793
154189
|
}
|
|
153794
154190
|
for (const [k, v] of entries) {
|
|
153795
154191
|
const safeKey = /^[A-Za-z_$][\w$]*$/.test(k) ? k : JSON.stringify(k);
|
|
153796
|
-
walk(v, `${
|
|
154192
|
+
walk(v, `${path31}.${safeKey}`, out);
|
|
153797
154193
|
}
|
|
153798
154194
|
return;
|
|
153799
154195
|
}
|
|
153800
|
-
out.push({ path:
|
|
154196
|
+
out.push({ path: path31, content: `**${path31}** = \`${String(val)}\`` });
|
|
153801
154197
|
}
|
|
153802
154198
|
var gfm, STRIP_SELECTORS, tdCache = null;
|
|
153803
154199
|
var init_html_to_md = __esm(() => {
|
|
@@ -153901,6 +154297,7 @@ async function fetchAndConvertOne(url2, deps, opts = {}) {
|
|
|
153901
154297
|
} catch (err) {
|
|
153902
154298
|
const msg = err instanceof Error ? err.message : String(err);
|
|
153903
154299
|
logger.error("fetch_and_index indexChunk failed", err, {
|
|
154300
|
+
projectId,
|
|
153904
154301
|
url: url2,
|
|
153905
154302
|
chunkId: chunk.id
|
|
153906
154303
|
});
|
|
@@ -154091,6 +154488,7 @@ class WebController {
|
|
|
154091
154488
|
return s.value;
|
|
154092
154489
|
const msg = s.reason instanceof Error ? s.reason.message : String(s.reason);
|
|
154093
154490
|
logger.error("fetch_and_index job rejected", s.reason, {
|
|
154491
|
+
projectId,
|
|
154094
154492
|
url: batch[i].url
|
|
154095
154493
|
});
|
|
154096
154494
|
return { kind: "error", url: batch[i].url, error: msg };
|
|
@@ -154222,8 +154620,8 @@ var init_recover_project = __esm(() => {
|
|
|
154222
154620
|
init_config();
|
|
154223
154621
|
init_dist();
|
|
154224
154622
|
init_inference_providers();
|
|
154225
|
-
import
|
|
154226
|
-
import
|
|
154623
|
+
import os9 from "os";
|
|
154624
|
+
import path31 from "path";
|
|
154227
154625
|
var WRITABLE_PROVIDERS = ["ollama", "lmstudio", "mistral", "openai", "google", "cohere"];
|
|
154228
154626
|
var GENERATOR_MARKER = "scripts/generate-subagent-artifacts.ts";
|
|
154229
154627
|
var GENERATOR_MARKER_MAX_LEVELS = 6;
|
|
@@ -154266,6 +154664,14 @@ Commands:
|
|
|
154266
154664
|
profile set <name> [--host <h>] [--dry-run]
|
|
154267
154665
|
Switch installed agents to a profile (restart required after)
|
|
154268
154666
|
|
|
154667
|
+
doctor [--fix] [--host <h>] [--target <dir>]
|
|
154668
|
+
Report agent model/profile drift: live-tree vs recorded
|
|
154669
|
+
versions, per-role models, variant staleness, env
|
|
154670
|
+
overrides. --fix re-runs the profile switch for the
|
|
154671
|
+
recorded active profile (restart required after).
|
|
154672
|
+
--target redirects the home the state/registries are
|
|
154673
|
+
read from (test seam, same convention as bootstrap)
|
|
154674
|
+
|
|
154269
154675
|
bootstrap list List every startup-contract rule: state, default, description
|
|
154270
154676
|
bootstrap show Same as 'bootstrap list'
|
|
154271
154677
|
bootstrap enable <rule-id> [--target <dir> --yes] [--dry-run]
|
|
@@ -154283,6 +154689,8 @@ Examples:
|
|
|
154283
154689
|
massa-ai-config set embedding.dimensions 1024
|
|
154284
154690
|
massa-ai-config recover my-project --path /home/user/renamed-dir
|
|
154285
154691
|
massa-ai-config profile set work --dry-run
|
|
154692
|
+
massa-ai-config doctor
|
|
154693
|
+
massa-ai-config doctor --fix
|
|
154286
154694
|
massa-ai-config bootstrap list
|
|
154287
154695
|
massa-ai-config bootstrap disable caveman
|
|
154288
154696
|
`);
|
|
@@ -154326,6 +154734,30 @@ function formatSwitchReport(report) {
|
|
|
154326
154734
|
A host session restart is required for the change to take effect.`);
|
|
154327
154735
|
}
|
|
154328
154736
|
}
|
|
154737
|
+
function formatDriftReport(report) {
|
|
154738
|
+
console.log(`doctor (${report.host}, route: ${report.route})`);
|
|
154739
|
+
console.log(` live root: ${report.liveRoot ?? "n/a"}`);
|
|
154740
|
+
console.log(` source version: ${report.sourceVersion ?? "n/a"} (live tree)`);
|
|
154741
|
+
console.log(` state version: ${report.stateVersion ?? "n/a"} (install-state)`);
|
|
154742
|
+
console.log(` pinned version: ${report.pinnedVersion ?? "n/a"} (installed_plugins)`);
|
|
154743
|
+
console.log(` active profile: ${report.activeProfile ?? "n/a"}`);
|
|
154744
|
+
for (const role of report.roles) {
|
|
154745
|
+
const stale = role.staleVariant ? " \u2014 STALE vs the recorded profile's variant" : "";
|
|
154746
|
+
console.log(` ${role.name}: model=${role.model ?? "unknown"} effort=${role.effort ?? "unknown"}${stale}`);
|
|
154747
|
+
}
|
|
154748
|
+
if (report.versionDrift) {
|
|
154749
|
+
console.log(` drift: live tree ${report.sourceVersion} != recorded ${report.stateVersion} \u2014 update the plugin (or re-run the installer)`);
|
|
154750
|
+
}
|
|
154751
|
+
if (report.profileMaterialized) {
|
|
154752
|
+
console.log(" drift: active agent files differ from the recorded profile's variants \u2014 run `massa-ai-config doctor --fix` (re-runs the profile switch)");
|
|
154753
|
+
}
|
|
154754
|
+
if (report.envOverride) {
|
|
154755
|
+
console.log(` override: ${report.envOverride.name}=${report.envOverride.value} wins over every per-agent model at runtime \u2014 remove it from the host env to let profiles govern`);
|
|
154756
|
+
}
|
|
154757
|
+
if (report.route !== "unresolved" && !report.versionDrift && !report.profileMaterialized && !report.envOverride) {
|
|
154758
|
+
console.log(" healthy: every recording agrees.");
|
|
154759
|
+
}
|
|
154760
|
+
}
|
|
154329
154761
|
async function runCli(argv) {
|
|
154330
154762
|
const args = argv;
|
|
154331
154763
|
const command = args[0];
|
|
@@ -154561,6 +154993,39 @@ Using defaults:`);
|
|
|
154561
154993
|
console.error("Usage: massa-ai-config profile <list|show|set> ...");
|
|
154562
154994
|
return 1;
|
|
154563
154995
|
}
|
|
154996
|
+
case "doctor": {
|
|
154997
|
+
const fix = options["fix"] === true;
|
|
154998
|
+
const hostOpt = typeof options.host === "string" ? options.host : undefined;
|
|
154999
|
+
if (hostOpt !== undefined && !isHost(hostOpt)) {
|
|
155000
|
+
console.error(`Error: unknown host "${hostOpt}"`);
|
|
155001
|
+
return 1;
|
|
155002
|
+
}
|
|
155003
|
+
const host = hostOpt ?? "claude";
|
|
155004
|
+
const targetHome = typeof options.target === "string" ? options.target : os9.homedir();
|
|
155005
|
+
try {
|
|
155006
|
+
let report = runtimeDriftReport({ targetHome, host });
|
|
155007
|
+
if (fix) {
|
|
155008
|
+
const profile = report.activeProfile;
|
|
155009
|
+
if (!profile) {
|
|
155010
|
+
console.error("Error: no recorded active profile in install-state.json \u2014 run " + "`massa-ai-config profile set <name>` first; there is nothing to fix from.");
|
|
155011
|
+
return 1;
|
|
155012
|
+
}
|
|
155013
|
+
const sourceRoot = findRepoRootWithMarker(import.meta.dirname, GENERATOR_MARKER, GENERATOR_MARKER_MAX_LEVELS);
|
|
155014
|
+
formatVariantSync(syncGeneratedVariants({ sourceRoot, targetHome }));
|
|
155015
|
+
const switchReport = switchProfile({ profile, host, targetHome });
|
|
155016
|
+
formatSwitchReport(switchReport);
|
|
155017
|
+
if (!reportSucceeded(switchReport)) {
|
|
155018
|
+
return 1;
|
|
155019
|
+
}
|
|
155020
|
+
report = runtimeDriftReport({ targetHome, host });
|
|
155021
|
+
}
|
|
155022
|
+
formatDriftReport(report);
|
|
155023
|
+
return 0;
|
|
155024
|
+
} catch (e) {
|
|
155025
|
+
console.error(`Error: ${e.message}`);
|
|
155026
|
+
return 1;
|
|
155027
|
+
}
|
|
155028
|
+
}
|
|
154564
155029
|
case "bootstrap": {
|
|
154565
155030
|
const subcommand = args[1];
|
|
154566
155031
|
if (subcommand === "list" || subcommand === "show") {
|
|
@@ -154585,9 +155050,9 @@ Using defaults:`);
|
|
|
154585
155050
|
return 1;
|
|
154586
155051
|
}
|
|
154587
155052
|
const targetOpt = typeof options.target === "string" ? options.target : undefined;
|
|
154588
|
-
const targetHome = targetOpt === undefined ?
|
|
154589
|
-
if (targetHome !==
|
|
154590
|
-
console.error(`Error: --target ${targetHome} is not your home (${
|
|
155053
|
+
const targetHome = targetOpt === undefined ? os9.homedir() : path31.resolve(targetOpt);
|
|
155054
|
+
if (targetHome !== os9.homedir() && options.yes !== true) {
|
|
155055
|
+
console.error(`Error: --target ${targetHome} is not your home (${os9.homedir()}) \u2014 pass --yes to confirm writing there`);
|
|
154591
155056
|
return 1;
|
|
154592
155057
|
}
|
|
154593
155058
|
const dryRun = options["dry-run"] === true;
|
|
@@ -154605,7 +155070,7 @@ Using defaults:`);
|
|
|
154605
155070
|
const report = applyBootstrapState({
|
|
154606
155071
|
targetHome,
|
|
154607
155072
|
dryRun,
|
|
154608
|
-
sourcePath: repoRoot === null ? undefined :
|
|
155073
|
+
sourcePath: repoRoot === null ? undefined : path31.join(repoRoot, "skills", "AGENTS.md")
|
|
154609
155074
|
});
|
|
154610
155075
|
console.log(formatBootstrapReport(report));
|
|
154611
155076
|
return bootstrapReportSucceeded(report) ? 0 : 1;
|