computer-agents 2.2.0__tar.gz → 2.3.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.
Files changed (41) hide show
  1. computer_agents-2.3.0/.github/ISSUE_TEMPLATE/bug_report.md +30 -0
  2. computer_agents-2.3.0/.github/ISSUE_TEMPLATE/feature_request.md +16 -0
  3. computer_agents-2.3.0/.github/ISSUE_TEMPLATE/question.md +16 -0
  4. computer_agents-2.3.0/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +19 -0
  5. computer_agents-2.3.0/.github/workflows/issues.yml +28 -0
  6. computer_agents-2.3.0/.github/workflows/release.yml +31 -0
  7. computer_agents-2.3.0/.github/workflows/test.yml +37 -0
  8. computer_agents-2.3.0/.gitignore +39 -0
  9. computer_agents-2.3.0/CHANGELOG.md +19 -0
  10. computer_agents-2.3.0/CONTRIBUTING.md +127 -0
  11. computer_agents-2.3.0/LICENSE +21 -0
  12. {computer_agents-2.2.0 → computer_agents-2.3.0}/PKG-INFO +19 -3
  13. {computer_agents-2.2.0 → computer_agents-2.3.0}/README.md +9 -1
  14. computer_agents-2.3.0/SECURITY.md +53 -0
  15. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/client.py +48 -22
  16. {computer_agents-2.2.0 → computer_agents-2.3.0}/examples/01_quickstart.py +3 -10
  17. {computer_agents-2.2.0 → computer_agents-2.3.0}/pyproject.toml +28 -2
  18. computer_agents-2.2.0/.gitignore +0 -181
  19. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/__init__.py +0 -0
  20. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/_api_client.py +0 -0
  21. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/_exceptions.py +0 -0
  22. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/py.typed +0 -0
  23. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/__init__.py +0 -0
  24. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/agents.py +0 -0
  25. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/budget.py +0 -0
  26. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/environments.py +0 -0
  27. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/files.py +0 -0
  28. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/git.py +0 -0
  29. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/orchestrations.py +0 -0
  30. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/projects.py +0 -0
  31. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/runs.py +0 -0
  32. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/schedules.py +0 -0
  33. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/threads.py +0 -0
  34. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/resources/triggers.py +0 -0
  35. {computer_agents-2.2.0 → computer_agents-2.3.0}/computer_agents/types.py +0 -0
  36. {computer_agents-2.2.0 → computer_agents-2.3.0}/examples/02_threads.py +0 -0
  37. {computer_agents-2.2.0 → computer_agents-2.3.0}/examples/03_environments.py +0 -0
  38. {computer_agents-2.2.0 → computer_agents-2.3.0}/examples/04_agents.py +0 -0
  39. {computer_agents-2.2.0 → computer_agents-2.3.0}/examples/05_files.py +0 -0
  40. {computer_agents-2.2.0 → computer_agents-2.3.0}/examples/06_schedules.py +0 -0
  41. {computer_agents-2.2.0 → computer_agents-2.3.0}/examples/07_git.py +0 -0
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: Bug report
3
+ about: Report a bug
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+ ---
8
+
9
+ ### Please read this first
10
+
11
+ - **Have you read the docs?** [Computer Agents docs](https://computer-agents.com/documentation)
12
+ - **Have you searched for related issues?** Others may have faced similar issues.
13
+
14
+ ### Describe the bug
15
+
16
+ A clear and concise description of what the bug is.
17
+
18
+ ### Debug information
19
+
20
+ - SDK version: (e.g. `2.2.0`)
21
+ - Python version: (e.g. `3.12.0`)
22
+ - OS: (e.g. macOS 15, Ubuntu 24.04)
23
+
24
+ ### Repro steps
25
+
26
+ Ideally provide a minimal Python script that can be run to reproduce the bug.
27
+
28
+ ### Expected behavior
29
+
30
+ A clear and concise description of what you expected to happen.
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+ ---
8
+
9
+ ### Please read this first
10
+
11
+ - **Have you read the docs?** [Computer Agents docs](https://computer-agents.com/documentation)
12
+ - **Have you searched for related issues?** Others may have had similar requests
13
+
14
+ ### Describe the feature
15
+
16
+ What is the feature you're requesting? How would it work? Please provide examples and details if possible.
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: Question
3
+ about: Questions about the SDK
4
+ title: ''
5
+ labels: question
6
+ assignees: ''
7
+ ---
8
+
9
+ ### Please read this first
10
+
11
+ - **Have you read the docs?** [Computer Agents docs](https://computer-agents.com/documentation)
12
+ - **Have you searched for related issues?** Others may have had similar requests
13
+
14
+ ### Question
15
+
16
+ Describe your question. Provide details if available.
@@ -0,0 +1,19 @@
1
+ ### Summary
2
+
3
+ <!-- Please give a short summary of the change and the problem this solves. -->
4
+
5
+ ### Test plan
6
+
7
+ <!-- Please explain how this was tested -->
8
+
9
+ ### Issue number
10
+
11
+ <!-- For example: "Closes #1234" -->
12
+
13
+ ### Checks
14
+
15
+ - [ ] I've added new tests (if relevant)
16
+ - [ ] I've added/updated the relevant documentation
17
+ - [ ] I've run `pytest` and all tests pass
18
+ - [ ] I've run type checking with `mypy computer_agents`
19
+ - [ ] I've ensured Python 3.9+ compatibility
@@ -0,0 +1,28 @@
1
+ name: Close inactive issues
2
+ on:
3
+ schedule:
4
+ - cron: "30 1 * * *"
5
+
6
+ jobs:
7
+ close-issues:
8
+ runs-on: ubuntu-latest
9
+ permissions:
10
+ issues: write
11
+ pull-requests: write
12
+ steps:
13
+ - uses: actions/stale@v9
14
+ with:
15
+ days-before-issue-stale: 7
16
+ days-before-issue-close: 3
17
+ stale-issue-label: "stale"
18
+ exempt-issue-labels: "skip-stale"
19
+ stale-issue-message: "This issue is stale because it has been open for 7 days with no activity."
20
+ close-issue-message: "This issue was closed because it has been inactive for 3 days since being marked as stale."
21
+ any-of-issue-labels: 'question,needs-more-info'
22
+ days-before-pr-stale: 10
23
+ days-before-pr-close: 7
24
+ stale-pr-label: "stale"
25
+ exempt-pr-labels: "skip-stale"
26
+ stale-pr-message: "This PR is stale because it has been open for 10 days with no activity."
27
+ close-pr-message: "This PR was closed because it has been inactive for 7 days since being marked as stale."
28
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,31 @@
1
+ name: Release to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ release:
12
+ runs-on: ubuntu-latest
13
+ environment: release
14
+ permissions:
15
+ id-token: write
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.12"
23
+
24
+ - name: Install build tools
25
+ run: python -m pip install --upgrade pip build
26
+
27
+ - name: Build package
28
+ run: python -m build
29
+
30
+ - name: Publish to PyPI
31
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,37 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -e ".[dev]"
28
+
29
+ - name: Lint
30
+ run: ruff check .
31
+
32
+ - name: Type check
33
+ run: mypy computer_agents
34
+ if: matrix.python-version != '3.9'
35
+
36
+ - name: Test
37
+ run: pytest
@@ -0,0 +1,39 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ build/
8
+ dist/
9
+ *.egg-info/
10
+ *.egg
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ ENV/
16
+
17
+ # IDE
18
+ .idea/
19
+ .vscode/
20
+ *.swp
21
+ *.swo
22
+
23
+ # OS
24
+ .DS_Store
25
+ Thumbs.db
26
+
27
+ # Environment variables
28
+ .env
29
+ .env.local
30
+
31
+ # Testing
32
+ .pytest_cache/
33
+ .coverage
34
+ htmlcov/
35
+ .mypy_cache/
36
+ .ruff_cache/
37
+
38
+ # Jupyter
39
+ .ipynb_checkpoints/
@@ -0,0 +1,19 @@
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/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.2.0] - 2025-02-14
9
+
10
+ ### Added
11
+
12
+ - Initial release of the Computer Agents Python SDK
13
+ - Full API parity with the [TypeScript SDK](https://github.com/TestBase-ai/computer-agents) v2.2.0
14
+ - Resources: threads, environments, agents, files, schedules, triggers, orchestrations, budget, billing, git, runs, projects
15
+ - SSE streaming support for real-time agent responses
16
+ - Context manager support for automatic cleanup
17
+ - Comprehensive type definitions using TypedDict
18
+ - 7 usage examples covering all major features
19
+ - PEP 561 typed package marker
@@ -0,0 +1,127 @@
1
+ # Contributing to Computer Agents Python SDK
2
+
3
+ Thank you for your interest in contributing! This document provides guidelines for contributing to the Computer Agents Python SDK.
4
+
5
+ ## Getting Started
6
+
7
+ ### Prerequisites
8
+
9
+ - Python 3.9 or higher
10
+ - pip or uv for package management
11
+
12
+ ### Setup
13
+
14
+ 1. Fork and clone the repository:
15
+ ```bash
16
+ git clone https://github.com/computer-agents/computer-agents-python.git
17
+ cd computer-agents-python
18
+ ```
19
+
20
+ 2. Create a virtual environment:
21
+ ```bash
22
+ python -m venv .venv
23
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
24
+ ```
25
+
26
+ 3. Install in development mode:
27
+ ```bash
28
+ pip install -e ".[dev]"
29
+ ```
30
+
31
+ ## Development
32
+
33
+ ### Project Structure
34
+
35
+ ```
36
+ computer-agents-python/
37
+ ├── computer_agents/
38
+ │ ├── __init__.py # Public API exports
39
+ │ ├── client.py # ComputerAgentsClient
40
+ │ ├── _api_client.py # Low-level HTTP client
41
+ │ ├── _exceptions.py # Exception classes
42
+ │ ├── types.py # TypedDict type definitions
43
+ │ ├── py.typed # PEP 561 marker
44
+ │ └── resources/ # API resource managers
45
+ │ ├── threads.py
46
+ │ ├── environments.py
47
+ │ ├── agents.py
48
+ │ ├── files.py
49
+ │ ├── schedules.py
50
+ │ ├── triggers.py
51
+ │ ├── orchestrations.py
52
+ │ ├── budget.py
53
+ │ ├── git.py
54
+ │ ├── runs.py
55
+ │ └── projects.py
56
+ ├── examples/ # Usage examples
57
+ ├── tests/ # Test suite
58
+ ├── pyproject.toml # Package configuration
59
+ └── README.md
60
+ ```
61
+
62
+ ### Running Tests
63
+
64
+ ```bash
65
+ pytest
66
+ ```
67
+
68
+ ### Type Checking
69
+
70
+ ```bash
71
+ mypy computer_agents
72
+ ```
73
+
74
+ ### Code Style
75
+
76
+ We follow standard Python conventions:
77
+ - PEP 8 for code style
78
+ - PEP 257 for docstrings
79
+ - Type hints throughout (PEP 484)
80
+ - snake_case for functions and variables
81
+ - PascalCase for classes
82
+
83
+ Use ruff for linting and formatting:
84
+ ```bash
85
+ ruff check .
86
+ ruff format .
87
+ ```
88
+
89
+ ## Making Changes
90
+
91
+ ### Pull Request Process
92
+
93
+ 1. Create a feature branch from `main`:
94
+ ```bash
95
+ git checkout -b feature/your-feature
96
+ ```
97
+
98
+ 2. Make your changes with clear, descriptive commits
99
+
100
+ 3. Ensure all tests pass and types check
101
+
102
+ 4. Push and open a pull request against `main`
103
+
104
+ ### Commit Messages
105
+
106
+ Use clear, descriptive commit messages:
107
+ - `fix: resolve SSE streaming timeout issue`
108
+ - `feat: add async client support`
109
+ - `docs: update environment examples`
110
+
111
+ ### What Makes a Good PR
112
+
113
+ - **Focused**: One feature or fix per PR
114
+ - **Tested**: Include tests for new functionality
115
+ - **Documented**: Update README or docstrings if needed
116
+ - **Typed**: All new code should have type annotations
117
+ - **Compatible**: Maintain Python 3.9+ compatibility
118
+
119
+ ## Reporting Issues
120
+
121
+ - **Bugs**: Use the bug report template
122
+ - **Features**: Use the feature request template
123
+ - **Security**: See [SECURITY.md](SECURITY.md)
124
+
125
+ ## License
126
+
127
+ By contributing, you agree that your contributions will be licensed under the MIT License.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Testbase
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.
@@ -1,12 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: computer-agents
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Official Python SDK for the Computer Agents Cloud API. Execute Claude-powered AI agents in isolated cloud containers.
5
5
  Project-URL: Homepage, https://computer-agents.com
6
6
  Project-URL: Documentation, https://computer-agents.com/documentation
7
- Project-URL: Repository, https://github.com/computer-agents/computer-agents-python
7
+ Project-URL: Repository, https://github.com/computer-agents/computer-agents-sdk-python
8
+ Project-URL: Issues, https://github.com/computer-agents/computer-agents-sdk-python/issues
9
+ Project-URL: Changelog, https://github.com/computer-agents/computer-agents-sdk-python/blob/main/CHANGELOG.md
8
10
  Author: Computer Agents
9
11
  License-Expression: MIT
12
+ License-File: LICENSE
10
13
  Keywords: agents,ai,anthropic,api,automation,claude,cloud,code-generation,computer-agents,mcp,sdk
11
14
  Classifier: Development Status :: 4 - Beta
12
15
  Classifier: Intended Audience :: Developers
@@ -21,10 +24,19 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
24
  Classifier: Typing :: Typed
22
25
  Requires-Python: >=3.9
23
26
  Requires-Dist: httpx>=0.25.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: mypy>=1.0; extra == 'dev'
29
+ Requires-Dist: pytest>=7.0; extra == 'dev'
30
+ Requires-Dist: respx>=0.21.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
24
32
  Description-Content-Type: text/markdown
25
33
 
26
34
  # Computer Agents Python SDK
27
35
 
36
+ [![PyPI version](https://img.shields.io/pypi/v/computer-agents.svg)](https://pypi.org/project/computer-agents/)
37
+ [![Python versions](https://img.shields.io/pypi/pyversions/computer-agents.svg)](https://pypi.org/project/computer-agents/)
38
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
39
+
28
40
  The official Python SDK for the [Computer Agents](https://computer-agents.com) Cloud API. Execute Claude-powered AI agents in isolated cloud containers.
29
41
 
30
42
  ## Installation
@@ -199,6 +211,10 @@ with ComputerAgentsClient(api_key="ca_...") as client:
199
211
  - Python >= 3.9
200
212
  - httpx >= 0.25.0
201
213
 
214
+ ## Contributing
215
+
216
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
217
+
202
218
  ## License
203
219
 
204
- MIT
220
+ MIT - see [LICENSE](LICENSE) for details.
@@ -1,5 +1,9 @@
1
1
  # Computer Agents Python SDK
2
2
 
3
+ [![PyPI version](https://img.shields.io/pypi/v/computer-agents.svg)](https://pypi.org/project/computer-agents/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/computer-agents.svg)](https://pypi.org/project/computer-agents/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
3
7
  The official Python SDK for the [Computer Agents](https://computer-agents.com) Cloud API. Execute Claude-powered AI agents in isolated cloud containers.
4
8
 
5
9
  ## Installation
@@ -174,6 +178,10 @@ with ComputerAgentsClient(api_key="ca_...") as client:
174
178
  - Python >= 3.9
175
179
  - httpx >= 0.25.0
176
180
 
181
+ ## Contributing
182
+
183
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
184
+
177
185
  ## License
178
186
 
179
- MIT
187
+ MIT - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,53 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ We release patches for security vulnerabilities for the following versions:
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | 2.x | :white_check_mark: |
10
+ | < 2.0.0 | :x: |
11
+
12
+ ## Reporting a Vulnerability
13
+
14
+ If you discover a security vulnerability, please create a private security advisory on GitHub or email security@testbase.ai instead of using the public issue tracker.
15
+
16
+ Please include:
17
+ - Description of the vulnerability
18
+ - Steps to reproduce
19
+ - Potential impact
20
+ - Suggested fix (if any)
21
+
22
+ We will respond within 48 hours and aim to release a patch within 7 days for critical vulnerabilities.
23
+
24
+ ## Security Best Practices
25
+
26
+ When using computer-agents:
27
+
28
+ 1. **API Keys**: Never commit API keys to version control
29
+ - Use environment variables (`COMPUTER_AGENTS_API_KEY`)
30
+ - Use `.env` files (already in `.gitignore`)
31
+
32
+ 2. **Cloud Execution**: Agents execute code in isolated containers
33
+ - Protect your API keys
34
+ - Set spending limits via the budget API
35
+ - Review usage regularly
36
+
37
+ 3. **Dependencies**: Keep dependencies updated
38
+ ```bash
39
+ pip install --upgrade computer-agents
40
+ pip audit
41
+ ```
42
+
43
+ ## Disclosure Policy
44
+
45
+ When we receive a security bug report, we will:
46
+
47
+ 1. Confirm the problem and determine affected versions
48
+ 2. Audit code to find similar problems
49
+ 3. Prepare fixes for all supported versions
50
+ 4. Release new versions as soon as possible
51
+ 5. Credit the reporter (unless they prefer to remain anonymous)
52
+
53
+ Thank you for helping keep computer-agents and our users safe!
@@ -7,23 +7,20 @@ Example::
7
7
 
8
8
  from computer_agents import ComputerAgentsClient
9
9
 
10
- client = ComputerAgentsClient(api_key="ca_...")
10
+ client = ComputerAgentsClient()
11
11
 
12
- # Execute a task (simplest usage)
12
+ # Execute a task that's it. No setup needed.
13
+ result = client.run("Create a REST API with Flask")
14
+ print(result.content)
15
+
16
+ # With streaming events
13
17
  result = client.run(
14
- "Create a REST API with Flask",
15
- environment_id="env_xxx",
18
+ "Build a web scraper",
16
19
  on_event=lambda e: print(e["type"]),
17
20
  )
18
- print(result.content)
19
21
 
20
- # Or use the thread API for multi-turn conversations
21
- thread = client.threads.create(environment_id="env_xxx")
22
- result = client.threads.send_message(
23
- thread["id"],
24
- content="Create a REST API",
25
- on_event=lambda e: print(e),
26
- )
22
+ # Continue the conversation
23
+ follow_up = client.run("Add error handling", thread_id=result.thread_id)
27
24
  """
28
25
 
29
26
  from __future__ import annotations
@@ -136,6 +133,9 @@ class ComputerAgentsClient:
136
133
  self.runs = RunsResource(self.api)
137
134
  self.projects = ProjectsResource(self.api)
138
135
 
136
+ # Cached default environment (populated on first run without environment_id)
137
+ self._default_environment_id: str | None = None
138
+
139
139
  def close(self) -> None:
140
140
  """Close the underlying HTTP client."""
141
141
  self.api.close()
@@ -153,7 +153,7 @@ class ComputerAgentsClient:
153
153
  def run(
154
154
  self,
155
155
  task: str,
156
- environment_id: str,
156
+ environment_id: str | None = None,
157
157
  *,
158
158
  thread_id: str | None = None,
159
159
  agent_config: dict[str, Any] | None = None,
@@ -163,13 +163,15 @@ class ComputerAgentsClient:
163
163
  """Execute a task with automatic thread management.
164
164
 
165
165
  This is the simplest way to run an agent task. It handles:
166
+ - Auto-creating a default environment (if ``environment_id`` not provided)
166
167
  - Creating a thread (if ``thread_id`` not provided)
167
168
  - Sending the message with SSE streaming
168
169
  - Returning the result with thread ID for follow-ups
169
170
 
170
171
  Args:
171
172
  task: The task to execute (e.g. ``"Create a REST API with Flask"``).
172
- environment_id: Environment ID to execute in.
173
+ environment_id: Environment ID to execute in. If not provided,
174
+ a default environment is created automatically.
173
175
  thread_id: Thread ID to continue (optional).
174
176
  agent_config: Agent configuration override (model, instructions, etc.).
175
177
  on_event: Callback for streaming events.
@@ -180,24 +182,29 @@ class ComputerAgentsClient:
180
182
 
181
183
  Example::
182
184
 
183
- # Simple one-shot execution
184
- result = client.run("Create hello.py", environment_id="env_xxx")
185
+ # Simplest usage — no setup needed
186
+ result = client.run("Create hello.py")
185
187
  print(result.content)
186
188
 
187
189
  # With streaming progress
188
190
  result = client.run(
189
191
  "Build a REST API",
190
- environment_id="env_xxx",
191
192
  on_event=lambda e: print(e.get("type")),
192
193
  )
193
194
 
194
195
  # Continue the conversation
195
196
  follow_up = client.run(
196
197
  "Add authentication",
197
- environment_id="env_xxx",
198
198
  thread_id=result.thread_id,
199
199
  )
200
+
201
+ # Explicit environment
202
+ result = client.run("Deploy to prod", environment_id="env_xxx")
200
203
  """
204
+ # Auto-resolve environment if not provided
205
+ if environment_id is None:
206
+ environment_id = self._ensure_default_environment()
207
+
201
208
  # Create or reuse thread
202
209
  if thread_id is None:
203
210
  thread = self.threads.create(environment_id=environment_id)
@@ -218,6 +225,24 @@ class ComputerAgentsClient:
218
225
  run=result.run,
219
226
  )
220
227
 
228
+ def _ensure_default_environment(self) -> str:
229
+ """Return the cached default environment ID, creating one if needed."""
230
+ if self._default_environment_id is not None:
231
+ return self._default_environment_id
232
+
233
+ environments = self.environments.list()
234
+ default_env = next((e for e in environments if e.get("isDefault")), None)
235
+
236
+ if default_env is None:
237
+ default_env = self.environments.create(
238
+ name="default",
239
+ internet_access=True,
240
+ is_default=True,
241
+ )
242
+
243
+ self._default_environment_id = default_env["id"]
244
+ return self._default_environment_id
245
+
221
246
  def quick_setup(
222
247
  self,
223
248
  *,
@@ -229,16 +254,17 @@ class ComputerAgentsClient:
229
254
  Creates a default environment if none exists, returning both
230
255
  the project and environment ready for execution.
231
256
 
257
+ .. note::
258
+ You usually don't need to call this directly. ``run()`` auto-creates
259
+ a default environment when ``environment_id`` is omitted.
260
+
232
261
  Returns:
233
262
  Dict with ``project`` and ``environment`` keys.
234
263
 
235
264
  Example::
236
265
 
237
266
  setup = client.quick_setup(internet_access=True)
238
- result = client.run(
239
- "Hello world!",
240
- environment_id=setup["environment"]["id"],
241
- )
267
+ env_id = setup["environment"]["id"]
242
268
  """
243
269
  project = self.projects.get()
244
270
 
@@ -2,18 +2,12 @@
2
2
 
3
3
  from computer_agents import ComputerAgentsClient
4
4
 
5
- # Initialize the client
6
- client = ComputerAgentsClient(api_key="ca_your_api_key")
5
+ # Initialize the client (reads COMPUTER_AGENTS_API_KEY from env)
6
+ client = ComputerAgentsClient()
7
7
 
8
- # Quick setup - creates a default environment if none exists
9
- setup = client.quick_setup(internet_access=True)
10
- env_id = setup["environment"]["id"]
11
- print(f"Using environment: {env_id}")
12
-
13
- # Execute a task with streaming
8
+ # Execute a task no setup needed, environment is created automatically
14
9
  result = client.run(
15
10
  "Create a Python file that prints 'Hello, World!'",
16
- environment_id=env_id,
17
11
  on_event=lambda e: print(f" [{e.get('type')}]"),
18
12
  )
19
13
 
@@ -23,7 +17,6 @@ print(f"Thread ID: {result.thread_id}")
23
17
  # Continue the conversation
24
18
  follow_up = client.run(
25
19
  "Now modify it to accept a name argument",
26
- environment_id=env_id,
27
20
  thread_id=result.thread_id,
28
21
  on_event=lambda e: print(f" [{e.get('type')}]"),
29
22
  )
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "computer-agents"
7
- version = "2.2.0"
7
+ version = "2.3.0"
8
8
  description = "Official Python SDK for the Computer Agents Cloud API. Execute Claude-powered AI agents in isolated cloud containers."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -42,10 +42,36 @@ dependencies = [
42
42
  "httpx>=0.25.0",
43
43
  ]
44
44
 
45
+ [project.optional-dependencies]
46
+ dev = [
47
+ "pytest>=7.0",
48
+ "mypy>=1.0",
49
+ "ruff>=0.4.0",
50
+ "respx>=0.21.0",
51
+ ]
52
+
45
53
  [project.urls]
46
54
  Homepage = "https://computer-agents.com"
47
55
  Documentation = "https://computer-agents.com/documentation"
48
- Repository = "https://github.com/computer-agents/computer-agents-python"
56
+ Repository = "https://github.com/computer-agents/computer-agents-sdk-python"
57
+ Issues = "https://github.com/computer-agents/computer-agents-sdk-python/issues"
58
+ Changelog = "https://github.com/computer-agents/computer-agents-sdk-python/blob/main/CHANGELOG.md"
49
59
 
50
60
  [tool.hatch.build.targets.wheel]
51
61
  packages = ["computer_agents"]
62
+
63
+ [tool.ruff]
64
+ target-version = "py39"
65
+ line-length = 100
66
+
67
+ [tool.ruff.lint]
68
+ select = ["E", "F", "I", "UP"]
69
+
70
+ [tool.mypy]
71
+ python_version = "3.9"
72
+ strict = false
73
+ warn_return_any = true
74
+ warn_unused_configs = true
75
+
76
+ [tool.pytest.ini_options]
77
+ testpaths = ["tests"]
@@ -1,181 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
- lerna-debug.log*
8
- .pnpm-debug.log*
9
-
10
- # Diagnostic reports (https://nodejs.org/api/report.html)
11
- report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12
-
13
- # Runtime data
14
- pids
15
- *.pid
16
- *.seed
17
- *.pid.lock
18
-
19
- # Directory for instrumented libs generated by jscoverage/JSCover
20
- lib-cov
21
-
22
- # Coverage directory used by tools like istanbul
23
- coverage
24
- *.lcov
25
-
26
- # nyc test coverage
27
- .nyc_output
28
-
29
- # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30
- .grunt
31
-
32
- # Bower dependency directory (https://bower.io/)
33
- bower_components
34
-
35
- # node-waf configuration
36
- .lock-wscript
37
-
38
- # Compiled binary addons (https://nodejs.org/api/addons.html)
39
- build/Release
40
-
41
- # Dependency directories
42
- node_modules/
43
- jspm_packages/
44
-
45
- # Snowpack dependency directory (https://snowpack.dev/)
46
- web_modules/
47
-
48
- # TypeScript cache
49
- *.tsbuildinfo
50
-
51
- # Optional npm cache directory
52
- .npm
53
-
54
- # Optional eslint cache
55
- .eslintcache
56
-
57
- # Optional stylelint cache
58
- .stylelintcache
59
-
60
- # Microbundle cache
61
- .rpt2_cache/
62
- .rts2_cache_cjs/
63
- .rts2_cache_es/
64
- .rts2_cache_umd/
65
-
66
- # Optional REPL history
67
- .node_repl_history
68
-
69
- # Output of 'npm pack'
70
- *.tgz
71
-
72
- # Yarn Integrity file
73
- .yarn-integrity
74
-
75
- # dotenv environment variable files
76
- .env
77
- .env.development.local
78
- .env.test.local
79
- .env.production.local
80
- .env.local
81
-
82
- # parcel-bundler cache (https://parceljs.org/)
83
- .cache
84
- .parcel-cache
85
-
86
- # Next.js build output
87
- .next
88
- out
89
-
90
- # Nuxt.js build / generate output
91
- .nuxt
92
- dist
93
-
94
- # Gatsby files
95
- .cache/
96
- # Comment in the public line in if your project uses Gatsby and not Next.js
97
- # https://nextjs.org/blog/next-9-1#public-directory-support
98
- # public
99
-
100
- # vuepress build output
101
- .vuepress/dist
102
-
103
- # vuepress v2.x temp and cache directory
104
- .temp
105
- .cache
106
-
107
- # vitepress build output
108
- **/.vitepress/dist
109
-
110
- # vitepress cache directory
111
- **/.vitepress/cache
112
-
113
- # Docusaurus cache and generated files
114
- .docusaurus
115
-
116
- # Serverless directories
117
- .serverless/
118
-
119
- # FuseBox cache
120
- .fusebox/
121
-
122
- # DynamoDB Local files
123
- .dynamodb/
124
-
125
- # TernJS port file
126
- .tern-port
127
-
128
- # Stores VSCode versions used for testing VSCode extensions
129
- .vscode-test
130
-
131
- # yarn v2
132
- .yarn/cache
133
- .yarn/unplugged
134
- .yarn/build-state.yml
135
- .yarn/install-state.gz
136
- .pnp.*
137
-
138
- packages/*/dist
139
-
140
- docs/src/content/docs/@openai/*
141
- docs/src/content/docs/openai/*
142
-
143
- # Python reference implementation (never published with the JS repo)
144
- openai-agents-python
145
-
146
- .DS_Store
147
-
148
- bundled/
149
-
150
- .wrangler/
151
- .dev.vars
152
-
153
- # Test artifacts
154
- **/tests/tmp/
155
- *.db
156
- *.sqlite
157
- *.sqlite3
158
-
159
- # Build artifacts that shouldn't be committed
160
- FIX_SUMMARY.md
161
- test-package-exports.mjs
162
- test-codex-loading.mjs
163
-
164
- # Internal documentation (not for public repo)
165
- API_DOCUMENTATION.md
166
- API_KEY_SYSTEM_COMPLETE.md
167
- API_KEY_TESTING_RESULTS.md
168
- API_KEY_MANAGEMENT.md
169
- BILLING.md
170
- *INTERNAL*.md
171
- AUTHENTICATION-UPDATE.md
172
- PHASE-2-COMPLETE.md
173
- PRE_PUBLISH_CHECKLIST.md
174
- REFACTORING_SUMMARY.md
175
- RENAME_COMPLETE.md
176
- REPUBLISH_GUIDE.md
177
- SESSION-SUMMARY.md
178
- TESTING-SUMMARY.md
179
- packages/cloud-infrastructure/API_KEY_MANAGEMENT.md
180
- packages/cloud-infrastructure/BILLING.md
181
- packages/cloud-infrastructure/BILLING_SYSTEM_COMPLETE.md