@camstack/addon-decoder-ffmpeg 1.2.12 → 1.2.14

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/index.js +686 -42
  2. package/dist/index.mjs +686 -42
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7206,8 +7206,31 @@ var AdoptionJobSchema = object({
7206
7206
  error: string().nullable()
7207
7207
  });
7208
7208
  /**
7209
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7210
- * pipeline functions an operator thinks in terms of.
7209
+ * Per-camera FUNCTION SWITCHES.
7210
+ *
7211
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7212
+ *
7213
+ * This file shipped as "the one coherent on/off surface over the pipeline
7214
+ * functions an operator thinks in terms of". The operator's verdict on
7215
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7216
+ * every function already had a settings page of its own, and a second place to
7217
+ * turn it off is a second place to look. Each switch is going back to its own
7218
+ * component's original options — detection to the detection-pipeline wrapper
7219
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7220
+ * (which was always first-class; the switch was a veneer over
7221
+ * `recording.setDeviceConfig`), notifications to a notification-center
7222
+ * per-device setting, the two camera planes to their own components.
7223
+ *
7224
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7225
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7226
+ * straight from the authorities with no group in the middle. That rule was
7227
+ * never about a control panel.
7228
+ *
7229
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7230
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7231
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7232
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7233
+ * stop; nothing new may be built on it.
7211
7234
  *
7212
7235
  * ## This file adds no state
7213
7236
  *
@@ -7558,7 +7581,15 @@ var RecordingConfigSchema = object({
7558
7581
  * Each completed/failed run also lands one durable ops-log row on its owning
7559
7582
  * addon surface.
7560
7583
  */
7584
+ /**
7585
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7586
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7587
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7588
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7589
+ * runs at all.
7590
+ */
7561
7591
  var RelocateJobStateSchema = _enum([
7592
+ "queued",
7562
7593
  "running",
7563
7594
  "done",
7564
7595
  "failed",
@@ -7593,6 +7624,15 @@ var RelocateFootageInputSchema = object({
7593
7624
  /** Limits relocation to the logical profile class. Omit only for the
7594
7625
  * pre-orchestration compatibility path. */
7595
7626
  footageClass: RelocateFootageClassSchema.optional(),
7627
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7628
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7629
+ * unit is a (camera, profile) pile, not a disk. */
7630
+ deviceId: number().int().optional(),
7631
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7632
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7633
+ * placement plan assigns those two independently, so a rebalance that could
7634
+ * only say "recordings" would move footage the plan never asked to move. */
7635
+ profiles: array(string()).optional(),
7596
7636
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7597
7637
  * never allowed to starve live writers. */
7598
7638
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7728,6 +7768,21 @@ var StorageLocationSchema = object({
7728
7768
  nodeId: string().optional(),
7729
7769
  isDefault: boolean().default(false),
7730
7770
  isSystem: boolean().default(false),
7771
+ /**
7772
+ * Operator opt-in: whether consumers that BALANCE across several locations
7773
+ * of a type may write here. Recordings reads it today; event media and
7774
+ * backups are the next consumers, which is why the flag lives on the
7775
+ * location rather than in any one addon's store — nothing has to be
7776
+ * extended to add the next consumer.
7777
+ *
7778
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7779
+ * flag existed reads back with no flag and keeps working exactly as before;
7780
+ * that is the whole compat story, and it is why no migration ships with it.
7781
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7782
+ * disk must not silently start writing to it); the default of a type is
7783
+ * always stamped `true`.
7784
+ */
7785
+ enabled: boolean().optional(),
7731
7786
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7732
7787
  * for node-local locations it can reach) — never persisted, absent when the
7733
7788
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12160,7 +12215,8 @@ method(object({
12160
12215
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12161
12216
  /**
12162
12217
  * filesystem-browse — per-node capability for browsing the node's local
12163
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12218
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12219
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12164
12220
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12165
12221
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12166
12222
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -13973,6 +14029,13 @@ var MaskGridDimsSchema = object({
13973
14029
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
13974
14030
  * this one field keeps the schema additive — a rule still declares exactly
13975
14031
  * one trigger.
14032
+ *
14033
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14034
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14035
+ * mirror.ts` fails the build on a member the app cannot render) and every
14036
+ * member costs a release train. A sustained-sound rule is therefore an
14037
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14038
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
13976
14039
  */
13977
14040
  var NcDeliverySchema = _enum([
13978
14041
  "immediate",
@@ -13987,15 +14050,32 @@ var NcDeliverySchema = _enum([
13987
14050
  * depend on a provider's raw event name or payload shape.
13988
14051
  */
13989
14052
  var NcSystemEventKindSchema = _enum([
13990
- "camera-online",
13991
- "camera-offline",
14053
+ "device-online",
14054
+ "device-offline",
14055
+ "device-disabled",
14056
+ "device-enabled",
13992
14057
  "stream-online",
13993
14058
  "stream-offline",
13994
14059
  "node-online",
13995
14060
  "node-offline",
13996
14061
  "addon-update-available",
13997
- "server-update-available"
14062
+ "server-update-available",
14063
+ "alarm-triggered",
14064
+ "alarm-armed",
14065
+ "alarm-disarmed",
14066
+ "camera-online",
14067
+ "camera-offline",
14068
+ "camera-disabled",
14069
+ "camera-enabled"
14070
+ ]);
14071
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14072
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14073
+ "camera-online",
14074
+ "camera-offline",
14075
+ "camera-disabled",
14076
+ "camera-enabled"
13998
14077
  ]);
14078
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
13999
14079
  /**
14000
14080
  * One coherent system-event condition. `kinds` is the required opt-in safety
14001
14081
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14004,6 +14084,18 @@ var NcSystemEventKindSchema = _enum([
14004
14084
  var NcSystemEventConditionSchema = object({
14005
14085
  kinds: array(NcSystemEventKindSchema).min(1),
14006
14086
  deviceIds: array(number().int()).min(1).optional(),
14087
+ /**
14088
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14089
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14090
+ * is what a liveness rule means when nobody said otherwise.
14091
+ *
14092
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14093
+ * one reason: the intake cannot know which devices this household cares
14094
+ * about, and a producer-side filter is one no operator can change. Fails
14095
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14096
+ * does not carry) matches no `deviceTypes` list.
14097
+ */
14098
+ deviceTypes: array(string().min(1)).min(1).optional(),
14007
14099
  nodeIds: array(string().min(1)).min(1).optional(),
14008
14100
  packageNames: array(string().min(1)).min(1).optional()
14009
14101
  });
@@ -14054,6 +14146,47 @@ var NcOccupancyConditionSchema = object({
14054
14146
  sustainSeconds: number().int().min(0).max(3600).default(15)
14055
14147
  });
14056
14148
  /**
14149
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14150
+ *
14151
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14152
+ * reference notifier uses, so an operator moving between them re-uses what
14153
+ * they already know): a rule matches when, over a sampling window of
14154
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14155
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14156
+ *
14157
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14158
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14159
+ * - `labels` — the classifier put at least one of these labels on it.
14160
+ *
14161
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14162
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14163
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14164
+ * is given** — a window in which every sample is trivially a hit would fire on
14165
+ * silence, so the engine refuses such a condition rather than notifying on
14166
+ * nothing (the schema cannot express "at least one of" without becoming a
14167
+ * ZodEffects the cap path would have to special-case).
14168
+ *
14169
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14170
+ * must be FULL before it can match — a window that has been open for two
14171
+ * seconds of its ten is 100% of nothing, and firing on it would make
14172
+ * `samplingSeconds` decorative.
14173
+ *
14174
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14175
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14176
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14177
+ * an operator who typed `dog` mean the same thing.
14178
+ */
14179
+ var NcAudioConditionSchema = object({
14180
+ /** Audio macro labels; absent = any sound (level-only rule). */
14181
+ labels: array(string().min(1)).min(1).optional(),
14182
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14183
+ dbThreshold: number().min(-96).max(0).optional(),
14184
+ /** Percentage of the window's samples that must be hits (1–100). */
14185
+ hitPercent: number().int().min(1).max(100).default(60),
14186
+ /** Length of the sampling window in seconds. */
14187
+ samplingSeconds: number().int().min(1).max(300).default(10)
14188
+ });
14189
+ /**
14057
14190
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14058
14191
  *
14059
14192
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14326,7 +14459,33 @@ var NcConditionsSchema = object({
14326
14459
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14327
14460
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14328
14461
  */
14329
- occupancy: NcOccupancyConditionSchema.optional()
14462
+ occupancy: NcOccupancyConditionSchema.optional(),
14463
+ /**
14464
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14465
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14466
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14467
+ * a window that is not full yet, neither filter given). See
14468
+ * {@link NcAudioCondition}.
14469
+ *
14470
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14471
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14472
+ * a detection, a track or a device event (the same fail-closed pairing
14473
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14474
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14475
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14476
+ * classified sample) stays exactly as it was for rules that already use it.
14477
+ *
14478
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14479
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14480
+ * (`camstack/src/data/notification-center.ts`, guarded by
14481
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14482
+ * condition fields it does not know when a rule is saved from the phone.
14483
+ * Publishing an editor for a condition the app cannot round-trip is how an
14484
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14485
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14486
+ * does an audio rule become authorable.
14487
+ */
14488
+ audio: NcAudioConditionSchema.optional()
14330
14489
  });
14331
14490
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14332
14491
  var NcRuleTargetSchema = object({
@@ -14440,6 +14599,73 @@ var NcThrottleSchema = object({
14440
14599
  */
14441
14600
  granularity: NcThrottleGranularitySchema.optional()
14442
14601
  });
14602
+ /**
14603
+ * How long the confirm gate may hold ONE notification, and how big the picture
14604
+ * it judges may be.
14605
+ *
14606
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14607
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14608
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14609
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14610
+ * tokens for pixels the model pools away.
14611
+ */
14612
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14613
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14614
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14615
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14616
+ var NcConfirmExpectSchema = object({
14617
+ op: _enum([
14618
+ ">=",
14619
+ ">",
14620
+ "<=",
14621
+ "<",
14622
+ "=="
14623
+ ]),
14624
+ count: number().int().min(0).max(1e3)
14625
+ });
14626
+ /**
14627
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14628
+ * to ship and says whether it agrees with the rule.
14629
+ *
14630
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14631
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14632
+ * on the operator's phone is not a verdict about this notification.
14633
+ *
14634
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14635
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14636
+ * the default and every fail-open is COUNTED, because a gate that always fails
14637
+ * open looks in the log exactly like a gate that works.
14638
+ *
14639
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14640
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14641
+ * production failures in one day), so the gate reads absent as the constant
14642
+ * above rather than trusting a parse it may never have seen.
14643
+ */
14644
+ var NcConfirmSchema = object({
14645
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14646
+ * same thing, and both mean "deliver exactly as before". */
14647
+ enabled: boolean().default(false),
14648
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14649
+ profileId: string().optional(),
14650
+ /**
14651
+ * The operator's question, in his own words. Absent = a question derived
14652
+ * from the rule (its class and its expectation).
14653
+ *
14654
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14655
+ * banners, signage and plates as instructions if you let them reach the
14656
+ * prompt — proven live — so the authoritative contract stays in the system
14657
+ * turn and only rule-authored words land here.
14658
+ */
14659
+ prompt: string().max(1e3).optional(),
14660
+ /** Fire only when the model's count satisfies this. Absent = the model's
14661
+ * own boolean verdict decides. */
14662
+ expect: NcConfirmExpectSchema.optional(),
14663
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14664
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14665
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14666
+ /** Longest edge the judged image is downscaled to before it is sent. */
14667
+ maxImagePx: number().int().min(64).max(2048).default(448)
14668
+ });
14443
14669
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14444
14670
  var NcRuleInputSchema = object({
14445
14671
  name: string().min(1).max(200),
@@ -14500,7 +14726,13 @@ var NcRuleInputSchema = object({
14500
14726
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14501
14727
  * shape as every other actuation.
14502
14728
  */
14503
- actions: NcRuleActionsSchema.optional()
14729
+ actions: NcRuleActionsSchema.optional(),
14730
+ /**
14731
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14732
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14733
+ * did, and absent is the only way to say that without a migration.
14734
+ */
14735
+ confirm: NcConfirmSchema.optional()
14504
14736
  });
14505
14737
  /**
14506
14738
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14511,7 +14743,37 @@ var NcRuleInputSchema = object({
14511
14743
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14512
14744
  * `updateRule` patch.
14513
14745
  */
14514
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14746
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14747
+ disabledTargetIds: array(string()).optional(),
14748
+ /**
14749
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14750
+ *
14751
+ * It makes the key optional to SUPPLY; the parse still materialises the
14752
+ * default when the key is absent. And `NcRuleStore.update` merges with
14753
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14754
+ * one — which made every partial edit destructive:
14755
+ *
14756
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14757
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14758
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14759
+ *
14760
+ * A rule scoped to one camera and one zone silently became a rule that
14761
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14762
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14763
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14764
+ * within a minute of a two-field patch.
14765
+ *
14766
+ * So every defaulted field is re-declared here WITHOUT its default. The
14767
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14768
+ * conditions remains a real instruction ("clear them") — and only the
14769
+ * absent key is now genuinely absent.
14770
+ */
14771
+ enabled: boolean().optional(),
14772
+ conditions: NcConditionsSchema.optional(),
14773
+ media: NcMediaPolicySchema.optional(),
14774
+ throttle: NcThrottleSchema.optional(),
14775
+ priority: number().int().min(1).max(5).optional()
14776
+ });
14515
14777
  /** A persisted rule. */
14516
14778
  var NcRuleSchema = NcRuleInputSchema.extend({
14517
14779
  id: string(),
@@ -14812,6 +15074,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14812
15074
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14813
15075
  * copy would lie the first time a rule is disabled.
14814
15076
  */
15077
+ /**
15078
+ * Why a device a mode NAMES is nonetheless not armed by it.
15079
+ *
15080
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15081
+ * per-camera notification switch the Notification Center already owns,
15082
+ * `detection-off` is the device's own detection binding being inactive, and
15083
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15084
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15085
+ * with the switches the operator actually used.
15086
+ */
15087
+ var NcAlarmSkipReasonSchema = _enum([
15088
+ "muted",
15089
+ "detection-off",
15090
+ "offline"
15091
+ ]);
15092
+ var NcAlarmSkippedDeviceSchema = object({
15093
+ deviceId: number().int(),
15094
+ reason: NcAlarmSkipReasonSchema
15095
+ });
14815
15096
  var NcAlarmModeCoverageSchema = object({
14816
15097
  mode: AlarmArmModeSchema,
14817
15098
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14819,7 +15100,18 @@ var NcAlarmModeCoverageSchema = object({
14819
15100
  /** At least one covering rule has no device scope, so the mode covers all. */
14820
15101
  allDevices: boolean(),
14821
15102
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14822
- deviceIds: array(number().int())
15103
+ deviceIds: array(number().int()),
15104
+ /**
15105
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15106
+ * excludes it.
15107
+ *
15108
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15109
+ * twelve makes it false in exactly the way nobody notices until an incident.
15110
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15111
+ * still parses as "nothing known to be skipped" rather than failing the whole
15112
+ * alarm tab.
15113
+ */
15114
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14823
15115
  });
14824
15116
  var NcAlarmConfigSchema = object({
14825
15117
  /**
@@ -17618,9 +17910,16 @@ var CameraStatusSchema = object({
17618
17910
  audio: CameraAudioStatusSchema.nullable(),
17619
17911
  recording: CameraRecordingStatusSchema.nullable(),
17620
17912
  /**
17621
- * Per-camera function switches an OPERATOR has turned off
17913
+ * Per-camera functions an OPERATOR has turned off
17622
17914
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17623
17915
  *
17916
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
17917
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
17918
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
17919
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
17920
+ * The badge outlives the control panel: the panel was a convenience, this is
17921
+ * the difference between a camera being off and a camera being dead.
17922
+ *
17624
17923
  * This is the difference between DISABLED and BROKEN. A camera whose
17625
17924
  * `detection` block reports zero fps and whose `switchedOff` contains
17626
17925
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -23129,7 +23428,19 @@ var RecordingManifestSchema = object({
23129
23428
  * profiles/subtrees/locations on this node). */
23130
23429
  var RecordingDeviceUsageSchema = object({
23131
23430
  deviceId: number(),
23132
- usedBytes: number()
23431
+ usedBytes: number(),
23432
+ /**
23433
+ * Start of this camera's OLDEST indexed segment, across every profile and
23434
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23435
+ * only honest answer to "is retention actually holding?" per camera.
23436
+ *
23437
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23438
+ * predates this field omits it entirely, and a hub whose types carry the
23439
+ * field must keep validating that older provider's payload: the framework
23440
+ * (types) and the addon ship on different trains, and the addon is usually
23441
+ * the later of the two.
23442
+ */
23443
+ oldestMs: number().nullable().optional()
23133
23444
  });
23134
23445
  /** Recording storage usage + capacity for one storage location. */
23135
23446
  var RecordingLocationUsageSchema = object({
@@ -23157,6 +23468,57 @@ var RecordingStorageUsageSchema = object({
23157
23468
  locations: array(RecordingLocationUsageSchema)
23158
23469
  });
23159
23470
  /**
23471
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23472
+ *
23473
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23474
+ * is the operator asking for the EXISTING archive to be brought into line with
23475
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23476
+ * location, run FIFO behind the single-flight mover.
23477
+ *
23478
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23479
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23480
+ * (empty on the plan).
23481
+ */
23482
+ var RecordingRebalanceMoveSchema = object({
23483
+ deviceId: number(),
23484
+ profile: string(),
23485
+ fromLocationId: string(),
23486
+ toLocationId: string(),
23487
+ bytes: number(),
23488
+ files: number().int()
23489
+ });
23490
+ /** Why a pile that is out of place is staying there. Every refusal is
23491
+ * reported: a rebalance that silently drops a camera reads exactly like one
23492
+ * that had nothing to do. */
23493
+ var RecordingRebalanceSkipReasonSchema = _enum([
23494
+ "unassigned",
23495
+ "target-not-writable",
23496
+ "below-threshold",
23497
+ "no-headroom"
23498
+ ]);
23499
+ var RecordingRebalanceSkipSchema = object({
23500
+ deviceId: number(),
23501
+ profile: string(),
23502
+ fromLocationId: string(),
23503
+ /** The location the plan wants; null when the camera has no assignment. */
23504
+ toLocationId: string().nullable(),
23505
+ bytes: number(),
23506
+ reason: RecordingRebalanceSkipReasonSchema
23507
+ });
23508
+ var RecordingRebalancePlanSchema = object({
23509
+ moves: array(RecordingRebalanceMoveSchema),
23510
+ skipped: array(RecordingRebalanceSkipSchema),
23511
+ bytesToMove: number(),
23512
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23513
+ jobIds: array(string())
23514
+ });
23515
+ var RecordingRebalanceInputSchema = object({
23516
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23517
+ throttleMbps: number().min(1).max(1e3).optional(),
23518
+ /** Ignore piles smaller than this (default 1 GB). */
23519
+ minMoveGb: number().min(0).optional()
23520
+ });
23521
+ /**
23160
23522
  * Result of locating footage at a wall-clock instant for one device/profile.
23161
23523
  * `segment` carries the covering segment's window; `gap` reports the forward
23162
23524
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23319,9 +23681,24 @@ method(object({
23319
23681
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23320
23682
  kind: "mutation",
23321
23683
  auth: "admin"
23684
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23685
+ kind: "mutation",
23686
+ auth: "admin"
23687
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23688
+ kind: "query",
23689
+ auth: "admin"
23690
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23691
+ kind: "mutation",
23692
+ auth: "admin"
23693
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23694
+ kind: "query",
23695
+ auth: "admin"
23696
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23697
+ kind: "mutation",
23698
+ auth: "admin"
23322
23699
  });
23323
23700
  /**
23324
- * `recordingExport` cap — render a footage time range into a single downloadable
23701
+ * `recording-export` cap — render a footage time range into a single downloadable
23325
23702
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23326
23703
  * bounded lifetime with a durable history, auto-expiry, and optional
23327
23704
  * delete-after-download.
@@ -23336,10 +23713,53 @@ method(object({
23336
23713
  */
23337
23714
  /** Playback-speed multiplier for the render (1 = realtime). */
23338
23715
  var ExportSpeedSchema = number().min(.25).max(32);
23716
+ /**
23717
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23718
+ *
23719
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23720
+ * derives these bounds from things that happened at a TIME (a track's
23721
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23722
+ * every segment present for the range, with each recording GAP removed. The
23723
+ * two agree only on a window that recorded without one interruption, and only
23724
+ * the render side knows the segments, so the translation lives there
23725
+ * (`export-dense-map.ts`, addon-pipeline).
23726
+ *
23727
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23728
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23729
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23730
+ * the video was a uniform timelapse, and the log line reported the five ranges
23731
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23732
+ *
23733
+ * Relative and not absolute epoch, because an absolute epoch would make every
23734
+ * call site responsible for the same subtraction.
23735
+ */
23736
+ var ExportDenseRangeSchema = object({
23737
+ fromSec: number().nonnegative(),
23738
+ toSec: number().nonnegative()
23739
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23740
+ /**
23741
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23742
+ * listed ranges and at the base `everyMs` everywhere else.
23743
+ *
23744
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23745
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23746
+ */
23747
+ var ExportDenseSchema = object({
23748
+ everyMs: number().int().positive(),
23749
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23750
+ });
23339
23751
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23340
23752
  var ExportTimelapseSchema = object({
23341
23753
  everyMs: number().int().positive(),
23342
- outputFps: number().int().min(1).max(60).optional()
23754
+ outputFps: number().int().min(1).max(60).optional(),
23755
+ /** Optional second, FASTER rate over the intervals that matter. */
23756
+ dense: ExportDenseSchema.optional()
23757
+ }).superRefine((v, ctx) => {
23758
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23759
+ code: ZodIssueCode.custom,
23760
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23761
+ path: ["dense", "everyMs"]
23762
+ });
23343
23763
  });
23344
23764
  /**
23345
23765
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23397,6 +23817,19 @@ var ExportDownloadSchema = object({
23397
23817
  url: string(),
23398
23818
  endpoints: array(string())
23399
23819
  });
23820
+ /**
23821
+ * A finished export's bytes, inline.
23822
+ *
23823
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23824
+ * against, so nobody has to infer it from the base64 length.
23825
+ */
23826
+ var ExportBytesSchema = object({
23827
+ base64: string(),
23828
+ contentType: string(),
23829
+ /** Suggested filename, extension included. */
23830
+ name: string(),
23831
+ bytes: number().int().nonnegative()
23832
+ });
23400
23833
  method(object({
23401
23834
  deviceId: number(),
23402
23835
  profile: string(),
@@ -23421,6 +23854,9 @@ method(object({
23421
23854
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23422
23855
  kind: "query",
23423
23856
  auth: "protected"
23857
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
23858
+ kind: "query",
23859
+ auth: "protected"
23424
23860
  });
23425
23861
  /**
23426
23862
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -28614,6 +29050,12 @@ Object.freeze({
28614
29050
  addonId: null,
28615
29051
  access: "create"
28616
29052
  },
29053
+ "recording.cancelRelocateJob": {
29054
+ capName: "recording",
29055
+ capScope: "system",
29056
+ addonId: null,
29057
+ access: "create"
29058
+ },
28617
29059
  "recording.cancelStorageMigrationMove": {
28618
29060
  capName: "recording",
28619
29061
  capScope: "system",
@@ -28668,6 +29110,12 @@ Object.freeze({
28668
29110
  addonId: null,
28669
29111
  access: "view"
28670
29112
  },
29113
+ "recording.listRelocateJobs": {
29114
+ capName: "recording",
29115
+ capScope: "system",
29116
+ addonId: null,
29117
+ access: "view"
29118
+ },
28671
29119
  "recording.locateSegment": {
28672
29120
  capName: "recording",
28673
29121
  capScope: "system",
@@ -28680,6 +29128,12 @@ Object.freeze({
28680
29128
  addonId: null,
28681
29129
  access: "create"
28682
29130
  },
29131
+ "recording.planStorageRebalance": {
29132
+ capName: "recording",
29133
+ capScope: "system",
29134
+ addonId: null,
29135
+ access: "view"
29136
+ },
28683
29137
  "recording.pruneFootage": {
28684
29138
  capName: "recording",
28685
29139
  capScope: "system",
@@ -28704,6 +29158,12 @@ Object.freeze({
28704
29158
  addonId: null,
28705
29159
  access: "create"
28706
29160
  },
29161
+ "recording.relocateFootage": {
29162
+ capName: "recording",
29163
+ capScope: "system",
29164
+ addonId: null,
29165
+ access: "create"
29166
+ },
28707
29167
  "recording.renderClip": {
28708
29168
  capName: "recording",
28709
29169
  capScope: "system",
@@ -28740,38 +29200,50 @@ Object.freeze({
28740
29200
  addonId: null,
28741
29201
  access: "create"
28742
29202
  },
29203
+ "recording.startStorageRebalance": {
29204
+ capName: "recording",
29205
+ capScope: "system",
29206
+ addonId: null,
29207
+ access: "create"
29208
+ },
28743
29209
  "recordingExport.cancelExport": {
28744
- capName: "recordingExport",
29210
+ capName: "recording-export",
28745
29211
  capScope: "system",
28746
29212
  addonId: null,
28747
29213
  access: "create"
28748
29214
  },
28749
29215
  "recordingExport.createExport": {
28750
- capName: "recordingExport",
29216
+ capName: "recording-export",
28751
29217
  capScope: "system",
28752
29218
  addonId: null,
28753
29219
  access: "create"
28754
29220
  },
28755
29221
  "recordingExport.deleteExport": {
28756
- capName: "recordingExport",
29222
+ capName: "recording-export",
28757
29223
  capScope: "system",
28758
29224
  addonId: null,
28759
29225
  access: "delete"
28760
29226
  },
28761
29227
  "recordingExport.getDownloadUrl": {
28762
- capName: "recordingExport",
29228
+ capName: "recording-export",
28763
29229
  capScope: "system",
28764
29230
  addonId: null,
28765
29231
  access: "view"
28766
29232
  },
28767
29233
  "recordingExport.getExport": {
28768
- capName: "recordingExport",
29234
+ capName: "recording-export",
28769
29235
  capScope: "system",
28770
29236
  addonId: null,
28771
29237
  access: "view"
28772
29238
  },
28773
29239
  "recordingExport.listExports": {
28774
- capName: "recordingExport",
29240
+ capName: "recording-export",
29241
+ capScope: "system",
29242
+ addonId: null,
29243
+ access: "view"
29244
+ },
29245
+ "recordingExport.readExportBytes": {
29246
+ capName: "recording-export",
28775
29247
  capScope: "system",
28776
29248
  addonId: null,
28777
29249
  access: "view"
@@ -30148,6 +30620,104 @@ var FramerateField = number().int().min(1).max(60);
30148
30620
  var TargetsField = array(NcRuleTargetSchema).min(1);
30149
30621
  var PriorityField = number().int().min(1).max(5);
30150
30622
  /**
30623
+ * Explicit override of the DENSE sampling cadence, seconds.
30624
+ *
30625
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
30626
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
30627
+ * made that same base 3 s and rendered a person pass as two frames.)
30628
+ *
30629
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
30630
+ * `denseCadenceSec` and played at `framerate` occupies
30631
+ *
30632
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
30633
+ *
30634
+ * 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.
30635
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
30636
+ * and therefore the length of a quiet night, does not move.
30637
+ *
30638
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
30639
+ * the recording has them returns the same frames, requested twice. Must be
30640
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
30641
+ * a uniform video the operator believes is two-rate — and upsert refuses it
30642
+ * rather than letting the export cap reject the render hours after the window.
30643
+ */
30644
+ var DenseCadenceSecField = number().min(.1).max(3600);
30645
+ /**
30646
+ * Minimum seconds of OUTPUT video each detection range must occupy.
30647
+ *
30648
+ * The operator-facing form of the arithmetic above: instead of solving for a
30649
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
30650
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
30651
+ * that range every ~583 ms.
30652
+ *
30653
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
30654
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
30655
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
30656
+ * ranges are sampled denser than they need. Per-range cadences require a cap
30657
+ * schema change and are the tracked follow-up.
30658
+ *
30659
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
30660
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
30661
+ * by real footage, never met by duplicating frames into motion that never
30662
+ * happened.
30663
+ */
30664
+ var MinDwellSecField = number().min(0).max(60);
30665
+ /**
30666
+ * Caption burned into the notification's preview frame.
30667
+ *
30668
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
30669
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
30670
+ * templating dialect for one field would be a second thing to explain.
30671
+ *
30672
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
30673
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
30674
+ * the reason this is not `.min(1)`.
30675
+ */
30676
+ var PreviewTextField = string().max(200);
30677
+ /**
30678
+ * Whether the notification's preview is a STILL or a short animation.
30679
+ *
30680
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
30681
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
30682
+ * night reads better as three seconds of motion than as one frame of it. Both
30683
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
30684
+ * simply applies it to a dozen frames sampled across the render and assembles
30685
+ * them.
30686
+ *
30687
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
30688
+ * seeks and a palette pass, and no rule that never asked for one should start
30689
+ * paying that on the deploy that shipped it.
30690
+ *
30691
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
30692
+ */
30693
+ var PreviewModeField = _enum(["image", "gif"]);
30694
+ /**
30695
+ * Which detection classes the notification reports counts for.
30696
+ *
30697
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
30698
+ * plan — no second query — aggregated per class. Absent or empty means "every
30699
+ * class the window actually contained", which is what an operator who never
30700
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
30701
+ * counts cars all night).
30702
+ *
30703
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
30704
+ * …). An unknown name simply never matches and reports nothing — it is not an
30705
+ * error, because a rule may legitimately name a class this camera's model does
30706
+ * not emit.
30707
+ *
30708
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
30709
+ * - `{{detections}}` — total over the reported classes
30710
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
30711
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
30712
+ * one per class, `count_` + the class name
30713
+ *
30714
+ * With NO custom body template the summary is appended to the derived body, and
30715
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
30716
+ * reads. With a custom template the operator owns every word — nothing is
30717
+ * appended, so `{{detectionSummary}}` is how he asks for it.
30718
+ */
30719
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
30720
+ /**
30151
30721
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30152
30722
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30153
30723
  * here (see the ownership note above).
@@ -30167,9 +30737,30 @@ var TimelapseRuleInputSchema = object({
30167
30737
  cadenceSec: CadenceSecField.default(15),
30168
30738
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30169
30739
  framerate: FramerateField.default(10),
30740
+ /**
30741
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
30742
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
30743
+ * field gets.
30744
+ */
30745
+ denseCadenceSec: DenseCadenceSecField.optional(),
30746
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
30747
+ minDwellSec: MinDwellSecField.optional(),
30170
30748
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30171
30749
  targets: TargetsField,
30172
30750
  template: TimelapseTemplateSchema.optional(),
30751
+ /**
30752
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
30753
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
30754
+ *
30755
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
30756
+ * the notification's title/body, and clearing it (`template: null`) must not
30757
+ * silently clear the caption too.
30758
+ */
30759
+ previewText: PreviewTextField.optional(),
30760
+ /** Still or animation — see {@link PreviewModeField}. */
30761
+ previewMode: PreviewModeField.default("image"),
30762
+ /** Classes the notification counts — see {@link ReportClassesField}. */
30763
+ reportClasses: ReportClassesField.optional(),
30173
30764
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30174
30765
  priority: PriorityField.default(3)
30175
30766
  });
@@ -30180,8 +30771,13 @@ object({
30180
30771
  schedule: NcScheduleSchema.optional(),
30181
30772
  cadenceSec: CadenceSecField.optional(),
30182
30773
  framerate: FramerateField.optional(),
30774
+ denseCadenceSec: DenseCadenceSecField.optional(),
30775
+ minDwellSec: MinDwellSecField.optional(),
30183
30776
  targets: TargetsField.optional(),
30184
30777
  template: TimelapseTemplateSchema.nullable().optional(),
30778
+ previewText: PreviewTextField.optional(),
30779
+ previewMode: PreviewModeField.optional(),
30780
+ reportClasses: ReportClassesField.optional(),
30185
30781
  priority: PriorityField.optional()
30186
30782
  });
30187
30783
  TimelapseRuleInputSchema.extend({
@@ -30193,10 +30789,28 @@ TimelapseRuleInputSchema.extend({
30193
30789
  */
30194
30790
  ownerUserId: string().optional(),
30195
30791
  /**
30196
- * Epoch-ms of the last successful generation the 1-hour re-generation
30197
- * guard's durable state (predecessor parity). Absent = never generated.
30792
+ * Epoch-ms of the NEWEST successful generation across every camera of this
30793
+ * rule. What a UI shows, and the compatibility floor for
30794
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30198
30795
  */
30199
30796
  lastGeneratedAt: number().optional(),
30797
+ /**
30798
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
30799
+ * re-generation guard's real durable state.
30800
+ *
30801
+ * One rule covers several cameras and each renders its own video, so a rule
30802
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
30803
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
30804
+ * already done — and B's night is gone for good, because the window will not
30805
+ * come back.
30806
+ *
30807
+ * ADDITIVE, so the migration is free: a row written before this field simply
30808
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
30809
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
30810
+ * "never generated" would re-render and re-notify every camera of every rule
30811
+ * once, on the deploy that shipped the map.
30812
+ */
30813
+ generatedByDevice: record(string(), number()).optional(),
30200
30814
  /** userId of the caller who created the rule (server-stamped). */
30201
30815
  createdBy: string(),
30202
30816
  createdAt: number(),
@@ -30247,25 +30861,32 @@ object({
30247
30861
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30248
30862
  object({
30249
30863
  /**
30250
- * How long a retained native frame is served before it counts as a miss.
30864
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
30865
+ * detection result.
30866
+ *
30867
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
30868
+ * a time window was never related to the event the pixels were waiting for.
30869
+ * A held frame now lives from delivery until the runner has its `FrameResult`
30870
+ * — at which moment the runner cuts the subject tiles it actually wanted and
30871
+ * releases the frame. The bound exists only so a runner that stops answering
30872
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
30251
30873
  *
30252
- * Must cover the FULL late-crop horizon: detection inference + the
30253
- * cross-process inference-result hop to hub post-analysis + tracking + the
30254
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30255
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30256
- * RAM per busy camera grows linearly with no measured hit-rate gain.
30874
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
30875
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
30876
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
30877
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
30878
+ * `holdOverflow` on the metrics line is what says you need it.
30257
30879
  */
30258
- ttlMs: number().int().min(250).max(1e4),
30880
+ holdFrames: number().int().min(1).max(64),
30259
30881
  /**
30260
30882
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30261
30883
  *
30262
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30263
- * which one is actually binding before reasoning from that. At the shipped
30264
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30265
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30266
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30267
- * change that admits fewer frames buys retention WINDOW at constant RAM
30268
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
30884
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
30885
+ * is what decides how much is held, and the ceiling is the number above which
30886
+ * something is wrong. Before that it was the effective cap at 1024 MB with
30887
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
30888
+ * with the TTL expiring nothing, which is exactly the confusion the hold
30889
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30269
30890
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30270
30891
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30271
30892
  * to replace).
@@ -30291,22 +30912,45 @@ object({
30291
30912
  * there is the signal that some caller names frames outside the inference set
30292
30913
  * and that this must go back to `all`.
30293
30914
  */
30294
- admission: NativeLeaseAdmissionSchema
30915
+ admission: NativeLeaseAdmissionSchema,
30916
+ /**
30917
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
30918
+ * compressed native crops the worker cuts at the moment a frame's detection
30919
+ * result arrives, and keeps long after the frame itself is freed.
30920
+ *
30921
+ * This is the knob that replaced the old retention window, and it buys about
30922
+ * three orders of magnitude more of it: a tile is one subject at native
30923
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
30924
+ * the frame it was cut from. A frame on which nothing was detected costs
30925
+ * nothing at all, which is the real change — the old lease paid per FRAME and
30926
+ * was interrogated per SUBJECT.
30927
+ *
30928
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
30929
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
30930
+ * reproduce that.
30931
+ */
30932
+ tileBudgetMb: number().int().min(0).max(1024)
30295
30933
  });
30296
30934
  /**
30297
- * The values in force when the operator has set nothing — byte-for-byte the
30298
- * constants the decode worker shipped with as env-var defaults, so making these
30299
- * settings changed no behaviour on the day it landed.
30935
+ * The values in force when the operator has set nothing.
30936
+ *
30937
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
30938
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
30939
+ * in the same change that redefines it would make a regression and a retune
30940
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
30941
+ * live traffic.
30300
30942
  */
30301
30943
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30302
- ttlMs: 1200,
30944
+ holdFrames: 8,
30303
30945
  budgetMb: 1024,
30304
30946
  activityMs: 15e3,
30947
+ tileBudgetMb: 64,
30305
30948
  admission: "inferred"
30306
30949
  };
30307
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
30950
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30308
30951
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30309
30952
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
30953
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30310
30954
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30311
30955
  /**
30312
30956
  * Fixed-capacity ring buffer. When full, push() overwrites the oldest entry.