/** * ChannelManager — encapsulates channel/pub-sub logic extracted from PhotonServer. * * Handles: * - Channel capability declaration for MCP server init * - Channel notification methods (per-target) * - Permission request/response flow * - Publishing channel events to daemon * - Subscribing to daemon channels and forwarding messages to MCP clients * - Cleanup of daemon subscriptions */ export type ChannelPermissionRequest = { request_id: string; tool_name: string; description: string; input_preview: string; }; export type ChannelPermissionResponse = { request_id: string; behavior: 'allow' | 'deny'; }; /** Channel-specific options extracted from PhotonServerOptions */ export interface ChannelOptions { channelMode?: boolean; channelName?: string; channelTargets?: string[]; channelInstructions?: string; } /** * Callback interface for sending notifications back to MCP clients. * PhotonServer implements this so ChannelManager stays decoupled. */ export interface ChannelNotificationSink { /** Send a notification to the primary (STDIO) server */ sendNotification(notification: { method: string; params: any; }): Promise; /** Send a notification to all SSE sessions */ sendNotificationToAllSessions(notification: { method: string; params: any; }): Promise; /** Get the photon instance for permission dispatch */ getPhotonInstance(): any; } export declare class ChannelManager { private channelUnsubscribers; private daemonName; private options; private workingDir?; private sink; private log; constructor(opts: { channelOptions: ChannelOptions; workingDir?: string; sink: ChannelNotificationSink; log: (level: string, message: string, data?: Record) => void; }); /** Whether channel mode is active */ get isChannelMode(): boolean; /** The current daemon name (set after daemon startup) */ get currentDaemonName(): string | null; /** Set the daemon name (called after daemon startup in PhotonServer) */ setDaemonName(name: string | null): void; /** * Returns the server name to use. * In channel mode, uses the channel name; otherwise defaults to 'photon-mcp'. */ getServerName(): string; /** * Returns extra capabilities to merge into the MCP Server capabilities object. * Produces the experimental channel entries for each declared target. */ getExtraCapabilities(): Record; /** * Returns extra server constructor options (e.g. instructions) for channel mode. */ getExtraServerOptions(): Record; /** * Get the notification methods for all declared channel targets. * Each target (e.g. 'claude') maps to `notifications/{target}/channel`. */ private getChannelNotificationMethods; /** * Handle a permission request from the client (e.g. Claude Code asking "Allow tool X?"). * Forwards to the photon instance via channel._dispatchPermission(). */ handlePermissionRequest(params: any): void; /** * Send a permission response back to the client. * Called by the photon instance (via this.channel.respond) when the user approves/denies. */ respondToPermission(response: ChannelPermissionResponse): void; /** * Publish a channel event to the daemon for cross-process pub/sub. * Called from output handlers whenever an emit has a `channel` field. */ publishIfChannel(emit: any): void; /** * Subscribe to daemon channels for cross-process notifications. * In channel mode, handleChannelMessage intercepts 'channel-push' events * and translates them to notifications/claude/channel for the connected client. */ subscribeToChannels(): Promise; /** * Handle incoming channel messages and forward as MCP notifications. * Routes channel-permission-response and channel-push messages, * and forwards everything else as standard MCP notifications with _photon data. */ private handleChannelMessage; /** * Check if an incoming message is a channel permission request and handle it. * Returns true if it was handled (caller should not process further). */ interceptPermissionRequest(message: any): boolean; /** * Unsubscribe from all daemon channels. Called during server shutdown. */ cleanup(): void; } //# sourceMappingURL=channel-manager.d.ts.map