enable debugging through sandbox (#88)
This commit is contained in:
parent
53a5728009
commit
2571e07175
|
@ -11,7 +11,7 @@
|
||||||
"clean": "scripts/clean.sh",
|
"clean": "scripts/clean.sh",
|
||||||
"test": "npm run test --workspaces",
|
"test": "npm run test --workspaces",
|
||||||
"start": "scripts/start.sh",
|
"start": "scripts/start.sh",
|
||||||
"debug": "scripts/debug.sh",
|
"debug": "DEBUG=1 scripts/start.sh",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
"lint": "eslint . --ext .ts,.tsx",
|
"lint": "eslint . --ext .ts,.tsx",
|
||||||
"typecheck": "tsc --noEmit --jsx react",
|
"typecheck": "tsc --noEmit --jsx react",
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Copyright 2025 Google LLC
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
node ./scripts/check-build-status.js
|
|
||||||
node --inspect-brk node_modules/@gemini-code/cli "$@"
|
|
|
@ -25,5 +25,9 @@ if [[ "${GEMINI_CODE_SANDBOX:-}" =~ ^(1|true)$ ]] || \
|
||||||
scripts/start_sandbox.sh "$@"
|
scripts/start_sandbox.sh "$@"
|
||||||
else
|
else
|
||||||
echo "WARNING: running outside of sandbox. Set GEMINI_CODE_SANDBOX to enable sandbox."
|
echo "WARNING: running outside of sandbox. Set GEMINI_CODE_SANDBOX to enable sandbox."
|
||||||
|
if [ -n "${DEBUG:-}" ]; then
|
||||||
|
node --inspect-brk node_modules/@gemini-code/cli "$@"
|
||||||
|
else
|
||||||
node node_modules/@gemini-code/cli "$@"
|
node node_modules/@gemini-code/cli "$@"
|
||||||
fi
|
fi
|
||||||
|
fi
|
|
@ -17,7 +17,8 @@ set -euo pipefail
|
||||||
|
|
||||||
IMAGE=gemini-code-sandbox
|
IMAGE=gemini-code-sandbox
|
||||||
WORKDIR=/sandbox/$(basename "$PWD")
|
WORKDIR=/sandbox/$(basename "$PWD")
|
||||||
CLI_DIST=/usr/local/share/npm-global/lib/node_modules/\@gemini-code/cli
|
CLI_PATH=/usr/local/share/npm-global/lib/node_modules/\@gemini-code/cli
|
||||||
|
DEBUG_PORT=9229
|
||||||
|
|
||||||
# use docker if installed, otherwise try to use podman instead
|
# use docker if installed, otherwise try to use podman instead
|
||||||
if command -v docker &> /dev/null; then
|
if command -v docker &> /dev/null; then
|
||||||
|
@ -42,6 +43,14 @@ while $CMD ps -a --format "{{.Names}}" | grep -q "$IMAGE-$INDEX"; do
|
||||||
done
|
done
|
||||||
run_args+=(--name "$IMAGE-$INDEX")
|
run_args+=(--name "$IMAGE-$INDEX")
|
||||||
|
|
||||||
|
# enable debugging via node --inspect-brk (and $DEBUG_PORT) if DEBUG is set
|
||||||
|
node_args=()
|
||||||
|
if [ -n "${DEBUG:-}" ]; then
|
||||||
|
node_args+=(--inspect-brk="0.0.0.0:$DEBUG_PORT")
|
||||||
|
run_args+=(-p "$DEBUG_PORT:$DEBUG_PORT")
|
||||||
|
fi
|
||||||
|
node_args+=("$CLI_PATH" "$@")
|
||||||
|
|
||||||
# run gemini-code in sandbox container
|
# run gemini-code in sandbox container
|
||||||
# use empty --authfile to skip unnecessary auth refresh overhead
|
# use empty --authfile to skip unnecessary auth refresh overhead
|
||||||
$CMD run "${run_args[@]}" --authfile <(echo '{}') --workdir "$WORKDIR" "$IMAGE" node "$CLI_DIST" "$@"
|
$CMD run "${run_args[@]}" --init --authfile <(echo '{}') --workdir "$WORKDIR" "$IMAGE" node "${node_args[@]}"
|
Loading…
Reference in New Issue