useSoulMemory
The useSoulMemory
hook returns a soul-wide reference to a memory container, accessed by key, as a way to persist information across the soul. It's usage is very similar to useProcessMemory
, but is scoped to soul-wide data.
exampleProcess.ts
import { useSoulMemory } from "@opensouls/engine"
const exampleProcess: MentalProcess = async ({ workingMemory }) => {
// create a persistent memory container scoped to the soul
const wasProvoked = useSoulMemory("wasProvoked", false)
console.log("current value of wasProvoked", wasProvoked.current)
// set the current value immediately
wasProvoked.current = true
// do other stuff ...
return workingMemory
}
export default exampleProcess
ℹ️
The memory container created here can be accessed in any mental process, and persists for the life of the soul.