| 33 | * at creation (the user picks a type when adding), so it is never patched here. |
| 34 | */ |
| 35 | export function updateMemory(id: string, patch: { label?: string; arguments?: Record<string, unknown> }): void { |
| 36 | const key = id; |
| 37 | useEditorStore.getState().setMemory((mem) => { |
| 38 | const existing = mem[key]; |
| 39 | if (!existing) return mem; |
| 40 | return { |
| 41 | ...mem, |
| 42 | [key]: { |
| 43 | ...existing, |
| 44 | ...(patch.label !== undefined ? { label: patch.label } : {}), |
| 45 | ...(patch.arguments ? { arguments: { ...existing.arguments, ...patch.arguments } } : {}), |
| 46 | }, |
| 47 | }; |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | export function deleteMemory(id: string): void { |
| 52 | const key = id; |