@camstack/addon-provider-dreame 0.2.13 → 0.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 +686 -42
  2. package/dist/addon.mjs +686 -42
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -57724,8 +57724,31 @@ var AdoptionJobSchema = object({
57724
57724
  error: string().nullable()
57725
57725
  });
57726
57726
  /**
57727
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
57728
- * pipeline functions an operator thinks in terms of.
57727
+ * Per-camera FUNCTION SWITCHES.
57728
+ *
57729
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
57730
+ *
57731
+ * This file shipped as "the one coherent on/off surface over the pipeline
57732
+ * functions an operator thinks in terms of". The operator's verdict on
57733
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
57734
+ * every function already had a settings page of its own, and a second place to
57735
+ * turn it off is a second place to look. Each switch is going back to its own
57736
+ * component's original options — detection to the detection-pipeline wrapper
57737
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
57738
+ * (which was always first-class; the switch was a veneer over
57739
+ * `recording.setDeviceConfig`), notifications to a notification-center
57740
+ * per-device setting, the two camera planes to their own components.
57741
+ *
57742
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
57743
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
57744
+ * straight from the authorities with no group in the middle. That rule was
57745
+ * never about a control panel.
57746
+ *
57747
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
57748
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
57749
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
57750
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
57751
+ * stop; nothing new may be built on it.
57729
57752
  *
57730
57753
  * ## This file adds no state
57731
57754
  *
@@ -58076,7 +58099,15 @@ var RecordingConfigSchema = object({
58076
58099
  * Each completed/failed run also lands one durable ops-log row on its owning
58077
58100
  * addon surface.
58078
58101
  */
58102
+ /**
58103
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
58104
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
58105
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
58106
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
58107
+ * runs at all.
58108
+ */
58079
58109
  var RelocateJobStateSchema = _enum([
58110
+ "queued",
58080
58111
  "running",
58081
58112
  "done",
58082
58113
  "failed",
@@ -58111,6 +58142,15 @@ var RelocateFootageInputSchema = object({
58111
58142
  /** Limits relocation to the logical profile class. Omit only for the
58112
58143
  * pre-orchestration compatibility path. */
58113
58144
  footageClass: RelocateFootageClassSchema.optional(),
58145
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
58146
+ * is what a whole-disk drain means. The rebalance path always sets it: its
58147
+ * unit is a (camera, profile) pile, not a disk. */
58148
+ deviceId: number().int().optional(),
58149
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
58150
+ * Finer than `footageClass`, which cannot separate high from mid — and the
58151
+ * placement plan assigns those two independently, so a rebalance that could
58152
+ * only say "recordings" would move footage the plan never asked to move. */
58153
+ profiles: array(string()).optional(),
58114
58154
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
58115
58155
  * never allowed to starve live writers. */
58116
58156
  throttleMbps: number().min(1).max(1e3).optional()
@@ -58246,6 +58286,21 @@ var StorageLocationSchema = object({
58246
58286
  nodeId: string().optional(),
58247
58287
  isDefault: boolean().default(false),
58248
58288
  isSystem: boolean().default(false),
58289
+ /**
58290
+ * Operator opt-in: whether consumers that BALANCE across several locations
58291
+ * of a type may write here. Recordings reads it today; event media and
58292
+ * backups are the next consumers, which is why the flag lives on the
58293
+ * location rather than in any one addon's store — nothing has to be
58294
+ * extended to add the next consumer.
58295
+ *
58296
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
58297
+ * flag existed reads back with no flag and keeps working exactly as before;
58298
+ * that is the whole compat story, and it is why no migration ships with it.
58299
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
58300
+ * disk must not silently start writing to it); the default of a type is
58301
+ * always stamped `true`.
58302
+ */
58303
+ enabled: boolean().optional(),
58249
58304
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
58250
58305
  * for node-local locations it can reach) — never persisted, absent when the
58251
58306
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -62815,7 +62870,8 @@ method(object({
62815
62870
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
62816
62871
  /**
62817
62872
  * filesystem-browse — per-node capability for browsing the node's local
62818
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
62873
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
62874
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
62819
62875
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
62820
62876
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
62821
62877
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -64656,6 +64712,13 @@ var MaskGridDimsSchema = object({
64656
64712
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
64657
64713
  * this one field keeps the schema additive — a rule still declares exactly
64658
64714
  * one trigger.
64715
+ *
64716
+ * AUDIO rules add no member here, for the reason occupancy added none: the
64717
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
64718
+ * mirror.ts` fails the build on a member the app cannot render) and every
64719
+ * member costs a release train. A sustained-sound rule is therefore an
64720
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
64721
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
64659
64722
  */
64660
64723
  var NcDeliverySchema = _enum([
64661
64724
  "immediate",
@@ -64670,15 +64733,32 @@ var NcDeliverySchema = _enum([
64670
64733
  * depend on a provider's raw event name or payload shape.
64671
64734
  */
64672
64735
  var NcSystemEventKindSchema = _enum([
64673
- "camera-online",
64674
- "camera-offline",
64736
+ "device-online",
64737
+ "device-offline",
64738
+ "device-disabled",
64739
+ "device-enabled",
64675
64740
  "stream-online",
64676
64741
  "stream-offline",
64677
64742
  "node-online",
64678
64743
  "node-offline",
64679
64744
  "addon-update-available",
64680
- "server-update-available"
64745
+ "server-update-available",
64746
+ "alarm-triggered",
64747
+ "alarm-armed",
64748
+ "alarm-disarmed",
64749
+ "camera-online",
64750
+ "camera-offline",
64751
+ "camera-disabled",
64752
+ "camera-enabled"
64753
+ ]);
64754
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
64755
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
64756
+ "camera-online",
64757
+ "camera-offline",
64758
+ "camera-disabled",
64759
+ "camera-enabled"
64681
64760
  ]);
64761
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
64682
64762
  /**
64683
64763
  * One coherent system-event condition. `kinds` is the required opt-in safety
64684
64764
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -64687,6 +64767,18 @@ var NcSystemEventKindSchema = _enum([
64687
64767
  var NcSystemEventConditionSchema = object({
64688
64768
  kinds: array(NcSystemEventKindSchema).min(1),
64689
64769
  deviceIds: array(number().int()).min(1).optional(),
64770
+ /**
64771
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
64772
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
64773
+ * is what a liveness rule means when nobody said otherwise.
64774
+ *
64775
+ * This is where "only my cameras" is expressed, and it lives on the rule for
64776
+ * one reason: the intake cannot know which devices this household cares
64777
+ * about, and a producer-side filter is one no operator can change. Fails
64778
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
64779
+ * does not carry) matches no `deviceTypes` list.
64780
+ */
64781
+ deviceTypes: array(string().min(1)).min(1).optional(),
64690
64782
  nodeIds: array(string().min(1)).min(1).optional(),
64691
64783
  packageNames: array(string().min(1)).min(1).optional()
64692
64784
  });
@@ -64737,6 +64829,47 @@ var NcOccupancyConditionSchema = object({
64737
64829
  sustainSeconds: number().int().min(0).max(3600).default(15)
64738
64830
  });
64739
64831
  /**
64832
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
64833
+ *
64834
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
64835
+ * reference notifier uses, so an operator moving between them re-uses what
64836
+ * they already know): a rule matches when, over a sampling window of
64837
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
64838
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
64839
+ *
64840
+ * - `dbThreshold` — its level is at or above this many dBFS (see
64841
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
64842
+ * - `labels` — the classifier put at least one of these labels on it.
64843
+ *
64844
+ * Both are OPTIONAL and independent, which is the point of the shape: a
64845
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
64846
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
64847
+ * is given** — a window in which every sample is trivially a hit would fire on
64848
+ * silence, so the engine refuses such a condition rather than notifying on
64849
+ * nothing (the schema cannot express "at least one of" without becoming a
64850
+ * ZodEffects the cap path would have to special-case).
64851
+ *
64852
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
64853
+ * must be FULL before it can match — a window that has been open for two
64854
+ * seconds of its ten is 100% of nothing, and firing on it would make
64855
+ * `samplingSeconds` decorative.
64856
+ *
64857
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
64858
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
64859
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
64860
+ * an operator who typed `dog` mean the same thing.
64861
+ */
64862
+ var NcAudioConditionSchema = object({
64863
+ /** Audio macro labels; absent = any sound (level-only rule). */
64864
+ labels: array(string().min(1)).min(1).optional(),
64865
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
64866
+ dbThreshold: number().min(-96).max(0).optional(),
64867
+ /** Percentage of the window's samples that must be hits (1–100). */
64868
+ hitPercent: number().int().min(1).max(100).default(60),
64869
+ /** Length of the sampling window in seconds. */
64870
+ samplingSeconds: number().int().min(1).max(300).default(10)
64871
+ });
64872
+ /**
64740
64873
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
64741
64874
  *
64742
64875
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -65009,7 +65142,33 @@ var NcConditionsSchema = object({
65009
65142
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
65010
65143
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
65011
65144
  */
65012
- occupancy: NcOccupancyConditionSchema.optional()
65145
+ occupancy: NcOccupancyConditionSchema.optional(),
65146
+ /**
65147
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
65148
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
65149
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
65150
+ * a window that is not full yet, neither filter given). See
65151
+ * {@link NcAudioCondition}.
65152
+ *
65153
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
65154
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
65155
+ * a detection, a track or a device event (the same fail-closed pairing
65156
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
65157
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
65158
+ * (an `immediate` rule naming an `audio-*` class, one notification per
65159
+ * classified sample) stays exactly as it was for rules that already use it.
65160
+ *
65161
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
65162
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
65163
+ * (`camstack/src/data/notification-center.ts`, guarded by
65164
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
65165
+ * condition fields it does not know when a rule is saved from the phone.
65166
+ * Publishing an editor for a condition the app cannot round-trip is how an
65167
+ * operator loses a rule's conditions by opening it — so the descriptor, the
65168
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
65169
+ * does an audio rule become authorable.
65170
+ */
65171
+ audio: NcAudioConditionSchema.optional()
65013
65172
  });
65014
65173
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
65015
65174
  var NcRuleTargetSchema = object({
@@ -65123,6 +65282,73 @@ var NcThrottleSchema = object({
65123
65282
  */
65124
65283
  granularity: NcThrottleGranularitySchema.optional()
65125
65284
  });
65285
+ /**
65286
+ * How long the confirm gate may hold ONE notification, and how big the picture
65287
+ * it judges may be.
65288
+ *
65289
+ * The clamp is the product decision, not a coincidence of the model: p50 was
65290
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
65291
+ * arrives after the visitor has gone is not a notification. 448 px was enough
65292
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
65293
+ * tokens for pixels the model pools away.
65294
+ */
65295
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
65296
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
65297
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
65298
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
65299
+ var NcConfirmExpectSchema = object({
65300
+ op: _enum([
65301
+ ">=",
65302
+ ">",
65303
+ "<=",
65304
+ "<",
65305
+ "=="
65306
+ ]),
65307
+ count: number().int().min(0).max(1e3)
65308
+ });
65309
+ /**
65310
+ * AI CONFIRM — a vision model looks at the picture this notification is about
65311
+ * to ship and says whether it agrees with the rule.
65312
+ *
65313
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
65314
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
65315
+ * on the operator's phone is not a verdict about this notification.
65316
+ *
65317
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
65318
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
65319
+ * the default and every fail-open is COUNTED, because a gate that always fails
65320
+ * open looks in the log exactly like a gate that works.
65321
+ *
65322
+ * Every field is `.optional()` rather than relied on as a Zod default at the
65323
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
65324
+ * production failures in one day), so the gate reads absent as the constant
65325
+ * above rather than trusting a parse it may never have seen.
65326
+ */
65327
+ var NcConfirmSchema = object({
65328
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
65329
+ * same thing, and both mean "deliver exactly as before". */
65330
+ enabled: boolean().default(false),
65331
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
65332
+ profileId: string().optional(),
65333
+ /**
65334
+ * The operator's question, in his own words. Absent = a question derived
65335
+ * from the rule (its class and its expectation).
65336
+ *
65337
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
65338
+ * banners, signage and plates as instructions if you let them reach the
65339
+ * prompt — proven live — so the authoritative contract stays in the system
65340
+ * turn and only rule-authored words land here.
65341
+ */
65342
+ prompt: string().max(1e3).optional(),
65343
+ /** Fire only when the model's count satisfies this. Absent = the model's
65344
+ * own boolean verdict decides. */
65345
+ expect: NcConfirmExpectSchema.optional(),
65346
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
65347
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
65348
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
65349
+ /** Longest edge the judged image is downscaled to before it is sent. */
65350
+ maxImagePx: number().int().min(64).max(2048).default(448)
65351
+ });
65126
65352
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
65127
65353
  var NcRuleInputSchema = object({
65128
65354
  name: string().min(1).max(200),
@@ -65183,7 +65409,13 @@ var NcRuleInputSchema = object({
65183
65409
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
65184
65410
  * shape as every other actuation.
65185
65411
  */
65186
- actions: NcRuleActionsSchema.optional()
65412
+ actions: NcRuleActionsSchema.optional(),
65413
+ /**
65414
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
65415
+ * a rule that predates the gate must keep delivering byte-for-byte as it
65416
+ * did, and absent is the only way to say that without a migration.
65417
+ */
65418
+ confirm: NcConfirmSchema.optional()
65187
65419
  });
65188
65420
  /**
65189
65421
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -65194,7 +65426,37 @@ var NcRuleInputSchema = object({
65194
65426
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
65195
65427
  * `updateRule` patch.
65196
65428
  */
65197
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
65429
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
65430
+ disabledTargetIds: array(string()).optional(),
65431
+ /**
65432
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
65433
+ *
65434
+ * It makes the key optional to SUPPLY; the parse still materialises the
65435
+ * default when the key is absent. And `NcRuleStore.update` merges with
65436
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
65437
+ * one — which made every partial edit destructive:
65438
+ *
65439
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
65440
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
65441
+ * setEnabled(ruleId, false) → conditions reset to `{}`
65442
+ *
65443
+ * A rule scoped to one camera and one zone silently became a rule that
65444
+ * matches EVERY event on EVERY camera, and lost its `media` policy
65445
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
65446
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
65447
+ * within a minute of a two-field patch.
65448
+ *
65449
+ * So every defaulted field is re-declared here WITHOUT its default. The
65450
+ * inner defaults still apply when the caller DOES send the key — `{}` for
65451
+ * conditions remains a real instruction ("clear them") — and only the
65452
+ * absent key is now genuinely absent.
65453
+ */
65454
+ enabled: boolean().optional(),
65455
+ conditions: NcConditionsSchema.optional(),
65456
+ media: NcMediaPolicySchema.optional(),
65457
+ throttle: NcThrottleSchema.optional(),
65458
+ priority: number().int().min(1).max(5).optional()
65459
+ });
65198
65460
  /** A persisted rule. */
65199
65461
  var NcRuleSchema = NcRuleInputSchema.extend({
65200
65462
  id: string(),
@@ -65495,6 +65757,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
65495
65757
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
65496
65758
  * copy would lie the first time a rule is disabled.
65497
65759
  */
65760
+ /**
65761
+ * Why a device a mode NAMES is nonetheless not armed by it.
65762
+ *
65763
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
65764
+ * per-camera notification switch the Notification Center already owns,
65765
+ * `detection-off` is the device's own detection binding being inactive, and
65766
+ * `offline` is the device manager's liveness. A fourth reason would mean a
65767
+ * fourth authority, and inventing one here is how a panel starts disagreeing
65768
+ * with the switches the operator actually used.
65769
+ */
65770
+ var NcAlarmSkipReasonSchema = _enum([
65771
+ "muted",
65772
+ "detection-off",
65773
+ "offline"
65774
+ ]);
65775
+ var NcAlarmSkippedDeviceSchema = object({
65776
+ deviceId: number().int(),
65777
+ reason: NcAlarmSkipReasonSchema
65778
+ });
65498
65779
  var NcAlarmModeCoverageSchema = object({
65499
65780
  mode: AlarmArmModeSchema,
65500
65781
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -65502,7 +65783,18 @@ var NcAlarmModeCoverageSchema = object({
65502
65783
  /** At least one covering rule has no device scope, so the mode covers all. */
65503
65784
  allDevices: boolean(),
65504
65785
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
65505
- deviceIds: array(number().int())
65786
+ deviceIds: array(number().int()),
65787
+ /**
65788
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
65789
+ * excludes it.
65790
+ *
65791
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
65792
+ * twelve makes it false in exactly the way nobody notices until an incident.
65793
+ * Defaulted to `[]` so a coverage answer computed before this field existed
65794
+ * still parses as "nothing known to be skipped" rather than failing the whole
65795
+ * alarm tab.
65796
+ */
65797
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
65506
65798
  });
65507
65799
  var NcAlarmConfigSchema = object({
65508
65800
  /**
@@ -68334,9 +68626,16 @@ var CameraStatusSchema = object({
68334
68626
  audio: CameraAudioStatusSchema.nullable(),
68335
68627
  recording: CameraRecordingStatusSchema.nullable(),
68336
68628
  /**
68337
- * Per-camera function switches an OPERATOR has turned off
68629
+ * Per-camera functions an OPERATOR has turned off
68338
68630
  * ([D61](../../../../docs/decisions/adr-0067.md)).
68339
68631
  *
68632
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
68633
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
68634
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
68635
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
68636
+ * The badge outlives the control panel: the panel was a convenience, this is
68637
+ * the difference between a camera being off and a camera being dead.
68638
+ *
68340
68639
  * This is the difference between DISABLED and BROKEN. A camera whose
68341
68640
  * `detection` block reports zero fps and whose `switchedOff` contains
68342
68641
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -75103,7 +75402,19 @@ var RecordingManifestSchema = object({
75103
75402
  * profiles/subtrees/locations on this node). */
75104
75403
  var RecordingDeviceUsageSchema = object({
75105
75404
  deviceId: number(),
75106
- usedBytes: number()
75405
+ usedBytes: number(),
75406
+ /**
75407
+ * Start of this camera's OLDEST indexed segment, across every profile and
75408
+ * location — the "Oldest footage" column in Recordings → Storage, and the
75409
+ * only honest answer to "is retention actually holding?" per camera.
75410
+ *
75411
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
75412
+ * predates this field omits it entirely, and a hub whose types carry the
75413
+ * field must keep validating that older provider's payload: the framework
75414
+ * (types) and the addon ship on different trains, and the addon is usually
75415
+ * the later of the two.
75416
+ */
75417
+ oldestMs: number().nullable().optional()
75107
75418
  });
75108
75419
  /** Recording storage usage + capacity for one storage location. */
75109
75420
  var RecordingLocationUsageSchema = object({
@@ -75131,6 +75442,57 @@ var RecordingStorageUsageSchema = object({
75131
75442
  locations: array(RecordingLocationUsageSchema)
75132
75443
  });
75133
75444
  /**
75445
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
75446
+ *
75447
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
75448
+ * is the operator asking for the EXISTING archive to be brought into line with
75449
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
75450
+ * location, run FIFO behind the single-flight mover.
75451
+ *
75452
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
75453
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
75454
+ * (empty on the plan).
75455
+ */
75456
+ var RecordingRebalanceMoveSchema = object({
75457
+ deviceId: number(),
75458
+ profile: string(),
75459
+ fromLocationId: string(),
75460
+ toLocationId: string(),
75461
+ bytes: number(),
75462
+ files: number().int()
75463
+ });
75464
+ /** Why a pile that is out of place is staying there. Every refusal is
75465
+ * reported: a rebalance that silently drops a camera reads exactly like one
75466
+ * that had nothing to do. */
75467
+ var RecordingRebalanceSkipReasonSchema = _enum([
75468
+ "unassigned",
75469
+ "target-not-writable",
75470
+ "below-threshold",
75471
+ "no-headroom"
75472
+ ]);
75473
+ var RecordingRebalanceSkipSchema = object({
75474
+ deviceId: number(),
75475
+ profile: string(),
75476
+ fromLocationId: string(),
75477
+ /** The location the plan wants; null when the camera has no assignment. */
75478
+ toLocationId: string().nullable(),
75479
+ bytes: number(),
75480
+ reason: RecordingRebalanceSkipReasonSchema
75481
+ });
75482
+ var RecordingRebalancePlanSchema = object({
75483
+ moves: array(RecordingRebalanceMoveSchema),
75484
+ skipped: array(RecordingRebalanceSkipSchema),
75485
+ bytesToMove: number(),
75486
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
75487
+ jobIds: array(string())
75488
+ });
75489
+ var RecordingRebalanceInputSchema = object({
75490
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
75491
+ throttleMbps: number().min(1).max(1e3).optional(),
75492
+ /** Ignore piles smaller than this (default 1 GB). */
75493
+ minMoveGb: number().min(0).optional()
75494
+ });
75495
+ /**
75134
75496
  * Result of locating footage at a wall-clock instant for one device/profile.
75135
75497
  * `segment` carries the covering segment's window; `gap` reports the forward
75136
75498
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -75293,9 +75655,24 @@ method(object({
75293
75655
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
75294
75656
  kind: "mutation",
75295
75657
  auth: "admin"
75658
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
75659
+ kind: "mutation",
75660
+ auth: "admin"
75661
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
75662
+ kind: "query",
75663
+ auth: "admin"
75664
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
75665
+ kind: "mutation",
75666
+ auth: "admin"
75667
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
75668
+ kind: "query",
75669
+ auth: "admin"
75670
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
75671
+ kind: "mutation",
75672
+ auth: "admin"
75296
75673
  });
75297
75674
  /**
75298
- * `recordingExport` cap — render a footage time range into a single downloadable
75675
+ * `recording-export` cap — render a footage time range into a single downloadable
75299
75676
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
75300
75677
  * bounded lifetime with a durable history, auto-expiry, and optional
75301
75678
  * delete-after-download.
@@ -75310,10 +75687,53 @@ method(object({
75310
75687
  */
75311
75688
  /** Playback-speed multiplier for the render (1 = realtime). */
75312
75689
  var ExportSpeedSchema = number().min(.25).max(32);
75690
+ /**
75691
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
75692
+ *
75693
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
75694
+ * derives these bounds from things that happened at a TIME (a track's
75695
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
75696
+ * every segment present for the range, with each recording GAP removed. The
75697
+ * two agree only on a window that recorded without one interruption, and only
75698
+ * the render side knows the segments, so the translation lives there
75699
+ * (`export-dense-map.ts`, addon-pipeline).
75700
+ *
75701
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
75702
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
75703
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
75704
+ * the video was a uniform timelapse, and the log line reported the five ranges
75705
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
75706
+ *
75707
+ * Relative and not absolute epoch, because an absolute epoch would make every
75708
+ * call site responsible for the same subtraction.
75709
+ */
75710
+ var ExportDenseRangeSchema = object({
75711
+ fromSec: number().nonnegative(),
75712
+ toSec: number().nonnegative()
75713
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
75714
+ /**
75715
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
75716
+ * listed ranges and at the base `everyMs` everywhere else.
75717
+ *
75718
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
75719
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
75720
+ */
75721
+ var ExportDenseSchema = object({
75722
+ everyMs: number().int().positive(),
75723
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
75724
+ });
75313
75725
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
75314
75726
  var ExportTimelapseSchema = object({
75315
75727
  everyMs: number().int().positive(),
75316
- outputFps: number().int().min(1).max(60).optional()
75728
+ outputFps: number().int().min(1).max(60).optional(),
75729
+ /** Optional second, FASTER rate over the intervals that matter. */
75730
+ dense: ExportDenseSchema.optional()
75731
+ }).superRefine((v, ctx) => {
75732
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
75733
+ code: ZodIssueCode.custom,
75734
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
75735
+ path: ["dense", "everyMs"]
75736
+ });
75317
75737
  });
75318
75738
  /**
75319
75739
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -75371,6 +75791,19 @@ var ExportDownloadSchema = object({
75371
75791
  url: string(),
75372
75792
  endpoints: array(string())
75373
75793
  });
75794
+ /**
75795
+ * A finished export's bytes, inline.
75796
+ *
75797
+ * `bytes` is the DECODED length — the number the caller bounds and logs
75798
+ * against, so nobody has to infer it from the base64 length.
75799
+ */
75800
+ var ExportBytesSchema = object({
75801
+ base64: string(),
75802
+ contentType: string(),
75803
+ /** Suggested filename, extension included. */
75804
+ name: string(),
75805
+ bytes: number().int().nonnegative()
75806
+ });
75374
75807
  method(object({
75375
75808
  deviceId: number(),
75376
75809
  profile: string(),
@@ -75395,6 +75828,9 @@ method(object({
75395
75828
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
75396
75829
  kind: "query",
75397
75830
  auth: "protected"
75831
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
75832
+ kind: "query",
75833
+ auth: "protected"
75398
75834
  });
75399
75835
  /**
75400
75836
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -82072,6 +82508,12 @@ Object.freeze({
82072
82508
  addonId: null,
82073
82509
  access: "create"
82074
82510
  },
82511
+ "recording.cancelRelocateJob": {
82512
+ capName: "recording",
82513
+ capScope: "system",
82514
+ addonId: null,
82515
+ access: "create"
82516
+ },
82075
82517
  "recording.cancelStorageMigrationMove": {
82076
82518
  capName: "recording",
82077
82519
  capScope: "system",
@@ -82126,6 +82568,12 @@ Object.freeze({
82126
82568
  addonId: null,
82127
82569
  access: "view"
82128
82570
  },
82571
+ "recording.listRelocateJobs": {
82572
+ capName: "recording",
82573
+ capScope: "system",
82574
+ addonId: null,
82575
+ access: "view"
82576
+ },
82129
82577
  "recording.locateSegment": {
82130
82578
  capName: "recording",
82131
82579
  capScope: "system",
@@ -82138,6 +82586,12 @@ Object.freeze({
82138
82586
  addonId: null,
82139
82587
  access: "create"
82140
82588
  },
82589
+ "recording.planStorageRebalance": {
82590
+ capName: "recording",
82591
+ capScope: "system",
82592
+ addonId: null,
82593
+ access: "view"
82594
+ },
82141
82595
  "recording.pruneFootage": {
82142
82596
  capName: "recording",
82143
82597
  capScope: "system",
@@ -82162,6 +82616,12 @@ Object.freeze({
82162
82616
  addonId: null,
82163
82617
  access: "create"
82164
82618
  },
82619
+ "recording.relocateFootage": {
82620
+ capName: "recording",
82621
+ capScope: "system",
82622
+ addonId: null,
82623
+ access: "create"
82624
+ },
82165
82625
  "recording.renderClip": {
82166
82626
  capName: "recording",
82167
82627
  capScope: "system",
@@ -82198,38 +82658,50 @@ Object.freeze({
82198
82658
  addonId: null,
82199
82659
  access: "create"
82200
82660
  },
82661
+ "recording.startStorageRebalance": {
82662
+ capName: "recording",
82663
+ capScope: "system",
82664
+ addonId: null,
82665
+ access: "create"
82666
+ },
82201
82667
  "recordingExport.cancelExport": {
82202
- capName: "recordingExport",
82668
+ capName: "recording-export",
82203
82669
  capScope: "system",
82204
82670
  addonId: null,
82205
82671
  access: "create"
82206
82672
  },
82207
82673
  "recordingExport.createExport": {
82208
- capName: "recordingExport",
82674
+ capName: "recording-export",
82209
82675
  capScope: "system",
82210
82676
  addonId: null,
82211
82677
  access: "create"
82212
82678
  },
82213
82679
  "recordingExport.deleteExport": {
82214
- capName: "recordingExport",
82680
+ capName: "recording-export",
82215
82681
  capScope: "system",
82216
82682
  addonId: null,
82217
82683
  access: "delete"
82218
82684
  },
82219
82685
  "recordingExport.getDownloadUrl": {
82220
- capName: "recordingExport",
82686
+ capName: "recording-export",
82221
82687
  capScope: "system",
82222
82688
  addonId: null,
82223
82689
  access: "view"
82224
82690
  },
82225
82691
  "recordingExport.getExport": {
82226
- capName: "recordingExport",
82692
+ capName: "recording-export",
82227
82693
  capScope: "system",
82228
82694
  addonId: null,
82229
82695
  access: "view"
82230
82696
  },
82231
82697
  "recordingExport.listExports": {
82232
- capName: "recordingExport",
82698
+ capName: "recording-export",
82699
+ capScope: "system",
82700
+ addonId: null,
82701
+ access: "view"
82702
+ },
82703
+ "recordingExport.readExportBytes": {
82704
+ capName: "recording-export",
82233
82705
  capScope: "system",
82234
82706
  addonId: null,
82235
82707
  access: "view"
@@ -83606,6 +84078,104 @@ var FramerateField = number().int().min(1).max(60);
83606
84078
  var TargetsField = array(NcRuleTargetSchema).min(1);
83607
84079
  var PriorityField = number().int().min(1).max(5);
83608
84080
  /**
84081
+ * Explicit override of the DENSE sampling cadence, seconds.
84082
+ *
84083
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
84084
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
84085
+ * made that same base 3 s and rendered a person pass as two frames.)
84086
+ *
84087
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
84088
+ * `denseCadenceSec` and played at `framerate` occupies
84089
+ *
84090
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
84091
+ *
84092
+ * 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.
84093
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
84094
+ * and therefore the length of a quiet night, does not move.
84095
+ *
84096
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
84097
+ * the recording has them returns the same frames, requested twice. Must be
84098
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
84099
+ * a uniform video the operator believes is two-rate — and upsert refuses it
84100
+ * rather than letting the export cap reject the render hours after the window.
84101
+ */
84102
+ var DenseCadenceSecField = number().min(.1).max(3600);
84103
+ /**
84104
+ * Minimum seconds of OUTPUT video each detection range must occupy.
84105
+ *
84106
+ * The operator-facing form of the arithmetic above: instead of solving for a
84107
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
84108
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
84109
+ * that range every ~583 ms.
84110
+ *
84111
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
84112
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
84113
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
84114
+ * ranges are sampled denser than they need. Per-range cadences require a cap
84115
+ * schema change and are the tracked follow-up.
84116
+ *
84117
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
84118
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
84119
+ * by real footage, never met by duplicating frames into motion that never
84120
+ * happened.
84121
+ */
84122
+ var MinDwellSecField = number().min(0).max(60);
84123
+ /**
84124
+ * Caption burned into the notification's preview frame.
84125
+ *
84126
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
84127
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
84128
+ * templating dialect for one field would be a second thing to explain.
84129
+ *
84130
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
84131
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
84132
+ * the reason this is not `.min(1)`.
84133
+ */
84134
+ var PreviewTextField = string().max(200);
84135
+ /**
84136
+ * Whether the notification's preview is a STILL or a short animation.
84137
+ *
84138
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
84139
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
84140
+ * night reads better as three seconds of motion than as one frame of it. Both
84141
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
84142
+ * simply applies it to a dozen frames sampled across the render and assembles
84143
+ * them.
84144
+ *
84145
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
84146
+ * seeks and a palette pass, and no rule that never asked for one should start
84147
+ * paying that on the deploy that shipped it.
84148
+ *
84149
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
84150
+ */
84151
+ var PreviewModeField = _enum(["image", "gif"]);
84152
+ /**
84153
+ * Which detection classes the notification reports counts for.
84154
+ *
84155
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
84156
+ * plan — no second query — aggregated per class. Absent or empty means "every
84157
+ * class the window actually contained", which is what an operator who never
84158
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
84159
+ * counts cars all night).
84160
+ *
84161
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
84162
+ * …). An unknown name simply never matches and reports nothing — it is not an
84163
+ * error, because a rule may legitimately name a class this camera's model does
84164
+ * not emit.
84165
+ *
84166
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
84167
+ * - `{{detections}}` — total over the reported classes
84168
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
84169
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
84170
+ * one per class, `count_` + the class name
84171
+ *
84172
+ * With NO custom body template the summary is appended to the derived body, and
84173
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
84174
+ * reads. With a custom template the operator owns every word — nothing is
84175
+ * appended, so `{{detectionSummary}}` is how he asks for it.
84176
+ */
84177
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
84178
+ /**
83609
84179
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
83610
84180
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
83611
84181
  * here (see the ownership note above).
@@ -83625,9 +84195,30 @@ var TimelapseRuleInputSchema = object({
83625
84195
  cadenceSec: CadenceSecField.default(15),
83626
84196
  /** Output frames per second of the assembled mp4 (predecessor parity). */
83627
84197
  framerate: FramerateField.default(10),
84198
+ /**
84199
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
84200
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
84201
+ * field gets.
84202
+ */
84203
+ denseCadenceSec: DenseCadenceSecField.optional(),
84204
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
84205
+ minDwellSec: MinDwellSecField.optional(),
83628
84206
  /** `notification-output` targets the finished video/thumbnail is sent to. */
83629
84207
  targets: TargetsField,
83630
84208
  template: TimelapseTemplateSchema.optional(),
84209
+ /**
84210
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
84211
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
84212
+ *
84213
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
84214
+ * the notification's title/body, and clearing it (`template: null`) must not
84215
+ * silently clear the caption too.
84216
+ */
84217
+ previewText: PreviewTextField.optional(),
84218
+ /** Still or animation — see {@link PreviewModeField}. */
84219
+ previewMode: PreviewModeField.default("image"),
84220
+ /** Classes the notification counts — see {@link ReportClassesField}. */
84221
+ reportClasses: ReportClassesField.optional(),
83631
84222
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
83632
84223
  priority: PriorityField.default(3)
83633
84224
  });
@@ -83638,8 +84229,13 @@ object({
83638
84229
  schedule: NcScheduleSchema.optional(),
83639
84230
  cadenceSec: CadenceSecField.optional(),
83640
84231
  framerate: FramerateField.optional(),
84232
+ denseCadenceSec: DenseCadenceSecField.optional(),
84233
+ minDwellSec: MinDwellSecField.optional(),
83641
84234
  targets: TargetsField.optional(),
83642
84235
  template: TimelapseTemplateSchema.nullable().optional(),
84236
+ previewText: PreviewTextField.optional(),
84237
+ previewMode: PreviewModeField.optional(),
84238
+ reportClasses: ReportClassesField.optional(),
83643
84239
  priority: PriorityField.optional()
83644
84240
  });
83645
84241
  TimelapseRuleInputSchema.extend({
@@ -83651,10 +84247,28 @@ TimelapseRuleInputSchema.extend({
83651
84247
  */
83652
84248
  ownerUserId: string().optional(),
83653
84249
  /**
83654
- * Epoch-ms of the last successful generation the 1-hour re-generation
83655
- * guard's durable state (predecessor parity). Absent = never generated.
84250
+ * Epoch-ms of the NEWEST successful generation across every camera of this
84251
+ * rule. What a UI shows, and the compatibility floor for
84252
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
83656
84253
  */
83657
84254
  lastGeneratedAt: number().optional(),
84255
+ /**
84256
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
84257
+ * re-generation guard's real durable state.
84258
+ *
84259
+ * One rule covers several cameras and each renders its own video, so a rule
84260
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
84261
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
84262
+ * already done — and B's night is gone for good, because the window will not
84263
+ * come back.
84264
+ *
84265
+ * ADDITIVE, so the migration is free: a row written before this field simply
84266
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
84267
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
84268
+ * "never generated" would re-render and re-notify every camera of every rule
84269
+ * once, on the deploy that shipped the map.
84270
+ */
84271
+ generatedByDevice: record(string(), number()).optional(),
83658
84272
  /** userId of the caller who created the rule (server-stamped). */
83659
84273
  createdBy: string(),
83660
84274
  createdAt: number(),
@@ -83705,25 +84319,32 @@ object({
83705
84319
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
83706
84320
  object({
83707
84321
  /**
83708
- * How long a retained native frame is served before it counts as a miss.
84322
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
84323
+ * detection result.
83709
84324
  *
83710
- * Must cover the FULL late-crop horizon: detection inference + the
83711
- * cross-process inference-result hop to hub post-analysis + tracking + the
83712
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
83713
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
83714
- * RAM per busy camera grows linearly with no measured hit-rate gain.
84325
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
84326
+ * a time window was never related to the event the pixels were waiting for.
84327
+ * A held frame now lives from delivery until the runner has its `FrameResult`
84328
+ * at which moment the runner cuts the subject tiles it actually wanted and
84329
+ * releases the frame. The bound exists only so a runner that stops answering
84330
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
84331
+ *
84332
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
84333
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
84334
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
84335
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
84336
+ * `holdOverflow` on the metrics line is what says you need it.
83715
84337
  */
83716
- ttlMs: number().int().min(250).max(1e4),
84338
+ holdFrames: number().int().min(1).max(64),
83717
84339
  /**
83718
84340
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
83719
84341
  *
83720
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
83721
- * which one is actually binding before reasoning from that. At the shipped
83722
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
83723
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
83724
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
83725
- * change that admits fewer frames buys retention WINDOW at constant RAM
83726
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
84342
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
84343
+ * is what decides how much is held, and the ceiling is the number above which
84344
+ * something is wrong. Before that it was the effective cap at 1024 MB with
84345
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
84346
+ * with the TTL expiring nothing, which is exactly the confusion the hold
84347
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
83727
84348
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
83728
84349
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
83729
84350
  * to replace).
@@ -83749,22 +84370,45 @@ object({
83749
84370
  * there is the signal that some caller names frames outside the inference set
83750
84371
  * and that this must go back to `all`.
83751
84372
  */
83752
- admission: NativeLeaseAdmissionSchema
84373
+ admission: NativeLeaseAdmissionSchema,
84374
+ /**
84375
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
84376
+ * compressed native crops the worker cuts at the moment a frame's detection
84377
+ * result arrives, and keeps long after the frame itself is freed.
84378
+ *
84379
+ * This is the knob that replaced the old retention window, and it buys about
84380
+ * three orders of magnitude more of it: a tile is one subject at native
84381
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
84382
+ * the frame it was cut from. A frame on which nothing was detected costs
84383
+ * nothing at all, which is the real change — the old lease paid per FRAME and
84384
+ * was interrogated per SUBJECT.
84385
+ *
84386
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
84387
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
84388
+ * reproduce that.
84389
+ */
84390
+ tileBudgetMb: number().int().min(0).max(1024)
83753
84391
  });
83754
84392
  /**
83755
- * The values in force when the operator has set nothing — byte-for-byte the
83756
- * constants the decode worker shipped with as env-var defaults, so making these
83757
- * settings changed no behaviour on the day it landed.
84393
+ * The values in force when the operator has set nothing.
84394
+ *
84395
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
84396
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
84397
+ * in the same change that redefines it would make a regression and a retune
84398
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
84399
+ * live traffic.
83758
84400
  */
83759
84401
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
83760
- ttlMs: 1200,
84402
+ holdFrames: 8,
83761
84403
  budgetMb: 1024,
83762
84404
  activityMs: 15e3,
84405
+ tileBudgetMb: 64,
83763
84406
  admission: "inferred"
83764
84407
  };
83765
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
84408
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
83766
84409
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
83767
84410
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
84411
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
83768
84412
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
83769
84413
  //#endregion
83770
84414
  //#region src/config.ts