Skip to main content

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 has twoWay: true.
Default implementation logs a warning. Override to forward replies to external systems.

Lifecycle Hooks (Service Connectors)

For channels with source: { 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.
Use this to set up WebSocket connections, API clients, polling loops, or file watchers. Call 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. Triggers onEvent() → notification push to subscribed sessions.
Only call pushIncoming() inside onConnect() event listeners. Calling it before onConnect() completes will log a warning since the handler is not yet wired.

Inherited Properties

From ExecutionContextBase:

Inherited Methods

From ExecutionContextBase:

Examples

Webhook Channel

Service Connector (Full Lifecycle)