plato-sdk-v2 2.0.50__py3-none-any.whl → 2.2.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.
Files changed (158) hide show
  1. plato/__init__.py +7 -6
  2. plato/_generated/__init__.py +1 -1
  3. plato/_generated/api/v1/env/evaluate_session.py +3 -3
  4. plato/_generated/api/v1/env/log_state_mutation.py +4 -4
  5. plato/_generated/api/v1/sandbox/checkpoint_vm.py +3 -3
  6. plato/_generated/api/v1/sandbox/save_vm_snapshot.py +3 -3
  7. plato/_generated/api/v1/sandbox/setup_sandbox.py +8 -8
  8. plato/_generated/api/v1/session/__init__.py +2 -0
  9. plato/_generated/api/v1/session/get_sessions_for_archival.py +100 -0
  10. plato/_generated/api/v1/testcases/__init__.py +6 -2
  11. plato/_generated/api/v1/testcases/get_mutation_groups_for_testcase.py +98 -0
  12. plato/_generated/api/v1/testcases/{get_next_output_testcase_for_scoring.py → get_next_testcase_for_scoring.py} +23 -10
  13. plato/_generated/api/v1/testcases/get_testcase_metadata_for_scoring.py +74 -0
  14. plato/_generated/api/v2/__init__.py +2 -1
  15. plato/_generated/api/v2/jobs/__init__.py +4 -0
  16. plato/_generated/api/v2/jobs/checkpoint.py +3 -3
  17. plato/_generated/api/v2/jobs/disk_snapshot.py +3 -3
  18. plato/_generated/api/v2/jobs/log_for_job.py +4 -39
  19. plato/_generated/api/v2/jobs/make.py +4 -4
  20. plato/_generated/api/v2/jobs/setup_sandbox.py +97 -0
  21. plato/_generated/api/v2/jobs/snapshot.py +3 -3
  22. plato/_generated/api/v2/jobs/snapshot_store.py +91 -0
  23. plato/_generated/api/v2/sessions/__init__.py +4 -0
  24. plato/_generated/api/v2/sessions/checkpoint.py +3 -3
  25. plato/_generated/api/v2/sessions/disk_snapshot.py +3 -3
  26. plato/_generated/api/v2/sessions/evaluate.py +3 -3
  27. plato/_generated/api/v2/sessions/log_job_mutation.py +4 -39
  28. plato/_generated/api/v2/sessions/make.py +4 -4
  29. plato/_generated/api/v2/sessions/setup_sandbox.py +98 -0
  30. plato/_generated/api/v2/sessions/snapshot.py +3 -3
  31. plato/_generated/api/v2/sessions/snapshot_store.py +94 -0
  32. plato/_generated/api/v2/user/__init__.py +7 -0
  33. plato/_generated/api/v2/user/get_current_user.py +76 -0
  34. plato/_generated/models/__init__.py +174 -23
  35. plato/_sims_generator/__init__.py +19 -4
  36. plato/_sims_generator/instruction.py +203 -0
  37. plato/_sims_generator/templates/instruction/helpers.py.jinja +161 -0
  38. plato/_sims_generator/templates/instruction/init.py.jinja +43 -0
  39. plato/agents/__init__.py +107 -517
  40. plato/agents/base.py +145 -0
  41. plato/agents/build.py +61 -0
  42. plato/agents/config.py +160 -0
  43. plato/agents/logging.py +401 -0
  44. plato/agents/runner.py +161 -0
  45. plato/agents/trajectory.py +266 -0
  46. plato/chronos/__init__.py +37 -0
  47. plato/chronos/api/__init__.py +3 -0
  48. plato/chronos/api/agents/__init__.py +13 -0
  49. plato/chronos/api/agents/create_agent.py +63 -0
  50. plato/chronos/api/agents/delete_agent.py +61 -0
  51. plato/chronos/api/agents/get_agent.py +62 -0
  52. plato/chronos/api/agents/get_agent_schema.py +72 -0
  53. plato/chronos/api/agents/get_agent_versions.py +62 -0
  54. plato/chronos/api/agents/list_agents.py +57 -0
  55. plato/chronos/api/agents/lookup_agent.py +74 -0
  56. plato/chronos/api/auth/__init__.py +9 -0
  57. plato/chronos/api/auth/debug_auth_api_auth_debug_get.py +43 -0
  58. plato/chronos/api/auth/get_auth_status_api_auth_status_get.py +61 -0
  59. plato/chronos/api/auth/get_current_user_route_api_auth_me_get.py +60 -0
  60. plato/chronos/api/callback/__init__.py +11 -0
  61. plato/chronos/api/callback/push_agent_logs.py +61 -0
  62. plato/chronos/api/callback/update_agent_status.py +57 -0
  63. plato/chronos/api/callback/upload_artifacts.py +59 -0
  64. plato/chronos/api/callback/upload_logs_zip.py +57 -0
  65. plato/chronos/api/callback/upload_trajectory.py +57 -0
  66. plato/chronos/api/default/__init__.py +7 -0
  67. plato/chronos/api/default/health.py +43 -0
  68. plato/chronos/api/jobs/__init__.py +7 -0
  69. plato/chronos/api/jobs/launch_job.py +63 -0
  70. plato/chronos/api/registry/__init__.py +19 -0
  71. plato/chronos/api/registry/get_agent_schema_api_registry_agents__agent_name__schema_get.py +62 -0
  72. plato/chronos/api/registry/get_agent_versions_api_registry_agents__agent_name__versions_get.py +52 -0
  73. plato/chronos/api/registry/get_world_schema_api_registry_worlds__package_name__schema_get.py +68 -0
  74. plato/chronos/api/registry/get_world_versions_api_registry_worlds__package_name__versions_get.py +52 -0
  75. plato/chronos/api/registry/list_registry_agents_api_registry_agents_get.py +44 -0
  76. plato/chronos/api/registry/list_registry_worlds_api_registry_worlds_get.py +44 -0
  77. plato/chronos/api/runtimes/__init__.py +11 -0
  78. plato/chronos/api/runtimes/create_runtime.py +63 -0
  79. plato/chronos/api/runtimes/delete_runtime.py +61 -0
  80. plato/chronos/api/runtimes/get_runtime.py +62 -0
  81. plato/chronos/api/runtimes/list_runtimes.py +57 -0
  82. plato/chronos/api/runtimes/test_runtime.py +67 -0
  83. plato/chronos/api/secrets/__init__.py +11 -0
  84. plato/chronos/api/secrets/create_secret.py +63 -0
  85. plato/chronos/api/secrets/delete_secret.py +61 -0
  86. plato/chronos/api/secrets/get_secret.py +62 -0
  87. plato/chronos/api/secrets/list_secrets.py +57 -0
  88. plato/chronos/api/secrets/update_secret.py +68 -0
  89. plato/chronos/api/sessions/__init__.py +10 -0
  90. plato/chronos/api/sessions/get_session.py +62 -0
  91. plato/chronos/api/sessions/get_session_logs.py +72 -0
  92. plato/chronos/api/sessions/get_session_logs_download.py +62 -0
  93. plato/chronos/api/sessions/list_sessions.py +57 -0
  94. plato/chronos/api/status/__init__.py +8 -0
  95. plato/chronos/api/status/get_status_api_status_get.py +44 -0
  96. plato/chronos/api/status/get_version_info_api_version_get.py +44 -0
  97. plato/chronos/api/templates/__init__.py +11 -0
  98. plato/chronos/api/templates/create_template.py +63 -0
  99. plato/chronos/api/templates/delete_template.py +61 -0
  100. plato/chronos/api/templates/get_template.py +62 -0
  101. plato/chronos/api/templates/list_templates.py +57 -0
  102. plato/chronos/api/templates/update_template.py +68 -0
  103. plato/chronos/api/trajectories/__init__.py +8 -0
  104. plato/chronos/api/trajectories/get_trajectory.py +62 -0
  105. plato/chronos/api/trajectories/list_trajectories.py +62 -0
  106. plato/chronos/api/worlds/__init__.py +10 -0
  107. plato/chronos/api/worlds/create_world.py +63 -0
  108. plato/chronos/api/worlds/delete_world.py +61 -0
  109. plato/chronos/api/worlds/get_world.py +62 -0
  110. plato/chronos/api/worlds/list_worlds.py +57 -0
  111. plato/chronos/client.py +171 -0
  112. plato/chronos/errors.py +141 -0
  113. plato/chronos/models/__init__.py +647 -0
  114. plato/chronos/py.typed +0 -0
  115. plato/sims/cli.py +299 -123
  116. plato/sims/registry.py +77 -4
  117. plato/v1/cli/agent.py +88 -84
  118. plato/v1/cli/main.py +2 -0
  119. plato/v1/cli/pm.py +441 -119
  120. plato/v1/cli/sandbox.py +747 -191
  121. plato/v1/cli/sim.py +11 -0
  122. plato/v1/cli/verify.py +1269 -0
  123. plato/v1/cli/world.py +3 -0
  124. plato/v1/flow_executor.py +21 -17
  125. plato/v1/models/env.py +11 -11
  126. plato/v1/sdk.py +2 -2
  127. plato/v1/sync_env.py +11 -11
  128. plato/v1/sync_flow_executor.py +21 -17
  129. plato/v1/sync_sdk.py +4 -2
  130. plato/v2/__init__.py +2 -0
  131. plato/v2/async_/environment.py +20 -1
  132. plato/v2/async_/session.py +54 -3
  133. plato/v2/sync/environment.py +2 -1
  134. plato/v2/sync/session.py +52 -2
  135. plato/worlds/README.md +218 -0
  136. plato/worlds/__init__.py +54 -18
  137. plato/worlds/base.py +304 -93
  138. plato/worlds/config.py +239 -73
  139. plato/worlds/runner.py +391 -80
  140. {plato_sdk_v2-2.0.50.dist-info → plato_sdk_v2-2.2.4.dist-info}/METADATA +1 -3
  141. {plato_sdk_v2-2.0.50.dist-info → plato_sdk_v2-2.2.4.dist-info}/RECORD +143 -68
  142. {plato_sdk_v2-2.0.50.dist-info → plato_sdk_v2-2.2.4.dist-info}/entry_points.txt +1 -0
  143. plato/_generated/api/v2/interfaces/__init__.py +0 -27
  144. plato/_generated/api/v2/interfaces/v2_interface_browser_create.py +0 -68
  145. plato/_generated/api/v2/interfaces/v2_interface_cdp_url.py +0 -65
  146. plato/_generated/api/v2/interfaces/v2_interface_click.py +0 -64
  147. plato/_generated/api/v2/interfaces/v2_interface_close.py +0 -59
  148. plato/_generated/api/v2/interfaces/v2_interface_computer_create.py +0 -68
  149. plato/_generated/api/v2/interfaces/v2_interface_cursor.py +0 -64
  150. plato/_generated/api/v2/interfaces/v2_interface_key.py +0 -68
  151. plato/_generated/api/v2/interfaces/v2_interface_screenshot.py +0 -65
  152. plato/_generated/api/v2/interfaces/v2_interface_scroll.py +0 -70
  153. plato/_generated/api/v2/interfaces/v2_interface_type.py +0 -64
  154. plato/world/__init__.py +0 -44
  155. plato/world/base.py +0 -267
  156. plato/world/config.py +0 -139
  157. plato/world/types.py +0 -47
  158. {plato_sdk_v2-2.0.50.dist-info → plato_sdk_v2-2.2.4.dist-info}/WHEEL +0 -0
@@ -0,0 +1,266 @@
1
+ """ATIF (Agent Trajectory Interchange Format) models.
2
+
3
+ This module provides Pydantic models for the ATIF specification,
4
+ a standardized format for logging agent interaction history.
5
+
6
+ Matches Harbor's trajectory format exactly for compatibility.
7
+ Spec: https://harborframework.com/docs/trajectory-format
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from datetime import datetime, timezone
13
+ from typing import Any, Literal
14
+
15
+ from pydantic import BaseModel, Field
16
+
17
+ SCHEMA_VERSION: Literal["ATIF-v1.0", "ATIF-v1.1", "ATIF-v1.2", "ATIF-v1.3", "ATIF-v1.4", "ATIF-v1.5"] = "ATIF-v1.5"
18
+
19
+
20
+ class Metrics(BaseModel):
21
+ """LLM operational and confidence data."""
22
+
23
+ model_config = {"extra": "forbid"}
24
+
25
+ prompt_tokens: int | None = Field(default=None, description="Number of tokens in the prompt")
26
+ completion_tokens: int | None = Field(default=None, description="Number of tokens in the completion")
27
+ cached_tokens: int | None = Field(default=None, description="Number of cached tokens used")
28
+ cost_usd: float | None = Field(default=None, description="Cost in USD for this step")
29
+ prompt_token_ids: list[int] | None = Field(default=None, description="Token IDs for the prompt")
30
+ completion_token_ids: list[int] | None = Field(default=None, description="Token IDs for the completion")
31
+ logprobs: list[float] | None = Field(default=None, description="Log probabilities for completion tokens")
32
+ extra: dict[str, Any] | None = Field(default=None, description="Custom metrics")
33
+
34
+
35
+ class FinalMetrics(BaseModel):
36
+ """Trajectory-level aggregate statistics."""
37
+
38
+ model_config = {"extra": "forbid"}
39
+
40
+ total_prompt_tokens: int | None = Field(
41
+ default=None,
42
+ description="Sum of all prompt tokens across all steps, including cached tokens",
43
+ )
44
+ total_completion_tokens: int | None = Field(
45
+ default=None,
46
+ description="Sum of all completion tokens across all steps",
47
+ )
48
+ total_cached_tokens: int | None = Field(
49
+ default=None,
50
+ description="Sum of all cached tokens across all steps",
51
+ )
52
+ total_cost_usd: float | None = Field(
53
+ default=None,
54
+ description="Total real monetary cost for the entire trajectory",
55
+ )
56
+ total_steps: int | None = Field(
57
+ default=None,
58
+ ge=0,
59
+ description="Number of steps in the trajectory",
60
+ )
61
+ extra: dict[str, Any] | None = Field(default=None, description="Custom aggregate metrics")
62
+
63
+
64
+ class ToolCall(BaseModel):
65
+ """A function/tool invocation."""
66
+
67
+ model_config = {"extra": "forbid"}
68
+
69
+ tool_call_id: str = Field(..., description="Unique identifier for this specific tool call")
70
+ function_name: str = Field(..., description="The name of the function or tool being invoked")
71
+ arguments: dict[str, Any] = Field(..., description="Arguments passed to the function (can be empty dict)")
72
+
73
+
74
+ class ObservationResult(BaseModel):
75
+ """Result from a single tool call."""
76
+
77
+ model_config = {"extra": "forbid"}
78
+
79
+ source_call_id: str = Field(..., description="ID of the tool call that produced this result")
80
+ content: str = Field(..., description="The result content from the tool execution")
81
+
82
+
83
+ class Observation(BaseModel):
84
+ """Environment feedback from tool execution."""
85
+
86
+ model_config = {"extra": "forbid"}
87
+
88
+ results: list[ObservationResult] = Field(..., description="Results from tool executions")
89
+
90
+
91
+ class Step(BaseModel):
92
+ """A single interaction step in the trajectory."""
93
+
94
+ model_config = {"extra": "forbid"}
95
+
96
+ step_id: int = Field(..., ge=1, description="Ordinal index of the turn (starting from 1)")
97
+ timestamp: str | None = Field(default=None, description="ISO 8601 timestamp")
98
+ source: Literal["user", "agent", "system"] = Field(..., description="Step originator")
99
+ message: str = Field(..., description="Dialogue content (allows empty string)")
100
+
101
+ # Agent-only fields
102
+ model_name: str | None = Field(default=None, description="LLM model used for this step")
103
+ reasoning_effort: str | float | None = Field(default=None, description="Effort measurement")
104
+ reasoning_content: str | None = Field(default=None, description="Agent's internal reasoning")
105
+ tool_calls: list[ToolCall] | None = Field(default=None, description="Structured action objects")
106
+ observation: Observation | None = Field(default=None, description="Environment feedback")
107
+ metrics: Metrics | None = Field(default=None, description="LLM operational and confidence data")
108
+ is_copied_context: bool | None = Field(default=None, description="Context reuse indicator (ATIF-v1.5+)")
109
+
110
+ # Custom metadata
111
+ extra: dict[str, Any] | None = Field(default=None, description="Custom metadata")
112
+
113
+ @classmethod
114
+ def user(cls, step_id: int, message: str, **kwargs: Any) -> Step:
115
+ """Create a user step."""
116
+ return cls(
117
+ step_id=step_id,
118
+ timestamp=datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
119
+ source="user",
120
+ message=message,
121
+ **kwargs,
122
+ )
123
+
124
+ @classmethod
125
+ def agent(
126
+ cls,
127
+ step_id: int,
128
+ message: str,
129
+ model_name: str,
130
+ tool_calls: list[ToolCall] | None = None,
131
+ observation: Observation | None = None,
132
+ metrics: Metrics | None = None,
133
+ reasoning_content: str | None = None,
134
+ **kwargs: Any,
135
+ ) -> Step:
136
+ """Create an agent step."""
137
+ return cls(
138
+ step_id=step_id,
139
+ timestamp=datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
140
+ source="agent",
141
+ message=message,
142
+ model_name=model_name,
143
+ tool_calls=tool_calls,
144
+ observation=observation,
145
+ metrics=metrics,
146
+ reasoning_content=reasoning_content,
147
+ **kwargs,
148
+ )
149
+
150
+ @classmethod
151
+ def system(cls, step_id: int, message: str, **kwargs: Any) -> Step:
152
+ """Create a system step."""
153
+ return cls(
154
+ step_id=step_id,
155
+ timestamp=datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
156
+ source="system",
157
+ message=message,
158
+ **kwargs,
159
+ )
160
+
161
+
162
+ class Agent(BaseModel):
163
+ """Agent metadata."""
164
+
165
+ model_config = {"extra": "forbid"}
166
+
167
+ name: str = Field(..., description="The name of the agent system")
168
+ version: str = Field(..., description="The version identifier of the agent system")
169
+ model_name: str | None = Field(default=None, description="Default LLM model used for this trajectory")
170
+ tool_definitions: list[dict[str, Any]] | None = Field(
171
+ default=None,
172
+ description="Array of tool/function definitions available to the agent",
173
+ )
174
+ extra: dict[str, Any] | None = Field(default=None, description="Custom agent configuration details")
175
+
176
+
177
+ class Trajectory(BaseModel):
178
+ """ATIF trajectory - the complete interaction history.
179
+
180
+ Example:
181
+ trajectory = Trajectory(
182
+ session_id="abc-123",
183
+ agent=Agent(name="openhands", version="0.37.0", model_name="claude-sonnet-4"),
184
+ steps=[
185
+ Step.user(1, "Fix the bug in main.py"),
186
+ Step.agent(2, "I'll analyze the code...", model_name="claude-sonnet-4"),
187
+ ],
188
+ )
189
+ trajectory.to_file("/logs/agent/trajectory.json")
190
+ """
191
+
192
+ model_config = {"extra": "forbid"}
193
+
194
+ schema_version: Literal["ATIF-v1.0", "ATIF-v1.1", "ATIF-v1.2", "ATIF-v1.3", "ATIF-v1.4", "ATIF-v1.5"] = Field(
195
+ default="ATIF-v1.5",
196
+ description="String defining ATIF compatibility",
197
+ )
198
+ session_id: str = Field(..., description="Unique identifier for the entire agent run")
199
+ agent: Agent = Field(..., description="Object specifying the agent configuration")
200
+ steps: list[Step] = Field(
201
+ ..., min_length=1, description="Array of step objects representing the complete interaction history"
202
+ )
203
+ notes: str | None = Field(default=None, description="Custom information, design notes, or explanations")
204
+ final_metrics: FinalMetrics | None = Field(default=None, description="Summary metrics for the entire trajectory")
205
+ continued_trajectory_ref: str | None = Field(
206
+ default=None,
207
+ description="Reference to continuation trajectory file if this trajectory is continued elsewhere",
208
+ )
209
+ extra: dict[str, Any] | None = Field(default=None, description="Custom root-level metadata")
210
+
211
+ def add_step(self, step: Step) -> None:
212
+ """Add a step to the trajectory."""
213
+ self.steps.append(step)
214
+
215
+ def compute_final_metrics(self) -> FinalMetrics:
216
+ """Compute aggregate metrics from all steps."""
217
+ total_prompt = 0
218
+ total_completion = 0
219
+ total_cached = 0
220
+ total_cost = 0.0
221
+
222
+ for step in self.steps:
223
+ if step.metrics:
224
+ if step.metrics.prompt_tokens:
225
+ total_prompt += step.metrics.prompt_tokens
226
+ if step.metrics.completion_tokens:
227
+ total_completion += step.metrics.completion_tokens
228
+ if step.metrics.cached_tokens:
229
+ total_cached += step.metrics.cached_tokens
230
+ if step.metrics.cost_usd:
231
+ total_cost += step.metrics.cost_usd
232
+
233
+ self.final_metrics = FinalMetrics(
234
+ total_prompt_tokens=total_prompt if total_prompt > 0 else None,
235
+ total_completion_tokens=total_completion if total_completion > 0 else None,
236
+ total_steps=len(self.steps),
237
+ total_cached_tokens=total_cached if total_cached > 0 else None,
238
+ total_cost_usd=total_cost if total_cost > 0 else None,
239
+ )
240
+ return self.final_metrics
241
+
242
+ def to_dict(self, exclude_none: bool = True) -> dict[str, Any]:
243
+ """Convert to dictionary, optionally excluding None values."""
244
+ return self.model_dump(exclude_none=exclude_none)
245
+
246
+ def to_json(self, indent: int = 2) -> str:
247
+ """Convert to JSON string."""
248
+ return self.model_dump_json(indent=indent, exclude_none=True)
249
+
250
+ def to_file(self, path: str) -> None:
251
+ """Write trajectory to a JSON file."""
252
+ import json
253
+ from pathlib import Path as PathLib
254
+
255
+ PathLib(path).parent.mkdir(parents=True, exist_ok=True)
256
+ with open(path, "w") as f:
257
+ json.dump(self.to_dict(), f, indent=2)
258
+
259
+ @classmethod
260
+ def from_file(cls, path: str) -> Trajectory:
261
+ """Load trajectory from a JSON file."""
262
+ import json
263
+
264
+ with open(path) as f:
265
+ data = json.load(f)
266
+ return cls(**data)
@@ -0,0 +1,37 @@
1
+ """Chronos API SDK - v0.1.0"""
2
+
3
+ from . import api, errors, models
4
+ from .client import AsyncClient, Client
5
+ from .errors import (
6
+ APIError,
7
+ BadRequestError,
8
+ ConflictError,
9
+ ForbiddenError,
10
+ InternalServerError,
11
+ NotFoundError,
12
+ RateLimitError,
13
+ ServiceUnavailableError,
14
+ UnauthorizedError,
15
+ UnprocessableEntityError,
16
+ )
17
+
18
+ __all__ = [
19
+ # Clients
20
+ "Client",
21
+ "AsyncClient",
22
+ # Modules
23
+ "api",
24
+ "models",
25
+ "errors",
26
+ # Error types for convenience
27
+ "APIError",
28
+ "BadRequestError",
29
+ "UnauthorizedError",
30
+ "ForbiddenError",
31
+ "NotFoundError",
32
+ "ConflictError",
33
+ "UnprocessableEntityError",
34
+ "RateLimitError",
35
+ "InternalServerError",
36
+ "ServiceUnavailableError",
37
+ ]
@@ -0,0 +1,3 @@
1
+ """Generated API modules."""
2
+
3
+ __all__ = []
@@ -0,0 +1,13 @@
1
+ """API endpoints."""
2
+
3
+ from . import create_agent, delete_agent, get_agent, get_agent_schema, get_agent_versions, list_agents, lookup_agent
4
+
5
+ __all__ = [
6
+ "list_agents",
7
+ "create_agent",
8
+ "lookup_agent",
9
+ "get_agent_versions",
10
+ "get_agent_schema",
11
+ "get_agent",
12
+ "delete_agent",
13
+ ]
@@ -0,0 +1,63 @@
1
+ """Create Agent"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import AgentCreate, AgentResponse
11
+
12
+
13
+ def _build_request_args(
14
+ body: AgentCreate,
15
+ x_api_key: str | None = None,
16
+ ) -> dict[str, Any]:
17
+ """Build request arguments."""
18
+ url = "/api/agents"
19
+
20
+ headers: dict[str, str] = {}
21
+ if x_api_key is not None:
22
+ headers["X-API-Key"] = x_api_key
23
+
24
+ return {
25
+ "method": "POST",
26
+ "url": url,
27
+ "json": body.model_dump(mode="json", exclude_none=True),
28
+ "headers": headers,
29
+ }
30
+
31
+
32
+ def sync(
33
+ client: httpx.Client,
34
+ body: AgentCreate,
35
+ x_api_key: str | None = None,
36
+ ) -> AgentResponse:
37
+ """Create a new agent version."""
38
+
39
+ request_args = _build_request_args(
40
+ body=body,
41
+ x_api_key=x_api_key,
42
+ )
43
+
44
+ response = client.request(**request_args)
45
+ raise_for_status(response)
46
+ return AgentResponse.model_validate(response.json())
47
+
48
+
49
+ async def asyncio(
50
+ client: httpx.AsyncClient,
51
+ body: AgentCreate,
52
+ x_api_key: str | None = None,
53
+ ) -> AgentResponse:
54
+ """Create a new agent version."""
55
+
56
+ request_args = _build_request_args(
57
+ body=body,
58
+ x_api_key=x_api_key,
59
+ )
60
+
61
+ response = await client.request(**request_args)
62
+ raise_for_status(response)
63
+ return AgentResponse.model_validate(response.json())
@@ -0,0 +1,61 @@
1
+ """Delete Agent"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+
11
+
12
+ def _build_request_args(
13
+ public_id: str,
14
+ x_api_key: str | None = None,
15
+ ) -> dict[str, Any]:
16
+ """Build request arguments."""
17
+ url = f"/api/agents/{public_id}"
18
+
19
+ headers: dict[str, str] = {}
20
+ if x_api_key is not None:
21
+ headers["X-API-Key"] = x_api_key
22
+
23
+ return {
24
+ "method": "DELETE",
25
+ "url": url,
26
+ "headers": headers,
27
+ }
28
+
29
+
30
+ def sync(
31
+ client: httpx.Client,
32
+ public_id: str,
33
+ x_api_key: str | None = None,
34
+ ) -> dict[str, Any]:
35
+ """Archive an agent."""
36
+
37
+ request_args = _build_request_args(
38
+ public_id=public_id,
39
+ x_api_key=x_api_key,
40
+ )
41
+
42
+ response = client.request(**request_args)
43
+ raise_for_status(response)
44
+ return response.json()
45
+
46
+
47
+ async def asyncio(
48
+ client: httpx.AsyncClient,
49
+ public_id: str,
50
+ x_api_key: str | None = None,
51
+ ) -> dict[str, Any]:
52
+ """Archive an agent."""
53
+
54
+ request_args = _build_request_args(
55
+ public_id=public_id,
56
+ x_api_key=x_api_key,
57
+ )
58
+
59
+ response = await client.request(**request_args)
60
+ raise_for_status(response)
61
+ return response.json()
@@ -0,0 +1,62 @@
1
+ """Get Agent"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import AgentResponse
11
+
12
+
13
+ def _build_request_args(
14
+ public_id: str,
15
+ x_api_key: str | None = None,
16
+ ) -> dict[str, Any]:
17
+ """Build request arguments."""
18
+ url = f"/api/agents/{public_id}"
19
+
20
+ headers: dict[str, str] = {}
21
+ if x_api_key is not None:
22
+ headers["X-API-Key"] = x_api_key
23
+
24
+ return {
25
+ "method": "GET",
26
+ "url": url,
27
+ "headers": headers,
28
+ }
29
+
30
+
31
+ def sync(
32
+ client: httpx.Client,
33
+ public_id: str,
34
+ x_api_key: str | None = None,
35
+ ) -> AgentResponse:
36
+ """Get an agent by public ID."""
37
+
38
+ request_args = _build_request_args(
39
+ public_id=public_id,
40
+ x_api_key=x_api_key,
41
+ )
42
+
43
+ response = client.request(**request_args)
44
+ raise_for_status(response)
45
+ return AgentResponse.model_validate(response.json())
46
+
47
+
48
+ async def asyncio(
49
+ client: httpx.AsyncClient,
50
+ public_id: str,
51
+ x_api_key: str | None = None,
52
+ ) -> AgentResponse:
53
+ """Get an agent by public ID."""
54
+
55
+ request_args = _build_request_args(
56
+ public_id=public_id,
57
+ x_api_key=x_api_key,
58
+ )
59
+
60
+ response = await client.request(**request_args)
61
+ raise_for_status(response)
62
+ return AgentResponse.model_validate(response.json())
@@ -0,0 +1,72 @@
1
+ """Get Agent Schema"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import ChronosModelsAgentAgentSchemaResponse
11
+
12
+
13
+ def _build_request_args(
14
+ name: str,
15
+ version: str | None = None,
16
+ x_api_key: str | None = None,
17
+ ) -> dict[str, Any]:
18
+ """Build request arguments."""
19
+ url = f"/api/agents/by-name/{name}/schema"
20
+
21
+ params: dict[str, Any] = {}
22
+ if version is not None:
23
+ params["version"] = version
24
+
25
+ headers: dict[str, str] = {}
26
+ if x_api_key is not None:
27
+ headers["X-API-Key"] = x_api_key
28
+
29
+ return {
30
+ "method": "GET",
31
+ "url": url,
32
+ "params": params,
33
+ "headers": headers,
34
+ }
35
+
36
+
37
+ def sync(
38
+ client: httpx.Client,
39
+ name: str,
40
+ version: str | None = None,
41
+ x_api_key: str | None = None,
42
+ ) -> ChronosModelsAgentAgentSchemaResponse:
43
+ """Get agent schema by name and optional version."""
44
+
45
+ request_args = _build_request_args(
46
+ name=name,
47
+ version=version,
48
+ x_api_key=x_api_key,
49
+ )
50
+
51
+ response = client.request(**request_args)
52
+ raise_for_status(response)
53
+ return ChronosModelsAgentAgentSchemaResponse.model_validate(response.json())
54
+
55
+
56
+ async def asyncio(
57
+ client: httpx.AsyncClient,
58
+ name: str,
59
+ version: str | None = None,
60
+ x_api_key: str | None = None,
61
+ ) -> ChronosModelsAgentAgentSchemaResponse:
62
+ """Get agent schema by name and optional version."""
63
+
64
+ request_args = _build_request_args(
65
+ name=name,
66
+ version=version,
67
+ x_api_key=x_api_key,
68
+ )
69
+
70
+ response = await client.request(**request_args)
71
+ raise_for_status(response)
72
+ return ChronosModelsAgentAgentSchemaResponse.model_validate(response.json())
@@ -0,0 +1,62 @@
1
+ """Get Agent Versions"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import ChronosModelsAgentAgentVersionsResponse
11
+
12
+
13
+ def _build_request_args(
14
+ name: str,
15
+ x_api_key: str | None = None,
16
+ ) -> dict[str, Any]:
17
+ """Build request arguments."""
18
+ url = f"/api/agents/by-name/{name}/versions"
19
+
20
+ headers: dict[str, str] = {}
21
+ if x_api_key is not None:
22
+ headers["X-API-Key"] = x_api_key
23
+
24
+ return {
25
+ "method": "GET",
26
+ "url": url,
27
+ "headers": headers,
28
+ }
29
+
30
+
31
+ def sync(
32
+ client: httpx.Client,
33
+ name: str,
34
+ x_api_key: str | None = None,
35
+ ) -> ChronosModelsAgentAgentVersionsResponse:
36
+ """Get all versions of an agent by name."""
37
+
38
+ request_args = _build_request_args(
39
+ name=name,
40
+ x_api_key=x_api_key,
41
+ )
42
+
43
+ response = client.request(**request_args)
44
+ raise_for_status(response)
45
+ return ChronosModelsAgentAgentVersionsResponse.model_validate(response.json())
46
+
47
+
48
+ async def asyncio(
49
+ client: httpx.AsyncClient,
50
+ name: str,
51
+ x_api_key: str | None = None,
52
+ ) -> ChronosModelsAgentAgentVersionsResponse:
53
+ """Get all versions of an agent by name."""
54
+
55
+ request_args = _build_request_args(
56
+ name=name,
57
+ x_api_key=x_api_key,
58
+ )
59
+
60
+ response = await client.request(**request_args)
61
+ raise_for_status(response)
62
+ return ChronosModelsAgentAgentVersionsResponse.model_validate(response.json())