@camstack/addon-provider-tuya 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
@@ -8039,8 +8039,31 @@ var AdoptionJobSchema = object({
8039
8039
  error: string().nullable()
8040
8040
  });
8041
8041
  /**
8042
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
8043
- * pipeline functions an operator thinks in terms of.
8042
+ * Per-camera FUNCTION SWITCHES.
8043
+ *
8044
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
8045
+ *
8046
+ * This file shipped as "the one coherent on/off surface over the pipeline
8047
+ * functions an operator thinks in terms of". The operator's verdict on
8048
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
8049
+ * every function already had a settings page of its own, and a second place to
8050
+ * turn it off is a second place to look. Each switch is going back to its own
8051
+ * component's original options — detection to the detection-pipeline wrapper
8052
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
8053
+ * (which was always first-class; the switch was a veneer over
8054
+ * `recording.setDeviceConfig`), notifications to a notification-center
8055
+ * per-device setting, the two camera planes to their own components.
8056
+ *
8057
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
8058
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
8059
+ * straight from the authorities with no group in the middle. That rule was
8060
+ * never about a control panel.
8061
+ *
8062
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
8063
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
8064
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
8065
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
8066
+ * stop; nothing new may be built on it.
8044
8067
  *
8045
8068
  * ## This file adds no state
8046
8069
  *
@@ -8391,7 +8414,15 @@ var RecordingConfigSchema = object({
8391
8414
  * Each completed/failed run also lands one durable ops-log row on its owning
8392
8415
  * addon surface.
8393
8416
  */
8417
+ /**
8418
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
8419
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
8420
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
8421
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
8422
+ * runs at all.
8423
+ */
8394
8424
  var RelocateJobStateSchema = _enum([
8425
+ "queued",
8395
8426
  "running",
8396
8427
  "done",
8397
8428
  "failed",
@@ -8426,6 +8457,15 @@ var RelocateFootageInputSchema = object({
8426
8457
  /** Limits relocation to the logical profile class. Omit only for the
8427
8458
  * pre-orchestration compatibility path. */
8428
8459
  footageClass: RelocateFootageClassSchema.optional(),
8460
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
8461
+ * is what a whole-disk drain means. The rebalance path always sets it: its
8462
+ * unit is a (camera, profile) pile, not a disk. */
8463
+ deviceId: number().int().optional(),
8464
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
8465
+ * Finer than `footageClass`, which cannot separate high from mid — and the
8466
+ * placement plan assigns those two independently, so a rebalance that could
8467
+ * only say "recordings" would move footage the plan never asked to move. */
8468
+ profiles: array(string()).optional(),
8429
8469
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
8430
8470
  * never allowed to starve live writers. */
8431
8471
  throttleMbps: number().min(1).max(1e3).optional()
@@ -8561,6 +8601,21 @@ var StorageLocationSchema = object({
8561
8601
  nodeId: string().optional(),
8562
8602
  isDefault: boolean().default(false),
8563
8603
  isSystem: boolean().default(false),
8604
+ /**
8605
+ * Operator opt-in: whether consumers that BALANCE across several locations
8606
+ * of a type may write here. Recordings reads it today; event media and
8607
+ * backups are the next consumers, which is why the flag lives on the
8608
+ * location rather than in any one addon's store — nothing has to be
8609
+ * extended to add the next consumer.
8610
+ *
8611
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
8612
+ * flag existed reads back with no flag and keeps working exactly as before;
8613
+ * that is the whole compat story, and it is why no migration ships with it.
8614
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
8615
+ * disk must not silently start writing to it); the default of a type is
8616
+ * always stamped `true`.
8617
+ */
8618
+ enabled: boolean().optional(),
8564
8619
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
8565
8620
  * for node-local locations it can reach) — never persisted, absent when the
8566
8621
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -13130,7 +13185,8 @@ method(object({
13130
13185
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
13131
13186
  /**
13132
13187
  * filesystem-browse — per-node capability for browsing the node's local
13133
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
13188
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13189
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
13134
13190
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
13135
13191
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
13136
13192
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14971,6 +15027,13 @@ var MaskGridDimsSchema = object({
14971
15027
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14972
15028
  * this one field keeps the schema additive — a rule still declares exactly
14973
15029
  * one trigger.
15030
+ *
15031
+ * AUDIO rules add no member here, for the reason occupancy added none: the
15032
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
15033
+ * mirror.ts` fails the build on a member the app cannot render) and every
15034
+ * member costs a release train. A sustained-sound rule is therefore an
15035
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
15036
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14974
15037
  */
14975
15038
  var NcDeliverySchema = _enum([
14976
15039
  "immediate",
@@ -14985,15 +15048,32 @@ var NcDeliverySchema = _enum([
14985
15048
  * depend on a provider's raw event name or payload shape.
14986
15049
  */
14987
15050
  var NcSystemEventKindSchema = _enum([
14988
- "camera-online",
14989
- "camera-offline",
15051
+ "device-online",
15052
+ "device-offline",
15053
+ "device-disabled",
15054
+ "device-enabled",
14990
15055
  "stream-online",
14991
15056
  "stream-offline",
14992
15057
  "node-online",
14993
15058
  "node-offline",
14994
15059
  "addon-update-available",
14995
- "server-update-available"
15060
+ "server-update-available",
15061
+ "alarm-triggered",
15062
+ "alarm-armed",
15063
+ "alarm-disarmed",
15064
+ "camera-online",
15065
+ "camera-offline",
15066
+ "camera-disabled",
15067
+ "camera-enabled"
15068
+ ]);
15069
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
15070
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
15071
+ "camera-online",
15072
+ "camera-offline",
15073
+ "camera-disabled",
15074
+ "camera-enabled"
14996
15075
  ]);
15076
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14997
15077
  /**
14998
15078
  * One coherent system-event condition. `kinds` is the required opt-in safety
14999
15079
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -15002,6 +15082,18 @@ var NcSystemEventKindSchema = _enum([
15002
15082
  var NcSystemEventConditionSchema = object({
15003
15083
  kinds: array(NcSystemEventKindSchema).min(1),
15004
15084
  deviceIds: array(number().int()).min(1).optional(),
15085
+ /**
15086
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
15087
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
15088
+ * is what a liveness rule means when nobody said otherwise.
15089
+ *
15090
+ * This is where "only my cameras" is expressed, and it lives on the rule for
15091
+ * one reason: the intake cannot know which devices this household cares
15092
+ * about, and a producer-side filter is one no operator can change. Fails
15093
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
15094
+ * does not carry) matches no `deviceTypes` list.
15095
+ */
15096
+ deviceTypes: array(string().min(1)).min(1).optional(),
15005
15097
  nodeIds: array(string().min(1)).min(1).optional(),
15006
15098
  packageNames: array(string().min(1)).min(1).optional()
15007
15099
  });
@@ -15052,6 +15144,47 @@ var NcOccupancyConditionSchema = object({
15052
15144
  sustainSeconds: number().int().min(0).max(3600).default(15)
15053
15145
  });
15054
15146
  /**
15147
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
15148
+ *
15149
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
15150
+ * reference notifier uses, so an operator moving between them re-uses what
15151
+ * they already know): a rule matches when, over a sampling window of
15152
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
15153
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
15154
+ *
15155
+ * - `dbThreshold` — its level is at or above this many dBFS (see
15156
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
15157
+ * - `labels` — the classifier put at least one of these labels on it.
15158
+ *
15159
+ * Both are OPTIONAL and independent, which is the point of the shape: a
15160
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
15161
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
15162
+ * is given** — a window in which every sample is trivially a hit would fire on
15163
+ * silence, so the engine refuses such a condition rather than notifying on
15164
+ * nothing (the schema cannot express "at least one of" without becoming a
15165
+ * ZodEffects the cap path would have to special-case).
15166
+ *
15167
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
15168
+ * must be FULL before it can match — a window that has been open for two
15169
+ * seconds of its ten is 100% of nothing, and firing on it would make
15170
+ * `samplingSeconds` decorative.
15171
+ *
15172
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
15173
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
15174
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
15175
+ * an operator who typed `dog` mean the same thing.
15176
+ */
15177
+ var NcAudioConditionSchema = object({
15178
+ /** Audio macro labels; absent = any sound (level-only rule). */
15179
+ labels: array(string().min(1)).min(1).optional(),
15180
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
15181
+ dbThreshold: number().min(-96).max(0).optional(),
15182
+ /** Percentage of the window's samples that must be hits (1–100). */
15183
+ hitPercent: number().int().min(1).max(100).default(60),
15184
+ /** Length of the sampling window in seconds. */
15185
+ samplingSeconds: number().int().min(1).max(300).default(10)
15186
+ });
15187
+ /**
15055
15188
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
15056
15189
  *
15057
15190
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -15324,7 +15457,33 @@ var NcConditionsSchema = object({
15324
15457
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
15325
15458
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
15326
15459
  */
15327
- occupancy: NcOccupancyConditionSchema.optional()
15460
+ occupancy: NcOccupancyConditionSchema.optional(),
15461
+ /**
15462
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
15463
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
15464
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
15465
+ * a window that is not full yet, neither filter given). See
15466
+ * {@link NcAudioCondition}.
15467
+ *
15468
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
15469
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
15470
+ * a detection, a track or a device event (the same fail-closed pairing
15471
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
15472
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
15473
+ * (an `immediate` rule naming an `audio-*` class, one notification per
15474
+ * classified sample) stays exactly as it was for rules that already use it.
15475
+ *
15476
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
15477
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
15478
+ * (`camstack/src/data/notification-center.ts`, guarded by
15479
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
15480
+ * condition fields it does not know when a rule is saved from the phone.
15481
+ * Publishing an editor for a condition the app cannot round-trip is how an
15482
+ * operator loses a rule's conditions by opening it — so the descriptor, the
15483
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
15484
+ * does an audio rule become authorable.
15485
+ */
15486
+ audio: NcAudioConditionSchema.optional()
15328
15487
  });
15329
15488
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
15330
15489
  var NcRuleTargetSchema = object({
@@ -15438,6 +15597,73 @@ var NcThrottleSchema = object({
15438
15597
  */
15439
15598
  granularity: NcThrottleGranularitySchema.optional()
15440
15599
  });
15600
+ /**
15601
+ * How long the confirm gate may hold ONE notification, and how big the picture
15602
+ * it judges may be.
15603
+ *
15604
+ * The clamp is the product decision, not a coincidence of the model: p50 was
15605
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
15606
+ * arrives after the visitor has gone is not a notification. 448 px was enough
15607
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
15608
+ * tokens for pixels the model pools away.
15609
+ */
15610
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
15611
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
15612
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
15613
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
15614
+ var NcConfirmExpectSchema = object({
15615
+ op: _enum([
15616
+ ">=",
15617
+ ">",
15618
+ "<=",
15619
+ "<",
15620
+ "=="
15621
+ ]),
15622
+ count: number().int().min(0).max(1e3)
15623
+ });
15624
+ /**
15625
+ * AI CONFIRM — a vision model looks at the picture this notification is about
15626
+ * to ship and says whether it agrees with the rule.
15627
+ *
15628
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
15629
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
15630
+ * on the operator's phone is not a verdict about this notification.
15631
+ *
15632
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
15633
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
15634
+ * the default and every fail-open is COUNTED, because a gate that always fails
15635
+ * open looks in the log exactly like a gate that works.
15636
+ *
15637
+ * Every field is `.optional()` rather than relied on as a Zod default at the
15638
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
15639
+ * production failures in one day), so the gate reads absent as the constant
15640
+ * above rather than trusting a parse it may never have seen.
15641
+ */
15642
+ var NcConfirmSchema = object({
15643
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
15644
+ * same thing, and both mean "deliver exactly as before". */
15645
+ enabled: boolean().default(false),
15646
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
15647
+ profileId: string().optional(),
15648
+ /**
15649
+ * The operator's question, in his own words. Absent = a question derived
15650
+ * from the rule (its class and its expectation).
15651
+ *
15652
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
15653
+ * banners, signage and plates as instructions if you let them reach the
15654
+ * prompt — proven live — so the authoritative contract stays in the system
15655
+ * turn and only rule-authored words land here.
15656
+ */
15657
+ prompt: string().max(1e3).optional(),
15658
+ /** Fire only when the model's count satisfies this. Absent = the model's
15659
+ * own boolean verdict decides. */
15660
+ expect: NcConfirmExpectSchema.optional(),
15661
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
15662
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
15663
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
15664
+ /** Longest edge the judged image is downscaled to before it is sent. */
15665
+ maxImagePx: number().int().min(64).max(2048).default(448)
15666
+ });
15441
15667
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
15442
15668
  var NcRuleInputSchema = object({
15443
15669
  name: string().min(1).max(200),
@@ -15498,7 +15724,13 @@ var NcRuleInputSchema = object({
15498
15724
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
15499
15725
  * shape as every other actuation.
15500
15726
  */
15501
- actions: NcRuleActionsSchema.optional()
15727
+ actions: NcRuleActionsSchema.optional(),
15728
+ /**
15729
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
15730
+ * a rule that predates the gate must keep delivering byte-for-byte as it
15731
+ * did, and absent is the only way to say that without a migration.
15732
+ */
15733
+ confirm: NcConfirmSchema.optional()
15502
15734
  });
15503
15735
  /**
15504
15736
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -15509,7 +15741,37 @@ var NcRuleInputSchema = object({
15509
15741
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
15510
15742
  * `updateRule` patch.
15511
15743
  */
15512
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
15744
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
15745
+ disabledTargetIds: array(string()).optional(),
15746
+ /**
15747
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
15748
+ *
15749
+ * It makes the key optional to SUPPLY; the parse still materialises the
15750
+ * default when the key is absent. And `NcRuleStore.update` merges with
15751
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
15752
+ * one — which made every partial edit destructive:
15753
+ *
15754
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
15755
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
15756
+ * setEnabled(ruleId, false) → conditions reset to `{}`
15757
+ *
15758
+ * A rule scoped to one camera and one zone silently became a rule that
15759
+ * matches EVERY event on EVERY camera, and lost its `media` policy
15760
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
15761
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
15762
+ * within a minute of a two-field patch.
15763
+ *
15764
+ * So every defaulted field is re-declared here WITHOUT its default. The
15765
+ * inner defaults still apply when the caller DOES send the key — `{}` for
15766
+ * conditions remains a real instruction ("clear them") — and only the
15767
+ * absent key is now genuinely absent.
15768
+ */
15769
+ enabled: boolean().optional(),
15770
+ conditions: NcConditionsSchema.optional(),
15771
+ media: NcMediaPolicySchema.optional(),
15772
+ throttle: NcThrottleSchema.optional(),
15773
+ priority: number().int().min(1).max(5).optional()
15774
+ });
15513
15775
  /** A persisted rule. */
15514
15776
  var NcRuleSchema = NcRuleInputSchema.extend({
15515
15777
  id: string(),
@@ -15810,6 +16072,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15810
16072
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15811
16073
  * copy would lie the first time a rule is disabled.
15812
16074
  */
16075
+ /**
16076
+ * Why a device a mode NAMES is nonetheless not armed by it.
16077
+ *
16078
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
16079
+ * per-camera notification switch the Notification Center already owns,
16080
+ * `detection-off` is the device's own detection binding being inactive, and
16081
+ * `offline` is the device manager's liveness. A fourth reason would mean a
16082
+ * fourth authority, and inventing one here is how a panel starts disagreeing
16083
+ * with the switches the operator actually used.
16084
+ */
16085
+ var NcAlarmSkipReasonSchema = _enum([
16086
+ "muted",
16087
+ "detection-off",
16088
+ "offline"
16089
+ ]);
16090
+ var NcAlarmSkippedDeviceSchema = object({
16091
+ deviceId: number().int(),
16092
+ reason: NcAlarmSkipReasonSchema
16093
+ });
15813
16094
  var NcAlarmModeCoverageSchema = object({
15814
16095
  mode: AlarmArmModeSchema,
15815
16096
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15817,7 +16098,18 @@ var NcAlarmModeCoverageSchema = object({
15817
16098
  /** At least one covering rule has no device scope, so the mode covers all. */
15818
16099
  allDevices: boolean(),
15819
16100
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15820
- deviceIds: array(number().int())
16101
+ deviceIds: array(number().int()),
16102
+ /**
16103
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
16104
+ * excludes it.
16105
+ *
16106
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
16107
+ * twelve makes it false in exactly the way nobody notices until an incident.
16108
+ * Defaulted to `[]` so a coverage answer computed before this field existed
16109
+ * still parses as "nothing known to be skipped" rather than failing the whole
16110
+ * alarm tab.
16111
+ */
16112
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15821
16113
  });
15822
16114
  var NcAlarmConfigSchema = object({
15823
16115
  /**
@@ -18649,9 +18941,16 @@ var CameraStatusSchema = object({
18649
18941
  audio: CameraAudioStatusSchema.nullable(),
18650
18942
  recording: CameraRecordingStatusSchema.nullable(),
18651
18943
  /**
18652
- * Per-camera function switches an OPERATOR has turned off
18944
+ * Per-camera functions an OPERATOR has turned off
18653
18945
  * ([D61](../../../../docs/decisions/adr-0067.md)).
18654
18946
  *
18947
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18948
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18949
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18950
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18951
+ * The badge outlives the control panel: the panel was a convenience, this is
18952
+ * the difference between a camera being off and a camera being dead.
18953
+ *
18655
18954
  * This is the difference between DISABLED and BROKEN. A camera whose
18656
18955
  * `detection` block reports zero fps and whose `switchedOff` contains
18657
18956
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -25401,7 +25700,19 @@ var RecordingManifestSchema = object({
25401
25700
  * profiles/subtrees/locations on this node). */
25402
25701
  var RecordingDeviceUsageSchema = object({
25403
25702
  deviceId: number(),
25404
- usedBytes: number()
25703
+ usedBytes: number(),
25704
+ /**
25705
+ * Start of this camera's OLDEST indexed segment, across every profile and
25706
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25707
+ * only honest answer to "is retention actually holding?" per camera.
25708
+ *
25709
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25710
+ * predates this field omits it entirely, and a hub whose types carry the
25711
+ * field must keep validating that older provider's payload: the framework
25712
+ * (types) and the addon ship on different trains, and the addon is usually
25713
+ * the later of the two.
25714
+ */
25715
+ oldestMs: number().nullable().optional()
25405
25716
  });
25406
25717
  /** Recording storage usage + capacity for one storage location. */
25407
25718
  var RecordingLocationUsageSchema = object({
@@ -25429,6 +25740,57 @@ var RecordingStorageUsageSchema = object({
25429
25740
  locations: array(RecordingLocationUsageSchema)
25430
25741
  });
25431
25742
  /**
25743
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25744
+ *
25745
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25746
+ * is the operator asking for the EXISTING archive to be brought into line with
25747
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25748
+ * location, run FIFO behind the single-flight mover.
25749
+ *
25750
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25751
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25752
+ * (empty on the plan).
25753
+ */
25754
+ var RecordingRebalanceMoveSchema = object({
25755
+ deviceId: number(),
25756
+ profile: string(),
25757
+ fromLocationId: string(),
25758
+ toLocationId: string(),
25759
+ bytes: number(),
25760
+ files: number().int()
25761
+ });
25762
+ /** Why a pile that is out of place is staying there. Every refusal is
25763
+ * reported: a rebalance that silently drops a camera reads exactly like one
25764
+ * that had nothing to do. */
25765
+ var RecordingRebalanceSkipReasonSchema = _enum([
25766
+ "unassigned",
25767
+ "target-not-writable",
25768
+ "below-threshold",
25769
+ "no-headroom"
25770
+ ]);
25771
+ var RecordingRebalanceSkipSchema = object({
25772
+ deviceId: number(),
25773
+ profile: string(),
25774
+ fromLocationId: string(),
25775
+ /** The location the plan wants; null when the camera has no assignment. */
25776
+ toLocationId: string().nullable(),
25777
+ bytes: number(),
25778
+ reason: RecordingRebalanceSkipReasonSchema
25779
+ });
25780
+ var RecordingRebalancePlanSchema = object({
25781
+ moves: array(RecordingRebalanceMoveSchema),
25782
+ skipped: array(RecordingRebalanceSkipSchema),
25783
+ bytesToMove: number(),
25784
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25785
+ jobIds: array(string())
25786
+ });
25787
+ var RecordingRebalanceInputSchema = object({
25788
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25789
+ throttleMbps: number().min(1).max(1e3).optional(),
25790
+ /** Ignore piles smaller than this (default 1 GB). */
25791
+ minMoveGb: number().min(0).optional()
25792
+ });
25793
+ /**
25432
25794
  * Result of locating footage at a wall-clock instant for one device/profile.
25433
25795
  * `segment` carries the covering segment's window; `gap` reports the forward
25434
25796
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -25591,9 +25953,24 @@ method(object({
25591
25953
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25592
25954
  kind: "mutation",
25593
25955
  auth: "admin"
25956
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25957
+ kind: "mutation",
25958
+ auth: "admin"
25959
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25960
+ kind: "query",
25961
+ auth: "admin"
25962
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25963
+ kind: "mutation",
25964
+ auth: "admin"
25965
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25966
+ kind: "query",
25967
+ auth: "admin"
25968
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25969
+ kind: "mutation",
25970
+ auth: "admin"
25594
25971
  });
25595
25972
  /**
25596
- * `recordingExport` cap — render a footage time range into a single downloadable
25973
+ * `recording-export` cap — render a footage time range into a single downloadable
25597
25974
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
25598
25975
  * bounded lifetime with a durable history, auto-expiry, and optional
25599
25976
  * delete-after-download.
@@ -25608,10 +25985,53 @@ method(object({
25608
25985
  */
25609
25986
  /** Playback-speed multiplier for the render (1 = realtime). */
25610
25987
  var ExportSpeedSchema = number().min(.25).max(32);
25988
+ /**
25989
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25990
+ *
25991
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25992
+ * derives these bounds from things that happened at a TIME (a track's
25993
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25994
+ * every segment present for the range, with each recording GAP removed. The
25995
+ * two agree only on a window that recorded without one interruption, and only
25996
+ * the render side knows the segments, so the translation lives there
25997
+ * (`export-dense-map.ts`, addon-pipeline).
25998
+ *
25999
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
26000
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
26001
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
26002
+ * the video was a uniform timelapse, and the log line reported the five ranges
26003
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
26004
+ *
26005
+ * Relative and not absolute epoch, because an absolute epoch would make every
26006
+ * call site responsible for the same subtraction.
26007
+ */
26008
+ var ExportDenseRangeSchema = object({
26009
+ fromSec: number().nonnegative(),
26010
+ toSec: number().nonnegative()
26011
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
26012
+ /**
26013
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
26014
+ * listed ranges and at the base `everyMs` everywhere else.
26015
+ *
26016
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
26017
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
26018
+ */
26019
+ var ExportDenseSchema = object({
26020
+ everyMs: number().int().positive(),
26021
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
26022
+ });
25611
26023
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
25612
26024
  var ExportTimelapseSchema = object({
25613
26025
  everyMs: number().int().positive(),
25614
- outputFps: number().int().min(1).max(60).optional()
26026
+ outputFps: number().int().min(1).max(60).optional(),
26027
+ /** Optional second, FASTER rate over the intervals that matter. */
26028
+ dense: ExportDenseSchema.optional()
26029
+ }).superRefine((v, ctx) => {
26030
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
26031
+ code: ZodIssueCode.custom,
26032
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
26033
+ path: ["dense", "everyMs"]
26034
+ });
25615
26035
  });
25616
26036
  /**
25617
26037
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -25669,6 +26089,19 @@ var ExportDownloadSchema = object({
25669
26089
  url: string(),
25670
26090
  endpoints: array(string())
25671
26091
  });
26092
+ /**
26093
+ * A finished export's bytes, inline.
26094
+ *
26095
+ * `bytes` is the DECODED length — the number the caller bounds and logs
26096
+ * against, so nobody has to infer it from the base64 length.
26097
+ */
26098
+ var ExportBytesSchema = object({
26099
+ base64: string(),
26100
+ contentType: string(),
26101
+ /** Suggested filename, extension included. */
26102
+ name: string(),
26103
+ bytes: number().int().nonnegative()
26104
+ });
25672
26105
  method(object({
25673
26106
  deviceId: number(),
25674
26107
  profile: string(),
@@ -25693,6 +26126,9 @@ method(object({
25693
26126
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
25694
26127
  kind: "query",
25695
26128
  auth: "protected"
26129
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
26130
+ kind: "query",
26131
+ auth: "protected"
25696
26132
  });
25697
26133
  /**
25698
26134
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -32370,6 +32806,12 @@ Object.freeze({
32370
32806
  addonId: null,
32371
32807
  access: "create"
32372
32808
  },
32809
+ "recording.cancelRelocateJob": {
32810
+ capName: "recording",
32811
+ capScope: "system",
32812
+ addonId: null,
32813
+ access: "create"
32814
+ },
32373
32815
  "recording.cancelStorageMigrationMove": {
32374
32816
  capName: "recording",
32375
32817
  capScope: "system",
@@ -32424,6 +32866,12 @@ Object.freeze({
32424
32866
  addonId: null,
32425
32867
  access: "view"
32426
32868
  },
32869
+ "recording.listRelocateJobs": {
32870
+ capName: "recording",
32871
+ capScope: "system",
32872
+ addonId: null,
32873
+ access: "view"
32874
+ },
32427
32875
  "recording.locateSegment": {
32428
32876
  capName: "recording",
32429
32877
  capScope: "system",
@@ -32436,6 +32884,12 @@ Object.freeze({
32436
32884
  addonId: null,
32437
32885
  access: "create"
32438
32886
  },
32887
+ "recording.planStorageRebalance": {
32888
+ capName: "recording",
32889
+ capScope: "system",
32890
+ addonId: null,
32891
+ access: "view"
32892
+ },
32439
32893
  "recording.pruneFootage": {
32440
32894
  capName: "recording",
32441
32895
  capScope: "system",
@@ -32460,6 +32914,12 @@ Object.freeze({
32460
32914
  addonId: null,
32461
32915
  access: "create"
32462
32916
  },
32917
+ "recording.relocateFootage": {
32918
+ capName: "recording",
32919
+ capScope: "system",
32920
+ addonId: null,
32921
+ access: "create"
32922
+ },
32463
32923
  "recording.renderClip": {
32464
32924
  capName: "recording",
32465
32925
  capScope: "system",
@@ -32496,38 +32956,50 @@ Object.freeze({
32496
32956
  addonId: null,
32497
32957
  access: "create"
32498
32958
  },
32959
+ "recording.startStorageRebalance": {
32960
+ capName: "recording",
32961
+ capScope: "system",
32962
+ addonId: null,
32963
+ access: "create"
32964
+ },
32499
32965
  "recordingExport.cancelExport": {
32500
- capName: "recordingExport",
32966
+ capName: "recording-export",
32501
32967
  capScope: "system",
32502
32968
  addonId: null,
32503
32969
  access: "create"
32504
32970
  },
32505
32971
  "recordingExport.createExport": {
32506
- capName: "recordingExport",
32972
+ capName: "recording-export",
32507
32973
  capScope: "system",
32508
32974
  addonId: null,
32509
32975
  access: "create"
32510
32976
  },
32511
32977
  "recordingExport.deleteExport": {
32512
- capName: "recordingExport",
32978
+ capName: "recording-export",
32513
32979
  capScope: "system",
32514
32980
  addonId: null,
32515
32981
  access: "delete"
32516
32982
  },
32517
32983
  "recordingExport.getDownloadUrl": {
32518
- capName: "recordingExport",
32984
+ capName: "recording-export",
32519
32985
  capScope: "system",
32520
32986
  addonId: null,
32521
32987
  access: "view"
32522
32988
  },
32523
32989
  "recordingExport.getExport": {
32524
- capName: "recordingExport",
32990
+ capName: "recording-export",
32525
32991
  capScope: "system",
32526
32992
  addonId: null,
32527
32993
  access: "view"
32528
32994
  },
32529
32995
  "recordingExport.listExports": {
32530
- capName: "recordingExport",
32996
+ capName: "recording-export",
32997
+ capScope: "system",
32998
+ addonId: null,
32999
+ access: "view"
33000
+ },
33001
+ "recordingExport.readExportBytes": {
33002
+ capName: "recording-export",
32531
33003
  capScope: "system",
32532
33004
  addonId: null,
32533
33005
  access: "view"
@@ -33904,6 +34376,104 @@ var FramerateField = number().int().min(1).max(60);
33904
34376
  var TargetsField = array(NcRuleTargetSchema).min(1);
33905
34377
  var PriorityField = number().int().min(1).max(5);
33906
34378
  /**
34379
+ * Explicit override of the DENSE sampling cadence, seconds.
34380
+ *
34381
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
34382
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
34383
+ * made that same base 3 s and rendered a person pass as two frames.)
34384
+ *
34385
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
34386
+ * `denseCadenceSec` and played at `framerate` occupies
34387
+ *
34388
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
34389
+ *
34390
+ * 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.
34391
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
34392
+ * and therefore the length of a quiet night, does not move.
34393
+ *
34394
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
34395
+ * the recording has them returns the same frames, requested twice. Must be
34396
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
34397
+ * a uniform video the operator believes is two-rate — and upsert refuses it
34398
+ * rather than letting the export cap reject the render hours after the window.
34399
+ */
34400
+ var DenseCadenceSecField = number().min(.1).max(3600);
34401
+ /**
34402
+ * Minimum seconds of OUTPUT video each detection range must occupy.
34403
+ *
34404
+ * The operator-facing form of the arithmetic above: instead of solving for a
34405
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
34406
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
34407
+ * that range every ~583 ms.
34408
+ *
34409
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
34410
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
34411
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
34412
+ * ranges are sampled denser than they need. Per-range cadences require a cap
34413
+ * schema change and are the tracked follow-up.
34414
+ *
34415
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
34416
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
34417
+ * by real footage, never met by duplicating frames into motion that never
34418
+ * happened.
34419
+ */
34420
+ var MinDwellSecField = number().min(0).max(60);
34421
+ /**
34422
+ * Caption burned into the notification's preview frame.
34423
+ *
34424
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
34425
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
34426
+ * templating dialect for one field would be a second thing to explain.
34427
+ *
34428
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
34429
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
34430
+ * the reason this is not `.min(1)`.
34431
+ */
34432
+ var PreviewTextField = string().max(200);
34433
+ /**
34434
+ * Whether the notification's preview is a STILL or a short animation.
34435
+ *
34436
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
34437
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
34438
+ * night reads better as three seconds of motion than as one frame of it. Both
34439
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
34440
+ * simply applies it to a dozen frames sampled across the render and assembles
34441
+ * them.
34442
+ *
34443
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
34444
+ * seeks and a palette pass, and no rule that never asked for one should start
34445
+ * paying that on the deploy that shipped it.
34446
+ *
34447
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
34448
+ */
34449
+ var PreviewModeField = _enum(["image", "gif"]);
34450
+ /**
34451
+ * Which detection classes the notification reports counts for.
34452
+ *
34453
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
34454
+ * plan — no second query — aggregated per class. Absent or empty means "every
34455
+ * class the window actually contained", which is what an operator who never
34456
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
34457
+ * counts cars all night).
34458
+ *
34459
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
34460
+ * …). An unknown name simply never matches and reports nothing — it is not an
34461
+ * error, because a rule may legitimately name a class this camera's model does
34462
+ * not emit.
34463
+ *
34464
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
34465
+ * - `{{detections}}` — total over the reported classes
34466
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
34467
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
34468
+ * one per class, `count_` + the class name
34469
+ *
34470
+ * With NO custom body template the summary is appended to the derived body, and
34471
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
34472
+ * reads. With a custom template the operator owns every word — nothing is
34473
+ * appended, so `{{detectionSummary}}` is how he asks for it.
34474
+ */
34475
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
34476
+ /**
33907
34477
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33908
34478
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33909
34479
  * here (see the ownership note above).
@@ -33923,9 +34493,30 @@ var TimelapseRuleInputSchema = object({
33923
34493
  cadenceSec: CadenceSecField.default(15),
33924
34494
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33925
34495
  framerate: FramerateField.default(10),
34496
+ /**
34497
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
34498
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
34499
+ * field gets.
34500
+ */
34501
+ denseCadenceSec: DenseCadenceSecField.optional(),
34502
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
34503
+ minDwellSec: MinDwellSecField.optional(),
33926
34504
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33927
34505
  targets: TargetsField,
33928
34506
  template: TimelapseTemplateSchema.optional(),
34507
+ /**
34508
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
34509
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
34510
+ *
34511
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
34512
+ * the notification's title/body, and clearing it (`template: null`) must not
34513
+ * silently clear the caption too.
34514
+ */
34515
+ previewText: PreviewTextField.optional(),
34516
+ /** Still or animation — see {@link PreviewModeField}. */
34517
+ previewMode: PreviewModeField.default("image"),
34518
+ /** Classes the notification counts — see {@link ReportClassesField}. */
34519
+ reportClasses: ReportClassesField.optional(),
33929
34520
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33930
34521
  priority: PriorityField.default(3)
33931
34522
  });
@@ -33936,8 +34527,13 @@ object({
33936
34527
  schedule: NcScheduleSchema.optional(),
33937
34528
  cadenceSec: CadenceSecField.optional(),
33938
34529
  framerate: FramerateField.optional(),
34530
+ denseCadenceSec: DenseCadenceSecField.optional(),
34531
+ minDwellSec: MinDwellSecField.optional(),
33939
34532
  targets: TargetsField.optional(),
33940
34533
  template: TimelapseTemplateSchema.nullable().optional(),
34534
+ previewText: PreviewTextField.optional(),
34535
+ previewMode: PreviewModeField.optional(),
34536
+ reportClasses: ReportClassesField.optional(),
33941
34537
  priority: PriorityField.optional()
33942
34538
  });
33943
34539
  TimelapseRuleInputSchema.extend({
@@ -33949,10 +34545,28 @@ TimelapseRuleInputSchema.extend({
33949
34545
  */
33950
34546
  ownerUserId: string().optional(),
33951
34547
  /**
33952
- * Epoch-ms of the last successful generation the 1-hour re-generation
33953
- * guard's durable state (predecessor parity). Absent = never generated.
34548
+ * Epoch-ms of the NEWEST successful generation across every camera of this
34549
+ * rule. What a UI shows, and the compatibility floor for
34550
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33954
34551
  */
33955
34552
  lastGeneratedAt: number().optional(),
34553
+ /**
34554
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
34555
+ * re-generation guard's real durable state.
34556
+ *
34557
+ * One rule covers several cameras and each renders its own video, so a rule
34558
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
34559
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
34560
+ * already done — and B's night is gone for good, because the window will not
34561
+ * come back.
34562
+ *
34563
+ * ADDITIVE, so the migration is free: a row written before this field simply
34564
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
34565
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
34566
+ * "never generated" would re-render and re-notify every camera of every rule
34567
+ * once, on the deploy that shipped the map.
34568
+ */
34569
+ generatedByDevice: record(string(), number()).optional(),
33956
34570
  /** userId of the caller who created the rule (server-stamped). */
33957
34571
  createdBy: string(),
33958
34572
  createdAt: number(),
@@ -34003,25 +34617,32 @@ object({
34003
34617
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
34004
34618
  object({
34005
34619
  /**
34006
- * How long a retained native frame is served before it counts as a miss.
34620
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
34621
+ * detection result.
34622
+ *
34623
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
34624
+ * a time window was never related to the event the pixels were waiting for.
34625
+ * A held frame now lives from delivery until the runner has its `FrameResult`
34626
+ * — at which moment the runner cuts the subject tiles it actually wanted and
34627
+ * releases the frame. The bound exists only so a runner that stops answering
34628
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
34007
34629
  *
34008
- * Must cover the FULL late-crop horizon: detection inference + the
34009
- * cross-process inference-result hop to hub post-analysis + tracking + the
34010
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
34011
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
34012
- * RAM per busy camera grows linearly with no measured hit-rate gain.
34630
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
34631
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
34632
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
34633
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
34634
+ * `holdOverflow` on the metrics line is what says you need it.
34013
34635
  */
34014
- ttlMs: number().int().min(250).max(1e4),
34636
+ holdFrames: number().int().min(1).max(64),
34015
34637
  /**
34016
34638
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
34017
34639
  *
34018
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
34019
- * which one is actually binding before reasoning from that. At the shipped
34020
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
34021
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
34022
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
34023
- * change that admits fewer frames buys retention WINDOW at constant RAM
34024
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
34640
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
34641
+ * is what decides how much is held, and the ceiling is the number above which
34642
+ * something is wrong. Before that it was the effective cap at 1024 MB with
34643
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
34644
+ * with the TTL expiring nothing, which is exactly the confusion the hold
34645
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
34025
34646
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
34026
34647
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
34027
34648
  * to replace).
@@ -34047,22 +34668,45 @@ object({
34047
34668
  * there is the signal that some caller names frames outside the inference set
34048
34669
  * and that this must go back to `all`.
34049
34670
  */
34050
- admission: NativeLeaseAdmissionSchema
34671
+ admission: NativeLeaseAdmissionSchema,
34672
+ /**
34673
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
34674
+ * compressed native crops the worker cuts at the moment a frame's detection
34675
+ * result arrives, and keeps long after the frame itself is freed.
34676
+ *
34677
+ * This is the knob that replaced the old retention window, and it buys about
34678
+ * three orders of magnitude more of it: a tile is one subject at native
34679
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
34680
+ * the frame it was cut from. A frame on which nothing was detected costs
34681
+ * nothing at all, which is the real change — the old lease paid per FRAME and
34682
+ * was interrogated per SUBJECT.
34683
+ *
34684
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
34685
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
34686
+ * reproduce that.
34687
+ */
34688
+ tileBudgetMb: number().int().min(0).max(1024)
34051
34689
  });
34052
34690
  /**
34053
- * The values in force when the operator has set nothing — byte-for-byte the
34054
- * constants the decode worker shipped with as env-var defaults, so making these
34055
- * settings changed no behaviour on the day it landed.
34691
+ * The values in force when the operator has set nothing.
34692
+ *
34693
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
34694
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
34695
+ * in the same change that redefines it would make a regression and a retune
34696
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
34697
+ * live traffic.
34056
34698
  */
34057
34699
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
34058
- ttlMs: 1200,
34700
+ holdFrames: 8,
34059
34701
  budgetMb: 1024,
34060
34702
  activityMs: 15e3,
34703
+ tileBudgetMb: 64,
34061
34704
  admission: "inferred"
34062
34705
  };
34063
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
34706
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
34064
34707
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
34065
34708
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34709
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
34066
34710
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
34067
34711
  //#endregion
34068
34712
  //#region src/config.ts