mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
refactor(agents): move tools package to app/agents/shared (slice 6)
Relocate the entire new_chat/tools/ package (62 files incl. registry, hitl, MCP cluster, and all connector subpackages: gmail/slack/discord/teams/drive/etc.) to the shared kernel. The package turned out to be a clean cohesive cluster: its only references to non-tools new_chat modules were comments, and its middleware deps were already flipped to shared in slice 5c. Flip 33 live importers (multi-agent, flows, routes, services, anonymous_agent, tests). Re-export shims remain for the frozen single-agent stack: a package __init__ mirroring the public surface (new_chat.__init__ imports it) plus invalid_tool + registry submodule shims (chat_deepagent imports those). Resolves slice 5c's two transient back-edges: shared/middleware/action_log (TYPE_CHECKING ToolDefinition) and tool_call_repair (local INVALID_TOOL_NAME) now point at app.agents.shared.tools.
This commit is contained in:
parent
a7fde2a48e
commit
aab95b9130
98 changed files with 1232 additions and 1152 deletions
|
|
@ -137,10 +137,10 @@ def install(active_patches: list[Any]) -> None:
|
|||
"""Patch production MCP streamable-HTTP boundaries exactly once."""
|
||||
targets = [
|
||||
(
|
||||
"app.agents.new_chat.tools.mcp_tool.streamablehttp_client",
|
||||
"app.agents.shared.tools.mcp_tool.streamablehttp_client",
|
||||
_fake_streamablehttp_client,
|
||||
),
|
||||
("app.agents.new_chat.tools.mcp_tool.ClientSession", _FakeClientSession),
|
||||
("app.agents.shared.tools.mcp_tool.ClientSession", _FakeClientSession),
|
||||
]
|
||||
for target, replacement in targets:
|
||||
p = patch(target, replacement)
|
||||
|
|
|
|||
|
|
@ -429,9 +429,9 @@ def install(active_patches: list[Any]) -> None:
|
|||
("app.connectors.google_drive.client.build", _fake_build),
|
||||
("app.connectors.google_gmail_connector.build", _fake_build),
|
||||
("app.connectors.google_calendar_connector.build", _fake_build),
|
||||
("app.agents.new_chat.tools.google_calendar.create_event.build", _fake_build),
|
||||
("app.agents.new_chat.tools.google_calendar.update_event.build", _fake_build),
|
||||
("app.agents.new_chat.tools.google_calendar.delete_event.build", _fake_build),
|
||||
("app.agents.shared.tools.google_calendar.create_event.build", _fake_build),
|
||||
("app.agents.shared.tools.google_calendar.update_event.build", _fake_build),
|
||||
("app.agents.shared.tools.google_calendar.delete_event.build", _fake_build),
|
||||
("googleapiclient.http.MediaIoBaseDownload", _FakeMediaIoBaseDownload),
|
||||
(
|
||||
"app.connectors.google_drive.client._build_thread_http",
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ def patched_shielded_session(async_engine, monkeypatch):
|
|||
yield session
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.agents.new_chat.tools.knowledge_base.shielded_async_session",
|
||||
"app.agents.shared.tools.knowledge_base.shielded_async_session",
|
||||
_test_shielded,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ async def test_browse_recent_documents_with_list_type_returns_both(
|
|||
committed_google_data, patched_shielded_session
|
||||
):
|
||||
"""_browse_recent_documents returns docs of all types when given a list."""
|
||||
from app.agents.new_chat.tools.knowledge_base import _browse_recent_documents
|
||||
from app.agents.shared.tools.knowledge_base import _browse_recent_documents
|
||||
|
||||
space_id = committed_google_data["search_space_id"]
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from langchain_core.tools import tool
|
|||
|
||||
from app.agents.shared.feature_flags import AgentFeatureFlags
|
||||
from app.agents.shared.middleware.action_log import ActionLogMiddleware
|
||||
from app.agents.new_chat.tools.registry import ToolDefinition
|
||||
from app.agents.shared.tools.registry import ToolDefinition
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ def test_no_agent_tools_means_no_dedup() -> None:
|
|||
|
||||
Coverage for the previously hardcoded native HITL tools now lives on
|
||||
each :class:`ToolDefinition.dedup_key` in
|
||||
:mod:`app.agents.new_chat.tools.registry`, which is wired through to
|
||||
:mod:`app.agents.shared.tools.registry`, which is wired through to
|
||||
``tool.metadata`` by :func:`build_tools`.
|
||||
"""
|
||||
mw = DedupHITLToolCallsMiddleware(agent_tools=None)
|
||||
|
|
@ -116,7 +116,7 @@ def test_registry_propagates_dedup_key_to_tool_metadata() -> None:
|
|||
the constructed tool's ``metadata`` so :class:`DedupHITLToolCallsMiddleware`
|
||||
can pick it up at agent build time.
|
||||
"""
|
||||
from app.agents.new_chat.tools.registry import (
|
||||
from app.agents.shared.tools.registry import (
|
||||
BUILTIN_TOOLS,
|
||||
wrap_dedup_key_by_arg_name,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ caused two production-painful behaviors:
|
|||
read-only tool calls, raising ``RejectedError("ls")``.
|
||||
* Mutating connector tools got *double* prompted — once via the
|
||||
middleware ``ask`` and again via the per-tool ``interrupt()`` in
|
||||
``app.agents.new_chat.tools.hitl``.
|
||||
``app.agents.shared.tools.hitl``.
|
||||
|
||||
These tests pin the layering so a refactor that drops the default
|
||||
ruleset fails loud.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from __future__ import annotations
|
|||
|
||||
import pytest
|
||||
|
||||
from app.agents.new_chat.tools.hitl import (
|
||||
from app.agents.shared.tools.hitl import (
|
||||
DEFAULT_AUTO_APPROVED_TOOLS,
|
||||
HITLResult,
|
||||
request_approval,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from langchain_core.messages import AIMessage
|
|||
from app.agents.shared.middleware.tool_call_repair import (
|
||||
ToolCallNameRepairMiddleware,
|
||||
)
|
||||
from app.agents.new_chat.tools.invalid_tool import INVALID_TOOL_NAME
|
||||
from app.agents.shared.tools.invalid_tool import INVALID_TOOL_NAME
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from types import SimpleNamespace
|
|||
|
||||
import pytest
|
||||
|
||||
from app.agents.new_chat.tools.mcp_tools_cache import (
|
||||
from app.agents.shared.tools.mcp_tools_cache import (
|
||||
CachedMCPToolDef,
|
||||
CachedMCPTools,
|
||||
read_cached_tools,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from unittest.mock import AsyncMock
|
|||
import pypdf
|
||||
import pytest
|
||||
|
||||
from app.agents.new_chat.tools import resume as resume_tool
|
||||
from app.agents.shared.tools import resume as resume_tool
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ async def test_global_openrouter_image_gen_sets_api_base_when_config_empty():
|
|||
async def test_generate_image_tool_global_sets_api_base_when_config_empty():
|
||||
"""Same defense at the agent tool entry point — both surfaces share
|
||||
the same OpenRouter config payloads."""
|
||||
from app.agents.new_chat.tools import generate_image as gi_module
|
||||
from app.agents.shared.tools import generate_image as gi_module
|
||||
|
||||
cfg = {
|
||||
"id": -20_001,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue