simplex 1.2.57__py3-none-any.whl → 1.2.61__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 simplex might be problematic. Click here for more details.
- simplex/simplex.py +64 -19
- {simplex-1.2.57.dist-info → simplex-1.2.61.dist-info}/METADATA +1 -1
- simplex-1.2.61.dist-info/RECORD +11 -0
- simplex-1.2.57.dist-info/RECORD +0 -11
- {simplex-1.2.57.dist-info → simplex-1.2.61.dist-info}/LICENSE +0 -0
- {simplex-1.2.57.dist-info → simplex-1.2.61.dist-info}/WHEEL +0 -0
- {simplex-1.2.57.dist-info → simplex-1.2.61.dist-info}/entry_points.txt +0 -0
- {simplex-1.2.57.dist-info → simplex-1.2.61.dist-info}/top_level.txt +0 -0
simplex/simplex.py
CHANGED
|
@@ -4,7 +4,7 @@ from typing import Optional, Union
|
|
|
4
4
|
import os
|
|
5
5
|
import json
|
|
6
6
|
import warnings
|
|
7
|
-
|
|
7
|
+
import time
|
|
8
8
|
# Try to import playwright, but don't fail if it's not available (lite version)
|
|
9
9
|
try:
|
|
10
10
|
from playwright.sync_api import sync_playwright
|
|
@@ -17,8 +17,8 @@ except ImportError:
|
|
|
17
17
|
ImportWarning
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
+
# BASE_URL = "https://simplex-dev--api-server-fastapi-app.modal.run"
|
|
20
21
|
BASE_URL = "https://api.simplex.sh"
|
|
21
|
-
|
|
22
22
|
class Playwright:
|
|
23
23
|
def __init__(self, simplex_instance):
|
|
24
24
|
self.simplex = simplex_instance
|
|
@@ -61,7 +61,7 @@ class Playwright:
|
|
|
61
61
|
print(response.json())
|
|
62
62
|
raise ValueError(f"It looks like the click action with playwright failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
63
63
|
|
|
64
|
-
if response.json()
|
|
64
|
+
if "succeeded" in response.json():
|
|
65
65
|
return
|
|
66
66
|
else:
|
|
67
67
|
raise ValueError(f"Failed to click element: {response.json()['error']}")
|
|
@@ -105,7 +105,7 @@ class Simplex:
|
|
|
105
105
|
self.session_id = None
|
|
106
106
|
if 'succeeded' not in response.json():
|
|
107
107
|
raise ValueError(f"It looks like the close_session action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
108
|
-
if response.json()
|
|
108
|
+
if "succeeded" in response.json():
|
|
109
109
|
return
|
|
110
110
|
else:
|
|
111
111
|
raise ValueError(f"Failed to close session: {response.json()['error']}")
|
|
@@ -158,7 +158,9 @@ class Simplex:
|
|
|
158
158
|
self.pw = sync_playwright().start()
|
|
159
159
|
self.connect_url = response_json['connect_url']
|
|
160
160
|
# self.pw_browser = self.pw.chromium.connect_over_cdp(response_json['connect_url'])
|
|
161
|
-
|
|
161
|
+
if not "api.simplex.sh" in BASE_URL:
|
|
162
|
+
livestream_url = f"http://localhost:3000/session/{self.session_id}"
|
|
163
|
+
|
|
162
164
|
if show_in_console:
|
|
163
165
|
print(f"Livestream URL: {livestream_url}")
|
|
164
166
|
|
|
@@ -188,12 +190,14 @@ class Simplex:
|
|
|
188
190
|
if 'succeeded' not in response.json():
|
|
189
191
|
raise ValueError(f"It looks like the goto action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
190
192
|
|
|
191
|
-
if response.json()
|
|
193
|
+
if "succeeded" in response.json():
|
|
192
194
|
return
|
|
193
195
|
else:
|
|
194
196
|
raise ValueError(f"Failed to goto url: {response.json()['error']}")
|
|
195
197
|
|
|
196
198
|
def click(self, element_description: str, cdp_url: str = None):
|
|
199
|
+
if not element_description or not element_description.strip():
|
|
200
|
+
raise ValueError("element_description cannot be empty")
|
|
197
201
|
if not cdp_url and not self.session_id:
|
|
198
202
|
raise ValueError(f"Must call create_session before calling action click with element_description='{element_description}'")
|
|
199
203
|
|
|
@@ -219,6 +223,8 @@ class Simplex:
|
|
|
219
223
|
raise ValueError(f"Failed to click element: {response.json()['error']}")
|
|
220
224
|
|
|
221
225
|
def type(self, text: str, cdp_url: str = None):
|
|
226
|
+
if not text or not text.strip():
|
|
227
|
+
raise ValueError("text cannot be empty")
|
|
222
228
|
if not cdp_url and not self.session_id:
|
|
223
229
|
raise ValueError(f"Must call create_session before calling action type with text='{text}'")
|
|
224
230
|
|
|
@@ -236,11 +242,38 @@ class Simplex:
|
|
|
236
242
|
},
|
|
237
243
|
data=data
|
|
238
244
|
)
|
|
239
|
-
if response.json()
|
|
245
|
+
if "succeeded" in response.json():
|
|
240
246
|
return
|
|
241
247
|
else:
|
|
248
|
+
print(response.json())
|
|
242
249
|
raise ValueError(f"Failed to type text: {response.json()['error']}")
|
|
250
|
+
|
|
243
251
|
|
|
252
|
+
def reload(self, cdp_url: str = None):
|
|
253
|
+
if not cdp_url and not self.session_id:
|
|
254
|
+
raise ValueError("Must call create_session before calling action reload")
|
|
255
|
+
|
|
256
|
+
data = {}
|
|
257
|
+
|
|
258
|
+
if cdp_url:
|
|
259
|
+
data['cdp_url'] = cdp_url
|
|
260
|
+
else:
|
|
261
|
+
data['session_id'] = self.session_id
|
|
262
|
+
|
|
263
|
+
response = requests.post(
|
|
264
|
+
f"{BASE_URL}/reload",
|
|
265
|
+
headers={
|
|
266
|
+
'x-api-key': self.api_key
|
|
267
|
+
},
|
|
268
|
+
data=data
|
|
269
|
+
)
|
|
270
|
+
if 'succeeded' not in response.json():
|
|
271
|
+
raise ValueError(f"It looks like the reload action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
272
|
+
if "succeeded" in response.json():
|
|
273
|
+
return
|
|
274
|
+
else:
|
|
275
|
+
raise ValueError(f"Failed to reload: {response.json()['error']}")
|
|
276
|
+
|
|
244
277
|
def press_enter(self, cdp_url: str = None):
|
|
245
278
|
if not cdp_url and not self.session_id:
|
|
246
279
|
raise ValueError("Must call create_session before calling action press_enter")
|
|
@@ -261,7 +294,7 @@ class Simplex:
|
|
|
261
294
|
)
|
|
262
295
|
if 'succeeded' not in response.json():
|
|
263
296
|
raise ValueError(f"It looks like the press_enter action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
264
|
-
if response.json()
|
|
297
|
+
if "succeeded" in response.json():
|
|
265
298
|
return
|
|
266
299
|
else:
|
|
267
300
|
raise ValueError(f"Failed to press enter: {response.json()['error']}")
|
|
@@ -286,7 +319,7 @@ class Simplex:
|
|
|
286
319
|
)
|
|
287
320
|
if 'succeeded' not in response.json():
|
|
288
321
|
raise ValueError(f"It looks like the press_tab action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
289
|
-
if response.json()
|
|
322
|
+
if "succeeded" in response.json():
|
|
290
323
|
return
|
|
291
324
|
else:
|
|
292
325
|
raise ValueError(f"Failed to press tab: {response.json()['error']}")
|
|
@@ -311,12 +344,14 @@ class Simplex:
|
|
|
311
344
|
)
|
|
312
345
|
if 'succeeded' not in response.json():
|
|
313
346
|
raise ValueError(f"It looks like the delete_text action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
314
|
-
if response.json()
|
|
347
|
+
if "succeeded" in response.json():
|
|
315
348
|
return
|
|
316
349
|
else:
|
|
317
350
|
raise ValueError(f"Failed to delete text: {response.json()['error']}")
|
|
318
351
|
|
|
319
352
|
def extract_bbox(self, element_description: str, cdp_url: str = None):
|
|
353
|
+
if not element_description or not element_description.strip():
|
|
354
|
+
raise ValueError("element_description cannot be empty")
|
|
320
355
|
if not cdp_url and not self.session_id:
|
|
321
356
|
raise ValueError(f"Must call create_session before calling action extract_bbox with element_description='{element_description}'")
|
|
322
357
|
|
|
@@ -336,12 +371,14 @@ class Simplex:
|
|
|
336
371
|
)
|
|
337
372
|
if 'succeeded' not in response.json():
|
|
338
373
|
raise ValueError(f"It looks like the extract_bbox action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
339
|
-
if response.json()
|
|
374
|
+
if "succeeded" in response.json():
|
|
340
375
|
return response.json()["bbox"]
|
|
341
376
|
else:
|
|
342
377
|
raise ValueError(f"Failed to extract bbox: {response.json()['error']}")
|
|
343
378
|
|
|
344
379
|
def extract_text(self, element_description: str, cdp_url: str = None):
|
|
380
|
+
if not element_description or not element_description.strip():
|
|
381
|
+
raise ValueError("element_description cannot be empty")
|
|
345
382
|
if not cdp_url and not self.session_id:
|
|
346
383
|
raise ValueError(f"Must call create_session before calling action extract_text with element_description='{element_description}'")
|
|
347
384
|
|
|
@@ -362,12 +399,14 @@ class Simplex:
|
|
|
362
399
|
response_json = response.json()
|
|
363
400
|
if 'succeeded' not in response_json:
|
|
364
401
|
raise ValueError(f"It looks like the extract_text action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
365
|
-
if
|
|
402
|
+
if "succeeded" in response_json:
|
|
366
403
|
return response_json["text"]
|
|
367
404
|
else:
|
|
368
405
|
raise ValueError(f"Failed to extract text: {response_json['error']}")
|
|
369
406
|
|
|
370
407
|
def extract_image(self, element_description: str, cdp_url: str = None):
|
|
408
|
+
if not element_description or not element_description.strip():
|
|
409
|
+
raise ValueError("element_description cannot be empty")
|
|
371
410
|
if not cdp_url and not self.session_id:
|
|
372
411
|
raise ValueError(f"Must call create_session before calling action extract_image with element_description='{element_description}'")
|
|
373
412
|
|
|
@@ -387,7 +426,7 @@ class Simplex:
|
|
|
387
426
|
)
|
|
388
427
|
if 'succeeded' not in response.json():
|
|
389
428
|
raise ValueError(f"It looks like the extract_image action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
390
|
-
if response.json()
|
|
429
|
+
if "succeeded" in response.json():
|
|
391
430
|
return response.json()["image"]
|
|
392
431
|
else:
|
|
393
432
|
raise ValueError(f"Failed to extract image: {response.json()['error']}")
|
|
@@ -412,7 +451,7 @@ class Simplex:
|
|
|
412
451
|
)
|
|
413
452
|
if 'succeeded' not in response.json():
|
|
414
453
|
raise ValueError(f"It looks like the scroll action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
415
|
-
if response.json()
|
|
454
|
+
if "succeeded" in response.json():
|
|
416
455
|
return
|
|
417
456
|
else:
|
|
418
457
|
raise ValueError(f"Failed to scroll: {response.json()['error']}")
|
|
@@ -437,7 +476,7 @@ class Simplex:
|
|
|
437
476
|
)
|
|
438
477
|
if 'succeeded' not in response.json():
|
|
439
478
|
raise ValueError(f"It looks like the wait action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
440
|
-
if response.json()
|
|
479
|
+
if "succeeded" in response.json():
|
|
441
480
|
return
|
|
442
481
|
else:
|
|
443
482
|
raise ValueError(f"Failed to wait: {response.json()['error']}")
|
|
@@ -554,7 +593,7 @@ class Simplex:
|
|
|
554
593
|
)
|
|
555
594
|
if 'succeeded' not in response.json():
|
|
556
595
|
raise ValueError(f"It looks like the restore_login_session action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
557
|
-
if response.json()
|
|
596
|
+
if "succeeded" in response.json():
|
|
558
597
|
return
|
|
559
598
|
else:
|
|
560
599
|
raise ValueError(f"Failed to restore login session: {response.json()['error']}")
|
|
@@ -565,6 +604,8 @@ class Simplex:
|
|
|
565
604
|
element_description: Description of the element to click and upload to
|
|
566
605
|
file_path_or_callable: Either a path to the file to be uploaded or a callable that returns a file-like object in 'rb' mode
|
|
567
606
|
"""
|
|
607
|
+
if not element_description or not element_description.strip():
|
|
608
|
+
raise ValueError("element_description cannot be empty")
|
|
568
609
|
if not self.session_id:
|
|
569
610
|
raise ValueError(f"Must call create_session before calling action click_and_upload with element_description='{element_description}'")
|
|
570
611
|
|
|
@@ -596,12 +637,14 @@ class Simplex:
|
|
|
596
637
|
)
|
|
597
638
|
if 'succeeded' not in response.json():
|
|
598
639
|
raise ValueError(f"It looks like the click_and_upload action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
599
|
-
if response.json()
|
|
640
|
+
if "succeeded" in response.json():
|
|
600
641
|
return
|
|
601
642
|
else:
|
|
602
643
|
raise ValueError(f"Failed to click and upload: {response.json()['error']}")
|
|
603
644
|
|
|
604
645
|
def click_and_download(self, element_description: str):
|
|
646
|
+
if not element_description or not element_description.strip():
|
|
647
|
+
raise ValueError("element_description cannot be empty")
|
|
605
648
|
if not self.session_id:
|
|
606
649
|
raise ValueError(f"Must call create_session before calling action click_and_download with element_description='{element_description}'")
|
|
607
650
|
|
|
@@ -620,12 +663,14 @@ class Simplex:
|
|
|
620
663
|
)
|
|
621
664
|
if 'succeeded' not in response.json():
|
|
622
665
|
raise ValueError(f"It looks like the click_and_download action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
623
|
-
if response.json()
|
|
666
|
+
if "succeeded" in response.json():
|
|
624
667
|
return response.json()["b64"], response.json()["filename"]
|
|
625
668
|
else:
|
|
626
669
|
raise ValueError(f"Failed to click and download: {response.json()['error']}")
|
|
627
670
|
|
|
628
671
|
def exists(self, element_description: str, cdp_url: str = None):
|
|
672
|
+
if not element_description or not element_description.strip():
|
|
673
|
+
raise ValueError("element_description cannot be empty")
|
|
629
674
|
if not cdp_url and not self.session_id:
|
|
630
675
|
raise ValueError(f"Must call create_session before calling action exists with element_description='{element_description}'")
|
|
631
676
|
|
|
@@ -646,7 +691,7 @@ class Simplex:
|
|
|
646
691
|
if 'succeeded' not in response.json():
|
|
647
692
|
raise ValueError(f"It looks like the exists action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
648
693
|
response_json = response.json()
|
|
649
|
-
if response_json
|
|
694
|
+
if "succeeded" in response_json:
|
|
650
695
|
return response_json['exists'], response_json['reasoning']
|
|
651
696
|
else:
|
|
652
697
|
raise ValueError(f"Failed to check if element exists: {response_json['error']}")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
|
|
2
|
+
simplex/cli.py,sha256=0K_pzoVdF7vfTJPUONhFzzTvjZk2M7FZPpEONjZWJC8,2268
|
|
3
|
+
simplex/simplex.py,sha256=cBmj1jxxNjqwLPb774tSrvWMBcayRkaqiXlhhpkMsjc,27624
|
|
4
|
+
simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
|
|
5
|
+
simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
|
|
6
|
+
simplex-1.2.61.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
|
|
7
|
+
simplex-1.2.61.dist-info/METADATA,sha256=z_qPNkJ3xM_h6v7ntRuiZIqp2d6vlh6Mw1vetBTzWo4,1045
|
|
8
|
+
simplex-1.2.61.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
+
simplex-1.2.61.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
|
|
10
|
+
simplex-1.2.61.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
|
|
11
|
+
simplex-1.2.61.dist-info/RECORD,,
|
simplex-1.2.57.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
|
|
2
|
-
simplex/cli.py,sha256=0K_pzoVdF7vfTJPUONhFzzTvjZk2M7FZPpEONjZWJC8,2268
|
|
3
|
-
simplex/simplex.py,sha256=qz9vUcp0HVIN_weBxv_sBCY1pw8LTObR3fcHcU_0gZQ,25413
|
|
4
|
-
simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
|
|
5
|
-
simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
|
|
6
|
-
simplex-1.2.57.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
|
|
7
|
-
simplex-1.2.57.dist-info/METADATA,sha256=actbMwYSlAmBFJC9spU_A845aGqUEd3VhUhYJWV42os,1045
|
|
8
|
-
simplex-1.2.57.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
-
simplex-1.2.57.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
|
|
10
|
-
simplex-1.2.57.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
|
|
11
|
-
simplex-1.2.57.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|