@camstack/system 1.2.118 → 1.2.120

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 (60) hide show
  1. package/dist/addon-runner.js +1 -1
  2. package/dist/addon-runner.mjs +1 -1
  3. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/alerts/alerts.addon.js +1 -1
  8. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  9. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  10. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  11. package/dist/builtins/console-logging/index.js +1 -1
  12. package/dist/builtins/console-logging/index.mjs +1 -1
  13. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  14. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  15. package/dist/builtins/device-manager/device-manager.addon.js +2 -2
  16. package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  17. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  18. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  19. package/dist/builtins/hub-forwarder/index.js +1 -1
  20. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  21. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  22. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  23. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  24. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  25. package/dist/builtins/local-network/local-network.addon.js +1 -1
  26. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  27. package/dist/builtins/loki-logging/index.js +1 -1
  28. package/dist/builtins/loki-logging/index.mjs +1 -1
  29. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  30. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  31. package/dist/builtins/platform-probe/index.js +1 -1
  32. package/dist/builtins/platform-probe/index.mjs +1 -1
  33. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  34. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  35. package/dist/builtins/snapshot/index.js +1 -1
  36. package/dist/builtins/snapshot/index.mjs +1 -1
  37. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  38. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  39. package/dist/builtins/sqlite-storage/index.mjs +1 -1
  40. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -2
  41. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  42. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  43. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  44. package/dist/builtins/system-config/system-config.addon.js +1 -1
  45. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  46. package/dist/builtins/winston-logging/index.js +1 -1
  47. package/dist/builtins/winston-logging/index.mjs +1 -1
  48. package/dist/{dist-C2_1HCpW.js → dist-CX9qXYC4.js} +114 -11
  49. package/dist/{dist-DCTpBXm4.mjs → dist-DNbsZxNv.mjs} +114 -11
  50. package/dist/index.js +187 -9
  51. package/dist/index.mjs +185 -11
  52. package/dist/kernel/config-manager.d.ts +8 -1
  53. package/dist/kernel/index.d.ts +3 -0
  54. package/dist/kernel/isolated-builtin-phase.d.ts +33 -0
  55. package/dist/kernel/settings-door-view.d.ts +7 -0
  56. package/dist/{manifest-python-deps-CwBbX4Ut.js → manifest-python-deps-76dZLxD0.js} +11 -3
  57. package/dist/{manifest-python-deps-SGdbr9D5.mjs → manifest-python-deps-DZSNlHjU.mjs} +12 -4
  58. package/dist/{retired-settings-keys-DHRXLMPn.js → retired-settings-keys-DlIuGG4o.js} +1 -1
  59. package/dist/{retired-settings-keys-Czd76yLZ.mjs → retired-settings-keys-Dt0-obcq.mjs} +1 -1
  60. package/package.json +6 -2
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Isolated builtins are not one spawn wave.
3
+ *
4
+ * Snapshot (D123) persists behind `settings-store`, so it must boot AFTER
5
+ * the in-process door. sqlite-settings IS the engine behind that door: spawn
6
+ * it in the consumer wave and every in-process builtin initialises against a
7
+ * missing store — the D44 empty-read failure, just with a fork in the way.
8
+ *
9
+ * `infra` = provides a capability in {@link INFRA_CAPABILITIES} → spawn
10
+ * BEFORE in-process builtins. `consumer` = everything else → spawn AFTER.
11
+ */
12
+ export interface CapabilityName {
13
+ readonly name: string;
14
+ }
15
+ export type IsolatedBuiltinPhase = 'infra' | 'consumer';
16
+ export declare function isolatedBuiltinPhase(capabilities: readonly CapabilityName[]): IsolatedBuiltinPhase;
17
+ export interface IsolatedBuiltinWaves {
18
+ readonly infra: readonly string[];
19
+ readonly consumers: readonly string[];
20
+ }
21
+ export declare function partitionIsolatedBuiltinIds(ids: readonly string[], capabilitiesOf: (id: string) => readonly CapabilityName[]): IsolatedBuiltinWaves;
22
+ export interface WaitUntilReadyOptions {
23
+ readonly timeoutMs: number;
24
+ readonly intervalMs: number;
25
+ readonly what: string;
26
+ }
27
+ /**
28
+ * Spawn of an infra isolate returns when the child process exists, not when
29
+ * its UDS handshake has put the engine in the parent's `getCollection`.
30
+ * In-process builtins that read the door before that handshake throw D44
31
+ * ("nothing behind it") and are skipped for the rest of the boot.
32
+ */
33
+ export declare function waitUntilReady(isReady: () => boolean, options: WaitUntilReadyOptions): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import { ISettingsStoreProvider } from '@camstack/types';
2
+ import { AddonSettingsView } from './config-manager.js';
3
+ export interface DoorSectionAccess {
4
+ getSection(section: string): Record<string, unknown>;
5
+ setSection(section: string, patch: Record<string, unknown>): void | Promise<void>;
6
+ }
7
+ export declare function createDoorSettingsView(addonId: string, door: ISettingsStoreProvider, sections: DoorSectionAccess): AddonSettingsView;
@@ -1850,6 +1850,10 @@ function callDeviceManager(api, method, input) {
1850
1850
  }
1851
1851
  function createBrokerDeviceManagerApi(opts) {
1852
1852
  const { api, addonId, nodeId, eventBus, registry } = opts;
1853
+ const deviceSliceSource = (0, _camstack_types_addon.createEventBusSliceSource)({
1854
+ eventBus,
1855
+ api
1856
+ });
1853
1857
  let selfApi;
1854
1858
  const deviceRebuildFactories = /* @__PURE__ */ new Map();
1855
1859
  const buildContext = (stableId, id, parentDeviceId = null, initialRuntimeState = {}, persistedConfig = {}, deviceMeta = null) => {
@@ -1894,7 +1898,7 @@ function createBrokerDeviceManagerApi(opts) {
1894
1898
  metadata: null
1895
1899
  },
1896
1900
  fetchDevice: async (deviceId) => {
1897
- return (0, _camstack_types_addon.createDeviceProxy)(api, await api.deviceManager.getBindings.query({ deviceId }));
1901
+ return (0, _camstack_types_addon.createDeviceProxy)(api, await api.deviceManager.getBindings.query({ deviceId }), { stateSource: deviceSliceSource });
1898
1902
  },
1899
1903
  get devices() {
1900
1904
  return selfApi;
@@ -7743,6 +7747,10 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
7743
7747
  const api = (0, _trpc_client.createTRPCClient)({ links });
7744
7748
  const scopedLogger = options?.createLogger?.(addonId) ?? (runtime.mode === "broker" ? createRemoteLogger(runtime.broker, addonId) : createUdsLogger(runtime.client, addonId, nodeId));
7745
7749
  const scopedEventBus = runtime.mode === "broker" ? createBrokerEventBus(runtime.broker, addonId) : createUdsEventBus(runtime.client, addonId);
7750
+ const deviceSliceSource = (0, _camstack_types_addon.createEventBusSliceSource)({
7751
+ eventBus: scopedEventBus,
7752
+ api
7753
+ });
7746
7754
  const workerDisposerChain = new _camstack_types_addon.DisposerChain({ onError: (err, index) => {
7747
7755
  scopedLogger.error(`Disposer #${index} threw during teardown`, { meta: { error: err instanceof Error ? err.message : String(err) } });
7748
7756
  } });
@@ -7994,10 +8002,10 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
7994
8002
  },
7995
8003
  fetchDevice: async (deviceId) => {
7996
8004
  const cached = bindingCache.get(deviceId);
7997
- if (cached) return (0, _camstack_types_addon.createDeviceProxy)(api, cached);
8005
+ if (cached) return (0, _camstack_types_addon.createDeviceProxy)(api, cached, { stateSource: deviceSliceSource });
7998
8006
  const binding = await api.deviceManager.getBindings.query({ deviceId });
7999
8007
  bindingCache.set(deviceId, binding);
8000
- return (0, _camstack_types_addon.createDeviceProxy)(api, binding);
8008
+ return (0, _camstack_types_addon.createDeviceProxy)(api, binding, { stateSource: deviceSliceSource });
8001
8009
  },
8002
8010
  useCapability(capName, scope = { type: "global" }) {
8003
8011
  return getOrCreateHandle(capName, scope, Number.POSITIVE_INFINITY);
@@ -12,7 +12,7 @@ import * as fs from "node:fs";
12
12
  import { createServer } from "node:http";
13
13
  import * as v8 from "node:v8";
14
14
  import * as vm from "node:vm";
15
- import { BOOT_RECOVERY_BACKOFF_MS, DATAPLANE_SECRET_HEADER, DeviceType, DisposerChain, EventCategory, ReadinessRegistry, asJsonObject, asString, createDeviceProxy, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, readNodePin, scopeKey, sleep, withCapInputDefaults } from "@camstack/types/addon";
15
+ import { BOOT_RECOVERY_BACKOFF_MS, DATAPLANE_SECRET_HEADER, DeviceType, DisposerChain, EventCategory, ReadinessRegistry, asJsonObject, asString, createDeviceProxy, createEventBusSliceSource, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, readNodePin, scopeKey, sleep, withCapInputDefaults } from "@camstack/types/addon";
16
16
  import { connect, createServer as createServer$1 } from "node:net";
17
17
  import { TRPCClientError, createTRPCClient } from "@trpc/client";
18
18
  //#region src/kernel/heap-watch.ts
@@ -1846,6 +1846,10 @@ function callDeviceManager(api, method, input) {
1846
1846
  }
1847
1847
  function createBrokerDeviceManagerApi(opts) {
1848
1848
  const { api, addonId, nodeId, eventBus, registry } = opts;
1849
+ const deviceSliceSource = createEventBusSliceSource({
1850
+ eventBus,
1851
+ api
1852
+ });
1849
1853
  let selfApi;
1850
1854
  const deviceRebuildFactories = /* @__PURE__ */ new Map();
1851
1855
  const buildContext = (stableId, id, parentDeviceId = null, initialRuntimeState = {}, persistedConfig = {}, deviceMeta = null) => {
@@ -1890,7 +1894,7 @@ function createBrokerDeviceManagerApi(opts) {
1890
1894
  metadata: null
1891
1895
  },
1892
1896
  fetchDevice: async (deviceId) => {
1893
- return createDeviceProxy(api, await api.deviceManager.getBindings.query({ deviceId }));
1897
+ return createDeviceProxy(api, await api.deviceManager.getBindings.query({ deviceId }), { stateSource: deviceSliceSource });
1894
1898
  },
1895
1899
  get devices() {
1896
1900
  return selfApi;
@@ -7739,6 +7743,10 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
7739
7743
  const api = createTRPCClient({ links });
7740
7744
  const scopedLogger = options?.createLogger?.(addonId) ?? (runtime.mode === "broker" ? createRemoteLogger(runtime.broker, addonId) : createUdsLogger(runtime.client, addonId, nodeId));
7741
7745
  const scopedEventBus = runtime.mode === "broker" ? createBrokerEventBus(runtime.broker, addonId) : createUdsEventBus(runtime.client, addonId);
7746
+ const deviceSliceSource = createEventBusSliceSource({
7747
+ eventBus: scopedEventBus,
7748
+ api
7749
+ });
7742
7750
  const workerDisposerChain = new DisposerChain({ onError: (err, index) => {
7743
7751
  scopedLogger.error(`Disposer #${index} threw during teardown`, { meta: { error: err instanceof Error ? err.message : String(err) } });
7744
7752
  } });
@@ -7990,10 +7998,10 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
7990
7998
  },
7991
7999
  fetchDevice: async (deviceId) => {
7992
8000
  const cached = bindingCache.get(deviceId);
7993
- if (cached) return createDeviceProxy(api, cached);
8001
+ if (cached) return createDeviceProxy(api, cached, { stateSource: deviceSliceSource });
7994
8002
  const binding = await api.deviceManager.getBindings.query({ deviceId });
7995
8003
  bindingCache.set(deviceId, binding);
7996
- return createDeviceProxy(api, binding);
8004
+ return createDeviceProxy(api, binding, { stateSource: deviceSliceSource });
7997
8005
  },
7998
8006
  useCapability(capName, scope = { type: "global" }) {
7999
8007
  return getOrCreateHandle(capName, scope, Number.POSITIVE_INFINITY);
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-C2_1HCpW.js");
1
+ const require_dist = require("./dist-CX9qXYC4.js");
2
2
  //#region src/builtins/sqlite-storage/retired-settings-keys.ts
3
3
  /**
4
4
  * Is THIS node the one whose settings store is the cluster's authority?
@@ -1,4 +1,4 @@
1
- import { kt as asJsonObject } from "./dist-DCTpBXm4.mjs";
1
+ import { kt as asJsonObject } from "./dist-DNbsZxNv.mjs";
2
2
  //#region src/builtins/sqlite-storage/retired-settings-keys.ts
3
3
  /**
4
4
  * Is THIS node the one whose settings store is the cluster's authority?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/system",
3
- "version": "1.2.118",
3
+ "version": "1.2.120",
4
4
  "description": "Core addon for CamStack — builtins, pipeline, process management, auth, logging, events",
5
5
  "keywords": [
6
6
  "camstack",
@@ -53,7 +53,11 @@
53
53
  "category": "system",
54
54
  "name": "SQLite Settings",
55
55
  "entry": "./dist/builtins/sqlite-storage/sqlite-settings.addon.js",
56
- "description": "The relational ENGINE behind the data door (SQLite WAL). Registers `data-store-provider`, an internal collection cap; the public `settings-store` door is owned by `storage-orchestrator`, which dispatches here. Callers never reach this addon directly — that is what makes the engine replaceable. It ALSO registers `vector-store` (sqlite-vec) from the same database file and the same open handle.",
56
+ "description": "The relational ENGINE behind the data door (SQLite WAL). Registers `data-store-provider`, an internal collection cap; the public `settings-store` door is owned by `storage-orchestrator`, which dispatches here. Callers never reach this addon directly — that is what makes the engine replaceable. It ALSO registers `vector-store` (sqlite-vec) from the same database file and the same open handle. Runs in its OWN process (`execution.isolate`) — `better-sqlite3` `Statement.run` does not belong on the event loop that serves the API ([D181]).",
57
+ "execution": {
58
+ "isolate": true,
59
+ "heapProfile": "heavy"
60
+ },
57
61
  "capabilities": [
58
62
  {
59
63
  "name": "data-store-provider"