@camstack/addon-provider-onvif 1.2.12 → 1.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +704 -56
  2. package/dist/addon.mjs +704 -56
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -7205,8 +7205,31 @@ var AdoptionJobSchema = object({
7205
7205
  error: string().nullable()
7206
7206
  });
7207
7207
  /**
7208
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7209
- * pipeline functions an operator thinks in terms of.
7208
+ * Per-camera FUNCTION SWITCHES.
7209
+ *
7210
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7211
+ *
7212
+ * This file shipped as "the one coherent on/off surface over the pipeline
7213
+ * functions an operator thinks in terms of". The operator's verdict on
7214
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7215
+ * every function already had a settings page of its own, and a second place to
7216
+ * turn it off is a second place to look. Each switch is going back to its own
7217
+ * component's original options — detection to the detection-pipeline wrapper
7218
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7219
+ * (which was always first-class; the switch was a veneer over
7220
+ * `recording.setDeviceConfig`), notifications to a notification-center
7221
+ * per-device setting, the two camera planes to their own components.
7222
+ *
7223
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7224
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7225
+ * straight from the authorities with no group in the middle. That rule was
7226
+ * never about a control panel.
7227
+ *
7228
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7229
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7230
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7231
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7232
+ * stop; nothing new may be built on it.
7210
7233
  *
7211
7234
  * ## This file adds no state
7212
7235
  *
@@ -7557,7 +7580,15 @@ var RecordingConfigSchema = object({
7557
7580
  * Each completed/failed run also lands one durable ops-log row on its owning
7558
7581
  * addon surface.
7559
7582
  */
7583
+ /**
7584
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7585
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7586
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7587
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7588
+ * runs at all.
7589
+ */
7560
7590
  var RelocateJobStateSchema = _enum([
7591
+ "queued",
7561
7592
  "running",
7562
7593
  "done",
7563
7594
  "failed",
@@ -7592,6 +7623,15 @@ var RelocateFootageInputSchema = object({
7592
7623
  /** Limits relocation to the logical profile class. Omit only for the
7593
7624
  * pre-orchestration compatibility path. */
7594
7625
  footageClass: RelocateFootageClassSchema.optional(),
7626
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7627
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7628
+ * unit is a (camera, profile) pile, not a disk. */
7629
+ deviceId: number().int().optional(),
7630
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7631
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7632
+ * placement plan assigns those two independently, so a rebalance that could
7633
+ * only say "recordings" would move footage the plan never asked to move. */
7634
+ profiles: array(string()).optional(),
7595
7635
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7596
7636
  * never allowed to starve live writers. */
7597
7637
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7727,6 +7767,21 @@ var StorageLocationSchema = object({
7727
7767
  nodeId: string().optional(),
7728
7768
  isDefault: boolean().default(false),
7729
7769
  isSystem: boolean().default(false),
7770
+ /**
7771
+ * Operator opt-in: whether consumers that BALANCE across several locations
7772
+ * of a type may write here. Recordings reads it today; event media and
7773
+ * backups are the next consumers, which is why the flag lives on the
7774
+ * location rather than in any one addon's store — nothing has to be
7775
+ * extended to add the next consumer.
7776
+ *
7777
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7778
+ * flag existed reads back with no flag and keeps working exactly as before;
7779
+ * that is the whole compat story, and it is why no migration ships with it.
7780
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7781
+ * disk must not silently start writing to it); the default of a type is
7782
+ * always stamped `true`.
7783
+ */
7784
+ enabled: boolean().optional(),
7730
7785
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7731
7786
  * for node-local locations it can reach) — never persisted, absent when the
7732
7787
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12084,7 +12139,8 @@ method(object({
12084
12139
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12085
12140
  /**
12086
12141
  * filesystem-browse — per-node capability for browsing the node's local
12087
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12142
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12143
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12088
12144
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12089
12145
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12090
12146
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -13897,6 +13953,13 @@ var MaskGridDimsSchema = object({
13897
13953
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
13898
13954
  * this one field keeps the schema additive — a rule still declares exactly
13899
13955
  * one trigger.
13956
+ *
13957
+ * AUDIO rules add no member here, for the reason occupancy added none: the
13958
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
13959
+ * mirror.ts` fails the build on a member the app cannot render) and every
13960
+ * member costs a release train. A sustained-sound rule is therefore an
13961
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
13962
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
13900
13963
  */
13901
13964
  var NcDeliverySchema = _enum([
13902
13965
  "immediate",
@@ -13911,15 +13974,32 @@ var NcDeliverySchema = _enum([
13911
13974
  * depend on a provider's raw event name or payload shape.
13912
13975
  */
13913
13976
  var NcSystemEventKindSchema = _enum([
13914
- "camera-online",
13915
- "camera-offline",
13977
+ "device-online",
13978
+ "device-offline",
13979
+ "device-disabled",
13980
+ "device-enabled",
13916
13981
  "stream-online",
13917
13982
  "stream-offline",
13918
13983
  "node-online",
13919
13984
  "node-offline",
13920
13985
  "addon-update-available",
13921
- "server-update-available"
13986
+ "server-update-available",
13987
+ "alarm-triggered",
13988
+ "alarm-armed",
13989
+ "alarm-disarmed",
13990
+ "camera-online",
13991
+ "camera-offline",
13992
+ "camera-disabled",
13993
+ "camera-enabled"
13994
+ ]);
13995
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
13996
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
13997
+ "camera-online",
13998
+ "camera-offline",
13999
+ "camera-disabled",
14000
+ "camera-enabled"
13922
14001
  ]);
14002
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
13923
14003
  /**
13924
14004
  * One coherent system-event condition. `kinds` is the required opt-in safety
13925
14005
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -13928,6 +14008,18 @@ var NcSystemEventKindSchema = _enum([
13928
14008
  var NcSystemEventConditionSchema = object({
13929
14009
  kinds: array(NcSystemEventKindSchema).min(1),
13930
14010
  deviceIds: array(number().int()).min(1).optional(),
14011
+ /**
14012
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14013
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14014
+ * is what a liveness rule means when nobody said otherwise.
14015
+ *
14016
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14017
+ * one reason: the intake cannot know which devices this household cares
14018
+ * about, and a producer-side filter is one no operator can change. Fails
14019
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14020
+ * does not carry) matches no `deviceTypes` list.
14021
+ */
14022
+ deviceTypes: array(string().min(1)).min(1).optional(),
13931
14023
  nodeIds: array(string().min(1)).min(1).optional(),
13932
14024
  packageNames: array(string().min(1)).min(1).optional()
13933
14025
  });
@@ -13978,6 +14070,47 @@ var NcOccupancyConditionSchema = object({
13978
14070
  sustainSeconds: number().int().min(0).max(3600).default(15)
13979
14071
  });
13980
14072
  /**
14073
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14074
+ *
14075
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14076
+ * reference notifier uses, so an operator moving between them re-uses what
14077
+ * they already know): a rule matches when, over a sampling window of
14078
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14079
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14080
+ *
14081
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14082
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14083
+ * - `labels` — the classifier put at least one of these labels on it.
14084
+ *
14085
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14086
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14087
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14088
+ * is given** — a window in which every sample is trivially a hit would fire on
14089
+ * silence, so the engine refuses such a condition rather than notifying on
14090
+ * nothing (the schema cannot express "at least one of" without becoming a
14091
+ * ZodEffects the cap path would have to special-case).
14092
+ *
14093
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14094
+ * must be FULL before it can match — a window that has been open for two
14095
+ * seconds of its ten is 100% of nothing, and firing on it would make
14096
+ * `samplingSeconds` decorative.
14097
+ *
14098
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14099
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14100
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14101
+ * an operator who typed `dog` mean the same thing.
14102
+ */
14103
+ var NcAudioConditionSchema = object({
14104
+ /** Audio macro labels; absent = any sound (level-only rule). */
14105
+ labels: array(string().min(1)).min(1).optional(),
14106
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14107
+ dbThreshold: number().min(-96).max(0).optional(),
14108
+ /** Percentage of the window's samples that must be hits (1–100). */
14109
+ hitPercent: number().int().min(1).max(100).default(60),
14110
+ /** Length of the sampling window in seconds. */
14111
+ samplingSeconds: number().int().min(1).max(300).default(10)
14112
+ });
14113
+ /**
13981
14114
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
13982
14115
  *
13983
14116
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14250,7 +14383,33 @@ var NcConditionsSchema = object({
14250
14383
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14251
14384
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14252
14385
  */
14253
- occupancy: NcOccupancyConditionSchema.optional()
14386
+ occupancy: NcOccupancyConditionSchema.optional(),
14387
+ /**
14388
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14389
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14390
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14391
+ * a window that is not full yet, neither filter given). See
14392
+ * {@link NcAudioCondition}.
14393
+ *
14394
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14395
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14396
+ * a detection, a track or a device event (the same fail-closed pairing
14397
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14398
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14399
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14400
+ * classified sample) stays exactly as it was for rules that already use it.
14401
+ *
14402
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14403
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14404
+ * (`camstack/src/data/notification-center.ts`, guarded by
14405
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14406
+ * condition fields it does not know when a rule is saved from the phone.
14407
+ * Publishing an editor for a condition the app cannot round-trip is how an
14408
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14409
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14410
+ * does an audio rule become authorable.
14411
+ */
14412
+ audio: NcAudioConditionSchema.optional()
14254
14413
  });
14255
14414
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14256
14415
  var NcRuleTargetSchema = object({
@@ -14364,6 +14523,73 @@ var NcThrottleSchema = object({
14364
14523
  */
14365
14524
  granularity: NcThrottleGranularitySchema.optional()
14366
14525
  });
14526
+ /**
14527
+ * How long the confirm gate may hold ONE notification, and how big the picture
14528
+ * it judges may be.
14529
+ *
14530
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14531
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14532
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14533
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14534
+ * tokens for pixels the model pools away.
14535
+ */
14536
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14537
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14538
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14539
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14540
+ var NcConfirmExpectSchema = object({
14541
+ op: _enum([
14542
+ ">=",
14543
+ ">",
14544
+ "<=",
14545
+ "<",
14546
+ "=="
14547
+ ]),
14548
+ count: number().int().min(0).max(1e3)
14549
+ });
14550
+ /**
14551
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14552
+ * to ship and says whether it agrees with the rule.
14553
+ *
14554
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14555
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14556
+ * on the operator's phone is not a verdict about this notification.
14557
+ *
14558
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14559
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14560
+ * the default and every fail-open is COUNTED, because a gate that always fails
14561
+ * open looks in the log exactly like a gate that works.
14562
+ *
14563
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14564
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14565
+ * production failures in one day), so the gate reads absent as the constant
14566
+ * above rather than trusting a parse it may never have seen.
14567
+ */
14568
+ var NcConfirmSchema = object({
14569
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14570
+ * same thing, and both mean "deliver exactly as before". */
14571
+ enabled: boolean().default(false),
14572
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14573
+ profileId: string().optional(),
14574
+ /**
14575
+ * The operator's question, in his own words. Absent = a question derived
14576
+ * from the rule (its class and its expectation).
14577
+ *
14578
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14579
+ * banners, signage and plates as instructions if you let them reach the
14580
+ * prompt — proven live — so the authoritative contract stays in the system
14581
+ * turn and only rule-authored words land here.
14582
+ */
14583
+ prompt: string().max(1e3).optional(),
14584
+ /** Fire only when the model's count satisfies this. Absent = the model's
14585
+ * own boolean verdict decides. */
14586
+ expect: NcConfirmExpectSchema.optional(),
14587
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14588
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14589
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14590
+ /** Longest edge the judged image is downscaled to before it is sent. */
14591
+ maxImagePx: number().int().min(64).max(2048).default(448)
14592
+ });
14367
14593
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14368
14594
  var NcRuleInputSchema = object({
14369
14595
  name: string().min(1).max(200),
@@ -14424,7 +14650,13 @@ var NcRuleInputSchema = object({
14424
14650
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14425
14651
  * shape as every other actuation.
14426
14652
  */
14427
- actions: NcRuleActionsSchema.optional()
14653
+ actions: NcRuleActionsSchema.optional(),
14654
+ /**
14655
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14656
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14657
+ * did, and absent is the only way to say that without a migration.
14658
+ */
14659
+ confirm: NcConfirmSchema.optional()
14428
14660
  });
14429
14661
  /**
14430
14662
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14435,7 +14667,37 @@ var NcRuleInputSchema = object({
14435
14667
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14436
14668
  * `updateRule` patch.
14437
14669
  */
14438
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14670
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14671
+ disabledTargetIds: array(string()).optional(),
14672
+ /**
14673
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14674
+ *
14675
+ * It makes the key optional to SUPPLY; the parse still materialises the
14676
+ * default when the key is absent. And `NcRuleStore.update` merges with
14677
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14678
+ * one — which made every partial edit destructive:
14679
+ *
14680
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14681
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14682
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14683
+ *
14684
+ * A rule scoped to one camera and one zone silently became a rule that
14685
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14686
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14687
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14688
+ * within a minute of a two-field patch.
14689
+ *
14690
+ * So every defaulted field is re-declared here WITHOUT its default. The
14691
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14692
+ * conditions remains a real instruction ("clear them") — and only the
14693
+ * absent key is now genuinely absent.
14694
+ */
14695
+ enabled: boolean().optional(),
14696
+ conditions: NcConditionsSchema.optional(),
14697
+ media: NcMediaPolicySchema.optional(),
14698
+ throttle: NcThrottleSchema.optional(),
14699
+ priority: number().int().min(1).max(5).optional()
14700
+ });
14439
14701
  /** A persisted rule. */
14440
14702
  var NcRuleSchema = NcRuleInputSchema.extend({
14441
14703
  id: string(),
@@ -14736,6 +14998,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14736
14998
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14737
14999
  * copy would lie the first time a rule is disabled.
14738
15000
  */
15001
+ /**
15002
+ * Why a device a mode NAMES is nonetheless not armed by it.
15003
+ *
15004
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15005
+ * per-camera notification switch the Notification Center already owns,
15006
+ * `detection-off` is the device's own detection binding being inactive, and
15007
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15008
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15009
+ * with the switches the operator actually used.
15010
+ */
15011
+ var NcAlarmSkipReasonSchema = _enum([
15012
+ "muted",
15013
+ "detection-off",
15014
+ "offline"
15015
+ ]);
15016
+ var NcAlarmSkippedDeviceSchema = object({
15017
+ deviceId: number().int(),
15018
+ reason: NcAlarmSkipReasonSchema
15019
+ });
14739
15020
  var NcAlarmModeCoverageSchema = object({
14740
15021
  mode: AlarmArmModeSchema,
14741
15022
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14743,7 +15024,18 @@ var NcAlarmModeCoverageSchema = object({
14743
15024
  /** At least one covering rule has no device scope, so the mode covers all. */
14744
15025
  allDevices: boolean(),
14745
15026
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14746
- deviceIds: array(number().int())
15027
+ deviceIds: array(number().int()),
15028
+ /**
15029
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15030
+ * excludes it.
15031
+ *
15032
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15033
+ * twelve makes it false in exactly the way nobody notices until an incident.
15034
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15035
+ * still parses as "nothing known to be skipped" rather than failing the whole
15036
+ * alarm tab.
15037
+ */
15038
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14747
15039
  });
14748
15040
  var NcAlarmConfigSchema = object({
14749
15041
  /**
@@ -17542,9 +17834,16 @@ var CameraStatusSchema = object({
17542
17834
  audio: CameraAudioStatusSchema.nullable(),
17543
17835
  recording: CameraRecordingStatusSchema.nullable(),
17544
17836
  /**
17545
- * Per-camera function switches an OPERATOR has turned off
17837
+ * Per-camera functions an OPERATOR has turned off
17546
17838
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17547
17839
  *
17840
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
17841
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
17842
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
17843
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
17844
+ * The badge outlives the control panel: the panel was a convenience, this is
17845
+ * the difference between a camera being off and a camera being dead.
17846
+ *
17548
17847
  * This is the difference between DISABLED and BROKEN. A camera whose
17549
17848
  * `detection` block reports zero fps and whose `switchedOff` contains
17550
17849
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -18151,24 +18450,28 @@ var snapshotCapability = {
18151
18450
  *
18152
18451
  * `getSnapshotOverview` is cache-only by contract: it answers from whatever
18153
18452
  * the wrapper happens to hold and never captures. Under D93 the client
18154
- * versions its image URL on that answer, and an image REQUEST is what enrols
18155
- * a camera in the keep-warm loop. Both of those are satisfiable by the
18156
- * client's own image cache — `expo-image` is URL-keyed and never revalidates
18157
- * — so a URL painted in a previous session comes off disk with no network,
18158
- * no enrolment, and nothing warming. Measured on the live hub: reopening
18159
- * after two minutes idle painted 15 of 16 tiles at **168 s old** with zero
18160
- * HTTP requests, and the fleet only recovered because a later poll happened
18161
- * to observe a different identity.
18453
+ * versions its image URL on that answer, and an image REQUEST was the only
18454
+ * demand signal. Both of those are satisfiable by the client's own image
18455
+ * cache — `expo-image` is URL-keyed and never revalidates — so a URL painted
18456
+ * in a previous session comes off disk with no network, no demand, and no
18457
+ * capture. Measured on the live hub: reopening after two minutes idle
18458
+ * painted 15 of 16 tiles at **168 s old** with zero HTTP requests, and the
18459
+ * fleet only recovered because a later poll happened to observe a different
18460
+ * identity.
18162
18461
  *
18163
18462
  * ## The two properties that fix it
18164
18463
  *
18165
18464
  * **It is an RPC, so no client cache can answer it.** The demand signal
18166
- * always reaches the wrapper. This method therefore MAY create keep-warm
18167
- * subscriptions, where `getSnapshotOverview` must never (D93) — the
18168
- * distinction is not "one is newer" but that the overview poll is app-wide
18169
- * (a creating overview would warm every camera on the install) while this is
18170
- * called by a rendered surface naming the tiles it is actually painting, at
18171
- * the width it is painting them.
18465
+ * always reaches the wrapper. This method therefore CAPTURES, where
18466
+ * `getSnapshotOverview` must never (D93) — the distinction is not "one is
18467
+ * newer" but that the overview poll is app-wide (a capturing overview would
18468
+ * dial every camera on the install) while this is called by a rendered
18469
+ * surface naming the tiles it is actually painting, at the width it is
18470
+ * painting them.
18471
+ *
18472
+ * Since 2026-08-11 this is the ONLY thing that refreshes a snapshot: the
18473
+ * server-side keep-warm loop was removed (operator directive — on-demand,
18474
+ * always), so a camera nobody is looking at costs nothing at all.
18172
18475
  *
18173
18476
  * **It waits, briefly and boundedly, for the capture it triggered.** The
18174
18477
  * returned `capturedAt` is the frame the link will serve, not the frame the
@@ -23186,7 +23489,19 @@ var RecordingManifestSchema = object({
23186
23489
  * profiles/subtrees/locations on this node). */
23187
23490
  var RecordingDeviceUsageSchema = object({
23188
23491
  deviceId: number(),
23189
- usedBytes: number()
23492
+ usedBytes: number(),
23493
+ /**
23494
+ * Start of this camera's OLDEST indexed segment, across every profile and
23495
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23496
+ * only honest answer to "is retention actually holding?" per camera.
23497
+ *
23498
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23499
+ * predates this field omits it entirely, and a hub whose types carry the
23500
+ * field must keep validating that older provider's payload: the framework
23501
+ * (types) and the addon ship on different trains, and the addon is usually
23502
+ * the later of the two.
23503
+ */
23504
+ oldestMs: number().nullable().optional()
23190
23505
  });
23191
23506
  /** Recording storage usage + capacity for one storage location. */
23192
23507
  var RecordingLocationUsageSchema = object({
@@ -23214,6 +23529,57 @@ var RecordingStorageUsageSchema = object({
23214
23529
  locations: array(RecordingLocationUsageSchema)
23215
23530
  });
23216
23531
  /**
23532
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23533
+ *
23534
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23535
+ * is the operator asking for the EXISTING archive to be brought into line with
23536
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23537
+ * location, run FIFO behind the single-flight mover.
23538
+ *
23539
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23540
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23541
+ * (empty on the plan).
23542
+ */
23543
+ var RecordingRebalanceMoveSchema = object({
23544
+ deviceId: number(),
23545
+ profile: string(),
23546
+ fromLocationId: string(),
23547
+ toLocationId: string(),
23548
+ bytes: number(),
23549
+ files: number().int()
23550
+ });
23551
+ /** Why a pile that is out of place is staying there. Every refusal is
23552
+ * reported: a rebalance that silently drops a camera reads exactly like one
23553
+ * that had nothing to do. */
23554
+ var RecordingRebalanceSkipReasonSchema = _enum([
23555
+ "unassigned",
23556
+ "target-not-writable",
23557
+ "below-threshold",
23558
+ "no-headroom"
23559
+ ]);
23560
+ var RecordingRebalanceSkipSchema = object({
23561
+ deviceId: number(),
23562
+ profile: string(),
23563
+ fromLocationId: string(),
23564
+ /** The location the plan wants; null when the camera has no assignment. */
23565
+ toLocationId: string().nullable(),
23566
+ bytes: number(),
23567
+ reason: RecordingRebalanceSkipReasonSchema
23568
+ });
23569
+ var RecordingRebalancePlanSchema = object({
23570
+ moves: array(RecordingRebalanceMoveSchema),
23571
+ skipped: array(RecordingRebalanceSkipSchema),
23572
+ bytesToMove: number(),
23573
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23574
+ jobIds: array(string())
23575
+ });
23576
+ var RecordingRebalanceInputSchema = object({
23577
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23578
+ throttleMbps: number().min(1).max(1e3).optional(),
23579
+ /** Ignore piles smaller than this (default 1 GB). */
23580
+ minMoveGb: number().min(0).optional()
23581
+ });
23582
+ /**
23217
23583
  * Result of locating footage at a wall-clock instant for one device/profile.
23218
23584
  * `segment` carries the covering segment's window; `gap` reports the forward
23219
23585
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23376,9 +23742,24 @@ method(object({
23376
23742
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23377
23743
  kind: "mutation",
23378
23744
  auth: "admin"
23745
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23746
+ kind: "mutation",
23747
+ auth: "admin"
23748
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23749
+ kind: "query",
23750
+ auth: "admin"
23751
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23752
+ kind: "mutation",
23753
+ auth: "admin"
23754
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23755
+ kind: "query",
23756
+ auth: "admin"
23757
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23758
+ kind: "mutation",
23759
+ auth: "admin"
23379
23760
  });
23380
23761
  /**
23381
- * `recordingExport` cap — render a footage time range into a single downloadable
23762
+ * `recording-export` cap — render a footage time range into a single downloadable
23382
23763
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23383
23764
  * bounded lifetime with a durable history, auto-expiry, and optional
23384
23765
  * delete-after-download.
@@ -23393,10 +23774,53 @@ method(object({
23393
23774
  */
23394
23775
  /** Playback-speed multiplier for the render (1 = realtime). */
23395
23776
  var ExportSpeedSchema = number().min(.25).max(32);
23777
+ /**
23778
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23779
+ *
23780
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23781
+ * derives these bounds from things that happened at a TIME (a track's
23782
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23783
+ * every segment present for the range, with each recording GAP removed. The
23784
+ * two agree only on a window that recorded without one interruption, and only
23785
+ * the render side knows the segments, so the translation lives there
23786
+ * (`export-dense-map.ts`, addon-pipeline).
23787
+ *
23788
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23789
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23790
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23791
+ * the video was a uniform timelapse, and the log line reported the five ranges
23792
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23793
+ *
23794
+ * Relative and not absolute epoch, because an absolute epoch would make every
23795
+ * call site responsible for the same subtraction.
23796
+ */
23797
+ var ExportDenseRangeSchema = object({
23798
+ fromSec: number().nonnegative(),
23799
+ toSec: number().nonnegative()
23800
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23801
+ /**
23802
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23803
+ * listed ranges and at the base `everyMs` everywhere else.
23804
+ *
23805
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23806
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23807
+ */
23808
+ var ExportDenseSchema = object({
23809
+ everyMs: number().int().positive(),
23810
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23811
+ });
23396
23812
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23397
23813
  var ExportTimelapseSchema = object({
23398
23814
  everyMs: number().int().positive(),
23399
- outputFps: number().int().min(1).max(60).optional()
23815
+ outputFps: number().int().min(1).max(60).optional(),
23816
+ /** Optional second, FASTER rate over the intervals that matter. */
23817
+ dense: ExportDenseSchema.optional()
23818
+ }).superRefine((v, ctx) => {
23819
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23820
+ code: ZodIssueCode.custom,
23821
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23822
+ path: ["dense", "everyMs"]
23823
+ });
23400
23824
  });
23401
23825
  /**
23402
23826
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23454,6 +23878,19 @@ var ExportDownloadSchema = object({
23454
23878
  url: string(),
23455
23879
  endpoints: array(string())
23456
23880
  });
23881
+ /**
23882
+ * A finished export's bytes, inline.
23883
+ *
23884
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23885
+ * against, so nobody has to infer it from the base64 length.
23886
+ */
23887
+ var ExportBytesSchema = object({
23888
+ base64: string(),
23889
+ contentType: string(),
23890
+ /** Suggested filename, extension included. */
23891
+ name: string(),
23892
+ bytes: number().int().nonnegative()
23893
+ });
23457
23894
  method(object({
23458
23895
  deviceId: number(),
23459
23896
  profile: string(),
@@ -23478,6 +23915,9 @@ method(object({
23478
23915
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23479
23916
  kind: "query",
23480
23917
  auth: "protected"
23918
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
23919
+ kind: "query",
23920
+ auth: "protected"
23481
23921
  });
23482
23922
  /**
23483
23923
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -29080,6 +29520,12 @@ Object.freeze({
29080
29520
  addonId: null,
29081
29521
  access: "create"
29082
29522
  },
29523
+ "recording.cancelRelocateJob": {
29524
+ capName: "recording",
29525
+ capScope: "system",
29526
+ addonId: null,
29527
+ access: "create"
29528
+ },
29083
29529
  "recording.cancelStorageMigrationMove": {
29084
29530
  capName: "recording",
29085
29531
  capScope: "system",
@@ -29134,6 +29580,12 @@ Object.freeze({
29134
29580
  addonId: null,
29135
29581
  access: "view"
29136
29582
  },
29583
+ "recording.listRelocateJobs": {
29584
+ capName: "recording",
29585
+ capScope: "system",
29586
+ addonId: null,
29587
+ access: "view"
29588
+ },
29137
29589
  "recording.locateSegment": {
29138
29590
  capName: "recording",
29139
29591
  capScope: "system",
@@ -29146,6 +29598,12 @@ Object.freeze({
29146
29598
  addonId: null,
29147
29599
  access: "create"
29148
29600
  },
29601
+ "recording.planStorageRebalance": {
29602
+ capName: "recording",
29603
+ capScope: "system",
29604
+ addonId: null,
29605
+ access: "view"
29606
+ },
29149
29607
  "recording.pruneFootage": {
29150
29608
  capName: "recording",
29151
29609
  capScope: "system",
@@ -29170,6 +29628,12 @@ Object.freeze({
29170
29628
  addonId: null,
29171
29629
  access: "create"
29172
29630
  },
29631
+ "recording.relocateFootage": {
29632
+ capName: "recording",
29633
+ capScope: "system",
29634
+ addonId: null,
29635
+ access: "create"
29636
+ },
29173
29637
  "recording.renderClip": {
29174
29638
  capName: "recording",
29175
29639
  capScope: "system",
@@ -29206,38 +29670,50 @@ Object.freeze({
29206
29670
  addonId: null,
29207
29671
  access: "create"
29208
29672
  },
29673
+ "recording.startStorageRebalance": {
29674
+ capName: "recording",
29675
+ capScope: "system",
29676
+ addonId: null,
29677
+ access: "create"
29678
+ },
29209
29679
  "recordingExport.cancelExport": {
29210
- capName: "recordingExport",
29680
+ capName: "recording-export",
29211
29681
  capScope: "system",
29212
29682
  addonId: null,
29213
29683
  access: "create"
29214
29684
  },
29215
29685
  "recordingExport.createExport": {
29216
- capName: "recordingExport",
29686
+ capName: "recording-export",
29217
29687
  capScope: "system",
29218
29688
  addonId: null,
29219
29689
  access: "create"
29220
29690
  },
29221
29691
  "recordingExport.deleteExport": {
29222
- capName: "recordingExport",
29692
+ capName: "recording-export",
29223
29693
  capScope: "system",
29224
29694
  addonId: null,
29225
29695
  access: "delete"
29226
29696
  },
29227
29697
  "recordingExport.getDownloadUrl": {
29228
- capName: "recordingExport",
29698
+ capName: "recording-export",
29229
29699
  capScope: "system",
29230
29700
  addonId: null,
29231
29701
  access: "view"
29232
29702
  },
29233
29703
  "recordingExport.getExport": {
29234
- capName: "recordingExport",
29704
+ capName: "recording-export",
29235
29705
  capScope: "system",
29236
29706
  addonId: null,
29237
29707
  access: "view"
29238
29708
  },
29239
29709
  "recordingExport.listExports": {
29240
- capName: "recordingExport",
29710
+ capName: "recording-export",
29711
+ capScope: "system",
29712
+ addonId: null,
29713
+ access: "view"
29714
+ },
29715
+ "recordingExport.readExportBytes": {
29716
+ capName: "recording-export",
29241
29717
  capScope: "system",
29242
29718
  addonId: null,
29243
29719
  access: "view"
@@ -30614,6 +31090,104 @@ var FramerateField = number().int().min(1).max(60);
30614
31090
  var TargetsField = array(NcRuleTargetSchema).min(1);
30615
31091
  var PriorityField = number().int().min(1).max(5);
30616
31092
  /**
31093
+ * Explicit override of the DENSE sampling cadence, seconds.
31094
+ *
31095
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
31096
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
31097
+ * made that same base 3 s and rendered a person pass as two frames.)
31098
+ *
31099
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
31100
+ * `denseCadenceSec` and played at `framerate` occupies
31101
+ *
31102
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
31103
+ *
31104
+ * 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.
31105
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
31106
+ * and therefore the length of a quiet night, does not move.
31107
+ *
31108
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
31109
+ * the recording has them returns the same frames, requested twice. Must be
31110
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
31111
+ * a uniform video the operator believes is two-rate — and upsert refuses it
31112
+ * rather than letting the export cap reject the render hours after the window.
31113
+ */
31114
+ var DenseCadenceSecField = number().min(.1).max(3600);
31115
+ /**
31116
+ * Minimum seconds of OUTPUT video each detection range must occupy.
31117
+ *
31118
+ * The operator-facing form of the arithmetic above: instead of solving for a
31119
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
31120
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
31121
+ * that range every ~583 ms.
31122
+ *
31123
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
31124
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
31125
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
31126
+ * ranges are sampled denser than they need. Per-range cadences require a cap
31127
+ * schema change and are the tracked follow-up.
31128
+ *
31129
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
31130
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
31131
+ * by real footage, never met by duplicating frames into motion that never
31132
+ * happened.
31133
+ */
31134
+ var MinDwellSecField = number().min(0).max(60);
31135
+ /**
31136
+ * Caption burned into the notification's preview frame.
31137
+ *
31138
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
31139
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
31140
+ * templating dialect for one field would be a second thing to explain.
31141
+ *
31142
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
31143
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
31144
+ * the reason this is not `.min(1)`.
31145
+ */
31146
+ var PreviewTextField = string().max(200);
31147
+ /**
31148
+ * Whether the notification's preview is a STILL or a short animation.
31149
+ *
31150
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
31151
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
31152
+ * night reads better as three seconds of motion than as one frame of it. Both
31153
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
31154
+ * simply applies it to a dozen frames sampled across the render and assembles
31155
+ * them.
31156
+ *
31157
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
31158
+ * seeks and a palette pass, and no rule that never asked for one should start
31159
+ * paying that on the deploy that shipped it.
31160
+ *
31161
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
31162
+ */
31163
+ var PreviewModeField = _enum(["image", "gif"]);
31164
+ /**
31165
+ * Which detection classes the notification reports counts for.
31166
+ *
31167
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
31168
+ * plan — no second query — aggregated per class. Absent or empty means "every
31169
+ * class the window actually contained", which is what an operator who never
31170
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
31171
+ * counts cars all night).
31172
+ *
31173
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
31174
+ * …). An unknown name simply never matches and reports nothing — it is not an
31175
+ * error, because a rule may legitimately name a class this camera's model does
31176
+ * not emit.
31177
+ *
31178
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
31179
+ * - `{{detections}}` — total over the reported classes
31180
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
31181
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
31182
+ * one per class, `count_` + the class name
31183
+ *
31184
+ * With NO custom body template the summary is appended to the derived body, and
31185
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
31186
+ * reads. With a custom template the operator owns every word — nothing is
31187
+ * appended, so `{{detectionSummary}}` is how he asks for it.
31188
+ */
31189
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
31190
+ /**
30617
31191
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30618
31192
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30619
31193
  * here (see the ownership note above).
@@ -30633,9 +31207,30 @@ var TimelapseRuleInputSchema = object({
30633
31207
  cadenceSec: CadenceSecField.default(15),
30634
31208
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30635
31209
  framerate: FramerateField.default(10),
31210
+ /**
31211
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
31212
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
31213
+ * field gets.
31214
+ */
31215
+ denseCadenceSec: DenseCadenceSecField.optional(),
31216
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
31217
+ minDwellSec: MinDwellSecField.optional(),
30636
31218
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30637
31219
  targets: TargetsField,
30638
31220
  template: TimelapseTemplateSchema.optional(),
31221
+ /**
31222
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
31223
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
31224
+ *
31225
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
31226
+ * the notification's title/body, and clearing it (`template: null`) must not
31227
+ * silently clear the caption too.
31228
+ */
31229
+ previewText: PreviewTextField.optional(),
31230
+ /** Still or animation — see {@link PreviewModeField}. */
31231
+ previewMode: PreviewModeField.default("image"),
31232
+ /** Classes the notification counts — see {@link ReportClassesField}. */
31233
+ reportClasses: ReportClassesField.optional(),
30639
31234
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30640
31235
  priority: PriorityField.default(3)
30641
31236
  });
@@ -30646,8 +31241,13 @@ object({
30646
31241
  schedule: NcScheduleSchema.optional(),
30647
31242
  cadenceSec: CadenceSecField.optional(),
30648
31243
  framerate: FramerateField.optional(),
31244
+ denseCadenceSec: DenseCadenceSecField.optional(),
31245
+ minDwellSec: MinDwellSecField.optional(),
30649
31246
  targets: TargetsField.optional(),
30650
31247
  template: TimelapseTemplateSchema.nullable().optional(),
31248
+ previewText: PreviewTextField.optional(),
31249
+ previewMode: PreviewModeField.optional(),
31250
+ reportClasses: ReportClassesField.optional(),
30651
31251
  priority: PriorityField.optional()
30652
31252
  });
30653
31253
  TimelapseRuleInputSchema.extend({
@@ -30659,10 +31259,28 @@ TimelapseRuleInputSchema.extend({
30659
31259
  */
30660
31260
  ownerUserId: string().optional(),
30661
31261
  /**
30662
- * Epoch-ms of the last successful generation the 1-hour re-generation
30663
- * guard's durable state (predecessor parity). Absent = never generated.
31262
+ * Epoch-ms of the NEWEST successful generation across every camera of this
31263
+ * rule. What a UI shows, and the compatibility floor for
31264
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30664
31265
  */
30665
31266
  lastGeneratedAt: number().optional(),
31267
+ /**
31268
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
31269
+ * re-generation guard's real durable state.
31270
+ *
31271
+ * One rule covers several cameras and each renders its own video, so a rule
31272
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
31273
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
31274
+ * already done — and B's night is gone for good, because the window will not
31275
+ * come back.
31276
+ *
31277
+ * ADDITIVE, so the migration is free: a row written before this field simply
31278
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
31279
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
31280
+ * "never generated" would re-render and re-notify every camera of every rule
31281
+ * once, on the deploy that shipped the map.
31282
+ */
31283
+ generatedByDevice: record(string(), number()).optional(),
30666
31284
  /** userId of the caller who created the rule (server-stamped). */
30667
31285
  createdBy: string(),
30668
31286
  createdAt: number(),
@@ -30713,25 +31331,32 @@ object({
30713
31331
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30714
31332
  object({
30715
31333
  /**
30716
- * How long a retained native frame is served before it counts as a miss.
31334
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
31335
+ * detection result.
30717
31336
  *
30718
- * Must cover the FULL late-crop horizon: detection inference + the
30719
- * cross-process inference-result hop to hub post-analysis + tracking + the
30720
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30721
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30722
- * RAM per busy camera grows linearly with no measured hit-rate gain.
31337
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
31338
+ * a time window was never related to the event the pixels were waiting for.
31339
+ * A held frame now lives from delivery until the runner has its `FrameResult`
31340
+ * at which moment the runner cuts the subject tiles it actually wanted and
31341
+ * releases the frame. The bound exists only so a runner that stops answering
31342
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
31343
+ *
31344
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
31345
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
31346
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
31347
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
31348
+ * `holdOverflow` on the metrics line is what says you need it.
30723
31349
  */
30724
- ttlMs: number().int().min(250).max(1e4),
31350
+ holdFrames: number().int().min(1).max(64),
30725
31351
  /**
30726
31352
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30727
31353
  *
30728
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30729
- * which one is actually binding before reasoning from that. At the shipped
30730
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30731
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30732
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30733
- * change that admits fewer frames buys retention WINDOW at constant RAM
30734
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
31354
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
31355
+ * is what decides how much is held, and the ceiling is the number above which
31356
+ * something is wrong. Before that it was the effective cap at 1024 MB with
31357
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
31358
+ * with the TTL expiring nothing, which is exactly the confusion the hold
31359
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30735
31360
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30736
31361
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30737
31362
  * to replace).
@@ -30757,22 +31382,45 @@ object({
30757
31382
  * there is the signal that some caller names frames outside the inference set
30758
31383
  * and that this must go back to `all`.
30759
31384
  */
30760
- admission: NativeLeaseAdmissionSchema
31385
+ admission: NativeLeaseAdmissionSchema,
31386
+ /**
31387
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
31388
+ * compressed native crops the worker cuts at the moment a frame's detection
31389
+ * result arrives, and keeps long after the frame itself is freed.
31390
+ *
31391
+ * This is the knob that replaced the old retention window, and it buys about
31392
+ * three orders of magnitude more of it: a tile is one subject at native
31393
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
31394
+ * the frame it was cut from. A frame on which nothing was detected costs
31395
+ * nothing at all, which is the real change — the old lease paid per FRAME and
31396
+ * was interrogated per SUBJECT.
31397
+ *
31398
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
31399
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
31400
+ * reproduce that.
31401
+ */
31402
+ tileBudgetMb: number().int().min(0).max(1024)
30761
31403
  });
30762
31404
  /**
30763
- * The values in force when the operator has set nothing — byte-for-byte the
30764
- * constants the decode worker shipped with as env-var defaults, so making these
30765
- * settings changed no behaviour on the day it landed.
31405
+ * The values in force when the operator has set nothing.
31406
+ *
31407
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
31408
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
31409
+ * in the same change that redefines it would make a regression and a retune
31410
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
31411
+ * live traffic.
30766
31412
  */
30767
31413
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30768
- ttlMs: 1200,
31414
+ holdFrames: 8,
30769
31415
  budgetMb: 1024,
30770
31416
  activityMs: 15e3,
31417
+ tileBudgetMb: 64,
30771
31418
  admission: "inferred"
30772
31419
  };
30773
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
31420
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30774
31421
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30775
31422
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
31423
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30776
31424
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30777
31425
  //#endregion
30778
31426
  //#region src/onvif-camera.ts