mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
feat(cognition): finish multi-character knowledge and monitor workflow
This commit is contained in:
@@ -3,6 +3,11 @@ import {
|
||||
normalizeEdgeMemoryScope,
|
||||
normalizeNodeMemoryScope,
|
||||
} from "../graph/memory-scope.js";
|
||||
import {
|
||||
createDefaultKnowledgeState,
|
||||
createDefaultRegionState,
|
||||
normalizeGraphCognitiveState,
|
||||
} from "../graph/knowledge-state.js";
|
||||
|
||||
const BATCH_JOURNAL_LIMIT = 96;
|
||||
const MAINTENANCE_JOURNAL_LIMIT = 20;
|
||||
@@ -28,8 +33,11 @@ export function createDefaultHistoryState(chatId = "") {
|
||||
lastBatchStatus: null,
|
||||
lastExtractedRegion: "",
|
||||
activeRegion: "",
|
||||
activeRegionSource: "",
|
||||
activeCharacterPovOwner: "",
|
||||
activeUserPovOwner: "",
|
||||
activeRecallOwnerKey: "",
|
||||
recentRecallOwnerKeys: [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -113,12 +121,29 @@ export function normalizeGraphRuntimeState(graph, chatId = "") {
|
||||
if (typeof historyState.activeRegion !== "string") {
|
||||
historyState.activeRegion = historyState.lastExtractedRegion || "";
|
||||
}
|
||||
if (typeof historyState.activeRegionSource !== "string") {
|
||||
historyState.activeRegionSource = historyState.activeRegion ? "history" : "";
|
||||
}
|
||||
if (typeof historyState.activeCharacterPovOwner !== "string") {
|
||||
historyState.activeCharacterPovOwner = "";
|
||||
}
|
||||
if (typeof historyState.activeUserPovOwner !== "string") {
|
||||
historyState.activeUserPovOwner = "";
|
||||
}
|
||||
if (typeof historyState.activeRecallOwnerKey !== "string") {
|
||||
historyState.activeRecallOwnerKey = "";
|
||||
}
|
||||
if (!Array.isArray(historyState.recentRecallOwnerKeys)) {
|
||||
historyState.recentRecallOwnerKeys = [];
|
||||
} else {
|
||||
historyState.recentRecallOwnerKeys = [
|
||||
...new Set(
|
||||
historyState.recentRecallOwnerKeys
|
||||
.map((value) => String(value || "").trim())
|
||||
.filter(Boolean),
|
||||
),
|
||||
].slice(0, 8);
|
||||
}
|
||||
|
||||
if (
|
||||
!historyState.processedMessageHashes ||
|
||||
@@ -220,6 +245,9 @@ export function normalizeGraphRuntimeState(graph, chatId = "") {
|
||||
.filter((entry) => entry && typeof entry === "object")
|
||||
.slice(-MAINTENANCE_JOURNAL_LIMIT)
|
||||
: createDefaultMaintenanceJournal();
|
||||
graph.knowledgeState = createDefaultKnowledgeState(graph.knowledgeState);
|
||||
graph.regionState = createDefaultRegionState(graph.regionState);
|
||||
normalizeGraphCognitiveState(graph);
|
||||
graph.lastProcessedSeq = historyState.lastProcessedAssistantFloor;
|
||||
return graph;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user