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