@vybestack/llxprt-code-core 0.1.18-nightly.250808.f9b79d74 → 0.1.18-nightly.250812.12fa8ad2
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/README.md +49 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/src/auth/anthropic-device-flow.d.ts +53 -0
- package/dist/src/auth/anthropic-device-flow.js +208 -0
- package/dist/src/auth/anthropic-device-flow.js.map +1 -0
- package/dist/src/auth/precedence.d.ts +55 -0
- package/dist/src/auth/precedence.js +211 -0
- package/dist/src/auth/precedence.js.map +1 -0
- package/dist/src/auth/qwen-device-flow.d.ts +45 -0
- package/dist/src/auth/qwen-device-flow.js +179 -0
- package/dist/src/auth/qwen-device-flow.js.map +1 -0
- package/dist/src/auth/token-store.d.ts +66 -0
- package/dist/src/auth/token-store.js +151 -0
- package/dist/src/auth/token-store.js.map +1 -0
- package/dist/src/auth/types.d.ts +130 -0
- package/dist/src/auth/types.js +60 -0
- package/dist/src/auth/types.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +2 -1
- package/dist/src/code_assist/converter.js +1 -1
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/oauth2.js +2 -1
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/config/config.d.ts +78 -3
- package/dist/src/config/config.js +159 -6
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/endpoints.d.ts +60 -0
- package/dist/src/config/endpoints.js +126 -0
- package/dist/src/config/endpoints.js.map +1 -0
- package/dist/src/config/profileManager.d.ts +14 -4
- package/dist/src/config/profileManager.js +90 -11
- package/dist/src/config/profileManager.js.map +1 -1
- package/dist/src/core/client.js +16 -16
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +4 -1
- package/dist/src/core/contentGenerator.js +3 -0
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/logger.d.ts +1 -0
- package/dist/src/core/logger.js +18 -0
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +24 -0
- package/dist/src/core/loggingContentGenerator.js +89 -0
- package/dist/src/core/loggingContentGenerator.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.js +17 -0
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/subagent.js +12 -10
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +2 -2
- package/dist/src/ide/ide-client.js +56 -18
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +12 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/providers/BaseProvider.d.ts +149 -0
- package/dist/src/providers/BaseProvider.js +315 -0
- package/dist/src/providers/BaseProvider.js.map +1 -0
- package/dist/src/providers/IProvider.d.ts +1 -0
- package/dist/src/providers/IProviderManager.d.ts +5 -0
- package/dist/src/providers/LoggingProviderWrapper.d.ts +54 -0
- package/dist/src/providers/LoggingProviderWrapper.js +350 -0
- package/dist/src/providers/LoggingProviderWrapper.js.map +1 -0
- package/dist/src/providers/ProviderManager.d.ts +20 -1
- package/dist/src/providers/ProviderManager.js +236 -14
- package/dist/src/providers/ProviderManager.js.map +1 -1
- package/dist/src/providers/anthropic/AnthropicProvider.d.ts +20 -6
- package/dist/src/providers/anthropic/AnthropicProvider.js +172 -26
- package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
- package/dist/src/providers/gemini/GeminiProvider.d.ts +16 -7
- package/dist/src/providers/gemini/GeminiProvider.js +163 -148
- package/dist/src/providers/gemini/GeminiProvider.js.map +1 -1
- package/dist/src/providers/logging/ProviderContentExtractor.d.ts +27 -0
- package/dist/src/providers/logging/ProviderContentExtractor.js +198 -0
- package/dist/src/providers/logging/ProviderContentExtractor.js.map +1 -0
- package/dist/src/providers/logging/ProviderPerformanceTracker.d.ts +43 -0
- package/dist/src/providers/logging/ProviderPerformanceTracker.js +98 -0
- package/dist/src/providers/logging/ProviderPerformanceTracker.js.map +1 -0
- package/dist/src/providers/openai/OpenAIProvider.d.ts +53 -6
- package/dist/src/providers/openai/OpenAIProvider.js +373 -40
- package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
- package/dist/src/providers/openai/RESPONSES_API_MODELS.d.ts +1 -1
- package/dist/src/providers/openai/RESPONSES_API_MODELS.js +1 -0
- package/dist/src/providers/openai/RESPONSES_API_MODELS.js.map +1 -1
- package/dist/src/providers/openai/syntheticToolResponses.d.ts +52 -0
- package/dist/src/providers/openai/syntheticToolResponses.js +129 -0
- package/dist/src/providers/openai/syntheticToolResponses.js.map +1 -0
- package/dist/src/providers/types.d.ts +47 -0
- package/dist/src/services/git-stats-service.d.ts +32 -0
- package/dist/src/services/git-stats-service.js +22 -0
- package/dist/src/services/git-stats-service.js.map +1 -0
- package/dist/src/services/loopDetectionService.js +10 -6
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.js +44 -8
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/settings/SettingsService.d.ts +32 -0
- package/dist/src/settings/SettingsService.js +204 -0
- package/dist/src/settings/SettingsService.js.map +1 -0
- package/dist/src/settings/settingsServiceInstance.d.ts +12 -0
- package/dist/src/settings/settingsServiceInstance.js +24 -0
- package/dist/src/settings/settingsServiceInstance.js.map +1 -0
- package/dist/src/settings/types.d.ts +141 -0
- package/dist/src/settings/types.js +5 -0
- package/dist/src/settings/types.js.map +1 -0
- package/dist/src/storage/ConversationFileWriter.d.ts +16 -0
- package/dist/src/storage/ConversationFileWriter.js +69 -0
- package/dist/src/storage/ConversationFileWriter.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +8 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +56 -3
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +5 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +11 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +5 -0
- package/dist/src/telemetry/constants.js +5 -0
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +5 -1
- package/dist/src/telemetry/loggers.js +87 -1
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +2 -1
- package/dist/src/telemetry/metrics.js +7 -1
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/tool-call-decision.d.ts +13 -0
- package/dist/src/telemetry/tool-call-decision.js +29 -0
- package/dist/src/telemetry/tool-call-decision.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +56 -1
- package/dist/src/telemetry/types.js +123 -0
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +2 -1
- package/dist/src/telemetry/uiTelemetry.js +1 -1
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/tools/diffOptions.d.ts +2 -0
- package/dist/src/tools/diffOptions.js +28 -0
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/edit.d.ts +8 -32
- package/dist/src/tools/edit.js +153 -136
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/glob.d.ts +3 -10
- package/dist/src/tools/glob.js +97 -99
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/grep.d.ts +3 -35
- package/dist/src/tools/grep.js +117 -88
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +4 -3
- package/dist/src/tools/mcp-client.js +23 -6
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/read-file.js +37 -9
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/todo-pause.d.ts +22 -0
- package/dist/src/tools/todo-pause.js +93 -0
- package/dist/src/tools/todo-pause.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +4 -0
- package/dist/src/tools/tool-error.js +4 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-registry.js +3 -3
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tools.d.ts +18 -0
- package/dist/src/tools/tools.js +15 -0
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +4 -0
- package/dist/src/tools/write-file.js +90 -16
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/types/modelParams.d.ts +2 -0
- package/dist/src/utils/environmentContext.js +1 -1
- package/dist/src/utils/errors.d.ts +3 -0
- package/dist/src/utils/errors.js +6 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +7 -0
- package/dist/src/utils/fileUtils.js +9 -0
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
- package/dist/src/utils/filesearch/fileSearch.js +27 -19
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/package.json +4 -2
- package/dist/src/code_assist/converter.test.d.ts +0 -6
- package/dist/src/code_assist/converter.test.js +0 -232
- package/dist/src/code_assist/converter.test.js.map +0 -1
- package/dist/src/code_assist/oauth2.test.d.ts +0 -6
- package/dist/src/code_assist/oauth2.test.js +0 -370
- package/dist/src/code_assist/oauth2.test.js.map +0 -1
- package/dist/src/code_assist/server.test.d.ts +0 -6
- package/dist/src/code_assist/server.test.js +0 -131
- package/dist/src/code_assist/server.test.js.map +0 -1
- package/dist/src/code_assist/setup.test.d.ts +0 -6
- package/dist/src/code_assist/setup.test.js +0 -65
- package/dist/src/code_assist/setup.test.js.map +0 -1
- package/dist/src/config/config.alwaysAllow.test.d.ts +0 -6
- package/dist/src/config/config.alwaysAllow.test.js +0 -84
- package/dist/src/config/config.alwaysAllow.test.js.map +0 -1
- package/dist/src/config/config.test.d.ts +0 -6
- package/dist/src/config/config.test.js +0 -361
- package/dist/src/config/config.test.js.map +0 -1
- package/dist/src/config/flashFallback.test.d.ts +0 -6
- package/dist/src/config/flashFallback.test.js +0 -91
- package/dist/src/config/flashFallback.test.js.map +0 -1
- package/dist/src/core/client.test.d.ts +0 -6
- package/dist/src/core/client.test.js +0 -1317
- package/dist/src/core/client.test.js.map +0 -1
- package/dist/src/core/contentGenerator.test.d.ts +0 -6
- package/dist/src/core/contentGenerator.test.js +0 -103
- package/dist/src/core/contentGenerator.test.js.map +0 -1
- package/dist/src/core/coreToolScheduler.test.d.ts +0 -6
- package/dist/src/core/coreToolScheduler.test.js +0 -637
- package/dist/src/core/coreToolScheduler.test.js.map +0 -1
- package/dist/src/core/geminiChat.test.d.ts +0 -6
- package/dist/src/core/geminiChat.test.js +0 -425
- package/dist/src/core/geminiChat.test.js.map +0 -1
- package/dist/src/core/googleGenAIWrapper.test.d.ts +0 -6
- package/dist/src/core/googleGenAIWrapper.test.js +0 -104
- package/dist/src/core/googleGenAIWrapper.test.js.map +0 -1
- package/dist/src/core/logger.test.d.ts +0 -6
- package/dist/src/core/logger.test.js +0 -438
- package/dist/src/core/logger.test.js.map +0 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.d.ts +0 -6
- package/dist/src/core/nonInteractiveToolExecutor.test.js +0 -165
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +0 -1
- package/dist/src/core/prompts-async.test.d.ts +0 -6
- package/dist/src/core/prompts-async.test.js +0 -115
- package/dist/src/core/prompts-async.test.js.map +0 -1
- package/dist/src/core/prompts.test.d.ts +0 -6
- package/dist/src/core/prompts.test.js +0 -68
- package/dist/src/core/prompts.test.js.map +0 -1
- package/dist/src/core/subagent.test.d.ts +0 -6
- package/dist/src/core/subagent.test.js +0 -519
- package/dist/src/core/subagent.test.js.map +0 -1
- package/dist/src/core/tokenLimits.test.d.ts +0 -6
- package/dist/src/core/tokenLimits.test.js +0 -66
- package/dist/src/core/tokenLimits.test.js.map +0 -1
- package/dist/src/core/turn.test.d.ts +0 -6
- package/dist/src/core/turn.test.js +0 -366
- package/dist/src/core/turn.test.js.map +0 -1
- package/dist/src/hooks/tool-render-suppression-hook.test.d.ts +0 -6
- package/dist/src/hooks/tool-render-suppression-hook.test.js +0 -59
- package/dist/src/hooks/tool-render-suppression-hook.test.js.map +0 -1
- package/dist/src/ide/ide-installer.test.d.ts +0 -6
- package/dist/src/ide/ide-installer.test.js +0 -55
- package/dist/src/ide/ide-installer.test.js.map +0 -1
- package/dist/src/ide/ideContext.test.d.ts +0 -6
- package/dist/src/ide/ideContext.test.js +0 -265
- package/dist/src/ide/ideContext.test.js.map +0 -1
- package/dist/src/index.test.d.ts +0 -6
- package/dist/src/index.test.js +0 -12
- package/dist/src/index.test.js.map +0 -1
- package/dist/src/integration-tests/todo-system.test.d.ts +0 -6
- package/dist/src/integration-tests/todo-system.test.js +0 -46
- package/dist/src/integration-tests/todo-system.test.js.map +0 -1
- package/dist/src/mcp/google-auth-provider.test.d.ts +0 -6
- package/dist/src/mcp/google-auth-provider.test.js +0 -54
- package/dist/src/mcp/google-auth-provider.test.js.map +0 -1
- package/dist/src/mcp/oauth-provider.test.d.ts +0 -6
- package/dist/src/mcp/oauth-provider.test.js +0 -602
- package/dist/src/mcp/oauth-provider.test.js.map +0 -1
- package/dist/src/mcp/oauth-token-storage.test.d.ts +0 -6
- package/dist/src/mcp/oauth-token-storage.test.js +0 -205
- package/dist/src/mcp/oauth-token-storage.test.js.map +0 -1
- package/dist/src/mcp/oauth-utils.test.d.ts +0 -6
- package/dist/src/mcp/oauth-utils.test.js +0 -144
- package/dist/src/mcp/oauth-utils.test.js.map +0 -1
- package/dist/src/parsers/TextToolCallParser.multibyte.test.d.ts +0 -1
- package/dist/src/parsers/TextToolCallParser.multibyte.test.js +0 -42
- package/dist/src/parsers/TextToolCallParser.multibyte.test.js.map +0 -1
- package/dist/src/parsers/TextToolCallParser.test.d.ts +0 -1
- package/dist/src/parsers/TextToolCallParser.test.js +0 -225
- package/dist/src/parsers/TextToolCallParser.test.js.map +0 -1
- package/dist/src/prompt-config/TemplateEngine.test.d.ts +0 -1
- package/dist/src/prompt-config/TemplateEngine.test.js +0 -494
- package/dist/src/prompt-config/TemplateEngine.test.js.map +0 -1
- package/dist/src/prompt-config/prompt-cache.test.d.ts +0 -6
- package/dist/src/prompt-config/prompt-cache.test.js +0 -437
- package/dist/src/prompt-config/prompt-cache.test.js.map +0 -1
- package/dist/src/prompt-config/prompt-installer.test.d.ts +0 -7
- package/dist/src/prompt-config/prompt-installer.test.js +0 -503
- package/dist/src/prompt-config/prompt-installer.test.js.map +0 -1
- package/dist/src/prompt-config/prompt-loader.test.d.ts +0 -5
- package/dist/src/prompt-config/prompt-loader.test.js +0 -413
- package/dist/src/prompt-config/prompt-loader.test.js.map +0 -1
- package/dist/src/prompt-config/prompt-resolver.test.d.ts +0 -1
- package/dist/src/prompt-config/prompt-resolver.test.js +0 -529
- package/dist/src/prompt-config/prompt-resolver.test.js.map +0 -1
- package/dist/src/prompt-config/prompt-service.test.d.ts +0 -1
- package/dist/src/prompt-config/prompt-service.test.js +0 -811
- package/dist/src/prompt-config/prompt-service.test.js.map +0 -1
- package/dist/src/providers/ProviderManager.gemini-switch.test.d.ts +0 -6
- package/dist/src/providers/ProviderManager.gemini-switch.test.js +0 -57
- package/dist/src/providers/ProviderManager.gemini-switch.test.js.map +0 -1
- package/dist/src/providers/ProviderManager.test.d.ts +0 -6
- package/dist/src/providers/ProviderManager.test.js +0 -284
- package/dist/src/providers/ProviderManager.test.js.map +0 -1
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.d.ts +0 -6
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.js +0 -273
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.js.map +0 -1
- package/dist/src/providers/anthropic/AnthropicProvider.modelParams.test.d.ts +0 -1
- package/dist/src/providers/anthropic/AnthropicProvider.modelParams.test.js +0 -48
- package/dist/src/providers/anthropic/AnthropicProvider.modelParams.test.js.map +0 -1
- package/dist/src/providers/anthropic/AnthropicProvider.test.d.ts +0 -1
- package/dist/src/providers/anthropic/AnthropicProvider.test.js +0 -487
- package/dist/src/providers/anthropic/AnthropicProvider.test.js.map +0 -1
- package/dist/src/providers/gemini/GeminiProvider.integration.test.d.ts +0 -6
- package/dist/src/providers/gemini/GeminiProvider.integration.test.js +0 -126
- package/dist/src/providers/gemini/GeminiProvider.integration.test.js.map +0 -1
- package/dist/src/providers/gemini/GeminiProvider.test.d.ts +0 -6
- package/dist/src/providers/gemini/GeminiProvider.test.js +0 -136
- package/dist/src/providers/gemini/GeminiProvider.test.js.map +0 -1
- package/dist/src/providers/integration/multi-provider.integration.test.d.ts +0 -6
- package/dist/src/providers/integration/multi-provider.integration.test.js +0 -292
- package/dist/src/providers/integration/multi-provider.integration.test.js.map +0 -1
- package/dist/src/providers/openai/ConversationCache.accumTokens.test.d.ts +0 -1
- package/dist/src/providers/openai/ConversationCache.accumTokens.test.js +0 -97
- package/dist/src/providers/openai/ConversationCache.accumTokens.test.js.map +0 -1
- package/dist/src/providers/openai/ConversationCache.test.d.ts +0 -1
- package/dist/src/providers/openai/ConversationCache.test.js +0 -113
- package/dist/src/providers/openai/ConversationCache.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.callResponses.stateless.test.d.ts +0 -1
- package/dist/src/providers/openai/OpenAIProvider.callResponses.stateless.test.js +0 -189
- package/dist/src/providers/openai/OpenAIProvider.callResponses.stateless.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.integration.test.d.ts +0 -6
- package/dist/src/providers/openai/OpenAIProvider.integration.test.js +0 -125
- package/dist/src/providers/openai/OpenAIProvider.integration.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.responses.test.d.ts +0 -1
- package/dist/src/providers/openai/OpenAIProvider.responses.test.js +0 -350
- package/dist/src/providers/openai/OpenAIProvider.responses.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.responsesIntegration.test.d.ts +0 -1
- package/dist/src/providers/openai/OpenAIProvider.responsesIntegration.test.js +0 -213
- package/dist/src/providers/openai/OpenAIProvider.responsesIntegration.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.shouldUseResponses.test.d.ts +0 -1
- package/dist/src/providers/openai/OpenAIProvider.shouldUseResponses.test.js +0 -59
- package/dist/src/providers/openai/OpenAIProvider.shouldUseResponses.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.stateful.integration.test.d.ts +0 -6
- package/dist/src/providers/openai/OpenAIProvider.stateful.integration.test.js +0 -105
- package/dist/src/providers/openai/OpenAIProvider.stateful.integration.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.switch.test.d.ts +0 -1
- package/dist/src/providers/openai/OpenAIProvider.switch.test.js +0 -256
- package/dist/src/providers/openai/OpenAIProvider.switch.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.test.d.ts +0 -16
- package/dist/src/providers/openai/OpenAIProvider.test.js +0 -620
- package/dist/src/providers/openai/OpenAIProvider.test.js.map +0 -1
- package/dist/src/providers/openai/ResponsesContextTrim.integration.test.d.ts +0 -1
- package/dist/src/providers/openai/ResponsesContextTrim.integration.test.js +0 -210
- package/dist/src/providers/openai/ResponsesContextTrim.integration.test.js.map +0 -1
- package/dist/src/providers/openai/__tests__/formatArrayResponse.test.d.ts +0 -1
- package/dist/src/providers/openai/__tests__/formatArrayResponse.test.js +0 -65
- package/dist/src/providers/openai/__tests__/formatArrayResponse.test.js.map +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.stripToolCalls.test.d.ts +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.stripToolCalls.test.js +0 -129
- package/dist/src/providers/openai/buildResponsesRequest.stripToolCalls.test.js.map +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.test.d.ts +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.test.js +0 -406
- package/dist/src/providers/openai/buildResponsesRequest.test.js.map +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.undefined.test.d.ts +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.undefined.test.js +0 -50
- package/dist/src/providers/openai/buildResponsesRequest.undefined.test.js.map +0 -1
- package/dist/src/providers/openai/estimateRemoteTokens.test.d.ts +0 -1
- package/dist/src/providers/openai/estimateRemoteTokens.test.js +0 -125
- package/dist/src/providers/openai/estimateRemoteTokens.test.js.map +0 -1
- package/dist/src/providers/openai/parseResponsesStream.responsesToolCalls.test.d.ts +0 -1
- package/dist/src/providers/openai/parseResponsesStream.responsesToolCalls.test.js +0 -192
- package/dist/src/providers/openai/parseResponsesStream.responsesToolCalls.test.js.map +0 -1
- package/dist/src/providers/openai/parseResponsesStream.test.d.ts +0 -1
- package/dist/src/providers/openai/parseResponsesStream.test.js +0 -151
- package/dist/src/providers/openai/parseResponsesStream.test.js.map +0 -1
- package/dist/src/services/fileDiscoveryService.test.d.ts +0 -6
- package/dist/src/services/fileDiscoveryService.test.js +0 -143
- package/dist/src/services/fileDiscoveryService.test.js.map +0 -1
- package/dist/src/services/gitService.test.d.ts +0 -6
- package/dist/src/services/gitService.test.js +0 -209
- package/dist/src/services/gitService.test.js.map +0 -1
- package/dist/src/services/loopDetectionService.test.d.ts +0 -6
- package/dist/src/services/loopDetectionService.test.js +0 -345
- package/dist/src/services/loopDetectionService.test.js.map +0 -1
- package/dist/src/services/shellExecutionService.multibyte.test.d.ts +0 -6
- package/dist/src/services/shellExecutionService.multibyte.test.js +0 -72
- package/dist/src/services/shellExecutionService.multibyte.test.js.map +0 -1
- package/dist/src/services/shellExecutionService.test.d.ts +0 -6
- package/dist/src/services/shellExecutionService.test.js +0 -272
- package/dist/src/services/shellExecutionService.test.js.map +0 -1
- package/dist/src/services/shellExecutionService.windows.multibyte.test.d.ts +0 -6
- package/dist/src/services/shellExecutionService.windows.multibyte.test.js +0 -98
- package/dist/src/services/shellExecutionService.windows.multibyte.test.js.map +0 -1
- package/dist/src/services/shellExecutionService.windows.test.d.ts +0 -6
- package/dist/src/services/shellExecutionService.windows.test.js +0 -79
- package/dist/src/services/shellExecutionService.windows.test.js.map +0 -1
- package/dist/src/services/tool-call-tracker-service.test.d.ts +0 -6
- package/dist/src/services/tool-call-tracker-service.test.js +0 -99
- package/dist/src/services/tool-call-tracker-service.test.js.map +0 -1
- package/dist/src/telemetry/loggers.test.d.ts +0 -6
- package/dist/src/telemetry/loggers.test.js +0 -572
- package/dist/src/telemetry/loggers.test.js.map +0 -1
- package/dist/src/telemetry/metrics.test.d.ts +0 -6
- package/dist/src/telemetry/metrics.test.js +0 -162
- package/dist/src/telemetry/metrics.test.js.map +0 -1
- package/dist/src/telemetry/telemetry.test.d.ts +0 -6
- package/dist/src/telemetry/telemetry.test.js +0 -54
- package/dist/src/telemetry/telemetry.test.js.map +0 -1
- package/dist/src/telemetry/uiTelemetry.test.d.ts +0 -6
- package/dist/src/telemetry/uiTelemetry.test.js +0 -517
- package/dist/src/telemetry/uiTelemetry.test.js.map +0 -1
- package/dist/src/tools/ToolFormatter.test.d.ts +0 -16
- package/dist/src/tools/ToolFormatter.test.js +0 -349
- package/dist/src/tools/ToolFormatter.test.js.map +0 -1
- package/dist/src/tools/ToolFormatter.toResponsesTool.test.d.ts +0 -1
- package/dist/src/tools/ToolFormatter.toResponsesTool.test.js +0 -241
- package/dist/src/tools/ToolFormatter.toResponsesTool.test.js.map +0 -1
- package/dist/src/tools/edit.test.d.ts +0 -6
- package/dist/src/tools/edit.test.js +0 -663
- package/dist/src/tools/edit.test.js.map +0 -1
- package/dist/src/tools/glob.test.d.ts +0 -6
- package/dist/src/tools/glob.test.js +0 -321
- package/dist/src/tools/glob.test.js.map +0 -1
- package/dist/src/tools/grep.test.d.ts +0 -6
- package/dist/src/tools/grep.test.js +0 -258
- package/dist/src/tools/grep.test.js.map +0 -1
- package/dist/src/tools/ls.test.d.ts +0 -6
- package/dist/src/tools/ls.test.js +0 -357
- package/dist/src/tools/ls.test.js.map +0 -1
- package/dist/src/tools/mcp-client.test.d.ts +0 -6
- package/dist/src/tools/mcp-client.test.js +0 -575
- package/dist/src/tools/mcp-client.test.js.map +0 -1
- package/dist/src/tools/mcp-tool.test.d.ts +0 -6
- package/dist/src/tools/mcp-tool.test.js +0 -501
- package/dist/src/tools/mcp-tool.test.js.map +0 -1
- package/dist/src/tools/memoryTool.test.d.ts +0 -6
- package/dist/src/tools/memoryTool.test.js +0 -266
- package/dist/src/tools/memoryTool.test.js.map +0 -1
- package/dist/src/tools/modifiable-tool.test.d.ts +0 -6
- package/dist/src/tools/modifiable-tool.test.js +0 -193
- package/dist/src/tools/modifiable-tool.test.js.map +0 -1
- package/dist/src/tools/read-file.test.d.ts +0 -6
- package/dist/src/tools/read-file.test.js +0 -313
- package/dist/src/tools/read-file.test.js.map +0 -1
- package/dist/src/tools/read-many-files.test.d.ts +0 -6
- package/dist/src/tools/read-many-files.test.js +0 -644
- package/dist/src/tools/read-many-files.test.js.map +0 -1
- package/dist/src/tools/shell.multibyte.test.d.ts +0 -6
- package/dist/src/tools/shell.multibyte.test.js +0 -75
- package/dist/src/tools/shell.multibyte.test.js.map +0 -1
- package/dist/src/tools/shell.test.d.ts +0 -6
- package/dist/src/tools/shell.test.js +0 -350
- package/dist/src/tools/shell.test.js.map +0 -1
- package/dist/src/tools/todo-read.test.d.ts +0 -6
- package/dist/src/tools/todo-read.test.js +0 -162
- package/dist/src/tools/todo-read.test.js.map +0 -1
- package/dist/src/tools/todo-schemas.test.d.ts +0 -6
- package/dist/src/tools/todo-schemas.test.js +0 -341
- package/dist/src/tools/todo-schemas.test.js.map +0 -1
- package/dist/src/tools/todo-store.test.d.ts +0 -6
- package/dist/src/tools/todo-store.test.js +0 -169
- package/dist/src/tools/todo-store.test.js.map +0 -1
- package/dist/src/tools/todo-write.test.d.ts +0 -6
- package/dist/src/tools/todo-write.test.js +0 -226
- package/dist/src/tools/todo-write.test.js.map +0 -1
- package/dist/src/tools/tool-registry.test.d.ts +0 -6
- package/dist/src/tools/tool-registry.test.js +0 -468
- package/dist/src/tools/tool-registry.test.js.map +0 -1
- package/dist/src/tools/tools.test.d.ts +0 -6
- package/dist/src/tools/tools.test.js +0 -117
- package/dist/src/tools/tools.test.js.map +0 -1
- package/dist/src/tools/web-fetch.integration.test.d.ts +0 -6
- package/dist/src/tools/web-fetch.integration.test.js +0 -532
- package/dist/src/tools/web-fetch.integration.test.js.map +0 -1
- package/dist/src/tools/web-search.test.d.ts +0 -6
- package/dist/src/tools/web-search.test.js +0 -229
- package/dist/src/tools/web-search.test.js.map +0 -1
- package/dist/src/tools/write-file.test.d.ts +0 -6
- package/dist/src/tools/write-file.test.js +0 -464
- package/dist/src/tools/write-file.test.js.map +0 -1
- package/dist/src/utils/bfsFileSearch.test.d.ts +0 -6
- package/dist/src/utils/bfsFileSearch.test.js +0 -191
- package/dist/src/utils/bfsFileSearch.test.js.map +0 -1
- package/dist/src/utils/editCorrector.test.d.ts +0 -6
- package/dist/src/utils/editCorrector.test.js +0 -564
- package/dist/src/utils/editCorrector.test.js.map +0 -1
- package/dist/src/utils/editor.test.d.ts +0 -6
- package/dist/src/utils/editor.test.js +0 -445
- package/dist/src/utils/editor.test.js.map +0 -1
- package/dist/src/utils/environmentContext.test.d.ts +0 -6
- package/dist/src/utils/environmentContext.test.js +0 -139
- package/dist/src/utils/environmentContext.test.js.map +0 -1
- package/dist/src/utils/errorReporting.test.d.ts +0 -6
- package/dist/src/utils/errorReporting.test.js +0 -130
- package/dist/src/utils/errorReporting.test.js.map +0 -1
- package/dist/src/utils/fileUtils.test.d.ts +0 -6
- package/dist/src/utils/fileUtils.test.js +0 -363
- package/dist/src/utils/fileUtils.test.js.map +0 -1
- package/dist/src/utils/filesearch/crawlCache.test.d.ts +0 -6
- package/dist/src/utils/filesearch/crawlCache.test.js +0 -103
- package/dist/src/utils/filesearch/crawlCache.test.js.map +0 -1
- package/dist/src/utils/filesearch/fileSearch.test.d.ts +0 -6
- package/dist/src/utils/filesearch/fileSearch.test.js +0 -654
- package/dist/src/utils/filesearch/fileSearch.test.js.map +0 -1
- package/dist/src/utils/filesearch/ignore.test.d.ts +0 -6
- package/dist/src/utils/filesearch/ignore.test.js +0 -57
- package/dist/src/utils/filesearch/ignore.test.js.map +0 -1
- package/dist/src/utils/filesearch/result-cache.test.d.ts +0 -6
- package/dist/src/utils/filesearch/result-cache.test.js +0 -47
- package/dist/src/utils/filesearch/result-cache.test.js.map +0 -1
- package/dist/src/utils/flashFallback.integration.test.d.ts +0 -6
- package/dist/src/utils/flashFallback.integration.test.js +0 -120
- package/dist/src/utils/flashFallback.integration.test.js.map +0 -1
- package/dist/src/utils/generateContentResponseUtilities.test.d.ts +0 -6
- package/dist/src/utils/generateContentResponseUtilities.test.js +0 -273
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +0 -1
- package/dist/src/utils/getFolderStructure.test.d.ts +0 -6
- package/dist/src/utils/getFolderStructure.test.js +0 -282
- package/dist/src/utils/getFolderStructure.test.js.map +0 -1
- package/dist/src/utils/gitIgnoreParser.test.d.ts +0 -6
- package/dist/src/utils/gitIgnoreParser.test.js +0 -154
- package/dist/src/utils/gitIgnoreParser.test.js.map +0 -1
- package/dist/src/utils/memoryDiscovery.test.d.ts +0 -6
- package/dist/src/utils/memoryDiscovery.test.js +0 -181
- package/dist/src/utils/memoryDiscovery.test.js.map +0 -1
- package/dist/src/utils/memoryImportProcessor.test.d.ts +0 -6
- package/dist/src/utils/memoryImportProcessor.test.js +0 -715
- package/dist/src/utils/memoryImportProcessor.test.js.map +0 -1
- package/dist/src/utils/nextSpeakerChecker.test.d.ts +0 -6
- package/dist/src/utils/nextSpeakerChecker.test.js +0 -172
- package/dist/src/utils/nextSpeakerChecker.test.js.map +0 -1
- package/dist/src/utils/partUtils.test.d.ts +0 -6
- package/dist/src/utils/partUtils.test.js +0 -130
- package/dist/src/utils/partUtils.test.js.map +0 -1
- package/dist/src/utils/paths.test.d.ts +0 -6
- package/dist/src/utils/paths.test.js +0 -153
- package/dist/src/utils/paths.test.js.map +0 -1
- package/dist/src/utils/retry.test.d.ts +0 -6
- package/dist/src/utils/retry.test.js +0 -322
- package/dist/src/utils/retry.test.js.map +0 -1
- package/dist/src/utils/safeJsonStringify.test.d.ts +0 -6
- package/dist/src/utils/safeJsonStringify.test.js +0 -61
- package/dist/src/utils/safeJsonStringify.test.js.map +0 -1
- package/dist/src/utils/sanitization.test.d.ts +0 -6
- package/dist/src/utils/sanitization.test.js +0 -81
- package/dist/src/utils/sanitization.test.js.map +0 -1
- package/dist/src/utils/schemaValidator.test.d.ts +0 -6
- package/dist/src/utils/schemaValidator.test.js +0 -146
- package/dist/src/utils/schemaValidator.test.js.map +0 -1
- package/dist/src/utils/secure-browser-launcher.test.d.ts +0 -6
- package/dist/src/utils/secure-browser-launcher.test.js +0 -149
- package/dist/src/utils/secure-browser-launcher.test.js.map +0 -1
- package/dist/src/utils/shell-utils.shellReplacement.test.d.ts +0 -6
- package/dist/src/utils/shell-utils.shellReplacement.test.js +0 -149
- package/dist/src/utils/shell-utils.shellReplacement.test.js.map +0 -1
- package/dist/src/utils/shell-utils.test.d.ts +0 -6
- package/dist/src/utils/shell-utils.test.js +0 -200
- package/dist/src/utils/shell-utils.test.js.map +0 -1
- package/dist/src/utils/summarizer.test.d.ts +0 -6
- package/dist/src/utils/summarizer.test.js +0 -131
- package/dist/src/utils/summarizer.test.js.map +0 -1
- package/dist/src/utils/systemEncoding.test.d.ts +0 -6
- package/dist/src/utils/systemEncoding.test.js +0 -368
- package/dist/src/utils/systemEncoding.test.js.map +0 -1
- package/dist/src/utils/toolOutputLimiter.test.d.ts +0 -6
- package/dist/src/utils/toolOutputLimiter.test.js +0 -164
- package/dist/src/utils/toolOutputLimiter.test.js.map +0 -1
- package/dist/src/utils/unicodeUtils.test.d.ts +0 -6
- package/dist/src/utils/unicodeUtils.test.js +0 -120
- package/dist/src/utils/unicodeUtils.test.js.map +0 -1
- package/dist/src/utils/user_account.test.d.ts +0 -6
- package/dist/src/utils/user_account.test.js +0 -153
- package/dist/src/utils/user_account.test.js.map +0 -1
- package/dist/src/utils/user_id.test.d.ts +0 -6
- package/dist/src/utils/user_id.test.js +0 -21
- package/dist/src/utils/user_id.test.js.map +0 -1
- package/dist/src/utils/workspaceContext.test.d.ts +0 -6
- package/dist/src/utils/workspaceContext.test.js +0 -209
- package/dist/src/utils/workspaceContext.test.js.map +0 -1
package/dist/src/tools/glob.js
CHANGED
|
@@ -7,7 +7,7 @@ import fs from 'fs';
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { glob } from 'glob';
|
|
9
9
|
import { SchemaValidator } from '../utils/schemaValidator.js';
|
|
10
|
-
import {
|
|
10
|
+
import { BaseDeclarativeTool, BaseToolInvocation, Icon, } from './tools.js';
|
|
11
11
|
import { Type } from '@google/genai';
|
|
12
12
|
import { shortenPath, makeRelative } from '../utils/paths.js';
|
|
13
13
|
import { limitOutputTokens, formatLimitedOutput, getOutputLimits, } from '../utils/toolOutputLimiter.js';
|
|
@@ -38,107 +38,32 @@ export function sortFileEntries(entries, nowTimestamp, recencyThresholdMs) {
|
|
|
38
38
|
});
|
|
39
39
|
return sortedEntries;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
* Implementation of the Glob tool logic
|
|
43
|
-
*/
|
|
44
|
-
export class GlobTool extends BaseTool {
|
|
41
|
+
class GlobToolInvocation extends BaseToolInvocation {
|
|
45
42
|
config;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
super(GlobTool.Name, 'FindFiles', 'Efficiently finds files matching specific glob patterns (e.g., `src/**/*.ts`, `**/*.md`), returning absolute paths sorted by modification time (newest first). Ideal for quickly locating files based on their name or path structure, especially in large codebases.', Icon.FileSearch, {
|
|
49
|
-
properties: {
|
|
50
|
-
pattern: {
|
|
51
|
-
description: "The glob pattern to match against (e.g., '**/*.py', 'docs/*.md').",
|
|
52
|
-
type: Type.STRING,
|
|
53
|
-
},
|
|
54
|
-
path: {
|
|
55
|
-
description: 'Optional: The absolute path to the directory to search within. If omitted, searches the root directory.',
|
|
56
|
-
type: Type.STRING,
|
|
57
|
-
},
|
|
58
|
-
case_sensitive: {
|
|
59
|
-
description: 'Optional: Whether the search should be case-sensitive. Defaults to false.',
|
|
60
|
-
type: Type.BOOLEAN,
|
|
61
|
-
},
|
|
62
|
-
respect_git_ignore: {
|
|
63
|
-
description: 'Optional: Whether to respect .gitignore patterns when finding files. Only available in git repositories. Defaults to true.',
|
|
64
|
-
type: Type.BOOLEAN,
|
|
65
|
-
},
|
|
66
|
-
max_files: {
|
|
67
|
-
description: 'Optional: Maximum number of files to return. If omitted, returns all matching files up to system limits. Set a lower number if you expect many matches to avoid overwhelming output.',
|
|
68
|
-
type: Type.NUMBER,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
required: ['pattern'],
|
|
72
|
-
type: Type.OBJECT,
|
|
73
|
-
});
|
|
43
|
+
constructor(config, params) {
|
|
44
|
+
super(params);
|
|
74
45
|
this.config = config;
|
|
75
46
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const errors = SchemaValidator.validate(this.schema.parameters, params);
|
|
81
|
-
if (errors) {
|
|
82
|
-
return errors;
|
|
83
|
-
}
|
|
84
|
-
const searchDirAbsolute = path.resolve(this.config.getTargetDir(), params.path || '.');
|
|
85
|
-
const workspaceContext = this.config.getWorkspaceContext();
|
|
86
|
-
if (!workspaceContext.isPathWithinWorkspace(searchDirAbsolute)) {
|
|
87
|
-
const directories = workspaceContext.getDirectories();
|
|
88
|
-
return `Search path ("${searchDirAbsolute}") resolves outside the allowed workspace directories: ${directories.join(', ')}`;
|
|
89
|
-
}
|
|
90
|
-
const targetDir = searchDirAbsolute || this.config.getTargetDir();
|
|
91
|
-
try {
|
|
92
|
-
if (!fs.existsSync(targetDir)) {
|
|
93
|
-
return `Search path does not exist ${targetDir}`;
|
|
94
|
-
}
|
|
95
|
-
if (!fs.statSync(targetDir).isDirectory()) {
|
|
96
|
-
return `Search path is not a directory: ${targetDir}`;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch (e) {
|
|
100
|
-
return `Error accessing search path: ${e}`;
|
|
101
|
-
}
|
|
102
|
-
if (!params.pattern ||
|
|
103
|
-
typeof params.pattern !== 'string' ||
|
|
104
|
-
params.pattern.trim() === '') {
|
|
105
|
-
return "The 'pattern' parameter cannot be empty.";
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Gets a description of the glob operation.
|
|
111
|
-
*/
|
|
112
|
-
getDescription(params) {
|
|
113
|
-
let description = `'${params.pattern}'`;
|
|
114
|
-
if (params.path) {
|
|
115
|
-
const searchDir = path.resolve(this.config.getTargetDir(), params.path || '.');
|
|
47
|
+
getDescription() {
|
|
48
|
+
let description = `'${this.params.pattern}'`;
|
|
49
|
+
if (this.params.path) {
|
|
50
|
+
const searchDir = path.resolve(this.config.getTargetDir(), this.params.path || '.');
|
|
116
51
|
const relativePath = makeRelative(searchDir, this.config.getTargetDir());
|
|
117
52
|
description += ` within ${shortenPath(relativePath)}`;
|
|
118
53
|
}
|
|
119
54
|
return description;
|
|
120
55
|
}
|
|
121
|
-
|
|
122
|
-
* Executes the glob search with the given parameters
|
|
123
|
-
*/
|
|
124
|
-
async execute(params, signal) {
|
|
125
|
-
const validationError = this.validateToolParams(params);
|
|
126
|
-
if (validationError) {
|
|
127
|
-
return {
|
|
128
|
-
llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`,
|
|
129
|
-
returnDisplay: validationError,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
56
|
+
async execute(signal) {
|
|
132
57
|
try {
|
|
133
58
|
const workspaceContext = this.config.getWorkspaceContext();
|
|
134
59
|
const workspaceDirectories = workspaceContext.getDirectories();
|
|
135
60
|
// If a specific path is provided, resolve it and check if it's within workspace
|
|
136
61
|
let searchDirectories;
|
|
137
|
-
if (params.path) {
|
|
138
|
-
const searchDirAbsolute = path.resolve(this.config.getTargetDir(), params.path);
|
|
62
|
+
if (this.params.path) {
|
|
63
|
+
const searchDirAbsolute = path.resolve(this.config.getTargetDir(), this.params.path);
|
|
139
64
|
if (!workspaceContext.isPathWithinWorkspace(searchDirAbsolute)) {
|
|
140
65
|
return {
|
|
141
|
-
llmContent: `Error: Path "${params.path}" is not within any workspace directory`,
|
|
66
|
+
llmContent: `Error: Path "${this.params.path}" is not within any workspace directory`,
|
|
142
67
|
returnDisplay: `Path is not within workspace`,
|
|
143
68
|
};
|
|
144
69
|
}
|
|
@@ -149,18 +74,18 @@ export class GlobTool extends BaseTool {
|
|
|
149
74
|
searchDirectories = workspaceDirectories;
|
|
150
75
|
}
|
|
151
76
|
// Get centralized file discovery service
|
|
152
|
-
const respectGitIgnore = params.respect_git_ignore ??
|
|
77
|
+
const respectGitIgnore = this.params.respect_git_ignore ??
|
|
153
78
|
this.config.getFileFilteringRespectGitIgnore();
|
|
154
79
|
const fileDiscovery = this.config.getFileService();
|
|
155
80
|
// Collect entries from all search directories
|
|
156
81
|
let allEntries = [];
|
|
157
82
|
for (const searchDir of searchDirectories) {
|
|
158
|
-
const entries = (await glob(params.pattern, {
|
|
83
|
+
const entries = (await glob(this.params.pattern, {
|
|
159
84
|
cwd: searchDir,
|
|
160
85
|
withFileTypes: true,
|
|
161
86
|
nodir: true,
|
|
162
87
|
stat: true,
|
|
163
|
-
nocase: !params.case_sensitive,
|
|
88
|
+
nocase: !this.params.case_sensitive,
|
|
164
89
|
dot: true,
|
|
165
90
|
ignore: ['**/node_modules/**', '**/.git/**'],
|
|
166
91
|
follow: false,
|
|
@@ -182,7 +107,7 @@ export class GlobTool extends BaseTool {
|
|
|
182
107
|
gitIgnoredCount = entries.length - filteredEntries.length;
|
|
183
108
|
}
|
|
184
109
|
if (!filteredEntries || filteredEntries.length === 0) {
|
|
185
|
-
let message = `No files found matching pattern "${params.pattern}"`;
|
|
110
|
+
let message = `No files found matching pattern "${this.params.pattern}"`;
|
|
186
111
|
if (searchDirectories.length === 1) {
|
|
187
112
|
message += ` within ${searchDirectories[0]}`;
|
|
188
113
|
}
|
|
@@ -202,18 +127,19 @@ export class GlobTool extends BaseTool {
|
|
|
202
127
|
const nowTimestamp = new Date().getTime();
|
|
203
128
|
// Sort the filtered entries using the new helper function
|
|
204
129
|
const sortedEntries = sortFileEntries(filteredEntries, nowTimestamp, oneDayInMs);
|
|
205
|
-
// Apply max_files limit if specified
|
|
130
|
+
// Apply max_files limit if specified (LLxprt feature)
|
|
206
131
|
let finalEntries = sortedEntries;
|
|
207
132
|
let limitMessage = '';
|
|
208
|
-
if (params.max_files &&
|
|
209
|
-
|
|
210
|
-
|
|
133
|
+
if (this.params.max_files &&
|
|
134
|
+
sortedEntries.length > this.params.max_files) {
|
|
135
|
+
finalEntries = sortedEntries.slice(0, this.params.max_files);
|
|
136
|
+
limitMessage = ` (showing first ${this.params.max_files} of ${sortedEntries.length} total matches)`;
|
|
211
137
|
}
|
|
212
138
|
const sortedAbsolutePaths = finalEntries.map((entry) => entry.fullpath());
|
|
213
139
|
const fileListDescription = sortedAbsolutePaths.join('\n');
|
|
214
140
|
const fileCount = finalEntries.length;
|
|
215
141
|
const totalCount = sortedEntries.length;
|
|
216
|
-
let resultMessage = `Found ${totalCount} file(s) matching "${params.pattern}"${limitMessage}`;
|
|
142
|
+
let resultMessage = `Found ${totalCount} file(s) matching "${this.params.pattern}"${limitMessage}`;
|
|
217
143
|
if (searchDirectories.length === 1) {
|
|
218
144
|
resultMessage += ` within ${searchDirectories[0]}`;
|
|
219
145
|
}
|
|
@@ -224,12 +150,12 @@ export class GlobTool extends BaseTool {
|
|
|
224
150
|
resultMessage += ` (${gitIgnoredCount} additional files were git-ignored)`;
|
|
225
151
|
}
|
|
226
152
|
resultMessage += `, sorted by modification time (newest first):\n${fileListDescription}`;
|
|
227
|
-
// Apply token-based limiting (
|
|
153
|
+
// Apply token-based limiting (LLxprt feature)
|
|
228
154
|
const limitedResult = limitOutputTokens(resultMessage, this.config, 'glob');
|
|
229
|
-
// If we hit token limits with warn mode, provide better guidance
|
|
155
|
+
// If we hit token limits with warn mode, provide better guidance (LLxprt feature)
|
|
230
156
|
if (limitedResult.wasTruncated &&
|
|
231
157
|
!limitedResult.content &&
|
|
232
|
-
!params.max_files) {
|
|
158
|
+
!this.params.max_files) {
|
|
233
159
|
const improvedMessage = `glob output exceeded token limit (${limitedResult.originalTokens} > ${getOutputLimits(this.config).maxTokens}). Too many files matched the pattern. Please:
|
|
234
160
|
1. Use the max_files parameter to limit results (e.g., max_files: 100)
|
|
235
161
|
2. Use a more specific glob pattern (e.g., "src/**/*.ts" instead of "**/*")
|
|
@@ -260,4 +186,76 @@ export class GlobTool extends BaseTool {
|
|
|
260
186
|
}
|
|
261
187
|
}
|
|
262
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Implementation of the Glob tool logic
|
|
191
|
+
*/
|
|
192
|
+
export class GlobTool extends BaseDeclarativeTool {
|
|
193
|
+
config;
|
|
194
|
+
static Name = 'glob';
|
|
195
|
+
constructor(config) {
|
|
196
|
+
super(GlobTool.Name, 'FindFiles', 'Efficiently finds files matching specific glob patterns (e.g., `src/**/*.ts`, `**/*.md`), returning absolute paths sorted by modification time (newest first). Ideal for quickly locating files based on their name or path structure, especially in large codebases.', Icon.FileSearch, {
|
|
197
|
+
properties: {
|
|
198
|
+
pattern: {
|
|
199
|
+
description: "The glob pattern to match against (e.g., '**/*.py', 'docs/*.md').",
|
|
200
|
+
type: Type.STRING,
|
|
201
|
+
},
|
|
202
|
+
path: {
|
|
203
|
+
description: 'Optional: The absolute path to the directory to search within. If omitted, searches the root directory.',
|
|
204
|
+
type: Type.STRING,
|
|
205
|
+
},
|
|
206
|
+
case_sensitive: {
|
|
207
|
+
description: 'Optional: Whether the search should be case-sensitive. Defaults to false.',
|
|
208
|
+
type: Type.BOOLEAN,
|
|
209
|
+
},
|
|
210
|
+
respect_git_ignore: {
|
|
211
|
+
description: 'Optional: Whether to respect .gitignore patterns when finding files. Only available in git repositories. Defaults to true.',
|
|
212
|
+
type: Type.BOOLEAN,
|
|
213
|
+
},
|
|
214
|
+
max_files: {
|
|
215
|
+
description: 'Optional: Maximum number of files to return. If omitted, returns all matching files up to system limits. Set a lower number if you expect many matches to avoid overwhelming output.',
|
|
216
|
+
type: Type.NUMBER,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
required: ['pattern'],
|
|
220
|
+
type: Type.OBJECT,
|
|
221
|
+
});
|
|
222
|
+
this.config = config;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Validates the parameters for the tool.
|
|
226
|
+
*/
|
|
227
|
+
validateToolParams(params) {
|
|
228
|
+
const errors = SchemaValidator.validate(this.schema.parameters, params);
|
|
229
|
+
if (errors) {
|
|
230
|
+
return errors;
|
|
231
|
+
}
|
|
232
|
+
const searchDirAbsolute = path.resolve(this.config.getTargetDir(), params.path || '.');
|
|
233
|
+
const workspaceContext = this.config.getWorkspaceContext();
|
|
234
|
+
if (!workspaceContext.isPathWithinWorkspace(searchDirAbsolute)) {
|
|
235
|
+
const directories = workspaceContext.getDirectories();
|
|
236
|
+
return `Search path ("${searchDirAbsolute}") resolves outside the allowed workspace directories: ${directories.join(', ')}`;
|
|
237
|
+
}
|
|
238
|
+
const targetDir = searchDirAbsolute || this.config.getTargetDir();
|
|
239
|
+
try {
|
|
240
|
+
if (!fs.existsSync(targetDir)) {
|
|
241
|
+
return `Search path does not exist ${targetDir}`;
|
|
242
|
+
}
|
|
243
|
+
if (!fs.statSync(targetDir).isDirectory()) {
|
|
244
|
+
return `Search path is not a directory: ${targetDir}`;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (e) {
|
|
248
|
+
return `Error accessing search path: ${e}`;
|
|
249
|
+
}
|
|
250
|
+
if (!params.pattern ||
|
|
251
|
+
typeof params.pattern !== 'string' ||
|
|
252
|
+
params.pattern.trim() === '') {
|
|
253
|
+
return "The 'pattern' parameter cannot be empty.";
|
|
254
|
+
}
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
createInvocation(params) {
|
|
258
|
+
return new GlobToolInvocation(this.config, params);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
263
261
|
//# sourceMappingURL=glob.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/tools/glob.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/tools/glob.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,IAAI,GAGL,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,GAChB,MAAM,+BAA+B,CAAC;AAQvC;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAmB,EACnB,YAAoB,EACpB,kBAA0B;IAE1B,MAAM,aAAa,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;IACnC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,C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AM,CAAC,OAAO,KAAK,QAAQ;YAClC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAC5B,CAAC;YACD,OAAO,0CAA0C,CAAC;QACpD,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAES,gBAAgB,CACxB,MAAsB;QAEtB,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC"}
|
package/dist/src/tools/grep.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { BaseDeclarativeTool, ToolInvocation, ToolResult } from './tools.js';
|
|
7
7
|
import { Config } from '../config/config.js';
|
|
8
8
|
/**
|
|
9
9
|
* Parameters for the GrepTool
|
|
@@ -29,7 +29,7 @@ export interface GrepToolParams {
|
|
|
29
29
|
/**
|
|
30
30
|
* Implementation of the Grep tool logic (moved from CLI)
|
|
31
31
|
*/
|
|
32
|
-
export declare class GrepTool extends
|
|
32
|
+
export declare class GrepTool extends BaseDeclarativeTool<GrepToolParams, ToolResult> {
|
|
33
33
|
private readonly config;
|
|
34
34
|
static readonly Name = "search_file_content";
|
|
35
35
|
constructor(config: Config);
|
|
@@ -46,37 +46,5 @@ export declare class GrepTool extends BaseTool<GrepToolParams, ToolResult> {
|
|
|
46
46
|
* @returns An error message string if invalid, null otherwise
|
|
47
47
|
*/
|
|
48
48
|
validateToolParams(params: GrepToolParams): string | null;
|
|
49
|
-
|
|
50
|
-
* Executes the grep search with the given parameters
|
|
51
|
-
* @param params Parameters for the grep search
|
|
52
|
-
* @returns Result of the grep search
|
|
53
|
-
*/
|
|
54
|
-
execute(params: GrepToolParams, signal: AbortSignal): Promise<ToolResult>;
|
|
55
|
-
/**
|
|
56
|
-
* Checks if a command is available in the system's PATH.
|
|
57
|
-
* @param {string} command The command name (e.g., 'git', 'grep').
|
|
58
|
-
* @returns {Promise<boolean>} True if the command is available, false otherwise.
|
|
59
|
-
*/
|
|
60
|
-
private isCommandAvailable;
|
|
61
|
-
/**
|
|
62
|
-
* Parses the standard output of grep-like commands (git grep, system grep).
|
|
63
|
-
* Expects format: filePath:lineNumber:lineContent
|
|
64
|
-
* Handles colons within file paths and line content correctly.
|
|
65
|
-
* @param {string} output The raw stdout string.
|
|
66
|
-
* @param {string} basePath The absolute directory the search was run from, for relative paths.
|
|
67
|
-
* @returns {GrepMatch[]} Array of match objects.
|
|
68
|
-
*/
|
|
69
|
-
private parseGrepOutput;
|
|
70
|
-
/**
|
|
71
|
-
* Gets a description of the grep operation
|
|
72
|
-
* @param params Parameters for the grep operation
|
|
73
|
-
* @returns A string describing the grep
|
|
74
|
-
*/
|
|
75
|
-
getDescription(params: GrepToolParams): string;
|
|
76
|
-
/**
|
|
77
|
-
* Performs the actual search using the prioritized strategies.
|
|
78
|
-
* @param options Search options including pattern, absolute path, and include glob.
|
|
79
|
-
* @returns A promise resolving to an array of match objects.
|
|
80
|
-
*/
|
|
81
|
-
private performGrepSearch;
|
|
49
|
+
protected createInvocation(params: GrepToolParams): ToolInvocation<GrepToolParams, ToolResult>;
|
|
82
50
|
}
|
package/dist/src/tools/grep.js
CHANGED
|
@@ -9,46 +9,19 @@ import path from 'path';
|
|
|
9
9
|
import { EOL } from 'os';
|
|
10
10
|
import { spawn } from 'child_process';
|
|
11
11
|
import { globStream } from 'glob';
|
|
12
|
-
import {
|
|
12
|
+
import { BaseDeclarativeTool, BaseToolInvocation, Icon, } from './tools.js';
|
|
13
13
|
import { Type } from '@google/genai';
|
|
14
14
|
import { SchemaValidator } from '../utils/schemaValidator.js';
|
|
15
15
|
import { makeRelative, shortenPath } from '../utils/paths.js';
|
|
16
16
|
import { getErrorMessage, isNodeError } from '../utils/errors.js';
|
|
17
17
|
import { isGitRepository } from '../utils/gitUtils.js';
|
|
18
18
|
import { limitOutputTokens, formatLimitedOutput, getOutputLimits, } from '../utils/toolOutputLimiter.js';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Implementation of the Grep tool logic (moved from CLI)
|
|
22
|
-
*/
|
|
23
|
-
export class GrepTool extends BaseTool {
|
|
19
|
+
class GrepToolInvocation extends BaseToolInvocation {
|
|
24
20
|
config;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
super(GrepTool.Name, 'SearchFileContent', 'Searches for a regular expression pattern within the content of files in a specified directory (or current working directory). Can filter files by a glob pattern. Returns the lines containing matches, along with their file paths and line numbers. IMPORTANT: This tool expects regular expression patterns, not literal strings.', Icon.FileSearch, {
|
|
28
|
-
properties: {
|
|
29
|
-
pattern: {
|
|
30
|
-
description: "The regular expression (regex) pattern to search for within file contents. Special characters like ( ) [ ] { } . * + ? ^ $ \\ | must be escaped with a backslash. Examples: 'openModelDialog\\(' to find 'openModelDialog(', 'function\\s+myFunction' to find function declarations, '\\.test\\.' to find '.test.' in filenames.",
|
|
31
|
-
type: Type.STRING,
|
|
32
|
-
},
|
|
33
|
-
path: {
|
|
34
|
-
description: 'Optional: The absolute path to the directory to search within. If omitted, searches the current working directory.',
|
|
35
|
-
type: Type.STRING,
|
|
36
|
-
},
|
|
37
|
-
include: {
|
|
38
|
-
description: "Optional: A glob pattern to filter which files are searched (e.g., '*.js', '*.{ts,tsx}', 'src/**'). If omitted, searches all files (respecting potential global ignores).",
|
|
39
|
-
type: Type.STRING,
|
|
40
|
-
},
|
|
41
|
-
max_matches: {
|
|
42
|
-
description: 'Optional: Maximum number of matches to return. If omitted, uses the configured limit (default 50). Set a lower number if you expect many matches to avoid overwhelming output.',
|
|
43
|
-
type: Type.NUMBER,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
required: ['pattern'],
|
|
47
|
-
type: Type.OBJECT,
|
|
48
|
-
});
|
|
21
|
+
constructor(config, params) {
|
|
22
|
+
super(params);
|
|
49
23
|
this.config = config;
|
|
50
24
|
}
|
|
51
|
-
// --- Validation Methods ---
|
|
52
25
|
/**
|
|
53
26
|
* Checks if a path is within the root directory and resolves it.
|
|
54
27
|
* @param relativePath Path relative to the root directory (or undefined for root).
|
|
@@ -82,51 +55,11 @@ export class GrepTool extends BaseTool {
|
|
|
82
55
|
}
|
|
83
56
|
return targetPath;
|
|
84
57
|
}
|
|
85
|
-
|
|
86
|
-
* Validates the parameters for the tool
|
|
87
|
-
* @param params Parameters to validate
|
|
88
|
-
* @returns An error message string if invalid, null otherwise
|
|
89
|
-
*/
|
|
90
|
-
validateToolParams(params) {
|
|
91
|
-
const errors = SchemaValidator.validate(this.schema.parameters, params);
|
|
92
|
-
if (errors) {
|
|
93
|
-
return errors;
|
|
94
|
-
}
|
|
95
|
-
try {
|
|
96
|
-
new RegExp(params.pattern);
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
return `Invalid regular expression pattern provided: ${params.pattern}. Error: ${getErrorMessage(error)}`;
|
|
100
|
-
}
|
|
101
|
-
// Only validate path if one is provided
|
|
102
|
-
if (params.path) {
|
|
103
|
-
try {
|
|
104
|
-
this.resolveAndValidatePath(params.path);
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
return getErrorMessage(error);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return null; // Parameters are valid
|
|
111
|
-
}
|
|
112
|
-
// --- Core Execution ---
|
|
113
|
-
/**
|
|
114
|
-
* Executes the grep search with the given parameters
|
|
115
|
-
* @param params Parameters for the grep search
|
|
116
|
-
* @returns Result of the grep search
|
|
117
|
-
*/
|
|
118
|
-
async execute(params, signal) {
|
|
119
|
-
const validationError = this.validateToolParams(params);
|
|
120
|
-
if (validationError) {
|
|
121
|
-
return {
|
|
122
|
-
llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`,
|
|
123
|
-
returnDisplay: `Model provided invalid parameters. Error: ${validationError}`,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
58
|
+
async execute(signal) {
|
|
126
59
|
try {
|
|
127
60
|
const workspaceContext = this.config.getWorkspaceContext();
|
|
128
|
-
const searchDirAbs = this.resolveAndValidatePath(params.path);
|
|
129
|
-
const searchDirDisplay = params.path || '.';
|
|
61
|
+
const searchDirAbs = this.resolveAndValidatePath(this.params.path);
|
|
62
|
+
const searchDirDisplay = this.params.path || '.';
|
|
130
63
|
// Determine which directories to search
|
|
131
64
|
let searchDirectories;
|
|
132
65
|
if (searchDirAbs === null) {
|
|
@@ -141,9 +74,9 @@ export class GrepTool extends BaseTool {
|
|
|
141
74
|
let allMatches = [];
|
|
142
75
|
for (const searchDir of searchDirectories) {
|
|
143
76
|
const matches = await this.performGrepSearch({
|
|
144
|
-
pattern: params.pattern,
|
|
77
|
+
pattern: this.params.pattern,
|
|
145
78
|
path: searchDir,
|
|
146
|
-
include: params.include,
|
|
79
|
+
include: this.params.include,
|
|
147
80
|
signal,
|
|
148
81
|
});
|
|
149
82
|
// Add directory prefix if searching multiple directories
|
|
@@ -167,7 +100,7 @@ export class GrepTool extends BaseTool {
|
|
|
167
100
|
searchLocationDescription = `in path "${searchDirDisplay}"`;
|
|
168
101
|
}
|
|
169
102
|
if (allMatches.length === 0) {
|
|
170
|
-
const noMatchMsg = `No matches found for pattern "${params.pattern}" ${searchLocationDescription}${params.include ? ` (filter: "${params.include}")` : ''}.`;
|
|
103
|
+
const noMatchMsg = `No matches found for pattern "${this.params.pattern}" ${searchLocationDescription}${this.params.include ? ` (filter: "${this.params.include}")` : ''}.`;
|
|
171
104
|
return { llmContent: noMatchMsg, returnDisplay: `No matches found` };
|
|
172
105
|
}
|
|
173
106
|
const matchCount = allMatches.length;
|
|
@@ -178,12 +111,12 @@ export class GrepTool extends BaseTool {
|
|
|
178
111
|
// Priority: 1. User-specified max_matches, 2. tool-output-max-items setting, 3. default
|
|
179
112
|
const ephemeralSettings = this.config.getEphemeralSettings();
|
|
180
113
|
const configMaxItems = ephemeralSettings['tool-output-max-items'];
|
|
181
|
-
const maxItems = params.max_matches ?? configMaxItems ?? 50;
|
|
114
|
+
const maxItems = this.params.max_matches ?? configMaxItems ?? 50;
|
|
182
115
|
let itemsToProcess = allMatches;
|
|
183
116
|
let itemLimitMessage = '';
|
|
184
117
|
if (allMatches.length > maxItems) {
|
|
185
118
|
// If user explicitly set max_matches, always truncate. Otherwise follow configured mode
|
|
186
|
-
if (params.max_matches) {
|
|
119
|
+
if (this.params.max_matches) {
|
|
187
120
|
// User explicitly set a limit, so truncate to that limit
|
|
188
121
|
itemsToProcess = allMatches.slice(0, maxItems);
|
|
189
122
|
itemLimitMessage = `\n[Showing first ${maxItems} of ${allMatches.length} matches as requested]`;
|
|
@@ -226,7 +159,7 @@ export class GrepTool extends BaseTool {
|
|
|
226
159
|
acc[fileKey].push(match);
|
|
227
160
|
return acc;
|
|
228
161
|
}, {});
|
|
229
|
-
let llmContent = `Found ${allMatches.length} ${matchTerm} for pattern "${params.pattern}" ${searchLocationDescription}${params.include ? ` (filter: "${params.include}")` : ''}:${itemLimitMessage}
|
|
162
|
+
let llmContent = `Found ${allMatches.length} ${matchTerm} for pattern "${this.params.pattern}" ${searchLocationDescription}${this.params.include ? ` (filter: "${this.params.include}")` : ''}:${itemLimitMessage}
|
|
230
163
|
---
|
|
231
164
|
`;
|
|
232
165
|
for (const filePath in limitedMatchesByFile) {
|
|
@@ -258,7 +191,6 @@ export class GrepTool extends BaseTool {
|
|
|
258
191
|
};
|
|
259
192
|
}
|
|
260
193
|
}
|
|
261
|
-
// --- Grep Implementation Logic ---
|
|
262
194
|
/**
|
|
263
195
|
* Checks if a command is available in the system's PATH.
|
|
264
196
|
* @param {string} command The command name (e.g., 'git', 'grep').
|
|
@@ -327,14 +259,15 @@ export class GrepTool extends BaseTool {
|
|
|
327
259
|
* @param params Parameters for the grep operation
|
|
328
260
|
* @returns A string describing the grep
|
|
329
261
|
*/
|
|
330
|
-
getDescription(
|
|
331
|
-
let description = `'${params.pattern}'`;
|
|
332
|
-
if (params.include) {
|
|
333
|
-
description += ` in ${params.include}`;
|
|
262
|
+
getDescription() {
|
|
263
|
+
let description = `'${this.params.pattern}'`;
|
|
264
|
+
if (this.params.include) {
|
|
265
|
+
description += ` in ${this.params.include}`;
|
|
334
266
|
}
|
|
335
|
-
if (params.path) {
|
|
336
|
-
const resolvedPath = path.resolve(this.config.getTargetDir(), params.path);
|
|
337
|
-
if (resolvedPath === this.config.getTargetDir() ||
|
|
267
|
+
if (this.params.path) {
|
|
268
|
+
const resolvedPath = path.resolve(this.config.getTargetDir(), this.params.path);
|
|
269
|
+
if (resolvedPath === this.config.getTargetDir() ||
|
|
270
|
+
this.params.path === '.') {
|
|
338
271
|
description += ` within ./`;
|
|
339
272
|
}
|
|
340
273
|
else {
|
|
@@ -527,4 +460,100 @@ export class GrepTool extends BaseTool {
|
|
|
527
460
|
}
|
|
528
461
|
}
|
|
529
462
|
}
|
|
463
|
+
// --- GrepLogic Class ---
|
|
464
|
+
/**
|
|
465
|
+
* Implementation of the Grep tool logic (moved from CLI)
|
|
466
|
+
*/
|
|
467
|
+
export class GrepTool extends BaseDeclarativeTool {
|
|
468
|
+
config;
|
|
469
|
+
static Name = 'search_file_content'; // Keep static name
|
|
470
|
+
constructor(config) {
|
|
471
|
+
super(GrepTool.Name, 'SearchFileContent', 'Searches for a regular expression pattern within the content of files in a specified directory (or current working directory). Can filter files by a glob pattern. Returns the lines containing matches, along with their file paths and line numbers. IMPORTANT: This tool expects regular expression patterns, not literal strings.', Icon.FileSearch, {
|
|
472
|
+
properties: {
|
|
473
|
+
pattern: {
|
|
474
|
+
description: "The regular expression (regex) pattern to search for within file contents. Special characters like ( ) [ ] { } . * + ? ^ $ \\ | must be escaped with a backslash. Examples: 'openModelDialog\\(' to find 'openModelDialog(', 'function\\s+myFunction' to find function declarations, '\\.test\\.' to find '.test.' in filenames.",
|
|
475
|
+
type: Type.STRING,
|
|
476
|
+
},
|
|
477
|
+
path: {
|
|
478
|
+
description: 'Optional: The absolute path to the directory to search within. If omitted, searches the current working directory.',
|
|
479
|
+
type: Type.STRING,
|
|
480
|
+
},
|
|
481
|
+
include: {
|
|
482
|
+
description: "Optional: A glob pattern to filter which files are searched (e.g., '*.js', '*.{ts,tsx}', 'src/**'). If omitted, searches all files (respecting potential global ignores).",
|
|
483
|
+
type: Type.STRING,
|
|
484
|
+
},
|
|
485
|
+
max_matches: {
|
|
486
|
+
description: 'Optional: Maximum number of matches to return. If omitted, uses the configured limit (default 50). Set a lower number if you expect many matches to avoid overwhelming output.',
|
|
487
|
+
type: Type.NUMBER,
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
required: ['pattern'],
|
|
491
|
+
type: Type.OBJECT,
|
|
492
|
+
});
|
|
493
|
+
this.config = config;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Checks if a path is within the root directory and resolves it.
|
|
497
|
+
* @param relativePath Path relative to the root directory (or undefined for root).
|
|
498
|
+
* @returns The absolute path if valid and exists, or null if no path specified (to search all directories).
|
|
499
|
+
* @throws {Error} If path is outside root, doesn't exist, or isn't a directory.
|
|
500
|
+
*/
|
|
501
|
+
resolveAndValidatePath(relativePath) {
|
|
502
|
+
// If no path specified, return null to indicate searching all workspace directories
|
|
503
|
+
if (!relativePath) {
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
const targetPath = path.resolve(this.config.getTargetDir(), relativePath);
|
|
507
|
+
// Security Check: Ensure the resolved path is within workspace boundaries
|
|
508
|
+
const workspaceContext = this.config.getWorkspaceContext();
|
|
509
|
+
if (!workspaceContext.isPathWithinWorkspace(targetPath)) {
|
|
510
|
+
const directories = workspaceContext.getDirectories();
|
|
511
|
+
throw new Error(`Path validation failed: Attempted path "${relativePath}" resolves outside the allowed workspace directories: ${directories.join(', ')}`);
|
|
512
|
+
}
|
|
513
|
+
// Check existence and type after resolving
|
|
514
|
+
try {
|
|
515
|
+
const stats = fs.statSync(targetPath);
|
|
516
|
+
if (!stats.isDirectory()) {
|
|
517
|
+
throw new Error(`Path is not a directory: ${targetPath}`);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
catch (error) {
|
|
521
|
+
if (isNodeError(error) && error.code !== 'ENOENT') {
|
|
522
|
+
throw new Error(`Path does not exist: ${targetPath}`);
|
|
523
|
+
}
|
|
524
|
+
throw new Error(`Failed to access path stats for ${targetPath}: ${error}`);
|
|
525
|
+
}
|
|
526
|
+
return targetPath;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Validates the parameters for the tool
|
|
530
|
+
* @param params Parameters to validate
|
|
531
|
+
* @returns An error message string if invalid, null otherwise
|
|
532
|
+
*/
|
|
533
|
+
validateToolParams(params) {
|
|
534
|
+
const errors = SchemaValidator.validate(this.schema.parameters, params);
|
|
535
|
+
if (errors) {
|
|
536
|
+
return errors;
|
|
537
|
+
}
|
|
538
|
+
try {
|
|
539
|
+
new RegExp(params.pattern);
|
|
540
|
+
}
|
|
541
|
+
catch (error) {
|
|
542
|
+
return `Invalid regular expression pattern provided: ${params.pattern}. Error: ${getErrorMessage(error)}`;
|
|
543
|
+
}
|
|
544
|
+
// Only validate path if one is provided
|
|
545
|
+
if (params.path) {
|
|
546
|
+
try {
|
|
547
|
+
this.resolveAndValidatePath(params.path);
|
|
548
|
+
}
|
|
549
|
+
catch (error) {
|
|
550
|
+
return getErrorMessage(error);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return null; // Parameters are valid
|
|
554
|
+
}
|
|
555
|
+
createInvocation(params) {
|
|
556
|
+
return new GrepToolInvocation(this.config, params);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
530
559
|
//# sourceMappingURL=grep.js.map
|