mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
@@ -358,6 +358,11 @@ export function onMessageDeletedController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function onMessageEditedController(runtime, messageId, meta = null) {
|
export function onMessageEditedController(runtime, messageId, meta = null) {
|
||||||
|
if (runtime.isMvuExtraAnalysisGuardActive?.()) {
|
||||||
|
console.debug?.("[ST-BME] skip: mvu-extra-analysis hook=MESSAGE_EDITED");
|
||||||
|
runtime.refreshPersistedRecallMessageUi?.();
|
||||||
|
return;
|
||||||
|
}
|
||||||
runtime.invalidateRecallAfterHistoryMutation("消息已编辑");
|
runtime.invalidateRecallAfterHistoryMutation("消息已编辑");
|
||||||
runtime.scheduleHistoryMutationRecheck("message-edited", messageId, meta);
|
runtime.scheduleHistoryMutationRecheck("message-edited", messageId, meta);
|
||||||
runtime.refreshPersistedRecallMessageUi?.();
|
runtime.refreshPersistedRecallMessageUi?.();
|
||||||
@@ -414,6 +419,13 @@ export async function onGenerationAfterCommandsController(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (runtime.isMvuExtraAnalysisGuardActive?.()) {
|
||||||
|
console.debug?.(
|
||||||
|
"[ST-BME] skip: mvu-extra-analysis hook=GENERATION_AFTER_COMMANDS",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const generationType = String(type || "normal").trim() || "normal";
|
const generationType = String(type || "normal").trim() || "normal";
|
||||||
const frozenInputSnapshot =
|
const frozenInputSnapshot =
|
||||||
generationType === "normal"
|
generationType === "normal"
|
||||||
@@ -547,6 +559,16 @@ export async function onBeforeCombinePromptsController(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (runtime.isMvuExtraAnalysisGuardActive?.()) {
|
||||||
|
console.debug?.(
|
||||||
|
"[ST-BME] skip: mvu-extra-analysis hook=GENERATE_BEFORE_COMBINE_PROMPTS",
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
skipped: true,
|
||||||
|
reason: "mvu-extra-analysis",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const frozenInputSnapshot =
|
const frozenInputSnapshot =
|
||||||
runtime.consumeHostGenerationInputSnapshot?.() ||
|
runtime.consumeHostGenerationInputSnapshot?.() ||
|
||||||
runtime.getPendingHostGenerationInputSnapshot?.() ||
|
runtime.getPendingHostGenerationInputSnapshot?.() ||
|
||||||
|
|||||||
53
index.js
53
index.js
@@ -764,6 +764,7 @@ let pendingAutoExtraction = {
|
|||||||
let isHostGenerationRunning = false;
|
let isHostGenerationRunning = false;
|
||||||
let lastHostGenerationEndedAt = 0;
|
let lastHostGenerationEndedAt = 0;
|
||||||
let skipBeforeCombineRecallUntil = 0;
|
let skipBeforeCombineRecallUntil = 0;
|
||||||
|
let mvuExtraAnalysisGuardUntil = 0;
|
||||||
let lastPreGenerationRecallKey = "";
|
let lastPreGenerationRecallKey = "";
|
||||||
let lastPreGenerationRecallAt = 0;
|
let lastPreGenerationRecallAt = 0;
|
||||||
const generationRecallTransactions = new Map();
|
const generationRecallTransactions = new Map();
|
||||||
@@ -789,6 +790,7 @@ const persistedRecallPersistDiagnosticTimestamps = new Map();
|
|||||||
const GENERATION_RECALL_TRANSACTION_TTL_MS = 15000;
|
const GENERATION_RECALL_TRANSACTION_TTL_MS = 15000;
|
||||||
const PLANNER_RECALL_HANDOFF_TTL_MS = GENERATION_RECALL_TRANSACTION_TTL_MS;
|
const PLANNER_RECALL_HANDOFF_TTL_MS = GENERATION_RECALL_TRANSACTION_TTL_MS;
|
||||||
const GENERATION_RECALL_HOOK_BRIDGE_MS = 1200;
|
const GENERATION_RECALL_HOOK_BRIDGE_MS = 1200;
|
||||||
|
const MVU_EXTRA_ANALYSIS_GUARD_TTL_MS = 2500;
|
||||||
const stageNoticeHandles = {
|
const stageNoticeHandles = {
|
||||||
extraction: null,
|
extraction: null,
|
||||||
vector: null,
|
vector: null,
|
||||||
@@ -6688,6 +6690,54 @@ function consumeDryRunPromptPreview(now = Date.now()) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readMvuExtraAnalysisFlag() {
|
||||||
|
try {
|
||||||
|
const sameFrameMvu = globalThis?.window?.Mvu;
|
||||||
|
if (typeof sameFrameMvu?.isDuringExtraAnalysis === "function") {
|
||||||
|
return Boolean(sameFrameMvu.isDuringExtraAnalysis());
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const parentMvu = globalThis?.window?.parent?.Mvu;
|
||||||
|
if (typeof parentMvu?.isDuringExtraAnalysis === "function") {
|
||||||
|
return Boolean(parentMvu.isDuringExtraAnalysis());
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const getActivePinia =
|
||||||
|
globalThis?.window?.getActivePinia ??
|
||||||
|
globalThis?.window?.parent?.getActivePinia;
|
||||||
|
if (typeof getActivePinia === "function") {
|
||||||
|
const pinia = getActivePinia();
|
||||||
|
return Boolean(
|
||||||
|
pinia?.state?.value?.["MVU变量框架"]?.runtimes?.is_during_extra_analysis,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isMvuExtraAnalysisGuardActive(now = Date.now()) {
|
||||||
|
if (readMvuExtraAnalysisFlag()) {
|
||||||
|
mvuExtraAnalysisGuardUntil = Math.max(
|
||||||
|
mvuExtraAnalysisGuardUntil,
|
||||||
|
now + MVU_EXTRA_ANALYSIS_GUARD_TTL_MS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mvuExtraAnalysisGuardUntil <= now) {
|
||||||
|
if (mvuExtraAnalysisGuardUntil !== 0) {
|
||||||
|
mvuExtraAnalysisGuardUntil = 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function isGraphEffectivelyEmpty(graph) {
|
function isGraphEffectivelyEmpty(graph) {
|
||||||
if (!graph || typeof graph !== "object") {
|
if (!graph || typeof graph !== "object") {
|
||||||
return true;
|
return true;
|
||||||
@@ -12642,6 +12692,7 @@ function onMessageEdited(messageId, meta = null) {
|
|||||||
const result = onMessageEditedController(
|
const result = onMessageEditedController(
|
||||||
{
|
{
|
||||||
invalidateRecallAfterHistoryMutation,
|
invalidateRecallAfterHistoryMutation,
|
||||||
|
isMvuExtraAnalysisGuardActive,
|
||||||
refreshPersistedRecallMessageUi: schedulePersistedRecallMessageUiRefresh,
|
refreshPersistedRecallMessageUi: schedulePersistedRecallMessageUiRefresh,
|
||||||
scheduleHistoryMutationRecheck,
|
scheduleHistoryMutationRecheck,
|
||||||
},
|
},
|
||||||
@@ -12739,6 +12790,7 @@ async function onGenerationAfterCommands(type, params = {}, dryRun = false) {
|
|||||||
getContext,
|
getContext,
|
||||||
getGenerationRecallHookStateFromResult,
|
getGenerationRecallHookStateFromResult,
|
||||||
getGenerationRecallTransactionResult,
|
getGenerationRecallTransactionResult,
|
||||||
|
isMvuExtraAnalysisGuardActive,
|
||||||
markGenerationRecallTransactionHookState,
|
markGenerationRecallTransactionHookState,
|
||||||
resolveGenerationRecallDeliveryMode,
|
resolveGenerationRecallDeliveryMode,
|
||||||
runRecall,
|
runRecall,
|
||||||
@@ -12763,6 +12815,7 @@ async function onBeforeCombinePrompts(promptData = null) {
|
|||||||
getContext,
|
getContext,
|
||||||
getGenerationRecallHookStateFromResult,
|
getGenerationRecallHookStateFromResult,
|
||||||
getGenerationRecallTransactionResult,
|
getGenerationRecallTransactionResult,
|
||||||
|
isMvuExtraAnalysisGuardActive,
|
||||||
markGenerationRecallTransactionHookState,
|
markGenerationRecallTransactionHookState,
|
||||||
resolveGenerationRecallDeliveryMode,
|
resolveGenerationRecallDeliveryMode,
|
||||||
runRecall,
|
runRecall,
|
||||||
|
|||||||
Reference in New Issue
Block a user