@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,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Default data directory — used when CAMSTACK_DATA env var is not set */
|
|
3
|
+
export declare const DEFAULT_DATA_PATH = "camstack-data";
|
|
4
|
+
/** Bootstrap config -- loaded from config.yaml ONLY at startup.
|
|
5
|
+
* All other settings live in SQL (system_settings table). */
|
|
6
|
+
export declare const bootstrapSchema: z.ZodObject<{
|
|
7
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
8
|
+
agent: "agent";
|
|
9
|
+
hub: "hub";
|
|
10
|
+
}>>;
|
|
11
|
+
server: z.ZodDefault<z.ZodObject<{
|
|
12
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
host: z.ZodDefault<z.ZodString>;
|
|
14
|
+
dataPath: z.ZodDefault<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
auth: z.ZodDefault<z.ZodObject<{
|
|
17
|
+
jwtSecret: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
adminUsername: z.ZodDefault<z.ZodString>;
|
|
19
|
+
adminPassword: z.ZodDefault<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
hub: z.ZodDefault<z.ZodObject<{
|
|
22
|
+
url: z.ZodDefault<z.ZodString>;
|
|
23
|
+
token: z.ZodDefault<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
agent: z.ZodDefault<z.ZodObject<{
|
|
26
|
+
name: z.ZodDefault<z.ZodString>;
|
|
27
|
+
statusPort: z.ZodDefault<z.ZodNumber>;
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
tls: z.ZodDefault<z.ZodObject<{
|
|
30
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
+
certPath: z.ZodOptional<z.ZodString>;
|
|
32
|
+
keyPath: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, z.core.$strip>>;
|
|
34
|
+
bootstrap: z.ZodDefault<z.ZodObject<{
|
|
35
|
+
settingsStoreAddon: z.ZodDefault<z.ZodString>;
|
|
36
|
+
installSource: z.ZodOptional<z.ZodEnum<{
|
|
37
|
+
local: "local";
|
|
38
|
+
npm: "npm";
|
|
39
|
+
symlink: "symlink";
|
|
40
|
+
}>>;
|
|
41
|
+
requiredAddons: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
forceDisable: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export type BootstrapConfig = z.infer<typeof bootstrapSchema>;
|
|
46
|
+
/**
|
|
47
|
+
* Runtime defaults — re-exported from @camstack/types (canonical location).
|
|
48
|
+
* Kept here for backward compatibility with existing kernel consumers.
|
|
49
|
+
*/
|
|
50
|
+
export { RUNTIME_DEFAULTS } from '@camstack/types';
|
|
51
|
+
export type ServerMode = 'hub' | 'agent';
|
|
52
|
+
export type AppConfig = BootstrapConfig & {
|
|
53
|
+
features: {
|
|
54
|
+
streaming: boolean;
|
|
55
|
+
notifications: boolean;
|
|
56
|
+
objectDetection: boolean;
|
|
57
|
+
remoteAccess: boolean;
|
|
58
|
+
agentCluster: boolean;
|
|
59
|
+
smartHome: boolean;
|
|
60
|
+
recordings: boolean;
|
|
61
|
+
backup: boolean;
|
|
62
|
+
repl: boolean;
|
|
63
|
+
};
|
|
64
|
+
storage: {
|
|
65
|
+
provider: string;
|
|
66
|
+
locations: Record<string, string>;
|
|
67
|
+
};
|
|
68
|
+
logging: {
|
|
69
|
+
level: string;
|
|
70
|
+
retentionDays: number;
|
|
71
|
+
};
|
|
72
|
+
eventBus: {
|
|
73
|
+
ringBufferSize: number;
|
|
74
|
+
};
|
|
75
|
+
retention: {
|
|
76
|
+
detectionEventsDays: number;
|
|
77
|
+
audioLevelsDays: number;
|
|
78
|
+
};
|
|
79
|
+
providers: Array<{
|
|
80
|
+
id: string;
|
|
81
|
+
type: string;
|
|
82
|
+
name: string;
|
|
83
|
+
url?: string;
|
|
84
|
+
username?: string;
|
|
85
|
+
password?: string;
|
|
86
|
+
mqtt?: {
|
|
87
|
+
brokerUrl: string;
|
|
88
|
+
username?: string;
|
|
89
|
+
password?: string;
|
|
90
|
+
topicPrefix: string;
|
|
91
|
+
};
|
|
92
|
+
}>;
|
|
93
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CustomActionSpec, CustomActionsSpec } from '@camstack/types';
|
|
2
|
+
type Handler = (action: string, input: unknown) => Promise<unknown>;
|
|
3
|
+
export interface CustomActionEntry {
|
|
4
|
+
readonly spec: CustomActionSpec;
|
|
5
|
+
readonly handler: (input: unknown) => Promise<unknown>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* CustomActionRegistry — per-process registry of addon custom actions.
|
|
9
|
+
*
|
|
10
|
+
* Populated at boot from each addon's `AddonInitResult.customActions` +
|
|
11
|
+
* `handleCustomAction` handler. Rejects actions declared with scope other
|
|
12
|
+
* than 'system' (today only 'system' is runtime-supported; the descriptor
|
|
13
|
+
* allows future scopes for forward compat).
|
|
14
|
+
*/
|
|
15
|
+
export declare class CustomActionRegistry {
|
|
16
|
+
private readonly byAddon;
|
|
17
|
+
registerAddon(addonId: string, catalog: CustomActionsSpec, handler: Handler): void;
|
|
18
|
+
unregisterAddon(addonId: string): void;
|
|
19
|
+
resolve(addonId: string, action: string): CustomActionEntry | null;
|
|
20
|
+
listActions(addonId: string): readonly string[];
|
|
21
|
+
listAddons(): readonly string[];
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IScopedLogger, IAddonDepsManager } from '@camstack/types';
|
|
2
|
+
export declare class AddonDepsManager implements IAddonDepsManager {
|
|
3
|
+
private readonly logger;
|
|
4
|
+
private readonly nodeRoot;
|
|
5
|
+
private readonly depsDir;
|
|
6
|
+
constructor(_dataDir: string, logger: IScopedLogger);
|
|
7
|
+
ensureBinary(opts: {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly downloadUrl: string;
|
|
10
|
+
readonly isArchive?: boolean;
|
|
11
|
+
readonly archiveFormat?: 'zip' | 'tar.gz' | 'tar.xz';
|
|
12
|
+
readonly archiveInnerPath?: string;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
ensureFfmpeg(): Promise<string>;
|
|
15
|
+
ensurePython(): Promise<string | null>;
|
|
16
|
+
installPythonPackages(packages: readonly string[]): Promise<void>;
|
|
17
|
+
installPythonRequirements(requirementsFile: string): Promise<void>;
|
|
18
|
+
getDepsDir(): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IScopedLogger } from '@camstack/types';
|
|
2
|
+
/**
|
|
3
|
+
* Native node modules an addon needs at runtime but cannot be bundled
|
|
4
|
+
* (`.node` binary files require ABI-matched compilation). Mirror of the
|
|
5
|
+
* Python `requirements.txt` pattern in `manifest-python-deps.ts` —
|
|
6
|
+
* declared in the addon's `package.json` under `camstack.nativeDependencies`,
|
|
7
|
+
* installed per-addon at install time so the host's regular `npm install`
|
|
8
|
+
* doesn't pull in the union of every camera driver's native deps.
|
|
9
|
+
*
|
|
10
|
+
* Phase E of the bundles + builder modernization spec
|
|
11
|
+
* (`docs/superpowers/specs/2026-05-09-bundles-and-builder-modernization-design.md`).
|
|
12
|
+
*
|
|
13
|
+
* Idempotent: hashes the `nativeDependencies` map and writes a marker
|
|
14
|
+
* to `<addonDir>/.camstack-native-deps-installed`. Re-installing only
|
|
15
|
+
* happens when the declared set changes.
|
|
16
|
+
*
|
|
17
|
+
* Failure modes:
|
|
18
|
+
* - manifest doesn't declare `nativeDependencies` (or declares empty) → no-op
|
|
19
|
+
* - `npm install` fails → throws (caller decides whether to abort install)
|
|
20
|
+
* - rebuild step fails → logs warning + continues (install may still
|
|
21
|
+
* work if prebuilt binaries shipped in the package cover the host
|
|
22
|
+
* ABI; surface a clear error at first `import` of the native module
|
|
23
|
+
* otherwise).
|
|
24
|
+
*/
|
|
25
|
+
export declare function installManifestNativeDeps(addonDir: string, pkgRaw: Record<string, unknown>, logger: IScopedLogger, registry?: string): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AddonDeclaration, IAddonDepsManager, IScopedLogger } from '@camstack/types';
|
|
2
|
+
/**
|
|
3
|
+
* Auto-install the pip requirements file declared in an addon's manifest
|
|
4
|
+
* (`camstack.addons[].python.requirements`) into the embedded portable
|
|
5
|
+
* Python before `onInitialize()` runs.
|
|
6
|
+
*
|
|
7
|
+
* Idempotent: `installPythonRequirements` skips when the file's content
|
|
8
|
+
* hash matches an existing marker under `<python>/.requirements-installed/`.
|
|
9
|
+
* Re-downloading the embedded Python wipes the marker dir together with
|
|
10
|
+
* site-packages, forcing a fresh re-install.
|
|
11
|
+
*
|
|
12
|
+
* Failure modes:
|
|
13
|
+
* - manifest doesn't declare `python.requirements` → no-op.
|
|
14
|
+
* - embedded Python download fails → warn + continue. The addon's
|
|
15
|
+
* own `onInitialize` will raise a precise error if Python is
|
|
16
|
+
* actually required.
|
|
17
|
+
* - pip install fails → propagate so the group-runner aborts boot
|
|
18
|
+
* loudly (vs silently shipping a half-installed env).
|
|
19
|
+
*/
|
|
20
|
+
export declare function installManifestPythonDeps(declaration: AddonDeclaration, addonDir: string, deps: IAddonDepsManager, logger: IScopedLogger): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IDevice, IDeviceRegistry } from '@camstack/types';
|
|
2
|
+
export declare class DeviceRegistry implements IDeviceRegistry {
|
|
3
|
+
/** Primary map: every registered device keyed by its progressive
|
|
4
|
+
* numeric id. Numeric id is the system-wide unique handle; stableId
|
|
5
|
+
* is integration-scoped and only used at external boundaries. */
|
|
6
|
+
private readonly byId;
|
|
7
|
+
/** Addon scoping index: addonId → set of numeric device ids owned
|
|
8
|
+
* by that addon. Lets `getAllForAddon` and per-addon teardown stay
|
|
9
|
+
* O(1) per lookup without a second primary table. */
|
|
10
|
+
private readonly byAddon;
|
|
11
|
+
/** Inverse of byAddon for the single-device case. */
|
|
12
|
+
private readonly idToAddon;
|
|
13
|
+
register(addonId: string, device: IDevice): void;
|
|
14
|
+
/** Owning addonId for a registered numeric id, or null if not registered. */
|
|
15
|
+
getAddonId(id: number): string | null;
|
|
16
|
+
/** Look up any registered device by its progressive numeric id. */
|
|
17
|
+
getById(id: number): IDevice | null;
|
|
18
|
+
getAllForAddon(addonId: string): readonly IDevice[];
|
|
19
|
+
getChildren(parentDeviceId: number): readonly IDevice[];
|
|
20
|
+
remove(deviceId: number): void;
|
|
21
|
+
getAll(): readonly IDevice[];
|
|
22
|
+
/** All devices with their owning addonId. */
|
|
23
|
+
getAllWithAddonId(): readonly {
|
|
24
|
+
addonId: string;
|
|
25
|
+
device: IDevice;
|
|
26
|
+
}[];
|
|
27
|
+
/** All addonIds that have at least one registered device. */
|
|
28
|
+
getAddonIds(): readonly string[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensure a directory exists (recursive).
|
|
3
|
+
* Single source of truth — replaces scattered mkdirSync calls.
|
|
4
|
+
*/
|
|
5
|
+
export declare function ensureDir(dirPath: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Copy a directory recursively.
|
|
8
|
+
* Single source of truth — extracted from addon-installer + first-boot-installer.
|
|
9
|
+
*/
|
|
10
|
+
export declare function copyDirRecursive(src: string, dest: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Strip @camstack/* dependencies and devDependencies from a package.json object.
|
|
13
|
+
* Used when installing addons into the addons directory — @camstack packages
|
|
14
|
+
* are provided by the host runtime, not installed per-addon.
|
|
15
|
+
*
|
|
16
|
+
* Returns a new object (immutable).
|
|
17
|
+
*/
|
|
18
|
+
export declare function stripCamstackDeps(pkg: Record<string, unknown>): Record<string, unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* Copy extra file directories declared in package.json "files" field.
|
|
21
|
+
* Copies directories (not individual files) from source to destination.
|
|
22
|
+
* Skips "dist" (already handled) and glob patterns.
|
|
23
|
+
*/
|
|
24
|
+
export declare function copyExtraFileDirs(pkgJson: Record<string, unknown>, sourceDir: string, destDir: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Check if any file in src/ is newer than dist/.
|
|
27
|
+
* Returns true if rebuild is needed.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isSourceNewer(packageDir: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Ensure a library dependency (not an addon) has a dist/ directory.
|
|
32
|
+
* Does NOT rebuild — in dev mode, `npm run build` should be run separately.
|
|
33
|
+
* Only checks that dist/ exists and has an index file.
|
|
34
|
+
*/
|
|
35
|
+
export declare function ensureLibraryBuilt(packageName: string, packagesDir: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Install a single npm package into a target directory (package.json + dist/).
|
|
38
|
+
* No validation on camstack.addons -- works for any @camstack/* package.
|
|
39
|
+
* Uses synchronous child_process calls (suitable for first-boot and update paths).
|
|
40
|
+
*/
|
|
41
|
+
export declare function installPackageFromNpmSync(packageName: string, targetDir: string): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HwAccelBackend, HwAccelResolution } from '@camstack/types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the preferred hardware acceleration backend order for the
|
|
4
|
+
* current host.
|
|
5
|
+
*
|
|
6
|
+
* An explicit `prefer` override — typically read from
|
|
7
|
+
* `system-config.hwaccel.prefer` — wins unconditionally: the caller
|
|
8
|
+
* stays on that single backend and falls back to software only if it
|
|
9
|
+
* fails at decoder init.
|
|
10
|
+
*
|
|
11
|
+
* When no override is set, platform signals drive the order.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveHwAccel(prefer?: HwAccelBackend | 'none' | null): HwAccelResolution;
|
|
14
|
+
/**
|
|
15
|
+
* Build the `IKernelHwAccel` provider used to populate `ctx.kernel.hwaccel`.
|
|
16
|
+
* Thin async wrapper around the sync `resolveHwAccel` function so the
|
|
17
|
+
* contract matches the per-node `$hwaccel.resolve` Moleculer action.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createKernelHwAccel(): import('@camstack/types').IKernelHwAccel;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type { RegisteredAddon } from './addon-loader.js';
|
|
2
|
+
export { AddonLoader } from './addon-loader.js';
|
|
3
|
+
export { AddonEngineManager } from './addon-engine-manager.js';
|
|
4
|
+
export type { AddonInstallerConfig, InstallSource, InstalledPackage } from './addon-installer.js';
|
|
5
|
+
export { AddonInstaller } from './addon-installer.js';
|
|
6
|
+
export type { AddonInstallSource, AddonManifestEntry, AddonManifestFile } from './addon-manifest.js';
|
|
7
|
+
export { AddonManifest } from './addon-manifest.js';
|
|
8
|
+
export { copyDirRecursive, ensureDir, stripCamstackDeps, copyExtraFileDirs, ensureLibraryBuilt, installPackageFromNpmSync, isSourceNewer, } from './fs-utils.js';
|
|
9
|
+
export { detectWorkspacePackagesDir } from './workspace-detect.js';
|
|
10
|
+
export { RESTART_MARKER_FILE, clearPendingRestart, getRestartMarkerPath, readPendingRestart, scheduleSelfRestart, writePendingRestart, } from './restart-coordinator.js';
|
|
11
|
+
export type { PendingRestartMarker, RestartKind, ScheduleSelfRestartOptions, } from './restart-coordinator.js';
|
|
12
|
+
export { CapabilityHandle, CapabilityUnavailableError } from './capability-handle.js';
|
|
13
|
+
export { CapabilityRegistry } from './capability-registry.js';
|
|
14
|
+
export { describeProviderKindDrift } from './provider-kind-drift.js';
|
|
15
|
+
export type { ProviderKindHint } from './provider-kind-drift.js';
|
|
16
|
+
export type { CapabilityRouter, CapabilityRouterFactory, ConfigReader, } from './capability-registry.js';
|
|
17
|
+
export { CustomActionRegistry, type CustomActionEntry } from './custom-action-registry.js';
|
|
18
|
+
export { INFRA_CAPABILITIES, isInfraCapability } from './infra-capabilities.js';
|
|
19
|
+
export type { InfraCapability } from './infra-capabilities.js';
|
|
20
|
+
export { ConfigManager } from './config-manager.js';
|
|
21
|
+
export type { ISettingsStore } from './config-manager.js';
|
|
22
|
+
export { bootstrapSchema, RUNTIME_DEFAULTS, DEFAULT_DATA_PATH } from './config-schema.js';
|
|
23
|
+
export type { BootstrapConfig, AppConfig, ServerMode } from './config-schema.js';
|
|
24
|
+
export type { AddonSettingsView } from './config-manager.js';
|
|
25
|
+
export { DeviceRegistry } from './device-registry.js';
|
|
26
|
+
export { buildStorageLocationRegistry } from './storage-location-registry.js';
|
|
27
|
+
export type { StorageLocationRegistry } from './storage-location-registry.js';
|
|
28
|
+
export { createBroker, deriveAgentListenPort } from './moleculer/broker-factory.js';
|
|
29
|
+
export type { BrokerConfig } from './moleculer/broker-factory.js';
|
|
30
|
+
export { createAddonService, validateProviderRegistrations, } from './moleculer/addon-service-factory.js';
|
|
31
|
+
export { createCoreCapService, CORE_CAP_SERVICE_NAME } from './moleculer/core-cap-service.js';
|
|
32
|
+
export type { CoreCapAction, CoreCapServiceOptions } from './moleculer/core-cap-service.js';
|
|
33
|
+
export { createAddonContext, createUdsAddonContext, setHubConnected, adaptBrokerToCluster, registerEventBusService, getBrokerEventBus, EVENT_TOPIC_PREFIX, } from './moleculer/addon-context-factory.js';
|
|
34
|
+
export { HubLogForwarder } from './moleculer/hub-log-forwarder.js';
|
|
35
|
+
export type { AddonContextOptions } from './moleculer/addon-context-factory.js';
|
|
36
|
+
export { createHubService } from './moleculer/hub-service.js';
|
|
37
|
+
export { HubNodeRegistry } from './moleculer/node-registry.js';
|
|
38
|
+
export type { CallFn, RegisteredAddonManifest, RegisteredNativeCap, RegisterNodeParams, RegisterNodeResult, NodeCapEntry, NodeNativeCapEntry, } from './moleculer/node-registry.js';
|
|
39
|
+
export { callRegisterNodeWithRetry, buildNodeManifest } from './moleculer/register-node-client.js';
|
|
40
|
+
export type { RegisterNodeBroker, CallRegisterNodeOptions, } from './moleculer/register-node-client.js';
|
|
41
|
+
export { hashClusterSecret, clusterSecretMatches, isClusterSecretMismatchError, CLUSTER_SECRET_MISMATCH_TYPE, CLUSTER_SECRET_REJECTED_EXIT_CODE, } from './moleculer/cluster-secret.js';
|
|
42
|
+
export { serializeTypedArrays } from './moleculer/typed-array-serde.js';
|
|
43
|
+
export { createReadinessService, createReadinessServiceForRegistry, } from './moleculer/readiness-service.js';
|
|
44
|
+
export type { ReadinessServiceDeps } from './moleculer/readiness-service.js';
|
|
45
|
+
export { getOrInitReadinessRegistry, getOrInitReadinessRegistryForClient, } from './moleculer/readiness-context.js';
|
|
46
|
+
export type { UdsReadinessClient } from './moleculer/readiness-context.js';
|
|
47
|
+
export { createStreamProbeBrokerService } from './moleculer/stream-probe-service.js';
|
|
48
|
+
export type { StreamProbeBrokerDeps } from './moleculer/stream-probe-service.js';
|
|
49
|
+
export { resolveHwAccel, createKernelHwAccel } from './hwaccel/hwaccel-resolver.js';
|
|
50
|
+
export { createHwAccelService } from './hwaccel/hwaccel-service.js';
|
|
51
|
+
export { AddonDepsManager } from './deps/addon-deps-manager.js';
|
|
52
|
+
export { installManifestPythonDeps } from './deps/manifest-python-deps.js';
|
|
53
|
+
export { installManifestNativeDeps } from './deps/manifest-native-deps.js';
|
|
54
|
+
export { AddonHealthMonitor, HEALTH_MONITOR_TICK_MS, HEALTH_MONITOR_GRACE_PERIOD_MS, HEALTH_MONITOR_RETRY_INTERVALS_MS, } from './addon-health-monitor.js';
|
|
55
|
+
export type { AddonHealthPhase, AddonHealthState, AddonHealthSnapshot, AddonHealthMonitorOptions, } from './addon-health-monitor.js';
|
|
56
|
+
export type { HwAccelServiceDeps } from './hwaccel/hwaccel-service.js';
|
|
57
|
+
export type { HubServiceDeps } from './moleculer/hub-service.js';
|
|
58
|
+
export { createBrokerDeviceManagerApi, buildNativeCapProxy, buildUdsNativeCapProxy, mountNativeCapService, NATIVE_PROVIDER_SERVICE_INFIX, } from './moleculer/device-cap-proxy.js';
|
|
59
|
+
export type { WorkerDeviceManagerOptions } from './moleculer/device-cap-proxy.js';
|
|
60
|
+
export { getWorkerDeviceRegistry } from './moleculer/addon-context-factory.js';
|
|
61
|
+
export { localProviderLink, brokerTransportLink, ipcChildLink, ipcParentLink, buildLinkChain, brokerCallForCap, } from './moleculer/trpc-links.js';
|
|
62
|
+
export type { LocalProviderResolver, BrokerCapCallOpts } from './moleculer/trpc-links.js';
|
|
63
|
+
export { createProcessService } from './moleculer/process-service.js';
|
|
64
|
+
export type { ProcessInfo } from './moleculer/process-service.js';
|
|
65
|
+
export { CapUsageRegistry, getCapUsageRegistry, __resetCapUsageRegistryForTests, } from './moleculer/cap-usage-registry.js';
|
|
66
|
+
export type { CapUsageCallRecord, CapUsageEdge, CapUsageRegistryOptions, } from './moleculer/cap-usage-registry.js';
|
|
67
|
+
export { createScopedProcessManager } from './moleculer/process-context.js';
|
|
68
|
+
export type { IAddonProcessManager } from '@camstack/types';
|
|
69
|
+
export { callWithServiceDiscovery } from './moleculer/resilient-cap-call.js';
|
|
70
|
+
export type { ServiceDiscoveryBroker } from './moleculer/resilient-cap-call.js';
|
|
71
|
+
export { RingBuffer } from './utils/ring-buffer.js';
|
|
72
|
+
export * from './transport/index.js';
|
|
73
|
+
export { ReadinessRegistry, ReadinessTimeoutError, readinessKey, scopeKey, emitDownForOwnedCaps, } from '@camstack/types';
|
|
74
|
+
export type { ReadinessHandler, ReadinessTransition, AwaitReadyOptions, ReadinessRegistryOptions, } from '@camstack/types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface InfraCapability {
|
|
2
|
+
/** Capability name */
|
|
3
|
+
readonly name: string;
|
|
4
|
+
/** If true, boot aborts when this capability's addon fails to initialize */
|
|
5
|
+
readonly required: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Infrastructure capabilities that must boot before all other addons.
|
|
9
|
+
* Enabled in Phase 1 of the boot sequence. Order matters: storage before logging.
|
|
10
|
+
*/
|
|
11
|
+
export declare const INFRA_CAPABILITIES: readonly InfraCapability[];
|
|
12
|
+
/** Check if a capability name is an infrastructure capability */
|
|
13
|
+
export declare function isInfraCapability(name: string): boolean;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ServiceBroker } from 'moleculer';
|
|
2
|
+
import { InternalAddonContext, AddonDeclaration, IStorageProvider, IScopedLogger, IClusterBroker } from '@camstack/types';
|
|
3
|
+
import { DeviceRegistry } from '../device-registry.js';
|
|
4
|
+
import { CapabilityRegistry } from '../capability-registry.js';
|
|
5
|
+
import { CapCallInput } from '../transport/index.js';
|
|
6
|
+
import { LocalChildClient } from '../transport/local-child-client.js';
|
|
7
|
+
import { DataPlaneSink } from './addon-data-plane-facility.js';
|
|
8
|
+
import { getBrokerEventBus, registerEventBusService, clusterEventTopic, EVENT_TOPIC_PREFIX } from './event-bus.js';
|
|
9
|
+
import { createRunnerLogger, setHubConnected, ___resetHubConnectedForTests, ___createRemoteLoggerForTests } from './remote-logger.js';
|
|
10
|
+
import { withAddonScope, setPreferredProvider, ___resetBindingSubscriptionForTests } from './provider-registry.js';
|
|
11
|
+
/**
|
|
12
|
+
* Adapt a Moleculer ServiceBroker to the camstack-types `IClusterBroker`
|
|
13
|
+
* structural interface so addons can consume cluster-level RPC without
|
|
14
|
+
* pulling a moleculer dependency. Method signatures differ slightly
|
|
15
|
+
* (Moleculer's overloads are wider than the camstack contract), so we
|
|
16
|
+
* forward through a thin object instead of casting at the boundary.
|
|
17
|
+
*/
|
|
18
|
+
declare function adaptBrokerToCluster(broker: ServiceBroker): IClusterBroker;
|
|
19
|
+
/**
|
|
20
|
+
* Expose the per-process worker device registry so the process-runner can
|
|
21
|
+
* mount the `device-ops-bridge` Moleculer service on top of the same live
|
|
22
|
+
* IDevice instances that `createBrokerDeviceManagerApi` writes to.
|
|
23
|
+
*
|
|
24
|
+
* Hub-side contexts also share this module, but they pass their own
|
|
25
|
+
* `opts.deviceRegistry` explicitly — nothing hub-side uses this accessor.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getWorkerDeviceRegistry(): DeviceRegistry;
|
|
28
|
+
/**
|
|
29
|
+
* Options for enriching the addon context with infrastructure providers.
|
|
30
|
+
* When the agent boots with core addons (storage, settings-store),
|
|
31
|
+
* pass them here so deployed addons get full capabilities.
|
|
32
|
+
*/
|
|
33
|
+
interface AddonContextOptions {
|
|
34
|
+
readonly storageProvider?: IStorageProvider;
|
|
35
|
+
readonly addonConfig?: Record<string, unknown>;
|
|
36
|
+
/** Custom logger factory — when set, overrides the default remote logger */
|
|
37
|
+
readonly createLogger?: (addonId: string) => IScopedLogger;
|
|
38
|
+
/**
|
|
39
|
+
* Hub `CapabilityRegistry`. When set, the `DeviceManagerApi` created
|
|
40
|
+
* for this context wires `DeviceContext.registerNativeCap` through it
|
|
41
|
+
* so device-driver addons can publish per-device native capability
|
|
42
|
+
* providers. Forked-worker processes don't carry a CapabilityRegistry,
|
|
43
|
+
* so this field is left undefined there — `registerNativeCap` becomes
|
|
44
|
+
* unavailable on workers, which throw at runtime if called.
|
|
45
|
+
*/
|
|
46
|
+
readonly capabilityRegistry?: CapabilityRegistry;
|
|
47
|
+
/**
|
|
48
|
+
* UDS egress function for child→parent cap calls. When provided,
|
|
49
|
+
* `ipcParentLink` is inserted between `localProviderLink` and
|
|
50
|
+
* `brokerTransportLink` so addon-runner cap calls route over UDS
|
|
51
|
+
* instead of through Moleculer when the parent owns the target cap.
|
|
52
|
+
*
|
|
53
|
+
* Returns `null` when the UDS channel is not yet connected (before
|
|
54
|
+
* `LocalChildClient.start()` resolves), in which case `ipcParentLink`
|
|
55
|
+
* no-ops and the call falls through to `brokerTransportLink`.
|
|
56
|
+
*
|
|
57
|
+
* Hub-side contexts omit this option; their link chain is unchanged.
|
|
58
|
+
*/
|
|
59
|
+
readonly getParentCallOut?: () => ((input: CapCallInput) => Promise<unknown>) | null;
|
|
60
|
+
/**
|
|
61
|
+
* Where this context's `ctx.dataPlane` publishes its live HTTP data-plane
|
|
62
|
+
* endpoints. The forked addon-runner passes a sink writing into a per-addonId
|
|
63
|
+
* map the hub pulls (`target: 'data-planes'`); the hub passes a sink writing
|
|
64
|
+
* straight into its `DataPlaneRegistry` for co-located addons. Omitted → the
|
|
65
|
+
* facility still serves locally but nothing advertises it (tests/isolation).
|
|
66
|
+
*/
|
|
67
|
+
readonly dataPlaneSink?: DataPlaneSink;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Broker-mode entry point — UNCHANGED public signature. The hub
|
|
71
|
+
* (`addon-registry.service.ts`), the agent (`agent-bootstrap.ts`), and
|
|
72
|
+
* every broker-mode test call this with a positional `ServiceBroker`.
|
|
73
|
+
*/
|
|
74
|
+
declare function createAddonContext(broker: ServiceBroker, declaration: AddonDeclaration, dataDir: string, options?: AddonContextOptions): Promise<InternalAddonContext>;
|
|
75
|
+
/**
|
|
76
|
+
* UDS-mode entry point — for a broker-less forked `addon-runner` child
|
|
77
|
+
* (Phase F1+F2). Logger/eventBus/readiness ride the UDS channel; the tRPC
|
|
78
|
+
* link chain is `[localProviderLink, ipcParentLink]` (no broker, so no
|
|
79
|
+
* `brokerTransportLink`). `getParentCallOut` is implied by the client and
|
|
80
|
+
* wired automatically — callers MUST NOT pass it in `options`.
|
|
81
|
+
*/
|
|
82
|
+
declare function createUdsAddonContext(client: LocalChildClient, nodeId: string, declaration: AddonDeclaration, dataDir: string, options?: AddonContextOptions): Promise<InternalAddonContext>;
|
|
83
|
+
/**
|
|
84
|
+
* Drain (and forget) the disposer chain for a worker-side addon. Idempotent:
|
|
85
|
+
* subsequent calls are no-ops. Called by process-runner / group-runner
|
|
86
|
+
* before reload or graceful shutdown so resources clean up before the
|
|
87
|
+
* next addon instance loads.
|
|
88
|
+
*/
|
|
89
|
+
declare function drainWorkerDisposerChain(nodeId: string, addonId: string): Promise<void>;
|
|
90
|
+
export { createAddonContext, createUdsAddonContext, setHubConnected, adaptBrokerToCluster, drainWorkerDisposerChain, registerEventBusService, clusterEventTopic, EVENT_TOPIC_PREFIX, getBrokerEventBus, withAddonScope, setPreferredProvider, createRunnerLogger, __resetHubConnectedForTests, __resetBindingSubscriptionForTests, __createRemoteLoggerForTests, };
|
|
91
|
+
export type { AddonContextOptions };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AddonDataPlane, AddonDataPlaneEndpoint, IScopedLogger } from '@camstack/types';
|
|
2
|
+
/** Where the facility publishes the addon's current data-plane endpoints so the
|
|
3
|
+
* runner can expose them to the hub's pull. */
|
|
4
|
+
export interface DataPlaneSink {
|
|
5
|
+
set(addonId: string, endpoints: readonly AddonDataPlaneEndpoint[]): void;
|
|
6
|
+
}
|
|
7
|
+
export interface AddonDataPlaneFacility {
|
|
8
|
+
readonly dataPlane: AddonDataPlane;
|
|
9
|
+
/** Close the listener + clear endpoints. Wired to the context disposer chain. */
|
|
10
|
+
dispose(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare function createAddonDataPlaneFacility(args: {
|
|
13
|
+
readonly addonId: string;
|
|
14
|
+
readonly logger: IScopedLogger;
|
|
15
|
+
readonly sink?: DataPlaneSink;
|
|
16
|
+
/** Bind host — `127.0.0.1` for a hub-local addon (default). Remote agents bind
|
|
17
|
+
* their reachable interface (deferred — single-hub first). */
|
|
18
|
+
readonly bindHost?: string;
|
|
19
|
+
}): AddonDataPlaneFacility;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ServiceSchema } from 'moleculer';
|
|
2
|
+
import { ICamstackAddon, AddonDeclaration } from '@camstack/types';
|
|
3
|
+
/**
|
|
4
|
+
* Validate that every capability declared in the addon manifest has a
|
|
5
|
+
* provider registered via context.registerProvider() during initialize().
|
|
6
|
+
*
|
|
7
|
+
* Call after addon.initialize() to catch missing registrations at boot time
|
|
8
|
+
* instead of at runtime when a consumer tries to use the capability.
|
|
9
|
+
*/
|
|
10
|
+
declare function validateProviderRegistrations(addonId: string, declaration: AddonDeclaration, providers: ReadonlyMap<string, unknown>, logger?: {
|
|
11
|
+
warn: (msg: string) => void;
|
|
12
|
+
debug?: (msg: string) => void;
|
|
13
|
+
info?: (msg: string) => void;
|
|
14
|
+
}): readonly string[];
|
|
15
|
+
/**
|
|
16
|
+
* Optional resolver that returns method names for a capability.
|
|
17
|
+
* Used by the hub to resolve methods from CapabilityDefinitions (*.cap.ts)
|
|
18
|
+
* when the package.json declaration doesn't include explicit methods.
|
|
19
|
+
*/
|
|
20
|
+
type MethodResolver = (capabilityName: string) => readonly string[];
|
|
21
|
+
/**
|
|
22
|
+
* Wrap an ICamstackAddon as a Moleculer ServiceSchema.
|
|
23
|
+
*
|
|
24
|
+
* Methods for each capability are resolved in this order:
|
|
25
|
+
* 1. `declaration.capabilities[].methods` from package.json
|
|
26
|
+
* 2. `methodResolver(capName)` from CapabilityRegistry definitions
|
|
27
|
+
* 3. Auto-discovery: enumerate own methods on the registered provider
|
|
28
|
+
*
|
|
29
|
+
* Additionally, the four two-level settings methods (`getGlobalSettings`,
|
|
30
|
+
* `updateGlobalSettings`, `getDeviceSettings`, `updateDeviceSettings`)
|
|
31
|
+
* are auto-exposed under a
|
|
32
|
+
* `settings.*` namespace if the addon implements them. This replaces the
|
|
33
|
+
* former `$addonHost` Moleculer service — the hub's `addon-settings`
|
|
34
|
+
* singleton provider calls `broker.call('<addonId>.settings.<method>')`.
|
|
35
|
+
*/
|
|
36
|
+
declare function createAddonService(addon: ICamstackAddon, declaration: AddonDeclaration, options?: {
|
|
37
|
+
readonly methodResolver?: MethodResolver;
|
|
38
|
+
/** Per-action Moleculer timeout override: (capName, methodName) → ms */
|
|
39
|
+
readonly timeoutResolver?: (capName: string, methodName: string) => number | undefined;
|
|
40
|
+
readonly providers?: ReadonlyMap<string, unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* Custom action catalog declared via `onInitialize()`'s `customActions`
|
|
43
|
+
* field. The service exposes them as `custom.<actionName>` moleculer
|
|
44
|
+
* actions + advertises their names via metadata so the hub can proxy
|
|
45
|
+
* dispatches into the worker when the addon runs forkable.
|
|
46
|
+
*/
|
|
47
|
+
readonly customActions?: Readonly<Record<string, unknown>>;
|
|
48
|
+
readonly actionHandlers?: Readonly<Record<string, (input: unknown) => unknown | Promise<unknown>>>;
|
|
49
|
+
}): ServiceSchema;
|
|
50
|
+
export { createAddonService, validateProviderRegistrations };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ServiceBroker } from 'moleculer';
|
|
2
|
+
interface BrokerConfig {
|
|
3
|
+
readonly nodeID: string;
|
|
4
|
+
readonly mode: 'hub' | 'agent' | 'test';
|
|
5
|
+
readonly hubAddress?: string;
|
|
6
|
+
readonly logLevel?: string;
|
|
7
|
+
/** Shared secret — used as Moleculer namespace to isolate the cluster on the network */
|
|
8
|
+
readonly secret?: string;
|
|
9
|
+
/**
|
|
10
|
+
* TCP port the hub listens on for cluster traffic.
|
|
11
|
+
* Agents need a deterministic port to connect via `urls: 'hub@host:port'`
|
|
12
|
+
* when UDP multicast discovery is disabled.
|
|
13
|
+
*/
|
|
14
|
+
readonly tcpPort?: number;
|
|
15
|
+
/** UDP port for cluster discovery (default: 4445). */
|
|
16
|
+
readonly udpPort?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Explicit TCP port for the agent's own Moleculer reader to bind.
|
|
19
|
+
* When omitted, the port is derived deterministically from `nodeID`
|
|
20
|
+
* (see `deriveAgentListenPort`). Set this only to resolve a port
|
|
21
|
+
* collision between two agents that happen to hash to the same port
|
|
22
|
+
* on one host.
|
|
23
|
+
*/
|
|
24
|
+
readonly agentListenPort?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Derive a STABLE Moleculer reader port for an agent from its nodeID.
|
|
28
|
+
*
|
|
29
|
+
* Moleculer's TCP transporter keeps disconnected nodes in its
|
|
30
|
+
* `NodeCatalog` (it never deletes them) and `processGossipHello` only
|
|
31
|
+
* adopts a node's host/port when the node is unknown — a reconnecting
|
|
32
|
+
* node's address is therefore never refreshed. With an OS-assigned
|
|
33
|
+
* EPHEMERAL reader port (`port: 0`) every agent restart picks a new
|
|
34
|
+
* port, so after a kill+restart under the SAME nodeID the hub (and every
|
|
35
|
+
* forked group-runner that gossiped about the agent) keeps the DEAD port
|
|
36
|
+
* and can never deliver the `GOSSIP_RESPONSE` carrying its INFO. The
|
|
37
|
+
* agent then never re-discovers the hub's services and `ctx.api.*` calls
|
|
38
|
+
* (e.g. the early `settings-store.get` in `bootCoreAddons`) poll service
|
|
39
|
+
* discovery forever.
|
|
40
|
+
*
|
|
41
|
+
* Binding a port DERIVED FROM the nodeID makes the agent reconnect at the
|
|
42
|
+
* SAME address every restart — exactly like the hub's fixed 6000 — so the
|
|
43
|
+
* stale catalog entries everywhere still point at a live socket and
|
|
44
|
+
* Moleculer's gossip seq self-healing completes the handshake. The nodeID
|
|
45
|
+
* is the agent's persisted stable identity, so the port is stable too.
|
|
46
|
+
*/
|
|
47
|
+
declare function deriveAgentListenPort(nodeID: string): number;
|
|
48
|
+
declare function createBroker(config: BrokerConfig): ServiceBroker;
|
|
49
|
+
export { createBroker, deriveAgentListenPort };
|
|
50
|
+
export type { BrokerConfig };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory observation of tRPC cap calls between addons.
|
|
3
|
+
*
|
|
4
|
+
* Storage: `Map<callerAddonId, Map<providerAddonId, Map<capName, RollingWindow>>>`.
|
|
5
|
+
* `RollingWindow` is a fixed-size ring of 1-second buckets — default 300
|
|
6
|
+
* buckets = 5 minutes retention. Queries narrower than the retention
|
|
7
|
+
* window filter buckets at read time.
|
|
8
|
+
*
|
|
9
|
+
* Memory bound: 30 callers × 30 providers × 50 caps × 300 buckets × 16 B ≈ 22 MB
|
|
10
|
+
* worst case. Realistic load (~10 active caller→provider→cap triples)
|
|
11
|
+
* keeps it under 200 KB.
|
|
12
|
+
*/
|
|
13
|
+
export interface CapUsageCallRecord {
|
|
14
|
+
readonly callerAddonId: string;
|
|
15
|
+
readonly providerAddonId: string;
|
|
16
|
+
readonly capName: string;
|
|
17
|
+
readonly methodName: string;
|
|
18
|
+
readonly atMs: number;
|
|
19
|
+
}
|
|
20
|
+
export interface CapUsageEdge {
|
|
21
|
+
readonly callerAddonId: string;
|
|
22
|
+
readonly providerAddonId: string;
|
|
23
|
+
readonly capName: string;
|
|
24
|
+
readonly callsPerMin: number;
|
|
25
|
+
readonly lastCallAtMs: number;
|
|
26
|
+
}
|
|
27
|
+
export interface CapUsageRegistryOptions {
|
|
28
|
+
/** Max retention in seconds (ring length). Default 300. */
|
|
29
|
+
readonly retentionSeconds?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare class CapUsageRegistry {
|
|
32
|
+
private readonly retentionSeconds;
|
|
33
|
+
private readonly map;
|
|
34
|
+
constructor(opts?: CapUsageRegistryOptions);
|
|
35
|
+
recordCall(rec: CapUsageCallRecord): void;
|
|
36
|
+
getGraph(opts: {
|
|
37
|
+
windowSeconds: number;
|
|
38
|
+
nowMs: number;
|
|
39
|
+
}): readonly CapUsageEdge[];
|
|
40
|
+
/** Test / diagnostic helper — drops all recorded calls. */
|
|
41
|
+
clear(): void;
|
|
42
|
+
}
|
|
43
|
+
/** Hub-side singleton. The first caller seeds it; subsequent calls return the same. */
|
|
44
|
+
export declare function getCapUsageRegistry(): CapUsageRegistry;
|
|
45
|
+
/** Test helper — clears the singleton (kept module-private elsewhere). */
|
|
46
|
+
export declare function __resetCapUsageRegistryForTests(): void;
|