@probelabs/probe-chat 0.6.0-rc151 → 0.6.0-rc153
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/LOCAL_IMAGE_SUPPORT.md +4 -4
- package/package.json +1 -1
- package/probeChat.js +19 -12
package/LOCAL_IMAGE_SUPPORT.md
CHANGED
|
@@ -7,7 +7,7 @@ The probe agent now supports reading local image files directly from file paths
|
|
|
7
7
|
### Automatic Local File Detection
|
|
8
8
|
- Detects local image file paths in user messages
|
|
9
9
|
- Supports both relative and absolute paths
|
|
10
|
-
- Recognizes common image extensions: `.png`, `.jpg`, `.jpeg`, `.webp`, `.
|
|
10
|
+
- Recognizes common image extensions: `.png`, `.jpg`, `.jpeg`, `.webp`, `.bmp`, `.svg`
|
|
11
11
|
|
|
12
12
|
### 🚀 NEW: Agentic Loop Image Loading
|
|
13
13
|
- **Automatic detection**: Agent automatically detects when it mentions image files in its internal thinking
|
|
@@ -26,7 +26,7 @@ The probe agent now supports reading local image files directly from file paths
|
|
|
26
26
|
./image.png # Relative path from current directory
|
|
27
27
|
../assets/screenshot.jpg # Relative path with directory traversal
|
|
28
28
|
/absolute/path/to/image.webp # Absolute path
|
|
29
|
-
image.
|
|
29
|
+
image.png # File in current directory
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
### Automatic Conversion
|
|
@@ -101,7 +101,7 @@ When the probe agent is working through a task, it can now:
|
|
|
101
101
|
The agent automatically loads images when it mentions:
|
|
102
102
|
|
|
103
103
|
- **Direct paths**: `./screenshot.png`, `/path/to/image.jpg`
|
|
104
|
-
- **Contextual references**: "the file diagram.png shows", "looking at chart.
|
|
104
|
+
- **Contextual references**: "the file diagram.png shows", "looking at chart.png"
|
|
105
105
|
- **Tool results**: When tools return paths to image files
|
|
106
106
|
- **Generated content**: "saved visualization as ./output.png"
|
|
107
107
|
|
|
@@ -135,7 +135,7 @@ The agent automatically loads images when it mentions:
|
|
|
135
135
|
### Pattern Matching
|
|
136
136
|
The system uses an enhanced regex pattern to detect:
|
|
137
137
|
```javascript
|
|
138
|
-
/(?:data:image\/[a-zA-Z]*;base64,[A-Za-z0-9+/=]+|https?:\/\/(?:(?:private-user-images\.githubusercontent\.com|github\.com\/user-attachments\/assets)\/[^\s"'<>]+|[^\s"'<>]+\.(?:png|jpg|jpeg|webp|
|
|
138
|
+
/(?:data:image\/[a-zA-Z]*;base64,[A-Za-z0-9+/=]+|https?:\/\/(?:(?:private-user-images\.githubusercontent\.com|github\.com\/user-attachments\/assets)\/[^\s"'<>]+|[^\s"'<>]+\.(?:png|jpg|jpeg|webp|bmp|svg)(?:\?[^\s"'<>]*)?)|(?:\.?\.?\/)?[^\s"'<>]*\.(?:png|jpg|jpeg|webp|bmp|svg))/gi
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
### Processing Pipeline
|
package/package.json
CHANGED
package/probeChat.js
CHANGED
|
@@ -8,6 +8,19 @@ import { TelemetryConfig } from './telemetry.js';
|
|
|
8
8
|
import { trace } from '@opentelemetry/api';
|
|
9
9
|
import { appTracer } from './appTracer.js';
|
|
10
10
|
|
|
11
|
+
// Image configuration (duplicated from @probelabs/probe/agent/imageConfig for compatibility)
|
|
12
|
+
// TODO: Import from '@probelabs/probe/agent/imageConfig' after next package publish
|
|
13
|
+
const IMAGE_MIME_TYPES = {
|
|
14
|
+
'png': 'image/png',
|
|
15
|
+
'jpg': 'image/jpeg',
|
|
16
|
+
'jpeg': 'image/jpeg',
|
|
17
|
+
'webp': 'image/webp',
|
|
18
|
+
'bmp': 'image/bmp',
|
|
19
|
+
'svg': 'image/svg+xml'
|
|
20
|
+
};
|
|
21
|
+
const SUPPORTED_IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'bmp', 'svg'];
|
|
22
|
+
const getExtensionPattern = (extensions = SUPPORTED_IMAGE_EXTENSIONS) => extensions.join('|');
|
|
23
|
+
|
|
11
24
|
// Parse and validate allowed folders from environment variable
|
|
12
25
|
const allowedFolders = process.env.ALLOWED_FOLDERS
|
|
13
26
|
? process.env.ALLOWED_FOLDERS.split(',').map(folder => folder.trim()).filter(Boolean)
|
|
@@ -104,17 +117,9 @@ async function convertImageFileToBase64(filePath, debug = false) {
|
|
|
104
117
|
return null;
|
|
105
118
|
}
|
|
106
119
|
|
|
107
|
-
// Determine MIME type based on file extension
|
|
120
|
+
// Determine MIME type based on file extension (from shared config)
|
|
108
121
|
const extension = absolutePath.toLowerCase().split('.').pop();
|
|
109
|
-
const
|
|
110
|
-
'png': 'image/png',
|
|
111
|
-
'jpg': 'image/jpeg',
|
|
112
|
-
'jpeg': 'image/jpeg',
|
|
113
|
-
'webp': 'image/webp',
|
|
114
|
-
'gif': 'image/gif'
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const mimeType = mimeTypes[extension];
|
|
122
|
+
const mimeType = IMAGE_MIME_TYPES[extension];
|
|
118
123
|
if (!mimeType) {
|
|
119
124
|
if (debug) {
|
|
120
125
|
console.log(`[DEBUG] Unsupported image format: ${extension}`);
|
|
@@ -157,11 +162,13 @@ async function extractImageUrls(message, debug = false) {
|
|
|
157
162
|
// Pattern to match image URLs, base64 data, and local file paths:
|
|
158
163
|
// 1. GitHub private-user-images URLs (always images, regardless of extension)
|
|
159
164
|
// 2. GitHub user-attachments/assets URLs (always images, regardless of extension)
|
|
160
|
-
// 3. URLs with common image extensions (PNG, JPG, JPEG, WebP,
|
|
165
|
+
// 3. URLs with common image extensions (PNG, JPG, JPEG, WebP, BMP, SVG)
|
|
161
166
|
// 4. Base64 data URLs (data:image/...)
|
|
162
167
|
// 5. Local file paths with image extensions (relative and absolute)
|
|
163
168
|
// Updated to stop at quotes, spaces, or common HTML/XML delimiters
|
|
164
|
-
|
|
169
|
+
// Pattern dynamically generated from shared config
|
|
170
|
+
const extPattern = getExtensionPattern();
|
|
171
|
+
const imageUrlPattern = new RegExp(`(?:data:image/[a-zA-Z]*;base64,[A-Za-z0-9+/=]+|https?://(?:(?:private-user-images\\.githubusercontent\\.com|github\\.com/user-attachments/assets)/[^\\s"'<>]+|[^\\s"'<>]+\\.(?:${extPattern})(?:\\?[^\\s"'<>]*)?)|(?:\\.?\\.?/)?[^\\s"'<>]*\\.(?:${extPattern}))`, 'gi');
|
|
165
172
|
|
|
166
173
|
span.setAttributes({
|
|
167
174
|
'message.length': message.length,
|