Buckets:
| import"../chunks/DsnmJJEf.js";import{i as Jc,h as jc,C as Cc,H as u,D as n,E as l,b as kc,s as Uc,a as p}from"../chunks/DCNlwWI8.js";import{p as Ic,o as Ac,s as e,f as v,a as d,b as Nc,c as o,d as g,n as t,r}from"../chunks/CMKpKl_X.js";const Ec='{"title":"Core API","local":"core-api","sections":[{"title":"Server","local":"server","sections":[{"title":"Environment server primitives","local":"openenv.core.Message","sections":[],"depth":3},{"title":"Types","local":"openenv.core.ServerMode","sections":[],"depth":3},{"title":"Exceptions","local":"openenv.core.OpenEnvError","sections":[],"depth":3},{"title":"HTTP server utilities","local":"openenv.core.HTTPEnvServer","sections":[],"depth":3},{"title":"Web interface helpers","local":"openenv.core.env_server.web_interface.ActionLog","sections":[],"depth":3},{"title":"Serialization","local":"openenv.core.deserialize_action","sections":[],"depth":3},{"title":"Transforms","local":"openenv.core.CompositeTransform","sections":[],"depth":3},{"title":"Route configuration","local":"openenv.core.GetEndpointConfig","sections":[],"depth":3}],"depth":2},{"title":"Clients","local":"clients","sections":[{"title":"Base client","local":"openenv.core.EnvClient","sections":[],"depth":3},{"title":"Synchronous client","local":"openenv.SyncEnvClient","sections":[],"depth":3},{"title":"Generic client","local":"openenv.GenericEnvClient","sections":[],"depth":3},{"title":"LLM client","local":"openenv.core.ToolCall","sections":[],"depth":3},{"title":"Shared dataclasses","local":"openenv.core.client_types.StepResult","sections":[],"depth":3}],"depth":2},{"title":"MCP (Model Context Protocol)","local":"mcp-model-context-protocol","sections":[{"title":"MCP environment","local":"openenv.core.MCPEnvironment","sections":[],"depth":3},{"title":"MCP types","local":"openenv.core.JsonRpcErrorCode","sections":[],"depth":3},{"title":"MCP client","local":"openenv.core.MCPClientBase","sections":[],"depth":3}],"depth":2},{"title":"Rubrics","local":"openenv.core.rubrics.Rubric","sections":[],"depth":2},{"title":"Tools","local":"openenv.core.tools.RepoInfo","sections":[],"depth":2},{"title":"Container providers","local":"openenv.core.containers.runtime.ContainerProvider","sections":[],"depth":2}],"depth":1}';var Rc=g('<meta name="hf:doc:metadata"/>'),m=g("<p>Examples:</p> <!>",1),Sc=g("<p>Async usage:</p> <!>",1),Lc=g("<p>Sync usage via <code>.sync()</code> wrapper:</p> <!>",1),Dc=g("<p>Sync wrapper:</p> <!>",1),Bc=g("<p>Per-step reward:</p> <!>",1),Wc=g("<p>Example:</p> <!>",1),Gc=g("<p>Sandbox v2 (beta) is opt-in:</p> <!>",1),Pc=g(`<p></p> <!> <!> <p>The <code>openenv.core</code> package provides the core abstractions for building and running environments. For an end-to-end tutorial on building environments with OpenEnv, see the <a href="../getting_started/environment-builder">building an environment</a> guide.</p> <p>If you are trying to understand when OpenEnv exposes the training loop versus direct MCP access, see the <a href="../guides/simulation-vs-production">simulation vs production mode</a> guide.</p> <p>For a high-level explanation of how MCP-backed environments move through <code>step()</code>, <code>step_async()</code>, and convenience tool helpers, see the <a href="../guides/mcp-environment-lifecycle">MCP environment lifecycle</a> guide.</p> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A message in a conversation.</p> <p>Compatible with Huggingface chat template format.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Protocol for tokenizers that support chat templates.</p> <p>This protocol defines the interface that tokenizers must implement | |
| to work with chat-based environments. It’s compatible with | |
| Huggingface transformers tokenizers.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Apply a chat template to format and optionally tokenize a conversation.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Decode token IDs back to text.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Transform observations to add rewards, metrics, or other modifications.</p> <p>Transforms follow the TorchRL pattern where they take an observation | |
| and return a (potentially modified) observation. This allows for | |
| flexible reward computation and observation augmentation.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Base class for all environment servers following Gym/Gymnasium API.</p> <p>See <a href="https://github.com/huggingface/OpenEnv/blob/main/rfcs/004-rubrics.md" rel="nofollow">rfcs/004-rubrics.md</a> for rubric design details.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Clean up resources used by the environment.</p> <p>Override this method to implement custom cleanup logic. | |
| Called when the environment is being destroyed or reset.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get metadata about this environment.</p> <p>Override this method to provide custom metadata for the environment. | |
| Default implementation returns basic metadata derived from class name.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Reset the environment and return initial observation.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Async version of reset. Default implementation calls sync reset.</p> <p>Override to provide true async implementation.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Take a step in the environment.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Async version of step. Default implementation calls sync step.</p> <p>Override to provide true async implementation.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Server operation mode.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Server health status values.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>WebSocket error codes for structured error handling.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Base class for all environment actions.</p> <p>All action subclasses should inherit from this base class. | |
| Uses Pydantic for automatic validation and serialization.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Base class for all environment observations.</p> <p>All observation subclasses should inherit from this base class. | |
| Uses Pydantic for automatic validation and serialization.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Request model for environment reset.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Response model for environment reset.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Request model for environment step.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Response model for environment step.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Base class for WebSocket messages with shared configuration.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Base class for environment state.</p> <p>Represents internal environment state, separate from observations.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Result of code execution containing stdout, stderr, and exit code.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Metadata about an environment for documentation and UI purposes.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Response model for the combined schema endpoint.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Response model for health check endpoint.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>WebSocket message to reset the environment.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>WebSocket message to execute a step.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>WebSocket message to request current state.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>WebSocket message to close the session.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>WebSocket response containing an observation.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>WebSocket response containing environment state.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>WebSocket response for errors.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Configuration for concurrent environment sessions.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Status of server capacity for concurrent sessions.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create status from active and max session counts.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Information about an active session.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Base exception for all OpenEnv errors.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Raised when an environment is misconfigured for concurrent sessions.</p> <p>This error is raised during server startup when max_concurrent_envs > 1 | |
| is specified for an environment that is not marked as SUPPORTS_CONCURRENT_SESSIONS.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Raised when the server cannot accept new sessions due to capacity limits.</p> <p>This error is raised when a new WebSocket connection is attempted but | |
| the server has already reached max_concurrent_envs active sessions.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Raised when attempting to access a session that does not exist.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Raised when a session cannot be created.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Raised when the environment factory fails to create an instance.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>HTTP server wrapper for Environment instances.</p> <p>This class wraps an Environment and exposes its reset(), step(), and state | |
| methods as HTTP and WebSocket endpoints compatible with EnvClient.</p> <p>The server expects:</p> <ul><li>Action deserialization: Converts JSON dict to Action subclass</li> <li>Observation serialization: Converts Observation subclass to JSON dict</li></ul> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get the current capacity status of the server.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get information about a specific session.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Register HTTP routes on a FastAPI application.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create a FastAPI application with or without web interface.</p> <p>This function creates a FastAPI app with the web interface enabled by default, | |
| including README integration for better user experience.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create a FastAPI application with comprehensive documentation.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Log entry for an action taken.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Current episode state for the web interface.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Manages the web interface for an environment.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Connect a new WebSocket client.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Disconnect a WebSocket client.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get current environment state.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Reset the environment and update state.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Execute a step in the environment and update state.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create a FastAPI application with web interface for the given environment.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Convert JSON dict to Action instance using Pydantic validation.</p> <p>MCP action types (<code>list_tools</code>, <code>call_tool</code>) are recognised | |
| automatically via the <code>"type"</code> discriminator field, regardless of | |
| the environment’s configured <code>action_cls</code>. All other payloads | |
| fall through to <code>action_cls.model_validate()</code>.</p> <p>For special cases (e.g., tensor fields, custom type conversions), | |
| use deserialize_action_with_preprocessing().</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Convert JSON dict to Action instance with preprocessing for special types.</p> <p>This version handles common type conversions needed for web interfaces:</p> <ul><li>Converting lists/strings to tensors for ‘tokens’ field</li> <li>Converting string action_id to int</li> <li>Other custom preprocessing as needed</li></ul></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Convert Observation instance to JSON-compatible dict using Pydantic.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Combines multiple transforms into a single transform.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Default transform that passes through unchanged.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Configuration for a simple GET endpoint.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Register multiple GET endpoints from configuration.</p></div> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Async environment client for persistent sessions.</p> <p>This client maintains a persistent WebSocket connection to an environment | |
| server, enabling efficient multi-step interactions. Each client instance | |
| corresponds to a dedicated environment session on the server.</p> <p>The client is async by default. For synchronous usage, use the <code>.sync()</code> method to get a <code>SyncEnvClient</code> wrapper.</p> <p>Features:</p> <ul><li>Lower latency for sequential interactions</li> <li>Session state is maintained server-side</li> <li>Better suited for long-running episodes</li> <li>Async by default for modern Python async/await patterns</li></ul> <p>Examples:</p> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create an environment client by spinning up a Docker container.</p> <p>Returns a bootstrap handle so the same call works from both async and | |
| synchronous code: <code>await</code> it for the connected async client, or chain <code>.sync()</code> for a connected <code>SyncEnvClient</code> (e.g. a TRL GRPO rollout loop | |
| that cannot <code>await</code>). Bootstrap is lazy — the container starts when the | |
| handle is resolved.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create a client from a Hugging Face Space.</p> <p>Returns a bootstrap handle: <code>await</code> it for the connected async client, or | |
| chain <code>.sync()</code> for a connected <code>SyncEnvClient</code>. Bootstrap is lazy — the | |
| Space starts when the handle is resolved.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create and connect a new session against the same environment server.</p> <p>The child session is tracked by this parent and closed when the parent | |
| is closed. Server-side capacity still applies: when the server is at <code>MAX_CONCURRENT_ENVS</code>, opening the child WebSocket can fail and is | |
| surfaced as a connection error.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Return a synchronous wrapper around this async client.</p> <p>Use this method when you need synchronous access to the environment | |
| without async/await syntax. This is useful for:</p> <ul><li>Integration with synchronous codebases</li> <li>Interactive/REPL usage</li> <li>Stopping async from “infecting” the call stack</li></ul> <!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Synchronous wrapper around an async EnvClient.</p> <p>This class provides a synchronous interface to an async EnvClient, | |
| making it easier to use in synchronous code or to stop async from | |
| “infecting” the entire call stack.</p> <p>The wrapper executes async operations on a dedicated background event loop | |
| so connection state remains bound to a single loop.</p> <p>For guaranteed resource cleanup, use <code>with SyncEnvClient(...)</code> or call <code>close()</code> explicitly. <code>__del__</code> is best-effort only and may not run | |
| reliably (for example, during interpreter shutdown).</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Close the connection and clean up resources.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Establish connection to the server.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Close the connection.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create a new synchronous session against the same environment server.</p> <p>The child session is tracked by this parent and closed when the parent | |
| is closed. Call this after the parent has connected, because the child | |
| reuses the parent’s current base URL. Server-side capacity still | |
| applies: when the server is at <code>MAX_CONCURRENT_ENVS</code>, opening the child | |
| WebSocket can fail and is surfaced as a connection error.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Reset the environment.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get the current environment state.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Execute an action in the environment.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Environment client that works with raw dictionaries instead of typed classes.</p> <p>This client doesn’t require installing environment-specific packages, making it | |
| ideal for:</p> <ul><li>Connecting to remote servers without installing their packages</li> <li>Quick prototyping and testing</li> <li>Environments where type safety isn’t needed</li> <li>Security-conscious scenarios where you don’t want to run remote code</li></ul> <p>The trade-off is that you lose type safety and IDE autocomplete for actions | |
| and observations. Instead of typed objects, you work with plain dictionaries.</p> <!> <p><code>GenericEnvClient</code> inherits <code>from_docker_image()</code> and <code>from_env()</code> from <code>EnvClient</code>, so you can use it with Docker containers and HuggingFace | |
| Spaces without any package installation.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A dictionary subclass for creating actions when using GenericEnvClient.</p> <p>This provides a semantic wrapper around dictionaries to make code more | |
| readable when working with GenericEnvClient. It behaves exactly like a | |
| dict but signals intent that this is an action for an environment.</p> <!> <p><code>GenericAction</code> is just a dict with a constructor that accepts keyword | |
| arguments. It’s provided for symmetry with typed Action classes and | |
| to make code more readable.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A single tool/function call returned by the model.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Normalized response from an LLM, with optional tool calls.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Convert to an OpenAI-format assistant message dict.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Abstract base for LLM endpoint clients.</p> <p>Subclass and implement <code>complete()</code> for your protocol.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Send a prompt, return the text response.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Send messages with tool definitions, return a normalized response.</p> <p>Messages use OpenAI-format dicts (<code>{"role": "...", "content": "..."}</code>). | |
| Tools use MCP tool definitions; they are converted internally.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Client for OpenAI-compatible APIs.</p> <p>Works with: OpenAI, vLLM, TGI, Ollama, HuggingFace Inference API, | |
| or any endpoint that speaks the OpenAI chat completions format.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Send a chat completion request.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Client for Anthropic’s Messages API.</p> <p>Requires the <code>anthropic</code> package (lazy-imported at construction time).</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create an LLM client for a hosted provider.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Represents the result of one environment step.</p></div> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Base class for environments that expose tools via MCP (Model Context Protocol).</p> <p>MCPEnvironment bridges FastMCP servers with OpenEnv’s Gym-style API, allowing | |
| agents to discover and invoke MCP tools through the standard step() interface.</p> <p>The class automatically handles:</p> <ul><li>ListToolsAction: Returns available tools from the MCP server</li> <li>CallToolAction: Invokes a specific tool with arguments</li></ul> <p>All other actions are delegated to the abstract _step_impl() method, | |
| which subclasses must implement.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Clean up resources used by the environment.</p> <p>This method cleans up the MCP client and any other resources. | |
| Subclasses should call super().close() if they override this method.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Execute Python code with tools available as callables.</p> <p>This enables the CodeAct pattern where agents write Python code | |
| that calls tools directly as functions, avoiding JSON-RPC overhead.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get callable functions for code mode.</p> <p>Returns tool functions as direct Python callables, enabling code mode | |
| where agents write Python code that calls tools directly (no JSON-RPC | |
| overhead). Mode-specific tools are filtered by the current mode.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Context manager for MCP client sessions.</p> <p>This wrapper serves two purposes:</p> <ol><li><p><strong>Null guard</strong> — raises a clear error if <code>close()</code> has already | |
| been called (<code>mcp_client</code> is <code>None</code>).</p></li> <li><p><strong>AsyncExitStack adapter</strong> — FastMCP’s <code>Client.__aenter__</code> creates a background <code>asyncio.Task</code> for session management. | |
| When entered directly via <code>AsyncExitStack</code> in the HTTP session | |
| path (<code>_create_session</code>), this task can be cancelled by ASGI | |
| harnesses (e.g. Starlette <code>TestClient</code>) between requests, | |
| corrupting session state. Wrapping in an <code>asynccontextmanager</code> generator isolates the task lifecycle: the generator frame keeps <code>async with client:</code> suspended at <code>yield</code>, so cleanup only | |
| runs when the stack explicitly closes the generator — not when | |
| the event loop cancels orphaned tasks.</p></li></ol> <p>Delegates to FastMCP’s <code>Client</code> context manager which is | |
| reentrant: the first entry opens the transport and subsequent | |
| (nested) entries simply increment an internal reference counter. | |
| The transport is closed only when the outermost context exits.</p> <p>No external lock is needed because <code>Client._connect</code> / <code>Client._disconnect</code> already serialise connection state changes | |
| through their own <code>anyio.Lock</code>.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Execute an action in the environment.</p> <p>This method routes MCP-specific actions (ListToolsAction, CallToolAction) | |
| to the appropriate handlers, while delegating all other actions to | |
| the subclass’s _step_impl() method.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Async step that routes MCP actions without going through run_async_safely.</p> <p>The WebSocket handler calls this directly on the outer event loop, where | |
| the MCP session is already open, avoiding the thread/event-loop deadlock | |
| that occurs when the sync step() path is used via run_in_executor.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Decorator for registering mode-aware tools.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Standard JSON-RPC 2.0 error codes.</p> <p>See: <a href="https://www.jsonrpc.org/specification#error_object" rel="nofollow">https://www.jsonrpc.org/specification#error_object</a></p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Supported MCP method names.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>JSON-RPC 2.0 error object.</p> <p>See: <a href="https://www.jsonrpc.org/specification#error_object" rel="nofollow">https://www.jsonrpc.org/specification#error_object</a></p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create an error from a standard error code.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>JSON-RPC 2.0 request object.</p> <p>See: <a href="https://www.jsonrpc.org/specification#request_object" rel="nofollow">https://www.jsonrpc.org/specification#request_object</a></p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>JSON-RPC 2.0 response object.</p> <p>Per JSON-RPC 2.0 spec, a response has either ‘result’ or ‘error’, not both. | |
| This model excludes None values during serialization to comply with the spec.</p> <p>See: <a href="https://www.jsonrpc.org/specification#response_object" rel="nofollow">https://www.jsonrpc.org/specification#response_object</a></p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create an error response from a standard error code.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Serialize to dict, excluding result or error when None (JSON-RPC compliance).</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Serialize to JSON string, excluding result or error when None (JSON-RPC compliance).</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create a success response.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Strongly typed MCP tool specification.</p> <p>Follows the MCP ToolSpec format for tool discovery. | |
| See: <a href="https://modelcontextprotocol.io/specification/2025-06-18/server/tools" rel="nofollow">https://modelcontextprotocol.io/specification/2025-06-18/server/tools</a></p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Types of errors that can occur during tool execution.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Structured error for tool execution failures.</p> <p>This is used for transport/framework errors, NOT for errors returned | |
| by the tool itself (those go in the result field).</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Request list of available tools from the environment.</p> <p>This action triggers MCP’s tools/list operation and returns | |
| all available tools with their schemas. Does NOT require reset() | |
| to be called first.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Call a specific tool via MCP.</p> <p>This action triggers MCP’s tools/call operation with the | |
| specified tool name and arguments.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Response containing available tools.</p> <p>Returned when processing a ListToolsAction.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Response from tool execution.</p> <p>Contains the tool’s result or an error if the call failed. | |
| Tool-specific errors (from the tool itself) are included in the result. | |
| Transport/framework errors use the error field.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>WebSocket message for MCP JSON-RPC requests.</p> <p>Allows direct MCP access via WebSocket for production inference, | |
| bypassing the step() API.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>WebSocket response for MCP JSON-RPC.</p> <p>Contains the JSON-RPC response from the MCP server.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Base class for MCP clients with tool discovery.</p> <p>This class provides the common <code>list_tools()</code> method for discovering | |
| available tools from an MCP-enabled environment. Subclasses implement | |
| specific interaction patterns (tool-calling or CodeAct).</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Close client resources.</p> <p>In production MCP mode, this also closes the server-side persistent | |
| MCP session (best effort) before closing websocket/provider resources.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Discover available tools from the environment.</p> <!></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Async client for tool-calling style MCP interactions.</p> <p>Each step invokes a single tool. Use this for traditional function-calling | |
| agent patterns where the agent decides which tool to call next.</p> <p>This client provides convenience methods for tool discovery and invocation:</p> <ul><li><code>list_tools()</code>: Get all available tools with their schemas</li> <li><code>call_tool(name, **kwargs)</code>: Invoke a tool by name with arguments</li></ul> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Call a tool by name.</p> <p>This is a convenience method that creates a CallToolAction, executes it, | |
| and returns the result directly. For more control, use <code>step()</code> with | |
| a CallToolAction directly.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get a specific tool by name.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Check if a tool exists.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Abstract base class for reward computation.</p> <p>A Rubric computes a reward signal from an action and observation. | |
| Subclasses implement forward() to define the reward logic.</p> <!> <p>Child rubrics are auto-registered when assigned as attributes, | |
| enabling hierarchical composition and introspection.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Iterate over immediate child rubrics.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Compute the reward. Implement this in subclasses.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Access a nested rubric by dot-separated path.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Load rubric configuration from checkpoint.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Iterate over immediate child rubrics with names.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Iterate over all descendant rubrics with dot-separated names.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Register a hook called after forward().</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Register a hook called before forward().</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Reset any internal state. Override in subclasses if needed.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Iterate over all descendant rubrics (depth-first).</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Serialize rubric configuration for checkpointing.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Run rubrics in order, fail-fast on zero.</p> <p>Runs child rubrics in order. If any returns 0, stops immediately | |
| and returns 0. This implements hierarchical gating patterns where | |
| syntax checks run before execution checks.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Run rubrics in order, return 0 if any returns 0. Sync version.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Threshold wrapper - returns 0 if child score is below threshold.</p> <p>Useful for hard constraints like “must pass 50% of tests”.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Return child score if >= threshold, else 0. Sync version.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Weighted combination of child rubrics.</p> <p>Standard aggregation pattern for multi-criteria evaluation.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Return weighted sum of child scores. Sync version.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Container for dynamic lists of rubrics.</p> <p>Analogous to nn.ModuleList. Does not define aggregation - use within | |
| a parent rubric that implements custom logic.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Add a rubric to the list.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Add multiple rubrics to the list.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>RubricList does not define aggregation - override in parent.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Container for named rubrics with keyed access.</p> <p>Analogous to nn.ModuleDict. Enables keyed access for multi-task | |
| environments where different tasks require different rubrics.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>RubricDict does not define aggregation - override in parent.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Iterate over (key, rubric) pairs.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Iterate over keys.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Update with rubrics from a dictionary.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Iterate over rubrics.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Abstract base for rubrics that score based on full trajectories.</p> <p>Subclasses implement:</p> <ul><li>score_trajectory(): Compute final score from trajectory</li> <li>compute_step_rewards(): Define credit assignment strategy</li></ul> <p>The <strong>call</strong> method accumulates steps and returns rewards according | |
| to the subclass’s implementation.</p> <p>IMPORTANT: Trajectories are stored in CPU memory to avoid GPU pressure. | |
| Environments with GPU tensors in observations must move them to CPU | |
| before returning from step().</p> <p>Known limitation: Very long episodes (thousands of steps) may consume | |
| significant CPU memory. For such cases, consider streaming rubrics.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Compute per-step rewards from the accumulated trajectory.</p> <p>Define your credit assignment strategy here (e.g., discounting, | |
| assigning all credit to specific steps, etc.).</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Accumulate step and return reward.</p> <p>Returns intermediate_reward until done, then computes trajectory score.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Load configuration from checkpoint.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Clear accumulated trajectory. Call on env.reset().</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Score the complete trajectory. Return 0.0-1.0.</p> <p>Called when observation.done=True.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Serialize configuration (not trajectory data).</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>TrajectoryRubric with exponential discounting for credit assignment.</p> <!> <p>With gamma=0.99, later steps get higher reward (they’re “closer” to the outcome). | |
| With gamma=1.0, all steps get equal reward. | |
| With gamma=0.0, only the final step gets reward.</p> <p>This is the standard temporal discounting used in reinforcement learning, | |
| applied retroactively once the episode outcome is known.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Apply exponential discounting from final reward.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Serialize configuration.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Rubric that uses an LLM to evaluate agent actions/observations.</p> <p>The prompt template is formatted with <code>{action}</code> and <code>{observation}</code> placeholders. The LLM response is parsed for a numeric score.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Evaluate by sending a prompt to the LLM and parsing the score.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Serialize rubric configuration.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Information about a repository.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Client for connecting to an external Gitea server.</p> <p>This client is optimized for task-based isolation where:</p> <ul><li>Multiple tasks share the same Gitea instance</li> <li>Each task has its own isolated workspace</li> <li>Fast reset() via git operations (no server restart)</li> <li>Repos are pre-migrated to Gitea once</li></ul> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Clone a repository to the workspace at a specific commit.</p> <p>This creates a fresh clone optimized for task isolation.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Execute a git command in the workspace.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get current commit hash of a workspace repository.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>List all repositories in Gitea.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Fast reset of workspace to base state (optimized for task resets).</p> <p>This is much faster than re-cloning. It:</p> <ol><li>Checks out the target commit</li> <li>Resets to that commit (hard)</li> <li>Cleans untracked files</li></ol></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Wait for Gitea server to be ready.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Check if a repository exists in workspace.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Abstract base class for container providers.</p> <p>Providers implement this interface to support different container platforms:</p> <ul><li>LocalDockerProvider: Runs containers on local Docker daemon</li> <li>KubernetesProvider: Runs containers in Kubernetes cluster</li> <li>FargateProvider: Runs containers on AWS Fargate</li> <li>CloudRunProvider: Runs containers on Google Cloud Run</li></ul> <p>The provider manages a single container lifecycle and provides the base URL | |
| for connecting to it.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Release provider-held resources (e.g. SDK clients, connections).</p> <p>Defaults to a no-op so existing providers are unaffected. Providers that | |
| hold external resources beyond the container itself (such as a cloud SDK | |
| client) override this to release them; it is also invoked on context- | |
| manager exit. Lightweight providers need not override it.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Start a container from the specified image.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Stop and remove the running container.</p> <p>This cleans up the container that was started by start_container().</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Wait for the container to be ready to accept requests.</p> <p>This typically polls the /health endpoint until it returns 200.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Container provider for local Docker daemon.</p> <p>This provider runs containers on the local machine using Docker. | |
| Useful for development and testing.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Start a Docker container locally.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Stop and remove the Docker container.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Wait for container to be ready by polling /health endpoint.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Container provider that uses Docker Swarm services for local concurrency.</p> <p>This provider creates a replicated Swarm service backed by the local Docker | |
| engine. The built-in load-balancer fans requests across the replicas, | |
| allowing multiple container instances to run concurrently on the developer | |
| workstation (mirroring the workflow described in the Docker stack docs).</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Start (or scale) a Swarm service for the given image.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Remove the Swarm service (and keep the Swarm manager running).</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Wait for at least one replica to become healthy by polling /health.</p> <p>With Swarm’s load balancer, requests round-robin across replicas, | |
| so this only verifies that at least one replica is responding. Some | |
| replicas may still be starting when this returns.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Abstract base class for runtime providers that are not container providers. | |
| Providers implement this interface to support different runtime platforms:</p> <ul><li>UVProvider: Runs environments via <code>uv run</code></li></ul> <p>The provider manages a single runtime lifecycle and provides the base URL | |
| for connecting to it.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Start the runtime.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Stop the runtime.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Wait for the runtime to be ready to accept requests.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>RuntimeProvider implementation backed by <code>uv run</code>.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Start the environment via <code>uv run</code>.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Stop the environment.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Wait for the environment to become ready.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Container provider that runs environments in Daytona cloud sandboxes.</p> <p>Example:</p> <blockquote><blockquote><blockquote><p>provider = DaytonaProvider(api_key=“your-key”) | |
| image = DaytonaProvider.image_from_dockerfile(“envs/echo_env/server/Dockerfile”) | |
| base_url = provider.start_container(image) | |
| provider.wait_for_ready(base_url) | |
| provider.stop_container()</p></blockquote></blockquote></blockquote> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Validate a Dockerfile and return a <code>dockerfile:</code> URI for <code>start_container</code>.</p> <p>Eagerly validates the Dockerfile (existence, COPY sources, | |
| BuildKit stripping) and stores the processed content in an | |
| internal registry. The actual <code>daytona.Image</code> is created | |
| later inside <code>start_container</code>.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get a fresh signed preview URL (valid for 24h).</p> <p>Daytona signed URLs expire after at most 24 hours. Call this to | |
| get a new one for long-running sessions. The returned URL points | |
| to the same sandbox — clients will need to reconnect using it.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create a Daytona sandbox from a Docker image or snapshot.</p> <p>Daytona does not execute the image’s CMD (known bug — ENTRYPOINT | |
| runs, CMD does not). The server command is resolved in order:</p> <ol><li>Explicit <code>cmd</code> passed to the constructor.</li> <li><code>cmd</code> key in <code>**kwargs</code> (popped before forwarding).</li> <li>Auto-discovered from <code>openenv.yaml</code> inside the sandbox.</li> <li><code>CMD</code> parsed from the Dockerfile (when <em>image</em> came from <code>image_from_dockerfile</code>).</li></ol></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Delete the Daytona sandbox.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Remove BuildKit <code>--mount=...</code> flags from <code>RUN</code> instructions.</p> <p>Handles single-line flags, multi-line continuations, and multiple <code>--mount</code> flags spread across continuation lines. Only leading <code>--mount</code> flags are removed (before the actual command starts).</p> <p>Daytona’s <code>Image.from_dockerfile</code> does not support BuildKit <code>--mount</code> syntax. This helper strips the flags so that standard | |
| Dockerfiles (like the ones generated by <code>openenv build</code>) can | |
| be used directly.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Poll the /health endpoint until the sandbox is ready.</p> <p>Uses a longer default timeout (120s) than Docker providers because | |
| Daytona sandboxes may have cold-start latency.</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Container provider backed by Azure Container Apps Sandboxes.</p> <p><code>start_container</code>’s <code>image</code> is an ACA sandbox source (<code>disk:<name></code> for a | |
| public disk image or <code>disk-id:<id></code> for a private one), not a Docker | |
| registry image. The provider boots an OpenEnv server inside the sandbox, | |
| exposes it on an anonymous ACA port, and returns an <code>https://</code> URL that <code>EnvClient</code> connects to over <code>wss://</code>.</p> <p>The environment runs untrusted code, so the provider is secure by default | |
| (proposed RFC 002 security invariants): it requires explicit <code>anonymous_port=True</code> ingress (S2), enforces https/wss transport (S1), offers <code>deny_all_egress()</code> to block the cloud metadata/IMDS endpoint (S3), and | |
| never surfaces raw sandbox output unless <code>surface_server_logs=True</code> (S4).</p> <p>Validated end to end against a live ACA sandbox group; the underlying <code>azure-containerapps-sandbox</code> SDK is preview, so pin it and re-validate | |
| after upgrades (see <code>tests/test_core/test_aca_provider_integration.py</code>).</p> <p><code>close()</code> stops the active sandbox <em>and</em> releases the underlying SDK client, | |
| so prefer using the provider as a context manager (or call <code>close()</code> explicitly) for deterministic cleanup. <code>close()</code>/<code>__enter__</code>/<code>__exit__</code> are | |
| defined on <code>ContainerProvider</code> (default no-op), so a caller holding a bare <code>ContainerProvider</code> reference can release the client polymorphically.</p> <p>Only one sandbox is active per provider: calling <code>start_container</code> again | |
| before <code>stop_container()</code>/<code>close()</code> raises <code>RuntimeError</code> rather than | |
| orphaning the running sandbox.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Stop the active sandbox and close the underlying SDK client.</p> <p>Overrides the base no-op so a caller can release the preview SDK client | |
| deterministically (also invoked on context-manager exit). The base <code>ContainerProvider</code> defines <code>close()</code>/<code>__enter__</code>/<code>__exit__</code>, so callers | |
| holding a bare <code>ContainerProvider</code> can release resources polymorphically.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Build a default-deny ACA <code>EgressPolicy</code> (RFC 002 security invariant S3).</p> <p>Untrusted RL/agent code should not be able to exfiltrate data or reach | |
| the cloud metadata/IMDS endpoint. This returns an <code>EgressPolicy</code> whose | |
| default action is <code>Deny</code>, with an optional host allowlist (for example a | |
| model endpoint or package registry the environment legitimately needs).</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Start an OpenEnv server in an ACA sandbox and return its base URL.</p> <p><code>image</code> is an ACA sandbox <em>source</em>, not a Docker/OCI registry image: a | |
| bare string or <code>disk:<name></code> for a public disk image, or <code>disk-id:<id></code> for a private one. It may be omitted when supplied to the constructor. | |
| A value that looks like a container image (a registry path or <code>name:tag</code>) is rejected with guidance. Only port 8000 is supported. <code>**kwargs</code> accepts per-start overrides (<code>cmd</code>, <code>labels</code>, <code>egress_policy</code>, <code>anonymous_port</code>); unknown options raise <code>ValueError</code> so typos cannot silently change sandbox behavior.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Delete the active ACA sandbox.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Wait for the ACA-hosted OpenEnv server to answer on <code>/health</code>.</p> <p>A <code>200</code> on <code>/health</code> proves HTTP reachability but not that the exposed | |
| ACA port proxies the <code>/ws</code> WebSocket upgrade <code>EnvClient</code> needs; the | |
| integration test covers the full <code>wss://</code> round-trip. If the captured | |
| server process dies during startup this raises <code>RuntimeError</code> (sandbox | |
| output is withheld unless <code>surface_server_logs=True</code>; see RFC 002 S4).</p></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Container provider that runs environments in Modal sandboxes.</p> <p><code>start_container</code>’s <code>image</code> is either a registry tag | |
| (<code>"echo-env:latest"</code>) or a <code>"dockerfile:<path>"</code> reference returned by <code>image_from_dockerfile</code>. The server is exposed on an encrypted Modal | |
| tunnel and the returned <code>https://</code> URL is what <code>EnvClient</code> connects to | |
| over <code>wss://</code>.</p> <p>The environment runs untrusted code, so the provider is secure by default: | |
| it enforces https/wss transport, treats the tunnel URL as a bearer secret | |
| (never interpolated into errors), and never surfaces raw sandbox output | |
| unless <code>surface_server_logs=True</code>.</p> <p>Only one sandbox is active per provider: calling <code>start_container</code> again | |
| before <code>stop_container()</code>/<code>close()\` raises \`RuntimeError\` rather than orphaning the running sandbox. \`close()</code> (and context-manager exit) stops | |
| the active sandbox.</p> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Stop the active sandbox.</p> <p>Overrides the base no-op so a caller holding a bare <code>ContainerProvider</code> reference can release the sandbox polymorphically (also invoked on | |
| context-manager exit). <code>ModalProvider</code> holds no separate SDK client, so | |
| this is equivalent to <code>stop_container()</code>.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Validate a Dockerfile and return a <code>dockerfile:</code> URI for <code>start_container</code>.</p> <p>Eagerly validates the Dockerfile (existence, COPY sources) and stores | |
| its content in an internal registry. The actual <code>modal.Image</code> is | |
| created later inside <code>start_container</code>.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Create a Modal sandbox from a Docker image or Dockerfile.</p> <p>The sandbox is started with a keep-alive process and the server | |
| command is launched via <code>exec</code> afterwards, mirroring the discovery | |
| flow used by other cloud providers. The server command is resolved in | |
| order:</p> <ol><li>Explicit <code>cmd</code> passed to the constructor.</li> <li><code>cmd</code> key in <code>**kwargs</code> (popped before forwarding).</li> <li>Auto-discovered from <code>openenv.yaml</code> inside the sandbox.</li> <li><code>CMD</code> parsed from the Dockerfile (when <em>image</em> came from <code>image_from_dockerfile</code>).</li></ol></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Terminate the Modal sandbox.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Poll the /health endpoint until the sandbox is ready.</p> <p>Uses a longer default timeout (120s) than local Docker providers | |
| because Modal sandboxes may have cold-start latency.</p></div></div> <!> <p></p>`,1);function zc(na,oa){Ic(oa,!1),Ac(()=>{new URLSearchParams(window.location.search).get("fw")}),Jc();var Wo=Pc();jc("sny15i",s=>{var c=Rc();Uc(c,"content",Ec),d(s,c)});var Go=e(v(Wo),2);Cc(Go,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var Po=e(Go,2);u(Po,{title:"Core API",local:"core-api",headingTag:"h1"});var Vo=e(Po,8);u(Vo,{title:"Server",local:"server",headingTag:"h2"});var Zo=e(Vo,2);u(Zo,{title:"Environment server primitives",local:"openenv.core.Message",headingTag:"h3"});var b=e(Zo,2),ra=o(b);n(ra,{name:"class openenv.core.Message",anchor:"openenv.core.Message",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L19",parameters:""}),t(4),r(b);var h=e(b,2),Yo=o(h);n(Yo,{name:"class openenv.core.ModelTokenizer",anchor:"openenv.core.ModelTokenizer",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L29",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}]});var _=e(Yo,6),ta=o(_);n(ta,{name:"apply_chat_template",anchor:"openenv.core.ModelTokenizer.apply_chat_template",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L37",parameters:[{name:"conversation",val:": list"},{name:"tokenize",val:": bool = True"},{name:"return_tensors",val:": str | None = None"},{name:"**kwargs",val:": typing.Any"}],parametersDescription:[{anchor:"openenv.core.ModelTokenizer.apply_chat_template.conversation",description:`<strong>conversation</strong> (<code>list[Message]</code>) — | |
| List of message dictionaries with ‘role’ and ‘content’.`,name:"conversation"},{anchor:"openenv.core.ModelTokenizer.apply_chat_template.tokenize",description:`<strong>tokenize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to tokenize the output.`,name:"tokenize"},{anchor:"openenv.core.ModelTokenizer.apply_chat_template.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code>, <em>optional</em>) — | |
| Format for returned tensors (‘pt’ for PyTorch).`,name:"return_tensors"},{anchor:"openenv.core.ModelTokenizer.apply_chat_template.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Additional arguments.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Formatted and optionally tokenized conversation.</p> | |
| `}),t(2),r(_);var zo=e(_,2),aa=o(zo);n(aa,{name:"decode",anchor:"openenv.core.ModelTokenizer.decode",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L61",parameters:[{name:"token_ids",val:": typing.Any"},{name:"skip_special_tokens",val:": bool = False"},{name:"**kwargs",val:": typing.Any"}],parametersDescription:[{anchor:"openenv.core.ModelTokenizer.decode.token_ids",description:`<strong>token_ids</strong> (<code>Any</code>) — | |
| Token IDs to decode.`,name:"token_ids"},{anchor:"openenv.core.ModelTokenizer.decode.skip_special_tokens",description:`<strong>skip_special_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to skip special tokens in output.`,name:"skip_special_tokens"},{anchor:"openenv.core.ModelTokenizer.decode.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Additional arguments.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Decoded text string.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>str</code></p> | |
| `}),t(2),r(zo),r(h);var y=e(h,2),sa=o(y);n(sa,{name:"class openenv.core.Transform",anchor:"openenv.core.Transform",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L115",parameters:[]}),t(4),r(y);var f=e(y,2),Fo=o(f);n(Fo,{name:"class openenv.core.Environment",anchor:"openenv.core.Environment",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L137",parameters:[{name:"transform",val:": typing.Optional[openenv.core.env_server.interfaces.Transform[~ObsT]] = None"},{name:"rubric",val:": typing.Optional[ForwardRef('Rubric')] = None"}],parametersDescription:[{anchor:"openenv.core.Environment.transform",description:`<strong>transform</strong> (<em>Transform</em>, <em>optional</em>) — | |
| Optional transform to apply to observations.`,name:"transform"},{anchor:"openenv.core.Environment.rubric",description:`<strong>rubric</strong> (<em>Rubric</em>, <em>optional</em>) — | |
| Optional rubric for reward computation. When provided, the | |
| rubric’s output can be used to set the observation’s reward in step().`,name:"rubric"},{anchor:"openenv.core.Environment.SUPPORTS_CONCURRENT_SESSIONS",description:`<strong>SUPPORTS_CONCURRENT_SESSIONS</strong> (<em>bool</em>) — | |
| Whether this environment supports concurrent sessions. When <code>True</code>, | |
| multiple WebSocket connections can each have their own environment | |
| instance (up to <code>max_concurrent_envs</code>). When <code>False</code> (default), | |
| the environment should only be used with a single session at a time.</p> | |
| <p>Set this to <code>True</code> in your subclass if the environment uses proper | |
| session isolation (unique working dirs, no shared mutable state, and | |
| external resources that can handle concurrent access).`,name:"SUPPORTS_CONCURRENT_SESSIONS"},{anchor:"openenv.core.Environment.rubric",description:`<strong>rubric</strong> (<em>Rubric</em>, <em>optional</em>) — | |
| Optional rubric for computing rewards. Set in <code>__init__</code> and use in | |
| <code>step()</code> to compute observation rewards. Training infrastructure can | |
| access it for introspection:`,name:"rubric"}]});var M=e(Fo,6),ia=o(M);n(ia,{name:"close",anchor:"openenv.core.Environment.close",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L348",parameters:[]}),t(4),r(M);var w=e(M,2),ca=o(w);n(ca,{name:"get_metadata",anchor:"openenv.core.Environment.get_metadata",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L236",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>EnvironmentMetadata</code> with environment information.</p> | |
| `}),t(4),r(w);var x=e(w,2),la=o(x);n(la,{name:"reset",anchor:"openenv.core.Environment.reset",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L186",parameters:[{name:"seed",val:": typing.Optional[int] = None"},{name:"episode_id",val:": typing.Optional[str] = None"},{name:"**kwargs",val:": typing.Any"}]}),t(2),r(x);var T=e(x,2),pa=o(T);n(pa,{name:"reset_async",anchor:"openenv.core.Environment.reset_async",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L196",parameters:[{name:"seed",val:": typing.Optional[int] = None"},{name:"episode_id",val:": typing.Optional[str] = None"},{name:"**kwargs",val:": typing.Any"}]}),t(4),r(T);var J=e(T,2),da=o(J);n(da,{name:"step",anchor:"openenv.core.Environment.step",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L208",parameters:[{name:"action",val:": ~ActT"},{name:"timeout_s",val:": typing.Optional[float] = None"},{name:"**kwargs",val:": typing.Any"}]}),t(2),r(J);var Oo=e(J,2),va=o(Oo);n(va,{name:"step_async",anchor:"openenv.core.Environment.step_async",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/interfaces.py#L218",parameters:[{name:"action",val:": ~ActT"},{name:"timeout_s",val:": typing.Optional[float] = None"},{name:"**kwargs",val:": typing.Any"}]}),t(4),r(Oo),r(f);var Xo=e(f,2);u(Xo,{title:"Types",local:"openenv.core.ServerMode",headingTag:"h3"});var j=e(Xo,2),ma=o(j);n(ma,{name:"class openenv.core.ServerMode",anchor:"openenv.core.ServerMode",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L18",parameters:[{name:"value",val:""},{name:"names",val:" = None"},{name:"module",val:" = None"},{name:"qualname",val:" = None"},{name:"type",val:" = None"},{name:"start",val:" = 1"}]}),t(2),r(j);var C=e(j,2),ua=o(C);n(ua,{name:"class openenv.core.HealthStatus",anchor:"openenv.core.HealthStatus",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L25",parameters:[{name:"value",val:""},{name:"names",val:" = None"},{name:"module",val:" = None"},{name:"qualname",val:" = None"},{name:"type",val:" = None"},{name:"start",val:" = 1"}]}),t(2),r(C);var k=e(C,2),ga=o(k);n(ga,{name:"class openenv.core.WSErrorCode",anchor:"openenv.core.WSErrorCode",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L33",parameters:[{name:"value",val:""},{name:"names",val:" = None"},{name:"module",val:" = None"},{name:"qualname",val:" = None"},{name:"type",val:" = None"},{name:"start",val:" = 1"}]}),t(2),r(k);var U=e(k,2),ba=o(U);n(ba,{name:"class openenv.core.Action",anchor:"openenv.core.Action",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L50",parameters:[{name:"metadata",val:": typing.Dict[str, typing.Any] = <factory>"}]}),t(4),r(U);var I=e(U,2),ha=o(I);n(ha,{name:"class openenv.core.Observation",anchor:"openenv.core.Observation",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L68",parameters:[{name:"done",val:": bool = False"},{name:"reward",val:": bool | int | float | None = None"},{name:"metadata",val:": typing.Dict[str, typing.Any] = <factory>"}]}),t(4),r(I);var A=e(I,2),_a=o(A);n(_a,{name:"class openenv.core.env_server.types.ResetRequest",anchor:"openenv.core.env_server.types.ResetRequest",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L90",parameters:[{name:"seed",val:": typing.Annotated[typing.Optional[int], Ge(ge=0)] = None"},{name:"episode_id",val:": typing.Annotated[typing.Optional[str], MaxLen(max_length=255)] = None"},{name:"**extra_data",val:": typing.Any"}]}),t(2),r(A);var N=e(A,2),ya=o(N);n(ya,{name:"class openenv.core.env_server.types.ResetResponse",anchor:"openenv.core.env_server.types.ResetResponse",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L106",parameters:[{name:"observation",val:": typing.Dict[str, typing.Any]"},{name:"reward",val:": typing.Optional[float] = None"},{name:"done",val:": bool = False"},{name:"metadata",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"}]}),t(2),r(N);var E=e(N,2),fa=o(E);n(fa,{name:"class openenv.core.env_server.types.StepRequest",anchor:"openenv.core.env_server.types.StepRequest",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L125",parameters:[{name:"action",val:": typing.Dict[str, typing.Any]"},{name:"timeout_s",val:": typing.Annotated[typing.Optional[float], Gt(gt=0)] = None"},{name:"request_id",val:": typing.Annotated[typing.Optional[str], MaxLen(max_length=255)] = None"},{name:"**extra_data",val:": typing.Any"}]}),t(2),r(E);var R=e(E,2),Ma=o(R);n(Ma,{name:"class openenv.core.env_server.types.StepResponse",anchor:"openenv.core.env_server.types.StepResponse",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L154",parameters:[{name:"observation",val:": typing.Dict[str, typing.Any]"},{name:"reward",val:": typing.Optional[float] = None"},{name:"done",val:": bool = False"},{name:"metadata",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"}]}),t(2),r(R);var S=e(R,2),wa=o(S);n(wa,{name:"class openenv.core.BaseMessage",anchor:"openenv.core.BaseMessage",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L171",parameters:[]}),t(2),r(S);var L=e(S,2),xa=o(L);n(xa,{name:"class openenv.core.State",anchor:"openenv.core.State",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L180",parameters:[{name:"episode_id",val:": typing.Optional[str] = None"},{name:"step_count",val:": Annotated = 0"},{name:"**extra_data",val:": typing.Any"}]}),t(4),r(L);var D=e(L,2),Ta=o(D);n(Ta,{name:"class openenv.core.env_server.types.CodeExecResult",anchor:"openenv.core.env_server.types.CodeExecResult",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L202",parameters:[{name:"stdout",val:": str"},{name:"stderr",val:": str"},{name:"exit_code",val:": int"}]}),t(2),r(D);var B=e(D,2),Ja=o(B);n(Ja,{name:"class openenv.core.env_server.types.EnvironmentMetadata",anchor:"openenv.core.env_server.types.EnvironmentMetadata",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L210",parameters:[{name:"name",val:": str"},{name:"description",val:": str"},{name:"readme_content",val:": typing.Optional[str] = None"},{name:"version",val:": typing.Optional[str] = None"},{name:"author",val:": typing.Optional[str] = None"},{name:"documentation_url",val:": typing.Optional[str] = None"}]}),t(2),r(B);var W=e(B,2),ja=o(W);n(ja,{name:"class openenv.core.SchemaResponse",anchor:"openenv.core.SchemaResponse",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L227",parameters:[{name:"action",val:": typing.Dict[str, typing.Any]"},{name:"observation",val:": typing.Dict[str, typing.Any]"},{name:"state",val:": typing.Dict[str, typing.Any]"}]}),t(2),r(W);var G=e(W,2),Ca=o(G);n(Ca,{name:"class openenv.core.HealthResponse",anchor:"openenv.core.HealthResponse",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L241",parameters:[{name:"status",val:": HealthStatus = <HealthStatus.HEALTHY: 'healthy'>"}]}),t(2),r(G);var P=e(G,2),ka=o(P);n(ka,{name:"class openenv.core.WSResetMessage",anchor:"openenv.core.WSResetMessage",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L277",parameters:[{name:"type",val:": typing.Literal['reset'] = 'reset'"},{name:"data",val:": typing.Dict[str, typing.Any] = <factory>"}]}),t(2),r(P);var V=e(P,2),Ua=o(V);n(Ua,{name:"class openenv.core.WSStepMessage",anchor:"openenv.core.WSStepMessage",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L287",parameters:[{name:"type",val:": typing.Literal['step'] = 'step'"},{name:"data",val:": typing.Dict[str, typing.Any]"}]}),t(2),r(V);var Z=e(V,2),Ia=o(Z);n(Ia,{name:"class openenv.core.WSStateMessage",anchor:"openenv.core.WSStateMessage",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L296",parameters:[{name:"type",val:": typing.Literal['state'] = 'state'"}]}),t(2),r(Z);var Y=e(Z,2),Aa=o(Y);n(Aa,{name:"class openenv.core.WSCloseMessage",anchor:"openenv.core.WSCloseMessage",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L302",parameters:[{name:"type",val:": typing.Literal['close'] = 'close'"}]}),t(2),r(Y);var z=e(Y,2),Na=o(z);n(Na,{name:"class openenv.core.WSObservationResponse",anchor:"openenv.core.WSObservationResponse",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L317",parameters:[{name:"type",val:": typing.Literal['observation'] = 'observation'"},{name:"data",val:": typing.Dict[str, typing.Any]"}]}),t(2),r(z);var F=e(z,2),Ea=o(F);n(Ea,{name:"class openenv.core.WSStateResponse",anchor:"openenv.core.WSStateResponse",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L328",parameters:[{name:"type",val:": typing.Literal['state'] = 'state'"},{name:"data",val:": typing.Dict[str, typing.Any]"}]}),t(2),r(F);var O=e(F,2),Ra=o(O);n(Ra,{name:"class openenv.core.WSErrorResponse",anchor:"openenv.core.WSErrorResponse",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L337",parameters:[{name:"type",val:": typing.Literal['error'] = 'error'"},{name:"data",val:": typing.Dict[str, typing.Any]"}]}),t(2),r(O);var X=e(O,2),Sa=o(X);n(Sa,{name:"class openenv.core.ConcurrencyConfig",anchor:"openenv.core.ConcurrencyConfig",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L346",parameters:[{name:"max_concurrent_envs",val:": Annotated = 1"},{name:"session_timeout",val:": typing.Annotated[typing.Optional[float], Gt(gt=0)] = None"}]}),t(2),r(X);var Q=e(X,2),Qo=o(Q);n(Qo,{name:"class openenv.core.ServerCapacityStatus",anchor:"openenv.core.ServerCapacityStatus",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L361",parameters:[{name:"active_sessions",val:": Annotated"},{name:"max_sessions",val:": Annotated"}]});var qo=e(Qo,4),La=o(qo);n(La,{name:"from_counts",anchor:"openenv.core.ServerCapacityStatus.from_counts",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L392",parameters:[{name:"active",val:": int"},{name:"max_sessions",val:": int"}]}),t(2),r(qo),r(Q);var q=e(Q,2),Da=o(q);n(Da,{name:"class openenv.core.SessionInfo",anchor:"openenv.core.SessionInfo",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/types.py#L401",parameters:[{name:"session_id",val:": str"},{name:"created_at",val:": float"},{name:"last_activity_at",val:": float"},{name:"step_count",val:": Annotated = 0"},{name:"environment_type",val:": str"}]}),t(2),r(q);var Ho=e(q,2);u(Ho,{title:"Exceptions",local:"openenv.core.OpenEnvError",headingTag:"h3"});var H=e(Ho,2),Ba=o(H);n(Ba,{name:"class openenv.core.OpenEnvError",anchor:"openenv.core.OpenEnvError",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/exceptions.py#L8",parameters:""}),t(2),r(H);var K=e(H,2),Wa=o(K);n(Wa,{name:"class openenv.core.ConcurrencyConfigurationError",anchor:"openenv.core.ConcurrencyConfigurationError",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/exceptions.py#L14",parameters:[{name:"environment_name",val:": str"},{name:"max_concurrent_envs",val:": int"},{name:"message",val:": typing.Optional[str] = None"}]}),t(4),r(K);var $=e(K,2),Ga=o($);n(Ga,{name:"class openenv.core.SessionCapacityError",anchor:"openenv.core.SessionCapacityError",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/exceptions.py#L42",parameters:[{name:"active_sessions",val:": int"},{name:"max_sessions",val:": int"},{name:"message",val:": typing.Optional[str] = None"}]}),t(4),r($);var ee=e($,2),Pa=o(ee);n(Pa,{name:"class openenv.core.SessionNotFoundError",anchor:"openenv.core.SessionNotFoundError",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/exceptions.py#L68",parameters:[{name:"session_id",val:": str"},{name:"message",val:": typing.Optional[str] = None"}]}),t(2),r(ee);var ne=e(ee,2),Va=o(ne);n(Va,{name:"class openenv.core.SessionCreationError",anchor:"openenv.core.SessionCreationError",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/exceptions.py#L80",parameters:[{name:"reason",val:": str"},{name:"message",val:": typing.Optional[str] = None"}]}),t(2),r(ne);var oe=e(ne,2),Za=o(oe);n(Za,{name:"class openenv.core.EnvironmentFactoryError",anchor:"openenv.core.EnvironmentFactoryError",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/exceptions.py#L92",parameters:[{name:"factory_name",val:": str"},{name:"message",val:": typing.Optional[str] = None"}]}),t(2),r(oe);var Ko=e(oe,2);u(Ko,{title:"HTTP server utilities",local:"openenv.core.HTTPEnvServer",headingTag:"h3"});var re=e(Ko,2),$o=o(re);n($o,{name:"class openenv.core.HTTPEnvServer",anchor:"openenv.core.HTTPEnvServer",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/http_server.py#L140",parameters:[{name:"env",val:": Callable[[], Environment]"},{name:"action_cls",val:": Type[Action]"},{name:"observation_cls",val:": Type[Observation]"},{name:"max_concurrent_envs",val:": Optional[int] = None"},{name:"concurrency_config",val:": Optional[ConcurrencyConfig] = None"},{name:"env_name",val:": Optional[str] = None"}]});var er=e($o,10);l(er,{anchor:"openenv.core.HTTPEnvServer.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"ZnJvbSUyMGNvcmUuZW52X3NlcnZlciUyMGltcG9ydCUyMEhUVFBFbnZTZXJ2ZXIlMEFmcm9tJTIwZW52cy5jb2RpbmdfZW52LnNlcnZlciUyMGltcG9ydCUyMENvZGVFeGVjdXRpb25FbnZpcm9ubWVudCUwQWZyb20lMjBlbnZzLmNvZGluZ19lbnYubW9kZWxzJTIwaW1wb3J0JTIwQ29kZUFjdGlvbiUyQyUyMENvZGVPYnNlcnZhdGlvbiUwQSUwQSUyMyUyMFBhc3MlMjBlbnZpcm9ubWVudCUyMGNsYXNzJTIwKGZhY3RvcnklMjBwYXR0ZXJuKSUwQXNlcnZlciUyMCUzRCUyMEhUVFBFbnZTZXJ2ZXIoJTBBJTIwJTIwJTIwJTIwZW52JTNEQ29kZUV4ZWN1dGlvbkVudmlyb25tZW50JTJDJTBBJTIwJTIwJTIwJTIwYWN0aW9uX2NscyUzRENvZGVBY3Rpb24lMkMlMEElMjAlMjAlMjAlMjBvYnNlcnZhdGlvbl9jbHMlM0RDb2RlT2JzZXJ2YXRpb24lMkMlMEElMjAlMjAlMjAlMjBtYXhfY29uY3VycmVudF9lbnZzJTNENCUyQyUwQSklMEElMEElMjMlMjBSZWdpc3RlciUyMHJvdXRlcyUyMHdpdGglMjBGYXN0QVBJJTBBZnJvbSUyMGZhc3RhcGklMjBpbXBvcnQlMjBGYXN0QVBJJTBBYXBwJTIwJTNEJTIwRmFzdEFQSSgpJTBBc2VydmVyLnJlZ2lzdGVyX3JvdXRlcyhhcHAp",highlighted:`<span class="hljs-keyword">from</span> core.env_server <span class="hljs-keyword">import</span> HTTPEnvServer | |
| <span class="hljs-keyword">from</span> envs.coding_env.server <span class="hljs-keyword">import</span> CodeExecutionEnvironment | |
| <span class="hljs-keyword">from</span> envs.coding_env.models <span class="hljs-keyword">import</span> CodeAction, CodeObservation | |
| <span class="hljs-comment"># Pass environment class (factory pattern)</span> | |
| server = HTTPEnvServer( | |
| env=CodeExecutionEnvironment, | |
| action_cls=CodeAction, | |
| observation_cls=CodeObservation, | |
| max_concurrent_envs=<span class="hljs-number">4</span>, | |
| ) | |
| <span class="hljs-comment"># Register routes with FastAPI</span> | |
| <span class="hljs-keyword">from</span> fastapi <span class="hljs-keyword">import</span> FastAPI | |
| app = FastAPI() | |
| server.register_routes(app)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var te=e(er,2),Ya=o(te);n(Ya,{name:"get_capacity_status",anchor:"openenv.core.HTTPEnvServer.get_capacity_status",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/http_server.py#L317",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ServerCapacityStatus</code> with current session counts and availability.</p> | |
| `}),t(2),r(te);var ae=e(te,2),za=o(ae);n(za,{name:"get_session_info",anchor:"openenv.core.HTTPEnvServer.get_session_info",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/http_server.py#L557",parameters:[{name:"session_id",val:": str"}],parametersDescription:[{anchor:"openenv.core.HTTPEnvServer.get_session_info.session_id",description:`<strong>session_id</strong> (<code>str</code>) — | |
| The session ID to query.`,name:"session_id"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>SessionInfo</code> if the session exists, <code>None</code> otherwise.</p> | |
| `}),t(2),r(ae);var nr=e(ae,2),Fa=o(nr);n(Fa,{name:"register_routes",anchor:"openenv.core.HTTPEnvServer.register_routes",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/http_server.py#L626",parameters:[{name:"app",val:": FastAPI"},{name:"mode",val:": ServerMode | str = <ServerMode.SIMULATION: 'simulation'>"}],parametersDescription:[{anchor:"openenv.core.HTTPEnvServer.register_routes.app",description:`<strong>app</strong> (<code>FastAPI</code>) — | |
| FastAPI application instance.`,name:"app"},{anchor:"openenv.core.HTTPEnvServer.register_routes.mode",description:`<strong>mode</strong> (<code>ServerMode</code> or <code>str</code>, <em>optional</em>, defaults to <code>ServerMode.SIMULATION</code>) — | |
| Server mode. In production mode, simulation control endpoints (/reset, /step, | |
| /state) are NOT registered. Only safe endpoints (/health, /schema, /metadata, | |
| /ws) are available.`,name:"mode"}],raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>ValueError</code> — If <code>mode</code> is not a valid <code>ServerMode</code> or string equivalent.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ValueError</code></p> | |
| `}),t(2),r(nr),r(re);var se=e(re,2),Oa=o(se);n(Oa,{name:"openenv.core.create_app",anchor:"openenv.core.create_app",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/http_server.py#L1699",parameters:[{name:"env",val:": Callable[[], Environment]"},{name:"action_cls",val:": Type[Action]"},{name:"observation_cls",val:": Type[Observation]"},{name:"env_name",val:": Optional[str] = None"},{name:"max_concurrent_envs",val:": Optional[int] = None"},{name:"concurrency_config",val:": Optional[ConcurrencyConfig] = None"},{name:"gradio_builder",val:": Optional[Callable[..., Any]] = None"},{name:"custom_tab_name",val:": str = 'Custom'"},{name:"custom_tab_primary",val:": bool = False"},{name:"show_default_tab",val:": bool = True"},{name:"title_override",val:": Optional[str] = None"}],parametersDescription:[{anchor:"openenv.core.create_app.env",description:`<strong>env</strong> (<code>Callable[[], Environment]</code>) — | |
| Environment factory (callable) that creates new instances.`,name:"env"},{anchor:"openenv.core.create_app.action_cls",description:`<strong>action_cls</strong> (<code>Type[Action]</code>) — | |
| The Action subclass this environment expects.`,name:"action_cls"},{anchor:"openenv.core.create_app.observation_cls",description:`<strong>observation_cls</strong> (<code>Type[Observation]</code>) — | |
| The Observation subclass this environment returns.`,name:"observation_cls"},{anchor:"openenv.core.create_app.env_name",description:`<strong>env_name</strong> (<code>str</code>, <em>optional</em>) — | |
| Environment name for README loading.`,name:"env_name"},{anchor:"openenv.core.create_app.max_concurrent_envs",description:`<strong>max_concurrent_envs</strong> (<code>int</code>, <em>optional</em>) — | |
| Maximum concurrent WebSocket sessions. Mutually exclusive with | |
| <code>concurrency_config</code>.`,name:"max_concurrent_envs"},{anchor:"openenv.core.create_app.concurrency_config",description:`<strong>concurrency_config</strong> (<code>ConcurrencyConfig</code>, <em>optional</em>) — | |
| Advanced concurrency settings. Mutually exclusive with | |
| <code>max_concurrent_envs</code>.`,name:"concurrency_config"},{anchor:"openenv.core.create_app.gradio_builder",description:`<strong>gradio_builder</strong> (<code>Callable</code>, <em>optional</em>) — | |
| Callable to build a custom Gradio UI at /web. Signature: | |
| <code>(web_manager, action_fields, metadata, is_chat_env, title, quick_start_md) -> gr.Blocks</code>. | |
| When <code>None</code>, the default Gradio app is used.`,name:"gradio_builder"},{anchor:"openenv.core.create_app.custom_tab_name",description:`<strong>custom_tab_name</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"Custom"</code>) — | |
| Label for the env-specific tab when <code>gradio_builder</code> is provided.`,name:"custom_tab_name"},{anchor:"openenv.core.create_app.custom_tab_primary",description:`<strong>custom_tab_primary</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| When <code>True</code>, the env-specific tab is active first; the auto-generated | |
| Playground becomes secondary.`,name:"custom_tab_primary"},{anchor:"openenv.core.create_app.show_default_tab",description:`<strong>show_default_tab</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| When <code>False</code>, mount the env’s <code>gradio_builder</code> output alone (no | |
| auto-generated Playground, no tab chrome). Only meaningful when | |
| <code>gradio_builder</code> is provided.`,name:"show_default_tab"},{anchor:"openenv.core.create_app.title_override",description:`<strong>title_override</strong> (<code>str</code>, <em>optional</em>) — | |
| If set, used as the Gradio app title instead of the default | |
| <code>"OpenEnv Agentic Environment: {name}"</code>.`,name:"title_override"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>FastAPI</code> application instance with or without web interface and README integration.</p> | |
| `}),t(4),r(se);var ie=e(se,2),Xa=o(ie);n(Xa,{name:"openenv.core.create_fastapi_app",anchor:"openenv.core.create_fastapi_app",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/http_server.py#L1790",parameters:[{name:"env",val:": Callable[[], Environment]"},{name:"action_cls",val:": Type[Action]"},{name:"observation_cls",val:": Type[Observation]"},{name:"max_concurrent_envs",val:": Optional[int] = None"},{name:"concurrency_config",val:": Optional[ConcurrencyConfig] = None"},{name:"env_name",val:": Optional[str] = None"}],parametersDescription:[{anchor:"openenv.core.create_fastapi_app.env",description:`<strong>env</strong> (<code>Callable[[], Environment]</code>) — | |
| Environment factory (callable) that creates new instances.`,name:"env"},{anchor:"openenv.core.create_fastapi_app.action_cls",description:`<strong>action_cls</strong> (<code>Type[Action]</code>) — | |
| The Action subclass this environment expects.`,name:"action_cls"},{anchor:"openenv.core.create_fastapi_app.observation_cls",description:`<strong>observation_cls</strong> (<code>Type[Observation]</code>) — | |
| The Observation subclass this environment returns.`,name:"observation_cls"},{anchor:"openenv.core.create_fastapi_app.max_concurrent_envs",description:`<strong>max_concurrent_envs</strong> (<code>int</code>, <em>optional</em>) — | |
| Maximum concurrent WebSocket sessions. Mutually exclusive with | |
| <code>concurrency_config</code>.`,name:"max_concurrent_envs"},{anchor:"openenv.core.create_fastapi_app.concurrency_config",description:`<strong>concurrency_config</strong> (<code>ConcurrencyConfig</code>, <em>optional</em>) — | |
| Advanced concurrency settings. Mutually exclusive with | |
| <code>max_concurrent_envs</code>.`,name:"concurrency_config"},{anchor:"openenv.core.create_fastapi_app.env_name",description:`<strong>env_name</strong> (<code>str</code>, <em>optional</em>) — | |
| Optional environment name for task/split endpoints.`,name:"env_name"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>FastAPI</code> application instance.</p> | |
| `}),t(2),r(ie);var or=e(ie,2);u(or,{title:"Web interface helpers",local:"openenv.core.env_server.web_interface.ActionLog",headingTag:"h3"});var ce=e(or,2),Qa=o(ce);n(Qa,{name:"class openenv.core.env_server.web_interface.ActionLog",anchor:"openenv.core.env_server.web_interface.ActionLog",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/web_interface.py#L203",parameters:[{name:"timestamp",val:": str"},{name:"action",val:": typing.Dict[str, typing.Any]"},{name:"observation",val:": typing.Dict[str, typing.Any]"},{name:"reward",val:": typing.Optional[float] = None"},{name:"done",val:": bool"},{name:"step_count",val:": int"}]}),t(2),r(ce);var le=e(ce,2),qa=o(le);n(qa,{name:"class openenv.core.env_server.web_interface.EpisodeState",anchor:"openenv.core.env_server.web_interface.EpisodeState",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/web_interface.py#L218",parameters:[{name:"episode_id",val:": typing.Optional[str] = None"},{name:"step_count",val:": int"},{name:"current_observation",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"action_logs",val:": typing.List[openenv.core.env_server.web_interface.ActionLog] = <factory>"},{name:"is_reset",val:": bool = True"}]}),t(2),r(le);var pe=e(le,2),rr=o(pe);n(rr,{name:"class openenv.core.WebInterfaceManager",anchor:"openenv.core.WebInterfaceManager",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/web_interface.py#L236",parameters:[{name:"env",val:": Environment"},{name:"action_cls",val:": Type[Action]"},{name:"observation_cls",val:": Type[Observation]"},{name:"metadata",val:": Optional[EnvironmentMetadata] = None"}]});var de=e(rr,4),Ha=o(de);n(Ha,{name:"connect_websocket",anchor:"openenv.core.WebInterfaceManager.connect_websocket",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/web_interface.py#L306",parameters:[{name:"websocket",val:": WebSocket"}]}),t(2),r(de);var ve=e(de,2),Ka=o(ve);n(Ka,{name:"disconnect_websocket",anchor:"openenv.core.WebInterfaceManager.disconnect_websocket",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/web_interface.py#L314",parameters:[{name:"websocket",val:": WebSocket"}]}),t(2),r(ve);var me=e(ve,2),$a=o(me);n($a,{name:"get_state",anchor:"openenv.core.WebInterfaceManager.get_state",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/web_interface.py#L419",parameters:[]}),t(2),r(me);var ue=e(me,2),es=o(ue);n(es,{name:"reset_environment",anchor:"openenv.core.WebInterfaceManager.reset_environment",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/web_interface.py#L341",parameters:[{name:"reset_kwargs",val:": Optional[Dict[str, Any]] = None"}]}),t(2),r(ue);var tr=e(ue,2),ns=o(tr);n(ns,{name:"step_environment",anchor:"openenv.core.WebInterfaceManager.step_environment",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/web_interface.py#L376",parameters:[{name:"action_data",val:": Dict[str, Any]"}]}),t(2),r(tr),r(pe);var ge=e(pe,2),os=o(ge);n(os,{name:"openenv.core.create_web_interface_app",anchor:"openenv.core.create_web_interface_app",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/web_interface.py#L425",parameters:[{name:"env",val:": Environment"},{name:"action_cls",val:": Type[Action]"},{name:"observation_cls",val:": Type[Observation]"},{name:"env_name",val:": Optional[str] = None"},{name:"max_concurrent_envs",val:": Optional[int] = None"},{name:"concurrency_config",val:": Optional[Any] = None"},{name:"gradio_builder",val:": Optional[Callable[..., Any]] = None"},{name:"custom_tab_name",val:": str = 'Custom'"},{name:"custom_tab_primary",val:": bool = False"},{name:"show_default_tab",val:": bool = True"},{name:"title_override",val:": Optional[str] = None"}],parametersDescription:[{anchor:"openenv.core.create_web_interface_app.env",description:"<strong>env</strong> — The Environment instance to serve",name:"env"},{anchor:"openenv.core.create_web_interface_app.action_cls",description:"<strong>action_cls</strong> — The Action subclass this environment expects",name:"action_cls"},{anchor:"openenv.core.create_web_interface_app.observation_cls",description:"<strong>observation_cls</strong> — The Observation subclass this environment returns",name:"observation_cls"},{anchor:"openenv.core.create_web_interface_app.env_name",description:"<strong>env_name</strong> — Optional environment name for README loading",name:"env_name"},{anchor:"openenv.core.create_web_interface_app.max_concurrent_envs",description:"<strong>max_concurrent_envs</strong> — Maximum concurrent WebSocket sessions",name:"max_concurrent_envs"},{anchor:"openenv.core.create_web_interface_app.concurrency_config",description:"<strong>concurrency_config</strong> — Optional ConcurrencyConfig for advanced concurrency settings",name:"concurrency_config"},{anchor:"openenv.core.create_web_interface_app.gradio_builder",description:`<strong>gradio_builder</strong> — Optional callable (web_manager, action_fields, metadata, | |
| is_chat_env, title, quick_start_md) -> gr.Blocks to use instead of the | |
| default Gradio UI. Lets envs replace or customize the /web interface.`,name:"gradio_builder"},{anchor:"openenv.core.create_web_interface_app.custom_tab_name",description:`<strong>custom_tab_name</strong> — Label shown on the env-specific tab when <code>gradio_builder</code> | |
| is provided. Defaults to <code>"Custom"</code> for backwards compatibility; envs | |
| that ship a rich custom UI should pass a descriptive name | |
| (e.g. <code>"REPL"</code>). Ignored when <code>show_default_tab=False</code> (no tab chrome | |
| is rendered).`,name:"custom_tab_name"},{anchor:"openenv.core.create_web_interface_app.custom_tab_primary",description:`<strong>custom_tab_primary</strong> — When True, the env-specific tab is rendered first and | |
| selected by default; the auto-generated Playground becomes secondary. | |
| Use this for envs whose custom tab is the real interaction surface | |
| (so visitors don’t land on a less informative schema form). Ignored | |
| when <code>show_default_tab=False</code>.`,name:"custom_tab_primary"},{anchor:"openenv.core.create_web_interface_app.show_default_tab",description:`<strong>show_default_tab</strong> — When False, the auto-generated Playground tab is not | |
| rendered and the env’s <code>gradio_builder</code> output is mounted directly | |
| (single-view UI, no tab chrome). Only meaningful when | |
| <code>gradio_builder</code> is provided.`,name:"show_default_tab"},{anchor:"openenv.core.create_web_interface_app.title_override",description:`<strong>title_override</strong> — If set, used verbatim as the Gradio app/browser-tab | |
| title instead of the default <code>"OpenEnv Agentic Environment: {name}"</code>.`,name:"title_override"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>FastAPI application instance with web interface</p> | |
| `}),t(2),r(ge);var ar=e(ge,2);u(ar,{title:"Serialization",local:"openenv.core.deserialize_action",headingTag:"h3"});var be=e(ar,2),rs=o(be);n(rs,{name:"openenv.core.deserialize_action",anchor:"openenv.core.deserialize_action",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/serialization.py#L42",parameters:[{name:"action_data",val:": typing.Dict[str, typing.Any]"},{name:"action_cls",val:": typing.Type[openenv.core.env_server.types.Action]"}],parametersDescription:[{anchor:"openenv.core.deserialize_action.action_data",description:`<strong>action_data</strong> (<em>dict</em>) — | |
| Dictionary containing action data.`,name:"action_data"},{anchor:"openenv.core.deserialize_action.action_cls",description:`<strong>action_cls</strong> (<em>type</em>) — | |
| The Action subclass to instantiate.`,name:"action_cls"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><em>Action</em> instance.</p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>ValidationError</code> — If <em>action_data</em> is invalid for the action class.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ValidationError</code></p> | |
| `}),t(6),r(be);var he=e(be,2),ts=o(he);n(ts,{name:"openenv.core.deserialize_action_with_preprocessing",anchor:"openenv.core.deserialize_action_with_preprocessing",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/serialization.py#L73",parameters:[{name:"action_data",val:": typing.Dict[str, typing.Any]"},{name:"action_cls",val:": typing.Type[openenv.core.env_server.types.Action]"}],parametersDescription:[{anchor:"openenv.core.deserialize_action_with_preprocessing.action_data",description:`<strong>action_data</strong> (<code>dict</code>) — | |
| Dictionary containing action data.`,name:"action_data"},{anchor:"openenv.core.deserialize_action_with_preprocessing.action_cls",description:`<strong>action_cls</strong> (<code>type</code>) — | |
| The Action subclass to instantiate.`,name:"action_cls"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>Action</code> instance.</p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>ValidationError</code> — If <code>action_data</code> is invalid for the action class.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ValidationError</code></p> | |
| `}),t(6),r(he);var _e=e(he,2),as=o(_e);n(as,{name:"openenv.core.serialize_observation",anchor:"openenv.core.serialize_observation",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/serialization.py#L137",parameters:[{name:"observation",val:": Observation"}],parametersDescription:[{anchor:"openenv.core.serialize_observation.observation",description:`<strong>observation</strong> (<code>Observation</code>) — | |
| Observation instance to serialize.`,name:"observation"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>observation</code> (<code>dict</code>): Observation fields.</li> | |
| <li><code>reward</code> (<code>float</code> or <code>None</code>): Reward value.</li> | |
| <li><code>done</code> (<code>bool</code>): Whether the episode is done.</li> | |
| <li><code>metadata</code> (<code>dict</code>, <em>optional</em>): Additional observation metadata.</li> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>dict</code> compatible with <code>EnvClient._parse_result()</code>, with keys</p> | |
| `}),t(2),r(_e);var sr=e(_e,2);u(sr,{title:"Transforms",local:"openenv.core.CompositeTransform",headingTag:"h3"});var ye=e(sr,2),ss=o(ye);n(ss,{name:"class openenv.core.CompositeTransform",anchor:"openenv.core.CompositeTransform",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/base_transforms.py#L9",parameters:[{name:"transforms",val:": list"}]}),t(2),r(ye);var fe=e(ye,2),is=o(fe);n(is,{name:"class openenv.core.NullTransform",anchor:"openenv.core.NullTransform",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/base_transforms.py#L21",parameters:[]}),t(2),r(fe);var ir=e(fe,2);u(ir,{title:"Route configuration",local:"openenv.core.GetEndpointConfig",headingTag:"h3"});var Me=e(ir,2),cs=o(Me);n(cs,{name:"class openenv.core.GetEndpointConfig",anchor:"openenv.core.GetEndpointConfig",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/route_config.py#L18",parameters:[{name:"path",val:": str"},{name:"handler",val:": typing.Callable[[], pydantic.main.BaseModel | dict]"},{name:"response_model",val:": typing.Union[typing.Type[pydantic.main.BaseModel], type[dict]]"},{name:"tag",val:": str"},{name:"summary",val:": str"},{name:"description",val:": str"}]}),t(2),r(Me);var we=e(Me,2),ls=o(we);n(ls,{name:"openenv.core.env_server.route_config.register_get_endpoints",anchor:"openenv.core.env_server.route_config.register_get_endpoints",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/route_config.py#L40",parameters:[{name:"app",val:": FastAPI"},{name:"configs",val:": typing.List[openenv.core.env_server.route_config.GetEndpointConfig]"}],parametersDescription:[{anchor:"openenv.core.env_server.route_config.register_get_endpoints.app",description:`<strong>app</strong> (<code>~fastapi.FastAPI</code>) — | |
| FastAPI application instance.`,name:"app"},{anchor:"openenv.core.env_server.route_config.register_get_endpoints.configs",description:`<strong>configs</strong> (<code>List[GetEndpointConfig]</code>) — | |
| List of GET endpoint configurations.`,name:"configs"}]}),t(2),r(we);var cr=e(we,2);u(cr,{title:"Clients",local:"clients",headingTag:"h2"});var lr=e(cr,2);u(lr,{title:"Base client",local:"openenv.core.EnvClient",headingTag:"h3"});var xe=e(lr,2),pr=o(xe);n(pr,{name:"class openenv.core.EnvClient",anchor:"openenv.core.EnvClient",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_client.py#L238",parameters:[{name:"base_url",val:": Optional[str] = None"},{name:"connect_timeout_s",val:": float = 10.0"},{name:"message_timeout_s",val:": float = 60.0"},{name:"max_message_size_mb",val:": float = 100.0"},{name:"websocket_ping_interval_s",val:": Optional[float] = 20.0"},{name:"websocket_ping_timeout_s",val:": Optional[float] = 20.0"},{name:"provider",val:": Optional['ContainerProvider | RuntimeProvider'] = None"},{name:"mode",val:": Optional[str] = None"}]});var dr=e(pr,14);l(dr,{anchor:"openenv.core.EnvClient.example",children:(s,c)=>{var a=Sc(),i=e(v(a),2);p(i,{code:"ZnJvbSUyMGVudnMuY29kaW5nX2Vudi5jbGllbnQlMjBpbXBvcnQlMjBDb2RpbmdFbnYlMEElMEFhc3luYyUyMHdpdGglMjBDb2RpbmdFbnYoYmFzZV91cmwlM0QlMjJ3cyUzQSUyRiUyRmxvY2FsaG9zdCUzQTgwMDAlMjIpJTIwYXMlMjBlbnYlM0ElMEElMjAlMjAlMjAlMjByZXN1bHQlMjAlM0QlMjBhd2FpdCUyMGVudi5yZXNldChzZWVkJTNENDIpJTBBJTIwJTIwJTIwJTIwd2hpbGUlMjBub3QlMjByZXN1bHQuZG9uZSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGFjdGlvbiUyMCUzRCUyMGFnZW50LnByZWRpY3QocmVzdWx0Lm9ic2VydmF0aW9uKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlc3VsdCUyMCUzRCUyMGF3YWl0JTIwZW52LnN0ZXAoYWN0aW9uKQ==",highlighted:`<span class="hljs-keyword">from</span> envs.coding_env.client <span class="hljs-keyword">import</span> CodingEnv | |
| <span class="hljs-keyword">async</span> <span class="hljs-keyword">with</span> CodingEnv(base_url=<span class="hljs-string">"ws://localhost:8000"</span>) <span class="hljs-keyword">as</span> env: | |
| result = <span class="hljs-keyword">await</span> env.reset(seed=<span class="hljs-number">42</span>) | |
| <span class="hljs-keyword">while</span> <span class="hljs-keyword">not</span> result.done: | |
| action = agent.predict(result.observation) | |
| result = <span class="hljs-keyword">await</span> env.step(action)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var vr=e(dr,2);l(vr,{anchor:"openenv.core.EnvClient.example-2",children:(s,c)=>{var a=Lc(),i=e(v(a),2);p(i,{code:"ZW52JTIwJTNEJTIwQ29kaW5nRW52KGJhc2VfdXJsJTNEJTIyd3MlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDAwJTIyKS5zeW5jKCklMEF3aXRoJTIwZW52JTNBJTBBJTIwJTIwJTIwJTIwcmVzdWx0JTIwJTNEJTIwZW52LnJlc2V0KHNlZWQlM0Q0MiklMEElMjAlMjAlMjAlMjByZXN1bHQlMjAlM0QlMjBlbnYuc3RlcChhY3Rpb24p",highlighted:`env = CodingEnv(base_url=<span class="hljs-string">"ws://localhost:8000"</span>).sync() | |
| <span class="hljs-keyword">with</span> env: | |
| result = env.reset(seed=<span class="hljs-number">42</span>) | |
| result = env.step(action)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var Te=e(vr,2),mr=o(Te);n(mr,{name:"from_docker_image",anchor:"openenv.core.EnvClient.from_docker_image",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_client.py#L629",parameters:[{name:"image",val:": str"},{name:"provider",val:": Optional['ContainerProvider'] = None"},{name:"**kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.core.EnvClient.from_docker_image.image",description:`<strong>image</strong> (<code>str</code>) — | |
| Docker image name to run (e.g., <code>"coding-env:latest"</code>).`,name:"image"},{anchor:"openenv.core.EnvClient.from_docker_image.provider",description:`<strong>provider</strong> (<code>ContainerProvider</code>, <em>optional</em>) — | |
| Container provider to use. Defaults to <code>LocalDockerProvider</code>.`,name:"provider"},{anchor:"openenv.core.EnvClient.from_docker_image.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Additional arguments to pass to <code>provider.start_container()</code>.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>await</code> for a connected async client, or call | |
| <code>.sync()</code> for a connected <code>SyncEnvClient</code>.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>_BootstrapResult</code></p> | |
| `});var ps=e(mr,6);l(ps,{anchor:"openenv.core.EnvClient.from_docker_image.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"JTIzJTIwQXN5bmMlMEFlbnYlMjAlM0QlMjBhd2FpdCUyME15RW52LmZyb21fZG9ja2VyX2ltYWdlKCUyMmNvZGluZy1lbnYlM0FsYXRlc3QlMjIpJTBBJTBBJTIzJTIwU3luYyUwQWVudiUyMCUzRCUyME15RW52LmZyb21fZG9ja2VyX2ltYWdlKCUyMmNvZGluZy1lbnYlM0FsYXRlc3QlMjIpLnN5bmMoKSUwQXJlc3VsdCUyMCUzRCUyMGVudi5yZXNldCgp",highlighted:`<span class="hljs-comment"># Async</span> | |
| env = <span class="hljs-keyword">await</span> MyEnv.from_docker_image(<span class="hljs-string">"coding-env:latest"</span>) | |
| <span class="hljs-comment"># Sync</span> | |
| env = MyEnv.from_docker_image(<span class="hljs-string">"coding-env:latest"</span>).sync() | |
| result = env.reset()`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}}),r(Te);var Je=e(Te,2),ur=o(Je);n(ur,{name:"from_env",anchor:"openenv.core.EnvClient.from_env",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_client.py#L749",parameters:[{name:"repo_id",val:": str"},{name:"use_docker",val:": bool = True"},{name:"provider",val:": Optional['ContainerProvider | RuntimeProvider'] = None"},{name:"**provider_kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.core.EnvClient.from_env.repo_id",description:`<strong>repo_id</strong> (<code>str</code>) — | |
| Hugging Face space identifier <code>{org}/{space}</code>.`,name:"repo_id"},{anchor:"openenv.core.EnvClient.from_env.use_docker",description:`<strong>use_docker</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| When <code>True</code>, pull from the HF registry and launch via <code>LocalDockerProvider</code>. | |
| When <code>False</code>, run the space locally with <code>UVProvider</code>.`,name:"use_docker"},{anchor:"openenv.core.EnvClient.from_env.provider",description:`<strong>provider</strong> (<code>ContainerProvider</code> or <code>RuntimeProvider</code>, <em>optional</em>) — | |
| Provider instance to reuse. Must be a <code>ContainerProvider</code> when | |
| <code>use_docker=True</code> and a <code>RuntimeProvider</code> otherwise.`,name:"provider"},{anchor:"openenv.core.EnvClient.from_env.*provider_kwargs",description:`*<strong>*provider_kwargs</strong> — | |
| Additional keyword arguments forwarded to either the container provider’s | |
| <code>start_container</code> (docker) or to the <code>UVProvider</code> constructor/start (uv). | |
| When <code>use_docker=False</code>, the <code>project_path</code> argument can be used to override | |
| the default git URL (<code>git+https://huggingface.co/spaces/{repo_id}</code>).`,name:"*provider_kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>await</code> for a connected async client, or call | |
| <code>.sync()</code> for a connected <code>SyncEnvClient</code>.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>_BootstrapResult</code></p> | |
| `});var ds=e(ur,6);l(ds,{anchor:"openenv.core.EnvClient.from_env.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"JTIzJTIwQXN5bmMlM0ElMjBwdWxsJTIwYW5kJTIwcnVuJTIwZnJvbSUyMEhGJTIwRG9ja2VyJTIwcmVnaXN0cnklMEFlbnYlMjAlM0QlMjBhd2FpdCUyME15RW52LmZyb21fZW52KCUyMm9wZW5lbnYlMkZlY2hvLWVudiUyMiklMEElMEElMjMlMjBTeW5jJTNBJTIwY2hhaW4lMjAuc3luYygpJTBBZW52JTIwJTNEJTIwTXlFbnYuZnJvbV9lbnYoJTIyb3BlbmVudiUyRmVjaG8tZW52JTIyKS5zeW5jKCklMEElMEElMjMlMjBSdW4lMjBsb2NhbGx5JTIwd2l0aCUyMFVWJTIwKGNsb25lcyUyMHRoZSUyMHNwYWNlKSUwQWVudiUyMCUzRCUyMGF3YWl0JTIwTXlFbnYuZnJvbV9lbnYoJTIyb3BlbmVudiUyRmVjaG8tZW52JTIyJTJDJTIwdXNlX2RvY2tlciUzREZhbHNlKSUwQSUwQSUyMyUyMFJ1biUyMGZyb20lMjBhJTIwbG9jYWwlMjBjaGVja291dCUwQWVudiUyMCUzRCUyMGF3YWl0JTIwTXlFbnYuZnJvbV9lbnYoJTBBJTIwJTIwJTIwJTIwJTIyb3BlbmVudiUyRmVjaG8tZW52JTIyJTJDJTBBJTIwJTIwJTIwJTIwdXNlX2RvY2tlciUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwcHJvamVjdF9wYXRoJTNEJTIyJTJGcGF0aCUyRnRvJTJGbG9jYWwlMkZjaGVja291dCUyMiUwQSk=",highlighted:`<span class="hljs-comment"># Async: pull and run from HF Docker registry</span> | |
| env = <span class="hljs-keyword">await</span> MyEnv.from_env(<span class="hljs-string">"openenv/echo-env"</span>) | |
| <span class="hljs-comment"># Sync: chain .sync()</span> | |
| env = MyEnv.from_env(<span class="hljs-string">"openenv/echo-env"</span>).sync() | |
| <span class="hljs-comment"># Run locally with UV (clones the space)</span> | |
| env = <span class="hljs-keyword">await</span> MyEnv.from_env(<span class="hljs-string">"openenv/echo-env"</span>, use_docker=<span class="hljs-literal">False</span>) | |
| <span class="hljs-comment"># Run from a local checkout</span> | |
| env = <span class="hljs-keyword">await</span> MyEnv.from_env( | |
| <span class="hljs-string">"openenv/echo-env"</span>, | |
| use_docker=<span class="hljs-literal">False</span>, | |
| project_path=<span class="hljs-string">"/path/to/local/checkout"</span> | |
| )`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}}),r(Je);var je=e(Je,2),vs=o(je);n(vs,{name:"new_session",anchor:"openenv.core.EnvClient.new_session",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_client.py#L412",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A connected child client of the same concrete type.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>EnvClient</code></p> | |
| `}),t(4),r(je);var gr=e(je,2),br=o(gr);n(br,{name:"sync",anchor:"openenv.core.EnvClient.sync",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_client.py#L952",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>SyncEnvClient wrapper that provides synchronous methods</p> | |
| `});var ms=e(br,8);l(ms,{anchor:"openenv.core.EnvClient.sync.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"YXN5bmNfY2xpZW50JTIwJTNEJTIwR2VuZXJpY0VudkNsaWVudChiYXNlX3VybCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDAwJTIyKSUwQXN5bmNfY2xpZW50JTIwJTNEJTIwYXN5bmNfY2xpZW50LnN5bmMoKSUwQSUwQXdpdGglMjBzeW5jX2NsaWVudCUzQSUwQSUyMCUyMCUyMCUyMHJlc3VsdCUyMCUzRCUyMHN5bmNfY2xpZW50LnJlc2V0KCklMEElMjAlMjAlMjAlMjByZXN1bHQlMjAlM0QlMjBzeW5jX2NsaWVudC5zdGVwKCU3QiUyMmNvZGUlMjIlM0ElMjAlMjJwcmludCgnaGVsbG8nKSUyMiU3RCk=",highlighted:`async_client = GenericEnvClient(base_url=<span class="hljs-string">"http://localhost:8000"</span>) | |
| sync_client = async_client.sync() | |
| <span class="hljs-keyword">with</span> sync_client: | |
| result = sync_client.reset() | |
| result = sync_client.step({<span class="hljs-string">"code"</span>: <span class="hljs-string">"print('hello')"</span>})`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}}),r(gr),r(xe);var hr=e(xe,2);u(hr,{title:"Synchronous client",local:"openenv.SyncEnvClient",headingTag:"h3"});var Ce=e(hr,2),_r=o(Ce);n(_r,{name:"class openenv.SyncEnvClient",anchor:"openenv.SyncEnvClient",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/sync_client.py#L43",parameters:[{name:"async_client",val:": 'EnvClient[ActT, ObsT, StateT]'"}],parametersDescription:[{anchor:"openenv.SyncEnvClient._async",description:"<strong>_async</strong> — The wrapped async EnvClient instance",name:"_async"}]});var yr=e(_r,10);l(yr,{anchor:"openenv.SyncEnvClient.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"JTIzJTIwRnJvbSUyMGFuJTIwYXN5bmMlMjBjbGllbnQlMEFhc3luY19jbGllbnQlMjAlM0QlMjBHZW5lcmljRW52Q2xpZW50KGJhc2VfdXJsJTNEJTIyaHR0cCUzQSUyRiUyRmxvY2FsaG9zdCUzQTgwMDAlMjIpJTBBc3luY19jbGllbnQlMjAlM0QlMjBhc3luY19jbGllbnQuc3luYygpJTBBJTBBJTIzJTIwVXNlJTIwc3luY2hyb25vdXMlMjBjb250ZXh0JTIwbWFuYWdlciUwQXdpdGglMjBzeW5jX2NsaWVudCUzQSUwQSUyMCUyMCUyMCUyMHJlc3VsdCUyMCUzRCUyMHN5bmNfY2xpZW50LnJlc2V0KCklMEElMjAlMjAlMjAlMjByZXN1bHQlMjAlM0QlMjBzeW5jX2NsaWVudC5zdGVwKCU3QiUyMmFjdGlvbiUyMiUzQSUyMCUyMnRlc3QlMjIlN0Qp",highlighted:`<span class="hljs-comment"># From an async client</span> | |
| async_client = GenericEnvClient(base_url=<span class="hljs-string">"http://localhost:8000"</span>) | |
| sync_client = async_client.sync() | |
| <span class="hljs-comment"># Use synchronous context manager</span> | |
| <span class="hljs-keyword">with</span> sync_client: | |
| result = sync_client.reset() | |
| result = sync_client.step({<span class="hljs-string">"action"</span>: <span class="hljs-string">"test"</span>})`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var ke=e(yr,2),us=o(ke);n(us,{name:"close",anchor:"openenv.SyncEnvClient.close",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/sync_client.py#L219",parameters:[]}),t(2),r(ke);var Ue=e(ke,2),gs=o(Ue);n(gs,{name:"connect",anchor:"openenv.SyncEnvClient.connect",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/sync_client.py#L163",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>self for method chaining</p> | |
| `}),t(2),r(Ue);var Ie=e(Ue,2),bs=o(Ie);n(bs,{name:"disconnect",anchor:"openenv.SyncEnvClient.disconnect",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/sync_client.py#L174",parameters:[]}),t(2),r(Ie);var Ae=e(Ie,2),hs=o(Ae);n(hs,{name:"new_session",anchor:"openenv.SyncEnvClient.new_session",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/sync_client.py#L231",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A connected child wrapper around a child async | |
| client of the same concrete type.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>SyncEnvClient</code></p> | |
| `}),t(4),r(Ae);var Ne=e(Ae,2),_s=o(Ne);n(_s,{name:"reset",anchor:"openenv.SyncEnvClient.reset",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/sync_client.py#L179",parameters:[{name:"**kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.SyncEnvClient.reset.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Optional parameters passed to the environment’s reset method.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>StepResult containing initial observation</p> | |
| `}),t(2),r(Ne);var Ee=e(Ne,2),ys=o(Ee);n(ys,{name:"state",anchor:"openenv.SyncEnvClient.state",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/sync_client.py#L209",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>State object with environment state information</p> | |
| `}),t(2),r(Ee);var fr=e(Ee,2),fs=o(fr);n(fs,{name:"step",anchor:"openenv.SyncEnvClient.step",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/sync_client.py#L193",parameters:[{name:"action",val:": ActT"},{name:"**kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.SyncEnvClient.step.action",description:`<strong>action</strong> — | |
| The action to execute.`,name:"action"},{anchor:"openenv.SyncEnvClient.step.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Optional parameters.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>StepResult containing observation, reward, and done status</p> | |
| `}),t(2),r(fr),r(Ce);var Mr=e(Ce,2);u(Mr,{title:"Generic client",local:"openenv.GenericEnvClient",headingTag:"h3"});var Re=e(Mr,2),wr=o(Re);n(wr,{name:"class openenv.GenericEnvClient",anchor:"openenv.GenericEnvClient",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/generic_client.py#L17",parameters:[{name:"base_url",val:": Optional[str] = None"},{name:"connect_timeout_s",val:": float = 10.0"},{name:"message_timeout_s",val:": float = 60.0"},{name:"max_message_size_mb",val:": float = 100.0"},{name:"websocket_ping_interval_s",val:": Optional[float] = 20.0"},{name:"websocket_ping_timeout_s",val:": Optional[float] = 20.0"},{name:"provider",val:": Optional['ContainerProvider | RuntimeProvider'] = None"},{name:"mode",val:": Optional[str] = None"}]});var Ms=e(wr,10);l(Ms,{anchor:"openenv.GenericEnvClient.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"JTIzJTIwRGlyZWN0JTIwY29ubmVjdGlvbiUyMHRvJTIwYSUyMHJ1bm5pbmclMjBzZXJ2ZXIlMjAobm8lMjBpbnN0YWxsYXRpb24lMjBuZWVkZWQpJTBBd2l0aCUyMEdlbmVyaWNFbnZDbGllbnQoYmFzZV91cmwlM0QlMjJodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBODAwMCUyMiklMjBhcyUyMGVudiUzQSUwQSUyMCUyMCUyMCUyMHJlc3VsdCUyMCUzRCUyMGVudi5yZXNldCgpJTBBJTIwJTIwJTIwJTIwcmVzdWx0JTIwJTNEJTIwZW52LnN0ZXAoJTdCJTIyY29kZSUyMiUzQSUyMCUyMnByaW50KCdoZWxsbycpJTIyJTdEKSUwQSUyMCUyMCUyMCUyMHByaW50KHJlc3VsdC5vYnNlcnZhdGlvbiklMjAlMjAlMjMlMjBEaWN0JTVCc3RyJTJDJTIwQW55JTVEJTBBJTIwJTIwJTIwJTIwcHJpbnQocmVzdWx0Lm9ic2VydmF0aW9uLmdldCglMjJvdXRwdXQlMjIpKSUwQSUwQSUyMyUyMEZyb20lMjBsb2NhbCUyMERvY2tlciUyMGltYWdlJTIwKGNoYWluJTIwLnN5bmMoKSUyMGZvciUyMHN5bmNocm9ub3VzJTIwdXNlKSUwQWVudiUyMCUzRCUyMEdlbmVyaWNFbnZDbGllbnQuZnJvbV9kb2NrZXJfaW1hZ2UoJTIyY29kaW5nLWVudiUzQWxhdGVzdCUyMikuc3luYygpJTBBcmVzdWx0JTIwJTNEJTIwZW52LnJlc2V0KCklMEFyZXN1bHQlMjAlM0QlMjBlbnYuc3RlcCglN0IlMjJjb2RlJTIyJTNBJTIwJTIyeCUyMCUzRCUyMDElMjAlMkIlMjAyJTIyJTdEKSUwQWVudi5jbG9zZSgpJTBBJTBBJTIzJTIwRnJvbSUyMEh1Z2dpbmdGYWNlJTIwSHViJTIwKHB1bGxzJTIwRG9ja2VyJTIwaW1hZ2UlMkMlMjBubyUyMHBpcCUyMGluc3RhbGwpJTBBZW52JTIwJTNEJTIwR2VuZXJpY0VudkNsaWVudC5mcm9tX2VudiglMjJ1c2VyJTJGbXktZW52JTIyJTJDJTIwdXNlX2RvY2tlciUzRFRydWUpLnN5bmMoKSUwQXJlc3VsdCUyMCUzRCUyMGVudi5yZXNldCgpJTBBZW52LmNsb3NlKCk=",highlighted:`<span class="hljs-comment"># Direct connection to a running server (no installation needed)</span> | |
| <span class="hljs-keyword">with</span> GenericEnvClient(base_url=<span class="hljs-string">"http://localhost:8000"</span>) <span class="hljs-keyword">as</span> env: | |
| result = env.reset() | |
| result = env.step({<span class="hljs-string">"code"</span>: <span class="hljs-string">"print('hello')"</span>}) | |
| <span class="hljs-built_in">print</span>(result.observation) <span class="hljs-comment"># Dict[str, Any]</span> | |
| <span class="hljs-built_in">print</span>(result.observation.get(<span class="hljs-string">"output"</span>)) | |
| <span class="hljs-comment"># From local Docker image (chain .sync() for synchronous use)</span> | |
| env = GenericEnvClient.from_docker_image(<span class="hljs-string">"coding-env:latest"</span>).sync() | |
| result = env.reset() | |
| result = env.step({<span class="hljs-string">"code"</span>: <span class="hljs-string">"x = 1 + 2"</span>}) | |
| env.close() | |
| <span class="hljs-comment"># From HuggingFace Hub (pulls Docker image, no pip install)</span> | |
| env = GenericEnvClient.from_env(<span class="hljs-string">"user/my-env"</span>, use_docker=<span class="hljs-literal">True</span>).sync() | |
| result = env.reset() | |
| env.close()`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}}),t(2),r(Re);var Se=e(Re,2),xr=o(Se);n(xr,{name:"class openenv.GenericAction",anchor:"openenv.GenericAction",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/generic_client.py#L126",parameters:[{name:"**kwargs",val:": typing.Any"}]});var ws=e(xr,6);l(ws,{anchor:"openenv.GenericAction.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"JTIzJTIwV2l0aG91dCUyMEdlbmVyaWNBY3Rpb24lMjAod29ya3MlMjBmaW5lKSUwQWVudi5zdGVwKCU3QiUyMmNvZGUlMjIlM0ElMjAlMjJwcmludCgnaGVsbG8nKSUyMiU3RCklMEElMEElMjMlMjBXaXRoJTIwR2VuZXJpY0FjdGlvbiUyMChtb3JlJTIwZXhwbGljaXQpJTBBYWN0aW9uJTIwJTNEJTIwR2VuZXJpY0FjdGlvbihjb2RlJTNEJTIycHJpbnQoJ2hlbGxvJyklMjIpJTBBZW52LnN0ZXAoYWN0aW9uKSUwQSUwQSUyMyUyMFdpdGglMjBtdWx0aXBsZSUyMGZpZWxkcyUwQWFjdGlvbiUyMCUzRCUyMEdlbmVyaWNBY3Rpb24oY29kZSUzRCUyMnglMjAlM0QlMjAxJTIyJTJDJTIwdGltZW91dCUzRDMwJTJDJTIwbWV0YWRhdGElM0QlN0IlMjJ0YWclMjIlM0ElMjAlMjJ0ZXN0JTIyJTdEKSUwQWVudi5zdGVwKGFjdGlvbik=",highlighted:`<span class="hljs-comment"># Without GenericAction (works fine)</span> | |
| env.step({<span class="hljs-string">"code"</span>: <span class="hljs-string">"print('hello')"</span>}) | |
| <span class="hljs-comment"># With GenericAction (more explicit)</span> | |
| action = GenericAction(code=<span class="hljs-string">"print('hello')"</span>) | |
| env.step(action) | |
| <span class="hljs-comment"># With multiple fields</span> | |
| action = GenericAction(code=<span class="hljs-string">"x = 1"</span>, timeout=<span class="hljs-number">30</span>, metadata={<span class="hljs-string">"tag"</span>: <span class="hljs-string">"test"</span>}) | |
| env.step(action)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}}),t(2),r(Se);var Tr=e(Se,2);u(Tr,{title:"LLM client",local:"openenv.core.ToolCall",headingTag:"h3"});var Le=e(Tr,2),xs=o(Le);n(xs,{name:"class openenv.core.ToolCall",anchor:"openenv.core.ToolCall",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/llm_client.py#L33",parameters:[{name:"id",val:": str"},{name:"name",val:": str"},{name:"args",val:": dict[str, Any]"}]}),t(2),r(Le);var De=e(Le,2),Jr=o(De);n(Jr,{name:"class openenv.core.LLMResponse",anchor:"openenv.core.LLMResponse",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/llm_client.py#L42",parameters:[{name:"content",val:": str"},{name:"tool_calls",val:": list[ToolCall] = <factory>"}]});var jr=e(Jr,4),Ts=o(jr);n(Ts,{name:"to_message_dict",anchor:"openenv.core.LLMResponse.to_message_dict",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/llm_client.py#L48",parameters:[]}),t(2),r(jr),r(De);var Be=e(De,2),Cr=o(Be);n(Cr,{name:"class openenv.core.LLMClient",anchor:"openenv.core.LLMClient",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/llm_client.py#L66",parameters:[{name:"endpoint",val:": str"},{name:"port",val:": int"}],parametersDescription:[{anchor:"openenv.core.LLMClient.endpoint",description:`<strong>endpoint</strong> (<code>str</code>) — | |
| The base URL of the LLM service (e.g. “http://localhost”).`,name:"endpoint"},{anchor:"openenv.core.LLMClient.port",description:`<strong>port</strong> (<code>int</code>) — | |
| The port the service listens on.`,name:"port"}]});var We=e(Cr,6),Js=o(We);n(Js,{name:"complete",anchor:"openenv.core.LLMClient.complete",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/llm_client.py#L82",parameters:[{name:"prompt",val:": str"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"openenv.core.LLMClient.complete.prompt",description:`<strong>prompt</strong> (<code>str</code>) — | |
| The user prompt to send.`,name:"prompt"},{anchor:"openenv.core.LLMClient.complete.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Override default parameters (temperature, max_tokens, etc.).`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The model’s text response.</p> | |
| `}),t(2),r(We);var kr=e(We,2),js=o(kr);n(js,{name:"complete_with_tools",anchor:"openenv.core.LLMClient.complete_with_tools",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/llm_client.py#L97",parameters:[{name:"messages",val:": list[dict[str, Any]]"},{name:"tools",val:": list[dict[str, Any]]"},{name:"**kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.core.LLMClient.complete_with_tools.messages",description:`<strong>messages</strong> (<code>list[dict[str, Any]]</code>) — | |
| Conversation history as OpenAI-format message dicts.`,name:"messages"},{anchor:"openenv.core.LLMClient.complete_with_tools.tools",description:`<strong>tools</strong> (<code>list[dict[str, Any]]</code>) — | |
| MCP tool definitions.`,name:"tools"},{anchor:"openenv.core.LLMClient.complete_with_tools.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Override default parameters (temperature, max_tokens, etc.).`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>An <code>LLMResponse</code> with the model’s text and any tool calls.</p> | |
| `}),t(4),r(kr),r(Be);var Ge=e(Be,2),Ur=o(Ge);n(Ur,{name:"class openenv.core.OpenAIClient",anchor:"openenv.core.OpenAIClient",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/llm_client.py#L129",parameters:[{name:"endpoint",val:": str"},{name:"port",val:": int"},{name:"model",val:": str"},{name:"api_key",val:": str | None = None"},{name:"system_prompt",val:": str | None = None"},{name:"temperature",val:": float = 0.0"},{name:"max_tokens",val:": int = 256"},{name:"use_max_completion_tokens",val:": bool = False"}],parametersDescription:[{anchor:"openenv.core.OpenAIClient.endpoint",description:`<strong>endpoint</strong> (<code>str</code>) — | |
| The base URL (e.g. “http://localhost”).`,name:"endpoint"},{anchor:"openenv.core.OpenAIClient.port",description:`<strong>port</strong> (<code>int</code>) — | |
| The port number.`,name:"port"},{anchor:"openenv.core.OpenAIClient.model",description:`<strong>model</strong> (<code>str</code>) — | |
| Model name to pass to the API.`,name:"model"},{anchor:"openenv.core.OpenAIClient.api_key",description:`<strong>api_key</strong> (<code>str</code>, <em>optional</em>) — | |
| API key. Defaults to “not-needed” for local endpoints.`,name:"api_key"},{anchor:"openenv.core.OpenAIClient.system_prompt",description:`<strong>system_prompt</strong> (<code>str</code>, <em>optional</em>) — | |
| System message prepended to every request.`,name:"system_prompt"},{anchor:"openenv.core.OpenAIClient.temperature",description:`<strong>temperature</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) — | |
| Default sampling temperature.`,name:"temperature"},{anchor:"openenv.core.OpenAIClient.max_tokens",description:`<strong>max_tokens</strong> (<code>int</code>, <em>optional</em>, defaults to <code>256</code>) — | |
| Default max tokens in the response.`,name:"max_tokens"},{anchor:"openenv.core.OpenAIClient.use_max_completion_tokens",description:`<strong>use_max_completion_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Use max_completion_tokens instead of max_tokens. Required for newer OpenAI models | |
| (gpt-5-mini, o1, o3). Not supported by self-hosted OpenAI-compatible endpoints.`,name:"use_max_completion_tokens"}]});var Ir=e(Ur,6),Cs=o(Ir);n(Cs,{name:"complete",anchor:"openenv.core.OpenAIClient.complete",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/llm_client.py#L193",parameters:[{name:"prompt",val:": str"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"openenv.core.OpenAIClient.complete.prompt",description:`<strong>prompt</strong> (<code>str</code>) — | |
| The user message.`,name:"prompt"},{anchor:"openenv.core.OpenAIClient.complete.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Overrides for temperature, max_tokens.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The assistant’s response text.</p> | |
| `}),t(2),r(Ir),r(Ge);var Pe=e(Ge,2),ks=o(Pe);n(ks,{name:"class openenv.core.AnthropicClient",anchor:"openenv.core.AnthropicClient",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/llm_client.py#L242",parameters:[{name:"endpoint",val:": str"},{name:"port",val:": int"},{name:"model",val:": str"},{name:"api_key",val:": str | None = None"},{name:"system_prompt",val:": str | None = None"},{name:"temperature",val:": float = 0.0"},{name:"max_tokens",val:": int = 256"}],parametersDescription:[{anchor:"openenv.core.AnthropicClient.endpoint",description:`<strong>endpoint</strong> (<code>str</code>) — | |
| The base URL (e.g. <code>https://api.anthropic.com</code>).`,name:"endpoint"},{anchor:"openenv.core.AnthropicClient.port",description:`<strong>port</strong> (<code>int</code>) — | |
| The port number.`,name:"port"},{anchor:"openenv.core.AnthropicClient.model",description:`<strong>model</strong> (<code>str</code>) — | |
| Model name (e.g. “claude-sonnet-4-20250514”).`,name:"model"},{anchor:"openenv.core.AnthropicClient.api_key",description:`<strong>api_key</strong> (<code>str</code>, <em>optional</em>) — | |
| Anthropic API key.`,name:"api_key"},{anchor:"openenv.core.AnthropicClient.system_prompt",description:`<strong>system_prompt</strong> (<code>str</code>, <em>optional</em>) — | |
| System message prepended to every request.`,name:"system_prompt"},{anchor:"openenv.core.AnthropicClient.temperature",description:`<strong>temperature</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) — | |
| Default sampling temperature.`,name:"temperature"},{anchor:"openenv.core.AnthropicClient.max_tokens",description:`<strong>max_tokens</strong> (<code>int</code>, <em>optional</em>, defaults to <code>256</code>) — | |
| Default max tokens in the response.`,name:"max_tokens"}]}),t(4),r(Pe);var Ve=e(Pe,2),Us=o(Ve);n(Us,{name:"openenv.core.create_llm_client",anchor:"openenv.core.create_llm_client",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/llm_client.py#L359",parameters:[{name:"provider",val:": str"},{name:"model",val:": str"},{name:"api_key",val:": str"},{name:"system_prompt",val:": str | None = None"},{name:"temperature",val:": float = 0.0"},{name:"max_tokens",val:": int = 4096"}],parametersDescription:[{anchor:"openenv.core.create_llm_client.provider",description:`<strong>provider</strong> (<code>str</code>) — | |
| Provider name (“openai” or “anthropic”).`,name:"provider"},{anchor:"openenv.core.create_llm_client.model",description:`<strong>model</strong> (<code>str</code>) — | |
| Model identifier.`,name:"model"},{anchor:"openenv.core.create_llm_client.api_key",description:`<strong>api_key</strong> (<code>str</code>) — | |
| API key for the provider.`,name:"api_key"},{anchor:"openenv.core.create_llm_client.system_prompt",description:`<strong>system_prompt</strong> (<code>str</code>, <em>optional</em>) — | |
| System message prepended to every request.`,name:"system_prompt"},{anchor:"openenv.core.create_llm_client.temperature",description:`<strong>temperature</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) — | |
| Sampling temperature.`,name:"temperature"},{anchor:"openenv.core.create_llm_client.max_tokens",description:`<strong>max_tokens</strong> (<code>int</code>, <em>optional</em>, defaults to <code>4096</code>) — | |
| Maximum tokens in the response.`,name:"max_tokens"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A configured <code>LLMClient</code> instance.</p> | |
| `}),t(2),r(Ve);var Ar=e(Ve,2);u(Ar,{title:"Shared dataclasses",local:"openenv.core.client_types.StepResult",headingTag:"h3"});var Ze=e(Ar,2),Is=o(Ze);n(Is,{name:"class openenv.core.client_types.StepResult",anchor:"openenv.core.client_types.StepResult",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/client_types.py#L11",parameters:[{name:"observation",val:": ~ObsT"},{name:"reward",val:": typing.Optional[float] = None"},{name:"done",val:": bool = False"},{name:"metadata",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"}],parametersDescription:[{anchor:"openenv.core.client_types.StepResult.observation",description:`<strong>observation</strong> — | |
| The environment’s observation after the action.`,name:"observation"},{anchor:"openenv.core.client_types.StepResult.reward",description:`<strong>reward</strong> (<code>float</code>, <em>optional</em>) — | |
| Scalar reward for this step.`,name:"reward"},{anchor:"openenv.core.client_types.StepResult.done",description:`<strong>done</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether the episode is finished.`,name:"done"},{anchor:"openenv.core.client_types.StepResult.metadata",description:`<strong>metadata</strong> (<code>dict</code>, <em>optional</em>) — | |
| Additional metadata returned alongside the observation.`,name:"metadata"}]}),t(2),r(Ze);var Nr=e(Ze,2);u(Nr,{title:"MCP (Model Context Protocol)",local:"mcp-model-context-protocol",headingTag:"h2"});var Er=e(Nr,2);u(Er,{title:"MCP environment",local:"openenv.core.MCPEnvironment",headingTag:"h3"});var Ye=e(Er,2),Rr=o(Ye);n(Rr,{name:"class openenv.core.MCPEnvironment",anchor:"openenv.core.MCPEnvironment",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_environment.py#L133",parameters:[{name:"mcp_server",val:": typing.Any"},{name:"transform",val:": typing.Optional[typing.Any] = None"}],parametersDescription:[{anchor:"openenv.core.MCPEnvironment.mcp_server",description:`<strong>mcp_server</strong> — A FastMCP server instance containing tool definitions. | |
| The server’s tools will be validated against reserved names.`,name:"mcp_server"},{anchor:"openenv.core.MCPEnvironment.transform",description:"<strong>transform</strong> — Optional transform to apply to observations (inherited from Environment).",name:"transform"}],raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>ValueError</code> — If any tool in the MCP server uses a reserved name | |
| (reset, step, state, close).</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ValueError</code></p> | |
| `});var Sr=e(Rr,12);l(Sr,{anchor:"openenv.core.MCPEnvironment.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"ZnJvbSUyMGZhc3RtY3AlMjBpbXBvcnQlMjBGYXN0TUNQJTBBJTBBbWNwJTIwJTNEJTIwRmFzdE1DUCglMjJjYWxjdWxhdG9yJTIyKSUwQSUwQSU0MG1jcC50b29sKCklMEFkZWYlMjBhZGQoYSUzQSUyMGludCUyQyUyMGIlM0ElMjBpbnQpJTIwLSUzRSUyMGludCUzQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGElMjAlMkIlMjBiJTBBJTBBZW52JTIwJTNEJTIwTXlNQ1BFbnZpcm9ubWVudChtY3ApJTBBb2JzJTIwJTNEJTIwZW52LnN0ZXAoTGlzdFRvb2xzQWN0aW9uKCkpJTBBb2JzLnRvb2xzJTVCMCU1RC5uYW1lJTIwJTIwJTIzJTIwJ2FkZCc=",highlighted:`<span class="hljs-keyword">from</span> fastmcp <span class="hljs-keyword">import</span> FastMCP | |
| mcp = FastMCP(<span class="hljs-string">"calculator"</span>) | |
| <span class="hljs-meta">@mcp.tool()</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">add</span>(<span class="hljs-params">a: <span class="hljs-built_in">int</span>, b: <span class="hljs-built_in">int</span></span>) -> <span class="hljs-built_in">int</span>: | |
| <span class="hljs-keyword">return</span> a + b | |
| env = MyMCPEnvironment(mcp) | |
| obs = env.step(ListToolsAction()) | |
| obs.tools[<span class="hljs-number">0</span>].name <span class="hljs-comment"># 'add'</span>`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var ze=e(Sr,2),As=o(ze);n(As,{name:"close",anchor:"openenv.core.MCPEnvironment.close",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_environment.py#L644",parameters:[]}),t(4),r(ze);var Fe=e(ze,2),Ns=o(Fe);n(Ns,{name:"execute_code",anchor:"openenv.core.MCPEnvironment.execute_code",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_environment.py#L290",parameters:[{name:"code",val:": str"}],parametersDescription:[{anchor:"openenv.core.MCPEnvironment.execute_code.code",description:`<strong>code</strong> — Python code to execute. Tools are available as functions | |
| in the execution namespace. Set a variable named ‘result’ | |
| to capture the return value.`,name:"code"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Observation with result in metadata[“result”] or error in | |
| metadata[“error”].</p> | |
| `}),t(4),r(Fe);var Oe=e(Fe,2),Es=o(Oe);n(Es,{name:"get_callables",anchor:"openenv.core.MCPEnvironment.get_callables",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_environment.py#L259",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Dictionary mapping tool names to callables.</p> | |
| `}),t(4),r(Oe);var Xe=e(Oe,2),Rs=o(Xe);n(Rs,{name:"mcp_session",anchor:"openenv.core.MCPEnvironment.mcp_session",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_environment.py#L211",parameters:[]}),t(10),r(Xe);var Qe=e(Xe,2),Ss=o(Qe);n(Ss,{name:"step",anchor:"openenv.core.MCPEnvironment.step",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_environment.py#L418",parameters:[{name:"action",val:": Action"},{name:"timeout_s",val:": typing.Optional[float] = None"},{name:"**kwargs",val:": typing.Any"}],parametersDescription:[{anchor:"openenv.core.MCPEnvironment.step.action",description:`<strong>action</strong> (<code>Action</code>) — | |
| The action to execute. <code>ListToolsAction</code> returns available MCP tools, | |
| <code>CallToolAction</code> invokes a specific MCP tool, and any other action | |
| is delegated to _step_impl().`,name:"action"},{anchor:"openenv.core.MCPEnvironment.step.timeout_s",description:`<strong>timeout_s</strong> (<code>float</code>, <em>optional</em>) — | |
| Timeout in seconds for the action. Defaults to MCP_TOOL_CALL_TIMEOUT | |
| (30s) for MCP actions.`,name:"timeout_s"},{anchor:"openenv.core.MCPEnvironment.step.*kwargs",description:`*<strong>*kwargs</strong> (<code>Any</code>) — | |
| Additional arguments passed to handlers.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ListToolsObservation</code> for <code>ListToolsAction</code>, | |
| <code>CallToolObservation</code> for <code>CallToolAction</code>, or a subclass-defined | |
| Observation for other actions.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>Observation</code></p> | |
| `}),t(4),r(Qe);var qe=e(Qe,2),Ls=o(qe);n(Ls,{name:"step_async",anchor:"openenv.core.MCPEnvironment.step_async",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_environment.py#L597",parameters:[{name:"action",val:": Action"},{name:"timeout_s",val:": typing.Optional[float] = None"},{name:"**kwargs",val:": typing.Any"}]}),t(4),r(qe);var Lr=e(qe,2),Ds=o(Lr);n(Ds,{name:"tool",anchor:"openenv.core.MCPEnvironment.tool",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_environment.py#L343",parameters:[{name:"mode",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"openenv.core.MCPEnvironment.tool.mode",description:`<strong>mode</strong> — Optional mode for the tool (“production” or “simulation”). | |
| If None, tool is available in all modes.`,name:"mode"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A decorator function for registering tools.</p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>ValueError</code> — If mode is not None, “production”, or “simulation”.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ValueError</code></p> | |
| `}),t(2),r(Lr),r(Ye);var Dr=e(Ye,2);u(Dr,{title:"MCP types",local:"openenv.core.JsonRpcErrorCode",headingTag:"h3"});var He=e(Dr,2),Bs=o(He);n(Bs,{name:"class openenv.core.JsonRpcErrorCode",anchor:"openenv.core.JsonRpcErrorCode",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L29",parameters:[{name:"value",val:""},{name:"names",val:" = None"},{name:"module",val:" = None"},{name:"qualname",val:" = None"},{name:"type",val:" = None"},{name:"start",val:" = 1"}]}),t(4),r(He);var Ke=e(He,2),Ws=o(Ke);n(Ws,{name:"class openenv.core.McpMethod",anchor:"openenv.core.McpMethod",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L47",parameters:[{name:"value",val:""},{name:"names",val:" = None"},{name:"module",val:" = None"},{name:"qualname",val:" = None"},{name:"type",val:" = None"},{name:"start",val:" = 1"}]}),t(2),r(Ke);var $e=e(Ke,2),Br=o($e);n(Br,{name:"class openenv.core.JsonRpcError",anchor:"openenv.core.JsonRpcError",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L54",parameters:[{name:"code",val:": int"},{name:"message",val:": str"},{name:"data",val:": typing.Optional[typing.Any] = None"}]});var Wr=e(Br,6),Gs=o(Wr);n(Gs,{name:"from_code",anchor:"openenv.core.JsonRpcError.from_code",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L69",parameters:[{name:"code",val:": JsonRpcErrorCode"},{name:"message",val:": typing.Optional[str] = None"},{name:"data",val:": typing.Any = None"}]}),t(2),r(Wr),r($e);var en=e($e,2),Ps=o(en);n(Ps,{name:"class openenv.core.JsonRpcRequest",anchor:"openenv.core.JsonRpcRequest",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L89",parameters:[{name:"jsonrpc",val:": typing.Literal['2.0']"},{name:"method",val:": str"},{name:"params",val:": typing.Dict[str, typing.Any] = <factory>"},{name:"id",val:": typing.Union[str, int, NoneType] = None"}]}),t(4),r(en);var nn=e(en,2),Gr=o(nn);n(Gr,{name:"class openenv.core.JsonRpcResponse",anchor:"openenv.core.JsonRpcResponse",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L108",parameters:[{name:"jsonrpc",val:": typing.Literal['2.0'] = '2.0'"},{name:"result",val:": typing.Optional[typing.Any] = None"},{name:"error",val:": typing.Optional[openenv.core.env_server.mcp_types.JsonRpcError] = None"},{name:"id",val:": typing.Union[str, int, NoneType] = None"}]});var on=e(Gr,8),Vs=o(on);n(Vs,{name:"error_response",anchor:"openenv.core.JsonRpcResponse.error_response",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L159",parameters:[{name:"code",val:": JsonRpcErrorCode"},{name:"message",val:": typing.Optional[str] = None"},{name:"data",val:": typing.Any = None"},{name:"request_id",val:": typing.Union[str, int, NoneType] = None"}]}),t(2),r(on);var rn=e(on,2),Zs=o(rn);n(Zs,{name:"model_dump",anchor:"openenv.core.JsonRpcResponse.model_dump",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L131",parameters:[{name:"**kwargs",val:""}]}),t(2),r(rn);var tn=e(rn,2),Ys=o(tn);n(Ys,{name:"model_dump_json",anchor:"openenv.core.JsonRpcResponse.model_dump_json",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L146",parameters:[{name:"**kwargs",val:""}]}),t(2),r(tn);var Pr=e(tn,2),zs=o(Pr);n(zs,{name:"success",anchor:"openenv.core.JsonRpcResponse.success",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L152",parameters:[{name:"result",val:": typing.Any"},{name:"request_id",val:": typing.Union[str, int, NoneType] = None"}]}),t(2),r(Pr),r(nn);var an=e(nn,2),Fs=o(an);n(Fs,{name:"class openenv.core.Tool",anchor:"openenv.core.Tool",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L179",parameters:[{name:"name",val:": str"},{name:"description",val:": str"},{name:"input_schema",val:": typing.Dict[str, typing.Any]"}]}),t(4),r(an);var sn=e(an,2),Os=o(sn);n(Os,{name:"class openenv.core.ToolErrorType",anchor:"openenv.core.ToolErrorType",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L198",parameters:[{name:"value",val:""},{name:"names",val:" = None"},{name:"module",val:" = None"},{name:"qualname",val:" = None"},{name:"type",val:" = None"},{name:"start",val:" = 1"}]}),t(2),r(sn);var cn=e(sn,2),Xs=o(cn);n(Xs,{name:"class openenv.core.ToolError",anchor:"openenv.core.ToolError",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L208",parameters:[{name:"error_type",val:": ToolErrorType"},{name:"message",val:": str"}]}),t(4),r(cn);var ln=e(cn,2),Qs=o(ln);n(Qs,{name:"class openenv.core.ListToolsAction",anchor:"openenv.core.ListToolsAction",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L225",parameters:[{name:"metadata",val:": typing.Dict[str, typing.Any] = <factory>"},{name:"type",val:": typing.Literal['list_tools'] = 'list_tools'"}]}),t(4),r(ln);var pn=e(ln,2),qs=o(pn);n(qs,{name:"class openenv.core.CallToolAction",anchor:"openenv.core.CallToolAction",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L239",parameters:[{name:"metadata",val:": typing.Dict[str, typing.Any] = <factory>"},{name:"type",val:": typing.Literal['call_tool'] = 'call_tool'"},{name:"tool_name",val:": str"},{name:"arguments",val:": typing.Dict[str, typing.Any] = <factory>"}]}),t(4),r(pn);var dn=e(pn,2),Hs=o(dn);n(Hs,{name:"class openenv.core.ListToolsObservation",anchor:"openenv.core.ListToolsObservation",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L259",parameters:[{name:"done",val:": bool = False"},{name:"reward",val:": bool | int | float | None = None"},{name:"metadata",val:": typing.Dict[str, typing.Any] = <factory>"},{name:"tools",val:": typing.List[openenv.core.env_server.mcp_types.Tool]"}]}),t(4),r(dn);var vn=e(dn,2),Ks=o(vn);n(Ks,{name:"class openenv.core.CallToolObservation",anchor:"openenv.core.CallToolObservation",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L269",parameters:[{name:"done",val:": bool = False"},{name:"reward",val:": bool | int | float | None = None"},{name:"metadata",val:": typing.Dict[str, typing.Any] = <factory>"},{name:"tool_name",val:": str"},{name:"result",val:": typing.Any = None"},{name:"error",val:": typing.Optional[openenv.core.env_server.mcp_types.ToolError] = None"}]}),t(4),r(vn);var mn=e(vn,2),$s=o(mn);n($s,{name:"class openenv.core.WSMCPMessage",anchor:"openenv.core.WSMCPMessage",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L290",parameters:[{name:"type",val:": typing.Literal['mcp'] = 'mcp'"},{name:"data",val:": typing.Dict[str, typing.Any]"}]}),t(4),r(mn);var un=e(mn,2),ei=o(un);n(ei,{name:"class openenv.core.WSMCPResponse",anchor:"openenv.core.WSMCPResponse",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/env_server/mcp_types.py#L302",parameters:[{name:"type",val:": str = 'mcp'"},{name:"data",val:": typing.Dict[str, typing.Any]"}]}),t(4),r(un);var Vr=e(un,2);u(Vr,{title:"MCP client",local:"openenv.core.MCPClientBase",headingTag:"h3"});var gn=e(Vr,2),Zr=o(gn);n(Zr,{name:"class openenv.core.MCPClientBase",anchor:"openenv.core.MCPClientBase",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/mcp_client.py#L94",parameters:[{name:"base_url",val:": str"},{name:"connect_timeout_s",val:": float = 10.0"},{name:"message_timeout_s",val:": float = 60.0"},{name:"websocket_ping_interval_s",val:": typing.Optional[float] = 20.0"},{name:"websocket_ping_timeout_s",val:": typing.Optional[float] = 20.0"},{name:"provider",val:": typing.Optional[typing.Any] = None"},{name:"mode",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"openenv.core.MCPClientBase._tools_cache",description:"<strong>_tools_cache</strong> — Cached list of tools (populated on first <code>list_tools()</code> call)",name:"_tools_cache"}]});var bn=e(Zr,6),ni=o(bn);n(ni,{name:"close",anchor:"openenv.core.MCPClientBase.close",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/mcp_client.py#L342",parameters:[]}),t(4),r(bn);var Yr=e(bn,2),zr=o(Yr);n(zr,{name:"list_tools",anchor:"openenv.core.MCPClientBase.list_tools",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/mcp_client.py#L219",parameters:[{name:"use_cache",val:": bool = True"}],parametersDescription:[{anchor:"openenv.core.MCPClientBase.list_tools.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| If <code>True</code>, return cached tools if available. Set to <code>False</code> to force a fresh request.`,name:"use_cache"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>List of <code>Tool</code> objects with name, description, and input_schema.</p> | |
| `});var oi=e(zr,4);l(oi,{anchor:"openenv.core.MCPClientBase.list_tools.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"dG9vbHMlMjAlM0QlMjBhd2FpdCUyMGVudi5saXN0X3Rvb2xzKCklMEFmb3IlMjB0b29sJTIwaW4lMjB0b29scyUzQSUwQSUyMCUyMCUyMCUyMHByaW50KGYlMjIlN0J0b29sLm5hbWUlN0QlM0ElMjAlN0J0b29sLmRlc2NyaXB0aW9uJTdEJTIyKQ==",highlighted:`tools = <span class="hljs-keyword">await</span> env.list_tools() | |
| <span class="hljs-keyword">for</span> tool <span class="hljs-keyword">in</span> tools: | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">f"<span class="hljs-subst">{tool.name}</span>: <span class="hljs-subst">{tool.description}</span>"</span>)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}}),r(Yr),r(gn);var hn=e(gn,2),Fr=o(hn);n(Fr,{name:"class openenv.core.MCPToolClient",anchor:"openenv.core.MCPToolClient",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/mcp_client.py#L372",parameters:[{name:"base_url",val:": str"},{name:"connect_timeout_s",val:": float = 10.0"},{name:"message_timeout_s",val:": float = 60.0"},{name:"websocket_ping_interval_s",val:": typing.Optional[float] = 20.0"},{name:"websocket_ping_timeout_s",val:": typing.Optional[float] = 20.0"},{name:"provider",val:": typing.Optional[typing.Any] = None"},{name:"mode",val:": typing.Optional[str] = None"}]});var Or=e(Fr,10);l(Or,{anchor:"openenv.core.MCPToolClient.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"YXN5bmMlMjB3aXRoJTIwTUNQVG9vbENsaWVudChiYXNlX3VybCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDAwJTIyKSUyMGFzJTIwZW52JTNBJTBBJTIwJTIwJTIwJTIwJTIzJTIwUmVzZXQlMjB0aGUlMjBlbnZpcm9ubWVudCUwQSUyMCUyMCUyMCUyMGF3YWl0JTIwZW52LnJlc2V0KCklMEElMEElMjAlMjAlMjAlMjAlMjMlMjBEaXNjb3ZlciUyMGF2YWlsYWJsZSUyMHRvb2xzJTBBJTIwJTIwJTIwJTIwdG9vbHMlMjAlM0QlMjBhd2FpdCUyMGVudi5saXN0X3Rvb2xzKCklMEElMjAlMjAlMjAlMjBwcmludCglNUJ0Lm5hbWUlMjBmb3IlMjB0JTIwaW4lMjB0b29scyU1RCklMjAlMjAlMjMlMjAlNUInZWNob19tZXNzYWdlJyUyQyUyMCdlY2hvX3dpdGhfbGVuZ3RoJyU1RCUwQSUwQSUyMCUyMCUyMCUyMCUyMyUyMENhbGwlMjBhJTIwdG9vbCUyMGRpcmVjdGx5JTBBJTIwJTIwJTIwJTIwcmVzdWx0JTIwJTNEJTIwYXdhaXQlMjBlbnYuY2FsbF90b29sKCUyMmVjaG9fbWVzc2FnZSUyMiUyQyUyMG1lc3NhZ2UlM0QlMjJIZWxsbyElMjIpJTBBJTIwJTIwJTIwJTIwcHJpbnQocmVzdWx0KSUyMCUyMCUyMyUyMCUyMkhlbGxvISUyMiUwQSUwQSUyMCUyMCUyMCUyMCUyMyUyME9yJTIwdXNlJTIwdGhlJTIwZnVsbCUyMGFjdGlvbiUyMGludGVyZmFjZSUwQSUyMCUyMCUyMCUyMGZyb20lMjBvcGVuZW52LmNvcmUuZW52X3NlcnZlci5tY3BfdHlwZXMlMjBpbXBvcnQlMjBDYWxsVG9vbEFjdGlvbiUwQSUyMCUyMCUyMCUyMHN0ZXBfcmVzdWx0JTIwJTNEJTIwYXdhaXQlMjBlbnYuc3RlcChDYWxsVG9vbEFjdGlvbiglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0b29sX25hbWUlM0QlMjJlY2hvX3dpdGhfbGVuZ3RoJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYXJndW1lbnRzJTNEJTdCJTIybWVzc2FnZSUyMiUzQSUyMCUyMlRlc3QlMjIlN0QlMEElMjAlMjAlMjAlMjApKSUwQSUyMCUyMCUyMCUyMHByaW50KHN0ZXBfcmVzdWx0Lm9ic2VydmF0aW9uLnJlc3VsdCk=",highlighted:`<span class="hljs-keyword">async</span> <span class="hljs-keyword">with</span> MCPToolClient(base_url=<span class="hljs-string">"http://localhost:8000"</span>) <span class="hljs-keyword">as</span> env: | |
| <span class="hljs-comment"># Reset the environment</span> | |
| <span class="hljs-keyword">await</span> env.reset() | |
| <span class="hljs-comment"># Discover available tools</span> | |
| tools = <span class="hljs-keyword">await</span> env.list_tools() | |
| <span class="hljs-built_in">print</span>([t.name <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> tools]) <span class="hljs-comment"># ['echo_message', 'echo_with_length']</span> | |
| <span class="hljs-comment"># Call a tool directly</span> | |
| result = <span class="hljs-keyword">await</span> env.call_tool(<span class="hljs-string">"echo_message"</span>, message=<span class="hljs-string">"Hello!"</span>) | |
| <span class="hljs-built_in">print</span>(result) <span class="hljs-comment"># "Hello!"</span> | |
| <span class="hljs-comment"># Or use the full action interface</span> | |
| <span class="hljs-keyword">from</span> openenv.core.env_server.mcp_types <span class="hljs-keyword">import</span> CallToolAction | |
| step_result = <span class="hljs-keyword">await</span> env.step(CallToolAction( | |
| tool_name=<span class="hljs-string">"echo_with_length"</span>, | |
| arguments={<span class="hljs-string">"message"</span>: <span class="hljs-string">"Test"</span>} | |
| )) | |
| <span class="hljs-built_in">print</span>(step_result.observation.result)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var Xr=e(Or,2);l(Xr,{anchor:"openenv.core.MCPToolClient.example-2",children:(s,c)=>{var a=Dc(),i=e(v(a),2);p(i,{code:"ZW52JTIwJTNEJTIwTUNQVG9vbENsaWVudChiYXNlX3VybCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDAwJTIyKS5zeW5jKCklMEF3aXRoJTIwZW52JTNBJTBBJTIwJTIwJTIwJTIwdG9vbHMlMjAlM0QlMjBlbnYubGlzdF90b29scygpJTBBJTIwJTIwJTIwJTIwcmVzdWx0JTIwJTNEJTIwZW52LmNhbGxfdG9vbCglMjJlY2hvX21lc3NhZ2UlMjIlMkMlMjBtZXNzYWdlJTNEJTIySGVsbG8hJTIyKQ==",highlighted:`env = MCPToolClient(base_url=<span class="hljs-string">"http://localhost:8000"</span>).sync() | |
| <span class="hljs-keyword">with</span> env: | |
| tools = env.list_tools() | |
| result = env.call_tool(<span class="hljs-string">"echo_message"</span>, message=<span class="hljs-string">"Hello!"</span>)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var _n=e(Xr,2),Qr=o(_n);n(Qr,{name:"call_tool",anchor:"openenv.core.MCPToolClient.call_tool",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/mcp_client.py#L417",parameters:[{name:"name",val:": str"},{name:"**kwargs",val:": typing.Any"}],parametersDescription:[{anchor:"openenv.core.MCPToolClient.call_tool.name",description:`<strong>name</strong> (<code>str</code>) — | |
| Name of the tool to invoke (must match a tool from <code>list_tools()</code>).`,name:"name"},{anchor:"openenv.core.MCPToolClient.call_tool.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Arguments to pass to the tool. Must match the tool’s input_schema.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The tool’s result. The type depends on the tool being called.</p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>RuntimeError</code> — If the server returns an error response.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>RuntimeError</code></p> | |
| `});var ri=e(Qr,6);l(ri,{anchor:"openenv.core.MCPToolClient.call_tool.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"cmVzdWx0JTIwJTNEJTIwYXdhaXQlMjBlbnYuY2FsbF90b29sKCUyMmFkZCUyMiUyQyUyMGElM0Q1JTJDJTIwYiUzRDMpJTBBcHJpbnQocmVzdWx0KSUyMCUyMCUyMyUyMDglMEElMEFyZXN1bHQlMjAlM0QlMjBhd2FpdCUyMGVudi5jYWxsX3Rvb2woJTIyZ3JlZXQlMjIlMkMlMjBuYW1lJTNEJTIyQ2xhdWRlJTIyKSUwQXByaW50KHJlc3VsdCklMjAlMjAlMjMlMjAlMjJIZWxsbyUyQyUyMENsYXVkZSElMjI=",highlighted:`result = <span class="hljs-keyword">await</span> env.call_tool(<span class="hljs-string">"add"</span>, a=<span class="hljs-number">5</span>, b=<span class="hljs-number">3</span>) | |
| <span class="hljs-built_in">print</span>(result) <span class="hljs-comment"># 8</span> | |
| result = <span class="hljs-keyword">await</span> env.call_tool(<span class="hljs-string">"greet"</span>, name=<span class="hljs-string">"Claude"</span>) | |
| <span class="hljs-built_in">print</span>(result) <span class="hljs-comment"># "Hello, Claude!"</span>`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}}),r(_n);var yn=e(_n,2),qr=o(yn);n(qr,{name:"get_tool",anchor:"openenv.core.MCPToolClient.get_tool",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/mcp_client.py#L493",parameters:[{name:"name",val:": str"}],parametersDescription:[{anchor:"openenv.core.MCPToolClient.get_tool.name",description:`<strong>name</strong> (<code>str</code>) — | |
| Name of the tool to find.`,name:"name"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The <code>Tool</code> object if found, <code>None</code> otherwise.</p> | |
| `});var ti=e(qr,4);l(ti,{anchor:"openenv.core.MCPToolClient.get_tool.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"dG9vbCUyMCUzRCUyMGF3YWl0JTIwZW52LmdldF90b29sKCUyMmVjaG9fbWVzc2FnZSUyMiklMEFpZiUyMHRvb2wlM0ElMEElMjAlMjAlMjAlMjBwcmludCh0b29sLmRlc2NyaXB0aW9uKSUwQSUyMCUyMCUyMCUyMHByaW50KHRvb2wuaW5wdXRfc2NoZW1hKQ==",highlighted:`tool = <span class="hljs-keyword">await</span> env.get_tool(<span class="hljs-string">"echo_message"</span>) | |
| <span class="hljs-keyword">if</span> tool: | |
| <span class="hljs-built_in">print</span>(tool.description) | |
| <span class="hljs-built_in">print</span>(tool.input_schema)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}}),r(yn);var Hr=e(yn,2),ai=o(Hr);n(ai,{name:"has_tool",anchor:"openenv.core.MCPToolClient.has_tool",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/mcp_client.py#L519",parameters:[{name:"name",val:": str"}],parametersDescription:[{anchor:"openenv.core.MCPToolClient.has_tool.name",description:`<strong>name</strong> (<code>str</code>) — | |
| Name of the tool to check.`,name:"name"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>True</code> if the tool exists, <code>False</code> otherwise.</p> | |
| `}),t(2),r(Hr),r(hn);var Kr=e(hn,2);u(Kr,{title:"Rubrics",local:"openenv.core.rubrics.Rubric",headingTag:"h2"});var fn=e(Kr,2),$r=o(fn);n($r,{name:"class openenv.core.rubrics.Rubric",anchor:"openenv.core.rubrics.Rubric",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L17",parameters:[]});var et=e($r,6);l(et,{anchor:"openenv.core.rubrics.Rubric.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"Y2xhc3MlMjBNeVJ1YnJpYyhSdWJyaWMpJTNBJTBBJTIwJTIwJTIwJTIwZGVmJTIwZm9yd2FyZChzZWxmJTJDJTIwYWN0aW9uJTJDJTIwb2JzZXJ2YXRpb24pJTIwLSUzRSUyMGZsb2F0JTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwMS4wJTIwaWYlMjBhY3Rpb24udmFsaWQlMjBlbHNlJTIwMC4wJTBBJTBBcnVicmljJTIwJTNEJTIwTXlSdWJyaWMoKSUwQXJld2FyZCUyMCUzRCUyMHJ1YnJpYyhhY3Rpb24lMkMlMjBvYnNlcnZhdGlvbik=",highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">MyRubric</span>(<span class="hljs-title class_ inherited__">Rubric</span>): | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, action, observation</span>) -> <span class="hljs-built_in">float</span>: | |
| <span class="hljs-keyword">return</span> <span class="hljs-number">1.0</span> <span class="hljs-keyword">if</span> action.valid <span class="hljs-keyword">else</span> <span class="hljs-number">0.0</span> | |
| rubric = MyRubric() | |
| reward = rubric(action, observation)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var Mn=e(et,4),si=o(Mn);n(si,{name:"children",anchor:"openenv.core.rubrics.Rubric.children",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L164",parameters:[]}),t(2),r(Mn);var wn=e(Mn,2),ii=o(wn);n(ii,{name:"forward",anchor:"openenv.core.rubrics.Rubric.forward",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L129",parameters:[{name:"action",val:": typing.Any"},{name:"observation",val:": typing.Any"}],parametersDescription:[{anchor:"openenv.core.rubrics.Rubric.forward.action",description:"<strong>action</strong> — The action taken by the agent.",name:"action"},{anchor:"openenv.core.rubrics.Rubric.forward.observation",description:"<strong>observation</strong> — The resulting observation.",name:"observation"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Reward value (typically 0.0 to 1.0).</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>float</code></p> | |
| `}),t(2),r(wn);var xn=e(wn,2),ci=o(xn);n(ci,{name:"get_rubric",anchor:"openenv.core.rubrics.Rubric.get_rubric",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L185",parameters:[{name:"path",val:": str"}],parametersDescription:[{anchor:"openenv.core.rubrics.Rubric.get_rubric.path",description:`<strong>path</strong> (<code>str</code>) — | |
| Dot-separated path (e.g., “code.syntax”).`,name:"path"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The rubric at the specified path.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>Rubric</code></p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>KeyError</code> — If the path does not exist.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>KeyError</code></p> | |
| `}),t(2),r(xn);var Tn=e(xn,2),li=o(Tn);n(li,{name:"load_state_dict",anchor:"openenv.core.rubrics.Rubric.load_state_dict",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L214",parameters:[{name:"state",val:": typing.Dict[str, typing.Any]"}]}),t(2),r(Tn);var Jn=e(Tn,2),pi=o(Jn);n(pi,{name:"named_children",anchor:"openenv.core.rubrics.Rubric.named_children",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L168",parameters:[]}),t(2),r(Jn);var jn=e(Jn,2),di=o(jn);n(di,{name:"named_rubrics",anchor:"openenv.core.rubrics.Rubric.named_rubrics",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L178",parameters:[{name:"prefix",val:": str = ''"}]}),t(2),r(jn);var Cn=e(jn,2),vi=o(Cn);n(vi,{name:"register_forward_hook",anchor:"openenv.core.rubrics.Rubric.register_forward_hook",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L142",parameters:[{name:"hook",val:": typing.Callable[[ForwardRef('Rubric'), typing.Any, typing.Any, float], NoneType]"}],parametersDescription:[{anchor:"openenv.core.rubrics.Rubric.register_forward_hook.hook",description:`<strong>hook</strong> (<code>Callable</code>) — | |
| Callable with signature (rubric, action, observation, result).`,name:"hook"}]}),t(2),r(Cn);var kn=e(Cn,2),mi=o(kn);n(mi,{name:"register_forward_pre_hook",anchor:"openenv.core.rubrics.Rubric.register_forward_pre_hook",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L153",parameters:[{name:"hook",val:": typing.Callable[[ForwardRef('Rubric'), typing.Any, typing.Any], NoneType]"}],parametersDescription:[{anchor:"openenv.core.rubrics.Rubric.register_forward_pre_hook.hook",description:`<strong>hook</strong> (<code>Callable</code>) — | |
| Callable with signature (rubric, action, observation).`,name:"hook"}]}),t(2),r(kn);var Un=e(kn,2),ui=o(Un);n(ui,{name:"reset",anchor:"openenv.core.rubrics.Rubric.reset",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L206",parameters:[]}),t(2),r(Un);var In=e(Un,2),gi=o(In);n(gi,{name:"rubrics",anchor:"openenv.core.rubrics.Rubric.rubrics",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L172",parameters:[]}),t(2),r(In);var nt=e(In,2),bi=o(nt);n(bi,{name:"state_dict",anchor:"openenv.core.rubrics.Rubric.state_dict",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/base.py#L210",parameters:[]}),t(2),r(nt),r(fn);var An=e(fn,2),ot=o(An);n(ot,{name:"class openenv.core.rubrics.Sequential",anchor:"openenv.core.rubrics.Sequential",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L27",parameters:[{name:"*rubrics",val:": Rubric"}]});var rt=e(ot,6);l(rt,{anchor:"openenv.core.rubrics.Sequential.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"cnVicmljJTIwJTNEJTIwU2VxdWVudGlhbCglMEElMjAlMjAlMjAlMjBHYXRlKENvbXBpbGVzKCkpJTJDJTBBJTIwJTIwJTIwJTIwR2F0ZShQYXNzZXNUZXN0cygpJTJDJTIwdGhyZXNob2xkJTNEMC41KSUyQyUwQSUyMCUyMCUyMCUyMFdlaWdodGVkU3VtKCU1QlBhc3Nlc1Rlc3RzKCklMkMlMjBTdHlsZVJ1YnJpYygpJTVEJTJDJTIwd2VpZ2h0cyUzRCU1QjAuNyUyQyUyMDAuMyU1RCklMEEp",highlighted:`rubric = Sequential( | |
| Gate(Compiles()), | |
| Gate(PassesTests(), threshold=<span class="hljs-number">0.5</span>), | |
| WeightedSum([PassesTests(), StyleRubric()], weights=[<span class="hljs-number">0.7</span>, <span class="hljs-number">0.3</span>]) | |
| )`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var tt=e(rt,2),hi=o(tt);n(hi,{name:"forward",anchor:"openenv.core.rubrics.Sequential.forward",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L57",parameters:[{name:"action",val:": typing.Any"},{name:"observation",val:": typing.Any"}]}),t(2),r(tt),r(An);var Nn=e(An,2),at=o(Nn);n(at,{name:"class openenv.core.rubrics.Gate",anchor:"openenv.core.rubrics.Gate",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L167",parameters:[{name:"rubric",val:": Rubric"},{name:"threshold",val:": float = 1.0"}]});var st=e(at,6);l(st,{anchor:"openenv.core.rubrics.Gate.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"cnVicmljJTIwJTNEJTIwR2F0ZShQYXNzZXNUZXN0cygpJTJDJTIwdGhyZXNob2xkJTNEMC41KSUwQSUyMyUyMFJldHVybnMlMjBQYXNzZXNUZXN0cygpJTIwc2NvcmUlMjBpZiUyMCUzRSUzRCUyMDAuNSUyQyUyMGVsc2UlMjAwLjA=",highlighted:`rubric = Gate(PassesTests(), threshold=<span class="hljs-number">0.5</span>) | |
| <span class="hljs-comment"># Returns PassesTests() score if >= 0.5, else 0.0</span>`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var it=e(st,2),_i=o(it);n(_i,{name:"forward",anchor:"openenv.core.rubrics.Gate.forward",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L193",parameters:[{name:"action",val:": typing.Any"},{name:"observation",val:": typing.Any"}]}),t(2),r(it),r(Nn);var En=e(Nn,2),ct=o(En);n(ct,{name:"class openenv.core.rubrics.WeightedSum",anchor:"openenv.core.rubrics.WeightedSum",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L223",parameters:[{name:"rubrics",val:": typing.List[openenv.core.rubrics.base.Rubric]"},{name:"weights",val:": typing.List[float]"}]});var lt=e(ct,6);l(lt,{anchor:"openenv.core.rubrics.WeightedSum.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"cnVicmljJTIwJTNEJTIwV2VpZ2h0ZWRTdW0oJTBBJTIwJTIwJTIwJTIwJTVCUGFzc2VzVGVzdHMoKSUyQyUyMFN0eWxlUnVicmljKCklNUQlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRzJTNEJTVCMC43JTJDJTIwMC4zJTVEJTBBKQ==",highlighted:`rubric = WeightedSum( | |
| [PassesTests(), StyleRubric()], | |
| weights=[<span class="hljs-number">0.7</span>, <span class="hljs-number">0.3</span>] | |
| )`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var pt=e(lt,2),yi=o(pt);n(yi,{name:"forward",anchor:"openenv.core.rubrics.WeightedSum.forward",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L264",parameters:[{name:"action",val:": typing.Any"},{name:"observation",val:": typing.Any"}]}),t(2),r(pt),r(En);var Rn=e(En,2),dt=o(Rn);n(dt,{name:"class openenv.core.rubrics.RubricList",anchor:"openenv.core.rubrics.RubricList",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L326",parameters:[{name:"rubrics",val:": typing.List[openenv.core.rubrics.base.Rubric] = None"}]});var vt=e(dt,6);l(vt,{anchor:"openenv.core.rubrics.RubricList.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"Y2xhc3MlMjBNdWx0aUdhbWVSdWJyaWMoUnVicmljKSUzQSUwQSUyMCUyMCUyMCUyMGRlZiUyMF9faW5pdF9fKHNlbGYlMkMlMjBnYW1lcyUzQSUyMExpc3QlNUJzdHIlNUQpJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc3VwZXIoKS5fX2luaXRfXygpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2VsZi5nYW1lcyUyMCUzRCUyMFJ1YnJpY0xpc3QoJTVCR2FtZVJ1YnJpYyhnKSUyMGZvciUyMGclMjBpbiUyMGdhbWVzJTVEKSUwQSUwQSUyMCUyMCUyMCUyMGRlZiUyMGZvcndhcmQoc2VsZiUyQyUyMGFjdGlvbiUyQyUyMG9icyklMjAtJTNFJTIwZmxvYXQlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjBzZWxmLmdhbWVzJTVCb2JzLmdhbWVfaW5kZXglNUQoYWN0aW9uJTJDJTIwb2JzKQ==",highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">MultiGameRubric</span>(<span class="hljs-title class_ inherited__">Rubric</span>): | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, games: <span class="hljs-type">List</span>[<span class="hljs-built_in">str</span>]</span>): | |
| <span class="hljs-built_in">super</span>().__init__() | |
| <span class="hljs-variable language_">self</span>.games = RubricList([GameRubric(g) <span class="hljs-keyword">for</span> g <span class="hljs-keyword">in</span> games]) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, action, obs</span>) -> <span class="hljs-built_in">float</span>: | |
| <span class="hljs-keyword">return</span> <span class="hljs-variable language_">self</span>.games[obs.game_index](action, obs)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var Sn=e(vt,2),fi=o(Sn);n(fi,{name:"append",anchor:"openenv.core.rubrics.RubricList.append",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L365",parameters:[{name:"rubric",val:": Rubric"}]}),t(2),r(Sn);var Ln=e(Sn,2),Mi=o(Ln);n(Mi,{name:"extend",anchor:"openenv.core.rubrics.RubricList.extend",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L371",parameters:[{name:"rubrics",val:": typing.List[openenv.core.rubrics.base.Rubric]"}]}),t(2),r(Ln);var mt=e(Ln,2),wi=o(mt);n(wi,{name:"forward",anchor:"openenv.core.rubrics.RubricList.forward",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L358",parameters:[{name:"action",val:": typing.Any"},{name:"observation",val:": typing.Any"}]}),t(2),r(mt),r(Rn);var Dn=e(Rn,2),ut=o(Dn);n(ut,{name:"class openenv.core.rubrics.RubricDict",anchor:"openenv.core.rubrics.RubricDict",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L386",parameters:[{name:"rubrics",val:": typing.Dict[str, openenv.core.rubrics.base.Rubric] = None"}]});var gt=e(ut,6);l(gt,{anchor:"openenv.core.rubrics.RubricDict.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"Y2xhc3MlMjBBdGFyaVJ1YnJpYyhSdWJyaWMpJTNBJTBBJTIwJTIwJTIwJTIwZGVmJTIwX19pbml0X18oc2VsZiklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzdXBlcigpLl9faW5pdF9fKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzZWxmLmdhbWVzJTIwJTNEJTIwUnVicmljRGljdCglN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJwb25nJTIyJTNBJTIwUG9uZ1J1YnJpYygpJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyYnJlYWtvdXQlMjIlM0ElMjBCcmVha291dFJ1YnJpYygpJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc3BhY2VfaW52YWRlcnMlMjIlM0ElMjBTcGFjZUludmFkZXJzUnVicmljKCklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0QpJTBBJTBBJTIwJTIwJTIwJTIwZGVmJTIwZm9yd2FyZChzZWxmJTJDJTIwYWN0aW9uJTJDJTIwb2JzKSUyMC0lM0UlMjBmbG9hdCUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMHNlbGYuZ2FtZXMlNUJvYnMuZ2FtZV9pZCU1RChhY3Rpb24lMkMlMjBvYnMpJTBBJTBBJTIzJTIwQWNjZXNzJTNBJTIwZW52LnJ1YnJpYy5nYW1lcyU1QiUyMnBvbmclMjIlNUQ=",highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">AtariRubric</span>(<span class="hljs-title class_ inherited__">Rubric</span>): | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self</span>): | |
| <span class="hljs-built_in">super</span>().__init__() | |
| <span class="hljs-variable language_">self</span>.games = RubricDict({ | |
| <span class="hljs-string">"pong"</span>: PongRubric(), | |
| <span class="hljs-string">"breakout"</span>: BreakoutRubric(), | |
| <span class="hljs-string">"space_invaders"</span>: SpaceInvadersRubric(), | |
| }) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, action, obs</span>) -> <span class="hljs-built_in">float</span>: | |
| <span class="hljs-keyword">return</span> <span class="hljs-variable language_">self</span>.games[obs.game_id](action, obs) | |
| <span class="hljs-comment"># Access: env.rubric.games["pong"]</span>`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var Bn=e(gt,2),xi=o(Bn);n(xi,{name:"forward",anchor:"openenv.core.rubrics.RubricDict.forward",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L424",parameters:[{name:"action",val:": typing.Any"},{name:"observation",val:": typing.Any"}]}),t(2),r(Bn);var Wn=e(Bn,2),Ti=o(Wn);n(Ti,{name:"items",anchor:"openenv.core.rubrics.RubricDict.items",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L458",parameters:[]}),t(2),r(Wn);var Gn=e(Wn,2),Ji=o(Gn);n(Ji,{name:"keys",anchor:"openenv.core.rubrics.RubricDict.keys",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L450",parameters:[]}),t(2),r(Gn);var Pn=e(Gn,2),ji=o(Pn);n(ji,{name:"update",anchor:"openenv.core.rubrics.RubricDict.update",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L462",parameters:[{name:"rubrics",val:": typing.Union[typing.Dict[str, openenv.core.rubrics.base.Rubric], typing.Mapping[str, openenv.core.rubrics.base.Rubric]]"}]}),t(2),r(Pn);var bt=e(Pn,2),Ci=o(bt);n(Ci,{name:"values",anchor:"openenv.core.rubrics.RubricDict.values",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/containers.py#L454",parameters:[]}),t(2),r(bt),r(Dn);var Vn=e(Dn,2),ht=o(Vn);n(ht,{name:"class openenv.core.rubrics.TrajectoryRubric",anchor:"openenv.core.rubrics.TrajectoryRubric",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/trajectory.py#L22",parameters:[{name:"intermediate_reward",val:": float = 0.0"}]});var _t=e(ht,14);l(_t,{anchor:"openenv.core.rubrics.TrajectoryRubric.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"Y2xhc3MlMjBXaW5Mb3NzUnVicmljKFRyYWplY3RvcnlSdWJyaWMpJTNBJTBBJTIwJTIwJTIwJTIwZGVmJTIwc2NvcmVfdHJhamVjdG9yeShzZWxmJTJDJTIwdHJhamVjdG9yeSklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBfJTJDJTIwZmluYWxfb2JzJTIwJTNEJTIwdHJhamVjdG9yeSU1Qi0xJTVEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwMS4wJTIwaWYlMjBmaW5hbF9vYnMubWV0YWRhdGEuZ2V0KCd3b24nKSUyMGVsc2UlMjAwLjAlMEElMEElMjAlMjAlMjAlMjBkZWYlMjBjb21wdXRlX3N0ZXBfcmV3YXJkcyhzZWxmKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMEVxdWFsJTIwY3JlZGl0JTIwdG8lMjBhbGwlMjBzdGVwcyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHNjb3JlJTIwJTNEJTIwc2VsZi5zY29yZV90cmFqZWN0b3J5KHNlbGYuX3RyYWplY3RvcnkpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTVCc2NvcmUlNUQlMjAqJTIwbGVuKHNlbGYuX3RyYWplY3RvcnkpJTBBJTBBcnVicmljJTIwJTNEJTIwV2luTG9zc1J1YnJpYygpJTBBZm9yJTIwYWN0aW9uJTJDJTIwb2JzJTIwaW4lMjBlcGlzb2RlJTNBJTBBJTIwJTIwJTIwJTIwcmV3YXJkJTIwJTNEJTIwcnVicmljKGFjdGlvbiUyQyUyMG9icyklMjAlMjAlMjMlMjAwLjAlMjB1bnRpbCUyMGRvbmUlMEFzdGVwX3Jld2FyZHMlMjAlM0QlMjBydWJyaWMuY29tcHV0ZV9zdGVwX3Jld2FyZHMoKSUyMCUyMCUyMyUyMENyZWRpdCUyMGFzc2lnbm1lbnQ=",highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">WinLossRubric</span>(<span class="hljs-title class_ inherited__">TrajectoryRubric</span>): | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">score_trajectory</span>(<span class="hljs-params">self, trajectory</span>): | |
| _, final_obs = trajectory[-<span class="hljs-number">1</span>] | |
| <span class="hljs-keyword">return</span> <span class="hljs-number">1.0</span> <span class="hljs-keyword">if</span> final_obs.metadata.get(<span class="hljs-string">'won'</span>) <span class="hljs-keyword">else</span> <span class="hljs-number">0.0</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_step_rewards</span>(<span class="hljs-params">self</span>): | |
| <span class="hljs-comment"># Equal credit to all steps</span> | |
| score = <span class="hljs-variable language_">self</span>.score_trajectory(<span class="hljs-variable language_">self</span>._trajectory) | |
| <span class="hljs-keyword">return</span> [score] * <span class="hljs-built_in">len</span>(<span class="hljs-variable language_">self</span>._trajectory) | |
| rubric = WinLossRubric() | |
| <span class="hljs-keyword">for</span> action, obs <span class="hljs-keyword">in</span> episode: | |
| reward = rubric(action, obs) <span class="hljs-comment"># 0.0 until done</span> | |
| step_rewards = rubric.compute_step_rewards() <span class="hljs-comment"># Credit assignment</span>`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var Zn=e(_t,2),ki=o(Zn);n(ki,{name:"compute_step_rewards",anchor:"openenv.core.rubrics.TrajectoryRubric.compute_step_rewards",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/trajectory.py#L107",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Rewards, one per step. Length matches len(trajectory).</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>list[float]</code></p> | |
| `}),t(4),r(Zn);var Yn=e(Zn,2),Ui=o(Yn);n(Ui,{name:"forward",anchor:"openenv.core.rubrics.TrajectoryRubric.forward",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/trajectory.py#L73",parameters:[{name:"action",val:": typing.Any"},{name:"observation",val:": typing.Any"}],parametersDescription:[{anchor:"openenv.core.rubrics.TrajectoryRubric.forward.action",description:"<strong>action</strong> — The action taken.",name:"action"},{anchor:"openenv.core.rubrics.TrajectoryRubric.forward.observation",description:"<strong>observation</strong> — The resulting observation. Must have a ‘done’ attribute.",name:"observation"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>intermediate_reward if not done, else score_trajectory() result.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>float</code></p> | |
| `}),t(4),r(Yn);var zn=e(Yn,2),Ii=o(zn);n(Ii,{name:"load_state_dict",anchor:"openenv.core.rubrics.TrajectoryRubric.load_state_dict",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/trajectory.py#L132",parameters:[{name:"state",val:": typing.Dict[str, typing.Any]"}]}),t(2),r(zn);var Fn=e(zn,2),Ai=o(Fn);n(Ai,{name:"reset",anchor:"openenv.core.rubrics.TrajectoryRubric.reset",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/trajectory.py#L119",parameters:[]}),t(2),r(Fn);var On=e(Fn,2),Ni=o(On);n(Ni,{name:"score_trajectory",anchor:"openenv.core.rubrics.TrajectoryRubric.score_trajectory",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/trajectory.py#L92",parameters:[{name:"trajectory",val:": typing.List[typing.Tuple[typing.Any, typing.Any]]"}],parametersDescription:[{anchor:"openenv.core.rubrics.TrajectoryRubric.score_trajectory.trajectory",description:`<strong>trajectory</strong> (<code>list</code>) — | |
| List of (action, observation) tuples.`,name:"trajectory"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Final trajectory score (typically 0.0 to 1.0).</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>float</code></p> | |
| `}),t(4),r(On);var yt=e(On,2),Ei=o(yt);n(Ei,{name:"state_dict",anchor:"openenv.core.rubrics.TrajectoryRubric.state_dict",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/trajectory.py#L128",parameters:[]}),t(2),r(yt),r(Vn);var Xn=e(Vn,2),ft=o(Xn);n(ft,{name:"class openenv.core.rubrics.ExponentialDiscountingTrajectoryRubric",anchor:"openenv.core.rubrics.ExponentialDiscountingTrajectoryRubric",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/trajectory.py#L138",parameters:[{name:"gamma",val:": float = 0.99"},{name:"intermediate_reward",val:": float = 0.0"}]});var Mt=e(ft,4);l(Mt,{anchor:"openenv.core.rubrics.ExponentialDiscountingTrajectoryRubric.example",children:(s,c)=>{var a=Bc(),i=e(v(a),2);p(i,{code:"cl90JTIwJTNEJTIwZ2FtbWElNUUoVC0xLXQpJTIwKiUyMFJfZmluYWw=",highlighted:"r_t = gamma^(T-1-t) * R_final",lang:"text",wrap:!1}),d(s,a)},$$slots:{default:!0}});var wt=e(Mt,6);l(wt,{anchor:"openenv.core.rubrics.ExponentialDiscountingTrajectoryRubric.example-2",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"Y2xhc3MlMjBDaGVzc1J1YnJpYyhFeHBvbmVudGlhbERpc2NvdW50aW5nVHJhamVjdG9yeVJ1YnJpYyklM0ElMEElMjAlMjAlMjAlMjBkZWYlMjBzY29yZV90cmFqZWN0b3J5KHNlbGYlMkMlMjB0cmFqZWN0b3J5KSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMF8lMkMlMjBmaW5hbF9vYnMlMjAlM0QlMjB0cmFqZWN0b3J5JTVCLTElNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRjb21lJTIwJTNEJTIwZmluYWxfb2JzLm1ldGFkYXRhLmdldCgnd2lubmVyJyklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZiUyMG91dGNvbWUlMjAlM0QlM0QlMjAnYWdlbnQnJTNBJTIwcmV0dXJuJTIwMS4wJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZWxpZiUyMG91dGNvbWUlMjAlM0QlM0QlMjAnb3Bwb25lbnQnJTNBJTIwcmV0dXJuJTIwMC4wJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZWxzZSUzQSUyMHJldHVybiUyMDAuNSUyMCUyMCUyMyUyMERyYXclMEElMEFydWJyaWMlMjAlM0QlMjBDaGVzc1J1YnJpYyhnYW1tYSUzRDAuOTkpJTBBcmV3YXJkJTIwJTNEJTIwcnVicmljKGFjdGlvbiUyQyUyMG9icyklMjAlMjAlMjMlMjAwLjAlMjB1bnRpbCUyMGRvbmUlMkMlMjB0aGVuJTIwZmluYWwlMjBzY29yZSUwQXN0ZXBfcmV3YXJkcyUyMCUzRCUyMHJ1YnJpYy5jb21wdXRlX3N0ZXBfcmV3YXJkcygpJTIwJTIwJTIzJTIwRGlzY291bnRlZCUyMHBlci1zdGVwJTIwcmV3YXJkcw==",highlighted:`<span class="hljs-keyword">class</span> <span class="hljs-title class_">ChessRubric</span>(<span class="hljs-title class_ inherited__">ExponentialDiscountingTrajectoryRubric</span>): | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">score_trajectory</span>(<span class="hljs-params">self, trajectory</span>): | |
| _, final_obs = trajectory[-<span class="hljs-number">1</span>] | |
| outcome = final_obs.metadata.get(<span class="hljs-string">'winner'</span>) | |
| <span class="hljs-keyword">if</span> outcome == <span class="hljs-string">'agent'</span>: <span class="hljs-keyword">return</span> <span class="hljs-number">1.0</span> | |
| <span class="hljs-keyword">elif</span> outcome == <span class="hljs-string">'opponent'</span>: <span class="hljs-keyword">return</span> <span class="hljs-number">0.0</span> | |
| <span class="hljs-keyword">else</span>: <span class="hljs-keyword">return</span> <span class="hljs-number">0.5</span> <span class="hljs-comment"># Draw</span> | |
| rubric = ChessRubric(gamma=<span class="hljs-number">0.99</span>) | |
| reward = rubric(action, obs) <span class="hljs-comment"># 0.0 until done, then final score</span> | |
| step_rewards = rubric.compute_step_rewards() <span class="hljs-comment"># Discounted per-step rewards</span>`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var Qn=e(wt,2),Ri=o(Qn);n(Ri,{name:"compute_step_rewards",anchor:"openenv.core.rubrics.ExponentialDiscountingTrajectoryRubric.compute_step_rewards",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/trajectory.py#L187",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Discounted rewards where <code>step_rewards[t] = gamma^(T-1-t) * R_final</code>, | |
| T is the trajectory length and R_final is score_trajectory().</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>list[float]</code></p> | |
| `}),t(2),r(Qn);var xt=e(Qn,2),Si=o(xt);n(Si,{name:"state_dict",anchor:"openenv.core.rubrics.ExponentialDiscountingTrajectoryRubric.state_dict",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/trajectory.py#L201",parameters:[]}),t(2),r(xt),r(Xn);var qn=e(Xn,2),Tt=o(qn);n(Tt,{name:"class openenv.core.rubrics.LLMJudge",anchor:"openenv.core.rubrics.LLMJudge",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/llm_judge.py#L28",parameters:[{name:"prompt_template",val:": str"},{name:"client",val:": LLMClient"},{name:"score_pattern",val:": str | None = None"},{name:"default_score",val:": float = 0.0"},{name:"normalize",val:": bool = True"}],parametersDescription:[{anchor:"openenv.core.rubrics.LLMJudge.prompt_template",description:`<strong>prompt_template</strong> (<em>str</em>) — | |
| Template string with {action} and {observation} placeholders.`,name:"prompt_template"},{anchor:"openenv.core.rubrics.LLMJudge.client",description:`<strong>client</strong> (<em>LLMClient</em>) — | |
| An LLMClient instance for making LLM calls.`,name:"client"},{anchor:"openenv.core.rubrics.LLMJudge.score_pattern",description:`<strong>score_pattern</strong> (<em>str</em>, <em>optional</em>) — | |
| Regex to extract the score from the LLM response. Defaults to matching | |
| the first decimal number.`,name:"score_pattern"},{anchor:"openenv.core.rubrics.LLMJudge.default_score",description:`<strong>default_score</strong> (<em>float</em>, <em>optional</em>, defaults to <em>0.0</em>) — | |
| Score returned when parsing fails.`,name:"default_score"},{anchor:"openenv.core.rubrics.LLMJudge.normalize",description:`<strong>normalize</strong> (<em>bool</em>, <em>optional</em>, defaults to <em>True</em>) — | |
| If True, clamp extracted score to [0, 1].`,name:"normalize"}]});var Hn=e(Tt,6),Li=o(Hn);n(Li,{name:"forward",anchor:"openenv.core.rubrics.LLMJudge.forward",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/llm_judge.py#L64",parameters:[{name:"action",val:": typing.Any"},{name:"observation",val:": typing.Any"}],parametersDescription:[{anchor:"openenv.core.rubrics.LLMJudge.forward.action",description:"<strong>action</strong> — The action taken by the agent.",name:"action"},{anchor:"openenv.core.rubrics.LLMJudge.forward.observation",description:"<strong>observation</strong> — The resulting observation.",name:"observation"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Parsed score from the LLM response.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>float</code></p> | |
| `}),t(2),r(Hn);var Jt=e(Hn,2),Di=o(Jt);n(Di,{name:"state_dict",anchor:"openenv.core.rubrics.LLMJudge.state_dict",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/rubrics/llm_judge.py#L104",parameters:[]}),t(2),r(Jt),r(qn);var jt=e(qn,2);u(jt,{title:"Tools",local:"openenv.core.tools.RepoInfo",headingTag:"h2"});var Kn=e(jt,2),Bi=o(Kn);n(Bi,{name:"class openenv.core.tools.RepoInfo",anchor:"openenv.core.tools.RepoInfo",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/tools/git_server_client.py#L21",parameters:[{name:"name",val:": str"},{name:"url",val:": str"},{name:"commit",val:": str"},{name:"clone_url",val:": str"}]}),t(2),r(Kn);var $n=e(Kn,2),Ct=o($n);n(Ct,{name:"class openenv.core.tools.GitServerClient",anchor:"openenv.core.tools.GitServerClient",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/tools/git_server_client.py#L30",parameters:[{name:"gitea_url",val:": str"},{name:"username",val:": str"},{name:"password",val:": str"},{name:"workspace_dir",val:": str = '/workspace'"}],parametersDescription:[{anchor:"openenv.core.tools.GitServerClient.gitea_url",description:"<strong>gitea_url</strong> — URL of the Gitea server (e.g., “http://gitea:3000”)",name:"gitea_url"},{anchor:"openenv.core.tools.GitServerClient.username",description:"<strong>username</strong> — Gitea username for authentication",name:"username"},{anchor:"openenv.core.tools.GitServerClient.password",description:"<strong>password</strong> — Gitea password for authentication",name:"password"},{anchor:"openenv.core.tools.GitServerClient.workspace_dir",description:"<strong>workspace_dir</strong> — Local workspace directory for cloning repos",name:"workspace_dir"}]});var kt=e(Ct,8);l(kt,{anchor:"openenv.core.tools.GitServerClient.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"aW1wb3J0JTIwb3MlMEElMEElMjMlMjBDb25uZWN0JTIwdG8lMjBzaGFyZWQlMjBHaXRlYSUyMChjcmVkZW50aWFscyUyMGZyb20lMjBlbnZpcm9ubWVudCklMEFjbGllbnQlMjAlM0QlMjBHaXRTZXJ2ZXJDbGllbnQoJTBBJTIwJTIwJTIwJTIwZ2l0ZWFfdXJsJTNEb3MuZ2V0ZW52KCUyMkdJVEVBX1VSTCUyMiklMkMlMEElMjAlMjAlMjAlMjB1c2VybmFtZSUzRG9zLmdldGVudiglMjJHSVRFQV9VU0VSTkFNRSUyMiklMkMlMEElMjAlMjAlMjAlMjBwYXNzd29yZCUzRG9zLmdldGVudiglMjJHSVRFQV9QQVNTV09SRCUyMiklMEEpJTBBY2xpZW50LndhaXRfZm9yX3JlYWR5KCklMEElMjMlMjBDbG9uZSUyMHJlcG8lMjB0byUyMHdvcmtzcGFjZSUwQXBhdGglMjAlM0QlMjBjbGllbnQuY2xvbmVfdG9fd29ya3NwYWNlKCUyMm15LXJlcG8lMjIlMkMlMjBjb21taXQlM0QlMjJhYmMxMjMlMjIpJTBBJTIzJTIwRmFzdCUyMHJlc2V0JTIwdG8lMjBiYXNlJTIwc3RhdGUlMEFjbGllbnQucmVzZXRfd29ya3NwYWNlKCUyMm15LXJlcG8lMjIlMkMlMjBjb21taXQlM0QlMjJhYmMxMjMlMjIp",highlighted:`<span class="hljs-keyword">import</span> os | |
| <span class="hljs-comment"># Connect to shared Gitea (credentials from environment)</span> | |
| client = GitServerClient( | |
| gitea_url=os.getenv(<span class="hljs-string">"GITEA_URL"</span>), | |
| username=os.getenv(<span class="hljs-string">"GITEA_USERNAME"</span>), | |
| password=os.getenv(<span class="hljs-string">"GITEA_PASSWORD"</span>) | |
| ) | |
| client.wait_for_ready() | |
| <span class="hljs-comment"># Clone repo to workspace</span> | |
| path = client.clone_to_workspace(<span class="hljs-string">"my-repo"</span>, commit=<span class="hljs-string">"abc123"</span>) | |
| <span class="hljs-comment"># Fast reset to base state</span> | |
| client.reset_workspace(<span class="hljs-string">"my-repo"</span>, commit=<span class="hljs-string">"abc123"</span>)`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var eo=e(kt,2),Wi=o(eo);n(Wi,{name:"clone_to_workspace",anchor:"openenv.core.tools.GitServerClient.clone_to_workspace",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/tools/git_server_client.py#L184",parameters:[{name:"repo_name",val:": str"},{name:"target_dir",val:": str | None = None"},{name:"commit",val:": str = 'main'"}],parametersDescription:[{anchor:"openenv.core.tools.GitServerClient.clone_to_workspace.repo_name",description:`<strong>repo_name</strong> (<code>str</code>) — | |
| Name of repository to clone.`,name:"repo_name"},{anchor:"openenv.core.tools.GitServerClient.clone_to_workspace.target_dir",description:`<strong>target_dir</strong> (<code>str</code>, <em>optional</em>) — | |
| Target directory name. Defaults to <code>repo_name</code>.`,name:"target_dir"},{anchor:"openenv.core.tools.GitServerClient.clone_to_workspace.commit",description:`<strong>commit</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"main"</code>) — | |
| Commit hash or branch to check out.`,name:"commit"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Path to cloned repository.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>str</code></p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>RuntimeError</code> — If clone fails.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>RuntimeError</code></p> | |
| `}),t(4),r(eo);var no=e(eo,2),Gi=o(no);n(Gi,{name:"execute_git_command",anchor:"openenv.core.tools.GitServerClient.execute_git_command",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/tools/git_server_client.py#L318",parameters:[{name:"command",val:": str"},{name:"working_dir",val:": str = ''"}],parametersDescription:[{anchor:"openenv.core.tools.GitServerClient.execute_git_command.command",description:`<strong>command</strong> (<code>str</code>) — | |
| Git command to execute (without <code>git</code> prefix).`,name:"command"},{anchor:"openenv.core.tools.GitServerClient.execute_git_command.working_dir",description:`<strong>working_dir</strong> (<code>str</code>, <em>optional</em>, defaults to <code>""</code>) — | |
| Working directory relative to workspace.`,name:"working_dir"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>tuple</code> of (exit_code, stdout, stderr).</p> | |
| `}),t(2),r(no);var oo=e(no,2),Pi=o(oo);n(Pi,{name:"get_current_commit",anchor:"openenv.core.tools.GitServerClient.get_current_commit",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/tools/git_server_client.py#L352",parameters:[{name:"repo_name",val:": str"}],parametersDescription:[{anchor:"openenv.core.tools.GitServerClient.get_current_commit.repo_name",description:`<strong>repo_name</strong> (<code>str</code>) — | |
| Name of repository in workspace.`,name:"repo_name"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Commit hash.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>str</code></p> | |
| `}),t(2),r(oo);var ro=e(oo,2),Vi=o(ro);n(Vi,{name:"list_repositories",anchor:"openenv.core.tools.GitServerClient.list_repositories",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/tools/git_server_client.py#L145",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>list</code> of repository information dictionaries.</p> | |
| `}),t(2),r(ro);var to=e(ro,2),Zi=o(to);n(Zi,{name:"reset_workspace",anchor:"openenv.core.tools.GitServerClient.reset_workspace",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/tools/git_server_client.py#L242",parameters:[{name:"repo_name",val:": str"},{name:"commit",val:": str = 'main'"}],parametersDescription:[{anchor:"openenv.core.tools.GitServerClient.reset_workspace.repo_name",description:`<strong>repo_name</strong> (<code>str</code>) — | |
| Name of repository (directory in workspace).`,name:"repo_name"},{anchor:"openenv.core.tools.GitServerClient.reset_workspace.commit",description:`<strong>commit</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"main"</code>) — | |
| Commit hash or branch to reset to.`,name:"commit"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>True if reset successful.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>bool</code></p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>RuntimeError</code> — If reset fails.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>RuntimeError</code></p> | |
| `}),t(6),r(to);var ao=e(to,2),Yi=o(ao);n(Yi,{name:"wait_for_ready",anchor:"openenv.core.tools.GitServerClient.wait_for_ready",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/tools/git_server_client.py#L114",parameters:[{name:"timeout",val:": int = 30"}],parametersDescription:[{anchor:"openenv.core.tools.GitServerClient.wait_for_ready.timeout",description:`<strong>timeout</strong> (<code>int</code>, <em>optional</em>, defaults to <code>30</code>) — | |
| Maximum seconds to wait.`,name:"timeout"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>True if server is ready, False otherwise.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>bool</code></p> | |
| `}),t(2),r(ao);var Ut=e(ao,2),zi=o(Ut);n(zi,{name:"workspace_exists",anchor:"openenv.core.tools.GitServerClient.workspace_exists",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/tools/git_server_client.py#L380",parameters:[{name:"repo_name",val:": str"}]}),t(2),r(Ut),r($n);var It=e($n,2);u(It,{title:"Container providers",local:"openenv.core.containers.runtime.ContainerProvider",headingTag:"h2"});var so=e(It,2),At=o(so);n(At,{name:"class openenv.core.containers.runtime.ContainerProvider",anchor:"openenv.core.containers.runtime.ContainerProvider",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L18",parameters:[]});var Nt=e(At,10);l(Nt,{anchor:"openenv.core.containers.runtime.ContainerProvider.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"cHJvdmlkZXIlMjAlM0QlMjBMb2NhbERvY2tlclByb3ZpZGVyKCklMEFiYXNlX3VybCUyMCUzRCUyMHByb3ZpZGVyLnN0YXJ0X2NvbnRhaW5lciglMjJlY2hvLWVudiUzQWxhdGVzdCUyMiklMEFwcmludChiYXNlX3VybCklMjAlMjAlMjMlMjBodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBODAwMCUwQSUyMyUyMFVzZSUyMHRoZSUyMGVudmlyb25tZW50JTIwdmlhJTIwYmFzZV91cmwlMEFwcm92aWRlci5zdG9wX2NvbnRhaW5lcigp",highlighted:`provider = LocalDockerProvider() | |
| base_url = provider.start_container(<span class="hljs-string">"echo-env:latest"</span>) | |
| <span class="hljs-built_in">print</span>(base_url) <span class="hljs-comment"># http://localhost:8000</span> | |
| <span class="hljs-comment"># Use the environment via base_url</span> | |
| provider.stop_container()`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var io=e(Nt,2),Fi=o(io);n(Fi,{name:"close",anchor:"openenv.core.containers.runtime.ContainerProvider.close",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L101",parameters:[]}),t(4),r(io);var co=e(io,2),Oi=o(co);n(Oi,{name:"start_container",anchor:"openenv.core.containers.runtime.ContainerProvider.start_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L42",parameters:[{name:"image",val:": str"},{name:"port",val:": Optional[int] = None"},{name:"env_vars",val:": Optional[Dict[str, str]] = None"},{name:"**kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.ContainerProvider.start_container.image",description:`<strong>image</strong> (<code>str</code>) — | |
| Provider-specific container <em>source</em> identifier. For | |
| container-based providers this is a registry image name (e.g. | |
| <code>"echo-env:latest"</code>); other providers may map it to a | |
| provider-specific source (see the provider’s documentation).`,name:"image"},{anchor:"openenv.core.containers.runtime.ContainerProvider.start_container.port",description:`<strong>port</strong> (<code>int</code>, <em>optional</em>) — | |
| Port to expose. If <code>None</code>, the provider chooses.`,name:"port"},{anchor:"openenv.core.containers.runtime.ContainerProvider.start_container.env_vars",description:`<strong>env_vars</strong> (<code>dict</code>, <em>optional</em>) — | |
| Environment variables to pass to container.`,name:"env_vars"},{anchor:"openenv.core.containers.runtime.ContainerProvider.start_container.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Provider-specific options.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Base URL to connect to the container (e.g., <code>"http://localhost:8000"</code>).</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>str</code></p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>RuntimeError</code> — If container fails to start.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>RuntimeError</code></p> | |
| `}),t(2),r(co);var lo=e(co,2),Xi=o(lo);n(Xi,{name:"stop_container",anchor:"openenv.core.containers.runtime.ContainerProvider.stop_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L74",parameters:[]}),t(4),r(lo);var Et=e(lo,2),Qi=o(Et);n(Qi,{name:"wait_for_ready",anchor:"openenv.core.containers.runtime.ContainerProvider.wait_for_ready",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L83",parameters:[{name:"base_url",val:": str"},{name:"timeout_s",val:": float = 30.0"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.ContainerProvider.wait_for_ready.base_url",description:`<strong>base_url</strong> (<code>str</code>) — | |
| Base URL of the container.`,name:"base_url"},{anchor:"openenv.core.containers.runtime.ContainerProvider.wait_for_ready.timeout_s",description:`<strong>timeout_s</strong> (<code>float</code>, <em>optional</em>, defaults to <code>30.0</code>) — | |
| Maximum time to wait in seconds.`,name:"timeout_s"}],raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>TimeoutError</code> — If container doesn’t become ready in time.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>TimeoutError</code></p> | |
| `}),t(4),r(Et),r(so);var po=e(so,2),Rt=o(po);n(Rt,{name:"class openenv.core.containers.runtime.LocalDockerProvider",anchor:"openenv.core.containers.runtime.LocalDockerProvider",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L120",parameters:[]});var St=e(Rt,6);l(St,{anchor:"openenv.core.containers.runtime.LocalDockerProvider.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"cHJvdmlkZXIlMjAlM0QlMjBMb2NhbERvY2tlclByb3ZpZGVyKCklMEFiYXNlX3VybCUyMCUzRCUyMHByb3ZpZGVyLnN0YXJ0X2NvbnRhaW5lciglMjJlY2hvLWVudiUzQWxhdGVzdCUyMiklMEElMjMlMjBDb250YWluZXIlMjBydW5uaW5nJTIwb24lMjBodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBJTNDcmFuZG9tLXBvcnQlM0UlMEFwcm92aWRlci5zdG9wX2NvbnRhaW5lcigp",highlighted:`provider = LocalDockerProvider() | |
| base_url = provider.start_container(<span class="hljs-string">"echo-env:latest"</span>) | |
| <span class="hljs-comment"># Container running on http://localhost:<random-port></span> | |
| provider.stop_container()`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var vo=e(St,2),qi=o(vo);n(qi,{name:"start_container",anchor:"openenv.core.containers.runtime.LocalDockerProvider.start_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L161",parameters:[{name:"image",val:": str"},{name:"port",val:": Optional[int] = None"},{name:"env_vars",val:": Optional[Dict[str, str]] = None"},{name:"**kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.LocalDockerProvider.start_container.image",description:`<strong>image</strong> (<code>str</code>) — | |
| Docker image name.`,name:"image"},{anchor:"openenv.core.containers.runtime.LocalDockerProvider.start_container.port",description:`<strong>port</strong> (<code>int</code>, <em>optional</em>) — | |
| Port to expose. If <code>None</code>, finds an available port.`,name:"port"},{anchor:"openenv.core.containers.runtime.LocalDockerProvider.start_container.env_vars",description:`<strong>env_vars</strong> (<code>dict</code>, <em>optional</em>) — | |
| Environment variables for the container.`,name:"env_vars"},{anchor:"openenv.core.containers.runtime.LocalDockerProvider.start_container.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Additional Docker run options.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Base URL to connect to the container.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>str</code></p> | |
| `}),t(2),r(vo);var mo=e(vo,2),Hi=o(mo);n(Hi,{name:"stop_container",anchor:"openenv.core.containers.runtime.LocalDockerProvider.stop_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L227",parameters:[]}),t(2),r(mo);var Lt=e(mo,2),Ki=o(Lt);n(Ki,{name:"wait_for_ready",anchor:"openenv.core.containers.runtime.LocalDockerProvider.wait_for_ready",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L259",parameters:[{name:"base_url",val:": str"},{name:"timeout_s",val:": float = 30.0"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.LocalDockerProvider.wait_for_ready.base_url",description:`<strong>base_url</strong> (<code>str</code>) — | |
| Base URL of the container.`,name:"base_url"},{anchor:"openenv.core.containers.runtime.LocalDockerProvider.wait_for_ready.timeout_s",description:`<strong>timeout_s</strong> (<code>float</code>, <em>optional</em>, defaults to <code>30.0</code>) — | |
| Maximum time to wait in seconds.`,name:"timeout_s"}],raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>TimeoutError</code> — If container doesn’t become ready.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>TimeoutError</code></p> | |
| `}),t(2),r(Lt),r(po);var uo=e(po,2),Dt=o(uo);n(Dt,{name:"class openenv.core.containers.runtime.DockerSwarmProvider",anchor:"openenv.core.containers.runtime.DockerSwarmProvider",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L329",parameters:[{name:"auto_init_swarm",val:": bool = True"},{name:"overlay_network",val:": Optional[str] = None"}]});var go=e(Dt,6),$i=o(go);n($i,{name:"start_container",anchor:"openenv.core.containers.runtime.DockerSwarmProvider.start_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L366",parameters:[{name:"image",val:": str"},{name:"port",val:": Optional[int] = None"},{name:"env_vars",val:": Optional[Dict[str, str]] = None"},{name:"**kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.DockerSwarmProvider.start_container.image",description:`<strong>image</strong> (<code>str</code>) — | |
| Docker image name.`,name:"image"},{anchor:"openenv.core.containers.runtime.DockerSwarmProvider.start_container.port",description:`<strong>port</strong> (<code>int</code>, <em>optional</em>) — | |
| Port to expose. If <code>None</code>, finds an available port.`,name:"port"},{anchor:"openenv.core.containers.runtime.DockerSwarmProvider.start_container.env_vars",description:`<strong>env_vars</strong> (<code>dict</code>, <em>optional</em>) — | |
| Environment variables for the container.`,name:"env_vars"},{anchor:"openenv.core.containers.runtime.DockerSwarmProvider.start_container.replicas",description:`<strong>replicas</strong> (<code>int</code>, <em>optional</em>, defaults to <code>2</code>) — | |
| Number of container replicas.`,name:"replicas"},{anchor:"openenv.core.containers.runtime.DockerSwarmProvider.start_container.cpu_limit",description:`<strong>cpu_limit</strong> (<code>float</code> or <code>str</code>, <em>optional</em>) — | |
| CPU limit passed to <code>--limit-cpu</code>.`,name:"cpu_limit"},{anchor:"openenv.core.containers.runtime.DockerSwarmProvider.start_container.memory_limit",description:`<strong>memory_limit</strong> (<code>str</code>, <em>optional</em>) — | |
| Memory limit passed to <code>--limit-memory</code>.`,name:"memory_limit"},{anchor:"openenv.core.containers.runtime.DockerSwarmProvider.start_container.constraints",description:`<strong>constraints</strong> (<code>Sequence[str]</code>, <em>optional</em>) — | |
| Placement constraints.`,name:"constraints"},{anchor:"openenv.core.containers.runtime.DockerSwarmProvider.start_container.labels",description:`<strong>labels</strong> (<code>dict</code>, <em>optional</em>) — | |
| Service labels.`,name:"labels"},{anchor:"openenv.core.containers.runtime.DockerSwarmProvider.start_container.command",description:`<strong>command</strong> (<code>Sequence[str]</code> or <code>str</code>, <em>optional</em>) — | |
| Override container command.`,name:"command"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Base URL to connect to the service.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>str</code></p> | |
| `}),t(2),r(go);var bo=e(go,2),ec=o(bo);n(ec,{name:"stop_container",anchor:"openenv.core.containers.runtime.DockerSwarmProvider.stop_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L493",parameters:[]}),t(2),r(bo);var Bt=e(bo,2),nc=o(Bt);n(nc,{name:"wait_for_ready",anchor:"openenv.core.containers.runtime.DockerSwarmProvider.wait_for_ready",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L517",parameters:[{name:"base_url",val:": str"},{name:"timeout_s",val:": float = 30.0"}]}),t(4),r(Bt),r(uo);var ho=e(uo,2),Wt=o(ho);n(Wt,{name:"class openenv.core.containers.runtime.RuntimeProvider",anchor:"openenv.core.containers.runtime.RuntimeProvider",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L660",parameters:[]});var Gt=e(Wt,8);l(Gt,{anchor:"openenv.core.containers.runtime.RuntimeProvider.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"cHJvdmlkZXIlMjAlM0QlMjBVVlByb3ZpZGVyKHByb2plY3RfcGF0aCUzRCUyMiUyRnBhdGglMkZ0byUyRmVudiUyMiklMEFiYXNlX3VybCUyMCUzRCUyMHByb3ZpZGVyLnN0YXJ0KCklMEFwcmludChiYXNlX3VybCklMjAlMjAlMjMlMjBodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBODAwMCUwQXByb3ZpZGVyLnN0b3AoKQ==",highlighted:`provider = UVProvider(project_path=<span class="hljs-string">"/path/to/env"</span>) | |
| base_url = provider.start() | |
| <span class="hljs-built_in">print</span>(base_url) <span class="hljs-comment"># http://localhost:8000</span> | |
| provider.stop()`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var _o=e(Gt,2),oc=o(_o);n(oc,{name:"start",anchor:"openenv.core.containers.runtime.RuntimeProvider.start",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L679",parameters:[{name:"port",val:": Optional[int] = None"},{name:"env_vars",val:": Optional[Dict[str, str]] = None"},{name:"**kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.RuntimeProvider.start.port",description:`<strong>port</strong> (<code>int</code>, <em>optional</em>) — | |
| Port to expose. If <code>None</code>, the provider chooses.`,name:"port"},{anchor:"openenv.core.containers.runtime.RuntimeProvider.start.env_vars",description:`<strong>env_vars</strong> (<code>dict</code>, <em>optional</em>) — | |
| Environment variables for the runtime.`,name:"env_vars"},{anchor:"openenv.core.containers.runtime.RuntimeProvider.start.*kwargs",description:`*<strong>*kwargs</strong> — | |
| Additional runtime options.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Base URL to connect to the runtime.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>str</code></p> | |
| `}),t(2),r(_o);var yo=e(_o,2),rc=o(yo);n(rc,{name:"stop",anchor:"openenv.core.containers.runtime.RuntimeProvider.stop",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L701",parameters:[]}),t(2),r(yo);var Pt=e(yo,2),tc=o(Pt);n(tc,{name:"wait_for_ready",anchor:"openenv.core.containers.runtime.RuntimeProvider.wait_for_ready",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/providers.py#L708",parameters:[{name:"timeout_s",val:": float = 30.0"}]}),t(2),r(Pt),r(ho);var fo=e(ho,2),Vt=o(fo);n(Vt,{name:"class openenv.core.containers.runtime.UVProvider",anchor:"openenv.core.containers.runtime.UVProvider",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/uv_provider.py#L125",parameters:[{name:"project_path",val:": str"},{name:"app",val:": str = 'server.app:app'"},{name:"host",val:": str = '0.0.0.0'"},{name:"reload",val:": bool = False"},{name:"env_vars",val:": Optional[Dict[str, str]] = None"},{name:"context_timeout_s",val:": float = 60.0"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.UVProvider.project_path",description:`<strong>project_path</strong> (<em>str</em>) — | |
| Local path to a uv project (passed to <em>uv run —project</em>), or a | |
| <em>git+<url></url></em> spec that is cloned to a temp directory on <em>start()</em>.`,name:"project_path"},{anchor:"openenv.core.containers.runtime.UVProvider.app",description:`<strong>app</strong> (<em>str</em>, <em>optional</em>, defaults to <em>“server.app —app”</em>): | |
| ASGI application path for uvicorn.`,name:"app"},{anchor:"openenv.core.containers.runtime.UVProvider.host",description:`<strong>host</strong> (<em>str</em>, <em>optional</em>, defaults to <em>“0.0.0.0”</em>) — | |
| Host interface to bind to.`,name:"host"},{anchor:"openenv.core.containers.runtime.UVProvider.reload",description:`<strong>reload</strong> (<em>bool</em>, <em>optional</em>, defaults to <em>False</em>) — | |
| Whether to enable uvicorn’s reload mode.`,name:"reload"},{anchor:"openenv.core.containers.runtime.UVProvider.env_vars",description:`<strong>env_vars</strong> (<em>dict</em>, <em>optional</em>) — | |
| Environment variables to pass through to the spawned process.`,name:"env_vars"},{anchor:"openenv.core.containers.runtime.UVProvider.context_timeout_s",description:`<strong>context_timeout_s</strong> (<em>float</em>, <em>optional</em>, defaults to <em>60.0</em>) — | |
| How long to wait for the environment to become ready.`,name:"context_timeout_s"}]});var Zt=e(Vt,4);l(Zt,{anchor:"openenv.core.containers.runtime.UVProvider.example",children:(s,c)=>{var a=m(),i=e(v(a),2);p(i,{code:"cHJvdmlkZXIlMjAlM0QlMjBVVlByb3ZpZGVyKHByb2plY3RfcGF0aCUzRCUyMiUyRnBhdGglMkZ0byUyRmVudiUyMiklMEFiYXNlX3VybCUyMCUzRCUyMHByb3ZpZGVyLnN0YXJ0KCklMEFwcmludChiYXNlX3VybCklMjAlMjAlMjMlMjBodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBODAwMCUwQSUyMyUyMFVzZSUyMHRoZSUyMGVudmlyb25tZW50JTIwdmlhJTIwYmFzZV91cmwlMEFwcm92aWRlci5zdG9wKCk=",highlighted:`provider = UVProvider(project_path=<span class="hljs-string">"/path/to/env"</span>) | |
| base_url = provider.start() | |
| <span class="hljs-built_in">print</span>(base_url) <span class="hljs-comment"># http://localhost:8000</span> | |
| <span class="hljs-comment"># Use the environment via base_url</span> | |
| provider.stop()`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var Mo=e(Zt,2),ac=o(Mo);n(ac,{name:"start",anchor:"openenv.core.containers.runtime.UVProvider.start",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/uv_provider.py#L184",parameters:[{name:"port",val:": Optional[int] = None"},{name:"env_vars",val:": Optional[Dict[str, str]] = None"},{name:"workers",val:": int = 1"},{name:"**_",val:": Dict[str, str]"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.UVProvider.start.port",description:`<strong>port</strong> (<code>int</code>, <em>optional</em>) — | |
| The port to bind the environment to.`,name:"port"},{anchor:"openenv.core.containers.runtime.UVProvider.start.env_vars",description:`<strong>env_vars</strong> (<code>dict</code>, <em>optional</em>) — | |
| Environment variables to pass to the environment.`,name:"env_vars"},{anchor:"openenv.core.containers.runtime.UVProvider.start.workers",description:`<strong>workers</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) — | |
| The number of workers to use.`,name:"workers"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Base URL of the environment.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>str</code></p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>RuntimeError</code> — If the environment is already running.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>RuntimeError</code></p> | |
| `}),t(2),r(Mo);var wo=e(Mo,2),sc=o(wo);n(sc,{name:"stop",anchor:"openenv.core.containers.runtime.UVProvider.stop",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/uv_provider.py#L276",parameters:[]}),t(2),r(wo);var Yt=e(wo,2),ic=o(Yt);n(ic,{name:"wait_for_ready",anchor:"openenv.core.containers.runtime.UVProvider.wait_for_ready",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/uv_provider.py#L254",parameters:[{name:"timeout_s",val:": float | None = None"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.UVProvider.wait_for_ready.timeout_s",description:`<strong>timeout_s</strong> (<code>float</code>, <em>optional</em>) — | |
| Maximum time in seconds to wait for the environment to become | |
| ready. Defaults to the provider’s <code>context_timeout_s</code>.`,name:"timeout_s"}],raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>RuntimeError</code> — If the environment is not running.</li> | |
| <li><code>TimeoutError</code> — If the environment does not become ready within the timeout.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>RuntimeError</code> or <code>TimeoutError</code></p> | |
| `}),t(2),r(Yt),r(fo);var xo=e(fo,2),zt=o(xo);n(zt,{name:"class openenv.core.containers.runtime.daytona_provider.DaytonaProvider",anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/daytona_provider.py#L20",parameters:[{name:"image",val:": Optional[str] = None"},{name:"env_vars",val:": Optional[Dict[str, str]] = None"},{name:"api_key",val:": Optional[str] = None"},{name:"public",val:": bool = False"},{name:"resources",val:": Optional[Any] = None"},{name:"auto_stop_interval",val:": int = 15"},{name:"target",val:": Optional[str] = None"},{name:"on_snapshot_create_logs",val:": Optional[Callable[[str], None]] = None"},{name:"cmd",val:": Optional[str] = None"},{name:"create_timeout",val:": float = 300"}]});var To=e(zt,8),cc=o(To);n(cc,{name:"image_from_dockerfile",anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.image_from_dockerfile",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/daytona_provider.py#L233",parameters:[{name:"dockerfile_path",val:": str"},{name:"context_dir",val:": str | None = None"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.image_from_dockerfile.dockerfile_path",description:"<strong>dockerfile_path</strong> — Path to the Dockerfile on disk.",name:"dockerfile_path"},{anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.image_from_dockerfile.context_dir",description:`<strong>context_dir</strong> — Build context directory. Defaults to the | |
| Dockerfile’s grandparent directory, matching the | |
| <code>openenv init</code> convention where Dockerfiles live in | |
| <code><env>/server/Dockerfile</code> and the build context is | |
| <code><env>/</code>. Pass explicitly for non-standard layouts | |
| (e.g. <code>context_dir="."</code> for repo-root contexts).`,name:"context_dir"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><abs_path>”<code>string to pass to</code>start_container\`.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A \`“dockerfile</p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>FileNotFoundError</code> — If <em>dockerfile_path</em> does not exist.</li> | |
| <li><code>ValueError</code> — If <em>context_dir</em> is given but does not exist, | |
| or if COPY sources in the Dockerfile cannot be found | |
| under the resolved context directory.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>FileNotFoundError</code> or <code>ValueError</code></p> | |
| `}),t(4),r(To);var Jo=e(To,2),lc=o(Jo);n(lc,{name:"refresh_preview_url",anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.refresh_preview_url",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/daytona_provider.py#L471",parameters:[]}),t(4),r(Jo);var jo=e(Jo,2),pc=o(jo);n(pc,{name:"start_container",anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.start_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/daytona_provider.py#L316",parameters:[{name:"image",val:": Optional[str] = None"},{name:"port",val:": Optional[int] = None"},{name:"env_vars",val:": Optional[Dict[str, str]] = None"},{name:"**kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.start_container.image",description:`<strong>image</strong> — Docker image name (e.g. <code>"echo-env:latest"</code>), | |
| <code>"snapshot:<name>"</code> to create from a pre-built snapshot, | |
| or <code>"dockerfile:<path>"</code> returned by | |
| <code>image_from_dockerfile</code>. May be omitted when supplied | |
| to the constructor.`,name:"image"},{anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.start_container.port",description:`<strong>port</strong> — Must be <code>None</code> or <code>8000</code>. Daytona exposes port 8000 | |
| via its preview proxy; other ports raise <code>ValueError</code>.`,name:"port"},{anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.start_container.env_vars",description:"<strong>env_vars</strong> — Environment variables forwarded to the sandbox.",name:"env_vars"},{anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.start_container.*kwargs",description:`*<strong>*kwargs</strong> — <code>cmd</code> (str) to override the server command; | |
| remaining kwargs passed through to <code>Daytona.create()</code>.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>HTTPS preview URL for the sandbox (base_url).</p> | |
| `}),t(6),r(jo);var Co=e(jo,2),dc=o(Co);n(dc,{name:"stop_container",anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.stop_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/daytona_provider.py#L484",parameters:[]}),t(2),r(Co);var ko=e(Co,2),vc=o(ko);n(vc,{name:"strip_buildkit_syntax",anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.strip_buildkit_syntax",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/daytona_provider.py#L167",parameters:[{name:"dockerfile_content",val:": str"}]}),t(6),r(ko);var Ft=e(ko,2),mc=o(Ft);n(mc,{name:"wait_for_ready",anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.wait_for_ready",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/daytona_provider.py#L495",parameters:[{name:"base_url",val:": str"},{name:"timeout_s",val:": float = 120.0"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.wait_for_ready.base_url",description:"<strong>base_url</strong> — Preview URL returned by <code>start_container()</code>.",name:"base_url"},{anchor:"openenv.core.containers.runtime.daytona_provider.DaytonaProvider.wait_for_ready.timeout_s",description:"<strong>timeout_s</strong> — Maximum seconds to wait.",name:"timeout_s"}],raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>TimeoutError</code> — If the sandbox doesn’t become ready in time.</li> | |
| <li><code>RuntimeError</code> — If the server process died (detected via PID check).</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>TimeoutError</code> or <code>RuntimeError</code></p> | |
| `}),t(4),r(Ft),r(xo);var Uo=e(xo,2),Ot=o(Uo);n(Ot,{name:"class openenv.core.containers.runtime.aca_provider.ACASandboxProvider",anchor:"openenv.core.containers.runtime.aca_provider.ACASandboxProvider",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/aca_provider.py#L256",parameters:[{name:"subscription_id",val:": Optional[str] = None"},{name:"resource_group",val:": Optional[str] = None"},{name:"sandbox_group",val:": Optional[str] = None"},{name:"region",val:": Optional[str] = None"},{name:"endpoint",val:": Optional[str] = None"},{name:"credential",val:": Any = None"},{name:"cpu",val:": str = '1000m'"},{name:"memory",val:": str = '2048Mi'"},{name:"disk_size",val:": Optional[str] = None"},{name:"auto_suspend_seconds",val:": int = 900"},{name:"auto_suspend_mode",val:": Literal['Memory', 'Disk'] = 'Memory'"},{name:"labels",val:": Optional[Dict[str, str]] = None"},{name:"egress_policy",val:": Any = None"},{name:"anonymous_port",val:": Literal[True] | None = None"},{name:"image",val:": Optional[str] = None"},{name:"env_vars",val:": Optional[Dict[str, str]] = None"},{name:"cmd",val:": Optional[str] = None"},{name:"working_directory",val:": Optional[str] = None"},{name:"surface_server_logs",val:": bool = False"},{name:"create_timeout",val:": int = 300"},{name:"polling_interval",val:": int = 3"},{name:"sdk_kwargs",val:": Optional[dict[str, Any]] = None"},{name:"_adapter",val:": Any = None"}]});var Xt=e(Ot,14);l(Xt,{anchor:"openenv.core.containers.runtime.aca_provider.ACASandboxProvider.example",children:(s,c)=>{p(s,{code:"d2l0aCUyMEFDQVNhbmRib3hQcm92aWRlciglMEElMjAlMjAlMjAlMjBpbWFnZSUzRCUyMmRpc2slM0FteS1lbnYlMjIlMkMlMEElMjAlMjAlMjAlMjBhbm9ueW1vdXNfcG9ydCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjAuLi4lMkMlMEEpJTIwYXMlMjBwcm92aWRlciUzQSUwQSUyMCUyMCUyMCUyMGJhc2VfdXJsJTIwJTNEJTIwcHJvdmlkZXIuc3RhcnRfY29udGFpbmVyKGNtZCUzRC4uLiklMEElMjAlMjAlMjAlMjAuLi4lMEElMjMlMjBzYW5kYm94JTIwZGVsZXRlZCUyMGFuZCUyMFNESyUyMGNsaWVudCUyMGNsb3NlZCUyMG9uJTIwZXhpdA==",highlighted:`<span class="hljs-keyword">with</span> ACASandboxProvider( | |
| image=<span class="hljs-string">"disk:my-env"</span>, | |
| anonymous_port=<span class="hljs-literal">True</span>, | |
| ..., | |
| ) <span class="hljs-keyword">as</span> provider: | |
| base_url = provider.start_container(cmd=...) | |
| ... | |
| <span class="hljs-comment"># sandbox deleted and SDK client closed on exit</span>`,lang:"python",wrap:!1})},$$slots:{default:!0}});var Io=e(Xt,2),uc=o(Io);n(uc,{name:"close",anchor:"openenv.core.containers.runtime.aca_provider.ACASandboxProvider.close",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/aca_provider.py#L675",parameters:[]}),t(4),r(Io);var Ao=e(Io,2),Qt=o(Ao);n(Qt,{name:"deny_all_egress",anchor:"openenv.core.containers.runtime.aca_provider.ACASandboxProvider.deny_all_egress",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/aca_provider.py#L381",parameters:[{name:"allow",val:": Optional[list[str]] = None"}]});var gc=e(Qt,6);l(gc,{anchor:"openenv.core.containers.runtime.aca_provider.ACASandboxProvider.deny_all_egress.example",children:(s,c)=>{p(s,{code:"cHJvdmlkZXIlMjAlM0QlMjBBQ0FTYW5kYm94UHJvdmlkZXIoJTBBJTIwJTIwJTIwJTIwYW5vbnltb3VzX3BvcnQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwZWdyZXNzX3BvbGljeSUzREFDQVNhbmRib3hQcm92aWRlci5kZW55X2FsbF9lZ3Jlc3MoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYWxsb3clM0QlNUIlMjJteS1tb2RlbC5vcGVuYWkuYXp1cmUuY29tJTIyJTVEJTBBJTIwJTIwJTIwJTIwKSUyQyUwQSk=",highlighted:`provider = ACASandboxProvider( | |
| anonymous_port=<span class="hljs-literal">True</span>, | |
| egress_policy=ACASandboxProvider.deny_all_egress( | |
| allow=[<span class="hljs-string">"my-model.openai.azure.com"</span>] | |
| ), | |
| )`,lang:"python",wrap:!1})},$$slots:{default:!0}}),r(Ao);var No=e(Ao,2),bc=o(No);n(bc,{name:"start_container",anchor:"openenv.core.containers.runtime.aca_provider.ACASandboxProvider.start_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/aca_provider.py#L409",parameters:[{name:"image",val:": Optional[str] = None"},{name:"port",val:": Optional[int] = None"},{name:"env_vars",val:": Optional[Dict[str, str]] = None"},{name:"**kwargs",val:": Any"}]}),t(4),r(No);var Eo=e(No,2),hc=o(Eo);n(hc,{name:"stop_container",anchor:"openenv.core.containers.runtime.aca_provider.ACASandboxProvider.stop_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/aca_provider.py#L647",parameters:[]}),t(2),r(Eo);var qt=e(Eo,2),_c=o(qt);n(_c,{name:"wait_for_ready",anchor:"openenv.core.containers.runtime.aca_provider.ACASandboxProvider.wait_for_ready",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/aca_provider.py#L603",parameters:[{name:"base_url",val:": str"},{name:"timeout_s",val:": float = 120.0"}]}),t(4),r(qt),r(Uo);var Ro=e(Uo,2),Ht=o(Ro);n(Ht,{name:"class openenv.core.containers.runtime.modal_provider.ModalProvider",anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/modal_provider.py#L137",parameters:[{name:"image",val:": str | None = None"},{name:"env_vars",val:": dict[str, str] | None = None"},{name:"app_name",val:": str = 'openenv'"},{name:"use_sandbox_v2",val:": bool = False"},{name:"timeout",val:": int = 300"},{name:"cmd",val:": str | None = None"},{name:"cpu",val:": float | None = None"},{name:"memory",val:": int | None = None"},{name:"surface_server_logs",val:": bool = False"},{name:"_adapter",val:": Any = None"}]});var Kt=e(Ht,10);l(Kt,{anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.example",children:(s,c)=>{var a=Wc(),i=e(v(a),2);p(i,{code:"d2l0aCUyME1vZGFsUHJvdmlkZXIoYXBwX25hbWUlM0QlMjJvcGVuZW52JTIyJTJDJTIwY3B1JTNEMi4wJTJDJTIwbWVtb3J5JTNENDA5NiklMjBhcyUyMHByb3ZpZGVyJTNBJTBBJTIwJTIwJTIwJTIwaW1hZ2UlMjAlM0QlMjBNb2RhbFByb3ZpZGVyLmltYWdlX2Zyb21fZG9ja2VyZmlsZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJlbnZzJTJGZWNob19lbnYlMkZzZXJ2ZXIlMkZEb2NrZXJmaWxlJTIyJTBBJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMGJhc2VfdXJsJTIwJTNEJTIwcHJvdmlkZXIuc3RhcnRfY29udGFpbmVyKGltYWdlKSUwQSUyMCUyMCUyMCUyMHByb3ZpZGVyLndhaXRfZm9yX3JlYWR5KGJhc2VfdXJsKSUwQSUyMyUyMHNhbmRib3glMjB0ZXJtaW5hdGVkJTIwb24lMjBleGl0",highlighted:`<span class="hljs-keyword">with</span> ModalProvider(app_name=<span class="hljs-string">"openenv"</span>, cpu=<span class="hljs-number">2.0</span>, memory=<span class="hljs-number">4096</span>) <span class="hljs-keyword">as</span> provider: | |
| image = ModalProvider.image_from_dockerfile( | |
| <span class="hljs-string">"envs/echo_env/server/Dockerfile"</span> | |
| ) | |
| base_url = provider.start_container(image) | |
| provider.wait_for_ready(base_url) | |
| <span class="hljs-comment"># sandbox terminated on exit</span>`,lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var $t=e(Kt,2);l($t,{anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.example-2",children:(s,c)=>{var a=Gc(),i=e(v(a),2);p(i,{code:"cHJvdmlkZXIlMjAlM0QlMjBNb2RhbFByb3ZpZGVyKGFwcF9uYW1lJTNEJTIyb3BlbmVudiUyMiUyQyUyMHVzZV9zYW5kYm94X3YyJTNEVHJ1ZSk=",highlighted:'provider = ModalProvider(app_name=<span class="hljs-string">"openenv"</span>, use_sandbox_v2=<span class="hljs-literal">True</span>)',lang:"python",wrap:!1}),d(s,a)},$$slots:{default:!0}});var So=e($t,2),yc=o(So);n(yc,{name:"close",anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.close",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/modal_provider.py#L587",parameters:[]}),t(4),r(So);var Lo=e(So,2),fc=o(Lo);n(fc,{name:"image_from_dockerfile",anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.image_from_dockerfile",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/modal_provider.py#L336",parameters:[{name:"dockerfile_path",val:": str"},{name:"context_dir",val:": str | None = None"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.image_from_dockerfile.dockerfile_path",description:`<strong>dockerfile_path</strong> (<em>str</em>) — | |
| Path to the Dockerfile on disk.`,name:"dockerfile_path"},{anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.image_from_dockerfile.context_dir",description:`<strong>context_dir</strong> (<em>str</em>, <em>optional</em>) — | |
| Build context directory. Defaults to the Dockerfile’s | |
| grandparent directory, matching the <code>openenv init</code> | |
| convention where Dockerfiles live in | |
| <code><env>/server/Dockerfile</code> and the build context is | |
| <code><env>/</code>. Pass explicitly for non-standard layouts | |
| (e.g. <code>context_dir="."</code> for repo-root contexts).`,name:"context_dir"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <code>"dockerfile:<abs_path>"</code> string to pass to | |
| <code>start_container</code>.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><em>str</em></p> | |
| `,raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>FileNotFoundError</code> — If <em>dockerfile_path</em> does not exist.</li> | |
| <li><code>ValueError</code> — If <em>context_dir</em> is given but does not exist, | |
| or if COPY sources in the Dockerfile cannot be found | |
| under the resolved context directory.</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>FileNotFoundError</code> or <code>ValueError</code></p> | |
| `}),t(4),r(Lo);var Do=e(Lo,2),Mc=o(Do);n(Mc,{name:"start_container",anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.start_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/modal_provider.py#L436",parameters:[{name:"image",val:": str | None = None"},{name:"port",val:": int | None = None"},{name:"env_vars",val:": dict[str, str] | None = None"},{name:"**kwargs",val:": Any"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.start_container.image",description:`<strong>image</strong> (<em>str</em>, <em>optional</em>) — | |
| Registry image tag (e.g. <code>"echo-env:latest"</code>) or | |
| <code>"dockerfile:<path>"</code> returned by | |
| <code>image_from_dockerfile</code>. May be omitted when supplied to | |
| the constructor.`,name:"image"},{anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.start_container.port",description:`<strong>port</strong> (<em>int</em>, <em>optional</em>) — | |
| Must be <code>None</code> or <code>8000</code>. Modal exposes port 8000 via an | |
| encrypted tunnel; other ports raise <code>ValueError</code>.`,name:"port"},{anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.start_container.env_vars",description:`<strong>env_vars</strong> (<em>dict</em>, <em>optional</em>) — | |
| Environment variables forwarded to the sandbox.`,name:"env_vars"},{anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.start_container.*kwargs",description:`*<strong>*kwargs</strong> — | |
| <code>cmd</code> (<em>str</em>) to override the server command; any remaining | |
| keyword arguments are forwarded to <code>modal.Sandbox.create</code>.`,name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>HTTPS tunnel URL for the sandbox (base_url).</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><em>str</em></p> | |
| `}),t(6),r(Do);var Bo=e(Do,2),wc=o(Bo);n(wc,{name:"stop_container",anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.stop_container",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/modal_provider.py#L573",parameters:[]}),t(2),r(Bo);var ea=e(Bo,2),xc=o(ea);n(xc,{name:"wait_for_ready",anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.wait_for_ready",source:"https://github.com/huggingface/openenv/blob/vr_1068/openenv/core/containers/runtime/modal_provider.py#L649",parameters:[{name:"base_url",val:": str"},{name:"timeout_s",val:": float = 120.0"}],parametersDescription:[{anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.wait_for_ready.base_url",description:`<strong>base_url</strong> (<em>str</em>) — | |
| Tunnel URL returned by <code>start_container()</code>.`,name:"base_url"},{anchor:"openenv.core.containers.runtime.modal_provider.ModalProvider.wait_for_ready.timeout_s",description:`<strong>timeout_s</strong> (<em>float</em>, <em>optional</em>, defaults to <em>120.0</em>) — | |
| Maximum seconds to wait.`,name:"timeout_s"}],raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>TimeoutError</code> — If the sandbox doesn’t become ready in time.</li> | |
| <li><code>RuntimeError</code> — If the server process died (detected via PID check).</li> | |
| </ul> | |
| `,raiseType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>TimeoutError</code> or <code>RuntimeError</code></p> | |
| `}),t(4),r(ea),r(Ro);var Tc=e(Ro,2);kc(Tc,{source:"https://github.com/huggingface/openenv/blob/main/docs/source/reference/core.md"}),t(2),d(na,Wo),Nc()}export{zc as component}; | |
Xet Storage Details
- Size:
- 245 kB
- Xet hash:
- b4b563d2c0528a7f33fc321efd44c679a9b4a1576a626e439a4ecc37bc0863fa
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.