intellicrack.core.tools
Tool registry for managing tool bridges.
This module provides a registry for tool bridges that handles initialization, availability checking, and tool schema generation for LLM function calling.
- ExternalToolExecutor
Signature an external namespace’s executor must satisfy.
It receives the canonical dotted function name and the parsed arguments, and returns whatever the tool produced – a plain JSON-compatible value for a simple tool, or a
ToolOutputfor one whose output is more than text or that can report its own failure. A call that cannot produce any result raisesToolError.
- ExternalDefinitionProvider
Signature an external namespace’s definition provider must satisfy.
Called every time the registry is asked what tools exist, so a source whose catalog changes at runtime – a server that added a tool, or one the operator just turned off – is reflected on the next turn without re-registering.
alias of
Callable[[],list[ToolDefinition]]
- class ExternalToolRegistry[source]
Bases:
objectNamespaces served by tool executors outside Intellicrack’s own bridges.
The wire contract for externally-sourced tools – raw JSON Schema, multi-part results, reversible wire names – is complete without any particular source of such tools, so this registry ships now and stays empty until something registers into it. An MCP client is the obvious first tenant.
Bridge namespaces are refused at registration rather than shadowed at dispatch, so the failure is a clear error at the point of the mistake instead of a bridge silently stopping working.
- register(namespace, executor, *, definitions=None)[source]
Register an executor, and optionally a definition provider, for one namespace.
- Parameters:
namespace (str) – The namespace the executor serves, e.g.
mcp-files.executor (Callable[[str, dict[str, Any]], Awaitable[object]]) – Awaitable callable invoked with the canonical dotted function name and the parsed arguments.
definitions (Callable[[], list[ToolDefinition]] | None) – Callable returning this namespace’s tool definitions, consulted every time the registry is asked what exists. A namespace registered without one can still be dispatched to, it is simply never advertised.
- Raises:
ToolError – If the namespace is empty, malformed, or reserved for an Intellicrack bridge.
- Return type:
None
- definitions()[source]
Collect the tool definitions every registered namespace advertises.
Each provider is isolated: one that raises contributes nothing and the rest still report, so a single unreachable server cannot empty the catalog and leave the model with no tools at all.
- Returns:
Definitions in registration order.
- Return type:
- get(namespace)[source]
Look up the executor serving a namespace.
- Parameters:
namespace (str) – The namespace to resolve.
- Returns:
The executor, or
Nonewhen the namespace is not registered.- Return type:
ExternalToolExecutor | None
- class ToolStatus[source]
Bases:
objectStatus of a registered tool.
- Variables:
name (ToolName) – Identifier of the tool.
available (bool) – Whether the tool is available on the system.
connected (bool) – Whether the tool is currently connected.
version (str | None) – Tool version if known.
path (Path | None) – Installation path if known.
error (str | None) – Last error if any.
- class ToolRegistry[source]
Bases:
objectRegistry for tool bridges.
Manages initialization, availability, and provides unified access to all tool bridges.
- __init__(tools_dir)[source]
Initialize the ToolRegistry with a tools directory.
- Parameters:
tools_dir (Path) – Directory for tool installations.
- Return type:
None
- property external_tools: ExternalToolRegistry
The registry of namespaces served outside Intellicrack’s bridges.
- Returns:
The registry a tool source registers into.
- Return type:
- set_session(session)[source]
Attach (or detach) the active session for every registered bridge.
Propagates the supplied session to every bridge so each bridge’s lifecycle transitions (connect, attach, error, detach) flow into the session’s
tool_statesregistry. Newly registered bridges added viaregister_bridge()inherit the current session automatically.- Parameters:
session (Session | None) – The active
Sessionto publish state into, orNoneto detach all bridges from any previously attached session.- Return type:
None
- property tools_directory: Path
The tools directory.
- Returns:
Path to tools directory.
- Return type:
Path
- async initialize()[source]
Initialize all tool bridges.
Creates bridge instances for all supported tools.
- Return type:
None
- async initialize_tool(name, port=None)[source]
Initialize a specific tool.
Finds or installs the tool and initializes its bridge.
- async shutdown()[source]
Shutdown all tool bridges.
Clears
self._bridgesafter every bridge has been shut down so a subsequent call toinitialize()rebuilds the registry from scratch instead of reusing closed bridge instances. Without this, callers observing_bridgesafter shutdown would see references to bridges whose underlying tool processes have been terminated.- Return type:
None
- get(name)[source]
Get a tool bridge by name.
- Parameters:
name (ToolName) – Tool name.
- Returns:
Tool bridge or None if not registered.
- Return type:
ToolBridgeBase | None
- register_bridge(name, bridge)[source]
Register or replace a tool bridge.
Allows callers to plug in a pre-built bridge supplied by an embedding application or a test harness without going through
initialize(). Replaces any existing bridge registered under the same name and logs the swap so the change is auditable.- Parameters:
name (ToolName) – Tool name to register the bridge under.
bridge (ToolBridgeBase) – Bridge instance to register.
- Return type:
None
- get_process_bridge()[source]
Get the process control bridge.
- Returns:
ProcessBridge instance.
- Return type:
- Raises:
ToolError – If bridge not available.
- get_frida_bridge()[source]
Get the Frida instrumentation bridge.
- Returns:
FridaBridge instance.
- Return type:
- Raises:
ToolError – If bridge not available.
- get_ghidra_bridge()[source]
Get the Ghidra analysis bridge.
- Returns:
GhidraBridge instance.
- Return type:
- Raises:
ToolError – If bridge not available.
- get_cutter_bridge()[source]
Get the Cutter/Rizin analysis bridge.
- Returns:
CutterBridge instance.
- Return type:
- Raises:
ToolError – If bridge not available.
- get_x64dbg_bridge()[source]
Get the x64dbg debugger bridge.
- Returns:
X64DbgBridge instance.
- Return type:
- Raises:
ToolError – If bridge not available.
- get_sandbox_bridge()[source]
Get the sandbox bridge.
- Returns:
SandboxBridge instance.
- Return type:
- Raises:
ToolError – If bridge not available.
- get_hex_editor_bridge()[source]
Get the hex editor bridge.
- Returns:
HexEditorBridge instance.
- Return type:
- Raises:
ToolError – If bridge not available.
- async get_status(name)[source]
Get status of a tool.
- Parameters:
name (ToolName) – Tool name.
- Returns:
ToolStatus instance.
- Return type:
- async get_all_status()[source]
Get status of all tools.
- Returns:
List of ToolStatus instances.
- Return type:
- get_tool_definitions()[source]
Get tool definitions for LLM function calling.
Bridge definitions come first and externally-sourced ones follow, so a provider that truncates a long tool list at its own cap drops third-party tools before it drops an Intellicrack bridge.
- Returns:
List of ToolDefinition instances.
- Return type: