| 28 | private keepAliveInterval: NodeJS.Timeout; |
| 29 | |
| 30 | constructor(opts: { |
| 31 | api: ApiClient, |
| 32 | client: ApiSessionClient, |
| 33 | path: string, |
| 34 | logPath: string, |
| 35 | sessionId: string | null, |
| 36 | claudeEnvVars?: Record<string, string>, |
| 37 | claudeArgs?: string[], |
| 38 | mcpServers: Record<string, any>, |
| 39 | messageQueue: MessageQueue2<EnhancedMode>, |
| 40 | onModeChange: (mode: 'local' | 'remote') => void, |
| 41 | allowedTools?: string[], |
| 42 | }) { |
| 43 | this.path = opts.path; |
| 44 | this.api = opts.api; |
| 45 | this.client = opts.client; |
| 46 | this.logPath = opts.logPath; |
| 47 | this.sessionId = opts.sessionId; |
| 48 | this.queue = opts.messageQueue; |
| 49 | this.claudeEnvVars = opts.claudeEnvVars; |
| 50 | this.claudeArgs = opts.claudeArgs; |
| 51 | this.mcpServers = opts.mcpServers; |
| 52 | this.allowedTools = opts.allowedTools; |
| 53 | this._onModeChange = opts.onModeChange; |
| 54 | |
| 55 | // Start keep alive |
| 56 | this.client.keepAlive(this.thinking, this.mode); |
| 57 | this.keepAliveInterval = setInterval(() => { |
| 58 | this.client.keepAlive(this.thinking, this.mode); |
| 59 | }, 2000); |
| 60 | } |
| 61 | |
| 62 | cleanup = (): void => { |
| 63 | clearInterval(this.keepAliveInterval); |