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

Function openDB

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

Source from the content-addressed store, hash-verified

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