SDK Reference
Python SDK
Python-specific setup, imports, and module structure for the CUP SDK.
Installation
pip install computeruseprotocolFor optional extras and platform-specific dependencies, see Installation.
API
The Python SDK exposes the full Session API. Here are Python-specific usage notes.
Import patterns
import cup
# Top-level convenience functions
text = cup.snapshot()
envelope = cup.snapshot_raw()
text = cup.overview()
# Session class for more control
session = cup.Session()Keyword arguments
Action parameters are passed as keyword arguments:
session.action("e5", "type", value="hello world")
session.action("e9", "scroll", direction="down")Type hints
The SDK uses Python 3.10+ type hints (str | None syntax). All public types are re-exported from cup:
from cup import Session, ActionResultModule structure
cup/
__init__.py # Public API (Session, snapshot, snapshot_raw, overview)
__main__.py # CLI entry point
_base.py # Abstract PlatformAdapter
_router.py # Platform detection and dispatch
format.py # Envelope builder, compact serializer, pruning
search.py # Semantic element search
actions/ # Per-platform action executors
platforms/ # Platform adapters (windows, macos, linux, web)
mcp/ # MCP server integration