Overview

The HAIP TypeScript SDK provides a complete implementation of the Human-Agent Interaction Protocol, enabling developers to build real-time, multi-modal applications with AI agents. The SDK is production-ready with comprehensive test coverage and supports all major transport protocols.

Quick Start

npm install @haip/sdk
import { createHAIPClient } from "@haip/sdk";

async function main() {
  const client = createHAIPClient({
    url: "ws://localhost:8080",
  });

  client.authenticate(() => {
    // You should send a token here.
    return {
      token: "Bearer TOKEN",
    };
  });

  try {
    await client.connect();

    const transaction = await client.startTransaction("echo", {});

    transaction.on("message", (message: any) => {
      console.log("🤖 Agent:", message.payload);
    });

    console.log("✅ Sending to transaction:", "Hello! Can you echo this?");
    transaction.sendTextMessage("Hello! Can you echo this?");
  } catch (error) {
    console.error("Error:", error);
    await client.disconnect();
  }
}

main();

Architecture

The SDK is built with a modular architecture that separates concerns and provides flexibility:
1

Client Layer

High-level client interface that manages connection lifecycle, handshakes, and protocol state.
2

Transport Layer

Pluggable transport implementations for different communication protocols.
3

Protocol Layer

Core protocol implementation with message validation, flow control, and event handling.
4

Utility Layer

Helper functions for message creation, validation, and common operations.

Supported Environments

  • Node.js: Full support with WebSocket and HTTP Streaming transports
  • Browser: Full support with WebSocket, SSE, and HTTP Streaming transports
  • TypeScript: Complete type definitions and IntelliSense support
  • JavaScript: Full compatibility with ES6+ features

Transport Options

TransportNode.jsBrowserFeatures
WebSocketReal-time, bidirectional, binary support
SSEServer-sent events, HTTP POST for sending
HTTP StreamingFetch-based streaming, universal compatibility

Protocol Support

The SDK implements the complete HAIP v1.1.2 specification.

View the spec

OpenAPI Specification

Getting Started

Choose your next step: