@camstack/server 1.2.910 → 1.2.911
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.
- package/CHANGELOG.md +7 -0
- package/dist/agent/main.js +21 -8
- package/dist/api/core/cap-providers.js +81 -78
- package/dist/api/trpc/generated-cap-routers.js +20 -0
- package/dist/core/addon/addon-registry.service.js +25 -1
- package/dist/core/addon/instance-lifecycle.js +106 -33
- package/package.json +29 -12
- package/system/dist/addon-runner.js +229 -21
- package/system/dist/addon-runner.mjs +230 -22
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +4 -4
- package/system/dist/builtins/composer/composer.addon.mjs +4 -4
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +4 -4
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -4
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +3 -3
- package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
- package/system/dist/builtins/loki-logging/index.js +15 -9
- package/system/dist/builtins/loki-logging/index.mjs +15 -9
- package/system/dist/builtins/loki-logging/loki-logging.addon.d.ts +6 -0
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-B7DJgM95.js → capture-engine-CRXUcNzg.js} +1 -1
- package/system/dist/{capture-engine-DTx0c7kf.mjs → capture-engine-erwNulcY.mjs} +1 -1
- package/system/dist/{composition-sources-DRZuLQaM.js → composition-sources-CmJRQLAB.js} +1 -1
- package/system/dist/{composition-sources-CY6MmRpR.mjs → composition-sources-DrQFzsQU.mjs} +1 -1
- package/system/dist/{constants-BIYn2uH-.js → constants-BuRweEmb.js} +1 -1
- package/system/dist/{constants-DKNphWBk.mjs → constants-D9ZICjoN.mjs} +1 -1
- package/system/dist/{device-ca-N9oMCP1h.js → device-ca-DGwzbKB7.js} +1 -1
- package/system/dist/{device-ca-CoeuG8vp.mjs → device-ca-XXMVM6Lu.mjs} +1 -1
- package/system/dist/{dist-xH7EdlAg.js → dist-CZx3IYRz.js} +487 -39
- package/system/dist/{dist-CUt0SVMu.mjs → dist-DUYpvNfO.mjs} +486 -38
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-BPRu1Pr9.mjs → hub-identity-Dc-SOwBk.mjs} +1 -1
- package/system/dist/{hub-identity-As9K7AG1.js → hub-identity-vVRXZi0z.js} +1 -1
- package/system/dist/{hub-mdns-ciao-D4CeSt_C.mjs → hub-mdns-ciao-DpRGDUEE.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-jaGozuwj.js → hub-mdns-ciao-uCdDDwE4.js} +2 -2
- package/system/dist/index.d.ts +1 -0
- package/system/dist/index.js +218 -26
- package/system/dist/index.mjs +219 -28
- package/system/dist/kernel/moleculer/accessory-spawn-retry.d.ts +67 -0
- package/system/dist/kernel/moleculer/device-cap-proxy.d.ts +2 -0
- package/system/dist/kernel/moleculer/hub-connect-switches.d.ts +23 -0
- package/system/dist/{legacy-integration-rows-door-Gk42wKsu.js → legacy-integration-rows-door-CtObsXaU.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-DAAF9Orf.mjs → legacy-integration-rows-door-DvbF3IY8.mjs} +1 -1
- package/system/dist/{rename-composition-block-CWJ_zyT_.mjs → rename-composition-block-CowZDV1m.mjs} +1 -1
- package/system/dist/{rename-composition-block-PFCvxuaj.js → rename-composition-block-rKmnICiK.js} +1 -1
- package/system/dist/{restore-archive-r_vUDU7Z.js → restore-archive-BvvAR6Ww.js} +1 -1
- package/system/dist/{restore-archive-BABm0OtJ.mjs → restore-archive-DH-lFUT0.mjs} +1 -1
- package/system/dist/{wal-maintenance-DugOl9LZ.mjs → wal-maintenance-B0uiPZUs.mjs} +0 -0
- package/system/dist/{wal-maintenance-hrjEiyFX.js → wal-maintenance-CB9zUxb-.js} +0 -0
- package/system/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-Cek0wNdY.js");
|
|
2
|
-
const require_wal_maintenance = require("./wal-maintenance-
|
|
2
|
+
const require_wal_maintenance = require("./wal-maintenance-CB9zUxb-.js");
|
|
3
3
|
let node_worker_threads = require("node:worker_threads");
|
|
4
4
|
//#region src/builtins/sqlite-storage/file-host-worker.ts
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-
|
|
1
|
+
import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-B0uiPZUs.mjs";
|
|
2
2
|
import { parentPort, threadId, workerData } from "node:worker_threads";
|
|
3
3
|
//#region src/builtins/sqlite-storage/file-host-worker.ts
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tl as defineRecordKinds } from "./dist-
|
|
1
|
+
import { Tl as defineRecordKinds } from "./dist-DUYpvNfO.mjs";
|
|
2
2
|
import { C as backdatedNotBefore, S as withUtcTimeEncoding, _ as NameConstraints, a as KeyUsageFlags, c as Pkcs10CertificateRequest, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, g as GeneralSubtrees, h as GeneralSubtree, i as Extension, l as Pkcs10CertificateRequestGenerator, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension, v as GeneralName, x as AsnConvert } from "./x509.es-BRiJgOvu.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { X509Certificate, createHash, createPrivateKey, randomBytes, webcrypto } from "node:crypto";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Cek0wNdY.js");
|
|
2
|
-
const require_dist = require("./dist-
|
|
2
|
+
const require_dist = require("./dist-CZx3IYRz.js");
|
|
3
3
|
const require_x509_es = require("./x509.es-WtnRNyYS.js");
|
|
4
4
|
let zod = require("zod");
|
|
5
5
|
let node_crypto = require("node:crypto");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { o as __toESM } from "./chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import { yu as userError } from "./dist-
|
|
2
|
+
import { yu as userError } from "./dist-DUYpvNfO.mjs";
|
|
3
3
|
import { f as X509Certificate$1 } from "./x509.es-BRiJgOvu.mjs";
|
|
4
|
-
import { A as evaluateExistingCert, C as localCaCommonName, F as isConstrainedCa, L as permitsIdentity, S as loadCa, b as generateCa, j as reasonRequiresNewCa, w as collectCertIdentity, x as issueLeaf, z as readNameConstraints } from "./hub-identity-
|
|
4
|
+
import { A as evaluateExistingCert, C as localCaCommonName, F as isConstrainedCa, L as permitsIdentity, S as loadCa, b as generateCa, j as reasonRequiresNewCa, w as collectCertIdentity, x as issueLeaf, z as readNameConstraints } from "./hub-identity-Dc-SOwBk.mjs";
|
|
5
5
|
import { X509Certificate, createPrivateKey } from "node:crypto";
|
|
6
6
|
import { writeOwnerOnlyFileSync } from "@camstack/types/node";
|
|
7
7
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Cek0wNdY.js");
|
|
2
|
-
const require_dist = require("./dist-
|
|
2
|
+
const require_dist = require("./dist-CZx3IYRz.js");
|
|
3
3
|
const require_x509_es = require("./x509.es-WtnRNyYS.js");
|
|
4
|
-
const require_hub_identity = require("./hub-identity-
|
|
4
|
+
const require_hub_identity = require("./hub-identity-vVRXZi0z.js");
|
|
5
5
|
let node_crypto = require("node:crypto");
|
|
6
6
|
let _camstack_types_node = require("@camstack/types/node");
|
|
7
7
|
let node_fs = require("node:fs");
|
package/system/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ export { createEventPlaneMeter, createEventPlaneReader, diffEventPlane, EVENT_PL
|
|
|
78
78
|
export type { SocketPeerDelta, SocketPeerSample, SocketPlaneBaseline, SocketPlaneCounters, SocketPlaneMeter, SocketPlaneReader, SocketPlaneRegistry, SocketPlaneRegistryChild, SocketPlaneSources, SocketPlaneWindow } from "./kernel/socket-plane-report.js";
|
|
79
79
|
export { createSocketPlaneMeter, createSocketPlaneReader, diffSocketPlane, EMPTY_SOCKET_PLANE_BASELINE, formatSocketPlane, readSocketQueues, SOCKET_PLANE_TOP_N, SOCKET_QUEUE_TOP_N } from "./kernel/socket-plane-report.js";
|
|
80
80
|
export type { SocketPeerQueue, SocketQueueReading } from "./kernel/socket-plane-report.js";
|
|
81
|
+
export { rehydrateSwitchesOnHubConnect } from "./kernel/moleculer/hub-connect-switches.js";
|
|
81
82
|
export type { MeshPeerQueue, MeshQueueReader } from "./kernel/moleculer/mesh-queue-report.js";
|
|
82
83
|
export { createMeshQueueReader, formatMeshQueue, MESH_QUEUE_TOP_N } from "./kernel/moleculer/mesh-queue-report.js";
|
|
83
84
|
export type { OutboundQueueGate, OutboundQueueGateOptions, OutboundQueueReading, OutboundQueueVerdict } from "./kernel/outbound-queue-watch.js";
|
package/system/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("./chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("./dist-
|
|
4
|
-
const require_device_ca = require("./device-ca-
|
|
3
|
+
const require_dist = require("./dist-CZx3IYRz.js");
|
|
4
|
+
const require_device_ca = require("./device-ca-DGwzbKB7.js");
|
|
5
5
|
const require_read_all_rows$1 = require("./read-all-rows-CVoO1ONM.js");
|
|
6
6
|
const require_log_redactor = require("./log-redactor-BhIEMaG9.js");
|
|
7
7
|
const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
|
|
@@ -28,22 +28,22 @@ const require_builtins_loki_logging_index = require("./builtins/loki-logging/ind
|
|
|
28
28
|
const require_builtins_native_metrics_native_metrics_addon = require("./builtins/native-metrics/native-metrics.addon.js");
|
|
29
29
|
const require_builtins_device_history_device_history_addon = require("./builtins/device-history/device-history.addon.js");
|
|
30
30
|
const require_builtins_sqlite_storage_filesystem_storage_addon = require("./builtins/sqlite-storage/filesystem-storage.addon.js");
|
|
31
|
-
const require_wal_maintenance = require("./wal-maintenance-
|
|
32
|
-
const require_legacy_integration_rows_door = require("./legacy-integration-rows-door-
|
|
31
|
+
const require_wal_maintenance = require("./wal-maintenance-CB9zUxb-.js");
|
|
32
|
+
const require_legacy_integration_rows_door = require("./legacy-integration-rows-door-CtObsXaU.js");
|
|
33
33
|
const require_builtins_sqlite_storage_sqlite_settings_addon = require("./builtins/sqlite-storage/sqlite-settings.addon.js");
|
|
34
34
|
const require_builtins_sqlite_storage_index = require("./builtins/sqlite-storage/index.js");
|
|
35
35
|
const require_builtins_storage_orchestrator_storage_orchestrator_addon = require("./builtins/storage-orchestrator/storage-orchestrator.addon.js");
|
|
36
36
|
require("./builtins/storage-orchestrator/index.js");
|
|
37
|
-
const require_hub_identity = require("./hub-identity-
|
|
38
|
-
const require_constants = require("./constants-
|
|
37
|
+
const require_hub_identity = require("./hub-identity-vVRXZi0z.js");
|
|
38
|
+
const require_constants = require("./constants-BuRweEmb.js");
|
|
39
39
|
const require_builtins_system_config_system_config_addon = require("./builtins/system-config/system-config.addon.js");
|
|
40
40
|
require("./builtins/system-config/index.js");
|
|
41
41
|
const require_builtins_winston_logging_index = require("./builtins/winston-logging/index.js");
|
|
42
42
|
const require_custom_action_registry = require("./custom-action-registry-CmWpSeMS.js");
|
|
43
|
-
const require_hub_mdns_ciao = require("./hub-mdns-ciao-
|
|
43
|
+
const require_hub_mdns_ciao = require("./hub-mdns-ciao-uCdDDwE4.js");
|
|
44
44
|
const require_platform_key_source = require("./platform-key-source-Di7HrlGR.js");
|
|
45
45
|
const require_resource_monitor = require("./resource-monitor-mio9dSCT.js");
|
|
46
|
-
const require_restore_archive = require("./restore-archive-
|
|
46
|
+
const require_restore_archive = require("./restore-archive-BvvAR6Ww.js");
|
|
47
47
|
const require_coral_accelerators = require("./coral-accelerators-BSVsBVzt.js");
|
|
48
48
|
let zod = require("zod");
|
|
49
49
|
let node_crypto = require("node:crypto");
|
|
@@ -1225,6 +1225,25 @@ function formatSocketPlane(window) {
|
|
|
1225
1225
|
return ` socketPeers=${window.peersMeasured}/${window.peersConnected} socketTx=${formatDirection(window.tx)} socketRx=${formatDirection(window.rx)}` + (top.length === 0 ? "" : ` socketTop=${top}`) + (topBytes.length === 0 ? "" : ` socketTopBytes=${topBytes}`) + ` socketQueued=${kb$1(window.queued.totalBytes)}kB` + (window.queued.unmeasured === 0 ? "" : ` socketQueuedUnmeasured=${window.queued.unmeasured}`) + (queuedTop.length === 0 ? "" : ` socketQueuedTop=${queuedTop}`) + (window.forward === void 0 ? "" : ` socketFwd=${window.forward.raw}/${window.forward.decoded}`) + (window.actions === void 0 ? "" : ` socketActions=${kb$1(window.actions.labelledBytes)}/${kb$1(window.actions.totalBytes)}kB` + (window.actions.top.length === 0 ? "" : ` socketTopActions=${window.actions.top.map(formatAction).join(",")}`));
|
|
1226
1226
|
}
|
|
1227
1227
|
//#endregion
|
|
1228
|
+
//#region src/kernel/moleculer/hub-connect-switches.ts
|
|
1229
|
+
/**
|
|
1230
|
+
* On a hub connect, every addon with instance kinds reads its switches from the registry again
|
|
1231
|
+
* (D1066). Event-driven, no timer (D3): the next connect retries. A forked runner's FIRST connect
|
|
1232
|
+
* is its boot, so a registry that still does not answer ends the process and the supervisor
|
|
1233
|
+
* respawns it, bounded and marked terminally failed (D6), instead of leaving instances off.
|
|
1234
|
+
*/
|
|
1235
|
+
async function rehydrateSwitchesOnHubConnect(entries, deps) {
|
|
1236
|
+
for (const entry of entries) {
|
|
1237
|
+
if (entry.addon.rehydrateSwitches === void 0) continue;
|
|
1238
|
+
try {
|
|
1239
|
+
await entry.addon.rehydrateSwitches();
|
|
1240
|
+
} catch (err) {
|
|
1241
|
+
if (deps.fatalOnUnread && (0, _camstack_types_addon.isInstanceSwitchesUnreadError)(err)) deps.exit(entry.addonId, err);
|
|
1242
|
+
else deps.onUnread(entry.addonId, err);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
//#endregion
|
|
1228
1247
|
//#region src/kernel/moleculer/mesh-queue-report.ts
|
|
1229
1248
|
function isRecord$6(value) {
|
|
1230
1249
|
return typeof value === "object" && value !== null;
|
|
@@ -5709,7 +5728,7 @@ var IntegrationRegistry = class IntegrationRegistry {
|
|
|
5709
5728
|
await this.resumeCounter();
|
|
5710
5729
|
}
|
|
5711
5730
|
async resumeCounter() {
|
|
5712
|
-
const rows = await (0, import_read_all_rows.readAllRows)(this.recordStores.integrations, { order: "id" });
|
|
5731
|
+
const rows = (await (0, import_read_all_rows.readAllRows)(this.recordStores.integrations, { order: "id" })).filter((r) => /^int_\d+$/.test(r.id));
|
|
5713
5732
|
rows.sort((a, b) => b.id.localeCompare(a.id));
|
|
5714
5733
|
const top = rows[0];
|
|
5715
5734
|
if (top !== void 0) {
|
|
@@ -5722,7 +5741,7 @@ var IntegrationRegistry = class IntegrationRegistry {
|
|
|
5722
5741
|
...rawInput,
|
|
5723
5742
|
addonId: require_dist.bareAddonId(rawInput.addonId)
|
|
5724
5743
|
};
|
|
5725
|
-
const id = nextIntegrationId();
|
|
5744
|
+
const id = input.id ?? nextIntegrationId();
|
|
5726
5745
|
const now = Math.floor(Date.now() / 1e3);
|
|
5727
5746
|
const enabled = input.enabled !== false;
|
|
5728
5747
|
const info = input.info ?? {};
|
|
@@ -5738,7 +5757,7 @@ var IntegrationRegistry = class IntegrationRegistry {
|
|
|
5738
5757
|
await this.recordStores.integrations.put({
|
|
5739
5758
|
id,
|
|
5740
5759
|
data: body
|
|
5741
|
-
});
|
|
5760
|
+
}, input.id === void 0 ? void 0 : { ifRev: 0 });
|
|
5742
5761
|
return mapIntegrationBody(id, body);
|
|
5743
5762
|
}
|
|
5744
5763
|
async getIntegration(id) {
|
|
@@ -14007,6 +14026,156 @@ var AccessoryShrinkGate = class {
|
|
|
14007
14026
|
}
|
|
14008
14027
|
};
|
|
14009
14028
|
//#endregion
|
|
14029
|
+
//#region src/kernel/moleculer/accessory-spawn-retry.ts
|
|
14030
|
+
/** A spawn failure that knows which step threw. */
|
|
14031
|
+
var AccessorySpawnStepError = class extends Error {
|
|
14032
|
+
step;
|
|
14033
|
+
/** The child's numeric id once allocated; null when allocation itself failed. */
|
|
14034
|
+
deviceId;
|
|
14035
|
+
constructor(step, deviceId, cause) {
|
|
14036
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
14037
|
+
super(`${step}: ${reason}`, { cause });
|
|
14038
|
+
this.name = "AccessorySpawnStepError";
|
|
14039
|
+
this.step = step;
|
|
14040
|
+
this.deviceId = deviceId;
|
|
14041
|
+
}
|
|
14042
|
+
};
|
|
14043
|
+
function describeError(error) {
|
|
14044
|
+
if (error instanceof AccessorySpawnStepError) return {
|
|
14045
|
+
step: error.step,
|
|
14046
|
+
reason: error.message.slice(error.step.length + 2)
|
|
14047
|
+
};
|
|
14048
|
+
return {
|
|
14049
|
+
step: "unknown",
|
|
14050
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
14051
|
+
};
|
|
14052
|
+
}
|
|
14053
|
+
var AccessorySpawnRetry = class AccessorySpawnRetry {
|
|
14054
|
+
#logger;
|
|
14055
|
+
#delaysMs;
|
|
14056
|
+
/** Pending spawns, by `<parent>:<child stableId>`. */
|
|
14057
|
+
#pending = /* @__PURE__ */ new Map();
|
|
14058
|
+
/** Gave up — sticks until the parent is registered again. */
|
|
14059
|
+
#gaveUp = /* @__PURE__ */ new Set();
|
|
14060
|
+
constructor(options) {
|
|
14061
|
+
this.#logger = options.logger;
|
|
14062
|
+
this.#delaysMs = options.delaysMs ?? _camstack_types_addon.DEVICE_RESTORE_RETRY_DELAYS_MS;
|
|
14063
|
+
}
|
|
14064
|
+
static #key(parentDeviceId, stableId) {
|
|
14065
|
+
return `${parentDeviceId}:${stableId}`;
|
|
14066
|
+
}
|
|
14067
|
+
/** The parent went away (teardown / shutdown): drop its pending rounds and its give-ups. */
|
|
14068
|
+
cancelParent(parentDeviceId) {
|
|
14069
|
+
for (const [key, entry] of this.#pending) {
|
|
14070
|
+
if (entry.parentDeviceId !== parentDeviceId) continue;
|
|
14071
|
+
entry.cancelled = true;
|
|
14072
|
+
if (entry.timer !== null) clearTimeout(entry.timer);
|
|
14073
|
+
this.#pending.delete(key);
|
|
14074
|
+
}
|
|
14075
|
+
this.#forgetGiveUps(parentDeviceId);
|
|
14076
|
+
}
|
|
14077
|
+
/** The parent registered again: a fresh chance for children that gave up. */
|
|
14078
|
+
resetParent(parentDeviceId) {
|
|
14079
|
+
this.#forgetGiveUps(parentDeviceId);
|
|
14080
|
+
}
|
|
14081
|
+
#forgetGiveUps(parentDeviceId) {
|
|
14082
|
+
const prefix = `${parentDeviceId}:`;
|
|
14083
|
+
for (const key of this.#gaveUp) if (key.startsWith(prefix)) this.#gaveUp.delete(key);
|
|
14084
|
+
}
|
|
14085
|
+
/** Record the initial failure and run the bounded rounds in the background. */
|
|
14086
|
+
schedule(request) {
|
|
14087
|
+
const key = AccessorySpawnRetry.#key(request.parentDeviceId, request.stableId);
|
|
14088
|
+
if (this.#pending.has(key)) return;
|
|
14089
|
+
if (this.#gaveUp.has(key)) {
|
|
14090
|
+
this.#logger.debug("Accessory child spawn skipped — gave up earlier, parent not re-registered", {
|
|
14091
|
+
tags: { parentDeviceId: request.parentDeviceId },
|
|
14092
|
+
meta: { stableId: request.stableId }
|
|
14093
|
+
});
|
|
14094
|
+
return;
|
|
14095
|
+
}
|
|
14096
|
+
const entry = {
|
|
14097
|
+
parentDeviceId: request.parentDeviceId,
|
|
14098
|
+
cancelled: false,
|
|
14099
|
+
timer: null
|
|
14100
|
+
};
|
|
14101
|
+
this.#pending.set(key, entry);
|
|
14102
|
+
this.#record(request, request.deviceId, request.error, 0, false);
|
|
14103
|
+
this.#run(key, entry, request);
|
|
14104
|
+
}
|
|
14105
|
+
#record(request, deviceId, error, retry, terminal) {
|
|
14106
|
+
const { step, reason } = describeError(error);
|
|
14107
|
+
this.#logger.error(terminal ? "Accessory child spawn gave up after the bounded retries" : "Accessory child spawn failed", {
|
|
14108
|
+
tags: {
|
|
14109
|
+
...deviceId === null ? {} : { deviceId },
|
|
14110
|
+
parentDeviceId: request.parentDeviceId
|
|
14111
|
+
},
|
|
14112
|
+
meta: {
|
|
14113
|
+
stableId: request.stableId,
|
|
14114
|
+
step,
|
|
14115
|
+
error: reason,
|
|
14116
|
+
retry,
|
|
14117
|
+
max: this.#delaysMs.length
|
|
14118
|
+
}
|
|
14119
|
+
});
|
|
14120
|
+
}
|
|
14121
|
+
async #run(key, entry, request) {
|
|
14122
|
+
let lastError = request.error;
|
|
14123
|
+
let deviceId = request.deviceId;
|
|
14124
|
+
for (let round = 1; round <= this.#delaysMs.length; round += 1) {
|
|
14125
|
+
await this.#sleep(entry, this.#delaysMs[round - 1] ?? 0);
|
|
14126
|
+
if (entry.cancelled) return;
|
|
14127
|
+
if (!request.isParentRegistered()) {
|
|
14128
|
+
this.#pending.delete(key);
|
|
14129
|
+
this.#logger.info("Accessory child spawn retry skipped — parent no longer registered", {
|
|
14130
|
+
tags: {
|
|
14131
|
+
...deviceId === null ? {} : { deviceId },
|
|
14132
|
+
parentDeviceId: request.parentDeviceId
|
|
14133
|
+
},
|
|
14134
|
+
meta: {
|
|
14135
|
+
stableId: request.stableId,
|
|
14136
|
+
retry: round
|
|
14137
|
+
}
|
|
14138
|
+
});
|
|
14139
|
+
return;
|
|
14140
|
+
}
|
|
14141
|
+
try {
|
|
14142
|
+
await request.attempt({ final: round === this.#delaysMs.length });
|
|
14143
|
+
if (entry.cancelled) return;
|
|
14144
|
+
this.#pending.delete(key);
|
|
14145
|
+
this.#logger.info("Accessory child spawned on retry", {
|
|
14146
|
+
tags: {
|
|
14147
|
+
...deviceId === null ? {} : { deviceId },
|
|
14148
|
+
parentDeviceId: request.parentDeviceId
|
|
14149
|
+
},
|
|
14150
|
+
meta: {
|
|
14151
|
+
stableId: request.stableId,
|
|
14152
|
+
retry: round
|
|
14153
|
+
}
|
|
14154
|
+
});
|
|
14155
|
+
return;
|
|
14156
|
+
} catch (err) {
|
|
14157
|
+
if (entry.cancelled) return;
|
|
14158
|
+
lastError = err;
|
|
14159
|
+
if (err instanceof AccessorySpawnStepError && err.deviceId !== null) deviceId = err.deviceId;
|
|
14160
|
+
if (round < this.#delaysMs.length) this.#record(request, deviceId, err, round, false);
|
|
14161
|
+
}
|
|
14162
|
+
}
|
|
14163
|
+
this.#record(request, deviceId, lastError, this.#delaysMs.length, true);
|
|
14164
|
+
this.#pending.delete(key);
|
|
14165
|
+
this.#gaveUp.add(key);
|
|
14166
|
+
}
|
|
14167
|
+
#sleep(entry, ms) {
|
|
14168
|
+
return new Promise((resolve) => {
|
|
14169
|
+
const timer = setTimeout(() => {
|
|
14170
|
+
entry.timer = null;
|
|
14171
|
+
resolve();
|
|
14172
|
+
}, ms);
|
|
14173
|
+
timer.unref?.();
|
|
14174
|
+
entry.timer = timer;
|
|
14175
|
+
});
|
|
14176
|
+
}
|
|
14177
|
+
};
|
|
14178
|
+
//#endregion
|
|
14010
14179
|
//#region src/kernel/moleculer/runtime-state-load.ts
|
|
14011
14180
|
/** A device build refused because its runtime state could not be loaded. */
|
|
14012
14181
|
var RuntimeStateLoadError = class extends Error {
|
|
@@ -14550,6 +14719,10 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
14550
14719
|
const resolveParentIntegrationId = async (parentId) => {
|
|
14551
14720
|
return (await callDeviceManager(api, "loadMeta", { deviceId: parentId }).catch(() => null))?.integrationId ?? void 0;
|
|
14552
14721
|
};
|
|
14722
|
+
const accessorySpawnRetry = new AccessorySpawnRetry({
|
|
14723
|
+
logger: opts.logger,
|
|
14724
|
+
...opts.accessorySpawnRetryDelaysMs !== void 0 ? { delaysMs: opts.accessorySpawnRetryDelaysMs } : {}
|
|
14725
|
+
});
|
|
14553
14726
|
/**
|
|
14554
14727
|
* Spawn one accessory child device declared by a parent's
|
|
14555
14728
|
* `getAccessoryChildren()`. Mirrors the standard `create()` flow
|
|
@@ -14559,9 +14732,20 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
14559
14732
|
* row already exists, `persistInitialConfig` is skipped (config
|
|
14560
14733
|
* arg empty) and the child self-hydrates from `loadConfig`.
|
|
14561
14734
|
*/
|
|
14562
|
-
const spawnAccessoryChild = async (parent, spec) => {
|
|
14735
|
+
const spawnAccessoryChild = async (parent, spec, spawnOptions = { final: false }) => {
|
|
14563
14736
|
const childStableId = `${parent.stableId}-${spec.stableIdSuffix}`;
|
|
14564
|
-
|
|
14737
|
+
let allocatedId = null;
|
|
14738
|
+
try {
|
|
14739
|
+
return await spawnAccessoryChildSteps(parent, spec, childStableId, (id) => {
|
|
14740
|
+
allocatedId = id;
|
|
14741
|
+
}, spawnOptions);
|
|
14742
|
+
} catch (err) {
|
|
14743
|
+
throw err instanceof AccessorySpawnStepError ? err : new AccessorySpawnStepError("register", allocatedId, err);
|
|
14744
|
+
}
|
|
14745
|
+
};
|
|
14746
|
+
const spawnAccessoryChildSteps = async (parent, spec, childStableId, onAllocated, spawnOptions) => {
|
|
14747
|
+
const id = await deviceApi.allocateDeviceId(childStableId).catch((err) => Promise.reject(new AccessorySpawnStepError("allocateDeviceId", null, err)));
|
|
14748
|
+
onAllocated(id);
|
|
14565
14749
|
const existing = registry.getById(id);
|
|
14566
14750
|
if (existing && existing.stableId === childStableId) return existing;
|
|
14567
14751
|
const empty = {};
|
|
@@ -14578,12 +14762,17 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
14578
14762
|
...spec.meta.type !== void 0 ? { type: spec.meta.type } : {},
|
|
14579
14763
|
...integrationId !== void 0 ? { integrationId } : {}
|
|
14580
14764
|
}).catch((err) => {
|
|
14581
|
-
|
|
14765
|
+
if (!spawnOptions.final) return Promise.reject(new AccessorySpawnStepError("applyInitialMeta", id, err));
|
|
14766
|
+
opts.logger.error("Accessory child spawned WITHOUT its meta pre-seed after the last retry", {
|
|
14582
14767
|
tags: {
|
|
14583
|
-
|
|
14584
|
-
|
|
14768
|
+
deviceId: id,
|
|
14769
|
+
parentDeviceId: parent.id
|
|
14585
14770
|
},
|
|
14586
|
-
meta: {
|
|
14771
|
+
meta: {
|
|
14772
|
+
step: "applyInitialMeta",
|
|
14773
|
+
stableId: childStableId,
|
|
14774
|
+
error: err instanceof Error ? err.message : String(err)
|
|
14775
|
+
}
|
|
14587
14776
|
});
|
|
14588
14777
|
});
|
|
14589
14778
|
if (isFirstSpawn && Object.keys(spec.config).length > 0) await callDeviceManager(api, "persistConfig", {
|
|
@@ -14591,7 +14780,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
14591
14780
|
data: spec.config
|
|
14592
14781
|
}).catch(() => {});
|
|
14593
14782
|
const [initialRuntimeState, loadedConfig, deviceMeta] = await Promise.all([
|
|
14594
|
-
loadRuntimeStateFor(id, childStableId, "accessory-child"),
|
|
14783
|
+
loadRuntimeStateFor(id, childStableId, "accessory-child").catch((err) => Promise.reject(new AccessorySpawnStepError("loadRuntimeState", id, err))),
|
|
14595
14784
|
callDeviceManager(api, "loadConfig", { deviceId: id }).catch(() => empty),
|
|
14596
14785
|
callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)
|
|
14597
14786
|
]);
|
|
@@ -14630,6 +14819,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
14630
14819
|
*/
|
|
14631
14820
|
const teardownLocal = async (deviceId, runLifecycle) => {
|
|
14632
14821
|
const device = registry.getById(deviceId);
|
|
14822
|
+
accessorySpawnRetry.cancelParent(deviceId);
|
|
14633
14823
|
cancelProbeRetry(deviceId);
|
|
14634
14824
|
if (!device) return;
|
|
14635
14825
|
const children = registry.getChildren(deviceId);
|
|
@@ -14874,6 +15064,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
14874
15064
|
if (!opts.capabilityRegistry) workerNativeCaps.get("device-ops")?.delete(device.id);
|
|
14875
15065
|
throw err;
|
|
14876
15066
|
}
|
|
15067
|
+
accessorySpawnRetry.resetParent(device.id);
|
|
14877
15068
|
const lifecycleHost = device;
|
|
14878
15069
|
const shrinkGate = new AccessoryShrinkGate();
|
|
14879
15070
|
const runReconcileNow = async () => {
|
|
@@ -14911,14 +15102,14 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
14911
15102
|
try {
|
|
14912
15103
|
await spawnAccessoryChild(device, spec);
|
|
14913
15104
|
} catch (err) {
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
15105
|
+
accessorySpawnRetry.schedule({
|
|
15106
|
+
deviceId: err instanceof AccessorySpawnStepError ? err.deviceId : null,
|
|
15107
|
+
stableId: `${device.stableId}-${spec.stableIdSuffix}`,
|
|
15108
|
+
parentDeviceId: device.id,
|
|
15109
|
+
error: err,
|
|
15110
|
+
isParentRegistered: () => registry.getById(device.id) !== null,
|
|
15111
|
+
attempt: async (attemptOptions) => {
|
|
15112
|
+
await spawnAccessoryChild(device, spec, attemptOptions);
|
|
14922
15113
|
}
|
|
14923
15114
|
});
|
|
14924
15115
|
}
|
|
@@ -26910,6 +27101,7 @@ exports.regenerateCertificate = require_hub_mdns_ciao.regenerateCertificate;
|
|
|
26910
27101
|
exports.registerEventBusService = registerEventBusService;
|
|
26911
27102
|
exports.registerHttpsListener = require_hub_mdns_ciao.registerHttpsListener;
|
|
26912
27103
|
exports.registerLanHttpHandler = require_hub_mdns_ciao.registerLanHttpHandler;
|
|
27104
|
+
exports.rehydrateSwitchesOnHubConnect = rehydrateSwitchesOnHubConnect;
|
|
26913
27105
|
exports.reissueTlsLeaf = require_hub_mdns_ciao.reissueTlsLeaf;
|
|
26914
27106
|
exports.reloadHttpsListener = require_hub_mdns_ciao.reloadHttpsListener;
|
|
26915
27107
|
exports.renewMeshCertificate = require_builtins_system_config_system_config_addon.renewMeshCertificate;
|