sandboxbox 3.0.3 → 3.0.4
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/commands/claude.js +38 -37
package/package.json
CHANGED
package/utils/commands/claude.js
CHANGED
|
@@ -15,43 +15,6 @@ const ALLOWED_TOOLS = [
|
|
|
15
15
|
'mcp__vexify__search_code'
|
|
16
16
|
];
|
|
17
17
|
|
|
18
|
-
function handleStreamingOutput(data) {
|
|
19
|
-
const lines = data.toString().split('\n').filter(line => line.trim());
|
|
20
|
-
|
|
21
|
-
for (const line of lines) {
|
|
22
|
-
const event = JSON.parse(line);
|
|
23
|
-
|
|
24
|
-
if (event.type === 'system' && event.subtype === 'init') {
|
|
25
|
-
if (!claudeStarted) {
|
|
26
|
-
const claudeCreateTime = Date.now() - claudeStartTime;
|
|
27
|
-
console.log(color('green', `✅ Claude Code started in ${claudeCreateTime}ms`));
|
|
28
|
-
claudeStarted = true;
|
|
29
|
-
}
|
|
30
|
-
console.log(color('green', `✅ Session started (${event.session_id.substring(0, 8)}...)`));
|
|
31
|
-
console.log(color('cyan', `📦 Model: ${event.model}`));
|
|
32
|
-
console.log(color('cyan', `🔧 Tools: ${event.tools.length} available\n`));
|
|
33
|
-
} else if (event.type === 'assistant' && event.message) {
|
|
34
|
-
const content = event.message.content;
|
|
35
|
-
if (Array.isArray(content)) {
|
|
36
|
-
for (const block of content) {
|
|
37
|
-
if (block.type === 'text') {
|
|
38
|
-
process.stdout.write(block.text);
|
|
39
|
-
} else if (block.type === 'tool_use') {
|
|
40
|
-
console.log(color('cyan', `\n🔧 Using tool: ${block.name}`));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
} else if (event.type === 'result') {
|
|
45
|
-
const usage = event.usage || {};
|
|
46
|
-
const cost = event.total_cost_usd || 0;
|
|
47
|
-
console.log(color('green', `\n\n✅ Completed in ${event.duration_ms}ms`));
|
|
48
|
-
console.log(color('yellow', `💰 Cost: $${cost.toFixed(4)}`));
|
|
49
|
-
if (usage.input_tokens) {
|
|
50
|
-
console.log(color('cyan', `📊 Tokens: ${usage.input_tokens} in, ${usage.output_tokens} out`));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
18
|
|
|
56
19
|
export async function claudeCommand(projectDir, prompt) {
|
|
57
20
|
if (!existsSync(projectDir)) {
|
|
@@ -112,6 +75,44 @@ export async function claudeCommand(projectDir, prompt) {
|
|
|
112
75
|
|
|
113
76
|
let claudeStarted = false;
|
|
114
77
|
|
|
78
|
+
function handleStreamingOutput(data) {
|
|
79
|
+
const lines = data.toString().split('\n').filter(line => line.trim());
|
|
80
|
+
|
|
81
|
+
for (const line of lines) {
|
|
82
|
+
const event = JSON.parse(line);
|
|
83
|
+
|
|
84
|
+
if (event.type === 'system' && event.subtype === 'init') {
|
|
85
|
+
if (!claudeStarted) {
|
|
86
|
+
const claudeCreateTime = Date.now() - claudeStartTime;
|
|
87
|
+
console.log(color('green', `✅ Claude Code started in ${claudeCreateTime}ms`));
|
|
88
|
+
claudeStarted = true;
|
|
89
|
+
}
|
|
90
|
+
console.log(color('green', `✅ Session started (${event.session_id.substring(0, 8)}...)`));
|
|
91
|
+
console.log(color('cyan', `📦 Model: ${event.model}`));
|
|
92
|
+
console.log(color('cyan', `🔧 Tools: ${event.tools.length} available\n`));
|
|
93
|
+
} else if (event.type === 'assistant' && event.message) {
|
|
94
|
+
const content = event.message.content;
|
|
95
|
+
if (Array.isArray(content)) {
|
|
96
|
+
for (const block of content) {
|
|
97
|
+
if (block.type === 'text') {
|
|
98
|
+
process.stdout.write(block.text);
|
|
99
|
+
} else if (block.type === 'tool_use') {
|
|
100
|
+
console.log(color('cyan', `\n🔧 Using tool: ${block.name}`));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} else if (event.type === 'result') {
|
|
105
|
+
const usage = event.usage || {};
|
|
106
|
+
const cost = event.total_cost_usd || 0;
|
|
107
|
+
console.log(color('green', `\n\n✅ Completed in ${event.duration_ms}ms`));
|
|
108
|
+
console.log(color('yellow', `💰 Cost: $${cost.toFixed(4)}`));
|
|
109
|
+
if (usage.input_tokens) {
|
|
110
|
+
console.log(color('cyan', `📊 Tokens: ${usage.input_tokens} in, ${usage.output_tokens} out`));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
115
116
|
// Add error handling
|
|
116
117
|
proc.on('error', (error) => {
|
|
117
118
|
console.log(color('red', `🔍 Debug: Process error: ${error.message}`));
|