mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
fix: restore missing runtime persistence helpers
This commit is contained in:
@@ -883,6 +883,64 @@ async function createGraphPersistenceHarness({
|
|||||||
buildSnapshotFromGraph,
|
buildSnapshotFromGraph,
|
||||||
evaluatePersistNativeDeltaGate,
|
evaluatePersistNativeDeltaGate,
|
||||||
buildBmeDbName,
|
buildBmeDbName,
|
||||||
|
BME_GRAPH_LOCAL_STORAGE_MODE_INDEXEDDB: "indexeddb",
|
||||||
|
BME_GRAPH_LOCAL_STORAGE_MODE_OPFS_SHADOW: "opfs-shadow",
|
||||||
|
detectOpfsSupport: async () => ({
|
||||||
|
available: false,
|
||||||
|
reason: "opfs-unsupported-in-test",
|
||||||
|
}),
|
||||||
|
isGraphLocalStorageModeOpfs: (mode = "") =>
|
||||||
|
/^opfs-/.test(String(mode || "").trim().toLowerCase()),
|
||||||
|
normalizeGraphLocalStorageMode: (mode = "", fallback = "indexeddb") => {
|
||||||
|
const normalized = String(mode || "").trim().toLowerCase();
|
||||||
|
if (
|
||||||
|
normalized === "indexeddb" ||
|
||||||
|
normalized === "opfs-shadow" ||
|
||||||
|
normalized === "opfs-primary"
|
||||||
|
) {
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
return String(fallback || "indexeddb").trim().toLowerCase() || "indexeddb";
|
||||||
|
},
|
||||||
|
OpfsGraphStore: class {
|
||||||
|
constructor(dbChatId = "") {
|
||||||
|
this.chatId = String(dbChatId || "");
|
||||||
|
this.storeKind = "opfs";
|
||||||
|
this.storeMode = "opfs-shadow";
|
||||||
|
}
|
||||||
|
async open() {}
|
||||||
|
async close() {}
|
||||||
|
async exportSnapshot() {
|
||||||
|
return getIndexedDbSnapshotForChat(this.chatId);
|
||||||
|
}
|
||||||
|
async commitDelta(delta, options = {}) {
|
||||||
|
return commitIndexedDbDelta(this.chatId, delta, options);
|
||||||
|
}
|
||||||
|
async importSnapshot(snapshot) {
|
||||||
|
setIndexedDbSnapshotForChat(this.chatId, snapshot);
|
||||||
|
return {
|
||||||
|
revision: Number(snapshot?.meta?.revision) || 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
async isEmpty() {
|
||||||
|
const snapshot = getIndexedDbSnapshotForChat(this.chatId);
|
||||||
|
return {
|
||||||
|
empty:
|
||||||
|
!snapshot ||
|
||||||
|
(!snapshot.nodes?.length && !snapshot.edges?.length && !snapshot.tombstones?.length),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
async getRevision() {
|
||||||
|
return Number(getIndexedDbSnapshotForChat(this.chatId)?.meta?.revision || 0);
|
||||||
|
}
|
||||||
|
async getMeta(key, fallbackValue = 0) {
|
||||||
|
const snapshot = getIndexedDbSnapshotForChat(this.chatId) || {};
|
||||||
|
if (!snapshot?.meta || !(key in snapshot.meta)) {
|
||||||
|
return fallbackValue;
|
||||||
|
}
|
||||||
|
return snapshot.meta[key];
|
||||||
|
}
|
||||||
|
},
|
||||||
scheduleUpload() {
|
scheduleUpload() {
|
||||||
if (runtimeContext.__scheduleUploadShouldThrow) {
|
if (runtimeContext.__scheduleUploadShouldThrow) {
|
||||||
throw new Error("schedule-upload-failed");
|
throw new Error("schedule-upload-failed");
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ export function createGenerationRecallHarness(options = {}) {
|
|||||||
},
|
},
|
||||||
isRecalling: false,
|
isRecalling: false,
|
||||||
getCurrentChatId: () => "chat-main",
|
getCurrentChatId: () => "chat-main",
|
||||||
|
normalizeChatIdCandidate: (value = "") => String(value ?? "").trim(),
|
||||||
normalizeRecallInputText: (text = "") => String(text || "").trim(),
|
normalizeRecallInputText: (text = "") => String(text || "").trim(),
|
||||||
isTrivialUserInput,
|
isTrivialUserInput,
|
||||||
getAssistantTurns: (chat = []) =>
|
getAssistantTurns: (chat = []) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user