@blueharford/scrypted-spatial-awareness 0.4.7 → 0.4.8-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -214,26 +214,53 @@ export function generateAlertMessage(
214
214
 
215
215
  switch (type) {
216
216
  case 'property_entry':
217
- return `${objectDesc} arrived at ${details.cameraName || 'property'}`;
217
+ // Use the rich description from spatial reasoning if available
218
+ if (details.objectLabel && details.objectLabel !== details.objectClass) {
219
+ return details.objectLabel;
220
+ }
221
+ // Fallback to basic description
222
+ if (details.involvedLandmarks && details.involvedLandmarks.length > 0) {
223
+ return `${objectDesc} entered property near ${details.involvedLandmarks[0]}`;
224
+ }
225
+ return `${objectDesc} entered property at ${details.cameraName || 'entrance'}`;
218
226
  case 'property_exit':
219
- return `${objectDesc} left from ${details.cameraName || 'property'}`;
227
+ // Use the rich description from spatial reasoning if available
228
+ if (details.objectLabel && details.objectLabel !== details.objectClass) {
229
+ return details.objectLabel;
230
+ }
231
+ // Fallback to basic description
232
+ if (details.involvedLandmarks && details.involvedLandmarks.length > 0) {
233
+ return `${objectDesc} left property via ${details.involvedLandmarks[0]}`;
234
+ }
235
+ return `${objectDesc} left property`;
220
236
  case 'movement':
221
- // If we have a rich description from LLM/RAG, use it
222
- if (details.objectLabel && details.usedLlm) {
237
+ // If objectLabel contains a full description, use it directly
238
+ if (details.objectLabel && details.objectLabel !== details.objectClass) {
239
+ // Check if this is a cross-camera movement or initial detection
240
+ if (details.fromCameraId && details.fromCameraId !== details.toCameraId && details.transitTime) {
241
+ const transitSecs = Math.round(details.transitTime / 1000);
242
+ const transitStr = transitSecs > 0 ? ` (${transitSecs}s)` : '';
243
+ const pathContext = details.pathDescription ? ` via ${details.pathDescription}` : '';
244
+ return `${details.objectLabel}${pathContext}${transitStr}`;
245
+ }
246
+ // Initial detection - use the label directly
247
+ return details.objectLabel;
248
+ }
249
+ // Cross-camera movement with basic info
250
+ if (details.fromCameraId && details.fromCameraId !== details.toCameraId) {
223
251
  const transitSecs = details.transitTime ? Math.round(details.transitTime / 1000) : 0;
224
- const transitStr = transitSecs > 0 ? ` (${transitSecs}s)` : '';
225
- // Include path/landmark context if available
226
- const pathContext = details.pathDescription ? ` via ${details.pathDescription}` : '';
227
- return `${details.objectLabel}${pathContext}${transitStr}`;
252
+ const transitStr = transitSecs > 0 ? ` (${transitSecs}s transit)` : '';
253
+ let movementDesc = `${objectDesc} moving from ${details.fromCameraName || 'unknown'} towards ${details.toCameraName || 'unknown'}`;
254
+ if (details.involvedLandmarks && details.involvedLandmarks.length > 0) {
255
+ movementDesc += ` near ${details.involvedLandmarks.join(', ')}`;
256
+ }
257
+ return `${movementDesc}${transitStr}`;
228
258
  }
229
- // Fallback to basic message with landmark info
230
- const transitSecs = details.transitTime ? Math.round(details.transitTime / 1000) : 0;
231
- const transitStr = transitSecs > 0 ? ` (${transitSecs}s transit)` : '';
232
- let movementDesc = `${objectDesc} moving from ${details.fromCameraName || 'unknown'} towards ${details.toCameraName || 'unknown'}`;
259
+ // Initial detection without full label
233
260
  if (details.involvedLandmarks && details.involvedLandmarks.length > 0) {
234
- movementDesc += ` near ${details.involvedLandmarks.join(', ')}`;
261
+ return `${objectDesc} detected near ${details.involvedLandmarks[0]}`;
235
262
  }
236
- return `${movementDesc}${transitStr}`;
263
+ return `${objectDesc} detected at ${details.cameraName || 'camera'}`;
237
264
  case 'unusual_path':
238
265
  return `${objectDesc} took unusual path: ${details.actualPath || 'unknown'}`;
239
266
  case 'dwell_time':