@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.
@@ -7576,6 +7576,13 @@ var CameraSwitchGroupSchema = object({
7576
7576
  fetchedAt: number()
7577
7577
  });
7578
7578
  /**
7579
+ * The wrapper capability each wrapper-backed switch controls. Named constants
7580
+ * because the same strings appear in `legacy-migrations.ts`, in
7581
+ * `isCapActiveForDevice` call sites and in the fake harness — a typo in any of
7582
+ * them is a switch that silently writes a binding nobody reads.
7583
+ */
7584
+ var DETECTION_PIPELINE_CAP_NAME = "detection-pipeline";
7585
+ /**
7579
7586
  * Ops-log — the durable, append-only operations audit shared by the
7580
7587
  * recordings and events management surfaces.
7581
7588
  *
@@ -7800,7 +7807,15 @@ function deriveRecordingMode(config) {
7800
7807
  * Each completed/failed run also lands one durable ops-log row on its owning
7801
7808
  * addon surface.
7802
7809
  */
7810
+ /**
7811
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7812
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7813
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7814
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7815
+ * runs at all.
7816
+ */
7803
7817
  var RelocateJobStateSchema = _enum([
7818
+ "queued",
7804
7819
  "running",
7805
7820
  "done",
7806
7821
  "failed",
@@ -7835,6 +7850,15 @@ var RelocateFootageInputSchema = object({
7835
7850
  /** Limits relocation to the logical profile class. Omit only for the
7836
7851
  * pre-orchestration compatibility path. */
7837
7852
  footageClass: RelocateFootageClassSchema.optional(),
7853
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7854
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7855
+ * unit is a (camera, profile) pile, not a disk. */
7856
+ deviceId: number().int().optional(),
7857
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7858
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7859
+ * placement plan assigns those two independently, so a rebalance that could
7860
+ * only say "recordings" would move footage the plan never asked to move. */
7861
+ profiles: array(string()).optional(),
7838
7862
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7839
7863
  * never allowed to starve live writers. */
7840
7864
  throttleMbps: number().min(1).max(1e3).optional()
@@ -14393,6 +14417,13 @@ var MaskGridDimsSchema = object({
14393
14417
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14394
14418
  * this one field keeps the schema additive — a rule still declares exactly
14395
14419
  * one trigger.
14420
+ *
14421
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14422
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14423
+ * mirror.ts` fails the build on a member the app cannot render) and every
14424
+ * member costs a release train. A sustained-sound rule is therefore an
14425
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14426
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14396
14427
  */
14397
14428
  var NcDeliverySchema = _enum([
14398
14429
  "immediate",
@@ -14407,15 +14438,32 @@ var NcDeliverySchema = _enum([
14407
14438
  * depend on a provider's raw event name or payload shape.
14408
14439
  */
14409
14440
  var NcSystemEventKindSchema = _enum([
14410
- "camera-online",
14411
- "camera-offline",
14441
+ "device-online",
14442
+ "device-offline",
14443
+ "device-disabled",
14444
+ "device-enabled",
14412
14445
  "stream-online",
14413
14446
  "stream-offline",
14414
14447
  "node-online",
14415
14448
  "node-offline",
14416
14449
  "addon-update-available",
14417
- "server-update-available"
14450
+ "server-update-available",
14451
+ "alarm-triggered",
14452
+ "alarm-armed",
14453
+ "alarm-disarmed",
14454
+ "camera-online",
14455
+ "camera-offline",
14456
+ "camera-disabled",
14457
+ "camera-enabled"
14418
14458
  ]);
14459
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14460
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14461
+ "camera-online",
14462
+ "camera-offline",
14463
+ "camera-disabled",
14464
+ "camera-enabled"
14465
+ ]);
14466
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14419
14467
  /**
14420
14468
  * One coherent system-event condition. `kinds` is the required opt-in safety
14421
14469
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14424,6 +14472,18 @@ var NcSystemEventKindSchema = _enum([
14424
14472
  var NcSystemEventConditionSchema = object({
14425
14473
  kinds: array(NcSystemEventKindSchema).min(1),
14426
14474
  deviceIds: array(number().int()).min(1).optional(),
14475
+ /**
14476
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14477
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14478
+ * is what a liveness rule means when nobody said otherwise.
14479
+ *
14480
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14481
+ * one reason: the intake cannot know which devices this household cares
14482
+ * about, and a producer-side filter is one no operator can change. Fails
14483
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14484
+ * does not carry) matches no `deviceTypes` list.
14485
+ */
14486
+ deviceTypes: array(string().min(1)).min(1).optional(),
14427
14487
  nodeIds: array(string().min(1)).min(1).optional(),
14428
14488
  packageNames: array(string().min(1)).min(1).optional()
14429
14489
  });
@@ -14474,6 +14534,47 @@ var NcOccupancyConditionSchema = object({
14474
14534
  sustainSeconds: number().int().min(0).max(3600).default(15)
14475
14535
  });
14476
14536
  /**
14537
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14538
+ *
14539
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14540
+ * reference notifier uses, so an operator moving between them re-uses what
14541
+ * they already know): a rule matches when, over a sampling window of
14542
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14543
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14544
+ *
14545
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14546
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14547
+ * - `labels` — the classifier put at least one of these labels on it.
14548
+ *
14549
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14550
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14551
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14552
+ * is given** — a window in which every sample is trivially a hit would fire on
14553
+ * silence, so the engine refuses such a condition rather than notifying on
14554
+ * nothing (the schema cannot express "at least one of" without becoming a
14555
+ * ZodEffects the cap path would have to special-case).
14556
+ *
14557
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14558
+ * must be FULL before it can match — a window that has been open for two
14559
+ * seconds of its ten is 100% of nothing, and firing on it would make
14560
+ * `samplingSeconds` decorative.
14561
+ *
14562
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14563
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14564
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14565
+ * an operator who typed `dog` mean the same thing.
14566
+ */
14567
+ var NcAudioConditionSchema = object({
14568
+ /** Audio macro labels; absent = any sound (level-only rule). */
14569
+ labels: array(string().min(1)).min(1).optional(),
14570
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14571
+ dbThreshold: number().min(-96).max(0).optional(),
14572
+ /** Percentage of the window's samples that must be hits (1–100). */
14573
+ hitPercent: number().int().min(1).max(100).default(60),
14574
+ /** Length of the sampling window in seconds. */
14575
+ samplingSeconds: number().int().min(1).max(300).default(10)
14576
+ });
14577
+ /**
14477
14578
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14478
14579
  *
14479
14580
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14746,7 +14847,33 @@ var NcConditionsSchema = object({
14746
14847
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14747
14848
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14748
14849
  */
14749
- occupancy: NcOccupancyConditionSchema.optional()
14850
+ occupancy: NcOccupancyConditionSchema.optional(),
14851
+ /**
14852
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14853
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14854
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14855
+ * a window that is not full yet, neither filter given). See
14856
+ * {@link NcAudioCondition}.
14857
+ *
14858
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14859
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14860
+ * a detection, a track or a device event (the same fail-closed pairing
14861
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14862
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14863
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14864
+ * classified sample) stays exactly as it was for rules that already use it.
14865
+ *
14866
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14867
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14868
+ * (`camstack/src/data/notification-center.ts`, guarded by
14869
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14870
+ * condition fields it does not know when a rule is saved from the phone.
14871
+ * Publishing an editor for a condition the app cannot round-trip is how an
14872
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14873
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14874
+ * does an audio rule become authorable.
14875
+ */
14876
+ audio: NcAudioConditionSchema.optional()
14750
14877
  });
14751
14878
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14752
14879
  var NcRuleTargetSchema = object({
@@ -14860,6 +14987,73 @@ var NcThrottleSchema = object({
14860
14987
  */
14861
14988
  granularity: NcThrottleGranularitySchema.optional()
14862
14989
  });
14990
+ /**
14991
+ * How long the confirm gate may hold ONE notification, and how big the picture
14992
+ * it judges may be.
14993
+ *
14994
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14995
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14996
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14997
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14998
+ * tokens for pixels the model pools away.
14999
+ */
15000
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
15001
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
15002
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
15003
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
15004
+ var NcConfirmExpectSchema = object({
15005
+ op: _enum([
15006
+ ">=",
15007
+ ">",
15008
+ "<=",
15009
+ "<",
15010
+ "=="
15011
+ ]),
15012
+ count: number().int().min(0).max(1e3)
15013
+ });
15014
+ /**
15015
+ * AI CONFIRM — a vision model looks at the picture this notification is about
15016
+ * to ship and says whether it agrees with the rule.
15017
+ *
15018
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
15019
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
15020
+ * on the operator's phone is not a verdict about this notification.
15021
+ *
15022
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
15023
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
15024
+ * the default and every fail-open is COUNTED, because a gate that always fails
15025
+ * open looks in the log exactly like a gate that works.
15026
+ *
15027
+ * Every field is `.optional()` rather than relied on as a Zod default at the
15028
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
15029
+ * production failures in one day), so the gate reads absent as the constant
15030
+ * above rather than trusting a parse it may never have seen.
15031
+ */
15032
+ var NcConfirmSchema = object({
15033
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
15034
+ * same thing, and both mean "deliver exactly as before". */
15035
+ enabled: boolean().default(false),
15036
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
15037
+ profileId: string().optional(),
15038
+ /**
15039
+ * The operator's question, in his own words. Absent = a question derived
15040
+ * from the rule (its class and its expectation).
15041
+ *
15042
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
15043
+ * banners, signage and plates as instructions if you let them reach the
15044
+ * prompt — proven live — so the authoritative contract stays in the system
15045
+ * turn and only rule-authored words land here.
15046
+ */
15047
+ prompt: string().max(1e3).optional(),
15048
+ /** Fire only when the model's count satisfies this. Absent = the model's
15049
+ * own boolean verdict decides. */
15050
+ expect: NcConfirmExpectSchema.optional(),
15051
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
15052
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
15053
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
15054
+ /** Longest edge the judged image is downscaled to before it is sent. */
15055
+ maxImagePx: number().int().min(64).max(2048).default(448)
15056
+ });
14863
15057
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14864
15058
  var NcRuleInputSchema = object({
14865
15059
  name: string().min(1).max(200),
@@ -14920,7 +15114,13 @@ var NcRuleInputSchema = object({
14920
15114
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14921
15115
  * shape as every other actuation.
14922
15116
  */
14923
- actions: NcRuleActionsSchema.optional()
15117
+ actions: NcRuleActionsSchema.optional(),
15118
+ /**
15119
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
15120
+ * a rule that predates the gate must keep delivering byte-for-byte as it
15121
+ * did, and absent is the only way to say that without a migration.
15122
+ */
15123
+ confirm: NcConfirmSchema.optional()
14924
15124
  });
14925
15125
  /**
14926
15126
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14931,7 +15131,37 @@ var NcRuleInputSchema = object({
14931
15131
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14932
15132
  * `updateRule` patch.
14933
15133
  */
14934
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
15134
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
15135
+ disabledTargetIds: array(string()).optional(),
15136
+ /**
15137
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
15138
+ *
15139
+ * It makes the key optional to SUPPLY; the parse still materialises the
15140
+ * default when the key is absent. And `NcRuleStore.update` merges with
15141
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
15142
+ * one — which made every partial edit destructive:
15143
+ *
15144
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
15145
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
15146
+ * setEnabled(ruleId, false) → conditions reset to `{}`
15147
+ *
15148
+ * A rule scoped to one camera and one zone silently became a rule that
15149
+ * matches EVERY event on EVERY camera, and lost its `media` policy
15150
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
15151
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
15152
+ * within a minute of a two-field patch.
15153
+ *
15154
+ * So every defaulted field is re-declared here WITHOUT its default. The
15155
+ * inner defaults still apply when the caller DOES send the key — `{}` for
15156
+ * conditions remains a real instruction ("clear them") — and only the
15157
+ * absent key is now genuinely absent.
15158
+ */
15159
+ enabled: boolean().optional(),
15160
+ conditions: NcConditionsSchema.optional(),
15161
+ media: NcMediaPolicySchema.optional(),
15162
+ throttle: NcThrottleSchema.optional(),
15163
+ priority: number().int().min(1).max(5).optional()
15164
+ });
14935
15165
  /** A persisted rule. */
14936
15166
  var NcRuleSchema = NcRuleInputSchema.extend({
14937
15167
  id: string(),
@@ -15044,12 +15274,20 @@ var NC_CONDITION_CATALOG = [
15044
15274
  valueType: "systemEvent",
15045
15275
  options: [
15046
15276
  {
15047
- value: "camera-online",
15048
- label: "Camera online"
15277
+ value: "device-online",
15278
+ label: "Device online"
15049
15279
  },
15050
15280
  {
15051
- value: "camera-offline",
15052
- label: "Camera offline"
15281
+ value: "device-offline",
15282
+ label: "Device offline"
15283
+ },
15284
+ {
15285
+ value: "device-disabled",
15286
+ label: "Device switched off"
15287
+ },
15288
+ {
15289
+ value: "device-enabled",
15290
+ label: "Device switched on"
15053
15291
  },
15054
15292
  {
15055
15293
  value: "stream-online",
@@ -15074,12 +15312,24 @@ var NC_CONDITION_CATALOG = [
15074
15312
  {
15075
15313
  value: "server-update-available",
15076
15314
  label: "Server update available"
15315
+ },
15316
+ {
15317
+ value: "alarm-triggered",
15318
+ label: "Alarm triggered"
15319
+ },
15320
+ {
15321
+ value: "alarm-armed",
15322
+ label: "Alarm armed"
15323
+ },
15324
+ {
15325
+ value: "alarm-disarmed",
15326
+ label: "Alarm disarmed"
15077
15327
  }
15078
15328
  ],
15079
15329
  operator: "in",
15080
15330
  appliesTo: ["system-event"],
15081
15331
  phase: "P1",
15082
- description: "Infrastructure and update events. Optionally narrow camera/stream events by device, node events by node id, and addon updates by package name."
15332
+ 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."
15083
15333
  },
15084
15334
  {
15085
15335
  id: "devices",
@@ -15603,6 +15853,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15603
15853
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15604
15854
  * copy would lie the first time a rule is disabled.
15605
15855
  */
15856
+ /**
15857
+ * Why a device a mode NAMES is nonetheless not armed by it.
15858
+ *
15859
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15860
+ * per-camera notification switch the Notification Center already owns,
15861
+ * `detection-off` is the device's own detection binding being inactive, and
15862
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15863
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15864
+ * with the switches the operator actually used.
15865
+ */
15866
+ var NcAlarmSkipReasonSchema = _enum([
15867
+ "muted",
15868
+ "detection-off",
15869
+ "offline"
15870
+ ]);
15871
+ var NcAlarmSkippedDeviceSchema = object({
15872
+ deviceId: number().int(),
15873
+ reason: NcAlarmSkipReasonSchema
15874
+ });
15606
15875
  var NcAlarmModeCoverageSchema = object({
15607
15876
  mode: AlarmArmModeSchema,
15608
15877
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15610,7 +15879,18 @@ var NcAlarmModeCoverageSchema = object({
15610
15879
  /** At least one covering rule has no device scope, so the mode covers all. */
15611
15880
  allDevices: boolean(),
15612
15881
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15613
- deviceIds: array(number().int())
15882
+ deviceIds: array(number().int()),
15883
+ /**
15884
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15885
+ * excludes it.
15886
+ *
15887
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15888
+ * twelve makes it false in exactly the way nobody notices until an incident.
15889
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15890
+ * still parses as "nothing known to be skipped" rather than failing the whole
15891
+ * alarm tab.
15892
+ */
15893
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15614
15894
  });
15615
15895
  var NcAlarmConfigSchema = object({
15616
15896
  /**
@@ -25792,7 +26072,19 @@ var RecordingManifestSchema = object({
25792
26072
  * profiles/subtrees/locations on this node). */
25793
26073
  var RecordingDeviceUsageSchema = object({
25794
26074
  deviceId: number(),
25795
- usedBytes: number()
26075
+ usedBytes: number(),
26076
+ /**
26077
+ * Start of this camera's OLDEST indexed segment, across every profile and
26078
+ * location — the "Oldest footage" column in Recordings → Storage, and the
26079
+ * only honest answer to "is retention actually holding?" per camera.
26080
+ *
26081
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
26082
+ * predates this field omits it entirely, and a hub whose types carry the
26083
+ * field must keep validating that older provider's payload: the framework
26084
+ * (types) and the addon ship on different trains, and the addon is usually
26085
+ * the later of the two.
26086
+ */
26087
+ oldestMs: number().nullable().optional()
25796
26088
  });
25797
26089
  /** Recording storage usage + capacity for one storage location. */
25798
26090
  var RecordingLocationUsageSchema = object({
@@ -25820,6 +26112,57 @@ var RecordingStorageUsageSchema = object({
25820
26112
  locations: array(RecordingLocationUsageSchema)
25821
26113
  });
25822
26114
  /**
26115
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
26116
+ *
26117
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
26118
+ * is the operator asking for the EXISTING archive to be brought into line with
26119
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
26120
+ * location, run FIFO behind the single-flight mover.
26121
+ *
26122
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
26123
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
26124
+ * (empty on the plan).
26125
+ */
26126
+ var RecordingRebalanceMoveSchema = object({
26127
+ deviceId: number(),
26128
+ profile: string(),
26129
+ fromLocationId: string(),
26130
+ toLocationId: string(),
26131
+ bytes: number(),
26132
+ files: number().int()
26133
+ });
26134
+ /** Why a pile that is out of place is staying there. Every refusal is
26135
+ * reported: a rebalance that silently drops a camera reads exactly like one
26136
+ * that had nothing to do. */
26137
+ var RecordingRebalanceSkipReasonSchema = _enum([
26138
+ "unassigned",
26139
+ "target-not-writable",
26140
+ "below-threshold",
26141
+ "no-headroom"
26142
+ ]);
26143
+ var RecordingRebalanceSkipSchema = object({
26144
+ deviceId: number(),
26145
+ profile: string(),
26146
+ fromLocationId: string(),
26147
+ /** The location the plan wants; null when the camera has no assignment. */
26148
+ toLocationId: string().nullable(),
26149
+ bytes: number(),
26150
+ reason: RecordingRebalanceSkipReasonSchema
26151
+ });
26152
+ var RecordingRebalancePlanSchema = object({
26153
+ moves: array(RecordingRebalanceMoveSchema),
26154
+ skipped: array(RecordingRebalanceSkipSchema),
26155
+ bytesToMove: number(),
26156
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
26157
+ jobIds: array(string())
26158
+ });
26159
+ var RecordingRebalanceInputSchema = object({
26160
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
26161
+ throttleMbps: number().min(1).max(1e3).optional(),
26162
+ /** Ignore piles smaller than this (default 1 GB). */
26163
+ minMoveGb: number().min(0).optional()
26164
+ });
26165
+ /**
25823
26166
  * Result of locating footage at a wall-clock instant for one device/profile.
25824
26167
  * `segment` carries the covering segment's window; `gap` reports the forward
25825
26168
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -25982,6 +26325,21 @@ method(object({
25982
26325
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25983
26326
  kind: "mutation",
25984
26327
  auth: "admin"
26328
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
26329
+ kind: "mutation",
26330
+ auth: "admin"
26331
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
26332
+ kind: "query",
26333
+ auth: "admin"
26334
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26335
+ kind: "mutation",
26336
+ auth: "admin"
26337
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26338
+ kind: "query",
26339
+ auth: "admin"
26340
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26341
+ kind: "mutation",
26342
+ auth: "admin"
25985
26343
  });
25986
26344
  /**
25987
26345
  * `recording-export` cap — render a footage time range into a single downloadable
@@ -32881,6 +33239,12 @@ Object.freeze({
32881
33239
  addonId: null,
32882
33240
  access: "create"
32883
33241
  },
33242
+ "recording.cancelRelocateJob": {
33243
+ capName: "recording",
33244
+ capScope: "system",
33245
+ addonId: null,
33246
+ access: "create"
33247
+ },
32884
33248
  "recording.cancelStorageMigrationMove": {
32885
33249
  capName: "recording",
32886
33250
  capScope: "system",
@@ -32935,6 +33299,12 @@ Object.freeze({
32935
33299
  addonId: null,
32936
33300
  access: "view"
32937
33301
  },
33302
+ "recording.listRelocateJobs": {
33303
+ capName: "recording",
33304
+ capScope: "system",
33305
+ addonId: null,
33306
+ access: "view"
33307
+ },
32938
33308
  "recording.locateSegment": {
32939
33309
  capName: "recording",
32940
33310
  capScope: "system",
@@ -32947,6 +33317,12 @@ Object.freeze({
32947
33317
  addonId: null,
32948
33318
  access: "create"
32949
33319
  },
33320
+ "recording.planStorageRebalance": {
33321
+ capName: "recording",
33322
+ capScope: "system",
33323
+ addonId: null,
33324
+ access: "view"
33325
+ },
32950
33326
  "recording.pruneFootage": {
32951
33327
  capName: "recording",
32952
33328
  capScope: "system",
@@ -32971,6 +33347,12 @@ Object.freeze({
32971
33347
  addonId: null,
32972
33348
  access: "create"
32973
33349
  },
33350
+ "recording.relocateFootage": {
33351
+ capName: "recording",
33352
+ capScope: "system",
33353
+ addonId: null,
33354
+ access: "create"
33355
+ },
32974
33356
  "recording.renderClip": {
32975
33357
  capName: "recording",
32976
33358
  capScope: "system",
@@ -33007,6 +33389,12 @@ Object.freeze({
33007
33389
  addonId: null,
33008
33390
  access: "create"
33009
33391
  },
33392
+ "recording.startStorageRebalance": {
33393
+ capName: "recording",
33394
+ capScope: "system",
33395
+ addonId: null,
33396
+ access: "create"
33397
+ },
33010
33398
  "recordingExport.cancelExport": {
33011
33399
  capName: "recording-export",
33012
33400
  capScope: "system",
@@ -34481,6 +34869,111 @@ var FramerateField = number().int().min(1).max(60);
34481
34869
  var TargetsField = array(NcRuleTargetSchema).min(1);
34482
34870
  var PriorityField = number().int().min(1).max(5);
34483
34871
  /**
34872
+ * Floor on any dense cadence, seconds — the recording's own frame interval.
34873
+ *
34874
+ * Declared here because it bounds BOTH the rule field and the renderer's
34875
+ * derivation, and two copies of a floor are two floors that can drift.
34876
+ */
34877
+ var TIMELAPSE_DENSE_FLOOR_SEC = .1;
34878
+ /**
34879
+ * Explicit override of the DENSE sampling cadence, seconds.
34880
+ *
34881
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
34882
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
34883
+ * made that same base 3 s and rendered a person pass as two frames.)
34884
+ *
34885
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
34886
+ * `denseCadenceSec` and played at `framerate` occupies
34887
+ *
34888
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
34889
+ *
34890
+ * 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.
34891
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
34892
+ * and therefore the length of a quiet night, does not move.
34893
+ *
34894
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
34895
+ * the recording has them returns the same frames, requested twice. Must be
34896
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
34897
+ * a uniform video the operator believes is two-rate — and upsert refuses it
34898
+ * rather than letting the export cap reject the render hours after the window.
34899
+ */
34900
+ var DenseCadenceSecField = number().min(TIMELAPSE_DENSE_FLOOR_SEC).max(3600);
34901
+ /**
34902
+ * Minimum seconds of OUTPUT video each detection range must occupy.
34903
+ *
34904
+ * The operator-facing form of the arithmetic above: instead of solving for a
34905
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
34906
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
34907
+ * that range every ~583 ms.
34908
+ *
34909
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
34910
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
34911
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
34912
+ * ranges are sampled denser than they need. Per-range cadences require a cap
34913
+ * schema change and are the tracked follow-up.
34914
+ *
34915
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
34916
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
34917
+ * by real footage, never met by duplicating frames into motion that never
34918
+ * happened.
34919
+ */
34920
+ var MinDwellSecField = number().min(0).max(60);
34921
+ /**
34922
+ * Caption burned into the notification's preview frame.
34923
+ *
34924
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
34925
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
34926
+ * templating dialect for one field would be a second thing to explain.
34927
+ *
34928
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
34929
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
34930
+ * the reason this is not `.min(1)`.
34931
+ */
34932
+ var PreviewTextField = string().max(200);
34933
+ /**
34934
+ * Whether the notification's preview is a STILL or a short animation.
34935
+ *
34936
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
34937
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
34938
+ * night reads better as three seconds of motion than as one frame of it. Both
34939
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
34940
+ * simply applies it to a dozen frames sampled across the render and assembles
34941
+ * them.
34942
+ *
34943
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
34944
+ * seeks and a palette pass, and no rule that never asked for one should start
34945
+ * paying that on the deploy that shipped it.
34946
+ *
34947
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
34948
+ */
34949
+ var PreviewModeField = _enum(["image", "gif"]);
34950
+ /**
34951
+ * Which detection classes the notification reports counts for.
34952
+ *
34953
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
34954
+ * plan — no second query — aggregated per class. Absent or empty means "every
34955
+ * class the window actually contained", which is what an operator who never
34956
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
34957
+ * counts cars all night).
34958
+ *
34959
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
34960
+ * …). An unknown name simply never matches and reports nothing — it is not an
34961
+ * error, because a rule may legitimately name a class this camera's model does
34962
+ * not emit.
34963
+ *
34964
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
34965
+ * - `{{detections}}` — total over the reported classes
34966
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
34967
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
34968
+ * one per class, `count_` + the class name
34969
+ *
34970
+ * With NO custom body template the summary is appended to the derived body, and
34971
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
34972
+ * reads. With a custom template the operator owns every word — nothing is
34973
+ * appended, so `{{detectionSummary}}` is how he asks for it.
34974
+ */
34975
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
34976
+ /**
34484
34977
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
34485
34978
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
34486
34979
  * here (see the ownership note above).
@@ -34500,13 +34993,42 @@ var TimelapseRuleInputSchema = object({
34500
34993
  cadenceSec: CadenceSecField.default(15),
34501
34994
  /** Output frames per second of the assembled mp4 (predecessor parity). */
34502
34995
  framerate: FramerateField.default(10),
34996
+ /**
34997
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
34998
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
34999
+ * field gets.
35000
+ */
35001
+ denseCadenceSec: DenseCadenceSecField.optional(),
35002
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
35003
+ minDwellSec: MinDwellSecField.optional(),
34503
35004
  /** `notification-output` targets the finished video/thumbnail is sent to. */
34504
35005
  targets: TargetsField,
34505
35006
  template: TimelapseTemplateSchema.optional(),
35007
+ /**
35008
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
35009
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
35010
+ *
35011
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
35012
+ * the notification's title/body, and clearing it (`template: null`) must not
35013
+ * silently clear the caption too.
35014
+ */
35015
+ previewText: PreviewTextField.optional(),
35016
+ /** Still or animation — see {@link PreviewModeField}. */
35017
+ previewMode: PreviewModeField.default("image"),
35018
+ /** Classes the notification counts — see {@link ReportClassesField}. */
35019
+ reportClasses: ReportClassesField.optional(),
34506
35020
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
34507
35021
  priority: PriorityField.default(3)
34508
35022
  });
34509
35023
  /**
35024
+ * The caption a rule that never set one gets.
35025
+ *
35026
+ * Rendered through the ordinary `{{var}}` pass at delivery, so a rule created
35027
+ * before this field existed still reads "Timelapse Videocamera ingresso" and
35028
+ * not the literal braces.
35029
+ */
35030
+ var DEFAULT_TIMELAPSE_PREVIEW_TEXT = "Timelapse {{camera}}";
35031
+ /**
34510
35032
  * Partial patch for an update — any subset of the INPUT fields, with NO
34511
35033
  * defaults (an absent key means "leave unchanged", never "reset to default").
34512
35034
  * Provenance and ownership are absent by construction: a patch can rename or
@@ -34529,8 +35051,13 @@ var TimelapseRulePatchSchema = object({
34529
35051
  schedule: NcScheduleSchema.optional(),
34530
35052
  cadenceSec: CadenceSecField.optional(),
34531
35053
  framerate: FramerateField.optional(),
35054
+ denseCadenceSec: DenseCadenceSecField.optional(),
35055
+ minDwellSec: MinDwellSecField.optional(),
34532
35056
  targets: TargetsField.optional(),
34533
35057
  template: TimelapseTemplateSchema.nullable().optional(),
35058
+ previewText: PreviewTextField.optional(),
35059
+ previewMode: PreviewModeField.optional(),
35060
+ reportClasses: ReportClassesField.optional(),
34534
35061
  priority: PriorityField.optional()
34535
35062
  });
34536
35063
  /** A persisted timelapse rule. */
@@ -34571,6 +35098,26 @@ var TimelapseRuleSchema = TimelapseRuleInputSchema.extend({
34571
35098
  updatedAt: number()
34572
35099
  });
34573
35100
  /**
35101
+ * Refuse a dense cadence that is not denser than the base.
35102
+ *
35103
+ * Called at UPSERT, on the MERGED rule — a patch that lowers `cadenceSec`
35104
+ * alone can invalidate a `denseCadenceSec` set months earlier, so checking the
35105
+ * patch in isolation would let the bad pair through.
35106
+ *
35107
+ * Refusing here and not at render time is the whole point: `ExportTimelapseSchema`
35108
+ * also rejects the pair, but it does so when the window has already closed and
35109
+ * the footage is being cut — the operator learns at 06:05 that last night was
35110
+ * never going to render, and a closed window does not come back. This turns
35111
+ * that into a failed edit he can see and correct.
35112
+ *
35113
+ * @throws Error naming both numbers, so the message is actionable in a toast.
35114
+ */
35115
+ function assertTimelapseCadences(pair) {
35116
+ const dense = pair.denseCadenceSec;
35117
+ if (dense === void 0) return;
35118
+ 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`);
35119
+ }
35120
+ /**
34574
35121
  * The last successful generation for ONE camera of a rule, epoch-ms.
34575
35122
  *
34576
35123
  * The per-device map wins; a rule with no map falls back to the rule-wide
@@ -34739,4 +35286,4 @@ function vectorDimFromBase64(encoded) {
34739
35286
  return Math.floor(Buffer.from(encoded, "base64").byteLength / 4);
34740
35287
  }
34741
35288
  //#endregion
34742
- export { isDeviceScopedCap as $, customAction as A, pipelineAnalyticsCapability as B, TimelapseRuleSchema as C, audioMetricsCapability as D, alarmPanelCapability as E, faceGalleryCapability as F, vectorDimFromBase64 as G, readDeviceStateFrom as H, hfModelUrl as I, errMsg as J, videoclipsCapability as K, isScheduleActive as L, deriveRecordingMode as M, embeddingEncoderCapability as N, buildEventKindDescriptor as O, encodeVectorBase64 as P, hydrateSchema as Q, kebabToCamel as R, TimelapseRulePatchSchema as S, addonWidgetsSourceCapability as T, readTimelapseGeneratedAt as U, plateGalleryCapability as V, subKindsOf as W, DeviceType as X, BaseAddon as Y, createEvent as Z, NcTaxonomySchema as _, EVENT_PAD_MS as a, literal as at, RetrainStatusSchema as b, NC_CONDITION_CATALOG as c, record as ct, NcRuleInputSchema as d, EventCategory as dt, nodePin as et, NcRulePatchSchema as f, NcSnoozeSuppressedSchema as g, NcSnoozeSchema as h, EVENT_KIND_BY_CAP as i, boolean as it, defineCustomActions as j, cosineSimilarity as k, NC_TAXONOMY as l, string as lt, NcSnoozeInputSchema as m, DEFAULT_EVENT_COLOR as n, _enum as nt, LabelAttributionSchema as o, number as ot, NcRuleSchema as p, zoneAnalyticsCapability as q, DeclaredDevices as r, array as rt, MACRO_LABELS as s, object as st, BaseDevice as t, sleep as tt, NcConditionDescriptorSchema as u, unknown as ut, OpsLogEntrySchema as v, TrackSourceSchema as w, TimelapseRuleInputSchema as x, RECORDING_EXPORT_MAX_READ_BYTES as y, notificationRulesCapability as z };
35289
+ export { BaseAddon as $, assertTimelapseCadences as A, hfModelUrl as B, TIMELAPSE_DENSE_FLOOR_SEC as C, TrackSourceSchema as D, TimelapseRuleSchema as E, defineCustomActions as F, plateGalleryCapability as G, kebabToCamel as H, deriveRecordingMode as I, subKindsOf as J, readDeviceStateFrom as K, embeddingEncoderCapability as L, buildEventKindDescriptor as M, cosineSimilarity as N, addonWidgetsSourceCapability as O, customAction as P, errMsg as Q, encodeVectorBase64 as R, RetrainStatusSchema as S, TimelapseRulePatchSchema as T, notificationRulesCapability as U, isScheduleActive as V, pipelineAnalyticsCapability as W, videoclipsCapability as X, vectorDimFromBase64 as Y, zoneAnalyticsCapability as Z, NcSnoozeSchema as _, DeclaredDevices as a, sleep as at, OpsLogEntrySchema as b, LabelAttributionSchema as c, boolean as ct, NC_TAXONOMY as d, object as dt, DeviceType as et, NcConditionDescriptorSchema as f, partialRecord as ft, NcSnoozeInputSchema as g, EventCategory as gt, NcRuleSchema as h, unknown as ht, DETECTION_PIPELINE_CAP_NAME as i, nodePin as it, audioMetricsCapability as j, alarmPanelCapability as k, MACRO_LABELS as l, literal as lt, NcRulePatchSchema as m, string as mt, DEFAULT_EVENT_COLOR as n, hydrateSchema as nt, EVENT_KIND_BY_CAP as o, _enum as ot, NcRuleInputSchema as p, record as pt, readTimelapseGeneratedAt as q, DEFAULT_TIMELAPSE_PREVIEW_TEXT as r, isDeviceScopedCap as rt, EVENT_PAD_MS as s, array as st, BaseDevice as t, createEvent as tt, NC_CONDITION_CATALOG as u, number as ut, NcSnoozeSuppressedSchema as v, TimelapseRuleInputSchema as w, RECORDING_EXPORT_MAX_READ_BYTES as x, NcTaxonomySchema as y, faceGalleryCapability as z };