@probelabs/probe 0.6.0-rc117 → 0.6.0-rc119
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.js +59 -4
- package/build/agent/index.js +3557 -158
- package/build/agent/probeTool.js +32 -6
- package/build/agent/tokenCounter.js +7 -7
- package/cjs/agent/ProbeAgent.cjs +3575 -176
- package/cjs/index.cjs +3560 -161
- package/package.json +3 -3
- package/src/agent/ProbeAgent.js +59 -4
- package/src/agent/probeTool.js +32 -6
- package/src/agent/tokenCounter.js +7 -7
|
@@ -380,6 +380,9 @@ export class ProbeAgent {
|
|
|
380
380
|
async processImageReferences(content) {
|
|
381
381
|
if (!content) return;
|
|
382
382
|
|
|
383
|
+
// First, try to parse listFiles output format to extract directory context
|
|
384
|
+
const listFilesDirectories = this.extractListFilesDirectories(content);
|
|
385
|
+
|
|
383
386
|
// Enhanced pattern to detect image file mentions in various contexts
|
|
384
387
|
// Looks for: "image", "file", "screenshot", etc. followed by path-like strings with image extensions
|
|
385
388
|
const extensionsPattern = `(?:${SUPPORTED_IMAGE_EXTENSIONS.join('|')})`;
|
|
@@ -414,10 +417,55 @@ export class ProbeAgent {
|
|
|
414
417
|
|
|
415
418
|
// Process each found path
|
|
416
419
|
for (const imagePath of foundPaths) {
|
|
417
|
-
|
|
420
|
+
// Try to resolve the path with directory context from listFiles output
|
|
421
|
+
let resolvedPath = imagePath;
|
|
422
|
+
|
|
423
|
+
// If the path is just a filename (no directory separator), try to find it in listFiles directories
|
|
424
|
+
if (!imagePath.includes('/') && !imagePath.includes('\\')) {
|
|
425
|
+
for (const dir of listFilesDirectories) {
|
|
426
|
+
const potentialPath = resolve(dir, imagePath);
|
|
427
|
+
// Check if this file exists by attempting to load it
|
|
428
|
+
const loaded = await this.loadImageIfValid(potentialPath);
|
|
429
|
+
if (loaded) {
|
|
430
|
+
// Successfully loaded with this directory context
|
|
431
|
+
if (this.debug) {
|
|
432
|
+
console.log(`[DEBUG] Resolved ${imagePath} to ${potentialPath} using listFiles context`);
|
|
433
|
+
}
|
|
434
|
+
break; // Found it, no need to try other directories
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
} else {
|
|
438
|
+
// Path already has directory info, load as-is
|
|
439
|
+
await this.loadImageIfValid(resolvedPath);
|
|
440
|
+
}
|
|
418
441
|
}
|
|
419
442
|
}
|
|
420
443
|
|
|
444
|
+
/**
|
|
445
|
+
* Extract directory paths from listFiles tool output
|
|
446
|
+
* @param {string} content - Tool output content
|
|
447
|
+
* @returns {string[]} - Array of directory paths
|
|
448
|
+
*/
|
|
449
|
+
extractListFilesDirectories(content) {
|
|
450
|
+
const directories = [];
|
|
451
|
+
|
|
452
|
+
// Pattern to match listFiles output format: "/path/to/directory:" at the start of a line
|
|
453
|
+
const dirPattern = /^([^\n:]+):\s*$/gm;
|
|
454
|
+
|
|
455
|
+
let match;
|
|
456
|
+
while ((match = dirPattern.exec(content)) !== null) {
|
|
457
|
+
const dirPath = match[1].trim();
|
|
458
|
+
if (dirPath && dirPath.length > 0) {
|
|
459
|
+
directories.push(dirPath);
|
|
460
|
+
if (this.debug) {
|
|
461
|
+
console.log(`[DEBUG] Extracted directory context from listFiles: ${dirPath}`);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return directories;
|
|
467
|
+
}
|
|
468
|
+
|
|
421
469
|
/**
|
|
422
470
|
* Load and cache an image if it's valid and accessible
|
|
423
471
|
* @param {string} imagePath - Path to the image file
|
|
@@ -644,16 +692,23 @@ export class ProbeAgent {
|
|
|
644
692
|
this.mcpBridge = new MCPXmlBridge({ debug: this.debug });
|
|
645
693
|
await this.mcpBridge.initialize(mcpConfig);
|
|
646
694
|
|
|
647
|
-
const
|
|
695
|
+
const mcpToolNames = this.mcpBridge.getToolNames();
|
|
696
|
+
const mcpToolCount = mcpToolNames.length;
|
|
648
697
|
if (mcpToolCount > 0) {
|
|
649
698
|
if (this.debug) {
|
|
650
|
-
console.
|
|
699
|
+
console.error('\n[DEBUG] ========================================');
|
|
700
|
+
console.error(`[DEBUG] MCP Tools Initialized (${mcpToolCount} tools)`);
|
|
701
|
+
console.error('[DEBUG] Available MCP tools:');
|
|
702
|
+
for (const toolName of mcpToolNames) {
|
|
703
|
+
console.error(`[DEBUG] - ${toolName}`);
|
|
704
|
+
}
|
|
705
|
+
console.error('[DEBUG] ========================================\n');
|
|
651
706
|
}
|
|
652
707
|
} else {
|
|
653
708
|
// For backward compatibility: if no tools were loaded, set bridge to null
|
|
654
709
|
// This maintains the behavior expected by existing tests
|
|
655
710
|
if (this.debug) {
|
|
656
|
-
console.
|
|
711
|
+
console.error('[DEBUG] No MCP tools loaded, setting bridge to null');
|
|
657
712
|
}
|
|
658
713
|
this.mcpBridge = null;
|
|
659
714
|
}
|