chore: 移除 Recall Card 排查用的 ST-BME:DIAG 临时日志

Made-with: Cursor
This commit is contained in:
Youzini-afk
2026-04-06 20:28:35 +08:00
parent d39e81cde5
commit 36e2a2c451
2 changed files with 1 additions and 33 deletions

View File

@@ -1,5 +1,3 @@
import { debugWarn } from "./debug-logging.js";
function getTimerApi(runtime) {
const rawSetTimeout =
typeof runtime?.setTimeout === "function"
@@ -40,14 +38,8 @@ export function registerBeforeCombinePromptsController(runtime, listener) {
export function registerGenerationAfterCommandsController(runtime, listener) {
const makeFirst = runtime.getEventMakeFirst();
const eventName = runtime.eventTypes.GENERATION_AFTER_COMMANDS;
debugWarn("[ST-BME:DIAG] Registering GENERATION_AFTER_COMMANDS:", {
eventName,
hasMakeFirst: typeof makeFirst === "function",
hasListener: typeof listener === "function",
});
if (typeof makeFirst === "function") {
const cleanup = makeFirst(eventName, listener);
debugWarn("[ST-BME:DIAG] Registered via makeFirst, cleanup:", typeof cleanup);
return cleanup;
}
@@ -412,9 +404,7 @@ export async function onGenerationAfterCommandsController(
params = {},
dryRun = false,
) {
debugWarn("[ST-BME:DIAG] GENERATION_AFTER_COMMANDS fired", { type, dryRun, paramsKeys: Object.keys(params || {}) });
if (dryRun) {
debugWarn("[ST-BME:DIAG] EXIT: dryRun=true");
return;
}
@@ -424,11 +414,9 @@ export async function onGenerationAfterCommandsController(
? runtime.consumeHostGenerationInputSnapshot?.({ preserve: true }) ||
runtime.consumeHostGenerationInputSnapshot?.()
: null;
debugWarn("[ST-BME:DIAG] frozenInputSnapshot:", frozenInputSnapshot?.text ? `"${frozenInputSnapshot.text.slice(0,50)}"` : "(empty)", "fresh:", !!frozenInputSnapshot?.at);
const context = runtime.getContext();
const chat = context?.chat;
debugWarn("[ST-BME:DIAG] chat length:", chat?.length, "last msg:", chat?.length ? { is_user: chat[chat.length-1]?.is_user, mes: (chat[chat.length-1]?.mes||"").slice(0,50) } : "(no chat)");
const recallOptions = runtime.buildGenerationAfterCommandsRecallInput(
type,
@@ -439,14 +427,11 @@ export async function onGenerationAfterCommandsController(
chat,
);
if (!recallOptions) {
debugWarn("[ST-BME:DIAG] EXIT: buildGenerationAfterCommandsRecallInput returned null");
return;
}
if (recallOptions?.__trivialSkip) {
debugWarn("[ST-BME:DIAG] EXIT: trivial-input-skip");
return;
}
debugWarn("[ST-BME:DIAG] recallOptions:", { generationType: recallOptions.generationType, overrideUserMessage: recallOptions.overrideUserMessage?.slice(0,50), overrideSource: recallOptions.overrideSource, targetIdx: recallOptions.targetUserMessageIndex });
const recallContext = runtime.createGenerationRecallContext({
hookName: "GENERATION_AFTER_COMMANDS",
@@ -454,10 +439,8 @@ export async function onGenerationAfterCommandsController(
recallOptions,
});
if (!recallContext.shouldRun && !recallContext.transaction) {
debugWarn("[ST-BME:DIAG] EXIT: shouldRun=false, no transaction. guardReason:", recallContext.guardReason);
return;
}
debugWarn("[ST-BME:DIAG] recallContext:", { shouldRun: recallContext.shouldRun, guardReason: recallContext.guardReason, transactionId: recallContext.transaction?.id });
const runtimeRecallOptions =
recallContext.recallOptions || recallOptions || {};
@@ -470,7 +453,6 @@ export async function onGenerationAfterCommandsController(
let recallResult = runtime.getGenerationRecallTransactionResult?.(
recallContext.transaction,
);
debugWarn("[ST-BME:DIAG] deliveryMode:", deliveryMode, "shouldRun:", recallContext.shouldRun);
if (recallContext.shouldRun) {
runtime.markGenerationRecallTransactionHookState(
@@ -481,7 +463,6 @@ export async function onGenerationAfterCommandsController(
if (deliveryMode === "deferred") {
runtime.clearLiveRecallInjectionPromptForRewrite?.();
}
debugWarn("[ST-BME:DIAG] >>> Starting runRecall...");
recallResult = await runtime.runRecall({
...runtimeRecallOptions,
deliveryMode,
@@ -489,7 +470,6 @@ export async function onGenerationAfterCommandsController(
hookName: recallContext.hookName,
signal: params?.signal,
});
debugWarn("[ST-BME:DIAG] <<< runRecall finished:", { status: recallResult?.status, ok: recallResult?.ok, reason: recallResult?.reason, injectionText: recallResult?.injectionText?.slice(0,80) });
runtime.storeGenerationRecallTransactionResult?.(
recallContext.transaction,
recallResult,
@@ -522,7 +502,6 @@ export async function onGenerationAfterCommandsController(
// 上面的兜底补写会把 fresh recall 绑定回最终 user 楼层。
// 这里再补一次 UI 刷新,避免需要等到消息编辑/历史恢复后才看到 Recall Card。
runtime.refreshPersistedRecallMessageUi?.();
debugWarn("[ST-BME:DIAG] DONE: immediate mode, injection via setExtensionPrompt in runRecall");
return recallResult;
}
@@ -556,7 +535,6 @@ export async function onBeforeCombinePromptsController(
frozenInputSnapshot,
});
if (normalInput?.__trivialSkip) {
debugWarn("[ST-BME:DIAG] EXIT: trivial-input-skip");
return {
skipped: true,
reason: `trivial:${normalInput.trivialReason || ""}`,

View File

@@ -1,6 +1,6 @@
// ST-BME: 召回输入解析与注入控制器(纯函数)
import { debugLog, debugWarn } from "./debug-logging.js";
import { debugLog } from "./debug-logging.js";
export function buildRecallRecentMessagesController(
chat,
@@ -289,12 +289,10 @@ export function applyRecallInjectionController(
}
export async function runRecallController(runtime, options = {}) {
debugWarn("[ST-BME:DIAG:RECALL] runRecallController entered");
if (runtime.getIsRecalling()) {
runtime.abortRecallStageWithReason("旧召回已取消,正在启动新的召回");
const settle = await runtime.waitForActiveRecallToSettle();
if (!settle.settled && runtime.getIsRecalling()) {
debugWarn("[ST-BME:DIAG:RECALL] EXIT: 上一轮召回仍在清理");
runtime.setLastRecallStatus(
"召回忙",
"上一轮召回仍在清理,请稍后重试",
@@ -310,18 +308,14 @@ export async function runRecallController(runtime, options = {}) {
}
const hasGraph = !!runtime.getCurrentGraph();
debugWarn("[ST-BME:DIAG:RECALL] hasGraph:", hasGraph);
if (!hasGraph) {
debugWarn("[ST-BME:DIAG:RECALL] EXIT: 当前无图谱");
return runtime.createRecallRunResult("skipped", {
reason: "当前无图谱",
});
}
const settings = runtime.getSettings();
debugWarn("[ST-BME:DIAG:RECALL] settings.enabled:", settings.enabled, "recallEnabled:", settings.recallEnabled);
if (!settings.enabled || !settings.recallEnabled) {
debugWarn("[ST-BME:DIAG:RECALL] EXIT: 召回功能未启用");
return runtime.createRecallRunResult("skipped", {
reason: "召回功能未启用",
});
@@ -330,12 +324,8 @@ export async function runRecallController(runtime, options = {}) {
typeof runtime.isGraphReadableForRecall === "function"
? runtime.isGraphReadableForRecall()
: runtime.isGraphReadable();
const chatId = typeof runtime.getCurrentChatId === "function" ? runtime.getCurrentChatId() : "(no fn)";
const loadState = runtime.getGraphPersistenceLoadState?.() || "(no fn)";
debugWarn("[ST-BME:DIAG:RECALL] isReadableForRecall:", isReadableForRecall, "chatId:", chatId, "loadState:", loadState);
if (!isReadableForRecall) {
const reason = runtime.getGraphMutationBlockReason("召回");
debugWarn("[ST-BME:DIAG:RECALL] EXIT: 图谱不可读 -", reason);
runtime.setLastRecallStatus("等待图谱加载", reason, "warning", {
syncRuntime: true,
});