Skip to content

feat(sdk): headless-browser provider mode - #18

Open
iWedmak wants to merge 5 commits into
masterfrom
feature/docker-headless-provider
Open

feat(sdk): headless-browser provider mode#18
iWedmak wants to merge 5 commits into
masterfrom
feature/docker-headless-provider

Conversation

@iWedmak

@iWedmak iWedmak commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

provider mode в SDK (ceki_sdk/_provider.py) — SDK разворачивает браузер-провайдера: token из ЛК -> провайдер online. Docker-образ вынесен в отдельный публичный репо Ceki-me/docker-browser.

Что в PR

  • provider mode в SDK (ceki_sdk/_provider.py): launcher Chromium + extension + token handshake + online poll + liveness
  • provider self-fingerprint fixes (tz match, fake audio devices, automation flag)
  • фикс убийства сессии: daemon void-command fallback + shared client WS reuse (ev 6621)
  • handle relay session_ended / error -1011 на смерти провайдера (ev 6621)

Проверено

  • QA PASS 6/6 (ev 5405, live E2E: session-ids + OCR-скрины)
  • тесты: tests/test_provider*

ceki-plugin added 5 commits August 2, 2026 19:26
Rent out a machine's browser as a public provider:

- `ceki provider run`: launches Chromium (Playwright, headed under Xvfb) with
  the Ceki extension loaded, injects the one-time browser token and brings the
  browser online with auto-accept enabled. Port of the QA public-browser
  recipe (provider-runner.js) into the Python SDK; the extension handles the
  provider WebSocket protocol itself.
- api_base normalization: accept both `https://host` and `https://host/api`
  for CEKI_API_URL / --api-url (request paths are built as base + /api/...).
- docker/: provider image (python:3.11-slim + Chromium via playwright +
  staged extension dist), entrypoint that starts Xvfb and execs the provider
  as PID 1 for clean SIGTERM shutdown, docker-compose reference, build.sh that
  stages the extension dist at build time, README.
- `[provider]` optional extra (playwright); .dockerignore keeps the staged
  extension dist out of git.
- tests: provider resolve helpers + CLI provider parser (10 tests).
- cli: _daemon_request returns (ok, result) tuple; callers branch on 'ok',
  a null result from a void command is success, not a failure signal
- daemon: reuse one shared Client per api_key (single WS, no per-rent leak);
  drop session from registry on session.ended; disconnect shared client
  only when the last session ends
- tests: unit regression for CLI void-command fallback and daemon WS reuse
The relay ends a session with 'session_ended' (underscore) carrying the id
in 'event_id', not 'session.ended'/'session_id' which the client listened
for. Relay-initiated ends (provider death, admin stop, backend reaper) were
therefore silently dropped, leaving a zombie entry in the daemon's session
registry and a live WS to the relay until an explicit /stop.

- dispatch: accept session.ended / session_end / session_ended, read the id
  from session_id or event_id
- dispatch: error -1011/-1018 with a session id is a session end, route it
  through the same cleanup (browser teardown + daemon hook) instead of
  logging it as an unhandled relay error
- tests: unit + WS-level E2E reproducing the provider-death sequence
  (session.provider_disconnected -> grace -> error -1011 + session_ended)
  verifying the daemon drops the session and closes the shared WS
@iWedmak iWedmak changed the title feat(sdk): headless-browser provider mode + docker image (ev 5203, 6621) feat(sdk): headless-browser provider mode Aug 12, 2026
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