@trillboards/edge-sdk 0.2.170 → 0.2.176
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/detector/README.md +6 -0
- package/deploy/detector/pyproject.toml +4 -1
- package/deploy/detector/tests/test_actor_action_wire.py +103 -0
- package/deploy/detector/tests/test_actor_actions.py +94 -0
- package/deploy/detector/tests/test_actor_checkpoint.py +99 -0
- package/deploy/detector/tests/test_actor_tracking.py +191 -0
- package/deploy/detector/tests/test_actor_tracking_wire.py +120 -0
- package/deploy/detector/tests/test_actor_views.py +108 -0
- package/deploy/detector/tests/test_compute_budget.py +28 -0
- package/deploy/detector/tests/test_detector_request.py +52 -0
- package/deploy/detector/tests/test_input_recipe.py +77 -0
- package/deploy/detector/tests/test_loader.py +20 -1
- package/deploy/detector/tests/test_pose.py +66 -0
- package/deploy/detector/tests/test_server.py +83 -0
- package/deploy/detector/tests/test_task_registry.py +74 -0
- package/deploy/detector/trillboards_detector/_version.py +2 -2
- package/deploy/detector/trillboards_detector/actor_action_contract.py +65 -0
- package/deploy/detector/trillboards_detector/actor_action_wire.py +189 -0
- package/deploy/detector/trillboards_detector/actor_actions.py +115 -0
- package/deploy/detector/trillboards_detector/actor_checkpoint.py +91 -0
- package/deploy/detector/trillboards_detector/actor_tracking.py +337 -0
- package/deploy/detector/trillboards_detector/actor_views.py +102 -0
- package/deploy/detector/trillboards_detector/cli.py +12 -2
- package/deploy/detector/trillboards_detector/labels.py +32 -0
- package/deploy/detector/trillboards_detector/loader.py +30 -4
- package/deploy/detector/trillboards_detector/pose.py +129 -0
- package/deploy/detector/trillboards_detector/registry.py +92 -7
- package/deploy/detector/trillboards_detector/server.py +131 -3
- package/deploy/detector/trillboards_detector/session.py +83 -49
- package/deploy/detector/trillboards_detector/tasks.py +27 -0
- package/deploy/detector/trillboards_detector/worker_budget.py +14 -0
- package/deploy/windows/README.md +1 -1
- package/deploy/windows/ci/test-published-install.ps1 +16 -3
- package/dist/ActorActionClient.d.ts +47 -0
- package/dist/ActorActionClient.d.ts.map +1 -0
- package/dist/ActorActionClient.js +187 -0
- package/dist/ActorActionClient.js.map +1 -0
- package/dist/ActorActionProducer.d.ts +17 -0
- package/dist/ActorActionProducer.d.ts.map +1 -0
- package/dist/ActorActionProducer.js +92 -0
- package/dist/ActorActionProducer.js.map +1 -0
- package/dist/ActorPerception.d.ts +65 -0
- package/dist/ActorPerception.d.ts.map +1 -0
- package/dist/ActorPerception.js +124 -0
- package/dist/ActorPerception.js.map +1 -0
- package/dist/ActorPose.d.ts +42 -0
- package/dist/ActorPose.d.ts.map +1 -0
- package/dist/ActorPose.js +62 -0
- package/dist/ActorPose.js.map +1 -0
- package/dist/ActorReview.d.ts +51 -0
- package/dist/ActorReview.d.ts.map +1 -0
- package/dist/ActorReview.js +84 -0
- package/dist/ActorReview.js.map +1 -0
- package/dist/ActorTracking.d.ts +33 -0
- package/dist/ActorTracking.d.ts.map +1 -0
- package/dist/ActorTracking.js +90 -0
- package/dist/ActorTracking.js.map +1 -0
- package/dist/ActorWindow.d.ts +56 -0
- package/dist/ActorWindow.d.ts.map +1 -0
- package/dist/ActorWindow.js +86 -0
- package/dist/ActorWindow.js.map +1 -0
- package/dist/ActorWindowContract.d.ts +5 -0
- package/dist/ActorWindowContract.d.ts.map +1 -0
- package/dist/ActorWindowContract.js +23 -0
- package/dist/ActorWindowContract.js.map +1 -0
- package/dist/AudienceAnalyzeClient.d.ts +4 -0
- package/dist/AudienceAnalyzeClient.d.ts.map +1 -1
- package/dist/AudienceAnalyzeClient.js.map +1 -1
- package/dist/ChannelProber.d.ts.map +1 -1
- package/dist/ChannelProber.js +8 -0
- package/dist/ChannelProber.js.map +1 -1
- package/dist/CloudSensingManager.d.ts +9 -0
- package/dist/CloudSensingManager.d.ts.map +1 -1
- package/dist/CloudSensingManager.js +41 -4
- package/dist/CloudSensingManager.js.map +1 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/LocalDetectorClient.d.ts +5 -1
- package/dist/LocalDetectorClient.d.ts.map +1 -1
- package/dist/LocalDetectorClient.js +48 -3
- package/dist/LocalDetectorClient.js.map +1 -1
- package/dist/MosaicSource.d.ts.map +1 -1
- package/dist/MosaicSource.js +3 -2
- package/dist/MosaicSource.js.map +1 -1
- package/dist/RetainedFieldContract.d.ts +2 -1
- package/dist/RetainedFieldContract.d.ts.map +1 -1
- package/dist/RetainedFieldContract.js +17 -5
- package/dist/RetainedFieldContract.js.map +1 -1
- package/dist/RuntimeModelSelection.d.ts.map +1 -1
- package/dist/RuntimeModelSelection.js +63 -2
- package/dist/RuntimeModelSelection.js.map +1 -1
- package/dist/TemporalReviewClient.d.ts.map +1 -1
- package/dist/TemporalReviewClient.js +20 -1
- package/dist/TemporalReviewClient.js.map +1 -1
- package/dist/TemporalReviewJournal.d.ts +10 -1
- package/dist/TemporalReviewJournal.d.ts.map +1 -1
- package/dist/TemporalReviewJournal.js +42 -10
- package/dist/TemporalReviewJournal.js.map +1 -1
- package/dist/config.d.ts +10 -43
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/connectorUpdate.d.ts +2 -0
- package/dist/connectorUpdate.d.ts.map +1 -1
- package/dist/connectorUpdate.js +33 -7
- package/dist/connectorUpdate.js.map +1 -1
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/jpegFrameSize.d.ts +1 -29
- package/dist/jpegFrameSize.d.ts.map +1 -1
- package/dist/jpegFrameSize.js +3 -91
- package/dist/jpegFrameSize.js.map +1 -1
- package/dist/localSensing.d.ts +13 -10
- package/dist/localSensing.d.ts.map +1 -1
- package/dist/localSensing.js +86 -72
- package/dist/localSensing.js.map +1 -1
- package/package.json +7 -7
- package/retained/RetainedCaptureClient.cjs +55 -9
- package/retained/__tests__/actor-perception.test.cjs +125 -0
- package/retained/__tests__/actor-window.test.cjs +78 -0
- package/retained/__tests__/runtime.test.cjs +44 -4
- package/retained/actor-window.cjs +62 -0
- package/retained/manager.cjs +14 -2
package/dist/jpegFrameSize.js
CHANGED
|
@@ -1,94 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The pixel dimensions of a JPEG, read from its own header.
|
|
4
|
-
*
|
|
5
|
-
* WHY THIS EXISTS AT ALL. A detector box arrives in PIXELS and an operator's
|
|
6
|
-
* region is NORMALIZED, so one of them has to be converted and neither the
|
|
7
|
-
* detector wire nor `DetectResult` carries a frame size. Asking the service for
|
|
8
|
-
* one would change a FROZEN contract (`cctv-detector-tier.md`: it carries
|
|
9
|
-
* `classes` and nothing else) to obtain a number already present in the bytes we
|
|
10
|
-
* just sent it.
|
|
11
|
-
*
|
|
12
|
-
* WHY NOT A DECODE. `sharp` is not a connector dependency and a full decode of
|
|
13
|
-
* every frame to learn two integers is a per-frame cost on the hot path. The SOF
|
|
14
|
-
* marker is 9 bytes into a segment that appears once, near the front.
|
|
15
|
-
*
|
|
16
|
-
* IT RETURNS NULL RATHER THAN GUESSING. A truncated or non-JPEG buffer has no
|
|
17
|
-
* dimensions, and inventing 1920x1080 would silently rescale every region — a
|
|
18
|
-
* doorway at x=0.4 lands somewhere else and the alert quietly watches the wrong
|
|
19
|
-
* part of the room. The caller must treat null as "no region can be applied",
|
|
20
|
-
* which degrades to the unfocused count rather than to zero.
|
|
21
|
-
*/
|
|
22
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.readJpegFrameSize =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* arithmetic/progressive/lossless variants that carry the SAME 5-byte header.
|
|
27
|
-
*
|
|
28
|
-
* NOT in this set on purpose: 0xC4 (DHT), 0xC8 (JPG, reserved) and 0xCC (DAC)
|
|
29
|
-
* share the 0xC0-0xCF range and are NOT frame headers. Reading dimensions out of
|
|
30
|
-
* a Huffman table is how a frame ends up 1x1 with no error anywhere.
|
|
31
|
-
*/
|
|
32
|
-
const SOF_MARKERS = new Set([
|
|
33
|
-
0xc0, 0xc1, 0xc2, 0xc3,
|
|
34
|
-
0xc5, 0xc6, 0xc7,
|
|
35
|
-
0xc9, 0xca, 0xcb,
|
|
36
|
-
0xcd, 0xce, 0xcf,
|
|
37
|
-
]);
|
|
38
|
-
/**
|
|
39
|
-
* @param jpeg the raw bytes, exactly as posted to the detector
|
|
40
|
-
* @returns the frame size, or null when the buffer is not a readable JPEG
|
|
41
|
-
*/
|
|
42
|
-
function readJpegFrameSize(jpeg) {
|
|
43
|
-
if (!jpeg || jpeg.length < 4)
|
|
44
|
-
return null;
|
|
45
|
-
// SOI. A buffer that does not start with it is not a JPEG, and scanning on
|
|
46
|
-
// would find a "marker" in arbitrary payload bytes.
|
|
47
|
-
if (jpeg[0] !== 0xff || jpeg[1] !== 0xd8)
|
|
48
|
-
return null;
|
|
49
|
-
let i = 2;
|
|
50
|
-
while (i + 3 < jpeg.length) {
|
|
51
|
-
if (jpeg[i] !== 0xff) {
|
|
52
|
-
// Not at a marker. Resynchronising by scanning would read entropy-coded
|
|
53
|
-
// data as structure, so this refuses instead.
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
let marker = jpeg[i + 1];
|
|
57
|
-
// 0xFF fill bytes are legal padding before a marker.
|
|
58
|
-
let j = i + 1;
|
|
59
|
-
while (marker === 0xff && j + 1 < jpeg.length) {
|
|
60
|
-
j += 1;
|
|
61
|
-
marker = jpeg[j];
|
|
62
|
-
}
|
|
63
|
-
if (marker === 0xd8 || (marker >= 0xd0 && marker <= 0xd9)) {
|
|
64
|
-
i = j + 1;
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
// SOS: entropy-coded data begins and no SOF can follow. A JPEG that reaches
|
|
68
|
-
// here without one has no dimensions we can read.
|
|
69
|
-
if (marker === 0xda)
|
|
70
|
-
return null;
|
|
71
|
-
const lenAt = j + 1;
|
|
72
|
-
if (lenAt + 1 >= jpeg.length)
|
|
73
|
-
return null;
|
|
74
|
-
const segLen = (jpeg[lenAt] << 8) | jpeg[lenAt + 1];
|
|
75
|
-
if (segLen < 2)
|
|
76
|
-
return null;
|
|
77
|
-
if (SOF_MARKERS.has(marker)) {
|
|
78
|
-
// length(2) precision(1) height(2) width(2)
|
|
79
|
-
const h = lenAt + 3;
|
|
80
|
-
if (h + 3 >= jpeg.length)
|
|
81
|
-
return null;
|
|
82
|
-
const height = (jpeg[h] << 8) | jpeg[h + 1];
|
|
83
|
-
const width = (jpeg[h + 2] << 8) | jpeg[h + 3];
|
|
84
|
-
// A zero dimension is a malformed header, not a frame. Returning it would
|
|
85
|
-
// divide by zero downstream, or worse, be clamped to something plausible.
|
|
86
|
-
if (width <= 0 || height <= 0)
|
|
87
|
-
return null;
|
|
88
|
-
return { width, height };
|
|
89
|
-
}
|
|
90
|
-
i = lenAt + segLen;
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
3
|
+
exports.readJpegFrameSize = void 0;
|
|
4
|
+
var edge_core_1 = require("@trillboards/edge-core");
|
|
5
|
+
Object.defineProperty(exports, "readJpegFrameSize", { enumerable: true, get: function () { return edge_core_1.readJpegFrameSize; } });
|
|
94
6
|
//# sourceMappingURL=jpegFrameSize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jpegFrameSize.js","sourceRoot":"","sources":["../src/jpegFrameSize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jpegFrameSize.js","sourceRoot":"","sources":["../src/jpegFrameSize.ts"],"names":[],"mappings":";;;AAAA,oDAA4E;AAApE,8GAAA,iBAAiB,OAAA"}
|
package/dist/localSensing.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { type ResolvedFeed, type SensingClient, type SensingLoopDeps } from './C
|
|
|
11
11
|
import type { SharedFrameSource } from './MosaicSource';
|
|
12
12
|
import { type LocalSchemaFieldSet } from './localInferenceSchema';
|
|
13
13
|
import type { EdgeAgentConfig } from './config';
|
|
14
|
+
import { ActorActionClient } from './ActorActionClient';
|
|
14
15
|
import type { ImageClassifierFieldProducer } from './ImageClassifierFieldProducer';
|
|
15
16
|
import { type ReviewModelUse } from './ReviewModelUse';
|
|
16
17
|
/**
|
|
@@ -71,6 +72,8 @@ export interface LocalSensingClientOptions {
|
|
|
71
72
|
modelId: string;
|
|
72
73
|
sha256: string;
|
|
73
74
|
};
|
|
75
|
+
/** Production uses the existing native detector address; injection is a runtime test seam. */
|
|
76
|
+
actorActionClient?: ActorActionClient;
|
|
74
77
|
/** Default-off local experiment; requires durable evidence and a loopback receiver. */
|
|
75
78
|
detectorCounts?: boolean;
|
|
76
79
|
/** Default-off local experiment. Requires retained evidence and a loopback receiver. */
|
|
@@ -282,6 +285,7 @@ export declare class LocalSensingClient implements SensingClient {
|
|
|
282
285
|
* quiet venue, and that is the failure this area keeps producing.
|
|
283
286
|
*/
|
|
284
287
|
private readonly resolveAlertFocusRegion;
|
|
288
|
+
private readonly actorActionProducer;
|
|
285
289
|
private readonly producerOptions;
|
|
286
290
|
private readonly producerInjected;
|
|
287
291
|
private lastProfileFetchMs;
|
|
@@ -411,18 +415,17 @@ export declare class LocalSensingClient implements SensingClient {
|
|
|
411
415
|
analyze(request: AudienceAnalyzeRequest): Promise<AudienceAnalyzeResponse>;
|
|
412
416
|
}
|
|
413
417
|
/**
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
* Lower-only, for the reasons on the config key and at the call site. Returns
|
|
418
|
-
* `undefined` for "operator said nothing", so the provider keeps its own
|
|
419
|
-
* default rather than being handed a number this layer invented.
|
|
420
|
-
*
|
|
421
|
-
* Exported for tests: the whole point of this function is the clamp and the
|
|
422
|
-
* warning, and neither is observable through `buildLocalSensingLoops` without
|
|
423
|
-
* standing up a full loop set.
|
|
418
|
+
* Validate the explicit occupancy policy once for every feed on a recorder.
|
|
419
|
+
* Larger policies are valid: the provider still learns a smaller real ceiling
|
|
420
|
+
* and reserves transient slots if the recorder refuses a persistent session.
|
|
424
421
|
*/
|
|
425
422
|
export declare function resolveMaxStreamSessionsPerSource(requested: number | undefined, warn?: (msg: string) => void): number | undefined;
|
|
423
|
+
/**
|
|
424
|
+
* Count the actual RTSP providers built by the shared mosaic topology.
|
|
425
|
+
* A configured mosaic source needs one session; orphan tiles each need their
|
|
426
|
+
* own. Recorder keys and grouping are the same owners used by capture itself.
|
|
427
|
+
*/
|
|
428
|
+
export declare function persistentStreamDemandBySource(feeds: readonly ResolvedFeed[]): Map<string, number>;
|
|
426
429
|
/** Injection points for tests (default to the real providers/clients). */
|
|
427
430
|
export interface BuildLocalSensingDeps {
|
|
428
431
|
/** Selected internally by the normal retained factory, not a second config. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localSensing.d.ts","sourceRoot":"","sources":["../src/localSensing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,wBAAwB,CAAC;AAInF,OAAO,EAA2B,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACnG,OAAO,EACL,qBAAqB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAGtF,OAAO,EAAyC,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC5H,OAAO,EACL,qBAAqB,EAErB,KAAK,4BAA4B,EAGlC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAsB,KAAK,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAwB,KAAK,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AACtF,OAAO,
|
|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,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,2BAA2B,KAAK,OAAO,CAAC,GAAG,IAAI,CAAC;CAChF;AAED,yEAAyE;AACzE,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS9D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,aAAa,CAAC,GAAG,MAAM,CAIzF;AAED,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,+EAA+E;IAC/E,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,yDAAyD;IACzD,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAID,qEAAqE;AACrE,wBAAgB,qBAAqB,IAAI,kBAAkB,CAM1D;AAmBD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,eAAe,EACvB,IAAI,CAAC,EAAE,qBAAqB,GAC3B,eAAe,EAAE,CA+PnB"}
|
package/dist/localSensing.js
CHANGED
|
@@ -38,6 +38,7 @@ exports.fieldSetForProfileType = fieldSetForProfileType;
|
|
|
38
38
|
exports.repairLowConfidencePresenceContradiction = repairLowConfidencePresenceContradiction;
|
|
39
39
|
exports.isAlertWorthy = isAlertWorthy;
|
|
40
40
|
exports.resolveMaxStreamSessionsPerSource = resolveMaxStreamSessionsPerSource;
|
|
41
|
+
exports.persistentStreamDemandBySource = persistentStreamDemandBySource;
|
|
41
42
|
exports.recordingUrlKey = recordingUrlKey;
|
|
42
43
|
exports.videoFeedKey = videoFeedKey;
|
|
43
44
|
exports.getVideoRecordingPlan = getVideoRecordingPlan;
|
|
@@ -62,6 +63,9 @@ const CloudSensingManager_1 = require("./CloudSensingManager");
|
|
|
62
63
|
const localInferenceSchema_1 = require("./localInferenceSchema");
|
|
63
64
|
const legacyRecorderProfile_1 = require("./legacyRecorderProfile");
|
|
64
65
|
const ReviewPriority_1 = require("./ReviewPriority");
|
|
66
|
+
const ActorActionClient_1 = require("./ActorActionClient");
|
|
67
|
+
const ActorActionProducer_1 = require("./ActorActionProducer");
|
|
68
|
+
const ActorReview_1 = require("./ActorReview");
|
|
65
69
|
const RetainedFieldContract_1 = require("./RetainedFieldContract");
|
|
66
70
|
const RuntimeModelSelection_1 = require("./RuntimeModelSelection");
|
|
67
71
|
const ReviewModelUse_1 = require("./ReviewModelUse");
|
|
@@ -497,6 +501,9 @@ class LocalSensingClient {
|
|
|
497
501
|
throw Error('Declared profile review requires scoped review');
|
|
498
502
|
}
|
|
499
503
|
this.producerOptions = options.detectorFieldProducerOptions ?? {};
|
|
504
|
+
this.actorActionProducer = new ActorActionProducer_1.ActorActionProducer(options.actorActionClient ?? new ActorActionClient_1.ActorActionClient({
|
|
505
|
+
baseUrl: this.producerOptions.baseUrl, timeoutMs: this.producerOptions.timeoutMs
|
|
506
|
+
}));
|
|
500
507
|
this.phonePersonDetector = options.phonePersonDetector ?? (async (jpeg, policy) => {
|
|
501
508
|
const client = new LocalDetectorClient_1.LocalDetectorClient({ baseUrl: this.producerOptions.baseUrl, timeoutMs: this.producerOptions.timeoutMs,
|
|
502
509
|
classes: ['person'], minConfidence: policy.minConfidence, expectedModel: policy.proposalModel });
|
|
@@ -727,6 +734,9 @@ class LocalSensingClient {
|
|
|
727
734
|
}
|
|
728
735
|
captureReviewContext() {
|
|
729
736
|
void this.prepareReview().catch(() => { });
|
|
737
|
+
const selected = this.cachedModelSelection && !('invalid' in this.cachedModelSelection) ? this.cachedModelSelection : null;
|
|
738
|
+
const actorTasks = (0, ActorActionProducer_1.hasSelectedActorActions)(selected);
|
|
739
|
+
const actorOnly = actorTasks && !selected.models.some(model => model.format === 'litert-lm');
|
|
730
740
|
const context = JSON.parse(JSON.stringify({
|
|
731
741
|
version: 1,
|
|
732
742
|
...(this.reviewProfileState ? { profileState: this.reviewProfileState } : {}),
|
|
@@ -734,6 +744,7 @@ class LocalSensingClient {
|
|
|
734
744
|
...(this.cachedReviewPolicy ? { reviewPolicy: this.cachedReviewPolicy } : {}),
|
|
735
745
|
...(this.cachedFieldContract ? { retainedFieldContract: this.cachedFieldContract } : {}),
|
|
736
746
|
...(this.cachedModelSelection ? { modelSelection: this.cachedModelSelection } : {}),
|
|
747
|
+
...(actorTasks ? { actorRegionsValid: this.cachedFocusRegionsValid } : {}),
|
|
737
748
|
prompt: this.cachedPrompt,
|
|
738
749
|
absenceWatchedFields: [...this.cachedAbsenceWatchedFields],
|
|
739
750
|
producerFields: this.cachedProducerFields,
|
|
@@ -744,7 +755,7 @@ class LocalSensingClient {
|
|
|
744
755
|
? [['person', this.cachedProducerOperatingPoints.get('person')]]
|
|
745
756
|
: [...this.cachedProducerOperatingPoints],
|
|
746
757
|
...(this.cachedDetectorCounts ? { detectorCounts: true } : {}),
|
|
747
|
-
...((this.scopedVlmReviewEnabled || this.usesWebsiteProfile()) && !this.cachedDetectorCounts && this.activeFieldSet === 'operator'
|
|
758
|
+
...(!actorOnly && (this.scopedVlmReviewEnabled || this.usesWebsiteProfile()) && !this.cachedDetectorCounts && this.activeFieldSet === 'operator'
|
|
748
759
|
&& (this.usesWebsiteProfile() && this.cachedVlmFields.length || this.cachedDeclaredProfileReview
|
|
749
760
|
|| this.cachedMixedFrameCounts || this.cachedAlertFocusRegions.size || !this.cachedFocusRegionsValid) ? { scopedVlmReview: {
|
|
750
761
|
version: 1, fieldSet: 'operator', fields: this.cachedVlmFields, regionsValid: this.cachedFocusRegionsValid,
|
|
@@ -826,12 +837,14 @@ class LocalSensingClient {
|
|
|
826
837
|
if (context && (context.version !== 1 || !context.schema || typeof context.prompt !== 'string' ||
|
|
827
838
|
!Array.isArray(context.producerFields) || !Array.isArray(context.regions) ||
|
|
828
839
|
!Array.isArray(context.operatingPoints) || !Array.isArray(context.absenceWatchedFields)
|
|
840
|
+
|| (context.actorRegionsValid !== undefined && typeof context.actorRegionsValid !== 'boolean')
|
|
829
841
|
|| (context.detectorCounts !== undefined && context.detectorCounts !== true))) {
|
|
830
842
|
throw new Error('Invalid retained sensing profile');
|
|
831
843
|
}
|
|
832
844
|
const capturedAtMs = request.capturedAt ?? Date.now();
|
|
833
845
|
const evidenceSha256 = (0, crypto_1.createHash)('sha256').update(request.jpeg).digest('hex');
|
|
834
846
|
let saved = request.cachedAnalysis;
|
|
847
|
+
const usedCachedAnalysis = !!saved;
|
|
835
848
|
const detectorCounts = context?.detectorCounts === true;
|
|
836
849
|
const scopedReview = context?.scopedVlmReview;
|
|
837
850
|
const capturedPolicy = (0, ReviewPriority_1.parseReviewPolicy)(context?.reviewPolicy);
|
|
@@ -840,6 +853,14 @@ class LocalSensingClient {
|
|
|
840
853
|
}
|
|
841
854
|
const requiredFields = (0, RetainedFieldContract_1.readFieldContract)(context?.retainedFieldContract);
|
|
842
855
|
const selection = (0, RuntimeModelSelection_1.retainedModelSelection)(context);
|
|
856
|
+
const actorActions = (0, ActorActionProducer_1.hasSelectedActorActions)(selection);
|
|
857
|
+
if (actorActions && context?.actorRegionsValid === false)
|
|
858
|
+
throw Error('Invalid captured actor focus geometry; original evidence retained');
|
|
859
|
+
const actorFields = new Set(selection?.tasks?.flatMap(task => task.task === 'actor_actions' ? task.fields : []) ?? []);
|
|
860
|
+
if (actorActions && (detectorCounts || scopedReview?.personCounts))
|
|
861
|
+
throw Error('Actor actions require ordinary selected field ownership, outside the local count comparison modes');
|
|
862
|
+
if (request.extra?.actorReview !== undefined)
|
|
863
|
+
throw Error('Actor review must come from the selected original action runtime');
|
|
843
864
|
if (saved?.runtimeSelectionSha256 !== undefined && !selection)
|
|
844
865
|
throw Error('Saved model-verified result requires its retained selection');
|
|
845
866
|
const vlmPin = selection?.models.find(model => model.format === 'litert-lm');
|
|
@@ -975,7 +996,7 @@ class LocalSensingClient {
|
|
|
975
996
|
if (!saved) {
|
|
976
997
|
const promptText = context?.prompt ?? this.cachedPrompt;
|
|
977
998
|
const schema = context?.schema ?? this.cachedSchema;
|
|
978
|
-
const fields = context?.producerFields ?? this.cachedProducerFields;
|
|
999
|
+
const fields = (context?.producerFields ?? this.cachedProducerFields).filter(field => !actorFields.has(field.field));
|
|
979
1000
|
const absence = context ? new Set(context.absenceWatchedFields) : this.cachedAbsenceWatchedFields;
|
|
980
1001
|
const regions = new Map(context?.regions ?? []);
|
|
981
1002
|
const producer = context && !this.producerInjected
|
|
@@ -1065,10 +1086,22 @@ class LocalSensingClient {
|
|
|
1065
1086
|
detectorProduced = Object.keys(producedBy).length ? producedBy : null;
|
|
1066
1087
|
this.producerFieldCollisions += collisions.length;
|
|
1067
1088
|
}
|
|
1089
|
+
const actorProduction = await this.actorActionProducer.produce(request, selection);
|
|
1090
|
+
if (actorProduction) {
|
|
1091
|
+
const summaries = (0, ActorReview_1.actorReviewSummary)(actorProduction.actorReview);
|
|
1092
|
+
for (const [field, value] of Object.entries(summaries)) {
|
|
1093
|
+
if (Object.prototype.hasOwnProperty.call(structured, field))
|
|
1094
|
+
throw Error('Actor action field collided with another model answer');
|
|
1095
|
+
structured[field] = value;
|
|
1096
|
+
}
|
|
1097
|
+
detectorProduced = { ...detectorProduced, ...Object.fromEntries(Object.entries(actorProduction.actorReview.models)
|
|
1098
|
+
.map(([field, model]) => [field, model.modelId])) };
|
|
1099
|
+
}
|
|
1068
1100
|
const analyzeMs = Date.now() - startedAt;
|
|
1069
1101
|
this.analyzeCost.record(analyzeMs);
|
|
1070
1102
|
saved = {
|
|
1071
1103
|
version: 1, structured, detectorProduced, analyzeMs, promptText,
|
|
1104
|
+
...(actorProduction ?? {}),
|
|
1072
1105
|
reviewedAtMs: Date.now(), evidenceSha256,
|
|
1073
1106
|
...(selection ? { runtimeSelectionSha256: (0, ProfileReviewWork_1.reviewContextHash)(context) } : {}),
|
|
1074
1107
|
// Zero can satisfy a below-count/absence rule too. Keep its evidence.
|
|
@@ -1080,7 +1113,9 @@ class LocalSensingClient {
|
|
|
1080
1113
|
}
|
|
1081
1114
|
// Also retry a previously failed disk commit before any upload. The spool
|
|
1082
1115
|
// keeps that answer in memory while disk recovers; inference is not repeated.
|
|
1083
|
-
(
|
|
1116
|
+
if (usedCachedAnalysis && (actorActions || saved.actorReview !== undefined || saved.actorActionRuns !== undefined || saved.actorPerceptionSha256 !== undefined))
|
|
1117
|
+
await this.actorActionProducer.produce(request, selection, saved);
|
|
1118
|
+
(0, RetainedFieldContract_1.assertCompleteFields)(requiredFields, saved.structured, saved.detectorProduced, saved.actorReview);
|
|
1084
1119
|
request.checkpointAnalysis?.(saved);
|
|
1085
1120
|
return saved;
|
|
1086
1121
|
}
|
|
@@ -1106,24 +1141,25 @@ class LocalSensingClient {
|
|
|
1106
1141
|
review.sourceReviewedAtMs = saved.sourceReviewedAtMs;
|
|
1107
1142
|
}
|
|
1108
1143
|
const selection = (0, RuntimeModelSelection_1.retainedModelSelection)(request.reviewContext);
|
|
1109
|
-
const selectedDetectorOnly = selection && selection.models.every(model => model.format === 'onnx')
|
|
1144
|
+
const selectedDetectorOnly = selection && !saved.actorReview && selection.models.every(model => model.format === 'onnx')
|
|
1110
1145
|
&& saved.analysisMethod === undefined;
|
|
1111
1146
|
const result = {
|
|
1112
1147
|
...saved.structured,
|
|
1113
|
-
source: selectedDetectorOnly || saved.analysisMethod === 'detector_counts_v1' ? 'detector_edge'
|
|
1148
|
+
source: saved.actorReview ? 'actor_edge' : selectedDetectorOnly || saved.analysisMethod === 'detector_counts_v1' ? 'detector_edge'
|
|
1114
1149
|
: saved.analysisMethod === 'scoped_detector_counts_v1' ? 'mixed_edge' : 'vlm_edge',
|
|
1115
1150
|
captured_at: new Date(capturedAtMs).toISOString(),
|
|
1116
1151
|
};
|
|
1117
1152
|
return this.uploadClient.analyzePreAnalyzed(result, {
|
|
1118
1153
|
capturedAt: capturedAtMs,
|
|
1119
1154
|
captureMode: request.captureMode,
|
|
1120
|
-
imageWidth: request.imageWidth,
|
|
1121
|
-
imageHeight: request.imageHeight,
|
|
1155
|
+
imageWidth: saved.actorReview?.frameSize.width ?? request.imageWidth,
|
|
1156
|
+
imageHeight: saved.actorReview?.frameSize.height ?? request.imageHeight,
|
|
1122
1157
|
analyzeMs: saved.analyzeMs,
|
|
1123
1158
|
promptText: saved.promptText,
|
|
1124
1159
|
...(saved.detectorProduced ? { detectorProduced: saved.detectorProduced } : {}),
|
|
1125
|
-
...((request.extra || review) ? {
|
|
1160
|
+
...((request.extra || review || saved.actorReview) ? {
|
|
1126
1161
|
extra: { ...request.extra, ...(review ? { evidenceReview: review } : {}),
|
|
1162
|
+
...(saved.actorReview ? { actorReview: saved.actorReview } : {}),
|
|
1127
1163
|
...(selectedDetectorOnly ? { selectedDetectorReview: {
|
|
1128
1164
|
version: 1, selectionSha256: saved.runtimeSelectionSha256,
|
|
1129
1165
|
fields: selection.fieldOwners.map(owner => owner.field), confidence: 'not_measured',
|
|
@@ -1151,52 +1187,49 @@ class LocalSensingClient {
|
|
|
1151
1187
|
}
|
|
1152
1188
|
exports.LocalSensingClient = LocalSensingClient;
|
|
1153
1189
|
/**
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
* Lower-only, for the reasons on the config key and at the call site. Returns
|
|
1158
|
-
* `undefined` for "operator said nothing", so the provider keeps its own
|
|
1159
|
-
* default rather than being handed a number this layer invented.
|
|
1160
|
-
*
|
|
1161
|
-
* Exported for tests: the whole point of this function is the clamp and the
|
|
1162
|
-
* warning, and neither is observable through `buildLocalSensingLoops` without
|
|
1163
|
-
* standing up a full loop set.
|
|
1190
|
+
* Validate the explicit occupancy policy once for every feed on a recorder.
|
|
1191
|
+
* Larger policies are valid: the provider still learns a smaller real ceiling
|
|
1192
|
+
* and reserves transient slots if the recorder refuses a persistent session.
|
|
1164
1193
|
*/
|
|
1165
1194
|
function resolveMaxStreamSessionsPerSource(requested, warn = (m) => console.warn(m)) {
|
|
1166
1195
|
if (requested === undefined || requested === null)
|
|
1167
1196
|
return undefined;
|
|
1168
|
-
//
|
|
1169
|
-
// (see the note at the top of config.ts), so it is required at runtime, never
|
|
1170
|
-
// imported. A host without it cannot run the persistent lane at all, and the
|
|
1171
|
-
// operator's own number is the only sane fallback there.
|
|
1197
|
+
// edge-platform-rtsp remains optional for callers that inject providers.
|
|
1172
1198
|
let builtIn;
|
|
1173
1199
|
try {
|
|
1174
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
1175
1200
|
({ DEFAULT_MAX_STREAM_SESSIONS_PER_SOURCE: builtIn } = require('@trillboards/edge-platform-rtsp'));
|
|
1176
1201
|
}
|
|
1177
1202
|
catch {
|
|
1178
|
-
builtIn = Number.
|
|
1203
|
+
builtIn = Number.MAX_SAFE_INTEGER;
|
|
1179
1204
|
}
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
: Math.min(builtIn, Number.MAX_SAFE_INTEGER);
|
|
1186
|
-
// Compared against what the OPERATOR WROTE, not against the truncated value:
|
|
1187
|
-
// `2.9` running as `2` is an adjustment they never asked for, and a rounding
|
|
1188
|
-
// that reports itself as agreement is the same silent clamp one decimal place
|
|
1189
|
-
// down.
|
|
1190
|
-
if (!Number.isFinite(Number(requested)) || Number(requested) !== effective) {
|
|
1205
|
+
const parsed = Number(requested);
|
|
1206
|
+
const effective = Number.isFinite(parsed)
|
|
1207
|
+
? Math.max(1, Math.min(Number.MAX_SAFE_INTEGER, Math.trunc(parsed)))
|
|
1208
|
+
: builtIn;
|
|
1209
|
+
if (!Number.isFinite(parsed) || parsed !== effective) {
|
|
1191
1210
|
warn(`cloudSensing.maxStreamSessionsPerSource=${requested} is not usable — running ${effective} ` +
|
|
1192
|
-
|
|
1193
|
-
`admission pools are shared per recorder and reconciled downward, so a higher value ` +
|
|
1194
|
-
`would apply only to whichever feed opened that recorder first. Lower it to leave ` +
|
|
1195
|
-
`sessions for the recorder's other clients — a recorder with more room to give is ` +
|
|
1196
|
-
`already discovered on its own.`);
|
|
1211
|
+
'persistent session(s) per recorder.');
|
|
1197
1212
|
}
|
|
1198
1213
|
return effective;
|
|
1199
1214
|
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Count the actual RTSP providers built by the shared mosaic topology.
|
|
1217
|
+
* A configured mosaic source needs one session; orphan tiles each need their
|
|
1218
|
+
* own. Recorder keys and grouping are the same owners used by capture itself.
|
|
1219
|
+
*/
|
|
1220
|
+
function persistentStreamDemandBySource(feeds) {
|
|
1221
|
+
const { captureSourceKey } = require('@trillboards/edge-platform-rtsp');
|
|
1222
|
+
const demand = new Map();
|
|
1223
|
+
for (const [key, members] of (0, CloudSensingManager_1.groupCameraSourceFeeds)(feeds)) {
|
|
1224
|
+
const source = members.find(feed => feed.id === key);
|
|
1225
|
+
for (const feed of source ? [source] : members) {
|
|
1226
|
+
const recorder = captureSourceKey(feed.rtspUrl);
|
|
1227
|
+
if (recorder !== null)
|
|
1228
|
+
demand.set(recorder, (demand.get(recorder) ?? 0) + 1);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
return demand;
|
|
1232
|
+
}
|
|
1200
1233
|
/** Under the connector's data root: one directory per recording feed. */
|
|
1201
1234
|
exports.VIDEO_SEGMENTS_DIRNAME = 'video-segments';
|
|
1202
1235
|
/**
|
|
@@ -1304,37 +1337,12 @@ function buildLocalSensingLoops(config, deps) {
|
|
|
1304
1337
|
* feeds did. So the worst case of this change is the behaviour that shipped
|
|
1305
1338
|
* before it.
|
|
1306
1339
|
*/
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
* ── WHY THIS EXISTS AT ALL ────────────────────────────────────────────────
|
|
1312
|
-
*
|
|
1313
|
-
* `maxStreamSessionsPerSource` has been on `RTSPStreamCameraConfig` and
|
|
1314
|
-
* honored by its constructor since the persistent lane shipped, and this —
|
|
1315
|
-
* the only production instantiation of that provider in the tree — never
|
|
1316
|
-
* passed it, while `config.ts` declared no key for it. So the field was
|
|
1317
|
-
* settable by a test and by nobody else, and the effective value was always
|
|
1318
|
-
* the built-in.
|
|
1319
|
-
*
|
|
1320
|
-
* ── WHY IT CAN ONLY LOWER ─────────────────────────────────────────────────
|
|
1321
|
-
*
|
|
1322
|
-
* Admission pools are keyed per recorder and SHARED by every feed on it, and
|
|
1323
|
-
* `streamAdmissionFor` reconciles an existing pool downward. A raise would
|
|
1324
|
-
* therefore take effect only if this feed were the first to open that
|
|
1325
|
-
* recorder — and above the recorder's real ceiling it walks straight back
|
|
1326
|
-
* into the defect the learned ceiling exists to fix, where our own sessions
|
|
1327
|
-
* fill the box and the per-grab fallback has nowhere to go.
|
|
1328
|
-
*
|
|
1329
|
-
* The direction that IS useful is down, and it is the one thing the connector
|
|
1330
|
-
* cannot discover for itself: `learnCeiling` only fires once WE have been
|
|
1331
|
-
* refused, by which point we already hold the sessions the venue's own grid
|
|
1332
|
-
* view wanted. That is knowledge the operator has and we do not.
|
|
1333
|
-
*
|
|
1334
|
-
* A refused raise is SAID, once, because a clamp nobody is told about is a
|
|
1335
|
-
* silent clamp — the same standard `formatDeployedCadence` is held to.
|
|
1336
|
-
*/
|
|
1340
|
+
// Resolve one explicit policy for all feeds before any session is admitted.
|
|
1341
|
+
// Without a policy, size each recorder's pool for its configured physical
|
|
1342
|
+
// streams. The direct provider's 16-session default cannot cover a 32-channel
|
|
1343
|
+
// deployment and never increases through learnCeiling (which only lowers).
|
|
1337
1344
|
const maxStreamSessionsPerSource = resolveMaxStreamSessionsPerSource(config.cloudSensing?.maxStreamSessionsPerSource);
|
|
1345
|
+
let persistentStreamDemand;
|
|
1338
1346
|
/**
|
|
1339
1347
|
* VIDEO — the same persistent session records the camera's own bitstream as
|
|
1340
1348
|
* MP4 segments (a stream copy: no decode, no second RTSP session), and a
|
|
@@ -1358,10 +1366,14 @@ function buildLocalSensingLoops(config, deps) {
|
|
|
1358
1366
|
const rtspFactory = deps?.rtspProviderFactory ??
|
|
1359
1367
|
((feed) => {
|
|
1360
1368
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
1361
|
-
const { RTSPStreamCameraProvider } = require('@trillboards/edge-platform-rtsp');
|
|
1369
|
+
const { RTSPStreamCameraProvider, DEFAULT_MAX_STREAM_SESSIONS_PER_SOURCE, captureSourceKey, } = require('@trillboards/edge-platform-rtsp');
|
|
1370
|
+
persistentStreamDemand ?? (persistentStreamDemand = persistentStreamDemandBySource(feeds));
|
|
1371
|
+
const sourceKey = captureSourceKey(feed.rtspUrl);
|
|
1372
|
+
const sessionLimit = maxStreamSessionsPerSource ?? Math.max(DEFAULT_MAX_STREAM_SESSIONS_PER_SOURCE, sourceKey === null ? 0 : persistentStreamDemand.get(sourceKey) ?? 0);
|
|
1362
1373
|
const legacy = (0, legacyRecorderProfile_1.legacyRecorderRtspOptions)(feed.sourceType);
|
|
1363
1374
|
const provider = new RTSPStreamCameraProvider({
|
|
1364
1375
|
rtspUrl: feed.rtspUrl,
|
|
1376
|
+
// Mosaic crops and evidence metadata share this configured pixel canvas.
|
|
1365
1377
|
width: feed.width,
|
|
1366
1378
|
height: feed.height,
|
|
1367
1379
|
transport: feed.transport,
|
|
@@ -1374,7 +1386,9 @@ function buildLocalSensingLoops(config, deps) {
|
|
|
1374
1386
|
// How many persistent sessions this connector may hold against the
|
|
1375
1387
|
// recorder this feed lives on. Shared per `host:port`, so every feed
|
|
1376
1388
|
// passes the same resolved number and the pool reconciles them.
|
|
1377
|
-
|
|
1389
|
+
maxStreamSessionsPerSource: sessionLimit,
|
|
1390
|
+
...(config.cloudSensing?.streamStartupTimeoutMs !== undefined
|
|
1391
|
+
? { startupTimeoutMs: config.cloudSensing.streamStartupTimeoutMs } : {}),
|
|
1378
1392
|
// A look reads the NEWEST decoded frame, so the stream must produce one
|
|
1379
1393
|
// at least as often as the connector looks. 4 fps against a 500 ms look
|
|
1380
1394
|
// cadence leaves 2x headroom, which is what keeps `getFrame()` from ever
|