refactor(browser): make sessionName optional, add selector filter, deduplicate session setup

- sessionName is now optional in open/exec; skips session restore when omitted
- add selector param to open: returns outerHTML or textContent of matched element
- extract session restore logic into private setupSession() to remove duplication
- replace per-exception instanceof checks with single HttpException base class check
- embed label into InternalServerErrorException message instead of logging separately
- update MCP tool schemas and HTTP DTOs to reflect optional sessionName and new selector
- add integration tests: sessionless open/exec, selector, selector+readerMode
This commit is contained in:
ars9 committed 2026-04-08 11:10:08 +03:00
1 parent f1dadc602a
commit f0437d9390
7 files changed
+109 -86

No files matched your search

+1 -1
View File
@@ -30,7 +30,7 @@ export class BrowserController {
@ApiResponse({ status: 404, description: 'Session not found' })
@ApiResponse({ status: 500, description: 'Browser automation failed' })
open(@Body() dto: OpenDto): Promise<OpenResult> {
return this.browserService.open(dto.sessionName, dto.url, dto.readerMode ?? false);
return this.browserService.open(dto.sessionName, dto.url, dto.readerMode ?? false, dto.selector);
}
@Post('exec')