diff --git a/src/looking_glass/stray-cat.ts b/src/looking_glass/stray-cat.ts index 791c02c..3a8dd03 100644 --- a/src/looking_glass/stray-cat.ts +++ b/src/looking_glass/stray-cat.ts @@ -112,6 +112,7 @@ export class StrayCat { log.warn(`No websocket connection is open for "${this.userId}". Queuing the message...`) this.wsQueue.push(msg) } + madHatter.executeHook('afterSendMessage', msg, this) } /** diff --git a/src/mad_hatter/core_plugin/plugin-hooks.ts b/src/mad_hatter/core_plugin/plugin-hooks.ts index f48193d..d91b339 100644 --- a/src/mad_hatter/core_plugin/plugin-hooks.ts +++ b/src/mad_hatter/core_plugin/plugin-hooks.ts @@ -35,6 +35,8 @@ CatHook.add('beforeReadMessage', msg => msg) CatHook.add('beforeSendMessage', msg => msg) +CatHook.add('afterSendMessage', msg => msg) + CatHook.add('beforeStoreEpisodicMemory', doc => doc) CatHook.add('beforeRecallMemories', configs => configs) diff --git a/src/mad_hatter/hook.ts b/src/mad_hatter/hook.ts index 8eef630..7a379e4 100644 --- a/src/mad_hatter/hook.ts +++ b/src/mad_hatter/hook.ts @@ -5,7 +5,7 @@ import type { EmbedderSettings, LLMSettings } from '@factory' import type { VectorMemoryCollection } from '@memory' import type { FileParsers, WebParser } from '@rh' import type { AgentFastReply, ContextInput, InstantToolTrigger } from '@dto/agent.ts' -import type { MemoryMessage, MemoryRecallConfigs, Message } from '@/dtos/message.ts' +import type { MemoryMessage, MemoryRecallConfigs, Message, WSMessage } from '@dto/message.ts' export interface HookTypes { // Cheshire Cat hooks @@ -28,6 +28,7 @@ export interface HookTypes { recallQuery: (query: string, stray: StrayCat) => MaybePromise beforeReadMessage: (msg: Message, stray: StrayCat) => MaybePromise beforeSendMessage: (msg: MemoryMessage, stray: StrayCat) => MaybePromise + afterSendMessage: (msg: WSMessage, stray: StrayCat) => MaybePromise beforeStoreEpisodicMemory: (doc: Document, stray: StrayCat) => MaybePromise beforeRecallMemories: (configs: MemoryRecallConfigs, stray: StrayCat) => MaybePromise afterRecallMemories: (stray: StrayCat) => MaybePromise