ISPN-3169 Define a Query API that will be common for library mode + remote

Work in progress!