export function sanitizeToValidChannelName(raw: any): any; /** * Splits a user-typed connection string into root-vs-channel parts. A bare * name (no colon) means a ROOT connection named `input` - `channel` comes * back undefined. "channel:app" means real channel `channel` with connection * name `app` inside it. Split on the FIRST colon only, so an app name may * itself contain colons. An empty channel before the colon (":foo") is left * for the caller to reject via VALID_CHANNEL_NAME, same as any other invalid * channel string - this function does no validation itself. */ export function parseChannelInput(input: any): { channel: any; appLabel: any; }; /** * @param {object} opts * @param {string} opts.appName - Short app-specific identifier, e.g. * "htmlpaint", "bulletino", "mindfoo". Used as: the localStorage key * namespace, this app's default ROOT connection name (unless * opts.defaultChannel or a prompt input overrides it), and (unless a * "channel:app" prompt input overrides it) the connection's * window.__mcpAppName label. * @param {string} [opts.defaultChannel] - The raw connect string used before * any human retargets via handleConnectClick's prompt. Defaults to * opts.appName - i.e. this app becomes its own root connection, addressed * directly by name with no channel needed. Pass a "channel:app-name" * string instead to have this app join a real channel by default. * @param {(state: 'disconnected'|'connecting'|'connected', channel: string, appLabel: string) => void} [opts.onStateChange] * Optional convenience callback, called on every state transition - an * alternative to onConnectionStateChange() below for a caller that just * wants one function rather than subscribing. * @param {string} [opts.serverUrl] - js-bridge-mcp's own origin, e.g. * "http://localhost:9000" for a server started with PORT=9000. Defaults to * "http://localhost:8766". * @param {() => Promise|void} [opts.beforeConnect] * Optional hook run once, before the very first main.js import - for a * host page that layers extra tool providers onto window.__mcpTools ahead * of connecting (e.g. bulletino-1 loading tool-bus.js + folderfoo's * provider). Not re-run on a later channel switch/rename - main.js reads * window.__mcpTools fresh on every import, so whatever this hook set up * the first time is still in place for subsequent connects. */ export function createMcpConnect(opts: { appName: string; defaultChannel?: string | undefined; onStateChange?: ((state: "disconnected" | "connecting" | "connected", channel: string, appLabel: string) => void) | undefined; serverUrl?: string | undefined; beforeConnect?: (() => Promise | void) | undefined; }): { init: () => Promise; handleConnectClick: () => Promise; onConnectionStateChange: (cb: any) => () => boolean; getConnectionState: () => { state: string; channel: any; appLabel: any; }; }; export const VALID_CHANNEL_NAME: RegExp;