@camstack/addon-auth 1.2.14 → 1.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7319,8 +7319,31 @@ var AdoptionJobSchema = object({
7319
7319
  error: string().nullable()
7320
7320
  });
7321
7321
  /**
7322
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7323
- * pipeline functions an operator thinks in terms of.
7322
+ * Per-camera FUNCTION SWITCHES.
7323
+ *
7324
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7325
+ *
7326
+ * This file shipped as "the one coherent on/off surface over the pipeline
7327
+ * functions an operator thinks in terms of". The operator's verdict on
7328
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7329
+ * every function already had a settings page of its own, and a second place to
7330
+ * turn it off is a second place to look. Each switch is going back to its own
7331
+ * component's original options — detection to the detection-pipeline wrapper
7332
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7333
+ * (which was always first-class; the switch was a veneer over
7334
+ * `recording.setDeviceConfig`), notifications to a notification-center
7335
+ * per-device setting, the two camera planes to their own components.
7336
+ *
7337
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7338
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7339
+ * straight from the authorities with no group in the middle. That rule was
7340
+ * never about a control panel.
7341
+ *
7342
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7343
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7344
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7345
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7346
+ * stop; nothing new may be built on it.
7324
7347
  *
7325
7348
  * ## This file adds no state
7326
7349
  *
@@ -7671,7 +7694,15 @@ var RecordingConfigSchema = object({
7671
7694
  * Each completed/failed run also lands one durable ops-log row on its owning
7672
7695
  * addon surface.
7673
7696
  */
7697
+ /**
7698
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7699
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7700
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7701
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7702
+ * runs at all.
7703
+ */
7674
7704
  var RelocateJobStateSchema = _enum([
7705
+ "queued",
7675
7706
  "running",
7676
7707
  "done",
7677
7708
  "failed",
@@ -7706,6 +7737,15 @@ var RelocateFootageInputSchema = object({
7706
7737
  /** Limits relocation to the logical profile class. Omit only for the
7707
7738
  * pre-orchestration compatibility path. */
7708
7739
  footageClass: RelocateFootageClassSchema.optional(),
7740
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7741
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7742
+ * unit is a (camera, profile) pile, not a disk. */
7743
+ deviceId: number().int().optional(),
7744
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7745
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7746
+ * placement plan assigns those two independently, so a rebalance that could
7747
+ * only say "recordings" would move footage the plan never asked to move. */
7748
+ profiles: array(string()).optional(),
7709
7749
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7710
7750
  * never allowed to starve live writers. */
7711
7751
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7841,6 +7881,21 @@ var StorageLocationSchema = object({
7841
7881
  nodeId: string().optional(),
7842
7882
  isDefault: boolean().default(false),
7843
7883
  isSystem: boolean().default(false),
7884
+ /**
7885
+ * Operator opt-in: whether consumers that BALANCE across several locations
7886
+ * of a type may write here. Recordings reads it today; event media and
7887
+ * backups are the next consumers, which is why the flag lives on the
7888
+ * location rather than in any one addon's store — nothing has to be
7889
+ * extended to add the next consumer.
7890
+ *
7891
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7892
+ * flag existed reads back with no flag and keeps working exactly as before;
7893
+ * that is the whole compat story, and it is why no migration ships with it.
7894
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7895
+ * disk must not silently start writing to it); the default of a type is
7896
+ * always stamped `true`.
7897
+ */
7898
+ enabled: boolean().optional(),
7844
7899
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7845
7900
  * for node-local locations it can reach) — never persisted, absent when the
7846
7901
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12181,7 +12236,8 @@ method(object({
12181
12236
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12182
12237
  /**
12183
12238
  * filesystem-browse — per-node capability for browsing the node's local
12184
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12239
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12240
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12185
12241
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12186
12242
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12187
12243
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14002,6 +14058,13 @@ var MaskGridDimsSchema = object({
14002
14058
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14003
14059
  * this one field keeps the schema additive — a rule still declares exactly
14004
14060
  * one trigger.
14061
+ *
14062
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14063
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14064
+ * mirror.ts` fails the build on a member the app cannot render) and every
14065
+ * member costs a release train. A sustained-sound rule is therefore an
14066
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14067
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14005
14068
  */
14006
14069
  var NcDeliverySchema = _enum([
14007
14070
  "immediate",
@@ -14016,15 +14079,32 @@ var NcDeliverySchema = _enum([
14016
14079
  * depend on a provider's raw event name or payload shape.
14017
14080
  */
14018
14081
  var NcSystemEventKindSchema = _enum([
14019
- "camera-online",
14020
- "camera-offline",
14082
+ "device-online",
14083
+ "device-offline",
14084
+ "device-disabled",
14085
+ "device-enabled",
14021
14086
  "stream-online",
14022
14087
  "stream-offline",
14023
14088
  "node-online",
14024
14089
  "node-offline",
14025
14090
  "addon-update-available",
14026
- "server-update-available"
14091
+ "server-update-available",
14092
+ "alarm-triggered",
14093
+ "alarm-armed",
14094
+ "alarm-disarmed",
14095
+ "camera-online",
14096
+ "camera-offline",
14097
+ "camera-disabled",
14098
+ "camera-enabled"
14099
+ ]);
14100
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14101
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14102
+ "camera-online",
14103
+ "camera-offline",
14104
+ "camera-disabled",
14105
+ "camera-enabled"
14027
14106
  ]);
14107
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14028
14108
  /**
14029
14109
  * One coherent system-event condition. `kinds` is the required opt-in safety
14030
14110
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14033,6 +14113,18 @@ var NcSystemEventKindSchema = _enum([
14033
14113
  var NcSystemEventConditionSchema = object({
14034
14114
  kinds: array(NcSystemEventKindSchema).min(1),
14035
14115
  deviceIds: array(number().int()).min(1).optional(),
14116
+ /**
14117
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14118
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14119
+ * is what a liveness rule means when nobody said otherwise.
14120
+ *
14121
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14122
+ * one reason: the intake cannot know which devices this household cares
14123
+ * about, and a producer-side filter is one no operator can change. Fails
14124
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14125
+ * does not carry) matches no `deviceTypes` list.
14126
+ */
14127
+ deviceTypes: array(string().min(1)).min(1).optional(),
14036
14128
  nodeIds: array(string().min(1)).min(1).optional(),
14037
14129
  packageNames: array(string().min(1)).min(1).optional()
14038
14130
  });
@@ -14083,6 +14175,47 @@ var NcOccupancyConditionSchema = object({
14083
14175
  sustainSeconds: number().int().min(0).max(3600).default(15)
14084
14176
  });
14085
14177
  /**
14178
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14179
+ *
14180
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14181
+ * reference notifier uses, so an operator moving between them re-uses what
14182
+ * they already know): a rule matches when, over a sampling window of
14183
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14184
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14185
+ *
14186
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14187
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14188
+ * - `labels` — the classifier put at least one of these labels on it.
14189
+ *
14190
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14191
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14192
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14193
+ * is given** — a window in which every sample is trivially a hit would fire on
14194
+ * silence, so the engine refuses such a condition rather than notifying on
14195
+ * nothing (the schema cannot express "at least one of" without becoming a
14196
+ * ZodEffects the cap path would have to special-case).
14197
+ *
14198
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14199
+ * must be FULL before it can match — a window that has been open for two
14200
+ * seconds of its ten is 100% of nothing, and firing on it would make
14201
+ * `samplingSeconds` decorative.
14202
+ *
14203
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14204
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14205
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14206
+ * an operator who typed `dog` mean the same thing.
14207
+ */
14208
+ var NcAudioConditionSchema = object({
14209
+ /** Audio macro labels; absent = any sound (level-only rule). */
14210
+ labels: array(string().min(1)).min(1).optional(),
14211
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14212
+ dbThreshold: number().min(-96).max(0).optional(),
14213
+ /** Percentage of the window's samples that must be hits (1–100). */
14214
+ hitPercent: number().int().min(1).max(100).default(60),
14215
+ /** Length of the sampling window in seconds. */
14216
+ samplingSeconds: number().int().min(1).max(300).default(10)
14217
+ });
14218
+ /**
14086
14219
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14087
14220
  *
14088
14221
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14355,7 +14488,33 @@ var NcConditionsSchema = object({
14355
14488
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14356
14489
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14357
14490
  */
14358
- occupancy: NcOccupancyConditionSchema.optional()
14491
+ occupancy: NcOccupancyConditionSchema.optional(),
14492
+ /**
14493
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14494
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14495
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14496
+ * a window that is not full yet, neither filter given). See
14497
+ * {@link NcAudioCondition}.
14498
+ *
14499
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14500
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14501
+ * a detection, a track or a device event (the same fail-closed pairing
14502
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14503
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14504
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14505
+ * classified sample) stays exactly as it was for rules that already use it.
14506
+ *
14507
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14508
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14509
+ * (`camstack/src/data/notification-center.ts`, guarded by
14510
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14511
+ * condition fields it does not know when a rule is saved from the phone.
14512
+ * Publishing an editor for a condition the app cannot round-trip is how an
14513
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14514
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14515
+ * does an audio rule become authorable.
14516
+ */
14517
+ audio: NcAudioConditionSchema.optional()
14359
14518
  });
14360
14519
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14361
14520
  var NcRuleTargetSchema = object({
@@ -14469,6 +14628,73 @@ var NcThrottleSchema = object({
14469
14628
  */
14470
14629
  granularity: NcThrottleGranularitySchema.optional()
14471
14630
  });
14631
+ /**
14632
+ * How long the confirm gate may hold ONE notification, and how big the picture
14633
+ * it judges may be.
14634
+ *
14635
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14636
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14637
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14638
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14639
+ * tokens for pixels the model pools away.
14640
+ */
14641
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14642
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14643
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14644
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14645
+ var NcConfirmExpectSchema = object({
14646
+ op: _enum([
14647
+ ">=",
14648
+ ">",
14649
+ "<=",
14650
+ "<",
14651
+ "=="
14652
+ ]),
14653
+ count: number().int().min(0).max(1e3)
14654
+ });
14655
+ /**
14656
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14657
+ * to ship and says whether it agrees with the rule.
14658
+ *
14659
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14660
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14661
+ * on the operator's phone is not a verdict about this notification.
14662
+ *
14663
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14664
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14665
+ * the default and every fail-open is COUNTED, because a gate that always fails
14666
+ * open looks in the log exactly like a gate that works.
14667
+ *
14668
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14669
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14670
+ * production failures in one day), so the gate reads absent as the constant
14671
+ * above rather than trusting a parse it may never have seen.
14672
+ */
14673
+ var NcConfirmSchema = object({
14674
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14675
+ * same thing, and both mean "deliver exactly as before". */
14676
+ enabled: boolean().default(false),
14677
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14678
+ profileId: string().optional(),
14679
+ /**
14680
+ * The operator's question, in his own words. Absent = a question derived
14681
+ * from the rule (its class and its expectation).
14682
+ *
14683
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14684
+ * banners, signage and plates as instructions if you let them reach the
14685
+ * prompt — proven live — so the authoritative contract stays in the system
14686
+ * turn and only rule-authored words land here.
14687
+ */
14688
+ prompt: string().max(1e3).optional(),
14689
+ /** Fire only when the model's count satisfies this. Absent = the model's
14690
+ * own boolean verdict decides. */
14691
+ expect: NcConfirmExpectSchema.optional(),
14692
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14693
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14694
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14695
+ /** Longest edge the judged image is downscaled to before it is sent. */
14696
+ maxImagePx: number().int().min(64).max(2048).default(448)
14697
+ });
14472
14698
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14473
14699
  var NcRuleInputSchema = object({
14474
14700
  name: string().min(1).max(200),
@@ -14529,7 +14755,13 @@ var NcRuleInputSchema = object({
14529
14755
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14530
14756
  * shape as every other actuation.
14531
14757
  */
14532
- actions: NcRuleActionsSchema.optional()
14758
+ actions: NcRuleActionsSchema.optional(),
14759
+ /**
14760
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14761
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14762
+ * did, and absent is the only way to say that without a migration.
14763
+ */
14764
+ confirm: NcConfirmSchema.optional()
14533
14765
  });
14534
14766
  /**
14535
14767
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14540,7 +14772,37 @@ var NcRuleInputSchema = object({
14540
14772
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14541
14773
  * `updateRule` patch.
14542
14774
  */
14543
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14775
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14776
+ disabledTargetIds: array(string()).optional(),
14777
+ /**
14778
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14779
+ *
14780
+ * It makes the key optional to SUPPLY; the parse still materialises the
14781
+ * default when the key is absent. And `NcRuleStore.update` merges with
14782
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14783
+ * one — which made every partial edit destructive:
14784
+ *
14785
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14786
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14787
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14788
+ *
14789
+ * A rule scoped to one camera and one zone silently became a rule that
14790
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14791
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14792
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14793
+ * within a minute of a two-field patch.
14794
+ *
14795
+ * So every defaulted field is re-declared here WITHOUT its default. The
14796
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14797
+ * conditions remains a real instruction ("clear them") — and only the
14798
+ * absent key is now genuinely absent.
14799
+ */
14800
+ enabled: boolean().optional(),
14801
+ conditions: NcConditionsSchema.optional(),
14802
+ media: NcMediaPolicySchema.optional(),
14803
+ throttle: NcThrottleSchema.optional(),
14804
+ priority: number().int().min(1).max(5).optional()
14805
+ });
14544
14806
  /** A persisted rule. */
14545
14807
  var NcRuleSchema = NcRuleInputSchema.extend({
14546
14808
  id: string(),
@@ -14841,6 +15103,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14841
15103
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14842
15104
  * copy would lie the first time a rule is disabled.
14843
15105
  */
15106
+ /**
15107
+ * Why a device a mode NAMES is nonetheless not armed by it.
15108
+ *
15109
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15110
+ * per-camera notification switch the Notification Center already owns,
15111
+ * `detection-off` is the device's own detection binding being inactive, and
15112
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15113
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15114
+ * with the switches the operator actually used.
15115
+ */
15116
+ var NcAlarmSkipReasonSchema = _enum([
15117
+ "muted",
15118
+ "detection-off",
15119
+ "offline"
15120
+ ]);
15121
+ var NcAlarmSkippedDeviceSchema = object({
15122
+ deviceId: number().int(),
15123
+ reason: NcAlarmSkipReasonSchema
15124
+ });
14844
15125
  var NcAlarmModeCoverageSchema = object({
14845
15126
  mode: AlarmArmModeSchema,
14846
15127
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14848,7 +15129,18 @@ var NcAlarmModeCoverageSchema = object({
14848
15129
  /** At least one covering rule has no device scope, so the mode covers all. */
14849
15130
  allDevices: boolean(),
14850
15131
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14851
- deviceIds: array(number().int())
15132
+ deviceIds: array(number().int()),
15133
+ /**
15134
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15135
+ * excludes it.
15136
+ *
15137
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15138
+ * twelve makes it false in exactly the way nobody notices until an incident.
15139
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15140
+ * still parses as "nothing known to be skipped" rather than failing the whole
15141
+ * alarm tab.
15142
+ */
15143
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14852
15144
  });
14853
15145
  var NcAlarmConfigSchema = object({
14854
15146
  /**
@@ -17647,9 +17939,16 @@ var CameraStatusSchema = object({
17647
17939
  audio: CameraAudioStatusSchema.nullable(),
17648
17940
  recording: CameraRecordingStatusSchema.nullable(),
17649
17941
  /**
17650
- * Per-camera function switches an OPERATOR has turned off
17942
+ * Per-camera functions an OPERATOR has turned off
17651
17943
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17652
17944
  *
17945
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
17946
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
17947
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
17948
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
17949
+ * The badge outlives the control panel: the panel was a convenience, this is
17950
+ * the difference between a camera being off and a camera being dead.
17951
+ *
17653
17952
  * This is the difference between DISABLED and BROKEN. A camera whose
17654
17953
  * `detection` block reports zero fps and whose `switchedOff` contains
17655
17954
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -23175,7 +23474,19 @@ var RecordingManifestSchema = object({
23175
23474
  * profiles/subtrees/locations on this node). */
23176
23475
  var RecordingDeviceUsageSchema = object({
23177
23476
  deviceId: number(),
23178
- usedBytes: number()
23477
+ usedBytes: number(),
23478
+ /**
23479
+ * Start of this camera's OLDEST indexed segment, across every profile and
23480
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23481
+ * only honest answer to "is retention actually holding?" per camera.
23482
+ *
23483
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23484
+ * predates this field omits it entirely, and a hub whose types carry the
23485
+ * field must keep validating that older provider's payload: the framework
23486
+ * (types) and the addon ship on different trains, and the addon is usually
23487
+ * the later of the two.
23488
+ */
23489
+ oldestMs: number().nullable().optional()
23179
23490
  });
23180
23491
  /** Recording storage usage + capacity for one storage location. */
23181
23492
  var RecordingLocationUsageSchema = object({
@@ -23203,6 +23514,57 @@ var RecordingStorageUsageSchema = object({
23203
23514
  locations: array(RecordingLocationUsageSchema)
23204
23515
  });
23205
23516
  /**
23517
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23518
+ *
23519
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23520
+ * is the operator asking for the EXISTING archive to be brought into line with
23521
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23522
+ * location, run FIFO behind the single-flight mover.
23523
+ *
23524
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23525
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23526
+ * (empty on the plan).
23527
+ */
23528
+ var RecordingRebalanceMoveSchema = object({
23529
+ deviceId: number(),
23530
+ profile: string(),
23531
+ fromLocationId: string(),
23532
+ toLocationId: string(),
23533
+ bytes: number(),
23534
+ files: number().int()
23535
+ });
23536
+ /** Why a pile that is out of place is staying there. Every refusal is
23537
+ * reported: a rebalance that silently drops a camera reads exactly like one
23538
+ * that had nothing to do. */
23539
+ var RecordingRebalanceSkipReasonSchema = _enum([
23540
+ "unassigned",
23541
+ "target-not-writable",
23542
+ "below-threshold",
23543
+ "no-headroom"
23544
+ ]);
23545
+ var RecordingRebalanceSkipSchema = object({
23546
+ deviceId: number(),
23547
+ profile: string(),
23548
+ fromLocationId: string(),
23549
+ /** The location the plan wants; null when the camera has no assignment. */
23550
+ toLocationId: string().nullable(),
23551
+ bytes: number(),
23552
+ reason: RecordingRebalanceSkipReasonSchema
23553
+ });
23554
+ var RecordingRebalancePlanSchema = object({
23555
+ moves: array(RecordingRebalanceMoveSchema),
23556
+ skipped: array(RecordingRebalanceSkipSchema),
23557
+ bytesToMove: number(),
23558
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23559
+ jobIds: array(string())
23560
+ });
23561
+ var RecordingRebalanceInputSchema = object({
23562
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23563
+ throttleMbps: number().min(1).max(1e3).optional(),
23564
+ /** Ignore piles smaller than this (default 1 GB). */
23565
+ minMoveGb: number().min(0).optional()
23566
+ });
23567
+ /**
23206
23568
  * Result of locating footage at a wall-clock instant for one device/profile.
23207
23569
  * `segment` carries the covering segment's window; `gap` reports the forward
23208
23570
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23365,9 +23727,24 @@ method(object({
23365
23727
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23366
23728
  kind: "mutation",
23367
23729
  auth: "admin"
23730
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23731
+ kind: "mutation",
23732
+ auth: "admin"
23733
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23734
+ kind: "query",
23735
+ auth: "admin"
23736
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23737
+ kind: "mutation",
23738
+ auth: "admin"
23739
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23740
+ kind: "query",
23741
+ auth: "admin"
23742
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23743
+ kind: "mutation",
23744
+ auth: "admin"
23368
23745
  });
23369
23746
  /**
23370
- * `recordingExport` cap — render a footage time range into a single downloadable
23747
+ * `recording-export` cap — render a footage time range into a single downloadable
23371
23748
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23372
23749
  * bounded lifetime with a durable history, auto-expiry, and optional
23373
23750
  * delete-after-download.
@@ -23382,10 +23759,53 @@ method(object({
23382
23759
  */
23383
23760
  /** Playback-speed multiplier for the render (1 = realtime). */
23384
23761
  var ExportSpeedSchema = number().min(.25).max(32);
23762
+ /**
23763
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23764
+ *
23765
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23766
+ * derives these bounds from things that happened at a TIME (a track's
23767
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23768
+ * every segment present for the range, with each recording GAP removed. The
23769
+ * two agree only on a window that recorded without one interruption, and only
23770
+ * the render side knows the segments, so the translation lives there
23771
+ * (`export-dense-map.ts`, addon-pipeline).
23772
+ *
23773
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23774
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23775
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23776
+ * the video was a uniform timelapse, and the log line reported the five ranges
23777
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23778
+ *
23779
+ * Relative and not absolute epoch, because an absolute epoch would make every
23780
+ * call site responsible for the same subtraction.
23781
+ */
23782
+ var ExportDenseRangeSchema = object({
23783
+ fromSec: number().nonnegative(),
23784
+ toSec: number().nonnegative()
23785
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23786
+ /**
23787
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23788
+ * listed ranges and at the base `everyMs` everywhere else.
23789
+ *
23790
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23791
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23792
+ */
23793
+ var ExportDenseSchema = object({
23794
+ everyMs: number().int().positive(),
23795
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23796
+ });
23385
23797
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23386
23798
  var ExportTimelapseSchema = object({
23387
23799
  everyMs: number().int().positive(),
23388
- outputFps: number().int().min(1).max(60).optional()
23800
+ outputFps: number().int().min(1).max(60).optional(),
23801
+ /** Optional second, FASTER rate over the intervals that matter. */
23802
+ dense: ExportDenseSchema.optional()
23803
+ }).superRefine((v, ctx) => {
23804
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23805
+ code: ZodIssueCode.custom,
23806
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23807
+ path: ["dense", "everyMs"]
23808
+ });
23389
23809
  });
23390
23810
  /**
23391
23811
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23443,6 +23863,19 @@ var ExportDownloadSchema = object({
23443
23863
  url: string(),
23444
23864
  endpoints: array(string())
23445
23865
  });
23866
+ /**
23867
+ * A finished export's bytes, inline.
23868
+ *
23869
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23870
+ * against, so nobody has to infer it from the base64 length.
23871
+ */
23872
+ var ExportBytesSchema = object({
23873
+ base64: string(),
23874
+ contentType: string(),
23875
+ /** Suggested filename, extension included. */
23876
+ name: string(),
23877
+ bytes: number().int().nonnegative()
23878
+ });
23446
23879
  method(object({
23447
23880
  deviceId: number(),
23448
23881
  profile: string(),
@@ -23467,6 +23900,9 @@ method(object({
23467
23900
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23468
23901
  kind: "query",
23469
23902
  auth: "protected"
23903
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
23904
+ kind: "query",
23905
+ auth: "protected"
23470
23906
  });
23471
23907
  /**
23472
23908
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -28660,6 +29096,12 @@ Object.freeze({
28660
29096
  addonId: null,
28661
29097
  access: "create"
28662
29098
  },
29099
+ "recording.cancelRelocateJob": {
29100
+ capName: "recording",
29101
+ capScope: "system",
29102
+ addonId: null,
29103
+ access: "create"
29104
+ },
28663
29105
  "recording.cancelStorageMigrationMove": {
28664
29106
  capName: "recording",
28665
29107
  capScope: "system",
@@ -28714,6 +29156,12 @@ Object.freeze({
28714
29156
  addonId: null,
28715
29157
  access: "view"
28716
29158
  },
29159
+ "recording.listRelocateJobs": {
29160
+ capName: "recording",
29161
+ capScope: "system",
29162
+ addonId: null,
29163
+ access: "view"
29164
+ },
28717
29165
  "recording.locateSegment": {
28718
29166
  capName: "recording",
28719
29167
  capScope: "system",
@@ -28726,6 +29174,12 @@ Object.freeze({
28726
29174
  addonId: null,
28727
29175
  access: "create"
28728
29176
  },
29177
+ "recording.planStorageRebalance": {
29178
+ capName: "recording",
29179
+ capScope: "system",
29180
+ addonId: null,
29181
+ access: "view"
29182
+ },
28729
29183
  "recording.pruneFootage": {
28730
29184
  capName: "recording",
28731
29185
  capScope: "system",
@@ -28750,6 +29204,12 @@ Object.freeze({
28750
29204
  addonId: null,
28751
29205
  access: "create"
28752
29206
  },
29207
+ "recording.relocateFootage": {
29208
+ capName: "recording",
29209
+ capScope: "system",
29210
+ addonId: null,
29211
+ access: "create"
29212
+ },
28753
29213
  "recording.renderClip": {
28754
29214
  capName: "recording",
28755
29215
  capScope: "system",
@@ -28786,38 +29246,50 @@ Object.freeze({
28786
29246
  addonId: null,
28787
29247
  access: "create"
28788
29248
  },
29249
+ "recording.startStorageRebalance": {
29250
+ capName: "recording",
29251
+ capScope: "system",
29252
+ addonId: null,
29253
+ access: "create"
29254
+ },
28789
29255
  "recordingExport.cancelExport": {
28790
- capName: "recordingExport",
29256
+ capName: "recording-export",
28791
29257
  capScope: "system",
28792
29258
  addonId: null,
28793
29259
  access: "create"
28794
29260
  },
28795
29261
  "recordingExport.createExport": {
28796
- capName: "recordingExport",
29262
+ capName: "recording-export",
28797
29263
  capScope: "system",
28798
29264
  addonId: null,
28799
29265
  access: "create"
28800
29266
  },
28801
29267
  "recordingExport.deleteExport": {
28802
- capName: "recordingExport",
29268
+ capName: "recording-export",
28803
29269
  capScope: "system",
28804
29270
  addonId: null,
28805
29271
  access: "delete"
28806
29272
  },
28807
29273
  "recordingExport.getDownloadUrl": {
28808
- capName: "recordingExport",
29274
+ capName: "recording-export",
28809
29275
  capScope: "system",
28810
29276
  addonId: null,
28811
29277
  access: "view"
28812
29278
  },
28813
29279
  "recordingExport.getExport": {
28814
- capName: "recordingExport",
29280
+ capName: "recording-export",
28815
29281
  capScope: "system",
28816
29282
  addonId: null,
28817
29283
  access: "view"
28818
29284
  },
28819
29285
  "recordingExport.listExports": {
28820
- capName: "recordingExport",
29286
+ capName: "recording-export",
29287
+ capScope: "system",
29288
+ addonId: null,
29289
+ access: "view"
29290
+ },
29291
+ "recordingExport.readExportBytes": {
29292
+ capName: "recording-export",
28821
29293
  capScope: "system",
28822
29294
  addonId: null,
28823
29295
  access: "view"
@@ -30194,6 +30666,104 @@ var FramerateField = number().int().min(1).max(60);
30194
30666
  var TargetsField = array(NcRuleTargetSchema).min(1);
30195
30667
  var PriorityField = number().int().min(1).max(5);
30196
30668
  /**
30669
+ * Explicit override of the DENSE sampling cadence, seconds.
30670
+ *
30671
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
30672
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
30673
+ * made that same base 3 s and rendered a person pass as two frames.)
30674
+ *
30675
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
30676
+ * `denseCadenceSec` and played at `framerate` occupies
30677
+ *
30678
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
30679
+ *
30680
+ * 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.
30681
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
30682
+ * and therefore the length of a quiet night, does not move.
30683
+ *
30684
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
30685
+ * the recording has them returns the same frames, requested twice. Must be
30686
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
30687
+ * a uniform video the operator believes is two-rate — and upsert refuses it
30688
+ * rather than letting the export cap reject the render hours after the window.
30689
+ */
30690
+ var DenseCadenceSecField = number().min(.1).max(3600);
30691
+ /**
30692
+ * Minimum seconds of OUTPUT video each detection range must occupy.
30693
+ *
30694
+ * The operator-facing form of the arithmetic above: instead of solving for a
30695
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
30696
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
30697
+ * that range every ~583 ms.
30698
+ *
30699
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
30700
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
30701
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
30702
+ * ranges are sampled denser than they need. Per-range cadences require a cap
30703
+ * schema change and are the tracked follow-up.
30704
+ *
30705
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
30706
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
30707
+ * by real footage, never met by duplicating frames into motion that never
30708
+ * happened.
30709
+ */
30710
+ var MinDwellSecField = number().min(0).max(60);
30711
+ /**
30712
+ * Caption burned into the notification's preview frame.
30713
+ *
30714
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
30715
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
30716
+ * templating dialect for one field would be a second thing to explain.
30717
+ *
30718
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
30719
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
30720
+ * the reason this is not `.min(1)`.
30721
+ */
30722
+ var PreviewTextField = string().max(200);
30723
+ /**
30724
+ * Whether the notification's preview is a STILL or a short animation.
30725
+ *
30726
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
30727
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
30728
+ * night reads better as three seconds of motion than as one frame of it. Both
30729
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
30730
+ * simply applies it to a dozen frames sampled across the render and assembles
30731
+ * them.
30732
+ *
30733
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
30734
+ * seeks and a palette pass, and no rule that never asked for one should start
30735
+ * paying that on the deploy that shipped it.
30736
+ *
30737
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
30738
+ */
30739
+ var PreviewModeField = _enum(["image", "gif"]);
30740
+ /**
30741
+ * Which detection classes the notification reports counts for.
30742
+ *
30743
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
30744
+ * plan — no second query — aggregated per class. Absent or empty means "every
30745
+ * class the window actually contained", which is what an operator who never
30746
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
30747
+ * counts cars all night).
30748
+ *
30749
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
30750
+ * …). An unknown name simply never matches and reports nothing — it is not an
30751
+ * error, because a rule may legitimately name a class this camera's model does
30752
+ * not emit.
30753
+ *
30754
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
30755
+ * - `{{detections}}` — total over the reported classes
30756
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
30757
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
30758
+ * one per class, `count_` + the class name
30759
+ *
30760
+ * With NO custom body template the summary is appended to the derived body, and
30761
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
30762
+ * reads. With a custom template the operator owns every word — nothing is
30763
+ * appended, so `{{detectionSummary}}` is how he asks for it.
30764
+ */
30765
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
30766
+ /**
30197
30767
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30198
30768
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30199
30769
  * here (see the ownership note above).
@@ -30213,9 +30783,30 @@ var TimelapseRuleInputSchema = object({
30213
30783
  cadenceSec: CadenceSecField.default(15),
30214
30784
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30215
30785
  framerate: FramerateField.default(10),
30786
+ /**
30787
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
30788
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
30789
+ * field gets.
30790
+ */
30791
+ denseCadenceSec: DenseCadenceSecField.optional(),
30792
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
30793
+ minDwellSec: MinDwellSecField.optional(),
30216
30794
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30217
30795
  targets: TargetsField,
30218
30796
  template: TimelapseTemplateSchema.optional(),
30797
+ /**
30798
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
30799
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
30800
+ *
30801
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
30802
+ * the notification's title/body, and clearing it (`template: null`) must not
30803
+ * silently clear the caption too.
30804
+ */
30805
+ previewText: PreviewTextField.optional(),
30806
+ /** Still or animation — see {@link PreviewModeField}. */
30807
+ previewMode: PreviewModeField.default("image"),
30808
+ /** Classes the notification counts — see {@link ReportClassesField}. */
30809
+ reportClasses: ReportClassesField.optional(),
30219
30810
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30220
30811
  priority: PriorityField.default(3)
30221
30812
  });
@@ -30226,8 +30817,13 @@ object({
30226
30817
  schedule: NcScheduleSchema.optional(),
30227
30818
  cadenceSec: CadenceSecField.optional(),
30228
30819
  framerate: FramerateField.optional(),
30820
+ denseCadenceSec: DenseCadenceSecField.optional(),
30821
+ minDwellSec: MinDwellSecField.optional(),
30229
30822
  targets: TargetsField.optional(),
30230
30823
  template: TimelapseTemplateSchema.nullable().optional(),
30824
+ previewText: PreviewTextField.optional(),
30825
+ previewMode: PreviewModeField.optional(),
30826
+ reportClasses: ReportClassesField.optional(),
30231
30827
  priority: PriorityField.optional()
30232
30828
  });
30233
30829
  TimelapseRuleInputSchema.extend({
@@ -30239,10 +30835,28 @@ TimelapseRuleInputSchema.extend({
30239
30835
  */
30240
30836
  ownerUserId: string().optional(),
30241
30837
  /**
30242
- * Epoch-ms of the last successful generation the 1-hour re-generation
30243
- * guard's durable state (predecessor parity). Absent = never generated.
30838
+ * Epoch-ms of the NEWEST successful generation across every camera of this
30839
+ * rule. What a UI shows, and the compatibility floor for
30840
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30244
30841
  */
30245
30842
  lastGeneratedAt: number().optional(),
30843
+ /**
30844
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
30845
+ * re-generation guard's real durable state.
30846
+ *
30847
+ * One rule covers several cameras and each renders its own video, so a rule
30848
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
30849
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
30850
+ * already done — and B's night is gone for good, because the window will not
30851
+ * come back.
30852
+ *
30853
+ * ADDITIVE, so the migration is free: a row written before this field simply
30854
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
30855
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
30856
+ * "never generated" would re-render and re-notify every camera of every rule
30857
+ * once, on the deploy that shipped the map.
30858
+ */
30859
+ generatedByDevice: record(string(), number()).optional(),
30246
30860
  /** userId of the caller who created the rule (server-stamped). */
30247
30861
  createdBy: string(),
30248
30862
  createdAt: number(),
@@ -30293,25 +30907,32 @@ object({
30293
30907
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30294
30908
  object({
30295
30909
  /**
30296
- * How long a retained native frame is served before it counts as a miss.
30910
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
30911
+ * detection result.
30912
+ *
30913
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
30914
+ * a time window was never related to the event the pixels were waiting for.
30915
+ * A held frame now lives from delivery until the runner has its `FrameResult`
30916
+ * — at which moment the runner cuts the subject tiles it actually wanted and
30917
+ * releases the frame. The bound exists only so a runner that stops answering
30918
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
30297
30919
  *
30298
- * Must cover the FULL late-crop horizon: detection inference + the
30299
- * cross-process inference-result hop to hub post-analysis + tracking + the
30300
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30301
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30302
- * RAM per busy camera grows linearly with no measured hit-rate gain.
30920
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
30921
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
30922
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
30923
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
30924
+ * `holdOverflow` on the metrics line is what says you need it.
30303
30925
  */
30304
- ttlMs: number().int().min(250).max(1e4),
30926
+ holdFrames: number().int().min(1).max(64),
30305
30927
  /**
30306
30928
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30307
30929
  *
30308
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30309
- * which one is actually binding before reasoning from that. At the shipped
30310
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30311
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30312
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30313
- * change that admits fewer frames buys retention WINDOW at constant RAM
30314
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
30930
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
30931
+ * is what decides how much is held, and the ceiling is the number above which
30932
+ * something is wrong. Before that it was the effective cap at 1024 MB with
30933
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
30934
+ * with the TTL expiring nothing, which is exactly the confusion the hold
30935
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30315
30936
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30316
30937
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30317
30938
  * to replace).
@@ -30337,22 +30958,45 @@ object({
30337
30958
  * there is the signal that some caller names frames outside the inference set
30338
30959
  * and that this must go back to `all`.
30339
30960
  */
30340
- admission: NativeLeaseAdmissionSchema
30961
+ admission: NativeLeaseAdmissionSchema,
30962
+ /**
30963
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
30964
+ * compressed native crops the worker cuts at the moment a frame's detection
30965
+ * result arrives, and keeps long after the frame itself is freed.
30966
+ *
30967
+ * This is the knob that replaced the old retention window, and it buys about
30968
+ * three orders of magnitude more of it: a tile is one subject at native
30969
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
30970
+ * the frame it was cut from. A frame on which nothing was detected costs
30971
+ * nothing at all, which is the real change — the old lease paid per FRAME and
30972
+ * was interrogated per SUBJECT.
30973
+ *
30974
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
30975
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
30976
+ * reproduce that.
30977
+ */
30978
+ tileBudgetMb: number().int().min(0).max(1024)
30341
30979
  });
30342
30980
  /**
30343
- * The values in force when the operator has set nothing — byte-for-byte the
30344
- * constants the decode worker shipped with as env-var defaults, so making these
30345
- * settings changed no behaviour on the day it landed.
30981
+ * The values in force when the operator has set nothing.
30982
+ *
30983
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
30984
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
30985
+ * in the same change that redefines it would make a regression and a retune
30986
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
30987
+ * live traffic.
30346
30988
  */
30347
30989
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30348
- ttlMs: 1200,
30990
+ holdFrames: 8,
30349
30991
  budgetMb: 1024,
30350
30992
  activityMs: 15e3,
30993
+ tileBudgetMb: 64,
30351
30994
  admission: "inferred"
30352
30995
  };
30353
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
30996
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30354
30997
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30355
30998
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
30999
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30356
31000
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30357
31001
  //#endregion
30358
31002
  Object.defineProperty(exports, "BaseAddon", {