-
Notifications
You must be signed in to change notification settings - Fork 41
Add Agentrun CLI #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Agentrun CLI #54
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 4ae759c
Update directory references in demo, pyproject, QUICKSTART, and READM…
acsoto d55252d
Integrate k8s provider & Unpack invoke runtime
t2wang 19c7d06
Add cli .gitignore
t2wang 5c2976e
Refactor DockerService to utilize Docker SDK for operations
acsoto 2b5dae2
Implement AgentCube provider for deploying AgentRuntime CRs to Kubern…
acsoto 3f3b0a7
Support custom API URI
acsoto c948cbd
Enhance deployment options by introducing support for standard Kubern…
acsoto 1e114eb
Implement polling mechanism for AgentRuntime CR endpoint retrieval an…
acsoto 986d07e
Refactor legacy provider
acsoto 02faaea
Update CLI commands to use 'kubectl agentrun'
acsoto eef3243
Project Clean-up
t2wang 20f84e1
Update README.md
acsoto c62f165
Add namespace & endpoint options to the publich command
t2wang 1443dff
Remove emojis
t2wang ab06e6c
Resolve code review issues
t2wang 59126c1
Set default namespace and modify CR
acsoto 62e8259
Add some options to AgentRuntime deployment
acsoto bfa6046
Add math agent example
acsoto 73500a0
Update runtime configuration to support registry credentials
acsoto 0a75302
Automatically increment the version number in agent_metadata.yaml wit…
acsoto d43be4c
Check if router_url and workload_manager_url are set
acsoto 47cbeea
Refactor CodeInterpreterClient usage
acsoto e4d8cbd
Reuse same session & Simplify cli workflow
t2wang f960773
Refactor math agent
acsoto 2d3b055
Add readinessProbe to AgentRuntime CR
t2wang 401fe5c
Adjust metadata fields order
t2wang da4c67d
Suppress warnings & Remove session id during publish
t2wang 376bcf5
Add RunPythonCodeArgs schema
acsoto 85101b3
Resolve code review comments
t2wang 1b4658d
Resolve code review comments
t2wang df268a7
Fix incorrect imports
t2wang c6ce6ba
Rename cli to AgentCube
t2wang 7af9239
Remove obsolete files
t2wang e8ec323
Correct env variable
t2wang ecf3e19
Add header validation
t2wang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Project specific | ||
| agent_metadata.yaml | ||
| Dockerfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
acsoto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
acsoto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| """ | ||
| CLI module for AgentRun. | ||
| """ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.