File size: 1,988 Bytes
66cf27f
 
 
 
 
 
 
 
 
df6fa5a
66cf27f
 
 
df6fa5a
 
 
66cf27f
 
430d13c
 
 
 
 
 
 
 
df6fa5a
 
 
66cf27f
 
 
 
 
2bf987b
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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


class CallAction(Action):
    """v8: one call to a tool from the list the task shows; tool and argument names differ per task."""

    tool: str = Field(description="Name of one tool from the task's tool list.")
    args: dict = Field(default_factory=dict, description="That tool's arguments, named as its list entry shows.")