lightfall 0.1.1__py3-none-any.whl
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.
- lightfall/__init__.py +8 -0
- lightfall/__main__.py +10 -0
- lightfall/_version.py +24 -0
- lightfall/acquire/__init__.py +74 -0
- lightfall/acquire/buffer.py +363 -0
- lightfall/acquire/device_wrapper.py +416 -0
- lightfall/acquire/engine/__init__.py +155 -0
- lightfall/acquire/engine/base.py +587 -0
- lightfall/acquire/engine/bluesky.py +358 -0
- lightfall/acquire/engine/mock.py +165 -0
- lightfall/acquire/engine/plugins/__init__.py +9 -0
- lightfall/acquire/engine/plugins/bluesky_plugin.py +56 -0
- lightfall/acquire/engine/plugins/mock_plugin.py +55 -0
- lightfall/acquire/engine/protocol.py +145 -0
- lightfall/acquire/engine/registry.py +152 -0
- lightfall/acquire/engine/state.py +32 -0
- lightfall/acquire/engine/waiting_hook.py +225 -0
- lightfall/acquire/nats_bridge.py +62 -0
- lightfall/acquire/plan_ui.py +78 -0
- lightfall/acquire/plans/__init__.py +38 -0
- lightfall/acquire/plans/adaptive.py +288 -0
- lightfall/acquire/plans/example_plans.py +995 -0
- lightfall/acquire/plans/lightfall_plans.py +587 -0
- lightfall/acquire/plans/registry.py +543 -0
- lightfall/acquire/plans/standard_plans.py +186 -0
- lightfall/acquire/plans/user_plans.py +470 -0
- lightfall/acquire/runengine.py +36 -0
- lightfall/acquire/signals.py +452 -0
- lightfall/acquire/triggers/__init__.py +16 -0
- lightfall/acquire/triggers/base.py +25 -0
- lightfall/acquire/triggers/filter.py +37 -0
- lightfall/acquire/triggers/manager.py +73 -0
- lightfall/acquire/triggers/manual.py +36 -0
- lightfall/acquire/triggers/run_end.py +74 -0
- lightfall/acquire/triggers/run_start.py +52 -0
- lightfall/auth/__init__.py +38 -0
- lightfall/auth/policy.py +518 -0
- lightfall/auth/providers/__init__.py +30 -0
- lightfall/auth/providers/base.py +124 -0
- lightfall/auth/providers/keycloak.py +1017 -0
- lightfall/auth/providers/local.py +319 -0
- lightfall/auth/providers/pam.py +250 -0
- lightfall/auth/service_key.py +173 -0
- lightfall/auth/service_key_auth.py +79 -0
- lightfall/auth/session.py +656 -0
- lightfall/claude/__init__.py +52 -0
- lightfall/claude/_internal/__init__.py +1 -0
- lightfall/claude/_internal/serialization.py +195 -0
- lightfall/claude/_internal/threading.py +61 -0
- lightfall/claude/_internal/worker.py +757 -0
- lightfall/claude/_session_assembly.py +124 -0
- lightfall/claude/agent.py +596 -0
- lightfall/claude/lightfall_core_tools.py +410 -0
- lightfall/claude/markdown.py +103 -0
- lightfall/claude/permission_manager.py +588 -0
- lightfall/claude/tools/__init__.py +45 -0
- lightfall/claude/tools/controller.py +143 -0
- lightfall/claude/tools/interaction.py +177 -0
- lightfall/claude/tools/introspection.py +127 -0
- lightfall/claude/tools/logs.py +155 -0
- lightfall/claude/tools/screenshot.py +87 -0
- lightfall/claude/widget.py +851 -0
- lightfall/claude/widgets/__init__.py +5 -0
- lightfall/claude/widgets/permission_request.py +282 -0
- lightfall/claude/widgets/question_request.py +227 -0
- lightfall/claude/widgets/task_card.py +223 -0
- lightfall/config/__init__.py +23 -0
- lightfall/config/layers.py +317 -0
- lightfall/config/manager.py +244 -0
- lightfall/config/schema.py +154 -0
- lightfall/core/__init__.py +23 -0
- lightfall/core/application.py +727 -0
- lightfall/core/services.py +235 -0
- lightfall/devices/__init__.py +53 -0
- lightfall/devices/backends/__init__.py +17 -0
- lightfall/devices/backends/bcs.py +448 -0
- lightfall/devices/backends/happi.py +986 -0
- lightfall/devices/backends/mock.py +646 -0
- lightfall/devices/base.py +338 -0
- lightfall/devices/catalog.py +1039 -0
- lightfall/devices/connection_manager.py +676 -0
- lightfall/devices/model.py +290 -0
- lightfall/devices/monitoring.py +442 -0
- lightfall/devices/sim/__init__.py +26 -0
- lightfall/devices/sim/areadetector.py +436 -0
- lightfall/devices/sim/generators.py +223 -0
- lightfall/devices/sim/plugins.py +116 -0
- lightfall/epics/__init__.py +28 -0
- lightfall/epics/ca/__init__.py +10 -0
- lightfall/epics/ca/context.py +100 -0
- lightfall/epics/ca/pv.py +303 -0
- lightfall/epics/widgets/__init__.py +49 -0
- lightfall/epics/widgets/areadetector/__init__.py +16 -0
- lightfall/epics/widgets/areadetector/areadetector.py +281 -0
- lightfall/epics/widgets/areadetector/controls.py +478 -0
- lightfall/epics/widgets/areadetector/image_view.py +447 -0
- lightfall/epics/widgets/auto.py +319 -0
- lightfall/epics/widgets/base.py +404 -0
- lightfall/epics/widgets/checkbox.py +239 -0
- lightfall/epics/widgets/combobox.py +202 -0
- lightfall/epics/widgets/label.py +176 -0
- lightfall/epics/widgets/lineedit.py +253 -0
- lightfall/epics/widgets/motor.py +694 -0
- lightfall/epics/widgets/ophyd_base.py +469 -0
- lightfall/epics/widgets/ophyd_combobox.py +86 -0
- lightfall/epics/widgets/ophyd_label.py +54 -0
- lightfall/epics/widgets/ophyd_lineedit.py +170 -0
- lightfall/epics/widgets/ophyd_spinbox.py +79 -0
- lightfall/epics/widgets/slider.py +272 -0
- lightfall/epics/widgets/status_indicator.py +98 -0
- lightfall/epics/widgets/style.py +188 -0
- lightfall/exporter/__init__.py +1 -0
- lightfall/exporter/cli.py +67 -0
- lightfall/exporter/converters/__init__.py +26 -0
- lightfall/exporter/converters/base.py +39 -0
- lightfall/exporter/converters/noop.py +39 -0
- lightfall/exporter/converters/nxsas.py +73 -0
- lightfall/exporter/service.py +200 -0
- lightfall/exporter/tiled_utils.py +92 -0
- lightfall/ipc/__init__.py +6 -0
- lightfall/ipc/service.py +701 -0
- lightfall/ipc/trust.py +144 -0
- lightfall/logbook/__init__.py +46 -0
- lightfall/logbook/action_dialog.py +207 -0
- lightfall/logbook/action_logger.py +432 -0
- lightfall/logbook/block_mapper.py +562 -0
- lightfall/logbook/client.py +799 -0
- lightfall/logbook/converter.py +273 -0
- lightfall/logbook/editors/__init__.py +19 -0
- lightfall/logbook/editors/highlighter.py +305 -0
- lightfall/logbook/editors/markdown_editor.py +319 -0
- lightfall/logbook/editors/richtext_editor.py +1397 -0
- lightfall/logbook/entry_widget.py +1065 -0
- lightfall/logbook/event_listener.py +221 -0
- lightfall/logbook/fragment_widgets.py +925 -0
- lightfall/logbook/position_mapper.py +320 -0
- lightfall/logbook/protection.py +402 -0
- lightfall/logbook/style.py +394 -0
- lightfall/logbook/url.py +29 -0
- lightfall/logbook/visual_protection.py +330 -0
- lightfall/logbook/widget.py +680 -0
- lightfall/main.py +1091 -0
- lightfall/pipelines/__init__.py +4 -0
- lightfall/pipelines/client.py +148 -0
- lightfall/plugins/__init__.py +119 -0
- lightfall/plugins/agent_plugin.py +106 -0
- lightfall/plugins/agents/__init__.py +10 -0
- lightfall/plugins/agents/_mcp_helpers.py +52 -0
- lightfall/plugins/agents/alignment.py +94 -0
- lightfall/plugins/agents/autonomous_experiment/__init__.py +12 -0
- lightfall/plugins/agents/autonomous_experiment/nats_tools.py +210 -0
- lightfall/plugins/agents/autonomous_experiment/plugin.py +60 -0
- lightfall/plugins/agents/autonomous_experiment/prompts.py +164 -0
- lightfall/plugins/agents/current_esaf.py +435 -0
- lightfall/plugins/agents/device_tools.py +1043 -0
- lightfall/plugins/agents/engine_tools.py +720 -0
- lightfall/plugins/agents/ipython_tools.py +444 -0
- lightfall/plugins/agents/panel_builder.py +637 -0
- lightfall/plugins/agents/panel_design/references/cross_panel_patterns.md +95 -0
- lightfall/plugins/agents/panel_design/references/panel_design.md +680 -0
- lightfall/plugins/agents/panel_design.py +94 -0
- lightfall/plugins/agents/plan_design/references/plan_design.md +398 -0
- lightfall/plugins/agents/plan_design.py +90 -0
- lightfall/plugins/agents/plan_tools.py +878 -0
- lightfall/plugins/agents/scan_planning.py +101 -0
- lightfall/plugins/builtin_manifest.py +348 -0
- lightfall/plugins/controller_plugin.py +162 -0
- lightfall/plugins/engine_plugin.py +124 -0
- lightfall/plugins/errors.py +104 -0
- lightfall/plugins/info.py +112 -0
- lightfall/plugins/loader.py +878 -0
- lightfall/plugins/manifest.py +150 -0
- lightfall/plugins/panel_plugin.py +119 -0
- lightfall/plugins/plan_plugin.py +163 -0
- lightfall/plugins/registry.py +309 -0
- lightfall/plugins/settings_plugin.py +226 -0
- lightfall/plugins/statusbar_plugin.py +289 -0
- lightfall/plugins/theme_plugin.py +165 -0
- lightfall/plugins/types.py +136 -0
- lightfall/plugins/user_plugins.py +764 -0
- lightfall/project/__init__.py +37 -0
- lightfall/project/model.py +375 -0
- lightfall/project/service.py +427 -0
- lightfall/project/welcome.py +106 -0
- lightfall/resources/__init__.py +126 -0
- lightfall/resources/images/__init__.py +1 -0
- lightfall/resources/images/icon.ico +0 -0
- lightfall/resources/images/icon.png +0 -0
- lightfall/resources/images/logo.png +0 -0
- lightfall/services/__init__.py +33 -0
- lightfall/services/_alshub_client.py +73 -0
- lightfall/services/access_stamper.py +240 -0
- lightfall/services/als_beam_status.py +347 -0
- lightfall/services/ca_tunnel.py +325 -0
- lightfall/services/threaded_tiled_writer.py +174 -0
- lightfall/services/tiled_auth.py +21 -0
- lightfall/services/tiled_service.py +971 -0
- lightfall/services/tiled_writer_patch.py +301 -0
- lightfall/settings/__init__.py +1 -0
- lightfall/settings/image_helpers.py +30 -0
- lightfall/settings/user_settings_client.py +232 -0
- lightfall/ui/__init__.py +28 -0
- lightfall/ui/annotations.py +208 -0
- lightfall/ui/common/__init__.py +7 -0
- lightfall/ui/dialogs/__init__.py +26 -0
- lightfall/ui/dialogs/about_dialog.py +131 -0
- lightfall/ui/dialogs/add_trigger_dialog.py +152 -0
- lightfall/ui/dialogs/base.py +44 -0
- lightfall/ui/dialogs/bug_report_dialog.py +353 -0
- lightfall/ui/dialogs/create_plan_dialog.py +189 -0
- lightfall/ui/dialogs/device_edit_dialog.py +183 -0
- lightfall/ui/dialogs/export_dialog.py +565 -0
- lightfall/ui/dialogs/go_to_position_dialog.py +192 -0
- lightfall/ui/dialogs/login_dialog.py +756 -0
- lightfall/ui/dialogs/oauth_browser_dialog.py +305 -0
- lightfall/ui/dialogs/run_pipeline_dialog.py +131 -0
- lightfall/ui/dialogs/sample_metadata_dialog.py +316 -0
- lightfall/ui/docking/__init__.py +22 -0
- lightfall/ui/docking/icon_sidebar.py +806 -0
- lightfall/ui/docking/manager.py +682 -0
- lightfall/ui/docking/state.py +113 -0
- lightfall/ui/docking/theme.py +399 -0
- lightfall/ui/docking/widget.py +214 -0
- lightfall/ui/events.py +75 -0
- lightfall/ui/mainwindow.py +1006 -0
- lightfall/ui/models/__init__.py +49 -0
- lightfall/ui/models/device_selection.py +389 -0
- lightfall/ui/models/device_tree.py +1095 -0
- lightfall/ui/models/thread_model.py +667 -0
- lightfall/ui/models/tiled_model.py +384 -0
- lightfall/ui/panels/__init__.py +28 -0
- lightfall/ui/panels/base.py +525 -0
- lightfall/ui/panels/bluesky_panel.py +619 -0
- lightfall/ui/panels/claude/__init__.py +9 -0
- lightfall/ui/panels/claude/agent_registry.py +168 -0
- lightfall/ui/panels/claude_panel.py +887 -0
- lightfall/ui/panels/device_panel.py +370 -0
- lightfall/ui/panels/documents_panel.py +166 -0
- lightfall/ui/panels/ipython_panel.py +580 -0
- lightfall/ui/panels/logbook_entries_panel.py +84 -0
- lightfall/ui/panels/logbook_panel.py +627 -0
- lightfall/ui/panels/logging_panel.py +587 -0
- lightfall/ui/panels/pipeline_jobs_panel.py +160 -0
- lightfall/ui/panels/pipeline_triggers_panel.py +170 -0
- lightfall/ui/panels/plugins/__init__.py +34 -0
- lightfall/ui/panels/plugins/bluesky_plugin.py +27 -0
- lightfall/ui/panels/plugins/claude_plugin.py +29 -0
- lightfall/ui/panels/plugins/device_plugin.py +27 -0
- lightfall/ui/panels/plugins/documents_plugin.py +26 -0
- lightfall/ui/panels/plugins/ipython_plugin.py +27 -0
- lightfall/ui/panels/plugins/logbook_entries_plugin.py +23 -0
- lightfall/ui/panels/plugins/logbook_plugin.py +27 -0
- lightfall/ui/panels/plugins/logging_plugin.py +27 -0
- lightfall/ui/panels/plugins/pipeline_jobs_plugin.py +23 -0
- lightfall/ui/panels/plugins/pipeline_triggers_plugin.py +25 -0
- lightfall/ui/panels/plugins/queue_plugin.py +29 -0
- lightfall/ui/panels/plugins/synoptic_plugin.py +38 -0
- lightfall/ui/panels/plugins/threads_plugin.py +27 -0
- lightfall/ui/panels/plugins/tiled_browser_plugin.py +27 -0
- lightfall/ui/panels/plugins/visualization_plugin.py +27 -0
- lightfall/ui/panels/queue.py +754 -0
- lightfall/ui/panels/registry.py +483 -0
- lightfall/ui/panels/synoptic/__init__.py +27 -0
- lightfall/ui/panels/synoptic/editors.py +481 -0
- lightfall/ui/panels/synoptic/items.py +556 -0
- lightfall/ui/panels/synoptic/models.py +336 -0
- lightfall/ui/panels/synoptic/panel.py +889 -0
- lightfall/ui/panels/synoptic/serialization.py +300 -0
- lightfall/ui/panels/synoptic/view.py +504 -0
- lightfall/ui/panels/threads_panel.py +621 -0
- lightfall/ui/panels/tiled_browser_panel.py +854 -0
- lightfall/ui/panels/visualization_panel.py +508 -0
- lightfall/ui/preferences/__init__.py +24 -0
- lightfall/ui/preferences/backend.py +148 -0
- lightfall/ui/preferences/builtin.py +220 -0
- lightfall/ui/preferences/claude_settings.py +762 -0
- lightfall/ui/preferences/device_settings.py +461 -0
- lightfall/ui/preferences/dialog.py +234 -0
- lightfall/ui/preferences/editor_settings.py +227 -0
- lightfall/ui/preferences/ipc_settings.py +226 -0
- lightfall/ui/preferences/logbook_settings.py +232 -0
- lightfall/ui/preferences/login_settings.py +183 -0
- lightfall/ui/preferences/manager.py +562 -0
- lightfall/ui/preferences/plugin_settings.py +392 -0
- lightfall/ui/preferences/proxy_settings.py +561 -0
- lightfall/ui/preferences/skill_settings.py +28 -0
- lightfall/ui/preferences/tiled_settings.py +469 -0
- lightfall/ui/preferences/tool_settings.py +393 -0
- lightfall/ui/preferences/user_portable_backend.py +131 -0
- lightfall/ui/preferences/user_profile_settings.py +316 -0
- lightfall/ui/preferences/visualization_settings.py +159 -0
- lightfall/ui/resources/__init__.py +1 -0
- lightfall/ui/resources/logo.png +0 -0
- lightfall/ui/statusbar/__init__.py +11 -0
- lightfall/ui/statusbar/manager.py +379 -0
- lightfall/ui/statusbar/plugins/__init__.py +28 -0
- lightfall/ui/statusbar/plugins/als_beam_status.py +218 -0
- lightfall/ui/statusbar/plugins/auth_status.py +116 -0
- lightfall/ui/statusbar/plugins/connection_status.py +100 -0
- lightfall/ui/statusbar/plugins/thread_status.py +556 -0
- lightfall/ui/statusbar/plugins/tiled_status.py +179 -0
- lightfall/ui/statusbar/plugins/user_status.py +84 -0
- lightfall/ui/theater/__init__.py +28 -0
- lightfall/ui/theater/manager.py +124 -0
- lightfall/ui/theater/overlay.py +279 -0
- lightfall/ui/theater/proxy.py +111 -0
- lightfall/ui/theme/__init__.py +18 -0
- lightfall/ui/theme/builtin.py +1015 -0
- lightfall/ui/theme/manager.py +875 -0
- lightfall/ui/theme/registry.py +195 -0
- lightfall/ui/toast.py +221 -0
- lightfall/ui/tutorial.py +1100 -0
- lightfall/ui/widgets/__init__.py +110 -0
- lightfall/ui/widgets/base_control.py +259 -0
- lightfall/ui/widgets/camera/__init__.py +36 -0
- lightfall/ui/widgets/camera/base.py +815 -0
- lightfall/ui/widgets/camera/dark_frames.py +213 -0
- lightfall/ui/widgets/camera/image_view.py +649 -0
- lightfall/ui/widgets/camera/panels/__init__.py +14 -0
- lightfall/ui/widgets/camera/panels/cooler.py +320 -0
- lightfall/ui/widgets/camera/panels/temperature.py +192 -0
- lightfall/ui/widgets/camera/plan_based.py +202 -0
- lightfall/ui/widgets/compact_motor.py +522 -0
- lightfall/ui/widgets/controller_matcher.py +278 -0
- lightfall/ui/widgets/controller_registry.py +144 -0
- lightfall/ui/widgets/device_control.py +411 -0
- lightfall/ui/widgets/device_selector.py +438 -0
- lightfall/ui/widgets/device_tree_tab.py +461 -0
- lightfall/ui/widgets/document_stream.py +1028 -0
- lightfall/ui/widgets/favorites_tab.py +191 -0
- lightfall/ui/widgets/motor_control.py +1120 -0
- lightfall/ui/widgets/observers/__init__.py +8 -0
- lightfall/ui/widgets/observers/camera.py +48 -0
- lightfall/ui/widgets/observers/image_view.py +130 -0
- lightfall/ui/widgets/plan_config.py +954 -0
- lightfall/ui/widgets/plan_edit_dialog.py +294 -0
- lightfall/ui/widgets/plan_selector.py +452 -0
- lightfall/ui/widgets/profile_avatar.py +128 -0
- lightfall/ui/widgets/queue_view.py +647 -0
- lightfall/ui/widgets/runengine_control.py +549 -0
- lightfall/ui/widgets/signal_control.py +793 -0
- lightfall/ui/widgets/skill_trigger_button.py +183 -0
- lightfall/ui/widgets/tiled_filter_widget.py +314 -0
- lightfall/ui/widgets/tiled_status.py +149 -0
- lightfall/ui/widgets/warning_banner.py +185 -0
- lightfall/utils/__init__.py +53 -0
- lightfall/utils/crash_diagnostics.py +454 -0
- lightfall/utils/data_migration.py +22 -0
- lightfall/utils/editor_launcher.py +594 -0
- lightfall/utils/error_collector.py +245 -0
- lightfall/utils/git_tracker.py +197 -0
- lightfall/utils/log_buffer.py +233 -0
- lightfall/utils/logging.py +229 -0
- lightfall/utils/module_resolver.py +70 -0
- lightfall/utils/sentry.py +722 -0
- lightfall/utils/threads.py +991 -0
- lightfall/utils/tiled_helpers.py +96 -0
- lightfall/visualization/__init__.py +50 -0
- lightfall/visualization/base.py +5 -0
- lightfall/visualization/base_visualization.py +74 -0
- lightfall/visualization/fitting/__init__.py +24 -0
- lightfall/visualization/fitting/base.py +267 -0
- lightfall/visualization/fitting/fitters.py +325 -0
- lightfall/visualization/fitting/panel.py +265 -0
- lightfall/visualization/memory.py +392 -0
- lightfall/visualization/motor_mixin.py +524 -0
- lightfall/visualization/pg.py +156 -0
- lightfall/visualization/registry.py +144 -0
- lightfall/visualization/spec.py +79 -0
- lightfall/visualization/theme.py +266 -0
- lightfall/visualization/widgets/__init__.py +28 -0
- lightfall/visualization/widgets/adaptive/__init__.py +1 -0
- lightfall/visualization/widgets/adaptive/heatmap.py +655 -0
- lightfall/visualization/widgets/adaptive/plot.py +233 -0
- lightfall/visualization/widgets/heatmap.py +264 -0
- lightfall/visualization/widgets/image_stack.py +316 -0
- lightfall/visualization/widgets/image_view_toolbar.py +227 -0
- lightfall/visualization/widgets/lazy_image_view.py +590 -0
- lightfall/visualization/widgets/plot_1d.py +262 -0
- lightfall/visualization/widgets/scatter.py +247 -0
- lightfall/visualization/widgets/table.py +221 -0
- lightfall/visualization/widgets/time_axis.py +93 -0
- lightfall-0.1.1.dist-info/METADATA +223 -0
- lightfall-0.1.1.dist-info/RECORD +388 -0
- lightfall-0.1.1.dist-info/WHEEL +4 -0
- lightfall-0.1.1.dist-info/entry_points.txt +6 -0
- lightfall-0.1.1.dist-info/licenses/LEGAL.md +13 -0
- lightfall-0.1.1.dist-info/licenses/LICENSE.md +33 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"""Plugin registry for managing loaded plugins.
|
|
2
|
+
|
|
3
|
+
The PluginRegistry provides thread-safe storage and retrieval of plugins
|
|
4
|
+
by type and name. It is registered with ServiceRegistry for dependency
|
|
5
|
+
injection throughout the application.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import threading
|
|
11
|
+
from typing import TYPE_CHECKING, Any
|
|
12
|
+
|
|
13
|
+
from loguru import logger
|
|
14
|
+
|
|
15
|
+
from lightfall.plugins.errors import PluginStatus
|
|
16
|
+
from lightfall.plugins.info import PluginInfo
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PluginRegistry:
|
|
23
|
+
"""Central registry for all NCS plugins.
|
|
24
|
+
|
|
25
|
+
Thread-safe registry providing:
|
|
26
|
+
- Registration and storage of plugin info
|
|
27
|
+
- Lookup by name, type, or both
|
|
28
|
+
- Duplicate detection across manifests
|
|
29
|
+
- Introspection API for MCP tools
|
|
30
|
+
|
|
31
|
+
This registry is designed to be registered with ServiceRegistry::
|
|
32
|
+
|
|
33
|
+
services.register(PluginRegistry, PluginRegistry)
|
|
34
|
+
|
|
35
|
+
Example::
|
|
36
|
+
|
|
37
|
+
registry = services.get(PluginRegistry)
|
|
38
|
+
registry.register(plugin_info)
|
|
39
|
+
plan = registry.get("plan", "my_scan")
|
|
40
|
+
all_plans = registry.get_by_type("plan")
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
_lock = threading.RLock()
|
|
44
|
+
|
|
45
|
+
def __init__(self) -> None:
|
|
46
|
+
"""Initialize the plugin registry."""
|
|
47
|
+
# Map: type_name -> {plugin_name -> PluginInfo}
|
|
48
|
+
self._plugins: dict[str, dict[str, PluginInfo]] = {}
|
|
49
|
+
# Track unique IDs to prevent duplicates
|
|
50
|
+
self._seen_ids: set[str] = set()
|
|
51
|
+
# Track which manifest provided each plugin
|
|
52
|
+
self._manifest_plugins: dict[str, list[str]] = {}
|
|
53
|
+
|
|
54
|
+
def register(
|
|
55
|
+
self,
|
|
56
|
+
plugin_info: PluginInfo,
|
|
57
|
+
*,
|
|
58
|
+
replace: bool = False,
|
|
59
|
+
) -> bool:
|
|
60
|
+
"""Register a plugin.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
plugin_info: Plugin information to register.
|
|
64
|
+
replace: If True, replace existing plugin with same ID.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
True if registered, False if duplicate (and not replacing).
|
|
68
|
+
"""
|
|
69
|
+
with self._lock:
|
|
70
|
+
unique_id = plugin_info.unique_id
|
|
71
|
+
|
|
72
|
+
# Check for duplicate
|
|
73
|
+
if unique_id in self._seen_ids and not replace:
|
|
74
|
+
existing = self._get_by_unique_id(unique_id)
|
|
75
|
+
logger.warning(
|
|
76
|
+
"Plugin {} already registered from manifest '{}', "
|
|
77
|
+
"ignoring duplicate from '{}'",
|
|
78
|
+
unique_id,
|
|
79
|
+
existing.manifest_name if existing else "unknown",
|
|
80
|
+
plugin_info.manifest_name,
|
|
81
|
+
)
|
|
82
|
+
return False
|
|
83
|
+
|
|
84
|
+
# Initialize type dict if needed
|
|
85
|
+
if plugin_info.type_name not in self._plugins:
|
|
86
|
+
self._plugins[plugin_info.type_name] = {}
|
|
87
|
+
|
|
88
|
+
# Register
|
|
89
|
+
self._plugins[plugin_info.type_name][plugin_info.name] = plugin_info
|
|
90
|
+
self._seen_ids.add(unique_id)
|
|
91
|
+
|
|
92
|
+
# Track manifest association
|
|
93
|
+
manifest_name = plugin_info.manifest_name
|
|
94
|
+
if manifest_name:
|
|
95
|
+
if manifest_name not in self._manifest_plugins:
|
|
96
|
+
self._manifest_plugins[manifest_name] = []
|
|
97
|
+
self._manifest_plugins[manifest_name].append(unique_id)
|
|
98
|
+
|
|
99
|
+
logger.debug("Registered plugin: {}", unique_id)
|
|
100
|
+
return True
|
|
101
|
+
|
|
102
|
+
def unregister(self, type_name: str, name: str) -> bool:
|
|
103
|
+
"""Unregister a plugin.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
type_name: Plugin type.
|
|
107
|
+
name: Plugin name.
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
True if plugin was registered.
|
|
111
|
+
"""
|
|
112
|
+
with self._lock:
|
|
113
|
+
unique_id = f"{type_name}:{name}"
|
|
114
|
+
|
|
115
|
+
if type_name in self._plugins and name in self._plugins[type_name]:
|
|
116
|
+
del self._plugins[type_name][name]
|
|
117
|
+
self._seen_ids.discard(unique_id)
|
|
118
|
+
logger.debug("Unregistered plugin: {}", unique_id)
|
|
119
|
+
return True
|
|
120
|
+
return False
|
|
121
|
+
|
|
122
|
+
def get(self, type_name: str, name: str) -> PluginInfo | None:
|
|
123
|
+
"""Get a plugin by type and name.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
type_name: Plugin type.
|
|
127
|
+
name: Plugin name.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
PluginInfo or None if not found.
|
|
131
|
+
"""
|
|
132
|
+
with self._lock:
|
|
133
|
+
type_plugins = self._plugins.get(type_name, {})
|
|
134
|
+
return type_plugins.get(name)
|
|
135
|
+
|
|
136
|
+
def get_plugin_instance(self, type_name: str, name: str) -> Any | None:
|
|
137
|
+
"""Get a plugin instance by type and name.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
type_name: Plugin type.
|
|
141
|
+
name: Plugin name.
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
Plugin instance or None if not found/not ready.
|
|
145
|
+
"""
|
|
146
|
+
info = self.get(type_name, name)
|
|
147
|
+
if info and info.is_ready:
|
|
148
|
+
return info.instance
|
|
149
|
+
return None
|
|
150
|
+
|
|
151
|
+
def get_by_type(self, type_name: str) -> list[PluginInfo]:
|
|
152
|
+
"""Get all plugins of a specific type.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
type_name: Plugin type.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
List of PluginInfo for that type.
|
|
159
|
+
"""
|
|
160
|
+
with self._lock:
|
|
161
|
+
return list(self._plugins.get(type_name, {}).values())
|
|
162
|
+
|
|
163
|
+
def get_ready_by_type(self, type_name: str) -> list[PluginInfo]:
|
|
164
|
+
"""Get all ready plugins of a specific type.
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
type_name: Plugin type.
|
|
168
|
+
|
|
169
|
+
Returns:
|
|
170
|
+
List of ready PluginInfo for that type.
|
|
171
|
+
"""
|
|
172
|
+
return [p for p in self.get_by_type(type_name) if p.is_ready]
|
|
173
|
+
|
|
174
|
+
def get_all(self) -> list[PluginInfo]:
|
|
175
|
+
"""Get all registered plugins.
|
|
176
|
+
|
|
177
|
+
Returns:
|
|
178
|
+
List of all PluginInfo.
|
|
179
|
+
"""
|
|
180
|
+
with self._lock:
|
|
181
|
+
all_plugins = []
|
|
182
|
+
for type_plugins in self._plugins.values():
|
|
183
|
+
all_plugins.extend(type_plugins.values())
|
|
184
|
+
return all_plugins
|
|
185
|
+
|
|
186
|
+
def has(self, type_name: str, name: str) -> bool:
|
|
187
|
+
"""Check if a plugin is registered.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
type_name: Plugin type.
|
|
191
|
+
name: Plugin name.
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
True if registered.
|
|
195
|
+
"""
|
|
196
|
+
with self._lock:
|
|
197
|
+
return type_name in self._plugins and name in self._plugins[type_name]
|
|
198
|
+
|
|
199
|
+
def is_ready(self, type_name: str, name: str) -> bool:
|
|
200
|
+
"""Check if a plugin is ready for use.
|
|
201
|
+
|
|
202
|
+
Args:
|
|
203
|
+
type_name: Plugin type.
|
|
204
|
+
name: Plugin name.
|
|
205
|
+
|
|
206
|
+
Returns:
|
|
207
|
+
True if ready.
|
|
208
|
+
"""
|
|
209
|
+
info = self.get(type_name, name)
|
|
210
|
+
return info is not None and info.is_ready
|
|
211
|
+
|
|
212
|
+
def _get_by_unique_id(self, unique_id: str) -> PluginInfo | None:
|
|
213
|
+
"""Get plugin by unique ID (internal helper).
|
|
214
|
+
|
|
215
|
+
Args:
|
|
216
|
+
unique_id: ID in format "type:name".
|
|
217
|
+
|
|
218
|
+
Returns:
|
|
219
|
+
PluginInfo or None.
|
|
220
|
+
"""
|
|
221
|
+
if ":" in unique_id:
|
|
222
|
+
type_name, name = unique_id.split(":", 1)
|
|
223
|
+
return self.get(type_name, name)
|
|
224
|
+
return None
|
|
225
|
+
|
|
226
|
+
def get_types(self) -> list[str]:
|
|
227
|
+
"""Get all registered plugin types.
|
|
228
|
+
|
|
229
|
+
Returns:
|
|
230
|
+
List of type names.
|
|
231
|
+
"""
|
|
232
|
+
with self._lock:
|
|
233
|
+
return list(self._plugins.keys())
|
|
234
|
+
|
|
235
|
+
def get_manifests(self) -> list[str]:
|
|
236
|
+
"""Get all manifests that provided plugins.
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
List of manifest names.
|
|
240
|
+
"""
|
|
241
|
+
with self._lock:
|
|
242
|
+
return list(self._manifest_plugins.keys())
|
|
243
|
+
|
|
244
|
+
def get_plugins_from_manifest(self, manifest_name: str) -> list[PluginInfo]:
|
|
245
|
+
"""Get all plugins from a specific manifest.
|
|
246
|
+
|
|
247
|
+
Args:
|
|
248
|
+
manifest_name: The manifest name.
|
|
249
|
+
|
|
250
|
+
Returns:
|
|
251
|
+
List of PluginInfo from that manifest.
|
|
252
|
+
"""
|
|
253
|
+
with self._lock:
|
|
254
|
+
unique_ids = self._manifest_plugins.get(manifest_name, [])
|
|
255
|
+
return [
|
|
256
|
+
info
|
|
257
|
+
for uid in unique_ids
|
|
258
|
+
if (info := self._get_by_unique_id(uid)) is not None
|
|
259
|
+
]
|
|
260
|
+
|
|
261
|
+
def get_introspection_data(self) -> dict[str, Any]:
|
|
262
|
+
"""Get introspection data for MCP tools.
|
|
263
|
+
|
|
264
|
+
Returns:
|
|
265
|
+
Dictionary with registry information.
|
|
266
|
+
"""
|
|
267
|
+
with self._lock:
|
|
268
|
+
by_type: dict[str, dict[str, Any]] = {}
|
|
269
|
+
for type_name, plugins in self._plugins.items():
|
|
270
|
+
ready = sum(1 for p in plugins.values() if p.is_ready)
|
|
271
|
+
failed = sum(1 for p in plugins.values() if p.is_failed)
|
|
272
|
+
by_type[type_name] = {
|
|
273
|
+
"total": len(plugins),
|
|
274
|
+
"ready": ready,
|
|
275
|
+
"failed": failed,
|
|
276
|
+
"plugins": [
|
|
277
|
+
{"name": p.name, "status": p.status.name}
|
|
278
|
+
for p in plugins.values()
|
|
279
|
+
],
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return {
|
|
283
|
+
"total_plugins": len(self._seen_ids),
|
|
284
|
+
"plugin_types": list(self._plugins.keys()),
|
|
285
|
+
"manifests": list(self._manifest_plugins.keys()),
|
|
286
|
+
"by_type": by_type,
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
def update_status(
|
|
290
|
+
self,
|
|
291
|
+
type_name: str,
|
|
292
|
+
name: str,
|
|
293
|
+
status: PluginStatus,
|
|
294
|
+
error: str | None = None,
|
|
295
|
+
) -> None:
|
|
296
|
+
"""Update the status of a plugin.
|
|
297
|
+
|
|
298
|
+
Args:
|
|
299
|
+
type_name: Plugin type.
|
|
300
|
+
name: Plugin name.
|
|
301
|
+
status: New status.
|
|
302
|
+
error: Error message (for failed states).
|
|
303
|
+
"""
|
|
304
|
+
with self._lock:
|
|
305
|
+
info = self.get(type_name, name)
|
|
306
|
+
if info:
|
|
307
|
+
info.status = status
|
|
308
|
+
if error:
|
|
309
|
+
info.error = error
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"""Settings plugin type for preferences pages.
|
|
2
|
+
|
|
3
|
+
SettingsPlugin is the plugin type for preferences/settings pages. Plugins
|
|
4
|
+
implementing this interface provide settings widgets that appear in the
|
|
5
|
+
Preferences dialog.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from abc import abstractmethod
|
|
11
|
+
from typing import TYPE_CHECKING, Any, ClassVar
|
|
12
|
+
|
|
13
|
+
from lightfall.plugins.types import PluginType
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from PySide6.QtGui import QIcon
|
|
17
|
+
from PySide6.QtWidgets import QWidget
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SettingsPlugin(PluginType):
|
|
21
|
+
"""Abstract base for settings/preferences plugins.
|
|
22
|
+
|
|
23
|
+
Settings plugins provide preference pages that can be discovered
|
|
24
|
+
and displayed in the Preferences dialog. Each plugin creates a widget
|
|
25
|
+
containing its settings controls.
|
|
26
|
+
|
|
27
|
+
Class Attributes:
|
|
28
|
+
type_name: "settings" - identifies this as a settings plugin.
|
|
29
|
+
is_singleton: True - settings plugins are singletons.
|
|
30
|
+
|
|
31
|
+
Lifecycle:
|
|
32
|
+
1. Plugin is instantiated on load
|
|
33
|
+
2. on_loaded() is called (for preload plugins, applies settings immediately)
|
|
34
|
+
3. When Preferences dialog opens:
|
|
35
|
+
- create_widget() is called once and cached
|
|
36
|
+
- load_settings() populates widget with current values
|
|
37
|
+
4. As user interacts:
|
|
38
|
+
- apply_preview() is called for live preview
|
|
39
|
+
5. On OK/Apply:
|
|
40
|
+
- validate() checks values
|
|
41
|
+
- save_settings() persists values
|
|
42
|
+
6. On Cancel:
|
|
43
|
+
- revert_preview() undoes any preview changes
|
|
44
|
+
|
|
45
|
+
Example implementation::
|
|
46
|
+
|
|
47
|
+
class MySettingsPlugin(SettingsPlugin):
|
|
48
|
+
@property
|
|
49
|
+
def name(self) -> str:
|
|
50
|
+
return "my_settings"
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def display_name(self) -> str:
|
|
54
|
+
return "My Settings"
|
|
55
|
+
|
|
56
|
+
def create_widget(self, parent=None) -> QWidget:
|
|
57
|
+
widget = QWidget(parent)
|
|
58
|
+
# Create controls...
|
|
59
|
+
return widget
|
|
60
|
+
|
|
61
|
+
def load_settings(self) -> None:
|
|
62
|
+
prefs = PreferencesManager.get_instance()
|
|
63
|
+
self._my_control.setValue(prefs.get("my_key"))
|
|
64
|
+
|
|
65
|
+
def save_settings(self) -> None:
|
|
66
|
+
prefs = PreferencesManager.get_instance()
|
|
67
|
+
prefs.set("my_key", self._my_control.value())
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
type_name: ClassVar[str] = "settings"
|
|
71
|
+
is_singleton: ClassVar[bool] = True
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def description(self) -> str:
|
|
75
|
+
"""Human-readable description of this settings plugin."""
|
|
76
|
+
return "Settings/Preferences plugin"
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
@abstractmethod
|
|
80
|
+
def name(self) -> str:
|
|
81
|
+
"""Unique identifier for this settings plugin.
|
|
82
|
+
|
|
83
|
+
This should be unique within the settings type and is used to
|
|
84
|
+
identify the plugin in the registry.
|
|
85
|
+
"""
|
|
86
|
+
...
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def display_name(self) -> str:
|
|
90
|
+
"""Human-readable name shown in preferences sidebar.
|
|
91
|
+
|
|
92
|
+
Override this to provide a custom display name. By default,
|
|
93
|
+
converts the name to title case.
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
Display name for the sidebar.
|
|
97
|
+
"""
|
|
98
|
+
return self.name.replace("_", " ").title()
|
|
99
|
+
|
|
100
|
+
@property
|
|
101
|
+
def icon(self) -> QIcon | None:
|
|
102
|
+
"""Optional icon for the preferences sidebar.
|
|
103
|
+
|
|
104
|
+
Override this to provide an icon. Returns None by default.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
QIcon or None.
|
|
108
|
+
"""
|
|
109
|
+
return None
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
def category(self) -> str:
|
|
113
|
+
"""Category for grouping settings in the sidebar.
|
|
114
|
+
|
|
115
|
+
Override this to group related settings together.
|
|
116
|
+
Common categories: "general", "appearance", "advanced", "plugins".
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
Category name. Defaults to "general".
|
|
120
|
+
"""
|
|
121
|
+
return "general"
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def priority(self) -> int:
|
|
125
|
+
"""Sort order within category (lower = higher in list).
|
|
126
|
+
|
|
127
|
+
Override this to control ordering. Lower values appear first.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
Priority value. Defaults to 100.
|
|
131
|
+
"""
|
|
132
|
+
return 100
|
|
133
|
+
|
|
134
|
+
@abstractmethod
|
|
135
|
+
def create_widget(self, parent: QWidget | None = None) -> QWidget:
|
|
136
|
+
"""Create the settings widget.
|
|
137
|
+
|
|
138
|
+
This is called once when the Preferences dialog opens. The returned
|
|
139
|
+
widget is cached and reused for subsequent opens.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
parent: Parent widget (the dialog).
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
A QWidget containing the settings controls.
|
|
146
|
+
"""
|
|
147
|
+
...
|
|
148
|
+
|
|
149
|
+
@abstractmethod
|
|
150
|
+
def load_settings(self) -> None:
|
|
151
|
+
"""Load current settings into the widget.
|
|
152
|
+
|
|
153
|
+
Called when the Preferences dialog opens, after create_widget().
|
|
154
|
+
Should populate the widget controls with current values from
|
|
155
|
+
PreferencesManager.
|
|
156
|
+
"""
|
|
157
|
+
...
|
|
158
|
+
|
|
159
|
+
@abstractmethod
|
|
160
|
+
def save_settings(self) -> None:
|
|
161
|
+
"""Save widget values to persistent storage.
|
|
162
|
+
|
|
163
|
+
Called when the user clicks OK or Apply, after validate() passes.
|
|
164
|
+
Should write values from the widget controls to PreferencesManager.
|
|
165
|
+
"""
|
|
166
|
+
...
|
|
167
|
+
|
|
168
|
+
def validate(self) -> list[str]:
|
|
169
|
+
"""Validate current widget values.
|
|
170
|
+
|
|
171
|
+
Called before save_settings(). Return a list of error messages
|
|
172
|
+
for any validation failures. If the list is non-empty, save is
|
|
173
|
+
blocked and errors are displayed.
|
|
174
|
+
|
|
175
|
+
Returns:
|
|
176
|
+
List of error messages, or empty list if valid.
|
|
177
|
+
"""
|
|
178
|
+
return []
|
|
179
|
+
|
|
180
|
+
def apply_preview(self) -> None:
|
|
181
|
+
"""Apply settings temporarily for live preview.
|
|
182
|
+
|
|
183
|
+
Called when the user changes settings in the dialog, allowing
|
|
184
|
+
immediate visual feedback (e.g., theme changes). Preview changes
|
|
185
|
+
should be reversible via revert_preview().
|
|
186
|
+
|
|
187
|
+
Override this for settings that benefit from live preview.
|
|
188
|
+
"""
|
|
189
|
+
pass
|
|
190
|
+
|
|
191
|
+
def revert_preview(self) -> None:
|
|
192
|
+
"""Revert any preview changes.
|
|
193
|
+
|
|
194
|
+
Called when the user cancels the Preferences dialog. Should undo
|
|
195
|
+
any changes made by apply_preview() and restore original values.
|
|
196
|
+
|
|
197
|
+
Override this if you implement apply_preview().
|
|
198
|
+
"""
|
|
199
|
+
pass
|
|
200
|
+
|
|
201
|
+
def on_loaded(self) -> None:
|
|
202
|
+
"""Called when plugin is loaded.
|
|
203
|
+
|
|
204
|
+
For preload plugins (preload=True), this is called before the main
|
|
205
|
+
window is created. Use this to apply settings immediately, such as
|
|
206
|
+
setting the theme before any windows appear.
|
|
207
|
+
|
|
208
|
+
Override this if your settings need to be applied at startup.
|
|
209
|
+
"""
|
|
210
|
+
pass
|
|
211
|
+
|
|
212
|
+
def get_introspection_data(self) -> dict[str, Any]:
|
|
213
|
+
"""Get introspection data for MCP tools.
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
Dictionary with settings plugin information.
|
|
217
|
+
"""
|
|
218
|
+
return {
|
|
219
|
+
"type": self.type_name,
|
|
220
|
+
"name": self.name,
|
|
221
|
+
"display_name": self.display_name,
|
|
222
|
+
"category": self.category,
|
|
223
|
+
"priority": self.priority,
|
|
224
|
+
"class": self.__class__.__name__,
|
|
225
|
+
"module": self.__class__.__module__,
|
|
226
|
+
}
|