@camstack/addon-provider-dreame 0.2.96 → 0.2.98

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
@@ -58018,6 +58018,86 @@ var ZodIssueCode = {
58018
58018
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
58019
58019
  var ZodFirstPartyTypeKind;
58020
58020
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
58021
+ //#endregion
58022
+ //#region ../types/dist/sleep-BnujYGPe.mjs
58023
+ /**
58024
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
58025
+ * window to float samples (D455).
58026
+ *
58027
+ * ## Why a format at all
58028
+ *
58029
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
58030
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
58031
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
58032
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
58033
+ * the plane carried four times the source. The plane crosses hub-main twice on
58034
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
58035
+ *
58036
+ * So the plane carries the source BYTES too, and whoever needs floats expands
58037
+ * them where it needs them. That is the same argument D450 made for the rate,
58038
+ * one step further along the same wire.
58039
+ *
58040
+ * ## Why the expansion lives here
58041
+ *
58042
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
58043
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
58044
+ * `AudioChunkPlane` expands per subscription) and
58045
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
58046
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
58047
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
58048
+ * into their own dist (`self-contained` externals), so this travels with a
58049
+ * `camstack deploy` and needs no published server.
58050
+ *
58051
+ * A second μ-law table anywhere else is the defect this module exists to
58052
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
58053
+ * direction for the WebRTC egress — a different transform, not a copy.)
58054
+ *
58055
+ * ## Absent means f32le
58056
+ *
58057
+ * `format` is optional on the wire and its absence means `f32le` — today's
58058
+ * bytes, byte for byte. A peer that never heard of the field is served what it
58059
+ * has always been served, because the broker only emits a coded window to a
58060
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
58061
+ * That is the D448 `rawForward` negotiation, and it is what makes this
58062
+ * deployable one addon at a time across three nodes.
58063
+ */
58064
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
58065
+ var AUDIO_CHUNK_FORMATS = [
58066
+ "f32le",
58067
+ "pcmu",
58068
+ "pcma"
58069
+ ];
58070
+ /**
58071
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
58072
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
58073
+ *
58074
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
58075
+ * it buffers the coded bytes and the plane's consumers expand.
58076
+ */
58077
+ function buildUlawTable() {
58078
+ const table = new Float32Array(256);
58079
+ for (let i = 0; i < 256; i++) {
58080
+ const complemented = ~i & 255;
58081
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
58082
+ const exponent = complemented >> 4 & 7;
58083
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
58084
+ }
58085
+ return table;
58086
+ }
58087
+ /** Build the A-law decode table (ITU-T G.711). */
58088
+ function buildAlawTable() {
58089
+ const table = new Float32Array(256);
58090
+ for (let i = 0; i < 256; i++) {
58091
+ const xored = i ^ 85;
58092
+ const sign = (xored & 128) !== 0 ? 1 : -1;
58093
+ const exponent = xored >> 4 & 7;
58094
+ const mantissa = xored & 15;
58095
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
58096
+ }
58097
+ return table;
58098
+ }
58099
+ buildUlawTable();
58100
+ buildAlawTable();
58021
58101
  Object.fromEntries([
58022
58102
  {
58023
58103
  id: "overview",
@@ -59310,11 +59390,20 @@ var SubscribeFramesResultSchema = object({
59310
59390
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
59311
59391
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
59312
59392
  */
59393
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
59313
59394
  var DecodedAudioChunkSchema = object({
59314
59395
  data: _instanceof(Uint8Array),
59315
59396
  sampleRate: number().int().positive(),
59316
59397
  channels: number().int().positive(),
59317
- timestamp: number()
59398
+ timestamp: number(),
59399
+ /**
59400
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
59401
+ * byte, for any peer that never heard of this field. A coded window
59402
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
59403
+ * subscription that DECLARED it accepts one, so absence can never mean
59404
+ * "coded bytes a consumer will read as floats" (D455).
59405
+ */
59406
+ format: AudioChunkFormatSchema.optional()
59318
59407
  });
59319
59408
  /**
59320
59409
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -59326,7 +59415,18 @@ var DecodedAudioChunkSchema = object({
59326
59415
  var SubscribeAudioChunksInputSchema = object({
59327
59416
  brokerId: string(),
59328
59417
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
59329
- tag: string().optional()
59418
+ tag: string().optional(),
59419
+ /**
59420
+ * Byte formats this subscriber can READ, best first. The broker serves the
59421
+ * chunk's own format when it is in this list and expands to `f32le`
59422
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
59423
+ *
59424
+ * Absent (or without the source format) means `f32le` — the behaviour every
59425
+ * subscriber had before D455, unchanged. This is the negotiation half of
59426
+ * the source-bytes lever: it is what lets the broker and its consumers
59427
+ * deploy one at a time across three nodes.
59428
+ */
59429
+ accept: array(AudioChunkFormatSchema).readonly().optional()
59330
59430
  });
59331
59431
  /** Result of `stream-broker.subscribeAudioChunks`. */
59332
59432
  var SubscribeAudioChunksResultSchema = object({
@@ -63314,6 +63414,51 @@ var AudioAnalysisSettingsSchema = object({
63314
63414
  minConfidence: number().min(0).max(1).default(.3),
63315
63415
  allowedClasses: array(string()).default([])
63316
63416
  });
63417
+ /**
63418
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
63419
+ *
63420
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
63421
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
63422
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
63423
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
63424
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
63425
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
63426
+ * way to the one expansion that feeds the model.
63427
+ *
63428
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
63429
+ * window, the per-device node assignment, the settings read) and therefore
63430
+ * still owns the attach/detach pair. It no longer owns the bytes.
63431
+ */
63432
+ var AudioAttachDeviceInputSchema = object({
63433
+ deviceId: number(),
63434
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
63435
+ brokerId: string(),
63436
+ /**
63437
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
63438
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
63439
+ * the orchestrator's poller pinned them before the move.
63440
+ */
63441
+ ingestNodeId: string(),
63442
+ /**
63443
+ * Resolved once by the orchestrator at attach time, exactly as it was read
63444
+ * once per subscription before D461. The analyzer does NOT re-resolve per
63445
+ * window: a settings change re-attaches, which is what always happened.
63446
+ */
63447
+ settings: AudioAnalysisSettingsSchema
63448
+ });
63449
+ var AudioAttachDeviceResultSchema = object({
63450
+ /** False only when the analyzer is shutting down and refused to attach. */
63451
+ attached: boolean(),
63452
+ /**
63453
+ * True when the attachment replaced a live one for the same device. An
63454
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
63455
+ * double the broker's fanout and neither would know about the other.
63456
+ */
63457
+ replaced: boolean()
63458
+ });
63459
+ var AudioDetachDeviceResultSchema = object({
63460
+ /** False when no attachment existed — detach is idempotent. */
63461
+ detached: boolean() });
63317
63462
  var AudioClassificationResultSchema = object({
63318
63463
  labels: array(AudioClassificationLabelSchema).readonly(),
63319
63464
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -63322,7 +63467,7 @@ var AudioClassificationResultSchema = object({
63322
63467
  method(object({
63323
63468
  chunk: AudioChunkInputSchema,
63324
63469
  settings: AudioAnalysisSettingsSchema
63325
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
63470
+ }), 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() }), {
63326
63471
  kind: "mutation",
63327
63472
  auth: "admin"
63328
63473
  });
@@ -73243,6 +73388,14 @@ var NativeCropResultSchema = object({
73243
73388
  * set `encodeJpeg: true`; `bytes` is then absent.
73244
73389
  */
73245
73390
  jpeg: string().optional(),
73391
+ /**
73392
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
73393
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
73394
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
73395
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
73396
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
73397
+ */
73398
+ jpegBytes: _instanceof(Uint8Array).optional(),
73246
73399
  width: number().int().positive(),
73247
73400
  height: number().int().positive(),
73248
73401
  /**
@@ -73309,7 +73462,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
73309
73462
  })]);
73310
73463
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
73311
73464
  var ParkedTrackFrameSchema = object({
73312
- jpeg: string(),
73465
+ /**
73466
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
73467
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
73468
+ * Exactly one of the two is present.
73469
+ */
73470
+ jpeg: string().optional(),
73471
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
73472
+ jpegBytes: _instanceof(Uint8Array).optional(),
73313
73473
  width: number().int().positive(),
73314
73474
  height: number().int().positive(),
73315
73475
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -73896,6 +74056,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
73896
74056
  bbox: NativeCropBboxSchema,
73897
74057
  maxWidth: number().int().positive().optional(),
73898
74058
  /**
74059
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
74060
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
74061
+ * wire — never assume consent: a pre-D462 caller parses the field as
74062
+ * base64 and bytes would decode to garbage rather than fail.
74063
+ */
74064
+ acceptJpegBytes: boolean().optional(),
74065
+ /**
73899
74066
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
73900
74067
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
73901
74068
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -73963,7 +74130,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
73963
74130
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
73964
74131
  deviceId: number(),
73965
74132
  trackId: string(),
73966
- kind: ParkedFrameKindSchema
74133
+ kind: ParkedFrameKindSchema,
74134
+ /**
74135
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
74136
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
74137
+ * wire — never assume consent: a pre-D462 caller parses the field as
74138
+ * base64 and bytes would decode to garbage rather than fail.
74139
+ */
74140
+ acceptJpegBytes: boolean().optional()
73967
74141
  }), ParkedTrackFrameSchema.nullable()), method(object({
73968
74142
  deviceId: number(),
73969
74143
  trackId: string()
@@ -87771,12 +87945,24 @@ Object.freeze({
87771
87945
  addonId: null,
87772
87946
  access: "create"
87773
87947
  },
87948
+ "audioAnalyzer.attachDevice": {
87949
+ capName: "audio-analyzer",
87950
+ capScope: "system",
87951
+ addonId: null,
87952
+ access: "create"
87953
+ },
87774
87954
  "audioAnalyzer.classify": {
87775
87955
  capName: "audio-analyzer",
87776
87956
  capScope: "system",
87777
87957
  addonId: null,
87778
87958
  access: "view"
87779
87959
  },
87960
+ "audioAnalyzer.detachDevice": {
87961
+ capName: "audio-analyzer",
87962
+ capScope: "system",
87963
+ addonId: null,
87964
+ access: "create"
87965
+ },
87780
87966
  "audioAnalyzer.dispose": {
87781
87967
  capName: "audio-analyzer",
87782
87968
  capScope: "system",
@@ -93620,11 +93806,21 @@ Object.freeze({
93620
93806
  form: "single",
93621
93807
  optional: false
93622
93808
  }],
93809
+ "audioAnalyzer.attachDevice": [{
93810
+ name: "deviceId",
93811
+ form: "single",
93812
+ optional: false
93813
+ }],
93623
93814
  "audioAnalyzer.classify": [{
93624
93815
  name: "deviceId",
93625
93816
  form: "single",
93626
93817
  optional: true
93627
93818
  }],
93819
+ "audioAnalyzer.detachDevice": [{
93820
+ name: "deviceId",
93821
+ form: "single",
93822
+ optional: false
93823
+ }],
93628
93824
  "audioMetrics.getCurrentSnapshot": [{
93629
93825
  name: "deviceId",
93630
93826
  form: "single",
@@ -95476,6 +95672,52 @@ Object.freeze({
95476
95672
  "network-access": "ingress",
95477
95673
  "smtp-provider": "email"
95478
95674
  });
95675
+ var G711_SCALE_CORRECTION_DB = {
95676
+ PCMU: 20 * Math.log10(4),
95677
+ PCMA: 20 * Math.log10(8)
95678
+ };
95679
+ /**
95680
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
95681
+ * same intent on the ITU-T scale (D460).
95682
+ *
95683
+ * ## When this applies, and when it is the wrong thing to reach for
95684
+ *
95685
+ * An absolute-dBFS number in this repo is one of two things, and only one of
95686
+ * them converts:
95687
+ *
95688
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
95689
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
95690
+ * after. The defect was never in the number; it was that 19 of this hub's
95691
+ * 25 cameras did not obey it. Converting such a number takes something
95692
+ * correct and makes it wrong, in order to preserve a bug.
95693
+ * - **A measurement taken through the old decoder** — a value someone read
95694
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
95695
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
95696
+ * louder. That is what this function is for.
95697
+ *
95698
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
95699
+ * and it cannot be answered from the number. It is answered by the comment the
95700
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
95701
+ * mandatory.
95702
+ *
95703
+ * ## Why a function and not a typed-in number
95704
+ *
95705
+ * `-55 + 12.04` written into a source file is, six months later, completely
95706
+ * indistinguishable from a threshold somebody simply preferred. Calling this
95707
+ * keeps the derivation, the law, and the original measurement all visible at
95708
+ * the call site, so a future reader can disagree with the *premise* instead of
95709
+ * having to reverse-engineer the sum.
95710
+ *
95711
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
95712
+ * it is declared. It must never be applied to a live sample or a stored
95713
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
95714
+ * adjusting numbers the decoder already got right is the original defect with
95715
+ * an extra place to argue with (D459).
95716
+ */
95717
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
95718
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
95719
+ }
95720
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
95479
95721
  /** Schema defaults — an untouched sub-field must author exactly these. */
95480
95722
  var NC_AUDIO_DEFAULTS = {
95481
95723
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -58015,6 +58015,86 @@ var ZodIssueCode = {
58015
58015
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
58016
58016
  var ZodFirstPartyTypeKind;
58017
58017
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
58018
+ //#endregion
58019
+ //#region ../types/dist/sleep-BnujYGPe.mjs
58020
+ /**
58021
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
58022
+ * window to float samples (D455).
58023
+ *
58024
+ * ## Why a format at all
58025
+ *
58026
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
58027
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
58028
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
58029
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
58030
+ * the plane carried four times the source. The plane crosses hub-main twice on
58031
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
58032
+ *
58033
+ * So the plane carries the source BYTES too, and whoever needs floats expands
58034
+ * them where it needs them. That is the same argument D450 made for the rate,
58035
+ * one step further along the same wire.
58036
+ *
58037
+ * ## Why the expansion lives here
58038
+ *
58039
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
58040
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
58041
+ * `AudioChunkPlane` expands per subscription) and
58042
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
58043
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
58044
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
58045
+ * into their own dist (`self-contained` externals), so this travels with a
58046
+ * `camstack deploy` and needs no published server.
58047
+ *
58048
+ * A second μ-law table anywhere else is the defect this module exists to
58049
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
58050
+ * direction for the WebRTC egress — a different transform, not a copy.)
58051
+ *
58052
+ * ## Absent means f32le
58053
+ *
58054
+ * `format` is optional on the wire and its absence means `f32le` — today's
58055
+ * bytes, byte for byte. A peer that never heard of the field is served what it
58056
+ * has always been served, because the broker only emits a coded window to a
58057
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
58058
+ * That is the D448 `rawForward` negotiation, and it is what makes this
58059
+ * deployable one addon at a time across three nodes.
58060
+ */
58061
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
58062
+ var AUDIO_CHUNK_FORMATS = [
58063
+ "f32le",
58064
+ "pcmu",
58065
+ "pcma"
58066
+ ];
58067
+ /**
58068
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
58069
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
58070
+ *
58071
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
58072
+ * it buffers the coded bytes and the plane's consumers expand.
58073
+ */
58074
+ function buildUlawTable() {
58075
+ const table = new Float32Array(256);
58076
+ for (let i = 0; i < 256; i++) {
58077
+ const complemented = ~i & 255;
58078
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
58079
+ const exponent = complemented >> 4 & 7;
58080
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
58081
+ }
58082
+ return table;
58083
+ }
58084
+ /** Build the A-law decode table (ITU-T G.711). */
58085
+ function buildAlawTable() {
58086
+ const table = new Float32Array(256);
58087
+ for (let i = 0; i < 256; i++) {
58088
+ const xored = i ^ 85;
58089
+ const sign = (xored & 128) !== 0 ? 1 : -1;
58090
+ const exponent = xored >> 4 & 7;
58091
+ const mantissa = xored & 15;
58092
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
58093
+ }
58094
+ return table;
58095
+ }
58096
+ buildUlawTable();
58097
+ buildAlawTable();
58018
58098
  Object.fromEntries([
58019
58099
  {
58020
58100
  id: "overview",
@@ -59307,11 +59387,20 @@ var SubscribeFramesResultSchema = object({
59307
59387
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
59308
59388
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
59309
59389
  */
59390
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
59310
59391
  var DecodedAudioChunkSchema = object({
59311
59392
  data: _instanceof(Uint8Array),
59312
59393
  sampleRate: number().int().positive(),
59313
59394
  channels: number().int().positive(),
59314
- timestamp: number()
59395
+ timestamp: number(),
59396
+ /**
59397
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
59398
+ * byte, for any peer that never heard of this field. A coded window
59399
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
59400
+ * subscription that DECLARED it accepts one, so absence can never mean
59401
+ * "coded bytes a consumer will read as floats" (D455).
59402
+ */
59403
+ format: AudioChunkFormatSchema.optional()
59315
59404
  });
59316
59405
  /**
59317
59406
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -59323,7 +59412,18 @@ var DecodedAudioChunkSchema = object({
59323
59412
  var SubscribeAudioChunksInputSchema = object({
59324
59413
  brokerId: string(),
59325
59414
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
59326
- tag: string().optional()
59415
+ tag: string().optional(),
59416
+ /**
59417
+ * Byte formats this subscriber can READ, best first. The broker serves the
59418
+ * chunk's own format when it is in this list and expands to `f32le`
59419
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
59420
+ *
59421
+ * Absent (or without the source format) means `f32le` — the behaviour every
59422
+ * subscriber had before D455, unchanged. This is the negotiation half of
59423
+ * the source-bytes lever: it is what lets the broker and its consumers
59424
+ * deploy one at a time across three nodes.
59425
+ */
59426
+ accept: array(AudioChunkFormatSchema).readonly().optional()
59327
59427
  });
59328
59428
  /** Result of `stream-broker.subscribeAudioChunks`. */
59329
59429
  var SubscribeAudioChunksResultSchema = object({
@@ -63311,6 +63411,51 @@ var AudioAnalysisSettingsSchema = object({
63311
63411
  minConfidence: number().min(0).max(1).default(.3),
63312
63412
  allowedClasses: array(string()).default([])
63313
63413
  });
63414
+ /**
63415
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
63416
+ *
63417
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
63418
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
63419
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
63420
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
63421
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
63422
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
63423
+ * way to the one expansion that feeds the model.
63424
+ *
63425
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
63426
+ * window, the per-device node assignment, the settings read) and therefore
63427
+ * still owns the attach/detach pair. It no longer owns the bytes.
63428
+ */
63429
+ var AudioAttachDeviceInputSchema = object({
63430
+ deviceId: number(),
63431
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
63432
+ brokerId: string(),
63433
+ /**
63434
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
63435
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
63436
+ * the orchestrator's poller pinned them before the move.
63437
+ */
63438
+ ingestNodeId: string(),
63439
+ /**
63440
+ * Resolved once by the orchestrator at attach time, exactly as it was read
63441
+ * once per subscription before D461. The analyzer does NOT re-resolve per
63442
+ * window: a settings change re-attaches, which is what always happened.
63443
+ */
63444
+ settings: AudioAnalysisSettingsSchema
63445
+ });
63446
+ var AudioAttachDeviceResultSchema = object({
63447
+ /** False only when the analyzer is shutting down and refused to attach. */
63448
+ attached: boolean(),
63449
+ /**
63450
+ * True when the attachment replaced a live one for the same device. An
63451
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
63452
+ * double the broker's fanout and neither would know about the other.
63453
+ */
63454
+ replaced: boolean()
63455
+ });
63456
+ var AudioDetachDeviceResultSchema = object({
63457
+ /** False when no attachment existed — detach is idempotent. */
63458
+ detached: boolean() });
63314
63459
  var AudioClassificationResultSchema = object({
63315
63460
  labels: array(AudioClassificationLabelSchema).readonly(),
63316
63461
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -63319,7 +63464,7 @@ var AudioClassificationResultSchema = object({
63319
63464
  method(object({
63320
63465
  chunk: AudioChunkInputSchema,
63321
63466
  settings: AudioAnalysisSettingsSchema
63322
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
63467
+ }), 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() }), {
63323
63468
  kind: "mutation",
63324
63469
  auth: "admin"
63325
63470
  });
@@ -73240,6 +73385,14 @@ var NativeCropResultSchema = object({
73240
73385
  * set `encodeJpeg: true`; `bytes` is then absent.
73241
73386
  */
73242
73387
  jpeg: string().optional(),
73388
+ /**
73389
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
73390
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
73391
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
73392
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
73393
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
73394
+ */
73395
+ jpegBytes: _instanceof(Uint8Array).optional(),
73243
73396
  width: number().int().positive(),
73244
73397
  height: number().int().positive(),
73245
73398
  /**
@@ -73306,7 +73459,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
73306
73459
  })]);
73307
73460
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
73308
73461
  var ParkedTrackFrameSchema = object({
73309
- jpeg: string(),
73462
+ /**
73463
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
73464
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
73465
+ * Exactly one of the two is present.
73466
+ */
73467
+ jpeg: string().optional(),
73468
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
73469
+ jpegBytes: _instanceof(Uint8Array).optional(),
73310
73470
  width: number().int().positive(),
73311
73471
  height: number().int().positive(),
73312
73472
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -73893,6 +74053,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
73893
74053
  bbox: NativeCropBboxSchema,
73894
74054
  maxWidth: number().int().positive().optional(),
73895
74055
  /**
74056
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
74057
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
74058
+ * wire — never assume consent: a pre-D462 caller parses the field as
74059
+ * base64 and bytes would decode to garbage rather than fail.
74060
+ */
74061
+ acceptJpegBytes: boolean().optional(),
74062
+ /**
73896
74063
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
73897
74064
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
73898
74065
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -73960,7 +74127,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
73960
74127
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
73961
74128
  deviceId: number(),
73962
74129
  trackId: string(),
73963
- kind: ParkedFrameKindSchema
74130
+ kind: ParkedFrameKindSchema,
74131
+ /**
74132
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
74133
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
74134
+ * wire — never assume consent: a pre-D462 caller parses the field as
74135
+ * base64 and bytes would decode to garbage rather than fail.
74136
+ */
74137
+ acceptJpegBytes: boolean().optional()
73964
74138
  }), ParkedTrackFrameSchema.nullable()), method(object({
73965
74139
  deviceId: number(),
73966
74140
  trackId: string()
@@ -87768,12 +87942,24 @@ Object.freeze({
87768
87942
  addonId: null,
87769
87943
  access: "create"
87770
87944
  },
87945
+ "audioAnalyzer.attachDevice": {
87946
+ capName: "audio-analyzer",
87947
+ capScope: "system",
87948
+ addonId: null,
87949
+ access: "create"
87950
+ },
87771
87951
  "audioAnalyzer.classify": {
87772
87952
  capName: "audio-analyzer",
87773
87953
  capScope: "system",
87774
87954
  addonId: null,
87775
87955
  access: "view"
87776
87956
  },
87957
+ "audioAnalyzer.detachDevice": {
87958
+ capName: "audio-analyzer",
87959
+ capScope: "system",
87960
+ addonId: null,
87961
+ access: "create"
87962
+ },
87777
87963
  "audioAnalyzer.dispose": {
87778
87964
  capName: "audio-analyzer",
87779
87965
  capScope: "system",
@@ -93617,11 +93803,21 @@ Object.freeze({
93617
93803
  form: "single",
93618
93804
  optional: false
93619
93805
  }],
93806
+ "audioAnalyzer.attachDevice": [{
93807
+ name: "deviceId",
93808
+ form: "single",
93809
+ optional: false
93810
+ }],
93620
93811
  "audioAnalyzer.classify": [{
93621
93812
  name: "deviceId",
93622
93813
  form: "single",
93623
93814
  optional: true
93624
93815
  }],
93816
+ "audioAnalyzer.detachDevice": [{
93817
+ name: "deviceId",
93818
+ form: "single",
93819
+ optional: false
93820
+ }],
93625
93821
  "audioMetrics.getCurrentSnapshot": [{
93626
93822
  name: "deviceId",
93627
93823
  form: "single",
@@ -95473,6 +95669,52 @@ Object.freeze({
95473
95669
  "network-access": "ingress",
95474
95670
  "smtp-provider": "email"
95475
95671
  });
95672
+ var G711_SCALE_CORRECTION_DB = {
95673
+ PCMU: 20 * Math.log10(4),
95674
+ PCMA: 20 * Math.log10(8)
95675
+ };
95676
+ /**
95677
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
95678
+ * same intent on the ITU-T scale (D460).
95679
+ *
95680
+ * ## When this applies, and when it is the wrong thing to reach for
95681
+ *
95682
+ * An absolute-dBFS number in this repo is one of two things, and only one of
95683
+ * them converts:
95684
+ *
95685
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
95686
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
95687
+ * after. The defect was never in the number; it was that 19 of this hub's
95688
+ * 25 cameras did not obey it. Converting such a number takes something
95689
+ * correct and makes it wrong, in order to preserve a bug.
95690
+ * - **A measurement taken through the old decoder** — a value someone read
95691
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
95692
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
95693
+ * louder. That is what this function is for.
95694
+ *
95695
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
95696
+ * and it cannot be answered from the number. It is answered by the comment the
95697
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
95698
+ * mandatory.
95699
+ *
95700
+ * ## Why a function and not a typed-in number
95701
+ *
95702
+ * `-55 + 12.04` written into a source file is, six months later, completely
95703
+ * indistinguishable from a threshold somebody simply preferred. Calling this
95704
+ * keeps the derivation, the law, and the original measurement all visible at
95705
+ * the call site, so a future reader can disagree with the *premise* instead of
95706
+ * having to reverse-engineer the sum.
95707
+ *
95708
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
95709
+ * it is declared. It must never be applied to a live sample or a stored
95710
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
95711
+ * adjusting numbers the decoder already got right is the original defect with
95712
+ * an extra place to argue with (D459).
95713
+ */
95714
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
95715
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
95716
+ }
95717
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
95476
95718
  /** Schema defaults — an untouched sub-field must author exactly these. */
95477
95719
  var NC_AUDIO_DEFAULTS = {
95478
95720
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-dreame",
3
- "version": "0.2.96",
3
+ "version": "0.2.98",
4
4
  "description": "Dreame robot-vacuum / lawn-mower device-provider addon for CamStack — wraps the @apocaliss92/nodedreame Dreamehome cloud client",
5
5
  "keywords": [
6
6
  "camstack",