npm package: @hivemynd/node
Description: HiveMind Node - Local AI gateway with multi-provider auth
Latest version: 0.1.0

# HiveMind Node

Local AI gateway with multi-provider authentication.

## Installation

```bash
npm install -g @hivemind/node
```

Or link locally during development:
```bash
cd packages/hivemind-node
npm link
```

## Quick Start

```bash
# Interactive setup (recommended)
hivemind setup
```

This walks you through:
1. **Select providers** — Anthropic, OpenAI, DeepSeek, Google, Ollama
2. **Authenticate** — API key or browser session
3. **See models** — Shows available models per provider
4. **Set default** — Pick your primary provider
5. **Connect** — Optionally link to HiveMind server

## Commands

```bash
# Setup & Status
hivemind setup              # Interactive setup wizard
hivemind status             # Show configured providers

# Models
hivemind models             # List available models
hivemind models -p anthropic  # Filter by provider

# Chat
hivemind chat "Hello"       # Quick chat with default provider
hivemind chat -p openai "Hi"  # Use specific provider
hivemind chat -m gpt-4o "Hi"  # Use specific model

# Provider Management
hivemind auth add <provider>    # Add a provider
hivemind auth list              # List providers
hivemind auth remove <provider> # Remove a provider
hivemind default <provider>     # Set default provider

# HiveMind Connection
hivemind connect <url>      # Connect to HiveMind server
```

## Authentication Methods

### API Key
Direct API access. Pay per token.

```bash
hivemind auth add anthropic
# Then enter your API key when prompted
```

Or with the key directly:
```bash
hivemind auth add anthropic -k sk-ant-xxx
```

### Browser Session (Subscription)
Use your existing Claude Max ($20/mo) or ChatGPT Plus subscription.

During `hivemind setup`, choose "Browser Session" and paste your session cookie from DevTools:
1. Go to claude.ai (logged in)
2. DevTools → Application → Cookies
3. Copy `sessionKey` value

### Environment Variables
The CLI auto-detects these:
```bash
export ANTHROPIC_API_KEY=sk-ant-xxx
export OPENAI_API_KEY=sk-xxx
export DEEPSEEK_API_KEY=sk-xxx
```

## Supported Providers

| Provider | Models | Auth Methods |
|----------|--------|--------------|
| **Anthropic** | claude-opus-4, claude-sonnet-4, claude-3.5-* | API Key, Session |
| **OpenAI** | gpt-4o, gpt-4-turbo, o1-* | API Key, Session |
| **DeepSeek** | deepseek-chat, deepseek-coder | API Key |
| **Google** | gemini-2.0-flash, gemini-1.5-pro | API Key |
| **Ollama** | llama3, mistral, codellama | Local (no auth) |

## How It Works

1. **Encrypted Storage** — Credentials in `~/.hivemind/auth.enc` (AES-256-GCM)
2. **Auto-Detection** — Checks env vars and existing sessions
3. **Health Checks** — Validates credentials before use
4. **HiveMind Integration** — Reports capabilities for routing

## HiveMind Connection

When connected to a HiveMind server, your node becomes an execution endpoint:

```bash
hivemind connect https://your-hivemind.vercel.app
```

The server can route LLM requests to your node based on:
- Which providers you have configured
- Which models you have access to
- Your node's availability

**Credentials stay local** — only capability info is shared with the server.

## Development

```bash
cd packages/hivemind-node
npm install
npm run build
npm link

# Test
hivemind status
```

## License

MIT