Skip to content

Personal AI, On Personal Devices

Python

fix(tools): register and correctly audit built-in tools (#1064)

Arush Wadhawan292a4e8b735a
diff --git a/src/openjarvis/security/data_boundary_audit.py b/src/openjarvis/security/data_boundary_audit.py
index 3dd70001..e58f0d4f 100644
--- a/src/openjarvis/security/data_boundary_audit.py
+++ b/src/openjarvis/security/data_boundary_audit.py
@@ -225,6 +225,7 @@ GENERIC_NETWORK_TOOLS = {"http_request"}
WEATHER_TOOLS = {"get_weather"}
MARKET_DATA_TOOLS = {"fx_macro_data"}
CHANNEL_OUTBOUND_TOOLS = {"channel_send"}
+CONNECTOR_NETWORK_TOOLS = {"digest_collect", "execute_pending_actions"}
CLOUD_MEDIA_TOOLS = {"audio_transcribe", "image_generate", "text_to_speech"}
CLOUD_TTS_BACKENDS = {"cartesia", "openai", "openai_tts"}
# Local knowledge chunks scanned by an inference engine (Deep Research path).
@@ -237,6 +238,7 @@ EXTERNAL_TOOL_SURFACES = (
| WEATHER_TOOLS
| MARKET_DATA_TOOLS
| CHANNEL_OUTBOUND_TOOLS
+ | CONNECTOR_NETWORK_TOOLS
| CLOUD_MEDIA_TOOLS
| KNOWLEDGE_ENGINE_TOOLS
)
@@ -251,12 +253,14 @@ LOCAL_ACCESS_TOOLS = {
"calendar_upcoming",
"channel_list",
"channel_status",
+ "check_permission",
"code_interpreter",
"code_interpreter_docker",
"db_query",
"docker_shell_exec",
"file_read",
"file_write",
+ "get_pending_actions",
"git_commit",
"git_diff",
"git_log",
@@ -265,6 +269,7 @@ LOCAL_ACCESS_TOOLS = {
"kg_add_relation",
"kg_neighbors",
"kg_query",
+ "knowledge_search",
"knowledge_sql",
"memory_index",
"memory_manage",
@@ -272,6 +277,8 @@ LOCAL_ACCESS_TOOLS = {
"memory_search",
"memory_store",
"pdf_extract",
+ "queue_action",
+ "record_decision",
"repl",
"retrieval",
"shell_exec",
@@ -1054,6 +1061,28 @@ def _audit_tool_surfaces(config: Any, builder: _FindingBuilder) -> None:
),
)
+ connector_tools = tools & CONNECTOR_NETWORK_TOOLS
+ if connector_tools:
+ paths = []
+ if "digest_collect" in connector_tools:
+ paths.append("authenticated sync requests -> configured connector services")
+ if "execute_pending_actions" in connector_tools:
+ paths.append(
+ "queued action payloads -> Gmail, Google Calendar, or iMessage"
+ )
+ builder.add(
+ finding_id="connector-network-tools-configured",
+ status="warn",
+ title="Tools that contact connector services are configured",
+ potential_data_path="; ".join(paths),
+ evidence=f"configured tool(s) = {_format_tools(connector_tools)}",
+ recommendation=(
+ "Review connector destinations and queued action approvals; these "
+ "tools can contact external services even when digest and channel "
+ "automation are disabled."
+ ),
+ )
+
cloud_media = tools & CLOUD_MEDIA_TOOLS
if cloud_media:
path_parts: list[str] = []
diff --git a/src/openjarvis/tools/__init__.py b/src/openjarvis/tools/__init__.py
index ddbc60d8..efb20958 100644
--- a/src/openjarvis/tools/__init__.py
+++ b/src/openjarvis/tools/__init__.py
@@ -167,4 +167,20 @@ try:
except ImportError:
pass
+try:
+ import openjarvis.tools.knowledge_search # noqa: F401
+except ImportError:
+ pass
+
+try:
+ import openjarvis.tools.browser # noqa: F401
+ import openjarvis.tools.browser_axtree # noqa: F401
+except ImportError:
+ pass
+
+try:
+ import openjarvis.tools.proactive_tools # noqa: F401
+except ImportError:
+ pass
+
__all__ = ["BaseTool", "ToolExecutor", "ToolSpec"]
diff --git a/tests/security/test_data_boundary_audit.py b/tests/security/test_data_boundary_audit.py
index 2eff9052..93999721 100644
--- a/tests/security/test_data_boundary_audit.py
+++ b/tests/security/test_data_boundary_audit.py
@@ -13,6 +13,7 @@ from openjarvis.security.data_boundary_audit import (
CHANNEL_REFERENCE_ENV_VARS,
CHANNEL_SECRET_ENV_VARS,
CLOUD_MEDIA_TOOLS,
+ CONNECTOR_NETWORK_TOOLS,
EXTERNAL_TOOL_SURFACES,
GENERIC_CREDENTIAL_ENV_VARS,
GENERIC_NETWORK_TOOLS,
@@ -39,6 +40,7 @@ EXPECTED_GENERIC_NETWORK_TOOLS = {"http_request"}
EXPECTED_WEATHER_TOOLS = {"get_weather"}
EXPECTED_MARKET_DATA_TOOLS = {"fx_macro_data"}
EXPECTED_CHANNEL_OUTBOUND_TOOLS = {"channel_send"}
+EXPECTED_CONNECTOR_NETWORK_TOOLS = {"digest_collect", "execute_pending_actions"}
EXPECTED_CLOUD_MEDIA_TOOLS = {
"audio_transcribe",
"image_generate",
@@ -51,10 +53,15 @@ EXPECTED_LOCAL_ACCESS_TOOLS = {
"apply_patch",
"calendar_search",
"calendar_upcoming",
+ "check_permission",
"docker_shell_exec",
"db_query",
+ "get_pending_actions",
+ "knowledge_search",
"knowledge_sql",
"memory_manage",
+ "queue_action",
+ "record_decision",
"repl",
"code_interpreter_docker",
"git_status",
@@ -96,6 +103,7 @@ CLASSIFIED_TOOLS = (
| WEATHER_TOOLS
| MARKET_DATA_TOOLS
| CHANNEL_OUTBOUND_TOOLS
+ | CONNECTOR_NETWORK_TOOLS
| CLOUD_MEDIA_TOOLS
| KNOWLEDGE_ENGINE_TOOLS
| LOCAL_ACCESS_TOOLS
@@ -748,12 +756,14 @@ def test_required_registered_tool_names_are_classified():
assert EXPECTED_GENERIC_NETWORK_TOOLS <= GENERIC_NETWORK_TOOLS
assert EXPECTED_WEATHER_TOOLS <= WEATHER_TOOLS
assert EXPECTED_CHANNEL_OUTBOUND_TOOLS <= CHANNEL_OUTBOUND_TOOLS
+ assert EXPECTED_CONNECTOR_NETWORK_TOOLS <= CONNECTOR_NETWORK_TOOLS
assert EXPECTED_CLOUD_MEDIA_TOOLS <= CLOUD_MEDIA_TOOLS
assert EXPECTED_KNOWLEDGE_ENGINE_TOOLS <= KNOWLEDGE_ENGINE_TOOLS
assert (
EXPECTED_GENERIC_NETWORK_TOOLS
| EXPECTED_WEATHER_TOOLS
| EXPECTED_CHANNEL_OUTBOUND_TOOLS
+ | EXPECTED_CONNECTOR_NETWORK_TOOLS
| EXPECTED_CLOUD_MEDIA_TOOLS
| EXPECTED_BROWSER_TOOLS
| EXPECTED_KNOWLEDGE_ENGINE_TOOLS
@@ -761,6 +771,30 @@ def test_required_registered_tool_names_are_classified():
assert EXPECTED_KNOWLEDGE_ENGINE_TOOLS <= EXTERNAL_TOOL_SURFACES
+ ("tool_name", "destination"),
+ [
+ ("digest_collect", "configured connector services"),
+ ("execute_pending_actions", "Gmail, Google Calendar, or iMessage"),
+ ],
+)
+def test_registered_connector_tools_warn_without_channel_or_digest_automation(
+ tmp_path, tool_name, destination
+):
+ config = _low_noise_config()
+ config.tools.enabled = tool_name
+ assert not config.digest.enabled
+ assert not config.channel.enabled
+
+ report = build_data_boundary_report(config, tmp_path)
+ findings = {finding.id: finding for finding in report.findings}
+ finding = findings["connector-network-tools-configured"]
+ assert finding.status == "warn"
+ assert tool_name in finding.evidence
+ assert destination in finding.potential_data_path
+ assert "local-access-tools-configured" not in findings
+
+
@pytest.mark.parametrize("tool_name", sorted(EXPECTED_WEATHER_TOOLS))
def test_weather_tool_produces_outbound_warn(tmp_path, tool_name):
config = _low_noise_config()
diff --git a/tests/server/test_tools_endpoint.py b/tests/server/test_tools_endpoint.py
index bd1ff32d..9c82aae7 100644
--- a/tests/server/test_tools_endpoint.py
+++ b/tests/server/test_tools_endpoint.py
@@ -49,6 +49,15 @@ def test_browser_meta_group():
assert "browser_navigate" not in names
+def test_tools_endpoint_includes_knowledge_search_and_proactive_tools():
+ from openjarvis.server.agent_manager_routes import build_tools_list
+
+ tools = build_tools_list()
+ names = {t["name"] for t in tools}
+ assert "knowledge_search" in names
+ assert "check_permission" in names
+
+
def test_web_search_available_without_tavily_key(monkeypatch):
"""DuckDuckGo fallback keeps web search usable without Tavily."""
from openjarvis.server.agent_manager_routes import build_tools_list
diff --git a/tests/tools/test_browser.py b/tests/tools/test_browser.py
index 62623a37..077cb87c 100644
--- a/tests/tools/test_browser.py
+++ b/tests/tools/test_browser.py
@@ -252,7 +252,10 @@ class TestBrowserNavigateTool:
page.goto.side_effect = Exception("net::ERR_NAME_NOT_RESOLVED")
session = _make_mock_session(page)
- with patch("openjarvis.tools.browser._session", session):
+ with (
+ patch("openjarvis.security.ssrf.check_ssrf", return_value=None),
+ patch("openjarvis.tools.browser._session", session),
+ ):
tool = BrowserNavigateTool()
result = tool.execute(url="https://nonexistent.example")
diff --git a/tests/tools/test_tool_registration.py b/tests/tools/test_tool_registration.py
index ce1cf7ee..6b7ccced 100644
--- a/tests/tools/test_tool_registration.py
+++ b/tests/tools/test_tool_registration.py
@@ -45,6 +45,8 @@ EXPECTED_TOOLS = {
"channel_status",
# http_request.py
"http_request",
+ # docker_shell_exec.py
+ "docker_shell_exec",
# shell_exec.py
"shell_exec",
# memory_manage.py
@@ -70,6 +72,8 @@ EXPECTED_TOOLS = {
"audio_transcribe",
# text_to_speech.py
"text_to_speech",
+ # digest_collect.py
+ "digest_collect",
# knowledge_tools.py
"kg_add_entity",
"kg_add_relation",
@@ -82,6 +86,22 @@ EXPECTED_TOOLS = {
# apple_calendar.py
"calendar_upcoming",
"calendar_search",
+ # knowledge_search.py
+ "knowledge_search",
+ # browser.py
+ "browser_navigate",
+ "browser_click",
+ "browser_type",
+ "browser_screenshot",
+ "browser_extract",
+ # browser_axtree.py
+ "browser_axtree",
+ # proactive_tools.py
+ "check_permission",
+ "queue_action",
+ "get_pending_actions",
+ "record_decision",
+ "execute_pending_actions",
}
@@ -90,10 +110,12 @@ def _reload_tool_modules() -> None:
The autouse ``_clean_registries`` fixture clears all registries before each
test. A plain ``import openjarvis.tools`` won't re-register because the
- submodules are already cached in ``sys.modules``. We must reload the
- individual submodules so their class-level ``@ToolRegistry.register``
- decorators execute again.
+ submodules are already cached in ``sys.modules``. We ensure the package is
+ imported, then reload the individual submodules so their class-level
+ ``@ToolRegistry.register`` decorators execute again.
"""
+ import openjarvis.tools # noqa: F401
+
for mod_name in list(sys.modules):
if (
mod_name.startswith("openjarvis.tools.")
@@ -158,3 +180,28 @@ def test_calendar_tools_register_when_connector_is_imported_first():
)
assert result.returncode == 0, result.stderr
+
+
+def test_package_import_registers_knowledge_browser_and_proactive_tools():
+ """Package import registers knowledge_search, browser, and proactive tools."""
+ result = subprocess.run(
+ [
+ sys.executable,
+ "-c",
+ (
+ "import openjarvis.tools; "
+ "from openjarvis.core.registry import ToolRegistry; "
+ "expected = {"
+ "'knowledge_search', 'browser_navigate', 'browser_axtree', "
+ "'check_permission', 'queue_action'"
+ "}; "
+ "missing = expected - set(ToolRegistry.keys()); "
+ "assert not missing, f'Missing tools: {sorted(missing)}'"
+ ),
+ ],
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+
+ assert result.returncode == 0, result.stderr