@probelabs/probe 0.6.0-rc116 → 0.6.0-rc117
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 +100 -10
- package/build/agent/index.js +342 -217
- package/build/agent/probeTool.js +93 -18
- package/build/agent/schemaUtils.js +1 -1
- package/build/index.js +4 -0
- package/cjs/agent/ProbeAgent.cjs +343 -218
- package/cjs/index.cjs +142 -13
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +100 -10
- package/src/agent/probeTool.js +93 -18
- package/src/agent/schemaUtils.js +1 -1
- package/src/index.js +4 -0
|
@@ -188,9 +188,23 @@ export class ProbeAgent {
|
|
|
188
188
|
if (this.enableBash && wrappedTools.bashToolInstance) {
|
|
189
189
|
this.toolImplementations.bash = wrappedTools.bashToolInstance;
|
|
190
190
|
}
|
|
191
|
-
|
|
191
|
+
|
|
192
192
|
// Store wrapped tools for ACP system
|
|
193
193
|
this.wrappedTools = wrappedTools;
|
|
194
|
+
|
|
195
|
+
// Log available tools in debug mode
|
|
196
|
+
if (this.debug) {
|
|
197
|
+
console.error('\n[DEBUG] ========================================');
|
|
198
|
+
console.error('[DEBUG] ProbeAgent Tools Initialized');
|
|
199
|
+
console.error('[DEBUG] Session ID:', this.sessionId);
|
|
200
|
+
console.error('[DEBUG] Available tools:');
|
|
201
|
+
for (const toolName of Object.keys(this.toolImplementations)) {
|
|
202
|
+
console.error(`[DEBUG] - ${toolName}`);
|
|
203
|
+
}
|
|
204
|
+
console.error('[DEBUG] Allowed folders:', this.allowedFolders);
|
|
205
|
+
console.error('[DEBUG] Outline mode:', this.outline);
|
|
206
|
+
console.error('[DEBUG] ========================================\n');
|
|
207
|
+
}
|
|
194
208
|
}
|
|
195
209
|
|
|
196
210
|
/**
|
|
@@ -1117,34 +1131,74 @@ When troubleshooting:
|
|
|
1117
1131
|
if (type === 'mcp' && this.mcpBridge && this.mcpBridge.isMcpTool(toolName)) {
|
|
1118
1132
|
// Execute MCP tool
|
|
1119
1133
|
try {
|
|
1120
|
-
|
|
1134
|
+
// Log MCP tool execution in debug mode
|
|
1135
|
+
if (this.debug) {
|
|
1136
|
+
console.error(`\n[DEBUG] ========================================`);
|
|
1137
|
+
console.error(`[DEBUG] Executing MCP tool: ${toolName}`);
|
|
1138
|
+
console.error(`[DEBUG] Arguments:`);
|
|
1139
|
+
for (const [key, value] of Object.entries(params)) {
|
|
1140
|
+
const displayValue = typeof value === 'string' && value.length > 100
|
|
1141
|
+
? value.substring(0, 100) + '...'
|
|
1142
|
+
: value;
|
|
1143
|
+
console.error(`[DEBUG] ${key}: ${JSON.stringify(displayValue)}`);
|
|
1144
|
+
}
|
|
1145
|
+
console.error(`[DEBUG] ========================================\n`);
|
|
1146
|
+
}
|
|
1121
1147
|
|
|
1122
1148
|
// Execute MCP tool through the bridge
|
|
1123
1149
|
const executionResult = await this.mcpBridge.mcpTools[toolName].execute(params);
|
|
1124
1150
|
|
|
1125
1151
|
const toolResultContent = typeof executionResult === 'string' ? executionResult : JSON.stringify(executionResult, null, 2);
|
|
1126
|
-
|
|
1152
|
+
|
|
1153
|
+
// Log MCP tool result in debug mode
|
|
1127
1154
|
if (this.debug) {
|
|
1128
|
-
|
|
1155
|
+
const preview = toolResultContent.length > 500 ? toolResultContent.substring(0, 500) + '...' : toolResultContent;
|
|
1156
|
+
console.error(`[DEBUG] ========================================`);
|
|
1157
|
+
console.error(`[DEBUG] MCP tool '${toolName}' completed successfully`);
|
|
1158
|
+
console.error(`[DEBUG] Result preview:`);
|
|
1159
|
+
console.error(preview);
|
|
1160
|
+
console.error(`[DEBUG] ========================================\n`);
|
|
1129
1161
|
}
|
|
1130
1162
|
|
|
1131
1163
|
currentMessages.push({ role: 'user', content: `<tool_result>\n${toolResultContent}\n</tool_result>` });
|
|
1132
1164
|
} catch (error) {
|
|
1133
1165
|
console.error(`Error executing MCP tool ${toolName}:`, error);
|
|
1134
1166
|
const toolResultContent = `Error executing MCP tool ${toolName}: ${error.message}`;
|
|
1135
|
-
|
|
1167
|
+
|
|
1168
|
+
// Log MCP tool error in debug mode
|
|
1169
|
+
if (this.debug) {
|
|
1170
|
+
console.error(`[DEBUG] ========================================`);
|
|
1171
|
+
console.error(`[DEBUG] MCP tool '${toolName}' failed with error:`);
|
|
1172
|
+
console.error(`[DEBUG] ${error.message}`);
|
|
1173
|
+
console.error(`[DEBUG] ========================================\n`);
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1136
1176
|
currentMessages.push({ role: 'user', content: `<tool_result>\n${toolResultContent}\n</tool_result>` });
|
|
1137
1177
|
}
|
|
1138
1178
|
} else if (this.toolImplementations[toolName]) {
|
|
1139
1179
|
// Execute native tool
|
|
1140
1180
|
try {
|
|
1141
1181
|
// Add sessionId and workingDirectory to params for tool execution
|
|
1142
|
-
const toolParams = {
|
|
1143
|
-
...params,
|
|
1182
|
+
const toolParams = {
|
|
1183
|
+
...params,
|
|
1144
1184
|
sessionId: this.sessionId,
|
|
1145
1185
|
workingDirectory: (this.allowedFolders && this.allowedFolders[0]) || process.cwd()
|
|
1146
1186
|
};
|
|
1147
|
-
|
|
1187
|
+
|
|
1188
|
+
// Log tool execution in debug mode
|
|
1189
|
+
if (this.debug) {
|
|
1190
|
+
console.error(`\n[DEBUG] ========================================`);
|
|
1191
|
+
console.error(`[DEBUG] Executing tool: ${toolName}`);
|
|
1192
|
+
console.error(`[DEBUG] Arguments:`);
|
|
1193
|
+
for (const [key, value] of Object.entries(params)) {
|
|
1194
|
+
const displayValue = typeof value === 'string' && value.length > 100
|
|
1195
|
+
? value.substring(0, 100) + '...'
|
|
1196
|
+
: value;
|
|
1197
|
+
console.error(`[DEBUG] ${key}: ${JSON.stringify(displayValue)}`);
|
|
1198
|
+
}
|
|
1199
|
+
console.error(`[DEBUG] ========================================\n`);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1148
1202
|
// Emit tool start event
|
|
1149
1203
|
this.events.emit('toolCall', {
|
|
1150
1204
|
timestamp: new Date().toISOString(),
|
|
@@ -1196,6 +1250,18 @@ When troubleshooting:
|
|
|
1196
1250
|
toolResult = await executeToolCall();
|
|
1197
1251
|
}
|
|
1198
1252
|
|
|
1253
|
+
// Log tool result in debug mode
|
|
1254
|
+
if (this.debug) {
|
|
1255
|
+
const resultPreview = typeof toolResult === 'string'
|
|
1256
|
+
? (toolResult.length > 500 ? toolResult.substring(0, 500) + '...' : toolResult)
|
|
1257
|
+
: (toolResult ? JSON.stringify(toolResult, null, 2).substring(0, 500) + '...' : 'No Result');
|
|
1258
|
+
console.error(`[DEBUG] ========================================`);
|
|
1259
|
+
console.error(`[DEBUG] Tool '${toolName}' completed successfully`);
|
|
1260
|
+
console.error(`[DEBUG] Result preview:`);
|
|
1261
|
+
console.error(resultPreview);
|
|
1262
|
+
console.error(`[DEBUG] ========================================\n`);
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1199
1265
|
// Emit tool success event
|
|
1200
1266
|
this.events.emit('toolCall', {
|
|
1201
1267
|
timestamp: new Date().toISOString(),
|
|
@@ -1206,8 +1272,16 @@ When troubleshooting:
|
|
|
1206
1272
|
: (toolResult ? JSON.stringify(toolResult).substring(0, 200) + '...' : 'No Result'),
|
|
1207
1273
|
status: 'completed'
|
|
1208
1274
|
});
|
|
1209
|
-
|
|
1275
|
+
|
|
1210
1276
|
} catch (toolError) {
|
|
1277
|
+
// Log tool error in debug mode
|
|
1278
|
+
if (this.debug) {
|
|
1279
|
+
console.error(`[DEBUG] ========================================`);
|
|
1280
|
+
console.error(`[DEBUG] Tool '${toolName}' failed with error:`);
|
|
1281
|
+
console.error(`[DEBUG] ${toolError.message}`);
|
|
1282
|
+
console.error(`[DEBUG] ========================================\n`);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1211
1285
|
// Emit tool error event
|
|
1212
1286
|
this.events.emit('toolCall', {
|
|
1213
1287
|
timestamp: new Date().toISOString(),
|
|
@@ -1262,7 +1336,23 @@ When troubleshooting:
|
|
|
1262
1336
|
}
|
|
1263
1337
|
}
|
|
1264
1338
|
} else {
|
|
1265
|
-
// No tool call found
|
|
1339
|
+
// No tool call found
|
|
1340
|
+
// Special case: If response contains a mermaid code block and no schema was provided,
|
|
1341
|
+
// treat it as a valid completion (for mermaid diagram fixing workflow)
|
|
1342
|
+
const hasMermaidCodeBlock = /```mermaid\s*\n[\s\S]*?\n```/.test(assistantResponseContent);
|
|
1343
|
+
const hasNoSchemaOrTools = !options.schema && validTools.length === 0;
|
|
1344
|
+
|
|
1345
|
+
if (hasMermaidCodeBlock && hasNoSchemaOrTools) {
|
|
1346
|
+
// Accept mermaid code block as final answer for diagram fixing
|
|
1347
|
+
finalResult = assistantResponseContent;
|
|
1348
|
+
completionAttempted = true;
|
|
1349
|
+
if (this.debug) {
|
|
1350
|
+
console.error(`[DEBUG] Accepting mermaid code block as valid completion (no schema, no tools)`);
|
|
1351
|
+
}
|
|
1352
|
+
break;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
// Add assistant response and ask for tool usage
|
|
1266
1356
|
currentMessages.push({ role: 'assistant', content: assistantResponseContent });
|
|
1267
1357
|
|
|
1268
1358
|
// Build appropriate reminder message based on whether schema is provided
|