rl-rock 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -2
- package/dist/index.d.mts +1082 -73
- package/dist/index.d.ts +1082 -73
- package/dist/index.js +1616 -448
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1602 -444
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -11,8 +11,9 @@ ROCK (Remote Operation Container Kit) TypeScript SDK - 用于管理远程沙箱
|
|
|
11
11
|
- 🚀 **沙箱管理** - 创建、启动、停止远程容器沙箱
|
|
12
12
|
- 📁 **文件系统** - 上传、下载、读取、写入文件
|
|
13
13
|
- 🖥️ **命令执行** - 同步/异步执行 Shell 命令
|
|
14
|
-
- 🔧 **运行时环境** - 支持 Python、Node.js
|
|
15
|
-
- 🤖
|
|
14
|
+
- 🔧 **运行时环境** - 支持 Python、Node.js 运行时环境管理(沙箱内安装)
|
|
15
|
+
- 🤖 **模型服务** - 沙箱内模型服务安装与生命周期管理
|
|
16
|
+
- 🎯 **Agent 框架** - 内置 Agent 支持自动化任务编排
|
|
16
17
|
- 📦 **EnvHub** - 环境注册与管理
|
|
17
18
|
- 🔄 **双模式构建** - 同时支持 ESM 和 CommonJS
|
|
18
19
|
|
|
@@ -128,6 +129,80 @@ const [obs, reward, terminated, truncated, info] = await env.step('action');
|
|
|
128
129
|
await env.close();
|
|
129
130
|
```
|
|
130
131
|
|
|
132
|
+
### 使用 RuntimeEnv (沙箱内运行时环境)
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { Sandbox, RuntimeEnv, PythonRuntimeEnvConfig } from 'rl-rock';
|
|
136
|
+
|
|
137
|
+
const sandbox = new Sandbox({ ... });
|
|
138
|
+
await sandbox.start();
|
|
139
|
+
|
|
140
|
+
// 创建 Python 运行时环境配置
|
|
141
|
+
const pythonConfig: PythonRuntimeEnvConfig = {
|
|
142
|
+
type: 'python',
|
|
143
|
+
version: '3.11',
|
|
144
|
+
pipPackages: ['requests', 'numpy'],
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// 在沙箱内安装 Python 运行时
|
|
148
|
+
const runtimeEnv = await RuntimeEnv.create(sandbox, pythonConfig);
|
|
149
|
+
|
|
150
|
+
// 使用 Python 执行命令
|
|
151
|
+
await runtimeEnv.run('python -c "import requests; print(requests.__version__)"');
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 使用 ModelService (沙箱内模型服务)
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { Sandbox, ModelService, ModelServiceConfig } from 'rl-rock';
|
|
158
|
+
|
|
159
|
+
const sandbox = new Sandbox({ ... });
|
|
160
|
+
await sandbox.start();
|
|
161
|
+
|
|
162
|
+
// 创建模型服务配置
|
|
163
|
+
const modelServiceConfig: ModelServiceConfig = {
|
|
164
|
+
enabled: true,
|
|
165
|
+
installCmd: 'pip install rl_rock[model-service]',
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// 在沙箱内安装并启动模型服务
|
|
169
|
+
const modelService = new ModelService(sandbox, modelServiceConfig);
|
|
170
|
+
await modelService.install();
|
|
171
|
+
await modelService.start();
|
|
172
|
+
|
|
173
|
+
// 监控 Agent 进程
|
|
174
|
+
await modelService.watchAgent('12345');
|
|
175
|
+
|
|
176
|
+
// 停止服务
|
|
177
|
+
await modelService.stop();
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### 使用 Agent (自动化任务编排)
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { Sandbox, DefaultAgent, RockAgentConfig } from 'rl-rock';
|
|
184
|
+
|
|
185
|
+
const sandbox = new Sandbox({ ... });
|
|
186
|
+
await sandbox.start();
|
|
187
|
+
|
|
188
|
+
// 配置 Agent
|
|
189
|
+
const agentConfig: RockAgentConfig = {
|
|
190
|
+
agentSession: 'my-agent-session',
|
|
191
|
+
runCmd: 'python agent.py --prompt {prompt}',
|
|
192
|
+
workingDir: './my-project', // 本地目录,自动上传到沙箱
|
|
193
|
+
runtimeEnvConfig: { type: 'python', version: '3.11' },
|
|
194
|
+
modelServiceConfig: { enabled: true },
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// 创建并安装 Agent
|
|
198
|
+
const agent = new DefaultAgent(sandbox);
|
|
199
|
+
await agent.install(agentConfig);
|
|
200
|
+
|
|
201
|
+
// 运行 Agent
|
|
202
|
+
const result = await agent.run('Please analyze the codebase');
|
|
203
|
+
console.log(result.output);
|
|
204
|
+
```
|
|
205
|
+
|
|
131
206
|
## 配置
|
|
132
207
|
|
|
133
208
|
### 环境变量
|
|
@@ -175,6 +250,9 @@ interface SandboxConfig {
|
|
|
175
250
|
| `envhub-usage.ts` | EnvHub 环境管理示例 |
|
|
176
251
|
| `sandbox-group.ts` | 沙箱组批量操作示例 |
|
|
177
252
|
| `complete-workflow.ts` | 完整开发工作流示例 |
|
|
253
|
+
| `runtime-env-usage.ts` | 运行时环境管理示例 |
|
|
254
|
+
| `model-service-usage.ts` | 模型服务使用示例 |
|
|
255
|
+
| `agent-usage.ts` | Agent 自动化任务示例 |
|
|
178
256
|
|
|
179
257
|
### 运行示例
|
|
180
258
|
|