@camstack/addon-export-hap 1.2.106 → 1.2.108

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.
@@ -5430,6 +5430,86 @@ var ZodIssueCode = {
5430
5430
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5431
5431
  var ZodFirstPartyTypeKind;
5432
5432
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5433
+ //#endregion
5434
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5435
+ /**
5436
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5437
+ * window to float samples (D455).
5438
+ *
5439
+ * ## Why a format at all
5440
+ *
5441
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5442
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5443
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5444
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5445
+ * the plane carried four times the source. The plane crosses hub-main twice on
5446
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5447
+ *
5448
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5449
+ * them where it needs them. That is the same argument D450 made for the rate,
5450
+ * one step further along the same wire.
5451
+ *
5452
+ * ## Why the expansion lives here
5453
+ *
5454
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5455
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5456
+ * `AudioChunkPlane` expands per subscription) and
5457
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5458
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5459
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5460
+ * into their own dist (`self-contained` externals), so this travels with a
5461
+ * `camstack deploy` and needs no published server.
5462
+ *
5463
+ * A second μ-law table anywhere else is the defect this module exists to
5464
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5465
+ * direction for the WebRTC egress — a different transform, not a copy.)
5466
+ *
5467
+ * ## Absent means f32le
5468
+ *
5469
+ * `format` is optional on the wire and its absence means `f32le` — today's
5470
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5471
+ * has always been served, because the broker only emits a coded window to a
5472
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5473
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5474
+ * deployable one addon at a time across three nodes.
5475
+ */
5476
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5477
+ var AUDIO_CHUNK_FORMATS = [
5478
+ "f32le",
5479
+ "pcmu",
5480
+ "pcma"
5481
+ ];
5482
+ /**
5483
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5484
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5485
+ *
5486
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5487
+ * it buffers the coded bytes and the plane's consumers expand.
5488
+ */
5489
+ function buildUlawTable() {
5490
+ const table = new Float32Array(256);
5491
+ for (let i = 0; i < 256; i++) {
5492
+ const complemented = ~i & 255;
5493
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5494
+ const exponent = complemented >> 4 & 7;
5495
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5496
+ }
5497
+ return table;
5498
+ }
5499
+ /** Build the A-law decode table (ITU-T G.711). */
5500
+ function buildAlawTable() {
5501
+ const table = new Float32Array(256);
5502
+ for (let i = 0; i < 256; i++) {
5503
+ const xored = i ^ 85;
5504
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5505
+ const exponent = xored >> 4 & 7;
5506
+ const mantissa = xored & 15;
5507
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5508
+ }
5509
+ return table;
5510
+ }
5511
+ buildUlawTable();
5512
+ buildAlawTable();
5433
5513
  Object.fromEntries([
5434
5514
  {
5435
5515
  id: "overview",
@@ -6722,11 +6802,20 @@ var SubscribeFramesResultSchema = object({
6722
6802
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6723
6803
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6724
6804
  */
6805
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6725
6806
  var DecodedAudioChunkSchema = object({
6726
6807
  data: _instanceof(Uint8Array),
6727
6808
  sampleRate: number().int().positive(),
6728
6809
  channels: number().int().positive(),
6729
- timestamp: number()
6810
+ timestamp: number(),
6811
+ /**
6812
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6813
+ * byte, for any peer that never heard of this field. A coded window
6814
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6815
+ * subscription that DECLARED it accepts one, so absence can never mean
6816
+ * "coded bytes a consumer will read as floats" (D455).
6817
+ */
6818
+ format: AudioChunkFormatSchema.optional()
6730
6819
  });
6731
6820
  /**
6732
6821
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6738,7 +6827,18 @@ var DecodedAudioChunkSchema = object({
6738
6827
  var SubscribeAudioChunksInputSchema = object({
6739
6828
  brokerId: string(),
6740
6829
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6741
- tag: string().optional()
6830
+ tag: string().optional(),
6831
+ /**
6832
+ * Byte formats this subscriber can READ, best first. The broker serves the
6833
+ * chunk's own format when it is in this list and expands to `f32le`
6834
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6835
+ *
6836
+ * Absent (or without the source format) means `f32le` — the behaviour every
6837
+ * subscriber had before D455, unchanged. This is the negotiation half of
6838
+ * the source-bytes lever: it is what lets the broker and its consumers
6839
+ * deploy one at a time across three nodes.
6840
+ */
6841
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6742
6842
  });
6743
6843
  /** Result of `stream-broker.subscribeAudioChunks`. */
6744
6844
  var SubscribeAudioChunksResultSchema = object({
@@ -11361,6 +11461,51 @@ var AudioAnalysisSettingsSchema = object({
11361
11461
  minConfidence: number().min(0).max(1).default(.3),
11362
11462
  allowedClasses: array(string()).default([])
11363
11463
  });
11464
+ /**
11465
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11466
+ *
11467
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11468
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11469
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11470
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11471
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11472
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11473
+ * way to the one expansion that feeds the model.
11474
+ *
11475
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11476
+ * window, the per-device node assignment, the settings read) and therefore
11477
+ * still owns the attach/detach pair. It no longer owns the bytes.
11478
+ */
11479
+ var AudioAttachDeviceInputSchema = object({
11480
+ deviceId: number(),
11481
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11482
+ brokerId: string(),
11483
+ /**
11484
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11485
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11486
+ * the orchestrator's poller pinned them before the move.
11487
+ */
11488
+ ingestNodeId: string(),
11489
+ /**
11490
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11491
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11492
+ * window: a settings change re-attaches, which is what always happened.
11493
+ */
11494
+ settings: AudioAnalysisSettingsSchema
11495
+ });
11496
+ var AudioAttachDeviceResultSchema = object({
11497
+ /** False only when the analyzer is shutting down and refused to attach. */
11498
+ attached: boolean(),
11499
+ /**
11500
+ * True when the attachment replaced a live one for the same device. An
11501
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11502
+ * double the broker's fanout and neither would know about the other.
11503
+ */
11504
+ replaced: boolean()
11505
+ });
11506
+ var AudioDetachDeviceResultSchema = object({
11507
+ /** False when no attachment existed — detach is idempotent. */
11508
+ detached: boolean() });
11364
11509
  var AudioClassificationResultSchema = object({
11365
11510
  labels: array(AudioClassificationLabelSchema).readonly(),
11366
11511
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11369,7 +11514,7 @@ var AudioClassificationResultSchema = object({
11369
11514
  method(object({
11370
11515
  chunk: AudioChunkInputSchema,
11371
11516
  settings: AudioAnalysisSettingsSchema
11372
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11517
+ }), 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() }), {
11373
11518
  kind: "mutation",
11374
11519
  auth: "admin"
11375
11520
  });
@@ -20986,6 +21131,14 @@ var NativeCropResultSchema = object({
20986
21131
  * set `encodeJpeg: true`; `bytes` is then absent.
20987
21132
  */
20988
21133
  jpeg: string().optional(),
21134
+ /**
21135
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21136
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21137
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21138
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21139
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21140
+ */
21141
+ jpegBytes: _instanceof(Uint8Array).optional(),
20989
21142
  width: number().int().positive(),
20990
21143
  height: number().int().positive(),
20991
21144
  /**
@@ -21052,7 +21205,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21052
21205
  })]);
21053
21206
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21054
21207
  var ParkedTrackFrameSchema = object({
21055
- jpeg: string(),
21208
+ /**
21209
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21210
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21211
+ * Exactly one of the two is present.
21212
+ */
21213
+ jpeg: string().optional(),
21214
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21215
+ jpegBytes: _instanceof(Uint8Array).optional(),
21056
21216
  width: number().int().positive(),
21057
21217
  height: number().int().positive(),
21058
21218
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21639,6 +21799,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21639
21799
  bbox: NativeCropBboxSchema,
21640
21800
  maxWidth: number().int().positive().optional(),
21641
21801
  /**
21802
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21803
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21804
+ * wire — never assume consent: a pre-D462 caller parses the field as
21805
+ * base64 and bytes would decode to garbage rather than fail.
21806
+ */
21807
+ acceptJpegBytes: boolean().optional(),
21808
+ /**
21642
21809
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21643
21810
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21644
21811
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21706,7 +21873,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21706
21873
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21707
21874
  deviceId: number(),
21708
21875
  trackId: string(),
21709
- kind: ParkedFrameKindSchema
21876
+ kind: ParkedFrameKindSchema,
21877
+ /**
21878
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21879
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21880
+ * wire — never assume consent: a pre-D462 caller parses the field as
21881
+ * base64 and bytes would decode to garbage rather than fail.
21882
+ */
21883
+ acceptJpegBytes: boolean().optional()
21710
21884
  }), ParkedTrackFrameSchema.nullable()), method(object({
21711
21885
  deviceId: number(),
21712
21886
  trackId: string()
@@ -31418,12 +31592,24 @@ Object.freeze({
31418
31592
  addonId: null,
31419
31593
  access: "create"
31420
31594
  },
31595
+ "audioAnalyzer.attachDevice": {
31596
+ capName: "audio-analyzer",
31597
+ capScope: "system",
31598
+ addonId: null,
31599
+ access: "create"
31600
+ },
31421
31601
  "audioAnalyzer.classify": {
31422
31602
  capName: "audio-analyzer",
31423
31603
  capScope: "system",
31424
31604
  addonId: null,
31425
31605
  access: "view"
31426
31606
  },
31607
+ "audioAnalyzer.detachDevice": {
31608
+ capName: "audio-analyzer",
31609
+ capScope: "system",
31610
+ addonId: null,
31611
+ access: "create"
31612
+ },
31427
31613
  "audioAnalyzer.dispose": {
31428
31614
  capName: "audio-analyzer",
31429
31615
  capScope: "system",
@@ -37267,11 +37453,21 @@ Object.freeze({
37267
37453
  form: "single",
37268
37454
  optional: false
37269
37455
  }],
37456
+ "audioAnalyzer.attachDevice": [{
37457
+ name: "deviceId",
37458
+ form: "single",
37459
+ optional: false
37460
+ }],
37270
37461
  "audioAnalyzer.classify": [{
37271
37462
  name: "deviceId",
37272
37463
  form: "single",
37273
37464
  optional: true
37274
37465
  }],
37466
+ "audioAnalyzer.detachDevice": [{
37467
+ name: "deviceId",
37468
+ form: "single",
37469
+ optional: false
37470
+ }],
37275
37471
  "audioMetrics.getCurrentSnapshot": [{
37276
37472
  name: "deviceId",
37277
37473
  form: "single",
@@ -39123,6 +39319,52 @@ Object.freeze({
39123
39319
  "network-access": "ingress",
39124
39320
  "smtp-provider": "email"
39125
39321
  });
39322
+ var G711_SCALE_CORRECTION_DB = {
39323
+ PCMU: 20 * Math.log10(4),
39324
+ PCMA: 20 * Math.log10(8)
39325
+ };
39326
+ /**
39327
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
39328
+ * same intent on the ITU-T scale (D460).
39329
+ *
39330
+ * ## When this applies, and when it is the wrong thing to reach for
39331
+ *
39332
+ * An absolute-dBFS number in this repo is one of two things, and only one of
39333
+ * them converts:
39334
+ *
39335
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
39336
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
39337
+ * after. The defect was never in the number; it was that 19 of this hub's
39338
+ * 25 cameras did not obey it. Converting such a number takes something
39339
+ * correct and makes it wrong, in order to preserve a bug.
39340
+ * - **A measurement taken through the old decoder** — a value someone read
39341
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
39342
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
39343
+ * louder. That is what this function is for.
39344
+ *
39345
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
39346
+ * and it cannot be answered from the number. It is answered by the comment the
39347
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
39348
+ * mandatory.
39349
+ *
39350
+ * ## Why a function and not a typed-in number
39351
+ *
39352
+ * `-55 + 12.04` written into a source file is, six months later, completely
39353
+ * indistinguishable from a threshold somebody simply preferred. Calling this
39354
+ * keeps the derivation, the law, and the original measurement all visible at
39355
+ * the call site, so a future reader can disagree with the *premise* instead of
39356
+ * having to reverse-engineer the sum.
39357
+ *
39358
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
39359
+ * it is declared. It must never be applied to a live sample or a stored
39360
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
39361
+ * adjusting numbers the decoder already got right is the original defect with
39362
+ * an extra place to argue with (D459).
39363
+ */
39364
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
39365
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
39366
+ }
39367
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
39126
39368
  /** Schema defaults — an untouched sub-field must author exactly these. */
39127
39369
  var NC_AUDIO_DEFAULTS = {
39128
39370
  hitPercent: 60,
@@ -5418,6 +5418,86 @@ var ZodIssueCode = {
5418
5418
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5419
5419
  var ZodFirstPartyTypeKind;
5420
5420
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5421
+ //#endregion
5422
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5423
+ /**
5424
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5425
+ * window to float samples (D455).
5426
+ *
5427
+ * ## Why a format at all
5428
+ *
5429
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5430
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5431
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5432
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5433
+ * the plane carried four times the source. The plane crosses hub-main twice on
5434
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5435
+ *
5436
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5437
+ * them where it needs them. That is the same argument D450 made for the rate,
5438
+ * one step further along the same wire.
5439
+ *
5440
+ * ## Why the expansion lives here
5441
+ *
5442
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5443
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5444
+ * `AudioChunkPlane` expands per subscription) and
5445
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5446
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5447
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5448
+ * into their own dist (`self-contained` externals), so this travels with a
5449
+ * `camstack deploy` and needs no published server.
5450
+ *
5451
+ * A second μ-law table anywhere else is the defect this module exists to
5452
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5453
+ * direction for the WebRTC egress — a different transform, not a copy.)
5454
+ *
5455
+ * ## Absent means f32le
5456
+ *
5457
+ * `format` is optional on the wire and its absence means `f32le` — today's
5458
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5459
+ * has always been served, because the broker only emits a coded window to a
5460
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5461
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5462
+ * deployable one addon at a time across three nodes.
5463
+ */
5464
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5465
+ var AUDIO_CHUNK_FORMATS = [
5466
+ "f32le",
5467
+ "pcmu",
5468
+ "pcma"
5469
+ ];
5470
+ /**
5471
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5472
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5473
+ *
5474
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5475
+ * it buffers the coded bytes and the plane's consumers expand.
5476
+ */
5477
+ function buildUlawTable() {
5478
+ const table = new Float32Array(256);
5479
+ for (let i = 0; i < 256; i++) {
5480
+ const complemented = ~i & 255;
5481
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5482
+ const exponent = complemented >> 4 & 7;
5483
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5484
+ }
5485
+ return table;
5486
+ }
5487
+ /** Build the A-law decode table (ITU-T G.711). */
5488
+ function buildAlawTable() {
5489
+ const table = new Float32Array(256);
5490
+ for (let i = 0; i < 256; i++) {
5491
+ const xored = i ^ 85;
5492
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5493
+ const exponent = xored >> 4 & 7;
5494
+ const mantissa = xored & 15;
5495
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5496
+ }
5497
+ return table;
5498
+ }
5499
+ buildUlawTable();
5500
+ buildAlawTable();
5421
5501
  Object.fromEntries([
5422
5502
  {
5423
5503
  id: "overview",
@@ -6710,11 +6790,20 @@ var SubscribeFramesResultSchema = object({
6710
6790
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6711
6791
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6712
6792
  */
6793
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6713
6794
  var DecodedAudioChunkSchema = object({
6714
6795
  data: _instanceof(Uint8Array),
6715
6796
  sampleRate: number().int().positive(),
6716
6797
  channels: number().int().positive(),
6717
- timestamp: number()
6798
+ timestamp: number(),
6799
+ /**
6800
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6801
+ * byte, for any peer that never heard of this field. A coded window
6802
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6803
+ * subscription that DECLARED it accepts one, so absence can never mean
6804
+ * "coded bytes a consumer will read as floats" (D455).
6805
+ */
6806
+ format: AudioChunkFormatSchema.optional()
6718
6807
  });
6719
6808
  /**
6720
6809
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6726,7 +6815,18 @@ var DecodedAudioChunkSchema = object({
6726
6815
  var SubscribeAudioChunksInputSchema = object({
6727
6816
  brokerId: string(),
6728
6817
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6729
- tag: string().optional()
6818
+ tag: string().optional(),
6819
+ /**
6820
+ * Byte formats this subscriber can READ, best first. The broker serves the
6821
+ * chunk's own format when it is in this list and expands to `f32le`
6822
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6823
+ *
6824
+ * Absent (or without the source format) means `f32le` — the behaviour every
6825
+ * subscriber had before D455, unchanged. This is the negotiation half of
6826
+ * the source-bytes lever: it is what lets the broker and its consumers
6827
+ * deploy one at a time across three nodes.
6828
+ */
6829
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6730
6830
  });
6731
6831
  /** Result of `stream-broker.subscribeAudioChunks`. */
6732
6832
  var SubscribeAudioChunksResultSchema = object({
@@ -11349,6 +11449,51 @@ var AudioAnalysisSettingsSchema = object({
11349
11449
  minConfidence: number().min(0).max(1).default(.3),
11350
11450
  allowedClasses: array(string()).default([])
11351
11451
  });
11452
+ /**
11453
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11454
+ *
11455
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11456
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11457
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11458
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11459
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11460
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11461
+ * way to the one expansion that feeds the model.
11462
+ *
11463
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11464
+ * window, the per-device node assignment, the settings read) and therefore
11465
+ * still owns the attach/detach pair. It no longer owns the bytes.
11466
+ */
11467
+ var AudioAttachDeviceInputSchema = object({
11468
+ deviceId: number(),
11469
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11470
+ brokerId: string(),
11471
+ /**
11472
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11473
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11474
+ * the orchestrator's poller pinned them before the move.
11475
+ */
11476
+ ingestNodeId: string(),
11477
+ /**
11478
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11479
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11480
+ * window: a settings change re-attaches, which is what always happened.
11481
+ */
11482
+ settings: AudioAnalysisSettingsSchema
11483
+ });
11484
+ var AudioAttachDeviceResultSchema = object({
11485
+ /** False only when the analyzer is shutting down and refused to attach. */
11486
+ attached: boolean(),
11487
+ /**
11488
+ * True when the attachment replaced a live one for the same device. An
11489
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11490
+ * double the broker's fanout and neither would know about the other.
11491
+ */
11492
+ replaced: boolean()
11493
+ });
11494
+ var AudioDetachDeviceResultSchema = object({
11495
+ /** False when no attachment existed — detach is idempotent. */
11496
+ detached: boolean() });
11352
11497
  var AudioClassificationResultSchema = object({
11353
11498
  labels: array(AudioClassificationLabelSchema).readonly(),
11354
11499
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11357,7 +11502,7 @@ var AudioClassificationResultSchema = object({
11357
11502
  method(object({
11358
11503
  chunk: AudioChunkInputSchema,
11359
11504
  settings: AudioAnalysisSettingsSchema
11360
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11505
+ }), 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() }), {
11361
11506
  kind: "mutation",
11362
11507
  auth: "admin"
11363
11508
  });
@@ -20974,6 +21119,14 @@ var NativeCropResultSchema = object({
20974
21119
  * set `encodeJpeg: true`; `bytes` is then absent.
20975
21120
  */
20976
21121
  jpeg: string().optional(),
21122
+ /**
21123
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21124
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21125
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21126
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21127
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21128
+ */
21129
+ jpegBytes: _instanceof(Uint8Array).optional(),
20977
21130
  width: number().int().positive(),
20978
21131
  height: number().int().positive(),
20979
21132
  /**
@@ -21040,7 +21193,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21040
21193
  })]);
21041
21194
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21042
21195
  var ParkedTrackFrameSchema = object({
21043
- jpeg: string(),
21196
+ /**
21197
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21198
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21199
+ * Exactly one of the two is present.
21200
+ */
21201
+ jpeg: string().optional(),
21202
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21203
+ jpegBytes: _instanceof(Uint8Array).optional(),
21044
21204
  width: number().int().positive(),
21045
21205
  height: number().int().positive(),
21046
21206
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21627,6 +21787,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21627
21787
  bbox: NativeCropBboxSchema,
21628
21788
  maxWidth: number().int().positive().optional(),
21629
21789
  /**
21790
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21791
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21792
+ * wire — never assume consent: a pre-D462 caller parses the field as
21793
+ * base64 and bytes would decode to garbage rather than fail.
21794
+ */
21795
+ acceptJpegBytes: boolean().optional(),
21796
+ /**
21630
21797
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21631
21798
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21632
21799
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21694,7 +21861,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21694
21861
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21695
21862
  deviceId: number(),
21696
21863
  trackId: string(),
21697
- kind: ParkedFrameKindSchema
21864
+ kind: ParkedFrameKindSchema,
21865
+ /**
21866
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21867
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21868
+ * wire — never assume consent: a pre-D462 caller parses the field as
21869
+ * base64 and bytes would decode to garbage rather than fail.
21870
+ */
21871
+ acceptJpegBytes: boolean().optional()
21698
21872
  }), ParkedTrackFrameSchema.nullable()), method(object({
21699
21873
  deviceId: number(),
21700
21874
  trackId: string()
@@ -31406,12 +31580,24 @@ Object.freeze({
31406
31580
  addonId: null,
31407
31581
  access: "create"
31408
31582
  },
31583
+ "audioAnalyzer.attachDevice": {
31584
+ capName: "audio-analyzer",
31585
+ capScope: "system",
31586
+ addonId: null,
31587
+ access: "create"
31588
+ },
31409
31589
  "audioAnalyzer.classify": {
31410
31590
  capName: "audio-analyzer",
31411
31591
  capScope: "system",
31412
31592
  addonId: null,
31413
31593
  access: "view"
31414
31594
  },
31595
+ "audioAnalyzer.detachDevice": {
31596
+ capName: "audio-analyzer",
31597
+ capScope: "system",
31598
+ addonId: null,
31599
+ access: "create"
31600
+ },
31415
31601
  "audioAnalyzer.dispose": {
31416
31602
  capName: "audio-analyzer",
31417
31603
  capScope: "system",
@@ -37255,11 +37441,21 @@ Object.freeze({
37255
37441
  form: "single",
37256
37442
  optional: false
37257
37443
  }],
37444
+ "audioAnalyzer.attachDevice": [{
37445
+ name: "deviceId",
37446
+ form: "single",
37447
+ optional: false
37448
+ }],
37258
37449
  "audioAnalyzer.classify": [{
37259
37450
  name: "deviceId",
37260
37451
  form: "single",
37261
37452
  optional: true
37262
37453
  }],
37454
+ "audioAnalyzer.detachDevice": [{
37455
+ name: "deviceId",
37456
+ form: "single",
37457
+ optional: false
37458
+ }],
37263
37459
  "audioMetrics.getCurrentSnapshot": [{
37264
37460
  name: "deviceId",
37265
37461
  form: "single",
@@ -39111,6 +39307,52 @@ Object.freeze({
39111
39307
  "network-access": "ingress",
39112
39308
  "smtp-provider": "email"
39113
39309
  });
39310
+ var G711_SCALE_CORRECTION_DB = {
39311
+ PCMU: 20 * Math.log10(4),
39312
+ PCMA: 20 * Math.log10(8)
39313
+ };
39314
+ /**
39315
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
39316
+ * same intent on the ITU-T scale (D460).
39317
+ *
39318
+ * ## When this applies, and when it is the wrong thing to reach for
39319
+ *
39320
+ * An absolute-dBFS number in this repo is one of two things, and only one of
39321
+ * them converts:
39322
+ *
39323
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
39324
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
39325
+ * after. The defect was never in the number; it was that 19 of this hub's
39326
+ * 25 cameras did not obey it. Converting such a number takes something
39327
+ * correct and makes it wrong, in order to preserve a bug.
39328
+ * - **A measurement taken through the old decoder** — a value someone read
39329
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
39330
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
39331
+ * louder. That is what this function is for.
39332
+ *
39333
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
39334
+ * and it cannot be answered from the number. It is answered by the comment the
39335
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
39336
+ * mandatory.
39337
+ *
39338
+ * ## Why a function and not a typed-in number
39339
+ *
39340
+ * `-55 + 12.04` written into a source file is, six months later, completely
39341
+ * indistinguishable from a threshold somebody simply preferred. Calling this
39342
+ * keeps the derivation, the law, and the original measurement all visible at
39343
+ * the call site, so a future reader can disagree with the *premise* instead of
39344
+ * having to reverse-engineer the sum.
39345
+ *
39346
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
39347
+ * it is declared. It must never be applied to a live sample or a stored
39348
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
39349
+ * adjusting numbers the decoder already got right is the original defect with
39350
+ * an extra place to argue with (D459).
39351
+ */
39352
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
39353
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
39354
+ }
39355
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
39114
39356
  /** Schema defaults — an untouched sub-field must author exactly these. */
39115
39357
  var NC_AUDIO_DEFAULTS = {
39116
39358
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-export-hap",
3
- "version": "1.2.106",
3
+ "version": "1.2.108",
4
4
  "description": "HomeKit (HAP) exporter for CamStack devices. Publishes each exposed device as its own HomeKit accessory: cameras and doorbells with SRTP streaming, HomeKit Secure Video, motion, two-way audio, PTZ and battery; switches, lights, locks and sensors through a capability→service table.",
5
5
  "keywords": [
6
6
  "camstack",