@camstack/addon-terminal 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +745 -52
  2. package/dist/addon.mjs +745 -52
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -7024,6 +7024,18 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7024
7024
  action: string().min(1),
7025
7025
  input: unknown()
7026
7026
  }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
7027
+ //#endregion
7028
+ //#region ../types/dist/err-msg-IQTHeDzc.mjs
7029
+ /**
7030
+ import { errMsg } from '@camstack/types'
7031
+ * Extract a human-readable message from an unknown error value.
7032
+ * Replaces the ubiquitous `errMsg(err)` pattern.
7033
+ */
7034
+ function errMsg(err) {
7035
+ if (err instanceof Error) return err.message;
7036
+ if (typeof err === "string") return err;
7037
+ return String(err);
7038
+ }
7027
7039
  var EncodeProfileSchema = object({
7028
7040
  video: object({
7029
7041
  codec: _enum([
@@ -7261,8 +7273,31 @@ var AdoptionJobSchema = object({
7261
7273
  error: string().nullable()
7262
7274
  });
7263
7275
  /**
7264
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7265
- * pipeline functions an operator thinks in terms of.
7276
+ * Per-camera FUNCTION SWITCHES.
7277
+ *
7278
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7279
+ *
7280
+ * This file shipped as "the one coherent on/off surface over the pipeline
7281
+ * functions an operator thinks in terms of". The operator's verdict on
7282
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7283
+ * every function already had a settings page of its own, and a second place to
7284
+ * turn it off is a second place to look. Each switch is going back to its own
7285
+ * component's original options — detection to the detection-pipeline wrapper
7286
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7287
+ * (which was always first-class; the switch was a veneer over
7288
+ * `recording.setDeviceConfig`), notifications to a notification-center
7289
+ * per-device setting, the two camera planes to their own components.
7290
+ *
7291
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7292
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7293
+ * straight from the authorities with no group in the middle. That rule was
7294
+ * never about a control panel.
7295
+ *
7296
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7297
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7298
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7299
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7300
+ * stop; nothing new may be built on it.
7266
7301
  *
7267
7302
  * ## This file adds no state
7268
7303
  *
@@ -7424,6 +7459,14 @@ var CameraSwitchGroupSchema = object({
7424
7459
  fetchedAt: number()
7425
7460
  });
7426
7461
  /**
7462
+ * The wrapper capability each wrapper-backed switch controls. Named constants
7463
+ * because the same strings appear in `legacy-migrations.ts`, in
7464
+ * `isCapActiveForDevice` call sites and in the fake harness — a typo in any of
7465
+ * them is a switch that silently writes a binding nobody reads.
7466
+ */
7467
+ var DETECTION_PIPELINE_CAP_NAME = "detection-pipeline";
7468
+ var AUDIO_ANALYSIS_CAP_NAME = "audio-analysis";
7469
+ /**
7427
7470
  * Ops-log — the durable, append-only operations audit shared by the
7428
7471
  * recordings and events management surfaces.
7429
7472
  *
@@ -7613,7 +7656,15 @@ var RecordingConfigSchema = object({
7613
7656
  * Each completed/failed run also lands one durable ops-log row on its owning
7614
7657
  * addon surface.
7615
7658
  */
7659
+ /**
7660
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7661
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7662
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7663
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7664
+ * runs at all.
7665
+ */
7616
7666
  var RelocateJobStateSchema = _enum([
7667
+ "queued",
7617
7668
  "running",
7618
7669
  "done",
7619
7670
  "failed",
@@ -7648,6 +7699,15 @@ var RelocateFootageInputSchema = object({
7648
7699
  /** Limits relocation to the logical profile class. Omit only for the
7649
7700
  * pre-orchestration compatibility path. */
7650
7701
  footageClass: RelocateFootageClassSchema.optional(),
7702
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7703
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7704
+ * unit is a (camera, profile) pile, not a disk. */
7705
+ deviceId: number().int().optional(),
7706
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7707
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7708
+ * placement plan assigns those two independently, so a rebalance that could
7709
+ * only say "recordings" would move footage the plan never asked to move. */
7710
+ profiles: array(string()).optional(),
7651
7711
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7652
7712
  * never allowed to starve live writers. */
7653
7713
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7783,6 +7843,21 @@ var StorageLocationSchema = object({
7783
7843
  nodeId: string().optional(),
7784
7844
  isDefault: boolean().default(false),
7785
7845
  isSystem: boolean().default(false),
7846
+ /**
7847
+ * Operator opt-in: whether consumers that BALANCE across several locations
7848
+ * of a type may write here. Recordings reads it today; event media and
7849
+ * backups are the next consumers, which is why the flag lives on the
7850
+ * location rather than in any one addon's store — nothing has to be
7851
+ * extended to add the next consumer.
7852
+ *
7853
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7854
+ * flag existed reads back with no flag and keeps working exactly as before;
7855
+ * that is the whole compat story, and it is why no migration ships with it.
7856
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7857
+ * disk must not silently start writing to it); the default of a type is
7858
+ * always stamped `true`.
7859
+ */
7860
+ enabled: boolean().optional(),
7786
7861
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7787
7862
  * for node-local locations it can reach) — never persisted, absent when the
7788
7863
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12280,7 +12355,8 @@ method(object({
12280
12355
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12281
12356
  /**
12282
12357
  * filesystem-browse — per-node capability for browsing the node's local
12283
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12358
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12359
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12284
12360
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12285
12361
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12286
12362
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14121,6 +14197,13 @@ var MaskGridDimsSchema = object({
14121
14197
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14122
14198
  * this one field keeps the schema additive — a rule still declares exactly
14123
14199
  * one trigger.
14200
+ *
14201
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14202
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14203
+ * mirror.ts` fails the build on a member the app cannot render) and every
14204
+ * member costs a release train. A sustained-sound rule is therefore an
14205
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14206
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14124
14207
  */
14125
14208
  var NcDeliverySchema = _enum([
14126
14209
  "immediate",
@@ -14135,15 +14218,32 @@ var NcDeliverySchema = _enum([
14135
14218
  * depend on a provider's raw event name or payload shape.
14136
14219
  */
14137
14220
  var NcSystemEventKindSchema = _enum([
14138
- "camera-online",
14139
- "camera-offline",
14221
+ "device-online",
14222
+ "device-offline",
14223
+ "device-disabled",
14224
+ "device-enabled",
14140
14225
  "stream-online",
14141
14226
  "stream-offline",
14142
14227
  "node-online",
14143
14228
  "node-offline",
14144
14229
  "addon-update-available",
14145
- "server-update-available"
14230
+ "server-update-available",
14231
+ "alarm-triggered",
14232
+ "alarm-armed",
14233
+ "alarm-disarmed",
14234
+ "camera-online",
14235
+ "camera-offline",
14236
+ "camera-disabled",
14237
+ "camera-enabled"
14146
14238
  ]);
14239
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14240
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14241
+ "camera-online",
14242
+ "camera-offline",
14243
+ "camera-disabled",
14244
+ "camera-enabled"
14245
+ ]);
14246
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14147
14247
  /**
14148
14248
  * One coherent system-event condition. `kinds` is the required opt-in safety
14149
14249
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14152,6 +14252,18 @@ var NcSystemEventKindSchema = _enum([
14152
14252
  var NcSystemEventConditionSchema = object({
14153
14253
  kinds: array(NcSystemEventKindSchema).min(1),
14154
14254
  deviceIds: array(number().int()).min(1).optional(),
14255
+ /**
14256
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14257
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14258
+ * is what a liveness rule means when nobody said otherwise.
14259
+ *
14260
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14261
+ * one reason: the intake cannot know which devices this household cares
14262
+ * about, and a producer-side filter is one no operator can change. Fails
14263
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14264
+ * does not carry) matches no `deviceTypes` list.
14265
+ */
14266
+ deviceTypes: array(string().min(1)).min(1).optional(),
14155
14267
  nodeIds: array(string().min(1)).min(1).optional(),
14156
14268
  packageNames: array(string().min(1)).min(1).optional()
14157
14269
  });
@@ -14202,6 +14314,47 @@ var NcOccupancyConditionSchema = object({
14202
14314
  sustainSeconds: number().int().min(0).max(3600).default(15)
14203
14315
  });
14204
14316
  /**
14317
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14318
+ *
14319
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14320
+ * reference notifier uses, so an operator moving between them re-uses what
14321
+ * they already know): a rule matches when, over a sampling window of
14322
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14323
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14324
+ *
14325
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14326
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14327
+ * - `labels` — the classifier put at least one of these labels on it.
14328
+ *
14329
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14330
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14331
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14332
+ * is given** — a window in which every sample is trivially a hit would fire on
14333
+ * silence, so the engine refuses such a condition rather than notifying on
14334
+ * nothing (the schema cannot express "at least one of" without becoming a
14335
+ * ZodEffects the cap path would have to special-case).
14336
+ *
14337
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14338
+ * must be FULL before it can match — a window that has been open for two
14339
+ * seconds of its ten is 100% of nothing, and firing on it would make
14340
+ * `samplingSeconds` decorative.
14341
+ *
14342
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14343
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14344
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14345
+ * an operator who typed `dog` mean the same thing.
14346
+ */
14347
+ var NcAudioConditionSchema = object({
14348
+ /** Audio macro labels; absent = any sound (level-only rule). */
14349
+ labels: array(string().min(1)).min(1).optional(),
14350
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14351
+ dbThreshold: number().min(-96).max(0).optional(),
14352
+ /** Percentage of the window's samples that must be hits (1–100). */
14353
+ hitPercent: number().int().min(1).max(100).default(60),
14354
+ /** Length of the sampling window in seconds. */
14355
+ samplingSeconds: number().int().min(1).max(300).default(10)
14356
+ });
14357
+ /**
14205
14358
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14206
14359
  *
14207
14360
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14474,7 +14627,33 @@ var NcConditionsSchema = object({
14474
14627
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14475
14628
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14476
14629
  */
14477
- occupancy: NcOccupancyConditionSchema.optional()
14630
+ occupancy: NcOccupancyConditionSchema.optional(),
14631
+ /**
14632
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14633
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14634
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14635
+ * a window that is not full yet, neither filter given). See
14636
+ * {@link NcAudioCondition}.
14637
+ *
14638
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14639
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14640
+ * a detection, a track or a device event (the same fail-closed pairing
14641
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14642
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14643
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14644
+ * classified sample) stays exactly as it was for rules that already use it.
14645
+ *
14646
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14647
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14648
+ * (`camstack/src/data/notification-center.ts`, guarded by
14649
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14650
+ * condition fields it does not know when a rule is saved from the phone.
14651
+ * Publishing an editor for a condition the app cannot round-trip is how an
14652
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14653
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14654
+ * does an audio rule become authorable.
14655
+ */
14656
+ audio: NcAudioConditionSchema.optional()
14478
14657
  });
14479
14658
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14480
14659
  var NcRuleTargetSchema = object({
@@ -14588,6 +14767,73 @@ var NcThrottleSchema = object({
14588
14767
  */
14589
14768
  granularity: NcThrottleGranularitySchema.optional()
14590
14769
  });
14770
+ /**
14771
+ * How long the confirm gate may hold ONE notification, and how big the picture
14772
+ * it judges may be.
14773
+ *
14774
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14775
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14776
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14777
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14778
+ * tokens for pixels the model pools away.
14779
+ */
14780
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14781
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14782
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14783
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14784
+ var NcConfirmExpectSchema = object({
14785
+ op: _enum([
14786
+ ">=",
14787
+ ">",
14788
+ "<=",
14789
+ "<",
14790
+ "=="
14791
+ ]),
14792
+ count: number().int().min(0).max(1e3)
14793
+ });
14794
+ /**
14795
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14796
+ * to ship and says whether it agrees with the rule.
14797
+ *
14798
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14799
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14800
+ * on the operator's phone is not a verdict about this notification.
14801
+ *
14802
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14803
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14804
+ * the default and every fail-open is COUNTED, because a gate that always fails
14805
+ * open looks in the log exactly like a gate that works.
14806
+ *
14807
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14808
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14809
+ * production failures in one day), so the gate reads absent as the constant
14810
+ * above rather than trusting a parse it may never have seen.
14811
+ */
14812
+ var NcConfirmSchema = object({
14813
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14814
+ * same thing, and both mean "deliver exactly as before". */
14815
+ enabled: boolean().default(false),
14816
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14817
+ profileId: string().optional(),
14818
+ /**
14819
+ * The operator's question, in his own words. Absent = a question derived
14820
+ * from the rule (its class and its expectation).
14821
+ *
14822
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14823
+ * banners, signage and plates as instructions if you let them reach the
14824
+ * prompt — proven live — so the authoritative contract stays in the system
14825
+ * turn and only rule-authored words land here.
14826
+ */
14827
+ prompt: string().max(1e3).optional(),
14828
+ /** Fire only when the model's count satisfies this. Absent = the model's
14829
+ * own boolean verdict decides. */
14830
+ expect: NcConfirmExpectSchema.optional(),
14831
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14832
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14833
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14834
+ /** Longest edge the judged image is downscaled to before it is sent. */
14835
+ maxImagePx: number().int().min(64).max(2048).default(448)
14836
+ });
14591
14837
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14592
14838
  var NcRuleInputSchema = object({
14593
14839
  name: string().min(1).max(200),
@@ -14648,7 +14894,13 @@ var NcRuleInputSchema = object({
14648
14894
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14649
14895
  * shape as every other actuation.
14650
14896
  */
14651
- actions: NcRuleActionsSchema.optional()
14897
+ actions: NcRuleActionsSchema.optional(),
14898
+ /**
14899
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14900
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14901
+ * did, and absent is the only way to say that without a migration.
14902
+ */
14903
+ confirm: NcConfirmSchema.optional()
14652
14904
  });
14653
14905
  /**
14654
14906
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14659,7 +14911,37 @@ var NcRuleInputSchema = object({
14659
14911
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14660
14912
  * `updateRule` patch.
14661
14913
  */
14662
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14914
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14915
+ disabledTargetIds: array(string()).optional(),
14916
+ /**
14917
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14918
+ *
14919
+ * It makes the key optional to SUPPLY; the parse still materialises the
14920
+ * default when the key is absent. And `NcRuleStore.update` merges with
14921
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14922
+ * one — which made every partial edit destructive:
14923
+ *
14924
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14925
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14926
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14927
+ *
14928
+ * A rule scoped to one camera and one zone silently became a rule that
14929
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14930
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14931
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14932
+ * within a minute of a two-field patch.
14933
+ *
14934
+ * So every defaulted field is re-declared here WITHOUT its default. The
14935
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14936
+ * conditions remains a real instruction ("clear them") — and only the
14937
+ * absent key is now genuinely absent.
14938
+ */
14939
+ enabled: boolean().optional(),
14940
+ conditions: NcConditionsSchema.optional(),
14941
+ media: NcMediaPolicySchema.optional(),
14942
+ throttle: NcThrottleSchema.optional(),
14943
+ priority: number().int().min(1).max(5).optional()
14944
+ });
14663
14945
  /** A persisted rule. */
14664
14946
  var NcRuleSchema = NcRuleInputSchema.extend({
14665
14947
  id: string(),
@@ -14960,6 +15242,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14960
15242
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14961
15243
  * copy would lie the first time a rule is disabled.
14962
15244
  */
15245
+ /**
15246
+ * Why a device a mode NAMES is nonetheless not armed by it.
15247
+ *
15248
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15249
+ * per-camera notification switch the Notification Center already owns,
15250
+ * `detection-off` is the device's own detection binding being inactive, and
15251
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15252
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15253
+ * with the switches the operator actually used.
15254
+ */
15255
+ var NcAlarmSkipReasonSchema = _enum([
15256
+ "muted",
15257
+ "detection-off",
15258
+ "offline"
15259
+ ]);
15260
+ var NcAlarmSkippedDeviceSchema = object({
15261
+ deviceId: number().int(),
15262
+ reason: NcAlarmSkipReasonSchema
15263
+ });
14963
15264
  var NcAlarmModeCoverageSchema = object({
14964
15265
  mode: AlarmArmModeSchema,
14965
15266
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14967,7 +15268,18 @@ var NcAlarmModeCoverageSchema = object({
14967
15268
  /** At least one covering rule has no device scope, so the mode covers all. */
14968
15269
  allDevices: boolean(),
14969
15270
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14970
- deviceIds: array(number().int())
15271
+ deviceIds: array(number().int()),
15272
+ /**
15273
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15274
+ * excludes it.
15275
+ *
15276
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15277
+ * twelve makes it false in exactly the way nobody notices until an incident.
15278
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15279
+ * still parses as "nothing known to be skipped" rather than failing the whole
15280
+ * alarm tab.
15281
+ */
15282
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14971
15283
  });
14972
15284
  var NcAlarmConfigSchema = object({
14973
15285
  /**
@@ -17799,9 +18111,16 @@ var CameraStatusSchema = object({
17799
18111
  audio: CameraAudioStatusSchema.nullable(),
17800
18112
  recording: CameraRecordingStatusSchema.nullable(),
17801
18113
  /**
17802
- * Per-camera function switches an OPERATOR has turned off
18114
+ * Per-camera functions an OPERATOR has turned off
17803
18115
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17804
18116
  *
18117
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18118
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18119
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18120
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18121
+ * The badge outlives the control panel: the panel was a convenience, this is
18122
+ * the difference between a camera being off and a camera being dead.
18123
+ *
17805
18124
  * This is the difference between DISABLED and BROKEN. A camera whose
17806
18125
  * `detection` block reports zero fps and whose `switchedOff` contains
17807
18126
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -24681,7 +25000,19 @@ var RecordingManifestSchema = object({
24681
25000
  * profiles/subtrees/locations on this node). */
24682
25001
  var RecordingDeviceUsageSchema = object({
24683
25002
  deviceId: number(),
24684
- usedBytes: number()
25003
+ usedBytes: number(),
25004
+ /**
25005
+ * Start of this camera's OLDEST indexed segment, across every profile and
25006
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25007
+ * only honest answer to "is retention actually holding?" per camera.
25008
+ *
25009
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25010
+ * predates this field omits it entirely, and a hub whose types carry the
25011
+ * field must keep validating that older provider's payload: the framework
25012
+ * (types) and the addon ship on different trains, and the addon is usually
25013
+ * the later of the two.
25014
+ */
25015
+ oldestMs: number().nullable().optional()
24685
25016
  });
24686
25017
  /** Recording storage usage + capacity for one storage location. */
24687
25018
  var RecordingLocationUsageSchema = object({
@@ -24709,6 +25040,57 @@ var RecordingStorageUsageSchema = object({
24709
25040
  locations: array(RecordingLocationUsageSchema)
24710
25041
  });
24711
25042
  /**
25043
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25044
+ *
25045
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25046
+ * is the operator asking for the EXISTING archive to be brought into line with
25047
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25048
+ * location, run FIFO behind the single-flight mover.
25049
+ *
25050
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25051
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25052
+ * (empty on the plan).
25053
+ */
25054
+ var RecordingRebalanceMoveSchema = object({
25055
+ deviceId: number(),
25056
+ profile: string(),
25057
+ fromLocationId: string(),
25058
+ toLocationId: string(),
25059
+ bytes: number(),
25060
+ files: number().int()
25061
+ });
25062
+ /** Why a pile that is out of place is staying there. Every refusal is
25063
+ * reported: a rebalance that silently drops a camera reads exactly like one
25064
+ * that had nothing to do. */
25065
+ var RecordingRebalanceSkipReasonSchema = _enum([
25066
+ "unassigned",
25067
+ "target-not-writable",
25068
+ "below-threshold",
25069
+ "no-headroom"
25070
+ ]);
25071
+ var RecordingRebalanceSkipSchema = object({
25072
+ deviceId: number(),
25073
+ profile: string(),
25074
+ fromLocationId: string(),
25075
+ /** The location the plan wants; null when the camera has no assignment. */
25076
+ toLocationId: string().nullable(),
25077
+ bytes: number(),
25078
+ reason: RecordingRebalanceSkipReasonSchema
25079
+ });
25080
+ var RecordingRebalancePlanSchema = object({
25081
+ moves: array(RecordingRebalanceMoveSchema),
25082
+ skipped: array(RecordingRebalanceSkipSchema),
25083
+ bytesToMove: number(),
25084
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25085
+ jobIds: array(string())
25086
+ });
25087
+ var RecordingRebalanceInputSchema = object({
25088
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25089
+ throttleMbps: number().min(1).max(1e3).optional(),
25090
+ /** Ignore piles smaller than this (default 1 GB). */
25091
+ minMoveGb: number().min(0).optional()
25092
+ });
25093
+ /**
24712
25094
  * Result of locating footage at a wall-clock instant for one device/profile.
24713
25095
  * `segment` carries the covering segment's window; `gap` reports the forward
24714
25096
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -24871,9 +25253,24 @@ method(object({
24871
25253
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24872
25254
  kind: "mutation",
24873
25255
  auth: "admin"
25256
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25257
+ kind: "mutation",
25258
+ auth: "admin"
25259
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25260
+ kind: "query",
25261
+ auth: "admin"
25262
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25263
+ kind: "mutation",
25264
+ auth: "admin"
25265
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25266
+ kind: "query",
25267
+ auth: "admin"
25268
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25269
+ kind: "mutation",
25270
+ auth: "admin"
24874
25271
  });
24875
25272
  /**
24876
- * `recordingExport` cap — render a footage time range into a single downloadable
25273
+ * `recording-export` cap — render a footage time range into a single downloadable
24877
25274
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
24878
25275
  * bounded lifetime with a durable history, auto-expiry, and optional
24879
25276
  * delete-after-download.
@@ -24888,10 +25285,42 @@ method(object({
24888
25285
  */
24889
25286
  /** Playback-speed multiplier for the render (1 = realtime). */
24890
25287
  var ExportSpeedSchema = number().min(.25).max(32);
25288
+ /**
25289
+ * One dense interval, in SECONDS FROM THE EXPORT'S OWN `fromMs`.
25290
+ *
25291
+ * Relative and not absolute epoch on purpose: the renderer's frame-select
25292
+ * expression sees ffmpeg's `t`, which starts at 0 for the export's source
25293
+ * playlist. Handing it absolute epochs would make every call site responsible
25294
+ * for the same subtraction, and the one that forgot would emit a filter that
25295
+ * selects nothing — silently, as a uniform timelapse.
25296
+ */
25297
+ var ExportDenseRangeSchema = object({
25298
+ fromSec: number().nonnegative(),
25299
+ toSec: number().nonnegative()
25300
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25301
+ /**
25302
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25303
+ * listed ranges and at the base `everyMs` everywhere else.
25304
+ *
25305
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25306
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25307
+ */
25308
+ var ExportDenseSchema = object({
25309
+ everyMs: number().int().positive(),
25310
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25311
+ });
24891
25312
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
24892
25313
  var ExportTimelapseSchema = object({
24893
25314
  everyMs: number().int().positive(),
24894
- outputFps: number().int().min(1).max(60).optional()
25315
+ outputFps: number().int().min(1).max(60).optional(),
25316
+ /** Optional second, FASTER rate over the intervals that matter. */
25317
+ dense: ExportDenseSchema.optional()
25318
+ }).superRefine((v, ctx) => {
25319
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25320
+ code: ZodIssueCode.custom,
25321
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25322
+ path: ["dense", "everyMs"]
25323
+ });
24895
25324
  });
24896
25325
  /**
24897
25326
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -24949,6 +25378,19 @@ var ExportDownloadSchema = object({
24949
25378
  url: string(),
24950
25379
  endpoints: array(string())
24951
25380
  });
25381
+ /**
25382
+ * A finished export's bytes, inline.
25383
+ *
25384
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25385
+ * against, so nobody has to infer it from the base64 length.
25386
+ */
25387
+ var ExportBytesSchema = object({
25388
+ base64: string(),
25389
+ contentType: string(),
25390
+ /** Suggested filename, extension included. */
25391
+ name: string(),
25392
+ bytes: number().int().nonnegative()
25393
+ });
24952
25394
  method(object({
24953
25395
  deviceId: number(),
24954
25396
  profile: string(),
@@ -24973,6 +25415,9 @@ method(object({
24973
25415
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
24974
25416
  kind: "query",
24975
25417
  auth: "protected"
25418
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25419
+ kind: "query",
25420
+ auth: "protected"
24976
25421
  });
24977
25422
  /**
24978
25423
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -31662,6 +32107,12 @@ Object.freeze({
31662
32107
  addonId: null,
31663
32108
  access: "create"
31664
32109
  },
32110
+ "recording.cancelRelocateJob": {
32111
+ capName: "recording",
32112
+ capScope: "system",
32113
+ addonId: null,
32114
+ access: "create"
32115
+ },
31665
32116
  "recording.cancelStorageMigrationMove": {
31666
32117
  capName: "recording",
31667
32118
  capScope: "system",
@@ -31716,6 +32167,12 @@ Object.freeze({
31716
32167
  addonId: null,
31717
32168
  access: "view"
31718
32169
  },
32170
+ "recording.listRelocateJobs": {
32171
+ capName: "recording",
32172
+ capScope: "system",
32173
+ addonId: null,
32174
+ access: "view"
32175
+ },
31719
32176
  "recording.locateSegment": {
31720
32177
  capName: "recording",
31721
32178
  capScope: "system",
@@ -31728,6 +32185,12 @@ Object.freeze({
31728
32185
  addonId: null,
31729
32186
  access: "create"
31730
32187
  },
32188
+ "recording.planStorageRebalance": {
32189
+ capName: "recording",
32190
+ capScope: "system",
32191
+ addonId: null,
32192
+ access: "view"
32193
+ },
31731
32194
  "recording.pruneFootage": {
31732
32195
  capName: "recording",
31733
32196
  capScope: "system",
@@ -31752,6 +32215,12 @@ Object.freeze({
31752
32215
  addonId: null,
31753
32216
  access: "create"
31754
32217
  },
32218
+ "recording.relocateFootage": {
32219
+ capName: "recording",
32220
+ capScope: "system",
32221
+ addonId: null,
32222
+ access: "create"
32223
+ },
31755
32224
  "recording.renderClip": {
31756
32225
  capName: "recording",
31757
32226
  capScope: "system",
@@ -31788,38 +32257,50 @@ Object.freeze({
31788
32257
  addonId: null,
31789
32258
  access: "create"
31790
32259
  },
32260
+ "recording.startStorageRebalance": {
32261
+ capName: "recording",
32262
+ capScope: "system",
32263
+ addonId: null,
32264
+ access: "create"
32265
+ },
31791
32266
  "recordingExport.cancelExport": {
31792
- capName: "recordingExport",
32267
+ capName: "recording-export",
31793
32268
  capScope: "system",
31794
32269
  addonId: null,
31795
32270
  access: "create"
31796
32271
  },
31797
32272
  "recordingExport.createExport": {
31798
- capName: "recordingExport",
32273
+ capName: "recording-export",
31799
32274
  capScope: "system",
31800
32275
  addonId: null,
31801
32276
  access: "create"
31802
32277
  },
31803
32278
  "recordingExport.deleteExport": {
31804
- capName: "recordingExport",
32279
+ capName: "recording-export",
31805
32280
  capScope: "system",
31806
32281
  addonId: null,
31807
32282
  access: "delete"
31808
32283
  },
31809
32284
  "recordingExport.getDownloadUrl": {
31810
- capName: "recordingExport",
32285
+ capName: "recording-export",
31811
32286
  capScope: "system",
31812
32287
  addonId: null,
31813
32288
  access: "view"
31814
32289
  },
31815
32290
  "recordingExport.getExport": {
31816
- capName: "recordingExport",
32291
+ capName: "recording-export",
31817
32292
  capScope: "system",
31818
32293
  addonId: null,
31819
32294
  access: "view"
31820
32295
  },
31821
32296
  "recordingExport.listExports": {
31822
- capName: "recordingExport",
32297
+ capName: "recording-export",
32298
+ capScope: "system",
32299
+ addonId: null,
32300
+ access: "view"
32301
+ },
32302
+ "recordingExport.readExportBytes": {
32303
+ capName: "recording-export",
31823
32304
  capScope: "system",
31824
32305
  addonId: null,
31825
32306
  access: "view"
@@ -33196,6 +33677,104 @@ var FramerateField = number().int().min(1).max(60);
33196
33677
  var TargetsField = array(NcRuleTargetSchema).min(1);
33197
33678
  var PriorityField = number().int().min(1).max(5);
33198
33679
  /**
33680
+ * Explicit override of the DENSE sampling cadence, seconds.
33681
+ *
33682
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
33683
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
33684
+ * made that same base 3 s and rendered a person pass as two frames.)
33685
+ *
33686
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
33687
+ * `denseCadenceSec` and played at `framerate` occupies
33688
+ *
33689
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
33690
+ *
33691
+ * 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.
33692
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
33693
+ * and therefore the length of a quiet night, does not move.
33694
+ *
33695
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
33696
+ * the recording has them returns the same frames, requested twice. Must be
33697
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
33698
+ * a uniform video the operator believes is two-rate — and upsert refuses it
33699
+ * rather than letting the export cap reject the render hours after the window.
33700
+ */
33701
+ var DenseCadenceSecField = number().min(.1).max(3600);
33702
+ /**
33703
+ * Minimum seconds of OUTPUT video each detection range must occupy.
33704
+ *
33705
+ * The operator-facing form of the arithmetic above: instead of solving for a
33706
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
33707
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
33708
+ * that range every ~583 ms.
33709
+ *
33710
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
33711
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
33712
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
33713
+ * ranges are sampled denser than they need. Per-range cadences require a cap
33714
+ * schema change and are the tracked follow-up.
33715
+ *
33716
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
33717
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
33718
+ * by real footage, never met by duplicating frames into motion that never
33719
+ * happened.
33720
+ */
33721
+ var MinDwellSecField = number().min(0).max(60);
33722
+ /**
33723
+ * Caption burned into the notification's preview frame.
33724
+ *
33725
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
33726
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
33727
+ * templating dialect for one field would be a second thing to explain.
33728
+ *
33729
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
33730
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
33731
+ * the reason this is not `.min(1)`.
33732
+ */
33733
+ var PreviewTextField = string().max(200);
33734
+ /**
33735
+ * Whether the notification's preview is a STILL or a short animation.
33736
+ *
33737
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
33738
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
33739
+ * night reads better as three seconds of motion than as one frame of it. Both
33740
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
33741
+ * simply applies it to a dozen frames sampled across the render and assembles
33742
+ * them.
33743
+ *
33744
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
33745
+ * seeks and a palette pass, and no rule that never asked for one should start
33746
+ * paying that on the deploy that shipped it.
33747
+ *
33748
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
33749
+ */
33750
+ var PreviewModeField = _enum(["image", "gif"]);
33751
+ /**
33752
+ * Which detection classes the notification reports counts for.
33753
+ *
33754
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
33755
+ * plan — no second query — aggregated per class. Absent or empty means "every
33756
+ * class the window actually contained", which is what an operator who never
33757
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
33758
+ * counts cars all night).
33759
+ *
33760
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
33761
+ * …). An unknown name simply never matches and reports nothing — it is not an
33762
+ * error, because a rule may legitimately name a class this camera's model does
33763
+ * not emit.
33764
+ *
33765
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
33766
+ * - `{{detections}}` — total over the reported classes
33767
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
33768
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
33769
+ * one per class, `count_` + the class name
33770
+ *
33771
+ * With NO custom body template the summary is appended to the derived body, and
33772
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
33773
+ * reads. With a custom template the operator owns every word — nothing is
33774
+ * appended, so `{{detectionSummary}}` is how he asks for it.
33775
+ */
33776
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
33777
+ /**
33199
33778
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33200
33779
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33201
33780
  * here (see the ownership note above).
@@ -33215,9 +33794,30 @@ var TimelapseRuleInputSchema = object({
33215
33794
  cadenceSec: CadenceSecField.default(15),
33216
33795
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33217
33796
  framerate: FramerateField.default(10),
33797
+ /**
33798
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
33799
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
33800
+ * field gets.
33801
+ */
33802
+ denseCadenceSec: DenseCadenceSecField.optional(),
33803
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
33804
+ minDwellSec: MinDwellSecField.optional(),
33218
33805
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33219
33806
  targets: TargetsField,
33220
33807
  template: TimelapseTemplateSchema.optional(),
33808
+ /**
33809
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
33810
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
33811
+ *
33812
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
33813
+ * the notification's title/body, and clearing it (`template: null`) must not
33814
+ * silently clear the caption too.
33815
+ */
33816
+ previewText: PreviewTextField.optional(),
33817
+ /** Still or animation — see {@link PreviewModeField}. */
33818
+ previewMode: PreviewModeField.default("image"),
33819
+ /** Classes the notification counts — see {@link ReportClassesField}. */
33820
+ reportClasses: ReportClassesField.optional(),
33221
33821
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33222
33822
  priority: PriorityField.default(3)
33223
33823
  });
@@ -33228,8 +33828,13 @@ object({
33228
33828
  schedule: NcScheduleSchema.optional(),
33229
33829
  cadenceSec: CadenceSecField.optional(),
33230
33830
  framerate: FramerateField.optional(),
33831
+ denseCadenceSec: DenseCadenceSecField.optional(),
33832
+ minDwellSec: MinDwellSecField.optional(),
33231
33833
  targets: TargetsField.optional(),
33232
33834
  template: TimelapseTemplateSchema.nullable().optional(),
33835
+ previewText: PreviewTextField.optional(),
33836
+ previewMode: PreviewModeField.optional(),
33837
+ reportClasses: ReportClassesField.optional(),
33233
33838
  priority: PriorityField.optional()
33234
33839
  });
33235
33840
  TimelapseRuleInputSchema.extend({
@@ -33241,10 +33846,28 @@ TimelapseRuleInputSchema.extend({
33241
33846
  */
33242
33847
  ownerUserId: string().optional(),
33243
33848
  /**
33244
- * Epoch-ms of the last successful generation the 1-hour re-generation
33245
- * guard's durable state (predecessor parity). Absent = never generated.
33849
+ * Epoch-ms of the NEWEST successful generation across every camera of this
33850
+ * rule. What a UI shows, and the compatibility floor for
33851
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33246
33852
  */
33247
33853
  lastGeneratedAt: number().optional(),
33854
+ /**
33855
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
33856
+ * re-generation guard's real durable state.
33857
+ *
33858
+ * One rule covers several cameras and each renders its own video, so a rule
33859
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
33860
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
33861
+ * already done — and B's night is gone for good, because the window will not
33862
+ * come back.
33863
+ *
33864
+ * ADDITIVE, so the migration is free: a row written before this field simply
33865
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
33866
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
33867
+ * "never generated" would re-render and re-notify every camera of every rule
33868
+ * once, on the deploy that shipped the map.
33869
+ */
33870
+ generatedByDevice: record(string(), number()).optional(),
33248
33871
  /** userId of the caller who created the rule (server-stamped). */
33249
33872
  createdBy: string(),
33250
33873
  createdAt: number(),
@@ -33493,6 +34116,91 @@ async function warmNodePty() {
33493
34116
  await loadNodePty();
33494
34117
  }
33495
34118
  //#endregion
34119
+ //#region src/silence-analysis.ts
34120
+ /**
34121
+ * Every analyzer a Terminal camera is created with switched OFF.
34122
+ *
34123
+ * `motion-detection` sits first deliberately: it is the one that holds the
34124
+ * decode session open, so it is the one whose absence is the difference between
34125
+ * a terminal costing a screen scrape and costing a decode pipeline.
34126
+ */
34127
+ var TERMINAL_SILENCED_CAP_NAMES = [
34128
+ "motion-detection",
34129
+ DETECTION_PIPELINE_CAP_NAME,
34130
+ AUDIO_ANALYSIS_CAP_NAME
34131
+ ];
34132
+ /**
34133
+ * Resolve the addon currently providing `capName` for this device.
34134
+ *
34135
+ * Inlined rather than reached for through a helper because there is exactly one
34136
+ * honest source: the device's own bindings. `listBindableCapsForDeviceType`
34137
+ * answers for the device TYPE and would happily name a wrapper that is not the
34138
+ * one bound here.
34139
+ *
34140
+ * Returns `null` when the cap is not bound at all — which is not an error: a
34141
+ * deployment with no audio analyzer has nothing to switch off, and demanding one
34142
+ * would make every terminal creation fail on a perfectly valid hub.
34143
+ */
34144
+ async function resolveBoundWrapper(api, deviceId, capName) {
34145
+ const bindings = await api.deviceManager.getBindings.query({ deviceId });
34146
+ for (const entry of bindings.entries) {
34147
+ if (entry.capName !== capName) continue;
34148
+ if (entry.kind !== "wrapped") continue;
34149
+ if (entry.providerAddonId === "") return null;
34150
+ return entry.providerAddonId;
34151
+ }
34152
+ return null;
34153
+ }
34154
+ /**
34155
+ * Switch every analyzer in {@link TERMINAL_SILENCED_CAP_NAMES} off for one
34156
+ * Terminal camera.
34157
+ *
34158
+ * Called ONLY on creation. An operator who deliberately turns detection back on
34159
+ * for a terminal must win, and a reconcile that re-asserted every pass would
34160
+ * silently overrule them once a minute.
34161
+ *
34162
+ * @throws if a cap IS bound and the write to its authority failed. The camera
34163
+ * would then be running a full analyzer for a screen recording, which is the
34164
+ * exact cost this exists to remove — and a silent version of that failure is
34165
+ * unfindable.
34166
+ */
34167
+ async function silenceAnalysisFor(deps, deviceId) {
34168
+ const failures = [];
34169
+ for (const capName of TERMINAL_SILENCED_CAP_NAMES) try {
34170
+ const wrapperAddonId = await resolveBoundWrapper(deps.api, deviceId, capName);
34171
+ if (wrapperAddonId === null) {
34172
+ deps.logger.debug("terminal camera: no analyzer bound for this capability", {
34173
+ tags: { deviceId },
34174
+ meta: { capName }
34175
+ });
34176
+ continue;
34177
+ }
34178
+ await deps.api.deviceManager.setWrapperActive.mutate({
34179
+ deviceId,
34180
+ capName,
34181
+ wrapperAddonId,
34182
+ active: false
34183
+ });
34184
+ deps.logger.info("terminal camera: analyzer switched off at its authority", {
34185
+ tags: { deviceId },
34186
+ meta: {
34187
+ capName,
34188
+ wrapperAddonId
34189
+ }
34190
+ });
34191
+ } catch (err) {
34192
+ failures.push(`${capName}: ${errMsg(err)}`);
34193
+ deps.logger.error("terminal camera: could NOT switch an analyzer off", {
34194
+ tags: { deviceId },
34195
+ meta: {
34196
+ capName,
34197
+ error: errMsg(err)
34198
+ }
34199
+ });
34200
+ }
34201
+ if (failures.length > 0) throw new Error(`terminal camera ${deviceId}: could not switch off ${failures.length} analyzer(s) — it will run at full detection cost (${failures.join("; ")})`);
34202
+ }
34203
+ //#endregion
33496
34204
  //#region src/terminal-camera-declarations.ts
33497
34205
  /**
33498
34206
  * Feed DeclaredDevices every live declaration plus one deterministic orphan
@@ -40026,37 +40734,22 @@ var TerminalAddon = class extends BaseAddon {
40026
40734
  }
40027
40735
  }
40028
40736
  /**
40029
- * A Terminal camera is a rendered screen. Object detection on it finds
40030
- * nothing, forever, at full cost.
40737
+ * A Terminal camera is a rendered screen. Every analyzer on it finds nothing,
40738
+ * forever, at full cost — see `silence-analysis.ts` for the measurements, the
40739
+ * reason `motion-detection` is in the list, and why a failure THROWS instead
40740
+ * of warning.
40031
40741
  *
40032
- * Measured on the hub 2026-08-11, for ONE terminal camera: 19 frames per 10 s
40033
- * through the detection pipeline at ~61 ms of inference each, plus 115
40034
- * capture-scheduler requests a minute against `detections=0`. Multiply by
40035
- * one terminal per node and it is a standing tax on a hub that was already
40036
- * shedding 86 % of its capture queue.
40037
- *
40038
- * Written through `setCameraSwitch`, which is the authority that already owns
40039
- * this function — [D62] forbids a second store that disagrees with it. And
40040
- * written ONLY on creation: an operator who deliberately turns detection back
40041
- * on for a terminal must win, and a reconcile that re-asserted every pass
40042
- * would silently overrule them once a minute.
40043
- */
40044
- async silenceAnalysisFor(deviceId) {
40045
- for (const switchId of ["object-detection", "audio-analysis"]) try {
40046
- await this.ctx.api.pipelineOrchestrator.setCameraSwitch.mutate({
40047
- deviceId,
40048
- switchId,
40049
- enabled: false
40050
- });
40051
- } catch (err) {
40052
- this.ctx.logger.warn("could not switch off analysis for a Terminal camera", {
40053
- tags: { deviceId },
40054
- meta: {
40055
- switchId,
40056
- error: err instanceof Error ? err.message : String(err)
40057
- }
40058
- });
40059
- }
40742
+ * Written to the AUTHORITIES (`deviceManager.setWrapperActive`), not through
40743
+ * the deprecated switch cap the previous version used (D113). Written ONLY on
40744
+ * creation: an operator who deliberately turns detection back on for a
40745
+ * terminal must win, and a reconcile that re-asserted every pass would
40746
+ * silently overrule them once a minute.
40747
+ */
40748
+ silenceAnalysisFor(deviceId) {
40749
+ return silenceAnalysisFor({
40750
+ api: this.ctx.api,
40751
+ logger: this.ctx.logger
40752
+ }, deviceId);
40060
40753
  }
40061
40754
  terminalInstanceControl() {
40062
40755
  return {