@probelabs/probe 0.6.0-rc165 → 0.6.0-rc166
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 +25 -4
- package/build/agent/index.js +44 -5
- package/build/agent/tools.js +25 -0
- package/cjs/agent/ProbeAgent.cjs +44 -5
- package/cjs/index.cjs +44 -5
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +25 -4
- package/src/agent/tools.js +25 -0
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
bashToolDefinition,
|
|
28
28
|
listFilesToolDefinition,
|
|
29
29
|
searchFilesToolDefinition,
|
|
30
|
+
readImageToolDefinition,
|
|
30
31
|
attemptCompletionToolDefinition,
|
|
31
32
|
implementToolDefinition,
|
|
32
33
|
editToolDefinition,
|
|
@@ -399,6 +400,23 @@ export class ProbeAgent {
|
|
|
399
400
|
delegate: wrappedTools.delegateToolInstance,
|
|
400
401
|
listFiles: listFilesToolInstance,
|
|
401
402
|
searchFiles: searchFilesToolInstance,
|
|
403
|
+
readImage: {
|
|
404
|
+
execute: async (params) => {
|
|
405
|
+
const imagePath = params.path;
|
|
406
|
+
if (!imagePath) {
|
|
407
|
+
throw new Error('Image path is required');
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Load the image using the existing loadImageIfValid method
|
|
411
|
+
const loaded = await this.loadImageIfValid(imagePath);
|
|
412
|
+
|
|
413
|
+
if (!loaded) {
|
|
414
|
+
throw new Error(`Failed to load image: ${imagePath}. The file may not exist, be too large, have an unsupported format, or be outside allowed directories.`);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return `Image loaded successfully: ${imagePath}. The image is now available for analysis in the conversation.`;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
402
420
|
};
|
|
403
421
|
|
|
404
422
|
// Add bash tool if enabled
|
|
@@ -1172,6 +1190,9 @@ export class ProbeAgent {
|
|
|
1172
1190
|
if (isToolAllowed('searchFiles')) {
|
|
1173
1191
|
toolDefinitions += `${searchFilesToolDefinition}\n`;
|
|
1174
1192
|
}
|
|
1193
|
+
if (isToolAllowed('readImage')) {
|
|
1194
|
+
toolDefinitions += `${readImageToolDefinition}\n`;
|
|
1195
|
+
}
|
|
1175
1196
|
|
|
1176
1197
|
// Edit tools (require both allowEdit flag AND allowedTools permission)
|
|
1177
1198
|
if (this.allowEdit && isToolAllowed('implement')) {
|
|
@@ -1262,6 +1283,7 @@ Available Tools:
|
|
|
1262
1283
|
- extract: Extract specific code blocks or lines from files.
|
|
1263
1284
|
- listFiles: List files and directories in a specified location.
|
|
1264
1285
|
- searchFiles: Find files matching a glob pattern with recursive search capability.
|
|
1286
|
+
- readImage: Read and load an image file for AI analysis.
|
|
1265
1287
|
${this.allowEdit ? '- implement: Implement a feature or fix a bug using aider.\n- edit: Edit files using exact string replacement.\n- create: Create new files with specified content.\n' : ''}${this.enableDelegate ? '- delegate: Delegate big distinct tasks to specialized probe subagents.\n' : ''}${this.enableBash ? '- bash: Execute bash commands for system operations.\n' : ''}
|
|
1266
1288
|
- attempt_completion: Finalize the task and provide the result to the user.
|
|
1267
1289
|
- attempt_complete: Quick completion using previous response (shorthand).
|
|
@@ -1700,10 +1722,8 @@ When troubleshooting:
|
|
|
1700
1722
|
console.log(`[DEBUG] Assistant response (${assistantResponseContent.length} chars): ${assistantPreview}`);
|
|
1701
1723
|
}
|
|
1702
1724
|
|
|
1703
|
-
//
|
|
1704
|
-
|
|
1705
|
-
await this.processImageReferences(assistantResponseContent);
|
|
1706
|
-
}
|
|
1725
|
+
// Images in assistant responses are not automatically processed
|
|
1726
|
+
// AI can use the readImage tool to explicitly request reading an image
|
|
1707
1727
|
|
|
1708
1728
|
// Parse tool call from response with valid tools list
|
|
1709
1729
|
// Build validTools based on allowedTools configuration (same pattern as getSystemMessage)
|
|
@@ -1713,6 +1733,7 @@ When troubleshooting:
|
|
|
1713
1733
|
if (this.allowedTools.isEnabled('extract')) validTools.push('extract');
|
|
1714
1734
|
if (this.allowedTools.isEnabled('listFiles')) validTools.push('listFiles');
|
|
1715
1735
|
if (this.allowedTools.isEnabled('searchFiles')) validTools.push('searchFiles');
|
|
1736
|
+
if (this.allowedTools.isEnabled('readImage')) validTools.push('readImage');
|
|
1716
1737
|
if (this.allowedTools.isEnabled('attempt_completion')) validTools.push('attempt_completion');
|
|
1717
1738
|
|
|
1718
1739
|
// Edit tools (require both allowEdit flag AND allowedTools permission)
|
package/build/agent/index.js
CHANGED
|
@@ -17572,7 +17572,7 @@ function parseXmlToolCallWithThinking(xmlString, validTools) {
|
|
|
17572
17572
|
}
|
|
17573
17573
|
return parseXmlToolCall(cleanedXmlString, validTools);
|
|
17574
17574
|
}
|
|
17575
|
-
var implementToolDefinition, listFilesToolDefinition, searchFilesToolDefinition;
|
|
17575
|
+
var implementToolDefinition, listFilesToolDefinition, searchFilesToolDefinition, readImageToolDefinition;
|
|
17576
17576
|
var init_tools2 = __esm({
|
|
17577
17577
|
"src/agent/tools.js"() {
|
|
17578
17578
|
"use strict";
|
|
@@ -17650,6 +17650,29 @@ User: Find all markdown files in the docs directory, but only at the top level.
|
|
|
17650
17650
|
<recursive>false</recursive>
|
|
17651
17651
|
</searchFiles>
|
|
17652
17652
|
|
|
17653
|
+
</examples>
|
|
17654
|
+
`;
|
|
17655
|
+
readImageToolDefinition = `
|
|
17656
|
+
## readImage
|
|
17657
|
+
Description: Read and load an image file so it can be viewed by the AI. Use this when you need to analyze, describe, or work with image content. Images from user messages are automatically loaded, but use this tool to explicitly read images mentioned in tool outputs or when you need to examine specific image files.
|
|
17658
|
+
|
|
17659
|
+
Parameters:
|
|
17660
|
+
- path: (required) The path to the image file to read. Supports png, jpg, jpeg, webp, bmp, and svg formats.
|
|
17661
|
+
|
|
17662
|
+
Usage Example:
|
|
17663
|
+
|
|
17664
|
+
<examples>
|
|
17665
|
+
|
|
17666
|
+
User: Can you describe what's in screenshot.png?
|
|
17667
|
+
<readImage>
|
|
17668
|
+
<path>screenshot.png</path>
|
|
17669
|
+
</readImage>
|
|
17670
|
+
|
|
17671
|
+
User: Analyze the diagram in docs/architecture.svg
|
|
17672
|
+
<readImage>
|
|
17673
|
+
<path>docs/architecture.svg</path>
|
|
17674
|
+
</readImage>
|
|
17675
|
+
|
|
17653
17676
|
</examples>
|
|
17654
17677
|
`;
|
|
17655
17678
|
}
|
|
@@ -57643,7 +57666,20 @@ var init_ProbeAgent = __esm({
|
|
|
57643
57666
|
extract: wrappedTools.extractToolInstance,
|
|
57644
57667
|
delegate: wrappedTools.delegateToolInstance,
|
|
57645
57668
|
listFiles: listFilesToolInstance,
|
|
57646
|
-
searchFiles: searchFilesToolInstance
|
|
57669
|
+
searchFiles: searchFilesToolInstance,
|
|
57670
|
+
readImage: {
|
|
57671
|
+
execute: async (params) => {
|
|
57672
|
+
const imagePath = params.path;
|
|
57673
|
+
if (!imagePath) {
|
|
57674
|
+
throw new Error("Image path is required");
|
|
57675
|
+
}
|
|
57676
|
+
const loaded = await this.loadImageIfValid(imagePath);
|
|
57677
|
+
if (!loaded) {
|
|
57678
|
+
throw new Error(`Failed to load image: ${imagePath}. The file may not exist, be too large, have an unsupported format, or be outside allowed directories.`);
|
|
57679
|
+
}
|
|
57680
|
+
return `Image loaded successfully: ${imagePath}. The image is now available for analysis in the conversation.`;
|
|
57681
|
+
}
|
|
57682
|
+
}
|
|
57647
57683
|
};
|
|
57648
57684
|
if (this.enableBash && wrappedTools.bashToolInstance) {
|
|
57649
57685
|
this.toolImplementations.bash = wrappedTools.bashToolInstance;
|
|
@@ -58246,6 +58282,10 @@ var init_ProbeAgent = __esm({
|
|
|
58246
58282
|
}
|
|
58247
58283
|
if (isToolAllowed("searchFiles")) {
|
|
58248
58284
|
toolDefinitions += `${searchFilesToolDefinition}
|
|
58285
|
+
`;
|
|
58286
|
+
}
|
|
58287
|
+
if (isToolAllowed("readImage")) {
|
|
58288
|
+
toolDefinitions += `${readImageToolDefinition}
|
|
58249
58289
|
`;
|
|
58250
58290
|
}
|
|
58251
58291
|
if (this.allowEdit && isToolAllowed("implement")) {
|
|
@@ -58333,6 +58373,7 @@ Available Tools:
|
|
|
58333
58373
|
- extract: Extract specific code blocks or lines from files.
|
|
58334
58374
|
- listFiles: List files and directories in a specified location.
|
|
58335
58375
|
- searchFiles: Find files matching a glob pattern with recursive search capability.
|
|
58376
|
+
- readImage: Read and load an image file for AI analysis.
|
|
58336
58377
|
${this.allowEdit ? "- implement: Implement a feature or fix a bug using aider.\n- edit: Edit files using exact string replacement.\n- create: Create new files with specified content.\n" : ""}${this.enableDelegate ? "- delegate: Delegate big distinct tasks to specialized probe subagents.\n" : ""}${this.enableBash ? "- bash: Execute bash commands for system operations.\n" : ""}
|
|
58337
58378
|
- attempt_completion: Finalize the task and provide the result to the user.
|
|
58338
58379
|
- attempt_complete: Quick completion using previous response (shorthand).
|
|
@@ -58690,15 +58731,13 @@ You are working with a repository located at: ${searchDirectory}
|
|
|
58690
58731
|
const assistantPreview = createMessagePreview(assistantResponseContent);
|
|
58691
58732
|
console.log(`[DEBUG] Assistant response (${assistantResponseContent.length} chars): ${assistantPreview}`);
|
|
58692
58733
|
}
|
|
58693
|
-
if (assistantResponseContent) {
|
|
58694
|
-
await this.processImageReferences(assistantResponseContent);
|
|
58695
|
-
}
|
|
58696
58734
|
const validTools = [];
|
|
58697
58735
|
if (this.allowedTools.isEnabled("search")) validTools.push("search");
|
|
58698
58736
|
if (this.allowedTools.isEnabled("query")) validTools.push("query");
|
|
58699
58737
|
if (this.allowedTools.isEnabled("extract")) validTools.push("extract");
|
|
58700
58738
|
if (this.allowedTools.isEnabled("listFiles")) validTools.push("listFiles");
|
|
58701
58739
|
if (this.allowedTools.isEnabled("searchFiles")) validTools.push("searchFiles");
|
|
58740
|
+
if (this.allowedTools.isEnabled("readImage")) validTools.push("readImage");
|
|
58702
58741
|
if (this.allowedTools.isEnabled("attempt_completion")) validTools.push("attempt_completion");
|
|
58703
58742
|
if (this.allowEdit && this.allowedTools.isEnabled("implement")) {
|
|
58704
58743
|
validTools.push("implement", "edit", "create");
|
package/build/agent/tools.js
CHANGED
|
@@ -154,6 +154,31 @@ User: Find all markdown files in the docs directory, but only at the top level.
|
|
|
154
154
|
</examples>
|
|
155
155
|
`;
|
|
156
156
|
|
|
157
|
+
// Define the readImage tool XML definition
|
|
158
|
+
export const readImageToolDefinition = `
|
|
159
|
+
## readImage
|
|
160
|
+
Description: Read and load an image file so it can be viewed by the AI. Use this when you need to analyze, describe, or work with image content. Images from user messages are automatically loaded, but use this tool to explicitly read images mentioned in tool outputs or when you need to examine specific image files.
|
|
161
|
+
|
|
162
|
+
Parameters:
|
|
163
|
+
- path: (required) The path to the image file to read. Supports png, jpg, jpeg, webp, bmp, and svg formats.
|
|
164
|
+
|
|
165
|
+
Usage Example:
|
|
166
|
+
|
|
167
|
+
<examples>
|
|
168
|
+
|
|
169
|
+
User: Can you describe what's in screenshot.png?
|
|
170
|
+
<readImage>
|
|
171
|
+
<path>screenshot.png</path>
|
|
172
|
+
</readImage>
|
|
173
|
+
|
|
174
|
+
User: Analyze the diagram in docs/architecture.svg
|
|
175
|
+
<readImage>
|
|
176
|
+
<path>docs/architecture.svg</path>
|
|
177
|
+
</readImage>
|
|
178
|
+
|
|
179
|
+
</examples>
|
|
180
|
+
`;
|
|
181
|
+
|
|
157
182
|
/**
|
|
158
183
|
* Enhanced XML parser that handles thinking tags and attempt_complete shorthand
|
|
159
184
|
* This function removes any <thinking></thinking> tags from the input string
|
package/cjs/agent/ProbeAgent.cjs
CHANGED
|
@@ -42232,7 +42232,7 @@ function parseXmlToolCallWithThinking(xmlString, validTools) {
|
|
|
42232
42232
|
}
|
|
42233
42233
|
return parseXmlToolCall(cleanedXmlString, validTools);
|
|
42234
42234
|
}
|
|
42235
|
-
var import_crypto4, implementToolDefinition, listFilesToolDefinition, searchFilesToolDefinition;
|
|
42235
|
+
var import_crypto4, implementToolDefinition, listFilesToolDefinition, searchFilesToolDefinition, readImageToolDefinition;
|
|
42236
42236
|
var init_tools2 = __esm({
|
|
42237
42237
|
"src/agent/tools.js"() {
|
|
42238
42238
|
"use strict";
|
|
@@ -42311,6 +42311,29 @@ User: Find all markdown files in the docs directory, but only at the top level.
|
|
|
42311
42311
|
<recursive>false</recursive>
|
|
42312
42312
|
</searchFiles>
|
|
42313
42313
|
|
|
42314
|
+
</examples>
|
|
42315
|
+
`;
|
|
42316
|
+
readImageToolDefinition = `
|
|
42317
|
+
## readImage
|
|
42318
|
+
Description: Read and load an image file so it can be viewed by the AI. Use this when you need to analyze, describe, or work with image content. Images from user messages are automatically loaded, but use this tool to explicitly read images mentioned in tool outputs or when you need to examine specific image files.
|
|
42319
|
+
|
|
42320
|
+
Parameters:
|
|
42321
|
+
- path: (required) The path to the image file to read. Supports png, jpg, jpeg, webp, bmp, and svg formats.
|
|
42322
|
+
|
|
42323
|
+
Usage Example:
|
|
42324
|
+
|
|
42325
|
+
<examples>
|
|
42326
|
+
|
|
42327
|
+
User: Can you describe what's in screenshot.png?
|
|
42328
|
+
<readImage>
|
|
42329
|
+
<path>screenshot.png</path>
|
|
42330
|
+
</readImage>
|
|
42331
|
+
|
|
42332
|
+
User: Analyze the diagram in docs/architecture.svg
|
|
42333
|
+
<readImage>
|
|
42334
|
+
<path>docs/architecture.svg</path>
|
|
42335
|
+
</readImage>
|
|
42336
|
+
|
|
42314
42337
|
</examples>
|
|
42315
42338
|
`;
|
|
42316
42339
|
}
|
|
@@ -82304,7 +82327,20 @@ var init_ProbeAgent = __esm({
|
|
|
82304
82327
|
extract: wrappedTools.extractToolInstance,
|
|
82305
82328
|
delegate: wrappedTools.delegateToolInstance,
|
|
82306
82329
|
listFiles: listFilesToolInstance,
|
|
82307
|
-
searchFiles: searchFilesToolInstance
|
|
82330
|
+
searchFiles: searchFilesToolInstance,
|
|
82331
|
+
readImage: {
|
|
82332
|
+
execute: async (params) => {
|
|
82333
|
+
const imagePath = params.path;
|
|
82334
|
+
if (!imagePath) {
|
|
82335
|
+
throw new Error("Image path is required");
|
|
82336
|
+
}
|
|
82337
|
+
const loaded = await this.loadImageIfValid(imagePath);
|
|
82338
|
+
if (!loaded) {
|
|
82339
|
+
throw new Error(`Failed to load image: ${imagePath}. The file may not exist, be too large, have an unsupported format, or be outside allowed directories.`);
|
|
82340
|
+
}
|
|
82341
|
+
return `Image loaded successfully: ${imagePath}. The image is now available for analysis in the conversation.`;
|
|
82342
|
+
}
|
|
82343
|
+
}
|
|
82308
82344
|
};
|
|
82309
82345
|
if (this.enableBash && wrappedTools.bashToolInstance) {
|
|
82310
82346
|
this.toolImplementations.bash = wrappedTools.bashToolInstance;
|
|
@@ -82907,6 +82943,10 @@ var init_ProbeAgent = __esm({
|
|
|
82907
82943
|
}
|
|
82908
82944
|
if (isToolAllowed("searchFiles")) {
|
|
82909
82945
|
toolDefinitions += `${searchFilesToolDefinition}
|
|
82946
|
+
`;
|
|
82947
|
+
}
|
|
82948
|
+
if (isToolAllowed("readImage")) {
|
|
82949
|
+
toolDefinitions += `${readImageToolDefinition}
|
|
82910
82950
|
`;
|
|
82911
82951
|
}
|
|
82912
82952
|
if (this.allowEdit && isToolAllowed("implement")) {
|
|
@@ -82994,6 +83034,7 @@ Available Tools:
|
|
|
82994
83034
|
- extract: Extract specific code blocks or lines from files.
|
|
82995
83035
|
- listFiles: List files and directories in a specified location.
|
|
82996
83036
|
- searchFiles: Find files matching a glob pattern with recursive search capability.
|
|
83037
|
+
- readImage: Read and load an image file for AI analysis.
|
|
82997
83038
|
${this.allowEdit ? "- implement: Implement a feature or fix a bug using aider.\n- edit: Edit files using exact string replacement.\n- create: Create new files with specified content.\n" : ""}${this.enableDelegate ? "- delegate: Delegate big distinct tasks to specialized probe subagents.\n" : ""}${this.enableBash ? "- bash: Execute bash commands for system operations.\n" : ""}
|
|
82998
83039
|
- attempt_completion: Finalize the task and provide the result to the user.
|
|
82999
83040
|
- attempt_complete: Quick completion using previous response (shorthand).
|
|
@@ -83351,15 +83392,13 @@ You are working with a repository located at: ${searchDirectory}
|
|
|
83351
83392
|
const assistantPreview = createMessagePreview(assistantResponseContent);
|
|
83352
83393
|
console.log(`[DEBUG] Assistant response (${assistantResponseContent.length} chars): ${assistantPreview}`);
|
|
83353
83394
|
}
|
|
83354
|
-
if (assistantResponseContent) {
|
|
83355
|
-
await this.processImageReferences(assistantResponseContent);
|
|
83356
|
-
}
|
|
83357
83395
|
const validTools = [];
|
|
83358
83396
|
if (this.allowedTools.isEnabled("search")) validTools.push("search");
|
|
83359
83397
|
if (this.allowedTools.isEnabled("query")) validTools.push("query");
|
|
83360
83398
|
if (this.allowedTools.isEnabled("extract")) validTools.push("extract");
|
|
83361
83399
|
if (this.allowedTools.isEnabled("listFiles")) validTools.push("listFiles");
|
|
83362
83400
|
if (this.allowedTools.isEnabled("searchFiles")) validTools.push("searchFiles");
|
|
83401
|
+
if (this.allowedTools.isEnabled("readImage")) validTools.push("readImage");
|
|
83363
83402
|
if (this.allowedTools.isEnabled("attempt_completion")) validTools.push("attempt_completion");
|
|
83364
83403
|
if (this.allowEdit && this.allowedTools.isEnabled("implement")) {
|
|
83365
83404
|
validTools.push("implement", "edit", "create");
|
package/cjs/index.cjs
CHANGED
|
@@ -28465,7 +28465,7 @@ function parseXmlToolCallWithThinking(xmlString, validTools) {
|
|
|
28465
28465
|
}
|
|
28466
28466
|
return parseXmlToolCall(cleanedXmlString, validTools);
|
|
28467
28467
|
}
|
|
28468
|
-
var import_crypto2, implementToolDefinition, listFilesToolDefinition, searchFilesToolDefinition;
|
|
28468
|
+
var import_crypto2, implementToolDefinition, listFilesToolDefinition, searchFilesToolDefinition, readImageToolDefinition;
|
|
28469
28469
|
var init_tools = __esm({
|
|
28470
28470
|
"src/agent/tools.js"() {
|
|
28471
28471
|
"use strict";
|
|
@@ -28544,6 +28544,29 @@ User: Find all markdown files in the docs directory, but only at the top level.
|
|
|
28544
28544
|
<recursive>false</recursive>
|
|
28545
28545
|
</searchFiles>
|
|
28546
28546
|
|
|
28547
|
+
</examples>
|
|
28548
|
+
`;
|
|
28549
|
+
readImageToolDefinition = `
|
|
28550
|
+
## readImage
|
|
28551
|
+
Description: Read and load an image file so it can be viewed by the AI. Use this when you need to analyze, describe, or work with image content. Images from user messages are automatically loaded, but use this tool to explicitly read images mentioned in tool outputs or when you need to examine specific image files.
|
|
28552
|
+
|
|
28553
|
+
Parameters:
|
|
28554
|
+
- path: (required) The path to the image file to read. Supports png, jpg, jpeg, webp, bmp, and svg formats.
|
|
28555
|
+
|
|
28556
|
+
Usage Example:
|
|
28557
|
+
|
|
28558
|
+
<examples>
|
|
28559
|
+
|
|
28560
|
+
User: Can you describe what's in screenshot.png?
|
|
28561
|
+
<readImage>
|
|
28562
|
+
<path>screenshot.png</path>
|
|
28563
|
+
</readImage>
|
|
28564
|
+
|
|
28565
|
+
User: Analyze the diagram in docs/architecture.svg
|
|
28566
|
+
<readImage>
|
|
28567
|
+
<path>docs/architecture.svg</path>
|
|
28568
|
+
</readImage>
|
|
28569
|
+
|
|
28547
28570
|
</examples>
|
|
28548
28571
|
`;
|
|
28549
28572
|
}
|
|
@@ -80046,7 +80069,20 @@ var init_ProbeAgent = __esm({
|
|
|
80046
80069
|
extract: wrappedTools.extractToolInstance,
|
|
80047
80070
|
delegate: wrappedTools.delegateToolInstance,
|
|
80048
80071
|
listFiles: listFilesToolInstance,
|
|
80049
|
-
searchFiles: searchFilesToolInstance
|
|
80072
|
+
searchFiles: searchFilesToolInstance,
|
|
80073
|
+
readImage: {
|
|
80074
|
+
execute: async (params) => {
|
|
80075
|
+
const imagePath = params.path;
|
|
80076
|
+
if (!imagePath) {
|
|
80077
|
+
throw new Error("Image path is required");
|
|
80078
|
+
}
|
|
80079
|
+
const loaded = await this.loadImageIfValid(imagePath);
|
|
80080
|
+
if (!loaded) {
|
|
80081
|
+
throw new Error(`Failed to load image: ${imagePath}. The file may not exist, be too large, have an unsupported format, or be outside allowed directories.`);
|
|
80082
|
+
}
|
|
80083
|
+
return `Image loaded successfully: ${imagePath}. The image is now available for analysis in the conversation.`;
|
|
80084
|
+
}
|
|
80085
|
+
}
|
|
80050
80086
|
};
|
|
80051
80087
|
if (this.enableBash && wrappedTools.bashToolInstance) {
|
|
80052
80088
|
this.toolImplementations.bash = wrappedTools.bashToolInstance;
|
|
@@ -80649,6 +80685,10 @@ var init_ProbeAgent = __esm({
|
|
|
80649
80685
|
}
|
|
80650
80686
|
if (isToolAllowed("searchFiles")) {
|
|
80651
80687
|
toolDefinitions += `${searchFilesToolDefinition}
|
|
80688
|
+
`;
|
|
80689
|
+
}
|
|
80690
|
+
if (isToolAllowed("readImage")) {
|
|
80691
|
+
toolDefinitions += `${readImageToolDefinition}
|
|
80652
80692
|
`;
|
|
80653
80693
|
}
|
|
80654
80694
|
if (this.allowEdit && isToolAllowed("implement")) {
|
|
@@ -80736,6 +80776,7 @@ Available Tools:
|
|
|
80736
80776
|
- extract: Extract specific code blocks or lines from files.
|
|
80737
80777
|
- listFiles: List files and directories in a specified location.
|
|
80738
80778
|
- searchFiles: Find files matching a glob pattern with recursive search capability.
|
|
80779
|
+
- readImage: Read and load an image file for AI analysis.
|
|
80739
80780
|
${this.allowEdit ? "- implement: Implement a feature or fix a bug using aider.\n- edit: Edit files using exact string replacement.\n- create: Create new files with specified content.\n" : ""}${this.enableDelegate ? "- delegate: Delegate big distinct tasks to specialized probe subagents.\n" : ""}${this.enableBash ? "- bash: Execute bash commands for system operations.\n" : ""}
|
|
80740
80781
|
- attempt_completion: Finalize the task and provide the result to the user.
|
|
80741
80782
|
- attempt_complete: Quick completion using previous response (shorthand).
|
|
@@ -81093,15 +81134,13 @@ You are working with a repository located at: ${searchDirectory}
|
|
|
81093
81134
|
const assistantPreview = createMessagePreview(assistantResponseContent);
|
|
81094
81135
|
console.log(`[DEBUG] Assistant response (${assistantResponseContent.length} chars): ${assistantPreview}`);
|
|
81095
81136
|
}
|
|
81096
|
-
if (assistantResponseContent) {
|
|
81097
|
-
await this.processImageReferences(assistantResponseContent);
|
|
81098
|
-
}
|
|
81099
81137
|
const validTools = [];
|
|
81100
81138
|
if (this.allowedTools.isEnabled("search")) validTools.push("search");
|
|
81101
81139
|
if (this.allowedTools.isEnabled("query")) validTools.push("query");
|
|
81102
81140
|
if (this.allowedTools.isEnabled("extract")) validTools.push("extract");
|
|
81103
81141
|
if (this.allowedTools.isEnabled("listFiles")) validTools.push("listFiles");
|
|
81104
81142
|
if (this.allowedTools.isEnabled("searchFiles")) validTools.push("searchFiles");
|
|
81143
|
+
if (this.allowedTools.isEnabled("readImage")) validTools.push("readImage");
|
|
81105
81144
|
if (this.allowedTools.isEnabled("attempt_completion")) validTools.push("attempt_completion");
|
|
81106
81145
|
if (this.allowEdit && this.allowedTools.isEnabled("implement")) {
|
|
81107
81146
|
validTools.push("implement", "edit", "create");
|
package/package.json
CHANGED
package/src/agent/ProbeAgent.js
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
bashToolDefinition,
|
|
28
28
|
listFilesToolDefinition,
|
|
29
29
|
searchFilesToolDefinition,
|
|
30
|
+
readImageToolDefinition,
|
|
30
31
|
attemptCompletionToolDefinition,
|
|
31
32
|
implementToolDefinition,
|
|
32
33
|
editToolDefinition,
|
|
@@ -399,6 +400,23 @@ export class ProbeAgent {
|
|
|
399
400
|
delegate: wrappedTools.delegateToolInstance,
|
|
400
401
|
listFiles: listFilesToolInstance,
|
|
401
402
|
searchFiles: searchFilesToolInstance,
|
|
403
|
+
readImage: {
|
|
404
|
+
execute: async (params) => {
|
|
405
|
+
const imagePath = params.path;
|
|
406
|
+
if (!imagePath) {
|
|
407
|
+
throw new Error('Image path is required');
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Load the image using the existing loadImageIfValid method
|
|
411
|
+
const loaded = await this.loadImageIfValid(imagePath);
|
|
412
|
+
|
|
413
|
+
if (!loaded) {
|
|
414
|
+
throw new Error(`Failed to load image: ${imagePath}. The file may not exist, be too large, have an unsupported format, or be outside allowed directories.`);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return `Image loaded successfully: ${imagePath}. The image is now available for analysis in the conversation.`;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
402
420
|
};
|
|
403
421
|
|
|
404
422
|
// Add bash tool if enabled
|
|
@@ -1172,6 +1190,9 @@ export class ProbeAgent {
|
|
|
1172
1190
|
if (isToolAllowed('searchFiles')) {
|
|
1173
1191
|
toolDefinitions += `${searchFilesToolDefinition}\n`;
|
|
1174
1192
|
}
|
|
1193
|
+
if (isToolAllowed('readImage')) {
|
|
1194
|
+
toolDefinitions += `${readImageToolDefinition}\n`;
|
|
1195
|
+
}
|
|
1175
1196
|
|
|
1176
1197
|
// Edit tools (require both allowEdit flag AND allowedTools permission)
|
|
1177
1198
|
if (this.allowEdit && isToolAllowed('implement')) {
|
|
@@ -1262,6 +1283,7 @@ Available Tools:
|
|
|
1262
1283
|
- extract: Extract specific code blocks or lines from files.
|
|
1263
1284
|
- listFiles: List files and directories in a specified location.
|
|
1264
1285
|
- searchFiles: Find files matching a glob pattern with recursive search capability.
|
|
1286
|
+
- readImage: Read and load an image file for AI analysis.
|
|
1265
1287
|
${this.allowEdit ? '- implement: Implement a feature or fix a bug using aider.\n- edit: Edit files using exact string replacement.\n- create: Create new files with specified content.\n' : ''}${this.enableDelegate ? '- delegate: Delegate big distinct tasks to specialized probe subagents.\n' : ''}${this.enableBash ? '- bash: Execute bash commands for system operations.\n' : ''}
|
|
1266
1288
|
- attempt_completion: Finalize the task and provide the result to the user.
|
|
1267
1289
|
- attempt_complete: Quick completion using previous response (shorthand).
|
|
@@ -1700,10 +1722,8 @@ When troubleshooting:
|
|
|
1700
1722
|
console.log(`[DEBUG] Assistant response (${assistantResponseContent.length} chars): ${assistantPreview}`);
|
|
1701
1723
|
}
|
|
1702
1724
|
|
|
1703
|
-
//
|
|
1704
|
-
|
|
1705
|
-
await this.processImageReferences(assistantResponseContent);
|
|
1706
|
-
}
|
|
1725
|
+
// Images in assistant responses are not automatically processed
|
|
1726
|
+
// AI can use the readImage tool to explicitly request reading an image
|
|
1707
1727
|
|
|
1708
1728
|
// Parse tool call from response with valid tools list
|
|
1709
1729
|
// Build validTools based on allowedTools configuration (same pattern as getSystemMessage)
|
|
@@ -1713,6 +1733,7 @@ When troubleshooting:
|
|
|
1713
1733
|
if (this.allowedTools.isEnabled('extract')) validTools.push('extract');
|
|
1714
1734
|
if (this.allowedTools.isEnabled('listFiles')) validTools.push('listFiles');
|
|
1715
1735
|
if (this.allowedTools.isEnabled('searchFiles')) validTools.push('searchFiles');
|
|
1736
|
+
if (this.allowedTools.isEnabled('readImage')) validTools.push('readImage');
|
|
1716
1737
|
if (this.allowedTools.isEnabled('attempt_completion')) validTools.push('attempt_completion');
|
|
1717
1738
|
|
|
1718
1739
|
// Edit tools (require both allowEdit flag AND allowedTools permission)
|
package/src/agent/tools.js
CHANGED
|
@@ -154,6 +154,31 @@ User: Find all markdown files in the docs directory, but only at the top level.
|
|
|
154
154
|
</examples>
|
|
155
155
|
`;
|
|
156
156
|
|
|
157
|
+
// Define the readImage tool XML definition
|
|
158
|
+
export const readImageToolDefinition = `
|
|
159
|
+
## readImage
|
|
160
|
+
Description: Read and load an image file so it can be viewed by the AI. Use this when you need to analyze, describe, or work with image content. Images from user messages are automatically loaded, but use this tool to explicitly read images mentioned in tool outputs or when you need to examine specific image files.
|
|
161
|
+
|
|
162
|
+
Parameters:
|
|
163
|
+
- path: (required) The path to the image file to read. Supports png, jpg, jpeg, webp, bmp, and svg formats.
|
|
164
|
+
|
|
165
|
+
Usage Example:
|
|
166
|
+
|
|
167
|
+
<examples>
|
|
168
|
+
|
|
169
|
+
User: Can you describe what's in screenshot.png?
|
|
170
|
+
<readImage>
|
|
171
|
+
<path>screenshot.png</path>
|
|
172
|
+
</readImage>
|
|
173
|
+
|
|
174
|
+
User: Analyze the diagram in docs/architecture.svg
|
|
175
|
+
<readImage>
|
|
176
|
+
<path>docs/architecture.svg</path>
|
|
177
|
+
</readImage>
|
|
178
|
+
|
|
179
|
+
</examples>
|
|
180
|
+
`;
|
|
181
|
+
|
|
157
182
|
/**
|
|
158
183
|
* Enhanced XML parser that handles thinking tags and attempt_complete shorthand
|
|
159
184
|
* This function removes any <thinking></thinking> tags from the input string
|