import { apiFetch } from '@/lib/api' import type { BindPayload } from '@/lib/types' import { pbCreateLiveSession } from '@/lib/pocketbase' export async function reportLiveControlEvent( bind: BindPayload | null, pbToken: string | null, userId: string | undefined, process: string, event: 'start' | 'restart' | 'stop', ): Promise { if (!bind || !pbToken?.trim() || !userId) return let machine: Record = {} try { const r = await apiFetch(bind, '/host/machine_summary', { pbToken: pbToken.trim() }) if (r.ok) machine = (await r.json()) as Record } catch { /* 忽略 */ } await pbCreateLiveSession(pbToken.trim(), userId, { process, event, machine }) }