@camstack/addon-export-hap 1.2.23 → 1.2.25

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.
@@ -8246,7 +8246,15 @@ var RecordingConfigSchema = object({
8246
8246
  * Each completed/failed run also lands one durable ops-log row on its owning
8247
8247
  * addon surface.
8248
8248
  */
8249
+ /**
8250
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
8251
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
8252
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
8253
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
8254
+ * runs at all.
8255
+ */
8249
8256
  var RelocateJobStateSchema = _enum([
8257
+ "queued",
8250
8258
  "running",
8251
8259
  "done",
8252
8260
  "failed",
@@ -8281,6 +8289,15 @@ var RelocateFootageInputSchema = object({
8281
8289
  /** Limits relocation to the logical profile class. Omit only for the
8282
8290
  * pre-orchestration compatibility path. */
8283
8291
  footageClass: RelocateFootageClassSchema.optional(),
8292
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
8293
+ * is what a whole-disk drain means. The rebalance path always sets it: its
8294
+ * unit is a (camera, profile) pile, not a disk. */
8295
+ deviceId: number().int().optional(),
8296
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
8297
+ * Finer than `footageClass`, which cannot separate high from mid — and the
8298
+ * placement plan assigns those two independently, so a rebalance that could
8299
+ * only say "recordings" would move footage the plan never asked to move. */
8300
+ profiles: array(string()).optional(),
8284
8301
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
8285
8302
  * never allowed to starve live writers. */
8286
8303
  throttleMbps: number().min(1).max(1e3).optional()
@@ -8416,6 +8433,21 @@ var StorageLocationSchema = object({
8416
8433
  nodeId: string().optional(),
8417
8434
  isDefault: boolean().default(false),
8418
8435
  isSystem: boolean().default(false),
8436
+ /**
8437
+ * Operator opt-in: whether consumers that BALANCE across several locations
8438
+ * of a type may write here. Recordings reads it today; event media and
8439
+ * backups are the next consumers, which is why the flag lives on the
8440
+ * location rather than in any one addon's store — nothing has to be
8441
+ * extended to add the next consumer.
8442
+ *
8443
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
8444
+ * flag existed reads back with no flag and keeps working exactly as before;
8445
+ * that is the whole compat story, and it is why no migration ships with it.
8446
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
8447
+ * disk must not silently start writing to it); the default of a type is
8448
+ * always stamped `true`.
8449
+ */
8450
+ enabled: boolean().optional(),
8419
8451
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
8420
8452
  * for node-local locations it can reach) — never persisted, absent when the
8421
8453
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12853,7 +12885,8 @@ method(object({
12853
12885
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12854
12886
  /**
12855
12887
  * filesystem-browse — per-node capability for browsing the node's local
12856
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12888
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12889
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12857
12890
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12858
12891
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12859
12892
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14666,6 +14699,13 @@ var MaskGridDimsSchema = object({
14666
14699
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14667
14700
  * this one field keeps the schema additive — a rule still declares exactly
14668
14701
  * one trigger.
14702
+ *
14703
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14704
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14705
+ * mirror.ts` fails the build on a member the app cannot render) and every
14706
+ * member costs a release train. A sustained-sound rule is therefore an
14707
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14708
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14669
14709
  */
14670
14710
  var NcDeliverySchema = _enum([
14671
14711
  "immediate",
@@ -14680,15 +14720,32 @@ var NcDeliverySchema = _enum([
14680
14720
  * depend on a provider's raw event name or payload shape.
14681
14721
  */
14682
14722
  var NcSystemEventKindSchema = _enum([
14683
- "camera-online",
14684
- "camera-offline",
14723
+ "device-online",
14724
+ "device-offline",
14725
+ "device-disabled",
14726
+ "device-enabled",
14685
14727
  "stream-online",
14686
14728
  "stream-offline",
14687
14729
  "node-online",
14688
14730
  "node-offline",
14689
14731
  "addon-update-available",
14690
- "server-update-available"
14732
+ "server-update-available",
14733
+ "alarm-triggered",
14734
+ "alarm-armed",
14735
+ "alarm-disarmed",
14736
+ "camera-online",
14737
+ "camera-offline",
14738
+ "camera-disabled",
14739
+ "camera-enabled"
14691
14740
  ]);
14741
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14742
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14743
+ "camera-online",
14744
+ "camera-offline",
14745
+ "camera-disabled",
14746
+ "camera-enabled"
14747
+ ]);
14748
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14692
14749
  /**
14693
14750
  * One coherent system-event condition. `kinds` is the required opt-in safety
14694
14751
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14697,6 +14754,18 @@ var NcSystemEventKindSchema = _enum([
14697
14754
  var NcSystemEventConditionSchema = object({
14698
14755
  kinds: array(NcSystemEventKindSchema).min(1),
14699
14756
  deviceIds: array(number().int()).min(1).optional(),
14757
+ /**
14758
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14759
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14760
+ * is what a liveness rule means when nobody said otherwise.
14761
+ *
14762
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14763
+ * one reason: the intake cannot know which devices this household cares
14764
+ * about, and a producer-side filter is one no operator can change. Fails
14765
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14766
+ * does not carry) matches no `deviceTypes` list.
14767
+ */
14768
+ deviceTypes: array(string().min(1)).min(1).optional(),
14700
14769
  nodeIds: array(string().min(1)).min(1).optional(),
14701
14770
  packageNames: array(string().min(1)).min(1).optional()
14702
14771
  });
@@ -14747,6 +14816,47 @@ var NcOccupancyConditionSchema = object({
14747
14816
  sustainSeconds: number().int().min(0).max(3600).default(15)
14748
14817
  });
14749
14818
  /**
14819
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14820
+ *
14821
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14822
+ * reference notifier uses, so an operator moving between them re-uses what
14823
+ * they already know): a rule matches when, over a sampling window of
14824
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14825
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14826
+ *
14827
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14828
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14829
+ * - `labels` — the classifier put at least one of these labels on it.
14830
+ *
14831
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14832
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14833
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14834
+ * is given** — a window in which every sample is trivially a hit would fire on
14835
+ * silence, so the engine refuses such a condition rather than notifying on
14836
+ * nothing (the schema cannot express "at least one of" without becoming a
14837
+ * ZodEffects the cap path would have to special-case).
14838
+ *
14839
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14840
+ * must be FULL before it can match — a window that has been open for two
14841
+ * seconds of its ten is 100% of nothing, and firing on it would make
14842
+ * `samplingSeconds` decorative.
14843
+ *
14844
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14845
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14846
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14847
+ * an operator who typed `dog` mean the same thing.
14848
+ */
14849
+ var NcAudioConditionSchema = object({
14850
+ /** Audio macro labels; absent = any sound (level-only rule). */
14851
+ labels: array(string().min(1)).min(1).optional(),
14852
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14853
+ dbThreshold: number().min(-96).max(0).optional(),
14854
+ /** Percentage of the window's samples that must be hits (1–100). */
14855
+ hitPercent: number().int().min(1).max(100).default(60),
14856
+ /** Length of the sampling window in seconds. */
14857
+ samplingSeconds: number().int().min(1).max(300).default(10)
14858
+ });
14859
+ /**
14750
14860
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14751
14861
  *
14752
14862
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -15019,7 +15129,33 @@ var NcConditionsSchema = object({
15019
15129
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
15020
15130
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
15021
15131
  */
15022
- occupancy: NcOccupancyConditionSchema.optional()
15132
+ occupancy: NcOccupancyConditionSchema.optional(),
15133
+ /**
15134
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
15135
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
15136
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
15137
+ * a window that is not full yet, neither filter given). See
15138
+ * {@link NcAudioCondition}.
15139
+ *
15140
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
15141
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
15142
+ * a detection, a track or a device event (the same fail-closed pairing
15143
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
15144
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
15145
+ * (an `immediate` rule naming an `audio-*` class, one notification per
15146
+ * classified sample) stays exactly as it was for rules that already use it.
15147
+ *
15148
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
15149
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
15150
+ * (`camstack/src/data/notification-center.ts`, guarded by
15151
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
15152
+ * condition fields it does not know when a rule is saved from the phone.
15153
+ * Publishing an editor for a condition the app cannot round-trip is how an
15154
+ * operator loses a rule's conditions by opening it — so the descriptor, the
15155
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
15156
+ * does an audio rule become authorable.
15157
+ */
15158
+ audio: NcAudioConditionSchema.optional()
15023
15159
  });
15024
15160
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
15025
15161
  var NcRuleTargetSchema = object({
@@ -15133,6 +15269,73 @@ var NcThrottleSchema = object({
15133
15269
  */
15134
15270
  granularity: NcThrottleGranularitySchema.optional()
15135
15271
  });
15272
+ /**
15273
+ * How long the confirm gate may hold ONE notification, and how big the picture
15274
+ * it judges may be.
15275
+ *
15276
+ * The clamp is the product decision, not a coincidence of the model: p50 was
15277
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
15278
+ * arrives after the visitor has gone is not a notification. 448 px was enough
15279
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
15280
+ * tokens for pixels the model pools away.
15281
+ */
15282
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
15283
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
15284
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
15285
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
15286
+ var NcConfirmExpectSchema = object({
15287
+ op: _enum([
15288
+ ">=",
15289
+ ">",
15290
+ "<=",
15291
+ "<",
15292
+ "=="
15293
+ ]),
15294
+ count: number().int().min(0).max(1e3)
15295
+ });
15296
+ /**
15297
+ * AI CONFIRM — a vision model looks at the picture this notification is about
15298
+ * to ship and says whether it agrees with the rule.
15299
+ *
15300
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
15301
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
15302
+ * on the operator's phone is not a verdict about this notification.
15303
+ *
15304
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
15305
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
15306
+ * the default and every fail-open is COUNTED, because a gate that always fails
15307
+ * open looks in the log exactly like a gate that works.
15308
+ *
15309
+ * Every field is `.optional()` rather than relied on as a Zod default at the
15310
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
15311
+ * production failures in one day), so the gate reads absent as the constant
15312
+ * above rather than trusting a parse it may never have seen.
15313
+ */
15314
+ var NcConfirmSchema = object({
15315
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
15316
+ * same thing, and both mean "deliver exactly as before". */
15317
+ enabled: boolean().default(false),
15318
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
15319
+ profileId: string().optional(),
15320
+ /**
15321
+ * The operator's question, in his own words. Absent = a question derived
15322
+ * from the rule (its class and its expectation).
15323
+ *
15324
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
15325
+ * banners, signage and plates as instructions if you let them reach the
15326
+ * prompt — proven live — so the authoritative contract stays in the system
15327
+ * turn and only rule-authored words land here.
15328
+ */
15329
+ prompt: string().max(1e3).optional(),
15330
+ /** Fire only when the model's count satisfies this. Absent = the model's
15331
+ * own boolean verdict decides. */
15332
+ expect: NcConfirmExpectSchema.optional(),
15333
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
15334
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
15335
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
15336
+ /** Longest edge the judged image is downscaled to before it is sent. */
15337
+ maxImagePx: number().int().min(64).max(2048).default(448)
15338
+ });
15136
15339
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
15137
15340
  var NcRuleInputSchema = object({
15138
15341
  name: string().min(1).max(200),
@@ -15193,7 +15396,13 @@ var NcRuleInputSchema = object({
15193
15396
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
15194
15397
  * shape as every other actuation.
15195
15398
  */
15196
- actions: NcRuleActionsSchema.optional()
15399
+ actions: NcRuleActionsSchema.optional(),
15400
+ /**
15401
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
15402
+ * a rule that predates the gate must keep delivering byte-for-byte as it
15403
+ * did, and absent is the only way to say that without a migration.
15404
+ */
15405
+ confirm: NcConfirmSchema.optional()
15197
15406
  });
15198
15407
  /**
15199
15408
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -15204,7 +15413,37 @@ var NcRuleInputSchema = object({
15204
15413
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
15205
15414
  * `updateRule` patch.
15206
15415
  */
15207
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
15416
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
15417
+ disabledTargetIds: array(string()).optional(),
15418
+ /**
15419
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
15420
+ *
15421
+ * It makes the key optional to SUPPLY; the parse still materialises the
15422
+ * default when the key is absent. And `NcRuleStore.update` merges with
15423
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
15424
+ * one — which made every partial edit destructive:
15425
+ *
15426
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
15427
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
15428
+ * setEnabled(ruleId, false) → conditions reset to `{}`
15429
+ *
15430
+ * A rule scoped to one camera and one zone silently became a rule that
15431
+ * matches EVERY event on EVERY camera, and lost its `media` policy
15432
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
15433
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
15434
+ * within a minute of a two-field patch.
15435
+ *
15436
+ * So every defaulted field is re-declared here WITHOUT its default. The
15437
+ * inner defaults still apply when the caller DOES send the key — `{}` for
15438
+ * conditions remains a real instruction ("clear them") — and only the
15439
+ * absent key is now genuinely absent.
15440
+ */
15441
+ enabled: boolean().optional(),
15442
+ conditions: NcConditionsSchema.optional(),
15443
+ media: NcMediaPolicySchema.optional(),
15444
+ throttle: NcThrottleSchema.optional(),
15445
+ priority: number().int().min(1).max(5).optional()
15446
+ });
15208
15447
  /** A persisted rule. */
15209
15448
  var NcRuleSchema = NcRuleInputSchema.extend({
15210
15449
  id: string(),
@@ -15505,6 +15744,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15505
15744
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15506
15745
  * copy would lie the first time a rule is disabled.
15507
15746
  */
15747
+ /**
15748
+ * Why a device a mode NAMES is nonetheless not armed by it.
15749
+ *
15750
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15751
+ * per-camera notification switch the Notification Center already owns,
15752
+ * `detection-off` is the device's own detection binding being inactive, and
15753
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15754
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15755
+ * with the switches the operator actually used.
15756
+ */
15757
+ var NcAlarmSkipReasonSchema = _enum([
15758
+ "muted",
15759
+ "detection-off",
15760
+ "offline"
15761
+ ]);
15762
+ var NcAlarmSkippedDeviceSchema = object({
15763
+ deviceId: number().int(),
15764
+ reason: NcAlarmSkipReasonSchema
15765
+ });
15508
15766
  var NcAlarmModeCoverageSchema = object({
15509
15767
  mode: AlarmArmModeSchema,
15510
15768
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15512,7 +15770,18 @@ var NcAlarmModeCoverageSchema = object({
15512
15770
  /** At least one covering rule has no device scope, so the mode covers all. */
15513
15771
  allDevices: boolean(),
15514
15772
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15515
- deviceIds: array(number().int())
15773
+ deviceIds: array(number().int()),
15774
+ /**
15775
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15776
+ * excludes it.
15777
+ *
15778
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15779
+ * twelve makes it false in exactly the way nobody notices until an incident.
15780
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15781
+ * still parses as "nothing known to be skipped" rather than failing the whole
15782
+ * alarm tab.
15783
+ */
15784
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15516
15785
  });
15517
15786
  var NcAlarmConfigSchema = object({
15518
15787
  /**
@@ -23829,7 +24098,19 @@ var RecordingManifestSchema = object({
23829
24098
  * profiles/subtrees/locations on this node). */
23830
24099
  var RecordingDeviceUsageSchema = object({
23831
24100
  deviceId: number(),
23832
- usedBytes: number()
24101
+ usedBytes: number(),
24102
+ /**
24103
+ * Start of this camera's OLDEST indexed segment, across every profile and
24104
+ * location — the "Oldest footage" column in Recordings → Storage, and the
24105
+ * only honest answer to "is retention actually holding?" per camera.
24106
+ *
24107
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
24108
+ * predates this field omits it entirely, and a hub whose types carry the
24109
+ * field must keep validating that older provider's payload: the framework
24110
+ * (types) and the addon ship on different trains, and the addon is usually
24111
+ * the later of the two.
24112
+ */
24113
+ oldestMs: number().nullable().optional()
23833
24114
  });
23834
24115
  /** Recording storage usage + capacity for one storage location. */
23835
24116
  var RecordingLocationUsageSchema = object({
@@ -23857,6 +24138,57 @@ var RecordingStorageUsageSchema = object({
23857
24138
  locations: array(RecordingLocationUsageSchema)
23858
24139
  });
23859
24140
  /**
24141
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
24142
+ *
24143
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
24144
+ * is the operator asking for the EXISTING archive to be brought into line with
24145
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
24146
+ * location, run FIFO behind the single-flight mover.
24147
+ *
24148
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
24149
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
24150
+ * (empty on the plan).
24151
+ */
24152
+ var RecordingRebalanceMoveSchema = object({
24153
+ deviceId: number(),
24154
+ profile: string(),
24155
+ fromLocationId: string(),
24156
+ toLocationId: string(),
24157
+ bytes: number(),
24158
+ files: number().int()
24159
+ });
24160
+ /** Why a pile that is out of place is staying there. Every refusal is
24161
+ * reported: a rebalance that silently drops a camera reads exactly like one
24162
+ * that had nothing to do. */
24163
+ var RecordingRebalanceSkipReasonSchema = _enum([
24164
+ "unassigned",
24165
+ "target-not-writable",
24166
+ "below-threshold",
24167
+ "no-headroom"
24168
+ ]);
24169
+ var RecordingRebalanceSkipSchema = object({
24170
+ deviceId: number(),
24171
+ profile: string(),
24172
+ fromLocationId: string(),
24173
+ /** The location the plan wants; null when the camera has no assignment. */
24174
+ toLocationId: string().nullable(),
24175
+ bytes: number(),
24176
+ reason: RecordingRebalanceSkipReasonSchema
24177
+ });
24178
+ var RecordingRebalancePlanSchema = object({
24179
+ moves: array(RecordingRebalanceMoveSchema),
24180
+ skipped: array(RecordingRebalanceSkipSchema),
24181
+ bytesToMove: number(),
24182
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
24183
+ jobIds: array(string())
24184
+ });
24185
+ var RecordingRebalanceInputSchema = object({
24186
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
24187
+ throttleMbps: number().min(1).max(1e3).optional(),
24188
+ /** Ignore piles smaller than this (default 1 GB). */
24189
+ minMoveGb: number().min(0).optional()
24190
+ });
24191
+ /**
23860
24192
  * Result of locating footage at a wall-clock instant for one device/profile.
23861
24193
  * `segment` carries the covering segment's window; `gap` reports the forward
23862
24194
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -24019,9 +24351,24 @@ method(object({
24019
24351
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24020
24352
  kind: "mutation",
24021
24353
  auth: "admin"
24354
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
24355
+ kind: "mutation",
24356
+ auth: "admin"
24357
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
24358
+ kind: "query",
24359
+ auth: "admin"
24360
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24361
+ kind: "mutation",
24362
+ auth: "admin"
24363
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
24364
+ kind: "query",
24365
+ auth: "admin"
24366
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
24367
+ kind: "mutation",
24368
+ auth: "admin"
24022
24369
  });
24023
24370
  /**
24024
- * `recordingExport` cap — render a footage time range into a single downloadable
24371
+ * `recording-export` cap — render a footage time range into a single downloadable
24025
24372
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
24026
24373
  * bounded lifetime with a durable history, auto-expiry, and optional
24027
24374
  * delete-after-download.
@@ -24037,13 +24384,24 @@ method(object({
24037
24384
  /** Playback-speed multiplier for the render (1 = realtime). */
24038
24385
  var ExportSpeedSchema = number().min(.25).max(32);
24039
24386
  /**
24040
- * One dense interval, in SECONDS FROM THE EXPORT'S OWN `fromMs`.
24041
- *
24042
- * Relative and not absolute epoch on purpose: the renderer's frame-select
24043
- * expression sees ffmpeg's `t`, which starts at 0 for the export's source
24044
- * playlist. Handing it absolute epochs would make every call site responsible
24045
- * for the same subtraction, and the one that forgot would emit a filter that
24046
- * selects nothing silently, as a uniform timelapse.
24387
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
24388
+ *
24389
+ * **Wall clock, not ffmpeg's `t`** and the recorder translates. A caller
24390
+ * derives these bounds from things that happened at a TIME (a track's
24391
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
24392
+ * every segment present for the range, with each recording GAP removed. The
24393
+ * two agree only on a window that recorded without one interruption, and only
24394
+ * the render side knows the segments, so the translation lives there
24395
+ * (`export-dense-map.ts`, addon-pipeline).
24396
+ *
24397
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
24398
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
24399
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
24400
+ * the video was a uniform timelapse, and the log line reported the five ranges
24401
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
24402
+ *
24403
+ * Relative and not absolute epoch, because an absolute epoch would make every
24404
+ * call site responsible for the same subtraction.
24047
24405
  */
24048
24406
  var ExportDenseRangeSchema = object({
24049
24407
  fromSec: number().nonnegative(),
@@ -29362,6 +29720,12 @@ Object.freeze({
29362
29720
  addonId: null,
29363
29721
  access: "create"
29364
29722
  },
29723
+ "recording.cancelRelocateJob": {
29724
+ capName: "recording",
29725
+ capScope: "system",
29726
+ addonId: null,
29727
+ access: "create"
29728
+ },
29365
29729
  "recording.cancelStorageMigrationMove": {
29366
29730
  capName: "recording",
29367
29731
  capScope: "system",
@@ -29416,6 +29780,12 @@ Object.freeze({
29416
29780
  addonId: null,
29417
29781
  access: "view"
29418
29782
  },
29783
+ "recording.listRelocateJobs": {
29784
+ capName: "recording",
29785
+ capScope: "system",
29786
+ addonId: null,
29787
+ access: "view"
29788
+ },
29419
29789
  "recording.locateSegment": {
29420
29790
  capName: "recording",
29421
29791
  capScope: "system",
@@ -29428,6 +29798,12 @@ Object.freeze({
29428
29798
  addonId: null,
29429
29799
  access: "create"
29430
29800
  },
29801
+ "recording.planStorageRebalance": {
29802
+ capName: "recording",
29803
+ capScope: "system",
29804
+ addonId: null,
29805
+ access: "view"
29806
+ },
29431
29807
  "recording.pruneFootage": {
29432
29808
  capName: "recording",
29433
29809
  capScope: "system",
@@ -29452,6 +29828,12 @@ Object.freeze({
29452
29828
  addonId: null,
29453
29829
  access: "create"
29454
29830
  },
29831
+ "recording.relocateFootage": {
29832
+ capName: "recording",
29833
+ capScope: "system",
29834
+ addonId: null,
29835
+ access: "create"
29836
+ },
29455
29837
  "recording.renderClip": {
29456
29838
  capName: "recording",
29457
29839
  capScope: "system",
@@ -29488,44 +29870,50 @@ Object.freeze({
29488
29870
  addonId: null,
29489
29871
  access: "create"
29490
29872
  },
29873
+ "recording.startStorageRebalance": {
29874
+ capName: "recording",
29875
+ capScope: "system",
29876
+ addonId: null,
29877
+ access: "create"
29878
+ },
29491
29879
  "recordingExport.cancelExport": {
29492
- capName: "recordingExport",
29880
+ capName: "recording-export",
29493
29881
  capScope: "system",
29494
29882
  addonId: null,
29495
29883
  access: "create"
29496
29884
  },
29497
29885
  "recordingExport.createExport": {
29498
- capName: "recordingExport",
29886
+ capName: "recording-export",
29499
29887
  capScope: "system",
29500
29888
  addonId: null,
29501
29889
  access: "create"
29502
29890
  },
29503
29891
  "recordingExport.deleteExport": {
29504
- capName: "recordingExport",
29892
+ capName: "recording-export",
29505
29893
  capScope: "system",
29506
29894
  addonId: null,
29507
29895
  access: "delete"
29508
29896
  },
29509
29897
  "recordingExport.getDownloadUrl": {
29510
- capName: "recordingExport",
29898
+ capName: "recording-export",
29511
29899
  capScope: "system",
29512
29900
  addonId: null,
29513
29901
  access: "view"
29514
29902
  },
29515
29903
  "recordingExport.getExport": {
29516
- capName: "recordingExport",
29904
+ capName: "recording-export",
29517
29905
  capScope: "system",
29518
29906
  addonId: null,
29519
29907
  access: "view"
29520
29908
  },
29521
29909
  "recordingExport.listExports": {
29522
- capName: "recordingExport",
29910
+ capName: "recording-export",
29523
29911
  capScope: "system",
29524
29912
  addonId: null,
29525
29913
  access: "view"
29526
29914
  },
29527
29915
  "recordingExport.readExportBytes": {
29528
- capName: "recordingExport",
29916
+ capName: "recording-export",
29529
29917
  capScope: "system",
29530
29918
  addonId: null,
29531
29919
  access: "view"
@@ -30902,6 +31290,104 @@ var FramerateField = number().int().min(1).max(60);
30902
31290
  var TargetsField = array(NcRuleTargetSchema).min(1);
30903
31291
  var PriorityField = number().int().min(1).max(5);
30904
31292
  /**
31293
+ * Explicit override of the DENSE sampling cadence, seconds.
31294
+ *
31295
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
31296
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
31297
+ * made that same base 3 s and rendered a person pass as two frames.)
31298
+ *
31299
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
31300
+ * `denseCadenceSec` and played at `framerate` occupies
31301
+ *
31302
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
31303
+ *
31304
+ * 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.
31305
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
31306
+ * and therefore the length of a quiet night, does not move.
31307
+ *
31308
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
31309
+ * the recording has them returns the same frames, requested twice. Must be
31310
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
31311
+ * a uniform video the operator believes is two-rate — and upsert refuses it
31312
+ * rather than letting the export cap reject the render hours after the window.
31313
+ */
31314
+ var DenseCadenceSecField = number().min(.1).max(3600);
31315
+ /**
31316
+ * Minimum seconds of OUTPUT video each detection range must occupy.
31317
+ *
31318
+ * The operator-facing form of the arithmetic above: instead of solving for a
31319
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
31320
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
31321
+ * that range every ~583 ms.
31322
+ *
31323
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
31324
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
31325
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
31326
+ * ranges are sampled denser than they need. Per-range cadences require a cap
31327
+ * schema change and are the tracked follow-up.
31328
+ *
31329
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
31330
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
31331
+ * by real footage, never met by duplicating frames into motion that never
31332
+ * happened.
31333
+ */
31334
+ var MinDwellSecField = number().min(0).max(60);
31335
+ /**
31336
+ * Caption burned into the notification's preview frame.
31337
+ *
31338
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
31339
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
31340
+ * templating dialect for one field would be a second thing to explain.
31341
+ *
31342
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
31343
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
31344
+ * the reason this is not `.min(1)`.
31345
+ */
31346
+ var PreviewTextField = string().max(200);
31347
+ /**
31348
+ * Whether the notification's preview is a STILL or a short animation.
31349
+ *
31350
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
31351
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
31352
+ * night reads better as three seconds of motion than as one frame of it. Both
31353
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
31354
+ * simply applies it to a dozen frames sampled across the render and assembles
31355
+ * them.
31356
+ *
31357
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
31358
+ * seeks and a palette pass, and no rule that never asked for one should start
31359
+ * paying that on the deploy that shipped it.
31360
+ *
31361
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
31362
+ */
31363
+ var PreviewModeField = _enum(["image", "gif"]);
31364
+ /**
31365
+ * Which detection classes the notification reports counts for.
31366
+ *
31367
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
31368
+ * plan — no second query — aggregated per class. Absent or empty means "every
31369
+ * class the window actually contained", which is what an operator who never
31370
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
31371
+ * counts cars all night).
31372
+ *
31373
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
31374
+ * …). An unknown name simply never matches and reports nothing — it is not an
31375
+ * error, because a rule may legitimately name a class this camera's model does
31376
+ * not emit.
31377
+ *
31378
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
31379
+ * - `{{detections}}` — total over the reported classes
31380
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
31381
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
31382
+ * one per class, `count_` + the class name
31383
+ *
31384
+ * With NO custom body template the summary is appended to the derived body, and
31385
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
31386
+ * reads. With a custom template the operator owns every word — nothing is
31387
+ * appended, so `{{detectionSummary}}` is how he asks for it.
31388
+ */
31389
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
31390
+ /**
30905
31391
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30906
31392
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30907
31393
  * here (see the ownership note above).
@@ -30921,9 +31407,30 @@ var TimelapseRuleInputSchema = object({
30921
31407
  cadenceSec: CadenceSecField.default(15),
30922
31408
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30923
31409
  framerate: FramerateField.default(10),
31410
+ /**
31411
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
31412
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
31413
+ * field gets.
31414
+ */
31415
+ denseCadenceSec: DenseCadenceSecField.optional(),
31416
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
31417
+ minDwellSec: MinDwellSecField.optional(),
30924
31418
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30925
31419
  targets: TargetsField,
30926
31420
  template: TimelapseTemplateSchema.optional(),
31421
+ /**
31422
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
31423
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
31424
+ *
31425
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
31426
+ * the notification's title/body, and clearing it (`template: null`) must not
31427
+ * silently clear the caption too.
31428
+ */
31429
+ previewText: PreviewTextField.optional(),
31430
+ /** Still or animation — see {@link PreviewModeField}. */
31431
+ previewMode: PreviewModeField.default("image"),
31432
+ /** Classes the notification counts — see {@link ReportClassesField}. */
31433
+ reportClasses: ReportClassesField.optional(),
30927
31434
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30928
31435
  priority: PriorityField.default(3)
30929
31436
  });
@@ -30934,8 +31441,13 @@ object({
30934
31441
  schedule: NcScheduleSchema.optional(),
30935
31442
  cadenceSec: CadenceSecField.optional(),
30936
31443
  framerate: FramerateField.optional(),
31444
+ denseCadenceSec: DenseCadenceSecField.optional(),
31445
+ minDwellSec: MinDwellSecField.optional(),
30937
31446
  targets: TargetsField.optional(),
30938
31447
  template: TimelapseTemplateSchema.nullable().optional(),
31448
+ previewText: PreviewTextField.optional(),
31449
+ previewMode: PreviewModeField.optional(),
31450
+ reportClasses: ReportClassesField.optional(),
30939
31451
  priority: PriorityField.optional()
30940
31452
  });
30941
31453
  TimelapseRuleInputSchema.extend({
@@ -31019,25 +31531,32 @@ object({
31019
31531
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
31020
31532
  object({
31021
31533
  /**
31022
- * How long a retained native frame is served before it counts as a miss.
31534
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
31535
+ * detection result.
31023
31536
  *
31024
- * Must cover the FULL late-crop horizon: detection inference + the
31025
- * cross-process inference-result hop to hub post-analysis + tracking + the
31026
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
31027
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
31028
- * RAM per busy camera grows linearly with no measured hit-rate gain.
31537
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
31538
+ * a time window was never related to the event the pixels were waiting for.
31539
+ * A held frame now lives from delivery until the runner has its `FrameResult`
31540
+ * at which moment the runner cuts the subject tiles it actually wanted and
31541
+ * releases the frame. The bound exists only so a runner that stops answering
31542
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
31543
+ *
31544
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
31545
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
31546
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
31547
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
31548
+ * `holdOverflow` on the metrics line is what says you need it.
31029
31549
  */
31030
- ttlMs: number().int().min(250).max(1e4),
31550
+ holdFrames: number().int().min(1).max(64),
31031
31551
  /**
31032
31552
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
31033
31553
  *
31034
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
31035
- * which one is actually binding before reasoning from that. At the shipped
31036
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
31037
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
31038
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
31039
- * change that admits fewer frames buys retention WINDOW at constant RAM
31040
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
31554
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
31555
+ * is what decides how much is held, and the ceiling is the number above which
31556
+ * something is wrong. Before that it was the effective cap at 1024 MB with
31557
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
31558
+ * with the TTL expiring nothing, which is exactly the confusion the hold
31559
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
31041
31560
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
31042
31561
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
31043
31562
  * to replace).
@@ -31063,22 +31582,45 @@ object({
31063
31582
  * there is the signal that some caller names frames outside the inference set
31064
31583
  * and that this must go back to `all`.
31065
31584
  */
31066
- admission: NativeLeaseAdmissionSchema
31585
+ admission: NativeLeaseAdmissionSchema,
31586
+ /**
31587
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
31588
+ * compressed native crops the worker cuts at the moment a frame's detection
31589
+ * result arrives, and keeps long after the frame itself is freed.
31590
+ *
31591
+ * This is the knob that replaced the old retention window, and it buys about
31592
+ * three orders of magnitude more of it: a tile is one subject at native
31593
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
31594
+ * the frame it was cut from. A frame on which nothing was detected costs
31595
+ * nothing at all, which is the real change — the old lease paid per FRAME and
31596
+ * was interrogated per SUBJECT.
31597
+ *
31598
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
31599
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
31600
+ * reproduce that.
31601
+ */
31602
+ tileBudgetMb: number().int().min(0).max(1024)
31067
31603
  });
31068
31604
  /**
31069
- * The values in force when the operator has set nothing — byte-for-byte the
31070
- * constants the decode worker shipped with as env-var defaults, so making these
31071
- * settings changed no behaviour on the day it landed.
31605
+ * The values in force when the operator has set nothing.
31606
+ *
31607
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
31608
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
31609
+ * in the same change that redefines it would make a regression and a retune
31610
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
31611
+ * live traffic.
31072
31612
  */
31073
31613
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
31074
- ttlMs: 1200,
31614
+ holdFrames: 8,
31075
31615
  budgetMb: 1024,
31076
31616
  activityMs: 15e3,
31617
+ tileBudgetMb: 64,
31077
31618
  admission: "inferred"
31078
31619
  };
31079
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
31620
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
31080
31621
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
31081
31622
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
31623
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
31082
31624
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
31083
31625
  /**
31084
31626
  * Compute the stable 64-char lowercase-hex fingerprint of a device's