hud.adapters
API reference for Adapters and Common Language Actions (CLA)
The hud.adapters
modules provide the base Adapter
class, specific adapter implementations (ClaudeAdapter
, OperatorAdapter
), and the definitions for the Common Language Actions (CLA
) used by environments.
See the Adapter Concepts page for explanations and usage examples.
Base Class (hud.adapters.common.adapter
)
Adapter
Base class for translating between agent-specific formats and the environment’s standard CLA
format. Handles observation rescaling and action coordinate rescaling.
Key Attributes:
agent_width
/agent_height
(int): The dimensions the agent’s model expects observations in. Used byrescale
. Subclasses (likeClaudeAdapter
,OperatorAdapter
) often set defaults (e.g., 1024x768).env_width
/env_height
(int): The actual dimensions of the environment image received. Updated automatically byrescale
. Used bypostprocess_action
for scaling action coordinates.
Key Methods:
rescale(self, observation)
: Takes an image observation (numpy, PIL, base64 str) and returns a base64 PNG string resized toagent_width
xagent_height
. Called byAgent.preprocess
.convert(self, action)
: (Intended for subclass implementation) Converts a single raw action from the specific agent model’s format into the standardCLA
format.adapt(self, action)
: Orchestrates the full adaptation of a single raw action: preprocess -> convert -> rescale coordinates -> validate CLA.adapt_list(self, actions)
: Appliesadapt
to a list of raw actions. Called byAgent.postprocess
.postprocess_action(self, action_dict)
: Internal helper called byadapt
to rescale coordinates in an action dictionary based onagent_width
/height
vsenv_width
/height
.
Built-in Adapters
ClaudeAdapter (hud.adapters.claude.ClaudeAdapter
)
Adapter for Anthropic Claude’s Computer Use API action format. Inherits from Adapter
. Used by default in ClaudeAgent
.
OperatorAdapter (hud.adapters.operator.OperatorAdapter
)
Adapter for OpenAI’s Computer Use Preview API action format. Inherits from Adapter
. Used by default in OperatorAgent
.
Common Language Actions (CLA) (hud.adapters.common.types
)
The CLA
type alias represents the standardized action format expected by env.step()
. It’s a union of specific Pydantic models.
Refer to the source code (hud/adapters/common/types.py
) for the complete definitions of all action types and CLAKey
literals.