+ Break-out functionality in `sendMessage` into separate procedures, namespaced by domain (e.g. `messages`, `facts`, `factTriggers`). + Make a `withDbWrite` function to wrap the calls to these procedures, so as to separate the generation of data from persisting it. + Somehow subscribe the UI to events from the `sendMessage` procedure, so the user knows what's going on. + Parallelize the generation of data, so that the UI doesn't freeze for so long while the data is being generated. + Chunk and generate embeddings for generated facts and fact triggers. And save them to a database. + Query the database for facts triggers that match the current conversation situation, and inject the facts they refer to into the conversation context. + Implement tool use. Including tool triggers similar to fact triggers.