@camstack/addon-export-google 0.1.59 → 0.1.61

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.
@@ -5423,6 +5423,86 @@ var ZodIssueCode = {
5423
5423
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5424
5424
  var ZodFirstPartyTypeKind;
5425
5425
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5426
+ //#endregion
5427
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5428
+ /**
5429
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5430
+ * window to float samples (D455).
5431
+ *
5432
+ * ## Why a format at all
5433
+ *
5434
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5435
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5436
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5437
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5438
+ * the plane carried four times the source. The plane crosses hub-main twice on
5439
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5440
+ *
5441
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5442
+ * them where it needs them. That is the same argument D450 made for the rate,
5443
+ * one step further along the same wire.
5444
+ *
5445
+ * ## Why the expansion lives here
5446
+ *
5447
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5448
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5449
+ * `AudioChunkPlane` expands per subscription) and
5450
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5451
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5452
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5453
+ * into their own dist (`self-contained` externals), so this travels with a
5454
+ * `camstack deploy` and needs no published server.
5455
+ *
5456
+ * A second μ-law table anywhere else is the defect this module exists to
5457
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5458
+ * direction for the WebRTC egress — a different transform, not a copy.)
5459
+ *
5460
+ * ## Absent means f32le
5461
+ *
5462
+ * `format` is optional on the wire and its absence means `f32le` — today's
5463
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5464
+ * has always been served, because the broker only emits a coded window to a
5465
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5466
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5467
+ * deployable one addon at a time across three nodes.
5468
+ */
5469
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5470
+ var AUDIO_CHUNK_FORMATS = [
5471
+ "f32le",
5472
+ "pcmu",
5473
+ "pcma"
5474
+ ];
5475
+ /**
5476
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5477
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5478
+ *
5479
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5480
+ * it buffers the coded bytes and the plane's consumers expand.
5481
+ */
5482
+ function buildUlawTable() {
5483
+ const table = new Float32Array(256);
5484
+ for (let i = 0; i < 256; i++) {
5485
+ const complemented = ~i & 255;
5486
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5487
+ const exponent = complemented >> 4 & 7;
5488
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5489
+ }
5490
+ return table;
5491
+ }
5492
+ /** Build the A-law decode table (ITU-T G.711). */
5493
+ function buildAlawTable() {
5494
+ const table = new Float32Array(256);
5495
+ for (let i = 0; i < 256; i++) {
5496
+ const xored = i ^ 85;
5497
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5498
+ const exponent = xored >> 4 & 7;
5499
+ const mantissa = xored & 15;
5500
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5501
+ }
5502
+ return table;
5503
+ }
5504
+ buildUlawTable();
5505
+ buildAlawTable();
5426
5506
  Object.fromEntries([
5427
5507
  {
5428
5508
  id: "overview",
@@ -6715,11 +6795,20 @@ var SubscribeFramesResultSchema = object({
6715
6795
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6716
6796
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6717
6797
  */
6798
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6718
6799
  var DecodedAudioChunkSchema = object({
6719
6800
  data: _instanceof(Uint8Array),
6720
6801
  sampleRate: number().int().positive(),
6721
6802
  channels: number().int().positive(),
6722
- timestamp: number()
6803
+ timestamp: number(),
6804
+ /**
6805
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6806
+ * byte, for any peer that never heard of this field. A coded window
6807
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6808
+ * subscription that DECLARED it accepts one, so absence can never mean
6809
+ * "coded bytes a consumer will read as floats" (D455).
6810
+ */
6811
+ format: AudioChunkFormatSchema.optional()
6723
6812
  });
6724
6813
  /**
6725
6814
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6731,7 +6820,18 @@ var DecodedAudioChunkSchema = object({
6731
6820
  var SubscribeAudioChunksInputSchema = object({
6732
6821
  brokerId: string(),
6733
6822
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6734
- tag: string().optional()
6823
+ tag: string().optional(),
6824
+ /**
6825
+ * Byte formats this subscriber can READ, best first. The broker serves the
6826
+ * chunk's own format when it is in this list and expands to `f32le`
6827
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6828
+ *
6829
+ * Absent (or without the source format) means `f32le` — the behaviour every
6830
+ * subscriber had before D455, unchanged. This is the negotiation half of
6831
+ * the source-bytes lever: it is what lets the broker and its consumers
6832
+ * deploy one at a time across three nodes.
6833
+ */
6834
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6735
6835
  });
6736
6836
  /** Result of `stream-broker.subscribeAudioChunks`. */
6737
6837
  var SubscribeAudioChunksResultSchema = object({
@@ -10860,6 +10960,51 @@ var AudioAnalysisSettingsSchema = object({
10860
10960
  minConfidence: number().min(0).max(1).default(.3),
10861
10961
  allowedClasses: array(string()).default([])
10862
10962
  });
10963
+ /**
10964
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10965
+ *
10966
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10967
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10968
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10969
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10970
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10971
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10972
+ * way to the one expansion that feeds the model.
10973
+ *
10974
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10975
+ * window, the per-device node assignment, the settings read) and therefore
10976
+ * still owns the attach/detach pair. It no longer owns the bytes.
10977
+ */
10978
+ var AudioAttachDeviceInputSchema = object({
10979
+ deviceId: number(),
10980
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10981
+ brokerId: string(),
10982
+ /**
10983
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10984
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10985
+ * the orchestrator's poller pinned them before the move.
10986
+ */
10987
+ ingestNodeId: string(),
10988
+ /**
10989
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10990
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10991
+ * window: a settings change re-attaches, which is what always happened.
10992
+ */
10993
+ settings: AudioAnalysisSettingsSchema
10994
+ });
10995
+ var AudioAttachDeviceResultSchema = object({
10996
+ /** False only when the analyzer is shutting down and refused to attach. */
10997
+ attached: boolean(),
10998
+ /**
10999
+ * True when the attachment replaced a live one for the same device. An
11000
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11001
+ * double the broker's fanout and neither would know about the other.
11002
+ */
11003
+ replaced: boolean()
11004
+ });
11005
+ var AudioDetachDeviceResultSchema = object({
11006
+ /** False when no attachment existed — detach is idempotent. */
11007
+ detached: boolean() });
10863
11008
  var AudioClassificationResultSchema = object({
10864
11009
  labels: array(AudioClassificationLabelSchema).readonly(),
10865
11010
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10868,7 +11013,7 @@ var AudioClassificationResultSchema = object({
10868
11013
  method(object({
10869
11014
  chunk: AudioChunkInputSchema,
10870
11015
  settings: AudioAnalysisSettingsSchema
10871
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11016
+ }), 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() }), {
10872
11017
  kind: "mutation",
10873
11018
  auth: "admin"
10874
11019
  });
@@ -20467,6 +20612,14 @@ var NativeCropResultSchema = object({
20467
20612
  * set `encodeJpeg: true`; `bytes` is then absent.
20468
20613
  */
20469
20614
  jpeg: string().optional(),
20615
+ /**
20616
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20617
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20618
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20619
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20620
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20621
+ */
20622
+ jpegBytes: _instanceof(Uint8Array).optional(),
20470
20623
  width: number().int().positive(),
20471
20624
  height: number().int().positive(),
20472
20625
  /**
@@ -20533,7 +20686,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20533
20686
  })]);
20534
20687
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20535
20688
  var ParkedTrackFrameSchema = object({
20536
- jpeg: string(),
20689
+ /**
20690
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20691
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20692
+ * Exactly one of the two is present.
20693
+ */
20694
+ jpeg: string().optional(),
20695
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20696
+ jpegBytes: _instanceof(Uint8Array).optional(),
20537
20697
  width: number().int().positive(),
20538
20698
  height: number().int().positive(),
20539
20699
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21120,6 +21280,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21120
21280
  bbox: NativeCropBboxSchema,
21121
21281
  maxWidth: number().int().positive().optional(),
21122
21282
  /**
21283
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21284
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21285
+ * wire — never assume consent: a pre-D462 caller parses the field as
21286
+ * base64 and bytes would decode to garbage rather than fail.
21287
+ */
21288
+ acceptJpegBytes: boolean().optional(),
21289
+ /**
21123
21290
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21124
21291
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21125
21292
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21187,7 +21354,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21187
21354
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21188
21355
  deviceId: number(),
21189
21356
  trackId: string(),
21190
- kind: ParkedFrameKindSchema
21357
+ kind: ParkedFrameKindSchema,
21358
+ /**
21359
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21360
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21361
+ * wire — never assume consent: a pre-D462 caller parses the field as
21362
+ * base64 and bytes would decode to garbage rather than fail.
21363
+ */
21364
+ acceptJpegBytes: boolean().optional()
21191
21365
  }), ParkedTrackFrameSchema.nullable()), method(object({
21192
21366
  deviceId: number(),
21193
21367
  trackId: string()
@@ -30845,12 +31019,24 @@ Object.freeze({
30845
31019
  addonId: null,
30846
31020
  access: "create"
30847
31021
  },
31022
+ "audioAnalyzer.attachDevice": {
31023
+ capName: "audio-analyzer",
31024
+ capScope: "system",
31025
+ addonId: null,
31026
+ access: "create"
31027
+ },
30848
31028
  "audioAnalyzer.classify": {
30849
31029
  capName: "audio-analyzer",
30850
31030
  capScope: "system",
30851
31031
  addonId: null,
30852
31032
  access: "view"
30853
31033
  },
31034
+ "audioAnalyzer.detachDevice": {
31035
+ capName: "audio-analyzer",
31036
+ capScope: "system",
31037
+ addonId: null,
31038
+ access: "create"
31039
+ },
30854
31040
  "audioAnalyzer.dispose": {
30855
31041
  capName: "audio-analyzer",
30856
31042
  capScope: "system",
@@ -36694,11 +36880,21 @@ Object.freeze({
36694
36880
  form: "single",
36695
36881
  optional: false
36696
36882
  }],
36883
+ "audioAnalyzer.attachDevice": [{
36884
+ name: "deviceId",
36885
+ form: "single",
36886
+ optional: false
36887
+ }],
36697
36888
  "audioAnalyzer.classify": [{
36698
36889
  name: "deviceId",
36699
36890
  form: "single",
36700
36891
  optional: true
36701
36892
  }],
36893
+ "audioAnalyzer.detachDevice": [{
36894
+ name: "deviceId",
36895
+ form: "single",
36896
+ optional: false
36897
+ }],
36702
36898
  "audioMetrics.getCurrentSnapshot": [{
36703
36899
  name: "deviceId",
36704
36900
  form: "single",
@@ -38550,6 +38746,52 @@ Object.freeze({
38550
38746
  "network-access": "ingress",
38551
38747
  "smtp-provider": "email"
38552
38748
  });
38749
+ var G711_SCALE_CORRECTION_DB = {
38750
+ PCMU: 20 * Math.log10(4),
38751
+ PCMA: 20 * Math.log10(8)
38752
+ };
38753
+ /**
38754
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
38755
+ * same intent on the ITU-T scale (D460).
38756
+ *
38757
+ * ## When this applies, and when it is the wrong thing to reach for
38758
+ *
38759
+ * An absolute-dBFS number in this repo is one of two things, and only one of
38760
+ * them converts:
38761
+ *
38762
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
38763
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
38764
+ * after. The defect was never in the number; it was that 19 of this hub's
38765
+ * 25 cameras did not obey it. Converting such a number takes something
38766
+ * correct and makes it wrong, in order to preserve a bug.
38767
+ * - **A measurement taken through the old decoder** — a value someone read
38768
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
38769
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
38770
+ * louder. That is what this function is for.
38771
+ *
38772
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
38773
+ * and it cannot be answered from the number. It is answered by the comment the
38774
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
38775
+ * mandatory.
38776
+ *
38777
+ * ## Why a function and not a typed-in number
38778
+ *
38779
+ * `-55 + 12.04` written into a source file is, six months later, completely
38780
+ * indistinguishable from a threshold somebody simply preferred. Calling this
38781
+ * keeps the derivation, the law, and the original measurement all visible at
38782
+ * the call site, so a future reader can disagree with the *premise* instead of
38783
+ * having to reverse-engineer the sum.
38784
+ *
38785
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
38786
+ * it is declared. It must never be applied to a live sample or a stored
38787
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
38788
+ * adjusting numbers the decoder already got right is the original defect with
38789
+ * an extra place to argue with (D459).
38790
+ */
38791
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
38792
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
38793
+ }
38794
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
38553
38795
  /** Schema defaults — an untouched sub-field must author exactly these. */
38554
38796
  var NC_AUDIO_DEFAULTS = {
38555
38797
  hitPercent: 60,
@@ -5419,6 +5419,86 @@ var ZodIssueCode = {
5419
5419
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5420
5420
  var ZodFirstPartyTypeKind;
5421
5421
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5422
+ //#endregion
5423
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5424
+ /**
5425
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5426
+ * window to float samples (D455).
5427
+ *
5428
+ * ## Why a format at all
5429
+ *
5430
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5431
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5432
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5433
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5434
+ * the plane carried four times the source. The plane crosses hub-main twice on
5435
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5436
+ *
5437
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5438
+ * them where it needs them. That is the same argument D450 made for the rate,
5439
+ * one step further along the same wire.
5440
+ *
5441
+ * ## Why the expansion lives here
5442
+ *
5443
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5444
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5445
+ * `AudioChunkPlane` expands per subscription) and
5446
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5447
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5448
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5449
+ * into their own dist (`self-contained` externals), so this travels with a
5450
+ * `camstack deploy` and needs no published server.
5451
+ *
5452
+ * A second μ-law table anywhere else is the defect this module exists to
5453
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5454
+ * direction for the WebRTC egress — a different transform, not a copy.)
5455
+ *
5456
+ * ## Absent means f32le
5457
+ *
5458
+ * `format` is optional on the wire and its absence means `f32le` — today's
5459
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5460
+ * has always been served, because the broker only emits a coded window to a
5461
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5462
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5463
+ * deployable one addon at a time across three nodes.
5464
+ */
5465
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5466
+ var AUDIO_CHUNK_FORMATS = [
5467
+ "f32le",
5468
+ "pcmu",
5469
+ "pcma"
5470
+ ];
5471
+ /**
5472
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5473
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5474
+ *
5475
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5476
+ * it buffers the coded bytes and the plane's consumers expand.
5477
+ */
5478
+ function buildUlawTable() {
5479
+ const table = new Float32Array(256);
5480
+ for (let i = 0; i < 256; i++) {
5481
+ const complemented = ~i & 255;
5482
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5483
+ const exponent = complemented >> 4 & 7;
5484
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5485
+ }
5486
+ return table;
5487
+ }
5488
+ /** Build the A-law decode table (ITU-T G.711). */
5489
+ function buildAlawTable() {
5490
+ const table = new Float32Array(256);
5491
+ for (let i = 0; i < 256; i++) {
5492
+ const xored = i ^ 85;
5493
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5494
+ const exponent = xored >> 4 & 7;
5495
+ const mantissa = xored & 15;
5496
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5497
+ }
5498
+ return table;
5499
+ }
5500
+ buildUlawTable();
5501
+ buildAlawTable();
5422
5502
  Object.fromEntries([
5423
5503
  {
5424
5504
  id: "overview",
@@ -6711,11 +6791,20 @@ var SubscribeFramesResultSchema = object({
6711
6791
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6712
6792
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6713
6793
  */
6794
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6714
6795
  var DecodedAudioChunkSchema = object({
6715
6796
  data: _instanceof(Uint8Array),
6716
6797
  sampleRate: number().int().positive(),
6717
6798
  channels: number().int().positive(),
6718
- timestamp: number()
6799
+ timestamp: number(),
6800
+ /**
6801
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6802
+ * byte, for any peer that never heard of this field. A coded window
6803
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6804
+ * subscription that DECLARED it accepts one, so absence can never mean
6805
+ * "coded bytes a consumer will read as floats" (D455).
6806
+ */
6807
+ format: AudioChunkFormatSchema.optional()
6719
6808
  });
6720
6809
  /**
6721
6810
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6727,7 +6816,18 @@ var DecodedAudioChunkSchema = object({
6727
6816
  var SubscribeAudioChunksInputSchema = object({
6728
6817
  brokerId: string(),
6729
6818
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6730
- tag: string().optional()
6819
+ tag: string().optional(),
6820
+ /**
6821
+ * Byte formats this subscriber can READ, best first. The broker serves the
6822
+ * chunk's own format when it is in this list and expands to `f32le`
6823
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6824
+ *
6825
+ * Absent (or without the source format) means `f32le` — the behaviour every
6826
+ * subscriber had before D455, unchanged. This is the negotiation half of
6827
+ * the source-bytes lever: it is what lets the broker and its consumers
6828
+ * deploy one at a time across three nodes.
6829
+ */
6830
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6731
6831
  });
6732
6832
  /** Result of `stream-broker.subscribeAudioChunks`. */
6733
6833
  var SubscribeAudioChunksResultSchema = object({
@@ -10856,6 +10956,51 @@ var AudioAnalysisSettingsSchema = object({
10856
10956
  minConfidence: number().min(0).max(1).default(.3),
10857
10957
  allowedClasses: array(string()).default([])
10858
10958
  });
10959
+ /**
10960
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10961
+ *
10962
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10963
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10964
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10965
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10966
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10967
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10968
+ * way to the one expansion that feeds the model.
10969
+ *
10970
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10971
+ * window, the per-device node assignment, the settings read) and therefore
10972
+ * still owns the attach/detach pair. It no longer owns the bytes.
10973
+ */
10974
+ var AudioAttachDeviceInputSchema = object({
10975
+ deviceId: number(),
10976
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10977
+ brokerId: string(),
10978
+ /**
10979
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10980
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10981
+ * the orchestrator's poller pinned them before the move.
10982
+ */
10983
+ ingestNodeId: string(),
10984
+ /**
10985
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10986
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10987
+ * window: a settings change re-attaches, which is what always happened.
10988
+ */
10989
+ settings: AudioAnalysisSettingsSchema
10990
+ });
10991
+ var AudioAttachDeviceResultSchema = object({
10992
+ /** False only when the analyzer is shutting down and refused to attach. */
10993
+ attached: boolean(),
10994
+ /**
10995
+ * True when the attachment replaced a live one for the same device. An
10996
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10997
+ * double the broker's fanout and neither would know about the other.
10998
+ */
10999
+ replaced: boolean()
11000
+ });
11001
+ var AudioDetachDeviceResultSchema = object({
11002
+ /** False when no attachment existed — detach is idempotent. */
11003
+ detached: boolean() });
10859
11004
  var AudioClassificationResultSchema = object({
10860
11005
  labels: array(AudioClassificationLabelSchema).readonly(),
10861
11006
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10864,7 +11009,7 @@ var AudioClassificationResultSchema = object({
10864
11009
  method(object({
10865
11010
  chunk: AudioChunkInputSchema,
10866
11011
  settings: AudioAnalysisSettingsSchema
10867
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11012
+ }), 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() }), {
10868
11013
  kind: "mutation",
10869
11014
  auth: "admin"
10870
11015
  });
@@ -20463,6 +20608,14 @@ var NativeCropResultSchema = object({
20463
20608
  * set `encodeJpeg: true`; `bytes` is then absent.
20464
20609
  */
20465
20610
  jpeg: string().optional(),
20611
+ /**
20612
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20613
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20614
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20615
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20616
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20617
+ */
20618
+ jpegBytes: _instanceof(Uint8Array).optional(),
20466
20619
  width: number().int().positive(),
20467
20620
  height: number().int().positive(),
20468
20621
  /**
@@ -20529,7 +20682,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20529
20682
  })]);
20530
20683
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20531
20684
  var ParkedTrackFrameSchema = object({
20532
- jpeg: string(),
20685
+ /**
20686
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20687
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20688
+ * Exactly one of the two is present.
20689
+ */
20690
+ jpeg: string().optional(),
20691
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20692
+ jpegBytes: _instanceof(Uint8Array).optional(),
20533
20693
  width: number().int().positive(),
20534
20694
  height: number().int().positive(),
20535
20695
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21116,6 +21276,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21116
21276
  bbox: NativeCropBboxSchema,
21117
21277
  maxWidth: number().int().positive().optional(),
21118
21278
  /**
21279
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21280
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21281
+ * wire — never assume consent: a pre-D462 caller parses the field as
21282
+ * base64 and bytes would decode to garbage rather than fail.
21283
+ */
21284
+ acceptJpegBytes: boolean().optional(),
21285
+ /**
21119
21286
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21120
21287
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21121
21288
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21183,7 +21350,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21183
21350
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21184
21351
  deviceId: number(),
21185
21352
  trackId: string(),
21186
- kind: ParkedFrameKindSchema
21353
+ kind: ParkedFrameKindSchema,
21354
+ /**
21355
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21356
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21357
+ * wire — never assume consent: a pre-D462 caller parses the field as
21358
+ * base64 and bytes would decode to garbage rather than fail.
21359
+ */
21360
+ acceptJpegBytes: boolean().optional()
21187
21361
  }), ParkedTrackFrameSchema.nullable()), method(object({
21188
21362
  deviceId: number(),
21189
21363
  trackId: string()
@@ -30841,12 +31015,24 @@ Object.freeze({
30841
31015
  addonId: null,
30842
31016
  access: "create"
30843
31017
  },
31018
+ "audioAnalyzer.attachDevice": {
31019
+ capName: "audio-analyzer",
31020
+ capScope: "system",
31021
+ addonId: null,
31022
+ access: "create"
31023
+ },
30844
31024
  "audioAnalyzer.classify": {
30845
31025
  capName: "audio-analyzer",
30846
31026
  capScope: "system",
30847
31027
  addonId: null,
30848
31028
  access: "view"
30849
31029
  },
31030
+ "audioAnalyzer.detachDevice": {
31031
+ capName: "audio-analyzer",
31032
+ capScope: "system",
31033
+ addonId: null,
31034
+ access: "create"
31035
+ },
30850
31036
  "audioAnalyzer.dispose": {
30851
31037
  capName: "audio-analyzer",
30852
31038
  capScope: "system",
@@ -36690,11 +36876,21 @@ Object.freeze({
36690
36876
  form: "single",
36691
36877
  optional: false
36692
36878
  }],
36879
+ "audioAnalyzer.attachDevice": [{
36880
+ name: "deviceId",
36881
+ form: "single",
36882
+ optional: false
36883
+ }],
36693
36884
  "audioAnalyzer.classify": [{
36694
36885
  name: "deviceId",
36695
36886
  form: "single",
36696
36887
  optional: true
36697
36888
  }],
36889
+ "audioAnalyzer.detachDevice": [{
36890
+ name: "deviceId",
36891
+ form: "single",
36892
+ optional: false
36893
+ }],
36698
36894
  "audioMetrics.getCurrentSnapshot": [{
36699
36895
  name: "deviceId",
36700
36896
  form: "single",
@@ -38546,6 +38742,52 @@ Object.freeze({
38546
38742
  "network-access": "ingress",
38547
38743
  "smtp-provider": "email"
38548
38744
  });
38745
+ var G711_SCALE_CORRECTION_DB = {
38746
+ PCMU: 20 * Math.log10(4),
38747
+ PCMA: 20 * Math.log10(8)
38748
+ };
38749
+ /**
38750
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
38751
+ * same intent on the ITU-T scale (D460).
38752
+ *
38753
+ * ## When this applies, and when it is the wrong thing to reach for
38754
+ *
38755
+ * An absolute-dBFS number in this repo is one of two things, and only one of
38756
+ * them converts:
38757
+ *
38758
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
38759
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
38760
+ * after. The defect was never in the number; it was that 19 of this hub's
38761
+ * 25 cameras did not obey it. Converting such a number takes something
38762
+ * correct and makes it wrong, in order to preserve a bug.
38763
+ * - **A measurement taken through the old decoder** — a value someone read
38764
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
38765
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
38766
+ * louder. That is what this function is for.
38767
+ *
38768
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
38769
+ * and it cannot be answered from the number. It is answered by the comment the
38770
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
38771
+ * mandatory.
38772
+ *
38773
+ * ## Why a function and not a typed-in number
38774
+ *
38775
+ * `-55 + 12.04` written into a source file is, six months later, completely
38776
+ * indistinguishable from a threshold somebody simply preferred. Calling this
38777
+ * keeps the derivation, the law, and the original measurement all visible at
38778
+ * the call site, so a future reader can disagree with the *premise* instead of
38779
+ * having to reverse-engineer the sum.
38780
+ *
38781
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
38782
+ * it is declared. It must never be applied to a live sample or a stored
38783
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
38784
+ * adjusting numbers the decoder already got right is the original defect with
38785
+ * an extra place to argue with (D459).
38786
+ */
38787
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
38788
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
38789
+ }
38790
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
38549
38791
  /** Schema defaults — an untouched sub-field must author exactly these. */
38550
38792
  var NC_AUDIO_DEFAULTS = {
38551
38793
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-export-google",
3
- "version": "0.1.59",
3
+ "version": "0.1.61",
4
4
  "description": "Google Home export — hub-side smart-home fulfillment (SYNC / QUERY / EXECUTE / DISCONNECT) for the non-camera fleet, served over the hub's own OAuth account link. No Google credential is stored, sent or required.",
5
5
  "keywords": [
6
6
  "camstack",