rhombus-node-mcp
Version:
MCP server for Rhombus API
34 lines (33 loc) • 1.44 kB
JavaScript
/**
* Keystone correlation helper for the OnGuard feature set.
*
* Given a badge-event-like entry (a camera `deviceUuid` + a `timestampMs`), produce the media hints
* the agent needs to *show* the moment: a still (camera-tool `image`) and a short clip window
* (clips-tool `createClip`). Pure and reusable — the follow-the-badge timeline, anomaly review, and
* lost-badge tracking all turn badge events into "here's the picture/video" the same way.
*
* Kept deliberately small and side-effect-free. Richer correlation (co-located face events,
* people-count in the window) layers on top of this when those features land.
*/
export const DEFAULT_CLIP_PADDING_SECONDS = 15;
/**
* Build still + clip hints for a single badge event. Returns empty hints (no clip/still) when the
* event lacks a camera or timestamp, so callers can render those events without media gracefully.
*/
export function buildMediaHints(event, clipPaddingSeconds = DEFAULT_CLIP_PADDING_SECONDS) {
if (!event.deviceUuid || event.timestampMs == null) {
return {};
}
const padMs = Math.max(0, clipPaddingSeconds) * 1000;
return {
clipHint: {
deviceUuid: event.deviceUuid,
startTimeMs: event.timestampMs - padMs,
endTimeMs: event.timestampMs + padMs,
},
stillHint: {
deviceUuid: event.deviceUuid,
timestampMs: event.timestampMs,
},
};
}