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.| Parameter | Type | Description |
|---|---|---|
payload | unknown | Raw event payload from the source. Shape depends on source type. |
Promise<ChannelNotification> — the notification to push to Claude Code sessions.
Payload Shapes by Source
| Source | Payload Shape |
|---|---|
webhook | WebhookPayload { body, headers, method, query } |
app-event | Whatever was passed to eventBus.emit(event, payload) |
agent-completion | AgentCompletionEvent { agentId, agentName, status, durationMs, output, error } |
job-completion | JobCompletionEvent { jobName, jobId, status, durationMs, output, error, sessionId } |
service | Whatever pushIncoming(payload) receives from your connection listener |
file-watcher | Whatever pushIncoming(payload) receives from your file watcher |
manual | Whatever was passed to handleEvent(payload) |
Optional Methods
onReply
Handle a reply from Claude Code. Only called when the channel hastwoWay: true.
| Parameter | Type | Description |
|---|---|---|
reply | string | The reply text from Claude |
meta | Record<string, string> | Metadata from the channel-reply tool call (e.g., chat_id) |
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.
| Parameter | Type | Description |
|---|---|---|
payload | unknown | Raw event payload to process through onEvent() |
Inherited Properties
FromExecutionContextBase:
| Property | Type | Description |
|---|---|---|
logger | FrontMcpLogger | Scoped logger for this channel |
metadata | ChannelMetadata | The channel’s decorator metadata |
channelName | string | The channel name (from metadata) |
Inherited Methods
FromExecutionContextBase:
| Method | Description |
|---|---|
get<T>(token) | Resolve a dependency from the DI container |
tryGet<T>(token) | Resolve or return undefined if not found |
scope | Access the parent scope |
fail(error) | Throw an MCP error |
Examples
Webhook Channel
Service Connector (Full Lifecycle)
Related
- @Channel Decorator — decorator configuration options
- Channels Guide — full documentation
- ExecutionContextBase — base class reference