export async function invokeRPC( rpcName: string, data?: Record ): Promise { const response = await fetch(`/remote/rpc/${encodeURIComponent(rpcName)}`, { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ data }), }) if (!response.ok) { throw new Error((await response.text()) || `RPC ${rpcName} failed`) } if (response.status === 204) { return undefined as TOutput } const text = await response.text() return text ? JSON.parse(text) as TOutput : undefined as TOutput }