@kokorolx/ai-sandbox-wrapper 3.0.1 → 3.0.2
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 +4 -0
- package/bin/ai-run +59 -0
- package/dockerfiles/base/Dockerfile +1 -0
- package/dockerfiles/sandbox/Dockerfile +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -198,6 +198,10 @@ When running nano-brain inside the sandbox, `ai-run` performs a targeted preflig
|
|
|
198
198
|
|
|
199
199
|
It also suppresses known **non-fatal** tree-sitter symbol-graph warnings when the command succeeds, so normal query output stays clean. To see suppressed diagnostics, run with debug mode (`AI_RUN_DEBUG=1`).
|
|
200
200
|
|
|
201
|
+
This behavior applies to both:
|
|
202
|
+
- direct mode (`ai-run npx nano-brain ...`)
|
|
203
|
+
- interactive shell mode (`ai-run`, then run `npx nano-brain ...` inside the container shell)
|
|
204
|
+
|
|
201
205
|
```bash
|
|
202
206
|
# Auto-repair enabled by default
|
|
203
207
|
ai-run npx nano-brain status
|
package/bin/ai-run
CHANGED
|
@@ -2299,6 +2299,61 @@ run_with_capture() {
|
|
|
2299
2299
|
run_with_capture
|
|
2300
2300
|
'
|
|
2301
2301
|
|
|
2302
|
+
NANO_BRAIN_SHELL_HOOK=$(cat <<'EOF'
|
|
2303
|
+
nano_brain_shell_wrapper() {
|
|
2304
|
+
local ORIG_CMD=("$@")
|
|
2305
|
+
local REPAIR_PATTERN="(tree-sitter|native binding|Cannot find module.*tree-sitter|compiled against a different Node.js version|Exec format error|invalid ELF header|Native bindings not available)"
|
|
2306
|
+
local WARN_PATTERN="(\\[treesitter\\] Native bindings not available|symbol graph disabled|tree-sitter-typescript\\.node|No such file or directory)"
|
|
2307
|
+
|
|
2308
|
+
local err_file
|
|
2309
|
+
err_file=$(mktemp)
|
|
2310
|
+
|
|
2311
|
+
set +e
|
|
2312
|
+
"${ORIG_CMD[@]}" 2>"$err_file"
|
|
2313
|
+
local exit_code=$?
|
|
2314
|
+
set -e
|
|
2315
|
+
|
|
2316
|
+
if [[ $exit_code -ne 0 ]] && grep -Eqi "$REPAIR_PATTERN" "$err_file"; then
|
|
2317
|
+
cat "$err_file" >&2
|
|
2318
|
+
echo "⚠️ Detected nano-brain native module issue."
|
|
2319
|
+
echo "🔧 Running automatic repair (clearing npx/node-gyp caches)..."
|
|
2320
|
+
rm -rf /home/agent/.npm/_npx /home/agent/.cache/node-gyp 2>/dev/null || true
|
|
2321
|
+
npm cache clean --force >/dev/null 2>&1 || true
|
|
2322
|
+
echo "🔁 Retrying nano-brain command once..."
|
|
2323
|
+
"${ORIG_CMD[@]}"
|
|
2324
|
+
local retry_code=$?
|
|
2325
|
+
rm -f "$err_file"
|
|
2326
|
+
return $retry_code
|
|
2327
|
+
fi
|
|
2328
|
+
|
|
2329
|
+
if [[ $exit_code -eq 0 ]] && grep -Eqi "$WARN_PATTERN" "$err_file"; then
|
|
2330
|
+
if [[ "${AI_RUN_DEBUG:-}" == "1" ]]; then
|
|
2331
|
+
echo "ℹ️ nano-brain: non-fatal tree-sitter warning captured." >&2
|
|
2332
|
+
cat "$err_file" >&2
|
|
2333
|
+
else
|
|
2334
|
+
grep -Eiv "$WARN_PATTERN" "$err_file" >&2 || true
|
|
2335
|
+
fi
|
|
2336
|
+
rm -f "$err_file"
|
|
2337
|
+
return 0
|
|
2338
|
+
fi
|
|
2339
|
+
|
|
2340
|
+
cat "$err_file" >&2
|
|
2341
|
+
rm -f "$err_file"
|
|
2342
|
+
return $exit_code
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
npx() {
|
|
2346
|
+
if [[ "${1:-}" == "nano-brain" ]]; then
|
|
2347
|
+
nano_brain_shell_wrapper command npx "$@"
|
|
2348
|
+
return $?
|
|
2349
|
+
fi
|
|
2350
|
+
command npx "$@"
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
export -f nano_brain_shell_wrapper npx
|
|
2354
|
+
EOF
|
|
2355
|
+
)
|
|
2356
|
+
|
|
2302
2357
|
# Prepare command based on mode
|
|
2303
2358
|
ENTRYPOINT_OVERRIDE=""
|
|
2304
2359
|
if [[ -n "$TOOL" && "$SHELL_MODE" != "true" ]]; then
|
|
@@ -2332,6 +2387,10 @@ else
|
|
|
2332
2387
|
fi
|
|
2333
2388
|
|
|
2334
2389
|
# Nano-brain targeted preflight + auto-repair wrapper
|
|
2390
|
+
if [[ "$SHELL_MODE" == "true" ]] && [[ "$NANO_BRAIN_AUTO_REPAIR" == "true" ]] && [[ "${DOCKER_COMMAND[0]:-}" == "-c" ]]; then
|
|
2391
|
+
DOCKER_COMMAND[1]="$NANO_BRAIN_SHELL_HOOK ${DOCKER_COMMAND[1]}"
|
|
2392
|
+
fi
|
|
2393
|
+
|
|
2335
2394
|
if [[ "$SHELL_MODE" != "true" ]] && is_nano_brain_command; then
|
|
2336
2395
|
if [[ "$NANO_BRAIN_AUTO_REPAIR" == "true" ]]; then
|
|
2337
2396
|
ENTRYPOINT_OVERRIDE="--entrypoint bash"
|
|
@@ -90,6 +90,7 @@ RUN mkdir -p /opt/playwright-browsers && \
|
|
|
90
90
|
ENV CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=1
|
|
91
91
|
RUN npm install -g chrome-devtools-mcp@latest && \
|
|
92
92
|
touch /opt/.mcp-chrome-devtools-installed
|
|
93
|
+
RUN touch /opt/.mcp-playwright-installed
|
|
93
94
|
|
|
94
95
|
# Create workspace
|
|
95
96
|
WORKDIR /workspace
|
|
@@ -90,6 +90,7 @@ RUN mkdir -p /opt/playwright-browsers && \
|
|
|
90
90
|
ENV CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=1
|
|
91
91
|
RUN npm install -g chrome-devtools-mcp@latest && \
|
|
92
92
|
touch /opt/.mcp-chrome-devtools-installed
|
|
93
|
+
RUN touch /opt/.mcp-playwright-installed
|
|
93
94
|
|
|
94
95
|
# Create workspace
|
|
95
96
|
WORKDIR /workspace
|
package/package.json
CHANGED