API ReferenceΒΆ

This section provides a complete API reference for the HAP package.

haive.hap.modelsΒΆ

haive.hap.models.contextΒΆ

haive.hap.models.graphΒΆ

haive.hap.serverΒΆ

haive.hap.server.runtimeΒΆ

haive.hap.hapΒΆ

Note: HAP (Haive Agent Protocol) uses JSON-RPC 2.0 for agent communication.

haive.hap.hap.contextΒΆ

Type DefinitionsΒΆ

EnumsΒΆ

Type AliasesΒΆ

# Backward compatibility aliases
AgentGraph = HAPGraph  # Old name for HAPGraph
AgentNode = HAPNode    # Old name for HAPNode

ExceptionsΒΆ

UtilitiesΒΆ

Graph UtilitiesΒΆ

Context UtilitiesΒΆ

ConstantsΒΆ

haive.hap.VERSION = "1.0.0"ΒΆ

Current HAP version

haive.hap.PROTOCOL_VERSION = "2.0"ΒΆ

JSON-RPC protocol version for HAP

Complete ExampleΒΆ

Here’s a complete example using the full API:

import asyncio
from haive.hap.models import HAPGraph, HAPContext
from haive.hap.server.runtime import HAPRuntime
from haive.hap.hap import HAPContext, SimpleAuthProvider
from haive.agents.simple.agent import SimpleAgent
from haive.core.engine.aug_llm import AugLLMConfig

async def complete_example():
    # Create agents
    agent1 = SimpleAgent(
        name="processor",
        engine=AugLLMConfig(temperature=0.5)
    )

    agent2 = SimpleAgent(
        name="validator",
        engine=AugLLMConfig(temperature=0.3)
    )

    # Build graph
    graph = HAPGraph()
    graph.add_agent_node("process", agent1, ["validate"])
    graph.add_agent_node("validate", agent2)
    graph.entry_node = "process"

    # Create runtime
    runtime = HAPRuntime(graph)

    # Create HAP context for protocol layer
    hap_context = HAPContext(
        request_id="req-123",
        auth_provider=SimpleAuthProvider(
            user="alice",
            scopes=["execute"]
        )
    )

    # Execute with initial context
    initial_data = {
        "input": "Process this data",
        "hap_context": hap_context
    }

    # Run workflow
    result = await runtime.run(initial_data)

    # Access results
    print(f"Execution path: {result.execution_path}")
    print(f"Final output: {result.outputs}")
    print(f"Metadata: {result.agent_metadata}")

    return result

# Run the example
if __name__ == "__main__":
    asyncio.run(complete_example())