@camstack/addon-import-alexa 0.2.12 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +686 -42
  2. package/dist/addon.mjs +686 -42
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -7377,8 +7377,31 @@ var AdoptionJobSchema = object({
7377
7377
  error: string().nullable()
7378
7378
  });
7379
7379
  /**
7380
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7381
- * pipeline functions an operator thinks in terms of.
7380
+ * Per-camera FUNCTION SWITCHES.
7381
+ *
7382
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7383
+ *
7384
+ * This file shipped as "the one coherent on/off surface over the pipeline
7385
+ * functions an operator thinks in terms of". The operator's verdict on
7386
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7387
+ * every function already had a settings page of its own, and a second place to
7388
+ * turn it off is a second place to look. Each switch is going back to its own
7389
+ * component's original options — detection to the detection-pipeline wrapper
7390
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7391
+ * (which was always first-class; the switch was a veneer over
7392
+ * `recording.setDeviceConfig`), notifications to a notification-center
7393
+ * per-device setting, the two camera planes to their own components.
7394
+ *
7395
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7396
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7397
+ * straight from the authorities with no group in the middle. That rule was
7398
+ * never about a control panel.
7399
+ *
7400
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7401
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7402
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7403
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7404
+ * stop; nothing new may be built on it.
7382
7405
  *
7383
7406
  * ## This file adds no state
7384
7407
  *
@@ -7729,7 +7752,15 @@ var RecordingConfigSchema = object({
7729
7752
  * Each completed/failed run also lands one durable ops-log row on its owning
7730
7753
  * addon surface.
7731
7754
  */
7755
+ /**
7756
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7757
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7758
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7759
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7760
+ * runs at all.
7761
+ */
7732
7762
  var RelocateJobStateSchema = _enum([
7763
+ "queued",
7733
7764
  "running",
7734
7765
  "done",
7735
7766
  "failed",
@@ -7764,6 +7795,15 @@ var RelocateFootageInputSchema = object({
7764
7795
  /** Limits relocation to the logical profile class. Omit only for the
7765
7796
  * pre-orchestration compatibility path. */
7766
7797
  footageClass: RelocateFootageClassSchema.optional(),
7798
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7799
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7800
+ * unit is a (camera, profile) pile, not a disk. */
7801
+ deviceId: number().int().optional(),
7802
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7803
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7804
+ * placement plan assigns those two independently, so a rebalance that could
7805
+ * only say "recordings" would move footage the plan never asked to move. */
7806
+ profiles: array(string()).optional(),
7767
7807
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7768
7808
  * never allowed to starve live writers. */
7769
7809
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7899,6 +7939,21 @@ var StorageLocationSchema = object({
7899
7939
  nodeId: string().optional(),
7900
7940
  isDefault: boolean().default(false),
7901
7941
  isSystem: boolean().default(false),
7942
+ /**
7943
+ * Operator opt-in: whether consumers that BALANCE across several locations
7944
+ * of a type may write here. Recordings reads it today; event media and
7945
+ * backups are the next consumers, which is why the flag lives on the
7946
+ * location rather than in any one addon's store — nothing has to be
7947
+ * extended to add the next consumer.
7948
+ *
7949
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7950
+ * flag existed reads back with no flag and keeps working exactly as before;
7951
+ * that is the whole compat story, and it is why no migration ships with it.
7952
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7953
+ * disk must not silently start writing to it); the default of a type is
7954
+ * always stamped `true`.
7955
+ */
7956
+ enabled: boolean().optional(),
7902
7957
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7903
7958
  * for node-local locations it can reach) — never persisted, absent when the
7904
7959
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12536,7 +12591,8 @@ method(object({
12536
12591
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12537
12592
  /**
12538
12593
  * filesystem-browse — per-node capability for browsing the node's local
12539
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12594
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12595
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12540
12596
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12541
12597
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12542
12598
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14377,6 +14433,13 @@ var MaskGridDimsSchema = object({
14377
14433
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14378
14434
  * this one field keeps the schema additive — a rule still declares exactly
14379
14435
  * one trigger.
14436
+ *
14437
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14438
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14439
+ * mirror.ts` fails the build on a member the app cannot render) and every
14440
+ * member costs a release train. A sustained-sound rule is therefore an
14441
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14442
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14380
14443
  */
14381
14444
  var NcDeliverySchema = _enum([
14382
14445
  "immediate",
@@ -14391,15 +14454,32 @@ var NcDeliverySchema = _enum([
14391
14454
  * depend on a provider's raw event name or payload shape.
14392
14455
  */
14393
14456
  var NcSystemEventKindSchema = _enum([
14394
- "camera-online",
14395
- "camera-offline",
14457
+ "device-online",
14458
+ "device-offline",
14459
+ "device-disabled",
14460
+ "device-enabled",
14396
14461
  "stream-online",
14397
14462
  "stream-offline",
14398
14463
  "node-online",
14399
14464
  "node-offline",
14400
14465
  "addon-update-available",
14401
- "server-update-available"
14466
+ "server-update-available",
14467
+ "alarm-triggered",
14468
+ "alarm-armed",
14469
+ "alarm-disarmed",
14470
+ "camera-online",
14471
+ "camera-offline",
14472
+ "camera-disabled",
14473
+ "camera-enabled"
14474
+ ]);
14475
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14476
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14477
+ "camera-online",
14478
+ "camera-offline",
14479
+ "camera-disabled",
14480
+ "camera-enabled"
14402
14481
  ]);
14482
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14403
14483
  /**
14404
14484
  * One coherent system-event condition. `kinds` is the required opt-in safety
14405
14485
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14408,6 +14488,18 @@ var NcSystemEventKindSchema = _enum([
14408
14488
  var NcSystemEventConditionSchema = object({
14409
14489
  kinds: array(NcSystemEventKindSchema).min(1),
14410
14490
  deviceIds: array(number().int()).min(1).optional(),
14491
+ /**
14492
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14493
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14494
+ * is what a liveness rule means when nobody said otherwise.
14495
+ *
14496
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14497
+ * one reason: the intake cannot know which devices this household cares
14498
+ * about, and a producer-side filter is one no operator can change. Fails
14499
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14500
+ * does not carry) matches no `deviceTypes` list.
14501
+ */
14502
+ deviceTypes: array(string().min(1)).min(1).optional(),
14411
14503
  nodeIds: array(string().min(1)).min(1).optional(),
14412
14504
  packageNames: array(string().min(1)).min(1).optional()
14413
14505
  });
@@ -14458,6 +14550,47 @@ var NcOccupancyConditionSchema = object({
14458
14550
  sustainSeconds: number().int().min(0).max(3600).default(15)
14459
14551
  });
14460
14552
  /**
14553
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14554
+ *
14555
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14556
+ * reference notifier uses, so an operator moving between them re-uses what
14557
+ * they already know): a rule matches when, over a sampling window of
14558
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14559
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14560
+ *
14561
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14562
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14563
+ * - `labels` — the classifier put at least one of these labels on it.
14564
+ *
14565
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14566
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14567
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14568
+ * is given** — a window in which every sample is trivially a hit would fire on
14569
+ * silence, so the engine refuses such a condition rather than notifying on
14570
+ * nothing (the schema cannot express "at least one of" without becoming a
14571
+ * ZodEffects the cap path would have to special-case).
14572
+ *
14573
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14574
+ * must be FULL before it can match — a window that has been open for two
14575
+ * seconds of its ten is 100% of nothing, and firing on it would make
14576
+ * `samplingSeconds` decorative.
14577
+ *
14578
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14579
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14580
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14581
+ * an operator who typed `dog` mean the same thing.
14582
+ */
14583
+ var NcAudioConditionSchema = object({
14584
+ /** Audio macro labels; absent = any sound (level-only rule). */
14585
+ labels: array(string().min(1)).min(1).optional(),
14586
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14587
+ dbThreshold: number().min(-96).max(0).optional(),
14588
+ /** Percentage of the window's samples that must be hits (1–100). */
14589
+ hitPercent: number().int().min(1).max(100).default(60),
14590
+ /** Length of the sampling window in seconds. */
14591
+ samplingSeconds: number().int().min(1).max(300).default(10)
14592
+ });
14593
+ /**
14461
14594
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14462
14595
  *
14463
14596
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14730,7 +14863,33 @@ var NcConditionsSchema = object({
14730
14863
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14731
14864
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14732
14865
  */
14733
- occupancy: NcOccupancyConditionSchema.optional()
14866
+ occupancy: NcOccupancyConditionSchema.optional(),
14867
+ /**
14868
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14869
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14870
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14871
+ * a window that is not full yet, neither filter given). See
14872
+ * {@link NcAudioCondition}.
14873
+ *
14874
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14875
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14876
+ * a detection, a track or a device event (the same fail-closed pairing
14877
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14878
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14879
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14880
+ * classified sample) stays exactly as it was for rules that already use it.
14881
+ *
14882
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14883
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14884
+ * (`camstack/src/data/notification-center.ts`, guarded by
14885
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14886
+ * condition fields it does not know when a rule is saved from the phone.
14887
+ * Publishing an editor for a condition the app cannot round-trip is how an
14888
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14889
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14890
+ * does an audio rule become authorable.
14891
+ */
14892
+ audio: NcAudioConditionSchema.optional()
14734
14893
  });
14735
14894
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14736
14895
  var NcRuleTargetSchema = object({
@@ -14844,6 +15003,73 @@ var NcThrottleSchema = object({
14844
15003
  */
14845
15004
  granularity: NcThrottleGranularitySchema.optional()
14846
15005
  });
15006
+ /**
15007
+ * How long the confirm gate may hold ONE notification, and how big the picture
15008
+ * it judges may be.
15009
+ *
15010
+ * The clamp is the product decision, not a coincidence of the model: p50 was
15011
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
15012
+ * arrives after the visitor has gone is not a notification. 448 px was enough
15013
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
15014
+ * tokens for pixels the model pools away.
15015
+ */
15016
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
15017
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
15018
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
15019
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
15020
+ var NcConfirmExpectSchema = object({
15021
+ op: _enum([
15022
+ ">=",
15023
+ ">",
15024
+ "<=",
15025
+ "<",
15026
+ "=="
15027
+ ]),
15028
+ count: number().int().min(0).max(1e3)
15029
+ });
15030
+ /**
15031
+ * AI CONFIRM — a vision model looks at the picture this notification is about
15032
+ * to ship and says whether it agrees with the rule.
15033
+ *
15034
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
15035
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
15036
+ * on the operator's phone is not a verdict about this notification.
15037
+ *
15038
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
15039
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
15040
+ * the default and every fail-open is COUNTED, because a gate that always fails
15041
+ * open looks in the log exactly like a gate that works.
15042
+ *
15043
+ * Every field is `.optional()` rather than relied on as a Zod default at the
15044
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
15045
+ * production failures in one day), so the gate reads absent as the constant
15046
+ * above rather than trusting a parse it may never have seen.
15047
+ */
15048
+ var NcConfirmSchema = object({
15049
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
15050
+ * same thing, and both mean "deliver exactly as before". */
15051
+ enabled: boolean().default(false),
15052
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
15053
+ profileId: string().optional(),
15054
+ /**
15055
+ * The operator's question, in his own words. Absent = a question derived
15056
+ * from the rule (its class and its expectation).
15057
+ *
15058
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
15059
+ * banners, signage and plates as instructions if you let them reach the
15060
+ * prompt — proven live — so the authoritative contract stays in the system
15061
+ * turn and only rule-authored words land here.
15062
+ */
15063
+ prompt: string().max(1e3).optional(),
15064
+ /** Fire only when the model's count satisfies this. Absent = the model's
15065
+ * own boolean verdict decides. */
15066
+ expect: NcConfirmExpectSchema.optional(),
15067
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
15068
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
15069
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
15070
+ /** Longest edge the judged image is downscaled to before it is sent. */
15071
+ maxImagePx: number().int().min(64).max(2048).default(448)
15072
+ });
14847
15073
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14848
15074
  var NcRuleInputSchema = object({
14849
15075
  name: string().min(1).max(200),
@@ -14904,7 +15130,13 @@ var NcRuleInputSchema = object({
14904
15130
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14905
15131
  * shape as every other actuation.
14906
15132
  */
14907
- actions: NcRuleActionsSchema.optional()
15133
+ actions: NcRuleActionsSchema.optional(),
15134
+ /**
15135
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
15136
+ * a rule that predates the gate must keep delivering byte-for-byte as it
15137
+ * did, and absent is the only way to say that without a migration.
15138
+ */
15139
+ confirm: NcConfirmSchema.optional()
14908
15140
  });
14909
15141
  /**
14910
15142
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14915,7 +15147,37 @@ var NcRuleInputSchema = object({
14915
15147
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14916
15148
  * `updateRule` patch.
14917
15149
  */
14918
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
15150
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
15151
+ disabledTargetIds: array(string()).optional(),
15152
+ /**
15153
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
15154
+ *
15155
+ * It makes the key optional to SUPPLY; the parse still materialises the
15156
+ * default when the key is absent. And `NcRuleStore.update` merges with
15157
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
15158
+ * one — which made every partial edit destructive:
15159
+ *
15160
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
15161
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
15162
+ * setEnabled(ruleId, false) → conditions reset to `{}`
15163
+ *
15164
+ * A rule scoped to one camera and one zone silently became a rule that
15165
+ * matches EVERY event on EVERY camera, and lost its `media` policy
15166
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
15167
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
15168
+ * within a minute of a two-field patch.
15169
+ *
15170
+ * So every defaulted field is re-declared here WITHOUT its default. The
15171
+ * inner defaults still apply when the caller DOES send the key — `{}` for
15172
+ * conditions remains a real instruction ("clear them") — and only the
15173
+ * absent key is now genuinely absent.
15174
+ */
15175
+ enabled: boolean().optional(),
15176
+ conditions: NcConditionsSchema.optional(),
15177
+ media: NcMediaPolicySchema.optional(),
15178
+ throttle: NcThrottleSchema.optional(),
15179
+ priority: number().int().min(1).max(5).optional()
15180
+ });
14919
15181
  /** A persisted rule. */
14920
15182
  var NcRuleSchema = NcRuleInputSchema.extend({
14921
15183
  id: string(),
@@ -15216,6 +15478,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15216
15478
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15217
15479
  * copy would lie the first time a rule is disabled.
15218
15480
  */
15481
+ /**
15482
+ * Why a device a mode NAMES is nonetheless not armed by it.
15483
+ *
15484
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15485
+ * per-camera notification switch the Notification Center already owns,
15486
+ * `detection-off` is the device's own detection binding being inactive, and
15487
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15488
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15489
+ * with the switches the operator actually used.
15490
+ */
15491
+ var NcAlarmSkipReasonSchema = _enum([
15492
+ "muted",
15493
+ "detection-off",
15494
+ "offline"
15495
+ ]);
15496
+ var NcAlarmSkippedDeviceSchema = object({
15497
+ deviceId: number().int(),
15498
+ reason: NcAlarmSkipReasonSchema
15499
+ });
15219
15500
  var NcAlarmModeCoverageSchema = object({
15220
15501
  mode: AlarmArmModeSchema,
15221
15502
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15223,7 +15504,18 @@ var NcAlarmModeCoverageSchema = object({
15223
15504
  /** At least one covering rule has no device scope, so the mode covers all. */
15224
15505
  allDevices: boolean(),
15225
15506
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15226
- deviceIds: array(number().int())
15507
+ deviceIds: array(number().int()),
15508
+ /**
15509
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15510
+ * excludes it.
15511
+ *
15512
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15513
+ * twelve makes it false in exactly the way nobody notices until an incident.
15514
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15515
+ * still parses as "nothing known to be skipped" rather than failing the whole
15516
+ * alarm tab.
15517
+ */
15518
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15227
15519
  });
15228
15520
  var NcAlarmConfigSchema = object({
15229
15521
  /**
@@ -18055,9 +18347,16 @@ var CameraStatusSchema = object({
18055
18347
  audio: CameraAudioStatusSchema.nullable(),
18056
18348
  recording: CameraRecordingStatusSchema.nullable(),
18057
18349
  /**
18058
- * Per-camera function switches an OPERATOR has turned off
18350
+ * Per-camera functions an OPERATOR has turned off
18059
18351
  * ([D61](../../../../docs/decisions/adr-0067.md)).
18060
18352
  *
18353
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18354
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18355
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18356
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18357
+ * The badge outlives the control panel: the panel was a convenience, this is
18358
+ * the difference between a camera being off and a camera being dead.
18359
+ *
18061
18360
  * This is the difference between DISABLED and BROKEN. A camera whose
18062
18361
  * `detection` block reports zero fps and whose `switchedOff` contains
18063
18362
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -24816,7 +25115,19 @@ var RecordingManifestSchema = object({
24816
25115
  * profiles/subtrees/locations on this node). */
24817
25116
  var RecordingDeviceUsageSchema = object({
24818
25117
  deviceId: number(),
24819
- usedBytes: number()
25118
+ usedBytes: number(),
25119
+ /**
25120
+ * Start of this camera's OLDEST indexed segment, across every profile and
25121
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25122
+ * only honest answer to "is retention actually holding?" per camera.
25123
+ *
25124
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25125
+ * predates this field omits it entirely, and a hub whose types carry the
25126
+ * field must keep validating that older provider's payload: the framework
25127
+ * (types) and the addon ship on different trains, and the addon is usually
25128
+ * the later of the two.
25129
+ */
25130
+ oldestMs: number().nullable().optional()
24820
25131
  });
24821
25132
  /** Recording storage usage + capacity for one storage location. */
24822
25133
  var RecordingLocationUsageSchema = object({
@@ -24844,6 +25155,57 @@ var RecordingStorageUsageSchema = object({
24844
25155
  locations: array(RecordingLocationUsageSchema)
24845
25156
  });
24846
25157
  /**
25158
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25159
+ *
25160
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25161
+ * is the operator asking for the EXISTING archive to be brought into line with
25162
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25163
+ * location, run FIFO behind the single-flight mover.
25164
+ *
25165
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25166
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25167
+ * (empty on the plan).
25168
+ */
25169
+ var RecordingRebalanceMoveSchema = object({
25170
+ deviceId: number(),
25171
+ profile: string(),
25172
+ fromLocationId: string(),
25173
+ toLocationId: string(),
25174
+ bytes: number(),
25175
+ files: number().int()
25176
+ });
25177
+ /** Why a pile that is out of place is staying there. Every refusal is
25178
+ * reported: a rebalance that silently drops a camera reads exactly like one
25179
+ * that had nothing to do. */
25180
+ var RecordingRebalanceSkipReasonSchema = _enum([
25181
+ "unassigned",
25182
+ "target-not-writable",
25183
+ "below-threshold",
25184
+ "no-headroom"
25185
+ ]);
25186
+ var RecordingRebalanceSkipSchema = object({
25187
+ deviceId: number(),
25188
+ profile: string(),
25189
+ fromLocationId: string(),
25190
+ /** The location the plan wants; null when the camera has no assignment. */
25191
+ toLocationId: string().nullable(),
25192
+ bytes: number(),
25193
+ reason: RecordingRebalanceSkipReasonSchema
25194
+ });
25195
+ var RecordingRebalancePlanSchema = object({
25196
+ moves: array(RecordingRebalanceMoveSchema),
25197
+ skipped: array(RecordingRebalanceSkipSchema),
25198
+ bytesToMove: number(),
25199
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25200
+ jobIds: array(string())
25201
+ });
25202
+ var RecordingRebalanceInputSchema = object({
25203
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25204
+ throttleMbps: number().min(1).max(1e3).optional(),
25205
+ /** Ignore piles smaller than this (default 1 GB). */
25206
+ minMoveGb: number().min(0).optional()
25207
+ });
25208
+ /**
24847
25209
  * Result of locating footage at a wall-clock instant for one device/profile.
24848
25210
  * `segment` carries the covering segment's window; `gap` reports the forward
24849
25211
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -25006,9 +25368,24 @@ method(object({
25006
25368
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25007
25369
  kind: "mutation",
25008
25370
  auth: "admin"
25371
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25372
+ kind: "mutation",
25373
+ auth: "admin"
25374
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25375
+ kind: "query",
25376
+ auth: "admin"
25377
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25378
+ kind: "mutation",
25379
+ auth: "admin"
25380
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25381
+ kind: "query",
25382
+ auth: "admin"
25383
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25384
+ kind: "mutation",
25385
+ auth: "admin"
25009
25386
  });
25010
25387
  /**
25011
- * `recordingExport` cap — render a footage time range into a single downloadable
25388
+ * `recording-export` cap — render a footage time range into a single downloadable
25012
25389
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
25013
25390
  * bounded lifetime with a durable history, auto-expiry, and optional
25014
25391
  * delete-after-download.
@@ -25023,10 +25400,53 @@ method(object({
25023
25400
  */
25024
25401
  /** Playback-speed multiplier for the render (1 = realtime). */
25025
25402
  var ExportSpeedSchema = number().min(.25).max(32);
25403
+ /**
25404
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25405
+ *
25406
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25407
+ * derives these bounds from things that happened at a TIME (a track's
25408
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25409
+ * every segment present for the range, with each recording GAP removed. The
25410
+ * two agree only on a window that recorded without one interruption, and only
25411
+ * the render side knows the segments, so the translation lives there
25412
+ * (`export-dense-map.ts`, addon-pipeline).
25413
+ *
25414
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25415
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25416
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25417
+ * the video was a uniform timelapse, and the log line reported the five ranges
25418
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25419
+ *
25420
+ * Relative and not absolute epoch, because an absolute epoch would make every
25421
+ * call site responsible for the same subtraction.
25422
+ */
25423
+ var ExportDenseRangeSchema = object({
25424
+ fromSec: number().nonnegative(),
25425
+ toSec: number().nonnegative()
25426
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25427
+ /**
25428
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25429
+ * listed ranges and at the base `everyMs` everywhere else.
25430
+ *
25431
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25432
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25433
+ */
25434
+ var ExportDenseSchema = object({
25435
+ everyMs: number().int().positive(),
25436
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25437
+ });
25026
25438
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
25027
25439
  var ExportTimelapseSchema = object({
25028
25440
  everyMs: number().int().positive(),
25029
- outputFps: number().int().min(1).max(60).optional()
25441
+ outputFps: number().int().min(1).max(60).optional(),
25442
+ /** Optional second, FASTER rate over the intervals that matter. */
25443
+ dense: ExportDenseSchema.optional()
25444
+ }).superRefine((v, ctx) => {
25445
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25446
+ code: ZodIssueCode.custom,
25447
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25448
+ path: ["dense", "everyMs"]
25449
+ });
25030
25450
  });
25031
25451
  /**
25032
25452
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -25084,6 +25504,19 @@ var ExportDownloadSchema = object({
25084
25504
  url: string(),
25085
25505
  endpoints: array(string())
25086
25506
  });
25507
+ /**
25508
+ * A finished export's bytes, inline.
25509
+ *
25510
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25511
+ * against, so nobody has to infer it from the base64 length.
25512
+ */
25513
+ var ExportBytesSchema = object({
25514
+ base64: string(),
25515
+ contentType: string(),
25516
+ /** Suggested filename, extension included. */
25517
+ name: string(),
25518
+ bytes: number().int().nonnegative()
25519
+ });
25087
25520
  method(object({
25088
25521
  deviceId: number(),
25089
25522
  profile: string(),
@@ -25108,6 +25541,9 @@ method(object({
25108
25541
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
25109
25542
  kind: "query",
25110
25543
  auth: "protected"
25544
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25545
+ kind: "query",
25546
+ auth: "protected"
25111
25547
  });
25112
25548
  /**
25113
25549
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -31785,6 +32221,12 @@ Object.freeze({
31785
32221
  addonId: null,
31786
32222
  access: "create"
31787
32223
  },
32224
+ "recording.cancelRelocateJob": {
32225
+ capName: "recording",
32226
+ capScope: "system",
32227
+ addonId: null,
32228
+ access: "create"
32229
+ },
31788
32230
  "recording.cancelStorageMigrationMove": {
31789
32231
  capName: "recording",
31790
32232
  capScope: "system",
@@ -31839,6 +32281,12 @@ Object.freeze({
31839
32281
  addonId: null,
31840
32282
  access: "view"
31841
32283
  },
32284
+ "recording.listRelocateJobs": {
32285
+ capName: "recording",
32286
+ capScope: "system",
32287
+ addonId: null,
32288
+ access: "view"
32289
+ },
31842
32290
  "recording.locateSegment": {
31843
32291
  capName: "recording",
31844
32292
  capScope: "system",
@@ -31851,6 +32299,12 @@ Object.freeze({
31851
32299
  addonId: null,
31852
32300
  access: "create"
31853
32301
  },
32302
+ "recording.planStorageRebalance": {
32303
+ capName: "recording",
32304
+ capScope: "system",
32305
+ addonId: null,
32306
+ access: "view"
32307
+ },
31854
32308
  "recording.pruneFootage": {
31855
32309
  capName: "recording",
31856
32310
  capScope: "system",
@@ -31875,6 +32329,12 @@ Object.freeze({
31875
32329
  addonId: null,
31876
32330
  access: "create"
31877
32331
  },
32332
+ "recording.relocateFootage": {
32333
+ capName: "recording",
32334
+ capScope: "system",
32335
+ addonId: null,
32336
+ access: "create"
32337
+ },
31878
32338
  "recording.renderClip": {
31879
32339
  capName: "recording",
31880
32340
  capScope: "system",
@@ -31911,38 +32371,50 @@ Object.freeze({
31911
32371
  addonId: null,
31912
32372
  access: "create"
31913
32373
  },
32374
+ "recording.startStorageRebalance": {
32375
+ capName: "recording",
32376
+ capScope: "system",
32377
+ addonId: null,
32378
+ access: "create"
32379
+ },
31914
32380
  "recordingExport.cancelExport": {
31915
- capName: "recordingExport",
32381
+ capName: "recording-export",
31916
32382
  capScope: "system",
31917
32383
  addonId: null,
31918
32384
  access: "create"
31919
32385
  },
31920
32386
  "recordingExport.createExport": {
31921
- capName: "recordingExport",
32387
+ capName: "recording-export",
31922
32388
  capScope: "system",
31923
32389
  addonId: null,
31924
32390
  access: "create"
31925
32391
  },
31926
32392
  "recordingExport.deleteExport": {
31927
- capName: "recordingExport",
32393
+ capName: "recording-export",
31928
32394
  capScope: "system",
31929
32395
  addonId: null,
31930
32396
  access: "delete"
31931
32397
  },
31932
32398
  "recordingExport.getDownloadUrl": {
31933
- capName: "recordingExport",
32399
+ capName: "recording-export",
31934
32400
  capScope: "system",
31935
32401
  addonId: null,
31936
32402
  access: "view"
31937
32403
  },
31938
32404
  "recordingExport.getExport": {
31939
- capName: "recordingExport",
32405
+ capName: "recording-export",
31940
32406
  capScope: "system",
31941
32407
  addonId: null,
31942
32408
  access: "view"
31943
32409
  },
31944
32410
  "recordingExport.listExports": {
31945
- capName: "recordingExport",
32411
+ capName: "recording-export",
32412
+ capScope: "system",
32413
+ addonId: null,
32414
+ access: "view"
32415
+ },
32416
+ "recordingExport.readExportBytes": {
32417
+ capName: "recording-export",
31946
32418
  capScope: "system",
31947
32419
  addonId: null,
31948
32420
  access: "view"
@@ -33319,6 +33791,104 @@ var FramerateField = number().int().min(1).max(60);
33319
33791
  var TargetsField = array(NcRuleTargetSchema).min(1);
33320
33792
  var PriorityField = number().int().min(1).max(5);
33321
33793
  /**
33794
+ * Explicit override of the DENSE sampling cadence, seconds.
33795
+ *
33796
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
33797
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
33798
+ * made that same base 3 s and rendered a person pass as two frames.)
33799
+ *
33800
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
33801
+ * `denseCadenceSec` and played at `framerate` occupies
33802
+ *
33803
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
33804
+ *
33805
+ * 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.
33806
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
33807
+ * and therefore the length of a quiet night, does not move.
33808
+ *
33809
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
33810
+ * the recording has them returns the same frames, requested twice. Must be
33811
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
33812
+ * a uniform video the operator believes is two-rate — and upsert refuses it
33813
+ * rather than letting the export cap reject the render hours after the window.
33814
+ */
33815
+ var DenseCadenceSecField = number().min(.1).max(3600);
33816
+ /**
33817
+ * Minimum seconds of OUTPUT video each detection range must occupy.
33818
+ *
33819
+ * The operator-facing form of the arithmetic above: instead of solving for a
33820
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
33821
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
33822
+ * that range every ~583 ms.
33823
+ *
33824
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
33825
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
33826
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
33827
+ * ranges are sampled denser than they need. Per-range cadences require a cap
33828
+ * schema change and are the tracked follow-up.
33829
+ *
33830
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
33831
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
33832
+ * by real footage, never met by duplicating frames into motion that never
33833
+ * happened.
33834
+ */
33835
+ var MinDwellSecField = number().min(0).max(60);
33836
+ /**
33837
+ * Caption burned into the notification's preview frame.
33838
+ *
33839
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
33840
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
33841
+ * templating dialect for one field would be a second thing to explain.
33842
+ *
33843
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
33844
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
33845
+ * the reason this is not `.min(1)`.
33846
+ */
33847
+ var PreviewTextField = string().max(200);
33848
+ /**
33849
+ * Whether the notification's preview is a STILL or a short animation.
33850
+ *
33851
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
33852
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
33853
+ * night reads better as three seconds of motion than as one frame of it. Both
33854
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
33855
+ * simply applies it to a dozen frames sampled across the render and assembles
33856
+ * them.
33857
+ *
33858
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
33859
+ * seeks and a palette pass, and no rule that never asked for one should start
33860
+ * paying that on the deploy that shipped it.
33861
+ *
33862
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
33863
+ */
33864
+ var PreviewModeField = _enum(["image", "gif"]);
33865
+ /**
33866
+ * Which detection classes the notification reports counts for.
33867
+ *
33868
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
33869
+ * plan — no second query — aggregated per class. Absent or empty means "every
33870
+ * class the window actually contained", which is what an operator who never
33871
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
33872
+ * counts cars all night).
33873
+ *
33874
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
33875
+ * …). An unknown name simply never matches and reports nothing — it is not an
33876
+ * error, because a rule may legitimately name a class this camera's model does
33877
+ * not emit.
33878
+ *
33879
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
33880
+ * - `{{detections}}` — total over the reported classes
33881
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
33882
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
33883
+ * one per class, `count_` + the class name
33884
+ *
33885
+ * With NO custom body template the summary is appended to the derived body, and
33886
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
33887
+ * reads. With a custom template the operator owns every word — nothing is
33888
+ * appended, so `{{detectionSummary}}` is how he asks for it.
33889
+ */
33890
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
33891
+ /**
33322
33892
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33323
33893
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33324
33894
  * here (see the ownership note above).
@@ -33338,9 +33908,30 @@ var TimelapseRuleInputSchema = object({
33338
33908
  cadenceSec: CadenceSecField.default(15),
33339
33909
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33340
33910
  framerate: FramerateField.default(10),
33911
+ /**
33912
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
33913
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
33914
+ * field gets.
33915
+ */
33916
+ denseCadenceSec: DenseCadenceSecField.optional(),
33917
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
33918
+ minDwellSec: MinDwellSecField.optional(),
33341
33919
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33342
33920
  targets: TargetsField,
33343
33921
  template: TimelapseTemplateSchema.optional(),
33922
+ /**
33923
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
33924
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
33925
+ *
33926
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
33927
+ * the notification's title/body, and clearing it (`template: null`) must not
33928
+ * silently clear the caption too.
33929
+ */
33930
+ previewText: PreviewTextField.optional(),
33931
+ /** Still or animation — see {@link PreviewModeField}. */
33932
+ previewMode: PreviewModeField.default("image"),
33933
+ /** Classes the notification counts — see {@link ReportClassesField}. */
33934
+ reportClasses: ReportClassesField.optional(),
33344
33935
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33345
33936
  priority: PriorityField.default(3)
33346
33937
  });
@@ -33351,8 +33942,13 @@ object({
33351
33942
  schedule: NcScheduleSchema.optional(),
33352
33943
  cadenceSec: CadenceSecField.optional(),
33353
33944
  framerate: FramerateField.optional(),
33945
+ denseCadenceSec: DenseCadenceSecField.optional(),
33946
+ minDwellSec: MinDwellSecField.optional(),
33354
33947
  targets: TargetsField.optional(),
33355
33948
  template: TimelapseTemplateSchema.nullable().optional(),
33949
+ previewText: PreviewTextField.optional(),
33950
+ previewMode: PreviewModeField.optional(),
33951
+ reportClasses: ReportClassesField.optional(),
33356
33952
  priority: PriorityField.optional()
33357
33953
  });
33358
33954
  TimelapseRuleInputSchema.extend({
@@ -33364,10 +33960,28 @@ TimelapseRuleInputSchema.extend({
33364
33960
  */
33365
33961
  ownerUserId: string().optional(),
33366
33962
  /**
33367
- * Epoch-ms of the last successful generation the 1-hour re-generation
33368
- * guard's durable state (predecessor parity). Absent = never generated.
33963
+ * Epoch-ms of the NEWEST successful generation across every camera of this
33964
+ * rule. What a UI shows, and the compatibility floor for
33965
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33369
33966
  */
33370
33967
  lastGeneratedAt: number().optional(),
33968
+ /**
33969
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
33970
+ * re-generation guard's real durable state.
33971
+ *
33972
+ * One rule covers several cameras and each renders its own video, so a rule
33973
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
33974
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
33975
+ * already done — and B's night is gone for good, because the window will not
33976
+ * come back.
33977
+ *
33978
+ * ADDITIVE, so the migration is free: a row written before this field simply
33979
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
33980
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
33981
+ * "never generated" would re-render and re-notify every camera of every rule
33982
+ * once, on the deploy that shipped the map.
33983
+ */
33984
+ generatedByDevice: record(string(), number()).optional(),
33371
33985
  /** userId of the caller who created the rule (server-stamped). */
33372
33986
  createdBy: string(),
33373
33987
  createdAt: number(),
@@ -33418,25 +34032,32 @@ object({
33418
34032
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33419
34033
  object({
33420
34034
  /**
33421
- * How long a retained native frame is served before it counts as a miss.
34035
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
34036
+ * detection result.
33422
34037
  *
33423
- * Must cover the FULL late-crop horizon: detection inference + the
33424
- * cross-process inference-result hop to hub post-analysis + tracking + the
33425
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33426
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33427
- * RAM per busy camera grows linearly with no measured hit-rate gain.
34038
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
34039
+ * a time window was never related to the event the pixels were waiting for.
34040
+ * A held frame now lives from delivery until the runner has its `FrameResult`
34041
+ * at which moment the runner cuts the subject tiles it actually wanted and
34042
+ * releases the frame. The bound exists only so a runner that stops answering
34043
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
34044
+ *
34045
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
34046
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
34047
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
34048
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
34049
+ * `holdOverflow` on the metrics line is what says you need it.
33428
34050
  */
33429
- ttlMs: number().int().min(250).max(1e4),
34051
+ holdFrames: number().int().min(1).max(64),
33430
34052
  /**
33431
34053
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33432
34054
  *
33433
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33434
- * which one is actually binding before reasoning from that. At the shipped
33435
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33436
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33437
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33438
- * change that admits fewer frames buys retention WINDOW at constant RAM
33439
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
34055
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
34056
+ * is what decides how much is held, and the ceiling is the number above which
34057
+ * something is wrong. Before that it was the effective cap at 1024 MB with
34058
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
34059
+ * with the TTL expiring nothing, which is exactly the confusion the hold
34060
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33440
34061
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33441
34062
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33442
34063
  * to replace).
@@ -33462,22 +34083,45 @@ object({
33462
34083
  * there is the signal that some caller names frames outside the inference set
33463
34084
  * and that this must go back to `all`.
33464
34085
  */
33465
- admission: NativeLeaseAdmissionSchema
34086
+ admission: NativeLeaseAdmissionSchema,
34087
+ /**
34088
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
34089
+ * compressed native crops the worker cuts at the moment a frame's detection
34090
+ * result arrives, and keeps long after the frame itself is freed.
34091
+ *
34092
+ * This is the knob that replaced the old retention window, and it buys about
34093
+ * three orders of magnitude more of it: a tile is one subject at native
34094
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
34095
+ * the frame it was cut from. A frame on which nothing was detected costs
34096
+ * nothing at all, which is the real change — the old lease paid per FRAME and
34097
+ * was interrogated per SUBJECT.
34098
+ *
34099
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
34100
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
34101
+ * reproduce that.
34102
+ */
34103
+ tileBudgetMb: number().int().min(0).max(1024)
33466
34104
  });
33467
34105
  /**
33468
- * The values in force when the operator has set nothing — byte-for-byte the
33469
- * constants the decode worker shipped with as env-var defaults, so making these
33470
- * settings changed no behaviour on the day it landed.
34106
+ * The values in force when the operator has set nothing.
34107
+ *
34108
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
34109
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
34110
+ * in the same change that redefines it would make a regression and a retune
34111
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
34112
+ * live traffic.
33471
34113
  */
33472
34114
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33473
- ttlMs: 1200,
34115
+ holdFrames: 8,
33474
34116
  budgetMb: 1024,
33475
34117
  activityMs: 15e3,
34118
+ tileBudgetMb: 64,
33476
34119
  admission: "inferred"
33477
34120
  };
33478
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
34121
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33479
34122
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33480
34123
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34124
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33481
34125
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33482
34126
  //#endregion
33483
34127
  //#region src/config.ts