@camstack/addon-matter-broker 0.2.94 → 0.2.96

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
@@ -5359,6 +5359,86 @@ var ZodIssueCode = {
5359
5359
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5360
5360
  var ZodFirstPartyTypeKind;
5361
5361
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5362
+ //#endregion
5363
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5364
+ /**
5365
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5366
+ * window to float samples (D455).
5367
+ *
5368
+ * ## Why a format at all
5369
+ *
5370
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5371
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5372
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5373
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5374
+ * the plane carried four times the source. The plane crosses hub-main twice on
5375
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5376
+ *
5377
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5378
+ * them where it needs them. That is the same argument D450 made for the rate,
5379
+ * one step further along the same wire.
5380
+ *
5381
+ * ## Why the expansion lives here
5382
+ *
5383
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5384
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5385
+ * `AudioChunkPlane` expands per subscription) and
5386
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5387
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5388
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5389
+ * into their own dist (`self-contained` externals), so this travels with a
5390
+ * `camstack deploy` and needs no published server.
5391
+ *
5392
+ * A second μ-law table anywhere else is the defect this module exists to
5393
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5394
+ * direction for the WebRTC egress — a different transform, not a copy.)
5395
+ *
5396
+ * ## Absent means f32le
5397
+ *
5398
+ * `format` is optional on the wire and its absence means `f32le` — today's
5399
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5400
+ * has always been served, because the broker only emits a coded window to a
5401
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5402
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5403
+ * deployable one addon at a time across three nodes.
5404
+ */
5405
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5406
+ var AUDIO_CHUNK_FORMATS = [
5407
+ "f32le",
5408
+ "pcmu",
5409
+ "pcma"
5410
+ ];
5411
+ /**
5412
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5413
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5414
+ *
5415
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5416
+ * it buffers the coded bytes and the plane's consumers expand.
5417
+ */
5418
+ function buildUlawTable() {
5419
+ const table = new Float32Array(256);
5420
+ for (let i = 0; i < 256; i++) {
5421
+ const complemented = ~i & 255;
5422
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5423
+ const exponent = complemented >> 4 & 7;
5424
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5425
+ }
5426
+ return table;
5427
+ }
5428
+ /** Build the A-law decode table (ITU-T G.711). */
5429
+ function buildAlawTable() {
5430
+ const table = new Float32Array(256);
5431
+ for (let i = 0; i < 256; i++) {
5432
+ const xored = i ^ 85;
5433
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5434
+ const exponent = xored >> 4 & 7;
5435
+ const mantissa = xored & 15;
5436
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5437
+ }
5438
+ return table;
5439
+ }
5440
+ buildUlawTable();
5441
+ buildAlawTable();
5362
5442
  Object.fromEntries([
5363
5443
  {
5364
5444
  id: "overview",
@@ -6651,11 +6731,20 @@ var SubscribeFramesResultSchema = object({
6651
6731
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6652
6732
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6653
6733
  */
6734
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6654
6735
  var DecodedAudioChunkSchema = object({
6655
6736
  data: _instanceof(Uint8Array),
6656
6737
  sampleRate: number().int().positive(),
6657
6738
  channels: number().int().positive(),
6658
- timestamp: number()
6739
+ timestamp: number(),
6740
+ /**
6741
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6742
+ * byte, for any peer that never heard of this field. A coded window
6743
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6744
+ * subscription that DECLARED it accepts one, so absence can never mean
6745
+ * "coded bytes a consumer will read as floats" (D455).
6746
+ */
6747
+ format: AudioChunkFormatSchema.optional()
6659
6748
  });
6660
6749
  /**
6661
6750
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6667,7 +6756,18 @@ var DecodedAudioChunkSchema = object({
6667
6756
  var SubscribeAudioChunksInputSchema = object({
6668
6757
  brokerId: string$2(),
6669
6758
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6670
- tag: string$2().optional()
6759
+ tag: string$2().optional(),
6760
+ /**
6761
+ * Byte formats this subscriber can READ, best first. The broker serves the
6762
+ * chunk's own format when it is in this list and expands to `f32le`
6763
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6764
+ *
6765
+ * Absent (or without the source format) means `f32le` — the behaviour every
6766
+ * subscriber had before D455, unchanged. This is the negotiation half of
6767
+ * the source-bytes lever: it is what lets the broker and its consumers
6768
+ * deploy one at a time across three nodes.
6769
+ */
6770
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6671
6771
  });
6672
6772
  /** Result of `stream-broker.subscribeAudioChunks`. */
6673
6773
  var SubscribeAudioChunksResultSchema = object({
@@ -10655,6 +10755,51 @@ var AudioAnalysisSettingsSchema = object({
10655
10755
  minConfidence: number().min(0).max(1).default(.3),
10656
10756
  allowedClasses: array(string$2()).default([])
10657
10757
  });
10758
+ /**
10759
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10760
+ *
10761
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10762
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10763
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10764
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10765
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10766
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10767
+ * way to the one expansion that feeds the model.
10768
+ *
10769
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10770
+ * window, the per-device node assignment, the settings read) and therefore
10771
+ * still owns the attach/detach pair. It no longer owns the bytes.
10772
+ */
10773
+ var AudioAttachDeviceInputSchema = object({
10774
+ deviceId: number(),
10775
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10776
+ brokerId: string$2(),
10777
+ /**
10778
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10779
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10780
+ * the orchestrator's poller pinned them before the move.
10781
+ */
10782
+ ingestNodeId: string$2(),
10783
+ /**
10784
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10785
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10786
+ * window: a settings change re-attaches, which is what always happened.
10787
+ */
10788
+ settings: AudioAnalysisSettingsSchema
10789
+ });
10790
+ var AudioAttachDeviceResultSchema = object({
10791
+ /** False only when the analyzer is shutting down and refused to attach. */
10792
+ attached: boolean(),
10793
+ /**
10794
+ * True when the attachment replaced a live one for the same device. An
10795
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10796
+ * double the broker's fanout and neither would know about the other.
10797
+ */
10798
+ replaced: boolean()
10799
+ });
10800
+ var AudioDetachDeviceResultSchema = object({
10801
+ /** False when no attachment existed — detach is idempotent. */
10802
+ detached: boolean() });
10658
10803
  var AudioClassificationResultSchema = object({
10659
10804
  labels: array(AudioClassificationLabelSchema).readonly(),
10660
10805
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10663,7 +10808,7 @@ var AudioClassificationResultSchema = object({
10663
10808
  method(object({
10664
10809
  chunk: AudioChunkInputSchema,
10665
10810
  settings: AudioAnalysisSettingsSchema
10666
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string$2() }), {
10811
+ }), 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$2() }), {
10667
10812
  kind: "mutation",
10668
10813
  auth: "admin"
10669
10814
  });
@@ -20633,6 +20778,14 @@ var NativeCropResultSchema = object({
20633
20778
  * set `encodeJpeg: true`; `bytes` is then absent.
20634
20779
  */
20635
20780
  jpeg: string$2().optional(),
20781
+ /**
20782
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20783
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20784
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20785
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20786
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20787
+ */
20788
+ jpegBytes: _instanceof(Uint8Array).optional(),
20636
20789
  width: number().int().positive(),
20637
20790
  height: number().int().positive(),
20638
20791
  /**
@@ -20699,7 +20852,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20699
20852
  })]);
20700
20853
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20701
20854
  var ParkedTrackFrameSchema = object({
20702
- jpeg: string$2(),
20855
+ /**
20856
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20857
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20858
+ * Exactly one of the two is present.
20859
+ */
20860
+ jpeg: string$2().optional(),
20861
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20862
+ jpegBytes: _instanceof(Uint8Array).optional(),
20703
20863
  width: number().int().positive(),
20704
20864
  height: number().int().positive(),
20705
20865
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21286,6 +21446,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21286
21446
  bbox: NativeCropBboxSchema,
21287
21447
  maxWidth: number().int().positive().optional(),
21288
21448
  /**
21449
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21450
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21451
+ * wire — never assume consent: a pre-D462 caller parses the field as
21452
+ * base64 and bytes would decode to garbage rather than fail.
21453
+ */
21454
+ acceptJpegBytes: boolean().optional(),
21455
+ /**
21289
21456
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21290
21457
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21291
21458
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21353,7 +21520,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21353
21520
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21354
21521
  deviceId: number(),
21355
21522
  trackId: string$2(),
21356
- kind: ParkedFrameKindSchema
21523
+ kind: ParkedFrameKindSchema,
21524
+ /**
21525
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21526
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21527
+ * wire — never assume consent: a pre-D462 caller parses the field as
21528
+ * base64 and bytes would decode to garbage rather than fail.
21529
+ */
21530
+ acceptJpegBytes: boolean().optional()
21357
21531
  }), ParkedTrackFrameSchema.nullable()), method(object({
21358
21532
  deviceId: number(),
21359
21533
  trackId: string$2()
@@ -35005,12 +35179,24 @@ Object.freeze({
35005
35179
  addonId: null,
35006
35180
  access: "create"
35007
35181
  },
35182
+ "audioAnalyzer.attachDevice": {
35183
+ capName: "audio-analyzer",
35184
+ capScope: "system",
35185
+ addonId: null,
35186
+ access: "create"
35187
+ },
35008
35188
  "audioAnalyzer.classify": {
35009
35189
  capName: "audio-analyzer",
35010
35190
  capScope: "system",
35011
35191
  addonId: null,
35012
35192
  access: "view"
35013
35193
  },
35194
+ "audioAnalyzer.detachDevice": {
35195
+ capName: "audio-analyzer",
35196
+ capScope: "system",
35197
+ addonId: null,
35198
+ access: "create"
35199
+ },
35014
35200
  "audioAnalyzer.dispose": {
35015
35201
  capName: "audio-analyzer",
35016
35202
  capScope: "system",
@@ -40854,11 +41040,21 @@ Object.freeze({
40854
41040
  form: "single",
40855
41041
  optional: false
40856
41042
  }],
41043
+ "audioAnalyzer.attachDevice": [{
41044
+ name: "deviceId",
41045
+ form: "single",
41046
+ optional: false
41047
+ }],
40857
41048
  "audioAnalyzer.classify": [{
40858
41049
  name: "deviceId",
40859
41050
  form: "single",
40860
41051
  optional: true
40861
41052
  }],
41053
+ "audioAnalyzer.detachDevice": [{
41054
+ name: "deviceId",
41055
+ form: "single",
41056
+ optional: false
41057
+ }],
40862
41058
  "audioMetrics.getCurrentSnapshot": [{
40863
41059
  name: "deviceId",
40864
41060
  form: "single",
@@ -42710,6 +42906,52 @@ Object.freeze({
42710
42906
  "network-access": "ingress",
42711
42907
  "smtp-provider": "email"
42712
42908
  });
42909
+ var G711_SCALE_CORRECTION_DB = {
42910
+ PCMU: 20 * Math.log10(4),
42911
+ PCMA: 20 * Math.log10(8)
42912
+ };
42913
+ /**
42914
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42915
+ * same intent on the ITU-T scale (D460).
42916
+ *
42917
+ * ## When this applies, and when it is the wrong thing to reach for
42918
+ *
42919
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42920
+ * them converts:
42921
+ *
42922
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42923
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42924
+ * after. The defect was never in the number; it was that 19 of this hub's
42925
+ * 25 cameras did not obey it. Converting such a number takes something
42926
+ * correct and makes it wrong, in order to preserve a bug.
42927
+ * - **A measurement taken through the old decoder** — a value someone read
42928
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42929
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42930
+ * louder. That is what this function is for.
42931
+ *
42932
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42933
+ * and it cannot be answered from the number. It is answered by the comment the
42934
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42935
+ * mandatory.
42936
+ *
42937
+ * ## Why a function and not a typed-in number
42938
+ *
42939
+ * `-55 + 12.04` written into a source file is, six months later, completely
42940
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42941
+ * keeps the derivation, the law, and the original measurement all visible at
42942
+ * the call site, so a future reader can disagree with the *premise* instead of
42943
+ * having to reverse-engineer the sum.
42944
+ *
42945
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42946
+ * it is declared. It must never be applied to a live sample or a stored
42947
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42948
+ * adjusting numbers the decoder already got right is the original defect with
42949
+ * an extra place to argue with (D459).
42950
+ */
42951
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42952
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42953
+ }
42954
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42713
42955
  /** Schema defaults — an untouched sub-field must author exactly these. */
42714
42956
  var NC_AUDIO_DEFAULTS = {
42715
42957
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5357,6 +5357,86 @@ var ZodIssueCode = {
5357
5357
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5358
5358
  var ZodFirstPartyTypeKind;
5359
5359
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5360
+ //#endregion
5361
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5362
+ /**
5363
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5364
+ * window to float samples (D455).
5365
+ *
5366
+ * ## Why a format at all
5367
+ *
5368
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5369
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5370
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5371
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5372
+ * the plane carried four times the source. The plane crosses hub-main twice on
5373
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5374
+ *
5375
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5376
+ * them where it needs them. That is the same argument D450 made for the rate,
5377
+ * one step further along the same wire.
5378
+ *
5379
+ * ## Why the expansion lives here
5380
+ *
5381
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5382
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5383
+ * `AudioChunkPlane` expands per subscription) and
5384
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5385
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5386
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5387
+ * into their own dist (`self-contained` externals), so this travels with a
5388
+ * `camstack deploy` and needs no published server.
5389
+ *
5390
+ * A second μ-law table anywhere else is the defect this module exists to
5391
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5392
+ * direction for the WebRTC egress — a different transform, not a copy.)
5393
+ *
5394
+ * ## Absent means f32le
5395
+ *
5396
+ * `format` is optional on the wire and its absence means `f32le` — today's
5397
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5398
+ * has always been served, because the broker only emits a coded window to a
5399
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5400
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5401
+ * deployable one addon at a time across three nodes.
5402
+ */
5403
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5404
+ var AUDIO_CHUNK_FORMATS = [
5405
+ "f32le",
5406
+ "pcmu",
5407
+ "pcma"
5408
+ ];
5409
+ /**
5410
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5411
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5412
+ *
5413
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5414
+ * it buffers the coded bytes and the plane's consumers expand.
5415
+ */
5416
+ function buildUlawTable() {
5417
+ const table = new Float32Array(256);
5418
+ for (let i = 0; i < 256; i++) {
5419
+ const complemented = ~i & 255;
5420
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5421
+ const exponent = complemented >> 4 & 7;
5422
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5423
+ }
5424
+ return table;
5425
+ }
5426
+ /** Build the A-law decode table (ITU-T G.711). */
5427
+ function buildAlawTable() {
5428
+ const table = new Float32Array(256);
5429
+ for (let i = 0; i < 256; i++) {
5430
+ const xored = i ^ 85;
5431
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5432
+ const exponent = xored >> 4 & 7;
5433
+ const mantissa = xored & 15;
5434
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5435
+ }
5436
+ return table;
5437
+ }
5438
+ buildUlawTable();
5439
+ buildAlawTable();
5360
5440
  Object.fromEntries([
5361
5441
  {
5362
5442
  id: "overview",
@@ -6649,11 +6729,20 @@ var SubscribeFramesResultSchema = object({
6649
6729
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6650
6730
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6651
6731
  */
6732
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6652
6733
  var DecodedAudioChunkSchema = object({
6653
6734
  data: _instanceof(Uint8Array),
6654
6735
  sampleRate: number().int().positive(),
6655
6736
  channels: number().int().positive(),
6656
- timestamp: number()
6737
+ timestamp: number(),
6738
+ /**
6739
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6740
+ * byte, for any peer that never heard of this field. A coded window
6741
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6742
+ * subscription that DECLARED it accepts one, so absence can never mean
6743
+ * "coded bytes a consumer will read as floats" (D455).
6744
+ */
6745
+ format: AudioChunkFormatSchema.optional()
6657
6746
  });
6658
6747
  /**
6659
6748
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6665,7 +6754,18 @@ var DecodedAudioChunkSchema = object({
6665
6754
  var SubscribeAudioChunksInputSchema = object({
6666
6755
  brokerId: string$2(),
6667
6756
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6668
- tag: string$2().optional()
6757
+ tag: string$2().optional(),
6758
+ /**
6759
+ * Byte formats this subscriber can READ, best first. The broker serves the
6760
+ * chunk's own format when it is in this list and expands to `f32le`
6761
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6762
+ *
6763
+ * Absent (or without the source format) means `f32le` — the behaviour every
6764
+ * subscriber had before D455, unchanged. This is the negotiation half of
6765
+ * the source-bytes lever: it is what lets the broker and its consumers
6766
+ * deploy one at a time across three nodes.
6767
+ */
6768
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6669
6769
  });
6670
6770
  /** Result of `stream-broker.subscribeAudioChunks`. */
6671
6771
  var SubscribeAudioChunksResultSchema = object({
@@ -10653,6 +10753,51 @@ var AudioAnalysisSettingsSchema = object({
10653
10753
  minConfidence: number().min(0).max(1).default(.3),
10654
10754
  allowedClasses: array(string$2()).default([])
10655
10755
  });
10756
+ /**
10757
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10758
+ *
10759
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10760
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10761
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10762
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10763
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10764
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10765
+ * way to the one expansion that feeds the model.
10766
+ *
10767
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10768
+ * window, the per-device node assignment, the settings read) and therefore
10769
+ * still owns the attach/detach pair. It no longer owns the bytes.
10770
+ */
10771
+ var AudioAttachDeviceInputSchema = object({
10772
+ deviceId: number(),
10773
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10774
+ brokerId: string$2(),
10775
+ /**
10776
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10777
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10778
+ * the orchestrator's poller pinned them before the move.
10779
+ */
10780
+ ingestNodeId: string$2(),
10781
+ /**
10782
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10783
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10784
+ * window: a settings change re-attaches, which is what always happened.
10785
+ */
10786
+ settings: AudioAnalysisSettingsSchema
10787
+ });
10788
+ var AudioAttachDeviceResultSchema = object({
10789
+ /** False only when the analyzer is shutting down and refused to attach. */
10790
+ attached: boolean(),
10791
+ /**
10792
+ * True when the attachment replaced a live one for the same device. An
10793
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10794
+ * double the broker's fanout and neither would know about the other.
10795
+ */
10796
+ replaced: boolean()
10797
+ });
10798
+ var AudioDetachDeviceResultSchema = object({
10799
+ /** False when no attachment existed — detach is idempotent. */
10800
+ detached: boolean() });
10656
10801
  var AudioClassificationResultSchema = object({
10657
10802
  labels: array(AudioClassificationLabelSchema).readonly(),
10658
10803
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10661,7 +10806,7 @@ var AudioClassificationResultSchema = object({
10661
10806
  method(object({
10662
10807
  chunk: AudioChunkInputSchema,
10663
10808
  settings: AudioAnalysisSettingsSchema
10664
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string$2() }), {
10809
+ }), 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$2() }), {
10665
10810
  kind: "mutation",
10666
10811
  auth: "admin"
10667
10812
  });
@@ -20631,6 +20776,14 @@ var NativeCropResultSchema = object({
20631
20776
  * set `encodeJpeg: true`; `bytes` is then absent.
20632
20777
  */
20633
20778
  jpeg: string$2().optional(),
20779
+ /**
20780
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20781
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20782
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20783
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20784
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20785
+ */
20786
+ jpegBytes: _instanceof(Uint8Array).optional(),
20634
20787
  width: number().int().positive(),
20635
20788
  height: number().int().positive(),
20636
20789
  /**
@@ -20697,7 +20850,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20697
20850
  })]);
20698
20851
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20699
20852
  var ParkedTrackFrameSchema = object({
20700
- jpeg: string$2(),
20853
+ /**
20854
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20855
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20856
+ * Exactly one of the two is present.
20857
+ */
20858
+ jpeg: string$2().optional(),
20859
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20860
+ jpegBytes: _instanceof(Uint8Array).optional(),
20701
20861
  width: number().int().positive(),
20702
20862
  height: number().int().positive(),
20703
20863
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21284,6 +21444,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21284
21444
  bbox: NativeCropBboxSchema,
21285
21445
  maxWidth: number().int().positive().optional(),
21286
21446
  /**
21447
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21448
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21449
+ * wire — never assume consent: a pre-D462 caller parses the field as
21450
+ * base64 and bytes would decode to garbage rather than fail.
21451
+ */
21452
+ acceptJpegBytes: boolean().optional(),
21453
+ /**
21287
21454
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21288
21455
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21289
21456
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21351,7 +21518,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21351
21518
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21352
21519
  deviceId: number(),
21353
21520
  trackId: string$2(),
21354
- kind: ParkedFrameKindSchema
21521
+ kind: ParkedFrameKindSchema,
21522
+ /**
21523
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21524
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21525
+ * wire — never assume consent: a pre-D462 caller parses the field as
21526
+ * base64 and bytes would decode to garbage rather than fail.
21527
+ */
21528
+ acceptJpegBytes: boolean().optional()
21355
21529
  }), ParkedTrackFrameSchema.nullable()), method(object({
21356
21530
  deviceId: number(),
21357
21531
  trackId: string$2()
@@ -35003,12 +35177,24 @@ Object.freeze({
35003
35177
  addonId: null,
35004
35178
  access: "create"
35005
35179
  },
35180
+ "audioAnalyzer.attachDevice": {
35181
+ capName: "audio-analyzer",
35182
+ capScope: "system",
35183
+ addonId: null,
35184
+ access: "create"
35185
+ },
35006
35186
  "audioAnalyzer.classify": {
35007
35187
  capName: "audio-analyzer",
35008
35188
  capScope: "system",
35009
35189
  addonId: null,
35010
35190
  access: "view"
35011
35191
  },
35192
+ "audioAnalyzer.detachDevice": {
35193
+ capName: "audio-analyzer",
35194
+ capScope: "system",
35195
+ addonId: null,
35196
+ access: "create"
35197
+ },
35012
35198
  "audioAnalyzer.dispose": {
35013
35199
  capName: "audio-analyzer",
35014
35200
  capScope: "system",
@@ -40852,11 +41038,21 @@ Object.freeze({
40852
41038
  form: "single",
40853
41039
  optional: false
40854
41040
  }],
41041
+ "audioAnalyzer.attachDevice": [{
41042
+ name: "deviceId",
41043
+ form: "single",
41044
+ optional: false
41045
+ }],
40855
41046
  "audioAnalyzer.classify": [{
40856
41047
  name: "deviceId",
40857
41048
  form: "single",
40858
41049
  optional: true
40859
41050
  }],
41051
+ "audioAnalyzer.detachDevice": [{
41052
+ name: "deviceId",
41053
+ form: "single",
41054
+ optional: false
41055
+ }],
40860
41056
  "audioMetrics.getCurrentSnapshot": [{
40861
41057
  name: "deviceId",
40862
41058
  form: "single",
@@ -42708,6 +42904,52 @@ Object.freeze({
42708
42904
  "network-access": "ingress",
42709
42905
  "smtp-provider": "email"
42710
42906
  });
42907
+ var G711_SCALE_CORRECTION_DB = {
42908
+ PCMU: 20 * Math.log10(4),
42909
+ PCMA: 20 * Math.log10(8)
42910
+ };
42911
+ /**
42912
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42913
+ * same intent on the ITU-T scale (D460).
42914
+ *
42915
+ * ## When this applies, and when it is the wrong thing to reach for
42916
+ *
42917
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42918
+ * them converts:
42919
+ *
42920
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42921
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42922
+ * after. The defect was never in the number; it was that 19 of this hub's
42923
+ * 25 cameras did not obey it. Converting such a number takes something
42924
+ * correct and makes it wrong, in order to preserve a bug.
42925
+ * - **A measurement taken through the old decoder** — a value someone read
42926
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42927
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42928
+ * louder. That is what this function is for.
42929
+ *
42930
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42931
+ * and it cannot be answered from the number. It is answered by the comment the
42932
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42933
+ * mandatory.
42934
+ *
42935
+ * ## Why a function and not a typed-in number
42936
+ *
42937
+ * `-55 + 12.04` written into a source file is, six months later, completely
42938
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42939
+ * keeps the derivation, the law, and the original measurement all visible at
42940
+ * the call site, so a future reader can disagree with the *premise* instead of
42941
+ * having to reverse-engineer the sum.
42942
+ *
42943
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42944
+ * it is declared. It must never be applied to a live sample or a stored
42945
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42946
+ * adjusting numbers the decoder already got right is the original defect with
42947
+ * an extra place to argue with (D459).
42948
+ */
42949
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42950
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42951
+ }
42952
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42711
42953
  /** Schema defaults — an untouched sub-field must author exactly these. */
42712
42954
  var NC_AUDIO_DEFAULTS = {
42713
42955
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-matter-broker",
3
- "version": "0.2.94",
3
+ "version": "0.2.96",
4
4
  "description": "Matter broker addon for CamStack — owns a Matter fabric (commissioning + the long-lived controller) via the matter.js controller and brokers commissioned Matter nodes into CamStack",
5
5
  "keywords": [
6
6
  "camstack",