@trillboards/edge-sdk 0.2.209 → 0.2.213
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.
- package/deploy/windows/ci/test-alert-window-field.ps1 +252 -0
- package/deploy/windows/ci/test-published-install.ps1 +6 -2
- package/dist/AlertClips.d.ts +131 -0
- package/dist/AlertClips.d.ts.map +1 -0
- package/dist/AlertClips.js +476 -0
- package/dist/AlertClips.js.map +1 -0
- package/dist/CloudSensingManager.d.ts +27 -0
- package/dist/CloudSensingManager.d.ts.map +1 -1
- package/dist/CloudSensingManager.js +138 -16
- package/dist/CloudSensingManager.js.map +1 -1
- package/dist/ConnectorStatusClient.d.ts +10 -0
- package/dist/ConnectorStatusClient.d.ts.map +1 -1
- package/dist/ConnectorStatusClient.js +11 -1
- package/dist/ConnectorStatusClient.js.map +1 -1
- package/dist/DurableVlmCandidateSpool.d.ts +4 -0
- package/dist/DurableVlmCandidateSpool.d.ts.map +1 -1
- package/dist/DurableVlmCandidateSpool.js +13 -0
- package/dist/DurableVlmCandidateSpool.js.map +1 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/LocalVideoBuffer.d.ts +59 -0
- package/dist/LocalVideoBuffer.d.ts.map +1 -0
- package/dist/LocalVideoBuffer.js +214 -0
- package/dist/LocalVideoBuffer.js.map +1 -0
- package/dist/NativeReadiness.d.ts +9 -1
- package/dist/NativeReadiness.d.ts.map +1 -1
- package/dist/NativeReadiness.js +21 -5
- package/dist/NativeReadiness.js.map +1 -1
- package/dist/SensingProfileClient.d.ts +62 -5
- package/dist/SensingProfileClient.d.ts.map +1 -1
- package/dist/SensingProfileClient.js +76 -1
- package/dist/SensingProfileClient.js.map +1 -1
- package/dist/VideoSegmentUploader.d.ts +169 -5
- package/dist/VideoSegmentUploader.d.ts.map +1 -1
- package/dist/VideoSegmentUploader.js +543 -32
- package/dist/VideoSegmentUploader.js.map +1 -1
- package/dist/autoSense.d.ts.map +1 -1
- package/dist/autoSense.js +4 -0
- package/dist/autoSense.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -0
- package/dist/cli.js.map +1 -1
- package/dist/connectorUpdate.d.ts +22 -0
- package/dist/connectorUpdate.d.ts.map +1 -1
- package/dist/connectorUpdate.js +72 -8
- package/dist/connectorUpdate.js.map +1 -1
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/dist/localSenseE2eHarness.d.ts +1 -1
- package/dist/localSenseE2eHarness.d.ts.map +1 -1
- package/dist/localSenseE2eHarness.js +7 -4
- package/dist/localSenseE2eHarness.js.map +1 -1
- package/dist/localSensing.d.ts +58 -0
- package/dist/localSensing.d.ts.map +1 -1
- package/dist/localSensing.js +126 -16
- package/dist/localSensing.js.map +1 -1
- package/package.json +5 -5
- package/retained/ArchiveLifecycle.cjs +11 -5
- package/retained/RetainedCaptureClient.cjs +206 -49
- package/retained/WebsiteAdmissionCaptureClient.cjs +40 -8
- package/retained/__tests__/evidence-uploads.test.cjs +130 -0
- package/retained/__tests__/realtime-schedule.test.cjs +71 -11
- package/retained/__tests__/upgrade-backlog.test.cjs +239 -0
- package/retained/__tests__/website-admission-realtime.test.cjs +48 -9
- package/retained/manager.cjs +2 -0
- package/retained/website-api-capability.cjs +7 -1
|
@@ -193,6 +193,13 @@ const DEFAULT_CAMERA_HEALTH_HEARTBEAT_INTERVAL_MS = 60000;
|
|
|
193
193
|
// Matches the sensing-profile client's own TTL so the two do not disagree about
|
|
194
194
|
// how stale a profile may be.
|
|
195
195
|
const DEFAULT_CADENCE_REFRESH_MS = 300000;
|
|
196
|
+
/**
|
|
197
|
+
* How often the candidate pump asks EVERY capture archive for work, rather
|
|
198
|
+
* than only those that changed. Catches time-driven transitions (a frame
|
|
199
|
+
* crossing its live-alert bound, a wait/recheck reservation lapsing) that no
|
|
200
|
+
* capture or completion announces.
|
|
201
|
+
*/
|
|
202
|
+
const ORDERED_SWEEP_INTERVAL_MS = 1000;
|
|
196
203
|
/**
|
|
197
204
|
* Node's `setTimeout` delay is a 32-bit SIGNED int. A larger value does not
|
|
198
205
|
* saturate and does not throw — it is coerced to 1 ms and the callback fires on
|
|
@@ -286,6 +293,15 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
286
293
|
this.uploadsInFlight = new Set();
|
|
287
294
|
this.deliveryRetryAtMs = 0;
|
|
288
295
|
this.candidatePumpTimer = null;
|
|
296
|
+
// Feeds whose capture archive changed since the pump last asked it (a capture,
|
|
297
|
+
// a finished or retried review, a refused offer). The pump asks only these;
|
|
298
|
+
// every feed is asked once per ORDERED_SWEEP_INTERVAL_MS for time-driven changes.
|
|
299
|
+
this.orderedDirty = new Set();
|
|
300
|
+
this.orderedSweepAtMs = 0;
|
|
301
|
+
// The one historical (backlog) original in the spool, if any.
|
|
302
|
+
this.backlogOffer = null;
|
|
303
|
+
this.backlogNextFeed = 0;
|
|
304
|
+
this.backlogCapable = null;
|
|
289
305
|
/**
|
|
290
306
|
* What the ARMED gate actually did, connector-wide.
|
|
291
307
|
*
|
|
@@ -351,6 +367,8 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
351
367
|
runMotionSkipped: 0,
|
|
352
368
|
retryDelayMs: null,
|
|
353
369
|
tickInFlight: false,
|
|
370
|
+
readinessWait: null,
|
|
371
|
+
readinessFailedAtMs: null,
|
|
354
372
|
lastCaptureAtMs: null,
|
|
355
373
|
lastHealthReportAtMs: null,
|
|
356
374
|
lastSensingState: null,
|
|
@@ -868,6 +886,8 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
868
886
|
// null for a feed with no audio, and nothing here may delay or fail the
|
|
869
887
|
// capture loops that already started above.
|
|
870
888
|
void this.attachAudioSensing();
|
|
889
|
+
// A new run asks every capture archive on its first pump.
|
|
890
|
+
this.orderedSweepAtMs = 0;
|
|
871
891
|
this.scheduleCandidatePump(generation);
|
|
872
892
|
// Ask once at startup so a connector picks up its deployed cadence on boot
|
|
873
893
|
// rather than after a full refresh period, then keep asking. Both are
|
|
@@ -1099,6 +1119,7 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
1099
1119
|
s.lastCaptureAtMs = null;
|
|
1100
1120
|
s.lastHealthReportAtMs = null;
|
|
1101
1121
|
s.lastSensingState = null;
|
|
1122
|
+
s.readinessFailedAtMs = null;
|
|
1102
1123
|
let needsOpen = !s.deps.camera.isOpen();
|
|
1103
1124
|
const startupDelayMs = this.staggerFor(s);
|
|
1104
1125
|
if (startupDelayMs > 0) {
|
|
@@ -1327,6 +1348,48 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
1327
1348
|
this.scheduleNext(s, generation);
|
|
1328
1349
|
});
|
|
1329
1350
|
}, delayMs);
|
|
1351
|
+
// Review readiness can lapse DURING a tick that already took its snapshot.
|
|
1352
|
+
// That tick re-arms here on the camera-health heartbeat, and nothing brought
|
|
1353
|
+
// it back before the heartbeat: three 60 s look pauses in six minutes on
|
|
1354
|
+
// Windows field run 42420251424. Wait for readiness now, unless a wait is
|
|
1355
|
+
// already running or the last one failed (the heartbeat is then its retry).
|
|
1356
|
+
if (!this.healthOnlyMode && s.reconnectDelayMs == null
|
|
1357
|
+
&& s.readinessWait?.generation !== generation
|
|
1358
|
+
&& (s.readinessFailedAtMs === null
|
|
1359
|
+
|| this.now() - s.readinessFailedAtMs >= this.cameraHealthHeartbeatIntervalMs)
|
|
1360
|
+
&& s.deps.client.isReviewActive?.() === false) {
|
|
1361
|
+
this.resumeWhenReviewReady(s, generation);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* Prepare this feed's review in the background and, once the client reports
|
|
1366
|
+
* active, replace a camera-health heartbeat timer with the active cadence.
|
|
1367
|
+
* A tick in flight re-arms from its own `.finally`, which reads the same
|
|
1368
|
+
* state, so this never arms a second chain.
|
|
1369
|
+
*/
|
|
1370
|
+
resumeWhenReviewReady(s, generation) {
|
|
1371
|
+
const prepared = s.deps.client.prepareReview?.();
|
|
1372
|
+
if (!prepared)
|
|
1373
|
+
return;
|
|
1374
|
+
const wait = { generation };
|
|
1375
|
+
s.readinessWait = wait;
|
|
1376
|
+
const settle = () => { if (s.readinessWait === wait)
|
|
1377
|
+
s.readinessWait = null; };
|
|
1378
|
+
prepared.then(() => {
|
|
1379
|
+
settle();
|
|
1380
|
+
s.readinessFailedAtMs = null;
|
|
1381
|
+
if (!this.isCurrentStart(generation) || s.tickInFlight || s.deps.client.isReviewActive?.() !== true)
|
|
1382
|
+
return;
|
|
1383
|
+
if (s.timer !== null) {
|
|
1384
|
+
clearTimeout(s.timer);
|
|
1385
|
+
s.timer = null;
|
|
1386
|
+
}
|
|
1387
|
+
this.scheduleNext(s, generation);
|
|
1388
|
+
}, (error) => {
|
|
1389
|
+
settle();
|
|
1390
|
+
s.readinessFailedAtMs = this.now();
|
|
1391
|
+
throw error;
|
|
1392
|
+
}).catch((error) => this.emitLoopError(s, error));
|
|
1330
1393
|
}
|
|
1331
1394
|
/**
|
|
1332
1395
|
* One scheduled loop iteration with built-in RTSP self-recovery.
|
|
@@ -1637,18 +1700,9 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
1637
1700
|
// Refresh in the background so saving a profile on the website arms this
|
|
1638
1701
|
// feed without restarting the connector. Saved pending evidence keeps its
|
|
1639
1702
|
// own old contract and is still drained by the independent review pump.
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
return;
|
|
1644
|
-
// Preparation can finish after the health tick armed its longer timer.
|
|
1645
|
-
// Replace that timer with the existing active cadence, never a second chain.
|
|
1646
|
-
if (s.timer !== null) {
|
|
1647
|
-
clearTimeout(s.timer);
|
|
1648
|
-
s.timer = null;
|
|
1649
|
-
}
|
|
1650
|
-
this.scheduleNext(s, generation);
|
|
1651
|
-
}).catch(error => this.emitLoopError(s, error));
|
|
1703
|
+
// Preparation can finish after this health tick armed its longer timer:
|
|
1704
|
+
// the wait then replaces that timer with the active cadence.
|
|
1705
|
+
this.resumeWhenReviewReady(s, this.startGeneration);
|
|
1652
1706
|
return this.captureHealthFrame(s).then(() => null);
|
|
1653
1707
|
}
|
|
1654
1708
|
if (!s.deps.camera.isOpen()) {
|
|
@@ -1754,6 +1808,7 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
1754
1808
|
if (s.deps.client.retainOrderedCapture) {
|
|
1755
1809
|
s.deps.client.retainOrderedCapture(capturedCandidate);
|
|
1756
1810
|
this.emit('orderedEvidenceRetained', { name: s.deps.name, capturedAtMs });
|
|
1811
|
+
this.orderedDirty.add(s.deps.name);
|
|
1757
1812
|
this.pumpCandidates(generation);
|
|
1758
1813
|
return null;
|
|
1759
1814
|
}
|
|
@@ -2229,7 +2284,7 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
2229
2284
|
.then(processed => this.emit('actorPerceptionCompleted', { name: s.deps.name, processed,
|
|
2230
2285
|
elapsedMs: this.now() - startedAtMs, current: this.isCurrentStart(generation) }))
|
|
2231
2286
|
.catch(error => this.emitLoopError(s, error))
|
|
2232
|
-
.finally(() => { this.actorPerceptionBusy = false; });
|
|
2287
|
+
.finally(() => { this.actorPerceptionBusy = false; this.orderedDirty.add(s.deps.name); });
|
|
2233
2288
|
return;
|
|
2234
2289
|
}
|
|
2235
2290
|
catch (error) {
|
|
@@ -2297,16 +2352,29 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
2297
2352
|
if (!buffer)
|
|
2298
2353
|
return;
|
|
2299
2354
|
// Re-offer durable sequence jobs even if the camera is currently offline.
|
|
2300
|
-
// Stable IDs make the capture/archive -> spool boundary idempotent.
|
|
2355
|
+
// Stable IDs make the capture/archive -> spool boundary idempotent. Only
|
|
2356
|
+
// archives that changed are asked, plus all of them once a sweep interval:
|
|
2357
|
+
// asking 32 archives every 50 ms is what turned a large archive into a
|
|
2358
|
+
// starved event loop.
|
|
2359
|
+
const now = this.now();
|
|
2360
|
+
const sweep = now >= this.orderedSweepAtMs;
|
|
2361
|
+
if (sweep)
|
|
2362
|
+
this.orderedSweepAtMs = now + ORDERED_SWEEP_INTERVAL_MS;
|
|
2301
2363
|
for (const s of this.loops) {
|
|
2302
2364
|
if (!s.deps.client.pendingOrderedCandidates)
|
|
2303
2365
|
continue;
|
|
2366
|
+
if (!sweep && !this.orderedDirty.has(s.deps.name))
|
|
2367
|
+
continue;
|
|
2368
|
+
this.orderedDirty.delete(s.deps.name);
|
|
2304
2369
|
try {
|
|
2305
2370
|
if (!(buffer instanceof DurableVlmCandidateSpool_1.DurableVlmCandidateSpool) || !this.continuousReview?.independentUploads)
|
|
2306
2371
|
throw Error('Ordered review requires independent uploads and a durable spool');
|
|
2307
2372
|
for (const candidate of s.deps.client.pendingOrderedCandidates()) {
|
|
2308
|
-
|
|
2373
|
+
// A full spool: ask this archive again on the next pump.
|
|
2374
|
+
if (buffer.offer(candidate) === 'rejected') {
|
|
2375
|
+
this.orderedDirty.add(s.deps.name);
|
|
2309
2376
|
break;
|
|
2377
|
+
}
|
|
2310
2378
|
}
|
|
2311
2379
|
}
|
|
2312
2380
|
catch (error) {
|
|
@@ -2316,6 +2384,8 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
2316
2384
|
// Age out first: a candidate past its TTL must never win a slot from one
|
|
2317
2385
|
// that is still current.
|
|
2318
2386
|
buffer.expire();
|
|
2387
|
+
if (buffer instanceof DurableVlmCandidateSpool_1.DurableVlmCandidateSpool && this.continuousReview?.independentUploads)
|
|
2388
|
+
this.pumpBacklog(buffer);
|
|
2319
2389
|
this.pumpUrgentTriage(generation);
|
|
2320
2390
|
if (this.continuousReview?.independentUploads)
|
|
2321
2391
|
this.pumpDeliveries(generation);
|
|
@@ -2373,6 +2443,7 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
2373
2443
|
void work.finally(() => {
|
|
2374
2444
|
this.reviewsInFlight.delete(work);
|
|
2375
2445
|
this.modelReviewsInFlight.delete(reservation);
|
|
2446
|
+
this.orderedDirty.add(candidate.name);
|
|
2376
2447
|
});
|
|
2377
2448
|
}
|
|
2378
2449
|
}
|
|
@@ -2408,7 +2479,58 @@ class CloudSensingManager extends events_1.EventEmitter {
|
|
|
2408
2479
|
}
|
|
2409
2480
|
const work = this.serveCandidate(s, candidate, null, generation);
|
|
2410
2481
|
this.uploadsInFlight.add(work);
|
|
2411
|
-
void work.finally(() => this.uploadsInFlight.delete(work));
|
|
2482
|
+
void work.finally(() => { this.uploadsInFlight.delete(work); this.orderedDirty.add(candidate.name); });
|
|
2483
|
+
}
|
|
2484
|
+
/**
|
|
2485
|
+
* Historical (backlog) originals: frames already past the live-alert bound
|
|
2486
|
+
* when their archive loaded. One at a time, offered only while the review
|
|
2487
|
+
* lane is idle and no live frame waits; a copy still queued when live work
|
|
2488
|
+
* arrives leaves at once. Its answer is history: the archive gives it no
|
|
2489
|
+
* capture-based deadline and the server's stale_event rule keeps it from
|
|
2490
|
+
* alerting.
|
|
2491
|
+
*/
|
|
2492
|
+
pumpBacklog(buffer) {
|
|
2493
|
+
this.backlogCapable ?? (this.backlogCapable = this.loops.some(loop => typeof loop.deps.client.pendingBacklogCandidate === 'function'));
|
|
2494
|
+
if (!this.backlogCapable)
|
|
2495
|
+
return;
|
|
2496
|
+
const held = this.backlogOffer;
|
|
2497
|
+
const liveWaiting = buffer.peek(undefined, 'review', held ? item => item.spoolId !== held.id : undefined) !== null;
|
|
2498
|
+
if (held) {
|
|
2499
|
+
const where = buffer.holds(held.id);
|
|
2500
|
+
if (where === null)
|
|
2501
|
+
this.backlogOffer = null;
|
|
2502
|
+
else if (where === 'queued' && liveWaiting && buffer.withdraw(held.id) === 'withdrawn') {
|
|
2503
|
+
this.backlogOffer = null;
|
|
2504
|
+
this.orderedDirty.add(held.name);
|
|
2505
|
+
this.emit('backlogWithdrawn', { name: held.name, evidenceId: held.id });
|
|
2506
|
+
}
|
|
2507
|
+
else
|
|
2508
|
+
return;
|
|
2509
|
+
}
|
|
2510
|
+
if (liveWaiting || this.reviewsInFlight.size > 0 || this.admissionGate.getInFlight() > 0)
|
|
2511
|
+
return;
|
|
2512
|
+
for (let offset = 0; offset < this.loops.length; offset++) {
|
|
2513
|
+
const index = (this.backlogNextFeed + offset) % this.loops.length, s = this.loops[index];
|
|
2514
|
+
if (!s.deps.client.pendingBacklogCandidate)
|
|
2515
|
+
continue;
|
|
2516
|
+
let candidate;
|
|
2517
|
+
try {
|
|
2518
|
+
candidate = s.deps.client.pendingBacklogCandidate();
|
|
2519
|
+
}
|
|
2520
|
+
catch (error) {
|
|
2521
|
+
this.emitLoopError(s, error);
|
|
2522
|
+
continue;
|
|
2523
|
+
}
|
|
2524
|
+
if (!candidate?.retainedId)
|
|
2525
|
+
continue;
|
|
2526
|
+
const result = buffer.offer(candidate);
|
|
2527
|
+
if (result === 'buffered' || result === 'coalesced') {
|
|
2528
|
+
this.backlogOffer = { name: s.deps.name, id: candidate.retainedId };
|
|
2529
|
+
this.backlogNextFeed = (index + 1) % this.loops.length;
|
|
2530
|
+
this.emit('backlogOffered', { name: s.deps.name, evidenceId: candidate.retainedId, capturedAtMs: candidate.enqueuedAtMs });
|
|
2531
|
+
}
|
|
2532
|
+
return;
|
|
2533
|
+
}
|
|
2412
2534
|
}
|
|
2413
2535
|
/** Analyze one held candidate and give the slot back. Never throws. */
|
|
2414
2536
|
async serveCandidate(s, candidate, ticket, generation) {
|