Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
680d5be
Add initial implementation of AgentRun CLI and supporting modules
acsoto Nov 17, 2025
4ae759c
Update directory references in demo, pyproject, QUICKSTART, and READM…
acsoto Nov 17, 2025
d55252d
Integrate k8s provider & Unpack invoke runtime
t2wang Nov 19, 2025
19c7d06
Add cli .gitignore
t2wang Nov 19, 2025
5c2976e
Refactor DockerService to utilize Docker SDK for operations
acsoto Nov 20, 2025
2b5dae2
Implement AgentCube provider for deploying AgentRuntime CRs to Kubern…
acsoto Nov 27, 2025
3f3b0a7
Support custom API URI
acsoto Nov 27, 2025
c948cbd
Enhance deployment options by introducing support for standard Kubern…
acsoto Nov 27, 2025
1e114eb
Implement polling mechanism for AgentRuntime CR endpoint retrieval an…
acsoto Nov 27, 2025
986d07e
Refactor legacy provider
acsoto Nov 27, 2025
02faaea
Update CLI commands to use 'kubectl agentrun'
acsoto Dec 1, 2025
eef3243
Project Clean-up
t2wang Nov 28, 2025
20f84e1
Update README.md
acsoto Nov 29, 2025
c62f165
Add namespace & endpoint options to the publich command
t2wang Dec 1, 2025
1443dff
Remove emojis
t2wang Dec 3, 2025
ab06e6c
Resolve code review issues
t2wang Dec 4, 2025
59126c1
Set default namespace and modify CR
acsoto Dec 5, 2025
62e8259
Add some options to AgentRuntime deployment
acsoto Dec 5, 2025
bfa6046
Add math agent example
acsoto Dec 7, 2025
73500a0
Update runtime configuration to support registry credentials
acsoto Dec 8, 2025
0a75302
Automatically increment the version number in agent_metadata.yaml wit…
acsoto Dec 8, 2025
d43be4c
Check if router_url and workload_manager_url are set
acsoto Dec 8, 2025
47cbeea
Refactor CodeInterpreterClient usage
acsoto Dec 8, 2025
e4d8cbd
Reuse same session & Simplify cli workflow
t2wang Dec 8, 2025
f960773
Refactor math agent
acsoto Dec 8, 2025
2d3b055
Add readinessProbe to AgentRuntime CR
t2wang Dec 8, 2025
401fe5c
Adjust metadata fields order
t2wang Dec 9, 2025
da4c67d
Suppress warnings & Remove session id during publish
t2wang Dec 9, 2025
376bcf5
Add RunPythonCodeArgs schema
acsoto Dec 9, 2025
85101b3
Resolve code review comments
t2wang Dec 9, 2025
1b4658d
Resolve code review comments
t2wang Dec 10, 2025
df268a7
Fix incorrect imports
t2wang Dec 11, 2025
c6ce6ba
Rename cli to AgentCube
t2wang Dec 17, 2025
7af9239
Remove obsolete files
t2wang Dec 17, 2025
e8ec323
Correct env variable
t2wang Dec 17, 2025
ecf3e19
Add header validation
t2wang Dec 17, 2025
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
3 changes: 3 additions & 0 deletions cmd/agentrun/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Project specific
agent_metadata.yaml
Dockerfile
303 changes: 303 additions & 0 deletions cmd/agentrun/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
# AgentRun CLI

AgentRun CLI is a developer tool that streamlines the development, packaging, building, and deployment of AI agents to AgentCube. It provides a unified interface for managing the complete agent lifecycle from local development to cloud deployment.

## Quick Start

### Prerequisites

- Python 3.8+
- Git
- Docker (optional, for container builds)

### Installation

```bash
# Clone the repository
git clone https://github.com/volcano-sh/agentcube.git
cd agentcube/cmd/agentrun

# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e .
```

### Your First Agent

1. **Package an existing agent:**
```bash
kubectl agentrun pack -f examples/hello-agent --agent-name "my-agent"
```

2. **Build the container image:**
```bash
kubectl agentrun build -f examples/hello-agent
```

3. **Publish to AgentCube:**
```bash
kubectl agentrun publish \
-f examples/hello-agent \
--image-url "docker.io/username/my-agent" \
```

4. **Invoke your agent:**
```bash
kubectl agentrun invoke -f examples/hello-agent --payload '{"prompt": "Hello World!"}'
```

5. **Check status:**
```bash
kubectl agentrun status -f examples/hello-agent
```

## Features

- **Multi-language Support**: Python, Java (with more languages planned)
- **Flexible Build Modes**: Local Docker builds and cloud builds
- **Multi-Provider Deployment**: Support for AgentCube CRDs and standard Kubernetes deployments
- **AgentCube Integration**: Seamless publishing and management
- **Developer-friendly**: Rich CLI experience with detailed feedback
- **CI/CD Ready**: Python SDK for programmatic access
- **Extensible Architecture**: Plugin system for custom providers

## Installation

### From PyPI (Recommended)

```bash
pip install agentrun
```

### From Source

```bash
git clone https://github.com/volcano-sh/agentcube.git
cd agentcube/cmd/agentrun
pip install -e .
```

## Documentation

- [Design](AgentRun-CLI-Design.md)
- [Examples](examples/)

## Configuration

AgentRun uses a `agent_metadata.yaml` file to configure your agent:

```yaml
agent_name: my-agent
description: "A sample AI agent"
language: python
entrypoint: python main.py
port: 8080
build_mode: local
requirements_file: requirements.txt
```

## Architecture

AgentRun CLI follows a modular four-layer architecture:

1. **CLI Layer**: Typer-based command interface
2. **Runtime Layer**: Business logic and Python SDK
3. **Operations Layer**: Core domain logic
4. **Services Layer**: External integrations

## Deployment Providers

AgentRun supports two deployment providers:

### AgentCube Provider (Default)

Deploys agents using AgentCube's custom AgentRuntime CRDs, providing enhanced agent lifecycle management and integration with the AgentCube ecosystem.

```bash
kubectl agentrun publish -f examples/hello-agent --provider agentcube
```

### Standard Kubernetes Provider

Deploys agents as standard Kubernetes Deployments and Services, suitable for environments without AgentCube CRDs installed.

```bash
kubectl agentrun publish -f examples/hello-agent --provider k8s \
--node-port 30080 \
--replicas 3
```

## Command Reference

### `kubectl agentrun pack`
Package the agent application into a standardized workspace.

```bash
kubectl agentrun pack [OPTIONS]

Options:
-f, --workspace TEXT Path to the agent workspace directory [default: .]
--agent-name TEXT Override the agent name
--language TEXT Programming language (python, java)
--entrypoint TEXT Override the entrypoint command
--port INTEGER Port to expose in the Dockerfile
--build-mode TEXT Build strategy: local or cloud
--description TEXT Agent description
--output TEXT Output path for packaged workspace
--verbose Enable detailed logging
```

### `kubectl agentrun build`
Build the agent image based on the packaged workspace.

```bash
kubectl agentrun build [OPTIONS]

Options:
-f, --workspace TEXT Path to the agent workspace directory [default: .]
-p, --proxy TEXT Custom proxy URL for dependency resolution
--cloud-provider TEXT Cloud provider name (e.g., huawei)
--output TEXT Output path for build artifacts
--verbose Enable detailed logging
```

### `kubectl agentrun publish`
Publish the agent to AgentCube

```bash
kubectl agentrun publish [OPTIONS]

Options:
-f, --workspace TEXT Path to the agent workspace directory [default: .]
--version TEXT Semantic version string (e.g., v1.0.0)
--image-url TEXT Image repository URL (required in local build mode)
--image-username TEXT Username for image repository
--image-password TEXT Password for image repository
--description TEXT Agent description
--region TEXT Deployment region
--cloud-provider TEXT Cloud provider name (e.g., huawei)
--provider TEXT Target provider for deployment (agentcube, k8s). 'agentcube' deploys AgentRuntime CR, 'k8s' deploys standard K8s Deployment/Service. [default: agentcube]
--node-port INTEGER Specific NodePort to use (30000-32767) for K8s deployment
--replicas INTEGER Number of replicas for K8s deployment (default: 1)
--endpoint TEXT Custom API endpoint for AgentCube or Kubernetes cluster
--namespace TEXT Kubernetes namespace to use for deployment [default: default]
--verbose Enable detailed logging
```

### `kubectl agentrun invoke`
Invoke a published agent via AgentCube or Kubernetes.

```bash
kubectl agentrun invoke [OPTIONS]

Options:
-f, --workspace TEXT Path to the agent workspace directory [default: .]
--payload TEXT JSON-formatted input passed to the agent [default: {}]
--header TEXT Custom HTTP headers (e.g., 'Authorization: Bearer token')
--provider TEXT Target provider for deployment (agentcube, k8s). 'agentcube' deploys AgentRuntime CR, 'k8s' deploys standard K8s Deployment/Service. [default: agentcube]
--verbose Enable detailed logging
```

### `kubectl agentrun status`
Check the status of a published agent.

```bash
kubectl agentrun status [OPTIONS]

Options:
-f, --workspace TEXT Path to the agent workspace directory [default: .]
--provider TEXT Target provider for deployment (agentcube, k8s). 'agentcube' deploys AgentRuntime CR, 'k8s' deploys standard K8s Deployment/Service. [default: agentcube]
--verbose Enable detailed logging
```

## Agent Structure

An AgentRun workspace typically contains:

```
my-agent/
├── agent_metadata.yaml # Agent configuration (auto-generated)
├── Dockerfile # Container definition (auto-generated)
├── requirements.txt # Python dependencies
├── main.py # Agent entrypoint
└── src/ # Source code
```

### `agent_metadata.yaml`

```yaml
agent_name: my-agent
description: "My AI agent"
language: python
entrypoint: python main.py
port: 8080
build_mode: local
requirements_file: requirements.txt
```

## Language Support

### Python

Fully supported with automatic dependency management and Dockerfile generation.

- Supported versions: Python 3.8+
- Package manager: pip
- Dependencies file: requirements.txt
- Example: [examples/hello-agent](examples/hello-agent)

### Java

Supported with Maven-based builds and OpenJDK runtime.

- Supported versions: Java 17+
- Build tool: Maven
- Dependencies file: pom.xml
- Note: Java example coming soon

## Troubleshooting

### Common Issues

1. **"Docker is not available"**
- Install Docker and make sure it's running
- Use `--build-mode cloud` for cloud builds

2. **"Metadata file not found"**
- Run `kubectl agentrun pack` first to generate metadata
- Ensure you're in the correct workspace directory

3. **"Agent not published yet"**
- Run `kubectl agentrun publish` before trying to invoke
- Check that the build completed successfully

4. **"Provider not found"**
- Ensure you're using a valid provider: `agentcube` or `k8s`
- Check that your Kubernetes cluster has the required CRDs (for agentcube provider)

### Getting Help

```bash
# General help
kubectl agentrun --help

# Command-specific help
kubectl agentrun pack --help
kubectl agentrun build --help
kubectl agentrun publish --help
kubectl agentrun invoke --help
kubectl agentrun status --help
```

## License

This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.

## Links

- [AgentCube Main Project](https://github.com/volcano-sh/agentcube)
- [Volcano Scheduler](https://github.com/volcano-sh/volcano)
- [Issue Tracker](https://github.com/volcano-sh/agentcube/issues)
21 changes: 21 additions & 0 deletions cmd/agentrun/agentrun/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
AgentRun CLI - A developer tool for packaging, building, and deploying AI agents to AgentCube.
"""

__version__ = "0.1.0"
__author__ = "AgentCube Community"
__email__ = "agentcube@volcano.sh"

from .cli.main import app
from .runtime.pack_runtime import PackRuntime
from .runtime.build_runtime import BuildRuntime
from .runtime.publish_runtime import PublishRuntime
from .runtime.invoke_runtime import InvokeRuntime

__all__ = [
"app",
"PackRuntime",
"BuildRuntime",
"PublishRuntime",
"InvokeRuntime",
]
3 changes: 3 additions & 0 deletions cmd/agentrun/agentrun/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
CLI module for AgentRun.
"""
Loading
Loading