39 lines
1.4 KiB
Python
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, [])
|