"""Action and observation models for Five Desks.""" from typing import Any, Literal from openenv.core.env_server.types import Action, Observation from pydantic import ConfigDict, Field class DeskAction(Action): # Unknown keys are ignored instead of failing the whole episode. model_config = ConfigDict(extra="ignore", validate_assignment=True) tool: Literal["list", "read", "calc", "submit"] = Field( description=( "list: show the workspace files. read: show one file (needs path). " "calc: evaluate one arithmetic expression (needs expr). " "submit: send the final answer (needs answer); this ends the episode." ) ) path: str = Field(default="", max_length=200, description="File name for read.") expr: str = Field( default="", max_length=1000, description="Arithmetic expression for calc, e.g. 1250*(1+0.04/12)**36.", ) answer: dict[str, Any] = Field( default_factory=dict, description="For submit: an object with exactly the answer keys the task asks for.", ) class DeskObservation(Observation): output: str = Field(default="", description="Result of the last action.") steps_left: int = Field(default=0, description="Actions left before the episode ends.")