@elementor/angie-sdk
Version:
TypeScript SDK for Angie AI assistant
52 lines (51 loc) • 1.99 kB
TypeScript
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
import { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
/**
* Transport implementation that uses the browser's MessageChannel API for communication
* between different browser contexts (iframes, workers, tabs, windows, etc.).
*/
export declare class BrowserContextTransport implements Transport {
sessionId: string;
onmessage?: (message: JSONRPCMessage) => void;
onerror?: (error: Error) => void;
onclose?: () => void;
private _port;
private _started;
private _closed;
/**
* Creates a new BrowserContextTransport using an existing MessagePort.
*
* @param { MessagePort } port The MessagePort to use for communication.
* @param { string } sessionId Optional session ID. If not provided, one will be generated.
*/
constructor(port: MessagePort, sessionId?: string);
/**
* Internal method to generate a session ID.
* This is separated so it can be used by static methods.
*/
private static generateSessionId;
/**
* Starts processing messages on the transport.
* This starts the underlying MessagePort if it hasn't been started yet.
*
* @throws Error if the transport is already started or has been closed.
*/
start(): Promise<void>;
/**
* Sends a JSON-RPC message over the MessagePort.
*
* @param { JSONRPCMessage } message The JSON-RPC message to send.
* @throws Error if the transport is closed or the message cannot be sent.
*/
send(message: JSONRPCMessage): Promise<void>;
/**
* Closes the MessagePort and marks the transport as closed.
* This method will call onclose if it's defined.
*/
close(): Promise<void>;
/**
* Generates a simple unique identifier using timestamp and random values.
* This is not a true UUID but is sufficient for session identification.
*/
private generateId;
}