@trillboards/edge-sdk 0.2.224 → 0.2.225

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/dist/EdgeAgent.js CHANGED
@@ -44,7 +44,7 @@ const edge_ads_1 = require("@trillboards/edge-ads");
44
44
  const CommandRouter_1 = require("./CommandRouter");
45
45
  const config_1 = require("./config");
46
46
  const dataDir_1 = require("./dataDir");
47
- const SDK_VERSION = '0.2.224';
47
+ const SDK_VERSION = '0.2.225';
48
48
  class EdgeAgent extends events_1.EventEmitter {
49
49
  constructor(config, deps) {
50
50
  super();
@@ -31,7 +31,7 @@ export interface DiagnosticReport {
31
31
  skipped: number;
32
32
  };
33
33
  }
34
- declare const SDK_VERSION = "0.2.224";
34
+ declare const SDK_VERSION = "0.2.225";
35
35
  declare function checkNodeVersion(): CheckResult;
36
36
  declare function checkPlatform(): CheckResult;
37
37
  declare function checkMemory(): CheckResult;
package/dist/diagnose.js CHANGED
@@ -63,7 +63,7 @@ const localNetworkAccess_1 = require("./localNetworkAccess");
63
63
  // ---------------------------------------------------------------------------
64
64
  // SDK version — mirrors package.json; kept in sync by CI
65
65
  // ---------------------------------------------------------------------------
66
- const SDK_VERSION = '0.2.224';
66
+ const SDK_VERSION = '0.2.225';
67
67
  exports._SDK_VERSION = SDK_VERSION;
68
68
  // ---------------------------------------------------------------------------
69
69
  // ANSI helpers (no external deps)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trillboards/edge-sdk",
3
- "version": "0.2.224",
3
+ "version": "0.2.225",
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",
@@ -68,16 +68,35 @@ function advanceAdmission(admission, row, previous) {
68
68
  return { contextSha256, evidenceId: row.id, capturedAt: row.capturedAt, anchors };
69
69
  }
70
70
 
71
+ /** A live look the camera is owed: see liveLookDue. */
72
+ const LIVE_LOOK = Object.freeze({ selected: true, disposition: 'pending_review', selectionReason: 'live_look_interval' });
73
+
71
74
  /** The ordinary website still owns all conditions, timing and delivery.
72
75
  * Originals are archived first; only redundant observations INSIDE every active
73
- * wait window may be omitted from inference. No image is called reviewed unless
74
- * the actual model ran. Realtime scheduling exposes the current selection to
75
- * the shared scheduler; durable admission bookkeeping remains bounded per pump.
76
+ * wait window may be omitted from inference, and never the camera's live look
77
+ * (liveLookIntervalMs). No image is called reviewed unless the actual model ran.
78
+ * Realtime scheduling exposes the current selection to the shared scheduler;
79
+ * durable admission bookkeeping remains bounded per pump.
76
80
  */
77
81
  class WebsiteAdmissionCaptureClient extends RetainedCaptureClient {
78
82
  constructor(client, directory, options) {
79
83
  super(client, directory, options);
80
84
  assert(typeof options.pairedCameraId === 'string' && options.pairedCameraId, 'Paired camera identity required');
85
+ // How often a live alert camera is looked at when nothing in it changed, or while a
86
+ // wait/recheck window omits its changed frames (0 = only the grouping and the website
87
+ // decide). Texas, 2026-11-09: still cameras were looked at only when the frame grouper
88
+ // re-selected — every 5 s (a follow-up, or the reset each 5 s lease renewal causes) or 10 s
89
+ // (its quiet check) — while camera 23, whose drawn area changes on every frame, took the
90
+ // box's other 37% of looks. With a frame always waiting, the spool's least-recently-served
91
+ // rotation gives every camera one look per round. Not part of the archive POLICY: it moves
92
+ // which frames are reviewed, never how an original is captured or kept.
93
+ assert(options.liveLookIntervalMs === undefined || Number.isSafeInteger(options.liveLookIntervalMs)
94
+ && options.liveLookIntervalMs >= this.intervalMs && options.liveLookIntervalMs <= 60000, 'Invalid live look interval');
95
+ this.liveLookIntervalMs = options.liveLookIntervalMs ?? 0;
96
+ // When this camera's newest live look started (its frozen reviewSchedule.startedAtMs), so a
97
+ // restart decides from the same durable facts. See liveLookDue.
98
+ this.liveLookStartedAtMs = null;
99
+ for (const row of this.records.values()) this.noteLiveLookStart(row);
81
100
  this.pairedCameraId = options.pairedCameraId;
82
101
  this.deferred = new Map();
83
102
  this.states = new Map();
@@ -112,7 +131,41 @@ class WebsiteAdmissionCaptureClient extends RetainedCaptureClient {
112
131
  }
113
132
  return null;
114
133
  }
115
- admissionSelection(row) {
134
+ /**
135
+ * A live realtime original is owed a look once it is liveLookIntervalMs past the start of
136
+ * the camera's newest live look (before any look has started, past its newest selection),
137
+ * whatever the grouping or a wait window says. From then until the next look starts, each
138
+ * newer original replaces it (realtime: newest wins), so the look reads a frame at most one
139
+ * capture old. A changed frame still selects at once (grouping); this bounds how long an
140
+ * unchanged camera goes unseen.
141
+ *
142
+ * Why the look's start: when the box is the bound, a camera's turn comes once per round, and
143
+ * the cadence the camera actually gets is the gap between the CAPTURE times of the frames
144
+ * its turns read. Measured on the Texas shape (5 cameras, 700 ms looks, a 3.5 s round):
145
+ * counting from the newest selection put the reviewed frames on the interval's own grid and
146
+ * on the grouper's follow-ups (gaps 3.0-5.0 s, frames up to 1.7 s old); counting from the
147
+ * look's start gives gaps of the round itself, at a fraction of the spool writes that
148
+ * selecting every frame costs, and none on a box with room. The start is the frozen
149
+ * reviewSchedule.startedAtMs, so a restart decides from the same durable facts.
150
+ */
151
+ liveLookDue(row, lastSelectedAt) {
152
+ if (!(this.liveLookIntervalMs > 0) || !this.realtime || row.reviewStage === null || !this.knownRealtime(row)) return false;
153
+ const since = this.liveLookStartedAtMs ?? lastSelectedAt;
154
+ return Number.isSafeInteger(since) && row.capturedAt - since >= this.liveLookIntervalMs;
155
+ }
156
+ /**
157
+ * A live look (latest or follow-up slot, never backlog) that has started: its frozen start
158
+ * time. At load the newest archived start wins; a look starting now always replaces it, so a
159
+ * store-PC clock stepped backwards cannot leave a future start blocking the camera's looks.
160
+ */
161
+ noteLiveLookStart(row, startingNow = false) {
162
+ const schedule = row?.reviewSchedule;
163
+ if (!schedule || !['latest', 'follow_up'].includes(schedule.slot) || !Number.isSafeInteger(schedule.startedAtMs)) return;
164
+ if (startingNow || this.liveLookStartedAtMs === null || schedule.startedAtMs > this.liveLookStartedAtMs) {
165
+ this.liveLookStartedAtMs = schedule.startedAtMs;
166
+ }
167
+ }
168
+ admissionSelection(row, lastSelectedAt = this.previousSelectedRecord?.capturedAt ?? null) {
116
169
  const admission = this.admission(row.candidate.reviewContext, row.capturedAt);
117
170
  const remembered = this.states.get(admissionContextHash(row.candidate.reviewContext));
118
171
  const state = remembered && remembered.capturedAt < row.capturedAt ? remembered : null;
@@ -122,12 +175,20 @@ class WebsiteAdmissionCaptureClient extends RetainedCaptureClient {
122
175
  const waiting = anchors.length > 0 && anchors.every(({ rule, anchor }) =>
123
176
  anchor && !anchor.confirmed && row.capturedAt < anchor.capturedAt + rule.waitMs);
124
177
  const followUp = this.followUpFor(row, anchors);
178
+ const lookDue = this.liveLookDue(row, lastSelectedAt);
125
179
  let choice;
126
- if (waiting) choice = { selected: false, disposition: 'archived_wait_window', selectionReason: 'before_all_website_wait_deadlines' };
180
+ // The server's wait/recheck clock ignores answers inside the window (routeReviewTiming:
181
+ // intermediate answers cannot cancel or clear an episode), so a live look there only keeps
182
+ // the camera watched; the deadline endpoint keeps its own reserved, urgent slot.
183
+ if (waiting) choice = lookDue ? LIVE_LOOK
184
+ : { selected: false, disposition: 'archived_wait_window', selectionReason: 'before_all_website_wait_deadlines' };
127
185
  else if (admission && (!state || expired || followUp)) choice = { selected: true, disposition: 'pending_review',
128
186
  selectionReason: followUp ? 'website_wait_deadline_check' : 'website_initial_or_context_change' };
129
- else choice = super.chooseReview(row.candidate, row.imageSha256,
130
- this.nextDue === null || row.capturedAt >= this.nextDue, row.reviewStage);
187
+ else {
188
+ choice = super.chooseReview(row.candidate, row.imageSha256,
189
+ this.nextDue === null || row.capturedAt >= this.nextDue, row.reviewStage);
190
+ if (lookDue && !choice.selected && choice.disposition === 'archived_grouped_unchanged') choice = LIVE_LOOK;
191
+ }
131
192
  return { choice, anchors, followUp };
132
193
  }
133
194
  commitAdmissionSelection(row, { choice, anchors, followUp }) {
@@ -199,7 +260,18 @@ class WebsiteAdmissionCaptureClient extends RetainedCaptureClient {
199
260
  }
200
261
  const inPrefix = new Set(prefix.map(row => row.id));
201
262
  if (!prefix.length || [...this.entries.keys()].some(id => !inPrefix.has(id))) return null;
202
- const choices = new Map(prefix.map(row => [row.id, this.admissionSelection(row)]));
263
+ // One pass decides several originals before committing any: each selection it makes is
264
+ // the camera's newest by the time the next original is decided, so a live look falls due
265
+ // liveLookIntervalMs after it, not after the last committed selection.
266
+ let lastSelectedAt = this.previousSelectedRecord?.capturedAt ?? null;
267
+ const choices = new Map();
268
+ for (const row of prefix) {
269
+ const selection = this.admissionSelection(row, lastSelectedAt);
270
+ choices.set(row.id, selection);
271
+ if ((row.selected || selection.choice.selected) && (lastSelectedAt === null || row.capturedAt > lastSelectedAt)) {
272
+ lastSelectedAt = row.capturedAt;
273
+ }
274
+ }
203
275
  const eligible = prefix.filter(row => row.selected || choices.get(row.id).choice.selected);
204
276
  const target = eligible.find(row => this.followUpOf(row) || choices.get(row.id).followUp) ?? eligible.at(-1);
205
277
  let writes = 0;
@@ -459,7 +531,12 @@ class WebsiteAdmissionCaptureClient extends RetainedCaptureClient {
459
531
  && imageHash(fs.readFileSync(this.image(first))) === anchor.imageSha256,
460
532
  'Website wait anchor missing or changed; keep evidence pending');
461
533
  }
462
- const prepared = await super.prepare(request);
534
+ // The base freezes reviewSchedule.startedAtMs before its first await, and not at all when
535
+ // it refuses the request, so only a look that actually started moves the live-look clock.
536
+ const live = this.records.get(request.evidenceId), unanswered = !live?.result;
537
+ const preparing = super.prepare(request);
538
+ if (unanswered) this.noteLiveLookStart(this.records.get(request.evidenceId), true);
539
+ const prepared = await preparing;
463
540
  this.remember(this.records.get(request.evidenceId));
464
541
  return prepared;
465
542
  }
@@ -9,6 +9,7 @@ const fs = require('node:fs'), os = require('node:os'), path = require('node:pat
9
9
  const { WebsiteAdmissionCaptureClient, readAdmission } = require('../WebsiteAdmissionCaptureClient.cjs');
10
10
  const { RetainedCaptureClient, RECHECK_ANCHOR_GRACE_MS } = require('../RetainedCaptureClient.cjs');
11
11
  const { DurableVlmCandidateSpool } = require('../../dist/DurableVlmCandidateSpool');
12
+ const { FrameGroupingShadow, groupingScopes } = require('../../dist/FrameGroupingShadow');
12
13
  const admissionApi = require('../../../../../trillboard-api/services/retainedWebsiteReviewAdmission');
13
14
  const timing = require('../../../../../trillboard-api/services/fein/routeReviewTiming');
14
15
  const { isHistoricalReview } = require('../../../../../trillboard-api/services/retainedCctvReviewProtocol');
@@ -48,8 +49,20 @@ function context(name, at, extra = {}) {
48
49
  delete captured.websiteReviewAdmission;
49
50
  return captured;
50
51
  }
51
- function rig(t, names = ['phone'], { freshnessMs = LIVE_BOUND_MS } = {}) {
52
+ // The website manager's grouping for an immediate rule (retained/manager.cjs: every website
53
+ // camera's rule is immediate, so followUpMs is 5000).
54
+ const GROUPING = { mode: 'shadow', separateProfileWork: true, pixelDelta: 12, minChangedPixels: 12,
55
+ quietIntervalMs: 10000, followUpMs: 5000 };
56
+ // The motion-resolution grey frame the grouper compares. A still scene repeats it exactly; a
57
+ // moving one shifts 40 bright pixels on every frame, a visible change each time (Texas camera 23).
58
+ function scene(at, moving) {
59
+ const data = new Uint8Array(32 * 24).fill(90);
60
+ if (moving) for (let i = 0; i < 40; i++) data[(i * 13 + Math.floor(at / 100)) % data.length] = 220;
61
+ return { width: 32, height: 24, data };
62
+ }
63
+ function rig(t, names = ['phone'], { freshnessMs = LIVE_BOUND_MS, grouping = false, liveLookIntervalMs, moving = [] } = {}) {
52
64
  const root = fs.mkdtempSync(path.join(os.tmpdir(), 'website-admission-realtime-'));
65
+ const groupers = new Map();
53
66
  const state = { now: 1000, answer: true, accepted: true, receiptVersion: 1 };
54
67
  const archives = new Map(), clients = new Map(), current = new Map(), server = new Map();
55
68
  const calls = [], uploads = [];
@@ -89,6 +102,8 @@ function rig(t, names = ['phone'], { freshnessMs = LIVE_BOUND_MS } = {}) {
89
102
  cameraId: name, pairedCameraId: 'paired-' + name, intervalMs: 500, offerWindow: 16,
90
103
  maxCaptures: 1000, maxBytes: 128 * 1024 ** 2, archiveRetentionMs: 600000,
91
104
  realtimeReview: { freshnessMs, now: () => state.now }, admissionNowMs: () => state.now,
105
+ ...(grouping ? { selectionMode: 'state-change-v1', groupingPolicy: GROUPING } : {}),
106
+ ...(liveLookIntervalMs === undefined ? {} : { liveLookIntervalMs }),
92
107
  });
93
108
  archive.attachReviewQueue(spool); archives.set(name, archive); return archive;
94
109
  }
@@ -100,9 +115,17 @@ function rig(t, names = ['phone'], { freshnessMs = LIVE_BOUND_MS } = {}) {
100
115
  function capture(name, at, extra = {}) {
101
116
  state.now = at;
102
117
  const captured = context(name, at, extra); current.set(name, captured);
103
- const archive = archives.get(name);
104
- archive.retainOrderedCapture({ name, enqueuedAtMs: at, jpeg: original(), captureMode: 'periodic',
105
- reason: 'motion', signature: String(at), reviewKind: 'event', reviewContext: captured });
118
+ const archive = archives.get(name), jpeg = original();
119
+ // With grouping on, the real grouper decides from the scene, exactly as CloudSensingManager feeds it.
120
+ let groupingShadow;
121
+ if (grouping) {
122
+ if (!groupers.has(name)) groupers.set(name, new FrameGroupingShadow(GROUPING));
123
+ groupingShadow = groupers.get(name).observe(scene(at, moving.includes(name)), groupingScopes(captured),
124
+ captured, at, sha(jpeg));
125
+ }
126
+ archive.retainOrderedCapture({ name, enqueuedAtMs: at, jpeg, captureMode: 'periodic',
127
+ reason: 'motion', signature: String(at), reviewKind: 'event', reviewContext: captured,
128
+ ...(groupingShadow ? { groupingShadow } : {}) });
106
129
  return archive.previousCaptureRecord;
107
130
  }
108
131
  function pump() {
@@ -302,6 +325,107 @@ test('three website cameras rotate fairly while one producer accumulates changed
302
325
  assert.deepEqual(served.slice(turn, turn + 3).sort(), ['door', 'lot', 'paint']);
303
326
  });
304
327
 
328
+ // A still camera, decided by the real grouper: without a live-look interval it is looked at
329
+ // only when the grouper re-selects (its first view, the 5 s follow-up, then the 10 s quiet
330
+ // check), the cadence the Texas store's still cameras showed on 2026-11-09.
331
+ test('a still website camera is looked at every live-look interval, not only when the grouper re-selects', async t => {
332
+ const runs = new Map();
333
+ for (const liveLookIntervalMs of [undefined, 2000]) {
334
+ const r = rig(t, ['person'], { grouping: true, liveLookIntervalMs }); r.state.answer = false;
335
+ const looked = [];
336
+ for (let at = 1000; at <= 12000; at += 500) {
337
+ r.capture('person', at, { websiteReviewAdmission: undefined });
338
+ if (r.pump().length) { const item = await r.review(); await r.upload(); looked.push(item.enqueuedAtMs); }
339
+ }
340
+ runs.set(liveLookIntervalMs, { r, looked });
341
+ }
342
+ assert.deepEqual(runs.get(undefined).looked, [1000, 6000]);
343
+ const { r, looked } = runs.get(2000);
344
+ assert.deepEqual(looked, [1000, 3000, 5000, 6000, 8000, 10000, 12000]);
345
+ const reasons = looked.map(at => [...r.archives.get('person').records.values()].find(row => row.capturedAt === at).selectionReason);
346
+ assert.deepEqual(reasons, ['group_selected', 'live_look_interval', 'live_look_interval', 'group_selected',
347
+ 'live_look_interval', 'live_look_interval', 'live_look_interval']);
348
+ const skipped = [...r.archives.get('person').records.values()].filter(row => !looked.includes(row.capturedAt));
349
+ assert(skipped.length && skipped.every(row => row.disposition === 'archived_grouped_unchanged'),
350
+ 'Between live looks an unchanged frame stays a saved, unreviewed grouped view');
351
+ });
352
+
353
+ test('a website wait window keeps the camera\'s live look; the server still confirms only at the deadline', async t => {
354
+ const r = rig(t, ['phone'], { liveLookIntervalMs: 2000 });
355
+ const first = r.capture('phone', 1000); await r.serve(); // true: the ten-second wait starts at 1000
356
+ const looked = [], eligible = [];
357
+ for (let at = 1500; at < 11000; at += 500) {
358
+ r.capture('phone', at);
359
+ if (r.pump().length) {
360
+ const item = await r.review(), delivered = await r.upload();
361
+ looked.push(item.enqueuedAtMs); eligible.push(delivered.decision.eligible);
362
+ }
363
+ }
364
+ assert.deepEqual(looked, [3000, 5000, 7000, 9000]);
365
+ assert.deepEqual(eligible, [false, false, false, false], 'A positive inside the window confirms nothing');
366
+ const omitted = [...r.archives.get('phone').records.values()].filter(row => row.capturedAt > 1000 && !looked.includes(row.capturedAt));
367
+ assert(omitted.length && omitted.every(row => row.disposition === 'archived_wait_window'));
368
+ const due = r.capture('phone', 11000); r.pump();
369
+ const item = r.spool.take(undefined, 'review');
370
+ assert.equal(item.spoolId, due.id);
371
+ assert.equal(item.reviewPriority, 'urgent', 'The deadline endpoint keeps its reserved, urgent slot');
372
+ await r.review(item); const delivered = await r.upload();
373
+ assert.equal(delivered.decision.eligible, true);
374
+ assert.equal(delivered.decision.confirmationBasis, 'first_and_follow_up');
375
+ assert.equal(delivered.decision.state.anchorCapturedAtMs, first.capturedAt);
376
+ });
377
+
378
+ // The Texas store PC at night, 2026-11-09: five alert cameras, camera 23's drawn area changing on
379
+ // every frame and the other four still, on a box that finishes ~1.46 looks a second. Served one at
380
+ // a time here, 700 ms each on the 100 ms clock: the same throughput.
381
+ async function texasNight(t, liveLookIntervalMs) {
382
+ const names = ['c20', 'c22', 'c23', 'c24', 'c3'], LOOK_MS = 700;
383
+ const r = rig(t, names, { grouping: true, liveLookIntervalMs, moving: ['c23'] }); r.state.answer = false;
384
+ const looks = [];
385
+ let busyUntil = 0;
386
+ for (let at = 1000; at <= 61000; at += 100) {
387
+ // Each camera captures every 500 ms, 100 ms after the previous one (the manager's feed stagger).
388
+ r.capture(names[(at / 100) % names.length], at, { websiteReviewAdmission: undefined });
389
+ r.pump();
390
+ if (at < busyUntil) continue;
391
+ const item = r.spool.take(at, 'review');
392
+ if (!item) continue;
393
+ await r.review(item); await r.upload();
394
+ looks.push({ name: item.name, capturedAt: item.enqueuedAtMs, startedAt: at });
395
+ busyUntil = at + LOOK_MS;
396
+ }
397
+ const pct = (values, q) => { const v = [...values].sort((a, b) => a - b); return v[Math.min(v.length - 1, Math.floor(q * v.length))]; };
398
+ const cameras = {};
399
+ for (const name of names) {
400
+ const mine = looks.filter(look => look.name === name);
401
+ const gaps = mine.slice(1).map((look, i) => look.capturedAt - mine[i].capturedAt);
402
+ cameras[name] = { looks: mine.length, share: mine.length / looks.length, gapP50: pct(gaps, 0.5), gapP90: pct(gaps, 0.9),
403
+ gapMax: Math.max(...gaps), ageMax: Math.max(...mine.map(look => look.startedAt - look.capturedAt)) };
404
+ }
405
+ return { looks, cameras };
406
+ }
407
+
408
+ test('Texas shape: the still cameras starve beside the changing one without a live-look interval', async t => {
409
+ const { cameras } = await texasNight(t, undefined);
410
+ t.diagnostic(JSON.stringify(cameras));
411
+ assert(cameras.c23.share > 0.5, 'camera 23 took ' + cameras.c23.share);
412
+ for (const name of ['c20', 'c22', 'c24', 'c3']) assert(cameras[name].gapP90 >= 9500, name + ' ' + JSON.stringify(cameras[name]));
413
+ });
414
+
415
+ test('Texas shape: with the live-look interval every camera gets one look per round, none above its share', async t => {
416
+ const { looks, cameras } = await texasNight(t, 2000);
417
+ t.diagnostic(JSON.stringify(cameras));
418
+ const share = looks.length / 5;
419
+ for (const [name, camera] of Object.entries(cameras)) {
420
+ const detail = name + ' ' + JSON.stringify(camera);
421
+ assert(Math.abs(camera.looks - share) <= 1.5, 'not one look per round: ' + detail);
422
+ // Five cameras x 700 ms: a round is 3.5 s.
423
+ assert(camera.gapP50 <= 4000 && camera.gapP90 <= 4000 && camera.gapMax <= 5000, detail);
424
+ // A still camera's waiting frame is never older than the interval plus one capture.
425
+ assert(camera.ageMax <= 2500, 'stale frame served: ' + detail);
426
+ }
427
+ });
428
+
305
429
  const exemptions = {
306
430
  temporalReviewContract: { version: 1, cameraId: 'phone', field: 'phone_use', mode: 'any', minObservations: 1,
307
431
  durationMs: 0, maxGapMs: 2000, unknownPolicy: 'reset_confirmation_keep_alert_latch' },
@@ -28,6 +28,16 @@ function assertSelectedModelsPrepared(models, actorPolicy, requiresDetector) {
28
28
  // artifact identity still pass before capture; this is not a second installer.
29
29
  /** LocalDetectorClient's own per-call default, which every other detector call of a look waits. */
30
30
  const PAIRED_DETECTOR_CALL_MS = 5000;
31
+ /**
32
+ * A website alert camera's newest frame is reviewed once it is this far past both the camera's
33
+ * newest selection and the start of its newest look, changed or not
34
+ * (WebsiteAdmissionCaptureClient.liveLookDue). Half the 4 s look target: when the box is the
35
+ * bound, every camera has a fresh frame waiting before its turn comes, so the spool's
36
+ * least-recently-served rotation splits the box evenly (Texas: five cameras, ~1.46 looks/s with
37
+ * two in flight, one look per camera every ~3.4 s, each of a frame ~1.4 s old); on a box with
38
+ * room a still camera is looked at every 2-2.5 s. A changed frame still selects at once.
39
+ */
40
+ const LIVE_LOOK_INTERVAL_MS = 2000;
31
41
 
32
42
  async function createWebsiteManager(input, stateDirectory, deps = {}) {
33
43
  const config = JSON.parse(JSON.stringify(input));
@@ -171,6 +181,7 @@ async function createWebsiteManager(input, stateDirectory, deps = {}) {
171
181
  offerWindow: rule.mode === 'wait_recheck' ? 1 : 16, unclearRetryMs: 2000,
172
182
  // Latest frame wins per camera; capture-order contracts keep their window.
173
183
  realtimeReview: { freshnessMs },
184
+ ...(websiteManaged ? { liveLookIntervalMs: LIVE_LOOK_INTERVAL_MS } : {}),
174
185
  ...(rule.mode==='immediate'?{actorPerceiver:new SelectedActorPerceptionClient(binding)}:{}),
175
186
  });
176
187
  loop.client = client; clients.push(client);