simplex 1.0.0__tar.gz → 1.0.6__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.

Potentially problematic release.


This version of simplex might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Simplex Labs, Inc.
3
+ Copyright (c) 2024 Simplex
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+ recursive-include simplex *.py
5
+ recursive-exclude tests *
6
+ recursive-exclude examples *
simplex-1.0.6/PKG-INFO ADDED
@@ -0,0 +1,423 @@
1
+ Metadata-Version: 2.4
2
+ Name: simplex
3
+ Version: 1.0.6
4
+ Summary: Official Python SDK for the Simplex API
5
+ Home-page: https://github.com/yourusername/simplex-python-sdk
6
+ Author: Simplex
7
+ Author-email: Simplex <support@simplex.sh>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/yourusername/simplex-python-sdk
10
+ Project-URL: Documentation, https://docs.simplex.sh
11
+ Project-URL: Repository, https://github.com/yourusername/simplex-python-sdk
12
+ Project-URL: Bug Tracker, https://github.com/yourusername/simplex-python-sdk/issues
13
+ Keywords: simplex,api,sdk,workflow,automation,browser
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Operating System :: OS Independent
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: requests>=2.25.0
29
+ Requires-Dist: urllib3>=1.26.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
32
+ Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
33
+ Requires-Dist: black>=22.0.0; extra == "dev"
34
+ Requires-Dist: flake8>=4.0.0; extra == "dev"
35
+ Requires-Dist: mypy>=0.950; extra == "dev"
36
+ Requires-Dist: python-dotenv>=0.19.0; extra == "dev"
37
+ Dynamic: author
38
+ Dynamic: home-page
39
+ Dynamic: license-file
40
+ Dynamic: requires-python
41
+
42
+ # Simplex Python SDK
43
+
44
+ Official Python SDK for the [Simplex API](https://simplex.sh) - A powerful workflow automation platform for browser-based tasks.
45
+
46
+ [![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
47
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
48
+
49
+ ## Features
50
+
51
+ - 🚀 Simple and intuitive API
52
+ - 🔄 Automatic retry logic with exponential backoff
53
+ - 🎯 Type hints for better IDE support
54
+ - 🔐 Built-in error handling
55
+ - 📦 Context manager support for automatic cleanup
56
+ - 🤖 Support for agentic workflows and named agents
57
+ - 📁 File download capabilities
58
+ - 🔑 2FA configuration management
59
+
60
+ ## Installation
61
+
62
+ Install the Simplex SDK using pip:
63
+
64
+ ```bash
65
+ pip install simplex-sdk
66
+ ```
67
+
68
+ Or install from source:
69
+
70
+ ```bash
71
+ git clone https://github.com/yourusername/simplex-python-sdk.git
72
+ cd simplex-python-sdk/python
73
+ pip install -e .
74
+ ```
75
+
76
+ ## Quick Start
77
+
78
+ ```python
79
+ from simplex import SimplexClient
80
+
81
+ # Initialize the client
82
+ client = SimplexClient(api_key='your-api-key')
83
+
84
+ # Run a workflow with variables
85
+ result = client.workflows.run(
86
+ 'workflow-id',
87
+ variables={'username': 'user@example.com'}
88
+ )
89
+
90
+ print(f"Workflow started: {result['session_id']}")
91
+ ```
92
+
93
+ ## Usage Examples
94
+
95
+ ### Creating a Workflow Session
96
+
97
+ Use workflow sessions for more control over browser automation:
98
+
99
+ ```python
100
+ from simplex import SimplexClient
101
+
102
+ client = SimplexClient(api_key='your-api-key')
103
+
104
+ # Using context manager for automatic cleanup
105
+ with client.create_workflow_session(
106
+ name='my-workflow',
107
+ url='https://example.com'
108
+ ) as session:
109
+ print(f'Session ID: {session.session_id}')
110
+ print(f'Livestream URL: {session.livestream_url}')
111
+
112
+ # Navigate to a page
113
+ session.goto('https://example.com/login')
114
+
115
+ # Run a named agent
116
+ session.run_agent('Login Agent', variables={
117
+ 'username': 'user@example.com',
118
+ 'password': 'secret'
119
+ })
120
+
121
+ # Execute an agentic task
122
+ session.agentic('Click the submit button and wait for confirmation')
123
+
124
+ # Session automatically closes when exiting the with block
125
+ ```
126
+
127
+ ### Running a Workflow
128
+
129
+ Execute pre-built workflows with variables:
130
+
131
+ ```python
132
+ from simplex import SimplexClient, WorkflowError
133
+
134
+ client = SimplexClient(api_key='your-api-key')
135
+
136
+ try:
137
+ # Run workflow with variables
138
+ result = client.workflows.run(
139
+ 'workflow-id',
140
+ variables={
141
+ 'email': 'user@example.com',
142
+ 'product_id': '12345'
143
+ },
144
+ metadata='Order processing workflow'
145
+ )
146
+
147
+ print(f"Success: {result['succeeded']}")
148
+ print(f"Session ID: {result['session_id']}")
149
+
150
+ # Check workflow status
151
+ status = client.workflows.get_status(result['session_id'])
152
+ print(f"Completed: {status['completed']}")
153
+ print(f"Total actions: {status['total_actions']}")
154
+
155
+ except WorkflowError as e:
156
+ print(f"Workflow failed: {e.message}")
157
+ ```
158
+
159
+ ### Using Agentic Tasks
160
+
161
+ Execute natural language instructions:
162
+
163
+ ```python
164
+ # Within a workflow session
165
+ session.agentic(
166
+ 'Navigate to the invoices page and download the latest invoice',
167
+ max_steps=10
168
+ )
169
+
170
+ # Or using the workflows resource
171
+ client.workflows.agentic(
172
+ task='Find and click the login button',
173
+ session_id='session-id',
174
+ max_steps=5
175
+ )
176
+ ```
177
+
178
+ ### Downloading Session Files
179
+
180
+ Download files created during workflow execution:
181
+
182
+ ```python
183
+ from simplex import SimplexClient
184
+
185
+ client = SimplexClient(api_key='your-api-key')
186
+
187
+ # Download all files as a zip
188
+ zip_data = client.download_session_files('session-id')
189
+ with open('session_files.zip', 'wb') as f:
190
+ f.write(zip_data)
191
+
192
+ # Download a specific file
193
+ file_data = client.download_session_files('session-id', filename='report.pdf')
194
+ with open('report.pdf', 'wb') as f:
195
+ f.write(file_data)
196
+ ```
197
+
198
+ ### Adding 2FA Configuration
199
+
200
+ Configure automatic 2FA handling:
201
+
202
+ ```python
203
+ from simplex import SimplexClient
204
+
205
+ client = SimplexClient(api_key='your-api-key')
206
+
207
+ result = client.add_2fa_config(
208
+ seed='JBSWY3DPEHPK3PXP',
209
+ name='My Service',
210
+ partial_url='example.com'
211
+ )
212
+
213
+ print(f"Total configs: {result['total_configs']}")
214
+ ```
215
+
216
+ ### Error Handling
217
+
218
+ The SDK provides specific exception types for different error scenarios:
219
+
220
+ ```python
221
+ from simplex import (
222
+ SimplexClient,
223
+ SimplexError,
224
+ WorkflowError,
225
+ AuthenticationError,
226
+ RateLimitError,
227
+ NetworkError
228
+ )
229
+
230
+ client = SimplexClient(api_key='your-api-key')
231
+
232
+ try:
233
+ result = client.workflows.run('workflow-id')
234
+ except AuthenticationError as e:
235
+ print(f"Authentication failed: {e.message}")
236
+ except RateLimitError as e:
237
+ print(f"Rate limit exceeded. Retry after {e.retry_after} seconds")
238
+ except WorkflowError as e:
239
+ print(f"Workflow error: {e.message}")
240
+ print(f"Workflow ID: {e.workflow_id}")
241
+ print(f"Session ID: {e.session_id}")
242
+ except NetworkError as e:
243
+ print(f"Network error: {e.message}")
244
+ except SimplexError as e:
245
+ print(f"General error: {e.message}")
246
+ ```
247
+
248
+ ## Configuration
249
+
250
+ ### Environment Variables
251
+
252
+ You can use environment variables for configuration:
253
+
254
+ ```python
255
+ import os
256
+ from simplex import SimplexClient
257
+
258
+ api_key = os.getenv('SIMPLEX_API_KEY')
259
+ client = SimplexClient(api_key=api_key)
260
+ ```
261
+
262
+ Example `.env` file:
263
+
264
+ ```bash
265
+ SIMPLEX_API_KEY=your-api-key
266
+ WORKFLOW_ID=your-workflow-id
267
+ ```
268
+
269
+ ### Client Options
270
+
271
+ Customize client behavior with initialization parameters:
272
+
273
+ ```python
274
+ from simplex import SimplexClient
275
+
276
+ client = SimplexClient(
277
+ api_key='your-api-key',
278
+ timeout=60, # Request timeout in seconds
279
+ max_retries=5, # Maximum retry attempts
280
+ retry_delay=2, # Delay between retries in seconds
281
+ base_url='https://api.simplex.sh' # API base URL
282
+ )
283
+ ```
284
+
285
+ ## API Reference
286
+
287
+ ### SimplexClient
288
+
289
+ Main client class for interacting with the Simplex API.
290
+
291
+ **Methods:**
292
+ - `create_workflow_session(name, url, proxies=False, session_data=None)` - Create a new workflow session
293
+ - `get_session_store(session_id)` - Retrieve session store data
294
+ - `download_session_files(session_id, filename=None)` - Download files from a session
295
+ - `add_2fa_config(seed, name=None, partial_url=None)` - Add 2FA configuration
296
+ - `update_api_key(api_key)` - Update the API key
297
+ - `set_custom_header(key, value)` - Set a custom header
298
+ - `remove_custom_header(key)` - Remove a custom header
299
+
300
+ ### Workflow Resource
301
+
302
+ Access via `client.workflows`
303
+
304
+ **Methods:**
305
+ - `run(workflow_id, variables=None, metadata=None, webhook_url=None)` - Execute a workflow
306
+ - `get_status(session_id)` - Get workflow execution status
307
+ - `create_workflow_session(workflow_name, url, proxies=False, session_data=None)` - Create a session
308
+ - `agentic(task, session_id, max_steps=None, actions_to_exclude=None, variables=None)` - Run agentic task
309
+ - `run_agent(agent_name, session_id, variables=None)` - Run a named agent
310
+ - `start_segment(workflow_id, segment_name)` - Start a workflow segment
311
+ - `finish_segment(workflow_id)` - Finish the current segment
312
+ - `start_capture(session_id)` - Start capture mode
313
+ - `stop_capture(session_id)` - Stop capture mode
314
+ - `close_workflow_session(session_id)` - Close a session
315
+
316
+ ### WorkflowSession
317
+
318
+ Created via `client.create_workflow_session()`. Supports context manager protocol.
319
+
320
+ **Properties:**
321
+ - `session_id` - Unique session identifier
322
+ - `workflow_id` - Associated workflow ID
323
+ - `livestream_url` - URL to view live browser session
324
+ - `connect_url` - Connection URL
325
+ - `vnc_url` - VNC access URL
326
+ - `is_closed` - Whether the session is closed
327
+
328
+ **Methods:**
329
+ - `goto(url)` - Navigate to a URL
330
+ - `agentic(task, max_steps=None, actions_to_exclude=None, variables=None)` - Execute agentic task
331
+ - `run_agent(agent_name, variables=None)` - Run a named agent
332
+ - `start_capture()` - Start capture mode
333
+ - `stop_capture()` - Stop capture mode
334
+ - `close()` - Close the session
335
+
336
+ ## Development
337
+
338
+ ### Setup Development Environment
339
+
340
+ ```bash
341
+ # Clone the repository
342
+ git clone https://github.com/yourusername/simplex-python-sdk.git
343
+ cd simplex-python-sdk/python
344
+
345
+ # Create a virtual environment
346
+ python -m venv venv
347
+ source venv/bin/activate # On Windows: venv\Scripts\activate
348
+
349
+ # Install development dependencies
350
+ pip install -r requirements-dev.txt
351
+
352
+ # Install the package in editable mode
353
+ pip install -e .
354
+ ```
355
+
356
+ ### Running Tests
357
+
358
+ ```bash
359
+ pytest tests/
360
+ ```
361
+
362
+ ### Code Formatting
363
+
364
+ ```bash
365
+ black simplex/
366
+ flake8 simplex/
367
+ mypy simplex/
368
+ ```
369
+
370
+ ## Examples
371
+
372
+ Check out the [examples](./examples) directory for more usage examples:
373
+
374
+ - `login_example.py` - Basic login workflow
375
+ - `create_workflow.py` - Creating and controlling sessions
376
+ - `run_workflow.py` - Running workflows with variables
377
+ - `download_file.py` - Downloading session files
378
+ - `add_2fa_config.py` - Adding 2FA configuration
379
+
380
+ ## Requirements
381
+
382
+ - Python 3.8 or higher
383
+ - `requests>=2.25.0`
384
+ - `urllib3>=1.26.0`
385
+
386
+ ## Contributing
387
+
388
+ Contributions are welcome! Please feel free to submit a Pull Request.
389
+
390
+ 1. Fork the repository
391
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
392
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
393
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
394
+ 5. Open a Pull Request
395
+
396
+ ## License
397
+
398
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
399
+
400
+ ## Support
401
+
402
+ - Documentation: [https://docs.simplex.sh](https://docs.simplex.sh)
403
+ - Email: support@simplex.sh
404
+ - GitHub Issues: [https://github.com/yourusername/simplex-python-sdk/issues](https://github.com/yourusername/simplex-python-sdk/issues)
405
+
406
+ ## Changelog
407
+
408
+ ### Version 1.0.0 (2024)
409
+
410
+ - Initial release
411
+ - Full feature parity with TypeScript SDK
412
+ - Support for workflow execution and session management
413
+ - Agentic task execution
414
+ - Named agent support
415
+ - File download capabilities
416
+ - 2FA configuration management
417
+ - Comprehensive error handling
418
+ - Type hints throughout
419
+ - Context manager support
420
+
421
+ ---
422
+
423
+ Made with ❤️ by [Simplex](https://simplex.sh)