sandboxbox 3.0.13 → 3.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sandboxbox",
3
- "version": "3.0.13",
3
+ "version": "3.0.15",
4
4
  "description": "Lightweight process containment sandbox for CLI tools - Playwright, Claude Code, and more. Pure Node.js, no dependencies.",
5
5
  "type": "module",
6
6
  "main": "cli.js",
package/test.txt ADDED
@@ -0,0 +1 @@
1
+ This is a test file created by Claude Code.
@@ -75,7 +75,8 @@ export async function claudeCommand(projectDir, prompt) {
75
75
  const claudeArgs = [
76
76
  '--verbose',
77
77
  '--output-format', 'stream-json',
78
- '--permission-mode', 'bypassPermissions'
78
+ '--permission-mode', 'bypassPermissions',
79
+ '--allowed-tools', ALLOWED_TOOLS.join(',')
79
80
  ];
80
81
 
81
82
  console.log(color('blue', `📝 Running Claude Code with host settings\n`));
@@ -84,10 +85,16 @@ export async function claudeCommand(projectDir, prompt) {
84
85
  const claudeStartTime = Date.now();
85
86
  console.log(color('cyan', '⏱️ Stage 3: Starting Claude Code...'));
86
87
 
87
- const proc = spawn('sh', ['-c', `cd "${join(sandboxDir, 'workspace')}" && claude ${claudeArgs.join(' ')}`], {
88
+ const workspacePath = join(sandboxDir, 'workspace');
89
+
90
+ // Modify the prompt to include directory change instruction
91
+ const modifiedPrompt = `You are working in a sandboxed environment. Your working directory is "${workspacePath}". All operations should be performed in this directory. ${prompt}`;
92
+
93
+ const proc = spawn('claude', claudeArgs, {
94
+ cwd: workspacePath, // Set working directory directly
88
95
  env: env, // Use the environment directly without modification
89
96
  stdio: ['pipe', 'pipe', 'pipe'],
90
- shell: true, // Use shell for proper directory handling
97
+ shell: false, // Don't use shell since we're setting cwd directly
91
98
  detached: false
92
99
  });
93
100
 
@@ -138,8 +145,10 @@ export async function claudeCommand(projectDir, prompt) {
138
145
  }
139
146
  }
140
147
  } catch (jsonError) {
141
- // Skip malformed JSON lines - might be incomplete chunks
142
- // Silently continue to avoid breaking the stream
148
+ // Log JSON parsing errors for troubleshooting
149
+ console.log(color('red', `🔍 JSON parse error: ${jsonError.message}`));
150
+ console.log(color('yellow', `🔍 Problematic line: ${line}`));
151
+ console.log(color('cyan', '🔍 This suggests an issue with the output stream formatting'));
143
152
  }
144
153
  }
145
154
  }
@@ -150,8 +159,8 @@ export async function claudeCommand(projectDir, prompt) {
150
159
  reject(error);
151
160
  });
152
161
 
153
- // Write prompt to stdin
154
- proc.stdin.write(prompt);
162
+ // Write modified prompt to stdin
163
+ proc.stdin.write(modifiedPrompt);
155
164
  proc.stdin.end();
156
165
 
157
166
  let stdoutOutput = '';
@@ -161,20 +170,6 @@ export async function claudeCommand(projectDir, prompt) {
161
170
  proc.stdout.on('data', (data) => {
162
171
  stdoutOutput += data.toString();
163
172
 
164
- // Check for errors in JSON output with error handling
165
- const lines = data.toString().split('\n').filter(l => l.trim());
166
- for (const line of lines) {
167
- try {
168
- const event = JSON.parse(line);
169
- if (event.type === 'result' && event.is_error) {
170
- lastError = event.result;
171
- }
172
- } catch (jsonError) {
173
- // Ignore JSON parsing errors - might be incomplete chunks
174
- console.error('JSON parse error:', jsonError.message);
175
- }
176
- }
177
-
178
173
  handleStreamingOutput(data);
179
174
  });
180
175
 
package/utils/sandbox.js CHANGED
@@ -30,11 +30,15 @@ export function createSandbox(projectDir) {
30
30
  });
31
31
 
32
32
  // Configure host repository to accept pushes to current branch
33
- execSync(`cd "${projectDir}" && git config receive.denyCurrentBranch updateInstead`, {
34
- stdio: 'pipe',
35
- shell: true,
36
- windowsHide: true
37
- });
33
+ try {
34
+ execSync(`cd "${projectDir}" && git config receive.denyCurrentBranch updateInstead`, {
35
+ stdio: 'pipe',
36
+ shell: true,
37
+ windowsHide: true
38
+ });
39
+ } catch (error) {
40
+ console.log(`⚠️ Warning: Could not configure host repository: ${error.message}`);
41
+ }
38
42
 
39
43
  // Copy/clone the project to workspace
40
44
  if (existsSync(join(projectDir, '.git'))) {
@@ -67,6 +71,7 @@ export function createSandbox(projectDir) {
67
71
  stdio: 'pipe',
68
72
  shell: true
69
73
  });
74
+ console.log(`✅ Configured host directory as remote 'origin': ${projectDir}`);
70
75
  } catch (e) {
71
76
  // Remote already exists, update it
72
77
  execSync(`git remote set-url origin "${projectDir}"`, {
@@ -74,6 +79,7 @@ export function createSandbox(projectDir) {
74
79
  stdio: 'pipe',
75
80
  shell: true
76
81
  });
82
+ console.log(`✅ Updated remote 'origin' to host directory: ${projectDir}`);
77
83
  }
78
84
 
79
85
  // Set up upstream tracking for current branch
@@ -84,6 +90,20 @@ export function createSandbox(projectDir) {
84
90
  stdio: 'pipe'
85
91
  }).trim();
86
92
 
93
+ // Ensure the branch exists on the host side
94
+ try {
95
+ execSync(`cd "${projectDir}" && git checkout ${currentBranch}`, {
96
+ stdio: 'pipe',
97
+ shell: true
98
+ });
99
+ } catch (e) {
100
+ // Branch doesn't exist on host, create it
101
+ execSync(`cd "${projectDir}" && git checkout -b ${currentBranch}`, {
102
+ stdio: 'pipe',
103
+ shell: true
104
+ });
105
+ }
106
+
87
107
  execSync(`git branch --set-upstream-to=origin/${currentBranch} ${currentBranch}`, {
88
108
  cwd: workspaceDir,
89
109
  stdio: 'pipe',
@@ -91,6 +111,7 @@ export function createSandbox(projectDir) {
91
111
  });
92
112
  } catch (e) {
93
113
  // Upstream may not exist yet, ignore error
114
+ console.log(`⚠️ Warning: Could not set up upstream tracking: ${e.message}`);
94
115
  }
95
116
 
96
117
  // Batch fetch git identity settings for efficiency
package/.vexify.db DELETED
Binary file