From b69b508d206b26030e7628ba1b6dd42e1842b9c8 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 29 Apr 2026 00:29:09 -0700 Subject: [PATCH] docs(hooks/bundled/readme): cover session compaction and message events The bundled hooks README listed only command/agent/gateway events and ended with a stale "More event types coming soon (session lifecycle, agent errors, etc.)" line, but production code now triggers: - session:compact:before / session:compact:after via src/agents/pi-embedded-runner/compaction-hooks.ts - message:received via src/auto-reply/reply/dispatch-from-config.ts - message:sent via src/infra/outbound/deliver.ts Updates the "Event Types" list with the four real production event names, drops the stale coming-soon line, and aligns the InternalHookEvent interface example with the actual InternalHookEventType union (adds "message" and refreshes the action examples). HOOK.md authors that target session lifecycle or message routing now have a real surface to subscribe to instead of relying on tribal knowledge or the type definitions. --- src/hooks/bundled/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hooks/bundled/README.md b/src/hooks/bundled/README.md index ad520d16d02..7eff826a226 100644 --- a/src/hooks/bundled/README.md +++ b/src/hooks/bundled/README.md @@ -170,8 +170,10 @@ Currently supported events: - **command:stop**: `/stop` command - **agent:bootstrap**: Before workspace bootstrap files are injected - **gateway:startup**: Gateway startup (after channels start) - -More event types coming soon (session lifecycle, agent errors, etc.). +- **session:compact:before**: Pre-compaction snapshot before the embedded runner rewrites session context +- **session:compact:after**: Post-compaction snapshot after the runner replaces session context +- **message:received**: Inbound channel message accepted for dispatch +- **message:sent**: Outbound channel message delivered (canonical payload only) ## Handler API @@ -179,8 +181,8 @@ Hook handlers receive an `InternalHookEvent` object: ```typescript interface InternalHookEvent { - type: "command" | "session" | "agent" | "gateway"; - action: string; // e.g., 'new', 'reset', 'stop' + type: "command" | "session" | "agent" | "gateway" | "message"; + action: string; // e.g., 'new', 'reset', 'stop', 'compact:before', 'received', 'sent' sessionKey: string; context: Record; timestamp: Date;