@trillboards/edge-sdk 0.2.74 → 0.2.76

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 (47) hide show
  1. package/deploy/detector/README.md +133 -0
  2. package/deploy/detector/bench/verify_against_reference.py +120 -0
  3. package/deploy/detector/pyproject.toml +49 -0
  4. package/deploy/detector/tests/__init__.py +0 -0
  5. package/deploy/detector/tests/test_modelpath.py +108 -0
  6. package/deploy/detector/tests/test_server.py +577 -0
  7. package/deploy/detector/tests/test_session.py +242 -0
  8. package/deploy/detector/trillboards_detector/__init__.py +8 -0
  9. package/deploy/detector/trillboards_detector/__main__.py +4 -0
  10. package/deploy/detector/trillboards_detector/cli.py +141 -0
  11. package/deploy/detector/trillboards_detector/errors.py +16 -0
  12. package/deploy/detector/trillboards_detector/labels.py +107 -0
  13. package/deploy/detector/trillboards_detector/loader.py +257 -0
  14. package/deploy/detector/trillboards_detector/modelpath.py +74 -0
  15. package/deploy/detector/trillboards_detector/server.py +460 -0
  16. package/deploy/detector/trillboards_detector/session.py +354 -0
  17. package/deploy/macos/build-macos-pkg.sh +48 -0
  18. package/deploy/macos/com.trillboards.detector.plist +61 -0
  19. package/deploy/macos/scripts/ensure-detector.sh +85 -0
  20. package/deploy/macos/scripts/postinstall +28 -0
  21. package/deploy/macos/scripts/setup-detector.sh +185 -0
  22. package/deploy/systemd/install.sh +35 -0
  23. package/deploy/systemd/setup-detector.sh +130 -0
  24. package/deploy/systemd/trillboards-detector.service +54 -0
  25. package/deploy/windows/build-windows.ps1 +38 -0
  26. package/deploy/windows/installer.nsi +24 -1
  27. package/deploy/windows/register-detector-task.ps1 +161 -0
  28. package/deploy/windows/register-task.ps1 +27 -0
  29. package/deploy/windows/setup-detector.ps1 +176 -0
  30. package/deploy/windows/stop-existing.ps1 +1 -0
  31. package/deploy/windows/trillboards-edge.cmd +25 -0
  32. package/dist/EdgeAgent.js +1 -1
  33. package/dist/LocalDetectorClient.d.ts +92 -0
  34. package/dist/LocalDetectorClient.d.ts.map +1 -0
  35. package/dist/LocalDetectorClient.js +241 -0
  36. package/dist/LocalDetectorClient.js.map +1 -0
  37. package/dist/diagnose.d.ts +1 -1
  38. package/dist/diagnose.js +1 -1
  39. package/dist/index.d.ts +4 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +17 -1
  42. package/dist/index.js.map +1 -1
  43. package/dist/zoneContainment.d.ts +148 -0
  44. package/dist/zoneContainment.d.ts.map +1 -0
  45. package/dist/zoneContainment.js +172 -0
  46. package/dist/zoneContainment.js.map +1 -0
  47. package/package.json +1 -1
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultDetectorPoster = exports.LocalDetectorClient = exports.DetectorUnavailableError = exports.DEFAULT_DETECTOR_PORT = void 0;
4
+ /**
5
+ * LocalDetectorClient — the Node side of the on-device object detector.
6
+ *
7
+ * ── WHY A SECOND LOOPBACK SERVICE, AND NOT A NODE MODULE ───────────────────
8
+ *
9
+ * The detector is RF-DETR Medium as fp32 ONNX. Three constraints decide where it
10
+ * runs, and none of them is negotiable:
11
+ *
12
+ * 1. `onnxruntime-node` is EXCLUDED BY NAME from both installers
13
+ * (`build-windows.ps1` `$xd`, `build-macos-pkg.sh`'s rsync `--exclude`) to
14
+ * keep the package ~50 MB instead of ~270 MB. Putting the runtime in the Node
15
+ * payload reverses a deliberate packaging decision.
16
+ * 2. The connector ALREADY installs and manages a uv/CPython environment, and
17
+ * `uv tool install` gives ONE ISOLATED VENV PER TOOL NAME
18
+ * (`<uv tool dir>/<name>/`). A second tool is namespace-isolated by
19
+ * construction. Adding a package INTO litert-lm's venv is not: three
20
+ * `setup-litertlm` scripts document, in triplicate, that
21
+ * `uv tool install --force` rebuilds that venv from scratch on any version
22
+ * drift or health failure, which is why the existing shim must be re-copied
23
+ * unconditionally on every run.
24
+ * 3. A second always-on loopback service is already a solved problem here — a
25
+ * launchd LaunchAgent, a systemd unit and a Windows Scheduled Task each
26
+ * supervise `litert-lm serve` today, with auto-restart, and Node never spawns
27
+ * it. This client is deliberately the same shape as `LiteRtVlmProvider`: an
28
+ * HTTP client over 127.0.0.1 with an injectable transport, no child process.
29
+ *
30
+ * So: its own `uv tool`, its own OS-supervised service, HTTP over loopback.
31
+ *
32
+ * ── WHY THE MODEL IS OTA'd AND NOT BUNDLED ─────────────────────────────────
33
+ *
34
+ * The macOS code-only build is hard-capped at `MAX_SLIM_PKG_BYTES` = 250 MiB and
35
+ * the code slice is already ~207 MB. A 124 MB ONNX does not fit and the build
36
+ * would `die`. `edge-core`'s `ModelManager` is model-agnostic (its own header:
37
+ * "adapted for Node.js/ONNX") and already runs two models on one instance, so
38
+ * the artifact arrives the same way Gemma's does.
39
+ *
40
+ * ── WHAT THIS FILE DOES NOT DO ─────────────────────────────────────────────
41
+ *
42
+ * It does not start the service, register it with an OS supervisor, install the
43
+ * uv tool, or fetch the model. Those are packaging changes in `deploy/`, and are
44
+ * deliberately a separate change from the wire contract. Nothing calls this yet;
45
+ * it advertises nothing to a device or an operator, which is the distinction that
46
+ * matters — `yolov8_nano` was OFFERED to profile authors for six months while the
47
+ * device hardcoded it unloadable, and that is the failure this ordering avoids.
48
+ *
49
+ * @reuse-audit
50
+ * considered: LiteRtVlmProvider (this package)
51
+ * - reused: its whole shape — loopback HTTP, an injectable `HttpJsonPoster`
52
+ * so tests need no server, health via a cheap GET, and a transport failure
53
+ * kept distinct from a bad answer. Deliberately NOT subclassed: that class
54
+ * carries chat-completions concerns (accelerator suffixes, enum repair,
55
+ * schema-as-prose) that a detector has none of, and inheriting them would
56
+ * drag the `,gpu` demotion machinery into a component with no delegates.
57
+ * considered: edge-sensing/src/processors/FaceDetector.ts
58
+ * - rejected as a base: it is in-process `onnxruntime-node`, which is exactly
59
+ * the dependency the installers exclude. Its NMS and centroid tracker are
60
+ * still the ones to reuse when tracking lands — they are model-agnostic and
61
+ * already written; do not write a fourth tracker.
62
+ */
63
+ const http_1 = require("http");
64
+ /** Where the detector service listens. Distinct port from litert-lm's 9379. */
65
+ exports.DEFAULT_DETECTOR_PORT = 9380;
66
+ const BOX_KEYS = ['x', 'y', 'width', 'height'];
67
+ /**
68
+ * A REAL number, never a coercion.
69
+ *
70
+ * `Number()` is the wrong tool on a wire value and this exact test caught it:
71
+ * `JSON.stringify(NaN)` is `null`, and `Number(null)` is `0` — perfectly finite.
72
+ * So a detection whose confidence failed to compute arrived as confidence 0, and
73
+ * a box that lost its `x` arrived pinned to the left edge of the frame. Both are
74
+ * plausible values that no downstream consumer could ever question. Typed
75
+ * refusal is the only thing that keeps a missing field distinguishable from a
76
+ * measured one.
77
+ */
78
+ function isFiniteNumber(v) {
79
+ return typeof v === 'number' && Number.isFinite(v);
80
+ }
81
+ /** The service was unreachable or answered non-2xx. Distinct from "no objects". */
82
+ class DetectorUnavailableError extends Error {
83
+ }
84
+ exports.DetectorUnavailableError = DetectorUnavailableError;
85
+ class LocalDetectorClient {
86
+ constructor(options = {}, poster) {
87
+ const base = (options.baseUrl || `http://127.0.0.1:${exports.DEFAULT_DETECTOR_PORT}`).replace(/\/+$/, '');
88
+ this.detectEndpoint = `${base}/detect`;
89
+ this.healthEndpoint = `${base}/health`;
90
+ this.timeoutMs = options.timeoutMs ?? 5000;
91
+ this.classes = Array.isArray(options.classes) ? options.classes.filter(Boolean) : [];
92
+ this.minConfidence = options.minConfidence ?? 0.25;
93
+ this.poster = poster ?? exports.defaultDetectorPoster;
94
+ }
95
+ getDetectEndpoint() { return this.detectEndpoint; }
96
+ /**
97
+ * Is the service up? A CHEAP probe — it must not run inference.
98
+ *
99
+ * Returns false rather than throwing: a connector whose detector is down must
100
+ * fall through to the VLM, not stop sensing. The runtime edge-cases runbook is
101
+ * a catalogue of the opposite mistake, where a failure could not report itself;
102
+ * this returns a boolean the caller is forced to look at.
103
+ */
104
+ async isHealthy() {
105
+ try {
106
+ const res = await this.poster(this.healthEndpoint, { method: 'GET', headers: { Accept: 'application/json' }, timeoutMs: Math.min(this.timeoutMs, 2000) }, null);
107
+ return res.statusCode >= 200 && res.statusCode < 300;
108
+ }
109
+ catch {
110
+ return false;
111
+ }
112
+ }
113
+ /**
114
+ * Detect objects in one JPEG.
115
+ *
116
+ * Throws `DetectorUnavailableError` when the SERVICE failed. An empty
117
+ * `detections` array is a RESULT — the frame genuinely had nothing — and the
118
+ * two must never collapse into one another: a gate that reads "service down"
119
+ * as "nothing there" suppresses every alert while looking healthy.
120
+ */
121
+ async detect(jpeg) {
122
+ if (!jpeg || jpeg.length === 0)
123
+ throw new Error('detect() requires a non-empty jpeg buffer');
124
+ const body = JSON.stringify({
125
+ image_b64: jpeg.toString('base64'),
126
+ ...(this.classes.length > 0 ? { classes: this.classes } : {}),
127
+ min_confidence: this.minConfidence,
128
+ });
129
+ let res;
130
+ try {
131
+ res = await this.poster(this.detectEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, timeoutMs: this.timeoutMs }, body);
132
+ }
133
+ catch (err) {
134
+ throw new DetectorUnavailableError(`detector transport failed: ${err?.message || String(err)}`);
135
+ }
136
+ if (res.statusCode < 200 || res.statusCode >= 300) {
137
+ throw new DetectorUnavailableError(`detector returned HTTP ${res.statusCode}`);
138
+ }
139
+ let parsed;
140
+ try {
141
+ parsed = JSON.parse(res.body);
142
+ }
143
+ catch {
144
+ throw new DetectorUnavailableError('detector returned a body that is not JSON');
145
+ }
146
+ // A MISSING `detections` array is a broken envelope, not an empty frame.
147
+ // `{ "error": "model failed" }`, a renamed field, or a captive portal's
148
+ // JSON all arrive here as "no array", and defaulting that to `[]` is
149
+ // precisely the collapse this class exists to prevent: the cascade would
150
+ // read a broken detector as a quiet venue and suppress every VLM call while
151
+ // every health surface stayed green.
152
+ if (!Array.isArray(parsed?.detections)) {
153
+ throw new DetectorUnavailableError('detector answered 2xx without a `detections` array — envelope is not the contract');
154
+ }
155
+ const detections = [];
156
+ for (const d of parsed.detections) {
157
+ // One malformed entry REJECTS THE WHOLE PAYLOAD rather than being skipped.
158
+ // Skipping is the same defect one size down: a schema-drifted service
159
+ // yields an undercount that is indistinguishable from a genuinely emptier
160
+ // frame, and no consumer downstream can tell those apart. Refusing is the
161
+ // only version that produces a signal anybody sees.
162
+ //
163
+ // The label check earns its own note: a prior eval run defaulted an absent
164
+ // class to index 0 and scored BUSES as people for an entire run, and the
165
+ // resulting table was completely plausible.
166
+ if (!d || typeof d.label !== 'string' || !d.label) {
167
+ throw new DetectorUnavailableError('detector returned a detection with no label');
168
+ }
169
+ if (!isFiniteNumber(d.confidence) || d.confidence < 0 || d.confidence > 1) {
170
+ throw new DetectorUnavailableError(`detector returned confidence ${JSON.stringify(d.confidence)}, which is not a number in [0,1]`);
171
+ }
172
+ const b = d.box;
173
+ if (!b || !BOX_KEYS.every((k) => isFiniteNumber(b[k]))) {
174
+ throw new DetectorUnavailableError('detector returned a detection whose box is not four finite numbers');
175
+ }
176
+ if (b.width <= 0 || b.height <= 0) {
177
+ throw new DetectorUnavailableError(`detector returned a box with no extent (${b.width}x${b.height})`);
178
+ }
179
+ detections.push({
180
+ label: d.label,
181
+ confidence: d.confidence,
182
+ box: { x: b.x, y: b.y, width: b.width, height: b.height },
183
+ });
184
+ }
185
+ return {
186
+ detections,
187
+ inferenceMs: isFiniteNumber(parsed?.inference_ms) && parsed.inference_ms > 0
188
+ ? Math.round(parsed.inference_ms)
189
+ : null,
190
+ model: typeof parsed?.model === 'string' && parsed.model ? parsed.model : null,
191
+ };
192
+ }
193
+ }
194
+ exports.LocalDetectorClient = LocalDetectorClient;
195
+ /** Node built-ins only — no new dependency, matching LiteRtVlmProvider. */
196
+ const defaultDetectorPoster = (url, options, body) => new Promise((resolve, reject) => {
197
+ const u = new URL(url);
198
+ const req = (0, http_1.request)({
199
+ hostname: u.hostname,
200
+ port: u.port,
201
+ path: u.pathname,
202
+ method: options.method,
203
+ headers: options.headers,
204
+ timeout: options.timeoutMs,
205
+ }, (res) => {
206
+ const chunks = [];
207
+ res.on('data', (c) => chunks.push(c));
208
+ res.on('end', () => resolve({ statusCode: res.statusCode || 0, body: Buffer.concat(chunks).toString('utf8') }));
209
+ // NO `aborted`/`error` listeners on the response, deliberately. Review
210
+ // asked for them on the grounds that a response aborted after its
211
+ // headers never settles. Measured on Node 22, three ways:
212
+ //
213
+ // socket destroyed after headers `req:error` ECONNRESET @2ms
214
+ // truncated under Content-Length nothing until `req:timeout` @5004ms,
215
+ // then `res:aborted` @5005ms — AFTER
216
+ // the destroy, and caused by it
217
+ // no res `error` listener at all no uncaughtException; Node routes it
218
+ // to the request's handler
219
+ //
220
+ // So `aborted` cannot fire early enough to help, and `error` prevents no
221
+ // throw. Listeners that can only run after the thing that already settled
222
+ // the promise would be noise in a file whose whole premise is that a
223
+ // failure must be legible. The tests pin the OUTCOME instead — fails fast
224
+ // on a destroyed socket, settles at the timeout on a truncation, never
225
+ // hangs — which survives a Node change that would invalidate either
226
+ // listener.
227
+ //
228
+ // The one case none of this covers: a server dribbling bytes slowly under
229
+ // a large Content-Length keeps the socket busy, so the inactivity timeout
230
+ // never fires and the call is genuinely unbounded. No response listener
231
+ // fixes that either — it needs an overall deadline, and it applies
232
+ // equally to every HTTP client in this package.
233
+ });
234
+ req.on('error', reject);
235
+ req.on('timeout', () => { req.destroy(new Error(`detector request timed out after ${options.timeoutMs}ms`)); });
236
+ if (body != null)
237
+ req.write(body);
238
+ req.end();
239
+ });
240
+ exports.defaultDetectorPoster = defaultDetectorPoster;
241
+ //# sourceMappingURL=LocalDetectorClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalDetectorClient.js","sourceRoot":"","sources":["../src/LocalDetectorClient.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,+BAA8C;AAE9C,+EAA+E;AAClE,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAsD1C,MAAM,QAAQ,GAAG,CAAC,GAAG,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AAC;IACxB,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,oCAAoC,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChH,IAAI,IAAI,IAAI,IAAI;QAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC,CAAC,CAAC;AA/CQ,QAAA,qBAAqB,yBA+C7B"}
@@ -31,7 +31,7 @@ export interface DiagnosticReport {
31
31
  skipped: number;
32
32
  };
33
33
  }
34
- declare const SDK_VERSION = "0.2.74";
34
+ declare const SDK_VERSION = "0.2.76";
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.74';
66
+ const SDK_VERSION = '0.2.76';
67
67
  exports._SDK_VERSION = SDK_VERSION;
68
68
  // ---------------------------------------------------------------------------
69
69
  // ANSI helpers (no external deps)
package/dist/index.d.ts CHANGED
@@ -37,5 +37,9 @@ export type { AudioSensingOptions, AudioOnsetAttachment, AudioOnsetTransport, }
37
37
  export { encodeWav16, takeMostRecentSeconds, GEMMA_AUDIO_SAMPLE_RATE, GEMMA_AUDIO_MAX_SECONDS, } from './wavEncode';
38
38
  export { SharedFrameSource, CropViewProvider } from './MosaicSource';
39
39
  export type { CropViewProviderOptions } from './MosaicSource';
40
+ export { LocalDetectorClient, DetectorUnavailableError, defaultDetectorPoster, DEFAULT_DETECTOR_PORT, } from './LocalDetectorClient';
41
+ export type { Detection, DetectResult, DetectorHttpPoster, LocalDetectorClientOptions, } from './LocalDetectorClient';
42
+ export { evaluateZone, countInZone, normalizeBox, assertNormalizedRect, DEFAULT_ZONE_PREDICATE, } from './zoneContainment';
43
+ export type { NormalizedRect, PixelBox, FrameSize, ZonePredicate, ZoneVerdict, } from './zoneContainment';
40
44
  export type { AudienceMetricsPayload, DetectedFace, EdgeQualityReport, VASResult, DeviceCapabilityMatrix, PlatformAdapter, CameraProvider, AudioProvider, EdgeSDKConfig, } from '@trillboards/edge-core';
41
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAKnD,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,mBAAmB,E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AC;AACjF,YAAY,EACV,yBAAyB,EACzB,eAAe,EACf,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACrE,YAAY,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAO9D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,cAAc,EACd,QAAQ,EACR,SAAS,EACT,aAAa,EACb,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // Run: npx trillboards-edge start --config trillboards.config.json
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.attachAudioOnset = exports.SILENCE_DBFS = exports.rmsDbfs = exports.AudioOnsetDetector = exports.motionSignature = exports.downscaleRgbaToGrey = exports.decodeGreyFrame = exports.isChangeCandidate = exports.SceneChangeDetector = exports.MotionGate = exports.DurableVlmCandidateSpool = exports.DEFAULT_CANDIDATE_TTL_MS = exports.VlmCandidateBuffer = exports.VlmAdmissionGate = exports.shouldAttemptRecorderAddressRecovery = exports.rewriteStreamHost = exports.normalizeMacAddress = exports.lookupMacAddress = exports.RecorderAddressRecovery = exports.resolveFeeds = exports.classifyRtspFailureClass = exports.buildTiledCameras = exports.buildSensingLoops = exports.CloudSensingManager = exports.defaultHttpPoster = exports.AudienceAnalyzeClient = exports.LOCAL_NETWORK_DENIED_SUMMARY = exports.LOCAL_NETWORK_DENIED_SUGGESTION = exports.decideLocalNetworkVerdict = exports.probeLocalNetworkAccess = exports.describeProxy = exports.resolveProxyForUrl = exports.describeTrustAnchors = exports.resolveTrustAnchors = exports.isTrustFailure = exports.formatTransportFailure = exports.classifyTransportError = exports.TransportFailure = exports.EnterpriseHttpsAgent = exports.resetEnterpriseNetworkCaches = exports.diagnoseTransportError = exports.getEnterpriseAgent = exports.describeNetworkPosture = exports.installEnterpriseNetworking = exports.runDiagnose = exports.runInit = exports.CommandRouter = exports.resolveConfig = exports.loadConfig = exports.EdgeAgent = void 0;
7
- exports.CropViewProvider = exports.SharedFrameSource = exports.GEMMA_AUDIO_MAX_SECONDS = exports.GEMMA_AUDIO_SAMPLE_RATE = exports.takeMostRecentSeconds = exports.encodeWav16 = void 0;
7
+ exports.DEFAULT_ZONE_PREDICATE = exports.assertNormalizedRect = exports.normalizeBox = exports.countInZone = exports.evaluateZone = exports.DEFAULT_DETECTOR_PORT = exports.defaultDetectorPoster = exports.DetectorUnavailableError = exports.LocalDetectorClient = exports.CropViewProvider = exports.SharedFrameSource = exports.GEMMA_AUDIO_MAX_SECONDS = exports.GEMMA_AUDIO_SAMPLE_RATE = exports.takeMostRecentSeconds = exports.encodeWav16 = void 0;
8
8
  var EdgeAgent_1 = require("./EdgeAgent");
9
9
  Object.defineProperty(exports, "EdgeAgent", { enumerable: true, get: function () { return EdgeAgent_1.EdgeAgent; } });
10
10
  var config_1 = require("./config");
@@ -98,4 +98,20 @@ Object.defineProperty(exports, "GEMMA_AUDIO_MAX_SECONDS", { enumerable: true, ge
98
98
  var MosaicSource_1 = require("./MosaicSource");
99
99
  Object.defineProperty(exports, "SharedFrameSource", { enumerable: true, get: function () { return MosaicSource_1.SharedFrameSource; } });
100
100
  Object.defineProperty(exports, "CropViewProvider", { enumerable: true, get: function () { return MosaicSource_1.CropViewProvider; } });
101
+ // On-device object detection. The client is the WIRE CONTRACT for a loopback
102
+ // detector service; the geometry answers "is it in the area the operator drew".
103
+ // Nothing calls either yet — the detector service is packaging work that ships
104
+ // separately, and advertising a capability before its artifact exists is the
105
+ // `yolov8_nano` failure this area already paid for once.
106
+ var LocalDetectorClient_1 = require("./LocalDetectorClient");
107
+ Object.defineProperty(exports, "LocalDetectorClient", { enumerable: true, get: function () { return LocalDetectorClient_1.LocalDetectorClient; } });
108
+ Object.defineProperty(exports, "DetectorUnavailableError", { enumerable: true, get: function () { return LocalDetectorClient_1.DetectorUnavailableError; } });
109
+ Object.defineProperty(exports, "defaultDetectorPoster", { enumerable: true, get: function () { return LocalDetectorClient_1.defaultDetectorPoster; } });
110
+ Object.defineProperty(exports, "DEFAULT_DETECTOR_PORT", { enumerable: true, get: function () { return LocalDetectorClient_1.DEFAULT_DETECTOR_PORT; } });
111
+ var zoneContainment_1 = require("./zoneContainment");
112
+ Object.defineProperty(exports, "evaluateZone", { enumerable: true, get: function () { return zoneContainment_1.evaluateZone; } });
113
+ Object.defineProperty(exports, "countInZone", { enumerable: true, get: function () { return zoneContainment_1.countInZone; } });
114
+ Object.defineProperty(exports, "normalizeBox", { enumerable: true, get: function () { return zoneContainment_1.normalizeBox; } });
115
+ Object.defineProperty(exports, "assertNormalizedRect", { enumerable: true, get: function () { return zoneContainment_1.assertNormalizedRect; } });
116
+ Object.defineProperty(exports, "DEFAULT_ZONE_PREDICATE", { enumerable: true, get: function () { return zoneContainment_1.DEFAULT_ZONE_PREDICATE; } });
101
117
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CH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gB,OAAA;AAMzB,wEAAwE;AACxE,sEAAsE;AACtE,2DAAoF;AAA3E,wHAAA,kBAAkB,OAAA;AAAE,8HAAA,wBAAwB,OAAA;AACrD,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AAYjC,6DAO+B;AAN7B,iHAAA,UAAU,OAAA;AACV,0HAAA,mBAAmB,OAAA;AACnB,wHAAA,iBAAiB,OAAA;AACjB,sHAAA,eAAe,OAAA;AACf,0HAAA,mBAAmB,OAAA;AACnB,sHAAA,eAAe,OAAA;AAajB,0EAA0E;AAC1E,2EAA2E;AAC3E,kDAAkD;AAClD,2DAAiF;AAAxE,wHAAA,kBAAkB,OAAA;AAAE,6GAAA,OAAO,OAAA;AAAE,kHAAA,YAAY,OAAA;AAMlD,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AAMzB,yCAKqB;AAJnB,wGAAA,WAAW,OAAA;AACX,kHAAA,qBAAqB,OAAA;AACrB,oHAAA,uBAAuB,OAAA;AACvB,oHAAA,uBAAuB,OAAA;AAEzB,+EAA+E;AAC/E,mEAAmE;AACnE,+CAAqE;AAA5D,iHAAA,iBAAiB,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AAG5C,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,6EAA6E;AAC7E,yDAAyD;AACzD,6DAK+B;AAJ7B,0HAAA,mBAAmB,OAAA;AACnB,+HAAA,wBAAwB,OAAA;AACxB,4HAAA,qBAAqB,OAAA;AACrB,4HAAA,qBAAqB,OAAA;AAQvB,qDAM2B;AALzB,+GAAA,YAAY,OAAA;AACZ,8GAAA,WAAW,OAAA;AACX,+GAAA,YAAY,OAAA;AACZ,uHAAA,oBAAoB,OAAA;AACpB,yHAAA,sBAAsB,OAAA"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * zoneContainment — "is this thing in the area the operator drew?", in code.
3
+ *
4
+ * ── WHY THIS EXISTS ────────────────────────────────────────────────────────
5
+ *
6
+ * The operator drags a rectangle on their camera and expects "only tell me about
7
+ * THIS". Today that promise is kept by writing the rectangle's coordinates into
8
+ * an English sentence and asking a vision-language model to respect it. Measured
9
+ * on production, before and after the description was repaired:
10
+ *
11
+ * - the focused field agreed with the UNRESTRICTED field on 99.5% of frames
12
+ * - after the fix the model demonstrably READS the constraint (divergence
13
+ * 0.34% -> 3.58%), and yet `focus_true` is still 0 of 391 in a window with
14
+ * MORE person activity than the one before it
15
+ *
16
+ * So the repaired prose suppresses, and whether it suppresses the RIGHT things
17
+ * is not knowable from the model's answer alone. A rectangle is geometry. Asking
18
+ * a language model to do geometry, and then having no way to check its working,
19
+ * is the part that has to stop.
20
+ *
21
+ * ── THE ANCHOR IS THE WHOLE PROBLEM, AND IT IS NOT A THRESHOLD ─────────────
22
+ *
23
+ * A person is a tall box. Someone standing on the pavement BESIDE a driveway
24
+ * overlaps the driveway's rectangle in image space with their head and shoulders
25
+ * while their feet are firmly outside it. Area-overlap answers "yes" and is
26
+ * wrong; whole-box containment answers "no" for anyone standing at the edge and
27
+ * is also wrong. Neither is rescued by tuning a fraction, because the error is
28
+ * not one of degree — the box's top is not where the person IS.
29
+ *
30
+ * A camera looks down. The ground plane is where a person occupies space, and
31
+ * the bottom edge of their box is where they touch it. So `groundContact` — the
32
+ * bottom-centre point — is the default, and it needs NO threshold: a point is
33
+ * inside a rectangle or it is not. That is the whole reason to prefer it. A
34
+ * magic fraction nobody can justify is exactly what this codebase asks not to
35
+ * invent, and here the physics removes the need for one.
36
+ *
37
+ * `areaOverlap` is offered for the cases where the ground plane is not the
38
+ * subject — a package on a shelf, a vehicle in a wide overhead view — and there
39
+ * the fraction is a REQUIRED, caller-supplied argument, never a default, so it
40
+ * appears in the route's own configuration where an operator's expectation can
41
+ * be compared against it.
42
+ *
43
+ * ── COORDINATE SPACES: EXACTLY ONE CONVERSION, HERE ────────────────────────
44
+ *
45
+ * Detector boxes are PIXELS in the submitted frame. `sensing_route_screens`
46
+ * stores `focus_x/y/width/height` NORMALIZED to [0,1] — that is what the portal
47
+ * writes and what `focusRegionFromScreenRow` reads. The two meet in exactly one
48
+ * place: this file. Every function takes the frame's dimensions explicitly
49
+ * rather than carrying a resolution around, because a stale resolution is
50
+ * silent and a missing argument is not.
51
+ *
52
+ * @reuse-audit
53
+ * considered: FaceDetector.iou (edge-sensing/src/processors/FaceDetector.ts)
54
+ * - not reused: IoU is a SYMMETRIC similarity between two detections, used
55
+ * for NMS and tracking. Containment is asymmetric — "how much of the BOX
56
+ * is in the RECT" — and IoU's denominator includes the rectangle's own
57
+ * area, so a small person inside a large zone scores near zero on IoU and
58
+ * 1.0 here. Same rectangles, different question. When the detector's own
59
+ * NMS lands it must call FaceDetector's iou, not a copy.
60
+ * considered: camera-alert-focus-selector.tsx (portal)
61
+ * - not reused: drag/clamp only, no containment predicate, and it is React
62
+ * in a different package. Its clamping is the reason `assertNormalizedRect`
63
+ * can be strict — the rect always arrives already inside [0,1].
64
+ */
65
+ /** A rectangle in normalized [0,1] frame coordinates, as the operator drew it. */
66
+ export interface NormalizedRect {
67
+ x: number;
68
+ y: number;
69
+ width: number;
70
+ height: number;
71
+ }
72
+ /** A box in PIXELS of the frame it was detected in. */
73
+ export interface PixelBox {
74
+ x: number;
75
+ y: number;
76
+ width: number;
77
+ height: number;
78
+ }
79
+ export interface FrameSize {
80
+ width: number;
81
+ height: number;
82
+ }
83
+ /**
84
+ * How to decide whether a box is "in" the zone.
85
+ *
86
+ * `groundContact` — the box's bottom-centre point falls inside the rect. The
87
+ * default, and the only one with a physical argument behind it.
88
+ *
89
+ * `areaOverlap` — at least `minOverlap` of the box's own area falls inside the
90
+ * rect. `minOverlap` is REQUIRED; there is no defensible default and inventing
91
+ * one would bury the decision.
92
+ */
93
+ export type ZonePredicate = {
94
+ kind: 'groundContact';
95
+ } | {
96
+ kind: 'areaOverlap';
97
+ minOverlap: number;
98
+ };
99
+ export declare const DEFAULT_ZONE_PREDICATE: ZonePredicate;
100
+ export interface ZoneVerdict {
101
+ inside: boolean;
102
+ /**
103
+ * Fraction of the box's area inside the rect, ALWAYS computed regardless of
104
+ * predicate.
105
+ *
106
+ * Reported even when unused because the alternative — logging only the boolean
107
+ * — makes a disputed verdict unreviewable after the fact. An operator saying
108
+ * "it missed someone standing right there" is answerable with 0.62 and
109
+ * unanswerable with `false`.
110
+ */
111
+ overlapFraction: number;
112
+ /** The bottom-centre point in normalized coordinates, for the same reason. */
113
+ groundContact: {
114
+ x: number;
115
+ y: number;
116
+ };
117
+ }
118
+ /**
119
+ * A rect outside [0,1] is a COORDINATE-SPACE error, and it must throw.
120
+ *
121
+ * The one way this happens is a caller passing pixels where normalized values
122
+ * belong — and pixels are numerically valid, so the verdict would just be
123
+ * silently wrong forever: a rect at x=640 clamps to the frame's right edge and
124
+ * every person reads as outside it. That failure has no symptom other than an
125
+ * alert that never fires, which is the failure this whole area keeps producing.
126
+ * Refusing loudly is the only version anybody notices.
127
+ */
128
+ export declare function assertNormalizedRect(rect: NormalizedRect): void;
129
+ /** Convert a pixel box to normalized coordinates. The only conversion there is. */
130
+ export declare function normalizeBox(box: PixelBox, frame: FrameSize): NormalizedRect;
131
+ /**
132
+ * Is this detection inside the operator's rectangle?
133
+ *
134
+ * Throws on a malformed rect or frame — see `assertNormalizedRect`. Never
135
+ * returns a verdict it could not compute.
136
+ */
137
+ export declare function evaluateZone(box: PixelBox, frame: FrameSize, rect: NormalizedRect, predicate?: ZonePredicate): ZoneVerdict;
138
+ /**
139
+ * Count the detections inside the zone.
140
+ *
141
+ * This is the integer the focused field has been asking a language model for.
142
+ * `null` rect means NO zone was drawn, and then the count is every detection —
143
+ * which is what the unfocused field already means, so absence degrades to the
144
+ * existing behaviour rather than to zero. A zone that silently counts nothing is
145
+ * indistinguishable from a quiet venue, and that is the whole failure mode here.
146
+ */
147
+ export declare function countInZone(boxes: PixelBox[], frame: FrameSize, rect: NormalizedRect | null | undefined, predicate?: ZonePredicate): number;
148
+ //# sourceMappingURL=zoneContainment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version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