@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.
- package/dist/addon/addon-api-factory.d.ts +35 -0
- package/dist/addon-routes/addon-route-registry.d.ts +37 -0
- package/dist/addon-runner.js +599 -0
- package/dist/addon-runner.mjs +597 -0
- package/dist/auth/api-key-manager.d.ts +26 -0
- package/dist/auth/auth-manager.d.ts +109 -0
- package/dist/auth/parse-record.d.ts +18 -0
- package/dist/auth/scope-matcher.d.ts +7 -0
- package/dist/auth/scoped-token-manager.d.ts +40 -0
- package/dist/auth/totp-manager.d.ts +51 -0
- package/dist/auth/user-manager.d.ts +34 -0
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.d.ts +53 -0
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +259 -0
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +251 -0
- package/dist/builtins/addon-pages-aggregator/dedupe-pages.d.ts +6 -0
- package/dist/builtins/addon-pages-aggregator/index.d.ts +1 -0
- package/dist/builtins/addon-pages-aggregator/index.js +8 -0
- package/dist/builtins/addon-pages-aggregator/index.mjs +2 -0
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.d.ts +47 -0
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +228 -0
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +220 -0
- package/dist/builtins/addon-widgets-aggregator/index.d.ts +1 -0
- package/dist/builtins/addon-widgets-aggregator/index.js +8 -0
- package/dist/builtins/addon-widgets-aggregator/index.mjs +2 -0
- package/dist/builtins/alerts/alerts.addon.d.ts +81 -0
- package/dist/builtins/alerts/alerts.addon.js +601 -0
- package/dist/builtins/alerts/alerts.addon.mjs +595 -0
- package/dist/builtins/alerts/index.d.ts +1 -0
- package/dist/builtins/alerts/index.js +4 -0
- package/dist/builtins/alerts/index.mjs +2 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +147 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2229 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2220 -0
- package/dist/builtins/backup-orchestrator/cron-helpers.d.ts +23 -0
- package/dist/builtins/backup-orchestrator/destination-policy.d.ts +72 -0
- package/dist/builtins/backup-orchestrator/download-helpers.d.ts +12 -0
- package/dist/builtins/backup-orchestrator/index.d.ts +2 -0
- package/dist/builtins/backup-orchestrator/index.js +8 -0
- package/dist/builtins/backup-orchestrator/index.mjs +2 -0
- package/dist/builtins/backup-orchestrator/manifest-store.d.ts +77 -0
- package/dist/builtins/console-logging/console-destination.d.ts +13 -0
- package/dist/builtins/console-logging/console-logging.addon.d.ts +25 -0
- package/dist/builtins/console-logging/index.d.ts +3 -0
- package/dist/builtins/console-logging/index.js +104 -0
- package/dist/builtins/console-logging/index.mjs +95 -0
- package/dist/builtins/device-manager/device-config-contribution.d.ts +32 -0
- package/dist/builtins/device-manager/device-event-propagator.d.ts +26 -0
- package/dist/builtins/device-manager/device-link-overlay.d.ts +23 -0
- package/dist/builtins/device-manager/device-link-resolver.d.ts +15 -0
- package/dist/builtins/device-manager/device-manager.addon.d.ts +452 -0
- package/dist/builtins/device-manager/device-manager.addon.js +3299 -0
- package/dist/builtins/device-manager/device-manager.addon.mjs +3292 -0
- package/dist/builtins/device-manager/index.d.ts +2 -0
- package/dist/builtins/device-manager/index.js +8 -0
- package/dist/builtins/device-manager/index.mjs +2 -0
- package/dist/builtins/hub-forwarder/hub-forwarder-destination.d.ts +44 -0
- package/dist/builtins/hub-forwarder/hub-forwarder.addon.d.ts +15 -0
- package/dist/builtins/hub-forwarder/index.d.ts +3 -0
- package/dist/builtins/hub-forwarder/index.js +154 -0
- package/dist/builtins/hub-forwarder/index.mjs +145 -0
- package/dist/builtins/local-auth/auth-schema.d.ts +26 -0
- package/dist/builtins/local-auth/index.d.ts +1 -0
- package/dist/builtins/local-auth/index.js +4 -0
- package/dist/builtins/local-auth/index.mjs +2 -0
- package/dist/builtins/local-auth/local-auth.addon.d.ts +18 -0
- package/dist/builtins/local-auth/local-auth.addon.js +8094 -0
- package/dist/builtins/local-auth/local-auth.addon.mjs +8063 -0
- package/dist/builtins/local-auth/oauth-grants.d.ts +45 -0
- package/dist/builtins/local-auth/oauth-session-manager.d.ts +50 -0
- package/dist/builtins/local-network/index.d.ts +2 -0
- package/dist/builtins/local-network/index.js +10 -0
- package/dist/builtins/local-network/index.mjs +2 -0
- package/dist/builtins/local-network/local-network.addon.d.ts +150 -0
- package/dist/builtins/local-network/local-network.addon.js +489 -0
- package/dist/builtins/local-network/local-network.addon.mjs +477 -0
- package/dist/builtins/native-metrics/index.d.ts +2 -0
- package/dist/builtins/native-metrics/native-metrics-provider.d.ts +48 -0
- package/dist/builtins/native-metrics/native-metrics.addon.d.ts +73 -0
- package/dist/builtins/native-metrics/native-metrics.addon.js +922 -0
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +914 -0
- package/dist/builtins/platform-probe/hardware-decode-accel-probe.d.ts +37 -0
- package/dist/builtins/platform-probe/hardware-encoder-probe.d.ts +13 -0
- package/dist/builtins/platform-probe/index.d.ts +22 -0
- package/dist/builtins/platform-probe/index.js +834 -0
- package/dist/builtins/platform-probe/index.mjs +822 -0
- package/dist/builtins/platform-probe/inference-config-resolver.d.ts +29 -0
- package/dist/builtins/platform-probe/intel-accelerators.d.ts +11 -0
- package/dist/builtins/platform-probe/platform-scorer.d.ts +30 -0
- package/dist/builtins/platform-probe/runtime-packages.d.ts +6 -0
- package/dist/builtins/remote-access-orchestrator/enabled-providers-reconcile.d.ts +96 -0
- package/dist/builtins/remote-access-orchestrator/index.d.ts +1 -0
- package/dist/builtins/remote-access-orchestrator/index.js +8 -0
- package/dist/builtins/remote-access-orchestrator/index.mjs +2 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.d.ts +40 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +214 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +208 -0
- package/dist/builtins/shared/settle-sources.d.ts +22 -0
- package/dist/builtins/snapshot/index.d.ts +2 -0
- package/dist/builtins/snapshot/index.js +494 -0
- package/dist/builtins/snapshot/index.mjs +488 -0
- package/dist/builtins/snapshot/snapshot.addon.d.ts +120 -0
- package/dist/builtins/sqlite-storage/config-store.d.ts +8 -0
- package/dist/builtins/sqlite-storage/device-store.d.ts +23 -0
- package/dist/builtins/sqlite-storage/filesystem-browse-provider.d.ts +25 -0
- package/dist/builtins/sqlite-storage/filesystem-storage-provider.d.ts +83 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts +32 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +396 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +388 -0
- package/dist/builtins/sqlite-storage/index.d.ts +8 -0
- package/dist/builtins/sqlite-storage/index.js +62 -0
- package/dist/builtins/sqlite-storage/index.mjs +49 -0
- package/dist/builtins/sqlite-storage/integration-registry.d.ts +27 -0
- package/dist/builtins/sqlite-storage/path-guard.d.ts +4 -0
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +102 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +14 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +644 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +636 -0
- package/dist/builtins/storage-orchestrator/index.d.ts +6 -0
- package/dist/builtins/storage-orchestrator/index.js +10 -0
- package/dist/builtins/storage-orchestrator/index.mjs +2 -0
- package/dist/builtins/storage-orchestrator/location-store.d.ts +49 -0
- package/dist/builtins/storage-orchestrator/provider-discovery.d.ts +10 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +103 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1138 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1128 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +236 -0
- package/dist/builtins/storage-orchestrator/storage-pressure-manager.d.ts +38 -0
- package/dist/builtins/system-backup/system-backup.service.d.ts +137 -0
- package/dist/builtins/system-config/index.d.ts +1 -0
- package/dist/builtins/system-config/index.js +8 -0
- package/dist/builtins/system-config/index.mjs +2 -0
- package/dist/builtins/system-config/system-config.addon.d.ts +10 -0
- package/dist/builtins/system-config/system-config.addon.js +232 -0
- package/dist/builtins/system-config/system-config.addon.mjs +226 -0
- package/dist/builtins/winston-logging/index.d.ts +3 -0
- package/dist/builtins/winston-logging/index.js +156 -0
- package/dist/builtins/winston-logging/index.mjs +144 -0
- package/dist/builtins/winston-logging/winston-destination.d.ts +21 -0
- package/dist/builtins/winston-logging/winston-logging.addon.d.ts +19 -0
- package/dist/chunk-CNf5ZN-e.mjs +37 -0
- package/dist/chunk-Cek0wNdY.js +64 -0
- package/dist/download/model-download-service.d.ts +41 -0
- package/dist/download/model-downloader.d.ts +31 -0
- package/dist/events/event-bus.d.ts +10 -0
- package/dist/events/system-event-bus.d.ts +14 -0
- package/dist/feature/feature-manager.d.ts +11 -0
- package/dist/formatter-B7qW8bPJ.mjs +162 -0
- package/dist/formatter-DqAKDlvN.js +167 -0
- package/dist/http/authenticated-file-server.d.ts +53 -0
- package/dist/http/data-plane-registry.d.ts +23 -0
- package/dist/http/file-data-plane.d.ts +10 -0
- package/dist/http/reverse-proxy.d.ts +15 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +93485 -0
- package/dist/index.mjs +93179 -0
- package/dist/intel-accelerators-Gg0P5mnl.js +20 -0
- package/dist/intel-accelerators-hGgpZ0pX.mjs +19 -0
- package/dist/kernel/addon-class-resolver.d.ts +4 -0
- package/dist/kernel/addon-engine-manager.d.ts +22 -0
- package/dist/kernel/addon-health-monitor.d.ts +154 -0
- package/dist/kernel/addon-installer.d.ts +208 -0
- package/dist/kernel/addon-loader.d.ts +106 -0
- package/dist/kernel/addon-manifest.d.ts +77 -0
- package/dist/kernel/capability-handle.d.ts +46 -0
- package/dist/kernel/capability-registry.d.ts +412 -0
- package/dist/kernel/config-manager.d.ts +212 -0
- package/dist/kernel/config-schema.d.ts +93 -0
- package/dist/kernel/custom-action-registry.d.ts +23 -0
- package/dist/kernel/deps/addon-deps-manager.d.ts +19 -0
- package/dist/kernel/deps/manifest-native-deps.d.ts +25 -0
- package/dist/kernel/deps/manifest-python-deps.d.ts +20 -0
- package/dist/kernel/device-registry.d.ts +29 -0
- package/dist/kernel/fs-utils.d.ts +41 -0
- package/dist/kernel/hwaccel/hwaccel-resolver.d.ts +19 -0
- package/dist/kernel/hwaccel/hwaccel-service.d.ts +4 -0
- package/dist/kernel/index.d.ts +74 -0
- package/dist/kernel/infra-capabilities.d.ts +13 -0
- package/dist/kernel/moleculer/addon-context-factory.d.ts +91 -0
- package/dist/kernel/moleculer/addon-data-plane-facility.d.ts +19 -0
- package/dist/kernel/moleculer/addon-runner.d.ts +1 -0
- package/dist/kernel/moleculer/addon-service-factory.d.ts +50 -0
- package/dist/kernel/moleculer/broker-factory.d.ts +50 -0
- package/dist/kernel/moleculer/cap-usage-registry.d.ts +46 -0
- package/dist/kernel/moleculer/capabilities-access.d.ts +21 -0
- package/dist/kernel/moleculer/child-addon-call-dispatch.d.ts +46 -0
- package/dist/kernel/moleculer/child-cap-dispatch.d.ts +20 -0
- package/dist/kernel/moleculer/cluster-secret.d.ts +15 -0
- package/dist/kernel/moleculer/core-cap-service.d.ts +50 -0
- package/dist/kernel/moleculer/crash-supervisor.d.ts +50 -0
- package/dist/kernel/moleculer/device-cap-proxy.d.ts +79 -0
- package/dist/kernel/moleculer/event-bus-core.d.ts +53 -0
- package/dist/kernel/moleculer/event-bus.d.ts +53 -0
- package/dist/kernel/moleculer/hub-log-forwarder.d.ts +36 -0
- package/dist/kernel/moleculer/hub-service.d.ts +35 -0
- package/dist/kernel/moleculer/node-registry.d.ts +126 -0
- package/dist/kernel/moleculer/process-context.d.ts +4 -0
- package/dist/kernel/moleculer/process-service.d.ts +72 -0
- package/dist/kernel/moleculer/provider-registry.d.ts +28 -0
- package/dist/kernel/moleculer/readiness-context.d.ts +62 -0
- package/dist/kernel/moleculer/readiness-service.d.ts +7 -0
- package/dist/kernel/moleculer/register-node-client.d.ts +35 -0
- package/dist/kernel/moleculer/remote-logger.d.ts +43 -0
- package/dist/kernel/moleculer/resilient-cap-call.d.ts +28 -0
- package/dist/kernel/moleculer/stream-probe-service.d.ts +9 -0
- package/dist/kernel/moleculer/trpc-links.d.ts +189 -0
- package/dist/kernel/moleculer/typed-array-serde.d.ts +25 -0
- package/dist/kernel/moleculer/worker-device-restore.d.ts +10 -0
- package/dist/kernel/provider-kind-drift.d.ts +12 -0
- package/dist/kernel/restart-coordinator.d.ts +90 -0
- package/dist/kernel/storage-location-registry.d.ts +40 -0
- package/dist/kernel/transport/cap-action-name.d.ts +100 -0
- package/dist/kernel/transport/cap-route-resolver.d.ts +148 -0
- package/dist/kernel/transport/cap-route.d.ts +148 -0
- package/dist/kernel/transport/child-cap-protocol.d.ts +136 -0
- package/dist/kernel/transport/create-local-transport.d.ts +7 -0
- package/dist/kernel/transport/frame-codec.d.ts +7 -0
- package/dist/kernel/transport/index.d.ts +27 -0
- package/dist/kernel/transport/local-child-client.d.ts +136 -0
- package/dist/kernel/transport/local-child-registry.d.ts +179 -0
- package/dist/kernel/transport/local-endpoint-path.d.ts +6 -0
- package/dist/kernel/transport/local-transport.d.ts +46 -0
- package/dist/kernel/transport/parent-unowned-call.d.ts +75 -0
- package/dist/kernel/transport/socket-channel.d.ts +27 -0
- package/dist/kernel/transport/uds-event-bridge.d.ts +36 -0
- package/dist/kernel/transport/uds-event-bus.d.ts +22 -0
- package/dist/kernel/transport/uds-local-transport.d.ts +18 -0
- package/dist/kernel/transport/uds-log-ingest.d.ts +28 -0
- package/dist/kernel/transport/uds-logger.d.ts +44 -0
- package/dist/kernel/utils/ring-buffer.d.ts +15 -0
- package/dist/kernel/workspace-detect.d.ts +9 -0
- package/dist/lifecycle/lifecycle-state-machine.d.ts +28 -0
- package/dist/logging/formatter.d.ts +30 -0
- package/dist/logging/log-manager.d.ts +54 -0
- package/dist/logging/log-ring-buffer.d.ts +47 -0
- package/dist/logging/partitioned-log-buffer.d.ts +35 -0
- package/dist/logging/scoped-logger.d.ts +17 -0
- package/dist/main-DNnMW7Z2.js +9983 -0
- package/dist/main-rtjOwPBR.mjs +9976 -0
- package/dist/manifest-python-deps-D1DbAQEv.js +6724 -0
- package/dist/manifest-python-deps-DZsKTbs1.mjs +6315 -0
- package/dist/network/network-quality.d.ts +11 -0
- package/dist/notification/notification-service.d.ts +37 -0
- package/dist/notification/toast-service.d.ts +22 -0
- package/dist/pipeline/engine-manager-resolver.d.ts +15 -0
- package/dist/pipeline/pipeline-runner.d.ts +8 -0
- package/dist/pipeline/pipeline-validator.d.ts +13 -0
- package/dist/process/resource-monitor.d.ts +11 -0
- package/dist/python/python-env-manager.d.ts +12 -0
- package/dist/repl/interfaces.d.ts +31 -0
- package/dist/repl/repl-engine.d.ts +8 -0
- package/dist/resource-monitor-ClDGFyf6.mjs +57 -0
- package/dist/resource-monitor-IIEanuJt.js +74 -0
- package/dist/settle-sources-Bhsy57y-.js +38 -0
- package/dist/settle-sources-CDtNC8ub.mjs +33 -0
- package/dist/storage/fs-storage-backend.d.ts +40 -0
- package/dist/storage/storage-location-manager.d.ts +23 -0
- package/dist/storage/storage-manager.d.ts +83 -0
- package/dist/tar-BgAEMRBR.js +5434 -0
- package/dist/tar-ByMOPNM0.mjs +5429 -0
- package/dist/tls/cert-manager.d.ts +26 -0
- package/dist/tls/index.d.ts +1 -0
- package/package.json +343 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { StorageLocationDeclaration } from '@camstack/types';
|
|
2
|
+
/**
|
|
3
|
+
* Read-only view over all aggregated storage-location declarations.
|
|
4
|
+
*
|
|
5
|
+
* Built at kernel boot by {@link buildStorageLocationRegistry} from the
|
|
6
|
+
* `storageLocations` arrays declared in each installed addon's manifest.
|
|
7
|
+
*/
|
|
8
|
+
export interface StorageLocationRegistry {
|
|
9
|
+
/** Returns the declaration for `id`, or `undefined` if not declared. */
|
|
10
|
+
get(id: string): StorageLocationDeclaration | undefined;
|
|
11
|
+
/** Returns `true` when at least one addon declared `id`. */
|
|
12
|
+
has(id: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the cardinality of `id`, or `null` when no addon declared it.
|
|
15
|
+
* Convenience shortcut over `get(id)?.cardinality`.
|
|
16
|
+
*/
|
|
17
|
+
cardinalityOf(id: string): 'single' | 'multi' | null;
|
|
18
|
+
/**
|
|
19
|
+
* Stable, immutable list of all aggregated declarations (insertion order of
|
|
20
|
+
* first occurrence per `id`).
|
|
21
|
+
*/
|
|
22
|
+
list(): readonly StorageLocationDeclaration[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Aggregates per-addon {@link StorageLocationDeclaration} arrays into a single
|
|
26
|
+
* {@link StorageLocationRegistry}.
|
|
27
|
+
*
|
|
28
|
+
* Merge rules:
|
|
29
|
+
* - Declarations are keyed by `id`; iteration order follows first occurrence.
|
|
30
|
+
* - **First declarer wins** for metadata (`displayName`, `description`,
|
|
31
|
+
* `defaultsTo`): if a later addon declares the same `id`, its metadata is
|
|
32
|
+
* silently ignored.
|
|
33
|
+
* - **Cardinality conflict throws**: if two addons declare the same `id` with
|
|
34
|
+
* different `cardinality` values an `Error` is thrown immediately (message
|
|
35
|
+
* contains the words "cardinality" and the conflicting `id`).
|
|
36
|
+
*
|
|
37
|
+
* @param perAddon - One entry per addon; each entry is that addon's
|
|
38
|
+
* `storageLocations` declaration array.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildStorageLocationRegistry(perAddon: readonly (readonly StorageLocationDeclaration[])[]): StorageLocationRegistry;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cap-action-name.ts — single source of truth for Moleculer cap
|
|
3
|
+
* action/service naming conventions.
|
|
4
|
+
*
|
|
5
|
+
* Moleculer service / action naming rules
|
|
6
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
7
|
+
* System (manifest) cap:
|
|
8
|
+
* service : `${addonId}.${capName}` (service `name` field)
|
|
9
|
+
* action : `${capName}.${method}` (registered INSIDE the service)
|
|
10
|
+
* full key : `${addonId}.${capName}.${method}` (broker.call key)
|
|
11
|
+
*
|
|
12
|
+
* Native (device-scoped) cap:
|
|
13
|
+
* service : `${addonId}${NATIVE_PROVIDER_SERVICE_INFIX}.${capName}`
|
|
14
|
+
* action : `${method}` (registered INSIDE the service)
|
|
15
|
+
* also aliased as `${capName}.${method}` for bridge discovery
|
|
16
|
+
* full key : `${addonId}${NATIVE_PROVIDER_SERVICE_INFIX}.${capName}.${method}`
|
|
17
|
+
*
|
|
18
|
+
* Registry-scan helpers:
|
|
19
|
+
* suffix : `.${capName}.${method}` — trailing match against a full action key
|
|
20
|
+
* bare : `${capName}.${method}` — the action key as registered by
|
|
21
|
+
* addon-service-factory (without the service-name prefix)
|
|
22
|
+
*
|
|
23
|
+
* Parse helper:
|
|
24
|
+
* parseCapAction(action) → { addonId, capName, method, native }
|
|
25
|
+
* Inverse of capActionName / capServiceName + ".${method}".
|
|
26
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
27
|
+
*
|
|
28
|
+
* All five construction sites that previously built these strings inline now
|
|
29
|
+
* import from here instead:
|
|
30
|
+
* 1. packages/kernel/src/transport/cap-route-resolver.ts (remote dispatch)
|
|
31
|
+
* 2. packages/kernel/src/moleculer/trpc-links.ts (findServiceCandidates + brokerTransportLink)
|
|
32
|
+
* 3. packages/kernel/src/moleculer/addon-service-factory.ts (service action registration)
|
|
33
|
+
* 4. packages/kernel/src/moleculer/device-cap-proxy.ts (native service/proxy)
|
|
34
|
+
* 5. server/backend/src/core/moleculer/moleculer.service.ts (legacy callFn fallback)
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Infix segment that separates the addonId from the capName in the Moleculer
|
|
38
|
+
* service name for device-scoped NATIVE capability providers.
|
|
39
|
+
*
|
|
40
|
+
* Native service name : `${addonId}${NATIVE_PROVIDER_SERVICE_INFIX}.${capName}`
|
|
41
|
+
* System service name : `${addonId}.${capName}` (no infix)
|
|
42
|
+
*/
|
|
43
|
+
export declare const NATIVE_PROVIDER_SERVICE_INFIX: ".native-provider";
|
|
44
|
+
/**
|
|
45
|
+
* Build the Moleculer SERVICE name for a cap provider.
|
|
46
|
+
*
|
|
47
|
+
* System cap : `${addonId}.${capName}`
|
|
48
|
+
* Native cap : `${addonId}${NATIVE_PROVIDER_SERVICE_INFIX}.${capName}`
|
|
49
|
+
*/
|
|
50
|
+
export declare function capServiceName(addonId: string, capName: string, native: boolean): string;
|
|
51
|
+
/**
|
|
52
|
+
* Build the full Moleculer ACTION key (broker.call key) for a cap method.
|
|
53
|
+
*
|
|
54
|
+
* System cap : `${addonId}.${capName}.${method}`
|
|
55
|
+
* Native cap : `${addonId}${NATIVE_PROVIDER_SERVICE_INFIX}.${capName}.${method}`
|
|
56
|
+
*/
|
|
57
|
+
export declare function capActionName(addonId: string, capName: string, method: string, native: boolean): string;
|
|
58
|
+
/**
|
|
59
|
+
* Build the trailing SUFFIX used to scan the Moleculer service registry for
|
|
60
|
+
* any service that exposes a given (capName, method) pair.
|
|
61
|
+
*
|
|
62
|
+
* The suffix `.${capName}.${method}` is compared against full action keys via
|
|
63
|
+
* `action.endsWith(suffix)` in `findServiceCandidates` (trpc-links.ts).
|
|
64
|
+
*/
|
|
65
|
+
export declare function capActionSuffix(capName: string, method: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Build the BARE action name — the key under which addon-service-factory
|
|
68
|
+
* registers the action WITHIN a service (i.e. without the addonId prefix).
|
|
69
|
+
*
|
|
70
|
+
* The full broker key is `${addonId}.${bareAction}` for system caps, but the
|
|
71
|
+
* registry scan checks for `bareAction` directly (`a === bareAction`) to catch
|
|
72
|
+
* the case where the service name itself IS the capName (e.g. stream-broker
|
|
73
|
+
* registering `camera-streams.getRtspEntries`).
|
|
74
|
+
*/
|
|
75
|
+
export declare function capBareAction(capName: string, method: string): string;
|
|
76
|
+
/** Result of parsing a full Moleculer action key. */
|
|
77
|
+
export interface ParsedCapAction {
|
|
78
|
+
readonly addonId: string;
|
|
79
|
+
readonly capName: string;
|
|
80
|
+
readonly method: string;
|
|
81
|
+
readonly native: boolean;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Parse a full Moleculer action key back into its constituent parts.
|
|
85
|
+
*
|
|
86
|
+
* Handles both forms:
|
|
87
|
+
* system : `${addonId}.${capName}.${method}`
|
|
88
|
+
* (splits on first and last dot; 3 segments minimum)
|
|
89
|
+
* native : `${addonId}${NATIVE_PROVIDER_SERVICE_INFIX}.${capName}.${method}`
|
|
90
|
+
* (NATIVE_PROVIDER_SERVICE_INFIX = `.native-provider`, so the raw
|
|
91
|
+
* action has the form `${addonId}.native-provider.${capName}.${method}`)
|
|
92
|
+
*
|
|
93
|
+
* Returns `null` when the action string cannot be parsed into at least 3
|
|
94
|
+
* dot-separated segments.
|
|
95
|
+
*
|
|
96
|
+
* **Parse semantics** — exact inverse of `capActionName`:
|
|
97
|
+
* capActionName(a, c, m, native) → action
|
|
98
|
+
* parseCapAction(action) → { addonId: a, capName: c, method: m, native }
|
|
99
|
+
*/
|
|
100
|
+
export declare function parseCapAction(action: string): ParsedCapAction | null;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { CapCallInput } from './child-cap-protocol.js';
|
|
2
|
+
import { ServiceDiscoveryBroker } from '../moleculer/resilient-cap-call.js';
|
|
3
|
+
import { CapRoute, CapRouteOpts, HubLocalUdsRoute, InProcessProviderRef } from './cap-route.js';
|
|
4
|
+
/**
|
|
5
|
+
* Minimal surface of LocalChildRegistry that the resolver needs.
|
|
6
|
+
* Keeping a narrow interface here prevents the resolver from depending on the
|
|
7
|
+
* full LocalChildRegistry class and avoids `as unknown as` casts in tests.
|
|
8
|
+
* The real `LocalChildRegistry` structurally satisfies this interface.
|
|
9
|
+
*/
|
|
10
|
+
export interface HubLocalChildDispatcher {
|
|
11
|
+
/** Returns the childId that provides the cap, or null. */
|
|
12
|
+
resolveChildId(capName: string, deviceId?: number): string | null;
|
|
13
|
+
/** Forwards a cap call to a specific child by id. */
|
|
14
|
+
callCapOnChild(childId: string, input: CapCallInput): Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Minimal view of the cluster node registry needed to build a CapRouteSnapshot.
|
|
18
|
+
* The concrete implementation (HubNodeRegistry) lives in server/backend and is
|
|
19
|
+
* wired in by Task 4/5. Keeping this interface in kernel prevents a layering
|
|
20
|
+
* inversion.
|
|
21
|
+
*/
|
|
22
|
+
export interface NodeCapAuthority {
|
|
23
|
+
/** Returns true if the given node's latest manifest includes the given cap. */
|
|
24
|
+
nodeKnowsCap(nodeId: string, capName: string): boolean;
|
|
25
|
+
/** Returns true if the given nodeId is an agent (bare id, no '/' separator). */
|
|
26
|
+
nodeIsAgent(nodeId: string): boolean;
|
|
27
|
+
/** Returns true if the given node is currently connected/online. */
|
|
28
|
+
nodeOnline(nodeId: string): boolean;
|
|
29
|
+
/** Returns all nodeIds currently in the registry. */
|
|
30
|
+
listNodeIds(): readonly string[];
|
|
31
|
+
/**
|
|
32
|
+
* Returns the addonId for the provider that registered (nodeId, capName).
|
|
33
|
+
* Used to build the Moleculer action `${addonId}.${capName}.${method}`.
|
|
34
|
+
* Returns null when the node does not host the cap (should not happen if
|
|
35
|
+
* nodeKnowsCap is true, but guard defensively).
|
|
36
|
+
*/
|
|
37
|
+
getAddonId(nodeId: string, capName: string): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the childId (runner id) of the agent's UDS child that provides
|
|
40
|
+
* the given cap. Only meaningful when nodeIsAgent(nodeId) is true.
|
|
41
|
+
* Returns null when unknown.
|
|
42
|
+
*/
|
|
43
|
+
getAgentChildId(agentNodeId: string, capName: string): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Returns true if the (nodeId, capName, deviceId?) tuple is a device-scoped
|
|
46
|
+
* NATIVE cap (vs. a system/manifest cap). When true, the remote-moleculer
|
|
47
|
+
* dispatcher uses `capActionName(addonId, cap, method, true)` which expands to
|
|
48
|
+
* `${addonId}.native-provider.${cap}.${method}` instead of the plain system-cap
|
|
49
|
+
* action `${addonId}.${cap}.${method}`.
|
|
50
|
+
* Implementations that do not track native caps should return false.
|
|
51
|
+
*/
|
|
52
|
+
isNativeCap(nodeId: string, capName: string, deviceId?: number): boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Injected lookup for providers that live in the hub host process.
|
|
56
|
+
* Returns a ready-to-invoke InProcessProviderRef, or null if the cap is not
|
|
57
|
+
* hosted in-process.
|
|
58
|
+
*/
|
|
59
|
+
export type InProcessProviderLookup = (capName: string) => InProcessProviderRef | null;
|
|
60
|
+
export interface CapRouteResolverDeps {
|
|
61
|
+
/** The hub's own Moleculer nodeId (e.g. `'hub'`). */
|
|
62
|
+
readonly hubNodeId: string;
|
|
63
|
+
/**
|
|
64
|
+
* Minimal Moleculer broker surface: `call` + `waitForServices`.
|
|
65
|
+
* Used for remote-moleculer and agent-child-forward dispatches.
|
|
66
|
+
*/
|
|
67
|
+
readonly broker: ServiceDiscoveryBroker;
|
|
68
|
+
/**
|
|
69
|
+
* Local UDS child dispatcher — routes hub-local-uds dispatches.
|
|
70
|
+
* May be null when the UDS server failed to start.
|
|
71
|
+
*/
|
|
72
|
+
readonly hubLocalRegistry: HubLocalChildDispatcher | null;
|
|
73
|
+
/**
|
|
74
|
+
* Authority over which nodes are online and which caps they know.
|
|
75
|
+
* Decouples the resolver from the concrete HubNodeRegistry class.
|
|
76
|
+
*/
|
|
77
|
+
readonly nodeAuthority: NodeCapAuthority;
|
|
78
|
+
/**
|
|
79
|
+
* Lookup for hub-in-process providers.
|
|
80
|
+
* Decouples the resolver from CapabilityRegistry.
|
|
81
|
+
*/
|
|
82
|
+
readonly inProcessProviders: InProcessProviderLookup;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Params envelope sent to the agent's `$agent-cap-fwd.forward` Moleculer action.
|
|
86
|
+
*
|
|
87
|
+
* Task 6 MUST register a Moleculer service named `$agent-cap-fwd` with an
|
|
88
|
+
* action `forward` that receives this payload, resolves `childId` in its own
|
|
89
|
+
* LocalChildRegistry, and dispatches over UDS to that child.
|
|
90
|
+
*/
|
|
91
|
+
export interface AgentCapForwardParams {
|
|
92
|
+
readonly capName: string;
|
|
93
|
+
readonly method: string;
|
|
94
|
+
readonly args: unknown;
|
|
95
|
+
/**
|
|
96
|
+
* Optional: the hub cannot resolve which forked child under the agent provides the cap.
|
|
97
|
+
* The agent resolves its own child locally (Task 6). Present when the hub authority
|
|
98
|
+
* happens to know it, absent (undefined) when not.
|
|
99
|
+
*/
|
|
100
|
+
readonly childId?: string;
|
|
101
|
+
readonly deviceId?: number;
|
|
102
|
+
}
|
|
103
|
+
/** The Moleculer service name that Task 6's agent registers. */
|
|
104
|
+
export declare const AGENT_CAP_FWD_SERVICE: "$agent-cap-fwd";
|
|
105
|
+
/** The Moleculer action (service.action) for agent cap forwarding. */
|
|
106
|
+
export declare const AGENT_CAP_FWD_ACTION: "$agent-cap-fwd.forward";
|
|
107
|
+
export declare function extractDeviceId(args: unknown): number | undefined;
|
|
108
|
+
export declare class CapRouteResolver {
|
|
109
|
+
private readonly hubNodeId;
|
|
110
|
+
private readonly broker;
|
|
111
|
+
private readonly hubLocalRegistry;
|
|
112
|
+
private readonly nodeAuthority;
|
|
113
|
+
private readonly inProcessProviders;
|
|
114
|
+
private readonly snapshot;
|
|
115
|
+
constructor(deps: CapRouteResolverDeps);
|
|
116
|
+
resolveCapRoute(capName: string, opts: CapRouteOpts): CapRoute;
|
|
117
|
+
/**
|
|
118
|
+
* Resolve the hub-local-uds route for a cap owned by a forked hub-local
|
|
119
|
+
* child, IGNORING any in-hub provider registered for the same cap name.
|
|
120
|
+
*
|
|
121
|
+
* `resolveCapRoute` gives Priority 1 to `hub-in-process`: when an in-hub
|
|
122
|
+
* provider (e.g. a wrapper) is registered for the cap, the route always
|
|
123
|
+
* classifies as `hub-in-process` and the hub-local-uds NATIVE child is never
|
|
124
|
+
* reached. That is correct for the generic dispatch path (the wrapper is the
|
|
125
|
+
* active provider), but WRONG for the native-cap fallback
|
|
126
|
+
* (`setNativeFallback`), whose contract is to reach the NATIVE provider in
|
|
127
|
+
* the forked vendor child so a wrapper can delegate to it. A wrapper cap
|
|
128
|
+
* with a forked native (today: `snapshot`) otherwise resolves to the wrapper
|
|
129
|
+
* itself, the native is never invoked, and the wrapper silently falls
|
|
130
|
+
* through to its secondary strategy.
|
|
131
|
+
*
|
|
132
|
+
* This method consults ONLY the hub-local-child authority
|
|
133
|
+
* (`hubLocalChildProvides` + `getHubLocalChildId`, both deviceId-aware), so
|
|
134
|
+
* it returns the native child route regardless of any in-process shadow.
|
|
135
|
+
* Returns null when no hub-local child owns `(capName, deviceId)` — the
|
|
136
|
+
* caller then falls through to its remote-resolution branch.
|
|
137
|
+
*/
|
|
138
|
+
resolveHubLocalUdsRoute(capName: string, deviceId?: number): HubLocalUdsRoute | null;
|
|
139
|
+
dispatch(route: CapRoute, method: string, args: unknown): Promise<unknown>;
|
|
140
|
+
/**
|
|
141
|
+
* Inner dispatch: may throw CapRouteError (validation failures) or arbitrary
|
|
142
|
+
* transport errors. The outer `dispatch` wraps non-CapRouteErrors.
|
|
143
|
+
*/
|
|
144
|
+
private dispatchInner;
|
|
145
|
+
private buildSnapshot;
|
|
146
|
+
/** Extract a nodeId string from a route for error reporting, or undefined. */
|
|
147
|
+
private routeNodeId;
|
|
148
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminated union describing HOW a capName call should be dispatched.
|
|
3
|
+
* Every variant carries `capName` so a resolved route is a self-contained
|
|
4
|
+
* dispatch descriptor. `method` is a dispatch-time concern supplied separately
|
|
5
|
+
* to the dispatcher — it does not belong on the route.
|
|
6
|
+
*
|
|
7
|
+
* This file is intentionally import-free — no broker/registry deps — so it can
|
|
8
|
+
* be imported from both the hub and agent without pulling the full kernel graph.
|
|
9
|
+
*/
|
|
10
|
+
export interface CapRouteBase {
|
|
11
|
+
readonly capName: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A typed thunk that invokes a method on a provider that lives in the current
|
|
15
|
+
* process. Using an invoker thunk instead of a raw `object` avoids `as`-casts
|
|
16
|
+
* at every dispatch site: the resolver builds the thunk once (knowing the
|
|
17
|
+
* provider's concrete type), and every consumer calls `ref.invoke(method, args)`
|
|
18
|
+
* without any type assertion.
|
|
19
|
+
*/
|
|
20
|
+
export type CapInvoker = (method: string, args: unknown) => Promise<unknown>;
|
|
21
|
+
export interface InProcessProviderRef {
|
|
22
|
+
readonly invoke: CapInvoker;
|
|
23
|
+
}
|
|
24
|
+
export interface HubInProcessRoute extends CapRouteBase {
|
|
25
|
+
readonly kind: 'hub-in-process';
|
|
26
|
+
readonly ref: InProcessProviderRef;
|
|
27
|
+
}
|
|
28
|
+
export interface HubLocalUdsRoute extends CapRouteBase {
|
|
29
|
+
readonly kind: 'hub-local-uds';
|
|
30
|
+
readonly childId: string;
|
|
31
|
+
}
|
|
32
|
+
export interface RemoteMoleculerRoute extends CapRouteBase {
|
|
33
|
+
readonly kind: 'remote-moleculer';
|
|
34
|
+
readonly nodeId: string;
|
|
35
|
+
}
|
|
36
|
+
export interface AgentChildForwardRoute extends CapRouteBase {
|
|
37
|
+
readonly kind: 'agent-child-forward';
|
|
38
|
+
readonly agentNodeId: string;
|
|
39
|
+
/** Optional: the hub cannot resolve which forked child under an agent provides the cap.
|
|
40
|
+
* The agent resolves its own child locally (Task 6). */
|
|
41
|
+
readonly childId?: string;
|
|
42
|
+
}
|
|
43
|
+
export type CapRoute = HubInProcessRoute | HubLocalUdsRoute | RemoteMoleculerRoute | AgentChildForwardRoute;
|
|
44
|
+
export type CapRouteReason = 'no-provider' | 'node-offline' | 'cap-unknown' | 'transport-failed';
|
|
45
|
+
export interface RejectedRoute {
|
|
46
|
+
readonly kind: string;
|
|
47
|
+
readonly why: string;
|
|
48
|
+
}
|
|
49
|
+
export interface CapRouteErrorDetail {
|
|
50
|
+
readonly reason: CapRouteReason;
|
|
51
|
+
readonly nodeId?: string;
|
|
52
|
+
readonly rejected: readonly RejectedRoute[];
|
|
53
|
+
}
|
|
54
|
+
export declare class CapRouteError extends Error {
|
|
55
|
+
readonly reason: CapRouteReason;
|
|
56
|
+
readonly nodeId: string | undefined;
|
|
57
|
+
readonly rejected: readonly RejectedRoute[];
|
|
58
|
+
/**
|
|
59
|
+
* @param cause Optional original error that triggered this routing failure.
|
|
60
|
+
* Stored as `Error.cause` (TC39 standard option, Node 16.9+).
|
|
61
|
+
* Dispatchers wrapping transport errors MUST pass the original.
|
|
62
|
+
*/
|
|
63
|
+
constructor(capName: string, method: string | undefined, detail: CapRouteErrorDetail, cause?: Error);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A read-only snapshot of the registry state needed to classify a route.
|
|
67
|
+
* All fields are predicates or accessors — no live broker/registry deps.
|
|
68
|
+
*
|
|
69
|
+
* `getInProcessProviderRef` is OPTIONAL: the plan's table-driven test literal
|
|
70
|
+
* omits it because none of the 4 plan cases hit the hub-in-process branch.
|
|
71
|
+
* When present, the function calls it; when absent (or returns null), the
|
|
72
|
+
* hub-in-process branch falls through to a `no-provider` CapRouteError instead
|
|
73
|
+
* of using an unsafe cast. This keeps the union type-safe without casts.
|
|
74
|
+
*
|
|
75
|
+
* `listKnownNodeIds` is OPTIONAL: used for singleton resolution (no nodeId
|
|
76
|
+
* given) to find a remote node that knows the cap. When absent, remote
|
|
77
|
+
* singleton resolution is skipped (no remote-moleculer route for singletons).
|
|
78
|
+
*
|
|
79
|
+
* `getHubLocalChildId` is OPTIONAL: resolves the runner childId of the
|
|
80
|
+
* hub-local child that provides this cap. When absent or returns null, the
|
|
81
|
+
* hub-local-uds branch falls through to a `no-provider` CapRouteError.
|
|
82
|
+
*
|
|
83
|
+
* `getAgentChildId` is OPTIONAL: resolves the runner childId of the agent's
|
|
84
|
+
* child that provides this cap. When absent or returns null, the
|
|
85
|
+
* agent-child-forward branch falls through to a `no-provider` CapRouteError.
|
|
86
|
+
*/
|
|
87
|
+
export interface CapRouteSnapshot {
|
|
88
|
+
/** The nodeId that represents the hub itself in the mesh. */
|
|
89
|
+
readonly hubNodeId: string;
|
|
90
|
+
/**
|
|
91
|
+
* Returns true if a hub-local UDS child process provides this cap.
|
|
92
|
+
* The optional `deviceId` is a routing hint for device-scoped native caps:
|
|
93
|
+
* a child that owns only a specific device's cap will match on (capName, deviceId)
|
|
94
|
+
* while a singleton provider (no deviceId on the descriptor) matches on capName alone.
|
|
95
|
+
*/
|
|
96
|
+
readonly hubLocalChildProvides: (cap: string, deviceId?: number) => boolean;
|
|
97
|
+
/** Returns true if the hub host process provides this cap in-process. */
|
|
98
|
+
readonly hubInProcessProvides: (cap: string) => boolean;
|
|
99
|
+
/** Returns true if the given node knows (registers) the given cap. */
|
|
100
|
+
readonly nodeKnowsCap: (nodeId: string, cap: string) => boolean;
|
|
101
|
+
/** Returns true if the given nodeId is an agent node (not a hub-local child). */
|
|
102
|
+
readonly nodeIsAgent: (nodeId: string) => boolean;
|
|
103
|
+
/** Returns true if the given node is currently online/reachable. */
|
|
104
|
+
readonly nodeOnline: (nodeId: string) => boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Optional: resolves a concrete InProcessProviderRef for an in-process cap.
|
|
107
|
+
* Required to actually produce a HubInProcessRoute. When absent or returns
|
|
108
|
+
* null, classifyCapRoute throws no-provider rather than casting.
|
|
109
|
+
*/
|
|
110
|
+
readonly getInProcessProviderRef?: (cap: string) => InProcessProviderRef | null;
|
|
111
|
+
/**
|
|
112
|
+
* Optional: enumerates all known remote nodeIds for singleton cap resolution
|
|
113
|
+
* (the case where no explicit nodeId is given by the caller).
|
|
114
|
+
*/
|
|
115
|
+
readonly listKnownNodeIds?: () => readonly string[];
|
|
116
|
+
/**
|
|
117
|
+
* Optional: resolves the runner childId of the hub-local child that provides this cap.
|
|
118
|
+
* The optional `deviceId` is a routing hint for device-scoped native caps (same semantics
|
|
119
|
+
* as `hubLocalChildProvides`).
|
|
120
|
+
*/
|
|
121
|
+
readonly getHubLocalChildId?: (cap: string, deviceId?: number) => string | null;
|
|
122
|
+
/** Optional: resolves the runner childId of the agent's child that provides this cap. */
|
|
123
|
+
readonly getAgentChildId?: (agentNodeId: string, cap: string) => string | null;
|
|
124
|
+
}
|
|
125
|
+
export interface CapRouteOpts {
|
|
126
|
+
readonly nodeId?: string;
|
|
127
|
+
/** Numeric device id — a routing hint for device-scoped native caps. */
|
|
128
|
+
readonly deviceId?: number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Classifies a (capName, opts) pair into a typed CapRoute dispatch descriptor.
|
|
132
|
+
*
|
|
133
|
+
* Precedence (explicit nodeId path):
|
|
134
|
+
* 1. hub-in-process — hub node + hubInProcessProvides
|
|
135
|
+
* 2. hub-local-uds — hub node + hubLocalChildProvides
|
|
136
|
+
* 3. node-offline → CapRouteError{reason:'node-offline'}
|
|
137
|
+
* 4. agent-child-forward — node is an agent AND nodeKnowsCap
|
|
138
|
+
* 5. remote-moleculer — any other online non-agent node
|
|
139
|
+
*
|
|
140
|
+
* Singleton path (no nodeId):
|
|
141
|
+
* 1. hub-in-process (hub provides in-process)
|
|
142
|
+
* 2. hub-local-uds (a hub-local UDS child provides it)
|
|
143
|
+
* 3. remote-moleculer (any online, non-hub node that knows it)
|
|
144
|
+
* 4. → CapRouteError{reason:'no-provider', rejected: all considered routes}
|
|
145
|
+
*
|
|
146
|
+
* PURE: no side effects, no async, no broker/registry imports.
|
|
147
|
+
*/
|
|
148
|
+
export declare function classifyCapRoute(capName: string, opts: CapRouteOpts, snapshot: CapRouteSnapshot): CapRoute;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { SystemEvent, IReadinessRegistryRecord, LogLevel, LogTags } from '@camstack/types';
|
|
2
|
+
/**
|
|
3
|
+
* Routing descriptor a child sends so the parent can route cap calls to it.
|
|
4
|
+
* The provider implementation never crosses the wire — only these keys do.
|
|
5
|
+
*/
|
|
6
|
+
export interface ChildCapDescriptor {
|
|
7
|
+
readonly capName: string;
|
|
8
|
+
/** Cap mode. Carried for the future cluster-exposure layer (agent-as-proxy); the local registry routes only on capName + deviceId. */
|
|
9
|
+
readonly mode: 'singleton' | 'collection';
|
|
10
|
+
/** Present for device-scoped caps; absent for singleton/system caps. */
|
|
11
|
+
readonly deviceId?: number;
|
|
12
|
+
}
|
|
13
|
+
/** First message a child sends after connecting — its complete cap manifest. */
|
|
14
|
+
export interface RegisterMessage {
|
|
15
|
+
readonly kind: 'register';
|
|
16
|
+
readonly childId: string;
|
|
17
|
+
readonly caps: readonly ChildCapDescriptor[];
|
|
18
|
+
}
|
|
19
|
+
/** Child → parent outbound cap invocation — the child asks the parent to route a cap call it does not own. */
|
|
20
|
+
export interface CapCallOutMessage {
|
|
21
|
+
readonly kind: 'cap-call-out';
|
|
22
|
+
readonly capName: string;
|
|
23
|
+
readonly method: string;
|
|
24
|
+
readonly args: unknown;
|
|
25
|
+
readonly deviceId?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Child → parent: a system event produced by the child to be forwarded to the hub event bus. */
|
|
28
|
+
export interface ChildEventMessage {
|
|
29
|
+
readonly kind: 'event';
|
|
30
|
+
readonly event: SystemEvent;
|
|
31
|
+
}
|
|
32
|
+
/** Child → parent: a structured log entry emitted by the child process. */
|
|
33
|
+
export interface ChildLogMessage {
|
|
34
|
+
readonly kind: 'log';
|
|
35
|
+
readonly level: LogLevel;
|
|
36
|
+
readonly message: string;
|
|
37
|
+
readonly addonId: string;
|
|
38
|
+
readonly nodeId?: string;
|
|
39
|
+
readonly scope?: string;
|
|
40
|
+
readonly tags?: LogTags;
|
|
41
|
+
readonly meta?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
/** Child → parent: request for the current readiness snapshot (all known records). */
|
|
44
|
+
export interface ReadinessSnapshotRequest {
|
|
45
|
+
readonly kind: 'readiness-request';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Child → parent message bodies.
|
|
49
|
+
* `RegisterMessage`, `CapCallOutMessage`, and `ReadinessSnapshotRequest` travel
|
|
50
|
+
* as correlated request frames (`channel.request`) and carry a response.
|
|
51
|
+
* `ChildEventMessage` and `ChildLogMessage` are sent fire-and-forget via
|
|
52
|
+
* `channel.emit()` and do NOT carry a response.
|
|
53
|
+
*/
|
|
54
|
+
export type ChildToParentRequest = RegisterMessage | CapCallOutMessage | ChildEventMessage | ChildLogMessage | ReadinessSnapshotRequest;
|
|
55
|
+
/** Parent → child cap invocation. */
|
|
56
|
+
export interface CapCallMessage {
|
|
57
|
+
readonly kind: 'cap-call';
|
|
58
|
+
readonly capName: string;
|
|
59
|
+
readonly method: string;
|
|
60
|
+
readonly args: unknown;
|
|
61
|
+
readonly deviceId?: number;
|
|
62
|
+
}
|
|
63
|
+
/** Parent → child: a system event delivered by the hub for the child to handle locally. */
|
|
64
|
+
export interface ParentEventMessage {
|
|
65
|
+
readonly kind: 'event';
|
|
66
|
+
readonly event: SystemEvent;
|
|
67
|
+
/** Moleculer node ID of the hub or agent that forwarded this event. */
|
|
68
|
+
readonly sourceNodeId: string;
|
|
69
|
+
}
|
|
70
|
+
/** Parent → child: authoritative readiness snapshot in response to a `readiness-request`. */
|
|
71
|
+
export interface ReadinessSnapshotResponse {
|
|
72
|
+
readonly kind: 'readiness-snapshot';
|
|
73
|
+
readonly records: readonly IReadinessRegistryRecord[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The exhaustive set of ADDON-LEVEL surfaces carried over the UDS addon-call
|
|
77
|
+
* plane — i.e. everything the removed per-addon Moleculer broker used to carry
|
|
78
|
+
* besides cap methods. THIS UNION IS THE SINGLE SOURCE OF TRUTH: every such
|
|
79
|
+
* surface MUST appear here AND be handled by `createChildAddonCallDispatch`'s
|
|
80
|
+
* exhaustive switch (a `never` check fails the build if one is added here but
|
|
81
|
+
* not dispatched, or hub-side routing is added without a target). Routes +
|
|
82
|
+
* custom-actions were ported in the UDS migration; `settings` was MISSED for
|
|
83
|
+
* months because it lived on a separate Moleculer path — adding it here makes
|
|
84
|
+
* that class of "missed link" a compile error from now on.
|
|
85
|
+
*
|
|
86
|
+
* `AddonCallTarget` values:
|
|
87
|
+
* - `routes` → the addon's `addon-routes` provider `getRoutes()` (handlers
|
|
88
|
+
* STRIPPED — MsgPack can't encode functions; the hub re-binds via `invoke`).
|
|
89
|
+
* - `custom` → the addon's custom-action handler (`action` + `args`).
|
|
90
|
+
* - `settings` → the addon's global/device settings methods (`method` names
|
|
91
|
+
* the entry; `args` carries the params). Mirrors the removed
|
|
92
|
+
* `<addonId>.settings.<method>` Moleculer action.
|
|
93
|
+
* - `data-planes` → the addon's live HTTP data-plane endpoints
|
|
94
|
+
* (`{prefix, access, baseUrl, secret}[]`), pulled when the hub mounts the
|
|
95
|
+
* addon so it can set up its reverse-proxy. Mirrors `routes`.
|
|
96
|
+
*/
|
|
97
|
+
export type AddonCallTarget = 'routes' | 'custom' | 'settings' | 'data-planes';
|
|
98
|
+
/** The four addon-settings methods reachable over the addon-call plane. */
|
|
99
|
+
export type AddonSettingsMethod = 'getGlobalSettings' | 'updateGlobalSettings' | 'getDeviceSettings' | 'updateDeviceSettings';
|
|
100
|
+
/**
|
|
101
|
+
* Parent → child: invoke an ADDON-LEVEL method on a loaded addon (not a cap).
|
|
102
|
+
* Carried as a correlated request frame (`channel.request`) — it returns a
|
|
103
|
+
* value (route descriptors, the custom-action result, or the settings schema /
|
|
104
|
+
* update ack). See {@link AddonCallTarget} for the exhaustive surface list.
|
|
105
|
+
*/
|
|
106
|
+
export interface AddonCallMessage {
|
|
107
|
+
readonly kind: 'addon-call';
|
|
108
|
+
readonly addonId: string;
|
|
109
|
+
readonly target: AddonCallTarget;
|
|
110
|
+
/** Required when `target === 'custom'` — the custom-action name. */
|
|
111
|
+
readonly action?: string;
|
|
112
|
+
/** Required when `target === 'settings'` — which settings method to invoke. */
|
|
113
|
+
readonly method?: AddonSettingsMethod;
|
|
114
|
+
/** Custom-action / settings input (already validated by the hub). */
|
|
115
|
+
readonly args?: unknown;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Parent → child: request to change the child's Moleculer log level.
|
|
119
|
+
* Fire-and-forget (sent via `channel.emit` — no response expected).
|
|
120
|
+
* Mirrors the `$node-mgmt.setLogLevel` Moleculer action for UDS children.
|
|
121
|
+
*/
|
|
122
|
+
export interface SetLogLevelMessage {
|
|
123
|
+
readonly kind: 'set-log-level';
|
|
124
|
+
readonly level: string;
|
|
125
|
+
}
|
|
126
|
+
/** Parent → child request bodies. */
|
|
127
|
+
export type ParentToChildRequest = CapCallMessage | ParentEventMessage | ReadinessSnapshotResponse | SetLogLevelMessage | AddonCallMessage;
|
|
128
|
+
/** Public view of a registered child (no channel handle). */
|
|
129
|
+
export interface RegisteredChild {
|
|
130
|
+
readonly childId: string;
|
|
131
|
+
readonly caps: readonly ChildCapDescriptor[];
|
|
132
|
+
}
|
|
133
|
+
/** Arguments to route a cap method call (the `cap-call` message minus its discriminant). */
|
|
134
|
+
export type CapCallInput = Omit<CapCallMessage, 'kind'>;
|
|
135
|
+
/** Arguments to route an addon-level call (the `addon-call` message minus its discriminant). */
|
|
136
|
+
export type AddonCallInput = Omit<AddonCallMessage, 'kind'>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LocalTransportFactory } from './local-transport.js';
|
|
2
|
+
/**
|
|
3
|
+
* The extension seam. UDS is the only shipped implementation; a future
|
|
4
|
+
* transport implements `LocalTransportFactory` and is selected here (e.g. via
|
|
5
|
+
* a `CAMSTACK_LOCAL_TRANSPORT` env) without touching any consumer.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createLocalTransport(): LocalTransportFactory;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Encode a value as a length-prefixed (4-byte big-endian) MsgPack frame. */
|
|
2
|
+
export declare function encodeFrame(value: unknown): Buffer;
|
|
3
|
+
/** Reassembles length-prefixed MsgPack frames from a byte stream. */
|
|
4
|
+
export declare class FrameDecoder {
|
|
5
|
+
private buf;
|
|
6
|
+
push(chunk: Buffer): unknown[];
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type { Frame, RequestHandler, EventHandler, LocalChannel, LocalTransportServer, LocalTransportClient, LocalTransportFactory, } from './local-transport.js';
|
|
2
|
+
export { encodeFrame, FrameDecoder } from './frame-codec.js';
|
|
3
|
+
export { localEndpointPath } from './local-endpoint-path.js';
|
|
4
|
+
export { SocketChannel } from './socket-channel.js';
|
|
5
|
+
export { UdsLocalTransportServer, UdsLocalTransportClient } from './uds-local-transport.js';
|
|
6
|
+
export { createLocalTransport } from './create-local-transport.js';
|
|
7
|
+
export type { ChildCapDescriptor, RegisterMessage, ChildLogMessage, ChildEventMessage, ChildToParentRequest, CapCallMessage, CapCallInput, CapCallOutMessage, AddonCallMessage, AddonCallInput, AddonCallTarget, AddonSettingsMethod, ParentToChildRequest, RegisteredChild, SetLogLevelMessage, } from './child-cap-protocol.js';
|
|
8
|
+
export { LocalChildRegistry, UDS_NO_ROUTE_PREFIX } from './local-child-registry.js';
|
|
9
|
+
export type { LocalChildRegistryOptions, LocalChildRegistryLogger } from './local-child-registry.js';
|
|
10
|
+
export type { LocalChildClientOptions, AddonCallHandler } from './local-child-client.js';
|
|
11
|
+
export { LocalChildClient } from './local-child-client.js';
|
|
12
|
+
export type { CapRoute, CapRouteBase, CapRouteOpts, HubInProcessRoute, HubLocalUdsRoute, RemoteMoleculerRoute, AgentChildForwardRoute, CapInvoker, InProcessProviderRef, CapRouteReason, RejectedRoute, CapRouteErrorDetail, } from './cap-route.js';
|
|
13
|
+
export { CapRouteError, classifyCapRoute } from './cap-route.js';
|
|
14
|
+
export { CapRouteResolver, AGENT_CAP_FWD_SERVICE, AGENT_CAP_FWD_ACTION, } from './cap-route-resolver.js';
|
|
15
|
+
export type { NodeCapAuthority, InProcessProviderLookup, CapRouteResolverDeps, AgentCapForwardParams, HubLocalChildDispatcher, } from './cap-route-resolver.js';
|
|
16
|
+
export { NATIVE_PROVIDER_SERVICE_INFIX, capServiceName, capActionName, capActionSuffix, capBareAction, parseCapAction, } from './cap-action-name.js';
|
|
17
|
+
export type { ParsedCapAction } from './cap-action-name.js';
|
|
18
|
+
export { createUdsLogger, createUdsLoggerWithControl } from './uds-logger.js';
|
|
19
|
+
export type { UdsLogSink, UdsLogLevelControl } from './uds-logger.js';
|
|
20
|
+
export { udsChildLogToWorkerEntry } from './uds-log-ingest.js';
|
|
21
|
+
export type { WorkerLogEntry } from './uds-log-ingest.js';
|
|
22
|
+
export { createUdsEventBus } from './uds-event-bus.js';
|
|
23
|
+
export type { UdsEventChannel } from './uds-event-bus.js';
|
|
24
|
+
export { createUdsEventBridge } from './uds-event-bridge.js';
|
|
25
|
+
export type { UdsEventBridgeDeps, ChildEventBroadcaster } from './uds-event-bridge.js';
|
|
26
|
+
export { createParentUnownedCallHandler } from './parent-unowned-call.js';
|
|
27
|
+
export type { ParentUnownedCallDeps, ParentUnownedCallLogger } from './parent-unowned-call.js';
|