@probelabs/probe 0.6.0-rc225 ā 0.6.0-rc227
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/bin/binaries/probe-v0.6.0-rc227-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc227-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc227-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc227-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc227-x86_64-unknown-linux-musl.tar.gz +0 -0
- package/build/agent/ProbeAgent.d.ts +24 -0
- package/build/agent/ProbeAgent.js +310 -141
- package/build/agent/engines/enhanced-claude-code.js +72 -3
- package/build/agent/index.js +386 -129
- package/build/tools/analyzeAll.js +6 -1
- package/build/tools/bash.js +18 -3
- package/build/tools/edit.js +19 -10
- package/build/tools/vercel.js +17 -7
- package/build/utils/path-validation.js +148 -1
- package/cjs/agent/ProbeAgent.cjs +683 -389
- package/cjs/index.cjs +680 -389
- package/package.json +1 -1
- package/src/agent/ProbeAgent.d.ts +24 -0
- package/src/agent/ProbeAgent.js +310 -141
- package/src/agent/engines/enhanced-claude-code.js +72 -3
- package/src/tools/analyzeAll.js +6 -1
- package/src/tools/bash.js +18 -3
- package/src/tools/edit.js +19 -10
- package/src/tools/vercel.js +17 -7
- package/src/utils/path-validation.js +148 -1
- package/bin/binaries/probe-v0.6.0-rc225-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc225-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc225-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc225-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc225-x86_64-unknown-linux-musl.tar.gz +0 -0
|
@@ -15,7 +15,7 @@ import { Session } from '../shared/Session.js';
|
|
|
15
15
|
* Enhanced Claude Code Engine
|
|
16
16
|
*/
|
|
17
17
|
export async function createEnhancedClaudeCLIEngine(options = {}) {
|
|
18
|
-
const { agent, systemPrompt, customPrompt, debug, sessionId, allowedTools } = options;
|
|
18
|
+
const { agent, systemPrompt, customPrompt, debug, sessionId, allowedTools, timeout = 120000 } = options;
|
|
19
19
|
|
|
20
20
|
// Create or reuse session
|
|
21
21
|
const session = new Session(
|
|
@@ -154,6 +154,37 @@ export async function createEnhancedClaudeCLIEngine(options = {}) {
|
|
|
154
154
|
stdio: ['ignore', 'pipe', 'pipe'] // Ignore stdin since echo handles it
|
|
155
155
|
});
|
|
156
156
|
|
|
157
|
+
// Subprocess timeout handling
|
|
158
|
+
let killed = false;
|
|
159
|
+
let timeoutHandle;
|
|
160
|
+
let sigkillHandle;
|
|
161
|
+
|
|
162
|
+
if (timeout > 0) {
|
|
163
|
+
timeoutHandle = setTimeout(() => {
|
|
164
|
+
if (!killed) {
|
|
165
|
+
killed = true;
|
|
166
|
+
processEnded = true;
|
|
167
|
+
proc.kill('SIGTERM');
|
|
168
|
+
|
|
169
|
+
if (debug) {
|
|
170
|
+
console.log(`[DEBUG] Process timed out after ${timeout}ms, sending SIGTERM`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Force kill after 5 seconds if still running
|
|
174
|
+
sigkillHandle = setTimeout(() => {
|
|
175
|
+
if (proc.exitCode === null) {
|
|
176
|
+
proc.kill('SIGKILL');
|
|
177
|
+
if (debug) {
|
|
178
|
+
console.log('[DEBUG] Process did not exit, sending SIGKILL');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, 5000);
|
|
182
|
+
|
|
183
|
+
emitter.emit('error', new Error(`Claude CLI process timed out after ${timeout}ms`));
|
|
184
|
+
}
|
|
185
|
+
}, timeout);
|
|
186
|
+
}
|
|
187
|
+
|
|
157
188
|
// Handle stdout
|
|
158
189
|
proc.stdout.on('data', (data) => {
|
|
159
190
|
buffer += data.toString();
|
|
@@ -179,11 +210,25 @@ export async function createEnhancedClaudeCLIEngine(options = {}) {
|
|
|
179
210
|
|
|
180
211
|
// Handle process end
|
|
181
212
|
proc.on('close', (code) => {
|
|
213
|
+
// Clear the timeouts to prevent memory leaks
|
|
214
|
+
if (timeoutHandle) {
|
|
215
|
+
clearTimeout(timeoutHandle);
|
|
216
|
+
}
|
|
217
|
+
if (sigkillHandle) {
|
|
218
|
+
clearTimeout(sigkillHandle);
|
|
219
|
+
}
|
|
220
|
+
|
|
182
221
|
processEnded = true;
|
|
183
222
|
if (code !== 0 && debug) {
|
|
184
223
|
console.log(`[DEBUG] Process exited with code ${code}`);
|
|
185
224
|
}
|
|
186
225
|
|
|
226
|
+
// If killed by timeout, the error was already emitted
|
|
227
|
+
if (killed) {
|
|
228
|
+
emitter.emit('end');
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
187
232
|
// Process any remaining buffer
|
|
188
233
|
if (buffer.trim()) {
|
|
189
234
|
processJsonBuffer(buffer, emitter, session, debug, toolCollector);
|
|
@@ -205,6 +250,14 @@ export async function createEnhancedClaudeCLIEngine(options = {}) {
|
|
|
205
250
|
});
|
|
206
251
|
|
|
207
252
|
proc.on('error', (error) => {
|
|
253
|
+
// Clear the timeouts to prevent memory leaks
|
|
254
|
+
if (timeoutHandle) {
|
|
255
|
+
clearTimeout(timeoutHandle);
|
|
256
|
+
}
|
|
257
|
+
if (sigkillHandle) {
|
|
258
|
+
clearTimeout(sigkillHandle);
|
|
259
|
+
}
|
|
260
|
+
processEnded = true;
|
|
208
261
|
emitter.emit('error', error);
|
|
209
262
|
});
|
|
210
263
|
|
|
@@ -259,8 +312,24 @@ export async function createEnhancedClaudeCLIEngine(options = {}) {
|
|
|
259
312
|
content: `\nš§ Using ${msg.name}: ${JSON.stringify(msg.input)}\n`
|
|
260
313
|
};
|
|
261
314
|
|
|
262
|
-
// Execute tool
|
|
263
|
-
const
|
|
315
|
+
// Execute tool with timeout to prevent indefinite blocking
|
|
316
|
+
const toolTimeout = 30000; // 30 seconds
|
|
317
|
+
let toolTimeoutId;
|
|
318
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
319
|
+
toolTimeoutId = setTimeout(() => reject(new Error(`Tool ${msg.name} timed out after ${toolTimeout}ms`)), toolTimeout);
|
|
320
|
+
});
|
|
321
|
+
let result;
|
|
322
|
+
try {
|
|
323
|
+
result = await Promise.race([
|
|
324
|
+
executeProbleTool(agent, msg.name, msg.input),
|
|
325
|
+
timeoutPromise
|
|
326
|
+
]);
|
|
327
|
+
} catch (error) {
|
|
328
|
+
result = `Tool error: ${error.message}`;
|
|
329
|
+
} finally {
|
|
330
|
+
// Always clear timeout to prevent memory leaks
|
|
331
|
+
clearTimeout(toolTimeoutId);
|
|
332
|
+
}
|
|
264
333
|
yield { type: 'text', content: `${result}\n` };
|
|
265
334
|
} else if (msg.type === 'toolBatch') {
|
|
266
335
|
// Pass through the tool batch for ProbeAgent to emit
|