@camstack/addon-provider-dreo 0.2.95 → 0.2.97

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
@@ -5381,6 +5381,86 @@ var ZodIssueCode = {
5381
5381
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5382
5382
  var ZodFirstPartyTypeKind;
5383
5383
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5384
+ //#endregion
5385
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5386
+ /**
5387
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5388
+ * window to float samples (D455).
5389
+ *
5390
+ * ## Why a format at all
5391
+ *
5392
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5393
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5394
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5395
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5396
+ * the plane carried four times the source. The plane crosses hub-main twice on
5397
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5398
+ *
5399
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5400
+ * them where it needs them. That is the same argument D450 made for the rate,
5401
+ * one step further along the same wire.
5402
+ *
5403
+ * ## Why the expansion lives here
5404
+ *
5405
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5406
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5407
+ * `AudioChunkPlane` expands per subscription) and
5408
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5409
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5410
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5411
+ * into their own dist (`self-contained` externals), so this travels with a
5412
+ * `camstack deploy` and needs no published server.
5413
+ *
5414
+ * A second μ-law table anywhere else is the defect this module exists to
5415
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5416
+ * direction for the WebRTC egress — a different transform, not a copy.)
5417
+ *
5418
+ * ## Absent means f32le
5419
+ *
5420
+ * `format` is optional on the wire and its absence means `f32le` — today's
5421
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5422
+ * has always been served, because the broker only emits a coded window to a
5423
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5424
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5425
+ * deployable one addon at a time across three nodes.
5426
+ */
5427
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5428
+ var AUDIO_CHUNK_FORMATS = [
5429
+ "f32le",
5430
+ "pcmu",
5431
+ "pcma"
5432
+ ];
5433
+ /**
5434
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5435
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5436
+ *
5437
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5438
+ * it buffers the coded bytes and the plane's consumers expand.
5439
+ */
5440
+ function buildUlawTable() {
5441
+ const table = new Float32Array(256);
5442
+ for (let i = 0; i < 256; i++) {
5443
+ const complemented = ~i & 255;
5444
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5445
+ const exponent = complemented >> 4 & 7;
5446
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5447
+ }
5448
+ return table;
5449
+ }
5450
+ /** Build the A-law decode table (ITU-T G.711). */
5451
+ function buildAlawTable() {
5452
+ const table = new Float32Array(256);
5453
+ for (let i = 0; i < 256; i++) {
5454
+ const xored = i ^ 85;
5455
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5456
+ const exponent = xored >> 4 & 7;
5457
+ const mantissa = xored & 15;
5458
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5459
+ }
5460
+ return table;
5461
+ }
5462
+ buildUlawTable();
5463
+ buildAlawTable();
5384
5464
  Object.fromEntries([
5385
5465
  {
5386
5466
  id: "overview",
@@ -6673,11 +6753,20 @@ var SubscribeFramesResultSchema = object({
6673
6753
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6674
6754
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6675
6755
  */
6756
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6676
6757
  var DecodedAudioChunkSchema = object({
6677
6758
  data: _instanceof(Uint8Array),
6678
6759
  sampleRate: number().int().positive(),
6679
6760
  channels: number().int().positive(),
6680
- timestamp: number()
6761
+ timestamp: number(),
6762
+ /**
6763
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6764
+ * byte, for any peer that never heard of this field. A coded window
6765
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6766
+ * subscription that DECLARED it accepts one, so absence can never mean
6767
+ * "coded bytes a consumer will read as floats" (D455).
6768
+ */
6769
+ format: AudioChunkFormatSchema.optional()
6681
6770
  });
6682
6771
  /**
6683
6772
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6689,7 +6778,18 @@ var DecodedAudioChunkSchema = object({
6689
6778
  var SubscribeAudioChunksInputSchema = object({
6690
6779
  brokerId: string(),
6691
6780
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6692
- tag: string().optional()
6781
+ tag: string().optional(),
6782
+ /**
6783
+ * Byte formats this subscriber can READ, best first. The broker serves the
6784
+ * chunk's own format when it is in this list and expands to `f32le`
6785
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6786
+ *
6787
+ * Absent (or without the source format) means `f32le` — the behaviour every
6788
+ * subscriber had before D455, unchanged. This is the negotiation half of
6789
+ * the source-bytes lever: it is what lets the broker and its consumers
6790
+ * deploy one at a time across three nodes.
6791
+ */
6792
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6693
6793
  });
6694
6794
  /** Result of `stream-broker.subscribeAudioChunks`. */
6695
6795
  var SubscribeAudioChunksResultSchema = object({
@@ -10677,6 +10777,51 @@ var AudioAnalysisSettingsSchema = object({
10677
10777
  minConfidence: number().min(0).max(1).default(.3),
10678
10778
  allowedClasses: array(string()).default([])
10679
10779
  });
10780
+ /**
10781
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10782
+ *
10783
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10784
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10785
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10786
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10787
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10788
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10789
+ * way to the one expansion that feeds the model.
10790
+ *
10791
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10792
+ * window, the per-device node assignment, the settings read) and therefore
10793
+ * still owns the attach/detach pair. It no longer owns the bytes.
10794
+ */
10795
+ var AudioAttachDeviceInputSchema = object({
10796
+ deviceId: number(),
10797
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10798
+ brokerId: string(),
10799
+ /**
10800
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10801
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10802
+ * the orchestrator's poller pinned them before the move.
10803
+ */
10804
+ ingestNodeId: string(),
10805
+ /**
10806
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10807
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10808
+ * window: a settings change re-attaches, which is what always happened.
10809
+ */
10810
+ settings: AudioAnalysisSettingsSchema
10811
+ });
10812
+ var AudioAttachDeviceResultSchema = object({
10813
+ /** False only when the analyzer is shutting down and refused to attach. */
10814
+ attached: boolean(),
10815
+ /**
10816
+ * True when the attachment replaced a live one for the same device. An
10817
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10818
+ * double the broker's fanout and neither would know about the other.
10819
+ */
10820
+ replaced: boolean()
10821
+ });
10822
+ var AudioDetachDeviceResultSchema = object({
10823
+ /** False when no attachment existed — detach is idempotent. */
10824
+ detached: boolean() });
10680
10825
  var AudioClassificationResultSchema = object({
10681
10826
  labels: array(AudioClassificationLabelSchema).readonly(),
10682
10827
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10685,7 +10830,7 @@ var AudioClassificationResultSchema = object({
10685
10830
  method(object({
10686
10831
  chunk: AudioChunkInputSchema,
10687
10832
  settings: AudioAnalysisSettingsSchema
10688
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10833
+ }), 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() }), {
10689
10834
  kind: "mutation",
10690
10835
  auth: "admin"
10691
10836
  });
@@ -20606,6 +20751,14 @@ var NativeCropResultSchema = object({
20606
20751
  * set `encodeJpeg: true`; `bytes` is then absent.
20607
20752
  */
20608
20753
  jpeg: string().optional(),
20754
+ /**
20755
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20756
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20757
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20758
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20759
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20760
+ */
20761
+ jpegBytes: _instanceof(Uint8Array).optional(),
20609
20762
  width: number().int().positive(),
20610
20763
  height: number().int().positive(),
20611
20764
  /**
@@ -20672,7 +20825,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20672
20825
  })]);
20673
20826
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20674
20827
  var ParkedTrackFrameSchema = object({
20675
- jpeg: string(),
20828
+ /**
20829
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20830
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20831
+ * Exactly one of the two is present.
20832
+ */
20833
+ jpeg: string().optional(),
20834
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20835
+ jpegBytes: _instanceof(Uint8Array).optional(),
20676
20836
  width: number().int().positive(),
20677
20837
  height: number().int().positive(),
20678
20838
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21259,6 +21419,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21259
21419
  bbox: NativeCropBboxSchema,
21260
21420
  maxWidth: number().int().positive().optional(),
21261
21421
  /**
21422
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21423
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21424
+ * wire — never assume consent: a pre-D462 caller parses the field as
21425
+ * base64 and bytes would decode to garbage rather than fail.
21426
+ */
21427
+ acceptJpegBytes: boolean().optional(),
21428
+ /**
21262
21429
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21263
21430
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21264
21431
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21326,7 +21493,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21326
21493
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21327
21494
  deviceId: number(),
21328
21495
  trackId: string(),
21329
- kind: ParkedFrameKindSchema
21496
+ kind: ParkedFrameKindSchema,
21497
+ /**
21498
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21499
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21500
+ * wire — never assume consent: a pre-D462 caller parses the field as
21501
+ * base64 and bytes would decode to garbage rather than fail.
21502
+ */
21503
+ acceptJpegBytes: boolean().optional()
21330
21504
  }), ParkedTrackFrameSchema.nullable()), method(object({
21331
21505
  deviceId: number(),
21332
21506
  trackId: string()
@@ -34969,12 +35143,24 @@ Object.freeze({
34969
35143
  addonId: null,
34970
35144
  access: "create"
34971
35145
  },
35146
+ "audioAnalyzer.attachDevice": {
35147
+ capName: "audio-analyzer",
35148
+ capScope: "system",
35149
+ addonId: null,
35150
+ access: "create"
35151
+ },
34972
35152
  "audioAnalyzer.classify": {
34973
35153
  capName: "audio-analyzer",
34974
35154
  capScope: "system",
34975
35155
  addonId: null,
34976
35156
  access: "view"
34977
35157
  },
35158
+ "audioAnalyzer.detachDevice": {
35159
+ capName: "audio-analyzer",
35160
+ capScope: "system",
35161
+ addonId: null,
35162
+ access: "create"
35163
+ },
34978
35164
  "audioAnalyzer.dispose": {
34979
35165
  capName: "audio-analyzer",
34980
35166
  capScope: "system",
@@ -40818,11 +41004,21 @@ Object.freeze({
40818
41004
  form: "single",
40819
41005
  optional: false
40820
41006
  }],
41007
+ "audioAnalyzer.attachDevice": [{
41008
+ name: "deviceId",
41009
+ form: "single",
41010
+ optional: false
41011
+ }],
40821
41012
  "audioAnalyzer.classify": [{
40822
41013
  name: "deviceId",
40823
41014
  form: "single",
40824
41015
  optional: true
40825
41016
  }],
41017
+ "audioAnalyzer.detachDevice": [{
41018
+ name: "deviceId",
41019
+ form: "single",
41020
+ optional: false
41021
+ }],
40826
41022
  "audioMetrics.getCurrentSnapshot": [{
40827
41023
  name: "deviceId",
40828
41024
  form: "single",
@@ -42674,6 +42870,52 @@ Object.freeze({
42674
42870
  "network-access": "ingress",
42675
42871
  "smtp-provider": "email"
42676
42872
  });
42873
+ var G711_SCALE_CORRECTION_DB = {
42874
+ PCMU: 20 * Math.log10(4),
42875
+ PCMA: 20 * Math.log10(8)
42876
+ };
42877
+ /**
42878
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42879
+ * same intent on the ITU-T scale (D460).
42880
+ *
42881
+ * ## When this applies, and when it is the wrong thing to reach for
42882
+ *
42883
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42884
+ * them converts:
42885
+ *
42886
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42887
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42888
+ * after. The defect was never in the number; it was that 19 of this hub's
42889
+ * 25 cameras did not obey it. Converting such a number takes something
42890
+ * correct and makes it wrong, in order to preserve a bug.
42891
+ * - **A measurement taken through the old decoder** — a value someone read
42892
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42893
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42894
+ * louder. That is what this function is for.
42895
+ *
42896
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42897
+ * and it cannot be answered from the number. It is answered by the comment the
42898
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42899
+ * mandatory.
42900
+ *
42901
+ * ## Why a function and not a typed-in number
42902
+ *
42903
+ * `-55 + 12.04` written into a source file is, six months later, completely
42904
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42905
+ * keeps the derivation, the law, and the original measurement all visible at
42906
+ * the call site, so a future reader can disagree with the *premise* instead of
42907
+ * having to reverse-engineer the sum.
42908
+ *
42909
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42910
+ * it is declared. It must never be applied to a live sample or a stored
42911
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42912
+ * adjusting numbers the decoder already got right is the original defect with
42913
+ * an extra place to argue with (D459).
42914
+ */
42915
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42916
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42917
+ }
42918
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42677
42919
  /** Schema defaults — an untouched sub-field must author exactly these. */
42678
42920
  var NC_AUDIO_DEFAULTS = {
42679
42921
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5382,6 +5382,86 @@ var ZodIssueCode = {
5382
5382
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5383
5383
  var ZodFirstPartyTypeKind;
5384
5384
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5385
+ //#endregion
5386
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5387
+ /**
5388
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5389
+ * window to float samples (D455).
5390
+ *
5391
+ * ## Why a format at all
5392
+ *
5393
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5394
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5395
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5396
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5397
+ * the plane carried four times the source. The plane crosses hub-main twice on
5398
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5399
+ *
5400
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5401
+ * them where it needs them. That is the same argument D450 made for the rate,
5402
+ * one step further along the same wire.
5403
+ *
5404
+ * ## Why the expansion lives here
5405
+ *
5406
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5407
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5408
+ * `AudioChunkPlane` expands per subscription) and
5409
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5410
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5411
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5412
+ * into their own dist (`self-contained` externals), so this travels with a
5413
+ * `camstack deploy` and needs no published server.
5414
+ *
5415
+ * A second μ-law table anywhere else is the defect this module exists to
5416
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5417
+ * direction for the WebRTC egress — a different transform, not a copy.)
5418
+ *
5419
+ * ## Absent means f32le
5420
+ *
5421
+ * `format` is optional on the wire and its absence means `f32le` — today's
5422
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5423
+ * has always been served, because the broker only emits a coded window to a
5424
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5425
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5426
+ * deployable one addon at a time across three nodes.
5427
+ */
5428
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5429
+ var AUDIO_CHUNK_FORMATS = [
5430
+ "f32le",
5431
+ "pcmu",
5432
+ "pcma"
5433
+ ];
5434
+ /**
5435
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5436
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5437
+ *
5438
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5439
+ * it buffers the coded bytes and the plane's consumers expand.
5440
+ */
5441
+ function buildUlawTable() {
5442
+ const table = new Float32Array(256);
5443
+ for (let i = 0; i < 256; i++) {
5444
+ const complemented = ~i & 255;
5445
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5446
+ const exponent = complemented >> 4 & 7;
5447
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5448
+ }
5449
+ return table;
5450
+ }
5451
+ /** Build the A-law decode table (ITU-T G.711). */
5452
+ function buildAlawTable() {
5453
+ const table = new Float32Array(256);
5454
+ for (let i = 0; i < 256; i++) {
5455
+ const xored = i ^ 85;
5456
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5457
+ const exponent = xored >> 4 & 7;
5458
+ const mantissa = xored & 15;
5459
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5460
+ }
5461
+ return table;
5462
+ }
5463
+ buildUlawTable();
5464
+ buildAlawTable();
5385
5465
  Object.fromEntries([
5386
5466
  {
5387
5467
  id: "overview",
@@ -6674,11 +6754,20 @@ var SubscribeFramesResultSchema = object({
6674
6754
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6675
6755
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6676
6756
  */
6757
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6677
6758
  var DecodedAudioChunkSchema = object({
6678
6759
  data: _instanceof(Uint8Array),
6679
6760
  sampleRate: number().int().positive(),
6680
6761
  channels: number().int().positive(),
6681
- timestamp: number()
6762
+ timestamp: number(),
6763
+ /**
6764
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6765
+ * byte, for any peer that never heard of this field. A coded window
6766
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6767
+ * subscription that DECLARED it accepts one, so absence can never mean
6768
+ * "coded bytes a consumer will read as floats" (D455).
6769
+ */
6770
+ format: AudioChunkFormatSchema.optional()
6682
6771
  });
6683
6772
  /**
6684
6773
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6690,7 +6779,18 @@ var DecodedAudioChunkSchema = object({
6690
6779
  var SubscribeAudioChunksInputSchema = object({
6691
6780
  brokerId: string(),
6692
6781
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6693
- tag: string().optional()
6782
+ tag: string().optional(),
6783
+ /**
6784
+ * Byte formats this subscriber can READ, best first. The broker serves the
6785
+ * chunk's own format when it is in this list and expands to `f32le`
6786
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6787
+ *
6788
+ * Absent (or without the source format) means `f32le` — the behaviour every
6789
+ * subscriber had before D455, unchanged. This is the negotiation half of
6790
+ * the source-bytes lever: it is what lets the broker and its consumers
6791
+ * deploy one at a time across three nodes.
6792
+ */
6793
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6694
6794
  });
6695
6795
  /** Result of `stream-broker.subscribeAudioChunks`. */
6696
6796
  var SubscribeAudioChunksResultSchema = object({
@@ -10678,6 +10778,51 @@ var AudioAnalysisSettingsSchema = object({
10678
10778
  minConfidence: number().min(0).max(1).default(.3),
10679
10779
  allowedClasses: array(string()).default([])
10680
10780
  });
10781
+ /**
10782
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10783
+ *
10784
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10785
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10786
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10787
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10788
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10789
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10790
+ * way to the one expansion that feeds the model.
10791
+ *
10792
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10793
+ * window, the per-device node assignment, the settings read) and therefore
10794
+ * still owns the attach/detach pair. It no longer owns the bytes.
10795
+ */
10796
+ var AudioAttachDeviceInputSchema = object({
10797
+ deviceId: number(),
10798
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10799
+ brokerId: string(),
10800
+ /**
10801
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10802
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10803
+ * the orchestrator's poller pinned them before the move.
10804
+ */
10805
+ ingestNodeId: string(),
10806
+ /**
10807
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10808
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10809
+ * window: a settings change re-attaches, which is what always happened.
10810
+ */
10811
+ settings: AudioAnalysisSettingsSchema
10812
+ });
10813
+ var AudioAttachDeviceResultSchema = object({
10814
+ /** False only when the analyzer is shutting down and refused to attach. */
10815
+ attached: boolean(),
10816
+ /**
10817
+ * True when the attachment replaced a live one for the same device. An
10818
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10819
+ * double the broker's fanout and neither would know about the other.
10820
+ */
10821
+ replaced: boolean()
10822
+ });
10823
+ var AudioDetachDeviceResultSchema = object({
10824
+ /** False when no attachment existed — detach is idempotent. */
10825
+ detached: boolean() });
10681
10826
  var AudioClassificationResultSchema = object({
10682
10827
  labels: array(AudioClassificationLabelSchema).readonly(),
10683
10828
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10686,7 +10831,7 @@ var AudioClassificationResultSchema = object({
10686
10831
  method(object({
10687
10832
  chunk: AudioChunkInputSchema,
10688
10833
  settings: AudioAnalysisSettingsSchema
10689
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10834
+ }), 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() }), {
10690
10835
  kind: "mutation",
10691
10836
  auth: "admin"
10692
10837
  });
@@ -20607,6 +20752,14 @@ var NativeCropResultSchema = object({
20607
20752
  * set `encodeJpeg: true`; `bytes` is then absent.
20608
20753
  */
20609
20754
  jpeg: string().optional(),
20755
+ /**
20756
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20757
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20758
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20759
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20760
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20761
+ */
20762
+ jpegBytes: _instanceof(Uint8Array).optional(),
20610
20763
  width: number().int().positive(),
20611
20764
  height: number().int().positive(),
20612
20765
  /**
@@ -20673,7 +20826,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20673
20826
  })]);
20674
20827
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20675
20828
  var ParkedTrackFrameSchema = object({
20676
- jpeg: string(),
20829
+ /**
20830
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20831
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20832
+ * Exactly one of the two is present.
20833
+ */
20834
+ jpeg: string().optional(),
20835
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20836
+ jpegBytes: _instanceof(Uint8Array).optional(),
20677
20837
  width: number().int().positive(),
20678
20838
  height: number().int().positive(),
20679
20839
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21260,6 +21420,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21260
21420
  bbox: NativeCropBboxSchema,
21261
21421
  maxWidth: number().int().positive().optional(),
21262
21422
  /**
21423
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21424
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21425
+ * wire — never assume consent: a pre-D462 caller parses the field as
21426
+ * base64 and bytes would decode to garbage rather than fail.
21427
+ */
21428
+ acceptJpegBytes: boolean().optional(),
21429
+ /**
21263
21430
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21264
21431
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21265
21432
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21327,7 +21494,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21327
21494
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21328
21495
  deviceId: number(),
21329
21496
  trackId: string(),
21330
- kind: ParkedFrameKindSchema
21497
+ kind: ParkedFrameKindSchema,
21498
+ /**
21499
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21500
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21501
+ * wire — never assume consent: a pre-D462 caller parses the field as
21502
+ * base64 and bytes would decode to garbage rather than fail.
21503
+ */
21504
+ acceptJpegBytes: boolean().optional()
21331
21505
  }), ParkedTrackFrameSchema.nullable()), method(object({
21332
21506
  deviceId: number(),
21333
21507
  trackId: string()
@@ -34970,12 +35144,24 @@ Object.freeze({
34970
35144
  addonId: null,
34971
35145
  access: "create"
34972
35146
  },
35147
+ "audioAnalyzer.attachDevice": {
35148
+ capName: "audio-analyzer",
35149
+ capScope: "system",
35150
+ addonId: null,
35151
+ access: "create"
35152
+ },
34973
35153
  "audioAnalyzer.classify": {
34974
35154
  capName: "audio-analyzer",
34975
35155
  capScope: "system",
34976
35156
  addonId: null,
34977
35157
  access: "view"
34978
35158
  },
35159
+ "audioAnalyzer.detachDevice": {
35160
+ capName: "audio-analyzer",
35161
+ capScope: "system",
35162
+ addonId: null,
35163
+ access: "create"
35164
+ },
34979
35165
  "audioAnalyzer.dispose": {
34980
35166
  capName: "audio-analyzer",
34981
35167
  capScope: "system",
@@ -40819,11 +41005,21 @@ Object.freeze({
40819
41005
  form: "single",
40820
41006
  optional: false
40821
41007
  }],
41008
+ "audioAnalyzer.attachDevice": [{
41009
+ name: "deviceId",
41010
+ form: "single",
41011
+ optional: false
41012
+ }],
40822
41013
  "audioAnalyzer.classify": [{
40823
41014
  name: "deviceId",
40824
41015
  form: "single",
40825
41016
  optional: true
40826
41017
  }],
41018
+ "audioAnalyzer.detachDevice": [{
41019
+ name: "deviceId",
41020
+ form: "single",
41021
+ optional: false
41022
+ }],
40827
41023
  "audioMetrics.getCurrentSnapshot": [{
40828
41024
  name: "deviceId",
40829
41025
  form: "single",
@@ -42675,6 +42871,52 @@ Object.freeze({
42675
42871
  "network-access": "ingress",
42676
42872
  "smtp-provider": "email"
42677
42873
  });
42874
+ var G711_SCALE_CORRECTION_DB = {
42875
+ PCMU: 20 * Math.log10(4),
42876
+ PCMA: 20 * Math.log10(8)
42877
+ };
42878
+ /**
42879
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42880
+ * same intent on the ITU-T scale (D460).
42881
+ *
42882
+ * ## When this applies, and when it is the wrong thing to reach for
42883
+ *
42884
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42885
+ * them converts:
42886
+ *
42887
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42888
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42889
+ * after. The defect was never in the number; it was that 19 of this hub's
42890
+ * 25 cameras did not obey it. Converting such a number takes something
42891
+ * correct and makes it wrong, in order to preserve a bug.
42892
+ * - **A measurement taken through the old decoder** — a value someone read
42893
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42894
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42895
+ * louder. That is what this function is for.
42896
+ *
42897
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42898
+ * and it cannot be answered from the number. It is answered by the comment the
42899
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42900
+ * mandatory.
42901
+ *
42902
+ * ## Why a function and not a typed-in number
42903
+ *
42904
+ * `-55 + 12.04` written into a source file is, six months later, completely
42905
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42906
+ * keeps the derivation, the law, and the original measurement all visible at
42907
+ * the call site, so a future reader can disagree with the *premise* instead of
42908
+ * having to reverse-engineer the sum.
42909
+ *
42910
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42911
+ * it is declared. It must never be applied to a live sample or a stored
42912
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42913
+ * adjusting numbers the decoder already got right is the original defect with
42914
+ * an extra place to argue with (D459).
42915
+ */
42916
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42917
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42918
+ }
42919
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42678
42920
  /** Schema defaults — an untouched sub-field must author exactly these. */
42679
42921
  var NC_AUDIO_DEFAULTS = {
42680
42922
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-dreo",
3
- "version": "0.2.95",
3
+ "version": "0.2.97",
4
4
  "description": "Dreo smart-device (fan / air-circulator / purifier / heater / humidifier) device-provider addon for CamStack — wraps the @apocaliss92/nodedreo Dreo cloud client (REST + WebSocket)",
5
5
  "keywords": [
6
6
  "camstack",