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