Skip to content

Haslab-dev/KendaliAI

Repository files navigation

KendaliAI

KendaliAI is a self-hosted AI automation platform that unified AI access, enables AI agents, provides workflow automation, controls messaging bots, and is highly extensible via plugins.

Architecture: Monolithic (single repository, unified config).

Project Plan & Checklist

  • Phase 1: Core Runtime

    • Core primitives (src/core)
    • Event Bus (src/eventbus)
    • Tool System (src/tools)
    • Intent Router (src/router)
    • Database Layer (src/database)
  • Phase 2: AI Gateway & Agents

    • AI Gateway (model routing, provider adapters, caching) (src/gateway)
    • Agent Runtime (planner, executor, memory) (src/agents)
  • Phase 3: Channel Routing

    • Prefix-based routing (src/server/routing)
    • Keyword-based routing
    • Interactive gateway selection
    • Channel-to-gateway binding (src/cli/routing)
  • Phase 4: Agent System

    • Agent personality configuration (src/server/agents/config.ts)
    • Agent templates (dev-assistant, support-bot, data-analyst, content-writer)
    • Per-gateway agent behavior
    • Custom instructions
  • Phase 5: Skills & Tools

    • Skills configuration per gateway (src/server/skills)
    • Tools configuration per gateway
    • Security sandboxing
    • Permission system
  • Phase 6: Workflow Automation

    • Workflow engine (node engine, triggers, scheduler) (src/workflow)
  • Phase 7: Dashboard UI

    • System monitoring (src/dashboard/pages/Overview)
    • Workflow editor (src/dashboard/pages/Workflows)
  • Phase 8: Plugin SDK

    • Tool extensions, workflow nodes, UI widgets SDK (src/sdk)
  • Phase 9: Messaging Integration

    • Messaging adapters (Telegram, Discord, WhatsApp) (src/adapters)

Quickstart

Step-by-Step: Creating your first AI Telegram Bot

Follow these steps to create an isolated AI Gateway and connect it to Telegram:

1. Create the Gateway

This initializes a dedicated workspace in .kendaliai/my-assistant/.

bun src/cli.ts gateway create my-assistant --provider deepseek

2. Set API Credentials

Securely store your AI provider's API key.

bun src/cli.ts gateway set-api-key my-assistant "your-api-key"

3. Connect Telegram

Add your Telegram Bot Token to the gateway.

bun src/cli.ts channel add-telegram --gateway my-assistant --bot-token "your-bot-token"

4. Authorize Yourself

KendaliAI uses a "Deny-by-Default" security model. You must allowlist your Telegram ID.

bun src/cli.ts channel bind-telegram <your-telegram-id> --gateway my-assistant

5. Bind Routing

Bind the channel to the gateway so it knows which agent should handle the messages.

# Get your channel ID from 'bun src/cli.ts channel list'
bun src/cli.ts routing bind <channel-id> my-assistant

6. Launch!

Start the gateway as a background daemon.

bun src/cli.ts gateway start my-assistant --daemon

Gateway Workspace Structure

Each gateway lives in its own isolated directory inside .kendaliai/:

  • .kendaliai/<name>/data/kendaliai.db: Gateway-specific message history and settings.
  • .kendaliai/<name>/logs/gateway.log: Dedicated execution logs.
  • .kendaliai/<name>/identity.md: Define who your agent is (Name, Vibe, Emoji).
  • .kendaliai/<name>/soul.md: The "brain" and deep instructions for the agent.
  • .kendaliai/<name>/run/: Process ID (PID) management.

Channel Routing

Route messages from the same channel to different gateways based on prefixes, keywords, or interactive selection.

# List all channel bindings
bun run src/cli.ts routing list

# Bind a channel to a gateway with prefix routing
bun run src/cli.ts routing bind <channel-id> dev-assistant --mode prefix --prefix /dev

# Bind with keyword routing
bun run src/cli.ts routing bind <channel-id> support-bot --mode keyword --keywords "help,support,issue"

# Set routing mode for a gateway
bun run src/cli.ts routing set-mode dev-assistant prefix
bun run src/cli.ts routing set-prefix dev-assistant /dev
bun run src/cli.ts routing set-keywords support-bot "help,support,ticket"

Routing Modes

| Mode | Description | Example | |\------|-------------|---------| | prefix | Route by command prefix | /dev review this code → dev-assistant | | keyword | Auto-route by detected keywords | "help with bug" → support-bot | | interactive | Ask user to select gateway | Shows menu of available gateways | | broadcast | Send to all bound gateways | Announcements | | round-robin | Distribute across gateways | Load balancing |

Agent System

Configure agents with unique personalities and behaviors for each gateway.

# List available agent templates
bun run src/cli.ts agent templates

# Configure agent for a gateway
bun run src/cli.ts agent configure dev-assistant --template dev-assistant

# Set custom instructions
bun run src/cli.ts agent instructions dev-assistant "Always include code examples"

Available Agent Templates

Template Description
dev-assistant Senior developer for code review and development
support-bot Friendly customer support representative
data-analyst Analytical data expert for analysis and visualization
content-writer Creative writer for content creation
general-assistant Versatile AI assistant for general tasks

Skills & Tools

Enable or disable skills and tools per gateway with security controls.

# List available skills
bun run src/cli.ts skills list

# Enable a skill for a gateway
bun run src/cli.ts skills enable dev-assistant code-analysis

# List available tools
bun run src/cli.ts tools list

# Enable a tool for a gateway
bun run src/cli.ts tools enable dev-assistant shell

# Configure security policy
bun run src/cli.ts security show dev-assistant
bun run src/cli.ts security update dev-assistant workspaceOnly false

Skill Registry

Install skills from external sources similar to ZeroClaw's skill system.

# Install skill from ZeroMarket registry
bun run src/cli.ts skills install namespace/code-review

# Install skill from ClawHub
bun run src/cli.ts skills install clawhub:summarize

# Install skill from Git remote
bun run src/cli.ts skills install https://github.com/user/kendaliai-skill

# Install skill from local zip file
bun run src/cli.ts skills install ~/Downloads/my-skill.zip

# Install skill from direct zip URL
bun run src/cli.ts skills install zip:https://example.com/skills/my-skill.zip

# List installed skills
bun run src/cli.ts skills installed

# Audit a skill for security issues
bun run src/cli.ts skills audit code-review

# Uninstall a skill
bun run src/cli.ts skills uninstall code-review

# Create a new skill scaffold
bun run src/cli.ts skills new my-custom-skill

Skill Sources

Source Format Description Example
namespace/name ZeroMarket registry zeroclaw/code-review
clawhub:name ClawHub registry clawhub:summarize
https://... Git remote repository https://github.com/user/skill
~/path/to/file.zip Local zip file ~/Downloads/skill.zip
zip:https://... Direct zip URL zip:https://example.com/skill.zip

Skill Manifest (SKILL.toml)

Skills are defined using a TOML manifest file:

[skill]
name = "code-review"
version = "1.0.0"
description = "AI-powered code review assistant"
author = "zeroclaw"
license = "MIT"
entry = "src/index.ts"

[permissions]
fs = { access = "read", paths = ["./src", "./tests"] }
net = { hosts = ["api.github.com"] }
exec = { commands = ["git", "npm"] }

[config]
model = { type = "string", default = "gpt-4", description = "AI model to use" }

Built-in Skills

Skill Description
code-analysis Analyze and review code
git-operations Git repository operations
web-search Search the web for information
data-processing Process and analyze data
debugging Help debug code and troubleshoot
faq-lookup Look up answers from FAQ database

Built-in Tools

Tool Risk Level Description
shell High Execute shell commands
git Medium Git operations
file Medium File read/write operations
http Low HTTP requests
memory Low Memory storage and retrieval
browser Medium Browser automation (disabled by default)
python High Python code execution (disabled by default)

Telegram Bot Commands

  • /init - Pair your Telegram account with KendaliAI
  • /status - Show current gateway status
  • /gateways - List available gateways
  • /<prefix> <message> - Route message to specific gateway

Frontend Dashboard

bun install
bun run dev

The frontend application runs on top of Vite and React. The backend API is entirely unified under src/server (or run concurrently) to avoid monorepo setups.

Backend Server

bun run src/server/index.ts

Build Binary

To create a standalone executable for the CLI:

# General build for the current platform
npm run build:binary

# Output is in dist/kendaliai
./dist/kendaliai --version

Compressed Distribution (Gzip)

To create a compressed version of the binary (safe for all platforms):

# Compresses the binary for your current platform
npm run build:binary:gz

# Build and compress for all platforms
npm run build:binary:all:gz

The resulting .gz files (e.g., dist/kendaliai.gz) are significantly smaller (~15MB). Users can extract them with gunzip on Linux/macOS or any archive tool on Windows.

Tip

Why Gzip? While executable compression (like UPX) saves space, it can trigger OS security blocks on macOS. Gzip provides equivalent space savings while ensuring the binary remains 100% stable after extraction.

Command Output
npm run build:binary dist/kendaliai
Script Description
bun start Start the interactive TUI
bun run gateway Gateway management commands
bun run dev Start frontend + backend concurrently
bun test Run unit tests
  • Workspace Isolation: Each gateway has its own SQLite database and markdown-based identity files.
  • Credential Encryption: API keys and bot tokens are encrypted using AES-256-GCM before storage.
  • Deny-by-Default: Channels will reject any user not explicitly added via bind-telegram.
  • System Level: The main system database at .kendaliai/kendaliai.db manages global gateway states.

Testing

Unit tests run natively via bun test. Test files are stored under the tests/ directory.

bun test

Architecture

src/
├── cli/                    # CLI modules
│   ├── gateway.ts          # Gateway management commands
│   ├── daemon.ts           # Daemon process management
│   ├── routing.ts          # Channel routing commands
│   ├── skills-config.ts    # Skills & tools commands
│   └── skills.ts           # Legacy skills management
├── server/
│   ├── ai/                 # AI SDK integration
│   │   └── index.ts        # OpenAI-compatible provider
│   ├── agents/             # Agent system
│   │   └── config.ts       # Agent configuration & templates
│   ├── routing/            # Channel routing
│   │   └── index.ts        # Routing manager & types
│   ├── skills/             # Skills & Tools system
│   │   └── index.ts        # Skills manager & security
│   ├── gateway/            # AI Gateway
│   ├── database/           # Database layer
│   ├── security/           # Security & encryption
│   └── config/             # Configuration
└── dashboard/              # React dashboard

About

Self-hosted AI automation platform with unified LLM gateway, agents, workflows, and messaging bots. OpenClaw alternative.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors