/** * Handlers for SSH sessions. * Context: sshManager, debugLog */ function register(deps) { const { sshManager, debugLog } = deps; return [ { type: 'startSshSession', handle: async (payload, reply) => { debugLog('startSshSession: payload=', JSON.stringify({ ...payload, hsUrl: payload.hsUrl ? payload.hsUrl.slice(0, 20) + '...' : null })); const result = await sshManager.startSession(payload); debugLog('startSshSession: result=', JSON.stringify({ ok: result.ok, sessionId: result.sessionId, wsPort: result.wsPort })); reply(result); } }, { type: 'stopSshSession', handle: async (payload, reply) => { debugLog('stopSshSession: payload=', JSON.stringify(payload)); const result = await sshManager.stopSession(payload); debugLog('stopSshSession: result=', JSON.stringify(result)); reply(result); } }, { type: 'resizeSshSession', handle: async (payload, reply) => { sshManager.resizeSession(payload); reply({ ok: true }); } }, { type: 'getSshSessions', handle: async (payload, reply) => reply({ ok: true, sessions: sshManager.getSessions() }) } ]; } module.exports = { register };