MCPcopy
hub / github.com/callstack/agent-device / createMemorySessionStore

Function createMemorySessionStore

src/runtime.ts:40–54  ·  view source on GitHub ↗
(
  records: readonly CommandSessionRecord[] = [],
)

Source from the content-addressed store, hash-verified

38}
39
40export function createMemorySessionStore(
41 records: readonly CommandSessionRecord[] = [],
42): CommandSessionStore {
43 const sessions = new Map(records.map((record) => [record.name, cloneSessionRecord(record)]));
44 return {
45 get: (name) => cloneSessionRecord(sessions.get(name)),
46 set: (record) => {
47 sessions.set(record.name, cloneSessionRecord(record));
48 },
49 delete: (name) => {
50 sessions.delete(name);
51 },
52 list: () => Array.from(sessions.values(), (record) => cloneSessionRecord(record)),
53 };
54}
55
56function cloneSessionRecord(record: CommandSessionRecord): CommandSessionRecord;
57function cloneSessionRecord(record: undefined): undefined;

Callers 5

createInteractionDeviceFunction · 0.90
createAgentDeviceFunction · 0.85

Calls 5

cloneSessionRecordFunction · 0.85
getMethod · 0.80
setMethod · 0.80
deleteMethod · 0.80
valuesMethod · 0.80

Tested by 1

createInteractionDeviceFunction · 0.72