@camstack/addon-tailscale 1.2.12 → 1.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.
@@ -7188,8 +7188,31 @@ var AdoptionJobSchema = object({
7188
7188
  error: string().nullable()
7189
7189
  });
7190
7190
  /**
7191
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7192
- * pipeline functions an operator thinks in terms of.
7191
+ * Per-camera FUNCTION SWITCHES.
7192
+ *
7193
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7194
+ *
7195
+ * This file shipped as "the one coherent on/off surface over the pipeline
7196
+ * functions an operator thinks in terms of". The operator's verdict on
7197
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7198
+ * every function already had a settings page of its own, and a second place to
7199
+ * turn it off is a second place to look. Each switch is going back to its own
7200
+ * component's original options — detection to the detection-pipeline wrapper
7201
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7202
+ * (which was always first-class; the switch was a veneer over
7203
+ * `recording.setDeviceConfig`), notifications to a notification-center
7204
+ * per-device setting, the two camera planes to their own components.
7205
+ *
7206
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7207
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7208
+ * straight from the authorities with no group in the middle. That rule was
7209
+ * never about a control panel.
7210
+ *
7211
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7212
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7213
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7214
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7215
+ * stop; nothing new may be built on it.
7193
7216
  *
7194
7217
  * ## This file adds no state
7195
7218
  *
@@ -7540,7 +7563,15 @@ var RecordingConfigSchema = object({
7540
7563
  * Each completed/failed run also lands one durable ops-log row on its owning
7541
7564
  * addon surface.
7542
7565
  */
7566
+ /**
7567
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7568
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7569
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7570
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7571
+ * runs at all.
7572
+ */
7543
7573
  var RelocateJobStateSchema = _enum([
7574
+ "queued",
7544
7575
  "running",
7545
7576
  "done",
7546
7577
  "failed",
@@ -7575,6 +7606,15 @@ var RelocateFootageInputSchema = object({
7575
7606
  /** Limits relocation to the logical profile class. Omit only for the
7576
7607
  * pre-orchestration compatibility path. */
7577
7608
  footageClass: RelocateFootageClassSchema.optional(),
7609
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7610
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7611
+ * unit is a (camera, profile) pile, not a disk. */
7612
+ deviceId: number().int().optional(),
7613
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7614
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7615
+ * placement plan assigns those two independently, so a rebalance that could
7616
+ * only say "recordings" would move footage the plan never asked to move. */
7617
+ profiles: array(string()).optional(),
7578
7618
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7579
7619
  * never allowed to starve live writers. */
7580
7620
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7710,6 +7750,21 @@ var StorageLocationSchema = object({
7710
7750
  nodeId: string().optional(),
7711
7751
  isDefault: boolean().default(false),
7712
7752
  isSystem: boolean().default(false),
7753
+ /**
7754
+ * Operator opt-in: whether consumers that BALANCE across several locations
7755
+ * of a type may write here. Recordings reads it today; event media and
7756
+ * backups are the next consumers, which is why the flag lives on the
7757
+ * location rather than in any one addon's store — nothing has to be
7758
+ * extended to add the next consumer.
7759
+ *
7760
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7761
+ * flag existed reads back with no flag and keeps working exactly as before;
7762
+ * that is the whole compat story, and it is why no migration ships with it.
7763
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7764
+ * disk must not silently start writing to it); the default of a type is
7765
+ * always stamped `true`.
7766
+ */
7767
+ enabled: boolean().optional(),
7713
7768
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7714
7769
  * for node-local locations it can reach) — never persisted, absent when the
7715
7770
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12012,7 +12067,8 @@ method(object({
12012
12067
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12013
12068
  /**
12014
12069
  * filesystem-browse — per-node capability for browsing the node's local
12015
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12070
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12071
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12016
12072
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12017
12073
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12018
12074
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -13842,6 +13898,13 @@ var MaskGridDimsSchema = object({
13842
13898
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
13843
13899
  * this one field keeps the schema additive — a rule still declares exactly
13844
13900
  * one trigger.
13901
+ *
13902
+ * AUDIO rules add no member here, for the reason occupancy added none: the
13903
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
13904
+ * mirror.ts` fails the build on a member the app cannot render) and every
13905
+ * member costs a release train. A sustained-sound rule is therefore an
13906
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
13907
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
13845
13908
  */
13846
13909
  var NcDeliverySchema = _enum([
13847
13910
  "immediate",
@@ -13856,15 +13919,32 @@ var NcDeliverySchema = _enum([
13856
13919
  * depend on a provider's raw event name or payload shape.
13857
13920
  */
13858
13921
  var NcSystemEventKindSchema = _enum([
13859
- "camera-online",
13860
- "camera-offline",
13922
+ "device-online",
13923
+ "device-offline",
13924
+ "device-disabled",
13925
+ "device-enabled",
13861
13926
  "stream-online",
13862
13927
  "stream-offline",
13863
13928
  "node-online",
13864
13929
  "node-offline",
13865
13930
  "addon-update-available",
13866
- "server-update-available"
13931
+ "server-update-available",
13932
+ "alarm-triggered",
13933
+ "alarm-armed",
13934
+ "alarm-disarmed",
13935
+ "camera-online",
13936
+ "camera-offline",
13937
+ "camera-disabled",
13938
+ "camera-enabled"
13939
+ ]);
13940
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
13941
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
13942
+ "camera-online",
13943
+ "camera-offline",
13944
+ "camera-disabled",
13945
+ "camera-enabled"
13867
13946
  ]);
13947
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
13868
13948
  /**
13869
13949
  * One coherent system-event condition. `kinds` is the required opt-in safety
13870
13950
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -13873,6 +13953,18 @@ var NcSystemEventKindSchema = _enum([
13873
13953
  var NcSystemEventConditionSchema = object({
13874
13954
  kinds: array(NcSystemEventKindSchema).min(1),
13875
13955
  deviceIds: array(number().int()).min(1).optional(),
13956
+ /**
13957
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
13958
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
13959
+ * is what a liveness rule means when nobody said otherwise.
13960
+ *
13961
+ * This is where "only my cameras" is expressed, and it lives on the rule for
13962
+ * one reason: the intake cannot know which devices this household cares
13963
+ * about, and a producer-side filter is one no operator can change. Fails
13964
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
13965
+ * does not carry) matches no `deviceTypes` list.
13966
+ */
13967
+ deviceTypes: array(string().min(1)).min(1).optional(),
13876
13968
  nodeIds: array(string().min(1)).min(1).optional(),
13877
13969
  packageNames: array(string().min(1)).min(1).optional()
13878
13970
  });
@@ -13923,6 +14015,47 @@ var NcOccupancyConditionSchema = object({
13923
14015
  sustainSeconds: number().int().min(0).max(3600).default(15)
13924
14016
  });
13925
14017
  /**
14018
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14019
+ *
14020
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14021
+ * reference notifier uses, so an operator moving between them re-uses what
14022
+ * they already know): a rule matches when, over a sampling window of
14023
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14024
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14025
+ *
14026
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14027
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14028
+ * - `labels` — the classifier put at least one of these labels on it.
14029
+ *
14030
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14031
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14032
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14033
+ * is given** — a window in which every sample is trivially a hit would fire on
14034
+ * silence, so the engine refuses such a condition rather than notifying on
14035
+ * nothing (the schema cannot express "at least one of" without becoming a
14036
+ * ZodEffects the cap path would have to special-case).
14037
+ *
14038
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14039
+ * must be FULL before it can match — a window that has been open for two
14040
+ * seconds of its ten is 100% of nothing, and firing on it would make
14041
+ * `samplingSeconds` decorative.
14042
+ *
14043
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14044
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14045
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14046
+ * an operator who typed `dog` mean the same thing.
14047
+ */
14048
+ var NcAudioConditionSchema = object({
14049
+ /** Audio macro labels; absent = any sound (level-only rule). */
14050
+ labels: array(string().min(1)).min(1).optional(),
14051
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14052
+ dbThreshold: number().min(-96).max(0).optional(),
14053
+ /** Percentage of the window's samples that must be hits (1–100). */
14054
+ hitPercent: number().int().min(1).max(100).default(60),
14055
+ /** Length of the sampling window in seconds. */
14056
+ samplingSeconds: number().int().min(1).max(300).default(10)
14057
+ });
14058
+ /**
13926
14059
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
13927
14060
  *
13928
14061
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14195,7 +14328,33 @@ var NcConditionsSchema = object({
14195
14328
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14196
14329
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14197
14330
  */
14198
- occupancy: NcOccupancyConditionSchema.optional()
14331
+ occupancy: NcOccupancyConditionSchema.optional(),
14332
+ /**
14333
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14334
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14335
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14336
+ * a window that is not full yet, neither filter given). See
14337
+ * {@link NcAudioCondition}.
14338
+ *
14339
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14340
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14341
+ * a detection, a track or a device event (the same fail-closed pairing
14342
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14343
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14344
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14345
+ * classified sample) stays exactly as it was for rules that already use it.
14346
+ *
14347
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14348
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14349
+ * (`camstack/src/data/notification-center.ts`, guarded by
14350
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14351
+ * condition fields it does not know when a rule is saved from the phone.
14352
+ * Publishing an editor for a condition the app cannot round-trip is how an
14353
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14354
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14355
+ * does an audio rule become authorable.
14356
+ */
14357
+ audio: NcAudioConditionSchema.optional()
14199
14358
  });
14200
14359
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14201
14360
  var NcRuleTargetSchema = object({
@@ -14309,6 +14468,73 @@ var NcThrottleSchema = object({
14309
14468
  */
14310
14469
  granularity: NcThrottleGranularitySchema.optional()
14311
14470
  });
14471
+ /**
14472
+ * How long the confirm gate may hold ONE notification, and how big the picture
14473
+ * it judges may be.
14474
+ *
14475
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14476
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14477
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14478
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14479
+ * tokens for pixels the model pools away.
14480
+ */
14481
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14482
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14483
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14484
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14485
+ var NcConfirmExpectSchema = object({
14486
+ op: _enum([
14487
+ ">=",
14488
+ ">",
14489
+ "<=",
14490
+ "<",
14491
+ "=="
14492
+ ]),
14493
+ count: number().int().min(0).max(1e3)
14494
+ });
14495
+ /**
14496
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14497
+ * to ship and says whether it agrees with the rule.
14498
+ *
14499
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14500
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14501
+ * on the operator's phone is not a verdict about this notification.
14502
+ *
14503
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14504
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14505
+ * the default and every fail-open is COUNTED, because a gate that always fails
14506
+ * open looks in the log exactly like a gate that works.
14507
+ *
14508
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14509
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14510
+ * production failures in one day), so the gate reads absent as the constant
14511
+ * above rather than trusting a parse it may never have seen.
14512
+ */
14513
+ var NcConfirmSchema = object({
14514
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14515
+ * same thing, and both mean "deliver exactly as before". */
14516
+ enabled: boolean().default(false),
14517
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14518
+ profileId: string().optional(),
14519
+ /**
14520
+ * The operator's question, in his own words. Absent = a question derived
14521
+ * from the rule (its class and its expectation).
14522
+ *
14523
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14524
+ * banners, signage and plates as instructions if you let them reach the
14525
+ * prompt — proven live — so the authoritative contract stays in the system
14526
+ * turn and only rule-authored words land here.
14527
+ */
14528
+ prompt: string().max(1e3).optional(),
14529
+ /** Fire only when the model's count satisfies this. Absent = the model's
14530
+ * own boolean verdict decides. */
14531
+ expect: NcConfirmExpectSchema.optional(),
14532
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14533
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14534
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14535
+ /** Longest edge the judged image is downscaled to before it is sent. */
14536
+ maxImagePx: number().int().min(64).max(2048).default(448)
14537
+ });
14312
14538
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14313
14539
  var NcRuleInputSchema = object({
14314
14540
  name: string().min(1).max(200),
@@ -14369,7 +14595,13 @@ var NcRuleInputSchema = object({
14369
14595
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14370
14596
  * shape as every other actuation.
14371
14597
  */
14372
- actions: NcRuleActionsSchema.optional()
14598
+ actions: NcRuleActionsSchema.optional(),
14599
+ /**
14600
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14601
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14602
+ * did, and absent is the only way to say that without a migration.
14603
+ */
14604
+ confirm: NcConfirmSchema.optional()
14373
14605
  });
14374
14606
  /**
14375
14607
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14380,7 +14612,37 @@ var NcRuleInputSchema = object({
14380
14612
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14381
14613
  * `updateRule` patch.
14382
14614
  */
14383
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14615
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14616
+ disabledTargetIds: array(string()).optional(),
14617
+ /**
14618
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14619
+ *
14620
+ * It makes the key optional to SUPPLY; the parse still materialises the
14621
+ * default when the key is absent. And `NcRuleStore.update` merges with
14622
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14623
+ * one — which made every partial edit destructive:
14624
+ *
14625
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14626
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14627
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14628
+ *
14629
+ * A rule scoped to one camera and one zone silently became a rule that
14630
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14631
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14632
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14633
+ * within a minute of a two-field patch.
14634
+ *
14635
+ * So every defaulted field is re-declared here WITHOUT its default. The
14636
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14637
+ * conditions remains a real instruction ("clear them") — and only the
14638
+ * absent key is now genuinely absent.
14639
+ */
14640
+ enabled: boolean().optional(),
14641
+ conditions: NcConditionsSchema.optional(),
14642
+ media: NcMediaPolicySchema.optional(),
14643
+ throttle: NcThrottleSchema.optional(),
14644
+ priority: number().int().min(1).max(5).optional()
14645
+ });
14384
14646
  /** A persisted rule. */
14385
14647
  var NcRuleSchema = NcRuleInputSchema.extend({
14386
14648
  id: string(),
@@ -14681,6 +14943,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14681
14943
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14682
14944
  * copy would lie the first time a rule is disabled.
14683
14945
  */
14946
+ /**
14947
+ * Why a device a mode NAMES is nonetheless not armed by it.
14948
+ *
14949
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
14950
+ * per-camera notification switch the Notification Center already owns,
14951
+ * `detection-off` is the device's own detection binding being inactive, and
14952
+ * `offline` is the device manager's liveness. A fourth reason would mean a
14953
+ * fourth authority, and inventing one here is how a panel starts disagreeing
14954
+ * with the switches the operator actually used.
14955
+ */
14956
+ var NcAlarmSkipReasonSchema = _enum([
14957
+ "muted",
14958
+ "detection-off",
14959
+ "offline"
14960
+ ]);
14961
+ var NcAlarmSkippedDeviceSchema = object({
14962
+ deviceId: number().int(),
14963
+ reason: NcAlarmSkipReasonSchema
14964
+ });
14684
14965
  var NcAlarmModeCoverageSchema = object({
14685
14966
  mode: AlarmArmModeSchema,
14686
14967
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14688,7 +14969,18 @@ var NcAlarmModeCoverageSchema = object({
14688
14969
  /** At least one covering rule has no device scope, so the mode covers all. */
14689
14970
  allDevices: boolean(),
14690
14971
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14691
- deviceIds: array(number().int())
14972
+ deviceIds: array(number().int()),
14973
+ /**
14974
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
14975
+ * excludes it.
14976
+ *
14977
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
14978
+ * twelve makes it false in exactly the way nobody notices until an incident.
14979
+ * Defaulted to `[]` so a coverage answer computed before this field existed
14980
+ * still parses as "nothing known to be skipped" rather than failing the whole
14981
+ * alarm tab.
14982
+ */
14983
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14692
14984
  });
14693
14985
  var NcAlarmConfigSchema = object({
14694
14986
  /**
@@ -17487,9 +17779,16 @@ var CameraStatusSchema = object({
17487
17779
  audio: CameraAudioStatusSchema.nullable(),
17488
17780
  recording: CameraRecordingStatusSchema.nullable(),
17489
17781
  /**
17490
- * Per-camera function switches an OPERATOR has turned off
17782
+ * Per-camera functions an OPERATOR has turned off
17491
17783
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17492
17784
  *
17785
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
17786
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
17787
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
17788
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
17789
+ * The badge outlives the control panel: the panel was a convenience, this is
17790
+ * the difference between a camera being off and a camera being dead.
17791
+ *
17493
17792
  * This is the difference between DISABLED and BROKEN. A camera whose
17494
17793
  * `detection` block reports zero fps and whose `switchedOff` contains
17495
17794
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -23059,7 +23358,19 @@ var RecordingManifestSchema = object({
23059
23358
  * profiles/subtrees/locations on this node). */
23060
23359
  var RecordingDeviceUsageSchema = object({
23061
23360
  deviceId: number(),
23062
- usedBytes: number()
23361
+ usedBytes: number(),
23362
+ /**
23363
+ * Start of this camera's OLDEST indexed segment, across every profile and
23364
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23365
+ * only honest answer to "is retention actually holding?" per camera.
23366
+ *
23367
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23368
+ * predates this field omits it entirely, and a hub whose types carry the
23369
+ * field must keep validating that older provider's payload: the framework
23370
+ * (types) and the addon ship on different trains, and the addon is usually
23371
+ * the later of the two.
23372
+ */
23373
+ oldestMs: number().nullable().optional()
23063
23374
  });
23064
23375
  /** Recording storage usage + capacity for one storage location. */
23065
23376
  var RecordingLocationUsageSchema = object({
@@ -23087,6 +23398,57 @@ var RecordingStorageUsageSchema = object({
23087
23398
  locations: array(RecordingLocationUsageSchema)
23088
23399
  });
23089
23400
  /**
23401
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23402
+ *
23403
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23404
+ * is the operator asking for the EXISTING archive to be brought into line with
23405
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23406
+ * location, run FIFO behind the single-flight mover.
23407
+ *
23408
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23409
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23410
+ * (empty on the plan).
23411
+ */
23412
+ var RecordingRebalanceMoveSchema = object({
23413
+ deviceId: number(),
23414
+ profile: string(),
23415
+ fromLocationId: string(),
23416
+ toLocationId: string(),
23417
+ bytes: number(),
23418
+ files: number().int()
23419
+ });
23420
+ /** Why a pile that is out of place is staying there. Every refusal is
23421
+ * reported: a rebalance that silently drops a camera reads exactly like one
23422
+ * that had nothing to do. */
23423
+ var RecordingRebalanceSkipReasonSchema = _enum([
23424
+ "unassigned",
23425
+ "target-not-writable",
23426
+ "below-threshold",
23427
+ "no-headroom"
23428
+ ]);
23429
+ var RecordingRebalanceSkipSchema = object({
23430
+ deviceId: number(),
23431
+ profile: string(),
23432
+ fromLocationId: string(),
23433
+ /** The location the plan wants; null when the camera has no assignment. */
23434
+ toLocationId: string().nullable(),
23435
+ bytes: number(),
23436
+ reason: RecordingRebalanceSkipReasonSchema
23437
+ });
23438
+ var RecordingRebalancePlanSchema = object({
23439
+ moves: array(RecordingRebalanceMoveSchema),
23440
+ skipped: array(RecordingRebalanceSkipSchema),
23441
+ bytesToMove: number(),
23442
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23443
+ jobIds: array(string())
23444
+ });
23445
+ var RecordingRebalanceInputSchema = object({
23446
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23447
+ throttleMbps: number().min(1).max(1e3).optional(),
23448
+ /** Ignore piles smaller than this (default 1 GB). */
23449
+ minMoveGb: number().min(0).optional()
23450
+ });
23451
+ /**
23090
23452
  * Result of locating footage at a wall-clock instant for one device/profile.
23091
23453
  * `segment` carries the covering segment's window; `gap` reports the forward
23092
23454
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23249,9 +23611,24 @@ method(object({
23249
23611
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23250
23612
  kind: "mutation",
23251
23613
  auth: "admin"
23614
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23615
+ kind: "mutation",
23616
+ auth: "admin"
23617
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23618
+ kind: "query",
23619
+ auth: "admin"
23620
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23621
+ kind: "mutation",
23622
+ auth: "admin"
23623
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23624
+ kind: "query",
23625
+ auth: "admin"
23626
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23627
+ kind: "mutation",
23628
+ auth: "admin"
23252
23629
  });
23253
23630
  /**
23254
- * `recordingExport` cap — render a footage time range into a single downloadable
23631
+ * `recording-export` cap — render a footage time range into a single downloadable
23255
23632
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23256
23633
  * bounded lifetime with a durable history, auto-expiry, and optional
23257
23634
  * delete-after-download.
@@ -23266,10 +23643,53 @@ method(object({
23266
23643
  */
23267
23644
  /** Playback-speed multiplier for the render (1 = realtime). */
23268
23645
  var ExportSpeedSchema = number().min(.25).max(32);
23646
+ /**
23647
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23648
+ *
23649
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23650
+ * derives these bounds from things that happened at a TIME (a track's
23651
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23652
+ * every segment present for the range, with each recording GAP removed. The
23653
+ * two agree only on a window that recorded without one interruption, and only
23654
+ * the render side knows the segments, so the translation lives there
23655
+ * (`export-dense-map.ts`, addon-pipeline).
23656
+ *
23657
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23658
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23659
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23660
+ * the video was a uniform timelapse, and the log line reported the five ranges
23661
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23662
+ *
23663
+ * Relative and not absolute epoch, because an absolute epoch would make every
23664
+ * call site responsible for the same subtraction.
23665
+ */
23666
+ var ExportDenseRangeSchema = object({
23667
+ fromSec: number().nonnegative(),
23668
+ toSec: number().nonnegative()
23669
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23670
+ /**
23671
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23672
+ * listed ranges and at the base `everyMs` everywhere else.
23673
+ *
23674
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23675
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23676
+ */
23677
+ var ExportDenseSchema = object({
23678
+ everyMs: number().int().positive(),
23679
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23680
+ });
23269
23681
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23270
23682
  var ExportTimelapseSchema = object({
23271
23683
  everyMs: number().int().positive(),
23272
- outputFps: number().int().min(1).max(60).optional()
23684
+ outputFps: number().int().min(1).max(60).optional(),
23685
+ /** Optional second, FASTER rate over the intervals that matter. */
23686
+ dense: ExportDenseSchema.optional()
23687
+ }).superRefine((v, ctx) => {
23688
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23689
+ code: ZodIssueCode.custom,
23690
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23691
+ path: ["dense", "everyMs"]
23692
+ });
23273
23693
  });
23274
23694
  /**
23275
23695
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23327,6 +23747,19 @@ var ExportDownloadSchema = object({
23327
23747
  url: string(),
23328
23748
  endpoints: array(string())
23329
23749
  });
23750
+ /**
23751
+ * A finished export's bytes, inline.
23752
+ *
23753
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23754
+ * against, so nobody has to infer it from the base64 length.
23755
+ */
23756
+ var ExportBytesSchema = object({
23757
+ base64: string(),
23758
+ contentType: string(),
23759
+ /** Suggested filename, extension included. */
23760
+ name: string(),
23761
+ bytes: number().int().nonnegative()
23762
+ });
23330
23763
  method(object({
23331
23764
  deviceId: number(),
23332
23765
  profile: string(),
@@ -23351,6 +23784,9 @@ method(object({
23351
23784
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23352
23785
  kind: "query",
23353
23786
  auth: "protected"
23787
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
23788
+ kind: "query",
23789
+ auth: "protected"
23354
23790
  });
23355
23791
  /**
23356
23792
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -28544,6 +28980,12 @@ Object.freeze({
28544
28980
  addonId: null,
28545
28981
  access: "create"
28546
28982
  },
28983
+ "recording.cancelRelocateJob": {
28984
+ capName: "recording",
28985
+ capScope: "system",
28986
+ addonId: null,
28987
+ access: "create"
28988
+ },
28547
28989
  "recording.cancelStorageMigrationMove": {
28548
28990
  capName: "recording",
28549
28991
  capScope: "system",
@@ -28598,6 +29040,12 @@ Object.freeze({
28598
29040
  addonId: null,
28599
29041
  access: "view"
28600
29042
  },
29043
+ "recording.listRelocateJobs": {
29044
+ capName: "recording",
29045
+ capScope: "system",
29046
+ addonId: null,
29047
+ access: "view"
29048
+ },
28601
29049
  "recording.locateSegment": {
28602
29050
  capName: "recording",
28603
29051
  capScope: "system",
@@ -28610,6 +29058,12 @@ Object.freeze({
28610
29058
  addonId: null,
28611
29059
  access: "create"
28612
29060
  },
29061
+ "recording.planStorageRebalance": {
29062
+ capName: "recording",
29063
+ capScope: "system",
29064
+ addonId: null,
29065
+ access: "view"
29066
+ },
28613
29067
  "recording.pruneFootage": {
28614
29068
  capName: "recording",
28615
29069
  capScope: "system",
@@ -28634,6 +29088,12 @@ Object.freeze({
28634
29088
  addonId: null,
28635
29089
  access: "create"
28636
29090
  },
29091
+ "recording.relocateFootage": {
29092
+ capName: "recording",
29093
+ capScope: "system",
29094
+ addonId: null,
29095
+ access: "create"
29096
+ },
28637
29097
  "recording.renderClip": {
28638
29098
  capName: "recording",
28639
29099
  capScope: "system",
@@ -28670,38 +29130,50 @@ Object.freeze({
28670
29130
  addonId: null,
28671
29131
  access: "create"
28672
29132
  },
29133
+ "recording.startStorageRebalance": {
29134
+ capName: "recording",
29135
+ capScope: "system",
29136
+ addonId: null,
29137
+ access: "create"
29138
+ },
28673
29139
  "recordingExport.cancelExport": {
28674
- capName: "recordingExport",
29140
+ capName: "recording-export",
28675
29141
  capScope: "system",
28676
29142
  addonId: null,
28677
29143
  access: "create"
28678
29144
  },
28679
29145
  "recordingExport.createExport": {
28680
- capName: "recordingExport",
29146
+ capName: "recording-export",
28681
29147
  capScope: "system",
28682
29148
  addonId: null,
28683
29149
  access: "create"
28684
29150
  },
28685
29151
  "recordingExport.deleteExport": {
28686
- capName: "recordingExport",
29152
+ capName: "recording-export",
28687
29153
  capScope: "system",
28688
29154
  addonId: null,
28689
29155
  access: "delete"
28690
29156
  },
28691
29157
  "recordingExport.getDownloadUrl": {
28692
- capName: "recordingExport",
29158
+ capName: "recording-export",
28693
29159
  capScope: "system",
28694
29160
  addonId: null,
28695
29161
  access: "view"
28696
29162
  },
28697
29163
  "recordingExport.getExport": {
28698
- capName: "recordingExport",
29164
+ capName: "recording-export",
28699
29165
  capScope: "system",
28700
29166
  addonId: null,
28701
29167
  access: "view"
28702
29168
  },
28703
29169
  "recordingExport.listExports": {
28704
- capName: "recordingExport",
29170
+ capName: "recording-export",
29171
+ capScope: "system",
29172
+ addonId: null,
29173
+ access: "view"
29174
+ },
29175
+ "recordingExport.readExportBytes": {
29176
+ capName: "recording-export",
28705
29177
  capScope: "system",
28706
29178
  addonId: null,
28707
29179
  access: "view"
@@ -30078,6 +30550,104 @@ var FramerateField = number().int().min(1).max(60);
30078
30550
  var TargetsField = array(NcRuleTargetSchema).min(1);
30079
30551
  var PriorityField = number().int().min(1).max(5);
30080
30552
  /**
30553
+ * Explicit override of the DENSE sampling cadence, seconds.
30554
+ *
30555
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
30556
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
30557
+ * made that same base 3 s and rendered a person pass as two frames.)
30558
+ *
30559
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
30560
+ * `denseCadenceSec` and played at `framerate` occupies
30561
+ *
30562
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
30563
+ *
30564
+ * 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.
30565
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
30566
+ * and therefore the length of a quiet night, does not move.
30567
+ *
30568
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
30569
+ * the recording has them returns the same frames, requested twice. Must be
30570
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
30571
+ * a uniform video the operator believes is two-rate — and upsert refuses it
30572
+ * rather than letting the export cap reject the render hours after the window.
30573
+ */
30574
+ var DenseCadenceSecField = number().min(.1).max(3600);
30575
+ /**
30576
+ * Minimum seconds of OUTPUT video each detection range must occupy.
30577
+ *
30578
+ * The operator-facing form of the arithmetic above: instead of solving for a
30579
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
30580
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
30581
+ * that range every ~583 ms.
30582
+ *
30583
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
30584
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
30585
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
30586
+ * ranges are sampled denser than they need. Per-range cadences require a cap
30587
+ * schema change and are the tracked follow-up.
30588
+ *
30589
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
30590
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
30591
+ * by real footage, never met by duplicating frames into motion that never
30592
+ * happened.
30593
+ */
30594
+ var MinDwellSecField = number().min(0).max(60);
30595
+ /**
30596
+ * Caption burned into the notification's preview frame.
30597
+ *
30598
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
30599
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
30600
+ * templating dialect for one field would be a second thing to explain.
30601
+ *
30602
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
30603
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
30604
+ * the reason this is not `.min(1)`.
30605
+ */
30606
+ var PreviewTextField = string().max(200);
30607
+ /**
30608
+ * Whether the notification's preview is a STILL or a short animation.
30609
+ *
30610
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
30611
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
30612
+ * night reads better as three seconds of motion than as one frame of it. Both
30613
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
30614
+ * simply applies it to a dozen frames sampled across the render and assembles
30615
+ * them.
30616
+ *
30617
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
30618
+ * seeks and a palette pass, and no rule that never asked for one should start
30619
+ * paying that on the deploy that shipped it.
30620
+ *
30621
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
30622
+ */
30623
+ var PreviewModeField = _enum(["image", "gif"]);
30624
+ /**
30625
+ * Which detection classes the notification reports counts for.
30626
+ *
30627
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
30628
+ * plan — no second query — aggregated per class. Absent or empty means "every
30629
+ * class the window actually contained", which is what an operator who never
30630
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
30631
+ * counts cars all night).
30632
+ *
30633
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
30634
+ * …). An unknown name simply never matches and reports nothing — it is not an
30635
+ * error, because a rule may legitimately name a class this camera's model does
30636
+ * not emit.
30637
+ *
30638
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
30639
+ * - `{{detections}}` — total over the reported classes
30640
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
30641
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
30642
+ * one per class, `count_` + the class name
30643
+ *
30644
+ * With NO custom body template the summary is appended to the derived body, and
30645
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
30646
+ * reads. With a custom template the operator owns every word — nothing is
30647
+ * appended, so `{{detectionSummary}}` is how he asks for it.
30648
+ */
30649
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
30650
+ /**
30081
30651
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30082
30652
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30083
30653
  * here (see the ownership note above).
@@ -30097,9 +30667,30 @@ var TimelapseRuleInputSchema = object({
30097
30667
  cadenceSec: CadenceSecField.default(15),
30098
30668
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30099
30669
  framerate: FramerateField.default(10),
30670
+ /**
30671
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
30672
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
30673
+ * field gets.
30674
+ */
30675
+ denseCadenceSec: DenseCadenceSecField.optional(),
30676
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
30677
+ minDwellSec: MinDwellSecField.optional(),
30100
30678
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30101
30679
  targets: TargetsField,
30102
30680
  template: TimelapseTemplateSchema.optional(),
30681
+ /**
30682
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
30683
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
30684
+ *
30685
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
30686
+ * the notification's title/body, and clearing it (`template: null`) must not
30687
+ * silently clear the caption too.
30688
+ */
30689
+ previewText: PreviewTextField.optional(),
30690
+ /** Still or animation — see {@link PreviewModeField}. */
30691
+ previewMode: PreviewModeField.default("image"),
30692
+ /** Classes the notification counts — see {@link ReportClassesField}. */
30693
+ reportClasses: ReportClassesField.optional(),
30103
30694
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30104
30695
  priority: PriorityField.default(3)
30105
30696
  });
@@ -30110,8 +30701,13 @@ object({
30110
30701
  schedule: NcScheduleSchema.optional(),
30111
30702
  cadenceSec: CadenceSecField.optional(),
30112
30703
  framerate: FramerateField.optional(),
30704
+ denseCadenceSec: DenseCadenceSecField.optional(),
30705
+ minDwellSec: MinDwellSecField.optional(),
30113
30706
  targets: TargetsField.optional(),
30114
30707
  template: TimelapseTemplateSchema.nullable().optional(),
30708
+ previewText: PreviewTextField.optional(),
30709
+ previewMode: PreviewModeField.optional(),
30710
+ reportClasses: ReportClassesField.optional(),
30115
30711
  priority: PriorityField.optional()
30116
30712
  });
30117
30713
  TimelapseRuleInputSchema.extend({
@@ -30123,10 +30719,28 @@ TimelapseRuleInputSchema.extend({
30123
30719
  */
30124
30720
  ownerUserId: string().optional(),
30125
30721
  /**
30126
- * Epoch-ms of the last successful generation — the 1-hour re-generation
30127
- * guard's durable state (predecessor parity). Absent = never generated.
30722
+ * Epoch-ms of the NEWEST successful generation across every camera of this
30723
+ * rule. What a UI shows, and the compatibility floor for
30724
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30128
30725
  */
30129
30726
  lastGeneratedAt: number().optional(),
30727
+ /**
30728
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
30729
+ * re-generation guard's real durable state.
30730
+ *
30731
+ * One rule covers several cameras and each renders its own video, so a rule
30732
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
30733
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
30734
+ * already done — and B's night is gone for good, because the window will not
30735
+ * come back.
30736
+ *
30737
+ * ADDITIVE, so the migration is free: a row written before this field simply
30738
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
30739
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
30740
+ * "never generated" would re-render and re-notify every camera of every rule
30741
+ * once, on the deploy that shipped the map.
30742
+ */
30743
+ generatedByDevice: record(string(), number()).optional(),
30130
30744
  /** userId of the caller who created the rule (server-stamped). */
30131
30745
  createdBy: string(),
30132
30746
  createdAt: number(),
@@ -30177,25 +30791,32 @@ object({
30177
30791
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30178
30792
  object({
30179
30793
  /**
30180
- * How long a retained native frame is served before it counts as a miss.
30794
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
30795
+ * detection result.
30796
+ *
30797
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
30798
+ * a time window was never related to the event the pixels were waiting for.
30799
+ * A held frame now lives from delivery until the runner has its `FrameResult`
30800
+ * — at which moment the runner cuts the subject tiles it actually wanted and
30801
+ * releases the frame. The bound exists only so a runner that stops answering
30802
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
30181
30803
  *
30182
- * Must cover the FULL late-crop horizon: detection inference + the
30183
- * cross-process inference-result hop to hub post-analysis + tracking + the
30184
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30185
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30186
- * RAM per busy camera grows linearly with no measured hit-rate gain.
30804
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
30805
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
30806
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
30807
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
30808
+ * `holdOverflow` on the metrics line is what says you need it.
30187
30809
  */
30188
- ttlMs: number().int().min(250).max(1e4),
30810
+ holdFrames: number().int().min(1).max(64),
30189
30811
  /**
30190
30812
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30191
30813
  *
30192
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30193
- * which one is actually binding before reasoning from that. At the shipped
30194
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30195
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30196
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30197
- * change that admits fewer frames buys retention WINDOW at constant RAM
30198
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
30814
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
30815
+ * is what decides how much is held, and the ceiling is the number above which
30816
+ * something is wrong. Before that it was the effective cap — at 1024 MB with
30817
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
30818
+ * with the TTL expiring nothing, which is exactly the confusion the hold
30819
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30199
30820
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30200
30821
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30201
30822
  * to replace).
@@ -30221,22 +30842,45 @@ object({
30221
30842
  * there is the signal that some caller names frames outside the inference set
30222
30843
  * and that this must go back to `all`.
30223
30844
  */
30224
- admission: NativeLeaseAdmissionSchema
30845
+ admission: NativeLeaseAdmissionSchema,
30846
+ /**
30847
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
30848
+ * compressed native crops the worker cuts at the moment a frame's detection
30849
+ * result arrives, and keeps long after the frame itself is freed.
30850
+ *
30851
+ * This is the knob that replaced the old retention window, and it buys about
30852
+ * three orders of magnitude more of it: a tile is one subject at native
30853
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
30854
+ * the frame it was cut from. A frame on which nothing was detected costs
30855
+ * nothing at all, which is the real change — the old lease paid per FRAME and
30856
+ * was interrogated per SUBJECT.
30857
+ *
30858
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
30859
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
30860
+ * reproduce that.
30861
+ */
30862
+ tileBudgetMb: number().int().min(0).max(1024)
30225
30863
  });
30226
30864
  /**
30227
- * The values in force when the operator has set nothing — byte-for-byte the
30228
- * constants the decode worker shipped with as env-var defaults, so making these
30229
- * settings changed no behaviour on the day it landed.
30865
+ * The values in force when the operator has set nothing.
30866
+ *
30867
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
30868
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
30869
+ * in the same change that redefines it would make a regression and a retune
30870
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
30871
+ * live traffic.
30230
30872
  */
30231
30873
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30232
- ttlMs: 1200,
30874
+ holdFrames: 8,
30233
30875
  budgetMb: 1024,
30234
30876
  activityMs: 15e3,
30877
+ tileBudgetMb: 64,
30235
30878
  admission: "inferred"
30236
30879
  };
30237
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
30880
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30238
30881
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30239
30882
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
30883
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30240
30884
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30241
30885
  //#endregion
30242
30886
  export { EventCategory as i, networkAccessCapability as n, BaseAddon as r, meshNetworkCapability as t };