hap.types.protocolΒΆ
Core types for the Haive Agent Protocol (HAP).
This module defines the fundamental types used throughout HAP, mirroring the structure of MCP but adapted for agents and graphs.
Enhanced with comprehensive Pydantic validation for: - Field-level validation with constraints - Cross-field validation - JSON-RPC 2.0 compliance - HAP protocol standards
ClassesΒΆ
Request to execute an agent with validation. |
|
Result from agent execution with validation. |
|
Agent metadata for HAP with enhanced validation. |
|
Base class for all HAP info types. |
|
Graph edge metadata with validation. |
|
Standard error codes. |
|
Agent execution status values. |
|
Field metadata. |
|
Request to execute a graph with validation. |
|
Result from graph execution with validation. |
|
Graph execution status values. |
|
Graph metadata for HAP with validation. |
|
Error structure for HAP protocol with enhanced validation. |
|
Base request structure for HAP protocol with JSON-RPC 2.0 compliance. |
|
Base response structure for HAP protocol with validation. |
|
Interface for HAP servers. |
|
Transport layer interface. |
|
Graph node metadata with validation. |
|
Graph node types. |
|
Prompt argument definition with validation. |
|
Request to get a prompt. |
|
Prompt metadata with enhanced validation. |
|
Resource metadata with validation. |
|
Request to read a resource. |
|
Server capabilities. |
|
Registration info for a HAP server. |
|
State schema metadata. |
|
Request to validate state. |
|
Result of state validation. |
|
Request to call a tool. |
|
Tool metadata with enhanced validation. |
|
Transport configuration. |
|
Available transport types. |
Module ContentsΒΆ
- class hap.types.protocol.AgentExecutionRequest(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelRequest to execute an agent with validation.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.AgentExecutionResult(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelResult from agent execution with validation.
- Parameters:
data (Any)
- validate_result_consistency() AgentExecutionResultΒΆ
Ensure result/error fields are consistent with status.
- Return type:
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- status: ExecutionStatus = NoneΒΆ
- class hap.types.protocol.AgentInfo(/, **data: Any)ΒΆ
Bases:
BaseInfoAgent metadata for HAP with enhanced validation.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.BaseInfo(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelBase class for all HAP info types.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.EdgeInfo(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelGraph edge metadata with validation.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.ErrorCodeΒΆ
-
Standard error codes.
- AGENT_NOT_FOUND = -32001ΒΆ
- AUTHENTICATION_ERROR = -32007ΒΆ
- EXECUTION_ERROR = -32005ΒΆ
- GRAPH_NOT_FOUND = -32002ΒΆ
- INTERNAL_ERROR = -32603ΒΆ
- INVALID_PARAMS = -32602ΒΆ
- INVALID_REQUEST = -32600ΒΆ
- METHOD_NOT_FOUND = -32601ΒΆ
- PARSE_ERROR = -32700ΒΆ
- RESOURCE_NOT_FOUND = -32004ΒΆ
- TOOL_NOT_FOUND = -32003ΒΆ
- VALIDATION_ERROR = -32006ΒΆ
- class hap.types.protocol.ExecutionStatusΒΆ
-
Agent execution status values.
- CANCELLED = 'cancelled'ΒΆ
- ERROR = 'error'ΒΆ
- SUCCESS = 'success'ΒΆ
- TIMEOUT = 'timeout'ΒΆ
- class hap.types.protocol.FieldInfo(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelField metadata.
- Parameters:
data (Any)
- class hap.types.protocol.GraphExecutionRequest(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelRequest to execute a graph with validation.
- Parameters:
data (Any)
- classmethod validate_input_not_empty(v: Dict[str, Any]) Dict[str, Any]ΒΆ
Ensure input data is not empty.
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.GraphExecutionResult(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelResult from graph execution with validation.
- Parameters:
data (Any)
- classmethod validate_path_items(v: List[str]) List[str]ΒΆ
Validate all path items are valid node IDs.
- validate_result_consistency() GraphExecutionResultΒΆ
Ensure result fields are consistent with status.
- Return type:
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- status: GraphExecutionStatus = NoneΒΆ
- class hap.types.protocol.GraphExecutionStatusΒΆ
-
Graph execution status values.
- CANCELLED = 'cancelled'ΒΆ
- ERROR = 'error'ΒΆ
- PARTIAL = 'partial'ΒΆ
- SUCCESS = 'success'ΒΆ
- TIMEOUT = 'timeout'ΒΆ
- class hap.types.protocol.GraphInfo(/, **data: Any)ΒΆ
Bases:
BaseInfoGraph metadata for HAP with validation.
- Parameters:
data (Any)
- classmethod validate_unique_node_ids(v: List[NodeInfo]) List[NodeInfo]ΒΆ
Ensure node IDs are unique.
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.HAPError(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelError structure for HAP protocol with enhanced validation.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.HAPRequest(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelBase request structure for HAP protocol with JSON-RPC 2.0 compliance.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.HAPResponse(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelBase response structure for HAP protocol with validation.
- Parameters:
data (Any)
- validate_result_or_error() HAPResponseΒΆ
Ensure response has either result or error, not both.
- Return type:
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.IHAPServerΒΆ
Bases:
ProtocolInterface for HAP servers.
- async handle_request(request: HAPRequest) HAPResponseΒΆ
Handle incoming HAP request.
- Parameters:
request (HAPRequest)
- Return type:
- list_prompts() List[PromptInfo]ΒΆ
List available prompts.
- Return type:
List[PromptInfo]
- list_resources() List[ResourceInfo]ΒΆ
List available resources.
- Return type:
List[ResourceInfo]
- class hap.types.protocol.ITransportΒΆ
Bases:
ProtocolTransport layer interface.
- async send_response(response: HAPResponse)ΒΆ
Send response to client.
- Parameters:
response (HAPResponse)
- async start(server: IHAPServer)ΒΆ
Start transport.
- Parameters:
server (IHAPServer)
- async stop()ΒΆ
Stop transport.
- class hap.types.protocol.NodeInfo(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelGraph node metadata with validation.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.NodeTypeΒΆ
-
Graph node types.
- AGENT = 'agent'ΒΆ
- DECISION = 'decision'ΒΆ
- END = 'end'ΒΆ
- MERGE = 'merge'ΒΆ
- PARALLEL = 'parallel'ΒΆ
- START = 'start'ΒΆ
- TOOL = 'tool'ΒΆ
- class hap.types.protocol.PromptArgument(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelPrompt argument definition with validation.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.PromptGet(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelRequest to get a prompt.
- Parameters:
data (Any)
- class hap.types.protocol.PromptInfo(/, **data: Any)ΒΆ
Bases:
BaseInfoPrompt metadata with enhanced validation.
- Parameters:
data (Any)
- classmethod validate_unique_arguments(v: List[PromptArgument]) List[PromptArgument]ΒΆ
Ensure argument names are unique.
- Parameters:
v (List[PromptArgument])
- Return type:
List[PromptArgument]
- arguments: List[PromptArgument] = NoneΒΆ
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.ResourceInfo(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelResource metadata with validation.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.ResourceRead(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelRequest to read a resource.
- Parameters:
data (Any)
- class hap.types.protocol.ServerCapabilityΒΆ
-
Server capabilities.
- AUTHENTICATION = 'authentication'ΒΆ
- PROMPTS = 'prompts'ΒΆ
- RESOURCES = 'resources'ΒΆ
- STATE_PERSISTENCE = 'state_persistence'ΒΆ
- STREAMING = 'streaming'ΒΆ
- TOOLS = 'tools'ΒΆ
- class hap.types.protocol.ServerRegistration(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelRegistration info for a HAP server.
- Parameters:
data (Any)
- capabilities: List[ServerCapability] = NoneΒΆ
- registered_at: datetime.datetime = NoneΒΆ
- class hap.types.protocol.StateSchemaInfo(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelState schema metadata.
- Parameters:
data (Any)
- class hap.types.protocol.StateValidationRequest(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelRequest to validate state.
- Parameters:
data (Any)
- class hap.types.protocol.StateValidationResult(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelResult of state validation.
- Parameters:
data (Any)
- class hap.types.protocol.ToolCall(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelRequest to call a tool.
- Parameters:
data (Any)
- class hap.types.protocol.ToolInfo(/, **data: Any)ΒΆ
Bases:
BaseInfoTool metadata with enhanced validation.
- Parameters:
data (Any)
- classmethod validate_json_schema(v: Dict[str, Any] | None) Dict[str, Any] | NoneΒΆ
Validate that schema is a valid JSON Schema structure.
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hap.types.protocol.TransportConfig(/, **data: Any)ΒΆ
Bases:
pydantic.BaseModelTransport configuration.
- Parameters:
data (Any)
- type: TransportTypeΒΆ