mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
refactor(automation): drop Capability registry
This commit is contained in:
parent
9fa35f21cf
commit
7ac99b89a0
6 changed files with 3 additions and 70 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
"""Capability, action, and trigger registries — populated at process startup."""
|
"""Action and trigger registries — populated at process startup."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
@ -9,13 +9,6 @@ from .actions import (
|
||||||
get_action,
|
get_action,
|
||||||
register_action,
|
register_action,
|
||||||
)
|
)
|
||||||
from .capabilities import (
|
|
||||||
Capability,
|
|
||||||
CapabilityHandler,
|
|
||||||
all_capabilities,
|
|
||||||
get_capability,
|
|
||||||
register_capability,
|
|
||||||
)
|
|
||||||
from .triggers import (
|
from .triggers import (
|
||||||
TriggerDefinition,
|
TriggerDefinition,
|
||||||
all_triggers,
|
all_triggers,
|
||||||
|
|
@ -26,16 +19,11 @@ from .triggers import (
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"ActionDefinition",
|
"ActionDefinition",
|
||||||
"ActionHandler",
|
"ActionHandler",
|
||||||
"Capability",
|
|
||||||
"CapabilityHandler",
|
|
||||||
"TriggerDefinition",
|
"TriggerDefinition",
|
||||||
"all_actions",
|
"all_actions",
|
||||||
"all_capabilities",
|
|
||||||
"all_triggers",
|
"all_triggers",
|
||||||
"get_action",
|
"get_action",
|
||||||
"get_capability",
|
|
||||||
"get_trigger",
|
"get_trigger",
|
||||||
"register_action",
|
"register_action",
|
||||||
"register_capability",
|
|
||||||
"register_trigger",
|
"register_trigger",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,5 @@ class ActionDefinition:
|
||||||
type: str
|
type: str
|
||||||
name: str
|
name: str
|
||||||
description: str
|
description: str
|
||||||
config_schema: dict[str, Any]
|
params_schema: dict[str, Any]
|
||||||
handler: ActionHandler
|
handler: ActionHandler
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
"""Capability registry."""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from .store import all_capabilities, get_capability, register_capability
|
|
||||||
from .types import Capability, CapabilityHandler
|
|
||||||
|
|
||||||
__all__ = [
|
|
||||||
"Capability",
|
|
||||||
"CapabilityHandler",
|
|
||||||
"all_capabilities",
|
|
||||||
"get_capability",
|
|
||||||
"register_capability",
|
|
||||||
]
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
"""In-memory capability registry. Populated once at process startup."""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from .types import Capability
|
|
||||||
|
|
||||||
_REGISTRY: dict[str, Capability] = {}
|
|
||||||
|
|
||||||
|
|
||||||
def register_capability(capability: Capability) -> None:
|
|
||||||
"""Register a capability. Raises on duplicate id."""
|
|
||||||
if capability.id in _REGISTRY:
|
|
||||||
raise ValueError(f"Capability already registered: {capability.id!r}")
|
|
||||||
_REGISTRY[capability.id] = capability
|
|
||||||
|
|
||||||
|
|
||||||
def get_capability(capability_id: str) -> Capability | None:
|
|
||||||
return _REGISTRY.get(capability_id)
|
|
||||||
|
|
||||||
|
|
||||||
def all_capabilities() -> dict[str, Capability]:
|
|
||||||
"""Defensive snapshot of the registry."""
|
|
||||||
return dict(_REGISTRY)
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
"""``Capability`` dataclass and handler signature. Locked at five fields for v1."""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
CapabilityHandler = Callable[[dict[str, Any]], Awaitable[Any]]
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, slots=True)
|
|
||||||
class Capability:
|
|
||||||
id: str
|
|
||||||
description: str
|
|
||||||
input_schema: dict[str, Any]
|
|
||||||
output_schema: dict[str, Any]
|
|
||||||
handler: CapabilityHandler
|
|
||||||
|
|
@ -10,5 +10,5 @@ from typing import Any
|
||||||
class TriggerDefinition:
|
class TriggerDefinition:
|
||||||
type: str
|
type: str
|
||||||
description: str
|
description: str
|
||||||
config_schema: dict[str, Any]
|
params_schema: dict[str, Any]
|
||||||
payload_schema: dict[str, Any]
|
payload_schema: dict[str, Any]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue