import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; export interface Session { id: string; status: 'waiting' | 'active' | 'disconnected'; created_at: string; display_active: boolean; audio_active: boolean; resolution: string | null; metadata: Record; } export interface ApiResponse { ok: boolean; data: T | null; error: string | null; } export interface HealthInfo { status: string; uptime_secs: number; active_sessions: number; connected_agents: number; version: string; } @Injectable({ providedIn: 'root' }) export class ApiService { private baseUrl = '/api'; constructor(private http: HttpClient) {} /** GET /api/health */ getHealth(): Observable> { return this.http.get>(`${this.baseUrl}/health`); } /** GET /api/sessions */ listSessions(): Observable> { return this.http.get>(`${this.baseUrl}/sessions`); } /** POST /api/sessions */ createSession(): Observable> { return this.http.post>(`${this.baseUrl}/sessions`, {}); } /** GET /api/sessions/:id */ getSession(id: string): Observable> { return this.http.get>(`${this.baseUrl}/sessions/${id}`); } /** DELETE /api/sessions/:id */ deleteSession(id: string): Observable> { return this.http.delete>(`${this.baseUrl}/sessions/${id}`); } /** POST /api/sessions/:id/hud — forward a HUD command to the agent. */ sendHudCommand(sessionId: string, command: string, params: Record = {}): Observable> { return this.http.post>(`${this.baseUrl}/sessions/${sessionId}/hud`, { command, params }); } }