Skip to content

Commit 73ca583

Browse files
davila7claude
andcommitted
Fix unwanted prompt confirmation dialog when using --sandbox
Problem: When using --sandbox with --prompt, the system was showing "Do you want to execute this prompt in Claude Code?" confirmation dialog after installing the agent, even though sandbox mode should handle the prompt execution directly. Root Cause: The issue existed since the beginning. When --sandbox installs an agent internally, the installIndividualComponents() function was also checking for options.prompt and calling handlePromptExecution(), creating a duplicate prompt handling path. Solution: Added !options.sandbox condition to all three locations where handlePromptExecution() is called: 1. Main template installation flow (line 372) 2. Individual components installation (line 1454) 3. Workflow components installation (line 1623) This ensures prompt execution only happens in regular mode, not sandbox mode. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7ed71b4 commit 73ca583

File tree

1 file changed

+49
-43
lines changed

1 file changed

+49
-43
lines changed

cli-tool/src/index.js

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ async function createClaudeConfig(options = {}) {
368368
await runPostInstallationValidation(targetDir, templateConfig);
369369
}
370370

371-
// Handle prompt execution if provided
372-
if (options.prompt) {
371+
// Handle prompt execution if provided (but not in sandbox mode)
372+
if (options.prompt && !options.sandbox) {
373373
await handlePromptExecution(options.prompt, targetDir);
374374
}
375375
}
@@ -1450,8 +1450,8 @@ async function installMultipleComponents(options, targetDir) {
14501450

14511451
// Note: Individual components are already tracked separately in their installation functions
14521452

1453-
// Handle prompt execution if provided
1454-
if (options.prompt) {
1453+
// Handle prompt execution if provided (but not in sandbox mode)
1454+
if (options.prompt && !options.sandbox) {
14551455
await handlePromptExecution(options.prompt, targetDir);
14561456
}
14571457

@@ -1619,8 +1619,8 @@ async function installWorkflow(workflowHash, targetDir, options) {
16191619
target_directory: path.relative(process.cwd(), targetDir)
16201620
});
16211621

1622-
// Handle prompt execution if provided
1623-
if (options.prompt) {
1622+
// Handle prompt execution if provided (but not in sandbox mode)
1623+
if (options.prompt && !options.sandbox) {
16241624
await handlePromptExecution(options.prompt, targetDir);
16251625
}
16261626

@@ -2239,43 +2239,49 @@ async function executeSandbox(options, targetDir) {
22392239
console.log(chalk.gray(`📦 Components to install:${componentsToInstall}`));
22402240
}
22412241

2242-
const sandboxExecution = spawn(pythonCmd, [
2243-
path.join(sandboxDir, 'e2b-launcher.py'),
2244-
prompt,
2245-
componentsToInstall.trim(),
2246-
e2bKey,
2247-
anthropicKey
2248-
], {
2249-
cwd: sandboxDir,
2250-
stdio: 'inherit',
2251-
timeout: 900000, // 15 minutes timeout for complex operations
2252-
env: {
2253-
...process.env,
2254-
E2B_API_KEY: e2bKey,
2255-
ANTHROPIC_API_KEY: anthropicKey
2256-
}
2257-
});
2258-
2259-
sandboxExecution.on('close', (sandboxCode) => {
2260-
if (sandboxCode === 0) {
2261-
console.log(chalk.green('🎉 Sandbox execution completed successfully!'));
2262-
console.log(chalk.blue('💡 Files were created inside the E2B sandbox environment'));
2263-
} else {
2264-
console.log(chalk.yellow(`⚠️ Sandbox execution finished with exit code ${sandboxCode}`));
2265-
console.log(chalk.gray('💡 Check the output above for any error details'));
2266-
}
2267-
});
2268-
2269-
sandboxExecution.on('error', (error) => {
2270-
if (error.code === 'TIMEOUT') {
2271-
console.log(chalk.yellow('⏱️ Sandbox execution timed out after 15 minutes'));
2272-
console.log(chalk.gray('💡 This may happen with very complex prompts or large projects'));
2273-
console.log(chalk.blue('💡 Try breaking down your prompt into smaller, more specific requests'));
2274-
} else {
2275-
console.log(chalk.red(`❌ Error executing sandbox: ${error.message}`));
2276-
console.log(chalk.yellow('💡 Make sure you have set E2B_API_KEY and ANTHROPIC_API_KEY environment variables'));
2277-
console.log(chalk.gray(' Create a .env file in the .claude/sandbox directory with your API keys'));
2278-
}
2242+
// Execute sandbox and wait for completion
2243+
await new Promise((resolve, reject) => {
2244+
const sandboxExecution = spawn(pythonCmd, [
2245+
path.join(sandboxDir, 'e2b-launcher.py'),
2246+
prompt,
2247+
componentsToInstall.trim(),
2248+
e2bKey,
2249+
anthropicKey
2250+
], {
2251+
cwd: sandboxDir,
2252+
stdio: 'inherit',
2253+
timeout: 900000, // 15 minutes timeout for complex operations
2254+
env: {
2255+
...process.env,
2256+
E2B_API_KEY: e2bKey,
2257+
ANTHROPIC_API_KEY: anthropicKey
2258+
}
2259+
});
2260+
2261+
sandboxExecution.on('close', (sandboxCode) => {
2262+
if (sandboxCode === 0) {
2263+
console.log(chalk.green('🎉 Sandbox execution completed successfully!'));
2264+
console.log(chalk.blue('💡 Files were created inside the E2B sandbox environment'));
2265+
resolve();
2266+
} else {
2267+
console.log(chalk.yellow(`⚠️ Sandbox execution finished with exit code ${sandboxCode}`));
2268+
console.log(chalk.gray('💡 Check the output above for any error details'));
2269+
resolve(); // Still resolve even with non-zero exit code
2270+
}
2271+
});
2272+
2273+
sandboxExecution.on('error', (error) => {
2274+
if (error.code === 'TIMEOUT') {
2275+
console.log(chalk.yellow('⏱️ Sandbox execution timed out after 15 minutes'));
2276+
console.log(chalk.gray('💡 This may happen with very complex prompts or large projects'));
2277+
console.log(chalk.blue('💡 Try breaking down your prompt into smaller, more specific requests'));
2278+
} else {
2279+
console.log(chalk.red(`❌ Error executing sandbox: ${error.message}`));
2280+
console.log(chalk.yellow('💡 Make sure you have set E2B_API_KEY and ANTHROPIC_API_KEY environment variables'));
2281+
console.log(chalk.gray(' Create a .env file in the .claude/sandbox directory with your API keys'));
2282+
}
2283+
reject(error);
2284+
});
22792285
});
22802286

22812287
} else {

0 commit comments

Comments
 (0)