@camstack/core 0.1.15 → 0.1.17
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 +36 -0
- package/dist/addon/addon-api-factory.d.ts.map +1 -0
- package/dist/addon-routes/addon-route-registry.d.ts +38 -0
- package/dist/addon-routes/addon-route-registry.d.ts.map +1 -0
- package/dist/auth/api-key-manager.d.ts +27 -0
- package/dist/auth/api-key-manager.d.ts.map +1 -0
- package/dist/auth/auth-manager.d.ts +47 -0
- package/dist/auth/auth-manager.d.ts.map +1 -0
- package/dist/auth/parse-record.d.ts +19 -0
- package/dist/auth/parse-record.d.ts.map +1 -0
- package/dist/auth/scoped-token-manager.d.ts +18 -0
- package/dist/auth/scoped-token-manager.d.ts.map +1 -0
- package/dist/auth/user-manager.d.ts +34 -0
- package/dist/auth/user-manager.d.ts.map +1 -0
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.d.ts +54 -0
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.d.ts.map +1 -0
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +223 -217
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js.map +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +216 -7
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs.map +1 -1
- package/dist/builtins/addon-pages-aggregator/index.d.ts +2 -0
- package/dist/builtins/addon-pages-aggregator/index.d.ts.map +1 -0
- package/dist/builtins/addon-pages-aggregator/index.js +6 -221
- package/dist/builtins/addon-pages-aggregator/index.mjs +2 -9
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.d.ts +33 -0
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.d.ts.map +1 -0
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +199 -197
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js.map +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +192 -7
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs.map +1 -1
- package/dist/builtins/addon-widgets-aggregator/index.d.ts +2 -0
- package/dist/builtins/addon-widgets-aggregator/index.d.ts.map +1 -0
- package/dist/builtins/addon-widgets-aggregator/index.js +6 -201
- package/dist/builtins/addon-widgets-aggregator/index.mjs +2 -9
- package/dist/builtins/alerts/alerts.addon.d.ts +82 -0
- package/dist/builtins/alerts/alerts.addon.d.ts.map +1 -0
- package/dist/builtins/alerts/alerts.addon.js +590 -430
- package/dist/builtins/alerts/alerts.addon.js.map +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +595 -7
- package/dist/builtins/alerts/alerts.addon.mjs.map +1 -1
- package/dist/builtins/alerts/index.d.ts +2 -0
- package/dist/builtins/alerts/index.d.ts.map +1 -0
- package/dist/builtins/alerts/index.js +3 -443
- package/dist/builtins/alerts/index.mjs +2 -8
- package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.d.ts +8 -0
- package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.d.ts.map +1 -0
- package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.js +56 -0
- package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.js.map +1 -0
- package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.mjs +50 -0
- package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.mjs.map +1 -0
- package/dist/builtins/auth-orchestrator/index.d.ts +2 -0
- package/dist/builtins/auth-orchestrator/index.d.ts.map +1 -0
- package/dist/builtins/auth-orchestrator/index.js +7 -0
- package/dist/builtins/auth-orchestrator/index.mjs +2 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +148 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts.map +1 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +7639 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js.map +1 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +7627 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs.map +1 -0
- package/dist/builtins/backup-orchestrator/cron-helpers.d.ts +24 -0
- package/dist/builtins/backup-orchestrator/cron-helpers.d.ts.map +1 -0
- package/dist/builtins/backup-orchestrator/destination-policy.d.ts +73 -0
- package/dist/builtins/backup-orchestrator/destination-policy.d.ts.map +1 -0
- package/dist/builtins/backup-orchestrator/download-helpers.d.ts +13 -0
- package/dist/builtins/backup-orchestrator/download-helpers.d.ts.map +1 -0
- package/dist/builtins/backup-orchestrator/index.d.ts +3 -0
- package/dist/builtins/backup-orchestrator/index.d.ts.map +1 -0
- package/dist/builtins/backup-orchestrator/index.js +7 -0
- package/dist/builtins/backup-orchestrator/index.mjs +2 -0
- package/dist/builtins/backup-orchestrator/manifest-store.d.ts +78 -0
- package/dist/builtins/backup-orchestrator/manifest-store.d.ts.map +1 -0
- package/dist/builtins/console-logging/console-destination.d.ts +14 -0
- package/dist/builtins/console-logging/console-destination.d.ts.map +1 -0
- package/dist/builtins/console-logging/console-logging.addon.d.ts +26 -0
- package/dist/builtins/console-logging/console-logging.addon.d.ts.map +1 -0
- package/dist/builtins/console-logging/index.d.ts +4 -0
- package/dist/builtins/console-logging/index.d.ts.map +1 -0
- package/dist/builtins/console-logging/index.js +99 -235
- package/dist/builtins/console-logging/index.js.map +1 -1
- package/dist/builtins/console-logging/index.mjs +95 -9
- package/dist/builtins/console-logging/index.mjs.map +1 -1
- package/dist/builtins/device-manager/device-event-propagator.d.ts +27 -0
- package/dist/builtins/device-manager/device-event-propagator.d.ts.map +1 -0
- package/dist/builtins/device-manager/device-manager.addon.d.ts +259 -0
- package/dist/builtins/device-manager/device-manager.addon.d.ts.map +1 -0
- package/dist/builtins/device-manager/device-manager.addon.js +2125 -2127
- package/dist/builtins/device-manager/device-manager.addon.js.map +1 -1
- package/dist/builtins/device-manager/device-manager.addon.mjs +2145 -7
- package/dist/builtins/device-manager/device-manager.addon.mjs.map +1 -1
- package/dist/builtins/device-manager/index.d.ts +3 -0
- package/dist/builtins/device-manager/index.d.ts.map +1 -0
- package/dist/builtins/device-manager/index.js +6 -2156
- package/dist/builtins/device-manager/index.mjs +2 -10
- package/dist/builtins/hub-forwarder/hub-forwarder-destination.d.ts +45 -0
- package/dist/builtins/hub-forwarder/hub-forwarder-destination.d.ts.map +1 -0
- package/dist/builtins/hub-forwarder/hub-forwarder.addon.d.ts +16 -0
- package/dist/builtins/hub-forwarder/hub-forwarder.addon.d.ts.map +1 -0
- package/dist/builtins/hub-forwarder/index.d.ts +4 -0
- package/dist/builtins/hub-forwarder/index.d.ts.map +1 -0
- package/dist/builtins/hub-forwarder/index.js +150 -291
- package/dist/builtins/hub-forwarder/index.js.map +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +145 -9
- package/dist/builtins/hub-forwarder/index.mjs.map +1 -1
- package/dist/builtins/local-auth/auth-schema.d.ts +12 -0
- package/dist/builtins/local-auth/auth-schema.d.ts.map +1 -0
- package/dist/builtins/local-auth/index.d.ts +2 -0
- package/dist/builtins/local-auth/index.d.ts.map +1 -0
- package/dist/builtins/local-auth/index.js +3 -623
- package/dist/builtins/local-auth/index.mjs +2 -8
- package/dist/builtins/local-auth/local-auth.addon.d.ts +17 -0
- package/dist/builtins/local-auth/local-auth.addon.d.ts.map +1 -0
- package/dist/builtins/local-auth/local-auth.addon.js +6861 -589
- package/dist/builtins/local-auth/local-auth.addon.js.map +1 -1
- package/dist/builtins/local-auth/local-auth.addon.mjs +6883 -7
- package/dist/builtins/local-auth/local-auth.addon.mjs.map +1 -1
- package/dist/builtins/local-network/index.d.ts +3 -0
- package/dist/builtins/local-network/index.d.ts.map +1 -0
- package/dist/builtins/local-network/index.js +9 -0
- package/dist/builtins/local-network/index.mjs +2 -0
- package/dist/builtins/local-network/local-network.addon.d.ts +110 -0
- package/dist/builtins/local-network/local-network.addon.d.ts.map +1 -0
- package/dist/builtins/local-network/local-network.addon.js +399 -0
- package/dist/builtins/local-network/local-network.addon.js.map +1 -0
- package/dist/builtins/local-network/local-network.addon.mjs +387 -0
- package/dist/builtins/local-network/local-network.addon.mjs.map +1 -0
- package/dist/builtins/mesh-orchestrator/index.d.ts +2 -0
- package/dist/builtins/mesh-orchestrator/index.d.ts.map +1 -0
- package/dist/builtins/mesh-orchestrator/index.js +7 -0
- package/dist/builtins/mesh-orchestrator/index.mjs +2 -0
- package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.d.ts +9 -0
- package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.d.ts.map +1 -0
- package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.js +83 -0
- package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.js.map +1 -0
- package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.mjs +77 -0
- package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.mjs.map +1 -0
- package/dist/builtins/native-metrics/index.d.ts +3 -0
- package/dist/builtins/native-metrics/index.d.ts.map +1 -0
- package/dist/builtins/native-metrics/native-metrics-provider.d.ts +49 -0
- package/dist/builtins/native-metrics/native-metrics-provider.d.ts.map +1 -0
- package/dist/builtins/native-metrics/native-metrics.addon.d.ts +74 -0
- package/dist/builtins/native-metrics/native-metrics.addon.d.ts.map +1 -0
- package/dist/builtins/native-metrics/native-metrics.addon.js +887 -861
- package/dist/builtins/native-metrics/native-metrics.addon.js.map +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +914 -5
- package/dist/builtins/native-metrics/native-metrics.addon.mjs.map +1 -1
- package/dist/builtins/platform-probe/index.d.ts +12 -0
- package/dist/builtins/platform-probe/index.d.ts.map +1 -0
- package/dist/builtins/platform-probe/index.js +539 -0
- package/dist/builtins/platform-probe/index.js.map +1 -0
- package/dist/builtins/platform-probe/index.mjs +530 -0
- package/dist/builtins/platform-probe/index.mjs.map +1 -0
- package/dist/builtins/platform-probe/inference-config-resolver.d.ts +30 -0
- package/dist/builtins/platform-probe/inference-config-resolver.d.ts.map +1 -0
- package/dist/builtins/platform-probe/platform-scorer.d.ts +22 -0
- package/dist/builtins/platform-probe/platform-scorer.d.ts.map +1 -0
- package/dist/builtins/remote-access-orchestrator/index.d.ts +2 -0
- package/dist/builtins/remote-access-orchestrator/index.d.ts.map +1 -0
- package/dist/builtins/remote-access-orchestrator/index.js +7 -0
- package/dist/builtins/remote-access-orchestrator/index.mjs +2 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.d.ts +9 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.d.ts.map +1 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +72 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js.map +1 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +66 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs.map +1 -0
- package/dist/builtins/snapshot/index.d.ts +3 -0
- package/dist/builtins/snapshot/index.d.ts.map +1 -0
- package/dist/builtins/snapshot/index.js +481 -491
- package/dist/builtins/snapshot/index.js.map +1 -1
- package/dist/builtins/snapshot/index.mjs +475 -464
- package/dist/builtins/snapshot/index.mjs.map +1 -1
- package/dist/builtins/snapshot/snapshot.addon.d.ts +121 -0
- package/dist/builtins/snapshot/snapshot.addon.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/config-store.d.ts +9 -0
- package/dist/builtins/sqlite-storage/config-store.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/device-store.d.ts +24 -0
- package/dist/builtins/sqlite-storage/device-store.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/filesystem-storage-provider.d.ts +87 -0
- package/dist/builtins/sqlite-storage/filesystem-storage-provider.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts +32 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +312 -56
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js.map +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +305 -7
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs.map +1 -1
- package/dist/builtins/sqlite-storage/index.d.ts +12 -0
- package/dist/builtins/sqlite-storage/index.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/index.js +229 -1001
- package/dist/builtins/sqlite-storage/index.js.map +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +268 -26
- package/dist/builtins/sqlite-storage/index.mjs.map +1 -1
- package/dist/builtins/sqlite-storage/integration-registry.d.ts +28 -0
- package/dist/builtins/sqlite-storage/integration-registry.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/settings-store.d.ts +40 -0
- package/dist/builtins/sqlite-storage/settings-store.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/sql-schema.d.ts +33 -0
- package/dist/builtins/sqlite-storage/sql-schema.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +94 -0
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +15 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts.map +1 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +586 -653
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js.map +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +582 -7
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs.map +1 -1
- package/dist/builtins/storage-orchestrator/index.d.ts +7 -0
- package/dist/builtins/storage-orchestrator/index.d.ts.map +1 -0
- package/dist/builtins/storage-orchestrator/index.js +9 -0
- package/dist/builtins/storage-orchestrator/index.mjs +2 -0
- package/dist/builtins/storage-orchestrator/location-store.d.ts +50 -0
- package/dist/builtins/storage-orchestrator/location-store.d.ts.map +1 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +60 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts.map +1 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +755 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js.map +1 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +746 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs.map +1 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +121 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts.map +1 -0
- package/dist/builtins/system-backup/system-backup.service.d.ts +138 -0
- package/dist/builtins/system-backup/system-backup.service.d.ts.map +1 -0
- package/dist/builtins/system-config/index.d.ts +2 -0
- package/dist/builtins/system-config/index.d.ts.map +1 -0
- package/dist/builtins/system-config/index.js +6 -188
- package/dist/builtins/system-config/index.mjs +2 -10
- package/dist/builtins/system-config/system-config.addon.d.ts +11 -0
- package/dist/builtins/system-config/system-config.addon.d.ts.map +1 -0
- package/dist/builtins/system-config/system-config.addon.js +227 -180
- package/dist/builtins/system-config/system-config.addon.js.map +1 -1
- package/dist/builtins/system-config/system-config.addon.mjs +226 -7
- package/dist/builtins/system-config/system-config.addon.mjs.map +1 -1
- package/dist/builtins/turn-orchestrator/index.d.ts +2 -0
- package/dist/builtins/turn-orchestrator/index.d.ts.map +1 -0
- package/dist/builtins/turn-orchestrator/index.js +7 -0
- package/dist/builtins/turn-orchestrator/index.mjs +2 -0
- package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.d.ts +10 -0
- package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.d.ts.map +1 -0
- package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.js +78 -0
- package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.js.map +1 -0
- package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.mjs +72 -0
- package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.mjs.map +1 -0
- package/dist/builtins/winston-logging/index.d.ts +4 -0
- package/dist/builtins/winston-logging/index.d.ts.map +1 -0
- package/dist/builtins/winston-logging/index.js +153 -300
- package/dist/builtins/winston-logging/index.js.map +1 -1
- package/dist/builtins/winston-logging/index.mjs +144 -9
- package/dist/builtins/winston-logging/index.mjs.map +1 -1
- package/dist/builtins/winston-logging/winston-destination.d.ts +22 -0
- package/dist/builtins/winston-logging/winston-destination.d.ts.map +1 -0
- package/dist/builtins/winston-logging/winston-logging.addon.d.ts +20 -0
- package/dist/builtins/winston-logging/winston-logging.addon.d.ts.map +1 -0
- package/dist/chunk-C13QxCFV.js +50 -0
- package/dist/chunk-hT5z_Zn9.mjs +35 -0
- package/dist/download/model-download-service.d.ts +42 -0
- package/dist/download/model-download-service.d.ts.map +1 -0
- package/dist/download/model-downloader.d.ts +32 -0
- package/dist/download/model-downloader.d.ts.map +1 -0
- package/dist/events/event-bus.d.ts +11 -0
- package/dist/events/event-bus.d.ts.map +1 -0
- package/dist/events/system-event-bus.d.ts +15 -0
- package/dist/events/system-event-bus.d.ts.map +1 -0
- package/dist/feature/feature-manager.d.ts +12 -0
- package/dist/feature/feature-manager.d.ts.map +1 -0
- package/dist/formatter-C-5An4Bl.mjs +164 -0
- package/dist/formatter-C-5An4Bl.mjs.map +1 -0
- package/dist/formatter-Dr_6NNZc.js +169 -0
- package/dist/formatter-Dr_6NNZc.js.map +1 -0
- package/dist/index.d.ts +76 -1696
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7780 -8035
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7707 -2148
- package/dist/index.mjs.map +1 -1
- package/dist/lifecycle/lifecycle-state-machine.d.ts +29 -0
- package/dist/lifecycle/lifecycle-state-machine.d.ts.map +1 -0
- package/dist/logging/formatter.d.ts +31 -0
- package/dist/logging/formatter.d.ts.map +1 -0
- package/dist/logging/log-manager.d.ts +52 -0
- package/dist/logging/log-manager.d.ts.map +1 -0
- package/dist/logging/log-ring-buffer.d.ts +48 -0
- package/dist/logging/log-ring-buffer.d.ts.map +1 -0
- package/dist/logging/scoped-logger.d.ts +18 -0
- package/dist/logging/scoped-logger.d.ts.map +1 -0
- package/dist/network/network-quality.d.ts +12 -0
- package/dist/network/network-quality.d.ts.map +1 -0
- package/dist/notification/notification-service.d.ts +38 -0
- package/dist/notification/notification-service.d.ts.map +1 -0
- package/dist/notification/toast-service.d.ts +23 -0
- package/dist/notification/toast-service.d.ts.map +1 -0
- package/dist/pipeline/engine-manager-resolver.d.ts +16 -0
- package/dist/pipeline/engine-manager-resolver.d.ts.map +1 -0
- package/dist/pipeline/pipeline-runner.d.ts +9 -0
- package/dist/pipeline/pipeline-runner.d.ts.map +1 -0
- package/dist/pipeline/pipeline-validator.d.ts +14 -0
- package/dist/pipeline/pipeline-validator.d.ts.map +1 -0
- package/dist/process/resource-monitor.d.ts +12 -0
- package/dist/process/resource-monitor.d.ts.map +1 -0
- package/dist/python/python-env-manager.d.ts +13 -0
- package/dist/python/python-env-manager.d.ts.map +1 -0
- package/dist/repl/interfaces.d.ts +32 -0
- package/dist/repl/interfaces.d.ts.map +1 -0
- package/dist/repl/repl-engine.d.ts +9 -0
- package/dist/repl/repl-engine.d.ts.map +1 -0
- package/dist/resource-monitor-CmuWlmap.js +76 -0
- package/dist/resource-monitor-CmuWlmap.js.map +1 -0
- package/dist/resource-monitor-DcQdKGYU.mjs +59 -0
- package/dist/resource-monitor-DcQdKGYU.mjs.map +1 -0
- package/dist/storage/fs-storage-backend.d.ts +41 -0
- package/dist/storage/fs-storage-backend.d.ts.map +1 -0
- package/dist/storage/storage-location-manager.d.ts +24 -0
- package/dist/storage/storage-location-manager.d.ts.map +1 -0
- package/dist/storage/storage-manager.d.ts +77 -0
- package/dist/storage/storage-manager.d.ts.map +1 -0
- package/dist/tls/cert-manager.d.ts +27 -0
- package/dist/tls/cert-manager.d.ts.map +1 -0
- package/dist/tls/index.d.ts +2 -0
- package/dist/tls/index.d.ts.map +1 -0
- package/package.json +119 -23
- package/dist/builtins/addon-pages-aggregator/index.js.map +0 -1
- package/dist/builtins/addon-pages-aggregator/index.mjs.map +0 -1
- package/dist/builtins/addon-widgets-aggregator/index.js.map +0 -1
- package/dist/builtins/addon-widgets-aggregator/index.mjs.map +0 -1
- package/dist/builtins/alerts/index.js.map +0 -1
- package/dist/builtins/alerts/index.mjs.map +0 -1
- package/dist/builtins/device-manager/index.js.map +0 -1
- package/dist/builtins/device-manager/index.mjs.map +0 -1
- package/dist/builtins/local-auth/index.js.map +0 -1
- package/dist/builtins/local-auth/index.mjs.map +0 -1
- package/dist/builtins/local-backup/index.js +0 -173
- package/dist/builtins/local-backup/index.js.map +0 -1
- package/dist/builtins/local-backup/index.mjs +0 -10
- package/dist/builtins/local-backup/index.mjs.map +0 -1
- package/dist/builtins/system-config/index.js.map +0 -1
- package/dist/builtins/system-config/index.mjs.map +0 -1
- package/dist/chunk-2CIYKDRN.mjs +0 -1
- package/dist/chunk-2CIYKDRN.mjs.map +0 -1
- package/dist/chunk-2F76X6NL.mjs +0 -136
- package/dist/chunk-2F76X6NL.mjs.map +0 -1
- package/dist/chunk-2QUFBZ7M.mjs +0 -1
- package/dist/chunk-2QUFBZ7M.mjs.map +0 -1
- package/dist/chunk-3BK2Y7GY.mjs +0 -593
- package/dist/chunk-3BK2Y7GY.mjs.map +0 -1
- package/dist/chunk-4OOHFJHT.mjs +0 -421
- package/dist/chunk-4OOHFJHT.mjs.map +0 -1
- package/dist/chunk-4XHB7IHT.mjs +0 -809
- package/dist/chunk-4XHB7IHT.mjs.map +0 -1
- package/dist/chunk-6M2HSSTQ.mjs +0 -98
- package/dist/chunk-6M2HSSTQ.mjs.map +0 -1
- package/dist/chunk-7FI7SQS7.mjs +0 -135
- package/dist/chunk-7FI7SQS7.mjs.map +0 -1
- package/dist/chunk-ED57RCQE.mjs +0 -171
- package/dist/chunk-ED57RCQE.mjs.map +0 -1
- package/dist/chunk-FZN56HGQ.mjs +0 -626
- package/dist/chunk-FZN56HGQ.mjs.map +0 -1
- package/dist/chunk-GL4OOB25.mjs +0 -51
- package/dist/chunk-GL4OOB25.mjs.map +0 -1
- package/dist/chunk-KDG2NTDB.mjs +0 -137
- package/dist/chunk-KDG2NTDB.mjs.map +0 -1
- package/dist/chunk-NRBQWBDM.mjs +0 -191
- package/dist/chunk-NRBQWBDM.mjs.map +0 -1
- package/dist/chunk-O4V246GG.mjs +0 -2137
- package/dist/chunk-O4V246GG.mjs.map +0 -1
- package/dist/chunk-QT57H266.mjs +0 -163
- package/dist/chunk-QT57H266.mjs.map +0 -1
- package/dist/chunk-QX4RH25I.mjs +0 -141
- package/dist/chunk-QX4RH25I.mjs.map +0 -1
- package/dist/chunk-TB562PZX.mjs +0 -86
- package/dist/chunk-TB562PZX.mjs.map +0 -1
- package/dist/chunk-TDYPZXK5.mjs +0 -1
- package/dist/chunk-TDYPZXK5.mjs.map +0 -1
- package/dist/chunk-UJI4LN5P.mjs +0 -36
- package/dist/chunk-UJI4LN5P.mjs.map +0 -1
- package/dist/chunk-W6RTHQGP.mjs +0 -1
- package/dist/chunk-W6RTHQGP.mjs.map +0 -1
- package/dist/chunk-ZELBCPDC.mjs +0 -369
- package/dist/chunk-ZELBCPDC.mjs.map +0 -1
- package/dist/index.d.mts +0 -1696
- package/dist/resource-monitor-UZUGPIAU.mjs +0 -9
- package/dist/resource-monitor-UZUGPIAU.mjs.map +0 -1
- package/dist/storage-location-manager-HFNB3PCS.mjs +0 -7
- package/dist/storage-location-manager-HFNB3PCS.mjs.map +0 -1
|
@@ -1,7 +1,916 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
} from "
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { BaseAddon, EventCategory, createEvent, metricsProviderCapability } from "@camstack/types";
|
|
5
|
+
import * as os from "node:os";
|
|
6
|
+
//#region src/builtins/native-metrics/native-metrics-provider.ts
|
|
7
|
+
var IS_DARWIN = os.platform() === "darwin";
|
|
8
|
+
var IS_LINUX = os.platform() === "linux";
|
|
9
|
+
var NativeMetricsProvider = class {
|
|
10
|
+
id = "native";
|
|
11
|
+
cachedSnapshot = null;
|
|
12
|
+
samplingTimer = null;
|
|
13
|
+
macMemTimer = null;
|
|
14
|
+
prevCpu;
|
|
15
|
+
diagnostics = null;
|
|
16
|
+
consecutiveSampleErrors = 0;
|
|
17
|
+
constructor() {
|
|
18
|
+
this.prevCpu = aggregateCpuTimes();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Optional diagnostics sink for sampling errors. The first failure and
|
|
22
|
+
* every Nth failure thereafter are reported so a permanently-broken
|
|
23
|
+
* collector doesn't spam logs but is still observable.
|
|
24
|
+
*/
|
|
25
|
+
setDiagnostics(diag) {
|
|
26
|
+
this.diagnostics = diag;
|
|
27
|
+
}
|
|
28
|
+
startSampling(intervalMs) {
|
|
29
|
+
if (IS_DARWIN) {
|
|
30
|
+
sampleMacMemory(this);
|
|
31
|
+
this.macMemTimer = setInterval(() => sampleMacMemory(this), 5e3);
|
|
32
|
+
if (this.macMemTimer.unref) this.macMemTimer.unref();
|
|
33
|
+
}
|
|
34
|
+
this.collectSnapshot().then((s) => {
|
|
35
|
+
this.cachedSnapshot = s;
|
|
36
|
+
this.consecutiveSampleErrors = 0;
|
|
37
|
+
}).catch((err) => this.reportSampleError(err));
|
|
38
|
+
this.samplingTimer = setInterval(() => {
|
|
39
|
+
this.collectSnapshot().then((s) => {
|
|
40
|
+
this.cachedSnapshot = s;
|
|
41
|
+
this.consecutiveSampleErrors = 0;
|
|
42
|
+
}).catch((err) => this.reportSampleError(err));
|
|
43
|
+
}, intervalMs);
|
|
44
|
+
if (this.samplingTimer.unref) this.samplingTimer.unref();
|
|
45
|
+
}
|
|
46
|
+
reportSampleError(err) {
|
|
47
|
+
this.consecutiveSampleErrors++;
|
|
48
|
+
if (!this.diagnostics) return;
|
|
49
|
+
if (!(this.consecutiveSampleErrors === 1 || this.consecutiveSampleErrors % 60 === 0)) return;
|
|
50
|
+
this.diagnostics.warn("metrics-provider sample failed", {
|
|
51
|
+
consecutiveErrors: this.consecutiveSampleErrors,
|
|
52
|
+
error: err instanceof Error ? err.message : String(err)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
stopSampling() {
|
|
56
|
+
if (this.samplingTimer) {
|
|
57
|
+
clearInterval(this.samplingTimer);
|
|
58
|
+
this.samplingTimer = null;
|
|
59
|
+
}
|
|
60
|
+
if (this.macMemTimer) {
|
|
61
|
+
clearInterval(this.macMemTimer);
|
|
62
|
+
this.macMemTimer = null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async collectSnapshot() {
|
|
66
|
+
const cpu = this.sampleCpu();
|
|
67
|
+
const memory = this.getMemoryInfo();
|
|
68
|
+
const processInfo = getProcessResources();
|
|
69
|
+
const [gpu, network, disk, cpuTemp] = await Promise.all([
|
|
70
|
+
getGpuInfoInternal().catch(() => null),
|
|
71
|
+
takeNetworkIoSnapshot(),
|
|
72
|
+
takeDiskIoSnapshot(),
|
|
73
|
+
getCpuTemperatureInternal().catch(() => null)
|
|
74
|
+
]);
|
|
75
|
+
const snapshot = {
|
|
76
|
+
cpu,
|
|
77
|
+
memory,
|
|
78
|
+
gpu,
|
|
79
|
+
network,
|
|
80
|
+
disk,
|
|
81
|
+
pressure: {
|
|
82
|
+
cpu: getPressure("cpu"),
|
|
83
|
+
memory: getPressure("memory"),
|
|
84
|
+
io: getPressure("io")
|
|
85
|
+
},
|
|
86
|
+
process: processInfo,
|
|
87
|
+
cpuTemperature: cpuTemp,
|
|
88
|
+
timestampMs: Date.now()
|
|
89
|
+
};
|
|
90
|
+
this.cachedSnapshot = snapshot;
|
|
91
|
+
return snapshot;
|
|
92
|
+
}
|
|
93
|
+
async getCached() {
|
|
94
|
+
return this.cachedSnapshot;
|
|
95
|
+
}
|
|
96
|
+
async getCurrent() {
|
|
97
|
+
const s = this.cachedSnapshot ?? await this.collectSnapshot();
|
|
98
|
+
const mb = (bytes) => Math.round(bytes / 1024 / 1024);
|
|
99
|
+
return {
|
|
100
|
+
cpuPercent: s.cpu.total,
|
|
101
|
+
memoryPercent: s.memory.percent,
|
|
102
|
+
memoryUsedMB: mb(s.memory.usedBytes),
|
|
103
|
+
memoryTotalMB: mb(s.memory.totalBytes),
|
|
104
|
+
temperature: s.cpuTemperature ?? void 0,
|
|
105
|
+
gpuPercent: s.gpu?.utilization,
|
|
106
|
+
gpuMemoryPercent: s.gpu && s.gpu.memoryTotalBytes > 0 ? Math.round(s.gpu.memoryUsedBytes / s.gpu.memoryTotalBytes * 1e3) / 10 : void 0
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
async getDiskSpace(input) {
|
|
110
|
+
return getDiskSpaceInternal(input.dirPath);
|
|
111
|
+
}
|
|
112
|
+
async getGpuInfo() {
|
|
113
|
+
return getGpuInfoInternal();
|
|
114
|
+
}
|
|
115
|
+
async getCpuTemperature() {
|
|
116
|
+
return getCpuTemperatureInternal();
|
|
117
|
+
}
|
|
118
|
+
async getProcessStats(input) {
|
|
119
|
+
const { getPidStats } = await import("../../resource-monitor-DcQdKGYU.mjs").then((n) => n.r);
|
|
120
|
+
const raw = await getPidStats(input.pids);
|
|
121
|
+
const result = [];
|
|
122
|
+
for (const [pid, s] of raw) result.push({
|
|
123
|
+
pid,
|
|
124
|
+
cpu: s.cpu,
|
|
125
|
+
memory: s.memory
|
|
126
|
+
});
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
sampleCpu() {
|
|
130
|
+
const curr = aggregateCpuTimes();
|
|
131
|
+
const prev = this.prevCpu;
|
|
132
|
+
this.prevCpu = curr;
|
|
133
|
+
const dUser = curr.user - prev.user;
|
|
134
|
+
const dNice = curr.nice - prev.nice;
|
|
135
|
+
const dSys = curr.sys - prev.sys;
|
|
136
|
+
const dIrq = curr.irq - prev.irq;
|
|
137
|
+
const dIdle = curr.idle - prev.idle;
|
|
138
|
+
const dTotal = dUser + dNice + dSys + dIrq + dIdle;
|
|
139
|
+
const pct = (v) => dTotal === 0 ? 0 : Math.round(v / dTotal * 1e3) / 10;
|
|
140
|
+
return {
|
|
141
|
+
total: pct(dUser + dNice + dSys + dIrq),
|
|
142
|
+
user: pct(dUser),
|
|
143
|
+
system: pct(dSys),
|
|
144
|
+
irq: pct(dIrq),
|
|
145
|
+
nice: pct(dNice),
|
|
146
|
+
loadAvg: os.loadavg(),
|
|
147
|
+
cores: os.cpus().length
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Cached macOS memory (set by sampleMacMemory timer). */
|
|
151
|
+
_cachedMacMem = null;
|
|
152
|
+
getMemoryInfo() {
|
|
153
|
+
const total = os.totalmem();
|
|
154
|
+
if (total === 0) return {
|
|
155
|
+
percent: 0,
|
|
156
|
+
totalBytes: 0,
|
|
157
|
+
usedBytes: 0,
|
|
158
|
+
availableBytes: 0,
|
|
159
|
+
swapUsedBytes: 0,
|
|
160
|
+
swapTotalBytes: 0
|
|
161
|
+
};
|
|
162
|
+
if (IS_DARWIN && this._cachedMacMem !== null) return this._cachedMacMem;
|
|
163
|
+
const free = os.freemem();
|
|
164
|
+
const used = total - free;
|
|
165
|
+
let swapUsedBytes = 0;
|
|
166
|
+
let swapTotalBytes = 0;
|
|
167
|
+
if (IS_LINUX) try {
|
|
168
|
+
const meminfo = fs.readFileSync("/proc/meminfo", "utf-8");
|
|
169
|
+
const swapTotal = parseInt(meminfo.match(/SwapTotal:\s+(\d+)/)?.[1] ?? "0", 10) * 1024;
|
|
170
|
+
const swapFree = parseInt(meminfo.match(/SwapFree:\s+(\d+)/)?.[1] ?? "0", 10) * 1024;
|
|
171
|
+
swapTotalBytes = swapTotal;
|
|
172
|
+
swapUsedBytes = swapTotal - swapFree;
|
|
173
|
+
} catch {}
|
|
174
|
+
return {
|
|
175
|
+
percent: Math.round((total - free) / total * 1e3) / 10,
|
|
176
|
+
totalBytes: total,
|
|
177
|
+
usedBytes: used,
|
|
178
|
+
availableBytes: free,
|
|
179
|
+
swapUsedBytes,
|
|
180
|
+
swapTotalBytes
|
|
181
|
+
};
|
|
182
|
+
}
|
|
6
183
|
};
|
|
184
|
+
function aggregateCpuTimes() {
|
|
185
|
+
const cpus = os.cpus();
|
|
186
|
+
let user = 0, nice = 0, sys = 0, irq = 0, idle = 0;
|
|
187
|
+
for (const cpu of cpus) {
|
|
188
|
+
user += cpu.times.user;
|
|
189
|
+
nice += cpu.times.nice;
|
|
190
|
+
sys += cpu.times.sys;
|
|
191
|
+
irq += cpu.times.irq;
|
|
192
|
+
idle += cpu.times.idle;
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
user,
|
|
196
|
+
nice,
|
|
197
|
+
sys,
|
|
198
|
+
irq,
|
|
199
|
+
idle
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function sampleMacMemory(provider) {
|
|
203
|
+
try {
|
|
204
|
+
const output = execFileSync("vm_stat", {
|
|
205
|
+
timeout: 2e3,
|
|
206
|
+
encoding: "utf-8"
|
|
207
|
+
});
|
|
208
|
+
const pageSize = 16384;
|
|
209
|
+
const parse = (label) => {
|
|
210
|
+
const match = output.match(new RegExp(`${label}:\\s+(\\d+)`));
|
|
211
|
+
return match ? parseInt(match[1], 10) * pageSize : 0;
|
|
212
|
+
};
|
|
213
|
+
const free = parse("Pages free");
|
|
214
|
+
const inactive = parse("Pages inactive");
|
|
215
|
+
const purgeable = parse("Pages purgeable");
|
|
216
|
+
const speculative = parse("Pages speculative");
|
|
217
|
+
const available = free + inactive + purgeable + speculative;
|
|
218
|
+
const total = os.totalmem();
|
|
219
|
+
const used = total - available;
|
|
220
|
+
let swapUsedBytes = 0;
|
|
221
|
+
let swapTotalBytes = 0;
|
|
222
|
+
try {
|
|
223
|
+
const swapOut = execFileSync("sysctl", ["-n", "vm.swapusage"], {
|
|
224
|
+
timeout: 2e3,
|
|
225
|
+
encoding: "utf-8"
|
|
226
|
+
});
|
|
227
|
+
const totalMatch = swapOut.match(/total\s*=\s*([\d.]+)M/);
|
|
228
|
+
const usedMatch = swapOut.match(/used\s*=\s*([\d.]+)M/);
|
|
229
|
+
if (totalMatch) swapTotalBytes = parseFloat(totalMatch[1]) * 1024 * 1024;
|
|
230
|
+
if (usedMatch) swapUsedBytes = parseFloat(usedMatch[1]) * 1024 * 1024;
|
|
231
|
+
} catch {}
|
|
232
|
+
provider._cachedMacMem = {
|
|
233
|
+
percent: Math.round(used / total * 1e3) / 10,
|
|
234
|
+
totalBytes: total,
|
|
235
|
+
usedBytes: used,
|
|
236
|
+
availableBytes: available,
|
|
237
|
+
swapUsedBytes,
|
|
238
|
+
swapTotalBytes
|
|
239
|
+
};
|
|
240
|
+
} catch {
|
|
241
|
+
provider._cachedMacMem = null;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function getDiskSpaceInternal(dirPath) {
|
|
245
|
+
return new Promise((resolve, reject) => {
|
|
246
|
+
fs.statfs(dirPath, (err, stats) => {
|
|
247
|
+
if (err) return reject(err);
|
|
248
|
+
const totalBytes = stats.blocks * stats.bsize;
|
|
249
|
+
const availableBytes = stats.bavail * stats.bsize;
|
|
250
|
+
const usedBytes = totalBytes - stats.bfree * stats.bsize;
|
|
251
|
+
resolve({
|
|
252
|
+
path: dirPath,
|
|
253
|
+
totalBytes,
|
|
254
|
+
usedBytes,
|
|
255
|
+
availableBytes,
|
|
256
|
+
percent: totalBytes > 0 ? Math.round(usedBytes / totalBytes * 1e3) / 10 : 0
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
async function takeDiskIoSnapshot() {
|
|
262
|
+
const now = Date.now();
|
|
263
|
+
if (IS_LINUX) try {
|
|
264
|
+
const data = fs.readFileSync("/proc/diskstats", "utf-8");
|
|
265
|
+
let readOps = 0, readBytes = 0, writeOps = 0, writeBytes = 0;
|
|
266
|
+
for (const line of data.split("\n")) {
|
|
267
|
+
const parts = line.trim().split(/\s+/);
|
|
268
|
+
if (parts.length < 14) continue;
|
|
269
|
+
const devName = parts[2];
|
|
270
|
+
if (/\d+$/.test(devName) && !/^nvme\d+n\d+$/.test(devName)) continue;
|
|
271
|
+
readOps += parseInt(parts[3], 10) || 0;
|
|
272
|
+
readBytes += (parseInt(parts[5], 10) || 0) * 512;
|
|
273
|
+
writeOps += parseInt(parts[7], 10) || 0;
|
|
274
|
+
writeBytes += (parseInt(parts[9], 10) || 0) * 512;
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
readBytes,
|
|
278
|
+
writeBytes,
|
|
279
|
+
readOps,
|
|
280
|
+
writeOps,
|
|
281
|
+
timestampMs: now
|
|
282
|
+
};
|
|
283
|
+
} catch {}
|
|
284
|
+
return {
|
|
285
|
+
readBytes: 0,
|
|
286
|
+
writeBytes: 0,
|
|
287
|
+
readOps: 0,
|
|
288
|
+
writeOps: 0,
|
|
289
|
+
timestampMs: now
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
async function takeNetworkIoSnapshot() {
|
|
293
|
+
const now = Date.now();
|
|
294
|
+
if (IS_LINUX) try {
|
|
295
|
+
const data = fs.readFileSync("/proc/net/dev", "utf-8");
|
|
296
|
+
let rxBytes = 0, txBytes = 0, rxPackets = 0, txPackets = 0, rxErrors = 0, txErrors = 0;
|
|
297
|
+
for (const line of data.split("\n")) {
|
|
298
|
+
const match = line.match(/^\s*(\w+):\s+(.+)$/);
|
|
299
|
+
if (!match) continue;
|
|
300
|
+
if (match[1] === "lo") continue;
|
|
301
|
+
const cols = match[2].trim().split(/\s+/);
|
|
302
|
+
rxBytes += parseInt(cols[0], 10) || 0;
|
|
303
|
+
rxPackets += parseInt(cols[1], 10) || 0;
|
|
304
|
+
rxErrors += parseInt(cols[2], 10) || 0;
|
|
305
|
+
txBytes += parseInt(cols[8], 10) || 0;
|
|
306
|
+
txPackets += parseInt(cols[9], 10) || 0;
|
|
307
|
+
txErrors += parseInt(cols[10], 10) || 0;
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
rxBytes,
|
|
311
|
+
txBytes,
|
|
312
|
+
rxPackets,
|
|
313
|
+
txPackets,
|
|
314
|
+
rxErrors,
|
|
315
|
+
txErrors,
|
|
316
|
+
timestampMs: now
|
|
317
|
+
};
|
|
318
|
+
} catch {}
|
|
319
|
+
if (IS_DARWIN) try {
|
|
320
|
+
const stdout = await execAsync("netstat", ["-ib"]);
|
|
321
|
+
let rxBytes = 0, txBytes = 0, rxPackets = 0, txPackets = 0, rxErrors = 0, txErrors = 0;
|
|
322
|
+
for (const line of stdout.split("\n")) {
|
|
323
|
+
const parts = line.trim().split(/\s+/);
|
|
324
|
+
if (parts.length < 11) continue;
|
|
325
|
+
if (parts[0] === "lo0" || parts[0] === "Name") continue;
|
|
326
|
+
if (!parts[2]?.startsWith("Link#")) continue;
|
|
327
|
+
rxPackets += parseInt(parts[4], 10) || 0;
|
|
328
|
+
rxErrors += parseInt(parts[5], 10) || 0;
|
|
329
|
+
rxBytes += parseInt(parts[6], 10) || 0;
|
|
330
|
+
txPackets += parseInt(parts[7], 10) || 0;
|
|
331
|
+
txErrors += parseInt(parts[8], 10) || 0;
|
|
332
|
+
txBytes += parseInt(parts[9], 10) || 0;
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
rxBytes,
|
|
336
|
+
txBytes,
|
|
337
|
+
rxPackets,
|
|
338
|
+
txPackets,
|
|
339
|
+
rxErrors,
|
|
340
|
+
txErrors,
|
|
341
|
+
timestampMs: now
|
|
342
|
+
};
|
|
343
|
+
} catch {}
|
|
344
|
+
return {
|
|
345
|
+
rxBytes: 0,
|
|
346
|
+
txBytes: 0,
|
|
347
|
+
rxPackets: 0,
|
|
348
|
+
txPackets: 0,
|
|
349
|
+
rxErrors: 0,
|
|
350
|
+
txErrors: 0,
|
|
351
|
+
timestampMs: now
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
async function getCpuTemperatureInternal() {
|
|
355
|
+
if (IS_LINUX) for (const p of ["/sys/class/thermal/thermal_zone0/temp", "/sys/class/hwmon/hwmon0/temp1_input"]) try {
|
|
356
|
+
const raw = fs.readFileSync(p, "utf-8").trim();
|
|
357
|
+
const millideg = parseInt(raw, 10);
|
|
358
|
+
if (!isNaN(millideg)) return Math.round(millideg / 100) / 10;
|
|
359
|
+
} catch {
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (IS_DARWIN) try {
|
|
363
|
+
const match = (await execAsync("sudo", [
|
|
364
|
+
"-n",
|
|
365
|
+
"powermetrics",
|
|
366
|
+
"--samplers",
|
|
367
|
+
"smc",
|
|
368
|
+
"-i",
|
|
369
|
+
"1",
|
|
370
|
+
"-n",
|
|
371
|
+
"1"
|
|
372
|
+
], 3e3)).match(/CPU die temperature:\s+([\d.]+)\s*C/);
|
|
373
|
+
if (match) return Math.round(parseFloat(match[1]) * 10) / 10;
|
|
374
|
+
} catch {}
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
async function getGpuInfoInternal() {
|
|
378
|
+
if (IS_DARWIN) try {
|
|
379
|
+
const utilMatch = (await execAsync("ioreg", [
|
|
380
|
+
"-r",
|
|
381
|
+
"-d",
|
|
382
|
+
"1",
|
|
383
|
+
"-c",
|
|
384
|
+
"IOAccelerator"
|
|
385
|
+
])).match(/"GPU Core Utilization"\s*=\s*(\d+)/);
|
|
386
|
+
const util = utilMatch ? parseInt(utilMatch[1], 10) : 0;
|
|
387
|
+
const utilPct = util > 1e3 ? Math.round(util / 1e7) : util;
|
|
388
|
+
return {
|
|
389
|
+
utilization: Math.min(100, utilPct),
|
|
390
|
+
model: "Apple Silicon GPU",
|
|
391
|
+
memoryUsedBytes: 0,
|
|
392
|
+
memoryTotalBytes: 0,
|
|
393
|
+
temperature: null
|
|
394
|
+
};
|
|
395
|
+
} catch {}
|
|
396
|
+
if (IS_LINUX) try {
|
|
397
|
+
const parts = (await execAsync("nvidia-smi", ["--query-gpu=utilization.gpu,name,memory.used,memory.total,temperature.gpu", "--format=csv,noheader,nounits"])).trim().split(",").map((s) => s.trim());
|
|
398
|
+
if (parts.length >= 5) return {
|
|
399
|
+
utilization: parseInt(parts[0], 10) || 0,
|
|
400
|
+
model: parts[1] ?? "Unknown GPU",
|
|
401
|
+
memoryUsedBytes: (parseInt(parts[2], 10) || 0) * 1024 * 1024,
|
|
402
|
+
memoryTotalBytes: (parseInt(parts[3], 10) || 0) * 1024 * 1024,
|
|
403
|
+
temperature: parseInt(parts[4], 10) || null
|
|
404
|
+
};
|
|
405
|
+
} catch {}
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
function getProcessResources() {
|
|
409
|
+
let openFds = 0;
|
|
410
|
+
let threadCount = 0;
|
|
411
|
+
if (IS_LINUX) {
|
|
412
|
+
try {
|
|
413
|
+
openFds = fs.readdirSync(`/proc/${process.pid}/fd`).length;
|
|
414
|
+
} catch {}
|
|
415
|
+
try {
|
|
416
|
+
const match = fs.readFileSync(`/proc/${process.pid}/status`, "utf-8").match(/Threads:\s+(\d+)/);
|
|
417
|
+
if (match) threadCount = parseInt(match[1], 10);
|
|
418
|
+
} catch {}
|
|
419
|
+
}
|
|
420
|
+
const nodeProcess = process;
|
|
421
|
+
return {
|
|
422
|
+
openFds,
|
|
423
|
+
threadCount,
|
|
424
|
+
activeHandles: (nodeProcess._getActiveHandles?.() ?? []).length,
|
|
425
|
+
activeRequests: (nodeProcess._getActiveRequests?.() ?? []).length
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
function getPressure(resource) {
|
|
429
|
+
if (!IS_LINUX) return null;
|
|
430
|
+
try {
|
|
431
|
+
const data = fs.readFileSync(`/proc/pressure/${resource}`, "utf-8");
|
|
432
|
+
const parseLine = (prefix) => {
|
|
433
|
+
const match = data.match(new RegExp(`${prefix} avg10=(\\d+\\.\\d+) avg60=(\\d+\\.\\d+) avg300=(\\d+\\.\\d+)`));
|
|
434
|
+
if (!match) return null;
|
|
435
|
+
return {
|
|
436
|
+
avg10: parseFloat(match[1]),
|
|
437
|
+
avg60: parseFloat(match[2]),
|
|
438
|
+
avg300: parseFloat(match[3])
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
const some = parseLine("some");
|
|
442
|
+
if (!some) return null;
|
|
443
|
+
return {
|
|
444
|
+
some,
|
|
445
|
+
full: parseLine("full")
|
|
446
|
+
};
|
|
447
|
+
} catch {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function execAsync(cmd, args, timeoutMs = 5e3) {
|
|
452
|
+
return new Promise((resolve, reject) => {
|
|
453
|
+
execFile(cmd, args, { timeout: timeoutMs }, (err, stdout) => {
|
|
454
|
+
if (err) return reject(err);
|
|
455
|
+
resolve(stdout);
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region src/builtins/native-metrics/native-metrics.addon.ts
|
|
461
|
+
var execFileAsync = promisify(execFile);
|
|
462
|
+
/**
|
|
463
|
+
* Regex matching camstack-related command lines. We surface anything with
|
|
464
|
+
* an obvious camstack fingerprint so operators can spot stray inference
|
|
465
|
+
* pools, leaked tsx watchers, and zombie node workers in the Cluster →
|
|
466
|
+
* Agent → Processes tab.
|
|
467
|
+
*
|
|
468
|
+
* Patterns mirror `scripts/hunt-zombies.sh` — keep them in sync when
|
|
469
|
+
* adding a new long-lived subprocess.
|
|
470
|
+
*/
|
|
471
|
+
var CAMSTACK_CMD_RE = /(camstack|tsx\s+watch\s.*launcher\.ts|packages\/agent\/dist\/cli\.js|inference_pool\.py|bench-(inference-pool|nodeav)|node .*\/packages\/)/;
|
|
472
|
+
/**
|
|
473
|
+
* Boundary patterns: ancestry walks that pass through a process whose
|
|
474
|
+
* command line matches one of these are considered to be inside an
|
|
475
|
+
* "intentional camstack tree". Anything reachable by walking up the
|
|
476
|
+
* pid tree from such a boundary is `system` — not a ghost.
|
|
477
|
+
*
|
|
478
|
+
* The boundaries are:
|
|
479
|
+
* - `tsx watch .../launcher.ts` — hub launcher (npm run dev:server)
|
|
480
|
+
* - `node .../packages/agent/dist/cli.js` — agent CLI (dev-cluster, npm run dev:agent)
|
|
481
|
+
* - `concurrently` — dev-cluster orchestrator that runs hub + admin-ui + agents
|
|
482
|
+
* - `npm exec ` / `npm-cli.js` — npm wrappers driving the above
|
|
483
|
+
* - `vite` — admin-ui dev server (sibling of hub under concurrently)
|
|
484
|
+
*
|
|
485
|
+
* The classification logic (`classifyByAncestry`) walks each candidate
|
|
486
|
+
* pid up to ppid=1; if any ancestor matches this regex, the candidate
|
|
487
|
+
* is `system`. Reaching ppid=1 without crossing a boundary = `ghost`.
|
|
488
|
+
*/
|
|
489
|
+
var SUPERVISOR_BOUNDARY_RE = /(tsx\s+watch\s.*launcher\.ts|packages\/agent\/dist\/cli\.js|\.bin\/concurrently|\/concurrently\/dist|\bnpm-cli\.js\b|npm exec |\.bin\/vite|\/vite\/bin\/vite\.js|node_modules\/\.bin\/(vite|concurrently|tsup|rollup|esbuild|tsx)(\s|$))/;
|
|
490
|
+
/**
|
|
491
|
+
* Cadence for the per-node metric snapshot bus events. ~5 s matches
|
|
492
|
+
* the existing UI polling cadence (ProcessesTab, ProcessResources)
|
|
493
|
+
* and stays within the sampling interval so consumers always see a
|
|
494
|
+
* fresh-from-OS payload.
|
|
495
|
+
*/
|
|
496
|
+
var METRICS_SNAPSHOT_INTERVAL_MS = 5e3;
|
|
497
|
+
/**
|
|
498
|
+
* Force a metrics-snapshot emit at least every 60s even when the
|
|
499
|
+
* coarsened payload looks unchanged. Without this an idle node
|
|
500
|
+
* (steady CPU within ±5%, no process churn) goes silent on the
|
|
501
|
+
* bus and the UI's "node alive" chip can stale out.
|
|
502
|
+
*/
|
|
503
|
+
var METRICS_SNAPSHOT_HEARTBEAT_MS = 6e4;
|
|
504
|
+
/**
|
|
505
|
+
* Coarsen CPU/mem percentages to integer buckets before deduping.
|
|
506
|
+
* Without this every 5s tick differs by ±0.3% and the equality check
|
|
507
|
+
* always fails, so the snapshot fans out unconditionally.
|
|
508
|
+
*/
|
|
509
|
+
function coarsenResourcesSnapshot(snapshot) {
|
|
510
|
+
if (!snapshot || typeof snapshot !== "object") return JSON.stringify(snapshot);
|
|
511
|
+
const round = (v) => {
|
|
512
|
+
if (typeof v === "number") {
|
|
513
|
+
if (v >= 0 && v <= 100) return Math.round(v / 5) * 5;
|
|
514
|
+
return Math.round(v / 1e5) * 1e5;
|
|
515
|
+
}
|
|
516
|
+
if (Array.isArray(v)) return v.map(round);
|
|
517
|
+
if (v && typeof v === "object") {
|
|
518
|
+
const out = {};
|
|
519
|
+
for (const [k, val] of Object.entries(v)) out[k] = round(val);
|
|
520
|
+
return out;
|
|
521
|
+
}
|
|
522
|
+
return v;
|
|
523
|
+
};
|
|
524
|
+
return JSON.stringify(round(snapshot));
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Coarsen a process list before deduping — pid, addonId, state +
|
|
528
|
+
* bucketed cpu%. Drops cmdline / cwd / start time / uptime which
|
|
529
|
+
* change every tick on a process that's just running. The result
|
|
530
|
+
* is "process X has the same role and roughly the same load" =
|
|
531
|
+
* skip emit.
|
|
532
|
+
*/
|
|
533
|
+
function coarsenProcessList(processes) {
|
|
534
|
+
const summary = processes.filter((p) => !!p && typeof p === "object").map((p) => {
|
|
535
|
+
return [
|
|
536
|
+
p["pid"],
|
|
537
|
+
p["addonId"],
|
|
538
|
+
p["state"],
|
|
539
|
+
typeof p["cpuPercent"] === "number" ? Math.round(p["cpuPercent"] / 5) * 5 : null,
|
|
540
|
+
typeof p["memoryRss"] === "number" ? Math.round(p["memoryRss"] / (50 * 1024 * 1024)) : null
|
|
541
|
+
];
|
|
542
|
+
});
|
|
543
|
+
return JSON.stringify(summary);
|
|
544
|
+
}
|
|
545
|
+
function narrowWorkerState(state) {
|
|
546
|
+
switch (state) {
|
|
547
|
+
case "starting":
|
|
548
|
+
case "running":
|
|
549
|
+
case "stopping":
|
|
550
|
+
case "stopped":
|
|
551
|
+
case "crashed": return state;
|
|
552
|
+
default: return "running";
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Native metrics — CPU, memory, disk usage sampling.
|
|
557
|
+
* Settings appear under Cluster → NodeDetail → Settings.
|
|
558
|
+
*/
|
|
559
|
+
var NativeMetricsAddon = class extends BaseAddon {
|
|
560
|
+
provider = null;
|
|
561
|
+
startedAtMs = Date.now();
|
|
562
|
+
snapshotTimer = null;
|
|
563
|
+
/**
|
|
564
|
+
* Snapshot-equality cache for the resources + processes emit.
|
|
565
|
+
* Stores the coarsened JSON and timestamp; a tick where the
|
|
566
|
+
* coarsened payload matches the cache (and the heartbeat hasn't
|
|
567
|
+
* elapsed) is skipped.
|
|
568
|
+
*/
|
|
569
|
+
lastResourcesEmit = null;
|
|
570
|
+
lastProcessesEmit = null;
|
|
571
|
+
constructor() {
|
|
572
|
+
super({ samplingIntervalMs: 5e3 });
|
|
573
|
+
}
|
|
574
|
+
async onInitialize() {
|
|
575
|
+
const provider = new NativeMetricsProvider();
|
|
576
|
+
provider.setDiagnostics({ warn: (message, meta) => this.ctx.logger.warn(message, { meta: meta ?? {} }) });
|
|
577
|
+
provider.startSampling(this.config.samplingIntervalMs);
|
|
578
|
+
this.provider = provider;
|
|
579
|
+
this.startedAtMs = Date.now();
|
|
580
|
+
this.ctx.logger.info("Native metrics provider started", { meta: { intervalMs: this.config.samplingIntervalMs } });
|
|
581
|
+
const composed = {
|
|
582
|
+
collectSnapshot: () => provider.collectSnapshot(),
|
|
583
|
+
getCached: () => provider.getCached(),
|
|
584
|
+
getCurrent: () => provider.getCurrent(),
|
|
585
|
+
getDiskSpace: (params) => provider.getDiskSpace(params),
|
|
586
|
+
getGpuInfo: () => provider.getGpuInfo(),
|
|
587
|
+
getCpuTemperature: () => provider.getCpuTemperature(),
|
|
588
|
+
getProcessStats: (params) => provider.getProcessStats(params),
|
|
589
|
+
listAddonInstances: () => this.listAddonInstances(),
|
|
590
|
+
getAddonStats: (params) => this.getAddonStats(params.addonId),
|
|
591
|
+
listNodeProcesses: () => this.listNodeProcesses(),
|
|
592
|
+
killProcess: (params) => this.killProcess(params)
|
|
593
|
+
};
|
|
594
|
+
this.snapshotTimer = setInterval(() => this.emitMetricsSnapshots(), METRICS_SNAPSHOT_INTERVAL_MS);
|
|
595
|
+
return [{
|
|
596
|
+
capability: metricsProviderCapability,
|
|
597
|
+
provider: composed
|
|
598
|
+
}];
|
|
599
|
+
}
|
|
600
|
+
async onShutdown() {
|
|
601
|
+
if (this.snapshotTimer) {
|
|
602
|
+
clearInterval(this.snapshotTimer);
|
|
603
|
+
this.snapshotTimer = null;
|
|
604
|
+
}
|
|
605
|
+
this.provider?.stopSampling();
|
|
606
|
+
this.provider = null;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Emit one `metrics.node-resources-snapshot` + one
|
|
610
|
+
* `metrics.node-processes-snapshot` for this node. UI consumers
|
|
611
|
+
* subscribe and read state directly from the payload.
|
|
612
|
+
*/
|
|
613
|
+
async emitMetricsSnapshots() {
|
|
614
|
+
const provider = this.provider;
|
|
615
|
+
const eventBus = this.ctx.eventBus;
|
|
616
|
+
if (!provider || !eventBus) return;
|
|
617
|
+
const rawNodeId = this.ctx.kernel.localNodeId ?? this.ctx.id;
|
|
618
|
+
const nodeId = rawNodeId.includes("/") ? rawNodeId.split("/")[0] : rawNodeId;
|
|
619
|
+
const timestamp = Date.now();
|
|
620
|
+
try {
|
|
621
|
+
const snapshot = await provider.getCached() ?? await provider.collectSnapshot();
|
|
622
|
+
const coarse = coarsenResourcesSnapshot(snapshot);
|
|
623
|
+
const prev = this.lastResourcesEmit;
|
|
624
|
+
const heartbeatDue = !prev || timestamp - prev.emittedAt >= METRICS_SNAPSHOT_HEARTBEAT_MS;
|
|
625
|
+
if (!prev || prev.coarse !== coarse || heartbeatDue) {
|
|
626
|
+
this.lastResourcesEmit = {
|
|
627
|
+
coarse,
|
|
628
|
+
emittedAt: timestamp
|
|
629
|
+
};
|
|
630
|
+
eventBus.emit(createEvent(EventCategory.MetricsNodeResourcesSnapshot, {
|
|
631
|
+
type: "node",
|
|
632
|
+
id: nodeId,
|
|
633
|
+
nodeId
|
|
634
|
+
}, {
|
|
635
|
+
nodeId,
|
|
636
|
+
snapshot,
|
|
637
|
+
timestamp
|
|
638
|
+
}));
|
|
639
|
+
}
|
|
640
|
+
} catch {}
|
|
641
|
+
try {
|
|
642
|
+
const processes = await this.listNodeProcesses();
|
|
643
|
+
const coarse = coarsenProcessList(processes);
|
|
644
|
+
const prev = this.lastProcessesEmit;
|
|
645
|
+
const heartbeatDue = !prev || timestamp - prev.emittedAt >= METRICS_SNAPSHOT_HEARTBEAT_MS;
|
|
646
|
+
if (!prev || prev.coarse !== coarse || heartbeatDue) {
|
|
647
|
+
this.lastProcessesEmit = {
|
|
648
|
+
coarse,
|
|
649
|
+
emittedAt: timestamp
|
|
650
|
+
};
|
|
651
|
+
eventBus.emit(createEvent(EventCategory.MetricsNodeProcessesSnapshot, {
|
|
652
|
+
type: "node",
|
|
653
|
+
id: nodeId,
|
|
654
|
+
nodeId
|
|
655
|
+
}, {
|
|
656
|
+
nodeId,
|
|
657
|
+
processes,
|
|
658
|
+
timestamp
|
|
659
|
+
}));
|
|
660
|
+
}
|
|
661
|
+
} catch {}
|
|
662
|
+
}
|
|
663
|
+
async onConfigChanged() {
|
|
664
|
+
this.provider?.stopSampling();
|
|
665
|
+
this.provider?.startSampling(this.config.samplingIntervalMs);
|
|
666
|
+
}
|
|
667
|
+
async listWorkerInstances() {
|
|
668
|
+
const broker = this.ctx.kernel.cluster?.broker;
|
|
669
|
+
if (!broker) return [];
|
|
670
|
+
try {
|
|
671
|
+
return await broker.call("$process.list");
|
|
672
|
+
} catch {
|
|
673
|
+
return [];
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
async listAddonInstances() {
|
|
677
|
+
const hubNodeId = (this.ctx.kernel.cluster?.broker)?.nodeID ?? "hub";
|
|
678
|
+
const uptimeSec = Math.max(0, Math.floor((Date.now() - this.startedAtMs) / 1e3));
|
|
679
|
+
const instances = [{
|
|
680
|
+
addonId: "$hub",
|
|
681
|
+
nodeId: hubNodeId,
|
|
682
|
+
role: "hub",
|
|
683
|
+
pid: process.pid,
|
|
684
|
+
state: "running",
|
|
685
|
+
uptimeSec
|
|
686
|
+
}];
|
|
687
|
+
const workers = await this.listWorkerInstances();
|
|
688
|
+
for (const w of workers) instances.push({
|
|
689
|
+
addonId: w.addonId,
|
|
690
|
+
nodeId: w.nodeId,
|
|
691
|
+
role: "worker",
|
|
692
|
+
pid: w.pid,
|
|
693
|
+
state: narrowWorkerState(w.state),
|
|
694
|
+
uptimeSec: w.uptimeSeconds
|
|
695
|
+
});
|
|
696
|
+
return instances;
|
|
697
|
+
}
|
|
698
|
+
async getAddonStats(addonId) {
|
|
699
|
+
const provider = this.provider;
|
|
700
|
+
if (!provider) return null;
|
|
701
|
+
if (addonId === "$hub") return (await provider.getProcessStats({ pids: [process.pid] }))[0] ?? null;
|
|
702
|
+
const target = (await this.listWorkerInstances()).find((w) => w.addonId === addonId);
|
|
703
|
+
if (!target) return null;
|
|
704
|
+
return (await provider.getProcessStats({ pids: [target.pid] }))[0] ?? null;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Walk the OS process table and classify each camstack-shaped process.
|
|
708
|
+
*
|
|
709
|
+
* Classification (ancestry-driven, NOT pattern-driven):
|
|
710
|
+
* - root — the current node's own pid (`process.pid`).
|
|
711
|
+
* - managed — pid is registered in the kernel's `$process.list`
|
|
712
|
+
* (forked addon worker spawned by this hub).
|
|
713
|
+
* - system — ancestry walk crosses a SUPERVISOR_BOUNDARY_RE match
|
|
714
|
+
* (tsx-watch launcher, agent CLI, concurrently, vite,
|
|
715
|
+
* npm exec wrapper). The process belongs to the dev
|
|
716
|
+
* tree even if not in `$process.list`. NEVER killable.
|
|
717
|
+
* - ghost — ancestry walk reaches `ppid=1` without crossing any
|
|
718
|
+
* supervisor boundary AND the parent isn't visible in
|
|
719
|
+
* `ps`. A truly orphaned camstack-shaped process. The
|
|
720
|
+
* ONLY classification that's eligible for kill.
|
|
721
|
+
*
|
|
722
|
+
* Old pattern-only ghost detection produced false positives: every
|
|
723
|
+
* monorepo-path process matched CAMSTACK_CMD_RE, ancestry walk
|
|
724
|
+
* stopping at ppid=hub returned false-positive ghosts whenever a
|
|
725
|
+
* concurrently sibling sat above hub. Ancestry-driven classification
|
|
726
|
+
* fixes that.
|
|
727
|
+
*/
|
|
728
|
+
async listNodeProcesses() {
|
|
729
|
+
const ps = await this.runPs();
|
|
730
|
+
if (ps.length === 0) return [];
|
|
731
|
+
const managedPids = /* @__PURE__ */ new Map();
|
|
732
|
+
const workers = await this.listWorkerInstances();
|
|
733
|
+
for (const w of workers) managedPids.set(w.pid, {
|
|
734
|
+
addonId: w.addonId,
|
|
735
|
+
nodeId: w.nodeId
|
|
736
|
+
});
|
|
737
|
+
const hubNodeId = this.ctx.kernel.cluster?.broker?.nodeID ?? "hub";
|
|
738
|
+
const selfPid = process.pid;
|
|
739
|
+
const psIndex = /* @__PURE__ */ new Map();
|
|
740
|
+
for (const p of ps) psIndex.set(p.pid, {
|
|
741
|
+
ppid: p.ppid,
|
|
742
|
+
command: p.command
|
|
743
|
+
});
|
|
744
|
+
/**
|
|
745
|
+
* Walk ancestry from `pid` up to ppid=1 (or until we leave the ps
|
|
746
|
+
* snapshot). Returns:
|
|
747
|
+
* - 'system' — crossed a SUPERVISOR_BOUNDARY_RE ancestor
|
|
748
|
+
* - 'ghost' — reached ppid=1 OR the parent isn't visible in ps
|
|
749
|
+
* without crossing a boundary
|
|
750
|
+
*
|
|
751
|
+
* `selfPid` itself is treated as a boundary (this node's own root).
|
|
752
|
+
*/
|
|
753
|
+
const classifyByAncestry = (startPid) => {
|
|
754
|
+
let cur = startPid;
|
|
755
|
+
for (let depth = 0; depth < 32; depth++) {
|
|
756
|
+
const node = psIndex.get(cur);
|
|
757
|
+
if (!node) return "ghost";
|
|
758
|
+
if (cur === selfPid) return "system";
|
|
759
|
+
if (SUPERVISOR_BOUNDARY_RE.test(node.command)) return "system";
|
|
760
|
+
if (node.ppid === 1) return "ghost";
|
|
761
|
+
if (node.ppid === selfPid) return "system";
|
|
762
|
+
cur = node.ppid;
|
|
763
|
+
}
|
|
764
|
+
return "system";
|
|
765
|
+
};
|
|
766
|
+
const out = [];
|
|
767
|
+
for (const p of ps) {
|
|
768
|
+
if (!CAMSTACK_CMD_RE.test(p.command)) continue;
|
|
769
|
+
const managed = managedPids.get(p.pid);
|
|
770
|
+
let classification;
|
|
771
|
+
if (p.pid === selfPid) classification = "root";
|
|
772
|
+
else if (managed) classification = "managed";
|
|
773
|
+
else classification = classifyByAncestry(p.pid);
|
|
774
|
+
const orphaned = classification === "ghost";
|
|
775
|
+
out.push({
|
|
776
|
+
pid: p.pid,
|
|
777
|
+
ppid: p.ppid,
|
|
778
|
+
pgid: p.pgid,
|
|
779
|
+
classification,
|
|
780
|
+
addonId: managed?.addonId ?? null,
|
|
781
|
+
nodeId: managed?.nodeId ?? (p.pid === selfPid ? hubNodeId : null),
|
|
782
|
+
command: p.command,
|
|
783
|
+
cpuPercent: p.cpuPercent,
|
|
784
|
+
memoryRssBytes: p.memoryRssBytes,
|
|
785
|
+
uptimeSec: p.uptimeSec,
|
|
786
|
+
orphaned
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
return out;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Send SIGTERM / SIGKILL to a pid. Refuses pids that don't appear in
|
|
793
|
+
* `listNodeProcesses()` to prevent arbitrary system kills — a dedicated
|
|
794
|
+
* admin-path for resurrected zombies, not a generic shell replacement.
|
|
795
|
+
*
|
|
796
|
+
* `root`-classified pids (the running launcher / agent CLI / hub itself)
|
|
797
|
+
* are also refused: killing them tears down the whole node and the
|
|
798
|
+
* operator's intent is almost always to nuke a leaked child, not the
|
|
799
|
+
* supervisor that keeps the rest alive. Process restart goes through
|
|
800
|
+
* the dedicated `$process.restart` action, not this kill API.
|
|
801
|
+
*/
|
|
802
|
+
async killProcess(input) {
|
|
803
|
+
const match = (await this.listNodeProcesses()).find((p) => p.pid === input.pid);
|
|
804
|
+
if (!match) return {
|
|
805
|
+
success: false,
|
|
806
|
+
reason: "pid not in node process table"
|
|
807
|
+
};
|
|
808
|
+
if (match.classification === "root" || match.classification === "system") {
|
|
809
|
+
this.ctx.logger.warn("Refused to kill protected process", { meta: {
|
|
810
|
+
pid: input.pid,
|
|
811
|
+
classification: match.classification,
|
|
812
|
+
addonId: match.addonId,
|
|
813
|
+
command: match.command
|
|
814
|
+
} });
|
|
815
|
+
return {
|
|
816
|
+
success: false,
|
|
817
|
+
reason: match.classification === "root" ? "cannot kill root (current node supervisor)" : "cannot kill system (intentional dev-tree ancestor — vite, concurrently, npm, etc.)"
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
const signal = input.force ? "SIGKILL" : "SIGTERM";
|
|
821
|
+
try {
|
|
822
|
+
process.kill(input.pid, signal);
|
|
823
|
+
this.ctx.logger.info("Killed node process", { meta: {
|
|
824
|
+
pid: input.pid,
|
|
825
|
+
signal,
|
|
826
|
+
classification: match.classification,
|
|
827
|
+
addonId: match.addonId
|
|
828
|
+
} });
|
|
829
|
+
return {
|
|
830
|
+
success: true,
|
|
831
|
+
signal
|
|
832
|
+
};
|
|
833
|
+
} catch (err) {
|
|
834
|
+
return {
|
|
835
|
+
success: false,
|
|
836
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
837
|
+
signal
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
/** Raw `ps` scan returning every pid + command + resource stats. */
|
|
842
|
+
async runPs() {
|
|
843
|
+
try {
|
|
844
|
+
const { stdout } = await execFileAsync("ps", ["-eo", "pid=,ppid=,pgid=,pcpu=,rss=,etime=,command="], {
|
|
845
|
+
timeout: 5e3,
|
|
846
|
+
maxBuffer: 8 * 1024 * 1024
|
|
847
|
+
});
|
|
848
|
+
const lines = stdout.split("\n");
|
|
849
|
+
const rows = [];
|
|
850
|
+
for (const line of lines) {
|
|
851
|
+
const trimmed = line.trim();
|
|
852
|
+
if (!trimmed) continue;
|
|
853
|
+
const match = trimmed.match(/^(\d+)\s+(\d+)\s+(\d+)\s+([\d.]+)\s+(\d+)\s+(\S+)\s+(.+)$/);
|
|
854
|
+
if (!match) continue;
|
|
855
|
+
const [, pidS, ppidS, pgidS, cpuS, rssS, etimeS, command] = match;
|
|
856
|
+
rows.push({
|
|
857
|
+
pid: parseInt(pidS, 10),
|
|
858
|
+
ppid: parseInt(ppidS, 10),
|
|
859
|
+
pgid: parseInt(pgidS, 10),
|
|
860
|
+
cpuPercent: Math.round(parseFloat(cpuS) * 10) / 10,
|
|
861
|
+
memoryRssBytes: parseInt(rssS, 10) * 1024,
|
|
862
|
+
uptimeSec: parseEtime(etimeS),
|
|
863
|
+
command
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
return rows;
|
|
867
|
+
} catch (err) {
|
|
868
|
+
this.ctx.logger.warn("ps scan failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
869
|
+
return [];
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
globalSettingsSchema() {
|
|
873
|
+
return this.schema({ sections: [{
|
|
874
|
+
id: "native-metrics-settings",
|
|
875
|
+
title: "System Metrics",
|
|
876
|
+
fields: [this.field({
|
|
877
|
+
type: "number",
|
|
878
|
+
key: "samplingIntervalMs",
|
|
879
|
+
label: "Sampling Interval",
|
|
880
|
+
description: "How often to collect system metrics",
|
|
881
|
+
min: 1e3,
|
|
882
|
+
max: 6e4,
|
|
883
|
+
step: 1e3,
|
|
884
|
+
default: 5e3,
|
|
885
|
+
unit: "ms"
|
|
886
|
+
})]
|
|
887
|
+
}] });
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
/**
|
|
891
|
+
* Parse `ps etime` format → seconds.
|
|
892
|
+
*
|
|
893
|
+
* Formats we handle:
|
|
894
|
+
* `MM:SS` (< 1h)
|
|
895
|
+
* `HH:MM:SS` (< 1d)
|
|
896
|
+
* `DD-HH:MM:SS` (>= 1d)
|
|
897
|
+
*/
|
|
898
|
+
function parseEtime(etime) {
|
|
899
|
+
const dashParts = etime.split("-");
|
|
900
|
+
let days = 0;
|
|
901
|
+
let hms = etime;
|
|
902
|
+
if (dashParts.length === 2) {
|
|
903
|
+
days = parseInt(dashParts[0], 10) || 0;
|
|
904
|
+
hms = dashParts[1];
|
|
905
|
+
}
|
|
906
|
+
const parts = hms.split(":").map((p) => parseInt(p, 10) || 0);
|
|
907
|
+
let hours = 0, minutes = 0, seconds = 0;
|
|
908
|
+
if (parts.length === 3) [hours, minutes, seconds] = parts;
|
|
909
|
+
else if (parts.length === 2) [minutes, seconds] = parts;
|
|
910
|
+
else if (parts.length === 1) [seconds] = parts;
|
|
911
|
+
return days * 86400 + hours * 3600 + minutes * 60 + seconds;
|
|
912
|
+
}
|
|
913
|
+
//#endregion
|
|
914
|
+
export { NativeMetricsAddon as default, NativeMetricsProvider as t };
|
|
915
|
+
|
|
7
916
|
//# sourceMappingURL=native-metrics.addon.mjs.map
|