()
| 69 | * 关闭 Socket.IO 服务 |
| 70 | */ |
| 71 | export async function closeSocket(): Promise<void> { |
| 72 | if (io) { |
| 73 | socketGateway?.destroy() |
| 74 | // Kill all active agent session pipelines on shutdown |
| 75 | await getSessionManager().destroyAll() |
| 76 | // Kill all standalone terminals on shutdown |
| 77 | try { |
| 78 | const tm = await getTerminalManager() |
| 79 | tm.destroyAll() |
| 80 | } catch { |
| 81 | // TerminalManager may not have been initialized; safe to ignore |
| 82 | } |
| 83 | await new Promise<void>((resolve) => { |
| 84 | io!.close(() => { |
| 85 | console.log('[Socket.IO] Closed') |
| 86 | resolve() |
| 87 | }) |
| 88 | }) |
| 89 | socketGateway = null |
| 90 | io = null |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // 导出类型和工具 |
| 95 | export * from './events.js' |
no test coverage detected