@camstack/addon-export-alexa 1.2.17 → 1.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7373,8 +7373,31 @@ var AdoptionJobSchema = object({
7373
7373
  error: string().nullable()
7374
7374
  });
7375
7375
  /**
7376
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7377
- * pipeline functions an operator thinks in terms of.
7376
+ * Per-camera FUNCTION SWITCHES.
7377
+ *
7378
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7379
+ *
7380
+ * This file shipped as "the one coherent on/off surface over the pipeline
7381
+ * functions an operator thinks in terms of". The operator's verdict on
7382
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7383
+ * every function already had a settings page of its own, and a second place to
7384
+ * turn it off is a second place to look. Each switch is going back to its own
7385
+ * component's original options — detection to the detection-pipeline wrapper
7386
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7387
+ * (which was always first-class; the switch was a veneer over
7388
+ * `recording.setDeviceConfig`), notifications to a notification-center
7389
+ * per-device setting, the two camera planes to their own components.
7390
+ *
7391
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7392
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7393
+ * straight from the authorities with no group in the middle. That rule was
7394
+ * never about a control panel.
7395
+ *
7396
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7397
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7398
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7399
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7400
+ * stop; nothing new may be built on it.
7378
7401
  *
7379
7402
  * ## This file adds no state
7380
7403
  *
@@ -7725,7 +7748,15 @@ var RecordingConfigSchema = object({
7725
7748
  * Each completed/failed run also lands one durable ops-log row on its owning
7726
7749
  * addon surface.
7727
7750
  */
7751
+ /**
7752
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7753
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7754
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7755
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7756
+ * runs at all.
7757
+ */
7728
7758
  var RelocateJobStateSchema = _enum([
7759
+ "queued",
7729
7760
  "running",
7730
7761
  "done",
7731
7762
  "failed",
@@ -7760,6 +7791,15 @@ var RelocateFootageInputSchema = object({
7760
7791
  /** Limits relocation to the logical profile class. Omit only for the
7761
7792
  * pre-orchestration compatibility path. */
7762
7793
  footageClass: RelocateFootageClassSchema.optional(),
7794
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7795
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7796
+ * unit is a (camera, profile) pile, not a disk. */
7797
+ deviceId: number().int().optional(),
7798
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7799
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7800
+ * placement plan assigns those two independently, so a rebalance that could
7801
+ * only say "recordings" would move footage the plan never asked to move. */
7802
+ profiles: array(string()).optional(),
7763
7803
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7764
7804
  * never allowed to starve live writers. */
7765
7805
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7895,6 +7935,21 @@ var StorageLocationSchema = object({
7895
7935
  nodeId: string().optional(),
7896
7936
  isDefault: boolean().default(false),
7897
7937
  isSystem: boolean().default(false),
7938
+ /**
7939
+ * Operator opt-in: whether consumers that BALANCE across several locations
7940
+ * of a type may write here. Recordings reads it today; event media and
7941
+ * backups are the next consumers, which is why the flag lives on the
7942
+ * location rather than in any one addon's store — nothing has to be
7943
+ * extended to add the next consumer.
7944
+ *
7945
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7946
+ * flag existed reads back with no flag and keeps working exactly as before;
7947
+ * that is the whole compat story, and it is why no migration ships with it.
7948
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7949
+ * disk must not silently start writing to it); the default of a type is
7950
+ * always stamped `true`.
7951
+ */
7952
+ enabled: boolean().optional(),
7898
7953
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7899
7954
  * for node-local locations it can reach) — never persisted, absent when the
7900
7955
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12324,7 +12379,8 @@ method(object({
12324
12379
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12325
12380
  /**
12326
12381
  * filesystem-browse — per-node capability for browsing the node's local
12327
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12382
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12383
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12328
12384
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12329
12385
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12330
12386
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14137,6 +14193,13 @@ var MaskGridDimsSchema = object({
14137
14193
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14138
14194
  * this one field keeps the schema additive — a rule still declares exactly
14139
14195
  * one trigger.
14196
+ *
14197
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14198
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14199
+ * mirror.ts` fails the build on a member the app cannot render) and every
14200
+ * member costs a release train. A sustained-sound rule is therefore an
14201
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14202
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14140
14203
  */
14141
14204
  var NcDeliverySchema = _enum([
14142
14205
  "immediate",
@@ -14151,15 +14214,32 @@ var NcDeliverySchema = _enum([
14151
14214
  * depend on a provider's raw event name or payload shape.
14152
14215
  */
14153
14216
  var NcSystemEventKindSchema = _enum([
14154
- "camera-online",
14155
- "camera-offline",
14217
+ "device-online",
14218
+ "device-offline",
14219
+ "device-disabled",
14220
+ "device-enabled",
14156
14221
  "stream-online",
14157
14222
  "stream-offline",
14158
14223
  "node-online",
14159
14224
  "node-offline",
14160
14225
  "addon-update-available",
14161
- "server-update-available"
14226
+ "server-update-available",
14227
+ "alarm-triggered",
14228
+ "alarm-armed",
14229
+ "alarm-disarmed",
14230
+ "camera-online",
14231
+ "camera-offline",
14232
+ "camera-disabled",
14233
+ "camera-enabled"
14234
+ ]);
14235
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14236
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14237
+ "camera-online",
14238
+ "camera-offline",
14239
+ "camera-disabled",
14240
+ "camera-enabled"
14162
14241
  ]);
14242
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14163
14243
  /**
14164
14244
  * One coherent system-event condition. `kinds` is the required opt-in safety
14165
14245
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14168,6 +14248,18 @@ var NcSystemEventKindSchema = _enum([
14168
14248
  var NcSystemEventConditionSchema = object({
14169
14249
  kinds: array(NcSystemEventKindSchema).min(1),
14170
14250
  deviceIds: array(number().int()).min(1).optional(),
14251
+ /**
14252
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14253
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14254
+ * is what a liveness rule means when nobody said otherwise.
14255
+ *
14256
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14257
+ * one reason: the intake cannot know which devices this household cares
14258
+ * about, and a producer-side filter is one no operator can change. Fails
14259
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14260
+ * does not carry) matches no `deviceTypes` list.
14261
+ */
14262
+ deviceTypes: array(string().min(1)).min(1).optional(),
14171
14263
  nodeIds: array(string().min(1)).min(1).optional(),
14172
14264
  packageNames: array(string().min(1)).min(1).optional()
14173
14265
  });
@@ -14218,6 +14310,47 @@ var NcOccupancyConditionSchema = object({
14218
14310
  sustainSeconds: number().int().min(0).max(3600).default(15)
14219
14311
  });
14220
14312
  /**
14313
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14314
+ *
14315
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14316
+ * reference notifier uses, so an operator moving between them re-uses what
14317
+ * they already know): a rule matches when, over a sampling window of
14318
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14319
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14320
+ *
14321
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14322
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14323
+ * - `labels` — the classifier put at least one of these labels on it.
14324
+ *
14325
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14326
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14327
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14328
+ * is given** — a window in which every sample is trivially a hit would fire on
14329
+ * silence, so the engine refuses such a condition rather than notifying on
14330
+ * nothing (the schema cannot express "at least one of" without becoming a
14331
+ * ZodEffects the cap path would have to special-case).
14332
+ *
14333
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14334
+ * must be FULL before it can match — a window that has been open for two
14335
+ * seconds of its ten is 100% of nothing, and firing on it would make
14336
+ * `samplingSeconds` decorative.
14337
+ *
14338
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14339
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14340
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14341
+ * an operator who typed `dog` mean the same thing.
14342
+ */
14343
+ var NcAudioConditionSchema = object({
14344
+ /** Audio macro labels; absent = any sound (level-only rule). */
14345
+ labels: array(string().min(1)).min(1).optional(),
14346
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14347
+ dbThreshold: number().min(-96).max(0).optional(),
14348
+ /** Percentage of the window's samples that must be hits (1–100). */
14349
+ hitPercent: number().int().min(1).max(100).default(60),
14350
+ /** Length of the sampling window in seconds. */
14351
+ samplingSeconds: number().int().min(1).max(300).default(10)
14352
+ });
14353
+ /**
14221
14354
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14222
14355
  *
14223
14356
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14490,7 +14623,33 @@ var NcConditionsSchema = object({
14490
14623
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14491
14624
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14492
14625
  */
14493
- occupancy: NcOccupancyConditionSchema.optional()
14626
+ occupancy: NcOccupancyConditionSchema.optional(),
14627
+ /**
14628
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14629
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14630
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14631
+ * a window that is not full yet, neither filter given). See
14632
+ * {@link NcAudioCondition}.
14633
+ *
14634
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14635
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14636
+ * a detection, a track or a device event (the same fail-closed pairing
14637
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14638
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14639
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14640
+ * classified sample) stays exactly as it was for rules that already use it.
14641
+ *
14642
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14643
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14644
+ * (`camstack/src/data/notification-center.ts`, guarded by
14645
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14646
+ * condition fields it does not know when a rule is saved from the phone.
14647
+ * Publishing an editor for a condition the app cannot round-trip is how an
14648
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14649
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14650
+ * does an audio rule become authorable.
14651
+ */
14652
+ audio: NcAudioConditionSchema.optional()
14494
14653
  });
14495
14654
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14496
14655
  var NcRuleTargetSchema = object({
@@ -14604,6 +14763,73 @@ var NcThrottleSchema = object({
14604
14763
  */
14605
14764
  granularity: NcThrottleGranularitySchema.optional()
14606
14765
  });
14766
+ /**
14767
+ * How long the confirm gate may hold ONE notification, and how big the picture
14768
+ * it judges may be.
14769
+ *
14770
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14771
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14772
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14773
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14774
+ * tokens for pixels the model pools away.
14775
+ */
14776
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14777
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14778
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14779
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14780
+ var NcConfirmExpectSchema = object({
14781
+ op: _enum([
14782
+ ">=",
14783
+ ">",
14784
+ "<=",
14785
+ "<",
14786
+ "=="
14787
+ ]),
14788
+ count: number().int().min(0).max(1e3)
14789
+ });
14790
+ /**
14791
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14792
+ * to ship and says whether it agrees with the rule.
14793
+ *
14794
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14795
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14796
+ * on the operator's phone is not a verdict about this notification.
14797
+ *
14798
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14799
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14800
+ * the default and every fail-open is COUNTED, because a gate that always fails
14801
+ * open looks in the log exactly like a gate that works.
14802
+ *
14803
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14804
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14805
+ * production failures in one day), so the gate reads absent as the constant
14806
+ * above rather than trusting a parse it may never have seen.
14807
+ */
14808
+ var NcConfirmSchema = object({
14809
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14810
+ * same thing, and both mean "deliver exactly as before". */
14811
+ enabled: boolean().default(false),
14812
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14813
+ profileId: string().optional(),
14814
+ /**
14815
+ * The operator's question, in his own words. Absent = a question derived
14816
+ * from the rule (its class and its expectation).
14817
+ *
14818
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14819
+ * banners, signage and plates as instructions if you let them reach the
14820
+ * prompt — proven live — so the authoritative contract stays in the system
14821
+ * turn and only rule-authored words land here.
14822
+ */
14823
+ prompt: string().max(1e3).optional(),
14824
+ /** Fire only when the model's count satisfies this. Absent = the model's
14825
+ * own boolean verdict decides. */
14826
+ expect: NcConfirmExpectSchema.optional(),
14827
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14828
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14829
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14830
+ /** Longest edge the judged image is downscaled to before it is sent. */
14831
+ maxImagePx: number().int().min(64).max(2048).default(448)
14832
+ });
14607
14833
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14608
14834
  var NcRuleInputSchema = object({
14609
14835
  name: string().min(1).max(200),
@@ -14664,7 +14890,13 @@ var NcRuleInputSchema = object({
14664
14890
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14665
14891
  * shape as every other actuation.
14666
14892
  */
14667
- actions: NcRuleActionsSchema.optional()
14893
+ actions: NcRuleActionsSchema.optional(),
14894
+ /**
14895
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14896
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14897
+ * did, and absent is the only way to say that without a migration.
14898
+ */
14899
+ confirm: NcConfirmSchema.optional()
14668
14900
  });
14669
14901
  /**
14670
14902
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14675,7 +14907,37 @@ var NcRuleInputSchema = object({
14675
14907
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14676
14908
  * `updateRule` patch.
14677
14909
  */
14678
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14910
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14911
+ disabledTargetIds: array(string()).optional(),
14912
+ /**
14913
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14914
+ *
14915
+ * It makes the key optional to SUPPLY; the parse still materialises the
14916
+ * default when the key is absent. And `NcRuleStore.update` merges with
14917
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14918
+ * one — which made every partial edit destructive:
14919
+ *
14920
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14921
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14922
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14923
+ *
14924
+ * A rule scoped to one camera and one zone silently became a rule that
14925
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14926
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14927
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14928
+ * within a minute of a two-field patch.
14929
+ *
14930
+ * So every defaulted field is re-declared here WITHOUT its default. The
14931
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14932
+ * conditions remains a real instruction ("clear them") — and only the
14933
+ * absent key is now genuinely absent.
14934
+ */
14935
+ enabled: boolean().optional(),
14936
+ conditions: NcConditionsSchema.optional(),
14937
+ media: NcMediaPolicySchema.optional(),
14938
+ throttle: NcThrottleSchema.optional(),
14939
+ priority: number().int().min(1).max(5).optional()
14940
+ });
14679
14941
  /** A persisted rule. */
14680
14942
  var NcRuleSchema = NcRuleInputSchema.extend({
14681
14943
  id: string(),
@@ -14976,6 +15238,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14976
15238
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14977
15239
  * copy would lie the first time a rule is disabled.
14978
15240
  */
15241
+ /**
15242
+ * Why a device a mode NAMES is nonetheless not armed by it.
15243
+ *
15244
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15245
+ * per-camera notification switch the Notification Center already owns,
15246
+ * `detection-off` is the device's own detection binding being inactive, and
15247
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15248
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15249
+ * with the switches the operator actually used.
15250
+ */
15251
+ var NcAlarmSkipReasonSchema = _enum([
15252
+ "muted",
15253
+ "detection-off",
15254
+ "offline"
15255
+ ]);
15256
+ var NcAlarmSkippedDeviceSchema = object({
15257
+ deviceId: number().int(),
15258
+ reason: NcAlarmSkipReasonSchema
15259
+ });
14979
15260
  var NcAlarmModeCoverageSchema = object({
14980
15261
  mode: AlarmArmModeSchema,
14981
15262
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14983,7 +15264,18 @@ var NcAlarmModeCoverageSchema = object({
14983
15264
  /** At least one covering rule has no device scope, so the mode covers all. */
14984
15265
  allDevices: boolean(),
14985
15266
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14986
- deviceIds: array(number().int())
15267
+ deviceIds: array(number().int()),
15268
+ /**
15269
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15270
+ * excludes it.
15271
+ *
15272
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15273
+ * twelve makes it false in exactly the way nobody notices until an incident.
15274
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15275
+ * still parses as "nothing known to be skipped" rather than failing the whole
15276
+ * alarm tab.
15277
+ */
15278
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14987
15279
  });
14988
15280
  var NcAlarmConfigSchema = object({
14989
15281
  /**
@@ -17788,9 +18080,16 @@ var CameraStatusSchema = object({
17788
18080
  audio: CameraAudioStatusSchema.nullable(),
17789
18081
  recording: CameraRecordingStatusSchema.nullable(),
17790
18082
  /**
17791
- * Per-camera function switches an OPERATOR has turned off
18083
+ * Per-camera functions an OPERATOR has turned off
17792
18084
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17793
18085
  *
18086
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18087
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18088
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18089
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18090
+ * The badge outlives the control panel: the panel was a convenience, this is
18091
+ * the difference between a camera being off and a camera being dead.
18092
+ *
17794
18093
  * This is the difference between DISABLED and BROKEN. A camera whose
17795
18094
  * `detection` block reports zero fps and whose `switchedOff` contains
17796
18095
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -23299,7 +23598,19 @@ var RecordingManifestSchema = object({
23299
23598
  * profiles/subtrees/locations on this node). */
23300
23599
  var RecordingDeviceUsageSchema = object({
23301
23600
  deviceId: number(),
23302
- usedBytes: number()
23601
+ usedBytes: number(),
23602
+ /**
23603
+ * Start of this camera's OLDEST indexed segment, across every profile and
23604
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23605
+ * only honest answer to "is retention actually holding?" per camera.
23606
+ *
23607
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23608
+ * predates this field omits it entirely, and a hub whose types carry the
23609
+ * field must keep validating that older provider's payload: the framework
23610
+ * (types) and the addon ship on different trains, and the addon is usually
23611
+ * the later of the two.
23612
+ */
23613
+ oldestMs: number().nullable().optional()
23303
23614
  });
23304
23615
  /** Recording storage usage + capacity for one storage location. */
23305
23616
  var RecordingLocationUsageSchema = object({
@@ -23327,6 +23638,57 @@ var RecordingStorageUsageSchema = object({
23327
23638
  locations: array(RecordingLocationUsageSchema)
23328
23639
  });
23329
23640
  /**
23641
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23642
+ *
23643
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23644
+ * is the operator asking for the EXISTING archive to be brought into line with
23645
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23646
+ * location, run FIFO behind the single-flight mover.
23647
+ *
23648
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23649
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23650
+ * (empty on the plan).
23651
+ */
23652
+ var RecordingRebalanceMoveSchema = object({
23653
+ deviceId: number(),
23654
+ profile: string(),
23655
+ fromLocationId: string(),
23656
+ toLocationId: string(),
23657
+ bytes: number(),
23658
+ files: number().int()
23659
+ });
23660
+ /** Why a pile that is out of place is staying there. Every refusal is
23661
+ * reported: a rebalance that silently drops a camera reads exactly like one
23662
+ * that had nothing to do. */
23663
+ var RecordingRebalanceSkipReasonSchema = _enum([
23664
+ "unassigned",
23665
+ "target-not-writable",
23666
+ "below-threshold",
23667
+ "no-headroom"
23668
+ ]);
23669
+ var RecordingRebalanceSkipSchema = object({
23670
+ deviceId: number(),
23671
+ profile: string(),
23672
+ fromLocationId: string(),
23673
+ /** The location the plan wants; null when the camera has no assignment. */
23674
+ toLocationId: string().nullable(),
23675
+ bytes: number(),
23676
+ reason: RecordingRebalanceSkipReasonSchema
23677
+ });
23678
+ var RecordingRebalancePlanSchema = object({
23679
+ moves: array(RecordingRebalanceMoveSchema),
23680
+ skipped: array(RecordingRebalanceSkipSchema),
23681
+ bytesToMove: number(),
23682
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23683
+ jobIds: array(string())
23684
+ });
23685
+ var RecordingRebalanceInputSchema = object({
23686
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23687
+ throttleMbps: number().min(1).max(1e3).optional(),
23688
+ /** Ignore piles smaller than this (default 1 GB). */
23689
+ minMoveGb: number().min(0).optional()
23690
+ });
23691
+ /**
23330
23692
  * Result of locating footage at a wall-clock instant for one device/profile.
23331
23693
  * `segment` carries the covering segment's window; `gap` reports the forward
23332
23694
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23489,9 +23851,24 @@ method(object({
23489
23851
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23490
23852
  kind: "mutation",
23491
23853
  auth: "admin"
23854
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23855
+ kind: "mutation",
23856
+ auth: "admin"
23857
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23858
+ kind: "query",
23859
+ auth: "admin"
23860
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23861
+ kind: "mutation",
23862
+ auth: "admin"
23863
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23864
+ kind: "query",
23865
+ auth: "admin"
23866
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23867
+ kind: "mutation",
23868
+ auth: "admin"
23492
23869
  });
23493
23870
  /**
23494
- * `recordingExport` cap — render a footage time range into a single downloadable
23871
+ * `recording-export` cap — render a footage time range into a single downloadable
23495
23872
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23496
23873
  * bounded lifetime with a durable history, auto-expiry, and optional
23497
23874
  * delete-after-download.
@@ -23506,10 +23883,53 @@ method(object({
23506
23883
  */
23507
23884
  /** Playback-speed multiplier for the render (1 = realtime). */
23508
23885
  var ExportSpeedSchema = number().min(.25).max(32);
23886
+ /**
23887
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23888
+ *
23889
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23890
+ * derives these bounds from things that happened at a TIME (a track's
23891
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23892
+ * every segment present for the range, with each recording GAP removed. The
23893
+ * two agree only on a window that recorded without one interruption, and only
23894
+ * the render side knows the segments, so the translation lives there
23895
+ * (`export-dense-map.ts`, addon-pipeline).
23896
+ *
23897
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23898
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23899
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23900
+ * the video was a uniform timelapse, and the log line reported the five ranges
23901
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23902
+ *
23903
+ * Relative and not absolute epoch, because an absolute epoch would make every
23904
+ * call site responsible for the same subtraction.
23905
+ */
23906
+ var ExportDenseRangeSchema = object({
23907
+ fromSec: number().nonnegative(),
23908
+ toSec: number().nonnegative()
23909
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23910
+ /**
23911
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23912
+ * listed ranges and at the base `everyMs` everywhere else.
23913
+ *
23914
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23915
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23916
+ */
23917
+ var ExportDenseSchema = object({
23918
+ everyMs: number().int().positive(),
23919
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23920
+ });
23509
23921
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23510
23922
  var ExportTimelapseSchema = object({
23511
23923
  everyMs: number().int().positive(),
23512
- outputFps: number().int().min(1).max(60).optional()
23924
+ outputFps: number().int().min(1).max(60).optional(),
23925
+ /** Optional second, FASTER rate over the intervals that matter. */
23926
+ dense: ExportDenseSchema.optional()
23927
+ }).superRefine((v, ctx) => {
23928
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23929
+ code: ZodIssueCode.custom,
23930
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23931
+ path: ["dense", "everyMs"]
23932
+ });
23513
23933
  });
23514
23934
  /**
23515
23935
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23567,6 +23987,19 @@ var ExportDownloadSchema = object({
23567
23987
  url: string(),
23568
23988
  endpoints: array(string())
23569
23989
  });
23990
+ /**
23991
+ * A finished export's bytes, inline.
23992
+ *
23993
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23994
+ * against, so nobody has to infer it from the base64 length.
23995
+ */
23996
+ var ExportBytesSchema = object({
23997
+ base64: string(),
23998
+ contentType: string(),
23999
+ /** Suggested filename, extension included. */
24000
+ name: string(),
24001
+ bytes: number().int().nonnegative()
24002
+ });
23570
24003
  method(object({
23571
24004
  deviceId: number(),
23572
24005
  profile: string(),
@@ -23591,6 +24024,9 @@ method(object({
23591
24024
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23592
24025
  kind: "query",
23593
24026
  auth: "protected"
24027
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
24028
+ kind: "query",
24029
+ auth: "protected"
23594
24030
  });
23595
24031
  /**
23596
24032
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -28784,6 +29220,12 @@ Object.freeze({
28784
29220
  addonId: null,
28785
29221
  access: "create"
28786
29222
  },
29223
+ "recording.cancelRelocateJob": {
29224
+ capName: "recording",
29225
+ capScope: "system",
29226
+ addonId: null,
29227
+ access: "create"
29228
+ },
28787
29229
  "recording.cancelStorageMigrationMove": {
28788
29230
  capName: "recording",
28789
29231
  capScope: "system",
@@ -28838,6 +29280,12 @@ Object.freeze({
28838
29280
  addonId: null,
28839
29281
  access: "view"
28840
29282
  },
29283
+ "recording.listRelocateJobs": {
29284
+ capName: "recording",
29285
+ capScope: "system",
29286
+ addonId: null,
29287
+ access: "view"
29288
+ },
28841
29289
  "recording.locateSegment": {
28842
29290
  capName: "recording",
28843
29291
  capScope: "system",
@@ -28850,6 +29298,12 @@ Object.freeze({
28850
29298
  addonId: null,
28851
29299
  access: "create"
28852
29300
  },
29301
+ "recording.planStorageRebalance": {
29302
+ capName: "recording",
29303
+ capScope: "system",
29304
+ addonId: null,
29305
+ access: "view"
29306
+ },
28853
29307
  "recording.pruneFootage": {
28854
29308
  capName: "recording",
28855
29309
  capScope: "system",
@@ -28874,6 +29328,12 @@ Object.freeze({
28874
29328
  addonId: null,
28875
29329
  access: "create"
28876
29330
  },
29331
+ "recording.relocateFootage": {
29332
+ capName: "recording",
29333
+ capScope: "system",
29334
+ addonId: null,
29335
+ access: "create"
29336
+ },
28877
29337
  "recording.renderClip": {
28878
29338
  capName: "recording",
28879
29339
  capScope: "system",
@@ -28910,38 +29370,50 @@ Object.freeze({
28910
29370
  addonId: null,
28911
29371
  access: "create"
28912
29372
  },
29373
+ "recording.startStorageRebalance": {
29374
+ capName: "recording",
29375
+ capScope: "system",
29376
+ addonId: null,
29377
+ access: "create"
29378
+ },
28913
29379
  "recordingExport.cancelExport": {
28914
- capName: "recordingExport",
29380
+ capName: "recording-export",
28915
29381
  capScope: "system",
28916
29382
  addonId: null,
28917
29383
  access: "create"
28918
29384
  },
28919
29385
  "recordingExport.createExport": {
28920
- capName: "recordingExport",
29386
+ capName: "recording-export",
28921
29387
  capScope: "system",
28922
29388
  addonId: null,
28923
29389
  access: "create"
28924
29390
  },
28925
29391
  "recordingExport.deleteExport": {
28926
- capName: "recordingExport",
29392
+ capName: "recording-export",
28927
29393
  capScope: "system",
28928
29394
  addonId: null,
28929
29395
  access: "delete"
28930
29396
  },
28931
29397
  "recordingExport.getDownloadUrl": {
28932
- capName: "recordingExport",
29398
+ capName: "recording-export",
28933
29399
  capScope: "system",
28934
29400
  addonId: null,
28935
29401
  access: "view"
28936
29402
  },
28937
29403
  "recordingExport.getExport": {
28938
- capName: "recordingExport",
29404
+ capName: "recording-export",
28939
29405
  capScope: "system",
28940
29406
  addonId: null,
28941
29407
  access: "view"
28942
29408
  },
28943
29409
  "recordingExport.listExports": {
28944
- capName: "recordingExport",
29410
+ capName: "recording-export",
29411
+ capScope: "system",
29412
+ addonId: null,
29413
+ access: "view"
29414
+ },
29415
+ "recordingExport.readExportBytes": {
29416
+ capName: "recording-export",
28945
29417
  capScope: "system",
28946
29418
  addonId: null,
28947
29419
  access: "view"
@@ -30318,6 +30790,104 @@ var FramerateField = number().int().min(1).max(60);
30318
30790
  var TargetsField = array(NcRuleTargetSchema).min(1);
30319
30791
  var PriorityField = number().int().min(1).max(5);
30320
30792
  /**
30793
+ * Explicit override of the DENSE sampling cadence, seconds.
30794
+ *
30795
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
30796
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
30797
+ * made that same base 3 s and rendered a person pass as two frames.)
30798
+ *
30799
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
30800
+ * `denseCadenceSec` and played at `framerate` occupies
30801
+ *
30802
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
30803
+ *
30804
+ * 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.
30805
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
30806
+ * and therefore the length of a quiet night, does not move.
30807
+ *
30808
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
30809
+ * the recording has them returns the same frames, requested twice. Must be
30810
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
30811
+ * a uniform video the operator believes is two-rate — and upsert refuses it
30812
+ * rather than letting the export cap reject the render hours after the window.
30813
+ */
30814
+ var DenseCadenceSecField = number().min(.1).max(3600);
30815
+ /**
30816
+ * Minimum seconds of OUTPUT video each detection range must occupy.
30817
+ *
30818
+ * The operator-facing form of the arithmetic above: instead of solving for a
30819
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
30820
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
30821
+ * that range every ~583 ms.
30822
+ *
30823
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
30824
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
30825
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
30826
+ * ranges are sampled denser than they need. Per-range cadences require a cap
30827
+ * schema change and are the tracked follow-up.
30828
+ *
30829
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
30830
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
30831
+ * by real footage, never met by duplicating frames into motion that never
30832
+ * happened.
30833
+ */
30834
+ var MinDwellSecField = number().min(0).max(60);
30835
+ /**
30836
+ * Caption burned into the notification's preview frame.
30837
+ *
30838
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
30839
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
30840
+ * templating dialect for one field would be a second thing to explain.
30841
+ *
30842
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
30843
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
30844
+ * the reason this is not `.min(1)`.
30845
+ */
30846
+ var PreviewTextField = string().max(200);
30847
+ /**
30848
+ * Whether the notification's preview is a STILL or a short animation.
30849
+ *
30850
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
30851
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
30852
+ * night reads better as three seconds of motion than as one frame of it. Both
30853
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
30854
+ * simply applies it to a dozen frames sampled across the render and assembles
30855
+ * them.
30856
+ *
30857
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
30858
+ * seeks and a palette pass, and no rule that never asked for one should start
30859
+ * paying that on the deploy that shipped it.
30860
+ *
30861
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
30862
+ */
30863
+ var PreviewModeField = _enum(["image", "gif"]);
30864
+ /**
30865
+ * Which detection classes the notification reports counts for.
30866
+ *
30867
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
30868
+ * plan — no second query — aggregated per class. Absent or empty means "every
30869
+ * class the window actually contained", which is what an operator who never
30870
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
30871
+ * counts cars all night).
30872
+ *
30873
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
30874
+ * …). An unknown name simply never matches and reports nothing — it is not an
30875
+ * error, because a rule may legitimately name a class this camera's model does
30876
+ * not emit.
30877
+ *
30878
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
30879
+ * - `{{detections}}` — total over the reported classes
30880
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
30881
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
30882
+ * one per class, `count_` + the class name
30883
+ *
30884
+ * With NO custom body template the summary is appended to the derived body, and
30885
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
30886
+ * reads. With a custom template the operator owns every word — nothing is
30887
+ * appended, so `{{detectionSummary}}` is how he asks for it.
30888
+ */
30889
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
30890
+ /**
30321
30891
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30322
30892
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30323
30893
  * here (see the ownership note above).
@@ -30337,9 +30907,30 @@ var TimelapseRuleInputSchema = object({
30337
30907
  cadenceSec: CadenceSecField.default(15),
30338
30908
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30339
30909
  framerate: FramerateField.default(10),
30910
+ /**
30911
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
30912
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
30913
+ * field gets.
30914
+ */
30915
+ denseCadenceSec: DenseCadenceSecField.optional(),
30916
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
30917
+ minDwellSec: MinDwellSecField.optional(),
30340
30918
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30341
30919
  targets: TargetsField,
30342
30920
  template: TimelapseTemplateSchema.optional(),
30921
+ /**
30922
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
30923
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
30924
+ *
30925
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
30926
+ * the notification's title/body, and clearing it (`template: null`) must not
30927
+ * silently clear the caption too.
30928
+ */
30929
+ previewText: PreviewTextField.optional(),
30930
+ /** Still or animation — see {@link PreviewModeField}. */
30931
+ previewMode: PreviewModeField.default("image"),
30932
+ /** Classes the notification counts — see {@link ReportClassesField}. */
30933
+ reportClasses: ReportClassesField.optional(),
30343
30934
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30344
30935
  priority: PriorityField.default(3)
30345
30936
  });
@@ -30350,8 +30941,13 @@ object({
30350
30941
  schedule: NcScheduleSchema.optional(),
30351
30942
  cadenceSec: CadenceSecField.optional(),
30352
30943
  framerate: FramerateField.optional(),
30944
+ denseCadenceSec: DenseCadenceSecField.optional(),
30945
+ minDwellSec: MinDwellSecField.optional(),
30353
30946
  targets: TargetsField.optional(),
30354
30947
  template: TimelapseTemplateSchema.nullable().optional(),
30948
+ previewText: PreviewTextField.optional(),
30949
+ previewMode: PreviewModeField.optional(),
30950
+ reportClasses: ReportClassesField.optional(),
30355
30951
  priority: PriorityField.optional()
30356
30952
  });
30357
30953
  TimelapseRuleInputSchema.extend({
@@ -30363,10 +30959,28 @@ TimelapseRuleInputSchema.extend({
30363
30959
  */
30364
30960
  ownerUserId: string().optional(),
30365
30961
  /**
30366
- * Epoch-ms of the last successful generation — the 1-hour re-generation
30367
- * guard's durable state (predecessor parity). Absent = never generated.
30962
+ * Epoch-ms of the NEWEST successful generation across every camera of this
30963
+ * rule. What a UI shows, and the compatibility floor for
30964
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30368
30965
  */
30369
30966
  lastGeneratedAt: number().optional(),
30967
+ /**
30968
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
30969
+ * re-generation guard's real durable state.
30970
+ *
30971
+ * One rule covers several cameras and each renders its own video, so a rule
30972
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
30973
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
30974
+ * already done — and B's night is gone for good, because the window will not
30975
+ * come back.
30976
+ *
30977
+ * ADDITIVE, so the migration is free: a row written before this field simply
30978
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
30979
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
30980
+ * "never generated" would re-render and re-notify every camera of every rule
30981
+ * once, on the deploy that shipped the map.
30982
+ */
30983
+ generatedByDevice: record(string(), number()).optional(),
30370
30984
  /** userId of the caller who created the rule (server-stamped). */
30371
30985
  createdBy: string(),
30372
30986
  createdAt: number(),
@@ -30417,25 +31031,32 @@ object({
30417
31031
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30418
31032
  object({
30419
31033
  /**
30420
- * How long a retained native frame is served before it counts as a miss.
31034
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
31035
+ * detection result.
31036
+ *
31037
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
31038
+ * a time window was never related to the event the pixels were waiting for.
31039
+ * A held frame now lives from delivery until the runner has its `FrameResult`
31040
+ * — at which moment the runner cuts the subject tiles it actually wanted and
31041
+ * releases the frame. The bound exists only so a runner that stops answering
31042
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
30421
31043
  *
30422
- * Must cover the FULL late-crop horizon: detection inference + the
30423
- * cross-process inference-result hop to hub post-analysis + tracking + the
30424
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30425
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30426
- * RAM per busy camera grows linearly with no measured hit-rate gain.
31044
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
31045
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
31046
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
31047
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
31048
+ * `holdOverflow` on the metrics line is what says you need it.
30427
31049
  */
30428
- ttlMs: number().int().min(250).max(1e4),
31050
+ holdFrames: number().int().min(1).max(64),
30429
31051
  /**
30430
31052
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30431
31053
  *
30432
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30433
- * which one is actually binding before reasoning from that. At the shipped
30434
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30435
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30436
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30437
- * change that admits fewer frames buys retention WINDOW at constant RAM
30438
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
31054
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
31055
+ * is what decides how much is held, and the ceiling is the number above which
31056
+ * something is wrong. Before that it was the effective cap — at 1024 MB with
31057
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
31058
+ * with the TTL expiring nothing, which is exactly the confusion the hold
31059
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30439
31060
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30440
31061
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30441
31062
  * to replace).
@@ -30461,22 +31082,45 @@ object({
30461
31082
  * there is the signal that some caller names frames outside the inference set
30462
31083
  * and that this must go back to `all`.
30463
31084
  */
30464
- admission: NativeLeaseAdmissionSchema
31085
+ admission: NativeLeaseAdmissionSchema,
31086
+ /**
31087
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
31088
+ * compressed native crops the worker cuts at the moment a frame's detection
31089
+ * result arrives, and keeps long after the frame itself is freed.
31090
+ *
31091
+ * This is the knob that replaced the old retention window, and it buys about
31092
+ * three orders of magnitude more of it: a tile is one subject at native
31093
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
31094
+ * the frame it was cut from. A frame on which nothing was detected costs
31095
+ * nothing at all, which is the real change — the old lease paid per FRAME and
31096
+ * was interrogated per SUBJECT.
31097
+ *
31098
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
31099
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
31100
+ * reproduce that.
31101
+ */
31102
+ tileBudgetMb: number().int().min(0).max(1024)
30465
31103
  });
30466
31104
  /**
30467
- * The values in force when the operator has set nothing — byte-for-byte the
30468
- * constants the decode worker shipped with as env-var defaults, so making these
30469
- * settings changed no behaviour on the day it landed.
31105
+ * The values in force when the operator has set nothing.
31106
+ *
31107
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
31108
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
31109
+ * in the same change that redefines it would make a regression and a retune
31110
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
31111
+ * live traffic.
30470
31112
  */
30471
31113
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30472
- ttlMs: 1200,
31114
+ holdFrames: 8,
30473
31115
  budgetMb: 1024,
30474
31116
  activityMs: 15e3,
31117
+ tileBudgetMb: 64,
30475
31118
  admission: "inferred"
30476
31119
  };
30477
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
31120
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30478
31121
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30479
31122
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
31123
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30480
31124
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30481
31125
  //#endregion
30482
31126
  //#region src/custom-actions.ts