Normalize mistaken user owners across extraction and cognition

This commit is contained in:
Youzini-afk
2026-04-09 23:38:14 +08:00
parent d1b07d8cbb
commit 5c9a8a9df1
7 changed files with 512 additions and 98 deletions

View File

@@ -14,6 +14,14 @@ import {
setManualActiveRegion,
} from "../graph/knowledge-state.js";
globalThis.SillyTavern = {
getContext() {
return {
name1: "露西亚",
};
},
};
const graph = createEmptyGraph();
const erinA = createNode({
type: "character",
@@ -168,4 +176,24 @@ assert.deepEqual(
["character", "user"],
);
const aliasMatchedUserOwner = resolveKnowledgeOwner(graph, {
ownerType: "character",
ownerName: "露 西 亚",
});
assert.equal(aliasMatchedUserOwner.ownerType, "user");
assert.equal(aliasMatchedUserOwner.ownerName, "露西亚");
const syntheticGraph = createEmptyGraph();
syntheticGraph.historyState.activeUserPovOwner = "玩家";
addNode(
syntheticGraph,
createNode({
type: "character",
fields: { name: "玩 家" },
seq: 1,
}),
);
const syntheticOwners = listKnowledgeOwners(syntheticGraph);
assert.equal(syntheticOwners.some((entry) => entry.ownerType === "character"), false);
console.log("knowledge-state tests passed");