@kokorolx/ai-sandbox-wrapper 1.0.0
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 +540 -0
- package/bin/ai-debug +116 -0
- package/bin/ai-network +144 -0
- package/bin/ai-run +631 -0
- package/bin/cli.js +83 -0
- package/bin/setup-ssh-config +328 -0
- package/dockerfiles/AGENTS.md +92 -0
- package/dockerfiles/aider/Dockerfile +5 -0
- package/dockerfiles/amp/Dockerfile +10 -0
- package/dockerfiles/auggie/Dockerfile +12 -0
- package/dockerfiles/base/Dockerfile +73 -0
- package/dockerfiles/claude/Dockerfile +11 -0
- package/dockerfiles/codebuddy/Dockerfile +12 -0
- package/dockerfiles/codex/Dockerfile +9 -0
- package/dockerfiles/droid/Dockerfile +8 -0
- package/dockerfiles/gemini/Dockerfile +9 -0
- package/dockerfiles/jules/Dockerfile +12 -0
- package/dockerfiles/kilo/Dockerfile +25 -0
- package/dockerfiles/opencode/Dockerfile +10 -0
- package/dockerfiles/qoder/Dockerfile +12 -0
- package/dockerfiles/qwen/Dockerfile +10 -0
- package/dockerfiles/shai/Dockerfile +9 -0
- package/lib/AGENTS.md +58 -0
- package/lib/generate-ai-run.sh +19 -0
- package/lib/install-aider.sh +30 -0
- package/lib/install-amp.sh +39 -0
- package/lib/install-auggie.sh +36 -0
- package/lib/install-base.sh +139 -0
- package/lib/install-claude.sh +42 -0
- package/lib/install-codebuddy.sh +36 -0
- package/lib/install-codeserver.sh +171 -0
- package/lib/install-codex.sh +40 -0
- package/lib/install-droid.sh +27 -0
- package/lib/install-gemini.sh +39 -0
- package/lib/install-jules.sh +36 -0
- package/lib/install-kilo.sh +57 -0
- package/lib/install-opencode.sh +39 -0
- package/lib/install-qoder.sh +37 -0
- package/lib/install-qwen.sh +40 -0
- package/lib/install-shai.sh +33 -0
- package/lib/install-tool.sh +40 -0
- package/lib/install-vscode.sh +219 -0
- package/lib/ssh-key-selector.sh +189 -0
- package/package.json +46 -0
- package/setup.sh +530 -0
package/README.md
ADDED
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
# 🔒 AI Sandbox Wrapper
|
|
2
|
+
|
|
3
|
+
**Isolate AI coding agents from your host system. Protect your data.**
|
|
4
|
+
|
|
5
|
+
AI coding tools like Claude, Gemini, and Aider have full access to your filesystem, environment variables, and terminal. This project sandboxes them in Docker containers with **strict security restrictions**.
|
|
6
|
+
|
|
7
|
+
**What this does:** Runs AI tools in secure containers that can only access specific project folders, protecting your SSH keys, API tokens, and other sensitive data.
|
|
8
|
+
|
|
9
|
+
**What you get:** Peace of mind using AI coding tools without risking your personal and system data.
|
|
10
|
+
|
|
11
|
+
*Last updated: Thursday, January 22, 2026*
|
|
12
|
+
|
|
13
|
+
## 🛡️ Why Use This?
|
|
14
|
+
|
|
15
|
+
Without sandbox:
|
|
16
|
+
- AI agents can read your SSH keys, API tokens, browser data
|
|
17
|
+
- Can execute arbitrary code with your user permissions
|
|
18
|
+
- Can access files outside your project
|
|
19
|
+
|
|
20
|
+
With AI Sandbox:
|
|
21
|
+
- ✅ AI only sees whitelisted workspace folders
|
|
22
|
+
- ✅ No access to host environment variables (API keys hidden)
|
|
23
|
+
- ✅ Read-only filesystem (except workspace)
|
|
24
|
+
- ✅ No network access to host services
|
|
25
|
+
- ✅ Runs as non-root user in container
|
|
26
|
+
- ✅ CAP_DROP=ALL (no elevated privileges)
|
|
27
|
+
|
|
28
|
+
## 🚀 Step-by-Step Installation
|
|
29
|
+
|
|
30
|
+
### Step 1: Prerequisites
|
|
31
|
+
Ensure you have Docker installed and running:
|
|
32
|
+
- **macOS:** [Install Docker Desktop](https://www.docker.com/products/docker-desktop) and start it
|
|
33
|
+
- **Linux:** Install Docker Engine with `curl -fsSL https://get.docker.com | sh`
|
|
34
|
+
- **Windows:** Use WSL2 with Docker Desktop
|
|
35
|
+
|
|
36
|
+
Verify Docker is working:
|
|
37
|
+
```bash
|
|
38
|
+
docker --version
|
|
39
|
+
docker ps # Should not show errors
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Step 2: Run Setup
|
|
43
|
+
|
|
44
|
+
**Option A: Using npx (Recommended)**
|
|
45
|
+
```bash
|
|
46
|
+
npx @kokorolx/ai-sandbox-wrapper setup
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Option B: Clone and run manually**
|
|
50
|
+
```bash
|
|
51
|
+
git clone https://github.com/kokorolx/ai-sandbox-wrapper.git
|
|
52
|
+
cd ai-sandbox-wrapper
|
|
53
|
+
./setup.sh
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Step 3: Follow the Interactive Prompts
|
|
57
|
+
1. **Whitelist workspaces** - Enter the directories where you want AI tools to access (e.g., `~/projects,~/code`)
|
|
58
|
+
2. **Select tools** - Use arrow keys to move, space to select, Enter to confirm
|
|
59
|
+
3. **Choose image source** - Select registry (faster) or build locally
|
|
60
|
+
|
|
61
|
+
### Step 4: Complete Setup
|
|
62
|
+
```bash
|
|
63
|
+
# Reload your shell to update PATH
|
|
64
|
+
source ~/.zshrc
|
|
65
|
+
|
|
66
|
+
# Add your API keys (only if using tools that require them)
|
|
67
|
+
nano ~/.ai-env # Add ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Step 5: Run Your First Tool
|
|
71
|
+
```bash
|
|
72
|
+
# Navigate to a project directory that's in your whitelisted workspaces
|
|
73
|
+
cd ~/projects/my-project
|
|
74
|
+
|
|
75
|
+
# Run a tool (the example below assumes you selected Claude during setup)
|
|
76
|
+
claude --version # or: ai-run claude --version
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 📋 What You Need
|
|
80
|
+
|
|
81
|
+
**Required:**
|
|
82
|
+
- **Docker** - Docker Desktop (macOS/Windows) or Docker Engine (Linux)
|
|
83
|
+
- **Git** - For cloning the repository
|
|
84
|
+
- **Bash** - For running the setup script
|
|
85
|
+
|
|
86
|
+
**Optional (for specific tools):**
|
|
87
|
+
- **Python 3** - For tools like Aider
|
|
88
|
+
- **SSH keys** - For Git access in containers
|
|
89
|
+
|
|
90
|
+
## ✅ After Installation
|
|
91
|
+
|
|
92
|
+
### Verify Everything Works
|
|
93
|
+
```bash
|
|
94
|
+
# Reload your shell to get the new commands
|
|
95
|
+
source ~/.zshrc
|
|
96
|
+
|
|
97
|
+
# Check if the main command works
|
|
98
|
+
ai-run --help
|
|
99
|
+
|
|
100
|
+
# Test a tool you installed (replace 'claude' with your chosen tool)
|
|
101
|
+
claude --version
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Add More Projects Later (Optional)
|
|
105
|
+
If you want to give AI access to more project directories later:
|
|
106
|
+
```bash
|
|
107
|
+
# Add a new workspace
|
|
108
|
+
echo '/path/to/new/project' >> ~/.ai-workspaces
|
|
109
|
+
|
|
110
|
+
# View current allowed directories
|
|
111
|
+
cat ~/.ai-workspaces
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Configure API Keys (If Needed)
|
|
115
|
+
Some tools require API keys to work properly:
|
|
116
|
+
```bash
|
|
117
|
+
nano ~/.ai-env
|
|
118
|
+
```
|
|
119
|
+
Then add your keys in the format: `KEY_NAME=your_actual_key_here`
|
|
120
|
+
Examples:
|
|
121
|
+
- `ANTHROPIC_API_KEY=your_key_here` (for Claude)
|
|
122
|
+
- `OPENAI_API_KEY=your_key_here` (for OpenAI tools)
|
|
123
|
+
|
|
124
|
+
## 🐳 Using Pre-Built Images
|
|
125
|
+
|
|
126
|
+
**Skip the build process!** Pull pre-built images directly from GitLab Container Registry:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Pull a specific tool image
|
|
130
|
+
docker pull registry.gitlab.com/kokorolee/ai-sandbox-wrapper/ai-claude:latest
|
|
131
|
+
docker pull registry.gitlab.com/kokorolee/ai-sandbox-wrapper/ai-gemini:latest
|
|
132
|
+
docker pull registry.gitlab.com/kokorolee/ai-sandbox-wrapper/ai-aider:latest
|
|
133
|
+
|
|
134
|
+
# Or let setup.sh pull them automatically
|
|
135
|
+
./setup.sh # Select tools, images will be pulled if available
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Available pre-built images:**
|
|
139
|
+
- `ai-base:latest` - Base image with Bun runtime
|
|
140
|
+
- `ai-amp:latest` - Sourcegraph Amp
|
|
141
|
+
- `ai-claude:latest` - Claude Code CLI
|
|
142
|
+
- `ai-droid:latest` - Factory CLI
|
|
143
|
+
- `ai-gemini:latest` - Google Gemini CLI
|
|
144
|
+
- `ai-kilo:latest` - Kilo Code (500+ models)
|
|
145
|
+
- `ai-codex:latest` - OpenAI Codex
|
|
146
|
+
- `ai-aider:latest` - AI pair programmer
|
|
147
|
+
- `ai-opencode:latest` - Open-source AI coding
|
|
148
|
+
- `ai-qwen:latest` - Alibaba Qwen (1M context)
|
|
149
|
+
- `ai-qoder:latest` - Qoder AI assistant
|
|
150
|
+
- `ai-auggie:latest` - Augment Auggie
|
|
151
|
+
- `ai-codebuddy:latest` - Tencent CodeBuddy
|
|
152
|
+
- `ai-jules:latest` - Google Jules
|
|
153
|
+
- `ai-shai:latest` - OVHcloud SHAI
|
|
154
|
+
|
|
155
|
+
**Benefits:**
|
|
156
|
+
- ⚡ **Faster setup** - No build time (seconds vs minutes)
|
|
157
|
+
- ✅ **CI-tested** - All images verified in GitLab CI
|
|
158
|
+
- 🔄 **Auto-updated** - Latest versions on every push to beta branch
|
|
159
|
+
|
|
160
|
+
## 📦 Supported Tools
|
|
161
|
+
|
|
162
|
+
### CLI Tools (Terminal-based)
|
|
163
|
+
|
|
164
|
+
| Tool | Status | Install Type | Description |
|
|
165
|
+
|------|--------|--------------|-------------|
|
|
166
|
+
| **claude** | ✅ | Native binary | Anthropic Claude Code |
|
|
167
|
+
| **opencode** | ✅ | Native Go | Open-source AI coding |
|
|
168
|
+
| **gemini** | ✅ | npm/Bun | Google Gemini CLI (free tier) |
|
|
169
|
+
| **aider** | ✅ | Python | AI pair programmer (Git-native) |
|
|
170
|
+
| **kilo** | ✅ | npm/Bun | Kilo Code (500+ models) |
|
|
171
|
+
| **codex** | ✅ | npm/Bun | OpenAI Codex agent |
|
|
172
|
+
| **amp** | ✅ | npm/Bun | Sourcegraph Amp |
|
|
173
|
+
| **qwen** | ✅ | npm/Bun | Alibaba Qwen CLI (1M context) |
|
|
174
|
+
| **droid** | ✅ | Custom | Factory CLI |
|
|
175
|
+
|
|
176
|
+
### GUI Tools (IDE/Editor)
|
|
177
|
+
|
|
178
|
+
| Tool | Status | Description |
|
|
179
|
+
|------|--------|-------------|
|
|
180
|
+
| **codeserver** | ✅ | VSCode in browser (localhost:8080) |
|
|
181
|
+
| **vscode** | ⚠️ Experimental | VSCode Desktop via X11 |
|
|
182
|
+
| **cursor** | 🔜 Planned | Cursor IDE sandbox |
|
|
183
|
+
| **antigravity** | 🔜 Planned | Antigravity IDE sandbox |
|
|
184
|
+
|
|
185
|
+
## 🖥️ Platform Support
|
|
186
|
+
|
|
187
|
+
| Platform | Status |
|
|
188
|
+
|----------|--------|
|
|
189
|
+
| macOS (Intel) | ✅ |
|
|
190
|
+
| macOS (Apple Silicon) | ✅ |
|
|
191
|
+
| Linux (x64) | ✅ |
|
|
192
|
+
| Linux (ARM64) | ✅ |
|
|
193
|
+
| Windows (Docker Desktop + WSL2) | ✅ |
|
|
194
|
+
|
|
195
|
+
## 📁 Directory Structure
|
|
196
|
+
|
|
197
|
+
AI Sandbox Wrapper creates and manages the following directories in your home folder:
|
|
198
|
+
|
|
199
|
+
| Directory | Purpose | Contents |
|
|
200
|
+
|-----------|---------|----------|
|
|
201
|
+
| `~/bin/` | Executables | `ai-run` wrapper and symlinks to tool scripts |
|
|
202
|
+
| `~/.ai-env` | API keys | Environment variables passed to containers (API keys) |
|
|
203
|
+
| `~/.ai-workspaces` | Security | List of whitelisted directories AI can access |
|
|
204
|
+
| `~/.ai-git-allowed` | Security | Workspaces where Git credentials are allowed |
|
|
205
|
+
| `~/.ai-cache/` | Caching | Tool-specific cache directories (e.g., `~/.ai-cache/claude/`) |
|
|
206
|
+
| `~/.ai-home/` | Config | Tool home directories with persistent configs |
|
|
207
|
+
| `~/.ai-images/` | Local images | Locally built Docker images (if not using registry) |
|
|
208
|
+
|
|
209
|
+
### Key Files
|
|
210
|
+
|
|
211
|
+
| File | Purpose |
|
|
212
|
+
|------|---------|
|
|
213
|
+
| `~/.ai-env` | API keys (format: `KEY=value`, one per line) |
|
|
214
|
+
| `~/.ai-git-allowed` | Workspaces with persistent Git access (one path per line) |
|
|
215
|
+
| `~/.ai-git-keys-*` | Saved SSH key selections for each workspace (md5-hashed) |
|
|
216
|
+
|
|
217
|
+
### Cache Structure
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
~/.ai-cache/
|
|
221
|
+
├── claude/ # Claude Code cache
|
|
222
|
+
├── gemini/ # Gemini CLI cache
|
|
223
|
+
├── aider/ # Aider cache
|
|
224
|
+
├── git/ # Git credentials cache (when enabled)
|
|
225
|
+
│ └── ssh/ # SSH keys and config for allowed workspace
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Home Structure
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
~/.ai-home/
|
|
232
|
+
├── claude/ # .claude.json and settings
|
|
233
|
+
├── gemini/ # Gemini configuration
|
|
234
|
+
├── aider/ # Aider config and history
|
|
235
|
+
└── .gitconfig # Git configuration (when Git access enabled)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## ⚙️ Configuration
|
|
239
|
+
|
|
240
|
+
### API Keys
|
|
241
|
+
```bash
|
|
242
|
+
# Edit environment file
|
|
243
|
+
nano ~/.ai-env
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Workspace Management
|
|
247
|
+
```bash
|
|
248
|
+
# Add workspace
|
|
249
|
+
echo '/path/to/project' >> ~/.ai-workspaces
|
|
250
|
+
|
|
251
|
+
# List workspaces
|
|
252
|
+
cat ~/.ai-workspaces
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Environment Variables
|
|
256
|
+
|
|
257
|
+
All environment variables are configured in `~/.ai-env` or passed at runtime:
|
|
258
|
+
|
|
259
|
+
#### Image Source
|
|
260
|
+
Choose between locally built images or pre-built GitLab registry images:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Add to ~/.ai-env
|
|
264
|
+
|
|
265
|
+
# Use locally built images (default)
|
|
266
|
+
AI_IMAGE_SOURCE=local
|
|
267
|
+
|
|
268
|
+
# Use pre-built images from GitLab registry
|
|
269
|
+
AI_IMAGE_SOURCE=registry
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Or run with environment variable:
|
|
273
|
+
```bash
|
|
274
|
+
AI_IMAGE_SOURCE=registry ai-run claude
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
#### Platform Selection
|
|
278
|
+
For ARM64 Macs or other platforms, specify the container platform:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
# Run with specific platform (linux/arm64, linux/amd64)
|
|
282
|
+
AI_RUN_PLATFORM=linux/arm64 ai-run claude
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
#### Docker Connection
|
|
286
|
+
For remote Docker hosts or non-default configurations:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Use a different Docker socket
|
|
290
|
+
export DOCKER_HOST=unix:///var/run/docker.sock
|
|
291
|
+
|
|
292
|
+
# Or TCP connection
|
|
293
|
+
export DOCKER_HOST=tcp://localhost:2375
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### API Keys
|
|
297
|
+
Configure in `~/.ai-env`:
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Required for Claude tools
|
|
301
|
+
ANTHROPIC_API_KEY=sk-ant-api03-...
|
|
302
|
+
|
|
303
|
+
# Required for OpenAI-based tools
|
|
304
|
+
OPENAI_API_KEY=sk-...
|
|
305
|
+
|
|
306
|
+
# Optional for Gemini CLI
|
|
307
|
+
GOOGLE_API_KEY=AIza...
|
|
308
|
+
|
|
309
|
+
# Optional: disable specific keys
|
|
310
|
+
# ANTHROPIC_API_KEY=
|
|
311
|
+
# OPENAI_API_KEY=
|
|
312
|
+
|
|
313
|
+
### Per-Project Config
|
|
314
|
+
|
|
315
|
+
Each tool supports project-specific config files that override global settings:
|
|
316
|
+
|
|
317
|
+
| Tool | Project Config | Global Config Location |
|
|
318
|
+
|------|----------------|------------------------|
|
|
319
|
+
| Claude | `.claude.json` | `~/.claude/` |
|
|
320
|
+
| Gemini | `.gemini.json` | `~/.config/gemini/` |
|
|
321
|
+
| Aider | `.aider.conf` | `~/.config/aider/` |
|
|
322
|
+
| Opencode | `.opencode.json` | `~/.config/opencode/` |
|
|
323
|
+
| Kilo | `.kilo.json` | `~/.config/kilo/` |
|
|
324
|
+
| Codex | `.codex.json` | `~/.config/codex/` |
|
|
325
|
+
| Amp | `.amp.json` | `~/.config/amp/` |
|
|
326
|
+
|
|
327
|
+
**Priority:** Project config > Global config > Container defaults
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
# Example: Project-specific Claude config
|
|
331
|
+
cat > .claude.json << 'EOF'
|
|
332
|
+
{
|
|
333
|
+
"model": "sonnet-4-20250514",
|
|
334
|
+
"max_output_tokens": 8192,
|
|
335
|
+
"temperature": 0.7
|
|
336
|
+
}
|
|
337
|
+
EOF
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Tool-Specific Config Locations
|
|
341
|
+
|
|
342
|
+
When using global configs (not project-specific), they're stored in:
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
~/.ai-home/{tool}/
|
|
346
|
+
├── .config/ # Tool configuration
|
|
347
|
+
│ └── {tool}/ # Per-tool config directory
|
|
348
|
+
├── .local/share/ # Tool data (cache, sessions)
|
|
349
|
+
└── .cache/ # Runtime cache
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Each tool's config is mounted to `/home/agent/` inside the container.
|
|
353
|
+
|
|
354
|
+
### Additional Tools (Container-Only)
|
|
355
|
+
|
|
356
|
+
During setup, you can optionally install additional tools into the base Docker image:
|
|
357
|
+
|
|
358
|
+
| Tool | Description | Size Impact |
|
|
359
|
+
|------|-------------|-------------|
|
|
360
|
+
| spec-kit | Spec-driven development toolkit | ~50MB |
|
|
361
|
+
| ux-ui-promax | UI/UX design intelligence tool | ~30MB |
|
|
362
|
+
| openspec | OpenSpec - spec-driven development | ~20MB |
|
|
363
|
+
| playwright | Browser automation with Chromium/Firefox/WebKit | ~500MB |
|
|
364
|
+
|
|
365
|
+
**Always Installed (for LSP support):**
|
|
366
|
+
- `typescript` + `typescript-language-server` - Required for AI coding assistants with LSP integration
|
|
367
|
+
|
|
368
|
+
**Playwright** is useful when AI tools need to:
|
|
369
|
+
- Run browser-based tests
|
|
370
|
+
- Scrape web content
|
|
371
|
+
- Verify UI changes
|
|
372
|
+
- Automate browser workflows
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
# Manual build with Playwright (if not selected during setup)
|
|
376
|
+
INSTALL_PLAYWRIGHT=1 bash lib/install-base.sh
|
|
377
|
+
|
|
378
|
+
# Verify Playwright in container
|
|
379
|
+
docker run --rm ai-base:latest npx playwright --version
|
|
380
|
+
|
|
381
|
+
# Verify TypeScript LSP
|
|
382
|
+
docker run --rm ai-base:latest tsc --version
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Git Workflow
|
|
386
|
+
AI tools work **inside** containers without Git credentials by default (secure).
|
|
387
|
+
|
|
388
|
+
**Option 1: Secure (Default) - Review & Commit from Host**
|
|
389
|
+
```bash
|
|
390
|
+
# 1. AI tool makes changes
|
|
391
|
+
ai-run claude # Edits files in your workspace
|
|
392
|
+
|
|
393
|
+
# 2. Review changes on host
|
|
394
|
+
git diff
|
|
395
|
+
|
|
396
|
+
# 3. Commit from host (you have full control)
|
|
397
|
+
git add .
|
|
398
|
+
git commit -m "feat: changes suggested by AI"
|
|
399
|
+
git push
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
**Option 2: Enable Git Access (Interactive Prompt)**
|
|
403
|
+
When you run an AI tool, you'll be prompted:
|
|
404
|
+
```
|
|
405
|
+
🔐 Git Access Control
|
|
406
|
+
Allow AI tool to access Git credentials for this workspace?
|
|
407
|
+
|
|
408
|
+
1) Yes, allow once (this session only)
|
|
409
|
+
2) Yes, always allow for this workspace
|
|
410
|
+
3) No, keep Git disabled (secure default)
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
**Managing Git access:**
|
|
414
|
+
```bash
|
|
415
|
+
# View allowed workspaces
|
|
416
|
+
cat ~/.ai-git-allowed
|
|
417
|
+
|
|
418
|
+
# Remove a workspace from allowed list
|
|
419
|
+
nano ~/.ai-git-allowed # Delete the line
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
**Why this is secure:**
|
|
423
|
+
- ✅ Opt-in per workspace (not global)
|
|
424
|
+
- ✅ Granular control: Only selected keys and their matching Host configs are shared
|
|
425
|
+
- ✅ SSH keys mounted read-only
|
|
426
|
+
- ✅ You control which projects get Git access
|
|
427
|
+
- ✅ Easy to revoke access anytime
|
|
428
|
+
|
|
429
|
+
## 🔐 Security Model
|
|
430
|
+
|
|
431
|
+
```
|
|
432
|
+
┌─────────────────────────────────────────────────┐
|
|
433
|
+
│ HOST SYSTEM │
|
|
434
|
+
│ ❌ SSH keys, API tokens, browser data │
|
|
435
|
+
│ ❌ Home directory, system files │
|
|
436
|
+
│ ❌ Other projects │
|
|
437
|
+
└─────────────────────────────────────────────────┘
|
|
438
|
+
│
|
|
439
|
+
Docker isolation
|
|
440
|
+
│
|
|
441
|
+
┌─────────────────────────────────────────────────┐
|
|
442
|
+
│ AI SANDBOX CONTAINER │
|
|
443
|
+
│ ✅ /workspace (whitelisted folders only) │
|
|
444
|
+
│ ✅ Passed API keys (explicit, for API calls) │
|
|
445
|
+
│ ✅ Git config (for commits) │
|
|
446
|
+
│ ❌ Everything else │
|
|
447
|
+
└─────────────────────────────────────────────────┘
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
## ❓ Troubleshooting
|
|
451
|
+
|
|
452
|
+
### Common Issues
|
|
453
|
+
|
|
454
|
+
**Docker not found**
|
|
455
|
+
- Make sure Docker Desktop is installed and running
|
|
456
|
+
- Check with: `docker --version` and `docker ps`
|
|
457
|
+
|
|
458
|
+
**"command not found: ai-run"**
|
|
459
|
+
- Reload your shell: `source ~/.zshrc`
|
|
460
|
+
- Verify setup completed: check if `~/bin/ai-run` exists
|
|
461
|
+
|
|
462
|
+
**"Workspaces not configured"**
|
|
463
|
+
- Run setup again: `./setup.sh`
|
|
464
|
+
- Make sure you entered workspace directories during setup
|
|
465
|
+
|
|
466
|
+
**Tool doesn't start**
|
|
467
|
+
- Check if you selected the tool during setup
|
|
468
|
+
- Look for the Docker image: `docker images | grep ai-`
|
|
469
|
+
|
|
470
|
+
**"Outside whitelisted workspace" error**
|
|
471
|
+
- Add your current directory: `echo "$(pwd)" >> ~/.ai-workspaces`
|
|
472
|
+
- Or navigate to a directory you whitelisted during setup
|
|
473
|
+
|
|
474
|
+
**API key errors**
|
|
475
|
+
- Check your keys in: `cat ~/.ai-env`
|
|
476
|
+
- Make sure keys are in format: `KEY_NAME=actual_key_value`
|
|
477
|
+
|
|
478
|
+
### Getting Help
|
|
479
|
+
|
|
480
|
+
If you're still having issues:
|
|
481
|
+
1. Check that Docker is running
|
|
482
|
+
2. Re-run `./setup.sh` to reinstall
|
|
483
|
+
3. Look at the configuration files in your home directory:
|
|
484
|
+
- `~/.ai-workspaces` - should contain your project directories
|
|
485
|
+
- `~/.ai-env` - should contain your API keys (if needed)
|
|
486
|
+
4. View Docker images: `docker images` to see if tools built successfully
|
|
487
|
+
|
|
488
|
+
## 📚 Quick Reference
|
|
489
|
+
|
|
490
|
+
### Main Commands
|
|
491
|
+
- `ai-run <tool>` - Run any tool in sandbox (e.g., `ai-run claude`)
|
|
492
|
+
- `ai-run <tool> --shell` - Start interactive shell mode (see [Shell Mode Guide](SHELL-MODE-USAGE.md))
|
|
493
|
+
- `<tool>` - Shortcut for tools you installed (e.g., `claude`, `aider`)
|
|
494
|
+
|
|
495
|
+
### Execution Modes
|
|
496
|
+
|
|
497
|
+
**Direct Mode (Default):**
|
|
498
|
+
```bash
|
|
499
|
+
ai-run opencode
|
|
500
|
+
# Tool runs directly, exits on Ctrl+C
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
**Shell Mode (Interactive):**
|
|
504
|
+
```bash
|
|
505
|
+
ai-run opencode --shell # or -s
|
|
506
|
+
# Starts bash shell, run tool manually
|
|
507
|
+
# Ctrl+C stops tool only, not container
|
|
508
|
+
# Perfect for development and debugging
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
See [SHELL-MODE-USAGE.md](SHELL-MODE-USAGE.md) for detailed examples and use cases.
|
|
512
|
+
|
|
513
|
+
### Configuration Files
|
|
514
|
+
- `~/.ai-env` - Store API keys here
|
|
515
|
+
- `~/.ai-workspaces` - Whitelisted project directories
|
|
516
|
+
- `~/.ai-cache/` - Tool cache (persistent)
|
|
517
|
+
- `~/.ai-home/` - Tool configurations (persistent)
|
|
518
|
+
|
|
519
|
+
### Common Tasks
|
|
520
|
+
```bash
|
|
521
|
+
# Add a new project directory to AI access
|
|
522
|
+
echo '/path/to/my/new/project' >> ~/.ai-workspaces
|
|
523
|
+
|
|
524
|
+
# Check what tools are installed
|
|
525
|
+
ls ~/bin/
|
|
526
|
+
|
|
527
|
+
# Reload shell after setup
|
|
528
|
+
source ~/.zshrc
|
|
529
|
+
|
|
530
|
+
# Update to latest version
|
|
531
|
+
npx @kokorolx/ai-sandbox-wrapper@latest setup
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
## 🤝 Contributing
|
|
535
|
+
|
|
536
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
537
|
+
|
|
538
|
+
## 📝 License
|
|
539
|
+
|
|
540
|
+
MIT
|
package/bin/ai-debug
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# AI Sandbox Wrapper - Diagnostic Tool
|
|
3
|
+
|
|
4
|
+
echo "🔍 AI Sandbox Wrapper - Diagnostic Information"
|
|
5
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
6
|
+
echo ""
|
|
7
|
+
|
|
8
|
+
# System info
|
|
9
|
+
echo "📋 System Information:"
|
|
10
|
+
echo " OS: $(uname -s)"
|
|
11
|
+
echo " Architecture: $(uname -m)"
|
|
12
|
+
echo " Kernel: $(uname -r)"
|
|
13
|
+
echo ""
|
|
14
|
+
|
|
15
|
+
# Docker info
|
|
16
|
+
echo "🐳 Docker Information:"
|
|
17
|
+
if command -v docker &> /dev/null; then
|
|
18
|
+
echo " Docker: $(docker --version)"
|
|
19
|
+
echo " Docker running: $(docker ps &>/dev/null && echo "✅ Yes" || echo "❌ No")"
|
|
20
|
+
|
|
21
|
+
# Check platform support
|
|
22
|
+
if docker buildx version &>/dev/null; then
|
|
23
|
+
echo " Buildx available: ✅ Yes"
|
|
24
|
+
else
|
|
25
|
+
echo " Buildx available: ❌ No"
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# Show running AI containers
|
|
29
|
+
AI_CONTAINERS=$(docker ps --filter "name=opencode-" --filter "name=claude-" --filter "name=gemini-" --filter "name=aider-" --format "{{.Names}}" 2>/dev/null | wc -l)
|
|
30
|
+
echo " Running AI containers: $AI_CONTAINERS"
|
|
31
|
+
if [ "$AI_CONTAINERS" -gt 0 ]; then
|
|
32
|
+
docker ps --filter "name=opencode-" --filter "name=claude-" --filter "name=gemini-" --filter "name=aider-" --format " - {{.Names}} ({{.Status}})"
|
|
33
|
+
fi
|
|
34
|
+
else
|
|
35
|
+
echo " Docker: ❌ Not installed or not in PATH"
|
|
36
|
+
fi
|
|
37
|
+
echo ""
|
|
38
|
+
|
|
39
|
+
# Terminal info
|
|
40
|
+
echo "🖥️ Terminal Information:"
|
|
41
|
+
echo " TERM: ${TERM:-not set}"
|
|
42
|
+
echo " COLORTERM: ${COLORTERM:-not set}"
|
|
43
|
+
echo " Terminal size: $(tput cols 2>/dev/null || echo "unknown") x $(tput lines 2>/dev/null || echo "unknown")"
|
|
44
|
+
echo " TTY: $(tty 2>/dev/null || echo "not a tty")"
|
|
45
|
+
echo " Interactive: $([[ -t 0 ]] && echo "✅ Yes" || echo "❌ No")"
|
|
46
|
+
echo ""
|
|
47
|
+
|
|
48
|
+
# Configuration files
|
|
49
|
+
echo "📁 Configuration Files:"
|
|
50
|
+
echo " Workspaces file: $([ -f "$HOME/.ai-workspaces" ] && echo "✅ Exists" || echo "❌ Missing")"
|
|
51
|
+
if [ -f "$HOME/.ai-workspaces" ]; then
|
|
52
|
+
echo " $(wc -l < "$HOME/.ai-workspaces") workspace(s) configured"
|
|
53
|
+
fi
|
|
54
|
+
echo " Env file: $([ -f "$HOME/.ai-env" ] && echo "✅ Exists" || echo "❌ Missing")"
|
|
55
|
+
if [ -f "$HOME/.ai-env" ]; then
|
|
56
|
+
echo " $(grep -c "=" "$HOME/.ai-env" 2>/dev/null || echo 0) variable(s) configured"
|
|
57
|
+
fi
|
|
58
|
+
echo " Git allowed: $([ -f "$HOME/.ai-git-allowed" ] && echo "✅ Exists" || echo "❌ Missing")"
|
|
59
|
+
if [ -f "$HOME/.ai-git-allowed" ]; then
|
|
60
|
+
echo " $(wc -l < "$HOME/.ai-git-allowed") workspace(s) with Git access"
|
|
61
|
+
fi
|
|
62
|
+
echo " Networks file: $([ -f "$HOME/.ai-networks" ] && echo "✅ Exists" || echo "❌ Missing")"
|
|
63
|
+
if [ -f "$HOME/.ai-networks" ]; then
|
|
64
|
+
echo " $(wc -l < "$HOME/.ai-networks") network(s) configured"
|
|
65
|
+
fi
|
|
66
|
+
echo ""
|
|
67
|
+
|
|
68
|
+
# AI Images
|
|
69
|
+
echo "🎨 AI Tool Images:"
|
|
70
|
+
AI_IMAGES=$(docker images --filter "reference=ai-*" --format "{{.Repository}}" 2>/dev/null | wc -l)
|
|
71
|
+
echo " Found $AI_IMAGES AI tool image(s)"
|
|
72
|
+
if [ "$AI_IMAGES" -gt 0 ]; then
|
|
73
|
+
docker images --filter "reference=ai-*" --format " - {{.Repository}}:{{.Tag}} ({{.Size}})"
|
|
74
|
+
fi
|
|
75
|
+
echo ""
|
|
76
|
+
|
|
77
|
+
# Performance check
|
|
78
|
+
echo "⚡ Performance Indicators:"
|
|
79
|
+
# Check if Rosetta is being used (macOS ARM running x86 images)
|
|
80
|
+
if [[ "$(uname -s)" == "Darwin" ]] && [[ "$(uname -m)" == "arm64" ]]; then
|
|
81
|
+
echo " Platform: Apple Silicon (ARM64)"
|
|
82
|
+
X86_IMAGES=$(docker images --filter "reference=ai-*" --format "{{.Repository}}" --filter "label=architecture=amd64" 2>/dev/null | wc -l)
|
|
83
|
+
if [ "$X86_IMAGES" -gt 0 ]; then
|
|
84
|
+
echo " ⚠️ Warning: x86_64 images detected (may run slow via Rosetta)"
|
|
85
|
+
echo " Consider rebuilding images for ARM64"
|
|
86
|
+
fi
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
# Check volume mount performance
|
|
90
|
+
if [[ "$(uname -s)" == "Darwin" ]]; then
|
|
91
|
+
echo " Volume mount type: $(docker info --format '{{.Driver}}' 2>/dev/null || echo "unknown")"
|
|
92
|
+
echo " 💡 Tip: Use 'delegated' mount mode for better performance (already configured)"
|
|
93
|
+
fi
|
|
94
|
+
echo ""
|
|
95
|
+
|
|
96
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
97
|
+
echo ""
|
|
98
|
+
echo "💡 Common Issues & Solutions:"
|
|
99
|
+
echo ""
|
|
100
|
+
echo "1. Slow startup or missing UI:"
|
|
101
|
+
echo " - Check architecture: Images should match your CPU (ARM64 or x86_64)"
|
|
102
|
+
echo " - Rebuild images: ./setup.sh (select tools to rebuild)"
|
|
103
|
+
echo " - Use shell mode: ai-run opencode --shell (better for TUI apps)"
|
|
104
|
+
echo ""
|
|
105
|
+
echo "2. 'Container name already in use':"
|
|
106
|
+
echo " - List containers: docker ps -a"
|
|
107
|
+
echo " - Remove old containers: docker rm -f <container-name>"
|
|
108
|
+
echo ""
|
|
109
|
+
echo "3. Terminal rendering issues:"
|
|
110
|
+
echo " - Set TERM: export TERM=xterm-256color"
|
|
111
|
+
echo " - Resize terminal and retry"
|
|
112
|
+
echo ""
|
|
113
|
+
echo "4. Tool not responding:"
|
|
114
|
+
echo " - Enable debug: AI_RUN_DEBUG=1 ai-run <tool>"
|
|
115
|
+
echo " - Check logs: docker logs <container-name>"
|
|
116
|
+
echo ""
|