recoder-code 2.4.3 → 2.4.4

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.
@@ -1,331 +0,0 @@
1
- # Recoder Code Sandbox Setup Guide
2
-
3
- ## What is the Sandbox?
4
-
5
- The sandbox feature provides **isolated execution** of commands and code, protecting your system from potentially harmful operations. When enabled, Recoder Code runs all shell commands and file operations inside a containerized environment.
6
-
7
- ## Benefits of Using Sandbox
8
-
9
- 1. **Security**: Isolates AI-generated code from your main system
10
- 2. **Reproducibility**: Consistent environment across different machines
11
- 3. **Safety**: Prevents accidental system-wide changes
12
- 4. **Clean testing**: Test code without affecting your development environment
13
-
14
- ## Current Status
15
-
16
- You're seeing "no sandbox" in the footer because sandbox mode is **disabled by default**. Recoder Code supports three sandbox options:
17
-
18
- 1. **Docker** (Linux/macOS/Windows)
19
- 2. **Podman** (Linux/macOS alternative to Docker)
20
- 3. **macOS Seatbelt** (macOS only, lightweight sandboxing)
21
-
22
- ## Quick Setup
23
-
24
- ### Option 1: Docker Sandbox (Recommended for most users)
25
-
26
- #### Prerequisites
27
- ```bash
28
- # Install Docker Desktop (macOS/Windows)
29
- # Or install Docker Engine (Linux)
30
- # Visit: https://docs.docker.com/get-docker/
31
- ```
32
-
33
- #### Enable Sandbox
34
- ```bash
35
- # Method 1: Environment variable (temporary)
36
- export RECODER_SANDBOX=docker
37
-
38
- # Method 2: In .env file (permanent)
39
- echo "RECODER_SANDBOX=docker" >> ~/.recoder/.env
40
-
41
- # Method 3: Command line flag
42
- recoder-code --sandbox docker
43
- ```
44
-
45
- #### Specify Custom Image (Optional)
46
- ```bash
47
- # Use a specific Docker image
48
- export RECODER_SANDBOX_IMAGE=node:20-alpine
49
-
50
- # Or in package.json config
51
- {
52
- "config": {
53
- "sandboxImageUri": "node:20-alpine"
54
- }
55
- }
56
- ```
57
-
58
- ### Option 2: macOS Seatbelt (macOS only, lightweight)
59
-
60
- macOS Seatbelt provides lightweight sandboxing without Docker:
61
-
62
- ```bash
63
- # Enable seatbelt sandbox
64
- export RECODER_SANDBOX=sandbox-exec
65
-
66
- # Choose a profile (optional, default: permissive-open)
67
- export SEATBELT_PROFILE=restrictive-open
68
-
69
- # Run Recoder Code
70
- recoder-code
71
- ```
72
-
73
- **Available Profiles:**
74
- - `permissive-open` - Network access allowed (default)
75
- - `permissive-closed` - No network access
76
- - `permissive-proxied` - Network through proxy only
77
- - `restrictive-open` - Limited file access + network
78
- - `restrictive-closed` - Limited file access, no network
79
- - `restrictive-proxied` - Limited file access + proxy
80
-
81
- ### Option 3: Podman (Docker alternative)
82
-
83
- ```bash
84
- # Install Podman first
85
- # macOS: brew install podman
86
- # Linux: sudo apt install podman (or use your distro's package manager)
87
-
88
- # Enable Podman sandbox
89
- export RECODER_SANDBOX=podman
90
-
91
- # Run Recoder Code
92
- recoder-code
93
- ```
94
-
95
- ## Configuration Options
96
-
97
- ### Environment Variables
98
-
99
- ```bash
100
- # Core sandbox settings
101
- RECODER_SANDBOX=docker|podman|sandbox-exec|false # Sandbox type
102
- RECODER_SANDBOX_IMAGE=image:tag # Container image
103
- SANDBOX=container-name # Inside sandbox (auto-set)
104
-
105
- # Advanced settings
106
- SANDBOX_PORTS=8080,3000 # Expose ports
107
- SANDBOX_FLAGS="--memory=2g --cpus=2" # Custom Docker flags
108
- SANDBOX_MOUNTS=/path/to/mount:/container/path:ro # Additional mounts
109
- SANDBOX_ENV="KEY1=value1,KEY2=value2" # Extra env vars
110
- SANDBOX_SET_UID_GID=1 # Use host UID/GID (Linux)
111
-
112
- # Seatbelt-specific (macOS)
113
- SEATBELT_PROFILE=permissive-open # Seatbelt profile
114
-
115
- # Proxy settings (for restricted networks)
116
- RECODER_SANDBOX_PROXY_COMMAND="mitmproxy -p 8877" # Proxy command
117
- HTTPS_PROXY=http://localhost:8877 # Proxy URL
118
- ```
119
-
120
- ### Settings File Configuration
121
-
122
- Add to `~/.recoder/settings.json`:
123
-
124
- ```json
125
- {
126
- "tools": {
127
- "sandbox": "docker"
128
- }
129
- }
130
- ```
131
-
132
- Or use `recoder-code --sandbox docker` when starting.
133
-
134
- ## Verifying Sandbox is Active
135
-
136
- When sandbox is enabled, you'll see in the footer:
137
-
138
- ```
139
- šŸ”’ docker-node-20 # Docker/Podman sandbox active
140
- šŸ”’ macOS Seatbelt (...) # macOS Seatbelt active
141
- šŸ’» Interactive Mode # No sandbox (current state)
142
- ```
143
-
144
- You can also check with:
145
- ```bash
146
- # Inside Recoder Code, run:
147
- !echo $SANDBOX
148
-
149
- # If output is empty, no sandbox
150
- # If output shows container name, sandbox is active
151
- ```
152
-
153
- ## Troubleshooting
154
-
155
- ### Docker Daemon Not Running
156
- ```
157
- Error: Cannot connect to Docker daemon
158
- Solution: Start Docker Desktop or Docker service
159
- ```
160
-
161
- ### Image Not Found
162
- ```
163
- Error: Sandbox image 'image:tag' is missing
164
- Solution: Pull the image manually or let Recoder Code pull it
165
- docker pull node:20-alpine
166
- ```
167
-
168
- ### Permission Issues (Linux)
169
- ```
170
- Error: Permission denied
171
- Solution: Add your user to docker group
172
- sudo usermod -aG docker $USER
173
- newgrp docker
174
- ```
175
-
176
- ### macOS Seatbelt Not Working
177
- ```
178
- Error: Missing sandbox command 'sandbox-exec'
179
- Solution: Seatbelt is built into macOS, check your macOS version
180
- ```
181
-
182
- ## Custom Sandbox Images
183
-
184
- ### Create a Custom Dockerfile
185
-
186
- Create `.recoder/sandbox.Dockerfile`:
187
-
188
- ```dockerfile
189
- FROM node:20-alpine
190
-
191
- # Install additional tools
192
- RUN apk add --no-cache \
193
- python3 \
194
- py3-pip \
195
- git \
196
- curl \
197
- vim
198
-
199
- # Install Python packages
200
- RUN pip3 install requests numpy pandas
201
-
202
- # Set working directory
203
- WORKDIR /workspace
204
-
205
- # Custom entrypoint (optional)
206
- CMD ["bash"]
207
- ```
208
-
209
- ### Build and Use Custom Image
210
-
211
- ```bash
212
- # Set BUILD_SANDBOX to build on first run
213
- export BUILD_SANDBOX=1
214
- export RECODER_SANDBOX=docker
215
- export RECODER_SANDBOX_IMAGE=recoder-code-custom
216
-
217
- recoder-code
218
- ```
219
-
220
- ## Performance Considerations
221
-
222
- ### Sandbox Overhead
223
- - **Docker/Podman**: ~100-500ms startup overhead, minimal runtime impact
224
- - **macOS Seatbelt**: Negligible overhead, native performance
225
-
226
- ### When to Use Sandbox
227
- - **Always**: When running untrusted or AI-generated code
228
- - **Development**: Testing in clean environments
229
- - **CI/CD**: Reproducible builds
230
- - **Demos**: Safe demonstrations
231
-
232
- ### When Sandbox Might Not Be Needed
233
- - **Trusted codebases**: Your own well-tested projects
234
- - **Read-only operations**: Analyzing code without execution
235
- - **Performance-critical**: High-frequency operations
236
-
237
- ## Integration with Recoder Code Features
238
-
239
- ### File Operations
240
- All file read/write operations happen in the sandbox when enabled.
241
-
242
- ### Shell Commands
243
- Every `!command` or shell execution runs inside the sandbox.
244
-
245
- ### Network Access
246
- - Docker/Podman: Network access by default
247
- - Seatbelt: Depends on profile (-open/-closed/-proxied)
248
-
249
- ### MCP Servers
250
- MCP servers can run in or outside the sandbox depending on configuration.
251
-
252
- ## Next Steps
253
-
254
- 1. **Choose a sandbox method** based on your OS and requirements
255
- 2. **Set environment variables** or use command-line flags
256
- 3. **Test with a simple command** to verify sandbox is active
257
- 4. **Customize sandbox image** if you need additional tools
258
-
259
- ## Example Workflows
260
-
261
- ### Workflow 1: Basic Docker Sandbox
262
- ```bash
263
- # Terminal 1: Start Docker Desktop (or ensure daemon is running)
264
-
265
- # Terminal 2: Enable sandbox and run Recoder Code
266
- export RECODER_SANDBOX=docker
267
- recoder-code
268
-
269
- # Inside Recoder Code:
270
- > !whoami # Should show 'node' or 'gemini' (container user)
271
- > !hostname # Should show container name
272
- ```
273
-
274
- ### Workflow 2: Custom Python Environment
275
- ```bash
276
- # Create custom Dockerfile
277
- mkdir -p ~/.recoder
278
- cat > ~/.recoder/sandbox.Dockerfile << 'EOF'
279
- FROM python:3.11-slim
280
- RUN pip install numpy pandas scikit-learn jupyter
281
- WORKDIR /workspace
282
- EOF
283
-
284
- # Build and use
285
- export BUILD_SANDBOX=1
286
- export RECODER_SANDBOX=docker
287
- export RECODER_SANDBOX_IMAGE=recoder-python
288
- recoder-code
289
- ```
290
-
291
- ### Workflow 3: macOS Lightweight Sandbox
292
- ```bash
293
- # No Docker needed, uses native macOS Seatbelt
294
- export RECODER_SANDBOX=sandbox-exec
295
- export SEATBELT_PROFILE=restrictive-open
296
- recoder-code
297
-
298
- # Inside Recoder Code:
299
- > !echo "Running in Seatbelt sandbox"
300
- > !curl https://example.com # Network access (if -open profile)
301
- ```
302
-
303
- ## FAQ
304
-
305
- **Q: Will sandbox slow down Recoder Code?**
306
- A: Docker/Podman adds ~100-500ms startup time. macOS Seatbelt has negligible impact.
307
-
308
- **Q: Can I use multiple sandbox types?**
309
- A: No, choose one sandbox method per session.
310
-
311
- **Q: Do I need to rebuild the sandbox image when I update Recoder Code?**
312
- A: Usually no, unless there are sandbox-specific changes. Set `BUILD_SANDBOX=1` to force rebuild.
313
-
314
- **Q: Can I access files outside my project directory in sandbox?**
315
- A: By default, only your project directory and `~/.recoder` are mounted. Use `SANDBOX_MOUNTS` for additional paths.
316
-
317
- **Q: Is sandbox required for Recoder Code to work?**
318
- A: No, sandbox is optional. Recoder Code works fine without it, but sandbox provides additional safety.
319
-
320
- **Q: Can I expose ports from the sandbox?**
321
- A: Yes, use `SANDBOX_PORTS=8080,3000` to expose specific ports.
322
-
323
- ## Support
324
-
325
- - **Documentation**: See `/docs` in Recoder Code repository
326
- - **Issues**: Create an issue on GitHub
327
- - **Community**: Join discussions in the community forum
328
-
329
- ---
330
-
331
- **Note**: Sandbox functionality is inherited from the Qwen Code base that Recoder Code was built upon. The code fully supports sandbox modes but requires explicit enablement.
package/validate.js DELETED
@@ -1,81 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const axios = require('axios');
4
- const config = require('./config.js');
5
-
6
- async function validateConfiguration() {
7
- console.log('šŸ” Validating Recoder Code configuration...\n');
8
-
9
- // Check environment variables
10
- console.log('šŸ“‹ Configuration Check:');
11
- console.log(` API Key: ${config.apiKey ? 'āœ… Set' : 'āŒ Missing'}`);
12
- console.log(` Model: ${config.model}`);
13
- console.log(` Base URL: ${config.baseURL}`);
14
- console.log(` Max Tokens: ${config.maxTokens}`);
15
- console.log(` Temperature: ${config.temperature}\n`);
16
-
17
- if (!config.apiKey) {
18
- console.log('āŒ Error: OPENROUTER_API_KEY is not set');
19
- console.log('Please run: npm run setup');
20
- process.exit(1);
21
- }
22
-
23
- // Test OpenRouter API connectivity
24
- console.log('🌐 Testing OpenRouter API connectivity...');
25
- try {
26
- const response = await axios.get('https://openrouter.ai/api/v1/models', {
27
- headers: {
28
- 'Authorization': `Bearer ${config.apiKey}`,
29
- 'HTTP-Referer': config.siteUrl,
30
- 'X-Title': config.siteName
31
- }
32
- });
33
-
34
- console.log('āœ… API connection successful');
35
-
36
- // Check if the configured model is available
37
- const models = response.data.data;
38
- const selectedModel = models.find(m => m.id === config.model);
39
-
40
- if (selectedModel) {
41
- console.log(`āœ… Model "${config.model}" is available`);
42
- console.log(` Context: ${selectedModel.context_length} tokens`);
43
- console.log(` Pricing: $${selectedModel.pricing?.prompt || 'N/A'} per 1K input tokens\n`);
44
- } else {
45
- console.log(`āš ļø Model "${config.model}" not found in available models`);
46
- console.log('Available models include:');
47
- models.slice(0, 5).forEach(model => {
48
- console.log(` - ${model.id}`);
49
- });
50
- console.log(' ... and more\n');
51
- }
52
-
53
- } catch (error) {
54
- console.log('āŒ API connection failed');
55
- if (error.response) {
56
- console.log(` Status: ${error.response.status}`);
57
- console.log(` Error: ${error.response.data?.error?.message || 'Unknown error'}`);
58
- } else {
59
- console.log(` Error: ${error.message}`);
60
- }
61
- console.log('\nPlease check your API key and network connection.\n');
62
- process.exit(1);
63
- }
64
-
65
- // Test tool configuration
66
- console.log('šŸ”§ Tool Configuration:');
67
- console.log(` Available tools: ${config.tools.length}`);
68
- config.tools.forEach(tool => {
69
- console.log(` - ${tool.name}: ${tool.description}`);
70
- });
71
-
72
- console.log('\nāœ… All validations passed! Recoder Code is ready to use.');
73
- console.log('\nšŸš€ Try it out:');
74
- console.log(' recoder "Create a simple hello world script"');
75
- }
76
-
77
- if (require.main === module) {
78
- validateConfiguration().catch(console.error);
79
- }
80
-
81
- module.exports = { validateConfiguration };