@camstack/addon-provider-rtsp 1.2.13 → 1.2.15

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 +704 -56
  2. package/dist/addon.mjs +704 -56
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -7219,8 +7219,31 @@ var AdoptionJobSchema = object({
7219
7219
  error: string().nullable()
7220
7220
  });
7221
7221
  /**
7222
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7223
- * pipeline functions an operator thinks in terms of.
7222
+ * Per-camera FUNCTION SWITCHES.
7223
+ *
7224
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7225
+ *
7226
+ * This file shipped as "the one coherent on/off surface over the pipeline
7227
+ * functions an operator thinks in terms of". The operator's verdict on
7228
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7229
+ * every function already had a settings page of its own, and a second place to
7230
+ * turn it off is a second place to look. Each switch is going back to its own
7231
+ * component's original options — detection to the detection-pipeline wrapper
7232
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7233
+ * (which was always first-class; the switch was a veneer over
7234
+ * `recording.setDeviceConfig`), notifications to a notification-center
7235
+ * per-device setting, the two camera planes to their own components.
7236
+ *
7237
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7238
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7239
+ * straight from the authorities with no group in the middle. That rule was
7240
+ * never about a control panel.
7241
+ *
7242
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7243
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7244
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7245
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7246
+ * stop; nothing new may be built on it.
7224
7247
  *
7225
7248
  * ## This file adds no state
7226
7249
  *
@@ -7603,7 +7626,15 @@ var RecordingConfigSchema = object({
7603
7626
  * Each completed/failed run also lands one durable ops-log row on its owning
7604
7627
  * addon surface.
7605
7628
  */
7629
+ /**
7630
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7631
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7632
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7633
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7634
+ * runs at all.
7635
+ */
7606
7636
  var RelocateJobStateSchema = _enum([
7637
+ "queued",
7607
7638
  "running",
7608
7639
  "done",
7609
7640
  "failed",
@@ -7638,6 +7669,15 @@ var RelocateFootageInputSchema = object({
7638
7669
  /** Limits relocation to the logical profile class. Omit only for the
7639
7670
  * pre-orchestration compatibility path. */
7640
7671
  footageClass: RelocateFootageClassSchema.optional(),
7672
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7673
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7674
+ * unit is a (camera, profile) pile, not a disk. */
7675
+ deviceId: number().int().optional(),
7676
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7677
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7678
+ * placement plan assigns those two independently, so a rebalance that could
7679
+ * only say "recordings" would move footage the plan never asked to move. */
7680
+ profiles: array(string()).optional(),
7641
7681
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7642
7682
  * never allowed to starve live writers. */
7643
7683
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7773,6 +7813,21 @@ var StorageLocationSchema = object({
7773
7813
  nodeId: string().optional(),
7774
7814
  isDefault: boolean().default(false),
7775
7815
  isSystem: boolean().default(false),
7816
+ /**
7817
+ * Operator opt-in: whether consumers that BALANCE across several locations
7818
+ * of a type may write here. Recordings reads it today; event media and
7819
+ * backups are the next consumers, which is why the flag lives on the
7820
+ * location rather than in any one addon's store — nothing has to be
7821
+ * extended to add the next consumer.
7822
+ *
7823
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7824
+ * flag existed reads back with no flag and keeps working exactly as before;
7825
+ * that is the whole compat story, and it is why no migration ships with it.
7826
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7827
+ * disk must not silently start writing to it); the default of a type is
7828
+ * always stamped `true`.
7829
+ */
7830
+ enabled: boolean().optional(),
7776
7831
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7777
7832
  * for node-local locations it can reach) — never persisted, absent when the
7778
7833
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12325,7 +12380,8 @@ method(object({
12325
12380
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12326
12381
  /**
12327
12382
  * filesystem-browse — per-node capability for browsing the node's local
12328
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12383
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12384
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12329
12385
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12330
12386
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12331
12387
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14166,6 +14222,13 @@ var MaskGridDimsSchema = object({
14166
14222
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14167
14223
  * this one field keeps the schema additive — a rule still declares exactly
14168
14224
  * one trigger.
14225
+ *
14226
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14227
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14228
+ * mirror.ts` fails the build on a member the app cannot render) and every
14229
+ * member costs a release train. A sustained-sound rule is therefore an
14230
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14231
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14169
14232
  */
14170
14233
  var NcDeliverySchema = _enum([
14171
14234
  "immediate",
@@ -14180,15 +14243,32 @@ var NcDeliverySchema = _enum([
14180
14243
  * depend on a provider's raw event name or payload shape.
14181
14244
  */
14182
14245
  var NcSystemEventKindSchema = _enum([
14183
- "camera-online",
14184
- "camera-offline",
14246
+ "device-online",
14247
+ "device-offline",
14248
+ "device-disabled",
14249
+ "device-enabled",
14185
14250
  "stream-online",
14186
14251
  "stream-offline",
14187
14252
  "node-online",
14188
14253
  "node-offline",
14189
14254
  "addon-update-available",
14190
- "server-update-available"
14255
+ "server-update-available",
14256
+ "alarm-triggered",
14257
+ "alarm-armed",
14258
+ "alarm-disarmed",
14259
+ "camera-online",
14260
+ "camera-offline",
14261
+ "camera-disabled",
14262
+ "camera-enabled"
14263
+ ]);
14264
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14265
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14266
+ "camera-online",
14267
+ "camera-offline",
14268
+ "camera-disabled",
14269
+ "camera-enabled"
14191
14270
  ]);
14271
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14192
14272
  /**
14193
14273
  * One coherent system-event condition. `kinds` is the required opt-in safety
14194
14274
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14197,6 +14277,18 @@ var NcSystemEventKindSchema = _enum([
14197
14277
  var NcSystemEventConditionSchema = object({
14198
14278
  kinds: array(NcSystemEventKindSchema).min(1),
14199
14279
  deviceIds: array(number().int()).min(1).optional(),
14280
+ /**
14281
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14282
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14283
+ * is what a liveness rule means when nobody said otherwise.
14284
+ *
14285
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14286
+ * one reason: the intake cannot know which devices this household cares
14287
+ * about, and a producer-side filter is one no operator can change. Fails
14288
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14289
+ * does not carry) matches no `deviceTypes` list.
14290
+ */
14291
+ deviceTypes: array(string().min(1)).min(1).optional(),
14200
14292
  nodeIds: array(string().min(1)).min(1).optional(),
14201
14293
  packageNames: array(string().min(1)).min(1).optional()
14202
14294
  });
@@ -14247,6 +14339,47 @@ var NcOccupancyConditionSchema = object({
14247
14339
  sustainSeconds: number().int().min(0).max(3600).default(15)
14248
14340
  });
14249
14341
  /**
14342
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14343
+ *
14344
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14345
+ * reference notifier uses, so an operator moving between them re-uses what
14346
+ * they already know): a rule matches when, over a sampling window of
14347
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14348
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14349
+ *
14350
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14351
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14352
+ * - `labels` — the classifier put at least one of these labels on it.
14353
+ *
14354
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14355
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14356
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14357
+ * is given** — a window in which every sample is trivially a hit would fire on
14358
+ * silence, so the engine refuses such a condition rather than notifying on
14359
+ * nothing (the schema cannot express "at least one of" without becoming a
14360
+ * ZodEffects the cap path would have to special-case).
14361
+ *
14362
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14363
+ * must be FULL before it can match — a window that has been open for two
14364
+ * seconds of its ten is 100% of nothing, and firing on it would make
14365
+ * `samplingSeconds` decorative.
14366
+ *
14367
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14368
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14369
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14370
+ * an operator who typed `dog` mean the same thing.
14371
+ */
14372
+ var NcAudioConditionSchema = object({
14373
+ /** Audio macro labels; absent = any sound (level-only rule). */
14374
+ labels: array(string().min(1)).min(1).optional(),
14375
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14376
+ dbThreshold: number().min(-96).max(0).optional(),
14377
+ /** Percentage of the window's samples that must be hits (1–100). */
14378
+ hitPercent: number().int().min(1).max(100).default(60),
14379
+ /** Length of the sampling window in seconds. */
14380
+ samplingSeconds: number().int().min(1).max(300).default(10)
14381
+ });
14382
+ /**
14250
14383
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14251
14384
  *
14252
14385
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14519,7 +14652,33 @@ var NcConditionsSchema = object({
14519
14652
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14520
14653
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14521
14654
  */
14522
- occupancy: NcOccupancyConditionSchema.optional()
14655
+ occupancy: NcOccupancyConditionSchema.optional(),
14656
+ /**
14657
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14658
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14659
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14660
+ * a window that is not full yet, neither filter given). See
14661
+ * {@link NcAudioCondition}.
14662
+ *
14663
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14664
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14665
+ * a detection, a track or a device event (the same fail-closed pairing
14666
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14667
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14668
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14669
+ * classified sample) stays exactly as it was for rules that already use it.
14670
+ *
14671
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14672
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14673
+ * (`camstack/src/data/notification-center.ts`, guarded by
14674
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14675
+ * condition fields it does not know when a rule is saved from the phone.
14676
+ * Publishing an editor for a condition the app cannot round-trip is how an
14677
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14678
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14679
+ * does an audio rule become authorable.
14680
+ */
14681
+ audio: NcAudioConditionSchema.optional()
14523
14682
  });
14524
14683
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14525
14684
  var NcRuleTargetSchema = object({
@@ -14633,6 +14792,73 @@ var NcThrottleSchema = object({
14633
14792
  */
14634
14793
  granularity: NcThrottleGranularitySchema.optional()
14635
14794
  });
14795
+ /**
14796
+ * How long the confirm gate may hold ONE notification, and how big the picture
14797
+ * it judges may be.
14798
+ *
14799
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14800
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14801
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14802
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14803
+ * tokens for pixels the model pools away.
14804
+ */
14805
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14806
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14807
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14808
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14809
+ var NcConfirmExpectSchema = object({
14810
+ op: _enum([
14811
+ ">=",
14812
+ ">",
14813
+ "<=",
14814
+ "<",
14815
+ "=="
14816
+ ]),
14817
+ count: number().int().min(0).max(1e3)
14818
+ });
14819
+ /**
14820
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14821
+ * to ship and says whether it agrees with the rule.
14822
+ *
14823
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14824
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14825
+ * on the operator's phone is not a verdict about this notification.
14826
+ *
14827
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14828
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14829
+ * the default and every fail-open is COUNTED, because a gate that always fails
14830
+ * open looks in the log exactly like a gate that works.
14831
+ *
14832
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14833
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14834
+ * production failures in one day), so the gate reads absent as the constant
14835
+ * above rather than trusting a parse it may never have seen.
14836
+ */
14837
+ var NcConfirmSchema = object({
14838
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14839
+ * same thing, and both mean "deliver exactly as before". */
14840
+ enabled: boolean().default(false),
14841
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14842
+ profileId: string().optional(),
14843
+ /**
14844
+ * The operator's question, in his own words. Absent = a question derived
14845
+ * from the rule (its class and its expectation).
14846
+ *
14847
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14848
+ * banners, signage and plates as instructions if you let them reach the
14849
+ * prompt — proven live — so the authoritative contract stays in the system
14850
+ * turn and only rule-authored words land here.
14851
+ */
14852
+ prompt: string().max(1e3).optional(),
14853
+ /** Fire only when the model's count satisfies this. Absent = the model's
14854
+ * own boolean verdict decides. */
14855
+ expect: NcConfirmExpectSchema.optional(),
14856
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14857
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14858
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14859
+ /** Longest edge the judged image is downscaled to before it is sent. */
14860
+ maxImagePx: number().int().min(64).max(2048).default(448)
14861
+ });
14636
14862
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14637
14863
  var NcRuleInputSchema = object({
14638
14864
  name: string().min(1).max(200),
@@ -14693,7 +14919,13 @@ var NcRuleInputSchema = object({
14693
14919
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14694
14920
  * shape as every other actuation.
14695
14921
  */
14696
- actions: NcRuleActionsSchema.optional()
14922
+ actions: NcRuleActionsSchema.optional(),
14923
+ /**
14924
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14925
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14926
+ * did, and absent is the only way to say that without a migration.
14927
+ */
14928
+ confirm: NcConfirmSchema.optional()
14697
14929
  });
14698
14930
  /**
14699
14931
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14704,7 +14936,37 @@ var NcRuleInputSchema = object({
14704
14936
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14705
14937
  * `updateRule` patch.
14706
14938
  */
14707
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14939
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14940
+ disabledTargetIds: array(string()).optional(),
14941
+ /**
14942
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14943
+ *
14944
+ * It makes the key optional to SUPPLY; the parse still materialises the
14945
+ * default when the key is absent. And `NcRuleStore.update` merges with
14946
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14947
+ * one — which made every partial edit destructive:
14948
+ *
14949
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14950
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14951
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14952
+ *
14953
+ * A rule scoped to one camera and one zone silently became a rule that
14954
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14955
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14956
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14957
+ * within a minute of a two-field patch.
14958
+ *
14959
+ * So every defaulted field is re-declared here WITHOUT its default. The
14960
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14961
+ * conditions remains a real instruction ("clear them") — and only the
14962
+ * absent key is now genuinely absent.
14963
+ */
14964
+ enabled: boolean().optional(),
14965
+ conditions: NcConditionsSchema.optional(),
14966
+ media: NcMediaPolicySchema.optional(),
14967
+ throttle: NcThrottleSchema.optional(),
14968
+ priority: number().int().min(1).max(5).optional()
14969
+ });
14708
14970
  /** A persisted rule. */
14709
14971
  var NcRuleSchema = NcRuleInputSchema.extend({
14710
14972
  id: string(),
@@ -15005,6 +15267,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15005
15267
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15006
15268
  * copy would lie the first time a rule is disabled.
15007
15269
  */
15270
+ /**
15271
+ * Why a device a mode NAMES is nonetheless not armed by it.
15272
+ *
15273
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15274
+ * per-camera notification switch the Notification Center already owns,
15275
+ * `detection-off` is the device's own detection binding being inactive, and
15276
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15277
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15278
+ * with the switches the operator actually used.
15279
+ */
15280
+ var NcAlarmSkipReasonSchema = _enum([
15281
+ "muted",
15282
+ "detection-off",
15283
+ "offline"
15284
+ ]);
15285
+ var NcAlarmSkippedDeviceSchema = object({
15286
+ deviceId: number().int(),
15287
+ reason: NcAlarmSkipReasonSchema
15288
+ });
15008
15289
  var NcAlarmModeCoverageSchema = object({
15009
15290
  mode: AlarmArmModeSchema,
15010
15291
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15012,7 +15293,18 @@ var NcAlarmModeCoverageSchema = object({
15012
15293
  /** At least one covering rule has no device scope, so the mode covers all. */
15013
15294
  allDevices: boolean(),
15014
15295
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15015
- deviceIds: array(number().int())
15296
+ deviceIds: array(number().int()),
15297
+ /**
15298
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15299
+ * excludes it.
15300
+ *
15301
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15302
+ * twelve makes it false in exactly the way nobody notices until an incident.
15303
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15304
+ * still parses as "nothing known to be skipped" rather than failing the whole
15305
+ * alarm tab.
15306
+ */
15307
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15016
15308
  });
15017
15309
  var NcAlarmConfigSchema = object({
15018
15310
  /**
@@ -17844,9 +18136,16 @@ var CameraStatusSchema = object({
17844
18136
  audio: CameraAudioStatusSchema.nullable(),
17845
18137
  recording: CameraRecordingStatusSchema.nullable(),
17846
18138
  /**
17847
- * Per-camera function switches an OPERATOR has turned off
18139
+ * Per-camera functions an OPERATOR has turned off
17848
18140
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17849
18141
  *
18142
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18143
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18144
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18145
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18146
+ * The badge outlives the control panel: the panel was a convenience, this is
18147
+ * the difference between a camera being off and a camera being dead.
18148
+ *
17850
18149
  * This is the difference between DISABLED and BROKEN. A camera whose
17851
18150
  * `detection` block reports zero fps and whose `switchedOff` contains
17852
18151
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -18453,24 +18752,28 @@ var snapshotCapability = {
18453
18752
  *
18454
18753
  * `getSnapshotOverview` is cache-only by contract: it answers from whatever
18455
18754
  * the wrapper happens to hold and never captures. Under D93 the client
18456
- * versions its image URL on that answer, and an image REQUEST is what enrols
18457
- * a camera in the keep-warm loop. Both of those are satisfiable by the
18458
- * client's own image cache — `expo-image` is URL-keyed and never revalidates
18459
- * — so a URL painted in a previous session comes off disk with no network,
18460
- * no enrolment, and nothing warming. Measured on the live hub: reopening
18461
- * after two minutes idle painted 15 of 16 tiles at **168 s old** with zero
18462
- * HTTP requests, and the fleet only recovered because a later poll happened
18463
- * to observe a different identity.
18755
+ * versions its image URL on that answer, and an image REQUEST was the only
18756
+ * demand signal. Both of those are satisfiable by the client's own image
18757
+ * cache — `expo-image` is URL-keyed and never revalidates — so a URL painted
18758
+ * in a previous session comes off disk with no network, no demand, and no
18759
+ * capture. Measured on the live hub: reopening after two minutes idle
18760
+ * painted 15 of 16 tiles at **168 s old** with zero HTTP requests, and the
18761
+ * fleet only recovered because a later poll happened to observe a different
18762
+ * identity.
18464
18763
  *
18465
18764
  * ## The two properties that fix it
18466
18765
  *
18467
18766
  * **It is an RPC, so no client cache can answer it.** The demand signal
18468
- * always reaches the wrapper. This method therefore MAY create keep-warm
18469
- * subscriptions, where `getSnapshotOverview` must never (D93) — the
18470
- * distinction is not "one is newer" but that the overview poll is app-wide
18471
- * (a creating overview would warm every camera on the install) while this is
18472
- * called by a rendered surface naming the tiles it is actually painting, at
18473
- * the width it is painting them.
18767
+ * always reaches the wrapper. This method therefore CAPTURES, where
18768
+ * `getSnapshotOverview` must never (D93) — the distinction is not "one is
18769
+ * newer" but that the overview poll is app-wide (a capturing overview would
18770
+ * dial every camera on the install) while this is called by a rendered
18771
+ * surface naming the tiles it is actually painting, at the width it is
18772
+ * painting them.
18773
+ *
18774
+ * Since 2026-08-11 this is the ONLY thing that refreshes a snapshot: the
18775
+ * server-side keep-warm loop was removed (operator directive — on-demand,
18776
+ * always), so a camera nobody is looking at costs nothing at all.
18474
18777
  *
18475
18778
  * **It waits, briefly and boundedly, for the capture it triggered.** The
18476
18779
  * returned `capturedAt` is the frame the link will serve, not the frame the
@@ -24687,7 +24990,19 @@ var RecordingManifestSchema = object({
24687
24990
  * profiles/subtrees/locations on this node). */
24688
24991
  var RecordingDeviceUsageSchema = object({
24689
24992
  deviceId: number(),
24690
- usedBytes: number()
24993
+ usedBytes: number(),
24994
+ /**
24995
+ * Start of this camera's OLDEST indexed segment, across every profile and
24996
+ * location — the "Oldest footage" column in Recordings → Storage, and the
24997
+ * only honest answer to "is retention actually holding?" per camera.
24998
+ *
24999
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25000
+ * predates this field omits it entirely, and a hub whose types carry the
25001
+ * field must keep validating that older provider's payload: the framework
25002
+ * (types) and the addon ship on different trains, and the addon is usually
25003
+ * the later of the two.
25004
+ */
25005
+ oldestMs: number().nullable().optional()
24691
25006
  });
24692
25007
  /** Recording storage usage + capacity for one storage location. */
24693
25008
  var RecordingLocationUsageSchema = object({
@@ -24715,6 +25030,57 @@ var RecordingStorageUsageSchema = object({
24715
25030
  locations: array(RecordingLocationUsageSchema)
24716
25031
  });
24717
25032
  /**
25033
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25034
+ *
25035
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25036
+ * is the operator asking for the EXISTING archive to be brought into line with
25037
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25038
+ * location, run FIFO behind the single-flight mover.
25039
+ *
25040
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25041
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25042
+ * (empty on the plan).
25043
+ */
25044
+ var RecordingRebalanceMoveSchema = object({
25045
+ deviceId: number(),
25046
+ profile: string(),
25047
+ fromLocationId: string(),
25048
+ toLocationId: string(),
25049
+ bytes: number(),
25050
+ files: number().int()
25051
+ });
25052
+ /** Why a pile that is out of place is staying there. Every refusal is
25053
+ * reported: a rebalance that silently drops a camera reads exactly like one
25054
+ * that had nothing to do. */
25055
+ var RecordingRebalanceSkipReasonSchema = _enum([
25056
+ "unassigned",
25057
+ "target-not-writable",
25058
+ "below-threshold",
25059
+ "no-headroom"
25060
+ ]);
25061
+ var RecordingRebalanceSkipSchema = object({
25062
+ deviceId: number(),
25063
+ profile: string(),
25064
+ fromLocationId: string(),
25065
+ /** The location the plan wants; null when the camera has no assignment. */
25066
+ toLocationId: string().nullable(),
25067
+ bytes: number(),
25068
+ reason: RecordingRebalanceSkipReasonSchema
25069
+ });
25070
+ var RecordingRebalancePlanSchema = object({
25071
+ moves: array(RecordingRebalanceMoveSchema),
25072
+ skipped: array(RecordingRebalanceSkipSchema),
25073
+ bytesToMove: number(),
25074
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25075
+ jobIds: array(string())
25076
+ });
25077
+ var RecordingRebalanceInputSchema = object({
25078
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25079
+ throttleMbps: number().min(1).max(1e3).optional(),
25080
+ /** Ignore piles smaller than this (default 1 GB). */
25081
+ minMoveGb: number().min(0).optional()
25082
+ });
25083
+ /**
24718
25084
  * Result of locating footage at a wall-clock instant for one device/profile.
24719
25085
  * `segment` carries the covering segment's window; `gap` reports the forward
24720
25086
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -24877,9 +25243,24 @@ method(object({
24877
25243
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24878
25244
  kind: "mutation",
24879
25245
  auth: "admin"
25246
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25247
+ kind: "mutation",
25248
+ auth: "admin"
25249
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25250
+ kind: "query",
25251
+ auth: "admin"
25252
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25253
+ kind: "mutation",
25254
+ auth: "admin"
25255
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25256
+ kind: "query",
25257
+ auth: "admin"
25258
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25259
+ kind: "mutation",
25260
+ auth: "admin"
24880
25261
  });
24881
25262
  /**
24882
- * `recordingExport` cap — render a footage time range into a single downloadable
25263
+ * `recording-export` cap — render a footage time range into a single downloadable
24883
25264
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
24884
25265
  * bounded lifetime with a durable history, auto-expiry, and optional
24885
25266
  * delete-after-download.
@@ -24894,10 +25275,53 @@ method(object({
24894
25275
  */
24895
25276
  /** Playback-speed multiplier for the render (1 = realtime). */
24896
25277
  var ExportSpeedSchema = number().min(.25).max(32);
25278
+ /**
25279
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25280
+ *
25281
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25282
+ * derives these bounds from things that happened at a TIME (a track's
25283
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25284
+ * every segment present for the range, with each recording GAP removed. The
25285
+ * two agree only on a window that recorded without one interruption, and only
25286
+ * the render side knows the segments, so the translation lives there
25287
+ * (`export-dense-map.ts`, addon-pipeline).
25288
+ *
25289
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25290
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25291
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25292
+ * the video was a uniform timelapse, and the log line reported the five ranges
25293
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25294
+ *
25295
+ * Relative and not absolute epoch, because an absolute epoch would make every
25296
+ * call site responsible for the same subtraction.
25297
+ */
25298
+ var ExportDenseRangeSchema = object({
25299
+ fromSec: number().nonnegative(),
25300
+ toSec: number().nonnegative()
25301
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25302
+ /**
25303
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25304
+ * listed ranges and at the base `everyMs` everywhere else.
25305
+ *
25306
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25307
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25308
+ */
25309
+ var ExportDenseSchema = object({
25310
+ everyMs: number().int().positive(),
25311
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25312
+ });
24897
25313
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
24898
25314
  var ExportTimelapseSchema = object({
24899
25315
  everyMs: number().int().positive(),
24900
- outputFps: number().int().min(1).max(60).optional()
25316
+ outputFps: number().int().min(1).max(60).optional(),
25317
+ /** Optional second, FASTER rate over the intervals that matter. */
25318
+ dense: ExportDenseSchema.optional()
25319
+ }).superRefine((v, ctx) => {
25320
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25321
+ code: ZodIssueCode.custom,
25322
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25323
+ path: ["dense", "everyMs"]
25324
+ });
24901
25325
  });
24902
25326
  /**
24903
25327
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -24955,6 +25379,19 @@ var ExportDownloadSchema = object({
24955
25379
  url: string(),
24956
25380
  endpoints: array(string())
24957
25381
  });
25382
+ /**
25383
+ * A finished export's bytes, inline.
25384
+ *
25385
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25386
+ * against, so nobody has to infer it from the base64 length.
25387
+ */
25388
+ var ExportBytesSchema = object({
25389
+ base64: string(),
25390
+ contentType: string(),
25391
+ /** Suggested filename, extension included. */
25392
+ name: string(),
25393
+ bytes: number().int().nonnegative()
25394
+ });
24958
25395
  method(object({
24959
25396
  deviceId: number(),
24960
25397
  profile: string(),
@@ -24979,6 +25416,9 @@ method(object({
24979
25416
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
24980
25417
  kind: "query",
24981
25418
  auth: "protected"
25419
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25420
+ kind: "query",
25421
+ auth: "protected"
24982
25422
  });
24983
25423
  /**
24984
25424
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -31735,6 +32175,12 @@ Object.freeze({
31735
32175
  addonId: null,
31736
32176
  access: "create"
31737
32177
  },
32178
+ "recording.cancelRelocateJob": {
32179
+ capName: "recording",
32180
+ capScope: "system",
32181
+ addonId: null,
32182
+ access: "create"
32183
+ },
31738
32184
  "recording.cancelStorageMigrationMove": {
31739
32185
  capName: "recording",
31740
32186
  capScope: "system",
@@ -31789,6 +32235,12 @@ Object.freeze({
31789
32235
  addonId: null,
31790
32236
  access: "view"
31791
32237
  },
32238
+ "recording.listRelocateJobs": {
32239
+ capName: "recording",
32240
+ capScope: "system",
32241
+ addonId: null,
32242
+ access: "view"
32243
+ },
31792
32244
  "recording.locateSegment": {
31793
32245
  capName: "recording",
31794
32246
  capScope: "system",
@@ -31801,6 +32253,12 @@ Object.freeze({
31801
32253
  addonId: null,
31802
32254
  access: "create"
31803
32255
  },
32256
+ "recording.planStorageRebalance": {
32257
+ capName: "recording",
32258
+ capScope: "system",
32259
+ addonId: null,
32260
+ access: "view"
32261
+ },
31804
32262
  "recording.pruneFootage": {
31805
32263
  capName: "recording",
31806
32264
  capScope: "system",
@@ -31825,6 +32283,12 @@ Object.freeze({
31825
32283
  addonId: null,
31826
32284
  access: "create"
31827
32285
  },
32286
+ "recording.relocateFootage": {
32287
+ capName: "recording",
32288
+ capScope: "system",
32289
+ addonId: null,
32290
+ access: "create"
32291
+ },
31828
32292
  "recording.renderClip": {
31829
32293
  capName: "recording",
31830
32294
  capScope: "system",
@@ -31861,38 +32325,50 @@ Object.freeze({
31861
32325
  addonId: null,
31862
32326
  access: "create"
31863
32327
  },
32328
+ "recording.startStorageRebalance": {
32329
+ capName: "recording",
32330
+ capScope: "system",
32331
+ addonId: null,
32332
+ access: "create"
32333
+ },
31864
32334
  "recordingExport.cancelExport": {
31865
- capName: "recordingExport",
32335
+ capName: "recording-export",
31866
32336
  capScope: "system",
31867
32337
  addonId: null,
31868
32338
  access: "create"
31869
32339
  },
31870
32340
  "recordingExport.createExport": {
31871
- capName: "recordingExport",
32341
+ capName: "recording-export",
31872
32342
  capScope: "system",
31873
32343
  addonId: null,
31874
32344
  access: "create"
31875
32345
  },
31876
32346
  "recordingExport.deleteExport": {
31877
- capName: "recordingExport",
32347
+ capName: "recording-export",
31878
32348
  capScope: "system",
31879
32349
  addonId: null,
31880
32350
  access: "delete"
31881
32351
  },
31882
32352
  "recordingExport.getDownloadUrl": {
31883
- capName: "recordingExport",
32353
+ capName: "recording-export",
31884
32354
  capScope: "system",
31885
32355
  addonId: null,
31886
32356
  access: "view"
31887
32357
  },
31888
32358
  "recordingExport.getExport": {
31889
- capName: "recordingExport",
32359
+ capName: "recording-export",
31890
32360
  capScope: "system",
31891
32361
  addonId: null,
31892
32362
  access: "view"
31893
32363
  },
31894
32364
  "recordingExport.listExports": {
31895
- capName: "recordingExport",
32365
+ capName: "recording-export",
32366
+ capScope: "system",
32367
+ addonId: null,
32368
+ access: "view"
32369
+ },
32370
+ "recordingExport.readExportBytes": {
32371
+ capName: "recording-export",
31896
32372
  capScope: "system",
31897
32373
  addonId: null,
31898
32374
  access: "view"
@@ -33269,6 +33745,104 @@ var FramerateField = number().int().min(1).max(60);
33269
33745
  var TargetsField = array(NcRuleTargetSchema).min(1);
33270
33746
  var PriorityField = number().int().min(1).max(5);
33271
33747
  /**
33748
+ * Explicit override of the DENSE sampling cadence, seconds.
33749
+ *
33750
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
33751
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
33752
+ * made that same base 3 s and rendered a person pass as two frames.)
33753
+ *
33754
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
33755
+ * `denseCadenceSec` and played at `framerate` occupies
33756
+ *
33757
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
33758
+ *
33759
+ * 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.
33760
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
33761
+ * and therefore the length of a quiet night, does not move.
33762
+ *
33763
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
33764
+ * the recording has them returns the same frames, requested twice. Must be
33765
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
33766
+ * a uniform video the operator believes is two-rate — and upsert refuses it
33767
+ * rather than letting the export cap reject the render hours after the window.
33768
+ */
33769
+ var DenseCadenceSecField = number().min(.1).max(3600);
33770
+ /**
33771
+ * Minimum seconds of OUTPUT video each detection range must occupy.
33772
+ *
33773
+ * The operator-facing form of the arithmetic above: instead of solving for a
33774
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
33775
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
33776
+ * that range every ~583 ms.
33777
+ *
33778
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
33779
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
33780
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
33781
+ * ranges are sampled denser than they need. Per-range cadences require a cap
33782
+ * schema change and are the tracked follow-up.
33783
+ *
33784
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
33785
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
33786
+ * by real footage, never met by duplicating frames into motion that never
33787
+ * happened.
33788
+ */
33789
+ var MinDwellSecField = number().min(0).max(60);
33790
+ /**
33791
+ * Caption burned into the notification's preview frame.
33792
+ *
33793
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
33794
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
33795
+ * templating dialect for one field would be a second thing to explain.
33796
+ *
33797
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
33798
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
33799
+ * the reason this is not `.min(1)`.
33800
+ */
33801
+ var PreviewTextField = string().max(200);
33802
+ /**
33803
+ * Whether the notification's preview is a STILL or a short animation.
33804
+ *
33805
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
33806
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
33807
+ * night reads better as three seconds of motion than as one frame of it. Both
33808
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
33809
+ * simply applies it to a dozen frames sampled across the render and assembles
33810
+ * them.
33811
+ *
33812
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
33813
+ * seeks and a palette pass, and no rule that never asked for one should start
33814
+ * paying that on the deploy that shipped it.
33815
+ *
33816
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
33817
+ */
33818
+ var PreviewModeField = _enum(["image", "gif"]);
33819
+ /**
33820
+ * Which detection classes the notification reports counts for.
33821
+ *
33822
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
33823
+ * plan — no second query — aggregated per class. Absent or empty means "every
33824
+ * class the window actually contained", which is what an operator who never
33825
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
33826
+ * counts cars all night).
33827
+ *
33828
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
33829
+ * …). An unknown name simply never matches and reports nothing — it is not an
33830
+ * error, because a rule may legitimately name a class this camera's model does
33831
+ * not emit.
33832
+ *
33833
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
33834
+ * - `{{detections}}` — total over the reported classes
33835
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
33836
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
33837
+ * one per class, `count_` + the class name
33838
+ *
33839
+ * With NO custom body template the summary is appended to the derived body, and
33840
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
33841
+ * reads. With a custom template the operator owns every word — nothing is
33842
+ * appended, so `{{detectionSummary}}` is how he asks for it.
33843
+ */
33844
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
33845
+ /**
33272
33846
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33273
33847
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33274
33848
  * here (see the ownership note above).
@@ -33288,9 +33862,30 @@ var TimelapseRuleInputSchema = object({
33288
33862
  cadenceSec: CadenceSecField.default(15),
33289
33863
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33290
33864
  framerate: FramerateField.default(10),
33865
+ /**
33866
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
33867
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
33868
+ * field gets.
33869
+ */
33870
+ denseCadenceSec: DenseCadenceSecField.optional(),
33871
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
33872
+ minDwellSec: MinDwellSecField.optional(),
33291
33873
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33292
33874
  targets: TargetsField,
33293
33875
  template: TimelapseTemplateSchema.optional(),
33876
+ /**
33877
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
33878
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
33879
+ *
33880
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
33881
+ * the notification's title/body, and clearing it (`template: null`) must not
33882
+ * silently clear the caption too.
33883
+ */
33884
+ previewText: PreviewTextField.optional(),
33885
+ /** Still or animation — see {@link PreviewModeField}. */
33886
+ previewMode: PreviewModeField.default("image"),
33887
+ /** Classes the notification counts — see {@link ReportClassesField}. */
33888
+ reportClasses: ReportClassesField.optional(),
33294
33889
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33295
33890
  priority: PriorityField.default(3)
33296
33891
  });
@@ -33301,8 +33896,13 @@ object({
33301
33896
  schedule: NcScheduleSchema.optional(),
33302
33897
  cadenceSec: CadenceSecField.optional(),
33303
33898
  framerate: FramerateField.optional(),
33899
+ denseCadenceSec: DenseCadenceSecField.optional(),
33900
+ minDwellSec: MinDwellSecField.optional(),
33304
33901
  targets: TargetsField.optional(),
33305
33902
  template: TimelapseTemplateSchema.nullable().optional(),
33903
+ previewText: PreviewTextField.optional(),
33904
+ previewMode: PreviewModeField.optional(),
33905
+ reportClasses: ReportClassesField.optional(),
33306
33906
  priority: PriorityField.optional()
33307
33907
  });
33308
33908
  TimelapseRuleInputSchema.extend({
@@ -33314,10 +33914,28 @@ TimelapseRuleInputSchema.extend({
33314
33914
  */
33315
33915
  ownerUserId: string().optional(),
33316
33916
  /**
33317
- * Epoch-ms of the last successful generation the 1-hour re-generation
33318
- * guard's durable state (predecessor parity). Absent = never generated.
33917
+ * Epoch-ms of the NEWEST successful generation across every camera of this
33918
+ * rule. What a UI shows, and the compatibility floor for
33919
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33319
33920
  */
33320
33921
  lastGeneratedAt: number().optional(),
33922
+ /**
33923
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
33924
+ * re-generation guard's real durable state.
33925
+ *
33926
+ * One rule covers several cameras and each renders its own video, so a rule
33927
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
33928
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
33929
+ * already done — and B's night is gone for good, because the window will not
33930
+ * come back.
33931
+ *
33932
+ * ADDITIVE, so the migration is free: a row written before this field simply
33933
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
33934
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
33935
+ * "never generated" would re-render and re-notify every camera of every rule
33936
+ * once, on the deploy that shipped the map.
33937
+ */
33938
+ generatedByDevice: record(string(), number()).optional(),
33321
33939
  /** userId of the caller who created the rule (server-stamped). */
33322
33940
  createdBy: string(),
33323
33941
  createdAt: number(),
@@ -33368,25 +33986,32 @@ object({
33368
33986
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33369
33987
  object({
33370
33988
  /**
33371
- * How long a retained native frame is served before it counts as a miss.
33989
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
33990
+ * detection result.
33372
33991
  *
33373
- * Must cover the FULL late-crop horizon: detection inference + the
33374
- * cross-process inference-result hop to hub post-analysis + tracking + the
33375
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33376
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33377
- * RAM per busy camera grows linearly with no measured hit-rate gain.
33992
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
33993
+ * a time window was never related to the event the pixels were waiting for.
33994
+ * A held frame now lives from delivery until the runner has its `FrameResult`
33995
+ * at which moment the runner cuts the subject tiles it actually wanted and
33996
+ * releases the frame. The bound exists only so a runner that stops answering
33997
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
33998
+ *
33999
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
34000
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
34001
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
34002
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
34003
+ * `holdOverflow` on the metrics line is what says you need it.
33378
34004
  */
33379
- ttlMs: number().int().min(250).max(1e4),
34005
+ holdFrames: number().int().min(1).max(64),
33380
34006
  /**
33381
34007
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33382
34008
  *
33383
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33384
- * which one is actually binding before reasoning from that. At the shipped
33385
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33386
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33387
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33388
- * change that admits fewer frames buys retention WINDOW at constant RAM
33389
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
34009
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
34010
+ * is what decides how much is held, and the ceiling is the number above which
34011
+ * something is wrong. Before that it was the effective cap at 1024 MB with
34012
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
34013
+ * with the TTL expiring nothing, which is exactly the confusion the hold
34014
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33390
34015
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33391
34016
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33392
34017
  * to replace).
@@ -33412,22 +34037,45 @@ object({
33412
34037
  * there is the signal that some caller names frames outside the inference set
33413
34038
  * and that this must go back to `all`.
33414
34039
  */
33415
- admission: NativeLeaseAdmissionSchema
34040
+ admission: NativeLeaseAdmissionSchema,
34041
+ /**
34042
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
34043
+ * compressed native crops the worker cuts at the moment a frame's detection
34044
+ * result arrives, and keeps long after the frame itself is freed.
34045
+ *
34046
+ * This is the knob that replaced the old retention window, and it buys about
34047
+ * three orders of magnitude more of it: a tile is one subject at native
34048
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
34049
+ * the frame it was cut from. A frame on which nothing was detected costs
34050
+ * nothing at all, which is the real change — the old lease paid per FRAME and
34051
+ * was interrogated per SUBJECT.
34052
+ *
34053
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
34054
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
34055
+ * reproduce that.
34056
+ */
34057
+ tileBudgetMb: number().int().min(0).max(1024)
33416
34058
  });
33417
34059
  /**
33418
- * The values in force when the operator has set nothing — byte-for-byte the
33419
- * constants the decode worker shipped with as env-var defaults, so making these
33420
- * settings changed no behaviour on the day it landed.
34060
+ * The values in force when the operator has set nothing.
34061
+ *
34062
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
34063
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
34064
+ * in the same change that redefines it would make a regression and a retune
34065
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
34066
+ * live traffic.
33421
34067
  */
33422
34068
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33423
- ttlMs: 1200,
34069
+ holdFrames: 8,
33424
34070
  budgetMb: 1024,
33425
34071
  activityMs: 15e3,
34072
+ tileBudgetMb: 64,
33426
34073
  admission: "inferred"
33427
34074
  };
33428
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
34075
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33429
34076
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33430
34077
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34078
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33431
34079
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33432
34080
  /**
33433
34081
  * Names that, when used as URL query parameters, almost certainly carry