This commit is contained in:
@@ -47,6 +47,10 @@ export class InMemoryMemoryStore implements BoxBrainMemoryStore {
|
||||
return stored;
|
||||
}
|
||||
|
||||
async listFacts(spaceId: string): Promise<StoredFact[]> {
|
||||
return [...(this.facts.get(spaceId) ?? [])].sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
||||
}
|
||||
|
||||
async findFacts(spaceId: string, topics: string[]): Promise<StoredFact[]> {
|
||||
const facts = this.facts.get(spaceId) ?? [];
|
||||
if (topics.length === 0) return [...facts];
|
||||
@@ -120,6 +124,17 @@ export class IdentityDbMemoryStore implements BoxBrainMemoryStore {
|
||||
return this.fromIdentityFact(stored);
|
||||
}
|
||||
|
||||
async listFacts(spaceId: string): Promise<StoredFact[]> {
|
||||
const topics = await this.options.db.listTopics({ spaceName: spaceId, includeFacts: true });
|
||||
const collected = new Map<string, StoredFact>();
|
||||
for (const topic of topics) {
|
||||
for (const fact of topic.facts) {
|
||||
collected.set(fact.id, this.fromIdentityFact(fact));
|
||||
}
|
||||
}
|
||||
return [...collected.values()].sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
||||
}
|
||||
|
||||
async findFacts(spaceId: string, topics: string[]): Promise<StoredFact[]> {
|
||||
const uniqueTopics = normalizeTopics(topics);
|
||||
const collected = new Map<string, StoredFact>();
|
||||
|
||||
@@ -167,6 +167,7 @@ export interface BoxBrainMemoryStore {
|
||||
createSpace(input: { displayName: string; seedMessage: string; now: string }): Promise<MemorySpace>;
|
||||
getSpace(spaceId: string): Promise<MemorySpace | null>;
|
||||
addFact(spaceId: string, fact: FactDraft): Promise<StoredFact>;
|
||||
listFacts(spaceId: string): Promise<StoredFact[]>;
|
||||
findFacts(spaceId: string, topics: string[]): Promise<StoredFact[]>;
|
||||
saveScheduleEntries(spaceId: string, entries: ScheduleEntry[]): Promise<void>;
|
||||
listScheduleEntries(spaceId: string, fromInclusive: string, toExclusive: string): Promise<ScheduleEntry[]>;
|
||||
|
||||
Reference in New Issue
Block a user