simplex 1.2.55__tar.gz → 1.2.58__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.2
2
2
  Name: simplex
3
- Version: 1.2.55
3
+ Version: 1.2.58
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -22,7 +22,7 @@ class PostInstallCommand(install):
22
22
 
23
23
  setup(
24
24
  name="simplex",
25
- version="1.2.55",
25
+ version="1.2.58",
26
26
  packages=find_packages(),
27
27
  package_data={
28
28
  "simplex": ["browser_agent/dom/*.js"], # Include JS files in the dom directory
@@ -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()["succeeded"]:
64
+ if "succeeded" in response.json():
65
65
  return
66
66
  else:
67
67
  raise ValueError(f"Failed to click element: {response.json()['error']}")
@@ -81,6 +81,7 @@ class Simplex:
81
81
  self.pw = None
82
82
 
83
83
  def close_session(self):
84
+ time.sleep(30)
84
85
  if PLAYWRIGHT_AVAILABLE and self.pw_browser:
85
86
  try:
86
87
  self.pw_browser.close()
@@ -105,12 +106,15 @@ class Simplex:
105
106
  self.session_id = None
106
107
  if 'succeeded' not in response.json():
107
108
  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()["succeeded"]:
109
+ if "succeeded" in response.json():
109
110
  return
110
111
  else:
111
112
  raise ValueError(f"Failed to close session: {response.json()['error']}")
112
113
 
113
- def create_session(self, show_in_console: Optional[bool] = True, proxies: Optional[bool] = True, session_data: Optional[dict | str] = None):
114
+ 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):
115
+ if self.session_id:
116
+ raise ValueError("A session is already active. Please close the current session before creating a new one.")
117
+
114
118
  if session_data:
115
119
  if isinstance(session_data, dict):
116
120
  session_data_dict = session_data
@@ -130,7 +134,7 @@ class Simplex:
130
134
  headers={
131
135
  'x-api-key': self.api_key
132
136
  },
133
- data={'proxies': proxies, 'session_data': json.dumps(session_data_dict)}
137
+ data={'proxies': proxies, 'session_data': json.dumps(session_data_dict), 'workflow_name': workflow_name}
134
138
  )
135
139
  else:
136
140
  response = requests.post(
@@ -138,7 +142,7 @@ class Simplex:
138
142
  headers={
139
143
  'x-api-key': self.api_key
140
144
  },
141
- data={'proxies': proxies}
145
+ data={'proxies': proxies, "workflow_name": workflow_name}
142
146
  )
143
147
  # Check for non-200 status code
144
148
  if response.status_code != 200:
@@ -155,7 +159,9 @@ class Simplex:
155
159
  self.pw = sync_playwright().start()
156
160
  self.connect_url = response_json['connect_url']
157
161
  # self.pw_browser = self.pw.chromium.connect_over_cdp(response_json['connect_url'])
158
-
162
+ if not "api.simplex.sh" in BASE_URL:
163
+ livestream_url = f"http://localhost:3000/session/{self.session_id}"
164
+
159
165
  if show_in_console:
160
166
  print(f"Livestream URL: {livestream_url}")
161
167
 
@@ -185,12 +191,14 @@ class Simplex:
185
191
  if 'succeeded' not in response.json():
186
192
  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?")
187
193
 
188
- if response.json()["succeeded"]:
194
+ if "succeeded" in response.json():
189
195
  return
190
196
  else:
191
197
  raise ValueError(f"Failed to goto url: {response.json()['error']}")
192
198
 
193
199
  def click(self, element_description: str, cdp_url: str = None):
200
+ if not element_description or not element_description.strip():
201
+ raise ValueError("element_description cannot be empty")
194
202
  if not cdp_url and not self.session_id:
195
203
  raise ValueError(f"Must call create_session before calling action click with element_description='{element_description}'")
196
204
 
@@ -210,12 +218,14 @@ class Simplex:
210
218
  )
211
219
  if 'succeeded' not in response.json():
212
220
  raise ValueError(f"It looks like the click action failed to return a response. Did you set your api_key when creating the Simplex class?")
213
- if response.json()["succeeded"]:
221
+ if "succeeded" in response.json():
214
222
  return response.json()["element_clicked"]
215
223
  else:
216
224
  raise ValueError(f"Failed to click element: {response.json()['error']}")
217
225
 
218
226
  def type(self, text: str, cdp_url: str = None):
227
+ if not text or not text.strip():
228
+ raise ValueError("text cannot be empty")
219
229
  if not cdp_url and not self.session_id:
220
230
  raise ValueError(f"Must call create_session before calling action type with text='{text}'")
221
231
 
@@ -233,11 +243,38 @@ class Simplex:
233
243
  },
234
244
  data=data
235
245
  )
236
- if response.json()["succeeded"]:
246
+ if "succeeded" in response.json():
237
247
  return
238
248
  else:
249
+ print(response.json())
239
250
  raise ValueError(f"Failed to type text: {response.json()['error']}")
251
+
252
+
253
+ def reload(self, cdp_url: str = None):
254
+ if not cdp_url and not self.session_id:
255
+ raise ValueError("Must call create_session before calling action reload")
256
+
257
+ data = {}
258
+
259
+ if cdp_url:
260
+ data['cdp_url'] = cdp_url
261
+ else:
262
+ data['session_id'] = self.session_id
240
263
 
264
+ response = requests.post(
265
+ f"{BASE_URL}/reload",
266
+ headers={
267
+ 'x-api-key': self.api_key
268
+ },
269
+ data=data
270
+ )
271
+ if 'succeeded' not in response.json():
272
+ 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?")
273
+ if "succeeded" in response.json():
274
+ return
275
+ else:
276
+ raise ValueError(f"Failed to reload: {response.json()['error']}")
277
+
241
278
  def press_enter(self, cdp_url: str = None):
242
279
  if not cdp_url and not self.session_id:
243
280
  raise ValueError("Must call create_session before calling action press_enter")
@@ -258,7 +295,7 @@ class Simplex:
258
295
  )
259
296
  if 'succeeded' not in response.json():
260
297
  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?")
261
- if response.json()["succeeded"]:
298
+ if "succeeded" in response.json():
262
299
  return
263
300
  else:
264
301
  raise ValueError(f"Failed to press enter: {response.json()['error']}")
@@ -283,7 +320,7 @@ class Simplex:
283
320
  )
284
321
  if 'succeeded' not in response.json():
285
322
  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?")
286
- if response.json()["succeeded"]:
323
+ if "succeeded" in response.json():
287
324
  return
288
325
  else:
289
326
  raise ValueError(f"Failed to press tab: {response.json()['error']}")
@@ -308,12 +345,14 @@ class Simplex:
308
345
  )
309
346
  if 'succeeded' not in response.json():
310
347
  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?")
311
- if response.json()["succeeded"]:
348
+ if "succeeded" in response.json():
312
349
  return
313
350
  else:
314
351
  raise ValueError(f"Failed to delete text: {response.json()['error']}")
315
352
 
316
353
  def extract_bbox(self, element_description: str, cdp_url: str = None):
354
+ if not element_description or not element_description.strip():
355
+ raise ValueError("element_description cannot be empty")
317
356
  if not cdp_url and not self.session_id:
318
357
  raise ValueError(f"Must call create_session before calling action extract_bbox with element_description='{element_description}'")
319
358
 
@@ -333,12 +372,14 @@ class Simplex:
333
372
  )
334
373
  if 'succeeded' not in response.json():
335
374
  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?")
336
- if response.json()["succeeded"]:
375
+ if "succeeded" in response.json():
337
376
  return response.json()["bbox"]
338
377
  else:
339
378
  raise ValueError(f"Failed to extract bbox: {response.json()['error']}")
340
379
 
341
380
  def extract_text(self, element_description: str, cdp_url: str = None):
381
+ if not element_description or not element_description.strip():
382
+ raise ValueError("element_description cannot be empty")
342
383
  if not cdp_url and not self.session_id:
343
384
  raise ValueError(f"Must call create_session before calling action extract_text with element_description='{element_description}'")
344
385
 
@@ -356,14 +397,17 @@ class Simplex:
356
397
  },
357
398
  data=data
358
399
  )
359
- if 'succeeded' not in response.json():
400
+ response_json = response.json()
401
+ if 'succeeded' not in response_json:
360
402
  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?")
361
- if response.json()["succeeded"]:
362
- return response.json()["text"]
403
+ if "succeeded" in response_json:
404
+ return response_json["text"]
363
405
  else:
364
- raise ValueError(f"Failed to extract text: {response.json()['error']}")
406
+ raise ValueError(f"Failed to extract text: {response_json['error']}")
365
407
 
366
408
  def extract_image(self, element_description: str, cdp_url: str = None):
409
+ if not element_description or not element_description.strip():
410
+ raise ValueError("element_description cannot be empty")
367
411
  if not cdp_url and not self.session_id:
368
412
  raise ValueError(f"Must call create_session before calling action extract_image with element_description='{element_description}'")
369
413
 
@@ -383,7 +427,7 @@ class Simplex:
383
427
  )
384
428
  if 'succeeded' not in response.json():
385
429
  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?")
386
- if response.json()["succeeded"]:
430
+ if "succeeded" in response.json():
387
431
  return response.json()["image"]
388
432
  else:
389
433
  raise ValueError(f"Failed to extract image: {response.json()['error']}")
@@ -408,7 +452,7 @@ class Simplex:
408
452
  )
409
453
  if 'succeeded' not in response.json():
410
454
  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?")
411
- if response.json()["succeeded"]:
455
+ if "succeeded" in response.json():
412
456
  return
413
457
  else:
414
458
  raise ValueError(f"Failed to scroll: {response.json()['error']}")
@@ -433,7 +477,7 @@ class Simplex:
433
477
  )
434
478
  if 'succeeded' not in response.json():
435
479
  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?")
436
- if response.json()["succeeded"]:
480
+ if "succeeded" in response.json():
437
481
  return
438
482
  else:
439
483
  raise ValueError(f"Failed to wait: {response.json()['error']}")
@@ -550,7 +594,7 @@ class Simplex:
550
594
  )
551
595
  if 'succeeded' not in response.json():
552
596
  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?")
553
- if response.json()["succeeded"]:
597
+ if "succeeded" in response.json():
554
598
  return
555
599
  else:
556
600
  raise ValueError(f"Failed to restore login session: {response.json()['error']}")
@@ -561,6 +605,8 @@ class Simplex:
561
605
  element_description: Description of the element to click and upload to
562
606
  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
563
607
  """
608
+ if not element_description or not element_description.strip():
609
+ raise ValueError("element_description cannot be empty")
564
610
  if not self.session_id:
565
611
  raise ValueError(f"Must call create_session before calling action click_and_upload with element_description='{element_description}'")
566
612
 
@@ -592,12 +638,14 @@ class Simplex:
592
638
  )
593
639
  if 'succeeded' not in response.json():
594
640
  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?")
595
- if response.json()["succeeded"]:
641
+ if "succeeded" in response.json():
596
642
  return
597
643
  else:
598
644
  raise ValueError(f"Failed to click and upload: {response.json()['error']}")
599
645
 
600
646
  def click_and_download(self, element_description: str):
647
+ if not element_description or not element_description.strip():
648
+ raise ValueError("element_description cannot be empty")
601
649
  if not self.session_id:
602
650
  raise ValueError(f"Must call create_session before calling action click_and_download with element_description='{element_description}'")
603
651
 
@@ -616,12 +664,14 @@ class Simplex:
616
664
  )
617
665
  if 'succeeded' not in response.json():
618
666
  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?")
619
- if response.json()["succeeded"]:
667
+ if "succeeded" in response.json():
620
668
  return response.json()["b64"], response.json()["filename"]
621
669
  else:
622
670
  raise ValueError(f"Failed to click and download: {response.json()['error']}")
623
671
 
624
672
  def exists(self, element_description: str, cdp_url: str = None):
673
+ if not element_description or not element_description.strip():
674
+ raise ValueError("element_description cannot be empty")
625
675
  if not cdp_url and not self.session_id:
626
676
  raise ValueError(f"Must call create_session before calling action exists with element_description='{element_description}'")
627
677
 
@@ -642,7 +692,7 @@ class Simplex:
642
692
  if 'succeeded' not in response.json():
643
693
  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?")
644
694
  response_json = response.json()
645
- if response_json['succeeded']:
695
+ if "succeeded" in response_json:
646
696
  return response_json['exists'], response_json['reasoning']
647
697
  else:
648
698
  raise ValueError(f"Failed to check if element exists: {response_json['error']}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: simplex
3
- Version: 1.2.55
3
+ Version: 1.2.58
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -11,5 +11,4 @@ simplex.egg-info/entry_points.txt
11
11
  simplex.egg-info/requires.txt
12
12
  simplex.egg-info/top_level.txt
13
13
  simplex/deploy/__init__.py
14
- simplex/deploy/push.py
15
- tests/test.py
14
+ simplex/deploy/push.py
@@ -1,23 +0,0 @@
1
- from simplex import Simplex
2
- import os
3
- from dotenv import load_dotenv
4
- import time
5
- from playwright.async_api import Page
6
-
7
- import asyncio
8
- import os
9
- import dotenv
10
-
11
- dotenv.load_dotenv()
12
-
13
- async def main():
14
- simplex = Simplex(os.getenv("SIMPLEX_API_KEY"))
15
-
16
- simplex.create_session()
17
- simplex.goto("https://gmail.com")
18
- simplex.type("test@gmail.com")
19
- simplex.press_enter()
20
- simplex.wait(1000000)
21
- if __name__ == "__main__":
22
- asyncio.run(main())
23
-
File without changes
File without changes
File without changes
File without changes
File without changes