Skip to content

Commit 063e632

Browse files
k4cper-gclaude
andcommitted
feat: initial release of CUP Python SDK
Python SDK for the Computer Use Protocol — tree capture, action execution, semantic search, and MCP server for AI agent integration. Extracted from computeruseprotocol/computer-use-protocol. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0 parents  commit 063e632

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+14165
-0
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.13"
19+
20+
- name: Install dependencies
21+
run: pip install -e ".[dev]"
22+
23+
- name: Ruff check
24+
run: ruff check cup/ tests/
25+
26+
- name: Ruff format check
27+
run: ruff format --check cup/ tests/
28+
29+
- name: Mypy
30+
run: mypy cup/ --ignore-missing-imports
31+
32+
test:
33+
runs-on: ${{ matrix.os }}
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
os: [ubuntu-latest, windows-latest, macos-latest]
38+
python-version: ["3.10", "3.12", "3.13"]
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Set up Python ${{ matrix.python-version }}
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{ matrix.python-version }}
47+
48+
- name: Install dependencies
49+
run: pip install -e ".[dev]"
50+
51+
- name: Run tests
52+
run: pytest -v

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.egg-info/
5+
dist/
6+
build/
7+
.venv/
8+
venv/
9+
10+
# Environment
11+
.env
12+
.mcp.json
13+
.claude/
14+
15+
# Runs / output data
16+
runs/
17+
benchmark/
18+
19+
# Testing
20+
.pytest_cache/
21+
22+
# IDE
23+
.vscode/
24+
.idea/

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
6+
7+
## [0.1.0] - 2026-02-23
8+
9+
Initial release. Extracted from [computeruseprotocol/computer-use-protocol](https://github.com/computeruseprotocol/computer-use-protocol).
10+
11+
### Added
12+
- **Platform adapters** for tree capture:
13+
- Windows (UIA COM via comtypes)
14+
- macOS (AXUIElement via pyobjc)
15+
- Linux (AT-SPI2 via PyGObject)
16+
- Web (Chrome DevTools Protocol)
17+
- **Action execution** on Windows and Web platforms (macOS and Linux planned)
18+
- **MCP server** (`cup-mcp`) with 7 tools for AI agent integration
19+
- **Semantic search engine** with fuzzy matching, role synonyms, and relevance ranking
20+
- **Viewport-aware pruning** that clips offscreen nodes using nested scrollable container intersection
21+
- **Session API** with `capture()`, `execute()`, `press_keys()`, `find_elements()`, `batch_execute()`, and `screenshot()`
22+
- **CLI** (`python -m cup`) for tree capture, JSON export, and compact output
23+
- **CI** with GitHub Actions running tests on Windows, macOS, and Linux
24+
25+
[0.1.0]: https://github.com/computeruseprotocol/python-sdk/releases/tag/v0.1.0

CODE_OF_CONDUCT.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment:
18+
19+
* Using welcoming and inclusive language
20+
* Being respectful of differing viewpoints and experiences
21+
* Giving and gracefully accepting constructive feedback
22+
* Accepting responsibility and apologizing to those affected by our mistakes
23+
* Focusing on what is best for the community
24+
25+
Examples of unacceptable behavior:
26+
27+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
28+
* Trolling, insulting or derogatory comments, and personal or political attacks
29+
* Public or private harassment
30+
* Publishing others' private information without their explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a professional setting
32+
33+
## Enforcement Responsibilities
34+
35+
Community leaders are responsible for clarifying and enforcing our standards of
36+
acceptable behavior and will take appropriate and fair corrective action in
37+
response to any behavior that they deem inappropriate, threatening, offensive,
38+
or harmful.
39+
40+
## Scope
41+
42+
This Code of Conduct applies within all community spaces, and also applies when
43+
an individual is officially representing the community in public spaces.
44+
45+
## Enforcement
46+
47+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
48+
reported to the project maintainers at **cup@computeruseprotocol.com**.
49+
50+
All complaints will be reviewed and investigated promptly and fairly. All
51+
community leaders are obligated to respect the privacy and security of the
52+
reporter of any incident.
53+
54+
## Attribution
55+
56+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/),
57+
version 2.1, available at
58+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).

CONTRIBUTING.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Contributing to the CUP Python SDK
2+
3+
Thanks for your interest in the Computer Use Protocol! CUP is in early development (v0.1.0) and contributions are welcome.
4+
5+
> For changes to the protocol schema, compact format spec, or role mappings, please contribute to [computer-use-protocol](https://github.com/computeruseprotocol/computer-use-protocol).
6+
7+
## Getting started
8+
9+
1. Fork the repository and clone your fork
10+
2. Create a virtual environment and install dev dependencies:
11+
12+
```bash
13+
python -m venv .venv
14+
source .venv/bin/activate # or .venv\Scripts\activate on Windows
15+
pip install -e ".[dev]"
16+
```
17+
18+
3. Run the test suite to verify your setup:
19+
20+
```bash
21+
pytest -v
22+
```
23+
24+
## Making changes
25+
26+
1. Create a branch from `main`:
27+
28+
```bash
29+
git checkout -b my-feature
30+
```
31+
32+
2. Make your changes. Follow existing code style — type hints, docstrings on public APIs, 4-space indentation.
33+
34+
3. Add or update tests for any changed behavior. Tests live in `tests/`.
35+
36+
4. Run the full suite and ensure it passes:
37+
38+
```bash
39+
pytest -v
40+
```
41+
42+
5. Run linting and type checks:
43+
44+
```bash
45+
ruff check cup/ tests/
46+
mypy cup/
47+
```
48+
49+
6. Open a pull request against `main`. Describe what you changed and why.
50+
51+
## What we're looking for
52+
53+
High-impact areas where contributions are especially useful:
54+
55+
- **Android adapter** (`cup/platforms/android.py`) — ADB + AccessibilityNodeInfo
56+
- **iOS adapter** (`cup/platforms/ios.py`) — XCUITest accessibility
57+
- **macOS / Linux action execution** — currently tree capture only
58+
- **Tests** — especially cross-platform integration tests
59+
- **Documentation** — tutorials, examples, API reference improvements
60+
61+
## Pull request guidelines
62+
63+
- Keep PRs focused. One feature or fix per PR.
64+
- Include tests for new functionality.
65+
- Update documentation if you change public APIs.
66+
- Ensure CI passes before requesting review.
67+
68+
## Reporting bugs
69+
70+
Open an issue with:
71+
- Platform and Python version
72+
- Minimal reproduction steps
73+
- Expected vs. actual behavior
74+
- Full traceback if applicable
75+
76+
## Code style
77+
78+
- Python 3.10+ with `from __future__ import annotations`
79+
- Type hints on all public function signatures
80+
- Docstrings on public classes and functions (Google style)
81+
- No unnecessary dependencies — platform deps are conditional
82+
83+
## License
84+
85+
By contributing, you agree that your contributions will be licensed under the [MIT License](LICENSE).

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 CUP Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)