suna agent installation cleanup

This commit is contained in:
Saumya 2025-07-30 12:29:25 +05:30
parent 26fd18b6b8
commit 080a0b1cef
7 changed files with 51 additions and 77 deletions

View File

@ -14,18 +14,6 @@ async def admin_install_suna_for_user(
replace_existing: bool = False,
_: bool = Depends(verify_admin_api_key)
):
"""Install Suna agent for a specific user account.
Args:
account_id: The account ID to install Suna agent for
replace_existing: Whether to replace existing Suna agent if found
Returns:
Success message with agent_id if successful
Raises:
HTTPException: If installation fails
"""
logger.info(f"Admin installing Suna agent for user: {account_id}")
service = SunaDefaultAgentService()

View File

@ -672,6 +672,7 @@ You have the ability to configure and enhance yourself! When users ask you to mo
- `search_mcp_servers`: Find integrations for specific services (Gmail, Slack, GitHub, etc.)
- `get_popular_mcp_servers`: Browse trending integrations
- `get_mcp_server_tools`: Explore integration capabilities
- `configure_profile_for_agent`: Add connected services to your configuration
### Credential Management
- `create_credential_profile`: Set up secure connections to external services

View File

@ -10,42 +10,14 @@ class SunaConfig:
SYSTEM_PROMPT = SYSTEM_PROMPT
DEFAULT_TOOLS = {
"sb_shell_tool": {
"enabled": True,
"description": "Execute shell commands"
},
"sb_files_tool": {
"enabled": True,
"description": "Read, write, and edit files"
},
"sb_browser_tool": {
"enabled": True,
"description": "Browse websites and interact with web pages"
},
"sb_deploy_tool": {
"enabled": True,
"description": "Deploy web applications"
},
"sb_expose_tool": {
"enabled": True,
"description": "Expose local services to the internet"
},
"web_search_tool": {
"enabled": True,
"description": "Search the web for information"
},
"sb_vision_tool": {
"enabled": True,
"description": "Analyze and understand images"
},
"sb_image_edit_tool": {
"enabled": True,
"description": "Edit and manipulate images"
},
"data_providers_tool": {
"enabled": True,
"description": "Access structured data from various providers"
}
"sb_shell_tool": True,
"sb_browser_tool": True,
"sb_deploy_tool": True,
"sb_expose_tool": True,
"web_search_tool": True,
"sb_vision_tool": True,
"sb_image_edit_tool": True,
"data_providers_tool": True
}
DEFAULT_MCPS = []

View File

@ -78,7 +78,6 @@ class SunaAgentRepository:
tools_count = len(mcp.get('enabledTools', mcp.get('enabled_tools', [])))
logger.info(f"Agent {agent_id} - Preserving custom MCP {i+1} ({mcp.get('name', 'Unknown')}) with {tools_count} enabled tools")
# Update the config with preserved MCPs and new metadata
updated_config = unified_config.copy()
updated_config['tools']['mcp'] = preserved_configured_mcps
updated_config['tools']['custom_mcp'] = preserved_custom_mcps
@ -157,7 +156,6 @@ class SunaAgentRepository:
async def create_suna_agent_simple(
self,
account_id: str,
version_tag: str
) -> str:
try:
from agent.suna.config import SunaConfig
@ -169,25 +167,11 @@ class SunaAgentRepository:
"name": SunaConfig.NAME,
"description": SunaConfig.DESCRIPTION,
"is_default": True,
"system_prompt": "[SUNA_MANAGED]",
"agentpress_tools": {},
"configured_mcps": SunaConfig.DEFAULT_MCPS,
"custom_mcps": SunaConfig.DEFAULT_CUSTOM_MCPS,
"config": {
'tools': {
'mcp': SunaConfig.DEFAULT_MCPS,
'custom_mcp': SunaConfig.DEFAULT_CUSTOM_MCPS,
'agentpress': {}
},
'metadata': {
'is_suna_default': True,
'centrally_managed': True
}
},
"avatar": SunaConfig.AVATAR,
"avatar_color": SunaConfig.AVATAR_COLOR,
"metadata": {
"is_suna_default": True,
"centrally_managed": True,
"config_version": version_tag,
"installation_date": datetime.now(timezone.utc).isoformat()
},
"version_count": 1
@ -198,6 +182,14 @@ class SunaAgentRepository:
if result.data:
agent_id = result.data[0]['agent_id']
logger.info(f"Created minimal Suna agent {agent_id} for {account_id}")
await self._create_initial_version(
agent_id=agent_id,
account_id=account_id,
system_prompt="[MANAGED]",
configured_mcps=SunaConfig.DEFAULT_MCPS,
custom_mcps=SunaConfig.DEFAULT_CUSTOM_MCPS,
agentpress_tools=SunaConfig.DEFAULT_TOOLS
)
return agent_id
raise Exception("No data returned from insert")
@ -211,7 +203,6 @@ class SunaAgentRepository:
agent_id: str,
version_tag: str
) -> bool:
"""Update only metadata for a Suna agent (system prompt/tools read from SunaConfig)"""
try:
client = await self.db.client
@ -244,7 +235,6 @@ class SunaAgentRepository:
raise
async def get_all_personal_accounts(self) -> List[str]:
"""Get all personal account IDs"""
try:
client = await self.db.client
result = await client.schema('basejump').table('accounts').select(
@ -255,4 +245,33 @@ class SunaAgentRepository:
except Exception as e:
logger.error(f"Failed to get personal accounts: {e}")
raise
raise
async def _create_initial_version(
self,
agent_id: str,
account_id: str,
system_prompt: str,
configured_mcps: List[Dict[str, Any]],
custom_mcps: List[Dict[str, Any]],
agentpress_tools: Dict[str, Any]
) -> None:
try:
from agent.versioning.version_service import get_version_service
version_service = await get_version_service()
await version_service.create_version(
agent_id=agent_id,
user_id=account_id,
system_prompt=system_prompt,
configured_mcps=configured_mcps,
custom_mcps=custom_mcps,
agentpress_tools=agentpress_tools,
version_name="v1",
change_description="Initial Suna agent version"
)
logger.info(f"Created initial version for Suna agent {agent_id}")
except Exception as e:
logger.error(f"Failed to create initial version for Suna agent {agent_id}: {e}")

View File

@ -12,7 +12,7 @@ import sys
import json
from pathlib import Path
backend_dir = Path(__file__).parent.parent
backend_dir = Path(__file__).parent.parent.parent
sys.path.insert(0, str(backend_dir))
from agent.suna import SunaSyncService

View File

@ -55,11 +55,7 @@ class SunaDefaultAgentService:
logger.info(f"User {account_id} already has Suna agent: {existing.agent_id}")
return existing.agent_id
current_config = self._sync_service.config_manager.get_current_config()
agent_id = await self._sync_service.repository.create_suna_agent_simple(
account_id,
current_config.version_tag
)
agent_id = await self._sync_service.repository.create_suna_agent_simple(account_id)
logger.info(f"Successfully installed Suna agent {agent_id} for user {account_id}")
return agent_id

View File

@ -59,8 +59,6 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
setUser(newSession?.user ?? null);
if (isLoading) setIsLoading(false);
// Handle specific auth events
switch (event) {
case 'SIGNED_IN':
if (newSession?.user) {