MCPcopy Create free account
hub / github.com/Roy3838/Observer / openDB

Function openDB

app/src/utils/agent_database.ts:27–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25
26// Open the database
27export async function openDB(): Promise<IDBDatabase> {
28 return new Promise((resolve, reject) => {
29 const request = indexedDB.open(DB_NAME, DB_VERSION);
30
31 request.onerror = () => reject(request.error);
32 request.onsuccess = () => resolve(request.result);
33
34 // Create the object stores when database is first created
35 request.onupgradeneeded = () => {
36 const db = request.result;
37
38 // Store for agent metadata
39 let agentStore: IDBObjectStore;
40 if (!db.objectStoreNames.contains(AGENT_STORE)) {
41 agentStore = db.createObjectStore(AGENT_STORE, { keyPath: 'id' });
42 } else {
43 agentStore = request.transaction!.objectStore(AGENT_STORE);
44 if (agentStore.indexNames.contains('by_status')) {
45 agentStore.deleteIndex('by_status');
46 }
47 }
48
49 // Store for agent configurations
50 if (!db.objectStoreNames.contains(CONFIG_STORE)) {
51 db.createObjectStore(CONFIG_STORE, { keyPath: 'id' });
52 }
53
54 // Store for agent code
55 if (!db.objectStoreNames.contains(CODE_STORE)) {
56 db.createObjectStore(CODE_STORE, { keyPath: 'id' });
57 }
58
59 // Store for agent memories
60 if (!db.objectStoreNames.contains(MEMORY_STORE)) {
61 db.createObjectStore(MEMORY_STORE, { keyPath: 'id' });
62 }
63
64 // Store for agent image memories
65 if (!db.objectStoreNames.contains(IMAGE_MEMORY_STORE)) {
66 db.createObjectStore(IMAGE_MEMORY_STORE, { keyPath: 'id' });
67 }
68 };
69 });
70}
71
72// Create or update an agent
73export async function saveAgent(

Callers 15

recordingsDB.tsFile · 0.85
saveAgentFunction · 0.85
getAllAgentIdsFunction · 0.85
listAgentsFunction · 0.85
getAgentFunction · 0.85
getAgentConfigFunction · 0.85
getAgentCodeFunction · 0.85
getAgentMemoryFunction · 0.85
getAllMemoriesFunction · 0.85
updateAgentMemoryFunction · 0.85
getAgentImageMemoryFunction · 0.85
getAllImageMemoriesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected