/** * Subscribe action — declarative real-time resource subscriptions with polling fallback. * * Enables server→client push via MCP resource subscriptions when the host supports it. * Automatically falls back to SetInterval + CallTool polling otherwise. */ import type { Action, ActionJSON } from './types.js'; export interface SubscribeOpts { /** Reactive store key where incoming data is written. */ stateKey: string; /** Poll interval (ms) when the host does not support push subscriptions. Defaults to 2000. */ fallbackInterval?: number; /** Tool to call when polling in fallback mode. */ fallbackTool?: string; /** Arguments passed to the fallback tool call. */ fallbackArgs?: Record; /** Action(s) executed whenever new data arrives (push or poll). */ onData?: Action | Action[]; /** Action(s) executed on subscription or poll error. */ onError?: Action | Action[]; } /** * Subscribe to a resource URI for real-time updates. * * When the host supports MCP resource subscriptions (`capabilities.subscriptions`), * the renderer uses push notifications via the bridge. Otherwise it falls back to * periodic polling using `SetInterval` + `CallTool`. * * @example * ```ts * new Subscribe('chess://game/abc123', { * stateKey: '$game', * fallbackInterval: 2000, * fallbackTool: '_action', * fallbackArgs: { action: 'refresh' }, * onData: new ShowToast('Game updated', { variant: 'info' }), * }) * ``` */ export declare class Subscribe implements Action { readonly uri: string; private readonly opts; constructor(uri: string, opts: SubscribeOpts); toJSON(): ActionJSON; } /** * Unsubscribe from a previously subscribed resource URI. * * Typically used in cleanup or when navigating away from a view. * The renderer also automatically unsubscribes on destroy. */ export declare class Unsubscribe implements Action { readonly uri: string; constructor(uri: string); toJSON(): ActionJSON; } //# sourceMappingURL=subscribe.d.ts.map