platform-core/modules/serviceCenter/services/serviceAgent/externalToolRegistry.py
ValueOn AG ce612ffcfc
All checks were successful
Deploy Plattform-Core (Int) / test (push) Successful in 1m0s
Deploy Plattform-Core (Int) / deploy (push) Successful in 9s
import referencing fixes
2026-06-08 14:46:52 +02:00

39 lines
1.4 KiB
Python

# Copyright (c) 2025 Patrick Motsch
# 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, [])