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

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jon Saad-Falcon
2026-03-28 20:26:26 -07:00
co-authored by Claude Sonnet 4.6
parent 7c1f983891
commit 677ece6fb3
12 changed files with 73 additions and 0 deletions
+1
View File
@@ -53,6 +53,7 @@ class InferenceEngine(ABC):
"""
engine_id: str
is_cloud: bool = False
@abstractmethod
def generate(
+1
View File
@@ -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
+1
View File
@@ -27,6 +27,7 @@ class LiteLLMEngine(InferenceEngine):
"""
engine_id = "litellm"
is_cloud = True
def __init__(
self,
+1
View File
@@ -51,6 +51,7 @@ class BaseTool(ABC):
"""
tool_id: str
is_local: bool = True
@property
@abstractmethod
+1
View File
@@ -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:
+5
View File
@@ -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:
+1
View File
@@ -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:
+1
View File
@@ -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
+1
View File
@@ -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:
+1
View File
@@ -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:
+1
View File
@@ -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")
+58
View File
@@ -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