@camstack/addon-notifiers 1.2.98 → 1.2.100

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
@@ -5375,6 +5375,86 @@ var ZodIssueCode = {
5375
5375
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5376
5376
  var ZodFirstPartyTypeKind;
5377
5377
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5378
+ //#endregion
5379
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5380
+ /**
5381
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5382
+ * window to float samples (D455).
5383
+ *
5384
+ * ## Why a format at all
5385
+ *
5386
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5387
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5388
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5389
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5390
+ * the plane carried four times the source. The plane crosses hub-main twice on
5391
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5392
+ *
5393
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5394
+ * them where it needs them. That is the same argument D450 made for the rate,
5395
+ * one step further along the same wire.
5396
+ *
5397
+ * ## Why the expansion lives here
5398
+ *
5399
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5400
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5401
+ * `AudioChunkPlane` expands per subscription) and
5402
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5403
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5404
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5405
+ * into their own dist (`self-contained` externals), so this travels with a
5406
+ * `camstack deploy` and needs no published server.
5407
+ *
5408
+ * A second μ-law table anywhere else is the defect this module exists to
5409
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5410
+ * direction for the WebRTC egress — a different transform, not a copy.)
5411
+ *
5412
+ * ## Absent means f32le
5413
+ *
5414
+ * `format` is optional on the wire and its absence means `f32le` — today's
5415
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5416
+ * has always been served, because the broker only emits a coded window to a
5417
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5418
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5419
+ * deployable one addon at a time across three nodes.
5420
+ */
5421
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5422
+ var AUDIO_CHUNK_FORMATS = [
5423
+ "f32le",
5424
+ "pcmu",
5425
+ "pcma"
5426
+ ];
5427
+ /**
5428
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5429
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5430
+ *
5431
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5432
+ * it buffers the coded bytes and the plane's consumers expand.
5433
+ */
5434
+ function buildUlawTable() {
5435
+ const table = new Float32Array(256);
5436
+ for (let i = 0; i < 256; i++) {
5437
+ const complemented = ~i & 255;
5438
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5439
+ const exponent = complemented >> 4 & 7;
5440
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5441
+ }
5442
+ return table;
5443
+ }
5444
+ /** Build the A-law decode table (ITU-T G.711). */
5445
+ function buildAlawTable() {
5446
+ const table = new Float32Array(256);
5447
+ for (let i = 0; i < 256; i++) {
5448
+ const xored = i ^ 85;
5449
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5450
+ const exponent = xored >> 4 & 7;
5451
+ const mantissa = xored & 15;
5452
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5453
+ }
5454
+ return table;
5455
+ }
5456
+ buildUlawTable();
5457
+ buildAlawTable();
5378
5458
  Object.fromEntries([
5379
5459
  {
5380
5460
  id: "overview",
@@ -6667,11 +6747,20 @@ var SubscribeFramesResultSchema = object({
6667
6747
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6668
6748
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6669
6749
  */
6750
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6670
6751
  var DecodedAudioChunkSchema = object({
6671
6752
  data: _instanceof(Uint8Array),
6672
6753
  sampleRate: number().int().positive(),
6673
6754
  channels: number().int().positive(),
6674
- timestamp: number()
6755
+ timestamp: number(),
6756
+ /**
6757
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6758
+ * byte, for any peer that never heard of this field. A coded window
6759
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6760
+ * subscription that DECLARED it accepts one, so absence can never mean
6761
+ * "coded bytes a consumer will read as floats" (D455).
6762
+ */
6763
+ format: AudioChunkFormatSchema.optional()
6675
6764
  });
6676
6765
  /**
6677
6766
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6683,7 +6772,18 @@ var DecodedAudioChunkSchema = object({
6683
6772
  var SubscribeAudioChunksInputSchema = object({
6684
6773
  brokerId: string(),
6685
6774
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6686
- tag: string().optional()
6775
+ tag: string().optional(),
6776
+ /**
6777
+ * Byte formats this subscriber can READ, best first. The broker serves the
6778
+ * chunk's own format when it is in this list and expands to `f32le`
6779
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6780
+ *
6781
+ * Absent (or without the source format) means `f32le` — the behaviour every
6782
+ * subscriber had before D455, unchanged. This is the negotiation half of
6783
+ * the source-bytes lever: it is what lets the broker and its consumers
6784
+ * deploy one at a time across three nodes.
6785
+ */
6786
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6687
6787
  });
6688
6788
  /** Result of `stream-broker.subscribeAudioChunks`. */
6689
6789
  var SubscribeAudioChunksResultSchema = object({
@@ -10793,6 +10893,51 @@ var AudioAnalysisSettingsSchema = object({
10793
10893
  minConfidence: number().min(0).max(1).default(.3),
10794
10894
  allowedClasses: array(string()).default([])
10795
10895
  });
10896
+ /**
10897
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10898
+ *
10899
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10900
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10901
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10902
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10903
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10904
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10905
+ * way to the one expansion that feeds the model.
10906
+ *
10907
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10908
+ * window, the per-device node assignment, the settings read) and therefore
10909
+ * still owns the attach/detach pair. It no longer owns the bytes.
10910
+ */
10911
+ var AudioAttachDeviceInputSchema = object({
10912
+ deviceId: number(),
10913
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10914
+ brokerId: string(),
10915
+ /**
10916
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10917
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10918
+ * the orchestrator's poller pinned them before the move.
10919
+ */
10920
+ ingestNodeId: string(),
10921
+ /**
10922
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10923
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10924
+ * window: a settings change re-attaches, which is what always happened.
10925
+ */
10926
+ settings: AudioAnalysisSettingsSchema
10927
+ });
10928
+ var AudioAttachDeviceResultSchema = object({
10929
+ /** False only when the analyzer is shutting down and refused to attach. */
10930
+ attached: boolean(),
10931
+ /**
10932
+ * True when the attachment replaced a live one for the same device. An
10933
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10934
+ * double the broker's fanout and neither would know about the other.
10935
+ */
10936
+ replaced: boolean()
10937
+ });
10938
+ var AudioDetachDeviceResultSchema = object({
10939
+ /** False when no attachment existed — detach is idempotent. */
10940
+ detached: boolean() });
10796
10941
  var AudioClassificationResultSchema = object({
10797
10942
  labels: array(AudioClassificationLabelSchema).readonly(),
10798
10943
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10801,7 +10946,7 @@ var AudioClassificationResultSchema = object({
10801
10946
  method(object({
10802
10947
  chunk: AudioChunkInputSchema,
10803
10948
  settings: AudioAnalysisSettingsSchema
10804
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10949
+ }), 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() }), {
10805
10950
  kind: "mutation",
10806
10951
  auth: "admin"
10807
10952
  });
@@ -24963,8 +25108,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
24963
25108
  *
24964
25109
  * An **empty array reads NOTHING** — `[]` is an empty page, never
24965
25110
  * "every camera". A request for no devices is a request, not an
24966
- * omission; same contract as `deviceManager.listFleet` and
24967
- * `pipelineAnalytics.listRecentTracks`.
25111
+ * omission; same contract as `deviceManager.listAll`'s `deviceIds`
25112
+ * and `pipelineAnalytics.listRecentTracks`.
24968
25113
  *
24969
25114
  * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
24970
25115
  */
@@ -30732,12 +30877,24 @@ Object.freeze({
30732
30877
  addonId: null,
30733
30878
  access: "create"
30734
30879
  },
30880
+ "audioAnalyzer.attachDevice": {
30881
+ capName: "audio-analyzer",
30882
+ capScope: "system",
30883
+ addonId: null,
30884
+ access: "create"
30885
+ },
30735
30886
  "audioAnalyzer.classify": {
30736
30887
  capName: "audio-analyzer",
30737
30888
  capScope: "system",
30738
30889
  addonId: null,
30739
30890
  access: "view"
30740
30891
  },
30892
+ "audioAnalyzer.detachDevice": {
30893
+ capName: "audio-analyzer",
30894
+ capScope: "system",
30895
+ addonId: null,
30896
+ access: "create"
30897
+ },
30741
30898
  "audioAnalyzer.dispose": {
30742
30899
  capName: "audio-analyzer",
30743
30900
  capScope: "system",
@@ -36581,11 +36738,21 @@ Object.freeze({
36581
36738
  form: "single",
36582
36739
  optional: false
36583
36740
  }],
36741
+ "audioAnalyzer.attachDevice": [{
36742
+ name: "deviceId",
36743
+ form: "single",
36744
+ optional: false
36745
+ }],
36584
36746
  "audioAnalyzer.classify": [{
36585
36747
  name: "deviceId",
36586
36748
  form: "single",
36587
36749
  optional: true
36588
36750
  }],
36751
+ "audioAnalyzer.detachDevice": [{
36752
+ name: "deviceId",
36753
+ form: "single",
36754
+ optional: false
36755
+ }],
36589
36756
  "audioMetrics.getCurrentSnapshot": [{
36590
36757
  name: "deviceId",
36591
36758
  form: "single",
@@ -38437,6 +38604,52 @@ Object.freeze({
38437
38604
  "network-access": "ingress",
38438
38605
  "smtp-provider": "email"
38439
38606
  });
38607
+ var G711_SCALE_CORRECTION_DB = {
38608
+ PCMU: 20 * Math.log10(4),
38609
+ PCMA: 20 * Math.log10(8)
38610
+ };
38611
+ /**
38612
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
38613
+ * same intent on the ITU-T scale (D460).
38614
+ *
38615
+ * ## When this applies, and when it is the wrong thing to reach for
38616
+ *
38617
+ * An absolute-dBFS number in this repo is one of two things, and only one of
38618
+ * them converts:
38619
+ *
38620
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
38621
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
38622
+ * after. The defect was never in the number; it was that 19 of this hub's
38623
+ * 25 cameras did not obey it. Converting such a number takes something
38624
+ * correct and makes it wrong, in order to preserve a bug.
38625
+ * - **A measurement taken through the old decoder** — a value someone read
38626
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
38627
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
38628
+ * louder. That is what this function is for.
38629
+ *
38630
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
38631
+ * and it cannot be answered from the number. It is answered by the comment the
38632
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
38633
+ * mandatory.
38634
+ *
38635
+ * ## Why a function and not a typed-in number
38636
+ *
38637
+ * `-55 + 12.04` written into a source file is, six months later, completely
38638
+ * indistinguishable from a threshold somebody simply preferred. Calling this
38639
+ * keeps the derivation, the law, and the original measurement all visible at
38640
+ * the call site, so a future reader can disagree with the *premise* instead of
38641
+ * having to reverse-engineer the sum.
38642
+ *
38643
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
38644
+ * it is declared. It must never be applied to a live sample or a stored
38645
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
38646
+ * adjusting numbers the decoder already got right is the original defect with
38647
+ * an extra place to argue with (D459).
38648
+ */
38649
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
38650
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
38651
+ }
38652
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
38440
38653
  /** Schema defaults — an untouched sub-field must author exactly these. */
38441
38654
  var NC_AUDIO_DEFAULTS = {
38442
38655
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5348,6 +5348,86 @@ var ZodIssueCode = {
5348
5348
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5349
5349
  var ZodFirstPartyTypeKind;
5350
5350
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5351
+ //#endregion
5352
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5353
+ /**
5354
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5355
+ * window to float samples (D455).
5356
+ *
5357
+ * ## Why a format at all
5358
+ *
5359
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5360
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5361
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5362
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5363
+ * the plane carried four times the source. The plane crosses hub-main twice on
5364
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5365
+ *
5366
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5367
+ * them where it needs them. That is the same argument D450 made for the rate,
5368
+ * one step further along the same wire.
5369
+ *
5370
+ * ## Why the expansion lives here
5371
+ *
5372
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5373
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5374
+ * `AudioChunkPlane` expands per subscription) and
5375
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5376
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5377
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5378
+ * into their own dist (`self-contained` externals), so this travels with a
5379
+ * `camstack deploy` and needs no published server.
5380
+ *
5381
+ * A second μ-law table anywhere else is the defect this module exists to
5382
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5383
+ * direction for the WebRTC egress — a different transform, not a copy.)
5384
+ *
5385
+ * ## Absent means f32le
5386
+ *
5387
+ * `format` is optional on the wire and its absence means `f32le` — today's
5388
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5389
+ * has always been served, because the broker only emits a coded window to a
5390
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5391
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5392
+ * deployable one addon at a time across three nodes.
5393
+ */
5394
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5395
+ var AUDIO_CHUNK_FORMATS = [
5396
+ "f32le",
5397
+ "pcmu",
5398
+ "pcma"
5399
+ ];
5400
+ /**
5401
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5402
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5403
+ *
5404
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5405
+ * it buffers the coded bytes and the plane's consumers expand.
5406
+ */
5407
+ function buildUlawTable() {
5408
+ const table = new Float32Array(256);
5409
+ for (let i = 0; i < 256; i++) {
5410
+ const complemented = ~i & 255;
5411
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5412
+ const exponent = complemented >> 4 & 7;
5413
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5414
+ }
5415
+ return table;
5416
+ }
5417
+ /** Build the A-law decode table (ITU-T G.711). */
5418
+ function buildAlawTable() {
5419
+ const table = new Float32Array(256);
5420
+ for (let i = 0; i < 256; i++) {
5421
+ const xored = i ^ 85;
5422
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5423
+ const exponent = xored >> 4 & 7;
5424
+ const mantissa = xored & 15;
5425
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5426
+ }
5427
+ return table;
5428
+ }
5429
+ buildUlawTable();
5430
+ buildAlawTable();
5351
5431
  Object.fromEntries([
5352
5432
  {
5353
5433
  id: "overview",
@@ -6640,11 +6720,20 @@ var SubscribeFramesResultSchema = object({
6640
6720
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6641
6721
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6642
6722
  */
6723
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6643
6724
  var DecodedAudioChunkSchema = object({
6644
6725
  data: _instanceof(Uint8Array),
6645
6726
  sampleRate: number().int().positive(),
6646
6727
  channels: number().int().positive(),
6647
- timestamp: number()
6728
+ timestamp: number(),
6729
+ /**
6730
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6731
+ * byte, for any peer that never heard of this field. A coded window
6732
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6733
+ * subscription that DECLARED it accepts one, so absence can never mean
6734
+ * "coded bytes a consumer will read as floats" (D455).
6735
+ */
6736
+ format: AudioChunkFormatSchema.optional()
6648
6737
  });
6649
6738
  /**
6650
6739
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6656,7 +6745,18 @@ var DecodedAudioChunkSchema = object({
6656
6745
  var SubscribeAudioChunksInputSchema = object({
6657
6746
  brokerId: string(),
6658
6747
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6659
- tag: string().optional()
6748
+ tag: string().optional(),
6749
+ /**
6750
+ * Byte formats this subscriber can READ, best first. The broker serves the
6751
+ * chunk's own format when it is in this list and expands to `f32le`
6752
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6753
+ *
6754
+ * Absent (or without the source format) means `f32le` — the behaviour every
6755
+ * subscriber had before D455, unchanged. This is the negotiation half of
6756
+ * the source-bytes lever: it is what lets the broker and its consumers
6757
+ * deploy one at a time across three nodes.
6758
+ */
6759
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6660
6760
  });
6661
6761
  /** Result of `stream-broker.subscribeAudioChunks`. */
6662
6762
  var SubscribeAudioChunksResultSchema = object({
@@ -10766,6 +10866,51 @@ var AudioAnalysisSettingsSchema = object({
10766
10866
  minConfidence: number().min(0).max(1).default(.3),
10767
10867
  allowedClasses: array(string()).default([])
10768
10868
  });
10869
+ /**
10870
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10871
+ *
10872
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10873
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10874
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10875
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10876
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10877
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10878
+ * way to the one expansion that feeds the model.
10879
+ *
10880
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10881
+ * window, the per-device node assignment, the settings read) and therefore
10882
+ * still owns the attach/detach pair. It no longer owns the bytes.
10883
+ */
10884
+ var AudioAttachDeviceInputSchema = object({
10885
+ deviceId: number(),
10886
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10887
+ brokerId: string(),
10888
+ /**
10889
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10890
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10891
+ * the orchestrator's poller pinned them before the move.
10892
+ */
10893
+ ingestNodeId: string(),
10894
+ /**
10895
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10896
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10897
+ * window: a settings change re-attaches, which is what always happened.
10898
+ */
10899
+ settings: AudioAnalysisSettingsSchema
10900
+ });
10901
+ var AudioAttachDeviceResultSchema = object({
10902
+ /** False only when the analyzer is shutting down and refused to attach. */
10903
+ attached: boolean(),
10904
+ /**
10905
+ * True when the attachment replaced a live one for the same device. An
10906
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10907
+ * double the broker's fanout and neither would know about the other.
10908
+ */
10909
+ replaced: boolean()
10910
+ });
10911
+ var AudioDetachDeviceResultSchema = object({
10912
+ /** False when no attachment existed — detach is idempotent. */
10913
+ detached: boolean() });
10769
10914
  var AudioClassificationResultSchema = object({
10770
10915
  labels: array(AudioClassificationLabelSchema).readonly(),
10771
10916
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10774,7 +10919,7 @@ var AudioClassificationResultSchema = object({
10774
10919
  method(object({
10775
10920
  chunk: AudioChunkInputSchema,
10776
10921
  settings: AudioAnalysisSettingsSchema
10777
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10922
+ }), 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() }), {
10778
10923
  kind: "mutation",
10779
10924
  auth: "admin"
10780
10925
  });
@@ -24936,8 +25081,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
24936
25081
  *
24937
25082
  * An **empty array reads NOTHING** — `[]` is an empty page, never
24938
25083
  * "every camera". A request for no devices is a request, not an
24939
- * omission; same contract as `deviceManager.listFleet` and
24940
- * `pipelineAnalytics.listRecentTracks`.
25084
+ * omission; same contract as `deviceManager.listAll`'s `deviceIds`
25085
+ * and `pipelineAnalytics.listRecentTracks`.
24941
25086
  *
24942
25087
  * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
24943
25088
  */
@@ -30705,12 +30850,24 @@ Object.freeze({
30705
30850
  addonId: null,
30706
30851
  access: "create"
30707
30852
  },
30853
+ "audioAnalyzer.attachDevice": {
30854
+ capName: "audio-analyzer",
30855
+ capScope: "system",
30856
+ addonId: null,
30857
+ access: "create"
30858
+ },
30708
30859
  "audioAnalyzer.classify": {
30709
30860
  capName: "audio-analyzer",
30710
30861
  capScope: "system",
30711
30862
  addonId: null,
30712
30863
  access: "view"
30713
30864
  },
30865
+ "audioAnalyzer.detachDevice": {
30866
+ capName: "audio-analyzer",
30867
+ capScope: "system",
30868
+ addonId: null,
30869
+ access: "create"
30870
+ },
30714
30871
  "audioAnalyzer.dispose": {
30715
30872
  capName: "audio-analyzer",
30716
30873
  capScope: "system",
@@ -36554,11 +36711,21 @@ Object.freeze({
36554
36711
  form: "single",
36555
36712
  optional: false
36556
36713
  }],
36714
+ "audioAnalyzer.attachDevice": [{
36715
+ name: "deviceId",
36716
+ form: "single",
36717
+ optional: false
36718
+ }],
36557
36719
  "audioAnalyzer.classify": [{
36558
36720
  name: "deviceId",
36559
36721
  form: "single",
36560
36722
  optional: true
36561
36723
  }],
36724
+ "audioAnalyzer.detachDevice": [{
36725
+ name: "deviceId",
36726
+ form: "single",
36727
+ optional: false
36728
+ }],
36562
36729
  "audioMetrics.getCurrentSnapshot": [{
36563
36730
  name: "deviceId",
36564
36731
  form: "single",
@@ -38410,6 +38577,52 @@ Object.freeze({
38410
38577
  "network-access": "ingress",
38411
38578
  "smtp-provider": "email"
38412
38579
  });
38580
+ var G711_SCALE_CORRECTION_DB = {
38581
+ PCMU: 20 * Math.log10(4),
38582
+ PCMA: 20 * Math.log10(8)
38583
+ };
38584
+ /**
38585
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
38586
+ * same intent on the ITU-T scale (D460).
38587
+ *
38588
+ * ## When this applies, and when it is the wrong thing to reach for
38589
+ *
38590
+ * An absolute-dBFS number in this repo is one of two things, and only one of
38591
+ * them converts:
38592
+ *
38593
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
38594
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
38595
+ * after. The defect was never in the number; it was that 19 of this hub's
38596
+ * 25 cameras did not obey it. Converting such a number takes something
38597
+ * correct and makes it wrong, in order to preserve a bug.
38598
+ * - **A measurement taken through the old decoder** — a value someone read
38599
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
38600
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
38601
+ * louder. That is what this function is for.
38602
+ *
38603
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
38604
+ * and it cannot be answered from the number. It is answered by the comment the
38605
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
38606
+ * mandatory.
38607
+ *
38608
+ * ## Why a function and not a typed-in number
38609
+ *
38610
+ * `-55 + 12.04` written into a source file is, six months later, completely
38611
+ * indistinguishable from a threshold somebody simply preferred. Calling this
38612
+ * keeps the derivation, the law, and the original measurement all visible at
38613
+ * the call site, so a future reader can disagree with the *premise* instead of
38614
+ * having to reverse-engineer the sum.
38615
+ *
38616
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
38617
+ * it is declared. It must never be applied to a live sample or a stored
38618
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
38619
+ * adjusting numbers the decoder already got right is the original defect with
38620
+ * an extra place to argue with (D459).
38621
+ */
38622
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
38623
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
38624
+ }
38625
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
38413
38626
  /** Schema defaults — an untouched sub-field must author exactly these. */
38414
38627
  var NC_AUDIO_DEFAULTS = {
38415
38628
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-notifiers",
3
- "version": "1.2.98",
3
+ "version": "1.2.100",
4
4
  "description": "System notifiers addon for CamStack — a `notification-output` collection provider hosting per-kind notifier adapters (ntfy, pushover, gotify, telegram, discord, webhook, zentik).",
5
5
  "keywords": [
6
6
  "camstack",