@kokorolx/ai-sandbox-wrapper 3.4.3-beta.2 → 4.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/bin/ai-run CHANGED
@@ -311,10 +311,11 @@ HLP
311
311
  --restart unless-stopped
312
312
  -v "$OD_VOLUME:/app/.od"
313
313
  --env-file "$OD_ENV_FILE"
314
+ -p "127.0.0.1:${host_port}:7456"
314
315
  )
315
316
 
316
317
  if [[ "$expose" == "true" ]]; then
317
- run_args+=(-p "${host_port}:7456")
318
+ echo "ℹ️ Port ${host_port} already published by default (127.0.0.1:${host_port}:7456)"
318
319
  fi
319
320
 
320
321
  run_args+=("$OD_IMAGE")
@@ -322,11 +323,7 @@ HLP
322
323
  echo "🔄 Starting $OD_CONTAINER_NAME..."
323
324
  docker "${run_args[@]}" >/dev/null
324
325
  echo "✅ $OD_CONTAINER_NAME running on network '$OD_NETWORK'"
325
- if [[ "$expose" == "true" ]]; then
326
- echo " Published to host: http://localhost:${host_port}"
327
- else
328
- echo " Internal-only: reachable from sandbox containers as http://ai-open-design:7456"
329
- fi
326
+ echo " Published to host: http://localhost:${host_port}"
330
327
  }
331
328
 
332
329
  od_stop() {
@@ -0,0 +1,103 @@
1
+ # Build RTK from source (multi-stage: only binary is kept, Rust toolchain discarded)
2
+ FROM rust:bookworm AS rtk-builder
3
+ RUN cargo install --git https://github.com/rtk-ai/rtk --locked
4
+
5
+ FROM node:22-bookworm-slim
6
+
7
+ ARG AGENT_UID=1001
8
+
9
+ RUN apt-get update && apt-get install -y --no-install-recommends git curl ssh ca-certificates jq python3 python3-pip python3-venv python3-dev python3-setuptools build-essential libopenblas-dev pipx unzip xclip wl-clipboard ripgrep tmux vim-nox fd-find sqlite3 poppler-utils qpdf tesseract-ocr && curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/usr/local/bin sh && rm -rf /var/lib/apt/lists/* && pipx ensurepath
10
+
11
+ # Install Python PDF processing tools for PDF skill
12
+ RUN pip3 install --no-cache-dir --break-system-packages pypdf pdfplumber reportlab pytesseract pdf2image
13
+
14
+ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && apt-get update && apt-get install -y gh && rm -rf /var/lib/apt/lists/*
15
+
16
+ # Install bun (used by most AI tool install scripts)
17
+ RUN npm install -g bun
18
+
19
+ # Install pnpm globally using npm (not bun, for stability)
20
+ RUN npm install -g pnpm
21
+
22
+ # Install TypeScript and LSP tools using npm
23
+ RUN npm install -g typescript typescript-language-server pyright vscode-langservers-extracted
24
+
25
+ # Verify installations
26
+ RUN node --version && npm --version && pnpm --version && tsc --version
27
+
28
+ # Install additional tools (if selected)
29
+ RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install specify-cli --pip-args="git+https://github.com/github/spec-kit.git" && \
30
+ chmod +x /usr/local/bin/specify && \
31
+ ln -sf /usr/local/bin/specify /usr/local/bin/specify-cli
32
+ RUN mkdir -p /usr/local/lib/uipro-cli && \
33
+ cd /usr/local/lib/uipro-cli && \
34
+ npm init -y && \
35
+ npm install uipro-cli && \
36
+ ln -sf /usr/local/lib/uipro-cli/node_modules/.bin/uipro /usr/local/bin/uipro && \
37
+ ln -sf /usr/local/bin/uipro /usr/local/bin/uipro-cli && \
38
+ chmod -R 755 /usr/local/lib/uipro-cli && \
39
+ chmod +x /usr/local/bin/uipro
40
+ RUN mkdir -p /usr/local/lib/openspec && \
41
+ cd /usr/local/lib/openspec && \
42
+ npm init -y && \
43
+ npm install @fission-ai/openspec && \
44
+ ln -sf /usr/local/lib/openspec/node_modules/.bin/openspec /usr/local/bin/openspec && \
45
+ chmod -R 755 /usr/local/lib/openspec && \
46
+ chmod +x /usr/local/bin/openspec
47
+ # Install RTK - token optimizer for AI coding agents (built from source)
48
+ COPY --from=rtk-builder /usr/local/cargo/bin/rtk /usr/local/bin/rtk
49
+ # Install RTK OpenCode skills (auto-discovered by OpenCode agents)
50
+ RUN mkdir -p /home/agent/.config/opencode/skills/rtk /home/agent/.config/opencode/skills/rtk-setup
51
+ COPY skills/rtk/SKILL.md /home/agent/.config/opencode/skills/rtk/SKILL.md
52
+ COPY skills/rtk-setup/SKILL.md /home/agent/.config/opencode/skills/rtk-setup/SKILL.md
53
+ RUN apt-get update && apt-get install -y --no-install-recommends \
54
+ libglib2.0-0 \
55
+ libnspr4 \
56
+ libnss3 \
57
+ libdbus-1-3 \
58
+ libatk1.0-0 \
59
+ libatk-bridge2.0-0 \
60
+ libcups2 \
61
+ libxcb1 \
62
+ libxkbcommon0 \
63
+ libatspi2.0-0 \
64
+ libx11-6 \
65
+ libxcomposite1 \
66
+ libxdamage1 \
67
+ libxext6 \
68
+ libxfixes3 \
69
+ libxrandr2 \
70
+ libgbm1 \
71
+ libdrm2 \
72
+ libcairo2 \
73
+ libpango-1.0-0 \
74
+ libasound2 \
75
+ fonts-liberation \
76
+ libappindicator3-1 \
77
+ libu2f-udev \
78
+ libvulkan1 \
79
+ libxshmfence1 \
80
+ xdg-utils \
81
+ wget \
82
+ && rm -rf /var/lib/apt/lists/*
83
+ ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright-browsers
84
+ RUN mkdir -p /opt/playwright-browsers && \
85
+ npm install -g @playwright/mcp@latest && \
86
+ npx playwright-core install --no-shell chromium && \
87
+ npx playwright-core install-deps chromium && \
88
+ chmod -R 777 /opt/playwright-browsers && \
89
+ ln -sf $(ls -d /opt/playwright-browsers/chromium-*/chrome-linux/chrome | sort -V | tail -1) /opt/chromium
90
+ ENV CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=1
91
+ RUN npm install -g chrome-devtools-mcp@latest && \
92
+ touch /opt/.mcp-chrome-devtools-installed
93
+
94
+ # Create workspace
95
+ WORKDIR /workspace
96
+
97
+ # Non-root user for security (match host UID)
98
+ RUN useradd -m -u ${AGENT_UID} -d /home/agent agent && \
99
+ mkdir -p /home/agent/.cache /home/agent/.npm /home/agent/.opencode /home/agent/.config && \
100
+ chown -R agent:agent /home/agent/.cache /home/agent/.npm /home/agent/.opencode /home/agent/.config /workspace && \
101
+ ([ -d /opt/playwright-browsers ] && chown -R agent:agent /opt/playwright-browsers || true)
102
+ USER agent
103
+ ENV HOME=/home/agent
@@ -0,0 +1,119 @@
1
+ # Build RTK from source (multi-stage: only binary is kept, Rust toolchain discarded)
2
+ FROM rust:bookworm AS rtk-builder
3
+ RUN cargo install --git https://github.com/rtk-ai/rtk --locked
4
+
5
+ FROM node:22-bookworm-slim
6
+
7
+ ARG AGENT_UID=1001
8
+
9
+ RUN apt-get update && apt-get install -y --no-install-recommends git curl ssh ca-certificates jq python3 python3-pip python3-venv python3-dev python3-setuptools build-essential libopenblas-dev pipx unzip xclip wl-clipboard ripgrep tmux vim-nox fd-find sqlite3 poppler-utils qpdf tesseract-ocr && curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/usr/local/bin sh && rm -rf /var/lib/apt/lists/* && pipx ensurepath
10
+
11
+ # Install Python PDF processing tools for PDF skill
12
+ RUN pip3 install --no-cache-dir --break-system-packages pypdf pdfplumber reportlab pytesseract pdf2image
13
+
14
+ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && apt-get update && apt-get install -y gh && rm -rf /var/lib/apt/lists/*
15
+
16
+ # Install bun (used by most AI tool install scripts)
17
+ RUN npm install -g bun
18
+
19
+ # Install pnpm globally using npm (not bun, for stability)
20
+ RUN npm install -g pnpm
21
+
22
+ # Install TypeScript and LSP tools using npm
23
+ RUN npm install -g typescript typescript-language-server pyright vscode-langservers-extracted
24
+
25
+ # Verify installations
26
+ RUN node --version && npm --version && pnpm --version && tsc --version
27
+
28
+ # Install additional tools (if selected)
29
+ RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install specify-cli --pip-args="git+https://github.com/github/spec-kit.git" && \
30
+ chmod +x /usr/local/bin/specify && \
31
+ ln -sf /usr/local/bin/specify /usr/local/bin/specify-cli
32
+ RUN mkdir -p /usr/local/lib/uipro-cli && \
33
+ cd /usr/local/lib/uipro-cli && \
34
+ npm init -y && \
35
+ npm install uipro-cli && \
36
+ ln -sf /usr/local/lib/uipro-cli/node_modules/.bin/uipro /usr/local/bin/uipro && \
37
+ ln -sf /usr/local/bin/uipro /usr/local/bin/uipro-cli && \
38
+ chmod -R 755 /usr/local/lib/uipro-cli && \
39
+ chmod +x /usr/local/bin/uipro
40
+ RUN mkdir -p /usr/local/lib/openspec && \
41
+ cd /usr/local/lib/openspec && \
42
+ npm init -y && \
43
+ npm install @fission-ai/openspec && \
44
+ ln -sf /usr/local/lib/openspec/node_modules/.bin/openspec /usr/local/bin/openspec && \
45
+ chmod -R 755 /usr/local/lib/openspec && \
46
+ chmod +x /usr/local/bin/openspec
47
+ # Install RTK - token optimizer for AI coding agents (built from source)
48
+ COPY --from=rtk-builder /usr/local/cargo/bin/rtk /usr/local/bin/rtk
49
+ # Install RTK OpenCode skills (auto-discovered by OpenCode agents)
50
+ RUN mkdir -p /home/agent/.config/opencode/skills/rtk /home/agent/.config/opencode/skills/rtk-setup
51
+ COPY skills/rtk/SKILL.md /home/agent/.config/opencode/skills/rtk/SKILL.md
52
+ COPY skills/rtk-setup/SKILL.md /home/agent/.config/opencode/skills/rtk-setup/SKILL.md
53
+ RUN apt-get update && apt-get install -y --no-install-recommends \
54
+ libglib2.0-0 \
55
+ libnspr4 \
56
+ libnss3 \
57
+ libdbus-1-3 \
58
+ libatk1.0-0 \
59
+ libatk-bridge2.0-0 \
60
+ libcups2 \
61
+ libxcb1 \
62
+ libxkbcommon0 \
63
+ libatspi2.0-0 \
64
+ libx11-6 \
65
+ libxcomposite1 \
66
+ libxdamage1 \
67
+ libxext6 \
68
+ libxfixes3 \
69
+ libxrandr2 \
70
+ libgbm1 \
71
+ libdrm2 \
72
+ libcairo2 \
73
+ libpango-1.0-0 \
74
+ libasound2 \
75
+ fonts-liberation \
76
+ libappindicator3-1 \
77
+ libu2f-udev \
78
+ libvulkan1 \
79
+ libxshmfence1 \
80
+ xdg-utils \
81
+ wget \
82
+ && rm -rf /var/lib/apt/lists/*
83
+ ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright-browsers
84
+ RUN mkdir -p /opt/playwright-browsers && \
85
+ npm install -g @playwright/mcp@latest && \
86
+ npx playwright-core install --no-shell chromium && \
87
+ npx playwright-core install-deps chromium && \
88
+ chmod -R 777 /opt/playwright-browsers && \
89
+ ln -sf $(ls -d /opt/playwright-browsers/chromium-*/chrome-linux/chrome | sort -V | tail -1) /opt/chromium
90
+ ENV CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=1
91
+ RUN npm install -g chrome-devtools-mcp@latest && \
92
+ touch /opt/.mcp-chrome-devtools-installed
93
+
94
+ # Create workspace
95
+ WORKDIR /workspace
96
+
97
+ # Non-root user for security (match host UID)
98
+ RUN useradd -m -u ${AGENT_UID} -d /home/agent agent && \
99
+ mkdir -p /home/agent/.cache /home/agent/.npm /home/agent/.opencode /home/agent/.config && \
100
+ chown -R agent:agent /home/agent/.cache /home/agent/.npm /home/agent/.opencode /home/agent/.config /workspace && \
101
+ ([ -d /opt/playwright-browsers ] && chown -R agent:agent /opt/playwright-browsers || true)
102
+
103
+ # === opencode ===
104
+ USER root
105
+ RUN curl -fsSL https://opencode.ai/install | bash && \
106
+ mv /root/.opencode/bin/opencode /usr/local/bin/opencode && \
107
+ rm -rf /root/.opencode
108
+
109
+ # === claude ===
110
+ USER root
111
+ RUN export HOME=/root && curl -fsSL https://claude.ai/install.sh | bash && \
112
+ mkdir -p /usr/local/share && \
113
+ mv /root/.local/share/claude /usr/local/share/claude && \
114
+ ln -sf /usr/local/share/claude/versions/$(ls /usr/local/share/claude/versions | head -1) /usr/local/bin/claude
115
+ USER agent
116
+
117
+ USER agent
118
+ ENV HOME=/home/agent
119
+ CMD ["bash"]
@@ -9,7 +9,7 @@ fi
9
9
 
10
10
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
11
  PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
12
- cd "$PROJECT_DIR"
12
+ cd "$PROJECT_DIR" || exit 1
13
13
 
14
14
  SANDBOX_DIR="dockerfiles/sandbox"
15
15
  mkdir -p "$SANDBOX_DIR"
@@ -53,6 +53,7 @@ BASE_PREAMBLE=$(echo "$BASE_CONTENT" | sed '/^USER agent$/,$d')
53
53
  fi
54
54
 
55
55
  echo "# === $tool ==="
56
+ # shellcheck source=/dev/null
56
57
  SNIPPET_MODE=1 source "$INSTALL_SCRIPT"
57
58
  dockerfile_snippet
58
59
  echo ""
@@ -3,8 +3,9 @@ set -e
3
3
 
4
4
  dockerfile_snippet() {
5
5
  cat <<'SNIPPET'
6
+ USER root
7
+ RUN UV_TOOL_BIN_DIR=/usr/local/bin uv tool install aider-chat
6
8
  USER agent
7
- RUN python3 -m pip install --break-system-packages aider-install && aider-install
8
9
  SNIPPET
9
10
  }
10
11
 
@@ -24,9 +25,9 @@ mkdir -p "$HOME/.ai-sandbox/tools/$TOOL/home"
24
25
  # Create Dockerfile (extends base image which has Python)
25
26
  cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
26
27
  FROM ai-base:latest
28
+ USER root
29
+ RUN UV_TOOL_BIN_DIR=/usr/local/bin uv tool install aider-chat
27
30
  USER agent
28
- # Install aider via aider-install
29
- RUN python3 -m pip install --break-system-packages aider-install && aider-install
30
31
  ENTRYPOINT ["aider"]
31
32
  EOF
32
33
 
@@ -179,10 +179,7 @@ fi
179
179
 
180
180
  # MCP Tools for AI agent browser automation
181
181
  # Both tools share Playwright's Chromium (native ARM64/x86_64, avoids Puppeteer arch issues)
182
- MCP_BROWSER_INSTALLED=false
183
-
184
182
  if [[ "${INSTALL_CHROME_DEVTOOLS_MCP:-0}" -eq 1 ]] || [[ "${INSTALL_PLAYWRIGHT_MCP:-0}" -eq 1 ]]; then
185
- MCP_BROWSER_INSTALLED=true
186
183
  echo "📦 Installing shared Chromium browser for MCP tools"
187
184
  ADDITIONAL_TOOLS_INSTALL+='RUN apt-get update && apt-get install -y --no-install-recommends \
188
185
  libglib2.0-0 \
@@ -26,11 +26,11 @@ if [[ ! -d "$OPENCLAW_REPO_DIR/.git" ]]; then
26
26
  git clone https://github.com/openclaw/openclaw.git "$OPENCLAW_REPO_DIR"
27
27
  else
28
28
  echo "📦 OpenClaw repository already exists, pulling latest..."
29
- cd "$OPENCLAW_REPO_DIR"
29
+ cd "$OPENCLAW_REPO_DIR" || exit 1
30
30
  git pull origin main || git pull origin master || true
31
31
  fi
32
32
 
33
- cd "$OPENCLAW_REPO_DIR"
33
+ cd "$OPENCLAW_REPO_DIR" || exit 1
34
34
 
35
35
  # Build OpenClaw Docker image using their docker-compose
36
36
  echo "🔨 Building OpenClaw Docker image..."
@@ -4,9 +4,12 @@ set -e
4
4
  dockerfile_snippet() {
5
5
  cat <<'SNIPPET'
6
6
  USER root
7
- RUN curl -fsSL https://opencode.ai/install | bash && \
7
+ ENV HOME=/root
8
+ RUN curl -fsSL --retry 3 --retry-delay 5 https://opencode.ai/install | bash && \
8
9
  mv /root/.opencode/bin/opencode /usr/local/bin/opencode && \
9
10
  rm -rf /root/.opencode
11
+ USER agent
12
+ ENV HOME=/home/agent
10
13
  SNIPPET
11
14
  }
12
15
 
@@ -32,11 +35,13 @@ if [[ -n "$OPENCODE_VERSION" ]]; then
32
35
  FROM ai-base:latest
33
36
 
34
37
  USER root
35
- RUN curl -fsSL https://opencode.ai/install | bash -s -- --version $OPENCODE_VERSION && \\
38
+ ENV HOME=/root
39
+ RUN curl -fsSL --retry 3 --retry-delay 5 https://opencode.ai/install | bash -s -- --version $OPENCODE_VERSION && \\
36
40
  mv /root/.opencode/bin/opencode /usr/local/bin/opencode && \\
37
41
  rm -rf /root/.opencode
38
42
 
39
43
  USER agent
44
+ ENV HOME=/home/agent
40
45
  ENTRYPOINT ["opencode"]
41
46
  EOF
42
47
  else
@@ -44,11 +49,13 @@ else
44
49
  FROM ai-base:latest
45
50
 
46
51
  USER root
47
- RUN curl -fsSL https://opencode.ai/install | bash && \
52
+ ENV HOME=/root
53
+ RUN curl -fsSL --retry 3 --retry-delay 5 https://opencode.ai/install | bash && \
48
54
  mv /root/.opencode/bin/opencode /usr/local/bin/opencode && \
49
55
  rm -rf /root/.opencode
50
56
 
51
57
  USER agent
58
+ ENV HOME=/home/agent
52
59
  ENTRYPOINT ["opencode"]
53
60
  EOF
54
61
  fi
@@ -189,6 +189,7 @@ pmcp::with_lock() {
189
189
  sleep 0.1
190
190
  waited=$((waited + 1))
191
191
  done
192
+ # shellcheck disable=SC2064 # intentional: capture $mutex value at trap definition time
192
193
  trap "rmdir '$mutex' 2>/dev/null || true" EXIT
193
194
  "$@"
194
195
  local rc=$?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokorolx/ai-sandbox-wrapper",
3
- "version": "3.4.3-beta.2",
3
+ "version": "4.0.0",
4
4
  "description": "Docker-based security sandbox for AI coding agents. Isolate Claude, Gemini, Aider, and other AI tools from your host system.",
5
5
  "keywords": [
6
6
  "ai",