UNPKG

rhombus-node-mcp

Version:
94 lines (93 loc) 3.16 kB
import { postApi } from "../network/network.js"; export async function searchLicensePlates(query, startTimeMs, endTimeMs, deviceUuids, locationUuids, requestModifiers, sessionId) { const body = { licensePlate: query, startTime: startTimeMs, endTime: endTimeMs, deviceUuids: deviceUuids ?? undefined, locationUuids: locationUuids ?? undefined, }; const res = await postApi({ route: "/search/searchLicensePlates", body, modifiers: requestModifiers, sessionId, }); if (res.error) { throw new Error(JSON.stringify(res)); } return (res.vehicleEvents?.map((event) => ({ licensePlate: event.vehicleLicensePlate ?? undefined, deviceUuid: event.deviceUuid ?? undefined, timestampMs: event.eventTimestamp ?? undefined, confidence: event.confidence ?? undefined, })) ?? []); } export async function searchObjectsByColor(color, cameraUuid, startTimeMs, endTimeMs, requestModifiers, sessionId) { const body = { colorFilter: [color], deviceFilter: [cameraUuid], startTimeMs: startTimeMs, endTimeMs: endTimeMs, }; const res = await postApi({ route: "/search/searchObjectsByColor", body, modifiers: requestModifiers, sessionId, }); if (res.error) { throw new Error(JSON.stringify(res)); } return (res.objects?.map((result) => ({ deviceUuid: result.deviceUuid ?? undefined, timestampMs: result.timestampMs ?? undefined, objectType: result.objectType ?? undefined, color: result.color ?? undefined, })) ?? []); } export async function searchObjectsByText(textQuery, startTimeMs, endTimeMs, deviceUuids, requestModifiers, sessionId) { const body = { searchText: textQuery, model: "CLIP_512", queryStartTimeMs: startTimeMs, queryEndTimeMs: endTimeMs, queryDeviceUuids: deviceUuids ?? [], maxNumResults: 100, similarityThreshold: 0.5, }; const res = await postApi({ route: "/search/searchSimilarObjectEmbeddingsByText", body, modifiers: requestModifiers, sessionId, }); if (res.error) { throw new Error(JSON.stringify(res)); } return (res.similarEmbeddings?.map((match) => ({ deviceUuid: match.embedding?.deviceUuid ?? undefined, timestampMs: match.embedding?.timestamp ?? undefined, score: match.distance ?? undefined, })) ?? []); } export async function searchMotionGrid(cameraUuid, startTimeMs, endTimeMs, requestModifiers, sessionId) { const body = { deviceUuid: cameraUuid, startTimeUtcSecs: Math.floor(startTimeMs / 1000), endTimeUtcSecs: Math.floor(endTimeMs / 1000), searchCells: [], }; const res = await postApi({ route: "/event/searchMotionGrid", body, modifiers: requestModifiers, sessionId, }); if (res.error) { throw new Error(JSON.stringify(res)); } return (res.timeUtcSecsList?.map((ts) => ({ timestampSecs: ts, })) ?? []); }