@camstack/addon-provider-rademacher 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
@@ -6330,6 +6330,86 @@ var ZodIssueCode = {
6330
6330
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
6331
6331
  var ZodFirstPartyTypeKind;
6332
6332
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6333
+ //#endregion
6334
+ //#region ../types/dist/sleep-BnujYGPe.mjs
6335
+ /**
6336
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
6337
+ * window to float samples (D455).
6338
+ *
6339
+ * ## Why a format at all
6340
+ *
6341
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
6342
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
6343
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
6344
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
6345
+ * the plane carried four times the source. The plane crosses hub-main twice on
6346
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
6347
+ *
6348
+ * So the plane carries the source BYTES too, and whoever needs floats expands
6349
+ * them where it needs them. That is the same argument D450 made for the rate,
6350
+ * one step further along the same wire.
6351
+ *
6352
+ * ## Why the expansion lives here
6353
+ *
6354
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
6355
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
6356
+ * `AudioChunkPlane` expands per subscription) and
6357
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
6358
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
6359
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
6360
+ * into their own dist (`self-contained` externals), so this travels with a
6361
+ * `camstack deploy` and needs no published server.
6362
+ *
6363
+ * A second μ-law table anywhere else is the defect this module exists to
6364
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
6365
+ * direction for the WebRTC egress — a different transform, not a copy.)
6366
+ *
6367
+ * ## Absent means f32le
6368
+ *
6369
+ * `format` is optional on the wire and its absence means `f32le` — today's
6370
+ * bytes, byte for byte. A peer that never heard of the field is served what it
6371
+ * has always been served, because the broker only emits a coded window to a
6372
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
6373
+ * That is the D448 `rawForward` negotiation, and it is what makes this
6374
+ * deployable one addon at a time across three nodes.
6375
+ */
6376
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
6377
+ var AUDIO_CHUNK_FORMATS = [
6378
+ "f32le",
6379
+ "pcmu",
6380
+ "pcma"
6381
+ ];
6382
+ /**
6383
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
6384
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
6385
+ *
6386
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
6387
+ * it buffers the coded bytes and the plane's consumers expand.
6388
+ */
6389
+ function buildUlawTable() {
6390
+ const table = new Float32Array(256);
6391
+ for (let i = 0; i < 256; i++) {
6392
+ const complemented = ~i & 255;
6393
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
6394
+ const exponent = complemented >> 4 & 7;
6395
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
6396
+ }
6397
+ return table;
6398
+ }
6399
+ /** Build the A-law decode table (ITU-T G.711). */
6400
+ function buildAlawTable() {
6401
+ const table = new Float32Array(256);
6402
+ for (let i = 0; i < 256; i++) {
6403
+ const xored = i ^ 85;
6404
+ const sign = (xored & 128) !== 0 ? 1 : -1;
6405
+ const exponent = xored >> 4 & 7;
6406
+ const mantissa = xored & 15;
6407
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
6408
+ }
6409
+ return table;
6410
+ }
6411
+ buildUlawTable();
6412
+ buildAlawTable();
6333
6413
  Object.fromEntries([
6334
6414
  {
6335
6415
  id: "overview",
@@ -7622,11 +7702,20 @@ var SubscribeFramesResultSchema = object({
7622
7702
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
7623
7703
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
7624
7704
  */
7705
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
7625
7706
  var DecodedAudioChunkSchema = object({
7626
7707
  data: _instanceof(Uint8Array),
7627
7708
  sampleRate: number().int().positive(),
7628
7709
  channels: number().int().positive(),
7629
- timestamp: number()
7710
+ timestamp: number(),
7711
+ /**
7712
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
7713
+ * byte, for any peer that never heard of this field. A coded window
7714
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
7715
+ * subscription that DECLARED it accepts one, so absence can never mean
7716
+ * "coded bytes a consumer will read as floats" (D455).
7717
+ */
7718
+ format: AudioChunkFormatSchema.optional()
7630
7719
  });
7631
7720
  /**
7632
7721
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -7638,7 +7727,18 @@ var DecodedAudioChunkSchema = object({
7638
7727
  var SubscribeAudioChunksInputSchema = object({
7639
7728
  brokerId: string(),
7640
7729
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
7641
- tag: string().optional()
7730
+ tag: string().optional(),
7731
+ /**
7732
+ * Byte formats this subscriber can READ, best first. The broker serves the
7733
+ * chunk's own format when it is in this list and expands to `f32le`
7734
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
7735
+ *
7736
+ * Absent (or without the source format) means `f32le` — the behaviour every
7737
+ * subscriber had before D455, unchanged. This is the negotiation half of
7738
+ * the source-bytes lever: it is what lets the broker and its consumers
7739
+ * deploy one at a time across three nodes.
7740
+ */
7741
+ accept: array(AudioChunkFormatSchema).readonly().optional()
7642
7742
  });
7643
7743
  /** Result of `stream-broker.subscribeAudioChunks`. */
7644
7744
  var SubscribeAudioChunksResultSchema = object({
@@ -11626,6 +11726,51 @@ var AudioAnalysisSettingsSchema = object({
11626
11726
  minConfidence: number().min(0).max(1).default(.3),
11627
11727
  allowedClasses: array(string()).default([])
11628
11728
  });
11729
+ /**
11730
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11731
+ *
11732
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11733
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11734
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11735
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11736
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11737
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11738
+ * way to the one expansion that feeds the model.
11739
+ *
11740
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11741
+ * window, the per-device node assignment, the settings read) and therefore
11742
+ * still owns the attach/detach pair. It no longer owns the bytes.
11743
+ */
11744
+ var AudioAttachDeviceInputSchema = object({
11745
+ deviceId: number(),
11746
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11747
+ brokerId: string(),
11748
+ /**
11749
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11750
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11751
+ * the orchestrator's poller pinned them before the move.
11752
+ */
11753
+ ingestNodeId: string(),
11754
+ /**
11755
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11756
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11757
+ * window: a settings change re-attaches, which is what always happened.
11758
+ */
11759
+ settings: AudioAnalysisSettingsSchema
11760
+ });
11761
+ var AudioAttachDeviceResultSchema = object({
11762
+ /** False only when the analyzer is shutting down and refused to attach. */
11763
+ attached: boolean(),
11764
+ /**
11765
+ * True when the attachment replaced a live one for the same device. An
11766
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11767
+ * double the broker's fanout and neither would know about the other.
11768
+ */
11769
+ replaced: boolean()
11770
+ });
11771
+ var AudioDetachDeviceResultSchema = object({
11772
+ /** False when no attachment existed — detach is idempotent. */
11773
+ detached: boolean() });
11629
11774
  var AudioClassificationResultSchema = object({
11630
11775
  labels: array(AudioClassificationLabelSchema).readonly(),
11631
11776
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11634,7 +11779,7 @@ var AudioClassificationResultSchema = object({
11634
11779
  method(object({
11635
11780
  chunk: AudioChunkInputSchema,
11636
11781
  settings: AudioAnalysisSettingsSchema
11637
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11782
+ }), 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() }), {
11638
11783
  kind: "mutation",
11639
11784
  auth: "admin"
11640
11785
  });
@@ -21538,6 +21683,14 @@ var NativeCropResultSchema = object({
21538
21683
  * set `encodeJpeg: true`; `bytes` is then absent.
21539
21684
  */
21540
21685
  jpeg: string().optional(),
21686
+ /**
21687
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21688
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21689
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21690
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21691
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21692
+ */
21693
+ jpegBytes: _instanceof(Uint8Array).optional(),
21541
21694
  width: number().int().positive(),
21542
21695
  height: number().int().positive(),
21543
21696
  /**
@@ -21604,7 +21757,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21604
21757
  })]);
21605
21758
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21606
21759
  var ParkedTrackFrameSchema = object({
21607
- jpeg: string(),
21760
+ /**
21761
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21762
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21763
+ * Exactly one of the two is present.
21764
+ */
21765
+ jpeg: string().optional(),
21766
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21767
+ jpegBytes: _instanceof(Uint8Array).optional(),
21608
21768
  width: number().int().positive(),
21609
21769
  height: number().int().positive(),
21610
21770
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -22191,6 +22351,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22191
22351
  bbox: NativeCropBboxSchema,
22192
22352
  maxWidth: number().int().positive().optional(),
22193
22353
  /**
22354
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22355
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22356
+ * wire — never assume consent: a pre-D462 caller parses the field as
22357
+ * base64 and bytes would decode to garbage rather than fail.
22358
+ */
22359
+ acceptJpegBytes: boolean().optional(),
22360
+ /**
22194
22361
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
22195
22362
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
22196
22363
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -22258,7 +22425,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22258
22425
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
22259
22426
  deviceId: number(),
22260
22427
  trackId: string(),
22261
- kind: ParkedFrameKindSchema
22428
+ kind: ParkedFrameKindSchema,
22429
+ /**
22430
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22431
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22432
+ * wire — never assume consent: a pre-D462 caller parses the field as
22433
+ * base64 and bytes would decode to garbage rather than fail.
22434
+ */
22435
+ acceptJpegBytes: boolean().optional()
22262
22436
  }), ParkedTrackFrameSchema.nullable()), method(object({
22263
22437
  deviceId: number(),
22264
22438
  trackId: string()
@@ -35893,12 +36067,24 @@ Object.freeze({
35893
36067
  addonId: null,
35894
36068
  access: "create"
35895
36069
  },
36070
+ "audioAnalyzer.attachDevice": {
36071
+ capName: "audio-analyzer",
36072
+ capScope: "system",
36073
+ addonId: null,
36074
+ access: "create"
36075
+ },
35896
36076
  "audioAnalyzer.classify": {
35897
36077
  capName: "audio-analyzer",
35898
36078
  capScope: "system",
35899
36079
  addonId: null,
35900
36080
  access: "view"
35901
36081
  },
36082
+ "audioAnalyzer.detachDevice": {
36083
+ capName: "audio-analyzer",
36084
+ capScope: "system",
36085
+ addonId: null,
36086
+ access: "create"
36087
+ },
35902
36088
  "audioAnalyzer.dispose": {
35903
36089
  capName: "audio-analyzer",
35904
36090
  capScope: "system",
@@ -41742,11 +41928,21 @@ Object.freeze({
41742
41928
  form: "single",
41743
41929
  optional: false
41744
41930
  }],
41931
+ "audioAnalyzer.attachDevice": [{
41932
+ name: "deviceId",
41933
+ form: "single",
41934
+ optional: false
41935
+ }],
41745
41936
  "audioAnalyzer.classify": [{
41746
41937
  name: "deviceId",
41747
41938
  form: "single",
41748
41939
  optional: true
41749
41940
  }],
41941
+ "audioAnalyzer.detachDevice": [{
41942
+ name: "deviceId",
41943
+ form: "single",
41944
+ optional: false
41945
+ }],
41750
41946
  "audioMetrics.getCurrentSnapshot": [{
41751
41947
  name: "deviceId",
41752
41948
  form: "single",
@@ -43598,6 +43794,52 @@ Object.freeze({
43598
43794
  "network-access": "ingress",
43599
43795
  "smtp-provider": "email"
43600
43796
  });
43797
+ var G711_SCALE_CORRECTION_DB = {
43798
+ PCMU: 20 * Math.log10(4),
43799
+ PCMA: 20 * Math.log10(8)
43800
+ };
43801
+ /**
43802
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43803
+ * same intent on the ITU-T scale (D460).
43804
+ *
43805
+ * ## When this applies, and when it is the wrong thing to reach for
43806
+ *
43807
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43808
+ * them converts:
43809
+ *
43810
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43811
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43812
+ * after. The defect was never in the number; it was that 19 of this hub's
43813
+ * 25 cameras did not obey it. Converting such a number takes something
43814
+ * correct and makes it wrong, in order to preserve a bug.
43815
+ * - **A measurement taken through the old decoder** — a value someone read
43816
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43817
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43818
+ * louder. That is what this function is for.
43819
+ *
43820
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43821
+ * and it cannot be answered from the number. It is answered by the comment the
43822
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43823
+ * mandatory.
43824
+ *
43825
+ * ## Why a function and not a typed-in number
43826
+ *
43827
+ * `-55 + 12.04` written into a source file is, six months later, completely
43828
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43829
+ * keeps the derivation, the law, and the original measurement all visible at
43830
+ * the call site, so a future reader can disagree with the *premise* instead of
43831
+ * having to reverse-engineer the sum.
43832
+ *
43833
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43834
+ * it is declared. It must never be applied to a live sample or a stored
43835
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43836
+ * adjusting numbers the decoder already got right is the original defect with
43837
+ * an extra place to argue with (D459).
43838
+ */
43839
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43840
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43841
+ }
43842
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43601
43843
  /** Schema defaults — an untouched sub-field must author exactly these. */
43602
43844
  var NC_AUDIO_DEFAULTS = {
43603
43845
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -6329,6 +6329,86 @@ var ZodIssueCode = {
6329
6329
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
6330
6330
  var ZodFirstPartyTypeKind;
6331
6331
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6332
+ //#endregion
6333
+ //#region ../types/dist/sleep-BnujYGPe.mjs
6334
+ /**
6335
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
6336
+ * window to float samples (D455).
6337
+ *
6338
+ * ## Why a format at all
6339
+ *
6340
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
6341
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
6342
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
6343
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
6344
+ * the plane carried four times the source. The plane crosses hub-main twice on
6345
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
6346
+ *
6347
+ * So the plane carries the source BYTES too, and whoever needs floats expands
6348
+ * them where it needs them. That is the same argument D450 made for the rate,
6349
+ * one step further along the same wire.
6350
+ *
6351
+ * ## Why the expansion lives here
6352
+ *
6353
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
6354
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
6355
+ * `AudioChunkPlane` expands per subscription) and
6356
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
6357
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
6358
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
6359
+ * into their own dist (`self-contained` externals), so this travels with a
6360
+ * `camstack deploy` and needs no published server.
6361
+ *
6362
+ * A second μ-law table anywhere else is the defect this module exists to
6363
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
6364
+ * direction for the WebRTC egress — a different transform, not a copy.)
6365
+ *
6366
+ * ## Absent means f32le
6367
+ *
6368
+ * `format` is optional on the wire and its absence means `f32le` — today's
6369
+ * bytes, byte for byte. A peer that never heard of the field is served what it
6370
+ * has always been served, because the broker only emits a coded window to a
6371
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
6372
+ * That is the D448 `rawForward` negotiation, and it is what makes this
6373
+ * deployable one addon at a time across three nodes.
6374
+ */
6375
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
6376
+ var AUDIO_CHUNK_FORMATS = [
6377
+ "f32le",
6378
+ "pcmu",
6379
+ "pcma"
6380
+ ];
6381
+ /**
6382
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
6383
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
6384
+ *
6385
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
6386
+ * it buffers the coded bytes and the plane's consumers expand.
6387
+ */
6388
+ function buildUlawTable() {
6389
+ const table = new Float32Array(256);
6390
+ for (let i = 0; i < 256; i++) {
6391
+ const complemented = ~i & 255;
6392
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
6393
+ const exponent = complemented >> 4 & 7;
6394
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
6395
+ }
6396
+ return table;
6397
+ }
6398
+ /** Build the A-law decode table (ITU-T G.711). */
6399
+ function buildAlawTable() {
6400
+ const table = new Float32Array(256);
6401
+ for (let i = 0; i < 256; i++) {
6402
+ const xored = i ^ 85;
6403
+ const sign = (xored & 128) !== 0 ? 1 : -1;
6404
+ const exponent = xored >> 4 & 7;
6405
+ const mantissa = xored & 15;
6406
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
6407
+ }
6408
+ return table;
6409
+ }
6410
+ buildUlawTable();
6411
+ buildAlawTable();
6332
6412
  Object.fromEntries([
6333
6413
  {
6334
6414
  id: "overview",
@@ -7621,11 +7701,20 @@ var SubscribeFramesResultSchema = object({
7621
7701
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
7622
7702
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
7623
7703
  */
7704
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
7624
7705
  var DecodedAudioChunkSchema = object({
7625
7706
  data: _instanceof(Uint8Array),
7626
7707
  sampleRate: number().int().positive(),
7627
7708
  channels: number().int().positive(),
7628
- timestamp: number()
7709
+ timestamp: number(),
7710
+ /**
7711
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
7712
+ * byte, for any peer that never heard of this field. A coded window
7713
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
7714
+ * subscription that DECLARED it accepts one, so absence can never mean
7715
+ * "coded bytes a consumer will read as floats" (D455).
7716
+ */
7717
+ format: AudioChunkFormatSchema.optional()
7629
7718
  });
7630
7719
  /**
7631
7720
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -7637,7 +7726,18 @@ var DecodedAudioChunkSchema = object({
7637
7726
  var SubscribeAudioChunksInputSchema = object({
7638
7727
  brokerId: string(),
7639
7728
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
7640
- tag: string().optional()
7729
+ tag: string().optional(),
7730
+ /**
7731
+ * Byte formats this subscriber can READ, best first. The broker serves the
7732
+ * chunk's own format when it is in this list and expands to `f32le`
7733
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
7734
+ *
7735
+ * Absent (or without the source format) means `f32le` — the behaviour every
7736
+ * subscriber had before D455, unchanged. This is the negotiation half of
7737
+ * the source-bytes lever: it is what lets the broker and its consumers
7738
+ * deploy one at a time across three nodes.
7739
+ */
7740
+ accept: array(AudioChunkFormatSchema).readonly().optional()
7641
7741
  });
7642
7742
  /** Result of `stream-broker.subscribeAudioChunks`. */
7643
7743
  var SubscribeAudioChunksResultSchema = object({
@@ -11625,6 +11725,51 @@ var AudioAnalysisSettingsSchema = object({
11625
11725
  minConfidence: number().min(0).max(1).default(.3),
11626
11726
  allowedClasses: array(string()).default([])
11627
11727
  });
11728
+ /**
11729
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11730
+ *
11731
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11732
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11733
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11734
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11735
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11736
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11737
+ * way to the one expansion that feeds the model.
11738
+ *
11739
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11740
+ * window, the per-device node assignment, the settings read) and therefore
11741
+ * still owns the attach/detach pair. It no longer owns the bytes.
11742
+ */
11743
+ var AudioAttachDeviceInputSchema = object({
11744
+ deviceId: number(),
11745
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11746
+ brokerId: string(),
11747
+ /**
11748
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11749
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11750
+ * the orchestrator's poller pinned them before the move.
11751
+ */
11752
+ ingestNodeId: string(),
11753
+ /**
11754
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11755
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11756
+ * window: a settings change re-attaches, which is what always happened.
11757
+ */
11758
+ settings: AudioAnalysisSettingsSchema
11759
+ });
11760
+ var AudioAttachDeviceResultSchema = object({
11761
+ /** False only when the analyzer is shutting down and refused to attach. */
11762
+ attached: boolean(),
11763
+ /**
11764
+ * True when the attachment replaced a live one for the same device. An
11765
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11766
+ * double the broker's fanout and neither would know about the other.
11767
+ */
11768
+ replaced: boolean()
11769
+ });
11770
+ var AudioDetachDeviceResultSchema = object({
11771
+ /** False when no attachment existed — detach is idempotent. */
11772
+ detached: boolean() });
11628
11773
  var AudioClassificationResultSchema = object({
11629
11774
  labels: array(AudioClassificationLabelSchema).readonly(),
11630
11775
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11633,7 +11778,7 @@ var AudioClassificationResultSchema = object({
11633
11778
  method(object({
11634
11779
  chunk: AudioChunkInputSchema,
11635
11780
  settings: AudioAnalysisSettingsSchema
11636
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11781
+ }), 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() }), {
11637
11782
  kind: "mutation",
11638
11783
  auth: "admin"
11639
11784
  });
@@ -21537,6 +21682,14 @@ var NativeCropResultSchema = object({
21537
21682
  * set `encodeJpeg: true`; `bytes` is then absent.
21538
21683
  */
21539
21684
  jpeg: string().optional(),
21685
+ /**
21686
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21687
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21688
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21689
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21690
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21691
+ */
21692
+ jpegBytes: _instanceof(Uint8Array).optional(),
21540
21693
  width: number().int().positive(),
21541
21694
  height: number().int().positive(),
21542
21695
  /**
@@ -21603,7 +21756,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21603
21756
  })]);
21604
21757
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21605
21758
  var ParkedTrackFrameSchema = object({
21606
- jpeg: string(),
21759
+ /**
21760
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21761
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21762
+ * Exactly one of the two is present.
21763
+ */
21764
+ jpeg: string().optional(),
21765
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21766
+ jpegBytes: _instanceof(Uint8Array).optional(),
21607
21767
  width: number().int().positive(),
21608
21768
  height: number().int().positive(),
21609
21769
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -22190,6 +22350,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22190
22350
  bbox: NativeCropBboxSchema,
22191
22351
  maxWidth: number().int().positive().optional(),
22192
22352
  /**
22353
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22354
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22355
+ * wire — never assume consent: a pre-D462 caller parses the field as
22356
+ * base64 and bytes would decode to garbage rather than fail.
22357
+ */
22358
+ acceptJpegBytes: boolean().optional(),
22359
+ /**
22193
22360
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
22194
22361
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
22195
22362
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -22257,7 +22424,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22257
22424
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
22258
22425
  deviceId: number(),
22259
22426
  trackId: string(),
22260
- kind: ParkedFrameKindSchema
22427
+ kind: ParkedFrameKindSchema,
22428
+ /**
22429
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22430
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22431
+ * wire — never assume consent: a pre-D462 caller parses the field as
22432
+ * base64 and bytes would decode to garbage rather than fail.
22433
+ */
22434
+ acceptJpegBytes: boolean().optional()
22261
22435
  }), ParkedTrackFrameSchema.nullable()), method(object({
22262
22436
  deviceId: number(),
22263
22437
  trackId: string()
@@ -35892,12 +36066,24 @@ Object.freeze({
35892
36066
  addonId: null,
35893
36067
  access: "create"
35894
36068
  },
36069
+ "audioAnalyzer.attachDevice": {
36070
+ capName: "audio-analyzer",
36071
+ capScope: "system",
36072
+ addonId: null,
36073
+ access: "create"
36074
+ },
35895
36075
  "audioAnalyzer.classify": {
35896
36076
  capName: "audio-analyzer",
35897
36077
  capScope: "system",
35898
36078
  addonId: null,
35899
36079
  access: "view"
35900
36080
  },
36081
+ "audioAnalyzer.detachDevice": {
36082
+ capName: "audio-analyzer",
36083
+ capScope: "system",
36084
+ addonId: null,
36085
+ access: "create"
36086
+ },
35901
36087
  "audioAnalyzer.dispose": {
35902
36088
  capName: "audio-analyzer",
35903
36089
  capScope: "system",
@@ -41741,11 +41927,21 @@ Object.freeze({
41741
41927
  form: "single",
41742
41928
  optional: false
41743
41929
  }],
41930
+ "audioAnalyzer.attachDevice": [{
41931
+ name: "deviceId",
41932
+ form: "single",
41933
+ optional: false
41934
+ }],
41744
41935
  "audioAnalyzer.classify": [{
41745
41936
  name: "deviceId",
41746
41937
  form: "single",
41747
41938
  optional: true
41748
41939
  }],
41940
+ "audioAnalyzer.detachDevice": [{
41941
+ name: "deviceId",
41942
+ form: "single",
41943
+ optional: false
41944
+ }],
41749
41945
  "audioMetrics.getCurrentSnapshot": [{
41750
41946
  name: "deviceId",
41751
41947
  form: "single",
@@ -43597,6 +43793,52 @@ Object.freeze({
43597
43793
  "network-access": "ingress",
43598
43794
  "smtp-provider": "email"
43599
43795
  });
43796
+ var G711_SCALE_CORRECTION_DB = {
43797
+ PCMU: 20 * Math.log10(4),
43798
+ PCMA: 20 * Math.log10(8)
43799
+ };
43800
+ /**
43801
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43802
+ * same intent on the ITU-T scale (D460).
43803
+ *
43804
+ * ## When this applies, and when it is the wrong thing to reach for
43805
+ *
43806
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43807
+ * them converts:
43808
+ *
43809
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43810
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43811
+ * after. The defect was never in the number; it was that 19 of this hub's
43812
+ * 25 cameras did not obey it. Converting such a number takes something
43813
+ * correct and makes it wrong, in order to preserve a bug.
43814
+ * - **A measurement taken through the old decoder** — a value someone read
43815
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43816
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43817
+ * louder. That is what this function is for.
43818
+ *
43819
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43820
+ * and it cannot be answered from the number. It is answered by the comment the
43821
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43822
+ * mandatory.
43823
+ *
43824
+ * ## Why a function and not a typed-in number
43825
+ *
43826
+ * `-55 + 12.04` written into a source file is, six months later, completely
43827
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43828
+ * keeps the derivation, the law, and the original measurement all visible at
43829
+ * the call site, so a future reader can disagree with the *premise* instead of
43830
+ * having to reverse-engineer the sum.
43831
+ *
43832
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43833
+ * it is declared. It must never be applied to a live sample or a stored
43834
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43835
+ * adjusting numbers the decoder already got right is the original defect with
43836
+ * an extra place to argue with (D459).
43837
+ */
43838
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43839
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43840
+ }
43841
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43600
43842
  /** Schema defaults — an untouched sub-field must author exactly these. */
43601
43843
  var NC_AUDIO_DEFAULTS = {
43602
43844
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-rademacher",
3
- "version": "0.2.94",
3
+ "version": "0.2.96",
4
4
  "description": "Rademacher HomePilot device-provider addon for CamStack — wraps the @apocaliss92/noderademacher local-hub client (roller shutters over the cover cap)",
5
5
  "keywords": [
6
6
  "camstack",