@camstack/types 1.2.63 → 1.2.65

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.
package/dist/index.js CHANGED
@@ -584,6 +584,19 @@ function resolveRunnerId(decl, addonId) {
584
584
  function resolveAddonPlacement(decl) {
585
585
  return resolveAddonExecution(decl).placement;
586
586
  }
587
+ /**
588
+ * True when a `@camstack/system` builtin opted out of the in-process rule and
589
+ * must be planned as a forked runner (`execution.isolate`).
590
+ *
591
+ * ONE predicate, because the hub asks this question in three places that must
592
+ * agree: the runner plan (`buildAddonGroupPlan`), the "does this boot
593
+ * in-process" filter, and `isForkedAddonEntry` (which decides route mounts,
594
+ * data-plane mounts, restart and uninstall). They diverged once before for
595
+ * `auth-oidc` and the addon's routes were mounted against an async UDS proxy.
596
+ */
597
+ function isIsolatedBuiltin(decl) {
598
+ return decl.execution?.isolate === true;
599
+ }
587
600
  //#endregion
588
601
  //#region src/interfaces/adoption-job.ts
589
602
  /**
@@ -1675,7 +1688,15 @@ function deriveRecordingMode(config) {
1675
1688
  * Each completed/failed run also lands one durable ops-log row on its owning
1676
1689
  * addon surface.
1677
1690
  */
1691
+ /**
1692
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
1693
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
1694
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
1695
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
1696
+ * runs at all.
1697
+ */
1678
1698
  var RelocateJobStateSchema = zod.z.enum([
1699
+ "queued",
1679
1700
  "running",
1680
1701
  "done",
1681
1702
  "failed",
@@ -1710,6 +1731,15 @@ var RelocateFootageInputSchema = zod.z.object({
1710
1731
  /** Limits relocation to the logical profile class. Omit only for the
1711
1732
  * pre-orchestration compatibility path. */
1712
1733
  footageClass: RelocateFootageClassSchema.optional(),
1734
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
1735
+ * is what a whole-disk drain means. The rebalance path always sets it: its
1736
+ * unit is a (camera, profile) pile, not a disk. */
1737
+ deviceId: zod.z.number().int().optional(),
1738
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
1739
+ * Finer than `footageClass`, which cannot separate high from mid — and the
1740
+ * placement plan assigns those two independently, so a rebalance that could
1741
+ * only say "recordings" would move footage the plan never asked to move. */
1742
+ profiles: zod.z.array(zod.z.string()).optional(),
1713
1743
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
1714
1744
  * never allowed to starve live writers. */
1715
1745
  throttleMbps: zod.z.number().min(1).max(1e3).optional()
@@ -11810,6 +11840,13 @@ var MaskGridDimsSchema = zod.z.object({
11810
11840
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
11811
11841
  * this one field keeps the schema additive — a rule still declares exactly
11812
11842
  * one trigger.
11843
+ *
11844
+ * AUDIO rules add no member here, for the reason occupancy added none: the
11845
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
11846
+ * mirror.ts` fails the build on a member the app cannot render) and every
11847
+ * member costs a release train. A sustained-sound rule is therefore an
11848
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
11849
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
11813
11850
  */
11814
11851
  var NcDeliverySchema = zod.z.enum([
11815
11852
  "immediate",
@@ -11824,16 +11861,51 @@ var NcDeliverySchema = zod.z.enum([
11824
11861
  * depend on a provider's raw event name or payload shape.
11825
11862
  */
11826
11863
  var NcSystemEventKindSchema = zod.z.enum([
11827
- "camera-online",
11828
- "camera-offline",
11864
+ "device-online",
11865
+ "device-offline",
11866
+ "device-disabled",
11867
+ "device-enabled",
11829
11868
  "stream-online",
11830
11869
  "stream-offline",
11831
11870
  "node-online",
11832
11871
  "node-offline",
11833
11872
  "addon-update-available",
11834
- "server-update-available"
11873
+ "server-update-available",
11874
+ "alarm-triggered",
11875
+ "alarm-armed",
11876
+ "alarm-disarmed",
11877
+ "camera-online",
11878
+ "camera-offline",
11879
+ "camera-disabled",
11880
+ "camera-enabled"
11881
+ ]);
11882
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
11883
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
11884
+ "camera-online",
11885
+ "camera-offline",
11886
+ "camera-disabled",
11887
+ "camera-enabled"
11835
11888
  ]);
11836
11889
  /**
11890
+ * The kinds a rule may be AUTHORED with — every schema member except the
11891
+ * legacy tail. Editors render THIS list; the schema still parses the tail so a
11892
+ * durable row (and an unmigrated rule) survives being read.
11893
+ */
11894
+ var NC_AUTHORABLE_SYSTEM_EVENT_KINDS = NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
11895
+ /**
11896
+ * The panel's three transitions, as ONE list.
11897
+ *
11898
+ * Named here rather than spelled out at each of the four sites that need them
11899
+ * (the emitter, the intake, the editor group, the combined-notification gate),
11900
+ * because a fourth transition added to the enum and forgotten at one of them is
11901
+ * an alarm state nobody can be notified about.
11902
+ */
11903
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
11904
+ "alarm-triggered",
11905
+ "alarm-armed",
11906
+ "alarm-disarmed"
11907
+ ];
11908
+ /**
11837
11909
  * One coherent system-event condition. `kinds` is the required opt-in safety
11838
11910
  * gate; the remaining lists are optional narrowing filters relevant to the
11839
11911
  * selected kinds.
@@ -11841,6 +11913,18 @@ var NcSystemEventKindSchema = zod.z.enum([
11841
11913
  var NcSystemEventConditionSchema = zod.z.object({
11842
11914
  kinds: zod.z.array(NcSystemEventKindSchema).min(1),
11843
11915
  deviceIds: zod.z.array(zod.z.number().int()).min(1).optional(),
11916
+ /**
11917
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
11918
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
11919
+ * is what a liveness rule means when nobody said otherwise.
11920
+ *
11921
+ * This is where "only my cameras" is expressed, and it lives on the rule for
11922
+ * one reason: the intake cannot know which devices this household cares
11923
+ * about, and a producer-side filter is one no operator can change. Fails
11924
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
11925
+ * does not carry) matches no `deviceTypes` list.
11926
+ */
11927
+ deviceTypes: zod.z.array(zod.z.string().min(1)).min(1).optional(),
11844
11928
  nodeIds: zod.z.array(zod.z.string().min(1)).min(1).optional(),
11845
11929
  packageNames: zod.z.array(zod.z.string().min(1)).min(1).optional()
11846
11930
  });
@@ -11899,6 +11983,59 @@ var NcOccupancyConditionSchema = zod.z.object({
11899
11983
  sustainSeconds: zod.z.number().int().min(0).max(3600).default(15)
11900
11984
  });
11901
11985
  /**
11986
+ * The dBFS floor the analyzer reports on digital silence
11987
+ * (`audio-analyzer-provider.ts`: `dbfs = rms > 0 ? 20*log10(rms) : -96`).
11988
+ *
11989
+ * It is the lower bound of {@link NcAudioConditionSchema.shape.dbThreshold} for
11990
+ * one reason worth stating out loud: **the scale is dBFS and it is
11991
+ * NEGATIVE-GOING** — `0` is full scale and silence reads as a large negative
11992
+ * number. An operator (or a UI) that writes `60` meaning "60 decibels, quite
11993
+ * loud" would author a threshold NO sample can ever reach, and the rule would
11994
+ * look broken rather than mis-configured. The schema range rejects it instead.
11995
+ */
11996
+ var NC_AUDIO_DBFS_FLOOR = -96;
11997
+ /**
11998
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
11999
+ *
12000
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
12001
+ * reference notifier uses, so an operator moving between them re-uses what
12002
+ * they already know): a rule matches when, over a sampling window of
12003
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
12004
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
12005
+ *
12006
+ * - `dbThreshold` — its level is at or above this many dBFS (see
12007
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
12008
+ * - `labels` — the classifier put at least one of these labels on it.
12009
+ *
12010
+ * Both are OPTIONAL and independent, which is the point of the shape: a
12011
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
12012
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
12013
+ * is given** — a window in which every sample is trivially a hit would fire on
12014
+ * silence, so the engine refuses such a condition rather than notifying on
12015
+ * nothing (the schema cannot express "at least one of" without becoming a
12016
+ * ZodEffects the cap path would have to special-case).
12017
+ *
12018
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
12019
+ * must be FULL before it can match — a window that has been open for two
12020
+ * seconds of its ten is 100% of nothing, and firing on it would make
12021
+ * `samplingSeconds` decorative.
12022
+ *
12023
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
12024
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
12025
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
12026
+ * an operator who typed `dog` mean the same thing.
12027
+ */
12028
+ var NcAudioConditionSchema = zod.z.object({
12029
+ /** Audio macro labels; absent = any sound (level-only rule). */
12030
+ labels: zod.z.array(zod.z.string().min(1)).min(1).optional(),
12031
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
12032
+ dbThreshold: zod.z.number().min(-96).max(0).optional(),
12033
+ /** Percentage of the window's samples that must be hits (1–100). */
12034
+ hitPercent: zod.z.number().int().min(1).max(100).default(60),
12035
+ /** Length of the sampling window in seconds. */
12036
+ samplingSeconds: zod.z.number().int().min(1).max(300).default(10)
12037
+ });
12038
+ /**
11902
12039
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
11903
12040
  *
11904
12041
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -12182,7 +12319,33 @@ var NcConditionsSchema = zod.z.object({
12182
12319
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
12183
12320
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
12184
12321
  */
12185
- occupancy: NcOccupancyConditionSchema.optional()
12322
+ occupancy: NcOccupancyConditionSchema.optional(),
12323
+ /**
12324
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
12325
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
12326
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
12327
+ * a window that is not full yet, neither filter given). See
12328
+ * {@link NcAudioCondition}.
12329
+ *
12330
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
12331
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
12332
+ * a detection, a track or a device event (the same fail-closed pairing
12333
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
12334
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
12335
+ * (an `immediate` rule naming an `audio-*` class, one notification per
12336
+ * classified sample) stays exactly as it was for rules that already use it.
12337
+ *
12338
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
12339
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
12340
+ * (`camstack/src/data/notification-center.ts`, guarded by
12341
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
12342
+ * condition fields it does not know when a rule is saved from the phone.
12343
+ * Publishing an editor for a condition the app cannot round-trip is how an
12344
+ * operator loses a rule's conditions by opening it — so the descriptor, the
12345
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
12346
+ * does an audio rule become authorable.
12347
+ */
12348
+ audio: NcAudioConditionSchema.optional()
12186
12349
  });
12187
12350
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
12188
12351
  var NcRuleTargetSchema = zod.z.object({
@@ -12296,6 +12459,74 @@ var NcThrottleSchema = zod.z.object({
12296
12459
  */
12297
12460
  granularity: NcThrottleGranularitySchema.optional()
12298
12461
  });
12462
+ /**
12463
+ * How long the confirm gate may hold ONE notification, and how big the picture
12464
+ * it judges may be.
12465
+ *
12466
+ * The clamp is the product decision, not a coincidence of the model: p50 was
12467
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
12468
+ * arrives after the visitor has gone is not a notification. 448 px was enough
12469
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
12470
+ * tokens for pixels the model pools away.
12471
+ */
12472
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
12473
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
12474
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
12475
+ var NC_CONFIRM_DEFAULT_MAX_IMAGE_PX = 448;
12476
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
12477
+ var NcConfirmExpectSchema = zod.z.object({
12478
+ op: zod.z.enum([
12479
+ ">=",
12480
+ ">",
12481
+ "<=",
12482
+ "<",
12483
+ "=="
12484
+ ]),
12485
+ count: zod.z.number().int().min(0).max(1e3)
12486
+ });
12487
+ /**
12488
+ * AI CONFIRM — a vision model looks at the picture this notification is about
12489
+ * to ship and says whether it agrees with the rule.
12490
+ *
12491
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
12492
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
12493
+ * on the operator's phone is not a verdict about this notification.
12494
+ *
12495
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
12496
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
12497
+ * the default and every fail-open is COUNTED, because a gate that always fails
12498
+ * open looks in the log exactly like a gate that works.
12499
+ *
12500
+ * Every field is `.optional()` rather than relied on as a Zod default at the
12501
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
12502
+ * production failures in one day), so the gate reads absent as the constant
12503
+ * above rather than trusting a parse it may never have seen.
12504
+ */
12505
+ var NcConfirmSchema = zod.z.object({
12506
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
12507
+ * same thing, and both mean "deliver exactly as before". */
12508
+ enabled: zod.z.boolean().default(false),
12509
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
12510
+ profileId: zod.z.string().optional(),
12511
+ /**
12512
+ * The operator's question, in his own words. Absent = a question derived
12513
+ * from the rule (its class and its expectation).
12514
+ *
12515
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
12516
+ * banners, signage and plates as instructions if you let them reach the
12517
+ * prompt — proven live — so the authoritative contract stays in the system
12518
+ * turn and only rule-authored words land here.
12519
+ */
12520
+ prompt: zod.z.string().max(1e3).optional(),
12521
+ /** Fire only when the model's count satisfies this. Absent = the model's
12522
+ * own boolean verdict decides. */
12523
+ expect: NcConfirmExpectSchema.optional(),
12524
+ timeoutMs: zod.z.number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
12525
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
12526
+ onTimeout: zod.z.enum(["fire", "suppress"]).default("fire"),
12527
+ /** Longest edge the judged image is downscaled to before it is sent. */
12528
+ maxImagePx: zod.z.number().int().min(64).max(2048).default(448)
12529
+ });
12299
12530
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
12300
12531
  var NcRuleInputSchema = zod.z.object({
12301
12532
  name: zod.z.string().min(1).max(200),
@@ -12356,7 +12587,13 @@ var NcRuleInputSchema = zod.z.object({
12356
12587
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
12357
12588
  * shape as every other actuation.
12358
12589
  */
12359
- actions: NcRuleActionsSchema.optional()
12590
+ actions: NcRuleActionsSchema.optional(),
12591
+ /**
12592
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
12593
+ * a rule that predates the gate must keep delivering byte-for-byte as it
12594
+ * did, and absent is the only way to say that without a migration.
12595
+ */
12596
+ confirm: NcConfirmSchema.optional()
12360
12597
  });
12361
12598
  /**
12362
12599
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -12367,7 +12604,37 @@ var NcRuleInputSchema = zod.z.object({
12367
12604
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
12368
12605
  * `updateRule` patch.
12369
12606
  */
12370
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: zod.z.array(zod.z.string()).optional() });
12607
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
12608
+ disabledTargetIds: zod.z.array(zod.z.string()).optional(),
12609
+ /**
12610
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
12611
+ *
12612
+ * It makes the key optional to SUPPLY; the parse still materialises the
12613
+ * default when the key is absent. And `NcRuleStore.update` merges with
12614
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
12615
+ * one — which made every partial edit destructive:
12616
+ *
12617
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
12618
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
12619
+ * setEnabled(ruleId, false) → conditions reset to `{}`
12620
+ *
12621
+ * A rule scoped to one camera and one zone silently became a rule that
12622
+ * matches EVERY event on EVERY camera, and lost its `media` policy
12623
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
12624
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
12625
+ * within a minute of a two-field patch.
12626
+ *
12627
+ * So every defaulted field is re-declared here WITHOUT its default. The
12628
+ * inner defaults still apply when the caller DOES send the key — `{}` for
12629
+ * conditions remains a real instruction ("clear them") — and only the
12630
+ * absent key is now genuinely absent.
12631
+ */
12632
+ enabled: zod.z.boolean().optional(),
12633
+ conditions: NcConditionsSchema.optional(),
12634
+ media: NcMediaPolicySchema.optional(),
12635
+ throttle: NcThrottleSchema.optional(),
12636
+ priority: zod.z.number().int().min(1).max(5).optional()
12637
+ });
12371
12638
  /** A persisted rule. */
12372
12639
  var NcRuleSchema = NcRuleInputSchema.extend({
12373
12640
  id: zod.z.string(),
@@ -12480,12 +12747,20 @@ var NC_CONDITION_CATALOG = [
12480
12747
  valueType: "systemEvent",
12481
12748
  options: [
12482
12749
  {
12483
- value: "camera-online",
12484
- label: "Camera online"
12750
+ value: "device-online",
12751
+ label: "Device online"
12752
+ },
12753
+ {
12754
+ value: "device-offline",
12755
+ label: "Device offline"
12485
12756
  },
12486
12757
  {
12487
- value: "camera-offline",
12488
- label: "Camera offline"
12758
+ value: "device-disabled",
12759
+ label: "Device switched off"
12760
+ },
12761
+ {
12762
+ value: "device-enabled",
12763
+ label: "Device switched on"
12489
12764
  },
12490
12765
  {
12491
12766
  value: "stream-online",
@@ -12510,12 +12785,24 @@ var NC_CONDITION_CATALOG = [
12510
12785
  {
12511
12786
  value: "server-update-available",
12512
12787
  label: "Server update available"
12788
+ },
12789
+ {
12790
+ value: "alarm-triggered",
12791
+ label: "Alarm triggered"
12792
+ },
12793
+ {
12794
+ value: "alarm-armed",
12795
+ label: "Alarm armed"
12796
+ },
12797
+ {
12798
+ value: "alarm-disarmed",
12799
+ label: "Alarm disarmed"
12513
12800
  }
12514
12801
  ],
12515
12802
  operator: "in",
12516
12803
  appliesTo: ["system-event"],
12517
12804
  phase: "P1",
12518
- description: "Infrastructure and update events. Optionally narrow camera/stream events by device, node events by node id, and addon updates by package name."
12805
+ 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."
12519
12806
  },
12520
12807
  {
12521
12808
  id: "devices",
@@ -13045,6 +13332,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
13045
13332
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
13046
13333
  * copy would lie the first time a rule is disabled.
13047
13334
  */
13335
+ /**
13336
+ * Why a device a mode NAMES is nonetheless not armed by it.
13337
+ *
13338
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
13339
+ * per-camera notification switch the Notification Center already owns,
13340
+ * `detection-off` is the device's own detection binding being inactive, and
13341
+ * `offline` is the device manager's liveness. A fourth reason would mean a
13342
+ * fourth authority, and inventing one here is how a panel starts disagreeing
13343
+ * with the switches the operator actually used.
13344
+ */
13345
+ var NcAlarmSkipReasonSchema = zod.z.enum([
13346
+ "muted",
13347
+ "detection-off",
13348
+ "offline"
13349
+ ]);
13350
+ var NcAlarmSkippedDeviceSchema = zod.z.object({
13351
+ deviceId: zod.z.number().int(),
13352
+ reason: NcAlarmSkipReasonSchema
13353
+ });
13048
13354
  var NcAlarmModeCoverageSchema = zod.z.object({
13049
13355
  mode: AlarmArmModeSchema,
13050
13356
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -13052,7 +13358,18 @@ var NcAlarmModeCoverageSchema = zod.z.object({
13052
13358
  /** At least one covering rule has no device scope, so the mode covers all. */
13053
13359
  allDevices: zod.z.boolean(),
13054
13360
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
13055
- deviceIds: zod.z.array(zod.z.number().int())
13361
+ deviceIds: zod.z.array(zod.z.number().int()),
13362
+ /**
13363
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
13364
+ * excludes it.
13365
+ *
13366
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
13367
+ * twelve makes it false in exactly the way nobody notices until an incident.
13368
+ * Defaulted to `[]` so a coverage answer computed before this field existed
13369
+ * still parses as "nothing known to be skipped" rather than failing the whole
13370
+ * alarm tab.
13371
+ */
13372
+ skippedDevices: zod.z.array(NcAlarmSkippedDeviceSchema).default([])
13056
13373
  });
13057
13374
  var NcAlarmConfigSchema = zod.z.object({
13058
13375
  /**
@@ -25621,7 +25938,19 @@ var RecordingManifestSchema = zod.z.object({
25621
25938
  * profiles/subtrees/locations on this node). */
25622
25939
  var RecordingDeviceUsageSchema = zod.z.object({
25623
25940
  deviceId: zod.z.number(),
25624
- usedBytes: zod.z.number()
25941
+ usedBytes: zod.z.number(),
25942
+ /**
25943
+ * Start of this camera's OLDEST indexed segment, across every profile and
25944
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25945
+ * only honest answer to "is retention actually holding?" per camera.
25946
+ *
25947
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25948
+ * predates this field omits it entirely, and a hub whose types carry the
25949
+ * field must keep validating that older provider's payload: the framework
25950
+ * (types) and the addon ship on different trains, and the addon is usually
25951
+ * the later of the two.
25952
+ */
25953
+ oldestMs: zod.z.number().nullable().optional()
25625
25954
  });
25626
25955
  /** Recording storage usage + capacity for one storage location. */
25627
25956
  var RecordingLocationUsageSchema = zod.z.object({
@@ -25649,6 +25978,57 @@ var RecordingStorageUsageSchema = zod.z.object({
25649
25978
  locations: zod.z.array(RecordingLocationUsageSchema)
25650
25979
  });
25651
25980
  /**
25981
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25982
+ *
25983
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25984
+ * is the operator asking for the EXISTING archive to be brought into line with
25985
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25986
+ * location, run FIFO behind the single-flight mover.
25987
+ *
25988
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25989
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25990
+ * (empty on the plan).
25991
+ */
25992
+ var RecordingRebalanceMoveSchema = zod.z.object({
25993
+ deviceId: zod.z.number(),
25994
+ profile: zod.z.string(),
25995
+ fromLocationId: zod.z.string(),
25996
+ toLocationId: zod.z.string(),
25997
+ bytes: zod.z.number(),
25998
+ files: zod.z.number().int()
25999
+ });
26000
+ /** Why a pile that is out of place is staying there. Every refusal is
26001
+ * reported: a rebalance that silently drops a camera reads exactly like one
26002
+ * that had nothing to do. */
26003
+ var RecordingRebalanceSkipReasonSchema = zod.z.enum([
26004
+ "unassigned",
26005
+ "target-not-writable",
26006
+ "below-threshold",
26007
+ "no-headroom"
26008
+ ]);
26009
+ var RecordingRebalanceSkipSchema = zod.z.object({
26010
+ deviceId: zod.z.number(),
26011
+ profile: zod.z.string(),
26012
+ fromLocationId: zod.z.string(),
26013
+ /** The location the plan wants; null when the camera has no assignment. */
26014
+ toLocationId: zod.z.string().nullable(),
26015
+ bytes: zod.z.number(),
26016
+ reason: RecordingRebalanceSkipReasonSchema
26017
+ });
26018
+ var RecordingRebalancePlanSchema = zod.z.object({
26019
+ moves: zod.z.array(RecordingRebalanceMoveSchema),
26020
+ skipped: zod.z.array(RecordingRebalanceSkipSchema),
26021
+ bytesToMove: zod.z.number(),
26022
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
26023
+ jobIds: zod.z.array(zod.z.string())
26024
+ });
26025
+ var RecordingRebalanceInputSchema = zod.z.object({
26026
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
26027
+ throttleMbps: zod.z.number().min(1).max(1e3).optional(),
26028
+ /** Ignore piles smaller than this (default 1 GB). */
26029
+ minMoveGb: zod.z.number().min(0).optional()
26030
+ });
26031
+ /**
25652
26032
  * Result of locating footage at a wall-clock instant for one device/profile.
25653
26033
  * `segment` carries the covering segment's window; `gap` reports the forward
25654
26034
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -25892,6 +26272,36 @@ var recordingCapability = {
25892
26272
  cancelStorageMigrationMove: require_sleep.method(zod.z.object({ jobId: zod.z.string() }), zod.z.object({ cancelled: zod.z.boolean() }), {
25893
26273
  kind: "mutation",
25894
26274
  auth: "admin"
26275
+ }),
26276
+ /**
26277
+ * Move footage between locations — the OPERATOR's mover, scoped to one
26278
+ * camera (and optionally to specific profiles) rather than a whole disk.
26279
+ * Queued FIFO behind the single-flight engine, so arming several is safe.
26280
+ */
26281
+ relocateFootage: require_sleep.method(RelocateFootageInputSchema, zod.z.object({ jobId: zod.z.string() }), {
26282
+ kind: "mutation",
26283
+ auth: "admin"
26284
+ }),
26285
+ /** Every relocate job this recorder knows about, newest first (in RAM: the
26286
+ * move is resumable, so a lost list costs nothing but the display). */
26287
+ listRelocateJobs: require_sleep.method(zod.z.object({}), zod.z.array(RelocateJobSchema).readonly(), {
26288
+ kind: "query",
26289
+ auth: "admin"
26290
+ }),
26291
+ /** Cancel a running or queued relocate job. A queued job never runs. */
26292
+ cancelRelocateJob: require_sleep.method(zod.z.object({ jobId: zod.z.string() }), zod.z.object({ cancelled: zod.z.boolean() }), {
26293
+ kind: "mutation",
26294
+ auth: "admin"
26295
+ }),
26296
+ /** What a rebalance WOULD move, and what it would refuse. Moves nothing. */
26297
+ planStorageRebalance: require_sleep.method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26298
+ kind: "query",
26299
+ auth: "admin"
26300
+ }),
26301
+ /** Arm the rebalance: enqueue one relocate job per planned move. */
26302
+ startStorageRebalance: require_sleep.method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26303
+ kind: "mutation",
26304
+ auth: "admin"
25895
26305
  })
25896
26306
  }
25897
26307
  };
@@ -25914,13 +26324,24 @@ var recordingCapability = {
25914
26324
  /** Playback-speed multiplier for the render (1 = realtime). */
25915
26325
  var ExportSpeedSchema = zod.z.number().min(.25).max(32);
25916
26326
  /**
25917
- * One dense interval, in SECONDS FROM THE EXPORT'S OWN `fromMs`.
26327
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
26328
+ *
26329
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
26330
+ * derives these bounds from things that happened at a TIME (a track's
26331
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
26332
+ * every segment present for the range, with each recording GAP removed. The
26333
+ * two agree only on a window that recorded without one interruption, and only
26334
+ * the render side knows the segments, so the translation lives there
26335
+ * (`export-dense-map.ts`, addon-pipeline).
25918
26336
  *
25919
- * Relative and not absolute epoch on purpose: the renderer's frame-select
25920
- * expression sees ffmpeg's `t`, which starts at 0 for the export's source
25921
- * playlist. Handing it absolute epochs would make every call site responsible
25922
- * for the same subtraction, and the one that forgot would emit a filter that
25923
- * selects nothing silently, as a uniform timelapse.
26337
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
26338
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
26339
+ * gap accumulated before it up to 6,607 s, well past EOF. Nothing matched,
26340
+ * the video was a uniform timelapse, and the log line reported the five ranges
26341
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
26342
+ *
26343
+ * Relative and not absolute epoch, because an absolute epoch would make every
26344
+ * call site responsible for the same subtraction.
25924
26345
  */
25925
26346
  var ExportDenseRangeSchema = zod.z.object({
25926
26347
  fromSec: zod.z.number().nonnegative(),
@@ -35839,6 +36260,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
35839
36260
  addonId: null,
35840
36261
  access: "create"
35841
36262
  },
36263
+ "recording.cancelRelocateJob": {
36264
+ capName: "recording",
36265
+ capScope: "system",
36266
+ addonId: null,
36267
+ access: "create"
36268
+ },
35842
36269
  "recording.cancelStorageMigrationMove": {
35843
36270
  capName: "recording",
35844
36271
  capScope: "system",
@@ -35893,6 +36320,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
35893
36320
  addonId: null,
35894
36321
  access: "view"
35895
36322
  },
36323
+ "recording.listRelocateJobs": {
36324
+ capName: "recording",
36325
+ capScope: "system",
36326
+ addonId: null,
36327
+ access: "view"
36328
+ },
35896
36329
  "recording.locateSegment": {
35897
36330
  capName: "recording",
35898
36331
  capScope: "system",
@@ -35905,6 +36338,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
35905
36338
  addonId: null,
35906
36339
  access: "create"
35907
36340
  },
36341
+ "recording.planStorageRebalance": {
36342
+ capName: "recording",
36343
+ capScope: "system",
36344
+ addonId: null,
36345
+ access: "view"
36346
+ },
35908
36347
  "recording.pruneFootage": {
35909
36348
  capName: "recording",
35910
36349
  capScope: "system",
@@ -35929,6 +36368,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
35929
36368
  addonId: null,
35930
36369
  access: "create"
35931
36370
  },
36371
+ "recording.relocateFootage": {
36372
+ capName: "recording",
36373
+ capScope: "system",
36374
+ addonId: null,
36375
+ access: "create"
36376
+ },
35932
36377
  "recording.renderClip": {
35933
36378
  capName: "recording",
35934
36379
  capScope: "system",
@@ -35965,6 +36410,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
35965
36410
  addonId: null,
35966
36411
  access: "create"
35967
36412
  },
36413
+ "recording.startStorageRebalance": {
36414
+ capName: "recording",
36415
+ capScope: "system",
36416
+ addonId: null,
36417
+ access: "create"
36418
+ },
35968
36419
  "recordingExport.cancelExport": {
35969
36420
  capName: "recording-export",
35970
36421
  capScope: "system",
@@ -38132,7 +38583,12 @@ function createSystemProxy(api) {
38132
38583
  refreshStorageLocationsForMigration: (input) => dispatch("recording", "refreshStorageLocationsForMigration", "mutation", input),
38133
38584
  startStorageMigrationMove: (input) => dispatch("recording", "startStorageMigrationMove", "mutation", input),
38134
38585
  getStorageMigrationMoveStatus: (input) => dispatch("recording", "getStorageMigrationMoveStatus", "query", input),
38135
- cancelStorageMigrationMove: (input) => dispatch("recording", "cancelStorageMigrationMove", "mutation", input)
38586
+ cancelStorageMigrationMove: (input) => dispatch("recording", "cancelStorageMigrationMove", "mutation", input),
38587
+ relocateFootage: (input) => dispatch("recording", "relocateFootage", "mutation", input),
38588
+ listRelocateJobs: (input) => dispatch("recording", "listRelocateJobs", "query", input),
38589
+ cancelRelocateJob: (input) => dispatch("recording", "cancelRelocateJob", "mutation", input),
38590
+ planStorageRebalance: (input) => dispatch("recording", "planStorageRebalance", "query", input),
38591
+ startStorageRebalance: (input) => dispatch("recording", "startStorageRebalance", "mutation", input)
38136
38592
  },
38137
38593
  recordingExport: {
38138
38594
  getExport: (input) => dispatch("recordingExport", "getExport", "query", input),
@@ -38694,6 +39150,111 @@ var FramerateField = zod.z.number().int().min(1).max(60);
38694
39150
  var TargetsField = zod.z.array(NcRuleTargetSchema).min(1);
38695
39151
  var PriorityField = zod.z.number().int().min(1).max(5);
38696
39152
  /**
39153
+ * Floor on any dense cadence, seconds — the recording's own frame interval.
39154
+ *
39155
+ * Declared here because it bounds BOTH the rule field and the renderer's
39156
+ * derivation, and two copies of a floor are two floors that can drift.
39157
+ */
39158
+ var TIMELAPSE_DENSE_FLOOR_SEC = .1;
39159
+ /**
39160
+ * Explicit override of the DENSE sampling cadence, seconds.
39161
+ *
39162
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
39163
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
39164
+ * made that same base 3 s and rendered a person pass as two frames.)
39165
+ *
39166
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
39167
+ * `denseCadenceSec` and played at `framerate` occupies
39168
+ *
39169
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
39170
+ *
39171
+ * 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.
39172
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
39173
+ * and therefore the length of a quiet night, does not move.
39174
+ *
39175
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
39176
+ * the recording has them returns the same frames, requested twice. Must be
39177
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
39178
+ * a uniform video the operator believes is two-rate — and upsert refuses it
39179
+ * rather than letting the export cap reject the render hours after the window.
39180
+ */
39181
+ var DenseCadenceSecField = zod.z.number().min(TIMELAPSE_DENSE_FLOOR_SEC).max(3600);
39182
+ /**
39183
+ * Minimum seconds of OUTPUT video each detection range must occupy.
39184
+ *
39185
+ * The operator-facing form of the arithmetic above: instead of solving for a
39186
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
39187
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
39188
+ * that range every ~583 ms.
39189
+ *
39190
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
39191
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
39192
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
39193
+ * ranges are sampled denser than they need. Per-range cadences require a cap
39194
+ * schema change and are the tracked follow-up.
39195
+ *
39196
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
39197
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
39198
+ * by real footage, never met by duplicating frames into motion that never
39199
+ * happened.
39200
+ */
39201
+ var MinDwellSecField = zod.z.number().min(0).max(60);
39202
+ /**
39203
+ * Caption burned into the notification's preview frame.
39204
+ *
39205
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
39206
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
39207
+ * templating dialect for one field would be a second thing to explain.
39208
+ *
39209
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
39210
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
39211
+ * the reason this is not `.min(1)`.
39212
+ */
39213
+ var PreviewTextField = zod.z.string().max(200);
39214
+ /**
39215
+ * Whether the notification's preview is a STILL or a short animation.
39216
+ *
39217
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
39218
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
39219
+ * night reads better as three seconds of motion than as one frame of it. Both
39220
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
39221
+ * simply applies it to a dozen frames sampled across the render and assembles
39222
+ * them.
39223
+ *
39224
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
39225
+ * seeks and a palette pass, and no rule that never asked for one should start
39226
+ * paying that on the deploy that shipped it.
39227
+ *
39228
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
39229
+ */
39230
+ var PreviewModeField = zod.z.enum(["image", "gif"]);
39231
+ /**
39232
+ * Which detection classes the notification reports counts for.
39233
+ *
39234
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
39235
+ * plan — no second query — aggregated per class. Absent or empty means "every
39236
+ * class the window actually contained", which is what an operator who never
39237
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
39238
+ * counts cars all night).
39239
+ *
39240
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
39241
+ * …). An unknown name simply never matches and reports nothing — it is not an
39242
+ * error, because a rule may legitimately name a class this camera's model does
39243
+ * not emit.
39244
+ *
39245
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
39246
+ * - `{{detections}}` — total over the reported classes
39247
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
39248
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
39249
+ * one per class, `count_` + the class name
39250
+ *
39251
+ * With NO custom body template the summary is appended to the derived body, and
39252
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
39253
+ * reads. With a custom template the operator owns every word — nothing is
39254
+ * appended, so `{{detectionSummary}}` is how he asks for it.
39255
+ */
39256
+ var ReportClassesField = zod.z.array(zod.z.string().min(1).max(40)).max(20);
39257
+ /**
38697
39258
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
38698
39259
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
38699
39260
  * here (see the ownership note above).
@@ -38713,13 +39274,42 @@ var TimelapseRuleInputSchema = zod.z.object({
38713
39274
  cadenceSec: CadenceSecField.default(15),
38714
39275
  /** Output frames per second of the assembled mp4 (predecessor parity). */
38715
39276
  framerate: FramerateField.default(10),
39277
+ /**
39278
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
39279
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
39280
+ * field gets.
39281
+ */
39282
+ denseCadenceSec: DenseCadenceSecField.optional(),
39283
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
39284
+ minDwellSec: MinDwellSecField.optional(),
38716
39285
  /** `notification-output` targets the finished video/thumbnail is sent to. */
38717
39286
  targets: TargetsField,
38718
39287
  template: TimelapseTemplateSchema.optional(),
39288
+ /**
39289
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
39290
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
39291
+ *
39292
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
39293
+ * the notification's title/body, and clearing it (`template: null`) must not
39294
+ * silently clear the caption too.
39295
+ */
39296
+ previewText: PreviewTextField.optional(),
39297
+ /** Still or animation — see {@link PreviewModeField}. */
39298
+ previewMode: PreviewModeField.default("image"),
39299
+ /** Classes the notification counts — see {@link ReportClassesField}. */
39300
+ reportClasses: ReportClassesField.optional(),
38719
39301
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
38720
39302
  priority: PriorityField.default(3)
38721
39303
  });
38722
39304
  /**
39305
+ * The caption a rule that never set one gets.
39306
+ *
39307
+ * Rendered through the ordinary `{{var}}` pass at delivery, so a rule created
39308
+ * before this field existed still reads "Timelapse Videocamera ingresso" and
39309
+ * not the literal braces.
39310
+ */
39311
+ var DEFAULT_TIMELAPSE_PREVIEW_TEXT = "Timelapse {{camera}}";
39312
+ /**
38723
39313
  * Partial patch for an update — any subset of the INPUT fields, with NO
38724
39314
  * defaults (an absent key means "leave unchanged", never "reset to default").
38725
39315
  * Provenance and ownership are absent by construction: a patch can rename or
@@ -38742,8 +39332,13 @@ var TimelapseRulePatchSchema = zod.z.object({
38742
39332
  schedule: NcScheduleSchema.optional(),
38743
39333
  cadenceSec: CadenceSecField.optional(),
38744
39334
  framerate: FramerateField.optional(),
39335
+ denseCadenceSec: DenseCadenceSecField.optional(),
39336
+ minDwellSec: MinDwellSecField.optional(),
38745
39337
  targets: TargetsField.optional(),
38746
39338
  template: TimelapseTemplateSchema.nullable().optional(),
39339
+ previewText: PreviewTextField.optional(),
39340
+ previewMode: PreviewModeField.optional(),
39341
+ reportClasses: ReportClassesField.optional(),
38747
39342
  priority: PriorityField.optional()
38748
39343
  });
38749
39344
  /** A persisted timelapse rule. */
@@ -38784,6 +39379,26 @@ var TimelapseRuleSchema = TimelapseRuleInputSchema.extend({
38784
39379
  updatedAt: zod.z.number()
38785
39380
  });
38786
39381
  /**
39382
+ * Refuse a dense cadence that is not denser than the base.
39383
+ *
39384
+ * Called at UPSERT, on the MERGED rule — a patch that lowers `cadenceSec`
39385
+ * alone can invalidate a `denseCadenceSec` set months earlier, so checking the
39386
+ * patch in isolation would let the bad pair through.
39387
+ *
39388
+ * Refusing here and not at render time is the whole point: `ExportTimelapseSchema`
39389
+ * also rejects the pair, but it does so when the window has already closed and
39390
+ * the footage is being cut — the operator learns at 06:05 that last night was
39391
+ * never going to render, and a closed window does not come back. This turns
39392
+ * that into a failed edit he can see and correct.
39393
+ *
39394
+ * @throws Error naming both numbers, so the message is actionable in a toast.
39395
+ */
39396
+ function assertTimelapseCadences(pair) {
39397
+ const dense = pair.denseCadenceSec;
39398
+ if (dense === void 0) return;
39399
+ 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`);
39400
+ }
39401
+ /**
38787
39402
  * The last successful generation for ONE camera of a rule, epoch-ms.
38788
39403
  *
38789
39404
  * The per-device map wins; a rule with no map falls back to the rule-wide
@@ -38999,8 +39614,8 @@ function slideInsideFrame(rect, frameWidth, frameHeight) {
38999
39614
  //#endregion
39000
39615
  //#region src/pipeline/native-lease.ts
39001
39616
  /**
39002
- * THE native-frame **lease** knobs — TTL, RAM budget and demand window for the
39003
- * decode worker's native-resolution frame retention.
39617
+ * THE native-frame **lease** knobs — hold depth, RAM budget, demand window and
39618
+ * subject-tile budget for the decode worker's native-resolution retention.
39004
39619
  *
39005
39620
  * ## Why they live here and not in the addon that reads them
39006
39621
  *
@@ -39016,20 +39631,25 @@ function slideInsideFrame(rect, frameWidth, frameHeight) {
39016
39631
  * The lease is a per-decode-worker RAM window. Its purpose — the late
39017
39632
  * cross-process native crop landing on a full-resolution frame rather than the
39018
39633
  * ≤640 detection fallback — is a property of the PIPELINE, not of a node's
39019
- * hardware: a per-node TTL would mean the same camera produces different crop
39634
+ * hardware: a per-node window would mean the same camera produces different crop
39020
39635
  * quality depending on which node the balancer placed it on, and nobody could
39021
39636
  * tell that from the stored media. Node-level RAM pressure is already handled
39022
39637
  * by the per-session budget ceiling, which is itself one of these knobs.
39023
39638
  *
39024
39639
  * ## What each knob costs
39025
39640
  *
39026
- * A retained frame is a full NATIVE-resolution copy in system RAM. With the
39641
+ * A HELD frame is a full NATIVE-resolution copy in system RAM. With the
39027
39642
  * default pinned-RGB24 lease path (`CAMSTACK_SESSION_PINNED_RGB_CROP`, on):
39028
39643
  * 4K ≈ 24.9 MB/frame, 1080p ≈ 6.2 MB/frame. On the YUV420P path (flag off, and
39029
39644
  * for software-decoded sessions): 4K ≈ 12.4 MB, 1080p ≈ 3.1 MB. Worst-case
39030
- * resident RAM for ONE busy camera frameBytes × deliveredFps × ttlSeconds,
39031
- * clamped by the budget ceiling. See `docs/design/decode-path.md` "Lease
39032
- * admission" for what actually gets admitted.
39645
+ * resident RAM for ONE busy camera is now `frameBytes × holdFrames`, clamped by
39646
+ * the budget ceiling bounded by a COUNT because a held frame is waiting for
39647
+ * one specific event (its own detection result), not for a clock.
39648
+ *
39649
+ * A TILE is one subject at native resolution, JPEG-encoded: ~60-120 KB on 4K,
39650
+ * and nothing at all on a frame that detected nothing. That is the asymmetry
39651
+ * this whole shape exists for — see
39652
+ * `docs/design/2026-08-13-native-lease-two-tier-redesign.md`.
39033
39653
  */
39034
39654
  /**
39035
39655
  * Store identity of the lease knobs in `pipeline-orchestrator`'s GLOBAL
@@ -39037,10 +39657,11 @@ function slideInsideFrame(rect, frameWidth, frameHeight) {
39037
39657
  * the reader can walk every section instead of trusting the section id.
39038
39658
  */
39039
39659
  var NATIVE_LEASE_SECTION_ID = "native-lease";
39040
- var NATIVE_LEASE_TTL_KEY = "nativeLeaseTtlMs";
39660
+ var NATIVE_LEASE_HOLD_KEY = "nativeLeaseHoldFrames";
39041
39661
  var NATIVE_LEASE_BUDGET_KEY = "nativeLeaseBudgetMb";
39042
39662
  var NATIVE_LEASE_ACTIVITY_KEY = "nativeLeaseActivityMs";
39043
39663
  var NATIVE_LEASE_ADMISSION_KEY = "nativeLeaseAdmission";
39664
+ var NATIVE_LEASE_TILE_BUDGET_KEY = "nativeTileBudgetMb";
39044
39665
  /**
39045
39666
  * WHICH delivered frames the decode worker retains a native copy of.
39046
39667
  *
@@ -39067,25 +39688,32 @@ var NativeLeaseAdmissionSchema = zod.z.enum(["all", "inferred"]);
39067
39688
  */
39068
39689
  var NativeLeaseSettingsSchema = zod.z.object({
39069
39690
  /**
39070
- * How long a retained native frame is served before it counts as a miss.
39691
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
39692
+ * detection result.
39071
39693
  *
39072
- * Must cover the FULL late-crop horizon: detection inference + the
39073
- * cross-process inference-result hop to hub post-analysis + tracking + the
39074
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
39075
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
39076
- * RAM per busy camera grows linearly with no measured hit-rate gain.
39694
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
39695
+ * a time window was never related to the event the pixels were waiting for.
39696
+ * A held frame now lives from delivery until the runner has its `FrameResult`
39697
+ * at which moment the runner cuts the subject tiles it actually wanted and
39698
+ * releases the frame. The bound exists only so a runner that stops answering
39699
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
39700
+ *
39701
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
39702
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
39703
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
39704
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
39705
+ * `holdOverflow` on the metrics line is what says you need it.
39077
39706
  */
39078
- ttlMs: zod.z.number().int().min(250).max(1e4),
39707
+ holdFrames: zod.z.number().int().min(1).max(64),
39079
39708
  /**
39080
39709
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
39081
39710
  *
39082
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
39083
- * which one is actually binding before reasoning from that. At the shipped
39084
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
39085
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
39086
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
39087
- * change that admits fewer frames buys retention WINDOW at constant RAM
39088
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
39711
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
39712
+ * is what decides how much is held, and the ceiling is the number above which
39713
+ * something is wrong. Before that it was the effective cap at 1024 MB with
39714
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
39715
+ * with the TTL expiring nothing, which is exactly the confusion the hold
39716
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
39089
39717
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
39090
39718
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
39091
39719
  * to replace).
@@ -39111,25 +39739,47 @@ var NativeLeaseSettingsSchema = zod.z.object({
39111
39739
  * there is the signal that some caller names frames outside the inference set
39112
39740
  * and that this must go back to `all`.
39113
39741
  */
39114
- admission: NativeLeaseAdmissionSchema
39742
+ admission: NativeLeaseAdmissionSchema,
39743
+ /**
39744
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
39745
+ * compressed native crops the worker cuts at the moment a frame's detection
39746
+ * result arrives, and keeps long after the frame itself is freed.
39747
+ *
39748
+ * This is the knob that replaced the old retention window, and it buys about
39749
+ * three orders of magnitude more of it: a tile is one subject at native
39750
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
39751
+ * the frame it was cut from. A frame on which nothing was detected costs
39752
+ * nothing at all, which is the real change — the old lease paid per FRAME and
39753
+ * was interrogated per SUBJECT.
39754
+ *
39755
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
39756
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
39757
+ * reproduce that.
39758
+ */
39759
+ tileBudgetMb: zod.z.number().int().min(0).max(1024)
39115
39760
  });
39116
39761
  /**
39117
- * The values in force when the operator has set nothing — byte-for-byte the
39118
- * constants the decode worker shipped with as env-var defaults, so making these
39119
- * settings changed no behaviour on the day it landed.
39762
+ * The values in force when the operator has set nothing.
39763
+ *
39764
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
39765
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
39766
+ * in the same change that redefines it would make a regression and a retune
39767
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
39768
+ * live traffic.
39120
39769
  */
39121
39770
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
39122
- ttlMs: 1200,
39771
+ holdFrames: 8,
39123
39772
  budgetMb: 1024,
39124
39773
  activityMs: 15e3,
39774
+ tileBudgetMb: 64,
39125
39775
  admission: "inferred"
39126
39776
  };
39127
39777
  /** Slider bounds for the operator-facing knobs (orchestrator settings UI). */
39128
- var NATIVE_LEASE_TTL_FIELD = {
39129
- min: 250,
39130
- max: 1e4,
39131
- step: 50,
39132
- default: DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs
39778
+ var NATIVE_LEASE_HOLD_FIELD = {
39779
+ min: 1,
39780
+ max: 64,
39781
+ step: 1,
39782
+ default: DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames
39133
39783
  };
39134
39784
  var NATIVE_LEASE_BUDGET_FIELD = {
39135
39785
  min: 0,
@@ -39143,6 +39793,12 @@ var NATIVE_LEASE_ACTIVITY_FIELD = {
39143
39793
  step: 1e3,
39144
39794
  default: DEFAULT_NATIVE_LEASE_SETTINGS.activityMs
39145
39795
  };
39796
+ var NATIVE_LEASE_TILE_BUDGET_FIELD = {
39797
+ min: 0,
39798
+ max: 1024,
39799
+ step: 16,
39800
+ default: DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb
39801
+ };
39146
39802
  /** Select options for the admission knob (orchestrator settings UI). */
39147
39803
  var NATIVE_LEASE_ADMISSION_FIELD = {
39148
39804
  options: [{
@@ -39162,7 +39818,7 @@ var NATIVE_LEASE_ADMISSION_FIELD = {
39162
39818
  * precedence being true and being a lie. `addon-settings.getGlobalSettings`
39163
39819
  * returns a HYDRATED payload, and `hydrateField` fills an unstored field with
39164
39820
  * the schema's own `default` (verified live on the hub: a cluster that has never
39165
- * opened the form still reports `nativeLeaseTtlMs = 1200`). A reader that took
39821
+ * opened the form still reports `nativeLeaseHoldFrames = 8`). A reader that took
39166
39822
  * that at face value would report all three knobs as "set" on every cluster on
39167
39823
  * the day this shipped, permanently retiring the `CAMSTACK_SESSION_NATIVE_LEASE_*`
39168
39824
  * emergency override that the precedence promises. There is no raw-store read on
@@ -39196,25 +39852,28 @@ function readAdmissionKnob(raw) {
39196
39852
  * {@link readKnob} for why the default counts as unset.
39197
39853
  */
39198
39854
  function readNativeLeaseOverride(config) {
39199
- const ttlMs = readKnob("ttlMs", config[NATIVE_LEASE_TTL_KEY]);
39855
+ const holdFrames = readKnob("holdFrames", config[NATIVE_LEASE_HOLD_KEY]);
39200
39856
  const budgetMb = readKnob("budgetMb", config[NATIVE_LEASE_BUDGET_KEY]);
39201
39857
  const activityMs = readKnob("activityMs", config[NATIVE_LEASE_ACTIVITY_KEY]);
39202
39858
  const admission = readAdmissionKnob(config[NATIVE_LEASE_ADMISSION_KEY]);
39859
+ const tileBudgetMb = readKnob("tileBudgetMb", config[NATIVE_LEASE_TILE_BUDGET_KEY]);
39203
39860
  return {
39204
- ...ttlMs === null ? {} : { ttlMs },
39861
+ ...holdFrames === null ? {} : { holdFrames },
39205
39862
  ...budgetMb === null ? {} : { budgetMb },
39206
39863
  ...activityMs === null ? {} : { activityMs },
39207
- ...admission === null ? {} : { admission }
39864
+ ...admission === null ? {} : { admission },
39865
+ ...tileBudgetMb === null ? {} : { tileBudgetMb }
39208
39866
  };
39209
39867
  }
39210
39868
  function isHydratedField(entry) {
39211
39869
  return typeof entry === "object" && entry !== null && "key" in entry;
39212
39870
  }
39213
39871
  var LEASE_KEYS = [
39214
- NATIVE_LEASE_TTL_KEY,
39872
+ NATIVE_LEASE_HOLD_KEY,
39215
39873
  NATIVE_LEASE_BUDGET_KEY,
39216
39874
  NATIVE_LEASE_ACTIVITY_KEY,
39217
- NATIVE_LEASE_ADMISSION_KEY
39875
+ NATIVE_LEASE_ADMISSION_KEY,
39876
+ NATIVE_LEASE_TILE_BUDGET_KEY
39218
39877
  ];
39219
39878
  /**
39220
39879
  * Extract the operator's lease overrides from an
@@ -40752,6 +41411,7 @@ exports.DEFAULT_FEATURES = DEFAULT_FEATURES;
40752
41411
  exports.DEFAULT_NATIVE_LEASE_SETTINGS = DEFAULT_NATIVE_LEASE_SETTINGS;
40753
41412
  exports.DEFAULT_RETENTION = DEFAULT_RETENTION;
40754
41413
  exports.DEFAULT_SCRUB_THUMBNAIL_PRESET = DEFAULT_SCRUB_THUMBNAIL_PRESET;
41414
+ exports.DEFAULT_TIMELAPSE_PREVIEW_TEXT = DEFAULT_TIMELAPSE_PREVIEW_TEXT;
40755
41415
  exports.DETAIL_CROP_PADDING_FIELD = DETAIL_CROP_PADDING_FIELD;
40756
41416
  exports.DETAIL_CROP_PADDING_KEY = DETAIL_CROP_PADDING_KEY;
40757
41417
  exports.DETAIL_CROP_SECTION_ID = DETAIL_CROP_SECTION_ID;
@@ -40992,11 +41652,20 @@ exports.NATIVE_LEASE_ADMISSION_FIELD = NATIVE_LEASE_ADMISSION_FIELD;
40992
41652
  exports.NATIVE_LEASE_ADMISSION_KEY = NATIVE_LEASE_ADMISSION_KEY;
40993
41653
  exports.NATIVE_LEASE_BUDGET_FIELD = NATIVE_LEASE_BUDGET_FIELD;
40994
41654
  exports.NATIVE_LEASE_BUDGET_KEY = NATIVE_LEASE_BUDGET_KEY;
41655
+ exports.NATIVE_LEASE_HOLD_FIELD = NATIVE_LEASE_HOLD_FIELD;
41656
+ exports.NATIVE_LEASE_HOLD_KEY = NATIVE_LEASE_HOLD_KEY;
40995
41657
  exports.NATIVE_LEASE_SECTION_ID = NATIVE_LEASE_SECTION_ID;
40996
- exports.NATIVE_LEASE_TTL_FIELD = NATIVE_LEASE_TTL_FIELD;
40997
- exports.NATIVE_LEASE_TTL_KEY = NATIVE_LEASE_TTL_KEY;
41658
+ exports.NATIVE_LEASE_TILE_BUDGET_FIELD = NATIVE_LEASE_TILE_BUDGET_FIELD;
41659
+ exports.NATIVE_LEASE_TILE_BUDGET_KEY = NATIVE_LEASE_TILE_BUDGET_KEY;
41660
+ exports.NC_ALARM_SYSTEM_EVENT_KINDS = NC_ALARM_SYSTEM_EVENT_KINDS;
41661
+ exports.NC_AUDIO_DBFS_FLOOR = NC_AUDIO_DBFS_FLOOR;
41662
+ exports.NC_AUTHORABLE_SYSTEM_EVENT_KINDS = NC_AUTHORABLE_SYSTEM_EVENT_KINDS;
40998
41663
  exports.NC_BASE_CONDITION_KEYS = NC_BASE_CONDITION_KEYS;
40999
41664
  exports.NC_CONDITION_CATALOG = NC_CONDITION_CATALOG;
41665
+ exports.NC_CONFIRM_DEFAULT_MAX_IMAGE_PX = NC_CONFIRM_DEFAULT_MAX_IMAGE_PX;
41666
+ exports.NC_CONFIRM_DEFAULT_TIMEOUT_MS = NC_CONFIRM_DEFAULT_TIMEOUT_MS;
41667
+ exports.NC_CONFIRM_MAX_TIMEOUT_MS = NC_CONFIRM_MAX_TIMEOUT_MS;
41668
+ exports.NC_CONFIRM_MIN_TIMEOUT_MS = NC_CONFIRM_MIN_TIMEOUT_MS;
41000
41669
  exports.NC_HISTORY_LIMIT_DEFAULT = NC_HISTORY_LIMIT_DEFAULT;
41001
41670
  exports.NC_HISTORY_LIMIT_MAX = NC_HISTORY_LIMIT_MAX;
41002
41671
  exports.NC_MAX_PER_TRACK_IMMEDIATE = NC_MAX_PER_TRACK_IMMEDIATE;
@@ -41015,8 +41684,13 @@ exports.NcAlarmConfigSchema = NcAlarmConfigSchema;
41015
41684
  exports.NcAlarmModeCoverageSchema = NcAlarmModeCoverageSchema;
41016
41685
  exports.NcAlarmSettingsPatchSchema = NcAlarmSettingsPatchSchema;
41017
41686
  exports.NcAlarmSettingsSchema = NcAlarmSettingsSchema;
41687
+ exports.NcAlarmSkipReasonSchema = NcAlarmSkipReasonSchema;
41688
+ exports.NcAlarmSkippedDeviceSchema = NcAlarmSkippedDeviceSchema;
41689
+ exports.NcAudioConditionSchema = NcAudioConditionSchema;
41018
41690
  exports.NcConditionDescriptorSchema = NcConditionDescriptorSchema;
41019
41691
  exports.NcConditionsSchema = NcConditionsSchema;
41692
+ exports.NcConfirmExpectSchema = NcConfirmExpectSchema;
41693
+ exports.NcConfirmSchema = NcConfirmSchema;
41020
41694
  exports.NcCrossingSchema = NcCrossingSchema;
41021
41695
  exports.NcDeliverySchema = NcDeliverySchema;
41022
41696
  exports.NcDeviceStateConditionSchema = NcDeviceStateConditionSchema;
@@ -41157,6 +41831,11 @@ exports.RecordingDeviceUsageSchema = RecordingDeviceUsageSchema;
41157
41831
  exports.RecordingLocationUsageSchema = RecordingLocationUsageSchema;
41158
41832
  exports.RecordingManifestSchema = RecordingManifestSchema;
41159
41833
  exports.RecordingRangeSchema = RecordingRangeSchema;
41834
+ exports.RecordingRebalanceInputSchema = RecordingRebalanceInputSchema;
41835
+ exports.RecordingRebalanceMoveSchema = RecordingRebalanceMoveSchema;
41836
+ exports.RecordingRebalancePlanSchema = RecordingRebalancePlanSchema;
41837
+ exports.RecordingRebalanceSkipReasonSchema = RecordingRebalanceSkipReasonSchema;
41838
+ exports.RecordingRebalanceSkipSchema = RecordingRebalanceSkipSchema;
41160
41839
  exports.RecordingRetentionSchema = RecordingRetentionSchema;
41161
41840
  exports.RecordingStatusSchema = RecordingStatusSchema;
41162
41841
  exports.RecordingStorageModeSchema = RecordingStorageModeSchema;
@@ -41286,6 +41965,7 @@ exports.SwitchStatusSchema = SwitchStatusSchema;
41286
41965
  exports.SystemMetricsSchema = SystemMetricsSchema;
41287
41966
  exports.SystemMirror = SystemMirror;
41288
41967
  exports.TAXONOMY_COLORS = TAXONOMY_COLORS;
41968
+ exports.TIMELAPSE_DENSE_FLOOR_SEC = TIMELAPSE_DENSE_FLOOR_SEC;
41289
41969
  exports.TIMEZONES = TIMEZONES;
41290
41970
  exports.TRANSCODE_DOWN_MAX_BITRATE_KBPS = TRANSCODE_DOWN_MAX_BITRATE_KBPS;
41291
41971
  exports.TRANSCODE_DOWN_MAX_HEIGHT = TRANSCODE_DOWN_MAX_HEIGHT;
@@ -41400,6 +42080,7 @@ exports.asJsonArray = require_sleep.asJsonArray;
41400
42080
  exports.asJsonObject = require_sleep.asJsonObject;
41401
42081
  exports.asNumber = require_sleep.asNumber;
41402
42082
  exports.asString = require_sleep.asString;
42083
+ exports.assertTimelapseCadences = assertTimelapseCadences;
41403
42084
  exports.audioAnalysisCapability = audioAnalysisCapability;
41404
42085
  exports.audioAnalyzerCapability = audioAnalyzerCapability;
41405
42086
  exports.audioCodecCapability = audioCodecCapability;
@@ -41547,6 +42228,7 @@ exports.isDeployableToAgent = isDeployableToAgent;
41547
42228
  exports.isDeviceConfigCap = require_sleep.isDeviceConfigCap;
41548
42229
  exports.isDeviceScopedCap = require_sleep.isDeviceScopedCap;
41549
42230
  exports.isEvent = require_sleep.isEvent;
42231
+ exports.isIsolatedBuiltin = isIsolatedBuiltin;
41550
42232
  exports.isNode = isNode;
41551
42233
  exports.isObjectInput = isObjectInput;
41552
42234
  exports.isSameAddonId = isSameAddonId;