@camstack/addon-provider-gree 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
@@ -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({
@@ -10644,6 +10744,51 @@ var AudioAnalysisSettingsSchema = object({
10644
10744
  minConfidence: number().min(0).max(1).default(.3),
10645
10745
  allowedClasses: array(string()).default([])
10646
10746
  });
10747
+ /**
10748
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10749
+ *
10750
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10751
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10752
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10753
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10754
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10755
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10756
+ * way to the one expansion that feeds the model.
10757
+ *
10758
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10759
+ * window, the per-device node assignment, the settings read) and therefore
10760
+ * still owns the attach/detach pair. It no longer owns the bytes.
10761
+ */
10762
+ var AudioAttachDeviceInputSchema = object({
10763
+ deviceId: number(),
10764
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10765
+ brokerId: string(),
10766
+ /**
10767
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10768
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10769
+ * the orchestrator's poller pinned them before the move.
10770
+ */
10771
+ ingestNodeId: string(),
10772
+ /**
10773
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10774
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10775
+ * window: a settings change re-attaches, which is what always happened.
10776
+ */
10777
+ settings: AudioAnalysisSettingsSchema
10778
+ });
10779
+ var AudioAttachDeviceResultSchema = object({
10780
+ /** False only when the analyzer is shutting down and refused to attach. */
10781
+ attached: boolean(),
10782
+ /**
10783
+ * True when the attachment replaced a live one for the same device. An
10784
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10785
+ * double the broker's fanout and neither would know about the other.
10786
+ */
10787
+ replaced: boolean()
10788
+ });
10789
+ var AudioDetachDeviceResultSchema = object({
10790
+ /** False when no attachment existed — detach is idempotent. */
10791
+ detached: boolean() });
10647
10792
  var AudioClassificationResultSchema = object({
10648
10793
  labels: array(AudioClassificationLabelSchema).readonly(),
10649
10794
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10652,7 +10797,7 @@ var AudioClassificationResultSchema = object({
10652
10797
  method(object({
10653
10798
  chunk: AudioChunkInputSchema,
10654
10799
  settings: AudioAnalysisSettingsSchema
10655
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10800
+ }), 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() }), {
10656
10801
  kind: "mutation",
10657
10802
  auth: "admin"
10658
10803
  });
@@ -20556,6 +20701,14 @@ var NativeCropResultSchema = object({
20556
20701
  * set `encodeJpeg: true`; `bytes` is then absent.
20557
20702
  */
20558
20703
  jpeg: string().optional(),
20704
+ /**
20705
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20706
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20707
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20708
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20709
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20710
+ */
20711
+ jpegBytes: _instanceof(Uint8Array).optional(),
20559
20712
  width: number().int().positive(),
20560
20713
  height: number().int().positive(),
20561
20714
  /**
@@ -20622,7 +20775,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20622
20775
  })]);
20623
20776
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20624
20777
  var ParkedTrackFrameSchema = object({
20625
- jpeg: string(),
20778
+ /**
20779
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20780
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20781
+ * Exactly one of the two is present.
20782
+ */
20783
+ jpeg: string().optional(),
20784
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20785
+ jpegBytes: _instanceof(Uint8Array).optional(),
20626
20786
  width: number().int().positive(),
20627
20787
  height: number().int().positive(),
20628
20788
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21209,6 +21369,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21209
21369
  bbox: NativeCropBboxSchema,
21210
21370
  maxWidth: number().int().positive().optional(),
21211
21371
  /**
21372
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21373
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21374
+ * wire — never assume consent: a pre-D462 caller parses the field as
21375
+ * base64 and bytes would decode to garbage rather than fail.
21376
+ */
21377
+ acceptJpegBytes: boolean().optional(),
21378
+ /**
21212
21379
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21213
21380
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21214
21381
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21276,7 +21443,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21276
21443
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21277
21444
  deviceId: number(),
21278
21445
  trackId: string(),
21279
- kind: ParkedFrameKindSchema
21446
+ kind: ParkedFrameKindSchema,
21447
+ /**
21448
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21449
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21450
+ * wire — never assume consent: a pre-D462 caller parses the field as
21451
+ * base64 and bytes would decode to garbage rather than fail.
21452
+ */
21453
+ acceptJpegBytes: boolean().optional()
21280
21454
  }), ParkedTrackFrameSchema.nullable()), method(object({
21281
21455
  deviceId: number(),
21282
21456
  trackId: string()
@@ -34911,12 +35085,24 @@ Object.freeze({
34911
35085
  addonId: null,
34912
35086
  access: "create"
34913
35087
  },
35088
+ "audioAnalyzer.attachDevice": {
35089
+ capName: "audio-analyzer",
35090
+ capScope: "system",
35091
+ addonId: null,
35092
+ access: "create"
35093
+ },
34914
35094
  "audioAnalyzer.classify": {
34915
35095
  capName: "audio-analyzer",
34916
35096
  capScope: "system",
34917
35097
  addonId: null,
34918
35098
  access: "view"
34919
35099
  },
35100
+ "audioAnalyzer.detachDevice": {
35101
+ capName: "audio-analyzer",
35102
+ capScope: "system",
35103
+ addonId: null,
35104
+ access: "create"
35105
+ },
34920
35106
  "audioAnalyzer.dispose": {
34921
35107
  capName: "audio-analyzer",
34922
35108
  capScope: "system",
@@ -40760,11 +40946,21 @@ Object.freeze({
40760
40946
  form: "single",
40761
40947
  optional: false
40762
40948
  }],
40949
+ "audioAnalyzer.attachDevice": [{
40950
+ name: "deviceId",
40951
+ form: "single",
40952
+ optional: false
40953
+ }],
40763
40954
  "audioAnalyzer.classify": [{
40764
40955
  name: "deviceId",
40765
40956
  form: "single",
40766
40957
  optional: true
40767
40958
  }],
40959
+ "audioAnalyzer.detachDevice": [{
40960
+ name: "deviceId",
40961
+ form: "single",
40962
+ optional: false
40963
+ }],
40768
40964
  "audioMetrics.getCurrentSnapshot": [{
40769
40965
  name: "deviceId",
40770
40966
  form: "single",
@@ -42616,6 +42812,52 @@ Object.freeze({
42616
42812
  "network-access": "ingress",
42617
42813
  "smtp-provider": "email"
42618
42814
  });
42815
+ var G711_SCALE_CORRECTION_DB = {
42816
+ PCMU: 20 * Math.log10(4),
42817
+ PCMA: 20 * Math.log10(8)
42818
+ };
42819
+ /**
42820
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42821
+ * same intent on the ITU-T scale (D460).
42822
+ *
42823
+ * ## When this applies, and when it is the wrong thing to reach for
42824
+ *
42825
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42826
+ * them converts:
42827
+ *
42828
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42829
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42830
+ * after. The defect was never in the number; it was that 19 of this hub's
42831
+ * 25 cameras did not obey it. Converting such a number takes something
42832
+ * correct and makes it wrong, in order to preserve a bug.
42833
+ * - **A measurement taken through the old decoder** — a value someone read
42834
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42835
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42836
+ * louder. That is what this function is for.
42837
+ *
42838
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42839
+ * and it cannot be answered from the number. It is answered by the comment the
42840
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42841
+ * mandatory.
42842
+ *
42843
+ * ## Why a function and not a typed-in number
42844
+ *
42845
+ * `-55 + 12.04` written into a source file is, six months later, completely
42846
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42847
+ * keeps the derivation, the law, and the original measurement all visible at
42848
+ * the call site, so a future reader can disagree with the *premise* instead of
42849
+ * having to reverse-engineer the sum.
42850
+ *
42851
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42852
+ * it is declared. It must never be applied to a live sample or a stored
42853
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42854
+ * adjusting numbers the decoder already got right is the original defect with
42855
+ * an extra place to argue with (D459).
42856
+ */
42857
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42858
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42859
+ }
42860
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42619
42861
  /** Schema defaults — an untouched sub-field must author exactly these. */
42620
42862
  var NC_AUDIO_DEFAULTS = {
42621
42863
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5347,6 +5347,86 @@ var ZodIssueCode = {
5347
5347
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5348
5348
  var ZodFirstPartyTypeKind;
5349
5349
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5350
+ //#endregion
5351
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5352
+ /**
5353
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5354
+ * window to float samples (D455).
5355
+ *
5356
+ * ## Why a format at all
5357
+ *
5358
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5359
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5360
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5361
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5362
+ * the plane carried four times the source. The plane crosses hub-main twice on
5363
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5364
+ *
5365
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5366
+ * them where it needs them. That is the same argument D450 made for the rate,
5367
+ * one step further along the same wire.
5368
+ *
5369
+ * ## Why the expansion lives here
5370
+ *
5371
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5372
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5373
+ * `AudioChunkPlane` expands per subscription) and
5374
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5375
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5376
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5377
+ * into their own dist (`self-contained` externals), so this travels with a
5378
+ * `camstack deploy` and needs no published server.
5379
+ *
5380
+ * A second μ-law table anywhere else is the defect this module exists to
5381
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5382
+ * direction for the WebRTC egress — a different transform, not a copy.)
5383
+ *
5384
+ * ## Absent means f32le
5385
+ *
5386
+ * `format` is optional on the wire and its absence means `f32le` — today's
5387
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5388
+ * has always been served, because the broker only emits a coded window to a
5389
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5390
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5391
+ * deployable one addon at a time across three nodes.
5392
+ */
5393
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5394
+ var AUDIO_CHUNK_FORMATS = [
5395
+ "f32le",
5396
+ "pcmu",
5397
+ "pcma"
5398
+ ];
5399
+ /**
5400
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5401
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5402
+ *
5403
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5404
+ * it buffers the coded bytes and the plane's consumers expand.
5405
+ */
5406
+ function buildUlawTable() {
5407
+ const table = new Float32Array(256);
5408
+ for (let i = 0; i < 256; i++) {
5409
+ const complemented = ~i & 255;
5410
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5411
+ const exponent = complemented >> 4 & 7;
5412
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5413
+ }
5414
+ return table;
5415
+ }
5416
+ /** Build the A-law decode table (ITU-T G.711). */
5417
+ function buildAlawTable() {
5418
+ const table = new Float32Array(256);
5419
+ for (let i = 0; i < 256; i++) {
5420
+ const xored = i ^ 85;
5421
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5422
+ const exponent = xored >> 4 & 7;
5423
+ const mantissa = xored & 15;
5424
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5425
+ }
5426
+ return table;
5427
+ }
5428
+ buildUlawTable();
5429
+ buildAlawTable();
5350
5430
  Object.fromEntries([
5351
5431
  {
5352
5432
  id: "overview",
@@ -6639,11 +6719,20 @@ var SubscribeFramesResultSchema = object({
6639
6719
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6640
6720
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6641
6721
  */
6722
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6642
6723
  var DecodedAudioChunkSchema = object({
6643
6724
  data: _instanceof(Uint8Array),
6644
6725
  sampleRate: number().int().positive(),
6645
6726
  channels: number().int().positive(),
6646
- timestamp: number()
6727
+ timestamp: number(),
6728
+ /**
6729
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6730
+ * byte, for any peer that never heard of this field. A coded window
6731
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6732
+ * subscription that DECLARED it accepts one, so absence can never mean
6733
+ * "coded bytes a consumer will read as floats" (D455).
6734
+ */
6735
+ format: AudioChunkFormatSchema.optional()
6647
6736
  });
6648
6737
  /**
6649
6738
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6655,7 +6744,18 @@ var DecodedAudioChunkSchema = object({
6655
6744
  var SubscribeAudioChunksInputSchema = object({
6656
6745
  brokerId: string(),
6657
6746
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6658
- tag: string().optional()
6747
+ tag: string().optional(),
6748
+ /**
6749
+ * Byte formats this subscriber can READ, best first. The broker serves the
6750
+ * chunk's own format when it is in this list and expands to `f32le`
6751
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6752
+ *
6753
+ * Absent (or without the source format) means `f32le` — the behaviour every
6754
+ * subscriber had before D455, unchanged. This is the negotiation half of
6755
+ * the source-bytes lever: it is what lets the broker and its consumers
6756
+ * deploy one at a time across three nodes.
6757
+ */
6758
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6659
6759
  });
6660
6760
  /** Result of `stream-broker.subscribeAudioChunks`. */
6661
6761
  var SubscribeAudioChunksResultSchema = object({
@@ -10643,6 +10743,51 @@ var AudioAnalysisSettingsSchema = object({
10643
10743
  minConfidence: number().min(0).max(1).default(.3),
10644
10744
  allowedClasses: array(string()).default([])
10645
10745
  });
10746
+ /**
10747
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10748
+ *
10749
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10750
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10751
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10752
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10753
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10754
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10755
+ * way to the one expansion that feeds the model.
10756
+ *
10757
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10758
+ * window, the per-device node assignment, the settings read) and therefore
10759
+ * still owns the attach/detach pair. It no longer owns the bytes.
10760
+ */
10761
+ var AudioAttachDeviceInputSchema = object({
10762
+ deviceId: number(),
10763
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10764
+ brokerId: string(),
10765
+ /**
10766
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10767
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10768
+ * the orchestrator's poller pinned them before the move.
10769
+ */
10770
+ ingestNodeId: string(),
10771
+ /**
10772
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10773
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10774
+ * window: a settings change re-attaches, which is what always happened.
10775
+ */
10776
+ settings: AudioAnalysisSettingsSchema
10777
+ });
10778
+ var AudioAttachDeviceResultSchema = object({
10779
+ /** False only when the analyzer is shutting down and refused to attach. */
10780
+ attached: boolean(),
10781
+ /**
10782
+ * True when the attachment replaced a live one for the same device. An
10783
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10784
+ * double the broker's fanout and neither would know about the other.
10785
+ */
10786
+ replaced: boolean()
10787
+ });
10788
+ var AudioDetachDeviceResultSchema = object({
10789
+ /** False when no attachment existed — detach is idempotent. */
10790
+ detached: boolean() });
10646
10791
  var AudioClassificationResultSchema = object({
10647
10792
  labels: array(AudioClassificationLabelSchema).readonly(),
10648
10793
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10651,7 +10796,7 @@ var AudioClassificationResultSchema = object({
10651
10796
  method(object({
10652
10797
  chunk: AudioChunkInputSchema,
10653
10798
  settings: AudioAnalysisSettingsSchema
10654
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10799
+ }), 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() }), {
10655
10800
  kind: "mutation",
10656
10801
  auth: "admin"
10657
10802
  });
@@ -20555,6 +20700,14 @@ var NativeCropResultSchema = object({
20555
20700
  * set `encodeJpeg: true`; `bytes` is then absent.
20556
20701
  */
20557
20702
  jpeg: string().optional(),
20703
+ /**
20704
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20705
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20706
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20707
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20708
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20709
+ */
20710
+ jpegBytes: _instanceof(Uint8Array).optional(),
20558
20711
  width: number().int().positive(),
20559
20712
  height: number().int().positive(),
20560
20713
  /**
@@ -20621,7 +20774,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20621
20774
  })]);
20622
20775
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20623
20776
  var ParkedTrackFrameSchema = object({
20624
- jpeg: string(),
20777
+ /**
20778
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20779
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20780
+ * Exactly one of the two is present.
20781
+ */
20782
+ jpeg: string().optional(),
20783
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20784
+ jpegBytes: _instanceof(Uint8Array).optional(),
20625
20785
  width: number().int().positive(),
20626
20786
  height: number().int().positive(),
20627
20787
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21208,6 +21368,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21208
21368
  bbox: NativeCropBboxSchema,
21209
21369
  maxWidth: number().int().positive().optional(),
21210
21370
  /**
21371
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21372
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21373
+ * wire — never assume consent: a pre-D462 caller parses the field as
21374
+ * base64 and bytes would decode to garbage rather than fail.
21375
+ */
21376
+ acceptJpegBytes: boolean().optional(),
21377
+ /**
21211
21378
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21212
21379
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21213
21380
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21275,7 +21442,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21275
21442
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21276
21443
  deviceId: number(),
21277
21444
  trackId: string(),
21278
- kind: ParkedFrameKindSchema
21445
+ kind: ParkedFrameKindSchema,
21446
+ /**
21447
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21448
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21449
+ * wire — never assume consent: a pre-D462 caller parses the field as
21450
+ * base64 and bytes would decode to garbage rather than fail.
21451
+ */
21452
+ acceptJpegBytes: boolean().optional()
21279
21453
  }), ParkedTrackFrameSchema.nullable()), method(object({
21280
21454
  deviceId: number(),
21281
21455
  trackId: string()
@@ -34910,12 +35084,24 @@ Object.freeze({
34910
35084
  addonId: null,
34911
35085
  access: "create"
34912
35086
  },
35087
+ "audioAnalyzer.attachDevice": {
35088
+ capName: "audio-analyzer",
35089
+ capScope: "system",
35090
+ addonId: null,
35091
+ access: "create"
35092
+ },
34913
35093
  "audioAnalyzer.classify": {
34914
35094
  capName: "audio-analyzer",
34915
35095
  capScope: "system",
34916
35096
  addonId: null,
34917
35097
  access: "view"
34918
35098
  },
35099
+ "audioAnalyzer.detachDevice": {
35100
+ capName: "audio-analyzer",
35101
+ capScope: "system",
35102
+ addonId: null,
35103
+ access: "create"
35104
+ },
34919
35105
  "audioAnalyzer.dispose": {
34920
35106
  capName: "audio-analyzer",
34921
35107
  capScope: "system",
@@ -40759,11 +40945,21 @@ Object.freeze({
40759
40945
  form: "single",
40760
40946
  optional: false
40761
40947
  }],
40948
+ "audioAnalyzer.attachDevice": [{
40949
+ name: "deviceId",
40950
+ form: "single",
40951
+ optional: false
40952
+ }],
40762
40953
  "audioAnalyzer.classify": [{
40763
40954
  name: "deviceId",
40764
40955
  form: "single",
40765
40956
  optional: true
40766
40957
  }],
40958
+ "audioAnalyzer.detachDevice": [{
40959
+ name: "deviceId",
40960
+ form: "single",
40961
+ optional: false
40962
+ }],
40767
40963
  "audioMetrics.getCurrentSnapshot": [{
40768
40964
  name: "deviceId",
40769
40965
  form: "single",
@@ -42615,6 +42811,52 @@ Object.freeze({
42615
42811
  "network-access": "ingress",
42616
42812
  "smtp-provider": "email"
42617
42813
  });
42814
+ var G711_SCALE_CORRECTION_DB = {
42815
+ PCMU: 20 * Math.log10(4),
42816
+ PCMA: 20 * Math.log10(8)
42817
+ };
42818
+ /**
42819
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42820
+ * same intent on the ITU-T scale (D460).
42821
+ *
42822
+ * ## When this applies, and when it is the wrong thing to reach for
42823
+ *
42824
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42825
+ * them converts:
42826
+ *
42827
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42828
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42829
+ * after. The defect was never in the number; it was that 19 of this hub's
42830
+ * 25 cameras did not obey it. Converting such a number takes something
42831
+ * correct and makes it wrong, in order to preserve a bug.
42832
+ * - **A measurement taken through the old decoder** — a value someone read
42833
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42834
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42835
+ * louder. That is what this function is for.
42836
+ *
42837
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42838
+ * and it cannot be answered from the number. It is answered by the comment the
42839
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42840
+ * mandatory.
42841
+ *
42842
+ * ## Why a function and not a typed-in number
42843
+ *
42844
+ * `-55 + 12.04` written into a source file is, six months later, completely
42845
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42846
+ * keeps the derivation, the law, and the original measurement all visible at
42847
+ * the call site, so a future reader can disagree with the *premise* instead of
42848
+ * having to reverse-engineer the sum.
42849
+ *
42850
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42851
+ * it is declared. It must never be applied to a live sample or a stored
42852
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42853
+ * adjusting numbers the decoder already got right is the original defect with
42854
+ * an extra place to argue with (D459).
42855
+ */
42856
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42857
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42858
+ }
42859
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42618
42860
  /** Schema defaults — an untouched sub-field must author exactly these. */
42619
42861
  var NC_AUDIO_DEFAULTS = {
42620
42862
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-gree",
3
- "version": "0.2.94",
3
+ "version": "0.2.96",
4
4
  "description": "Gree air-conditioner device-provider addon for CamStack — wraps the @apocaliss92/nodegree local-UDP client (LAN discovery + AES control), exposing climate-control and fan-control",
5
5
  "keywords": [
6
6
  "camstack",