@camstack/addon-notifiers 1.2.99 → 1.2.101

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
  });
@@ -20373,6 +20518,14 @@ var NativeCropResultSchema = object({
20373
20518
  * set `encodeJpeg: true`; `bytes` is then absent.
20374
20519
  */
20375
20520
  jpeg: string().optional(),
20521
+ /**
20522
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20523
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20524
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20525
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20526
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20527
+ */
20528
+ jpegBytes: _instanceof(Uint8Array).optional(),
20376
20529
  width: number().int().positive(),
20377
20530
  height: number().int().positive(),
20378
20531
  /**
@@ -20439,7 +20592,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20439
20592
  })]);
20440
20593
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20441
20594
  var ParkedTrackFrameSchema = object({
20442
- jpeg: string(),
20595
+ /**
20596
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20597
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20598
+ * Exactly one of the two is present.
20599
+ */
20600
+ jpeg: string().optional(),
20601
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20602
+ jpegBytes: _instanceof(Uint8Array).optional(),
20443
20603
  width: number().int().positive(),
20444
20604
  height: number().int().positive(),
20445
20605
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21026,6 +21186,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21026
21186
  bbox: NativeCropBboxSchema,
21027
21187
  maxWidth: number().int().positive().optional(),
21028
21188
  /**
21189
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21190
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21191
+ * wire — never assume consent: a pre-D462 caller parses the field as
21192
+ * base64 and bytes would decode to garbage rather than fail.
21193
+ */
21194
+ acceptJpegBytes: boolean().optional(),
21195
+ /**
21029
21196
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21030
21197
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21031
21198
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21093,7 +21260,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21093
21260
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21094
21261
  deviceId: number(),
21095
21262
  trackId: string(),
21096
- kind: ParkedFrameKindSchema
21263
+ kind: ParkedFrameKindSchema,
21264
+ /**
21265
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21266
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21267
+ * wire — never assume consent: a pre-D462 caller parses the field as
21268
+ * base64 and bytes would decode to garbage rather than fail.
21269
+ */
21270
+ acceptJpegBytes: boolean().optional()
21097
21271
  }), ParkedTrackFrameSchema.nullable()), method(object({
21098
21272
  deviceId: number(),
21099
21273
  trackId: string()
@@ -30732,12 +30906,24 @@ Object.freeze({
30732
30906
  addonId: null,
30733
30907
  access: "create"
30734
30908
  },
30909
+ "audioAnalyzer.attachDevice": {
30910
+ capName: "audio-analyzer",
30911
+ capScope: "system",
30912
+ addonId: null,
30913
+ access: "create"
30914
+ },
30735
30915
  "audioAnalyzer.classify": {
30736
30916
  capName: "audio-analyzer",
30737
30917
  capScope: "system",
30738
30918
  addonId: null,
30739
30919
  access: "view"
30740
30920
  },
30921
+ "audioAnalyzer.detachDevice": {
30922
+ capName: "audio-analyzer",
30923
+ capScope: "system",
30924
+ addonId: null,
30925
+ access: "create"
30926
+ },
30741
30927
  "audioAnalyzer.dispose": {
30742
30928
  capName: "audio-analyzer",
30743
30929
  capScope: "system",
@@ -36581,11 +36767,21 @@ Object.freeze({
36581
36767
  form: "single",
36582
36768
  optional: false
36583
36769
  }],
36770
+ "audioAnalyzer.attachDevice": [{
36771
+ name: "deviceId",
36772
+ form: "single",
36773
+ optional: false
36774
+ }],
36584
36775
  "audioAnalyzer.classify": [{
36585
36776
  name: "deviceId",
36586
36777
  form: "single",
36587
36778
  optional: true
36588
36779
  }],
36780
+ "audioAnalyzer.detachDevice": [{
36781
+ name: "deviceId",
36782
+ form: "single",
36783
+ optional: false
36784
+ }],
36589
36785
  "audioMetrics.getCurrentSnapshot": [{
36590
36786
  name: "deviceId",
36591
36787
  form: "single",
@@ -38437,6 +38633,52 @@ Object.freeze({
38437
38633
  "network-access": "ingress",
38438
38634
  "smtp-provider": "email"
38439
38635
  });
38636
+ var G711_SCALE_CORRECTION_DB = {
38637
+ PCMU: 20 * Math.log10(4),
38638
+ PCMA: 20 * Math.log10(8)
38639
+ };
38640
+ /**
38641
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
38642
+ * same intent on the ITU-T scale (D460).
38643
+ *
38644
+ * ## When this applies, and when it is the wrong thing to reach for
38645
+ *
38646
+ * An absolute-dBFS number in this repo is one of two things, and only one of
38647
+ * them converts:
38648
+ *
38649
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
38650
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
38651
+ * after. The defect was never in the number; it was that 19 of this hub's
38652
+ * 25 cameras did not obey it. Converting such a number takes something
38653
+ * correct and makes it wrong, in order to preserve a bug.
38654
+ * - **A measurement taken through the old decoder** — a value someone read
38655
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
38656
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
38657
+ * louder. That is what this function is for.
38658
+ *
38659
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
38660
+ * and it cannot be answered from the number. It is answered by the comment the
38661
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
38662
+ * mandatory.
38663
+ *
38664
+ * ## Why a function and not a typed-in number
38665
+ *
38666
+ * `-55 + 12.04` written into a source file is, six months later, completely
38667
+ * indistinguishable from a threshold somebody simply preferred. Calling this
38668
+ * keeps the derivation, the law, and the original measurement all visible at
38669
+ * the call site, so a future reader can disagree with the *premise* instead of
38670
+ * having to reverse-engineer the sum.
38671
+ *
38672
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
38673
+ * it is declared. It must never be applied to a live sample or a stored
38674
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
38675
+ * adjusting numbers the decoder already got right is the original defect with
38676
+ * an extra place to argue with (D459).
38677
+ */
38678
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
38679
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
38680
+ }
38681
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
38440
38682
  /** Schema defaults — an untouched sub-field must author exactly these. */
38441
38683
  var NC_AUDIO_DEFAULTS = {
38442
38684
  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
  });
@@ -20346,6 +20491,14 @@ var NativeCropResultSchema = object({
20346
20491
  * set `encodeJpeg: true`; `bytes` is then absent.
20347
20492
  */
20348
20493
  jpeg: string().optional(),
20494
+ /**
20495
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20496
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20497
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20498
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20499
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20500
+ */
20501
+ jpegBytes: _instanceof(Uint8Array).optional(),
20349
20502
  width: number().int().positive(),
20350
20503
  height: number().int().positive(),
20351
20504
  /**
@@ -20412,7 +20565,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20412
20565
  })]);
20413
20566
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20414
20567
  var ParkedTrackFrameSchema = object({
20415
- jpeg: string(),
20568
+ /**
20569
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20570
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20571
+ * Exactly one of the two is present.
20572
+ */
20573
+ jpeg: string().optional(),
20574
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20575
+ jpegBytes: _instanceof(Uint8Array).optional(),
20416
20576
  width: number().int().positive(),
20417
20577
  height: number().int().positive(),
20418
20578
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -20999,6 +21159,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
20999
21159
  bbox: NativeCropBboxSchema,
21000
21160
  maxWidth: number().int().positive().optional(),
21001
21161
  /**
21162
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21163
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21164
+ * wire — never assume consent: a pre-D462 caller parses the field as
21165
+ * base64 and bytes would decode to garbage rather than fail.
21166
+ */
21167
+ acceptJpegBytes: boolean().optional(),
21168
+ /**
21002
21169
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21003
21170
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21004
21171
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21066,7 +21233,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21066
21233
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21067
21234
  deviceId: number(),
21068
21235
  trackId: string(),
21069
- kind: ParkedFrameKindSchema
21236
+ kind: ParkedFrameKindSchema,
21237
+ /**
21238
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21239
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21240
+ * wire — never assume consent: a pre-D462 caller parses the field as
21241
+ * base64 and bytes would decode to garbage rather than fail.
21242
+ */
21243
+ acceptJpegBytes: boolean().optional()
21070
21244
  }), ParkedTrackFrameSchema.nullable()), method(object({
21071
21245
  deviceId: number(),
21072
21246
  trackId: string()
@@ -30705,12 +30879,24 @@ Object.freeze({
30705
30879
  addonId: null,
30706
30880
  access: "create"
30707
30881
  },
30882
+ "audioAnalyzer.attachDevice": {
30883
+ capName: "audio-analyzer",
30884
+ capScope: "system",
30885
+ addonId: null,
30886
+ access: "create"
30887
+ },
30708
30888
  "audioAnalyzer.classify": {
30709
30889
  capName: "audio-analyzer",
30710
30890
  capScope: "system",
30711
30891
  addonId: null,
30712
30892
  access: "view"
30713
30893
  },
30894
+ "audioAnalyzer.detachDevice": {
30895
+ capName: "audio-analyzer",
30896
+ capScope: "system",
30897
+ addonId: null,
30898
+ access: "create"
30899
+ },
30714
30900
  "audioAnalyzer.dispose": {
30715
30901
  capName: "audio-analyzer",
30716
30902
  capScope: "system",
@@ -36554,11 +36740,21 @@ Object.freeze({
36554
36740
  form: "single",
36555
36741
  optional: false
36556
36742
  }],
36743
+ "audioAnalyzer.attachDevice": [{
36744
+ name: "deviceId",
36745
+ form: "single",
36746
+ optional: false
36747
+ }],
36557
36748
  "audioAnalyzer.classify": [{
36558
36749
  name: "deviceId",
36559
36750
  form: "single",
36560
36751
  optional: true
36561
36752
  }],
36753
+ "audioAnalyzer.detachDevice": [{
36754
+ name: "deviceId",
36755
+ form: "single",
36756
+ optional: false
36757
+ }],
36562
36758
  "audioMetrics.getCurrentSnapshot": [{
36563
36759
  name: "deviceId",
36564
36760
  form: "single",
@@ -38410,6 +38606,52 @@ Object.freeze({
38410
38606
  "network-access": "ingress",
38411
38607
  "smtp-provider": "email"
38412
38608
  });
38609
+ var G711_SCALE_CORRECTION_DB = {
38610
+ PCMU: 20 * Math.log10(4),
38611
+ PCMA: 20 * Math.log10(8)
38612
+ };
38613
+ /**
38614
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
38615
+ * same intent on the ITU-T scale (D460).
38616
+ *
38617
+ * ## When this applies, and when it is the wrong thing to reach for
38618
+ *
38619
+ * An absolute-dBFS number in this repo is one of two things, and only one of
38620
+ * them converts:
38621
+ *
38622
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
38623
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
38624
+ * after. The defect was never in the number; it was that 19 of this hub's
38625
+ * 25 cameras did not obey it. Converting such a number takes something
38626
+ * correct and makes it wrong, in order to preserve a bug.
38627
+ * - **A measurement taken through the old decoder** — a value someone read
38628
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
38629
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
38630
+ * louder. That is what this function is for.
38631
+ *
38632
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
38633
+ * and it cannot be answered from the number. It is answered by the comment the
38634
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
38635
+ * mandatory.
38636
+ *
38637
+ * ## Why a function and not a typed-in number
38638
+ *
38639
+ * `-55 + 12.04` written into a source file is, six months later, completely
38640
+ * indistinguishable from a threshold somebody simply preferred. Calling this
38641
+ * keeps the derivation, the law, and the original measurement all visible at
38642
+ * the call site, so a future reader can disagree with the *premise* instead of
38643
+ * having to reverse-engineer the sum.
38644
+ *
38645
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
38646
+ * it is declared. It must never be applied to a live sample or a stored
38647
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
38648
+ * adjusting numbers the decoder already got right is the original defect with
38649
+ * an extra place to argue with (D459).
38650
+ */
38651
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
38652
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
38653
+ }
38654
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
38413
38655
  /** Schema defaults — an untouched sub-field must author exactly these. */
38414
38656
  var NC_AUDIO_DEFAULTS = {
38415
38657
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-notifiers",
3
- "version": "1.2.99",
3
+ "version": "1.2.101",
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",