@camstack/addon-provider-wyze 0.2.99 → 0.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
@@ -5377,6 +5377,86 @@ var ZodIssueCode = {
5377
5377
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5378
5378
  var ZodFirstPartyTypeKind;
5379
5379
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5380
+ //#endregion
5381
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5382
+ /**
5383
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5384
+ * window to float samples (D455).
5385
+ *
5386
+ * ## Why a format at all
5387
+ *
5388
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5389
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5390
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5391
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5392
+ * the plane carried four times the source. The plane crosses hub-main twice on
5393
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5394
+ *
5395
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5396
+ * them where it needs them. That is the same argument D450 made for the rate,
5397
+ * one step further along the same wire.
5398
+ *
5399
+ * ## Why the expansion lives here
5400
+ *
5401
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5402
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5403
+ * `AudioChunkPlane` expands per subscription) and
5404
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5405
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5406
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5407
+ * into their own dist (`self-contained` externals), so this travels with a
5408
+ * `camstack deploy` and needs no published server.
5409
+ *
5410
+ * A second μ-law table anywhere else is the defect this module exists to
5411
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5412
+ * direction for the WebRTC egress — a different transform, not a copy.)
5413
+ *
5414
+ * ## Absent means f32le
5415
+ *
5416
+ * `format` is optional on the wire and its absence means `f32le` — today's
5417
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5418
+ * has always been served, because the broker only emits a coded window to a
5419
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5420
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5421
+ * deployable one addon at a time across three nodes.
5422
+ */
5423
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5424
+ var AUDIO_CHUNK_FORMATS = [
5425
+ "f32le",
5426
+ "pcmu",
5427
+ "pcma"
5428
+ ];
5429
+ /**
5430
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5431
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5432
+ *
5433
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5434
+ * it buffers the coded bytes and the plane's consumers expand.
5435
+ */
5436
+ function buildUlawTable() {
5437
+ const table = new Float32Array(256);
5438
+ for (let i = 0; i < 256; i++) {
5439
+ const complemented = ~i & 255;
5440
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5441
+ const exponent = complemented >> 4 & 7;
5442
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5443
+ }
5444
+ return table;
5445
+ }
5446
+ /** Build the A-law decode table (ITU-T G.711). */
5447
+ function buildAlawTable() {
5448
+ const table = new Float32Array(256);
5449
+ for (let i = 0; i < 256; i++) {
5450
+ const xored = i ^ 85;
5451
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5452
+ const exponent = xored >> 4 & 7;
5453
+ const mantissa = xored & 15;
5454
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5455
+ }
5456
+ return table;
5457
+ }
5458
+ buildUlawTable();
5459
+ buildAlawTable();
5380
5460
  Object.fromEntries([
5381
5461
  {
5382
5462
  id: "overview",
@@ -6669,11 +6749,20 @@ var SubscribeFramesResultSchema = object({
6669
6749
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6670
6750
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6671
6751
  */
6752
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6672
6753
  var DecodedAudioChunkSchema = object({
6673
6754
  data: _instanceof(Uint8Array),
6674
6755
  sampleRate: number().int().positive(),
6675
6756
  channels: number().int().positive(),
6676
- timestamp: number()
6757
+ timestamp: number(),
6758
+ /**
6759
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6760
+ * byte, for any peer that never heard of this field. A coded window
6761
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6762
+ * subscription that DECLARED it accepts one, so absence can never mean
6763
+ * "coded bytes a consumer will read as floats" (D455).
6764
+ */
6765
+ format: AudioChunkFormatSchema.optional()
6677
6766
  });
6678
6767
  /**
6679
6768
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6685,7 +6774,18 @@ var DecodedAudioChunkSchema = object({
6685
6774
  var SubscribeAudioChunksInputSchema = object({
6686
6775
  brokerId: string(),
6687
6776
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6688
- tag: string().optional()
6777
+ tag: string().optional(),
6778
+ /**
6779
+ * Byte formats this subscriber can READ, best first. The broker serves the
6780
+ * chunk's own format when it is in this list and expands to `f32le`
6781
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6782
+ *
6783
+ * Absent (or without the source format) means `f32le` — the behaviour every
6784
+ * subscriber had before D455, unchanged. This is the negotiation half of
6785
+ * the source-bytes lever: it is what lets the broker and its consumers
6786
+ * deploy one at a time across three nodes.
6787
+ */
6788
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6689
6789
  });
6690
6790
  /** Result of `stream-broker.subscribeAudioChunks`. */
6691
6791
  var SubscribeAudioChunksResultSchema = object({
@@ -10673,6 +10773,51 @@ var AudioAnalysisSettingsSchema = object({
10673
10773
  minConfidence: number().min(0).max(1).default(.3),
10674
10774
  allowedClasses: array(string()).default([])
10675
10775
  });
10776
+ /**
10777
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10778
+ *
10779
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10780
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10781
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10782
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10783
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10784
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10785
+ * way to the one expansion that feeds the model.
10786
+ *
10787
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10788
+ * window, the per-device node assignment, the settings read) and therefore
10789
+ * still owns the attach/detach pair. It no longer owns the bytes.
10790
+ */
10791
+ var AudioAttachDeviceInputSchema = object({
10792
+ deviceId: number(),
10793
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10794
+ brokerId: string(),
10795
+ /**
10796
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10797
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10798
+ * the orchestrator's poller pinned them before the move.
10799
+ */
10800
+ ingestNodeId: string(),
10801
+ /**
10802
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10803
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10804
+ * window: a settings change re-attaches, which is what always happened.
10805
+ */
10806
+ settings: AudioAnalysisSettingsSchema
10807
+ });
10808
+ var AudioAttachDeviceResultSchema = object({
10809
+ /** False only when the analyzer is shutting down and refused to attach. */
10810
+ attached: boolean(),
10811
+ /**
10812
+ * True when the attachment replaced a live one for the same device. An
10813
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10814
+ * double the broker's fanout and neither would know about the other.
10815
+ */
10816
+ replaced: boolean()
10817
+ });
10818
+ var AudioDetachDeviceResultSchema = object({
10819
+ /** False when no attachment existed — detach is idempotent. */
10820
+ detached: boolean() });
10676
10821
  var AudioClassificationResultSchema = object({
10677
10822
  labels: array(AudioClassificationLabelSchema).readonly(),
10678
10823
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10681,7 +10826,7 @@ var AudioClassificationResultSchema = object({
10681
10826
  method(object({
10682
10827
  chunk: AudioChunkInputSchema,
10683
10828
  settings: AudioAnalysisSettingsSchema
10684
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10829
+ }), 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() }), {
10685
10830
  kind: "mutation",
10686
10831
  auth: "admin"
10687
10832
  });
@@ -20602,6 +20747,14 @@ var NativeCropResultSchema = object({
20602
20747
  * set `encodeJpeg: true`; `bytes` is then absent.
20603
20748
  */
20604
20749
  jpeg: string().optional(),
20750
+ /**
20751
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20752
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20753
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20754
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20755
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20756
+ */
20757
+ jpegBytes: _instanceof(Uint8Array).optional(),
20605
20758
  width: number().int().positive(),
20606
20759
  height: number().int().positive(),
20607
20760
  /**
@@ -20668,7 +20821,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20668
20821
  })]);
20669
20822
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20670
20823
  var ParkedTrackFrameSchema = object({
20671
- jpeg: string(),
20824
+ /**
20825
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20826
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20827
+ * Exactly one of the two is present.
20828
+ */
20829
+ jpeg: string().optional(),
20830
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20831
+ jpegBytes: _instanceof(Uint8Array).optional(),
20672
20832
  width: number().int().positive(),
20673
20833
  height: number().int().positive(),
20674
20834
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21255,6 +21415,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21255
21415
  bbox: NativeCropBboxSchema,
21256
21416
  maxWidth: number().int().positive().optional(),
21257
21417
  /**
21418
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21419
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21420
+ * wire — never assume consent: a pre-D462 caller parses the field as
21421
+ * base64 and bytes would decode to garbage rather than fail.
21422
+ */
21423
+ acceptJpegBytes: boolean().optional(),
21424
+ /**
21258
21425
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21259
21426
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21260
21427
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21322,7 +21489,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21322
21489
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21323
21490
  deviceId: number(),
21324
21491
  trackId: string(),
21325
- kind: ParkedFrameKindSchema
21492
+ kind: ParkedFrameKindSchema,
21493
+ /**
21494
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21495
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21496
+ * wire — never assume consent: a pre-D462 caller parses the field as
21497
+ * base64 and bytes would decode to garbage rather than fail.
21498
+ */
21499
+ acceptJpegBytes: boolean().optional()
21326
21500
  }), ParkedTrackFrameSchema.nullable()), method(object({
21327
21501
  deviceId: number(),
21328
21502
  trackId: string()
@@ -35069,12 +35243,24 @@ Object.freeze({
35069
35243
  addonId: null,
35070
35244
  access: "create"
35071
35245
  },
35246
+ "audioAnalyzer.attachDevice": {
35247
+ capName: "audio-analyzer",
35248
+ capScope: "system",
35249
+ addonId: null,
35250
+ access: "create"
35251
+ },
35072
35252
  "audioAnalyzer.classify": {
35073
35253
  capName: "audio-analyzer",
35074
35254
  capScope: "system",
35075
35255
  addonId: null,
35076
35256
  access: "view"
35077
35257
  },
35258
+ "audioAnalyzer.detachDevice": {
35259
+ capName: "audio-analyzer",
35260
+ capScope: "system",
35261
+ addonId: null,
35262
+ access: "create"
35263
+ },
35078
35264
  "audioAnalyzer.dispose": {
35079
35265
  capName: "audio-analyzer",
35080
35266
  capScope: "system",
@@ -40918,11 +41104,21 @@ Object.freeze({
40918
41104
  form: "single",
40919
41105
  optional: false
40920
41106
  }],
41107
+ "audioAnalyzer.attachDevice": [{
41108
+ name: "deviceId",
41109
+ form: "single",
41110
+ optional: false
41111
+ }],
40921
41112
  "audioAnalyzer.classify": [{
40922
41113
  name: "deviceId",
40923
41114
  form: "single",
40924
41115
  optional: true
40925
41116
  }],
41117
+ "audioAnalyzer.detachDevice": [{
41118
+ name: "deviceId",
41119
+ form: "single",
41120
+ optional: false
41121
+ }],
40926
41122
  "audioMetrics.getCurrentSnapshot": [{
40927
41123
  name: "deviceId",
40928
41124
  form: "single",
@@ -42774,6 +42970,52 @@ Object.freeze({
42774
42970
  "network-access": "ingress",
42775
42971
  "smtp-provider": "email"
42776
42972
  });
42973
+ var G711_SCALE_CORRECTION_DB = {
42974
+ PCMU: 20 * Math.log10(4),
42975
+ PCMA: 20 * Math.log10(8)
42976
+ };
42977
+ /**
42978
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42979
+ * same intent on the ITU-T scale (D460).
42980
+ *
42981
+ * ## When this applies, and when it is the wrong thing to reach for
42982
+ *
42983
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42984
+ * them converts:
42985
+ *
42986
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42987
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42988
+ * after. The defect was never in the number; it was that 19 of this hub's
42989
+ * 25 cameras did not obey it. Converting such a number takes something
42990
+ * correct and makes it wrong, in order to preserve a bug.
42991
+ * - **A measurement taken through the old decoder** — a value someone read
42992
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42993
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42994
+ * louder. That is what this function is for.
42995
+ *
42996
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42997
+ * and it cannot be answered from the number. It is answered by the comment the
42998
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42999
+ * mandatory.
43000
+ *
43001
+ * ## Why a function and not a typed-in number
43002
+ *
43003
+ * `-55 + 12.04` written into a source file is, six months later, completely
43004
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43005
+ * keeps the derivation, the law, and the original measurement all visible at
43006
+ * the call site, so a future reader can disagree with the *premise* instead of
43007
+ * having to reverse-engineer the sum.
43008
+ *
43009
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43010
+ * it is declared. It must never be applied to a live sample or a stored
43011
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43012
+ * adjusting numbers the decoder already got right is the original defect with
43013
+ * an extra place to argue with (D459).
43014
+ */
43015
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43016
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43017
+ }
43018
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42777
43019
  /** Schema defaults — an untouched sub-field must author exactly these. */
42778
43020
  var NC_AUDIO_DEFAULTS = {
42779
43021
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5356,6 +5356,86 @@ var ZodIssueCode = {
5356
5356
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5357
5357
  var ZodFirstPartyTypeKind;
5358
5358
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5359
+ //#endregion
5360
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5361
+ /**
5362
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5363
+ * window to float samples (D455).
5364
+ *
5365
+ * ## Why a format at all
5366
+ *
5367
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5368
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5369
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5370
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5371
+ * the plane carried four times the source. The plane crosses hub-main twice on
5372
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5373
+ *
5374
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5375
+ * them where it needs them. That is the same argument D450 made for the rate,
5376
+ * one step further along the same wire.
5377
+ *
5378
+ * ## Why the expansion lives here
5379
+ *
5380
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5381
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5382
+ * `AudioChunkPlane` expands per subscription) and
5383
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5384
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5385
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5386
+ * into their own dist (`self-contained` externals), so this travels with a
5387
+ * `camstack deploy` and needs no published server.
5388
+ *
5389
+ * A second μ-law table anywhere else is the defect this module exists to
5390
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5391
+ * direction for the WebRTC egress — a different transform, not a copy.)
5392
+ *
5393
+ * ## Absent means f32le
5394
+ *
5395
+ * `format` is optional on the wire and its absence means `f32le` — today's
5396
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5397
+ * has always been served, because the broker only emits a coded window to a
5398
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5399
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5400
+ * deployable one addon at a time across three nodes.
5401
+ */
5402
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5403
+ var AUDIO_CHUNK_FORMATS = [
5404
+ "f32le",
5405
+ "pcmu",
5406
+ "pcma"
5407
+ ];
5408
+ /**
5409
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5410
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5411
+ *
5412
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5413
+ * it buffers the coded bytes and the plane's consumers expand.
5414
+ */
5415
+ function buildUlawTable() {
5416
+ const table = new Float32Array(256);
5417
+ for (let i = 0; i < 256; i++) {
5418
+ const complemented = ~i & 255;
5419
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5420
+ const exponent = complemented >> 4 & 7;
5421
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5422
+ }
5423
+ return table;
5424
+ }
5425
+ /** Build the A-law decode table (ITU-T G.711). */
5426
+ function buildAlawTable() {
5427
+ const table = new Float32Array(256);
5428
+ for (let i = 0; i < 256; i++) {
5429
+ const xored = i ^ 85;
5430
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5431
+ const exponent = xored >> 4 & 7;
5432
+ const mantissa = xored & 15;
5433
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5434
+ }
5435
+ return table;
5436
+ }
5437
+ buildUlawTable();
5438
+ buildAlawTable();
5359
5439
  Object.fromEntries([
5360
5440
  {
5361
5441
  id: "overview",
@@ -6648,11 +6728,20 @@ var SubscribeFramesResultSchema = object({
6648
6728
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6649
6729
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6650
6730
  */
6731
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6651
6732
  var DecodedAudioChunkSchema = object({
6652
6733
  data: _instanceof(Uint8Array),
6653
6734
  sampleRate: number().int().positive(),
6654
6735
  channels: number().int().positive(),
6655
- timestamp: number()
6736
+ timestamp: number(),
6737
+ /**
6738
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6739
+ * byte, for any peer that never heard of this field. A coded window
6740
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6741
+ * subscription that DECLARED it accepts one, so absence can never mean
6742
+ * "coded bytes a consumer will read as floats" (D455).
6743
+ */
6744
+ format: AudioChunkFormatSchema.optional()
6656
6745
  });
6657
6746
  /**
6658
6747
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6664,7 +6753,18 @@ var DecodedAudioChunkSchema = object({
6664
6753
  var SubscribeAudioChunksInputSchema = object({
6665
6754
  brokerId: string(),
6666
6755
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6667
- tag: string().optional()
6756
+ tag: string().optional(),
6757
+ /**
6758
+ * Byte formats this subscriber can READ, best first. The broker serves the
6759
+ * chunk's own format when it is in this list and expands to `f32le`
6760
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6761
+ *
6762
+ * Absent (or without the source format) means `f32le` — the behaviour every
6763
+ * subscriber had before D455, unchanged. This is the negotiation half of
6764
+ * the source-bytes lever: it is what lets the broker and its consumers
6765
+ * deploy one at a time across three nodes.
6766
+ */
6767
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6668
6768
  });
6669
6769
  /** Result of `stream-broker.subscribeAudioChunks`. */
6670
6770
  var SubscribeAudioChunksResultSchema = object({
@@ -10652,6 +10752,51 @@ var AudioAnalysisSettingsSchema = object({
10652
10752
  minConfidence: number().min(0).max(1).default(.3),
10653
10753
  allowedClasses: array(string()).default([])
10654
10754
  });
10755
+ /**
10756
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10757
+ *
10758
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10759
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10760
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10761
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10762
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10763
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10764
+ * way to the one expansion that feeds the model.
10765
+ *
10766
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10767
+ * window, the per-device node assignment, the settings read) and therefore
10768
+ * still owns the attach/detach pair. It no longer owns the bytes.
10769
+ */
10770
+ var AudioAttachDeviceInputSchema = object({
10771
+ deviceId: number(),
10772
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10773
+ brokerId: string(),
10774
+ /**
10775
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10776
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10777
+ * the orchestrator's poller pinned them before the move.
10778
+ */
10779
+ ingestNodeId: string(),
10780
+ /**
10781
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10782
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10783
+ * window: a settings change re-attaches, which is what always happened.
10784
+ */
10785
+ settings: AudioAnalysisSettingsSchema
10786
+ });
10787
+ var AudioAttachDeviceResultSchema = object({
10788
+ /** False only when the analyzer is shutting down and refused to attach. */
10789
+ attached: boolean(),
10790
+ /**
10791
+ * True when the attachment replaced a live one for the same device. An
10792
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10793
+ * double the broker's fanout and neither would know about the other.
10794
+ */
10795
+ replaced: boolean()
10796
+ });
10797
+ var AudioDetachDeviceResultSchema = object({
10798
+ /** False when no attachment existed — detach is idempotent. */
10799
+ detached: boolean() });
10655
10800
  var AudioClassificationResultSchema = object({
10656
10801
  labels: array(AudioClassificationLabelSchema).readonly(),
10657
10802
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10660,7 +10805,7 @@ var AudioClassificationResultSchema = object({
10660
10805
  method(object({
10661
10806
  chunk: AudioChunkInputSchema,
10662
10807
  settings: AudioAnalysisSettingsSchema
10663
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10808
+ }), 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() }), {
10664
10809
  kind: "mutation",
10665
10810
  auth: "admin"
10666
10811
  });
@@ -20581,6 +20726,14 @@ var NativeCropResultSchema = object({
20581
20726
  * set `encodeJpeg: true`; `bytes` is then absent.
20582
20727
  */
20583
20728
  jpeg: string().optional(),
20729
+ /**
20730
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20731
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20732
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20733
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20734
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20735
+ */
20736
+ jpegBytes: _instanceof(Uint8Array).optional(),
20584
20737
  width: number().int().positive(),
20585
20738
  height: number().int().positive(),
20586
20739
  /**
@@ -20647,7 +20800,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20647
20800
  })]);
20648
20801
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20649
20802
  var ParkedTrackFrameSchema = object({
20650
- jpeg: string(),
20803
+ /**
20804
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20805
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20806
+ * Exactly one of the two is present.
20807
+ */
20808
+ jpeg: string().optional(),
20809
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20810
+ jpegBytes: _instanceof(Uint8Array).optional(),
20651
20811
  width: number().int().positive(),
20652
20812
  height: number().int().positive(),
20653
20813
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21234,6 +21394,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21234
21394
  bbox: NativeCropBboxSchema,
21235
21395
  maxWidth: number().int().positive().optional(),
21236
21396
  /**
21397
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21398
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21399
+ * wire — never assume consent: a pre-D462 caller parses the field as
21400
+ * base64 and bytes would decode to garbage rather than fail.
21401
+ */
21402
+ acceptJpegBytes: boolean().optional(),
21403
+ /**
21237
21404
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21238
21405
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21239
21406
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21301,7 +21468,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21301
21468
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21302
21469
  deviceId: number(),
21303
21470
  trackId: string(),
21304
- kind: ParkedFrameKindSchema
21471
+ kind: ParkedFrameKindSchema,
21472
+ /**
21473
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21474
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21475
+ * wire — never assume consent: a pre-D462 caller parses the field as
21476
+ * base64 and bytes would decode to garbage rather than fail.
21477
+ */
21478
+ acceptJpegBytes: boolean().optional()
21305
21479
  }), ParkedTrackFrameSchema.nullable()), method(object({
21306
21480
  deviceId: number(),
21307
21481
  trackId: string()
@@ -35048,12 +35222,24 @@ Object.freeze({
35048
35222
  addonId: null,
35049
35223
  access: "create"
35050
35224
  },
35225
+ "audioAnalyzer.attachDevice": {
35226
+ capName: "audio-analyzer",
35227
+ capScope: "system",
35228
+ addonId: null,
35229
+ access: "create"
35230
+ },
35051
35231
  "audioAnalyzer.classify": {
35052
35232
  capName: "audio-analyzer",
35053
35233
  capScope: "system",
35054
35234
  addonId: null,
35055
35235
  access: "view"
35056
35236
  },
35237
+ "audioAnalyzer.detachDevice": {
35238
+ capName: "audio-analyzer",
35239
+ capScope: "system",
35240
+ addonId: null,
35241
+ access: "create"
35242
+ },
35057
35243
  "audioAnalyzer.dispose": {
35058
35244
  capName: "audio-analyzer",
35059
35245
  capScope: "system",
@@ -40897,11 +41083,21 @@ Object.freeze({
40897
41083
  form: "single",
40898
41084
  optional: false
40899
41085
  }],
41086
+ "audioAnalyzer.attachDevice": [{
41087
+ name: "deviceId",
41088
+ form: "single",
41089
+ optional: false
41090
+ }],
40900
41091
  "audioAnalyzer.classify": [{
40901
41092
  name: "deviceId",
40902
41093
  form: "single",
40903
41094
  optional: true
40904
41095
  }],
41096
+ "audioAnalyzer.detachDevice": [{
41097
+ name: "deviceId",
41098
+ form: "single",
41099
+ optional: false
41100
+ }],
40905
41101
  "audioMetrics.getCurrentSnapshot": [{
40906
41102
  name: "deviceId",
40907
41103
  form: "single",
@@ -42753,6 +42949,52 @@ Object.freeze({
42753
42949
  "network-access": "ingress",
42754
42950
  "smtp-provider": "email"
42755
42951
  });
42952
+ var G711_SCALE_CORRECTION_DB = {
42953
+ PCMU: 20 * Math.log10(4),
42954
+ PCMA: 20 * Math.log10(8)
42955
+ };
42956
+ /**
42957
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42958
+ * same intent on the ITU-T scale (D460).
42959
+ *
42960
+ * ## When this applies, and when it is the wrong thing to reach for
42961
+ *
42962
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42963
+ * them converts:
42964
+ *
42965
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42966
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42967
+ * after. The defect was never in the number; it was that 19 of this hub's
42968
+ * 25 cameras did not obey it. Converting such a number takes something
42969
+ * correct and makes it wrong, in order to preserve a bug.
42970
+ * - **A measurement taken through the old decoder** — a value someone read
42971
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42972
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42973
+ * louder. That is what this function is for.
42974
+ *
42975
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42976
+ * and it cannot be answered from the number. It is answered by the comment the
42977
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42978
+ * mandatory.
42979
+ *
42980
+ * ## Why a function and not a typed-in number
42981
+ *
42982
+ * `-55 + 12.04` written into a source file is, six months later, completely
42983
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42984
+ * keeps the derivation, the law, and the original measurement all visible at
42985
+ * the call site, so a future reader can disagree with the *premise* instead of
42986
+ * having to reverse-engineer the sum.
42987
+ *
42988
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42989
+ * it is declared. It must never be applied to a live sample or a stored
42990
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42991
+ * adjusting numbers the decoder already got right is the original defect with
42992
+ * an extra place to argue with (D459).
42993
+ */
42994
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42995
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42996
+ }
42997
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42756
42998
  /** Schema defaults — an untouched sub-field must author exactly these. */
42757
42999
  var NC_AUDIO_DEFAULTS = {
42758
43000
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-wyze",
3
- "version": "0.2.99",
3
+ "version": "0.2.101",
4
4
  "description": "Wyze camera device-provider addon for CamStack — wraps the @apocaliss92/wyze-bridge-js P2P/DTLS client, feeding the stream-broker via the pull-rfc4571 lazy-publish path (a structural twin of addon-provider-reolink)",
5
5
  "keywords": [
6
6
  "camstack",