feat(transport): introduce transport abstraction and socket-mode support for RustBridge
This commit is contained in:
@@ -45,3 +45,17 @@ export interface IRustBridgeOptions extends IBinaryLocatorOptions {
|
||||
* Resets on each chunk received. */
|
||||
streamTimeoutMs?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for connecting to an already-running daemon via Unix socket or named pipe.
|
||||
*/
|
||||
export interface ISocketConnectOptions {
|
||||
/** Enable auto-reconnect on unexpected disconnect (default: false) */
|
||||
autoReconnect?: boolean;
|
||||
/** Initial delay between reconnect attempts in ms (default: 100) */
|
||||
reconnectBaseDelayMs?: number;
|
||||
/** Maximum delay between reconnect attempts in ms (default: 30000) */
|
||||
reconnectMaxDelayMs?: number;
|
||||
/** Maximum number of reconnect attempts before giving up (default: 10) */
|
||||
maxReconnectAttempts?: number;
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './ipc.js';
|
||||
export * from './config.js';
|
||||
export * from './transport.js';
|
||||
|
||||
26
ts/interfaces/transport.ts
Normal file
26
ts/interfaces/transport.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type * as plugins from '../plugins.js';
|
||||
|
||||
/**
|
||||
* Abstract transport for communicating with a Rust process.
|
||||
* Both stdio and socket transports implement this interface.
|
||||
*
|
||||
* Events emitted:
|
||||
* - 'line' (line: string) — a complete newline-terminated JSON line received
|
||||
* - 'error' (err: Error) — transport-level error
|
||||
* - 'close' (...args: any[]) — transport has closed/disconnected
|
||||
* - 'stderr' (line: string) — stderr output (stdio transport only)
|
||||
* - 'reconnected' () — transport reconnected after unexpected disconnect (socket only)
|
||||
*/
|
||||
export interface IRustTransport extends plugins.events.EventEmitter {
|
||||
/** Connect the transport (spawn process or connect to socket). Resolves when I/O channel is open. */
|
||||
connect(): Promise<void>;
|
||||
|
||||
/** Write a string to the transport. Handles backpressure. */
|
||||
write(data: string): Promise<void>;
|
||||
|
||||
/** Disconnect the transport. For stdio: kills the process. For socket: closes the connection. */
|
||||
disconnect(): void;
|
||||
|
||||
/** Whether the transport is currently connected and writable. */
|
||||
readonly connected: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user