from definable.interfaces import InterfaceHook, InterfaceMessage, InterfaceResponse, InterfaceSession
class MyHook:
async def on_message_received(self, message: InterfaceMessage) -> bool | None:
"""Called when a message arrives. Return False to skip it."""
...
async def on_before_respond(
self, message: InterfaceMessage, session: InterfaceSession
) -> InterfaceMessage | None:
"""Called before agent processing. Return a new message to modify it."""
...
async def on_after_respond(
self, message: InterfaceMessage, response: InterfaceResponse, session: InterfaceSession
) -> InterfaceResponse | None:
"""Called after agent produces a response. Return a new response to modify it."""
...
async def on_error(self, error: Exception, message: InterfaceMessage | None) -> None:
"""Called when an error occurs."""
...