New protocol version released: This page may contain outdated information.
The HAIP CLI can be installed and used in multiple ways. Choose the method that best fits your environment and requirements.

Prerequisites

Node.js

Version 20.0.0 or higher

npm

Version 9.0.0 or higher

Git

For cloning the repository
1

Clone the Repository

git clone https://github.com/haiprotocol/haip-cli.git cd haip-cli
2

Install Dependencies

bash npm install
3

Build the Project

bash npm run build
4

Verify Installation

bash node dist/index.js --help You should see the HAIP CLI banner and help information.

Optional: Install Globally

# Link globally (requires sudo on some systems)
npm link

# Test global installation
haip --help

Method 2: From NPM

Available Now: The HAIP CLI is available on npm as @haip/cli.
npm version npm downloads License: MIT
# Install globally from NPM
npm install -g @haip/cli

# Verify installation
haip --help

Method 3: Docker

Docker: Docker images will be available on Docker Hub as haip/cli in the future.

Pull the Image

docker pull haip/cli:latest

Run the Container

# Run with interactive terminal
docker run -it haip/cli:latest --help

# Run with volume mount for configuration
docker run -it -v $(pwd):/workspace haip/cli:latest health

Development Setup

Prerequisites for Development

  • Node.js 20.0.0 or higher
  • npm 9.0.0 or higher
  • TypeScript 5.0.0 or higher
  • Git for version control

Development Installation

# Clone the repository
git clone https://github.com/haiprotocol/haip-cli.git
cd haip-cli

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

# Run with coverage
npm run test:coverage

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

Development Mode

# Start in development mode (watch for changes)
npm run dev

# Link for global testing
npm link

Verification

After installation, verify that the CLI is working correctly:

1. Check Version

node dist/index.js version
Expected output:
HAIP CLI v1.0.0
Human-Agent Interaction Protocol Command Line Interface
https://github.com/haiprotocol/haip-cli

2. Check System Information

node dist/index.js info
Expected output:
HAIP CLI System Information
────────────────────────────────────────
Node.js: v20.11.0
Platform: darwin
Architecture: arm64
HAIP Version: 1.1.2
CLI Version: 1.0.0

3. Check Help System

node dist/index.js --help
You should see the ASCII art banner and complete command listing.

4. Test Commands

# Test health command
node dist/index.js health --help

# Test send command
node dist/index.js send --help

# Test monitor command
node dist/index.js monitor --help

Configuration

Environment Variables

The CLI can be configured using environment variables:
# Server configuration
export HAIP_DEFAULT_URL=ws://localhost:8080
export HAIP_DEFAULT_TRANSPORT=websocket
export HAIP_DEFAULT_TOKEN=your-jwt-token

# Connection settings
export HAIP_TIMEOUT=10000
export HAIP_RECONNECT_ATTEMPTS=3
export HAIP_RECONNECT_DELAY=1000

# Output settings
export HAIP_VERBOSE=false
export HAIP_COLOR=true

Configuration File (Future Enhancement)

Create a configuration file for persistent settings:
# Create config directory
mkdir -p ~/.haip

# Create configuration file
cat > ~/.haip/config.json << EOF
{
  "defaultUrl": "ws://localhost:8080",
  "defaultTransport": "websocket",
  "timeout": 10000,
  "reconnectAttempts": 3,
  "verbose": false,
  "color": true
}
EOF

Troubleshooting

Common Issues

Permission Denied

# If you get permission errors when linking globally
sudo npm link

# Or use npx to run without global installation
npx haip --help

Node Version Issues

# Check your Node.js version
node --version

# If version is too old, update Node.js
# Using nvm (Node Version Manager)
nvm install 16
nvm use 16

# Or download from https://nodejs.org/

Build Errors

# Clean and rebuild
npm run clean
npm install
npm run build

# Check TypeScript errors
npx tsc --noEmit

Test Failures

# Run tests with verbose output
npm test -- --verbose

# Run specific test suites
npm test -- --testNamePattern="utils"

Getting Help

If you encounter issues:
  1. Check the logs - Run with verbose output: node dist/index.js --verbose
  2. Check Node.js version - Ensure you’re using Node.js 16+
  3. Check dependencies - Run npm install to ensure all dependencies are installed
  4. Check TypeScript - Run npx tsc --noEmit to check for type errors
  5. Check tests - Run npm test to ensure everything is working

Next Steps