computeruseprotocol 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- computeruseprotocol-0.1.0/.github/workflows/ci.yml +100 -0
- computeruseprotocol-0.1.0/.github/workflows/publish.yml +29 -0
- computeruseprotocol-0.1.0/.gitignore +24 -0
- computeruseprotocol-0.1.0/CHANGELOG.md +25 -0
- computeruseprotocol-0.1.0/CODE_OF_CONDUCT.md +58 -0
- computeruseprotocol-0.1.0/CONTRIBUTING.md +84 -0
- computeruseprotocol-0.1.0/LICENSE +21 -0
- computeruseprotocol-0.1.0/PKG-INFO +225 -0
- computeruseprotocol-0.1.0/README.md +180 -0
- computeruseprotocol-0.1.0/SECURITY.md +38 -0
- computeruseprotocol-0.1.0/assets/banner.png +0 -0
- computeruseprotocol-0.1.0/assets/cup.png +0 -0
- computeruseprotocol-0.1.0/cup/__init__.py +548 -0
- computeruseprotocol-0.1.0/cup/__main__.py +222 -0
- computeruseprotocol-0.1.0/cup/_base.py +123 -0
- computeruseprotocol-0.1.0/cup/_router.py +63 -0
- computeruseprotocol-0.1.0/cup/actions/__init__.py +9 -0
- computeruseprotocol-0.1.0/cup/actions/_handler.py +62 -0
- computeruseprotocol-0.1.0/cup/actions/_keys.py +56 -0
- computeruseprotocol-0.1.0/cup/actions/_linux.py +1008 -0
- computeruseprotocol-0.1.0/cup/actions/_macos.py +1090 -0
- computeruseprotocol-0.1.0/cup/actions/_web.py +555 -0
- computeruseprotocol-0.1.0/cup/actions/_windows.py +984 -0
- computeruseprotocol-0.1.0/cup/actions/executor.py +162 -0
- computeruseprotocol-0.1.0/cup/format.py +653 -0
- computeruseprotocol-0.1.0/cup/mcp/__init__.py +1 -0
- computeruseprotocol-0.1.0/cup/mcp/__main__.py +11 -0
- computeruseprotocol-0.1.0/cup/mcp/server.py +418 -0
- computeruseprotocol-0.1.0/cup/platforms/__init__.py +0 -0
- computeruseprotocol-0.1.0/cup/platforms/linux.py +1060 -0
- computeruseprotocol-0.1.0/cup/platforms/macos.py +1005 -0
- computeruseprotocol-0.1.0/cup/platforms/web.py +1009 -0
- computeruseprotocol-0.1.0/cup/platforms/windows.py +935 -0
- computeruseprotocol-0.1.0/cup/search.py +583 -0
- computeruseprotocol-0.1.0/docs/api-reference.md +352 -0
- computeruseprotocol-0.1.0/examples/cross-os/README.md +168 -0
- computeruseprotocol-0.1.0/examples/cross-os/cup_remote.py +306 -0
- computeruseprotocol-0.1.0/examples/cross-os/cup_server.py +194 -0
- computeruseprotocol-0.1.0/examples/cross-os/mcp_server.py +503 -0
- computeruseprotocol-0.1.0/pyproject.toml +100 -0
- computeruseprotocol-0.1.0/schema/README.md +5 -0
- computeruseprotocol-0.1.0/schema/cup.schema.json +480 -0
- computeruseprotocol-0.1.0/schema/example.json +331 -0
- computeruseprotocol-0.1.0/schema/mappings.json +108 -0
- computeruseprotocol-0.1.0/tests/__init__.py +0 -0
- computeruseprotocol-0.1.0/tests/test_actions.py +371 -0
- computeruseprotocol-0.1.0/tests/test_batch.py +156 -0
- computeruseprotocol-0.1.0/tests/test_find.py +580 -0
- computeruseprotocol-0.1.0/tests/test_format.py +1425 -0
- computeruseprotocol-0.1.0/tests/test_router.py +52 -0
- computeruseprotocol-0.1.0/tests/test_schema.py +481 -0
- computeruseprotocol-0.1.0/tests/test_screenshot.py +72 -0
- computeruseprotocol-0.1.0/tests/test_web_actions.py +269 -0
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
cache: "pip"
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: pip install -e ".[dev]"
|
|
23
|
+
|
|
24
|
+
- name: Ruff check
|
|
25
|
+
run: ruff check cup/ tests/
|
|
26
|
+
|
|
27
|
+
- name: Ruff format check
|
|
28
|
+
run: ruff format --check cup/ tests/
|
|
29
|
+
|
|
30
|
+
- name: Mypy
|
|
31
|
+
run: mypy cup/ --ignore-missing-imports
|
|
32
|
+
|
|
33
|
+
test:
|
|
34
|
+
runs-on: ${{ matrix.os }}
|
|
35
|
+
strategy:
|
|
36
|
+
fail-fast: false
|
|
37
|
+
matrix:
|
|
38
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
39
|
+
python-version: ["3.10", "3.12", "3.13"]
|
|
40
|
+
include:
|
|
41
|
+
- os: ubuntu-latest
|
|
42
|
+
python-version: "3.14"
|
|
43
|
+
experimental: true
|
|
44
|
+
continue-on-error: ${{ matrix.experimental || false }}
|
|
45
|
+
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@v4
|
|
48
|
+
|
|
49
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
50
|
+
uses: actions/setup-python@v5
|
|
51
|
+
with:
|
|
52
|
+
python-version: ${{ matrix.python-version }}
|
|
53
|
+
cache: "pip"
|
|
54
|
+
allow-prereleases: true
|
|
55
|
+
|
|
56
|
+
- name: Install dependencies
|
|
57
|
+
run: pip install -e ".[dev,web,screenshot]"
|
|
58
|
+
|
|
59
|
+
- name: Run tests with coverage
|
|
60
|
+
run: pytest -v --cov=cup --cov-report=xml --cov-report=term-missing
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
build:
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
steps:
|
|
66
|
+
- uses: actions/checkout@v4
|
|
67
|
+
|
|
68
|
+
- name: Set up Python
|
|
69
|
+
uses: actions/setup-python@v5
|
|
70
|
+
with:
|
|
71
|
+
python-version: "3.13"
|
|
72
|
+
cache: "pip"
|
|
73
|
+
|
|
74
|
+
- name: Install build tools
|
|
75
|
+
run: pip install build
|
|
76
|
+
|
|
77
|
+
- name: Build package
|
|
78
|
+
run: python -m build
|
|
79
|
+
|
|
80
|
+
- name: Verify wheel installs cleanly
|
|
81
|
+
run: |
|
|
82
|
+
pip install dist/*.whl
|
|
83
|
+
python -c "import cup; print('cup imported successfully')"
|
|
84
|
+
|
|
85
|
+
audit:
|
|
86
|
+
runs-on: ubuntu-latest
|
|
87
|
+
steps:
|
|
88
|
+
- uses: actions/checkout@v4
|
|
89
|
+
|
|
90
|
+
- name: Set up Python
|
|
91
|
+
uses: actions/setup-python@v5
|
|
92
|
+
with:
|
|
93
|
+
python-version: "3.13"
|
|
94
|
+
cache: "pip"
|
|
95
|
+
|
|
96
|
+
- name: Install dependencies
|
|
97
|
+
run: pip install -e ".[dev,web,screenshot]"
|
|
98
|
+
|
|
99
|
+
- name: Audit dependencies
|
|
100
|
+
run: pip install pip-audit && pip-audit
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment: pypi
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Set up Python
|
|
17
|
+
uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.13"
|
|
20
|
+
cache: "pip"
|
|
21
|
+
|
|
22
|
+
- name: Install build tools
|
|
23
|
+
run: pip install build
|
|
24
|
+
|
|
25
|
+
- name: Build package
|
|
26
|
+
run: python -m build
|
|
27
|
+
|
|
28
|
+
- name: Publish to PyPI
|
|
29
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -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/
|
|
@@ -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/computeruseprotocol](https://github.com/computeruseprotocol/computeruseprotocol).
|
|
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 all four platforms (Windows, macOS, Linux, Web)
|
|
18
|
+
- **MCP server** (`cup-mcp`) with 8 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 `snapshot()`, `action()`, `press()`, `find()`, `batch()`, 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
|
|
@@ -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).
|
|
@@ -0,0 +1,84 @@
|
|
|
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 [computeruseprotocol](https://github.com/computeruseprotocol/computeruseprotocol).
|
|
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
|
+
- **Tests** — especially cross-platform integration tests
|
|
58
|
+
- **Documentation** — tutorials, examples, API reference improvements
|
|
59
|
+
|
|
60
|
+
## Pull request guidelines
|
|
61
|
+
|
|
62
|
+
- Keep PRs focused. One feature or fix per PR.
|
|
63
|
+
- Include tests for new functionality.
|
|
64
|
+
- Update documentation if you change public APIs.
|
|
65
|
+
- Ensure CI passes before requesting review.
|
|
66
|
+
|
|
67
|
+
## Reporting bugs
|
|
68
|
+
|
|
69
|
+
Open an issue with:
|
|
70
|
+
- Platform and Python version
|
|
71
|
+
- Minimal reproduction steps
|
|
72
|
+
- Expected vs. actual behavior
|
|
73
|
+
- Full traceback if applicable
|
|
74
|
+
|
|
75
|
+
## Code style
|
|
76
|
+
|
|
77
|
+
- Python 3.10+ with `from __future__ import annotations`
|
|
78
|
+
- Type hints on all public function signatures
|
|
79
|
+
- Docstrings on public classes and functions (Google style)
|
|
80
|
+
- No unnecessary dependencies — platform deps are conditional
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
By contributing, you agree that your contributions will be licensed under the [MIT License](LICENSE).
|
|
@@ -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,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: computeruseprotocol
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the Computer Use Protocol — universal cross-platform UI accessibility
|
|
5
|
+
Project-URL: Homepage, https://computeruseprotocol.com
|
|
6
|
+
Project-URL: Repository, https://github.com/computeruseprotocol/python-sdk
|
|
7
|
+
Project-URL: Specification, https://github.com/computeruseprotocol/computeruseprotocol
|
|
8
|
+
Project-URL: Documentation, https://computeruseprotocol.com
|
|
9
|
+
Author-email: CUP Contributors <cup@computeruseprotocol.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: accessibility,ai-agents,aria,computer-use,ui-automation
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
+
Classifier: Topic :: Software Development :: Testing
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: comtypes>=1.2; sys_platform == 'win32'
|
|
28
|
+
Requires-Dist: pyobjc-framework-applicationservices>=10.0; sys_platform == 'darwin'
|
|
29
|
+
Requires-Dist: pyobjc-framework-cocoa>=10.0; sys_platform == 'darwin'
|
|
30
|
+
Requires-Dist: pyobjc-framework-quartz>=10.0; sys_platform == 'darwin'
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: jsonschema>=4.20; extra == 'dev'
|
|
33
|
+
Requires-Dist: mypy>=1.13; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.8; extra == 'dev'
|
|
37
|
+
Provides-Extra: mcp
|
|
38
|
+
Requires-Dist: mcp>=1.6; extra == 'mcp'
|
|
39
|
+
Requires-Dist: mss>=6.0; extra == 'mcp'
|
|
40
|
+
Provides-Extra: screenshot
|
|
41
|
+
Requires-Dist: mss>=6.0; extra == 'screenshot'
|
|
42
|
+
Provides-Extra: web
|
|
43
|
+
Requires-Dist: websocket-client>=1.6; extra == 'web'
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
|
|
46
|
+
<p align="center">
|
|
47
|
+
<a href="https://computeruseprotocol.com">
|
|
48
|
+
<img src="assets/banner.png" alt="Computer Use Protocol">
|
|
49
|
+
</a>
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
<p align="center">
|
|
53
|
+
<b>Python SDK for the Computer Use Protocol</b>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
<br>
|
|
57
|
+
|
|
58
|
+
<p align="center">
|
|
59
|
+
<a href="https://pypi.org/project/computeruseprotocol"><img src="https://img.shields.io/pypi/v/computeruseprotocol?style=for-the-badge&color=FF6F61&labelColor=000000" alt="PyPI"></a>
|
|
60
|
+
<a href="https://github.com/computeruseprotocol/python-sdk/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-0cc0df?style=for-the-badge&labelColor=000000" alt="MIT License"></a>
|
|
61
|
+
<a href="https://github.com/computeruseprotocol/computeruseprotocol"><img src="https://img.shields.io/badge/Spec-computer--use--protocol-7ed957?style=for-the-badge&labelColor=000000" alt="Spec"></a>
|
|
62
|
+
</p>
|
|
63
|
+
|
|
64
|
+
The official Python SDK for the [Computer Use Protocol (CUP)](https://github.com/computeruseprotocol/computeruseprotocol) — a universal protocol for AI agents to perceive and interact with any desktop UI. This package provides tree capture, action execution, semantic search, and an MCP server for AI agent integration.
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install computeruseprotocol
|
|
70
|
+
|
|
71
|
+
# Linux additionally requires system packages
|
|
72
|
+
sudo apt install python3-gi gir1.2-atspi-2.0
|
|
73
|
+
|
|
74
|
+
# Web adapter (Chrome DevTools Protocol, works on any OS)
|
|
75
|
+
pip install computeruseprotocol[web]
|
|
76
|
+
|
|
77
|
+
# Screenshot support (mss; not needed on macOS)
|
|
78
|
+
pip install computeruseprotocol[screenshot]
|
|
79
|
+
|
|
80
|
+
# MCP server for AI agent integration
|
|
81
|
+
pip install computeruseprotocol[mcp]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Quick start
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
import cup
|
|
88
|
+
|
|
89
|
+
# Snapshot the foreground window — optimized for LLM context windows
|
|
90
|
+
screen = cup.snapshot()
|
|
91
|
+
print(screen)
|
|
92
|
+
|
|
93
|
+
# All windows
|
|
94
|
+
screen = cup.snapshot("full")
|
|
95
|
+
|
|
96
|
+
# Structured CUP envelope (dict) instead of compact text
|
|
97
|
+
envelope = cup.snapshot_raw()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Output:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
# CUP 0.1.0 | windows | 2560x1440
|
|
104
|
+
# app: Spotify
|
|
105
|
+
# 63 nodes (280 before pruning)
|
|
106
|
+
|
|
107
|
+
[e0] win "Spotify" 120,40 1680x1020
|
|
108
|
+
[e1] doc "Spotify" 120,40 1680x1020
|
|
109
|
+
[e2] btn "Back" 132,52 32x32 [clk]
|
|
110
|
+
[e3] btn "Forward" 170,52 32x32 {dis} [clk]
|
|
111
|
+
[e7] nav "Main" 120,88 240x972
|
|
112
|
+
[e8] lnk "Home" 132,100 216x40 {sel} [clk]
|
|
113
|
+
[e9] lnk "Search" 132,148 216x40 [clk]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## CLI
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Print the foreground window tree (default)
|
|
120
|
+
python -m cup
|
|
121
|
+
|
|
122
|
+
# Filter by app name
|
|
123
|
+
python -m cup --scope full --app Discord
|
|
124
|
+
|
|
125
|
+
# Save JSON envelope to file
|
|
126
|
+
python -m cup --json-out tree.json
|
|
127
|
+
|
|
128
|
+
# Capture from Chrome via CDP
|
|
129
|
+
python -m cup --platform web --cdp-port 9222
|
|
130
|
+
|
|
131
|
+
# Include diagnostics (timing, role distribution, sizes)
|
|
132
|
+
python -m cup --verbose
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Platform support
|
|
136
|
+
|
|
137
|
+
| Platform | Adapter | Tree Capture | Actions |
|
|
138
|
+
|----------|---------|-------------|---------|
|
|
139
|
+
| Windows | UIA COM (comtypes) | Stable | Stable |
|
|
140
|
+
| macOS | AXUIElement (pyobjc) | Stable | Stable |
|
|
141
|
+
| Linux | AT-SPI2 (PyGObject) | Stable | Stable |
|
|
142
|
+
| Web | Chrome DevTools Protocol | Stable | Stable |
|
|
143
|
+
| Android | | Planned | Planned |
|
|
144
|
+
| iOS | | Planned | Planned |
|
|
145
|
+
|
|
146
|
+
CUP auto-detects your platform. Platform-specific dependencies (comtypes on Windows, pyobjc on macOS) are installed automatically.
|
|
147
|
+
|
|
148
|
+
## Architecture
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
cup/
|
|
152
|
+
├── __init__.py # Public API: snapshot, action, find, ...
|
|
153
|
+
├── __main__.py # CLI entry point
|
|
154
|
+
├── _base.py # Abstract PlatformAdapter interface
|
|
155
|
+
├── _router.py # Platform detection & adapter dispatch
|
|
156
|
+
├── format.py # Envelope builder, compact serializer, tree pruning
|
|
157
|
+
├── search.py # Semantic element search with fuzzy matching
|
|
158
|
+
├── actions/ # Action execution layer
|
|
159
|
+
│ ├── executor.py # ActionExecutor orchestrator
|
|
160
|
+
│ ├── _handler.py # Abstract ActionHandler interface
|
|
161
|
+
│ ├── _keys.py # Key name mapping utilities
|
|
162
|
+
│ ├── _windows.py # Windows UIA actions
|
|
163
|
+
│ ├── _web.py # Chrome CDP actions
|
|
164
|
+
│ ├── _macos.py # macOS actions (Quartz CGEvents + AX)
|
|
165
|
+
│ └── _linux.py # Linux actions (XTest + AT-SPI2)
|
|
166
|
+
├── platforms/ # Platform-specific tree capture
|
|
167
|
+
│ ├── windows.py # Windows UIA adapter
|
|
168
|
+
│ ├── macos.py # macOS AXUIElement adapter
|
|
169
|
+
│ ├── linux.py # Linux AT-SPI2 adapter
|
|
170
|
+
│ └── web.py # Chrome CDP adapter
|
|
171
|
+
└── mcp/ # MCP server integration
|
|
172
|
+
├── __main__.py # python -m cup.mcp entry point
|
|
173
|
+
└── server.py # MCP protocol server
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Adding a new platform means implementing `PlatformAdapter` — see [cup/_base.py](cup/_base.py) for the interface.
|
|
177
|
+
|
|
178
|
+
## MCP Server
|
|
179
|
+
|
|
180
|
+
CUP ships an MCP server for integration with AI agents (Claude, Copilot, etc.).
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Run directly
|
|
184
|
+
cup-mcp
|
|
185
|
+
|
|
186
|
+
# Or via Python
|
|
187
|
+
python -m cup.mcp
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Add to your MCP client config (e.g., `.mcp.json` for Claude Code):
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"mcpServers": {
|
|
195
|
+
"cup": {
|
|
196
|
+
"command": "cup-mcp",
|
|
197
|
+
"args": []
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Tools:** `snapshot`, `snapshot_app`, `overview`, `snapshot_desktop`, `find`, `action`, `open_app`, `screenshot`
|
|
204
|
+
|
|
205
|
+
## Contributing
|
|
206
|
+
|
|
207
|
+
CUP is in early development (v0.1.0). Contributions welcome — especially:
|
|
208
|
+
|
|
209
|
+
- Android adapter (`cup/platforms/android.py`)
|
|
210
|
+
- iOS adapter (`cup/platforms/ios.py`)
|
|
211
|
+
- Tests — especially cross-platform integration tests
|
|
212
|
+
- Documentation and examples
|
|
213
|
+
|
|
214
|
+
For protocol or schema changes, please contribute to [computeruseprotocol](https://github.com/computeruseprotocol/computeruseprotocol).
|
|
215
|
+
|
|
216
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions and guidelines.
|
|
217
|
+
|
|
218
|
+
## Documentation
|
|
219
|
+
|
|
220
|
+
- **[API Reference](docs/api-reference.md)** — Session API, actions, envelope format, MCP server
|
|
221
|
+
- **[Protocol Specification](https://github.com/computeruseprotocol/computeruseprotocol)** — Schema, roles, states, actions, compact format
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
[MIT](LICENSE)
|