grasp-sdk 0.1.0__py3-none-any.whl
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.
Potentially problematic release.
This version of grasp-sdk might be problematic. Click here for more details.
- grasp_sdk/__init__.py +262 -0
- grasp_sdk/models/__init__.py +78 -0
- grasp_sdk/sandbox/chrome-stable.mjs +381 -0
- grasp_sdk/sandbox/chromium.mjs +378 -0
- grasp_sdk/sandbox/jsconfig.json +22 -0
- grasp_sdk/services/__init__.py +8 -0
- grasp_sdk/services/browser.py +414 -0
- grasp_sdk/services/sandbox.py +583 -0
- grasp_sdk/utils/__init__.py +31 -0
- grasp_sdk/utils/auth.py +227 -0
- grasp_sdk/utils/config.py +150 -0
- grasp_sdk/utils/logger.py +233 -0
- grasp_sdk-0.1.0.dist-info/METADATA +201 -0
- grasp_sdk-0.1.0.dist-info/RECORD +17 -0
- grasp_sdk-0.1.0.dist-info/WHEEL +5 -0
- grasp_sdk-0.1.0.dist-info/entry_points.txt +2 -0
- grasp_sdk-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: grasp_sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for Grasp E2B - Browser automation and sandbox management
|
|
5
|
+
Home-page: https://github.com/grasp-team/grasp-e2b
|
|
6
|
+
Author: Grasp Team
|
|
7
|
+
Author-email: Grasp Team <team@grasp.com>
|
|
8
|
+
Project-URL: Homepage, https://github.com/grasp-team/grasp-e2b
|
|
9
|
+
Project-URL: Bug Reports, https://github.com/grasp-team/grasp-e2b/issues
|
|
10
|
+
Project-URL: Source, https://github.com/grasp-team/grasp-e2b
|
|
11
|
+
Project-URL: Documentation, https://docs.grasp.com
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
24
|
+
Classifier: Topic :: System :: Emulators
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
28
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
29
|
+
Requires-Dist: typing-extensions>=4.8.0
|
|
30
|
+
Requires-Dist: e2b>=1.5.0
|
|
31
|
+
Requires-Dist: e2b-code-interpreter>=1.5.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
35
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
38
|
+
Provides-Extra: browser
|
|
39
|
+
Requires-Dist: playwright>=1.40.0; extra == "browser"
|
|
40
|
+
Provides-Extra: websocket
|
|
41
|
+
Requires-Dist: websockets>=12.0; extra == "websocket"
|
|
42
|
+
Provides-Extra: validation
|
|
43
|
+
Requires-Dist: pydantic>=2.5.0; extra == "validation"
|
|
44
|
+
Dynamic: author
|
|
45
|
+
Dynamic: home-page
|
|
46
|
+
Dynamic: requires-python
|
|
47
|
+
|
|
48
|
+
# Grasp SDK - Python Implementation
|
|
49
|
+
|
|
50
|
+
๐ Python implementation of Grasp SDK for E2B platform providing secure command execution and browser automation in isolated cloud environments.
|
|
51
|
+
|
|
52
|
+
## ๐ Features
|
|
53
|
+
|
|
54
|
+
- **Secure Execution**: Run commands and scripts in isolated E2B sandboxes
|
|
55
|
+
- **Browser Automation**: Control Chromium browsers with Playwright integration
|
|
56
|
+
- **Async/Await Support**: Full async/await support for modern Python development
|
|
57
|
+
- **Type Safety**: Complete type hints with Pydantic models
|
|
58
|
+
- **WebSocket Communication**: Real-time communication with sandbox environments
|
|
59
|
+
- **Multi-language Support**: Compatible with Node.js/TypeScript version
|
|
60
|
+
|
|
61
|
+
## ๐ฆ Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Install from PyPI (when published)
|
|
65
|
+
pip install grasp-sdk
|
|
66
|
+
|
|
67
|
+
# Install from source
|
|
68
|
+
pip install -e .
|
|
69
|
+
|
|
70
|
+
# Install with development dependencies
|
|
71
|
+
pip install -e ".[dev]"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## ๐ง Quick Start
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import asyncio
|
|
78
|
+
from grasp_sdk import GraspServer
|
|
79
|
+
|
|
80
|
+
async def main():
|
|
81
|
+
# Initialize Grasp server
|
|
82
|
+
server = GraspServer({
|
|
83
|
+
"key": api_key,
|
|
84
|
+
"timeout": 30000,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
# Start sandbox
|
|
89
|
+
await server.start()
|
|
90
|
+
|
|
91
|
+
# Execute command
|
|
92
|
+
result = await server.execute_command("echo 'Hello from Python!'")
|
|
93
|
+
print(f"Output: {result.stdout}")
|
|
94
|
+
|
|
95
|
+
# Browser automation
|
|
96
|
+
browser_task = await server.create_browser_task()
|
|
97
|
+
await browser_task.navigate("https://example.com")
|
|
98
|
+
screenshot = await browser_task.screenshot("example.png")
|
|
99
|
+
|
|
100
|
+
finally:
|
|
101
|
+
# Clean up
|
|
102
|
+
await server.close()
|
|
103
|
+
|
|
104
|
+
if __name__ == "__main__":
|
|
105
|
+
asyncio.run(main())
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## ๐๏ธ Architecture
|
|
109
|
+
|
|
110
|
+
The Python implementation mirrors the Node.js/TypeScript version:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
py-src/
|
|
114
|
+
โโโ __init__.py # Main package exports
|
|
115
|
+
โโโ grasp_server.py # Main GraspServer class
|
|
116
|
+
โโโ services/ # Core services
|
|
117
|
+
โ โโโ __init__.py
|
|
118
|
+
โ โโโ sandbox_service.py # E2B sandbox management
|
|
119
|
+
โ โโโ browser_service.py # Browser automation
|
|
120
|
+
โโโ types/ # Type definitions
|
|
121
|
+
โ โโโ __init__.py
|
|
122
|
+
โโโ utils/ # Utilities
|
|
123
|
+
โ โโโ __init__.py
|
|
124
|
+
โ โโโ config.py # Configuration management
|
|
125
|
+
โ โโโ logger.py # Logging utilities
|
|
126
|
+
โ โโโ auth.py # Authentication
|
|
127
|
+
โโโ cli/ # Command line interface
|
|
128
|
+
โ โโโ __init__.py
|
|
129
|
+
โ โโโ main.py
|
|
130
|
+
โโโ tests/ # Test suite
|
|
131
|
+
โโโ ...
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## ๐ Environment Variables
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Required
|
|
138
|
+
E2B_API_KEY=your_e2b_api_key_here
|
|
139
|
+
|
|
140
|
+
# Optional
|
|
141
|
+
GRASP_LOG_LEVEL=info
|
|
142
|
+
GRASP_TIMEOUT=30000
|
|
143
|
+
GRASP_TEMPLATE=python
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## ๐งช Development
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Install development dependencies
|
|
150
|
+
pip install -e ".[dev]"
|
|
151
|
+
|
|
152
|
+
# Run tests
|
|
153
|
+
pytest
|
|
154
|
+
|
|
155
|
+
# Format code
|
|
156
|
+
black .
|
|
157
|
+
isort .
|
|
158
|
+
|
|
159
|
+
# Type checking
|
|
160
|
+
mypy .
|
|
161
|
+
|
|
162
|
+
# Linting
|
|
163
|
+
flake8 .
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## ๐ API Reference
|
|
167
|
+
|
|
168
|
+
### GraspServer
|
|
169
|
+
|
|
170
|
+
Main class for interacting with E2B sandboxes and browser automation.
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
class GraspServer:
|
|
174
|
+
def __init__(self, config: ISandboxConfig = None)
|
|
175
|
+
async def start(self) -> None
|
|
176
|
+
async def close(self) -> None
|
|
177
|
+
async def execute_command(self, command: str, options: ICommandOptions = None) -> CommandResult
|
|
178
|
+
async def execute_script(self, script_path: str, options: IScriptOptions = None) -> CommandResult
|
|
179
|
+
async def create_browser_task(self, config: IBrowserConfig = None) -> BrowserTask
|
|
180
|
+
def get_sandbox_status(self) -> SandboxStatus
|
|
181
|
+
def get_sandbox_id(self) -> str
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## ๐ค Compatibility
|
|
185
|
+
|
|
186
|
+
This Python implementation provides the same API surface as the Node.js/TypeScript version, ensuring:
|
|
187
|
+
|
|
188
|
+
- **Feature Parity**: All features available in both implementations
|
|
189
|
+
- **API Consistency**: Same method names and behavior
|
|
190
|
+
- **Type Safety**: Equivalent type definitions using TypedDict and Pydantic
|
|
191
|
+
- **Error Handling**: Consistent error types and messages
|
|
192
|
+
|
|
193
|
+
## ๐ License
|
|
194
|
+
|
|
195
|
+
MIT License - see the [LICENSE](../LICENSE) file for details.
|
|
196
|
+
|
|
197
|
+
## ๐ Related
|
|
198
|
+
|
|
199
|
+
- [Node.js/TypeScript Implementation](../src/)
|
|
200
|
+
- [E2B Platform](https://e2b.dev/)
|
|
201
|
+
- [Playwright Python](https://playwright.dev/python/)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
grasp_sdk/__init__.py,sha256=7P4CFKAv1YgmbEog1s5uKMTVljSC0FDkC4ePhS0j_rE,7475
|
|
2
|
+
grasp_sdk/models/__init__.py,sha256=lAlbb9tG8fsKz1fo2IVr30pGVytU5V-KblDAzZnLbVQ,2738
|
|
3
|
+
grasp_sdk/sandbox/chrome-stable.mjs,sha256=8e20N7tlNRlQZ6bO3qpAdwllCBWE9cdbMN-iEW19F30,11281
|
|
4
|
+
grasp_sdk/sandbox/chromium.mjs,sha256=DTepEfkJ75mQE_nLLRE11ZrnODpjZXw0ahAFaaFSVX4,11477
|
|
5
|
+
grasp_sdk/sandbox/jsconfig.json,sha256=XkAgp68pCDDdHNpggzFb_dYB8hk3MHfJBOsUZZJXNCs,418
|
|
6
|
+
grasp_sdk/services/__init__.py,sha256=HqRD-WRedLwOb2gZPXPFzI-3892VT9IknKSbuDyiss8,327
|
|
7
|
+
grasp_sdk/services/browser.py,sha256=KBLy0ySJ8Zr7-XO_xVENhvP6h5-DLGi5eYDEHd4_CA4,14863
|
|
8
|
+
grasp_sdk/services/sandbox.py,sha256=VFlRuBFe5AjIbTvK80ntWK6xt2dsCfh7MwkUC-1FvpU,21783
|
|
9
|
+
grasp_sdk/utils/__init__.py,sha256=IQzRV-iZJXanSlaXBcgXBCcOXTVBCY6ZujxQpDTGW9w,816
|
|
10
|
+
grasp_sdk/utils/auth.py,sha256=M_SX3uKTjjfi6fzk384IqPvUtqt98bif22HHMgio1D4,7258
|
|
11
|
+
grasp_sdk/utils/config.py,sha256=txnmKQ6nxw-wvOBmr9mkZiWX7ROKwyHQLBpM_Wy9XZI,4171
|
|
12
|
+
grasp_sdk/utils/logger.py,sha256=k6WDmzL3cPTcQbiiTD4Q6fsDdUO_kyXQHz7nlmtv7G4,7228
|
|
13
|
+
grasp_sdk-0.1.0.dist-info/METADATA,sha256=y0oJ0nxQMqEDxzUAWFW6atYg9xcTxwQeFpLF5cwEGDM,6113
|
|
14
|
+
grasp_sdk-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
15
|
+
grasp_sdk-0.1.0.dist-info/entry_points.txt,sha256=roDjUu4JR6b1tUtRmq018mw167AbfC5zQiOtv3o6IMo,45
|
|
16
|
+
grasp_sdk-0.1.0.dist-info/top_level.txt,sha256=C9GL798_aP9Hgjq7UUlaGHLDfUohO2PSGYuGDV0cMx8,10
|
|
17
|
+
grasp_sdk-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
grasp_sdk
|