@camstack/addon-provider-tuya 0.2.95 → 0.2.97

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
@@ -6165,6 +6165,86 @@ var ZodIssueCode = {
6165
6165
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
6166
6166
  var ZodFirstPartyTypeKind;
6167
6167
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6168
+ //#endregion
6169
+ //#region ../types/dist/sleep-BnujYGPe.mjs
6170
+ /**
6171
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
6172
+ * window to float samples (D455).
6173
+ *
6174
+ * ## Why a format at all
6175
+ *
6176
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
6177
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
6178
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
6179
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
6180
+ * the plane carried four times the source. The plane crosses hub-main twice on
6181
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
6182
+ *
6183
+ * So the plane carries the source BYTES too, and whoever needs floats expands
6184
+ * them where it needs them. That is the same argument D450 made for the rate,
6185
+ * one step further along the same wire.
6186
+ *
6187
+ * ## Why the expansion lives here
6188
+ *
6189
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
6190
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
6191
+ * `AudioChunkPlane` expands per subscription) and
6192
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
6193
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
6194
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
6195
+ * into their own dist (`self-contained` externals), so this travels with a
6196
+ * `camstack deploy` and needs no published server.
6197
+ *
6198
+ * A second μ-law table anywhere else is the defect this module exists to
6199
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
6200
+ * direction for the WebRTC egress — a different transform, not a copy.)
6201
+ *
6202
+ * ## Absent means f32le
6203
+ *
6204
+ * `format` is optional on the wire and its absence means `f32le` — today's
6205
+ * bytes, byte for byte. A peer that never heard of the field is served what it
6206
+ * has always been served, because the broker only emits a coded window to a
6207
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
6208
+ * That is the D448 `rawForward` negotiation, and it is what makes this
6209
+ * deployable one addon at a time across three nodes.
6210
+ */
6211
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
6212
+ var AUDIO_CHUNK_FORMATS = [
6213
+ "f32le",
6214
+ "pcmu",
6215
+ "pcma"
6216
+ ];
6217
+ /**
6218
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
6219
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
6220
+ *
6221
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
6222
+ * it buffers the coded bytes and the plane's consumers expand.
6223
+ */
6224
+ function buildUlawTable() {
6225
+ const table = new Float32Array(256);
6226
+ for (let i = 0; i < 256; i++) {
6227
+ const complemented = ~i & 255;
6228
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
6229
+ const exponent = complemented >> 4 & 7;
6230
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
6231
+ }
6232
+ return table;
6233
+ }
6234
+ /** Build the A-law decode table (ITU-T G.711). */
6235
+ function buildAlawTable() {
6236
+ const table = new Float32Array(256);
6237
+ for (let i = 0; i < 256; i++) {
6238
+ const xored = i ^ 85;
6239
+ const sign = (xored & 128) !== 0 ? 1 : -1;
6240
+ const exponent = xored >> 4 & 7;
6241
+ const mantissa = xored & 15;
6242
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
6243
+ }
6244
+ return table;
6245
+ }
6246
+ buildUlawTable();
6247
+ buildAlawTable();
6168
6248
  Object.fromEntries([
6169
6249
  {
6170
6250
  id: "overview",
@@ -7457,11 +7537,20 @@ var SubscribeFramesResultSchema = object({
7457
7537
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
7458
7538
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
7459
7539
  */
7540
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
7460
7541
  var DecodedAudioChunkSchema = object({
7461
7542
  data: _instanceof(Uint8Array),
7462
7543
  sampleRate: number().int().positive(),
7463
7544
  channels: number().int().positive(),
7464
- timestamp: number()
7545
+ timestamp: number(),
7546
+ /**
7547
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
7548
+ * byte, for any peer that never heard of this field. A coded window
7549
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
7550
+ * subscription that DECLARED it accepts one, so absence can never mean
7551
+ * "coded bytes a consumer will read as floats" (D455).
7552
+ */
7553
+ format: AudioChunkFormatSchema.optional()
7465
7554
  });
7466
7555
  /**
7467
7556
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -7473,7 +7562,18 @@ var DecodedAudioChunkSchema = object({
7473
7562
  var SubscribeAudioChunksInputSchema = object({
7474
7563
  brokerId: string(),
7475
7564
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
7476
- tag: string().optional()
7565
+ tag: string().optional(),
7566
+ /**
7567
+ * Byte formats this subscriber can READ, best first. The broker serves the
7568
+ * chunk's own format when it is in this list and expands to `f32le`
7569
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
7570
+ *
7571
+ * Absent (or without the source format) means `f32le` — the behaviour every
7572
+ * subscriber had before D455, unchanged. This is the negotiation half of
7573
+ * the source-bytes lever: it is what lets the broker and its consumers
7574
+ * deploy one at a time across three nodes.
7575
+ */
7576
+ accept: array(AudioChunkFormatSchema).readonly().optional()
7477
7577
  });
7478
7578
  /** Result of `stream-broker.subscribeAudioChunks`. */
7479
7579
  var SubscribeAudioChunksResultSchema = object({
@@ -11461,6 +11561,51 @@ var AudioAnalysisSettingsSchema = object({
11461
11561
  minConfidence: number().min(0).max(1).default(.3),
11462
11562
  allowedClasses: array(string()).default([])
11463
11563
  });
11564
+ /**
11565
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11566
+ *
11567
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11568
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11569
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11570
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11571
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11572
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11573
+ * way to the one expansion that feeds the model.
11574
+ *
11575
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11576
+ * window, the per-device node assignment, the settings read) and therefore
11577
+ * still owns the attach/detach pair. It no longer owns the bytes.
11578
+ */
11579
+ var AudioAttachDeviceInputSchema = object({
11580
+ deviceId: number(),
11581
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11582
+ brokerId: string(),
11583
+ /**
11584
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11585
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11586
+ * the orchestrator's poller pinned them before the move.
11587
+ */
11588
+ ingestNodeId: string(),
11589
+ /**
11590
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11591
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11592
+ * window: a settings change re-attaches, which is what always happened.
11593
+ */
11594
+ settings: AudioAnalysisSettingsSchema
11595
+ });
11596
+ var AudioAttachDeviceResultSchema = object({
11597
+ /** False only when the analyzer is shutting down and refused to attach. */
11598
+ attached: boolean(),
11599
+ /**
11600
+ * True when the attachment replaced a live one for the same device. An
11601
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11602
+ * double the broker's fanout and neither would know about the other.
11603
+ */
11604
+ replaced: boolean()
11605
+ });
11606
+ var AudioDetachDeviceResultSchema = object({
11607
+ /** False when no attachment existed — detach is idempotent. */
11608
+ detached: boolean() });
11464
11609
  var AudioClassificationResultSchema = object({
11465
11610
  labels: array(AudioClassificationLabelSchema).readonly(),
11466
11611
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11469,7 +11614,7 @@ var AudioClassificationResultSchema = object({
11469
11614
  method(object({
11470
11615
  chunk: AudioChunkInputSchema,
11471
11616
  settings: AudioAnalysisSettingsSchema
11472
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11617
+ }), 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() }), {
11473
11618
  kind: "mutation",
11474
11619
  auth: "admin"
11475
11620
  });
@@ -21390,6 +21535,14 @@ var NativeCropResultSchema = object({
21390
21535
  * set `encodeJpeg: true`; `bytes` is then absent.
21391
21536
  */
21392
21537
  jpeg: string().optional(),
21538
+ /**
21539
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21540
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21541
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21542
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21543
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21544
+ */
21545
+ jpegBytes: _instanceof(Uint8Array).optional(),
21393
21546
  width: number().int().positive(),
21394
21547
  height: number().int().positive(),
21395
21548
  /**
@@ -21456,7 +21609,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21456
21609
  })]);
21457
21610
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21458
21611
  var ParkedTrackFrameSchema = object({
21459
- jpeg: string(),
21612
+ /**
21613
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21614
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21615
+ * Exactly one of the two is present.
21616
+ */
21617
+ jpeg: string().optional(),
21618
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21619
+ jpegBytes: _instanceof(Uint8Array).optional(),
21460
21620
  width: number().int().positive(),
21461
21621
  height: number().int().positive(),
21462
21622
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -22043,6 +22203,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22043
22203
  bbox: NativeCropBboxSchema,
22044
22204
  maxWidth: number().int().positive().optional(),
22045
22205
  /**
22206
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22207
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22208
+ * wire — never assume consent: a pre-D462 caller parses the field as
22209
+ * base64 and bytes would decode to garbage rather than fail.
22210
+ */
22211
+ acceptJpegBytes: boolean().optional(),
22212
+ /**
22046
22213
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
22047
22214
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
22048
22215
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -22110,7 +22277,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22110
22277
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
22111
22278
  deviceId: number(),
22112
22279
  trackId: string(),
22113
- kind: ParkedFrameKindSchema
22280
+ kind: ParkedFrameKindSchema,
22281
+ /**
22282
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22283
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22284
+ * wire — never assume consent: a pre-D462 caller parses the field as
22285
+ * base64 and bytes would decode to garbage rather than fail.
22286
+ */
22287
+ acceptJpegBytes: boolean().optional()
22114
22288
  }), ParkedTrackFrameSchema.nullable()), method(object({
22115
22289
  deviceId: number(),
22116
22290
  trackId: string()
@@ -35753,12 +35927,24 @@ Object.freeze({
35753
35927
  addonId: null,
35754
35928
  access: "create"
35755
35929
  },
35930
+ "audioAnalyzer.attachDevice": {
35931
+ capName: "audio-analyzer",
35932
+ capScope: "system",
35933
+ addonId: null,
35934
+ access: "create"
35935
+ },
35756
35936
  "audioAnalyzer.classify": {
35757
35937
  capName: "audio-analyzer",
35758
35938
  capScope: "system",
35759
35939
  addonId: null,
35760
35940
  access: "view"
35761
35941
  },
35942
+ "audioAnalyzer.detachDevice": {
35943
+ capName: "audio-analyzer",
35944
+ capScope: "system",
35945
+ addonId: null,
35946
+ access: "create"
35947
+ },
35762
35948
  "audioAnalyzer.dispose": {
35763
35949
  capName: "audio-analyzer",
35764
35950
  capScope: "system",
@@ -41602,11 +41788,21 @@ Object.freeze({
41602
41788
  form: "single",
41603
41789
  optional: false
41604
41790
  }],
41791
+ "audioAnalyzer.attachDevice": [{
41792
+ name: "deviceId",
41793
+ form: "single",
41794
+ optional: false
41795
+ }],
41605
41796
  "audioAnalyzer.classify": [{
41606
41797
  name: "deviceId",
41607
41798
  form: "single",
41608
41799
  optional: true
41609
41800
  }],
41801
+ "audioAnalyzer.detachDevice": [{
41802
+ name: "deviceId",
41803
+ form: "single",
41804
+ optional: false
41805
+ }],
41610
41806
  "audioMetrics.getCurrentSnapshot": [{
41611
41807
  name: "deviceId",
41612
41808
  form: "single",
@@ -43458,6 +43654,52 @@ Object.freeze({
43458
43654
  "network-access": "ingress",
43459
43655
  "smtp-provider": "email"
43460
43656
  });
43657
+ var G711_SCALE_CORRECTION_DB = {
43658
+ PCMU: 20 * Math.log10(4),
43659
+ PCMA: 20 * Math.log10(8)
43660
+ };
43661
+ /**
43662
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43663
+ * same intent on the ITU-T scale (D460).
43664
+ *
43665
+ * ## When this applies, and when it is the wrong thing to reach for
43666
+ *
43667
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43668
+ * them converts:
43669
+ *
43670
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43671
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43672
+ * after. The defect was never in the number; it was that 19 of this hub's
43673
+ * 25 cameras did not obey it. Converting such a number takes something
43674
+ * correct and makes it wrong, in order to preserve a bug.
43675
+ * - **A measurement taken through the old decoder** — a value someone read
43676
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43677
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43678
+ * louder. That is what this function is for.
43679
+ *
43680
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43681
+ * and it cannot be answered from the number. It is answered by the comment the
43682
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43683
+ * mandatory.
43684
+ *
43685
+ * ## Why a function and not a typed-in number
43686
+ *
43687
+ * `-55 + 12.04` written into a source file is, six months later, completely
43688
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43689
+ * keeps the derivation, the law, and the original measurement all visible at
43690
+ * the call site, so a future reader can disagree with the *premise* instead of
43691
+ * having to reverse-engineer the sum.
43692
+ *
43693
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43694
+ * it is declared. It must never be applied to a live sample or a stored
43695
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43696
+ * adjusting numbers the decoder already got right is the original defect with
43697
+ * an extra place to argue with (D459).
43698
+ */
43699
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43700
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43701
+ }
43702
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43461
43703
  /** Schema defaults — an untouched sub-field must author exactly these. */
43462
43704
  var NC_AUDIO_DEFAULTS = {
43463
43705
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -6164,6 +6164,86 @@ var ZodIssueCode = {
6164
6164
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
6165
6165
  var ZodFirstPartyTypeKind;
6166
6166
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6167
+ //#endregion
6168
+ //#region ../types/dist/sleep-BnujYGPe.mjs
6169
+ /**
6170
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
6171
+ * window to float samples (D455).
6172
+ *
6173
+ * ## Why a format at all
6174
+ *
6175
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
6176
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
6177
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
6178
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
6179
+ * the plane carried four times the source. The plane crosses hub-main twice on
6180
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
6181
+ *
6182
+ * So the plane carries the source BYTES too, and whoever needs floats expands
6183
+ * them where it needs them. That is the same argument D450 made for the rate,
6184
+ * one step further along the same wire.
6185
+ *
6186
+ * ## Why the expansion lives here
6187
+ *
6188
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
6189
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
6190
+ * `AudioChunkPlane` expands per subscription) and
6191
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
6192
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
6193
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
6194
+ * into their own dist (`self-contained` externals), so this travels with a
6195
+ * `camstack deploy` and needs no published server.
6196
+ *
6197
+ * A second μ-law table anywhere else is the defect this module exists to
6198
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
6199
+ * direction for the WebRTC egress — a different transform, not a copy.)
6200
+ *
6201
+ * ## Absent means f32le
6202
+ *
6203
+ * `format` is optional on the wire and its absence means `f32le` — today's
6204
+ * bytes, byte for byte. A peer that never heard of the field is served what it
6205
+ * has always been served, because the broker only emits a coded window to a
6206
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
6207
+ * That is the D448 `rawForward` negotiation, and it is what makes this
6208
+ * deployable one addon at a time across three nodes.
6209
+ */
6210
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
6211
+ var AUDIO_CHUNK_FORMATS = [
6212
+ "f32le",
6213
+ "pcmu",
6214
+ "pcma"
6215
+ ];
6216
+ /**
6217
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
6218
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
6219
+ *
6220
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
6221
+ * it buffers the coded bytes and the plane's consumers expand.
6222
+ */
6223
+ function buildUlawTable() {
6224
+ const table = new Float32Array(256);
6225
+ for (let i = 0; i < 256; i++) {
6226
+ const complemented = ~i & 255;
6227
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
6228
+ const exponent = complemented >> 4 & 7;
6229
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
6230
+ }
6231
+ return table;
6232
+ }
6233
+ /** Build the A-law decode table (ITU-T G.711). */
6234
+ function buildAlawTable() {
6235
+ const table = new Float32Array(256);
6236
+ for (let i = 0; i < 256; i++) {
6237
+ const xored = i ^ 85;
6238
+ const sign = (xored & 128) !== 0 ? 1 : -1;
6239
+ const exponent = xored >> 4 & 7;
6240
+ const mantissa = xored & 15;
6241
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
6242
+ }
6243
+ return table;
6244
+ }
6245
+ buildUlawTable();
6246
+ buildAlawTable();
6167
6247
  Object.fromEntries([
6168
6248
  {
6169
6249
  id: "overview",
@@ -7456,11 +7536,20 @@ var SubscribeFramesResultSchema = object({
7456
7536
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
7457
7537
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
7458
7538
  */
7539
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
7459
7540
  var DecodedAudioChunkSchema = object({
7460
7541
  data: _instanceof(Uint8Array),
7461
7542
  sampleRate: number().int().positive(),
7462
7543
  channels: number().int().positive(),
7463
- timestamp: number()
7544
+ timestamp: number(),
7545
+ /**
7546
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
7547
+ * byte, for any peer that never heard of this field. A coded window
7548
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
7549
+ * subscription that DECLARED it accepts one, so absence can never mean
7550
+ * "coded bytes a consumer will read as floats" (D455).
7551
+ */
7552
+ format: AudioChunkFormatSchema.optional()
7464
7553
  });
7465
7554
  /**
7466
7555
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -7472,7 +7561,18 @@ var DecodedAudioChunkSchema = object({
7472
7561
  var SubscribeAudioChunksInputSchema = object({
7473
7562
  brokerId: string(),
7474
7563
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
7475
- tag: string().optional()
7564
+ tag: string().optional(),
7565
+ /**
7566
+ * Byte formats this subscriber can READ, best first. The broker serves the
7567
+ * chunk's own format when it is in this list and expands to `f32le`
7568
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
7569
+ *
7570
+ * Absent (or without the source format) means `f32le` — the behaviour every
7571
+ * subscriber had before D455, unchanged. This is the negotiation half of
7572
+ * the source-bytes lever: it is what lets the broker and its consumers
7573
+ * deploy one at a time across three nodes.
7574
+ */
7575
+ accept: array(AudioChunkFormatSchema).readonly().optional()
7476
7576
  });
7477
7577
  /** Result of `stream-broker.subscribeAudioChunks`. */
7478
7578
  var SubscribeAudioChunksResultSchema = object({
@@ -11460,6 +11560,51 @@ var AudioAnalysisSettingsSchema = object({
11460
11560
  minConfidence: number().min(0).max(1).default(.3),
11461
11561
  allowedClasses: array(string()).default([])
11462
11562
  });
11563
+ /**
11564
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11565
+ *
11566
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11567
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11568
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11569
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11570
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11571
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11572
+ * way to the one expansion that feeds the model.
11573
+ *
11574
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11575
+ * window, the per-device node assignment, the settings read) and therefore
11576
+ * still owns the attach/detach pair. It no longer owns the bytes.
11577
+ */
11578
+ var AudioAttachDeviceInputSchema = object({
11579
+ deviceId: number(),
11580
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11581
+ brokerId: string(),
11582
+ /**
11583
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11584
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11585
+ * the orchestrator's poller pinned them before the move.
11586
+ */
11587
+ ingestNodeId: string(),
11588
+ /**
11589
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11590
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11591
+ * window: a settings change re-attaches, which is what always happened.
11592
+ */
11593
+ settings: AudioAnalysisSettingsSchema
11594
+ });
11595
+ var AudioAttachDeviceResultSchema = object({
11596
+ /** False only when the analyzer is shutting down and refused to attach. */
11597
+ attached: boolean(),
11598
+ /**
11599
+ * True when the attachment replaced a live one for the same device. An
11600
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11601
+ * double the broker's fanout and neither would know about the other.
11602
+ */
11603
+ replaced: boolean()
11604
+ });
11605
+ var AudioDetachDeviceResultSchema = object({
11606
+ /** False when no attachment existed — detach is idempotent. */
11607
+ detached: boolean() });
11463
11608
  var AudioClassificationResultSchema = object({
11464
11609
  labels: array(AudioClassificationLabelSchema).readonly(),
11465
11610
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11468,7 +11613,7 @@ var AudioClassificationResultSchema = object({
11468
11613
  method(object({
11469
11614
  chunk: AudioChunkInputSchema,
11470
11615
  settings: AudioAnalysisSettingsSchema
11471
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11616
+ }), 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() }), {
11472
11617
  kind: "mutation",
11473
11618
  auth: "admin"
11474
11619
  });
@@ -21389,6 +21534,14 @@ var NativeCropResultSchema = object({
21389
21534
  * set `encodeJpeg: true`; `bytes` is then absent.
21390
21535
  */
21391
21536
  jpeg: string().optional(),
21537
+ /**
21538
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21539
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21540
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21541
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21542
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21543
+ */
21544
+ jpegBytes: _instanceof(Uint8Array).optional(),
21392
21545
  width: number().int().positive(),
21393
21546
  height: number().int().positive(),
21394
21547
  /**
@@ -21455,7 +21608,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21455
21608
  })]);
21456
21609
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21457
21610
  var ParkedTrackFrameSchema = object({
21458
- jpeg: string(),
21611
+ /**
21612
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21613
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21614
+ * Exactly one of the two is present.
21615
+ */
21616
+ jpeg: string().optional(),
21617
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21618
+ jpegBytes: _instanceof(Uint8Array).optional(),
21459
21619
  width: number().int().positive(),
21460
21620
  height: number().int().positive(),
21461
21621
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -22042,6 +22202,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22042
22202
  bbox: NativeCropBboxSchema,
22043
22203
  maxWidth: number().int().positive().optional(),
22044
22204
  /**
22205
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22206
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22207
+ * wire — never assume consent: a pre-D462 caller parses the field as
22208
+ * base64 and bytes would decode to garbage rather than fail.
22209
+ */
22210
+ acceptJpegBytes: boolean().optional(),
22211
+ /**
22045
22212
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
22046
22213
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
22047
22214
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -22109,7 +22276,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22109
22276
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
22110
22277
  deviceId: number(),
22111
22278
  trackId: string(),
22112
- kind: ParkedFrameKindSchema
22279
+ kind: ParkedFrameKindSchema,
22280
+ /**
22281
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22282
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22283
+ * wire — never assume consent: a pre-D462 caller parses the field as
22284
+ * base64 and bytes would decode to garbage rather than fail.
22285
+ */
22286
+ acceptJpegBytes: boolean().optional()
22113
22287
  }), ParkedTrackFrameSchema.nullable()), method(object({
22114
22288
  deviceId: number(),
22115
22289
  trackId: string()
@@ -35752,12 +35926,24 @@ Object.freeze({
35752
35926
  addonId: null,
35753
35927
  access: "create"
35754
35928
  },
35929
+ "audioAnalyzer.attachDevice": {
35930
+ capName: "audio-analyzer",
35931
+ capScope: "system",
35932
+ addonId: null,
35933
+ access: "create"
35934
+ },
35755
35935
  "audioAnalyzer.classify": {
35756
35936
  capName: "audio-analyzer",
35757
35937
  capScope: "system",
35758
35938
  addonId: null,
35759
35939
  access: "view"
35760
35940
  },
35941
+ "audioAnalyzer.detachDevice": {
35942
+ capName: "audio-analyzer",
35943
+ capScope: "system",
35944
+ addonId: null,
35945
+ access: "create"
35946
+ },
35761
35947
  "audioAnalyzer.dispose": {
35762
35948
  capName: "audio-analyzer",
35763
35949
  capScope: "system",
@@ -41601,11 +41787,21 @@ Object.freeze({
41601
41787
  form: "single",
41602
41788
  optional: false
41603
41789
  }],
41790
+ "audioAnalyzer.attachDevice": [{
41791
+ name: "deviceId",
41792
+ form: "single",
41793
+ optional: false
41794
+ }],
41604
41795
  "audioAnalyzer.classify": [{
41605
41796
  name: "deviceId",
41606
41797
  form: "single",
41607
41798
  optional: true
41608
41799
  }],
41800
+ "audioAnalyzer.detachDevice": [{
41801
+ name: "deviceId",
41802
+ form: "single",
41803
+ optional: false
41804
+ }],
41609
41805
  "audioMetrics.getCurrentSnapshot": [{
41610
41806
  name: "deviceId",
41611
41807
  form: "single",
@@ -43457,6 +43653,52 @@ Object.freeze({
43457
43653
  "network-access": "ingress",
43458
43654
  "smtp-provider": "email"
43459
43655
  });
43656
+ var G711_SCALE_CORRECTION_DB = {
43657
+ PCMU: 20 * Math.log10(4),
43658
+ PCMA: 20 * Math.log10(8)
43659
+ };
43660
+ /**
43661
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43662
+ * same intent on the ITU-T scale (D460).
43663
+ *
43664
+ * ## When this applies, and when it is the wrong thing to reach for
43665
+ *
43666
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43667
+ * them converts:
43668
+ *
43669
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43670
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43671
+ * after. The defect was never in the number; it was that 19 of this hub's
43672
+ * 25 cameras did not obey it. Converting such a number takes something
43673
+ * correct and makes it wrong, in order to preserve a bug.
43674
+ * - **A measurement taken through the old decoder** — a value someone read
43675
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43676
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43677
+ * louder. That is what this function is for.
43678
+ *
43679
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43680
+ * and it cannot be answered from the number. It is answered by the comment the
43681
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43682
+ * mandatory.
43683
+ *
43684
+ * ## Why a function and not a typed-in number
43685
+ *
43686
+ * `-55 + 12.04` written into a source file is, six months later, completely
43687
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43688
+ * keeps the derivation, the law, and the original measurement all visible at
43689
+ * the call site, so a future reader can disagree with the *premise* instead of
43690
+ * having to reverse-engineer the sum.
43691
+ *
43692
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43693
+ * it is declared. It must never be applied to a live sample or a stored
43694
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43695
+ * adjusting numbers the decoder already got right is the original defect with
43696
+ * an extra place to argue with (D459).
43697
+ */
43698
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43699
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43700
+ }
43701
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43460
43702
  /** Schema defaults — an untouched sub-field must author exactly these. */
43461
43703
  var NC_AUDIO_DEFAULTS = {
43462
43704
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-tuya",
3
- "version": "0.2.95",
3
+ "version": "0.2.97",
4
4
  "description": "Tuya / Smart Life device-provider addon for CamStack — account-onboarded (Tuya IoT cloud fetch of device localKeys) + LOCAL DP control via the @apocaliss92/nodetuya encrypted-LAN client, exposing switch / water-heater-family kettle entities",
5
5
  "keywords": [
6
6
  "camstack",