@camstack/addon-provider-amcrest 0.2.14 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +704 -56
  2. package/dist/addon.mjs +704 -56
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -7199,8 +7199,31 @@ var AdoptionJobSchema = object({
7199
7199
  error: string().nullable()
7200
7200
  });
7201
7201
  /**
7202
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7203
- * pipeline functions an operator thinks in terms of.
7202
+ * Per-camera FUNCTION SWITCHES.
7203
+ *
7204
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7205
+ *
7206
+ * This file shipped as "the one coherent on/off surface over the pipeline
7207
+ * functions an operator thinks in terms of". The operator's verdict on
7208
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7209
+ * every function already had a settings page of its own, and a second place to
7210
+ * turn it off is a second place to look. Each switch is going back to its own
7211
+ * component's original options — detection to the detection-pipeline wrapper
7212
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7213
+ * (which was always first-class; the switch was a veneer over
7214
+ * `recording.setDeviceConfig`), notifications to a notification-center
7215
+ * per-device setting, the two camera planes to their own components.
7216
+ *
7217
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7218
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7219
+ * straight from the authorities with no group in the middle. That rule was
7220
+ * never about a control panel.
7221
+ *
7222
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7223
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7224
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7225
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7226
+ * stop; nothing new may be built on it.
7204
7227
  *
7205
7228
  * ## This file adds no state
7206
7229
  *
@@ -7551,7 +7574,15 @@ var RecordingConfigSchema = object({
7551
7574
  * Each completed/failed run also lands one durable ops-log row on its owning
7552
7575
  * addon surface.
7553
7576
  */
7577
+ /**
7578
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7579
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7580
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7581
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7582
+ * runs at all.
7583
+ */
7554
7584
  var RelocateJobStateSchema = _enum([
7585
+ "queued",
7555
7586
  "running",
7556
7587
  "done",
7557
7588
  "failed",
@@ -7586,6 +7617,15 @@ var RelocateFootageInputSchema = object({
7586
7617
  /** Limits relocation to the logical profile class. Omit only for the
7587
7618
  * pre-orchestration compatibility path. */
7588
7619
  footageClass: RelocateFootageClassSchema.optional(),
7620
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7621
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7622
+ * unit is a (camera, profile) pile, not a disk. */
7623
+ deviceId: number().int().optional(),
7624
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7625
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7626
+ * placement plan assigns those two independently, so a rebalance that could
7627
+ * only say "recordings" would move footage the plan never asked to move. */
7628
+ profiles: array(string()).optional(),
7589
7629
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7590
7630
  * never allowed to starve live writers. */
7591
7631
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7721,6 +7761,21 @@ var StorageLocationSchema = object({
7721
7761
  nodeId: string().optional(),
7722
7762
  isDefault: boolean().default(false),
7723
7763
  isSystem: boolean().default(false),
7764
+ /**
7765
+ * Operator opt-in: whether consumers that BALANCE across several locations
7766
+ * of a type may write here. Recordings reads it today; event media and
7767
+ * backups are the next consumers, which is why the flag lives on the
7768
+ * location rather than in any one addon's store — nothing has to be
7769
+ * extended to add the next consumer.
7770
+ *
7771
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7772
+ * flag existed reads back with no flag and keeps working exactly as before;
7773
+ * that is the whole compat story, and it is why no migration ships with it.
7774
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7775
+ * disk must not silently start writing to it); the default of a type is
7776
+ * always stamped `true`.
7777
+ */
7778
+ enabled: boolean().optional(),
7724
7779
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7725
7780
  * for node-local locations it can reach) — never persisted, absent when the
7726
7781
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12273,7 +12328,8 @@ method(object({
12273
12328
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12274
12329
  /**
12275
12330
  * filesystem-browse — per-node capability for browsing the node's local
12276
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12331
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12332
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12277
12333
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12278
12334
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12279
12335
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14114,6 +14170,13 @@ var MaskGridDimsSchema = object({
14114
14170
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14115
14171
  * this one field keeps the schema additive — a rule still declares exactly
14116
14172
  * one trigger.
14173
+ *
14174
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14175
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14176
+ * mirror.ts` fails the build on a member the app cannot render) and every
14177
+ * member costs a release train. A sustained-sound rule is therefore an
14178
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14179
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14117
14180
  */
14118
14181
  var NcDeliverySchema = _enum([
14119
14182
  "immediate",
@@ -14128,15 +14191,32 @@ var NcDeliverySchema = _enum([
14128
14191
  * depend on a provider's raw event name or payload shape.
14129
14192
  */
14130
14193
  var NcSystemEventKindSchema = _enum([
14131
- "camera-online",
14132
- "camera-offline",
14194
+ "device-online",
14195
+ "device-offline",
14196
+ "device-disabled",
14197
+ "device-enabled",
14133
14198
  "stream-online",
14134
14199
  "stream-offline",
14135
14200
  "node-online",
14136
14201
  "node-offline",
14137
14202
  "addon-update-available",
14138
- "server-update-available"
14203
+ "server-update-available",
14204
+ "alarm-triggered",
14205
+ "alarm-armed",
14206
+ "alarm-disarmed",
14207
+ "camera-online",
14208
+ "camera-offline",
14209
+ "camera-disabled",
14210
+ "camera-enabled"
14211
+ ]);
14212
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14213
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14214
+ "camera-online",
14215
+ "camera-offline",
14216
+ "camera-disabled",
14217
+ "camera-enabled"
14139
14218
  ]);
14219
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14140
14220
  /**
14141
14221
  * One coherent system-event condition. `kinds` is the required opt-in safety
14142
14222
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14145,6 +14225,18 @@ var NcSystemEventKindSchema = _enum([
14145
14225
  var NcSystemEventConditionSchema = object({
14146
14226
  kinds: array(NcSystemEventKindSchema).min(1),
14147
14227
  deviceIds: array(number().int()).min(1).optional(),
14228
+ /**
14229
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14230
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14231
+ * is what a liveness rule means when nobody said otherwise.
14232
+ *
14233
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14234
+ * one reason: the intake cannot know which devices this household cares
14235
+ * about, and a producer-side filter is one no operator can change. Fails
14236
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14237
+ * does not carry) matches no `deviceTypes` list.
14238
+ */
14239
+ deviceTypes: array(string().min(1)).min(1).optional(),
14148
14240
  nodeIds: array(string().min(1)).min(1).optional(),
14149
14241
  packageNames: array(string().min(1)).min(1).optional()
14150
14242
  });
@@ -14195,6 +14287,47 @@ var NcOccupancyConditionSchema = object({
14195
14287
  sustainSeconds: number().int().min(0).max(3600).default(15)
14196
14288
  });
14197
14289
  /**
14290
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14291
+ *
14292
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14293
+ * reference notifier uses, so an operator moving between them re-uses what
14294
+ * they already know): a rule matches when, over a sampling window of
14295
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14296
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14297
+ *
14298
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14299
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14300
+ * - `labels` — the classifier put at least one of these labels on it.
14301
+ *
14302
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14303
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14304
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14305
+ * is given** — a window in which every sample is trivially a hit would fire on
14306
+ * silence, so the engine refuses such a condition rather than notifying on
14307
+ * nothing (the schema cannot express "at least one of" without becoming a
14308
+ * ZodEffects the cap path would have to special-case).
14309
+ *
14310
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14311
+ * must be FULL before it can match — a window that has been open for two
14312
+ * seconds of its ten is 100% of nothing, and firing on it would make
14313
+ * `samplingSeconds` decorative.
14314
+ *
14315
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14316
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14317
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14318
+ * an operator who typed `dog` mean the same thing.
14319
+ */
14320
+ var NcAudioConditionSchema = object({
14321
+ /** Audio macro labels; absent = any sound (level-only rule). */
14322
+ labels: array(string().min(1)).min(1).optional(),
14323
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14324
+ dbThreshold: number().min(-96).max(0).optional(),
14325
+ /** Percentage of the window's samples that must be hits (1–100). */
14326
+ hitPercent: number().int().min(1).max(100).default(60),
14327
+ /** Length of the sampling window in seconds. */
14328
+ samplingSeconds: number().int().min(1).max(300).default(10)
14329
+ });
14330
+ /**
14198
14331
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14199
14332
  *
14200
14333
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14467,7 +14600,33 @@ var NcConditionsSchema = object({
14467
14600
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14468
14601
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14469
14602
  */
14470
- occupancy: NcOccupancyConditionSchema.optional()
14603
+ occupancy: NcOccupancyConditionSchema.optional(),
14604
+ /**
14605
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14606
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14607
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14608
+ * a window that is not full yet, neither filter given). See
14609
+ * {@link NcAudioCondition}.
14610
+ *
14611
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14612
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14613
+ * a detection, a track or a device event (the same fail-closed pairing
14614
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14615
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14616
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14617
+ * classified sample) stays exactly as it was for rules that already use it.
14618
+ *
14619
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14620
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14621
+ * (`camstack/src/data/notification-center.ts`, guarded by
14622
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14623
+ * condition fields it does not know when a rule is saved from the phone.
14624
+ * Publishing an editor for a condition the app cannot round-trip is how an
14625
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14626
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14627
+ * does an audio rule become authorable.
14628
+ */
14629
+ audio: NcAudioConditionSchema.optional()
14471
14630
  });
14472
14631
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14473
14632
  var NcRuleTargetSchema = object({
@@ -14581,6 +14740,73 @@ var NcThrottleSchema = object({
14581
14740
  */
14582
14741
  granularity: NcThrottleGranularitySchema.optional()
14583
14742
  });
14743
+ /**
14744
+ * How long the confirm gate may hold ONE notification, and how big the picture
14745
+ * it judges may be.
14746
+ *
14747
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14748
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14749
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14750
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14751
+ * tokens for pixels the model pools away.
14752
+ */
14753
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14754
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14755
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14756
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14757
+ var NcConfirmExpectSchema = object({
14758
+ op: _enum([
14759
+ ">=",
14760
+ ">",
14761
+ "<=",
14762
+ "<",
14763
+ "=="
14764
+ ]),
14765
+ count: number().int().min(0).max(1e3)
14766
+ });
14767
+ /**
14768
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14769
+ * to ship and says whether it agrees with the rule.
14770
+ *
14771
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14772
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14773
+ * on the operator's phone is not a verdict about this notification.
14774
+ *
14775
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14776
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14777
+ * the default and every fail-open is COUNTED, because a gate that always fails
14778
+ * open looks in the log exactly like a gate that works.
14779
+ *
14780
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14781
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14782
+ * production failures in one day), so the gate reads absent as the constant
14783
+ * above rather than trusting a parse it may never have seen.
14784
+ */
14785
+ var NcConfirmSchema = object({
14786
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14787
+ * same thing, and both mean "deliver exactly as before". */
14788
+ enabled: boolean().default(false),
14789
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14790
+ profileId: string().optional(),
14791
+ /**
14792
+ * The operator's question, in his own words. Absent = a question derived
14793
+ * from the rule (its class and its expectation).
14794
+ *
14795
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14796
+ * banners, signage and plates as instructions if you let them reach the
14797
+ * prompt — proven live — so the authoritative contract stays in the system
14798
+ * turn and only rule-authored words land here.
14799
+ */
14800
+ prompt: string().max(1e3).optional(),
14801
+ /** Fire only when the model's count satisfies this. Absent = the model's
14802
+ * own boolean verdict decides. */
14803
+ expect: NcConfirmExpectSchema.optional(),
14804
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14805
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14806
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14807
+ /** Longest edge the judged image is downscaled to before it is sent. */
14808
+ maxImagePx: number().int().min(64).max(2048).default(448)
14809
+ });
14584
14810
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14585
14811
  var NcRuleInputSchema = object({
14586
14812
  name: string().min(1).max(200),
@@ -14641,7 +14867,13 @@ var NcRuleInputSchema = object({
14641
14867
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14642
14868
  * shape as every other actuation.
14643
14869
  */
14644
- actions: NcRuleActionsSchema.optional()
14870
+ actions: NcRuleActionsSchema.optional(),
14871
+ /**
14872
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14873
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14874
+ * did, and absent is the only way to say that without a migration.
14875
+ */
14876
+ confirm: NcConfirmSchema.optional()
14645
14877
  });
14646
14878
  /**
14647
14879
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14652,7 +14884,37 @@ var NcRuleInputSchema = object({
14652
14884
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14653
14885
  * `updateRule` patch.
14654
14886
  */
14655
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14887
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14888
+ disabledTargetIds: array(string()).optional(),
14889
+ /**
14890
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14891
+ *
14892
+ * It makes the key optional to SUPPLY; the parse still materialises the
14893
+ * default when the key is absent. And `NcRuleStore.update` merges with
14894
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14895
+ * one — which made every partial edit destructive:
14896
+ *
14897
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14898
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14899
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14900
+ *
14901
+ * A rule scoped to one camera and one zone silently became a rule that
14902
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14903
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14904
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14905
+ * within a minute of a two-field patch.
14906
+ *
14907
+ * So every defaulted field is re-declared here WITHOUT its default. The
14908
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14909
+ * conditions remains a real instruction ("clear them") — and only the
14910
+ * absent key is now genuinely absent.
14911
+ */
14912
+ enabled: boolean().optional(),
14913
+ conditions: NcConditionsSchema.optional(),
14914
+ media: NcMediaPolicySchema.optional(),
14915
+ throttle: NcThrottleSchema.optional(),
14916
+ priority: number().int().min(1).max(5).optional()
14917
+ });
14656
14918
  /** A persisted rule. */
14657
14919
  var NcRuleSchema = NcRuleInputSchema.extend({
14658
14920
  id: string(),
@@ -14953,6 +15215,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14953
15215
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14954
15216
  * copy would lie the first time a rule is disabled.
14955
15217
  */
15218
+ /**
15219
+ * Why a device a mode NAMES is nonetheless not armed by it.
15220
+ *
15221
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15222
+ * per-camera notification switch the Notification Center already owns,
15223
+ * `detection-off` is the device's own detection binding being inactive, and
15224
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15225
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15226
+ * with the switches the operator actually used.
15227
+ */
15228
+ var NcAlarmSkipReasonSchema = _enum([
15229
+ "muted",
15230
+ "detection-off",
15231
+ "offline"
15232
+ ]);
15233
+ var NcAlarmSkippedDeviceSchema = object({
15234
+ deviceId: number().int(),
15235
+ reason: NcAlarmSkipReasonSchema
15236
+ });
14956
15237
  var NcAlarmModeCoverageSchema = object({
14957
15238
  mode: AlarmArmModeSchema,
14958
15239
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14960,7 +15241,18 @@ var NcAlarmModeCoverageSchema = object({
14960
15241
  /** At least one covering rule has no device scope, so the mode covers all. */
14961
15242
  allDevices: boolean(),
14962
15243
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14963
- deviceIds: array(number().int())
15244
+ deviceIds: array(number().int()),
15245
+ /**
15246
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15247
+ * excludes it.
15248
+ *
15249
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15250
+ * twelve makes it false in exactly the way nobody notices until an incident.
15251
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15252
+ * still parses as "nothing known to be skipped" rather than failing the whole
15253
+ * alarm tab.
15254
+ */
15255
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14964
15256
  });
14965
15257
  var NcAlarmConfigSchema = object({
14966
15258
  /**
@@ -17792,9 +18084,16 @@ var CameraStatusSchema = object({
17792
18084
  audio: CameraAudioStatusSchema.nullable(),
17793
18085
  recording: CameraRecordingStatusSchema.nullable(),
17794
18086
  /**
17795
- * Per-camera function switches an OPERATOR has turned off
18087
+ * Per-camera functions an OPERATOR has turned off
17796
18088
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17797
18089
  *
18090
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18091
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18092
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18093
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18094
+ * The badge outlives the control panel: the panel was a convenience, this is
18095
+ * the difference between a camera being off and a camera being dead.
18096
+ *
17798
18097
  * This is the difference between DISABLED and BROKEN. A camera whose
17799
18098
  * `detection` block reports zero fps and whose `switchedOff` contains
17800
18099
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -18401,24 +18700,28 @@ var snapshotCapability = {
18401
18700
  *
18402
18701
  * `getSnapshotOverview` is cache-only by contract: it answers from whatever
18403
18702
  * the wrapper happens to hold and never captures. Under D93 the client
18404
- * versions its image URL on that answer, and an image REQUEST is what enrols
18405
- * a camera in the keep-warm loop. Both of those are satisfiable by the
18406
- * client's own image cache — `expo-image` is URL-keyed and never revalidates
18407
- * — so a URL painted in a previous session comes off disk with no network,
18408
- * no enrolment, and nothing warming. Measured on the live hub: reopening
18409
- * after two minutes idle painted 15 of 16 tiles at **168 s old** with zero
18410
- * HTTP requests, and the fleet only recovered because a later poll happened
18411
- * to observe a different identity.
18703
+ * versions its image URL on that answer, and an image REQUEST was the only
18704
+ * demand signal. Both of those are satisfiable by the client's own image
18705
+ * cache — `expo-image` is URL-keyed and never revalidates — so a URL painted
18706
+ * in a previous session comes off disk with no network, no demand, and no
18707
+ * capture. Measured on the live hub: reopening after two minutes idle
18708
+ * painted 15 of 16 tiles at **168 s old** with zero HTTP requests, and the
18709
+ * fleet only recovered because a later poll happened to observe a different
18710
+ * identity.
18412
18711
  *
18413
18712
  * ## The two properties that fix it
18414
18713
  *
18415
18714
  * **It is an RPC, so no client cache can answer it.** The demand signal
18416
- * always reaches the wrapper. This method therefore MAY create keep-warm
18417
- * subscriptions, where `getSnapshotOverview` must never (D93) — the
18418
- * distinction is not "one is newer" but that the overview poll is app-wide
18419
- * (a creating overview would warm every camera on the install) while this is
18420
- * called by a rendered surface naming the tiles it is actually painting, at
18421
- * the width it is painting them.
18715
+ * always reaches the wrapper. This method therefore CAPTURES, where
18716
+ * `getSnapshotOverview` must never (D93) — the distinction is not "one is
18717
+ * newer" but that the overview poll is app-wide (a capturing overview would
18718
+ * dial every camera on the install) while this is called by a rendered
18719
+ * surface naming the tiles it is actually painting, at the width it is
18720
+ * painting them.
18721
+ *
18722
+ * Since 2026-08-11 this is the ONLY thing that refreshes a snapshot: the
18723
+ * server-side keep-warm loop was removed (operator directive — on-demand,
18724
+ * always), so a camera nobody is looking at costs nothing at all.
18422
18725
  *
18423
18726
  * **It waits, briefly and boundedly, for the capture it triggered.** The
18424
18727
  * returned `capturedAt` is the frame the link will serve, not the frame the
@@ -24715,7 +25018,19 @@ var RecordingManifestSchema = object({
24715
25018
  * profiles/subtrees/locations on this node). */
24716
25019
  var RecordingDeviceUsageSchema = object({
24717
25020
  deviceId: number(),
24718
- usedBytes: number()
25021
+ usedBytes: number(),
25022
+ /**
25023
+ * Start of this camera's OLDEST indexed segment, across every profile and
25024
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25025
+ * only honest answer to "is retention actually holding?" per camera.
25026
+ *
25027
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25028
+ * predates this field omits it entirely, and a hub whose types carry the
25029
+ * field must keep validating that older provider's payload: the framework
25030
+ * (types) and the addon ship on different trains, and the addon is usually
25031
+ * the later of the two.
25032
+ */
25033
+ oldestMs: number().nullable().optional()
24719
25034
  });
24720
25035
  /** Recording storage usage + capacity for one storage location. */
24721
25036
  var RecordingLocationUsageSchema = object({
@@ -24743,6 +25058,57 @@ var RecordingStorageUsageSchema = object({
24743
25058
  locations: array(RecordingLocationUsageSchema)
24744
25059
  });
24745
25060
  /**
25061
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25062
+ *
25063
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25064
+ * is the operator asking for the EXISTING archive to be brought into line with
25065
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25066
+ * location, run FIFO behind the single-flight mover.
25067
+ *
25068
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25069
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25070
+ * (empty on the plan).
25071
+ */
25072
+ var RecordingRebalanceMoveSchema = object({
25073
+ deviceId: number(),
25074
+ profile: string(),
25075
+ fromLocationId: string(),
25076
+ toLocationId: string(),
25077
+ bytes: number(),
25078
+ files: number().int()
25079
+ });
25080
+ /** Why a pile that is out of place is staying there. Every refusal is
25081
+ * reported: a rebalance that silently drops a camera reads exactly like one
25082
+ * that had nothing to do. */
25083
+ var RecordingRebalanceSkipReasonSchema = _enum([
25084
+ "unassigned",
25085
+ "target-not-writable",
25086
+ "below-threshold",
25087
+ "no-headroom"
25088
+ ]);
25089
+ var RecordingRebalanceSkipSchema = object({
25090
+ deviceId: number(),
25091
+ profile: string(),
25092
+ fromLocationId: string(),
25093
+ /** The location the plan wants; null when the camera has no assignment. */
25094
+ toLocationId: string().nullable(),
25095
+ bytes: number(),
25096
+ reason: RecordingRebalanceSkipReasonSchema
25097
+ });
25098
+ var RecordingRebalancePlanSchema = object({
25099
+ moves: array(RecordingRebalanceMoveSchema),
25100
+ skipped: array(RecordingRebalanceSkipSchema),
25101
+ bytesToMove: number(),
25102
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25103
+ jobIds: array(string())
25104
+ });
25105
+ var RecordingRebalanceInputSchema = object({
25106
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25107
+ throttleMbps: number().min(1).max(1e3).optional(),
25108
+ /** Ignore piles smaller than this (default 1 GB). */
25109
+ minMoveGb: number().min(0).optional()
25110
+ });
25111
+ /**
24746
25112
  * Result of locating footage at a wall-clock instant for one device/profile.
24747
25113
  * `segment` carries the covering segment's window; `gap` reports the forward
24748
25114
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -24905,9 +25271,24 @@ method(object({
24905
25271
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24906
25272
  kind: "mutation",
24907
25273
  auth: "admin"
25274
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25275
+ kind: "mutation",
25276
+ auth: "admin"
25277
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25278
+ kind: "query",
25279
+ auth: "admin"
25280
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25281
+ kind: "mutation",
25282
+ auth: "admin"
25283
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25284
+ kind: "query",
25285
+ auth: "admin"
25286
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25287
+ kind: "mutation",
25288
+ auth: "admin"
24908
25289
  });
24909
25290
  /**
24910
- * `recordingExport` cap — render a footage time range into a single downloadable
25291
+ * `recording-export` cap — render a footage time range into a single downloadable
24911
25292
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
24912
25293
  * bounded lifetime with a durable history, auto-expiry, and optional
24913
25294
  * delete-after-download.
@@ -24922,10 +25303,53 @@ method(object({
24922
25303
  */
24923
25304
  /** Playback-speed multiplier for the render (1 = realtime). */
24924
25305
  var ExportSpeedSchema = number().min(.25).max(32);
25306
+ /**
25307
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25308
+ *
25309
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25310
+ * derives these bounds from things that happened at a TIME (a track's
25311
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25312
+ * every segment present for the range, with each recording GAP removed. The
25313
+ * two agree only on a window that recorded without one interruption, and only
25314
+ * the render side knows the segments, so the translation lives there
25315
+ * (`export-dense-map.ts`, addon-pipeline).
25316
+ *
25317
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25318
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25319
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25320
+ * the video was a uniform timelapse, and the log line reported the five ranges
25321
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25322
+ *
25323
+ * Relative and not absolute epoch, because an absolute epoch would make every
25324
+ * call site responsible for the same subtraction.
25325
+ */
25326
+ var ExportDenseRangeSchema = object({
25327
+ fromSec: number().nonnegative(),
25328
+ toSec: number().nonnegative()
25329
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25330
+ /**
25331
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25332
+ * listed ranges and at the base `everyMs` everywhere else.
25333
+ *
25334
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25335
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25336
+ */
25337
+ var ExportDenseSchema = object({
25338
+ everyMs: number().int().positive(),
25339
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25340
+ });
24925
25341
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
24926
25342
  var ExportTimelapseSchema = object({
24927
25343
  everyMs: number().int().positive(),
24928
- outputFps: number().int().min(1).max(60).optional()
25344
+ outputFps: number().int().min(1).max(60).optional(),
25345
+ /** Optional second, FASTER rate over the intervals that matter. */
25346
+ dense: ExportDenseSchema.optional()
25347
+ }).superRefine((v, ctx) => {
25348
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25349
+ code: ZodIssueCode.custom,
25350
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25351
+ path: ["dense", "everyMs"]
25352
+ });
24929
25353
  });
24930
25354
  /**
24931
25355
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -24983,6 +25407,19 @@ var ExportDownloadSchema = object({
24983
25407
  url: string(),
24984
25408
  endpoints: array(string())
24985
25409
  });
25410
+ /**
25411
+ * A finished export's bytes, inline.
25412
+ *
25413
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25414
+ * against, so nobody has to infer it from the base64 length.
25415
+ */
25416
+ var ExportBytesSchema = object({
25417
+ base64: string(),
25418
+ contentType: string(),
25419
+ /** Suggested filename, extension included. */
25420
+ name: string(),
25421
+ bytes: number().int().nonnegative()
25422
+ });
24986
25423
  method(object({
24987
25424
  deviceId: number(),
24988
25425
  profile: string(),
@@ -25007,6 +25444,9 @@ method(object({
25007
25444
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
25008
25445
  kind: "query",
25009
25446
  auth: "protected"
25447
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25448
+ kind: "query",
25449
+ auth: "protected"
25010
25450
  });
25011
25451
  /**
25012
25452
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -32026,6 +32466,12 @@ Object.freeze({
32026
32466
  addonId: null,
32027
32467
  access: "create"
32028
32468
  },
32469
+ "recording.cancelRelocateJob": {
32470
+ capName: "recording",
32471
+ capScope: "system",
32472
+ addonId: null,
32473
+ access: "create"
32474
+ },
32029
32475
  "recording.cancelStorageMigrationMove": {
32030
32476
  capName: "recording",
32031
32477
  capScope: "system",
@@ -32080,6 +32526,12 @@ Object.freeze({
32080
32526
  addonId: null,
32081
32527
  access: "view"
32082
32528
  },
32529
+ "recording.listRelocateJobs": {
32530
+ capName: "recording",
32531
+ capScope: "system",
32532
+ addonId: null,
32533
+ access: "view"
32534
+ },
32083
32535
  "recording.locateSegment": {
32084
32536
  capName: "recording",
32085
32537
  capScope: "system",
@@ -32092,6 +32544,12 @@ Object.freeze({
32092
32544
  addonId: null,
32093
32545
  access: "create"
32094
32546
  },
32547
+ "recording.planStorageRebalance": {
32548
+ capName: "recording",
32549
+ capScope: "system",
32550
+ addonId: null,
32551
+ access: "view"
32552
+ },
32095
32553
  "recording.pruneFootage": {
32096
32554
  capName: "recording",
32097
32555
  capScope: "system",
@@ -32116,6 +32574,12 @@ Object.freeze({
32116
32574
  addonId: null,
32117
32575
  access: "create"
32118
32576
  },
32577
+ "recording.relocateFootage": {
32578
+ capName: "recording",
32579
+ capScope: "system",
32580
+ addonId: null,
32581
+ access: "create"
32582
+ },
32119
32583
  "recording.renderClip": {
32120
32584
  capName: "recording",
32121
32585
  capScope: "system",
@@ -32152,38 +32616,50 @@ Object.freeze({
32152
32616
  addonId: null,
32153
32617
  access: "create"
32154
32618
  },
32619
+ "recording.startStorageRebalance": {
32620
+ capName: "recording",
32621
+ capScope: "system",
32622
+ addonId: null,
32623
+ access: "create"
32624
+ },
32155
32625
  "recordingExport.cancelExport": {
32156
- capName: "recordingExport",
32626
+ capName: "recording-export",
32157
32627
  capScope: "system",
32158
32628
  addonId: null,
32159
32629
  access: "create"
32160
32630
  },
32161
32631
  "recordingExport.createExport": {
32162
- capName: "recordingExport",
32632
+ capName: "recording-export",
32163
32633
  capScope: "system",
32164
32634
  addonId: null,
32165
32635
  access: "create"
32166
32636
  },
32167
32637
  "recordingExport.deleteExport": {
32168
- capName: "recordingExport",
32638
+ capName: "recording-export",
32169
32639
  capScope: "system",
32170
32640
  addonId: null,
32171
32641
  access: "delete"
32172
32642
  },
32173
32643
  "recordingExport.getDownloadUrl": {
32174
- capName: "recordingExport",
32644
+ capName: "recording-export",
32175
32645
  capScope: "system",
32176
32646
  addonId: null,
32177
32647
  access: "view"
32178
32648
  },
32179
32649
  "recordingExport.getExport": {
32180
- capName: "recordingExport",
32650
+ capName: "recording-export",
32181
32651
  capScope: "system",
32182
32652
  addonId: null,
32183
32653
  access: "view"
32184
32654
  },
32185
32655
  "recordingExport.listExports": {
32186
- capName: "recordingExport",
32656
+ capName: "recording-export",
32657
+ capScope: "system",
32658
+ addonId: null,
32659
+ access: "view"
32660
+ },
32661
+ "recordingExport.readExportBytes": {
32662
+ capName: "recording-export",
32187
32663
  capScope: "system",
32188
32664
  addonId: null,
32189
32665
  access: "view"
@@ -33560,6 +34036,104 @@ var FramerateField = number().int().min(1).max(60);
33560
34036
  var TargetsField = array(NcRuleTargetSchema).min(1);
33561
34037
  var PriorityField = number().int().min(1).max(5);
33562
34038
  /**
34039
+ * Explicit override of the DENSE sampling cadence, seconds.
34040
+ *
34041
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
34042
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
34043
+ * made that same base 3 s and rendered a person pass as two frames.)
34044
+ *
34045
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
34046
+ * `denseCadenceSec` and played at `framerate` occupies
34047
+ *
34048
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
34049
+ *
34050
+ * 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.
34051
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
34052
+ * and therefore the length of a quiet night, does not move.
34053
+ *
34054
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
34055
+ * the recording has them returns the same frames, requested twice. Must be
34056
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
34057
+ * a uniform video the operator believes is two-rate — and upsert refuses it
34058
+ * rather than letting the export cap reject the render hours after the window.
34059
+ */
34060
+ var DenseCadenceSecField = number().min(.1).max(3600);
34061
+ /**
34062
+ * Minimum seconds of OUTPUT video each detection range must occupy.
34063
+ *
34064
+ * The operator-facing form of the arithmetic above: instead of solving for a
34065
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
34066
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
34067
+ * that range every ~583 ms.
34068
+ *
34069
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
34070
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
34071
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
34072
+ * ranges are sampled denser than they need. Per-range cadences require a cap
34073
+ * schema change and are the tracked follow-up.
34074
+ *
34075
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
34076
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
34077
+ * by real footage, never met by duplicating frames into motion that never
34078
+ * happened.
34079
+ */
34080
+ var MinDwellSecField = number().min(0).max(60);
34081
+ /**
34082
+ * Caption burned into the notification's preview frame.
34083
+ *
34084
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
34085
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
34086
+ * templating dialect for one field would be a second thing to explain.
34087
+ *
34088
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
34089
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
34090
+ * the reason this is not `.min(1)`.
34091
+ */
34092
+ var PreviewTextField = string().max(200);
34093
+ /**
34094
+ * Whether the notification's preview is a STILL or a short animation.
34095
+ *
34096
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
34097
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
34098
+ * night reads better as three seconds of motion than as one frame of it. Both
34099
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
34100
+ * simply applies it to a dozen frames sampled across the render and assembles
34101
+ * them.
34102
+ *
34103
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
34104
+ * seeks and a palette pass, and no rule that never asked for one should start
34105
+ * paying that on the deploy that shipped it.
34106
+ *
34107
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
34108
+ */
34109
+ var PreviewModeField = _enum(["image", "gif"]);
34110
+ /**
34111
+ * Which detection classes the notification reports counts for.
34112
+ *
34113
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
34114
+ * plan — no second query — aggregated per class. Absent or empty means "every
34115
+ * class the window actually contained", which is what an operator who never
34116
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
34117
+ * counts cars all night).
34118
+ *
34119
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
34120
+ * …). An unknown name simply never matches and reports nothing — it is not an
34121
+ * error, because a rule may legitimately name a class this camera's model does
34122
+ * not emit.
34123
+ *
34124
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
34125
+ * - `{{detections}}` — total over the reported classes
34126
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
34127
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
34128
+ * one per class, `count_` + the class name
34129
+ *
34130
+ * With NO custom body template the summary is appended to the derived body, and
34131
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
34132
+ * reads. With a custom template the operator owns every word — nothing is
34133
+ * appended, so `{{detectionSummary}}` is how he asks for it.
34134
+ */
34135
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
34136
+ /**
33563
34137
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33564
34138
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33565
34139
  * here (see the ownership note above).
@@ -33579,9 +34153,30 @@ var TimelapseRuleInputSchema = object({
33579
34153
  cadenceSec: CadenceSecField.default(15),
33580
34154
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33581
34155
  framerate: FramerateField.default(10),
34156
+ /**
34157
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
34158
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
34159
+ * field gets.
34160
+ */
34161
+ denseCadenceSec: DenseCadenceSecField.optional(),
34162
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
34163
+ minDwellSec: MinDwellSecField.optional(),
33582
34164
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33583
34165
  targets: TargetsField,
33584
34166
  template: TimelapseTemplateSchema.optional(),
34167
+ /**
34168
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
34169
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
34170
+ *
34171
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
34172
+ * the notification's title/body, and clearing it (`template: null`) must not
34173
+ * silently clear the caption too.
34174
+ */
34175
+ previewText: PreviewTextField.optional(),
34176
+ /** Still or animation — see {@link PreviewModeField}. */
34177
+ previewMode: PreviewModeField.default("image"),
34178
+ /** Classes the notification counts — see {@link ReportClassesField}. */
34179
+ reportClasses: ReportClassesField.optional(),
33585
34180
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33586
34181
  priority: PriorityField.default(3)
33587
34182
  });
@@ -33592,8 +34187,13 @@ object({
33592
34187
  schedule: NcScheduleSchema.optional(),
33593
34188
  cadenceSec: CadenceSecField.optional(),
33594
34189
  framerate: FramerateField.optional(),
34190
+ denseCadenceSec: DenseCadenceSecField.optional(),
34191
+ minDwellSec: MinDwellSecField.optional(),
33595
34192
  targets: TargetsField.optional(),
33596
34193
  template: TimelapseTemplateSchema.nullable().optional(),
34194
+ previewText: PreviewTextField.optional(),
34195
+ previewMode: PreviewModeField.optional(),
34196
+ reportClasses: ReportClassesField.optional(),
33597
34197
  priority: PriorityField.optional()
33598
34198
  });
33599
34199
  TimelapseRuleInputSchema.extend({
@@ -33605,10 +34205,28 @@ TimelapseRuleInputSchema.extend({
33605
34205
  */
33606
34206
  ownerUserId: string().optional(),
33607
34207
  /**
33608
- * Epoch-ms of the last successful generation the 1-hour re-generation
33609
- * guard's durable state (predecessor parity). Absent = never generated.
34208
+ * Epoch-ms of the NEWEST successful generation across every camera of this
34209
+ * rule. What a UI shows, and the compatibility floor for
34210
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33610
34211
  */
33611
34212
  lastGeneratedAt: number().optional(),
34213
+ /**
34214
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
34215
+ * re-generation guard's real durable state.
34216
+ *
34217
+ * One rule covers several cameras and each renders its own video, so a rule
34218
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
34219
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
34220
+ * already done — and B's night is gone for good, because the window will not
34221
+ * come back.
34222
+ *
34223
+ * ADDITIVE, so the migration is free: a row written before this field simply
34224
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
34225
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
34226
+ * "never generated" would re-render and re-notify every camera of every rule
34227
+ * once, on the deploy that shipped the map.
34228
+ */
34229
+ generatedByDevice: record(string(), number()).optional(),
33612
34230
  /** userId of the caller who created the rule (server-stamped). */
33613
34231
  createdBy: string(),
33614
34232
  createdAt: number(),
@@ -33659,25 +34277,32 @@ object({
33659
34277
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33660
34278
  object({
33661
34279
  /**
33662
- * How long a retained native frame is served before it counts as a miss.
34280
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
34281
+ * detection result.
33663
34282
  *
33664
- * Must cover the FULL late-crop horizon: detection inference + the
33665
- * cross-process inference-result hop to hub post-analysis + tracking + the
33666
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33667
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33668
- * RAM per busy camera grows linearly with no measured hit-rate gain.
34283
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
34284
+ * a time window was never related to the event the pixels were waiting for.
34285
+ * A held frame now lives from delivery until the runner has its `FrameResult`
34286
+ * at which moment the runner cuts the subject tiles it actually wanted and
34287
+ * releases the frame. The bound exists only so a runner that stops answering
34288
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
34289
+ *
34290
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
34291
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
34292
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
34293
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
34294
+ * `holdOverflow` on the metrics line is what says you need it.
33669
34295
  */
33670
- ttlMs: number().int().min(250).max(1e4),
34296
+ holdFrames: number().int().min(1).max(64),
33671
34297
  /**
33672
34298
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33673
34299
  *
33674
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33675
- * which one is actually binding before reasoning from that. At the shipped
33676
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33677
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33678
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33679
- * change that admits fewer frames buys retention WINDOW at constant RAM
33680
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
34300
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
34301
+ * is what decides how much is held, and the ceiling is the number above which
34302
+ * something is wrong. Before that it was the effective cap at 1024 MB with
34303
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
34304
+ * with the TTL expiring nothing, which is exactly the confusion the hold
34305
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33681
34306
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33682
34307
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33683
34308
  * to replace).
@@ -33703,22 +34328,45 @@ object({
33703
34328
  * there is the signal that some caller names frames outside the inference set
33704
34329
  * and that this must go back to `all`.
33705
34330
  */
33706
- admission: NativeLeaseAdmissionSchema
34331
+ admission: NativeLeaseAdmissionSchema,
34332
+ /**
34333
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
34334
+ * compressed native crops the worker cuts at the moment a frame's detection
34335
+ * result arrives, and keeps long after the frame itself is freed.
34336
+ *
34337
+ * This is the knob that replaced the old retention window, and it buys about
34338
+ * three orders of magnitude more of it: a tile is one subject at native
34339
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
34340
+ * the frame it was cut from. A frame on which nothing was detected costs
34341
+ * nothing at all, which is the real change — the old lease paid per FRAME and
34342
+ * was interrogated per SUBJECT.
34343
+ *
34344
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
34345
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
34346
+ * reproduce that.
34347
+ */
34348
+ tileBudgetMb: number().int().min(0).max(1024)
33707
34349
  });
33708
34350
  /**
33709
- * The values in force when the operator has set nothing — byte-for-byte the
33710
- * constants the decode worker shipped with as env-var defaults, so making these
33711
- * settings changed no behaviour on the day it landed.
34351
+ * The values in force when the operator has set nothing.
34352
+ *
34353
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
34354
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
34355
+ * in the same change that redefines it would make a regression and a retune
34356
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
34357
+ * live traffic.
33712
34358
  */
33713
34359
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33714
- ttlMs: 1200,
34360
+ holdFrames: 8,
33715
34361
  budgetMb: 1024,
33716
34362
  activityMs: 15e3,
34363
+ tileBudgetMb: 64,
33717
34364
  admission: "inferred"
33718
34365
  };
33719
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
34366
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33720
34367
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33721
34368
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34369
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33722
34370
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33723
34371
  //#endregion
33724
34372
  //#region src/digest-auth.ts