MCPcopy
hub / github.com/rohitg00/agentmemory / mockKV

Function mockKV

test/auto-forget.test.ts:15–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13import type { Memory, CompressedObservation, Session } from "../src/types.js";
14
15function mockKV() {
16 const store = new Map<string, Map<string, unknown>>();
17 return {
18 get: async <T>(scope: string, key: string): Promise<T | null> => {
19 return (store.get(scope)?.get(key) as T) ?? null;
20 },
21 set: async <T>(scope: string, key: string, data: T): Promise<T> => {
22 if (!store.has(scope)) store.set(scope, new Map());
23 store.get(scope)!.set(key, data);
24 return data;
25 },
26 delete: async (scope: string, key: string): Promise<void> => {
27 store.get(scope)?.delete(key);
28 },
29 list: async <T>(scope: string): Promise<T[]> => {
30 const entries = store.get(scope);
31 return entries ? (Array.from(entries.values()) as T[]) : [];
32 },
33 };
34}
35
36function mockSdk() {
37 const functions = new Map<string, Function>();

Callers 1

Calls 4

hasMethod · 0.80
getMethod · 0.45
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected