mirror of
https://github.com/browser-use/browser-use.git
synced 2026-09-14 19:59:47 +08:00
1905f6aff1
- Rm extract (dead, always errored) - Rm sessions (confusable with cloud session) - Rm server (overlaps with close) - Rename type to type-text to distinguish from input - Clarify close vs session stop and cookies vs profile cookies in help text and docs
32 lines
898 B
Python
32 lines
898 B
Python
"""Session management command handlers."""
|
|
|
|
import logging
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
if TYPE_CHECKING:
|
|
from browser_use.skill_cli.sessions import SessionRegistry
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
COMMANDS = {'close'}
|
|
|
|
|
|
async def handle(action: str, session_name: str, registry: 'SessionRegistry', params: dict[str, Any]) -> Any:
|
|
"""Handle session management command."""
|
|
if action == 'close':
|
|
if params.get('all'):
|
|
# Close all sessions and signal shutdown
|
|
sessions = registry.list_sessions()
|
|
await registry.close_all()
|
|
return {
|
|
'closed': [s['name'] for s in sessions],
|
|
'count': len(sessions),
|
|
'_shutdown': True, # Signal to stop server
|
|
}
|
|
else:
|
|
# Close this server's session and shutdown
|
|
await registry.close_session(session_name)
|
|
return {'closed': session_name, '_shutdown': True}
|
|
|
|
raise ValueError(f'Unknown session action: {action}')
|