Files
Laith Weinberger 1905f6aff1 drop confusing commands, rename type to type-text
- 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
2026-02-23 12:54:57 -05:00

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}')