plato-sdk-v2 2.8.2__py3-none-any.whl → 2.8.4__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.
plato/cli/pm.py CHANGED
@@ -43,6 +43,8 @@ from plato.cli.utils import (
43
43
  from plato.v1.flow_executor import FlowExecutor
44
44
  from plato.v1.models.flow import Flow
45
45
  from plato.v1.sdk import Plato
46
+ from plato.v2.async_.client import AsyncPlato
47
+ from plato.v2.types import Env
46
48
 
47
49
  # =============================================================================
48
50
  # CONSTANTS
@@ -724,18 +726,25 @@ def review_data(
724
726
  help="Artifact UUID to review. If not provided, uses server's data_artifact_id.",
725
727
  ),
726
728
  ):
727
- """Launch browser with EnvGen Recorder extension for data review.
729
+ """
730
+ Launch browser with Data Review extension for data review.
728
731
 
729
- Opens Chrome with the EnvGen Recorder extension installed for reviewing
730
- data artifacts. The extension sidebar can be used to record and submit reviews.
731
- Press Control-C to exit when done.
732
+ Opens Chrome with the Data Review extension installed for reviewing
733
+ data artifacts. Close the browser when done.
732
734
 
733
- Requires simulator status: data_review_requested
735
+ SPECIFYING SIMULATOR AND ARTIFACT:
734
736
 
735
- Options:
736
- -s, --simulator: Simulator name. Supports colon notation for artifact:
737
- '-s sim' (uses server's data_artifact_id) or '-s sim:<uuid>'
738
- -a, --artifact: Explicit artifact UUID to review. Overrides server's value.
737
+ -s <simulator> Use server's data_artifact_id
738
+ -s <simulator> -a <artifact-uuid> Explicit artifact
739
+ -s <simulator>:<artifact-uuid> Colon notation (same as above)
740
+
741
+ EXAMPLES:
742
+
743
+ plato pm review data -s fathom
744
+ plato pm review data -s fathom -a e9c25ca5-1234-5678-9abc-def012345678
745
+ plato pm review data -s fathom:e9c25ca5-1234-5678-9abc-def012345678
746
+
747
+ Requires simulator status: data_review_requested
739
748
  """
740
749
  api_key = require_api_key()
741
750
 
@@ -744,8 +753,6 @@ def review_data(
744
753
  simulator, artifact, require_artifact=False, command_name="review data"
745
754
  )
746
755
 
747
- # Determine target URL based on simulator
748
- target_url = f"https://{simulator_name}.web.plato.so"
749
756
  console.print(f"[cyan]Simulator:[/cyan] {simulator_name}")
750
757
 
751
758
  # Fetch simulator config and get artifact ID if not provided
@@ -790,45 +797,75 @@ def review_data(
790
797
  console.print(f"[cyan]Artifact:[/cyan] {artifact_id}")
791
798
 
792
799
  # Find Chrome extension source
793
- package_dir = Path(__file__).resolve().parent.parent # v1/
800
+ package_dir = Path(__file__).resolve().parent.parent # plato/
794
801
  is_installed = "site-packages" in str(package_dir)
795
802
 
796
803
  if is_installed:
797
- extension_source_path = package_dir / "extensions" / "envgen-recorder-old"
804
+ extension_source_path = package_dir / "extensions" / "data-review"
798
805
  else:
799
- repo_root = package_dir.parent.parent.parent # plato-client/
800
- extension_source_path = repo_root / "extensions" / "envgen-recorder-old"
806
+ repo_root = package_dir.parent.parent # plato-client/
807
+ extension_source_path = repo_root / "extensions" / "data-review"
801
808
 
802
809
  # Fallback to env var
803
810
  if not extension_source_path.exists():
804
811
  plato_client_dir_env = os.getenv("PLATO_CLIENT_DIR")
805
812
  if plato_client_dir_env:
806
- env_path = Path(plato_client_dir_env) / "extensions" / "envgen-recorder-old"
813
+ env_path = Path(plato_client_dir_env) / "extensions" / "data-review"
807
814
  if env_path.exists():
808
815
  extension_source_path = env_path
809
816
 
810
817
  if not extension_source_path.exists():
811
- console.print("[red]❌ EnvGen Recorder extension not found[/red]")
818
+ console.print("[red]❌ Data Review extension not found[/red]")
812
819
  console.print(f"\n[yellow]Expected location:[/yellow] {extension_source_path}")
813
820
  raise typer.Exit(1)
814
821
 
815
822
  # Copy extension to temp directory
816
823
  temp_ext_dir = Path(tempfile.mkdtemp(prefix="plato-extension-"))
817
- extension_path = temp_ext_dir / "envgen-recorder"
824
+ extension_path = temp_ext_dir / "data-review"
818
825
 
819
826
  console.print("[cyan]Copying extension to temp directory...[/cyan]")
820
827
  shutil.copytree(extension_source_path, extension_path, dirs_exist_ok=False)
821
828
  console.print(f"[green]✅ Extension copied to: {extension_path}[/green]")
822
829
 
823
830
  async def _review_data():
831
+ base_url = _get_base_url()
832
+ plato = AsyncPlato(api_key=api_key, base_url=base_url)
833
+ session = None
824
834
  playwright = None
825
835
  browser = None
826
836
 
827
837
  try:
838
+ # Check if we have an artifact ID to create a session
839
+ if not artifact_id:
840
+ console.print("[red]❌ No artifact ID available. Cannot create session.[/red]")
841
+ console.print("[yellow]Specify artifact with: plato pm review data -s simulator:artifact_id[/yellow]")
842
+ raise typer.Exit(1)
843
+
844
+ # Create session with artifact
845
+ console.print(f"[cyan]Creating {simulator_name} environment with artifact {artifact_id}...[/cyan]")
846
+ session = await plato.sessions.create(
847
+ envs=[Env.artifact(artifact_id)],
848
+ timeout=300,
849
+ )
850
+ console.print(f"[green]✅ Session created: {session.session_id}[/green]")
851
+
852
+ # Reset environment
853
+ console.print("[cyan]Resetting environment...[/cyan]")
854
+ await session.reset()
855
+ console.print("[green]✅ Environment reset complete![/green]")
856
+
857
+ # Get public URL
858
+ public_urls = await session.get_public_url()
859
+ first_alias = session.envs[0].alias if session.envs else None
860
+ public_url = public_urls.get(first_alias) if first_alias else None
861
+ if not public_url and public_urls:
862
+ public_url = list(public_urls.values())[0]
863
+ console.print(f"[cyan]Public URL:[/cyan] {public_url}")
864
+
828
865
  user_data_dir = Path.home() / ".plato" / "chrome-data"
829
866
  user_data_dir.mkdir(parents=True, exist_ok=True)
830
867
 
831
- console.print("[cyan]Launching Chrome with EnvGen Recorder extension...[/cyan]")
868
+ console.print("[cyan]Launching Chrome with Data Review extension...[/cyan]")
832
869
 
833
870
  from playwright.async_api import async_playwright
834
871
 
@@ -869,13 +906,14 @@ def review_data(
869
906
  else:
870
907
  console.print("[yellow]⚠️ Could not find extension ID. Please set API key manually.[/yellow]")
871
908
 
872
- # Step 1: Navigate to target URL first
873
- console.print(f"[cyan]Navigating to {target_url}...[/cyan]")
909
+ # Navigate to public URL (user logs in manually with displayed credentials)
910
+ console.print("[cyan]Opening environment...[/cyan]")
874
911
  main_page = await browser.new_page()
875
- await main_page.goto(target_url, wait_until="domcontentloaded")
876
- console.print(f"[green]✅ Loaded: {target_url}[/green]")
912
+ if public_url:
913
+ await main_page.goto(public_url)
914
+ console.print(f"[green]✅ Loaded: {public_url}[/green]")
877
915
 
878
- # Step 2: Use options page to set API key
916
+ # Use options page to set API key
879
917
  if extension_id:
880
918
  options_page = await browser.new_page()
881
919
  try:
@@ -899,17 +937,16 @@ def review_data(
899
937
  await options_page.close()
900
938
 
901
939
  # Bring main page to front
902
- await main_page.bring_to_front()
940
+ if main_page:
941
+ await main_page.bring_to_front()
903
942
 
904
943
  console.print()
905
944
  console.print("[bold]Instructions:[/bold]")
906
- console.print(" 1. Click the EnvGen Recorder extension icon to open the sidebar")
907
- if simulator:
908
- console.print(f" 2. Click 'Configure Session' and enter '{simulator}' as the simulator name")
909
- else:
910
- console.print(" 2. Click 'Configure Session' and enter a simulator name")
911
- console.print(" 3. Use the extension to record and submit reviews")
912
- console.print(" 4. When done, press Control-C to exit")
945
+ console.print(" 1. Click the Data Review extension icon to open the sidebar")
946
+ console.print(f" 2. Enter '{simulator_name}' as the simulator name and click Start Review")
947
+ console.print(" 3. Take screenshots and add comments for any issues")
948
+ console.print(" 4. Select Pass or Reject and submit the review")
949
+ console.print(" 5. When done, press Control-C to exit")
913
950
 
914
951
  # Show recent review if available
915
952
  if recent_review:
@@ -922,10 +959,20 @@ def review_data(
922
959
  else:
923
960
  console.print(f"[bold green]📋 Most Recent Data Review: PASSED[/bold green] ({timestamp})")
924
961
 
925
- comments = recent_review.get("comments")
926
- if comments:
962
+ # Handle both old 'comments' field and new 'sim_comments' structure
963
+ sim_comments = recent_review.get("sim_comments")
964
+ if sim_comments:
927
965
  console.print("\n[yellow]Reviewer Comments:[/yellow]")
928
- console.print(f" {comments}")
966
+ for i, item in enumerate(sim_comments, 1):
967
+ comment_text = item.get("comment", "")
968
+ if comment_text:
969
+ console.print(f" {i}. {comment_text}")
970
+ else:
971
+ # Fallback to old comments field
972
+ comments = recent_review.get("comments")
973
+ if comments:
974
+ console.print("\n[yellow]Reviewer Comments:[/yellow]")
975
+ console.print(f" {comments}")
929
976
  console.print("=" * 60)
930
977
 
931
978
  console.print()
@@ -946,6 +993,8 @@ def review_data(
946
993
 
947
994
  finally:
948
995
  try:
996
+ if session:
997
+ await session.close()
949
998
  if browser:
950
999
  await browser.close()
951
1000
  if playwright:
@@ -953,7 +1002,7 @@ def review_data(
953
1002
  if temp_ext_dir.exists():
954
1003
  shutil.rmtree(temp_ext_dir, ignore_errors=True)
955
1004
  except Exception as e:
956
- console.print(f"[yellow]⚠️ Browser cleanup error: {e}[/yellow]")
1005
+ console.print(f"[yellow]⚠️ Cleanup error: {e}[/yellow]")
957
1006
 
958
1007
  handle_async(_review_data())
959
1008
 
plato/cli/sandbox.py CHANGED
@@ -260,7 +260,8 @@ class Output:
260
260
  """Output a successful result."""
261
261
  data = _to_dict(result)
262
262
  if self.json_mode:
263
- self.super_console.print(json.dumps(data, indent=2, default=str))
263
+ # Use print() directly to avoid Rich adding ANSI codes
264
+ print(json.dumps(data, indent=2, default=str))
264
265
  else:
265
266
  if title:
266
267
  self.super_console.print(f"[green]{title}[/green]")
@@ -276,7 +277,8 @@ class Output:
276
277
  def error(self, msg: str) -> None:
277
278
  """Output an error."""
278
279
  if self.json_mode:
279
- self.super_console.print(json.dumps({"error": msg}))
280
+ # Use print() directly to avoid Rich adding ANSI codes
281
+ print(json.dumps({"error": msg}))
280
282
  else:
281
283
  self.super_console.print(f"[red]{msg}[/red]")
282
284
 
plato/v2/sync/sandbox.py CHANGED
@@ -841,6 +841,8 @@ class SandboxClient:
841
841
  )
842
842
 
843
843
  if wait_timeout > 0:
844
+ # Wait before first state poll to allow worker to initialize
845
+ time.sleep(15)
844
846
  start_time = time.time()
845
847
  poll_interval = 10
846
848
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plato-sdk-v2
3
- Version: 2.8.2
3
+ Version: 2.8.4
4
4
  Summary: Python SDK for the Plato API
5
5
  Author-email: Plato <support@plato.so>
6
6
  License-Expression: MIT
@@ -419,9 +419,9 @@ plato/cli/agent.py,sha256=5qA0T1n0H0JQ5ZB-fAVKm3Nw-y_M-GiSQx1OTcKgkrI,44050
419
419
  plato/cli/audit_ui.py,sha256=AfnC3wngGV3ujg9POHNYQhal2S6Hr0ZhcXrAAxtVfMg,12307
420
420
  plato/cli/chronos.py,sha256=OTS-xcmH0U99sMHrABqtJMOdOEhHil5hv_yO3YNgrS8,27824
421
421
  plato/cli/main.py,sha256=f-L_Q6MWA8ylGrOcEsJU5HRK1JaDUeh6ONWSaKwag10,6800
422
- plato/cli/pm.py,sha256=9j0S2ATPGS3GGbl0530YaQJSVN4dnGaDXVt-j42mJ7A,52589
422
+ plato/cli/pm.py,sha256=y74kMFm0RdnPrcf3TPb5ES-D0SgZiO41nagheS1xtlQ,54775
423
423
  plato/cli/proxy.py,sha256=c1t1ljZvArTnFba-NprCj2tma4XneEqRDQCbwzQ9GD4,6803
424
- plato/cli/sandbox.py,sha256=sTPsbDEZywvYFMOGOCphDd2nZvDj21xA8MgmfBTjX88,26731
424
+ plato/cli/sandbox.py,sha256=VwXPETWOGa0urYIsHGUKQyRd8hABPVaEUYrxsdGWti8,26827
425
425
  plato/cli/utils.py,sha256=PIZnJYuhojbARoRA2Tk3KfB5Tycg1uwlPLhut5Es0ew,6900
426
426
  plato/cli/verify.py,sha256=fGmKAh9SB2s7Q67oI9q26_gYxZh4JzGMCS4PyfMqb-g,22930
427
427
  plato/cli/world.py,sha256=bH-ReNhGdjcba5rXijLfhAKFwsk3GzlQQEtXUFWOZbw,8822
@@ -513,7 +513,7 @@ plato/v2/sync/chronos.py,sha256=ChXpasjRzAZjoYTimpPqYydnwEk-IgdxR0SDXDOZbUM,1207
513
513
  plato/v2/sync/client.py,sha256=rsrU7_RhE-syf3FMNw5LaxmF7rYw2GBzC_TPpd-6thk,4986
514
514
  plato/v2/sync/environment.py,sha256=WnDzbyEHpwCSEP8XnfNSjIYS7rt7lYR4HGJjzprZmTQ,5066
515
515
  plato/v2/sync/flow_executor.py,sha256=N41-WCWIJVcCR2UmPUEiK7roNacYoeONkRXpR7lUgT8,13941
516
- plato/v2/sync/sandbox.py,sha256=jDvlCFtmX5Pz3bi-PiHycfdjUY0ninfx2xz436NUP0o,54901
516
+ plato/v2/sync/sandbox.py,sha256=OJpXtdSNDeYBb8JOPHfW5_8Lzaw7BHZ1oT-Ub2noP8s,55001
517
517
  plato/v2/sync/session.py,sha256=FYVxgGZ3eL_YpoJiUgJamrt-jVaBqJITzFzepOKMRjA,35065
518
518
  plato/v2/utils/__init__.py,sha256=XLeFFsjXkm9g2raMmo7Wt4QN4hhCrNZDJKnpffJ4LtM,38
519
519
  plato/v2/utils/db_cleanup.py,sha256=JMzAAJz0ZnoUXtd8F4jpQmBpJpos2__RkgN_cuEearg,8692
@@ -526,7 +526,7 @@ plato/worlds/base.py,sha256=-RR71bSxEFI5yydtrtq-AAbuw98CIjvmrbztqzB9oIc,31041
526
526
  plato/worlds/build_hook.py,sha256=KSoW0kqa5b7NyZ7MYOw2qsZ_2FkWuz0M3Ru7AKOP7Qw,3486
527
527
  plato/worlds/config.py,sha256=O1lUXzxp-Z_M7izslT8naXgE6XujjzwYFFrDDzUOueI,12736
528
528
  plato/worlds/runner.py,sha256=r9B2BxBae8_dM7y5cJf9xhThp_I1Qvf_tlPq2rs8qC8,4013
529
- plato_sdk_v2-2.8.2.dist-info/METADATA,sha256=ARvX_fQyqW0AhorrZ2H9MTLTdayuVeIj5loPTiaqtMo,8652
530
- plato_sdk_v2-2.8.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
531
- plato_sdk_v2-2.8.2.dist-info/entry_points.txt,sha256=iynJvTkU7E4MZNtSozVF0Wh083yPm6cuKV362Ol_ez8,133
532
- plato_sdk_v2-2.8.2.dist-info/RECORD,,
529
+ plato_sdk_v2-2.8.4.dist-info/METADATA,sha256=sLLcAPK7s-jHZqdMIG2lwIvO1m6CFtqW7bVY_VfLmrc,8652
530
+ plato_sdk_v2-2.8.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
531
+ plato_sdk_v2-2.8.4.dist-info/entry_points.txt,sha256=iynJvTkU7E4MZNtSozVF0Wh083yPm6cuKV362Ol_ez8,133
532
+ plato_sdk_v2-2.8.4.dist-info/RECORD,,