@camstack/system 1.1.34 → 1.1.36

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 (49) hide show
  1. package/dist/addon-runner.js +87 -35
  2. package/dist/addon-runner.mjs +87 -35
  3. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +6 -6
  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 +6 -6
  6. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/alerts/alerts.addon.js +12 -12
  8. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  9. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +5 -5
  10. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  11. package/dist/builtins/console-logging/index.js +3 -3
  12. package/dist/builtins/console-logging/index.mjs +1 -1
  13. package/dist/builtins/device-manager/device-manager.addon.js +69 -69
  14. package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  15. package/dist/builtins/hub-forwarder/index.js +3 -3
  16. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  17. package/dist/builtins/local-auth/local-auth.addon.js +7 -7
  18. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  19. package/dist/builtins/local-network/local-network.addon.js +7 -7
  20. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  21. package/dist/builtins/native-metrics/native-metrics.addon.js +5 -5
  22. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  23. package/dist/builtins/platform-probe/index.js +13 -13
  24. package/dist/builtins/platform-probe/index.mjs +1 -1
  25. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
  26. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  27. package/dist/builtins/snapshot/index.js +13 -13
  28. package/dist/builtins/snapshot/index.mjs +1 -1
  29. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +4 -4
  30. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  31. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +9 -9
  32. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +1 -1
  33. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +5 -5
  34. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  35. package/dist/builtins/system-config/system-config.addon.js +5 -5
  36. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  37. package/dist/builtins/winston-logging/index.js +3 -3
  38. package/dist/builtins/winston-logging/index.mjs +1 -1
  39. package/dist/dist-C7oOY4iL.mjs +24559 -0
  40. package/dist/dist-COIhbSao.js +25032 -0
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.js +92 -115
  43. package/dist/index.mjs +52 -52
  44. package/dist/kernel/moleculer/child-cap-descriptors.d.ts +34 -0
  45. package/dist/kernel/moleculer/child-cap-dispatch.d.ts +10 -2
  46. package/dist/kernel/transport/child-cap-protocol.d.ts +20 -0
  47. package/dist/{manifest-python-deps-u-AQBQY6.mjs → manifest-python-deps-BYIV8-rc.mjs} +31 -29
  48. package/dist/{manifest-python-deps-CAnO1wPx.js → manifest-python-deps-CZFqI4wp.js} +7 -5
  49. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
+ import { H as readNodePin } from "./dist-C7oOY4iL.mjs";
1
2
  import { ensureBinary, ensureFfmpeg, ensurePython, installPythonPackages, installPythonRequirements } from "@camstack/types/node";
2
3
  import { createServer } from "node:http";
3
4
  import * as fs from "node:fs";
4
5
  import * as path$1 from "node:path";
5
6
  import { isAbsolute, join } from "node:path";
6
- import { readNodePin } from "@camstack/types";
7
7
  import * as crypto$1 from "node:crypto";
8
8
  import { randomBytes, randomUUID } from "node:crypto";
9
9
  import { execFile } from "node:child_process";
@@ -11,7 +11,7 @@ import { promisify } from "node:util";
11
11
  import * as os from "node:os";
12
12
  import { tmpdir } from "node:os";
13
13
  import { unlink } from "node:fs/promises";
14
- import { DATAPLANE_SECRET_HEADER as DATAPLANE_SECRET_HEADER$1, DeviceType as DeviceType$1, DisposerChain, EventCategory as EventCategory$1, ReadinessRegistry, asJsonObject as asJsonObject$1, asString as asString$1, createDeviceProxy, deviceOpsCapability, emitReadiness as emitReadiness$1, errMsg as errMsg$1, expandCapMethods as expandCapMethods$1, scopeKey, sleep as sleep$1 } from "@camstack/types/addon";
14
+ import { DATAPLANE_SECRET_HEADER, DeviceType, DisposerChain, EventCategory, ReadinessRegistry, asJsonObject, asString, createDeviceProxy, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, scopeKey, sleep } from "@camstack/types/addon";
15
15
  import { TRPCClientError, createTRPCClient } from "@trpc/client";
16
16
  import { connect, createServer as createServer$1 } from "node:net";
17
17
  //#region src/kernel/addon-class-resolver.ts
@@ -102,7 +102,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry) {
102
102
  } catch (err) {
103
103
  logger.warn("Failed to write native deps marker", { meta: {
104
104
  markerFile,
105
- error: errMsg$1(err)
105
+ error: errMsg(err)
106
106
  } });
107
107
  }
108
108
  return;
@@ -129,7 +129,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry) {
129
129
  timeout: 3e5
130
130
  });
131
131
  } catch (err) {
132
- throw new Error(`npm install of native deps failed for ${addonDir}: ${errMsg$1(err)}`, { cause: err });
132
+ throw new Error(`npm install of native deps failed for ${addonDir}: ${errMsg(err)}`, { cause: err });
133
133
  }
134
134
  await rebuildNativeDeps(addonDir, pending.map(([name]) => name), logger);
135
135
  try {
@@ -137,7 +137,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry) {
137
137
  } catch (err) {
138
138
  logger.warn("Failed to write native deps marker", { meta: {
139
139
  markerFile,
140
- error: errMsg$1(err)
140
+ error: errMsg(err)
141
141
  } });
142
142
  }
143
143
  }
@@ -174,7 +174,7 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
174
174
  logger.warn("Prebuilt native dep copy failed — will try npm install", { meta: {
175
175
  name,
176
176
  source,
177
- error: errMsg$1(err)
177
+ error: errMsg(err)
178
178
  } });
179
179
  }
180
180
  }
@@ -207,13 +207,13 @@ function candidateHoistedDirs(name, addonDir) {
207
207
  }
208
208
  /** Read & validate `camstack.nativeDependencies`. Returns null when absent. */
209
209
  function readNativeDeps(pkgRaw) {
210
- const camstack = asJsonObject$1(pkgRaw["camstack"]);
210
+ const camstack = asJsonObject(pkgRaw["camstack"]);
211
211
  if (!camstack) return null;
212
- const native = asJsonObject$1(camstack["nativeDependencies"]);
212
+ const native = asJsonObject(camstack["nativeDependencies"]);
213
213
  if (!native) return null;
214
214
  const out = {};
215
215
  for (const [k, v] of Object.entries(native)) {
216
- const range = asString$1(v);
216
+ const range = asString(v);
217
217
  if (range) out[k] = range;
218
218
  }
219
219
  return Object.keys(out).length > 0 ? out : null;
@@ -280,7 +280,7 @@ async function rebuildNativeDeps(addonDir, packageNames, logger) {
280
280
  } catch (err) {
281
281
  logger.warn("Electron rebuild failed (continuing — prebuilt binary may be present)", { meta: {
282
282
  addonDir,
283
- error: errMsg$1(err)
283
+ error: errMsg(err)
284
284
  } });
285
285
  }
286
286
  return;
@@ -298,7 +298,7 @@ async function rebuildNativeDeps(addonDir, packageNames, logger) {
298
298
  } catch (err) {
299
299
  logger.warn("npm rebuild failed (continuing — prebuilt binary may be present)", { meta: {
300
300
  addonDir,
301
- error: errMsg$1(err)
301
+ error: errMsg(err)
302
302
  } });
303
303
  }
304
304
  }
@@ -925,7 +925,7 @@ var nativeCapReadinessGeneration = typeof crypto !== "undefined" && crypto.rando
925
925
  function mountNativeCapService(broker, addonId, cap) {
926
926
  const serviceName = capServiceName(addonId, cap.name, true);
927
927
  if (mountedNativeCapServices.has(serviceName)) return;
928
- const expandedMethods = expandCapMethods$1(cap);
928
+ const expandedMethods = expandCapMethods(cap);
929
929
  if (expandedMethods === void 0 || Object.keys(expandedMethods).length === 0 || typeof broker.createService !== "function") {
930
930
  mountedNativeCapServices.add(serviceName);
931
931
  return;
@@ -1031,7 +1031,7 @@ async function callWithServiceDiscoveryRetry(broker, actionName, input) {
1031
1031
  if (!(err instanceof Error ? err.message : String(err)).includes("is not found")) throw err;
1032
1032
  attempt++;
1033
1033
  if (attempt === 1) broker.logger.warn(`native-cap-bridge: service not found for "${actionName}", retrying with exponential backoff…`);
1034
- await sleep$1(delay);
1034
+ await sleep(delay);
1035
1035
  delay = Math.min(delay * 2, BACKOFF_MAX_MS);
1036
1036
  }
1037
1037
  }
@@ -1136,7 +1136,7 @@ function createBrokerDeviceManagerApi(opts) {
1136
1136
  parentDeviceId,
1137
1137
  logger: (() => {
1138
1138
  const base = opts.logger.child(stableId);
1139
- const containerDeviceId = parentDeviceId ?? (deviceMeta?.type === DeviceType$1.Container ? id : null);
1139
+ const containerDeviceId = parentDeviceId ?? (deviceMeta?.type === DeviceType.Container ? id : null);
1140
1140
  return base.withTags(containerDeviceId !== null ? {
1141
1141
  deviceId: id,
1142
1142
  containerDeviceId
@@ -1162,7 +1162,7 @@ function createBrokerDeviceManagerApi(opts) {
1162
1162
  id,
1163
1163
  stableId,
1164
1164
  addonId,
1165
- type: DeviceType$1.Camera,
1165
+ type: DeviceType.Camera,
1166
1166
  name: stableId,
1167
1167
  location: null,
1168
1168
  disabled: false,
@@ -1228,7 +1228,7 @@ function createBrokerDeviceManagerApi(opts) {
1228
1228
  type: "device",
1229
1229
  id
1230
1230
  },
1231
- category: EventCategory$1.DeviceBindingsChanged,
1231
+ category: EventCategory.DeviceBindingsChanged,
1232
1232
  data: {
1233
1233
  deviceId: id,
1234
1234
  capName: cap.name,
@@ -1237,7 +1237,7 @@ function createBrokerDeviceManagerApi(opts) {
1237
1237
  nodeId
1238
1238
  }
1239
1239
  });
1240
- emitReadiness$1(eventBus, {
1240
+ emitReadiness(eventBus, {
1241
1241
  capName: cap.name,
1242
1242
  scope: {
1243
1243
  type: "device",
@@ -1632,7 +1632,7 @@ function createBrokerDeviceManagerApi(opts) {
1632
1632
  type: "device",
1633
1633
  id: device.id
1634
1634
  },
1635
- category: EventCategory$1.DeviceReady,
1635
+ category: EventCategory.DeviceReady,
1636
1636
  data: { deviceId: device.id }
1637
1637
  });
1638
1638
  };
@@ -1771,7 +1771,7 @@ function createBrokerDeviceManagerApi(opts) {
1771
1771
  type: "device",
1772
1772
  id: deviceId
1773
1773
  },
1774
- category: EventCategory$1.DeviceBindingsChanged,
1774
+ category: EventCategory.DeviceBindingsChanged,
1775
1775
  data: {
1776
1776
  deviceId,
1777
1777
  capName,
@@ -1780,7 +1780,7 @@ function createBrokerDeviceManagerApi(opts) {
1780
1780
  nodeId
1781
1781
  }
1782
1782
  });
1783
- emitReadiness$1(eventBus, {
1783
+ emitReadiness(eventBus, {
1784
1784
  capName,
1785
1785
  scope: {
1786
1786
  type: "device",
@@ -4192,7 +4192,8 @@ var LocalChildRegistry = class {
4192
4192
  capName: input.capName,
4193
4193
  method: input.method,
4194
4194
  args: input.args,
4195
- ...input.deviceId !== void 0 ? { deviceId: input.deviceId } : {}
4195
+ ...input.deviceId !== void 0 ? { deviceId: input.deviceId } : {},
4196
+ ...input.addonId !== void 0 ? { addonId: input.addonId } : {}
4196
4197
  };
4197
4198
  }
4198
4199
  listChildren() {
@@ -4890,6 +4891,7 @@ function createParentUnownedCallHandler(deps) {
4890
4891
  return async (input) => {
4891
4892
  const deviceId = input.deviceId ?? extractDeviceId(input.args);
4892
4893
  const nodeId = deps.isDataNodeIdCap?.(input.capName) === true ? void 0 : input.nodeId ?? extractNodeId(input.args);
4894
+ const pinnedToOtherNode = nodeId !== void 0 && nodeId !== deps.broker.nodeID;
4893
4895
  if (nodeId === void 0) {
4894
4896
  const empty = deps.resolveEmptyCollection?.(input.capName, input.method);
4895
4897
  if (empty != null) return empty;
@@ -4906,7 +4908,7 @@ function createParentUnownedCallHandler(deps) {
4906
4908
  }
4907
4909
  else deps.logger?.debug?.(`onUnownedCall: resolver not ready, routing ${input.capName}.${input.method} via broker fallback`);
4908
4910
  try {
4909
- if (deviceId !== void 0) {
4911
+ if (deviceId !== void 0 && !pinnedToOtherNode) {
4910
4912
  const localDispatcher = deps.getLocalDispatcher?.() ?? null;
4911
4913
  if (localDispatcher !== null) {
4912
4914
  let childId = localDispatcher.resolveChildId(input.capName, deviceId);
@@ -5737,7 +5739,7 @@ function createAddonDataPlaneFacility(args) {
5737
5739
  let server = null;
5738
5740
  let baseUrl = "";
5739
5741
  const route = (req, res) => {
5740
- if (req.headers[DATAPLANE_SECRET_HEADER$1] !== secret) {
5742
+ if (req.headers[DATAPLANE_SECRET_HEADER] !== secret) {
5741
5743
  res.writeHead(403).end();
5742
5744
  return;
5743
5745
  }
@@ -5856,7 +5858,7 @@ function resolveNodeRoot() {
5856
5858
  var inFlight = /* @__PURE__ */ new Map();
5857
5859
  var LOCK_STALE_MS = 10 * 6e4;
5858
5860
  var LOCK_POLL_MS = 500;
5859
- function sleep$2(ms) {
5861
+ function sleep$1(ms) {
5860
5862
  return new Promise((resolve) => setTimeout(resolve, ms));
5861
5863
  }
5862
5864
  /**
@@ -5875,7 +5877,7 @@ async function withFileLock(lockPath, fn) {
5875
5877
  } catch {
5876
5878
  try {
5877
5879
  if (Date.now() - fs.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs.rmSync(lockPath, { force: true });
5878
- else await sleep$2(LOCK_POLL_MS);
5880
+ else await sleep$1(LOCK_POLL_MS);
5879
5881
  } catch {}
5880
5882
  }
5881
5883
  try {
@@ -6725,7 +6727,7 @@ function getWorkerDeviceRegistry() {
6725
6727
  * the property-access boundary and validate structurally.
6726
6728
  */
6727
6729
  function buildRemoteNativeProvider(api, cap, options) {
6728
- const capNameCamel = kebabToCamel$1(cap.name);
6730
+ const capNameCamel = kebabToCamel(cap.name);
6729
6731
  const provider = {};
6730
6732
  for (const [methodName, methodSchema] of Object.entries(cap.methods)) {
6731
6733
  const callKind = methodSchema.kind === "mutation" ? "mutate" : "query";
@@ -6746,7 +6748,7 @@ function buildRemoteNativeProvider(api, cap, options) {
6746
6748
  }
6747
6749
  return provider;
6748
6750
  }
6749
- function kebabToCamel$1(s) {
6751
+ function kebabToCamel(s) {
6750
6752
  return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
6751
6753
  }
6752
6754
  /**
@@ -6824,7 +6826,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
6824
6826
  } });
6825
6827
  registerWorkerDisposerChain(nodeId, addonId, workerDisposerChain);
6826
6828
  const bindingCache = /* @__PURE__ */ new Map();
6827
- scopedEventBus.subscribe({ category: EventCategory$1.DeviceBindingsChanged }, (e) => {
6829
+ scopedEventBus.subscribe({ category: EventCategory.DeviceBindingsChanged }, (e) => {
6828
6830
  const data = e.data ?? {};
6829
6831
  if (typeof data.deviceId === "number") {
6830
6832
  bindingCache.delete(data.deviceId);
@@ -6867,7 +6869,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
6867
6869
  scopedLogger.warn(`settings write failed (${coll}/${key}) — ${isTrpcError ? "transport error" : "store error"}`, { meta: {
6868
6870
  collection: coll,
6869
6871
  key,
6870
- error: errMsg$1(err)
6872
+ error: errMsg(err)
6871
6873
  } });
6872
6874
  }
6873
6875
  };
@@ -1,11 +1,11 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
+ const require_dist = require("./dist-COIhbSao.js");
2
3
  let _camstack_types_node = require("@camstack/types/node");
3
4
  let node_http = require("node:http");
4
5
  let node_fs = require("node:fs");
5
6
  node_fs = require_chunk.__toESM(node_fs);
6
7
  let node_path = require("node:path");
7
8
  node_path = require_chunk.__toESM(node_path);
8
- let _camstack_types = require("@camstack/types");
9
9
  let node_crypto = require("node:crypto");
10
10
  node_crypto = require_chunk.__toESM(node_crypto);
11
11
  let node_child_process = require("node:child_process");
@@ -4194,7 +4194,8 @@ var LocalChildRegistry = class {
4194
4194
  capName: input.capName,
4195
4195
  method: input.method,
4196
4196
  args: input.args,
4197
- ...input.deviceId !== void 0 ? { deviceId: input.deviceId } : {}
4197
+ ...input.deviceId !== void 0 ? { deviceId: input.deviceId } : {},
4198
+ ...input.addonId !== void 0 ? { addonId: input.addonId } : {}
4198
4199
  };
4199
4200
  }
4200
4201
  listChildren() {
@@ -4892,6 +4893,7 @@ function createParentUnownedCallHandler(deps) {
4892
4893
  return async (input) => {
4893
4894
  const deviceId = input.deviceId ?? extractDeviceId(input.args);
4894
4895
  const nodeId = deps.isDataNodeIdCap?.(input.capName) === true ? void 0 : input.nodeId ?? extractNodeId(input.args);
4896
+ const pinnedToOtherNode = nodeId !== void 0 && nodeId !== deps.broker.nodeID;
4895
4897
  if (nodeId === void 0) {
4896
4898
  const empty = deps.resolveEmptyCollection?.(input.capName, input.method);
4897
4899
  if (empty != null) return empty;
@@ -4908,7 +4910,7 @@ function createParentUnownedCallHandler(deps) {
4908
4910
  }
4909
4911
  else deps.logger?.debug?.(`onUnownedCall: resolver not ready, routing ${input.capName}.${input.method} via broker fallback`);
4910
4912
  try {
4911
- if (deviceId !== void 0) {
4913
+ if (deviceId !== void 0 && !pinnedToOtherNode) {
4912
4914
  const localDispatcher = deps.getLocalDispatcher?.() ?? null;
4913
4915
  if (localDispatcher !== null) {
4914
4916
  let childId = localDispatcher.resolveChildId(input.capName, deviceId);
@@ -5063,7 +5065,7 @@ function localProviderLink(resolver, observerOpts) {
5063
5065
  const parsed = parsePath(op.path);
5064
5066
  if (!parsed) return next(op);
5065
5067
  if (localBase !== void 0) {
5066
- const pinnedNodeId = (0, _camstack_types.readNodePin)(op.context);
5068
+ const pinnedNodeId = require_dist.readNodePin(op.context);
5067
5069
  if (pinnedNodeId !== void 0 && pinnedNodeId !== localBase) return next(op);
5068
5070
  }
5069
5071
  const provider = resolver.getByName(parsed.capName);
@@ -5432,7 +5434,7 @@ function ipcParentLink(getCallOut) {
5432
5434
  const input = op.input;
5433
5435
  const inputObj = input && typeof input === "object" && !Array.isArray(input) ? input : null;
5434
5436
  const deviceId = inputObj && typeof Reflect.get(inputObj, "deviceId") === "number" ? Reflect.get(inputObj, "deviceId") : void 0;
5435
- const pinnedNodeId = (0, _camstack_types.readNodePin)(op.context);
5437
+ const pinnedNodeId = require_dist.readNodePin(op.context);
5436
5438
  const capCallInput = {
5437
5439
  capName: parsed.capName,
5438
5440
  method: parsed.method,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/system",
3
- "version": "1.1.34",
3
+ "version": "1.1.36",
4
4
  "description": "Core addon for CamStack — builtins, pipeline, process management, auth, logging, events",
5
5
  "keywords": [
6
6
  "camstack",