@camstack/system 1.0.2

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 (262) hide show
  1. package/dist/addon/addon-api-factory.d.ts +35 -0
  2. package/dist/addon-routes/addon-route-registry.d.ts +37 -0
  3. package/dist/addon-runner.js +599 -0
  4. package/dist/addon-runner.mjs +597 -0
  5. package/dist/auth/api-key-manager.d.ts +26 -0
  6. package/dist/auth/auth-manager.d.ts +109 -0
  7. package/dist/auth/parse-record.d.ts +18 -0
  8. package/dist/auth/scope-matcher.d.ts +7 -0
  9. package/dist/auth/scoped-token-manager.d.ts +40 -0
  10. package/dist/auth/totp-manager.d.ts +51 -0
  11. package/dist/auth/user-manager.d.ts +34 -0
  12. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.d.ts +53 -0
  13. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +259 -0
  14. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +251 -0
  15. package/dist/builtins/addon-pages-aggregator/dedupe-pages.d.ts +6 -0
  16. package/dist/builtins/addon-pages-aggregator/index.d.ts +1 -0
  17. package/dist/builtins/addon-pages-aggregator/index.js +8 -0
  18. package/dist/builtins/addon-pages-aggregator/index.mjs +2 -0
  19. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.d.ts +47 -0
  20. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +228 -0
  21. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +220 -0
  22. package/dist/builtins/addon-widgets-aggregator/index.d.ts +1 -0
  23. package/dist/builtins/addon-widgets-aggregator/index.js +8 -0
  24. package/dist/builtins/addon-widgets-aggregator/index.mjs +2 -0
  25. package/dist/builtins/alerts/alerts.addon.d.ts +81 -0
  26. package/dist/builtins/alerts/alerts.addon.js +601 -0
  27. package/dist/builtins/alerts/alerts.addon.mjs +595 -0
  28. package/dist/builtins/alerts/index.d.ts +1 -0
  29. package/dist/builtins/alerts/index.js +4 -0
  30. package/dist/builtins/alerts/index.mjs +2 -0
  31. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +147 -0
  32. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2229 -0
  33. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2220 -0
  34. package/dist/builtins/backup-orchestrator/cron-helpers.d.ts +23 -0
  35. package/dist/builtins/backup-orchestrator/destination-policy.d.ts +72 -0
  36. package/dist/builtins/backup-orchestrator/download-helpers.d.ts +12 -0
  37. package/dist/builtins/backup-orchestrator/index.d.ts +2 -0
  38. package/dist/builtins/backup-orchestrator/index.js +8 -0
  39. package/dist/builtins/backup-orchestrator/index.mjs +2 -0
  40. package/dist/builtins/backup-orchestrator/manifest-store.d.ts +77 -0
  41. package/dist/builtins/console-logging/console-destination.d.ts +13 -0
  42. package/dist/builtins/console-logging/console-logging.addon.d.ts +25 -0
  43. package/dist/builtins/console-logging/index.d.ts +3 -0
  44. package/dist/builtins/console-logging/index.js +104 -0
  45. package/dist/builtins/console-logging/index.mjs +95 -0
  46. package/dist/builtins/device-manager/device-config-contribution.d.ts +32 -0
  47. package/dist/builtins/device-manager/device-event-propagator.d.ts +26 -0
  48. package/dist/builtins/device-manager/device-link-overlay.d.ts +23 -0
  49. package/dist/builtins/device-manager/device-link-resolver.d.ts +15 -0
  50. package/dist/builtins/device-manager/device-manager.addon.d.ts +452 -0
  51. package/dist/builtins/device-manager/device-manager.addon.js +3299 -0
  52. package/dist/builtins/device-manager/device-manager.addon.mjs +3292 -0
  53. package/dist/builtins/device-manager/index.d.ts +2 -0
  54. package/dist/builtins/device-manager/index.js +8 -0
  55. package/dist/builtins/device-manager/index.mjs +2 -0
  56. package/dist/builtins/hub-forwarder/hub-forwarder-destination.d.ts +44 -0
  57. package/dist/builtins/hub-forwarder/hub-forwarder.addon.d.ts +15 -0
  58. package/dist/builtins/hub-forwarder/index.d.ts +3 -0
  59. package/dist/builtins/hub-forwarder/index.js +154 -0
  60. package/dist/builtins/hub-forwarder/index.mjs +145 -0
  61. package/dist/builtins/local-auth/auth-schema.d.ts +26 -0
  62. package/dist/builtins/local-auth/index.d.ts +1 -0
  63. package/dist/builtins/local-auth/index.js +4 -0
  64. package/dist/builtins/local-auth/index.mjs +2 -0
  65. package/dist/builtins/local-auth/local-auth.addon.d.ts +18 -0
  66. package/dist/builtins/local-auth/local-auth.addon.js +8094 -0
  67. package/dist/builtins/local-auth/local-auth.addon.mjs +8063 -0
  68. package/dist/builtins/local-auth/oauth-grants.d.ts +45 -0
  69. package/dist/builtins/local-auth/oauth-session-manager.d.ts +50 -0
  70. package/dist/builtins/local-network/index.d.ts +2 -0
  71. package/dist/builtins/local-network/index.js +10 -0
  72. package/dist/builtins/local-network/index.mjs +2 -0
  73. package/dist/builtins/local-network/local-network.addon.d.ts +150 -0
  74. package/dist/builtins/local-network/local-network.addon.js +489 -0
  75. package/dist/builtins/local-network/local-network.addon.mjs +477 -0
  76. package/dist/builtins/native-metrics/index.d.ts +2 -0
  77. package/dist/builtins/native-metrics/native-metrics-provider.d.ts +48 -0
  78. package/dist/builtins/native-metrics/native-metrics.addon.d.ts +73 -0
  79. package/dist/builtins/native-metrics/native-metrics.addon.js +922 -0
  80. package/dist/builtins/native-metrics/native-metrics.addon.mjs +914 -0
  81. package/dist/builtins/platform-probe/hardware-decode-accel-probe.d.ts +37 -0
  82. package/dist/builtins/platform-probe/hardware-encoder-probe.d.ts +13 -0
  83. package/dist/builtins/platform-probe/index.d.ts +22 -0
  84. package/dist/builtins/platform-probe/index.js +834 -0
  85. package/dist/builtins/platform-probe/index.mjs +822 -0
  86. package/dist/builtins/platform-probe/inference-config-resolver.d.ts +29 -0
  87. package/dist/builtins/platform-probe/intel-accelerators.d.ts +11 -0
  88. package/dist/builtins/platform-probe/platform-scorer.d.ts +30 -0
  89. package/dist/builtins/platform-probe/runtime-packages.d.ts +6 -0
  90. package/dist/builtins/remote-access-orchestrator/enabled-providers-reconcile.d.ts +96 -0
  91. package/dist/builtins/remote-access-orchestrator/index.d.ts +1 -0
  92. package/dist/builtins/remote-access-orchestrator/index.js +8 -0
  93. package/dist/builtins/remote-access-orchestrator/index.mjs +2 -0
  94. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.d.ts +40 -0
  95. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +214 -0
  96. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +208 -0
  97. package/dist/builtins/shared/settle-sources.d.ts +22 -0
  98. package/dist/builtins/snapshot/index.d.ts +2 -0
  99. package/dist/builtins/snapshot/index.js +494 -0
  100. package/dist/builtins/snapshot/index.mjs +488 -0
  101. package/dist/builtins/snapshot/snapshot.addon.d.ts +120 -0
  102. package/dist/builtins/sqlite-storage/config-store.d.ts +8 -0
  103. package/dist/builtins/sqlite-storage/device-store.d.ts +23 -0
  104. package/dist/builtins/sqlite-storage/filesystem-browse-provider.d.ts +25 -0
  105. package/dist/builtins/sqlite-storage/filesystem-storage-provider.d.ts +83 -0
  106. package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts +32 -0
  107. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +396 -0
  108. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +388 -0
  109. package/dist/builtins/sqlite-storage/index.d.ts +8 -0
  110. package/dist/builtins/sqlite-storage/index.js +62 -0
  111. package/dist/builtins/sqlite-storage/index.mjs +49 -0
  112. package/dist/builtins/sqlite-storage/integration-registry.d.ts +27 -0
  113. package/dist/builtins/sqlite-storage/path-guard.d.ts +4 -0
  114. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +102 -0
  115. package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +14 -0
  116. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +644 -0
  117. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +636 -0
  118. package/dist/builtins/storage-orchestrator/index.d.ts +6 -0
  119. package/dist/builtins/storage-orchestrator/index.js +10 -0
  120. package/dist/builtins/storage-orchestrator/index.mjs +2 -0
  121. package/dist/builtins/storage-orchestrator/location-store.d.ts +49 -0
  122. package/dist/builtins/storage-orchestrator/provider-discovery.d.ts +10 -0
  123. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +103 -0
  124. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1138 -0
  125. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1128 -0
  126. package/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +236 -0
  127. package/dist/builtins/storage-orchestrator/storage-pressure-manager.d.ts +38 -0
  128. package/dist/builtins/system-backup/system-backup.service.d.ts +137 -0
  129. package/dist/builtins/system-config/index.d.ts +1 -0
  130. package/dist/builtins/system-config/index.js +8 -0
  131. package/dist/builtins/system-config/index.mjs +2 -0
  132. package/dist/builtins/system-config/system-config.addon.d.ts +10 -0
  133. package/dist/builtins/system-config/system-config.addon.js +232 -0
  134. package/dist/builtins/system-config/system-config.addon.mjs +226 -0
  135. package/dist/builtins/winston-logging/index.d.ts +3 -0
  136. package/dist/builtins/winston-logging/index.js +156 -0
  137. package/dist/builtins/winston-logging/index.mjs +144 -0
  138. package/dist/builtins/winston-logging/winston-destination.d.ts +21 -0
  139. package/dist/builtins/winston-logging/winston-logging.addon.d.ts +19 -0
  140. package/dist/chunk-CNf5ZN-e.mjs +37 -0
  141. package/dist/chunk-Cek0wNdY.js +64 -0
  142. package/dist/download/model-download-service.d.ts +41 -0
  143. package/dist/download/model-downloader.d.ts +31 -0
  144. package/dist/events/event-bus.d.ts +10 -0
  145. package/dist/events/system-event-bus.d.ts +14 -0
  146. package/dist/feature/feature-manager.d.ts +11 -0
  147. package/dist/formatter-B7qW8bPJ.mjs +162 -0
  148. package/dist/formatter-DqAKDlvN.js +167 -0
  149. package/dist/http/authenticated-file-server.d.ts +53 -0
  150. package/dist/http/data-plane-registry.d.ts +23 -0
  151. package/dist/http/file-data-plane.d.ts +10 -0
  152. package/dist/http/reverse-proxy.d.ts +15 -0
  153. package/dist/index.d.ts +82 -0
  154. package/dist/index.js +93485 -0
  155. package/dist/index.mjs +93179 -0
  156. package/dist/intel-accelerators-Gg0P5mnl.js +20 -0
  157. package/dist/intel-accelerators-hGgpZ0pX.mjs +19 -0
  158. package/dist/kernel/addon-class-resolver.d.ts +4 -0
  159. package/dist/kernel/addon-engine-manager.d.ts +22 -0
  160. package/dist/kernel/addon-health-monitor.d.ts +154 -0
  161. package/dist/kernel/addon-installer.d.ts +208 -0
  162. package/dist/kernel/addon-loader.d.ts +106 -0
  163. package/dist/kernel/addon-manifest.d.ts +77 -0
  164. package/dist/kernel/capability-handle.d.ts +46 -0
  165. package/dist/kernel/capability-registry.d.ts +412 -0
  166. package/dist/kernel/config-manager.d.ts +212 -0
  167. package/dist/kernel/config-schema.d.ts +93 -0
  168. package/dist/kernel/custom-action-registry.d.ts +23 -0
  169. package/dist/kernel/deps/addon-deps-manager.d.ts +19 -0
  170. package/dist/kernel/deps/manifest-native-deps.d.ts +25 -0
  171. package/dist/kernel/deps/manifest-python-deps.d.ts +20 -0
  172. package/dist/kernel/device-registry.d.ts +29 -0
  173. package/dist/kernel/fs-utils.d.ts +41 -0
  174. package/dist/kernel/hwaccel/hwaccel-resolver.d.ts +19 -0
  175. package/dist/kernel/hwaccel/hwaccel-service.d.ts +4 -0
  176. package/dist/kernel/index.d.ts +74 -0
  177. package/dist/kernel/infra-capabilities.d.ts +13 -0
  178. package/dist/kernel/moleculer/addon-context-factory.d.ts +91 -0
  179. package/dist/kernel/moleculer/addon-data-plane-facility.d.ts +19 -0
  180. package/dist/kernel/moleculer/addon-runner.d.ts +1 -0
  181. package/dist/kernel/moleculer/addon-service-factory.d.ts +50 -0
  182. package/dist/kernel/moleculer/broker-factory.d.ts +50 -0
  183. package/dist/kernel/moleculer/cap-usage-registry.d.ts +46 -0
  184. package/dist/kernel/moleculer/capabilities-access.d.ts +21 -0
  185. package/dist/kernel/moleculer/child-addon-call-dispatch.d.ts +46 -0
  186. package/dist/kernel/moleculer/child-cap-dispatch.d.ts +20 -0
  187. package/dist/kernel/moleculer/cluster-secret.d.ts +15 -0
  188. package/dist/kernel/moleculer/core-cap-service.d.ts +50 -0
  189. package/dist/kernel/moleculer/crash-supervisor.d.ts +50 -0
  190. package/dist/kernel/moleculer/device-cap-proxy.d.ts +79 -0
  191. package/dist/kernel/moleculer/event-bus-core.d.ts +53 -0
  192. package/dist/kernel/moleculer/event-bus.d.ts +53 -0
  193. package/dist/kernel/moleculer/hub-log-forwarder.d.ts +36 -0
  194. package/dist/kernel/moleculer/hub-service.d.ts +35 -0
  195. package/dist/kernel/moleculer/node-registry.d.ts +126 -0
  196. package/dist/kernel/moleculer/process-context.d.ts +4 -0
  197. package/dist/kernel/moleculer/process-service.d.ts +72 -0
  198. package/dist/kernel/moleculer/provider-registry.d.ts +28 -0
  199. package/dist/kernel/moleculer/readiness-context.d.ts +62 -0
  200. package/dist/kernel/moleculer/readiness-service.d.ts +7 -0
  201. package/dist/kernel/moleculer/register-node-client.d.ts +35 -0
  202. package/dist/kernel/moleculer/remote-logger.d.ts +43 -0
  203. package/dist/kernel/moleculer/resilient-cap-call.d.ts +28 -0
  204. package/dist/kernel/moleculer/stream-probe-service.d.ts +9 -0
  205. package/dist/kernel/moleculer/trpc-links.d.ts +189 -0
  206. package/dist/kernel/moleculer/typed-array-serde.d.ts +25 -0
  207. package/dist/kernel/moleculer/worker-device-restore.d.ts +10 -0
  208. package/dist/kernel/provider-kind-drift.d.ts +12 -0
  209. package/dist/kernel/restart-coordinator.d.ts +90 -0
  210. package/dist/kernel/storage-location-registry.d.ts +40 -0
  211. package/dist/kernel/transport/cap-action-name.d.ts +100 -0
  212. package/dist/kernel/transport/cap-route-resolver.d.ts +148 -0
  213. package/dist/kernel/transport/cap-route.d.ts +148 -0
  214. package/dist/kernel/transport/child-cap-protocol.d.ts +136 -0
  215. package/dist/kernel/transport/create-local-transport.d.ts +7 -0
  216. package/dist/kernel/transport/frame-codec.d.ts +7 -0
  217. package/dist/kernel/transport/index.d.ts +27 -0
  218. package/dist/kernel/transport/local-child-client.d.ts +136 -0
  219. package/dist/kernel/transport/local-child-registry.d.ts +179 -0
  220. package/dist/kernel/transport/local-endpoint-path.d.ts +6 -0
  221. package/dist/kernel/transport/local-transport.d.ts +46 -0
  222. package/dist/kernel/transport/parent-unowned-call.d.ts +75 -0
  223. package/dist/kernel/transport/socket-channel.d.ts +27 -0
  224. package/dist/kernel/transport/uds-event-bridge.d.ts +36 -0
  225. package/dist/kernel/transport/uds-event-bus.d.ts +22 -0
  226. package/dist/kernel/transport/uds-local-transport.d.ts +18 -0
  227. package/dist/kernel/transport/uds-log-ingest.d.ts +28 -0
  228. package/dist/kernel/transport/uds-logger.d.ts +44 -0
  229. package/dist/kernel/utils/ring-buffer.d.ts +15 -0
  230. package/dist/kernel/workspace-detect.d.ts +9 -0
  231. package/dist/lifecycle/lifecycle-state-machine.d.ts +28 -0
  232. package/dist/logging/formatter.d.ts +30 -0
  233. package/dist/logging/log-manager.d.ts +54 -0
  234. package/dist/logging/log-ring-buffer.d.ts +47 -0
  235. package/dist/logging/partitioned-log-buffer.d.ts +35 -0
  236. package/dist/logging/scoped-logger.d.ts +17 -0
  237. package/dist/main-DNnMW7Z2.js +9983 -0
  238. package/dist/main-rtjOwPBR.mjs +9976 -0
  239. package/dist/manifest-python-deps-D1DbAQEv.js +6724 -0
  240. package/dist/manifest-python-deps-DZsKTbs1.mjs +6315 -0
  241. package/dist/network/network-quality.d.ts +11 -0
  242. package/dist/notification/notification-service.d.ts +37 -0
  243. package/dist/notification/toast-service.d.ts +22 -0
  244. package/dist/pipeline/engine-manager-resolver.d.ts +15 -0
  245. package/dist/pipeline/pipeline-runner.d.ts +8 -0
  246. package/dist/pipeline/pipeline-validator.d.ts +13 -0
  247. package/dist/process/resource-monitor.d.ts +11 -0
  248. package/dist/python/python-env-manager.d.ts +12 -0
  249. package/dist/repl/interfaces.d.ts +31 -0
  250. package/dist/repl/repl-engine.d.ts +8 -0
  251. package/dist/resource-monitor-ClDGFyf6.mjs +57 -0
  252. package/dist/resource-monitor-IIEanuJt.js +74 -0
  253. package/dist/settle-sources-Bhsy57y-.js +38 -0
  254. package/dist/settle-sources-CDtNC8ub.mjs +33 -0
  255. package/dist/storage/fs-storage-backend.d.ts +40 -0
  256. package/dist/storage/storage-location-manager.d.ts +23 -0
  257. package/dist/storage/storage-manager.d.ts +83 -0
  258. package/dist/tar-BgAEMRBR.js +5434 -0
  259. package/dist/tar-ByMOPNM0.mjs +5429 -0
  260. package/dist/tls/cert-manager.d.ts +26 -0
  261. package/dist/tls/index.d.ts +1 -0
  262. package/package.json +343 -0
@@ -0,0 +1,136 @@
1
+ import { ChildCapDescriptor, CapCallInput, ChildLogMessage, AddonCallInput } from './child-cap-protocol.js';
2
+ import { SystemEvent, IReadinessRegistryRecord } from '@camstack/types';
3
+ export interface LocalChildClientOptions {
4
+ /** Parent node id — selects the UDS endpoint this child connects to. */
5
+ readonly nodeId: string;
6
+ /** This child's stable id (its addon-runner id). */
7
+ readonly childId: string;
8
+ /** Cap manifest sent to the parent on registration. */
9
+ readonly caps: readonly ChildCapDescriptor[];
10
+ /** Invoked for each parent→child cap call; returns the cap method's result. */
11
+ readonly dispatch: (call: CapCallInput) => Promise<unknown>;
12
+ }
13
+ /** Handler invoked for each parent→child addon-level call (`routes` / `custom`). */
14
+ export type AddonCallHandler = (call: AddonCallInput) => Promise<unknown>;
15
+ /**
16
+ * Child side of the local UDS transport. Connects to its parent (hub or
17
+ * agent), registers its cap manifest, and serves parent→child cap calls by
18
+ * delegating to `dispatch`. The provider implementation lives in the child;
19
+ * only routing keys + call arguments cross the wire.
20
+ *
21
+ * Additional channels beyond cap-call:
22
+ * - `emitEvent` fire-and-forget event toward the parent
23
+ * - `sendLog` fire-and-forget log entry toward the parent
24
+ * - `requestReadinessSnapshot` request/response snapshot of readiness records
25
+ * - `onEvent` register a handler for parent→child events
26
+ *
27
+ * Events and logs emitted before `start()` resolves are buffered and flushed
28
+ * on connect (mirrors the `updateCaps`/`latestCaps` pattern).
29
+ */
30
+ export declare class LocalChildClient {
31
+ private readonly options;
32
+ private client;
33
+ private channel;
34
+ /**
35
+ * The cap set `start()` will register, kept current by `updateCaps`. Native
36
+ * device caps register on device-restore, which can race AHEAD of the UDS
37
+ * connect — buffering here lets a pre-start `updateCaps` survive (start sends
38
+ * the latest set) instead of being lost or throwing.
39
+ */
40
+ private latestCaps;
41
+ /** Events and logs queued while the channel is not yet open. */
42
+ private readonly pendingEmits;
43
+ /** Handler for parent→child events. Registered via `onEvent`. */
44
+ private eventHandler;
45
+ /**
46
+ * Handler for parent→child addon-level calls (`routes` / `custom`).
47
+ * Registered via `onAddonCall`. Resolves the loaded addon instance and
48
+ * invokes its `addon-routes.getRoutes()` or its custom-action handler.
49
+ * Replaces the per-addon Moleculer `getRoutes` / `custom.<action>` actions
50
+ * removed in F1/F2. Only one handler is active at a time.
51
+ */
52
+ private addonCallHandler;
53
+ /**
54
+ * Handler for `set-log-level` messages pushed by the parent.
55
+ * Registered via `onSetLogLevel`. The handler applies the new level to the
56
+ * child's local Moleculer logger (mirrors `$node-mgmt.setLogLevel`).
57
+ * E2: wired in `addon-runner.ts` to forward to the broker logger.
58
+ */
59
+ private setLogLevelHandler;
60
+ /** Callbacks registered via `onConnected`. Fired on every (re)connect. */
61
+ private readonly connectedHandlers;
62
+ constructor(options: LocalChildClientOptions);
63
+ /**
64
+ * Register a callback that fires each time the client successfully connects
65
+ * (or reconnects) to its parent. Multiple handlers may be registered; all
66
+ * are called in registration order. Used by readiness-context in UDS mode
67
+ * to trigger a snapshot hydrate on connect/reconnect.
68
+ */
69
+ onConnected(handler: () => void): void;
70
+ /**
71
+ * Register a handler for events pushed from the parent to this child.
72
+ * Must be called before `start()` to avoid missing early events (though
73
+ * registration after start is also safe for events not yet delivered).
74
+ * Replaces any previously registered handler.
75
+ */
76
+ onEvent(handler: (event: SystemEvent) => void): void;
77
+ /**
78
+ * Register the handler invoked when the parent sends an `addon-call` (the
79
+ * addon-level routes / custom-action plane). The addon-runner wires this to
80
+ * resolve the loaded addon by id and dispatch to its `getRoutes()` or its
81
+ * custom-action handler. Safe to register before or after `start()`;
82
+ * replaces any prior handler.
83
+ */
84
+ onAddonCall(handler: AddonCallHandler): void;
85
+ /**
86
+ * E2: Register a handler invoked when the parent sends a `set-log-level`
87
+ * message to this child. The handler should forward the new level to the
88
+ * child's local Moleculer broker logger (mirrors `$node-mgmt.setLogLevel`).
89
+ * Safe to register before or after `start()`. Replaces any prior handler.
90
+ */
91
+ onSetLogLevel(handler: (level: string) => void): void;
92
+ /**
93
+ * True once `start()` has successfully connected and registered. Used by
94
+ * callers (event-bus/logger bridges) to know the channel is live.
95
+ */
96
+ get isConnected(): boolean;
97
+ start(): Promise<void>;
98
+ /** Flush buffered pre-start emits over the now-open channel. */
99
+ private flushPending;
100
+ /**
101
+ * Re-send the cap manifest to the parent, atomically replacing the child's
102
+ * registered descriptor set. Call this after device-restore so newly
103
+ * registered native (device-scoped) caps become routable over UDS.
104
+ *
105
+ * Safe to call before `start()`: the new set is buffered and `start()` sends
106
+ * it (device-restore can race ahead of the UDS connect). After `start()`,
107
+ * the set is sent immediately.
108
+ */
109
+ updateCaps(caps: readonly ChildCapDescriptor[]): Promise<void>;
110
+ /**
111
+ * Fire-and-forget: send a system event to the parent for forwarding to the
112
+ * hub event bus. Safe to call before `start()` — events are buffered and
113
+ * flushed on connect.
114
+ */
115
+ emitEvent(event: SystemEvent): void;
116
+ /**
117
+ * Fire-and-forget: send a structured log entry to the parent. Safe to call
118
+ * before `start()` — log entries are buffered and flushed on connect.
119
+ */
120
+ sendLog(entry: Omit<ChildLogMessage, 'kind'>): void;
121
+ /**
122
+ * Request the current readiness snapshot from the parent. Returns the
123
+ * authoritative set of `IReadinessRegistryRecord` entries the hub holds.
124
+ * Requires `start()` to have been called; throws with a clear message if not.
125
+ */
126
+ requestReadinessSnapshot(): Promise<readonly IReadinessRegistryRecord[]>;
127
+ /**
128
+ * Ask the parent to execute a cap call this child does NOT own. The parent
129
+ * routes to the owning local sibling over UDS, or — if no sibling owns it —
130
+ * to its `onUnownedCall` fallback (the cluster CapabilityRegistry in
131
+ * production). Throws if called before `start()`.
132
+ */
133
+ callOut(input: CapCallInput): Promise<unknown>;
134
+ /** Disconnect from the parent. Safe to call before `start()` (no-op) and idempotent. */
135
+ close(): Promise<void>;
136
+ }
@@ -0,0 +1,179 @@
1
+ import { LocalTransportServer } from './local-transport.js';
2
+ import { ChildLogMessage, CapCallInput, AddonCallInput, RegisteredChild } from './child-cap-protocol.js';
3
+ import { SystemEvent, IReadinessRegistryRecord } from '@camstack/types';
4
+ /**
5
+ * Sentinel prefix used in the no-route error thrown when `cap-call-out` has no
6
+ * local sibling and no `onUnownedCall` fallback. `ipcParentLink` detects this
7
+ * prefix to distinguish routing failures (safe to retry via broker) from real
8
+ * provider errors (must NOT retry to avoid double-executing side effects).
9
+ */
10
+ export declare const UDS_NO_ROUTE_PREFIX = "UDS_NO_ROUTE";
11
+ /**
12
+ * Minimal logger interface accepted by `LocalChildRegistry`.
13
+ * Kept narrow so the registry doesn't depend on any concrete logger class.
14
+ */
15
+ export interface LocalChildRegistryLogger {
16
+ info(msg: string, meta?: unknown): void;
17
+ }
18
+ /**
19
+ * Options accepted by `LocalChildRegistry`.
20
+ * The `server` field is the UDS server to listen on.
21
+ * The optional `onUnownedCall` is the parent-supplied fallback invoked when no
22
+ * local child owns the requested cap (the hub / agent will wire this to the
23
+ * cluster CapabilityRegistry).
24
+ * The optional `logger` receives a single deduplicated INFO line the first time
25
+ * each capName is routed child→sibling over UDS.
26
+ */
27
+ export interface LocalChildRegistryOptions {
28
+ readonly server: LocalTransportServer;
29
+ readonly onUnownedCall?: (input: CapCallInput) => Promise<unknown>;
30
+ readonly logger?: LocalChildRegistryLogger;
31
+ /**
32
+ * Resolver for the operator's active-singleton preference. When two or
33
+ * more local children register the SAME singleton capName (e.g. two
34
+ * addons both providing `webrtc-session`), the registry must consult
35
+ * `CapabilityRegistry` to pick the operator-selected provider instead of
36
+ * returning the first-registered child by insertion order. Returns the preferred
37
+ * addonId (== childId for solo-addon runners), or null when no
38
+ * preference is set or the cap is not a singleton.
39
+ */
40
+ readonly getActiveSingletonAddonId?: (capName: string) => string | null;
41
+ }
42
+ /**
43
+ * Parent-side authority for local addon-runners reachable over a
44
+ * `LocalTransportServer` (UDS). Children register their cap manifest on
45
+ * connect; the registry routes `(capName, deviceId?)` cap calls to the
46
+ * owning child over the channel and drops a child's caps on disconnect.
47
+ */
48
+ export declare class LocalChildRegistry {
49
+ private readonly children;
50
+ private registeredHandler;
51
+ private goneHandler;
52
+ private eventHandler;
53
+ private logHandler;
54
+ private readinessHandler;
55
+ private readonly server;
56
+ private readonly onUnownedCall?;
57
+ private readonly logger?;
58
+ private readonly getActiveSingletonAddonId?;
59
+ /** Tracks capNames already logged as UDS-routed; one INFO line per capName per process. */
60
+ private readonly egressRoutedCaps;
61
+ /**
62
+ * Accepts either a plain positional `server` argument (backward-compatible)
63
+ * or a full `LocalChildRegistryOptions` object.
64
+ *
65
+ * Positional overloads (existing call sites are unchanged):
66
+ * new LocalChildRegistry(server)
67
+ * new LocalChildRegistry(server, onUnownedCall)
68
+ *
69
+ * Options object (new call sites that pass a logger):
70
+ * new LocalChildRegistry({ server, onUnownedCall, logger })
71
+ */
72
+ constructor(serverOrOptions: LocalTransportServer | LocalChildRegistryOptions, onUnownedCallArg?: (input: CapCallInput) => Promise<unknown>);
73
+ start(): Promise<void>;
74
+ /**
75
+ * Child id that can service a call to `capName` (optionally addressing
76
+ * `deviceId`), or null.
77
+ *
78
+ * `deviceId` is a routing HINT, not a hard filter. A singleton cap
79
+ * (`pipeline-runner`, `stream-broker`, …) addresses devices through its
80
+ * METHOD ARGUMENTS — `attachCamera({ deviceId })` is one provider serving
81
+ * many cameras — so its descriptor carries no `deviceId`. Resolving on
82
+ * `deviceId` alone would never match it and would force the call onto the
83
+ * broker fallback (which then hangs in service discovery). Hence:
84
+ * 1. exact device-scoped owner (native per-device caps where each child
85
+ * owns a disjoint device subset) is preferred, then
86
+ * 2. a singleton owner (deviceId-less descriptor) is the fallback.
87
+ * A cap is globally singleton XOR device-scoped, so the two tiers never
88
+ * compete for the same capName.
89
+ */
90
+ resolveChildId(capName: string, deviceId?: number): string | null;
91
+ /** First child whose cap manifest contains a descriptor matching `predicate`. */
92
+ private findChildId;
93
+ /** Every child whose cap manifest contains a descriptor matching `predicate`. */
94
+ private findAllChildIds;
95
+ /**
96
+ * Does the named child currently provide `(capName, deviceId?)`?
97
+ *
98
+ * Used by the hub proxy seam, which knows the EXACT addon (→ runner →
99
+ * childId) a provider belongs to. Unlike `resolveChildId` (which picks the
100
+ * first child owning `capName`), this targets one child — required for
101
+ * COLLECTION caps (`addon-widgets-source`, …) where many children register
102
+ * the same capName: routing by capName alone collapses every provider to
103
+ * the first child. Same deviceId-as-hint semantics as `resolveChildId`:
104
+ * a device-scoped descriptor matching `deviceId` OR a deviceId-less
105
+ * (singleton/collection) descriptor counts.
106
+ */
107
+ /**
108
+ * Is `childId` currently connected (has it completed its UDS handshake)?
109
+ * Coarser than {@link childProvides}: it answers "is the child reachable
110
+ * over UDS at all", regardless of which caps it has announced yet. Used by
111
+ * the route-mount fallback to decide between the handler-stripped
112
+ * `callAddonOnChild(target:'routes')` path (child reachable) and awaiting a
113
+ * cap proxy's `getRoutes()` (child not yet UDS-registered).
114
+ */
115
+ isChildKnown(childId: string): boolean;
116
+ childProvides(childId: string, capName: string, deviceId?: number): boolean;
117
+ /** Forward a cap method call to a SPECIFIC child by id over UDS; rejects if that child is absent. */
118
+ callCapOnChild(childId: string, input: CapCallInput): Promise<unknown>;
119
+ /** Forward a cap method call to the owning child over UDS; rejects if none. */
120
+ callCap(input: CapCallInput): Promise<unknown>;
121
+ /**
122
+ * Forward an ADDON-LEVEL call (routes / custom-action) to a SPECIFIC child
123
+ * by id over UDS; rejects if that child is absent.
124
+ *
125
+ * The childId for a hub-local single-addon runner equals the addonId
126
+ * (`resolveRunnerId` returns the addonId when no `execution.group` is
127
+ * declared — no shipped addon declares one). Mirrors `callCapOnChild` for
128
+ * the cap plane; carries the two surfaces the removed per-addon Moleculer
129
+ * broker used to serve (`getRoutes` + `custom.<action>`).
130
+ */
131
+ callAddonOnChild(childId: string, input: AddonCallInput): Promise<unknown>;
132
+ /** Build the parent→child `addon-call` wire message from an addon-call input. */
133
+ private toAddonCall;
134
+ /** Build the parent→child `cap-call` wire message from a routing input. */
135
+ private toCapCall;
136
+ listChildren(): readonly RegisteredChild[];
137
+ /** Register the (single) child-registered handler. Only one handler is active at a time. */
138
+ onChildRegistered(handler: (child: RegisteredChild) => void): void;
139
+ /** Register the (single) child-gone handler. Only one handler is active at a time. */
140
+ onChildGone(handler: (childId: string) => void): void;
141
+ /**
142
+ * Register the (single) child-event handler. Invoked when a child sends an
143
+ * event via `LocalChildClient.emitEvent`. Only one handler is active at a
144
+ * time; a new handler replaces the prior one. Pass `null` to clear the
145
+ * handler entirely (used by the UDS event bridge disposer on shutdown).
146
+ */
147
+ onChildEvent(handler: ((childId: string, event: SystemEvent) => void) | null): void;
148
+ /**
149
+ * Register the (single) child-log handler. Invoked when a child sends a log
150
+ * entry via `LocalChildClient.sendLog`. Only one handler is active.
151
+ */
152
+ onChildLog(handler: (childId: string, entry: ChildLogMessage) => void): void;
153
+ /**
154
+ * Register the handler that supplies the authoritative readiness snapshot
155
+ * when a child sends a `readiness-request`. Only one handler is active.
156
+ */
157
+ onReadinessSnapshotRequest(handler: () => readonly IReadinessRegistryRecord[]): void;
158
+ /**
159
+ * Push a parent→child event to a specific child. Fire-and-forget (uses the
160
+ * one-way `emit` path on the channel). No-op if the child is not connected.
161
+ */
162
+ sendEventToChild(childId: string, event: SystemEvent, sourceNodeId: string): void;
163
+ /**
164
+ * Push a parent→child event to every registered child, optionally skipping
165
+ * one (the originating child, to avoid echo). Fire-and-forget.
166
+ */
167
+ broadcastEventToChildren(event: SystemEvent, sourceNodeId: string, exceptChildId?: string): void;
168
+ /**
169
+ * E2: Send a `set-log-level` control message to a specific child.
170
+ * Returns `true` if the child is currently connected and the message was
171
+ * emitted; `false` if the child is not connected (no-op). The `false`
172
+ * return lets the caller (MoleculerService.setChildLogLevelByNodeId) fall
173
+ * back to the Moleculer `$node-mgmt.setLogLevel` action for the node.
174
+ * Mirrors the `$node-mgmt.setLogLevel` Moleculer action for UDS children.
175
+ */
176
+ setChildLogLevel(childId: string, level: string): boolean;
177
+ close(): Promise<void>;
178
+ private onConnection;
179
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Filesystem path (POSIX) or named-pipe path (Windows) a node listens on for
3
+ * its local addon-runners. Derived deterministically from the nodeId so a
4
+ * parent and its children agree without extra coordination.
5
+ */
6
+ export declare function localEndpointPath(nodeId: string): string;
@@ -0,0 +1,46 @@
1
+ /** Wire frame exchanged over a local channel. */
2
+ export type Frame = {
3
+ readonly k: 'req';
4
+ readonly id: number;
5
+ readonly body: unknown;
6
+ } | {
7
+ readonly k: 'res';
8
+ readonly id: number;
9
+ readonly ok: true;
10
+ readonly body: unknown;
11
+ } | {
12
+ readonly k: 'res';
13
+ readonly id: number;
14
+ readonly ok: false;
15
+ readonly err: string;
16
+ } | {
17
+ readonly k: 'evt';
18
+ readonly body: unknown;
19
+ };
20
+ export type RequestHandler = (body: unknown) => Promise<unknown>;
21
+ export type EventHandler = (body: unknown) => void;
22
+ /** A bidirectional request/response + one-way event channel over one socket. */
23
+ export interface LocalChannel {
24
+ request(body: unknown): Promise<unknown>;
25
+ emit(body: unknown): void;
26
+ onRequest(handler: RequestHandler): void;
27
+ onEvent(handler: EventHandler): void;
28
+ onClose(handler: () => void): void;
29
+ close(): void;
30
+ }
31
+ /** Parent side: listens and hands a channel per accepted child connection. */
32
+ export interface LocalTransportServer {
33
+ listen(): Promise<void>;
34
+ onConnection(handler: (channel: LocalChannel) => void): void;
35
+ close(): Promise<void>;
36
+ }
37
+ /** Child side: connects to the parent and returns a channel. */
38
+ export interface LocalTransportClient {
39
+ connect(): Promise<LocalChannel>;
40
+ close(): Promise<void>;
41
+ }
42
+ /** The extension seam: a future transport implements this factory. */
43
+ export interface LocalTransportFactory {
44
+ createServer(nodeId: string): LocalTransportServer;
45
+ createClient(nodeId: string): LocalTransportClient;
46
+ }
@@ -0,0 +1,75 @@
1
+ import { CapCallInput } from './child-cap-protocol.js';
2
+ import { CapRouteResolver, HubLocalChildDispatcher } from './cap-route-resolver.js';
3
+ import { HubNodeRegistry } from '../moleculer/node-registry.js';
4
+ import { ServiceBroker } from 'moleculer';
5
+ /**
6
+ * Minimal logger surface accepted by the unowned-call handler. Matches the
7
+ * `LocalChildRegistryLogger` shape so a single logger object can be shared.
8
+ */
9
+ export interface ParentUnownedCallLogger {
10
+ debug?(msg: string, meta?: unknown): void;
11
+ warn?(msg: string, meta?: unknown): void;
12
+ }
13
+ export interface ParentUnownedCallDeps {
14
+ /**
15
+ * Returns the parent's `CapRouteResolver` at call time, or `null` when the
16
+ * parent has none (the agent) or it has not been constructed yet (the hub,
17
+ * before `onModuleInit` finishes — the resolver is built late, so this is a
18
+ * live getter, not a captured value).
19
+ */
20
+ readonly getResolver: () => CapRouteResolver | null;
21
+ /** The parent's Moleculer broker — reaches the cluster + the hub's `$`-infra services. */
22
+ readonly broker: ServiceBroker;
23
+ /**
24
+ * The hub's single capability authority. Used to find the node that OWNS a
25
+ * device-scoped native cap so the broker-fallback can be pinned to it instead
26
+ * of load-balancing the call (which can hit the wrong provider).
27
+ */
28
+ readonly nodeRegistry: HubNodeRegistry;
29
+ /**
30
+ * Hub-local UDS child dispatcher (`LocalChildRegistry`). Resolves
31
+ * device-scoped native caps OWNED by hub-local children (reolink/hikvision
32
+ * cameras run as forked hub-local UDS children — they register via the hub's
33
+ * `LocalChildRegistry`, NOT via `registerNode`, so the `nodeRegistry` lookup
34
+ * is empty for them) and dispatches the call to the owning child over UDS.
35
+ *
36
+ * A live GETTER (init-order safety): on the agent the local registry is built
37
+ * AFTER this handler, so the instance is captured lazily. Returns null when
38
+ * no local registry exists (failed to start) or when not yet constructed.
39
+ */
40
+ readonly getLocalDispatcher?: () => HubLocalChildDispatcher | null;
41
+ /**
42
+ * Optional predicate — returns `true` when `capName` is a DEVICE-NATIVE cap
43
+ * (`deviceNative: true` in its `CapabilityDefinition`): the provider IS the
44
+ * device and routes ONLY over UDS / the per-node native path, never as a plain
45
+ * Moleculer service. The kernel layer has no cap registry, so the wiring side
46
+ * (which does) injects this.
47
+ *
48
+ * It gates the registration-race recovery in the broker-fallback branch: when
49
+ * a device-scoped call's hub-local binding is not yet in the LocalChildRegistry
50
+ * (`resolveChildId === null`) and no remote owner is known, the handler applies
51
+ * a SHORT bounded retry, then — if still unresolved AND the cap is device-native
52
+ * — throws a precise "binding not yet registered" error instead of attempting
53
+ * the unpinned `brokerCallForCap`, which can NEVER reach a device-native cap and
54
+ * would surface the misleading doubled `${cap}.${cap}.${method}` Moleculer error.
55
+ *
56
+ * Omitted (or returning `false`) ⇒ legacy behaviour is preserved exactly: no
57
+ * retry, no precise error, straight to the existing broker fallback. This keeps
58
+ * deviceId-carrying SYSTEM-cap calls (e.g. `system.info({deviceId})`) fast.
59
+ */
60
+ readonly isDeviceNativeCap?: (capName: string) => boolean;
61
+ /** Optional logger for the broker-fallback diagnostic line. */
62
+ readonly logger?: ParentUnownedCallLogger;
63
+ }
64
+ /**
65
+ * Build the `onUnownedCall` handler the hub / agent passes into
66
+ * `new LocalChildRegistry({ ..., onUnownedCall })`.
67
+ *
68
+ * The returned handler:
69
+ * - tries the resolver first (when present),
70
+ * - falls back to the broker for `no-provider` resolver misses (the
71
+ * `$`-infra / core services), and
72
+ * - surfaces a clear error when the call is genuinely unroutable (so the
73
+ * child's call rejects rather than hanging).
74
+ */
75
+ export declare function createParentUnownedCallHandler(deps: ParentUnownedCallDeps): (input: CapCallInput) => Promise<unknown>;
@@ -0,0 +1,27 @@
1
+ import { Socket } from 'node:net';
2
+ import { LocalChannel, RequestHandler, EventHandler } from './local-transport.js';
3
+ export declare class SocketChannel implements LocalChannel {
4
+ private readonly socket;
5
+ private nextId;
6
+ private readonly pending;
7
+ private readonly decoder;
8
+ private requestHandler;
9
+ private eventHandler;
10
+ private closeHandler;
11
+ private closed;
12
+ private closeFired;
13
+ constructor(socket: Socket);
14
+ request(body: unknown): Promise<unknown>;
15
+ emit(body: unknown): void;
16
+ /** Replace the request handler. Only one handler is active at a time. */
17
+ onRequest(handler: RequestHandler): void;
18
+ /** Replace the event handler. Only one handler is active at a time. */
19
+ onEvent(handler: EventHandler): void;
20
+ /** Replace the close handler. Only one handler is active at a time. */
21
+ onClose(handler: () => void): void;
22
+ close(): void;
23
+ private send;
24
+ private onData;
25
+ private handleFrame;
26
+ private handleClose;
27
+ }
@@ -0,0 +1,36 @@
1
+ import { IEventBus, SystemEvent } from '@camstack/types';
2
+ /**
3
+ * Minimal surface the bridge requires from `LocalChildRegistry`.
4
+ * Structurally typed so tests can provide a fake without any casts.
5
+ */
6
+ export interface ChildEventBroadcaster {
7
+ /**
8
+ * Register the (single) child-event handler, or pass `null` to clear it.
9
+ * A new handler replaces the prior one; `null` removes it entirely.
10
+ */
11
+ onChildEvent(handler: ((childId: string, event: SystemEvent) => void) | null): void;
12
+ sendEventToChild(childId: string, event: SystemEvent, sourceNodeId: string): void;
13
+ broadcastEventToChildren(event: SystemEvent, sourceNodeId: string, exceptChildId?: string): void;
14
+ }
15
+ /**
16
+ * Dependencies for the UDS event bridge.
17
+ */
18
+ export interface UdsEventBridgeDeps {
19
+ /** The parent-side child registry. Only the event-related surface is required. */
20
+ readonly registry: ChildEventBroadcaster;
21
+ /** The parent process's event bus (backed by `getBrokerEventBus(broker)`). */
22
+ readonly parentBus: IEventBus;
23
+ /** This process's Moleculer node ID (e.g. `'hub'` or `'agent-a1b2c3'`). */
24
+ readonly parentNodeId: string;
25
+ }
26
+ /**
27
+ * Create the parent-side UDS ↔ Moleculer event bridge.
28
+ *
29
+ * Call this once after the parent's `LocalChildRegistry` and `IEventBus` are
30
+ * both ready. The bridge is inert-but-correct while no children are connected
31
+ * (UDS child events never arrive, cluster events are fan-outed to zero children).
32
+ *
33
+ * @returns A disposer function that unsubscribes the bridge from the parent bus
34
+ * and clears the child-event handler. Call it on process shutdown.
35
+ */
36
+ export declare function createUdsEventBridge(deps: UdsEventBridgeDeps): () => void;
@@ -0,0 +1,22 @@
1
+ import { IEventBus, SystemEvent } from '@camstack/types';
2
+ /**
3
+ * Minimal interface this bus requires from the child-side UDS transport.
4
+ * `LocalChildClient` satisfies it structurally; tests can provide a fake.
5
+ *
6
+ * - `emitEvent` — fire-and-forget: send a system event to the parent.
7
+ * - `onEvent` — register the single handler for parent→child events.
8
+ * (Only one handler is registered; calling again replaces the previous one.)
9
+ */
10
+ export interface UdsEventChannel {
11
+ emitEvent(event: SystemEvent): void;
12
+ onEvent(handler: (event: SystemEvent) => void): void;
13
+ }
14
+ /**
15
+ * Create a UDS-backed `IEventBus` for use inside a forked child process.
16
+ *
17
+ * @param client - The UDS channel toward the parent (hub or agent).
18
+ * @param addonId - This child's stable addon id — stamped as `sourceAddonId`
19
+ * on every outbound event so cluster consumers can attribute
20
+ * events to their source addon.
21
+ */
22
+ export declare function createUdsEventBus(client: UdsEventChannel, addonId: string): IEventBus;
@@ -0,0 +1,18 @@
1
+ import { LocalChannel, LocalTransportServer, LocalTransportClient } from './local-transport.js';
2
+ export declare class UdsLocalTransportServer implements LocalTransportServer {
3
+ private readonly path;
4
+ private server;
5
+ private connHandler;
6
+ private readonly channels;
7
+ constructor(path: string);
8
+ onConnection(handler: (channel: LocalChannel) => void): void;
9
+ listen(): Promise<void>;
10
+ close(): Promise<void>;
11
+ }
12
+ export declare class UdsLocalTransportClient implements LocalTransportClient {
13
+ private readonly path;
14
+ private channel;
15
+ constructor(path: string);
16
+ connect(): Promise<LocalChannel>;
17
+ close(): Promise<void>;
18
+ }
@@ -0,0 +1,28 @@
1
+ import { LogTags } from '@camstack/types';
2
+ import { ChildLogMessage } from './child-cap-protocol.js';
3
+ /**
4
+ * The entry shape accepted by `LoggingService.writeFromWorker` (hub) and by
5
+ * the agent's `log-receiver.ingest` Moleculer forwarding call.
6
+ *
7
+ * Typed here so the helper has no dependency on hub-only server classes.
8
+ */
9
+ export interface WorkerLogEntry {
10
+ readonly addonId: string;
11
+ readonly nodeId?: string;
12
+ readonly level: string;
13
+ readonly message: string;
14
+ readonly scope?: string;
15
+ readonly tags?: LogTags;
16
+ readonly meta?: Record<string, unknown>;
17
+ }
18
+ /**
19
+ * Convert a `ChildLogMessage` received over a UDS channel into the
20
+ * `WorkerLogEntry` shape.
21
+ *
22
+ * - `childId` is used as the `nodeId` fallback when the child did not include
23
+ * its own `nodeId` in the log entry (pre-B2 runners or very early boot logs).
24
+ * - The entry's `addonId` is preserved as-is — it identifies the actual addon
25
+ * that emitted the log, not the runner that forwarded it. Child identity is
26
+ * fully preserved so the admin-UI log stream shows the originating addon.
27
+ */
28
+ export declare function udsChildLogToWorkerEntry(childId: string, entry: ChildLogMessage): WorkerLogEntry;
@@ -0,0 +1,44 @@
1
+ import { IScopedLogger, LogTags } from '@camstack/types';
2
+ import { ChildLogMessage } from './child-cap-protocol.js';
3
+ /**
4
+ * Minimal interface this module requires from the transport client.
5
+ *
6
+ * `LocalChildClient` satisfies this structurally. Using a minimal named
7
+ * interface keeps `uds-logger.ts` decoupled from the full `LocalChildClient`
8
+ * class and allows tests to pass a plain fake object without casts.
9
+ *
10
+ * `isConnected` is intentionally omitted — the logger never reads it; all
11
+ * pre-connect buffering is handled by the client implementation.
12
+ */
13
+ export interface UdsLogSink {
14
+ /**
15
+ * Fire-and-forget: send a structured log entry to the parent.
16
+ * Safe to call before `start()` — entries are buffered and flushed on connect.
17
+ */
18
+ readonly sendLog: (entry: Omit<ChildLogMessage, 'kind'>) => void;
19
+ }
20
+ /**
21
+ * Mutable log-level control shared across every `IScopedLogger` built by a
22
+ * single `createUdsLogger` family (the root plus its `child`/`withTags`
23
+ * descendants). Replaces the broker logger's per-appender level: the parent's
24
+ * `$node-mgmt.setLogLevel` equivalent over UDS (`onSetLogLevel`) calls
25
+ * `setLevel`, and entries below the threshold are dropped before `sendLog`
26
+ * (the parent's LoggingService also filters at query time — this just trims
27
+ * transport traffic, matching the broker `**: childLogLevel` appender gate).
28
+ */
29
+ export interface UdsLogLevelControl {
30
+ setLevel(level: string): void;
31
+ }
32
+ declare function createUdsLogger(client: UdsLogSink, addonId: string, nodeId: string, scope?: string, tags?: LogTags): IScopedLogger;
33
+ /**
34
+ * Like {@link createUdsLogger} but also returns a {@link UdsLogLevelControl}.
35
+ * The control's `setLevel` retunes the threshold for this logger AND every
36
+ * `child`/`withTags` descendant (they share the level state). Used by the
37
+ * `addon-runner` self-logger so the parent's UDS `set-log-level` message can
38
+ * raise/lower the child's outbound log verbosity.
39
+ */
40
+ declare function createUdsLoggerWithControl(client: UdsLogSink, addonId: string, nodeId: string, scope?: string, tags?: LogTags): {
41
+ logger: IScopedLogger;
42
+ control: UdsLogLevelControl;
43
+ };
44
+ export { createUdsLogger, createUdsLoggerWithControl };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Fixed-capacity ring buffer. When full, push() overwrites the oldest entry.
3
+ * drain() returns up to maxCount items in FIFO order and removes them.
4
+ */
5
+ export declare class RingBuffer<T> {
6
+ private readonly capacity;
7
+ private readonly items;
8
+ private head;
9
+ private tail;
10
+ private count;
11
+ constructor(capacity: number);
12
+ get size(): number;
13
+ push(item: T): void;
14
+ drain(maxCount: number): T[];
15
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Detect whether we're running inside the monorepo workspace.
3
+ * Returns the absolute path to the packages/ directory if found, otherwise null.
4
+ *
5
+ * Single source of truth — replaces identical implementations in:
6
+ * - first-boot-installer.ts
7
+ * - addon-bridge.service.ts
8
+ */
9
+ export declare function detectWorkspacePackagesDir(startDir: string): string | null;