@camstack/addon-provider-wyze 0.2.12 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +704 -56
  2. package/dist/addon.mjs +704 -56
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -7236,8 +7236,31 @@ var AdoptionJobSchema = object({
7236
7236
  error: string().nullable()
7237
7237
  });
7238
7238
  /**
7239
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7240
- * pipeline functions an operator thinks in terms of.
7239
+ * Per-camera FUNCTION SWITCHES.
7240
+ *
7241
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7242
+ *
7243
+ * This file shipped as "the one coherent on/off surface over the pipeline
7244
+ * functions an operator thinks in terms of". The operator's verdict on
7245
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7246
+ * every function already had a settings page of its own, and a second place to
7247
+ * turn it off is a second place to look. Each switch is going back to its own
7248
+ * component's original options — detection to the detection-pipeline wrapper
7249
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7250
+ * (which was always first-class; the switch was a veneer over
7251
+ * `recording.setDeviceConfig`), notifications to a notification-center
7252
+ * per-device setting, the two camera planes to their own components.
7253
+ *
7254
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7255
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7256
+ * straight from the authorities with no group in the middle. That rule was
7257
+ * never about a control panel.
7258
+ *
7259
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7260
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7261
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7262
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7263
+ * stop; nothing new may be built on it.
7241
7264
  *
7242
7265
  * ## This file adds no state
7243
7266
  *
@@ -7588,7 +7611,15 @@ var RecordingConfigSchema = object({
7588
7611
  * Each completed/failed run also lands one durable ops-log row on its owning
7589
7612
  * addon surface.
7590
7613
  */
7614
+ /**
7615
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7616
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7617
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7618
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7619
+ * runs at all.
7620
+ */
7591
7621
  var RelocateJobStateSchema = _enum([
7622
+ "queued",
7592
7623
  "running",
7593
7624
  "done",
7594
7625
  "failed",
@@ -7623,6 +7654,15 @@ var RelocateFootageInputSchema = object({
7623
7654
  /** Limits relocation to the logical profile class. Omit only for the
7624
7655
  * pre-orchestration compatibility path. */
7625
7656
  footageClass: RelocateFootageClassSchema.optional(),
7657
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7658
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7659
+ * unit is a (camera, profile) pile, not a disk. */
7660
+ deviceId: number().int().optional(),
7661
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7662
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7663
+ * placement plan assigns those two independently, so a rebalance that could
7664
+ * only say "recordings" would move footage the plan never asked to move. */
7665
+ profiles: array(string()).optional(),
7626
7666
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7627
7667
  * never allowed to starve live writers. */
7628
7668
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7758,6 +7798,21 @@ var StorageLocationSchema = object({
7758
7798
  nodeId: string().optional(),
7759
7799
  isDefault: boolean().default(false),
7760
7800
  isSystem: boolean().default(false),
7801
+ /**
7802
+ * Operator opt-in: whether consumers that BALANCE across several locations
7803
+ * of a type may write here. Recordings reads it today; event media and
7804
+ * backups are the next consumers, which is why the flag lives on the
7805
+ * location rather than in any one addon's store — nothing has to be
7806
+ * extended to add the next consumer.
7807
+ *
7808
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7809
+ * flag existed reads back with no flag and keeps working exactly as before;
7810
+ * that is the whole compat story, and it is why no migration ships with it.
7811
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7812
+ * disk must not silently start writing to it); the default of a type is
7813
+ * always stamped `true`.
7814
+ */
7815
+ enabled: boolean().optional(),
7761
7816
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7762
7817
  * for node-local locations it can reach) — never persisted, absent when the
7763
7818
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12327,7 +12382,8 @@ method(object({
12327
12382
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12328
12383
  /**
12329
12384
  * filesystem-browse — per-node capability for browsing the node's local
12330
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12385
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12386
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12331
12387
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12332
12388
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12333
12389
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14168,6 +14224,13 @@ var MaskGridDimsSchema = object({
14168
14224
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14169
14225
  * this one field keeps the schema additive — a rule still declares exactly
14170
14226
  * one trigger.
14227
+ *
14228
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14229
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14230
+ * mirror.ts` fails the build on a member the app cannot render) and every
14231
+ * member costs a release train. A sustained-sound rule is therefore an
14232
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14233
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14171
14234
  */
14172
14235
  var NcDeliverySchema = _enum([
14173
14236
  "immediate",
@@ -14182,15 +14245,32 @@ var NcDeliverySchema = _enum([
14182
14245
  * depend on a provider's raw event name or payload shape.
14183
14246
  */
14184
14247
  var NcSystemEventKindSchema = _enum([
14185
- "camera-online",
14186
- "camera-offline",
14248
+ "device-online",
14249
+ "device-offline",
14250
+ "device-disabled",
14251
+ "device-enabled",
14187
14252
  "stream-online",
14188
14253
  "stream-offline",
14189
14254
  "node-online",
14190
14255
  "node-offline",
14191
14256
  "addon-update-available",
14192
- "server-update-available"
14257
+ "server-update-available",
14258
+ "alarm-triggered",
14259
+ "alarm-armed",
14260
+ "alarm-disarmed",
14261
+ "camera-online",
14262
+ "camera-offline",
14263
+ "camera-disabled",
14264
+ "camera-enabled"
14265
+ ]);
14266
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14267
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14268
+ "camera-online",
14269
+ "camera-offline",
14270
+ "camera-disabled",
14271
+ "camera-enabled"
14193
14272
  ]);
14273
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14194
14274
  /**
14195
14275
  * One coherent system-event condition. `kinds` is the required opt-in safety
14196
14276
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14199,6 +14279,18 @@ var NcSystemEventKindSchema = _enum([
14199
14279
  var NcSystemEventConditionSchema = object({
14200
14280
  kinds: array(NcSystemEventKindSchema).min(1),
14201
14281
  deviceIds: array(number().int()).min(1).optional(),
14282
+ /**
14283
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14284
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14285
+ * is what a liveness rule means when nobody said otherwise.
14286
+ *
14287
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14288
+ * one reason: the intake cannot know which devices this household cares
14289
+ * about, and a producer-side filter is one no operator can change. Fails
14290
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14291
+ * does not carry) matches no `deviceTypes` list.
14292
+ */
14293
+ deviceTypes: array(string().min(1)).min(1).optional(),
14202
14294
  nodeIds: array(string().min(1)).min(1).optional(),
14203
14295
  packageNames: array(string().min(1)).min(1).optional()
14204
14296
  });
@@ -14249,6 +14341,47 @@ var NcOccupancyConditionSchema = object({
14249
14341
  sustainSeconds: number().int().min(0).max(3600).default(15)
14250
14342
  });
14251
14343
  /**
14344
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14345
+ *
14346
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14347
+ * reference notifier uses, so an operator moving between them re-uses what
14348
+ * they already know): a rule matches when, over a sampling window of
14349
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14350
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14351
+ *
14352
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14353
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14354
+ * - `labels` — the classifier put at least one of these labels on it.
14355
+ *
14356
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14357
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14358
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14359
+ * is given** — a window in which every sample is trivially a hit would fire on
14360
+ * silence, so the engine refuses such a condition rather than notifying on
14361
+ * nothing (the schema cannot express "at least one of" without becoming a
14362
+ * ZodEffects the cap path would have to special-case).
14363
+ *
14364
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14365
+ * must be FULL before it can match — a window that has been open for two
14366
+ * seconds of its ten is 100% of nothing, and firing on it would make
14367
+ * `samplingSeconds` decorative.
14368
+ *
14369
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14370
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14371
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14372
+ * an operator who typed `dog` mean the same thing.
14373
+ */
14374
+ var NcAudioConditionSchema = object({
14375
+ /** Audio macro labels; absent = any sound (level-only rule). */
14376
+ labels: array(string().min(1)).min(1).optional(),
14377
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14378
+ dbThreshold: number().min(-96).max(0).optional(),
14379
+ /** Percentage of the window's samples that must be hits (1–100). */
14380
+ hitPercent: number().int().min(1).max(100).default(60),
14381
+ /** Length of the sampling window in seconds. */
14382
+ samplingSeconds: number().int().min(1).max(300).default(10)
14383
+ });
14384
+ /**
14252
14385
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14253
14386
  *
14254
14387
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14521,7 +14654,33 @@ var NcConditionsSchema = object({
14521
14654
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14522
14655
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14523
14656
  */
14524
- occupancy: NcOccupancyConditionSchema.optional()
14657
+ occupancy: NcOccupancyConditionSchema.optional(),
14658
+ /**
14659
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14660
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14661
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14662
+ * a window that is not full yet, neither filter given). See
14663
+ * {@link NcAudioCondition}.
14664
+ *
14665
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14666
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14667
+ * a detection, a track or a device event (the same fail-closed pairing
14668
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14669
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14670
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14671
+ * classified sample) stays exactly as it was for rules that already use it.
14672
+ *
14673
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14674
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14675
+ * (`camstack/src/data/notification-center.ts`, guarded by
14676
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14677
+ * condition fields it does not know when a rule is saved from the phone.
14678
+ * Publishing an editor for a condition the app cannot round-trip is how an
14679
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14680
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14681
+ * does an audio rule become authorable.
14682
+ */
14683
+ audio: NcAudioConditionSchema.optional()
14525
14684
  });
14526
14685
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14527
14686
  var NcRuleTargetSchema = object({
@@ -14635,6 +14794,73 @@ var NcThrottleSchema = object({
14635
14794
  */
14636
14795
  granularity: NcThrottleGranularitySchema.optional()
14637
14796
  });
14797
+ /**
14798
+ * How long the confirm gate may hold ONE notification, and how big the picture
14799
+ * it judges may be.
14800
+ *
14801
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14802
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14803
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14804
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14805
+ * tokens for pixels the model pools away.
14806
+ */
14807
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14808
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14809
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14810
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14811
+ var NcConfirmExpectSchema = object({
14812
+ op: _enum([
14813
+ ">=",
14814
+ ">",
14815
+ "<=",
14816
+ "<",
14817
+ "=="
14818
+ ]),
14819
+ count: number().int().min(0).max(1e3)
14820
+ });
14821
+ /**
14822
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14823
+ * to ship and says whether it agrees with the rule.
14824
+ *
14825
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14826
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14827
+ * on the operator's phone is not a verdict about this notification.
14828
+ *
14829
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14830
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14831
+ * the default and every fail-open is COUNTED, because a gate that always fails
14832
+ * open looks in the log exactly like a gate that works.
14833
+ *
14834
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14835
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14836
+ * production failures in one day), so the gate reads absent as the constant
14837
+ * above rather than trusting a parse it may never have seen.
14838
+ */
14839
+ var NcConfirmSchema = object({
14840
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14841
+ * same thing, and both mean "deliver exactly as before". */
14842
+ enabled: boolean().default(false),
14843
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14844
+ profileId: string().optional(),
14845
+ /**
14846
+ * The operator's question, in his own words. Absent = a question derived
14847
+ * from the rule (its class and its expectation).
14848
+ *
14849
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14850
+ * banners, signage and plates as instructions if you let them reach the
14851
+ * prompt — proven live — so the authoritative contract stays in the system
14852
+ * turn and only rule-authored words land here.
14853
+ */
14854
+ prompt: string().max(1e3).optional(),
14855
+ /** Fire only when the model's count satisfies this. Absent = the model's
14856
+ * own boolean verdict decides. */
14857
+ expect: NcConfirmExpectSchema.optional(),
14858
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14859
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14860
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14861
+ /** Longest edge the judged image is downscaled to before it is sent. */
14862
+ maxImagePx: number().int().min(64).max(2048).default(448)
14863
+ });
14638
14864
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14639
14865
  var NcRuleInputSchema = object({
14640
14866
  name: string().min(1).max(200),
@@ -14695,7 +14921,13 @@ var NcRuleInputSchema = object({
14695
14921
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14696
14922
  * shape as every other actuation.
14697
14923
  */
14698
- actions: NcRuleActionsSchema.optional()
14924
+ actions: NcRuleActionsSchema.optional(),
14925
+ /**
14926
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14927
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14928
+ * did, and absent is the only way to say that without a migration.
14929
+ */
14930
+ confirm: NcConfirmSchema.optional()
14699
14931
  });
14700
14932
  /**
14701
14933
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14706,7 +14938,37 @@ var NcRuleInputSchema = object({
14706
14938
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14707
14939
  * `updateRule` patch.
14708
14940
  */
14709
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14941
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14942
+ disabledTargetIds: array(string()).optional(),
14943
+ /**
14944
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14945
+ *
14946
+ * It makes the key optional to SUPPLY; the parse still materialises the
14947
+ * default when the key is absent. And `NcRuleStore.update` merges with
14948
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14949
+ * one — which made every partial edit destructive:
14950
+ *
14951
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14952
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14953
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14954
+ *
14955
+ * A rule scoped to one camera and one zone silently became a rule that
14956
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14957
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14958
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14959
+ * within a minute of a two-field patch.
14960
+ *
14961
+ * So every defaulted field is re-declared here WITHOUT its default. The
14962
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14963
+ * conditions remains a real instruction ("clear them") — and only the
14964
+ * absent key is now genuinely absent.
14965
+ */
14966
+ enabled: boolean().optional(),
14967
+ conditions: NcConditionsSchema.optional(),
14968
+ media: NcMediaPolicySchema.optional(),
14969
+ throttle: NcThrottleSchema.optional(),
14970
+ priority: number().int().min(1).max(5).optional()
14971
+ });
14710
14972
  /** A persisted rule. */
14711
14973
  var NcRuleSchema = NcRuleInputSchema.extend({
14712
14974
  id: string(),
@@ -15007,6 +15269,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15007
15269
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15008
15270
  * copy would lie the first time a rule is disabled.
15009
15271
  */
15272
+ /**
15273
+ * Why a device a mode NAMES is nonetheless not armed by it.
15274
+ *
15275
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15276
+ * per-camera notification switch the Notification Center already owns,
15277
+ * `detection-off` is the device's own detection binding being inactive, and
15278
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15279
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15280
+ * with the switches the operator actually used.
15281
+ */
15282
+ var NcAlarmSkipReasonSchema = _enum([
15283
+ "muted",
15284
+ "detection-off",
15285
+ "offline"
15286
+ ]);
15287
+ var NcAlarmSkippedDeviceSchema = object({
15288
+ deviceId: number().int(),
15289
+ reason: NcAlarmSkipReasonSchema
15290
+ });
15010
15291
  var NcAlarmModeCoverageSchema = object({
15011
15292
  mode: AlarmArmModeSchema,
15012
15293
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15014,7 +15295,18 @@ var NcAlarmModeCoverageSchema = object({
15014
15295
  /** At least one covering rule has no device scope, so the mode covers all. */
15015
15296
  allDevices: boolean(),
15016
15297
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15017
- deviceIds: array(number().int())
15298
+ deviceIds: array(number().int()),
15299
+ /**
15300
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15301
+ * excludes it.
15302
+ *
15303
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15304
+ * twelve makes it false in exactly the way nobody notices until an incident.
15305
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15306
+ * still parses as "nothing known to be skipped" rather than failing the whole
15307
+ * alarm tab.
15308
+ */
15309
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15018
15310
  });
15019
15311
  var NcAlarmConfigSchema = object({
15020
15312
  /**
@@ -17846,9 +18138,16 @@ var CameraStatusSchema = object({
17846
18138
  audio: CameraAudioStatusSchema.nullable(),
17847
18139
  recording: CameraRecordingStatusSchema.nullable(),
17848
18140
  /**
17849
- * Per-camera function switches an OPERATOR has turned off
18141
+ * Per-camera functions an OPERATOR has turned off
17850
18142
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17851
18143
  *
18144
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18145
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18146
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18147
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18148
+ * The badge outlives the control panel: the panel was a convenience, this is
18149
+ * the difference between a camera being off and a camera being dead.
18150
+ *
17852
18151
  * This is the difference between DISABLED and BROKEN. A camera whose
17853
18152
  * `detection` block reports zero fps and whose `switchedOff` contains
17854
18153
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -18455,24 +18754,28 @@ var snapshotCapability = {
18455
18754
  *
18456
18755
  * `getSnapshotOverview` is cache-only by contract: it answers from whatever
18457
18756
  * the wrapper happens to hold and never captures. Under D93 the client
18458
- * versions its image URL on that answer, and an image REQUEST is what enrols
18459
- * a camera in the keep-warm loop. Both of those are satisfiable by the
18460
- * client's own image cache — `expo-image` is URL-keyed and never revalidates
18461
- * — so a URL painted in a previous session comes off disk with no network,
18462
- * no enrolment, and nothing warming. Measured on the live hub: reopening
18463
- * after two minutes idle painted 15 of 16 tiles at **168 s old** with zero
18464
- * HTTP requests, and the fleet only recovered because a later poll happened
18465
- * to observe a different identity.
18757
+ * versions its image URL on that answer, and an image REQUEST was the only
18758
+ * demand signal. Both of those are satisfiable by the client's own image
18759
+ * cache — `expo-image` is URL-keyed and never revalidates — so a URL painted
18760
+ * in a previous session comes off disk with no network, no demand, and no
18761
+ * capture. Measured on the live hub: reopening after two minutes idle
18762
+ * painted 15 of 16 tiles at **168 s old** with zero HTTP requests, and the
18763
+ * fleet only recovered because a later poll happened to observe a different
18764
+ * identity.
18466
18765
  *
18467
18766
  * ## The two properties that fix it
18468
18767
  *
18469
18768
  * **It is an RPC, so no client cache can answer it.** The demand signal
18470
- * always reaches the wrapper. This method therefore MAY create keep-warm
18471
- * subscriptions, where `getSnapshotOverview` must never (D93) — the
18472
- * distinction is not "one is newer" but that the overview poll is app-wide
18473
- * (a creating overview would warm every camera on the install) while this is
18474
- * called by a rendered surface naming the tiles it is actually painting, at
18475
- * the width it is painting them.
18769
+ * always reaches the wrapper. This method therefore CAPTURES, where
18770
+ * `getSnapshotOverview` must never (D93) — the distinction is not "one is
18771
+ * newer" but that the overview poll is app-wide (a capturing overview would
18772
+ * dial every camera on the install) while this is called by a rendered
18773
+ * surface naming the tiles it is actually painting, at the width it is
18774
+ * painting them.
18775
+ *
18776
+ * Since 2026-08-11 this is the ONLY thing that refreshes a snapshot: the
18777
+ * server-side keep-warm loop was removed (operator directive — on-demand,
18778
+ * always), so a camera nobody is looking at costs nothing at all.
18476
18779
  *
18477
18780
  * **It waits, briefly and boundedly, for the capture it triggered.** The
18478
18781
  * returned `capturedAt` is the frame the link will serve, not the frame the
@@ -24732,7 +25035,19 @@ var RecordingManifestSchema = object({
24732
25035
  * profiles/subtrees/locations on this node). */
24733
25036
  var RecordingDeviceUsageSchema = object({
24734
25037
  deviceId: number(),
24735
- usedBytes: number()
25038
+ usedBytes: number(),
25039
+ /**
25040
+ * Start of this camera's OLDEST indexed segment, across every profile and
25041
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25042
+ * only honest answer to "is retention actually holding?" per camera.
25043
+ *
25044
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25045
+ * predates this field omits it entirely, and a hub whose types carry the
25046
+ * field must keep validating that older provider's payload: the framework
25047
+ * (types) and the addon ship on different trains, and the addon is usually
25048
+ * the later of the two.
25049
+ */
25050
+ oldestMs: number().nullable().optional()
24736
25051
  });
24737
25052
  /** Recording storage usage + capacity for one storage location. */
24738
25053
  var RecordingLocationUsageSchema = object({
@@ -24760,6 +25075,57 @@ var RecordingStorageUsageSchema = object({
24760
25075
  locations: array(RecordingLocationUsageSchema)
24761
25076
  });
24762
25077
  /**
25078
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25079
+ *
25080
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25081
+ * is the operator asking for the EXISTING archive to be brought into line with
25082
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25083
+ * location, run FIFO behind the single-flight mover.
25084
+ *
25085
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25086
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25087
+ * (empty on the plan).
25088
+ */
25089
+ var RecordingRebalanceMoveSchema = object({
25090
+ deviceId: number(),
25091
+ profile: string(),
25092
+ fromLocationId: string(),
25093
+ toLocationId: string(),
25094
+ bytes: number(),
25095
+ files: number().int()
25096
+ });
25097
+ /** Why a pile that is out of place is staying there. Every refusal is
25098
+ * reported: a rebalance that silently drops a camera reads exactly like one
25099
+ * that had nothing to do. */
25100
+ var RecordingRebalanceSkipReasonSchema = _enum([
25101
+ "unassigned",
25102
+ "target-not-writable",
25103
+ "below-threshold",
25104
+ "no-headroom"
25105
+ ]);
25106
+ var RecordingRebalanceSkipSchema = object({
25107
+ deviceId: number(),
25108
+ profile: string(),
25109
+ fromLocationId: string(),
25110
+ /** The location the plan wants; null when the camera has no assignment. */
25111
+ toLocationId: string().nullable(),
25112
+ bytes: number(),
25113
+ reason: RecordingRebalanceSkipReasonSchema
25114
+ });
25115
+ var RecordingRebalancePlanSchema = object({
25116
+ moves: array(RecordingRebalanceMoveSchema),
25117
+ skipped: array(RecordingRebalanceSkipSchema),
25118
+ bytesToMove: number(),
25119
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25120
+ jobIds: array(string())
25121
+ });
25122
+ var RecordingRebalanceInputSchema = object({
25123
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25124
+ throttleMbps: number().min(1).max(1e3).optional(),
25125
+ /** Ignore piles smaller than this (default 1 GB). */
25126
+ minMoveGb: number().min(0).optional()
25127
+ });
25128
+ /**
24763
25129
  * Result of locating footage at a wall-clock instant for one device/profile.
24764
25130
  * `segment` carries the covering segment's window; `gap` reports the forward
24765
25131
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -24922,9 +25288,24 @@ method(object({
24922
25288
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24923
25289
  kind: "mutation",
24924
25290
  auth: "admin"
25291
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25292
+ kind: "mutation",
25293
+ auth: "admin"
25294
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25295
+ kind: "query",
25296
+ auth: "admin"
25297
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25298
+ kind: "mutation",
25299
+ auth: "admin"
25300
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25301
+ kind: "query",
25302
+ auth: "admin"
25303
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25304
+ kind: "mutation",
25305
+ auth: "admin"
24925
25306
  });
24926
25307
  /**
24927
- * `recordingExport` cap — render a footage time range into a single downloadable
25308
+ * `recording-export` cap — render a footage time range into a single downloadable
24928
25309
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
24929
25310
  * bounded lifetime with a durable history, auto-expiry, and optional
24930
25311
  * delete-after-download.
@@ -24939,10 +25320,53 @@ method(object({
24939
25320
  */
24940
25321
  /** Playback-speed multiplier for the render (1 = realtime). */
24941
25322
  var ExportSpeedSchema = number().min(.25).max(32);
25323
+ /**
25324
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25325
+ *
25326
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25327
+ * derives these bounds from things that happened at a TIME (a track's
25328
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25329
+ * every segment present for the range, with each recording GAP removed. The
25330
+ * two agree only on a window that recorded without one interruption, and only
25331
+ * the render side knows the segments, so the translation lives there
25332
+ * (`export-dense-map.ts`, addon-pipeline).
25333
+ *
25334
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25335
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25336
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25337
+ * the video was a uniform timelapse, and the log line reported the five ranges
25338
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25339
+ *
25340
+ * Relative and not absolute epoch, because an absolute epoch would make every
25341
+ * call site responsible for the same subtraction.
25342
+ */
25343
+ var ExportDenseRangeSchema = object({
25344
+ fromSec: number().nonnegative(),
25345
+ toSec: number().nonnegative()
25346
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25347
+ /**
25348
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25349
+ * listed ranges and at the base `everyMs` everywhere else.
25350
+ *
25351
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25352
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25353
+ */
25354
+ var ExportDenseSchema = object({
25355
+ everyMs: number().int().positive(),
25356
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25357
+ });
24942
25358
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
24943
25359
  var ExportTimelapseSchema = object({
24944
25360
  everyMs: number().int().positive(),
24945
- outputFps: number().int().min(1).max(60).optional()
25361
+ outputFps: number().int().min(1).max(60).optional(),
25362
+ /** Optional second, FASTER rate over the intervals that matter. */
25363
+ dense: ExportDenseSchema.optional()
25364
+ }).superRefine((v, ctx) => {
25365
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25366
+ code: ZodIssueCode.custom,
25367
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25368
+ path: ["dense", "everyMs"]
25369
+ });
24946
25370
  });
24947
25371
  /**
24948
25372
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -25000,6 +25424,19 @@ var ExportDownloadSchema = object({
25000
25424
  url: string(),
25001
25425
  endpoints: array(string())
25002
25426
  });
25427
+ /**
25428
+ * A finished export's bytes, inline.
25429
+ *
25430
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25431
+ * against, so nobody has to infer it from the base64 length.
25432
+ */
25433
+ var ExportBytesSchema = object({
25434
+ base64: string(),
25435
+ contentType: string(),
25436
+ /** Suggested filename, extension included. */
25437
+ name: string(),
25438
+ bytes: number().int().nonnegative()
25439
+ });
25003
25440
  method(object({
25004
25441
  deviceId: number(),
25005
25442
  profile: string(),
@@ -25024,6 +25461,9 @@ method(object({
25024
25461
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
25025
25462
  kind: "query",
25026
25463
  auth: "protected"
25464
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25465
+ kind: "query",
25466
+ auth: "protected"
25027
25467
  });
25028
25468
  /**
25029
25469
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -31714,6 +32154,12 @@ Object.freeze({
31714
32154
  addonId: null,
31715
32155
  access: "create"
31716
32156
  },
32157
+ "recording.cancelRelocateJob": {
32158
+ capName: "recording",
32159
+ capScope: "system",
32160
+ addonId: null,
32161
+ access: "create"
32162
+ },
31717
32163
  "recording.cancelStorageMigrationMove": {
31718
32164
  capName: "recording",
31719
32165
  capScope: "system",
@@ -31768,6 +32214,12 @@ Object.freeze({
31768
32214
  addonId: null,
31769
32215
  access: "view"
31770
32216
  },
32217
+ "recording.listRelocateJobs": {
32218
+ capName: "recording",
32219
+ capScope: "system",
32220
+ addonId: null,
32221
+ access: "view"
32222
+ },
31771
32223
  "recording.locateSegment": {
31772
32224
  capName: "recording",
31773
32225
  capScope: "system",
@@ -31780,6 +32232,12 @@ Object.freeze({
31780
32232
  addonId: null,
31781
32233
  access: "create"
31782
32234
  },
32235
+ "recording.planStorageRebalance": {
32236
+ capName: "recording",
32237
+ capScope: "system",
32238
+ addonId: null,
32239
+ access: "view"
32240
+ },
31783
32241
  "recording.pruneFootage": {
31784
32242
  capName: "recording",
31785
32243
  capScope: "system",
@@ -31804,6 +32262,12 @@ Object.freeze({
31804
32262
  addonId: null,
31805
32263
  access: "create"
31806
32264
  },
32265
+ "recording.relocateFootage": {
32266
+ capName: "recording",
32267
+ capScope: "system",
32268
+ addonId: null,
32269
+ access: "create"
32270
+ },
31807
32271
  "recording.renderClip": {
31808
32272
  capName: "recording",
31809
32273
  capScope: "system",
@@ -31840,38 +32304,50 @@ Object.freeze({
31840
32304
  addonId: null,
31841
32305
  access: "create"
31842
32306
  },
32307
+ "recording.startStorageRebalance": {
32308
+ capName: "recording",
32309
+ capScope: "system",
32310
+ addonId: null,
32311
+ access: "create"
32312
+ },
31843
32313
  "recordingExport.cancelExport": {
31844
- capName: "recordingExport",
32314
+ capName: "recording-export",
31845
32315
  capScope: "system",
31846
32316
  addonId: null,
31847
32317
  access: "create"
31848
32318
  },
31849
32319
  "recordingExport.createExport": {
31850
- capName: "recordingExport",
32320
+ capName: "recording-export",
31851
32321
  capScope: "system",
31852
32322
  addonId: null,
31853
32323
  access: "create"
31854
32324
  },
31855
32325
  "recordingExport.deleteExport": {
31856
- capName: "recordingExport",
32326
+ capName: "recording-export",
31857
32327
  capScope: "system",
31858
32328
  addonId: null,
31859
32329
  access: "delete"
31860
32330
  },
31861
32331
  "recordingExport.getDownloadUrl": {
31862
- capName: "recordingExport",
32332
+ capName: "recording-export",
31863
32333
  capScope: "system",
31864
32334
  addonId: null,
31865
32335
  access: "view"
31866
32336
  },
31867
32337
  "recordingExport.getExport": {
31868
- capName: "recordingExport",
32338
+ capName: "recording-export",
31869
32339
  capScope: "system",
31870
32340
  addonId: null,
31871
32341
  access: "view"
31872
32342
  },
31873
32343
  "recordingExport.listExports": {
31874
- capName: "recordingExport",
32344
+ capName: "recording-export",
32345
+ capScope: "system",
32346
+ addonId: null,
32347
+ access: "view"
32348
+ },
32349
+ "recordingExport.readExportBytes": {
32350
+ capName: "recording-export",
31875
32351
  capScope: "system",
31876
32352
  addonId: null,
31877
32353
  access: "view"
@@ -33248,6 +33724,104 @@ var FramerateField = number().int().min(1).max(60);
33248
33724
  var TargetsField = array(NcRuleTargetSchema).min(1);
33249
33725
  var PriorityField = number().int().min(1).max(5);
33250
33726
  /**
33727
+ * Explicit override of the DENSE sampling cadence, seconds.
33728
+ *
33729
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
33730
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
33731
+ * made that same base 3 s and rendered a person pass as two frames.)
33732
+ *
33733
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
33734
+ * `denseCadenceSec` and played at `framerate` occupies
33735
+ *
33736
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
33737
+ *
33738
+ * 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.
33739
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
33740
+ * and therefore the length of a quiet night, does not move.
33741
+ *
33742
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
33743
+ * the recording has them returns the same frames, requested twice. Must be
33744
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
33745
+ * a uniform video the operator believes is two-rate — and upsert refuses it
33746
+ * rather than letting the export cap reject the render hours after the window.
33747
+ */
33748
+ var DenseCadenceSecField = number().min(.1).max(3600);
33749
+ /**
33750
+ * Minimum seconds of OUTPUT video each detection range must occupy.
33751
+ *
33752
+ * The operator-facing form of the arithmetic above: instead of solving for a
33753
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
33754
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
33755
+ * that range every ~583 ms.
33756
+ *
33757
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
33758
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
33759
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
33760
+ * ranges are sampled denser than they need. Per-range cadences require a cap
33761
+ * schema change and are the tracked follow-up.
33762
+ *
33763
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
33764
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
33765
+ * by real footage, never met by duplicating frames into motion that never
33766
+ * happened.
33767
+ */
33768
+ var MinDwellSecField = number().min(0).max(60);
33769
+ /**
33770
+ * Caption burned into the notification's preview frame.
33771
+ *
33772
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
33773
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
33774
+ * templating dialect for one field would be a second thing to explain.
33775
+ *
33776
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
33777
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
33778
+ * the reason this is not `.min(1)`.
33779
+ */
33780
+ var PreviewTextField = string().max(200);
33781
+ /**
33782
+ * Whether the notification's preview is a STILL or a short animation.
33783
+ *
33784
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
33785
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
33786
+ * night reads better as three seconds of motion than as one frame of it. Both
33787
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
33788
+ * simply applies it to a dozen frames sampled across the render and assembles
33789
+ * them.
33790
+ *
33791
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
33792
+ * seeks and a palette pass, and no rule that never asked for one should start
33793
+ * paying that on the deploy that shipped it.
33794
+ *
33795
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
33796
+ */
33797
+ var PreviewModeField = _enum(["image", "gif"]);
33798
+ /**
33799
+ * Which detection classes the notification reports counts for.
33800
+ *
33801
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
33802
+ * plan — no second query — aggregated per class. Absent or empty means "every
33803
+ * class the window actually contained", which is what an operator who never
33804
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
33805
+ * counts cars all night).
33806
+ *
33807
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
33808
+ * …). An unknown name simply never matches and reports nothing — it is not an
33809
+ * error, because a rule may legitimately name a class this camera's model does
33810
+ * not emit.
33811
+ *
33812
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
33813
+ * - `{{detections}}` — total over the reported classes
33814
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
33815
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
33816
+ * one per class, `count_` + the class name
33817
+ *
33818
+ * With NO custom body template the summary is appended to the derived body, and
33819
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
33820
+ * reads. With a custom template the operator owns every word — nothing is
33821
+ * appended, so `{{detectionSummary}}` is how he asks for it.
33822
+ */
33823
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
33824
+ /**
33251
33825
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33252
33826
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33253
33827
  * here (see the ownership note above).
@@ -33267,9 +33841,30 @@ var TimelapseRuleInputSchema = object({
33267
33841
  cadenceSec: CadenceSecField.default(15),
33268
33842
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33269
33843
  framerate: FramerateField.default(10),
33844
+ /**
33845
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
33846
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
33847
+ * field gets.
33848
+ */
33849
+ denseCadenceSec: DenseCadenceSecField.optional(),
33850
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
33851
+ minDwellSec: MinDwellSecField.optional(),
33270
33852
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33271
33853
  targets: TargetsField,
33272
33854
  template: TimelapseTemplateSchema.optional(),
33855
+ /**
33856
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
33857
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
33858
+ *
33859
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
33860
+ * the notification's title/body, and clearing it (`template: null`) must not
33861
+ * silently clear the caption too.
33862
+ */
33863
+ previewText: PreviewTextField.optional(),
33864
+ /** Still or animation — see {@link PreviewModeField}. */
33865
+ previewMode: PreviewModeField.default("image"),
33866
+ /** Classes the notification counts — see {@link ReportClassesField}. */
33867
+ reportClasses: ReportClassesField.optional(),
33273
33868
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33274
33869
  priority: PriorityField.default(3)
33275
33870
  });
@@ -33280,8 +33875,13 @@ object({
33280
33875
  schedule: NcScheduleSchema.optional(),
33281
33876
  cadenceSec: CadenceSecField.optional(),
33282
33877
  framerate: FramerateField.optional(),
33878
+ denseCadenceSec: DenseCadenceSecField.optional(),
33879
+ minDwellSec: MinDwellSecField.optional(),
33283
33880
  targets: TargetsField.optional(),
33284
33881
  template: TimelapseTemplateSchema.nullable().optional(),
33882
+ previewText: PreviewTextField.optional(),
33883
+ previewMode: PreviewModeField.optional(),
33884
+ reportClasses: ReportClassesField.optional(),
33285
33885
  priority: PriorityField.optional()
33286
33886
  });
33287
33887
  TimelapseRuleInputSchema.extend({
@@ -33293,10 +33893,28 @@ TimelapseRuleInputSchema.extend({
33293
33893
  */
33294
33894
  ownerUserId: string().optional(),
33295
33895
  /**
33296
- * Epoch-ms of the last successful generation the 1-hour re-generation
33297
- * guard's durable state (predecessor parity). Absent = never generated.
33896
+ * Epoch-ms of the NEWEST successful generation across every camera of this
33897
+ * rule. What a UI shows, and the compatibility floor for
33898
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33298
33899
  */
33299
33900
  lastGeneratedAt: number().optional(),
33901
+ /**
33902
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
33903
+ * re-generation guard's real durable state.
33904
+ *
33905
+ * One rule covers several cameras and each renders its own video, so a rule
33906
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
33907
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
33908
+ * already done — and B's night is gone for good, because the window will not
33909
+ * come back.
33910
+ *
33911
+ * ADDITIVE, so the migration is free: a row written before this field simply
33912
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
33913
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
33914
+ * "never generated" would re-render and re-notify every camera of every rule
33915
+ * once, on the deploy that shipped the map.
33916
+ */
33917
+ generatedByDevice: record(string(), number()).optional(),
33300
33918
  /** userId of the caller who created the rule (server-stamped). */
33301
33919
  createdBy: string(),
33302
33920
  createdAt: number(),
@@ -33347,25 +33965,32 @@ object({
33347
33965
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33348
33966
  object({
33349
33967
  /**
33350
- * How long a retained native frame is served before it counts as a miss.
33968
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
33969
+ * detection result.
33351
33970
  *
33352
- * Must cover the FULL late-crop horizon: detection inference + the
33353
- * cross-process inference-result hop to hub post-analysis + tracking + the
33354
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33355
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33356
- * RAM per busy camera grows linearly with no measured hit-rate gain.
33971
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
33972
+ * a time window was never related to the event the pixels were waiting for.
33973
+ * A held frame now lives from delivery until the runner has its `FrameResult`
33974
+ * at which moment the runner cuts the subject tiles it actually wanted and
33975
+ * releases the frame. The bound exists only so a runner that stops answering
33976
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
33977
+ *
33978
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
33979
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
33980
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
33981
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
33982
+ * `holdOverflow` on the metrics line is what says you need it.
33357
33983
  */
33358
- ttlMs: number().int().min(250).max(1e4),
33984
+ holdFrames: number().int().min(1).max(64),
33359
33985
  /**
33360
33986
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33361
33987
  *
33362
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33363
- * which one is actually binding before reasoning from that. At the shipped
33364
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33365
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33366
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33367
- * change that admits fewer frames buys retention WINDOW at constant RAM
33368
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
33988
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
33989
+ * is what decides how much is held, and the ceiling is the number above which
33990
+ * something is wrong. Before that it was the effective cap at 1024 MB with
33991
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
33992
+ * with the TTL expiring nothing, which is exactly the confusion the hold
33993
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33369
33994
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33370
33995
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33371
33996
  * to replace).
@@ -33391,22 +34016,45 @@ object({
33391
34016
  * there is the signal that some caller names frames outside the inference set
33392
34017
  * and that this must go back to `all`.
33393
34018
  */
33394
- admission: NativeLeaseAdmissionSchema
34019
+ admission: NativeLeaseAdmissionSchema,
34020
+ /**
34021
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
34022
+ * compressed native crops the worker cuts at the moment a frame's detection
34023
+ * result arrives, and keeps long after the frame itself is freed.
34024
+ *
34025
+ * This is the knob that replaced the old retention window, and it buys about
34026
+ * three orders of magnitude more of it: a tile is one subject at native
34027
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
34028
+ * the frame it was cut from. A frame on which nothing was detected costs
34029
+ * nothing at all, which is the real change — the old lease paid per FRAME and
34030
+ * was interrogated per SUBJECT.
34031
+ *
34032
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
34033
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
34034
+ * reproduce that.
34035
+ */
34036
+ tileBudgetMb: number().int().min(0).max(1024)
33395
34037
  });
33396
34038
  /**
33397
- * The values in force when the operator has set nothing — byte-for-byte the
33398
- * constants the decode worker shipped with as env-var defaults, so making these
33399
- * settings changed no behaviour on the day it landed.
34039
+ * The values in force when the operator has set nothing.
34040
+ *
34041
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
34042
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
34043
+ * in the same change that redefines it would make a regression and a retune
34044
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
34045
+ * live traffic.
33400
34046
  */
33401
34047
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33402
- ttlMs: 1200,
34048
+ holdFrames: 8,
33403
34049
  budgetMb: 1024,
33404
34050
  activityMs: 15e3,
34051
+ tileBudgetMb: 64,
33405
34052
  admission: "inferred"
33406
34053
  };
33407
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
34054
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33408
34055
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33409
34056
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34057
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33410
34058
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33411
34059
  //#endregion
33412
34060
  //#region ../../node_modules/@apocaliss92/wyze-bridge-js/dist/index.js