from typing import Literal from openenv.core.env_server.types import Action, Observation from pydantic import Field MAX_STEPS = 20 class WorkbenchAction(Action): tool: Literal["ls", "read", "grep", "python", "write", "edit", "submit"] = Field( description=( "ls lists workspace files; read shows numbered lines of `path`; grep searches " "`pattern` (regex) in `path` or in all files; python runs `code` in the workspace " "(stdout is returned, 10 s limit); write replaces `path` with `content`; edit replaces " "the one exact occurrence of `old` in `path` with `new`; submit ends the episode and " "scores `answer`." ) ) # No numeric or length bounds here: a schema-invalid reply ends an arena episode, so the # server clamps instead. path: str = Field(default="", description="File for read or grep.") start: int = Field(default=1, description="First line for read (1-based).") lines: int = Field(default=40, description="Number of lines for read (at most 80 are shown).") pattern: str = Field(default="", description="Regex for grep.") code: str = Field(default="", description="Python source for python.") answer: str = Field(default="", description="Final answer for submit.") content: str = Field(default="", description="Full new file content for write.") old: str = Field(default="", description="Exact text to replace for edit (must occur once).") new: str = Field(default="", description="Replacement text for edit.") class WorkbenchObservation(Observation): output: str = "" remaining_steps: int = MAX_STEPS