@camstack/server 1.2.827 → 1.2.829

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 (127) hide show
  1. package/CHANGELOG.md +20 -3
  2. package/dist/agent/agent-boot-mode.js +14 -1
  3. package/dist/agent/agent-http.js +12 -0
  4. package/dist/agent/agent-hub-rediscovery.js +205 -0
  5. package/dist/agent/agent-membership-watch.js +29 -1
  6. package/dist/agent/agent-pairing-store.js +47 -3
  7. package/dist/agent/hubs-found.js +1 -0
  8. package/dist/agent/main.js +64 -6
  9. package/dist/api/core/agent-pairing.router.js +9 -0
  10. package/dist/api/core/cluster-update.provider.js +98 -0
  11. package/dist/api/mesh-membership-routes.js +3 -2
  12. package/dist/api/trpc/generated-cap-mounts.js +2 -1
  13. package/dist/api/trpc/generated-cap-routers.js +2339 -2286
  14. package/dist/api/trpc/server-provided-caps.js +1 -0
  15. package/dist/api/trpc/trpc.router.js +5 -0
  16. package/dist/auth/auth-provider-gate.js +6 -2
  17. package/dist/core/addon/device-meta-mirror.js +1 -0
  18. package/dist/core/cluster-update/cluster-update-job-store.js +106 -0
  19. package/dist/core/cluster-update/cluster-update-plan.js +147 -0
  20. package/dist/core/cluster-update/cluster-update-seams.js +13 -0
  21. package/dist/core/cluster-update/cluster-update-steps.js +293 -0
  22. package/dist/core/cluster-update/cluster-update.service.js +319 -0
  23. package/dist/main.js +3 -0
  24. package/dist/manual-boot.js +19 -0
  25. package/package.json +17 -41
  26. package/system/dist/addon-runner.js +12 -0
  27. package/system/dist/addon-runner.mjs +12 -0
  28. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  29. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  30. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  31. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  32. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  33. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  34. package/system/dist/builtins/autotrack/index.js +1 -1
  35. package/system/dist/builtins/autotrack/index.mjs +1 -1
  36. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  37. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  38. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  39. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  40. package/system/dist/builtins/camera-grid/index.js +1 -1
  41. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  42. package/system/dist/builtins/composer/composer.addon.js +17 -6
  43. package/system/dist/builtins/composer/composer.addon.mjs +17 -6
  44. package/system/dist/builtins/composer/graft-host.d.ts +2 -0
  45. package/system/dist/builtins/console-logging/index.js +1 -1
  46. package/system/dist/builtins/console-logging/index.mjs +1 -1
  47. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  48. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  49. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  50. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  51. package/system/dist/builtins/device-manager/device-aggregation.d.ts +25 -1
  52. package/system/dist/builtins/device-manager/device-manager.addon.d.ts +6 -0
  53. package/system/dist/builtins/device-manager/device-manager.addon.js +354 -7
  54. package/system/dist/builtins/device-manager/device-manager.addon.mjs +354 -7
  55. package/system/dist/builtins/device-manager/device-meta-actions.d.ts +6 -0
  56. package/system/dist/builtins/device-manager/device-meta-types.d.ts +4 -0
  57. package/system/dist/builtins/device-manager/device-row-store.d.ts +2 -1
  58. package/system/dist/builtins/device-manager/device-search.d.ts +42 -0
  59. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  60. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  61. package/system/dist/builtins/keychain/index.js +4 -4
  62. package/system/dist/builtins/keychain/index.mjs +4 -4
  63. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  64. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  65. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  66. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  67. package/system/dist/builtins/local-network/hub-mdns.d.ts +5 -1
  68. package/system/dist/builtins/local-network/local-network.addon.js +24 -13
  69. package/system/dist/builtins/local-network/local-network.addon.mjs +24 -13
  70. package/system/dist/builtins/loki-logging/index.js +1 -1
  71. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  72. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  73. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  74. package/system/dist/builtins/platform-probe/index.js +1 -1
  75. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  76. package/system/dist/builtins/record-entries/index.js +1 -1
  77. package/system/dist/builtins/record-entries/index.mjs +1 -1
  78. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  79. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  80. package/system/dist/builtins/snapshot/index.js +1 -1
  81. package/system/dist/builtins/snapshot/index.mjs +1 -1
  82. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  83. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  84. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  85. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  86. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  87. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  88. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  89. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  90. package/system/dist/builtins/system-config/system-config.addon.js +59 -20
  91. package/system/dist/builtins/system-config/system-config.addon.mjs +48 -10
  92. package/system/dist/builtins/winston-logging/index.js +1 -1
  93. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  94. package/system/dist/{capture-engine-B0yQx6hA.mjs → capture-engine-CsFrmbpC.mjs} +1 -1
  95. package/system/dist/{capture-engine-1A7HAX3x.js → capture-engine-Cvetsl63.js} +1 -1
  96. package/system/dist/{composition-sources-CyJ0d6Sc.mjs → composition-sources-Yw0KDrdI.mjs} +1 -1
  97. package/system/dist/{composition-sources-BzM19ASO.js → composition-sources-wNOckeFb.js} +1 -1
  98. package/system/dist/{constants-B_FLEjP_.mjs → constants-B7-Ccoim.mjs} +1 -1
  99. package/system/dist/{constants-DSO4ZEO3.js → constants-BqrgVNCL.js} +1 -1
  100. package/system/dist/{device-ca-CveuNCHp.mjs → device-ca-BDKMOSKW.mjs} +1 -1
  101. package/system/dist/{device-ca-DLTDsonl.js → device-ca-C9VMoted.js} +1 -1
  102. package/system/dist/{dist-CIyyHwVx.mjs → dist-Bv_ADY4Y.mjs} +385 -20
  103. package/system/dist/{dist-DhbzVygm.js → dist-KJhkakFo.js} +385 -20
  104. package/system/dist/file-host-worker.js +1 -1
  105. package/system/dist/file-host-worker.mjs +1 -1
  106. package/system/dist/{agent-https-BlLVD9hG.js → hub-identity-BS1rzEes.js} +120 -1
  107. package/system/dist/{agent-https-BSxTUzKT.mjs → hub-identity-DSLLzLph.mjs} +97 -2
  108. package/system/dist/{hub-mdns-ciao-C_ITDs0-.js → hub-mdns-ciao-BQh04Eo9.js} +18 -18
  109. package/system/dist/{hub-mdns-ciao-CQdCUsrI.mjs → hub-mdns-ciao-FVifxI5j.mjs} +2 -2
  110. package/system/dist/index.js +61 -44
  111. package/system/dist/index.mjs +22 -10
  112. package/system/dist/kernel/hub-identity.d.ts +17 -0
  113. package/system/dist/kernel/index.d.ts +2 -0
  114. package/system/dist/kernel/moleculer/mesh-mtls/mesh-membership.d.ts +7 -0
  115. package/system/dist/kernel/moleculer/mesh-mtls/pairing/agent-pairing.d.ts +11 -1
  116. package/system/dist/kernel/moleculer/mesh-mtls/pairing/hub-pairing.d.ts +5 -0
  117. package/system/dist/kernel/moleculer/mesh-mtls/pairing/index.d.ts +1 -1
  118. package/system/dist/kernel/moleculer/mesh-mtls/pairing/pairing-protocol.d.ts +2 -0
  119. package/system/dist/{legacy-integration-rows-door-D_tfRhsx.js → legacy-integration-rows-door-B3K3A9JU.js} +1 -1
  120. package/system/dist/{legacy-integration-rows-door-tX6Qktxd.mjs → legacy-integration-rows-door-Cu9uee1R.mjs} +1 -1
  121. package/system/dist/{rename-composition-block-DNhbAonr.js → rename-composition-block-31JmUak2.js} +1 -1
  122. package/system/dist/{rename-composition-block-COaMxshT.mjs → rename-composition-block-BglTrMYB.mjs} +1 -1
  123. package/system/dist/{restore-archive-BMqp_hMT.mjs → restore-archive-5UHNYi4u.mjs} +1 -1
  124. package/system/dist/{restore-archive-Dbzuv5hK.js → restore-archive-BHOc02Fh.js} +1 -1
  125. package/system/dist/{wal-maintenance-CWODOTsa.js → wal-maintenance-At5TeYwr.js} +0 -0
  126. package/system/dist/{wal-maintenance-ITsLGvFA.mjs → wal-maintenance-COJdLp-y.mjs} +0 -0
  127. package/system/package.json +1 -1
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildClusterUpdateSeams = buildClusterUpdateSeams;
4
+ exports.buildClusterUpdateProvider = buildClusterUpdateProvider;
5
+ /**
6
+ * `cluster-update` — the hub-provided cap over {@link ClusterUpdateService},
7
+ * and the seams that bind the service to the hub's own services: the server
8
+ * update engine (hub) and the `server-management` proxy (agents), the
9
+ * topology, the `backup` singleton and the addons provider the admin UI uses.
10
+ */
11
+ const node_crypto_1 = require("node:crypto");
12
+ const zod_1 = require("zod");
13
+ const types_1 = require("@camstack/types");
14
+ const addon_package_service_js_1 = require("../../core/addon/addon-package.service.js");
15
+ const cluster_update_job_store_js_1 = require("../../core/cluster-update/cluster-update-job-store.js");
16
+ const cluster_update_seams_js_1 = require("../../core/cluster-update/cluster-update-seams.js");
17
+ const cap_providers_js_1 = require("./cap-providers.js");
18
+ const UpdatePackageResultShape = zod_1.z.looseObject({
19
+ success: zod_1.z.boolean(),
20
+ error: zod_1.z.string().optional(),
21
+ });
22
+ /** The job runs without a request behind it; its addon updates are `system`'s. */
23
+ const SYSTEM_CONTEXT = { user: null };
24
+ function serverManagementProxy(moleculer, nodeId) {
25
+ const proxy = moleculer.createCapabilityProxy('server-management', nodeId);
26
+ if (proxy === null)
27
+ throw new Error(`server-management unreachable on ${nodeId}`);
28
+ return proxy;
29
+ }
30
+ async function callProxy(proxy, method, params) {
31
+ const fn = proxy[method];
32
+ if (fn === undefined)
33
+ throw new Error(`server-management.${method} is not callable`);
34
+ return fn(params);
35
+ }
36
+ function buildClusterUpdateSeams(deps) {
37
+ const logger = deps.loggingService.createLogger('ClusterUpdate');
38
+ const nodes = (0, cap_providers_js_1.buildNodesProvider)(deps.agentRegistry, deps.moleculer, deps.addonRegistry, (0, cap_providers_js_1.createNodeRootPackageLookup)(deps.moleculer, deps.serverUpdate), logger);
39
+ const addons = () => (0, cap_providers_js_1.buildAddonsProvider)(deps.addonRegistry, deps.addonPackages, deps.loggingService, deps.moleculer, deps.configService, SYSTEM_CONTEXT, deps.agentRegistry);
40
+ return {
41
+ readTopology: async () => (await nodes.topology()).map((n) => ({
42
+ id: n.id,
43
+ isHub: n.isHub,
44
+ isOnline: n.isOnline,
45
+ ...(n.capabilitiesRegistered !== undefined
46
+ ? { capabilitiesRegistered: n.capabilitiesRegistered }
47
+ : {}),
48
+ capabilityCount: new Set(n.addons.flatMap((a) => a.capabilities)).size,
49
+ })),
50
+ readServerStatus: async (nodeId) => nodeId === null
51
+ ? deps.serverUpdate.getServerPackageStatus()
52
+ : types_1.ServerPackageStatusSchema.parse(await callProxy(serverManagementProxy(deps.moleculer, nodeId), 'getServerPackageStatus', {})),
53
+ applyServerUpdate: async (nodeId, version) => nodeId === null
54
+ ? deps.serverUpdate.applyServerUpdate({ version })
55
+ : types_1.ServerUpdateActionResultSchema.parse(await callProxy(serverManagementProxy(deps.moleculer, nodeId), 'applyServerUpdate', {
56
+ version,
57
+ })),
58
+ getBackup: () => {
59
+ const backup = deps.addonRegistry
60
+ .getCapabilityRegistry()
61
+ .getSingleton('backup');
62
+ if (backup === null)
63
+ return null;
64
+ return {
65
+ trigger: (label) => backup.trigger({ label }),
66
+ listRuns: () => backup.listRuns(),
67
+ };
68
+ },
69
+ // Framework packages travel with the server closure, and an update held
70
+ // for a server minimum (D989) is not offered: it waits for that server.
71
+ listAddonUpdates: async () => (await deps.addonPackages.checkUpdates()).filter((u) => u.category === 'addon' && u.name !== addon_package_service_js_1.SYSTEM_PACKAGE && u.blockedBy === undefined),
72
+ updateAddon: async (name, version) => {
73
+ // The cap declares its output `unknown`; the provider answers this shape.
74
+ const parsed = UpdatePackageResultShape.safeParse(await addons().updatePackage({ name, version }));
75
+ if (!parsed.success)
76
+ return { success: false, error: 'unrecognised updatePackage answer' };
77
+ return parsed.data.success
78
+ ? { success: true }
79
+ : { success: false, error: parsed.data.error ?? 'update failed' };
80
+ },
81
+ readInstallations: async () => (await addons().listInstallations({})).installations,
82
+ store: new cluster_update_job_store_js_1.FileClusterUpdateJobStore(deps.dataDir, logger),
83
+ logger,
84
+ now: Date.now,
85
+ sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
86
+ newId: () => (0, node_crypto_1.randomUUID)(),
87
+ timeouts: cluster_update_seams_js_1.DEFAULT_CLUSTER_UPDATE_TIMEOUTS,
88
+ };
89
+ }
90
+ function buildClusterUpdateProvider(service, ctx) {
91
+ if (service === null)
92
+ return null;
93
+ return {
94
+ previewClusterUpdate: (input) => service.preview(input),
95
+ startClusterUpdate: (input) => service.start(input, ctx.user?.username ?? ctx.user?.id ?? 'system'),
96
+ getClusterUpdateJob: async (input) => service.getJob(input.jobId),
97
+ };
98
+ }
@@ -6,7 +6,7 @@ const system_1 = require("@camstack/server/system");
6
6
  const auth_rate_limit_1 = require("../auth/auth-rate-limit");
7
7
  const WINDOW_MS = 60_000;
8
8
  const DEFAULT_PER_MINUTE = 60;
9
- function createProcessMembershipResponder(logger) {
9
+ function createProcessMembershipResponder(logger, hubId) {
10
10
  return new system_1.MembershipResponder({
11
11
  registry: system_1.getProcessMeshCertificateRegistry,
12
12
  crl: system_1.processMeshCrl,
@@ -14,11 +14,12 @@ function createProcessMembershipResponder(logger) {
14
14
  const state = (0, system_1.getProcessMeshCaState)();
15
15
  return state.state === 'ready' ? state.ca.keyPem : null;
16
16
  },
17
+ ...(hubId !== undefined ? { hubId } : {}),
17
18
  log: (message, meta) => logger.warn(message, { tags: { nodeId: meta.nodeId } }),
18
19
  });
19
20
  }
20
21
  function registerMeshMembershipRoutes(fastify, options) {
21
- const responder = options.responder ?? createProcessMembershipResponder(options.logger);
22
+ const responder = options.responder ?? createProcessMembershipResponder(options.logger, options.hubId);
22
23
  const limiter = (0, auth_rate_limit_1.createRateLimiter)({
23
24
  windowMs: WINDOW_MS,
24
25
  max: options.perMinute ?? DEFAULT_PER_MINUTE,
@@ -2,7 +2,7 @@
2
2
  // AUTO-GENERATED by scripts/generate-cap-mounts.ts — DO NOT EDIT
3
3
  // Re-run: npx tsx scripts/generate-cap-mounts.ts
4
4
  //
5
- // Mounted: 202 Skipped (legacy): 3
5
+ // Mounted: 203 Skipped (legacy): 3
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.LEGACY_SHAPE_SKIP = void 0;
8
8
  exports.mountAllCaps = mountAllCaps;
@@ -157,6 +157,7 @@ function mountAllCaps(services) {
157
157
  cameraStreams: (0, generated_cap_routers_js_1.createCapRouter_cameraStreams)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'camera-streams'), remoteCapProxy),
158
158
  carbonMonoxide: (0, generated_cap_routers_js_1.createCapRouter_carbonMonoxide)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'carbon-monoxide'), remoteCapProxy),
159
159
  climateControl: (0, generated_cap_routers_js_1.createCapRouter_climateControl)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'climate-control'), remoteCapProxy),
160
+ clusterUpdate: (0, generated_cap_routers_js_1.createCapRouter_clusterUpdate)((_ctx) => reg?.getSingleton('cluster-update') ?? null, remoteCapProxy),
160
161
  color: (0, generated_cap_routers_js_1.createCapRouter_color)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'color'), remoteCapProxy),
161
162
  composer: (0, generated_cap_routers_js_1.createCapRouter_composer)((_ctx) => reg?.getSingleton('composer') ?? null, remoteCapProxy),
162
163
  connectivity: (0, generated_cap_routers_js_1.createCapRouter_connectivity)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'connectivity'), remoteCapProxy),