@camstack/addon-provider-rtsp 1.1.19 → 1.1.21

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/addon.js +870 -304
  2. package/dist/addon.mjs +847 -304
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import net from "node:net";
1
2
  //#region ../../node_modules/zod/v4/core/core.js
2
3
  var _a$1;
3
4
  function $constructor(name, initializer, params) {
@@ -4641,7 +4642,7 @@ function preprocess(fn, schema) {
4641
4642
  });
4642
4643
  }
4643
4644
  //#endregion
4644
- //#region ../types/dist/sleep-CZDdRBua.mjs
4645
+ //#region ../types/dist/sleep-BC9Yqte7.mjs
4645
4646
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4646
4647
  EventCategory["SystemBoot"] = "system.boot";
4647
4648
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -4827,6 +4828,18 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
4827
4828
  */
4828
4829
  EventCategory["PipelineCameraUpdated"] = "pipeline.camera-updated";
4829
4830
  /**
4831
+ * The cluster camera-source OWNER changed (`clusterRoles.ingestNode`).
4832
+ * Emitted by addon-pipeline-orchestrator whenever it (re)derives node
4833
+ * capabilities — at boot, on agent online/offline, and on an ingest-node
4834
+ * flip. Carries the resolved `ownerNodeId`. The stream-broker consumes it to
4835
+ * keep its ingest-owner-gate decision current WITHOUT a per-`ensureBroker`
4836
+ * cross-process `getIngestOwner` query (push the authority's decision instead
4837
+ * of polling it on the hot path). Idempotent state — re-emitted on every
4838
+ * topology change, so a dropped event self-heals on the next one (plus the
4839
+ * broker's long backstop reconcile query).
4840
+ */
4841
+ EventCategory["PipelineIngestOwnerChanged"] = "pipeline.ingest-owner-changed";
4842
+ /**
4830
4843
  * Periodic snapshot of per-node pipeline-runner load
4831
4844
  * (`RunnerLocalLoad`). Emitted ~1Hz by every runner so UI dashboards
4832
4845
  * subscribe instead of polling `pipelineRunner.getLocalLoad`.
@@ -5350,10 +5363,6 @@ function hydrateField(field, values) {
5350
5363
  };
5351
5364
  }
5352
5365
  const rawValue = storedValue !== void 0 ? storedValue : defaultValue !== void 0 ? defaultValue : null;
5353
- if (field.type === "password") return {
5354
- ...field,
5355
- value: ""
5356
- };
5357
5366
  const value = field.type === "textarea" && field.isJson && rawValue !== null && typeof rawValue === "object" ? JSON.stringify(rawValue, null, 2) : rawValue;
5358
5367
  return {
5359
5368
  ...field,
@@ -6737,10 +6746,25 @@ function method(input, output, options) {
6737
6746
  timeoutMs: options?.timeoutMs
6738
6747
  };
6739
6748
  }
6749
+ /**
6750
+ * A wrapper/system-only method: served exclusively by the cap's system-level
6751
+ * provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
6752
+ * driver natives don't stub out a wrapper concern (e.g. a cross-device cache
6753
+ * overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
6754
+ */
6755
+ function systemMethod(input, output, options) {
6756
+ return {
6757
+ ...method(input, output, options),
6758
+ systemOnly: true
6759
+ };
6760
+ }
6740
6761
  /** Shorthand to define an event schema */
6741
6762
  function event(data) {
6742
6763
  return { data };
6743
6764
  }
6765
+ var StaticDirOutputSchema$1 = object({ staticDir: string() });
6766
+ var VersionOutputSchema$1 = object({ version: string() });
6767
+ method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6744
6768
  var StaticDirOutputSchema = object({ staticDir: string() });
6745
6769
  var VersionOutputSchema = object({ version: string() });
6746
6770
  method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
@@ -6910,6 +6934,36 @@ var ModelFormatsSchema = object({
6910
6934
  tflite: ModelFormatEntrySchema.optional(),
6911
6935
  pt: ModelFormatEntrySchema.optional()
6912
6936
  });
6937
+ /**
6938
+ * Variant-selector grouping axes. Shared by the full `ModelCatalogEntry` and by
6939
+ * the reduced `PipelineModelOption` returned in `pipeline.getSchema()` so the
6940
+ * grouped Family→Tier→Variant picker renders identically in the config UI and
6941
+ * in the pipeline/device steppers. The flat `id` stays the source of truth for
6942
+ * resolution/download/persistence; this is a presentation overlay resolved back
6943
+ * to an `id`.
6944
+ */
6945
+ var ModelVariantGroupSchema = object({
6946
+ /** Top-level family, e.g. `yolo26` (later `d-fine`, `rf-detr`). */
6947
+ family: string(),
6948
+ /** Size within the family, e.g. `n` | `s` | `m` | `l`. */
6949
+ tier: string(),
6950
+ /** Quantization axis. Omit ⇒ the fp32 base build. */
6951
+ precision: _enum(["fp32", "int8"]).optional(),
6952
+ /**
6953
+ * Speed-optimization axis. Omit ⇒ the standard build. `fast` marks a
6954
+ * latency-optimized export (e.g. ReLU-activation variant) — the slot the
6955
+ * future performance variants plug into.
6956
+ */
6957
+ optimization: _enum(["standard", "fast"]).optional(),
6958
+ /**
6959
+ * Input-resolution axis (square input side, px). Omit ⇒ the family's native
6960
+ * resolution (640 for yolo26). Reduced-input builds (320 / 256) are a big,
6961
+ * cheap latency lever — especially on Apple ANE and the Intel N100 — at a
6962
+ * small-object accuracy cost. Mirrors the model's `inputSize` but lifted onto
6963
+ * the group so the selector can offer it as a variant axis.
6964
+ */
6965
+ resolution: number().int().positive().optional()
6966
+ });
6913
6967
  var ModelCatalogEntrySchema = object({
6914
6968
  id: string(),
6915
6969
  name: string(),
@@ -6939,7 +6993,43 @@ var ModelCatalogEntrySchema = object({
6939
6993
  * Auxiliary files required at runtime (labels JSON, charset dict, etc.).
6940
6994
  * Downloaded into the same modelsDir alongside the model file.
6941
6995
  */
6942
- extraFiles: array(ModelExtraFileSchema).readonly().optional()
6996
+ extraFiles: array(ModelExtraFileSchema).readonly().optional(),
6997
+ /**
6998
+ * LEGACY entry — retained in the catalog so a persisted operator selection
6999
+ * still RESOLVES (and can be re-activated), but hidden from the selectable
7000
+ * model list and excluded from the auto format-default pick. Set on the
7001
+ * superseded / consolidated models (older lineages, redundant fp16 IRs) so
7002
+ * the active lineup stays the coherent curated ladder without deleting a
7003
+ * model anyone may still be pinned to. `resolveModelForFormat` keeps honoring
7004
+ * an explicit legacy id that has a build for the node's format.
7005
+ */
7006
+ legacy: boolean().optional(),
7007
+ /**
7008
+ * Measured quality/latency metadata — populated from the benchmark addon on
7009
+ * the real node classes. Absent = not yet measured (most entries today; the
7010
+ * catalog historically carried only `sizeMB`, a poor cross-architecture
7011
+ * speed proxy). `p95LatencyMs` is keyed by node class (e.g. `n100`, `mac`).
7012
+ */
7013
+ metrics: object({
7014
+ map50: number().optional(),
7015
+ p95LatencyMs: record(string(), number()).optional()
7016
+ }).optional(),
7017
+ /**
7018
+ * SPDX-ish license id of the model weights (e.g. `AGPL-3.0` for Ultralytics
7019
+ * YOLO26, `GPL-3.0` for YOLOv9, `Apache-2.0` for D-FINE/RF-DETR). Matters for
7020
+ * the retraining addon and any future commercial distribution.
7021
+ */
7022
+ license: string().optional(),
7023
+ /**
7024
+ * Variant-selector grouping. The UI groups models by `family` + `tier` and
7025
+ * offers `precision` / `optimization` as variant axes WITHIN a tier — so all
7026
+ * of a family's sizes and quantizations collapse into one grouped picker
7027
+ * instead of a flat list of `yolo26s`, `yolo26s-int8`, … Absent ⇒ ungrouped
7028
+ * (legacy / custom models) — never shown in the grouped selector. The flat
7029
+ * `id` stays the source of truth for resolution/download/persistence; grouping
7030
+ * is a presentation overlay resolved back to an `id`.
7031
+ */
7032
+ group: ModelVariantGroupSchema.optional()
6943
7033
  });
6944
7034
  var ConvertTargetSchema = discriminatedUnion("format", [object({
6945
7035
  format: literal("openvino"),
@@ -7000,8 +7090,8 @@ var RecordingModeSchema = _enum([
7000
7090
  "onAudioThreshold"
7001
7091
  ]);
7002
7092
  /**
7003
- * First-class, authoritative per-camera storage mode — the netta choice the UI
7004
- * reads directly (never inferred from `rules`):
7093
+ * First-class, authoritative per-camera storage mode — the explicit choice the
7094
+ * UI reads directly (never inferred from `rules`):
7005
7095
  * - `off` — not recording.
7006
7096
  * - `events` — record only around triggers (motion / audio threshold),
7007
7097
  * with pre/post-buffer.
@@ -8533,6 +8623,72 @@ function shallowEqual(a, b) {
8533
8623
  for (const k of ak) if (a[k] !== b[k]) return false;
8534
8624
  return true;
8535
8625
  }
8626
+ /** Reject after `ms`; always clears its own timer. */
8627
+ async function withTimeout(promise, ms, label) {
8628
+ let timer;
8629
+ const timeout = new Promise((_resolve, reject) => {
8630
+ timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`${label} timed out after ${String(ms)}ms`)), ms);
8631
+ });
8632
+ try {
8633
+ return await Promise.race([promise, timeout]);
8634
+ } finally {
8635
+ if (timer !== void 0) clearTimeout(timer);
8636
+ }
8637
+ }
8638
+ /**
8639
+ * Start the reachability poll loop. Returns a handle whose `stop()` clears the
8640
+ * timer and prevents any further ticks. Start on device activation, stop on
8641
+ * device teardown (`removeDevice`) so no timer leaks.
8642
+ */
8643
+ function startReachabilityPoll(options) {
8644
+ const intervalMs = options.intervalMs ?? 3e4;
8645
+ const failuresToOffline = options.failuresToOffline ?? 3;
8646
+ const probeTimeoutMs = options.probeTimeoutMs ?? 1e4;
8647
+ const runImmediately = options.runImmediately ?? true;
8648
+ let stopped = false;
8649
+ let running = false;
8650
+ let consecutiveFailures = 0;
8651
+ let timer;
8652
+ const tick = async () => {
8653
+ if (stopped) return;
8654
+ if (running) return;
8655
+ if (options.isEnabled && !options.isEnabled()) return;
8656
+ running = true;
8657
+ try {
8658
+ const reachable = await withTimeout(Promise.resolve().then(options.probe), probeTimeoutMs, "reachability probe");
8659
+ if (stopped) return;
8660
+ if (reachable) {
8661
+ consecutiveFailures = 0;
8662
+ options.setOnline(true);
8663
+ } else registerFailure("probe resolved unreachable");
8664
+ } catch (error) {
8665
+ if (stopped) return;
8666
+ registerFailure(error instanceof Error ? error.message : "probe threw");
8667
+ } finally {
8668
+ running = false;
8669
+ }
8670
+ };
8671
+ const registerFailure = (reason) => {
8672
+ consecutiveFailures += 1;
8673
+ options.logger?.debug("reachability probe failed", {
8674
+ reason,
8675
+ consecutiveFailures,
8676
+ failuresToOffline
8677
+ });
8678
+ if (consecutiveFailures >= failuresToOffline) options.setOnline(false);
8679
+ };
8680
+ timer = setInterval(() => {
8681
+ tick();
8682
+ }, intervalMs);
8683
+ if (typeof timer === "object" && timer !== null && "unref" in timer) timer.unref();
8684
+ if (runImmediately) tick();
8685
+ return { stop: () => {
8686
+ if (stopped) return;
8687
+ stopped = true;
8688
+ if (timer !== void 0) clearInterval(timer);
8689
+ timer = void 0;
8690
+ } };
8691
+ }
8536
8692
  /**
8537
8693
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
8538
8694
  * for every device, regardless of provider — the kernel needs a uniform
@@ -9196,26 +9352,13 @@ onBrightnessChanged: { data: object({
9196
9352
  */
9197
9353
  runtimeState: BrightnessStatusSchema
9198
9354
  };
9355
+ /** Stream delivery format. (Relocated from the retired `streaming-engine` cap.) */
9199
9356
  var StreamFormatSchema = _enum([
9200
9357
  "webrtc",
9201
9358
  "hls",
9202
9359
  "mjpeg",
9203
9360
  "rtsp"
9204
9361
  ]);
9205
- var StreamInfoSchema = object({
9206
- streamId: string(),
9207
- format: StreamFormatSchema,
9208
- url: string().nullable(),
9209
- active: boolean()
9210
- });
9211
- method(object({
9212
- streamId: string(),
9213
- sourceUrl: string(),
9214
- codec: string().optional()
9215
- }), _void(), { kind: "mutation" }), method(object({ streamId: string() }), _void(), { kind: "mutation" }), method(object({
9216
- streamId: string(),
9217
- format: StreamFormatSchema
9218
- }), string().nullable()), method(_void(), array(StreamInfoSchema));
9219
9362
  var RtspRestreamEntrySchema = object({
9220
9363
  brokerId: string(),
9221
9364
  url: string(),
@@ -10083,37 +10226,7 @@ var consumablesCapability = {
10083
10226
  scope: "device",
10084
10227
  deviceNative: true,
10085
10228
  mode: "singleton",
10086
- deviceTypes: [
10087
- DeviceType.Camera,
10088
- DeviceType.Hub,
10089
- DeviceType.Light,
10090
- DeviceType.Siren,
10091
- DeviceType.Switch,
10092
- DeviceType.Sensor,
10093
- DeviceType.Thermostat,
10094
- DeviceType.Button,
10095
- DeviceType.EventEmitter,
10096
- DeviceType.Update,
10097
- DeviceType.Generic,
10098
- DeviceType.Notifier,
10099
- DeviceType.Script,
10100
- DeviceType.Automation,
10101
- DeviceType.Lock,
10102
- DeviceType.Cover,
10103
- DeviceType.Valve,
10104
- DeviceType.Humidifier,
10105
- DeviceType.WaterHeater,
10106
- DeviceType.Fan,
10107
- DeviceType.MediaPlayer,
10108
- DeviceType.AlarmPanel,
10109
- DeviceType.Control,
10110
- DeviceType.Presence,
10111
- DeviceType.Weather,
10112
- DeviceType.Vacuum,
10113
- DeviceType.LawnMower,
10114
- DeviceType.Container,
10115
- DeviceType.Image
10116
- ],
10229
+ deviceTypes: Object.values(DeviceType),
10117
10230
  deviceConfig: { ui: {
10118
10231
  kind: "widget",
10119
10232
  widgetId: "host/consumables-panel",
@@ -11571,7 +11684,7 @@ var BoundingBoxSchema = object({
11571
11684
  w: number(),
11572
11685
  h: number()
11573
11686
  });
11574
- var SpatialDetectionSchema = object({
11687
+ object({
11575
11688
  class: string(),
11576
11689
  originalClass: string(),
11577
11690
  score: number(),
@@ -11706,7 +11819,6 @@ var PipelineDefaultStepSchema = lazy(() => object({
11706
11819
  enabled: boolean(),
11707
11820
  modelId: string(),
11708
11821
  children: array(PipelineDefaultStepSchema).readonly(),
11709
- engine: PipelineEngineChoiceSchema.optional(),
11710
11822
  group: string().optional(),
11711
11823
  settings: record(string(), unknown()).optional()
11712
11824
  }));
@@ -11731,7 +11843,9 @@ var PipelineModelOptionSchema = object({
11731
11843
  formats: record(string(), object({
11732
11844
  downloaded: boolean(),
11733
11845
  sizeMB: number()
11734
- }))
11846
+ })),
11847
+ group: ModelVariantGroupSchema.optional(),
11848
+ legacy: boolean().optional()
11735
11849
  });
11736
11850
  var ConfigFieldBridge = custom();
11737
11851
  var PipelineAddonSchemaSchema = object({
@@ -11745,6 +11859,7 @@ var PipelineAddonSchemaSchema = object({
11745
11859
  defaultModelId: string(),
11746
11860
  defaultModelIdByFormat: record(string(), string()).optional(),
11747
11861
  enabledByDefault: boolean().optional(),
11862
+ backfillIntoExistingOverrides: boolean().optional(),
11748
11863
  defaultConfidence: number(),
11749
11864
  group: string().optional(),
11750
11865
  configSchema: array(ConfigFieldBridge).readonly().optional()
@@ -11761,11 +11876,6 @@ var PipelineSchemaSchema = object({
11761
11876
  selectedEngine: PipelineEngineChoiceSchema,
11762
11877
  slots: array(PipelineSlotSchemaSchema).readonly()
11763
11878
  });
11764
- var DetectorOutputSchema = object({
11765
- detections: array(SpatialDetectionSchema).readonly(),
11766
- inferenceMs: number(),
11767
- modelId: string()
11768
- });
11769
11879
  var EngineProvisioningSchema = object({
11770
11880
  runtimeId: _enum([
11771
11881
  "onnx",
@@ -11782,15 +11892,42 @@ var EngineProvisioningSchema = object({
11782
11892
  ]),
11783
11893
  progress: number().optional(),
11784
11894
  error: string().optional(),
11785
- nextRetryAt: number().optional()
11895
+ nextRetryAt: number().optional(),
11896
+ /**
11897
+ * Gate A (config-correctness gate at engine change): human-readable
11898
+ * config issues surfaced EAGERLY when the node's engine changes — model
11899
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
11900
+ * has a <format> build"). Additive/optional: informational only, never
11901
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
11902
+ * Absent/empty when the node-default tree resolves cleanly.
11903
+ */
11904
+ configIssues: array(string()).optional()
11786
11905
  });
11787
11906
  var PipelineStepInputSchema = lazy(() => object({
11788
11907
  addonId: string(),
11789
- modelId: string(),
11908
+ modelId: string().optional(),
11790
11909
  enabled: boolean().default(true),
11791
11910
  children: array(PipelineStepInputSchema).optional(),
11792
11911
  settings: record(string(), unknown()).optional()
11793
11912
  }));
11913
+ var ModelSubstitutionSchema = object({
11914
+ addonId: string(),
11915
+ chosen: string(),
11916
+ running: string(),
11917
+ format: string()
11918
+ });
11919
+ var PipelineValidationIssueSchema = object({
11920
+ addonId: string(),
11921
+ kind: _enum(["unknown-addon", "no-format-build"]),
11922
+ detail: string()
11923
+ });
11924
+ var PipelineValidationResultSchema = object({
11925
+ ok: boolean(),
11926
+ issues: array(PipelineValidationIssueSchema).readonly(),
11927
+ substitutions: array(ModelSubstitutionSchema).readonly(),
11928
+ /** The node's `currentEngine.format` this validation ran against. */
11929
+ format: string()
11930
+ });
11794
11931
  var ReferenceImageEntrySchema = object({
11795
11932
  filename: string(),
11796
11933
  stepIds: array(string()).readonly().optional()
@@ -11861,7 +11998,13 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11861
11998
  })) }), object({ success: literal(true) }), {
11862
11999
  kind: "mutation",
11863
12000
  auth: "admin"
11864
- }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
12001
+ }), method(object({ nodeId: string() }), object({
12002
+ success: literal(true),
12003
+ clearedDevices: number()
12004
+ }), {
12005
+ kind: "mutation",
12006
+ auth: "admin"
12007
+ }), 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({
11865
12008
  name: string(),
11866
12009
  steps: array(PipelineTemplateStepSchema).readonly(),
11867
12010
  engine: PipelineEngineChoiceSchema
@@ -11878,10 +12021,6 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11878
12021
  modelId: string(),
11879
12022
  format: ModelFormatSchema$1
11880
12023
  }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
11881
- addonId: string(),
11882
- frame: FrameInputSchema,
11883
- config: record(string(), unknown()).optional()
11884
- }), DetectorOutputSchema), method(object({
11885
12024
  engine: PipelineEngineChoiceSchema.optional(),
11886
12025
  steps: array(PipelineStepInputSchema).min(1),
11887
12026
  frame: FrameInputSchema.optional(),
@@ -12060,6 +12199,25 @@ var zonesCapability = {
12060
12199
  runtimeState: object({ zones: array(ZoneSchema).readonly() })
12061
12200
  };
12062
12201
  /**
12202
+ * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
12203
+ * decode worker resolves it against the RETAINED native frame's real pixel dims,
12204
+ * so the caller supplies only the detection-res bbox divided by the detection
12205
+ * dims — no native resolution to plumb.
12206
+ */
12207
+ var NativeCropBboxSchema = object({
12208
+ x: number(),
12209
+ y: number(),
12210
+ w: number(),
12211
+ h: number()
12212
+ });
12213
+ /** Result of a best-effort native-resolution crop (`getNativeCrop`). */
12214
+ var NativeCropResultSchema = object({
12215
+ /** Packed rgb (24-bit) pixels of the crop. */
12216
+ bytes: _instanceof(Uint8Array),
12217
+ width: number().int().positive(),
12218
+ height: number().int().positive()
12219
+ });
12220
+ /**
12063
12221
  * Per-camera tunable ranges + defaults. Single source of truth used
12064
12222
  * by both the Zod data schema (validation + default fallback) and
12065
12223
  * the device settings UI (slider min/max/step). Touch one place and
@@ -12154,6 +12312,13 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
12154
12312
  kind: literal("remote-restream"),
12155
12313
  /** The camera's source-owner node (slice 1: always the hub). */
12156
12314
  ownerNodeId: string(),
12315
+ /**
12316
+ * The owner's LAN-reachable host, resolved by the orchestrator from the
12317
+ * per-node `reachableHost` override (Cluster UI). When present the runner
12318
+ * dials THIS host for the owner's restream, in preference to the
12319
+ * `CAMSTACK_HUB_URL`-derived default. Absent → auto-detect fallback.
12320
+ */
12321
+ ownerReachableHost: string().optional(),
12157
12322
  /** Operator override for the owner host the runner dials. */
12158
12323
  hubHostnameOverride: string().optional()
12159
12324
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
@@ -12162,13 +12327,11 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
12162
12327
  * specific runner instance via `attachCamera`. Carries everything the
12163
12328
  * runner needs to subscribe to the local broker and execute inference.
12164
12329
  *
12165
- * Stateless-pipeline model: the full pipeline content (`engine`, `steps`,
12166
- * optional `audio`) travels with the attach payload. The runner keeps it
12167
- * in RAM for the lifetime of the attach — on rebalance, edit, or
12168
- * restart the orchestrator re-sends the latest snapshot.
12169
- *
12170
- * `engine`/`steps`/`audio` are optional during the additive migration
12171
- * window; once orchestrator + UI are migrated they become required.
12330
+ * Stateless-pipeline model: the pipeline content (`steps`, optional
12331
+ * `audio`) travels with the attach payload. The runner keeps it in RAM
12332
+ * for the lifetime of the attach — on rebalance, edit, or restart the
12333
+ * orchestrator re-sends the latest snapshot. Engine is NOT carried: it is
12334
+ * node-local, resolved by the executing runner at dispatch time.
12172
12335
  */
12173
12336
  var RunnerCameraConfigSchema = object({
12174
12337
  deviceId: number(),
@@ -12219,14 +12382,11 @@ var RunnerCameraConfigSchema = object({
12219
12382
  */
12220
12383
  motionSources: MotionSourcesSchema.default(["analyzer"]),
12221
12384
  pipelineEnabled: boolean().default(true),
12222
- /** Engine choice for video steps (runtime+backend+format). */
12223
- engine: PipelineEngineChoiceSchema.optional(),
12224
12385
  /** Ordered tree of video steps. Absent → runner skips video detection. */
12225
12386
  steps: array(PipelineStepInputSchema).readonly().optional(),
12226
12387
  /** Audio classification branch. `enabled:false` disables, null skips. */
12227
12388
  audio: object({
12228
- engine: PipelineEngineChoiceSchema,
12229
- modelId: string(),
12389
+ modelId: string().optional(),
12230
12390
  enabled: boolean()
12231
12391
  }).nullable().optional(),
12232
12392
  /**
@@ -12313,7 +12473,11 @@ var RunnerLocalMetricsSchema = object({
12313
12473
  avgInferenceTimeMs: number(),
12314
12474
  queueDepth: number()
12315
12475
  });
12316
- method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mutation" }), method(object({ deviceId: number() }), object({ success: literal(true) }), { kind: "mutation" }), method(ReportMotionInputSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), RunnerLocalLoadSchema), method(_void(), RunnerLocalMetricsSchema), method(object({ deviceId: number() }), CameraMetricsSchema.nullable()), method(_void(), array(CameraMetricsWithDeviceIdSchema).readonly()), method(_void(), array(number()).readonly());
12476
+ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mutation" }), method(object({ deviceId: number() }), object({ success: literal(true) }), { kind: "mutation" }), method(ReportMotionInputSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), RunnerLocalLoadSchema), method(_void(), RunnerLocalMetricsSchema), method(object({ deviceId: number() }), CameraMetricsSchema.nullable()), method(_void(), array(CameraMetricsWithDeviceIdSchema).readonly()), method(_void(), array(number()).readonly()), method(object({
12477
+ handle: FrameHandleSchema,
12478
+ bbox: NativeCropBboxSchema,
12479
+ maxWidth: number().int().positive().optional()
12480
+ }), NativeCropResultSchema.nullable());
12317
12481
  /**
12318
12482
  * Hardware / firmware motion sensor cap — binary detected state plus
12319
12483
  * a timestamp of the last observation. Distinct from
@@ -15244,7 +15408,9 @@ var AddonPageDeclarationSchema$1 = object({
15244
15408
  icon: string(),
15245
15409
  path: string(),
15246
15410
  remoteName: string(),
15247
- bundle: string()
15411
+ bundle: string(),
15412
+ section: string().optional(),
15413
+ sectionLabel: string().optional()
15248
15414
  });
15249
15415
  var AddonPageInfoSchema = object({
15250
15416
  addonId: string(),
@@ -15284,7 +15450,18 @@ var AddonPageDeclarationSchema = object({
15284
15450
  * the static-file route can compute an mtime-based cache-buster URL
15285
15451
  * without a separate filesystem stat.
15286
15452
  */
15287
- bundle: string()
15453
+ bundle: string(),
15454
+ /**
15455
+ * Sidebar section this page docks into. Well-known ids: `'detection'`,
15456
+ * `'cluster'`, `'administration'` — the page renders inside that group.
15457
+ * Any OTHER string creates (or joins) a custom section rendered after
15458
+ * the built-in groups; its label comes from `sectionLabel` (first
15459
+ * declaration wins), falling back to the id. Absent → the legacy
15460
+ * "Addon Pages" group.
15461
+ */
15462
+ section: string().optional(),
15463
+ /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
15464
+ sectionLabel: string().optional()
15288
15465
  });
15289
15466
  method(_void(), array(AddonPageDeclarationSchema).readonly());
15290
15467
  var AddonHttpRouteSchema = object({
@@ -15500,6 +15677,17 @@ var WidgetMetadataSchema = object({
15500
15677
  deviceContext: boolean().default(false),
15501
15678
  integrationContext: boolean().default(false)
15502
15679
  }),
15680
+ /**
15681
+ * Loadable BEFORE authentication. The normal widget registry listing
15682
+ * (`addon-widgets.listWidgets`) is auth-gated, so a pre-auth surface
15683
+ * (the login page) cannot discover a widget through it. A widget that
15684
+ * declares `preAuth: true` marks itself as safe to mount on a pre-auth
15685
+ * screen — it is surfaced through the PUBLIC `auth.listLoginMethods`
15686
+ * login-method contribution channel (see `login-method.cap.ts`) rather
15687
+ * than the authenticated registry, and its bundle is served by the
15688
+ * public `/api/addon-widgets/:addonId/*` static route. Defaults false.
15689
+ */
15690
+ preAuth: boolean().optional().default(false),
15503
15691
  /** Dashboard placement HINTS (operator can override per instance). */
15504
15692
  defaultSize: WidgetSizeEnum.default("md"),
15505
15693
  allowedSizes: array(WidgetSizeEnum).readonly().default([
@@ -15801,6 +15989,66 @@ method(object({
15801
15989
  password: string()
15802
15990
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
15803
15991
  /**
15992
+ * `login-method` — collection cap through which auth addons contribute
15993
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
15994
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
15995
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
15996
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
15997
+ * procedure aggregates them for the unauthenticated login page.
15998
+ *
15999
+ * A contribution is a discriminated union on `kind`:
16000
+ *
16001
+ * - `redirect` — a declarative button. The login page renders a generic
16002
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
16003
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16004
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
16005
+ * login page needs NO change.
16006
+ *
16007
+ * - `widget` — a Module-Federation widget the login page mounts (via
16008
+ * `loadRemoteBundle`) for an in-page ceremony. Covers the passkey
16009
+ * login ceremony, which must run `@simplewebauthn/browser` INSIDE the
16010
+ * addon bundle. The referenced widget also declares `preAuth: true` in
16011
+ * its `addon-widgets-source` catalog entry. `auth.listLoginMethods`
16012
+ * stamps a public `bundleUrl` from `addonId` + `bundle`.
16013
+ *
16014
+ * Every contribution carries a `stage`:
16015
+ * - `primary` — shown on the first credentials screen (OIDC /
16016
+ * magic-link buttons; a future usernameless passkey).
16017
+ * - `second-factor` — shown AFTER the password leg, gated on the
16018
+ * returned `factors` (passkey-as-2FA today).
16019
+ *
16020
+ * `mount: skip` — the cap is read server-side by the core auth router
16021
+ * (`registry.getCollection('login-method')`), never mounted as its own
16022
+ * tRPC router.
16023
+ */
16024
+ /** When a login method renders in the two-phase login flow. */
16025
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
16026
+ /** One login-method contribution — redirect button OR pre-auth widget. */
16027
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [object({
16028
+ kind: literal("redirect"),
16029
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16030
+ id: string(),
16031
+ /** Operator-facing button label. */
16032
+ label: string(),
16033
+ /** lucide-react icon name. */
16034
+ icon: string().optional(),
16035
+ /** Addon-owned HTTP route the button navigates to (GET). */
16036
+ startUrl: string(),
16037
+ stage: LoginStageEnum
16038
+ }), object({
16039
+ kind: literal("widget"),
16040
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16041
+ id: string(),
16042
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
16043
+ addonId: string(),
16044
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16045
+ bundle: string(),
16046
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16047
+ remote: WidgetRemoteSchema,
16048
+ stage: LoginStageEnum
16049
+ })]);
16050
+ method(_void(), array(LoginMethodContributionSchema).readonly());
16051
+ /**
15804
16052
  * Orchestrator-side destination metadata. The orchestrator computes
15805
16053
  * `id = <addonId>:<subId>` from its provider lookup so consumers
15806
16054
  * (admin UI, restore flow) see one canonical key.
@@ -17904,7 +18152,17 @@ var TrackSchema = object({
17904
18152
  /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17905
18153
  totalDistance: number(),
17906
18154
  state: TrackStateSchema,
17907
- active: boolean()
18155
+ active: boolean(),
18156
+ /** Deterministic key-event importance score in [0,1] (server-computed at
18157
+ * track expiry, recomputed on late label). Absent on legacy rows written
18158
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
18159
+ importance: number().optional(),
18160
+ /** Id of the track's highest-confidence ObjectEvent (its representative
18161
+ * "best" frame). Absent when the track produced no object events. */
18162
+ bestEventId: string().optional(),
18163
+ /** Tag of the importance sub-signal that dominated the score
18164
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
18165
+ importanceReason: string().optional()
17908
18166
  });
17909
18167
  var BaseEventFields = {
17910
18168
  id: string(),
@@ -17969,8 +18227,18 @@ var ObjectEventSchema = object({
17969
18227
  frameHeight: number().optional(),
17970
18228
  /** MediaStore key for the crop attached to this event (if any). */
17971
18229
  mediaKey: string().optional(),
18230
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
18231
+ * best-detection full frame). Resolve via the event-media data-plane
18232
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18233
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18234
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
18235
+ keyFrameMediaKey: string().optional(),
17972
18236
  /** Populated by B5 (recording playback URL for this event). */
17973
- mediaUrl: string().optional()
18237
+ mediaUrl: string().optional(),
18238
+ /** The parent track's key-event importance [0,1], propagated to every object
18239
+ * event of the track (so an event row can be sorted by importance without a
18240
+ * track join). Absent on legacy rows / before the track was scored. */
18241
+ importance: number().optional()
17974
18242
  });
17975
18243
  var AudioEventSchema = object({
17976
18244
  ...BaseEventFields,
@@ -17994,7 +18262,8 @@ var MediaFileKindEnum = _enum([
17994
18262
  "fullFrame",
17995
18263
  "fullFrameBoxed",
17996
18264
  "faceCrop",
17997
- "plateCrop"
18265
+ "plateCrop",
18266
+ "keyFrame"
17998
18267
  ]);
17999
18268
  var MediaFileSchema = object({
18000
18269
  key: string(),
@@ -18015,6 +18284,32 @@ var DeviceEventQueryInput = object({
18015
18284
  projection: _enum(["full", "slim"]).optional()
18016
18285
  });
18017
18286
  var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18287
+ var KeyEventQueryInput = object({
18288
+ deviceId: number(),
18289
+ /** Window lower bound (track firstSeen ≥ since). */
18290
+ since: number(),
18291
+ /** Window upper bound (track firstSeen ≤ until). */
18292
+ until: number(),
18293
+ limit: number().int().min(1).max(200).default(50),
18294
+ /** Drop tracks scoring below this importance. */
18295
+ minImportance: number().min(0).max(1).optional(),
18296
+ /** Restrict to a single class (e.g. 'person'). */
18297
+ classFilter: string().optional()
18298
+ });
18299
+ var KeyEventSchema = object({
18300
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18301
+ id: string(),
18302
+ trackId: string(),
18303
+ /** Track start time (firstSeen). */
18304
+ timestamp: number(),
18305
+ className: string(),
18306
+ label: string().optional(),
18307
+ importance: number(),
18308
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18309
+ bestEventId: string(),
18310
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18311
+ windowMs: number().optional()
18312
+ });
18018
18313
  var TrackedDetectionSchema = object({
18019
18314
  trackId: string(),
18020
18315
  className: string(),
@@ -18044,7 +18339,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18044
18339
  }), array(TrackSchema).readonly()), method(object({ deviceId: number() }), _void(), {
18045
18340
  kind: "mutation",
18046
18341
  auth: "admin"
18047
- }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({
18342
+ }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18048
18343
  deviceId: number(),
18049
18344
  since: number(),
18050
18345
  until: number(),
@@ -18089,11 +18384,11 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18089
18384
  timestamp: number()
18090
18385
  });
18091
18386
  var CameraPipelineConfigSchema = object({
18092
- engine: PipelineEngineChoiceSchema,
18387
+ engine: PipelineEngineChoiceSchema.optional(),
18093
18388
  steps: array(PipelineStepInputSchema).readonly(),
18094
18389
  audio: object({
18095
- engine: PipelineEngineChoiceSchema,
18096
- modelId: string(),
18390
+ engine: PipelineEngineChoiceSchema.optional(),
18391
+ modelId: string().optional(),
18097
18392
  enabled: boolean(),
18098
18393
  settings: record(string(), unknown()).readonly().optional()
18099
18394
  }).nullable().optional()
@@ -18108,7 +18403,7 @@ var PipelineTemplateSchema = object({
18108
18403
  });
18109
18404
  var AgentAddonConfigSchema = object({
18110
18405
  enabled: boolean(),
18111
- modelId: string(),
18406
+ modelId: string().optional(),
18112
18407
  settings: record(string(), unknown()).readonly()
18113
18408
  });
18114
18409
  var AgentPipelineSettingsSchema = object({
@@ -18118,12 +18413,25 @@ var AgentPipelineSettingsSchema = object({
18118
18413
  detectWeight: number().positive().optional(),
18119
18414
  /** Node is eligible to run the detection pipeline (decode + inference). */
18120
18415
  detect: boolean().optional(),
18121
- /** Node is eligible to host decoder sessions. */
18416
+ /**
18417
+ * DEPRECATED AND IGNORED. Decode is always co-located with its frame
18418
+ * consumer, so decode eligibility IS detect eligibility. Kept optional in
18419
+ * the schema ONLY so persisted stores written before the removal still
18420
+ * parse — no code reads it and no write path emits it.
18421
+ */
18122
18422
  decode: boolean().optional(),
18123
18423
  /** Node is eligible to run audio-analyzer sessions. */
18124
18424
  audio: boolean().optional(),
18125
18425
  /** Node is eligible to be the ingest / source-owner (serve the restream). */
18126
- ingest: boolean().optional()
18426
+ ingest: boolean().optional(),
18427
+ /**
18428
+ * Operator override for the LAN host a cross-node decoder dials to reach
18429
+ * THIS node's restream (Cluster UI). Absent → auto-detect: a remote runner
18430
+ * falls back to its `CAMSTACK_HUB_URL`-derived host (the Moleculer address
18431
+ * it already uses to reach the hub). Set this only when the auto-detected
18432
+ * address is wrong (multi-homed host, NAT, custom interface).
18433
+ */
18434
+ reachableHost: string().optional()
18127
18435
  });
18128
18436
  var CameraPipelineForAgentSchema = object({
18129
18437
  steps: array(PipelineStepInputSchema).readonly(),
@@ -18171,25 +18479,6 @@ var PipelineAssignmentSchema = object({
18171
18479
  assignedAt: number()
18172
18480
  });
18173
18481
  /**
18174
- * Decoder placement record. Symmetric to `PipelineAssignmentSchema` but for
18175
- * the decoder-node placement domain (`balanceDecoder` decision: manual pin
18176
- * → co-located with pipeline → capacity).
18177
- */
18178
- var DecoderAssignmentSchema = object({
18179
- deviceId: number(),
18180
- /** Moleculer node id of the decoder provider currently responsible for this camera. */
18181
- decoderNodeId: string(),
18182
- /** True when the assignment was set manually via `assignDecoder`, false when chosen by the balancer. */
18183
- pinned: boolean(),
18184
- /** Why this assignment was made — useful for debugging the decoder balancer. */
18185
- reason: _enum([
18186
- "manual",
18187
- "co-located",
18188
- "capacity",
18189
- "hardware-affinity"
18190
- ])
18191
- });
18192
- /**
18193
18482
  * Per-agent load summary surfaced to the load balancer + dashboards.
18194
18483
  * Aggregated from each runner's `getLocalLoad` cap call.
18195
18484
  */
@@ -18229,6 +18518,15 @@ var GlobalMetricsSchema = object({
18229
18518
  * capability providers.
18230
18519
  */
18231
18520
  var CapabilityBindingsSchema = record(string(), string());
18521
+ /**
18522
+ * The cluster's single camera-source owner (`clusterRoles.ingestNode`) plus
18523
+ * its LAN-reachable host, if one is registered. See `getIngestOwner`.
18524
+ */
18525
+ var IngestOwnerSchema = object({
18526
+ ownerNodeId: string(),
18527
+ reachableHost: string().optional(),
18528
+ configIssue: string().optional()
18529
+ });
18232
18530
  /** Source block — always present; derives from the stream catalog. */
18233
18531
  var CameraSourceStatusSchema = object({ streams: array(object({
18234
18532
  camStreamId: string(),
@@ -18243,6 +18541,14 @@ var CameraAssignmentStatusSchema = object({
18243
18541
  detectionNodeId: string().nullable(),
18244
18542
  decoderNodeId: string().nullable(),
18245
18543
  audioNodeId: string().nullable(),
18544
+ /**
18545
+ * The node that OWNS this camera's physical source pull (dials the RTSP and
18546
+ * hosts the broker/restream) — the cluster ingest owner today
18547
+ * (`clusterRoles.ingestNode`), per-camera once source assignment lands. Lets
18548
+ * the UI show WHERE a camera is sourced without SSH/logs, and is the node the
18549
+ * broker block below was read from (pinned). Nullable only pre-wiring.
18550
+ */
18551
+ sourceNodeId: string().nullable(),
18246
18552
  pinned: object({
18247
18553
  detection: boolean(),
18248
18554
  decoder: boolean(),
@@ -18375,16 +18681,7 @@ method(object({
18375
18681
  }), object({ success: literal(true) }), {
18376
18682
  kind: "mutation",
18377
18683
  auth: "admin"
18378
- }), method(object({
18379
- deviceId: number(),
18380
- nodeId: string()
18381
- }), _void(), {
18382
- kind: "mutation",
18383
- auth: "admin"
18384
- }), method(object({ deviceId: number() }), _void(), {
18385
- kind: "mutation",
18386
- auth: "admin"
18387
- }), method(_void(), array(DecoderAssignmentSchema).readonly()), method(object({
18684
+ }), method(_void(), IngestOwnerSchema), method(object({
18388
18685
  deviceId: number(),
18389
18686
  nodeId: string()
18390
18687
  }), object({ success: literal(true) }), {
@@ -18405,10 +18702,7 @@ method(object({
18405
18702
  nodeId: string(),
18406
18703
  pinned: boolean(),
18407
18704
  assignedAt: number()
18408
- }))), method(object({
18409
- deviceId: number(),
18410
- pipelineNodeId: string().optional()
18411
- }), DecoderAssignmentSchema), method(object({ agentNodeId: string() }), AgentPipelineSettingsSchema.nullable()), method(_void(), array(object({
18705
+ }))), method(object({ agentNodeId: string() }), AgentPipelineSettingsSchema.nullable()), method(_void(), array(object({
18412
18706
  nodeId: string(),
18413
18707
  settings: AgentPipelineSettingsSchema
18414
18708
  })).readonly()), method(object({
@@ -18438,12 +18732,26 @@ method(object({
18438
18732
  }), method(object({
18439
18733
  agentNodeId: string(),
18440
18734
  detect: boolean().nullable().optional(),
18441
- decode: boolean().nullable().optional(),
18442
18735
  audio: boolean().nullable().optional(),
18443
18736
  ingest: boolean().nullable().optional()
18444
18737
  }), object({ success: literal(true) }), {
18445
18738
  kind: "mutation",
18446
18739
  auth: "admin"
18740
+ }), method(object({
18741
+ agentNodeId: string(),
18742
+ reachableHost: string().nullable()
18743
+ }), object({ success: literal(true) }), {
18744
+ kind: "mutation",
18745
+ auth: "admin"
18746
+ }), method(object({ agentNodeId: string() }), object({
18747
+ success: literal(true),
18748
+ /** Hardware-aware default detection model now in effect on the node (null when unresolvable). */
18749
+ effectiveModelId: string().nullable(),
18750
+ /** Number of cameras whose node-scoped overrides were cleared. */
18751
+ clearedCameraOverrides: number()
18752
+ }), {
18753
+ kind: "mutation",
18754
+ auth: "admin"
18447
18755
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
18448
18756
  deviceId: number(),
18449
18757
  addonId: string(),
@@ -18488,22 +18796,131 @@ method(object({
18488
18796
  kind: "mutation",
18489
18797
  auth: "admin"
18490
18798
  });
18491
- var RegisteredStreamSchema = object({
18492
- streamId: string(),
18493
- label: string().optional(),
18494
- codec: string(),
18495
- type: _enum(["video", "audio"]),
18496
- sourceUrl: string()
18799
+ /**
18800
+ * server-management — per-NODE singleton capability for a node's ROOT
18801
+ * package lifecycle (runtime-updatable node packages, phase 2: hub + docker
18802
+ * agents).
18803
+ *
18804
+ * Each node's root package (`@camstack/server` on the hub, `@camstack/agent`
18805
+ * on agents) carries the whole software stack in its npm dep tree, so ONE
18806
+ * version describes the node. Updates install into
18807
+ * `<dataDir>/server-root/versions/<v>/` and apply on restart via the baked
18808
+ * starter (probation boot + auto-rollback to N-1).
18809
+ *
18810
+ * Providers:
18811
+ * - HUB: `ServerUpdateService` behind the `server-provided` mount
18812
+ * (`buildServerProviders` in trpc.router.ts) — the default target for
18813
+ * unpinned calls.
18814
+ * - AGENT: `AgentUpdateService` registered by the agent bootstrap under
18815
+ * the synthetic `agent-runtime` addonId and declared in the agent's
18816
+ * `$hub.registerNode` manifest.
18817
+ *
18818
+ * Node routing: singleton caps get the codegen/runtime-builder `nodeId`
18819
+ * injection on every method — `input.nodeId` (or `nodePin(nodeId)` from the
18820
+ * SDK) routes the call to that node's provider via the standard remote
18821
+ * proxy (`createCapabilityProxy` → `$agent-cap-fwd` → the agent's
18822
+ * in-process provider lookup). No `nodeId` → the hub's own provider.
18823
+ *
18824
+ * Spec: docs/superpowers/specs/2026-07-12-runtime-updatable-node-packages-design.md
18825
+ */
18826
+ /**
18827
+ * Where the running hub's code was loaded from:
18828
+ * - `workspace` — dev checkout (tsx / workspace dist); the starter defers to
18829
+ * plain resolution and runtime updates are refused.
18830
+ * - `baked` — the immutable image seed closure (no data-dir root active).
18831
+ * - `data-root` — the runtime-updatable `<dataDir>/server-root` closure.
18832
+ */
18833
+ var ServerBootModeSchema = _enum([
18834
+ "workspace",
18835
+ "baked",
18836
+ "data-root"
18837
+ ]);
18838
+ /**
18839
+ * Update lifecycle state:
18840
+ * - `idle` / `checking` / `staging` — steady / in-flight registry work.
18841
+ * - `pending-restart` — a version is staged and the node has NOT yet
18842
+ * restarted onto it (still running the OLD version).
18843
+ * - `awaiting-confirmation` — the node HAS restarted onto the staged version
18844
+ * (it is the active probation boot) and is waiting to confirm boot-health.
18845
+ * Apply/rollback are refused in this state and the node must NOT be
18846
+ * manually restarted, or the probation boot auto-rolls-back.
18847
+ */
18848
+ var ServerUpdateStateSchema = _enum([
18849
+ "idle",
18850
+ "checking",
18851
+ "staging",
18852
+ "pending-restart",
18853
+ "awaiting-confirmation"
18854
+ ]);
18855
+ var ServerRollbackInfoSchema = object({
18856
+ /** The version that failed (or was manually rolled back). */
18857
+ fromVersion: string(),
18858
+ /** The version rolled back to; null = the baked seed. */
18859
+ toVersion: string().nullable(),
18860
+ atMs: number(),
18861
+ reason: string()
18497
18862
  });
18498
- var ExposedResourceSchema = object({
18499
- streamId: string(),
18500
- format: string(),
18501
- value: string()
18863
+ var ServerPackageStatusSchema = object({
18864
+ /** Root package name (`@camstack/server` on the hub). */
18865
+ packageName: string(),
18866
+ /** Version of the code the running process ACTUALLY loaded. */
18867
+ runningVersion: string().nullable(),
18868
+ /** Node.js runtime version the node's process runs on (`process.versions.node`). */
18869
+ nodeRuntimeVersion: string().nullable(),
18870
+ /** Active data-dir root version; null when booted from seed/workspace. */
18871
+ activeVersion: string().nullable(),
18872
+ /** N-1 version kept for rollback; null when no previous version exists. */
18873
+ previousVersion: string().nullable(),
18874
+ /** Version of the immutable baked seed closure (image fallback). */
18875
+ seedVersion: string().nullable(),
18876
+ /** Latest registry version from the most recent check (null = never checked). */
18877
+ latestVersion: string().nullable(),
18878
+ updateAvailable: boolean(),
18879
+ bootMode: ServerBootModeSchema,
18880
+ updateState: ServerUpdateStateSchema,
18881
+ /** Version staged + awaiting its probation boot, when one is pending. */
18882
+ pendingVersion: string().nullable(),
18883
+ /** Set when the last freshly-activated version failed its boot health-check. */
18884
+ rolledBack: ServerRollbackInfoSchema.nullable(),
18885
+ /**
18886
+ * True when `server-root/state.json` EXISTS but is unreadable/corrupt — the
18887
+ * hub is running from the baked seed (or workspace) while installed data-dir
18888
+ * versions are being IGNORED. Surfaced as a warning in the UI.
18889
+ */
18890
+ stateFileCorrupt: boolean(),
18891
+ lastCheckedAtMs: number().nullable()
18892
+ });
18893
+ var ServerUpdateCheckResultSchema = object({
18894
+ packageName: string(),
18895
+ runningVersion: string().nullable(),
18896
+ latestVersion: string().nullable(),
18897
+ updateAvailable: boolean(),
18898
+ checkedAtMs: number(),
18899
+ /** Non-null when the registry lookup failed (offline, bad registry, …). */
18900
+ error: string().nullable()
18901
+ });
18902
+ var ServerUpdateActionResultSchema = object({
18903
+ accepted: boolean(),
18904
+ targetVersion: string().nullable(),
18905
+ /** True when a graceful restart was scheduled to apply the change. */
18906
+ restarting: boolean(),
18907
+ message: string()
18908
+ });
18909
+ method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
18910
+ kind: "mutation",
18911
+ auth: "admin"
18912
+ }), method(object({
18913
+ /** Explicit target version; omitted = latest from the registry. */
18914
+ version: string().optional() }), ServerUpdateActionResultSchema, {
18915
+ kind: "mutation",
18916
+ auth: "admin"
18917
+ }), method(_void(), ServerUpdateActionResultSchema, {
18918
+ kind: "mutation",
18919
+ auth: "admin"
18920
+ }), method(_void(), ServerUpdateActionResultSchema, {
18921
+ kind: "mutation",
18922
+ auth: "admin"
18502
18923
  });
18503
- method(object({
18504
- deviceId: number(),
18505
- streams: array(RegisteredStreamSchema).readonly()
18506
- }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), array(ExposedResourceSchema).readonly());
18507
18924
  /**
18508
18925
  * Query filter for settings-store collections.
18509
18926
  */
@@ -18656,9 +19073,9 @@ method(SendEmailInputSchema, SendEmailResultSchema, {
18656
19073
  /**
18657
19074
  * A single device snapshot returned as base64 JPEG/PNG.
18658
19075
  *
18659
- * Shared with the `snapshot-provider` collection cap the orchestrator
18660
- * receives the same shape from each native provider and from the
18661
- * broker-based fallback.
19076
+ * The `SnapshotAddon` wrapper returns this shape whether the frame came from
19077
+ * the device-native provider (onboard capture) or from the stream-broker
19078
+ * prebuffer fallback.
18662
19079
  */
18663
19080
  var SnapshotImageSchema = object({
18664
19081
  base64: string(),
@@ -18726,17 +19143,26 @@ var snapshotCapability = {
18726
19143
  invalidateCache: method(object({ deviceId: number() }), _void(), {
18727
19144
  kind: "mutation",
18728
19145
  auth: "admin"
18729
- })
19146
+ }),
19147
+ /**
19148
+ * Cache-only batch overview — answers from the wrapper's in-memory cache in
19149
+ * O(n) and NEVER triggers a capture. Lets a grid skip requesting images for
19150
+ * devices that never produced a frame, and gives it an ETag per device for
19151
+ * conditional (304-able) image fetches. `lastCapturedAt`/`cacheAgeMs`/`etag`
19152
+ * are null for a device with no cached frame.
19153
+ */
19154
+ getSnapshotOverview: systemMethod(object({ deviceIds: array(number()).min(1).max(200) }), array(object({
19155
+ deviceId: number(),
19156
+ lastCapturedAt: number().nullable(),
19157
+ cacheAgeMs: number().nullable(),
19158
+ etag: string().nullable()
19159
+ })))
18730
19160
  },
18731
19161
  status: {
18732
19162
  schema: SnapshotStatusSchema,
18733
19163
  kind: "poll"
18734
19164
  }
18735
19165
  };
18736
- method(object({ deviceId: number() }), boolean()), method(object({
18737
- deviceId: number(),
18738
- streamId: string().optional()
18739
- }), SnapshotImageSchema.nullable());
18740
19166
  /**
18741
19167
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
18742
19168
  * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
@@ -18987,10 +19413,32 @@ method(_void(), array(TurnServerSchema).readonly());
18987
19413
  * b. `finishAuthentication({userId, response})` → server verifies
18988
19414
  * the assertion, bumps the credential counter, returns ok.
18989
19415
  *
19416
+ * 2b. Usernameless (discoverable-credential) authentication — the
19417
+ * passkey IS the primary factor, no password leg:
19418
+ * a. `beginDiscoverableAuthentication({})` → assertion options with
19419
+ * EMPTY `allowCredentials` (the browser offers every resident
19420
+ * passkey it holds for this RP) + `userVerification: 'required'`
19421
+ * (the passkey replaces both factors, so UV is mandatory).
19422
+ * The challenge is stored server-side, NOT bound to any user.
19423
+ * b. `finishDiscoverableAuthentication({response})` → the provider
19424
+ * resolves the credential by the response's credential id,
19425
+ * verifies the assertion against the stored challenge + that
19426
+ * credential's public key/counter, and returns the OWNING
19427
+ * `userId` — the caller (core auth router) mints the session.
19428
+ *
18990
19429
  * 3. Management:
18991
19430
  * - `listPasskeys({userId})` — enumerate user's enrolled credentials.
18992
19431
  * - `removePasskey({userId, credentialId})` — revoke one credential.
18993
19432
  *
19433
+ * 4. Second-factor preference (opt-in, default OFF):
19434
+ * Enrolling a passkey only enables passkey-FIRST sign-in. It is
19435
+ * demanded as a second factor after a password login ONLY when the
19436
+ * user explicitly opts in via `setSecondFactorPreference`.
19437
+ * - `getSecondFactorPreference({userId})` → `{ enabled }` (missing
19438
+ * row ⇒ `enabled: false`).
19439
+ * - `setSecondFactorPreference({userId, enabled})` — persisted by
19440
+ * the providing addon beside its credentials.
19441
+ *
18994
19442
  * Challenges are short-lived (5 min, in-memory). The cap is internal —
18995
19443
  * the admin-ui composes the begin/finish round-trip and never exposes
18996
19444
  * the cap to non-admins.
@@ -19033,6 +19481,17 @@ method(object({
19033
19481
  }), object({ verified: boolean() }), {
19034
19482
  kind: "mutation",
19035
19483
  access: "view"
19484
+ }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
19485
+ kind: "mutation",
19486
+ access: "view"
19487
+ }), method(object({
19488
+ /** AuthenticationResponseJSON from the browser. */
19489
+ response: record(string(), unknown()) }), object({
19490
+ verified: boolean(),
19491
+ userId: string().nullable()
19492
+ }), {
19493
+ kind: "mutation",
19494
+ access: "view"
19036
19495
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
19037
19496
  userId: string(),
19038
19497
  credentialId: string()
@@ -19040,6 +19499,13 @@ method(object({
19040
19499
  kind: "mutation",
19041
19500
  auth: "admin",
19042
19501
  access: "delete"
19502
+ }), method(object({ userId: string() }), object({ enabled: boolean() }), { auth: "admin" }), method(object({
19503
+ userId: string(),
19504
+ enabled: boolean()
19505
+ }), object({ success: literal(true) }), {
19506
+ kind: "mutation",
19507
+ auth: "admin",
19508
+ access: "create"
19043
19509
  });
19044
19510
  /**
19045
19511
  * `videoclips` — the unified, navigable-clip surface for a camera.
@@ -19097,9 +19563,10 @@ method(object({
19097
19563
  auth: "admin"
19098
19564
  });
19099
19565
  /**
19100
- * Optional client-side hints sent at session creation to help the
19101
- * provider pick the best native source. All fields are optional —
19102
- * a viewer that knows nothing still gets a sane default.
19566
+ * Optional client-side hints sent at session creation to help the provider
19567
+ * pick the best native source. All fields optional — a viewer that knows
19568
+ * nothing still gets a sane default. (Relocated from the retired `webrtc`
19569
+ * collection cap; this `webrtc-session` cap is the live signaling surface.)
19103
19570
  */
19104
19571
  var webrtcClientHintsSchema = object({
19105
19572
  viewportWidth: number().int().positive().optional(),
@@ -19110,22 +19577,6 @@ var webrtcClientHintsSchema = object({
19110
19577
  /** Hard tier override; takes precedence over scoring when registered. */
19111
19578
  prefersTier: string().optional()
19112
19579
  }).partial();
19113
- method(object({
19114
- streamId: string(),
19115
- sdpOffer: string()
19116
- }), string(), { kind: "mutation" }), method(object({ streamId: string() }), boolean()), method(object({
19117
- streamId: string(),
19118
- codec: string()
19119
- }), _void(), { kind: "mutation" }), method(object({ streamId: string() }), _void(), { kind: "mutation" }), method(object({
19120
- streamId: string(),
19121
- hints: webrtcClientHintsSchema.optional()
19122
- }), object({
19123
- sessionId: string(),
19124
- sdpOffer: string()
19125
- }), { kind: "mutation" }), method(object({
19126
- sessionId: string(),
19127
- sdpAnswer: string()
19128
- }), _void(), { kind: "mutation" }), method(object({ sessionId: string() }), _void(), { kind: "mutation" }), method(object({ streamId: string() }), boolean());
19129
19580
  /**
19130
19581
  * Discriminated target for a WebRTC session. The client sends this
19131
19582
  * structured object instead of building / parsing brokerId strings;
@@ -19856,7 +20307,17 @@ var FaceInfoSchema = object({
19856
20307
  recognizedIdentityId: string().optional(),
19857
20308
  identityName: string().optional(),
19858
20309
  assigned: boolean(),
19859
- base64: string().optional()
20310
+ base64: string().optional(),
20311
+ /** Design B: the face bbox (pixel space) on the key frame — lets a detail
20312
+ * view draw the box over the native `keyFrameMediaKey` frame. Absent on
20313
+ * legacy rows written before design B. */
20314
+ faceBbox: BoundingBoxSchema.optional(),
20315
+ /** Design B: MediaStore key of the track's native-resolution key frame.
20316
+ * Fetch the native JPEG via the event-media data-plane
20317
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
20318
+ * track produced no key frame (e.g. native/onboard source) — the UI falls
20319
+ * back to the inline `base64` face crop. */
20320
+ keyFrameMediaKey: string().optional()
19860
20321
  });
19861
20322
  var FaceFilterEnum = _enum([
19862
20323
  "unassigned",
@@ -20553,6 +21014,16 @@ var TopologyCategorySchema = object({
20553
21014
  healthy: number(),
20554
21015
  addons: array(TopologyCategoryAddonSchema).readonly()
20555
21016
  });
21017
+ /**
21018
+ * The node's runtime-updatable ROOT package (`@camstack/server` on the hub,
21019
+ * `@camstack/agent` on agents) as reported by its `registerNode` manifest —
21020
+ * version visibility for the Server management surface. Nullable: offline
21021
+ * rows and pre-phase-2 nodes report none.
21022
+ */
21023
+ var TopologyRootPackageSchema = object({
21024
+ name: string(),
21025
+ version: string()
21026
+ });
20556
21027
  var TopologyNodeSchema = object({
20557
21028
  id: string(),
20558
21029
  name: string(),
@@ -20576,7 +21047,8 @@ var TopologyNodeSchema = object({
20576
21047
  status: string()
20577
21048
  })).readonly(),
20578
21049
  processes: array(TopologyProcessSchema).readonly(),
20579
- categories: array(TopologyCategorySchema).readonly()
21050
+ categories: array(TopologyCategorySchema).readonly(),
21051
+ rootPackage: TopologyRootPackageSchema.nullable()
20580
21052
  });
20581
21053
  var CapUsageEdgeSchema = object({
20582
21054
  callerAddonId: string(),
@@ -23389,6 +23861,12 @@ Object.freeze({
23389
23861
  addonId: null,
23390
23862
  access: "create"
23391
23863
  },
23864
+ "loginMethod.getLoginMethods": {
23865
+ capName: "login-method",
23866
+ capScope: "system",
23867
+ addonId: null,
23868
+ access: "view"
23869
+ },
23392
23870
  "mediaPlayer.next": {
23393
23871
  capName: "media-player",
23394
23872
  capScope: "device",
@@ -23971,6 +24449,12 @@ Object.freeze({
23971
24449
  addonId: null,
23972
24450
  access: "view"
23973
24451
  },
24452
+ "pipelineAnalytics.getKeyEvents": {
24453
+ capName: "pipeline-analytics",
24454
+ capScope: "device",
24455
+ addonId: null,
24456
+ access: "view"
24457
+ },
23974
24458
  "pipelineAnalytics.getMotionEvents": {
23975
24459
  capName: "pipeline-analytics",
23976
24460
  capScope: "device",
@@ -24019,23 +24503,23 @@ Object.freeze({
24019
24503
  addonId: null,
24020
24504
  access: "create"
24021
24505
  },
24022
- "pipelineExecutor.deleteModel": {
24506
+ "pipelineExecutor.clearDeviceOverrides": {
24023
24507
  capName: "pipeline-executor",
24024
24508
  capScope: "system",
24025
24509
  addonId: null,
24026
24510
  access: "delete"
24027
24511
  },
24028
- "pipelineExecutor.deleteTemplate": {
24512
+ "pipelineExecutor.deleteModel": {
24029
24513
  capName: "pipeline-executor",
24030
24514
  capScope: "system",
24031
24515
  addonId: null,
24032
24516
  access: "delete"
24033
24517
  },
24034
- "pipelineExecutor.detect": {
24518
+ "pipelineExecutor.deleteTemplate": {
24035
24519
  capName: "pipeline-executor",
24036
24520
  capScope: "system",
24037
24521
  addonId: null,
24038
- access: "view"
24522
+ access: "delete"
24039
24523
  },
24040
24524
  "pipelineExecutor.downloadModel": {
24041
24525
  capName: "pipeline-executor",
@@ -24229,13 +24713,13 @@ Object.freeze({
24229
24713
  addonId: null,
24230
24714
  access: "create"
24231
24715
  },
24232
- "pipelineOrchestrator.assignAudio": {
24233
- capName: "pipeline-orchestrator",
24716
+ "pipelineExecutor.validatePipeline": {
24717
+ capName: "pipeline-executor",
24234
24718
  capScope: "system",
24235
24719
  addonId: null,
24236
- access: "create"
24720
+ access: "view"
24237
24721
  },
24238
- "pipelineOrchestrator.assignDecoder": {
24722
+ "pipelineOrchestrator.assignAudio": {
24239
24723
  capName: "pipeline-orchestrator",
24240
24724
  capScope: "system",
24241
24725
  addonId: null,
@@ -24319,19 +24803,13 @@ Object.freeze({
24319
24803
  addonId: null,
24320
24804
  access: "view"
24321
24805
  },
24322
- "pipelineOrchestrator.getDecoderAssignment": {
24323
- capName: "pipeline-orchestrator",
24324
- capScope: "system",
24325
- addonId: null,
24326
- access: "view"
24327
- },
24328
- "pipelineOrchestrator.getDecoderAssignments": {
24806
+ "pipelineOrchestrator.getGlobalMetrics": {
24329
24807
  capName: "pipeline-orchestrator",
24330
24808
  capScope: "system",
24331
24809
  addonId: null,
24332
24810
  access: "view"
24333
24811
  },
24334
- "pipelineOrchestrator.getGlobalMetrics": {
24812
+ "pipelineOrchestrator.getIngestOwner": {
24335
24813
  capName: "pipeline-orchestrator",
24336
24814
  capScope: "system",
24337
24815
  addonId: null,
@@ -24373,6 +24851,12 @@ Object.freeze({
24373
24851
  addonId: null,
24374
24852
  access: "delete"
24375
24853
  },
24854
+ "pipelineOrchestrator.resetNodePipelineDefaults": {
24855
+ capName: "pipeline-orchestrator",
24856
+ capScope: "system",
24857
+ addonId: null,
24858
+ access: "delete"
24859
+ },
24376
24860
  "pipelineOrchestrator.resolvePipeline": {
24377
24861
  capName: "pipeline-orchestrator",
24378
24862
  capScope: "system",
@@ -24409,37 +24893,37 @@ Object.freeze({
24409
24893
  addonId: null,
24410
24894
  access: "create"
24411
24895
  },
24412
- "pipelineOrchestrator.setCameraPipelineForAgent": {
24896
+ "pipelineOrchestrator.setAgentReachableHost": {
24413
24897
  capName: "pipeline-orchestrator",
24414
24898
  capScope: "system",
24415
24899
  addonId: null,
24416
24900
  access: "create"
24417
24901
  },
24418
- "pipelineOrchestrator.setCameraStepOverride": {
24902
+ "pipelineOrchestrator.setCameraPipelineForAgent": {
24419
24903
  capName: "pipeline-orchestrator",
24420
24904
  capScope: "system",
24421
24905
  addonId: null,
24422
24906
  access: "create"
24423
24907
  },
24424
- "pipelineOrchestrator.setCameraStepToggle": {
24908
+ "pipelineOrchestrator.setCameraStepOverride": {
24425
24909
  capName: "pipeline-orchestrator",
24426
24910
  capScope: "system",
24427
24911
  addonId: null,
24428
24912
  access: "create"
24429
24913
  },
24430
- "pipelineOrchestrator.setCapabilityBinding": {
24914
+ "pipelineOrchestrator.setCameraStepToggle": {
24431
24915
  capName: "pipeline-orchestrator",
24432
24916
  capScope: "system",
24433
24917
  addonId: null,
24434
24918
  access: "create"
24435
24919
  },
24436
- "pipelineOrchestrator.unassignAudio": {
24920
+ "pipelineOrchestrator.setCapabilityBinding": {
24437
24921
  capName: "pipeline-orchestrator",
24438
24922
  capScope: "system",
24439
24923
  addonId: null,
24440
24924
  access: "create"
24441
24925
  },
24442
- "pipelineOrchestrator.unassignDecoder": {
24926
+ "pipelineOrchestrator.unassignAudio": {
24443
24927
  capName: "pipeline-orchestrator",
24444
24928
  capScope: "system",
24445
24929
  addonId: null,
@@ -24499,6 +24983,12 @@ Object.freeze({
24499
24983
  addonId: null,
24500
24984
  access: "view"
24501
24985
  },
24986
+ "pipelineRunner.getNativeCrop": {
24987
+ capName: "pipeline-runner",
24988
+ capScope: "system",
24989
+ addonId: null,
24990
+ access: "view"
24991
+ },
24502
24992
  "pipelineRunner.reportMotion": {
24503
24993
  capName: "pipeline-runner",
24504
24994
  capScope: "system",
@@ -24739,33 +25229,45 @@ Object.freeze({
24739
25229
  addonId: null,
24740
25230
  access: "create"
24741
25231
  },
24742
- "restreamer.getExposedResources": {
24743
- capName: "restreamer",
25232
+ "scriptRunner.run": {
25233
+ capName: "script-runner",
25234
+ capScope: "device",
25235
+ addonId: null,
25236
+ access: "create"
25237
+ },
25238
+ "scriptRunner.stop": {
25239
+ capName: "script-runner",
25240
+ capScope: "device",
25241
+ addonId: null,
25242
+ access: "create"
25243
+ },
25244
+ "serverManagement.applyServerUpdate": {
25245
+ capName: "server-management",
24744
25246
  capScope: "system",
24745
25247
  addonId: null,
24746
- access: "view"
25248
+ access: "create"
24747
25249
  },
24748
- "restreamer.registerDevice": {
24749
- capName: "restreamer",
25250
+ "serverManagement.checkServerUpdate": {
25251
+ capName: "server-management",
24750
25252
  capScope: "system",
24751
25253
  addonId: null,
24752
25254
  access: "create"
24753
25255
  },
24754
- "restreamer.unregisterDevice": {
24755
- capName: "restreamer",
25256
+ "serverManagement.getServerPackageStatus": {
25257
+ capName: "server-management",
24756
25258
  capScope: "system",
24757
25259
  addonId: null,
24758
- access: "delete"
25260
+ access: "view"
24759
25261
  },
24760
- "scriptRunner.run": {
24761
- capName: "script-runner",
24762
- capScope: "device",
25262
+ "serverManagement.restartServer": {
25263
+ capName: "server-management",
25264
+ capScope: "system",
24763
25265
  addonId: null,
24764
25266
  access: "create"
24765
25267
  },
24766
- "scriptRunner.stop": {
24767
- capName: "script-runner",
24768
- capScope: "device",
25268
+ "serverManagement.rollbackServerUpdate": {
25269
+ capName: "server-management",
25270
+ capScope: "system",
24769
25271
  addonId: null,
24770
25272
  access: "create"
24771
25273
  },
@@ -24853,23 +25355,17 @@ Object.freeze({
24853
25355
  addonId: null,
24854
25356
  access: "view"
24855
25357
  },
24856
- "snapshot.invalidateCache": {
25358
+ "snapshot.getSnapshotOverview": {
24857
25359
  capName: "snapshot",
24858
25360
  capScope: "device",
24859
25361
  addonId: null,
24860
- access: "create"
24861
- },
24862
- "snapshotProvider.getSnapshot": {
24863
- capName: "snapshot-provider",
24864
- capScope: "system",
24865
- addonId: null,
24866
25362
  access: "view"
24867
25363
  },
24868
- "snapshotProvider.supportsDevice": {
24869
- capName: "snapshot-provider",
24870
- capScope: "system",
25364
+ "snapshot.invalidateCache": {
25365
+ capName: "snapshot",
25366
+ capScope: "device",
24871
25367
  addonId: null,
24872
- access: "view"
25368
+ access: "create"
24873
25369
  },
24874
25370
  "ssoBridge.signBridgeToken": {
24875
25371
  capName: "sso-bridge",
@@ -25297,30 +25793,6 @@ Object.freeze({
25297
25793
  addonId: null,
25298
25794
  access: "view"
25299
25795
  },
25300
- "streamingEngine.getStreamUrl": {
25301
- capName: "streaming-engine",
25302
- capScope: "system",
25303
- addonId: null,
25304
- access: "view"
25305
- },
25306
- "streamingEngine.listStreams": {
25307
- capName: "streaming-engine",
25308
- capScope: "system",
25309
- addonId: null,
25310
- access: "view"
25311
- },
25312
- "streamingEngine.registerStream": {
25313
- capName: "streaming-engine",
25314
- capScope: "system",
25315
- addonId: null,
25316
- access: "create"
25317
- },
25318
- "streamingEngine.unregisterStream": {
25319
- capName: "streaming-engine",
25320
- capScope: "system",
25321
- addonId: null,
25322
- access: "delete"
25323
- },
25324
25796
  "streamParams.getConfigSchema": {
25325
25797
  capName: "stream-params",
25326
25798
  capScope: "device",
@@ -25567,6 +26039,12 @@ Object.freeze({
25567
26039
  addonId: null,
25568
26040
  access: "view"
25569
26041
  },
26042
+ "userPasskeys.beginDiscoverableAuthentication": {
26043
+ capName: "user-passkeys",
26044
+ capScope: "system",
26045
+ addonId: null,
26046
+ access: "view"
26047
+ },
25570
26048
  "userPasskeys.beginRegistration": {
25571
26049
  capName: "user-passkeys",
25572
26050
  capScope: "system",
@@ -25579,12 +26057,24 @@ Object.freeze({
25579
26057
  addonId: null,
25580
26058
  access: "view"
25581
26059
  },
26060
+ "userPasskeys.finishDiscoverableAuthentication": {
26061
+ capName: "user-passkeys",
26062
+ capScope: "system",
26063
+ addonId: null,
26064
+ access: "view"
26065
+ },
25582
26066
  "userPasskeys.finishRegistration": {
25583
26067
  capName: "user-passkeys",
25584
26068
  capScope: "system",
25585
26069
  addonId: null,
25586
26070
  access: "create"
25587
26071
  },
26072
+ "userPasskeys.getSecondFactorPreference": {
26073
+ capName: "user-passkeys",
26074
+ capScope: "system",
26075
+ addonId: null,
26076
+ access: "view"
26077
+ },
25588
26078
  "userPasskeys.listPasskeys": {
25589
26079
  capName: "user-passkeys",
25590
26080
  capScope: "system",
@@ -25597,6 +26087,12 @@ Object.freeze({
25597
26087
  addonId: null,
25598
26088
  access: "delete"
25599
26089
  },
26090
+ "userPasskeys.setSecondFactorPreference": {
26091
+ capName: "user-passkeys",
26092
+ capScope: "system",
26093
+ addonId: null,
26094
+ access: "create"
26095
+ },
25600
26096
  "vacuumControl.locate": {
25601
26097
  capName: "vacuum-control",
25602
26098
  capScope: "device",
@@ -25669,6 +26165,18 @@ Object.freeze({
25669
26165
  addonId: null,
25670
26166
  access: "view"
25671
26167
  },
26168
+ "viewerUi.getStaticDir": {
26169
+ capName: "viewer-ui",
26170
+ capScope: "system",
26171
+ addonId: null,
26172
+ access: "view"
26173
+ },
26174
+ "viewerUi.getVersion": {
26175
+ capName: "viewer-ui",
26176
+ capScope: "system",
26177
+ addonId: null,
26178
+ access: "view"
26179
+ },
25672
26180
  "waterHeater.setAway": {
25673
26181
  capName: "water-heater",
25674
26182
  capScope: "device",
@@ -25687,54 +26195,6 @@ Object.freeze({
25687
26195
  addonId: null,
25688
26196
  access: "create"
25689
26197
  },
25690
- "webrtc.closeSession": {
25691
- capName: "webrtc",
25692
- capScope: "system",
25693
- addonId: null,
25694
- access: "create"
25695
- },
25696
- "webrtc.createSession": {
25697
- capName: "webrtc",
25698
- capScope: "system",
25699
- addonId: null,
25700
- access: "create"
25701
- },
25702
- "webrtc.handleAnswer": {
25703
- capName: "webrtc",
25704
- capScope: "system",
25705
- addonId: null,
25706
- access: "create"
25707
- },
25708
- "webrtc.handleOffer": {
25709
- capName: "webrtc",
25710
- capScope: "system",
25711
- addonId: null,
25712
- access: "create"
25713
- },
25714
- "webrtc.hasAdaptiveBitrate": {
25715
- capName: "webrtc",
25716
- capScope: "system",
25717
- addonId: null,
25718
- access: "view"
25719
- },
25720
- "webrtc.registerStream": {
25721
- capName: "webrtc",
25722
- capScope: "system",
25723
- addonId: null,
25724
- access: "create"
25725
- },
25726
- "webrtc.supportsStream": {
25727
- capName: "webrtc",
25728
- capScope: "system",
25729
- addonId: null,
25730
- access: "view"
25731
- },
25732
- "webrtc.unregisterStream": {
25733
- capName: "webrtc",
25734
- capScope: "system",
25735
- addonId: null,
25736
- access: "delete"
25737
- },
25738
26198
  "webrtcSession.addIceCandidate": {
25739
26199
  capName: "webrtc-session",
25740
26200
  capScope: "device",
@@ -25948,6 +26408,72 @@ function maskUrlCredentials(rawUrl) {
25948
26408
  return rawUrl;
25949
26409
  }
25950
26410
  }
26411
+ //#endregion
26412
+ //#region src/rtsp-reachability.ts
26413
+ /**
26414
+ * Control-plane reachability probe for a generic RTSP camera.
26415
+ *
26416
+ * Unlike Hikvision/Amcrest/ONVIF, an RTSP source exposes NO management API —
26417
+ * we only have an `rtsp://` URL. Reachability is therefore probed at the RTSP
26418
+ * control channel itself:
26419
+ *
26420
+ * 1. open a TCP connection to the RTSP `host:port` (default 554);
26421
+ * 2. best-effort send an RTSP `OPTIONS` request;
26422
+ * 3. treat an `RTSP/…` response OR a successful TCP handshake (even without
26423
+ * a response before the deadline) as REACHABLE.
26424
+ *
26425
+ * A successful TCP handshake already proves the camera's RTSP port is live —
26426
+ * the `OPTIONS` round-trip is a stronger confirmation when the server answers
26427
+ * promptly, but we deliberately fall back to the bare connect so a camera that
26428
+ * gates `OPTIONS` behind auth (or is simply slow to answer) is not wrongly
26429
+ * marked offline.
26430
+ *
26431
+ * The socket is always destroyed; the probe never throws and resolves within
26432
+ * `timeoutMs`.
26433
+ */
26434
+ var DEFAULT_RTSP_PORT = 554;
26435
+ /** Parse `host` + `port` out of an `rtsp://` URL. Credentials/path ignored. */
26436
+ function parseRtspTarget(url) {
26437
+ try {
26438
+ const parsed = new URL(url);
26439
+ if (!parsed.hostname) return null;
26440
+ const port = parsed.port ? Number.parseInt(parsed.port, 10) : DEFAULT_RTSP_PORT;
26441
+ if (!Number.isFinite(port) || port <= 0 || port > 65535) return null;
26442
+ return {
26443
+ host: parsed.hostname,
26444
+ port
26445
+ };
26446
+ } catch {
26447
+ return null;
26448
+ }
26449
+ }
26450
+ async function probeRtspReachable(url, timeoutMs) {
26451
+ const target = parseRtspTarget(url);
26452
+ if (!target) return false;
26453
+ return new Promise((resolve) => {
26454
+ let settled = false;
26455
+ let connected = false;
26456
+ const socket = new net.Socket();
26457
+ const finish = (reachable) => {
26458
+ if (settled) return;
26459
+ settled = true;
26460
+ socket.destroy();
26461
+ resolve(reachable);
26462
+ };
26463
+ socket.setTimeout(timeoutMs);
26464
+ socket.once("timeout", () => finish(connected));
26465
+ socket.once("error", () => finish(false));
26466
+ socket.once("connect", () => {
26467
+ connected = true;
26468
+ const request = `OPTIONS ${url} RTSP/1.0\r\nCSeq: 1\r\nUser-Agent: camstack-reachability\r\n\r\n`;
26469
+ socket.write(request, () => {});
26470
+ });
26471
+ socket.once("data", (buf) => {
26472
+ finish(buf.toString("latin1").startsWith("RTSP/") || connected);
26473
+ });
26474
+ socket.connect(target.port, target.host);
26475
+ });
26476
+ }
25951
26477
  var rtspCameraSchema = object({
25952
26478
  streams: preprocess((raw) => {
25953
26479
  if (!Array.isArray(raw)) return raw;
@@ -25985,15 +26511,44 @@ var legacyStreamSchema = object({
25985
26511
  label: CamProfileSchema,
25986
26512
  url: string()
25987
26513
  });
25988
- var RtspCamera = class extends BaseDevice {
26514
+ var RtspCamera = class RtspCamera extends BaseDevice {
25989
26515
  type = DeviceType.Camera;
25990
26516
  features = [];
26517
+ /** Control-plane reachability poll — an RTSP `OPTIONS`/TCP-connect probe to
26518
+ * the camera's RTSP port every 30s drives `device.online`, decoupled from
26519
+ * stream-broker video health. Started in `onActivate`, stopped in
26520
+ * `removeDevice`. */
26521
+ reachabilityPoll = null;
25991
26522
  constructor(ctx) {
25992
26523
  super(ctx, rtspCameraSchema, { type: DeviceType.Camera });
25993
26524
  this.migrateLegacyStreamsIfNeeded(ctx.persistedConfig ?? {});
25994
26525
  this.registerSnapshotProvider();
25995
26526
  this.registerStreamCatalogProvider();
25996
26527
  }
26528
+ /** Phase 5 — device is live: begin the control-plane reachability poll. */
26529
+ async onActivate() {
26530
+ this.startReachabilityPolling();
26531
+ }
26532
+ /** Start the RTSP reachability poll: a lightweight `OPTIONS`/TCP-connect
26533
+ * probe to the first configured stream's `host:port` every 30s drives
26534
+ * `device.online`, with hysteresis. Idempotent. */
26535
+ startReachabilityPolling() {
26536
+ if (this.reachabilityPoll) return;
26537
+ this.reachabilityPoll = startReachabilityPoll({
26538
+ probe: async () => {
26539
+ const url = this.config.get("streams")[0]?.url;
26540
+ if (!url) return false;
26541
+ return probeRtspReachable(url, RtspCamera.RTSP_PROBE_TIMEOUT_MS);
26542
+ },
26543
+ setOnline: (online) => {
26544
+ this.markOnline(online);
26545
+ },
26546
+ isEnabled: () => !this.disabled,
26547
+ logger: this.ctx.logger
26548
+ });
26549
+ }
26550
+ /** Per-probe TCP/RTSP round-trip budget — a dead host resolves as a miss. */
26551
+ static RTSP_PROBE_TIMEOUT_MS = 5e3;
25997
26552
  /**
25998
26553
  * Build this camera's pull-able stream catalog — the descriptors the
25999
26554
  * stream-broker needs to dial. Single source of truth feeding the
@@ -26084,6 +26639,8 @@ var RtspCamera = class extends BaseDevice {
26084
26639
  }
26085
26640
  async removeDevice() {
26086
26641
  this.ctx.logger.info("Removing RTSP camera", { meta: { stableId: this.stableId } });
26642
+ this.reachabilityPoll?.stop();
26643
+ this.reachabilityPoll = null;
26087
26644
  const streams = this.config.get("streams");
26088
26645
  await Promise.all(streams.map((s) => this.ctx.api.streamBroker.retractCameraStream.mutate({
26089
26646
  deviceId: this.id,
@@ -26361,21 +26918,7 @@ var RtspProviderAddon = class extends BaseDeviceProvider {
26361
26918
  super({});
26362
26919
  }
26363
26920
  async onInitialize() {
26364
- const regs = await super.onInitialize();
26365
- this.subscribe({ category: EventCategory.DeviceStateChanged }, (event) => {
26366
- const data = event.data;
26367
- if (data.capName !== "camera-streams") return;
26368
- const deviceId = data.deviceId;
26369
- if (typeof deviceId !== "number") return;
26370
- const registry = this.ctx.kernel.deviceRegistry;
26371
- if (!registry) return;
26372
- if (registry.getAddonId(deviceId) !== this.addonId) return;
26373
- const device = registry.getById(deviceId);
26374
- if (!device) return;
26375
- const online = data.slice?.online === true;
26376
- if (device.online !== online) device.online = online;
26377
- });
26378
- return regs;
26921
+ return await super.onInitialize();
26379
26922
  }
26380
26923
  async onGetCreationSchema(type) {
26381
26924
  if (type !== DeviceType.Camera) return null;