(type: MemoryType)
| 15 | |
| 16 | /** Create a new memory primitive of the given type in the editor store. Returns the new instance. */ |
| 17 | export function addMemory(type: MemoryType): Memory { |
| 18 | const id = generateId(); |
| 19 | const existing = Object.values(useEditorStore.getState().memory).map((m) => m.label); |
| 20 | const instance: Memory = { |
| 21 | id, |
| 22 | label: uniqueName(LABEL_PREFIX[type], existing), |
| 23 | type, |
| 24 | arguments: seedDefaultArguments(MemoryRegistry.getByType(type)?.parameters ?? []), |
| 25 | }; |
| 26 | useEditorStore.getState().setMemory((mem) => ({ ...mem, [id]: instance })); |
| 27 | return instance; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Apply a partial patch to a memory primitive. Top-level `label` and the |
no test coverage detected