@trillboards/edge-sdk 0.2.225 → 0.2.227

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.
Files changed (53) hide show
  1. package/deploy/windows/README.md +9 -4
  2. package/deploy/windows/ci/test-rollout-proofs.ps1 +300 -38
  3. package/deploy/windows/install-update.ps1 +5 -2
  4. package/deploy/windows/register-detector-task.ps1 +19 -1
  5. package/dist/AlertClips.d.ts +16 -1
  6. package/dist/AlertClips.d.ts.map +1 -1
  7. package/dist/AlertClips.js +35 -2
  8. package/dist/AlertClips.js.map +1 -1
  9. package/dist/CloudSensingManager.d.ts +33 -0
  10. package/dist/CloudSensingManager.d.ts.map +1 -1
  11. package/dist/CloudSensingManager.js +57 -0
  12. package/dist/CloudSensingManager.js.map +1 -1
  13. package/dist/DurableVlmCandidateSpool.d.ts +17 -0
  14. package/dist/DurableVlmCandidateSpool.d.ts.map +1 -1
  15. package/dist/DurableVlmCandidateSpool.js +46 -0
  16. package/dist/DurableVlmCandidateSpool.js.map +1 -1
  17. package/dist/EdgeAgent.js +1 -1
  18. package/dist/VideoSegmentUploader.d.ts +28 -2
  19. package/dist/VideoSegmentUploader.d.ts.map +1 -1
  20. package/dist/VideoSegmentUploader.js +53 -6
  21. package/dist/VideoSegmentUploader.js.map +1 -1
  22. package/dist/autoSense.d.ts +11 -1
  23. package/dist/autoSense.d.ts.map +1 -1
  24. package/dist/autoSense.js +33 -2
  25. package/dist/autoSense.js.map +1 -1
  26. package/dist/cli.d.ts.map +1 -1
  27. package/dist/cli.js +5 -1
  28. package/dist/cli.js.map +1 -1
  29. package/dist/connectorUpdate.d.ts +189 -38
  30. package/dist/connectorUpdate.d.ts.map +1 -1
  31. package/dist/connectorUpdate.js +337 -48
  32. package/dist/connectorUpdate.js.map +1 -1
  33. package/dist/connectorUpdateApply.d.ts +23 -1
  34. package/dist/connectorUpdateApply.d.ts.map +1 -1
  35. package/dist/connectorUpdateApply.js +72 -1
  36. package/dist/connectorUpdateApply.js.map +1 -1
  37. package/dist/connectorUpdateApplyMac.d.ts +4 -0
  38. package/dist/connectorUpdateApplyMac.d.ts.map +1 -1
  39. package/dist/connectorUpdateApplyMac.js +14 -0
  40. package/dist/connectorUpdateApplyMac.js.map +1 -1
  41. package/dist/diagnose.d.ts +1 -1
  42. package/dist/diagnose.js +1 -1
  43. package/dist/localSensing.d.ts +37 -2
  44. package/dist/localSensing.d.ts.map +1 -1
  45. package/dist/localSensing.js +65 -2
  46. package/dist/localSensing.js.map +1 -1
  47. package/dist/sensingRunMode.d.ts +12 -0
  48. package/dist/sensingRunMode.d.ts.map +1 -1
  49. package/dist/sensingRunMode.js.map +1 -1
  50. package/package.json +3 -3
  51. package/retained/WebsiteAdmissionCaptureClient.cjs +31 -2
  52. package/retained/WebsiteAdmissionState.cjs +1 -1
  53. package/retained/__tests__/website-admission.test.cjs +27 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trillboards/edge-sdk",
3
- "version": "0.2.225",
3
+ "version": "0.2.227",
4
4
  "description": "Composable cross-platform Edge AI SDK for audience sensing on DOOH/CTV devices",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,8 +11,8 @@
11
11
  "scripts": {
12
12
  "build": "tsc",
13
13
  "postbuild": "chmod +x dist/cli.js dist/mcp-server.js",
14
- "test": "jest --passWithNoTests --forceExit && node --test retained/__tests__/runtime.test.cjs retained/__tests__/archive-lifecycle.test.cjs retained/__tests__/actor-perception.test.cjs retained/__tests__/actor-window.test.cjs retained/__tests__/website-admission.test.cjs retained/__tests__/realtime-schedule.test.cjs retained/__tests__/upgrade-backlog.test.cjs retained/__tests__/website-admission-realtime.test.cjs retained/__tests__/evidence-uploads.test.cjs scripts/__tests__/local-sense-wiring-detector.test.cjs",
15
- "test:retained": "node --test retained/__tests__/runtime.test.cjs retained/__tests__/archive-lifecycle.test.cjs retained/__tests__/actor-perception.test.cjs retained/__tests__/actor-window.test.cjs retained/__tests__/website-admission.test.cjs retained/__tests__/realtime-schedule.test.cjs retained/__tests__/upgrade-backlog.test.cjs retained/__tests__/website-admission-realtime.test.cjs retained/__tests__/evidence-uploads.test.cjs scripts/__tests__/local-sense-wiring-detector.test.cjs",
14
+ "test": "jest --passWithNoTests --forceExit && node --test retained/__tests__/runtime.test.cjs retained/__tests__/archive-lifecycle.test.cjs retained/__tests__/actor-perception.test.cjs retained/__tests__/actor-window.test.cjs retained/__tests__/website-admission.test.cjs retained/__tests__/realtime-schedule.test.cjs retained/__tests__/upgrade-backlog.test.cjs retained/__tests__/website-admission-realtime.test.cjs retained/__tests__/evidence-uploads.test.cjs scripts/__tests__/local-sense-wiring-detector.test.cjs scripts/__tests__/alert-safe-point-verdict.test.mjs",
15
+ "test:retained": "node --test retained/__tests__/runtime.test.cjs retained/__tests__/archive-lifecycle.test.cjs retained/__tests__/actor-perception.test.cjs retained/__tests__/actor-window.test.cjs retained/__tests__/website-admission.test.cjs retained/__tests__/realtime-schedule.test.cjs retained/__tests__/upgrade-backlog.test.cjs retained/__tests__/website-admission-realtime.test.cjs retained/__tests__/evidence-uploads.test.cjs scripts/__tests__/local-sense-wiring-detector.test.cjs scripts/__tests__/alert-safe-point-verdict.test.mjs",
16
16
  "clean": "rm -rf dist",
17
17
  "prepublishOnly": "npm run build"
18
18
  },
@@ -4,7 +4,7 @@ const fs = require('node:fs');
4
4
  const crypto = require('node:crypto');
5
5
  const assert = require('node:assert/strict');
6
6
  const { RetainedCaptureClient } = require('./RetainedCaptureClient.cjs');
7
- const { phoneSearchPolicy, admissionContextHash, choosePhoneReview, coversPhoneDecision, recheckAnchorAt } = require('./WebsiteAdmissionState.cjs');
7
+ const { phoneSearchPolicy, admissionContextHash, choosePhoneReview, coversPhoneDecision, recheckAnchorAt, RECHECK_ANCHOR_GRACE_MS } = require('./WebsiteAdmissionState.cjs');
8
8
  const hash = value => crypto.createHash('sha256').update(JSON.stringify(value ?? null)).digest('hex');
9
9
  const imageHash = bytes => crypto.createHash('sha256').update(bytes).digest('hex');
10
10
  function save(file, row) {
@@ -100,6 +100,9 @@ class WebsiteAdmissionCaptureClient extends RetainedCaptureClient {
100
100
  this.pairedCameraId = options.pairedCameraId;
101
101
  this.deferred = new Map();
102
102
  this.states = new Map();
103
+ // Per admission context: when its soonest unconfirmed wait/recheck follow-up
104
+ // falls due (anchor capture + the rule's wait). See nextAlertFollowUpDueAtMs.
105
+ this.followUpDue = new Map();
103
106
  this.admissionMetadata = new Map();
104
107
  this.phoneReceipts = new Map();
105
108
  this.phoneProofChecks = new Map();
@@ -348,7 +351,33 @@ class WebsiteAdmissionCaptureClient extends RetainedCaptureClient {
348
351
  const admission = this.admission(row.candidate.reviewContext, row.capturedAt);
349
352
  if (!admission) return;
350
353
  const key = admissionContextHash(row.candidate.reviewContext);
351
- this.states.set(key, advanceAdmission(admission, row, this.states.get(key)));
354
+ const state = advanceAdmission(admission, row, this.states.get(key));
355
+ this.states.set(key, state);
356
+ let due = null;
357
+ for (const rule of admission.rules) {
358
+ const anchor = state.anchors[rule.routeId];
359
+ if (!anchor || anchor.confirmed) continue;
360
+ const at = anchor.capturedAt + rule.waitMs;
361
+ if (due === null || at < due) due = at;
362
+ }
363
+ if (due === null) this.followUpDue.delete(key); else this.followUpDue.set(key, due);
364
+ }
365
+ /**
366
+ * When this camera's soonest unconfirmed wait/recheck follow-up falls due (capture clock), or null.
367
+ * connectorUpdate's alert_work safe point: a follow-up due while the box restarts waits for the
368
+ * restart. It stays due (in the past) until its look is answered, confirming or clearing the anchor;
369
+ * an anchor older than wait + the server's grace confirms nothing (recheckAnchorAt) and is ignored,
370
+ * and so is a context the archive no longer holds. The anchor itself is rebuilt from the durable
371
+ * archive at startup, so a follow-up due after the restart is not at risk.
372
+ */
373
+ nextAlertFollowUpDueAtMs(nowMs = this.realtime?.now?.() ?? Date.now()) {
374
+ let next = null;
375
+ for (const [key, due] of this.followUpDue) {
376
+ if (!this.states.has(key)) { this.followUpDue.delete(key); continue; }
377
+ if (nowMs > due + RECHECK_ANCHOR_GRACE_MS) continue;
378
+ if (next === null || due < next) next = due;
379
+ }
380
+ return next;
352
381
  }
353
382
  archivePins() {
354
383
  const pins = super.archivePins();
@@ -72,4 +72,4 @@ function coversPhoneDecision(row, decision, contextSha256) {
72
72
  && row.capturedAt >= decision.fromCapturedAtMs && row.capturedAt < decision.untilCapturedAtMs;
73
73
  }
74
74
 
75
- module.exports = { phoneSearchPolicy, admissionContextHash, choosePhoneReview, coversPhoneDecision, recheckAnchorAt };
75
+ module.exports = { phoneSearchPolicy, admissionContextHash, choosePhoneReview, coversPhoneDecision, recheckAnchorAt, RECHECK_ANCHOR_GRACE_MS };
@@ -172,6 +172,33 @@ test('slow inference never adds duration, and a negative follow-up clears the an
172
172
  assert.equal([...f.archive.states.values()][0].anchors['fixture-phone'].capturedAt, 11500);
173
173
  });
174
174
 
175
+ test('a connector update sees the follow-up a wait window owes until its look is answered, across a restart', async t => {
176
+ const f = fixture(t);
177
+ assert.equal(f.archive.nextAlertFollowUpDueAtMs(500), null); // no wait window open
178
+ f.capture(1000); await f.deliver(); // the first sighting anchors a 10-s wait
179
+ assert.equal(f.archive.nextAlertFollowUpDueAtMs(2000), 11000);
180
+ // The anchor is durable: a restarted connector owes the same follow-up.
181
+ assert.equal(f.recover().nextAlertFollowUpDueAtMs(2000), 11000);
182
+ for (let at = 1500; at <= 11000; at += 500) f.capture(at);
183
+ // Due and still unanswered: past due, still owed.
184
+ assert.equal(f.archive.nextAlertFollowUpDueAtMs(11200), 11000);
185
+ const [followUp] = f.archive.pendingOrderedCandidates();
186
+ assert.equal(followUp.reviewPriority, 'urgent');
187
+ await f.deliver(followUp); // positive: the anchor is confirmed, nothing more is owed
188
+ assert.equal(f.archive.nextAlertFollowUpDueAtMs(12000), null);
189
+ });
190
+
191
+ test('a follow-up stops being owed when its look clears the anchor, or when the anchor expires unanswered', async t => {
192
+ const f = fixture(t); f.capture(1000); await f.deliver();
193
+ for (let at = 1500; at <= 11000; at += 500) f.capture(at);
194
+ f.answer(false); await f.deliver(f.archive.pendingOrderedCandidates()[0]);
195
+ assert.equal(f.archive.nextAlertFollowUpDueAtMs(11500), null);
196
+ // An anchor older than wait + the server's 60-s grace confirms nothing (recheckAnchorAt).
197
+ const g = fixture(t); g.capture(1000); await g.deliver();
198
+ assert.equal(g.archive.nextAlertFollowUpDueAtMs(11000 + 60000), 11000);
199
+ assert.equal(g.archive.nextAlertFollowUpDueAtMs(11000 + 60001), null);
200
+ });
201
+
175
202
  test('unknown endpoint retains the anchor and reviews the next frame, not a fabricated negative', async t => {
176
203
  const f = fixture(t); f.capture(1000); await f.deliver(); f.capture(11000); f.capture(11500);
177
204
  f.answer(null); await f.deliver();