diff --git a/docs/hooks.md b/docs/hooks.md index 8576146ba..86f0b9ca3 100644 --- a/docs/hooks.md +++ b/docs/hooks.md @@ -235,6 +235,15 @@ Triggered when the gateway starts: - **`gateway:startup`**: After channels start and hooks are loaded +### Session Events + +Triggered during session lifecycle: + +- **`session:start`**: When a new session begins (after `/new`, `/reset`, or first message from a new sender) + - Context includes: `sessionEntry`, `sessionId`, `sessionFile`, `commandSource`, `senderId`, `isReset` (true if triggered by reset command), `cfg` +- **`session:end`**: When a session ends (before `/new` or `/reset` clears the session) + - Context includes: `sessionEntry` (previous session), `sessionId`, `sessionFile`, `commandSource`, `senderId`, `reason` ("reset"), `cfg` + ### Tool Result Hooks (Plugin API) These hooks are not event-stream listeners; they let plugins synchronously adjust tool results before Moltbot persists them. @@ -244,9 +253,6 @@ These hooks are not event-stream listeners; they let plugins synchronously adjus ### Future Events Planned event types: - -- **`session:start`**: When a new session begins -- **`session:end`**: When a session ends - **`agent:error`**: When an agent encounters an error - **`message:sent`**: When a message is sent - **`message:received`**: When a message is received diff --git a/src/auto-reply/reply/commands-core.ts b/src/auto-reply/reply/commands-core.ts index a54f90b2b..757315edc 100644 --- a/src/auto-reply/reply/commands-core.ts +++ b/src/auto-reply/reply/commands-core.ts @@ -71,6 +71,21 @@ export async function handleCommands(params: HandleCommandsParams): Promise