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

Function mockKV

test/timeline.test.ts:10–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

timeline.test.tsFile · 0.70

Calls 4

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

Tested by

no test coverage detected