File size: 1,743 Bytes
e9b7141
 
19abe39
e9b7141
 
 
 
19abe39
e9b7141
19abe39
 
 
 
e9b7141
 
19abe39
e9b7141
19abe39
e9b7141
 
 
 
 
 
 
 
 
 
19abe39
 
 
 
e9b7141
 
 
 
 
 
 
 
 
19abe39
 
 
e9b7141
 
 
 
 
 
 
19abe39
e9b7141
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
43
44
45
46
47
48
49
50
51
52
53
54
"""
OpenEnv Pydantic models for the env/ stack.

Matches the env/environment data shape: observations with prompt, target_name,
step, paper_fold_json; actions as fold dicts with from/to/assignment.
"""
from typing import Optional

from pydantic import ConfigDict, Field

from openenv.core.env_server.types import Action, Observation, State


class OrigamiAction(Action):
    """One fold operation — from_point, to_point, assignment."""

    model_config = ConfigDict(populate_by_name=True)

    from_point: list[float] = Field(
        alias="from",
        description="[x, y] start point of the crease",
    )
    to_point: list[float] = Field(
        alias="to",
        description="[x, y] end point of the crease",
    )
    assignment: str = Field(
        description="'M' (mountain) or 'V' (valley)",
    )


class OrigamiObservation(Observation):
    """Observation from env.environment — prompt, target, step, paper state."""

    prompt: str = Field(default="", description="LLM prompt for the current step")
    target_name: str = Field(default="", description="Name of the target (.fold stem)")
    step: int = Field(default=0, ge=0, description="Current step index")
    paper_fold_json: dict = Field(
        default_factory=dict,
        description="Graph edges (crease pattern state)",
    )


class OrigamiState(State):
    """Server-side episode state."""

    paper: dict = Field(default_factory=dict, description="Paper state")
    target: Optional[str] = Field(default=None, description="Target name")
    step: int = Field(default=0, ge=0, description="Step count")
    mode: str = Field(default="step", description="'step' or 'code_as_policy'")


__all__ = ["OrigamiAction", "OrigamiObservation", "OrigamiState"]