展示 HN:Klaw.sh – AI 代理的 Kubernetes
Show HN: Klaw.sh – Kubernetes for AI agents

原始链接: https://github.com/klawsh/klaw.sh

## klaw:Kubernetes 适用于 AI 代理 - 摘要 klaw 是一个开源平台,旨在部署、编排和扩展 AI 代理,其功能类似于 Kubernetes 对容器的管理。它允许用户管理能够进行编码、研究、通信和自动化的智能代理,只需一个二进制文件且无依赖项,可在笔记本电脑到企业集群上运行。 主要特性包括通过统一 API 支持多个 LLM 提供商(each::labs、OpenRouter、Anthropic),Kubernetes 风格的多租户(通过命名空间),以及强大的内置代理功能,如工具使用(bash、网络访问、文件操作)。代理可以通过 CLI、Slack 集成或容器化进行部署,并使用 cron 作业进行调度。 klaw 采用分布式架构,具有控制器和工作节点以实现可扩展性,并支持熟悉的 Kubernetes 风格命令进行管理。它使用 Go 编写,并利用 Podman 作为容器运行时。对于个人/内部使用是免费的,SaaS 和 OEM 应用需要授权。

## Klaw.sh:用于AI代理的Kubernetes Klaw.sh是一个新的开源项目,旨在管理和编排AI代理集群,解决扩展到少数几个代理之外时出现的操作挑战。Klaw由一家生成式AI基础设施公司的创始人创建,它借鉴了Kubernetes的概念——如集群、命名空间和通道——以提供隔离、监控和简化的部署。 本质上,Klaw管理的是*管理*代理,而不是定义它们如何协作(例如CrewAI等框架)。它允许团队级别的隔离,通过简单的CLI(类似于`kubectl`)轻松扩展,并通过Go重写显著减小代理尺寸。 创建者强调了从构建代理到*运营*它们在规模上的转变,Klaw旨在解决诸如识别失败的代理和快速添加新环境等问题。它被设计为位于现有代理框架*之上*的一层,允许它们在Klaw管理的環境中运行。
相关文章

原文

klaw

The Kubernetes for AI Agents

Deploy, orchestrate, and scale AI agents across your infrastructure.
One binary. No dependencies. From laptop to enterprise cluster.

WebsiteQuick StartDeployment ModesFeaturesArchitecture

License Go Version Stars


klaw is an open-source platform for deploying and managing AI agents at scale. Think of it as Kubernetes, but instead of containers, you're orchestrating intelligent agents that can code, research, communicate, and automate tasks.

# Interactive chat
klaw chat

# Start full platform (Slack bot + scheduler + agents)
klaw start

# One-line install
curl -fsSL https://klaw.sh/install.sh | sh

# Or build from source
git clone https://github.com/klawsh/klaw.sh.git
cd klaw && make build
sudo mv bin/klaw /usr/local/bin/
# Option 1: each::labs Router (300+ models, single API key)
export EACHLABS_API_KEY=your-key

# Option 2: OpenRouter (multi-provider gateway)
export OPENROUTER_API_KEY=your-key

# Option 3: Direct Anthropic
export ANTHROPIC_API_KEY=sk-ant-...
# Interactive CLI chat
klaw chat

# Or start full platform with Slack integration
export SLACK_BOT_TOKEN=xoxb-...
export SLACK_APP_TOKEN=xapp-...
klaw start

klaw supports multiple deployment modes to fit your needs:

Run everything on a single machine—perfect for development and small teams:

# Interactive chat
klaw chat

# Full platform (Slack + scheduler)
klaw start

# Run agent in container
klaw run coder --task "Fix the bug"

Scale across multiple machines with controller-node architecture:

# Start the controller (central brain)
klaw controller start --port 9090

# Join worker nodes
klaw node join controller:9090 --token <token>

# Dispatch tasks across the cluster
klaw dispatch "analyze this codebase" --agent researcher

Run agents in isolated containers for security and reproducibility:

# Build the container image
klaw build

# Run agent in container
klaw run coder --task "Review this PR"
klaw run coder --detach  # Background

# Manage containers
klaw ps                  # List running
klaw logs coder          # View logs
klaw stop coder          # Stop container

300+ Models via LLM Router

Use any LLM through a single API with automatic provider selection:

klaw chat --model claude-sonnet-4-20250514
klaw chat --model gpt-4o
klaw chat --model gemini-pro

Supported Providers:

  • each::labs Router - 300+ models through single API
  • OpenRouter - Multi-provider gateway
  • Anthropic - Direct Claude access

Organize agents with Kubernetes-style multi-tenancy:

# Create cluster
klaw create cluster production

# Create namespaces
klaw create namespace engineering --cluster production
klaw create namespace marketing --cluster production

# Switch context
klaw context use production/engineering

# Agents are scoped to namespaces
klaw create agent coder --namespace engineering

Agents come with powerful capabilities out of the box:

Tool Description
bash Execute shell commands with 2-minute timeout
read Read file contents
write Create and write files
edit Edit files with precise string replacement
glob Find files by pattern
grep Search file contents with regex
web_fetch Fetch and process web content
web_search Search the internet
agent_spawn Create specialized sub-agents
skill Install and manage agent skills
cron Schedule recurring tasks

Composable capability bundles for agents:

klaw skill list
klaw skill install browser
klaw create agent researcher --skills web-search,browser,code-exec

Automate recurring tasks:

# Create a cron job
klaw cron create daily-report \
  --schedule "0 9 * * *" \
  --agent reporter \
  --task "Generate daily status report"

# List jobs
klaw cron list

# Manage jobs
klaw cron enable daily-report
klaw cron disable daily-report

Deploy agents to multiple surfaces:

klaw chat              # Interactive CLI
klaw chat --tui        # Rich TUI mode
klaw start             # Slack bot + scheduler

┌─────────────────────────────────────────────────┐
│              CHANNELS                            │
│     (Slack, CLI, TUI, API, Telegram)            │
└──────────────────┬──────────────────────────────┘
                   │
         ┌─────────▼──────────┐
         │   ORCHESTRATOR     │
         │  (Message Routing) │
         └─────────┬──────────┘
                   │
         ┌─────────▼──────────┐
         │      AGENT         │
         │ (LLM + Tool Loop)  │
         └─────────┬──────────┘
                   │
    ┌──────┬───────┼───────┬──────┐
    │      │       │       │      │
    ▼      ▼       ▼       ▼      ▼
  BASH   READ   WRITE   GREP   WEB
┌─────────────────────────────────────┐
│           CONTROLLER                │
│  ┌─────────────────────────────┐   │
│  │    Agent Registry           │   │
│  │    Task Dispatcher          │   │
│  │    State Manager            │   │
│  └─────────────────────────────┘   │
│              │                     │
│              │ TCP/JSON            │
│              ▼                     │
└──────────────┬──────────────────────┘
               │
┌──────────────┼────────────────────────┐
│              │                        │
▼              ▼                        ▼
┌─────────────┐  ┌─────────────┐  ┌─────────────┐
│   NODE 1    │  │   NODE 2    │  │   NODE 3    │
│ ┌─────────┐ │  │ ┌─────────┐ │  │ ┌─────────┐ │
│ │ Agent A │ │  │ │ Agent C │ │  │ │ Agent E │ │
│ └─────────┘ │  │ └─────────┘ │  │ └─────────┘ │
└─────────────┘  └─────────────┘  └─────────────┘

Why "Kubernetes for AI Agents"?

Just as Kubernetes revolutionized container orchestration, klaw brings the same paradigm to AI agents:

┌─────────────────────────────────────────────────────────────────────────┐
│                    KUBERNETES vs KLAW                                    │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│   KUBERNETES (Containers)          KLAW (AI Agents)                     │
│   ════════════════════════         ═══════════════════                  │
│                                                                          │
│   Container Image    ────────►     Agent Definition                     │
│   Pod                ────────►     Agent Instance                       │
│   Deployment         ────────►     AgentBinding                         │
│   Service            ────────►     Channel (Slack, CLI, API)            │
│   Node               ────────►     Node (Worker Machine)                │
│   Namespace          ────────►     Namespace (Isolation)                │
│   ConfigMap          ────────►     SOUL.md / Config                     │
│   kubectl            ────────►     klaw CLI                             │
│   Scheduler          ────────►     Task Dispatcher                      │
│   CronJob            ────────►     klaw cron                            │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

The Problem klaw Solves:

Challenge Kubernetes Solution klaw Solution
"Where does my workload run?" Schedules pods to nodes Schedules agents to nodes
"How do I scale?" HPA/VPA for containers Spawn agents on demand
"How do I isolate?" Namespaces Namespaces + workspaces
"How do I update?" Rolling deployments Hot-reload agent configs
"How do I communicate?" Services + Ingress Channels (Slack, API)
"How do I schedule?" CronJobs klaw cron

Familiar Patterns:

# Kubernetes                      # klaw
kubectl get pods                  klaw get agents
kubectl create deployment         klaw create agent
kubectl logs pod-name             klaw logs agent-name
kubectl exec -it pod -- bash      klaw attach agent-name
kubectl apply -f manifest.yaml    klaw apply -f agent.toml
kubectl config use-context        klaw context use

klaw chat                     # Interactive terminal chat
klaw chat --tui               # TUI mode with Bubble Tea
klaw start                    # Start platform (Slack + scheduler)
klaw create agent <name> --model <model> --skills <skills>
klaw get agents
klaw describe agent <name>
klaw delete agent <name>
klaw build                    # Build container image
klaw run <agent> --task "..." # Run in container
klaw run <agent> --detach     # Run in background
klaw ps                       # List containers
klaw logs <container>         # View logs
klaw stop <container>         # Stop container
klaw attach <container>       # Attach to container
klaw controller start         # Start controller
klaw node join <addr>         # Join a controller
klaw dispatch "task"          # Dispatch task
klaw get nodes                # List nodes
klaw get tasks                # List tasks
klaw create cluster <name>
klaw create namespace <name> --cluster <cluster>
klaw get clusters
klaw get namespaces
klaw context use <cluster>/<namespace>
klaw skill list
klaw skill install <name>
klaw skill uninstall <name>
klaw skill show <name>
klaw cron create <name> --schedule "..." --agent <agent> --task "..."
klaw cron list
klaw cron enable <name>
klaw cron disable <name>
klaw cron delete <name>

~/.klaw/config.toml:

[defaults]
model = "claude-sonnet-4-20250514"
agent = "default"

[workspace]
path = "~/.klaw/workspace"

[provider.eachlabs]
api_key = "${EACHLABS_API_KEY}"

[provider.anthropic]
api_key = "${ANTHROPIC_API_KEY}"
model = "claude-sonnet-4-20250514"

[provider.openrouter]
api_key = "${OPENROUTER_API_KEY}"

[channel.slack]
enabled = true
bot_token = "${SLACK_BOT_TOKEN}"
app_token = "${SLACK_APP_TOKEN}"

[server]
port = 8080
host = "127.0.0.1"

[logging]
level = "info"
~/.klaw/
├── config.toml          # Main configuration
├── workspace/           # Agent workspace files
│   ├── SOUL.md
│   ├── AGENTS.md
│   └── TOOLS.md
├── agents/              # Agent definitions (TOML)
├── skills/              # Installed skills
├── sessions/            # Session history
└── logs/                # Log files
# Provider API Keys
ANTHROPIC_API_KEY       # Anthropic Claude
OPENROUTER_API_KEY      # OpenRouter gateway
EACHLABS_API_KEY        # each::labs router

# Channel Tokens
SLACK_BOT_TOKEN         # Slack bot
SLACK_APP_TOKEN         # Slack app

# Overrides
KLAW_MODEL              # Default model
KLAW_STATE_DIR          # State directory

Feature klaw Claude Code LangChain AutoGPT
Open Source Yes No Yes Yes
Single Binary Yes No No No
No Dependencies Yes No No No
Distributed Yes No No No
Container Support Yes (Podman) No No No
Multi-Agent Yes No Yes Yes
Namespaces Yes No No No
Slack/Teams Yes No Manual No
300+ Models Yes No Yes No
Cron Jobs Yes No No No
Production Ready Yes Yes Partial No

git clone https://github.com/klawsh/klaw.sh.git
cd klaw

make build          # Build binary
make test           # Run tests
make fmt            # Format code
make lint           # Lint code
make cross          # Cross-compile (Darwin, Linux, Windows)
  • Language: Go 1.24+ (no runtime dependencies)
  • CLI Framework: Cobra
  • TUI: Bubble Tea, Lipgloss, Bubbles
  • LLM SDKs: anthropic-sdk-go, openai-go
  • Config: TOML
  • Containers: Podman
  • IPC: gRPC, JSON over TCP
klaw/
├── cmd/klaw/
│   ├── main.go              # Entry point
│   └── commands/            # CLI commands
├── internal/
│   ├── agent/               # Agent logic and definitions
│   ├── channel/             # Channel implementations
│   ├── config/              # Configuration management
│   ├── cluster/             # Namespaces and clusters
│   ├── controller/          # Distributed controller
│   ├── memory/              # Workspace memory system
│   ├── node/                # Worker node
│   ├── orchestrator/        # Message routing
│   ├── provider/            # LLM providers
│   ├── runtime/             # Podman runtime
│   ├── scheduler/           # Cron scheduling
│   ├── skill/               # Skills system
│   ├── tool/                # Tool implementations
│   └── tui/                 # Bubble Tea TUI
└── proto/                   # gRPC definitions

We welcome contributions! See CONTRIBUTING.md for guidelines.

git clone https://github.com/klawsh/klaw.sh.git
cd klaw
make build
make test
./bin/klaw chat


klaw is source-available under the each::labs License.

Free to use for:

  • Internal business purposes
  • Personal projects
  • Building your own AI applications
  • Consulting and professional services

Requires license for:

  • Multi-tenant SaaS offerings
  • White-label/OEM distribution

See LICENSE for details. For enterprise licensing: [email protected]


klaw - The Kubernetes for AI Agents
Built by each::labs

联系我们 contact @ memedata.com