@massa-ai/mcp-client 1.60.1 → 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 +434 -162
- package/dist/index.js +384 -173
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -25994,7 +25994,7 @@ function getConfigForEnv() {
|
|
|
25994
25994
|
} else {
|
|
25995
25995
|
console.error(`[getConfigForEnv] embedding.provider "${provider}" has no env-projection branch \u2014 no embedding env vars were set`);
|
|
25996
25996
|
}
|
|
25997
|
-
env.
|
|
25997
|
+
env.MASSA_AI_LOG_LEVEL = config2.logging.level;
|
|
25998
25998
|
env.ENABLE_METRICS = String(config2.logging.enableMetrics);
|
|
25999
25999
|
return env;
|
|
26000
26000
|
}
|
|
@@ -26568,7 +26568,7 @@ var init_config = __esm(() => {
|
|
|
26568
26568
|
corsOrigins: envList("MASSA_AI_API_CORS_ORIGINS", fileConfig.security?.corsOrigins ?? [])
|
|
26569
26569
|
},
|
|
26570
26570
|
logging: {
|
|
26571
|
-
level: process.env.
|
|
26571
|
+
level: process.env.MASSA_AI_LOG_LEVEL || fileConfig.logging?.level || "info",
|
|
26572
26572
|
enableMetrics: process.env.ENABLE_METRICS === "true" || process.env.ENABLE_METRICS === undefined && !!fileConfig.logging?.enableMetrics,
|
|
26573
26573
|
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file || path4.join(resolvedDataDir, "logs", "massa-ai.log"),
|
|
26574
26574
|
enableFileSink: envBool("MASSA_AI_LOG_ENABLE_FILE_SINK", fileConfig.logging?.enableFileSink ?? true),
|
|
@@ -26901,6 +26901,32 @@ var init_log_buffer = __esm(() => {
|
|
|
26901
26901
|
});
|
|
26902
26902
|
|
|
26903
26903
|
// ../../packages/shared/dist/utils/logger.js
|
|
26904
|
+
function formatAgo(ms) {
|
|
26905
|
+
const totalSeconds = Math.floor(ms / 1000);
|
|
26906
|
+
if (totalSeconds < 60)
|
|
26907
|
+
return `${totalSeconds}s`;
|
|
26908
|
+
return `${Math.floor(totalSeconds / 60)}m`;
|
|
26909
|
+
}
|
|
26910
|
+
function capErrorText(value) {
|
|
26911
|
+
if (value.length <= MAX_ERROR_TEXT_CHARS)
|
|
26912
|
+
return value;
|
|
26913
|
+
const truncatedChars = value.length - MAX_ERROR_TEXT_CHARS;
|
|
26914
|
+
return `${value.slice(0, MAX_ERROR_TEXT_CHARS)}\u2026(truncated ${truncatedChars} chars)`;
|
|
26915
|
+
}
|
|
26916
|
+
function pickErrorFields(err, includeStack) {
|
|
26917
|
+
const out = { name: err.name, message: capErrorText(err.message) };
|
|
26918
|
+
if (includeStack)
|
|
26919
|
+
out.stack = err.stack;
|
|
26920
|
+
const code = err.code;
|
|
26921
|
+
if (code !== undefined)
|
|
26922
|
+
out.code = code;
|
|
26923
|
+
const cause = err.cause;
|
|
26924
|
+
if (cause !== undefined) {
|
|
26925
|
+
out.cause = capErrorText(cause instanceof Error ? cause.message : String(cause));
|
|
26926
|
+
}
|
|
26927
|
+
return out;
|
|
26928
|
+
}
|
|
26929
|
+
|
|
26904
26930
|
class Logger {
|
|
26905
26931
|
_level;
|
|
26906
26932
|
_enableMetrics;
|
|
@@ -26909,6 +26935,7 @@ class Logger {
|
|
|
26909
26935
|
_maxFileSizeBytes;
|
|
26910
26936
|
_maxFiles;
|
|
26911
26937
|
_initialized = false;
|
|
26938
|
+
repeats = new Map;
|
|
26912
26939
|
constructor() {}
|
|
26913
26940
|
ensureInitialized() {
|
|
26914
26941
|
if (!this._initialized) {
|
|
@@ -26969,13 +26996,70 @@ class Logger {
|
|
|
26969
26996
|
shouldLog(level) {
|
|
26970
26997
|
return level >= this.level;
|
|
26971
26998
|
}
|
|
26999
|
+
serializeMetaErrors(meta3) {
|
|
27000
|
+
if (!meta3)
|
|
27001
|
+
return meta3;
|
|
27002
|
+
let out;
|
|
27003
|
+
for (const [key, value] of Object.entries(meta3)) {
|
|
27004
|
+
if (value instanceof Error) {
|
|
27005
|
+
if (!out)
|
|
27006
|
+
out = { ...meta3 };
|
|
27007
|
+
out[key] = pickErrorFields(value, false);
|
|
27008
|
+
}
|
|
27009
|
+
}
|
|
27010
|
+
return out ?? meta3;
|
|
27011
|
+
}
|
|
27012
|
+
applyRepeatAccounting(level, message, meta3) {
|
|
27013
|
+
if (level !== LogLevel.WARN && level !== LogLevel.ERROR)
|
|
27014
|
+
return meta3;
|
|
27015
|
+
const label = typeof meta3?.label === "string" ? meta3.label : "";
|
|
27016
|
+
const key = `${level}|${message}|${label}`;
|
|
27017
|
+
const now = Date.now();
|
|
27018
|
+
const existing = this.repeats.get(key);
|
|
27019
|
+
if (!existing || now - existing.firstSeenAt > REPEAT_WINDOW_MS) {
|
|
27020
|
+
if (this.repeats.size >= MAX_REPEAT_KEYS)
|
|
27021
|
+
this.repeats.clear();
|
|
27022
|
+
this.repeats.set(key, { firstSeenAt: now, count: 1 });
|
|
27023
|
+
return meta3;
|
|
27024
|
+
}
|
|
27025
|
+
existing.count += 1;
|
|
27026
|
+
return {
|
|
27027
|
+
...meta3,
|
|
27028
|
+
occurrences: existing.count,
|
|
27029
|
+
firstSeenAgo: formatAgo(now - existing.firstSeenAt)
|
|
27030
|
+
};
|
|
27031
|
+
}
|
|
27032
|
+
_resetRepeatsForTesting() {
|
|
27033
|
+
this.repeats.clear();
|
|
27034
|
+
}
|
|
27035
|
+
safeStringifyMeta(meta3) {
|
|
27036
|
+
const seen = new WeakSet;
|
|
27037
|
+
try {
|
|
27038
|
+
return JSON.stringify(meta3, (_key, value) => {
|
|
27039
|
+
if (typeof value === "bigint")
|
|
27040
|
+
return value.toString();
|
|
27041
|
+
if (typeof value === "object" && value !== null) {
|
|
27042
|
+
if (seen.has(value))
|
|
27043
|
+
return "[Circular]";
|
|
27044
|
+
seen.add(value);
|
|
27045
|
+
}
|
|
27046
|
+
return value;
|
|
27047
|
+
});
|
|
27048
|
+
} catch (err) {
|
|
27049
|
+
return JSON.stringify({
|
|
27050
|
+
metaUnserializable: err instanceof Error ? err.message : String(err)
|
|
27051
|
+
});
|
|
27052
|
+
}
|
|
27053
|
+
}
|
|
26972
27054
|
formatMessage(level, message, meta3, timestamp = new Date().toISOString()) {
|
|
26973
|
-
const metaStr = meta3 ? ` ${
|
|
27055
|
+
const metaStr = meta3 ? ` ${this.safeStringifyMeta(meta3)}` : "";
|
|
26974
27056
|
return `[${timestamp}] [${level}] ${message}${metaStr}`;
|
|
26975
27057
|
}
|
|
26976
27058
|
emit(level, message, meta3) {
|
|
27059
|
+
const serializedMeta = this.serializeMetaErrors(meta3);
|
|
27060
|
+
const finalMeta = this.applyRepeatAccounting(level, message, serializedMeta);
|
|
26977
27061
|
const ts = new Date().toISOString();
|
|
26978
|
-
const line = this.formatMessage(LOG_LEVEL_LABELS[level], message,
|
|
27062
|
+
const line = this.formatMessage(LOG_LEVEL_LABELS[level], message, finalMeta, ts);
|
|
26979
27063
|
console.error(line);
|
|
26980
27064
|
if (this.enableFileSink) {
|
|
26981
27065
|
const filePath = this.logFilePath;
|
|
@@ -26987,7 +27071,7 @@ class Logger {
|
|
|
26987
27071
|
ts,
|
|
26988
27072
|
level: LOG_LEVEL_BUFFER_TAGS[level],
|
|
26989
27073
|
message,
|
|
26990
|
-
...
|
|
27074
|
+
...finalMeta ? { meta: finalMeta } : {}
|
|
26991
27075
|
});
|
|
26992
27076
|
}
|
|
26993
27077
|
debug(message, meta3) {
|
|
@@ -27009,11 +27093,7 @@ class Logger {
|
|
|
27009
27093
|
if (this.shouldLog(LogLevel.ERROR)) {
|
|
27010
27094
|
const errorMeta = error51 ? {
|
|
27011
27095
|
...meta3,
|
|
27012
|
-
error: {
|
|
27013
|
-
name: error51.name,
|
|
27014
|
-
message: error51.message,
|
|
27015
|
-
stack: error51.stack
|
|
27016
|
-
}
|
|
27096
|
+
error: error51 instanceof Error ? pickErrorFields(error51, true) : { message: String(error51) }
|
|
27017
27097
|
} : meta3;
|
|
27018
27098
|
this.emit(LogLevel.ERROR, message, errorMeta);
|
|
27019
27099
|
}
|
|
@@ -27044,7 +27124,7 @@ class Logger {
|
|
|
27044
27124
|
return childLogger;
|
|
27045
27125
|
}
|
|
27046
27126
|
}
|
|
27047
|
-
var LogLevel, LOG_LEVEL_LABELS, LOG_LEVEL_BUFFER_TAGS, logger;
|
|
27127
|
+
var LogLevel, LOG_LEVEL_LABELS, LOG_LEVEL_BUFFER_TAGS, REPEAT_WINDOW_MS, MAX_REPEAT_KEYS = 500, MAX_ERROR_TEXT_CHARS = 300, logger;
|
|
27048
27128
|
var init_logger = __esm(() => {
|
|
27049
27129
|
init_config();
|
|
27050
27130
|
init_log_sink();
|
|
@@ -27067,6 +27147,7 @@ var init_logger = __esm(() => {
|
|
|
27067
27147
|
[LogLevel.WARN]: "warn",
|
|
27068
27148
|
[LogLevel.ERROR]: "error"
|
|
27069
27149
|
};
|
|
27150
|
+
REPEAT_WINDOW_MS = 15 * 60 * 1000;
|
|
27070
27151
|
logger = new Logger;
|
|
27071
27152
|
});
|
|
27072
27153
|
|
|
@@ -27122,8 +27203,9 @@ var init_metrics = __esm(() => {
|
|
|
27122
27203
|
}
|
|
27123
27204
|
} catch (error51) {
|
|
27124
27205
|
const err = error51 instanceof Error ? error51 : new Error(String(error51));
|
|
27125
|
-
logger.warn(
|
|
27126
|
-
|
|
27206
|
+
logger.warn("MetricsCollector: failed to fetch pricing", {
|
|
27207
|
+
modelId,
|
|
27208
|
+
error: err
|
|
27127
27209
|
});
|
|
27128
27210
|
}
|
|
27129
27211
|
const fallback = FALLBACK_PRICING[modelId];
|
|
@@ -27131,7 +27213,7 @@ var init_metrics = __esm(() => {
|
|
|
27131
27213
|
logger.debug(`Using fallback pricing for ${modelId}`);
|
|
27132
27214
|
return fallback;
|
|
27133
27215
|
}
|
|
27134
|
-
logger.warn(
|
|
27216
|
+
logger.warn("MetricsCollector: unknown model, using gpt-4 pricing as default", { modelId });
|
|
27135
27217
|
return FALLBACK_PRICING["gpt-4"];
|
|
27136
27218
|
}
|
|
27137
27219
|
static calculateCost(inputTokens, outputTokens, model) {
|
|
@@ -27310,7 +27392,9 @@ class SmartRateLimiter {
|
|
|
27310
27392
|
const hasRequestCapacity = this.requestLimiter.tryConsume(1);
|
|
27311
27393
|
const hasTokenCapacity = this.tokenLimiter.tryConsume(estimatedTokens);
|
|
27312
27394
|
if (!hasRequestCapacity) {
|
|
27313
|
-
logger.warn("Request rate limit exceeded"
|
|
27395
|
+
logger.warn("Request rate limit exceeded", {
|
|
27396
|
+
availableTokens: this.requestLimiter.getAvailableTokens()
|
|
27397
|
+
});
|
|
27314
27398
|
return false;
|
|
27315
27399
|
}
|
|
27316
27400
|
if (!hasTokenCapacity) {
|
|
@@ -27853,6 +27937,7 @@ function readRoles(liveRoot, activeProfile) {
|
|
|
27853
27937
|
}
|
|
27854
27938
|
function runtimeDriftReport(opts = {}) {
|
|
27855
27939
|
const targetHome = opts.targetHome ?? os6.homedir();
|
|
27940
|
+
const host = opts.host ?? "claude";
|
|
27856
27941
|
const stateFilePath = opts.stateFilePath ?? path10.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
27857
27942
|
let state = opts.state ?? null;
|
|
27858
27943
|
if (state === null) {
|
|
@@ -27862,9 +27947,24 @@ function runtimeDriftReport(opts = {}) {
|
|
|
27862
27947
|
state = null;
|
|
27863
27948
|
}
|
|
27864
27949
|
}
|
|
27865
|
-
const platform = state?.platforms?.
|
|
27950
|
+
const platform = state?.platforms?.[host];
|
|
27866
27951
|
const stateVersion = typeof platform?.plugin?.version === "string" ? platform.plugin.version : null;
|
|
27867
27952
|
const activeProfile = platform?.modelProfile?.profile ?? null;
|
|
27953
|
+
if (host !== "claude") {
|
|
27954
|
+
return {
|
|
27955
|
+
host,
|
|
27956
|
+
route: "unresolved",
|
|
27957
|
+
liveRoot: null,
|
|
27958
|
+
sourceVersion: null,
|
|
27959
|
+
stateVersion,
|
|
27960
|
+
pinnedVersion: null,
|
|
27961
|
+
activeProfile,
|
|
27962
|
+
roles: [],
|
|
27963
|
+
envOverride: detectEnvOverride(opts.env ?? process.env),
|
|
27964
|
+
versionDrift: false,
|
|
27965
|
+
profileMaterialized: false
|
|
27966
|
+
};
|
|
27967
|
+
}
|
|
27868
27968
|
const install = resolveClaudeMarketplaceInstall({ targetHome, pluginKey: opts.pluginKey });
|
|
27869
27969
|
const liveRoot = install?.root ?? null;
|
|
27870
27970
|
const sourceVersion = liveRoot === null ? null : readPluginVersion(liveRoot);
|
|
@@ -27936,7 +28036,7 @@ function listProfiles(opts = {}) {
|
|
|
27936
28036
|
installed: false,
|
|
27937
28037
|
skipped: false,
|
|
27938
28038
|
skipReason: null,
|
|
27939
|
-
activeProfile: platform2.modelProfile?.profile ??
|
|
28039
|
+
activeProfile: platform2.modelProfile?.profile ?? "balanced",
|
|
27940
28040
|
bundleVersion: platform2.plugin?.version ?? null,
|
|
27941
28041
|
availableProfiles: [],
|
|
27942
28042
|
...claudeDriftFields(host)
|
|
@@ -27963,7 +28063,7 @@ function listProfiles(opts = {}) {
|
|
|
27963
28063
|
installed,
|
|
27964
28064
|
skipped: false,
|
|
27965
28065
|
skipReason: null,
|
|
27966
|
-
activeProfile: platform?.modelProfile?.profile ??
|
|
28066
|
+
activeProfile: platform?.modelProfile?.profile ?? "balanced",
|
|
27967
28067
|
bundleVersion: platform?.plugin?.version ?? null,
|
|
27968
28068
|
availableProfiles,
|
|
27969
28069
|
...claudeDriftFields(host)
|
|
@@ -28943,6 +29043,7 @@ var init_dist = __esm(() => {
|
|
|
28943
29043
|
init_engine();
|
|
28944
29044
|
init_variant_sync();
|
|
28945
29045
|
init_repo_root();
|
|
29046
|
+
init_doctor();
|
|
28946
29047
|
init_bootstrap();
|
|
28947
29048
|
init_types2();
|
|
28948
29049
|
init_interfaces();
|
|
@@ -40095,7 +40196,7 @@ class ProjectIdentityAliasResolver {
|
|
|
40095
40196
|
this.cache.set(projectId, { canonical, expiresAt: this.now() + this.ttlMs });
|
|
40096
40197
|
return canonical;
|
|
40097
40198
|
} catch (error51) {
|
|
40098
|
-
logger.warn("[project-identity] alias resolution failed; using original id", safeErrorSummary(error51));
|
|
40199
|
+
logger.warn("[project-identity] alias resolution failed; using original id", { projectId, ...safeErrorSummary(error51) });
|
|
40099
40200
|
return projectId;
|
|
40100
40201
|
}
|
|
40101
40202
|
}
|
|
@@ -59202,7 +59303,7 @@ async function _checkJsonSchemaSupport() {
|
|
|
59202
59303
|
} catch (e) {
|
|
59203
59304
|
_jsonSchemaSupported = false;
|
|
59204
59305
|
logger.warn("json_schema: version check error \u2014 falling back to json_object", {
|
|
59205
|
-
error: e
|
|
59306
|
+
error: e
|
|
59206
59307
|
});
|
|
59207
59308
|
return false;
|
|
59208
59309
|
}
|
|
@@ -59250,7 +59351,7 @@ function hostPort(url2) {
|
|
|
59250
59351
|
return null;
|
|
59251
59352
|
}
|
|
59252
59353
|
}
|
|
59253
|
-
function
|
|
59354
|
+
function resolveMatchedProviderSpec(baseUrl) {
|
|
59254
59355
|
const target = hostPort(baseUrl);
|
|
59255
59356
|
if (target) {
|
|
59256
59357
|
const match2 = inferenceProviderList().find((spec) => hostPort(spec.defaultLlmBaseUrl) === target);
|
|
@@ -59268,7 +59369,13 @@ function resolveInferenceSpec(baseUrl) {
|
|
|
59268
59369
|
if (embeddingProvider && LOCAL_INFERENCE_IDS.includes(embeddingProvider)) {
|
|
59269
59370
|
return INFERENCE_PROVIDERS[embeddingProvider];
|
|
59270
59371
|
}
|
|
59271
|
-
return
|
|
59372
|
+
return;
|
|
59373
|
+
}
|
|
59374
|
+
function resolveInferenceSpec(baseUrl) {
|
|
59375
|
+
return resolveMatchedProviderSpec(baseUrl) ?? INFERENCE_PROVIDERS.ollama;
|
|
59376
|
+
}
|
|
59377
|
+
function resolveProviderIdForLogging(baseUrl) {
|
|
59378
|
+
return resolveMatchedProviderSpec(baseUrl)?.id ?? "unknown";
|
|
59272
59379
|
}
|
|
59273
59380
|
function _wrapFetchDisableThink(baseFetch) {
|
|
59274
59381
|
const wrapped = async (input, init) => {
|
|
@@ -59411,12 +59518,40 @@ function _isAbortOrTimeoutError(err) {
|
|
|
59411
59518
|
}
|
|
59412
59519
|
return false;
|
|
59413
59520
|
}
|
|
59414
|
-
|
|
59521
|
+
function summarizeZodIssues(error51, maxIssues = 5) {
|
|
59522
|
+
return error51.issues.slice(0, maxIssues).map((issue2) => `${issue2.path.join(".") || "(root)"}: ${issue2.message}`).join("; ");
|
|
59523
|
+
}
|
|
59524
|
+
function recordLlmFailure(label, role, model, baseUrl, timeoutMs, elapsedMs, err) {
|
|
59525
|
+
const consecutiveFailures = (llmFailureStreaks.get(label) ?? 0) + 1;
|
|
59526
|
+
llmFailureStreaks.set(label, consecutiveFailures);
|
|
59527
|
+
logger.warn("LLM call failed \u2014 using non-LLM fallback", {
|
|
59528
|
+
label,
|
|
59529
|
+
role,
|
|
59530
|
+
model,
|
|
59531
|
+
provider: resolveProviderIdForLogging(baseUrl),
|
|
59532
|
+
timeoutMs,
|
|
59533
|
+
elapsedMs,
|
|
59534
|
+
timedOut: _isAbortOrTimeoutError(err),
|
|
59535
|
+
error: err,
|
|
59536
|
+
consecutiveFailures
|
|
59537
|
+
});
|
|
59538
|
+
return consecutiveFailures;
|
|
59539
|
+
}
|
|
59540
|
+
function recordLlmSuccess(label, model) {
|
|
59541
|
+
const priorFailures = llmFailureStreaks.get(label) ?? 0;
|
|
59542
|
+
if (priorFailures > 0) {
|
|
59543
|
+
logger.info("LLM call recovered", { label, model, afterFailures: priorFailures });
|
|
59544
|
+
}
|
|
59545
|
+
llmFailureStreaks.set(label, 0);
|
|
59546
|
+
}
|
|
59547
|
+
async function llmComplete(prompt, opts) {
|
|
59415
59548
|
if (!isLlmEnabled()) {
|
|
59416
59549
|
return { ok: false, error: "llm disabled" };
|
|
59417
59550
|
}
|
|
59418
59551
|
const llm = getLlmConfig({ modelRole: opts.modelRole });
|
|
59552
|
+
const role = opts.modelRole ?? "instruct";
|
|
59419
59553
|
const timeoutMs = opts.timeoutMs ?? llm.timeoutMs;
|
|
59554
|
+
const startedAt = Date.now();
|
|
59420
59555
|
try {
|
|
59421
59556
|
const result = await generateText({
|
|
59422
59557
|
model: buildProvider(llm),
|
|
@@ -59427,14 +59562,17 @@ async function llmComplete(prompt, opts = {}) {
|
|
|
59427
59562
|
abortSignal: timeoutSignal(timeoutMs)
|
|
59428
59563
|
});
|
|
59429
59564
|
const text2 = result.text ?? "";
|
|
59430
|
-
if (text2.length > 0)
|
|
59565
|
+
if (text2.length > 0) {
|
|
59566
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59431
59567
|
return { ok: true, value: text2 };
|
|
59568
|
+
}
|
|
59432
59569
|
if (llm.disableThink) {
|
|
59433
59570
|
const reasoning = _reasoningToText(result);
|
|
59434
59571
|
if (reasoning.length > 0) {
|
|
59435
59572
|
logger.warn("llmComplete: empty content \u2014 recovered from reasoning channel", {
|
|
59436
59573
|
reasoningLen: reasoning.length
|
|
59437
59574
|
});
|
|
59575
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59438
59576
|
return { ok: true, value: reasoning };
|
|
59439
59577
|
}
|
|
59440
59578
|
logger.warn("llm reasoning-recovery empty", {
|
|
@@ -59442,21 +59580,22 @@ async function llmComplete(prompt, opts = {}) {
|
|
|
59442
59580
|
finishReason: result?.finishReason ?? null
|
|
59443
59581
|
});
|
|
59444
59582
|
}
|
|
59445
|
-
|
|
59446
|
-
|
|
59583
|
+
const emptyErr = new Error("empty content (thinking model)");
|
|
59584
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, emptyErr);
|
|
59585
|
+
return { ok: false, error: emptyErr.message };
|
|
59447
59586
|
} catch (e) {
|
|
59448
|
-
|
|
59449
|
-
error: e.message
|
|
59450
|
-
});
|
|
59587
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, e);
|
|
59451
59588
|
return { ok: false, error: e.message };
|
|
59452
59589
|
}
|
|
59453
59590
|
}
|
|
59454
|
-
async function llmObject(prompt, schema, opts
|
|
59591
|
+
async function llmObject(prompt, schema, opts) {
|
|
59455
59592
|
if (!isLlmEnabled()) {
|
|
59456
59593
|
return { ok: false, error: "llm disabled" };
|
|
59457
59594
|
}
|
|
59458
59595
|
const llm = getLlmConfig({ modelRole: opts.modelRole });
|
|
59596
|
+
const role = opts.modelRole ?? "instruct";
|
|
59459
59597
|
const timeoutMs = opts.timeoutMs ?? llm.timeoutMs;
|
|
59598
|
+
const startedAt = Date.now();
|
|
59460
59599
|
let result = null;
|
|
59461
59600
|
try {
|
|
59462
59601
|
const useJsonSchema = llm.disableThink && await _checkJsonSchemaSupport();
|
|
@@ -59471,7 +59610,8 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
59471
59610
|
maxOutputTokens: llm.maxOutputTokens,
|
|
59472
59611
|
abortSignal: timeoutSignal(timeoutMs)
|
|
59473
59612
|
});
|
|
59474
|
-
logger.
|
|
59613
|
+
logger.debug("json_schema: constrained decoding used", { label: opts.label, model: llm.model });
|
|
59614
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59475
59615
|
return { ok: true, value: result.object };
|
|
59476
59616
|
}
|
|
59477
59617
|
result = await generateObject({
|
|
@@ -59485,7 +59625,8 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
59485
59625
|
});
|
|
59486
59626
|
const validated = schema.safeParse(result.object);
|
|
59487
59627
|
if (validated.success) {
|
|
59488
|
-
logger.
|
|
59628
|
+
logger.debug("json_schema: fallback to json_object \u2014 validated", { label: opts.label, model: llm.model });
|
|
59629
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59489
59630
|
return { ok: true, value: validated.data };
|
|
59490
59631
|
}
|
|
59491
59632
|
if (llm.disableThink) {
|
|
@@ -59498,15 +59639,17 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
59498
59639
|
logger.warn("llmObject: recovered object from reasoning channel (fallback path)", {
|
|
59499
59640
|
reasoningLen: reasoning.length
|
|
59500
59641
|
});
|
|
59642
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59501
59643
|
return { ok: true, value: recovered.data };
|
|
59502
59644
|
}
|
|
59503
59645
|
}
|
|
59504
59646
|
}
|
|
59505
59647
|
}
|
|
59506
|
-
|
|
59507
|
-
|
|
59648
|
+
const validationErr = new Error("schema validation failed (fallback path)", {
|
|
59649
|
+
cause: summarizeZodIssues(validated.error)
|
|
59508
59650
|
});
|
|
59509
|
-
|
|
59651
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, validationErr);
|
|
59652
|
+
return { ok: false, error: validationErr.message };
|
|
59510
59653
|
} catch (e) {
|
|
59511
59654
|
if (llm.disableThink && !_isAbortOrTimeoutError(e)) {
|
|
59512
59655
|
const reasoning = _reasoningToText(result).length > 0 ? _reasoningToText(result) : _reasoningToText(e);
|
|
@@ -59518,6 +59661,7 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
59518
59661
|
logger.warn("llmObject: recovered object from reasoning channel", {
|
|
59519
59662
|
reasoningLen: reasoning.length
|
|
59520
59663
|
});
|
|
59664
|
+
recordLlmSuccess(opts.label, llm.model);
|
|
59521
59665
|
return { ok: true, value: validated.data };
|
|
59522
59666
|
}
|
|
59523
59667
|
}
|
|
@@ -59527,19 +59671,18 @@ async function llmObject(prompt, schema, opts = {}) {
|
|
|
59527
59671
|
finishReason: e?.finishReason ?? null
|
|
59528
59672
|
});
|
|
59529
59673
|
}
|
|
59530
|
-
|
|
59531
|
-
error: e.message
|
|
59532
|
-
});
|
|
59674
|
+
recordLlmFailure(opts.label, role, llm.model, llm.baseUrl, timeoutMs, Date.now() - startedAt, e);
|
|
59533
59675
|
return { ok: false, error: e.message };
|
|
59534
59676
|
}
|
|
59535
59677
|
}
|
|
59536
|
-
var _jsonSchemaSupported = null, testEnabledOverride = null, testBaseUrlOverride = null, llm;
|
|
59678
|
+
var _jsonSchemaSupported = null, testEnabledOverride = null, testBaseUrlOverride = null, llmFailureStreaks, llm;
|
|
59537
59679
|
var init_llm_client = __esm(() => {
|
|
59538
59680
|
init_dist6();
|
|
59539
59681
|
init_dist7();
|
|
59540
59682
|
init_dist();
|
|
59541
59683
|
init_config();
|
|
59542
59684
|
init_inference_providers();
|
|
59685
|
+
llmFailureStreaks = new Map;
|
|
59543
59686
|
llm = {
|
|
59544
59687
|
complete: llmComplete,
|
|
59545
59688
|
object: llmObject,
|
|
@@ -68552,7 +68695,7 @@ class MetricsCollector2 {
|
|
|
68552
68695
|
try {
|
|
68553
68696
|
writeFileSync(this.metricsPath, JSON.stringify(this.currentMetrics, null, 2));
|
|
68554
68697
|
} catch (error51) {
|
|
68555
|
-
logger.error("
|
|
68698
|
+
logger.error("Metrics: failed to save", error51, { path: this.metricsPath });
|
|
68556
68699
|
}
|
|
68557
68700
|
}
|
|
68558
68701
|
reset() {
|
|
@@ -68727,7 +68870,8 @@ class EmbeddingRateLimiter {
|
|
|
68727
68870
|
}
|
|
68728
68871
|
}
|
|
68729
68872
|
if (this.config.requestsPerDay && this.dailyRequestsWindow.length >= this.config.requestsPerDay) {
|
|
68730
|
-
logger.warn(
|
|
68873
|
+
logger.warn("EmbeddingRateLimiter: RPD limit reached, waiting 60s", {
|
|
68874
|
+
providerId: this.providerId,
|
|
68731
68875
|
rpd: this.config.requestsPerDay,
|
|
68732
68876
|
current: this.dailyRequestsWindow.length
|
|
68733
68877
|
});
|
|
@@ -102030,16 +102174,16 @@ class LocalTransformersEmbeddingProvider {
|
|
|
102030
102174
|
const out = await extractor("test", { pooling: "mean", normalize: true });
|
|
102031
102175
|
const vec = Array.from(out.data);
|
|
102032
102176
|
if (!Array.isArray(vec) || vec.length !== this.dimensions) {
|
|
102033
|
-
logger.error(
|
|
102177
|
+
logger.error("LocalTransformersProvider: invalid embedding dimensions", undefined, { providerId: this.id, expected: this.dimensions, got: vec.length });
|
|
102034
102178
|
return false;
|
|
102035
102179
|
}
|
|
102036
102180
|
if (vec.some((v) => typeof v !== "number" || isNaN(v))) {
|
|
102037
|
-
logger.error(
|
|
102181
|
+
logger.error("LocalTransformersProvider: invalid embedding values (not numbers)", undefined, { providerId: this.id });
|
|
102038
102182
|
return false;
|
|
102039
102183
|
}
|
|
102040
102184
|
return true;
|
|
102041
102185
|
} catch (error51) {
|
|
102042
|
-
logger.error(
|
|
102186
|
+
logger.error("LocalTransformersProvider: provider unavailable", error51, { providerId: this.id });
|
|
102043
102187
|
return false;
|
|
102044
102188
|
}
|
|
102045
102189
|
}
|
|
@@ -102079,7 +102223,13 @@ async function withRetry(fn, config3, context2) {
|
|
|
102079
102223
|
lastError2 = error51;
|
|
102080
102224
|
if (attempt < config3.maxRetries) {
|
|
102081
102225
|
const delay2 = getRetryDelay(attempt, config3);
|
|
102082
|
-
logger.warn(
|
|
102226
|
+
logger.warn("EmbeddingProvider: operation failed, retrying", {
|
|
102227
|
+
context: context2,
|
|
102228
|
+
attempt: attempt + 1,
|
|
102229
|
+
maxAttempts: config3.maxRetries + 1,
|
|
102230
|
+
delayMs: delay2,
|
|
102231
|
+
error: lastError2
|
|
102232
|
+
});
|
|
102083
102233
|
await sleep(delay2);
|
|
102084
102234
|
}
|
|
102085
102235
|
}
|
|
@@ -102395,7 +102545,7 @@ var init_provider = __esm(() => {
|
|
|
102395
102545
|
return output;
|
|
102396
102546
|
}, this.retryConfig, `[${this.id}] embedBatchDirect (${texts.length} texts)`), this.timeout, `[${this.id}] embedBatchDirect`);
|
|
102397
102547
|
} catch (error51) {
|
|
102398
|
-
logger.warn(
|
|
102548
|
+
logger.warn("EmbeddingProvider: Ollama batch endpoint unavailable, falling back to sequential embeds", { providerId: this.id, textCount: texts.length, error: error51 });
|
|
102399
102549
|
const embeddings = [];
|
|
102400
102550
|
let consecutiveFailures = 0;
|
|
102401
102551
|
for (const text2 of texts) {
|
|
@@ -102434,11 +102584,11 @@ var init_provider = __esm(() => {
|
|
|
102434
102584
|
});
|
|
102435
102585
|
clearTimeout(timeoutId);
|
|
102436
102586
|
if (!response.ok) {
|
|
102437
|
-
logger.error(
|
|
102587
|
+
logger.error("EmbeddingProvider: Ollama API returned non-OK status", undefined, { providerId: this.id, status: response.status });
|
|
102438
102588
|
return false;
|
|
102439
102589
|
}
|
|
102440
102590
|
} catch {
|
|
102441
|
-
logger.error(
|
|
102591
|
+
logger.error("EmbeddingProvider: Ollama service unreachable", undefined, { providerId: this.id, baseURL: this.baseURL, timeoutMs: 2000 });
|
|
102442
102592
|
return false;
|
|
102443
102593
|
}
|
|
102444
102594
|
}
|
|
@@ -102448,16 +102598,16 @@ var init_provider = __esm(() => {
|
|
|
102448
102598
|
if (Array.isArray(embedding)) {
|
|
102449
102599
|
this.lastDimensionMismatch = new DimensionMismatchError(this.id, this.dimensions, embedding.length);
|
|
102450
102600
|
}
|
|
102451
|
-
logger.error(
|
|
102601
|
+
logger.error("EmbeddingProvider: invalid embedding dimensions", undefined, { providerId: this.id, expected: this.dimensions, got: embedding.length });
|
|
102452
102602
|
return false;
|
|
102453
102603
|
}
|
|
102454
102604
|
if (!embedding.every((v) => typeof v === "number" && !isNaN(v))) {
|
|
102455
|
-
logger.error(
|
|
102605
|
+
logger.error("EmbeddingProvider: invalid embedding values (not numbers)", undefined, { providerId: this.id });
|
|
102456
102606
|
return false;
|
|
102457
102607
|
}
|
|
102458
102608
|
return true;
|
|
102459
102609
|
} catch (error51) {
|
|
102460
|
-
logger.error(
|
|
102610
|
+
logger.error("EmbeddingProvider: provider unavailable", error51, { providerId: this.id });
|
|
102461
102611
|
return false;
|
|
102462
102612
|
}
|
|
102463
102613
|
}
|
|
@@ -114673,7 +114823,7 @@ function getPrismaClient2() {
|
|
|
114673
114823
|
const pg2 = _adapters.loadPg();
|
|
114674
114824
|
const { PrismaPg: PrismaPg2 } = _adapters.loadPrismaPg();
|
|
114675
114825
|
const pool = new pg2.Pool({ connectionString: databaseUrl, max: 10, idleTimeoutMillis: 30000, connectionTimeoutMillis: 5000 });
|
|
114676
|
-
pool.on("error", (error51) => logger.error("
|
|
114826
|
+
pool.on("error", (error51) => logger.error("prisma-client: unexpected PG pool error", error51, { poolMax: 10 }));
|
|
114677
114827
|
prismaPool = pool;
|
|
114678
114828
|
prismaInstance = new import_prisma.PrismaClient({ adapter: new PrismaPg2(pool) });
|
|
114679
114829
|
logger.info("Prisma Client initialized with PostgreSQL");
|
|
@@ -114982,7 +115132,10 @@ var init_config2 = __esm(() => {
|
|
|
114982
115132
|
"local"
|
|
114983
115133
|
]);
|
|
114984
115134
|
if (!SELECTABLE_PROVIDERS.has(selectedProvider)) {
|
|
114985
|
-
logger.warn(
|
|
115135
|
+
logger.warn("EmbeddingConfig: selected provider has no runtime entry, falling back to priority order", {
|
|
115136
|
+
selectedProvider,
|
|
115137
|
+
source: process.env.EMBEDDING_PROVIDER ? "EMBEDDING_PROVIDER env" : "config.json embedding.provider"
|
|
115138
|
+
});
|
|
114986
115139
|
}
|
|
114987
115140
|
embeddingProviders = {
|
|
114988
115141
|
google: (() => {
|
|
@@ -115022,7 +115175,12 @@ var init_config2 = __esm(() => {
|
|
|
115022
115175
|
const envDimensions = Number.isInteger(rawEnvDimensions) && rawEnvDimensions > 0 ? rawEnvDimensions : undefined;
|
|
115023
115176
|
const resolvedDimensions = resolveEmbeddingDimensions(model, file2?.dimensions, envDimensions);
|
|
115024
115177
|
if (resolvedDimensions.correctedFrom !== undefined) {
|
|
115025
|
-
logger.warn(
|
|
115178
|
+
logger.warn("EmbeddingConfig: ollama config.json dimensions mismatch corrected", {
|
|
115179
|
+
provider: "ollama",
|
|
115180
|
+
model,
|
|
115181
|
+
configuredDimensions: resolvedDimensions.correctedFrom,
|
|
115182
|
+
correctedDimensions: resolvedDimensions.dimensions
|
|
115183
|
+
});
|
|
115026
115184
|
}
|
|
115027
115185
|
return {
|
|
115028
115186
|
provider: "ollama",
|
|
@@ -115174,8 +115332,8 @@ class EmbeddingService {
|
|
|
115174
115332
|
dimensions: this.provider.dimensions
|
|
115175
115333
|
});
|
|
115176
115334
|
} catch (error51) {
|
|
115177
|
-
logger.error("Failed to initialize embedding service", error51);
|
|
115178
|
-
logger.warn("Embedding service will use fallback mode");
|
|
115335
|
+
logger.error("Failed to initialize embedding service", error51, { stage: "initialize" });
|
|
115336
|
+
logger.warn("Embedding service will use fallback mode", { stage: "initialize" });
|
|
115179
115337
|
}
|
|
115180
115338
|
}
|
|
115181
115339
|
async ensureInitialized() {
|
|
@@ -115257,7 +115415,7 @@ async function tryCreateProvider(config3, providerId, skipHealthCheck) {
|
|
|
115257
115415
|
return { provider };
|
|
115258
115416
|
}
|
|
115259
115417
|
function refuseOnDimensionMismatch(providerId, mismatch) {
|
|
115260
|
-
logger.error(
|
|
115418
|
+
logger.error("EmbeddingProvider: configured provider failed with a dimension mismatch, refusing to fall through", mismatch, { providerId, configuredDimensions: mismatch.expected, modelDimensions: mismatch.got });
|
|
115261
115419
|
throw mismatch;
|
|
115262
115420
|
}
|
|
115263
115421
|
async function createEmbeddingProvider(options = {}) {
|
|
@@ -115356,6 +115514,7 @@ Write the hypothetical implementation paragraph.`;
|
|
|
115356
115514
|
}
|
|
115357
115515
|
async function rewriteQuery(query, surface, opts = {}) {
|
|
115358
115516
|
const res = await surface.object(rewritePrompt(query), QueryRewriteSchema, {
|
|
115517
|
+
label: "query-rewrite",
|
|
115359
115518
|
system: REWRITE_SYSTEM,
|
|
115360
115519
|
timeoutMs: opts.timeoutMs
|
|
115361
115520
|
});
|
|
@@ -115368,6 +115527,7 @@ async function rewriteQuery(query, surface, opts = {}) {
|
|
|
115368
115527
|
}
|
|
115369
115528
|
async function hyde(query, surface, embedFn, opts = {}) {
|
|
115370
115529
|
const text2 = await surface.complete(hydePrompt(query), {
|
|
115530
|
+
label: "hyde",
|
|
115371
115531
|
system: HYDE_SYSTEM,
|
|
115372
115532
|
timeoutMs: opts.timeoutMs
|
|
115373
115533
|
});
|
|
@@ -115381,7 +115541,7 @@ async function hyde(query, surface, embedFn, opts = {}) {
|
|
|
115381
115541
|
return vec;
|
|
115382
115542
|
} catch (e) {
|
|
115383
115543
|
logger.warn("hyde embed failed \u2014 skipping HyDE stream", {
|
|
115384
|
-
error: e
|
|
115544
|
+
error: e
|
|
115385
115545
|
});
|
|
115386
115546
|
return null;
|
|
115387
115547
|
}
|
|
@@ -117109,7 +117269,7 @@ class KeywordSearchPg {
|
|
|
117109
117269
|
`);
|
|
117110
117270
|
this.trigramAvailable = true;
|
|
117111
117271
|
} catch (error51) {
|
|
117112
|
-
logger.warn("pg_trgm unavailable \u2014 trigram RRF stream disabled on PG", {
|
|
117272
|
+
logger.warn("pg_trgm unavailable \u2014 trigram RRF stream disabled on PG", { error: error51 });
|
|
117113
117273
|
this.trigramAvailable = false;
|
|
117114
117274
|
}
|
|
117115
117275
|
logger.info("PostgreSQL keyword search initialized", {
|
|
@@ -117648,7 +117808,8 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
117648
117808
|
this.schemaDimensions = providerDimensions;
|
|
117649
117809
|
const { rows } = await client.query(`SELECT tablename FROM pg_tables WHERE tablename = $1`, [this.tableName]);
|
|
117650
117810
|
if (rows.length === 0) {
|
|
117651
|
-
logger.warn(
|
|
117811
|
+
logger.warn("PostgresVectorStore: table not found, creating fallback table", {
|
|
117812
|
+
tableName: this.tableName,
|
|
117652
117813
|
note: 'Run "prisma migrate deploy" to create tables via migrations'
|
|
117653
117814
|
});
|
|
117654
117815
|
await this.createFallbackTable(client, providerDimensions);
|
|
@@ -117685,10 +117846,12 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
117685
117846
|
if (projects.length === 0)
|
|
117686
117847
|
continue;
|
|
117687
117848
|
const otherDim = tablename.match(/_([0-9]+)d$/)?.[1];
|
|
117688
|
-
logger.warn(
|
|
117849
|
+
logger.warn("PostgresVectorStore: orphaned chunks detected, embedding model likely changed, reindex required", {
|
|
117689
117850
|
currentTable: this.tableName,
|
|
117690
117851
|
currentCount,
|
|
117852
|
+
currentDim,
|
|
117691
117853
|
orphanedTable: tablename,
|
|
117854
|
+
orphanedDim: otherDim,
|
|
117692
117855
|
affectedProjects: projects.map((p) => ({ projectId: p.project_id, chunks: p.n }))
|
|
117693
117856
|
});
|
|
117694
117857
|
}
|
|
@@ -117832,7 +117995,7 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
117832
117995
|
logger.warn("[postgres] Sub-batch embedding failed, falling back per-document", {
|
|
117833
117996
|
subBatchIndex: Math.floor(i / EMBED_SUB_BATCH_SIZE),
|
|
117834
117997
|
count: subBatch.length,
|
|
117835
|
-
error: error51
|
|
117998
|
+
error: error51
|
|
117836
117999
|
});
|
|
117837
118000
|
}
|
|
117838
118001
|
if (embeddings) {
|
|
@@ -117844,7 +118007,7 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
117844
118007
|
logger.warn("[postgres] Sub-batch insert failed, falling back per-document", {
|
|
117845
118008
|
subBatchIndex: Math.floor(i / EMBED_SUB_BATCH_SIZE),
|
|
117846
118009
|
count: subBatch.length,
|
|
117847
|
-
error: error51
|
|
118010
|
+
error: error51
|
|
117848
118011
|
});
|
|
117849
118012
|
}
|
|
117850
118013
|
}
|
|
@@ -117857,7 +118020,7 @@ var init_postgres_vector_store = __esm(() => {
|
|
|
117857
118020
|
totalFailed++;
|
|
117858
118021
|
logger.warn("[postgres] Skipping document due to embedding/insert error", {
|
|
117859
118022
|
id: doc2.id,
|
|
117860
|
-
error: singleError
|
|
118023
|
+
error: singleError
|
|
117861
118024
|
});
|
|
117862
118025
|
}
|
|
117863
118026
|
}
|
|
@@ -118529,7 +118692,9 @@ class SearchAnalyticsPg {
|
|
|
118529
118692
|
}
|
|
118530
118693
|
trackSearch(event) {
|
|
118531
118694
|
this.trackSearchAsync(event).catch((err) => {
|
|
118532
|
-
logger.error("Failed to track search event", err
|
|
118695
|
+
logger.error("Failed to track search event", err, {
|
|
118696
|
+
projectId: event.projectId
|
|
118697
|
+
});
|
|
118533
118698
|
});
|
|
118534
118699
|
}
|
|
118535
118700
|
async trackSearchAsync(event) {
|
|
@@ -118554,7 +118719,9 @@ class SearchAnalyticsPg {
|
|
|
118554
118719
|
event.score || null
|
|
118555
118720
|
]);
|
|
118556
118721
|
} catch (error51) {
|
|
118557
|
-
logger.error("Failed to track search event in PostgreSQL", error51
|
|
118722
|
+
logger.error("Failed to track search event in PostgreSQL", error51, {
|
|
118723
|
+
projectId: event.projectId
|
|
118724
|
+
});
|
|
118558
118725
|
}
|
|
118559
118726
|
}
|
|
118560
118727
|
async recordQuery(query, projectId, resultsCount = 0, duration3 = 0, cacheHit = false) {
|
|
@@ -121155,7 +121322,11 @@ class GraphStorePg {
|
|
|
121155
121322
|
`;
|
|
121156
121323
|
return rows[0] ? rowToEdge(rows[0]) : null;
|
|
121157
121324
|
} catch (error51) {
|
|
121158
|
-
logger.error("Failed to create edge", error51
|
|
121325
|
+
logger.error("Failed to create edge", error51, {
|
|
121326
|
+
sourceId: edge.sourceId,
|
|
121327
|
+
targetId: edge.targetId,
|
|
121328
|
+
relationType: edge.relationType
|
|
121329
|
+
});
|
|
121159
121330
|
return null;
|
|
121160
121331
|
}
|
|
121161
121332
|
}
|
|
@@ -121751,7 +121922,7 @@ class PgSynapseSessionStore {
|
|
|
121751
121922
|
} catch (e) {
|
|
121752
121923
|
this.hydrateFailedAt = Date.now();
|
|
121753
121924
|
logger.warn("PgSynapseSessionStore hydrate failed (best-effort)", {
|
|
121754
|
-
error: e
|
|
121925
|
+
error: e
|
|
121755
121926
|
});
|
|
121756
121927
|
} finally {
|
|
121757
121928
|
this.hydrating = null;
|
|
@@ -121886,7 +122057,7 @@ class PgSynapseSessionStore {
|
|
|
121886
122057
|
const next = prev.then(fn).catch((e) => {
|
|
121887
122058
|
logger.warn("PgSynapseSessionStore write failed (best-effort)", {
|
|
121888
122059
|
key,
|
|
121889
|
-
error: e
|
|
122060
|
+
error: e
|
|
121890
122061
|
});
|
|
121891
122062
|
});
|
|
121892
122063
|
this.inflight.set(key, next);
|
|
@@ -121992,7 +122163,7 @@ class SessionRegistry {
|
|
|
121992
122163
|
try {
|
|
121993
122164
|
this.store?.save(session);
|
|
121994
122165
|
} catch (error51) {
|
|
121995
|
-
logger.warn("
|
|
122166
|
+
logger.warn("SessionRegistry: store save failed", { sessionId: session.sessionId, error: error51 });
|
|
121996
122167
|
}
|
|
121997
122168
|
return session;
|
|
121998
122169
|
}
|
|
@@ -122000,7 +122171,7 @@ class SessionRegistry {
|
|
|
122000
122171
|
try {
|
|
122001
122172
|
await this.store?.ensureReady();
|
|
122002
122173
|
} catch (error51) {
|
|
122003
|
-
logger.warn("
|
|
122174
|
+
logger.warn("SessionRegistry: store ensureReady failed", { error: error51 });
|
|
122004
122175
|
}
|
|
122005
122176
|
}
|
|
122006
122177
|
async getAsync(sessionId, now2 = Date.now()) {
|
|
@@ -122021,7 +122192,7 @@ class SessionRegistry {
|
|
|
122021
122192
|
session = loaded;
|
|
122022
122193
|
}
|
|
122023
122194
|
} catch (error51) {
|
|
122024
|
-
logger.warn("
|
|
122195
|
+
logger.warn("SessionRegistry: store load failed", { sessionId, error: error51 });
|
|
122025
122196
|
}
|
|
122026
122197
|
}
|
|
122027
122198
|
if (!session)
|
|
@@ -122031,7 +122202,7 @@ class SessionRegistry {
|
|
|
122031
122202
|
try {
|
|
122032
122203
|
this.store?.delete(sessionId);
|
|
122033
122204
|
} catch (error51) {
|
|
122034
|
-
logger.warn("
|
|
122205
|
+
logger.warn("SessionRegistry: store delete (expired) failed", { sessionId, error: error51 });
|
|
122035
122206
|
}
|
|
122036
122207
|
return null;
|
|
122037
122208
|
}
|
|
@@ -122053,7 +122224,7 @@ class SessionRegistry {
|
|
|
122053
122224
|
try {
|
|
122054
122225
|
this.store?.save(session);
|
|
122055
122226
|
} catch (error51) {
|
|
122056
|
-
logger.warn("
|
|
122227
|
+
logger.warn("SessionRegistry: store save (updateTaskContext) failed", { sessionId, error: error51 });
|
|
122057
122228
|
}
|
|
122058
122229
|
return session;
|
|
122059
122230
|
}
|
|
@@ -122080,7 +122251,7 @@ class SessionRegistry {
|
|
|
122080
122251
|
try {
|
|
122081
122252
|
this.store?.recordAccess(sessionId, memoryId, nextCount);
|
|
122082
122253
|
} catch (error51) {
|
|
122083
|
-
logger.warn("
|
|
122254
|
+
logger.warn("SessionRegistry: store recordAccess failed", { sessionId, memoryId, error: error51 });
|
|
122084
122255
|
}
|
|
122085
122256
|
}
|
|
122086
122257
|
delete(sessionId) {
|
|
@@ -122088,7 +122259,7 @@ class SessionRegistry {
|
|
|
122088
122259
|
try {
|
|
122089
122260
|
this.store?.delete(sessionId);
|
|
122090
122261
|
} catch (error51) {
|
|
122091
|
-
logger.warn("
|
|
122262
|
+
logger.warn("SessionRegistry: store delete failed", { sessionId, error: error51 });
|
|
122092
122263
|
}
|
|
122093
122264
|
return removed;
|
|
122094
122265
|
}
|
|
@@ -122116,7 +122287,7 @@ function getSessionRegistry() {
|
|
|
122116
122287
|
const { getSessionStore: getSessionStore2 } = (init_session_store(), __toCommonJS(exports_session_store));
|
|
122117
122288
|
store2 = getSessionStore2();
|
|
122118
122289
|
} catch (error51) {
|
|
122119
|
-
logger.warn("
|
|
122290
|
+
logger.warn("SessionRegistry: store init failed, falling back to MemorySessionStore", { error: error51 });
|
|
122120
122291
|
const { MemorySessionStore: MemorySessionStore2 } = (init_session_store(), __toCommonJS(exports_session_store));
|
|
122121
122292
|
store2 = new MemorySessionStore2;
|
|
122122
122293
|
}
|
|
@@ -122933,19 +123104,22 @@ class LLMJudgeReranker {
|
|
|
122933
123104
|
const tail = results.slice(k);
|
|
122934
123105
|
const prompt = buildPrompt(query, head);
|
|
122935
123106
|
let verdict;
|
|
123107
|
+
let verdictError;
|
|
122936
123108
|
try {
|
|
122937
|
-
const res = await this.llm.object(prompt, RerankVerdictSchema, { modelRole: "code" });
|
|
123109
|
+
const res = await this.llm.object(prompt, RerankVerdictSchema, { label: "reranker", modelRole: "code" });
|
|
122938
123110
|
verdict = res.ok ? res.value ?? null : null;
|
|
123111
|
+
verdictError = res.ok ? undefined : res.error;
|
|
122939
123112
|
} catch (e) {
|
|
122940
123113
|
logger.warn("LLMJudgeReranker threw \u2014 degrading to input order", {
|
|
122941
123114
|
query,
|
|
122942
|
-
error: e
|
|
123115
|
+
error: e
|
|
122943
123116
|
});
|
|
122944
123117
|
return results;
|
|
122945
123118
|
}
|
|
122946
123119
|
if (!verdict) {
|
|
122947
123120
|
logger.warn("LLMJudgeReranker got {ok:false} \u2014 degrading to input order", {
|
|
122948
|
-
query
|
|
123121
|
+
query,
|
|
123122
|
+
error: verdictError
|
|
122949
123123
|
});
|
|
122950
123124
|
return results;
|
|
122951
123125
|
}
|
|
@@ -124791,7 +124965,7 @@ class TaskEnvelopeService {
|
|
|
124791
124965
|
errors4.push("prime");
|
|
124792
124966
|
logger.warn("synapse_task_begin: prime sub-step failed", {
|
|
124793
124967
|
sessionId,
|
|
124794
|
-
error: err
|
|
124968
|
+
error: err
|
|
124795
124969
|
});
|
|
124796
124970
|
}
|
|
124797
124971
|
}
|
|
@@ -124814,7 +124988,7 @@ class TaskEnvelopeService {
|
|
|
124814
124988
|
errors4.push("search");
|
|
124815
124989
|
logger.warn("synapse_task_begin: search sub-step failed", {
|
|
124816
124990
|
sessionId,
|
|
124817
|
-
error: err
|
|
124991
|
+
error: err
|
|
124818
124992
|
});
|
|
124819
124993
|
}
|
|
124820
124994
|
if (firstHitFile) {
|
|
@@ -124837,7 +125011,7 @@ class TaskEnvelopeService {
|
|
|
124837
125011
|
errors4.push("prefetch");
|
|
124838
125012
|
logger.warn("synapse_task_begin: prefetch sub-step failed", {
|
|
124839
125013
|
sessionId,
|
|
124840
|
-
error: err
|
|
125014
|
+
error: err
|
|
124841
125015
|
});
|
|
124842
125016
|
}
|
|
124843
125017
|
}
|
|
@@ -124848,7 +125022,7 @@ class TaskEnvelopeService {
|
|
|
124848
125022
|
errors4.push("access");
|
|
124849
125023
|
logger.warn("synapse_task_begin: access sub-step failed", {
|
|
124850
125024
|
sessionId,
|
|
124851
|
-
error: err
|
|
125025
|
+
error: err
|
|
124852
125026
|
});
|
|
124853
125027
|
}
|
|
124854
125028
|
}
|
|
@@ -125191,7 +125365,7 @@ async function applySynapseState(deps, baseResults, query, projectId, sessionId,
|
|
|
125191
125365
|
logger.warn("Synapse session lookup failed \u2014 using stateless search", {
|
|
125192
125366
|
sessionId,
|
|
125193
125367
|
projectId,
|
|
125194
|
-
error: error51
|
|
125368
|
+
error: error51
|
|
125195
125369
|
});
|
|
125196
125370
|
return baseResults;
|
|
125197
125371
|
}
|
|
@@ -125212,7 +125386,7 @@ async function applySynapseState(deps, baseResults, query, projectId, sessionId,
|
|
|
125212
125386
|
logger.warn("Synapse processing failed \u2014 using stateless search", {
|
|
125213
125387
|
sessionId,
|
|
125214
125388
|
projectId,
|
|
125215
|
-
error: error51
|
|
125389
|
+
error: error51
|
|
125216
125390
|
});
|
|
125217
125391
|
return baseResults;
|
|
125218
125392
|
}
|
|
@@ -125972,7 +126146,7 @@ class PgJobStore {
|
|
|
125972
126146
|
} catch (e) {
|
|
125973
126147
|
this.recovered = true;
|
|
125974
126148
|
logger.warn("PgJobStore markStaleRunningFailed failed (best-effort)", {
|
|
125975
|
-
error: e
|
|
126149
|
+
error: e
|
|
125976
126150
|
});
|
|
125977
126151
|
}
|
|
125978
126152
|
}
|
|
@@ -125998,7 +126172,7 @@ class PgJobStore {
|
|
|
125998
126172
|
logger.info("PgJobStore hydrated", { rows: this.mirror.size });
|
|
125999
126173
|
} catch (e) {
|
|
126000
126174
|
logger.warn("PgJobStore hydrate failed (best-effort)", {
|
|
126001
|
-
error: e
|
|
126175
|
+
error: e
|
|
126002
126176
|
});
|
|
126003
126177
|
} finally {
|
|
126004
126178
|
this.hydrating = null;
|
|
@@ -126021,7 +126195,7 @@ class PgJobStore {
|
|
|
126021
126195
|
next.catch((e) => {
|
|
126022
126196
|
logger.warn("PgJobStore.save failed (best-effort)", {
|
|
126023
126197
|
jobId: job.jobId,
|
|
126024
|
-
error: e
|
|
126198
|
+
error: e
|
|
126025
126199
|
});
|
|
126026
126200
|
});
|
|
126027
126201
|
}
|
|
@@ -126153,7 +126327,7 @@ class PgJobStore {
|
|
|
126153
126327
|
}
|
|
126154
126328
|
} catch (e) {
|
|
126155
126329
|
logger.warn("PgJobStore markStaleRunningFailed failed (best-effort)", {
|
|
126156
|
-
error: e
|
|
126330
|
+
error: e
|
|
126157
126331
|
});
|
|
126158
126332
|
}
|
|
126159
126333
|
})();
|
|
@@ -126343,7 +126517,13 @@ class IndexJobTracker {
|
|
|
126343
126517
|
const stale = hbMs != null && hbMs < cutoff || hbMs == null && startedMs != null && startedMs < cutoff;
|
|
126344
126518
|
if (!stale)
|
|
126345
126519
|
continue;
|
|
126346
|
-
logger.warn(
|
|
126520
|
+
logger.warn("indexJobTracker: reaping stale running job", {
|
|
126521
|
+
jobId: job.jobId,
|
|
126522
|
+
projectId: job.projectId,
|
|
126523
|
+
staleMs,
|
|
126524
|
+
heartbeatAt: job.heartbeatAt?.toISOString() ?? "n/a",
|
|
126525
|
+
startedAt: job.startedAt?.toISOString() ?? "n/a"
|
|
126526
|
+
});
|
|
126347
126527
|
this.jobs.set(job.jobId, job);
|
|
126348
126528
|
const reapedPrevStatus = job.status;
|
|
126349
126529
|
this.setResult(job.jobId, undefined, "heartbeat stale (possible crash/OOM)");
|
|
@@ -126368,7 +126548,7 @@ class IndexJobTracker {
|
|
|
126368
126548
|
try {
|
|
126369
126549
|
this.store?.save(job);
|
|
126370
126550
|
} catch (err) {
|
|
126371
|
-
logger.warn(
|
|
126551
|
+
logger.warn("indexJobTracker: job store write failed on setResult", { jobId, error: err });
|
|
126372
126552
|
}
|
|
126373
126553
|
if (prevStatus === "pending") {
|
|
126374
126554
|
this.publishStateChange(job, prevStatus);
|
|
@@ -126398,7 +126578,7 @@ class IndexJobTracker {
|
|
|
126398
126578
|
const survivors = remaining.slice(0, this.MAX_JOBS);
|
|
126399
126579
|
const overflow = remaining.slice(this.MAX_JOBS);
|
|
126400
126580
|
for (const job of overflow) {
|
|
126401
|
-
logger.warn(
|
|
126581
|
+
logger.warn("indexJobTracker: evicting non-terminal job to honor MAX_JOBS cap \u2014 caller may lose visibility", { jobId: job.jobId, projectId: job.projectId, status: job.status });
|
|
126402
126582
|
this.jobs.delete(job.jobId);
|
|
126403
126583
|
}
|
|
126404
126584
|
}
|
|
@@ -126552,8 +126732,9 @@ class DiscoverStage {
|
|
|
126552
126732
|
};
|
|
126553
126733
|
} catch (err) {
|
|
126554
126734
|
logger.warn("DiscoverStage: failed to stat/read file", {
|
|
126735
|
+
projectId: ctx.projectId,
|
|
126555
126736
|
relativePath,
|
|
126556
|
-
error: err
|
|
126737
|
+
error: err
|
|
126557
126738
|
});
|
|
126558
126739
|
throw new Error(`required_file_unreadable:${relativePath}:${err.message}`);
|
|
126559
126740
|
}
|
|
@@ -129078,8 +129259,9 @@ class ParseStage {
|
|
|
129078
129259
|
timestamp: Date.now()
|
|
129079
129260
|
});
|
|
129080
129261
|
logger.warn("ParseStage: failed to parse file", {
|
|
129262
|
+
projectId: ctx.projectId,
|
|
129081
129263
|
filePath: file2.relativePath,
|
|
129082
|
-
error: err
|
|
129264
|
+
error: err
|
|
129083
129265
|
});
|
|
129084
129266
|
if (err instanceof StructuralEtlParseError)
|
|
129085
129267
|
throw err;
|
|
@@ -130315,7 +130497,7 @@ class ResolveStage {
|
|
|
130315
130497
|
throw new Error("structural_repository_seed_failed", { cause: err });
|
|
130316
130498
|
logger.warn("buildSymbolIndex: repo seed failed, in-batch only", {
|
|
130317
130499
|
projectId,
|
|
130318
|
-
error: err
|
|
130500
|
+
error: err
|
|
130319
130501
|
});
|
|
130320
130502
|
}
|
|
130321
130503
|
const inBatch = new Map;
|
|
@@ -130478,7 +130660,7 @@ async function withDeadlockRetry(operation, options = {}) {
|
|
|
130478
130660
|
attempt,
|
|
130479
130661
|
maxAttempts,
|
|
130480
130662
|
delayMs,
|
|
130481
|
-
error: error51
|
|
130663
|
+
error: error51
|
|
130482
130664
|
});
|
|
130483
130665
|
await new Promise((resolve5) => setTimeout(resolve5, delayMs));
|
|
130484
130666
|
}
|
|
@@ -131608,7 +131790,7 @@ var init_pipeline = __esm(() => {
|
|
|
131608
131790
|
logger.warn("EtlPipeline: search-admission marker write failed", {
|
|
131609
131791
|
projectId,
|
|
131610
131792
|
jobId,
|
|
131611
|
-
error: markerError
|
|
131793
|
+
error: markerError
|
|
131612
131794
|
});
|
|
131613
131795
|
}
|
|
131614
131796
|
if (forceReindex) {
|
|
@@ -131620,7 +131802,7 @@ var init_pipeline = __esm(() => {
|
|
|
131620
131802
|
logger.warn("EtlPipeline: embedding fingerprint stamp failed", {
|
|
131621
131803
|
projectId,
|
|
131622
131804
|
jobId,
|
|
131623
|
-
error: stampError
|
|
131805
|
+
error: stampError
|
|
131624
131806
|
});
|
|
131625
131807
|
}
|
|
131626
131808
|
}
|
|
@@ -132979,9 +133161,9 @@ class SymbolGraphService {
|
|
|
132979
133161
|
return null;
|
|
132980
133162
|
const workspace = graphSnapshot.workspace;
|
|
132981
133163
|
const arch = await this.computeArchitectureMapSafe(graphSnapshot.architecture).catch((err) => {
|
|
132982
|
-
logger.warn("
|
|
133164
|
+
logger.warn("SymbolGraphService: getProjectMap architecture map failed, skipping", {
|
|
132983
133165
|
projectId,
|
|
132984
|
-
error: err
|
|
133166
|
+
error: err
|
|
132985
133167
|
});
|
|
132986
133168
|
return null;
|
|
132987
133169
|
});
|
|
@@ -134700,7 +134882,7 @@ class RelationExtractor {
|
|
|
134700
134882
|
} catch (error51) {
|
|
134701
134883
|
logger.warn("RelationExtractor: extraction failed", {
|
|
134702
134884
|
memoryId,
|
|
134703
|
-
error: error51
|
|
134885
|
+
error: error51
|
|
134704
134886
|
});
|
|
134705
134887
|
}
|
|
134706
134888
|
return edgesCreated;
|
|
@@ -135147,7 +135329,7 @@ class MemoryGraphService {
|
|
|
135147
135329
|
} catch (error51) {
|
|
135148
135330
|
logger.warn("Graph update failed after memory store", {
|
|
135149
135331
|
memoryId,
|
|
135150
|
-
error: error51
|
|
135332
|
+
error: error51
|
|
135151
135333
|
});
|
|
135152
135334
|
}
|
|
135153
135335
|
}
|
|
@@ -135163,7 +135345,7 @@ class MemoryGraphService {
|
|
|
135163
135345
|
} catch (error51) {
|
|
135164
135346
|
logger.warn("Graph cleanup failed after memory delete", {
|
|
135165
135347
|
memoryId,
|
|
135166
|
-
error: error51
|
|
135348
|
+
error: error51
|
|
135167
135349
|
});
|
|
135168
135350
|
}
|
|
135169
135351
|
}
|
|
@@ -135312,7 +135494,7 @@ async function consolidateWindow(candidates2, llm2, opts = {}) {
|
|
|
135312
135494
|
if (!llm2.isEnabled())
|
|
135313
135495
|
return null;
|
|
135314
135496
|
const prompt = buildPrompt2(window2);
|
|
135315
|
-
const result = await llm2.object(prompt, ConsolidatedBatchSchema);
|
|
135497
|
+
const result = await llm2.object(prompt, ConsolidatedBatchSchema, { label: "memory-consolidation" });
|
|
135316
135498
|
if (!result.ok || !result.value)
|
|
135317
135499
|
return null;
|
|
135318
135500
|
const batch = {
|
|
@@ -135413,7 +135595,7 @@ class MemoryConsolidationJob {
|
|
|
135413
135595
|
} catch (error51) {
|
|
135414
135596
|
logger.warn("Memory consolidation skipped", {
|
|
135415
135597
|
trigger,
|
|
135416
|
-
error: error51
|
|
135598
|
+
error: error51
|
|
135417
135599
|
});
|
|
135418
135600
|
} finally {
|
|
135419
135601
|
this.running = false;
|
|
@@ -135436,7 +135618,7 @@ class MemoryConsolidationJob {
|
|
|
135436
135618
|
candidates2 = await Promise.resolve(repo.listConsolidationCandidates(staleSinceMs, 500));
|
|
135437
135619
|
} catch (e) {
|
|
135438
135620
|
logger.warn("consolidation: candidate list failed (decay)", {
|
|
135439
|
-
error: e
|
|
135621
|
+
error: e
|
|
135440
135622
|
});
|
|
135441
135623
|
return 0;
|
|
135442
135624
|
}
|
|
@@ -135458,7 +135640,7 @@ class MemoryConsolidationJob {
|
|
|
135458
135640
|
} catch (e) {
|
|
135459
135641
|
logger.warn("consolidation: decay write failed", {
|
|
135460
135642
|
id: row.id,
|
|
135461
|
-
error: e
|
|
135643
|
+
error: e
|
|
135462
135644
|
});
|
|
135463
135645
|
}
|
|
135464
135646
|
}
|
|
@@ -135487,14 +135669,14 @@ class MemoryConsolidationJob {
|
|
|
135487
135669
|
} catch (e) {
|
|
135488
135670
|
logger.warn("consolidation: soft-delete failed", {
|
|
135489
135671
|
id: row.id,
|
|
135490
|
-
error: e
|
|
135672
|
+
error: e
|
|
135491
135673
|
});
|
|
135492
135674
|
}
|
|
135493
135675
|
}
|
|
135494
135676
|
}
|
|
135495
135677
|
} catch (e) {
|
|
135496
135678
|
logger.warn("consolidation: prune scan failed", {
|
|
135497
|
-
error: e
|
|
135679
|
+
error: e
|
|
135498
135680
|
});
|
|
135499
135681
|
}
|
|
135500
135682
|
return pruned;
|
|
@@ -135505,7 +135687,7 @@ class MemoryConsolidationJob {
|
|
|
135505
135687
|
candidates2 = await Promise.resolve(repo.listConsolidationCandidates(staleSinceMs, 200));
|
|
135506
135688
|
} catch (e) {
|
|
135507
135689
|
logger.warn("consolidation: candidate list failed (merge)", {
|
|
135508
|
-
error: e
|
|
135690
|
+
error: e
|
|
135509
135691
|
});
|
|
135510
135692
|
return { merged: 0, batchesCreated: 0 };
|
|
135511
135693
|
}
|
|
@@ -135531,7 +135713,7 @@ class MemoryConsolidationJob {
|
|
|
135531
135713
|
} catch (e) {
|
|
135532
135714
|
logger.warn("consolidation: merge insert failed", {
|
|
135533
135715
|
batchId: batch.id,
|
|
135534
|
-
error: e
|
|
135716
|
+
error: e
|
|
135535
135717
|
});
|
|
135536
135718
|
return { merged: 0, batchesCreated: 0 };
|
|
135537
135719
|
}
|
|
@@ -135544,7 +135726,7 @@ class MemoryConsolidationJob {
|
|
|
135544
135726
|
logger.warn("consolidation: addSupercedesEdge failed", {
|
|
135545
135727
|
newId,
|
|
135546
135728
|
sourceId,
|
|
135547
|
-
error: e
|
|
135729
|
+
error: e
|
|
135548
135730
|
});
|
|
135549
135731
|
}
|
|
135550
135732
|
}
|
|
@@ -135584,7 +135766,7 @@ class MemoryConsolidationJob {
|
|
|
135584
135766
|
return result;
|
|
135585
135767
|
} catch (e) {
|
|
135586
135768
|
logger.warn("consolidation: promote (PG) failed", {
|
|
135587
|
-
error: e
|
|
135769
|
+
error: e
|
|
135588
135770
|
});
|
|
135589
135771
|
return 0;
|
|
135590
135772
|
}
|
|
@@ -135623,19 +135805,22 @@ class SalienceJudge {
|
|
|
135623
135805
|
}
|
|
135624
135806
|
const prompt = buildPrompt3(trimmed, type);
|
|
135625
135807
|
let verdict;
|
|
135808
|
+
let verdictError;
|
|
135626
135809
|
try {
|
|
135627
|
-
const res = await this.llm.object(prompt, SalienceSchema);
|
|
135810
|
+
const res = await this.llm.object(prompt, SalienceSchema, { label: "salience-judge" });
|
|
135628
135811
|
verdict = res.ok ? res.value ?? null : null;
|
|
135812
|
+
verdictError = res.ok ? undefined : res.error;
|
|
135629
135813
|
} catch (e) {
|
|
135630
135814
|
logger.warn("SalienceJudge threw \u2014 degrading to neutral default", {
|
|
135631
135815
|
type,
|
|
135632
|
-
error: e
|
|
135816
|
+
error: e
|
|
135633
135817
|
});
|
|
135634
135818
|
return { salience: NEUTRAL_SALIENCE, source: "default" };
|
|
135635
135819
|
}
|
|
135636
135820
|
if (!verdict) {
|
|
135637
135821
|
logger.warn("SalienceJudge got {ok:false} \u2014 degrading to neutral default", {
|
|
135638
|
-
type
|
|
135822
|
+
type,
|
|
135823
|
+
error: verdictError
|
|
135639
135824
|
});
|
|
135640
135825
|
return { salience: NEUTRAL_SALIENCE, source: "default" };
|
|
135641
135826
|
}
|
|
@@ -135850,7 +136035,8 @@ class MemoryController {
|
|
|
135850
136035
|
}
|
|
135851
136036
|
} catch (err) {
|
|
135852
136037
|
logger.warn("Graph enrichment failed", {
|
|
135853
|
-
|
|
136038
|
+
projectId,
|
|
136039
|
+
error: err
|
|
135854
136040
|
});
|
|
135855
136041
|
}
|
|
135856
136042
|
}
|
|
@@ -136052,7 +136238,7 @@ class CodeCompressor {
|
|
|
136052
136238
|
}
|
|
136053
136239
|
const prompt = buildLlmCompressPrompt(content, language3, targetRatio, preservedElements);
|
|
136054
136240
|
try {
|
|
136055
|
-
const res = await this.llmCompleteFn(prompt, { timeoutMs, modelRole: "code" });
|
|
136241
|
+
const res = await this.llmCompleteFn(prompt, { label: "code-compressor", timeoutMs, modelRole: "code" });
|
|
136056
136242
|
if (res.ok && typeof res.value === "string" && res.value.trim().length > 0 && res.value.length <= content.length) {
|
|
136057
136243
|
compressed = res.value;
|
|
136058
136244
|
compressionSource = "llm";
|
|
@@ -136092,7 +136278,10 @@ class CodeCompressor {
|
|
|
136092
136278
|
});
|
|
136093
136279
|
return compressedContent;
|
|
136094
136280
|
} catch (error51) {
|
|
136095
|
-
logger.error("Code compression failed", error51
|
|
136281
|
+
logger.error("Code compression failed", error51, {
|
|
136282
|
+
strategy: useStrategy,
|
|
136283
|
+
originalLength: content.length
|
|
136284
|
+
});
|
|
136096
136285
|
return CompressedContent.identity(content);
|
|
136097
136286
|
}
|
|
136098
136287
|
}
|
|
@@ -136402,9 +136591,9 @@ class TokenMetrics {
|
|
|
136402
136591
|
}
|
|
136403
136592
|
throw new Error("Model not found in models.dev");
|
|
136404
136593
|
} catch (error51) {
|
|
136405
|
-
logger.warn("
|
|
136594
|
+
logger.warn("TokenMetrics: failed to fetch pricing from models.dev, using fallback", {
|
|
136406
136595
|
modelId,
|
|
136407
|
-
error: error51
|
|
136596
|
+
error: error51
|
|
136408
136597
|
});
|
|
136409
136598
|
const fallback = FALLBACK_PRICING2[modelId] || FALLBACK_PRICING2["gpt-4"];
|
|
136410
136599
|
this.pricingCache.set(modelId, {
|
|
@@ -136742,7 +136931,7 @@ class ContextController {
|
|
|
136742
136931
|
});
|
|
136743
136932
|
}
|
|
136744
136933
|
} catch (err) {
|
|
136745
|
-
logger.warn("
|
|
136934
|
+
logger.warn("ContextController: graph prefilter failed", { projectId, query, error: err });
|
|
136746
136935
|
}
|
|
136747
136936
|
}
|
|
136748
136937
|
const [searchResult, memories] = await Promise.all([
|
|
@@ -136896,9 +137085,11 @@ class ContextController {
|
|
|
136896
137085
|
});
|
|
136897
137086
|
return result.memories;
|
|
136898
137087
|
} catch (error51) {
|
|
136899
|
-
logger.warn("
|
|
136900
|
-
|
|
136901
|
-
|
|
137088
|
+
logger.warn("ContextController: memory search failed, continuing without memories", {
|
|
137089
|
+
projectId: opts.projectId,
|
|
137090
|
+
sessionId: opts.sessionId,
|
|
137091
|
+
query: query.slice(0, 30),
|
|
137092
|
+
error: error51
|
|
136902
137093
|
});
|
|
136903
137094
|
return [];
|
|
136904
137095
|
}
|
|
@@ -137574,7 +137765,7 @@ class PgCheckpointStore {
|
|
|
137574
137765
|
} catch (e) {
|
|
137575
137766
|
this.hydrateFailedAt = Date.now();
|
|
137576
137767
|
logger.warn("PgCheckpointStore hydrate failed (best-effort)", {
|
|
137577
|
-
error: e
|
|
137768
|
+
error: e
|
|
137578
137769
|
});
|
|
137579
137770
|
} finally {
|
|
137580
137771
|
this.hydrating = null;
|
|
@@ -137768,8 +137959,9 @@ class PgCheckpointStore {
|
|
|
137768
137959
|
}
|
|
137769
137960
|
return existing;
|
|
137770
137961
|
} catch (e) {
|
|
137771
|
-
logger.warn("countExistingMemoryIds failed (best-effort
|
|
137772
|
-
|
|
137962
|
+
logger.warn("PgCheckpointStore: countExistingMemoryIds failed (best-effort, assuming all exist)", {
|
|
137963
|
+
memoryIdCount: memoryIds.length,
|
|
137964
|
+
error: e
|
|
137773
137965
|
});
|
|
137774
137966
|
return memoryIds;
|
|
137775
137967
|
}
|
|
@@ -137836,7 +138028,7 @@ class PgCheckpointStore {
|
|
|
137836
138028
|
const next = prev.then(fn).catch((e) => {
|
|
137837
138029
|
logger.warn("PgCheckpointStore write failed (best-effort)", {
|
|
137838
138030
|
key,
|
|
137839
|
-
error: e
|
|
138031
|
+
error: e
|
|
137840
138032
|
});
|
|
137841
138033
|
});
|
|
137842
138034
|
this.inflight.set(key, next);
|
|
@@ -138262,7 +138454,7 @@ class ListCheckpointsTool {
|
|
|
138262
138454
|
};
|
|
138263
138455
|
return serializeToolResponse(responseData, { format, fields });
|
|
138264
138456
|
} catch (error51) {
|
|
138265
|
-
logger.error("Failed to list checkpoints", error51);
|
|
138457
|
+
logger.error("Failed to list checkpoints", error51, { taskId, projectId });
|
|
138266
138458
|
return {
|
|
138267
138459
|
success: false,
|
|
138268
138460
|
error: `Failed to list checkpoints: ${error51.message}`
|
|
@@ -138354,7 +138546,7 @@ class PgObservationStore {
|
|
|
138354
138546
|
} catch (e) {
|
|
138355
138547
|
this.hydrateFailedAt = Date.now();
|
|
138356
138548
|
logger.warn("PgObservationStore hydrate failed (best-effort)", {
|
|
138357
|
-
error: e
|
|
138549
|
+
error: e
|
|
138358
138550
|
});
|
|
138359
138551
|
} finally {
|
|
138360
138552
|
this.hydrating = null;
|
|
@@ -138405,7 +138597,7 @@ class PgObservationStore {
|
|
|
138405
138597
|
const next = prev.then(fn).catch((e) => {
|
|
138406
138598
|
logger.warn("PgObservationStore.insert failed (best-effort)", {
|
|
138407
138599
|
id: key,
|
|
138408
|
-
error: e
|
|
138600
|
+
error: e
|
|
138409
138601
|
});
|
|
138410
138602
|
});
|
|
138411
138603
|
this.inflight.set(key, next);
|
|
@@ -139248,7 +139440,8 @@ class CompactSnapshotTool {
|
|
|
139248
139440
|
});
|
|
139249
139441
|
} catch (e) {
|
|
139250
139442
|
logger.warn("compact_snapshot: persist failed (non-fatal)", {
|
|
139251
|
-
|
|
139443
|
+
sessionId,
|
|
139444
|
+
error: e
|
|
139252
139445
|
});
|
|
139253
139446
|
persistedId = undefined;
|
|
139254
139447
|
}
|
|
@@ -141042,7 +141235,7 @@ class ProjectRootCache {
|
|
|
141042
141235
|
return workspace.project_path;
|
|
141043
141236
|
}
|
|
141044
141237
|
} catch (error51) {
|
|
141045
|
-
logger.warn("
|
|
141238
|
+
logger.warn("ProjectRootCache: failed to look up project root", { projectId, error: error51 });
|
|
141046
141239
|
}
|
|
141047
141240
|
return null;
|
|
141048
141241
|
}
|
|
@@ -141710,7 +141903,7 @@ function warnSandboxUnavailable() {
|
|
|
141710
141903
|
return;
|
|
141711
141904
|
_warnedAboutNoSandbox = true;
|
|
141712
141905
|
const missingTool = process.platform === "darwin" ? "sandbox-exec" : "docker";
|
|
141713
|
-
logger.warn(
|
|
141906
|
+
logger.warn("Sandbox: no sandbox tool found for auto mode, falling back to best-effort containment", { missingTool, platform: process.platform, effectiveMode: "none" });
|
|
141714
141907
|
}
|
|
141715
141908
|
function getSandboxMode() {
|
|
141716
141909
|
const env4 = process.env.MASSA_AI_EXECUTOR_SANDBOX ?? "auto";
|
|
@@ -142625,7 +142818,10 @@ class ExecutorController {
|
|
|
142625
142818
|
}
|
|
142626
142819
|
};
|
|
142627
142820
|
} catch (error51) {
|
|
142628
|
-
logger.error("batch_execute failed", error51
|
|
142821
|
+
logger.error("batch_execute failed", error51, {
|
|
142822
|
+
commandCount: commands.length,
|
|
142823
|
+
concurrency: effectiveConcurrency
|
|
142824
|
+
});
|
|
142629
142825
|
return {
|
|
142630
142826
|
success: false,
|
|
142631
142827
|
error: `batch_execute failed: ${error51.message}`
|
|
@@ -144567,7 +144763,7 @@ class PgScheduledJobStore {
|
|
|
144567
144763
|
logger.info("PgScheduledJobStore hydrated", { rows: this.mirror.size });
|
|
144568
144764
|
} catch (e) {
|
|
144569
144765
|
logger.warn("PgScheduledJobStore hydrate failed (best-effort)", {
|
|
144570
|
-
error: e
|
|
144766
|
+
error: e
|
|
144571
144767
|
});
|
|
144572
144768
|
} finally {
|
|
144573
144769
|
this.hydrating = null;
|
|
@@ -144581,9 +144777,10 @@ class PgScheduledJobStore {
|
|
|
144581
144777
|
try {
|
|
144582
144778
|
await action();
|
|
144583
144779
|
} catch (e) {
|
|
144584
|
-
logger.warn(
|
|
144780
|
+
logger.warn("PgScheduledJobStore mutation failed (best-effort)", {
|
|
144585
144781
|
id,
|
|
144586
|
-
|
|
144782
|
+
operation,
|
|
144783
|
+
error: e
|
|
144587
144784
|
});
|
|
144588
144785
|
}
|
|
144589
144786
|
};
|
|
@@ -144836,7 +145033,7 @@ class Scheduler {
|
|
|
144836
145033
|
this.timer = setInterval(() => {
|
|
144837
145034
|
this.tick().catch((e) => {
|
|
144838
145035
|
logger.warn("Scheduler tick failed (swallowed)", {
|
|
144839
|
-
error: e
|
|
145036
|
+
error: e
|
|
144840
145037
|
});
|
|
144841
145038
|
});
|
|
144842
145039
|
}, this.tickIntervalMs);
|
|
@@ -144951,7 +145148,7 @@ class Scheduler {
|
|
|
144951
145148
|
logger.warn("Scheduler: job handler threw (caught)", {
|
|
144952
145149
|
id: job.id,
|
|
144953
145150
|
jobKind: job.jobKind,
|
|
144954
|
-
error:
|
|
145151
|
+
error: e
|
|
144955
145152
|
});
|
|
144956
145153
|
} finally {
|
|
144957
145154
|
if (succeeded) {
|
|
@@ -144970,7 +145167,7 @@ class Scheduler {
|
|
|
144970
145167
|
} catch (e) {
|
|
144971
145168
|
logger.warn("Scheduler: persist after fire failed", {
|
|
144972
145169
|
id: job.id,
|
|
144973
|
-
error: e
|
|
145170
|
+
error: e
|
|
144974
145171
|
});
|
|
144975
145172
|
}
|
|
144976
145173
|
this.running.delete(job.jobKind);
|
|
@@ -144990,6 +145187,8 @@ class Scheduler {
|
|
|
144990
145187
|
enabled: j.enabled,
|
|
144991
145188
|
nextRunAt: j.nextRunAt,
|
|
144992
145189
|
lastRunAt: j.lastRunAt,
|
|
145190
|
+
lastSuccessAt: j.lastSuccessAt ?? null,
|
|
145191
|
+
consecutiveFailures: j.consecutiveFailures ?? 0,
|
|
144993
145192
|
due: j.enabled && j.nextRunAt <= now2,
|
|
144994
145193
|
currentlyRunning: this.running.has(j.jobKind)
|
|
144995
145194
|
}))
|
|
@@ -145636,7 +145835,7 @@ async function enrichWithLlm(candidates2, observations, surface) {
|
|
|
145636
145835
|
const prompt = buildEnrichmentPrompt(candidates2, observations);
|
|
145637
145836
|
let enrichment = null;
|
|
145638
145837
|
try {
|
|
145639
|
-
const res = await surface.object(prompt, ProposalEnrichmentSchema);
|
|
145838
|
+
const res = await surface.object(prompt, ProposalEnrichmentSchema, { label: "auto-improve" });
|
|
145640
145839
|
if (!res.ok || !res.value || !Array.isArray(res.value.items)) {
|
|
145641
145840
|
return { candidates: candidates2, used: false };
|
|
145642
145841
|
}
|
|
@@ -145832,7 +146031,7 @@ async function runOnce(job, projectId) {
|
|
|
145832
146031
|
try {
|
|
145833
146032
|
observations = job.observationStore.listRecent(projectId, job.maxWindow);
|
|
145834
146033
|
} catch (e) {
|
|
145835
|
-
logger.warn("auto-improve: listRecent failed", { projectId, error: e
|
|
146034
|
+
logger.warn("auto-improve: listRecent failed", { projectId, error: e });
|
|
145836
146035
|
return noop2;
|
|
145837
146036
|
}
|
|
145838
146037
|
if (observations.length < 2)
|
|
@@ -145847,7 +146046,7 @@ async function runOnce(job, projectId) {
|
|
|
145847
146046
|
if (res.used)
|
|
145848
146047
|
source = "llm";
|
|
145849
146048
|
} catch (e) {
|
|
145850
|
-
logger.warn("auto-improve: enrichWithLlm threw (silent)", { projectId, error: e
|
|
146049
|
+
logger.warn("auto-improve: enrichWithLlm threw (silent)", { projectId, error: e });
|
|
145851
146050
|
}
|
|
145852
146051
|
const seen = new Set;
|
|
145853
146052
|
const unique = candidates2.filter((c) => {
|
|
@@ -145895,7 +146094,7 @@ async function runOnce(job, projectId) {
|
|
|
145895
146094
|
} catch (e) {
|
|
145896
146095
|
if (e instanceof SearchServiceError)
|
|
145897
146096
|
throw e;
|
|
145898
|
-
logger.warn("proposal:auto-approved:threw", { id: r.id, projectId, error: e
|
|
146097
|
+
logger.warn("proposal:auto-approved:threw", { id: r.id, projectId, error: e });
|
|
145899
146098
|
}
|
|
145900
146099
|
}
|
|
145901
146100
|
result.proposalsApplied = applied;
|
|
@@ -145924,7 +146123,7 @@ async function approve(job, id, projectId, source = "rule-based") {
|
|
|
145924
146123
|
appliedMemoryId = await applyProposal(job, row);
|
|
145925
146124
|
} catch (e) {
|
|
145926
146125
|
const reason = e instanceof ApplyRejection ? e.reason : "apply-failed";
|
|
145927
|
-
logger.warn("proposal:apply-failed", { id, projectId: row.projectId, reason, error: e
|
|
146126
|
+
logger.warn("proposal:apply-failed", { id, projectId: row.projectId, reason, error: e });
|
|
145928
146127
|
return { ok: false, reason };
|
|
145929
146128
|
}
|
|
145930
146129
|
let updated;
|
|
@@ -146059,9 +146258,9 @@ class AutoImproveJob {
|
|
|
146059
146258
|
return;
|
|
146060
146259
|
this.newSinceRun = 0;
|
|
146061
146260
|
this.lastRunAt = now2;
|
|
146062
|
-
this.runOnce(projectId).catch((e) => logger.warn("auto-improve: runOnce failed (silent)", { projectId, error: e
|
|
146261
|
+
this.runOnce(projectId).catch((e) => logger.warn("auto-improve: runOnce failed (silent)", { projectId, error: e }));
|
|
146063
146262
|
} catch (e) {
|
|
146064
|
-
logger.warn("auto-improve: maybeRun swallowed", { projectId, error: e
|
|
146263
|
+
logger.warn("auto-improve: maybeRun swallowed", { projectId, error: e });
|
|
146065
146264
|
}
|
|
146066
146265
|
}
|
|
146067
146266
|
async runOnce(projectId) {
|
|
@@ -146161,13 +146360,13 @@ class ObservationConsolidationJob {
|
|
|
146161
146360
|
this.runOnce(projectId).catch((e) => {
|
|
146162
146361
|
logger.warn("observation consolidation: runOnce failed (silent)", {
|
|
146163
146362
|
projectId,
|
|
146164
|
-
error: e
|
|
146363
|
+
error: e
|
|
146165
146364
|
});
|
|
146166
146365
|
});
|
|
146167
146366
|
} catch (e) {
|
|
146168
146367
|
logger.warn("observation consolidation: maybeRun swallowed", {
|
|
146169
146368
|
projectId,
|
|
146170
|
-
error: e
|
|
146369
|
+
error: e
|
|
146171
146370
|
});
|
|
146172
146371
|
}
|
|
146173
146372
|
}
|
|
@@ -146191,7 +146390,7 @@ class ObservationConsolidationJob {
|
|
|
146191
146390
|
} catch (e) {
|
|
146192
146391
|
logger.warn("observation consolidation: listRecent failed", {
|
|
146193
146392
|
projectId,
|
|
146194
|
-
error: e
|
|
146393
|
+
error: e
|
|
146195
146394
|
});
|
|
146196
146395
|
return noop2;
|
|
146197
146396
|
}
|
|
@@ -146202,7 +146401,7 @@ class ObservationConsolidationJob {
|
|
|
146202
146401
|
const prompt = buildObservationPrompt(window2);
|
|
146203
146402
|
let batch;
|
|
146204
146403
|
try {
|
|
146205
|
-
const res = await this.llm.object(prompt, ConsolidatedBatchSchema);
|
|
146404
|
+
const res = await this.llm.object(prompt, ConsolidatedBatchSchema, { label: "observation-consolidation" });
|
|
146206
146405
|
if (!res.ok || !res.value) {
|
|
146207
146406
|
return noop2;
|
|
146208
146407
|
}
|
|
@@ -146218,7 +146417,7 @@ class ObservationConsolidationJob {
|
|
|
146218
146417
|
} catch (e) {
|
|
146219
146418
|
logger.warn("observation consolidation: llm.object threw (silent)", {
|
|
146220
146419
|
projectId,
|
|
146221
|
-
error: e
|
|
146420
|
+
error: e
|
|
146222
146421
|
});
|
|
146223
146422
|
return noop2;
|
|
146224
146423
|
}
|
|
@@ -146247,7 +146446,7 @@ class ObservationConsolidationJob {
|
|
|
146247
146446
|
} catch (e) {
|
|
146248
146447
|
logger.warn("observation consolidation: summary insert failed", {
|
|
146249
146448
|
batchId: batch.id,
|
|
146250
|
-
error: e
|
|
146449
|
+
error: e
|
|
146251
146450
|
});
|
|
146252
146451
|
return noop2;
|
|
146253
146452
|
}
|
|
@@ -146524,8 +146723,9 @@ var init_models_dev_client = __esm(() => {
|
|
|
146524
146723
|
path: cachePath
|
|
146525
146724
|
});
|
|
146526
146725
|
} catch (error51) {
|
|
146527
|
-
logger.warn("
|
|
146528
|
-
|
|
146726
|
+
logger.warn("ModelsDevClient: failed to save local pricing cache", {
|
|
146727
|
+
path: cachePath,
|
|
146728
|
+
error: error51
|
|
146529
146729
|
});
|
|
146530
146730
|
}
|
|
146531
146731
|
}
|
|
@@ -146747,7 +146947,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
146747
146947
|
return value;
|
|
146748
146948
|
}
|
|
146749
146949
|
}
|
|
146750
|
-
logger.warn(
|
|
146950
|
+
logger.warn("ModelsDevClient: model pricing not found", { modelId });
|
|
146751
146951
|
return null;
|
|
146752
146952
|
}
|
|
146753
146953
|
async searchModels(query) {
|
|
@@ -146851,8 +147051,9 @@ var init_models_dev_client = __esm(() => {
|
|
|
146851
147051
|
logger.debug("Local pricing cache file deleted");
|
|
146852
147052
|
}
|
|
146853
147053
|
} catch (error51) {
|
|
146854
|
-
logger.warn("
|
|
146855
|
-
|
|
147054
|
+
logger.warn("ModelsDevClient: failed to delete local pricing cache", {
|
|
147055
|
+
path: cachePath,
|
|
147056
|
+
error: error51
|
|
146856
147057
|
});
|
|
146857
147058
|
}
|
|
146858
147059
|
}
|
|
@@ -147508,9 +147709,10 @@ class SearchSessionHook {
|
|
|
147508
147709
|
});
|
|
147509
147710
|
} catch (err) {
|
|
147510
147711
|
logger.warn("SearchSessionHook: store failed (best-effort)", {
|
|
147511
|
-
error: err.message,
|
|
147512
147712
|
projectId,
|
|
147513
|
-
|
|
147713
|
+
sessionId,
|
|
147714
|
+
query: query.slice(0, 60),
|
|
147715
|
+
error: err
|
|
147514
147716
|
});
|
|
147515
147717
|
}
|
|
147516
147718
|
}
|
|
@@ -147586,8 +147788,10 @@ class CoRetrievalHook {
|
|
|
147586
147788
|
peers = await this.findPeers(memoryId, projectId, sessionId);
|
|
147587
147789
|
} catch (err) {
|
|
147588
147790
|
logger.warn("CoRetrievalHook: peer lookup failed", {
|
|
147589
|
-
|
|
147590
|
-
|
|
147791
|
+
projectId,
|
|
147792
|
+
sessionId,
|
|
147793
|
+
memoryId,
|
|
147794
|
+
error: err
|
|
147591
147795
|
});
|
|
147592
147796
|
return;
|
|
147593
147797
|
}
|
|
@@ -164633,6 +164837,7 @@ async function fetchAndConvertOne(url2, deps, opts = {}) {
|
|
|
164633
164837
|
} catch (err) {
|
|
164634
164838
|
const msg = err instanceof Error ? err.message : String(err);
|
|
164635
164839
|
logger.error("fetch_and_index indexChunk failed", err, {
|
|
164840
|
+
projectId,
|
|
164636
164841
|
url: url2,
|
|
164637
164842
|
chunkId: chunk.id
|
|
164638
164843
|
});
|
|
@@ -164823,6 +165028,7 @@ class WebController {
|
|
|
164823
165028
|
return s.value;
|
|
164824
165029
|
const msg = s.reason instanceof Error ? s.reason.message : String(s.reason);
|
|
164825
165030
|
logger.error("fetch_and_index job rejected", s.reason, {
|
|
165031
|
+
projectId,
|
|
164826
165032
|
url: batch[i].url
|
|
164827
165033
|
});
|
|
164828
165034
|
return { kind: "error", url: batch[i].url, error: msg };
|
|
@@ -165011,7 +165217,7 @@ class OperationLogRepositoryPg {
|
|
|
165011
165217
|
op: input.op,
|
|
165012
165218
|
projectId,
|
|
165013
165219
|
result: input.result,
|
|
165014
|
-
error: err
|
|
165220
|
+
error: err
|
|
165015
165221
|
});
|
|
165016
165222
|
}
|
|
165017
165223
|
}
|
|
@@ -165224,9 +165430,11 @@ class HookService {
|
|
|
165224
165430
|
});
|
|
165225
165431
|
this.bridge.maybeRun(obs.projectId);
|
|
165226
165432
|
} catch (e) {
|
|
165227
|
-
logger.warn("observation persist failed", {
|
|
165433
|
+
logger.warn("HookService: observation persist failed", {
|
|
165228
165434
|
id: obs.id,
|
|
165229
|
-
|
|
165435
|
+
projectId: obs.projectId,
|
|
165436
|
+
sessionId: obs.sessionId,
|
|
165437
|
+
error: e
|
|
165230
165438
|
});
|
|
165231
165439
|
}
|
|
165232
165440
|
});
|
|
@@ -165352,7 +165560,7 @@ class BootstrapService {
|
|
|
165352
165560
|
} catch (e) {
|
|
165353
165561
|
logger.warn("bootstrap: marker check threw (continuing)", {
|
|
165354
165562
|
projectId,
|
|
165355
|
-
error: e
|
|
165563
|
+
error: e
|
|
165356
165564
|
});
|
|
165357
165565
|
}
|
|
165358
165566
|
} else if (!cfg.refreshEnabled) {
|
|
@@ -165400,7 +165608,7 @@ class BootstrapService {
|
|
|
165400
165608
|
} catch (e) {
|
|
165401
165609
|
logger.warn("bootstrap: storeSeeds failed (silent)", {
|
|
165402
165610
|
projectId,
|
|
165403
|
-
error: e
|
|
165611
|
+
error: e
|
|
165404
165612
|
});
|
|
165405
165613
|
return { ...noopResult("insert-failed"), signalCount, source };
|
|
165406
165614
|
}
|
|
@@ -165553,7 +165761,7 @@ async function summarizeWithLlm(signals, surface, maxSeedMemories) {
|
|
|
165553
165761
|
return { ok: false, reason: "llm disabled" };
|
|
165554
165762
|
const prompt = buildSummarizePrompt(signals, maxSeedMemories);
|
|
165555
165763
|
try {
|
|
165556
|
-
const res = await surface.object(prompt, SeedMemoriesSchema, { modelRole: "code" });
|
|
165764
|
+
const res = await surface.object(prompt, SeedMemoriesSchema, { label: "bootstrap-seed", modelRole: "code" });
|
|
165557
165765
|
if (!res.ok || !res.value) {
|
|
165558
165766
|
return { ok: false, reason: res.error || "llm returned no value" };
|
|
165559
165767
|
}
|
|
@@ -166236,7 +166444,7 @@ function formatMemoryContent(record3) {
|
|
|
166236
166444
|
}
|
|
166237
166445
|
async function polishSummary(surface, input) {
|
|
166238
166446
|
const prompt = buildPolishPrompt(input);
|
|
166239
|
-
const res = await surface.object(prompt, HandoffSummarySchema);
|
|
166447
|
+
const res = await surface.object(prompt, HandoffSummarySchema, { label: "handoff-summary" });
|
|
166240
166448
|
if (!res.ok || !res.value || !res.value.summary)
|
|
166241
166449
|
return null;
|
|
166242
166450
|
return res.value.summary;
|
|
@@ -169791,7 +169999,10 @@ class EmbeddedApiClient {
|
|
|
169791
169999
|
const rows = filtered.slice(offset, offset + limit);
|
|
169792
170000
|
return { success: true, data: { memories: rows, total, limit, offset } };
|
|
169793
170001
|
} catch (error51) {
|
|
169794
|
-
logger.error("Failed to list memories (embedded)", error51
|
|
170002
|
+
logger.error("Failed to list memories (embedded)", error51, {
|
|
170003
|
+
projectId: body.projectId,
|
|
170004
|
+
sessionId: body.sessionId
|
|
170005
|
+
});
|
|
169795
170006
|
return { success: false, error: `Failed to list memories: ${error51.message}` };
|
|
169796
170007
|
}
|
|
169797
170008
|
}
|