summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.json2
-rwxr-xr-xscripts/debug.sh19
-rwxr-xr-xscripts/start.sh6
-rwxr-xr-xscripts/start_sandbox.sh13
4 files changed, 17 insertions, 23 deletions
diff --git a/package.json b/package.json
index c73fa3e5..dd6a23a1 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
"clean": "scripts/clean.sh",
"test": "npm run test --workspaces",
"start": "scripts/start.sh",
- "debug": "scripts/debug.sh",
+ "debug": "DEBUG=1 scripts/start.sh",
"lint:fix": "eslint . --fix",
"lint": "eslint . --ext .ts,.tsx",
"typecheck": "tsc --noEmit --jsx react",
diff --git a/scripts/debug.sh b/scripts/debug.sh
deleted file mode 100755
index d70dd60f..00000000
--- a/scripts/debug.sh
+++ /dev/null
@@ -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 "$@" \ No newline at end of file
diff --git a/scripts/start.sh b/scripts/start.sh
index 441eb754..c4c57f3c 100755
--- a/scripts/start.sh
+++ b/scripts/start.sh
@@ -25,5 +25,9 @@ if [[ "${GEMINI_CODE_SANDBOX:-}" =~ ^(1|true)$ ]] || \
scripts/start_sandbox.sh "$@"
else
echo "WARNING: running outside of sandbox. Set GEMINI_CODE_SANDBOX to enable sandbox."
- node node_modules/@gemini-code/cli "$@"
+ if [ -n "${DEBUG:-}" ]; then
+ node --inspect-brk node_modules/@gemini-code/cli "$@"
+ else
+ node node_modules/@gemini-code/cli "$@"
+ fi
fi \ No newline at end of file
diff --git a/scripts/start_sandbox.sh b/scripts/start_sandbox.sh
index b30e81bf..efa8ecc2 100755
--- a/scripts/start_sandbox.sh
+++ b/scripts/start_sandbox.sh
@@ -17,7 +17,8 @@ set -euo pipefail
IMAGE=gemini-code-sandbox
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
if command -v docker &> /dev/null; then
@@ -42,6 +43,14 @@ while $CMD ps -a --format "{{.Names}}" | grep -q "$IMAGE-$INDEX"; do
done
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
# use empty --authfile to skip unnecessary auth refresh overhead
-$CMD run "${run_args[@]}" --authfile <(echo '{}') --workdir "$WORKDIR" "$IMAGE" node "$CLI_DIST" "$@" \ No newline at end of file
+$CMD run "${run_args[@]}" --init --authfile <(echo '{}') --workdir "$WORKDIR" "$IMAGE" node "${node_args[@]}" \ No newline at end of file