platform-core/modules/serviceCenter/services/serviceAgent/externalToolRegistry.py
ValueOn AG 4a60086c80
Some checks failed
Deploy Plattform-Core (Int) / test (push) Failing after 15s
Deploy Plattform-Core (Int) / deploy (push) Has been skipped
cp adapted to 2026 poweron
2026-06-09 09:53:31 +02:00

39 lines
1.4 KiB
Python

# Copyright (c) 2026 PowerOn AG
# All rights reserved.
"""
External agent-tool provider registry.
Allows higher-layer components (e.g. ``workflowAutomation``) to register their
agent tool definitions WITHOUT the agent service importing them. The agent
reads registered definitions by toolbox id during toolbox activation.
This inverts the dependency: ``workflowAutomation -> serviceCenter`` (push at
boot), instead of ``serviceCenter -> workflowAutomation`` (pull). The agent
never imports workflowAutomation.
Tool definition dicts are the same shape consumed by
``ToolRegistry.registerFromDefinition`` (``name``, ``description``,
``parameters``, optional ``handler`` / ``readOnly`` / ``toolSet`` ...).
"""
import logging
from typing import Dict, List, Any
logger = logging.getLogger(__name__)
_externalTools: Dict[str, List[Dict[str, Any]]] = {}
def registerExternalTools(toolboxId: str, toolDefinitions: List[Dict[str, Any]]) -> None:
"""Register agent tool definitions (with handlers) for a toolbox id."""
_externalTools[toolboxId] = list(toolDefinitions or [])
logger.info(
"Registered %d external agent tool(s) for toolbox '%s'",
len(_externalTools[toolboxId]),
toolboxId,
)
def getExternalTools(toolboxId: str) -> List[Dict[str, Any]]:
"""Return registered tool definitions for a toolbox id (empty if none)."""
return _externalTools.get(toolboxId, [])