Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
sidebar_position: 4
---

# Rock Agent 快速启动

Rock Agent 是 ROCK 提供的 AI Agent 运行框架,支持在沙箱环境中运行各种类型的 Agent。

## 前置条件

- ROCK Admin 服务已启动:`rock admin start`

## 使用示例

ROCK 提供了两个Hello World Agent 示例,位于 `examples/agents/` 目录下:

```
examples/agents/
├── claude_code/ # ClaudeCode Agent 示例
└── iflow_cli/ # IFlowCli Agent 示例
```

### 运行 IFlowCli 示例

```bash
cd examples/agents/iflow_cli
python iflow_cli_demo.py
```

### 运行 ClaudeCode 示例

```bash
cd examples/agents/claude_code
python claude_code_demo.py
```

## IFlowCli 配置文件

配置文件位于 `examples/agents/iflow_cli/rock_agent_config.yaml`:

```yaml
run_cmd: "iflow -p ${prompt} --yolo"

runtime_env_config:
type: node
npm_registry: "https://registry.npmmirror.com"
custom_install_cmd: "npm i -g @iflow-ai/iflow-cli@latest"

env:
IFLOW_API_KEY: "" # 填入你的 API Key
IFLOW_BASE_URL: "" # 填入你的 Base URL
IFLOW_MODEL_NAME: "" # 填入你的模型名称
```

## ClaudeCode 配置文件

配置文件位于 `examples/agents/claude_code/rock_agent_config.yaml`:

```yaml
run_cmd: "claude -p ${prompt}"

runtime_env_config:
type: node
custom_install_cmd: "npm install -g @anthropic-ai/claude-code"

env:
ANTHROPIC_BASE_URL: "" # 填入你的anthropic base url
ANTHROPIC_API_KEY: "" # 填入你的anthropic api key
```

## 相关文档

- [RockAgent 参考](../References/Python%20SDK%20References/rock-agent.md)
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ await sandbox.agent.run(prompt="hello")
5. 执行 `post_init_cmds`

**参数:**
- `config`: YAML 配置文件路径或 `RockAgentConfig` 对象
- `config`: Agent 配置文件,支持两种传入方式:
- **字符串路径**: YAML 配置文件路径,默认值为 `"rock_agent_config.yaml"`
- **RockAgentConfig 对象**: 直接传入 `RockAgentConfig` 实例

### run(prompt)

Expand Down
73 changes: 73 additions & 0 deletions docs/versioned_docs/version-1.1.x/Getting Started/rock-agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
sidebar_position: 4
---

# Rock Agent Quick Start

Rock Agent is an AI Agent runtime framework provided by ROCK, supporting various types of Agents running in sandbox environments.

## Prerequisites

- ROCK Admin service is running: `rock admin start`

## Examples

ROCK provides two Hello World Agent examples in the `examples/agents/` directory:

```
examples/agents/
├── claude_code/ # ClaudeCode Agent example
└── iflow_cli/ # IFlowCli Agent example
```

### Run IFlowCli Example

```bash
cd examples/agents/iflow_cli
python iflow_cli_demo.py
```

### Run ClaudeCode Example

```bash
cd examples/agents/claude_code
python claude_code_demo.py
```

## IFlowCli Configuration File

The configuration file is located at `examples/agents/iflow_cli/rock_agent_config.yaml`:

```yaml
run_cmd: "iflow -p ${prompt} --yolo"

runtime_env_config:
type: node
npm_registry: "https://registry.npmmirror.com"
custom_install_cmd: "npm i -g @iflow-ai/iflow-cli@latest"

env:
IFLOW_API_KEY: "" # Enter your API key
IFLOW_BASE_URL: "" # Enter your base URL
IFLOW_MODEL_NAME: "" # Enter your model name
```

## ClaudeCode Configuration File

The configuration file is located at `examples/agents/claude_code/rock_agent_config.yaml`:

```yaml
run_cmd: "claude -p ${prompt}"

runtime_env_config:
type: node
custom_install_cmd: "npm install -g @anthropic-ai/claude-code"

env:
ANTHROPIC_BASE_URL: "" # Enter your anthropic base url
ANTHROPIC_API_KEY: "" # Enter your anthropic api key
```

## Related Documentation

- [RockAgent Reference](../References/Python%20SDK%20References/rock-agent.md)
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ Initialize Agent environment.
5. Execute `post_init_cmds`

**Parameters:**
- `config`: YAML config file path or `RockAgentConfig` object
- `config`: Agent configuration file, supports two input methods:
- **String path**: YAML config file path, default value like `"rock_agent_config.yaml"`
- **RockAgentConfig object**: Directly pass a `RockAgentConfig` instance

### run(prompt)

Expand Down
29 changes: 29 additions & 0 deletions examples/agents/claude_code/claude_code_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import asyncio
import os
from pathlib import Path

from rock.sdk.sandbox.client import Sandbox
from rock.sdk.sandbox.config import SandboxConfig


async def main() -> None:
sandbox = Sandbox(SandboxConfig())

await sandbox.start()

await sandbox.agent.install()

result = await sandbox.agent.run("Hello")

print(f"[Agent] run finished, result={result}")

await sandbox.stop()


if __name__ == "__main__":
os.chdir(Path(__file__).resolve().parent)

# Ensure admin server is running before executing
print("IMPORTANT: Make sure the admin server is running before executing this demo!")
print("Start the admin server with: rock admin start")
asyncio.run(main())
9 changes: 9 additions & 0 deletions examples/agents/claude_code/rock_agent_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
run_cmd: "claude -p ${prompt}"

runtime_env_config:
type: node
custom_install_cmd: "npm install -g @anthropic-ai/claude-code"

env:
ANTHROPIC_BASE_URL: "" # Enter your anthropic base url
ANTHROPIC_API_KEY: "" # Enter your anthropic api key
29 changes: 29 additions & 0 deletions examples/agents/iflow_cli/iflow_cli_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import asyncio
import os
from pathlib import Path

from rock.sdk.sandbox.client import Sandbox
from rock.sdk.sandbox.config import SandboxConfig


async def main() -> None:
sandbox = Sandbox(SandboxConfig())

await sandbox.start()

await sandbox.agent.install()

result = await sandbox.agent.run("Hello")

print(f"[Agent] run finished, result={result}")

await sandbox.stop()


if __name__ == "__main__":
os.chdir(Path(__file__).resolve().parent)

# Ensure admin server is running before executing
print("IMPORTANT: Make sure the admin server is running before executing this demo!")
print("Start the admin server with: rock admin start")
asyncio.run(main())
11 changes: 11 additions & 0 deletions examples/agents/iflow_cli/rock_agent_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
run_cmd: "iflow -p ${prompt} --yolo"

runtime_env_config:
type: node
npm_registry: "https://registry.npmmirror.com"
custom_install_cmd: "npm i -g @iflow-ai/iflow-cli@latest"

env:
IFLOW_API_KEY: "" # Enter your API key
IFLOW_BASE_URL: "" # Enter your base url
IFLOW_MODEL_NAME: "" # Enter your model name