@kokorolx/ai-sandbox-wrapper 3.0.2 → 3.0.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.
package/bin/ai-run CHANGED
@@ -701,6 +701,7 @@ get_installed_tools() {
701
701
  # Tool config persistence via bind mounts
702
702
  # Bind-mount host paths directly to ensure changes persist to the host.
703
703
  TOOL_CONFIG_MOUNTS=""
704
+ RG_COMPAT_MOUNT=""
704
705
 
705
706
  mount_tool_config() {
706
707
  local host_path="$1"
@@ -724,6 +725,32 @@ for tool in $(get_installed_tools); do
724
725
  done
725
726
  done
726
727
 
728
+ setup_opencode_rg_compat() {
729
+ [[ "$TOOL" != "opencode" ]] && return 0
730
+
731
+ local bundled_rg="$HOME/.local/share/opencode/bin/rg"
732
+ local rg_shim_path="$SANDBOX_DIR/shared/rg-linux-shim"
733
+
734
+ [[ -f "$bundled_rg" ]] || return 0
735
+ command -v file &>/dev/null || return 0
736
+
737
+ local rg_file_info
738
+ rg_file_info=$(file -b "$bundled_rg" 2>/dev/null || true)
739
+
740
+ if echo "$rg_file_info" | grep -qi "Mach-O"; then
741
+ mkdir -p "$(dirname "$rg_shim_path")"
742
+ cat > "$rg_shim_path" << 'EOF'
743
+ #!/usr/bin/env bash
744
+ exec /usr/bin/rg "$@"
745
+ EOF
746
+ chmod +x "$rg_shim_path"
747
+ RG_COMPAT_MOUNT="-v $rg_shim_path:/home/agent/.local/share/opencode/bin/rg:ro"
748
+ echo "⚠️ Detected incompatible OpenCode bundled rg (Mach-O). Using /usr/bin/rg in container."
749
+ fi
750
+ }
751
+
752
+ setup_opencode_rg_compat
753
+
727
754
  # Bundle OpenCode default skills (if opencode is installed)
728
755
  if get_installed_tools | grep -qw "opencode"; then
729
756
  AIRUN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -756,11 +783,12 @@ if [[ -d "$HOST_SKILLS_DIR" ]]; then
756
783
  SHARED_CACHE_MOUNTS="$SHARED_CACHE_MOUNTS -v $HOST_SKILLS_DIR:/home/agent/.config/opencode/skills:ro"
757
784
  fi
758
785
 
759
- # Nano-brain mount disabled to prevent SQLite conflicts between host and container
760
- # All tools should use the MCP interface to interact with nano-brain on the host
786
+ # Nano-brain read-only mount
787
+ # Exposes logs/index/sqlite files to container while preventing writes
788
+ NANO_BRAIN_MOUNT=""
761
789
  if [[ -d "$HOME/.nano-brain" ]]; then
762
- echo "ℹ️ Skipping .nano-brain mount to prevent SQLite database corruption"
763
- echo " Use MCP interface for nano-brain access instead of direct CLI"
790
+ NANO_BRAIN_MOUNT="-v $HOME/.nano-brain:/home/agent/.nano-brain:ro"
791
+ echo "ℹ️ Mounted .nano-brain as read-only at /home/agent/.nano-brain"
764
792
  fi
765
793
 
766
794
 
@@ -1972,7 +2000,7 @@ configure_opencode_mcp() {
1972
2000
  for tool in "${all_tools[@]}"; do
1973
2001
  case "$tool" in
1974
2002
  chrome-devtools)
1975
- if add_mcp_config "chrome-devtools" '["chrome-devtools-mcp", "--headless", "--isolated", "--executablePath", "/opt/chromium"]'; then
2003
+ if add_mcp_config "chrome-devtools" "[\"chrome-devtools-mcp\", \"--headless\", \"--isolated\", \"--executablePath\", \"$CHROMIUM_PATH\", \"--chrome-arg=--no-sandbox\"]"; then
1976
2004
  echo " ✓ Configured Chrome DevTools MCP"
1977
2005
  configured_any=true
1978
2006
  fi
@@ -2009,9 +2037,8 @@ configure_opencode_mcp() {
2009
2037
  if [[ "$tool_choice" =~ ^[Yy]$ ]]; then
2010
2038
  case "$tool" in
2011
2039
  chrome-devtools)
2012
- if add_mcp_config "chrome-devtools" '["chrome-devtools-mcp", "--headless", "--isolated", "--executablePath", "/opt/chromium"]'; then
2040
+ if add_mcp_config "chrome-devtools" "[\"chrome-devtools-mcp\", \"--headless\", \"--isolated\", \"--executablePath\", \"$CHROMIUM_PATH\", \"--chrome-arg=--no-sandbox\"]"; then
2013
2041
  echo " ✓ Configured"
2014
- configured_any=true
2015
2042
  fi
2016
2043
  ;;
2017
2044
  playwright)
@@ -2230,6 +2257,7 @@ if [[ "${AI_RUN_DEBUG:-}" == "1" ]]; then
2230
2257
  echo "🔧 Debug: PORT_MAPPINGS='$PORT_MAPPINGS'"
2231
2258
  echo "🔧 Debug: WEB_DETECTED='$WEB_DETECTED'"
2232
2259
  echo "🔧 Debug: EXPOSE_PORTS_LIST='$EXPOSE_PORTS_LIST'"
2260
+ echo "🔧 Debug: RG_COMPAT_MOUNT='$RG_COMPAT_MOUNT'"
2233
2261
  fi
2234
2262
 
2235
2263
  is_nano_brain_command() {
@@ -2443,6 +2471,15 @@ if [[ ! -f "$CACHE_DIR/playwright-browsers/.seeded" ]]; then
2443
2471
  fi
2444
2472
  fi
2445
2473
 
2474
+ # Resolve the latest chromium binary path from shared cache
2475
+ # The /opt/chromium symlink inside the image may point to a stale version
2476
+ CHROMIUM_PATH="/opt/chromium"
2477
+ LATEST_CHROMIUM=$(ls -d "$CACHE_DIR/playwright-browsers"/chromium-*/chrome-linux/chrome 2>/dev/null | sort -V | tail -1)
2478
+ if [[ -n "$LATEST_CHROMIUM" ]]; then
2479
+ # Convert host cache path to container path
2480
+ CHROMIUM_PATH="/opt/playwright-browsers/$(echo "$LATEST_CHROMIUM" | grep -oP 'chromium-[^/]+')/chrome-linux/chrome"
2481
+ fi
2482
+
2446
2483
  # Detect display configuration (clipboard integration)
2447
2484
  DISPLAY_FLAGS=$(detect_display_config)
2448
2485
 
@@ -2516,6 +2553,7 @@ docker run $CONTAINER_NAME --rm $TTY_FLAGS \
2516
2553
  $VOLUME_MOUNTS \
2517
2554
  $CONFIG_MOUNT \
2518
2555
  $TOOL_CONFIG_MOUNTS \
2556
+ $RG_COMPAT_MOUNT \
2519
2557
  $GIT_MOUNTS \
2520
2558
  $SSH_AGENT_ENV \
2521
2559
  $NETWORK_OPTIONS \
@@ -2525,6 +2563,7 @@ docker run $CONTAINER_NAME --rm $TTY_FLAGS \
2525
2563
  $OPENCODE_PASSWORD_ENV \
2526
2564
  -v "$HOME_DIR":/home/agent \
2527
2565
  $SHARED_CACHE_MOUNTS \
2566
+ $NANO_BRAIN_MOUNT \
2528
2567
  -w "$CURRENT_DIR" \
2529
2568
  --env-file "$ENV_FILE" \
2530
2569
  -e TERM="$TERM" \
@@ -175,7 +175,7 @@ RUN mkdir -p /opt/playwright-browsers && \
175
175
  npx playwright-core install --no-shell chromium && \
176
176
  npx playwright-core install-deps chromium && \
177
177
  chmod -R 777 /opt/playwright-browsers && \
178
- ln -sf $(ls -d /opt/playwright-browsers/chromium-*/chrome-linux/chrome | head -1) /opt/chromium
178
+ ln -sf $(ls -d /opt/playwright-browsers/chromium-*/chrome-linux/chrome | sort -V | tail -1) /opt/chromium
179
179
  '
180
180
  fi
181
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokorolx/ai-sandbox-wrapper",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
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",