rename dev image with -dev suffix (#195)
This commit is contained in:
parent
a8f679ccb5
commit
491a9da80b
|
@ -57,16 +57,6 @@ function start_sandbox(sandbox: string) {
|
||||||
// determine full path for gemini-code to distinguish linked vs installed setting
|
// determine full path for gemini-code to distinguish linked vs installed setting
|
||||||
const gcPath = execSync(`realpath $(which gemini-code)`).toString().trim();
|
const gcPath = execSync(`realpath $(which gemini-code)`).toString().trim();
|
||||||
|
|
||||||
// stop if image is missing
|
|
||||||
const image = 'gemini-code-sandbox';
|
|
||||||
if (!execSync(`${sandbox} images -q ${image}`).toString().trim()) {
|
|
||||||
const remedy = gcPath.includes('gemini-code/packages/')
|
|
||||||
? 'Try `scripts/build_sandbox.sh` under gemini-code repo.'
|
|
||||||
: 'Please notify gemini-code-dev@google.com.';
|
|
||||||
console.error(`ERROR: ${image} is missing. ${remedy}`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// stop if debugging in sandbox using linked/installed gemini-code
|
// stop if debugging in sandbox using linked/installed gemini-code
|
||||||
// note this is because it does not work (unclear why, parent process interferes somehow)
|
// note this is because it does not work (unclear why, parent process interferes somehow)
|
||||||
// note `npm run debug` runs sandbox directly and avoids any interference from parent process
|
// note `npm run debug` runs sandbox directly and avoids any interference from parent process
|
||||||
|
@ -78,17 +68,31 @@ function start_sandbox(sandbox: string) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if project is gemini-code, then run sandboxed CLI from ${workdir}/packages/cli
|
// if project is gemini-code, then switch to -dev image & run CLI from ${workdir}/packages/cli
|
||||||
// otherwise refuse debug mode (see comments in launch.json around remoteRoot)
|
let image = 'gemini-code-sandbox';
|
||||||
const project = path.basename(process.cwd());
|
const project = path.basename(process.cwd());
|
||||||
const workdir = `/sandbox/${project}`;
|
const workdir = `/sandbox/${project}`;
|
||||||
let cliPath = '/usr/local/share/npm-global/lib/node_modules/@gemini-code/cli';
|
let cliPath = '/usr/local/share/npm-global/lib/node_modules/@gemini-code/cli';
|
||||||
if (project === 'gemini-code') {
|
if (project === 'gemini-code') {
|
||||||
|
image += '-dev';
|
||||||
cliPath = `${workdir}/packages/cli`;
|
cliPath = `${workdir}/packages/cli`;
|
||||||
} else if (process.env.DEBUG) {
|
} else {
|
||||||
|
// refuse to debug using global installation for now (can be added later)
|
||||||
|
// (requires a separate attach config, see comments in launch.json around remoteRoot)
|
||||||
|
if (process.env.DEBUG) {
|
||||||
console.error('ERROR: cannot debug in sandbox outside gemini-code repo');
|
console.error('ERROR: cannot debug in sandbox outside gemini-code repo');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop if image is missing
|
||||||
|
if (!execSync(`${sandbox} images -q ${image}`).toString().trim()) {
|
||||||
|
const remedy = gcPath.includes('gemini-code/packages/')
|
||||||
|
? 'Try `scripts/build_sandbox.sh` under gemini-code repo.'
|
||||||
|
: 'Please notify gemini-code-dev@google.com.';
|
||||||
|
console.error(`ERROR: ${image} is missing. ${remedy}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// use interactive tty mode and auto-remove container on exit
|
// use interactive tty mode and auto-remove container on exit
|
||||||
// run init binary inside container to forward signals & reap zombies
|
// run init binary inside container to forward signals & reap zombies
|
||||||
|
|
|
@ -24,6 +24,7 @@ export interface ShellToolParams {
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
|
|
||||||
export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
|
export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
|
||||||
|
// name should match TerminalTool.Name used in prompts.ts for now
|
||||||
static Name: string = 'execute_bash_command';
|
static Name: string = 'execute_bash_command';
|
||||||
private readonly config: Config;
|
private readonly config: Config;
|
||||||
private whitelist: Set<string> = new Set();
|
private whitelist: Set<string> = new Set();
|
||||||
|
|
|
@ -30,11 +30,14 @@ SKIP_NPM_INSTALL_BUILD=false
|
||||||
while getopts "sd" opt; do
|
while getopts "sd" opt; do
|
||||||
case ${opt} in
|
case ${opt} in
|
||||||
s) SKIP_NPM_INSTALL_BUILD=true ;;
|
s) SKIP_NPM_INSTALL_BUILD=true ;;
|
||||||
d) DOCKERFILE=Dockerfile-dev ;;
|
d)
|
||||||
|
DOCKERFILE=Dockerfile-dev
|
||||||
|
IMAGE+="-dev"
|
||||||
|
;;
|
||||||
\?)
|
\?)
|
||||||
echo "usage: $(basename "$0") [-s] [-d]"
|
echo "usage: $(basename "$0") [-s] [-d]"
|
||||||
echo " -s: skip npm install + npm run build"
|
echo " -s: skip npm install + npm run build"
|
||||||
echo " -d: use Dockerfile-dev"
|
echo " -d: build dev image (using Dockerfile-dev)"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -23,28 +23,27 @@ fi
|
||||||
CMD=$(scripts/sandbox_command.sh)
|
CMD=$(scripts/sandbox_command.sh)
|
||||||
IMAGE=gemini-code-sandbox
|
IMAGE=gemini-code-sandbox
|
||||||
DEBUG_PORT=9229
|
DEBUG_PORT=9229
|
||||||
|
|
||||||
# stop if image is missing
|
|
||||||
if ! $CMD images -q "$IMAGE" | grep -q .; then
|
|
||||||
echo "ERROR: $IMAGE is missing. Try \`npm run build\` with sandboxing enabled."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
PROJECT=$(basename "$PWD")
|
PROJECT=$(basename "$PWD")
|
||||||
WORKDIR=/sandbox/$PROJECT
|
WORKDIR=/sandbox/$PROJECT
|
||||||
CLI_PATH=/usr/local/share/npm-global/lib/node_modules/\@gemini-code/cli
|
CLI_PATH=/usr/local/share/npm-global/lib/node_modules/\@gemini-code/cli
|
||||||
|
|
||||||
# if project is gemini-code, then run CLI from $WORKDIR/packages/cli
|
# if project is gemini-code, then switch to -dev image & run CLI from $WORKDIR/packages/cli
|
||||||
# note this means the global installation is not required in this case
|
|
||||||
if [[ "$PROJECT" == "gemini-code" ]]; then
|
if [[ "$PROJECT" == "gemini-code" ]]; then
|
||||||
|
IMAGE+="-dev"
|
||||||
CLI_PATH="$WORKDIR/packages/cli"
|
CLI_PATH="$WORKDIR/packages/cli"
|
||||||
elif [ -n "${DEBUG:-}" ]; then
|
elif [ -n "${DEBUG:-}" ]; then
|
||||||
# refuse to debug using global installation
|
# refuse to debug using global installation for now (can be added later)
|
||||||
# (requires a separate attach config in launch.json, see comments there around remoteRoot)
|
# (requires a separate attach config, see comments in launch.json around remoteRoot)
|
||||||
echo "ERROR: debugging is sandbox is not supported when target/root is not gemini-code"
|
echo "ERROR: debugging is sandbox is not supported when target/root is not gemini-code"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# stop if image is missing
|
||||||
|
if ! $CMD images -q "$IMAGE" | grep -q .; then
|
||||||
|
echo "ERROR: $IMAGE is missing. Try \`npm run build\` with sandboxing enabled."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# use interactive tty mode and auto-remove container on exit
|
# use interactive tty mode and auto-remove container on exit
|
||||||
run_args=(-it --rm)
|
run_args=(-it --rm)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue