File size: 1,839 Bytes
922c4d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
57
58
59
"""
IncidentOps Environment Client.

Provides the client for connecting to a running IncidentOps environment server.
IncidentOpsEnv extends EnvClient with type-safe action/observation handling.

Example (sync):

    with IncidentOpsEnv(base_url="http://localhost:8000").sync() as env:
        result = env.reset()
        result = env.step(IncidentAction(command="alerts"))

Example (async):

    async with IncidentOpsEnv(base_url="https://your-space.hf.space") as env:
        result = await env.reset()
        result = await env.step(IncidentAction(command="status"))

Example (from Docker):

    env = IncidentOpsEnv.from_docker_image("incident-ops-env:latest")
    try:
        env.reset()
        env.step(IncidentAction(command="alerts"))
    finally:
        env.close()
"""

from openenv.core.env_client import EnvClient

from .models import IncidentAction, IncidentObservation


class IncidentOpsEnv(EnvClient):
    """
    Client for the IncidentOps SRE Incident Response Environment.

    Connects to a running IncidentOps server and provides type-safe wrappers
    around the standard OpenEnv reset() / step() / state() interface.

    The agent interacts using text commands that mirror a real ops terminal.
    See IncidentAction and IncidentObservation in models.py for the full
    action/observation schema.

    Attributes:
        base_url: URL of the running environment server.

    Usage:
        with IncidentOpsEnv(base_url="http://localhost:8000").sync() as env:
            result = env.reset(task_name="service-restart")
            while not result.observation.done:
                action = IncidentAction(command="alerts")
                result = env.step(action)
            print(f"Final score: {result.reward:.3f}")
    """

    action_class = IncidentAction
    observation_class = IncidentObservation