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