@camstack/addon-export-alexa 1.2.101 → 1.2.103

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.
@@ -5372,6 +5372,86 @@ var ZodIssueCode = {
5372
5372
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5373
5373
  var ZodFirstPartyTypeKind;
5374
5374
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5375
+ //#endregion
5376
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5377
+ /**
5378
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5379
+ * window to float samples (D455).
5380
+ *
5381
+ * ## Why a format at all
5382
+ *
5383
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5384
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5385
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5386
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5387
+ * the plane carried four times the source. The plane crosses hub-main twice on
5388
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5389
+ *
5390
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5391
+ * them where it needs them. That is the same argument D450 made for the rate,
5392
+ * one step further along the same wire.
5393
+ *
5394
+ * ## Why the expansion lives here
5395
+ *
5396
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5397
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5398
+ * `AudioChunkPlane` expands per subscription) and
5399
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5400
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5401
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5402
+ * into their own dist (`self-contained` externals), so this travels with a
5403
+ * `camstack deploy` and needs no published server.
5404
+ *
5405
+ * A second μ-law table anywhere else is the defect this module exists to
5406
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5407
+ * direction for the WebRTC egress — a different transform, not a copy.)
5408
+ *
5409
+ * ## Absent means f32le
5410
+ *
5411
+ * `format` is optional on the wire and its absence means `f32le` — today's
5412
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5413
+ * has always been served, because the broker only emits a coded window to a
5414
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5415
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5416
+ * deployable one addon at a time across three nodes.
5417
+ */
5418
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5419
+ var AUDIO_CHUNK_FORMATS = [
5420
+ "f32le",
5421
+ "pcmu",
5422
+ "pcma"
5423
+ ];
5424
+ /**
5425
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5426
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5427
+ *
5428
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5429
+ * it buffers the coded bytes and the plane's consumers expand.
5430
+ */
5431
+ function buildUlawTable() {
5432
+ const table = new Float32Array(256);
5433
+ for (let i = 0; i < 256; i++) {
5434
+ const complemented = ~i & 255;
5435
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5436
+ const exponent = complemented >> 4 & 7;
5437
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5438
+ }
5439
+ return table;
5440
+ }
5441
+ /** Build the A-law decode table (ITU-T G.711). */
5442
+ function buildAlawTable() {
5443
+ const table = new Float32Array(256);
5444
+ for (let i = 0; i < 256; i++) {
5445
+ const xored = i ^ 85;
5446
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5447
+ const exponent = xored >> 4 & 7;
5448
+ const mantissa = xored & 15;
5449
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5450
+ }
5451
+ return table;
5452
+ }
5453
+ buildUlawTable();
5454
+ buildAlawTable();
5375
5455
  Object.fromEntries([
5376
5456
  {
5377
5457
  id: "overview",
@@ -6664,11 +6744,20 @@ var SubscribeFramesResultSchema = object({
6664
6744
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6665
6745
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6666
6746
  */
6747
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6667
6748
  var DecodedAudioChunkSchema = object({
6668
6749
  data: _instanceof(Uint8Array),
6669
6750
  sampleRate: number().int().positive(),
6670
6751
  channels: number().int().positive(),
6671
- timestamp: number()
6752
+ timestamp: number(),
6753
+ /**
6754
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6755
+ * byte, for any peer that never heard of this field. A coded window
6756
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6757
+ * subscription that DECLARED it accepts one, so absence can never mean
6758
+ * "coded bytes a consumer will read as floats" (D455).
6759
+ */
6760
+ format: AudioChunkFormatSchema.optional()
6672
6761
  });
6673
6762
  /**
6674
6763
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6680,7 +6769,18 @@ var DecodedAudioChunkSchema = object({
6680
6769
  var SubscribeAudioChunksInputSchema = object({
6681
6770
  brokerId: string(),
6682
6771
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6683
- tag: string().optional()
6772
+ tag: string().optional(),
6773
+ /**
6774
+ * Byte formats this subscriber can READ, best first. The broker serves the
6775
+ * chunk's own format when it is in this list and expands to `f32le`
6776
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6777
+ *
6778
+ * Absent (or without the source format) means `f32le` — the behaviour every
6779
+ * subscriber had before D455, unchanged. This is the negotiation half of
6780
+ * the source-bytes lever: it is what lets the broker and its consumers
6781
+ * deploy one at a time across three nodes.
6782
+ */
6783
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6684
6784
  });
6685
6785
  /** Result of `stream-broker.subscribeAudioChunks`. */
6686
6786
  var SubscribeAudioChunksResultSchema = object({
@@ -10889,6 +10989,51 @@ var AudioAnalysisSettingsSchema = object({
10889
10989
  minConfidence: number().min(0).max(1).default(.3),
10890
10990
  allowedClasses: array(string()).default([])
10891
10991
  });
10992
+ /**
10993
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10994
+ *
10995
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10996
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10997
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10998
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10999
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11000
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11001
+ * way to the one expansion that feeds the model.
11002
+ *
11003
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11004
+ * window, the per-device node assignment, the settings read) and therefore
11005
+ * still owns the attach/detach pair. It no longer owns the bytes.
11006
+ */
11007
+ var AudioAttachDeviceInputSchema = object({
11008
+ deviceId: number(),
11009
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11010
+ brokerId: string(),
11011
+ /**
11012
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11013
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11014
+ * the orchestrator's poller pinned them before the move.
11015
+ */
11016
+ ingestNodeId: string(),
11017
+ /**
11018
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11019
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11020
+ * window: a settings change re-attaches, which is what always happened.
11021
+ */
11022
+ settings: AudioAnalysisSettingsSchema
11023
+ });
11024
+ var AudioAttachDeviceResultSchema = object({
11025
+ /** False only when the analyzer is shutting down and refused to attach. */
11026
+ attached: boolean(),
11027
+ /**
11028
+ * True when the attachment replaced a live one for the same device. An
11029
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11030
+ * double the broker's fanout and neither would know about the other.
11031
+ */
11032
+ replaced: boolean()
11033
+ });
11034
+ var AudioDetachDeviceResultSchema = object({
11035
+ /** False when no attachment existed — detach is idempotent. */
11036
+ detached: boolean() });
10892
11037
  var AudioClassificationResultSchema = object({
10893
11038
  labels: array(AudioClassificationLabelSchema).readonly(),
10894
11039
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10897,7 +11042,7 @@ var AudioClassificationResultSchema = object({
10897
11042
  method(object({
10898
11043
  chunk: AudioChunkInputSchema,
10899
11044
  settings: AudioAnalysisSettingsSchema
10900
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11045
+ }), 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() }), {
10901
11046
  kind: "mutation",
10902
11047
  auth: "admin"
10903
11048
  });
@@ -20496,6 +20641,14 @@ var NativeCropResultSchema = object({
20496
20641
  * set `encodeJpeg: true`; `bytes` is then absent.
20497
20642
  */
20498
20643
  jpeg: string().optional(),
20644
+ /**
20645
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20646
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20647
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20648
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20649
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20650
+ */
20651
+ jpegBytes: _instanceof(Uint8Array).optional(),
20499
20652
  width: number().int().positive(),
20500
20653
  height: number().int().positive(),
20501
20654
  /**
@@ -20562,7 +20715,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20562
20715
  })]);
20563
20716
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20564
20717
  var ParkedTrackFrameSchema = object({
20565
- jpeg: string(),
20718
+ /**
20719
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20720
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20721
+ * Exactly one of the two is present.
20722
+ */
20723
+ jpeg: string().optional(),
20724
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20725
+ jpegBytes: _instanceof(Uint8Array).optional(),
20566
20726
  width: number().int().positive(),
20567
20727
  height: number().int().positive(),
20568
20728
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21149,6 +21309,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21149
21309
  bbox: NativeCropBboxSchema,
21150
21310
  maxWidth: number().int().positive().optional(),
21151
21311
  /**
21312
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21313
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21314
+ * wire — never assume consent: a pre-D462 caller parses the field as
21315
+ * base64 and bytes would decode to garbage rather than fail.
21316
+ */
21317
+ acceptJpegBytes: boolean().optional(),
21318
+ /**
21152
21319
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21153
21320
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21154
21321
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21216,7 +21383,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21216
21383
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21217
21384
  deviceId: number(),
21218
21385
  trackId: string(),
21219
- kind: ParkedFrameKindSchema
21386
+ kind: ParkedFrameKindSchema,
21387
+ /**
21388
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21389
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21390
+ * wire — never assume consent: a pre-D462 caller parses the field as
21391
+ * base64 and bytes would decode to garbage rather than fail.
21392
+ */
21393
+ acceptJpegBytes: boolean().optional()
21220
21394
  }), ParkedTrackFrameSchema.nullable()), method(object({
21221
21395
  deviceId: number(),
21222
21396
  trackId: string()
@@ -30855,12 +31029,24 @@ Object.freeze({
30855
31029
  addonId: null,
30856
31030
  access: "create"
30857
31031
  },
31032
+ "audioAnalyzer.attachDevice": {
31033
+ capName: "audio-analyzer",
31034
+ capScope: "system",
31035
+ addonId: null,
31036
+ access: "create"
31037
+ },
30858
31038
  "audioAnalyzer.classify": {
30859
31039
  capName: "audio-analyzer",
30860
31040
  capScope: "system",
30861
31041
  addonId: null,
30862
31042
  access: "view"
30863
31043
  },
31044
+ "audioAnalyzer.detachDevice": {
31045
+ capName: "audio-analyzer",
31046
+ capScope: "system",
31047
+ addonId: null,
31048
+ access: "create"
31049
+ },
30864
31050
  "audioAnalyzer.dispose": {
30865
31051
  capName: "audio-analyzer",
30866
31052
  capScope: "system",
@@ -36704,11 +36890,21 @@ Object.freeze({
36704
36890
  form: "single",
36705
36891
  optional: false
36706
36892
  }],
36893
+ "audioAnalyzer.attachDevice": [{
36894
+ name: "deviceId",
36895
+ form: "single",
36896
+ optional: false
36897
+ }],
36707
36898
  "audioAnalyzer.classify": [{
36708
36899
  name: "deviceId",
36709
36900
  form: "single",
36710
36901
  optional: true
36711
36902
  }],
36903
+ "audioAnalyzer.detachDevice": [{
36904
+ name: "deviceId",
36905
+ form: "single",
36906
+ optional: false
36907
+ }],
36712
36908
  "audioMetrics.getCurrentSnapshot": [{
36713
36909
  name: "deviceId",
36714
36910
  form: "single",
@@ -38560,6 +38756,52 @@ Object.freeze({
38560
38756
  "network-access": "ingress",
38561
38757
  "smtp-provider": "email"
38562
38758
  });
38759
+ var G711_SCALE_CORRECTION_DB = {
38760
+ PCMU: 20 * Math.log10(4),
38761
+ PCMA: 20 * Math.log10(8)
38762
+ };
38763
+ /**
38764
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
38765
+ * same intent on the ITU-T scale (D460).
38766
+ *
38767
+ * ## When this applies, and when it is the wrong thing to reach for
38768
+ *
38769
+ * An absolute-dBFS number in this repo is one of two things, and only one of
38770
+ * them converts:
38771
+ *
38772
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
38773
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
38774
+ * after. The defect was never in the number; it was that 19 of this hub's
38775
+ * 25 cameras did not obey it. Converting such a number takes something
38776
+ * correct and makes it wrong, in order to preserve a bug.
38777
+ * - **A measurement taken through the old decoder** — a value someone read
38778
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
38779
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
38780
+ * louder. That is what this function is for.
38781
+ *
38782
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
38783
+ * and it cannot be answered from the number. It is answered by the comment the
38784
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
38785
+ * mandatory.
38786
+ *
38787
+ * ## Why a function and not a typed-in number
38788
+ *
38789
+ * `-55 + 12.04` written into a source file is, six months later, completely
38790
+ * indistinguishable from a threshold somebody simply preferred. Calling this
38791
+ * keeps the derivation, the law, and the original measurement all visible at
38792
+ * the call site, so a future reader can disagree with the *premise* instead of
38793
+ * having to reverse-engineer the sum.
38794
+ *
38795
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
38796
+ * it is declared. It must never be applied to a live sample or a stored
38797
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
38798
+ * adjusting numbers the decoder already got right is the original defect with
38799
+ * an extra place to argue with (D459).
38800
+ */
38801
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
38802
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
38803
+ }
38804
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
38563
38805
  /** Schema defaults — an untouched sub-field must author exactly these. */
38564
38806
  var NC_AUDIO_DEFAULTS = {
38565
38807
  hitPercent: 60,
@@ -5345,6 +5345,86 @@ var ZodIssueCode = {
5345
5345
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5346
5346
  var ZodFirstPartyTypeKind;
5347
5347
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5348
+ //#endregion
5349
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5350
+ /**
5351
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5352
+ * window to float samples (D455).
5353
+ *
5354
+ * ## Why a format at all
5355
+ *
5356
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5357
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5358
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5359
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5360
+ * the plane carried four times the source. The plane crosses hub-main twice on
5361
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5362
+ *
5363
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5364
+ * them where it needs them. That is the same argument D450 made for the rate,
5365
+ * one step further along the same wire.
5366
+ *
5367
+ * ## Why the expansion lives here
5368
+ *
5369
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5370
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5371
+ * `AudioChunkPlane` expands per subscription) and
5372
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5373
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5374
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5375
+ * into their own dist (`self-contained` externals), so this travels with a
5376
+ * `camstack deploy` and needs no published server.
5377
+ *
5378
+ * A second μ-law table anywhere else is the defect this module exists to
5379
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5380
+ * direction for the WebRTC egress — a different transform, not a copy.)
5381
+ *
5382
+ * ## Absent means f32le
5383
+ *
5384
+ * `format` is optional on the wire and its absence means `f32le` — today's
5385
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5386
+ * has always been served, because the broker only emits a coded window to a
5387
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5388
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5389
+ * deployable one addon at a time across three nodes.
5390
+ */
5391
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5392
+ var AUDIO_CHUNK_FORMATS = [
5393
+ "f32le",
5394
+ "pcmu",
5395
+ "pcma"
5396
+ ];
5397
+ /**
5398
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5399
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5400
+ *
5401
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5402
+ * it buffers the coded bytes and the plane's consumers expand.
5403
+ */
5404
+ function buildUlawTable() {
5405
+ const table = new Float32Array(256);
5406
+ for (let i = 0; i < 256; i++) {
5407
+ const complemented = ~i & 255;
5408
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5409
+ const exponent = complemented >> 4 & 7;
5410
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5411
+ }
5412
+ return table;
5413
+ }
5414
+ /** Build the A-law decode table (ITU-T G.711). */
5415
+ function buildAlawTable() {
5416
+ const table = new Float32Array(256);
5417
+ for (let i = 0; i < 256; i++) {
5418
+ const xored = i ^ 85;
5419
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5420
+ const exponent = xored >> 4 & 7;
5421
+ const mantissa = xored & 15;
5422
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5423
+ }
5424
+ return table;
5425
+ }
5426
+ buildUlawTable();
5427
+ buildAlawTable();
5348
5428
  Object.fromEntries([
5349
5429
  {
5350
5430
  id: "overview",
@@ -6637,11 +6717,20 @@ var SubscribeFramesResultSchema = object({
6637
6717
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6638
6718
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6639
6719
  */
6720
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6640
6721
  var DecodedAudioChunkSchema = object({
6641
6722
  data: _instanceof(Uint8Array),
6642
6723
  sampleRate: number().int().positive(),
6643
6724
  channels: number().int().positive(),
6644
- timestamp: number()
6725
+ timestamp: number(),
6726
+ /**
6727
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6728
+ * byte, for any peer that never heard of this field. A coded window
6729
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6730
+ * subscription that DECLARED it accepts one, so absence can never mean
6731
+ * "coded bytes a consumer will read as floats" (D455).
6732
+ */
6733
+ format: AudioChunkFormatSchema.optional()
6645
6734
  });
6646
6735
  /**
6647
6736
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6653,7 +6742,18 @@ var DecodedAudioChunkSchema = object({
6653
6742
  var SubscribeAudioChunksInputSchema = object({
6654
6743
  brokerId: string(),
6655
6744
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6656
- tag: string().optional()
6745
+ tag: string().optional(),
6746
+ /**
6747
+ * Byte formats this subscriber can READ, best first. The broker serves the
6748
+ * chunk's own format when it is in this list and expands to `f32le`
6749
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6750
+ *
6751
+ * Absent (or without the source format) means `f32le` — the behaviour every
6752
+ * subscriber had before D455, unchanged. This is the negotiation half of
6753
+ * the source-bytes lever: it is what lets the broker and its consumers
6754
+ * deploy one at a time across three nodes.
6755
+ */
6756
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6657
6757
  });
6658
6758
  /** Result of `stream-broker.subscribeAudioChunks`. */
6659
6759
  var SubscribeAudioChunksResultSchema = object({
@@ -10862,6 +10962,51 @@ var AudioAnalysisSettingsSchema = object({
10862
10962
  minConfidence: number().min(0).max(1).default(.3),
10863
10963
  allowedClasses: array(string()).default([])
10864
10964
  });
10965
+ /**
10966
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10967
+ *
10968
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10969
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10970
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10971
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10972
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10973
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10974
+ * way to the one expansion that feeds the model.
10975
+ *
10976
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10977
+ * window, the per-device node assignment, the settings read) and therefore
10978
+ * still owns the attach/detach pair. It no longer owns the bytes.
10979
+ */
10980
+ var AudioAttachDeviceInputSchema = object({
10981
+ deviceId: number(),
10982
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10983
+ brokerId: string(),
10984
+ /**
10985
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10986
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10987
+ * the orchestrator's poller pinned them before the move.
10988
+ */
10989
+ ingestNodeId: string(),
10990
+ /**
10991
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10992
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10993
+ * window: a settings change re-attaches, which is what always happened.
10994
+ */
10995
+ settings: AudioAnalysisSettingsSchema
10996
+ });
10997
+ var AudioAttachDeviceResultSchema = object({
10998
+ /** False only when the analyzer is shutting down and refused to attach. */
10999
+ attached: boolean(),
11000
+ /**
11001
+ * True when the attachment replaced a live one for the same device. An
11002
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11003
+ * double the broker's fanout and neither would know about the other.
11004
+ */
11005
+ replaced: boolean()
11006
+ });
11007
+ var AudioDetachDeviceResultSchema = object({
11008
+ /** False when no attachment existed — detach is idempotent. */
11009
+ detached: boolean() });
10865
11010
  var AudioClassificationResultSchema = object({
10866
11011
  labels: array(AudioClassificationLabelSchema).readonly(),
10867
11012
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10870,7 +11015,7 @@ var AudioClassificationResultSchema = object({
10870
11015
  method(object({
10871
11016
  chunk: AudioChunkInputSchema,
10872
11017
  settings: AudioAnalysisSettingsSchema
10873
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11018
+ }), 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() }), {
10874
11019
  kind: "mutation",
10875
11020
  auth: "admin"
10876
11021
  });
@@ -20469,6 +20614,14 @@ var NativeCropResultSchema = object({
20469
20614
  * set `encodeJpeg: true`; `bytes` is then absent.
20470
20615
  */
20471
20616
  jpeg: string().optional(),
20617
+ /**
20618
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20619
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20620
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20621
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20622
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20623
+ */
20624
+ jpegBytes: _instanceof(Uint8Array).optional(),
20472
20625
  width: number().int().positive(),
20473
20626
  height: number().int().positive(),
20474
20627
  /**
@@ -20535,7 +20688,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20535
20688
  })]);
20536
20689
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20537
20690
  var ParkedTrackFrameSchema = object({
20538
- jpeg: string(),
20691
+ /**
20692
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20693
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20694
+ * Exactly one of the two is present.
20695
+ */
20696
+ jpeg: string().optional(),
20697
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20698
+ jpegBytes: _instanceof(Uint8Array).optional(),
20539
20699
  width: number().int().positive(),
20540
20700
  height: number().int().positive(),
20541
20701
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21122,6 +21282,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21122
21282
  bbox: NativeCropBboxSchema,
21123
21283
  maxWidth: number().int().positive().optional(),
21124
21284
  /**
21285
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21286
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21287
+ * wire — never assume consent: a pre-D462 caller parses the field as
21288
+ * base64 and bytes would decode to garbage rather than fail.
21289
+ */
21290
+ acceptJpegBytes: boolean().optional(),
21291
+ /**
21125
21292
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21126
21293
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21127
21294
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21189,7 +21356,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21189
21356
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21190
21357
  deviceId: number(),
21191
21358
  trackId: string(),
21192
- kind: ParkedFrameKindSchema
21359
+ kind: ParkedFrameKindSchema,
21360
+ /**
21361
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21362
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21363
+ * wire — never assume consent: a pre-D462 caller parses the field as
21364
+ * base64 and bytes would decode to garbage rather than fail.
21365
+ */
21366
+ acceptJpegBytes: boolean().optional()
21193
21367
  }), ParkedTrackFrameSchema.nullable()), method(object({
21194
21368
  deviceId: number(),
21195
21369
  trackId: string()
@@ -30828,12 +31002,24 @@ Object.freeze({
30828
31002
  addonId: null,
30829
31003
  access: "create"
30830
31004
  },
31005
+ "audioAnalyzer.attachDevice": {
31006
+ capName: "audio-analyzer",
31007
+ capScope: "system",
31008
+ addonId: null,
31009
+ access: "create"
31010
+ },
30831
31011
  "audioAnalyzer.classify": {
30832
31012
  capName: "audio-analyzer",
30833
31013
  capScope: "system",
30834
31014
  addonId: null,
30835
31015
  access: "view"
30836
31016
  },
31017
+ "audioAnalyzer.detachDevice": {
31018
+ capName: "audio-analyzer",
31019
+ capScope: "system",
31020
+ addonId: null,
31021
+ access: "create"
31022
+ },
30837
31023
  "audioAnalyzer.dispose": {
30838
31024
  capName: "audio-analyzer",
30839
31025
  capScope: "system",
@@ -36677,11 +36863,21 @@ Object.freeze({
36677
36863
  form: "single",
36678
36864
  optional: false
36679
36865
  }],
36866
+ "audioAnalyzer.attachDevice": [{
36867
+ name: "deviceId",
36868
+ form: "single",
36869
+ optional: false
36870
+ }],
36680
36871
  "audioAnalyzer.classify": [{
36681
36872
  name: "deviceId",
36682
36873
  form: "single",
36683
36874
  optional: true
36684
36875
  }],
36876
+ "audioAnalyzer.detachDevice": [{
36877
+ name: "deviceId",
36878
+ form: "single",
36879
+ optional: false
36880
+ }],
36685
36881
  "audioMetrics.getCurrentSnapshot": [{
36686
36882
  name: "deviceId",
36687
36883
  form: "single",
@@ -38533,6 +38729,52 @@ Object.freeze({
38533
38729
  "network-access": "ingress",
38534
38730
  "smtp-provider": "email"
38535
38731
  });
38732
+ var G711_SCALE_CORRECTION_DB = {
38733
+ PCMU: 20 * Math.log10(4),
38734
+ PCMA: 20 * Math.log10(8)
38735
+ };
38736
+ /**
38737
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
38738
+ * same intent on the ITU-T scale (D460).
38739
+ *
38740
+ * ## When this applies, and when it is the wrong thing to reach for
38741
+ *
38742
+ * An absolute-dBFS number in this repo is one of two things, and only one of
38743
+ * them converts:
38744
+ *
38745
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
38746
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
38747
+ * after. The defect was never in the number; it was that 19 of this hub's
38748
+ * 25 cameras did not obey it. Converting such a number takes something
38749
+ * correct and makes it wrong, in order to preserve a bug.
38750
+ * - **A measurement taken through the old decoder** — a value someone read
38751
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
38752
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
38753
+ * louder. That is what this function is for.
38754
+ *
38755
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
38756
+ * and it cannot be answered from the number. It is answered by the comment the
38757
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
38758
+ * mandatory.
38759
+ *
38760
+ * ## Why a function and not a typed-in number
38761
+ *
38762
+ * `-55 + 12.04` written into a source file is, six months later, completely
38763
+ * indistinguishable from a threshold somebody simply preferred. Calling this
38764
+ * keeps the derivation, the law, and the original measurement all visible at
38765
+ * the call site, so a future reader can disagree with the *premise* instead of
38766
+ * having to reverse-engineer the sum.
38767
+ *
38768
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
38769
+ * it is declared. It must never be applied to a live sample or a stored
38770
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
38771
+ * adjusting numbers the decoder already got right is the original defect with
38772
+ * an extra place to argue with (D459).
38773
+ */
38774
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
38775
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
38776
+ }
38777
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
38536
38778
  /** Schema defaults — an untouched sub-field must author exactly these. */
38537
38779
  var NC_AUDIO_DEFAULTS = {
38538
38780
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-export-alexa",
3
- "version": "1.2.101",
3
+ "version": "1.2.103",
4
4
  "description": "Alexa Smart Home Skill export — hub-side OAuth provider + directive handler. The companion AWS Lambda forwards Alexa directives to this addon's /addon/export-alexa/directive endpoint.",
5
5
  "keywords": [
6
6
  "camstack",