@camstack/types 1.2.316 → 1.2.318

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.
@@ -0,0 +1,75 @@
1
+ import type { DeviceDemand } from './plan-schemas.js';
2
+ /** How a camera's detection runs. `disabled` cameras charge nothing. */
3
+ export type BestSettingsDetectionMode = 'always-on' | 'on-motion' | 'disabled';
4
+ /** One camera's detection load. */
5
+ export interface BestSettingsCameraLoad {
6
+ readonly deviceId: number;
7
+ readonly mode: BestSettingsDetectionMode;
8
+ /** Detection frames per second while a session runs. */
9
+ readonly fps: number;
10
+ /** False when only the camera's own (onboard) detector runs — no pipeline root. */
11
+ readonly runsPipelineRoot: boolean;
12
+ /** The node an always-on camera stands on; null when not placed (on-motion). */
13
+ readonly standingNodeId: string | null;
14
+ /** The operator's node pin (`pipelineNodeId`), or null. */
15
+ readonly nodePinId: string | null;
16
+ /**
17
+ * An operator pin of this camera to one device. `nodeId` null = the pin
18
+ * names only a deviceKey (no node pin, no standing node): it resolves to the
19
+ * one node that has that key, or is ignored when several or none do.
20
+ */
21
+ readonly devicePin: {
22
+ readonly nodeId: string | null;
23
+ readonly deviceKey: string;
24
+ } | null;
25
+ }
26
+ /** The cluster-wide peak of parallel sessions (sum over every device at one census). */
27
+ export interface ObservedClusterPeak {
28
+ readonly peakSessions: number;
29
+ readonly observedForMs: number;
30
+ }
31
+ /** Share placement input: node shares and the cluster-wide peak. */
32
+ export interface DemandShares {
33
+ /** nodeId → share (any scale). Device shares are the eligible devices' weights. */
34
+ readonly nodes: Readonly<Record<string, number>>;
35
+ readonly clusterPeak: ObservedClusterPeak | null;
36
+ }
37
+ /** A device the balancer may place a session on. */
38
+ export interface BestSettingsEligibleDevice {
39
+ readonly nodeId: string;
40
+ readonly deviceKey: string;
41
+ readonly weight: number;
42
+ }
43
+ /** The observed peak of concurrent sessions on one device. */
44
+ export interface ObservedDevicePeak {
45
+ readonly nodeId: string;
46
+ /** `''` = the node's sessions as a whole (a single-device node reports no per-device rows). */
47
+ readonly deviceKey: string;
48
+ /** Most sessions attached at once in the window. */
49
+ readonly peakSessions: number;
50
+ /** How long the device has been observed (ms) — the window is complete at 24 h. */
51
+ readonly observedForMs: number;
52
+ }
53
+ /** The on-motion load model's knobs. */
54
+ export interface DemandOptions {
55
+ /** Share of on-motion cameras assumed concurrent when there is no full observation. */
56
+ readonly onMotionConcurrency: number;
57
+ /** Minimum concurrent on-motion sessions assumed (capped at the camera count). */
58
+ readonly onMotionMinConcurrent: number;
59
+ }
60
+ export declare const DEFAULT_DEMAND_OPTIONS: DemandOptions;
61
+ /** A full observation window. */
62
+ export declare const OBSERVATION_WINDOW_MS: number;
63
+ /** Concurrent on-motion sessions assumed cluster-wide without an observation. */
64
+ export declare function estimatedConcurrentSessions(cameraCount: number, options: DemandOptions): number;
65
+ /**
66
+ * Demand on every eligible device of the cluster.
67
+ */
68
+ export declare function estimateDeviceDemand(input: {
69
+ readonly cameras: readonly BestSettingsCameraLoad[];
70
+ readonly eligible: readonly BestSettingsEligibleDevice[];
71
+ readonly peaks: readonly ObservedDevicePeak[];
72
+ readonly options?: DemandOptions;
73
+ /** Present ⇒ share placement (D748); absent ⇒ least-loaded. */
74
+ readonly shares?: DemandShares;
75
+ }): readonly DeviceDemand[];
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Measured YOLOv9 detector latency per hardware class × accelerator, and the
3
+ * person accuracy each model reaches at its shipped floor — the data the Best
4
+ * settings recommender picks from (D745).
5
+ *
6
+ * Transcribed from `docs/benchmarks/detector-latency.json` (latency) and
7
+ * `docs/benchmarks/model-floors.json` (person precision / recall at the
8
+ * shipped floor). `__tests__/detector-performance.spec.ts` holds both tables
9
+ * equal to those files, so a re-measurement replaces the JSON and this file
10
+ * together. Only the YOLOv9 t/s/m family is here: the cluster runs ONE family
11
+ * (YOLOv9 — the one that runs well on every accelerator class measured), and
12
+ * tier c is not offered (a few recall points for 25–50 % more latency).
13
+ */
14
+ import type { AcceleratorKind, HardwareClassId } from './plan-schemas.js';
15
+ /** One measured (or derived) latency cell. */
16
+ export interface DetectorLatencyCell {
17
+ /** Single-request median latency. */
18
+ readonly p50Ms: number;
19
+ /** Throughput ceiling of one accelerator running only this model. */
20
+ readonly fps: number;
21
+ /** False for a cell derived from another column (scaled), not measured. */
22
+ readonly measured: boolean;
23
+ }
24
+ /** `modelId → cell` for one (hardware class, accelerator) column. */
25
+ export type DetectorLatencyColumn = Readonly<Record<string, DetectorLatencyCell>>;
26
+ /** The latency table: hardware class → accelerator → column. */
27
+ export type DetectorPerfTable = Readonly<Partial<Record<HardwareClassId, Readonly<Partial<Record<AcceleratorKind, DetectorLatencyColumn>>>>>>;
28
+ /** Person precision / recall of one model at its shipped person floor. */
29
+ export interface DetectorAccuracy {
30
+ readonly personPrecision: number;
31
+ readonly personRecall: number;
32
+ }
33
+ export declare const DETECTOR_PERF: DetectorPerfTable;
34
+ export declare const DETECTOR_ACCURACY: Readonly<Record<string, DetectorAccuracy>>;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Static hardware classification for the Best settings recommender (D745).
3
+ *
4
+ * A node is classified from the facts its platform probe already reports —
5
+ * `cpuModel`, `arch`, `gpu`, `npu` — never from a benchmark. The class picks a
6
+ * column of the measured latency table (`detector-performance.ts`); a node
7
+ * whose CPU matches no measured class is `unknown` and the recommender leaves
8
+ * it alone, saying so.
9
+ *
10
+ * `cpuModel` is the host's CPU string even inside Docker (`os.cpus()`), which
11
+ * is why it is the discriminator: "Intel(R) Core(TM) Ultra 7 265K",
12
+ * "Intel(R) N100", "Apple M2", "Apple M3 Pro".
13
+ */
14
+ import type { HardwareInfo } from '../../interfaces/platform.js';
15
+ import type { AcceleratorKind, HardwareClassId } from './plan-schemas.js';
16
+ /** Apple silicon generation and variant, parsed from `cpuModel`. */
17
+ export interface AppleChip {
18
+ readonly generation: number;
19
+ readonly variant: 'base' | 'pro' | 'max' | 'ultra';
20
+ }
21
+ /** How a node was classified. */
22
+ export interface HardwareClassification {
23
+ readonly hardwareClass: HardwareClassId;
24
+ /** The CPU string the class was read from, for the plan's reasons. */
25
+ readonly cpuModel: string;
26
+ readonly apple?: AppleChip;
27
+ }
28
+ /**
29
+ * Classify a node. Apple base chips (M1–M4) map to the measured M2 column, the
30
+ * Pro/Max/Ultra chips to the measured M3 Pro column — the M2 was measured at
31
+ * 1.0–1.2× the M3 Pro on the Neural Engine, so the generation inside a variant
32
+ * matters less than the column's own error.
33
+ */
34
+ export declare function classifyInferenceHardware(hw: HardwareInfo): HardwareClassification;
35
+ /**
36
+ * The accelerator kind of one of a node's device keys (`openvino:npu`,
37
+ * `openvino:gpu`, `coreml:all`, `edgetpu:usb`, `cpu`, `onnx:cpu`, …). `null`
38
+ * for a key this table has no column for.
39
+ */
40
+ export declare function acceleratorKindOf(deviceKey: string, hw: HardwareInfo): AcceleratorKind | null;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Best settings (D745): the static-hardware × measured-latency × demand
3
+ * recommender of ONE detector family for the whole cluster, and the shapes of
4
+ * its plan. See `recommend.ts`.
5
+ */
6
+ export * from './hardware-class.js';
7
+ export * from './detector-performance.js';
8
+ export * from './demand.js';
9
+ export * from './recommend.js';
10
+ export * from './plan-schemas.js';