@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.
Files changed (45) hide show
  1. package/README.md +540 -0
  2. package/bin/ai-debug +116 -0
  3. package/bin/ai-network +144 -0
  4. package/bin/ai-run +631 -0
  5. package/bin/cli.js +83 -0
  6. package/bin/setup-ssh-config +328 -0
  7. package/dockerfiles/AGENTS.md +92 -0
  8. package/dockerfiles/aider/Dockerfile +5 -0
  9. package/dockerfiles/amp/Dockerfile +10 -0
  10. package/dockerfiles/auggie/Dockerfile +12 -0
  11. package/dockerfiles/base/Dockerfile +73 -0
  12. package/dockerfiles/claude/Dockerfile +11 -0
  13. package/dockerfiles/codebuddy/Dockerfile +12 -0
  14. package/dockerfiles/codex/Dockerfile +9 -0
  15. package/dockerfiles/droid/Dockerfile +8 -0
  16. package/dockerfiles/gemini/Dockerfile +9 -0
  17. package/dockerfiles/jules/Dockerfile +12 -0
  18. package/dockerfiles/kilo/Dockerfile +25 -0
  19. package/dockerfiles/opencode/Dockerfile +10 -0
  20. package/dockerfiles/qoder/Dockerfile +12 -0
  21. package/dockerfiles/qwen/Dockerfile +10 -0
  22. package/dockerfiles/shai/Dockerfile +9 -0
  23. package/lib/AGENTS.md +58 -0
  24. package/lib/generate-ai-run.sh +19 -0
  25. package/lib/install-aider.sh +30 -0
  26. package/lib/install-amp.sh +39 -0
  27. package/lib/install-auggie.sh +36 -0
  28. package/lib/install-base.sh +139 -0
  29. package/lib/install-claude.sh +42 -0
  30. package/lib/install-codebuddy.sh +36 -0
  31. package/lib/install-codeserver.sh +171 -0
  32. package/lib/install-codex.sh +40 -0
  33. package/lib/install-droid.sh +27 -0
  34. package/lib/install-gemini.sh +39 -0
  35. package/lib/install-jules.sh +36 -0
  36. package/lib/install-kilo.sh +57 -0
  37. package/lib/install-opencode.sh +39 -0
  38. package/lib/install-qoder.sh +37 -0
  39. package/lib/install-qwen.sh +40 -0
  40. package/lib/install-shai.sh +33 -0
  41. package/lib/install-tool.sh +40 -0
  42. package/lib/install-vscode.sh +219 -0
  43. package/lib/ssh-key-selector.sh +189 -0
  44. package/package.json +46 -0
  45. package/setup.sh +530 -0
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # Codex CLI installer: OpenAI's terminal coding agent
5
+ TOOL="codex"
6
+
7
+ echo "Installing $TOOL (OpenAI Codex CLI)..."
8
+
9
+ # Create directories
10
+ mkdir -p "dockerfiles/$TOOL"
11
+ mkdir -p "$HOME/.ai-cache/$TOOL"
12
+ mkdir -p "$HOME/.ai-home/$TOOL"
13
+
14
+ # Create Dockerfile (extends base image for faster builds)
15
+ cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
16
+ FROM ai-base:latest
17
+ USER root
18
+ RUN mkdir -p /usr/local/lib/codex && \
19
+ cd /usr/local/lib/codex && \
20
+ bun init -y && \
21
+ bun add @openai/codex && \
22
+ ln -s /usr/local/lib/codex/node_modules/.bin/codex /usr/local/bin/codex
23
+ USER agent
24
+ ENTRYPOINT ["codex"]
25
+ EOF
26
+
27
+ # Build image
28
+ echo "Building Docker image for $TOOL..."
29
+ docker build -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
30
+
31
+ echo "✅ $TOOL installed"
32
+ echo ""
33
+ echo "Features:"
34
+ echo " ✓ OpenAI's official terminal agent"
35
+ echo " ✓ GPT-4 and Codex models"
36
+ echo " ✓ Multi-file code generation"
37
+ echo " ✓ Terminal command execution"
38
+ echo ""
39
+ echo "Usage: ai-run codex"
40
+ echo "Auth: Set OPENAI_API_KEY environment variable"
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ echo "Installing droid (Factory CLI)..."
5
+
6
+ # Create directories
7
+ mkdir -p "dockerfiles/droid"
8
+ mkdir -p "$HOME/.ai-cache/droid"
9
+ mkdir -p "$HOME/.ai-home/droid"
10
+
11
+ # Create Dockerfile with curl install
12
+ cat <<'EOF' > "dockerfiles/droid/Dockerfile"
13
+ FROM ai-base:latest
14
+ USER root
15
+ RUN mkdir -p /home/agent/.factory && \
16
+ bash -c "curl -fsSL https://app.factory.ai/cli | sh" && \
17
+ mv /home/agent/.local/bin/droid /usr/local/bin/droid && \
18
+ chown -R agent:agent /home/agent/.factory
19
+ USER agent
20
+ ENTRYPOINT ["bash", "-c", "exec droid \"$@\"", "--"]
21
+ EOF
22
+
23
+ # Build image
24
+ echo "Building Docker image for droid..."
25
+ docker build -t "ai-droid:latest" "dockerfiles/droid"
26
+
27
+ echo "✅ droid installed"
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # Gemini CLI installer: Google's AI coding agent
5
+ TOOL="gemini"
6
+
7
+ echo "Installing $TOOL (Google Gemini CLI)..."
8
+
9
+ # Create directories
10
+ mkdir -p "dockerfiles/$TOOL"
11
+ mkdir -p "$HOME/.ai-cache/$TOOL"
12
+ mkdir -p "$HOME/.ai-home/$TOOL"
13
+
14
+ # Create Dockerfile (extends base image for faster builds)
15
+ cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
16
+ FROM ai-base:latest
17
+ USER root
18
+ RUN mkdir -p /usr/local/lib/gemini && \
19
+ cd /usr/local/lib/gemini && \
20
+ bun init -y && \
21
+ bun add @google/gemini-cli && \
22
+ ln -s /usr/local/lib/gemini/node_modules/.bin/gemini /usr/local/bin/gemini
23
+ USER agent
24
+ ENTRYPOINT ["gemini"]
25
+ EOF
26
+
27
+ # Build image
28
+ echo "Building Docker image for $TOOL..."
29
+ docker build -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
30
+
31
+ echo "✅ $TOOL installed"
32
+ echo ""
33
+ echo "Features:"
34
+ echo " ✓ Free tier with Gemini 2.5 Pro"
35
+ echo " ✓ MCP (Model Context Protocol) support"
36
+ echo " ✓ Google Search grounding"
37
+ echo ""
38
+ echo "Usage: ai-run gemini"
39
+ echo "Auth: Set GOOGLE_API_KEY or use 'gemini auth'"
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # Jules CLI installer: Google's AI coding assistant
5
+ TOOL="jules"
6
+
7
+ echo "Installing $TOOL (Google Jules CLI)..."
8
+
9
+ # Create directories
10
+ mkdir -p "dockerfiles/$TOOL"
11
+ mkdir -p "$HOME/.ai-cache/$TOOL"
12
+ mkdir -p "$HOME/.ai-home/$TOOL"
13
+
14
+ # Create Dockerfile
15
+ cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
16
+ FROM ai-base:latest
17
+ USER root
18
+
19
+ # Install Jules CLI to a non-shadowed path
20
+ RUN mkdir -p /usr/local/lib/jules && \
21
+ cd /usr/local/lib/jules && \
22
+ bun init -y && \
23
+ bun add @google/jules && \
24
+ ln -s /usr/local/lib/jules/node_modules/.bin/jules /usr/local/bin/jules
25
+
26
+ USER agent
27
+ ENTRYPOINT ["jules"]
28
+ EOF
29
+
30
+ # Build image
31
+ echo "Building Docker image for $TOOL..."
32
+ docker build -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
33
+
34
+ echo "✅ $TOOL installed"
35
+ echo ""
36
+ echo "Usage: ai-run jules"
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # Kilo Code installer: Multi-model AI coding agent
5
+ # Note: Uses npm instead of bun due to cheerio dependency resolution issue
6
+ TOOL="kilo"
7
+
8
+ echo "Installing $TOOL (Kilo Code CLI)..."
9
+
10
+ # Create directories
11
+ mkdir -p "dockerfiles/$TOOL"
12
+ mkdir -p "$HOME/.ai-cache/$TOOL"
13
+ mkdir -p "$HOME/.ai-home/$TOOL"
14
+
15
+ # Create Dockerfile - use Node.js for this tool due to Bun compatibility issue
16
+ cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
17
+ FROM node:22-slim
18
+
19
+ # Install dependencies
20
+ RUN apt-get update && apt-get install -y --no-install-recommends \
21
+ git \
22
+ curl \
23
+ ssh \
24
+ ca-certificates \
25
+ && rm -rf /var/lib/apt/lists/*
26
+
27
+ # Install Kilo Code CLI as root
28
+ RUN npm install -g @kilocode/cli
29
+
30
+ # Create workspace
31
+ WORKDIR /workspace
32
+
33
+ # Create worker user
34
+ RUN useradd -m -u 1001 -d /home/agent agent && \
35
+ chown -R agent:agent /workspace
36
+
37
+ USER agent
38
+ ENV HOME=/home/agent
39
+
40
+ # Kilo uses 'kilocode' as entrypoint
41
+ ENTRYPOINT ["kilocode"]
42
+ EOF
43
+
44
+ # Build image
45
+ echo "Building Docker image for $TOOL..."
46
+ docker build -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
47
+
48
+ echo "✅ $TOOL installed"
49
+ echo ""
50
+ echo "Features:"
51
+ echo " ✓ 500+ AI models supported"
52
+ echo " ✓ Parallel agents with git worktrees"
53
+ echo " ✓ Orchestrator mode for complex tasks"
54
+ echo " ✓ Multiple modes: ask, architect, code, debug"
55
+ echo ""
56
+ echo "Usage: ai-run kilo"
57
+ echo "Modes: ai-run kilo --mode architect"
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # OpenCode installer: Open-source AI coding tool (Native Go Binary)
5
+ TOOL="opencode"
6
+
7
+ echo "Installing $TOOL (OpenCode AI - Native Go Binary)..."
8
+
9
+ # Create directories
10
+ mkdir -p "dockerfiles/$TOOL"
11
+ mkdir -p "$HOME/.ai-cache/$TOOL"
12
+ mkdir -p "$HOME/.ai-home/$TOOL"
13
+
14
+ # Create Dockerfile using official native installer (Go binary)
15
+ cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
16
+ FROM ai-base:latest
17
+
18
+ USER root
19
+ # Install OpenCode using official native installer
20
+ RUN curl -fsSL https://opencode.ai/install | bash && \
21
+ mv /home/agent/.opencode/bin/opencode /usr/local/bin/opencode && \
22
+ rm -rf /home/agent/.opencode
23
+
24
+ USER agent
25
+ ENTRYPOINT ["opencode"]
26
+ EOF
27
+
28
+ # Build image
29
+ echo "Building Docker image for $TOOL (native binary)..."
30
+ docker build -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
31
+
32
+ echo "✅ $TOOL installed (Native Go Binary)"
33
+ echo ""
34
+ echo "Features:"
35
+ echo " ✓ Native Go binary (no Node.js)"
36
+ echo " ✓ Multi-model flexibility"
37
+ echo " ✓ Terminal-based TUI workflow"
38
+ echo ""
39
+ echo "Usage: ai-run opencode"
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # Qoder CLI installer: Qoder's AI coding assistant
5
+ TOOL="qoder"
6
+
7
+ echo "Installing $TOOL (Qoder AI CLI)..."
8
+
9
+ # Create directories
10
+ mkdir -p "dockerfiles/$TOOL"
11
+ mkdir -p "$HOME/.ai-cache/$TOOL"
12
+ mkdir -p "$HOME/.ai-home/$TOOL"
13
+
14
+ # Create Dockerfile
15
+ cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
16
+ FROM ai-base:latest
17
+ USER root
18
+
19
+ # Install Qoder CLI to a non-shadowed path
20
+ RUN mkdir -p /usr/local/lib/qoder && \
21
+ cd /usr/local/lib/qoder && \
22
+ bun init -y && \
23
+ bun add @qoder-ai/qodercli && \
24
+ ln -s /usr/local/lib/qoder/node_modules/.bin/qodercli /usr/local/bin/qoder
25
+
26
+ USER agent
27
+ ENTRYPOINT ["qoder"]
28
+ EOF
29
+
30
+ # Build image
31
+ echo "Building Docker image for $TOOL..."
32
+ docker build -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
33
+
34
+ echo "✅ $TOOL installed"
35
+ echo ""
36
+ echo "Usage: ai-run qoder"
37
+ echo "Auth: Set QODER_API_KEY environment variable"
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # Qwen Code installer: Alibaba's AI coding agent
5
+ TOOL="qwen"
6
+
7
+ echo "Installing $TOOL (Alibaba Qwen Code CLI)..."
8
+
9
+ # Create directories
10
+ mkdir -p "dockerfiles/$TOOL"
11
+ mkdir -p "$HOME/.ai-cache/$TOOL"
12
+ mkdir -p "$HOME/.ai-home/$TOOL"
13
+
14
+ # Create Dockerfile (extends base image for faster builds)
15
+ cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
16
+ FROM ai-base:latest
17
+ USER root
18
+ # Install qwen-code in a dedicated directory and symlink to /usr/local/bin
19
+ RUN mkdir -p /usr/local/lib/qwen && \
20
+ cd /usr/local/lib/qwen && \
21
+ bun init -y && \
22
+ bun add @qwen-code/qwen-code@latest tiktoken && \
23
+ ln -s /usr/local/lib/qwen/node_modules/.bin/qwen /usr/local/bin/qwen
24
+ USER agent
25
+ ENTRYPOINT ["qwen"]
26
+ EOF
27
+
28
+ # Build image
29
+ echo "Building Docker image for $TOOL..."
30
+ docker build -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
31
+
32
+ echo "✅ $TOOL installed"
33
+ echo ""
34
+ echo "Features:"
35
+ echo " ✓ Qwen3-Coder model (1M context)"
36
+ echo " ✓ Agentic programming workflows"
37
+ echo " ✓ Multi-file code editing"
38
+ echo ""
39
+ echo "Usage: ai-run qwen"
40
+ echo "Auth: Set DASHSCOPE_API_KEY or configure endpoint"
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # SHAI CLI installer: OVHcloud's AI agent
5
+ TOOL="shai"
6
+
7
+ echo "Installing $TOOL (OVHcloud SHAI)..."
8
+
9
+ # Create directories
10
+ mkdir -p "dockerfiles/$TOOL"
11
+ mkdir -p "$HOME/.ai-cache/$TOOL"
12
+ mkdir -p "$HOME/.ai-home/$TOOL"
13
+
14
+ # Create Dockerfile
15
+ cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
16
+ FROM ai-base:latest
17
+ USER root
18
+
19
+ # Install SHAI native binary and relocate to /usr/local/bin
20
+ RUN curl -fsSL https://raw.githubusercontent.com/ovh/shai/main/install.sh | bash && \
21
+ mv /home/agent/.local/bin/shai /usr/local/bin/shai
22
+
23
+ USER agent
24
+ ENTRYPOINT ["shai"]
25
+ EOF
26
+
27
+ # Build image
28
+ echo "Building Docker image for $TOOL..."
29
+ docker build -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
30
+
31
+ echo "✅ $TOOL installed"
32
+ echo ""
33
+ echo "Usage: ai-run shai"
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # Generic tool installer: ./install-tool.sh <tool> <npm-package> <entrypoint>
5
+ # Uses Bun runtime for 2x faster startup
6
+ TOOL="$1"
7
+ NPM_PACKAGE="$2"
8
+ ENTRYPOINT="${3:-$TOOL}"
9
+
10
+ if [[ -z "$TOOL" || -z "$NPM_PACKAGE" ]]; then
11
+ echo "Usage: $0 <tool> <npm-package> [entrypoint]"
12
+ exit 1
13
+ fi
14
+
15
+ echo "Installing $TOOL..."
16
+
17
+ # Create directories
18
+ mkdir -p "dockerfiles/$TOOL"
19
+ mkdir -p "$HOME/.ai-cache/$TOOL"
20
+ mkdir -p "$HOME/.ai-home/$TOOL"
21
+
22
+ # Create Dockerfile using Bun
23
+ cat <<EOF > "dockerfiles/$TOOL/Dockerfile"
24
+ FROM ai-base:latest
25
+ USER root
26
+ RUN mkdir -p /usr/local/lib/$TOOL && \
27
+ cd /usr/local/lib/$TOOL && \
28
+ bun init -y && \
29
+ bun add $NPM_PACKAGE && \
30
+ ln -s /usr/local/lib/$TOOL/node_modules/.bin/$ENTRYPOINT /usr/local/bin/$ENTRYPOINT
31
+ USER agent
32
+ ENTRYPOINT ["$ENTRYPOINT"]
33
+ EOF
34
+
35
+ # Build image
36
+ echo "Building Docker image for $TOOL..."
37
+ docker build -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
38
+
39
+ echo "✅ $TOOL installed"
40
+
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # VSCode Server installer: Headless VSCode in browser
5
+ TOOL="vscode"
6
+ VSCODE_PORT="${VSCODE_PORT:-8000}"
7
+
8
+ echo "Installing $TOOL (VSCode Server - browser-based)..."
9
+
10
+ # Create directories
11
+ mkdir -p "dockerfiles/$TOOL"
12
+ mkdir -p "$HOME/.ai-cache/$TOOL"
13
+ mkdir -p "$HOME/.ai-home/$TOOL"
14
+
15
+ # Create Dockerfile for VSCode Desktop (with X11 forwarding)
16
+ cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
17
+ FROM ubuntu:22.04
18
+
19
+ ENV DEBIAN_FRONTEND=noninteractive
20
+
21
+ # Install VSCode Desktop dependencies (GTK, X11, OpenGL, and other required libraries)
22
+ RUN apt-get update && apt-get install -y --no-install-recommends \
23
+ wget \
24
+ ca-certificates \
25
+ gnupg2 \
26
+ libgtk-3-0 \
27
+ libgbm1 \
28
+ libnss3 \
29
+ libxss1 \
30
+ libasound2 \
31
+ libx11-xcb1 \
32
+ libxcb-dri3-0 \
33
+ libdrm2 \
34
+ libxshmfence1 \
35
+ libxkbfile1 \
36
+ libsecret-1-0 \
37
+ libatk1.0-0 \
38
+ libatk-bridge2.0-0 \
39
+ libcups2 \
40
+ libxcomposite1 \
41
+ libxdamage1 \
42
+ libxrandr2 \
43
+ libpango-1.0-0 \
44
+ libcairo2 \
45
+ libxfixes3 \
46
+ libnotify4 \
47
+ fonts-liberation \
48
+ xdg-utils \
49
+ libgl1 \
50
+ libegl1 \
51
+ libgl1-mesa-dri \
52
+ libglx-mesa0 \
53
+ mesa-utils \
54
+ dbus \
55
+ dbus-x11 \
56
+ && rm -rf /var/lib/apt/lists/*
57
+
58
+ # Download and install VSCode Desktop
59
+ RUN ARCH=$(dpkg --print-architecture) && \
60
+ echo "Downloading VSCode Desktop for ${ARCH}..." && \
61
+ wget -q -O /tmp/vscode.deb "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-${ARCH}" && \
62
+ apt-get update && apt-get install -y /tmp/vscode.deb && \
63
+ rm /tmp/vscode.deb && \
64
+ rm -rf /var/lib/apt/lists/* && \
65
+ echo "VSCode Desktop installed successfully"
66
+
67
+ # Create directories
68
+ RUN mkdir -p /workspace /tmp /home/vscode/.config/Code /run/dbus
69
+ WORKDIR /workspace
70
+
71
+ # Non-root user (use UID 1001 to avoid conflicts)
72
+ RUN useradd -m -u 1001 -d /home/vscode vscode && \
73
+ chown -R vscode:vscode /workspace /tmp /home/vscode
74
+
75
+ USER vscode
76
+
77
+ # Set home directory
78
+ ENV HOME=/home/vscode
79
+
80
+ # Start VSCode Desktop with software rendering (no GPU)
81
+ ENTRYPOINT ["/usr/share/code/code", "--no-sandbox", "--disable-gpu"]
82
+ CMD ["/workspace"]
83
+ EOF
84
+
85
+ # Build image
86
+ echo "Building Docker image for $TOOL..."
87
+ docker build -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
88
+
89
+ # Create wrapper script
90
+ cat <<'EOF' > "$HOME/bin/vscode-run"
91
+ #!/usr/bin/env bash
92
+ # VSCode Desktop launcher with X11 forwarding
93
+
94
+ set -e
95
+
96
+ WORKSPACES_FILE="$HOME/.ai-workspaces"
97
+ CONTAINER_NAME="ai-vscode-sandbox-$$"
98
+
99
+ if [ ! -f "$WORKSPACES_FILE" ]; then
100
+ echo "Error: No workspaces configured. Run setup.sh first." >&2
101
+ exit 1
102
+ fi
103
+
104
+ # Detect OS for X11 setup
105
+ OS_TYPE=$(uname -s)
106
+
107
+ # Build volume mounts from whitelisted workspaces
108
+ VOLUME_MOUNTS=""
109
+ WS_INDEX=0
110
+ while IFS= read -r ws; do
111
+ if [ -n "$ws" ] && [ -d "$ws" ]; then
112
+ VOLUME_MOUNTS="$VOLUME_MOUNTS -v $ws:/workspace/workspace-$WS_INDEX"
113
+ WS_INDEX=$((WS_INDEX + 1))
114
+ fi
115
+ done < "$WORKSPACES_FILE"
116
+
117
+ if [ $WS_INDEX -eq 0 ]; then
118
+ echo "Error: No valid workspaces found in $WORKSPACES_FILE" >&2
119
+ exit 1
120
+ fi
121
+
122
+ echo "🔒 Starting containerized VSCode Desktop (strict sandbox)..."
123
+ echo ""
124
+ echo "Mounted workspaces:"
125
+ WS_INDEX=0
126
+ while IFS= read -r ws; do
127
+ if [ -n "$ws" ] && [ -d "$ws" ]; then
128
+ echo " ✓ $ws → /workspace/workspace-$WS_INDEX"
129
+ WS_INDEX=$((WS_INDEX + 1))
130
+ fi
131
+ done < "$WORKSPACES_FILE"
132
+ echo ""
133
+
134
+ # Setup X11 forwarding based on OS
135
+ X11_OPTS=""
136
+ if [ "$OS_TYPE" = "Darwin" ]; then
137
+ # macOS: Check if XQuartz is running
138
+ if ! pgrep -q Xquartz 2>/dev/null && ! pgrep -q X11 2>/dev/null; then
139
+ echo "⚠️ XQuartz not detected. Starting XQuartz..."
140
+ open -a XQuartz
141
+ sleep 3
142
+ fi
143
+
144
+ # Configure XQuartz to allow network connections (needed for Docker)
145
+ defaults write org.xquartz.X11 nolisten_tcp -bool false 2>/dev/null || true
146
+
147
+ # Allow connections from localhost
148
+ xhost + localhost 2>/dev/null || true
149
+ xhost + 127.0.0.1 2>/dev/null || true
150
+
151
+ # Use TCP connection for X11 (Docker Desktop on macOS can't use Unix sockets)
152
+ X11_OPTS="-e DISPLAY=host.docker.internal:0"
153
+
154
+ elif [ "$OS_TYPE" = "Linux" ]; then
155
+ # Linux: Use host X11 socket directly
156
+ X11_OPTS="-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY"
157
+
158
+ # Allow local Docker connections
159
+ xhost +local:docker 2>/dev/null || true
160
+ fi
161
+
162
+ echo "🚀 Launching VSCode Desktop in sandbox container..."
163
+ echo ""
164
+
165
+ # STRICT SANDBOX SECURITY:
166
+ # - Read-only filesystem (except /workspace, /tmp, /home/vscode)
167
+ # - No host environment variables (except DISPLAY)
168
+ # - No access to host files outside volumes
169
+ # - Non-root user
170
+
171
+ docker run \
172
+ --rm \
173
+ --name "$CONTAINER_NAME" \
174
+ $VOLUME_MOUNTS \
175
+ $X11_OPTS \
176
+ --tmpfs /tmp:exec \
177
+ --tmpfs /run \
178
+ --tmpfs /home/vscode/.config:uid=1001,gid=1001 \
179
+ --tmpfs /home/vscode/.vscode:uid=1001,gid=1001 \
180
+ -e HOME=/home/vscode \
181
+ -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
182
+ -u 1001:1001 \
183
+ -w /workspace \
184
+ "ai-vscode:latest"
185
+
186
+ echo ""
187
+ echo "✅ VSCode Desktop closed"
188
+ echo "🧹 Sandbox cleaned up"
189
+ EOF
190
+
191
+ chmod +x "$HOME/bin/vscode-run"
192
+
193
+ echo "✅ $TOOL installed (VSCode Desktop with X11)"
194
+ echo ""
195
+ echo "Created files:"
196
+ echo " - Docker image: ai-$TOOL:latest"
197
+ echo " - Wrapper script: $HOME/bin/vscode-run"
198
+ echo ""
199
+ echo "Requirements (macOS):"
200
+ echo " - XQuartz: brew install xquartz"
201
+ echo " - Log out and log back in after installing XQuartz"
202
+ echo ""
203
+ echo "Security Features:"
204
+ echo " ✓ No host environment variables visible (except DISPLAY)"
205
+ echo " ✓ No access to host filesystem outside volumes"
206
+ echo " ✓ Runs as non-root user"
207
+ echo " ✓ Terminal in VSCode is sandboxed"
208
+ echo ""
209
+ echo "Usage:"
210
+ echo " vscode-run"
211
+ echo " # Opens VSCode Desktop in a sandboxed container"
212
+ echo ""
213
+ echo "Whitelisted Workspaces:"
214
+ while IFS= read -r ws; do
215
+ if [ -n "$ws" ] && [ -d "$ws" ]; then
216
+ echo " - $ws"
217
+ fi
218
+ done < "$WORKSPACES_FILE"
219
+