import { ChannelContext, ChannelEntry, type ChannelRecord, type EntryOwnerRef, type ScopeEntry } from '../common'; import type { ChannelNotification } from '../common/metadata/channel.metadata'; import type ProviderRegistry from '../provider/provider.registry'; import type { ChannelNotificationService } from './channel-notification.service'; /** * Concrete implementation of a channel that can receive events and push notifications. * * For service connector channels (source: { type: 'service' }), maintains a persistent * ChannelContext that is connected on init and disconnected on teardown. * * **Scope Binding:** The ChannelInstance captures its scope and providers at construction time. */ export declare class ChannelInstance extends ChannelEntry { /** The provider registry this channel is bound to */ private readonly _providers; /** The scope this channel operates in */ readonly scope: ScopeEntry; /** The notification service for pushing to Claude Code sessions */ private _channelNotificationService?; /** Persistent context for service connectors (kept alive for the lifetime of the scope) */ private _serviceContext?; /** Replay buffer for events that arrive when no sessions are connected */ private _replayBuffer; /** Maximum replay buffer size */ private readonly _maxReplayEvents; constructor(record: ChannelRecord, providers: ProviderRegistry, owner: EntryOwnerRef); /** * Set the notification service reference (injected after registry init). */ setNotificationService(service: ChannelNotificationService): void; get providers(): ProviderRegistry; /** * Whether this channel requires a persistent connection via onConnect()/onDisconnect(). * True for service connectors and file watchers. */ get isServiceConnector(): boolean; protected initialize(): Promise; /** * Connect the service connector (called after notification service is wired). * Creates a persistent context, wires pushIncoming, and calls onConnect(). */ connectService(): Promise; /** * Disconnect the service connector (called during scope teardown). */ disconnectService(): Promise; /** * Get the persistent service context (for service connectors only). */ get serviceContext(): ChannelContext | undefined; /** * Create a ChannelContext for handling an event. */ create(authInfo: Partial>): ChannelContext; /** * Whether replay buffering is enabled for this channel. */ get replayEnabled(): boolean; /** * Get the current replay buffer contents (read-only). */ get replayBuffer(): readonly ChannelNotification[]; /** * Push a notification to subscribed Claude Code sessions. * * **Session isolation:** If `targetSessionId` is provided, the notification is sent * ONLY to that specific session. This prevents session-scoped data (job results, * agent outputs) from leaking to other connected sessions. * * If `targetSessionId` is undefined, the notification goes to ALL subscribed sessions * (appropriate for global events like webhooks, file changes, etc.). * * @param content - The notification content * @param meta - Additional metadata * @param targetSessionId - If set, deliver ONLY to this session */ pushNotification(content: string, meta?: Record, targetSessionId?: string): void; /** * Replay buffered events to a specific session. * Called when a new Claude Code session connects and the channel has buffered events. * * @param sessionId - The session to replay events to * @returns Number of events replayed */ replayBufferedEvents(sessionId: string): number; /** * Clear the replay buffer. */ clearReplayBuffer(): void; /** * Handle an incoming event from the channel's source. * Creates a context, transforms the payload, and pushes the notification. * * @param payload - The raw event payload from the source * @param targetSessionId - If set, deliver notification ONLY to this session * (prevents session-scoped data from leaking to other sessions) * @returns The notification that was sent (or null if transform failed) */ handleEvent(payload: unknown, targetSessionId?: string): Promise; /** * Handle a reply from Claude Code (for two-way channels). */ handleReply(reply: string, meta?: Record): Promise; } //# sourceMappingURL=channel.instance.d.ts.map