@camstack/addon-provider-hikvision 1.2.16 → 1.2.18

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
@@ -7201,8 +7201,31 @@ var AdoptionJobSchema = object({
7201
7201
  error: string().nullable()
7202
7202
  });
7203
7203
  /**
7204
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7205
- * pipeline functions an operator thinks in terms of.
7204
+ * Per-camera FUNCTION SWITCHES.
7205
+ *
7206
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7207
+ *
7208
+ * This file shipped as "the one coherent on/off surface over the pipeline
7209
+ * functions an operator thinks in terms of". The operator's verdict on
7210
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7211
+ * every function already had a settings page of its own, and a second place to
7212
+ * turn it off is a second place to look. Each switch is going back to its own
7213
+ * component's original options — detection to the detection-pipeline wrapper
7214
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7215
+ * (which was always first-class; the switch was a veneer over
7216
+ * `recording.setDeviceConfig`), notifications to a notification-center
7217
+ * per-device setting, the two camera planes to their own components.
7218
+ *
7219
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7220
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7221
+ * straight from the authorities with no group in the middle. That rule was
7222
+ * never about a control panel.
7223
+ *
7224
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7225
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7226
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7227
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7228
+ * stop; nothing new may be built on it.
7206
7229
  *
7207
7230
  * ## This file adds no state
7208
7231
  *
@@ -7553,7 +7576,15 @@ var RecordingConfigSchema = object({
7553
7576
  * Each completed/failed run also lands one durable ops-log row on its owning
7554
7577
  * addon surface.
7555
7578
  */
7579
+ /**
7580
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7581
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7582
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7583
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7584
+ * runs at all.
7585
+ */
7556
7586
  var RelocateJobStateSchema = _enum([
7587
+ "queued",
7557
7588
  "running",
7558
7589
  "done",
7559
7590
  "failed",
@@ -7588,6 +7619,15 @@ var RelocateFootageInputSchema = object({
7588
7619
  /** Limits relocation to the logical profile class. Omit only for the
7589
7620
  * pre-orchestration compatibility path. */
7590
7621
  footageClass: RelocateFootageClassSchema.optional(),
7622
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7623
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7624
+ * unit is a (camera, profile) pile, not a disk. */
7625
+ deviceId: number().int().optional(),
7626
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7627
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7628
+ * placement plan assigns those two independently, so a rebalance that could
7629
+ * only say "recordings" would move footage the plan never asked to move. */
7630
+ profiles: array(string()).optional(),
7591
7631
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7592
7632
  * never allowed to starve live writers. */
7593
7633
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7723,6 +7763,21 @@ var StorageLocationSchema = object({
7723
7763
  nodeId: string().optional(),
7724
7764
  isDefault: boolean().default(false),
7725
7765
  isSystem: boolean().default(false),
7766
+ /**
7767
+ * Operator opt-in: whether consumers that BALANCE across several locations
7768
+ * of a type may write here. Recordings reads it today; event media and
7769
+ * backups are the next consumers, which is why the flag lives on the
7770
+ * location rather than in any one addon's store — nothing has to be
7771
+ * extended to add the next consumer.
7772
+ *
7773
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7774
+ * flag existed reads back with no flag and keeps working exactly as before;
7775
+ * that is the whole compat story, and it is why no migration ships with it.
7776
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7777
+ * disk must not silently start writing to it); the default of a type is
7778
+ * always stamped `true`.
7779
+ */
7780
+ enabled: boolean().optional(),
7726
7781
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7727
7782
  * for node-local locations it can reach) — never persisted, absent when the
7728
7783
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12462,7 +12517,8 @@ method(object({
12462
12517
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12463
12518
  /**
12464
12519
  * filesystem-browse — per-node capability for browsing the node's local
12465
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12520
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12521
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12466
12522
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12467
12523
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12468
12524
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14303,6 +14359,13 @@ var MaskGridDimsSchema = object({
14303
14359
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14304
14360
  * this one field keeps the schema additive — a rule still declares exactly
14305
14361
  * one trigger.
14362
+ *
14363
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14364
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14365
+ * mirror.ts` fails the build on a member the app cannot render) and every
14366
+ * member costs a release train. A sustained-sound rule is therefore an
14367
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14368
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14306
14369
  */
14307
14370
  var NcDeliverySchema = _enum([
14308
14371
  "immediate",
@@ -14317,15 +14380,32 @@ var NcDeliverySchema = _enum([
14317
14380
  * depend on a provider's raw event name or payload shape.
14318
14381
  */
14319
14382
  var NcSystemEventKindSchema = _enum([
14320
- "camera-online",
14321
- "camera-offline",
14383
+ "device-online",
14384
+ "device-offline",
14385
+ "device-disabled",
14386
+ "device-enabled",
14322
14387
  "stream-online",
14323
14388
  "stream-offline",
14324
14389
  "node-online",
14325
14390
  "node-offline",
14326
14391
  "addon-update-available",
14327
- "server-update-available"
14392
+ "server-update-available",
14393
+ "alarm-triggered",
14394
+ "alarm-armed",
14395
+ "alarm-disarmed",
14396
+ "camera-online",
14397
+ "camera-offline",
14398
+ "camera-disabled",
14399
+ "camera-enabled"
14400
+ ]);
14401
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14402
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14403
+ "camera-online",
14404
+ "camera-offline",
14405
+ "camera-disabled",
14406
+ "camera-enabled"
14328
14407
  ]);
14408
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14329
14409
  /**
14330
14410
  * One coherent system-event condition. `kinds` is the required opt-in safety
14331
14411
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14334,6 +14414,18 @@ var NcSystemEventKindSchema = _enum([
14334
14414
  var NcSystemEventConditionSchema = object({
14335
14415
  kinds: array(NcSystemEventKindSchema).min(1),
14336
14416
  deviceIds: array(number().int()).min(1).optional(),
14417
+ /**
14418
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14419
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14420
+ * is what a liveness rule means when nobody said otherwise.
14421
+ *
14422
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14423
+ * one reason: the intake cannot know which devices this household cares
14424
+ * about, and a producer-side filter is one no operator can change. Fails
14425
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14426
+ * does not carry) matches no `deviceTypes` list.
14427
+ */
14428
+ deviceTypes: array(string().min(1)).min(1).optional(),
14337
14429
  nodeIds: array(string().min(1)).min(1).optional(),
14338
14430
  packageNames: array(string().min(1)).min(1).optional()
14339
14431
  });
@@ -14384,6 +14476,47 @@ var NcOccupancyConditionSchema = object({
14384
14476
  sustainSeconds: number().int().min(0).max(3600).default(15)
14385
14477
  });
14386
14478
  /**
14479
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14480
+ *
14481
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14482
+ * reference notifier uses, so an operator moving between them re-uses what
14483
+ * they already know): a rule matches when, over a sampling window of
14484
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14485
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14486
+ *
14487
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14488
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14489
+ * - `labels` — the classifier put at least one of these labels on it.
14490
+ *
14491
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14492
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14493
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14494
+ * is given** — a window in which every sample is trivially a hit would fire on
14495
+ * silence, so the engine refuses such a condition rather than notifying on
14496
+ * nothing (the schema cannot express "at least one of" without becoming a
14497
+ * ZodEffects the cap path would have to special-case).
14498
+ *
14499
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14500
+ * must be FULL before it can match — a window that has been open for two
14501
+ * seconds of its ten is 100% of nothing, and firing on it would make
14502
+ * `samplingSeconds` decorative.
14503
+ *
14504
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14505
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14506
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14507
+ * an operator who typed `dog` mean the same thing.
14508
+ */
14509
+ var NcAudioConditionSchema = object({
14510
+ /** Audio macro labels; absent = any sound (level-only rule). */
14511
+ labels: array(string().min(1)).min(1).optional(),
14512
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14513
+ dbThreshold: number().min(-96).max(0).optional(),
14514
+ /** Percentage of the window's samples that must be hits (1–100). */
14515
+ hitPercent: number().int().min(1).max(100).default(60),
14516
+ /** Length of the sampling window in seconds. */
14517
+ samplingSeconds: number().int().min(1).max(300).default(10)
14518
+ });
14519
+ /**
14387
14520
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14388
14521
  *
14389
14522
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14656,7 +14789,33 @@ var NcConditionsSchema = object({
14656
14789
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14657
14790
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14658
14791
  */
14659
- occupancy: NcOccupancyConditionSchema.optional()
14792
+ occupancy: NcOccupancyConditionSchema.optional(),
14793
+ /**
14794
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14795
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14796
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14797
+ * a window that is not full yet, neither filter given). See
14798
+ * {@link NcAudioCondition}.
14799
+ *
14800
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14801
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14802
+ * a detection, a track or a device event (the same fail-closed pairing
14803
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14804
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14805
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14806
+ * classified sample) stays exactly as it was for rules that already use it.
14807
+ *
14808
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14809
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14810
+ * (`camstack/src/data/notification-center.ts`, guarded by
14811
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14812
+ * condition fields it does not know when a rule is saved from the phone.
14813
+ * Publishing an editor for a condition the app cannot round-trip is how an
14814
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14815
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14816
+ * does an audio rule become authorable.
14817
+ */
14818
+ audio: NcAudioConditionSchema.optional()
14660
14819
  });
14661
14820
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14662
14821
  var NcRuleTargetSchema = object({
@@ -14770,6 +14929,73 @@ var NcThrottleSchema = object({
14770
14929
  */
14771
14930
  granularity: NcThrottleGranularitySchema.optional()
14772
14931
  });
14932
+ /**
14933
+ * How long the confirm gate may hold ONE notification, and how big the picture
14934
+ * it judges may be.
14935
+ *
14936
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14937
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14938
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14939
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14940
+ * tokens for pixels the model pools away.
14941
+ */
14942
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14943
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14944
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14945
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14946
+ var NcConfirmExpectSchema = object({
14947
+ op: _enum([
14948
+ ">=",
14949
+ ">",
14950
+ "<=",
14951
+ "<",
14952
+ "=="
14953
+ ]),
14954
+ count: number().int().min(0).max(1e3)
14955
+ });
14956
+ /**
14957
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14958
+ * to ship and says whether it agrees with the rule.
14959
+ *
14960
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14961
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14962
+ * on the operator's phone is not a verdict about this notification.
14963
+ *
14964
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14965
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14966
+ * the default and every fail-open is COUNTED, because a gate that always fails
14967
+ * open looks in the log exactly like a gate that works.
14968
+ *
14969
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14970
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14971
+ * production failures in one day), so the gate reads absent as the constant
14972
+ * above rather than trusting a parse it may never have seen.
14973
+ */
14974
+ var NcConfirmSchema = object({
14975
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14976
+ * same thing, and both mean "deliver exactly as before". */
14977
+ enabled: boolean().default(false),
14978
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14979
+ profileId: string().optional(),
14980
+ /**
14981
+ * The operator's question, in his own words. Absent = a question derived
14982
+ * from the rule (its class and its expectation).
14983
+ *
14984
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14985
+ * banners, signage and plates as instructions if you let them reach the
14986
+ * prompt — proven live — so the authoritative contract stays in the system
14987
+ * turn and only rule-authored words land here.
14988
+ */
14989
+ prompt: string().max(1e3).optional(),
14990
+ /** Fire only when the model's count satisfies this. Absent = the model's
14991
+ * own boolean verdict decides. */
14992
+ expect: NcConfirmExpectSchema.optional(),
14993
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14994
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14995
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14996
+ /** Longest edge the judged image is downscaled to before it is sent. */
14997
+ maxImagePx: number().int().min(64).max(2048).default(448)
14998
+ });
14773
14999
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14774
15000
  var NcRuleInputSchema = object({
14775
15001
  name: string().min(1).max(200),
@@ -14830,7 +15056,13 @@ var NcRuleInputSchema = object({
14830
15056
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14831
15057
  * shape as every other actuation.
14832
15058
  */
14833
- actions: NcRuleActionsSchema.optional()
15059
+ actions: NcRuleActionsSchema.optional(),
15060
+ /**
15061
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
15062
+ * a rule that predates the gate must keep delivering byte-for-byte as it
15063
+ * did, and absent is the only way to say that without a migration.
15064
+ */
15065
+ confirm: NcConfirmSchema.optional()
14834
15066
  });
14835
15067
  /**
14836
15068
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14841,7 +15073,37 @@ var NcRuleInputSchema = object({
14841
15073
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14842
15074
  * `updateRule` patch.
14843
15075
  */
14844
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
15076
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
15077
+ disabledTargetIds: array(string()).optional(),
15078
+ /**
15079
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
15080
+ *
15081
+ * It makes the key optional to SUPPLY; the parse still materialises the
15082
+ * default when the key is absent. And `NcRuleStore.update` merges with
15083
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
15084
+ * one — which made every partial edit destructive:
15085
+ *
15086
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
15087
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
15088
+ * setEnabled(ruleId, false) → conditions reset to `{}`
15089
+ *
15090
+ * A rule scoped to one camera and one zone silently became a rule that
15091
+ * matches EVERY event on EVERY camera, and lost its `media` policy
15092
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
15093
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
15094
+ * within a minute of a two-field patch.
15095
+ *
15096
+ * So every defaulted field is re-declared here WITHOUT its default. The
15097
+ * inner defaults still apply when the caller DOES send the key — `{}` for
15098
+ * conditions remains a real instruction ("clear them") — and only the
15099
+ * absent key is now genuinely absent.
15100
+ */
15101
+ enabled: boolean().optional(),
15102
+ conditions: NcConditionsSchema.optional(),
15103
+ media: NcMediaPolicySchema.optional(),
15104
+ throttle: NcThrottleSchema.optional(),
15105
+ priority: number().int().min(1).max(5).optional()
15106
+ });
14845
15107
  /** A persisted rule. */
14846
15108
  var NcRuleSchema = NcRuleInputSchema.extend({
14847
15109
  id: string(),
@@ -15142,6 +15404,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15142
15404
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15143
15405
  * copy would lie the first time a rule is disabled.
15144
15406
  */
15407
+ /**
15408
+ * Why a device a mode NAMES is nonetheless not armed by it.
15409
+ *
15410
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15411
+ * per-camera notification switch the Notification Center already owns,
15412
+ * `detection-off` is the device's own detection binding being inactive, and
15413
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15414
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15415
+ * with the switches the operator actually used.
15416
+ */
15417
+ var NcAlarmSkipReasonSchema = _enum([
15418
+ "muted",
15419
+ "detection-off",
15420
+ "offline"
15421
+ ]);
15422
+ var NcAlarmSkippedDeviceSchema = object({
15423
+ deviceId: number().int(),
15424
+ reason: NcAlarmSkipReasonSchema
15425
+ });
15145
15426
  var NcAlarmModeCoverageSchema = object({
15146
15427
  mode: AlarmArmModeSchema,
15147
15428
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15149,7 +15430,18 @@ var NcAlarmModeCoverageSchema = object({
15149
15430
  /** At least one covering rule has no device scope, so the mode covers all. */
15150
15431
  allDevices: boolean(),
15151
15432
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15152
- deviceIds: array(number().int())
15433
+ deviceIds: array(number().int()),
15434
+ /**
15435
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15436
+ * excludes it.
15437
+ *
15438
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15439
+ * twelve makes it false in exactly the way nobody notices until an incident.
15440
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15441
+ * still parses as "nothing known to be skipped" rather than failing the whole
15442
+ * alarm tab.
15443
+ */
15444
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15153
15445
  });
15154
15446
  var NcAlarmConfigSchema = object({
15155
15447
  /**
@@ -17981,9 +18273,16 @@ var CameraStatusSchema = object({
17981
18273
  audio: CameraAudioStatusSchema.nullable(),
17982
18274
  recording: CameraRecordingStatusSchema.nullable(),
17983
18275
  /**
17984
- * Per-camera function switches an OPERATOR has turned off
18276
+ * Per-camera functions an OPERATOR has turned off
17985
18277
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17986
18278
  *
18279
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18280
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18281
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18282
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18283
+ * The badge outlives the control panel: the panel was a convenience, this is
18284
+ * the difference between a camera being off and a camera being dead.
18285
+ *
17987
18286
  * This is the difference between DISABLED and BROKEN. A camera whose
17988
18287
  * `detection` block reports zero fps and whose `switchedOff` contains
17989
18288
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -18590,24 +18889,28 @@ var snapshotCapability = {
18590
18889
  *
18591
18890
  * `getSnapshotOverview` is cache-only by contract: it answers from whatever
18592
18891
  * the wrapper happens to hold and never captures. Under D93 the client
18593
- * versions its image URL on that answer, and an image REQUEST is what enrols
18594
- * a camera in the keep-warm loop. Both of those are satisfiable by the
18595
- * client's own image cache — `expo-image` is URL-keyed and never revalidates
18596
- * — so a URL painted in a previous session comes off disk with no network,
18597
- * no enrolment, and nothing warming. Measured on the live hub: reopening
18598
- * after two minutes idle painted 15 of 16 tiles at **168 s old** with zero
18599
- * HTTP requests, and the fleet only recovered because a later poll happened
18600
- * to observe a different identity.
18892
+ * versions its image URL on that answer, and an image REQUEST was the only
18893
+ * demand signal. Both of those are satisfiable by the client's own image
18894
+ * cache — `expo-image` is URL-keyed and never revalidates — so a URL painted
18895
+ * in a previous session comes off disk with no network, no demand, and no
18896
+ * capture. Measured on the live hub: reopening after two minutes idle
18897
+ * painted 15 of 16 tiles at **168 s old** with zero HTTP requests, and the
18898
+ * fleet only recovered because a later poll happened to observe a different
18899
+ * identity.
18601
18900
  *
18602
18901
  * ## The two properties that fix it
18603
18902
  *
18604
18903
  * **It is an RPC, so no client cache can answer it.** The demand signal
18605
- * always reaches the wrapper. This method therefore MAY create keep-warm
18606
- * subscriptions, where `getSnapshotOverview` must never (D93) — the
18607
- * distinction is not "one is newer" but that the overview poll is app-wide
18608
- * (a creating overview would warm every camera on the install) while this is
18609
- * called by a rendered surface naming the tiles it is actually painting, at
18610
- * the width it is painting them.
18904
+ * always reaches the wrapper. This method therefore CAPTURES, where
18905
+ * `getSnapshotOverview` must never (D93) — the distinction is not "one is
18906
+ * newer" but that the overview poll is app-wide (a capturing overview would
18907
+ * dial every camera on the install) while this is called by a rendered
18908
+ * surface naming the tiles it is actually painting, at the width it is
18909
+ * painting them.
18910
+ *
18911
+ * Since 2026-08-11 this is the ONLY thing that refreshes a snapshot: the
18912
+ * server-side keep-warm loop was removed (operator directive — on-demand,
18913
+ * always), so a camera nobody is looking at costs nothing at all.
18611
18914
  *
18612
18915
  * **It waits, briefly and boundedly, for the capture it triggered.** The
18613
18916
  * returned `capturedAt` is the frame the link will serve, not the frame the
@@ -25000,7 +25303,19 @@ var RecordingManifestSchema = object({
25000
25303
  * profiles/subtrees/locations on this node). */
25001
25304
  var RecordingDeviceUsageSchema = object({
25002
25305
  deviceId: number(),
25003
- usedBytes: number()
25306
+ usedBytes: number(),
25307
+ /**
25308
+ * Start of this camera's OLDEST indexed segment, across every profile and
25309
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25310
+ * only honest answer to "is retention actually holding?" per camera.
25311
+ *
25312
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25313
+ * predates this field omits it entirely, and a hub whose types carry the
25314
+ * field must keep validating that older provider's payload: the framework
25315
+ * (types) and the addon ship on different trains, and the addon is usually
25316
+ * the later of the two.
25317
+ */
25318
+ oldestMs: number().nullable().optional()
25004
25319
  });
25005
25320
  /** Recording storage usage + capacity for one storage location. */
25006
25321
  var RecordingLocationUsageSchema = object({
@@ -25028,6 +25343,57 @@ var RecordingStorageUsageSchema = object({
25028
25343
  locations: array(RecordingLocationUsageSchema)
25029
25344
  });
25030
25345
  /**
25346
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25347
+ *
25348
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25349
+ * is the operator asking for the EXISTING archive to be brought into line with
25350
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25351
+ * location, run FIFO behind the single-flight mover.
25352
+ *
25353
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25354
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25355
+ * (empty on the plan).
25356
+ */
25357
+ var RecordingRebalanceMoveSchema = object({
25358
+ deviceId: number(),
25359
+ profile: string(),
25360
+ fromLocationId: string(),
25361
+ toLocationId: string(),
25362
+ bytes: number(),
25363
+ files: number().int()
25364
+ });
25365
+ /** Why a pile that is out of place is staying there. Every refusal is
25366
+ * reported: a rebalance that silently drops a camera reads exactly like one
25367
+ * that had nothing to do. */
25368
+ var RecordingRebalanceSkipReasonSchema = _enum([
25369
+ "unassigned",
25370
+ "target-not-writable",
25371
+ "below-threshold",
25372
+ "no-headroom"
25373
+ ]);
25374
+ var RecordingRebalanceSkipSchema = object({
25375
+ deviceId: number(),
25376
+ profile: string(),
25377
+ fromLocationId: string(),
25378
+ /** The location the plan wants; null when the camera has no assignment. */
25379
+ toLocationId: string().nullable(),
25380
+ bytes: number(),
25381
+ reason: RecordingRebalanceSkipReasonSchema
25382
+ });
25383
+ var RecordingRebalancePlanSchema = object({
25384
+ moves: array(RecordingRebalanceMoveSchema),
25385
+ skipped: array(RecordingRebalanceSkipSchema),
25386
+ bytesToMove: number(),
25387
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25388
+ jobIds: array(string())
25389
+ });
25390
+ var RecordingRebalanceInputSchema = object({
25391
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25392
+ throttleMbps: number().min(1).max(1e3).optional(),
25393
+ /** Ignore piles smaller than this (default 1 GB). */
25394
+ minMoveGb: number().min(0).optional()
25395
+ });
25396
+ /**
25031
25397
  * Result of locating footage at a wall-clock instant for one device/profile.
25032
25398
  * `segment` carries the covering segment's window; `gap` reports the forward
25033
25399
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -25190,9 +25556,24 @@ method(object({
25190
25556
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25191
25557
  kind: "mutation",
25192
25558
  auth: "admin"
25559
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25560
+ kind: "mutation",
25561
+ auth: "admin"
25562
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25563
+ kind: "query",
25564
+ auth: "admin"
25565
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25566
+ kind: "mutation",
25567
+ auth: "admin"
25568
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25569
+ kind: "query",
25570
+ auth: "admin"
25571
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25572
+ kind: "mutation",
25573
+ auth: "admin"
25193
25574
  });
25194
25575
  /**
25195
- * `recordingExport` cap — render a footage time range into a single downloadable
25576
+ * `recording-export` cap — render a footage time range into a single downloadable
25196
25577
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
25197
25578
  * bounded lifetime with a durable history, auto-expiry, and optional
25198
25579
  * delete-after-download.
@@ -25207,10 +25588,53 @@ method(object({
25207
25588
  */
25208
25589
  /** Playback-speed multiplier for the render (1 = realtime). */
25209
25590
  var ExportSpeedSchema = number().min(.25).max(32);
25591
+ /**
25592
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25593
+ *
25594
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25595
+ * derives these bounds from things that happened at a TIME (a track's
25596
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25597
+ * every segment present for the range, with each recording GAP removed. The
25598
+ * two agree only on a window that recorded without one interruption, and only
25599
+ * the render side knows the segments, so the translation lives there
25600
+ * (`export-dense-map.ts`, addon-pipeline).
25601
+ *
25602
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25603
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25604
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25605
+ * the video was a uniform timelapse, and the log line reported the five ranges
25606
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25607
+ *
25608
+ * Relative and not absolute epoch, because an absolute epoch would make every
25609
+ * call site responsible for the same subtraction.
25610
+ */
25611
+ var ExportDenseRangeSchema = object({
25612
+ fromSec: number().nonnegative(),
25613
+ toSec: number().nonnegative()
25614
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25615
+ /**
25616
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25617
+ * listed ranges and at the base `everyMs` everywhere else.
25618
+ *
25619
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25620
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25621
+ */
25622
+ var ExportDenseSchema = object({
25623
+ everyMs: number().int().positive(),
25624
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25625
+ });
25210
25626
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
25211
25627
  var ExportTimelapseSchema = object({
25212
25628
  everyMs: number().int().positive(),
25213
- outputFps: number().int().min(1).max(60).optional()
25629
+ outputFps: number().int().min(1).max(60).optional(),
25630
+ /** Optional second, FASTER rate over the intervals that matter. */
25631
+ dense: ExportDenseSchema.optional()
25632
+ }).superRefine((v, ctx) => {
25633
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25634
+ code: ZodIssueCode.custom,
25635
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25636
+ path: ["dense", "everyMs"]
25637
+ });
25214
25638
  });
25215
25639
  /**
25216
25640
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -25268,6 +25692,19 @@ var ExportDownloadSchema = object({
25268
25692
  url: string(),
25269
25693
  endpoints: array(string())
25270
25694
  });
25695
+ /**
25696
+ * A finished export's bytes, inline.
25697
+ *
25698
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25699
+ * against, so nobody has to infer it from the base64 length.
25700
+ */
25701
+ var ExportBytesSchema = object({
25702
+ base64: string(),
25703
+ contentType: string(),
25704
+ /** Suggested filename, extension included. */
25705
+ name: string(),
25706
+ bytes: number().int().nonnegative()
25707
+ });
25271
25708
  method(object({
25272
25709
  deviceId: number(),
25273
25710
  profile: string(),
@@ -25292,6 +25729,9 @@ method(object({
25292
25729
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
25293
25730
  kind: "query",
25294
25731
  auth: "protected"
25732
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25733
+ kind: "query",
25734
+ auth: "protected"
25295
25735
  });
25296
25736
  /**
25297
25737
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -32326,6 +32766,12 @@ Object.freeze({
32326
32766
  addonId: null,
32327
32767
  access: "create"
32328
32768
  },
32769
+ "recording.cancelRelocateJob": {
32770
+ capName: "recording",
32771
+ capScope: "system",
32772
+ addonId: null,
32773
+ access: "create"
32774
+ },
32329
32775
  "recording.cancelStorageMigrationMove": {
32330
32776
  capName: "recording",
32331
32777
  capScope: "system",
@@ -32380,6 +32826,12 @@ Object.freeze({
32380
32826
  addonId: null,
32381
32827
  access: "view"
32382
32828
  },
32829
+ "recording.listRelocateJobs": {
32830
+ capName: "recording",
32831
+ capScope: "system",
32832
+ addonId: null,
32833
+ access: "view"
32834
+ },
32383
32835
  "recording.locateSegment": {
32384
32836
  capName: "recording",
32385
32837
  capScope: "system",
@@ -32392,6 +32844,12 @@ Object.freeze({
32392
32844
  addonId: null,
32393
32845
  access: "create"
32394
32846
  },
32847
+ "recording.planStorageRebalance": {
32848
+ capName: "recording",
32849
+ capScope: "system",
32850
+ addonId: null,
32851
+ access: "view"
32852
+ },
32395
32853
  "recording.pruneFootage": {
32396
32854
  capName: "recording",
32397
32855
  capScope: "system",
@@ -32416,6 +32874,12 @@ Object.freeze({
32416
32874
  addonId: null,
32417
32875
  access: "create"
32418
32876
  },
32877
+ "recording.relocateFootage": {
32878
+ capName: "recording",
32879
+ capScope: "system",
32880
+ addonId: null,
32881
+ access: "create"
32882
+ },
32419
32883
  "recording.renderClip": {
32420
32884
  capName: "recording",
32421
32885
  capScope: "system",
@@ -32452,38 +32916,50 @@ Object.freeze({
32452
32916
  addonId: null,
32453
32917
  access: "create"
32454
32918
  },
32919
+ "recording.startStorageRebalance": {
32920
+ capName: "recording",
32921
+ capScope: "system",
32922
+ addonId: null,
32923
+ access: "create"
32924
+ },
32455
32925
  "recordingExport.cancelExport": {
32456
- capName: "recordingExport",
32926
+ capName: "recording-export",
32457
32927
  capScope: "system",
32458
32928
  addonId: null,
32459
32929
  access: "create"
32460
32930
  },
32461
32931
  "recordingExport.createExport": {
32462
- capName: "recordingExport",
32932
+ capName: "recording-export",
32463
32933
  capScope: "system",
32464
32934
  addonId: null,
32465
32935
  access: "create"
32466
32936
  },
32467
32937
  "recordingExport.deleteExport": {
32468
- capName: "recordingExport",
32938
+ capName: "recording-export",
32469
32939
  capScope: "system",
32470
32940
  addonId: null,
32471
32941
  access: "delete"
32472
32942
  },
32473
32943
  "recordingExport.getDownloadUrl": {
32474
- capName: "recordingExport",
32944
+ capName: "recording-export",
32475
32945
  capScope: "system",
32476
32946
  addonId: null,
32477
32947
  access: "view"
32478
32948
  },
32479
32949
  "recordingExport.getExport": {
32480
- capName: "recordingExport",
32950
+ capName: "recording-export",
32481
32951
  capScope: "system",
32482
32952
  addonId: null,
32483
32953
  access: "view"
32484
32954
  },
32485
32955
  "recordingExport.listExports": {
32486
- capName: "recordingExport",
32956
+ capName: "recording-export",
32957
+ capScope: "system",
32958
+ addonId: null,
32959
+ access: "view"
32960
+ },
32961
+ "recordingExport.readExportBytes": {
32962
+ capName: "recording-export",
32487
32963
  capScope: "system",
32488
32964
  addonId: null,
32489
32965
  access: "view"
@@ -33860,6 +34336,104 @@ var FramerateField = number().int().min(1).max(60);
33860
34336
  var TargetsField = array(NcRuleTargetSchema).min(1);
33861
34337
  var PriorityField = number().int().min(1).max(5);
33862
34338
  /**
34339
+ * Explicit override of the DENSE sampling cadence, seconds.
34340
+ *
34341
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
34342
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
34343
+ * made that same base 3 s and rendered a person pass as two frames.)
34344
+ *
34345
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
34346
+ * `denseCadenceSec` and played at `framerate` occupies
34347
+ *
34348
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
34349
+ *
34350
+ * 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.
34351
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
34352
+ * and therefore the length of a quiet night, does not move.
34353
+ *
34354
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
34355
+ * the recording has them returns the same frames, requested twice. Must be
34356
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
34357
+ * a uniform video the operator believes is two-rate — and upsert refuses it
34358
+ * rather than letting the export cap reject the render hours after the window.
34359
+ */
34360
+ var DenseCadenceSecField = number().min(.1).max(3600);
34361
+ /**
34362
+ * Minimum seconds of OUTPUT video each detection range must occupy.
34363
+ *
34364
+ * The operator-facing form of the arithmetic above: instead of solving for a
34365
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
34366
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
34367
+ * that range every ~583 ms.
34368
+ *
34369
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
34370
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
34371
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
34372
+ * ranges are sampled denser than they need. Per-range cadences require a cap
34373
+ * schema change and are the tracked follow-up.
34374
+ *
34375
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
34376
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
34377
+ * by real footage, never met by duplicating frames into motion that never
34378
+ * happened.
34379
+ */
34380
+ var MinDwellSecField = number().min(0).max(60);
34381
+ /**
34382
+ * Caption burned into the notification's preview frame.
34383
+ *
34384
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
34385
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
34386
+ * templating dialect for one field would be a second thing to explain.
34387
+ *
34388
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
34389
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
34390
+ * the reason this is not `.min(1)`.
34391
+ */
34392
+ var PreviewTextField = string().max(200);
34393
+ /**
34394
+ * Whether the notification's preview is a STILL or a short animation.
34395
+ *
34396
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
34397
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
34398
+ * night reads better as three seconds of motion than as one frame of it. Both
34399
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
34400
+ * simply applies it to a dozen frames sampled across the render and assembles
34401
+ * them.
34402
+ *
34403
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
34404
+ * seeks and a palette pass, and no rule that never asked for one should start
34405
+ * paying that on the deploy that shipped it.
34406
+ *
34407
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
34408
+ */
34409
+ var PreviewModeField = _enum(["image", "gif"]);
34410
+ /**
34411
+ * Which detection classes the notification reports counts for.
34412
+ *
34413
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
34414
+ * plan — no second query — aggregated per class. Absent or empty means "every
34415
+ * class the window actually contained", which is what an operator who never
34416
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
34417
+ * counts cars all night).
34418
+ *
34419
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
34420
+ * …). An unknown name simply never matches and reports nothing — it is not an
34421
+ * error, because a rule may legitimately name a class this camera's model does
34422
+ * not emit.
34423
+ *
34424
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
34425
+ * - `{{detections}}` — total over the reported classes
34426
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
34427
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
34428
+ * one per class, `count_` + the class name
34429
+ *
34430
+ * With NO custom body template the summary is appended to the derived body, and
34431
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
34432
+ * reads. With a custom template the operator owns every word — nothing is
34433
+ * appended, so `{{detectionSummary}}` is how he asks for it.
34434
+ */
34435
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
34436
+ /**
33863
34437
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33864
34438
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33865
34439
  * here (see the ownership note above).
@@ -33879,9 +34453,30 @@ var TimelapseRuleInputSchema = object({
33879
34453
  cadenceSec: CadenceSecField.default(15),
33880
34454
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33881
34455
  framerate: FramerateField.default(10),
34456
+ /**
34457
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
34458
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
34459
+ * field gets.
34460
+ */
34461
+ denseCadenceSec: DenseCadenceSecField.optional(),
34462
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
34463
+ minDwellSec: MinDwellSecField.optional(),
33882
34464
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33883
34465
  targets: TargetsField,
33884
34466
  template: TimelapseTemplateSchema.optional(),
34467
+ /**
34468
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
34469
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
34470
+ *
34471
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
34472
+ * the notification's title/body, and clearing it (`template: null`) must not
34473
+ * silently clear the caption too.
34474
+ */
34475
+ previewText: PreviewTextField.optional(),
34476
+ /** Still or animation — see {@link PreviewModeField}. */
34477
+ previewMode: PreviewModeField.default("image"),
34478
+ /** Classes the notification counts — see {@link ReportClassesField}. */
34479
+ reportClasses: ReportClassesField.optional(),
33885
34480
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33886
34481
  priority: PriorityField.default(3)
33887
34482
  });
@@ -33892,8 +34487,13 @@ object({
33892
34487
  schedule: NcScheduleSchema.optional(),
33893
34488
  cadenceSec: CadenceSecField.optional(),
33894
34489
  framerate: FramerateField.optional(),
34490
+ denseCadenceSec: DenseCadenceSecField.optional(),
34491
+ minDwellSec: MinDwellSecField.optional(),
33895
34492
  targets: TargetsField.optional(),
33896
34493
  template: TimelapseTemplateSchema.nullable().optional(),
34494
+ previewText: PreviewTextField.optional(),
34495
+ previewMode: PreviewModeField.optional(),
34496
+ reportClasses: ReportClassesField.optional(),
33897
34497
  priority: PriorityField.optional()
33898
34498
  });
33899
34499
  TimelapseRuleInputSchema.extend({
@@ -33905,10 +34505,28 @@ TimelapseRuleInputSchema.extend({
33905
34505
  */
33906
34506
  ownerUserId: string().optional(),
33907
34507
  /**
33908
- * Epoch-ms of the last successful generation the 1-hour re-generation
33909
- * guard's durable state (predecessor parity). Absent = never generated.
34508
+ * Epoch-ms of the NEWEST successful generation across every camera of this
34509
+ * rule. What a UI shows, and the compatibility floor for
34510
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33910
34511
  */
33911
34512
  lastGeneratedAt: number().optional(),
34513
+ /**
34514
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
34515
+ * re-generation guard's real durable state.
34516
+ *
34517
+ * One rule covers several cameras and each renders its own video, so a rule
34518
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
34519
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
34520
+ * already done — and B's night is gone for good, because the window will not
34521
+ * come back.
34522
+ *
34523
+ * ADDITIVE, so the migration is free: a row written before this field simply
34524
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
34525
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
34526
+ * "never generated" would re-render and re-notify every camera of every rule
34527
+ * once, on the deploy that shipped the map.
34528
+ */
34529
+ generatedByDevice: record(string(), number()).optional(),
33912
34530
  /** userId of the caller who created the rule (server-stamped). */
33913
34531
  createdBy: string(),
33914
34532
  createdAt: number(),
@@ -33959,25 +34577,32 @@ object({
33959
34577
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33960
34578
  object({
33961
34579
  /**
33962
- * How long a retained native frame is served before it counts as a miss.
34580
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
34581
+ * detection result.
33963
34582
  *
33964
- * Must cover the FULL late-crop horizon: detection inference + the
33965
- * cross-process inference-result hop to hub post-analysis + tracking + the
33966
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33967
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33968
- * RAM per busy camera grows linearly with no measured hit-rate gain.
34583
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
34584
+ * a time window was never related to the event the pixels were waiting for.
34585
+ * A held frame now lives from delivery until the runner has its `FrameResult`
34586
+ * at which moment the runner cuts the subject tiles it actually wanted and
34587
+ * releases the frame. The bound exists only so a runner that stops answering
34588
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
34589
+ *
34590
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
34591
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
34592
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
34593
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
34594
+ * `holdOverflow` on the metrics line is what says you need it.
33969
34595
  */
33970
- ttlMs: number().int().min(250).max(1e4),
34596
+ holdFrames: number().int().min(1).max(64),
33971
34597
  /**
33972
34598
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33973
34599
  *
33974
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33975
- * which one is actually binding before reasoning from that. At the shipped
33976
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33977
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33978
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33979
- * change that admits fewer frames buys retention WINDOW at constant RAM
33980
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
34600
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
34601
+ * is what decides how much is held, and the ceiling is the number above which
34602
+ * something is wrong. Before that it was the effective cap at 1024 MB with
34603
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
34604
+ * with the TTL expiring nothing, which is exactly the confusion the hold
34605
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33981
34606
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33982
34607
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33983
34608
  * to replace).
@@ -34003,22 +34628,45 @@ object({
34003
34628
  * there is the signal that some caller names frames outside the inference set
34004
34629
  * and that this must go back to `all`.
34005
34630
  */
34006
- admission: NativeLeaseAdmissionSchema
34631
+ admission: NativeLeaseAdmissionSchema,
34632
+ /**
34633
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
34634
+ * compressed native crops the worker cuts at the moment a frame's detection
34635
+ * result arrives, and keeps long after the frame itself is freed.
34636
+ *
34637
+ * This is the knob that replaced the old retention window, and it buys about
34638
+ * three orders of magnitude more of it: a tile is one subject at native
34639
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
34640
+ * the frame it was cut from. A frame on which nothing was detected costs
34641
+ * nothing at all, which is the real change — the old lease paid per FRAME and
34642
+ * was interrogated per SUBJECT.
34643
+ *
34644
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
34645
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
34646
+ * reproduce that.
34647
+ */
34648
+ tileBudgetMb: number().int().min(0).max(1024)
34007
34649
  });
34008
34650
  /**
34009
- * The values in force when the operator has set nothing — byte-for-byte the
34010
- * constants the decode worker shipped with as env-var defaults, so making these
34011
- * settings changed no behaviour on the day it landed.
34651
+ * The values in force when the operator has set nothing.
34652
+ *
34653
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
34654
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
34655
+ * in the same change that redefines it would make a regression and a retune
34656
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
34657
+ * live traffic.
34012
34658
  */
34013
34659
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
34014
- ttlMs: 1200,
34660
+ holdFrames: 8,
34015
34661
  budgetMb: 1024,
34016
34662
  activityMs: 15e3,
34663
+ tileBudgetMb: 64,
34017
34664
  admission: "inferred"
34018
34665
  };
34019
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
34666
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
34020
34667
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
34021
34668
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34669
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
34022
34670
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
34023
34671
  //#endregion
34024
34672
  //#region src/accessories/base.ts