Skip to content
/ hexos Public

Central orchestrator for multi-agent conversations with LLM providers, tool execution, and human-in-the-loop approvals.

License

Notifications You must be signed in to change notification settings

hexoshq/hexos

Repository files navigation

Hexos

A React library for building AI agent chat applications with streaming, multi-agent coordination, and human-in-the-loop tool approvals.

Features

  • Multi-LLM Support — Anthropic, OpenAI, and Ollama providers out of the box
  • Multi-Agent Swarm — Agents can hand off conversations to each other with automatic routing
  • Streaming SSE — Real-time token streaming via Server-Sent Events
  • Human-in-the-Loop — Tool approval system for sensitive operations
  • MCP Integration — Connect to Model Context Protocol servers (stdio and SSE transports)
  • Frontend Tools — Register browser-side tools that the LLM can invoke directly
  • Theming — Fully customizable chat UI with theme provider
  • Framework Handlers — Built-in support for Next.js App Router and Express

Packages

Package Description
@hexos/common Shared types, enums, and utilities
@hexos/react-core React hooks, Jotai atoms, and SSE transport
@hexos/react-ui Pre-built chat UI components
@hexos/runtime Server-side agent runtime with LLM providers

Quick Start

Install

# Install all packages
npm install @hexos/react-core @hexos/react-ui @hexos/runtime @hexos/common

Backend (Next.js App Router)

// app/api/agent/chat/route.ts
import { AgentRuntime, createAgentHandler } from '@hexos/runtime';
import { LLMProvider, AnthropicModel } from '@hexos/common';

const runtime = new AgentRuntime({
  agents: [
    {
      id: 'assistant',
      name: 'Assistant',
      description: 'A helpful assistant',
      model: {
        provider: LLMProvider.Anthropic,
        model: AnthropicModel.Claude4Sonnet,
      },
      systemPrompt: 'You are a helpful assistant.',
      tools: [],
    },
  ],
  defaultAgent: 'assistant',
});

export const POST = createAgentHandler(runtime);

Frontend (React)

import { AgentProvider } from '@hexos/react-core';
import { ChatWindow, AgentUIProvider } from '@hexos/react-ui';
import '@hexos/react-ui/styles.css';

function App() {
  return (
    <AgentProvider config={{ endpoint: '/api/agent/chat' }}>
      <AgentUIProvider>
        <ChatWindow config={{ endpoint: '/api/agent/chat' }} />
      </AgentUIProvider>
    </AgentProvider>
  );
}

Monorepo Structure

packages/
├── common/          # @hexos/common — Shared types and utilities
├── react-core/      # @hexos/react-core — React hooks and state management
├── react-ui/        # @hexos/react-ui — Chat UI components
└── runtime/         # @hexos/runtime — Server-side agent runtime

apps/
├── docs/            # Documentation site (Nextra)
├── example-nextjs/  # Next.js demo application
└── example-nestjs/  # NestJS backend with MCP server

Development

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Development mode
pnpm dev

# Run tests
pnpm test

# Lint
pnpm lint

Requirements

  • Node.js >= 20.0.0
  • pnpm 9.15.0

Environment Variables

Variable Description
ANTHROPIC_API_KEY Anthropic API key
OPENAI_API_KEY OpenAI API key
OLLAMA_HOST Ollama server URL (default: http://localhost:11434)

License

MIT

About

Central orchestrator for multi-agent conversations with LLM providers, tool execution, and human-in-the-loop approvals.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published