Overview
ChannelContext extends ExecutionContextBase and provides the foundation for all channel implementations. It handles event transformation via onEvent() and optional reply handling via onReply().
Class Hierarchy
Abstract Methods
onEvent
Transform an incoming event payload into a channel notification.
Returns:
Promise<ChannelNotification> — the notification to push to Claude Code sessions.
Payload Shapes by Source
Optional Methods
onReply
Handle a reply from Claude Code. Only called when the channel hastwoWay: true.
Default implementation logs a warning. Override to forward replies to external systems.
Lifecycle Hooks (Service Connectors)
For channels withsource: { type: 'service' } or source: { type: 'file-watcher' }, these lifecycle hooks manage persistent connections.
onConnect
Establish a persistent connection to an external service. Called during scope initialization after the notification service is wired.pushIncoming() inside event listeners to feed incoming events into the notification pipeline.
onDisconnect
Tear down the persistent connection. Called during scope shutdown.pushIncoming
Push an incoming event from a service connection into the notification pipeline. TriggersonEvent() → notification push to subscribed sessions.
Inherited Properties
FromExecutionContextBase:
Inherited Methods
FromExecutionContextBase:
Examples
Webhook Channel
Service Connector (Full Lifecycle)
Related
- @Channel Decorator — decorator configuration options
- Channels Guide — full documentation
- ExecutionContextBase — base class reference