simplex 1.2.64__tar.gz → 1.2.69__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
  Metadata-Version: 2.1
2
2
  Name: simplex
3
- Version: 1.2.64
3
+ Version: 1.2.69
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -18,7 +18,7 @@ Requires-Dist: requests
18
18
  Requires-Dist: python-dotenv
19
19
  Requires-Dist: click
20
20
  Provides-Extra: playwright
21
- Requires-Dist: playwright>=1.0.0; extra == "playwright"
21
+ Requires-Dist: rebrowser-playwright>=1.0.0; extra == "playwright"
22
22
 
23
23
  # Simplex AI Python SDK
24
24
 
@@ -8,21 +8,21 @@ class PostDevelopCommand(develop):
8
8
  """Post-installation for development mode."""
9
9
  def run(self):
10
10
  develop.run(self)
11
- # Only install playwright if playwright version is being installed
11
+ # Only install rebrowser-playwright if playwright version is being installed
12
12
  if any('playwright' in arg for arg in sys.argv):
13
- check_call(["playwright", "install"])
13
+ check_call(["rebrowser-playwright", "install"])
14
14
 
15
15
  class PostInstallCommand(install):
16
16
  """Post-installation for installation mode."""
17
17
  def run(self):
18
18
  install.run(self)
19
- # Only install playwright if playwright version is being installed
19
+ # Only install rebrowser-playwright if playwright version is being installed
20
20
  if any('playwright' in arg for arg in sys.argv):
21
- check_call(["playwright", "install"])
21
+ check_call(["rebrowser-playwright", "install"])
22
22
 
23
23
  setup(
24
24
  name="simplex",
25
- version="1.2.64",
25
+ version="1.2.69",
26
26
  packages=find_packages(),
27
27
  package_data={
28
28
  "simplex": ["browser_agent/dom/*.js"], # Include JS files in the dom directory
@@ -34,7 +34,7 @@ setup(
34
34
  "click",
35
35
  ],
36
36
  extras_require={
37
- 'playwright': ['playwright>=1.0.0'], # Full version with playwright
37
+ 'playwright': ['rebrowser-playwright>=1.0.0'], # Full version with rebrowser-playwright
38
38
  },
39
39
  cmdclass={
40
40
  'develop': PostDevelopCommand,
@@ -4,9 +4,7 @@ from typing import Optional, Union
4
4
  import os
5
5
  import json
6
6
  import warnings
7
- import time
8
- import tempfile
9
- # Try to import playwright, but don't fail if it's not available (lite version)
7
+
10
8
  try:
11
9
  from rebrowser_playwright.sync_api import sync_playwright
12
10
  PLAYWRIGHT_AVAILABLE = True
@@ -81,11 +79,9 @@ class Simplex:
81
79
  self.session_id = None
82
80
  atexit.register(self.close_session)
83
81
  if PLAYWRIGHT_AVAILABLE:
84
- self.playwright = Playwright(self)
85
82
  self.pw_browser = None
86
83
  self.pw = None
87
84
  else:
88
- self.playwright = None
89
85
  self.pw_browser = None
90
86
  self.pw = None
91
87
 
@@ -114,13 +110,12 @@ class Simplex:
114
110
  self.session_id = None
115
111
  if 'succeeded' not in response.json():
116
112
  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?")
117
- if "succeeded" in response.json():
113
+ if response.json()['succeeded']:
118
114
  return
119
115
  else:
120
116
  raise ValueError(f"Failed to close session: {response.json()['error']}")
121
117
 
122
118
  def create_session(self, show_in_console: Optional[bool] = True, proxies: Optional[bool] = True, workflow_name: Optional[str] = None, session_data: Optional[dict | str] = None):
123
- print("CREATING SESSION")
124
119
  if self.session_id:
125
120
  raise ValueError("A session is already active. Please close the current session before creating a new one.")
126
121
 
@@ -201,10 +196,11 @@ class Simplex:
201
196
  if 'succeeded' not in response.json():
202
197
  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?")
203
198
 
204
- if "succeeded" in response.json():
199
+ if response.json()['succeeded']:
205
200
  return
206
201
  else:
207
202
  raise ValueError(f"Failed to goto url: {response.json()['error']}")
203
+
208
204
 
209
205
  def click(self, element_description: str, cdp_url: str = None):
210
206
  if not element_description or not element_description.strip():
@@ -232,6 +228,35 @@ class Simplex:
232
228
  return response.json()["element_clicked"]
233
229
  else:
234
230
  raise ValueError(f"Failed to click element: {response.json()['error']}")
231
+
232
+ def select_dropdown_option(self, element_description: str, cdp_url: str = None):
233
+ if not element_description or not element_description.strip():
234
+ raise ValueError("element_description cannot be empty")
235
+ if not cdp_url and not self.session_id:
236
+ raise ValueError(f"Must call create_session before calling action select_from_dropdown with element_description='{element_description}'")
237
+
238
+ data = {'element_description': element_description}
239
+
240
+ if cdp_url:
241
+ data['cdp_url'] = cdp_url
242
+ else:
243
+ data['session_id'] = self.session_id
244
+
245
+
246
+ response = requests.post(
247
+ f"{BASE_URL}/select_dropdown_option",
248
+ headers={
249
+ 'x-api-key': self.api_key
250
+ },
251
+ data=data
252
+ )
253
+
254
+ if 'succeeded' not in response.json():
255
+ raise ValueError(f"It looks like the select_dropdown_option action failed to return a response. Did you set your api_key when creating the Simplex class?")
256
+ if response.json()["succeeded"]:
257
+ return response.json()["element_clicked"]
258
+ else:
259
+ raise ValueError(f"Failed to select dropdown option: {response.json()['error']}")
235
260
 
236
261
 
237
262
  def scroll_to_element(self, element_description: str, cdp_url: str = None):
@@ -312,7 +337,7 @@ class Simplex:
312
337
  },
313
338
  data=data
314
339
  )
315
- if "succeeded" in response.json():
340
+ if response.json()['succeeded']:
316
341
  return
317
342
  else:
318
343
  raise ValueError(f"Failed to type text: {response.json()['error']}")
@@ -338,7 +363,7 @@ class Simplex:
338
363
  )
339
364
  if 'succeeded' not in response.json():
340
365
  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?")
341
- if "succeeded" in response.json():
366
+ if response.json()['succeeded']:
342
367
  return
343
368
  else:
344
369
  raise ValueError(f"Failed to reload: {response.json()['error']}")
@@ -363,7 +388,7 @@ class Simplex:
363
388
  )
364
389
  if 'succeeded' not in response.json():
365
390
  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?")
366
- if "succeeded" in response.json():
391
+ if response.json()['succeeded']:
367
392
  return
368
393
  else:
369
394
  raise ValueError(f"Failed to press enter: {response.json()['error']}")
@@ -388,7 +413,7 @@ class Simplex:
388
413
  )
389
414
  if 'succeeded' not in response.json():
390
415
  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?")
391
- if "succeeded" in response.json():
416
+ if response.json()['succeeded']:
392
417
  return
393
418
  else:
394
419
  raise ValueError(f"Failed to press tab: {response.json()['error']}")
@@ -413,7 +438,7 @@ class Simplex:
413
438
  )
414
439
  if 'succeeded' not in response.json():
415
440
  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?")
416
- if "succeeded" in response.json():
441
+ if response.json()['succeeded']:
417
442
  return
418
443
  else:
419
444
  raise ValueError(f"Failed to delete text: {response.json()['error']}")
@@ -440,7 +465,7 @@ class Simplex:
440
465
  )
441
466
  if 'succeeded' not in response.json():
442
467
  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?")
443
- if "succeeded" in response.json():
468
+ if response.json()['succeeded']:
444
469
  return response.json()["bbox"]
445
470
  else:
446
471
  raise ValueError(f"Failed to extract bbox: {response.json()['error']}")
@@ -495,7 +520,7 @@ class Simplex:
495
520
  )
496
521
  if 'succeeded' not in response.json():
497
522
  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?")
498
- if "succeeded" in response.json():
523
+ if response.json()['succeeded']:
499
524
  return response.json()["image"]
500
525
  else:
501
526
  raise ValueError(f"Failed to extract image: {response.json()['error']}")
@@ -520,7 +545,7 @@ class Simplex:
520
545
  )
521
546
  if 'succeeded' not in response.json():
522
547
  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?")
523
- if "succeeded" in response.json():
548
+ if response.json()['succeeded']:
524
549
  return
525
550
  else:
526
551
  raise ValueError(f"Failed to scroll: {response.json()['error']}")
@@ -545,7 +570,7 @@ class Simplex:
545
570
  )
546
571
  if 'succeeded' not in response.json():
547
572
  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?")
548
- if "succeeded" in response.json():
573
+ if response.json()['succeeded']:
549
574
  return
550
575
  else:
551
576
  raise ValueError(f"Failed to wait: {response.json()['error']}")
@@ -601,6 +626,7 @@ class Simplex:
601
626
  </body>
602
627
  </html>
603
628
  """
629
+ import tempfile
604
630
  # Write to a temporary file
605
631
  with tempfile.NamedTemporaryFile(delete=False, suffix='.html', mode='w') as f:
606
632
  f.write(html_content)
@@ -707,7 +733,7 @@ class Simplex:
707
733
  )
708
734
  if 'succeeded' not in response.json():
709
735
  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?")
710
- if "succeeded" in response.json():
736
+ if response.json()['succeeded']:
711
737
  return
712
738
  else:
713
739
  raise ValueError(f"Failed to restore login session: {response.json()['error']}")
@@ -751,7 +777,7 @@ class Simplex:
751
777
  )
752
778
  if 'succeeded' not in response.json():
753
779
  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?")
754
- if "succeeded" in response.json():
780
+ if response.json()['succeeded']:
755
781
  return
756
782
  else:
757
783
  raise ValueError(f"Failed to click and upload: {response.json()['error']}")
@@ -775,6 +801,7 @@ class Simplex:
775
801
  },
776
802
  data=data
777
803
  )
804
+
778
805
  # Get filename from Content-Disposition header
779
806
  content_disposition = response.headers.get('Content-Disposition')
780
807
  if content_disposition:
@@ -791,7 +818,11 @@ class Simplex:
791
818
  except Exception:
792
819
  raise ValueError("File failed to be parsed from Content-Disposition header.")
793
820
  else:
794
- raise ValueError("No Content-Disposition header found. File was not downloaded.")
821
+ try:
822
+ raise ValueError(response.json()["error"])
823
+ except:
824
+ raise ValueError("No Content-Disposition header found. File was not downloaded.")
825
+
795
826
 
796
827
  # Check if response content is empty
797
828
  if len(response.content) == 0:
@@ -822,7 +853,8 @@ class Simplex:
822
853
  if 'succeeded' not in response.json():
823
854
  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?")
824
855
  response_json = response.json()
825
- if "succeeded" in response_json:
856
+
857
+ if response_json['succeeded']:
826
858
  return response_json['exists'], response_json['reasoning']
827
859
  else:
828
860
  raise ValueError(f"Failed to check if element exists: {response_json['error']}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simplex
3
- Version: 1.2.64
3
+ Version: 1.2.69
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -18,7 +18,7 @@ Requires-Dist: requests
18
18
  Requires-Dist: python-dotenv
19
19
  Requires-Dist: click
20
20
  Provides-Extra: playwright
21
- Requires-Dist: playwright>=1.0.0; extra == "playwright"
21
+ Requires-Dist: rebrowser-playwright>=1.0.0; extra == "playwright"
22
22
 
23
23
  # Simplex AI Python SDK
24
24
 
@@ -4,4 +4,4 @@ python-dotenv
4
4
  click
5
5
 
6
6
  [playwright]
7
- playwright>=1.0.0
7
+ rebrowser-playwright>=1.0.0
File without changes
File without changes
File without changes
File without changes
File without changes