@@ -255,3 +255,48 @@ class SandboxMetrics(BaseModel):
255255 )
256256
257257 model_config = ConfigDict (populate_by_name = True )
258+
259+
260+ class SandboxState :
261+ """High-level lifecycle state of the sandbox.
262+
263+ This class provides constant string values for sandbox states.
264+ Note that the sandbox service may introduce new states in future
265+ versions; clients should handle unknown string values gracefully.
266+
267+ Common States:
268+ PENDING (str): Sandbox is being provisioned.
269+ RUNNING (str): Sandbox is running and ready to accept requests.
270+ PAUSING (str): Sandbox is in the process of pausing.
271+ PAUSED (str): Sandbox has been paused while retaining its state.
272+ STOPPING (str): Sandbox is being terminated.
273+ TERMINATED (str): Sandbox has been successfully terminated.
274+ FAILED (str): Sandbox encountered a critical error.
275+ UNKNOWN (str): State is unknown or unsupported by the current version.
276+
277+ State Transitions:
278+ - Pending -> Running: After creation completes.
279+ - Running -> Pausing: When pause is requested.
280+ - Pausing -> Paused: After pause operation completes.
281+ - Paused -> Running: When resume is requested.
282+ - Running/Paused -> Stopping: When kill is requested or TTL expires.
283+ - Stopping -> Terminated: After kill/timeout operation completes.
284+ - Pending/Running/Paused -> Failed: On critical error.
285+ """
286+
287+ PENDING = "Pending"
288+ RUNNING = "Running"
289+ PAUSING = "Pausing"
290+ PAUSED = "Paused"
291+ STOPPING = "Stopping"
292+ TERMINATED = "Terminated"
293+ FAILED = "Failed"
294+ UNKNOWN = "Unknown"
295+
296+ @classmethod
297+ def values (cls ) -> set [str ]:
298+ """Returns a set of all known state values."""
299+ return {
300+ v for k , v in cls .__dict__ .items ()
301+ if k .isupper () and not k .startswith ("_" )
302+ }
0 commit comments