@camstack/addon-import-alexa 0.2.94 → 0.2.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -5384,6 +5384,86 @@ var ZodIssueCode = {
5384
5384
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5385
5385
  var ZodFirstPartyTypeKind;
5386
5386
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5387
+ //#endregion
5388
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5389
+ /**
5390
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5391
+ * window to float samples (D455).
5392
+ *
5393
+ * ## Why a format at all
5394
+ *
5395
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5396
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5397
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5398
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5399
+ * the plane carried four times the source. The plane crosses hub-main twice on
5400
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5401
+ *
5402
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5403
+ * them where it needs them. That is the same argument D450 made for the rate,
5404
+ * one step further along the same wire.
5405
+ *
5406
+ * ## Why the expansion lives here
5407
+ *
5408
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5409
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5410
+ * `AudioChunkPlane` expands per subscription) and
5411
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5412
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5413
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5414
+ * into their own dist (`self-contained` externals), so this travels with a
5415
+ * `camstack deploy` and needs no published server.
5416
+ *
5417
+ * A second μ-law table anywhere else is the defect this module exists to
5418
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5419
+ * direction for the WebRTC egress — a different transform, not a copy.)
5420
+ *
5421
+ * ## Absent means f32le
5422
+ *
5423
+ * `format` is optional on the wire and its absence means `f32le` — today's
5424
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5425
+ * has always been served, because the broker only emits a coded window to a
5426
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5427
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5428
+ * deployable one addon at a time across three nodes.
5429
+ */
5430
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5431
+ var AUDIO_CHUNK_FORMATS = [
5432
+ "f32le",
5433
+ "pcmu",
5434
+ "pcma"
5435
+ ];
5436
+ /**
5437
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5438
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5439
+ *
5440
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5441
+ * it buffers the coded bytes and the plane's consumers expand.
5442
+ */
5443
+ function buildUlawTable() {
5444
+ const table = new Float32Array(256);
5445
+ for (let i = 0; i < 256; i++) {
5446
+ const complemented = ~i & 255;
5447
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5448
+ const exponent = complemented >> 4 & 7;
5449
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5450
+ }
5451
+ return table;
5452
+ }
5453
+ /** Build the A-law decode table (ITU-T G.711). */
5454
+ function buildAlawTable() {
5455
+ const table = new Float32Array(256);
5456
+ for (let i = 0; i < 256; i++) {
5457
+ const xored = i ^ 85;
5458
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5459
+ const exponent = xored >> 4 & 7;
5460
+ const mantissa = xored & 15;
5461
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5462
+ }
5463
+ return table;
5464
+ }
5465
+ buildUlawTable();
5466
+ buildAlawTable();
5387
5467
  Object.fromEntries([
5388
5468
  {
5389
5469
  id: "overview",
@@ -6676,11 +6756,20 @@ var SubscribeFramesResultSchema = object({
6676
6756
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6677
6757
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6678
6758
  */
6759
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6679
6760
  var DecodedAudioChunkSchema = object({
6680
6761
  data: _instanceof(Uint8Array),
6681
6762
  sampleRate: number().int().positive(),
6682
6763
  channels: number().int().positive(),
6683
- timestamp: number()
6764
+ timestamp: number(),
6765
+ /**
6766
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6767
+ * byte, for any peer that never heard of this field. A coded window
6768
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6769
+ * subscription that DECLARED it accepts one, so absence can never mean
6770
+ * "coded bytes a consumer will read as floats" (D455).
6771
+ */
6772
+ format: AudioChunkFormatSchema.optional()
6684
6773
  });
6685
6774
  /**
6686
6775
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6692,7 +6781,18 @@ var DecodedAudioChunkSchema = object({
6692
6781
  var SubscribeAudioChunksInputSchema = object({
6693
6782
  brokerId: string(),
6694
6783
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6695
- tag: string().optional()
6784
+ tag: string().optional(),
6785
+ /**
6786
+ * Byte formats this subscriber can READ, best first. The broker serves the
6787
+ * chunk's own format when it is in this list and expands to `f32le`
6788
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6789
+ *
6790
+ * Absent (or without the source format) means `f32le` — the behaviour every
6791
+ * subscriber had before D455, unchanged. This is the negotiation half of
6792
+ * the source-bytes lever: it is what lets the broker and its consumers
6793
+ * deploy one at a time across three nodes.
6794
+ */
6795
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6696
6796
  });
6697
6797
  /** Result of `stream-broker.subscribeAudioChunks`. */
6698
6798
  var SubscribeAudioChunksResultSchema = object({
@@ -10818,6 +10918,51 @@ var AudioAnalysisSettingsSchema = object({
10818
10918
  minConfidence: number().min(0).max(1).default(.3),
10819
10919
  allowedClasses: array(string()).default([])
10820
10920
  });
10921
+ /**
10922
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10923
+ *
10924
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10925
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10926
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10927
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10928
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10929
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10930
+ * way to the one expansion that feeds the model.
10931
+ *
10932
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10933
+ * window, the per-device node assignment, the settings read) and therefore
10934
+ * still owns the attach/detach pair. It no longer owns the bytes.
10935
+ */
10936
+ var AudioAttachDeviceInputSchema = object({
10937
+ deviceId: number(),
10938
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10939
+ brokerId: string(),
10940
+ /**
10941
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10942
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10943
+ * the orchestrator's poller pinned them before the move.
10944
+ */
10945
+ ingestNodeId: string(),
10946
+ /**
10947
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10948
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10949
+ * window: a settings change re-attaches, which is what always happened.
10950
+ */
10951
+ settings: AudioAnalysisSettingsSchema
10952
+ });
10953
+ var AudioAttachDeviceResultSchema = object({
10954
+ /** False only when the analyzer is shutting down and refused to attach. */
10955
+ attached: boolean(),
10956
+ /**
10957
+ * True when the attachment replaced a live one for the same device. An
10958
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10959
+ * double the broker's fanout and neither would know about the other.
10960
+ */
10961
+ replaced: boolean()
10962
+ });
10963
+ var AudioDetachDeviceResultSchema = object({
10964
+ /** False when no attachment existed — detach is idempotent. */
10965
+ detached: boolean() });
10821
10966
  var AudioClassificationResultSchema = object({
10822
10967
  labels: array(AudioClassificationLabelSchema).readonly(),
10823
10968
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10826,7 +10971,7 @@ var AudioClassificationResultSchema = object({
10826
10971
  method(object({
10827
10972
  chunk: AudioChunkInputSchema,
10828
10973
  settings: AudioAnalysisSettingsSchema
10829
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10974
+ }), 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() }), {
10830
10975
  kind: "mutation",
10831
10976
  auth: "admin"
10832
10977
  });
@@ -20796,6 +20941,14 @@ var NativeCropResultSchema = object({
20796
20941
  * set `encodeJpeg: true`; `bytes` is then absent.
20797
20942
  */
20798
20943
  jpeg: string().optional(),
20944
+ /**
20945
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20946
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20947
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20948
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20949
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20950
+ */
20951
+ jpegBytes: _instanceof(Uint8Array).optional(),
20799
20952
  width: number().int().positive(),
20800
20953
  height: number().int().positive(),
20801
20954
  /**
@@ -20862,7 +21015,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20862
21015
  })]);
20863
21016
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20864
21017
  var ParkedTrackFrameSchema = object({
20865
- jpeg: string(),
21018
+ /**
21019
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21020
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21021
+ * Exactly one of the two is present.
21022
+ */
21023
+ jpeg: string().optional(),
21024
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21025
+ jpegBytes: _instanceof(Uint8Array).optional(),
20866
21026
  width: number().int().positive(),
20867
21027
  height: number().int().positive(),
20868
21028
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21449,6 +21609,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21449
21609
  bbox: NativeCropBboxSchema,
21450
21610
  maxWidth: number().int().positive().optional(),
21451
21611
  /**
21612
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21613
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21614
+ * wire — never assume consent: a pre-D462 caller parses the field as
21615
+ * base64 and bytes would decode to garbage rather than fail.
21616
+ */
21617
+ acceptJpegBytes: boolean().optional(),
21618
+ /**
21452
21619
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21453
21620
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21454
21621
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21516,7 +21683,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21516
21683
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21517
21684
  deviceId: number(),
21518
21685
  trackId: string(),
21519
- kind: ParkedFrameKindSchema
21686
+ kind: ParkedFrameKindSchema,
21687
+ /**
21688
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21689
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21690
+ * wire — never assume consent: a pre-D462 caller parses the field as
21691
+ * base64 and bytes would decode to garbage rather than fail.
21692
+ */
21693
+ acceptJpegBytes: boolean().optional()
21520
21694
  }), ParkedTrackFrameSchema.nullable()), method(object({
21521
21695
  deviceId: number(),
21522
21696
  trackId: string()
@@ -35168,12 +35342,24 @@ Object.freeze({
35168
35342
  addonId: null,
35169
35343
  access: "create"
35170
35344
  },
35345
+ "audioAnalyzer.attachDevice": {
35346
+ capName: "audio-analyzer",
35347
+ capScope: "system",
35348
+ addonId: null,
35349
+ access: "create"
35350
+ },
35171
35351
  "audioAnalyzer.classify": {
35172
35352
  capName: "audio-analyzer",
35173
35353
  capScope: "system",
35174
35354
  addonId: null,
35175
35355
  access: "view"
35176
35356
  },
35357
+ "audioAnalyzer.detachDevice": {
35358
+ capName: "audio-analyzer",
35359
+ capScope: "system",
35360
+ addonId: null,
35361
+ access: "create"
35362
+ },
35177
35363
  "audioAnalyzer.dispose": {
35178
35364
  capName: "audio-analyzer",
35179
35365
  capScope: "system",
@@ -41017,11 +41203,21 @@ Object.freeze({
41017
41203
  form: "single",
41018
41204
  optional: false
41019
41205
  }],
41206
+ "audioAnalyzer.attachDevice": [{
41207
+ name: "deviceId",
41208
+ form: "single",
41209
+ optional: false
41210
+ }],
41020
41211
  "audioAnalyzer.classify": [{
41021
41212
  name: "deviceId",
41022
41213
  form: "single",
41023
41214
  optional: true
41024
41215
  }],
41216
+ "audioAnalyzer.detachDevice": [{
41217
+ name: "deviceId",
41218
+ form: "single",
41219
+ optional: false
41220
+ }],
41025
41221
  "audioMetrics.getCurrentSnapshot": [{
41026
41222
  name: "deviceId",
41027
41223
  form: "single",
@@ -42873,6 +43069,52 @@ Object.freeze({
42873
43069
  "network-access": "ingress",
42874
43070
  "smtp-provider": "email"
42875
43071
  });
43072
+ var G711_SCALE_CORRECTION_DB = {
43073
+ PCMU: 20 * Math.log10(4),
43074
+ PCMA: 20 * Math.log10(8)
43075
+ };
43076
+ /**
43077
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43078
+ * same intent on the ITU-T scale (D460).
43079
+ *
43080
+ * ## When this applies, and when it is the wrong thing to reach for
43081
+ *
43082
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43083
+ * them converts:
43084
+ *
43085
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43086
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43087
+ * after. The defect was never in the number; it was that 19 of this hub's
43088
+ * 25 cameras did not obey it. Converting such a number takes something
43089
+ * correct and makes it wrong, in order to preserve a bug.
43090
+ * - **A measurement taken through the old decoder** — a value someone read
43091
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43092
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43093
+ * louder. That is what this function is for.
43094
+ *
43095
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43096
+ * and it cannot be answered from the number. It is answered by the comment the
43097
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43098
+ * mandatory.
43099
+ *
43100
+ * ## Why a function and not a typed-in number
43101
+ *
43102
+ * `-55 + 12.04` written into a source file is, six months later, completely
43103
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43104
+ * keeps the derivation, the law, and the original measurement all visible at
43105
+ * the call site, so a future reader can disagree with the *premise* instead of
43106
+ * having to reverse-engineer the sum.
43107
+ *
43108
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43109
+ * it is declared. It must never be applied to a live sample or a stored
43110
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43111
+ * adjusting numbers the decoder already got right is the original defect with
43112
+ * an extra place to argue with (D459).
43113
+ */
43114
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43115
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43116
+ }
43117
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42876
43118
  /** Schema defaults — an untouched sub-field must author exactly these. */
42877
43119
  var NC_AUDIO_DEFAULTS = {
42878
43120
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5384,6 +5384,86 @@ var ZodIssueCode = {
5384
5384
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5385
5385
  var ZodFirstPartyTypeKind;
5386
5386
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5387
+ //#endregion
5388
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5389
+ /**
5390
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5391
+ * window to float samples (D455).
5392
+ *
5393
+ * ## Why a format at all
5394
+ *
5395
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5396
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5397
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5398
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5399
+ * the plane carried four times the source. The plane crosses hub-main twice on
5400
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5401
+ *
5402
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5403
+ * them where it needs them. That is the same argument D450 made for the rate,
5404
+ * one step further along the same wire.
5405
+ *
5406
+ * ## Why the expansion lives here
5407
+ *
5408
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5409
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5410
+ * `AudioChunkPlane` expands per subscription) and
5411
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5412
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5413
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5414
+ * into their own dist (`self-contained` externals), so this travels with a
5415
+ * `camstack deploy` and needs no published server.
5416
+ *
5417
+ * A second μ-law table anywhere else is the defect this module exists to
5418
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5419
+ * direction for the WebRTC egress — a different transform, not a copy.)
5420
+ *
5421
+ * ## Absent means f32le
5422
+ *
5423
+ * `format` is optional on the wire and its absence means `f32le` — today's
5424
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5425
+ * has always been served, because the broker only emits a coded window to a
5426
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5427
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5428
+ * deployable one addon at a time across three nodes.
5429
+ */
5430
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5431
+ var AUDIO_CHUNK_FORMATS = [
5432
+ "f32le",
5433
+ "pcmu",
5434
+ "pcma"
5435
+ ];
5436
+ /**
5437
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5438
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5439
+ *
5440
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5441
+ * it buffers the coded bytes and the plane's consumers expand.
5442
+ */
5443
+ function buildUlawTable() {
5444
+ const table = new Float32Array(256);
5445
+ for (let i = 0; i < 256; i++) {
5446
+ const complemented = ~i & 255;
5447
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5448
+ const exponent = complemented >> 4 & 7;
5449
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5450
+ }
5451
+ return table;
5452
+ }
5453
+ /** Build the A-law decode table (ITU-T G.711). */
5454
+ function buildAlawTable() {
5455
+ const table = new Float32Array(256);
5456
+ for (let i = 0; i < 256; i++) {
5457
+ const xored = i ^ 85;
5458
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5459
+ const exponent = xored >> 4 & 7;
5460
+ const mantissa = xored & 15;
5461
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5462
+ }
5463
+ return table;
5464
+ }
5465
+ buildUlawTable();
5466
+ buildAlawTable();
5387
5467
  Object.fromEntries([
5388
5468
  {
5389
5469
  id: "overview",
@@ -6676,11 +6756,20 @@ var SubscribeFramesResultSchema = object({
6676
6756
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6677
6757
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6678
6758
  */
6759
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6679
6760
  var DecodedAudioChunkSchema = object({
6680
6761
  data: _instanceof(Uint8Array),
6681
6762
  sampleRate: number().int().positive(),
6682
6763
  channels: number().int().positive(),
6683
- timestamp: number()
6764
+ timestamp: number(),
6765
+ /**
6766
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6767
+ * byte, for any peer that never heard of this field. A coded window
6768
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6769
+ * subscription that DECLARED it accepts one, so absence can never mean
6770
+ * "coded bytes a consumer will read as floats" (D455).
6771
+ */
6772
+ format: AudioChunkFormatSchema.optional()
6684
6773
  });
6685
6774
  /**
6686
6775
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6692,7 +6781,18 @@ var DecodedAudioChunkSchema = object({
6692
6781
  var SubscribeAudioChunksInputSchema = object({
6693
6782
  brokerId: string(),
6694
6783
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6695
- tag: string().optional()
6784
+ tag: string().optional(),
6785
+ /**
6786
+ * Byte formats this subscriber can READ, best first. The broker serves the
6787
+ * chunk's own format when it is in this list and expands to `f32le`
6788
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6789
+ *
6790
+ * Absent (or without the source format) means `f32le` — the behaviour every
6791
+ * subscriber had before D455, unchanged. This is the negotiation half of
6792
+ * the source-bytes lever: it is what lets the broker and its consumers
6793
+ * deploy one at a time across three nodes.
6794
+ */
6795
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6696
6796
  });
6697
6797
  /** Result of `stream-broker.subscribeAudioChunks`. */
6698
6798
  var SubscribeAudioChunksResultSchema = object({
@@ -10818,6 +10918,51 @@ var AudioAnalysisSettingsSchema = object({
10818
10918
  minConfidence: number().min(0).max(1).default(.3),
10819
10919
  allowedClasses: array(string()).default([])
10820
10920
  });
10921
+ /**
10922
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10923
+ *
10924
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10925
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10926
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10927
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10928
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10929
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10930
+ * way to the one expansion that feeds the model.
10931
+ *
10932
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10933
+ * window, the per-device node assignment, the settings read) and therefore
10934
+ * still owns the attach/detach pair. It no longer owns the bytes.
10935
+ */
10936
+ var AudioAttachDeviceInputSchema = object({
10937
+ deviceId: number(),
10938
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10939
+ brokerId: string(),
10940
+ /**
10941
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10942
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10943
+ * the orchestrator's poller pinned them before the move.
10944
+ */
10945
+ ingestNodeId: string(),
10946
+ /**
10947
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10948
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10949
+ * window: a settings change re-attaches, which is what always happened.
10950
+ */
10951
+ settings: AudioAnalysisSettingsSchema
10952
+ });
10953
+ var AudioAttachDeviceResultSchema = object({
10954
+ /** False only when the analyzer is shutting down and refused to attach. */
10955
+ attached: boolean(),
10956
+ /**
10957
+ * True when the attachment replaced a live one for the same device. An
10958
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10959
+ * double the broker's fanout and neither would know about the other.
10960
+ */
10961
+ replaced: boolean()
10962
+ });
10963
+ var AudioDetachDeviceResultSchema = object({
10964
+ /** False when no attachment existed — detach is idempotent. */
10965
+ detached: boolean() });
10821
10966
  var AudioClassificationResultSchema = object({
10822
10967
  labels: array(AudioClassificationLabelSchema).readonly(),
10823
10968
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10826,7 +10971,7 @@ var AudioClassificationResultSchema = object({
10826
10971
  method(object({
10827
10972
  chunk: AudioChunkInputSchema,
10828
10973
  settings: AudioAnalysisSettingsSchema
10829
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10974
+ }), 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() }), {
10830
10975
  kind: "mutation",
10831
10976
  auth: "admin"
10832
10977
  });
@@ -20796,6 +20941,14 @@ var NativeCropResultSchema = object({
20796
20941
  * set `encodeJpeg: true`; `bytes` is then absent.
20797
20942
  */
20798
20943
  jpeg: string().optional(),
20944
+ /**
20945
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20946
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20947
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20948
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20949
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20950
+ */
20951
+ jpegBytes: _instanceof(Uint8Array).optional(),
20799
20952
  width: number().int().positive(),
20800
20953
  height: number().int().positive(),
20801
20954
  /**
@@ -20862,7 +21015,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20862
21015
  })]);
20863
21016
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20864
21017
  var ParkedTrackFrameSchema = object({
20865
- jpeg: string(),
21018
+ /**
21019
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21020
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21021
+ * Exactly one of the two is present.
21022
+ */
21023
+ jpeg: string().optional(),
21024
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21025
+ jpegBytes: _instanceof(Uint8Array).optional(),
20866
21026
  width: number().int().positive(),
20867
21027
  height: number().int().positive(),
20868
21028
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21449,6 +21609,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21449
21609
  bbox: NativeCropBboxSchema,
21450
21610
  maxWidth: number().int().positive().optional(),
21451
21611
  /**
21612
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21613
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21614
+ * wire — never assume consent: a pre-D462 caller parses the field as
21615
+ * base64 and bytes would decode to garbage rather than fail.
21616
+ */
21617
+ acceptJpegBytes: boolean().optional(),
21618
+ /**
21452
21619
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21453
21620
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21454
21621
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21516,7 +21683,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21516
21683
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21517
21684
  deviceId: number(),
21518
21685
  trackId: string(),
21519
- kind: ParkedFrameKindSchema
21686
+ kind: ParkedFrameKindSchema,
21687
+ /**
21688
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21689
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21690
+ * wire — never assume consent: a pre-D462 caller parses the field as
21691
+ * base64 and bytes would decode to garbage rather than fail.
21692
+ */
21693
+ acceptJpegBytes: boolean().optional()
21520
21694
  }), ParkedTrackFrameSchema.nullable()), method(object({
21521
21695
  deviceId: number(),
21522
21696
  trackId: string()
@@ -35168,12 +35342,24 @@ Object.freeze({
35168
35342
  addonId: null,
35169
35343
  access: "create"
35170
35344
  },
35345
+ "audioAnalyzer.attachDevice": {
35346
+ capName: "audio-analyzer",
35347
+ capScope: "system",
35348
+ addonId: null,
35349
+ access: "create"
35350
+ },
35171
35351
  "audioAnalyzer.classify": {
35172
35352
  capName: "audio-analyzer",
35173
35353
  capScope: "system",
35174
35354
  addonId: null,
35175
35355
  access: "view"
35176
35356
  },
35357
+ "audioAnalyzer.detachDevice": {
35358
+ capName: "audio-analyzer",
35359
+ capScope: "system",
35360
+ addonId: null,
35361
+ access: "create"
35362
+ },
35177
35363
  "audioAnalyzer.dispose": {
35178
35364
  capName: "audio-analyzer",
35179
35365
  capScope: "system",
@@ -41017,11 +41203,21 @@ Object.freeze({
41017
41203
  form: "single",
41018
41204
  optional: false
41019
41205
  }],
41206
+ "audioAnalyzer.attachDevice": [{
41207
+ name: "deviceId",
41208
+ form: "single",
41209
+ optional: false
41210
+ }],
41020
41211
  "audioAnalyzer.classify": [{
41021
41212
  name: "deviceId",
41022
41213
  form: "single",
41023
41214
  optional: true
41024
41215
  }],
41216
+ "audioAnalyzer.detachDevice": [{
41217
+ name: "deviceId",
41218
+ form: "single",
41219
+ optional: false
41220
+ }],
41025
41221
  "audioMetrics.getCurrentSnapshot": [{
41026
41222
  name: "deviceId",
41027
41223
  form: "single",
@@ -42873,6 +43069,52 @@ Object.freeze({
42873
43069
  "network-access": "ingress",
42874
43070
  "smtp-provider": "email"
42875
43071
  });
43072
+ var G711_SCALE_CORRECTION_DB = {
43073
+ PCMU: 20 * Math.log10(4),
43074
+ PCMA: 20 * Math.log10(8)
43075
+ };
43076
+ /**
43077
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43078
+ * same intent on the ITU-T scale (D460).
43079
+ *
43080
+ * ## When this applies, and when it is the wrong thing to reach for
43081
+ *
43082
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43083
+ * them converts:
43084
+ *
43085
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43086
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43087
+ * after. The defect was never in the number; it was that 19 of this hub's
43088
+ * 25 cameras did not obey it. Converting such a number takes something
43089
+ * correct and makes it wrong, in order to preserve a bug.
43090
+ * - **A measurement taken through the old decoder** — a value someone read
43091
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43092
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43093
+ * louder. That is what this function is for.
43094
+ *
43095
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43096
+ * and it cannot be answered from the number. It is answered by the comment the
43097
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43098
+ * mandatory.
43099
+ *
43100
+ * ## Why a function and not a typed-in number
43101
+ *
43102
+ * `-55 + 12.04` written into a source file is, six months later, completely
43103
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43104
+ * keeps the derivation, the law, and the original measurement all visible at
43105
+ * the call site, so a future reader can disagree with the *premise* instead of
43106
+ * having to reverse-engineer the sum.
43107
+ *
43108
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43109
+ * it is declared. It must never be applied to a live sample or a stored
43110
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43111
+ * adjusting numbers the decoder already got right is the original defect with
43112
+ * an extra place to argue with (D459).
43113
+ */
43114
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43115
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43116
+ }
43117
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42876
43118
  /** Schema defaults — an untouched sub-field must author exactly these. */
42877
43119
  var NC_AUDIO_DEFAULTS = {
42878
43120
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-import-alexa",
3
- "version": "0.2.94",
3
+ "version": "0.2.96",
4
4
  "description": "Alexa device-import provider for CamStack — imports the smart-home devices in a user's Alexa account via the unofficial alexa-remote2 cookie/token client (the inverse of the Alexa exporter)",
5
5
  "keywords": [
6
6
  "camstack",