@camstack/addon-provider-petkit 0.2.95 → 0.2.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -6447,6 +6447,86 @@ var ZodIssueCode = {
6447
6447
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
6448
6448
  var ZodFirstPartyTypeKind;
6449
6449
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6450
+ //#endregion
6451
+ //#region ../types/dist/sleep-BnujYGPe.mjs
6452
+ /**
6453
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
6454
+ * window to float samples (D455).
6455
+ *
6456
+ * ## Why a format at all
6457
+ *
6458
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
6459
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
6460
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
6461
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
6462
+ * the plane carried four times the source. The plane crosses hub-main twice on
6463
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
6464
+ *
6465
+ * So the plane carries the source BYTES too, and whoever needs floats expands
6466
+ * them where it needs them. That is the same argument D450 made for the rate,
6467
+ * one step further along the same wire.
6468
+ *
6469
+ * ## Why the expansion lives here
6470
+ *
6471
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
6472
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
6473
+ * `AudioChunkPlane` expands per subscription) and
6474
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
6475
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
6476
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
6477
+ * into their own dist (`self-contained` externals), so this travels with a
6478
+ * `camstack deploy` and needs no published server.
6479
+ *
6480
+ * A second μ-law table anywhere else is the defect this module exists to
6481
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
6482
+ * direction for the WebRTC egress — a different transform, not a copy.)
6483
+ *
6484
+ * ## Absent means f32le
6485
+ *
6486
+ * `format` is optional on the wire and its absence means `f32le` — today's
6487
+ * bytes, byte for byte. A peer that never heard of the field is served what it
6488
+ * has always been served, because the broker only emits a coded window to a
6489
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
6490
+ * That is the D448 `rawForward` negotiation, and it is what makes this
6491
+ * deployable one addon at a time across three nodes.
6492
+ */
6493
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
6494
+ var AUDIO_CHUNK_FORMATS = [
6495
+ "f32le",
6496
+ "pcmu",
6497
+ "pcma"
6498
+ ];
6499
+ /**
6500
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
6501
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
6502
+ *
6503
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
6504
+ * it buffers the coded bytes and the plane's consumers expand.
6505
+ */
6506
+ function buildUlawTable() {
6507
+ const table = new Float32Array(256);
6508
+ for (let i = 0; i < 256; i++) {
6509
+ const complemented = ~i & 255;
6510
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
6511
+ const exponent = complemented >> 4 & 7;
6512
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
6513
+ }
6514
+ return table;
6515
+ }
6516
+ /** Build the A-law decode table (ITU-T G.711). */
6517
+ function buildAlawTable() {
6518
+ const table = new Float32Array(256);
6519
+ for (let i = 0; i < 256; i++) {
6520
+ const xored = i ^ 85;
6521
+ const sign = (xored & 128) !== 0 ? 1 : -1;
6522
+ const exponent = xored >> 4 & 7;
6523
+ const mantissa = xored & 15;
6524
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
6525
+ }
6526
+ return table;
6527
+ }
6528
+ buildUlawTable();
6529
+ buildAlawTable();
6450
6530
  Object.fromEntries([
6451
6531
  {
6452
6532
  id: "overview",
@@ -7739,11 +7819,20 @@ var SubscribeFramesResultSchema = object({
7739
7819
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
7740
7820
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
7741
7821
  */
7822
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
7742
7823
  var DecodedAudioChunkSchema = object({
7743
7824
  data: _instanceof(Uint8Array),
7744
7825
  sampleRate: number().int().positive(),
7745
7826
  channels: number().int().positive(),
7746
- timestamp: number()
7827
+ timestamp: number(),
7828
+ /**
7829
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
7830
+ * byte, for any peer that never heard of this field. A coded window
7831
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
7832
+ * subscription that DECLARED it accepts one, so absence can never mean
7833
+ * "coded bytes a consumer will read as floats" (D455).
7834
+ */
7835
+ format: AudioChunkFormatSchema.optional()
7747
7836
  });
7748
7837
  /**
7749
7838
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -7755,7 +7844,18 @@ var DecodedAudioChunkSchema = object({
7755
7844
  var SubscribeAudioChunksInputSchema = object({
7756
7845
  brokerId: string(),
7757
7846
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
7758
- tag: string().optional()
7847
+ tag: string().optional(),
7848
+ /**
7849
+ * Byte formats this subscriber can READ, best first. The broker serves the
7850
+ * chunk's own format when it is in this list and expands to `f32le`
7851
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
7852
+ *
7853
+ * Absent (or without the source format) means `f32le` — the behaviour every
7854
+ * subscriber had before D455, unchanged. This is the negotiation half of
7855
+ * the source-bytes lever: it is what lets the broker and its consumers
7856
+ * deploy one at a time across three nodes.
7857
+ */
7858
+ accept: array(AudioChunkFormatSchema).readonly().optional()
7759
7859
  });
7760
7860
  /** Result of `stream-broker.subscribeAudioChunks`. */
7761
7861
  var SubscribeAudioChunksResultSchema = object({
@@ -11743,6 +11843,51 @@ var AudioAnalysisSettingsSchema = object({
11743
11843
  minConfidence: number().min(0).max(1).default(.3),
11744
11844
  allowedClasses: array(string()).default([])
11745
11845
  });
11846
+ /**
11847
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11848
+ *
11849
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11850
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11851
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11852
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11853
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11854
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11855
+ * way to the one expansion that feeds the model.
11856
+ *
11857
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11858
+ * window, the per-device node assignment, the settings read) and therefore
11859
+ * still owns the attach/detach pair. It no longer owns the bytes.
11860
+ */
11861
+ var AudioAttachDeviceInputSchema = object({
11862
+ deviceId: number(),
11863
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11864
+ brokerId: string(),
11865
+ /**
11866
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11867
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11868
+ * the orchestrator's poller pinned them before the move.
11869
+ */
11870
+ ingestNodeId: string(),
11871
+ /**
11872
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11873
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11874
+ * window: a settings change re-attaches, which is what always happened.
11875
+ */
11876
+ settings: AudioAnalysisSettingsSchema
11877
+ });
11878
+ var AudioAttachDeviceResultSchema = object({
11879
+ /** False only when the analyzer is shutting down and refused to attach. */
11880
+ attached: boolean(),
11881
+ /**
11882
+ * True when the attachment replaced a live one for the same device. An
11883
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11884
+ * double the broker's fanout and neither would know about the other.
11885
+ */
11886
+ replaced: boolean()
11887
+ });
11888
+ var AudioDetachDeviceResultSchema = object({
11889
+ /** False when no attachment existed — detach is idempotent. */
11890
+ detached: boolean() });
11746
11891
  var AudioClassificationResultSchema = object({
11747
11892
  labels: array(AudioClassificationLabelSchema).readonly(),
11748
11893
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11751,7 +11896,7 @@ var AudioClassificationResultSchema = object({
11751
11896
  method(object({
11752
11897
  chunk: AudioChunkInputSchema,
11753
11898
  settings: AudioAnalysisSettingsSchema
11754
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11899
+ }), 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() }), {
11755
11900
  kind: "mutation",
11756
11901
  auth: "admin"
11757
11902
  });
@@ -21672,6 +21817,14 @@ var NativeCropResultSchema = object({
21672
21817
  * set `encodeJpeg: true`; `bytes` is then absent.
21673
21818
  */
21674
21819
  jpeg: string().optional(),
21820
+ /**
21821
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21822
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21823
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21824
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21825
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21826
+ */
21827
+ jpegBytes: _instanceof(Uint8Array).optional(),
21675
21828
  width: number().int().positive(),
21676
21829
  height: number().int().positive(),
21677
21830
  /**
@@ -21738,7 +21891,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21738
21891
  })]);
21739
21892
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21740
21893
  var ParkedTrackFrameSchema = object({
21741
- jpeg: string(),
21894
+ /**
21895
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21896
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21897
+ * Exactly one of the two is present.
21898
+ */
21899
+ jpeg: string().optional(),
21900
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21901
+ jpegBytes: _instanceof(Uint8Array).optional(),
21742
21902
  width: number().int().positive(),
21743
21903
  height: number().int().positive(),
21744
21904
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -22325,6 +22485,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22325
22485
  bbox: NativeCropBboxSchema,
22326
22486
  maxWidth: number().int().positive().optional(),
22327
22487
  /**
22488
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22489
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22490
+ * wire — never assume consent: a pre-D462 caller parses the field as
22491
+ * base64 and bytes would decode to garbage rather than fail.
22492
+ */
22493
+ acceptJpegBytes: boolean().optional(),
22494
+ /**
22328
22495
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
22329
22496
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
22330
22497
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -22392,7 +22559,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22392
22559
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
22393
22560
  deviceId: number(),
22394
22561
  trackId: string(),
22395
- kind: ParkedFrameKindSchema
22562
+ kind: ParkedFrameKindSchema,
22563
+ /**
22564
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22565
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22566
+ * wire — never assume consent: a pre-D462 caller parses the field as
22567
+ * base64 and bytes would decode to garbage rather than fail.
22568
+ */
22569
+ acceptJpegBytes: boolean().optional()
22396
22570
  }), ParkedTrackFrameSchema.nullable()), method(object({
22397
22571
  deviceId: number(),
22398
22572
  trackId: string()
@@ -36035,12 +36209,24 @@ Object.freeze({
36035
36209
  addonId: null,
36036
36210
  access: "create"
36037
36211
  },
36212
+ "audioAnalyzer.attachDevice": {
36213
+ capName: "audio-analyzer",
36214
+ capScope: "system",
36215
+ addonId: null,
36216
+ access: "create"
36217
+ },
36038
36218
  "audioAnalyzer.classify": {
36039
36219
  capName: "audio-analyzer",
36040
36220
  capScope: "system",
36041
36221
  addonId: null,
36042
36222
  access: "view"
36043
36223
  },
36224
+ "audioAnalyzer.detachDevice": {
36225
+ capName: "audio-analyzer",
36226
+ capScope: "system",
36227
+ addonId: null,
36228
+ access: "create"
36229
+ },
36044
36230
  "audioAnalyzer.dispose": {
36045
36231
  capName: "audio-analyzer",
36046
36232
  capScope: "system",
@@ -41884,11 +42070,21 @@ Object.freeze({
41884
42070
  form: "single",
41885
42071
  optional: false
41886
42072
  }],
42073
+ "audioAnalyzer.attachDevice": [{
42074
+ name: "deviceId",
42075
+ form: "single",
42076
+ optional: false
42077
+ }],
41887
42078
  "audioAnalyzer.classify": [{
41888
42079
  name: "deviceId",
41889
42080
  form: "single",
41890
42081
  optional: true
41891
42082
  }],
42083
+ "audioAnalyzer.detachDevice": [{
42084
+ name: "deviceId",
42085
+ form: "single",
42086
+ optional: false
42087
+ }],
41892
42088
  "audioMetrics.getCurrentSnapshot": [{
41893
42089
  name: "deviceId",
41894
42090
  form: "single",
@@ -43740,6 +43936,52 @@ Object.freeze({
43740
43936
  "network-access": "ingress",
43741
43937
  "smtp-provider": "email"
43742
43938
  });
43939
+ var G711_SCALE_CORRECTION_DB = {
43940
+ PCMU: 20 * Math.log10(4),
43941
+ PCMA: 20 * Math.log10(8)
43942
+ };
43943
+ /**
43944
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43945
+ * same intent on the ITU-T scale (D460).
43946
+ *
43947
+ * ## When this applies, and when it is the wrong thing to reach for
43948
+ *
43949
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43950
+ * them converts:
43951
+ *
43952
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43953
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43954
+ * after. The defect was never in the number; it was that 19 of this hub's
43955
+ * 25 cameras did not obey it. Converting such a number takes something
43956
+ * correct and makes it wrong, in order to preserve a bug.
43957
+ * - **A measurement taken through the old decoder** — a value someone read
43958
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43959
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43960
+ * louder. That is what this function is for.
43961
+ *
43962
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43963
+ * and it cannot be answered from the number. It is answered by the comment the
43964
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43965
+ * mandatory.
43966
+ *
43967
+ * ## Why a function and not a typed-in number
43968
+ *
43969
+ * `-55 + 12.04` written into a source file is, six months later, completely
43970
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43971
+ * keeps the derivation, the law, and the original measurement all visible at
43972
+ * the call site, so a future reader can disagree with the *premise* instead of
43973
+ * having to reverse-engineer the sum.
43974
+ *
43975
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43976
+ * it is declared. It must never be applied to a live sample or a stored
43977
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43978
+ * adjusting numbers the decoder already got right is the original defect with
43979
+ * an extra place to argue with (D459).
43980
+ */
43981
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43982
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43983
+ }
43984
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43743
43985
  /** Schema defaults — an untouched sub-field must author exactly these. */
43744
43986
  var NC_AUDIO_DEFAULTS = {
43745
43987
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -6446,6 +6446,86 @@ var ZodIssueCode = {
6446
6446
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
6447
6447
  var ZodFirstPartyTypeKind;
6448
6448
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6449
+ //#endregion
6450
+ //#region ../types/dist/sleep-BnujYGPe.mjs
6451
+ /**
6452
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
6453
+ * window to float samples (D455).
6454
+ *
6455
+ * ## Why a format at all
6456
+ *
6457
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
6458
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
6459
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
6460
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
6461
+ * the plane carried four times the source. The plane crosses hub-main twice on
6462
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
6463
+ *
6464
+ * So the plane carries the source BYTES too, and whoever needs floats expands
6465
+ * them where it needs them. That is the same argument D450 made for the rate,
6466
+ * one step further along the same wire.
6467
+ *
6468
+ * ## Why the expansion lives here
6469
+ *
6470
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
6471
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
6472
+ * `AudioChunkPlane` expands per subscription) and
6473
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
6474
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
6475
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
6476
+ * into their own dist (`self-contained` externals), so this travels with a
6477
+ * `camstack deploy` and needs no published server.
6478
+ *
6479
+ * A second μ-law table anywhere else is the defect this module exists to
6480
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
6481
+ * direction for the WebRTC egress — a different transform, not a copy.)
6482
+ *
6483
+ * ## Absent means f32le
6484
+ *
6485
+ * `format` is optional on the wire and its absence means `f32le` — today's
6486
+ * bytes, byte for byte. A peer that never heard of the field is served what it
6487
+ * has always been served, because the broker only emits a coded window to a
6488
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
6489
+ * That is the D448 `rawForward` negotiation, and it is what makes this
6490
+ * deployable one addon at a time across three nodes.
6491
+ */
6492
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
6493
+ var AUDIO_CHUNK_FORMATS = [
6494
+ "f32le",
6495
+ "pcmu",
6496
+ "pcma"
6497
+ ];
6498
+ /**
6499
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
6500
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
6501
+ *
6502
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
6503
+ * it buffers the coded bytes and the plane's consumers expand.
6504
+ */
6505
+ function buildUlawTable() {
6506
+ const table = new Float32Array(256);
6507
+ for (let i = 0; i < 256; i++) {
6508
+ const complemented = ~i & 255;
6509
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
6510
+ const exponent = complemented >> 4 & 7;
6511
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
6512
+ }
6513
+ return table;
6514
+ }
6515
+ /** Build the A-law decode table (ITU-T G.711). */
6516
+ function buildAlawTable() {
6517
+ const table = new Float32Array(256);
6518
+ for (let i = 0; i < 256; i++) {
6519
+ const xored = i ^ 85;
6520
+ const sign = (xored & 128) !== 0 ? 1 : -1;
6521
+ const exponent = xored >> 4 & 7;
6522
+ const mantissa = xored & 15;
6523
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
6524
+ }
6525
+ return table;
6526
+ }
6527
+ buildUlawTable();
6528
+ buildAlawTable();
6449
6529
  Object.fromEntries([
6450
6530
  {
6451
6531
  id: "overview",
@@ -7738,11 +7818,20 @@ var SubscribeFramesResultSchema = object({
7738
7818
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
7739
7819
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
7740
7820
  */
7821
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
7741
7822
  var DecodedAudioChunkSchema = object({
7742
7823
  data: _instanceof(Uint8Array),
7743
7824
  sampleRate: number().int().positive(),
7744
7825
  channels: number().int().positive(),
7745
- timestamp: number()
7826
+ timestamp: number(),
7827
+ /**
7828
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
7829
+ * byte, for any peer that never heard of this field. A coded window
7830
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
7831
+ * subscription that DECLARED it accepts one, so absence can never mean
7832
+ * "coded bytes a consumer will read as floats" (D455).
7833
+ */
7834
+ format: AudioChunkFormatSchema.optional()
7746
7835
  });
7747
7836
  /**
7748
7837
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -7754,7 +7843,18 @@ var DecodedAudioChunkSchema = object({
7754
7843
  var SubscribeAudioChunksInputSchema = object({
7755
7844
  brokerId: string(),
7756
7845
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
7757
- tag: string().optional()
7846
+ tag: string().optional(),
7847
+ /**
7848
+ * Byte formats this subscriber can READ, best first. The broker serves the
7849
+ * chunk's own format when it is in this list and expands to `f32le`
7850
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
7851
+ *
7852
+ * Absent (or without the source format) means `f32le` — the behaviour every
7853
+ * subscriber had before D455, unchanged. This is the negotiation half of
7854
+ * the source-bytes lever: it is what lets the broker and its consumers
7855
+ * deploy one at a time across three nodes.
7856
+ */
7857
+ accept: array(AudioChunkFormatSchema).readonly().optional()
7758
7858
  });
7759
7859
  /** Result of `stream-broker.subscribeAudioChunks`. */
7760
7860
  var SubscribeAudioChunksResultSchema = object({
@@ -11742,6 +11842,51 @@ var AudioAnalysisSettingsSchema = object({
11742
11842
  minConfidence: number().min(0).max(1).default(.3),
11743
11843
  allowedClasses: array(string()).default([])
11744
11844
  });
11845
+ /**
11846
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11847
+ *
11848
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11849
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11850
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11851
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11852
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11853
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11854
+ * way to the one expansion that feeds the model.
11855
+ *
11856
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11857
+ * window, the per-device node assignment, the settings read) and therefore
11858
+ * still owns the attach/detach pair. It no longer owns the bytes.
11859
+ */
11860
+ var AudioAttachDeviceInputSchema = object({
11861
+ deviceId: number(),
11862
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11863
+ brokerId: string(),
11864
+ /**
11865
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11866
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11867
+ * the orchestrator's poller pinned them before the move.
11868
+ */
11869
+ ingestNodeId: string(),
11870
+ /**
11871
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11872
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11873
+ * window: a settings change re-attaches, which is what always happened.
11874
+ */
11875
+ settings: AudioAnalysisSettingsSchema
11876
+ });
11877
+ var AudioAttachDeviceResultSchema = object({
11878
+ /** False only when the analyzer is shutting down and refused to attach. */
11879
+ attached: boolean(),
11880
+ /**
11881
+ * True when the attachment replaced a live one for the same device. An
11882
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11883
+ * double the broker's fanout and neither would know about the other.
11884
+ */
11885
+ replaced: boolean()
11886
+ });
11887
+ var AudioDetachDeviceResultSchema = object({
11888
+ /** False when no attachment existed — detach is idempotent. */
11889
+ detached: boolean() });
11745
11890
  var AudioClassificationResultSchema = object({
11746
11891
  labels: array(AudioClassificationLabelSchema).readonly(),
11747
11892
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11750,7 +11895,7 @@ var AudioClassificationResultSchema = object({
11750
11895
  method(object({
11751
11896
  chunk: AudioChunkInputSchema,
11752
11897
  settings: AudioAnalysisSettingsSchema
11753
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11898
+ }), 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() }), {
11754
11899
  kind: "mutation",
11755
11900
  auth: "admin"
11756
11901
  });
@@ -21671,6 +21816,14 @@ var NativeCropResultSchema = object({
21671
21816
  * set `encodeJpeg: true`; `bytes` is then absent.
21672
21817
  */
21673
21818
  jpeg: string().optional(),
21819
+ /**
21820
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21821
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21822
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21823
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21824
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21825
+ */
21826
+ jpegBytes: _instanceof(Uint8Array).optional(),
21674
21827
  width: number().int().positive(),
21675
21828
  height: number().int().positive(),
21676
21829
  /**
@@ -21737,7 +21890,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21737
21890
  })]);
21738
21891
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21739
21892
  var ParkedTrackFrameSchema = object({
21740
- jpeg: string(),
21893
+ /**
21894
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21895
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21896
+ * Exactly one of the two is present.
21897
+ */
21898
+ jpeg: string().optional(),
21899
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21900
+ jpegBytes: _instanceof(Uint8Array).optional(),
21741
21901
  width: number().int().positive(),
21742
21902
  height: number().int().positive(),
21743
21903
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -22324,6 +22484,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22324
22484
  bbox: NativeCropBboxSchema,
22325
22485
  maxWidth: number().int().positive().optional(),
22326
22486
  /**
22487
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22488
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22489
+ * wire — never assume consent: a pre-D462 caller parses the field as
22490
+ * base64 and bytes would decode to garbage rather than fail.
22491
+ */
22492
+ acceptJpegBytes: boolean().optional(),
22493
+ /**
22327
22494
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
22328
22495
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
22329
22496
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -22391,7 +22558,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22391
22558
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
22392
22559
  deviceId: number(),
22393
22560
  trackId: string(),
22394
- kind: ParkedFrameKindSchema
22561
+ kind: ParkedFrameKindSchema,
22562
+ /**
22563
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22564
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22565
+ * wire — never assume consent: a pre-D462 caller parses the field as
22566
+ * base64 and bytes would decode to garbage rather than fail.
22567
+ */
22568
+ acceptJpegBytes: boolean().optional()
22395
22569
  }), ParkedTrackFrameSchema.nullable()), method(object({
22396
22570
  deviceId: number(),
22397
22571
  trackId: string()
@@ -36034,12 +36208,24 @@ Object.freeze({
36034
36208
  addonId: null,
36035
36209
  access: "create"
36036
36210
  },
36211
+ "audioAnalyzer.attachDevice": {
36212
+ capName: "audio-analyzer",
36213
+ capScope: "system",
36214
+ addonId: null,
36215
+ access: "create"
36216
+ },
36037
36217
  "audioAnalyzer.classify": {
36038
36218
  capName: "audio-analyzer",
36039
36219
  capScope: "system",
36040
36220
  addonId: null,
36041
36221
  access: "view"
36042
36222
  },
36223
+ "audioAnalyzer.detachDevice": {
36224
+ capName: "audio-analyzer",
36225
+ capScope: "system",
36226
+ addonId: null,
36227
+ access: "create"
36228
+ },
36043
36229
  "audioAnalyzer.dispose": {
36044
36230
  capName: "audio-analyzer",
36045
36231
  capScope: "system",
@@ -41883,11 +42069,21 @@ Object.freeze({
41883
42069
  form: "single",
41884
42070
  optional: false
41885
42071
  }],
42072
+ "audioAnalyzer.attachDevice": [{
42073
+ name: "deviceId",
42074
+ form: "single",
42075
+ optional: false
42076
+ }],
41886
42077
  "audioAnalyzer.classify": [{
41887
42078
  name: "deviceId",
41888
42079
  form: "single",
41889
42080
  optional: true
41890
42081
  }],
42082
+ "audioAnalyzer.detachDevice": [{
42083
+ name: "deviceId",
42084
+ form: "single",
42085
+ optional: false
42086
+ }],
41891
42087
  "audioMetrics.getCurrentSnapshot": [{
41892
42088
  name: "deviceId",
41893
42089
  form: "single",
@@ -43739,6 +43935,52 @@ Object.freeze({
43739
43935
  "network-access": "ingress",
43740
43936
  "smtp-provider": "email"
43741
43937
  });
43938
+ var G711_SCALE_CORRECTION_DB = {
43939
+ PCMU: 20 * Math.log10(4),
43940
+ PCMA: 20 * Math.log10(8)
43941
+ };
43942
+ /**
43943
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43944
+ * same intent on the ITU-T scale (D460).
43945
+ *
43946
+ * ## When this applies, and when it is the wrong thing to reach for
43947
+ *
43948
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43949
+ * them converts:
43950
+ *
43951
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43952
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43953
+ * after. The defect was never in the number; it was that 19 of this hub's
43954
+ * 25 cameras did not obey it. Converting such a number takes something
43955
+ * correct and makes it wrong, in order to preserve a bug.
43956
+ * - **A measurement taken through the old decoder** — a value someone read
43957
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43958
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43959
+ * louder. That is what this function is for.
43960
+ *
43961
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43962
+ * and it cannot be answered from the number. It is answered by the comment the
43963
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43964
+ * mandatory.
43965
+ *
43966
+ * ## Why a function and not a typed-in number
43967
+ *
43968
+ * `-55 + 12.04` written into a source file is, six months later, completely
43969
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43970
+ * keeps the derivation, the law, and the original measurement all visible at
43971
+ * the call site, so a future reader can disagree with the *premise* instead of
43972
+ * having to reverse-engineer the sum.
43973
+ *
43974
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43975
+ * it is declared. It must never be applied to a live sample or a stored
43976
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43977
+ * adjusting numbers the decoder already got right is the original defect with
43978
+ * an extra place to argue with (D459).
43979
+ */
43980
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43981
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43982
+ }
43983
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43742
43984
  /** Schema defaults — an untouched sub-field must author exactly these. */
43743
43985
  var NC_AUDIO_DEFAULTS = {
43744
43986
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-petkit",
3
- "version": "0.2.95",
3
+ "version": "0.2.97",
4
4
  "description": "PetKit smart-feeder device-provider addon for CamStack — wraps the @apocaliss92/nodepetkit PetKit cloud client",
5
5
  "keywords": [
6
6
  "camstack",