@camstack/addon-post-analysis 1.2.66 → 1.2.67

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.
@@ -7607,6 +7607,13 @@ var CameraSwitchGroupSchema = object({
7607
7607
  fetchedAt: number()
7608
7608
  });
7609
7609
  /**
7610
+ * The wrapper capability each wrapper-backed switch controls. Named constants
7611
+ * because the same strings appear in `legacy-migrations.ts`, in
7612
+ * `isCapActiveForDevice` call sites and in the fake harness — a typo in any of
7613
+ * them is a switch that silently writes a binding nobody reads.
7614
+ */
7615
+ var DETECTION_PIPELINE_CAP_NAME = "detection-pipeline";
7616
+ /**
7610
7617
  * Ops-log — the durable, append-only operations audit shared by the
7611
7618
  * recordings and events management surfaces.
7612
7619
  *
@@ -7831,7 +7838,15 @@ function deriveRecordingMode(config) {
7831
7838
  * Each completed/failed run also lands one durable ops-log row on its owning
7832
7839
  * addon surface.
7833
7840
  */
7841
+ /**
7842
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7843
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7844
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7845
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7846
+ * runs at all.
7847
+ */
7834
7848
  var RelocateJobStateSchema = _enum([
7849
+ "queued",
7835
7850
  "running",
7836
7851
  "done",
7837
7852
  "failed",
@@ -7866,6 +7881,15 @@ var RelocateFootageInputSchema = object({
7866
7881
  /** Limits relocation to the logical profile class. Omit only for the
7867
7882
  * pre-orchestration compatibility path. */
7868
7883
  footageClass: RelocateFootageClassSchema.optional(),
7884
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7885
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7886
+ * unit is a (camera, profile) pile, not a disk. */
7887
+ deviceId: number().int().optional(),
7888
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7889
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7890
+ * placement plan assigns those two independently, so a rebalance that could
7891
+ * only say "recordings" would move footage the plan never asked to move. */
7892
+ profiles: array(string()).optional(),
7869
7893
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7870
7894
  * never allowed to starve live writers. */
7871
7895
  throttleMbps: number().min(1).max(1e3).optional()
@@ -14424,6 +14448,13 @@ var MaskGridDimsSchema = object({
14424
14448
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14425
14449
  * this one field keeps the schema additive — a rule still declares exactly
14426
14450
  * one trigger.
14451
+ *
14452
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14453
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14454
+ * mirror.ts` fails the build on a member the app cannot render) and every
14455
+ * member costs a release train. A sustained-sound rule is therefore an
14456
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14457
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14427
14458
  */
14428
14459
  var NcDeliverySchema = _enum([
14429
14460
  "immediate",
@@ -14438,15 +14469,32 @@ var NcDeliverySchema = _enum([
14438
14469
  * depend on a provider's raw event name or payload shape.
14439
14470
  */
14440
14471
  var NcSystemEventKindSchema = _enum([
14441
- "camera-online",
14442
- "camera-offline",
14472
+ "device-online",
14473
+ "device-offline",
14474
+ "device-disabled",
14475
+ "device-enabled",
14443
14476
  "stream-online",
14444
14477
  "stream-offline",
14445
14478
  "node-online",
14446
14479
  "node-offline",
14447
14480
  "addon-update-available",
14448
- "server-update-available"
14481
+ "server-update-available",
14482
+ "alarm-triggered",
14483
+ "alarm-armed",
14484
+ "alarm-disarmed",
14485
+ "camera-online",
14486
+ "camera-offline",
14487
+ "camera-disabled",
14488
+ "camera-enabled"
14449
14489
  ]);
14490
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14491
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14492
+ "camera-online",
14493
+ "camera-offline",
14494
+ "camera-disabled",
14495
+ "camera-enabled"
14496
+ ]);
14497
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14450
14498
  /**
14451
14499
  * One coherent system-event condition. `kinds` is the required opt-in safety
14452
14500
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14455,6 +14503,18 @@ var NcSystemEventKindSchema = _enum([
14455
14503
  var NcSystemEventConditionSchema = object({
14456
14504
  kinds: array(NcSystemEventKindSchema).min(1),
14457
14505
  deviceIds: array(number().int()).min(1).optional(),
14506
+ /**
14507
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14508
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14509
+ * is what a liveness rule means when nobody said otherwise.
14510
+ *
14511
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14512
+ * one reason: the intake cannot know which devices this household cares
14513
+ * about, and a producer-side filter is one no operator can change. Fails
14514
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14515
+ * does not carry) matches no `deviceTypes` list.
14516
+ */
14517
+ deviceTypes: array(string().min(1)).min(1).optional(),
14458
14518
  nodeIds: array(string().min(1)).min(1).optional(),
14459
14519
  packageNames: array(string().min(1)).min(1).optional()
14460
14520
  });
@@ -14505,6 +14565,47 @@ var NcOccupancyConditionSchema = object({
14505
14565
  sustainSeconds: number().int().min(0).max(3600).default(15)
14506
14566
  });
14507
14567
  /**
14568
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14569
+ *
14570
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14571
+ * reference notifier uses, so an operator moving between them re-uses what
14572
+ * they already know): a rule matches when, over a sampling window of
14573
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14574
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14575
+ *
14576
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14577
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14578
+ * - `labels` — the classifier put at least one of these labels on it.
14579
+ *
14580
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14581
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14582
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14583
+ * is given** — a window in which every sample is trivially a hit would fire on
14584
+ * silence, so the engine refuses such a condition rather than notifying on
14585
+ * nothing (the schema cannot express "at least one of" without becoming a
14586
+ * ZodEffects the cap path would have to special-case).
14587
+ *
14588
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14589
+ * must be FULL before it can match — a window that has been open for two
14590
+ * seconds of its ten is 100% of nothing, and firing on it would make
14591
+ * `samplingSeconds` decorative.
14592
+ *
14593
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14594
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14595
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14596
+ * an operator who typed `dog` mean the same thing.
14597
+ */
14598
+ var NcAudioConditionSchema = object({
14599
+ /** Audio macro labels; absent = any sound (level-only rule). */
14600
+ labels: array(string().min(1)).min(1).optional(),
14601
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14602
+ dbThreshold: number().min(-96).max(0).optional(),
14603
+ /** Percentage of the window's samples that must be hits (1–100). */
14604
+ hitPercent: number().int().min(1).max(100).default(60),
14605
+ /** Length of the sampling window in seconds. */
14606
+ samplingSeconds: number().int().min(1).max(300).default(10)
14607
+ });
14608
+ /**
14508
14609
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14509
14610
  *
14510
14611
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14777,7 +14878,33 @@ var NcConditionsSchema = object({
14777
14878
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14778
14879
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14779
14880
  */
14780
- occupancy: NcOccupancyConditionSchema.optional()
14881
+ occupancy: NcOccupancyConditionSchema.optional(),
14882
+ /**
14883
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14884
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14885
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14886
+ * a window that is not full yet, neither filter given). See
14887
+ * {@link NcAudioCondition}.
14888
+ *
14889
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14890
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14891
+ * a detection, a track or a device event (the same fail-closed pairing
14892
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14893
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14894
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14895
+ * classified sample) stays exactly as it was for rules that already use it.
14896
+ *
14897
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14898
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14899
+ * (`camstack/src/data/notification-center.ts`, guarded by
14900
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14901
+ * condition fields it does not know when a rule is saved from the phone.
14902
+ * Publishing an editor for a condition the app cannot round-trip is how an
14903
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14904
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14905
+ * does an audio rule become authorable.
14906
+ */
14907
+ audio: NcAudioConditionSchema.optional()
14781
14908
  });
14782
14909
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14783
14910
  var NcRuleTargetSchema = object({
@@ -14891,6 +15018,73 @@ var NcThrottleSchema = object({
14891
15018
  */
14892
15019
  granularity: NcThrottleGranularitySchema.optional()
14893
15020
  });
15021
+ /**
15022
+ * How long the confirm gate may hold ONE notification, and how big the picture
15023
+ * it judges may be.
15024
+ *
15025
+ * The clamp is the product decision, not a coincidence of the model: p50 was
15026
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
15027
+ * arrives after the visitor has gone is not a notification. 448 px was enough
15028
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
15029
+ * tokens for pixels the model pools away.
15030
+ */
15031
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
15032
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
15033
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
15034
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
15035
+ var NcConfirmExpectSchema = object({
15036
+ op: _enum([
15037
+ ">=",
15038
+ ">",
15039
+ "<=",
15040
+ "<",
15041
+ "=="
15042
+ ]),
15043
+ count: number().int().min(0).max(1e3)
15044
+ });
15045
+ /**
15046
+ * AI CONFIRM — a vision model looks at the picture this notification is about
15047
+ * to ship and says whether it agrees with the rule.
15048
+ *
15049
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
15050
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
15051
+ * on the operator's phone is not a verdict about this notification.
15052
+ *
15053
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
15054
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
15055
+ * the default and every fail-open is COUNTED, because a gate that always fails
15056
+ * open looks in the log exactly like a gate that works.
15057
+ *
15058
+ * Every field is `.optional()` rather than relied on as a Zod default at the
15059
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
15060
+ * production failures in one day), so the gate reads absent as the constant
15061
+ * above rather than trusting a parse it may never have seen.
15062
+ */
15063
+ var NcConfirmSchema = object({
15064
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
15065
+ * same thing, and both mean "deliver exactly as before". */
15066
+ enabled: boolean().default(false),
15067
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
15068
+ profileId: string().optional(),
15069
+ /**
15070
+ * The operator's question, in his own words. Absent = a question derived
15071
+ * from the rule (its class and its expectation).
15072
+ *
15073
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
15074
+ * banners, signage and plates as instructions if you let them reach the
15075
+ * prompt — proven live — so the authoritative contract stays in the system
15076
+ * turn and only rule-authored words land here.
15077
+ */
15078
+ prompt: string().max(1e3).optional(),
15079
+ /** Fire only when the model's count satisfies this. Absent = the model's
15080
+ * own boolean verdict decides. */
15081
+ expect: NcConfirmExpectSchema.optional(),
15082
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
15083
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
15084
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
15085
+ /** Longest edge the judged image is downscaled to before it is sent. */
15086
+ maxImagePx: number().int().min(64).max(2048).default(448)
15087
+ });
14894
15088
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14895
15089
  var NcRuleInputSchema = object({
14896
15090
  name: string().min(1).max(200),
@@ -14951,7 +15145,13 @@ var NcRuleInputSchema = object({
14951
15145
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14952
15146
  * shape as every other actuation.
14953
15147
  */
14954
- actions: NcRuleActionsSchema.optional()
15148
+ actions: NcRuleActionsSchema.optional(),
15149
+ /**
15150
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
15151
+ * a rule that predates the gate must keep delivering byte-for-byte as it
15152
+ * did, and absent is the only way to say that without a migration.
15153
+ */
15154
+ confirm: NcConfirmSchema.optional()
14955
15155
  });
14956
15156
  /**
14957
15157
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14962,7 +15162,37 @@ var NcRuleInputSchema = object({
14962
15162
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14963
15163
  * `updateRule` patch.
14964
15164
  */
14965
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
15165
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
15166
+ disabledTargetIds: array(string()).optional(),
15167
+ /**
15168
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
15169
+ *
15170
+ * It makes the key optional to SUPPLY; the parse still materialises the
15171
+ * default when the key is absent. And `NcRuleStore.update` merges with
15172
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
15173
+ * one — which made every partial edit destructive:
15174
+ *
15175
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
15176
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
15177
+ * setEnabled(ruleId, false) → conditions reset to `{}`
15178
+ *
15179
+ * A rule scoped to one camera and one zone silently became a rule that
15180
+ * matches EVERY event on EVERY camera, and lost its `media` policy
15181
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
15182
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
15183
+ * within a minute of a two-field patch.
15184
+ *
15185
+ * So every defaulted field is re-declared here WITHOUT its default. The
15186
+ * inner defaults still apply when the caller DOES send the key — `{}` for
15187
+ * conditions remains a real instruction ("clear them") — and only the
15188
+ * absent key is now genuinely absent.
15189
+ */
15190
+ enabled: boolean().optional(),
15191
+ conditions: NcConditionsSchema.optional(),
15192
+ media: NcMediaPolicySchema.optional(),
15193
+ throttle: NcThrottleSchema.optional(),
15194
+ priority: number().int().min(1).max(5).optional()
15195
+ });
14966
15196
  /** A persisted rule. */
14967
15197
  var NcRuleSchema = NcRuleInputSchema.extend({
14968
15198
  id: string(),
@@ -15075,12 +15305,20 @@ var NC_CONDITION_CATALOG = [
15075
15305
  valueType: "systemEvent",
15076
15306
  options: [
15077
15307
  {
15078
- value: "camera-online",
15079
- label: "Camera online"
15308
+ value: "device-online",
15309
+ label: "Device online"
15080
15310
  },
15081
15311
  {
15082
- value: "camera-offline",
15083
- label: "Camera offline"
15312
+ value: "device-offline",
15313
+ label: "Device offline"
15314
+ },
15315
+ {
15316
+ value: "device-disabled",
15317
+ label: "Device switched off"
15318
+ },
15319
+ {
15320
+ value: "device-enabled",
15321
+ label: "Device switched on"
15084
15322
  },
15085
15323
  {
15086
15324
  value: "stream-online",
@@ -15105,12 +15343,24 @@ var NC_CONDITION_CATALOG = [
15105
15343
  {
15106
15344
  value: "server-update-available",
15107
15345
  label: "Server update available"
15346
+ },
15347
+ {
15348
+ value: "alarm-triggered",
15349
+ label: "Alarm triggered"
15350
+ },
15351
+ {
15352
+ value: "alarm-armed",
15353
+ label: "Alarm armed"
15354
+ },
15355
+ {
15356
+ value: "alarm-disarmed",
15357
+ label: "Alarm disarmed"
15108
15358
  }
15109
15359
  ],
15110
15360
  operator: "in",
15111
15361
  appliesTo: ["system-event"],
15112
15362
  phase: "P1",
15113
- description: "Infrastructure and update events. Optionally narrow camera/stream events by device, node events by node id, and addon updates by package name."
15363
+ description: "Infrastructure and update events. Device liveness covers EVERY device type — narrow it by device type (cameras only, say) and/or by device, node events by node id, and addon updates by package name."
15114
15364
  },
15115
15365
  {
15116
15366
  id: "devices",
@@ -15634,6 +15884,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15634
15884
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15635
15885
  * copy would lie the first time a rule is disabled.
15636
15886
  */
15887
+ /**
15888
+ * Why a device a mode NAMES is nonetheless not armed by it.
15889
+ *
15890
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15891
+ * per-camera notification switch the Notification Center already owns,
15892
+ * `detection-off` is the device's own detection binding being inactive, and
15893
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15894
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15895
+ * with the switches the operator actually used.
15896
+ */
15897
+ var NcAlarmSkipReasonSchema = _enum([
15898
+ "muted",
15899
+ "detection-off",
15900
+ "offline"
15901
+ ]);
15902
+ var NcAlarmSkippedDeviceSchema = object({
15903
+ deviceId: number().int(),
15904
+ reason: NcAlarmSkipReasonSchema
15905
+ });
15637
15906
  var NcAlarmModeCoverageSchema = object({
15638
15907
  mode: AlarmArmModeSchema,
15639
15908
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15641,7 +15910,18 @@ var NcAlarmModeCoverageSchema = object({
15641
15910
  /** At least one covering rule has no device scope, so the mode covers all. */
15642
15911
  allDevices: boolean(),
15643
15912
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15644
- deviceIds: array(number().int())
15913
+ deviceIds: array(number().int()),
15914
+ /**
15915
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15916
+ * excludes it.
15917
+ *
15918
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15919
+ * twelve makes it false in exactly the way nobody notices until an incident.
15920
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15921
+ * still parses as "nothing known to be skipped" rather than failing the whole
15922
+ * alarm tab.
15923
+ */
15924
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15645
15925
  });
15646
15926
  var NcAlarmConfigSchema = object({
15647
15927
  /**
@@ -25823,7 +26103,19 @@ var RecordingManifestSchema = object({
25823
26103
  * profiles/subtrees/locations on this node). */
25824
26104
  var RecordingDeviceUsageSchema = object({
25825
26105
  deviceId: number(),
25826
- usedBytes: number()
26106
+ usedBytes: number(),
26107
+ /**
26108
+ * Start of this camera's OLDEST indexed segment, across every profile and
26109
+ * location — the "Oldest footage" column in Recordings → Storage, and the
26110
+ * only honest answer to "is retention actually holding?" per camera.
26111
+ *
26112
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
26113
+ * predates this field omits it entirely, and a hub whose types carry the
26114
+ * field must keep validating that older provider's payload: the framework
26115
+ * (types) and the addon ship on different trains, and the addon is usually
26116
+ * the later of the two.
26117
+ */
26118
+ oldestMs: number().nullable().optional()
25827
26119
  });
25828
26120
  /** Recording storage usage + capacity for one storage location. */
25829
26121
  var RecordingLocationUsageSchema = object({
@@ -25851,6 +26143,57 @@ var RecordingStorageUsageSchema = object({
25851
26143
  locations: array(RecordingLocationUsageSchema)
25852
26144
  });
25853
26145
  /**
26146
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
26147
+ *
26148
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
26149
+ * is the operator asking for the EXISTING archive to be brought into line with
26150
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
26151
+ * location, run FIFO behind the single-flight mover.
26152
+ *
26153
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
26154
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
26155
+ * (empty on the plan).
26156
+ */
26157
+ var RecordingRebalanceMoveSchema = object({
26158
+ deviceId: number(),
26159
+ profile: string(),
26160
+ fromLocationId: string(),
26161
+ toLocationId: string(),
26162
+ bytes: number(),
26163
+ files: number().int()
26164
+ });
26165
+ /** Why a pile that is out of place is staying there. Every refusal is
26166
+ * reported: a rebalance that silently drops a camera reads exactly like one
26167
+ * that had nothing to do. */
26168
+ var RecordingRebalanceSkipReasonSchema = _enum([
26169
+ "unassigned",
26170
+ "target-not-writable",
26171
+ "below-threshold",
26172
+ "no-headroom"
26173
+ ]);
26174
+ var RecordingRebalanceSkipSchema = object({
26175
+ deviceId: number(),
26176
+ profile: string(),
26177
+ fromLocationId: string(),
26178
+ /** The location the plan wants; null when the camera has no assignment. */
26179
+ toLocationId: string().nullable(),
26180
+ bytes: number(),
26181
+ reason: RecordingRebalanceSkipReasonSchema
26182
+ });
26183
+ var RecordingRebalancePlanSchema = object({
26184
+ moves: array(RecordingRebalanceMoveSchema),
26185
+ skipped: array(RecordingRebalanceSkipSchema),
26186
+ bytesToMove: number(),
26187
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
26188
+ jobIds: array(string())
26189
+ });
26190
+ var RecordingRebalanceInputSchema = object({
26191
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
26192
+ throttleMbps: number().min(1).max(1e3).optional(),
26193
+ /** Ignore piles smaller than this (default 1 GB). */
26194
+ minMoveGb: number().min(0).optional()
26195
+ });
26196
+ /**
25854
26197
  * Result of locating footage at a wall-clock instant for one device/profile.
25855
26198
  * `segment` carries the covering segment's window; `gap` reports the forward
25856
26199
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -26013,6 +26356,21 @@ method(object({
26013
26356
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26014
26357
  kind: "mutation",
26015
26358
  auth: "admin"
26359
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
26360
+ kind: "mutation",
26361
+ auth: "admin"
26362
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
26363
+ kind: "query",
26364
+ auth: "admin"
26365
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26366
+ kind: "mutation",
26367
+ auth: "admin"
26368
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26369
+ kind: "query",
26370
+ auth: "admin"
26371
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26372
+ kind: "mutation",
26373
+ auth: "admin"
26016
26374
  });
26017
26375
  /**
26018
26376
  * `recording-export` cap — render a footage time range into a single downloadable
@@ -32912,6 +33270,12 @@ Object.freeze({
32912
33270
  addonId: null,
32913
33271
  access: "create"
32914
33272
  },
33273
+ "recording.cancelRelocateJob": {
33274
+ capName: "recording",
33275
+ capScope: "system",
33276
+ addonId: null,
33277
+ access: "create"
33278
+ },
32915
33279
  "recording.cancelStorageMigrationMove": {
32916
33280
  capName: "recording",
32917
33281
  capScope: "system",
@@ -32966,6 +33330,12 @@ Object.freeze({
32966
33330
  addonId: null,
32967
33331
  access: "view"
32968
33332
  },
33333
+ "recording.listRelocateJobs": {
33334
+ capName: "recording",
33335
+ capScope: "system",
33336
+ addonId: null,
33337
+ access: "view"
33338
+ },
32969
33339
  "recording.locateSegment": {
32970
33340
  capName: "recording",
32971
33341
  capScope: "system",
@@ -32978,6 +33348,12 @@ Object.freeze({
32978
33348
  addonId: null,
32979
33349
  access: "create"
32980
33350
  },
33351
+ "recording.planStorageRebalance": {
33352
+ capName: "recording",
33353
+ capScope: "system",
33354
+ addonId: null,
33355
+ access: "view"
33356
+ },
32981
33357
  "recording.pruneFootage": {
32982
33358
  capName: "recording",
32983
33359
  capScope: "system",
@@ -33002,6 +33378,12 @@ Object.freeze({
33002
33378
  addonId: null,
33003
33379
  access: "create"
33004
33380
  },
33381
+ "recording.relocateFootage": {
33382
+ capName: "recording",
33383
+ capScope: "system",
33384
+ addonId: null,
33385
+ access: "create"
33386
+ },
33005
33387
  "recording.renderClip": {
33006
33388
  capName: "recording",
33007
33389
  capScope: "system",
@@ -33038,6 +33420,12 @@ Object.freeze({
33038
33420
  addonId: null,
33039
33421
  access: "create"
33040
33422
  },
33423
+ "recording.startStorageRebalance": {
33424
+ capName: "recording",
33425
+ capScope: "system",
33426
+ addonId: null,
33427
+ access: "create"
33428
+ },
33041
33429
  "recordingExport.cancelExport": {
33042
33430
  capName: "recording-export",
33043
33431
  capScope: "system",
@@ -34512,6 +34900,111 @@ var FramerateField = number().int().min(1).max(60);
34512
34900
  var TargetsField = array(NcRuleTargetSchema).min(1);
34513
34901
  var PriorityField = number().int().min(1).max(5);
34514
34902
  /**
34903
+ * Floor on any dense cadence, seconds — the recording's own frame interval.
34904
+ *
34905
+ * Declared here because it bounds BOTH the rule field and the renderer's
34906
+ * derivation, and two copies of a floor are two floors that can drift.
34907
+ */
34908
+ var TIMELAPSE_DENSE_FLOOR_SEC = .1;
34909
+ /**
34910
+ * Explicit override of the DENSE sampling cadence, seconds.
34911
+ *
34912
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
34913
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
34914
+ * made that same base 3 s and rendered a person pass as two frames.)
34915
+ *
34916
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
34917
+ * `denseCadenceSec` and played at `framerate` occupies
34918
+ *
34919
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
34920
+ *
34921
+ * 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.
34922
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
34923
+ * and therefore the length of a quiet night, does not move.
34924
+ *
34925
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
34926
+ * the recording has them returns the same frames, requested twice. Must be
34927
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
34928
+ * a uniform video the operator believes is two-rate — and upsert refuses it
34929
+ * rather than letting the export cap reject the render hours after the window.
34930
+ */
34931
+ var DenseCadenceSecField = number().min(TIMELAPSE_DENSE_FLOOR_SEC).max(3600);
34932
+ /**
34933
+ * Minimum seconds of OUTPUT video each detection range must occupy.
34934
+ *
34935
+ * The operator-facing form of the arithmetic above: instead of solving for a
34936
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
34937
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
34938
+ * that range every ~583 ms.
34939
+ *
34940
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
34941
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
34942
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
34943
+ * ranges are sampled denser than they need. Per-range cadences require a cap
34944
+ * schema change and are the tracked follow-up.
34945
+ *
34946
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
34947
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
34948
+ * by real footage, never met by duplicating frames into motion that never
34949
+ * happened.
34950
+ */
34951
+ var MinDwellSecField = number().min(0).max(60);
34952
+ /**
34953
+ * Caption burned into the notification's preview frame.
34954
+ *
34955
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
34956
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
34957
+ * templating dialect for one field would be a second thing to explain.
34958
+ *
34959
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
34960
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
34961
+ * the reason this is not `.min(1)`.
34962
+ */
34963
+ var PreviewTextField = string().max(200);
34964
+ /**
34965
+ * Whether the notification's preview is a STILL or a short animation.
34966
+ *
34967
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
34968
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
34969
+ * night reads better as three seconds of motion than as one frame of it. Both
34970
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
34971
+ * simply applies it to a dozen frames sampled across the render and assembles
34972
+ * them.
34973
+ *
34974
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
34975
+ * seeks and a palette pass, and no rule that never asked for one should start
34976
+ * paying that on the deploy that shipped it.
34977
+ *
34978
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
34979
+ */
34980
+ var PreviewModeField = _enum(["image", "gif"]);
34981
+ /**
34982
+ * Which detection classes the notification reports counts for.
34983
+ *
34984
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
34985
+ * plan — no second query — aggregated per class. Absent or empty means "every
34986
+ * class the window actually contained", which is what an operator who never
34987
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
34988
+ * counts cars all night).
34989
+ *
34990
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
34991
+ * …). An unknown name simply never matches and reports nothing — it is not an
34992
+ * error, because a rule may legitimately name a class this camera's model does
34993
+ * not emit.
34994
+ *
34995
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
34996
+ * - `{{detections}}` — total over the reported classes
34997
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
34998
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
34999
+ * one per class, `count_` + the class name
35000
+ *
35001
+ * With NO custom body template the summary is appended to the derived body, and
35002
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
35003
+ * reads. With a custom template the operator owns every word — nothing is
35004
+ * appended, so `{{detectionSummary}}` is how he asks for it.
35005
+ */
35006
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
35007
+ /**
34515
35008
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
34516
35009
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
34517
35010
  * here (see the ownership note above).
@@ -34531,13 +35024,42 @@ var TimelapseRuleInputSchema = object({
34531
35024
  cadenceSec: CadenceSecField.default(15),
34532
35025
  /** Output frames per second of the assembled mp4 (predecessor parity). */
34533
35026
  framerate: FramerateField.default(10),
35027
+ /**
35028
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
35029
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
35030
+ * field gets.
35031
+ */
35032
+ denseCadenceSec: DenseCadenceSecField.optional(),
35033
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
35034
+ minDwellSec: MinDwellSecField.optional(),
34534
35035
  /** `notification-output` targets the finished video/thumbnail is sent to. */
34535
35036
  targets: TargetsField,
34536
35037
  template: TimelapseTemplateSchema.optional(),
35038
+ /**
35039
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
35040
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
35041
+ *
35042
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
35043
+ * the notification's title/body, and clearing it (`template: null`) must not
35044
+ * silently clear the caption too.
35045
+ */
35046
+ previewText: PreviewTextField.optional(),
35047
+ /** Still or animation — see {@link PreviewModeField}. */
35048
+ previewMode: PreviewModeField.default("image"),
35049
+ /** Classes the notification counts — see {@link ReportClassesField}. */
35050
+ reportClasses: ReportClassesField.optional(),
34537
35051
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
34538
35052
  priority: PriorityField.default(3)
34539
35053
  });
34540
35054
  /**
35055
+ * The caption a rule that never set one gets.
35056
+ *
35057
+ * Rendered through the ordinary `{{var}}` pass at delivery, so a rule created
35058
+ * before this field existed still reads "Timelapse Videocamera ingresso" and
35059
+ * not the literal braces.
35060
+ */
35061
+ var DEFAULT_TIMELAPSE_PREVIEW_TEXT = "Timelapse {{camera}}";
35062
+ /**
34541
35063
  * Partial patch for an update — any subset of the INPUT fields, with NO
34542
35064
  * defaults (an absent key means "leave unchanged", never "reset to default").
34543
35065
  * Provenance and ownership are absent by construction: a patch can rename or
@@ -34560,8 +35082,13 @@ var TimelapseRulePatchSchema = object({
34560
35082
  schedule: NcScheduleSchema.optional(),
34561
35083
  cadenceSec: CadenceSecField.optional(),
34562
35084
  framerate: FramerateField.optional(),
35085
+ denseCadenceSec: DenseCadenceSecField.optional(),
35086
+ minDwellSec: MinDwellSecField.optional(),
34563
35087
  targets: TargetsField.optional(),
34564
35088
  template: TimelapseTemplateSchema.nullable().optional(),
35089
+ previewText: PreviewTextField.optional(),
35090
+ previewMode: PreviewModeField.optional(),
35091
+ reportClasses: ReportClassesField.optional(),
34565
35092
  priority: PriorityField.optional()
34566
35093
  });
34567
35094
  /** A persisted timelapse rule. */
@@ -34602,6 +35129,26 @@ var TimelapseRuleSchema = TimelapseRuleInputSchema.extend({
34602
35129
  updatedAt: number()
34603
35130
  });
34604
35131
  /**
35132
+ * Refuse a dense cadence that is not denser than the base.
35133
+ *
35134
+ * Called at UPSERT, on the MERGED rule — a patch that lowers `cadenceSec`
35135
+ * alone can invalidate a `denseCadenceSec` set months earlier, so checking the
35136
+ * patch in isolation would let the bad pair through.
35137
+ *
35138
+ * Refusing here and not at render time is the whole point: `ExportTimelapseSchema`
35139
+ * also rejects the pair, but it does so when the window has already closed and
35140
+ * the footage is being cut — the operator learns at 06:05 that last night was
35141
+ * never going to render, and a closed window does not come back. This turns
35142
+ * that into a failed edit he can see and correct.
35143
+ *
35144
+ * @throws Error naming both numbers, so the message is actionable in a toast.
35145
+ */
35146
+ function assertTimelapseCadences(pair) {
35147
+ const dense = pair.denseCadenceSec;
35148
+ if (dense === void 0) return;
35149
+ if (dense >= pair.cadenceSec) throw new Error(`denseCadenceSec (${dense}s) must be strictly smaller than cadenceSec (${pair.cadenceSec}s) — a dense cadence that is not denser renders a uniform timelapse`);
35150
+ }
35151
+ /**
34605
35152
  * The last successful generation for ONE camera of a rule, epoch-ms.
34606
35153
  *
34607
35154
  * The per-device map wins; a rule with no map falls back to the rule-wide
@@ -34788,6 +35335,18 @@ Object.defineProperty(exports, "DEFAULT_EVENT_COLOR", {
34788
35335
  return DEFAULT_EVENT_COLOR;
34789
35336
  }
34790
35337
  });
35338
+ Object.defineProperty(exports, "DEFAULT_TIMELAPSE_PREVIEW_TEXT", {
35339
+ enumerable: true,
35340
+ get: function() {
35341
+ return DEFAULT_TIMELAPSE_PREVIEW_TEXT;
35342
+ }
35343
+ });
35344
+ Object.defineProperty(exports, "DETECTION_PIPELINE_CAP_NAME", {
35345
+ enumerable: true,
35346
+ get: function() {
35347
+ return DETECTION_PIPELINE_CAP_NAME;
35348
+ }
35349
+ });
34791
35350
  Object.defineProperty(exports, "DeclaredDevices", {
34792
35351
  enumerable: true,
34793
35352
  get: function() {
@@ -34908,6 +35467,12 @@ Object.defineProperty(exports, "RetrainStatusSchema", {
34908
35467
  return RetrainStatusSchema;
34909
35468
  }
34910
35469
  });
35470
+ Object.defineProperty(exports, "TIMELAPSE_DENSE_FLOOR_SEC", {
35471
+ enumerable: true,
35472
+ get: function() {
35473
+ return TIMELAPSE_DENSE_FLOOR_SEC;
35474
+ }
35475
+ });
34911
35476
  Object.defineProperty(exports, "TimelapseRuleInputSchema", {
34912
35477
  enumerable: true,
34913
35478
  get: function() {
@@ -34968,6 +35533,12 @@ Object.defineProperty(exports, "array", {
34968
35533
  return array;
34969
35534
  }
34970
35535
  });
35536
+ Object.defineProperty(exports, "assertTimelapseCadences", {
35537
+ enumerable: true,
35538
+ get: function() {
35539
+ return assertTimelapseCadences;
35540
+ }
35541
+ });
34971
35542
  Object.defineProperty(exports, "audioMetricsCapability", {
34972
35543
  enumerable: true,
34973
35544
  get: function() {
@@ -35100,6 +35671,12 @@ Object.defineProperty(exports, "object", {
35100
35671
  return object;
35101
35672
  }
35102
35673
  });
35674
+ Object.defineProperty(exports, "partialRecord", {
35675
+ enumerable: true,
35676
+ get: function() {
35677
+ return partialRecord;
35678
+ }
35679
+ });
35103
35680
  Object.defineProperty(exports, "pipelineAnalyticsCapability", {
35104
35681
  enumerable: true,
35105
35682
  get: function() {