@camstack/addon-provider-homematic 1.2.96 → 1.2.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -5354,6 +5354,86 @@ var ZodIssueCode = {
5354
5354
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5355
5355
  var ZodFirstPartyTypeKind;
5356
5356
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5357
+ //#endregion
5358
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5359
+ /**
5360
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5361
+ * window to float samples (D455).
5362
+ *
5363
+ * ## Why a format at all
5364
+ *
5365
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5366
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5367
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5368
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5369
+ * the plane carried four times the source. The plane crosses hub-main twice on
5370
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5371
+ *
5372
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5373
+ * them where it needs them. That is the same argument D450 made for the rate,
5374
+ * one step further along the same wire.
5375
+ *
5376
+ * ## Why the expansion lives here
5377
+ *
5378
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5379
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5380
+ * `AudioChunkPlane` expands per subscription) and
5381
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5382
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5383
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5384
+ * into their own dist (`self-contained` externals), so this travels with a
5385
+ * `camstack deploy` and needs no published server.
5386
+ *
5387
+ * A second μ-law table anywhere else is the defect this module exists to
5388
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5389
+ * direction for the WebRTC egress — a different transform, not a copy.)
5390
+ *
5391
+ * ## Absent means f32le
5392
+ *
5393
+ * `format` is optional on the wire and its absence means `f32le` — today's
5394
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5395
+ * has always been served, because the broker only emits a coded window to a
5396
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5397
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5398
+ * deployable one addon at a time across three nodes.
5399
+ */
5400
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5401
+ var AUDIO_CHUNK_FORMATS = [
5402
+ "f32le",
5403
+ "pcmu",
5404
+ "pcma"
5405
+ ];
5406
+ /**
5407
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5408
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5409
+ *
5410
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5411
+ * it buffers the coded bytes and the plane's consumers expand.
5412
+ */
5413
+ function buildUlawTable() {
5414
+ const table = new Float32Array(256);
5415
+ for (let i = 0; i < 256; i++) {
5416
+ const complemented = ~i & 255;
5417
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5418
+ const exponent = complemented >> 4 & 7;
5419
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5420
+ }
5421
+ return table;
5422
+ }
5423
+ /** Build the A-law decode table (ITU-T G.711). */
5424
+ function buildAlawTable() {
5425
+ const table = new Float32Array(256);
5426
+ for (let i = 0; i < 256; i++) {
5427
+ const xored = i ^ 85;
5428
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5429
+ const exponent = xored >> 4 & 7;
5430
+ const mantissa = xored & 15;
5431
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5432
+ }
5433
+ return table;
5434
+ }
5435
+ buildUlawTable();
5436
+ buildAlawTable();
5357
5437
  Object.fromEntries([
5358
5438
  {
5359
5439
  id: "overview",
@@ -6646,11 +6726,20 @@ var SubscribeFramesResultSchema = object({
6646
6726
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6647
6727
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6648
6728
  */
6729
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6649
6730
  var DecodedAudioChunkSchema = object({
6650
6731
  data: _instanceof(Uint8Array),
6651
6732
  sampleRate: number().int().positive(),
6652
6733
  channels: number().int().positive(),
6653
- timestamp: number()
6734
+ timestamp: number(),
6735
+ /**
6736
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6737
+ * byte, for any peer that never heard of this field. A coded window
6738
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6739
+ * subscription that DECLARED it accepts one, so absence can never mean
6740
+ * "coded bytes a consumer will read as floats" (D455).
6741
+ */
6742
+ format: AudioChunkFormatSchema.optional()
6654
6743
  });
6655
6744
  /**
6656
6745
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6662,7 +6751,18 @@ var DecodedAudioChunkSchema = object({
6662
6751
  var SubscribeAudioChunksInputSchema = object({
6663
6752
  brokerId: string(),
6664
6753
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6665
- tag: string().optional()
6754
+ tag: string().optional(),
6755
+ /**
6756
+ * Byte formats this subscriber can READ, best first. The broker serves the
6757
+ * chunk's own format when it is in this list and expands to `f32le`
6758
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6759
+ *
6760
+ * Absent (or without the source format) means `f32le` — the behaviour every
6761
+ * subscriber had before D455, unchanged. This is the negotiation half of
6762
+ * the source-bytes lever: it is what lets the broker and its consumers
6763
+ * deploy one at a time across three nodes.
6764
+ */
6765
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6666
6766
  });
6667
6767
  /** Result of `stream-broker.subscribeAudioChunks`. */
6668
6768
  var SubscribeAudioChunksResultSchema = object({
@@ -10650,6 +10750,51 @@ var AudioAnalysisSettingsSchema = object({
10650
10750
  minConfidence: number().min(0).max(1).default(.3),
10651
10751
  allowedClasses: array(string()).default([])
10652
10752
  });
10753
+ /**
10754
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10755
+ *
10756
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10757
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10758
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10759
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10760
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10761
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10762
+ * way to the one expansion that feeds the model.
10763
+ *
10764
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10765
+ * window, the per-device node assignment, the settings read) and therefore
10766
+ * still owns the attach/detach pair. It no longer owns the bytes.
10767
+ */
10768
+ var AudioAttachDeviceInputSchema = object({
10769
+ deviceId: number(),
10770
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10771
+ brokerId: string(),
10772
+ /**
10773
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10774
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10775
+ * the orchestrator's poller pinned them before the move.
10776
+ */
10777
+ ingestNodeId: string(),
10778
+ /**
10779
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10780
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10781
+ * window: a settings change re-attaches, which is what always happened.
10782
+ */
10783
+ settings: AudioAnalysisSettingsSchema
10784
+ });
10785
+ var AudioAttachDeviceResultSchema = object({
10786
+ /** False only when the analyzer is shutting down and refused to attach. */
10787
+ attached: boolean(),
10788
+ /**
10789
+ * True when the attachment replaced a live one for the same device. An
10790
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10791
+ * double the broker's fanout and neither would know about the other.
10792
+ */
10793
+ replaced: boolean()
10794
+ });
10795
+ var AudioDetachDeviceResultSchema = object({
10796
+ /** False when no attachment existed — detach is idempotent. */
10797
+ detached: boolean() });
10653
10798
  var AudioClassificationResultSchema = object({
10654
10799
  labels: array(AudioClassificationLabelSchema).readonly(),
10655
10800
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10658,7 +10803,7 @@ var AudioClassificationResultSchema = object({
10658
10803
  method(object({
10659
10804
  chunk: AudioChunkInputSchema,
10660
10805
  settings: AudioAnalysisSettingsSchema
10661
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10806
+ }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10662
10807
  kind: "mutation",
10663
10808
  auth: "admin"
10664
10809
  });
@@ -20628,6 +20773,14 @@ var NativeCropResultSchema = object({
20628
20773
  * set `encodeJpeg: true`; `bytes` is then absent.
20629
20774
  */
20630
20775
  jpeg: string().optional(),
20776
+ /**
20777
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20778
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20779
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20780
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20781
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20782
+ */
20783
+ jpegBytes: _instanceof(Uint8Array).optional(),
20631
20784
  width: number().int().positive(),
20632
20785
  height: number().int().positive(),
20633
20786
  /**
@@ -20694,7 +20847,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20694
20847
  })]);
20695
20848
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20696
20849
  var ParkedTrackFrameSchema = object({
20697
- jpeg: string(),
20850
+ /**
20851
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20852
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20853
+ * Exactly one of the two is present.
20854
+ */
20855
+ jpeg: string().optional(),
20856
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20857
+ jpegBytes: _instanceof(Uint8Array).optional(),
20698
20858
  width: number().int().positive(),
20699
20859
  height: number().int().positive(),
20700
20860
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21281,6 +21441,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21281
21441
  bbox: NativeCropBboxSchema,
21282
21442
  maxWidth: number().int().positive().optional(),
21283
21443
  /**
21444
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21445
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21446
+ * wire — never assume consent: a pre-D462 caller parses the field as
21447
+ * base64 and bytes would decode to garbage rather than fail.
21448
+ */
21449
+ acceptJpegBytes: boolean().optional(),
21450
+ /**
21284
21451
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21285
21452
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21286
21453
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21348,7 +21515,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21348
21515
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21349
21516
  deviceId: number(),
21350
21517
  trackId: string(),
21351
- kind: ParkedFrameKindSchema
21518
+ kind: ParkedFrameKindSchema,
21519
+ /**
21520
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21521
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21522
+ * wire — never assume consent: a pre-D462 caller parses the field as
21523
+ * base64 and bytes would decode to garbage rather than fail.
21524
+ */
21525
+ acceptJpegBytes: boolean().optional()
21352
21526
  }), ParkedTrackFrameSchema.nullable()), method(object({
21353
21527
  deviceId: number(),
21354
21528
  trackId: string()
@@ -34983,12 +35157,24 @@ Object.freeze({
34983
35157
  addonId: null,
34984
35158
  access: "create"
34985
35159
  },
35160
+ "audioAnalyzer.attachDevice": {
35161
+ capName: "audio-analyzer",
35162
+ capScope: "system",
35163
+ addonId: null,
35164
+ access: "create"
35165
+ },
34986
35166
  "audioAnalyzer.classify": {
34987
35167
  capName: "audio-analyzer",
34988
35168
  capScope: "system",
34989
35169
  addonId: null,
34990
35170
  access: "view"
34991
35171
  },
35172
+ "audioAnalyzer.detachDevice": {
35173
+ capName: "audio-analyzer",
35174
+ capScope: "system",
35175
+ addonId: null,
35176
+ access: "create"
35177
+ },
34992
35178
  "audioAnalyzer.dispose": {
34993
35179
  capName: "audio-analyzer",
34994
35180
  capScope: "system",
@@ -40832,11 +41018,21 @@ Object.freeze({
40832
41018
  form: "single",
40833
41019
  optional: false
40834
41020
  }],
41021
+ "audioAnalyzer.attachDevice": [{
41022
+ name: "deviceId",
41023
+ form: "single",
41024
+ optional: false
41025
+ }],
40835
41026
  "audioAnalyzer.classify": [{
40836
41027
  name: "deviceId",
40837
41028
  form: "single",
40838
41029
  optional: true
40839
41030
  }],
41031
+ "audioAnalyzer.detachDevice": [{
41032
+ name: "deviceId",
41033
+ form: "single",
41034
+ optional: false
41035
+ }],
40840
41036
  "audioMetrics.getCurrentSnapshot": [{
40841
41037
  name: "deviceId",
40842
41038
  form: "single",
@@ -42688,6 +42884,52 @@ Object.freeze({
42688
42884
  "network-access": "ingress",
42689
42885
  "smtp-provider": "email"
42690
42886
  });
42887
+ var G711_SCALE_CORRECTION_DB = {
42888
+ PCMU: 20 * Math.log10(4),
42889
+ PCMA: 20 * Math.log10(8)
42890
+ };
42891
+ /**
42892
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42893
+ * same intent on the ITU-T scale (D460).
42894
+ *
42895
+ * ## When this applies, and when it is the wrong thing to reach for
42896
+ *
42897
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42898
+ * them converts:
42899
+ *
42900
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42901
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42902
+ * after. The defect was never in the number; it was that 19 of this hub's
42903
+ * 25 cameras did not obey it. Converting such a number takes something
42904
+ * correct and makes it wrong, in order to preserve a bug.
42905
+ * - **A measurement taken through the old decoder** — a value someone read
42906
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42907
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42908
+ * louder. That is what this function is for.
42909
+ *
42910
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42911
+ * and it cannot be answered from the number. It is answered by the comment the
42912
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42913
+ * mandatory.
42914
+ *
42915
+ * ## Why a function and not a typed-in number
42916
+ *
42917
+ * `-55 + 12.04` written into a source file is, six months later, completely
42918
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42919
+ * keeps the derivation, the law, and the original measurement all visible at
42920
+ * the call site, so a future reader can disagree with the *premise* instead of
42921
+ * having to reverse-engineer the sum.
42922
+ *
42923
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42924
+ * it is declared. It must never be applied to a live sample or a stored
42925
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42926
+ * adjusting numbers the decoder already got right is the original defect with
42927
+ * an extra place to argue with (D459).
42928
+ */
42929
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42930
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42931
+ }
42932
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42691
42933
  /** Schema defaults — an untouched sub-field must author exactly these. */
42692
42934
  var NC_AUDIO_DEFAULTS = {
42693
42935
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5355,6 +5355,86 @@ var ZodIssueCode = {
5355
5355
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5356
5356
  var ZodFirstPartyTypeKind;
5357
5357
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5358
+ //#endregion
5359
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5360
+ /**
5361
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5362
+ * window to float samples (D455).
5363
+ *
5364
+ * ## Why a format at all
5365
+ *
5366
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5367
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5368
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5369
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5370
+ * the plane carried four times the source. The plane crosses hub-main twice on
5371
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5372
+ *
5373
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5374
+ * them where it needs them. That is the same argument D450 made for the rate,
5375
+ * one step further along the same wire.
5376
+ *
5377
+ * ## Why the expansion lives here
5378
+ *
5379
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5380
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5381
+ * `AudioChunkPlane` expands per subscription) and
5382
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5383
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5384
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5385
+ * into their own dist (`self-contained` externals), so this travels with a
5386
+ * `camstack deploy` and needs no published server.
5387
+ *
5388
+ * A second μ-law table anywhere else is the defect this module exists to
5389
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5390
+ * direction for the WebRTC egress — a different transform, not a copy.)
5391
+ *
5392
+ * ## Absent means f32le
5393
+ *
5394
+ * `format` is optional on the wire and its absence means `f32le` — today's
5395
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5396
+ * has always been served, because the broker only emits a coded window to a
5397
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5398
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5399
+ * deployable one addon at a time across three nodes.
5400
+ */
5401
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5402
+ var AUDIO_CHUNK_FORMATS = [
5403
+ "f32le",
5404
+ "pcmu",
5405
+ "pcma"
5406
+ ];
5407
+ /**
5408
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5409
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5410
+ *
5411
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5412
+ * it buffers the coded bytes and the plane's consumers expand.
5413
+ */
5414
+ function buildUlawTable() {
5415
+ const table = new Float32Array(256);
5416
+ for (let i = 0; i < 256; i++) {
5417
+ const complemented = ~i & 255;
5418
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5419
+ const exponent = complemented >> 4 & 7;
5420
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5421
+ }
5422
+ return table;
5423
+ }
5424
+ /** Build the A-law decode table (ITU-T G.711). */
5425
+ function buildAlawTable() {
5426
+ const table = new Float32Array(256);
5427
+ for (let i = 0; i < 256; i++) {
5428
+ const xored = i ^ 85;
5429
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5430
+ const exponent = xored >> 4 & 7;
5431
+ const mantissa = xored & 15;
5432
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5433
+ }
5434
+ return table;
5435
+ }
5436
+ buildUlawTable();
5437
+ buildAlawTable();
5358
5438
  Object.fromEntries([
5359
5439
  {
5360
5440
  id: "overview",
@@ -6647,11 +6727,20 @@ var SubscribeFramesResultSchema = object({
6647
6727
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6648
6728
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6649
6729
  */
6730
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6650
6731
  var DecodedAudioChunkSchema = object({
6651
6732
  data: _instanceof(Uint8Array),
6652
6733
  sampleRate: number().int().positive(),
6653
6734
  channels: number().int().positive(),
6654
- timestamp: number()
6735
+ timestamp: number(),
6736
+ /**
6737
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6738
+ * byte, for any peer that never heard of this field. A coded window
6739
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6740
+ * subscription that DECLARED it accepts one, so absence can never mean
6741
+ * "coded bytes a consumer will read as floats" (D455).
6742
+ */
6743
+ format: AudioChunkFormatSchema.optional()
6655
6744
  });
6656
6745
  /**
6657
6746
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6663,7 +6752,18 @@ var DecodedAudioChunkSchema = object({
6663
6752
  var SubscribeAudioChunksInputSchema = object({
6664
6753
  brokerId: string(),
6665
6754
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6666
- tag: string().optional()
6755
+ tag: string().optional(),
6756
+ /**
6757
+ * Byte formats this subscriber can READ, best first. The broker serves the
6758
+ * chunk's own format when it is in this list and expands to `f32le`
6759
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6760
+ *
6761
+ * Absent (or without the source format) means `f32le` — the behaviour every
6762
+ * subscriber had before D455, unchanged. This is the negotiation half of
6763
+ * the source-bytes lever: it is what lets the broker and its consumers
6764
+ * deploy one at a time across three nodes.
6765
+ */
6766
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6667
6767
  });
6668
6768
  /** Result of `stream-broker.subscribeAudioChunks`. */
6669
6769
  var SubscribeAudioChunksResultSchema = object({
@@ -10651,6 +10751,51 @@ var AudioAnalysisSettingsSchema = object({
10651
10751
  minConfidence: number().min(0).max(1).default(.3),
10652
10752
  allowedClasses: array(string()).default([])
10653
10753
  });
10754
+ /**
10755
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10756
+ *
10757
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10758
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10759
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10760
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10761
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10762
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10763
+ * way to the one expansion that feeds the model.
10764
+ *
10765
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10766
+ * window, the per-device node assignment, the settings read) and therefore
10767
+ * still owns the attach/detach pair. It no longer owns the bytes.
10768
+ */
10769
+ var AudioAttachDeviceInputSchema = object({
10770
+ deviceId: number(),
10771
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10772
+ brokerId: string(),
10773
+ /**
10774
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10775
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10776
+ * the orchestrator's poller pinned them before the move.
10777
+ */
10778
+ ingestNodeId: string(),
10779
+ /**
10780
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10781
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10782
+ * window: a settings change re-attaches, which is what always happened.
10783
+ */
10784
+ settings: AudioAnalysisSettingsSchema
10785
+ });
10786
+ var AudioAttachDeviceResultSchema = object({
10787
+ /** False only when the analyzer is shutting down and refused to attach. */
10788
+ attached: boolean(),
10789
+ /**
10790
+ * True when the attachment replaced a live one for the same device. An
10791
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10792
+ * double the broker's fanout and neither would know about the other.
10793
+ */
10794
+ replaced: boolean()
10795
+ });
10796
+ var AudioDetachDeviceResultSchema = object({
10797
+ /** False when no attachment existed — detach is idempotent. */
10798
+ detached: boolean() });
10654
10799
  var AudioClassificationResultSchema = object({
10655
10800
  labels: array(AudioClassificationLabelSchema).readonly(),
10656
10801
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10659,7 +10804,7 @@ var AudioClassificationResultSchema = object({
10659
10804
  method(object({
10660
10805
  chunk: AudioChunkInputSchema,
10661
10806
  settings: AudioAnalysisSettingsSchema
10662
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10807
+ }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10663
10808
  kind: "mutation",
10664
10809
  auth: "admin"
10665
10810
  });
@@ -20629,6 +20774,14 @@ var NativeCropResultSchema = object({
20629
20774
  * set `encodeJpeg: true`; `bytes` is then absent.
20630
20775
  */
20631
20776
  jpeg: string().optional(),
20777
+ /**
20778
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20779
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20780
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20781
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20782
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20783
+ */
20784
+ jpegBytes: _instanceof(Uint8Array).optional(),
20632
20785
  width: number().int().positive(),
20633
20786
  height: number().int().positive(),
20634
20787
  /**
@@ -20695,7 +20848,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20695
20848
  })]);
20696
20849
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20697
20850
  var ParkedTrackFrameSchema = object({
20698
- jpeg: string(),
20851
+ /**
20852
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20853
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20854
+ * Exactly one of the two is present.
20855
+ */
20856
+ jpeg: string().optional(),
20857
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20858
+ jpegBytes: _instanceof(Uint8Array).optional(),
20699
20859
  width: number().int().positive(),
20700
20860
  height: number().int().positive(),
20701
20861
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21282,6 +21442,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21282
21442
  bbox: NativeCropBboxSchema,
21283
21443
  maxWidth: number().int().positive().optional(),
21284
21444
  /**
21445
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21446
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21447
+ * wire — never assume consent: a pre-D462 caller parses the field as
21448
+ * base64 and bytes would decode to garbage rather than fail.
21449
+ */
21450
+ acceptJpegBytes: boolean().optional(),
21451
+ /**
21285
21452
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21286
21453
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21287
21454
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21349,7 +21516,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21349
21516
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21350
21517
  deviceId: number(),
21351
21518
  trackId: string(),
21352
- kind: ParkedFrameKindSchema
21519
+ kind: ParkedFrameKindSchema,
21520
+ /**
21521
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21522
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21523
+ * wire — never assume consent: a pre-D462 caller parses the field as
21524
+ * base64 and bytes would decode to garbage rather than fail.
21525
+ */
21526
+ acceptJpegBytes: boolean().optional()
21353
21527
  }), ParkedTrackFrameSchema.nullable()), method(object({
21354
21528
  deviceId: number(),
21355
21529
  trackId: string()
@@ -34984,12 +35158,24 @@ Object.freeze({
34984
35158
  addonId: null,
34985
35159
  access: "create"
34986
35160
  },
35161
+ "audioAnalyzer.attachDevice": {
35162
+ capName: "audio-analyzer",
35163
+ capScope: "system",
35164
+ addonId: null,
35165
+ access: "create"
35166
+ },
34987
35167
  "audioAnalyzer.classify": {
34988
35168
  capName: "audio-analyzer",
34989
35169
  capScope: "system",
34990
35170
  addonId: null,
34991
35171
  access: "view"
34992
35172
  },
35173
+ "audioAnalyzer.detachDevice": {
35174
+ capName: "audio-analyzer",
35175
+ capScope: "system",
35176
+ addonId: null,
35177
+ access: "create"
35178
+ },
34993
35179
  "audioAnalyzer.dispose": {
34994
35180
  capName: "audio-analyzer",
34995
35181
  capScope: "system",
@@ -40833,11 +41019,21 @@ Object.freeze({
40833
41019
  form: "single",
40834
41020
  optional: false
40835
41021
  }],
41022
+ "audioAnalyzer.attachDevice": [{
41023
+ name: "deviceId",
41024
+ form: "single",
41025
+ optional: false
41026
+ }],
40836
41027
  "audioAnalyzer.classify": [{
40837
41028
  name: "deviceId",
40838
41029
  form: "single",
40839
41030
  optional: true
40840
41031
  }],
41032
+ "audioAnalyzer.detachDevice": [{
41033
+ name: "deviceId",
41034
+ form: "single",
41035
+ optional: false
41036
+ }],
40841
41037
  "audioMetrics.getCurrentSnapshot": [{
40842
41038
  name: "deviceId",
40843
41039
  form: "single",
@@ -42689,6 +42885,52 @@ Object.freeze({
42689
42885
  "network-access": "ingress",
42690
42886
  "smtp-provider": "email"
42691
42887
  });
42888
+ var G711_SCALE_CORRECTION_DB = {
42889
+ PCMU: 20 * Math.log10(4),
42890
+ PCMA: 20 * Math.log10(8)
42891
+ };
42892
+ /**
42893
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42894
+ * same intent on the ITU-T scale (D460).
42895
+ *
42896
+ * ## When this applies, and when it is the wrong thing to reach for
42897
+ *
42898
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42899
+ * them converts:
42900
+ *
42901
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42902
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42903
+ * after. The defect was never in the number; it was that 19 of this hub's
42904
+ * 25 cameras did not obey it. Converting such a number takes something
42905
+ * correct and makes it wrong, in order to preserve a bug.
42906
+ * - **A measurement taken through the old decoder** — a value someone read
42907
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42908
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42909
+ * louder. That is what this function is for.
42910
+ *
42911
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42912
+ * and it cannot be answered from the number. It is answered by the comment the
42913
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42914
+ * mandatory.
42915
+ *
42916
+ * ## Why a function and not a typed-in number
42917
+ *
42918
+ * `-55 + 12.04` written into a source file is, six months later, completely
42919
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42920
+ * keeps the derivation, the law, and the original measurement all visible at
42921
+ * the call site, so a future reader can disagree with the *premise* instead of
42922
+ * having to reverse-engineer the sum.
42923
+ *
42924
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42925
+ * it is declared. It must never be applied to a live sample or a stored
42926
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42927
+ * adjusting numbers the decoder already got right is the original defect with
42928
+ * an extra place to argue with (D459).
42929
+ */
42930
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42931
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42932
+ }
42933
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42692
42934
  /** Schema defaults — an untouched sub-field must author exactly these. */
42693
42935
  var NC_AUDIO_DEFAULTS = {
42694
42936
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-homematic",
3
- "version": "1.2.96",
3
+ "version": "1.2.98",
4
4
  "description": "Homematic / HomematicIP (CCU3 / RaspberryMatic) device-provider addon for CamStack — wraps the nodehomematic library",
5
5
  "keywords": [
6
6
  "camstack",