( sessionPath: string, content: string, category: string, )
| 111 | |
| 112 | /** Save a single memory entry */ |
| 113 | export async function saveMemory( |
| 114 | sessionPath: string, |
| 115 | content: string, |
| 116 | category: string, |
| 117 | ): Promise<MemoryEntry> { |
| 118 | const entry: MemoryEntry = { |
| 119 | id: `mem_${Date.now()}`, |
| 120 | content, |
| 121 | category: (['fact', 'preference', 'event', 'emotion'].includes(category) |
| 122 | ? category |
| 123 | : 'other') as MemoryEntry['category'], |
| 124 | createdAt: Date.now(), |
| 125 | }; |
| 126 | |
| 127 | try { |
| 128 | await fetch(memoryApiUrl(sessionPath, `${entry.id}.json`), { |
| 129 | method: 'POST', |
| 130 | headers: { 'Content-Type': 'application/json' }, |
| 131 | body: JSON.stringify(entry), |
| 132 | }); |
| 133 | } catch { |
| 134 | // silently ignore |
| 135 | } |
| 136 | |
| 137 | return entry; |
| 138 | } |
| 139 | |
| 140 | /** Execute the save_memory tool call */ |
| 141 | export async function executeMemoryTool( |
no test coverage detected