mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-12 13:50:59 +00:00
fix(box): tighten sandbox exposure and restore box integration coverage
This commit is contained in:
@@ -147,7 +147,6 @@ class RuntimeMCPSession:
|
||||
try:
|
||||
await box_service.create_session(
|
||||
session_payload,
|
||||
skip_host_mount_validation=True,
|
||||
)
|
||||
except Exception:
|
||||
self.error_phase = MCPSessionErrorPhase.SESSION_CREATE
|
||||
@@ -164,9 +163,7 @@ class RuntimeMCPSession:
|
||||
exec_payload['cmd'] = install_cmd
|
||||
exec_payload['timeout_sec'] = self.box_config.startup_timeout_sec or 120
|
||||
try:
|
||||
result = await box_service.client.execute(
|
||||
box_service.build_spec(exec_payload, skip_host_mount_validation=True)
|
||||
)
|
||||
result = await box_service.client.execute(box_service.build_spec(exec_payload))
|
||||
except Exception:
|
||||
self.error_phase = MCPSessionErrorPhase.DEP_INSTALL
|
||||
raise
|
||||
|
||||
@@ -17,12 +17,14 @@ class NativeToolLoader(loader.ToolLoader):
|
||||
self._sandbox_exec_tool: resource_tool.LLMTool | None = None
|
||||
|
||||
async def get_tools(self, bound_plugins: list[str] | None = None) -> list[resource_tool.LLMTool]:
|
||||
if not self._is_sandbox_available():
|
||||
return []
|
||||
if self._sandbox_exec_tool is None:
|
||||
self._sandbox_exec_tool = self._build_sandbox_exec_tool()
|
||||
return [self._sandbox_exec_tool]
|
||||
|
||||
async def has_tool(self, name: str) -> bool:
|
||||
return name == SANDBOX_EXEC_TOOL_NAME
|
||||
return name == SANDBOX_EXEC_TOOL_NAME and self._is_sandbox_available()
|
||||
|
||||
async def invoke_tool(self, name: str, parameters: dict, query: pipeline_query.Query):
|
||||
if name != SANDBOX_EXEC_TOOL_NAME:
|
||||
@@ -37,6 +39,10 @@ class NativeToolLoader(loader.ToolLoader):
|
||||
async def shutdown(self):
|
||||
pass
|
||||
|
||||
def _is_sandbox_available(self) -> bool:
|
||||
box_service = getattr(self.ap, 'box_service', None)
|
||||
return bool(getattr(box_service, 'available', False))
|
||||
|
||||
def _build_sandbox_exec_tool(self) -> resource_tool.LLMTool:
|
||||
return resource_tool.LLMTool(
|
||||
name=SANDBOX_EXEC_TOOL_NAME,
|
||||
|
||||
Reference in New Issue
Block a user