@camstack/addon-terminal 0.1.100 → 0.1.102

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
@@ -5377,6 +5377,86 @@ var ZodIssueCode = {
5377
5377
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5378
5378
  var ZodFirstPartyTypeKind;
5379
5379
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5380
+ //#endregion
5381
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5382
+ /**
5383
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5384
+ * window to float samples (D455).
5385
+ *
5386
+ * ## Why a format at all
5387
+ *
5388
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5389
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5390
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5391
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5392
+ * the plane carried four times the source. The plane crosses hub-main twice on
5393
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5394
+ *
5395
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5396
+ * them where it needs them. That is the same argument D450 made for the rate,
5397
+ * one step further along the same wire.
5398
+ *
5399
+ * ## Why the expansion lives here
5400
+ *
5401
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5402
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5403
+ * `AudioChunkPlane` expands per subscription) and
5404
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5405
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5406
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5407
+ * into their own dist (`self-contained` externals), so this travels with a
5408
+ * `camstack deploy` and needs no published server.
5409
+ *
5410
+ * A second μ-law table anywhere else is the defect this module exists to
5411
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5412
+ * direction for the WebRTC egress — a different transform, not a copy.)
5413
+ *
5414
+ * ## Absent means f32le
5415
+ *
5416
+ * `format` is optional on the wire and its absence means `f32le` — today's
5417
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5418
+ * has always been served, because the broker only emits a coded window to a
5419
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5420
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5421
+ * deployable one addon at a time across three nodes.
5422
+ */
5423
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5424
+ var AUDIO_CHUNK_FORMATS = [
5425
+ "f32le",
5426
+ "pcmu",
5427
+ "pcma"
5428
+ ];
5429
+ /**
5430
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5431
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5432
+ *
5433
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5434
+ * it buffers the coded bytes and the plane's consumers expand.
5435
+ */
5436
+ function buildUlawTable() {
5437
+ const table = new Float32Array(256);
5438
+ for (let i = 0; i < 256; i++) {
5439
+ const complemented = ~i & 255;
5440
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5441
+ const exponent = complemented >> 4 & 7;
5442
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5443
+ }
5444
+ return table;
5445
+ }
5446
+ /** Build the A-law decode table (ITU-T G.711). */
5447
+ function buildAlawTable() {
5448
+ const table = new Float32Array(256);
5449
+ for (let i = 0; i < 256; i++) {
5450
+ const xored = i ^ 85;
5451
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5452
+ const exponent = xored >> 4 & 7;
5453
+ const mantissa = xored & 15;
5454
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5455
+ }
5456
+ return table;
5457
+ }
5458
+ buildUlawTable();
5459
+ buildAlawTable();
5380
5460
  Object.fromEntries([
5381
5461
  {
5382
5462
  id: "overview",
@@ -6669,11 +6749,20 @@ var SubscribeFramesResultSchema = object({
6669
6749
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6670
6750
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6671
6751
  */
6752
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6672
6753
  var DecodedAudioChunkSchema = object({
6673
6754
  data: _instanceof(Uint8Array),
6674
6755
  sampleRate: number().int().positive(),
6675
6756
  channels: number().int().positive(),
6676
- timestamp: number()
6757
+ timestamp: number(),
6758
+ /**
6759
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6760
+ * byte, for any peer that never heard of this field. A coded window
6761
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6762
+ * subscription that DECLARED it accepts one, so absence can never mean
6763
+ * "coded bytes a consumer will read as floats" (D455).
6764
+ */
6765
+ format: AudioChunkFormatSchema.optional()
6677
6766
  });
6678
6767
  /**
6679
6768
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6685,7 +6774,18 @@ var DecodedAudioChunkSchema = object({
6685
6774
  var SubscribeAudioChunksInputSchema = object({
6686
6775
  brokerId: string(),
6687
6776
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6688
- tag: string().optional()
6777
+ tag: string().optional(),
6778
+ /**
6779
+ * Byte formats this subscriber can READ, best first. The broker serves the
6780
+ * chunk's own format when it is in this list and expands to `f32le`
6781
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6782
+ *
6783
+ * Absent (or without the source format) means `f32le` — the behaviour every
6784
+ * subscriber had before D455, unchanged. This is the negotiation half of
6785
+ * the source-bytes lever: it is what lets the broker and its consumers
6786
+ * deploy one at a time across three nodes.
6787
+ */
6788
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6689
6789
  });
6690
6790
  /** Result of `stream-broker.subscribeAudioChunks`. */
6691
6791
  var SubscribeAudioChunksResultSchema = object({
@@ -10740,6 +10840,51 @@ var AudioAnalysisSettingsSchema = object({
10740
10840
  minConfidence: number().min(0).max(1).default(.3),
10741
10841
  allowedClasses: array(string()).default([])
10742
10842
  });
10843
+ /**
10844
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10845
+ *
10846
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10847
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10848
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10849
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10850
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10851
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10852
+ * way to the one expansion that feeds the model.
10853
+ *
10854
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10855
+ * window, the per-device node assignment, the settings read) and therefore
10856
+ * still owns the attach/detach pair. It no longer owns the bytes.
10857
+ */
10858
+ var AudioAttachDeviceInputSchema = object({
10859
+ deviceId: number(),
10860
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10861
+ brokerId: string(),
10862
+ /**
10863
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10864
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10865
+ * the orchestrator's poller pinned them before the move.
10866
+ */
10867
+ ingestNodeId: string(),
10868
+ /**
10869
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10870
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10871
+ * window: a settings change re-attaches, which is what always happened.
10872
+ */
10873
+ settings: AudioAnalysisSettingsSchema
10874
+ });
10875
+ var AudioAttachDeviceResultSchema = object({
10876
+ /** False only when the analyzer is shutting down and refused to attach. */
10877
+ attached: boolean(),
10878
+ /**
10879
+ * True when the attachment replaced a live one for the same device. An
10880
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10881
+ * double the broker's fanout and neither would know about the other.
10882
+ */
10883
+ replaced: boolean()
10884
+ });
10885
+ var AudioDetachDeviceResultSchema = object({
10886
+ /** False when no attachment existed — detach is idempotent. */
10887
+ detached: boolean() });
10743
10888
  var AudioClassificationResultSchema = object({
10744
10889
  labels: array(AudioClassificationLabelSchema).readonly(),
10745
10890
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10748,7 +10893,7 @@ var AudioClassificationResultSchema = object({
10748
10893
  method(object({
10749
10894
  chunk: AudioChunkInputSchema,
10750
10895
  settings: AudioAnalysisSettingsSchema
10751
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10896
+ }), 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() }), {
10752
10897
  kind: "mutation",
10753
10898
  auth: "admin"
10754
10899
  });
@@ -20571,6 +20716,14 @@ var NativeCropResultSchema = object({
20571
20716
  * set `encodeJpeg: true`; `bytes` is then absent.
20572
20717
  */
20573
20718
  jpeg: string().optional(),
20719
+ /**
20720
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20721
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20722
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20723
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20724
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20725
+ */
20726
+ jpegBytes: _instanceof(Uint8Array).optional(),
20574
20727
  width: number().int().positive(),
20575
20728
  height: number().int().positive(),
20576
20729
  /**
@@ -20637,7 +20790,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20637
20790
  })]);
20638
20791
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20639
20792
  var ParkedTrackFrameSchema = object({
20640
- jpeg: string(),
20793
+ /**
20794
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20795
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20796
+ * Exactly one of the two is present.
20797
+ */
20798
+ jpeg: string().optional(),
20799
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20800
+ jpegBytes: _instanceof(Uint8Array).optional(),
20641
20801
  width: number().int().positive(),
20642
20802
  height: number().int().positive(),
20643
20803
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21224,6 +21384,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21224
21384
  bbox: NativeCropBboxSchema,
21225
21385
  maxWidth: number().int().positive().optional(),
21226
21386
  /**
21387
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21388
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21389
+ * wire — never assume consent: a pre-D462 caller parses the field as
21390
+ * base64 and bytes would decode to garbage rather than fail.
21391
+ */
21392
+ acceptJpegBytes: boolean().optional(),
21393
+ /**
21227
21394
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21228
21395
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21229
21396
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21291,7 +21458,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21291
21458
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21292
21459
  deviceId: number(),
21293
21460
  trackId: string(),
21294
- kind: ParkedFrameKindSchema
21461
+ kind: ParkedFrameKindSchema,
21462
+ /**
21463
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21464
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21465
+ * wire — never assume consent: a pre-D462 caller parses the field as
21466
+ * base64 and bytes would decode to garbage rather than fail.
21467
+ */
21468
+ acceptJpegBytes: boolean().optional()
21295
21469
  }), ParkedTrackFrameSchema.nullable()), method(object({
21296
21470
  deviceId: number(),
21297
21471
  trackId: string()
@@ -34656,12 +34830,24 @@ Object.freeze({
34656
34830
  addonId: null,
34657
34831
  access: "create"
34658
34832
  },
34833
+ "audioAnalyzer.attachDevice": {
34834
+ capName: "audio-analyzer",
34835
+ capScope: "system",
34836
+ addonId: null,
34837
+ access: "create"
34838
+ },
34659
34839
  "audioAnalyzer.classify": {
34660
34840
  capName: "audio-analyzer",
34661
34841
  capScope: "system",
34662
34842
  addonId: null,
34663
34843
  access: "view"
34664
34844
  },
34845
+ "audioAnalyzer.detachDevice": {
34846
+ capName: "audio-analyzer",
34847
+ capScope: "system",
34848
+ addonId: null,
34849
+ access: "create"
34850
+ },
34665
34851
  "audioAnalyzer.dispose": {
34666
34852
  capName: "audio-analyzer",
34667
34853
  capScope: "system",
@@ -40505,11 +40691,21 @@ Object.freeze({
40505
40691
  form: "single",
40506
40692
  optional: false
40507
40693
  }],
40694
+ "audioAnalyzer.attachDevice": [{
40695
+ name: "deviceId",
40696
+ form: "single",
40697
+ optional: false
40698
+ }],
40508
40699
  "audioAnalyzer.classify": [{
40509
40700
  name: "deviceId",
40510
40701
  form: "single",
40511
40702
  optional: true
40512
40703
  }],
40704
+ "audioAnalyzer.detachDevice": [{
40705
+ name: "deviceId",
40706
+ form: "single",
40707
+ optional: false
40708
+ }],
40513
40709
  "audioMetrics.getCurrentSnapshot": [{
40514
40710
  name: "deviceId",
40515
40711
  form: "single",
@@ -42361,6 +42557,52 @@ Object.freeze({
42361
42557
  "network-access": "ingress",
42362
42558
  "smtp-provider": "email"
42363
42559
  });
42560
+ var G711_SCALE_CORRECTION_DB = {
42561
+ PCMU: 20 * Math.log10(4),
42562
+ PCMA: 20 * Math.log10(8)
42563
+ };
42564
+ /**
42565
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42566
+ * same intent on the ITU-T scale (D460).
42567
+ *
42568
+ * ## When this applies, and when it is the wrong thing to reach for
42569
+ *
42570
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42571
+ * them converts:
42572
+ *
42573
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42574
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42575
+ * after. The defect was never in the number; it was that 19 of this hub's
42576
+ * 25 cameras did not obey it. Converting such a number takes something
42577
+ * correct and makes it wrong, in order to preserve a bug.
42578
+ * - **A measurement taken through the old decoder** — a value someone read
42579
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42580
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42581
+ * louder. That is what this function is for.
42582
+ *
42583
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42584
+ * and it cannot be answered from the number. It is answered by the comment the
42585
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42586
+ * mandatory.
42587
+ *
42588
+ * ## Why a function and not a typed-in number
42589
+ *
42590
+ * `-55 + 12.04` written into a source file is, six months later, completely
42591
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42592
+ * keeps the derivation, the law, and the original measurement all visible at
42593
+ * the call site, so a future reader can disagree with the *premise* instead of
42594
+ * having to reverse-engineer the sum.
42595
+ *
42596
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42597
+ * it is declared. It must never be applied to a live sample or a stored
42598
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42599
+ * adjusting numbers the decoder already got right is the original defect with
42600
+ * an extra place to argue with (D459).
42601
+ */
42602
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42603
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42604
+ }
42605
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42364
42606
  /** Schema defaults — an untouched sub-field must author exactly these. */
42365
42607
  var NC_AUDIO_DEFAULTS = {
42366
42608
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5354,6 +5354,86 @@ var ZodIssueCode = {
5354
5354
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5355
5355
  var ZodFirstPartyTypeKind;
5356
5356
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5357
+ //#endregion
5358
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5359
+ /**
5360
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5361
+ * window to float samples (D455).
5362
+ *
5363
+ * ## Why a format at all
5364
+ *
5365
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5366
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5367
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5368
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5369
+ * the plane carried four times the source. The plane crosses hub-main twice on
5370
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5371
+ *
5372
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5373
+ * them where it needs them. That is the same argument D450 made for the rate,
5374
+ * one step further along the same wire.
5375
+ *
5376
+ * ## Why the expansion lives here
5377
+ *
5378
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5379
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5380
+ * `AudioChunkPlane` expands per subscription) and
5381
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5382
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5383
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5384
+ * into their own dist (`self-contained` externals), so this travels with a
5385
+ * `camstack deploy` and needs no published server.
5386
+ *
5387
+ * A second μ-law table anywhere else is the defect this module exists to
5388
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5389
+ * direction for the WebRTC egress — a different transform, not a copy.)
5390
+ *
5391
+ * ## Absent means f32le
5392
+ *
5393
+ * `format` is optional on the wire and its absence means `f32le` — today's
5394
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5395
+ * has always been served, because the broker only emits a coded window to a
5396
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5397
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5398
+ * deployable one addon at a time across three nodes.
5399
+ */
5400
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5401
+ var AUDIO_CHUNK_FORMATS = [
5402
+ "f32le",
5403
+ "pcmu",
5404
+ "pcma"
5405
+ ];
5406
+ /**
5407
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5408
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5409
+ *
5410
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5411
+ * it buffers the coded bytes and the plane's consumers expand.
5412
+ */
5413
+ function buildUlawTable() {
5414
+ const table = new Float32Array(256);
5415
+ for (let i = 0; i < 256; i++) {
5416
+ const complemented = ~i & 255;
5417
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5418
+ const exponent = complemented >> 4 & 7;
5419
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5420
+ }
5421
+ return table;
5422
+ }
5423
+ /** Build the A-law decode table (ITU-T G.711). */
5424
+ function buildAlawTable() {
5425
+ const table = new Float32Array(256);
5426
+ for (let i = 0; i < 256; i++) {
5427
+ const xored = i ^ 85;
5428
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5429
+ const exponent = xored >> 4 & 7;
5430
+ const mantissa = xored & 15;
5431
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5432
+ }
5433
+ return table;
5434
+ }
5435
+ buildUlawTable();
5436
+ buildAlawTable();
5357
5437
  Object.fromEntries([
5358
5438
  {
5359
5439
  id: "overview",
@@ -6646,11 +6726,20 @@ var SubscribeFramesResultSchema = object({
6646
6726
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6647
6727
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6648
6728
  */
6729
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6649
6730
  var DecodedAudioChunkSchema = object({
6650
6731
  data: _instanceof(Uint8Array),
6651
6732
  sampleRate: number().int().positive(),
6652
6733
  channels: number().int().positive(),
6653
- timestamp: number()
6734
+ timestamp: number(),
6735
+ /**
6736
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6737
+ * byte, for any peer that never heard of this field. A coded window
6738
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6739
+ * subscription that DECLARED it accepts one, so absence can never mean
6740
+ * "coded bytes a consumer will read as floats" (D455).
6741
+ */
6742
+ format: AudioChunkFormatSchema.optional()
6654
6743
  });
6655
6744
  /**
6656
6745
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6662,7 +6751,18 @@ var DecodedAudioChunkSchema = object({
6662
6751
  var SubscribeAudioChunksInputSchema = object({
6663
6752
  brokerId: string(),
6664
6753
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6665
- tag: string().optional()
6754
+ tag: string().optional(),
6755
+ /**
6756
+ * Byte formats this subscriber can READ, best first. The broker serves the
6757
+ * chunk's own format when it is in this list and expands to `f32le`
6758
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6759
+ *
6760
+ * Absent (or without the source format) means `f32le` — the behaviour every
6761
+ * subscriber had before D455, unchanged. This is the negotiation half of
6762
+ * the source-bytes lever: it is what lets the broker and its consumers
6763
+ * deploy one at a time across three nodes.
6764
+ */
6765
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6666
6766
  });
6667
6767
  /** Result of `stream-broker.subscribeAudioChunks`. */
6668
6768
  var SubscribeAudioChunksResultSchema = object({
@@ -10717,6 +10817,51 @@ var AudioAnalysisSettingsSchema = object({
10717
10817
  minConfidence: number().min(0).max(1).default(.3),
10718
10818
  allowedClasses: array(string()).default([])
10719
10819
  });
10820
+ /**
10821
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10822
+ *
10823
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10824
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10825
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10826
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10827
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10828
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10829
+ * way to the one expansion that feeds the model.
10830
+ *
10831
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10832
+ * window, the per-device node assignment, the settings read) and therefore
10833
+ * still owns the attach/detach pair. It no longer owns the bytes.
10834
+ */
10835
+ var AudioAttachDeviceInputSchema = object({
10836
+ deviceId: number(),
10837
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10838
+ brokerId: string(),
10839
+ /**
10840
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10841
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10842
+ * the orchestrator's poller pinned them before the move.
10843
+ */
10844
+ ingestNodeId: string(),
10845
+ /**
10846
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10847
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10848
+ * window: a settings change re-attaches, which is what always happened.
10849
+ */
10850
+ settings: AudioAnalysisSettingsSchema
10851
+ });
10852
+ var AudioAttachDeviceResultSchema = object({
10853
+ /** False only when the analyzer is shutting down and refused to attach. */
10854
+ attached: boolean(),
10855
+ /**
10856
+ * True when the attachment replaced a live one for the same device. An
10857
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10858
+ * double the broker's fanout and neither would know about the other.
10859
+ */
10860
+ replaced: boolean()
10861
+ });
10862
+ var AudioDetachDeviceResultSchema = object({
10863
+ /** False when no attachment existed — detach is idempotent. */
10864
+ detached: boolean() });
10720
10865
  var AudioClassificationResultSchema = object({
10721
10866
  labels: array(AudioClassificationLabelSchema).readonly(),
10722
10867
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10725,7 +10870,7 @@ var AudioClassificationResultSchema = object({
10725
10870
  method(object({
10726
10871
  chunk: AudioChunkInputSchema,
10727
10872
  settings: AudioAnalysisSettingsSchema
10728
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10873
+ }), 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() }), {
10729
10874
  kind: "mutation",
10730
10875
  auth: "admin"
10731
10876
  });
@@ -20548,6 +20693,14 @@ var NativeCropResultSchema = object({
20548
20693
  * set `encodeJpeg: true`; `bytes` is then absent.
20549
20694
  */
20550
20695
  jpeg: string().optional(),
20696
+ /**
20697
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20698
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20699
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20700
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20701
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20702
+ */
20703
+ jpegBytes: _instanceof(Uint8Array).optional(),
20551
20704
  width: number().int().positive(),
20552
20705
  height: number().int().positive(),
20553
20706
  /**
@@ -20614,7 +20767,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20614
20767
  })]);
20615
20768
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20616
20769
  var ParkedTrackFrameSchema = object({
20617
- jpeg: string(),
20770
+ /**
20771
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20772
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20773
+ * Exactly one of the two is present.
20774
+ */
20775
+ jpeg: string().optional(),
20776
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20777
+ jpegBytes: _instanceof(Uint8Array).optional(),
20618
20778
  width: number().int().positive(),
20619
20779
  height: number().int().positive(),
20620
20780
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21201,6 +21361,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21201
21361
  bbox: NativeCropBboxSchema,
21202
21362
  maxWidth: number().int().positive().optional(),
21203
21363
  /**
21364
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21365
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21366
+ * wire — never assume consent: a pre-D462 caller parses the field as
21367
+ * base64 and bytes would decode to garbage rather than fail.
21368
+ */
21369
+ acceptJpegBytes: boolean().optional(),
21370
+ /**
21204
21371
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21205
21372
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21206
21373
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21268,7 +21435,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21268
21435
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21269
21436
  deviceId: number(),
21270
21437
  trackId: string(),
21271
- kind: ParkedFrameKindSchema
21438
+ kind: ParkedFrameKindSchema,
21439
+ /**
21440
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21441
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21442
+ * wire — never assume consent: a pre-D462 caller parses the field as
21443
+ * base64 and bytes would decode to garbage rather than fail.
21444
+ */
21445
+ acceptJpegBytes: boolean().optional()
21272
21446
  }), ParkedTrackFrameSchema.nullable()), method(object({
21273
21447
  deviceId: number(),
21274
21448
  trackId: string()
@@ -34633,12 +34807,24 @@ Object.freeze({
34633
34807
  addonId: null,
34634
34808
  access: "create"
34635
34809
  },
34810
+ "audioAnalyzer.attachDevice": {
34811
+ capName: "audio-analyzer",
34812
+ capScope: "system",
34813
+ addonId: null,
34814
+ access: "create"
34815
+ },
34636
34816
  "audioAnalyzer.classify": {
34637
34817
  capName: "audio-analyzer",
34638
34818
  capScope: "system",
34639
34819
  addonId: null,
34640
34820
  access: "view"
34641
34821
  },
34822
+ "audioAnalyzer.detachDevice": {
34823
+ capName: "audio-analyzer",
34824
+ capScope: "system",
34825
+ addonId: null,
34826
+ access: "create"
34827
+ },
34642
34828
  "audioAnalyzer.dispose": {
34643
34829
  capName: "audio-analyzer",
34644
34830
  capScope: "system",
@@ -40482,11 +40668,21 @@ Object.freeze({
40482
40668
  form: "single",
40483
40669
  optional: false
40484
40670
  }],
40671
+ "audioAnalyzer.attachDevice": [{
40672
+ name: "deviceId",
40673
+ form: "single",
40674
+ optional: false
40675
+ }],
40485
40676
  "audioAnalyzer.classify": [{
40486
40677
  name: "deviceId",
40487
40678
  form: "single",
40488
40679
  optional: true
40489
40680
  }],
40681
+ "audioAnalyzer.detachDevice": [{
40682
+ name: "deviceId",
40683
+ form: "single",
40684
+ optional: false
40685
+ }],
40490
40686
  "audioMetrics.getCurrentSnapshot": [{
40491
40687
  name: "deviceId",
40492
40688
  form: "single",
@@ -42338,6 +42534,52 @@ Object.freeze({
42338
42534
  "network-access": "ingress",
42339
42535
  "smtp-provider": "email"
42340
42536
  });
42537
+ var G711_SCALE_CORRECTION_DB = {
42538
+ PCMU: 20 * Math.log10(4),
42539
+ PCMA: 20 * Math.log10(8)
42540
+ };
42541
+ /**
42542
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42543
+ * same intent on the ITU-T scale (D460).
42544
+ *
42545
+ * ## When this applies, and when it is the wrong thing to reach for
42546
+ *
42547
+ * An absolute-dBFS number in this repo is one of two things, and only one of
42548
+ * them converts:
42549
+ *
42550
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
42551
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
42552
+ * after. The defect was never in the number; it was that 19 of this hub's
42553
+ * 25 cameras did not obey it. Converting such a number takes something
42554
+ * correct and makes it wrong, in order to preserve a bug.
42555
+ * - **A measurement taken through the old decoder** — a value someone read
42556
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
42557
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
42558
+ * louder. That is what this function is for.
42559
+ *
42560
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
42561
+ * and it cannot be answered from the number. It is answered by the comment the
42562
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
42563
+ * mandatory.
42564
+ *
42565
+ * ## Why a function and not a typed-in number
42566
+ *
42567
+ * `-55 + 12.04` written into a source file is, six months later, completely
42568
+ * indistinguishable from a threshold somebody simply preferred. Calling this
42569
+ * keeps the derivation, the law, and the original measurement all visible at
42570
+ * the call site, so a future reader can disagree with the *premise* instead of
42571
+ * having to reverse-engineer the sum.
42572
+ *
42573
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
42574
+ * it is declared. It must never be applied to a live sample or a stored
42575
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
42576
+ * adjusting numbers the decoder already got right is the original defect with
42577
+ * an extra place to argue with (D459).
42578
+ */
42579
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
42580
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
42581
+ }
42582
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42341
42583
  /** Schema defaults — an untouched sub-field must author exactly these. */
42342
42584
  var NC_AUDIO_DEFAULTS = {
42343
42585
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-terminal",
3
- "version": "0.1.100",
3
+ "version": "0.1.102",
4
4
  "description": "Interactive terminal sessions (pty + xterm) as a CamStack addon",
5
5
  "keywords": [
6
6
  "camstack",