tooluniverse.tool_registry 模块¶
简化的工具注册表,用于自动工具发现和注册。
记录工具故障。
- tooluniverse.tool_registry.register_tool(tool_type_name=None, config=None)[源代码]¶
用于自动注册工具类及其配置的装饰器。
- 用法:
@register_tool(‘CustomToolName’, config={…}) class 我的工具:
通过
- tooluniverse.tool_registry.register_tool_configs(configs)[源代码]¶
Register a list of tool configs from a sub-package (e.g. tooluniverse-circuit).
Sub-package
__init__.pyfiles call this to make their JSON configs discoverable byToolUniverse.load_tools()without requiring any entries indefault_config.py.- 参数:
configs (list) – List of tool config dicts, each containing at least a
namekey.
- tooluniverse.tool_registry.get_list_config_registry()[源代码]¶
Return the flat list of configs registered by sub-packages.
- tooluniverse.tool_registry.clear_lazy_cache()[源代码]¶
Clear the module-level lazy import cache.
Built-in tool modules (in
src/tooluniverse/tools/) are cached after their first import. Call this function in development environments when you have edited a built-in tool module and want the changes to take effect without restarting the process. After calling this, the next access to the tool will re-import its module from disk.Note: this does NOT affect workspace user tool files; those are handled separately via mtime tracking in
_import_user_python_tools().Example:
from tooluniverse.tool_registry import clear_lazy_cache clear_lazy_cache() tu.refresh_tools()
- tooluniverse.tool_registry.lazy_import_tool(tool_name)[源代码]¶
通过工具名称懒加载导入,而无需导入所有工具模块。仅导入包含所请求工具的特定模块。
- tooluniverse.tool_registry.build_lazy_registry(package_name=None)[源代码]¶
Build a mapping of tool names to module names. Prioritizes pre-computed static registry (for bundles/frozen envs). Falls back to AST analysis if static registry is missing.
- tooluniverse.tool_registry.reset_plugin_discovery()[源代码]¶
Clear the set of already-discovered plugin names.
Call this before
build_lazy_registry()(orrefresh_tools()) when a new plugin package has been installed in the current process and you want_discover_entry_point_plugins()to pick it up without restarting.