@camstack/addon-osd-manager 0.1.5 → 0.1.7

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.
package/dist/index.mjs CHANGED
@@ -7276,8 +7276,31 @@ var AdoptionJobSchema = object({
7276
7276
  error: string().nullable()
7277
7277
  });
7278
7278
  /**
7279
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7280
- * pipeline functions an operator thinks in terms of.
7279
+ * Per-camera FUNCTION SWITCHES.
7280
+ *
7281
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7282
+ *
7283
+ * This file shipped as "the one coherent on/off surface over the pipeline
7284
+ * functions an operator thinks in terms of". The operator's verdict on
7285
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7286
+ * every function already had a settings page of its own, and a second place to
7287
+ * turn it off is a second place to look. Each switch is going back to its own
7288
+ * component's original options — detection to the detection-pipeline wrapper
7289
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7290
+ * (which was always first-class; the switch was a veneer over
7291
+ * `recording.setDeviceConfig`), notifications to a notification-center
7292
+ * per-device setting, the two camera planes to their own components.
7293
+ *
7294
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7295
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7296
+ * straight from the authorities with no group in the middle. That rule was
7297
+ * never about a control panel.
7298
+ *
7299
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7300
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7301
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7302
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7303
+ * stop; nothing new may be built on it.
7281
7304
  *
7282
7305
  * ## This file adds no state
7283
7306
  *
@@ -7628,7 +7651,15 @@ var RecordingConfigSchema = object({
7628
7651
  * Each completed/failed run also lands one durable ops-log row on its owning
7629
7652
  * addon surface.
7630
7653
  */
7654
+ /**
7655
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7656
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7657
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7658
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7659
+ * runs at all.
7660
+ */
7631
7661
  var RelocateJobStateSchema = _enum([
7662
+ "queued",
7632
7663
  "running",
7633
7664
  "done",
7634
7665
  "failed",
@@ -7663,6 +7694,15 @@ var RelocateFootageInputSchema = object({
7663
7694
  /** Limits relocation to the logical profile class. Omit only for the
7664
7695
  * pre-orchestration compatibility path. */
7665
7696
  footageClass: RelocateFootageClassSchema.optional(),
7697
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7698
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7699
+ * unit is a (camera, profile) pile, not a disk. */
7700
+ deviceId: number().int().optional(),
7701
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7702
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7703
+ * placement plan assigns those two independently, so a rebalance that could
7704
+ * only say "recordings" would move footage the plan never asked to move. */
7705
+ profiles: array(string()).optional(),
7666
7706
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7667
7707
  * never allowed to starve live writers. */
7668
7708
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7798,6 +7838,21 @@ var StorageLocationSchema = object({
7798
7838
  nodeId: string().optional(),
7799
7839
  isDefault: boolean().default(false),
7800
7840
  isSystem: boolean().default(false),
7841
+ /**
7842
+ * Operator opt-in: whether consumers that BALANCE across several locations
7843
+ * of a type may write here. Recordings reads it today; event media and
7844
+ * backups are the next consumers, which is why the flag lives on the
7845
+ * location rather than in any one addon's store — nothing has to be
7846
+ * extended to add the next consumer.
7847
+ *
7848
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7849
+ * flag existed reads back with no flag and keeps working exactly as before;
7850
+ * that is the whole compat story, and it is why no migration ships with it.
7851
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7852
+ * disk must not silently start writing to it); the default of a type is
7853
+ * always stamped `true`.
7854
+ */
7855
+ enabled: boolean().optional(),
7801
7856
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7802
7857
  * for node-local locations it can reach) — never persisted, absent when the
7803
7858
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -13597,7 +13652,8 @@ var embeddingEncoderCapability = {
13597
13652
  };
13598
13653
  /**
13599
13654
  * filesystem-browse — per-node capability for browsing the node's local
13600
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
13655
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13656
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
13601
13657
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
13602
13658
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
13603
13659
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -13618,9 +13674,9 @@ var filesystemBrowseCapability = {
13618
13674
  mode: "singleton",
13619
13675
  internal: true,
13620
13676
  methods: {
13621
- /** The allowed roots browsing is sandboxed to on this node. */
13677
+ /** The roots `createDir` is sandboxed to on this node. Browsing is not confined to them. */
13622
13678
  listAllowedRoots: method(_void(), array(string()).readonly(), { auth: "admin" }),
13623
- /** Immediate subdirectories of `path` (must be within an allowed root) + free/total bytes. */
13679
+ /** Immediate subdirectories of any absolute `path` + free/total bytes. Read-only. */
13624
13680
  browse: method(object({ path: string() }), BrowseResultSchema, { auth: "admin" }),
13625
13681
  /** Create a subdirectory (within an allowed root). Returns its absolute path. */
13626
13682
  createDir: method(object({ path: string() }), object({ path: string() }), {
@@ -15651,6 +15707,13 @@ var MaskGridDimsSchema = object({
15651
15707
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
15652
15708
  * this one field keeps the schema additive — a rule still declares exactly
15653
15709
  * one trigger.
15710
+ *
15711
+ * AUDIO rules add no member here, for the reason occupancy added none: the
15712
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
15713
+ * mirror.ts` fails the build on a member the app cannot render) and every
15714
+ * member costs a release train. A sustained-sound rule is therefore an
15715
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
15716
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
15654
15717
  */
15655
15718
  var NcDeliverySchema = _enum([
15656
15719
  "immediate",
@@ -15665,15 +15728,32 @@ var NcDeliverySchema = _enum([
15665
15728
  * depend on a provider's raw event name or payload shape.
15666
15729
  */
15667
15730
  var NcSystemEventKindSchema = _enum([
15668
- "camera-online",
15669
- "camera-offline",
15731
+ "device-online",
15732
+ "device-offline",
15733
+ "device-disabled",
15734
+ "device-enabled",
15670
15735
  "stream-online",
15671
15736
  "stream-offline",
15672
15737
  "node-online",
15673
15738
  "node-offline",
15674
15739
  "addon-update-available",
15675
- "server-update-available"
15740
+ "server-update-available",
15741
+ "alarm-triggered",
15742
+ "alarm-armed",
15743
+ "alarm-disarmed",
15744
+ "camera-online",
15745
+ "camera-offline",
15746
+ "camera-disabled",
15747
+ "camera-enabled"
15676
15748
  ]);
15749
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
15750
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
15751
+ "camera-online",
15752
+ "camera-offline",
15753
+ "camera-disabled",
15754
+ "camera-enabled"
15755
+ ]);
15756
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
15677
15757
  /**
15678
15758
  * One coherent system-event condition. `kinds` is the required opt-in safety
15679
15759
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -15682,6 +15762,18 @@ var NcSystemEventKindSchema = _enum([
15682
15762
  var NcSystemEventConditionSchema = object({
15683
15763
  kinds: array(NcSystemEventKindSchema).min(1),
15684
15764
  deviceIds: array(number().int()).min(1).optional(),
15765
+ /**
15766
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
15767
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
15768
+ * is what a liveness rule means when nobody said otherwise.
15769
+ *
15770
+ * This is where "only my cameras" is expressed, and it lives on the rule for
15771
+ * one reason: the intake cannot know which devices this household cares
15772
+ * about, and a producer-side filter is one no operator can change. Fails
15773
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
15774
+ * does not carry) matches no `deviceTypes` list.
15775
+ */
15776
+ deviceTypes: array(string().min(1)).min(1).optional(),
15685
15777
  nodeIds: array(string().min(1)).min(1).optional(),
15686
15778
  packageNames: array(string().min(1)).min(1).optional()
15687
15779
  });
@@ -15732,6 +15824,47 @@ var NcOccupancyConditionSchema = object({
15732
15824
  sustainSeconds: number().int().min(0).max(3600).default(15)
15733
15825
  });
15734
15826
  /**
15827
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
15828
+ *
15829
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
15830
+ * reference notifier uses, so an operator moving between them re-uses what
15831
+ * they already know): a rule matches when, over a sampling window of
15832
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
15833
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
15834
+ *
15835
+ * - `dbThreshold` — its level is at or above this many dBFS (see
15836
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
15837
+ * - `labels` — the classifier put at least one of these labels on it.
15838
+ *
15839
+ * Both are OPTIONAL and independent, which is the point of the shape: a
15840
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
15841
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
15842
+ * is given** — a window in which every sample is trivially a hit would fire on
15843
+ * silence, so the engine refuses such a condition rather than notifying on
15844
+ * nothing (the schema cannot express "at least one of" without becoming a
15845
+ * ZodEffects the cap path would have to special-case).
15846
+ *
15847
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
15848
+ * must be FULL before it can match — a window that has been open for two
15849
+ * seconds of its ten is 100% of nothing, and firing on it would make
15850
+ * `samplingSeconds` decorative.
15851
+ *
15852
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
15853
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
15854
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
15855
+ * an operator who typed `dog` mean the same thing.
15856
+ */
15857
+ var NcAudioConditionSchema = object({
15858
+ /** Audio macro labels; absent = any sound (level-only rule). */
15859
+ labels: array(string().min(1)).min(1).optional(),
15860
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
15861
+ dbThreshold: number().min(-96).max(0).optional(),
15862
+ /** Percentage of the window's samples that must be hits (1–100). */
15863
+ hitPercent: number().int().min(1).max(100).default(60),
15864
+ /** Length of the sampling window in seconds. */
15865
+ samplingSeconds: number().int().min(1).max(300).default(10)
15866
+ });
15867
+ /**
15735
15868
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
15736
15869
  *
15737
15870
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -16004,7 +16137,33 @@ var NcConditionsSchema = object({
16004
16137
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
16005
16138
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
16006
16139
  */
16007
- occupancy: NcOccupancyConditionSchema.optional()
16140
+ occupancy: NcOccupancyConditionSchema.optional(),
16141
+ /**
16142
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
16143
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
16144
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
16145
+ * a window that is not full yet, neither filter given). See
16146
+ * {@link NcAudioCondition}.
16147
+ *
16148
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
16149
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
16150
+ * a detection, a track or a device event (the same fail-closed pairing
16151
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
16152
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
16153
+ * (an `immediate` rule naming an `audio-*` class, one notification per
16154
+ * classified sample) stays exactly as it was for rules that already use it.
16155
+ *
16156
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
16157
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
16158
+ * (`camstack/src/data/notification-center.ts`, guarded by
16159
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
16160
+ * condition fields it does not know when a rule is saved from the phone.
16161
+ * Publishing an editor for a condition the app cannot round-trip is how an
16162
+ * operator loses a rule's conditions by opening it — so the descriptor, the
16163
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
16164
+ * does an audio rule become authorable.
16165
+ */
16166
+ audio: NcAudioConditionSchema.optional()
16008
16167
  });
16009
16168
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
16010
16169
  var NcRuleTargetSchema = object({
@@ -16118,6 +16277,73 @@ var NcThrottleSchema = object({
16118
16277
  */
16119
16278
  granularity: NcThrottleGranularitySchema.optional()
16120
16279
  });
16280
+ /**
16281
+ * How long the confirm gate may hold ONE notification, and how big the picture
16282
+ * it judges may be.
16283
+ *
16284
+ * The clamp is the product decision, not a coincidence of the model: p50 was
16285
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
16286
+ * arrives after the visitor has gone is not a notification. 448 px was enough
16287
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
16288
+ * tokens for pixels the model pools away.
16289
+ */
16290
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
16291
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
16292
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
16293
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
16294
+ var NcConfirmExpectSchema = object({
16295
+ op: _enum([
16296
+ ">=",
16297
+ ">",
16298
+ "<=",
16299
+ "<",
16300
+ "=="
16301
+ ]),
16302
+ count: number().int().min(0).max(1e3)
16303
+ });
16304
+ /**
16305
+ * AI CONFIRM — a vision model looks at the picture this notification is about
16306
+ * to ship and says whether it agrees with the rule.
16307
+ *
16308
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
16309
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
16310
+ * on the operator's phone is not a verdict about this notification.
16311
+ *
16312
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
16313
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
16314
+ * the default and every fail-open is COUNTED, because a gate that always fails
16315
+ * open looks in the log exactly like a gate that works.
16316
+ *
16317
+ * Every field is `.optional()` rather than relied on as a Zod default at the
16318
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
16319
+ * production failures in one day), so the gate reads absent as the constant
16320
+ * above rather than trusting a parse it may never have seen.
16321
+ */
16322
+ var NcConfirmSchema = object({
16323
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
16324
+ * same thing, and both mean "deliver exactly as before". */
16325
+ enabled: boolean().default(false),
16326
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
16327
+ profileId: string().optional(),
16328
+ /**
16329
+ * The operator's question, in his own words. Absent = a question derived
16330
+ * from the rule (its class and its expectation).
16331
+ *
16332
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
16333
+ * banners, signage and plates as instructions if you let them reach the
16334
+ * prompt — proven live — so the authoritative contract stays in the system
16335
+ * turn and only rule-authored words land here.
16336
+ */
16337
+ prompt: string().max(1e3).optional(),
16338
+ /** Fire only when the model's count satisfies this. Absent = the model's
16339
+ * own boolean verdict decides. */
16340
+ expect: NcConfirmExpectSchema.optional(),
16341
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
16342
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
16343
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
16344
+ /** Longest edge the judged image is downscaled to before it is sent. */
16345
+ maxImagePx: number().int().min(64).max(2048).default(448)
16346
+ });
16121
16347
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
16122
16348
  var NcRuleInputSchema = object({
16123
16349
  name: string().min(1).max(200),
@@ -16178,7 +16404,13 @@ var NcRuleInputSchema = object({
16178
16404
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
16179
16405
  * shape as every other actuation.
16180
16406
  */
16181
- actions: NcRuleActionsSchema.optional()
16407
+ actions: NcRuleActionsSchema.optional(),
16408
+ /**
16409
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
16410
+ * a rule that predates the gate must keep delivering byte-for-byte as it
16411
+ * did, and absent is the only way to say that without a migration.
16412
+ */
16413
+ confirm: NcConfirmSchema.optional()
16182
16414
  });
16183
16415
  /**
16184
16416
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -16189,7 +16421,37 @@ var NcRuleInputSchema = object({
16189
16421
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
16190
16422
  * `updateRule` patch.
16191
16423
  */
16192
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
16424
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
16425
+ disabledTargetIds: array(string()).optional(),
16426
+ /**
16427
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
16428
+ *
16429
+ * It makes the key optional to SUPPLY; the parse still materialises the
16430
+ * default when the key is absent. And `NcRuleStore.update` merges with
16431
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
16432
+ * one — which made every partial edit destructive:
16433
+ *
16434
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
16435
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
16436
+ * setEnabled(ruleId, false) → conditions reset to `{}`
16437
+ *
16438
+ * A rule scoped to one camera and one zone silently became a rule that
16439
+ * matches EVERY event on EVERY camera, and lost its `media` policy
16440
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
16441
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
16442
+ * within a minute of a two-field patch.
16443
+ *
16444
+ * So every defaulted field is re-declared here WITHOUT its default. The
16445
+ * inner defaults still apply when the caller DOES send the key — `{}` for
16446
+ * conditions remains a real instruction ("clear them") — and only the
16447
+ * absent key is now genuinely absent.
16448
+ */
16449
+ enabled: boolean().optional(),
16450
+ conditions: NcConditionsSchema.optional(),
16451
+ media: NcMediaPolicySchema.optional(),
16452
+ throttle: NcThrottleSchema.optional(),
16453
+ priority: number().int().min(1).max(5).optional()
16454
+ });
16193
16455
  /** A persisted rule. */
16194
16456
  var NcRuleSchema = NcRuleInputSchema.extend({
16195
16457
  id: string(),
@@ -16302,12 +16564,20 @@ var NC_CONDITION_CATALOG = [
16302
16564
  valueType: "systemEvent",
16303
16565
  options: [
16304
16566
  {
16305
- value: "camera-online",
16306
- label: "Camera online"
16567
+ value: "device-online",
16568
+ label: "Device online"
16569
+ },
16570
+ {
16571
+ value: "device-offline",
16572
+ label: "Device offline"
16573
+ },
16574
+ {
16575
+ value: "device-disabled",
16576
+ label: "Device switched off"
16307
16577
  },
16308
16578
  {
16309
- value: "camera-offline",
16310
- label: "Camera offline"
16579
+ value: "device-enabled",
16580
+ label: "Device switched on"
16311
16581
  },
16312
16582
  {
16313
16583
  value: "stream-online",
@@ -16332,12 +16602,24 @@ var NC_CONDITION_CATALOG = [
16332
16602
  {
16333
16603
  value: "server-update-available",
16334
16604
  label: "Server update available"
16605
+ },
16606
+ {
16607
+ value: "alarm-triggered",
16608
+ label: "Alarm triggered"
16609
+ },
16610
+ {
16611
+ value: "alarm-armed",
16612
+ label: "Alarm armed"
16613
+ },
16614
+ {
16615
+ value: "alarm-disarmed",
16616
+ label: "Alarm disarmed"
16335
16617
  }
16336
16618
  ],
16337
16619
  operator: "in",
16338
16620
  appliesTo: ["system-event"],
16339
16621
  phase: "P1",
16340
- description: "Infrastructure and update events. Optionally narrow camera/stream events by device, node events by node id, and addon updates by package name."
16622
+ description: "Infrastructure and update events. Device liveness covers EVERY device type — narrow it by device type (cameras only, say) and/or by device, node events by node id, and addon updates by package name."
16341
16623
  },
16342
16624
  {
16343
16625
  id: "devices",
@@ -16860,6 +17142,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
16860
17142
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
16861
17143
  * copy would lie the first time a rule is disabled.
16862
17144
  */
17145
+ /**
17146
+ * Why a device a mode NAMES is nonetheless not armed by it.
17147
+ *
17148
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
17149
+ * per-camera notification switch the Notification Center already owns,
17150
+ * `detection-off` is the device's own detection binding being inactive, and
17151
+ * `offline` is the device manager's liveness. A fourth reason would mean a
17152
+ * fourth authority, and inventing one here is how a panel starts disagreeing
17153
+ * with the switches the operator actually used.
17154
+ */
17155
+ var NcAlarmSkipReasonSchema = _enum([
17156
+ "muted",
17157
+ "detection-off",
17158
+ "offline"
17159
+ ]);
17160
+ var NcAlarmSkippedDeviceSchema = object({
17161
+ deviceId: number().int(),
17162
+ reason: NcAlarmSkipReasonSchema
17163
+ });
16863
17164
  var NcAlarmModeCoverageSchema = object({
16864
17165
  mode: AlarmArmModeSchema,
16865
17166
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -16867,7 +17168,18 @@ var NcAlarmModeCoverageSchema = object({
16867
17168
  /** At least one covering rule has no device scope, so the mode covers all. */
16868
17169
  allDevices: boolean(),
16869
17170
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
16870
- deviceIds: array(number().int())
17171
+ deviceIds: array(number().int()),
17172
+ /**
17173
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
17174
+ * excludes it.
17175
+ *
17176
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
17177
+ * twelve makes it false in exactly the way nobody notices until an incident.
17178
+ * Defaulted to `[]` so a coverage answer computed before this field existed
17179
+ * still parses as "nothing known to be skipped" rather than failing the whole
17180
+ * alarm tab.
17181
+ */
17182
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
16871
17183
  });
16872
17184
  var NcAlarmConfigSchema = object({
16873
17185
  /**
@@ -20494,9 +20806,16 @@ var CameraStatusSchema = object({
20494
20806
  audio: CameraAudioStatusSchema.nullable(),
20495
20807
  recording: CameraRecordingStatusSchema.nullable(),
20496
20808
  /**
20497
- * Per-camera function switches an OPERATOR has turned off
20809
+ * Per-camera functions an OPERATOR has turned off
20498
20810
  * ([D61](../../../../docs/decisions/adr-0067.md)).
20499
20811
  *
20812
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
20813
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
20814
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
20815
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
20816
+ * The badge outlives the control panel: the panel was a convenience, this is
20817
+ * the difference between a camera being off and a camera being dead.
20818
+ *
20500
20819
  * This is the difference between DISABLED and BROKEN. A camera whose
20501
20820
  * `detection` block reports zero fps and whose `switchedOff` contains
20502
20821
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -20935,6 +21254,10 @@ var pipelineOrchestratorCapability = {
20935
21254
  agentNodeId: string().optional()
20936
21255
  }), CameraPipelineConfigSchema),
20937
21256
  /**
21257
+ * @deprecated The aggregate switch group is being withdrawn
21258
+ * ([D113](../../../../docs/decisions/adr-0113.md)). Build nothing new on
21259
+ * this pair; read the authority directly.
21260
+ *
20938
21261
  * The whole per-camera function switch group, DERIVED — never a stored
20939
21262
  * list ([D61](../../../../docs/decisions/adr-0067.md)).
20940
21263
  *
@@ -20948,9 +21271,23 @@ var pipelineOrchestratorCapability = {
20948
21271
  * `auth: 'view'` deliberately — a NON-admin must be able to see that a
20949
21272
  * camera is quiet because somebody switched it off. Only the mutation is
20950
21273
  * admin-gated.
21274
+ *
21275
+ * **Removal plan.** It stays and it KEEPS WORKING while shipped viewers
21276
+ * (v1.0.305) and the admin UI still call it — removing it now is a broken
21277
+ * app on a device nobody can redeploy from here. It is served by a thin
21278
+ * shim over the same authorities (`camera-switch-service.ts`), so the
21279
+ * behaviour of the pair is the behaviour of the authorities by
21280
+ * construction. It is deleted once every surface reaches its own
21281
+ * component's options and the last caller is gone. Nothing on this server
21282
+ * reads it: `CameraStatus.switchedOff` is composed from the authorities
21283
+ * directly via `composeSwitchedOff`.
20951
21284
  */
20952
21285
  getCameraSwitches: method(object({ deviceId: number() }), CameraSwitchGroupSchema),
20953
21286
  /**
21287
+ * @deprecated See {@link getCameraSwitches}. Write the authority — the
21288
+ * wrapper binding, `RecordingConfig.enabled`, the notification mute — not
21289
+ * this ([D113](../../../../docs/decisions/adr-0113.md)).
21290
+ *
20954
21291
  * Flip ONE switch, routed to its existing authority.
20955
21292
  *
20956
21293
  * Never writes a parallel map: `recording` patches `RecordingConfig.enabled`
@@ -21432,24 +21769,28 @@ var snapshotCapability = {
21432
21769
  *
21433
21770
  * `getSnapshotOverview` is cache-only by contract: it answers from whatever
21434
21771
  * the wrapper happens to hold and never captures. Under D93 the client
21435
- * versions its image URL on that answer, and an image REQUEST is what enrols
21436
- * a camera in the keep-warm loop. Both of those are satisfiable by the
21437
- * client's own image cache — `expo-image` is URL-keyed and never revalidates
21438
- * — so a URL painted in a previous session comes off disk with no network,
21439
- * no enrolment, and nothing warming. Measured on the live hub: reopening
21440
- * after two minutes idle painted 15 of 16 tiles at **168 s old** with zero
21441
- * HTTP requests, and the fleet only recovered because a later poll happened
21442
- * to observe a different identity.
21772
+ * versions its image URL on that answer, and an image REQUEST was the only
21773
+ * demand signal. Both of those are satisfiable by the client's own image
21774
+ * cache — `expo-image` is URL-keyed and never revalidates — so a URL painted
21775
+ * in a previous session comes off disk with no network, no demand, and no
21776
+ * capture. Measured on the live hub: reopening after two minutes idle
21777
+ * painted 15 of 16 tiles at **168 s old** with zero HTTP requests, and the
21778
+ * fleet only recovered because a later poll happened to observe a different
21779
+ * identity.
21443
21780
  *
21444
21781
  * ## The two properties that fix it
21445
21782
  *
21446
21783
  * **It is an RPC, so no client cache can answer it.** The demand signal
21447
- * always reaches the wrapper. This method therefore MAY create keep-warm
21448
- * subscriptions, where `getSnapshotOverview` must never (D93) — the
21449
- * distinction is not "one is newer" but that the overview poll is app-wide
21450
- * (a creating overview would warm every camera on the install) while this is
21451
- * called by a rendered surface naming the tiles it is actually painting, at
21452
- * the width it is painting them.
21784
+ * always reaches the wrapper. This method therefore CAPTURES, where
21785
+ * `getSnapshotOverview` must never (D93) — the distinction is not "one is
21786
+ * newer" but that the overview poll is app-wide (a capturing overview would
21787
+ * dial every camera on the install) while this is called by a rendered
21788
+ * surface naming the tiles it is actually painting, at the width it is
21789
+ * painting them.
21790
+ *
21791
+ * Since 2026-08-11 this is the ONLY thing that refreshes a snapshot: the
21792
+ * server-side keep-warm loop was removed (operator directive — on-demand,
21793
+ * always), so a camera nobody is looking at costs nothing at all.
21453
21794
  *
21454
21795
  * **It waits, briefly and boundedly, for the capture it triggered.** The
21455
21796
  * returned `capturedAt` is the frame the link will serve, not the frame the
@@ -28759,7 +29100,19 @@ var RecordingManifestSchema = object({
28759
29100
  * profiles/subtrees/locations on this node). */
28760
29101
  var RecordingDeviceUsageSchema = object({
28761
29102
  deviceId: number(),
28762
- usedBytes: number()
29103
+ usedBytes: number(),
29104
+ /**
29105
+ * Start of this camera's OLDEST indexed segment, across every profile and
29106
+ * location — the "Oldest footage" column in Recordings → Storage, and the
29107
+ * only honest answer to "is retention actually holding?" per camera.
29108
+ *
29109
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
29110
+ * predates this field omits it entirely, and a hub whose types carry the
29111
+ * field must keep validating that older provider's payload: the framework
29112
+ * (types) and the addon ship on different trains, and the addon is usually
29113
+ * the later of the two.
29114
+ */
29115
+ oldestMs: number().nullable().optional()
28763
29116
  });
28764
29117
  /** Recording storage usage + capacity for one storage location. */
28765
29118
  var RecordingLocationUsageSchema = object({
@@ -28787,6 +29140,57 @@ var RecordingStorageUsageSchema = object({
28787
29140
  locations: array(RecordingLocationUsageSchema)
28788
29141
  });
28789
29142
  /**
29143
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
29144
+ *
29145
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
29146
+ * is the operator asking for the EXISTING archive to be brought into line with
29147
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
29148
+ * location, run FIFO behind the single-flight mover.
29149
+ *
29150
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
29151
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
29152
+ * (empty on the plan).
29153
+ */
29154
+ var RecordingRebalanceMoveSchema = object({
29155
+ deviceId: number(),
29156
+ profile: string(),
29157
+ fromLocationId: string(),
29158
+ toLocationId: string(),
29159
+ bytes: number(),
29160
+ files: number().int()
29161
+ });
29162
+ /** Why a pile that is out of place is staying there. Every refusal is
29163
+ * reported: a rebalance that silently drops a camera reads exactly like one
29164
+ * that had nothing to do. */
29165
+ var RecordingRebalanceSkipReasonSchema = _enum([
29166
+ "unassigned",
29167
+ "target-not-writable",
29168
+ "below-threshold",
29169
+ "no-headroom"
29170
+ ]);
29171
+ var RecordingRebalanceSkipSchema = object({
29172
+ deviceId: number(),
29173
+ profile: string(),
29174
+ fromLocationId: string(),
29175
+ /** The location the plan wants; null when the camera has no assignment. */
29176
+ toLocationId: string().nullable(),
29177
+ bytes: number(),
29178
+ reason: RecordingRebalanceSkipReasonSchema
29179
+ });
29180
+ var RecordingRebalancePlanSchema = object({
29181
+ moves: array(RecordingRebalanceMoveSchema),
29182
+ skipped: array(RecordingRebalanceSkipSchema),
29183
+ bytesToMove: number(),
29184
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
29185
+ jobIds: array(string())
29186
+ });
29187
+ var RecordingRebalanceInputSchema = object({
29188
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
29189
+ throttleMbps: number().min(1).max(1e3).optional(),
29190
+ /** Ignore piles smaller than this (default 1 GB). */
29191
+ minMoveGb: number().min(0).optional()
29192
+ });
29193
+ /**
28790
29194
  * Result of locating footage at a wall-clock instant for one device/profile.
28791
29195
  * `segment` carries the covering segment's window; `gap` reports the forward
28792
29196
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -29030,11 +29434,41 @@ var recordingCapability = {
29030
29434
  cancelStorageMigrationMove: method(object({ jobId: string() }), object({ cancelled: boolean() }), {
29031
29435
  kind: "mutation",
29032
29436
  auth: "admin"
29437
+ }),
29438
+ /**
29439
+ * Move footage between locations — the OPERATOR's mover, scoped to one
29440
+ * camera (and optionally to specific profiles) rather than a whole disk.
29441
+ * Queued FIFO behind the single-flight engine, so arming several is safe.
29442
+ */
29443
+ relocateFootage: method(RelocateFootageInputSchema, object({ jobId: string() }), {
29444
+ kind: "mutation",
29445
+ auth: "admin"
29446
+ }),
29447
+ /** Every relocate job this recorder knows about, newest first (in RAM: the
29448
+ * move is resumable, so a lost list costs nothing but the display). */
29449
+ listRelocateJobs: method(object({}), array(RelocateJobSchema).readonly(), {
29450
+ kind: "query",
29451
+ auth: "admin"
29452
+ }),
29453
+ /** Cancel a running or queued relocate job. A queued job never runs. */
29454
+ cancelRelocateJob: method(object({ jobId: string() }), object({ cancelled: boolean() }), {
29455
+ kind: "mutation",
29456
+ auth: "admin"
29457
+ }),
29458
+ /** What a rebalance WOULD move, and what it would refuse. Moves nothing. */
29459
+ planStorageRebalance: method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
29460
+ kind: "query",
29461
+ auth: "admin"
29462
+ }),
29463
+ /** Arm the rebalance: enqueue one relocate job per planned move. */
29464
+ startStorageRebalance: method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
29465
+ kind: "mutation",
29466
+ auth: "admin"
29033
29467
  })
29034
29468
  }
29035
29469
  };
29036
29470
  /**
29037
- * `recordingExport` cap — render a footage time range into a single downloadable
29471
+ * `recording-export` cap — render a footage time range into a single downloadable
29038
29472
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
29039
29473
  * bounded lifetime with a durable history, auto-expiry, and optional
29040
29474
  * delete-after-download.
@@ -29049,10 +29483,53 @@ var recordingCapability = {
29049
29483
  */
29050
29484
  /** Playback-speed multiplier for the render (1 = realtime). */
29051
29485
  var ExportSpeedSchema = number().min(.25).max(32);
29486
+ /**
29487
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
29488
+ *
29489
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
29490
+ * derives these bounds from things that happened at a TIME (a track's
29491
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
29492
+ * every segment present for the range, with each recording GAP removed. The
29493
+ * two agree only on a window that recorded without one interruption, and only
29494
+ * the render side knows the segments, so the translation lives there
29495
+ * (`export-dense-map.ts`, addon-pipeline).
29496
+ *
29497
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
29498
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
29499
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
29500
+ * the video was a uniform timelapse, and the log line reported the five ranges
29501
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
29502
+ *
29503
+ * Relative and not absolute epoch, because an absolute epoch would make every
29504
+ * call site responsible for the same subtraction.
29505
+ */
29506
+ var ExportDenseRangeSchema = object({
29507
+ fromSec: number().nonnegative(),
29508
+ toSec: number().nonnegative()
29509
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
29510
+ /**
29511
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
29512
+ * listed ranges and at the base `everyMs` everywhere else.
29513
+ *
29514
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
29515
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
29516
+ */
29517
+ var ExportDenseSchema = object({
29518
+ everyMs: number().int().positive(),
29519
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
29520
+ });
29052
29521
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
29053
29522
  var ExportTimelapseSchema = object({
29054
29523
  everyMs: number().int().positive(),
29055
- outputFps: number().int().min(1).max(60).optional()
29524
+ outputFps: number().int().min(1).max(60).optional(),
29525
+ /** Optional second, FASTER rate over the intervals that matter. */
29526
+ dense: ExportDenseSchema.optional()
29527
+ }).superRefine((v, ctx) => {
29528
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
29529
+ code: ZodIssueCode.custom,
29530
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
29531
+ path: ["dense", "everyMs"]
29532
+ });
29056
29533
  });
29057
29534
  /**
29058
29535
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -29110,8 +29587,21 @@ var ExportDownloadSchema = object({
29110
29587
  url: string(),
29111
29588
  endpoints: array(string())
29112
29589
  });
29590
+ /**
29591
+ * A finished export's bytes, inline.
29592
+ *
29593
+ * `bytes` is the DECODED length — the number the caller bounds and logs
29594
+ * against, so nobody has to infer it from the base64 length.
29595
+ */
29596
+ var ExportBytesSchema = object({
29597
+ base64: string(),
29598
+ contentType: string(),
29599
+ /** Suggested filename, extension included. */
29600
+ name: string(),
29601
+ bytes: number().int().nonnegative()
29602
+ });
29113
29603
  var recordingExportCapability = {
29114
- name: "recordingExport",
29604
+ name: "recording-export",
29115
29605
  scope: "system",
29116
29606
  mode: "singleton",
29117
29607
  methods: {
@@ -29149,6 +29639,27 @@ var recordingExportCapability = {
29149
29639
  getDownloadUrl: method(object({ exportId: string() }), ExportDownloadSchema, {
29150
29640
  kind: "query",
29151
29641
  auth: "protected"
29642
+ }),
29643
+ /**
29644
+ * The finished file's BYTES, base64, for a caller that must republish them
29645
+ * somewhere a session-less fetcher can reach.
29646
+ *
29647
+ * `getDownloadUrl` is the right answer for a human: the download route is
29648
+ * served `access: 'authenticated'`, which a browser satisfies and a
29649
+ * notifier BACKEND does not. It answers a RELATIVE path, so it is not even
29650
+ * a URL an outside fetcher could try. This method exists for the one case
29651
+ * that needs the other thing — a scheduled timelapse whose video has to
29652
+ * become a public attachment on the notification artifact plane.
29653
+ *
29654
+ * Deliberately narrow: `ready` only (a queued, rendering, failed, expired
29655
+ * or deleted export has no file, and answering "0 bytes" for one is how a
29656
+ * caller ships an empty attachment), still inside its lifetime, and under
29657
+ * {@link RECORDING_EXPORT_MAX_READ_BYTES}. Every refusal throws with the
29658
+ * reason — none of them is silent.
29659
+ */
29660
+ readExportBytes: method(object({ exportId: string() }), ExportBytesSchema, {
29661
+ kind: "query",
29662
+ auth: "protected"
29152
29663
  })
29153
29664
  }
29154
29665
  };
@@ -35085,6 +35596,12 @@ Object.freeze({
35085
35596
  addonId: null,
35086
35597
  access: "create"
35087
35598
  },
35599
+ "recording.cancelRelocateJob": {
35600
+ capName: "recording",
35601
+ capScope: "system",
35602
+ addonId: null,
35603
+ access: "create"
35604
+ },
35088
35605
  "recording.cancelStorageMigrationMove": {
35089
35606
  capName: "recording",
35090
35607
  capScope: "system",
@@ -35139,6 +35656,12 @@ Object.freeze({
35139
35656
  addonId: null,
35140
35657
  access: "view"
35141
35658
  },
35659
+ "recording.listRelocateJobs": {
35660
+ capName: "recording",
35661
+ capScope: "system",
35662
+ addonId: null,
35663
+ access: "view"
35664
+ },
35142
35665
  "recording.locateSegment": {
35143
35666
  capName: "recording",
35144
35667
  capScope: "system",
@@ -35151,6 +35674,12 @@ Object.freeze({
35151
35674
  addonId: null,
35152
35675
  access: "create"
35153
35676
  },
35677
+ "recording.planStorageRebalance": {
35678
+ capName: "recording",
35679
+ capScope: "system",
35680
+ addonId: null,
35681
+ access: "view"
35682
+ },
35154
35683
  "recording.pruneFootage": {
35155
35684
  capName: "recording",
35156
35685
  capScope: "system",
@@ -35175,6 +35704,12 @@ Object.freeze({
35175
35704
  addonId: null,
35176
35705
  access: "create"
35177
35706
  },
35707
+ "recording.relocateFootage": {
35708
+ capName: "recording",
35709
+ capScope: "system",
35710
+ addonId: null,
35711
+ access: "create"
35712
+ },
35178
35713
  "recording.renderClip": {
35179
35714
  capName: "recording",
35180
35715
  capScope: "system",
@@ -35211,38 +35746,50 @@ Object.freeze({
35211
35746
  addonId: null,
35212
35747
  access: "create"
35213
35748
  },
35749
+ "recording.startStorageRebalance": {
35750
+ capName: "recording",
35751
+ capScope: "system",
35752
+ addonId: null,
35753
+ access: "create"
35754
+ },
35214
35755
  "recordingExport.cancelExport": {
35215
- capName: "recordingExport",
35756
+ capName: "recording-export",
35216
35757
  capScope: "system",
35217
35758
  addonId: null,
35218
35759
  access: "create"
35219
35760
  },
35220
35761
  "recordingExport.createExport": {
35221
- capName: "recordingExport",
35762
+ capName: "recording-export",
35222
35763
  capScope: "system",
35223
35764
  addonId: null,
35224
35765
  access: "create"
35225
35766
  },
35226
35767
  "recordingExport.deleteExport": {
35227
- capName: "recordingExport",
35768
+ capName: "recording-export",
35228
35769
  capScope: "system",
35229
35770
  addonId: null,
35230
35771
  access: "delete"
35231
35772
  },
35232
35773
  "recordingExport.getDownloadUrl": {
35233
- capName: "recordingExport",
35774
+ capName: "recording-export",
35234
35775
  capScope: "system",
35235
35776
  addonId: null,
35236
35777
  access: "view"
35237
35778
  },
35238
35779
  "recordingExport.getExport": {
35239
- capName: "recordingExport",
35780
+ capName: "recording-export",
35240
35781
  capScope: "system",
35241
35782
  addonId: null,
35242
35783
  access: "view"
35243
35784
  },
35244
35785
  "recordingExport.listExports": {
35245
- capName: "recordingExport",
35786
+ capName: "recording-export",
35787
+ capScope: "system",
35788
+ addonId: null,
35789
+ access: "view"
35790
+ },
35791
+ "recordingExport.readExportBytes": {
35792
+ capName: "recording-export",
35246
35793
  capScope: "system",
35247
35794
  addonId: null,
35248
35795
  access: "view"
@@ -36679,6 +37226,104 @@ var FramerateField = number().int().min(1).max(60);
36679
37226
  var TargetsField = array(NcRuleTargetSchema).min(1);
36680
37227
  var PriorityField = number().int().min(1).max(5);
36681
37228
  /**
37229
+ * Explicit override of the DENSE sampling cadence, seconds.
37230
+ *
37231
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
37232
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
37233
+ * made that same base 3 s and rendered a person pass as two frames.)
37234
+ *
37235
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
37236
+ * `denseCadenceSec` and played at `framerate` occupies
37237
+ *
37238
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
37239
+ *
37240
+ * 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.
37241
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
37242
+ * and therefore the length of a quiet night, does not move.
37243
+ *
37244
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
37245
+ * the recording has them returns the same frames, requested twice. Must be
37246
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
37247
+ * a uniform video the operator believes is two-rate — and upsert refuses it
37248
+ * rather than letting the export cap reject the render hours after the window.
37249
+ */
37250
+ var DenseCadenceSecField = number().min(.1).max(3600);
37251
+ /**
37252
+ * Minimum seconds of OUTPUT video each detection range must occupy.
37253
+ *
37254
+ * The operator-facing form of the arithmetic above: instead of solving for a
37255
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
37256
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
37257
+ * that range every ~583 ms.
37258
+ *
37259
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
37260
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
37261
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
37262
+ * ranges are sampled denser than they need. Per-range cadences require a cap
37263
+ * schema change and are the tracked follow-up.
37264
+ *
37265
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
37266
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
37267
+ * by real footage, never met by duplicating frames into motion that never
37268
+ * happened.
37269
+ */
37270
+ var MinDwellSecField = number().min(0).max(60);
37271
+ /**
37272
+ * Caption burned into the notification's preview frame.
37273
+ *
37274
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
37275
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
37276
+ * templating dialect for one field would be a second thing to explain.
37277
+ *
37278
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
37279
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
37280
+ * the reason this is not `.min(1)`.
37281
+ */
37282
+ var PreviewTextField = string().max(200);
37283
+ /**
37284
+ * Whether the notification's preview is a STILL or a short animation.
37285
+ *
37286
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
37287
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
37288
+ * night reads better as three seconds of motion than as one frame of it. Both
37289
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
37290
+ * simply applies it to a dozen frames sampled across the render and assembles
37291
+ * them.
37292
+ *
37293
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
37294
+ * seeks and a palette pass, and no rule that never asked for one should start
37295
+ * paying that on the deploy that shipped it.
37296
+ *
37297
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
37298
+ */
37299
+ var PreviewModeField = _enum(["image", "gif"]);
37300
+ /**
37301
+ * Which detection classes the notification reports counts for.
37302
+ *
37303
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
37304
+ * plan — no second query — aggregated per class. Absent or empty means "every
37305
+ * class the window actually contained", which is what an operator who never
37306
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
37307
+ * counts cars all night).
37308
+ *
37309
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
37310
+ * …). An unknown name simply never matches and reports nothing — it is not an
37311
+ * error, because a rule may legitimately name a class this camera's model does
37312
+ * not emit.
37313
+ *
37314
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
37315
+ * - `{{detections}}` — total over the reported classes
37316
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
37317
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
37318
+ * one per class, `count_` + the class name
37319
+ *
37320
+ * With NO custom body template the summary is appended to the derived body, and
37321
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
37322
+ * reads. With a custom template the operator owns every word — nothing is
37323
+ * appended, so `{{detectionSummary}}` is how he asks for it.
37324
+ */
37325
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
37326
+ /**
36682
37327
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
36683
37328
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
36684
37329
  * here (see the ownership note above).
@@ -36698,9 +37343,30 @@ var TimelapseRuleInputSchema = object({
36698
37343
  cadenceSec: CadenceSecField.default(15),
36699
37344
  /** Output frames per second of the assembled mp4 (predecessor parity). */
36700
37345
  framerate: FramerateField.default(10),
37346
+ /**
37347
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
37348
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
37349
+ * field gets.
37350
+ */
37351
+ denseCadenceSec: DenseCadenceSecField.optional(),
37352
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
37353
+ minDwellSec: MinDwellSecField.optional(),
36701
37354
  /** `notification-output` targets the finished video/thumbnail is sent to. */
36702
37355
  targets: TargetsField,
36703
37356
  template: TimelapseTemplateSchema.optional(),
37357
+ /**
37358
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
37359
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
37360
+ *
37361
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
37362
+ * the notification's title/body, and clearing it (`template: null`) must not
37363
+ * silently clear the caption too.
37364
+ */
37365
+ previewText: PreviewTextField.optional(),
37366
+ /** Still or animation — see {@link PreviewModeField}. */
37367
+ previewMode: PreviewModeField.default("image"),
37368
+ /** Classes the notification counts — see {@link ReportClassesField}. */
37369
+ reportClasses: ReportClassesField.optional(),
36704
37370
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
36705
37371
  priority: PriorityField.default(3)
36706
37372
  });
@@ -36711,8 +37377,13 @@ object({
36711
37377
  schedule: NcScheduleSchema.optional(),
36712
37378
  cadenceSec: CadenceSecField.optional(),
36713
37379
  framerate: FramerateField.optional(),
37380
+ denseCadenceSec: DenseCadenceSecField.optional(),
37381
+ minDwellSec: MinDwellSecField.optional(),
36714
37382
  targets: TargetsField.optional(),
36715
37383
  template: TimelapseTemplateSchema.nullable().optional(),
37384
+ previewText: PreviewTextField.optional(),
37385
+ previewMode: PreviewModeField.optional(),
37386
+ reportClasses: ReportClassesField.optional(),
36716
37387
  priority: PriorityField.optional()
36717
37388
  });
36718
37389
  TimelapseRuleInputSchema.extend({
@@ -36724,10 +37395,28 @@ TimelapseRuleInputSchema.extend({
36724
37395
  */
36725
37396
  ownerUserId: string().optional(),
36726
37397
  /**
36727
- * Epoch-ms of the last successful generation the 1-hour re-generation
36728
- * guard's durable state (predecessor parity). Absent = never generated.
37398
+ * Epoch-ms of the NEWEST successful generation across every camera of this
37399
+ * rule. What a UI shows, and the compatibility floor for
37400
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
36729
37401
  */
36730
37402
  lastGeneratedAt: number().optional(),
37403
+ /**
37404
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
37405
+ * re-generation guard's real durable state.
37406
+ *
37407
+ * One rule covers several cameras and each renders its own video, so a rule
37408
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
37409
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
37410
+ * already done — and B's night is gone for good, because the window will not
37411
+ * come back.
37412
+ *
37413
+ * ADDITIVE, so the migration is free: a row written before this field simply
37414
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
37415
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
37416
+ * "never generated" would re-render and re-notify every camera of every rule
37417
+ * once, on the deploy that shipped the map.
37418
+ */
37419
+ generatedByDevice: record(string(), number()).optional(),
36731
37420
  /** userId of the caller who created the rule (server-stamped). */
36732
37421
  createdBy: string(),
36733
37422
  createdAt: number(),
@@ -36778,25 +37467,32 @@ object({
36778
37467
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
36779
37468
  object({
36780
37469
  /**
36781
- * How long a retained native frame is served before it counts as a miss.
37470
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
37471
+ * detection result.
36782
37472
  *
36783
- * Must cover the FULL late-crop horizon: detection inference + the
36784
- * cross-process inference-result hop to hub post-analysis + tracking + the
36785
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
36786
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
36787
- * RAM per busy camera grows linearly with no measured hit-rate gain.
37473
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
37474
+ * a time window was never related to the event the pixels were waiting for.
37475
+ * A held frame now lives from delivery until the runner has its `FrameResult`
37476
+ * at which moment the runner cuts the subject tiles it actually wanted and
37477
+ * releases the frame. The bound exists only so a runner that stops answering
37478
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
37479
+ *
37480
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
37481
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
37482
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
37483
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
37484
+ * `holdOverflow` on the metrics line is what says you need it.
36788
37485
  */
36789
- ttlMs: number().int().min(250).max(1e4),
37486
+ holdFrames: number().int().min(1).max(64),
36790
37487
  /**
36791
37488
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
36792
37489
  *
36793
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
36794
- * which one is actually binding before reasoning from that. At the shipped
36795
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
36796
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
36797
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
36798
- * change that admits fewer frames buys retention WINDOW at constant RAM
36799
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
37490
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
37491
+ * is what decides how much is held, and the ceiling is the number above which
37492
+ * something is wrong. Before that it was the effective cap at 1024 MB with
37493
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
37494
+ * with the TTL expiring nothing, which is exactly the confusion the hold
37495
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
36800
37496
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
36801
37497
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
36802
37498
  * to replace).
@@ -36822,22 +37518,45 @@ object({
36822
37518
  * there is the signal that some caller names frames outside the inference set
36823
37519
  * and that this must go back to `all`.
36824
37520
  */
36825
- admission: NativeLeaseAdmissionSchema
37521
+ admission: NativeLeaseAdmissionSchema,
37522
+ /**
37523
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
37524
+ * compressed native crops the worker cuts at the moment a frame's detection
37525
+ * result arrives, and keeps long after the frame itself is freed.
37526
+ *
37527
+ * This is the knob that replaced the old retention window, and it buys about
37528
+ * three orders of magnitude more of it: a tile is one subject at native
37529
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
37530
+ * the frame it was cut from. A frame on which nothing was detected costs
37531
+ * nothing at all, which is the real change — the old lease paid per FRAME and
37532
+ * was interrogated per SUBJECT.
37533
+ *
37534
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
37535
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
37536
+ * reproduce that.
37537
+ */
37538
+ tileBudgetMb: number().int().min(0).max(1024)
36826
37539
  });
36827
37540
  /**
36828
- * The values in force when the operator has set nothing — byte-for-byte the
36829
- * constants the decode worker shipped with as env-var defaults, so making these
36830
- * settings changed no behaviour on the day it landed.
37541
+ * The values in force when the operator has set nothing.
37542
+ *
37543
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
37544
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
37545
+ * in the same change that redefines it would make a regression and a retune
37546
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
37547
+ * live traffic.
36831
37548
  */
36832
37549
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
36833
- ttlMs: 1200,
37550
+ holdFrames: 8,
36834
37551
  budgetMb: 1024,
36835
37552
  activityMs: 15e3,
37553
+ tileBudgetMb: 64,
36836
37554
  admission: "inferred"
36837
37555
  };
36838
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
37556
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
36839
37557
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
36840
37558
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
37559
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
36841
37560
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
36842
37561
  //#endregion
36843
37562
  //#region src/bindings-store.ts