sandboxbox 2.4.8 → 2.5.0

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": "2.4.8",
3
+ "version": "2.5.0",
4
4
  "description": "Portable container runner with Podman - Claude Code & Playwright support. Works on Windows, macOS, and Linux.",
5
5
  "type": "module",
6
6
  "main": "cli.js",
@@ -86,12 +86,20 @@ export function runCommand(projectDir, cmd = 'bash') {
86
86
  while (retries < maxRetries) {
87
87
  try {
88
88
  // Try container operation first
89
- execSync(`"${podmanPath}" run --rm -it ${mounts.join(' ')} -w /workspace sandboxbox:latest ${cmd}`, {
90
- stdio: 'inherit',
89
+ const containerOptions = {
90
+ stdio: process.platform === 'win32' ? ['pipe', 'pipe', 'pipe'] : 'inherit',
91
91
  shell: process.platform === 'win32',
92
92
  windowsHide: process.platform === 'win32',
93
93
  timeout: 30000 // 30 second timeout
94
- });
94
+ };
95
+
96
+ // For echo command, use non-interactive mode
97
+ if (cmd === 'echo' || cmd.startsWith('echo ')) {
98
+ const echoCmd = cmd.replace('echo ', '');
99
+ execSync(`"${podmanPath}" run --rm ${mounts.join(' ')} -w /workspace sandboxbox:latest echo ${echoCmd}`, containerOptions);
100
+ } else {
101
+ execSync(`"${podmanPath}" run --rm -it ${mounts.join(' ')} -w /workspace sandboxbox:latest ${cmd}`, containerOptions);
102
+ }
95
103
 
96
104
  cleanup();
97
105
  console.log(color('green', '\n✅ Container execution completed! (Isolated - no host changes)'));
@@ -104,14 +112,7 @@ export function runCommand(projectDir, cmd = 'bash') {
104
112
  // Actually initialize the machine instead of just waiting
105
113
  if (process.platform === 'win32') {
106
114
  try {
107
- console.log(color('cyan', ' Initializing Podman machine...'));
108
- execSync(`"${podmanPath}" machine init --rootful=false`, {
109
- stdio: 'pipe',
110
- shell: true,
111
- windowsHide: true,
112
- timeout: 180000 // 3 minutes for machine init
113
- });
114
-
115
+ // First try to start existing machine
115
116
  console.log(color('cyan', ' Starting Podman machine...'));
116
117
  execSync(`"${podmanPath}" machine start`, {
117
118
  stdio: 'pipe',
@@ -120,10 +121,42 @@ export function runCommand(projectDir, cmd = 'bash') {
120
121
  timeout: 60000 // 1 minute for machine start
121
122
  });
122
123
 
123
- console.log(color('green', ' ✅ Podman machine ready!'));
124
- continue; // Try container again immediately
125
- } catch (machineError) {
126
- console.log(color('red', ` Machine setup failed: ${machineError.message}`));
124
+ console.log(color('green', ' ✅ Podman machine started!'));
125
+ // Wait a bit more for machine to be fully ready
126
+ console.log(color('cyan', ' Waiting 5 seconds for machine to fully initialize...'));
127
+ const readyStart = Date.now();
128
+ while (Date.now() - readyStart < 5000) {
129
+ // Wait 5 seconds
130
+ }
131
+ continue; // Try container again
132
+ } catch (startError) {
133
+ // Machine doesn't exist or failed to start, try initializing it
134
+ if (startError.message.includes('does not exist') || startError.message.includes('not found')) {
135
+ try {
136
+ console.log(color('cyan', ' Initializing new Podman machine...'));
137
+ execSync(`"${podmanPath}" machine init --rootful=false`, {
138
+ stdio: 'pipe',
139
+ shell: true,
140
+ windowsHide: true,
141
+ timeout: 180000 // 3 minutes for machine init
142
+ });
143
+
144
+ console.log(color('cyan', ' Starting new Podman machine...'));
145
+ execSync(`"${podmanPath}" machine start`, {
146
+ stdio: 'pipe',
147
+ shell: true,
148
+ windowsHide: true,
149
+ timeout: 60000 // 1 minute for machine start
150
+ });
151
+
152
+ console.log(color('green', ' ✅ Podman machine ready!'));
153
+ continue; // Try container again immediately
154
+ } catch (initError) {
155
+ console.log(color('red', ` Machine init failed: ${initError.message}`));
156
+ }
157
+ } else {
158
+ console.log(color('red', ` Machine start failed: ${startError.message}`));
159
+ }
127
160
  }
128
161
  }
129
162
 
@@ -173,7 +206,7 @@ export function shellCommand(projectDir) {
173
206
  while (retries < maxRetries) {
174
207
  try {
175
208
  execSync(`"${podmanPath}" run --rm -it ${mounts.join(' ')} -w /workspace sandboxbox:latest /bin/bash`, {
176
- stdio: 'inherit',
209
+ stdio: process.platform === 'win32' ? ['pipe', 'pipe', 'pipe'] : 'inherit',
177
210
  shell: process.platform === 'win32',
178
211
  windowsHide: process.platform === 'win32',
179
212
  timeout: 30000 // 30 second timeout
@@ -189,14 +222,7 @@ export function shellCommand(projectDir) {
189
222
  // Actually initialize the machine instead of just waiting
190
223
  if (process.platform === 'win32') {
191
224
  try {
192
- console.log(color('cyan', ' Initializing Podman machine...'));
193
- execSync(`"${podmanPath}" machine init --rootful=false`, {
194
- stdio: 'pipe',
195
- shell: true,
196
- windowsHide: true,
197
- timeout: 180000 // 3 minutes for machine init
198
- });
199
-
225
+ // First try to start existing machine
200
226
  console.log(color('cyan', ' Starting Podman machine...'));
201
227
  execSync(`"${podmanPath}" machine start`, {
202
228
  stdio: 'pipe',
@@ -205,10 +231,42 @@ export function shellCommand(projectDir) {
205
231
  timeout: 60000 // 1 minute for machine start
206
232
  });
207
233
 
208
- console.log(color('green', ' ✅ Podman machine ready!'));
209
- continue; // Try container again immediately
210
- } catch (machineError) {
211
- console.log(color('red', ` Machine setup failed: ${machineError.message}`));
234
+ console.log(color('green', ' ✅ Podman machine started!'));
235
+ // Wait a bit more for machine to be fully ready
236
+ console.log(color('cyan', ' Waiting 5 seconds for machine to fully initialize...'));
237
+ const readyStart = Date.now();
238
+ while (Date.now() - readyStart < 5000) {
239
+ // Wait 5 seconds
240
+ }
241
+ continue; // Try container again
242
+ } catch (startError) {
243
+ // Machine doesn't exist or failed to start, try initializing it
244
+ if (startError.message.includes('does not exist') || startError.message.includes('not found')) {
245
+ try {
246
+ console.log(color('cyan', ' Initializing new Podman machine...'));
247
+ execSync(`"${podmanPath}" machine init --rootful=false`, {
248
+ stdio: 'pipe',
249
+ shell: true,
250
+ windowsHide: true,
251
+ timeout: 180000 // 3 minutes for machine init
252
+ });
253
+
254
+ console.log(color('cyan', ' Starting new Podman machine...'));
255
+ execSync(`"${podmanPath}" machine start`, {
256
+ stdio: 'pipe',
257
+ shell: true,
258
+ windowsHide: true,
259
+ timeout: 60000 // 1 minute for machine start
260
+ });
261
+
262
+ console.log(color('green', ' ✅ Podman machine ready!'));
263
+ continue; // Try container again immediately
264
+ } catch (initError) {
265
+ console.log(color('red', ` Machine init failed: ${initError.message}`));
266
+ }
267
+ } else {
268
+ console.log(color('red', ` Machine start failed: ${startError.message}`));
269
+ }
212
270
  }
213
271
  }
214
272