@camstack/system 1.2.219 → 1.2.221

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/addon-runner.js +2 -2
  2. package/dist/addon-runner.mjs +2 -2
  3. package/dist/addon-utils.js +1 -1
  4. package/dist/addon-utils.mjs +1 -1
  5. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  8. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  9. package/dist/builtins/alerts/alerts.addon.js +1 -1
  10. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  11. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  12. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  13. package/dist/builtins/console-logging/index.js +1 -1
  14. package/dist/builtins/console-logging/index.mjs +1 -1
  15. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  16. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  17. package/dist/builtins/device-manager/device-manager.addon.js +2 -2
  18. package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  19. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  20. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  21. package/dist/builtins/hub-forwarder/index.js +1 -1
  22. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  23. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  24. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  25. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  26. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  27. package/dist/builtins/local-network/local-network.addon.js +1 -1
  28. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  29. package/dist/builtins/loki-logging/index.js +1 -1
  30. package/dist/builtins/loki-logging/index.mjs +1 -1
  31. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  32. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  33. package/dist/builtins/platform-probe/index.js +1 -1
  34. package/dist/builtins/platform-probe/index.mjs +1 -1
  35. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  36. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  37. package/dist/builtins/snapshot/index.js +1 -1
  38. package/dist/builtins/snapshot/index.mjs +1 -1
  39. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  40. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  41. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  42. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  43. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  44. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  45. package/dist/builtins/system-config/system-config.addon.js +1 -1
  46. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  47. package/dist/builtins/winston-logging/index.js +1 -1
  48. package/dist/builtins/winston-logging/index.mjs +1 -1
  49. package/dist/{custom-action-registry-DKWhaWL1.js → custom-action-registry-DvVMHLfJ.js} +1 -1
  50. package/dist/{custom-action-registry-B6gOtUWA.mjs → custom-action-registry-DvtOs-tp.mjs} +1 -1
  51. package/dist/{dist-B17W9ngu.js → dist-0sWJNwme.js} +261 -4
  52. package/dist/{dist-Cyz5_i7z.mjs → dist-T9GvfhgV.mjs} +261 -4
  53. package/dist/index.js +71 -32
  54. package/dist/index.mjs +65 -33
  55. package/dist/kernel/gc-census.d.ts +144 -0
  56. package/dist/kernel/heap-watch.d.ts +8 -0
  57. package/dist/kernel/socket-plane-report.d.ts +37 -0
  58. package/dist/kernel/transport/cap-action-census.d.ts +218 -0
  59. package/dist/kernel/transport/cap-child-index.d.ts +49 -0
  60. package/dist/kernel/transport/index.d.ts +2 -0
  61. package/dist/kernel/transport/local-child-registry.d.ts +63 -4
  62. package/dist/kernel/transport/local-transport.d.ts +9 -0
  63. package/dist/kernel/transport/socket-channel.d.ts +21 -0
  64. package/dist/{manifest-system-deps-g_nK0xsF.js → manifest-system-deps-DfpwaXkh.js} +550 -27
  65. package/dist/{manifest-system-deps-C7dihwWT.mjs → manifest-system-deps-iadzxSBr.mjs} +509 -28
  66. package/dist/{retired-settings-keys-CjvB7Etx.js → retired-settings-keys-Dh-XMfFx.js} +1 -1
  67. package/dist/{retired-settings-keys-BCYUrdsA.mjs → retired-settings-keys-DmVZAH9M.mjs} +1 -1
  68. package/package.json +1 -1
@@ -675,6 +675,86 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
675
675
  EventCategory["ModelConvertProgress"] = "model-convert.progress";
676
676
  return EventCategory;
677
677
  }({});
678
+ //#endregion
679
+ //#region ../types/dist/sleep-BnujYGPe.mjs
680
+ /**
681
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
682
+ * window to float samples (D455).
683
+ *
684
+ * ## Why a format at all
685
+ *
686
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
687
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
688
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
689
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
690
+ * the plane carried four times the source. The plane crosses hub-main twice on
691
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
692
+ *
693
+ * So the plane carries the source BYTES too, and whoever needs floats expands
694
+ * them where it needs them. That is the same argument D450 made for the rate,
695
+ * one step further along the same wire.
696
+ *
697
+ * ## Why the expansion lives here
698
+ *
699
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
700
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
701
+ * `AudioChunkPlane` expands per subscription) and
702
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
703
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
704
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
705
+ * into their own dist (`self-contained` externals), so this travels with a
706
+ * `camstack deploy` and needs no published server.
707
+ *
708
+ * A second μ-law table anywhere else is the defect this module exists to
709
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
710
+ * direction for the WebRTC egress — a different transform, not a copy.)
711
+ *
712
+ * ## Absent means f32le
713
+ *
714
+ * `format` is optional on the wire and its absence means `f32le` — today's
715
+ * bytes, byte for byte. A peer that never heard of the field is served what it
716
+ * has always been served, because the broker only emits a coded window to a
717
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
718
+ * That is the D448 `rawForward` negotiation, and it is what makes this
719
+ * deployable one addon at a time across three nodes.
720
+ */
721
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
722
+ var AUDIO_CHUNK_FORMATS = [
723
+ "f32le",
724
+ "pcmu",
725
+ "pcma"
726
+ ];
727
+ /**
728
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
729
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
730
+ *
731
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
732
+ * it buffers the coded bytes and the plane's consumers expand.
733
+ */
734
+ function buildUlawTable() {
735
+ const table = new Float32Array(256);
736
+ for (let i = 0; i < 256; i++) {
737
+ const complemented = ~i & 255;
738
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
739
+ const exponent = complemented >> 4 & 7;
740
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
741
+ }
742
+ return table;
743
+ }
744
+ /** Build the A-law decode table (ITU-T G.711). */
745
+ function buildAlawTable() {
746
+ const table = new Float32Array(256);
747
+ for (let i = 0; i < 256; i++) {
748
+ const xored = i ^ 85;
749
+ const sign = (xored & 128) !== 0 ? 1 : -1;
750
+ const exponent = xored >> 4 & 7;
751
+ const mantissa = xored & 15;
752
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
753
+ }
754
+ return table;
755
+ }
756
+ buildUlawTable();
757
+ buildAlawTable();
678
758
  /** Lookup map for well-known tabs by ID. */
679
759
  var WELL_KNOWN_TAB_MAP = Object.fromEntries([
680
760
  {
@@ -1975,11 +2055,20 @@ var SubscribeFramesResultSchema = z.object({
1975
2055
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
1976
2056
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
1977
2057
  */
2058
+ var AudioChunkFormatSchema = z.enum(AUDIO_CHUNK_FORMATS);
1978
2059
  var DecodedAudioChunkSchema = z.object({
1979
2060
  data: z.instanceof(Uint8Array),
1980
2061
  sampleRate: z.number().int().positive(),
1981
2062
  channels: z.number().int().positive(),
1982
- timestamp: z.number()
2063
+ timestamp: z.number(),
2064
+ /**
2065
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
2066
+ * byte, for any peer that never heard of this field. A coded window
2067
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
2068
+ * subscription that DECLARED it accepts one, so absence can never mean
2069
+ * "coded bytes a consumer will read as floats" (D455).
2070
+ */
2071
+ format: AudioChunkFormatSchema.optional()
1983
2072
  });
1984
2073
  /**
1985
2074
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -1991,7 +2080,18 @@ var DecodedAudioChunkSchema = z.object({
1991
2080
  var SubscribeAudioChunksInputSchema = z.object({
1992
2081
  brokerId: z.string(),
1993
2082
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
1994
- tag: z.string().optional()
2083
+ tag: z.string().optional(),
2084
+ /**
2085
+ * Byte formats this subscriber can READ, best first. The broker serves the
2086
+ * chunk's own format when it is in this list and expands to `f32le`
2087
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
2088
+ *
2089
+ * Absent (or without the source format) means `f32le` — the behaviour every
2090
+ * subscriber had before D455, unchanged. This is the negotiation half of
2091
+ * the source-bytes lever: it is what lets the broker and its consumers
2092
+ * deploy one at a time across three nodes.
2093
+ */
2094
+ accept: z.array(AudioChunkFormatSchema).readonly().optional()
1995
2095
  });
1996
2096
  /** Result of `stream-broker.subscribeAudioChunks`. */
1997
2097
  var SubscribeAudioChunksResultSchema = z.object({
@@ -7366,6 +7466,51 @@ var AudioAnalysisSettingsSchema = z.object({
7366
7466
  minConfidence: z.number().min(0).max(1).default(.3),
7367
7467
  allowedClasses: z.array(z.string()).default([])
7368
7468
  });
7469
+ /**
7470
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
7471
+ *
7472
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
7473
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
7474
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
7475
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
7476
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
7477
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
7478
+ * way to the one expansion that feeds the model.
7479
+ *
7480
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
7481
+ * window, the per-device node assignment, the settings read) and therefore
7482
+ * still owns the attach/detach pair. It no longer owns the bytes.
7483
+ */
7484
+ var AudioAttachDeviceInputSchema = z.object({
7485
+ deviceId: z.number(),
7486
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
7487
+ brokerId: z.string(),
7488
+ /**
7489
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
7490
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
7491
+ * the orchestrator's poller pinned them before the move.
7492
+ */
7493
+ ingestNodeId: z.string(),
7494
+ /**
7495
+ * Resolved once by the orchestrator at attach time, exactly as it was read
7496
+ * once per subscription before D461. The analyzer does NOT re-resolve per
7497
+ * window: a settings change re-attaches, which is what always happened.
7498
+ */
7499
+ settings: AudioAnalysisSettingsSchema
7500
+ });
7501
+ var AudioAttachDeviceResultSchema = z.object({
7502
+ /** False only when the analyzer is shutting down and refused to attach. */
7503
+ attached: z.boolean(),
7504
+ /**
7505
+ * True when the attachment replaced a live one for the same device. An
7506
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
7507
+ * double the broker's fanout and neither would know about the other.
7508
+ */
7509
+ replaced: z.boolean()
7510
+ });
7511
+ var AudioDetachDeviceResultSchema = z.object({
7512
+ /** False when no attachment existed — detach is idempotent. */
7513
+ detached: z.boolean() });
7369
7514
  var AudioClassificationResultSchema = z.object({
7370
7515
  labels: z.array(AudioClassificationLabelSchema).readonly(),
7371
7516
  rawLabels: z.array(AudioClassificationLabelSchema).readonly().optional(),
@@ -7381,6 +7526,21 @@ var audioAnalyzerCapability = {
7381
7526
  settings: AudioAnalysisSettingsSchema
7382
7527
  }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }),
7383
7528
  classify: method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }),
7529
+ /**
7530
+ * Start pulling this camera's audio from the broker, in THIS process.
7531
+ * Returns as soon as the attachment exists — the first
7532
+ * `subscribeAudioChunks` retries with backoff behind it, because the
7533
+ * broker for a camStream may not be registered yet (that tolerance moved
7534
+ * with the poller, D461). Replaces any live attachment for the device.
7535
+ */
7536
+ attachDevice: method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }),
7537
+ /**
7538
+ * Stop pulling this camera's audio and release the broker subscription.
7539
+ * Idempotent. A detach that never arrives is the one failure mode this
7540
+ * split adds, which is why `AudioChunkPlane` reaps a subscription nobody
7541
+ * drains rather than trusting it (D461).
7542
+ */
7543
+ detachDevice: method(z.object({ deviceId: z.number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }),
7384
7544
  isReady: method(z.void(), z.boolean()),
7385
7545
  dispose: method(z.void(), z.void(), { kind: "mutation" }),
7386
7546
  /**
@@ -20206,6 +20366,14 @@ var NativeCropResultSchema = z.object({
20206
20366
  * set `encodeJpeg: true`; `bytes` is then absent.
20207
20367
  */
20208
20368
  jpeg: z.string().optional(),
20369
+ /**
20370
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20371
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20372
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20373
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20374
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20375
+ */
20376
+ jpegBytes: z.instanceof(Uint8Array).optional(),
20209
20377
  width: z.number().int().positive(),
20210
20378
  height: z.number().int().positive(),
20211
20379
  /**
@@ -20272,7 +20440,14 @@ var ParkTrackFrameResultSchema = z.discriminatedUnion("parked", [z.object({
20272
20440
  })]);
20273
20441
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20274
20442
  var ParkedTrackFrameSchema = z.object({
20275
- jpeg: z.string(),
20443
+ /**
20444
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20445
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20446
+ * Exactly one of the two is present.
20447
+ */
20448
+ jpeg: z.string().optional(),
20449
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20450
+ jpegBytes: z.instanceof(Uint8Array).optional(),
20276
20451
  width: z.number().int().positive(),
20277
20452
  height: z.number().int().positive(),
20278
20453
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -20923,6 +21098,13 @@ var pipelineRunnerCapability = {
20923
21098
  bbox: NativeCropBboxSchema,
20924
21099
  maxWidth: z.number().int().positive().optional(),
20925
21100
  /**
21101
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21102
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21103
+ * wire — never assume consent: a pre-D462 caller parses the field as
21104
+ * base64 and bytes would decode to garbage rather than fail.
21105
+ */
21106
+ acceptJpegBytes: z.boolean().optional(),
21107
+ /**
20926
21108
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
20927
21109
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
20928
21110
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21095,7 +21277,14 @@ var pipelineRunnerCapability = {
21095
21277
  getParkedTrackFrame: method(z.object({
21096
21278
  deviceId: z.number(),
21097
21279
  trackId: z.string(),
21098
- kind: ParkedFrameKindSchema
21280
+ kind: ParkedFrameKindSchema,
21281
+ /**
21282
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21283
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21284
+ * wire — never assume consent: a pre-D462 caller parses the field as
21285
+ * base64 and bytes would decode to garbage rather than fail.
21286
+ */
21287
+ acceptJpegBytes: z.boolean().optional()
21099
21288
  }), ParkedTrackFrameSchema.nullable()),
21100
21289
  /**
21101
21290
  * Drop every parcel of a track — the hub closed it. Idempotent. A track
@@ -36736,12 +36925,24 @@ var METHOD_ACCESS_MAP = Object.freeze({
36736
36925
  addonId: null,
36737
36926
  access: "create"
36738
36927
  },
36928
+ "audioAnalyzer.attachDevice": {
36929
+ capName: "audio-analyzer",
36930
+ capScope: "system",
36931
+ addonId: null,
36932
+ access: "create"
36933
+ },
36739
36934
  "audioAnalyzer.classify": {
36740
36935
  capName: "audio-analyzer",
36741
36936
  capScope: "system",
36742
36937
  addonId: null,
36743
36938
  access: "view"
36744
36939
  },
36940
+ "audioAnalyzer.detachDevice": {
36941
+ capName: "audio-analyzer",
36942
+ capScope: "system",
36943
+ addonId: null,
36944
+ access: "create"
36945
+ },
36745
36946
  "audioAnalyzer.dispose": {
36746
36947
  capName: "audio-analyzer",
36747
36948
  capScope: "system",
@@ -42585,11 +42786,21 @@ Object.freeze({
42585
42786
  form: "single",
42586
42787
  optional: false
42587
42788
  }],
42789
+ "audioAnalyzer.attachDevice": [{
42790
+ name: "deviceId",
42791
+ form: "single",
42792
+ optional: false
42793
+ }],
42588
42794
  "audioAnalyzer.classify": [{
42589
42795
  name: "deviceId",
42590
42796
  form: "single",
42591
42797
  optional: true
42592
42798
  }],
42799
+ "audioAnalyzer.detachDevice": [{
42800
+ name: "deviceId",
42801
+ form: "single",
42802
+ optional: false
42803
+ }],
42593
42804
  "audioMetrics.getCurrentSnapshot": [{
42594
42805
  name: "deviceId",
42595
42806
  form: "single",
@@ -44733,6 +44944,52 @@ var SESSION_ONLY_POLICY = {
44733
44944
  durability: "session",
44734
44945
  volatileFields: []
44735
44946
  };
44947
+ var G711_SCALE_CORRECTION_DB = {
44948
+ PCMU: 20 * Math.log10(4),
44949
+ PCMA: 20 * Math.log10(8)
44950
+ };
44951
+ /**
44952
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
44953
+ * same intent on the ITU-T scale (D460).
44954
+ *
44955
+ * ## When this applies, and when it is the wrong thing to reach for
44956
+ *
44957
+ * An absolute-dBFS number in this repo is one of two things, and only one of
44958
+ * them converts:
44959
+ *
44960
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
44961
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
44962
+ * after. The defect was never in the number; it was that 19 of this hub's
44963
+ * 25 cameras did not obey it. Converting such a number takes something
44964
+ * correct and makes it wrong, in order to preserve a bug.
44965
+ * - **A measurement taken through the old decoder** — a value someone read
44966
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
44967
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
44968
+ * louder. That is what this function is for.
44969
+ *
44970
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
44971
+ * and it cannot be answered from the number. It is answered by the comment the
44972
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
44973
+ * mandatory.
44974
+ *
44975
+ * ## Why a function and not a typed-in number
44976
+ *
44977
+ * `-55 + 12.04` written into a source file is, six months later, completely
44978
+ * indistinguishable from a threshold somebody simply preferred. Calling this
44979
+ * keeps the derivation, the law, and the original measurement all visible at
44980
+ * the call site, so a future reader can disagree with the *premise* instead of
44981
+ * having to reverse-engineer the sum.
44982
+ *
44983
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
44984
+ * it is declared. It must never be applied to a live sample or a stored
44985
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
44986
+ * adjusting numbers the decoder already got right is the original defect with
44987
+ * an extra place to argue with (D459).
44988
+ */
44989
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
44990
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
44991
+ }
44992
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
44736
44993
  /** Schema defaults — an untouched sub-field must author exactly these. */
44737
44994
  var NC_AUDIO_DEFAULTS = {
44738
44995
  hitPercent: 60,
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-Cek0wNdY.js");
3
- const require_dist = require("./dist-B17W9ngu.js");
3
+ const require_dist = require("./dist-0sWJNwme.js");
4
4
  const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
5
5
  require("./builtins/alerts/index.js");
6
6
  const require_formatter = require("./formatter-DqAKDlvN.js");
@@ -27,9 +27,9 @@ require("./builtins/system-config/index.js");
27
27
  const require_builtins_winston_logging_index = require("./builtins/winston-logging/index.js");
28
28
  const require_event_loop_stall_monitor = require("./event-loop-stall-monitor-CAsHdMwP.js");
29
29
  const require_tls$1 = require("./tls-BFs4PzoW.js");
30
- const require_manifest_system_deps = require("./manifest-system-deps-g_nK0xsF.js");
30
+ const require_manifest_system_deps = require("./manifest-system-deps-DfpwaXkh.js");
31
31
  const require_resource_monitor = require("./resource-monitor-LVE1BoLs.js");
32
- const require_custom_action_registry = require("./custom-action-registry-DKWhaWL1.js");
32
+ const require_custom_action_registry = require("./custom-action-registry-DvVMHLfJ.js");
33
33
  let zod = require("zod");
34
34
  let node_crypto = require("node:crypto");
35
35
  let _camstack_types_node = require("@camstack/types/node");
@@ -78885,16 +78885,36 @@ var require_udp_broadcaster = /* @__PURE__ */ require_chunk.__commonJSMin(((expo
78885
78885
  var require_parser = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
78886
78886
  var Writable = require("stream").Writable;
78887
78887
  var { resolvePacketType } = require_constants();
78888
- /**
78889
- * Import types
78890
- *
78891
- * @typedef {import("./parser")} ParserClass
78892
- */
78888
+ /** Moleculer TCP framing: CRC byte, 4-byte BE total length, type byte, payload. */
78889
+ var HEADER_BYTES = 6;
78893
78890
  /**
78894
78891
  * TCP packet parser
78895
78892
  * @class Parser
78896
78893
  * @extends {Writable}
78897
78894
  * @implements {ParserClass}
78895
+ *
78896
+ * ── CamStack patch (D457) — the accumulator is no longer quadratic ─────────
78897
+ *
78898
+ * The shipped `_write` did, ONCE PER SOCKET CHUNK that left a partial packet:
78899
+ *
78900
+ * packet = Buffer.concat([this.buf, chunk]); // copies the whole pending
78901
+ * this.buf = Buffer.from(packet); // copies it AGAIN
78902
+ *
78903
+ * so a message of M bytes arriving in chunks of c copied ~2·M²/2c bytes on the
78904
+ * receiving event loop — quadratic in the chunk COUNT. On CamStack's hub the
78905
+ * mesh carries base64 JPEG cross-node (`pipelineRunner.getNativeCrop`
78906
+ * with `encodeJpeg`, `pipelineRunner.runStatelessStep{frameJpeg}`) at
78907
+ * `maxPacketSize: 10 MiB`, and a 50 s V8 profile of hub-main put **20.8 % of
78908
+ * its busy main thread inside this one function**.
78909
+ *
78910
+ * The fix is the same one CamStack applied to its own UDS `FrameDecoder`:
78911
+ * hold the pending chunks in a LIST, concatenate ONCE when a whole packet is
78912
+ * available, and never at all while one is still incomplete. Everything else —
78913
+ * the framing, the CRC check and its position, the `maxPacketSize` rule
78914
+ * (accumulated bytes, not the declared length, exactly as before), the `data`
78915
+ * event shape, the error text — is byte-for-byte the original behaviour, and
78916
+ * `packages/system/src/kernel/__tests__/moleculer/mesh-tcp-parser.spec.ts`
78917
+ * asserts each of those cases alongside the copy accounting.
78898
78918
  */
78899
78919
  var Parser = class extends Writable {
78900
78920
  /**
@@ -78905,32 +78925,44 @@ var require_parser = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
78905
78925
  constructor(options, maxPacketSize) {
78906
78926
  super(options);
78907
78927
  this.maxPacketSize = maxPacketSize;
78908
- this.buf = null;
78928
+ /** Pending chunks, newest last. Never concatenated until a packet completes. */
78929
+ this.bufs = [];
78930
+ /** Total bytes across `bufs` — the old `this.buf.length`. */
78931
+ this.bufLen = 0;
78932
+ }
78933
+ /** The first `HEADER_BYTES` pending bytes, without flattening the rest. */
78934
+ _header() {
78935
+ const first = this.bufs[0];
78936
+ if (first.length >= HEADER_BYTES) return first;
78937
+ const head = Buffer.allocUnsafe(HEADER_BYTES);
78938
+ let written = 0;
78939
+ for (let i = 0; i < this.bufs.length && written < HEADER_BYTES; i++) {
78940
+ const b = this.bufs[i];
78941
+ const take = Math.min(HEADER_BYTES - written, b.length);
78942
+ b.copy(head, written, 0, take);
78943
+ written += take;
78944
+ }
78945
+ return head;
78909
78946
  }
78910
78947
  _write(chunk, encoding, cb) {
78911
- let packet = chunk;
78912
- if (this.buf && this.buf.length > 0) {
78913
- packet = Buffer.concat([this.buf, chunk]);
78914
- this.buf = null;
78915
- }
78916
- while (packet.length > 0) {
78917
- if (packet.length < 6) {
78918
- this.buf = Buffer.from(packet);
78919
- return cb();
78920
- }
78921
- if (this.maxPacketSize && packet.length > this.maxPacketSize) return cb(/* @__PURE__ */ new Error(`Incoming packet is larger than the 'maxPacketSize' limit (${packet.length} > ${this.maxPacketSize})!`));
78922
- const crc = packet[1] ^ packet[2] ^ packet[3] ^ packet[4] ^ packet[5];
78923
- if (crc !== packet[0]) return cb(/* @__PURE__ */ new Error("Invalid packet CRC! " + crc));
78924
- const length = packet.readInt32BE(1);
78925
- if (packet.length >= length) {
78926
- const msg = packet.slice(6, length);
78927
- const type = resolvePacketType(packet[5]);
78928
- this.emit("data", type, msg);
78929
- packet = packet.slice(length);
78930
- } else {
78931
- this.buf = Buffer.from(packet);
78932
- return cb();
78933
- }
78948
+ if (this.bufLen > 0) this.bufs.push(chunk);
78949
+ else this.bufs = [chunk];
78950
+ this.bufLen += chunk.length;
78951
+ while (this.bufLen > 0) {
78952
+ if (this.bufLen < HEADER_BYTES) return cb();
78953
+ if (this.maxPacketSize && this.bufLen > this.maxPacketSize) return cb(/* @__PURE__ */ new Error(`Incoming packet is larger than the 'maxPacketSize' limit (${this.bufLen} > ${this.maxPacketSize})!`));
78954
+ const header = this._header();
78955
+ const crc = header[1] ^ header[2] ^ header[3] ^ header[4] ^ header[5];
78956
+ if (crc !== header[0]) return cb(/* @__PURE__ */ new Error("Invalid packet CRC! " + crc));
78957
+ const length = header.readInt32BE(1);
78958
+ if (this.bufLen < length) return cb();
78959
+ const packet = this.bufs.length === 1 ? this.bufs[0] : Buffer.concat(this.bufs, this.bufLen);
78960
+ const msg = packet.slice(HEADER_BYTES, length);
78961
+ const type = resolvePacketType(packet[5]);
78962
+ this.emit("data", type, msg);
78963
+ const rest = packet.slice(length);
78964
+ this.bufs = rest.length > 0 ? [rest] : [];
78965
+ this.bufLen = rest.length;
78934
78966
  }
78935
78967
  cb();
78936
78968
  }
@@ -95777,6 +95809,8 @@ exports.AddonRouteRegistry = AddonRouteRegistry;
95777
95809
  exports.AlertCenterAddon = require_builtins_alerts_alerts_addon.AlertCenterAddon;
95778
95810
  exports.ApiKeyManager = require_builtins_local_auth_local_auth_addon.ApiKeyManager;
95779
95811
  exports.AuthManager = require_builtins_local_auth_local_auth_addon.AuthManager;
95812
+ exports.CAP_ACTION_OVERFLOW_LABEL = require_manifest_system_deps.CAP_ACTION_OVERFLOW_LABEL;
95813
+ exports.CAP_ACTION_UNLABELLED = require_manifest_system_deps.CAP_ACTION_UNLABELLED;
95780
95814
  exports.CA_COMMON_NAME = require_tls$1.CA_COMMON_NAME;
95781
95815
  exports.CA_VALIDITY_DAYS = require_tls$1.CA_VALIDITY_DAYS;
95782
95816
  exports.CLUSTER_SECRET_MISMATCH_TYPE = CLUSTER_SECRET_MISMATCH_TYPE;
@@ -95804,6 +95838,7 @@ exports.DataPlaneRegistry = DataPlaneRegistry;
95804
95838
  exports.DeviceManagerAddon = require_builtins_device_manager_device_manager_addon.DeviceManagerAddon;
95805
95839
  exports.DeviceRegistry = require_manifest_system_deps.DeviceRegistry;
95806
95840
  exports.DeviceStore = require_builtins_sqlite_storage_index.DeviceStore$1;
95841
+ exports.EMPTY_CAP_ACTION_READING = require_manifest_system_deps.EMPTY_CAP_ACTION_READING;
95807
95842
  exports.EMPTY_SOCKET_DIRECTION = require_manifest_system_deps.EMPTY_SOCKET_DIRECTION;
95808
95843
  exports.EMPTY_SOCKET_PLANE_BASELINE = require_manifest_system_deps.EMPTY_SOCKET_PLANE_BASELINE;
95809
95844
  exports.EVENT_PLANE_TOP_N = require_manifest_system_deps.EVENT_PLANE_TOP_N;
@@ -95848,6 +95883,7 @@ exports.LogRingBuffer = LogRingBuffer;
95848
95883
  exports.LoggingGate = LoggingGate;
95849
95884
  exports.LokiDestination = require_builtins_loki_logging_index.LokiDestination$1;
95850
95885
  exports.LokiLoggingAddon = require_builtins_loki_logging_index.LokiLoggingAddon$1;
95886
+ exports.MAX_CAP_ACTIONS_PER_PEER = require_manifest_system_deps.MAX_CAP_ACTIONS_PER_PEER;
95851
95887
  exports.MAX_LEAF_VALIDITY_DAYS = require_tls$1.MAX_LEAF_VALIDITY_DAYS;
95852
95888
  exports.MESH_QUEUE_TOP_N = require_manifest_system_deps.MESH_QUEUE_TOP_N;
95853
95889
  exports.METHOD_ACCESS_MAP = require_dist.METHOD_ACCESS_MAP;
@@ -95936,6 +95972,7 @@ exports.builderMountedCapNames = builderMountedCapNames;
95936
95972
  exports.callRegisterNodeWithRetry = callRegisterNodeWithRetry;
95937
95973
  exports.callWithServiceDiscovery = require_manifest_system_deps.callWithServiceDiscovery;
95938
95974
  exports.canServeDataPlane = canServeDataPlane;
95975
+ exports.capActionLabel = require_manifest_system_deps.capActionLabel;
95939
95976
  exports.capActionName = require_manifest_system_deps.capActionName;
95940
95977
  exports.capActionSuffix = require_manifest_system_deps.capActionSuffix;
95941
95978
  exports.capBareAction = require_manifest_system_deps.capBareAction;
@@ -95958,6 +95995,7 @@ exports.createArrayBufferCensusGate = require_manifest_system_deps.createArrayBu
95958
95995
  exports.createAuthenticatedFileServer = require_event_loop_stall_monitor.createAuthenticatedFileServer;
95959
95996
  exports.createBroker = createBroker;
95960
95997
  exports.createBrokerDeviceManagerApi = require_manifest_system_deps.createBrokerDeviceManagerApi;
95998
+ exports.createCapActionCensus = require_manifest_system_deps.createCapActionCensus;
95961
95999
  exports.createCoreCapService = createCoreCapService;
95962
96000
  exports.createDeferredHeapWatchSink = require_manifest_system_deps.createDeferredHeapWatchSink;
95963
96001
  exports.createDoorSettingsView = createDoorSettingsView;
@@ -95992,6 +96030,7 @@ exports.deriveAgentListenPort = deriveAgentListenPort;
95992
96030
  exports.describeProviderKindDrift = describeProviderKindDrift;
95993
96031
  exports.describeRss = require_manifest_system_deps.describeRss;
95994
96032
  exports.detectWorkspacePackagesDir = detectWorkspacePackagesDir;
96033
+ exports.diffCapActionCensus = require_manifest_system_deps.diffCapActionCensus;
95995
96034
  exports.diffEventPlane = require_manifest_system_deps.diffEventPlane;
95996
96035
  exports.diffSocketPlane = require_manifest_system_deps.diffSocketPlane;
95997
96036
  Object.defineProperty(exports, "downloadBinary", {