camstack 1.2.138 → 1.2.139

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.
@@ -23633,9 +23633,9 @@ var require_zod = __commonJS({
23633
23633
  }
23634
23634
  });
23635
23635
 
23636
- // ../system/dist/dist-B17W9ngu.js
23637
- var require_dist_B17W9ngu = __commonJS({
23638
- "../system/dist/dist-B17W9ngu.js"(exports) {
23636
+ // ../system/dist/dist-CllKpcTd.js
23637
+ var require_dist_CllKpcTd = __commonJS({
23638
+ "../system/dist/dist-CllKpcTd.js"(exports) {
23639
23639
  "use strict";
23640
23640
  var zod = require_zod();
23641
23641
  var EventCategory = /* @__PURE__ */ (function(EventCategory2) {
@@ -23793,6 +23793,34 @@ var require_dist_B17W9ngu = __commonJS({
23793
23793
  EventCategory2["ModelConvertProgress"] = "model-convert.progress";
23794
23794
  return EventCategory2;
23795
23795
  })({});
23796
+ var AUDIO_CHUNK_FORMATS = [
23797
+ "f32le",
23798
+ "pcmu",
23799
+ "pcma"
23800
+ ];
23801
+ function buildUlawTable() {
23802
+ const table2 = new Float32Array(256);
23803
+ for (let i = 0; i < 256; i++) {
23804
+ const complemented = ~i & 255;
23805
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
23806
+ const exponent = complemented >> 4 & 7;
23807
+ table2[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
23808
+ }
23809
+ return table2;
23810
+ }
23811
+ function buildAlawTable() {
23812
+ const table2 = new Float32Array(256);
23813
+ for (let i = 0; i < 256; i++) {
23814
+ const xored = i ^ 85;
23815
+ const sign = (xored & 128) !== 0 ? 1 : -1;
23816
+ const exponent = xored >> 4 & 7;
23817
+ const mantissa = xored & 15;
23818
+ table2[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
23819
+ }
23820
+ return table2;
23821
+ }
23822
+ buildUlawTable();
23823
+ buildAlawTable();
23796
23824
  var WELL_KNOWN_TAB_MAP = Object.fromEntries([
23797
23825
  {
23798
23826
  id: "overview",
@@ -24867,16 +24895,36 @@ var require_dist_B17W9ngu = __commonJS({
24867
24895
  /** Reader-side cadence hint (frames/s) — echoes `SubscribeFramesInput.maxFps`. */
24868
24896
  maxFps: zod.z.number().nonnegative()
24869
24897
  });
24898
+ var AudioChunkFormatSchema = zod.z.enum(AUDIO_CHUNK_FORMATS);
24870
24899
  var DecodedAudioChunkSchema = zod.z.object({
24871
24900
  data: zod.z.instanceof(Uint8Array),
24872
24901
  sampleRate: zod.z.number().int().positive(),
24873
24902
  channels: zod.z.number().int().positive(),
24874
- timestamp: zod.z.number()
24903
+ timestamp: zod.z.number(),
24904
+ /**
24905
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
24906
+ * byte, for any peer that never heard of this field. A coded window
24907
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
24908
+ * subscription that DECLARED it accepts one, so absence can never mean
24909
+ * "coded bytes a consumer will read as floats" (D455).
24910
+ */
24911
+ format: AudioChunkFormatSchema.optional()
24875
24912
  });
24876
24913
  var SubscribeAudioChunksInputSchema = zod.z.object({
24877
24914
  brokerId: zod.z.string(),
24878
24915
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
24879
- tag: zod.z.string().optional()
24916
+ tag: zod.z.string().optional(),
24917
+ /**
24918
+ * Byte formats this subscriber can READ, best first. The broker serves the
24919
+ * chunk's own format when it is in this list and expands to `f32le`
24920
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
24921
+ *
24922
+ * Absent (or without the source format) means `f32le` — the behaviour every
24923
+ * subscriber had before D455, unchanged. This is the negotiation half of
24924
+ * the source-bytes lever: it is what lets the broker and its consumers
24925
+ * deploy one at a time across three nodes.
24926
+ */
24927
+ accept: zod.z.array(AudioChunkFormatSchema).readonly().optional()
24880
24928
  });
24881
24929
  var SubscribeAudioChunksResultSchema = zod.z.object({
24882
24930
  /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
@@ -28572,6 +28620,37 @@ var require_dist_B17W9ngu = __commonJS({
28572
28620
  minConfidence: zod.z.number().min(0).max(1).default(0.3),
28573
28621
  allowedClasses: zod.z.array(zod.z.string()).default([])
28574
28622
  });
28623
+ var AudioAttachDeviceInputSchema = zod.z.object({
28624
+ deviceId: zod.z.number(),
28625
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
28626
+ brokerId: zod.z.string(),
28627
+ /**
28628
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
28629
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
28630
+ * the orchestrator's poller pinned them before the move.
28631
+ */
28632
+ ingestNodeId: zod.z.string(),
28633
+ /**
28634
+ * Resolved once by the orchestrator at attach time, exactly as it was read
28635
+ * once per subscription before D461. The analyzer does NOT re-resolve per
28636
+ * window: a settings change re-attaches, which is what always happened.
28637
+ */
28638
+ settings: AudioAnalysisSettingsSchema
28639
+ });
28640
+ var AudioAttachDeviceResultSchema = zod.z.object({
28641
+ /** False only when the analyzer is shutting down and refused to attach. */
28642
+ attached: zod.z.boolean(),
28643
+ /**
28644
+ * True when the attachment replaced a live one for the same device. An
28645
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
28646
+ * double the broker's fanout and neither would know about the other.
28647
+ */
28648
+ replaced: zod.z.boolean()
28649
+ });
28650
+ var AudioDetachDeviceResultSchema = zod.z.object({
28651
+ /** False when no attachment existed — detach is idempotent. */
28652
+ detached: zod.z.boolean()
28653
+ });
28575
28654
  var AudioClassificationResultSchema = zod.z.object({
28576
28655
  labels: zod.z.array(AudioClassificationLabelSchema).readonly(),
28577
28656
  rawLabels: zod.z.array(AudioClassificationLabelSchema).readonly().optional(),
@@ -28587,6 +28666,21 @@ var require_dist_B17W9ngu = __commonJS({
28587
28666
  settings: AudioAnalysisSettingsSchema
28588
28667
  }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }),
28589
28668
  classify: method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }),
28669
+ /**
28670
+ * Start pulling this camera's audio from the broker, in THIS process.
28671
+ * Returns as soon as the attachment exists — the first
28672
+ * `subscribeAudioChunks` retries with backoff behind it, because the
28673
+ * broker for a camStream may not be registered yet (that tolerance moved
28674
+ * with the poller, D461). Replaces any live attachment for the device.
28675
+ */
28676
+ attachDevice: method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }),
28677
+ /**
28678
+ * Stop pulling this camera's audio and release the broker subscription.
28679
+ * Idempotent. A detach that never arrives is the one failure mode this
28680
+ * split adds, which is why `AudioChunkPlane` reaps a subscription nobody
28681
+ * drains rather than trusting it (D461).
28682
+ */
28683
+ detachDevice: method(zod.z.object({ deviceId: zod.z.number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }),
28590
28684
  isReady: method(zod.z.void(), zod.z.boolean()),
28591
28685
  dispose: method(zod.z.void(), zod.z.void(), { kind: "mutation" }),
28592
28686
  /**
@@ -52384,12 +52478,24 @@ var require_dist_B17W9ngu = __commonJS({
52384
52478
  addonId: null,
52385
52479
  access: "create"
52386
52480
  },
52481
+ "audioAnalyzer.attachDevice": {
52482
+ capName: "audio-analyzer",
52483
+ capScope: "system",
52484
+ addonId: null,
52485
+ access: "create"
52486
+ },
52387
52487
  "audioAnalyzer.classify": {
52388
52488
  capName: "audio-analyzer",
52389
52489
  capScope: "system",
52390
52490
  addonId: null,
52391
52491
  access: "view"
52392
52492
  },
52493
+ "audioAnalyzer.detachDevice": {
52494
+ capName: "audio-analyzer",
52495
+ capScope: "system",
52496
+ addonId: null,
52497
+ access: "create"
52498
+ },
52393
52499
  "audioAnalyzer.dispose": {
52394
52500
  capName: "audio-analyzer",
52395
52501
  capScope: "system",
@@ -58233,11 +58339,21 @@ var require_dist_B17W9ngu = __commonJS({
58233
58339
  form: "single",
58234
58340
  optional: false
58235
58341
  }],
58342
+ "audioAnalyzer.attachDevice": [{
58343
+ name: "deviceId",
58344
+ form: "single",
58345
+ optional: false
58346
+ }],
58236
58347
  "audioAnalyzer.classify": [{
58237
58348
  name: "deviceId",
58238
58349
  form: "single",
58239
58350
  optional: true
58240
58351
  }],
58352
+ "audioAnalyzer.detachDevice": [{
58353
+ name: "deviceId",
58354
+ form: "single",
58355
+ optional: false
58356
+ }],
58241
58357
  "audioMetrics.getCurrentSnapshot": [{
58242
58358
  name: "deviceId",
58243
58359
  form: "single",
@@ -60366,6 +60482,14 @@ var require_dist_B17W9ngu = __commonJS({
60366
60482
  durability: "session",
60367
60483
  volatileFields: []
60368
60484
  };
60485
+ var G711_SCALE_CORRECTION_DB = {
60486
+ PCMU: 20 * Math.log10(4),
60487
+ PCMA: 20 * Math.log10(8)
60488
+ };
60489
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
60490
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
60491
+ }
60492
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
60369
60493
  var NC_AUDIO_DEFAULTS = {
60370
60494
  hitPercent: 60,
60371
60495
  samplingSeconds: 10
@@ -61586,7 +61710,7 @@ var require_alerts_addon = __commonJS({
61586
61710
  [Symbol.toStringTag]: { value: "Module" }
61587
61711
  });
61588
61712
  require_chunk_Cek0wNdY();
61589
- var require_dist10 = require_dist_B17W9ngu();
61713
+ var require_dist10 = require_dist_CllKpcTd();
61590
61714
  function selectExpired(alerts, cutoffMs) {
61591
61715
  return alerts.filter((a) => a.createdAt < cutoffMs).sort((a, b) => a.createdAt - b.createdAt).map((a) => a.id);
61592
61716
  }
@@ -62405,7 +62529,7 @@ var require_console_logging = __commonJS({
62405
62529
  [Symbol.toStringTag]: { value: "Module" }
62406
62530
  });
62407
62531
  require_chunk_Cek0wNdY();
62408
- var require_dist10 = require_dist_B17W9ngu();
62532
+ var require_dist10 = require_dist_CllKpcTd();
62409
62533
  var require_formatter = require_formatter_DqAKDlvN();
62410
62534
  var LEVEL_RANK = {
62411
62535
  debug: 0,
@@ -62499,7 +62623,7 @@ var require_core_blocks_addon = __commonJS({
62499
62623
  "use strict";
62500
62624
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
62501
62625
  var require_chunk = require_chunk_Cek0wNdY();
62502
- var require_dist10 = require_dist_B17W9ngu();
62626
+ var require_dist10 = require_dist_CllKpcTd();
62503
62627
  var node_crypto = __require("crypto");
62504
62628
  var node_fs_promises = __require("fs/promises");
62505
62629
  node_fs_promises = require_chunk.__toESM(node_fs_promises);
@@ -63396,11 +63520,11 @@ var require_core_blocks = __commonJS({
63396
63520
  }
63397
63521
  });
63398
63522
 
63399
- // ../system/dist/retired-settings-keys-CjvB7Etx.js
63400
- var require_retired_settings_keys_CjvB7Etx = __commonJS({
63401
- "../system/dist/retired-settings-keys-CjvB7Etx.js"(exports) {
63523
+ // ../system/dist/retired-settings-keys-7iEsSzmD.js
63524
+ var require_retired_settings_keys_7iEsSzmD = __commonJS({
63525
+ "../system/dist/retired-settings-keys-7iEsSzmD.js"(exports) {
63402
63526
  "use strict";
63403
- var require_dist10 = require_dist_B17W9ngu();
63527
+ var require_dist10 = require_dist_CllKpcTd();
63404
63528
  function settingsStoreIsAuthoritativeHere(env) {
63405
63529
  const raw = (env["CAMSTACK_ROLE"] ?? "").trim().toLowerCase();
63406
63530
  return raw === "" || raw === "hub";
@@ -65635,8 +65759,8 @@ var require_device_manager_addon = __commonJS({
65635
65759
  [Symbol.toStringTag]: { value: "Module" }
65636
65760
  });
65637
65761
  require_chunk_Cek0wNdY();
65638
- var require_dist10 = require_dist_B17W9ngu();
65639
- var require_retired_settings_keys = require_retired_settings_keys_CjvB7Etx();
65762
+ var require_dist10 = require_dist_CllKpcTd();
65763
+ var require_retired_settings_keys = require_retired_settings_keys_7iEsSzmD();
65640
65764
  var node_crypto = __require("crypto");
65641
65765
  var _camstack_types_node = require_node();
65642
65766
  var JOB_HISTORY = 20;
@@ -71261,7 +71385,7 @@ var require_hub_forwarder = __commonJS({
71261
71385
  [Symbol.toStringTag]: { value: "Module" }
71262
71386
  });
71263
71387
  require_chunk_Cek0wNdY();
71264
- var require_dist10 = require_dist_B17W9ngu();
71388
+ var require_dist10 = require_dist_CllKpcTd();
71265
71389
  var require_formatter = require_formatter_DqAKDlvN();
71266
71390
  var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
71267
71391
  var HubForwarderDestination = class {
@@ -71398,7 +71522,7 @@ var require_liveness_monitor_addon = __commonJS({
71398
71522
  "use strict";
71399
71523
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
71400
71524
  require_chunk_Cek0wNdY();
71401
- var require_dist10 = require_dist_B17W9ngu();
71525
+ var require_dist10 = require_dist_CllKpcTd();
71402
71526
  var NO_DEVICES = "liveness:no-devices";
71403
71527
  var ALL_OFFLINE = "liveness:all-devices-offline";
71404
71528
  var NO_FOOTAGE_PREFIX = "liveness:no-footage:";
@@ -71594,7 +71718,7 @@ var require_local_auth_addon = __commonJS({
71594
71718
  [Symbol.toStringTag]: { value: "Module" }
71595
71719
  });
71596
71720
  var require_chunk = require_chunk_Cek0wNdY();
71597
- var require_dist10 = require_dist_B17W9ngu();
71721
+ var require_dist10 = require_dist_CllKpcTd();
71598
71722
  var node_crypto = __require("crypto");
71599
71723
  node_crypto = require_chunk.__toESM(node_crypto);
71600
71724
  var crypto$1 = __require("crypto");
@@ -79407,7 +79531,7 @@ var require_loki_logging = __commonJS({
79407
79531
  [Symbol.toStringTag]: { value: "Module" }
79408
79532
  });
79409
79533
  require_chunk_Cek0wNdY();
79410
- var require_dist10 = require_dist_B17W9ngu();
79534
+ var require_dist10 = require_dist_CllKpcTd();
79411
79535
  function sanitizeLabelName(raw) {
79412
79536
  const replaced = raw.replaceAll(/[^a-zA-Z0-9_]/g, "_");
79413
79537
  return /^[a-zA-Z_]/.test(replaced) ? replaced : `_${replaced}`;
@@ -79994,7 +80118,7 @@ var require_native_metrics_addon = __commonJS({
79994
80118
  [Symbol.toStringTag]: { value: "Module" }
79995
80119
  });
79996
80120
  var require_chunk = require_chunk_Cek0wNdY();
79997
- var require_dist10 = require_dist_B17W9ngu();
80121
+ var require_dist10 = require_dist_CllKpcTd();
79998
80122
  var node_fs_promises = __require("fs/promises");
79999
80123
  var node_fs = __require("fs");
80000
80124
  node_fs = require_chunk.__toESM(node_fs);
@@ -82747,7 +82871,7 @@ var require_filesystem_storage_addon = __commonJS({
82747
82871
  [Symbol.toStringTag]: { value: "Module" }
82748
82872
  });
82749
82873
  var require_chunk = require_chunk_Cek0wNdY();
82750
- var require_dist10 = require_dist_B17W9ngu();
82874
+ var require_dist10 = require_dist_CllKpcTd();
82751
82875
  var node_crypto = __require("crypto");
82752
82876
  var node_fs_promises = __require("fs/promises");
82753
82877
  var node_path = __require("path");
@@ -83974,8 +84098,8 @@ var require_sqlite_settings_addon = __commonJS({
83974
84098
  [Symbol.toStringTag]: { value: "Module" }
83975
84099
  });
83976
84100
  var require_chunk = require_chunk_Cek0wNdY();
83977
- var require_dist10 = require_dist_B17W9ngu();
83978
- var require_retired_settings_keys = require_retired_settings_keys_CjvB7Etx();
84101
+ var require_dist10 = require_dist_CllKpcTd();
84102
+ var require_retired_settings_keys = require_retired_settings_keys_7iEsSzmD();
83979
84103
  var require_wal_checkpoint_policy = require_wal_checkpoint_policy_CCJZngds();
83980
84104
  var node_crypto = __require("crypto");
83981
84105
  var node_path = __require("path");
@@ -86642,7 +86766,7 @@ var require_storage_orchestrator_addon = __commonJS({
86642
86766
  [Symbol.toStringTag]: { value: "Module" }
86643
86767
  });
86644
86768
  var require_chunk = require_chunk_Cek0wNdY();
86645
- var require_dist10 = require_dist_B17W9ngu();
86769
+ var require_dist10 = require_dist_CllKpcTd();
86646
86770
  var require_hub_cap_forward = require_hub_cap_forward_DmHNjbB0();
86647
86771
  var zod = require_zod();
86648
86772
  var node_crypto = __require("crypto");
@@ -90292,7 +90416,7 @@ var require_system_config_addon = __commonJS({
90292
90416
  [Symbol.toStringTag]: { value: "Module" }
90293
90417
  });
90294
90418
  require_chunk_Cek0wNdY();
90295
- var require_dist10 = require_dist_B17W9ngu();
90419
+ var require_dist10 = require_dist_CllKpcTd();
90296
90420
  var SECTION_TITLES = {
90297
90421
  server: "Server",
90298
90422
  auth: "Authentication"
@@ -108353,7 +108477,7 @@ var require_winston_logging = __commonJS({
108353
108477
  [Symbol.toStringTag]: { value: "Module" }
108354
108478
  });
108355
108479
  var require_chunk = require_chunk_Cek0wNdY();
108356
- var require_dist10 = require_dist_B17W9ngu();
108480
+ var require_dist10 = require_dist_CllKpcTd();
108357
108481
  var require_formatter = require_formatter_DqAKDlvN();
108358
108482
  var node_path = __require("path");
108359
108483
  node_path = require_chunk.__toESM(node_path);
@@ -110390,12 +110514,57 @@ var require_event_category_BNJ9EE5B = __commonJS({
110390
110514
  }
110391
110515
  });
110392
110516
 
110393
- // ../types/dist/sleep-CTHjJilA.js
110394
- var require_sleep_CTHjJilA = __commonJS({
110395
- "../types/dist/sleep-CTHjJilA.js"(exports) {
110517
+ // ../types/dist/sleep-B1ZwxAhh.js
110518
+ var require_sleep_B1ZwxAhh = __commonJS({
110519
+ "../types/dist/sleep-B1ZwxAhh.js"(exports) {
110396
110520
  "use strict";
110397
110521
  var require_event_category = require_event_category_BNJ9EE5B();
110398
110522
  var zod = require_zod();
110523
+ var AUDIO_CHUNK_FORMATS = [
110524
+ "f32le",
110525
+ "pcmu",
110526
+ "pcma"
110527
+ ];
110528
+ function isAudioChunkFormat(value) {
110529
+ return typeof value === "string" && AUDIO_CHUNK_FORMATS.includes(value);
110530
+ }
110531
+ function audioChunkBytesPerSample(format2) {
110532
+ return format2 === "f32le" ? 4 : 1;
110533
+ }
110534
+ function expandAudioChunkToF32le(data, format2) {
110535
+ if (format2 === "f32le") {
110536
+ const copy2 = new Uint8Array(data.byteLength);
110537
+ copy2.set(data);
110538
+ return copy2;
110539
+ }
110540
+ const table = format2 === "pcmu" ? ULAW_TABLE : ALAW_TABLE;
110541
+ const out = new Float32Array(data.length);
110542
+ for (let i = 0; i < data.length; i++) out[i] = table[data[i]];
110543
+ return new Uint8Array(out.buffer);
110544
+ }
110545
+ function buildUlawTable() {
110546
+ const table = new Float32Array(256);
110547
+ for (let i = 0; i < 256; i++) {
110548
+ const complemented = ~i & 255;
110549
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
110550
+ const exponent = complemented >> 4 & 7;
110551
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
110552
+ }
110553
+ return table;
110554
+ }
110555
+ function buildAlawTable() {
110556
+ const table = new Float32Array(256);
110557
+ for (let i = 0; i < 256; i++) {
110558
+ const xored = i ^ 85;
110559
+ const sign = (xored & 128) !== 0 ? 1 : -1;
110560
+ const exponent = xored >> 4 & 7;
110561
+ const mantissa = xored & 15;
110562
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
110563
+ }
110564
+ return table;
110565
+ }
110566
+ var ULAW_TABLE = buildUlawTable();
110567
+ var ALAW_TABLE = buildAlawTable();
110399
110568
  var WELL_KNOWN_TABS = [
110400
110569
  {
110401
110570
  id: "overview",
@@ -111617,16 +111786,36 @@ var require_sleep_CTHjJilA = __commonJS({
111617
111786
  /** Reader-side cadence hint (frames/s) — echoes `SubscribeFramesInput.maxFps`. */
111618
111787
  maxFps: zod.z.number().nonnegative()
111619
111788
  });
111789
+ var AudioChunkFormatSchema = zod.z.enum(AUDIO_CHUNK_FORMATS);
111620
111790
  var DecodedAudioChunkSchema = zod.z.object({
111621
111791
  data: zod.z.instanceof(Uint8Array),
111622
111792
  sampleRate: zod.z.number().int().positive(),
111623
111793
  channels: zod.z.number().int().positive(),
111624
- timestamp: zod.z.number()
111794
+ timestamp: zod.z.number(),
111795
+ /**
111796
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
111797
+ * byte, for any peer that never heard of this field. A coded window
111798
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
111799
+ * subscription that DECLARED it accepts one, so absence can never mean
111800
+ * "coded bytes a consumer will read as floats" (D455).
111801
+ */
111802
+ format: AudioChunkFormatSchema.optional()
111625
111803
  });
111626
111804
  var SubscribeAudioChunksInputSchema = zod.z.object({
111627
111805
  brokerId: zod.z.string(),
111628
111806
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
111629
- tag: zod.z.string().optional()
111807
+ tag: zod.z.string().optional(),
111808
+ /**
111809
+ * Byte formats this subscriber can READ, best first. The broker serves the
111810
+ * chunk's own format when it is in this list and expands to `f32le`
111811
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
111812
+ *
111813
+ * Absent (or without the source format) means `f32le` — the behaviour every
111814
+ * subscriber had before D455, unchanged. This is the negotiation half of
111815
+ * the source-bytes lever: it is what lets the broker and its consumers
111816
+ * deploy one at a time across three nodes.
111817
+ */
111818
+ accept: zod.z.array(AudioChunkFormatSchema).readonly().optional()
111630
111819
  });
111631
111820
  var SubscribeAudioChunksResultSchema = zod.z.object({
111632
111821
  /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
@@ -113307,6 +113496,7 @@ var require_sleep_CTHjJilA = __commonJS({
113307
113496
  getDeviceSettings: (input) => dispatchSystem("addonSettings", "getDeviceSettings", "query", input),
113308
113497
  updateDeviceSettings: (input) => dispatchSystem("addonSettings", "updateDeviceSettings", "mutation", input)
113309
113498
  },
113499
+ audioAnalyzer: { detachDevice: (input) => dispatchSystem("audioAnalyzer", "detachDevice", "mutation", input) },
113310
113500
  cameraPipelineConfig: {
113311
113501
  getDeviceSettingsContribution: (input) => dispatchSystem("cameraPipelineConfig", "getDeviceSettingsContribution", "query", input),
113312
113502
  getDeviceLiveContribution: (input) => dispatchSystem("cameraPipelineConfig", "getDeviceLiveContribution", "query", input),
@@ -113610,6 +113800,18 @@ var require_sleep_CTHjJilA = __commonJS({
113610
113800
  signal.addEventListener("abort", onAbort, { once: true });
113611
113801
  });
113612
113802
  }
113803
+ Object.defineProperty(exports, "AUDIO_CHUNK_FORMATS", {
113804
+ enumerable: true,
113805
+ get: function() {
113806
+ return AUDIO_CHUNK_FORMATS;
113807
+ }
113808
+ });
113809
+ Object.defineProperty(exports, "AudioChunkFormatSchema", {
113810
+ enumerable: true,
113811
+ get: function() {
113812
+ return AudioChunkFormatSchema;
113813
+ }
113814
+ });
113613
113815
  Object.defineProperty(exports, "BOOT_RECOVERY_BACKOFF_MS", {
113614
113816
  enumerable: true,
113615
113817
  get: function() {
@@ -113892,6 +114094,12 @@ var require_sleep_CTHjJilA = __commonJS({
113892
114094
  return asString;
113893
114095
  }
113894
114096
  });
114097
+ Object.defineProperty(exports, "audioChunkBytesPerSample", {
114098
+ enumerable: true,
114099
+ get: function() {
114100
+ return audioChunkBytesPerSample;
114101
+ }
114102
+ });
113895
114103
  Object.defineProperty(exports, "collectHydratedFieldEntries", {
113896
114104
  enumerable: true,
113897
114105
  get: function() {
@@ -113970,6 +114178,12 @@ var require_sleep_CTHjJilA = __commonJS({
113970
114178
  return event;
113971
114179
  }
113972
114180
  });
114181
+ Object.defineProperty(exports, "expandAudioChunkToF32le", {
114182
+ enumerable: true,
114183
+ get: function() {
114184
+ return expandAudioChunkToF32le;
114185
+ }
114186
+ });
113973
114187
  Object.defineProperty(exports, "expandCapMethods", {
113974
114188
  enumerable: true,
113975
114189
  get: function() {
@@ -113982,6 +114196,12 @@ var require_sleep_CTHjJilA = __commonJS({
113982
114196
  return hydrateSchema;
113983
114197
  }
113984
114198
  });
114199
+ Object.defineProperty(exports, "isAudioChunkFormat", {
114200
+ enumerable: true,
114201
+ get: function() {
114202
+ return isAudioChunkFormat;
114203
+ }
114204
+ });
113985
114205
  Object.defineProperty(exports, "isDeviceConfigCap", {
113986
114206
  enumerable: true,
113987
114207
  get: function() {
@@ -114128,15 +114348,21 @@ var require_addon = __commonJS({
114128
114348
  "../types/dist/addon.js"(exports) {
114129
114349
  "use strict";
114130
114350
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
114351
+ var require_sleep = require_sleep_B1ZwxAhh();
114131
114352
  var require_event_category = require_event_category_BNJ9EE5B();
114132
- var require_sleep = require_sleep_CTHjJilA();
114133
114353
  var require_err_msg = require_err_msg_COpsHMw2();
114134
114354
  var CAP_INPUT_DEFAULTS = Object.freeze({
114135
114355
  "addons": { "getLogs": { "limit": 100 } },
114136
- "audio-analyzer": { "analyseChunk": { "settings": { "__nested__": {
114137
- "minConfidence": 0.3,
114138
- "allowedClasses": []
114139
- } } } },
114356
+ "audio-analyzer": {
114357
+ "analyseChunk": { "settings": { "__nested__": {
114358
+ "minConfidence": 0.3,
114359
+ "allowedClasses": []
114360
+ } } },
114361
+ "attachDevice": { "settings": { "__nested__": {
114362
+ "minConfidence": 0.3,
114363
+ "allowedClasses": []
114364
+ } } }
114365
+ },
114140
114366
  "audio-codec": {
114141
114367
  "pullEncoded": { "maxCount": 8 },
114142
114368
  "pullPcm": { "maxCount": 8 }
@@ -120987,9 +121213,9 @@ var require_dist2 = __commonJS({
120987
121213
  }
120988
121214
  });
120989
121215
 
120990
- // ../system/dist/manifest-system-deps-g_nK0xsF.js
120991
- var require_manifest_system_deps_g_nK0xsF = __commonJS({
120992
- "../system/dist/manifest-system-deps-g_nK0xsF.js"(exports) {
121216
+ // ../system/dist/manifest-system-deps-DfpwaXkh.js
121217
+ var require_manifest_system_deps_DfpwaXkh = __commonJS({
121218
+ "../system/dist/manifest-system-deps-DfpwaXkh.js"(exports) {
120993
121219
  "use strict";
120994
121220
  var require_chunk = require_chunk_Cek0wNdY();
120995
121221
  require_hub_cap_forward_DmHNjbB0();
@@ -121099,6 +121325,116 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
121099
121325
  const top = window2.top.map((d) => `${d.childId}:${d.sent}/${d.suppressed}`).join(",");
121100
121326
  return ` fanoutMode=uds:${window2.udsMode}/cross-node:${window2.crossNodeMode} children=${window2.childrenConnected} childrenUndeclared=${window2.childrenUndeclared} fanoutSent=${window2.fanoutSent} fanoutSuppressed=${window2.fanoutSuppressed} crossNodeDelivered=${window2.crossNodeDelivered} crossNodeSuppressed=${window2.crossNodeSuppressed}` + (top.length === 0 ? "" : ` fanoutTop=${top}`);
121101
121327
  }
121328
+ var EMPTY_CAP_ACTION_READING = /* @__PURE__ */ new Map();
121329
+ var CAP_ACTION_UNLABELLED = "(unlabelled)";
121330
+ var CAP_ACTION_OVERFLOW_LABEL = "(overflow)";
121331
+ var MAX_CAP_ACTIONS_PER_PEER = 64;
121332
+ function capActionLabel(body) {
121333
+ if (typeof body !== "object" || body === null) return null;
121334
+ const env = body;
121335
+ if (env.kind !== "cap-call" && env.kind !== "cap-call-out") return null;
121336
+ if (typeof env.capName !== "string" || typeof env.method !== "string") return null;
121337
+ return `${env.capName}.${env.method}`;
121338
+ }
121339
+ function emptyCounters() {
121340
+ return {
121341
+ calls: 0,
121342
+ reqBytes: 0,
121343
+ resBytes: 0,
121344
+ raw: 0,
121345
+ decoded: 0
121346
+ };
121347
+ }
121348
+ function createCapActionCensus() {
121349
+ const peers = /* @__PURE__ */ new Map();
121350
+ const slot = (peerId, action) => {
121351
+ let byAction = peers.get(peerId);
121352
+ if (byAction === void 0) {
121353
+ byAction = /* @__PURE__ */ new Map();
121354
+ peers.set(peerId, byAction);
121355
+ }
121356
+ const existing = byAction.get(action);
121357
+ if (existing !== void 0) return existing;
121358
+ if (byAction.size >= 64) {
121359
+ let overflow = byAction.get(CAP_ACTION_OVERFLOW_LABEL);
121360
+ if (overflow === void 0) {
121361
+ overflow = emptyCounters();
121362
+ byAction.set(CAP_ACTION_OVERFLOW_LABEL, overflow);
121363
+ }
121364
+ return overflow;
121365
+ }
121366
+ const fresh = emptyCounters();
121367
+ byAction.set(action, fresh);
121368
+ return fresh;
121369
+ };
121370
+ return {
121371
+ record(peerId, action, reqBytes, resBytes) {
121372
+ const c = slot(peerId, action);
121373
+ c.calls += 1;
121374
+ c.reqBytes += reqBytes;
121375
+ c.resBytes += resBytes;
121376
+ },
121377
+ recordForward(peerId, action, kind) {
121378
+ const c = slot(peerId, action);
121379
+ if (kind === "raw") c.raw += 1;
121380
+ else c.decoded += 1;
121381
+ },
121382
+ recordUnlabelled(peerId, bytes) {
121383
+ const c = slot(peerId, CAP_ACTION_UNLABELLED);
121384
+ c.resBytes += bytes;
121385
+ },
121386
+ forget(peerId) {
121387
+ peers.delete(peerId);
121388
+ },
121389
+ read() {
121390
+ const out = /* @__PURE__ */ new Map();
121391
+ for (const [peerId, byAction] of peers) {
121392
+ const copy2 = /* @__PURE__ */ new Map();
121393
+ for (const [action, c] of byAction) copy2.set(action, {
121394
+ calls: c.calls,
121395
+ reqBytes: c.reqBytes,
121396
+ resBytes: c.resBytes,
121397
+ raw: c.raw,
121398
+ decoded: c.decoded
121399
+ });
121400
+ out.set(peerId, copy2);
121401
+ }
121402
+ return out;
121403
+ }
121404
+ };
121405
+ }
121406
+ function sampleOf(reading, peerId, action) {
121407
+ return reading.get(peerId)?.get(action);
121408
+ }
121409
+ function diffCapActionCensus(before, current, topN) {
121410
+ const deltas = [];
121411
+ let labelledBytes = 0;
121412
+ let totalBytes = 0;
121413
+ for (const [peerId, byAction] of current) for (const [action, now] of byAction) {
121414
+ const then = sampleOf(before, peerId, action);
121415
+ const reqBytes = Math.max(0, now.reqBytes - (then?.reqBytes ?? 0));
121416
+ const resBytes = Math.max(0, now.resBytes - (then?.resBytes ?? 0));
121417
+ const bytes = reqBytes + resBytes;
121418
+ totalBytes += bytes;
121419
+ if (action === "(unlabelled)" || action === "(overflow)") continue;
121420
+ labelledBytes += bytes;
121421
+ if (bytes === 0) continue;
121422
+ deltas.push({
121423
+ peerId,
121424
+ action,
121425
+ calls: Math.max(0, now.calls - (then?.calls ?? 0)),
121426
+ reqBytes,
121427
+ resBytes,
121428
+ raw: Math.max(0, now.raw - (then?.raw ?? 0)),
121429
+ decoded: Math.max(0, now.decoded - (then?.decoded ?? 0))
121430
+ });
121431
+ }
121432
+ return {
121433
+ top: deltas.toSorted((a, b) => b.reqBytes + b.resBytes - (a.reqBytes + a.resBytes) || a.peerId.localeCompare(b.peerId) || a.action.localeCompare(b.action)).slice(0, topN),
121434
+ labelledBytes,
121435
+ totalBytes
121436
+ };
121437
+ }
121102
121438
  function createSocketDirectionCounters() {
121103
121439
  return {
121104
121440
  reqMessages: 0,
@@ -121165,10 +121501,12 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
121165
121501
  });
121166
121502
  }
121167
121503
  const forward = registry.readForwardCensus?.();
121504
+ const actions = registry.readActionCensus?.();
121168
121505
  return {
121169
121506
  peers,
121170
121507
  peersConnected: listed.length,
121171
- ...forward === void 0 ? {} : { forward }
121508
+ ...forward === void 0 ? {} : { forward },
121509
+ ...actions === void 0 ? {} : { actions }
121172
121510
  };
121173
121511
  } catch {
121174
121512
  return;
@@ -121249,6 +121587,7 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
121249
121587
  if (peerMessages(delta) > 0) deltas.push(delta);
121250
121588
  }
121251
121589
  const forward = diffForward(current.forward, baseline.forward);
121590
+ const actions = current.actions === void 0 ? void 0 : diffCapActionCensus(baseline.actions ?? EMPTY_CAP_ACTION_READING, current.actions, 5);
121252
121591
  return {
121253
121592
  peersConnected: current.peersConnected,
121254
121593
  peersMeasured: current.peers.length,
@@ -121257,7 +121596,8 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
121257
121596
  top: deltas.toSorted((a, b) => peerMessages(b) - peerMessages(a) || a.peerId.localeCompare(b.peerId)).slice(0, topN),
121258
121597
  topBytes: deltas.toSorted((a, b) => peerBytes(b) - peerBytes(a) || a.peerId.localeCompare(b.peerId)).slice(0, topN),
121259
121598
  queued: readSocketQueues(current),
121260
- ...forward === void 0 ? {} : { forward }
121599
+ ...forward === void 0 ? {} : { forward },
121600
+ ...actions === void 0 ? {} : { actions }
121261
121601
  };
121262
121602
  }
121263
121603
  function createSocketPlaneMeter(reader, topN = 5) {
@@ -121268,7 +121608,8 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
121268
121608
  const window2 = diffSocketPlane(baseline, current, topN);
121269
121609
  baseline = {
121270
121610
  peers: new Map(current.peers.map((p) => [p.peerId, p])),
121271
- ...current.forward === void 0 ? {} : { forward: current.forward }
121611
+ ...current.forward === void 0 ? {} : { forward: current.forward },
121612
+ ...current.actions === void 0 ? {} : { actions: current.actions }
121272
121613
  };
121273
121614
  return window2;
121274
121615
  } };
@@ -121285,13 +121626,16 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
121285
121626
  function formatPeer(delta) {
121286
121627
  return `${delta.peerId}:tx=${delta.tx.reqMessages}/${delta.tx.resMessages}/${delta.tx.evtMessages}:rx=${delta.rx.reqMessages}/${delta.rx.resMessages}/${delta.rx.evtMessages}:txkB=${formatPeerBytes(delta.tx)}:rxkB=${formatPeerBytes(delta.rx)}`;
121287
121628
  }
121629
+ function formatAction(entry) {
121630
+ return `${entry.peerId}!${entry.action}:${kb$1(entry.reqBytes + entry.resBytes)}kB/${entry.calls}:r${entry.raw}/d${entry.decoded}`;
121631
+ }
121288
121632
  function formatSocketPlane(window2) {
121289
121633
  if (window2 === void 0) return "";
121290
121634
  const top = window2.top.map(formatPeer).join(",");
121291
121635
  const named = new Set(window2.top.map((p) => p.peerId));
121292
121636
  const topBytes = window2.topBytes.filter((p) => !named.has(p.peerId)).map(formatPeer).join(",");
121293
121637
  const queuedTop = window2.queued.top.map((p) => `${p.peerId}:${kb$1(p.bytes)}`).join(",");
121294
- return ` socketPeers=${window2.peersMeasured}/${window2.peersConnected} socketTx=${formatDirection(window2.tx)} socketRx=${formatDirection(window2.rx)}` + (top.length === 0 ? "" : ` socketTop=${top}`) + (topBytes.length === 0 ? "" : ` socketTopBytes=${topBytes}`) + ` socketQueued=${kb$1(window2.queued.totalBytes)}kB` + (window2.queued.unmeasured === 0 ? "" : ` socketQueuedUnmeasured=${window2.queued.unmeasured}`) + (queuedTop.length === 0 ? "" : ` socketQueuedTop=${queuedTop}`) + (window2.forward === void 0 ? "" : ` socketFwd=${window2.forward.raw}/${window2.forward.decoded}`);
121638
+ return ` socketPeers=${window2.peersMeasured}/${window2.peersConnected} socketTx=${formatDirection(window2.tx)} socketRx=${formatDirection(window2.rx)}` + (top.length === 0 ? "" : ` socketTop=${top}`) + (topBytes.length === 0 ? "" : ` socketTopBytes=${topBytes}`) + ` socketQueued=${kb$1(window2.queued.totalBytes)}kB` + (window2.queued.unmeasured === 0 ? "" : ` socketQueuedUnmeasured=${window2.queued.unmeasured}`) + (queuedTop.length === 0 ? "" : ` socketQueuedTop=${queuedTop}`) + (window2.forward === void 0 ? "" : ` socketFwd=${window2.forward.raw}/${window2.forward.decoded}`) + (window2.actions === void 0 ? "" : ` socketActions=${kb$1(window2.actions.labelledBytes)}/${kb$1(window2.actions.totalBytes)}kB` + (window2.actions.top.length === 0 ? "" : ` socketTopActions=${window2.actions.top.map(formatAction).join(",")}`));
121295
121639
  }
121296
121640
  function isRecord$1(value) {
121297
121641
  return typeof value === "object" && value !== null;
@@ -121604,6 +121948,95 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
121604
121948
  const verdict = live < context.rawMb * 0.5 ? "mostly DEAD buffers awaiting a sweep, not a retention" : "LIVE \u2014 something holds them";
121605
121949
  return `[mem] ${label} arrayBuffer census: live=${live}MB in ${report.count} ArrayBuffers (raw arrayBuffers=${context.rawMb}MB at the trigger \u2192 ${verdict}) top sizes: ${report.topSizes.map(formatExact).join(", ") || "(none)"}; buckets: ${report.buckets.map(formatBucket).join(", ") || "(none)"}; detached=${report.detached} took=${context.tookMs}ms \u2014 cost: ONE forced full GC (the same pause as a reclaim pass), walked in memory, nothing serialised, nothing written; trigger: ${context.reason}`;
121606
121950
  }
121951
+ function countsOf(entries, kinds) {
121952
+ let majors = 0;
121953
+ let minors = 0;
121954
+ let incrementals = 0;
121955
+ let pauseMs = 0;
121956
+ for (const e of entries) {
121957
+ if (e.kind === kinds.major) majors++;
121958
+ else if (e.kind === kinds.minor) minors++;
121959
+ else if (e.kind === kinds.incremental) incrementals++;
121960
+ pauseMs += e.durationMs;
121961
+ }
121962
+ return {
121963
+ majors,
121964
+ minors,
121965
+ incrementals,
121966
+ pauseMs,
121967
+ windowMs: 0
121968
+ };
121969
+ }
121970
+ function createGcCensus(install, kinds, startedAt) {
121971
+ let pending = [];
121972
+ const stopObserving = install((entry) => {
121973
+ pending.push(entry);
121974
+ });
121975
+ if (stopObserving === void 0) return void 0;
121976
+ let windowStart = startedAt;
121977
+ return {
121978
+ read: (at) => {
121979
+ const windowMs = at - windowStart;
121980
+ if (windowMs < 1e3) return null;
121981
+ const taken = pending;
121982
+ pending = [];
121983
+ windowStart = at;
121984
+ return {
121985
+ ...countsOf(taken, kinds),
121986
+ windowMs
121987
+ };
121988
+ },
121989
+ stop: () => {
121990
+ stopObserving();
121991
+ pending = [];
121992
+ }
121993
+ };
121994
+ }
121995
+ function nodeGcObserver() {
121996
+ return {
121997
+ kinds: readKinds({
121998
+ major: 4,
121999
+ minor: 1,
122000
+ incremental: 8
122001
+ }),
122002
+ install: (observe) => {
122003
+ try {
122004
+ const observer = new (process.getBuiltinModule("node:perf_hooks")).PerformanceObserver((list) => {
122005
+ for (const entry of list.getEntries()) {
122006
+ const detail = "detail" in entry ? entry.detail : void 0;
122007
+ observe({
122008
+ kind: typeof detail === "object" && detail !== null && "kind" in detail && typeof detail.kind === "number" ? detail.kind : -1,
122009
+ durationMs: entry.duration
122010
+ });
122011
+ }
122012
+ });
122013
+ observer.observe({ entryTypes: ["gc"] });
122014
+ return () => {
122015
+ observer.disconnect();
122016
+ };
122017
+ } catch {
122018
+ return;
122019
+ }
122020
+ }
122021
+ };
122022
+ }
122023
+ function readKinds(fallback) {
122024
+ try {
122025
+ const c = process.getBuiltinModule("node:perf_hooks").constants;
122026
+ return {
122027
+ major: c.NODE_PERFORMANCE_GC_MAJOR,
122028
+ minor: c.NODE_PERFORMANCE_GC_MINOR,
122029
+ incremental: c.NODE_PERFORMANCE_GC_INCREMENTAL
122030
+ };
122031
+ } catch {
122032
+ return fallback;
122033
+ }
122034
+ }
122035
+ function formatGcCensus(window2) {
122036
+ if (window2 === null || window2 === void 0) return "";
122037
+ const perMin = (n) => window2.windowMs <= 0 ? "?" : (n / (window2.windowMs / 6e4)).toFixed(1);
122038
+ return ` gc=maj${window2.majors}/min${window2.minors}/inc${window2.incrementals}@${Math.round(window2.windowMs / 1e3)}s gcMajPerMin=${perMin(window2.majors)} gcPauseMs=${Math.round(window2.pauseMs)}`;
122039
+ }
121607
122040
  var HUB_MAIN_HEAP_WATCH_LABEL = "hub-main";
121608
122041
  var HEAP_WATCH_INTERVAL_MS = 6e4;
121609
122042
  var HEAP_WATCH_WARN_RATIO = 0.8;
@@ -121772,6 +122205,8 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
121772
122205
  const socketPlane = probes?.socketPlane === void 0 ? void 0 : createSocketPlaneMeter(probes.socketPlane);
121773
122206
  const readMemory = reclaimOptions?.readMemory ?? (() => process.memoryUsage());
121774
122207
  const now = reclaimOptions?.now ?? (() => Date.now());
122208
+ const gcObserver = probes?.gcObserver ?? nodeGcObserver();
122209
+ const gcCensus = createGcCensus(gcObserver.install, gcObserver.kinds, now());
121775
122210
  const triggerMb = reclaimOptions?.triggerMb ?? 1024;
121776
122211
  const minIntervalMs = reclaimOptions?.minIntervalMs ?? 12e4;
121777
122212
  const steadyStateIntervalMs = reclaimOptions?.steadyStateIntervalMs ?? 6e5;
@@ -121847,7 +122282,7 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
121847
122282
  const due = at - lastLoggedAt >= intervalMs;
121848
122283
  if (mode === "escalated" || due) {
121849
122284
  lastLoggedAt = at;
121850
- const line = format2(label, sample, loopDelay?.read(), budgetMb, `${formatHeapSpaces(readSpaces())}${formatEventPlane(eventPlane?.read())}` + formatSocketPlane(socketPlane?.read()) + formatMeshQueue(meshQueue?.()));
122285
+ const line = format2(label, sample, loopDelay?.read(), budgetMb, `${formatHeapSpaces(readSpaces())}${formatEventPlane(eventPlane?.read())}` + formatSocketPlane(socketPlane?.read()) + formatMeshQueue(meshQueue?.()) + formatGcCensus(gcCensus?.read(at)));
121851
122286
  if (sample.nearLimit) sink.warn(`${line} \u2014 APPROACHING HEAP LIMIT`);
121852
122287
  else if (mode === "escalated") sink.warn(`${line} \u2014 heap elevated, sampling every ${probeIntervalMs}ms`);
121853
122288
  else sink.info(line);
@@ -121905,6 +122340,7 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
121905
122340
  stopped = true;
121906
122341
  clearInterval(timer);
121907
122342
  loopDelay?.stop();
122343
+ gcCensus?.stop();
121908
122344
  };
121909
122345
  }
121910
122346
  var RUNNER_HEAP_WATCH_INTERVAL_MS = 3e5;
@@ -125262,6 +125698,8 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
125262
125698
  txCounters = createSocketDirectionCounters();
125263
125699
  /** Frames read from the peer, cumulative, split by kind. */
125264
125700
  rxCounters = createSocketDirectionCounters();
125701
+ /** See {@link CapActionChannelObserver}. Absent = no per-action census. */
125702
+ actionObserver = null;
125265
125703
  constructor(socket) {
125266
125704
  this.socket = socket;
125267
125705
  socket.on("data", (chunk) => this.onData(chunk));
@@ -125293,16 +125731,26 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
125293
125731
  }, timeoutMs);
125294
125732
  timer.unref?.();
125295
125733
  }
125734
+ const label = this.labelSafely(body);
125296
125735
  this.pending.set(id, {
125297
125736
  resolve,
125298
125737
  reject,
125299
- timer
125738
+ timer,
125739
+ action: null
125300
125740
  });
125301
- this.send({
125741
+ const reqBytes = this.send({
125302
125742
  k: "req",
125303
125743
  id,
125304
125744
  body
125305
125745
  }, opts?.payload);
125746
+ const entry = this.pending.get(id);
125747
+ if (entry !== void 0 && label !== void 0) this.pending.set(id, {
125748
+ ...entry,
125749
+ action: {
125750
+ label,
125751
+ reqBytes
125752
+ }
125753
+ });
125306
125754
  });
125307
125755
  }
125308
125756
  emit(body) {
@@ -125312,6 +125760,37 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
125312
125760
  body
125313
125761
  });
125314
125762
  }
125763
+ /**
125764
+ * Wire the per-action census. Only one observer is active at a time; an
125765
+ * unwired channel records nothing at all (never zeros).
125766
+ */
125767
+ observeActions(observer) {
125768
+ this.actionObserver = observer;
125769
+ }
125770
+ /**
125771
+ * The label for one envelope, or `undefined` when there is nothing to
125772
+ * record. Wrapped: a broken labeller must never fail the call it watches —
125773
+ * the same discipline `LocalChildRegistry.recordCapUsage` applies, and for
125774
+ * the same reason.
125775
+ */
125776
+ labelSafely(body) {
125777
+ const obs = this.actionObserver;
125778
+ if (obs === null) return void 0;
125779
+ try {
125780
+ return obs.label(body);
125781
+ } catch {
125782
+ return null;
125783
+ }
125784
+ }
125785
+ /** Settle one request/response pair on the census. Never throws. */
125786
+ recordAction(label, reqBytes, resBytes) {
125787
+ const obs = this.actionObserver;
125788
+ if (obs === null) return;
125789
+ try {
125790
+ obs.record(label, reqBytes, resBytes);
125791
+ } catch {
125792
+ }
125793
+ }
125315
125794
  /** Replace the request handler. Only one handler is active at a time. */
125316
125795
  onRequest(handler) {
125317
125796
  this.requestHandler = handler;
@@ -125359,21 +125838,27 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
125359
125838
  * are never copied into the head. A forwarded payload is a view into the
125360
125839
  * frame it arrived on, and that frame's buffer is never mutated, so handing
125361
125840
  * the view to the socket is safe.
125841
+ *
125842
+ * Returns the on-the-wire bytes it charged — the same number the per-kind
125843
+ * counter got, so the per-action census can never disagree with the per-peer
125844
+ * one. `0` when the channel is closed and nothing was written.
125362
125845
  */
125363
125846
  send(frame, payload) {
125364
- if (this.closed) return;
125847
+ if (this.closed) return 0;
125365
125848
  if (payload === void 0) {
125366
125849
  const encoded = encodeFrame(frame);
125367
125850
  recordSocketFrame(this.txCounters, frame.k, encoded.byteLength);
125368
125851
  this.socket.write(encoded);
125369
- return;
125852
+ return encoded.byteLength;
125370
125853
  }
125371
125854
  const head = encodeFrameHead(frame, payload);
125372
- recordSocketFrame(this.txCounters, frame.k, head.byteLength + payload.byteLength);
125855
+ const bytes = head.byteLength + payload.byteLength;
125856
+ recordSocketFrame(this.txCounters, frame.k, bytes);
125373
125857
  this.socket.cork();
125374
125858
  this.socket.write(head);
125375
125859
  this.socket.write(payload);
125376
125860
  this.socket.uncork();
125861
+ return bytes;
125377
125862
  }
125378
125863
  onData(chunk) {
125379
125864
  const frames = this.decoder.push(chunk);
@@ -125392,28 +125877,31 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
125392
125877
  async handleFrame(frame, wireBytes) {
125393
125878
  recordSocketFrame(this.rxCounters, frame.k, wireBytes);
125394
125879
  if (frame.k === "req") {
125880
+ const label = this.labelSafely(frame.body);
125881
+ let resBytes = 0;
125395
125882
  try {
125396
125883
  const result = await this.requestHandler(frame.body, frame.pl);
125397
- if (result instanceof PayloadReply) this.send({
125884
+ if (result instanceof PayloadReply) resBytes = this.send({
125398
125885
  k: "res",
125399
125886
  id: frame.id,
125400
125887
  ok: true,
125401
125888
  body: result.body
125402
125889
  }, result.payload);
125403
- else this.send({
125890
+ else resBytes = this.send({
125404
125891
  k: "res",
125405
125892
  id: frame.id,
125406
125893
  ok: true,
125407
125894
  body: result
125408
125895
  });
125409
125896
  } catch (err) {
125410
- this.send({
125897
+ resBytes = this.send({
125411
125898
  k: "res",
125412
125899
  id: frame.id,
125413
125900
  ok: false,
125414
125901
  err: err instanceof Error ? err.message : String(err)
125415
125902
  });
125416
125903
  }
125904
+ if (label !== void 0) this.recordAction(label, wireBytes, resBytes);
125417
125905
  return;
125418
125906
  }
125419
125907
  if (frame.k === "res") {
@@ -125421,6 +125909,7 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
125421
125909
  if (!p) return;
125422
125910
  this.pending.delete(frame.id);
125423
125911
  if (p.timer !== null) clearTimeout(p.timer);
125912
+ if (p.action !== null) this.recordAction(p.action.label, p.action.reqBytes, wireBytes);
125424
125913
  if (!frame.ok) p.reject(new Error(frame.err));
125425
125914
  else if (frame.pl !== void 0) p.resolve(new PayloadReply(frame.body, frame.pl));
125426
125915
  else p.resolve(frame.body);
@@ -125812,6 +126301,42 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
125812
126301
  }
125813
126302
  }
125814
126303
  }
126304
+ var DEVICE_KEY_SEPARATOR = "\0";
126305
+ var NO_CANDIDATES = Object.freeze([]);
126306
+ var MapCapChildIndex = class {
126307
+ deviceOwners;
126308
+ singletons;
126309
+ constructor(deviceOwners, singletons) {
126310
+ this.deviceOwners = deviceOwners;
126311
+ this.singletons = singletons;
126312
+ }
126313
+ deviceOwner(capName, deviceId) {
126314
+ return this.deviceOwners.get(`${capName}${DEVICE_KEY_SEPARATOR}${deviceId}`) ?? null;
126315
+ }
126316
+ singletonCandidates(capName) {
126317
+ return this.singletons.get(capName) ?? NO_CANDIDATES;
126318
+ }
126319
+ };
126320
+ function buildCapChildIndex(entries) {
126321
+ const deviceOwners = /* @__PURE__ */ new Map();
126322
+ const singletons = /* @__PURE__ */ new Map();
126323
+ for (const entry of entries) {
126324
+ const namedForThisChild = /* @__PURE__ */ new Set();
126325
+ for (const cap of entry.caps) {
126326
+ if (cap.deviceId === void 0) {
126327
+ if (namedForThisChild.has(cap.capName)) continue;
126328
+ namedForThisChild.add(cap.capName);
126329
+ const candidates = singletons.get(cap.capName);
126330
+ if (candidates === void 0) singletons.set(cap.capName, [entry.childId]);
126331
+ else candidates.push(entry.childId);
126332
+ continue;
126333
+ }
126334
+ const key = `${cap.capName}${DEVICE_KEY_SEPARATOR}${cap.deviceId}`;
126335
+ if (!deviceOwners.has(key)) deviceOwners.set(key, entry.childId);
126336
+ }
126337
+ }
126338
+ return new MapCapChildIndex(deviceOwners, singletons);
126339
+ }
125815
126340
  function liftRoutingHints(args) {
125816
126341
  if (args === null || typeof args !== "object" || Array.isArray(args)) return {};
125817
126342
  const nodeId = Reflect.get(args, "nodeId");
@@ -125851,6 +126376,14 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
125851
126376
  /** See {@link ForwardCensus}. Mutable counters on the hot path, by design. */
125852
126377
  forwardedRaw = 0;
125853
126378
  forwardedDecoded = 0;
126379
+ /**
126380
+ * The per-ACTION byte census (D456). `ForwardCensus` above is the same
126381
+ * question asked of the whole plane; this one asks it per `<cap>.<method>`,
126382
+ * beside the bytes that method actually moved. Both are kept: `socketFwd=`
126383
+ * says whether the negotiation is working at all, and a `raw=0` on ONE
126384
+ * method with `raw>0` on its neighbours is a different fault.
126385
+ */
126386
+ actionCensus = createCapActionCensus();
125854
126387
  /** See {@link LocalChildRegistryOptions.capTimeoutMs}. */
125855
126388
  capTimeoutMs;
125856
126389
  /** See {@link LocalChildRegistryOptions.capUsageObserver}. */
@@ -125864,6 +126397,12 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
125864
126397
  /** Last pattern-set string logged per child, to dedup the INFO line. */
125865
126398
  loggedPatternSet = /* @__PURE__ */ new Map();
125866
126399
  /**
126400
+ * Derived `(cap, device?) → child` index over {@link children}, or `null`
126401
+ * when it must be rebuilt. See {@link capIndex} for why it is a cache and
126402
+ * never a registry (D3, D457).
126403
+ */
126404
+ capChildIndex = null;
126405
+ /**
125867
126406
  * Accepts either a plain positional `server` argument (backward-compatible)
125868
126407
  * or a full `LocalChildRegistryOptions` object.
125869
126408
  *
@@ -125944,6 +126483,21 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
125944
126483
  };
125945
126484
  }
125946
126485
  /**
126486
+ * Cumulative per-action byte census: peer → `<cap>.<method>` → bytes, calls
126487
+ * and the raw/decoded split. A COPY (`cap-action-census.ts` explains why it
126488
+ * must be one); the heartbeat subtracts the previous reading.
126489
+ *
126490
+ * This is the instrument D454 closed by asking for. `socketTopBytes=` names
126491
+ * the peer that moves the bytes and `txkB=` says they are responses; neither
126492
+ * can say WHICH method originates them, and after raw-forward the bytes that
126493
+ * cross are no longer the proxy for what hub-main pays — 85.7 % of sibling
126494
+ * calls cross unread. What costs is what hub-main LOOKS at, and that is the
126495
+ * `decoded` half of an entry, next to the bytes it carried.
126496
+ */
126497
+ readActionCensus() {
126498
+ return this.actionCensus.read();
126499
+ }
126500
+ /**
125947
126501
  * The regime the counters above were produced under, read once from
125948
126502
  * `CAMSTACK_UDS_EVENT_FANOUT` at construction.
125949
126503
  *
@@ -126057,11 +126611,12 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
126057
126611
  * compete for the same capName.
126058
126612
  */
126059
126613
  resolveChildId(capName, deviceId) {
126614
+ const index = this.capIndex();
126060
126615
  if (deviceId !== void 0) {
126061
- const deviceOwner = this.findChildId((cap) => cap.capName === capName && cap.deviceId === deviceId);
126616
+ const deviceOwner = index.deviceOwner(capName, deviceId);
126062
126617
  if (deviceOwner !== null) return deviceOwner;
126063
126618
  }
126064
- const candidates = this.findAllChildIds((cap) => cap.capName === capName && cap.deviceId === void 0);
126619
+ const candidates = index.singletonCandidates(capName);
126065
126620
  if (candidates.length === 0) return null;
126066
126621
  if (candidates.length === 1) return candidates[0];
126067
126622
  const preferredAddonId = this.getActiveSingletonAddonId?.(capName) ?? null;
@@ -126095,16 +126650,37 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
126095
126650
  } catch {
126096
126651
  }
126097
126652
  }
126098
- /** First child whose cap manifest contains a descriptor matching `predicate`. */
126099
- findChildId(predicate) {
126100
- for (const entry of this.children.values()) if (entry.caps.some(predicate)) return entry.childId;
126101
- return null;
126653
+ /**
126654
+ * The cap index over the CURRENT children, rebuilt on first use after any
126655
+ * mutation of {@link children}.
126656
+ *
126657
+ * This replaced a linear walk of every child's cap manifest per
126658
+ * `cap-call-out`, measured at **7.1 % of hub-main's busy main thread**
126659
+ * across 39 children (D456). Why it did not exist before is the whole
126660
+ * design: what it indexes moves — a runner is replaced on every update, a
126661
+ * crash respawns one, a child re-registers with a replacement manifest after
126662
+ * init — and an index that names a dead child routes work into a socket
126663
+ * nobody is reading, which is strictly worse than a slow scan.
126664
+ *
126665
+ * So it is not maintained; it is DISCARDED. `buildCapChildIndex` is a pure
126666
+ * function of `children.values()`, the only two writers of that map
126667
+ * ({@link invalidateCapIndex}'s call sites) drop the index in the same
126668
+ * statement, and nothing else can construct one. There is no add-on-register
126669
+ * / remove-on-close path that could disagree with the map — i.e. no shadow
126670
+ * registry (D3): the map remains the single authority and this holds no fact
126671
+ * it does not.
126672
+ *
126673
+ * The operator's active-singleton preference is deliberately NOT indexed —
126674
+ * it changes without any child connecting or leaving, so `resolveChildId`
126675
+ * reads it live and the index only supplies the candidate list.
126676
+ */
126677
+ capIndex() {
126678
+ if (this.capChildIndex === null) this.capChildIndex = buildCapChildIndex(this.children.values());
126679
+ return this.capChildIndex;
126102
126680
  }
126103
- /** Every child whose cap manifest contains a descriptor matching `predicate`. */
126104
- findAllChildIds(predicate) {
126105
- const out = [];
126106
- for (const entry of this.children.values()) if (entry.caps.some(predicate)) out.push(entry.childId);
126107
- return out;
126681
+ /** Drop the derived index. MUST follow every write to {@link children}. */
126682
+ invalidateCapIndex() {
126683
+ this.capChildIndex = null;
126108
126684
  }
126109
126685
  /**
126110
126686
  * Does the named child currently provide `(capName, deviceId?)`?
@@ -126300,6 +126876,14 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
126300
126876
  onConnection(channel) {
126301
126877
  let childId = null;
126302
126878
  const incarnation = this.nextIncarnation++;
126879
+ channel.observeActions?.({
126880
+ label: capActionLabel,
126881
+ record: (label, reqBytes, resBytes) => {
126882
+ const peerId = childId ?? "(pre-register)";
126883
+ if (label === null) this.actionCensus.recordUnlabelled(peerId, reqBytes + resBytes);
126884
+ else this.actionCensus.record(peerId, label, reqBytes, resBytes);
126885
+ }
126886
+ });
126303
126887
  channel.onEvent((body) => {
126304
126888
  const msg = body;
126305
126889
  if (msg.kind === "event") {
@@ -126342,6 +126926,7 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
126342
126926
  incarnation,
126343
126927
  rawForward: msg.rawForward === true
126344
126928
  });
126929
+ this.invalidateCapIndex();
126345
126930
  this.logPatternSet(msg.childId, eventPatterns);
126346
126931
  this.registeredHandler({
126347
126932
  childId: msg.childId,
@@ -126373,6 +126958,8 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
126373
126958
  const addonPinned = pinnedNodeId === void 0 && this.isAddonPinnedCall?.(out.capName, out.method, hints) === true;
126374
126959
  const target = !(out.native === true) && !aggregated && !addonPinned && (pinnedNodeId === void 0 || pinTargetsThisNode) ? this.resolveChildId(out.capName, out.deviceId) : null;
126375
126960
  this.recordCapUsage(childId, target, out.capName, out.method);
126961
+ const actionPeer = childId ?? "(pre-register)";
126962
+ const actionLabel = `${out.capName}.${out.method}`;
126376
126963
  if (target !== null) {
126377
126964
  if (!this.egressRoutedCaps.has(out.capName)) {
126378
126965
  this.egressRoutedCaps.add(out.capName);
@@ -126381,6 +126968,7 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
126381
126968
  const entry = this.children.get(target);
126382
126969
  if (payload !== void 0 && entry !== void 0 && entry.rawForward) {
126383
126970
  this.forwardedRaw += 1;
126971
+ this.actionCensus.recordForward(actionPeer, actionLabel, "raw");
126384
126972
  const forward = {
126385
126973
  kind: "cap-call",
126386
126974
  capName: out.capName,
@@ -126395,9 +126983,12 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
126395
126983
  });
126396
126984
  }
126397
126985
  this.forwardedDecoded += 1;
126398
- return this.callCap(buildInput());
126986
+ this.actionCensus.recordForward(actionPeer, actionLabel, "decoded");
126987
+ const input = buildInput();
126988
+ return entry !== void 0 ? this.callCapOnChild(target, input) : this.callCap(input);
126399
126989
  }
126400
126990
  this.forwardedDecoded += 1;
126991
+ this.actionCensus.recordForward(actionPeer, actionLabel, "decoded");
126401
126992
  if (this.onUnownedCall !== void 0) return this.onUnownedCall(buildInput());
126402
126993
  throw new Error(`${UDS_NO_ROUTE_PREFIX}: cap-call-out has no local provider for "${out.capName}" and no fallback`);
126403
126994
  }
@@ -126420,7 +127011,9 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
126420
127011
  return;
126421
127012
  }
126422
127013
  this.children.delete(childId);
127014
+ this.invalidateCapIndex();
126423
127015
  this.childEventStats.delete(childId);
127016
+ this.actionCensus.forget(childId);
126424
127017
  this.loggedPatternSet.delete(childId);
126425
127018
  this.goneHandler(childId, incarnation);
126426
127019
  });
@@ -129074,6 +129667,18 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
129074
129667
  return AddonDepsManager;
129075
129668
  }
129076
129669
  });
129670
+ Object.defineProperty(exports, "CAP_ACTION_OVERFLOW_LABEL", {
129671
+ enumerable: true,
129672
+ get: function() {
129673
+ return CAP_ACTION_OVERFLOW_LABEL;
129674
+ }
129675
+ });
129676
+ Object.defineProperty(exports, "CAP_ACTION_UNLABELLED", {
129677
+ enumerable: true,
129678
+ get: function() {
129679
+ return CAP_ACTION_UNLABELLED;
129680
+ }
129681
+ });
129077
129682
  Object.defineProperty(exports, "CapRouteError", {
129078
129683
  enumerable: true,
129079
129684
  get: function() {
@@ -129116,6 +129721,12 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
129116
129721
  return DeviceRegistry;
129117
129722
  }
129118
129723
  });
129724
+ Object.defineProperty(exports, "EMPTY_CAP_ACTION_READING", {
129725
+ enumerable: true,
129726
+ get: function() {
129727
+ return EMPTY_CAP_ACTION_READING;
129728
+ }
129729
+ });
129119
129730
  Object.defineProperty(exports, "EMPTY_SOCKET_DIRECTION", {
129120
129731
  enumerable: true,
129121
129732
  get: function() {
@@ -129212,6 +129823,12 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
129212
129823
  return LocalChildRegistry;
129213
129824
  }
129214
129825
  });
129826
+ Object.defineProperty(exports, "MAX_CAP_ACTIONS_PER_PEER", {
129827
+ enumerable: true,
129828
+ get: function() {
129829
+ return MAX_CAP_ACTIONS_PER_PEER;
129830
+ }
129831
+ });
129215
129832
  Object.defineProperty(exports, "MESH_QUEUE_TOP_N", {
129216
129833
  enumerable: true,
129217
129834
  get: function() {
@@ -129368,6 +129985,12 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
129368
129985
  return callWithServiceDiscovery;
129369
129986
  }
129370
129987
  });
129988
+ Object.defineProperty(exports, "capActionLabel", {
129989
+ enumerable: true,
129990
+ get: function() {
129991
+ return capActionLabel;
129992
+ }
129993
+ });
129371
129994
  Object.defineProperty(exports, "capActionName", {
129372
129995
  enumerable: true,
129373
129996
  get: function() {
@@ -129440,6 +130063,12 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
129440
130063
  return createBrokerDeviceManagerApi;
129441
130064
  }
129442
130065
  });
130066
+ Object.defineProperty(exports, "createCapActionCensus", {
130067
+ enumerable: true,
130068
+ get: function() {
130069
+ return createCapActionCensus;
130070
+ }
130071
+ });
129443
130072
  Object.defineProperty(exports, "createDeferredHeapWatchSink", {
129444
130073
  enumerable: true,
129445
130074
  get: function() {
@@ -129566,6 +130195,12 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
129566
130195
  return deserializeTypedArrays;
129567
130196
  }
129568
130197
  });
130198
+ Object.defineProperty(exports, "diffCapActionCensus", {
130199
+ enumerable: true,
130200
+ get: function() {
130201
+ return diffCapActionCensus;
130202
+ }
130203
+ });
129569
130204
  Object.defineProperty(exports, "diffEventPlane", {
129570
130205
  enumerable: true,
129571
130206
  get: function() {
@@ -129905,11 +130540,11 @@ var require_manifest_system_deps_g_nK0xsF = __commonJS({
129905
130540
  }
129906
130541
  });
129907
130542
 
129908
- // ../system/dist/custom-action-registry-DKWhaWL1.js
129909
- var require_custom_action_registry_DKWhaWL1 = __commonJS({
129910
- "../system/dist/custom-action-registry-DKWhaWL1.js"(exports) {
130543
+ // ../system/dist/custom-action-registry-B42MC_Pv.js
130544
+ var require_custom_action_registry_B42MC_Pv = __commonJS({
130545
+ "../system/dist/custom-action-registry-B42MC_Pv.js"(exports) {
129911
130546
  "use strict";
129912
- var require_dist10 = require_dist_B17W9ngu();
130547
+ var require_dist10 = require_dist_CllKpcTd();
129913
130548
  var CustomActionRegistry = class {
129914
130549
  byAddon = /* @__PURE__ */ new Map();
129915
130550
  registerAddon(addonId, catalog, handler) {
@@ -133723,7 +134358,7 @@ var require_dist3 = __commonJS({
133723
134358
  "use strict";
133724
134359
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
133725
134360
  var require_chunk = require_chunk_Cek0wNdY();
133726
- var require_dist10 = require_dist_B17W9ngu();
134361
+ var require_dist10 = require_dist_CllKpcTd();
133727
134362
  var require_builtins_alerts_alerts_addon = require_alerts_addon();
133728
134363
  require_alerts();
133729
134364
  var require_formatter = require_formatter_DqAKDlvN();
@@ -133750,9 +134385,9 @@ var require_dist3 = __commonJS({
133750
134385
  var require_builtins_winston_logging_index = require_winston_logging();
133751
134386
  var require_event_loop_stall_monitor = require_event_loop_stall_monitor_CAsHdMwP();
133752
134387
  var require_tls$1 = require_tls_BFs4PzoW();
133753
- var require_manifest_system_deps = require_manifest_system_deps_g_nK0xsF();
134388
+ var require_manifest_system_deps = require_manifest_system_deps_DfpwaXkh();
133754
134389
  var require_resource_monitor = require_resource_monitor_LVE1BoLs();
133755
- var require_custom_action_registry = require_custom_action_registry_DKWhaWL1();
134390
+ var require_custom_action_registry = require_custom_action_registry_B42MC_Pv();
133756
134391
  var zod = require_zod();
133757
134392
  var node_crypto = __require("crypto");
133758
134393
  var _camstack_types_node = require_node();
@@ -198409,6 +199044,7 @@ ${originalIndentation}`;
198409
199044
  var require_parser3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports2, module2) => {
198410
199045
  var Writable = __require("stream").Writable;
198411
199046
  var { resolvePacketType } = require_constants15();
199047
+ var HEADER_BYTES = 6;
198412
199048
  var Parser = class extends Writable {
198413
199049
  /**
198414
199050
  * Create an instance of Parser
@@ -198418,32 +199054,42 @@ ${originalIndentation}`;
198418
199054
  constructor(options, maxPacketSize) {
198419
199055
  super(options);
198420
199056
  this.maxPacketSize = maxPacketSize;
198421
- this.buf = null;
199057
+ this.bufs = [];
199058
+ this.bufLen = 0;
199059
+ }
199060
+ /** The first `HEADER_BYTES` pending bytes, without flattening the rest. */
199061
+ _header() {
199062
+ const first = this.bufs[0];
199063
+ if (first.length >= HEADER_BYTES) return first;
199064
+ const head = Buffer.allocUnsafe(HEADER_BYTES);
199065
+ let written = 0;
199066
+ for (let i = 0; i < this.bufs.length && written < HEADER_BYTES; i++) {
199067
+ const b = this.bufs[i];
199068
+ const take = Math.min(HEADER_BYTES - written, b.length);
199069
+ b.copy(head, written, 0, take);
199070
+ written += take;
199071
+ }
199072
+ return head;
198422
199073
  }
198423
199074
  _write(chunk, encoding, cb) {
198424
- let packet = chunk;
198425
- if (this.buf && this.buf.length > 0) {
198426
- packet = Buffer.concat([this.buf, chunk]);
198427
- this.buf = null;
198428
- }
198429
- while (packet.length > 0) {
198430
- if (packet.length < 6) {
198431
- this.buf = Buffer.from(packet);
198432
- return cb();
198433
- }
198434
- if (this.maxPacketSize && packet.length > this.maxPacketSize) return cb(/* @__PURE__ */ new Error(`Incoming packet is larger than the 'maxPacketSize' limit (${packet.length} > ${this.maxPacketSize})!`));
198435
- const crc = packet[1] ^ packet[2] ^ packet[3] ^ packet[4] ^ packet[5];
198436
- if (crc !== packet[0]) return cb(/* @__PURE__ */ new Error("Invalid packet CRC! " + crc));
198437
- const length = packet.readInt32BE(1);
198438
- if (packet.length >= length) {
198439
- const msg = packet.slice(6, length);
198440
- const type2 = resolvePacketType(packet[5]);
198441
- this.emit("data", type2, msg);
198442
- packet = packet.slice(length);
198443
- } else {
198444
- this.buf = Buffer.from(packet);
198445
- return cb();
198446
- }
199075
+ if (this.bufLen > 0) this.bufs.push(chunk);
199076
+ else this.bufs = [chunk];
199077
+ this.bufLen += chunk.length;
199078
+ while (this.bufLen > 0) {
199079
+ if (this.bufLen < HEADER_BYTES) return cb();
199080
+ if (this.maxPacketSize && this.bufLen > this.maxPacketSize) return cb(/* @__PURE__ */ new Error(`Incoming packet is larger than the 'maxPacketSize' limit (${this.bufLen} > ${this.maxPacketSize})!`));
199081
+ const header = this._header();
199082
+ const crc = header[1] ^ header[2] ^ header[3] ^ header[4] ^ header[5];
199083
+ if (crc !== header[0]) return cb(/* @__PURE__ */ new Error("Invalid packet CRC! " + crc));
199084
+ const length = header.readInt32BE(1);
199085
+ if (this.bufLen < length) return cb();
199086
+ const packet = this.bufs.length === 1 ? this.bufs[0] : Buffer.concat(this.bufs, this.bufLen);
199087
+ const msg = packet.slice(HEADER_BYTES, length);
199088
+ const type2 = resolvePacketType(packet[5]);
199089
+ this.emit("data", type2, msg);
199090
+ const rest = packet.slice(length);
199091
+ this.bufs = rest.length > 0 ? [rest] : [];
199092
+ this.bufLen = rest.length;
198447
199093
  }
198448
199094
  cb();
198449
199095
  }
@@ -214429,6 +215075,8 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
214429
215075
  exports.AlertCenterAddon = require_builtins_alerts_alerts_addon.AlertCenterAddon;
214430
215076
  exports.ApiKeyManager = require_builtins_local_auth_local_auth_addon.ApiKeyManager;
214431
215077
  exports.AuthManager = require_builtins_local_auth_local_auth_addon.AuthManager;
215078
+ exports.CAP_ACTION_OVERFLOW_LABEL = require_manifest_system_deps.CAP_ACTION_OVERFLOW_LABEL;
215079
+ exports.CAP_ACTION_UNLABELLED = require_manifest_system_deps.CAP_ACTION_UNLABELLED;
214432
215080
  exports.CA_COMMON_NAME = require_tls$1.CA_COMMON_NAME;
214433
215081
  exports.CA_VALIDITY_DAYS = require_tls$1.CA_VALIDITY_DAYS;
214434
215082
  exports.CLUSTER_SECRET_MISMATCH_TYPE = CLUSTER_SECRET_MISMATCH_TYPE;
@@ -214456,6 +215104,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
214456
215104
  exports.DeviceManagerAddon = require_builtins_device_manager_device_manager_addon.DeviceManagerAddon;
214457
215105
  exports.DeviceRegistry = require_manifest_system_deps.DeviceRegistry;
214458
215106
  exports.DeviceStore = require_builtins_sqlite_storage_index.DeviceStore$1;
215107
+ exports.EMPTY_CAP_ACTION_READING = require_manifest_system_deps.EMPTY_CAP_ACTION_READING;
214459
215108
  exports.EMPTY_SOCKET_DIRECTION = require_manifest_system_deps.EMPTY_SOCKET_DIRECTION;
214460
215109
  exports.EMPTY_SOCKET_PLANE_BASELINE = require_manifest_system_deps.EMPTY_SOCKET_PLANE_BASELINE;
214461
215110
  exports.EVENT_PLANE_TOP_N = require_manifest_system_deps.EVENT_PLANE_TOP_N;
@@ -214500,6 +215149,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
214500
215149
  exports.LoggingGate = LoggingGate;
214501
215150
  exports.LokiDestination = require_builtins_loki_logging_index.LokiDestination$1;
214502
215151
  exports.LokiLoggingAddon = require_builtins_loki_logging_index.LokiLoggingAddon$1;
215152
+ exports.MAX_CAP_ACTIONS_PER_PEER = require_manifest_system_deps.MAX_CAP_ACTIONS_PER_PEER;
214503
215153
  exports.MAX_LEAF_VALIDITY_DAYS = require_tls$1.MAX_LEAF_VALIDITY_DAYS;
214504
215154
  exports.MESH_QUEUE_TOP_N = require_manifest_system_deps.MESH_QUEUE_TOP_N;
214505
215155
  exports.METHOD_ACCESS_MAP = require_dist10.METHOD_ACCESS_MAP;
@@ -214588,6 +215238,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
214588
215238
  exports.callRegisterNodeWithRetry = callRegisterNodeWithRetry;
214589
215239
  exports.callWithServiceDiscovery = require_manifest_system_deps.callWithServiceDiscovery;
214590
215240
  exports.canServeDataPlane = canServeDataPlane;
215241
+ exports.capActionLabel = require_manifest_system_deps.capActionLabel;
214591
215242
  exports.capActionName = require_manifest_system_deps.capActionName;
214592
215243
  exports.capActionSuffix = require_manifest_system_deps.capActionSuffix;
214593
215244
  exports.capBareAction = require_manifest_system_deps.capBareAction;
@@ -214610,6 +215261,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
214610
215261
  exports.createAuthenticatedFileServer = require_event_loop_stall_monitor.createAuthenticatedFileServer;
214611
215262
  exports.createBroker = createBroker2;
214612
215263
  exports.createBrokerDeviceManagerApi = require_manifest_system_deps.createBrokerDeviceManagerApi;
215264
+ exports.createCapActionCensus = require_manifest_system_deps.createCapActionCensus;
214613
215265
  exports.createCoreCapService = createCoreCapService;
214614
215266
  exports.createDeferredHeapWatchSink = require_manifest_system_deps.createDeferredHeapWatchSink;
214615
215267
  exports.createDoorSettingsView = createDoorSettingsView;
@@ -214644,6 +215296,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
214644
215296
  exports.describeProviderKindDrift = describeProviderKindDrift;
214645
215297
  exports.describeRss = require_manifest_system_deps.describeRss;
214646
215298
  exports.detectWorkspacePackagesDir = detectWorkspacePackagesDir;
215299
+ exports.diffCapActionCensus = require_manifest_system_deps.diffCapActionCensus;
214647
215300
  exports.diffEventPlane = require_manifest_system_deps.diffEventPlane;
214648
215301
  exports.diffSocketPlane = require_manifest_system_deps.diffSocketPlane;
214649
215302
  Object.defineProperty(exports, "downloadBinary", {
@@ -214841,8 +215494,8 @@ var require_dist4 = __commonJS({
214841
215494
  "../types/dist/index.js"(exports) {
214842
215495
  "use strict";
214843
215496
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
215497
+ var require_sleep = require_sleep_B1ZwxAhh();
214844
215498
  var require_event_category = require_event_category_BNJ9EE5B();
214845
- var require_sleep = require_sleep_CTHjJilA();
214846
215499
  var require_canonical_hash = require_canonical_hash_DNV8S5ET();
214847
215500
  var require_enums2 = require_enums();
214848
215501
  var require_err_msg = require_err_msg_COpsHMw2();
@@ -215990,6 +216643,7 @@ var require_dist4 = __commonJS({
215990
216643
  var RecordingObjectTriggerClassSchema = zod.z.enum(FIRST_LEVEL_MACRO_CLASSES);
215991
216644
  var noDuplicates = (values) => new Set(values).size === values.length;
215992
216645
  var MAX_SENSOR_TRIGGER_DEVICES = 16;
216646
+ var RECORDING_AUDIO_TRIGGER_OFFERED_DBFS = -30;
215993
216647
  var RecordingTriggersSchema = zod.z.object({
215994
216648
  motion: zod.z.boolean().optional(),
215995
216649
  audioThresholdDbfs: zod.z.number().optional(),
@@ -219584,6 +220238,37 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
219584
220238
  minConfidence: zod.z.number().min(0).max(1).default(0.3),
219585
220239
  allowedClasses: zod.z.array(zod.z.string()).default([])
219586
220240
  });
220241
+ var AudioAttachDeviceInputSchema = zod.z.object({
220242
+ deviceId: zod.z.number(),
220243
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
220244
+ brokerId: zod.z.string(),
220245
+ /**
220246
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
220247
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
220248
+ * the orchestrator's poller pinned them before the move.
220249
+ */
220250
+ ingestNodeId: zod.z.string(),
220251
+ /**
220252
+ * Resolved once by the orchestrator at attach time, exactly as it was read
220253
+ * once per subscription before D461. The analyzer does NOT re-resolve per
220254
+ * window: a settings change re-attaches, which is what always happened.
220255
+ */
220256
+ settings: AudioAnalysisSettingsSchema
220257
+ });
220258
+ var AudioAttachDeviceResultSchema = zod.z.object({
220259
+ /** False only when the analyzer is shutting down and refused to attach. */
220260
+ attached: zod.z.boolean(),
220261
+ /**
220262
+ * True when the attachment replaced a live one for the same device. An
220263
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
220264
+ * double the broker's fanout and neither would know about the other.
220265
+ */
220266
+ replaced: zod.z.boolean()
220267
+ });
220268
+ var AudioDetachDeviceResultSchema = zod.z.object({
220269
+ /** False when no attachment existed — detach is idempotent. */
220270
+ detached: zod.z.boolean()
220271
+ });
219587
220272
  var AudioClassificationResultSchema = zod.z.object({
219588
220273
  labels: zod.z.array(AudioClassificationLabelSchema).readonly(),
219589
220274
  rawLabels: zod.z.array(AudioClassificationLabelSchema).readonly().optional(),
@@ -219617,6 +220302,21 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
219617
220302
  settings: AudioAnalysisSettingsSchema
219618
220303
  }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }),
219619
220304
  classify: require_sleep.method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }),
220305
+ /**
220306
+ * Start pulling this camera's audio from the broker, in THIS process.
220307
+ * Returns as soon as the attachment exists — the first
220308
+ * `subscribeAudioChunks` retries with backoff behind it, because the
220309
+ * broker for a camStream may not be registered yet (that tolerance moved
220310
+ * with the poller, D461). Replaces any live attachment for the device.
220311
+ */
220312
+ attachDevice: require_sleep.method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }),
220313
+ /**
220314
+ * Stop pulling this camera's audio and release the broker subscription.
220315
+ * Idempotent. A detach that never arrives is the one failure mode this
220316
+ * split adds, which is why `AudioChunkPlane` reaps a subscription nobody
220317
+ * drains rather than trusting it (D461).
220318
+ */
220319
+ detachDevice: require_sleep.method(zod.z.object({ deviceId: zod.z.number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }),
219620
220320
  isReady: require_sleep.method(zod.z.void(), zod.z.boolean()),
219621
220321
  dispose: require_sleep.method(zod.z.void(), zod.z.void(), { kind: "mutation" }),
219622
220322
  /**
@@ -248054,12 +248754,24 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
248054
248754
  addonId: null,
248055
248755
  access: "create"
248056
248756
  },
248757
+ "audioAnalyzer.attachDevice": {
248758
+ capName: "audio-analyzer",
248759
+ capScope: "system",
248760
+ addonId: null,
248761
+ access: "create"
248762
+ },
248057
248763
  "audioAnalyzer.classify": {
248058
248764
  capName: "audio-analyzer",
248059
248765
  capScope: "system",
248060
248766
  addonId: null,
248061
248767
  access: "view"
248062
248768
  },
248769
+ "audioAnalyzer.detachDevice": {
248770
+ capName: "audio-analyzer",
248771
+ capScope: "system",
248772
+ addonId: null,
248773
+ access: "create"
248774
+ },
248063
248775
  "audioAnalyzer.dispose": {
248064
248776
  capName: "audio-analyzer",
248065
248777
  capScope: "system",
@@ -254167,11 +254879,21 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
254167
254879
  form: "single",
254168
254880
  optional: false
254169
254881
  }],
254882
+ "audioAnalyzer.attachDevice": [{
254883
+ name: "deviceId",
254884
+ form: "single",
254885
+ optional: false
254886
+ }],
254170
254887
  "audioAnalyzer.classify": [{
254171
254888
  name: "deviceId",
254172
254889
  form: "single",
254173
254890
  optional: true
254174
254891
  }],
254892
+ "audioAnalyzer.detachDevice": [{
254893
+ name: "deviceId",
254894
+ form: "single",
254895
+ optional: false
254896
+ }],
254175
254897
  "audioMetrics.getCurrentSnapshot": [{
254176
254898
  name: "deviceId",
254177
254899
  form: "single",
@@ -256017,7 +256739,9 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
256017
256739
  var SYSTEM_SCOPE_DEVICE_METHODS = [
256018
256740
  "addonSettings.getDeviceSettings",
256019
256741
  "addonSettings.updateDeviceSettings",
256742
+ "audioAnalyzer.attachDevice",
256020
256743
  "audioAnalyzer.classify",
256744
+ "audioAnalyzer.detachDevice",
256021
256745
  "decoder.createSession",
256022
256746
  "deviceAdoption.release",
256023
256747
  "deviceAdoption.resync",
@@ -256634,6 +257358,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
256634
257358
  audioAnalyzer: {
256635
257359
  analyseChunk: (input) => dispatch("audioAnalyzer", "analyseChunk", "mutation", input),
256636
257360
  classify: (input) => dispatch("audioAnalyzer", "classify", "query", input),
257361
+ attachDevice: (input) => dispatch("audioAnalyzer", "attachDevice", "mutation", input),
256637
257362
  isReady: (input) => dispatch("audioAnalyzer", "isReady", "query", input),
256638
257363
  dispose: (input) => dispatch("audioAnalyzer", "dispose", "mutation", input),
256639
257364
  reprobeAudioEngine: (input) => dispatch("audioAnalyzer", "reprobeAudioEngine", "mutation", input)
@@ -257206,6 +257931,19 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
257206
257931
  }
257207
257932
  };
257208
257933
  }
257934
+ var AUDIO_SCALE_EPOCH_ISO = "2026-09-11T00:00:00.000Z";
257935
+ var AUDIO_SCALE_EPOCH_MS = Date.parse(AUDIO_SCALE_EPOCH_ISO);
257936
+ var G711_SCALE_CORRECTION_DB = {
257937
+ PCMU: 20 * Math.log10(4),
257938
+ PCMA: 20 * Math.log10(8)
257939
+ };
257940
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
257941
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
257942
+ }
257943
+ function audioScaleEraOf(timestampMs) {
257944
+ if (!Number.isFinite(timestampMs) || timestampMs <= 0) return "unknown";
257945
+ return timestampMs >= AUDIO_SCALE_EPOCH_MS ? "itu" : "pre-itu";
257946
+ }
257209
257947
  var AUDIO_KIND_PREFIX = "audio-";
257210
257948
  function normalizeAudioLabel(value) {
257211
257949
  return value.startsWith(AUDIO_KIND_PREFIX) ? value.slice(6) : value;
@@ -257216,7 +257954,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
257216
257954
  var NC_AUDIO_DB_MIN = -96;
257217
257955
  var NC_AUDIO_DB_MAX = 0;
257218
257956
  var NC_AUDIO_DB_STEP = 3;
257219
- var NC_AUDIO_DB_OFFERED = -55;
257957
+ var NC_AUDIO_DB_OFFERED = Math.round(ituDbfsFromPreEpoch("PCMU", -55));
257220
257958
  var NC_AUDIO_HIT_PERCENT_MIN = 1;
257221
257959
  var NC_AUDIO_HIT_PERCENT_MAX = 100;
257222
257960
  var NC_AUDIO_SAMPLING_MIN_SEC = 1;
@@ -257258,7 +257996,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
257258
257996
  const hasLabels = wantedLabels !== void 0 && wantedLabels.length > 0;
257259
257997
  const mode = patch.mode ?? (has(patch, "labels") && hasLabels ? "label" : has(patch, "dbThreshold") && wantedDb !== void 0 ? "level" : hasLabels ? "label" : wantedDb !== void 0 ? "level" : null);
257260
257998
  const labels = mode === "label" && hasLabels ? wantedLabels : void 0;
257261
- const dbThreshold = mode !== "level" ? void 0 : wantedDb ?? (patch.mode === "level" ? -55 : void 0);
257999
+ const dbThreshold = mode !== "level" ? void 0 : wantedDb ?? (patch.mode === "level" ? NC_AUDIO_DB_OFFERED : void 0);
257262
258000
  return {
257263
258001
  ...labels !== void 0 ? { labels: [...labels] } : {},
257264
258002
  ...dbThreshold !== void 0 ? { dbThreshold: clampInt(dbThreshold, NC_AUDIO_DB_MIN, 0) } : {},
@@ -257771,7 +258509,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
257771
258509
  var NC_AUDIO_SEED = {
257772
258510
  hitPercent: NC_AUDIO_DEFAULTS.hitPercent,
257773
258511
  samplingSeconds: NC_AUDIO_DEFAULTS.samplingSeconds,
257774
- dbThreshold: -55
258512
+ dbThreshold: NC_AUDIO_DB_OFFERED
257775
258513
  };
257776
258514
  function ruleSeedForSection(section) {
257777
258515
  switch (section) {
@@ -259867,8 +260605,11 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
259867
260605
  exports.ARCHIVED_DEBUG_NOTES_DEFAULT_LIMIT = ARCHIVED_DEBUG_NOTES_DEFAULT_LIMIT;
259868
260606
  exports.AUDIO_ANALYSIS_CAP_NAME = AUDIO_ANALYSIS_CAP_NAME;
259869
260607
  exports.AUDIO_BACKEND_CHOICES = AUDIO_BACKEND_CHOICES;
260608
+ exports.AUDIO_CHUNK_FORMATS = require_sleep.AUDIO_CHUNK_FORMATS;
259870
260609
  exports.AUDIO_MACRO_LABELS = AUDIO_MACRO_LABELS;
259871
260610
  exports.AUDIO_PRESETS = require_canonical_hash.AUDIO_PRESETS;
260611
+ exports.AUDIO_SCALE_EPOCH_ISO = AUDIO_SCALE_EPOCH_ISO;
260612
+ exports.AUDIO_SCALE_EPOCH_MS = AUDIO_SCALE_EPOCH_MS;
259872
260613
  exports.AccessoriesStatusSchema = AccessoriesStatusSchema;
259873
260614
  exports.AccessoryKind = AccessoryKind;
259874
260615
  exports.AddBrokerInputSchema = AddBrokerInputSchema;
@@ -259908,12 +260649,16 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
259908
260649
  exports.AttachmentSchema = AttachmentSchema;
259909
260650
  exports.AudioAnalysisResultSchema = AudioAnalysisResultSchema;
259910
260651
  exports.AudioAnalysisSettingsSchema = AudioAnalysisSettingsSchema;
260652
+ exports.AudioAttachDeviceInputSchema = AudioAttachDeviceInputSchema;
260653
+ exports.AudioAttachDeviceResultSchema = AudioAttachDeviceResultSchema;
260654
+ exports.AudioChunkFormatSchema = require_sleep.AudioChunkFormatSchema;
259911
260655
  exports.AudioChunkInputSchema = AudioChunkInputSchema;
259912
260656
  exports.AudioClassSummarySchema = AudioClassSummarySchema;
259913
260657
  exports.AudioClassificationLabelSchema = AudioClassificationLabelSchema;
259914
260658
  exports.AudioClassificationResultSchema = AudioClassificationResultSchema;
259915
260659
  exports.AudioCodecInfoSchema = AudioCodecInfoSchema;
259916
260660
  exports.AudioDecodeSessionConfigSchema = AudioDecodeSessionConfigSchema;
260661
+ exports.AudioDetachDeviceResultSchema = AudioDetachDeviceResultSchema;
259917
260662
  exports.AudioEncodeSchema = AudioEncodeSchema;
259918
260663
  exports.AudioEncodeSessionConfigSchema = AudioEncodeSessionConfigSchema;
259919
260664
  exports.AudioEncodedChunkSchema = AudioEncodedChunkSchema;
@@ -260227,6 +260972,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
260227
260972
  exports.FrameInputSchema = FrameInputSchema;
260228
260973
  exports.FrameLazyCountersSchema = FrameLazyCountersSchema;
260229
260974
  exports.FrameLazyMetricsSchema = FrameLazyMetricsSchema;
260975
+ exports.G711_SCALE_CORRECTION_DB = G711_SCALE_CORRECTION_DB;
260230
260976
  exports.GasStatusSchema = GasStatusSchema;
260231
260977
  exports.GetLoggingSettingsInputSchema = GetLoggingSettingsInputSchema;
260232
260978
  exports.GetStreamWithCodecInputSchema = GetStreamWithCodecInputSchema;
@@ -260615,6 +261361,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
260615
261361
  exports.REACHABILITY_POLL_INTERVAL_MS = REACHABILITY_POLL_INTERVAL_MS;
260616
261362
  exports.REACHABILITY_PROBE_TIMEOUT_MS = REACHABILITY_PROBE_TIMEOUT_MS;
260617
261363
  exports.RECOGNITION_TYPES = RECOGNITION_TYPES;
261364
+ exports.RECORDING_AUDIO_TRIGGER_OFFERED_DBFS = RECORDING_AUDIO_TRIGGER_OFFERED_DBFS;
260618
261365
  exports.RECORDING_EXPORT_MAX_READ_BYTES = RECORDING_EXPORT_MAX_READ_BYTES;
260619
261366
  exports.RECORDING_TIMELINE_BATCH_MAX = RECORDING_TIMELINE_BATCH_MAX;
260620
261367
  exports.REDACTED_SECRET = REDACTED_SECRET;
@@ -260966,6 +261713,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
260966
261713
  exports.assertTimelapseCadences = assertTimelapseCadences;
260967
261714
  exports.audioAnalysisCapability = audioAnalysisCapability;
260968
261715
  exports.audioAnalyzerCapability = audioAnalyzerCapability;
261716
+ exports.audioChunkBytesPerSample = require_sleep.audioChunkBytesPerSample;
260969
261717
  exports.audioCodecCapability = audioCodecCapability;
260970
261718
  exports.audioIsFailClosed = audioIsFailClosed;
260971
261719
  exports.audioKindId = audioKindId;
@@ -260974,6 +261722,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
260974
261722
  exports.audioModeOf = audioModeOf;
260975
261723
  exports.audioOrDefaults = audioOrDefaults;
260976
261724
  exports.audioPlanFromEncodeProfile = require_canonical_hash.audioPlanFromEncodeProfile;
261725
+ exports.audioScaleEraOf = audioScaleEraOf;
260977
261726
  exports.authProviderCapability = authProviderCapability;
260978
261727
  exports.autoAssignProfiles = autoAssignProfiles;
260979
261728
  exports.automationControlCapability = automationControlCapability;
@@ -261101,6 +261850,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
261101
261850
  exports.eventsCapability = eventsCapability;
261102
261851
  exports.evictionPolicyForMode = evictionPolicyForMode;
261103
261852
  exports.evictionPolicyOfLocation = evictionPolicyOfLocation;
261853
+ exports.expandAudioChunkToF32le = require_sleep.expandAudioChunkToF32le;
261104
261854
  exports.expandCapMethods = require_sleep.expandCapMethods;
261105
261855
  exports.extractNestedAddonId = extractNestedAddonId;
261106
261856
  exports.extractSourceInfoFromMetadata = extractSourceInfoFromMetadata;
@@ -261138,6 +261888,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
261138
261888
  exports.invocationFromEncodeProfile = require_canonical_hash.invocationFromEncodeProfile;
261139
261889
  exports.isAgentOnlyPlacement = isAgentOnlyPlacement;
261140
261890
  exports.isArrayOutputSchema = isArrayOutputSchema;
261891
+ exports.isAudioChunkFormat = require_sleep.isAudioChunkFormat;
261141
261892
  exports.isAudioLabelSelected = isAudioLabelSelected;
261142
261893
  exports.isAudioRule = isAudioRule;
261143
261894
  exports.isBaseConditionKey = isBaseConditionKey;
@@ -261164,6 +261915,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
261164
261915
  exports.isStorageLocationMode = isStorageLocationMode;
261165
261916
  exports.isSystemDelivery = isSystemDelivery;
261166
261917
  exports.isVoidInput = isVoidInput;
261918
+ exports.ituDbfsFromPreEpoch = ituDbfsFromPreEpoch;
261167
261919
  exports.jobKindSchema = jobKindSchema;
261168
261920
  exports.kebabToCamel = kebabToCamel;
261169
261921
  exports.knownValues = knownValues;
@@ -356819,6 +357571,7 @@ var require_parser2 = __commonJS({
356819
357571
  "use strict";
356820
357572
  var Writable = __require("stream").Writable;
356821
357573
  var { resolvePacketType } = require_constants9();
357574
+ var HEADER_BYTES = 6;
356822
357575
  var Parser = class extends Writable {
356823
357576
  /**
356824
357577
  * Create an instance of Parser
@@ -356828,40 +357581,57 @@ var require_parser2 = __commonJS({
356828
357581
  constructor(options, maxPacketSize) {
356829
357582
  super(options);
356830
357583
  this.maxPacketSize = maxPacketSize;
356831
- this.buf = null;
357584
+ this.bufs = [];
357585
+ this.bufLen = 0;
357586
+ }
357587
+ /** The first `HEADER_BYTES` pending bytes, without flattening the rest. */
357588
+ _header() {
357589
+ const first = this.bufs[0];
357590
+ if (first.length >= HEADER_BYTES) return first;
357591
+ const head = Buffer.allocUnsafe(HEADER_BYTES);
357592
+ let written = 0;
357593
+ for (let i = 0; i < this.bufs.length && written < HEADER_BYTES; i++) {
357594
+ const b = this.bufs[i];
357595
+ const take = Math.min(HEADER_BYTES - written, b.length);
357596
+ b.copy(head, written, 0, take);
357597
+ written += take;
357598
+ }
357599
+ return head;
356832
357600
  }
356833
357601
  _write(chunk, encoding, cb) {
356834
- let packet = chunk;
356835
- if (this.buf && this.buf.length > 0) {
356836
- packet = Buffer.concat([this.buf, chunk]);
356837
- this.buf = null;
356838
- }
356839
- while (packet.length > 0) {
356840
- if (packet.length < 6) {
356841
- this.buf = Buffer.from(packet);
357602
+ if (this.bufLen > 0) {
357603
+ this.bufs.push(chunk);
357604
+ } else {
357605
+ this.bufs = [chunk];
357606
+ }
357607
+ this.bufLen += chunk.length;
357608
+ while (this.bufLen > 0) {
357609
+ if (this.bufLen < HEADER_BYTES) {
356842
357610
  return cb();
356843
357611
  }
356844
- if (this.maxPacketSize && packet.length > this.maxPacketSize) {
357612
+ if (this.maxPacketSize && this.bufLen > this.maxPacketSize) {
356845
357613
  return cb(
356846
357614
  new Error(
356847
- `Incoming packet is larger than the 'maxPacketSize' limit (${packet.length} > ${this.maxPacketSize})!`
357615
+ `Incoming packet is larger than the 'maxPacketSize' limit (${this.bufLen} > ${this.maxPacketSize})!`
356848
357616
  )
356849
357617
  );
356850
357618
  }
356851
- const crc = packet[1] ^ packet[2] ^ packet[3] ^ packet[4] ^ packet[5];
356852
- if (crc !== packet[0]) {
357619
+ const header = this._header();
357620
+ const crc = header[1] ^ header[2] ^ header[3] ^ header[4] ^ header[5];
357621
+ if (crc !== header[0]) {
356853
357622
  return cb(new Error("Invalid packet CRC! " + crc));
356854
357623
  }
356855
- const length = packet.readInt32BE(1);
356856
- if (packet.length >= length) {
356857
- const msg = packet.slice(6, length);
356858
- const type = resolvePacketType(packet[5]);
356859
- this.emit("data", type, msg);
356860
- packet = packet.slice(length);
356861
- } else {
356862
- this.buf = Buffer.from(packet);
357624
+ const length = header.readInt32BE(1);
357625
+ if (this.bufLen < length) {
356863
357626
  return cb();
356864
357627
  }
357628
+ const packet = this.bufs.length === 1 ? this.bufs[0] : Buffer.concat(this.bufs, this.bufLen);
357629
+ const msg = packet.slice(HEADER_BYTES, length);
357630
+ const type = resolvePacketType(packet[5]);
357631
+ this.emit("data", type, msg);
357632
+ const rest = packet.slice(length);
357633
+ this.bufs = rest.length > 0 ? [rest] : [];
357634
+ this.bufLen = rest.length;
356865
357635
  }
356866
357636
  cb();
356867
357637
  }