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:
CREDO23 2026-06-04 13:11:56 +02:00
parent a7fde2a48e
commit aab95b9130
98 changed files with 1232 additions and 1152 deletions

View file

@ -665,7 +665,7 @@ def _refresh_mcp_cache(connector_id: int, space_id: int) -> None:
isolated from the OAuth response flow.
"""
try:
from app.agents.new_chat.tools.mcp_tools_cache import (
from app.agents.shared.tools.mcp_tools_cache import (
refresh_mcp_tools_cache_for_connector,
)

View file

@ -1668,7 +1668,7 @@ async def list_agent_tools(
Hidden (WIP) tools are excluded from the response.
"""
from app.agents.new_chat.tools.registry import BUILTIN_TOOLS
from app.agents.shared.tools.registry import BUILTIN_TOOLS
return [
AgentToolInfo(

View file

@ -675,7 +675,7 @@ async def delete_search_source_connector(
await session.commit()
if is_mcp:
from app.agents.new_chat.tools.mcp_tool import invalidate_mcp_tools_cache
from app.agents.shared.tools.mcp_tool import invalidate_mcp_tools_cache
invalidate_mcp_tools_cache(search_space_id)
@ -2687,7 +2687,7 @@ async def create_mcp_connector(
f"for user {user.id} in search space {search_space_id}"
)
from app.agents.new_chat.tools.mcp_tools_cache import (
from app.agents.shared.tools.mcp_tools_cache import (
refresh_mcp_tools_cache_for_connector,
)
@ -2867,7 +2867,7 @@ async def update_mcp_connector(
logger.info(f"Updated MCP connector {connector_id}")
from app.agents.new_chat.tools.mcp_tools_cache import (
from app.agents.shared.tools.mcp_tools_cache import (
refresh_mcp_tools_cache_for_connector,
)
@ -2927,7 +2927,7 @@ async def delete_mcp_connector(
await session.delete(connector)
await session.commit()
from app.agents.new_chat.tools.mcp_tool import invalidate_mcp_tools_cache
from app.agents.shared.tools.mcp_tool import invalidate_mcp_tools_cache
invalidate_mcp_tools_cache(search_space_id)
@ -2966,7 +2966,7 @@ async def test_mcp_server_connection(
Connection status and list of available tools
"""
try:
from app.agents.new_chat.tools.mcp_client import (
from app.agents.shared.tools.mcp_client import (
test_mcp_connection,
test_mcp_http_connection,
)
@ -3157,7 +3157,7 @@ async def trust_mcp_tool(
connectors (``LINEAR_CONNECTOR``, ``JIRA_CONNECTOR``, ...) the
storage primitive is the same JSON list under ``config.trusted_tools``.
"""
from app.agents.new_chat.tools.mcp_tool import invalidate_mcp_tools_cache
from app.agents.shared.tools.mcp_tool import invalidate_mcp_tools_cache
from app.services.user_tool_allowlist import add_user_trust
try:
@ -3197,7 +3197,7 @@ async def untrust_mcp_tool(
The tool will require HITL approval again on subsequent calls.
"""
from app.agents.new_chat.tools.mcp_tool import invalidate_mcp_tools_cache
from app.agents.shared.tools.mcp_tool import invalidate_mcp_tools_cache
from app.services.user_tool_allowlist import remove_user_trust
try: