@camstack/addon-provider-reolink 1.2.22 → 1.2.24

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 +820 -68
  2. package/dist/addon.mjs +820 -68
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -7244,8 +7244,31 @@ var AdoptionJobSchema = object({
7244
7244
  error: string().nullable()
7245
7245
  });
7246
7246
  /**
7247
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7248
- * pipeline functions an operator thinks in terms of.
7247
+ * Per-camera FUNCTION SWITCHES.
7248
+ *
7249
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7250
+ *
7251
+ * This file shipped as "the one coherent on/off surface over the pipeline
7252
+ * functions an operator thinks in terms of". The operator's verdict on
7253
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7254
+ * every function already had a settings page of its own, and a second place to
7255
+ * turn it off is a second place to look. Each switch is going back to its own
7256
+ * component's original options — detection to the detection-pipeline wrapper
7257
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7258
+ * (which was always first-class; the switch was a veneer over
7259
+ * `recording.setDeviceConfig`), notifications to a notification-center
7260
+ * per-device setting, the two camera planes to their own components.
7261
+ *
7262
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7263
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7264
+ * straight from the authorities with no group in the middle. That rule was
7265
+ * never about a control panel.
7266
+ *
7267
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7268
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7269
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7270
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7271
+ * stop; nothing new may be built on it.
7249
7272
  *
7250
7273
  * ## This file adds no state
7251
7274
  *
@@ -7596,7 +7619,15 @@ var RecordingConfigSchema = object({
7596
7619
  * Each completed/failed run also lands one durable ops-log row on its owning
7597
7620
  * addon surface.
7598
7621
  */
7622
+ /**
7623
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7624
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7625
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7626
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7627
+ * runs at all.
7628
+ */
7599
7629
  var RelocateJobStateSchema = _enum([
7630
+ "queued",
7600
7631
  "running",
7601
7632
  "done",
7602
7633
  "failed",
@@ -7631,6 +7662,15 @@ var RelocateFootageInputSchema = object({
7631
7662
  /** Limits relocation to the logical profile class. Omit only for the
7632
7663
  * pre-orchestration compatibility path. */
7633
7664
  footageClass: RelocateFootageClassSchema.optional(),
7665
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7666
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7667
+ * unit is a (camera, profile) pile, not a disk. */
7668
+ deviceId: number().int().optional(),
7669
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7670
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7671
+ * placement plan assigns those two independently, so a rebalance that could
7672
+ * only say "recordings" would move footage the plan never asked to move. */
7673
+ profiles: array(string()).optional(),
7634
7674
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7635
7675
  * never allowed to starve live writers. */
7636
7676
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7766,6 +7806,21 @@ var StorageLocationSchema = object({
7766
7806
  nodeId: string().optional(),
7767
7807
  isDefault: boolean().default(false),
7768
7808
  isSystem: boolean().default(false),
7809
+ /**
7810
+ * Operator opt-in: whether consumers that BALANCE across several locations
7811
+ * of a type may write here. Recordings reads it today; event media and
7812
+ * backups are the next consumers, which is why the flag lives on the
7813
+ * location rather than in any one addon's store — nothing has to be
7814
+ * extended to add the next consumer.
7815
+ *
7816
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7817
+ * flag existed reads back with no flag and keeps working exactly as before;
7818
+ * that is the whole compat story, and it is why no migration ships with it.
7819
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7820
+ * disk must not silently start writing to it); the default of a type is
7821
+ * always stamped `true`.
7822
+ */
7823
+ enabled: boolean().optional(),
7769
7824
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7770
7825
  * for node-local locations it can reach) — never persisted, absent when the
7771
7826
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12505,7 +12560,8 @@ method(object({
12505
12560
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12506
12561
  /**
12507
12562
  * filesystem-browse — per-node capability for browsing the node's local
12508
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12563
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12564
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12509
12565
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12510
12566
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12511
12567
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14346,6 +14402,13 @@ var MaskGridDimsSchema = object({
14346
14402
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14347
14403
  * this one field keeps the schema additive — a rule still declares exactly
14348
14404
  * one trigger.
14405
+ *
14406
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14407
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14408
+ * mirror.ts` fails the build on a member the app cannot render) and every
14409
+ * member costs a release train. A sustained-sound rule is therefore an
14410
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14411
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14349
14412
  */
14350
14413
  var NcDeliverySchema = _enum([
14351
14414
  "immediate",
@@ -14360,15 +14423,32 @@ var NcDeliverySchema = _enum([
14360
14423
  * depend on a provider's raw event name or payload shape.
14361
14424
  */
14362
14425
  var NcSystemEventKindSchema = _enum([
14363
- "camera-online",
14364
- "camera-offline",
14426
+ "device-online",
14427
+ "device-offline",
14428
+ "device-disabled",
14429
+ "device-enabled",
14365
14430
  "stream-online",
14366
14431
  "stream-offline",
14367
14432
  "node-online",
14368
14433
  "node-offline",
14369
14434
  "addon-update-available",
14370
- "server-update-available"
14435
+ "server-update-available",
14436
+ "alarm-triggered",
14437
+ "alarm-armed",
14438
+ "alarm-disarmed",
14439
+ "camera-online",
14440
+ "camera-offline",
14441
+ "camera-disabled",
14442
+ "camera-enabled"
14443
+ ]);
14444
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14445
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14446
+ "camera-online",
14447
+ "camera-offline",
14448
+ "camera-disabled",
14449
+ "camera-enabled"
14371
14450
  ]);
14451
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14372
14452
  /**
14373
14453
  * One coherent system-event condition. `kinds` is the required opt-in safety
14374
14454
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14377,6 +14457,18 @@ var NcSystemEventKindSchema = _enum([
14377
14457
  var NcSystemEventConditionSchema = object({
14378
14458
  kinds: array(NcSystemEventKindSchema).min(1),
14379
14459
  deviceIds: array(number().int()).min(1).optional(),
14460
+ /**
14461
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14462
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14463
+ * is what a liveness rule means when nobody said otherwise.
14464
+ *
14465
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14466
+ * one reason: the intake cannot know which devices this household cares
14467
+ * about, and a producer-side filter is one no operator can change. Fails
14468
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14469
+ * does not carry) matches no `deviceTypes` list.
14470
+ */
14471
+ deviceTypes: array(string().min(1)).min(1).optional(),
14380
14472
  nodeIds: array(string().min(1)).min(1).optional(),
14381
14473
  packageNames: array(string().min(1)).min(1).optional()
14382
14474
  });
@@ -14427,6 +14519,47 @@ var NcOccupancyConditionSchema = object({
14427
14519
  sustainSeconds: number().int().min(0).max(3600).default(15)
14428
14520
  });
14429
14521
  /**
14522
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14523
+ *
14524
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14525
+ * reference notifier uses, so an operator moving between them re-uses what
14526
+ * they already know): a rule matches when, over a sampling window of
14527
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14528
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14529
+ *
14530
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14531
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14532
+ * - `labels` — the classifier put at least one of these labels on it.
14533
+ *
14534
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14535
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14536
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14537
+ * is given** — a window in which every sample is trivially a hit would fire on
14538
+ * silence, so the engine refuses such a condition rather than notifying on
14539
+ * nothing (the schema cannot express "at least one of" without becoming a
14540
+ * ZodEffects the cap path would have to special-case).
14541
+ *
14542
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14543
+ * must be FULL before it can match — a window that has been open for two
14544
+ * seconds of its ten is 100% of nothing, and firing on it would make
14545
+ * `samplingSeconds` decorative.
14546
+ *
14547
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14548
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14549
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14550
+ * an operator who typed `dog` mean the same thing.
14551
+ */
14552
+ var NcAudioConditionSchema = object({
14553
+ /** Audio macro labels; absent = any sound (level-only rule). */
14554
+ labels: array(string().min(1)).min(1).optional(),
14555
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14556
+ dbThreshold: number().min(-96).max(0).optional(),
14557
+ /** Percentage of the window's samples that must be hits (1–100). */
14558
+ hitPercent: number().int().min(1).max(100).default(60),
14559
+ /** Length of the sampling window in seconds. */
14560
+ samplingSeconds: number().int().min(1).max(300).default(10)
14561
+ });
14562
+ /**
14430
14563
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14431
14564
  *
14432
14565
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14699,7 +14832,33 @@ var NcConditionsSchema = object({
14699
14832
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14700
14833
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14701
14834
  */
14702
- occupancy: NcOccupancyConditionSchema.optional()
14835
+ occupancy: NcOccupancyConditionSchema.optional(),
14836
+ /**
14837
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14838
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14839
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14840
+ * a window that is not full yet, neither filter given). See
14841
+ * {@link NcAudioCondition}.
14842
+ *
14843
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14844
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14845
+ * a detection, a track or a device event (the same fail-closed pairing
14846
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14847
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14848
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14849
+ * classified sample) stays exactly as it was for rules that already use it.
14850
+ *
14851
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14852
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14853
+ * (`camstack/src/data/notification-center.ts`, guarded by
14854
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14855
+ * condition fields it does not know when a rule is saved from the phone.
14856
+ * Publishing an editor for a condition the app cannot round-trip is how an
14857
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14858
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14859
+ * does an audio rule become authorable.
14860
+ */
14861
+ audio: NcAudioConditionSchema.optional()
14703
14862
  });
14704
14863
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14705
14864
  var NcRuleTargetSchema = object({
@@ -14813,6 +14972,73 @@ var NcThrottleSchema = object({
14813
14972
  */
14814
14973
  granularity: NcThrottleGranularitySchema.optional()
14815
14974
  });
14975
+ /**
14976
+ * How long the confirm gate may hold ONE notification, and how big the picture
14977
+ * it judges may be.
14978
+ *
14979
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14980
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14981
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14982
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14983
+ * tokens for pixels the model pools away.
14984
+ */
14985
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14986
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14987
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14988
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14989
+ var NcConfirmExpectSchema = object({
14990
+ op: _enum([
14991
+ ">=",
14992
+ ">",
14993
+ "<=",
14994
+ "<",
14995
+ "=="
14996
+ ]),
14997
+ count: number().int().min(0).max(1e3)
14998
+ });
14999
+ /**
15000
+ * AI CONFIRM — a vision model looks at the picture this notification is about
15001
+ * to ship and says whether it agrees with the rule.
15002
+ *
15003
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
15004
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
15005
+ * on the operator's phone is not a verdict about this notification.
15006
+ *
15007
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
15008
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
15009
+ * the default and every fail-open is COUNTED, because a gate that always fails
15010
+ * open looks in the log exactly like a gate that works.
15011
+ *
15012
+ * Every field is `.optional()` rather than relied on as a Zod default at the
15013
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
15014
+ * production failures in one day), so the gate reads absent as the constant
15015
+ * above rather than trusting a parse it may never have seen.
15016
+ */
15017
+ var NcConfirmSchema = object({
15018
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
15019
+ * same thing, and both mean "deliver exactly as before". */
15020
+ enabled: boolean().default(false),
15021
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
15022
+ profileId: string().optional(),
15023
+ /**
15024
+ * The operator's question, in his own words. Absent = a question derived
15025
+ * from the rule (its class and its expectation).
15026
+ *
15027
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
15028
+ * banners, signage and plates as instructions if you let them reach the
15029
+ * prompt — proven live — so the authoritative contract stays in the system
15030
+ * turn and only rule-authored words land here.
15031
+ */
15032
+ prompt: string().max(1e3).optional(),
15033
+ /** Fire only when the model's count satisfies this. Absent = the model's
15034
+ * own boolean verdict decides. */
15035
+ expect: NcConfirmExpectSchema.optional(),
15036
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
15037
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
15038
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
15039
+ /** Longest edge the judged image is downscaled to before it is sent. */
15040
+ maxImagePx: number().int().min(64).max(2048).default(448)
15041
+ });
14816
15042
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14817
15043
  var NcRuleInputSchema = object({
14818
15044
  name: string().min(1).max(200),
@@ -14873,7 +15099,13 @@ var NcRuleInputSchema = object({
14873
15099
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14874
15100
  * shape as every other actuation.
14875
15101
  */
14876
- actions: NcRuleActionsSchema.optional()
15102
+ actions: NcRuleActionsSchema.optional(),
15103
+ /**
15104
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
15105
+ * a rule that predates the gate must keep delivering byte-for-byte as it
15106
+ * did, and absent is the only way to say that without a migration.
15107
+ */
15108
+ confirm: NcConfirmSchema.optional()
14877
15109
  });
14878
15110
  /**
14879
15111
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14884,7 +15116,37 @@ var NcRuleInputSchema = object({
14884
15116
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14885
15117
  * `updateRule` patch.
14886
15118
  */
14887
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
15119
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
15120
+ disabledTargetIds: array(string()).optional(),
15121
+ /**
15122
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
15123
+ *
15124
+ * It makes the key optional to SUPPLY; the parse still materialises the
15125
+ * default when the key is absent. And `NcRuleStore.update` merges with
15126
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
15127
+ * one — which made every partial edit destructive:
15128
+ *
15129
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
15130
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
15131
+ * setEnabled(ruleId, false) → conditions reset to `{}`
15132
+ *
15133
+ * A rule scoped to one camera and one zone silently became a rule that
15134
+ * matches EVERY event on EVERY camera, and lost its `media` policy
15135
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
15136
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
15137
+ * within a minute of a two-field patch.
15138
+ *
15139
+ * So every defaulted field is re-declared here WITHOUT its default. The
15140
+ * inner defaults still apply when the caller DOES send the key — `{}` for
15141
+ * conditions remains a real instruction ("clear them") — and only the
15142
+ * absent key is now genuinely absent.
15143
+ */
15144
+ enabled: boolean().optional(),
15145
+ conditions: NcConditionsSchema.optional(),
15146
+ media: NcMediaPolicySchema.optional(),
15147
+ throttle: NcThrottleSchema.optional(),
15148
+ priority: number().int().min(1).max(5).optional()
15149
+ });
14888
15150
  /** A persisted rule. */
14889
15151
  var NcRuleSchema = NcRuleInputSchema.extend({
14890
15152
  id: string(),
@@ -15185,6 +15447,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15185
15447
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15186
15448
  * copy would lie the first time a rule is disabled.
15187
15449
  */
15450
+ /**
15451
+ * Why a device a mode NAMES is nonetheless not armed by it.
15452
+ *
15453
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15454
+ * per-camera notification switch the Notification Center already owns,
15455
+ * `detection-off` is the device's own detection binding being inactive, and
15456
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15457
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15458
+ * with the switches the operator actually used.
15459
+ */
15460
+ var NcAlarmSkipReasonSchema = _enum([
15461
+ "muted",
15462
+ "detection-off",
15463
+ "offline"
15464
+ ]);
15465
+ var NcAlarmSkippedDeviceSchema = object({
15466
+ deviceId: number().int(),
15467
+ reason: NcAlarmSkipReasonSchema
15468
+ });
15188
15469
  var NcAlarmModeCoverageSchema = object({
15189
15470
  mode: AlarmArmModeSchema,
15190
15471
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15192,7 +15473,18 @@ var NcAlarmModeCoverageSchema = object({
15192
15473
  /** At least one covering rule has no device scope, so the mode covers all. */
15193
15474
  allDevices: boolean(),
15194
15475
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15195
- deviceIds: array(number().int())
15476
+ deviceIds: array(number().int()),
15477
+ /**
15478
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15479
+ * excludes it.
15480
+ *
15481
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15482
+ * twelve makes it false in exactly the way nobody notices until an incident.
15483
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15484
+ * still parses as "nothing known to be skipped" rather than failing the whole
15485
+ * alarm tab.
15486
+ */
15487
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15196
15488
  });
15197
15489
  var NcAlarmConfigSchema = object({
15198
15490
  /**
@@ -18024,9 +18316,16 @@ var CameraStatusSchema = object({
18024
18316
  audio: CameraAudioStatusSchema.nullable(),
18025
18317
  recording: CameraRecordingStatusSchema.nullable(),
18026
18318
  /**
18027
- * Per-camera function switches an OPERATOR has turned off
18319
+ * Per-camera functions an OPERATOR has turned off
18028
18320
  * ([D61](../../../../docs/decisions/adr-0067.md)).
18029
18321
  *
18322
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18323
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18324
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18325
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18326
+ * The badge outlives the control panel: the panel was a convenience, this is
18327
+ * the difference between a camera being off and a camera being dead.
18328
+ *
18030
18329
  * This is the difference between DISABLED and BROKEN. A camera whose
18031
18330
  * `detection` block reports zero fps and whose `switchedOff` contains
18032
18331
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -18633,24 +18932,28 @@ var snapshotCapability = {
18633
18932
  *
18634
18933
  * `getSnapshotOverview` is cache-only by contract: it answers from whatever
18635
18934
  * the wrapper happens to hold and never captures. Under D93 the client
18636
- * versions its image URL on that answer, and an image REQUEST is what enrols
18637
- * a camera in the keep-warm loop. Both of those are satisfiable by the
18638
- * client's own image cache — `expo-image` is URL-keyed and never revalidates
18639
- * — so a URL painted in a previous session comes off disk with no network,
18640
- * no enrolment, and nothing warming. Measured on the live hub: reopening
18641
- * after two minutes idle painted 15 of 16 tiles at **168 s old** with zero
18642
- * HTTP requests, and the fleet only recovered because a later poll happened
18643
- * to observe a different identity.
18935
+ * versions its image URL on that answer, and an image REQUEST was the only
18936
+ * demand signal. Both of those are satisfiable by the client's own image
18937
+ * cache — `expo-image` is URL-keyed and never revalidates — so a URL painted
18938
+ * in a previous session comes off disk with no network, no demand, and no
18939
+ * capture. Measured on the live hub: reopening after two minutes idle
18940
+ * painted 15 of 16 tiles at **168 s old** with zero HTTP requests, and the
18941
+ * fleet only recovered because a later poll happened to observe a different
18942
+ * identity.
18644
18943
  *
18645
18944
  * ## The two properties that fix it
18646
18945
  *
18647
18946
  * **It is an RPC, so no client cache can answer it.** The demand signal
18648
- * always reaches the wrapper. This method therefore MAY create keep-warm
18649
- * subscriptions, where `getSnapshotOverview` must never (D93) — the
18650
- * distinction is not "one is newer" but that the overview poll is app-wide
18651
- * (a creating overview would warm every camera on the install) while this is
18652
- * called by a rendered surface naming the tiles it is actually painting, at
18653
- * the width it is painting them.
18947
+ * always reaches the wrapper. This method therefore CAPTURES, where
18948
+ * `getSnapshotOverview` must never (D93) — the distinction is not "one is
18949
+ * newer" but that the overview poll is app-wide (a capturing overview would
18950
+ * dial every camera on the install) while this is called by a rendered
18951
+ * surface naming the tiles it is actually painting, at the width it is
18952
+ * painting them.
18953
+ *
18954
+ * Since 2026-08-11 this is the ONLY thing that refreshes a snapshot: the
18955
+ * server-side keep-warm loop was removed (operator directive — on-demand,
18956
+ * always), so a camera nobody is looking at costs nothing at all.
18654
18957
  *
18655
18958
  * **It waits, briefly and boundedly, for the capture it triggered.** The
18656
18959
  * returned `capturedAt` is the frame the link will serve, not the frame the
@@ -24997,7 +25300,19 @@ var RecordingManifestSchema = object({
24997
25300
  * profiles/subtrees/locations on this node). */
24998
25301
  var RecordingDeviceUsageSchema = object({
24999
25302
  deviceId: number(),
25000
- usedBytes: number()
25303
+ usedBytes: number(),
25304
+ /**
25305
+ * Start of this camera's OLDEST indexed segment, across every profile and
25306
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25307
+ * only honest answer to "is retention actually holding?" per camera.
25308
+ *
25309
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25310
+ * predates this field omits it entirely, and a hub whose types carry the
25311
+ * field must keep validating that older provider's payload: the framework
25312
+ * (types) and the addon ship on different trains, and the addon is usually
25313
+ * the later of the two.
25314
+ */
25315
+ oldestMs: number().nullable().optional()
25001
25316
  });
25002
25317
  /** Recording storage usage + capacity for one storage location. */
25003
25318
  var RecordingLocationUsageSchema = object({
@@ -25025,6 +25340,57 @@ var RecordingStorageUsageSchema = object({
25025
25340
  locations: array(RecordingLocationUsageSchema)
25026
25341
  });
25027
25342
  /**
25343
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25344
+ *
25345
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25346
+ * is the operator asking for the EXISTING archive to be brought into line with
25347
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25348
+ * location, run FIFO behind the single-flight mover.
25349
+ *
25350
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25351
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25352
+ * (empty on the plan).
25353
+ */
25354
+ var RecordingRebalanceMoveSchema = object({
25355
+ deviceId: number(),
25356
+ profile: string(),
25357
+ fromLocationId: string(),
25358
+ toLocationId: string(),
25359
+ bytes: number(),
25360
+ files: number().int()
25361
+ });
25362
+ /** Why a pile that is out of place is staying there. Every refusal is
25363
+ * reported: a rebalance that silently drops a camera reads exactly like one
25364
+ * that had nothing to do. */
25365
+ var RecordingRebalanceSkipReasonSchema = _enum([
25366
+ "unassigned",
25367
+ "target-not-writable",
25368
+ "below-threshold",
25369
+ "no-headroom"
25370
+ ]);
25371
+ var RecordingRebalanceSkipSchema = object({
25372
+ deviceId: number(),
25373
+ profile: string(),
25374
+ fromLocationId: string(),
25375
+ /** The location the plan wants; null when the camera has no assignment. */
25376
+ toLocationId: string().nullable(),
25377
+ bytes: number(),
25378
+ reason: RecordingRebalanceSkipReasonSchema
25379
+ });
25380
+ var RecordingRebalancePlanSchema = object({
25381
+ moves: array(RecordingRebalanceMoveSchema),
25382
+ skipped: array(RecordingRebalanceSkipSchema),
25383
+ bytesToMove: number(),
25384
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25385
+ jobIds: array(string())
25386
+ });
25387
+ var RecordingRebalanceInputSchema = object({
25388
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25389
+ throttleMbps: number().min(1).max(1e3).optional(),
25390
+ /** Ignore piles smaller than this (default 1 GB). */
25391
+ minMoveGb: number().min(0).optional()
25392
+ });
25393
+ /**
25028
25394
  * Result of locating footage at a wall-clock instant for one device/profile.
25029
25395
  * `segment` carries the covering segment's window; `gap` reports the forward
25030
25396
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -25187,9 +25553,24 @@ method(object({
25187
25553
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25188
25554
  kind: "mutation",
25189
25555
  auth: "admin"
25556
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25557
+ kind: "mutation",
25558
+ auth: "admin"
25559
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25560
+ kind: "query",
25561
+ auth: "admin"
25562
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25563
+ kind: "mutation",
25564
+ auth: "admin"
25565
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25566
+ kind: "query",
25567
+ auth: "admin"
25568
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25569
+ kind: "mutation",
25570
+ auth: "admin"
25190
25571
  });
25191
25572
  /**
25192
- * `recordingExport` cap — render a footage time range into a single downloadable
25573
+ * `recording-export` cap — render a footage time range into a single downloadable
25193
25574
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
25194
25575
  * bounded lifetime with a durable history, auto-expiry, and optional
25195
25576
  * delete-after-download.
@@ -25204,10 +25585,53 @@ method(object({
25204
25585
  */
25205
25586
  /** Playback-speed multiplier for the render (1 = realtime). */
25206
25587
  var ExportSpeedSchema = number().min(.25).max(32);
25588
+ /**
25589
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25590
+ *
25591
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25592
+ * derives these bounds from things that happened at a TIME (a track's
25593
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25594
+ * every segment present for the range, with each recording GAP removed. The
25595
+ * two agree only on a window that recorded without one interruption, and only
25596
+ * the render side knows the segments, so the translation lives there
25597
+ * (`export-dense-map.ts`, addon-pipeline).
25598
+ *
25599
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25600
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25601
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25602
+ * the video was a uniform timelapse, and the log line reported the five ranges
25603
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25604
+ *
25605
+ * Relative and not absolute epoch, because an absolute epoch would make every
25606
+ * call site responsible for the same subtraction.
25607
+ */
25608
+ var ExportDenseRangeSchema = object({
25609
+ fromSec: number().nonnegative(),
25610
+ toSec: number().nonnegative()
25611
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25612
+ /**
25613
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25614
+ * listed ranges and at the base `everyMs` everywhere else.
25615
+ *
25616
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25617
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25618
+ */
25619
+ var ExportDenseSchema = object({
25620
+ everyMs: number().int().positive(),
25621
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25622
+ });
25207
25623
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
25208
25624
  var ExportTimelapseSchema = object({
25209
25625
  everyMs: number().int().positive(),
25210
- outputFps: number().int().min(1).max(60).optional()
25626
+ outputFps: number().int().min(1).max(60).optional(),
25627
+ /** Optional second, FASTER rate over the intervals that matter. */
25628
+ dense: ExportDenseSchema.optional()
25629
+ }).superRefine((v, ctx) => {
25630
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25631
+ code: ZodIssueCode$16.custom,
25632
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25633
+ path: ["dense", "everyMs"]
25634
+ });
25211
25635
  });
25212
25636
  /**
25213
25637
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -25265,6 +25689,19 @@ var ExportDownloadSchema = object({
25265
25689
  url: string(),
25266
25690
  endpoints: array(string())
25267
25691
  });
25692
+ /**
25693
+ * A finished export's bytes, inline.
25694
+ *
25695
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25696
+ * against, so nobody has to infer it from the base64 length.
25697
+ */
25698
+ var ExportBytesSchema = object({
25699
+ base64: string(),
25700
+ contentType: string(),
25701
+ /** Suggested filename, extension included. */
25702
+ name: string(),
25703
+ bytes: number().int().nonnegative()
25704
+ });
25268
25705
  method(object({
25269
25706
  deviceId: number(),
25270
25707
  profile: string(),
@@ -25289,6 +25726,9 @@ method(object({
25289
25726
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
25290
25727
  kind: "query",
25291
25728
  auth: "protected"
25729
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25730
+ kind: "query",
25731
+ auth: "protected"
25292
25732
  });
25293
25733
  /**
25294
25734
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -32257,6 +32697,12 @@ Object.freeze({
32257
32697
  addonId: null,
32258
32698
  access: "create"
32259
32699
  },
32700
+ "recording.cancelRelocateJob": {
32701
+ capName: "recording",
32702
+ capScope: "system",
32703
+ addonId: null,
32704
+ access: "create"
32705
+ },
32260
32706
  "recording.cancelStorageMigrationMove": {
32261
32707
  capName: "recording",
32262
32708
  capScope: "system",
@@ -32311,6 +32757,12 @@ Object.freeze({
32311
32757
  addonId: null,
32312
32758
  access: "view"
32313
32759
  },
32760
+ "recording.listRelocateJobs": {
32761
+ capName: "recording",
32762
+ capScope: "system",
32763
+ addonId: null,
32764
+ access: "view"
32765
+ },
32314
32766
  "recording.locateSegment": {
32315
32767
  capName: "recording",
32316
32768
  capScope: "system",
@@ -32323,6 +32775,12 @@ Object.freeze({
32323
32775
  addonId: null,
32324
32776
  access: "create"
32325
32777
  },
32778
+ "recording.planStorageRebalance": {
32779
+ capName: "recording",
32780
+ capScope: "system",
32781
+ addonId: null,
32782
+ access: "view"
32783
+ },
32326
32784
  "recording.pruneFootage": {
32327
32785
  capName: "recording",
32328
32786
  capScope: "system",
@@ -32347,6 +32805,12 @@ Object.freeze({
32347
32805
  addonId: null,
32348
32806
  access: "create"
32349
32807
  },
32808
+ "recording.relocateFootage": {
32809
+ capName: "recording",
32810
+ capScope: "system",
32811
+ addonId: null,
32812
+ access: "create"
32813
+ },
32350
32814
  "recording.renderClip": {
32351
32815
  capName: "recording",
32352
32816
  capScope: "system",
@@ -32383,38 +32847,50 @@ Object.freeze({
32383
32847
  addonId: null,
32384
32848
  access: "create"
32385
32849
  },
32850
+ "recording.startStorageRebalance": {
32851
+ capName: "recording",
32852
+ capScope: "system",
32853
+ addonId: null,
32854
+ access: "create"
32855
+ },
32386
32856
  "recordingExport.cancelExport": {
32387
- capName: "recordingExport",
32857
+ capName: "recording-export",
32388
32858
  capScope: "system",
32389
32859
  addonId: null,
32390
32860
  access: "create"
32391
32861
  },
32392
32862
  "recordingExport.createExport": {
32393
- capName: "recordingExport",
32863
+ capName: "recording-export",
32394
32864
  capScope: "system",
32395
32865
  addonId: null,
32396
32866
  access: "create"
32397
32867
  },
32398
32868
  "recordingExport.deleteExport": {
32399
- capName: "recordingExport",
32869
+ capName: "recording-export",
32400
32870
  capScope: "system",
32401
32871
  addonId: null,
32402
32872
  access: "delete"
32403
32873
  },
32404
32874
  "recordingExport.getDownloadUrl": {
32405
- capName: "recordingExport",
32875
+ capName: "recording-export",
32406
32876
  capScope: "system",
32407
32877
  addonId: null,
32408
32878
  access: "view"
32409
32879
  },
32410
32880
  "recordingExport.getExport": {
32411
- capName: "recordingExport",
32881
+ capName: "recording-export",
32412
32882
  capScope: "system",
32413
32883
  addonId: null,
32414
32884
  access: "view"
32415
32885
  },
32416
32886
  "recordingExport.listExports": {
32417
- capName: "recordingExport",
32887
+ capName: "recording-export",
32888
+ capScope: "system",
32889
+ addonId: null,
32890
+ access: "view"
32891
+ },
32892
+ "recordingExport.readExportBytes": {
32893
+ capName: "recording-export",
32418
32894
  capScope: "system",
32419
32895
  addonId: null,
32420
32896
  access: "view"
@@ -33791,6 +34267,104 @@ var FramerateField = number().int().min(1).max(60);
33791
34267
  var TargetsField = array(NcRuleTargetSchema).min(1);
33792
34268
  var PriorityField = number().int().min(1).max(5);
33793
34269
  /**
34270
+ * Explicit override of the DENSE sampling cadence, seconds.
34271
+ *
34272
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
34273
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
34274
+ * made that same base 3 s and rendered a person pass as two frames.)
34275
+ *
34276
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
34277
+ * `denseCadenceSec` and played at `framerate` occupies
34278
+ *
34279
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
34280
+ *
34281
+ * so a 7 s pass at 1 s / 12 fps is 0.58 s of video, and at 0.5 s it is 1.17 s.
34282
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
34283
+ * and therefore the length of a quiet night, does not move.
34284
+ *
34285
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
34286
+ * the recording has them returns the same frames, requested twice. Must be
34287
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
34288
+ * a uniform video the operator believes is two-rate — and upsert refuses it
34289
+ * rather than letting the export cap reject the render hours after the window.
34290
+ */
34291
+ var DenseCadenceSecField = number().min(.1).max(3600);
34292
+ /**
34293
+ * Minimum seconds of OUTPUT video each detection range must occupy.
34294
+ *
34295
+ * The operator-facing form of the arithmetic above: instead of solving for a
34296
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
34297
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
34298
+ * that range every ~583 ms.
34299
+ *
34300
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
34301
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
34302
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
34303
+ * ranges are sampled denser than they need. Per-range cadences require a cap
34304
+ * schema change and are the tracked follow-up.
34305
+ *
34306
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
34307
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
34308
+ * by real footage, never met by duplicating frames into motion that never
34309
+ * happened.
34310
+ */
34311
+ var MinDwellSecField = number().min(0).max(60);
34312
+ /**
34313
+ * Caption burned into the notification's preview frame.
34314
+ *
34315
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
34316
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
34317
+ * templating dialect for one field would be a second thing to explain.
34318
+ *
34319
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
34320
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
34321
+ * the reason this is not `.min(1)`.
34322
+ */
34323
+ var PreviewTextField = string().max(200);
34324
+ /**
34325
+ * Whether the notification's preview is a STILL or a short animation.
34326
+ *
34327
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
34328
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
34329
+ * night reads better as three seconds of motion than as one frame of it. Both
34330
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
34331
+ * simply applies it to a dozen frames sampled across the render and assembles
34332
+ * them.
34333
+ *
34334
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
34335
+ * seeks and a palette pass, and no rule that never asked for one should start
34336
+ * paying that on the deploy that shipped it.
34337
+ *
34338
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
34339
+ */
34340
+ var PreviewModeField = _enum(["image", "gif"]);
34341
+ /**
34342
+ * Which detection classes the notification reports counts for.
34343
+ *
34344
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
34345
+ * plan — no second query — aggregated per class. Absent or empty means "every
34346
+ * class the window actually contained", which is what an operator who never
34347
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
34348
+ * counts cars all night).
34349
+ *
34350
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
34351
+ * …). An unknown name simply never matches and reports nothing — it is not an
34352
+ * error, because a rule may legitimately name a class this camera's model does
34353
+ * not emit.
34354
+ *
34355
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
34356
+ * - `{{detections}}` — total over the reported classes
34357
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
34358
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
34359
+ * one per class, `count_` + the class name
34360
+ *
34361
+ * With NO custom body template the summary is appended to the derived body, and
34362
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
34363
+ * reads. With a custom template the operator owns every word — nothing is
34364
+ * appended, so `{{detectionSummary}}` is how he asks for it.
34365
+ */
34366
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
34367
+ /**
33794
34368
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33795
34369
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33796
34370
  * here (see the ownership note above).
@@ -33810,9 +34384,30 @@ var TimelapseRuleInputSchema = object({
33810
34384
  cadenceSec: CadenceSecField.default(15),
33811
34385
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33812
34386
  framerate: FramerateField.default(10),
34387
+ /**
34388
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
34389
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
34390
+ * field gets.
34391
+ */
34392
+ denseCadenceSec: DenseCadenceSecField.optional(),
34393
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
34394
+ minDwellSec: MinDwellSecField.optional(),
33813
34395
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33814
34396
  targets: TargetsField,
33815
34397
  template: TimelapseTemplateSchema.optional(),
34398
+ /**
34399
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
34400
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
34401
+ *
34402
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
34403
+ * the notification's title/body, and clearing it (`template: null`) must not
34404
+ * silently clear the caption too.
34405
+ */
34406
+ previewText: PreviewTextField.optional(),
34407
+ /** Still or animation — see {@link PreviewModeField}. */
34408
+ previewMode: PreviewModeField.default("image"),
34409
+ /** Classes the notification counts — see {@link ReportClassesField}. */
34410
+ reportClasses: ReportClassesField.optional(),
33816
34411
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33817
34412
  priority: PriorityField.default(3)
33818
34413
  });
@@ -33823,8 +34418,13 @@ object({
33823
34418
  schedule: NcScheduleSchema.optional(),
33824
34419
  cadenceSec: CadenceSecField.optional(),
33825
34420
  framerate: FramerateField.optional(),
34421
+ denseCadenceSec: DenseCadenceSecField.optional(),
34422
+ minDwellSec: MinDwellSecField.optional(),
33826
34423
  targets: TargetsField.optional(),
33827
34424
  template: TimelapseTemplateSchema.nullable().optional(),
34425
+ previewText: PreviewTextField.optional(),
34426
+ previewMode: PreviewModeField.optional(),
34427
+ reportClasses: ReportClassesField.optional(),
33828
34428
  priority: PriorityField.optional()
33829
34429
  });
33830
34430
  TimelapseRuleInputSchema.extend({
@@ -33836,10 +34436,28 @@ TimelapseRuleInputSchema.extend({
33836
34436
  */
33837
34437
  ownerUserId: string().optional(),
33838
34438
  /**
33839
- * Epoch-ms of the last successful generation the 1-hour re-generation
33840
- * guard's durable state (predecessor parity). Absent = never generated.
34439
+ * Epoch-ms of the NEWEST successful generation across every camera of this
34440
+ * rule. What a UI shows, and the compatibility floor for
34441
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33841
34442
  */
33842
34443
  lastGeneratedAt: number().optional(),
34444
+ /**
34445
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
34446
+ * re-generation guard's real durable state.
34447
+ *
34448
+ * One rule covers several cameras and each renders its own video, so a rule
34449
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
34450
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
34451
+ * already done — and B's night is gone for good, because the window will not
34452
+ * come back.
34453
+ *
34454
+ * ADDITIVE, so the migration is free: a row written before this field simply
34455
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
34456
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
34457
+ * "never generated" would re-render and re-notify every camera of every rule
34458
+ * once, on the deploy that shipped the map.
34459
+ */
34460
+ generatedByDevice: record(string(), number()).optional(),
33843
34461
  /** userId of the caller who created the rule (server-stamped). */
33844
34462
  createdBy: string(),
33845
34463
  createdAt: number(),
@@ -33890,25 +34508,32 @@ object({
33890
34508
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33891
34509
  object({
33892
34510
  /**
33893
- * How long a retained native frame is served before it counts as a miss.
34511
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
34512
+ * detection result.
33894
34513
  *
33895
- * Must cover the FULL late-crop horizon: detection inference + the
33896
- * cross-process inference-result hop to hub post-analysis + tracking + the
33897
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33898
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33899
- * RAM per busy camera grows linearly with no measured hit-rate gain.
34514
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
34515
+ * a time window was never related to the event the pixels were waiting for.
34516
+ * A held frame now lives from delivery until the runner has its `FrameResult`
34517
+ * at which moment the runner cuts the subject tiles it actually wanted and
34518
+ * releases the frame. The bound exists only so a runner that stops answering
34519
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
34520
+ *
34521
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
34522
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
34523
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
34524
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
34525
+ * `holdOverflow` on the metrics line is what says you need it.
33900
34526
  */
33901
- ttlMs: number().int().min(250).max(1e4),
34527
+ holdFrames: number().int().min(1).max(64),
33902
34528
  /**
33903
34529
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33904
34530
  *
33905
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33906
- * which one is actually binding before reasoning from that. At the shipped
33907
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33908
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33909
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33910
- * change that admits fewer frames buys retention WINDOW at constant RAM
33911
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
34531
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
34532
+ * is what decides how much is held, and the ceiling is the number above which
34533
+ * something is wrong. Before that it was the effective cap at 1024 MB with
34534
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
34535
+ * with the TTL expiring nothing, which is exactly the confusion the hold
34536
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33912
34537
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33913
34538
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33914
34539
  * to replace).
@@ -33934,22 +34559,45 @@ object({
33934
34559
  * there is the signal that some caller names frames outside the inference set
33935
34560
  * and that this must go back to `all`.
33936
34561
  */
33937
- admission: NativeLeaseAdmissionSchema
34562
+ admission: NativeLeaseAdmissionSchema,
34563
+ /**
34564
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
34565
+ * compressed native crops the worker cuts at the moment a frame's detection
34566
+ * result arrives, and keeps long after the frame itself is freed.
34567
+ *
34568
+ * This is the knob that replaced the old retention window, and it buys about
34569
+ * three orders of magnitude more of it: a tile is one subject at native
34570
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
34571
+ * the frame it was cut from. A frame on which nothing was detected costs
34572
+ * nothing at all, which is the real change — the old lease paid per FRAME and
34573
+ * was interrogated per SUBJECT.
34574
+ *
34575
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
34576
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
34577
+ * reproduce that.
34578
+ */
34579
+ tileBudgetMb: number().int().min(0).max(1024)
33938
34580
  });
33939
34581
  /**
33940
- * The values in force when the operator has set nothing — byte-for-byte the
33941
- * constants the decode worker shipped with as env-var defaults, so making these
33942
- * settings changed no behaviour on the day it landed.
34582
+ * The values in force when the operator has set nothing.
34583
+ *
34584
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
34585
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
34586
+ * in the same change that redefines it would make a regression and a retune
34587
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
34588
+ * live traffic.
33943
34589
  */
33944
34590
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33945
- ttlMs: 1200,
34591
+ holdFrames: 8,
33946
34592
  budgetMb: 1024,
33947
34593
  activityMs: 15e3,
34594
+ tileBudgetMb: 64,
33948
34595
  admission: "inferred"
33949
34596
  };
33950
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
34597
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33951
34598
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33952
34599
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34600
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33953
34601
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33954
34602
  //#endregion
33955
34603
  //#region ../../node_modules/undici/lib/core/symbols.js
@@ -223794,6 +224442,47 @@ function isRecoverableBaichuanError(err) {
223794
224442
  return RECOVERABLE_FRAGMENTS.some((fragment) => message.includes(fragment));
223795
224443
  }
223796
224444
  //#endregion
224445
+ //#region src/ptz-zoom.ts
224446
+ /**
224447
+ * Fraction of total zoom travel moved by ONE press. ~8 presses to cross
224448
+ * the full range reads like a zoom rocker.
224449
+ */
224450
+ var ZOOM_STEP_FRACTION = .12;
224451
+ /** `zoomToFactor` expresses an absolute movePos as `factor * 1000`. */
224452
+ var ZOOM_FACTOR_SCALE = 1e3;
224453
+ /** Pause before the retry above — long enough for the lens to settle. */
224454
+ var ZOOM_SET_RETRY_MS = 1500;
224455
+ /**
224456
+ * Resolve the absolute zoom position one press should drive to.
224457
+ *
224458
+ * Only the SIGN of `zoom` is read. Pan/tilt already discard their
224459
+ * magnitude, and the two clients disagree on it anyway — the viewer
224460
+ * sends ±0.2 per press while ui-library sends ±1 — so honouring
224461
+ * magnitude would make the same button travel different distances
224462
+ * depending on which app pressed it.
224463
+ */
224464
+ var resolveZoomStep = (travel, zoom) => {
224465
+ if (!Number.isFinite(travel.minPos) || !Number.isFinite(travel.maxPos)) return {
224466
+ kind: "refused",
224467
+ reason: "no-travel"
224468
+ };
224469
+ if (travel.maxPos <= travel.minPos) return {
224470
+ kind: "refused",
224471
+ reason: "no-travel"
224472
+ };
224473
+ const step = (travel.maxPos - travel.minPos) * ZOOM_STEP_FRACTION;
224474
+ const raw = travel.curPos + Math.sign(zoom) * step;
224475
+ const target = Math.round(Math.min(travel.maxPos, Math.max(travel.minPos, raw)));
224476
+ if (target === travel.curPos) return {
224477
+ kind: "refused",
224478
+ reason: "at-limit"
224479
+ };
224480
+ return {
224481
+ kind: "move",
224482
+ target
224483
+ };
224484
+ };
224485
+ //#endregion
223797
224486
  //#region src/intercom-encoder.ts
223798
224487
  /**
223799
224488
  * IMA ADPCM (DVI4) encoder — Reolink Baichuan talk-back wire format.
@@ -229216,14 +229905,16 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
229216
229905
  }
229217
229906
  }
229218
229907
  /**
229219
- * Translate normalized (-1..1) pan/tilt/zoom to one or more discrete
229220
- * Baichuan PTZ commands. Camstack ptz uses ONVIF-style continuous
229908
+ * Translate normalized (-1..1) pan/tilt to discrete Baichuan
229909
+ * directional commands. Camstack ptz uses ONVIF-style continuous
229221
229910
  * motion vectors; Reolink Baichuan needs discrete directional
229222
- * commands (Left/Right/Up/Down/ZoomIn/ZoomOut). Magnitudes map to
229223
- * speed (0–63 typical). Continuous=true issues 'start' (camera moves
229224
- * until next 'stop'); continuous=false issues 'start' followed by an
229225
- * autoStop after a short window so a single tap of an arrow key
229226
- * results in a tiny nudge.
229911
+ * commands (Left/Right/Up/Down). Magnitudes map to speed (0–63
229912
+ * typical). Continuous=true issues 'start' (camera moves until next
229913
+ * 'stop'); continuous=false issues 'start' followed by an autoStop
229914
+ * after a short window so a single tap of an arrow key results in a
229915
+ * tiny nudge.
229916
+ *
229917
+ * Zoom is NOT a direction on this frame — see `runZoom`.
229227
229918
  */
229228
229919
  async runPtz(pan, tilt, zoom, speed, continuous) {
229229
229920
  const api = await this.ensureApi();
@@ -229231,7 +229922,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
229231
229922
  const cmds = [];
229232
229923
  if (pan !== void 0 && Math.abs(pan) > .01) cmds.push(pan > 0 ? "Right" : "Left");
229233
229924
  if (tilt !== void 0 && Math.abs(tilt) > .01) cmds.push(tilt > 0 ? "Up" : "Down");
229234
- if (zoom !== void 0 && Math.abs(zoom) > .01) cmds.push(zoom > 0 ? "ZoomIn" : "ZoomOut");
229925
+ if (zoom !== void 0 && Math.abs(zoom) > .01) await this.runZoom(api, channel, zoom);
229235
229926
  if (cmds.length === 0) return;
229236
229927
  const baichuanSpeed = speed === void 0 ? 32 : Math.max(1, Math.min(63, Math.round(speed * 63)));
229237
229928
  for (const command of cmds) try {
@@ -229251,6 +229942,67 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
229251
229942
  });
229252
229943
  }
229253
229944
  }
229945
+ /**
229946
+ * Step the lens along the camera's own zoom travel.
229947
+ *
229948
+ * Baichuan has NO directional zoom on MSG_ID_PTZ_CONTROL (cmd 18) —
229949
+ * that frame accepts left/right/up/down and nothing else, so every
229950
+ * zoom this provider ever sent threw `Unsupported PTZ command for
229951
+ * MSG_ID_PTZ_CONTROL: ZoomIn` inside the lib, got swallowed into a
229952
+ * WARN, and returned void. The cap reported success and the lens
229953
+ * never moved: zoom has never worked on a Reolink here.
229954
+ *
229955
+ * The step arithmetic lives in `resolveZoomStep` (`./ptz-zoom.js`);
229956
+ * this method is only the I/O around it. A camera whose answer
229957
+ * carries no `<zoom>` block has no zoom to drive — that is a dropped
229958
+ * command and it is logged as one.
229959
+ */
229960
+ async runZoom(api, channel, zoom) {
229961
+ try {
229962
+ const range = (await api.getZoomFocus(channel)).zoom;
229963
+ if (!range) {
229964
+ this.ctx.logger.warn("Baichuan zoom dropped — camera reported no zoom travel", {
229965
+ tags: { deviceId: this.id },
229966
+ meta: { reason: "no-zoom-block" }
229967
+ });
229968
+ return;
229969
+ }
229970
+ const step = resolveZoomStep(range, zoom);
229971
+ if (step.kind === "refused") {
229972
+ this.ctx.logger.warn("Baichuan zoom dropped", {
229973
+ tags: { deviceId: this.id },
229974
+ meta: {
229975
+ reason: step.reason,
229976
+ curPos: range.curPos,
229977
+ minPos: range.minPos,
229978
+ maxPos: range.maxPos
229979
+ }
229980
+ });
229981
+ return;
229982
+ }
229983
+ for (let attempt = 1;; attempt += 1) try {
229984
+ await api.zoomToFactor(channel, step.target / ZOOM_FACTOR_SCALE);
229985
+ break;
229986
+ } catch (err) {
229987
+ if (attempt >= 2) throw err;
229988
+ await new Promise((resolve) => setTimeout(resolve, ZOOM_SET_RETRY_MS));
229989
+ }
229990
+ this.ctx.logger.debug("Baichuan zoom applied", {
229991
+ tags: { deviceId: this.id },
229992
+ meta: {
229993
+ from: range.curPos,
229994
+ to: step.target,
229995
+ minPos: range.minPos,
229996
+ maxPos: range.maxPos
229997
+ }
229998
+ });
229999
+ } catch (err) {
230000
+ this.ctx.logger.warn("Baichuan zoom command failed", {
230001
+ tags: { deviceId: this.id },
230002
+ meta: { error: err instanceof Error ? err.message : String(err) }
230003
+ });
230004
+ }
230005
+ }
229254
230006
  async getStreamSources() {
229255
230007
  return buildStreamIds(this.channelCount()).map((s, i) => ({
229256
230008
  id: s.id,
@@ -229559,6 +230311,10 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
229559
230311
  async materializeStreamSocket(camStreamId) {
229560
230312
  const parts = parseCamStreamId(camStreamId, this.getChannel());
229561
230313
  if (!parts || parts.kind !== "native") return;
230314
+ this.ctx.logger.info("broker requested rfc4571 source refresh — materializing on demand", {
230315
+ tags: { deviceId: this.id },
230316
+ meta: { camStreamId }
230317
+ });
229562
230318
  const server = await this.ensureRfc4571Server(camStreamId, parts.channel, parts.profile);
229563
230319
  if (!server) {
229564
230320
  this.ctx.logger.warn("materializeStreamSocket: ensureRfc4571Server returned null", { tags: {
@@ -234053,10 +234809,6 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
234053
234809
  this.ctx.logger.debug("broker requested source refresh without a camStreamId — broker will re-pull the catalog", { tags: { deviceId } });
234054
234810
  return;
234055
234811
  }
234056
- this.ctx.logger.info("broker requested rfc4571 source refresh — materializing on demand", {
234057
- tags: { deviceId },
234058
- meta: { camStreamId }
234059
- });
234060
234812
  await dev.materializeStreamSocket(camStreamId);
234061
234813
  }
234062
234814
  async supportsDiscovery() {