@camstack/addon-notifiers 1.2.17 → 1.2.19

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 +686 -42
  2. package/dist/addon.mjs +686 -42
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -7338,8 +7338,31 @@ var AdoptionJobSchema = object({
7338
7338
  error: string().nullable()
7339
7339
  });
7340
7340
  /**
7341
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7342
- * pipeline functions an operator thinks in terms of.
7341
+ * Per-camera FUNCTION SWITCHES.
7342
+ *
7343
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7344
+ *
7345
+ * This file shipped as "the one coherent on/off surface over the pipeline
7346
+ * functions an operator thinks in terms of". The operator's verdict on
7347
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7348
+ * every function already had a settings page of its own, and a second place to
7349
+ * turn it off is a second place to look. Each switch is going back to its own
7350
+ * component's original options — detection to the detection-pipeline wrapper
7351
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7352
+ * (which was always first-class; the switch was a veneer over
7353
+ * `recording.setDeviceConfig`), notifications to a notification-center
7354
+ * per-device setting, the two camera planes to their own components.
7355
+ *
7356
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7357
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7358
+ * straight from the authorities with no group in the middle. That rule was
7359
+ * never about a control panel.
7360
+ *
7361
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7362
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7363
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7364
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7365
+ * stop; nothing new may be built on it.
7343
7366
  *
7344
7367
  * ## This file adds no state
7345
7368
  *
@@ -7690,7 +7713,15 @@ var RecordingConfigSchema = object({
7690
7713
  * Each completed/failed run also lands one durable ops-log row on its owning
7691
7714
  * addon surface.
7692
7715
  */
7716
+ /**
7717
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7718
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7719
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7720
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7721
+ * runs at all.
7722
+ */
7693
7723
  var RelocateJobStateSchema = _enum([
7724
+ "queued",
7694
7725
  "running",
7695
7726
  "done",
7696
7727
  "failed",
@@ -7725,6 +7756,15 @@ var RelocateFootageInputSchema = object({
7725
7756
  /** Limits relocation to the logical profile class. Omit only for the
7726
7757
  * pre-orchestration compatibility path. */
7727
7758
  footageClass: RelocateFootageClassSchema.optional(),
7759
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7760
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7761
+ * unit is a (camera, profile) pile, not a disk. */
7762
+ deviceId: number().int().optional(),
7763
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7764
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7765
+ * placement plan assigns those two independently, so a rebalance that could
7766
+ * only say "recordings" would move footage the plan never asked to move. */
7767
+ profiles: array(string()).optional(),
7728
7768
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7729
7769
  * never allowed to starve live writers. */
7730
7770
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7860,6 +7900,21 @@ var StorageLocationSchema = object({
7860
7900
  nodeId: string().optional(),
7861
7901
  isDefault: boolean().default(false),
7862
7902
  isSystem: boolean().default(false),
7903
+ /**
7904
+ * Operator opt-in: whether consumers that BALANCE across several locations
7905
+ * of a type may write here. Recordings reads it today; event media and
7906
+ * backups are the next consumers, which is why the flag lives on the
7907
+ * location rather than in any one addon's store — nothing has to be
7908
+ * extended to add the next consumer.
7909
+ *
7910
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7911
+ * flag existed reads back with no flag and keeps working exactly as before;
7912
+ * that is the whole compat story, and it is why no migration ships with it.
7913
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7914
+ * disk must not silently start writing to it); the default of a type is
7915
+ * always stamped `true`.
7916
+ */
7917
+ enabled: boolean().optional(),
7863
7918
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7864
7919
  * for node-local locations it can reach) — never persisted, absent when the
7865
7920
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12203,7 +12258,8 @@ method(object({
12203
12258
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12204
12259
  /**
12205
12260
  * filesystem-browse — per-node capability for browsing the node's local
12206
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12261
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12262
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12207
12263
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12208
12264
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12209
12265
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14030,6 +14086,13 @@ var MaskGridDimsSchema = object({
14030
14086
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14031
14087
  * this one field keeps the schema additive — a rule still declares exactly
14032
14088
  * one trigger.
14089
+ *
14090
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14091
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14092
+ * mirror.ts` fails the build on a member the app cannot render) and every
14093
+ * member costs a release train. A sustained-sound rule is therefore an
14094
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14095
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14033
14096
  */
14034
14097
  var NcDeliverySchema = _enum([
14035
14098
  "immediate",
@@ -14044,15 +14107,32 @@ var NcDeliverySchema = _enum([
14044
14107
  * depend on a provider's raw event name or payload shape.
14045
14108
  */
14046
14109
  var NcSystemEventKindSchema = _enum([
14047
- "camera-online",
14048
- "camera-offline",
14110
+ "device-online",
14111
+ "device-offline",
14112
+ "device-disabled",
14113
+ "device-enabled",
14049
14114
  "stream-online",
14050
14115
  "stream-offline",
14051
14116
  "node-online",
14052
14117
  "node-offline",
14053
14118
  "addon-update-available",
14054
- "server-update-available"
14119
+ "server-update-available",
14120
+ "alarm-triggered",
14121
+ "alarm-armed",
14122
+ "alarm-disarmed",
14123
+ "camera-online",
14124
+ "camera-offline",
14125
+ "camera-disabled",
14126
+ "camera-enabled"
14127
+ ]);
14128
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14129
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14130
+ "camera-online",
14131
+ "camera-offline",
14132
+ "camera-disabled",
14133
+ "camera-enabled"
14055
14134
  ]);
14135
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14056
14136
  /**
14057
14137
  * One coherent system-event condition. `kinds` is the required opt-in safety
14058
14138
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14061,6 +14141,18 @@ var NcSystemEventKindSchema = _enum([
14061
14141
  var NcSystemEventConditionSchema = object({
14062
14142
  kinds: array(NcSystemEventKindSchema).min(1),
14063
14143
  deviceIds: array(number().int()).min(1).optional(),
14144
+ /**
14145
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14146
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14147
+ * is what a liveness rule means when nobody said otherwise.
14148
+ *
14149
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14150
+ * one reason: the intake cannot know which devices this household cares
14151
+ * about, and a producer-side filter is one no operator can change. Fails
14152
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14153
+ * does not carry) matches no `deviceTypes` list.
14154
+ */
14155
+ deviceTypes: array(string().min(1)).min(1).optional(),
14064
14156
  nodeIds: array(string().min(1)).min(1).optional(),
14065
14157
  packageNames: array(string().min(1)).min(1).optional()
14066
14158
  });
@@ -14111,6 +14203,47 @@ var NcOccupancyConditionSchema = object({
14111
14203
  sustainSeconds: number().int().min(0).max(3600).default(15)
14112
14204
  });
14113
14205
  /**
14206
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14207
+ *
14208
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14209
+ * reference notifier uses, so an operator moving between them re-uses what
14210
+ * they already know): a rule matches when, over a sampling window of
14211
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14212
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14213
+ *
14214
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14215
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14216
+ * - `labels` — the classifier put at least one of these labels on it.
14217
+ *
14218
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14219
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14220
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14221
+ * is given** — a window in which every sample is trivially a hit would fire on
14222
+ * silence, so the engine refuses such a condition rather than notifying on
14223
+ * nothing (the schema cannot express "at least one of" without becoming a
14224
+ * ZodEffects the cap path would have to special-case).
14225
+ *
14226
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14227
+ * must be FULL before it can match — a window that has been open for two
14228
+ * seconds of its ten is 100% of nothing, and firing on it would make
14229
+ * `samplingSeconds` decorative.
14230
+ *
14231
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14232
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14233
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14234
+ * an operator who typed `dog` mean the same thing.
14235
+ */
14236
+ var NcAudioConditionSchema = object({
14237
+ /** Audio macro labels; absent = any sound (level-only rule). */
14238
+ labels: array(string().min(1)).min(1).optional(),
14239
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14240
+ dbThreshold: number().min(-96).max(0).optional(),
14241
+ /** Percentage of the window's samples that must be hits (1–100). */
14242
+ hitPercent: number().int().min(1).max(100).default(60),
14243
+ /** Length of the sampling window in seconds. */
14244
+ samplingSeconds: number().int().min(1).max(300).default(10)
14245
+ });
14246
+ /**
14114
14247
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14115
14248
  *
14116
14249
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14383,7 +14516,33 @@ var NcConditionsSchema = object({
14383
14516
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14384
14517
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14385
14518
  */
14386
- occupancy: NcOccupancyConditionSchema.optional()
14519
+ occupancy: NcOccupancyConditionSchema.optional(),
14520
+ /**
14521
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14522
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14523
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14524
+ * a window that is not full yet, neither filter given). See
14525
+ * {@link NcAudioCondition}.
14526
+ *
14527
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14528
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14529
+ * a detection, a track or a device event (the same fail-closed pairing
14530
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14531
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14532
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14533
+ * classified sample) stays exactly as it was for rules that already use it.
14534
+ *
14535
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14536
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14537
+ * (`camstack/src/data/notification-center.ts`, guarded by
14538
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14539
+ * condition fields it does not know when a rule is saved from the phone.
14540
+ * Publishing an editor for a condition the app cannot round-trip is how an
14541
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14542
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14543
+ * does an audio rule become authorable.
14544
+ */
14545
+ audio: NcAudioConditionSchema.optional()
14387
14546
  });
14388
14547
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14389
14548
  var NcRuleTargetSchema = object({
@@ -14497,6 +14656,73 @@ var NcThrottleSchema = object({
14497
14656
  */
14498
14657
  granularity: NcThrottleGranularitySchema.optional()
14499
14658
  });
14659
+ /**
14660
+ * How long the confirm gate may hold ONE notification, and how big the picture
14661
+ * it judges may be.
14662
+ *
14663
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14664
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14665
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14666
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14667
+ * tokens for pixels the model pools away.
14668
+ */
14669
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14670
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14671
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14672
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14673
+ var NcConfirmExpectSchema = object({
14674
+ op: _enum([
14675
+ ">=",
14676
+ ">",
14677
+ "<=",
14678
+ "<",
14679
+ "=="
14680
+ ]),
14681
+ count: number().int().min(0).max(1e3)
14682
+ });
14683
+ /**
14684
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14685
+ * to ship and says whether it agrees with the rule.
14686
+ *
14687
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14688
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14689
+ * on the operator's phone is not a verdict about this notification.
14690
+ *
14691
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14692
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14693
+ * the default and every fail-open is COUNTED, because a gate that always fails
14694
+ * open looks in the log exactly like a gate that works.
14695
+ *
14696
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14697
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14698
+ * production failures in one day), so the gate reads absent as the constant
14699
+ * above rather than trusting a parse it may never have seen.
14700
+ */
14701
+ var NcConfirmSchema = object({
14702
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14703
+ * same thing, and both mean "deliver exactly as before". */
14704
+ enabled: boolean().default(false),
14705
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14706
+ profileId: string().optional(),
14707
+ /**
14708
+ * The operator's question, in his own words. Absent = a question derived
14709
+ * from the rule (its class and its expectation).
14710
+ *
14711
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14712
+ * banners, signage and plates as instructions if you let them reach the
14713
+ * prompt — proven live — so the authoritative contract stays in the system
14714
+ * turn and only rule-authored words land here.
14715
+ */
14716
+ prompt: string().max(1e3).optional(),
14717
+ /** Fire only when the model's count satisfies this. Absent = the model's
14718
+ * own boolean verdict decides. */
14719
+ expect: NcConfirmExpectSchema.optional(),
14720
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14721
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14722
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14723
+ /** Longest edge the judged image is downscaled to before it is sent. */
14724
+ maxImagePx: number().int().min(64).max(2048).default(448)
14725
+ });
14500
14726
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14501
14727
  var NcRuleInputSchema = object({
14502
14728
  name: string().min(1).max(200),
@@ -14557,7 +14783,13 @@ var NcRuleInputSchema = object({
14557
14783
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14558
14784
  * shape as every other actuation.
14559
14785
  */
14560
- actions: NcRuleActionsSchema.optional()
14786
+ actions: NcRuleActionsSchema.optional(),
14787
+ /**
14788
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14789
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14790
+ * did, and absent is the only way to say that without a migration.
14791
+ */
14792
+ confirm: NcConfirmSchema.optional()
14561
14793
  });
14562
14794
  /**
14563
14795
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14568,7 +14800,37 @@ var NcRuleInputSchema = object({
14568
14800
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14569
14801
  * `updateRule` patch.
14570
14802
  */
14571
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14803
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14804
+ disabledTargetIds: array(string()).optional(),
14805
+ /**
14806
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14807
+ *
14808
+ * It makes the key optional to SUPPLY; the parse still materialises the
14809
+ * default when the key is absent. And `NcRuleStore.update` merges with
14810
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14811
+ * one — which made every partial edit destructive:
14812
+ *
14813
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14814
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14815
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14816
+ *
14817
+ * A rule scoped to one camera and one zone silently became a rule that
14818
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14819
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14820
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14821
+ * within a minute of a two-field patch.
14822
+ *
14823
+ * So every defaulted field is re-declared here WITHOUT its default. The
14824
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14825
+ * conditions remains a real instruction ("clear them") — and only the
14826
+ * absent key is now genuinely absent.
14827
+ */
14828
+ enabled: boolean().optional(),
14829
+ conditions: NcConditionsSchema.optional(),
14830
+ media: NcMediaPolicySchema.optional(),
14831
+ throttle: NcThrottleSchema.optional(),
14832
+ priority: number().int().min(1).max(5).optional()
14833
+ });
14572
14834
  /** A persisted rule. */
14573
14835
  var NcRuleSchema = NcRuleInputSchema.extend({
14574
14836
  id: string(),
@@ -14869,6 +15131,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14869
15131
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14870
15132
  * copy would lie the first time a rule is disabled.
14871
15133
  */
15134
+ /**
15135
+ * Why a device a mode NAMES is nonetheless not armed by it.
15136
+ *
15137
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15138
+ * per-camera notification switch the Notification Center already owns,
15139
+ * `detection-off` is the device's own detection binding being inactive, and
15140
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15141
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15142
+ * with the switches the operator actually used.
15143
+ */
15144
+ var NcAlarmSkipReasonSchema = _enum([
15145
+ "muted",
15146
+ "detection-off",
15147
+ "offline"
15148
+ ]);
15149
+ var NcAlarmSkippedDeviceSchema = object({
15150
+ deviceId: number().int(),
15151
+ reason: NcAlarmSkipReasonSchema
15152
+ });
14872
15153
  var NcAlarmModeCoverageSchema = object({
14873
15154
  mode: AlarmArmModeSchema,
14874
15155
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14876,7 +15157,18 @@ var NcAlarmModeCoverageSchema = object({
14876
15157
  /** At least one covering rule has no device scope, so the mode covers all. */
14877
15158
  allDevices: boolean(),
14878
15159
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14879
- deviceIds: array(number().int())
15160
+ deviceIds: array(number().int()),
15161
+ /**
15162
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15163
+ * excludes it.
15164
+ *
15165
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15166
+ * twelve makes it false in exactly the way nobody notices until an incident.
15167
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15168
+ * still parses as "nothing known to be skipped" rather than failing the whole
15169
+ * alarm tab.
15170
+ */
15171
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14880
15172
  });
14881
15173
  var NcAlarmConfigSchema = object({
14882
15174
  /**
@@ -17675,9 +17967,16 @@ var CameraStatusSchema = object({
17675
17967
  audio: CameraAudioStatusSchema.nullable(),
17676
17968
  recording: CameraRecordingStatusSchema.nullable(),
17677
17969
  /**
17678
- * Per-camera function switches an OPERATOR has turned off
17970
+ * Per-camera functions an OPERATOR has turned off
17679
17971
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17680
17972
  *
17973
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
17974
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
17975
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
17976
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
17977
+ * The badge outlives the control panel: the panel was a convenience, this is
17978
+ * the difference between a camera being off and a camera being dead.
17979
+ *
17681
17980
  * This is the difference between DISABLED and BROKEN. A camera whose
17682
17981
  * `detection` block reports zero fps and whose `switchedOff` contains
17683
17982
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -23186,7 +23485,19 @@ var RecordingManifestSchema = object({
23186
23485
  * profiles/subtrees/locations on this node). */
23187
23486
  var RecordingDeviceUsageSchema = object({
23188
23487
  deviceId: number(),
23189
- usedBytes: number()
23488
+ usedBytes: number(),
23489
+ /**
23490
+ * Start of this camera's OLDEST indexed segment, across every profile and
23491
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23492
+ * only honest answer to "is retention actually holding?" per camera.
23493
+ *
23494
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23495
+ * predates this field omits it entirely, and a hub whose types carry the
23496
+ * field must keep validating that older provider's payload: the framework
23497
+ * (types) and the addon ship on different trains, and the addon is usually
23498
+ * the later of the two.
23499
+ */
23500
+ oldestMs: number().nullable().optional()
23190
23501
  });
23191
23502
  /** Recording storage usage + capacity for one storage location. */
23192
23503
  var RecordingLocationUsageSchema = object({
@@ -23214,6 +23525,57 @@ var RecordingStorageUsageSchema = object({
23214
23525
  locations: array(RecordingLocationUsageSchema)
23215
23526
  });
23216
23527
  /**
23528
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23529
+ *
23530
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23531
+ * is the operator asking for the EXISTING archive to be brought into line with
23532
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23533
+ * location, run FIFO behind the single-flight mover.
23534
+ *
23535
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23536
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23537
+ * (empty on the plan).
23538
+ */
23539
+ var RecordingRebalanceMoveSchema = object({
23540
+ deviceId: number(),
23541
+ profile: string(),
23542
+ fromLocationId: string(),
23543
+ toLocationId: string(),
23544
+ bytes: number(),
23545
+ files: number().int()
23546
+ });
23547
+ /** Why a pile that is out of place is staying there. Every refusal is
23548
+ * reported: a rebalance that silently drops a camera reads exactly like one
23549
+ * that had nothing to do. */
23550
+ var RecordingRebalanceSkipReasonSchema = _enum([
23551
+ "unassigned",
23552
+ "target-not-writable",
23553
+ "below-threshold",
23554
+ "no-headroom"
23555
+ ]);
23556
+ var RecordingRebalanceSkipSchema = object({
23557
+ deviceId: number(),
23558
+ profile: string(),
23559
+ fromLocationId: string(),
23560
+ /** The location the plan wants; null when the camera has no assignment. */
23561
+ toLocationId: string().nullable(),
23562
+ bytes: number(),
23563
+ reason: RecordingRebalanceSkipReasonSchema
23564
+ });
23565
+ var RecordingRebalancePlanSchema = object({
23566
+ moves: array(RecordingRebalanceMoveSchema),
23567
+ skipped: array(RecordingRebalanceSkipSchema),
23568
+ bytesToMove: number(),
23569
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23570
+ jobIds: array(string())
23571
+ });
23572
+ var RecordingRebalanceInputSchema = object({
23573
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23574
+ throttleMbps: number().min(1).max(1e3).optional(),
23575
+ /** Ignore piles smaller than this (default 1 GB). */
23576
+ minMoveGb: number().min(0).optional()
23577
+ });
23578
+ /**
23217
23579
  * Result of locating footage at a wall-clock instant for one device/profile.
23218
23580
  * `segment` carries the covering segment's window; `gap` reports the forward
23219
23581
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23376,9 +23738,24 @@ method(object({
23376
23738
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23377
23739
  kind: "mutation",
23378
23740
  auth: "admin"
23741
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23742
+ kind: "mutation",
23743
+ auth: "admin"
23744
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23745
+ kind: "query",
23746
+ auth: "admin"
23747
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23748
+ kind: "mutation",
23749
+ auth: "admin"
23750
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23751
+ kind: "query",
23752
+ auth: "admin"
23753
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23754
+ kind: "mutation",
23755
+ auth: "admin"
23379
23756
  });
23380
23757
  /**
23381
- * `recordingExport` cap — render a footage time range into a single downloadable
23758
+ * `recording-export` cap — render a footage time range into a single downloadable
23382
23759
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23383
23760
  * bounded lifetime with a durable history, auto-expiry, and optional
23384
23761
  * delete-after-download.
@@ -23393,10 +23770,53 @@ method(object({
23393
23770
  */
23394
23771
  /** Playback-speed multiplier for the render (1 = realtime). */
23395
23772
  var ExportSpeedSchema = number().min(.25).max(32);
23773
+ /**
23774
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23775
+ *
23776
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23777
+ * derives these bounds from things that happened at a TIME (a track's
23778
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23779
+ * every segment present for the range, with each recording GAP removed. The
23780
+ * two agree only on a window that recorded without one interruption, and only
23781
+ * the render side knows the segments, so the translation lives there
23782
+ * (`export-dense-map.ts`, addon-pipeline).
23783
+ *
23784
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23785
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23786
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23787
+ * the video was a uniform timelapse, and the log line reported the five ranges
23788
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23789
+ *
23790
+ * Relative and not absolute epoch, because an absolute epoch would make every
23791
+ * call site responsible for the same subtraction.
23792
+ */
23793
+ var ExportDenseRangeSchema = object({
23794
+ fromSec: number().nonnegative(),
23795
+ toSec: number().nonnegative()
23796
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23797
+ /**
23798
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23799
+ * listed ranges and at the base `everyMs` everywhere else.
23800
+ *
23801
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23802
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23803
+ */
23804
+ var ExportDenseSchema = object({
23805
+ everyMs: number().int().positive(),
23806
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23807
+ });
23396
23808
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23397
23809
  var ExportTimelapseSchema = object({
23398
23810
  everyMs: number().int().positive(),
23399
- outputFps: number().int().min(1).max(60).optional()
23811
+ outputFps: number().int().min(1).max(60).optional(),
23812
+ /** Optional second, FASTER rate over the intervals that matter. */
23813
+ dense: ExportDenseSchema.optional()
23814
+ }).superRefine((v, ctx) => {
23815
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23816
+ code: ZodIssueCode.custom,
23817
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23818
+ path: ["dense", "everyMs"]
23819
+ });
23400
23820
  });
23401
23821
  /**
23402
23822
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23454,6 +23874,19 @@ var ExportDownloadSchema = object({
23454
23874
  url: string(),
23455
23875
  endpoints: array(string())
23456
23876
  });
23877
+ /**
23878
+ * A finished export's bytes, inline.
23879
+ *
23880
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23881
+ * against, so nobody has to infer it from the base64 length.
23882
+ */
23883
+ var ExportBytesSchema = object({
23884
+ base64: string(),
23885
+ contentType: string(),
23886
+ /** Suggested filename, extension included. */
23887
+ name: string(),
23888
+ bytes: number().int().nonnegative()
23889
+ });
23457
23890
  method(object({
23458
23891
  deviceId: number(),
23459
23892
  profile: string(),
@@ -23478,6 +23911,9 @@ method(object({
23478
23911
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23479
23912
  kind: "query",
23480
23913
  auth: "protected"
23914
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
23915
+ kind: "query",
23916
+ auth: "protected"
23481
23917
  });
23482
23918
  /**
23483
23919
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -28671,6 +29107,12 @@ Object.freeze({
28671
29107
  addonId: null,
28672
29108
  access: "create"
28673
29109
  },
29110
+ "recording.cancelRelocateJob": {
29111
+ capName: "recording",
29112
+ capScope: "system",
29113
+ addonId: null,
29114
+ access: "create"
29115
+ },
28674
29116
  "recording.cancelStorageMigrationMove": {
28675
29117
  capName: "recording",
28676
29118
  capScope: "system",
@@ -28725,6 +29167,12 @@ Object.freeze({
28725
29167
  addonId: null,
28726
29168
  access: "view"
28727
29169
  },
29170
+ "recording.listRelocateJobs": {
29171
+ capName: "recording",
29172
+ capScope: "system",
29173
+ addonId: null,
29174
+ access: "view"
29175
+ },
28728
29176
  "recording.locateSegment": {
28729
29177
  capName: "recording",
28730
29178
  capScope: "system",
@@ -28737,6 +29185,12 @@ Object.freeze({
28737
29185
  addonId: null,
28738
29186
  access: "create"
28739
29187
  },
29188
+ "recording.planStorageRebalance": {
29189
+ capName: "recording",
29190
+ capScope: "system",
29191
+ addonId: null,
29192
+ access: "view"
29193
+ },
28740
29194
  "recording.pruneFootage": {
28741
29195
  capName: "recording",
28742
29196
  capScope: "system",
@@ -28761,6 +29215,12 @@ Object.freeze({
28761
29215
  addonId: null,
28762
29216
  access: "create"
28763
29217
  },
29218
+ "recording.relocateFootage": {
29219
+ capName: "recording",
29220
+ capScope: "system",
29221
+ addonId: null,
29222
+ access: "create"
29223
+ },
28764
29224
  "recording.renderClip": {
28765
29225
  capName: "recording",
28766
29226
  capScope: "system",
@@ -28797,38 +29257,50 @@ Object.freeze({
28797
29257
  addonId: null,
28798
29258
  access: "create"
28799
29259
  },
29260
+ "recording.startStorageRebalance": {
29261
+ capName: "recording",
29262
+ capScope: "system",
29263
+ addonId: null,
29264
+ access: "create"
29265
+ },
28800
29266
  "recordingExport.cancelExport": {
28801
- capName: "recordingExport",
29267
+ capName: "recording-export",
28802
29268
  capScope: "system",
28803
29269
  addonId: null,
28804
29270
  access: "create"
28805
29271
  },
28806
29272
  "recordingExport.createExport": {
28807
- capName: "recordingExport",
29273
+ capName: "recording-export",
28808
29274
  capScope: "system",
28809
29275
  addonId: null,
28810
29276
  access: "create"
28811
29277
  },
28812
29278
  "recordingExport.deleteExport": {
28813
- capName: "recordingExport",
29279
+ capName: "recording-export",
28814
29280
  capScope: "system",
28815
29281
  addonId: null,
28816
29282
  access: "delete"
28817
29283
  },
28818
29284
  "recordingExport.getDownloadUrl": {
28819
- capName: "recordingExport",
29285
+ capName: "recording-export",
28820
29286
  capScope: "system",
28821
29287
  addonId: null,
28822
29288
  access: "view"
28823
29289
  },
28824
29290
  "recordingExport.getExport": {
28825
- capName: "recordingExport",
29291
+ capName: "recording-export",
28826
29292
  capScope: "system",
28827
29293
  addonId: null,
28828
29294
  access: "view"
28829
29295
  },
28830
29296
  "recordingExport.listExports": {
28831
- capName: "recordingExport",
29297
+ capName: "recording-export",
29298
+ capScope: "system",
29299
+ addonId: null,
29300
+ access: "view"
29301
+ },
29302
+ "recordingExport.readExportBytes": {
29303
+ capName: "recording-export",
28832
29304
  capScope: "system",
28833
29305
  addonId: null,
28834
29306
  access: "view"
@@ -30412,6 +30884,104 @@ var FramerateField = number().int().min(1).max(60);
30412
30884
  var TargetsField = array(NcRuleTargetSchema).min(1);
30413
30885
  var PriorityField = number().int().min(1).max(5);
30414
30886
  /**
30887
+ * Explicit override of the DENSE sampling cadence, seconds.
30888
+ *
30889
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
30890
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
30891
+ * made that same base 3 s and rendered a person pass as two frames.)
30892
+ *
30893
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
30894
+ * `denseCadenceSec` and played at `framerate` occupies
30895
+ *
30896
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
30897
+ *
30898
+ * 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.
30899
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
30900
+ * and therefore the length of a quiet night, does not move.
30901
+ *
30902
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
30903
+ * the recording has them returns the same frames, requested twice. Must be
30904
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
30905
+ * a uniform video the operator believes is two-rate — and upsert refuses it
30906
+ * rather than letting the export cap reject the render hours after the window.
30907
+ */
30908
+ var DenseCadenceSecField = number().min(.1).max(3600);
30909
+ /**
30910
+ * Minimum seconds of OUTPUT video each detection range must occupy.
30911
+ *
30912
+ * The operator-facing form of the arithmetic above: instead of solving for a
30913
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
30914
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
30915
+ * that range every ~583 ms.
30916
+ *
30917
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
30918
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
30919
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
30920
+ * ranges are sampled denser than they need. Per-range cadences require a cap
30921
+ * schema change and are the tracked follow-up.
30922
+ *
30923
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
30924
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
30925
+ * by real footage, never met by duplicating frames into motion that never
30926
+ * happened.
30927
+ */
30928
+ var MinDwellSecField = number().min(0).max(60);
30929
+ /**
30930
+ * Caption burned into the notification's preview frame.
30931
+ *
30932
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
30933
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
30934
+ * templating dialect for one field would be a second thing to explain.
30935
+ *
30936
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
30937
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
30938
+ * the reason this is not `.min(1)`.
30939
+ */
30940
+ var PreviewTextField = string().max(200);
30941
+ /**
30942
+ * Whether the notification's preview is a STILL or a short animation.
30943
+ *
30944
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
30945
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
30946
+ * night reads better as three seconds of motion than as one frame of it. Both
30947
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
30948
+ * simply applies it to a dozen frames sampled across the render and assembles
30949
+ * them.
30950
+ *
30951
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
30952
+ * seeks and a palette pass, and no rule that never asked for one should start
30953
+ * paying that on the deploy that shipped it.
30954
+ *
30955
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
30956
+ */
30957
+ var PreviewModeField = _enum(["image", "gif"]);
30958
+ /**
30959
+ * Which detection classes the notification reports counts for.
30960
+ *
30961
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
30962
+ * plan — no second query — aggregated per class. Absent or empty means "every
30963
+ * class the window actually contained", which is what an operator who never
30964
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
30965
+ * counts cars all night).
30966
+ *
30967
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
30968
+ * …). An unknown name simply never matches and reports nothing — it is not an
30969
+ * error, because a rule may legitimately name a class this camera's model does
30970
+ * not emit.
30971
+ *
30972
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
30973
+ * - `{{detections}}` — total over the reported classes
30974
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
30975
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
30976
+ * one per class, `count_` + the class name
30977
+ *
30978
+ * With NO custom body template the summary is appended to the derived body, and
30979
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
30980
+ * reads. With a custom template the operator owns every word — nothing is
30981
+ * appended, so `{{detectionSummary}}` is how he asks for it.
30982
+ */
30983
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
30984
+ /**
30415
30985
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30416
30986
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30417
30987
  * here (see the ownership note above).
@@ -30431,9 +31001,30 @@ var TimelapseRuleInputSchema = object({
30431
31001
  cadenceSec: CadenceSecField.default(15),
30432
31002
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30433
31003
  framerate: FramerateField.default(10),
31004
+ /**
31005
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
31006
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
31007
+ * field gets.
31008
+ */
31009
+ denseCadenceSec: DenseCadenceSecField.optional(),
31010
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
31011
+ minDwellSec: MinDwellSecField.optional(),
30434
31012
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30435
31013
  targets: TargetsField,
30436
31014
  template: TimelapseTemplateSchema.optional(),
31015
+ /**
31016
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
31017
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
31018
+ *
31019
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
31020
+ * the notification's title/body, and clearing it (`template: null`) must not
31021
+ * silently clear the caption too.
31022
+ */
31023
+ previewText: PreviewTextField.optional(),
31024
+ /** Still or animation — see {@link PreviewModeField}. */
31025
+ previewMode: PreviewModeField.default("image"),
31026
+ /** Classes the notification counts — see {@link ReportClassesField}. */
31027
+ reportClasses: ReportClassesField.optional(),
30437
31028
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30438
31029
  priority: PriorityField.default(3)
30439
31030
  });
@@ -30444,8 +31035,13 @@ object({
30444
31035
  schedule: NcScheduleSchema.optional(),
30445
31036
  cadenceSec: CadenceSecField.optional(),
30446
31037
  framerate: FramerateField.optional(),
31038
+ denseCadenceSec: DenseCadenceSecField.optional(),
31039
+ minDwellSec: MinDwellSecField.optional(),
30447
31040
  targets: TargetsField.optional(),
30448
31041
  template: TimelapseTemplateSchema.nullable().optional(),
31042
+ previewText: PreviewTextField.optional(),
31043
+ previewMode: PreviewModeField.optional(),
31044
+ reportClasses: ReportClassesField.optional(),
30449
31045
  priority: PriorityField.optional()
30450
31046
  });
30451
31047
  TimelapseRuleInputSchema.extend({
@@ -30457,10 +31053,28 @@ TimelapseRuleInputSchema.extend({
30457
31053
  */
30458
31054
  ownerUserId: string().optional(),
30459
31055
  /**
30460
- * Epoch-ms of the last successful generation the 1-hour re-generation
30461
- * guard's durable state (predecessor parity). Absent = never generated.
31056
+ * Epoch-ms of the NEWEST successful generation across every camera of this
31057
+ * rule. What a UI shows, and the compatibility floor for
31058
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30462
31059
  */
30463
31060
  lastGeneratedAt: number().optional(),
31061
+ /**
31062
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
31063
+ * re-generation guard's real durable state.
31064
+ *
31065
+ * One rule covers several cameras and each renders its own video, so a rule
31066
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
31067
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
31068
+ * already done — and B's night is gone for good, because the window will not
31069
+ * come back.
31070
+ *
31071
+ * ADDITIVE, so the migration is free: a row written before this field simply
31072
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
31073
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
31074
+ * "never generated" would re-render and re-notify every camera of every rule
31075
+ * once, on the deploy that shipped the map.
31076
+ */
31077
+ generatedByDevice: record(string(), number()).optional(),
30464
31078
  /** userId of the caller who created the rule (server-stamped). */
30465
31079
  createdBy: string(),
30466
31080
  createdAt: number(),
@@ -30511,25 +31125,32 @@ object({
30511
31125
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30512
31126
  object({
30513
31127
  /**
30514
- * How long a retained native frame is served before it counts as a miss.
31128
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
31129
+ * detection result.
31130
+ *
31131
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
31132
+ * a time window was never related to the event the pixels were waiting for.
31133
+ * A held frame now lives from delivery until the runner has its `FrameResult`
31134
+ * — at which moment the runner cuts the subject tiles it actually wanted and
31135
+ * releases the frame. The bound exists only so a runner that stops answering
31136
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
30515
31137
  *
30516
- * Must cover the FULL late-crop horizon: detection inference + the
30517
- * cross-process inference-result hop to hub post-analysis + tracking + the
30518
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30519
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30520
- * RAM per busy camera grows linearly with no measured hit-rate gain.
31138
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
31139
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
31140
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
31141
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
31142
+ * `holdOverflow` on the metrics line is what says you need it.
30521
31143
  */
30522
- ttlMs: number().int().min(250).max(1e4),
31144
+ holdFrames: number().int().min(1).max(64),
30523
31145
  /**
30524
31146
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30525
31147
  *
30526
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30527
- * which one is actually binding before reasoning from that. At the shipped
30528
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30529
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30530
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30531
- * change that admits fewer frames buys retention WINDOW at constant RAM
30532
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
31148
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
31149
+ * is what decides how much is held, and the ceiling is the number above which
31150
+ * something is wrong. Before that it was the effective cap at 1024 MB with
31151
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
31152
+ * with the TTL expiring nothing, which is exactly the confusion the hold
31153
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30533
31154
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30534
31155
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30535
31156
  * to replace).
@@ -30555,22 +31176,45 @@ object({
30555
31176
  * there is the signal that some caller names frames outside the inference set
30556
31177
  * and that this must go back to `all`.
30557
31178
  */
30558
- admission: NativeLeaseAdmissionSchema
31179
+ admission: NativeLeaseAdmissionSchema,
31180
+ /**
31181
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
31182
+ * compressed native crops the worker cuts at the moment a frame's detection
31183
+ * result arrives, and keeps long after the frame itself is freed.
31184
+ *
31185
+ * This is the knob that replaced the old retention window, and it buys about
31186
+ * three orders of magnitude more of it: a tile is one subject at native
31187
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
31188
+ * the frame it was cut from. A frame on which nothing was detected costs
31189
+ * nothing at all, which is the real change — the old lease paid per FRAME and
31190
+ * was interrogated per SUBJECT.
31191
+ *
31192
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
31193
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
31194
+ * reproduce that.
31195
+ */
31196
+ tileBudgetMb: number().int().min(0).max(1024)
30559
31197
  });
30560
31198
  /**
30561
- * The values in force when the operator has set nothing — byte-for-byte the
30562
- * constants the decode worker shipped with as env-var defaults, so making these
30563
- * settings changed no behaviour on the day it landed.
31199
+ * The values in force when the operator has set nothing.
31200
+ *
31201
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
31202
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
31203
+ * in the same change that redefines it would make a regression and a retune
31204
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
31205
+ * live traffic.
30564
31206
  */
30565
31207
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30566
- ttlMs: 1200,
31208
+ holdFrames: 8,
30567
31209
  budgetMb: 1024,
30568
31210
  activityMs: 15e3,
31211
+ tileBudgetMb: 64,
30569
31212
  admission: "inferred"
30570
31213
  };
30571
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
31214
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30572
31215
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30573
31216
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
31217
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30574
31218
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30575
31219
  var NOTIFIER_ICONS = {
30576
31220
  telegram: {