Files

62 lines
2.3 KiB
TypeScript
Raw Permalink Normal View History

/**
* Minimal logger interface for the bridge.
*/
export interface IRustBridgeLogger {
log(level: string, message: string, data?: Record<string, any>): void;
}
/**
* Options for locating a Rust binary.
*/
export interface IBinaryLocatorOptions {
/** Name of the binary (e.g., 'rustproxy') */
binaryName: string;
/** Environment variable to check for explicit binary path (e.g., 'SMARTPROXY_RUST_BINARY') */
envVarName?: string;
/** Prefix for platform-specific npm packages (e.g., '@push.rocks/smartproxy') */
platformPackagePrefix?: string;
/** Additional local paths to search (defaults to ./rust/target/release/<binaryName> and ./rust/target/debug/<binaryName>) */
localPaths?: string[];
/** Whether to search the system PATH (default: true) */
searchSystemPath?: boolean;
/** Explicit binary path override - skips all other search */
binaryPath?: string;
}
/**
* Options for the RustBridge.
*/
export interface IRustBridgeOptions extends IBinaryLocatorOptions {
/** CLI arguments passed to the binary (default: ['--management']) */
cliArgs?: string[];
/** Timeout for individual requests in ms (default: 30000) */
requestTimeoutMs?: number;
/** Timeout for the ready event during spawn in ms (default: 10000) */
readyTimeoutMs?: number;
/** Additional environment variables for the child process */
env?: Record<string, string>;
/** Name of the ready event emitted by the Rust binary (default: 'ready') */
readyEventName?: string;
/** Optional logger instance */
logger?: IRustBridgeLogger;
/** Maximum message size in bytes (default: 50MB). Messages exceeding this are rejected. */
maxPayloadSize?: number;
/** Inactivity timeout for streaming commands in ms (default: same as requestTimeoutMs).
* 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;
}