Skip to content

Personal AI, On Personal Devices

Python

feat: tag engines with is_cloud and tools with is_local for boundary scanning

Jon Saad-Falcon677ece6fb35a
diff --git a/src/openjarvis/engine/_stubs.py b/src/openjarvis/engine/_stubs.py
index 04604c0e..4a940274 100644
--- a/src/openjarvis/engine/_stubs.py
+++ b/src/openjarvis/engine/_stubs.py
@@ -53,6 +53,7 @@ class InferenceEngine(ABC):
"""
engine_id: str
+ is_cloud: bool = False
@abstractmethod
def generate(
diff --git a/src/openjarvis/engine/cloud.py b/src/openjarvis/engine/cloud.py
index d58b131f..7a6340c0 100644
--- a/src/openjarvis/engine/cloud.py
+++ b/src/openjarvis/engine/cloud.py
@@ -213,6 +213,7 @@ class CloudEngine(InferenceEngine):
"""Cloud inference via OpenAI, Anthropic, Google, and MiniMax SDKs."""
engine_id = "cloud"
+ is_cloud = True
def __init__(self) -> None:
self._openai_client: Any = None
diff --git a/src/openjarvis/engine/litellm.py b/src/openjarvis/engine/litellm.py
index fb25dfdd..a90ec474 100644
--- a/src/openjarvis/engine/litellm.py
+++ b/src/openjarvis/engine/litellm.py
@@ -27,6 +27,7 @@ class LiteLLMEngine(InferenceEngine):
"""
engine_id = "litellm"
+ is_cloud = True
def __init__(
self,
diff --git a/src/openjarvis/tools/_stubs.py b/src/openjarvis/tools/_stubs.py
index 98a73d1f..b8a3d4fe 100644
--- a/src/openjarvis/tools/_stubs.py
+++ b/src/openjarvis/tools/_stubs.py
@@ -51,6 +51,7 @@ class BaseTool(ABC):
"""
tool_id: str
+ is_local: bool = True
@property
@abstractmethod
diff --git a/src/openjarvis/tools/audio_tool.py b/src/openjarvis/tools/audio_tool.py
index 4fb77928..823c4260 100644
--- a/src/openjarvis/tools/audio_tool.py
+++ b/src/openjarvis/tools/audio_tool.py
@@ -19,6 +19,7 @@ class AudioTranscribeTool(BaseTool):
"""Transcribe audio files using OpenAI Whisper or a local provider."""
tool_id = "audio_transcribe"
+ is_local = False
@property
def spec(self) -> ToolSpec:
diff --git a/src/openjarvis/tools/browser.py b/src/openjarvis/tools/browser.py
index c026d587..a8f9211b 100644
--- a/src/openjarvis/tools/browser.py
+++ b/src/openjarvis/tools/browser.py
@@ -57,6 +57,7 @@ class BrowserNavigateTool(BaseTool):
"""Navigate to a URL in the browser."""
tool_id = "browser_navigate"
+ is_local = False
@property
def spec(self) -> ToolSpec:
@@ -155,6 +156,7 @@ class BrowserClickTool(BaseTool):
"""Click an element on the page."""
tool_id = "browser_click"
+ is_local = False
@property
def spec(self) -> ToolSpec:
@@ -234,6 +236,7 @@ class BrowserTypeTool(BaseTool):
"""Type text into a form field."""
tool_id = "browser_type"
+ is_local = False
@property
def spec(self) -> ToolSpec:
@@ -324,6 +327,7 @@ class BrowserScreenshotTool(BaseTool):
"""Take a screenshot of the current page."""
tool_id = "browser_screenshot"
+ is_local = False
@property
def spec(self) -> ToolSpec:
@@ -403,6 +407,7 @@ class BrowserExtractTool(BaseTool):
"""Extract content from the current page."""
tool_id = "browser_extract"
+ is_local = False
@property
def spec(self) -> ToolSpec:
diff --git a/src/openjarvis/tools/browser_axtree.py b/src/openjarvis/tools/browser_axtree.py
index ed0b7c58..84f65986 100644
--- a/src/openjarvis/tools/browser_axtree.py
+++ b/src/openjarvis/tools/browser_axtree.py
@@ -28,6 +28,7 @@ class BrowserAXTreeTool(BaseTool):
"""Extract the accessibility tree from the current browser page."""
tool_id = "browser_axtree"
+ is_local = False
@property
def spec(self) -> ToolSpec:
diff --git a/src/openjarvis/tools/channel_tools.py b/src/openjarvis/tools/channel_tools.py
index aeb79b4c..7c5b2607 100644
--- a/src/openjarvis/tools/channel_tools.py
+++ b/src/openjarvis/tools/channel_tools.py
@@ -19,6 +19,7 @@ class ChannelSendTool(BaseTool):
"""MCP-exposed tool: send a message via a channel backend."""
tool_id = "channel_send"
+ is_local = False
def __init__(self, channel: BaseChannel | None = None) -> None:
self._channel = channel
diff --git a/src/openjarvis/tools/http_request.py b/src/openjarvis/tools/http_request.py
index fe61adbb..4206b09b 100644
--- a/src/openjarvis/tools/http_request.py
+++ b/src/openjarvis/tools/http_request.py
@@ -26,6 +26,7 @@ class HttpRequestTool(BaseTool):
"""Make HTTP requests to external APIs with SSRF protection."""
tool_id = "http_request"
+ is_local = False
@property
def spec(self) -> ToolSpec:
diff --git a/src/openjarvis/tools/image_tool.py b/src/openjarvis/tools/image_tool.py
index 5b18b5ee..0e78140e 100644
--- a/src/openjarvis/tools/image_tool.py
+++ b/src/openjarvis/tools/image_tool.py
@@ -17,6 +17,7 @@ class ImageGenerateTool(BaseTool):
"""Generate images from text descriptions via OpenAI DALL-E."""
tool_id = "image_generate"
+ is_local = False
@property
def spec(self) -> ToolSpec:
diff --git a/src/openjarvis/tools/web_search.py b/src/openjarvis/tools/web_search.py
index 9b10bef3..fcf5fe1a 100644
--- a/src/openjarvis/tools/web_search.py
+++ b/src/openjarvis/tools/web_search.py
@@ -19,6 +19,7 @@ class WebSearchTool(BaseTool):
"""Search the web via Tavily API."""
tool_id = "web_search"
+ is_local = False
def __init__(self, api_key: str | None = None, max_results: int = 5):
self._api_key = api_key or os.environ.get("TAVILY_API_KEY")
diff --git a/tests/security/test_boundary_guard.py b/tests/security/test_boundary_guard.py
index 62499023..8bfd6dcf 100644
--- a/tests/security/test_boundary_guard.py
+++ b/tests/security/test_boundary_guard.py
@@ -102,3 +102,61 @@ class TestBoundaryGuardDisabled:
text = "sk-proj-abc123def456ghi789jkl012mno345pqr678stu"
result = guard.scan_outbound(text, destination="openai")
assert result == text
+
+
+class TestEngineTagging:
+ """Cloud engines must have is_cloud=True, local engines is_cloud=False."""
+
+ def test_inference_engine_default_is_local(self) -> None:
+ from openjarvis.engine._stubs import InferenceEngine
+
+ assert InferenceEngine.is_cloud is False
+
+ def test_cloud_engine_is_cloud(self) -> None:
+ from openjarvis.engine.cloud import CloudEngine
+
+ assert CloudEngine.is_cloud is True
+
+ def test_litellm_engine_is_cloud(self) -> None:
+ from openjarvis.engine.litellm import LiteLLMEngine
+
+ assert LiteLLMEngine.is_cloud is True
+
+ def test_ollama_engine_is_local(self) -> None:
+ from openjarvis.engine.ollama import OllamaEngine
+
+ assert OllamaEngine.is_cloud is False
+
+
+class TestToolTagging:
+ """External tools must have is_local=False, local tools is_local=True."""
+
+ def test_base_tool_default_is_local(self) -> None:
+ from openjarvis.tools._stubs import BaseTool
+
+ assert BaseTool.is_local is True
+
+ def test_web_search_is_external(self) -> None:
+ from openjarvis.tools.web_search import WebSearchTool
+
+ assert WebSearchTool.is_local is False
+
+ def test_http_request_is_external(self) -> None:
+ from openjarvis.tools.http_request import HttpRequestTool
+
+ assert HttpRequestTool.is_local is False
+
+ def test_channel_send_is_external(self) -> None:
+ from openjarvis.tools.channel_tools import ChannelSendTool
+
+ assert ChannelSendTool.is_local is False
+
+ def test_think_tool_is_local(self) -> None:
+ from openjarvis.tools.think import ThinkTool
+
+ assert ThinkTool.is_local is True
+
+ def test_calculator_is_local(self) -> None:
+ from openjarvis.tools.calculator import CalculatorTool
+
+ assert CalculatorTool.is_local is True