@camstack/server 1.2.743 → 1.2.744

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 (94) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/agent/main.js +4 -2
  3. package/package.json +4 -6
  4. package/system/dist/addon-runner.js +145 -76
  5. package/system/dist/addon-runner.mjs +145 -76
  6. package/system/dist/{agent-https-CTLbLv1Z.js → agent-https-BcxBTl03.js} +1 -1
  7. package/system/dist/{agent-https-BXFwvxco.mjs → agent-https-zLZqE2uf.mjs} +1 -1
  8. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  10. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  12. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  13. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  14. package/system/dist/builtins/autotrack/index.js +1 -1
  15. package/system/dist/builtins/autotrack/index.mjs +1 -1
  16. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  17. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  18. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  19. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  20. package/system/dist/builtins/camera-grid/index.js +1 -1
  21. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  22. package/system/dist/builtins/composer/composer.addon.js +3 -3
  23. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  24. package/system/dist/builtins/console-logging/index.js +1 -1
  25. package/system/dist/builtins/console-logging/index.mjs +1 -1
  26. package/system/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  27. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  28. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  29. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  30. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  31. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  32. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  33. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  34. package/system/dist/builtins/keychain/index.js +3 -3
  35. package/system/dist/builtins/keychain/index.mjs +3 -3
  36. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  37. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  38. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  39. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  40. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  41. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  42. package/system/dist/builtins/loki-logging/index.js +1 -1
  43. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  44. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  45. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  46. package/system/dist/builtins/platform-probe/index.js +1 -1
  47. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  48. package/system/dist/builtins/record-entries/index.js +1 -1
  49. package/system/dist/builtins/record-entries/index.mjs +1 -1
  50. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  51. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  52. package/system/dist/builtins/snapshot/index.js +1 -1
  53. package/system/dist/builtins/snapshot/index.mjs +1 -1
  54. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  55. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  56. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  57. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  58. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
  59. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
  60. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  61. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  62. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  63. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  64. package/system/dist/builtins/winston-logging/index.js +1 -1
  65. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  66. package/system/dist/{composition-sources-T2lA4x2c.js → composition-sources-B8hXkZdd.js} +1 -1
  67. package/system/dist/{composition-sources-BsdQWUId.mjs → composition-sources-Bc_D8LR5.mjs} +1 -1
  68. package/system/dist/{constants-3SpeBQ9e.mjs → constants-CBAenEIc.mjs} +1 -1
  69. package/system/dist/{constants-BrhaiRkm.js → constants-oztBWIpa.js} +1 -1
  70. package/system/dist/{device-ca-BCeNjQxi.js → device-ca-C5TjvqyB.js} +1 -1
  71. package/system/dist/{device-ca-Dp9VZmay.mjs → device-ca-DgEn-SoG.mjs} +1 -1
  72. package/system/dist/{dist-hoy7lFFU.js → dist-B0zmp3zn.js} +18 -2
  73. package/system/dist/{dist-CYQNDx7D.mjs → dist-Cdz0_zxq.mjs} +18 -2
  74. package/system/dist/file-host-worker.js +1 -1
  75. package/system/dist/file-host-worker.mjs +1 -1
  76. package/system/dist/{hub-mdns-ciao-Btg3hLbv.js → hub-mdns-ciao-DM_nVIFe.js} +2 -2
  77. package/system/dist/{hub-mdns-ciao-Bmgiu2PS.mjs → hub-mdns-ciao-nWSv_w8h.mjs} +2 -2
  78. package/system/dist/index.js +73 -11
  79. package/system/dist/index.mjs +73 -12
  80. package/system/dist/kernel/moleculer/runner-init-loop.d.ts +25 -0
  81. package/system/dist/kernel/transport/acting-addon.d.ts +17 -0
  82. package/system/dist/kernel/transport/child-cap-protocol.d.ts +12 -0
  83. package/system/dist/kernel/transport/index.d.ts +1 -0
  84. package/system/dist/kernel/transport/local-child-client.d.ts +2 -2
  85. package/system/dist/kernel/transport/local-child-registry.d.ts +7 -0
  86. package/system/dist/kernel/transport/runner-of-addon.d.ts +11 -0
  87. package/system/dist/migrations/hub/2026-11-02-records-owner-group-to-addon.d.ts +11 -0
  88. package/system/dist/{restore-archive-NPXKTdgW.js → restore-archive-CS-DPZ3U.js} +1 -1
  89. package/system/dist/{restore-archive-Da6R2OpB.mjs → restore-archive-gAzBMq-y.mjs} +1 -1
  90. package/system/dist/{retention-YUgpamYA.js → retention-CJ47t_51.js} +1 -1
  91. package/system/dist/{retention-BnRv1V1H.mjs → retention-Cfw9Jeyz.mjs} +1 -1
  92. package/system/dist/{wal-maintenance-B0jahuQG.js → wal-maintenance-BqyLi3Ko.js} +0 -0
  93. package/system/dist/{wal-maintenance-pDyTGZ-n.mjs → wal-maintenance-D8QmKPOV.mjs} +0 -0
  94. package/system/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.744] - 2026-11-02
11
+
12
+ ### Changed
13
+
14
+ - An agent now verifies which addon a shared runner acts for, so a grouped addon's records and secrets are owned by the addon on agents too
15
+
10
16
  ## [1.2.743] - 2026-11-02
11
17
 
12
18
  ### Changed
@@ -88,6 +88,7 @@ const RECONNECT_DEADLINE_MS = 90_000;
88
88
  /** How often the agent re-evaluates whether to ask its hub "am I still a member?" (D857). */
89
89
  const MEMBERSHIP_TICK_MS = 15_000;
90
90
  const agentLogManager = new system_2.LogManager(5000);
91
+ const agentRunnerOfAddon = new system_1.RunnerOfAddon();
91
92
  /**
92
93
  * Caps whose `nodeId` arg is provider DATA (`nodeIdMode: 'data'` —
93
94
  * `addon-settings`, `addons`, `nodes`, `pipeline-orchestrator`), never a
@@ -707,6 +708,7 @@ async function startAgent(configPath) {
707
708
  // it with "no provider registered" unless it knew the agent hosts the
708
709
  // cap). A pin to ANOTHER node still bypasses the sibling → onUnownedCall.
709
710
  ownNodeId: agentNodeId,
711
+ resolveChildIdForAddon: agentRunnerOfAddon.resolve,
710
712
  onUnownedCall,
711
713
  // NO `capUsageObserver` here, deliberately. `getCapUsageRegistry()` is a
712
714
  // per-process singleton and the reader (`nodes.getCapUsageGraph`) runs on
@@ -1348,7 +1350,7 @@ async function loadClusterCapableAddons(broker, config, capabilityRegistry, load
1348
1350
  if (placement === 'hub-only')
1349
1351
  continue;
1350
1352
  allGroupCandidates.push({
1351
- groupId: (0, types_2.resolveRunnerId)(registered.declaration, registered.declaration.id),
1353
+ groupId: agentRunnerOfAddon.record(registered.declaration.id, (0, types_2.resolveRunnerId)(registered.declaration, registered.declaration.id)),
1352
1354
  addonId: registered.declaration.id,
1353
1355
  addonDir: dir,
1354
1356
  version: registered.declaration.version ?? '0.0.0',
@@ -1438,7 +1440,7 @@ async function loadDeployedAddons(broker, addonsDir, dataDir, loadedAddons, stor
1438
1440
  continue;
1439
1441
  if ((0, agent_group_runner_js_1.isGroupRunnerAddon)(decl)) {
1440
1442
  groupCandidates.push({
1441
- groupId: (0, types_2.resolveRunnerId)(decl, addonId),
1443
+ groupId: agentRunnerOfAddon.record(addonId, (0, types_2.resolveRunnerId)(decl, addonId)),
1442
1444
  addonId,
1443
1445
  addonDir: dir,
1444
1446
  version: decl.version ?? '0.0.0',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.743",
3
+ "version": "1.2.744",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,9 +66,7 @@
66
66
  ],
67
67
  "requires": {
68
68
  "addons": {
69
- "@camstack/addon-admin-ui": ">=1.2.561",
70
- "@camstack/addon-pipeline-orchestrator": ">=1.2.653",
71
- "@camstack/addon-post-analysis": ">=1.2.665"
69
+ "@camstack/addon-admin-ui": ">=1.2.562"
72
70
  },
73
71
  "wrapper": {
74
72
  "desktop": ">=0.0.1",
@@ -77,7 +75,7 @@
77
75
  }
78
76
  },
79
77
  "dependencies": {
80
- "@camstack/addon-admin-ui": "1.2.561",
78
+ "@camstack/addon-admin-ui": "1.2.562",
81
79
  "@camstack/addon-agent-ui": "1.2.317",
82
80
  "@camstack/addon-auth": "1.2.175",
83
81
  "@camstack/addon-benchmark": "1.2.311",
@@ -88,7 +86,7 @@
88
86
  "@camstack/addon-post-analysis": "1.2.665",
89
87
  "@camstack/develop": "0.1.44",
90
88
  "@camstack/sdk": "1.2.155",
91
- "@camstack/types": "1.2.481",
89
+ "@camstack/types": "1.2.482",
92
90
  "@camstack/ui-library": "1.2.375",
93
91
  "@fastify/compress": "^9.0.0",
94
92
  "@fastify/cookie": "^11.0.2",
@@ -20,11 +20,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
20
  enumerable: true
21
21
  }) : target, mod));
22
22
  //#endregion
23
+ let _camstack_types_addon = require("@camstack/types/addon");
23
24
  let node_fs = require("node:fs");
24
25
  node_fs = __toESM(node_fs);
25
26
  let node_path = require("node:path");
26
27
  node_path = __toESM(node_path);
27
- let _camstack_types_addon = require("@camstack/types/addon");
28
28
  let node_child_process = require("node:child_process");
29
29
  let node_util = require("node:util");
30
30
  let node_os = require("node:os");
@@ -88,6 +88,51 @@ function findAddonRefusal(err) {
88
88
  return null;
89
89
  }
90
90
  //#endregion
91
+ //#region src/kernel/moleculer/runner-init-loop.ts
92
+ /**
93
+ * The per-addon init orchestration of a runner, apart from `addon-runner.ts` (whose `main()` runs
94
+ * at import time and cannot be unit-tested).
95
+ *
96
+ * An addon blocked by its OWN migrations is not a crash and not the runner's problem: it is
97
+ * reported and skipped, and its co-located siblings keep initialising (a runner that exited here
98
+ * took every member of its group down with it, five times, into the D6 breaker). Any other init
99
+ * failure stays fatal, through the injected `fatal` (which exits). Only a runner where NOTHING
100
+ * loaded because members were blocked leaves, with the D877 refusal code: parked `refused`, with
101
+ * the reason, no breaker and no respawn.
102
+ */
103
+ async function runAddonInits(entries, ports) {
104
+ let initialised = 0;
105
+ const blocked = [];
106
+ for (const entry of entries) try {
107
+ await ports.init(entry);
108
+ initialised += 1;
109
+ } catch (err) {
110
+ const migrationIds = (0, _camstack_types_addon.findMigrationsBlocked)(err);
111
+ if (migrationIds === null) return ports.fatal(entry, err);
112
+ blocked.push({
113
+ addonId: entry.spec.addonId,
114
+ migrationIds
115
+ });
116
+ ports.blocked(entry.spec.addonId, migrationIds);
117
+ }
118
+ return {
119
+ initialised,
120
+ blocked
121
+ };
122
+ }
123
+ /** The refusal a runner leaves with when every member was blocked; null when none was. */
124
+ function allBlockedRefusal(blocked) {
125
+ const first = blocked[0];
126
+ if (first === void 0) return null;
127
+ const detail = blocked.map((b) => `${b.addonId} (${b.migrationIds.join(", ")})`).join("; ");
128
+ return {
129
+ addonId: first.addonId,
130
+ code: "migrations-blocked",
131
+ reason: `no addon of this runner could start: its migrations did not apply: ${detail}.`,
132
+ remedy: "Fix or retry the migrations (migrations.retry), then restart the addon."
133
+ };
134
+ }
135
+ //#endregion
91
136
  //#region src/kernel/moleculer/runner-refusal.ts
92
137
  var REFUSED_PREFIX = "REFUSED:";
93
138
  /** The stdout line for a refusal. Always one line: JSON has no raw newline. */
@@ -5180,7 +5225,8 @@ var LocalChildClient = class {
5180
5225
  const routing = {
5181
5226
  ...input.deviceId !== void 0 ? { deviceId: input.deviceId } : {},
5182
5227
  ...input.nodeId !== void 0 ? { nodeId: input.nodeId } : {},
5183
- ...input.native === true ? { native: true } : {}
5228
+ ...input.native === true ? { native: true } : {},
5229
+ ...input.actingAddonId !== void 0 ? { actingAddonId: input.actingAddonId } : {}
5184
5230
  };
5185
5231
  if (this.parentRawForward && input.args !== void 0) {
5186
5232
  const hints = liftRoutingHints(input.args);
@@ -10803,7 +10849,10 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
10803
10849
  const links = [localProviderLink(workerResolver, observerOpts)];
10804
10850
  if (runtime.mode === "uds") {
10805
10851
  const udsClient = runtime.client;
10806
- links.push(ipcParentLink(() => (input) => udsClient.callOut(input)));
10852
+ links.push(ipcParentLink(() => (input) => udsClient.callOut({
10853
+ ...input,
10854
+ actingAddonId: addonId
10855
+ })));
10807
10856
  } else {
10808
10857
  const parentCallOutGetter = options?.getParentCallOut;
10809
10858
  if (parentCallOutGetter !== void 0) links.push(ipcParentLink(parentCallOutGetter));
@@ -11823,84 +11872,104 @@ async function main() {
11823
11872
  });
11824
11873
  const loaded = [];
11825
11874
  const deviceRestorePromises = [];
11826
- for (const { spec, declaration, AddonClass } of loadedModules) try {
11827
- const addon = new AddonClass();
11828
- const context = await createUdsAddonContext(udsChildClient, nodeId, declaration, dataDir, {
11829
- ...storageProvider ? { storageProvider } : {},
11830
- dataPlaneSink: { set: (addonId, endpoints) => {
11831
- addonDataPlanes.set(addonId, endpoints);
11832
- } }
11833
- });
11834
- if (context.secrets !== void 0) addonSecrets.set(spec.addonId, context.secrets);
11835
- try {
11836
- const pkgRaw = JSON.parse(node_fs.readFileSync(node_path.join(spec.addonDir, "package.json"), "utf-8"));
11837
- await installManifestNativeDeps(spec.addonDir, pkgRaw, context.logger);
11838
- } catch (nativeErr) {
11839
- console.error(`[addon-runner] native deps install failed for "${spec.addonId}": ${(0, _camstack_types_addon.errMsg)(nativeErr)}`);
11840
- process.exit(1);
11841
- }
11842
- await installManifestPythonDeps(declaration, spec.addonDir, context.deps, context.logger);
11843
- await installManifestSystemDeps(declaration, context.logger);
11844
- const registeredProviders = /* @__PURE__ */ new Map();
11845
- const initWatchdog = startInitWatchdog({
11846
- addonId: spec.addonId,
11847
- declaredCapabilities: declaredCapabilityNames(declaration),
11848
- warn: (message, meta) => {
11849
- runnerLog.warn(message, { meta });
11875
+ const initOne = async ({ spec, declaration, AddonClass }) => {
11876
+ {
11877
+ const addon = new AddonClass();
11878
+ const context = await createUdsAddonContext(udsChildClient, nodeId, declaration, dataDir, {
11879
+ ...storageProvider ? { storageProvider } : {},
11880
+ dataPlaneSink: { set: (addonId, endpoints) => {
11881
+ addonDataPlanes.set(addonId, endpoints);
11882
+ } }
11883
+ });
11884
+ if (context.secrets !== void 0) addonSecrets.set(spec.addonId, context.secrets);
11885
+ try {
11886
+ const pkgRaw = JSON.parse(node_fs.readFileSync(node_path.join(spec.addonDir, "package.json"), "utf-8"));
11887
+ await installManifestNativeDeps(spec.addonDir, pkgRaw, context.logger);
11888
+ } catch (nativeErr) {
11889
+ console.error(`[addon-runner] native deps install failed for "${spec.addonId}": ${(0, _camstack_types_addon.errMsg)(nativeErr)}`);
11890
+ process.exit(1);
11850
11891
  }
11851
- });
11852
- let initResult;
11853
- try {
11854
- initResult = (0, _camstack_types_addon.normalizeAddonInitResult)(await addon.initialize(context));
11855
- } finally {
11856
- initWatchdog.clear();
11857
- }
11858
- for (const reg of initResult?.providers ?? []) {
11859
- const capName = reg.capability.name;
11860
- registeredProviders.set(capName, reg.provider);
11861
- context.registerProvider(capName, reg.provider);
11862
- const prov = reg.provider;
11863
- if (prov !== null && typeof prov === "object" && !Array.isArray(prov)) {
11864
- const byAddon = allSingletonProviders.get(capName) ?? /* @__PURE__ */ new Map();
11865
- byAddon.set(spec.addonId, prov);
11866
- allSingletonProviders.set(capName, byAddon);
11867
- if (capName === "addon-routes") addonRouteProviders.set(spec.addonId, prov);
11892
+ await installManifestPythonDeps(declaration, spec.addonDir, context.deps, context.logger);
11893
+ await installManifestSystemDeps(declaration, context.logger);
11894
+ const registeredProviders = /* @__PURE__ */ new Map();
11895
+ const initWatchdog = startInitWatchdog({
11896
+ addonId: spec.addonId,
11897
+ declaredCapabilities: declaredCapabilityNames(declaration),
11898
+ warn: (message, meta) => {
11899
+ runnerLog.warn(message, { meta });
11900
+ }
11901
+ });
11902
+ let initResult;
11903
+ try {
11904
+ initResult = (0, _camstack_types_addon.normalizeAddonInitResult)(await addon.initialize(context));
11905
+ } finally {
11906
+ initWatchdog.clear();
11868
11907
  }
11869
- }
11870
- if (initResult?.customActions && initResult.actionHandlers) {
11871
- const handlers = initResult.actionHandlers;
11872
- customActionRegistry.registerAddon(spec.addonId, initResult.customActions, (action, input, caller) => {
11873
- const fn = handlers[action];
11874
- if (!fn) throw new Error(`addon '${spec.addonId}' has no handler for custom action '${action}'`);
11875
- return fn(input, caller);
11908
+ for (const reg of initResult?.providers ?? []) {
11909
+ const capName = reg.capability.name;
11910
+ registeredProviders.set(capName, reg.provider);
11911
+ context.registerProvider(capName, reg.provider);
11912
+ const prov = reg.provider;
11913
+ if (prov !== null && typeof prov === "object" && !Array.isArray(prov)) {
11914
+ const byAddon = allSingletonProviders.get(capName) ?? /* @__PURE__ */ new Map();
11915
+ byAddon.set(spec.addonId, prov);
11916
+ allSingletonProviders.set(capName, byAddon);
11917
+ if (capName === "addon-routes") addonRouteProviders.set(spec.addonId, prov);
11918
+ }
11919
+ }
11920
+ if (initResult?.customActions && initResult.actionHandlers) {
11921
+ const handlers = initResult.actionHandlers;
11922
+ customActionRegistry.registerAddon(spec.addonId, initResult.customActions, (action, input, caller) => {
11923
+ const fn = handlers[action];
11924
+ if (!fn) throw new Error(`addon '${spec.addonId}' has no handler for custom action '${action}'`);
11925
+ return fn(input, caller);
11926
+ });
11927
+ }
11928
+ validateProviderRegistrations(spec.addonId, declaration, registeredProviders, context.logger);
11929
+ const capNames = [...registeredProviders.keys()];
11930
+ context.logger.info(`"${spec.addonId}" caps: ${capNames.length > 0 ? capNames.join(", ") : "(none)"}`);
11931
+ runnerManifest.push({
11932
+ addonId: spec.addonId,
11933
+ capabilities: capNames
11934
+ });
11935
+ if (typeof addon.restoreDevices === "function") deviceRestorePromises.push(runWorkerDeviceRestoreWithRetry(addon, context, spec.addonId, nodeId));
11936
+ addon.postBrokerStart();
11937
+ loadedAddonInstances.set(spec.addonId, addon);
11938
+ loaded.push({
11939
+ addonId: spec.addonId,
11940
+ declaration,
11941
+ addon,
11942
+ initResult: initResult ?? null
11876
11943
  });
11877
11944
  }
11878
- validateProviderRegistrations(spec.addonId, declaration, registeredProviders, context.logger);
11879
- const capNames = [...registeredProviders.keys()];
11880
- context.logger.info(`"${spec.addonId}" caps: ${capNames.length > 0 ? capNames.join(", ") : "(none)"}`);
11881
- runnerManifest.push({
11882
- addonId: spec.addonId,
11883
- capabilities: capNames
11884
- });
11885
- if (typeof addon.restoreDevices === "function") deviceRestorePromises.push(runWorkerDeviceRestoreWithRetry(addon, context, spec.addonId, nodeId));
11886
- addon.postBrokerStart();
11887
- loadedAddonInstances.set(spec.addonId, addon);
11888
- loaded.push({
11889
- addonId: spec.addonId,
11890
- declaration,
11891
- addon,
11892
- initResult: initResult ?? null
11893
- });
11894
- } catch (err) {
11895
- console.error(`[addon-runner] Init failed for "${spec.addonId}": ${(0, _camstack_types_addon.errMsg)(err)}`);
11896
- const refusal = findAddonRefusal(err);
11897
- if (refusal !== null) {
11898
- try {
11899
- node_fs.writeSync(1, formatRunnerRefusalLine(nodeId, refusalReportOf(spec.addonId, refusal)));
11900
- } catch {}
11901
- process.exit(78);
11945
+ };
11946
+ const initOutcome = await runAddonInits(loadedModules, {
11947
+ init: initOne,
11948
+ blocked: (addonId, migrationIds) => {
11949
+ runnerLog.error(`"${addonId}" is blocked by its migrations and was not started: ${migrationIds.join(", ")}`, {
11950
+ tags: { addonId },
11951
+ meta: { migrationIds: [...migrationIds] }
11952
+ });
11953
+ },
11954
+ fatal: (entry, err) => {
11955
+ console.error(`[addon-runner] Init failed for "${entry.spec.addonId}": ${(0, _camstack_types_addon.errMsg)(err)}`);
11956
+ const refusal = findAddonRefusal(err);
11957
+ if (refusal !== null) {
11958
+ try {
11959
+ node_fs.writeSync(1, formatRunnerRefusalLine(nodeId, refusalReportOf(entry.spec.addonId, refusal)));
11960
+ } catch {}
11961
+ process.exit(78);
11962
+ }
11963
+ process.exit(1);
11902
11964
  }
11903
- process.exit(1);
11965
+ });
11966
+ const allBlocked = initOutcome.initialised === 0 ? allBlockedRefusal(initOutcome.blocked) : null;
11967
+ if (allBlocked !== null) {
11968
+ console.error(`[addon-runner] ${allBlocked.reason}`);
11969
+ try {
11970
+ node_fs.writeSync(1, formatRunnerRefusalLine(nodeId, allBlocked));
11971
+ } catch {}
11972
+ process.exit(78);
11904
11973
  }
11905
11974
  if (deviceRestorePromises.length > 0 && !shuttingDown) await Promise.allSettled(deviceRestorePromises);
11906
11975
  refreshChildCaps("post-init", customActionRegistry.describeAll(specs.map((spec) => spec.addonId)));
@@ -1,9 +1,9 @@
1
1
  import { register } from "node:module";
2
+ import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry, ReadinessTimeoutError, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, createDebugEmitter, createDeviceProxy, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, describeCustomActions, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, findMigrationsBlocked, isCollectionArrayMethodName, isProviderOptionalMethodName, maskUrlCredentials, nodeIdOfScopedKey, normalizeAddonInitResult, readErrorI18n, readNodePin, resolveDeviceSettings, resolveSecretViewsIn, scopeKey, scrubKnownSecrets, withCapInputDefaults } from "@camstack/types/addon";
2
3
  import * as fs$1 from "node:fs";
3
4
  import fs, { createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
4
5
  import * as path from "node:path";
5
6
  import { basename, dirname, isAbsolute, join } from "node:path";
6
- import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry, ReadinessTimeoutError, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, createDebugEmitter, createDeviceProxy, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, describeCustomActions, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, isCollectionArrayMethodName, isProviderOptionalMethodName, maskUrlCredentials, nodeIdOfScopedKey, normalizeAddonInitResult, readErrorI18n, readNodePin, resolveDeviceSettings, resolveSecretViewsIn, scopeKey, scrubKnownSecrets, withCapInputDefaults } from "@camstack/types/addon";
7
7
  import { execFile } from "node:child_process";
8
8
  import { promisify } from "node:util";
9
9
  import * as os from "node:os";
@@ -64,6 +64,51 @@ function findAddonRefusal(err) {
64
64
  return null;
65
65
  }
66
66
  //#endregion
67
+ //#region src/kernel/moleculer/runner-init-loop.ts
68
+ /**
69
+ * The per-addon init orchestration of a runner, apart from `addon-runner.ts` (whose `main()` runs
70
+ * at import time and cannot be unit-tested).
71
+ *
72
+ * An addon blocked by its OWN migrations is not a crash and not the runner's problem: it is
73
+ * reported and skipped, and its co-located siblings keep initialising (a runner that exited here
74
+ * took every member of its group down with it, five times, into the D6 breaker). Any other init
75
+ * failure stays fatal, through the injected `fatal` (which exits). Only a runner where NOTHING
76
+ * loaded because members were blocked leaves, with the D877 refusal code: parked `refused`, with
77
+ * the reason, no breaker and no respawn.
78
+ */
79
+ async function runAddonInits(entries, ports) {
80
+ let initialised = 0;
81
+ const blocked = [];
82
+ for (const entry of entries) try {
83
+ await ports.init(entry);
84
+ initialised += 1;
85
+ } catch (err) {
86
+ const migrationIds = findMigrationsBlocked(err);
87
+ if (migrationIds === null) return ports.fatal(entry, err);
88
+ blocked.push({
89
+ addonId: entry.spec.addonId,
90
+ migrationIds
91
+ });
92
+ ports.blocked(entry.spec.addonId, migrationIds);
93
+ }
94
+ return {
95
+ initialised,
96
+ blocked
97
+ };
98
+ }
99
+ /** The refusal a runner leaves with when every member was blocked; null when none was. */
100
+ function allBlockedRefusal(blocked) {
101
+ const first = blocked[0];
102
+ if (first === void 0) return null;
103
+ const detail = blocked.map((b) => `${b.addonId} (${b.migrationIds.join(", ")})`).join("; ");
104
+ return {
105
+ addonId: first.addonId,
106
+ code: "migrations-blocked",
107
+ reason: `no addon of this runner could start: its migrations did not apply: ${detail}.`,
108
+ remedy: "Fix or retry the migrations (migrations.retry), then restart the addon."
109
+ };
110
+ }
111
+ //#endregion
67
112
  //#region src/kernel/moleculer/runner-refusal.ts
68
113
  var REFUSED_PREFIX = "REFUSED:";
69
114
  /** The stdout line for a refusal. Always one line: JSON has no raw newline. */
@@ -5125,7 +5170,8 @@ var LocalChildClient = class {
5125
5170
  const routing = {
5126
5171
  ...input.deviceId !== void 0 ? { deviceId: input.deviceId } : {},
5127
5172
  ...input.nodeId !== void 0 ? { nodeId: input.nodeId } : {},
5128
- ...input.native === true ? { native: true } : {}
5173
+ ...input.native === true ? { native: true } : {},
5174
+ ...input.actingAddonId !== void 0 ? { actingAddonId: input.actingAddonId } : {}
5129
5175
  };
5130
5176
  if (this.parentRawForward && input.args !== void 0) {
5131
5177
  const hints = liftRoutingHints(input.args);
@@ -10748,7 +10794,10 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
10748
10794
  const links = [localProviderLink(workerResolver, observerOpts)];
10749
10795
  if (runtime.mode === "uds") {
10750
10796
  const udsClient = runtime.client;
10751
- links.push(ipcParentLink(() => (input) => udsClient.callOut(input)));
10797
+ links.push(ipcParentLink(() => (input) => udsClient.callOut({
10798
+ ...input,
10799
+ actingAddonId: addonId
10800
+ })));
10752
10801
  } else {
10753
10802
  const parentCallOutGetter = options?.getParentCallOut;
10754
10803
  if (parentCallOutGetter !== void 0) links.push(ipcParentLink(parentCallOutGetter));
@@ -11768,84 +11817,104 @@ async function main() {
11768
11817
  });
11769
11818
  const loaded = [];
11770
11819
  const deviceRestorePromises = [];
11771
- for (const { spec, declaration, AddonClass } of loadedModules) try {
11772
- const addon = new AddonClass();
11773
- const context = await createUdsAddonContext(udsChildClient, nodeId, declaration, dataDir, {
11774
- ...storageProvider ? { storageProvider } : {},
11775
- dataPlaneSink: { set: (addonId, endpoints) => {
11776
- addonDataPlanes.set(addonId, endpoints);
11777
- } }
11778
- });
11779
- if (context.secrets !== void 0) addonSecrets.set(spec.addonId, context.secrets);
11780
- try {
11781
- const pkgRaw = JSON.parse(fs$1.readFileSync(path.join(spec.addonDir, "package.json"), "utf-8"));
11782
- await installManifestNativeDeps(spec.addonDir, pkgRaw, context.logger);
11783
- } catch (nativeErr) {
11784
- console.error(`[addon-runner] native deps install failed for "${spec.addonId}": ${errMsg(nativeErr)}`);
11785
- process.exit(1);
11786
- }
11787
- await installManifestPythonDeps(declaration, spec.addonDir, context.deps, context.logger);
11788
- await installManifestSystemDeps(declaration, context.logger);
11789
- const registeredProviders = /* @__PURE__ */ new Map();
11790
- const initWatchdog = startInitWatchdog({
11791
- addonId: spec.addonId,
11792
- declaredCapabilities: declaredCapabilityNames(declaration),
11793
- warn: (message, meta) => {
11794
- runnerLog.warn(message, { meta });
11820
+ const initOne = async ({ spec, declaration, AddonClass }) => {
11821
+ {
11822
+ const addon = new AddonClass();
11823
+ const context = await createUdsAddonContext(udsChildClient, nodeId, declaration, dataDir, {
11824
+ ...storageProvider ? { storageProvider } : {},
11825
+ dataPlaneSink: { set: (addonId, endpoints) => {
11826
+ addonDataPlanes.set(addonId, endpoints);
11827
+ } }
11828
+ });
11829
+ if (context.secrets !== void 0) addonSecrets.set(spec.addonId, context.secrets);
11830
+ try {
11831
+ const pkgRaw = JSON.parse(fs$1.readFileSync(path.join(spec.addonDir, "package.json"), "utf-8"));
11832
+ await installManifestNativeDeps(spec.addonDir, pkgRaw, context.logger);
11833
+ } catch (nativeErr) {
11834
+ console.error(`[addon-runner] native deps install failed for "${spec.addonId}": ${errMsg(nativeErr)}`);
11835
+ process.exit(1);
11795
11836
  }
11796
- });
11797
- let initResult;
11798
- try {
11799
- initResult = normalizeAddonInitResult(await addon.initialize(context));
11800
- } finally {
11801
- initWatchdog.clear();
11802
- }
11803
- for (const reg of initResult?.providers ?? []) {
11804
- const capName = reg.capability.name;
11805
- registeredProviders.set(capName, reg.provider);
11806
- context.registerProvider(capName, reg.provider);
11807
- const prov = reg.provider;
11808
- if (prov !== null && typeof prov === "object" && !Array.isArray(prov)) {
11809
- const byAddon = allSingletonProviders.get(capName) ?? /* @__PURE__ */ new Map();
11810
- byAddon.set(spec.addonId, prov);
11811
- allSingletonProviders.set(capName, byAddon);
11812
- if (capName === "addon-routes") addonRouteProviders.set(spec.addonId, prov);
11837
+ await installManifestPythonDeps(declaration, spec.addonDir, context.deps, context.logger);
11838
+ await installManifestSystemDeps(declaration, context.logger);
11839
+ const registeredProviders = /* @__PURE__ */ new Map();
11840
+ const initWatchdog = startInitWatchdog({
11841
+ addonId: spec.addonId,
11842
+ declaredCapabilities: declaredCapabilityNames(declaration),
11843
+ warn: (message, meta) => {
11844
+ runnerLog.warn(message, { meta });
11845
+ }
11846
+ });
11847
+ let initResult;
11848
+ try {
11849
+ initResult = normalizeAddonInitResult(await addon.initialize(context));
11850
+ } finally {
11851
+ initWatchdog.clear();
11813
11852
  }
11814
- }
11815
- if (initResult?.customActions && initResult.actionHandlers) {
11816
- const handlers = initResult.actionHandlers;
11817
- customActionRegistry.registerAddon(spec.addonId, initResult.customActions, (action, input, caller) => {
11818
- const fn = handlers[action];
11819
- if (!fn) throw new Error(`addon '${spec.addonId}' has no handler for custom action '${action}'`);
11820
- return fn(input, caller);
11853
+ for (const reg of initResult?.providers ?? []) {
11854
+ const capName = reg.capability.name;
11855
+ registeredProviders.set(capName, reg.provider);
11856
+ context.registerProvider(capName, reg.provider);
11857
+ const prov = reg.provider;
11858
+ if (prov !== null && typeof prov === "object" && !Array.isArray(prov)) {
11859
+ const byAddon = allSingletonProviders.get(capName) ?? /* @__PURE__ */ new Map();
11860
+ byAddon.set(spec.addonId, prov);
11861
+ allSingletonProviders.set(capName, byAddon);
11862
+ if (capName === "addon-routes") addonRouteProviders.set(spec.addonId, prov);
11863
+ }
11864
+ }
11865
+ if (initResult?.customActions && initResult.actionHandlers) {
11866
+ const handlers = initResult.actionHandlers;
11867
+ customActionRegistry.registerAddon(spec.addonId, initResult.customActions, (action, input, caller) => {
11868
+ const fn = handlers[action];
11869
+ if (!fn) throw new Error(`addon '${spec.addonId}' has no handler for custom action '${action}'`);
11870
+ return fn(input, caller);
11871
+ });
11872
+ }
11873
+ validateProviderRegistrations(spec.addonId, declaration, registeredProviders, context.logger);
11874
+ const capNames = [...registeredProviders.keys()];
11875
+ context.logger.info(`"${spec.addonId}" caps: ${capNames.length > 0 ? capNames.join(", ") : "(none)"}`);
11876
+ runnerManifest.push({
11877
+ addonId: spec.addonId,
11878
+ capabilities: capNames
11879
+ });
11880
+ if (typeof addon.restoreDevices === "function") deviceRestorePromises.push(runWorkerDeviceRestoreWithRetry(addon, context, spec.addonId, nodeId));
11881
+ addon.postBrokerStart();
11882
+ loadedAddonInstances.set(spec.addonId, addon);
11883
+ loaded.push({
11884
+ addonId: spec.addonId,
11885
+ declaration,
11886
+ addon,
11887
+ initResult: initResult ?? null
11821
11888
  });
11822
11889
  }
11823
- validateProviderRegistrations(spec.addonId, declaration, registeredProviders, context.logger);
11824
- const capNames = [...registeredProviders.keys()];
11825
- context.logger.info(`"${spec.addonId}" caps: ${capNames.length > 0 ? capNames.join(", ") : "(none)"}`);
11826
- runnerManifest.push({
11827
- addonId: spec.addonId,
11828
- capabilities: capNames
11829
- });
11830
- if (typeof addon.restoreDevices === "function") deviceRestorePromises.push(runWorkerDeviceRestoreWithRetry(addon, context, spec.addonId, nodeId));
11831
- addon.postBrokerStart();
11832
- loadedAddonInstances.set(spec.addonId, addon);
11833
- loaded.push({
11834
- addonId: spec.addonId,
11835
- declaration,
11836
- addon,
11837
- initResult: initResult ?? null
11838
- });
11839
- } catch (err) {
11840
- console.error(`[addon-runner] Init failed for "${spec.addonId}": ${errMsg(err)}`);
11841
- const refusal = findAddonRefusal(err);
11842
- if (refusal !== null) {
11843
- try {
11844
- fs$1.writeSync(1, formatRunnerRefusalLine(nodeId, refusalReportOf(spec.addonId, refusal)));
11845
- } catch {}
11846
- process.exit(78);
11890
+ };
11891
+ const initOutcome = await runAddonInits(loadedModules, {
11892
+ init: initOne,
11893
+ blocked: (addonId, migrationIds) => {
11894
+ runnerLog.error(`"${addonId}" is blocked by its migrations and was not started: ${migrationIds.join(", ")}`, {
11895
+ tags: { addonId },
11896
+ meta: { migrationIds: [...migrationIds] }
11897
+ });
11898
+ },
11899
+ fatal: (entry, err) => {
11900
+ console.error(`[addon-runner] Init failed for "${entry.spec.addonId}": ${errMsg(err)}`);
11901
+ const refusal = findAddonRefusal(err);
11902
+ if (refusal !== null) {
11903
+ try {
11904
+ fs$1.writeSync(1, formatRunnerRefusalLine(nodeId, refusalReportOf(entry.spec.addonId, refusal)));
11905
+ } catch {}
11906
+ process.exit(78);
11907
+ }
11908
+ process.exit(1);
11847
11909
  }
11848
- process.exit(1);
11910
+ });
11911
+ const allBlocked = initOutcome.initialised === 0 ? allBlockedRefusal(initOutcome.blocked) : null;
11912
+ if (allBlocked !== null) {
11913
+ console.error(`[addon-runner] ${allBlocked.reason}`);
11914
+ try {
11915
+ fs$1.writeSync(1, formatRunnerRefusalLine(nodeId, allBlocked));
11916
+ } catch {}
11917
+ process.exit(78);
11849
11918
  }
11850
11919
  if (deviceRestorePromises.length > 0 && !shuttingDown) await Promise.allSettled(deviceRestorePromises);
11851
11920
  refreshChildCaps("post-init", customActionRegistry.describeAll(specs.map((spec) => spec.addonId)));
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-hoy7lFFU.js");
2
+ const require_dist = require("./dist-B0zmp3zn.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,4 +1,4 @@
1
- import { us as defineRecordKinds } from "./dist-CYQNDx7D.mjs";
1
+ import { us as defineRecordKinds } from "./dist-Cdz0_zxq.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";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-hoy7lFFU.js");
6
+ const require_dist = require("../../dist-B0zmp3zn.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { an as addonPagesCapability, ho as BaseAddon, nc as EventCategory, tc as errMsg } from "../../dist-CYQNDx7D.mjs";
1
+ import { an as addonPagesCapability, ho as BaseAddon, nc as EventCategory, tc as errMsg } from "../../dist-Cdz0_zxq.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as path$1 from "node:path";