Improve Gateway lifecycle management with the following features: - Add exponential backoff reconnection (1s-30s delay, max 10 attempts) - Add health check monitoring every 30 seconds - Add proper restart method with graceful shutdown - Handle server-initiated notifications (channel status, chat messages) - Add 'reconnecting' state for better UI feedback - Enhance IPC handlers with isConnected and health check endpoints - Update preload script with new event channels - Improve type safety and error handling throughout Also fixes several TypeScript errors and unused variable warnings.
59 lines
1.0 KiB
TypeScript
59 lines
1.0 KiB
TypeScript
/**
|
|
* Gateway Type Definitions
|
|
* Types for Gateway communication and data structures
|
|
*/
|
|
|
|
/**
|
|
* Gateway connection status
|
|
*/
|
|
export interface GatewayStatus {
|
|
state: 'stopped' | 'starting' | 'running' | 'error' | 'reconnecting';
|
|
port: number;
|
|
pid?: number;
|
|
uptime?: number;
|
|
error?: string;
|
|
connectedAt?: number;
|
|
version?: string;
|
|
reconnectAttempts?: number;
|
|
}
|
|
|
|
/**
|
|
* Gateway RPC response
|
|
*/
|
|
export interface GatewayRpcResponse<T = unknown> {
|
|
success: boolean;
|
|
result?: T;
|
|
error?: string;
|
|
}
|
|
|
|
/**
|
|
* Gateway health check response
|
|
*/
|
|
export interface GatewayHealth {
|
|
ok: boolean;
|
|
error?: string;
|
|
uptime?: number;
|
|
version?: string;
|
|
}
|
|
|
|
/**
|
|
* Gateway notification (server-initiated event)
|
|
*/
|
|
export interface GatewayNotification {
|
|
method: string;
|
|
params?: unknown;
|
|
}
|
|
|
|
/**
|
|
* Provider configuration
|
|
*/
|
|
export interface ProviderConfig {
|
|
id: string;
|
|
name: string;
|
|
type: 'openai' | 'anthropic' | 'ollama' | 'custom';
|
|
apiKey?: string;
|
|
baseUrl?: string;
|
|
model?: string;
|
|
enabled: boolean;
|
|
}
|