Skip to content

feat(tools): drag, evaluate_readonly, read_download, save_deliverable, set_emulation - #24

Open
unohee wants to merge 2 commits into
masterfrom
feat/task-tools
Open

unohee wants to merge 2 commits into
masterfrom
feat/task-tools

Conversation

@unohee

@unohee unohee commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

무엇

새 도구 5종 (src/lyra_browser/tools/tasks.py, register_all 에 등록):

  • drag(source, target): 두 끝을 click 과 같은 actionability 로 검사한 뒤, 상호작용 동의(hover 와 같은 INTERACT)를 거쳐 source 에서 누르고 target 위로 단계적으로 옮겨 놓는다.
  • evaluate_readonly(expression): CDP Runtime.evaluate 를 throwOnSideEffect 로 실행한다. 쓰기(대입, DOM 변경, 요청)는 정규식이 아니라 V8 이 실행 전에 거부한다(refused_side_effect). 그래서 evaluate 와 달리 승인을 묻지 않는다. cookie·web storage 를 이름으로 부르는 식은 refused_storage 로 거부한다. 값 공개 전에 묻는 storage 를 우회하지 못하게 하기 위해서다.
  • read_download(filename): 이 세션이 저장한 파일만 읽는다. 텍스트는 최대 50000자, 바이너리는 크기·sha256·앞 바이트를 돌려준다.
  • save_deliverable(name, content): 평범한 파일명만 받아 deliverables 디렉터리(<data_dir>/deliverables, UAT 에서는 run 디렉터리)에 쓴다. 기존 파일은 overwrite=true 일 때만 덮어쓰고, 1 MB 까지다.
  • set_emulation(latitude, longitude, accuracy, locale, timezone, clear): 위치(권한 부여 포함), locale, 시간대를 현재 탭과 이후 열리는 탭에 적용한다.

read_storage 는 새로 만들지 않았다. 0.4.0 의 storage 도구가 같은 일을 하고(값은 reveal 때 묻는다), 문서에 대응을 적었다. UAT 에서는 이 도구들을 기본으로 주지 않는다. 필요한 페르소나만 tools.allow 에 넣는다.

부수 변경: Config.deliverables_dir 필드, 테스트 fake(FakeMouse.down/up/move, FakeCDPSession, FakeSession.page_observers), README·docs/UAT.md.

왜

벤치마크 과제 일부는 드래그, 스크립트 상태 읽기, 다운로드 확인, 산출물 저장, 지역 설정 없이는 풀 수 없다.

검증

  • pytest -q: 1995 passed, 5 failed. 실패 5건(test_uat_llm_brains.py)은 이 venv 에 SDK 가 없어서 나며, origin/master 에서도 똑같이 실패한다. 새 tests/test_task_tools.py 는 14개 모두 통과했다. 쓰기·storage 거부, 사이트 밖 drag 의 needs_approval 처리, 두 끝 검사, 저장된 파일만 읽기, 파일명·크기·덮어쓰기 규칙, 이후 탭에 적용을 다룬다.
  • 실제 Chrome 게이트 scripts/verify_task_tools_e2e.py (headless, 2026-11-15): native·playwright 모두 ALL PASS.
    • pointer 슬라이더가 끝까지 따라감. HTML5 DnD 도 두 드라이버에서 drop 됨 (NOTE 로 측정).
    • document.title=…, DOM append, fetch 를 Chrome 이 refused_side_effect 로 거부했고, 이후 title 은 그대로였다.
    • 다운로드한 CSV 를 다시 읽음. 산출물은 쓰였고 두 번 쓰이지 않음.
    • 위치·locale·시간대가 navigation 뒤에도 유지되고, 이후 연 탭에도 locale 이 적용됨.
  • 측정 중 발견: Chrome 은 override 를 건 CDP 세션이 detach 되면 Emulation.* override 를 버린다. Playwright 의 new_cdp_session 은 별도 세션이라 탭마다 세션을 열어 둔 채 유지하도록 했다.

남은 것

  • patchright 드라이버로는 게이트를 돌리지 않았다.
  • set_emulation 은 Accept-Language 와 IP 를 바꾸지 않는다(문서에 명시).
  • 같은 날 열린 UAT PR 들과 docs/UAT.md, uat/server.py 를 같이 건드린다.

…, set_emulation

drag presses on one element and releases on another through the click
actionability checks and the interaction consent. evaluate_readonly runs an
expression with V8's throwOnSideEffect, so a write is refused by Chrome
before it runs; names of cookies and storage are left to storage, which
asks before it reveals. read_download reads only files this session saved;
save_deliverable writes a plain-named file into the deliverables directory
(a UAT run's own directory). set_emulation overrides position (granting the
permission), locale and time zone for this tab and every later one.
…is a field

Chrome drops an Emulation override when the session that set it detaches,
which Playwright's new_cdp_session does; the gate now passes on native and
Playwright.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant