-
public final class ClientToolRegistryRegistry for managing client-side tools that can be executed by ElevenLabs agents
This class provides a comprehensive framework for registering, validating, and executing client tools with proper error handling, timeout management, and async execution.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classClientToolRegistry.Companion
-
Constructor Summary
Constructors Constructor Description ClientToolRegistry()
-
Method Summary
Modifier and Type Method Description final UnitregisterTool(String name, ClientTool tool)Register a client tool that can be called by agents final BooleanunregisterTool(String name)Unregister a previously registered client tool final ClientToolResultexecuteTool(String name, Map<String, Object> parameters, Long timeoutMs)Execute a client tool with the provided parameters final UnitexecuteToolAsync(String name, Map<String, Object> parameters, Function1<ClientToolResult, Unit> callback)Execute a tool in the background without waiting for the result final List<String>getRegisteredTools()Get a list of all registered tool names final BooleanisToolRegistered(String name)Check if a tool with the given name is registered final IntegergetToolCount()Get the number of registered tools final UnitclearAllTools()Clear all registered tools final Unitcleanup()Clean up resources when the registry is no longer needed -
-
Method Detail
-
registerTool
final Unit registerTool(String name, ClientTool tool)
Register a client tool that can be called by agents
- Parameters:
name- Unique identifier for the tool that agents will usetool- Implementation of the tool functionality
-
unregisterTool
final Boolean unregisterTool(String name)
Unregister a previously registered client tool
- Parameters:
name- Tool identifier to remove
-
executeTool
final ClientToolResult executeTool(String name, Map<String, Object> parameters, Long timeoutMs)
Execute a client tool with the provided parameters
- Parameters:
name- Tool name to executeparameters- Parameters to pass to the tooltimeoutMs- Maximum execution time in milliseconds
-
executeToolAsync
final Unit executeToolAsync(String name, Map<String, Object> parameters, Function1<ClientToolResult, Unit> callback)
Execute a tool in the background without waiting for the result
- Parameters:
name- Tool name to executeparameters- Parameters to pass to the toolcallback- Optional callback to receive the result
-
getRegisteredTools
final List<String> getRegisteredTools()
Get a list of all registered tool names
-
isToolRegistered
final Boolean isToolRegistered(String name)
Check if a tool with the given name is registered
- Parameters:
name- Tool name to check
-
getToolCount
final Integer getToolCount()
Get the number of registered tools
-
clearAllTools
final Unit clearAllTools()
Clear all registered tools
-
-
-
-