plato-sdk-v2 2.8.7__py3-none-any.whl → 2.9.0__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/worlds/schema.py ADDED
@@ -0,0 +1,154 @@
1
+ """JSON schema generation for Plato world configurations."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any
6
+
7
+ from plato.worlds.markers import Agent, Env, EnvList, Secret
8
+
9
+ if TYPE_CHECKING:
10
+ from plato.worlds.config import RunConfig
11
+
12
+
13
+ def get_field_annotations(config_cls: type[RunConfig]) -> dict[str, Agent | Secret | Env | EnvList | None]:
14
+ """Get Agent/Secret/Env/EnvList annotations for each field.
15
+
16
+ Args:
17
+ config_cls: The RunConfig subclass to inspect
18
+
19
+ Returns:
20
+ Dict mapping field name to annotation marker (or None if no marker)
21
+ """
22
+ result: dict[str, Agent | Secret | Env | EnvList | None] = {}
23
+
24
+ for field_name, field_info in config_cls.model_fields.items():
25
+ marker = None
26
+
27
+ for meta in field_info.metadata:
28
+ if isinstance(meta, (Agent, Secret, Env, EnvList)):
29
+ marker = meta
30
+ break
31
+
32
+ result[field_name] = marker
33
+
34
+ return result
35
+
36
+
37
+ def get_world_config_schema(config_cls: type[RunConfig]) -> dict[str, Any]:
38
+ """Get JSON schema for a world config with agents, secrets, and envs separated.
39
+
40
+ Args:
41
+ config_cls: The RunConfig subclass to generate schema for
42
+
43
+ Returns:
44
+ JSON schema dict with properties, required, agents, secrets, and envs fields
45
+ """
46
+ full_schema = config_cls.model_json_schema()
47
+ full_schema.pop("title", None)
48
+
49
+ annotations = get_field_annotations(config_cls)
50
+ properties = full_schema.get("properties", {})
51
+
52
+ world_properties: dict[str, Any] = {}
53
+ agents: list[dict[str, Any]] = []
54
+ secrets: list[dict[str, Any]] = []
55
+ envs: list[dict[str, Any]] = []
56
+ env_list_field: dict[str, Any] | None = None
57
+
58
+ # Skip runtime fields
59
+ runtime_fields = {"session_id", "otel_url", "upload_url", "plato_session", "checkpoint", "state"}
60
+
61
+ for field_name, prop_schema in properties.items():
62
+ if field_name in runtime_fields:
63
+ continue
64
+
65
+ marker = annotations.get(field_name)
66
+
67
+ if isinstance(marker, Agent):
68
+ agents.append(
69
+ {
70
+ "name": field_name,
71
+ "description": marker.description,
72
+ "required": marker.required,
73
+ }
74
+ )
75
+ elif isinstance(marker, Secret):
76
+ secrets.append(
77
+ {
78
+ "name": field_name,
79
+ "description": marker.description,
80
+ "required": marker.required,
81
+ }
82
+ )
83
+ elif isinstance(marker, Env):
84
+ # Get default value for this env field
85
+ field_info = config_cls.model_fields.get(field_name)
86
+ default_value = None
87
+ if field_info and field_info.default is not None:
88
+ default_env = field_info.default
89
+ if hasattr(default_env, "model_dump"):
90
+ default_value = default_env.model_dump()
91
+ elif isinstance(default_env, dict):
92
+ default_value = default_env
93
+
94
+ envs.append(
95
+ {
96
+ "name": field_name,
97
+ "description": marker.description,
98
+ "required": marker.required,
99
+ "default": default_value,
100
+ }
101
+ )
102
+ elif isinstance(marker, EnvList):
103
+ env_list_field = {
104
+ "name": field_name,
105
+ "description": marker.description,
106
+ }
107
+ else:
108
+ world_properties[field_name] = prop_schema
109
+
110
+ # Compute required fields (excluding runtime and annotated fields)
111
+ required = [r for r in full_schema.get("required", []) if r not in runtime_fields and annotations.get(r) is None]
112
+
113
+ result: dict[str, Any] = {
114
+ "properties": world_properties,
115
+ "required": required,
116
+ "agents": agents,
117
+ "secrets": secrets,
118
+ "envs": envs,
119
+ }
120
+
121
+ # Include $defs if present (for nested type references)
122
+ if "$defs" in full_schema:
123
+ result["$defs"] = full_schema["$defs"]
124
+
125
+ # Add env_list if present (for worlds with arbitrary environment lists)
126
+ if env_list_field:
127
+ result["env_list"] = env_list_field
128
+
129
+ return result
130
+
131
+
132
+ def get_world_schema(world_cls: type) -> dict[str, Any]:
133
+ """Get full schema for a world including config, agents, secrets, and envs.
134
+
135
+ Args:
136
+ world_cls: The BaseWorld subclass to generate schema for
137
+
138
+ Returns:
139
+ JSON schema dict with all schema sections
140
+ """
141
+ config_class = world_cls.get_config_class()
142
+ schema = get_world_config_schema(config_class)
143
+
144
+ return {
145
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
146
+ "type": "object",
147
+ "properties": schema.get("properties", {}),
148
+ "required": schema.get("required", []),
149
+ "agents": schema.get("agents", []),
150
+ "secrets": schema.get("secrets", []),
151
+ "envs": schema.get("envs", []),
152
+ "$defs": schema.get("$defs"),
153
+ "env_list": schema.get("env_list"),
154
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plato-sdk-v2
3
- Version: 2.8.7
3
+ Version: 2.9.0
4
4
  Summary: Python SDK for the Plato API
5
5
  Author-email: Plato <support@plato.so>
6
6
  License-Expression: MIT
@@ -315,7 +315,7 @@ plato/_generated/api/v2/work_orders/get_work_order.py,sha256=dOOTdoS_tJSoLKYlvUb
315
315
  plato/_generated/api/v2/work_orders/list_work_orders.py,sha256=buAOqkAbCma9aODSEKRt0es36oVDdv_Y4jb-EkkC668,2026
316
316
  plato/_generated/api/version/__init__.py,sha256=dQXTYrXjD1RZcvWwnlqXWAZ-eAV-V-6JSNuY7uaca7o,70
317
317
  plato/_generated/api/version/check.py,sha256=HTVNw0oi9gbvX4pOVoH4y4JywCxdl1pJTCk2PjJFwJ4,778
318
- plato/_generated/models/__init__.py,sha256=i3yWG9SyRdj_mhBUIp1_BuDpmwA9aFIKbYQGCdsV070,172881
318
+ plato/_generated/models/__init__.py,sha256=goJEywXdEra3Su3zZ2qknqMomKvQM88zNLU-MbdgwNE,173217
319
319
  plato/_sims_generator/__init__.py,sha256=Km4QOl9wxjQ5dgpdhk9QnBFJFFc9eq3rPbMWIQRjIn0,1602
320
320
  plato/_sims_generator/cli.py,sha256=mzolN-dxfMkVAdA-vC0esnai-cGg-i4ozOw8dACefV4,2709
321
321
  plato/_sims_generator/instruction.py,sha256=Na9M-jIdBPhp_fLuBPTicoFnWriRyi8YiZ-eQBj64HI,6644
@@ -332,11 +332,13 @@ plato/_sims_generator/templates/python/tag_init.py.jinja,sha256=WB_9cv0JKIVg5TOX
332
332
  plato/_sims_generator/templates/python/version_init.py.jinja,sha256=sGvFcYVfzXFyQDAe0PSOrg9yys93KE0XInFQNb1TvCY,179
333
333
  plato/agents/__init__.py,sha256=Cxc-HUMwRGQ4D1hHnFo9vt2AV5upPRYP4e3y8X6Hzr0,3052
334
334
  plato/agents/artifacts.py,sha256=ljeI0wzsp7Q6uKqMb-k7kTb680Vizs54ohtM-d7zvOg,2929
335
- plato/agents/base.py,sha256=vUbPQuNSo6Ka2lIB_ZOXgi4EoAjtAD7GIj9LnNotam0,4577
335
+ plato/agents/base.py,sha256=5vRIENOr4hzDSMgcKJFggbIdf9pS0OXLb1KAIjUmFJM,4423
336
336
  plato/agents/build.py,sha256=CNMbVQFs2_pYit1dA29Davve28Yi4c7TNK9wBB7odrE,1621
337
- plato/agents/config.py,sha256=GWXEAbruNVI2q3XIWpQ9vGLK2wGhsFPYA-oekmAlrg8,5392
338
- plato/agents/otel.py,sha256=A2LkkjBtjSe0eztr9UvYvSUOwfmShCgPg3OUN8nOyIo,9159
337
+ plato/agents/config.py,sha256=1OcidjteU-kPUZhFnYwscsboEBliC8LcpxpkFKumCuI,3608
338
+ plato/agents/markers.py,sha256=fZSke6Btm2IFsTFhRQMrRcr6W2c594FwD3n45vb6JRQ,559
339
+ plato/agents/otel.py,sha256=_aEKZbLard8jdUAIZDS46LSutdcT8J7vY-FrN8c4SUE,7247
339
340
  plato/agents/runner.py,sha256=Y-e5fCfPJpG1Wo1ICLco8kHzm7u-kbzwgbvLH3XBN-w,7969
341
+ plato/agents/schema.py,sha256=FuBfDu0mrSXgyI3-egFOvCQmRk6VsWUCN1YZ9t8vYbI,2747
340
342
  plato/agents/trajectory.py,sha256=WdiBmua0KvCrNaM3qgPI7-7B4xmSkfbP4oZ_9_8qHzU,10529
341
343
  plato/chronos/__init__.py,sha256=RHMvSrQS_-vkKOyTRuAkp2gKDP1HEuBLDnw8jcZs1Jg,739
342
344
  plato/chronos/client.py,sha256=YcOGtHWERyOD9z8LKt8bRMVL0cEwL2hiAP4qQgdZlUI,5495
@@ -430,11 +432,13 @@ plato/chronos/models/__init__.py,sha256=M2dV42UmYgsNC4M76jOO4vILgzNvM6m3BGpf6Mcf
430
432
  plato/cli/__init__.py,sha256=UsKj-69eWKuAlk-Fiwlrz0GJiBfuOmcf-ZLmZJb21Vo,102
431
433
  plato/cli/agent.py,sha256=5qA0T1n0H0JQ5ZB-fAVKm3Nw-y_M-GiSQx1OTcKgkrI,44050
432
434
  plato/cli/audit_ui.py,sha256=AfnC3wngGV3ujg9POHNYQhal2S6Hr0ZhcXrAAxtVfMg,12307
433
- plato/cli/chronos.py,sha256=OTS-xcmH0U99sMHrABqtJMOdOEhHil5hv_yO3YNgrS8,27824
434
- plato/cli/main.py,sha256=f-L_Q6MWA8ylGrOcEsJU5HRK1JaDUeh6ONWSaKwag10,6800
435
+ plato/cli/chronos.py,sha256=6QkHVdZxLyevbLJm43HFPJDCpkzFPRFikVhJ_fZR5D4,27863
436
+ plato/cli/compose.py,sha256=MIUBFbYeRO8TyUadUSnhgtWsh1M3LQHF-WLEbmFxIW0,51802
437
+ plato/cli/main.py,sha256=euLI0aw42SG2KIAX1xzMZ2A1LYWNOYayZ2ZCZo10ws4,6984
435
438
  plato/cli/pm.py,sha256=eex5K2JucJWzlK81tyBfJrntwZiX_QrmgeKQluv0XKc,54829
436
439
  plato/cli/proxy.py,sha256=c1t1ljZvArTnFba-NprCj2tma4XneEqRDQCbwzQ9GD4,6803
437
- plato/cli/sandbox.py,sha256=VwXPETWOGa0urYIsHGUKQyRd8hABPVaEUYrxsdGWti8,26827
440
+ plato/cli/sandbox.py,sha256=mHRMCcUcdwPFJF7u2VGwuk118so9dlV_gHxKY8-pGWM,28768
441
+ plato/cli/session.py,sha256=sRziUcPo1sitOqJ2erhD5H21mBNwquCbDnaQ2O9JoJw,14909
438
442
  plato/cli/utils.py,sha256=PIZnJYuhojbARoRA2Tk3KfB5Tycg1uwlPLhut5Es0ew,6900
439
443
  plato/cli/verify.py,sha256=fGmKAh9SB2s7Q67oI9q26_gYxZh4JzGMCS4PyfMqb-g,22930
440
444
  plato/cli/world.py,sha256=bH-ReNhGdjcba5rXijLfhAKFwsk3GzlQQEtXUFWOZbw,8822
@@ -512,34 +516,37 @@ plato/v1/models/task.py,sha256=QXwdFpDM_NLjRpQSK6duibXJXFAPZ8-PpyuLWZC5o4I,4897
512
516
  plato/v1/utils/proxytunnel.py,sha256=N1MshFY3Pu3d19cTU619-e-gP2_j-89CEcld7lCoiGk,5706
513
517
  plato/v2/__init__.py,sha256=dr15BezwgPcMntwGvLlz5CE0tyd-_tRLVuCcjmDjUmE,2069
514
518
  plato/v2/models.py,sha256=2oeGv_AEmD9YrFod0L5i1B1iarn84ix_yEt-Xpmxt_Q,3404
515
- plato/v2/types.py,sha256=MrHiE8AobOegeTfoKKHZ5JTccaFfS3-EW0arV7q8S5c,3533
519
+ plato/v2/types.py,sha256=-JOIEAOwut9SEIS_rwWLmL8X5j_vhP-PS11zFZJ5e6E,5124
516
520
  plato/v2/async_/__init__.py,sha256=rq9olvr4PuI6sY535IsLT4kg9YX_sGYrrY6SA991xk8,654
517
521
  plato/v2/async_/artifact.py,sha256=JBWVQeVaZhkU2qn_knyzyA7wd5iQ8qxfLQ_l9GPhgYs,1217
518
522
  plato/v2/async_/chronos.py,sha256=WeqYF3HIKs7hV9LNZb2GlDS1yP6b422DZKtNuPxdL34,12394
519
523
  plato/v2/async_/client.py,sha256=IhiEiwbLNPBr9JJilw4uz7MLKXY_rUZpYGYC1dX-UfA,5186
520
- plato/v2/async_/environment.py,sha256=M5IeWYLwREOIyuS2zqgBSqHE_x66_OZXrevA9Rkc8Is,5825
524
+ plato/v2/async_/environment.py,sha256=a-3pR9LD-t7vGA6q6P59_3s61VVX36ecGL1uP9aNaXw,25196
521
525
  plato/v2/async_/flow_executor.py,sha256=Tl4nRu1ZPWJFNNxyTGy-PxvebZEUD18ZDaz8T2chtzU,14188
522
- plato/v2/async_/session.py,sha256=31sJeQNKlUL2g0GRsJAG1OmoQp5LJxwfCECuUBh87CQ,43459
526
+ plato/v2/async_/session.py,sha256=Ba68kn4R8d8y-AzUvTg_98-xlWKPN-Zw4F8mp9gelEs,45192
523
527
  plato/v2/sync/__init__.py,sha256=3WXLqem7GbicVevLD1lCarr7YI1m6j7-AmJf9OVKKgc,521
524
528
  plato/v2/sync/artifact.py,sha256=wTLC-tugG128wLvh-JqNPb0zsw5FXEJlZNahurSWink,1169
525
529
  plato/v2/sync/chronos.py,sha256=ChXpasjRzAZjoYTimpPqYydnwEk-IgdxR0SDXDOZbUM,12078
526
530
  plato/v2/sync/client.py,sha256=rsrU7_RhE-syf3FMNw5LaxmF7rYw2GBzC_TPpd-6thk,4986
527
- plato/v2/sync/environment.py,sha256=WnDzbyEHpwCSEP8XnfNSjIYS7rt7lYR4HGJjzprZmTQ,5066
531
+ plato/v2/sync/environment.py,sha256=t50KSp_mQ7AwPNc-pm_L3vC_zBKdt9-zQjEq2l-_bAM,5279
528
532
  plato/v2/sync/flow_executor.py,sha256=N41-WCWIJVcCR2UmPUEiK7roNacYoeONkRXpR7lUgT8,13941
529
- plato/v2/sync/sandbox.py,sha256=fq5xUkqUwsSEoWUp243qsw9JboiGM-duHzycsWZmeX0,55599
530
- plato/v2/sync/session.py,sha256=FYVxgGZ3eL_YpoJiUgJamrt-jVaBqJITzFzepOKMRjA,35065
533
+ plato/v2/sync/sandbox.py,sha256=ywtFXHSXRen5recCe49viNFofPk_wTr_eZUxN16PGM0,62925
534
+ plato/v2/sync/session.py,sha256=Be3k0bCKIvyXLLlgjdmUGbEEPOiU1O3nguJ6fXXB5uY,35554
531
535
  plato/v2/utils/__init__.py,sha256=XLeFFsjXkm9g2raMmo7Wt4QN4hhCrNZDJKnpffJ4LtM,38
532
536
  plato/v2/utils/db_cleanup.py,sha256=JMzAAJz0ZnoUXtd8F4jpQmBpJpos2__RkgN_cuEearg,8692
533
537
  plato/v2/utils/gateway_tunnel.py,sha256=eWgwf4VV8-jx6iCuHFgCISsAOVmNOOjCB56EuZLsnOA,7171
534
538
  plato/v2/utils/models.py,sha256=PwehSSnIRG-tM3tWL1PzZEH77ZHhIAZ9R0UPs6YknbM,1441
535
539
  plato/v2/utils/proxy_tunnel.py,sha256=8ZTd0jCGSfIHMvSv1fgEyacuISWnGPHLPbDglWroTzY,10463
536
540
  plato/worlds/README.md,sha256=XFOkEA3cNNcrWkk-Cxnsl-zn-y0kvUENKQRSqFKpdqw,5479
537
- plato/worlds/__init__.py,sha256=nwuEerEkP2TSfadPiOMcUE3p6u1vhaS7ZxfTh2zNcF8,2217
538
- plato/worlds/base.py,sha256=-RR71bSxEFI5yydtrtq-AAbuw98CIjvmrbztqzB9oIc,31041
541
+ plato/worlds/__init__.py,sha256=1n23AAev3RZrKHpeSXoCnCVJ5TRtP88jVvagLMxISgg,2256
542
+ plato/worlds/base.py,sha256=pjriEuu-_PcpgBqc0tQmMQnsa08oZrCP83lC586liKo,28237
539
543
  plato/worlds/build_hook.py,sha256=KSoW0kqa5b7NyZ7MYOw2qsZ_2FkWuz0M3Ru7AKOP7Qw,3486
540
- plato/worlds/config.py,sha256=O1lUXzxp-Z_M7izslT8naXgE6XujjzwYFFrDDzUOueI,12736
544
+ plato/worlds/config.py,sha256=pmeOxVHLwL-DI5zzU04Pa5wng66LX2suCxd4ey9lAfU,7486
545
+ plato/worlds/markers.py,sha256=dB4jOVYHWFm82LqskjQ4igrFp89H2FSgv8nfBXMf550,1762
546
+ plato/worlds/models.py,sha256=dN_Lsmy4yBuyd5D17kbL4Qy9VKc-06Ea1ombXC3b-Gk,477
541
547
  plato/worlds/runner.py,sha256=r9B2BxBae8_dM7y5cJf9xhThp_I1Qvf_tlPq2rs8qC8,4013
542
- plato_sdk_v2-2.8.7.dist-info/METADATA,sha256=J0tjvkPDfLEYTJ9DTF-_AQd0BzQbt1_oHXoqskPQoF0,8652
543
- plato_sdk_v2-2.8.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
544
- plato_sdk_v2-2.8.7.dist-info/entry_points.txt,sha256=iynJvTkU7E4MZNtSozVF0Wh083yPm6cuKV362Ol_ez8,133
545
- plato_sdk_v2-2.8.7.dist-info/RECORD,,
548
+ plato/worlds/schema.py,sha256=Wn_nwvOyVYWZAVQwzMtHMxnyBWcGT4X55sbiTruwQZs,5035
549
+ plato_sdk_v2-2.9.0.dist-info/METADATA,sha256=qEB_ulz6ty1s5dEKYvSop_O0aKG2hlRCLm3aX-ZEPo4,8652
550
+ plato_sdk_v2-2.9.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
551
+ plato_sdk_v2-2.9.0.dist-info/entry_points.txt,sha256=iynJvTkU7E4MZNtSozVF0Wh083yPm6cuKV362Ol_ez8,133
552
+ plato_sdk_v2-2.9.0.dist-info/RECORD,,