Package com.tnsai.hooks.events
Interface HookEvent
- All Known Subinterfaces:
ActionHookEvent,AgentHookEvent,CapabilityHookEvent,ChatHookEvent,PluginHookEvent,SessionHookEvent
- All Known Implementing Classes:
AgentInit,AgentStart,AgentStop,OnActionError,OnCapabilityDispatch,OnChunk,OnNotification,OnSessionIdle,OnSPILoad,OnStateTransition,PostAction,PostChat,PreAction,PreChat,SessionEnd,SessionStart
public sealed interface HookEvent
permits ActionHookEvent, ChatHookEvent, AgentHookEvent, CapabilityHookEvent, SessionHookEvent, PluginHookEvent
Root of the hook event hierarchy (issue #58). Sealed to a fixed list
of category sub-interfaces — Tool, Action, Chat, Agent, Capability,
Memory, Group, Session, Plugin — each in its own follow-up PR (#59
tool/action, #60 chat/agent, #61 memory, #62 group, #63 session/plugin).
Sealing is intentional: callers that
switch over HookEvent get compile-time exhaustiveness,
and adding a new category in a follow-up PR forces every consumer
to acknowledge it. The cost is that adding a category here is a
minor breaking change for switch consumers — that's the right
trade-off for a safety-critical interception layer.
Categories landed so far:
ActionHookEvent— generic action-dispatch events (#59)ChatHookEvent— conversation-boundary events (#60)AgentHookEvent— agent lifecycle events (#60)CapabilityHookEvent—@Capabilitydispatch events (#60)SessionHookEvent— server session lifecycle events (#63)PluginHookEvent— SPI / tool registration events (#63)
permits clause in their feature PRs.- Since:
- 0.5.0 (issue #58)
-
Method Details
-
eventId
String eventId()Stable per-event id (ULID-shaped) for correlation across logs. -
timestamp
Instant timestamp()When the event was created. -
context
HookContext context()Surrounding context — tenant / agent / role / group / trace / etc. -
eventType
Short stable string identifier of the event kind, e.g."PreToolUse". Default implementation derives it from the concrete record's simple class name; concrete records may override if a different naming is desirable.
-