@camstack/addon-provider-gree 0.2.12 → 0.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/addon.js +686 -42
  2. package/dist/addon.mjs +686 -42
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -7221,8 +7221,31 @@ var AdoptionJobSchema = object({
7221
7221
  error: string().nullable()
7222
7222
  });
7223
7223
  /**
7224
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7225
- * pipeline functions an operator thinks in terms of.
7224
+ * Per-camera FUNCTION SWITCHES.
7225
+ *
7226
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7227
+ *
7228
+ * This file shipped as "the one coherent on/off surface over the pipeline
7229
+ * functions an operator thinks in terms of". The operator's verdict on
7230
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7231
+ * every function already had a settings page of its own, and a second place to
7232
+ * turn it off is a second place to look. Each switch is going back to its own
7233
+ * component's original options — detection to the detection-pipeline wrapper
7234
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7235
+ * (which was always first-class; the switch was a veneer over
7236
+ * `recording.setDeviceConfig`), notifications to a notification-center
7237
+ * per-device setting, the two camera planes to their own components.
7238
+ *
7239
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7240
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7241
+ * straight from the authorities with no group in the middle. That rule was
7242
+ * never about a control panel.
7243
+ *
7244
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7245
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7246
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7247
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7248
+ * stop; nothing new may be built on it.
7226
7249
  *
7227
7250
  * ## This file adds no state
7228
7251
  *
@@ -7573,7 +7596,15 @@ var RecordingConfigSchema = object({
7573
7596
  * Each completed/failed run also lands one durable ops-log row on its owning
7574
7597
  * addon surface.
7575
7598
  */
7599
+ /**
7600
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7601
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7602
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7603
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7604
+ * runs at all.
7605
+ */
7576
7606
  var RelocateJobStateSchema = _enum([
7607
+ "queued",
7577
7608
  "running",
7578
7609
  "done",
7579
7610
  "failed",
@@ -7608,6 +7639,15 @@ var RelocateFootageInputSchema = object({
7608
7639
  /** Limits relocation to the logical profile class. Omit only for the
7609
7640
  * pre-orchestration compatibility path. */
7610
7641
  footageClass: RelocateFootageClassSchema.optional(),
7642
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7643
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7644
+ * unit is a (camera, profile) pile, not a disk. */
7645
+ deviceId: number().int().optional(),
7646
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7647
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7648
+ * placement plan assigns those two independently, so a rebalance that could
7649
+ * only say "recordings" would move footage the plan never asked to move. */
7650
+ profiles: array(string()).optional(),
7611
7651
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7612
7652
  * never allowed to starve live writers. */
7613
7653
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7743,6 +7783,21 @@ var StorageLocationSchema = object({
7743
7783
  nodeId: string().optional(),
7744
7784
  isDefault: boolean().default(false),
7745
7785
  isSystem: boolean().default(false),
7786
+ /**
7787
+ * Operator opt-in: whether consumers that BALANCE across several locations
7788
+ * of a type may write here. Recordings reads it today; event media and
7789
+ * backups are the next consumers, which is why the flag lives on the
7790
+ * location rather than in any one addon's store — nothing has to be
7791
+ * extended to add the next consumer.
7792
+ *
7793
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7794
+ * flag existed reads back with no flag and keeps working exactly as before;
7795
+ * that is the whole compat story, and it is why no migration ships with it.
7796
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7797
+ * disk must not silently start writing to it); the default of a type is
7798
+ * always stamped `true`.
7799
+ */
7800
+ enabled: boolean().optional(),
7746
7801
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7747
7802
  * for node-local locations it can reach) — never persisted, absent when the
7748
7803
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12295,7 +12350,8 @@ method(object({
12295
12350
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12296
12351
  /**
12297
12352
  * filesystem-browse — per-node capability for browsing the node's local
12298
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12353
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12354
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12299
12355
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12300
12356
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12301
12357
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14136,6 +14192,13 @@ var MaskGridDimsSchema = object({
14136
14192
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14137
14193
  * this one field keeps the schema additive — a rule still declares exactly
14138
14194
  * one trigger.
14195
+ *
14196
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14197
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14198
+ * mirror.ts` fails the build on a member the app cannot render) and every
14199
+ * member costs a release train. A sustained-sound rule is therefore an
14200
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14201
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14139
14202
  */
14140
14203
  var NcDeliverySchema = _enum([
14141
14204
  "immediate",
@@ -14150,15 +14213,32 @@ var NcDeliverySchema = _enum([
14150
14213
  * depend on a provider's raw event name or payload shape.
14151
14214
  */
14152
14215
  var NcSystemEventKindSchema = _enum([
14153
- "camera-online",
14154
- "camera-offline",
14216
+ "device-online",
14217
+ "device-offline",
14218
+ "device-disabled",
14219
+ "device-enabled",
14155
14220
  "stream-online",
14156
14221
  "stream-offline",
14157
14222
  "node-online",
14158
14223
  "node-offline",
14159
14224
  "addon-update-available",
14160
- "server-update-available"
14225
+ "server-update-available",
14226
+ "alarm-triggered",
14227
+ "alarm-armed",
14228
+ "alarm-disarmed",
14229
+ "camera-online",
14230
+ "camera-offline",
14231
+ "camera-disabled",
14232
+ "camera-enabled"
14233
+ ]);
14234
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14235
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14236
+ "camera-online",
14237
+ "camera-offline",
14238
+ "camera-disabled",
14239
+ "camera-enabled"
14161
14240
  ]);
14241
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14162
14242
  /**
14163
14243
  * One coherent system-event condition. `kinds` is the required opt-in safety
14164
14244
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14167,6 +14247,18 @@ var NcSystemEventKindSchema = _enum([
14167
14247
  var NcSystemEventConditionSchema = object({
14168
14248
  kinds: array(NcSystemEventKindSchema).min(1),
14169
14249
  deviceIds: array(number().int()).min(1).optional(),
14250
+ /**
14251
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14252
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14253
+ * is what a liveness rule means when nobody said otherwise.
14254
+ *
14255
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14256
+ * one reason: the intake cannot know which devices this household cares
14257
+ * about, and a producer-side filter is one no operator can change. Fails
14258
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14259
+ * does not carry) matches no `deviceTypes` list.
14260
+ */
14261
+ deviceTypes: array(string().min(1)).min(1).optional(),
14170
14262
  nodeIds: array(string().min(1)).min(1).optional(),
14171
14263
  packageNames: array(string().min(1)).min(1).optional()
14172
14264
  });
@@ -14217,6 +14309,47 @@ var NcOccupancyConditionSchema = object({
14217
14309
  sustainSeconds: number().int().min(0).max(3600).default(15)
14218
14310
  });
14219
14311
  /**
14312
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14313
+ *
14314
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14315
+ * reference notifier uses, so an operator moving between them re-uses what
14316
+ * they already know): a rule matches when, over a sampling window of
14317
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14318
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14319
+ *
14320
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14321
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14322
+ * - `labels` — the classifier put at least one of these labels on it.
14323
+ *
14324
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14325
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14326
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14327
+ * is given** — a window in which every sample is trivially a hit would fire on
14328
+ * silence, so the engine refuses such a condition rather than notifying on
14329
+ * nothing (the schema cannot express "at least one of" without becoming a
14330
+ * ZodEffects the cap path would have to special-case).
14331
+ *
14332
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14333
+ * must be FULL before it can match — a window that has been open for two
14334
+ * seconds of its ten is 100% of nothing, and firing on it would make
14335
+ * `samplingSeconds` decorative.
14336
+ *
14337
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14338
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14339
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14340
+ * an operator who typed `dog` mean the same thing.
14341
+ */
14342
+ var NcAudioConditionSchema = object({
14343
+ /** Audio macro labels; absent = any sound (level-only rule). */
14344
+ labels: array(string().min(1)).min(1).optional(),
14345
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14346
+ dbThreshold: number().min(-96).max(0).optional(),
14347
+ /** Percentage of the window's samples that must be hits (1–100). */
14348
+ hitPercent: number().int().min(1).max(100).default(60),
14349
+ /** Length of the sampling window in seconds. */
14350
+ samplingSeconds: number().int().min(1).max(300).default(10)
14351
+ });
14352
+ /**
14220
14353
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14221
14354
  *
14222
14355
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14489,7 +14622,33 @@ var NcConditionsSchema = object({
14489
14622
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14490
14623
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14491
14624
  */
14492
- occupancy: NcOccupancyConditionSchema.optional()
14625
+ occupancy: NcOccupancyConditionSchema.optional(),
14626
+ /**
14627
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14628
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14629
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14630
+ * a window that is not full yet, neither filter given). See
14631
+ * {@link NcAudioCondition}.
14632
+ *
14633
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14634
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14635
+ * a detection, a track or a device event (the same fail-closed pairing
14636
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14637
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14638
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14639
+ * classified sample) stays exactly as it was for rules that already use it.
14640
+ *
14641
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14642
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14643
+ * (`camstack/src/data/notification-center.ts`, guarded by
14644
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14645
+ * condition fields it does not know when a rule is saved from the phone.
14646
+ * Publishing an editor for a condition the app cannot round-trip is how an
14647
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14648
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14649
+ * does an audio rule become authorable.
14650
+ */
14651
+ audio: NcAudioConditionSchema.optional()
14493
14652
  });
14494
14653
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14495
14654
  var NcRuleTargetSchema = object({
@@ -14603,6 +14762,73 @@ var NcThrottleSchema = object({
14603
14762
  */
14604
14763
  granularity: NcThrottleGranularitySchema.optional()
14605
14764
  });
14765
+ /**
14766
+ * How long the confirm gate may hold ONE notification, and how big the picture
14767
+ * it judges may be.
14768
+ *
14769
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14770
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14771
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14772
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14773
+ * tokens for pixels the model pools away.
14774
+ */
14775
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14776
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14777
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14778
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14779
+ var NcConfirmExpectSchema = object({
14780
+ op: _enum([
14781
+ ">=",
14782
+ ">",
14783
+ "<=",
14784
+ "<",
14785
+ "=="
14786
+ ]),
14787
+ count: number().int().min(0).max(1e3)
14788
+ });
14789
+ /**
14790
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14791
+ * to ship and says whether it agrees with the rule.
14792
+ *
14793
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14794
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14795
+ * on the operator's phone is not a verdict about this notification.
14796
+ *
14797
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14798
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14799
+ * the default and every fail-open is COUNTED, because a gate that always fails
14800
+ * open looks in the log exactly like a gate that works.
14801
+ *
14802
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14803
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14804
+ * production failures in one day), so the gate reads absent as the constant
14805
+ * above rather than trusting a parse it may never have seen.
14806
+ */
14807
+ var NcConfirmSchema = object({
14808
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14809
+ * same thing, and both mean "deliver exactly as before". */
14810
+ enabled: boolean().default(false),
14811
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14812
+ profileId: string().optional(),
14813
+ /**
14814
+ * The operator's question, in his own words. Absent = a question derived
14815
+ * from the rule (its class and its expectation).
14816
+ *
14817
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14818
+ * banners, signage and plates as instructions if you let them reach the
14819
+ * prompt — proven live — so the authoritative contract stays in the system
14820
+ * turn and only rule-authored words land here.
14821
+ */
14822
+ prompt: string().max(1e3).optional(),
14823
+ /** Fire only when the model's count satisfies this. Absent = the model's
14824
+ * own boolean verdict decides. */
14825
+ expect: NcConfirmExpectSchema.optional(),
14826
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14827
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14828
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14829
+ /** Longest edge the judged image is downscaled to before it is sent. */
14830
+ maxImagePx: number().int().min(64).max(2048).default(448)
14831
+ });
14606
14832
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14607
14833
  var NcRuleInputSchema = object({
14608
14834
  name: string().min(1).max(200),
@@ -14663,7 +14889,13 @@ var NcRuleInputSchema = object({
14663
14889
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14664
14890
  * shape as every other actuation.
14665
14891
  */
14666
- actions: NcRuleActionsSchema.optional()
14892
+ actions: NcRuleActionsSchema.optional(),
14893
+ /**
14894
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14895
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14896
+ * did, and absent is the only way to say that without a migration.
14897
+ */
14898
+ confirm: NcConfirmSchema.optional()
14667
14899
  });
14668
14900
  /**
14669
14901
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14674,7 +14906,37 @@ var NcRuleInputSchema = object({
14674
14906
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14675
14907
  * `updateRule` patch.
14676
14908
  */
14677
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14909
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14910
+ disabledTargetIds: array(string()).optional(),
14911
+ /**
14912
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14913
+ *
14914
+ * It makes the key optional to SUPPLY; the parse still materialises the
14915
+ * default when the key is absent. And `NcRuleStore.update` merges with
14916
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14917
+ * one — which made every partial edit destructive:
14918
+ *
14919
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14920
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14921
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14922
+ *
14923
+ * A rule scoped to one camera and one zone silently became a rule that
14924
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14925
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14926
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14927
+ * within a minute of a two-field patch.
14928
+ *
14929
+ * So every defaulted field is re-declared here WITHOUT its default. The
14930
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14931
+ * conditions remains a real instruction ("clear them") — and only the
14932
+ * absent key is now genuinely absent.
14933
+ */
14934
+ enabled: boolean().optional(),
14935
+ conditions: NcConditionsSchema.optional(),
14936
+ media: NcMediaPolicySchema.optional(),
14937
+ throttle: NcThrottleSchema.optional(),
14938
+ priority: number().int().min(1).max(5).optional()
14939
+ });
14678
14940
  /** A persisted rule. */
14679
14941
  var NcRuleSchema = NcRuleInputSchema.extend({
14680
14942
  id: string(),
@@ -14975,6 +15237,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14975
15237
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14976
15238
  * copy would lie the first time a rule is disabled.
14977
15239
  */
15240
+ /**
15241
+ * Why a device a mode NAMES is nonetheless not armed by it.
15242
+ *
15243
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15244
+ * per-camera notification switch the Notification Center already owns,
15245
+ * `detection-off` is the device's own detection binding being inactive, and
15246
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15247
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15248
+ * with the switches the operator actually used.
15249
+ */
15250
+ var NcAlarmSkipReasonSchema = _enum([
15251
+ "muted",
15252
+ "detection-off",
15253
+ "offline"
15254
+ ]);
15255
+ var NcAlarmSkippedDeviceSchema = object({
15256
+ deviceId: number().int(),
15257
+ reason: NcAlarmSkipReasonSchema
15258
+ });
14978
15259
  var NcAlarmModeCoverageSchema = object({
14979
15260
  mode: AlarmArmModeSchema,
14980
15261
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14982,7 +15263,18 @@ var NcAlarmModeCoverageSchema = object({
14982
15263
  /** At least one covering rule has no device scope, so the mode covers all. */
14983
15264
  allDevices: boolean(),
14984
15265
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14985
- deviceIds: array(number().int())
15266
+ deviceIds: array(number().int()),
15267
+ /**
15268
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15269
+ * excludes it.
15270
+ *
15271
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15272
+ * twelve makes it false in exactly the way nobody notices until an incident.
15273
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15274
+ * still parses as "nothing known to be skipped" rather than failing the whole
15275
+ * alarm tab.
15276
+ */
15277
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14986
15278
  });
14987
15279
  var NcAlarmConfigSchema = object({
14988
15280
  /**
@@ -17814,9 +18106,16 @@ var CameraStatusSchema = object({
17814
18106
  audio: CameraAudioStatusSchema.nullable(),
17815
18107
  recording: CameraRecordingStatusSchema.nullable(),
17816
18108
  /**
17817
- * Per-camera function switches an OPERATOR has turned off
18109
+ * Per-camera functions an OPERATOR has turned off
17818
18110
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17819
18111
  *
18112
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18113
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18114
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18115
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18116
+ * The badge outlives the control panel: the panel was a convenience, this is
18117
+ * the difference between a camera being off and a camera being dead.
18118
+ *
17820
18119
  * This is the difference between DISABLED and BROKEN. A camera whose
17821
18120
  * `detection` block reports zero fps and whose `switchedOff` contains
17822
18121
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -24558,7 +24857,19 @@ var RecordingManifestSchema = object({
24558
24857
  * profiles/subtrees/locations on this node). */
24559
24858
  var RecordingDeviceUsageSchema = object({
24560
24859
  deviceId: number(),
24561
- usedBytes: number()
24860
+ usedBytes: number(),
24861
+ /**
24862
+ * Start of this camera's OLDEST indexed segment, across every profile and
24863
+ * location — the "Oldest footage" column in Recordings → Storage, and the
24864
+ * only honest answer to "is retention actually holding?" per camera.
24865
+ *
24866
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
24867
+ * predates this field omits it entirely, and a hub whose types carry the
24868
+ * field must keep validating that older provider's payload: the framework
24869
+ * (types) and the addon ship on different trains, and the addon is usually
24870
+ * the later of the two.
24871
+ */
24872
+ oldestMs: number().nullable().optional()
24562
24873
  });
24563
24874
  /** Recording storage usage + capacity for one storage location. */
24564
24875
  var RecordingLocationUsageSchema = object({
@@ -24586,6 +24897,57 @@ var RecordingStorageUsageSchema = object({
24586
24897
  locations: array(RecordingLocationUsageSchema)
24587
24898
  });
24588
24899
  /**
24900
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
24901
+ *
24902
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
24903
+ * is the operator asking for the EXISTING archive to be brought into line with
24904
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
24905
+ * location, run FIFO behind the single-flight mover.
24906
+ *
24907
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
24908
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
24909
+ * (empty on the plan).
24910
+ */
24911
+ var RecordingRebalanceMoveSchema = object({
24912
+ deviceId: number(),
24913
+ profile: string(),
24914
+ fromLocationId: string(),
24915
+ toLocationId: string(),
24916
+ bytes: number(),
24917
+ files: number().int()
24918
+ });
24919
+ /** Why a pile that is out of place is staying there. Every refusal is
24920
+ * reported: a rebalance that silently drops a camera reads exactly like one
24921
+ * that had nothing to do. */
24922
+ var RecordingRebalanceSkipReasonSchema = _enum([
24923
+ "unassigned",
24924
+ "target-not-writable",
24925
+ "below-threshold",
24926
+ "no-headroom"
24927
+ ]);
24928
+ var RecordingRebalanceSkipSchema = object({
24929
+ deviceId: number(),
24930
+ profile: string(),
24931
+ fromLocationId: string(),
24932
+ /** The location the plan wants; null when the camera has no assignment. */
24933
+ toLocationId: string().nullable(),
24934
+ bytes: number(),
24935
+ reason: RecordingRebalanceSkipReasonSchema
24936
+ });
24937
+ var RecordingRebalancePlanSchema = object({
24938
+ moves: array(RecordingRebalanceMoveSchema),
24939
+ skipped: array(RecordingRebalanceSkipSchema),
24940
+ bytesToMove: number(),
24941
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
24942
+ jobIds: array(string())
24943
+ });
24944
+ var RecordingRebalanceInputSchema = object({
24945
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
24946
+ throttleMbps: number().min(1).max(1e3).optional(),
24947
+ /** Ignore piles smaller than this (default 1 GB). */
24948
+ minMoveGb: number().min(0).optional()
24949
+ });
24950
+ /**
24589
24951
  * Result of locating footage at a wall-clock instant for one device/profile.
24590
24952
  * `segment` carries the covering segment's window; `gap` reports the forward
24591
24953
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -24748,9 +25110,24 @@ method(object({
24748
25110
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24749
25111
  kind: "mutation",
24750
25112
  auth: "admin"
25113
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25114
+ kind: "mutation",
25115
+ auth: "admin"
25116
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25117
+ kind: "query",
25118
+ auth: "admin"
25119
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25120
+ kind: "mutation",
25121
+ auth: "admin"
25122
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25123
+ kind: "query",
25124
+ auth: "admin"
25125
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25126
+ kind: "mutation",
25127
+ auth: "admin"
24751
25128
  });
24752
25129
  /**
24753
- * `recordingExport` cap — render a footage time range into a single downloadable
25130
+ * `recording-export` cap — render a footage time range into a single downloadable
24754
25131
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
24755
25132
  * bounded lifetime with a durable history, auto-expiry, and optional
24756
25133
  * delete-after-download.
@@ -24765,10 +25142,53 @@ method(object({
24765
25142
  */
24766
25143
  /** Playback-speed multiplier for the render (1 = realtime). */
24767
25144
  var ExportSpeedSchema = number().min(.25).max(32);
25145
+ /**
25146
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25147
+ *
25148
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25149
+ * derives these bounds from things that happened at a TIME (a track's
25150
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25151
+ * every segment present for the range, with each recording GAP removed. The
25152
+ * two agree only on a window that recorded without one interruption, and only
25153
+ * the render side knows the segments, so the translation lives there
25154
+ * (`export-dense-map.ts`, addon-pipeline).
25155
+ *
25156
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25157
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25158
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25159
+ * the video was a uniform timelapse, and the log line reported the five ranges
25160
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25161
+ *
25162
+ * Relative and not absolute epoch, because an absolute epoch would make every
25163
+ * call site responsible for the same subtraction.
25164
+ */
25165
+ var ExportDenseRangeSchema = object({
25166
+ fromSec: number().nonnegative(),
25167
+ toSec: number().nonnegative()
25168
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25169
+ /**
25170
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25171
+ * listed ranges and at the base `everyMs` everywhere else.
25172
+ *
25173
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25174
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25175
+ */
25176
+ var ExportDenseSchema = object({
25177
+ everyMs: number().int().positive(),
25178
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25179
+ });
24768
25180
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
24769
25181
  var ExportTimelapseSchema = object({
24770
25182
  everyMs: number().int().positive(),
24771
- outputFps: number().int().min(1).max(60).optional()
25183
+ outputFps: number().int().min(1).max(60).optional(),
25184
+ /** Optional second, FASTER rate over the intervals that matter. */
25185
+ dense: ExportDenseSchema.optional()
25186
+ }).superRefine((v, ctx) => {
25187
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25188
+ code: ZodIssueCode.custom,
25189
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25190
+ path: ["dense", "everyMs"]
25191
+ });
24772
25192
  });
24773
25193
  /**
24774
25194
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -24826,6 +25246,19 @@ var ExportDownloadSchema = object({
24826
25246
  url: string(),
24827
25247
  endpoints: array(string())
24828
25248
  });
25249
+ /**
25250
+ * A finished export's bytes, inline.
25251
+ *
25252
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25253
+ * against, so nobody has to infer it from the base64 length.
25254
+ */
25255
+ var ExportBytesSchema = object({
25256
+ base64: string(),
25257
+ contentType: string(),
25258
+ /** Suggested filename, extension included. */
25259
+ name: string(),
25260
+ bytes: number().int().nonnegative()
25261
+ });
24829
25262
  method(object({
24830
25263
  deviceId: number(),
24831
25264
  profile: string(),
@@ -24850,6 +25283,9 @@ method(object({
24850
25283
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
24851
25284
  kind: "query",
24852
25285
  auth: "protected"
25286
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25287
+ kind: "query",
25288
+ auth: "protected"
24853
25289
  });
24854
25290
  /**
24855
25291
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -31527,6 +31963,12 @@ Object.freeze({
31527
31963
  addonId: null,
31528
31964
  access: "create"
31529
31965
  },
31966
+ "recording.cancelRelocateJob": {
31967
+ capName: "recording",
31968
+ capScope: "system",
31969
+ addonId: null,
31970
+ access: "create"
31971
+ },
31530
31972
  "recording.cancelStorageMigrationMove": {
31531
31973
  capName: "recording",
31532
31974
  capScope: "system",
@@ -31581,6 +32023,12 @@ Object.freeze({
31581
32023
  addonId: null,
31582
32024
  access: "view"
31583
32025
  },
32026
+ "recording.listRelocateJobs": {
32027
+ capName: "recording",
32028
+ capScope: "system",
32029
+ addonId: null,
32030
+ access: "view"
32031
+ },
31584
32032
  "recording.locateSegment": {
31585
32033
  capName: "recording",
31586
32034
  capScope: "system",
@@ -31593,6 +32041,12 @@ Object.freeze({
31593
32041
  addonId: null,
31594
32042
  access: "create"
31595
32043
  },
32044
+ "recording.planStorageRebalance": {
32045
+ capName: "recording",
32046
+ capScope: "system",
32047
+ addonId: null,
32048
+ access: "view"
32049
+ },
31596
32050
  "recording.pruneFootage": {
31597
32051
  capName: "recording",
31598
32052
  capScope: "system",
@@ -31617,6 +32071,12 @@ Object.freeze({
31617
32071
  addonId: null,
31618
32072
  access: "create"
31619
32073
  },
32074
+ "recording.relocateFootage": {
32075
+ capName: "recording",
32076
+ capScope: "system",
32077
+ addonId: null,
32078
+ access: "create"
32079
+ },
31620
32080
  "recording.renderClip": {
31621
32081
  capName: "recording",
31622
32082
  capScope: "system",
@@ -31653,38 +32113,50 @@ Object.freeze({
31653
32113
  addonId: null,
31654
32114
  access: "create"
31655
32115
  },
32116
+ "recording.startStorageRebalance": {
32117
+ capName: "recording",
32118
+ capScope: "system",
32119
+ addonId: null,
32120
+ access: "create"
32121
+ },
31656
32122
  "recordingExport.cancelExport": {
31657
- capName: "recordingExport",
32123
+ capName: "recording-export",
31658
32124
  capScope: "system",
31659
32125
  addonId: null,
31660
32126
  access: "create"
31661
32127
  },
31662
32128
  "recordingExport.createExport": {
31663
- capName: "recordingExport",
32129
+ capName: "recording-export",
31664
32130
  capScope: "system",
31665
32131
  addonId: null,
31666
32132
  access: "create"
31667
32133
  },
31668
32134
  "recordingExport.deleteExport": {
31669
- capName: "recordingExport",
32135
+ capName: "recording-export",
31670
32136
  capScope: "system",
31671
32137
  addonId: null,
31672
32138
  access: "delete"
31673
32139
  },
31674
32140
  "recordingExport.getDownloadUrl": {
31675
- capName: "recordingExport",
32141
+ capName: "recording-export",
31676
32142
  capScope: "system",
31677
32143
  addonId: null,
31678
32144
  access: "view"
31679
32145
  },
31680
32146
  "recordingExport.getExport": {
31681
- capName: "recordingExport",
32147
+ capName: "recording-export",
31682
32148
  capScope: "system",
31683
32149
  addonId: null,
31684
32150
  access: "view"
31685
32151
  },
31686
32152
  "recordingExport.listExports": {
31687
- capName: "recordingExport",
32153
+ capName: "recording-export",
32154
+ capScope: "system",
32155
+ addonId: null,
32156
+ access: "view"
32157
+ },
32158
+ "recordingExport.readExportBytes": {
32159
+ capName: "recording-export",
31688
32160
  capScope: "system",
31689
32161
  addonId: null,
31690
32162
  access: "view"
@@ -33061,6 +33533,104 @@ var FramerateField = number().int().min(1).max(60);
33061
33533
  var TargetsField = array(NcRuleTargetSchema).min(1);
33062
33534
  var PriorityField = number().int().min(1).max(5);
33063
33535
  /**
33536
+ * Explicit override of the DENSE sampling cadence, seconds.
33537
+ *
33538
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
33539
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
33540
+ * made that same base 3 s and rendered a person pass as two frames.)
33541
+ *
33542
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
33543
+ * `denseCadenceSec` and played at `framerate` occupies
33544
+ *
33545
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
33546
+ *
33547
+ * 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.
33548
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
33549
+ * and therefore the length of a quiet night, does not move.
33550
+ *
33551
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
33552
+ * the recording has them returns the same frames, requested twice. Must be
33553
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
33554
+ * a uniform video the operator believes is two-rate — and upsert refuses it
33555
+ * rather than letting the export cap reject the render hours after the window.
33556
+ */
33557
+ var DenseCadenceSecField = number().min(.1).max(3600);
33558
+ /**
33559
+ * Minimum seconds of OUTPUT video each detection range must occupy.
33560
+ *
33561
+ * The operator-facing form of the arithmetic above: instead of solving for a
33562
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
33563
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
33564
+ * that range every ~583 ms.
33565
+ *
33566
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
33567
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
33568
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
33569
+ * ranges are sampled denser than they need. Per-range cadences require a cap
33570
+ * schema change and are the tracked follow-up.
33571
+ *
33572
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
33573
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
33574
+ * by real footage, never met by duplicating frames into motion that never
33575
+ * happened.
33576
+ */
33577
+ var MinDwellSecField = number().min(0).max(60);
33578
+ /**
33579
+ * Caption burned into the notification's preview frame.
33580
+ *
33581
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
33582
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
33583
+ * templating dialect for one field would be a second thing to explain.
33584
+ *
33585
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
33586
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
33587
+ * the reason this is not `.min(1)`.
33588
+ */
33589
+ var PreviewTextField = string().max(200);
33590
+ /**
33591
+ * Whether the notification's preview is a STILL or a short animation.
33592
+ *
33593
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
33594
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
33595
+ * night reads better as three seconds of motion than as one frame of it. Both
33596
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
33597
+ * simply applies it to a dozen frames sampled across the render and assembles
33598
+ * them.
33599
+ *
33600
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
33601
+ * seeks and a palette pass, and no rule that never asked for one should start
33602
+ * paying that on the deploy that shipped it.
33603
+ *
33604
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
33605
+ */
33606
+ var PreviewModeField = _enum(["image", "gif"]);
33607
+ /**
33608
+ * Which detection classes the notification reports counts for.
33609
+ *
33610
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
33611
+ * plan — no second query — aggregated per class. Absent or empty means "every
33612
+ * class the window actually contained", which is what an operator who never
33613
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
33614
+ * counts cars all night).
33615
+ *
33616
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
33617
+ * …). An unknown name simply never matches and reports nothing — it is not an
33618
+ * error, because a rule may legitimately name a class this camera's model does
33619
+ * not emit.
33620
+ *
33621
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
33622
+ * - `{{detections}}` — total over the reported classes
33623
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
33624
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
33625
+ * one per class, `count_` + the class name
33626
+ *
33627
+ * With NO custom body template the summary is appended to the derived body, and
33628
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
33629
+ * reads. With a custom template the operator owns every word — nothing is
33630
+ * appended, so `{{detectionSummary}}` is how he asks for it.
33631
+ */
33632
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
33633
+ /**
33064
33634
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33065
33635
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33066
33636
  * here (see the ownership note above).
@@ -33080,9 +33650,30 @@ var TimelapseRuleInputSchema = object({
33080
33650
  cadenceSec: CadenceSecField.default(15),
33081
33651
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33082
33652
  framerate: FramerateField.default(10),
33653
+ /**
33654
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
33655
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
33656
+ * field gets.
33657
+ */
33658
+ denseCadenceSec: DenseCadenceSecField.optional(),
33659
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
33660
+ minDwellSec: MinDwellSecField.optional(),
33083
33661
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33084
33662
  targets: TargetsField,
33085
33663
  template: TimelapseTemplateSchema.optional(),
33664
+ /**
33665
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
33666
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
33667
+ *
33668
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
33669
+ * the notification's title/body, and clearing it (`template: null`) must not
33670
+ * silently clear the caption too.
33671
+ */
33672
+ previewText: PreviewTextField.optional(),
33673
+ /** Still or animation — see {@link PreviewModeField}. */
33674
+ previewMode: PreviewModeField.default("image"),
33675
+ /** Classes the notification counts — see {@link ReportClassesField}. */
33676
+ reportClasses: ReportClassesField.optional(),
33086
33677
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33087
33678
  priority: PriorityField.default(3)
33088
33679
  });
@@ -33093,8 +33684,13 @@ object({
33093
33684
  schedule: NcScheduleSchema.optional(),
33094
33685
  cadenceSec: CadenceSecField.optional(),
33095
33686
  framerate: FramerateField.optional(),
33687
+ denseCadenceSec: DenseCadenceSecField.optional(),
33688
+ minDwellSec: MinDwellSecField.optional(),
33096
33689
  targets: TargetsField.optional(),
33097
33690
  template: TimelapseTemplateSchema.nullable().optional(),
33691
+ previewText: PreviewTextField.optional(),
33692
+ previewMode: PreviewModeField.optional(),
33693
+ reportClasses: ReportClassesField.optional(),
33098
33694
  priority: PriorityField.optional()
33099
33695
  });
33100
33696
  TimelapseRuleInputSchema.extend({
@@ -33106,10 +33702,28 @@ TimelapseRuleInputSchema.extend({
33106
33702
  */
33107
33703
  ownerUserId: string().optional(),
33108
33704
  /**
33109
- * Epoch-ms of the last successful generation the 1-hour re-generation
33110
- * guard's durable state (predecessor parity). Absent = never generated.
33705
+ * Epoch-ms of the NEWEST successful generation across every camera of this
33706
+ * rule. What a UI shows, and the compatibility floor for
33707
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33111
33708
  */
33112
33709
  lastGeneratedAt: number().optional(),
33710
+ /**
33711
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
33712
+ * re-generation guard's real durable state.
33713
+ *
33714
+ * One rule covers several cameras and each renders its own video, so a rule
33715
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
33716
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
33717
+ * already done — and B's night is gone for good, because the window will not
33718
+ * come back.
33719
+ *
33720
+ * ADDITIVE, so the migration is free: a row written before this field simply
33721
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
33722
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
33723
+ * "never generated" would re-render and re-notify every camera of every rule
33724
+ * once, on the deploy that shipped the map.
33725
+ */
33726
+ generatedByDevice: record(string(), number()).optional(),
33113
33727
  /** userId of the caller who created the rule (server-stamped). */
33114
33728
  createdBy: string(),
33115
33729
  createdAt: number(),
@@ -33160,25 +33774,32 @@ object({
33160
33774
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33161
33775
  object({
33162
33776
  /**
33163
- * How long a retained native frame is served before it counts as a miss.
33777
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
33778
+ * detection result.
33779
+ *
33780
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
33781
+ * a time window was never related to the event the pixels were waiting for.
33782
+ * A held frame now lives from delivery until the runner has its `FrameResult`
33783
+ * — at which moment the runner cuts the subject tiles it actually wanted and
33784
+ * releases the frame. The bound exists only so a runner that stops answering
33785
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
33164
33786
  *
33165
- * Must cover the FULL late-crop horizon: detection inference + the
33166
- * cross-process inference-result hop to hub post-analysis + tracking + the
33167
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33168
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33169
- * RAM per busy camera grows linearly with no measured hit-rate gain.
33787
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
33788
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
33789
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
33790
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
33791
+ * `holdOverflow` on the metrics line is what says you need it.
33170
33792
  */
33171
- ttlMs: number().int().min(250).max(1e4),
33793
+ holdFrames: number().int().min(1).max(64),
33172
33794
  /**
33173
33795
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33174
33796
  *
33175
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33176
- * which one is actually binding before reasoning from that. At the shipped
33177
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33178
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33179
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33180
- * change that admits fewer frames buys retention WINDOW at constant RAM
33181
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
33797
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
33798
+ * is what decides how much is held, and the ceiling is the number above which
33799
+ * something is wrong. Before that it was the effective cap at 1024 MB with
33800
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
33801
+ * with the TTL expiring nothing, which is exactly the confusion the hold
33802
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33182
33803
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33183
33804
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33184
33805
  * to replace).
@@ -33204,22 +33825,45 @@ object({
33204
33825
  * there is the signal that some caller names frames outside the inference set
33205
33826
  * and that this must go back to `all`.
33206
33827
  */
33207
- admission: NativeLeaseAdmissionSchema
33828
+ admission: NativeLeaseAdmissionSchema,
33829
+ /**
33830
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
33831
+ * compressed native crops the worker cuts at the moment a frame's detection
33832
+ * result arrives, and keeps long after the frame itself is freed.
33833
+ *
33834
+ * This is the knob that replaced the old retention window, and it buys about
33835
+ * three orders of magnitude more of it: a tile is one subject at native
33836
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
33837
+ * the frame it was cut from. A frame on which nothing was detected costs
33838
+ * nothing at all, which is the real change — the old lease paid per FRAME and
33839
+ * was interrogated per SUBJECT.
33840
+ *
33841
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
33842
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
33843
+ * reproduce that.
33844
+ */
33845
+ tileBudgetMb: number().int().min(0).max(1024)
33208
33846
  });
33209
33847
  /**
33210
- * The values in force when the operator has set nothing — byte-for-byte the
33211
- * constants the decode worker shipped with as env-var defaults, so making these
33212
- * settings changed no behaviour on the day it landed.
33848
+ * The values in force when the operator has set nothing.
33849
+ *
33850
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
33851
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
33852
+ * in the same change that redefines it would make a regression and a retune
33853
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
33854
+ * live traffic.
33213
33855
  */
33214
33856
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33215
- ttlMs: 1200,
33857
+ holdFrames: 8,
33216
33858
  budgetMb: 1024,
33217
33859
  activityMs: 15e3,
33860
+ tileBudgetMb: 64,
33218
33861
  admission: "inferred"
33219
33862
  };
33220
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
33863
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33221
33864
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33222
33865
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
33866
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33223
33867
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33224
33868
  //#endregion
33225
33869
  //#region src/config.ts