Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ npms:
repository: "https://github.com/onkernel"
bugs: https://github.com/onkernel/cli/issues
description: Kernel CLI
homepage: https://onkernel.com/docs
homepage: https://www.kernel.sh/docs
license: MIT
author: "Rafael Garcia <raf@onkernel.com>"
author: "Rafael Garcia <raf@kernel.sh>"
access: public
keywords:
- kernel
Expand Down Expand Up @@ -89,7 +89,7 @@ release:

## What to do next?

- Read the [documentation](https://onkernel.com/docs)
- Read the [documentation](https://www.kernel.sh/docs)
- Join our [Discord server](https://discord.gg/FBrveQRcud)
- Follow us on Twitter [here](https://twitter.com/rfgarcia) and [here](https://x.com/juecd__)

Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

The Kernel CLI is a fast, friendly command‑line interface for Kernel — the platform that provides sandboxed, ready‑to‑use Chrome browsers for browser automations and web agents.

Sign up at [onkernel.com](https://www.onkernel.com/) and read the [docs](https://onkernel.com/docs/introduction).
Sign up at [kernel.sh](https://www.kernel.sh/) and read the [docs](https://www.kernel.sh/docs/introduction).

## What's Kernel?

Expand Down Expand Up @@ -124,6 +124,7 @@ Create an API key from the [Kernel dashboard](https://dashboard.onkernel.com).
- `gemini-computer-use` - Implements a Gemini computer use agent (TypeScript only)
- `openagi-computer-use` - OpenAGI Lux computer-use models (Python only)
- `magnitude` - Magnitude framework sample (TypeScript only)
- `claude-agent-sdk` - Claude Agent SDK browser automation agent

### App Deployment

Expand Down Expand Up @@ -395,6 +396,9 @@ kernel create --name my-agent --language ts --template stagehand

# Create a Python Computer Use app
kernel create --name my-cu-app --language py --template anthropic-computer-use

# Create a Claude Agent SDK app (TypeScript or Python)
kernel create --name my-claude-agent --language ts --template claude-agent-sdk
```

### Deploy with environment variables
Expand Down Expand Up @@ -587,15 +591,15 @@ kernel proxies delete prx_123 --yes

For complete documentation, visit:

- [📖 Documentation](https://onkernel.com/docs)
- [🚀 Quickstart Guide](https://onkernel.com/docs/quickstart)
- [📋 CLI Reference](https://onkernel.com/docs/reference/cli)
- [📖 Documentation](https://www.kernel.sh/docs)
- [🚀 Quickstart Guide](https://www.kernel.sh/docs/quickstart)
- [📋 CLI Reference](https://www.kernel.sh/docs/reference/cli)

## Support

- [Discord Community](https://discord.gg/kernel)
- [GitHub Issues](https://github.com/onkernel/kernel/issues)
- [Documentation](https://onkernel.com/docs)
- [Documentation](https://www.kernel.sh/docs)

---

Expand Down
2 changes: 1 addition & 1 deletion cmd/mcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func runServer(cmd *cobra.Command, args []string) {

pterm.Println()
pterm.DefaultSection.Println("Documentation")
pterm.Println(" https://onkernel.com/docs/reference/mcp-server")
pterm.Println(" https://www.kernel.sh/docs/reference/mcp-server")

pterm.Println()
pterm.Info.Println("Use 'kernel mcp install --target <tool>' to configure your AI tool automatically.")
Expand Down
16 changes: 16 additions & 0 deletions pkg/create/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
TemplateBrowserUse = "browser-use"
TemplateStagehand = "stagehand"
TemplateOpenAGIComputerUse = "openagi-computer-use"
TemplateClaudeAgentSDK = "claude-agent-sdk"
)

type TemplateInfo struct {
Expand Down Expand Up @@ -78,6 +79,11 @@ var Templates = map[string]TemplateInfo{
Description: "Implements an OpenAGI computer use agent",
Languages: []string{LanguagePython},
},
TemplateClaudeAgentSDK: {
Name: "Claude Agent SDK",
Description: "Implements a Claude Agent SDK browser automation agent",
Languages: []string{LanguageTypeScript, LanguagePython},
},
}

// GetSupportedTemplatesForLanguage returns a list of all supported template names for a given language
Expand Down Expand Up @@ -189,6 +195,11 @@ var Commands = map[string]map[string]DeployConfig{
NeedsEnvFile: true,
InvokeCommand: "kernel invoke ts-gemini-cua gemini-cua-task",
},
TemplateClaudeAgentSDK: {
EntryPoint: "index.ts",
NeedsEnvFile: true,
InvokeCommand: `kernel invoke ts-claude-agent-sdk agent-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 3 stories"}'`,
},
},
LanguagePython: {
TemplateSampleApp: {
Expand Down Expand Up @@ -221,6 +232,11 @@ var Commands = map[string]map[string]DeployConfig{
NeedsEnvFile: true,
InvokeCommand: `kernel invoke python-openagi-cua openagi-default-task -p '{"instruction": "Navigate to https://agiopen.org and click the What is Computer Use? button", "record_replay": "True"}'`,
},
TemplateClaudeAgentSDK: {
EntryPoint: "main.py",
NeedsEnvFile: true,
InvokeCommand: `kernel invoke py-claude-agent-sdk agent-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 3 stories"}'`,
},
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/templates/python/anthropic-computer-use/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This is a simple Kernel application that implements a prompt loop using Anthropi

It generally follows the [Anthropic Reference Implementation](https://github.com/anthropics/anthropic-quickstarts/tree/main/computer-use-demo) but replaces `xodotool` and `gnome-screenshot` with Playwright.

See the [docs](https://onkernel.com/docs/quickstart) for information.
See the [docs](https://www.kernel.sh/docs/quickstart) for information.
2 changes: 1 addition & 1 deletion pkg/templates/python/browser-use/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

This is a simple Kernel application that implements the Browser Use SDK.

See the [docs](https://onkernel.com/docs/build/browser-frameworks) for information.
See the [docs](https://www.kernel.sh/docs/build/browser-frameworks) for information.
2 changes: 1 addition & 1 deletion pkg/templates/python/browser-use/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TaskInput(TypedDict):


# LLM API Keys are set in the environment during `kernel deploy <filename> -e OPENAI_API_KEY=XXX`
# See https://onkernel.com/docs/launch/deploy#environment-variables
# See https://www.kernel.sh/docs/launch/deploy#environment-variables
llm = ChatOpenAI(model="gpt-4.1")


Expand Down
4 changes: 1 addition & 3 deletions pkg/templates/python/captcha-solver/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ async def test_captcha_solver(ctx: kernel.KernelContext) -> None:
)
page = context.pages[0] if context.pages else await context.new_page()

# Access the live view. Retrieve this live_view_url from the Kernel logs in your CLI:
# kernel login # or: export KERNEL_API_KEY=<Your API key>
# kernel logs python-captcha-solver --follow
# Access the live view URL printed below in the logs (logs stream automatically with kernel invoke)
print(
"Kernel browser live view url: ", kernel_browser.browser_live_view_url
)
Expand Down
5 changes: 5 additions & 0 deletions pkg/templates/python/claude-agent-sdk/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Anthropic API Key - Get from https://console.anthropic.com/
ANTHROPIC_API_KEY=your_anthropic_api_key_here

# Kernel API Key - Get from https://dashboard.onkernel.com/api-keys
KERNEL_API_KEY=your_kernel_api_key_here
128 changes: 128 additions & 0 deletions pkg/templates/python/claude-agent-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Claude Agent SDK + Kernel Browser Automation

This template demonstrates how to use the [Claude Agent SDK](https://platform.claude.com/docs/en/agent-sdk/overview) with [Kernel's](https://www.kernel.sh) browser automation capabilities.

## Prerequisites

### Claude Code Installation

The Claude Agent SDK requires Claude Code to be installed. Follow the [official installation guide](https://platform.claude.com/docs/en/agent-sdk/overview#get-started):

```bash
# macOS/Linux/WSL
curl -fsSL https://claude.ai/install.sh | bash
```

> **Note:** When deploying to Kernel, the app automatically installs Claude Code on the remote infrastructure.

### API Keys

You'll need:
- **ANTHROPIC_API_KEY**: Get from the [Anthropic Console](https://console.anthropic.com/)
- **KERNEL_API_KEY**: Get from the [Kernel Dashboard](https://dashboard.onkernel.com/api-keys)

## Overview

The Claude Agent SDK provides a powerful way to build AI agents that can autonomously perform tasks. This example combines it with Kernel's Playwright Execution API to create an agent that can browse the web and interact with websites.

## Features

- **Claude Agent SDK**: Uses Claude's agent capabilities with built-in tool management
- **Kernel Browser**: Cloud-based browser with stealth mode and live view
- **Playwright Execution**: Execute Playwright code directly in the browser VM
- **In-process MCP Server**: Custom tool exposed via MCP for the agent to use
- **Dual Execution**: Run locally via CLI or deploy as a Kernel app

## Setup

1. Install dependencies:

```bash
uv sync
```

2. Set up environment variables:

```bash
cp .env.example .env
# Edit .env with your API keys
```

## Running Locally

Run the agent directly from the command line:

```bash
# Default task (Hacker News top stories)
uv run main.py

# Custom task
uv run main.py "Go to duckduckgo.com and search for 'Kernel browser automation'"

# Another example
uv run main.py "Go to https://github.com/trending and list the top 5 trending repositories"
```

## Deploying to Kernel

Deploy and invoke the app on Kernel's infrastructure:

```bash
# Login to Kernel
kernel login

# Deploy the app with environment variables
kernel deploy main.py --env-file .env

# Invoke the action (logs stream automatically)
kernel invoke py-claude-agent-sdk agent-task -p '{"task": "Go to https://news.ycombinator.com and get the top 3 stories"}'
```

## How It Works

1. **Browser Creation**: A Kernel browser session is created with stealth mode enabled
2. **MCP Server**: An in-process MCP server is created with an `execute_playwright` tool
3. **Agent Execution**: The Claude Agent SDK runs with access to the Playwright tool
4. **Task Completion**: Claude autonomously uses the tool to complete the given task
5. **Cleanup**: The browser session is deleted when done

When running on Kernel, the app first installs Claude Code on the remote infrastructure before executing the agent.

## Example Tasks

```bash
# Get top Hacker News stories
uv run main.py "Go to https://news.ycombinator.com and tell me the top 3 stories"

# Search for something
uv run main.py "Go to duckduckgo.com and search for 'Kernel browser automation'"

# Extract data from a page
uv run main.py "Go to https://github.com/trending and list the top 5 trending repositories"
```

## Environment Variables

| Variable | Description |
| ------------------- | ------------------------------------------ |
| `ANTHROPIC_API_KEY` | Your Anthropic API key for Claude |
| `KERNEL_API_KEY` | Your Kernel API key for browser automation |

## API Response

When invoked via Kernel, the action returns:

```json
{
"result": "The agent's final response text",
"cost_usd": 0.1234,
"duration_ms": 45000
}
```

## Learn More

- [Claude Agent SDK Documentation](https://platform.claude.com/docs/en/agent-sdk/overview)
- [Claude Agent SDK Get Started](https://platform.claude.com/docs/en/agent-sdk/overview#get-started)
- [Kernel Documentation](https://www.kernel.sh/docs)
- [Kernel Playwright Execution API](https://www.kernel.sh/docs/browsers/playwright-execution)
66 changes: 66 additions & 0 deletions pkg/templates/python/claude-agent-sdk/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Virtual Environment
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
activate/

# IDE
.idea/
.vscode/
*.swp
*.swo
.project
.pydevproject
.settings/

# Testing
.coverage
htmlcov/
.pytest_cache/
.tox/
.nox/
coverage.xml
*.cover
.hypothesis/

# Logs
*.log
logs/

# OS
.DS_Store
Thumbs.db

# Misc
.cache/
.pytest_cache/
.mypy_cache/
.ruff_cache/
.temp/
.tmp/
Loading