(
sessionId: string,
status: SiSession["status"],
terminationReason?: string,
handoffData?: Record<string, unknown>
)
| 218 | } |
| 219 | |
| 220 | async updateSessionStatus( |
| 221 | sessionId: string, |
| 222 | status: SiSession["status"], |
| 223 | terminationReason?: string, |
| 224 | handoffData?: Record<string, unknown> |
| 225 | ): Promise<SiSession | null> { |
| 226 | const result = await query( |
| 227 | `UPDATE si_sessions |
| 228 | SET status = $2, |
| 229 | termination_reason = $3, |
| 230 | handoff_data = $4, |
| 231 | terminated_at = CASE WHEN $2::VARCHAR IN ('complete', 'timeout', 'error') THEN NOW() ELSE NULL END |
| 232 | WHERE session_id = $1 |
| 233 | RETURNING *`, |
| 234 | [ |
| 235 | sessionId, |
| 236 | status, |
| 237 | terminationReason || null, |
| 238 | handoffData ? JSON.stringify(handoffData) : null, |
| 239 | ] |
| 240 | ); |
| 241 | |
| 242 | if (result.rows.length === 0) return null; |
| 243 | return this.deserializeSession(result.rows[0]); |
| 244 | } |
| 245 | |
| 246 | async getActiveSessions(hostIdentifier?: string): Promise<SiSession[]> { |
| 247 | let sql = "SELECT * FROM si_sessions WHERE status = 'active'"; |
no test coverage detected