Skip to content

@himorishige/hatago-transport

Transport layer implementations: STDIO, HTTP/SSE, WebSocket.

Terminal window
npm install @himorishige/hatago-transport
import { createStdioTransport } from '@himorishige/hatago-transport';
const t = await createStdioTransport({ command: 'node', args: ['./server.js'] });
await t.connect();
import { createHttpTransport } from '@himorishige/hatago-transport';
const t = createHttpTransport({ url: 'http://localhost:3535', sessionId: 'abc' });
await t.connect();
import { createWebSocketTransport } from '@himorishige/hatago-transport';
const t = createWebSocketTransport({ url: 'ws://localhost:3535', reconnect: true });
await t.connect();
interface Transport {
connect(): Promise<void>;
disconnect(): Promise<void>;
send(message: any): Promise<void>;
onMessage(fn: (m: any) => void): void;
onError(fn: (e: Error) => void): void;
onClose(fn: () => void): void;
}

MIT