@camstack/types 1.2.319 → 1.2.321

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.
@@ -100,8 +100,30 @@ export declare const PlacementStatsSchema: z.ZodObject<{
100
100
  }, z.core.$strip>>>;
101
101
  }, z.core.$strip>;
102
102
  export type PlacementStats = z.infer<typeof PlacementStatsSchema>;
103
+ /**
104
+ * Where an automatic share's capacity comes from (D755).
105
+ * - `hardware` — the static capacity of each device at its Auto tune model:
106
+ * the measured latency table for the node's hardware class.
107
+ * - `benchmark` — the node's own measured capacity (node benchmark results).
108
+ * A node with no results falls back to `hardware`, and says so.
109
+ */
110
+ export declare const CapacitySourceSchema: z.ZodEnum<{
111
+ hardware: "hardware";
112
+ benchmark: "benchmark";
113
+ }>;
114
+ export type CapacitySource = z.infer<typeof CapacitySourceSchema>;
115
+ /** Why a node under the `benchmark` source was sized from hardware instead. */
116
+ export declare const CapacityFallbackSchema: z.ZodEnum<{
117
+ "no-benchmark-results": "no-benchmark-results";
118
+ "partial-benchmark-results": "partial-benchmark-results";
119
+ }>;
120
+ export type CapacityFallback = z.infer<typeof CapacityFallbackSchema>;
103
121
  export declare const SuggestSharesInputSchema: z.ZodObject<{
104
122
  headroom: z.ZodDefault<z.ZodNumber>;
123
+ source: z.ZodDefault<z.ZodEnum<{
124
+ hardware: "hardware";
125
+ benchmark: "benchmark";
126
+ }>>;
105
127
  }, z.core.$strip>;
106
128
  export type SuggestSharesInput = z.infer<typeof SuggestSharesInputSchema>;
107
129
  export declare const SuggestedDeviceShareSchema: z.ZodObject<{
@@ -126,12 +148,24 @@ export declare const SuggestedNodeShareSchema: z.ZodObject<{
126
148
  suggestedMaxSessions: z.ZodNullable<z.ZodNumber>;
127
149
  }, z.core.$strip>>>;
128
150
  skippedReason: z.ZodNullable<z.ZodString>;
151
+ capacitySource: z.ZodNullable<z.ZodEnum<{
152
+ hardware: "hardware";
153
+ benchmark: "benchmark";
154
+ }>>;
155
+ capacityFallback: z.ZodNullable<z.ZodEnum<{
156
+ "no-benchmark-results": "no-benchmark-results";
157
+ "partial-benchmark-results": "partial-benchmark-results";
158
+ }>>;
129
159
  }, z.core.$strip>;
130
160
  export type SuggestedNodeShare = z.infer<typeof SuggestedNodeShareSchema>;
131
161
  export declare const SuggestSharesResultSchema: z.ZodObject<{
132
162
  headroom: z.ZodNumber;
163
+ source: z.ZodEnum<{
164
+ hardware: "hardware";
165
+ benchmark: "benchmark";
166
+ }>;
133
167
  cameraFps: z.ZodNumber;
134
- iterations: z.ZodNumber;
168
+ minSessionsPerDevice: z.ZodNumber;
135
169
  nodes: z.ZodReadonly<z.ZodArray<z.ZodObject<{
136
170
  nodeId: z.ZodString;
137
171
  share: z.ZodNullable<z.ZodNumber>;
@@ -145,34 +179,52 @@ export declare const SuggestSharesResultSchema: z.ZodObject<{
145
179
  suggestedMaxSessions: z.ZodNullable<z.ZodNumber>;
146
180
  }, z.core.$strip>>>;
147
181
  skippedReason: z.ZodNullable<z.ZodString>;
182
+ capacitySource: z.ZodNullable<z.ZodEnum<{
183
+ hardware: "hardware";
184
+ benchmark: "benchmark";
185
+ }>>;
186
+ capacityFallback: z.ZodNullable<z.ZodEnum<{
187
+ "no-benchmark-results": "no-benchmark-results";
188
+ "partial-benchmark-results": "partial-benchmark-results";
189
+ }>>;
148
190
  }, z.core.$strip>>>;
149
191
  }, z.core.$strip>;
150
192
  export type SuggestSharesResult = z.infer<typeof SuggestSharesResultSchema>;
151
193
  /**
152
- * Where the node and device shares come from (D750).
153
- * - `auto` — computed by the system from the cluster's measured capacity at
154
- * the Auto tune models, and recomputed whenever a node or device joins,
155
- * leaves, is switched on or off, or changes model.
156
- * - `manual` — the operator's stored sliders. A node or device that cannot
157
- * take sessions gives its share to the others in proportion; the stored
158
- * values are never rewritten for that.
194
+ * Where the node and device shares come from (D750, D755).
195
+ * - `hardware` (default) — computed by the system from each node's static
196
+ * capacity (its accelerators at their Auto tune models, from the measured
197
+ * latency table), recomputed whenever a node or device joins, leaves, is
198
+ * switched on or off, or changes model. No load input.
199
+ * - `benchmark` — the same, from each node's measured capacity (node
200
+ * benchmark results); a node without results falls back to `hardware`.
201
+ * - `manual` — the operator's stored sliders.
202
+ * Either way a node or device that cannot take sessions gives its share to
203
+ * the others in proportion; the stored values are never rewritten for that.
159
204
  */
160
205
  export declare const ShareSourceSchema: z.ZodEnum<{
161
206
  manual: "manual";
162
- auto: "auto";
207
+ hardware: "hardware";
208
+ benchmark: "benchmark";
163
209
  }>;
164
210
  export type ShareSource = z.infer<typeof ShareSourceSchema>;
165
211
  export declare const DEFAULT_SHARE_SOURCE: ShareSource;
212
+ /** `hardware` or `benchmark`: the system computes the shares. */
213
+ export declare function isAutomaticShareSource(source: ShareSource): source is Exclude<ShareSource, 'manual'>;
166
214
  /** Headroom the automatic shares are computed at (Auto tune's default). */
167
215
  export declare const AUTO_SHARE_HEADROOM = 0.4;
168
216
  /** The global-settings key the share source is stored under (orchestrator `load` section). */
169
217
  export declare const SHARE_SOURCE_SETTING_KEY = "shareSource";
170
- /** Parse a stored value; anything unknown is the default. */
218
+ /**
219
+ * Parse a stored value; anything unknown is the default. `auto` (D750, before
220
+ * D755 split it) reads as `hardware` — that is what it computed.
221
+ */
171
222
  export declare function parseShareSource(value: unknown): ShareSource;
172
223
  export declare const SetShareSourceInputSchema: z.ZodObject<{
173
224
  source: z.ZodEnum<{
174
225
  manual: "manual";
175
- auto: "auto";
226
+ hardware: "hardware";
227
+ benchmark: "benchmark";
176
228
  }>;
177
229
  }, z.core.$strip>;
178
230
  export type SetShareSourceInput = z.infer<typeof SetShareSourceInputSchema>;
@@ -194,6 +246,14 @@ export declare const EffectiveNodeShareSchema: z.ZodObject<{
194
246
  eligible: z.ZodBoolean;
195
247
  configuredPct: z.ZodNumber;
196
248
  effectivePct: z.ZodNumber;
249
+ capacitySource: z.ZodNullable<z.ZodEnum<{
250
+ hardware: "hardware";
251
+ benchmark: "benchmark";
252
+ }>>;
253
+ capacityFallback: z.ZodNullable<z.ZodEnum<{
254
+ "no-benchmark-results": "no-benchmark-results";
255
+ "partial-benchmark-results": "partial-benchmark-results";
256
+ }>>;
197
257
  devices: z.ZodReadonly<z.ZodArray<z.ZodObject<{
198
258
  deviceKey: z.ZodString;
199
259
  eligible: z.ZodBoolean;
@@ -205,7 +265,8 @@ export type EffectiveNodeShare = z.infer<typeof EffectiveNodeShareSchema>;
205
265
  export declare const EffectiveSharesSchema: z.ZodObject<{
206
266
  source: z.ZodEnum<{
207
267
  manual: "manual";
208
- auto: "auto";
268
+ hardware: "hardware";
269
+ benchmark: "benchmark";
209
270
  }>;
210
271
  policy: z.ZodEnum<{
211
272
  "least-loaded": "least-loaded";
@@ -219,6 +280,14 @@ export declare const EffectiveSharesSchema: z.ZodObject<{
219
280
  eligible: z.ZodBoolean;
220
281
  configuredPct: z.ZodNumber;
221
282
  effectivePct: z.ZodNumber;
283
+ capacitySource: z.ZodNullable<z.ZodEnum<{
284
+ hardware: "hardware";
285
+ benchmark: "benchmark";
286
+ }>>;
287
+ capacityFallback: z.ZodNullable<z.ZodEnum<{
288
+ "no-benchmark-results": "no-benchmark-results";
289
+ "partial-benchmark-results": "partial-benchmark-results";
290
+ }>>;
222
291
  devices: z.ZodReadonly<z.ZodArray<z.ZodObject<{
223
292
  deviceKey: z.ZodString;
224
293
  eligible: z.ZodBoolean;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The layers of a detection step's settings, and the field-level edits on them
3
+ * (D754).
4
+ *
5
+ * A step's settings reach a session through up to three stored layers, merged
6
+ * key by key — a key in a higher layer wins:
7
+ *
8
+ * node the node's folded base (`inferenceDevices[node][*].steps`)
9
+ * camera `cameraSettings[cam].stepSettings[step]` — every accelerator
10
+ * accelerator `cameraSettings[cam].stepOverridesByDevice[node][key][step].settings`
11
+ *
12
+ * Below them sits the default: the running model's (D738) or the field's own.
13
+ *
14
+ * Every layer is SPARSE and FIELD-LEVEL. A key present in a layer is an
15
+ * override; an absent key inherits. Two consequences that every editor must
16
+ * respect, and why this module exists:
17
+ *
18
+ * - A model-bound field (D738) occupies TWO keys, its value and
19
+ * `<key>ModelId`. They are written, compared and removed as one unit — a
20
+ * value without its binding over a lower layer's binding would be judged
21
+ * against the wrong model.
22
+ * - An editor writes a DIFF against the merged layers below, never a copy of
23
+ * them. A copy pins every field at the value it had that day, so later
24
+ * edits below never reach it (the full-copy "Override" this replaced).
25
+ */
26
+ /** One stored settings layer. */
27
+ export type StepSettingsBag = Readonly<Record<string, unknown>>;
28
+ /** The stored layers, from the top. `undefined` = the layer stores nothing for this step. */
29
+ export interface StepSettingsLayers {
30
+ readonly accelerator?: StepSettingsBag;
31
+ readonly camera?: StepSettingsBag;
32
+ readonly node?: StepSettingsBag;
33
+ }
34
+ /** Which stored layer supplies a field, or `default` when none does. */
35
+ export type StepSettingSource = 'accelerator' | 'camera' | 'node' | 'default';
36
+ /**
37
+ * The keys one field occupies in a bag: its own, plus its binding key when it
38
+ * binds to a model. `boundKeys` = `collectModelBoundKeys(schema)`.
39
+ */
40
+ export declare function fieldUnitKeys(key: string, boundKeys: readonly string[]): readonly string[];
41
+ /** Structural equality for stored values (numbers, strings, booleans, arrays, plain objects). */
42
+ export declare function settingValuesEqual(a: unknown, b: unknown): boolean;
43
+ /** Merge bags bottom-up (later wins, per key). Fresh object. */
44
+ export declare function mergeSettingsBags(...bags: readonly (StepSettingsBag | undefined)[]): Record<string, unknown>;
45
+ /** The merged value of the layers BELOW `layer` (what removing a key from `layer` falls back to). */
46
+ export declare function settingsBelow(layers: StepSettingsLayers, layer: Exclude<StepSettingSource, 'default'>): Record<string, unknown>;
47
+ /** The effective bag: every stored layer merged. */
48
+ export declare function effectiveStepSettings(layers: StepSettingsLayers): Record<string, unknown>;
49
+ /** The highest stored layer that holds any key of `key`'s unit, or `default`. */
50
+ export declare function stepSettingSource(layers: StepSettingsLayers, key: string, boundKeys: readonly string[]): StepSettingSource;
51
+ /**
52
+ * `layer` with `key`'s unit set from `values` (a bag carrying the unit's new
53
+ * value — e.g. the editor's whole next settings bag). A unit key that `values`
54
+ * does not carry is removed from the layer. Fresh object.
55
+ */
56
+ export declare function withFieldFrom(layer: StepSettingsBag | undefined, key: string, values: StepSettingsBag, boundKeys: readonly string[]): Record<string, unknown>;
57
+ /** `layer` without `key`'s unit — "reset to the next level". Fresh object. */
58
+ export declare function withoutField(layer: StepSettingsBag | undefined, key: string, boundKeys: readonly string[]): Record<string, unknown>;
59
+ /**
60
+ * `layer` reduced to the fields that DIFFER from `below` — what an editor
61
+ * stores. A unit is kept or dropped whole. `undefined` when nothing is left.
62
+ */
63
+ export declare function diffStepSettings(layer: StepSettingsBag | undefined, below: StepSettingsBag, boundKeys: readonly string[]): Record<string, unknown> | undefined;
64
+ /**
65
+ * The fields `layer` stores at exactly the value of the layers below — a
66
+ * legacy full copy's leftovers. They change nothing today and stop every
67
+ * later edit below from reaching this layer. Sorted.
68
+ */
69
+ export declare function fieldsPinnedAtValueBelow(layer: StepSettingsBag | undefined, below: StepSettingsBag, boundKeys: readonly string[]): readonly string[];
@@ -3757,6 +3757,7 @@ function createDeviceProxy(api, binding, opts) {
3757
3757
  setCameraStepToggle: (input) => dispatchSystem("pipelineOrchestrator", "setCameraStepToggle", "mutation", input),
3758
3758
  getCameraStepOverrides: (input) => dispatchSystem("pipelineOrchestrator", "getCameraStepOverrides", "query", input),
3759
3759
  setCameraStepOverride: (input) => dispatchSystem("pipelineOrchestrator", "setCameraStepOverride", "mutation", input),
3760
+ setCameraStepSettings: (input) => dispatchSystem("pipelineOrchestrator", "setCameraStepSettings", "mutation", input),
3760
3761
  setCameraPipelineForAgent: (input) => dispatchSystem("pipelineOrchestrator", "setCameraPipelineForAgent", "mutation", input),
3761
3762
  resolvePipeline: (input) => dispatchSystem("pipelineOrchestrator", "resolvePipeline", "query", input),
3762
3763
  getCameraSwitches: (input) => dispatchSystem("pipelineOrchestrator", "getCameraSwitches", "query", input),
@@ -3757,6 +3757,7 @@ function createDeviceProxy(api, binding, opts) {
3757
3757
  setCameraStepToggle: (input) => dispatchSystem("pipelineOrchestrator", "setCameraStepToggle", "mutation", input),
3758
3758
  getCameraStepOverrides: (input) => dispatchSystem("pipelineOrchestrator", "getCameraStepOverrides", "query", input),
3759
3759
  setCameraStepOverride: (input) => dispatchSystem("pipelineOrchestrator", "setCameraStepOverride", "mutation", input),
3760
+ setCameraStepSettings: (input) => dispatchSystem("pipelineOrchestrator", "setCameraStepSettings", "mutation", input),
3760
3761
  setCameraPipelineForAgent: (input) => dispatchSystem("pipelineOrchestrator", "setCameraPipelineForAgent", "mutation", input),
3761
3762
  resolvePipeline: (input) => dispatchSystem("pipelineOrchestrator", "resolvePipeline", "query", input),
3762
3763
  getCameraSwitches: (input) => dispatchSystem("pipelineOrchestrator", "getCameraSwitches", "query", input),
@@ -158,6 +158,17 @@ export interface AgentPipelineSettings {
158
158
  */
159
159
  export interface CameraPipelineSettings {
160
160
  readonly stepToggles?: Readonly<Record<string, boolean>>;
161
+ /**
162
+ * Camera-wide step SETTINGS (D754): `[addonId] → { fieldKey → value }`, the
163
+ * fields this camera overrides on EVERY accelerator it is balanced onto. A
164
+ * sparse, field-level bag — a key present here is an override, an absent key
165
+ * inherits the node. Merge order at dispatch, per key:
166
+ * node (folded base) ⊕ this ⊕ `stepOverridesByDevice[node][deviceKey]`.
167
+ * A model-bound field (D738) is always written with its binding key.
168
+ * Settings only: a model is a per-accelerator question (formats differ), so
169
+ * it stays in `stepOverridesByDevice`.
170
+ */
171
+ readonly stepSettings?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
161
172
  /**
162
173
  * Per-(camera,node,device) model/settings override. Addressed by
163
174
  * `[agentNodeId][deviceKey][addonId]` because the camera is balanced onto
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/types",
3
- "version": "1.2.319",
3
+ "version": "1.2.321",
4
4
  "description": "Shared types, interfaces, and model catalogs for the CamStack detection ecosystem",
5
5
  "keywords": [
6
6
  "camstack",
@@ -1,75 +0,0 @@
1
- import type { DeviceDemand } from './plan-schemas.js';
2
- /** How a camera's detection runs. `disabled` cameras charge nothing. */
3
- export type AutoTuneDetectionMode = 'always-on' | 'on-motion' | 'disabled';
4
- /** One camera's detection load. */
5
- export interface AutoTuneCameraLoad {
6
- readonly deviceId: number;
7
- readonly mode: AutoTuneDetectionMode;
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 AutoTuneEligibleDevice {
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 AutoTuneCameraLoad[];
70
- readonly eligible: readonly AutoTuneEligibleDevice[];
71
- readonly peaks: readonly ObservedDevicePeak[];
72
- readonly options?: DemandOptions;
73
- /** Present ⇒ share placement (D748); absent ⇒ least-loaded. */
74
- readonly shares?: DemandShares;
75
- }): readonly DeviceDemand[];