@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.js CHANGED
@@ -7047,6 +7047,18 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7047
7047
  action: string().min(1),
7048
7048
  input: unknown()
7049
7049
  }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
7050
+ //#endregion
7051
+ //#region ../types/dist/err-msg-IQTHeDzc.mjs
7052
+ /**
7053
+ import { errMsg } from '@camstack/types'
7054
+ * Extract a human-readable message from an unknown error value.
7055
+ * Replaces the ubiquitous `errMsg(err)` pattern.
7056
+ */
7057
+ function errMsg(err) {
7058
+ if (err instanceof Error) return err.message;
7059
+ if (typeof err === "string") return err;
7060
+ return String(err);
7061
+ }
7050
7062
  var EncodeProfileSchema = object({
7051
7063
  video: object({
7052
7064
  codec: _enum([
@@ -7284,8 +7296,31 @@ var AdoptionJobSchema = object({
7284
7296
  error: string().nullable()
7285
7297
  });
7286
7298
  /**
7287
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7288
- * pipeline functions an operator thinks in terms of.
7299
+ * Per-camera FUNCTION SWITCHES.
7300
+ *
7301
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7302
+ *
7303
+ * This file shipped as "the one coherent on/off surface over the pipeline
7304
+ * functions an operator thinks in terms of". The operator's verdict on
7305
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7306
+ * every function already had a settings page of its own, and a second place to
7307
+ * turn it off is a second place to look. Each switch is going back to its own
7308
+ * component's original options — detection to the detection-pipeline wrapper
7309
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7310
+ * (which was always first-class; the switch was a veneer over
7311
+ * `recording.setDeviceConfig`), notifications to a notification-center
7312
+ * per-device setting, the two camera planes to their own components.
7313
+ *
7314
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7315
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7316
+ * straight from the authorities with no group in the middle. That rule was
7317
+ * never about a control panel.
7318
+ *
7319
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7320
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7321
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7322
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7323
+ * stop; nothing new may be built on it.
7289
7324
  *
7290
7325
  * ## This file adds no state
7291
7326
  *
@@ -7447,6 +7482,14 @@ var CameraSwitchGroupSchema = object({
7447
7482
  fetchedAt: number()
7448
7483
  });
7449
7484
  /**
7485
+ * The wrapper capability each wrapper-backed switch controls. Named constants
7486
+ * because the same strings appear in `legacy-migrations.ts`, in
7487
+ * `isCapActiveForDevice` call sites and in the fake harness — a typo in any of
7488
+ * them is a switch that silently writes a binding nobody reads.
7489
+ */
7490
+ var DETECTION_PIPELINE_CAP_NAME = "detection-pipeline";
7491
+ var AUDIO_ANALYSIS_CAP_NAME = "audio-analysis";
7492
+ /**
7450
7493
  * Ops-log — the durable, append-only operations audit shared by the
7451
7494
  * recordings and events management surfaces.
7452
7495
  *
@@ -7636,7 +7679,15 @@ var RecordingConfigSchema = object({
7636
7679
  * Each completed/failed run also lands one durable ops-log row on its owning
7637
7680
  * addon surface.
7638
7681
  */
7682
+ /**
7683
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7684
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7685
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7686
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7687
+ * runs at all.
7688
+ */
7639
7689
  var RelocateJobStateSchema = _enum([
7690
+ "queued",
7640
7691
  "running",
7641
7692
  "done",
7642
7693
  "failed",
@@ -7671,6 +7722,15 @@ var RelocateFootageInputSchema = object({
7671
7722
  /** Limits relocation to the logical profile class. Omit only for the
7672
7723
  * pre-orchestration compatibility path. */
7673
7724
  footageClass: RelocateFootageClassSchema.optional(),
7725
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7726
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7727
+ * unit is a (camera, profile) pile, not a disk. */
7728
+ deviceId: number().int().optional(),
7729
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7730
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7731
+ * placement plan assigns those two independently, so a rebalance that could
7732
+ * only say "recordings" would move footage the plan never asked to move. */
7733
+ profiles: array(string()).optional(),
7674
7734
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7675
7735
  * never allowed to starve live writers. */
7676
7736
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7806,6 +7866,21 @@ var StorageLocationSchema = object({
7806
7866
  nodeId: string().optional(),
7807
7867
  isDefault: boolean().default(false),
7808
7868
  isSystem: boolean().default(false),
7869
+ /**
7870
+ * Operator opt-in: whether consumers that BALANCE across several locations
7871
+ * of a type may write here. Recordings reads it today; event media and
7872
+ * backups are the next consumers, which is why the flag lives on the
7873
+ * location rather than in any one addon's store — nothing has to be
7874
+ * extended to add the next consumer.
7875
+ *
7876
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7877
+ * flag existed reads back with no flag and keeps working exactly as before;
7878
+ * that is the whole compat story, and it is why no migration ships with it.
7879
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7880
+ * disk must not silently start writing to it); the default of a type is
7881
+ * always stamped `true`.
7882
+ */
7883
+ enabled: boolean().optional(),
7809
7884
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7810
7885
  * for node-local locations it can reach) — never persisted, absent when the
7811
7886
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12303,7 +12378,8 @@ method(object({
12303
12378
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12304
12379
  /**
12305
12380
  * filesystem-browse — per-node capability for browsing the node's local
12306
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12381
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12382
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12307
12383
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12308
12384
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12309
12385
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14144,6 +14220,13 @@ var MaskGridDimsSchema = object({
14144
14220
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14145
14221
  * this one field keeps the schema additive — a rule still declares exactly
14146
14222
  * one trigger.
14223
+ *
14224
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14225
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14226
+ * mirror.ts` fails the build on a member the app cannot render) and every
14227
+ * member costs a release train. A sustained-sound rule is therefore an
14228
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14229
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14147
14230
  */
14148
14231
  var NcDeliverySchema = _enum([
14149
14232
  "immediate",
@@ -14158,15 +14241,32 @@ var NcDeliverySchema = _enum([
14158
14241
  * depend on a provider's raw event name or payload shape.
14159
14242
  */
14160
14243
  var NcSystemEventKindSchema = _enum([
14161
- "camera-online",
14162
- "camera-offline",
14244
+ "device-online",
14245
+ "device-offline",
14246
+ "device-disabled",
14247
+ "device-enabled",
14163
14248
  "stream-online",
14164
14249
  "stream-offline",
14165
14250
  "node-online",
14166
14251
  "node-offline",
14167
14252
  "addon-update-available",
14168
- "server-update-available"
14253
+ "server-update-available",
14254
+ "alarm-triggered",
14255
+ "alarm-armed",
14256
+ "alarm-disarmed",
14257
+ "camera-online",
14258
+ "camera-offline",
14259
+ "camera-disabled",
14260
+ "camera-enabled"
14169
14261
  ]);
14262
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14263
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14264
+ "camera-online",
14265
+ "camera-offline",
14266
+ "camera-disabled",
14267
+ "camera-enabled"
14268
+ ]);
14269
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14170
14270
  /**
14171
14271
  * One coherent system-event condition. `kinds` is the required opt-in safety
14172
14272
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14175,6 +14275,18 @@ var NcSystemEventKindSchema = _enum([
14175
14275
  var NcSystemEventConditionSchema = object({
14176
14276
  kinds: array(NcSystemEventKindSchema).min(1),
14177
14277
  deviceIds: array(number().int()).min(1).optional(),
14278
+ /**
14279
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14280
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14281
+ * is what a liveness rule means when nobody said otherwise.
14282
+ *
14283
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14284
+ * one reason: the intake cannot know which devices this household cares
14285
+ * about, and a producer-side filter is one no operator can change. Fails
14286
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14287
+ * does not carry) matches no `deviceTypes` list.
14288
+ */
14289
+ deviceTypes: array(string().min(1)).min(1).optional(),
14178
14290
  nodeIds: array(string().min(1)).min(1).optional(),
14179
14291
  packageNames: array(string().min(1)).min(1).optional()
14180
14292
  });
@@ -14225,6 +14337,47 @@ var NcOccupancyConditionSchema = object({
14225
14337
  sustainSeconds: number().int().min(0).max(3600).default(15)
14226
14338
  });
14227
14339
  /**
14340
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14341
+ *
14342
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14343
+ * reference notifier uses, so an operator moving between them re-uses what
14344
+ * they already know): a rule matches when, over a sampling window of
14345
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14346
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14347
+ *
14348
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14349
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14350
+ * - `labels` — the classifier put at least one of these labels on it.
14351
+ *
14352
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14353
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14354
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14355
+ * is given** — a window in which every sample is trivially a hit would fire on
14356
+ * silence, so the engine refuses such a condition rather than notifying on
14357
+ * nothing (the schema cannot express "at least one of" without becoming a
14358
+ * ZodEffects the cap path would have to special-case).
14359
+ *
14360
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14361
+ * must be FULL before it can match — a window that has been open for two
14362
+ * seconds of its ten is 100% of nothing, and firing on it would make
14363
+ * `samplingSeconds` decorative.
14364
+ *
14365
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14366
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14367
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14368
+ * an operator who typed `dog` mean the same thing.
14369
+ */
14370
+ var NcAudioConditionSchema = object({
14371
+ /** Audio macro labels; absent = any sound (level-only rule). */
14372
+ labels: array(string().min(1)).min(1).optional(),
14373
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14374
+ dbThreshold: number().min(-96).max(0).optional(),
14375
+ /** Percentage of the window's samples that must be hits (1–100). */
14376
+ hitPercent: number().int().min(1).max(100).default(60),
14377
+ /** Length of the sampling window in seconds. */
14378
+ samplingSeconds: number().int().min(1).max(300).default(10)
14379
+ });
14380
+ /**
14228
14381
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14229
14382
  *
14230
14383
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14497,7 +14650,33 @@ var NcConditionsSchema = object({
14497
14650
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14498
14651
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14499
14652
  */
14500
- occupancy: NcOccupancyConditionSchema.optional()
14653
+ occupancy: NcOccupancyConditionSchema.optional(),
14654
+ /**
14655
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14656
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14657
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14658
+ * a window that is not full yet, neither filter given). See
14659
+ * {@link NcAudioCondition}.
14660
+ *
14661
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14662
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14663
+ * a detection, a track or a device event (the same fail-closed pairing
14664
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14665
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14666
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14667
+ * classified sample) stays exactly as it was for rules that already use it.
14668
+ *
14669
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14670
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14671
+ * (`camstack/src/data/notification-center.ts`, guarded by
14672
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14673
+ * condition fields it does not know when a rule is saved from the phone.
14674
+ * Publishing an editor for a condition the app cannot round-trip is how an
14675
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14676
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14677
+ * does an audio rule become authorable.
14678
+ */
14679
+ audio: NcAudioConditionSchema.optional()
14501
14680
  });
14502
14681
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14503
14682
  var NcRuleTargetSchema = object({
@@ -14611,6 +14790,73 @@ var NcThrottleSchema = object({
14611
14790
  */
14612
14791
  granularity: NcThrottleGranularitySchema.optional()
14613
14792
  });
14793
+ /**
14794
+ * How long the confirm gate may hold ONE notification, and how big the picture
14795
+ * it judges may be.
14796
+ *
14797
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14798
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14799
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14800
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14801
+ * tokens for pixels the model pools away.
14802
+ */
14803
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14804
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14805
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14806
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14807
+ var NcConfirmExpectSchema = object({
14808
+ op: _enum([
14809
+ ">=",
14810
+ ">",
14811
+ "<=",
14812
+ "<",
14813
+ "=="
14814
+ ]),
14815
+ count: number().int().min(0).max(1e3)
14816
+ });
14817
+ /**
14818
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14819
+ * to ship and says whether it agrees with the rule.
14820
+ *
14821
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14822
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14823
+ * on the operator's phone is not a verdict about this notification.
14824
+ *
14825
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14826
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14827
+ * the default and every fail-open is COUNTED, because a gate that always fails
14828
+ * open looks in the log exactly like a gate that works.
14829
+ *
14830
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14831
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14832
+ * production failures in one day), so the gate reads absent as the constant
14833
+ * above rather than trusting a parse it may never have seen.
14834
+ */
14835
+ var NcConfirmSchema = object({
14836
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14837
+ * same thing, and both mean "deliver exactly as before". */
14838
+ enabled: boolean().default(false),
14839
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14840
+ profileId: string().optional(),
14841
+ /**
14842
+ * The operator's question, in his own words. Absent = a question derived
14843
+ * from the rule (its class and its expectation).
14844
+ *
14845
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14846
+ * banners, signage and plates as instructions if you let them reach the
14847
+ * prompt — proven live — so the authoritative contract stays in the system
14848
+ * turn and only rule-authored words land here.
14849
+ */
14850
+ prompt: string().max(1e3).optional(),
14851
+ /** Fire only when the model's count satisfies this. Absent = the model's
14852
+ * own boolean verdict decides. */
14853
+ expect: NcConfirmExpectSchema.optional(),
14854
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14855
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14856
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14857
+ /** Longest edge the judged image is downscaled to before it is sent. */
14858
+ maxImagePx: number().int().min(64).max(2048).default(448)
14859
+ });
14614
14860
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14615
14861
  var NcRuleInputSchema = object({
14616
14862
  name: string().min(1).max(200),
@@ -14671,7 +14917,13 @@ var NcRuleInputSchema = object({
14671
14917
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14672
14918
  * shape as every other actuation.
14673
14919
  */
14674
- actions: NcRuleActionsSchema.optional()
14920
+ actions: NcRuleActionsSchema.optional(),
14921
+ /**
14922
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14923
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14924
+ * did, and absent is the only way to say that without a migration.
14925
+ */
14926
+ confirm: NcConfirmSchema.optional()
14675
14927
  });
14676
14928
  /**
14677
14929
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14682,7 +14934,37 @@ var NcRuleInputSchema = object({
14682
14934
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14683
14935
  * `updateRule` patch.
14684
14936
  */
14685
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14937
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14938
+ disabledTargetIds: array(string()).optional(),
14939
+ /**
14940
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14941
+ *
14942
+ * It makes the key optional to SUPPLY; the parse still materialises the
14943
+ * default when the key is absent. And `NcRuleStore.update` merges with
14944
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14945
+ * one — which made every partial edit destructive:
14946
+ *
14947
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14948
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14949
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14950
+ *
14951
+ * A rule scoped to one camera and one zone silently became a rule that
14952
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14953
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14954
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14955
+ * within a minute of a two-field patch.
14956
+ *
14957
+ * So every defaulted field is re-declared here WITHOUT its default. The
14958
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14959
+ * conditions remains a real instruction ("clear them") — and only the
14960
+ * absent key is now genuinely absent.
14961
+ */
14962
+ enabled: boolean().optional(),
14963
+ conditions: NcConditionsSchema.optional(),
14964
+ media: NcMediaPolicySchema.optional(),
14965
+ throttle: NcThrottleSchema.optional(),
14966
+ priority: number().int().min(1).max(5).optional()
14967
+ });
14686
14968
  /** A persisted rule. */
14687
14969
  var NcRuleSchema = NcRuleInputSchema.extend({
14688
14970
  id: string(),
@@ -14983,6 +15265,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14983
15265
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14984
15266
  * copy would lie the first time a rule is disabled.
14985
15267
  */
15268
+ /**
15269
+ * Why a device a mode NAMES is nonetheless not armed by it.
15270
+ *
15271
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15272
+ * per-camera notification switch the Notification Center already owns,
15273
+ * `detection-off` is the device's own detection binding being inactive, and
15274
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15275
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15276
+ * with the switches the operator actually used.
15277
+ */
15278
+ var NcAlarmSkipReasonSchema = _enum([
15279
+ "muted",
15280
+ "detection-off",
15281
+ "offline"
15282
+ ]);
15283
+ var NcAlarmSkippedDeviceSchema = object({
15284
+ deviceId: number().int(),
15285
+ reason: NcAlarmSkipReasonSchema
15286
+ });
14986
15287
  var NcAlarmModeCoverageSchema = object({
14987
15288
  mode: AlarmArmModeSchema,
14988
15289
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14990,7 +15291,18 @@ var NcAlarmModeCoverageSchema = object({
14990
15291
  /** At least one covering rule has no device scope, so the mode covers all. */
14991
15292
  allDevices: boolean(),
14992
15293
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14993
- deviceIds: array(number().int())
15294
+ deviceIds: array(number().int()),
15295
+ /**
15296
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15297
+ * excludes it.
15298
+ *
15299
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15300
+ * twelve makes it false in exactly the way nobody notices until an incident.
15301
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15302
+ * still parses as "nothing known to be skipped" rather than failing the whole
15303
+ * alarm tab.
15304
+ */
15305
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14994
15306
  });
14995
15307
  var NcAlarmConfigSchema = object({
14996
15308
  /**
@@ -17822,9 +18134,16 @@ var CameraStatusSchema = object({
17822
18134
  audio: CameraAudioStatusSchema.nullable(),
17823
18135
  recording: CameraRecordingStatusSchema.nullable(),
17824
18136
  /**
17825
- * Per-camera function switches an OPERATOR has turned off
18137
+ * Per-camera functions an OPERATOR has turned off
17826
18138
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17827
18139
  *
18140
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18141
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18142
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18143
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18144
+ * The badge outlives the control panel: the panel was a convenience, this is
18145
+ * the difference between a camera being off and a camera being dead.
18146
+ *
17828
18147
  * This is the difference between DISABLED and BROKEN. A camera whose
17829
18148
  * `detection` block reports zero fps and whose `switchedOff` contains
17830
18149
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -24704,7 +25023,19 @@ var RecordingManifestSchema = object({
24704
25023
  * profiles/subtrees/locations on this node). */
24705
25024
  var RecordingDeviceUsageSchema = object({
24706
25025
  deviceId: number(),
24707
- usedBytes: number()
25026
+ usedBytes: number(),
25027
+ /**
25028
+ * Start of this camera's OLDEST indexed segment, across every profile and
25029
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25030
+ * only honest answer to "is retention actually holding?" per camera.
25031
+ *
25032
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25033
+ * predates this field omits it entirely, and a hub whose types carry the
25034
+ * field must keep validating that older provider's payload: the framework
25035
+ * (types) and the addon ship on different trains, and the addon is usually
25036
+ * the later of the two.
25037
+ */
25038
+ oldestMs: number().nullable().optional()
24708
25039
  });
24709
25040
  /** Recording storage usage + capacity for one storage location. */
24710
25041
  var RecordingLocationUsageSchema = object({
@@ -24732,6 +25063,57 @@ var RecordingStorageUsageSchema = object({
24732
25063
  locations: array(RecordingLocationUsageSchema)
24733
25064
  });
24734
25065
  /**
25066
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25067
+ *
25068
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25069
+ * is the operator asking for the EXISTING archive to be brought into line with
25070
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25071
+ * location, run FIFO behind the single-flight mover.
25072
+ *
25073
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25074
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25075
+ * (empty on the plan).
25076
+ */
25077
+ var RecordingRebalanceMoveSchema = object({
25078
+ deviceId: number(),
25079
+ profile: string(),
25080
+ fromLocationId: string(),
25081
+ toLocationId: string(),
25082
+ bytes: number(),
25083
+ files: number().int()
25084
+ });
25085
+ /** Why a pile that is out of place is staying there. Every refusal is
25086
+ * reported: a rebalance that silently drops a camera reads exactly like one
25087
+ * that had nothing to do. */
25088
+ var RecordingRebalanceSkipReasonSchema = _enum([
25089
+ "unassigned",
25090
+ "target-not-writable",
25091
+ "below-threshold",
25092
+ "no-headroom"
25093
+ ]);
25094
+ var RecordingRebalanceSkipSchema = object({
25095
+ deviceId: number(),
25096
+ profile: string(),
25097
+ fromLocationId: string(),
25098
+ /** The location the plan wants; null when the camera has no assignment. */
25099
+ toLocationId: string().nullable(),
25100
+ bytes: number(),
25101
+ reason: RecordingRebalanceSkipReasonSchema
25102
+ });
25103
+ var RecordingRebalancePlanSchema = object({
25104
+ moves: array(RecordingRebalanceMoveSchema),
25105
+ skipped: array(RecordingRebalanceSkipSchema),
25106
+ bytesToMove: number(),
25107
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25108
+ jobIds: array(string())
25109
+ });
25110
+ var RecordingRebalanceInputSchema = object({
25111
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25112
+ throttleMbps: number().min(1).max(1e3).optional(),
25113
+ /** Ignore piles smaller than this (default 1 GB). */
25114
+ minMoveGb: number().min(0).optional()
25115
+ });
25116
+ /**
24735
25117
  * Result of locating footage at a wall-clock instant for one device/profile.
24736
25118
  * `segment` carries the covering segment's window; `gap` reports the forward
24737
25119
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -24894,9 +25276,24 @@ method(object({
24894
25276
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24895
25277
  kind: "mutation",
24896
25278
  auth: "admin"
25279
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25280
+ kind: "mutation",
25281
+ auth: "admin"
25282
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25283
+ kind: "query",
25284
+ auth: "admin"
25285
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25286
+ kind: "mutation",
25287
+ auth: "admin"
25288
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25289
+ kind: "query",
25290
+ auth: "admin"
25291
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25292
+ kind: "mutation",
25293
+ auth: "admin"
24897
25294
  });
24898
25295
  /**
24899
- * `recordingExport` cap — render a footage time range into a single downloadable
25296
+ * `recording-export` cap — render a footage time range into a single downloadable
24900
25297
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
24901
25298
  * bounded lifetime with a durable history, auto-expiry, and optional
24902
25299
  * delete-after-download.
@@ -24911,10 +25308,42 @@ method(object({
24911
25308
  */
24912
25309
  /** Playback-speed multiplier for the render (1 = realtime). */
24913
25310
  var ExportSpeedSchema = number().min(.25).max(32);
25311
+ /**
25312
+ * One dense interval, in SECONDS FROM THE EXPORT'S OWN `fromMs`.
25313
+ *
25314
+ * Relative and not absolute epoch on purpose: the renderer's frame-select
25315
+ * expression sees ffmpeg's `t`, which starts at 0 for the export's source
25316
+ * playlist. Handing it absolute epochs would make every call site responsible
25317
+ * for the same subtraction, and the one that forgot would emit a filter that
25318
+ * selects nothing — silently, as a uniform timelapse.
25319
+ */
25320
+ var ExportDenseRangeSchema = object({
25321
+ fromSec: number().nonnegative(),
25322
+ toSec: number().nonnegative()
25323
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25324
+ /**
25325
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25326
+ * listed ranges and at the base `everyMs` everywhere else.
25327
+ *
25328
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25329
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25330
+ */
25331
+ var ExportDenseSchema = object({
25332
+ everyMs: number().int().positive(),
25333
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25334
+ });
24914
25335
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
24915
25336
  var ExportTimelapseSchema = object({
24916
25337
  everyMs: number().int().positive(),
24917
- outputFps: number().int().min(1).max(60).optional()
25338
+ outputFps: number().int().min(1).max(60).optional(),
25339
+ /** Optional second, FASTER rate over the intervals that matter. */
25340
+ dense: ExportDenseSchema.optional()
25341
+ }).superRefine((v, ctx) => {
25342
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25343
+ code: ZodIssueCode.custom,
25344
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25345
+ path: ["dense", "everyMs"]
25346
+ });
24918
25347
  });
24919
25348
  /**
24920
25349
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -24972,6 +25401,19 @@ var ExportDownloadSchema = object({
24972
25401
  url: string(),
24973
25402
  endpoints: array(string())
24974
25403
  });
25404
+ /**
25405
+ * A finished export's bytes, inline.
25406
+ *
25407
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25408
+ * against, so nobody has to infer it from the base64 length.
25409
+ */
25410
+ var ExportBytesSchema = object({
25411
+ base64: string(),
25412
+ contentType: string(),
25413
+ /** Suggested filename, extension included. */
25414
+ name: string(),
25415
+ bytes: number().int().nonnegative()
25416
+ });
24975
25417
  method(object({
24976
25418
  deviceId: number(),
24977
25419
  profile: string(),
@@ -24996,6 +25438,9 @@ method(object({
24996
25438
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
24997
25439
  kind: "query",
24998
25440
  auth: "protected"
25441
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25442
+ kind: "query",
25443
+ auth: "protected"
24999
25444
  });
25000
25445
  /**
25001
25446
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -31685,6 +32130,12 @@ Object.freeze({
31685
32130
  addonId: null,
31686
32131
  access: "create"
31687
32132
  },
32133
+ "recording.cancelRelocateJob": {
32134
+ capName: "recording",
32135
+ capScope: "system",
32136
+ addonId: null,
32137
+ access: "create"
32138
+ },
31688
32139
  "recording.cancelStorageMigrationMove": {
31689
32140
  capName: "recording",
31690
32141
  capScope: "system",
@@ -31739,6 +32190,12 @@ Object.freeze({
31739
32190
  addonId: null,
31740
32191
  access: "view"
31741
32192
  },
32193
+ "recording.listRelocateJobs": {
32194
+ capName: "recording",
32195
+ capScope: "system",
32196
+ addonId: null,
32197
+ access: "view"
32198
+ },
31742
32199
  "recording.locateSegment": {
31743
32200
  capName: "recording",
31744
32201
  capScope: "system",
@@ -31751,6 +32208,12 @@ Object.freeze({
31751
32208
  addonId: null,
31752
32209
  access: "create"
31753
32210
  },
32211
+ "recording.planStorageRebalance": {
32212
+ capName: "recording",
32213
+ capScope: "system",
32214
+ addonId: null,
32215
+ access: "view"
32216
+ },
31754
32217
  "recording.pruneFootage": {
31755
32218
  capName: "recording",
31756
32219
  capScope: "system",
@@ -31775,6 +32238,12 @@ Object.freeze({
31775
32238
  addonId: null,
31776
32239
  access: "create"
31777
32240
  },
32241
+ "recording.relocateFootage": {
32242
+ capName: "recording",
32243
+ capScope: "system",
32244
+ addonId: null,
32245
+ access: "create"
32246
+ },
31778
32247
  "recording.renderClip": {
31779
32248
  capName: "recording",
31780
32249
  capScope: "system",
@@ -31811,38 +32280,50 @@ Object.freeze({
31811
32280
  addonId: null,
31812
32281
  access: "create"
31813
32282
  },
32283
+ "recording.startStorageRebalance": {
32284
+ capName: "recording",
32285
+ capScope: "system",
32286
+ addonId: null,
32287
+ access: "create"
32288
+ },
31814
32289
  "recordingExport.cancelExport": {
31815
- capName: "recordingExport",
32290
+ capName: "recording-export",
31816
32291
  capScope: "system",
31817
32292
  addonId: null,
31818
32293
  access: "create"
31819
32294
  },
31820
32295
  "recordingExport.createExport": {
31821
- capName: "recordingExport",
32296
+ capName: "recording-export",
31822
32297
  capScope: "system",
31823
32298
  addonId: null,
31824
32299
  access: "create"
31825
32300
  },
31826
32301
  "recordingExport.deleteExport": {
31827
- capName: "recordingExport",
32302
+ capName: "recording-export",
31828
32303
  capScope: "system",
31829
32304
  addonId: null,
31830
32305
  access: "delete"
31831
32306
  },
31832
32307
  "recordingExport.getDownloadUrl": {
31833
- capName: "recordingExport",
32308
+ capName: "recording-export",
31834
32309
  capScope: "system",
31835
32310
  addonId: null,
31836
32311
  access: "view"
31837
32312
  },
31838
32313
  "recordingExport.getExport": {
31839
- capName: "recordingExport",
32314
+ capName: "recording-export",
31840
32315
  capScope: "system",
31841
32316
  addonId: null,
31842
32317
  access: "view"
31843
32318
  },
31844
32319
  "recordingExport.listExports": {
31845
- capName: "recordingExport",
32320
+ capName: "recording-export",
32321
+ capScope: "system",
32322
+ addonId: null,
32323
+ access: "view"
32324
+ },
32325
+ "recordingExport.readExportBytes": {
32326
+ capName: "recording-export",
31846
32327
  capScope: "system",
31847
32328
  addonId: null,
31848
32329
  access: "view"
@@ -33219,6 +33700,104 @@ var FramerateField = number().int().min(1).max(60);
33219
33700
  var TargetsField = array(NcRuleTargetSchema).min(1);
33220
33701
  var PriorityField = number().int().min(1).max(5);
33221
33702
  /**
33703
+ * Explicit override of the DENSE sampling cadence, seconds.
33704
+ *
33705
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
33706
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
33707
+ * made that same base 3 s and rendered a person pass as two frames.)
33708
+ *
33709
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
33710
+ * `denseCadenceSec` and played at `framerate` occupies
33711
+ *
33712
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
33713
+ *
33714
+ * 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.
33715
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
33716
+ * and therefore the length of a quiet night, does not move.
33717
+ *
33718
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
33719
+ * the recording has them returns the same frames, requested twice. Must be
33720
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
33721
+ * a uniform video the operator believes is two-rate — and upsert refuses it
33722
+ * rather than letting the export cap reject the render hours after the window.
33723
+ */
33724
+ var DenseCadenceSecField = number().min(.1).max(3600);
33725
+ /**
33726
+ * Minimum seconds of OUTPUT video each detection range must occupy.
33727
+ *
33728
+ * The operator-facing form of the arithmetic above: instead of solving for a
33729
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
33730
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
33731
+ * that range every ~583 ms.
33732
+ *
33733
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
33734
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
33735
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
33736
+ * ranges are sampled denser than they need. Per-range cadences require a cap
33737
+ * schema change and are the tracked follow-up.
33738
+ *
33739
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
33740
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
33741
+ * by real footage, never met by duplicating frames into motion that never
33742
+ * happened.
33743
+ */
33744
+ var MinDwellSecField = number().min(0).max(60);
33745
+ /**
33746
+ * Caption burned into the notification's preview frame.
33747
+ *
33748
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
33749
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
33750
+ * templating dialect for one field would be a second thing to explain.
33751
+ *
33752
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
33753
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
33754
+ * the reason this is not `.min(1)`.
33755
+ */
33756
+ var PreviewTextField = string().max(200);
33757
+ /**
33758
+ * Whether the notification's preview is a STILL or a short animation.
33759
+ *
33760
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
33761
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
33762
+ * night reads better as three seconds of motion than as one frame of it. Both
33763
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
33764
+ * simply applies it to a dozen frames sampled across the render and assembles
33765
+ * them.
33766
+ *
33767
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
33768
+ * seeks and a palette pass, and no rule that never asked for one should start
33769
+ * paying that on the deploy that shipped it.
33770
+ *
33771
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
33772
+ */
33773
+ var PreviewModeField = _enum(["image", "gif"]);
33774
+ /**
33775
+ * Which detection classes the notification reports counts for.
33776
+ *
33777
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
33778
+ * plan — no second query — aggregated per class. Absent or empty means "every
33779
+ * class the window actually contained", which is what an operator who never
33780
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
33781
+ * counts cars all night).
33782
+ *
33783
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
33784
+ * …). An unknown name simply never matches and reports nothing — it is not an
33785
+ * error, because a rule may legitimately name a class this camera's model does
33786
+ * not emit.
33787
+ *
33788
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
33789
+ * - `{{detections}}` — total over the reported classes
33790
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
33791
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
33792
+ * one per class, `count_` + the class name
33793
+ *
33794
+ * With NO custom body template the summary is appended to the derived body, and
33795
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
33796
+ * reads. With a custom template the operator owns every word — nothing is
33797
+ * appended, so `{{detectionSummary}}` is how he asks for it.
33798
+ */
33799
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
33800
+ /**
33222
33801
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33223
33802
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33224
33803
  * here (see the ownership note above).
@@ -33238,9 +33817,30 @@ var TimelapseRuleInputSchema = object({
33238
33817
  cadenceSec: CadenceSecField.default(15),
33239
33818
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33240
33819
  framerate: FramerateField.default(10),
33820
+ /**
33821
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
33822
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
33823
+ * field gets.
33824
+ */
33825
+ denseCadenceSec: DenseCadenceSecField.optional(),
33826
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
33827
+ minDwellSec: MinDwellSecField.optional(),
33241
33828
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33242
33829
  targets: TargetsField,
33243
33830
  template: TimelapseTemplateSchema.optional(),
33831
+ /**
33832
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
33833
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
33834
+ *
33835
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
33836
+ * the notification's title/body, and clearing it (`template: null`) must not
33837
+ * silently clear the caption too.
33838
+ */
33839
+ previewText: PreviewTextField.optional(),
33840
+ /** Still or animation — see {@link PreviewModeField}. */
33841
+ previewMode: PreviewModeField.default("image"),
33842
+ /** Classes the notification counts — see {@link ReportClassesField}. */
33843
+ reportClasses: ReportClassesField.optional(),
33244
33844
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33245
33845
  priority: PriorityField.default(3)
33246
33846
  });
@@ -33251,8 +33851,13 @@ object({
33251
33851
  schedule: NcScheduleSchema.optional(),
33252
33852
  cadenceSec: CadenceSecField.optional(),
33253
33853
  framerate: FramerateField.optional(),
33854
+ denseCadenceSec: DenseCadenceSecField.optional(),
33855
+ minDwellSec: MinDwellSecField.optional(),
33254
33856
  targets: TargetsField.optional(),
33255
33857
  template: TimelapseTemplateSchema.nullable().optional(),
33858
+ previewText: PreviewTextField.optional(),
33859
+ previewMode: PreviewModeField.optional(),
33860
+ reportClasses: ReportClassesField.optional(),
33256
33861
  priority: PriorityField.optional()
33257
33862
  });
33258
33863
  TimelapseRuleInputSchema.extend({
@@ -33264,10 +33869,28 @@ TimelapseRuleInputSchema.extend({
33264
33869
  */
33265
33870
  ownerUserId: string().optional(),
33266
33871
  /**
33267
- * Epoch-ms of the last successful generation the 1-hour re-generation
33268
- * guard's durable state (predecessor parity). Absent = never generated.
33872
+ * Epoch-ms of the NEWEST successful generation across every camera of this
33873
+ * rule. What a UI shows, and the compatibility floor for
33874
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33269
33875
  */
33270
33876
  lastGeneratedAt: number().optional(),
33877
+ /**
33878
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
33879
+ * re-generation guard's real durable state.
33880
+ *
33881
+ * One rule covers several cameras and each renders its own video, so a rule
33882
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
33883
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
33884
+ * already done — and B's night is gone for good, because the window will not
33885
+ * come back.
33886
+ *
33887
+ * ADDITIVE, so the migration is free: a row written before this field simply
33888
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
33889
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
33890
+ * "never generated" would re-render and re-notify every camera of every rule
33891
+ * once, on the deploy that shipped the map.
33892
+ */
33893
+ generatedByDevice: record(string(), number()).optional(),
33271
33894
  /** userId of the caller who created the rule (server-stamped). */
33272
33895
  createdBy: string(),
33273
33896
  createdAt: number(),
@@ -33516,6 +34139,91 @@ async function warmNodePty() {
33516
34139
  await loadNodePty();
33517
34140
  }
33518
34141
  //#endregion
34142
+ //#region src/silence-analysis.ts
34143
+ /**
34144
+ * Every analyzer a Terminal camera is created with switched OFF.
34145
+ *
34146
+ * `motion-detection` sits first deliberately: it is the one that holds the
34147
+ * decode session open, so it is the one whose absence is the difference between
34148
+ * a terminal costing a screen scrape and costing a decode pipeline.
34149
+ */
34150
+ var TERMINAL_SILENCED_CAP_NAMES = [
34151
+ "motion-detection",
34152
+ DETECTION_PIPELINE_CAP_NAME,
34153
+ AUDIO_ANALYSIS_CAP_NAME
34154
+ ];
34155
+ /**
34156
+ * Resolve the addon currently providing `capName` for this device.
34157
+ *
34158
+ * Inlined rather than reached for through a helper because there is exactly one
34159
+ * honest source: the device's own bindings. `listBindableCapsForDeviceType`
34160
+ * answers for the device TYPE and would happily name a wrapper that is not the
34161
+ * one bound here.
34162
+ *
34163
+ * Returns `null` when the cap is not bound at all — which is not an error: a
34164
+ * deployment with no audio analyzer has nothing to switch off, and demanding one
34165
+ * would make every terminal creation fail on a perfectly valid hub.
34166
+ */
34167
+ async function resolveBoundWrapper(api, deviceId, capName) {
34168
+ const bindings = await api.deviceManager.getBindings.query({ deviceId });
34169
+ for (const entry of bindings.entries) {
34170
+ if (entry.capName !== capName) continue;
34171
+ if (entry.kind !== "wrapped") continue;
34172
+ if (entry.providerAddonId === "") return null;
34173
+ return entry.providerAddonId;
34174
+ }
34175
+ return null;
34176
+ }
34177
+ /**
34178
+ * Switch every analyzer in {@link TERMINAL_SILENCED_CAP_NAMES} off for one
34179
+ * Terminal camera.
34180
+ *
34181
+ * Called ONLY on creation. An operator who deliberately turns detection back on
34182
+ * for a terminal must win, and a reconcile that re-asserted every pass would
34183
+ * silently overrule them once a minute.
34184
+ *
34185
+ * @throws if a cap IS bound and the write to its authority failed. The camera
34186
+ * would then be running a full analyzer for a screen recording, which is the
34187
+ * exact cost this exists to remove — and a silent version of that failure is
34188
+ * unfindable.
34189
+ */
34190
+ async function silenceAnalysisFor(deps, deviceId) {
34191
+ const failures = [];
34192
+ for (const capName of TERMINAL_SILENCED_CAP_NAMES) try {
34193
+ const wrapperAddonId = await resolveBoundWrapper(deps.api, deviceId, capName);
34194
+ if (wrapperAddonId === null) {
34195
+ deps.logger.debug("terminal camera: no analyzer bound for this capability", {
34196
+ tags: { deviceId },
34197
+ meta: { capName }
34198
+ });
34199
+ continue;
34200
+ }
34201
+ await deps.api.deviceManager.setWrapperActive.mutate({
34202
+ deviceId,
34203
+ capName,
34204
+ wrapperAddonId,
34205
+ active: false
34206
+ });
34207
+ deps.logger.info("terminal camera: analyzer switched off at its authority", {
34208
+ tags: { deviceId },
34209
+ meta: {
34210
+ capName,
34211
+ wrapperAddonId
34212
+ }
34213
+ });
34214
+ } catch (err) {
34215
+ failures.push(`${capName}: ${errMsg(err)}`);
34216
+ deps.logger.error("terminal camera: could NOT switch an analyzer off", {
34217
+ tags: { deviceId },
34218
+ meta: {
34219
+ capName,
34220
+ error: errMsg(err)
34221
+ }
34222
+ });
34223
+ }
34224
+ 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("; ")})`);
34225
+ }
34226
+ //#endregion
33519
34227
  //#region src/terminal-camera-declarations.ts
33520
34228
  /**
33521
34229
  * Feed DeclaredDevices every live declaration plus one deterministic orphan
@@ -40049,37 +40757,22 @@ var TerminalAddon = class extends BaseAddon {
40049
40757
  }
40050
40758
  }
40051
40759
  /**
40052
- * A Terminal camera is a rendered screen. Object detection on it finds
40053
- * nothing, forever, at full cost.
40760
+ * A Terminal camera is a rendered screen. Every analyzer on it finds nothing,
40761
+ * forever, at full cost — see `silence-analysis.ts` for the measurements, the
40762
+ * reason `motion-detection` is in the list, and why a failure THROWS instead
40763
+ * of warning.
40054
40764
  *
40055
- * Measured on the hub 2026-08-11, for ONE terminal camera: 19 frames per 10 s
40056
- * through the detection pipeline at ~61 ms of inference each, plus 115
40057
- * capture-scheduler requests a minute against `detections=0`. Multiply by
40058
- * one terminal per node and it is a standing tax on a hub that was already
40059
- * shedding 86 % of its capture queue.
40060
- *
40061
- * Written through `setCameraSwitch`, which is the authority that already owns
40062
- * this function — [D62] forbids a second store that disagrees with it. And
40063
- * written ONLY on creation: an operator who deliberately turns detection back
40064
- * on for a terminal must win, and a reconcile that re-asserted every pass
40065
- * would silently overrule them once a minute.
40066
- */
40067
- async silenceAnalysisFor(deviceId) {
40068
- for (const switchId of ["object-detection", "audio-analysis"]) try {
40069
- await this.ctx.api.pipelineOrchestrator.setCameraSwitch.mutate({
40070
- deviceId,
40071
- switchId,
40072
- enabled: false
40073
- });
40074
- } catch (err) {
40075
- this.ctx.logger.warn("could not switch off analysis for a Terminal camera", {
40076
- tags: { deviceId },
40077
- meta: {
40078
- switchId,
40079
- error: err instanceof Error ? err.message : String(err)
40080
- }
40081
- });
40082
- }
40765
+ * Written to the AUTHORITIES (`deviceManager.setWrapperActive`), not through
40766
+ * the deprecated switch cap the previous version used (D113). Written ONLY on
40767
+ * creation: an operator who deliberately turns detection back on for a
40768
+ * terminal must win, and a reconcile that re-asserted every pass would
40769
+ * silently overrule them once a minute.
40770
+ */
40771
+ silenceAnalysisFor(deviceId) {
40772
+ return silenceAnalysisFor({
40773
+ api: this.ctx.api,
40774
+ logger: this.ctx.logger
40775
+ }, deviceId);
40083
40776
  }
40084
40777
  terminalInstanceControl() {
40085
40778
  return {