plato-sdk-v2 2.8.8__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/agents/base.py +3 -9
- plato/agents/config.py +7 -64
- plato/agents/markers.py +18 -0
- plato/agents/otel.py +22 -60
- plato/agents/schema.py +96 -0
- plato/cli/chronos.py +2 -100
- plato/worlds/__init__.py +2 -6
- plato/worlds/base.py +44 -130
- plato/worlds/config.py +5 -166
- plato/worlds/markers.py +63 -0
- plato/worlds/models.py +23 -0
- plato/worlds/schema.py +154 -0
- {plato_sdk_v2-2.8.8.dist-info → plato_sdk_v2-2.9.0.dist-info}/METADATA +1 -1
- {plato_sdk_v2-2.8.8.dist-info → plato_sdk_v2-2.9.0.dist-info}/RECORD +16 -11
- {plato_sdk_v2-2.8.8.dist-info → plato_sdk_v2-2.9.0.dist-info}/WHEEL +0 -0
- {plato_sdk_v2-2.8.8.dist-info → plato_sdk_v2-2.9.0.dist-info}/entry_points.txt +0 -0
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
|
+
}
|
|
@@ -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=
|
|
335
|
+
plato/agents/base.py,sha256=5vRIENOr4hzDSMgcKJFggbIdf9pS0OXLb1KAIjUmFJM,4423
|
|
336
336
|
plato/agents/build.py,sha256=CNMbVQFs2_pYit1dA29Davve28Yi4c7TNK9wBB7odrE,1621
|
|
337
|
-
plato/agents/config.py,sha256=
|
|
338
|
-
plato/agents/
|
|
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,7 +432,7 @@ 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=
|
|
435
|
+
plato/cli/chronos.py,sha256=6QkHVdZxLyevbLJm43HFPJDCpkzFPRFikVhJ_fZR5D4,27863
|
|
434
436
|
plato/cli/compose.py,sha256=MIUBFbYeRO8TyUadUSnhgtWsh1M3LQHF-WLEbmFxIW0,51802
|
|
435
437
|
plato/cli/main.py,sha256=euLI0aw42SG2KIAX1xzMZ2A1LYWNOYayZ2ZCZo10ws4,6984
|
|
436
438
|
plato/cli/pm.py,sha256=eex5K2JucJWzlK81tyBfJrntwZiX_QrmgeKQluv0XKc,54829
|
|
@@ -536,12 +538,15 @@ plato/v2/utils/gateway_tunnel.py,sha256=eWgwf4VV8-jx6iCuHFgCISsAOVmNOOjCB56EuZLs
|
|
|
536
538
|
plato/v2/utils/models.py,sha256=PwehSSnIRG-tM3tWL1PzZEH77ZHhIAZ9R0UPs6YknbM,1441
|
|
537
539
|
plato/v2/utils/proxy_tunnel.py,sha256=8ZTd0jCGSfIHMvSv1fgEyacuISWnGPHLPbDglWroTzY,10463
|
|
538
540
|
plato/worlds/README.md,sha256=XFOkEA3cNNcrWkk-Cxnsl-zn-y0kvUENKQRSqFKpdqw,5479
|
|
539
|
-
plato/worlds/__init__.py,sha256=
|
|
540
|
-
plato/worlds/base.py,sha256
|
|
541
|
+
plato/worlds/__init__.py,sha256=1n23AAev3RZrKHpeSXoCnCVJ5TRtP88jVvagLMxISgg,2256
|
|
542
|
+
plato/worlds/base.py,sha256=pjriEuu-_PcpgBqc0tQmMQnsa08oZrCP83lC586liKo,28237
|
|
541
543
|
plato/worlds/build_hook.py,sha256=KSoW0kqa5b7NyZ7MYOw2qsZ_2FkWuz0M3Ru7AKOP7Qw,3486
|
|
542
|
-
plato/worlds/config.py,sha256=
|
|
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
|
|
543
547
|
plato/worlds/runner.py,sha256=r9B2BxBae8_dM7y5cJf9xhThp_I1Qvf_tlPq2rs8qC8,4013
|
|
544
|
-
|
|
545
|
-
plato_sdk_v2-2.
|
|
546
|
-
plato_sdk_v2-2.
|
|
547
|
-
plato_sdk_v2-2.
|
|
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,,
|
|
File without changes
|
|
File without changes
|