File size: 1,617 Bytes
e7b864e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""

ImmunoOrg OpenEnv client

=========================



Thin OpenEnv ``EnvClient`` binding for the ImmunoOrg environment.

This module is intentionally **server-free**: it only imports the

shared wire schemas from ``immunoorg.api_models`` so it can be

installed (or vendored) by external training code without dragging

in the FastAPI server, the simulator, or any of the heavy

``immunoorg`` engines.



Usage

-----

.. code-block:: python



    from client import ImmunoOrgEnv, ImmunoOrgAction



    with ImmunoOrgEnv(base_url="https://hirann-immunoorg-2.hf.space").sync() as env:

        obs = env.reset()

        obs = env.step(ImmunoOrgAction(

            action_type="tactical",

            tactical_action="scan_logs",

            target="web-server-00",

            reasoning="Detection phase scan.",

        ))



If the ``openenv`` package is unavailable (e.g. inside a minimal

container), the module still exposes the wire schemas so callers can

talk to the FastAPI endpoints with plain ``requests``.

"""

from __future__ import annotations

from immunoorg.api_models import ImmunoOrgAction, ImmunoOrgObservation

try:
    from openenv.core import EnvClient

    class ImmunoOrgEnv(EnvClient[ImmunoOrgAction, ImmunoOrgObservation, dict]):
        """OpenEnv client for ImmunoOrg."""

        action_type = ImmunoOrgAction
        observation_type = ImmunoOrgObservation
except ImportError:  # pragma: no cover - openenv is an optional dep here
    ImmunoOrgEnv = None  # type: ignore[assignment]


__all__ = ["ImmunoOrgEnv", "ImmunoOrgAction", "ImmunoOrgObservation"]