mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
Implement scoped memory graph and refresh defaults
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
// ST-BME: 运行时状态与历史恢复辅助
|
||||
import {
|
||||
normalizeEdgeMemoryScope,
|
||||
normalizeNodeMemoryScope,
|
||||
} from "./memory-scope.js";
|
||||
|
||||
const BATCH_JOURNAL_LIMIT = 96;
|
||||
const MAINTENANCE_JOURNAL_LIMIT = 20;
|
||||
@@ -22,6 +26,10 @@ export function createDefaultHistoryState(chatId = "") {
|
||||
extractionCount: 0,
|
||||
lastRecoveryResult: null,
|
||||
lastBatchStatus: null,
|
||||
lastExtractedRegion: "",
|
||||
activeRegion: "",
|
||||
activeCharacterPovOwner: "",
|
||||
activeUserPovOwner: "",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -99,6 +107,18 @@ export function normalizeGraphRuntimeState(graph, chatId = "") {
|
||||
historyAdvanced: false,
|
||||
};
|
||||
}
|
||||
if (typeof historyState.lastExtractedRegion !== "string") {
|
||||
historyState.lastExtractedRegion = "";
|
||||
}
|
||||
if (typeof historyState.activeRegion !== "string") {
|
||||
historyState.activeRegion = historyState.lastExtractedRegion || "";
|
||||
}
|
||||
if (typeof historyState.activeCharacterPovOwner !== "string") {
|
||||
historyState.activeCharacterPovOwner = "";
|
||||
}
|
||||
if (typeof historyState.activeUserPovOwner !== "string") {
|
||||
historyState.activeUserPovOwner = "";
|
||||
}
|
||||
|
||||
if (
|
||||
!historyState.processedMessageHashes ||
|
||||
@@ -186,6 +206,12 @@ export function normalizeGraphRuntimeState(graph, chatId = "") {
|
||||
|
||||
graph.historyState = historyState;
|
||||
graph.vectorIndexState = vectorIndexState;
|
||||
if (Array.isArray(graph.nodes)) {
|
||||
graph.nodes.forEach((node) => normalizeNodeMemoryScope(node));
|
||||
}
|
||||
if (Array.isArray(graph.edges)) {
|
||||
graph.edges.forEach((edge) => normalizeEdgeMemoryScope(edge));
|
||||
}
|
||||
graph.batchJournal = Array.isArray(graph.batchJournal)
|
||||
? graph.batchJournal.slice(-BATCH_JOURNAL_LIMIT)
|
||||
: createDefaultBatchJournal();
|
||||
|
||||
Reference in New Issue
Block a user