@camstack/addon-provider-petkit 0.2.13 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +686 -42
  2. package/dist/addon.mjs +686 -42
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -8321,8 +8321,31 @@ var AdoptionJobSchema = object({
8321
8321
  error: string().nullable()
8322
8322
  });
8323
8323
  /**
8324
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
8325
- * pipeline functions an operator thinks in terms of.
8324
+ * Per-camera FUNCTION SWITCHES.
8325
+ *
8326
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
8327
+ *
8328
+ * This file shipped as "the one coherent on/off surface over the pipeline
8329
+ * functions an operator thinks in terms of". The operator's verdict on
8330
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
8331
+ * every function already had a settings page of its own, and a second place to
8332
+ * turn it off is a second place to look. Each switch is going back to its own
8333
+ * component's original options — detection to the detection-pipeline wrapper
8334
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
8335
+ * (which was always first-class; the switch was a veneer over
8336
+ * `recording.setDeviceConfig`), notifications to a notification-center
8337
+ * per-device setting, the two camera planes to their own components.
8338
+ *
8339
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
8340
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
8341
+ * straight from the authorities with no group in the middle. That rule was
8342
+ * never about a control panel.
8343
+ *
8344
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
8345
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
8346
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
8347
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
8348
+ * stop; nothing new may be built on it.
8326
8349
  *
8327
8350
  * ## This file adds no state
8328
8351
  *
@@ -8673,7 +8696,15 @@ var RecordingConfigSchema = object({
8673
8696
  * Each completed/failed run also lands one durable ops-log row on its owning
8674
8697
  * addon surface.
8675
8698
  */
8699
+ /**
8700
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
8701
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
8702
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
8703
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
8704
+ * runs at all.
8705
+ */
8676
8706
  var RelocateJobStateSchema = _enum([
8707
+ "queued",
8677
8708
  "running",
8678
8709
  "done",
8679
8710
  "failed",
@@ -8708,6 +8739,15 @@ var RelocateFootageInputSchema = object({
8708
8739
  /** Limits relocation to the logical profile class. Omit only for the
8709
8740
  * pre-orchestration compatibility path. */
8710
8741
  footageClass: RelocateFootageClassSchema.optional(),
8742
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
8743
+ * is what a whole-disk drain means. The rebalance path always sets it: its
8744
+ * unit is a (camera, profile) pile, not a disk. */
8745
+ deviceId: number().int().optional(),
8746
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
8747
+ * Finer than `footageClass`, which cannot separate high from mid — and the
8748
+ * placement plan assigns those two independently, so a rebalance that could
8749
+ * only say "recordings" would move footage the plan never asked to move. */
8750
+ profiles: array(string()).optional(),
8711
8751
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
8712
8752
  * never allowed to starve live writers. */
8713
8753
  throttleMbps: number().min(1).max(1e3).optional()
@@ -8843,6 +8883,21 @@ var StorageLocationSchema = object({
8843
8883
  nodeId: string().optional(),
8844
8884
  isDefault: boolean().default(false),
8845
8885
  isSystem: boolean().default(false),
8886
+ /**
8887
+ * Operator opt-in: whether consumers that BALANCE across several locations
8888
+ * of a type may write here. Recordings reads it today; event media and
8889
+ * backups are the next consumers, which is why the flag lives on the
8890
+ * location rather than in any one addon's store — nothing has to be
8891
+ * extended to add the next consumer.
8892
+ *
8893
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
8894
+ * flag existed reads back with no flag and keeps working exactly as before;
8895
+ * that is the whole compat story, and it is why no migration ships with it.
8896
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
8897
+ * disk must not silently start writing to it); the default of a type is
8898
+ * always stamped `true`.
8899
+ */
8900
+ enabled: boolean().optional(),
8846
8901
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
8847
8902
  * for node-local locations it can reach) — never persisted, absent when the
8848
8903
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -13412,7 +13467,8 @@ method(object({
13412
13467
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
13413
13468
  /**
13414
13469
  * filesystem-browse — per-node capability for browsing the node's local
13415
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
13470
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13471
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
13416
13472
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
13417
13473
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
13418
13474
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -15253,6 +15309,13 @@ var MaskGridDimsSchema = object({
15253
15309
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
15254
15310
  * this one field keeps the schema additive — a rule still declares exactly
15255
15311
  * one trigger.
15312
+ *
15313
+ * AUDIO rules add no member here, for the reason occupancy added none: the
15314
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
15315
+ * mirror.ts` fails the build on a member the app cannot render) and every
15316
+ * member costs a release train. A sustained-sound rule is therefore an
15317
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
15318
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
15256
15319
  */
15257
15320
  var NcDeliverySchema = _enum([
15258
15321
  "immediate",
@@ -15267,15 +15330,32 @@ var NcDeliverySchema = _enum([
15267
15330
  * depend on a provider's raw event name or payload shape.
15268
15331
  */
15269
15332
  var NcSystemEventKindSchema = _enum([
15270
- "camera-online",
15271
- "camera-offline",
15333
+ "device-online",
15334
+ "device-offline",
15335
+ "device-disabled",
15336
+ "device-enabled",
15272
15337
  "stream-online",
15273
15338
  "stream-offline",
15274
15339
  "node-online",
15275
15340
  "node-offline",
15276
15341
  "addon-update-available",
15277
- "server-update-available"
15342
+ "server-update-available",
15343
+ "alarm-triggered",
15344
+ "alarm-armed",
15345
+ "alarm-disarmed",
15346
+ "camera-online",
15347
+ "camera-offline",
15348
+ "camera-disabled",
15349
+ "camera-enabled"
15350
+ ]);
15351
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
15352
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
15353
+ "camera-online",
15354
+ "camera-offline",
15355
+ "camera-disabled",
15356
+ "camera-enabled"
15278
15357
  ]);
15358
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
15279
15359
  /**
15280
15360
  * One coherent system-event condition. `kinds` is the required opt-in safety
15281
15361
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -15284,6 +15364,18 @@ var NcSystemEventKindSchema = _enum([
15284
15364
  var NcSystemEventConditionSchema = object({
15285
15365
  kinds: array(NcSystemEventKindSchema).min(1),
15286
15366
  deviceIds: array(number().int()).min(1).optional(),
15367
+ /**
15368
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
15369
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
15370
+ * is what a liveness rule means when nobody said otherwise.
15371
+ *
15372
+ * This is where "only my cameras" is expressed, and it lives on the rule for
15373
+ * one reason: the intake cannot know which devices this household cares
15374
+ * about, and a producer-side filter is one no operator can change. Fails
15375
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
15376
+ * does not carry) matches no `deviceTypes` list.
15377
+ */
15378
+ deviceTypes: array(string().min(1)).min(1).optional(),
15287
15379
  nodeIds: array(string().min(1)).min(1).optional(),
15288
15380
  packageNames: array(string().min(1)).min(1).optional()
15289
15381
  });
@@ -15334,6 +15426,47 @@ var NcOccupancyConditionSchema = object({
15334
15426
  sustainSeconds: number().int().min(0).max(3600).default(15)
15335
15427
  });
15336
15428
  /**
15429
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
15430
+ *
15431
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
15432
+ * reference notifier uses, so an operator moving between them re-uses what
15433
+ * they already know): a rule matches when, over a sampling window of
15434
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
15435
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
15436
+ *
15437
+ * - `dbThreshold` — its level is at or above this many dBFS (see
15438
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
15439
+ * - `labels` — the classifier put at least one of these labels on it.
15440
+ *
15441
+ * Both are OPTIONAL and independent, which is the point of the shape: a
15442
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
15443
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
15444
+ * is given** — a window in which every sample is trivially a hit would fire on
15445
+ * silence, so the engine refuses such a condition rather than notifying on
15446
+ * nothing (the schema cannot express "at least one of" without becoming a
15447
+ * ZodEffects the cap path would have to special-case).
15448
+ *
15449
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
15450
+ * must be FULL before it can match — a window that has been open for two
15451
+ * seconds of its ten is 100% of nothing, and firing on it would make
15452
+ * `samplingSeconds` decorative.
15453
+ *
15454
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
15455
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
15456
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
15457
+ * an operator who typed `dog` mean the same thing.
15458
+ */
15459
+ var NcAudioConditionSchema = object({
15460
+ /** Audio macro labels; absent = any sound (level-only rule). */
15461
+ labels: array(string().min(1)).min(1).optional(),
15462
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
15463
+ dbThreshold: number().min(-96).max(0).optional(),
15464
+ /** Percentage of the window's samples that must be hits (1–100). */
15465
+ hitPercent: number().int().min(1).max(100).default(60),
15466
+ /** Length of the sampling window in seconds. */
15467
+ samplingSeconds: number().int().min(1).max(300).default(10)
15468
+ });
15469
+ /**
15337
15470
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
15338
15471
  *
15339
15472
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -15606,7 +15739,33 @@ var NcConditionsSchema = object({
15606
15739
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
15607
15740
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
15608
15741
  */
15609
- occupancy: NcOccupancyConditionSchema.optional()
15742
+ occupancy: NcOccupancyConditionSchema.optional(),
15743
+ /**
15744
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
15745
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
15746
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
15747
+ * a window that is not full yet, neither filter given). See
15748
+ * {@link NcAudioCondition}.
15749
+ *
15750
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
15751
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
15752
+ * a detection, a track or a device event (the same fail-closed pairing
15753
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
15754
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
15755
+ * (an `immediate` rule naming an `audio-*` class, one notification per
15756
+ * classified sample) stays exactly as it was for rules that already use it.
15757
+ *
15758
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
15759
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
15760
+ * (`camstack/src/data/notification-center.ts`, guarded by
15761
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
15762
+ * condition fields it does not know when a rule is saved from the phone.
15763
+ * Publishing an editor for a condition the app cannot round-trip is how an
15764
+ * operator loses a rule's conditions by opening it — so the descriptor, the
15765
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
15766
+ * does an audio rule become authorable.
15767
+ */
15768
+ audio: NcAudioConditionSchema.optional()
15610
15769
  });
15611
15770
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
15612
15771
  var NcRuleTargetSchema = object({
@@ -15720,6 +15879,73 @@ var NcThrottleSchema = object({
15720
15879
  */
15721
15880
  granularity: NcThrottleGranularitySchema.optional()
15722
15881
  });
15882
+ /**
15883
+ * How long the confirm gate may hold ONE notification, and how big the picture
15884
+ * it judges may be.
15885
+ *
15886
+ * The clamp is the product decision, not a coincidence of the model: p50 was
15887
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
15888
+ * arrives after the visitor has gone is not a notification. 448 px was enough
15889
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
15890
+ * tokens for pixels the model pools away.
15891
+ */
15892
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
15893
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
15894
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
15895
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
15896
+ var NcConfirmExpectSchema = object({
15897
+ op: _enum([
15898
+ ">=",
15899
+ ">",
15900
+ "<=",
15901
+ "<",
15902
+ "=="
15903
+ ]),
15904
+ count: number().int().min(0).max(1e3)
15905
+ });
15906
+ /**
15907
+ * AI CONFIRM — a vision model looks at the picture this notification is about
15908
+ * to ship and says whether it agrees with the rule.
15909
+ *
15910
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
15911
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
15912
+ * on the operator's phone is not a verdict about this notification.
15913
+ *
15914
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
15915
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
15916
+ * the default and every fail-open is COUNTED, because a gate that always fails
15917
+ * open looks in the log exactly like a gate that works.
15918
+ *
15919
+ * Every field is `.optional()` rather than relied on as a Zod default at the
15920
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
15921
+ * production failures in one day), so the gate reads absent as the constant
15922
+ * above rather than trusting a parse it may never have seen.
15923
+ */
15924
+ var NcConfirmSchema = object({
15925
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
15926
+ * same thing, and both mean "deliver exactly as before". */
15927
+ enabled: boolean().default(false),
15928
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
15929
+ profileId: string().optional(),
15930
+ /**
15931
+ * The operator's question, in his own words. Absent = a question derived
15932
+ * from the rule (its class and its expectation).
15933
+ *
15934
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
15935
+ * banners, signage and plates as instructions if you let them reach the
15936
+ * prompt — proven live — so the authoritative contract stays in the system
15937
+ * turn and only rule-authored words land here.
15938
+ */
15939
+ prompt: string().max(1e3).optional(),
15940
+ /** Fire only when the model's count satisfies this. Absent = the model's
15941
+ * own boolean verdict decides. */
15942
+ expect: NcConfirmExpectSchema.optional(),
15943
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
15944
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
15945
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
15946
+ /** Longest edge the judged image is downscaled to before it is sent. */
15947
+ maxImagePx: number().int().min(64).max(2048).default(448)
15948
+ });
15723
15949
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
15724
15950
  var NcRuleInputSchema = object({
15725
15951
  name: string().min(1).max(200),
@@ -15780,7 +16006,13 @@ var NcRuleInputSchema = object({
15780
16006
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
15781
16007
  * shape as every other actuation.
15782
16008
  */
15783
- actions: NcRuleActionsSchema.optional()
16009
+ actions: NcRuleActionsSchema.optional(),
16010
+ /**
16011
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
16012
+ * a rule that predates the gate must keep delivering byte-for-byte as it
16013
+ * did, and absent is the only way to say that without a migration.
16014
+ */
16015
+ confirm: NcConfirmSchema.optional()
15784
16016
  });
15785
16017
  /**
15786
16018
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -15791,7 +16023,37 @@ var NcRuleInputSchema = object({
15791
16023
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
15792
16024
  * `updateRule` patch.
15793
16025
  */
15794
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
16026
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
16027
+ disabledTargetIds: array(string()).optional(),
16028
+ /**
16029
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
16030
+ *
16031
+ * It makes the key optional to SUPPLY; the parse still materialises the
16032
+ * default when the key is absent. And `NcRuleStore.update` merges with
16033
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
16034
+ * one — which made every partial edit destructive:
16035
+ *
16036
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
16037
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
16038
+ * setEnabled(ruleId, false) → conditions reset to `{}`
16039
+ *
16040
+ * A rule scoped to one camera and one zone silently became a rule that
16041
+ * matches EVERY event on EVERY camera, and lost its `media` policy
16042
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
16043
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
16044
+ * within a minute of a two-field patch.
16045
+ *
16046
+ * So every defaulted field is re-declared here WITHOUT its default. The
16047
+ * inner defaults still apply when the caller DOES send the key — `{}` for
16048
+ * conditions remains a real instruction ("clear them") — and only the
16049
+ * absent key is now genuinely absent.
16050
+ */
16051
+ enabled: boolean().optional(),
16052
+ conditions: NcConditionsSchema.optional(),
16053
+ media: NcMediaPolicySchema.optional(),
16054
+ throttle: NcThrottleSchema.optional(),
16055
+ priority: number().int().min(1).max(5).optional()
16056
+ });
15795
16057
  /** A persisted rule. */
15796
16058
  var NcRuleSchema = NcRuleInputSchema.extend({
15797
16059
  id: string(),
@@ -16092,6 +16354,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
16092
16354
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
16093
16355
  * copy would lie the first time a rule is disabled.
16094
16356
  */
16357
+ /**
16358
+ * Why a device a mode NAMES is nonetheless not armed by it.
16359
+ *
16360
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
16361
+ * per-camera notification switch the Notification Center already owns,
16362
+ * `detection-off` is the device's own detection binding being inactive, and
16363
+ * `offline` is the device manager's liveness. A fourth reason would mean a
16364
+ * fourth authority, and inventing one here is how a panel starts disagreeing
16365
+ * with the switches the operator actually used.
16366
+ */
16367
+ var NcAlarmSkipReasonSchema = _enum([
16368
+ "muted",
16369
+ "detection-off",
16370
+ "offline"
16371
+ ]);
16372
+ var NcAlarmSkippedDeviceSchema = object({
16373
+ deviceId: number().int(),
16374
+ reason: NcAlarmSkipReasonSchema
16375
+ });
16095
16376
  var NcAlarmModeCoverageSchema = object({
16096
16377
  mode: AlarmArmModeSchema,
16097
16378
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -16099,7 +16380,18 @@ var NcAlarmModeCoverageSchema = object({
16099
16380
  /** At least one covering rule has no device scope, so the mode covers all. */
16100
16381
  allDevices: boolean(),
16101
16382
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
16102
- deviceIds: array(number().int())
16383
+ deviceIds: array(number().int()),
16384
+ /**
16385
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
16386
+ * excludes it.
16387
+ *
16388
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
16389
+ * twelve makes it false in exactly the way nobody notices until an incident.
16390
+ * Defaulted to `[]` so a coverage answer computed before this field existed
16391
+ * still parses as "nothing known to be skipped" rather than failing the whole
16392
+ * alarm tab.
16393
+ */
16394
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
16103
16395
  });
16104
16396
  var NcAlarmConfigSchema = object({
16105
16397
  /**
@@ -18931,9 +19223,16 @@ var CameraStatusSchema = object({
18931
19223
  audio: CameraAudioStatusSchema.nullable(),
18932
19224
  recording: CameraRecordingStatusSchema.nullable(),
18933
19225
  /**
18934
- * Per-camera function switches an OPERATOR has turned off
19226
+ * Per-camera functions an OPERATOR has turned off
18935
19227
  * ([D61](../../../../docs/decisions/adr-0067.md)).
18936
19228
  *
19229
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
19230
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
19231
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
19232
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
19233
+ * The badge outlives the control panel: the panel was a convenience, this is
19234
+ * the difference between a camera being off and a camera being dead.
19235
+ *
18937
19236
  * This is the difference between DISABLED and BROKEN. A camera whose
18938
19237
  * `detection` block reports zero fps and whose `switchedOff` contains
18939
19238
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -25683,7 +25982,19 @@ var RecordingManifestSchema = object({
25683
25982
  * profiles/subtrees/locations on this node). */
25684
25983
  var RecordingDeviceUsageSchema = object({
25685
25984
  deviceId: number(),
25686
- usedBytes: number()
25985
+ usedBytes: number(),
25986
+ /**
25987
+ * Start of this camera's OLDEST indexed segment, across every profile and
25988
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25989
+ * only honest answer to "is retention actually holding?" per camera.
25990
+ *
25991
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25992
+ * predates this field omits it entirely, and a hub whose types carry the
25993
+ * field must keep validating that older provider's payload: the framework
25994
+ * (types) and the addon ship on different trains, and the addon is usually
25995
+ * the later of the two.
25996
+ */
25997
+ oldestMs: number().nullable().optional()
25687
25998
  });
25688
25999
  /** Recording storage usage + capacity for one storage location. */
25689
26000
  var RecordingLocationUsageSchema = object({
@@ -25711,6 +26022,57 @@ var RecordingStorageUsageSchema = object({
25711
26022
  locations: array(RecordingLocationUsageSchema)
25712
26023
  });
25713
26024
  /**
26025
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
26026
+ *
26027
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
26028
+ * is the operator asking for the EXISTING archive to be brought into line with
26029
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
26030
+ * location, run FIFO behind the single-flight mover.
26031
+ *
26032
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
26033
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
26034
+ * (empty on the plan).
26035
+ */
26036
+ var RecordingRebalanceMoveSchema = object({
26037
+ deviceId: number(),
26038
+ profile: string(),
26039
+ fromLocationId: string(),
26040
+ toLocationId: string(),
26041
+ bytes: number(),
26042
+ files: number().int()
26043
+ });
26044
+ /** Why a pile that is out of place is staying there. Every refusal is
26045
+ * reported: a rebalance that silently drops a camera reads exactly like one
26046
+ * that had nothing to do. */
26047
+ var RecordingRebalanceSkipReasonSchema = _enum([
26048
+ "unassigned",
26049
+ "target-not-writable",
26050
+ "below-threshold",
26051
+ "no-headroom"
26052
+ ]);
26053
+ var RecordingRebalanceSkipSchema = object({
26054
+ deviceId: number(),
26055
+ profile: string(),
26056
+ fromLocationId: string(),
26057
+ /** The location the plan wants; null when the camera has no assignment. */
26058
+ toLocationId: string().nullable(),
26059
+ bytes: number(),
26060
+ reason: RecordingRebalanceSkipReasonSchema
26061
+ });
26062
+ var RecordingRebalancePlanSchema = object({
26063
+ moves: array(RecordingRebalanceMoveSchema),
26064
+ skipped: array(RecordingRebalanceSkipSchema),
26065
+ bytesToMove: number(),
26066
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
26067
+ jobIds: array(string())
26068
+ });
26069
+ var RecordingRebalanceInputSchema = object({
26070
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
26071
+ throttleMbps: number().min(1).max(1e3).optional(),
26072
+ /** Ignore piles smaller than this (default 1 GB). */
26073
+ minMoveGb: number().min(0).optional()
26074
+ });
26075
+ /**
25714
26076
  * Result of locating footage at a wall-clock instant for one device/profile.
25715
26077
  * `segment` carries the covering segment's window; `gap` reports the forward
25716
26078
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -25873,9 +26235,24 @@ method(object({
25873
26235
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25874
26236
  kind: "mutation",
25875
26237
  auth: "admin"
26238
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
26239
+ kind: "mutation",
26240
+ auth: "admin"
26241
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
26242
+ kind: "query",
26243
+ auth: "admin"
26244
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26245
+ kind: "mutation",
26246
+ auth: "admin"
26247
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26248
+ kind: "query",
26249
+ auth: "admin"
26250
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26251
+ kind: "mutation",
26252
+ auth: "admin"
25876
26253
  });
25877
26254
  /**
25878
- * `recordingExport` cap — render a footage time range into a single downloadable
26255
+ * `recording-export` cap — render a footage time range into a single downloadable
25879
26256
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
25880
26257
  * bounded lifetime with a durable history, auto-expiry, and optional
25881
26258
  * delete-after-download.
@@ -25890,10 +26267,53 @@ method(object({
25890
26267
  */
25891
26268
  /** Playback-speed multiplier for the render (1 = realtime). */
25892
26269
  var ExportSpeedSchema = number().min(.25).max(32);
26270
+ /**
26271
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
26272
+ *
26273
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
26274
+ * derives these bounds from things that happened at a TIME (a track's
26275
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
26276
+ * every segment present for the range, with each recording GAP removed. The
26277
+ * two agree only on a window that recorded without one interruption, and only
26278
+ * the render side knows the segments, so the translation lives there
26279
+ * (`export-dense-map.ts`, addon-pipeline).
26280
+ *
26281
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
26282
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
26283
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
26284
+ * the video was a uniform timelapse, and the log line reported the five ranges
26285
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
26286
+ *
26287
+ * Relative and not absolute epoch, because an absolute epoch would make every
26288
+ * call site responsible for the same subtraction.
26289
+ */
26290
+ var ExportDenseRangeSchema = object({
26291
+ fromSec: number().nonnegative(),
26292
+ toSec: number().nonnegative()
26293
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
26294
+ /**
26295
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
26296
+ * listed ranges and at the base `everyMs` everywhere else.
26297
+ *
26298
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
26299
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
26300
+ */
26301
+ var ExportDenseSchema = object({
26302
+ everyMs: number().int().positive(),
26303
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
26304
+ });
25893
26305
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
25894
26306
  var ExportTimelapseSchema = object({
25895
26307
  everyMs: number().int().positive(),
25896
- outputFps: number().int().min(1).max(60).optional()
26308
+ outputFps: number().int().min(1).max(60).optional(),
26309
+ /** Optional second, FASTER rate over the intervals that matter. */
26310
+ dense: ExportDenseSchema.optional()
26311
+ }).superRefine((v, ctx) => {
26312
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
26313
+ code: ZodIssueCode.custom,
26314
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
26315
+ path: ["dense", "everyMs"]
26316
+ });
25897
26317
  });
25898
26318
  /**
25899
26319
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -25951,6 +26371,19 @@ var ExportDownloadSchema = object({
25951
26371
  url: string(),
25952
26372
  endpoints: array(string())
25953
26373
  });
26374
+ /**
26375
+ * A finished export's bytes, inline.
26376
+ *
26377
+ * `bytes` is the DECODED length — the number the caller bounds and logs
26378
+ * against, so nobody has to infer it from the base64 length.
26379
+ */
26380
+ var ExportBytesSchema = object({
26381
+ base64: string(),
26382
+ contentType: string(),
26383
+ /** Suggested filename, extension included. */
26384
+ name: string(),
26385
+ bytes: number().int().nonnegative()
26386
+ });
25954
26387
  method(object({
25955
26388
  deviceId: number(),
25956
26389
  profile: string(),
@@ -25975,6 +26408,9 @@ method(object({
25975
26408
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
25976
26409
  kind: "query",
25977
26410
  auth: "protected"
26411
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
26412
+ kind: "query",
26413
+ auth: "protected"
25978
26414
  });
25979
26415
  /**
25980
26416
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -32652,6 +33088,12 @@ Object.freeze({
32652
33088
  addonId: null,
32653
33089
  access: "create"
32654
33090
  },
33091
+ "recording.cancelRelocateJob": {
33092
+ capName: "recording",
33093
+ capScope: "system",
33094
+ addonId: null,
33095
+ access: "create"
33096
+ },
32655
33097
  "recording.cancelStorageMigrationMove": {
32656
33098
  capName: "recording",
32657
33099
  capScope: "system",
@@ -32706,6 +33148,12 @@ Object.freeze({
32706
33148
  addonId: null,
32707
33149
  access: "view"
32708
33150
  },
33151
+ "recording.listRelocateJobs": {
33152
+ capName: "recording",
33153
+ capScope: "system",
33154
+ addonId: null,
33155
+ access: "view"
33156
+ },
32709
33157
  "recording.locateSegment": {
32710
33158
  capName: "recording",
32711
33159
  capScope: "system",
@@ -32718,6 +33166,12 @@ Object.freeze({
32718
33166
  addonId: null,
32719
33167
  access: "create"
32720
33168
  },
33169
+ "recording.planStorageRebalance": {
33170
+ capName: "recording",
33171
+ capScope: "system",
33172
+ addonId: null,
33173
+ access: "view"
33174
+ },
32721
33175
  "recording.pruneFootage": {
32722
33176
  capName: "recording",
32723
33177
  capScope: "system",
@@ -32742,6 +33196,12 @@ Object.freeze({
32742
33196
  addonId: null,
32743
33197
  access: "create"
32744
33198
  },
33199
+ "recording.relocateFootage": {
33200
+ capName: "recording",
33201
+ capScope: "system",
33202
+ addonId: null,
33203
+ access: "create"
33204
+ },
32745
33205
  "recording.renderClip": {
32746
33206
  capName: "recording",
32747
33207
  capScope: "system",
@@ -32778,38 +33238,50 @@ Object.freeze({
32778
33238
  addonId: null,
32779
33239
  access: "create"
32780
33240
  },
33241
+ "recording.startStorageRebalance": {
33242
+ capName: "recording",
33243
+ capScope: "system",
33244
+ addonId: null,
33245
+ access: "create"
33246
+ },
32781
33247
  "recordingExport.cancelExport": {
32782
- capName: "recordingExport",
33248
+ capName: "recording-export",
32783
33249
  capScope: "system",
32784
33250
  addonId: null,
32785
33251
  access: "create"
32786
33252
  },
32787
33253
  "recordingExport.createExport": {
32788
- capName: "recordingExport",
33254
+ capName: "recording-export",
32789
33255
  capScope: "system",
32790
33256
  addonId: null,
32791
33257
  access: "create"
32792
33258
  },
32793
33259
  "recordingExport.deleteExport": {
32794
- capName: "recordingExport",
33260
+ capName: "recording-export",
32795
33261
  capScope: "system",
32796
33262
  addonId: null,
32797
33263
  access: "delete"
32798
33264
  },
32799
33265
  "recordingExport.getDownloadUrl": {
32800
- capName: "recordingExport",
33266
+ capName: "recording-export",
32801
33267
  capScope: "system",
32802
33268
  addonId: null,
32803
33269
  access: "view"
32804
33270
  },
32805
33271
  "recordingExport.getExport": {
32806
- capName: "recordingExport",
33272
+ capName: "recording-export",
32807
33273
  capScope: "system",
32808
33274
  addonId: null,
32809
33275
  access: "view"
32810
33276
  },
32811
33277
  "recordingExport.listExports": {
32812
- capName: "recordingExport",
33278
+ capName: "recording-export",
33279
+ capScope: "system",
33280
+ addonId: null,
33281
+ access: "view"
33282
+ },
33283
+ "recordingExport.readExportBytes": {
33284
+ capName: "recording-export",
32813
33285
  capScope: "system",
32814
33286
  addonId: null,
32815
33287
  access: "view"
@@ -34186,6 +34658,104 @@ var FramerateField = number().int().min(1).max(60);
34186
34658
  var TargetsField = array(NcRuleTargetSchema).min(1);
34187
34659
  var PriorityField = number().int().min(1).max(5);
34188
34660
  /**
34661
+ * Explicit override of the DENSE sampling cadence, seconds.
34662
+ *
34663
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
34664
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
34665
+ * made that same base 3 s and rendered a person pass as two frames.)
34666
+ *
34667
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
34668
+ * `denseCadenceSec` and played at `framerate` occupies
34669
+ *
34670
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
34671
+ *
34672
+ * 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.
34673
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
34674
+ * and therefore the length of a quiet night, does not move.
34675
+ *
34676
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
34677
+ * the recording has them returns the same frames, requested twice. Must be
34678
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
34679
+ * a uniform video the operator believes is two-rate — and upsert refuses it
34680
+ * rather than letting the export cap reject the render hours after the window.
34681
+ */
34682
+ var DenseCadenceSecField = number().min(.1).max(3600);
34683
+ /**
34684
+ * Minimum seconds of OUTPUT video each detection range must occupy.
34685
+ *
34686
+ * The operator-facing form of the arithmetic above: instead of solving for a
34687
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
34688
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
34689
+ * that range every ~583 ms.
34690
+ *
34691
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
34692
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
34693
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
34694
+ * ranges are sampled denser than they need. Per-range cadences require a cap
34695
+ * schema change and are the tracked follow-up.
34696
+ *
34697
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
34698
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
34699
+ * by real footage, never met by duplicating frames into motion that never
34700
+ * happened.
34701
+ */
34702
+ var MinDwellSecField = number().min(0).max(60);
34703
+ /**
34704
+ * Caption burned into the notification's preview frame.
34705
+ *
34706
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
34707
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
34708
+ * templating dialect for one field would be a second thing to explain.
34709
+ *
34710
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
34711
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
34712
+ * the reason this is not `.min(1)`.
34713
+ */
34714
+ var PreviewTextField = string().max(200);
34715
+ /**
34716
+ * Whether the notification's preview is a STILL or a short animation.
34717
+ *
34718
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
34719
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
34720
+ * night reads better as three seconds of motion than as one frame of it. Both
34721
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
34722
+ * simply applies it to a dozen frames sampled across the render and assembles
34723
+ * them.
34724
+ *
34725
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
34726
+ * seeks and a palette pass, and no rule that never asked for one should start
34727
+ * paying that on the deploy that shipped it.
34728
+ *
34729
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
34730
+ */
34731
+ var PreviewModeField = _enum(["image", "gif"]);
34732
+ /**
34733
+ * Which detection classes the notification reports counts for.
34734
+ *
34735
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
34736
+ * plan — no second query — aggregated per class. Absent or empty means "every
34737
+ * class the window actually contained", which is what an operator who never
34738
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
34739
+ * counts cars all night).
34740
+ *
34741
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
34742
+ * …). An unknown name simply never matches and reports nothing — it is not an
34743
+ * error, because a rule may legitimately name a class this camera's model does
34744
+ * not emit.
34745
+ *
34746
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
34747
+ * - `{{detections}}` — total over the reported classes
34748
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
34749
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
34750
+ * one per class, `count_` + the class name
34751
+ *
34752
+ * With NO custom body template the summary is appended to the derived body, and
34753
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
34754
+ * reads. With a custom template the operator owns every word — nothing is
34755
+ * appended, so `{{detectionSummary}}` is how he asks for it.
34756
+ */
34757
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
34758
+ /**
34189
34759
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
34190
34760
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
34191
34761
  * here (see the ownership note above).
@@ -34205,9 +34775,30 @@ var TimelapseRuleInputSchema = object({
34205
34775
  cadenceSec: CadenceSecField.default(15),
34206
34776
  /** Output frames per second of the assembled mp4 (predecessor parity). */
34207
34777
  framerate: FramerateField.default(10),
34778
+ /**
34779
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
34780
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
34781
+ * field gets.
34782
+ */
34783
+ denseCadenceSec: DenseCadenceSecField.optional(),
34784
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
34785
+ minDwellSec: MinDwellSecField.optional(),
34208
34786
  /** `notification-output` targets the finished video/thumbnail is sent to. */
34209
34787
  targets: TargetsField,
34210
34788
  template: TimelapseTemplateSchema.optional(),
34789
+ /**
34790
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
34791
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
34792
+ *
34793
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
34794
+ * the notification's title/body, and clearing it (`template: null`) must not
34795
+ * silently clear the caption too.
34796
+ */
34797
+ previewText: PreviewTextField.optional(),
34798
+ /** Still or animation — see {@link PreviewModeField}. */
34799
+ previewMode: PreviewModeField.default("image"),
34800
+ /** Classes the notification counts — see {@link ReportClassesField}. */
34801
+ reportClasses: ReportClassesField.optional(),
34211
34802
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
34212
34803
  priority: PriorityField.default(3)
34213
34804
  });
@@ -34218,8 +34809,13 @@ object({
34218
34809
  schedule: NcScheduleSchema.optional(),
34219
34810
  cadenceSec: CadenceSecField.optional(),
34220
34811
  framerate: FramerateField.optional(),
34812
+ denseCadenceSec: DenseCadenceSecField.optional(),
34813
+ minDwellSec: MinDwellSecField.optional(),
34221
34814
  targets: TargetsField.optional(),
34222
34815
  template: TimelapseTemplateSchema.nullable().optional(),
34816
+ previewText: PreviewTextField.optional(),
34817
+ previewMode: PreviewModeField.optional(),
34818
+ reportClasses: ReportClassesField.optional(),
34223
34819
  priority: PriorityField.optional()
34224
34820
  });
34225
34821
  TimelapseRuleInputSchema.extend({
@@ -34231,10 +34827,28 @@ TimelapseRuleInputSchema.extend({
34231
34827
  */
34232
34828
  ownerUserId: string().optional(),
34233
34829
  /**
34234
- * Epoch-ms of the last successful generation the 1-hour re-generation
34235
- * guard's durable state (predecessor parity). Absent = never generated.
34830
+ * Epoch-ms of the NEWEST successful generation across every camera of this
34831
+ * rule. What a UI shows, and the compatibility floor for
34832
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
34236
34833
  */
34237
34834
  lastGeneratedAt: number().optional(),
34835
+ /**
34836
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
34837
+ * re-generation guard's real durable state.
34838
+ *
34839
+ * One rule covers several cameras and each renders its own video, so a rule
34840
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
34841
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
34842
+ * already done — and B's night is gone for good, because the window will not
34843
+ * come back.
34844
+ *
34845
+ * ADDITIVE, so the migration is free: a row written before this field simply
34846
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
34847
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
34848
+ * "never generated" would re-render and re-notify every camera of every rule
34849
+ * once, on the deploy that shipped the map.
34850
+ */
34851
+ generatedByDevice: record(string(), number()).optional(),
34238
34852
  /** userId of the caller who created the rule (server-stamped). */
34239
34853
  createdBy: string(),
34240
34854
  createdAt: number(),
@@ -34285,25 +34899,32 @@ object({
34285
34899
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
34286
34900
  object({
34287
34901
  /**
34288
- * How long a retained native frame is served before it counts as a miss.
34902
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
34903
+ * detection result.
34904
+ *
34905
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
34906
+ * a time window was never related to the event the pixels were waiting for.
34907
+ * A held frame now lives from delivery until the runner has its `FrameResult`
34908
+ * — at which moment the runner cuts the subject tiles it actually wanted and
34909
+ * releases the frame. The bound exists only so a runner that stops answering
34910
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
34289
34911
  *
34290
- * Must cover the FULL late-crop horizon: detection inference + the
34291
- * cross-process inference-result hop to hub post-analysis + tracking + the
34292
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
34293
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
34294
- * RAM per busy camera grows linearly with no measured hit-rate gain.
34912
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
34913
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
34914
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
34915
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
34916
+ * `holdOverflow` on the metrics line is what says you need it.
34295
34917
  */
34296
- ttlMs: number().int().min(250).max(1e4),
34918
+ holdFrames: number().int().min(1).max(64),
34297
34919
  /**
34298
34920
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
34299
34921
  *
34300
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
34301
- * which one is actually binding before reasoning from that. At the shipped
34302
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
34303
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
34304
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
34305
- * change that admits fewer frames buys retention WINDOW at constant RAM
34306
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
34922
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
34923
+ * is what decides how much is held, and the ceiling is the number above which
34924
+ * something is wrong. Before that it was the effective cap at 1024 MB with
34925
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
34926
+ * with the TTL expiring nothing, which is exactly the confusion the hold
34927
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
34307
34928
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
34308
34929
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
34309
34930
  * to replace).
@@ -34329,22 +34950,45 @@ object({
34329
34950
  * there is the signal that some caller names frames outside the inference set
34330
34951
  * and that this must go back to `all`.
34331
34952
  */
34332
- admission: NativeLeaseAdmissionSchema
34953
+ admission: NativeLeaseAdmissionSchema,
34954
+ /**
34955
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
34956
+ * compressed native crops the worker cuts at the moment a frame's detection
34957
+ * result arrives, and keeps long after the frame itself is freed.
34958
+ *
34959
+ * This is the knob that replaced the old retention window, and it buys about
34960
+ * three orders of magnitude more of it: a tile is one subject at native
34961
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
34962
+ * the frame it was cut from. A frame on which nothing was detected costs
34963
+ * nothing at all, which is the real change — the old lease paid per FRAME and
34964
+ * was interrogated per SUBJECT.
34965
+ *
34966
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
34967
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
34968
+ * reproduce that.
34969
+ */
34970
+ tileBudgetMb: number().int().min(0).max(1024)
34333
34971
  });
34334
34972
  /**
34335
- * The values in force when the operator has set nothing — byte-for-byte the
34336
- * constants the decode worker shipped with as env-var defaults, so making these
34337
- * settings changed no behaviour on the day it landed.
34973
+ * The values in force when the operator has set nothing.
34974
+ *
34975
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
34976
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
34977
+ * in the same change that redefines it would make a regression and a retune
34978
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
34979
+ * live traffic.
34338
34980
  */
34339
34981
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
34340
- ttlMs: 1200,
34982
+ holdFrames: 8,
34341
34983
  budgetMb: 1024,
34342
34984
  activityMs: 15e3,
34985
+ tileBudgetMb: 64,
34343
34986
  admission: "inferred"
34344
34987
  };
34345
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
34988
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
34346
34989
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
34347
34990
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34991
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
34348
34992
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
34349
34993
  //#endregion
34350
34994
  //#region src/config.ts