sandboxbox 3.0.18 → 3.0.20
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 +1 -1
- package/utils/claude-optimizer.js +1 -3
- package/utils/commands/claude.js +27 -46
- package/utils/sandbox.js +2 -9
- package/utils/system-optimizer.js +5 -14
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ export class ClaudeOptimizer {
|
|
|
17
17
|
try {
|
|
18
18
|
settings = JSON.parse(require('fs').readFileSync(settingsPath, 'utf8'));
|
|
19
19
|
} catch (e) {
|
|
20
|
-
|
|
20
|
+
// Silently create default settings
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -56,14 +56,12 @@ export class ClaudeOptimizer {
|
|
|
56
56
|
|
|
57
57
|
// Write optimized settings
|
|
58
58
|
writeFileSync(settingsPath, JSON.stringify(optimizedSettings, null, 2));
|
|
59
|
-
console.log('✅ Applied Claude startup optimizations');
|
|
60
59
|
|
|
61
60
|
return optimizedSettings;
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
// Pre-warm plugin connections
|
|
65
64
|
async prewarmPlugins() {
|
|
66
|
-
console.log('🔥 Pre-warming Claude plugins...');
|
|
67
65
|
|
|
68
66
|
const prewarmScript = `
|
|
69
67
|
# Pre-warm script for Claude plugins
|
package/utils/commands/claude.js
CHANGED
|
@@ -236,10 +236,7 @@ export async function claudeCommand(projectDir, prompt) {
|
|
|
236
236
|
|
|
237
237
|
// Note: We don't require git repository anymore - the sandbox will initialize it if needed
|
|
238
238
|
|
|
239
|
-
|
|
240
|
-
console.log(color('yellow', `Project: ${projectDir}`));
|
|
241
|
-
console.log(color('yellow', `Prompt: ${prompt}`));
|
|
242
|
-
console.log('');
|
|
239
|
+
// Silent start - only show conversation unless verbose
|
|
243
240
|
|
|
244
241
|
const startTime = Date.now();
|
|
245
242
|
if (VERBOSE_OUTPUT) console.log(color('cyan', '⏱️ Stage 1: Creating sandbox...'));
|
|
@@ -280,8 +277,6 @@ export async function claudeCommand(projectDir, prompt) {
|
|
|
280
277
|
console.log(color('yellow', `🚀 System-level optimizations applied`));
|
|
281
278
|
}
|
|
282
279
|
|
|
283
|
-
if (VERBOSE_OUTPUT) console.log(color('cyan', `📦 Using host Claude settings with all available tools\n`));
|
|
284
|
-
|
|
285
280
|
const claudeArgs = [
|
|
286
281
|
'--verbose',
|
|
287
282
|
'--output-format', 'stream-json',
|
|
@@ -289,11 +284,9 @@ export async function claudeCommand(projectDir, prompt) {
|
|
|
289
284
|
'--allowed-tools', ALLOWED_TOOLS.join(',')
|
|
290
285
|
];
|
|
291
286
|
|
|
292
|
-
if (VERBOSE_OUTPUT) console.log(color('blue', `📝 Running Claude Code with host settings\n`));
|
|
293
|
-
|
|
294
287
|
return new Promise((resolve, reject) => {
|
|
295
288
|
const claudeStartTime = Date.now();
|
|
296
|
-
console.log(color('cyan', '⏱️ Stage 3: Starting Claude Code...'));
|
|
289
|
+
if (VERBOSE_OUTPUT) console.log(color('cyan', '⏱️ Stage 3: Starting Claude Code...'));
|
|
297
290
|
|
|
298
291
|
const workspacePath = join(sandboxDir, 'workspace');
|
|
299
292
|
|
|
@@ -320,32 +313,18 @@ export async function claudeCommand(projectDir, prompt) {
|
|
|
320
313
|
}
|
|
321
314
|
if (VERBOSE_OUTPUT) console.log(color('green', `✅ Session started (${event.session_id.substring(0, 8)}...)`));
|
|
322
315
|
if (VERBOSE_OUTPUT) console.log(color('cyan', `📦 Model: ${event.model}`));
|
|
323
|
-
console.log(color('cyan', `🔧 Tools: ${event.tools.length} available`));
|
|
324
316
|
|
|
325
|
-
//
|
|
326
|
-
if (event.tools.length
|
|
327
|
-
console.log(color('yellow', `⚠️
|
|
328
|
-
console.log(color('yellow', `⚠️ Host settings should provide 39 tools with MCP plugins`));
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// List available tools
|
|
332
|
-
if (event.tools && event.tools.length > 0) {
|
|
333
|
-
const toolNames = event.tools.map(tool => tool.name || tool).sort();
|
|
334
|
-
console.log(color('yellow', ` Available: ${toolNames.join(', ')}\n`));
|
|
335
|
-
} else {
|
|
336
|
-
console.log('');
|
|
317
|
+
// Simple tool count warning only if less than 15 tools
|
|
318
|
+
if (event.tools.length < 15) {
|
|
319
|
+
console.log(color('yellow', `⚠️ Only ${event.tools.length} tools available`));
|
|
337
320
|
}
|
|
338
321
|
} else if (event.type === 'assistant' && event.message) {
|
|
339
322
|
const content = event.message.content;
|
|
340
323
|
if (Array.isArray(content)) {
|
|
341
324
|
for (const block of content) {
|
|
342
325
|
if (block.type === 'text') {
|
|
343
|
-
//
|
|
344
|
-
|
|
345
|
-
process.stdout.write(block.text);
|
|
346
|
-
} else {
|
|
347
|
-
logConversationalText(block.text);
|
|
348
|
-
}
|
|
326
|
+
// Always show conversational text immediately
|
|
327
|
+
process.stdout.write(block.text);
|
|
349
328
|
} else if (block.type === 'tool_use') {
|
|
350
329
|
// Track the tool call for later result matching
|
|
351
330
|
if (block.id) {
|
|
@@ -377,10 +356,12 @@ export async function claudeCommand(projectDir, prompt) {
|
|
|
377
356
|
} else if (event.type === 'result') {
|
|
378
357
|
const usage = event.usage || {};
|
|
379
358
|
const cost = event.total_cost_usd || 0;
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
359
|
+
if (VERBOSE_OUTPUT) {
|
|
360
|
+
console.log(color('green', `\n\n✅ Completed in ${event.duration_ms}ms`));
|
|
361
|
+
console.log(color('yellow', `💰 Cost: $${cost.toFixed(4)}`));
|
|
362
|
+
if (usage.input_tokens) {
|
|
363
|
+
console.log(color('cyan', `📊 Tokens: ${usage.input_tokens} in, ${usage.output_tokens} out`));
|
|
364
|
+
}
|
|
384
365
|
}
|
|
385
366
|
}
|
|
386
367
|
}
|
|
@@ -439,7 +420,7 @@ export async function claudeCommand(projectDir, prompt) {
|
|
|
439
420
|
proc.on('close', (code) => {
|
|
440
421
|
const sessionEndTime = Date.now();
|
|
441
422
|
const totalTime = sessionEndTime - startTime;
|
|
442
|
-
console.log(color('cyan', `\n⏱️ Stage 4: Session completed in ${totalTime}ms`));
|
|
423
|
+
if (VERBOSE_OUTPUT) console.log(color('cyan', `\n⏱️ Stage 4: Session completed in ${totalTime}ms`));
|
|
443
424
|
|
|
444
425
|
// Try to parse any remaining data in buffer
|
|
445
426
|
if (jsonBuffer.trim()) {
|
|
@@ -452,19 +433,19 @@ export async function claudeCommand(projectDir, prompt) {
|
|
|
452
433
|
}
|
|
453
434
|
}
|
|
454
435
|
|
|
455
|
-
// Display recent tool calls
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
436
|
+
// Display recent tool calls and performance summary only if verbose
|
|
437
|
+
if (VERBOSE_OUTPUT) {
|
|
438
|
+
displayRecentToolCalls();
|
|
439
|
+
console.log(color('cyan', `\n📊 Performance Summary:`));
|
|
440
|
+
console.log(color('cyan', ` • Sandbox creation: ${sandboxCreateTime}ms`));
|
|
441
|
+
console.log(color('cyan', ` • Environment setup: ${envCreateTime}ms`));
|
|
442
|
+
console.log(color('cyan', ` • Claude Code session: ${totalTime - sandboxCreateTime - envCreateTime}ms`));
|
|
443
|
+
console.log(color('cyan', ` • Total time: ${totalTime}ms`));
|
|
444
|
+
|
|
445
|
+
// Log file information if enabled
|
|
446
|
+
if (ENABLE_FILE_LOGGING && global.logFileHandle) {
|
|
447
|
+
console.log(color('yellow', `📝 Tool calls logged to: ${global.logFileHandle}`));
|
|
448
|
+
}
|
|
468
449
|
}
|
|
469
450
|
|
|
470
451
|
cleanup();
|
package/utils/sandbox.js
CHANGED
|
@@ -37,7 +37,7 @@ export function createSandbox(projectDir) {
|
|
|
37
37
|
windowsHide: true
|
|
38
38
|
});
|
|
39
39
|
} catch (error) {
|
|
40
|
-
|
|
40
|
+
// Silently skip repository configuration
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// Copy/clone the project to workspace
|
|
@@ -71,7 +71,6 @@ export function createSandbox(projectDir) {
|
|
|
71
71
|
stdio: 'pipe',
|
|
72
72
|
shell: true
|
|
73
73
|
});
|
|
74
|
-
console.log(`✅ Configured host directory as remote 'origin': ${projectDir}`);
|
|
75
74
|
} catch (e) {
|
|
76
75
|
// Remote already exists, update it
|
|
77
76
|
execSync(`git remote set-url origin "${projectDir}"`, {
|
|
@@ -79,10 +78,7 @@ export function createSandbox(projectDir) {
|
|
|
79
78
|
stdio: 'pipe',
|
|
80
79
|
shell: true
|
|
81
80
|
});
|
|
82
|
-
|
|
83
|
-
if (VERBOSE_OUTPUT) {
|
|
84
|
-
console.log(`✅ Updated remote 'origin' to host directory: ${projectDir}`);
|
|
85
|
-
}
|
|
81
|
+
// Remote updated silently
|
|
86
82
|
}
|
|
87
83
|
|
|
88
84
|
// Set up upstream tracking for current branch
|
|
@@ -114,7 +110,6 @@ export function createSandbox(projectDir) {
|
|
|
114
110
|
});
|
|
115
111
|
} catch (e) {
|
|
116
112
|
// Upstream may not exist yet, ignore error
|
|
117
|
-
console.log(`⚠️ Warning: Could not set up upstream tracking: ${e.message}`);
|
|
118
113
|
}
|
|
119
114
|
|
|
120
115
|
// Batch fetch git identity settings for efficiency
|
|
@@ -142,10 +137,8 @@ export function createSandbox(projectDir) {
|
|
|
142
137
|
try {
|
|
143
138
|
// Create symbolic link to host .claude directory
|
|
144
139
|
symlinkSync(hostClaudeDir, sandboxClaudeDir, 'dir');
|
|
145
|
-
console.log('✅ Linked to host Claude settings directory');
|
|
146
140
|
} catch (error) {
|
|
147
141
|
// Fallback to copying if symlink fails
|
|
148
|
-
console.log('⚠️ Could not create symlink, copying Claude settings instead');
|
|
149
142
|
mkdirSync(sandboxClaudeDir, { recursive: true });
|
|
150
143
|
|
|
151
144
|
// Copy only essential files (avoid large files like history)
|
|
@@ -18,10 +18,7 @@ export class SystemOptimizer {
|
|
|
18
18
|
|
|
19
19
|
// Optimize system for Claude Code performance
|
|
20
20
|
async optimizeSystem() {
|
|
21
|
-
console.log('🚀 Applying system-level optimizations...');
|
|
22
|
-
|
|
23
21
|
if (!this.hasSudo) {
|
|
24
|
-
console.log('⚠️ No sudo access, skipping system optimizations');
|
|
25
22
|
return false;
|
|
26
23
|
}
|
|
27
24
|
|
|
@@ -36,7 +33,6 @@ export class SystemOptimizer {
|
|
|
36
33
|
const results = await Promise.allSettled(optimizations);
|
|
37
34
|
const successCount = results.filter(r => r.status === 'fulfilled').length;
|
|
38
35
|
|
|
39
|
-
console.log(`✅ Applied ${successCount}/${optimizations.length} system optimizations`);
|
|
40
36
|
return successCount > 0;
|
|
41
37
|
}
|
|
42
38
|
|
|
@@ -59,10 +55,9 @@ export class SystemOptimizer {
|
|
|
59
55
|
execSync(`sudo ${tweak}`, { stdio: 'pipe' });
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
console.log('✅ Optimized kernel parameters');
|
|
63
58
|
return true;
|
|
64
59
|
} catch (error) {
|
|
65
|
-
|
|
60
|
+
// Silently skip optimization if it fails
|
|
66
61
|
return false;
|
|
67
62
|
}
|
|
68
63
|
}
|
|
@@ -97,10 +92,9 @@ echo "Preloading complete"
|
|
|
97
92
|
// Execute preload script with elevated privileges if needed
|
|
98
93
|
execSync(preloadPath, { stdio: 'pipe' });
|
|
99
94
|
|
|
100
|
-
console.log('✅ Preloaded common libraries');
|
|
101
95
|
return true;
|
|
102
96
|
} catch (error) {
|
|
103
|
-
|
|
97
|
+
// Silently skip optimization if it fails
|
|
104
98
|
return false;
|
|
105
99
|
}
|
|
106
100
|
}
|
|
@@ -121,10 +115,9 @@ echo "Preloading complete"
|
|
|
121
115
|
execSync(`sudo ${opt}`, { stdio: 'pipe' });
|
|
122
116
|
}
|
|
123
117
|
|
|
124
|
-
console.log('✅ Optimized filesystem for Claude');
|
|
125
118
|
return true;
|
|
126
119
|
} catch (error) {
|
|
127
|
-
|
|
120
|
+
// Silently skip optimization if it fails
|
|
128
121
|
return false;
|
|
129
122
|
}
|
|
130
123
|
}
|
|
@@ -180,10 +173,9 @@ echo "Claude pre-warm service ready"
|
|
|
180
173
|
execSync('sudo systemctl enable claude-prewarm.service', { stdio: 'pipe' });
|
|
181
174
|
execSync('sudo systemctl start claude-prewarm.service', { stdio: 'pipe' });
|
|
182
175
|
|
|
183
|
-
console.log('✅ Setup Claude pre-warm service');
|
|
184
176
|
return true;
|
|
185
177
|
} catch (error) {
|
|
186
|
-
|
|
178
|
+
// Silently skip optimization if it fails
|
|
187
179
|
return false;
|
|
188
180
|
}
|
|
189
181
|
}
|
|
@@ -205,10 +197,9 @@ echo "Claude pre-warm service ready"
|
|
|
205
197
|
execSync(`sudo ${opt}`, { stdio: 'pipe' });
|
|
206
198
|
}
|
|
207
199
|
|
|
208
|
-
console.log('✅ Optimized network stack');
|
|
209
200
|
return true;
|
|
210
201
|
} catch (error) {
|
|
211
|
-
|
|
202
|
+
// Silently skip optimization if it fails
|
|
212
203
|
return false;
|
|
213
204
|
}
|
|
214
205
|
}
|