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