@camstack/addon-agent-ui 1.2.100 → 1.2.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.
Files changed (2) hide show
  1. package/dist/addon.js +248 -6
  2. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -5346,6 +5346,86 @@ var ZodIssueCode = {
5346
5346
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5347
5347
  var ZodFirstPartyTypeKind;
5348
5348
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5349
+ //#endregion
5350
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5351
+ /**
5352
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5353
+ * window to float samples (D455).
5354
+ *
5355
+ * ## Why a format at all
5356
+ *
5357
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5358
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5359
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5360
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5361
+ * the plane carried four times the source. The plane crosses hub-main twice on
5362
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5363
+ *
5364
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5365
+ * them where it needs them. That is the same argument D450 made for the rate,
5366
+ * one step further along the same wire.
5367
+ *
5368
+ * ## Why the expansion lives here
5369
+ *
5370
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5371
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5372
+ * `AudioChunkPlane` expands per subscription) and
5373
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5374
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5375
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5376
+ * into their own dist (`self-contained` externals), so this travels with a
5377
+ * `camstack deploy` and needs no published server.
5378
+ *
5379
+ * A second μ-law table anywhere else is the defect this module exists to
5380
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5381
+ * direction for the WebRTC egress — a different transform, not a copy.)
5382
+ *
5383
+ * ## Absent means f32le
5384
+ *
5385
+ * `format` is optional on the wire and its absence means `f32le` — today's
5386
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5387
+ * has always been served, because the broker only emits a coded window to a
5388
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5389
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5390
+ * deployable one addon at a time across three nodes.
5391
+ */
5392
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5393
+ var AUDIO_CHUNK_FORMATS = [
5394
+ "f32le",
5395
+ "pcmu",
5396
+ "pcma"
5397
+ ];
5398
+ /**
5399
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5400
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5401
+ *
5402
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5403
+ * it buffers the coded bytes and the plane's consumers expand.
5404
+ */
5405
+ function buildUlawTable() {
5406
+ const table = new Float32Array(256);
5407
+ for (let i = 0; i < 256; i++) {
5408
+ const complemented = ~i & 255;
5409
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5410
+ const exponent = complemented >> 4 & 7;
5411
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5412
+ }
5413
+ return table;
5414
+ }
5415
+ /** Build the A-law decode table (ITU-T G.711). */
5416
+ function buildAlawTable() {
5417
+ const table = new Float32Array(256);
5418
+ for (let i = 0; i < 256; i++) {
5419
+ const xored = i ^ 85;
5420
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5421
+ const exponent = xored >> 4 & 7;
5422
+ const mantissa = xored & 15;
5423
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5424
+ }
5425
+ return table;
5426
+ }
5427
+ buildUlawTable();
5428
+ buildAlawTable();
5349
5429
  Object.fromEntries([
5350
5430
  {
5351
5431
  id: "overview",
@@ -6638,11 +6718,20 @@ var SubscribeFramesResultSchema = object({
6638
6718
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6639
6719
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6640
6720
  */
6721
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6641
6722
  var DecodedAudioChunkSchema = object({
6642
6723
  data: _instanceof(Uint8Array),
6643
6724
  sampleRate: number().int().positive(),
6644
6725
  channels: number().int().positive(),
6645
- timestamp: number()
6726
+ timestamp: number(),
6727
+ /**
6728
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6729
+ * byte, for any peer that never heard of this field. A coded window
6730
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6731
+ * subscription that DECLARED it accepts one, so absence can never mean
6732
+ * "coded bytes a consumer will read as floats" (D455).
6733
+ */
6734
+ format: AudioChunkFormatSchema.optional()
6646
6735
  });
6647
6736
  /**
6648
6737
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6654,7 +6743,18 @@ var DecodedAudioChunkSchema = object({
6654
6743
  var SubscribeAudioChunksInputSchema = object({
6655
6744
  brokerId: string(),
6656
6745
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6657
- tag: string().optional()
6746
+ tag: string().optional(),
6747
+ /**
6748
+ * Byte formats this subscriber can READ, best first. The broker serves the
6749
+ * chunk's own format when it is in this list and expands to `f32le`
6750
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6751
+ *
6752
+ * Absent (or without the source format) means `f32le` — the behaviour every
6753
+ * subscriber had before D455, unchanged. This is the negotiation half of
6754
+ * the source-bytes lever: it is what lets the broker and its consumers
6755
+ * deploy one at a time across three nodes.
6756
+ */
6757
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6658
6758
  });
6659
6759
  /** Result of `stream-broker.subscribeAudioChunks`. */
6660
6760
  var SubscribeAudioChunksResultSchema = object({
@@ -10644,6 +10744,51 @@ var AudioAnalysisSettingsSchema = object({
10644
10744
  minConfidence: number().min(0).max(1).default(.3),
10645
10745
  allowedClasses: array(string()).default([])
10646
10746
  });
10747
+ /**
10748
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10749
+ *
10750
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10751
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10752
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10753
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10754
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10755
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10756
+ * way to the one expansion that feeds the model.
10757
+ *
10758
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10759
+ * window, the per-device node assignment, the settings read) and therefore
10760
+ * still owns the attach/detach pair. It no longer owns the bytes.
10761
+ */
10762
+ var AudioAttachDeviceInputSchema = object({
10763
+ deviceId: number(),
10764
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10765
+ brokerId: string(),
10766
+ /**
10767
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10768
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10769
+ * the orchestrator's poller pinned them before the move.
10770
+ */
10771
+ ingestNodeId: string(),
10772
+ /**
10773
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10774
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10775
+ * window: a settings change re-attaches, which is what always happened.
10776
+ */
10777
+ settings: AudioAnalysisSettingsSchema
10778
+ });
10779
+ var AudioAttachDeviceResultSchema = object({
10780
+ /** False only when the analyzer is shutting down and refused to attach. */
10781
+ attached: boolean(),
10782
+ /**
10783
+ * True when the attachment replaced a live one for the same device. An
10784
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10785
+ * double the broker's fanout and neither would know about the other.
10786
+ */
10787
+ replaced: boolean()
10788
+ });
10789
+ var AudioDetachDeviceResultSchema = object({
10790
+ /** False when no attachment existed — detach is idempotent. */
10791
+ detached: boolean() });
10647
10792
  var AudioClassificationResultSchema = object({
10648
10793
  labels: array(AudioClassificationLabelSchema).readonly(),
10649
10794
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10652,7 +10797,7 @@ var AudioClassificationResultSchema = object({
10652
10797
  method(object({
10653
10798
  chunk: AudioChunkInputSchema,
10654
10799
  settings: AudioAnalysisSettingsSchema
10655
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10800
+ }), 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() }), {
10656
10801
  kind: "mutation",
10657
10802
  auth: "admin"
10658
10803
  });
@@ -20188,6 +20333,14 @@ var NativeCropResultSchema = object({
20188
20333
  * set `encodeJpeg: true`; `bytes` is then absent.
20189
20334
  */
20190
20335
  jpeg: string().optional(),
20336
+ /**
20337
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20338
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20339
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20340
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20341
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20342
+ */
20343
+ jpegBytes: _instanceof(Uint8Array).optional(),
20191
20344
  width: number().int().positive(),
20192
20345
  height: number().int().positive(),
20193
20346
  /**
@@ -20254,7 +20407,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20254
20407
  })]);
20255
20408
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20256
20409
  var ParkedTrackFrameSchema = object({
20257
- jpeg: string(),
20410
+ /**
20411
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20412
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20413
+ * Exactly one of the two is present.
20414
+ */
20415
+ jpeg: string().optional(),
20416
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20417
+ jpegBytes: _instanceof(Uint8Array).optional(),
20258
20418
  width: number().int().positive(),
20259
20419
  height: number().int().positive(),
20260
20420
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -20841,6 +21001,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
20841
21001
  bbox: NativeCropBboxSchema,
20842
21002
  maxWidth: number().int().positive().optional(),
20843
21003
  /**
21004
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21005
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21006
+ * wire — never assume consent: a pre-D462 caller parses the field as
21007
+ * base64 and bytes would decode to garbage rather than fail.
21008
+ */
21009
+ acceptJpegBytes: boolean().optional(),
21010
+ /**
20844
21011
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
20845
21012
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
20846
21013
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -20908,7 +21075,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
20908
21075
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
20909
21076
  deviceId: number(),
20910
21077
  trackId: string(),
20911
- kind: ParkedFrameKindSchema
21078
+ kind: ParkedFrameKindSchema,
21079
+ /**
21080
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21081
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21082
+ * wire — never assume consent: a pre-D462 caller parses the field as
21083
+ * base64 and bytes would decode to garbage rather than fail.
21084
+ */
21085
+ acceptJpegBytes: boolean().optional()
20912
21086
  }), ParkedTrackFrameSchema.nullable()), method(object({
20913
21087
  deviceId: number(),
20914
21088
  trackId: string()
@@ -30547,12 +30721,24 @@ Object.freeze({
30547
30721
  addonId: null,
30548
30722
  access: "create"
30549
30723
  },
30724
+ "audioAnalyzer.attachDevice": {
30725
+ capName: "audio-analyzer",
30726
+ capScope: "system",
30727
+ addonId: null,
30728
+ access: "create"
30729
+ },
30550
30730
  "audioAnalyzer.classify": {
30551
30731
  capName: "audio-analyzer",
30552
30732
  capScope: "system",
30553
30733
  addonId: null,
30554
30734
  access: "view"
30555
30735
  },
30736
+ "audioAnalyzer.detachDevice": {
30737
+ capName: "audio-analyzer",
30738
+ capScope: "system",
30739
+ addonId: null,
30740
+ access: "create"
30741
+ },
30556
30742
  "audioAnalyzer.dispose": {
30557
30743
  capName: "audio-analyzer",
30558
30744
  capScope: "system",
@@ -36396,11 +36582,21 @@ Object.freeze({
36396
36582
  form: "single",
36397
36583
  optional: false
36398
36584
  }],
36585
+ "audioAnalyzer.attachDevice": [{
36586
+ name: "deviceId",
36587
+ form: "single",
36588
+ optional: false
36589
+ }],
36399
36590
  "audioAnalyzer.classify": [{
36400
36591
  name: "deviceId",
36401
36592
  form: "single",
36402
36593
  optional: true
36403
36594
  }],
36595
+ "audioAnalyzer.detachDevice": [{
36596
+ name: "deviceId",
36597
+ form: "single",
36598
+ optional: false
36599
+ }],
36404
36600
  "audioMetrics.getCurrentSnapshot": [{
36405
36601
  name: "deviceId",
36406
36602
  form: "single",
@@ -38252,6 +38448,52 @@ Object.freeze({
38252
38448
  "network-access": "ingress",
38253
38449
  "smtp-provider": "email"
38254
38450
  });
38451
+ var G711_SCALE_CORRECTION_DB = {
38452
+ PCMU: 20 * Math.log10(4),
38453
+ PCMA: 20 * Math.log10(8)
38454
+ };
38455
+ /**
38456
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
38457
+ * same intent on the ITU-T scale (D460).
38458
+ *
38459
+ * ## When this applies, and when it is the wrong thing to reach for
38460
+ *
38461
+ * An absolute-dBFS number in this repo is one of two things, and only one of
38462
+ * them converts:
38463
+ *
38464
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
38465
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
38466
+ * after. The defect was never in the number; it was that 19 of this hub's
38467
+ * 25 cameras did not obey it. Converting such a number takes something
38468
+ * correct and makes it wrong, in order to preserve a bug.
38469
+ * - **A measurement taken through the old decoder** — a value someone read
38470
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
38471
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
38472
+ * louder. That is what this function is for.
38473
+ *
38474
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
38475
+ * and it cannot be answered from the number. It is answered by the comment the
38476
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
38477
+ * mandatory.
38478
+ *
38479
+ * ## Why a function and not a typed-in number
38480
+ *
38481
+ * `-55 + 12.04` written into a source file is, six months later, completely
38482
+ * indistinguishable from a threshold somebody simply preferred. Calling this
38483
+ * keeps the derivation, the law, and the original measurement all visible at
38484
+ * the call site, so a future reader can disagree with the *premise* instead of
38485
+ * having to reverse-engineer the sum.
38486
+ *
38487
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
38488
+ * it is declared. It must never be applied to a live sample or a stored
38489
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
38490
+ * adjusting numbers the decoder already got right is the original defect with
38491
+ * an extra place to argue with (D459).
38492
+ */
38493
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
38494
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
38495
+ }
38496
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
38255
38497
  /** Schema defaults — an untouched sub-field must author exactly these. */
38256
38498
  var NC_AUDIO_DEFAULTS = {
38257
38499
  hitPercent: 60,
@@ -38755,7 +38997,7 @@ var AgentUIAddon = class extends BaseAddon {
38755
38997
  capability: adminUiCapability,
38756
38998
  provider: {
38757
38999
  getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
38758
- getVersion: async () => ({ version: "1.2.100" })
39000
+ getVersion: async () => ({ version: "1.2.102" })
38759
39001
  }
38760
39002
  }];
38761
39003
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-agent-ui",
3
- "version": "1.2.100",
3
+ "version": "1.2.102",
4
4
  "description": "Agent UI — lightweight status dashboard served by every agent node",
5
5
  "keywords": [
6
6
  "camstack",