@probelabs/probe 0.6.0-rc174 → 0.6.0-rc175
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/build/agent/ProbeAgent.d.ts +6 -0
- package/build/agent/ProbeAgent.js +69 -1
- package/build/agent/index.js +317 -229
- package/build/extract.js +13 -5
- package/build/query.js +9 -2
- package/build/search.js +10 -2
- package/build/tools/bash.js +5 -5
- package/build/tools/edit.js +7 -7
- package/build/tools/langchain.js +12 -3
- package/build/tools/vercel.js +25 -29
- package/build/utils/path-validation.js +58 -0
- package/cjs/agent/ProbeAgent.cjs +449 -360
- package/cjs/index.cjs +469 -371
- package/index.d.ts +12 -1
- package/package.json +1 -1
- package/src/agent/ProbeAgent.d.ts +6 -0
- package/src/agent/ProbeAgent.js +69 -1
- package/src/extract.js +13 -5
- package/src/query.js +9 -2
- package/src/search.js +10 -2
- package/src/tools/bash.js +5 -5
- package/src/tools/edit.js +7 -7
- package/src/tools/langchain.js +12 -3
- package/src/tools/vercel.js +25 -29
- package/src/utils/path-validation.js +58 -0
|
@@ -45,6 +45,12 @@ export interface ProbeAgentOptions {
|
|
|
45
45
|
retry?: RetryOptions;
|
|
46
46
|
/** Fallback configuration for multi-provider support */
|
|
47
47
|
fallback?: FallbackOptions | { auto: boolean };
|
|
48
|
+
/** Disable automatic mermaid diagram validation and fixing */
|
|
49
|
+
disableMermaidValidation?: boolean;
|
|
50
|
+
/** Disable automatic JSON validation and fixing (prevents infinite recursion in JsonFixingAgent) */
|
|
51
|
+
disableJsonValidation?: boolean;
|
|
52
|
+
/** Custom prompt to run after attempt_completion for validation/review (runs before mermaid/JSON validation) */
|
|
53
|
+
completionPrompt?: string;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
/**
|
|
@@ -95,6 +95,7 @@ export class ProbeAgent {
|
|
|
95
95
|
* @param {boolean} [options.allowEdit=false] - Allow the use of the 'implement' tool
|
|
96
96
|
* @param {boolean} [options.enableDelegate=false] - Enable the delegate tool for task distribution to subagents
|
|
97
97
|
* @param {string} [options.path] - Search directory path
|
|
98
|
+
* @param {string} [options.cwd] - Working directory for resolving relative paths (independent of allowedFolders)
|
|
98
99
|
* @param {string} [options.provider] - Force specific AI provider
|
|
99
100
|
* @param {string} [options.model] - Override model name
|
|
100
101
|
* @param {boolean} [options.debug] - Enable debug mode
|
|
@@ -123,6 +124,7 @@ export class ProbeAgent {
|
|
|
123
124
|
* @param {Array<Object>} [options.fallback.providers] - List of provider configurations for custom fallback
|
|
124
125
|
* @param {boolean} [options.fallback.stopOnSuccess=true] - Stop on first success
|
|
125
126
|
* @param {number} [options.fallback.maxTotalAttempts=10] - Maximum total attempts across all providers
|
|
127
|
+
* @param {string} [options.completionPrompt] - Custom prompt to run after attempt_completion for validation/review (runs before mermaid/JSON validation)
|
|
126
128
|
*/
|
|
127
129
|
constructor(options = {}) {
|
|
128
130
|
// Basic configuration
|
|
@@ -147,6 +149,9 @@ export class ProbeAgent {
|
|
|
147
149
|
this.disableMermaidValidation = !!options.disableMermaidValidation;
|
|
148
150
|
this.disableJsonValidation = !!options.disableJsonValidation;
|
|
149
151
|
|
|
152
|
+
// Completion prompt for post-completion validation/review
|
|
153
|
+
this.completionPrompt = options.completionPrompt || null;
|
|
154
|
+
|
|
150
155
|
// Tool filtering configuration
|
|
151
156
|
// Parse allowedTools option: ['*'] = all tools, [] or null = no tools, ['tool1', 'tool2'] = specific tools
|
|
152
157
|
// Supports exclusion with '!' prefix: ['*', '!bash'] = all tools except bash
|
|
@@ -180,6 +185,9 @@ export class ProbeAgent {
|
|
|
180
185
|
this.allowedFolders = [process.cwd()];
|
|
181
186
|
}
|
|
182
187
|
|
|
188
|
+
// Working directory for resolving relative paths (separate from allowedFolders security)
|
|
189
|
+
this.cwd = options.cwd || null;
|
|
190
|
+
|
|
183
191
|
// API configuration
|
|
184
192
|
this.clientApiProvider = options.provider || null;
|
|
185
193
|
this.clientApiModel = options.model || null;
|
|
@@ -425,7 +433,8 @@ export class ProbeAgent {
|
|
|
425
433
|
const configOptions = {
|
|
426
434
|
sessionId: this.sessionId,
|
|
427
435
|
debug: this.debug,
|
|
428
|
-
|
|
436
|
+
// Use explicit cwd if set, otherwise fall back to first allowed folder
|
|
437
|
+
cwd: this.cwd || (this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd()),
|
|
429
438
|
allowedFolders: this.allowedFolders,
|
|
430
439
|
outline: this.outline,
|
|
431
440
|
allowEdit: this.allowEdit,
|
|
@@ -2743,6 +2752,63 @@ IMPORTANT: When using <attempt_complete>, this must be the ONLY content in your
|
|
|
2743
2752
|
// Continue even if storage fails
|
|
2744
2753
|
}
|
|
2745
2754
|
|
|
2755
|
+
// Completion prompt handling - run a follow-up prompt after attempt_completion for validation/review
|
|
2756
|
+
// This runs BEFORE mermaid validation and JSON schema validation
|
|
2757
|
+
// Skip if we're already in a completion prompt follow-up call or if no completion prompt is configured
|
|
2758
|
+
if (completionAttempted && this.completionPrompt && !options._completionPromptProcessed) {
|
|
2759
|
+
if (this.debug) {
|
|
2760
|
+
console.log('[DEBUG] Running completion prompt for post-completion validation/review...');
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
try {
|
|
2764
|
+
// Record completion prompt start in telemetry
|
|
2765
|
+
if (this.tracer) {
|
|
2766
|
+
this.tracer.recordEvent('completion_prompt.started', {
|
|
2767
|
+
'completion_prompt.original_result_length': finalResult?.length || 0
|
|
2768
|
+
});
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
// Create the completion prompt with the current result as context
|
|
2772
|
+
const completionPromptMessage = `${this.completionPrompt}
|
|
2773
|
+
|
|
2774
|
+
Here is the result to review:
|
|
2775
|
+
<result>
|
|
2776
|
+
${finalResult}
|
|
2777
|
+
</result>
|
|
2778
|
+
|
|
2779
|
+
After reviewing, provide your final answer using attempt_completion.`;
|
|
2780
|
+
|
|
2781
|
+
// Make a follow-up call with the completion prompt
|
|
2782
|
+
// Pass _completionPromptProcessed to prevent infinite loops
|
|
2783
|
+
const completionResult = await this.answer(completionPromptMessage, [], {
|
|
2784
|
+
...options,
|
|
2785
|
+
_completionPromptProcessed: true
|
|
2786
|
+
});
|
|
2787
|
+
|
|
2788
|
+
// Update finalResult with the result from the completion prompt
|
|
2789
|
+
finalResult = completionResult;
|
|
2790
|
+
|
|
2791
|
+
if (this.debug) {
|
|
2792
|
+
console.log(`[DEBUG] Completion prompt finished. New result length: ${finalResult?.length || 0}`);
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
// Record completion prompt completion in telemetry
|
|
2796
|
+
if (this.tracer) {
|
|
2797
|
+
this.tracer.recordEvent('completion_prompt.completed', {
|
|
2798
|
+
'completion_prompt.final_result_length': finalResult?.length || 0
|
|
2799
|
+
});
|
|
2800
|
+
}
|
|
2801
|
+
} catch (error) {
|
|
2802
|
+
console.error('[ERROR] Completion prompt failed:', error);
|
|
2803
|
+
// Keep the original result if completion prompt fails
|
|
2804
|
+
if (this.tracer) {
|
|
2805
|
+
this.tracer.recordEvent('completion_prompt.error', {
|
|
2806
|
+
'completion_prompt.error': error.message
|
|
2807
|
+
});
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2746
2812
|
// Schema handling - format response according to provided schema
|
|
2747
2813
|
// Skip schema processing if result came from attempt_completion tool
|
|
2748
2814
|
// Don't apply schema formatting if we failed due to max iterations
|
|
@@ -3330,6 +3396,7 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
3330
3396
|
enableDelegate: this.enableDelegate,
|
|
3331
3397
|
path: this.allowedFolders[0], // Use first allowed folder as primary path
|
|
3332
3398
|
allowedFolders: [...this.allowedFolders],
|
|
3399
|
+
cwd: this.cwd, // Preserve explicit working directory
|
|
3333
3400
|
provider: this.clientApiProvider,
|
|
3334
3401
|
model: this.clientApiModel,
|
|
3335
3402
|
debug: this.debug,
|
|
@@ -3338,6 +3405,7 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
3338
3405
|
maxIterations: this.maxIterations,
|
|
3339
3406
|
disableMermaidValidation: this.disableMermaidValidation,
|
|
3340
3407
|
disableJsonValidation: this.disableJsonValidation,
|
|
3408
|
+
completionPrompt: this.completionPrompt,
|
|
3341
3409
|
allowedTools: allowedToolsArray,
|
|
3342
3410
|
enableMcp: !!this.mcpBridge,
|
|
3343
3411
|
mcpConfig: this.mcpConfig,
|