@camstack/addon-decoder-nodeav 1.1.8 → 1.1.9

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 (3) hide show
  1. package/dist/index.js +502 -527
  2. package/dist/index.mjs +488 -523
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,276 +1,6 @@
1
- import { FrameRingReaderCache, FrameRingWriter, MIN_RING_SLOTS, computeSegmentSize, computeSlotByteLength, createSegment, deriveSlotCount, unlinkSegment } from "@camstack/shm-ring";
1
+ import { DecoderFrameRingSink, FrameRingReaderCache, RING_BUDGET_MB, SEGMENT_NAME_PREFIX, makeSegmentName, unlinkSegment } from "@camstack/shm-ring";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { readdirSync } from "node:fs";
4
- //#region src/frame-ring-sink.ts
5
- /**
6
- * `DecoderFrameRingSink` — the decoder's shared-memory write side (Phase 5 / D9).
7
- *
8
- * When a decoder session is configured with `frameSink: 'shm'`, the decoder
9
- * **owns** the shared-memory ring segment for that stream: it creates the
10
- * segment on the first decoded frame (when the output geometry is known),
11
- * writes every subsequent decoded frame into the ring via a `FrameRingWriter`,
12
- * and closes + unlinks the segment when the session is destroyed.
13
- *
14
- * What leaves the decoder is no longer the pixel `Buffer` — it is a tiny,
15
- * serialisable `FrameHandle` (`FrameRingWriter.writeFrame`'s return value).
16
- * Same-host consumers (motion, detection, the WebRTC encoder) open the same
17
- * segment with a `FrameRingReader` and read the pixels zero-copy.
18
- *
19
- * ## Lazy segment creation
20
- *
21
- * The segment cannot be sized until the first frame: `slotByteLength` is
22
- * `width × height × bytesPerPixel`, and the output dimensions are only known
23
- * once the scaler has produced its first `dstFrame`. So `writeFrame` is a
24
- * no-op-until-armed: the first call sizes + creates the segment, every later
25
- * call writes into it.
26
- *
27
- * ## Resolution-change decision
28
- *
29
- * A live camera stream can change resolution mid-stream (the decoder's scaler
30
- * is rebuilt on a config toggle, or the source renegotiates). The slot is
31
- * sized for the **first** frame's geometry. A later frame that no longer fits
32
- * the slot triggers a **segment re-create**: the old segment is closed +
33
- * unlinked and a fresh, larger segment is created under a new generation-tagged
34
- * name. This is simpler and leak-free versus over-allocating slots for a
35
- * worst-case 4K frame on every stream; resolution changes on a live camera are
36
- * rare, and a brief gap while consumers re-open the segment is acceptable
37
- * (latest-wins — a missed frame is correct behaviour).
38
- */
39
- /**
40
- * Per-ring shared-memory budget (MB) — the slot count is derived per-resolution
41
- * from this budget via {@link deriveSlotCount}, so a 360p stream gets many
42
- * slots and a 4K stream a few, both inside the same memory footprint.
43
- *
44
- * Read ONCE at module load from `CAMSTACK_SHM_RING_BUDGET_MB`; a non-finite or
45
- * non-positive value falls back to the 16 MB default.
46
- *
47
- * The default is deliberately small (16 MB) so many concurrent per-camera rings
48
- * fit inside a bounded `/dev/shm`. The decoder output is capped at 640px wide, so
49
- * a slot is ≤ ~920 KB and 16 MB still yields ~17–70 latest-wins slots. A ring
50
- * segment larger than the container's `/dev/shm` tmpfs backing (Docker default is
51
- * only 64 MB) faults an **uncatchable SIGBUS** on write past `st_size` — the old
52
- * 128 MB default overflowed a 64 MB `/dev/shm` and crashed the decoder on 8MP
53
- * streams. Pair this with a `--shm-size` that scales with concurrent-decode load.
54
- */
55
- var RING_BUDGET_MB = (() => {
56
- const raw = Number(process.env["CAMSTACK_SHM_RING_BUDGET_MB"]);
57
- return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : 16;
58
- })();
59
- /** {@link RING_BUDGET_MB} in bytes — the budget passed to `deriveSlotCount`. */
60
- var RING_BUDGET_BYTES = RING_BUDGET_MB * 1024 * 1024;
61
- /** A unique, stable shared-memory segment name for a decoder stream.
62
- *
63
- * macOS POSIX shm names are capped at ~31 characters (`PSHMNAMLEN`). A
64
- * `camstack.frames.<deviceId>.<streamId>` scheme overflows that for realistic
65
- * ids, so the sink uses a short, collision-resistant scheme instead:
66
- * `csf.<base36 hash>.<gen>`. The hash folds the device id, the session tag
67
- * and a per-process random salt; the generation suffix makes a re-created
68
- * segment (resolution change) a distinct name so a stale consumer mapping is
69
- * never silently reused.
70
- */
71
- /**
72
- * Shared prefix for every decoder shm segment name. Startup orphan reclamation
73
- * (`purgeOrphanSegments`) keys off this to find segments left behind by a
74
- * crashed prior instance.
75
- */
76
- var SEGMENT_NAME_PREFIX = "csf.";
77
- function makeSegmentName(seed, generation) {
78
- let hash = 5381;
79
- for (let i = 0; i < seed.length; i += 1) hash = (hash << 5) + hash + seed.charCodeAt(i) | 0;
80
- return `${SEGMENT_NAME_PREFIX}${(hash >>> 0).toString(36)}.${generation}`;
81
- }
82
- /**
83
- * The decoder-side owner of one stream's shared-memory frame ring.
84
- *
85
- * Not constructed until a session actually uses the shm sink; the segment
86
- * itself is created lazily on the first `writeFrame`.
87
- */
88
- var DecoderFrameRingSink = class {
89
- seed;
90
- logger;
91
- nodeId;
92
- segment = null;
93
- writer = null;
94
- segmentName = null;
95
- slotByteLength = 0;
96
- generation = 0;
97
- destroyed = false;
98
- /** Frames committed into the ring across this sink's lifetime (all generations). */
99
- framesWritten = 0;
100
- constructor(options) {
101
- const salt = Math.random().toString(36).slice(2, 8);
102
- this.seed = `${options.seed}.${salt}`;
103
- this.logger = options.logger;
104
- this.nodeId = options.nodeId;
105
- }
106
- /** Whether a segment has been created (i.e. at least one frame written). */
107
- get isArmed() {
108
- return this.writer !== null;
109
- }
110
- /** The current segment name, or `null` before the first frame. */
111
- get currentSegmentName() {
112
- return this.segmentName;
113
- }
114
- /**
115
- * Write one decoded frame into the ring and return its `FrameHandle`.
116
- *
117
- * On the first call (or after a geometry change that overflows the current
118
- * slot) the segment is created / re-created sized for this frame. Returns
119
- * `null` only when the sink has been destroyed.
120
- *
121
- * This is the copy-in convenience form (it copies `pixels` into the slot).
122
- * The decoder's hot path uses the zero-copy {@link beginFrame} /
123
- * {@link commitFrame} scatter-write pair instead — the scaler produces its
124
- * packed output directly into the slot, eliminating the write-side memcpy.
125
- */
126
- writeFrame(pixels, meta) {
127
- if (this.destroyed) return null;
128
- if (this.writer === null || computeSlotByteLength(meta.width, meta.height, meta.format) > this.slotByteLength) this.recreateSegment(computeSlotByteLength(meta.width, meta.height, meta.format));
129
- const writer = this.writer;
130
- if (writer === null) return null;
131
- const handle = writer.writeFrame(pixels, meta);
132
- this.framesWritten += 1;
133
- return handle;
134
- }
135
- /**
136
- * Reserve a ring slot for a frame of the given geometry — the **zero-copy**
137
- * scatter-write entry point (Phase 5 / D9 Task 7c).
138
- *
139
- * The segment is created / re-created here if this is the first frame or the
140
- * geometry overflows the current slot capacity, so the slot is correctly
141
- * sized before the caller fills it. The returned `buffer` is a writable view
142
- * **directly over the mapped segment** — the node-av scaler scatters its
143
- * packed output straight into it, with no intermediate copy. The caller MUST
144
- * call {@link commitFrame} with the returned `slot` once the slot is filled.
145
- *
146
- * Returns `null` when the sink is destroyed or the segment cannot be created.
147
- */
148
- beginFrame(width, height, format) {
149
- if (this.destroyed) return null;
150
- const requiredSlotBytes = computeSlotByteLength(width, height, format);
151
- if (this.writer === null || requiredSlotBytes > this.slotByteLength) this.recreateSegment(requiredSlotBytes);
152
- const writer = this.writer;
153
- if (writer === null) return null;
154
- const { slot, buffer } = writer.beginFrame();
155
- return {
156
- slot,
157
- buffer
158
- };
159
- }
160
- /**
161
- * Publish the frame whose slot was reserved by {@link beginFrame} and filled
162
- * in place by the caller. `slot` MUST be the value from the matching
163
- * `beginFrame`. Returns the published `FrameHandle`, or `null` if the sink
164
- * was destroyed (or the segment lost) between begin and commit.
165
- */
166
- commitFrame(slot, meta) {
167
- if (this.destroyed) return null;
168
- const writer = this.writer;
169
- if (writer === null) return null;
170
- const handle = writer.commitFrame(slot, meta);
171
- this.framesWritten += 1;
172
- return handle;
173
- }
174
- /**
175
- * Current shm ring usage — `null` until the first frame arms the segment.
176
- * Surfaced through `decoder.getShmStats` so a downstream consumer can
177
- * observe ring pressure (slot depth, byte budget, frames written).
178
- */
179
- getShmStats() {
180
- if (this.writer === null) return null;
181
- return {
182
- slotCount: this.writer.slotCount,
183
- slotByteLength: this.slotByteLength,
184
- segmentBytes: computeSegmentSize(this.writer.slotCount, this.slotByteLength),
185
- framesWritten: this.framesWritten
186
- };
187
- }
188
- /**
189
- * Abandon a slot reserved by {@link beginFrame} **without publishing it** —
190
- * the degenerate-path counterpart of {@link commitFrame}.
191
- *
192
- * A caller that reserved a slot but then could not produce valid pixels (no
193
- * decoded source planes, or the scaler threw) MUST call this instead of
194
- * `commitFrame`: it closes the open seqlock without advancing `writeIndex`,
195
- * so no reader ever sees the slot's uninitialised bytes as a real frame, and
196
- * no `FrameHandle` is handed downstream. `slot` MUST be the value from the
197
- * matching `beginFrame`. A no-op if the sink was destroyed (or the segment
198
- * lost) between begin and abort.
199
- */
200
- abortFrame(slot) {
201
- if (this.destroyed) return;
202
- const writer = this.writer;
203
- if (writer === null) return;
204
- writer.abortFrame(slot);
205
- }
206
- /** Close + unlink the segment. Idempotent. */
207
- destroy() {
208
- if (this.destroyed) return;
209
- this.destroyed = true;
210
- this.releaseSegment();
211
- }
212
- /**
213
- * Create a fresh segment sized for at least `slotByteLength` bytes per slot,
214
- * replacing any prior one. A re-create bumps the generation so the new
215
- * segment has a distinct name — a consumer holding the old mapping is never
216
- * silently handed a resized segment.
217
- */
218
- recreateSegment(slotByteLength) {
219
- this.releaseSegment();
220
- this.generation += 1;
221
- const name = makeSegmentName(this.seed, this.generation);
222
- const slotCount = deriveSlotCount(RING_BUDGET_BYTES, slotByteLength);
223
- if (slotCount === MIN_RING_SLOTS && MIN_RING_SLOTS * slotByteLength > RING_BUDGET_BYTES) this.logger.warn("decoder shm ring: budget too small for resolution — using MIN slots", { meta: {
224
- slotByteLength,
225
- budgetMb: RING_BUDGET_MB
226
- } });
227
- const totalBytes = computeSegmentSize(slotCount, slotByteLength);
228
- try {
229
- const segment = createSegment(name, totalBytes);
230
- this.segment = segment;
231
- this.segmentName = name;
232
- this.slotByteLength = slotByteLength;
233
- this.writer = new FrameRingWriter(segment.buffer, name, slotCount, slotByteLength, this.nodeId);
234
- this.logger.info("decoder shm ring: segment created", { meta: {
235
- segment: name,
236
- slotCount,
237
- slotByteLength,
238
- totalBytes,
239
- generation: this.generation
240
- } });
241
- } catch (err) {
242
- this.segment = null;
243
- this.writer = null;
244
- this.segmentName = null;
245
- this.slotByteLength = 0;
246
- this.logger.error("decoder shm ring: segment create failed", { meta: {
247
- segment: name,
248
- slotByteLength,
249
- error: err instanceof Error ? err.message : String(err)
250
- } });
251
- }
252
- }
253
- /** Unmap + unlink the current segment, if any. */
254
- releaseSegment() {
255
- const segment = this.segment;
256
- if (segment === null) return;
257
- this.segment = null;
258
- this.writer = null;
259
- const name = this.segmentName;
260
- this.segmentName = null;
261
- try {
262
- segment.close();
263
- segment.unlink();
264
- this.logger.info("decoder shm ring: segment released", { meta: { segment: name } });
265
- } catch (err) {
266
- this.logger.warn("decoder shm ring: segment release failed", { meta: {
267
- segment: name,
268
- error: err instanceof Error ? err.message : String(err)
269
- } });
270
- }
271
- }
272
- };
273
- //#endregion
274
4
  //#region ../../node_modules/zod/v4/core/core.js
275
5
  var _a$1;
276
6
  function $constructor(name, initializer, params) {
@@ -4900,7 +4630,7 @@ function _instanceof(cls, params = {}) {
4900
4630
  return inst;
4901
4631
  }
4902
4632
  //#endregion
4903
- //#region ../types/dist/sleep-CZDdRBua.mjs
4633
+ //#region ../types/dist/sleep-DJaTV2D7.mjs
4904
4634
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4905
4635
  EventCategory["SystemBoot"] = "system.boot";
4906
4636
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5086,6 +4816,18 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
5086
4816
  */
5087
4817
  EventCategory["PipelineCameraUpdated"] = "pipeline.camera-updated";
5088
4818
  /**
4819
+ * The cluster camera-source OWNER changed (`clusterRoles.ingestNode`).
4820
+ * Emitted by addon-pipeline-orchestrator whenever it (re)derives node
4821
+ * capabilities — at boot, on agent online/offline, and on an ingest-node
4822
+ * flip. Carries the resolved `ownerNodeId`. The stream-broker consumes it to
4823
+ * keep its ingest-owner-gate decision current WITHOUT a per-`ensureBroker`
4824
+ * cross-process `getIngestOwner` query (push the authority's decision instead
4825
+ * of polling it on the hot path). Idempotent state — re-emitted on every
4826
+ * topology change, so a dropped event self-heals on the next one (plus the
4827
+ * broker's long backstop reconcile query).
4828
+ */
4829
+ EventCategory["PipelineIngestOwnerChanged"] = "pipeline.ingest-owner-changed";
4830
+ /**
5089
4831
  * Periodic snapshot of per-node pipeline-runner load
5090
4832
  * (`RunnerLocalLoad`). Emitted ~1Hz by every runner so UI dashboards
5091
4833
  * subscribe instead of polling `pipelineRunner.getLocalLoad`.
@@ -5609,10 +5351,6 @@ function hydrateField(field, values) {
5609
5351
  };
5610
5352
  }
5611
5353
  const rawValue = storedValue !== void 0 ? storedValue : defaultValue !== void 0 ? defaultValue : null;
5612
- if (field.type === "password") return {
5613
- ...field,
5614
- value: ""
5615
- };
5616
5354
  const value = field.type === "textarea" && field.isJson && rawValue !== null && typeof rawValue === "object" ? JSON.stringify(rawValue, null, 2) : rawValue;
5617
5355
  return {
5618
5356
  ...field,
@@ -6996,6 +6734,9 @@ function method(input, output, options) {
6996
6734
  timeoutMs: options?.timeoutMs
6997
6735
  };
6998
6736
  }
6737
+ var StaticDirOutputSchema$1 = object({ staticDir: string() });
6738
+ var VersionOutputSchema$1 = object({ version: string() });
6739
+ method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6999
6740
  var StaticDirOutputSchema = object({ staticDir: string() });
7000
6741
  var VersionOutputSchema = object({ version: string() });
7001
6742
  method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
@@ -7177,6 +6918,36 @@ var ModelFormatsSchema = object({
7177
6918
  tflite: ModelFormatEntrySchema.optional(),
7178
6919
  pt: ModelFormatEntrySchema.optional()
7179
6920
  });
6921
+ /**
6922
+ * Variant-selector grouping axes. Shared by the full `ModelCatalogEntry` and by
6923
+ * the reduced `PipelineModelOption` returned in `pipeline.getSchema()` so the
6924
+ * grouped Family→Tier→Variant picker renders identically in the config UI and
6925
+ * in the pipeline/device steppers. The flat `id` stays the source of truth for
6926
+ * resolution/download/persistence; this is a presentation overlay resolved back
6927
+ * to an `id`.
6928
+ */
6929
+ var ModelVariantGroupSchema = object({
6930
+ /** Top-level family, e.g. `yolo26` (later `d-fine`, `rf-detr`). */
6931
+ family: string(),
6932
+ /** Size within the family, e.g. `n` | `s` | `m` | `l`. */
6933
+ tier: string(),
6934
+ /** Quantization axis. Omit ⇒ the fp32 base build. */
6935
+ precision: _enum(["fp32", "int8"]).optional(),
6936
+ /**
6937
+ * Speed-optimization axis. Omit ⇒ the standard build. `fast` marks a
6938
+ * latency-optimized export (e.g. ReLU-activation variant) — the slot the
6939
+ * future performance variants plug into.
6940
+ */
6941
+ optimization: _enum(["standard", "fast"]).optional(),
6942
+ /**
6943
+ * Input-resolution axis (square input side, px). Omit ⇒ the family's native
6944
+ * resolution (640 for yolo26). Reduced-input builds (320 / 256) are a big,
6945
+ * cheap latency lever — especially on Apple ANE and the Intel N100 — at a
6946
+ * small-object accuracy cost. Mirrors the model's `inputSize` but lifted onto
6947
+ * the group so the selector can offer it as a variant axis.
6948
+ */
6949
+ resolution: number().int().positive().optional()
6950
+ });
7180
6951
  var ModelCatalogEntrySchema = object({
7181
6952
  id: string(),
7182
6953
  name: string(),
@@ -7206,7 +6977,43 @@ var ModelCatalogEntrySchema = object({
7206
6977
  * Auxiliary files required at runtime (labels JSON, charset dict, etc.).
7207
6978
  * Downloaded into the same modelsDir alongside the model file.
7208
6979
  */
7209
- extraFiles: array(ModelExtraFileSchema).readonly().optional()
6980
+ extraFiles: array(ModelExtraFileSchema).readonly().optional(),
6981
+ /**
6982
+ * LEGACY entry — retained in the catalog so a persisted operator selection
6983
+ * still RESOLVES (and can be re-activated), but hidden from the selectable
6984
+ * model list and excluded from the auto format-default pick. Set on the
6985
+ * superseded / consolidated models (older lineages, redundant fp16 IRs) so
6986
+ * the active lineup stays the coherent curated ladder without deleting a
6987
+ * model anyone may still be pinned to. `resolveModelForFormat` keeps honoring
6988
+ * an explicit legacy id that has a build for the node's format.
6989
+ */
6990
+ legacy: boolean().optional(),
6991
+ /**
6992
+ * Measured quality/latency metadata — populated from the benchmark addon on
6993
+ * the real node classes. Absent = not yet measured (most entries today; the
6994
+ * catalog historically carried only `sizeMB`, a poor cross-architecture
6995
+ * speed proxy). `p95LatencyMs` is keyed by node class (e.g. `n100`, `mac`).
6996
+ */
6997
+ metrics: object({
6998
+ map50: number().optional(),
6999
+ p95LatencyMs: record(string(), number()).optional()
7000
+ }).optional(),
7001
+ /**
7002
+ * SPDX-ish license id of the model weights (e.g. `AGPL-3.0` for Ultralytics
7003
+ * YOLO26, `GPL-3.0` for YOLOv9, `Apache-2.0` for D-FINE/RF-DETR). Matters for
7004
+ * the retraining addon and any future commercial distribution.
7005
+ */
7006
+ license: string().optional(),
7007
+ /**
7008
+ * Variant-selector grouping. The UI groups models by `family` + `tier` and
7009
+ * offers `precision` / `optimization` as variant axes WITHIN a tier — so all
7010
+ * of a family's sizes and quantizations collapse into one grouped picker
7011
+ * instead of a flat list of `yolo26s`, `yolo26s-int8`, … Absent ⇒ ungrouped
7012
+ * (legacy / custom models) — never shown in the grouped selector. The flat
7013
+ * `id` stays the source of truth for resolution/download/persistence; grouping
7014
+ * is a presentation overlay resolved back to an `id`.
7015
+ */
7016
+ group: ModelVariantGroupSchema.optional()
7210
7017
  });
7211
7018
  var ConvertTargetSchema = discriminatedUnion("format", [object({
7212
7019
  format: literal("openvino"),
@@ -7267,8 +7074,8 @@ var RecordingModeSchema = _enum([
7267
7074
  "onAudioThreshold"
7268
7075
  ]);
7269
7076
  /**
7270
- * First-class, authoritative per-camera storage mode — the netta choice the UI
7271
- * reads directly (never inferred from `rules`):
7077
+ * First-class, authoritative per-camera storage mode — the explicit choice the
7078
+ * UI reads directly (never inferred from `rules`):
7272
7079
  * - `off` — not recording.
7273
7080
  * - `events` — record only around triggers (motion / audio threshold),
7274
7081
  * with pre/post-buffer.
@@ -8916,26 +8723,13 @@ DeviceType.Light, method(object({
8916
8723
  percentage: number().min(0).max(100),
8917
8724
  lastChangedAt: number()
8918
8725
  });
8726
+ /** Stream delivery format. (Relocated from the retired `streaming-engine` cap.) */
8919
8727
  var StreamFormatSchema = _enum([
8920
8728
  "webrtc",
8921
8729
  "hls",
8922
8730
  "mjpeg",
8923
8731
  "rtsp"
8924
8732
  ]);
8925
- var StreamInfoSchema = object({
8926
- streamId: string(),
8927
- format: StreamFormatSchema,
8928
- url: string().nullable(),
8929
- active: boolean()
8930
- });
8931
- method(object({
8932
- streamId: string(),
8933
- sourceUrl: string(),
8934
- codec: string().optional()
8935
- }), _void(), { kind: "mutation" }), method(object({ streamId: string() }), _void(), { kind: "mutation" }), method(object({
8936
- streamId: string(),
8937
- format: StreamFormatSchema
8938
- }), string().nullable()), method(_void(), array(StreamInfoSchema));
8939
8733
  var RtspRestreamEntrySchema = object({
8940
8734
  brokerId: string(),
8941
8735
  url: string(),
@@ -9600,7 +9394,7 @@ var ConsumablesStatusSchema = object({
9600
9394
  })),
9601
9395
  lastChangedAt: number()
9602
9396
  });
9603
- DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, method(object({
9397
+ Object.values(DeviceType), method(object({
9604
9398
  deviceId: number().int().nonnegative(),
9605
9399
  key: string().min(1)
9606
9400
  }), _void(), {
@@ -10515,7 +10309,7 @@ var BoundingBoxSchema = object({
10515
10309
  w: number(),
10516
10310
  h: number()
10517
10311
  });
10518
- var SpatialDetectionSchema = object({
10312
+ object({
10519
10313
  class: string(),
10520
10314
  originalClass: string(),
10521
10315
  score: number(),
@@ -10650,7 +10444,6 @@ var PipelineDefaultStepSchema = lazy(() => object({
10650
10444
  enabled: boolean(),
10651
10445
  modelId: string(),
10652
10446
  children: array(PipelineDefaultStepSchema).readonly(),
10653
- engine: PipelineEngineChoiceSchema.optional(),
10654
10447
  group: string().optional(),
10655
10448
  settings: record(string(), unknown()).optional()
10656
10449
  }));
@@ -10675,7 +10468,9 @@ var PipelineModelOptionSchema = object({
10675
10468
  formats: record(string(), object({
10676
10469
  downloaded: boolean(),
10677
10470
  sizeMB: number()
10678
- }))
10471
+ })),
10472
+ group: ModelVariantGroupSchema.optional(),
10473
+ legacy: boolean().optional()
10679
10474
  });
10680
10475
  var ConfigFieldBridge = custom();
10681
10476
  var PipelineAddonSchemaSchema = object({
@@ -10705,11 +10500,6 @@ var PipelineSchemaSchema = object({
10705
10500
  selectedEngine: PipelineEngineChoiceSchema,
10706
10501
  slots: array(PipelineSlotSchemaSchema).readonly()
10707
10502
  });
10708
- var DetectorOutputSchema = object({
10709
- detections: array(SpatialDetectionSchema).readonly(),
10710
- inferenceMs: number(),
10711
- modelId: string()
10712
- });
10713
10503
  var EngineProvisioningSchema = object({
10714
10504
  runtimeId: _enum([
10715
10505
  "onnx",
@@ -10726,15 +10516,42 @@ var EngineProvisioningSchema = object({
10726
10516
  ]),
10727
10517
  progress: number().optional(),
10728
10518
  error: string().optional(),
10729
- nextRetryAt: number().optional()
10519
+ nextRetryAt: number().optional(),
10520
+ /**
10521
+ * Gate A (config-correctness gate at engine change): human-readable
10522
+ * config issues surfaced EAGERLY when the node's engine changes — model
10523
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
10524
+ * has a <format> build"). Additive/optional: informational only, never
10525
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
10526
+ * Absent/empty when the node-default tree resolves cleanly.
10527
+ */
10528
+ configIssues: array(string()).optional()
10730
10529
  });
10731
10530
  var PipelineStepInputSchema = lazy(() => object({
10732
10531
  addonId: string(),
10733
- modelId: string(),
10532
+ modelId: string().optional(),
10734
10533
  enabled: boolean().default(true),
10735
10534
  children: array(PipelineStepInputSchema).optional(),
10736
10535
  settings: record(string(), unknown()).optional()
10737
10536
  }));
10537
+ var ModelSubstitutionSchema = object({
10538
+ addonId: string(),
10539
+ chosen: string(),
10540
+ running: string(),
10541
+ format: string()
10542
+ });
10543
+ var PipelineValidationIssueSchema = object({
10544
+ addonId: string(),
10545
+ kind: _enum(["unknown-addon", "no-format-build"]),
10546
+ detail: string()
10547
+ });
10548
+ var PipelineValidationResultSchema = object({
10549
+ ok: boolean(),
10550
+ issues: array(PipelineValidationIssueSchema).readonly(),
10551
+ substitutions: array(ModelSubstitutionSchema).readonly(),
10552
+ /** The node's `currentEngine.format` this validation ran against. */
10553
+ format: string()
10554
+ });
10738
10555
  var ReferenceImageEntrySchema = object({
10739
10556
  filename: string(),
10740
10557
  stepIds: array(string()).readonly().optional()
@@ -10805,7 +10622,13 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
10805
10622
  })) }), object({ success: literal(true) }), {
10806
10623
  kind: "mutation",
10807
10624
  auth: "admin"
10808
- }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
10625
+ }), method(object({ nodeId: string() }), object({
10626
+ success: literal(true),
10627
+ clearedDevices: number()
10628
+ }), {
10629
+ kind: "mutation",
10630
+ auth: "admin"
10631
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
10809
10632
  name: string(),
10810
10633
  steps: array(PipelineTemplateStepSchema).readonly(),
10811
10634
  engine: PipelineEngineChoiceSchema
@@ -10822,10 +10645,6 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
10822
10645
  modelId: string(),
10823
10646
  format: ModelFormatSchema$1
10824
10647
  }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
10825
- addonId: string(),
10826
- frame: FrameInputSchema,
10827
- config: record(string(), unknown()).optional()
10828
- }), DetectorOutputSchema), method(object({
10829
10648
  engine: PipelineEngineChoiceSchema.optional(),
10830
10649
  steps: array(PipelineStepInputSchema).min(1),
10831
10650
  frame: FrameInputSchema.optional(),
@@ -11065,6 +10884,13 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
11065
10884
  kind: literal("remote-restream"),
11066
10885
  /** The camera's source-owner node (slice 1: always the hub). */
11067
10886
  ownerNodeId: string(),
10887
+ /**
10888
+ * The owner's LAN-reachable host, resolved by the orchestrator from the
10889
+ * per-node `reachableHost` override (Cluster UI). When present the runner
10890
+ * dials THIS host for the owner's restream, in preference to the
10891
+ * `CAMSTACK_HUB_URL`-derived default. Absent → auto-detect fallback.
10892
+ */
10893
+ ownerReachableHost: string().optional(),
11068
10894
  /** Operator override for the owner host the runner dials. */
11069
10895
  hubHostnameOverride: string().optional()
11070
10896
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
@@ -11073,13 +10899,11 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
11073
10899
  * specific runner instance via `attachCamera`. Carries everything the
11074
10900
  * runner needs to subscribe to the local broker and execute inference.
11075
10901
  *
11076
- * Stateless-pipeline model: the full pipeline content (`engine`, `steps`,
11077
- * optional `audio`) travels with the attach payload. The runner keeps it
11078
- * in RAM for the lifetime of the attach — on rebalance, edit, or
11079
- * restart the orchestrator re-sends the latest snapshot.
11080
- *
11081
- * `engine`/`steps`/`audio` are optional during the additive migration
11082
- * window; once orchestrator + UI are migrated they become required.
10902
+ * Stateless-pipeline model: the pipeline content (`steps`, optional
10903
+ * `audio`) travels with the attach payload. The runner keeps it in RAM
10904
+ * for the lifetime of the attach — on rebalance, edit, or restart the
10905
+ * orchestrator re-sends the latest snapshot. Engine is NOT carried: it is
10906
+ * node-local, resolved by the executing runner at dispatch time.
11083
10907
  */
11084
10908
  var RunnerCameraConfigSchema = object({
11085
10909
  deviceId: number(),
@@ -11130,14 +10954,11 @@ var RunnerCameraConfigSchema = object({
11130
10954
  */
11131
10955
  motionSources: MotionSourcesSchema.default(["analyzer"]),
11132
10956
  pipelineEnabled: boolean().default(true),
11133
- /** Engine choice for video steps (runtime+backend+format). */
11134
- engine: PipelineEngineChoiceSchema.optional(),
11135
10957
  /** Ordered tree of video steps. Absent → runner skips video detection. */
11136
10958
  steps: array(PipelineStepInputSchema).readonly().optional(),
11137
10959
  /** Audio classification branch. `enabled:false` disables, null skips. */
11138
10960
  audio: object({
11139
- engine: PipelineEngineChoiceSchema,
11140
- modelId: string(),
10961
+ modelId: string().optional(),
11141
10962
  enabled: boolean()
11142
10963
  }).nullable().optional(),
11143
10964
  /**
@@ -12518,7 +12339,9 @@ var AddonPageDeclarationSchema$1 = object({
12518
12339
  icon: string(),
12519
12340
  path: string(),
12520
12341
  remoteName: string(),
12521
- bundle: string()
12342
+ bundle: string(),
12343
+ section: string().optional(),
12344
+ sectionLabel: string().optional()
12522
12345
  });
12523
12346
  var AddonPageInfoSchema = object({
12524
12347
  addonId: string(),
@@ -12558,7 +12381,18 @@ var AddonPageDeclarationSchema = object({
12558
12381
  * the static-file route can compute an mtime-based cache-buster URL
12559
12382
  * without a separate filesystem stat.
12560
12383
  */
12561
- bundle: string()
12384
+ bundle: string(),
12385
+ /**
12386
+ * Sidebar section this page docks into. Well-known ids: `'detection'`,
12387
+ * `'cluster'`, `'administration'` — the page renders inside that group.
12388
+ * Any OTHER string creates (or joins) a custom section rendered after
12389
+ * the built-in groups; its label comes from `sectionLabel` (first
12390
+ * declaration wins), falling back to the id. Absent → the legacy
12391
+ * "Addon Pages" group.
12392
+ */
12393
+ section: string().optional(),
12394
+ /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
12395
+ sectionLabel: string().optional()
12562
12396
  });
12563
12397
  method(_void(), array(AddonPageDeclarationSchema).readonly());
12564
12398
  var AddonHttpRouteSchema = object({
@@ -12774,6 +12608,17 @@ var WidgetMetadataSchema = object({
12774
12608
  deviceContext: boolean().default(false),
12775
12609
  integrationContext: boolean().default(false)
12776
12610
  }),
12611
+ /**
12612
+ * Loadable BEFORE authentication. The normal widget registry listing
12613
+ * (`addon-widgets.listWidgets`) is auth-gated, so a pre-auth surface
12614
+ * (the login page) cannot discover a widget through it. A widget that
12615
+ * declares `preAuth: true` marks itself as safe to mount on a pre-auth
12616
+ * screen — it is surfaced through the PUBLIC `auth.listLoginMethods`
12617
+ * login-method contribution channel (see `login-method.cap.ts`) rather
12618
+ * than the authenticated registry, and its bundle is served by the
12619
+ * public `/api/addon-widgets/:addonId/*` static route. Defaults false.
12620
+ */
12621
+ preAuth: boolean().optional().default(false),
12777
12622
  /** Dashboard placement HINTS (operator can override per instance). */
12778
12623
  defaultSize: WidgetSizeEnum.default("md"),
12779
12624
  allowedSizes: array(WidgetSizeEnum).readonly().default([
@@ -13112,6 +12957,66 @@ method(object({
13112
12957
  password: string()
13113
12958
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13114
12959
  /**
12960
+ * `login-method` — collection cap through which auth addons contribute
12961
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
12962
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
12963
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
12964
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
12965
+ * procedure aggregates them for the unauthenticated login page.
12966
+ *
12967
+ * A contribution is a discriminated union on `kind`:
12968
+ *
12969
+ * - `redirect` — a declarative button. The login page renders a generic
12970
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
12971
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
12972
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
12973
+ * login page needs NO change.
12974
+ *
12975
+ * - `widget` — a Module-Federation widget the login page mounts (via
12976
+ * `loadRemoteBundle`) for an in-page ceremony. Covers the passkey
12977
+ * login ceremony, which must run `@simplewebauthn/browser` INSIDE the
12978
+ * addon bundle. The referenced widget also declares `preAuth: true` in
12979
+ * its `addon-widgets-source` catalog entry. `auth.listLoginMethods`
12980
+ * stamps a public `bundleUrl` from `addonId` + `bundle`.
12981
+ *
12982
+ * Every contribution carries a `stage`:
12983
+ * - `primary` — shown on the first credentials screen (OIDC /
12984
+ * magic-link buttons; a future usernameless passkey).
12985
+ * - `second-factor` — shown AFTER the password leg, gated on the
12986
+ * returned `factors` (passkey-as-2FA today).
12987
+ *
12988
+ * `mount: skip` — the cap is read server-side by the core auth router
12989
+ * (`registry.getCollection('login-method')`), never mounted as its own
12990
+ * tRPC router.
12991
+ */
12992
+ /** When a login method renders in the two-phase login flow. */
12993
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
12994
+ /** One login-method contribution — redirect button OR pre-auth widget. */
12995
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [object({
12996
+ kind: literal("redirect"),
12997
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
12998
+ id: string(),
12999
+ /** Operator-facing button label. */
13000
+ label: string(),
13001
+ /** lucide-react icon name. */
13002
+ icon: string().optional(),
13003
+ /** Addon-owned HTTP route the button navigates to (GET). */
13004
+ startUrl: string(),
13005
+ stage: LoginStageEnum
13006
+ }), object({
13007
+ kind: literal("widget"),
13008
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13009
+ id: string(),
13010
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
13011
+ addonId: string(),
13012
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13013
+ bundle: string(),
13014
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13015
+ remote: WidgetRemoteSchema,
13016
+ stage: LoginStageEnum
13017
+ })]);
13018
+ method(_void(), array(LoginMethodContributionSchema).readonly());
13019
+ /**
13115
13020
  * Orchestrator-side destination metadata. The orchestrator computes
13116
13021
  * `id = <addonId>:<subId>` from its provider lookup so consumers
13117
13022
  * (admin UI, restore flow) see one canonical key.
@@ -15493,11 +15398,11 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
15493
15398
  timestamp: number()
15494
15399
  });
15495
15400
  var CameraPipelineConfigSchema = object({
15496
- engine: PipelineEngineChoiceSchema,
15401
+ engine: PipelineEngineChoiceSchema.optional(),
15497
15402
  steps: array(PipelineStepInputSchema).readonly(),
15498
15403
  audio: object({
15499
- engine: PipelineEngineChoiceSchema,
15500
- modelId: string(),
15404
+ engine: PipelineEngineChoiceSchema.optional(),
15405
+ modelId: string().optional(),
15501
15406
  enabled: boolean(),
15502
15407
  settings: record(string(), unknown()).readonly().optional()
15503
15408
  }).nullable().optional()
@@ -15512,7 +15417,7 @@ var PipelineTemplateSchema = object({
15512
15417
  });
15513
15418
  var AgentAddonConfigSchema = object({
15514
15419
  enabled: boolean(),
15515
- modelId: string(),
15420
+ modelId: string().optional(),
15516
15421
  settings: record(string(), unknown()).readonly()
15517
15422
  });
15518
15423
  var AgentPipelineSettingsSchema = object({
@@ -15522,12 +15427,25 @@ var AgentPipelineSettingsSchema = object({
15522
15427
  detectWeight: number().positive().optional(),
15523
15428
  /** Node is eligible to run the detection pipeline (decode + inference). */
15524
15429
  detect: boolean().optional(),
15525
- /** Node is eligible to host decoder sessions. */
15430
+ /**
15431
+ * DEPRECATED AND IGNORED. Decode is always co-located with its frame
15432
+ * consumer, so decode eligibility IS detect eligibility. Kept optional in
15433
+ * the schema ONLY so persisted stores written before the removal still
15434
+ * parse — no code reads it and no write path emits it.
15435
+ */
15526
15436
  decode: boolean().optional(),
15527
15437
  /** Node is eligible to run audio-analyzer sessions. */
15528
15438
  audio: boolean().optional(),
15529
15439
  /** Node is eligible to be the ingest / source-owner (serve the restream). */
15530
- ingest: boolean().optional()
15440
+ ingest: boolean().optional(),
15441
+ /**
15442
+ * Operator override for the LAN host a cross-node decoder dials to reach
15443
+ * THIS node's restream (Cluster UI). Absent → auto-detect: a remote runner
15444
+ * falls back to its `CAMSTACK_HUB_URL`-derived host (the Moleculer address
15445
+ * it already uses to reach the hub). Set this only when the auto-detected
15446
+ * address is wrong (multi-homed host, NAT, custom interface).
15447
+ */
15448
+ reachableHost: string().optional()
15531
15449
  });
15532
15450
  var CameraPipelineForAgentSchema = object({
15533
15451
  steps: array(PipelineStepInputSchema).readonly(),
@@ -15575,25 +15493,6 @@ var PipelineAssignmentSchema = object({
15575
15493
  assignedAt: number()
15576
15494
  });
15577
15495
  /**
15578
- * Decoder placement record. Symmetric to `PipelineAssignmentSchema` but for
15579
- * the decoder-node placement domain (`balanceDecoder` decision: manual pin
15580
- * → co-located with pipeline → capacity).
15581
- */
15582
- var DecoderAssignmentSchema = object({
15583
- deviceId: number(),
15584
- /** Moleculer node id of the decoder provider currently responsible for this camera. */
15585
- decoderNodeId: string(),
15586
- /** True when the assignment was set manually via `assignDecoder`, false when chosen by the balancer. */
15587
- pinned: boolean(),
15588
- /** Why this assignment was made — useful for debugging the decoder balancer. */
15589
- reason: _enum([
15590
- "manual",
15591
- "co-located",
15592
- "capacity",
15593
- "hardware-affinity"
15594
- ])
15595
- });
15596
- /**
15597
15496
  * Per-agent load summary surfaced to the load balancer + dashboards.
15598
15497
  * Aggregated from each runner's `getLocalLoad` cap call.
15599
15498
  */
@@ -15633,6 +15532,15 @@ var GlobalMetricsSchema = object({
15633
15532
  * capability providers.
15634
15533
  */
15635
15534
  var CapabilityBindingsSchema = record(string(), string());
15535
+ /**
15536
+ * The cluster's single camera-source owner (`clusterRoles.ingestNode`) plus
15537
+ * its LAN-reachable host, if one is registered. See `getIngestOwner`.
15538
+ */
15539
+ var IngestOwnerSchema = object({
15540
+ ownerNodeId: string(),
15541
+ reachableHost: string().optional(),
15542
+ configIssue: string().optional()
15543
+ });
15636
15544
  /** Source block — always present; derives from the stream catalog. */
15637
15545
  var CameraSourceStatusSchema = object({ streams: array(object({
15638
15546
  camStreamId: string(),
@@ -15647,6 +15555,14 @@ var CameraAssignmentStatusSchema = object({
15647
15555
  detectionNodeId: string().nullable(),
15648
15556
  decoderNodeId: string().nullable(),
15649
15557
  audioNodeId: string().nullable(),
15558
+ /**
15559
+ * The node that OWNS this camera's physical source pull (dials the RTSP and
15560
+ * hosts the broker/restream) — the cluster ingest owner today
15561
+ * (`clusterRoles.ingestNode`), per-camera once source assignment lands. Lets
15562
+ * the UI show WHERE a camera is sourced without SSH/logs, and is the node the
15563
+ * broker block below was read from (pinned). Nullable only pre-wiring.
15564
+ */
15565
+ sourceNodeId: string().nullable(),
15650
15566
  pinned: object({
15651
15567
  detection: boolean(),
15652
15568
  decoder: boolean(),
@@ -15779,16 +15695,7 @@ method(object({
15779
15695
  }), object({ success: literal(true) }), {
15780
15696
  kind: "mutation",
15781
15697
  auth: "admin"
15782
- }), method(object({
15783
- deviceId: number(),
15784
- nodeId: string()
15785
- }), _void(), {
15786
- kind: "mutation",
15787
- auth: "admin"
15788
- }), method(object({ deviceId: number() }), _void(), {
15789
- kind: "mutation",
15790
- auth: "admin"
15791
- }), method(_void(), array(DecoderAssignmentSchema).readonly()), method(object({
15698
+ }), method(_void(), IngestOwnerSchema), method(object({
15792
15699
  deviceId: number(),
15793
15700
  nodeId: string()
15794
15701
  }), object({ success: literal(true) }), {
@@ -15809,10 +15716,7 @@ method(object({
15809
15716
  nodeId: string(),
15810
15717
  pinned: boolean(),
15811
15718
  assignedAt: number()
15812
- }))), method(object({
15813
- deviceId: number(),
15814
- pipelineNodeId: string().optional()
15815
- }), DecoderAssignmentSchema), method(object({ agentNodeId: string() }), AgentPipelineSettingsSchema.nullable()), method(_void(), array(object({
15719
+ }))), method(object({ agentNodeId: string() }), AgentPipelineSettingsSchema.nullable()), method(_void(), array(object({
15816
15720
  nodeId: string(),
15817
15721
  settings: AgentPipelineSettingsSchema
15818
15722
  })).readonly()), method(object({
@@ -15842,12 +15746,26 @@ method(object({
15842
15746
  }), method(object({
15843
15747
  agentNodeId: string(),
15844
15748
  detect: boolean().nullable().optional(),
15845
- decode: boolean().nullable().optional(),
15846
15749
  audio: boolean().nullable().optional(),
15847
15750
  ingest: boolean().nullable().optional()
15848
15751
  }), object({ success: literal(true) }), {
15849
15752
  kind: "mutation",
15850
15753
  auth: "admin"
15754
+ }), method(object({
15755
+ agentNodeId: string(),
15756
+ reachableHost: string().nullable()
15757
+ }), object({ success: literal(true) }), {
15758
+ kind: "mutation",
15759
+ auth: "admin"
15760
+ }), method(object({ agentNodeId: string() }), object({
15761
+ success: literal(true),
15762
+ /** Hardware-aware default detection model now in effect on the node (null when unresolvable). */
15763
+ effectiveModelId: string().nullable(),
15764
+ /** Number of cameras whose node-scoped overrides were cleared. */
15765
+ clearedCameraOverrides: number()
15766
+ }), {
15767
+ kind: "mutation",
15768
+ auth: "admin"
15851
15769
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
15852
15770
  deviceId: number(),
15853
15771
  addonId: string(),
@@ -15892,22 +15810,131 @@ method(object({
15892
15810
  kind: "mutation",
15893
15811
  auth: "admin"
15894
15812
  });
15895
- var RegisteredStreamSchema = object({
15896
- streamId: string(),
15897
- label: string().optional(),
15898
- codec: string(),
15899
- type: _enum(["video", "audio"]),
15900
- sourceUrl: string()
15813
+ /**
15814
+ * server-management — per-NODE singleton capability for a node's ROOT
15815
+ * package lifecycle (runtime-updatable node packages, phase 2: hub + docker
15816
+ * agents).
15817
+ *
15818
+ * Each node's root package (`@camstack/server` on the hub, `@camstack/agent`
15819
+ * on agents) carries the whole software stack in its npm dep tree, so ONE
15820
+ * version describes the node. Updates install into
15821
+ * `<dataDir>/server-root/versions/<v>/` and apply on restart via the baked
15822
+ * starter (probation boot + auto-rollback to N-1).
15823
+ *
15824
+ * Providers:
15825
+ * - HUB: `ServerUpdateService` behind the `server-provided` mount
15826
+ * (`buildServerProviders` in trpc.router.ts) — the default target for
15827
+ * unpinned calls.
15828
+ * - AGENT: `AgentUpdateService` registered by the agent bootstrap under
15829
+ * the synthetic `agent-runtime` addonId and declared in the agent's
15830
+ * `$hub.registerNode` manifest.
15831
+ *
15832
+ * Node routing: singleton caps get the codegen/runtime-builder `nodeId`
15833
+ * injection on every method — `input.nodeId` (or `nodePin(nodeId)` from the
15834
+ * SDK) routes the call to that node's provider via the standard remote
15835
+ * proxy (`createCapabilityProxy` → `$agent-cap-fwd` → the agent's
15836
+ * in-process provider lookup). No `nodeId` → the hub's own provider.
15837
+ *
15838
+ * Spec: docs/superpowers/specs/2026-07-12-runtime-updatable-node-packages-design.md
15839
+ */
15840
+ /**
15841
+ * Where the running hub's code was loaded from:
15842
+ * - `workspace` — dev checkout (tsx / workspace dist); the starter defers to
15843
+ * plain resolution and runtime updates are refused.
15844
+ * - `baked` — the immutable image seed closure (no data-dir root active).
15845
+ * - `data-root` — the runtime-updatable `<dataDir>/server-root` closure.
15846
+ */
15847
+ var ServerBootModeSchema = _enum([
15848
+ "workspace",
15849
+ "baked",
15850
+ "data-root"
15851
+ ]);
15852
+ /**
15853
+ * Update lifecycle state:
15854
+ * - `idle` / `checking` / `staging` — steady / in-flight registry work.
15855
+ * - `pending-restart` — a version is staged and the node has NOT yet
15856
+ * restarted onto it (still running the OLD version).
15857
+ * - `awaiting-confirmation` — the node HAS restarted onto the staged version
15858
+ * (it is the active probation boot) and is waiting to confirm boot-health.
15859
+ * Apply/rollback are refused in this state and the node must NOT be
15860
+ * manually restarted, or the probation boot auto-rolls-back.
15861
+ */
15862
+ var ServerUpdateStateSchema = _enum([
15863
+ "idle",
15864
+ "checking",
15865
+ "staging",
15866
+ "pending-restart",
15867
+ "awaiting-confirmation"
15868
+ ]);
15869
+ var ServerRollbackInfoSchema = object({
15870
+ /** The version that failed (or was manually rolled back). */
15871
+ fromVersion: string(),
15872
+ /** The version rolled back to; null = the baked seed. */
15873
+ toVersion: string().nullable(),
15874
+ atMs: number(),
15875
+ reason: string()
15901
15876
  });
15902
- var ExposedResourceSchema = object({
15903
- streamId: string(),
15904
- format: string(),
15905
- value: string()
15877
+ var ServerPackageStatusSchema = object({
15878
+ /** Root package name (`@camstack/server` on the hub). */
15879
+ packageName: string(),
15880
+ /** Version of the code the running process ACTUALLY loaded. */
15881
+ runningVersion: string().nullable(),
15882
+ /** Node.js runtime version the node's process runs on (`process.versions.node`). */
15883
+ nodeRuntimeVersion: string().nullable(),
15884
+ /** Active data-dir root version; null when booted from seed/workspace. */
15885
+ activeVersion: string().nullable(),
15886
+ /** N-1 version kept for rollback; null when no previous version exists. */
15887
+ previousVersion: string().nullable(),
15888
+ /** Version of the immutable baked seed closure (image fallback). */
15889
+ seedVersion: string().nullable(),
15890
+ /** Latest registry version from the most recent check (null = never checked). */
15891
+ latestVersion: string().nullable(),
15892
+ updateAvailable: boolean(),
15893
+ bootMode: ServerBootModeSchema,
15894
+ updateState: ServerUpdateStateSchema,
15895
+ /** Version staged + awaiting its probation boot, when one is pending. */
15896
+ pendingVersion: string().nullable(),
15897
+ /** Set when the last freshly-activated version failed its boot health-check. */
15898
+ rolledBack: ServerRollbackInfoSchema.nullable(),
15899
+ /**
15900
+ * True when `server-root/state.json` EXISTS but is unreadable/corrupt — the
15901
+ * hub is running from the baked seed (or workspace) while installed data-dir
15902
+ * versions are being IGNORED. Surfaced as a warning in the UI.
15903
+ */
15904
+ stateFileCorrupt: boolean(),
15905
+ lastCheckedAtMs: number().nullable()
15906
+ });
15907
+ var ServerUpdateCheckResultSchema = object({
15908
+ packageName: string(),
15909
+ runningVersion: string().nullable(),
15910
+ latestVersion: string().nullable(),
15911
+ updateAvailable: boolean(),
15912
+ checkedAtMs: number(),
15913
+ /** Non-null when the registry lookup failed (offline, bad registry, …). */
15914
+ error: string().nullable()
15915
+ });
15916
+ var ServerUpdateActionResultSchema = object({
15917
+ accepted: boolean(),
15918
+ targetVersion: string().nullable(),
15919
+ /** True when a graceful restart was scheduled to apply the change. */
15920
+ restarting: boolean(),
15921
+ message: string()
15922
+ });
15923
+ method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
15924
+ kind: "mutation",
15925
+ auth: "admin"
15926
+ }), method(object({
15927
+ /** Explicit target version; omitted = latest from the registry. */
15928
+ version: string().optional() }), ServerUpdateActionResultSchema, {
15929
+ kind: "mutation",
15930
+ auth: "admin"
15931
+ }), method(_void(), ServerUpdateActionResultSchema, {
15932
+ kind: "mutation",
15933
+ auth: "admin"
15934
+ }), method(_void(), ServerUpdateActionResultSchema, {
15935
+ kind: "mutation",
15936
+ auth: "admin"
15906
15937
  });
15907
- method(object({
15908
- deviceId: number(),
15909
- streams: array(RegisteredStreamSchema).readonly()
15910
- }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), array(ExposedResourceSchema).readonly());
15911
15938
  /**
15912
15939
  * Query filter for settings-store collections.
15913
15940
  */
@@ -16060,9 +16087,9 @@ method(SendEmailInputSchema, SendEmailResultSchema, {
16060
16087
  /**
16061
16088
  * A single device snapshot returned as base64 JPEG/PNG.
16062
16089
  *
16063
- * Shared with the `snapshot-provider` collection cap the orchestrator
16064
- * receives the same shape from each native provider and from the
16065
- * broker-based fallback.
16090
+ * The `SnapshotAddon` wrapper returns this shape whether the frame came from
16091
+ * the device-native provider (onboard capture) or from the stream-broker
16092
+ * prebuffer fallback.
16066
16093
  */
16067
16094
  var SnapshotImageSchema = object({
16068
16095
  base64: string(),
@@ -16094,10 +16121,6 @@ DeviceType.Camera, method(object({
16094
16121
  kind: "mutation",
16095
16122
  auth: "admin"
16096
16123
  });
16097
- method(object({ deviceId: number() }), boolean()), method(object({
16098
- deviceId: number(),
16099
- streamId: string().optional()
16100
- }), SnapshotImageSchema.nullable());
16101
16124
  /**
16102
16125
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
16103
16126
  * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
@@ -16458,9 +16481,10 @@ method(object({
16458
16481
  auth: "admin"
16459
16482
  });
16460
16483
  /**
16461
- * Optional client-side hints sent at session creation to help the
16462
- * provider pick the best native source. All fields are optional —
16463
- * a viewer that knows nothing still gets a sane default.
16484
+ * Optional client-side hints sent at session creation to help the provider
16485
+ * pick the best native source. All fields optional — a viewer that knows
16486
+ * nothing still gets a sane default. (Relocated from the retired `webrtc`
16487
+ * collection cap; this `webrtc-session` cap is the live signaling surface.)
16464
16488
  */
16465
16489
  var webrtcClientHintsSchema = object({
16466
16490
  viewportWidth: number().int().positive().optional(),
@@ -16471,22 +16495,6 @@ var webrtcClientHintsSchema = object({
16471
16495
  /** Hard tier override; takes precedence over scoring when registered. */
16472
16496
  prefersTier: string().optional()
16473
16497
  }).partial();
16474
- method(object({
16475
- streamId: string(),
16476
- sdpOffer: string()
16477
- }), string(), { kind: "mutation" }), method(object({ streamId: string() }), boolean()), method(object({
16478
- streamId: string(),
16479
- codec: string()
16480
- }), _void(), { kind: "mutation" }), method(object({ streamId: string() }), _void(), { kind: "mutation" }), method(object({
16481
- streamId: string(),
16482
- hints: webrtcClientHintsSchema.optional()
16483
- }), object({
16484
- sessionId: string(),
16485
- sdpOffer: string()
16486
- }), { kind: "mutation" }), method(object({
16487
- sessionId: string(),
16488
- sdpAnswer: string()
16489
- }), _void(), { kind: "mutation" }), method(object({ sessionId: string() }), _void(), { kind: "mutation" }), method(object({ streamId: string() }), boolean());
16490
16498
  /**
16491
16499
  * Discriminated target for a WebRTC session. The client sends this
16492
16500
  * structured object instead of building / parsing brokerId strings;
@@ -17914,6 +17922,16 @@ var TopologyCategorySchema = object({
17914
17922
  healthy: number(),
17915
17923
  addons: array(TopologyCategoryAddonSchema).readonly()
17916
17924
  });
17925
+ /**
17926
+ * The node's runtime-updatable ROOT package (`@camstack/server` on the hub,
17927
+ * `@camstack/agent` on agents) as reported by its `registerNode` manifest —
17928
+ * version visibility for the Server management surface. Nullable: offline
17929
+ * rows and pre-phase-2 nodes report none.
17930
+ */
17931
+ var TopologyRootPackageSchema = object({
17932
+ name: string(),
17933
+ version: string()
17934
+ });
17917
17935
  var TopologyNodeSchema = object({
17918
17936
  id: string(),
17919
17937
  name: string(),
@@ -17937,7 +17955,8 @@ var TopologyNodeSchema = object({
17937
17955
  status: string()
17938
17956
  })).readonly(),
17939
17957
  processes: array(TopologyProcessSchema).readonly(),
17940
- categories: array(TopologyCategorySchema).readonly()
17958
+ categories: array(TopologyCategorySchema).readonly(),
17959
+ rootPackage: TopologyRootPackageSchema.nullable()
17941
17960
  });
17942
17961
  var CapUsageEdgeSchema = object({
17943
17962
  callerAddonId: string(),
@@ -20737,6 +20756,12 @@ Object.freeze({
20737
20756
  addonId: null,
20738
20757
  access: "create"
20739
20758
  },
20759
+ "loginMethod.getLoginMethods": {
20760
+ capName: "login-method",
20761
+ capScope: "system",
20762
+ addonId: null,
20763
+ access: "view"
20764
+ },
20740
20765
  "mediaPlayer.next": {
20741
20766
  capName: "media-player",
20742
20767
  capScope: "device",
@@ -21367,23 +21392,23 @@ Object.freeze({
21367
21392
  addonId: null,
21368
21393
  access: "create"
21369
21394
  },
21370
- "pipelineExecutor.deleteModel": {
21395
+ "pipelineExecutor.clearDeviceOverrides": {
21371
21396
  capName: "pipeline-executor",
21372
21397
  capScope: "system",
21373
21398
  addonId: null,
21374
21399
  access: "delete"
21375
21400
  },
21376
- "pipelineExecutor.deleteTemplate": {
21401
+ "pipelineExecutor.deleteModel": {
21377
21402
  capName: "pipeline-executor",
21378
21403
  capScope: "system",
21379
21404
  addonId: null,
21380
21405
  access: "delete"
21381
21406
  },
21382
- "pipelineExecutor.detect": {
21407
+ "pipelineExecutor.deleteTemplate": {
21383
21408
  capName: "pipeline-executor",
21384
21409
  capScope: "system",
21385
21410
  addonId: null,
21386
- access: "view"
21411
+ access: "delete"
21387
21412
  },
21388
21413
  "pipelineExecutor.downloadModel": {
21389
21414
  capName: "pipeline-executor",
@@ -21577,13 +21602,13 @@ Object.freeze({
21577
21602
  addonId: null,
21578
21603
  access: "create"
21579
21604
  },
21580
- "pipelineOrchestrator.assignAudio": {
21581
- capName: "pipeline-orchestrator",
21605
+ "pipelineExecutor.validatePipeline": {
21606
+ capName: "pipeline-executor",
21582
21607
  capScope: "system",
21583
21608
  addonId: null,
21584
- access: "create"
21609
+ access: "view"
21585
21610
  },
21586
- "pipelineOrchestrator.assignDecoder": {
21611
+ "pipelineOrchestrator.assignAudio": {
21587
21612
  capName: "pipeline-orchestrator",
21588
21613
  capScope: "system",
21589
21614
  addonId: null,
@@ -21667,19 +21692,13 @@ Object.freeze({
21667
21692
  addonId: null,
21668
21693
  access: "view"
21669
21694
  },
21670
- "pipelineOrchestrator.getDecoderAssignment": {
21671
- capName: "pipeline-orchestrator",
21672
- capScope: "system",
21673
- addonId: null,
21674
- access: "view"
21675
- },
21676
- "pipelineOrchestrator.getDecoderAssignments": {
21695
+ "pipelineOrchestrator.getGlobalMetrics": {
21677
21696
  capName: "pipeline-orchestrator",
21678
21697
  capScope: "system",
21679
21698
  addonId: null,
21680
21699
  access: "view"
21681
21700
  },
21682
- "pipelineOrchestrator.getGlobalMetrics": {
21701
+ "pipelineOrchestrator.getIngestOwner": {
21683
21702
  capName: "pipeline-orchestrator",
21684
21703
  capScope: "system",
21685
21704
  addonId: null,
@@ -21721,6 +21740,12 @@ Object.freeze({
21721
21740
  addonId: null,
21722
21741
  access: "delete"
21723
21742
  },
21743
+ "pipelineOrchestrator.resetNodePipelineDefaults": {
21744
+ capName: "pipeline-orchestrator",
21745
+ capScope: "system",
21746
+ addonId: null,
21747
+ access: "delete"
21748
+ },
21724
21749
  "pipelineOrchestrator.resolvePipeline": {
21725
21750
  capName: "pipeline-orchestrator",
21726
21751
  capScope: "system",
@@ -21757,37 +21782,37 @@ Object.freeze({
21757
21782
  addonId: null,
21758
21783
  access: "create"
21759
21784
  },
21760
- "pipelineOrchestrator.setCameraPipelineForAgent": {
21785
+ "pipelineOrchestrator.setAgentReachableHost": {
21761
21786
  capName: "pipeline-orchestrator",
21762
21787
  capScope: "system",
21763
21788
  addonId: null,
21764
21789
  access: "create"
21765
21790
  },
21766
- "pipelineOrchestrator.setCameraStepOverride": {
21791
+ "pipelineOrchestrator.setCameraPipelineForAgent": {
21767
21792
  capName: "pipeline-orchestrator",
21768
21793
  capScope: "system",
21769
21794
  addonId: null,
21770
21795
  access: "create"
21771
21796
  },
21772
- "pipelineOrchestrator.setCameraStepToggle": {
21797
+ "pipelineOrchestrator.setCameraStepOverride": {
21773
21798
  capName: "pipeline-orchestrator",
21774
21799
  capScope: "system",
21775
21800
  addonId: null,
21776
21801
  access: "create"
21777
21802
  },
21778
- "pipelineOrchestrator.setCapabilityBinding": {
21803
+ "pipelineOrchestrator.setCameraStepToggle": {
21779
21804
  capName: "pipeline-orchestrator",
21780
21805
  capScope: "system",
21781
21806
  addonId: null,
21782
21807
  access: "create"
21783
21808
  },
21784
- "pipelineOrchestrator.unassignAudio": {
21809
+ "pipelineOrchestrator.setCapabilityBinding": {
21785
21810
  capName: "pipeline-orchestrator",
21786
21811
  capScope: "system",
21787
21812
  addonId: null,
21788
21813
  access: "create"
21789
21814
  },
21790
- "pipelineOrchestrator.unassignDecoder": {
21815
+ "pipelineOrchestrator.unassignAudio": {
21791
21816
  capName: "pipeline-orchestrator",
21792
21817
  capScope: "system",
21793
21818
  addonId: null,
@@ -22087,33 +22112,45 @@ Object.freeze({
22087
22112
  addonId: null,
22088
22113
  access: "create"
22089
22114
  },
22090
- "restreamer.getExposedResources": {
22091
- capName: "restreamer",
22115
+ "scriptRunner.run": {
22116
+ capName: "script-runner",
22117
+ capScope: "device",
22118
+ addonId: null,
22119
+ access: "create"
22120
+ },
22121
+ "scriptRunner.stop": {
22122
+ capName: "script-runner",
22123
+ capScope: "device",
22124
+ addonId: null,
22125
+ access: "create"
22126
+ },
22127
+ "serverManagement.applyServerUpdate": {
22128
+ capName: "server-management",
22092
22129
  capScope: "system",
22093
22130
  addonId: null,
22094
- access: "view"
22131
+ access: "create"
22095
22132
  },
22096
- "restreamer.registerDevice": {
22097
- capName: "restreamer",
22133
+ "serverManagement.checkServerUpdate": {
22134
+ capName: "server-management",
22098
22135
  capScope: "system",
22099
22136
  addonId: null,
22100
22137
  access: "create"
22101
22138
  },
22102
- "restreamer.unregisterDevice": {
22103
- capName: "restreamer",
22139
+ "serverManagement.getServerPackageStatus": {
22140
+ capName: "server-management",
22104
22141
  capScope: "system",
22105
22142
  addonId: null,
22106
- access: "delete"
22143
+ access: "view"
22107
22144
  },
22108
- "scriptRunner.run": {
22109
- capName: "script-runner",
22110
- capScope: "device",
22145
+ "serverManagement.restartServer": {
22146
+ capName: "server-management",
22147
+ capScope: "system",
22111
22148
  addonId: null,
22112
22149
  access: "create"
22113
22150
  },
22114
- "scriptRunner.stop": {
22115
- capName: "script-runner",
22116
- capScope: "device",
22151
+ "serverManagement.rollbackServerUpdate": {
22152
+ capName: "server-management",
22153
+ capScope: "system",
22117
22154
  addonId: null,
22118
22155
  access: "create"
22119
22156
  },
@@ -22207,18 +22244,6 @@ Object.freeze({
22207
22244
  addonId: null,
22208
22245
  access: "create"
22209
22246
  },
22210
- "snapshotProvider.getSnapshot": {
22211
- capName: "snapshot-provider",
22212
- capScope: "system",
22213
- addonId: null,
22214
- access: "view"
22215
- },
22216
- "snapshotProvider.supportsDevice": {
22217
- capName: "snapshot-provider",
22218
- capScope: "system",
22219
- addonId: null,
22220
- access: "view"
22221
- },
22222
22247
  "ssoBridge.signBridgeToken": {
22223
22248
  capName: "sso-bridge",
22224
22249
  capScope: "system",
@@ -22645,30 +22670,6 @@ Object.freeze({
22645
22670
  addonId: null,
22646
22671
  access: "view"
22647
22672
  },
22648
- "streamingEngine.getStreamUrl": {
22649
- capName: "streaming-engine",
22650
- capScope: "system",
22651
- addonId: null,
22652
- access: "view"
22653
- },
22654
- "streamingEngine.listStreams": {
22655
- capName: "streaming-engine",
22656
- capScope: "system",
22657
- addonId: null,
22658
- access: "view"
22659
- },
22660
- "streamingEngine.registerStream": {
22661
- capName: "streaming-engine",
22662
- capScope: "system",
22663
- addonId: null,
22664
- access: "create"
22665
- },
22666
- "streamingEngine.unregisterStream": {
22667
- capName: "streaming-engine",
22668
- capScope: "system",
22669
- addonId: null,
22670
- access: "delete"
22671
- },
22672
22673
  "streamParams.getConfigSchema": {
22673
22674
  capName: "stream-params",
22674
22675
  capScope: "device",
@@ -23017,6 +23018,18 @@ Object.freeze({
23017
23018
  addonId: null,
23018
23019
  access: "view"
23019
23020
  },
23021
+ "viewerUi.getStaticDir": {
23022
+ capName: "viewer-ui",
23023
+ capScope: "system",
23024
+ addonId: null,
23025
+ access: "view"
23026
+ },
23027
+ "viewerUi.getVersion": {
23028
+ capName: "viewer-ui",
23029
+ capScope: "system",
23030
+ addonId: null,
23031
+ access: "view"
23032
+ },
23020
23033
  "waterHeater.setAway": {
23021
23034
  capName: "water-heater",
23022
23035
  capScope: "device",
@@ -23035,54 +23048,6 @@ Object.freeze({
23035
23048
  addonId: null,
23036
23049
  access: "create"
23037
23050
  },
23038
- "webrtc.closeSession": {
23039
- capName: "webrtc",
23040
- capScope: "system",
23041
- addonId: null,
23042
- access: "create"
23043
- },
23044
- "webrtc.createSession": {
23045
- capName: "webrtc",
23046
- capScope: "system",
23047
- addonId: null,
23048
- access: "create"
23049
- },
23050
- "webrtc.handleAnswer": {
23051
- capName: "webrtc",
23052
- capScope: "system",
23053
- addonId: null,
23054
- access: "create"
23055
- },
23056
- "webrtc.handleOffer": {
23057
- capName: "webrtc",
23058
- capScope: "system",
23059
- addonId: null,
23060
- access: "create"
23061
- },
23062
- "webrtc.hasAdaptiveBitrate": {
23063
- capName: "webrtc",
23064
- capScope: "system",
23065
- addonId: null,
23066
- access: "view"
23067
- },
23068
- "webrtc.registerStream": {
23069
- capName: "webrtc",
23070
- capScope: "system",
23071
- addonId: null,
23072
- access: "create"
23073
- },
23074
- "webrtc.supportsStream": {
23075
- capName: "webrtc",
23076
- capScope: "system",
23077
- addonId: null,
23078
- access: "view"
23079
- },
23080
- "webrtc.unregisterStream": {
23081
- capName: "webrtc",
23082
- capScope: "system",
23083
- addonId: null,
23084
- access: "delete"
23085
- },
23086
23051
  "webrtcSession.addIceCandidate": {
23087
23052
  capName: "webrtc-session",
23088
23053
  capScope: "device",