Skip to content

feat: ceki-daemon persistent renter-process + CLI IPC#15

Open
iWedmak wants to merge 10 commits into
masterfrom
feature/daemon
Open

feat: ceki-daemon persistent renter-process + CLI IPC#15
iWedmak wants to merge 10 commits into
masterfrom
feature/daemon

Conversation

@iWedmak

@iWedmak iWedmak commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

ceki-daemon — persistent renter-process, решающий CLI one-shot session disconnect.

Что сделано

Part 1 — daemon core (новый ceki_sdk/daemon.py)

  • HTTP/JSON IPC сервер (localhost:18777), 18 endpoints
  • Persistent WS-соединение с auto-reconnect (exponential backoff)
  • PID file /tmp/ceki-daemon.pid
  • Graceful shutdown по SIGTERM/SIGINT
  • Zero новых pip-зависимостей — только stdlib

Part 2 — CLI integration (ceki_sdk/cli.py)

  • ceki daemon start|stop|status
  • Все browser-команды (navigate, click, type, screenshot и т.д.) проверяют daemon first:
    • daemon alive → IPC запрос
    • daemon down → clear error
    • без daemon → fallback one-shot (backward compat)

Part 3 — SDK transport

  • Browser API не меняется

Версия

bump 2.35.6 → 2.36.0

После merge — создать GitHub Release v2.36.0 для публикации на PyPI.

ceki-plugin added 10 commits July 19, 2026 15:09
…e import logging, visible stderr error

- Sync __init__.__version__ to 2.36.0 matching pyproject.toml
- Close log_file handle after subprocess.Popen in _ensure_daemon() and _cmd_daemon_start()
- Move import logging to top-level imports
- Add user-visible stderr error on daemon auto-start failure in _ensure_daemon()
- Remove redundant is_running() check after for-loop (proc.poll() already covers it)
- Add .claude/ .graphifyignore .mypy_cache/ to .gitignore
Missing [project.scripts] ceki-daemon = ceki_sdk.daemon:main entry
point — the published PyPI package had no ceki-daemon binary.
Every Joe review round (4400, 4439, 4444) cited this as the blocker.
Same wire call, same args, different name — lets AI agents express
'edit the task' intent instead of 'propose a correction'.

- New top-level subcommand 'edit' (ceki edit <eid> --label ...)
- Delegates to ContractClient.propose() under the hood
- Accepts all the same args: --status, --label, --desc, --start,
  --end, --date, --duration, --amount, --currency, --benefitable, --tags
Added 'edit' as a contract subparser (ceki contract edit <eid> ...)
that delegates to ContractClient.propose() — same args, same wire
call, different name for 'edit task' intent.
- WebRTCTransport: wraps aiortc RTCPeerConnection for P2P CDP
  over DataChannel('ceki-cmd') with ICE candidate queuing
- _client.py: P2P init, webrtc.offer/answer/ice_candidate dispatch
- _browser.py: DC-aware Browser.send() — P2P transport preferred
  over WS fallback when ceki-cmd DC is open
- CEKI_FORCE_WS env flag, CEKI_TURN_SERVERS env,
  CEKI_ICE_TRANSPORT_POLICY env
- 41 unit tests in tests/test_webrtc_p2p.py (134/135 pass,
  1 pre-existing failure in test_cli.py)
- pyproject.toml: aiortc>=1.9,<2 dependency
BUG: In P2P mode (cmd_dc_open=true), CDP responses arrive via BOTH
WS relay (as cdp_response) and the ceki-cmd data channel. The WS
response arrives first but has empty result {} for large payloads
like screenshot base64. The pending CDP future resolves with empty
data before the DC response with real data arrives.

FIX: In _reader_loop, when P2P is active and cmd_dc_open is true,
skip WS cdp_response messages. The DC response arrives and resolves
the future with complete data. When DC is not open (WS-only mode),
WS cdp_response is handled as before.

Affected: screenshot(), snapshot() return 0 bytes in P2P mode without this fix.
v1 (25cb42e) was too broad: skipped ALL WS cdp_response when P2P
DC was open, including responses for commands sent via WS before
P2P connected.

v2 fix: tag each pending CDP future with its transport ('dc' or 'ws')
at send time. _on_cdp_response only skips WS echo for futures tagged
as 'dc' (the screenshot race). WS-sent commands resolve normally even
if P2P connects before their response arrives.

Key changes:
- Browser.send(): tag fut._cdp_transport before storing
- Browser._on_cdp_response(): check tag + message origin;
  skip WS echo for DC-sent commands, accept all others
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