@camstack/system 1.2.218 → 1.2.220

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 (97) hide show
  1. package/dist/addon-runner.js +2 -2
  2. package/dist/addon-runner.mjs +2 -2
  3. package/dist/addon-utils.js +2 -2
  4. package/dist/addon-utils.mjs +2 -2
  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 +2 -2
  28. package/dist/builtins/local-network/local-network.addon.mjs +2 -2
  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/gpu-probe.d.ts +18 -0
  32. package/dist/builtins/native-metrics/native-metrics-provider.d.ts +1 -1
  33. package/dist/builtins/native-metrics/native-metrics.addon.d.ts +26 -3
  34. package/dist/builtins/native-metrics/native-metrics.addon.js +1320 -1093
  35. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1320 -1096
  36. package/dist/builtins/native-metrics/proc-process-table.d.ts +25 -0
  37. package/dist/builtins/platform-probe/index.js +3 -3
  38. package/dist/builtins/platform-probe/index.mjs +3 -3
  39. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  40. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  41. package/dist/builtins/snapshot/index.js +1 -1
  42. package/dist/builtins/snapshot/index.mjs +1 -1
  43. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  44. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  45. package/dist/builtins/sqlite-storage/sqlite-pragmas.d.ts +23 -0
  46. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +1 -1
  47. package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +1 -0
  48. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  49. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  50. package/dist/builtins/sqlite-storage/wal-checkpoint-policy.d.ts +115 -0
  51. package/dist/builtins/sqlite-storage/wal-checkpoint-worker.d.ts +1 -0
  52. package/dist/builtins/sqlite-storage/wal-checkpointer.d.ts +70 -0
  53. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  54. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  55. package/dist/builtins/system-config/system-config.addon.js +1 -1
  56. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  57. package/dist/builtins/winston-logging/index.js +1 -1
  58. package/dist/builtins/winston-logging/index.mjs +1 -1
  59. package/dist/{custom-action-registry-BDwM5qAK.js → custom-action-registry-B42MC_Pv.js} +1 -1
  60. package/dist/{custom-action-registry-CsONUlhC.mjs → custom-action-registry-CpR58DXT.mjs} +1 -1
  61. package/dist/{dist-DigmGsQS.mjs → dist-Ca_jaxXs.mjs} +232 -4
  62. package/dist/{dist-BOlMCOeT.js → dist-CllKpcTd.js} +232 -4
  63. package/dist/index.d.ts +6 -1
  64. package/dist/index.js +99 -65
  65. package/dist/index.mjs +84 -67
  66. package/dist/kernel/gc-census.d.ts +144 -0
  67. package/dist/kernel/heap-watch.d.ts +32 -1
  68. package/dist/kernel/moleculer/mesh-queue-report.d.ts +51 -0
  69. package/dist/kernel/outbound-queue-watch.d.ts +94 -0
  70. package/dist/kernel/socket-plane-report.d.ts +112 -4
  71. package/dist/kernel/transport/cap-action-census.d.ts +218 -0
  72. package/dist/kernel/transport/cap-child-index.d.ts +49 -0
  73. package/dist/kernel/transport/cap-routing-hints.d.ts +21 -0
  74. package/dist/kernel/transport/child-cap-protocol.d.ts +28 -2
  75. package/dist/kernel/transport/frame-codec.d.ts +49 -0
  76. package/dist/kernel/transport/index.d.ts +2 -0
  77. package/dist/kernel/transport/local-child-client.d.ts +7 -0
  78. package/dist/kernel/transport/local-child-registry.d.ts +99 -5
  79. package/dist/kernel/transport/local-transport.d.ts +54 -2
  80. package/dist/kernel/transport/socket-channel.d.ts +40 -1
  81. package/dist/{manifest-system-deps-Bo92lg5u.js → manifest-system-deps-DfpwaXkh.js} +1725 -614
  82. package/dist/{manifest-system-deps-D--wyMD9.mjs → manifest-system-deps-iadzxSBr.mjs} +1850 -841
  83. package/dist/process/proc-stat.d.ts +75 -0
  84. package/dist/process/resource-monitor.d.ts +9 -1
  85. package/dist/{resource-monitor-CdnzxBLP.js → resource-monitor-LVE1BoLs.js} +42 -23
  86. package/dist/{resource-monitor-BWmQ5i-o.mjs → resource-monitor-Vp0bPV3U.mjs} +42 -22
  87. package/dist/{retired-settings-keys-xEAlYnv7.js → retired-settings-keys-7iEsSzmD.js} +1 -1
  88. package/dist/{retired-settings-keys-vK_U-CG2.mjs → retired-settings-keys-DQnfr__p.mjs} +1 -1
  89. package/dist/wal-checkpoint-policy-CAcg63o-.mjs +92 -0
  90. package/dist/wal-checkpoint-policy-CCJZngds.js +127 -0
  91. package/dist/wal-checkpoint-worker.js +138 -0
  92. package/dist/wal-checkpoint-worker.mjs +137 -0
  93. package/package.json +1 -1
  94. package/dist/{event-loop-stall-monitor-DM9OAzy8.js → event-loop-stall-monitor-CAsHdMwP.js} +1 -1
  95. package/dist/{event-loop-stall-monitor-B3CFd9tM.mjs → event-loop-stall-monitor-GPrVvx14.mjs} +1 -1
  96. package/dist/{tls-DOTmtLCW.mjs → tls-2xbgg78V.mjs} +2 -2
  97. package/dist/{tls-BxQlomxd.js → tls-BFs4PzoW.js} +2 -2
@@ -0,0 +1,137 @@
1
+ import { a as isWorkerStop, o as parseWalIndexHeader, r as decideCheckpoint } from "./wal-checkpoint-policy-CAcg63o-.mjs";
2
+ import { closeSync, openSync, readSync } from "node:fs";
3
+ import Database from "better-sqlite3";
4
+ import { parentPort, workerData } from "node:worker_threads";
5
+ //#region src/builtins/sqlite-storage/wal-checkpoint-worker.ts
6
+ /**
7
+ * The checkpoint worker — a thread of `hub/sqlite-settings` whose only job is
8
+ * `PRAGMA wal_checkpoint(PASSIVE)` over its own connection.
9
+ *
10
+ * Why it exists, the measurement, and the rule it follows are in
11
+ * `wal-checkpoint-policy.ts`. What this file adds is the mechanics:
12
+ *
13
+ * - Its OWN connection to the same file. A checkpoint's fsyncs happen on the
14
+ * thread that issues the pragma; issuing it here is what takes them off the
15
+ * settings thread. The connection is sized to do nothing but checkpoint —
16
+ * a 2 MiB page cache and no mmap — so it is not a second copy of the
17
+ * engine's working set.
18
+ * - PASSIVE, never FULL/RESTART/TRUNCATE. PASSIVE takes no writer lock and
19
+ * waits for nobody: it copies what it can and returns. The settings thread's
20
+ * writers and readers are never blocked by this thread. (The idle-gated
21
+ * TRUNCATE in `wal-maintenance.ts` is a different job — reclaiming a
22
+ * sidecar that outgrew its limit — and stays where it is.)
23
+ * - The wal-index header is read as bytes (`-shm`, 100 bytes, no lock) so the
24
+ * poll costs nothing; when it cannot be read the policy falls back to a
25
+ * fixed interval, so nothing here can turn "unreadable" into "nothing to do".
26
+ * - Every checkpoint is reported to the parent with its numbers. The parent
27
+ * decides what is worth a line.
28
+ *
29
+ * A worker entry is a separate bundle (`dist/wal-checkpoint-worker.js`, wired
30
+ * in `vite.config.ts` next to `addon-runner`). It imports nothing from the
31
+ * kernel: it must load in a bare thread with `better-sqlite3` and the policy
32
+ * module, nothing else.
33
+ */
34
+ function isCheckpointRow(value) {
35
+ if (typeof value !== "object" || value === null) return false;
36
+ if (!("busy" in value) || !("log" in value) || !("checkpointed" in value)) return false;
37
+ return typeof value.busy === "number" && typeof value.log === "number" && typeof value.checkpointed === "number";
38
+ }
39
+ function readCheckpointRow(value) {
40
+ if (isCheckpointRow(value)) return value;
41
+ if (Array.isArray(value)) {
42
+ const [first] = value;
43
+ if (isCheckpointRow(first)) return first;
44
+ }
45
+ return null;
46
+ }
47
+ function isWorkerData(value) {
48
+ if (typeof value !== "object" || value === null) return false;
49
+ if (!("dbPath" in value) || !("pollMs" in value)) return false;
50
+ return typeof value.dbPath === "string" && typeof value.pollMs === "number";
51
+ }
52
+ /** The two wal-index counters, or nulls when the sidecar cannot be read. */
53
+ function readWalIndex(shmPath) {
54
+ let fd = null;
55
+ try {
56
+ fd = openSync(shmPath, "r");
57
+ const buffer = Buffer.alloc(100);
58
+ if (readSync(fd, buffer, 0, 100, 0) < 100) return {
59
+ mxFrame: null,
60
+ nBackfill: null
61
+ };
62
+ return parseWalIndexHeader(buffer) ?? {
63
+ mxFrame: null,
64
+ nBackfill: null
65
+ };
66
+ } catch {
67
+ return {
68
+ mxFrame: null,
69
+ nBackfill: null
70
+ };
71
+ } finally {
72
+ if (fd !== null) closeSync(fd);
73
+ }
74
+ }
75
+ function post(message) {
76
+ parentPort?.postMessage(message);
77
+ }
78
+ function run() {
79
+ const port = parentPort;
80
+ if (port === null) throw new Error("wal-checkpoint-worker: no parent port");
81
+ if (!isWorkerData(workerData)) throw new Error("wal-checkpoint-worker: bad workerData");
82
+ const { dbPath, pollMs } = workerData;
83
+ const shmPath = `${dbPath}-shm`;
84
+ const db = new Database(dbPath);
85
+ db.pragma("cache_size = -2048");
86
+ db.pragma("mmap_size = 0");
87
+ let lastRunAt = Date.now();
88
+ let timer = null;
89
+ let stopping = false;
90
+ const tick = () => {
91
+ if (stopping) return;
92
+ const decision = decideCheckpoint({
93
+ ...readWalIndex(shmPath),
94
+ sinceLastRunMs: Date.now() - lastRunAt
95
+ });
96
+ if (decision.run) {
97
+ const startedAt = Date.now();
98
+ let raw;
99
+ try {
100
+ raw = db.pragma("wal_checkpoint(PASSIVE)");
101
+ } catch (err) {
102
+ post({
103
+ kind: "failed",
104
+ error: err instanceof Error ? err.message : String(err)
105
+ });
106
+ raw = null;
107
+ }
108
+ lastRunAt = Date.now();
109
+ const row = readCheckpointRow(raw);
110
+ if (row !== null) post({
111
+ kind: "checkpointed",
112
+ reason: decision.reason,
113
+ pendingFrames: decision.pendingFrames,
114
+ walFrames: row.log,
115
+ checkpointedFrames: row.checkpointed,
116
+ busy: row.busy !== 0,
117
+ ms: lastRunAt - startedAt
118
+ });
119
+ }
120
+ timer = setTimeout(tick, pollMs);
121
+ };
122
+ port.on("message", (message) => {
123
+ if (!isWorkerStop(message)) return;
124
+ stopping = true;
125
+ if (timer !== null) clearTimeout(timer);
126
+ try {
127
+ db.close();
128
+ } finally {
129
+ port.close();
130
+ }
131
+ });
132
+ post({ kind: "ready" });
133
+ timer = setTimeout(tick, pollMs);
134
+ }
135
+ run();
136
+ //#endregion
137
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/system",
3
- "version": "1.2.218",
3
+ "version": "1.2.220",
4
4
  "description": "Core addon for CamStack — builtins, pipeline, process management, auth, logging, events",
5
5
  "keywords": [
6
6
  "camstack",
@@ -2,9 +2,9 @@ const require_chunk = require("./chunk-Cek0wNdY.js");
2
2
  let node_crypto = require("node:crypto");
3
3
  let node_path = require("node:path");
4
4
  node_path = require_chunk.__toESM(node_path);
5
- let node_util = require("node:util");
6
5
  let node_fs = require("node:fs");
7
6
  node_fs = require_chunk.__toESM(node_fs);
7
+ let node_util = require("node:util");
8
8
  let node_http = require("node:http");
9
9
  let node_zlib = require("node:zlib");
10
10
  let node_perf_hooks = require("node:perf_hooks");
@@ -1,9 +1,9 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import * as path$1 from "node:path";
3
3
  import path from "node:path";
4
- import { promisify } from "node:util";
5
4
  import * as fs from "node:fs";
6
5
  import { createReadStream, promises } from "node:fs";
6
+ import { promisify } from "node:util";
7
7
  import { createServer } from "node:http";
8
8
  import { brotliCompress, constants as constants$1, gzip } from "node:zlib";
9
9
  import { PerformanceObserver } from "node:perf_hooks";
@@ -1,11 +1,11 @@
1
1
  import { X509Certificate, createPrivateKey, randomBytes } from "node:crypto";
2
2
  import { chmod, copyFile, mkdtemp, rm, writeFile } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
- import { execFile } from "node:child_process";
5
- import { promisify } from "node:util";
6
4
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
5
+ import { execFile } from "node:child_process";
7
6
  import * as os from "node:os";
8
7
  import { tmpdir } from "node:os";
8
+ import { promisify } from "node:util";
9
9
  import { createServer } from "node:http";
10
10
  import { isIP } from "node:net";
11
11
  //#region src/http/lan-http-bind.ts
@@ -2,11 +2,11 @@ const require_chunk = require("./chunk-Cek0wNdY.js");
2
2
  let node_crypto = require("node:crypto");
3
3
  let node_fs_promises = require("node:fs/promises");
4
4
  let node_path = require("node:path");
5
- let node_child_process = require("node:child_process");
6
- let node_util = require("node:util");
7
5
  let node_fs = require("node:fs");
6
+ let node_child_process = require("node:child_process");
8
7
  let node_os = require("node:os");
9
8
  node_os = require_chunk.__toESM(node_os);
9
+ let node_util = require("node:util");
10
10
  let node_http = require("node:http");
11
11
  let node_net = require("node:net");
12
12
  //#region src/http/lan-http-bind.ts