@probelabs/probe 0.6.0-rc229 → 0.6.0-rc231
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/bin/binaries/probe-v0.6.0-rc231-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc231-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc231-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc231-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc231-x86_64-unknown-linux-musl.tar.gz +0 -0
- package/build/agent/ProbeAgent.js +128 -7
- package/build/agent/index.js +191 -12
- package/build/agent/mcp/config.js +7 -1
- package/build/agent/tasks/taskTool.js +32 -2
- package/build/agent/tools.js +4 -0
- package/build/index.js +4 -0
- package/build/tools/common.js +24 -0
- package/build/utils/path-validation.js +28 -2
- package/cjs/agent/ProbeAgent.cjs +8734 -10878
- package/cjs/index.cjs +8748 -10888
- package/package.json +2 -2
- package/src/agent/ProbeAgent.js +128 -7
- package/src/agent/mcp/config.js +7 -1
- package/src/agent/tasks/taskTool.js +32 -2
- package/src/agent/tools.js +4 -0
- package/src/index.js +4 -0
- package/src/tools/common.js +24 -0
- package/src/utils/path-validation.js +28 -2
- package/bin/binaries/probe-v0.6.0-rc229-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc229-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc229-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc229-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc229-x86_64-unknown-linux-musl.tar.gz +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@probelabs/probe",
|
|
3
|
-
"version": "0.6.0-
|
|
3
|
+
"version": "0.6.0-rc231",
|
|
4
4
|
"description": "Node.js wrapper for the probe code search tool",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@ai-sdk/openai": "^2.0.10",
|
|
80
80
|
"@anthropic-ai/claude-agent-sdk": "^0.1.46",
|
|
81
81
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
82
|
-
"@probelabs/maid": "^0.0.
|
|
82
|
+
"@probelabs/maid": "^0.0.24",
|
|
83
83
|
"adm-zip": "^0.5.16",
|
|
84
84
|
"ai": "^5.0.0",
|
|
85
85
|
"ajv": "^8.17.1",
|
package/src/agent/ProbeAgent.js
CHANGED
|
@@ -58,6 +58,8 @@ import {
|
|
|
58
58
|
implementToolDefinition,
|
|
59
59
|
editToolDefinition,
|
|
60
60
|
createToolDefinition,
|
|
61
|
+
googleSearchToolDefinition,
|
|
62
|
+
urlContextToolDefinition,
|
|
61
63
|
attemptCompletionSchema,
|
|
62
64
|
parseXmlToolCallWithThinking
|
|
63
65
|
} from './tools.js';
|
|
@@ -404,6 +406,10 @@ export class ProbeAgent {
|
|
|
404
406
|
// Initialize the AI model
|
|
405
407
|
this.initializeModel();
|
|
406
408
|
|
|
409
|
+
// Gemini built-in tools (provider-defined, server-side)
|
|
410
|
+
// These are enabled automatically when the provider is Google
|
|
411
|
+
this._geminiToolsEnabled = this._initializeGeminiBuiltinTools();
|
|
412
|
+
|
|
407
413
|
// Note: MCP initialization is now done in initialize() method
|
|
408
414
|
// Constructor must remain synchronous for backward compatibility
|
|
409
415
|
}
|
|
@@ -1320,6 +1326,15 @@ export class ProbeAgent {
|
|
|
1320
1326
|
abortSignal: controller.signal
|
|
1321
1327
|
};
|
|
1322
1328
|
|
|
1329
|
+
// Strip Gemini provider-defined tools when falling back to non-Google provider
|
|
1330
|
+
// These tools have no execute function and would cause errors on other providers
|
|
1331
|
+
if (config.provider !== 'google' && fallbackOptions.tools) {
|
|
1332
|
+
delete fallbackOptions.tools;
|
|
1333
|
+
if (this.debug) {
|
|
1334
|
+
console.error(`[DEBUG] Stripped Gemini built-in tools for fallback to ${config.provider} provider`);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1323
1338
|
const providerRetryManager = new RetryManager({
|
|
1324
1339
|
maxRetries: config.maxRetries ?? this.retryConfig.maxRetries ?? 3,
|
|
1325
1340
|
initialDelay: this.retryConfig.initialDelay ?? 1000,
|
|
@@ -1442,6 +1457,83 @@ export class ProbeAgent {
|
|
|
1442
1457
|
}
|
|
1443
1458
|
}
|
|
1444
1459
|
|
|
1460
|
+
/**
|
|
1461
|
+
* Initialize Gemini built-in tools (gemini_google_search, gemini_url_context).
|
|
1462
|
+
* These are provider-defined tools that execute server-side on Google's infrastructure.
|
|
1463
|
+
* They are only available when the provider is Google Gemini.
|
|
1464
|
+
* @returns {{ googleSearch: boolean, urlContext: boolean }} Which tools were enabled
|
|
1465
|
+
* @private
|
|
1466
|
+
*/
|
|
1467
|
+
_initializeGeminiBuiltinTools() {
|
|
1468
|
+
const isToolAllowed = (toolName) => this.allowedTools.isEnabled(toolName);
|
|
1469
|
+
const result = { googleSearch: false, urlContext: false };
|
|
1470
|
+
|
|
1471
|
+
if (this.apiType !== 'google') {
|
|
1472
|
+
// Log info about unavailability for non-Google providers
|
|
1473
|
+
if (isToolAllowed('gemini_google_search') || isToolAllowed('gemini_url_context')) {
|
|
1474
|
+
if (this.debug) {
|
|
1475
|
+
console.error(`[DEBUG] Gemini built-in tools (gemini_google_search, gemini_url_context) are not available: provider is '${this.apiType}', not 'google'. These tools require the Google Gemini provider.`);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
return result;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
// Check SDK support
|
|
1482
|
+
if (!this.provider || !this.provider.tools) {
|
|
1483
|
+
console.error('[ProbeAgent] Gemini built-in tools unavailable: @ai-sdk/google does not expose provider.tools. Upgrade to @ai-sdk/google v2.0.14+.');
|
|
1484
|
+
return result;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
if (isToolAllowed('gemini_google_search')) {
|
|
1488
|
+
result.googleSearch = true;
|
|
1489
|
+
if (this.debug) {
|
|
1490
|
+
console.error('[DEBUG] Gemini built-in tool enabled: gemini_google_search');
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
if (isToolAllowed('gemini_url_context')) {
|
|
1495
|
+
result.urlContext = true;
|
|
1496
|
+
if (this.debug) {
|
|
1497
|
+
console.error('[DEBUG] Gemini built-in tool enabled: gemini_url_context');
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
return result;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
/**
|
|
1505
|
+
* Build Gemini provider-defined tools object for streamText().
|
|
1506
|
+
* Returns undefined if no Gemini tools are enabled.
|
|
1507
|
+
* @returns {Object|undefined}
|
|
1508
|
+
* @private
|
|
1509
|
+
*/
|
|
1510
|
+
_buildGeminiProviderTools() {
|
|
1511
|
+
if (this.apiType !== 'google' || !this._geminiToolsEnabled) {
|
|
1512
|
+
return undefined;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
const { googleSearch, urlContext } = this._geminiToolsEnabled;
|
|
1516
|
+
if (!googleSearch && !urlContext) {
|
|
1517
|
+
return undefined;
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
if (!this.provider || !this.provider.tools) {
|
|
1521
|
+
return undefined;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
const tools = {};
|
|
1525
|
+
const providerTools = this.provider.tools;
|
|
1526
|
+
|
|
1527
|
+
if (googleSearch && providerTools.googleSearch) {
|
|
1528
|
+
tools.google_search = providerTools.googleSearch({});
|
|
1529
|
+
}
|
|
1530
|
+
if (urlContext && providerTools.urlContext) {
|
|
1531
|
+
tools.url_context = providerTools.urlContext({});
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
return Object.keys(tools).length > 0 ? tools : undefined;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1445
1537
|
/**
|
|
1446
1538
|
* Initialize AWS Bedrock model
|
|
1447
1539
|
*/
|
|
@@ -2404,10 +2496,9 @@ ${extractGuidance}
|
|
|
2404
2496
|
toolDefinitions += `${taskToolDefinition}\n`;
|
|
2405
2497
|
}
|
|
2406
2498
|
|
|
2407
|
-
// Always include attempt_completion
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
}
|
|
2499
|
+
// Always include attempt_completion unconditionally - it's a completion signal, not a tool
|
|
2500
|
+
// This ensures agents can always complete their work, regardless of tool restrictions
|
|
2501
|
+
toolDefinitions += `${attemptCompletionToolDefinition}\n`;
|
|
2411
2502
|
|
|
2412
2503
|
// Delegate tool (require both enableDelegate flag AND allowedTools permission)
|
|
2413
2504
|
// Place after attempt_completion as it's an optional tool
|
|
@@ -2420,6 +2511,14 @@ ${extractGuidance}
|
|
|
2420
2511
|
toolDefinitions += `${analyzeAllToolDefinition}\n`;
|
|
2421
2512
|
}
|
|
2422
2513
|
|
|
2514
|
+
// Gemini built-in tools (only when using Google provider)
|
|
2515
|
+
if (this._geminiToolsEnabled?.googleSearch && isToolAllowed('gemini_google_search')) {
|
|
2516
|
+
toolDefinitions += `${googleSearchToolDefinition}\n`;
|
|
2517
|
+
}
|
|
2518
|
+
if (this._geminiToolsEnabled?.urlContext && isToolAllowed('gemini_url_context')) {
|
|
2519
|
+
toolDefinitions += `${urlContextToolDefinition}\n`;
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2423
2522
|
// Build XML tool guidelines with dynamic examples based on allowed tools
|
|
2424
2523
|
// Build examples only for allowed tools
|
|
2425
2524
|
let toolExamples = '';
|
|
@@ -2497,6 +2596,12 @@ The configuration is loaded from src/config.js lines 15-25 which contains the da
|
|
|
2497
2596
|
availableToolsList += '- attempt_completion: Finalize the task and provide the result to the user.\n';
|
|
2498
2597
|
availableToolsList += '- attempt_complete: Quick completion using previous response (shorthand).\n';
|
|
2499
2598
|
}
|
|
2599
|
+
if (this._geminiToolsEnabled?.googleSearch && isToolAllowed('gemini_google_search')) {
|
|
2600
|
+
availableToolsList += '- gemini_google_search: (auto) Web search via Google — invoked automatically by the model when it needs current information.\n';
|
|
2601
|
+
}
|
|
2602
|
+
if (this._geminiToolsEnabled?.urlContext && isToolAllowed('gemini_url_context')) {
|
|
2603
|
+
availableToolsList += '- gemini_url_context: (auto) URL content reader via Google — automatically fetches and reads URLs mentioned in the conversation.\n';
|
|
2604
|
+
}
|
|
2500
2605
|
|
|
2501
2606
|
let xmlToolGuidelines = `
|
|
2502
2607
|
# Tool Use Formatting
|
|
@@ -3049,12 +3154,21 @@ Follow these instructions carefully:
|
|
|
3049
3154
|
// Prepare messages with potential image content
|
|
3050
3155
|
const messagesForAI = this.prepareMessagesWithImages(currentMessages);
|
|
3051
3156
|
|
|
3052
|
-
|
|
3157
|
+
// Build streamText options, including Gemini provider-defined tools if applicable
|
|
3158
|
+
const streamOptions = {
|
|
3053
3159
|
model: this.provider ? this.provider(this.model) : this.model,
|
|
3054
3160
|
messages: messagesForAI,
|
|
3055
3161
|
maxTokens: maxResponseTokens,
|
|
3056
3162
|
temperature: 0.3,
|
|
3057
|
-
}
|
|
3163
|
+
};
|
|
3164
|
+
|
|
3165
|
+
// Inject Gemini built-in tools (gemini_google_search, gemini_url_context) when using Google provider
|
|
3166
|
+
const geminiProviderTools = this._buildGeminiProviderTools();
|
|
3167
|
+
if (geminiProviderTools) {
|
|
3168
|
+
streamOptions.tools = geminiProviderTools;
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
const result = await this.streamTextWithRetryAndFallback(streamOptions);
|
|
3058
3172
|
|
|
3059
3173
|
// Get the promise reference BEFORE consuming stream (doesn't lock it)
|
|
3060
3174
|
const usagePromise = result.usage;
|
|
@@ -3189,8 +3303,9 @@ Follow these instructions carefully:
|
|
|
3189
3303
|
if (this.enableSkills && this.allowedTools.isEnabled('listSkills')) validTools.push('listSkills');
|
|
3190
3304
|
if (this.enableSkills && this.allowedTools.isEnabled('useSkill')) validTools.push('useSkill');
|
|
3191
3305
|
if (this.allowedTools.isEnabled('readImage')) validTools.push('readImage');
|
|
3192
|
-
// Always allow attempt_completion - it's a completion signal, not a tool
|
|
3306
|
+
// Always allow attempt_completion in validTools - it's a completion signal, not a tool
|
|
3193
3307
|
// This ensures agents can complete even when disableTools: true is set (fixes #333)
|
|
3308
|
+
// The tool DEFINITION may be hidden in raw AI mode, but we still need to recognize it
|
|
3194
3309
|
validTools.push('attempt_completion');
|
|
3195
3310
|
|
|
3196
3311
|
// Edit tools (require both allowEdit flag AND allowedTools permission)
|
|
@@ -3585,6 +3700,12 @@ Follow these instructions carefully:
|
|
|
3585
3700
|
|
|
3586
3701
|
let toolResultContent = typeof toolResult === 'string' ? toolResult : JSON.stringify(toolResult, null, 2);
|
|
3587
3702
|
|
|
3703
|
+
// Convert absolute workspace paths to relative in tool results
|
|
3704
|
+
if (this.workspaceRoot && toolResultContent) {
|
|
3705
|
+
const wsPrefix = this.workspaceRoot.endsWith(sep) ? this.workspaceRoot : this.workspaceRoot + sep;
|
|
3706
|
+
toolResultContent = toolResultContent.split(wsPrefix).join('');
|
|
3707
|
+
}
|
|
3708
|
+
|
|
3588
3709
|
// Truncate if output exceeds token limit
|
|
3589
3710
|
try {
|
|
3590
3711
|
const truncateResult = await truncateIfNeeded(toolResultContent, this.tokenCounter, this.sessionId, this.maxOutputTokens);
|
package/src/agent/mcp/config.js
CHANGED
|
@@ -15,7 +15,13 @@ const __dirname = dirname(__filename);
|
|
|
15
15
|
* Timeout configuration constants
|
|
16
16
|
*/
|
|
17
17
|
export const DEFAULT_TIMEOUT = 30000; // 30 seconds
|
|
18
|
-
export const MAX_TIMEOUT =
|
|
18
|
+
export const MAX_TIMEOUT = (() => {
|
|
19
|
+
if (process.env.MCP_MAX_TIMEOUT) {
|
|
20
|
+
const parsed = parseInt(process.env.MCP_MAX_TIMEOUT, 10);
|
|
21
|
+
if (!isNaN(parsed) && parsed >= 30000 && parsed <= 7200000) return parsed;
|
|
22
|
+
}
|
|
23
|
+
return 1800000; // 30 minutes default - workflow tools (code checkouts, AI exploration) need time
|
|
24
|
+
})();
|
|
19
25
|
|
|
20
26
|
/**
|
|
21
27
|
* Validate and normalize a timeout value
|
|
@@ -23,7 +23,8 @@ export const taskItemSchema = z.object({
|
|
|
23
23
|
*/
|
|
24
24
|
export const taskSchema = z.object({
|
|
25
25
|
action: z.enum(['create', 'update', 'complete', 'delete', 'list']),
|
|
26
|
-
|
|
26
|
+
// Accept both array and JSON string (AI models sometimes serialize as string)
|
|
27
|
+
tasks: z.union([z.array(z.union([z.string(), taskItemSchema])), z.string()]).optional(),
|
|
27
28
|
id: z.string().optional(),
|
|
28
29
|
title: z.string().optional(),
|
|
29
30
|
description: z.string().optional(),
|
|
@@ -142,6 +143,25 @@ SKIP TASKS for single-goal requests, even if they require multiple searches:
|
|
|
142
143
|
**Key insight**: Multiple *internal steps* (search, read, analyze) are NOT the same as multiple *goals*.
|
|
143
144
|
A single investigation with many steps is still ONE task, not many.
|
|
144
145
|
|
|
146
|
+
## Task Granularity
|
|
147
|
+
|
|
148
|
+
Tasks represent LOGICAL UNITS OF WORK, not individual files or steps:
|
|
149
|
+
- "Fix 8 similar test files" → ONE task (same type of fix across files)
|
|
150
|
+
- "Update API + tests + docs" → THREE tasks (different types of work)
|
|
151
|
+
- "Implement feature in 5 files" → ONE task (single feature)
|
|
152
|
+
|
|
153
|
+
**Rule of thumb**: If you're creating more than 3-4 tasks, you're probably too granular.
|
|
154
|
+
|
|
155
|
+
**Anti-patterns to avoid**:
|
|
156
|
+
- One task per file ❌
|
|
157
|
+
- One task per function ❌
|
|
158
|
+
- One task per repository (when same type of work) ❌
|
|
159
|
+
|
|
160
|
+
**Good patterns**:
|
|
161
|
+
- One task per distinct deliverable ✓
|
|
162
|
+
- One task per phase (implement, test, document) ✓
|
|
163
|
+
- One task per different type of work ✓
|
|
164
|
+
|
|
145
165
|
MODIFY TASKS when (during execution):
|
|
146
166
|
- You discover the problem is more complex than expected → Add new tasks
|
|
147
167
|
- A single task covers too much scope → Split into smaller tasks
|
|
@@ -314,7 +334,17 @@ export function createTaskTool(options = {}) {
|
|
|
314
334
|
return `Error: Invalid task parameters - ${validation.error.message}`;
|
|
315
335
|
}
|
|
316
336
|
|
|
317
|
-
const { action, tasks, id, title, description, status, priority, dependencies, after } = validation.data;
|
|
337
|
+
const { action, tasks: rawTasks, id, title, description, status, priority, dependencies, after } = validation.data;
|
|
338
|
+
|
|
339
|
+
// Parse tasks if passed as JSON string (common AI model behavior)
|
|
340
|
+
let tasks = rawTasks;
|
|
341
|
+
if (typeof rawTasks === 'string') {
|
|
342
|
+
try {
|
|
343
|
+
tasks = JSON.parse(rawTasks);
|
|
344
|
+
} catch (e) {
|
|
345
|
+
return `Error: Invalid tasks JSON - ${e.message}`;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
318
348
|
|
|
319
349
|
switch (action) {
|
|
320
350
|
case 'create': {
|
package/src/agent/tools.js
CHANGED
|
@@ -27,6 +27,8 @@ import {
|
|
|
27
27
|
bashToolDefinition,
|
|
28
28
|
editToolDefinition,
|
|
29
29
|
createToolDefinition,
|
|
30
|
+
googleSearchToolDefinition,
|
|
31
|
+
urlContextToolDefinition,
|
|
30
32
|
parseXmlToolCall
|
|
31
33
|
} from '../index.js';
|
|
32
34
|
import { randomUUID } from 'crypto';
|
|
@@ -108,6 +110,8 @@ export {
|
|
|
108
110
|
editToolDefinition,
|
|
109
111
|
createToolDefinition,
|
|
110
112
|
attemptCompletionToolDefinition,
|
|
113
|
+
googleSearchToolDefinition,
|
|
114
|
+
urlContextToolDefinition,
|
|
111
115
|
parseXmlToolCall
|
|
112
116
|
};
|
|
113
117
|
|
package/src/index.js
CHANGED
|
@@ -35,6 +35,8 @@ import {
|
|
|
35
35
|
analyzeAllToolDefinition,
|
|
36
36
|
attemptCompletionToolDefinition,
|
|
37
37
|
bashToolDefinition,
|
|
38
|
+
googleSearchToolDefinition,
|
|
39
|
+
urlContextToolDefinition,
|
|
38
40
|
parseXmlToolCall
|
|
39
41
|
} from './tools/common.js';
|
|
40
42
|
import {
|
|
@@ -114,6 +116,8 @@ export {
|
|
|
114
116
|
bashToolDefinition,
|
|
115
117
|
editToolDefinition,
|
|
116
118
|
createToolDefinition,
|
|
119
|
+
googleSearchToolDefinition,
|
|
120
|
+
urlContextToolDefinition,
|
|
117
121
|
// Export parser function
|
|
118
122
|
parseXmlToolCall,
|
|
119
123
|
// Export task management
|
package/src/tools/common.js
CHANGED
|
@@ -386,6 +386,30 @@ User: Check system info
|
|
|
386
386
|
</examples>
|
|
387
387
|
`;
|
|
388
388
|
|
|
389
|
+
export const googleSearchToolDefinition = `
|
|
390
|
+
## gemini_google_search (Gemini Built-in)
|
|
391
|
+
Description: Web search powered by Google. This is a built-in Gemini capability that automatically searches the web when the model needs current information. The model decides when to search and integrates results directly into its response with source citations.
|
|
392
|
+
|
|
393
|
+
This tool is invoked automatically by the model — you do NOT need to use XML tool calls for it. Simply ask questions that require up-to-date or real-world information and the model will search the web as needed.
|
|
394
|
+
|
|
395
|
+
Capabilities:
|
|
396
|
+
- Real-time web search with grounded citations
|
|
397
|
+
- Automatic query generation and result synthesis
|
|
398
|
+
- Source attribution with URLs
|
|
399
|
+
`;
|
|
400
|
+
|
|
401
|
+
export const urlContextToolDefinition = `
|
|
402
|
+
## gemini_url_context (Gemini Built-in)
|
|
403
|
+
Description: URL content reader powered by Google. This is a built-in Gemini capability that automatically fetches and analyzes the content of URLs mentioned in the conversation. When you include URLs in your message, the model can read and understand their content.
|
|
404
|
+
|
|
405
|
+
This tool is invoked automatically by the model — you do NOT need to use XML tool calls for it. Simply include URLs in your message and the model will fetch and analyze their content.
|
|
406
|
+
|
|
407
|
+
Capabilities:
|
|
408
|
+
- Fetch and read web page content from URLs in the prompt
|
|
409
|
+
- Supports up to 20 URLs per request
|
|
410
|
+
- Processes HTML content (does not execute JavaScript)
|
|
411
|
+
`;
|
|
412
|
+
|
|
389
413
|
export const searchDescription = 'Search code in the repository. Free-form questions are accepted, but Elasticsearch-style keyword queries work best. Use this tool first for any code-related questions.';
|
|
390
414
|
export const queryDescription = 'Search code using ast-grep structural pattern matching. Use this tool to find specific code structures like functions, classes, or methods.';
|
|
391
415
|
export const extractDescription = 'Extract code blocks from files based on file paths and optional line numbers. Use this tool to see complete context after finding relevant files.';
|
|
@@ -55,9 +55,9 @@ export function safeRealpath(inputPath) {
|
|
|
55
55
|
* - Does NOT restrict access to specific directories (that's the responsibility
|
|
56
56
|
* of higher-level components like ProbeAgent with allowedFolders)
|
|
57
57
|
*
|
|
58
|
-
* @param {string} inputPath - The path to validate
|
|
58
|
+
* @param {string} inputPath - The path to validate (can be a file or directory; file paths are resolved to their parent directory)
|
|
59
59
|
* @param {string} [defaultPath] - Default path to use if inputPath is not provided
|
|
60
|
-
* @returns {Promise<string>} Normalized absolute path
|
|
60
|
+
* @returns {Promise<string>} Normalized absolute directory path. If inputPath is a file, returns its parent directory.
|
|
61
61
|
* @throws {PathError} If the path is invalid or doesn't exist
|
|
62
62
|
*/
|
|
63
63
|
export async function validateCwdPath(inputPath, defaultPath = process.cwd()) {
|
|
@@ -72,6 +72,32 @@ export async function validateCwdPath(inputPath, defaultPath = process.cwd()) {
|
|
|
72
72
|
try {
|
|
73
73
|
const stats = await fs.stat(normalizedPath);
|
|
74
74
|
if (!stats.isDirectory()) {
|
|
75
|
+
// If the path is a file, resolve to its parent directory
|
|
76
|
+
// This handles cases where a file path is passed as cwd
|
|
77
|
+
// Use safeRealpath to resolve symlinks before extracting parent directory
|
|
78
|
+
const resolvedPath = safeRealpath(normalizedPath);
|
|
79
|
+
const dirPath = path.dirname(resolvedPath);
|
|
80
|
+
try {
|
|
81
|
+
const dirStats = await fs.stat(dirPath);
|
|
82
|
+
if (dirStats.isDirectory()) {
|
|
83
|
+
return safeRealpath(dirPath);
|
|
84
|
+
}
|
|
85
|
+
} catch (dirError) {
|
|
86
|
+
if (dirError.code === 'ENOENT') {
|
|
87
|
+
throw new PathError(`Parent directory does not exist for file: ${normalizedPath}`, {
|
|
88
|
+
suggestion: 'The specified path is a file whose parent directory does not exist.',
|
|
89
|
+
details: { path: normalizedPath, parentPath: dirPath, type: 'file' }
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (dirError.code === 'EACCES') {
|
|
93
|
+
throw new PathError(`Permission denied accessing parent directory: ${dirPath}`, {
|
|
94
|
+
recoverable: false,
|
|
95
|
+
suggestion: 'Permission denied accessing the parent directory of the specified file.',
|
|
96
|
+
details: { path: normalizedPath, parentPath: dirPath, type: 'file' }
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
throw dirError;
|
|
100
|
+
}
|
|
75
101
|
throw new PathError(`Path is not a directory: ${normalizedPath}`, {
|
|
76
102
|
suggestion: 'The specified path is a file, not a directory. Please provide a directory path for searching.',
|
|
77
103
|
details: { path: normalizedPath, type: 'file' }
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|