(
messages: Array<{ role: string; content: string }>,
memoryLevel: string,
agentId?: string,
infer: boolean = true
)
| 364 | // --------------------------------------------------------------------------- |
| 365 | |
| 366 | export async function addMemory( |
| 367 | messages: Array<{ role: string; content: string }>, |
| 368 | memoryLevel: string, |
| 369 | agentId?: string, |
| 370 | infer: boolean = true |
| 371 | ): Promise<boolean> { |
| 372 | try { |
| 373 | const body = { |
| 374 | messages, |
| 375 | memory_level: memoryLevel, |
| 376 | infer, |
| 377 | ...(agentId && { agent_id: agentId }), |
| 378 | }; |
| 379 | const res = await requestJson(API_ENDPOINTS.memory.entry.add, { |
| 380 | method: "POST", |
| 381 | headers: getAuthHeaders(), |
| 382 | body: JSON.stringify(body), |
| 383 | }); |
| 384 | // Backend returns inserted info or payload directly on success |
| 385 | return !!res; |
| 386 | } catch (e) { |
| 387 | log.error("addMemory error", e); |
| 388 | throw e; |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | export async function clearMemory( |
| 393 | memoryLevel: string, |
no test coverage detected