@camstack/addon-provider-dreo 0.2.13 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +686 -42
  2. package/dist/addon.mjs +686 -42
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -7242,8 +7242,31 @@ var AdoptionJobSchema = object({
7242
7242
  error: string().nullable()
7243
7243
  });
7244
7244
  /**
7245
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7246
- * pipeline functions an operator thinks in terms of.
7245
+ * Per-camera FUNCTION SWITCHES.
7246
+ *
7247
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7248
+ *
7249
+ * This file shipped as "the one coherent on/off surface over the pipeline
7250
+ * functions an operator thinks in terms of". The operator's verdict on
7251
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7252
+ * every function already had a settings page of its own, and a second place to
7253
+ * turn it off is a second place to look. Each switch is going back to its own
7254
+ * component's original options — detection to the detection-pipeline wrapper
7255
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7256
+ * (which was always first-class; the switch was a veneer over
7257
+ * `recording.setDeviceConfig`), notifications to a notification-center
7258
+ * per-device setting, the two camera planes to their own components.
7259
+ *
7260
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7261
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7262
+ * straight from the authorities with no group in the middle. That rule was
7263
+ * never about a control panel.
7264
+ *
7265
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7266
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7267
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7268
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7269
+ * stop; nothing new may be built on it.
7247
7270
  *
7248
7271
  * ## This file adds no state
7249
7272
  *
@@ -7594,7 +7617,15 @@ var RecordingConfigSchema = object({
7594
7617
  * Each completed/failed run also lands one durable ops-log row on its owning
7595
7618
  * addon surface.
7596
7619
  */
7620
+ /**
7621
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7622
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7623
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7624
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7625
+ * runs at all.
7626
+ */
7597
7627
  var RelocateJobStateSchema = _enum([
7628
+ "queued",
7598
7629
  "running",
7599
7630
  "done",
7600
7631
  "failed",
@@ -7629,6 +7660,15 @@ var RelocateFootageInputSchema = object({
7629
7660
  /** Limits relocation to the logical profile class. Omit only for the
7630
7661
  * pre-orchestration compatibility path. */
7631
7662
  footageClass: RelocateFootageClassSchema.optional(),
7663
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7664
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7665
+ * unit is a (camera, profile) pile, not a disk. */
7666
+ deviceId: number().int().optional(),
7667
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7668
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7669
+ * placement plan assigns those two independently, so a rebalance that could
7670
+ * only say "recordings" would move footage the plan never asked to move. */
7671
+ profiles: array(string()).optional(),
7632
7672
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7633
7673
  * never allowed to starve live writers. */
7634
7674
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7764,6 +7804,21 @@ var StorageLocationSchema = object({
7764
7804
  nodeId: string().optional(),
7765
7805
  isDefault: boolean().default(false),
7766
7806
  isSystem: boolean().default(false),
7807
+ /**
7808
+ * Operator opt-in: whether consumers that BALANCE across several locations
7809
+ * of a type may write here. Recordings reads it today; event media and
7810
+ * backups are the next consumers, which is why the flag lives on the
7811
+ * location rather than in any one addon's store — nothing has to be
7812
+ * extended to add the next consumer.
7813
+ *
7814
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7815
+ * flag existed reads back with no flag and keeps working exactly as before;
7816
+ * that is the whole compat story, and it is why no migration ships with it.
7817
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7818
+ * disk must not silently start writing to it); the default of a type is
7819
+ * always stamped `true`.
7820
+ */
7821
+ enabled: boolean().optional(),
7767
7822
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7768
7823
  * for node-local locations it can reach) — never persisted, absent when the
7769
7824
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12333,7 +12388,8 @@ method(object({
12333
12388
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12334
12389
  /**
12335
12390
  * filesystem-browse — per-node capability for browsing the node's local
12336
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12391
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12392
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12337
12393
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12338
12394
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12339
12395
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14174,6 +14230,13 @@ var MaskGridDimsSchema = object({
14174
14230
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14175
14231
  * this one field keeps the schema additive — a rule still declares exactly
14176
14232
  * one trigger.
14233
+ *
14234
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14235
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14236
+ * mirror.ts` fails the build on a member the app cannot render) and every
14237
+ * member costs a release train. A sustained-sound rule is therefore an
14238
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14239
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14177
14240
  */
14178
14241
  var NcDeliverySchema = _enum([
14179
14242
  "immediate",
@@ -14188,15 +14251,32 @@ var NcDeliverySchema = _enum([
14188
14251
  * depend on a provider's raw event name or payload shape.
14189
14252
  */
14190
14253
  var NcSystemEventKindSchema = _enum([
14191
- "camera-online",
14192
- "camera-offline",
14254
+ "device-online",
14255
+ "device-offline",
14256
+ "device-disabled",
14257
+ "device-enabled",
14193
14258
  "stream-online",
14194
14259
  "stream-offline",
14195
14260
  "node-online",
14196
14261
  "node-offline",
14197
14262
  "addon-update-available",
14198
- "server-update-available"
14263
+ "server-update-available",
14264
+ "alarm-triggered",
14265
+ "alarm-armed",
14266
+ "alarm-disarmed",
14267
+ "camera-online",
14268
+ "camera-offline",
14269
+ "camera-disabled",
14270
+ "camera-enabled"
14271
+ ]);
14272
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14273
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14274
+ "camera-online",
14275
+ "camera-offline",
14276
+ "camera-disabled",
14277
+ "camera-enabled"
14199
14278
  ]);
14279
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14200
14280
  /**
14201
14281
  * One coherent system-event condition. `kinds` is the required opt-in safety
14202
14282
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14205,6 +14285,18 @@ var NcSystemEventKindSchema = _enum([
14205
14285
  var NcSystemEventConditionSchema = object({
14206
14286
  kinds: array(NcSystemEventKindSchema).min(1),
14207
14287
  deviceIds: array(number().int()).min(1).optional(),
14288
+ /**
14289
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14290
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14291
+ * is what a liveness rule means when nobody said otherwise.
14292
+ *
14293
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14294
+ * one reason: the intake cannot know which devices this household cares
14295
+ * about, and a producer-side filter is one no operator can change. Fails
14296
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14297
+ * does not carry) matches no `deviceTypes` list.
14298
+ */
14299
+ deviceTypes: array(string().min(1)).min(1).optional(),
14208
14300
  nodeIds: array(string().min(1)).min(1).optional(),
14209
14301
  packageNames: array(string().min(1)).min(1).optional()
14210
14302
  });
@@ -14255,6 +14347,47 @@ var NcOccupancyConditionSchema = object({
14255
14347
  sustainSeconds: number().int().min(0).max(3600).default(15)
14256
14348
  });
14257
14349
  /**
14350
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14351
+ *
14352
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14353
+ * reference notifier uses, so an operator moving between them re-uses what
14354
+ * they already know): a rule matches when, over a sampling window of
14355
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14356
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14357
+ *
14358
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14359
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14360
+ * - `labels` — the classifier put at least one of these labels on it.
14361
+ *
14362
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14363
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14364
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14365
+ * is given** — a window in which every sample is trivially a hit would fire on
14366
+ * silence, so the engine refuses such a condition rather than notifying on
14367
+ * nothing (the schema cannot express "at least one of" without becoming a
14368
+ * ZodEffects the cap path would have to special-case).
14369
+ *
14370
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14371
+ * must be FULL before it can match — a window that has been open for two
14372
+ * seconds of its ten is 100% of nothing, and firing on it would make
14373
+ * `samplingSeconds` decorative.
14374
+ *
14375
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14376
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14377
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14378
+ * an operator who typed `dog` mean the same thing.
14379
+ */
14380
+ var NcAudioConditionSchema = object({
14381
+ /** Audio macro labels; absent = any sound (level-only rule). */
14382
+ labels: array(string().min(1)).min(1).optional(),
14383
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14384
+ dbThreshold: number().min(-96).max(0).optional(),
14385
+ /** Percentage of the window's samples that must be hits (1–100). */
14386
+ hitPercent: number().int().min(1).max(100).default(60),
14387
+ /** Length of the sampling window in seconds. */
14388
+ samplingSeconds: number().int().min(1).max(300).default(10)
14389
+ });
14390
+ /**
14258
14391
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14259
14392
  *
14260
14393
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14527,7 +14660,33 @@ var NcConditionsSchema = object({
14527
14660
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14528
14661
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14529
14662
  */
14530
- occupancy: NcOccupancyConditionSchema.optional()
14663
+ occupancy: NcOccupancyConditionSchema.optional(),
14664
+ /**
14665
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14666
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14667
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14668
+ * a window that is not full yet, neither filter given). See
14669
+ * {@link NcAudioCondition}.
14670
+ *
14671
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14672
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14673
+ * a detection, a track or a device event (the same fail-closed pairing
14674
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14675
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14676
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14677
+ * classified sample) stays exactly as it was for rules that already use it.
14678
+ *
14679
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14680
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14681
+ * (`camstack/src/data/notification-center.ts`, guarded by
14682
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14683
+ * condition fields it does not know when a rule is saved from the phone.
14684
+ * Publishing an editor for a condition the app cannot round-trip is how an
14685
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14686
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14687
+ * does an audio rule become authorable.
14688
+ */
14689
+ audio: NcAudioConditionSchema.optional()
14531
14690
  });
14532
14691
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14533
14692
  var NcRuleTargetSchema = object({
@@ -14641,6 +14800,73 @@ var NcThrottleSchema = object({
14641
14800
  */
14642
14801
  granularity: NcThrottleGranularitySchema.optional()
14643
14802
  });
14803
+ /**
14804
+ * How long the confirm gate may hold ONE notification, and how big the picture
14805
+ * it judges may be.
14806
+ *
14807
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14808
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14809
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14810
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14811
+ * tokens for pixels the model pools away.
14812
+ */
14813
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14814
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14815
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14816
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14817
+ var NcConfirmExpectSchema = object({
14818
+ op: _enum([
14819
+ ">=",
14820
+ ">",
14821
+ "<=",
14822
+ "<",
14823
+ "=="
14824
+ ]),
14825
+ count: number().int().min(0).max(1e3)
14826
+ });
14827
+ /**
14828
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14829
+ * to ship and says whether it agrees with the rule.
14830
+ *
14831
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14832
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14833
+ * on the operator's phone is not a verdict about this notification.
14834
+ *
14835
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14836
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14837
+ * the default and every fail-open is COUNTED, because a gate that always fails
14838
+ * open looks in the log exactly like a gate that works.
14839
+ *
14840
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14841
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14842
+ * production failures in one day), so the gate reads absent as the constant
14843
+ * above rather than trusting a parse it may never have seen.
14844
+ */
14845
+ var NcConfirmSchema = object({
14846
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14847
+ * same thing, and both mean "deliver exactly as before". */
14848
+ enabled: boolean().default(false),
14849
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14850
+ profileId: string().optional(),
14851
+ /**
14852
+ * The operator's question, in his own words. Absent = a question derived
14853
+ * from the rule (its class and its expectation).
14854
+ *
14855
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14856
+ * banners, signage and plates as instructions if you let them reach the
14857
+ * prompt — proven live — so the authoritative contract stays in the system
14858
+ * turn and only rule-authored words land here.
14859
+ */
14860
+ prompt: string().max(1e3).optional(),
14861
+ /** Fire only when the model's count satisfies this. Absent = the model's
14862
+ * own boolean verdict decides. */
14863
+ expect: NcConfirmExpectSchema.optional(),
14864
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14865
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14866
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14867
+ /** Longest edge the judged image is downscaled to before it is sent. */
14868
+ maxImagePx: number().int().min(64).max(2048).default(448)
14869
+ });
14644
14870
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14645
14871
  var NcRuleInputSchema = object({
14646
14872
  name: string().min(1).max(200),
@@ -14701,7 +14927,13 @@ var NcRuleInputSchema = object({
14701
14927
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14702
14928
  * shape as every other actuation.
14703
14929
  */
14704
- actions: NcRuleActionsSchema.optional()
14930
+ actions: NcRuleActionsSchema.optional(),
14931
+ /**
14932
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14933
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14934
+ * did, and absent is the only way to say that without a migration.
14935
+ */
14936
+ confirm: NcConfirmSchema.optional()
14705
14937
  });
14706
14938
  /**
14707
14939
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14712,7 +14944,37 @@ var NcRuleInputSchema = object({
14712
14944
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14713
14945
  * `updateRule` patch.
14714
14946
  */
14715
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14947
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14948
+ disabledTargetIds: array(string()).optional(),
14949
+ /**
14950
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14951
+ *
14952
+ * It makes the key optional to SUPPLY; the parse still materialises the
14953
+ * default when the key is absent. And `NcRuleStore.update` merges with
14954
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14955
+ * one — which made every partial edit destructive:
14956
+ *
14957
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14958
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14959
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14960
+ *
14961
+ * A rule scoped to one camera and one zone silently became a rule that
14962
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14963
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14964
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14965
+ * within a minute of a two-field patch.
14966
+ *
14967
+ * So every defaulted field is re-declared here WITHOUT its default. The
14968
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14969
+ * conditions remains a real instruction ("clear them") — and only the
14970
+ * absent key is now genuinely absent.
14971
+ */
14972
+ enabled: boolean().optional(),
14973
+ conditions: NcConditionsSchema.optional(),
14974
+ media: NcMediaPolicySchema.optional(),
14975
+ throttle: NcThrottleSchema.optional(),
14976
+ priority: number().int().min(1).max(5).optional()
14977
+ });
14716
14978
  /** A persisted rule. */
14717
14979
  var NcRuleSchema = NcRuleInputSchema.extend({
14718
14980
  id: string(),
@@ -15013,6 +15275,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15013
15275
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15014
15276
  * copy would lie the first time a rule is disabled.
15015
15277
  */
15278
+ /**
15279
+ * Why a device a mode NAMES is nonetheless not armed by it.
15280
+ *
15281
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15282
+ * per-camera notification switch the Notification Center already owns,
15283
+ * `detection-off` is the device's own detection binding being inactive, and
15284
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15285
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15286
+ * with the switches the operator actually used.
15287
+ */
15288
+ var NcAlarmSkipReasonSchema = _enum([
15289
+ "muted",
15290
+ "detection-off",
15291
+ "offline"
15292
+ ]);
15293
+ var NcAlarmSkippedDeviceSchema = object({
15294
+ deviceId: number().int(),
15295
+ reason: NcAlarmSkipReasonSchema
15296
+ });
15016
15297
  var NcAlarmModeCoverageSchema = object({
15017
15298
  mode: AlarmArmModeSchema,
15018
15299
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15020,7 +15301,18 @@ var NcAlarmModeCoverageSchema = object({
15020
15301
  /** At least one covering rule has no device scope, so the mode covers all. */
15021
15302
  allDevices: boolean(),
15022
15303
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15023
- deviceIds: array(number().int())
15304
+ deviceIds: array(number().int()),
15305
+ /**
15306
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15307
+ * excludes it.
15308
+ *
15309
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15310
+ * twelve makes it false in exactly the way nobody notices until an incident.
15311
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15312
+ * still parses as "nothing known to be skipped" rather than failing the whole
15313
+ * alarm tab.
15314
+ */
15315
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15024
15316
  });
15025
15317
  var NcAlarmConfigSchema = object({
15026
15318
  /**
@@ -17852,9 +18144,16 @@ var CameraStatusSchema = object({
17852
18144
  audio: CameraAudioStatusSchema.nullable(),
17853
18145
  recording: CameraRecordingStatusSchema.nullable(),
17854
18146
  /**
17855
- * Per-camera function switches an OPERATOR has turned off
18147
+ * Per-camera functions an OPERATOR has turned off
17856
18148
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17857
18149
  *
18150
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18151
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18152
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18153
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18154
+ * The badge outlives the control panel: the panel was a convenience, this is
18155
+ * the difference between a camera being off and a camera being dead.
18156
+ *
17858
18157
  * This is the difference between DISABLED and BROKEN. A camera whose
17859
18158
  * `detection` block reports zero fps and whose `switchedOff` contains
17860
18159
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -24604,7 +24903,19 @@ var RecordingManifestSchema = object({
24604
24903
  * profiles/subtrees/locations on this node). */
24605
24904
  var RecordingDeviceUsageSchema = object({
24606
24905
  deviceId: number(),
24607
- usedBytes: number()
24906
+ usedBytes: number(),
24907
+ /**
24908
+ * Start of this camera's OLDEST indexed segment, across every profile and
24909
+ * location — the "Oldest footage" column in Recordings → Storage, and the
24910
+ * only honest answer to "is retention actually holding?" per camera.
24911
+ *
24912
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
24913
+ * predates this field omits it entirely, and a hub whose types carry the
24914
+ * field must keep validating that older provider's payload: the framework
24915
+ * (types) and the addon ship on different trains, and the addon is usually
24916
+ * the later of the two.
24917
+ */
24918
+ oldestMs: number().nullable().optional()
24608
24919
  });
24609
24920
  /** Recording storage usage + capacity for one storage location. */
24610
24921
  var RecordingLocationUsageSchema = object({
@@ -24632,6 +24943,57 @@ var RecordingStorageUsageSchema = object({
24632
24943
  locations: array(RecordingLocationUsageSchema)
24633
24944
  });
24634
24945
  /**
24946
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
24947
+ *
24948
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
24949
+ * is the operator asking for the EXISTING archive to be brought into line with
24950
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
24951
+ * location, run FIFO behind the single-flight mover.
24952
+ *
24953
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
24954
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
24955
+ * (empty on the plan).
24956
+ */
24957
+ var RecordingRebalanceMoveSchema = object({
24958
+ deviceId: number(),
24959
+ profile: string(),
24960
+ fromLocationId: string(),
24961
+ toLocationId: string(),
24962
+ bytes: number(),
24963
+ files: number().int()
24964
+ });
24965
+ /** Why a pile that is out of place is staying there. Every refusal is
24966
+ * reported: a rebalance that silently drops a camera reads exactly like one
24967
+ * that had nothing to do. */
24968
+ var RecordingRebalanceSkipReasonSchema = _enum([
24969
+ "unassigned",
24970
+ "target-not-writable",
24971
+ "below-threshold",
24972
+ "no-headroom"
24973
+ ]);
24974
+ var RecordingRebalanceSkipSchema = object({
24975
+ deviceId: number(),
24976
+ profile: string(),
24977
+ fromLocationId: string(),
24978
+ /** The location the plan wants; null when the camera has no assignment. */
24979
+ toLocationId: string().nullable(),
24980
+ bytes: number(),
24981
+ reason: RecordingRebalanceSkipReasonSchema
24982
+ });
24983
+ var RecordingRebalancePlanSchema = object({
24984
+ moves: array(RecordingRebalanceMoveSchema),
24985
+ skipped: array(RecordingRebalanceSkipSchema),
24986
+ bytesToMove: number(),
24987
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
24988
+ jobIds: array(string())
24989
+ });
24990
+ var RecordingRebalanceInputSchema = object({
24991
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
24992
+ throttleMbps: number().min(1).max(1e3).optional(),
24993
+ /** Ignore piles smaller than this (default 1 GB). */
24994
+ minMoveGb: number().min(0).optional()
24995
+ });
24996
+ /**
24635
24997
  * Result of locating footage at a wall-clock instant for one device/profile.
24636
24998
  * `segment` carries the covering segment's window; `gap` reports the forward
24637
24999
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -24794,9 +25156,24 @@ method(object({
24794
25156
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24795
25157
  kind: "mutation",
24796
25158
  auth: "admin"
25159
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25160
+ kind: "mutation",
25161
+ auth: "admin"
25162
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25163
+ kind: "query",
25164
+ auth: "admin"
25165
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25166
+ kind: "mutation",
25167
+ auth: "admin"
25168
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25169
+ kind: "query",
25170
+ auth: "admin"
25171
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25172
+ kind: "mutation",
25173
+ auth: "admin"
24797
25174
  });
24798
25175
  /**
24799
- * `recordingExport` cap — render a footage time range into a single downloadable
25176
+ * `recording-export` cap — render a footage time range into a single downloadable
24800
25177
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
24801
25178
  * bounded lifetime with a durable history, auto-expiry, and optional
24802
25179
  * delete-after-download.
@@ -24811,10 +25188,53 @@ method(object({
24811
25188
  */
24812
25189
  /** Playback-speed multiplier for the render (1 = realtime). */
24813
25190
  var ExportSpeedSchema = number().min(.25).max(32);
25191
+ /**
25192
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25193
+ *
25194
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25195
+ * derives these bounds from things that happened at a TIME (a track's
25196
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25197
+ * every segment present for the range, with each recording GAP removed. The
25198
+ * two agree only on a window that recorded without one interruption, and only
25199
+ * the render side knows the segments, so the translation lives there
25200
+ * (`export-dense-map.ts`, addon-pipeline).
25201
+ *
25202
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25203
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25204
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25205
+ * the video was a uniform timelapse, and the log line reported the five ranges
25206
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25207
+ *
25208
+ * Relative and not absolute epoch, because an absolute epoch would make every
25209
+ * call site responsible for the same subtraction.
25210
+ */
25211
+ var ExportDenseRangeSchema = object({
25212
+ fromSec: number().nonnegative(),
25213
+ toSec: number().nonnegative()
25214
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25215
+ /**
25216
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25217
+ * listed ranges and at the base `everyMs` everywhere else.
25218
+ *
25219
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25220
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25221
+ */
25222
+ var ExportDenseSchema = object({
25223
+ everyMs: number().int().positive(),
25224
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25225
+ });
24814
25226
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
24815
25227
  var ExportTimelapseSchema = object({
24816
25228
  everyMs: number().int().positive(),
24817
- outputFps: number().int().min(1).max(60).optional()
25229
+ outputFps: number().int().min(1).max(60).optional(),
25230
+ /** Optional second, FASTER rate over the intervals that matter. */
25231
+ dense: ExportDenseSchema.optional()
25232
+ }).superRefine((v, ctx) => {
25233
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25234
+ code: ZodIssueCode.custom,
25235
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25236
+ path: ["dense", "everyMs"]
25237
+ });
24818
25238
  });
24819
25239
  /**
24820
25240
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -24872,6 +25292,19 @@ var ExportDownloadSchema = object({
24872
25292
  url: string(),
24873
25293
  endpoints: array(string())
24874
25294
  });
25295
+ /**
25296
+ * A finished export's bytes, inline.
25297
+ *
25298
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25299
+ * against, so nobody has to infer it from the base64 length.
25300
+ */
25301
+ var ExportBytesSchema = object({
25302
+ base64: string(),
25303
+ contentType: string(),
25304
+ /** Suggested filename, extension included. */
25305
+ name: string(),
25306
+ bytes: number().int().nonnegative()
25307
+ });
24875
25308
  method(object({
24876
25309
  deviceId: number(),
24877
25310
  profile: string(),
@@ -24896,6 +25329,9 @@ method(object({
24896
25329
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
24897
25330
  kind: "query",
24898
25331
  auth: "protected"
25332
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25333
+ kind: "query",
25334
+ auth: "protected"
24899
25335
  });
24900
25336
  /**
24901
25337
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -31573,6 +32009,12 @@ Object.freeze({
31573
32009
  addonId: null,
31574
32010
  access: "create"
31575
32011
  },
32012
+ "recording.cancelRelocateJob": {
32013
+ capName: "recording",
32014
+ capScope: "system",
32015
+ addonId: null,
32016
+ access: "create"
32017
+ },
31576
32018
  "recording.cancelStorageMigrationMove": {
31577
32019
  capName: "recording",
31578
32020
  capScope: "system",
@@ -31627,6 +32069,12 @@ Object.freeze({
31627
32069
  addonId: null,
31628
32070
  access: "view"
31629
32071
  },
32072
+ "recording.listRelocateJobs": {
32073
+ capName: "recording",
32074
+ capScope: "system",
32075
+ addonId: null,
32076
+ access: "view"
32077
+ },
31630
32078
  "recording.locateSegment": {
31631
32079
  capName: "recording",
31632
32080
  capScope: "system",
@@ -31639,6 +32087,12 @@ Object.freeze({
31639
32087
  addonId: null,
31640
32088
  access: "create"
31641
32089
  },
32090
+ "recording.planStorageRebalance": {
32091
+ capName: "recording",
32092
+ capScope: "system",
32093
+ addonId: null,
32094
+ access: "view"
32095
+ },
31642
32096
  "recording.pruneFootage": {
31643
32097
  capName: "recording",
31644
32098
  capScope: "system",
@@ -31663,6 +32117,12 @@ Object.freeze({
31663
32117
  addonId: null,
31664
32118
  access: "create"
31665
32119
  },
32120
+ "recording.relocateFootage": {
32121
+ capName: "recording",
32122
+ capScope: "system",
32123
+ addonId: null,
32124
+ access: "create"
32125
+ },
31666
32126
  "recording.renderClip": {
31667
32127
  capName: "recording",
31668
32128
  capScope: "system",
@@ -31699,38 +32159,50 @@ Object.freeze({
31699
32159
  addonId: null,
31700
32160
  access: "create"
31701
32161
  },
32162
+ "recording.startStorageRebalance": {
32163
+ capName: "recording",
32164
+ capScope: "system",
32165
+ addonId: null,
32166
+ access: "create"
32167
+ },
31702
32168
  "recordingExport.cancelExport": {
31703
- capName: "recordingExport",
32169
+ capName: "recording-export",
31704
32170
  capScope: "system",
31705
32171
  addonId: null,
31706
32172
  access: "create"
31707
32173
  },
31708
32174
  "recordingExport.createExport": {
31709
- capName: "recordingExport",
32175
+ capName: "recording-export",
31710
32176
  capScope: "system",
31711
32177
  addonId: null,
31712
32178
  access: "create"
31713
32179
  },
31714
32180
  "recordingExport.deleteExport": {
31715
- capName: "recordingExport",
32181
+ capName: "recording-export",
31716
32182
  capScope: "system",
31717
32183
  addonId: null,
31718
32184
  access: "delete"
31719
32185
  },
31720
32186
  "recordingExport.getDownloadUrl": {
31721
- capName: "recordingExport",
32187
+ capName: "recording-export",
31722
32188
  capScope: "system",
31723
32189
  addonId: null,
31724
32190
  access: "view"
31725
32191
  },
31726
32192
  "recordingExport.getExport": {
31727
- capName: "recordingExport",
32193
+ capName: "recording-export",
31728
32194
  capScope: "system",
31729
32195
  addonId: null,
31730
32196
  access: "view"
31731
32197
  },
31732
32198
  "recordingExport.listExports": {
31733
- capName: "recordingExport",
32199
+ capName: "recording-export",
32200
+ capScope: "system",
32201
+ addonId: null,
32202
+ access: "view"
32203
+ },
32204
+ "recordingExport.readExportBytes": {
32205
+ capName: "recording-export",
31734
32206
  capScope: "system",
31735
32207
  addonId: null,
31736
32208
  access: "view"
@@ -33107,6 +33579,104 @@ var FramerateField = number().int().min(1).max(60);
33107
33579
  var TargetsField = array(NcRuleTargetSchema).min(1);
33108
33580
  var PriorityField = number().int().min(1).max(5);
33109
33581
  /**
33582
+ * Explicit override of the DENSE sampling cadence, seconds.
33583
+ *
33584
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
33585
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
33586
+ * made that same base 3 s and rendered a person pass as two frames.)
33587
+ *
33588
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
33589
+ * `denseCadenceSec` and played at `framerate` occupies
33590
+ *
33591
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
33592
+ *
33593
+ * 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.
33594
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
33595
+ * and therefore the length of a quiet night, does not move.
33596
+ *
33597
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
33598
+ * the recording has them returns the same frames, requested twice. Must be
33599
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
33600
+ * a uniform video the operator believes is two-rate — and upsert refuses it
33601
+ * rather than letting the export cap reject the render hours after the window.
33602
+ */
33603
+ var DenseCadenceSecField = number().min(.1).max(3600);
33604
+ /**
33605
+ * Minimum seconds of OUTPUT video each detection range must occupy.
33606
+ *
33607
+ * The operator-facing form of the arithmetic above: instead of solving for a
33608
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
33609
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
33610
+ * that range every ~583 ms.
33611
+ *
33612
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
33613
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
33614
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
33615
+ * ranges are sampled denser than they need. Per-range cadences require a cap
33616
+ * schema change and are the tracked follow-up.
33617
+ *
33618
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
33619
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
33620
+ * by real footage, never met by duplicating frames into motion that never
33621
+ * happened.
33622
+ */
33623
+ var MinDwellSecField = number().min(0).max(60);
33624
+ /**
33625
+ * Caption burned into the notification's preview frame.
33626
+ *
33627
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
33628
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
33629
+ * templating dialect for one field would be a second thing to explain.
33630
+ *
33631
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
33632
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
33633
+ * the reason this is not `.min(1)`.
33634
+ */
33635
+ var PreviewTextField = string().max(200);
33636
+ /**
33637
+ * Whether the notification's preview is a STILL or a short animation.
33638
+ *
33639
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
33640
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
33641
+ * night reads better as three seconds of motion than as one frame of it. Both
33642
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
33643
+ * simply applies it to a dozen frames sampled across the render and assembles
33644
+ * them.
33645
+ *
33646
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
33647
+ * seeks and a palette pass, and no rule that never asked for one should start
33648
+ * paying that on the deploy that shipped it.
33649
+ *
33650
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
33651
+ */
33652
+ var PreviewModeField = _enum(["image", "gif"]);
33653
+ /**
33654
+ * Which detection classes the notification reports counts for.
33655
+ *
33656
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
33657
+ * plan — no second query — aggregated per class. Absent or empty means "every
33658
+ * class the window actually contained", which is what an operator who never
33659
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
33660
+ * counts cars all night).
33661
+ *
33662
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
33663
+ * …). An unknown name simply never matches and reports nothing — it is not an
33664
+ * error, because a rule may legitimately name a class this camera's model does
33665
+ * not emit.
33666
+ *
33667
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
33668
+ * - `{{detections}}` — total over the reported classes
33669
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
33670
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
33671
+ * one per class, `count_` + the class name
33672
+ *
33673
+ * With NO custom body template the summary is appended to the derived body, and
33674
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
33675
+ * reads. With a custom template the operator owns every word — nothing is
33676
+ * appended, so `{{detectionSummary}}` is how he asks for it.
33677
+ */
33678
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
33679
+ /**
33110
33680
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33111
33681
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33112
33682
  * here (see the ownership note above).
@@ -33126,9 +33696,30 @@ var TimelapseRuleInputSchema = object({
33126
33696
  cadenceSec: CadenceSecField.default(15),
33127
33697
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33128
33698
  framerate: FramerateField.default(10),
33699
+ /**
33700
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
33701
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
33702
+ * field gets.
33703
+ */
33704
+ denseCadenceSec: DenseCadenceSecField.optional(),
33705
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
33706
+ minDwellSec: MinDwellSecField.optional(),
33129
33707
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33130
33708
  targets: TargetsField,
33131
33709
  template: TimelapseTemplateSchema.optional(),
33710
+ /**
33711
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
33712
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
33713
+ *
33714
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
33715
+ * the notification's title/body, and clearing it (`template: null`) must not
33716
+ * silently clear the caption too.
33717
+ */
33718
+ previewText: PreviewTextField.optional(),
33719
+ /** Still or animation — see {@link PreviewModeField}. */
33720
+ previewMode: PreviewModeField.default("image"),
33721
+ /** Classes the notification counts — see {@link ReportClassesField}. */
33722
+ reportClasses: ReportClassesField.optional(),
33132
33723
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33133
33724
  priority: PriorityField.default(3)
33134
33725
  });
@@ -33139,8 +33730,13 @@ object({
33139
33730
  schedule: NcScheduleSchema.optional(),
33140
33731
  cadenceSec: CadenceSecField.optional(),
33141
33732
  framerate: FramerateField.optional(),
33733
+ denseCadenceSec: DenseCadenceSecField.optional(),
33734
+ minDwellSec: MinDwellSecField.optional(),
33142
33735
  targets: TargetsField.optional(),
33143
33736
  template: TimelapseTemplateSchema.nullable().optional(),
33737
+ previewText: PreviewTextField.optional(),
33738
+ previewMode: PreviewModeField.optional(),
33739
+ reportClasses: ReportClassesField.optional(),
33144
33740
  priority: PriorityField.optional()
33145
33741
  });
33146
33742
  TimelapseRuleInputSchema.extend({
@@ -33152,10 +33748,28 @@ TimelapseRuleInputSchema.extend({
33152
33748
  */
33153
33749
  ownerUserId: string().optional(),
33154
33750
  /**
33155
- * Epoch-ms of the last successful generation the 1-hour re-generation
33156
- * guard's durable state (predecessor parity). Absent = never generated.
33751
+ * Epoch-ms of the NEWEST successful generation across every camera of this
33752
+ * rule. What a UI shows, and the compatibility floor for
33753
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33157
33754
  */
33158
33755
  lastGeneratedAt: number().optional(),
33756
+ /**
33757
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
33758
+ * re-generation guard's real durable state.
33759
+ *
33760
+ * One rule covers several cameras and each renders its own video, so a rule
33761
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
33762
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
33763
+ * already done — and B's night is gone for good, because the window will not
33764
+ * come back.
33765
+ *
33766
+ * ADDITIVE, so the migration is free: a row written before this field simply
33767
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
33768
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
33769
+ * "never generated" would re-render and re-notify every camera of every rule
33770
+ * once, on the deploy that shipped the map.
33771
+ */
33772
+ generatedByDevice: record(string(), number()).optional(),
33159
33773
  /** userId of the caller who created the rule (server-stamped). */
33160
33774
  createdBy: string(),
33161
33775
  createdAt: number(),
@@ -33206,25 +33820,32 @@ object({
33206
33820
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33207
33821
  object({
33208
33822
  /**
33209
- * How long a retained native frame is served before it counts as a miss.
33823
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
33824
+ * detection result.
33825
+ *
33826
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
33827
+ * a time window was never related to the event the pixels were waiting for.
33828
+ * A held frame now lives from delivery until the runner has its `FrameResult`
33829
+ * — at which moment the runner cuts the subject tiles it actually wanted and
33830
+ * releases the frame. The bound exists only so a runner that stops answering
33831
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
33210
33832
  *
33211
- * Must cover the FULL late-crop horizon: detection inference + the
33212
- * cross-process inference-result hop to hub post-analysis + tracking + the
33213
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33214
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33215
- * RAM per busy camera grows linearly with no measured hit-rate gain.
33833
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
33834
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
33835
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
33836
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
33837
+ * `holdOverflow` on the metrics line is what says you need it.
33216
33838
  */
33217
- ttlMs: number().int().min(250).max(1e4),
33839
+ holdFrames: number().int().min(1).max(64),
33218
33840
  /**
33219
33841
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33220
33842
  *
33221
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33222
- * which one is actually binding before reasoning from that. At the shipped
33223
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33224
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33225
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33226
- * change that admits fewer frames buys retention WINDOW at constant RAM
33227
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
33843
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
33844
+ * is what decides how much is held, and the ceiling is the number above which
33845
+ * something is wrong. Before that it was the effective cap at 1024 MB with
33846
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
33847
+ * with the TTL expiring nothing, which is exactly the confusion the hold
33848
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33228
33849
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33229
33850
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33230
33851
  * to replace).
@@ -33250,22 +33871,45 @@ object({
33250
33871
  * there is the signal that some caller names frames outside the inference set
33251
33872
  * and that this must go back to `all`.
33252
33873
  */
33253
- admission: NativeLeaseAdmissionSchema
33874
+ admission: NativeLeaseAdmissionSchema,
33875
+ /**
33876
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
33877
+ * compressed native crops the worker cuts at the moment a frame's detection
33878
+ * result arrives, and keeps long after the frame itself is freed.
33879
+ *
33880
+ * This is the knob that replaced the old retention window, and it buys about
33881
+ * three orders of magnitude more of it: a tile is one subject at native
33882
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
33883
+ * the frame it was cut from. A frame on which nothing was detected costs
33884
+ * nothing at all, which is the real change — the old lease paid per FRAME and
33885
+ * was interrogated per SUBJECT.
33886
+ *
33887
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
33888
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
33889
+ * reproduce that.
33890
+ */
33891
+ tileBudgetMb: number().int().min(0).max(1024)
33254
33892
  });
33255
33893
  /**
33256
- * The values in force when the operator has set nothing — byte-for-byte the
33257
- * constants the decode worker shipped with as env-var defaults, so making these
33258
- * settings changed no behaviour on the day it landed.
33894
+ * The values in force when the operator has set nothing.
33895
+ *
33896
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
33897
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
33898
+ * in the same change that redefines it would make a regression and a retune
33899
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
33900
+ * live traffic.
33259
33901
  */
33260
33902
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33261
- ttlMs: 1200,
33903
+ holdFrames: 8,
33262
33904
  budgetMb: 1024,
33263
33905
  activityMs: 15e3,
33906
+ tileBudgetMb: 64,
33264
33907
  admission: "inferred"
33265
33908
  };
33266
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
33909
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33267
33910
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33268
33911
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
33912
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33269
33913
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33270
33914
  //#endregion
33271
33915
  //#region src/config.ts