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